Lines Matching +full:com +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0
8 * Antti Laakso <antti.laakso@intel.com>
9 * Tianshu Qiu <tian.shu.qiu@intel.com>
10 * Jian Xu Zheng <jian.xu.zheng@intel.com>
11 * Yuning Pu <yuning.pu@intel.com>
29 static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset) in tps68470_gpio_get() argument
32 struct regmap *regmap = tps68470_gpio->tps68470_regmap; in tps68470_gpio_get()
36 if (offset >= TPS68470_N_REGULAR_GPIO) { in tps68470_gpio_get()
37 offset -= TPS68470_N_REGULAR_GPIO; in tps68470_gpio_get()
43 dev_err(tps68470_gpio->gc.parent, "reg 0x%x read failed\n", in tps68470_gpio_get()
47 return !!(val & BIT(offset)); in tps68470_gpio_get()
51 unsigned int offset) in tps68470_gpio_get_direction() argument
54 struct regmap *regmap = tps68470_gpio->tps68470_regmap; in tps68470_gpio_get_direction()
58 if (offset >= TPS68470_N_REGULAR_GPIO) in tps68470_gpio_get_direction()
61 ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val); in tps68470_gpio_get_direction()
63 dev_err(tps68470_gpio->gc.parent, "reg 0x%x read failed\n", in tps68470_gpio_get_direction()
64 TPS68470_GPIO_CTL_REG_A(offset)); in tps68470_gpio_get_direction()
73 static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset, in tps68470_gpio_set() argument
77 struct regmap *regmap = tps68470_gpio->tps68470_regmap; in tps68470_gpio_set()
80 if (offset >= TPS68470_N_REGULAR_GPIO) { in tps68470_gpio_set()
82 offset -= TPS68470_N_REGULAR_GPIO; in tps68470_gpio_set()
85 regmap_update_bits(regmap, reg, BIT(offset), value ? BIT(offset) : 0); in tps68470_gpio_set()
88 static int tps68470_gpio_output(struct gpio_chip *gc, unsigned int offset, in tps68470_gpio_output() argument
92 struct regmap *regmap = tps68470_gpio->tps68470_regmap; in tps68470_gpio_output()
95 tps68470_gpio_set(gc, offset, value); in tps68470_gpio_output()
98 if (offset >= TPS68470_N_REGULAR_GPIO) in tps68470_gpio_output()
101 return regmap_update_bits(regmap, TPS68470_GPIO_CTL_REG_A(offset), in tps68470_gpio_output()
106 static int tps68470_gpio_input(struct gpio_chip *gc, unsigned int offset) in tps68470_gpio_input() argument
109 struct regmap *regmap = tps68470_gpio->tps68470_regmap; in tps68470_gpio_input()
112 if (offset >= TPS68470_N_REGULAR_GPIO) in tps68470_gpio_input()
113 return -EINVAL; in tps68470_gpio_input()
115 return regmap_update_bits(regmap, TPS68470_GPIO_CTL_REG_A(offset), in tps68470_gpio_input()
129 tps68470_gpio = devm_kzalloc(&pdev->dev, sizeof(*tps68470_gpio), in tps68470_gpio_probe()
132 return -ENOMEM; in tps68470_gpio_probe()
134 tps68470_gpio->tps68470_regmap = dev_get_drvdata(pdev->dev.parent); in tps68470_gpio_probe()
135 tps68470_gpio->gc.label = "tps68470-gpio"; in tps68470_gpio_probe()
136 tps68470_gpio->gc.owner = THIS_MODULE; in tps68470_gpio_probe()
137 tps68470_gpio->gc.direction_input = tps68470_gpio_input; in tps68470_gpio_probe()
138 tps68470_gpio->gc.direction_output = tps68470_gpio_output; in tps68470_gpio_probe()
139 tps68470_gpio->gc.get = tps68470_gpio_get; in tps68470_gpio_probe()
140 tps68470_gpio->gc.get_direction = tps68470_gpio_get_direction; in tps68470_gpio_probe()
141 tps68470_gpio->gc.set = tps68470_gpio_set; in tps68470_gpio_probe()
142 tps68470_gpio->gc.can_sleep = true; in tps68470_gpio_probe()
143 tps68470_gpio->gc.names = tps68470_names; in tps68470_gpio_probe()
144 tps68470_gpio->gc.ngpio = TPS68470_N_GPIO; in tps68470_gpio_probe()
145 tps68470_gpio->gc.base = -1; in tps68470_gpio_probe()
146 tps68470_gpio->gc.parent = &pdev->dev; in tps68470_gpio_probe()
148 return devm_gpiochip_add_data(&pdev->dev, &tps68470_gpio->gc, tps68470_gpio); in tps68470_gpio_probe()
153 .name = "tps68470-gpio",
159 MODULE_ALIAS("platform:tps68470-gpio");