From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree
Date: Mon, 26 Nov 2012 15:06:37 +0100 [thread overview]
Message-ID: <7701261.79JI41uS12@avalon> (raw)
In-Reply-To: <1353889014-17142-5-git-send-email-horms@verge.net.au>
Hi Simon,
On Monday 26 November 2012 09:16:51 Simon Horman wrote:
> Register the pfc with sh73a0_init_gpio_dt() to allow
> gpios provided by pfc to be accessed by devices which
> are registered using device tree.
>
> The motivation of this is to allow the gpio used for carrier detect
> but the Micro SD SDHI port of the KZM-9A-GT board to be accessed
> using device tree. Thus, allowing the SDHI device of the KZM-9A-GT
> board to be registered using device tree.
>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
> arch/arm/mach-shmobile/pfc-sh73a0.c | 45 ++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/arch/arm/mach-shmobile/pfc-sh73a0.c
> b/arch/arm/mach-shmobile/pfc-sh73a0.c index b442f9d..d1a04c0b 100644
> --- a/arch/arm/mach-shmobile/pfc-sh73a0.c
> +++ b/arch/arm/mach-shmobile/pfc-sh73a0.c
> @@ -2797,7 +2797,52 @@ static struct pinmux_info sh73a0_pinmux_info = {
> .gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
> };
>
> +#ifdef CONFIG_OF_GPIO
> +static int sh73a0_gpio_xlate(struct gpio_chip *gc,
> + const struct of_phandle_args *gpiospec,
> + u32 *flags)
> +{
> + if (WARN_ON(gc->of_gpio_n_cells < 2))
> + return -EINVAL;
> +
> + if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
> + return -EINVAL;
> +
> + if (gpiospec->args[0] > gc->ngpio)
> + return -EINVAL;
> +
> + if (flags)
> + *flags = gpiospec->args[1];
> +
> + return gpiospec->args[0];
> +}
Is there any reason not to use of_gpio_simple_xlate here ? If there isn't,
of_xlate and of_gpio_n_cells default to of_gpio_simple_xlate and 2
respectively when of_xlate isn't specified, so you could omit both.
> +static const struct of_device_id sh73a0_gpio_dt_match[] __initdata = {
> + { .compatible = "renesas,sh_pfc-sh73a0", },
> + {}
> +};
> +
> +static inline void sh73a0_init_gpio_dt(void)
> +{
> + struct device_node *of_node;
> +
> + if (!of_have_populated_dt())
> + return;
> +
> + of_node = of_find_matching_node(NULL, sh73a0_gpio_dt_match);
> + sh73a0_pinmux_info.of_node = of_node;
> + sh73a0_pinmux_info.of_gpio_n_cells = 2;
> + sh73a0_pinmux_info.of_xlate = sh73a0_gpio_xlate;
> +}
> +
> +#else
> +
> +static inline void sh73a0_init_gpio_dt(void) {}
> +
> +#endif
> +
> void sh73a0_pinmux_init(void)
> {
> + sh73a0_init_gpio_dt();
> register_pinmux(&sh73a0_pinmux_info);
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2012-11-26 14:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
2012-11-26 0:16 ` [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage Simon Horman
2012-11-26 4:06 ` Magnus Damm
2012-11-26 4:39 ` Simon Horman
2012-11-26 0:16 ` [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios Simon Horman
2012-11-26 10:16 ` Guennadi Liakhovetski
2012-11-26 10:18 ` Guennadi Liakhovetski
2012-11-26 0:16 ` [PATCH 3/7] sh: pfc: Allow device tree registration Simon Horman
2012-11-26 12:54 ` Laurent Pinchart
2012-11-27 0:07 ` Laurent Pinchart
2012-11-27 0:42 ` Simon Horman
2012-11-26 0:16 ` [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree Simon Horman
2012-11-26 14:06 ` Laurent Pinchart [this message]
2012-11-27 3:36 ` Simon Horman
2012-11-26 0:16 ` [PATCH 5/7] ARM: mach-shmobile: sh73a0: Allow initialisation of GIC by DT Simon Horman
2012-11-26 0:16 ` [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT Simon Horman
2012-11-26 4:23 ` Magnus Damm
2012-11-26 4:58 ` Simon Horman
2012-11-26 12:53 ` Laurent Pinchart
2012-11-27 0:32 ` Simon Horman
2012-11-26 0:16 ` [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
2012-11-26 8:34 ` Tetsuyuki Kobayashi
2012-11-27 0:33 ` Simon Horman
2012-11-26 6:10 ` [PATCH 0/7] " Tetsuyuki Kobayashi
2012-11-27 0:32 ` Simon Horman
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=7701261.79JI41uS12@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.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