14 #include <linux/kernel.h>
15 #include <linux/module.h>
23 static uint8_t trout_int_mask[2] = {
27 static uint8_t trout_sleep_int_mask[] = {
38 #define to_msm_gpio_chip(c) container_of(c, struct msm_gpio_chip, chip)
40 static int msm_gpiolib_get(
struct gpio_chip *
chip,
unsigned offset)
48 static void msm_gpiolib_set(
struct gpio_chip *
chip,
unsigned offset,
int val)
61 static int msm_gpiolib_direction_input(
struct gpio_chip *chip,
64 msm_gpiolib_set(chip, offset, 0);
68 static int msm_gpiolib_direction_output(
struct gpio_chip *chip,
69 unsigned offset,
int val)
71 msm_gpiolib_set(chip, offset, val);
75 static int trout_gpio_to_irq(
struct gpio_chip *chip,
unsigned offset)
80 #define TROUT_GPIO_BANK(name, reg_num, base_gpio, shadow_val) \
84 .direction_input = msm_gpiolib_direction_input,\
85 .direction_output = msm_gpiolib_direction_output, \
86 .get = msm_gpiolib_get, \
87 .set = msm_gpiolib_set, \
88 .to_irq = trout_gpio_to_irq, \
92 .reg = (void *) reg_num + TROUT_CPLD_BASE, \
93 .shadow = shadow_val, \
97 #if defined(CONFIG_MSM_DEBUG_UART1)
114 static void trout_gpio_irq_ack(
struct irq_data *
d)
123 static void trout_gpio_irq_mask(
struct irq_data *
d)
132 reg_val = trout_int_mask[bank] |=
mask;
139 static void trout_gpio_irq_unmask(
struct irq_data *
d)
148 reg_val = trout_int_mask[bank] &= ~mask;
163 trout_sleep_int_mask[bank] &= ~mask;
165 trout_sleep_int_mask[bank] |=
mask;
170 static void trout_gpio_irq_handler(
unsigned int irq,
struct irq_desc *
desc)
179 for (bank = 0; bank < 2; bank++) {
182 int_mask = trout_int_mask[bank];
186 "interrupt: %d:%02x\n", bank, v & int_mask);
202 static struct irq_chip trout_gpio_irq_chip = {
204 .irq_ack = trout_gpio_irq_ack,
205 .irq_mask = trout_gpio_irq_mask,
206 .irq_unmask = trout_gpio_irq_unmask,
217 irq_set_chip_and_handler(i, &trout_gpio_irq_chip,
222 for (i = 0; i <
ARRAY_SIZE(msm_gpio_banks); i++)