Lines Matching +full:off +full:- +full:chip
6 * Licensed under the GPL-2 or later.
24 static int adp5520_gpio_get_value(struct gpio_chip *chip, unsigned off) in adp5520_gpio_get_value() argument
29 dev = gpiochip_get_data(chip); in adp5520_gpio_get_value()
36 if (test_bit(off, &dev->output)) in adp5520_gpio_get_value()
37 adp5520_read(dev->master, ADP5520_GPIO_OUT, ®_val); in adp5520_gpio_get_value()
39 adp5520_read(dev->master, ADP5520_GPIO_IN, ®_val); in adp5520_gpio_get_value()
41 return !!(reg_val & dev->lut[off]); in adp5520_gpio_get_value()
44 static void adp5520_gpio_set_value(struct gpio_chip *chip, in adp5520_gpio_set_value() argument
45 unsigned off, int val) in adp5520_gpio_set_value() argument
48 dev = gpiochip_get_data(chip); in adp5520_gpio_set_value()
51 adp5520_set_bits(dev->master, ADP5520_GPIO_OUT, dev->lut[off]); in adp5520_gpio_set_value()
53 adp5520_clr_bits(dev->master, ADP5520_GPIO_OUT, dev->lut[off]); in adp5520_gpio_set_value()
56 static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off) in adp5520_gpio_direction_input() argument
59 dev = gpiochip_get_data(chip); in adp5520_gpio_direction_input()
61 clear_bit(off, &dev->output); in adp5520_gpio_direction_input()
63 return adp5520_clr_bits(dev->master, ADP5520_GPIO_CFG_2, in adp5520_gpio_direction_input()
64 dev->lut[off]); in adp5520_gpio_direction_input()
67 static int adp5520_gpio_direction_output(struct gpio_chip *chip, in adp5520_gpio_direction_output() argument
68 unsigned off, int val) in adp5520_gpio_direction_output() argument
72 dev = gpiochip_get_data(chip); in adp5520_gpio_direction_output()
74 set_bit(off, &dev->output); in adp5520_gpio_direction_output()
77 ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_OUT, in adp5520_gpio_direction_output()
78 dev->lut[off]); in adp5520_gpio_direction_output()
80 ret |= adp5520_clr_bits(dev->master, ADP5520_GPIO_OUT, in adp5520_gpio_direction_output()
81 dev->lut[off]); in adp5520_gpio_direction_output()
83 ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_CFG_2, in adp5520_gpio_direction_output()
84 dev->lut[off]); in adp5520_gpio_direction_output()
91 struct adp5520_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); in adp5520_gpio_probe()
98 dev_err(&pdev->dev, "missing platform data\n"); in adp5520_gpio_probe()
99 return -ENODEV; in adp5520_gpio_probe()
102 if (pdev->id != ID_ADP5520) { in adp5520_gpio_probe()
103 dev_err(&pdev->dev, "only ADP5520 supports GPIO\n"); in adp5520_gpio_probe()
104 return -ENODEV; in adp5520_gpio_probe()
107 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); in adp5520_gpio_probe()
109 return -ENOMEM; in adp5520_gpio_probe()
111 dev->master = pdev->dev.parent; in adp5520_gpio_probe()
114 if (pdata->gpio_en_mask & (1 << i)) in adp5520_gpio_probe()
115 dev->lut[gpios++] = 1 << i; in adp5520_gpio_probe()
118 ret = -EINVAL; in adp5520_gpio_probe()
122 gc = &dev->gpio_chip; in adp5520_gpio_probe()
123 gc->direction_input = adp5520_gpio_direction_input; in adp5520_gpio_probe()
124 gc->direction_output = adp5520_gpio_direction_output; in adp5520_gpio_probe()
125 gc->get = adp5520_gpio_get_value; in adp5520_gpio_probe()
126 gc->set = adp5520_gpio_set_value; in adp5520_gpio_probe()
127 gc->can_sleep = true; in adp5520_gpio_probe()
129 gc->base = pdata->gpio_start; in adp5520_gpio_probe()
130 gc->ngpio = gpios; in adp5520_gpio_probe()
131 gc->label = pdev->name; in adp5520_gpio_probe()
132 gc->owner = THIS_MODULE; in adp5520_gpio_probe()
134 ret = adp5520_clr_bits(dev->master, ADP5520_GPIO_CFG_1, in adp5520_gpio_probe()
135 pdata->gpio_en_mask); in adp5520_gpio_probe()
137 if (pdata->gpio_en_mask & ADP5520_GPIO_C3) in adp5520_gpio_probe()
140 if (pdata->gpio_en_mask & ADP5520_GPIO_R3) in adp5520_gpio_probe()
144 ret = adp5520_set_bits(dev->master, ADP5520_LED_CONTROL, in adp5520_gpio_probe()
147 ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_PULLUP, in adp5520_gpio_probe()
148 pdata->gpio_pullup_mask); in adp5520_gpio_probe()
151 dev_err(&pdev->dev, "failed to write\n"); in adp5520_gpio_probe()
155 ret = devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev); in adp5520_gpio_probe()
168 .name = "adp5520-gpio",
178 MODULE_ALIAS("platform:adp5520-gpio");