lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<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(&regs->afsela);
> +       if (cfg == PINMUX_TYPE_FUNCTION)
> +               val |= bit;
> +       else
> +               val &= ~bit;
> +       writel(val | bit, &regs->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, &regs->dirs);
> +               writel(bit, &regs->datc);
> +               break;
> +       case PINMUX_TYPE_OUTPUT_HIGH:
> +               writel(bit, &regs->dirs);
> +               writel(bit, &regs->dats);
> +               break;
> +       case PINMUX_TYPE_INPUT:
> +               writel(bit, &regs->dirc);
> +               val = readl(&regs->pdis) | bit;
> +               writel(val, &regs->pdis);
> +               break;
> +       case PINMUX_TYPE_INPUT_PULLUP:
> +               writel(bit, &regs->dirc);
> +               val = readl(&regs->pdis) & ~bit;
> +               writel(val, &regs->pdis);
> +               writel(bit, &regs->dats);
> +               break;
> +       case PINMUX_TYPE_INPUT_PULLDOWN:
> +               writel(bit, &regs->dirc);
> +               val = readl(&regs->pdis) & ~bit;
> +               writel(val, &regs->pdis);
> +               writel(bit, &regs->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

Powered by Openwall GNU/*/Linux Powered by OpenVZ