reg += OMAP730_GPIO_DIR_CONTROL;
break;
}
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (is_input)
l |= 1 << gpio;
else
l &= ~(1 << gpio);
- __raw_writel(l, reg);
+ __raw_writel(l, (void __iomem *)reg);
}
void omap_set_gpio_direction(int gpio, int is_input)
switch (bank->method) {
case METHOD_MPUIO:
reg += OMAP_MPUIO_OUTPUT;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (enable)
l |= 1 << gpio;
else
break;
case METHOD_GPIO_1510:
reg += OMAP1510_GPIO_DATA_OUTPUT;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (enable)
l |= 1 << gpio;
else
break;
case METHOD_GPIO_730:
reg += OMAP730_GPIO_DATA_OUTPUT;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (enable)
l |= 1 << gpio;
else
BUG();
return;
}
- __raw_writel(l, reg);
+ __raw_writel(l, (void __iomem *)reg);
}
void omap_set_gpio_dataout(int gpio, int enable)
BUG();
return -1;
}
- return (__raw_readl(reg) & (1 << get_gpio_index(gpio))) != 0;
+ return (__raw_readl((void __iomem *)reg)
+ & (1 << get_gpio_index(gpio))) != 0;
}
-static void _set_gpio_edge_ctrl(struct gpio_bank *bank, int gpio, int edge)
+static int _set_gpio_edge_ctrl(struct gpio_bank *bank, int gpio, int edge)
{
u32 reg = bank->base;
u32 l;
switch (bank->method) {
case METHOD_MPUIO:
reg += OMAP_MPUIO_GPIO_INT_EDGE;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (edge == OMAP_GPIO_RISING_EDGE)
l |= 1 << gpio;
- else
+ else if (edge == OMAP_GPIO_FALLING_EDGE)
l &= ~(1 << gpio);
- __raw_writel(l, reg);
+ else
+ goto bad;
break;
case METHOD_GPIO_1510:
reg += OMAP1510_GPIO_INT_CONTROL;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (edge == OMAP_GPIO_RISING_EDGE)
l |= 1 << gpio;
- else
+ else if (edge == OMAP_GPIO_FALLING_EDGE)
l &= ~(1 << gpio);
- __raw_writel(l, reg);
+ else
+ goto bad;
break;
case METHOD_GPIO_1610:
edge &= 0x03;
else
reg += OMAP1610_GPIO_EDGE_CTRL1;
gpio &= 0x07;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
l &= ~(3 << (gpio << 1));
l |= edge << (gpio << 1);
- __raw_writel(l, reg);
break;
case METHOD_GPIO_730:
reg += OMAP730_GPIO_INT_CONTROL;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (edge == OMAP_GPIO_RISING_EDGE)
l |= 1 << gpio;
- else
+ else if (edge == OMAP_GPIO_FALLING_EDGE)
l &= ~(1 << gpio);
- __raw_writel(l, reg);
+ else
+ goto bad;
break;
default:
BUG();
- return;
+ goto bad;
}
+ __raw_writel(l, (void __iomem *)reg);
+ return 0;
+bad:
+ return -EINVAL;
+}
+
+static int gpio_irq_type(unsigned irq, unsigned type)
+{
+ struct gpio_bank *bank;
+ unsigned gpio;
+ int retval;
+
+ if (irq > IH_MPUIO_BASE)
+ gpio = OMAP_MPUIO(irq - IH_MPUIO_BASE);
+ else
+ gpio = irq - IH_GPIO_BASE;
+
+ if (check_gpio(gpio) < 0)
+ return -EINVAL;
+
+ /* NOTE: __IRQT_FALEDGE == OMAP_GPIO_FALLING_EDGE,
+ * and __IRQT_RISEDGE == OMAP_GPIO_RISING_EDGE
+ */
+ if (type & (__IRQT_LOWLVL|__IRQT_HIGHLVL|IRQT_PROBE))
+ return -EINVAL;
+
+ bank = get_gpio_bank(gpio);
+ spin_lock(&bank->lock);
+ retval = _set_gpio_edge_ctrl(bank, get_gpio_index(gpio), type);
+ spin_unlock(&bank->lock);
+ return retval;
}
void omap_set_gpio_edge_ctrl(int gpio, int edge)
BUG();
return;
}
- __raw_writel(gpio_mask, reg);
+ __raw_writel(gpio_mask, (void __iomem *)reg);
}
static inline void _clear_gpio_irqstatus(struct gpio_bank *bank, int gpio)
switch (bank->method) {
case METHOD_MPUIO:
reg += OMAP_MPUIO_GPIO_MASKIT;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (enable)
l &= ~(gpio_mask);
else
break;
case METHOD_GPIO_1510:
reg += OMAP1510_GPIO_INT_MASK;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (enable)
l &= ~(gpio_mask);
else
break;
case METHOD_GPIO_730:
reg += OMAP730_GPIO_INT_MASK;
- l = __raw_readl(reg);
+ l = __raw_readl((void __iomem *)reg);
if (enable)
l &= ~(gpio_mask);
else
BUG();
return;
}
- __raw_writel(l, reg);
+ __raw_writel(l, (void __iomem *)reg);
}
static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable)
* enabled. When system is suspended, only selected GPIO interrupts need
* to have wake-up enabled.
*/
-static void _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
+static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
{
switch (bank->method) {
case METHOD_GPIO_1610:
else
bank->suspend_wakeup &= ~(1 << gpio);
spin_unlock(&bank->lock);
- break;
+ return 0;
default:
printk(KERN_ERR "Can't enable GPIO wakeup for method %i\n",
bank->method);
- return;
+ return -EINVAL;
}
}
{
unsigned int gpio = irq - IH_GPIO_BASE;
struct gpio_bank *bank;
+ int retval;
if (check_gpio(gpio) < 0)
return -ENODEV;
bank = get_gpio_bank(gpio);
spin_lock(&bank->lock);
- _set_gpio_wakeup(bank, get_gpio_index(gpio), enable);
+ retval = _set_gpio_wakeup(bank, get_gpio_index(gpio), enable);
spin_unlock(&bank->lock);
- return 0;
+ return retval;
}
int omap_request_gpio(int gpio)
if (bank->method == METHOD_GPIO_1610) {
/* Enable wake-up during idle for dynamic tick */
u32 reg = bank->base + OMAP1610_GPIO_SET_WAKEUPENA;
- __raw_writel(1 << get_gpio_index(gpio), reg);
+ __raw_writel(1 << get_gpio_index(gpio), (void __iomem *)reg);
}
#endif
spin_unlock(&bank->lock);
if (bank->method == METHOD_GPIO_1610) {
/* Disable wake-up during idle for dynamic tick */
u32 reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
- __raw_writel(1 << get_gpio_index(gpio), reg);
+ __raw_writel(1 << get_gpio_index(gpio), (void __iomem *)reg);
}
#endif
bank->reserved_map &= ~(1 << get_gpio_index(gpio));
isr_reg = bank->base + OMAP730_GPIO_INT_STATUS;
#endif
- isr = __raw_readl(isr_reg);
+ isr = __raw_readl((void __iomem *)isr_reg);
_enable_gpio_irqbank(bank, isr, 0);
_clear_gpio_irqbank(bank, isr);
_enable_gpio_irqbank(bank, isr, 1);
.ack = gpio_ack_irq,
.mask = gpio_mask_irq,
.unmask = gpio_unmask_irq,
+ .type = gpio_irq_type,
.wake = gpio_wake_enable,
};
}
#ifdef CONFIG_ARCH_OMAP16XX
-static int omap_gpio_suspend(struct sys_device *dev, u32 state)
+static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
{
int i;