[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdZCY+tbTgPyt7MWaZw93O_m28tMgaB8SbDAtJS-0VuGtw@mail.gmail.com>
Date: Thu, 12 Apr 2012 17:05:43 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Alessandro Rubini <rubini@...dd.com>
Cc: linux-kernel@...r.kernel.org,
Giancarlo Asnaghi <giancarlo.asnaghi@...com>,
Alan Cox <alan@...ux.intel.com>, sameo@...ux.intel.com,
grant.likely@...retlab.ca, linus.walleij@...ricsson.com
Subject: Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block
On Thu, Apr 12, 2012 at 10:48 AM, Alessandro Rubini <rubini@...dd.com> wrote:
> +/*
> + * Special method: alternate functions and pullup/pulldown. This is only
> + * invoked on startup to configure gpio's according to platform data.
> + * FIXME : this functionality shall be managed (and exported to other drivers)
> + * via the pin control subsystem.
> + */
> +static void gsta_set_config(struct gsta_gpio *chip, int nr, unsigned cfg)
> +{
> + struct gsta_regs __iomem *regs = __regs(chip, nr);
> + unsigned long flags;
> + u32 bit = __bit(nr);
> + u32 val;
> + int err = 0;
> +
> + pr_info("%s: %p %i %i\n", __func__, chip, nr, cfg);
> +
> + if (cfg == PINMUX_TYPE_NONE)
> + return;
> +
> + /* Alternate function or not? */
> + spin_lock_irqsave(&chip->lock, flags);
> + val = readl(®s->afsela);
> + if (cfg == PINMUX_TYPE_FUNCTION)
> + val |= bit;
> + else
> + val &= ~bit;
> + writel(val | bit, ®s->afsela);
> + if (cfg == PINMUX_TYPE_FUNCTION) {
> + spin_unlock_irqrestore(&chip->lock, flags);
> + return;
> + }
> +
> + /* not alternate function: set details */
> + switch (cfg) {
> + case PINMUX_TYPE_OUTPUT_LOW:
> + writel(bit, ®s->dirs);
> + writel(bit, ®s->datc);
> + break;
> + case PINMUX_TYPE_OUTPUT_HIGH:
> + writel(bit, ®s->dirs);
> + writel(bit, ®s->dats);
> + break;
> + case PINMUX_TYPE_INPUT:
> + writel(bit, ®s->dirc);
> + val = readl(®s->pdis) | bit;
> + writel(val, ®s->pdis);
> + break;
> + case PINMUX_TYPE_INPUT_PULLUP:
> + writel(bit, ®s->dirc);
> + val = readl(®s->pdis) & ~bit;
> + writel(val, ®s->pdis);
> + writel(bit, ®s->dats);
> + break;
> + case PINMUX_TYPE_INPUT_PULLDOWN:
> + writel(bit, ®s->dirc);
> + val = readl(®s->pdis) & ~bit;
> + writel(val, ®s->pdis);
> + writel(bit, ®s->datc);
> + break;
> + default:
> + err = 1;
> + }
> + spin_unlock_irqrestore(&chip->lock, flags);
> + if (err)
> + pr_err("%s: chip %p, pin %i, cfg %i is invalid\n",
> + __func__, chip, nr, cfg);
> +}
I would still prefer to use the pinctrl subsystem for this from day 1 instead of
adding more custom stuff for later refactoring...
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists