Lines Matching refs:sch
44 static unsigned sch_gpio_offset(struct sch_gpio *sch, unsigned gpio, in sch_gpio_offset() argument
49 if (gpio >= sch->resume_base) { in sch_gpio_offset()
50 gpio -= sch->resume_base; in sch_gpio_offset()
57 static unsigned sch_gpio_bit(struct sch_gpio *sch, unsigned gpio) in sch_gpio_bit() argument
59 if (gpio >= sch->resume_base) in sch_gpio_bit()
60 gpio -= sch->resume_base; in sch_gpio_bit()
64 static int sch_gpio_reg_get(struct sch_gpio *sch, unsigned gpio, unsigned reg) in sch_gpio_reg_get() argument
69 offset = sch_gpio_offset(sch, gpio, reg); in sch_gpio_reg_get()
70 bit = sch_gpio_bit(sch, gpio); in sch_gpio_reg_get()
72 reg_val = !!(inb(sch->iobase + offset) & BIT(bit)); in sch_gpio_reg_get()
77 static void sch_gpio_reg_set(struct sch_gpio *sch, unsigned gpio, unsigned reg, in sch_gpio_reg_set() argument
83 offset = sch_gpio_offset(sch, gpio, reg); in sch_gpio_reg_set()
84 bit = sch_gpio_bit(sch, gpio); in sch_gpio_reg_set()
86 reg_val = inb(sch->iobase + offset); in sch_gpio_reg_set()
89 outb(reg_val | BIT(bit), sch->iobase + offset); in sch_gpio_reg_set()
91 outb((reg_val & ~BIT(bit)), sch->iobase + offset); in sch_gpio_reg_set()
96 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_direction_in() local
98 spin_lock(&sch->lock); in sch_gpio_direction_in()
99 sch_gpio_reg_set(sch, gpio_num, GIO, 1); in sch_gpio_direction_in()
100 spin_unlock(&sch->lock); in sch_gpio_direction_in()
106 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_get() local
107 return sch_gpio_reg_get(sch, gpio_num, GLV); in sch_gpio_get()
112 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_set() local
114 spin_lock(&sch->lock); in sch_gpio_set()
115 sch_gpio_reg_set(sch, gpio_num, GLV, val); in sch_gpio_set()
116 spin_unlock(&sch->lock); in sch_gpio_set()
122 struct sch_gpio *sch = gpiochip_get_data(gc); in sch_gpio_direction_out() local
124 spin_lock(&sch->lock); in sch_gpio_direction_out()
125 sch_gpio_reg_set(sch, gpio_num, GIO, 0); in sch_gpio_direction_out()
126 spin_unlock(&sch->lock); in sch_gpio_direction_out()
152 struct sch_gpio *sch; in sch_gpio_probe() local
155 sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL); in sch_gpio_probe()
156 if (!sch) in sch_gpio_probe()
167 spin_lock_init(&sch->lock); in sch_gpio_probe()
168 sch->iobase = res->start; in sch_gpio_probe()
169 sch->chip = sch_gpio_chip; in sch_gpio_probe()
170 sch->chip.label = dev_name(&pdev->dev); in sch_gpio_probe()
171 sch->chip.parent = &pdev->dev; in sch_gpio_probe()
175 sch->core_base = 0; in sch_gpio_probe()
176 sch->resume_base = 10; in sch_gpio_probe()
177 sch->chip.ngpio = 14; in sch_gpio_probe()
184 sch_gpio_reg_set(sch, 8, GEN, 1); in sch_gpio_probe()
185 sch_gpio_reg_set(sch, 9, GEN, 1); in sch_gpio_probe()
190 sch_gpio_reg_set(sch, 13, GEN, 1); in sch_gpio_probe()
194 sch->core_base = 0; in sch_gpio_probe()
195 sch->resume_base = 5; in sch_gpio_probe()
196 sch->chip.ngpio = 14; in sch_gpio_probe()
200 sch->core_base = 0; in sch_gpio_probe()
201 sch->resume_base = 21; in sch_gpio_probe()
202 sch->chip.ngpio = 30; in sch_gpio_probe()
206 sch->core_base = 0; in sch_gpio_probe()
207 sch->resume_base = 2; in sch_gpio_probe()
208 sch->chip.ngpio = 8; in sch_gpio_probe()
215 platform_set_drvdata(pdev, sch); in sch_gpio_probe()
217 return devm_gpiochip_add_data(&pdev->dev, &sch->chip, sch); in sch_gpio_probe()