14 #include <linux/kernel.h>
15 #include <linux/module.h>
21 #define MSP71XX_CFG_OFFSET(gpio) (4 * (gpio))
22 #define CONF_MASK 0x0F
23 #define MSP71XX_GPIO_INPUT 0x01
24 #define MSP71XX_GPIO_OUTPUT 0x08
26 #define MSP71XX_GPIO_BASE 0x0B8400000L
28 #define to_msp71xx_gpio_chip(c) container_of(c, struct msp71xx_gpio_chip, chip)
53 static int msp71xx_gpio_get(
struct gpio_chip *
chip,
unsigned offset)
69 static void msp71xx_gpio_set(
struct gpio_chip *
chip,
unsigned offset,
int value)
84 spin_unlock_irqrestore(&gpio_lock, flags);
95 static int msp71xx_set_gpio_mode(
struct gpio_chip *chip,
96 unsigned offset,
int mode)
110 spin_unlock_irqrestore(&gpio_lock, flags);
124 static int msp71xx_direction_output(
struct gpio_chip *chip,
125 unsigned offset,
int value)
127 msp71xx_gpio_set(chip, offset, value);
139 static int msp71xx_direction_input(
struct gpio_chip *chip,
unsigned offset)
156 if (gpio > 15 || gpio < 0)
165 data &= ~(1 <<
gpio);
168 spin_unlock_irqrestore(&gpio_lock, flags);
174 #define MSP71XX_GPIO_BANK(name, dr, cr, base_gpio, num_gpio) \
178 .direction_input = msp71xx_direction_input, \
179 .direction_output = msp71xx_direction_output, \
180 .get = msp71xx_gpio_get, \
181 .set = msp71xx_gpio_set, \
185 .data_reg = (void __iomem *)(MSP71XX_GPIO_BASE + dr), \
186 .config_reg = (void __iomem *)(MSP71XX_GPIO_BASE + cr), \
187 .out_drive_reg = (void __iomem *)(MSP71XX_GPIO_BASE + 0x190), \
214 for (i = 0; i <
ARRAY_SIZE(msp71xx_gpio_banks); i++)