linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mike@compulab.co.il (Mike Rapoport)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] ARM: tegra: harmony: register sdhci devices
Date: Tue, 22 Feb 2011 08:59:16 +0200	[thread overview]
Message-ID: <4D635EC4.2030102@compulab.co.il> (raw)
In-Reply-To: <1298354117-19097-5-git-send-email-olof@lixom.net>

Hi Olof,
Sorry for jumping late, haven't thought about the proposal below yesterday.
I'm not objecting to applying the patch as is, we can refactor the code
afterwards as well.

On 02/22/11 07:55, Olof Johansson wrote:
> Add the 3 sdhci devices that are available on Harmony as
> platform devices. Two go to slots (one 4-lane, one 8-lane),
> and one goes to onboard wifi.
> 
> Signed-off-by: Olof Johansson <olof@lixom.net>
> ---
>  arch/arm/mach-tegra/board-harmony.c |   30 ++++++++++++++++++++++++++++++
>  1 files changed, 30 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-tegra/board-harmony.c b/arch/arm/mach-tegra/board-harmony.c
> index f6ad58b..7010774 100644
> --- a/arch/arm/mach-tegra/board-harmony.c
> +++ b/arch/arm/mach-tegra/board-harmony.c
> @@ -30,10 +30,13 @@
>  
>  #include <mach/iomap.h>
>  #include <mach/irqs.h>
> +#include <mach/sdhci.h>
>  
>  #include "board.h"
>  #include "board-harmony.h"
>  #include "clock.h"
> +#include "devices.h"
> +#include "gpio-names.h"
>  
>  static struct plat_serial8250_port debug_uart_platform_data[] = {
>  	{
> @@ -59,6 +62,9 @@ static struct platform_device debug_uart = {
>  
>  static struct platform_device *harmony_devices[] __initdata = {
>  	&debug_uart,
> +	&tegra_sdhci_device1,
> +	&tegra_sdhci_device2,
> +	&tegra_sdhci_device4,
>  };
>  
>  static void __init tegra_harmony_fixup(struct machine_desc *desc,
> @@ -77,6 +83,26 @@ static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = {
>  	{ NULL,		NULL,		0,		0},
>  };
>  
> +
> +static struct tegra_sdhci_platform_data sdhci_pdata1 = {
> +	.cd_gpio	= -1,
> +	.wp_gpio	= -1,
> +	.power_gpio	= -1,
> +};
> +
> +static struct tegra_sdhci_platform_data sdhci_pdata2 = {
> +	.cd_gpio	= TEGRA_GPIO_PI5,
> +	.wp_gpio	= TEGRA_GPIO_PH1,
> +	.power_gpio	= TEGRA_GPIO_PT3,
> +};
> +
> +static struct tegra_sdhci_platform_data sdhci_pdata4 = {
> +	.cd_gpio	= TEGRA_GPIO_PH2,
> +	.wp_gpio	= TEGRA_GPIO_PH3,
> +	.power_gpio	= TEGRA_GPIO_PI6,
> +	.is_8bit	= 1,
> +};
> +
>  static void __init tegra_harmony_init(void)
>  {
>  	tegra_common_init();
> @@ -85,6 +111,10 @@ static void __init tegra_harmony_init(void)
>  
>  	harmony_pinmux_init();
>  
> +	tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
> +	tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2;
> +	tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
> +

I think that instead of copying explicit initialization of the platform_data
member from board to board we can do something similar to what PXA does. The
board file would have to call something like
tegra_set_device_X_info(struct tegra_device_X_platform_data *data);
and then static registration of platform devices in the board files can be dropped.

For instance, the devices.c would have

void __init tegra_register_device(struct platform_device *dev, void *data)
{
	int ret;

	dev->dev.platform_data = data;

	ret = platform_device_register(dev);
	if (ret)
		dev_err(&dev->dev, "unable to register device: %d\n", ret);
}

void __init tegra_set_sdhci1_info(struct tegra_sdhci_platform_data *info)
{
	tegra_register_device(&tegra_sdhci_device1, info);
}

and the board files would just call tegra_set_sdhci1_info to pass the platform
data for the tegra_sdhci_device1 and register the device.

This way we could reduce amount of copy/paste between the board files. Besides,
if/when tegra will be using device trees, handling of the device registration in
common place would make the transition easier.

>  	platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices));
>  }
>  


-- 
Sincerely yours,
Mike.

  reply	other threads:[~2011-02-22  6:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22  5:55 [PATCH v3 0/6] Tegra board patches Olof Johansson
2011-02-22  5:55 ` [PATCH 1/6] ARM: tegra: add tegra_gpio_table and tegra_gpio_config Olof Johansson
2011-02-22 13:13   ` Sergei Shtylyov
2011-02-22 15:31     ` Olof Johansson
2011-02-22 19:18   ` Erik Gilling
2011-02-22 19:35     ` Olof Johansson
2011-02-22 23:14       ` Erik Gilling
2011-02-22 20:46   ` Russell King - ARM Linux
2011-02-22 21:00     ` Olof Johansson
2011-02-22  5:55 ` [PATCH 2/6] ARM: tegra: common device resources Olof Johansson
2011-02-22  5:55 ` [PATCH 3/6] ARM: tegra: remove stale nvidia atag handler Olof Johansson
2011-02-22 19:39   ` Colin Cross
2011-02-22  5:55 ` [PATCH 4/6] ARM: tegra: harmony: register sdhci devices Olof Johansson
2011-02-22  6:59   ` Mike Rapoport [this message]
2011-02-22 15:44     ` Olof Johansson
2011-02-23 20:53       ` Grant Likely
2011-02-22 19:40   ` Colin Cross
2011-02-22  5:55 ` [PATCH 5/6] ARM: tegra: harmony: fix pinmux for MMC slot Olof Johansson
2011-02-22  5:55 ` [PATCH 6/6] ARM: tegra: add seaboard, wario and kaen boards Olof Johansson
2011-02-22  7:05   ` Colin Cross
2011-02-22 20:48   ` Russell King - ARM Linux
2011-02-22 21:05     ` Olof Johansson

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=4D635EC4.2030102@compulab.co.il \
    --to=mike@compulab.co.il \
    --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;
as well as URLs for NNTP newsgroup(s).