24 #include <linux/kernel.h>
31 #include <linux/types.h>
32 #include <linux/slab.h>
34 #define GPIO_MASK(gpio) (0x80000000 >> (gpio))
35 #define GPIO_MASK2(gpio) (0xc0000000 >> ((gpio) * 2))
71 to_ppc4xx_gpiochip(
struct of_mm_gpio_chip *
mm_gc)
76 static int ppc4xx_gpio_get(
struct gpio_chip *
gc,
unsigned int gpio)
78 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
85 __ppc4xx_gpio_set(
struct gpio_chip *
gc,
unsigned int gpio,
int val)
87 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
97 ppc4xx_gpio_set(
struct gpio_chip *gc,
unsigned int gpio,
int val)
99 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
105 __ppc4xx_gpio_set(gc, gpio, val);
107 spin_unlock_irqrestore(&chip->
lock, flags);
109 pr_debug(
"%s: gpio: %d val: %d\n", __func__, gpio, val);
112 static int ppc4xx_gpio_dir_in(
struct gpio_chip *gc,
unsigned int gpio)
114 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
136 spin_unlock_irqrestore(&chip->
lock, flags);
142 ppc4xx_gpio_dir_out(
struct gpio_chip *gc,
unsigned int gpio,
int val)
144 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
152 __ppc4xx_gpio_set(gc, gpio, val);
169 spin_unlock_irqrestore(&chip->
lock, flags);
171 pr_debug(
"%s: gpio: %d val: %d\n", __func__, gpio, val);
176 static int __init ppc4xx_add_gpiochips(
void)
180 for_each_compatible_node(np,
NULL,
"ibm,ppc4xx-gpio") {
183 struct of_mm_gpio_chip *mm_gc;
184 struct gpio_chip *gc;
186 ppc4xx_gc = kzalloc(
sizeof(*ppc4xx_gc),
GFP_KERNEL);
194 mm_gc = &ppc4xx_gc->
mm_gc;
198 gc->direction_input = ppc4xx_gpio_dir_in;
199 gc->direction_output = ppc4xx_gpio_dir_out;
200 gc->get = ppc4xx_gpio_get;
201 gc->set = ppc4xx_gpio_set;
208 pr_err(
"%s: registration failed with status %d\n",