Lines Matching +full:off +full:- +full:chip
1 // SPDX-License-Identifier: GPL-2.0-only
24 static int adp5585_gpio_get_direction(struct gpio_chip *chip, unsigned int off) in adp5585_gpio_get_direction() argument
26 struct adp5585_gpio_dev *adp5585_gpio = gpiochip_get_data(chip); in adp5585_gpio_get_direction()
27 unsigned int bank = ADP5585_BANK(off); in adp5585_gpio_get_direction()
28 unsigned int bit = ADP5585_BIT(off); in adp5585_gpio_get_direction()
31 regmap_read(adp5585_gpio->regmap, ADP5585_GPIO_DIRECTION_A + bank, &val); in adp5585_gpio_get_direction()
36 static int adp5585_gpio_direction_input(struct gpio_chip *chip, unsigned int off) in adp5585_gpio_direction_input() argument
38 struct adp5585_gpio_dev *adp5585_gpio = gpiochip_get_data(chip); in adp5585_gpio_direction_input()
39 unsigned int bank = ADP5585_BANK(off); in adp5585_gpio_direction_input()
40 unsigned int bit = ADP5585_BIT(off); in adp5585_gpio_direction_input()
42 return regmap_clear_bits(adp5585_gpio->regmap, in adp5585_gpio_direction_input()
46 static int adp5585_gpio_direction_output(struct gpio_chip *chip, unsigned int off, int val) in adp5585_gpio_direction_output() argument
48 struct adp5585_gpio_dev *adp5585_gpio = gpiochip_get_data(chip); in adp5585_gpio_direction_output()
49 unsigned int bank = ADP5585_BANK(off); in adp5585_gpio_direction_output()
50 unsigned int bit = ADP5585_BIT(off); in adp5585_gpio_direction_output()
53 ret = regmap_update_bits(adp5585_gpio->regmap, in adp5585_gpio_direction_output()
59 return regmap_set_bits(adp5585_gpio->regmap, in adp5585_gpio_direction_output()
63 static int adp5585_gpio_get_value(struct gpio_chip *chip, unsigned int off) in adp5585_gpio_get_value() argument
65 struct adp5585_gpio_dev *adp5585_gpio = gpiochip_get_data(chip); in adp5585_gpio_get_value()
66 unsigned int bank = ADP5585_BANK(off); in adp5585_gpio_get_value()
67 unsigned int bit = ADP5585_BIT(off); in adp5585_gpio_get_value()
82 regmap_read(adp5585_gpio->regmap, ADP5585_GPIO_DIRECTION_A + bank, &val); in adp5585_gpio_get_value()
84 regmap_read(adp5585_gpio->regmap, reg + bank, &val); in adp5585_gpio_get_value()
89 static void adp5585_gpio_set_value(struct gpio_chip *chip, unsigned int off, int val) in adp5585_gpio_set_value() argument
91 struct adp5585_gpio_dev *adp5585_gpio = gpiochip_get_data(chip); in adp5585_gpio_set_value()
92 unsigned int bank = ADP5585_BANK(off); in adp5585_gpio_set_value()
93 unsigned int bit = ADP5585_BIT(off); in adp5585_gpio_set_value()
95 regmap_update_bits(adp5585_gpio->regmap, ADP5585_GPO_DATA_OUT_A + bank, in adp5585_gpio_set_value()
100 unsigned int off, unsigned int bias) in adp5585_gpio_set_bias() argument
109 bit = off * 2 + (off > 5 ? 4 : 0); in adp5585_gpio_set_bias()
114 return regmap_update_bits(adp5585_gpio->regmap, reg, mask, val); in adp5585_gpio_set_bias()
118 unsigned int off, enum pin_config_param drive) in adp5585_gpio_set_drive() argument
120 unsigned int bank = ADP5585_BANK(off); in adp5585_gpio_set_drive()
121 unsigned int bit = ADP5585_BIT(off); in adp5585_gpio_set_drive()
123 return regmap_update_bits(adp5585_gpio->regmap, in adp5585_gpio_set_drive()
129 unsigned int off, unsigned int debounce) in adp5585_gpio_set_debounce() argument
131 unsigned int bank = ADP5585_BANK(off); in adp5585_gpio_set_debounce()
132 unsigned int bit = ADP5585_BIT(off); in adp5585_gpio_set_debounce()
134 return regmap_update_bits(adp5585_gpio->regmap, in adp5585_gpio_set_debounce()
139 static int adp5585_gpio_set_config(struct gpio_chip *chip, unsigned int off, in adp5585_gpio_set_config() argument
142 struct adp5585_gpio_dev *adp5585_gpio = gpiochip_get_data(chip); in adp5585_gpio_set_config()
148 return adp5585_gpio_set_bias(adp5585_gpio, off, in adp5585_gpio_set_config()
152 return adp5585_gpio_set_bias(adp5585_gpio, off, arg ? in adp5585_gpio_set_config()
157 return adp5585_gpio_set_bias(adp5585_gpio, off, arg ? in adp5585_gpio_set_config()
163 return adp5585_gpio_set_drive(adp5585_gpio, off, param); in adp5585_gpio_set_config()
166 return adp5585_gpio_set_debounce(adp5585_gpio, off, arg); in adp5585_gpio_set_config()
169 return -ENOTSUPP; in adp5585_gpio_set_config()
175 struct adp5585_dev *adp5585 = dev_get_drvdata(pdev->dev.parent); in adp5585_gpio_probe()
177 struct device *dev = &pdev->dev; in adp5585_gpio_probe()
183 return -ENOMEM; in adp5585_gpio_probe()
185 adp5585_gpio->regmap = adp5585->regmap; in adp5585_gpio_probe()
187 device_set_of_node_from_dev(dev, dev->parent); in adp5585_gpio_probe()
189 gc = &adp5585_gpio->gpio_chip; in adp5585_gpio_probe()
190 gc->parent = dev; in adp5585_gpio_probe()
191 gc->get_direction = adp5585_gpio_get_direction; in adp5585_gpio_probe()
192 gc->direction_input = adp5585_gpio_direction_input; in adp5585_gpio_probe()
193 gc->direction_output = adp5585_gpio_direction_output; in adp5585_gpio_probe()
194 gc->get = adp5585_gpio_get_value; in adp5585_gpio_probe()
195 gc->set = adp5585_gpio_set_value; in adp5585_gpio_probe()
196 gc->set_config = adp5585_gpio_set_config; in adp5585_gpio_probe()
197 gc->can_sleep = true; in adp5585_gpio_probe()
199 gc->base = -1; in adp5585_gpio_probe()
200 gc->ngpio = ADP5585_GPIO_MAX; in adp5585_gpio_probe()
201 gc->label = pdev->name; in adp5585_gpio_probe()
202 gc->owner = THIS_MODULE; in adp5585_gpio_probe()
204 ret = devm_gpiochip_add_data(dev, &adp5585_gpio->gpio_chip, in adp5585_gpio_probe()
207 return dev_err_probe(dev, ret, "failed to add GPIO chip\n"); in adp5585_gpio_probe()
213 { "adp5585-gpio" },
220 .name = "adp5585-gpio",