11 #define pr_fmt(fmt) "sh_pfc " KBUILD_MODNAME ": " fmt
15 #include <linux/slab.h>
17 #include <linux/module.h>
32 static struct sh_pfc *gpio_to_pfc(
struct gpio_chip *
gc)
34 return gpio_to_pfc_chip(gc)->pfc;
37 static int sh_gpio_request(
struct gpio_chip *
gc,
unsigned offset)
42 static void sh_gpio_free(
struct gpio_chip *
gc,
unsigned offset)
47 static void sh_gpio_set_value(
struct sh_pfc *pfc,
unsigned gpio,
int value)
58 static int sh_gpio_get_value(
struct sh_pfc *pfc,
unsigned gpio)
69 static int sh_gpio_direction_input(
struct gpio_chip *
gc,
unsigned offset)
74 static int sh_gpio_direction_output(
struct gpio_chip *
gc,
unsigned offset,
77 sh_gpio_set_value(gpio_to_pfc(gc), offset, value);
82 static int sh_gpio_get(
struct gpio_chip *gc,
unsigned offset)
84 return sh_gpio_get_value(gpio_to_pfc(gc), offset);
87 static void sh_gpio_set(
struct gpio_chip *gc,
unsigned offset,
int value)
89 sh_gpio_set_value(gpio_to_pfc(gc), offset, value);
92 static int sh_gpio_to_irq(
struct gpio_chip *gc,
unsigned offset)
94 struct sh_pfc *pfc = gpio_to_pfc(gc);
103 if (pos <= 0 || !enum_id)
108 for (k = 0; enum_ids[
k]; k++) {
109 if (enum_ids[k] == enum_id)
123 gc->request = sh_gpio_request;
124 gc->free = sh_gpio_free;
125 gc->direction_input = sh_gpio_direction_input;
126 gc->get = sh_gpio_get;
127 gc->direction_output = sh_gpio_direction_output;
128 gc->set = sh_gpio_set;
129 gc->to_irq = sh_gpio_to_irq;
133 gc->label = pfc->
name;
150 sh_pfc_gpio_setup(chip);
156 pr_info(
"%s handling gpio %d -> %d\n",
163 static int sh_pfc_gpio_match(
struct gpio_chip *gc,
void *
data)
165 return !!
strstr(gc->label, data);
171 struct gpio_chip *gc;
175 pr_err(
"Cant find gpio chip\n");
179 chip = gpio_to_pfc_chip(gc);
180 platform_set_drvdata(pdev, chip);
182 pr_info(
"attaching to GPIO chip %s\n", chip->
pfc->name);
189 struct sh_pfc_chip *chip = platform_get_drvdata(pdev);
201 .probe = sh_pfc_gpio_probe,
204 .name = KBUILD_MODNAME,
210 .name = KBUILD_MODNAME,
214 static int __init sh_pfc_gpio_init(
void)
228 static void __exit sh_pfc_gpio_exit(
void)