Lines Matching refs:sch
29 static unsigned int sch_gpio_offset(struct sch_gpio *sch, unsigned int gpio,
34 if (gpio >= sch->resume_base) {
35 gpio -= sch->resume_base;
42 static unsigned int sch_gpio_bit(struct sch_gpio *sch, unsigned int gpio)
44 if (gpio >= sch->resume_base)
45 gpio -= sch->resume_base;
49 static int sch_gpio_reg_get(struct sch_gpio *sch, unsigned int gpio, unsigned int reg)
54 offset = sch_gpio_offset(sch, gpio, reg);
55 bit = sch_gpio_bit(sch, gpio);
57 reg_val = !!(inb(sch->iobase + offset) & BIT(bit));
62 static void sch_gpio_reg_set(struct sch_gpio *sch, unsigned int gpio, unsigned int reg,
68 offset = sch_gpio_offset(sch, gpio, reg);
69 bit = sch_gpio_bit(sch, gpio);
71 reg_val = inb(sch->iobase + offset);
74 outb(reg_val | BIT(bit), sch->iobase + offset);
76 outb((reg_val & ~BIT(bit)), sch->iobase + offset);
81 struct sch_gpio *sch = gpiochip_get_data(gc);
83 spin_lock(&sch->lock);
84 sch_gpio_reg_set(sch, gpio_num, GIO, 1);
85 spin_unlock(&sch->lock);
91 struct sch_gpio *sch = gpiochip_get_data(gc);
93 return sch_gpio_reg_get(sch, gpio_num, GLV);
98 struct sch_gpio *sch = gpiochip_get_data(gc);
100 spin_lock(&sch->lock);
101 sch_gpio_reg_set(sch, gpio_num, GLV, val);
102 spin_unlock(&sch->lock);
108 struct sch_gpio *sch = gpiochip_get_data(gc);
110 spin_lock(&sch->lock);
111 sch_gpio_reg_set(sch, gpio_num, GIO, 0);
112 spin_unlock(&sch->lock);
129 struct sch_gpio *sch = gpiochip_get_data(gc);
131 if (sch_gpio_reg_get(sch, gpio_num, GIO))
149 struct sch_gpio *sch;
152 sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL);
153 if (!sch)
164 spin_lock_init(&sch->lock);
165 sch->iobase = res->start;
166 sch->chip = sch_gpio_chip;
167 sch->chip.label = dev_name(&pdev->dev);
168 sch->chip.parent = &pdev->dev;
172 sch->resume_base = 10;
173 sch->chip.ngpio = 14;
180 sch_gpio_reg_set(sch, 8, GEN, 1);
181 sch_gpio_reg_set(sch, 9, GEN, 1);
186 sch_gpio_reg_set(sch, 13, GEN, 1);
190 sch->resume_base = 5;
191 sch->chip.ngpio = 14;
195 sch->resume_base = 21;
196 sch->chip.ngpio = 30;
200 sch->resume_base = 2;
201 sch->chip.ngpio = 8;
208 platform_set_drvdata(pdev, sch);
210 return devm_gpiochip_add_data(&pdev->dev, &sch->chip, sch);