From: Kevin Hilman <khilman@ti.com>
To: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: linux-omap@vger.kernel.org, santosh.shilimkar@ti.com, tony@atomide.com
Subject: Re: [PATCH v2 12/18] GPIO: OMAP: Clean omap_gpio_mod_init function
Date: Thu, 16 Jun 2011 10:49:11 -0700 [thread overview]
Message-ID: <87fwn9mzu0.fsf@ti.com> (raw)
In-Reply-To: <1308111806-29152-3-git-send-email-tarun.kanti@ti.com> (Tarun Kanti DebBarma's message of "Wed, 15 Jun 2011 09:53:20 +0530")
Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:
> From: Charulatha V <charu@ti.com>
>
> With register offsets now defined for respective OMAP versions we can get rid
> of cpu_class_* checks. In addition, organized common initialization for the
> different OMAP silicon versions.
>
> Signed-off-by: Charulatha V <charu@ti.com>
> Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Since the SYSCONFIG register settings are OMAP1-only and init-time only,
they could be done in the OMAP1-specific init functions.
Also, this could be quite a bit more compact by not duplicating code for
both bank widths. Instead, create some local function pointers for 16
or 32-bit register access, and assign them based on bank width.
Kevin
> ---
> arch/arm/mach-omap1/gpio16xx.c | 1 +
> arch/arm/plat-omap/include/plat/gpio.h | 2 +
> drivers/gpio/gpio-omap.c | 121 +++++++++++++++++++++-----------
> 3 files changed, 84 insertions(+), 40 deletions(-)
>
> diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
> index 4677ea5..efd9275 100644
> --- a/arch/arm/mach-omap1/gpio16xx.c
> +++ b/arch/arm/mach-omap1/gpio16xx.c
> @@ -96,6 +96,7 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
> .wkup_set = OMAP1610_GPIO_SET_WAKEUPENA,
> .edgectrl1 = OMAP1610_GPIO_EDGE_CTRL1,
> .edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2,
> + .sysconfig = OMAP1610_GPIO_SYSCONFIG,
> };
>
> static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
> diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h
> index c0a92ea..30db400 100644
> --- a/arch/arm/plat-omap/include/plat/gpio.h
> +++ b/arch/arm/plat-omap/include/plat/gpio.h
> @@ -200,6 +200,8 @@ struct omap_gpio_reg_offs {
> u16 irqctrl;
> u16 edgectrl1;
> u16 edgectrl2;
> + /* Not applicable for OMAP2+ as hwmod layer takes care of sysconfig */
> + u16 sysconfig;
>
> bool irqenable_inv;
> };
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 53f2ea6..89d1ea5 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -887,47 +887,94 @@ static void __init omap_gpio_show_rev(struct gpio_bank *bank)
> */
> static struct lock_class_key gpio_lock_class;
>
> -/* TODO: Cleanup cpu_is_* checks */
> static void omap_gpio_mod_init(struct gpio_bank *bank)
> {
> - if (cpu_class_is_omap2()) {
> - if (cpu_is_omap44xx()) {
> - __raw_writel(0xffffffff, bank->base +
> - OMAP4_GPIO_IRQSTATUSCLR0);
> - __raw_writel(0x00000000, bank->base +
> - OMAP4_GPIO_DEBOUNCENABLE);
> - /* Initialize interface clk ungated, module enabled */
> - __raw_writel(0, bank->base + OMAP4_GPIO_CTRL);
> - } else if (cpu_is_omap34xx()) {
> - __raw_writel(0x00000000, bank->base +
> - OMAP24XX_GPIO_IRQENABLE1);
> - __raw_writel(0xffffffff, bank->base +
> - OMAP24XX_GPIO_IRQSTATUS1);
> - __raw_writel(0x00000000, bank->base +
> - OMAP24XX_GPIO_DEBOUNCE_EN);
> + if (bank->width == 32) {
> + u32 clr_all = 0; /* clear all the bits */
> + u32 set_all = 0xFFFFFFFF; /* set all the bits */
> +
> + if (bank_is_mpuio(bank)) {
> + __raw_writel(set_all, bank->base +
> + bank->regs->irqenable);
> +
> + if (bank->suspend_support)
> + mpuio_init(bank);
>
> + return;
> + }
> +
> + if (bank->regs->ctrl)
> /* Initialize interface clk ungated, module enabled */
> - __raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
> + __raw_writel(clr_all, bank->base + bank->regs->ctrl);
> +
> + if (bank->regs->clr_irqenable) {
> + __raw_writel(set_all, bank->base +
> + bank->regs->clr_irqenable);
> + } else if (bank->regs->irqenable) {
> + u32 i;
> +
> + if (bank->regs->irqenable_inv)
> + i = set_all;
> + else
> + i = clr_all;
> +
> + __raw_writel(i, bank->base + bank->regs->irqenable);
> }
> - } else if (cpu_class_is_omap1()) {
> - if (bank_is_mpuio(bank) && bank->suspend_support) {
> - __raw_writew(0xffff, bank->base +
> - OMAP_MPUIO_GPIO_MASKIT / bank->stride);
> - mpuio_init(bank);
> +
> + if (bank->regs->irqstatus) {
> + u32 i;
> +
> + if (bank->regs->irqenable_inv)
> + i = clr_all;
> + else
> + i = set_all;
> +
> + __raw_writel(i, bank->base + bank->regs->irqstatus);
> }
> - if (cpu_is_omap15xx() && bank->method == METHOD_GPIO_1510) {
> - __raw_writew(0xffff, bank->base
> - + OMAP1510_GPIO_INT_MASK);
> - __raw_writew(0x0000, bank->base
> - + OMAP1510_GPIO_INT_STATUS);
> +
> + if (bank->regs->debounce_en)
> + __raw_writel(clr_all, bank->base +
> + bank->regs->debounce_en);
> +
> + } else if (bank->width == 16) {
> + u16 clr_all = 0; /* clear all the bits */
> + u16 set_all = 0xFFFF; /* set all the bits */
> +
> + if (bank_is_mpuio(bank)) {
> + __raw_writew(set_all, bank->base +
> + bank->regs->irqenable);
> +
> + if (bank->suspend_support)
> + mpuio_init(bank);
> +
> + return;
> }
> - if (cpu_is_omap16xx() && bank->method == METHOD_GPIO_1610) {
> - __raw_writew(0x0000, bank->base
> - + OMAP1610_GPIO_IRQENABLE1);
> - __raw_writew(0xffff, bank->base
> - + OMAP1610_GPIO_IRQSTATUS1);
> - __raw_writew(0x0014, bank->base
> - + OMAP1610_GPIO_SYSCONFIG);
> +
> + if (bank->regs->irqenable) {
> + u16 i;
> +
> + if (bank->regs->irqenable_inv)
> + i = set_all;
> + else
> + i = clr_all;
> +
> + __raw_writew(i, bank->base + bank->regs->irqenable);
> + }
> +
> + if (bank->regs->irqstatus) {
> + u32 i;
> +
> + if (bank->regs->irqenable_inv)
> + i = clr_all;
> + else
> + i = set_all;
> +
> + __raw_writew(i, bank->base + bank->regs->irqstatus);
> + }
> +
> + if (bank->regs->sysconfig) {
> + /* set wakeup-enable and smart-idle */
> + __raw_writew(0x14, bank->base + bank->regs->sysconfig);
>
> /*
> * Enable system clock for GPIO module.
> @@ -936,12 +983,6 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
> omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04,
> ULPD_CAM_CLK_CTRL);
> }
> - if (cpu_is_omap7xx() && bank->method == METHOD_GPIO_7XX) {
> - __raw_writel(0xffffffff, bank->base
> - + OMAP7XX_GPIO_INT_MASK);
> - __raw_writel(0x00000000, bank->base
> - + OMAP7XX_GPIO_INT_STATUS);
> - }
> }
> }
next prev parent reply other threads:[~2011-06-16 17:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-15 4:23 [PATCH v2 10/18] GPIO: OMAP: Remove hardcoded offsets in ctxt save/restore Tarun Kanti DebBarma
2011-06-15 4:23 ` [PATCH v2 11/18] GPIO: OMAP: Clean set_gpio_triggering function Tarun Kanti DebBarma
2011-06-16 17:40 ` Kevin Hilman
2011-06-17 5:16 ` DebBarma, Tarun Kanti
2011-06-15 4:23 ` [PATCH v2 12/18] GPIO: OMAP: Clean omap_gpio_mod_init function Tarun Kanti DebBarma
2011-06-16 17:49 ` Kevin Hilman [this message]
2011-06-17 5:11 ` DebBarma, Tarun Kanti
2011-06-27 10:48 ` DebBarma, Tarun Kanti
2011-06-27 23:06 ` Kevin Hilman
2011-06-15 4:23 ` [PATCH v2 13/18] GPIO: OMAP15xx: Use pinctrl offset instead of macro Tarun Kanti DebBarma
2011-06-15 4:23 ` [PATCH v2 14/18] GPIO: OMAP: Fix use of readl/readw to access isr_reg Tarun Kanti DebBarma
2011-06-16 17:53 ` Kevin Hilman
2011-06-17 5:07 ` DebBarma, Tarun Kanti
2011-06-16 17:57 ` Kevin Hilman
2011-06-17 5:05 ` DebBarma, Tarun Kanti
2011-06-15 4:23 ` [PATCH v2 15/18] GPIO: OMAP: Remove bank->method & METHOD_* macros Tarun Kanti DebBarma
2011-06-15 4:23 ` [PATCH v2 16/18] GPIO: OMAP: Fix bankwidth for OMAP7xx MPUIO Tarun Kanti DebBarma
2011-06-15 4:23 ` [PATCH v2 17/18] GPIO: OMAP: Use PM runtime framework Tarun Kanti DebBarma
2011-06-16 18:03 ` Kevin Hilman
2011-06-17 5:00 ` DebBarma, Tarun Kanti
2011-06-15 4:23 ` [PATCH v2 18/18] GPIO: OMAP2+: Clean prepare_for_idle and resume_after_idle Tarun Kanti DebBarma
2011-06-16 18:10 ` Kevin Hilman
2011-06-17 4:57 ` DebBarma, Tarun Kanti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fwn9mzu0.fsf@ti.com \
--to=khilman@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=santosh.shilimkar@ti.com \
--cc=tarun.kanti@ti.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.