Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 172816
b: refs/heads/master
c: 058af1e
h: refs/heads/master
v: v3
  • Loading branch information
Charulatha V authored and Tony Lindgren committed Nov 22, 2009
1 parent 1062810 commit b4c7e38
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: edeae658b282f2d076efb3b3f39ccd8eb0c384fa
refs/heads/master: 058af1ea98675a672ad2aefca035d2e5a228d2cc
32 changes: 32 additions & 0 deletions trunk/arch/arm/plat-omap/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ struct gpio_bank {
spinlock_t lock;
struct gpio_chip chip;
struct clk *dbck;
u32 mod_usage;
};

#define METHOD_MPUIO 0
Expand Down Expand Up @@ -628,6 +629,10 @@ void omap_set_gpio_debounce(int gpio, int enable)
#else
reg += OMAP24XX_GPIO_DEBOUNCE_EN;
#endif
if (!(bank->mod_usage & l)) {
printk(KERN_ERR "GPIO %d not requested\n", gpio);
return;
}

spin_lock_irqsave(&bank->lock, flags);
val = __raw_readl(reg);
Expand Down Expand Up @@ -663,6 +668,11 @@ void omap_set_gpio_debounce_time(int gpio, int enc_time)
bank = get_gpio_bank(gpio);
reg = bank->base;

if (!bank->mod_usage) {
printk(KERN_ERR "GPIO not requested\n");
return;
}

enc_time &= 0xff;
#ifdef CONFIG_ARCH_OMAP4
reg += OMAP4_GPIO_DEBOUNCINGTIME;
Expand Down Expand Up @@ -1144,6 +1154,16 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
__raw_writel(__raw_readl(reg) | (1 << offset), reg);
}
#endif
if (!cpu_class_is_omap1()) {
if (!bank->mod_usage) {
u32 ctrl;
ctrl = __raw_readl(bank->base + OMAP24XX_GPIO_CTRL);
ctrl &= 0xFFFFFFFE;
/* Module is enabled, clocks are not gated */
__raw_writel(ctrl, bank->base + OMAP24XX_GPIO_CTRL);
}
bank->mod_usage |= 1 << offset;
}
spin_unlock_irqrestore(&bank->lock, flags);

return 0;
Expand All @@ -1170,6 +1190,16 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
__raw_writel(1 << offset, reg);
}
#endif
if (!cpu_class_is_omap1()) {
bank->mod_usage &= ~(1 << offset);
if (!bank->mod_usage) {
u32 ctrl;
ctrl = __raw_readl(bank->base + OMAP24XX_GPIO_CTRL);
/* Module is disabled, clocks are gated */
ctrl |= 1;
__raw_writel(ctrl, bank->base + OMAP24XX_GPIO_CTRL);
}
}
_reset_gpio(bank, bank->chip.base + offset);
spin_unlock_irqrestore(&bank->lock, flags);
}
Expand Down Expand Up @@ -1749,6 +1779,8 @@ static int __init _omap_gpio_init(void)
gpio_count = 32;
}
#endif

bank->mod_usage = 0;
/* REVISIT eventually switch from OMAP-specific gpio structs
* over to the generic ones
*/
Expand Down

0 comments on commit b4c7e38

Please sign in to comment.