Lines Matching +full:offset +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0-only
27 static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) in palmas_gpio_get() argument
30 struct palmas *palmas = pg->palmas; in palmas_gpio_get()
34 int gpio16 = (offset/8); in palmas_gpio_get()
36 offset %= 8; in palmas_gpio_get()
41 dev_err(gc->parent, "Reg 0x%02x read failed, %d\n", reg, ret); in palmas_gpio_get()
45 if (val & BIT(offset)) in palmas_gpio_get()
52 dev_err(gc->parent, "Reg 0x%02x read failed, %d\n", reg, ret); in palmas_gpio_get()
55 return !!(val & BIT(offset)); in palmas_gpio_get()
58 static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, in palmas_gpio_set() argument
62 struct palmas *palmas = pg->palmas; in palmas_gpio_set()
65 int gpio16 = (offset/8); in palmas_gpio_set()
67 offset %= 8; in palmas_gpio_set()
75 ret = palmas_write(palmas, PALMAS_GPIO_BASE, reg, BIT(offset)); in palmas_gpio_set()
77 dev_err(gc->parent, "Reg 0x%02x write failed, %d\n", reg, ret); in palmas_gpio_set()
80 static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, in palmas_gpio_output() argument
84 struct palmas *palmas = pg->palmas; in palmas_gpio_output()
87 int gpio16 = (offset/8); in palmas_gpio_output()
89 offset %= 8; in palmas_gpio_output()
93 palmas_gpio_set(gc, offset, value); in palmas_gpio_output()
96 BIT(offset), BIT(offset)); in palmas_gpio_output()
98 dev_err(gc->parent, "Reg 0x%02x update failed, %d\n", reg, in palmas_gpio_output()
103 static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) in palmas_gpio_input() argument
106 struct palmas *palmas = pg->palmas; in palmas_gpio_input()
109 int gpio16 = (offset/8); in palmas_gpio_input()
111 offset %= 8; in palmas_gpio_input()
114 ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE, reg, BIT(offset), 0); in palmas_gpio_input()
116 dev_err(gc->parent, "Reg 0x%02x update failed, %d\n", reg, in palmas_gpio_input()
121 static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset) in palmas_gpio_to_irq() argument
124 struct palmas *palmas = pg->palmas; in palmas_gpio_to_irq()
126 return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset); in palmas_gpio_to_irq()
138 { .compatible = "ti,palmas-gpio", .data = &palmas_dev_data,},
139 { .compatible = "ti,tps65913-gpio", .data = &palmas_dev_data,},
140 { .compatible = "ti,tps65914-gpio", .data = &palmas_dev_data,},
141 { .compatible = "ti,tps80036-gpio", .data = &tps80036_dev_data,},
147 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); in palmas_gpio_probe()
153 dev_data = of_device_get_match_data(&pdev->dev); in palmas_gpio_probe()
157 palmas_gpio = devm_kzalloc(&pdev->dev, in palmas_gpio_probe()
160 return -ENOMEM; in palmas_gpio_probe()
162 palmas_gpio->palmas = palmas; in palmas_gpio_probe()
163 palmas_gpio->gpio_chip.owner = THIS_MODULE; in palmas_gpio_probe()
164 palmas_gpio->gpio_chip.label = dev_name(&pdev->dev); in palmas_gpio_probe()
165 palmas_gpio->gpio_chip.ngpio = dev_data->ngpio; in palmas_gpio_probe()
166 palmas_gpio->gpio_chip.can_sleep = true; in palmas_gpio_probe()
167 palmas_gpio->gpio_chip.direction_input = palmas_gpio_input; in palmas_gpio_probe()
168 palmas_gpio->gpio_chip.direction_output = palmas_gpio_output; in palmas_gpio_probe()
169 palmas_gpio->gpio_chip.to_irq = palmas_gpio_to_irq; in palmas_gpio_probe()
170 palmas_gpio->gpio_chip.set = palmas_gpio_set; in palmas_gpio_probe()
171 palmas_gpio->gpio_chip.get = palmas_gpio_get; in palmas_gpio_probe()
172 palmas_gpio->gpio_chip.parent = &pdev->dev; in palmas_gpio_probe()
174 palmas_gpio->gpio_chip.of_node = pdev->dev.of_node; in palmas_gpio_probe()
176 palmas_pdata = dev_get_platdata(palmas->dev); in palmas_gpio_probe()
177 if (palmas_pdata && palmas_pdata->gpio_base) in palmas_gpio_probe()
178 palmas_gpio->gpio_chip.base = palmas_pdata->gpio_base; in palmas_gpio_probe()
180 palmas_gpio->gpio_chip.base = -1; in palmas_gpio_probe()
182 ret = devm_gpiochip_add_data(&pdev->dev, &palmas_gpio->gpio_chip, in palmas_gpio_probe()
185 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); in palmas_gpio_probe()
194 .driver.name = "palmas-gpio",