mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
Via Paul Walmsley <[email protected]>:
Move some of the OMAP2+ CM and System Control Module direct register accesses into CM- and System Control Module-specific "drivers" underneath arch/arm/mach-omap2/. This is a prerequisite for moving this code out of arch/arm/mach-omap2/ into drivers/. Basic test logs are available here: http://www.pwsan.com/omap/testlogs/cm_scm_cleanup_a_v3.13/20131019101809/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) iQIcBAABAgAGBQJSZAZXAAoJEBvUPslcq6VzCWQQAKH4Rj0izwbbLkgBAeeaQz5K oJgPJ6UPLOJ2uLIUauCKUSR6+nktrCTfV8P+J4DhCc6OiGrKBXJhSETPgaTbWsNw Bd577pmuvXSfNFXUaLwCgkSmafJ1pi6d7kEx/7ZW3TziVE/aUxyeHkrMtWJHrjTP 28tJVieOxLlO5iK06DfmGcCpLUBKJKtgGRo0h/oqMhLAaN5S8//lyVYgdsto7oCN /bes6OpuVVdKiSr78V4rCVtR5Lij5+lVrT8HDiw2BA0V3bYcI7+CVlWBPZ3mYkuy oAJDcn9whNyfWS+SsaTIjy6nHsgQkhEJnhrQW3k2skVZobRtWDv7U5LiTjsUhb3o pjyWD8zZ7jqrkgyLsai6dm1zsljMQXsIQwH5h++HdCRhtNOXd6bVQZy0KqkpLu0y Bhpt8/edh4Bdc305oB05/Y9Uxr7Gr8M377chVZx+JD3rxIDjRRyOJcRIhd27WZEf HSMLpO/ayUXWdDuTlKW0IEnImx3PrxT913cnjIY589FhfdahfGQoft4sWDeiQLAX +zVYZljeY+GxbUWO6aY4m2PfVN9p/Hwal58NZZgj59wq9iHUuJErK11X7rj+2vwN +20IS8sikz6Iym84iC0T+omUeFVY0Zo004DVvpPB+D1C2LpwdI1c6kTz4DYT1EBP pvs8Wihkk7xQxQn0rBGP =L37r -----END PGP SIGNATURE----- Merge tag 'omap-for-v3.13/cm-scm-cleanup-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/cleanup From Paul Walmsley <[email protected]> via Tony Lindgren: Move some of the OMAP2+ CM and System Control Module direct register accesses into CM- and System Control Module-specific "drivers" underneath arch/arm/mach-omap2/. This is a prerequisite for moving this code out of arch/arm/mach-omap2/ into drivers/. Basic test logs are available here: http://www.pwsan.com/omap/testlogs/cm_scm_cleanup_a_v3.13/20131019101809/ * tag 'omap-for-v3.13/cm-scm-cleanup-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: ARM: OMAP3: control: add API for setting IVA bootmode ARM: OMAP3: CM/control: move CM scratchpad save to CM driver ARM: OMAP3: McBSP: do not access CM register directly ARM: OMAP3: clock: add API to enable/disable autoidle for a single clock ARM: OMAP2: CM/PM: remove direct register accesses outside CM code + Linux 3.12-rc4 Signed-off-by: Olof Johansson <[email protected]>
This commit is contained in:
commit
43d93947a5
539 changed files with 5293 additions and 3065 deletions
|
|
@ -63,6 +63,7 @@ struct gpio_bank {
|
|||
struct gpio_chip chip;
|
||||
struct clk *dbck;
|
||||
u32 mod_usage;
|
||||
u32 irq_usage;
|
||||
u32 dbck_enable_mask;
|
||||
bool dbck_enabled;
|
||||
struct device *dev;
|
||||
|
|
@ -86,6 +87,9 @@ struct gpio_bank {
|
|||
#define GPIO_BIT(bank, gpio) (1 << GPIO_INDEX(bank, gpio))
|
||||
#define GPIO_MOD_CTRL_BIT BIT(0)
|
||||
|
||||
#define BANK_USED(bank) (bank->mod_usage || bank->irq_usage)
|
||||
#define LINE_USED(line, offset) (line & (1 << offset))
|
||||
|
||||
static int irq_to_gpio(struct gpio_bank *bank, unsigned int gpio_irq)
|
||||
{
|
||||
return bank->chip.base + gpio_irq;
|
||||
|
|
@ -420,15 +424,69 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void _enable_gpio_module(struct gpio_bank *bank, unsigned offset)
|
||||
{
|
||||
if (bank->regs->pinctrl) {
|
||||
void __iomem *reg = bank->base + bank->regs->pinctrl;
|
||||
|
||||
/* Claim the pin for MPU */
|
||||
__raw_writel(__raw_readl(reg) | (1 << offset), reg);
|
||||
}
|
||||
|
||||
if (bank->regs->ctrl && !BANK_USED(bank)) {
|
||||
void __iomem *reg = bank->base + bank->regs->ctrl;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = __raw_readl(reg);
|
||||
/* Module is enabled, clocks are not gated */
|
||||
ctrl &= ~GPIO_MOD_CTRL_BIT;
|
||||
__raw_writel(ctrl, reg);
|
||||
bank->context.ctrl = ctrl;
|
||||
}
|
||||
}
|
||||
|
||||
static void _disable_gpio_module(struct gpio_bank *bank, unsigned offset)
|
||||
{
|
||||
void __iomem *base = bank->base;
|
||||
|
||||
if (bank->regs->wkup_en &&
|
||||
!LINE_USED(bank->mod_usage, offset) &&
|
||||
!LINE_USED(bank->irq_usage, offset)) {
|
||||
/* Disable wake-up during idle for dynamic tick */
|
||||
_gpio_rmw(base, bank->regs->wkup_en, 1 << offset, 0);
|
||||
bank->context.wake_en =
|
||||
__raw_readl(bank->base + bank->regs->wkup_en);
|
||||
}
|
||||
|
||||
if (bank->regs->ctrl && !BANK_USED(bank)) {
|
||||
void __iomem *reg = bank->base + bank->regs->ctrl;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = __raw_readl(reg);
|
||||
/* Module is disabled, clocks are gated */
|
||||
ctrl |= GPIO_MOD_CTRL_BIT;
|
||||
__raw_writel(ctrl, reg);
|
||||
bank->context.ctrl = ctrl;
|
||||
}
|
||||
}
|
||||
|
||||
static int gpio_is_input(struct gpio_bank *bank, int mask)
|
||||
{
|
||||
void __iomem *reg = bank->base + bank->regs->direction;
|
||||
|
||||
return __raw_readl(reg) & mask;
|
||||
}
|
||||
|
||||
static int gpio_irq_type(struct irq_data *d, unsigned type)
|
||||
{
|
||||
struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
|
||||
unsigned gpio = 0;
|
||||
int retval;
|
||||
unsigned long flags;
|
||||
unsigned offset;
|
||||
|
||||
if (WARN_ON(!bank->mod_usage))
|
||||
return -EINVAL;
|
||||
if (!BANK_USED(bank))
|
||||
pm_runtime_get_sync(bank->dev);
|
||||
|
||||
#ifdef CONFIG_ARCH_OMAP1
|
||||
if (d->irq > IH_MPUIO_BASE)
|
||||
|
|
@ -446,7 +504,17 @@ static int gpio_irq_type(struct irq_data *d, unsigned type)
|
|||
return -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&bank->lock, flags);
|
||||
retval = _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), type);
|
||||
offset = GPIO_INDEX(bank, gpio);
|
||||
retval = _set_gpio_triggering(bank, offset, type);
|
||||
if (!LINE_USED(bank->mod_usage, offset)) {
|
||||
_enable_gpio_module(bank, offset);
|
||||
_set_gpio_direction(bank, offset, 1);
|
||||
} else if (!gpio_is_input(bank, 1 << offset)) {
|
||||
spin_unlock_irqrestore(&bank->lock, flags);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bank->irq_usage |= 1 << GPIO_INDEX(bank, gpio);
|
||||
spin_unlock_irqrestore(&bank->lock, flags);
|
||||
|
||||
if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
|
||||
|
|
@ -603,35 +671,19 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
|
|||
* If this is the first gpio_request for the bank,
|
||||
* enable the bank module.
|
||||
*/
|
||||
if (!bank->mod_usage)
|
||||
if (!BANK_USED(bank))
|
||||
pm_runtime_get_sync(bank->dev);
|
||||
|
||||
spin_lock_irqsave(&bank->lock, flags);
|
||||
/* Set trigger to none. You need to enable the desired trigger with
|
||||
* request_irq() or set_irq_type().
|
||||
* request_irq() or set_irq_type(). Only do this if the IRQ line has
|
||||
* not already been requested.
|
||||
*/
|
||||
_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
|
||||
|
||||
if (bank->regs->pinctrl) {
|
||||
void __iomem *reg = bank->base + bank->regs->pinctrl;
|
||||
|
||||
/* Claim the pin for MPU */
|
||||
__raw_writel(__raw_readl(reg) | (1 << offset), reg);
|
||||
if (!LINE_USED(bank->irq_usage, offset)) {
|
||||
_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
|
||||
_enable_gpio_module(bank, offset);
|
||||
}
|
||||
|
||||
if (bank->regs->ctrl && !bank->mod_usage) {
|
||||
void __iomem *reg = bank->base + bank->regs->ctrl;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = __raw_readl(reg);
|
||||
/* Module is enabled, clocks are not gated */
|
||||
ctrl &= ~GPIO_MOD_CTRL_BIT;
|
||||
__raw_writel(ctrl, reg);
|
||||
bank->context.ctrl = ctrl;
|
||||
}
|
||||
|
||||
bank->mod_usage |= 1 << offset;
|
||||
|
||||
spin_unlock_irqrestore(&bank->lock, flags);
|
||||
|
||||
return 0;
|
||||
|
|
@ -640,31 +692,11 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
|
|||
static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
|
||||
void __iomem *base = bank->base;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bank->lock, flags);
|
||||
|
||||
if (bank->regs->wkup_en) {
|
||||
/* Disable wake-up during idle for dynamic tick */
|
||||
_gpio_rmw(base, bank->regs->wkup_en, 1 << offset, 0);
|
||||
bank->context.wake_en =
|
||||
__raw_readl(bank->base + bank->regs->wkup_en);
|
||||
}
|
||||
|
||||
bank->mod_usage &= ~(1 << offset);
|
||||
|
||||
if (bank->regs->ctrl && !bank->mod_usage) {
|
||||
void __iomem *reg = bank->base + bank->regs->ctrl;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = __raw_readl(reg);
|
||||
/* Module is disabled, clocks are gated */
|
||||
ctrl |= GPIO_MOD_CTRL_BIT;
|
||||
__raw_writel(ctrl, reg);
|
||||
bank->context.ctrl = ctrl;
|
||||
}
|
||||
|
||||
_disable_gpio_module(bank, offset);
|
||||
_reset_gpio(bank, bank->chip.base + offset);
|
||||
spin_unlock_irqrestore(&bank->lock, flags);
|
||||
|
||||
|
|
@ -672,7 +704,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
|
|||
* If this is the last gpio to be freed in the bank,
|
||||
* disable the bank module.
|
||||
*/
|
||||
if (!bank->mod_usage)
|
||||
if (!BANK_USED(bank))
|
||||
pm_runtime_put(bank->dev);
|
||||
}
|
||||
|
||||
|
|
@ -762,10 +794,20 @@ static void gpio_irq_shutdown(struct irq_data *d)
|
|||
struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
|
||||
unsigned int gpio = irq_to_gpio(bank, d->hwirq);
|
||||
unsigned long flags;
|
||||
unsigned offset = GPIO_INDEX(bank, gpio);
|
||||
|
||||
spin_lock_irqsave(&bank->lock, flags);
|
||||
bank->irq_usage &= ~(1 << offset);
|
||||
_disable_gpio_module(bank, offset);
|
||||
_reset_gpio(bank, gpio);
|
||||
spin_unlock_irqrestore(&bank->lock, flags);
|
||||
|
||||
/*
|
||||
* If this is the last IRQ to be freed in the bank,
|
||||
* disable the bank module.
|
||||
*/
|
||||
if (!BANK_USED(bank))
|
||||
pm_runtime_put(bank->dev);
|
||||
}
|
||||
|
||||
static void gpio_ack_irq(struct irq_data *d)
|
||||
|
|
@ -897,13 +939,6 @@ static int gpio_input(struct gpio_chip *chip, unsigned offset)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_is_input(struct gpio_bank *bank, int mask)
|
||||
{
|
||||
void __iomem *reg = bank->base + bank->regs->direction;
|
||||
|
||||
return __raw_readl(reg) & mask;
|
||||
}
|
||||
|
||||
static int gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
struct gpio_bank *bank;
|
||||
|
|
@ -922,13 +957,22 @@ static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
|
|||
{
|
||||
struct gpio_bank *bank;
|
||||
unsigned long flags;
|
||||
int retval = 0;
|
||||
|
||||
bank = container_of(chip, struct gpio_bank, chip);
|
||||
spin_lock_irqsave(&bank->lock, flags);
|
||||
|
||||
if (LINE_USED(bank->irq_usage, offset)) {
|
||||
retval = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
bank->set_dataout(bank, offset, value);
|
||||
_set_gpio_direction(bank, offset, 0);
|
||||
|
||||
exit:
|
||||
spin_unlock_irqrestore(&bank->lock, flags);
|
||||
return 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int gpio_debounce(struct gpio_chip *chip, unsigned offset,
|
||||
|
|
@ -1400,7 +1444,7 @@ void omap2_gpio_prepare_for_idle(int pwr_mode)
|
|||
struct gpio_bank *bank;
|
||||
|
||||
list_for_each_entry(bank, &omap_gpio_list, node) {
|
||||
if (!bank->mod_usage || !bank->loses_context)
|
||||
if (!BANK_USED(bank) || !bank->loses_context)
|
||||
continue;
|
||||
|
||||
bank->power_mode = pwr_mode;
|
||||
|
|
@ -1414,7 +1458,7 @@ void omap2_gpio_resume_after_idle(void)
|
|||
struct gpio_bank *bank;
|
||||
|
||||
list_for_each_entry(bank, &omap_gpio_list, node) {
|
||||
if (!bank->mod_usage || !bank->loses_context)
|
||||
if (!BANK_USED(bank) || !bank->loses_context)
|
||||
continue;
|
||||
|
||||
pm_runtime_get_sync(bank->dev);
|
||||
|
|
|
|||
Loading…
Reference in a new issue