From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-Boot, v2, 3/6] dm: sunxi: Add pinmux functions which take a bank parameter
Date: Fri, 24 Oct 2014 11:00:44 +0200 [thread overview]
Message-ID: <544A153C.1010700@redhat.com> (raw)
In-Reply-To: <1414036962-28463-4-git-send-email-sjg@chromium.org>
Hi,
On 10/23/2014 06:02 AM, Simon Glass wrote:
> With driver model we will have access to a bank pointer, so we want to
> use it rather than converting back to a number, and then back to a
> bank pointer. Add functions to provide this feature.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
Looks good:
Acked-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
>
> Changes in v2: None
>
> arch/arm/cpu/armv7/sunxi/pinmux.c | 32 +++++++++++++++++++++-----------
> arch/arm/include/asm/arch-sunxi/gpio.h | 4 +++-
> 2 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/sunxi/pinmux.c b/arch/arm/cpu/armv7/sunxi/pinmux.c
> index 1f2843f..b026f78 100644
> --- a/arch/arm/cpu/armv7/sunxi/pinmux.c
> +++ b/arch/arm/cpu/armv7/sunxi/pinmux.c
> @@ -10,32 +10,42 @@
> #include <asm/io.h>
> #include <asm/arch/gpio.h>
>
> -int sunxi_gpio_set_cfgpin(u32 pin, u32 val)
> +void sunxi_gpio_set_cfgbank(struct sunxi_gpio *pio, int bank_offset, u32 val)
> {
> - u32 bank = GPIO_BANK(pin);
> - u32 index = GPIO_CFG_INDEX(pin);
> - u32 offset = GPIO_CFG_OFFSET(pin);
> - struct sunxi_gpio *pio = BANK_TO_GPIO(bank);
> + u32 index = GPIO_CFG_INDEX(bank_offset);
> + u32 offset = GPIO_CFG_OFFSET(bank_offset);
>
> clrsetbits_le32(&pio->cfg[0] + index, 0xf << offset, val << offset);
> -
> - return 0;
> }
>
> -int sunxi_gpio_get_cfgpin(u32 pin)
> +void sunxi_gpio_set_cfgpin(u32 pin, u32 val)
> {
> - u32 cfg;
> u32 bank = GPIO_BANK(pin);
> - u32 index = GPIO_CFG_INDEX(pin);
> - u32 offset = GPIO_CFG_OFFSET(pin);
> struct sunxi_gpio *pio = BANK_TO_GPIO(bank);
>
> + sunxi_gpio_set_cfgbank(pio, pin, val);
> +}
> +
> +int sunxi_gpio_get_cfgbank(struct sunxi_gpio *pio, int bank_offset)
> +{
> + u32 index = GPIO_CFG_INDEX(bank_offset);
> + u32 offset = GPIO_CFG_OFFSET(bank_offset);
> + u32 cfg;
> +
> cfg = readl(&pio->cfg[0] + index);
> cfg >>= offset;
>
> return cfg & 0xf;
> }
>
> +int sunxi_gpio_get_cfgpin(u32 pin)
> +{
> + u32 bank = GPIO_BANK(pin);
> + struct sunxi_gpio *pio = BANK_TO_GPIO(bank);
> +
> + return sunxi_gpio_get_cfgbank(pio, pin);
> +}
> +
> int sunxi_gpio_set_drv(u32 pin, u32 val)
> {
> u32 bank = GPIO_BANK(pin);
> diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h
> index f7f3d8c..f72e2fd 100644
> --- a/arch/arm/include/asm/arch-sunxi/gpio.h
> +++ b/arch/arm/include/asm/arch-sunxi/gpio.h
> @@ -139,7 +139,9 @@ enum sunxi_gpio_number {
> #define SUNXI_GPIO_PULL_UP 1
> #define SUNXI_GPIO_PULL_DOWN 2
>
> -int sunxi_gpio_set_cfgpin(u32 pin, u32 val);
> +void sunxi_gpio_set_cfgbank(struct sunxi_gpio *pio, int bank_offset, u32 val);
> +void sunxi_gpio_set_cfgpin(u32 pin, u32 val);
> +int sunxi_gpio_get_cfgbank(struct sunxi_gpio *pio, int bank_offset);
> int sunxi_gpio_get_cfgpin(u32 pin);
> int sunxi_gpio_set_drv(u32 pin, u32 val);
> int sunxi_gpio_set_pull(u32 pin, u32 val);
>
next prev parent reply other threads:[~2014-10-24 9:00 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 4:02 [U-Boot] [PATCH v2 0/6] dm: Introduce driver model for sunxi Simon Glass
2014-10-23 4:02 ` [U-Boot] [PATCH v2 1/6] dm: sunxi: dts: Add sun7i device tree files Simon Glass
2014-10-24 8:32 ` [U-Boot] [U-Boot, v2, " Hans de Goede
2014-10-28 1:05 ` Simon Glass
2014-10-23 4:02 ` [U-Boot] [PATCH v2 2/6] dm: sunxi: Add a new config for an FDT-based pcDuino3 Simon Glass
2014-10-24 8:38 ` [U-Boot] [U-Boot, v2, " Hans de Goede
2014-10-28 0:04 ` Simon Glass
2014-10-28 9:13 ` Hans de Goede
2014-10-29 3:02 ` Simon Glass
2014-10-29 9:32 ` Hans de Goede
2014-10-29 19:30 ` Simon Glass
2014-10-30 8:36 ` Hans de Goede
2014-10-23 4:02 ` [U-Boot] [PATCH v2 3/6] dm: sunxi: Add pinmux functions which take a bank parameter Simon Glass
2014-10-24 9:00 ` Hans de Goede [this message]
2014-10-23 4:02 ` [U-Boot] [PATCH v2 4/6] dm: sunxi: Make sure that GPIOs are requested Simon Glass
2014-10-24 9:01 ` [U-Boot] [U-Boot, v2, " Hans de Goede
2014-10-23 4:02 ` [U-Boot] [PATCH v2 5/6] dm: sunxi: Modify the GPIO driver to support driver model Simon Glass
2014-10-24 9:08 ` [U-Boot] [U-Boot, v2, " Hans de Goede
2014-10-28 0:05 ` Simon Glass
2014-10-28 2:53 ` Chen-Yu Tsai
2014-10-28 3:29 ` Simon Glass
2014-10-28 3:39 ` Chen-Yu Tsai
2014-10-28 14:30 ` Maxime Ripard
2014-10-23 4:02 ` [U-Boot] [PATCH v2 6/6] dm: sunxi: Add support for serial using " Simon Glass
2014-10-24 9:10 ` [U-Boot] [U-Boot, v2, " Hans de Goede
2014-10-24 9:42 ` [U-Boot] [PATCH v2 " Ian Campbell
2014-10-28 0:06 ` Simon Glass
2014-10-29 8:05 ` Ian Campbell
2014-10-29 19:28 ` Simon Glass
2014-10-30 9:08 ` Ian Campbell
2014-10-30 9:36 ` Hans de Goede
2014-10-30 10:14 ` Ian Campbell
2014-10-31 2:45 ` Simon Glass
2014-10-31 9:07 ` Hans de Goede
2014-10-31 9:30 ` Ian Campbell
2014-10-31 9:33 ` Hans de Goede
2014-10-31 9:55 ` Ian Campbell
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=544A153C.1010700@redhat.com \
--to=hdegoede@redhat.com \
--cc=u-boot@lists.denx.de \
/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