linux-aspeed.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Joel Stanley <joel@jms.id.au>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH v2 3/4] gpio: aspeed: Add command source registers
Date: Mon, 18 Jun 2018 15:08:40 +0930	[thread overview]
Message-ID: <CACPK8XdRHgNhz6xNJorUKPVk7SKrJEXTdfSPA_tnV_RYx7iL1A@mail.gmail.com> (raw)
In-Reply-To: <20180618045352.9489-4-benh@kernel.crashing.org>

On 18 June 2018 at 14:23, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> This adds the definitions for the command source registers
> and a helper to set them.
>
> Those registers allow to control which bus master on the
> SoC is allowed to modify a given bank of GPIOs and will
> be used by subsequent patches.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

>
> +static void aspeed_gpio_change_cmd_source(struct aspeed_gpio *gpio,
> +                                         const struct aspeed_gpio_bank *bank,
> +                                         int bindex, int cmdsrc)
> +{
> +       void __iomem *c0 = bank_reg(gpio, bank, reg_cmdsrc0);
> +       void __iomem *c1 = bank_reg(gpio, bank, reg_cmdsrc1);
> +       u32 bit, reg;
> +
> +       /*
> +        * Each register controls 4 banks, so take the bottom 2
> +        * bits of the bank index, and use them to select the
> +        * right control bit (0, 8, 16 or 24).
> +        */
> +       bit = BIT((bindex & 3) << 3);

This is still hard to understand (it looks like a mistake at first
glance). I don't have any suggestions other than changing  << 3 to *
8.

The comment does explain it, so I'm fine with it going in.

Reviewed-by: Joel Stanley <joel@jms.id.au>

> +
> +       /* Source 1 first to avoid illegal 11 combination */
> +       reg = ioread32(c1);
> +       if (cmdsrc & 2)
> +               reg |= bit;
> +       else
> +               reg &= ~bit;
> +       iowrite32(reg, c1);
> +
> +       /* Then Source 0 */
> +       reg = ioread32(c0);
> +       if (cmdsrc & 1)
> +               reg |= bit;
> +       else
> +               reg &= ~bit;
> +       iowrite32(reg, c0);
> +}
> +
>  static int aspeed_gpio_get(struct gpio_chip *gc, unsigned int offset)
>  {
>         struct aspeed_gpio *gpio = gpiochip_get_data(gc);
> --
> 2.17.1
>

  reply	other threads:[~2018-06-18  5:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18  4:53 [PATCH v2 0/4] gpio: aspeed: Fixes and support for sharing with co-processor Benjamin Herrenschmidt
2018-06-18  4:53 ` [PATCH v2 1/4] gpio: aspeed: Rework register type accessors Benjamin Herrenschmidt
2018-06-18  5:38   ` Joel Stanley
2018-06-18  5:55   ` Andrew Jeffery
2018-06-18  4:53 ` [PATCH v2 2/4] gpio: aspeed: Add "Read Data" register to read the write latch Benjamin Herrenschmidt
2018-06-18  5:38   ` Joel Stanley
2018-06-18 13:38   ` Andrew Jeffery
2018-06-18 13:49     ` Benjamin Herrenschmidt
2018-06-18  4:53 ` [PATCH v2 3/4] gpio: aspeed: Add command source registers Benjamin Herrenschmidt
2018-06-18  5:38   ` Joel Stanley [this message]
2018-06-18  6:14   ` Andrew Jeffery
2018-06-18  4:53 ` [PATCH v2 4/4] gpio: aspeed: Add interfaces for co-processor to grab GPIOs Benjamin Herrenschmidt
2018-06-18  5:38   ` Joel Stanley
2018-06-18 14:23   ` Andrew Jeffery
2018-06-18 14:38     ` Benjamin Herrenschmidt
2018-06-19  0:36       ` Benjamin Herrenschmidt
2018-06-19  0:38         ` Andrew Jeffery

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=CACPK8XdRHgNhz6xNJorUKPVk7SKrJEXTdfSPA_tnV_RYx7iL1A@mail.gmail.com \
    --to=joel@jms.id.au \
    --cc=linux-aspeed@lists.ozlabs.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).