17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/slab.h>
20 #include <linux/i2c.h>
23 #define GPIO_GROUP_NUM 2
24 #define GPIO_NUM_PER_GROUP 8
25 #define GPIO_NUM (GPIO_GROUP_NUM*GPIO_NUM_PER_GROUP)
32 static inline struct mc9s08dz60 *to_mc9s08dz60(
struct gpio_chip *
gc)
44 static int mc9s08dz60_get_value(
struct gpio_chip *
gc,
unsigned offset)
50 mc9s_gpio_to_reg_and_bit(offset, ®, &bit);
53 return (value >= 0) ? (value >>
bit) & 0x1 : 0;
56 static int mc9s08dz60_set(
struct mc9s08dz60 *mc9s,
unsigned offset,
int val)
61 mc9s_gpio_to_reg_and_bit(offset, ®, &bit);
76 static void mc9s08dz60_set_value(
struct gpio_chip *gc,
unsigned offset,
int val)
80 mc9s08dz60_set(mc9s, offset, val);
83 static int mc9s08dz60_direction_output(
struct gpio_chip *gc,
84 unsigned offset,
int val)
88 return mc9s08dz60_set(mc9s, offset, val);
101 mc9s->
chip.base = -1;
105 mc9s->
chip.can_sleep = 1;
106 mc9s->
chip.get = mc9s08dz60_get_value;
107 mc9s->
chip.set = mc9s08dz60_set_value;
108 mc9s->
chip.direction_output = mc9s08dz60_direction_output;
110 i2c_set_clientdata(client, mc9s);
115 static int mc9s08dz60_remove(
struct i2c_client *client)
119 mc9s = i2c_get_clientdata(client);
131 static struct i2c_driver mc9s08dz60_i2c_driver = {
134 .name =
"mc9s08dz60",
136 .probe = mc9s08dz60_probe,
137 .remove = mc9s08dz60_remove,
138 .id_table = mc9s08dz60_id,