24 #include <linux/kernel.h>
25 #include <linux/slab.h>
26 #include <linux/module.h>
28 #include <linux/device.h>
53 return !!(val &
BIT(offset));
56 static void rc5t583_gpio_set(
struct gpio_chip *gc,
unsigned int offset,
int val)
58 struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc);
66 static int rc5t583_gpio_dir_input(
struct gpio_chip *gc,
unsigned int offset)
68 struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc);
80 static int rc5t583_gpio_dir_output(
struct gpio_chip *gc,
unsigned offset,
83 struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc);
87 rc5t583_gpio_set(gc, offset, value);
96 static int rc5t583_gpio_to_irq(
struct gpio_chip *gc,
unsigned offset)
98 struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc);
100 if ((offset >= 0) && (offset < 8))
101 return rc5t583_gpio->
rc5t583->irq_base +
106 static void rc5t583_gpio_free(
struct gpio_chip *gc,
unsigned offset)
108 struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc);
118 struct rc5t583_gpio *rc5t583_gpio;
123 dev_warn(&pdev->
dev,
"Mem allocation for rc5t583_gpio failed");
127 rc5t583_gpio->
gpio_chip.label =
"gpio-rc5t583",
129 rc5t583_gpio->
gpio_chip.free = rc5t583_gpio_free,
130 rc5t583_gpio->
gpio_chip.direction_input = rc5t583_gpio_dir_input,
131 rc5t583_gpio->
gpio_chip.direction_output = rc5t583_gpio_dir_output,
132 rc5t583_gpio->
gpio_chip.set = rc5t583_gpio_set,
133 rc5t583_gpio->
gpio_chip.get = rc5t583_gpio_get,
134 rc5t583_gpio->
gpio_chip.to_irq = rc5t583_gpio_to_irq,
144 platform_set_drvdata(pdev, rc5t583_gpio);
151 struct rc5t583_gpio *rc5t583_gpio = platform_get_drvdata(pdev);
158 .name =
"rc5t583-gpio",
161 .probe = rc5t583_gpio_probe,
165 static int __init rc5t583_gpio_init(
void)
171 static void __exit rc5t583_gpio_exit(
void)