Lines Matching refs:sch
51 static unsigned int sch_gpio_offset(struct sch_gpio *sch, unsigned int gpio, in sch_gpio_offset() argument
56 if (gpio >= sch->resume_base) { in sch_gpio_offset()
57 gpio -= sch->resume_base; in sch_gpio_offset()
64 static unsigned int sch_gpio_bit(struct sch_gpio *sch, unsigned int gpio) in sch_gpio_bit() argument
66 if (gpio >= sch->resume_base) in sch_gpio_bit()
67 gpio -= sch->resume_base; in sch_gpio_bit()
71 static int sch_gpio_reg_get(struct sch_gpio *sch, unsigned int gpio, unsigned int reg) in sch_gpio_reg_get() argument
76 offset = sch_gpio_offset(sch, gpio, reg); in sch_gpio_reg_get()
77 bit = sch_gpio_bit(sch, gpio); in sch_gpio_reg_get()
79 reg_val = !!(inb(sch->iobase + offset) & BIT(bit)); in sch_gpio_reg_get()
84 static void sch_gpio_reg_set(struct sch_gpio *sch, unsigned int gpio, unsigned int reg, in sch_gpio_reg_set() argument
90 offset = sch_gpio_offset(sch, gpio, reg); in sch_gpio_reg_set()
91 bit = sch_gpio_bit(sch, gpio); in sch_gpio_reg_set()
93 reg_val = inb(sch->iobase + offset); in sch_gpio_reg_set()
96 outb(reg_val | BIT(bit), sch->iobase + offset); in sch_gpio_reg_set()
98 outb((reg_val & ~BIT(bit)), sch->iobase + offset); in sch_gpio_reg_set()
103 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_direction_in() local
106 spin_lock_irqsave(&sch->lock, flags); in sch_gpio_direction_in()
107 sch_gpio_reg_set(sch, gpio_num, GIO, 1); in sch_gpio_direction_in()
108 spin_unlock_irqrestore(&sch->lock, flags); in sch_gpio_direction_in()
114 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_get() local
116 return sch_gpio_reg_get(sch, gpio_num, GLV); in sch_gpio_get()
121 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_set() local
124 spin_lock_irqsave(&sch->lock, flags); in sch_gpio_set()
125 sch_gpio_reg_set(sch, gpio_num, GLV, val); in sch_gpio_set()
126 spin_unlock_irqrestore(&sch->lock, flags); in sch_gpio_set()
132 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_direction_out() local
135 spin_lock_irqsave(&sch->lock, flags); in sch_gpio_direction_out()
136 sch_gpio_reg_set(sch, gpio_num, GIO, 0); in sch_gpio_direction_out()
137 spin_unlock_irqrestore(&sch->lock, flags); in sch_gpio_direction_out()
154 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_get_direction() local
156 if (sch_gpio_reg_get(sch, gpio_num, GIO)) in sch_gpio_get_direction()
175 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_irq_type() local
197 spin_lock_irqsave(&sch->lock, flags); in sch_irq_type()
199 sch_gpio_reg_set(sch, gpio_num, GTPE, rising); in sch_irq_type()
200 sch_gpio_reg_set(sch, gpio_num, GTNE, falling); in sch_irq_type()
204 spin_unlock_irqrestore(&sch->lock, flags); in sch_irq_type()
212 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_irq_ack() local
216 spin_lock_irqsave(&sch->lock, flags); in sch_irq_ack()
217 sch_gpio_reg_set(sch, gpio_num, GTS, 1); in sch_irq_ack()
218 spin_unlock_irqrestore(&sch->lock, flags); in sch_irq_ack()
224 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_irq_mask_unmask() local
228 spin_lock_irqsave(&sch->lock, flags); in sch_irq_mask_unmask()
229 sch_gpio_reg_set(sch, gpio_num, GGPE, val); in sch_irq_mask_unmask()
230 spin_unlock_irqrestore(&sch->lock, flags); in sch_irq_mask_unmask()
245 struct sch_gpio *sch = context; in sch_gpio_gpe_handler() local
246 struct gpio_chip *gc = &sch->chip; in sch_gpio_gpe_handler()
253 spin_lock_irqsave(&sch->lock, flags); in sch_gpio_gpe_handler()
255 core_status = inl(sch->iobase + CORE_BANK_OFFSET + GTS); in sch_gpio_gpe_handler()
256 resume_status = inl(sch->iobase + RESUME_BANK_OFFSET + GTS); in sch_gpio_gpe_handler()
258 spin_unlock_irqrestore(&sch->lock, flags); in sch_gpio_gpe_handler()
260 pending = (resume_status << sch->resume_base) | core_status; in sch_gpio_gpe_handler()
261 for_each_set_bit(offset, &pending, sch->chip.ngpio) in sch_gpio_gpe_handler()
275 struct sch_gpio *sch = data; in sch_gpio_remove_gpe_handler() local
277 acpi_disable_gpe(NULL, sch->gpe); in sch_gpio_remove_gpe_handler()
278 acpi_remove_gpe_handler(NULL, sch->gpe, sch->gpe_handler); in sch_gpio_remove_gpe_handler()
281 static int sch_gpio_install_gpe_handler(struct sch_gpio *sch) in sch_gpio_install_gpe_handler() argument
283 struct device *dev = sch->chip.parent; in sch_gpio_install_gpe_handler()
286 status = acpi_install_gpe_handler(NULL, sch->gpe, ACPI_GPE_LEVEL_TRIGGERED, in sch_gpio_install_gpe_handler()
287 sch->gpe_handler, sch); in sch_gpio_install_gpe_handler()
290 sch->gpe, acpi_format_exception(status)); in sch_gpio_install_gpe_handler()
294 status = acpi_enable_gpe(NULL, sch->gpe); in sch_gpio_install_gpe_handler()
297 sch->gpe, acpi_format_exception(status)); in sch_gpio_install_gpe_handler()
298 acpi_remove_gpe_handler(NULL, sch->gpe, sch->gpe_handler); in sch_gpio_install_gpe_handler()
302 return devm_add_action_or_reset(dev, sch_gpio_remove_gpe_handler, sch); in sch_gpio_install_gpe_handler()
308 struct sch_gpio *sch; in sch_gpio_probe() local
312 sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL); in sch_gpio_probe()
313 if (!sch) in sch_gpio_probe()
324 spin_lock_init(&sch->lock); in sch_gpio_probe()
325 sch->iobase = res->start; in sch_gpio_probe()
326 sch->chip = sch_gpio_chip; in sch_gpio_probe()
327 sch->chip.label = dev_name(&pdev->dev); in sch_gpio_probe()
328 sch->chip.parent = &pdev->dev; in sch_gpio_probe()
332 sch->resume_base = 10; in sch_gpio_probe()
333 sch->chip.ngpio = 14; in sch_gpio_probe()
340 sch_gpio_reg_set(sch, 8, GEN, 1); in sch_gpio_probe()
341 sch_gpio_reg_set(sch, 9, GEN, 1); in sch_gpio_probe()
346 sch_gpio_reg_set(sch, 13, GEN, 1); in sch_gpio_probe()
350 sch->resume_base = 5; in sch_gpio_probe()
351 sch->chip.ngpio = 14; in sch_gpio_probe()
355 sch->resume_base = 21; in sch_gpio_probe()
356 sch->chip.ngpio = 30; in sch_gpio_probe()
360 sch->resume_base = 2; in sch_gpio_probe()
361 sch->chip.ngpio = 8; in sch_gpio_probe()
368 platform_set_drvdata(pdev, sch); in sch_gpio_probe()
370 sch->irqchip.name = "sch_gpio"; in sch_gpio_probe()
371 sch->irqchip.irq_ack = sch_irq_ack; in sch_gpio_probe()
372 sch->irqchip.irq_mask = sch_irq_mask; in sch_gpio_probe()
373 sch->irqchip.irq_unmask = sch_irq_unmask; in sch_gpio_probe()
374 sch->irqchip.irq_set_type = sch_irq_type; in sch_gpio_probe()
376 girq = &sch->chip.irq; in sch_gpio_probe()
377 girq->chip = &sch->irqchip; in sch_gpio_probe()
385 sch->gpe = GPE0E_GPIO; in sch_gpio_probe()
386 sch->gpe_handler = sch_gpio_gpe_handler; in sch_gpio_probe()
388 ret = sch_gpio_install_gpe_handler(sch); in sch_gpio_probe()
392 return devm_gpiochip_add_data(&pdev->dev, &sch->chip, sch); in sch_gpio_probe()