linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree
@ 2012-05-17 21:21 Stephen Warren
  2012-05-17 21:21 ` [PATCH V2 2/3] ARM: tegra: harmony: init regulators, PCIe when booting from DT Stephen Warren
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Stephen Warren @ 2012-05-17 21:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Stephen Warren <swarren@nvidia.com>

There currently aren't bindings for the Tegra PCIe controller. Work on
this is in progress, but not yet complete. Manually initialize PCIe when
booting from device tree, in order to bring DT support to the same
feature level as board files, which will in turn allow board files to be
deprecated.

PCIe hosts the wired Ethernet controller on TrimSlice.

To support this, add infra-structure to board-dt-tegra20.c for board-
specific initialization code. Once device tree support for the relevant
features is in place, this code will be removed.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: Use .init_late hook in DT_MACHINE_START instead of an explicit late
initcall.
---
 arch/arm/mach-tegra/board-dt-tegra20.c |   36 +++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index eb7249d..9537f20 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -98,6 +98,40 @@ static void __init tegra_dt_init(void)
 				tegra20_auxdata_lookup, NULL);
 }
 
+#ifdef CONFIG_MACH_TRIMSLICE
+static void __init trimslice_init(void)
+{
+	int ret;
+
+	ret = tegra_pcie_init(true, true);
+	if (ret)
+		pr_err("tegra_pci_init() failed: %d\n", ret);
+}
+#endif
+
+static struct {
+	char *machine;
+	void (*init)(void);
+} board_init_funcs[] = {
+#ifdef CONFIG_MACH_TRIMSLICE
+	{ "compulab,trimslice", trimslice_init },
+#endif
+};
+
+static void __init tegra_dt_init_late(void)
+{
+	int i;
+
+	tegra_init_late();
+
+	for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
+		if (of_machine_is_compatible(board_init_funcs[i].machine)) {
+			board_init_funcs[i].init();
+			break;
+		}
+	}
+}
+
 static const char *tegra20_dt_board_compat[] = {
 	"nvidia,tegra20",
 	NULL
@@ -110,7 +144,7 @@ DT_MACHINE_START(TEGRA_DT, "nVidia Tegra20 (Flattened Device Tree)")
 	.handle_irq	= gic_handle_irq,
 	.timer		= &tegra_timer,
 	.init_machine	= tegra_dt_init,
-	.init_late	= tegra_init_late,
+	.init_late	= tegra_dt_init_late,
 	.restart	= tegra_assert_system_reset,
 	.dt_compat	= tegra20_dt_board_compat,
 MACHINE_END
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH V2 2/3] ARM: tegra: harmony: init regulators, PCIe when booting from DT
  2012-05-17 21:21 [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree Stephen Warren
@ 2012-05-17 21:21 ` Stephen Warren
  2012-05-17 21:21 ` [PATCH V2 3/3] ARM: tegra: paz00: enable WiFi rfkill when booting from device tree Stephen Warren
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2012-05-17 21:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Stephen Warren <swarren@nvidia.com>

There currently aren't bindings for the Tegra PCIe controller. Work on
this is in progress, but not yet complete. Manually initialize PCIe when
booting from device tree, in order to bring DT support to the same
feature level as board files, which will in turn allow board files to be
deprecated.

PCIe on Harmony requires various regulators to be registered and enabled
before initializing the PCIe controller. Note that since the I2C
controllers are instantiated from DT, we must use i2c_new_device() to
register the PMU rather than i2c_register_board_info().

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/board-dt-tegra20.c    |   20 ++++++++++++++++++++
 arch/arm/mach-tegra/board-harmony-pcie.c  |   15 ++++++++++-----
 arch/arm/mach-tegra/board-harmony-power.c |   25 ++++++++++++++++++++++++-
 arch/arm/mach-tegra/board.h               |    7 +++++++
 4 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index 9537f20..7771386 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -109,6 +109,23 @@ static void __init trimslice_init(void)
 }
 #endif
 
+#ifdef CONFIG_MACH_HARMONY
+static void __init harmony_init(void)
+{
+	int ret;
+
+	ret = harmony_regulator_init();
+	if (ret) {
+		pr_err("harmony_regulator_init() failed: %d\n", ret);
+		return;
+	}
+
+	ret = harmony_pcie_init();
+	if (ret)
+		pr_err("harmony_pcie_init() failed: %d\n", ret);
+}
+#endif
+
 static struct {
 	char *machine;
 	void (*init)(void);
@@ -116,6 +133,9 @@ static struct {
 #ifdef CONFIG_MACH_TRIMSLICE
 	{ "compulab,trimslice", trimslice_init },
 #endif
+#ifdef CONFIG_MACH_HARMONY
+	{ "nvidia,harmony", harmony_init },
+#endif
 };
 
 static void __init tegra_dt_init_late(void)
diff --git a/arch/arm/mach-tegra/board-harmony-pcie.c b/arch/arm/mach-tegra/board-harmony-pcie.c
index 33c4fed..e8c3fda 100644
--- a/arch/arm/mach-tegra/board-harmony-pcie.c
+++ b/arch/arm/mach-tegra/board-harmony-pcie.c
@@ -27,14 +27,11 @@
 
 #ifdef CONFIG_TEGRA_PCI
 
-static int __init harmony_pcie_init(void)
+int __init harmony_pcie_init(void)
 {
 	struct regulator *regulator = NULL;
 	int err;
 
-	if (!machine_is_harmony())
-		return 0;
-
 	err = gpio_request(TEGRA_GPIO_EN_VDD_1V05_GPIO, "EN_VDD_1V05");
 	if (err)
 		return err;
@@ -62,7 +59,15 @@ err_reg:
 	return err;
 }
 
+static int __init harmony_pcie_initcall(void)
+{
+	if (!machine_is_harmony())
+		return 0;
+
+	return harmony_pcie_init();
+}
+
 /* PCI should be initialized after I2C, mfd and regulators */
-subsys_initcall_sync(harmony_pcie_init);
+subsys_initcall_sync(harmony_pcie_initcall);
 
 #endif
diff --git a/arch/arm/mach-tegra/board-harmony-power.c b/arch/arm/mach-tegra/board-harmony-power.c
index 82f3230..44dcb2e 100644
--- a/arch/arm/mach-tegra/board-harmony-power.c
+++ b/arch/arm/mach-tegra/board-harmony-power.c
@@ -20,6 +20,10 @@
 #include <linux/gpio.h>
 #include <linux/regulator/machine.h>
 #include <linux/mfd/tps6586x.h>
+#include <linux/of.h>
+#include <linux/of_i2c.h>
+
+#include <asm/mach-types.h>
 
 #include <mach/irqs.h>
 
@@ -110,7 +114,26 @@ static struct i2c_board_info __initdata harmony_regulators[] = {
 
 int __init harmony_regulator_init(void)
 {
-	i2c_register_board_info(3, harmony_regulators, 1);
+	if (machine_is_harmony()) {
+		i2c_register_board_info(3, harmony_regulators, 1);
+	} else { /* Harmony, booted using device tree */
+		struct device_node *np;
+		struct i2c_adapter *adapter;
+
+		np = of_find_node_by_path("/i2c at 7000d000");
+		if (np == NULL) {
+			pr_err("Could not find device_node for DVC I2C\n");
+			return -ENODEV;
+		}
+
+		adapter = of_find_i2c_adapter_by_node(np);
+		if (!adapter) {
+			pr_err("Could not find i2c_adapter for DVC I2C\n");
+			return -ENODEV;
+		}
+
+		i2c_new_device(adapter, harmony_regulators);
+	}
 
 	return 0;
 }
diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h
index 6501496..097e0e1 100644
--- a/arch/arm/mach-tegra/board.h
+++ b/arch/arm/mach-tegra/board.h
@@ -46,5 +46,12 @@ int __init tegra_powergate_debugfs_init(void);
 static inline int tegra_powergate_debugfs_init(void) { return 0; }
 #endif
 
+int __init harmony_regulator_init(void);
+#ifdef CONFIG_TEGRA_PCI
+int __init harmony_pcie_init(void);
+#else
+static inline int harmony_pcie_init(void) { return 0; }
+#endif
+
 extern struct sys_timer tegra_timer;
 #endif
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH V2 3/3] ARM: tegra: paz00: enable WiFi rfkill when booting from device tree
  2012-05-17 21:21 [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree Stephen Warren
  2012-05-17 21:21 ` [PATCH V2 2/3] ARM: tegra: harmony: init regulators, PCIe when booting from DT Stephen Warren
@ 2012-05-17 21:21 ` Stephen Warren
  2012-05-22 10:17 ` [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe " Ben Dooks
  2012-06-04 17:46 ` Stephen Warren
  3 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2012-05-17 21:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Stephen Warren <swarren@nvidia.com>

There currently aren't bindings for a WiFi rfkill button, and defining
a good binding is non-trivial. Manually register this "device" when
booting from device tree, in order to bring DT support to the same
feature level as board files, which will in turn allow board files to be
deprecated.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/board-dt-tegra20.c |   10 ++++++++++
 arch/arm/mach-tegra/board-paz00.c      |    7 ++++++-
 arch/arm/mach-tegra/board.h            |    2 ++
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index 7771386..8b4e6e1 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -126,6 +126,13 @@ static void __init harmony_init(void)
 }
 #endif
 
+#ifdef CONFIG_MACH_PAZ00
+static void __init paz00_init(void)
+{
+	tegra_paz00_wifikill_init();
+}
+#endif
+
 static struct {
 	char *machine;
 	void (*init)(void);
@@ -136,6 +143,9 @@ static struct {
 #ifdef CONFIG_MACH_HARMONY
 	{ "nvidia,harmony", harmony_init },
 #endif
+#ifdef CONFIG_MACH_PAZ00
+	{ "compal,paz00", paz00_init },
+#endif
 };
 
 static void __init tegra_dt_init_late(void)
diff --git a/arch/arm/mach-tegra/board-paz00.c b/arch/arm/mach-tegra/board-paz00.c
index bbc1907..4b64af5 100644
--- a/arch/arm/mach-tegra/board-paz00.c
+++ b/arch/arm/mach-tegra/board-paz00.c
@@ -148,7 +148,6 @@ static struct platform_device *paz00_devices[] __initdata = {
 	&debug_uart,
 	&tegra_sdhci_device4,
 	&tegra_sdhci_device1,
-	&wifi_rfkill_device,
 	&leds_gpio,
 	&gpio_keys_device,
 };
@@ -201,6 +200,11 @@ static struct tegra_sdhci_platform_data sdhci_pdata4 = {
 	.is_8bit	= 1,
 };
 
+void __init tegra_paz00_wifikill_init(void)
+{
+	platform_device_register(&wifi_rfkill_device);
+}
+
 static void __init tegra_paz00_init(void)
 {
 	tegra_clk_init_from_table(paz00_clk_init_table);
@@ -211,6 +215,7 @@ static void __init tegra_paz00_init(void)
 	tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
 
 	platform_add_devices(paz00_devices, ARRAY_SIZE(paz00_devices));
+	tegra_paz00_wifikill_init();
 
 	paz00_i2c_init();
 	paz00_usb_init();
diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h
index 097e0e1..f88e514 100644
--- a/arch/arm/mach-tegra/board.h
+++ b/arch/arm/mach-tegra/board.h
@@ -53,5 +53,7 @@ int __init harmony_pcie_init(void);
 static inline int harmony_pcie_init(void) { return 0; }
 #endif
 
+void __init tegra_paz00_wifikill_init(void);
+
 extern struct sys_timer tegra_timer;
 #endif
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree
  2012-05-17 21:21 [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree Stephen Warren
  2012-05-17 21:21 ` [PATCH V2 2/3] ARM: tegra: harmony: init regulators, PCIe when booting from DT Stephen Warren
  2012-05-17 21:21 ` [PATCH V2 3/3] ARM: tegra: paz00: enable WiFi rfkill when booting from device tree Stephen Warren
@ 2012-05-22 10:17 ` Ben Dooks
  2012-05-22 16:18   ` Stephen Warren
  2012-06-04 17:46 ` Stephen Warren
  3 siblings, 1 reply; 6+ messages in thread
From: Ben Dooks @ 2012-05-22 10:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/05/12 22:21, Stephen Warren wrote:
> From: Stephen Warren<swarren@nvidia.com>
>
> There currently aren't bindings for the Tegra PCIe controller. Work on
> this is in progress, but not yet complete. Manually initialize PCIe when
> booting from device tree, in order to bring DT support to the same
> feature level as board files, which will in turn allow board files to be
> deprecated.
>
> PCIe hosts the wired Ethernet controller on TrimSlice.
>
> To support this, add infra-structure to board-dt-tegra20.c for board-
> specific initialization code. Once device tree support for the relevant
> features is in place, this code will be removed.
>
> Signed-off-by: Stephen Warren<swarren@nvidia.com>
> ---
> v2: Use .init_late hook in DT_MACHINE_START instead of an explicit late
> initcall.
> ---
>   arch/arm/mach-tegra/board-dt-tegra20.c |   36 +++++++++++++++++++++++++++++++-
>   1 files changed, 35 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
> index eb7249d..9537f20 100644
> --- a/arch/arm/mach-tegra/board-dt-tegra20.c
> +++ b/arch/arm/mach-tegra/board-dt-tegra20.c
> @@ -98,6 +98,40 @@ static void __init tegra_dt_init(void)
>   				tegra20_auxdata_lookup, NULL);
>   }
>
> +#ifdef CONFIG_MACH_TRIMSLICE
> +static void __init trimslice_init(void)
> +{
> +	int ret;
> +
> +	ret = tegra_pcie_init(true, true);
> +	if (ret)
> +		pr_err("tegra_pci_init() failed: %d\n", ret);
> +}
> +#endif

Given the size of some of these functions, is it worth even
bothering with an #ifdef around them, especially as they are
marked init.

How about having some sort of standard pcie binding for the pcie
part?

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree
  2012-05-22 10:17 ` [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe " Ben Dooks
@ 2012-05-22 16:18   ` Stephen Warren
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2012-05-22 16:18 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/22/2012 04:17 AM, Ben Dooks wrote:
> On 17/05/12 22:21, Stephen Warren wrote:
>> From: Stephen Warren<swarren@nvidia.com>
>>
>> There currently aren't bindings for the Tegra PCIe controller. Work on
>> this is in progress, but not yet complete. Manually initialize PCIe when
>> booting from device tree, in order to bring DT support to the same
>> feature level as board files, which will in turn allow board files to be
>> deprecated.
>>
>> PCIe hosts the wired Ethernet controller on TrimSlice.
>>
>> To support this, add infra-structure to board-dt-tegra20.c for board-
>> specific initialization code. Once device tree support for the relevant
>> features is in place, this code will be removed.
>>
>> Signed-off-by: Stephen Warren<swarren@nvidia.com>

>> +++ b/arch/arm/mach-tegra/board-dt-tegra20.c

>> +#ifdef CONFIG_MACH_TRIMSLICE
>> +static void __init trimslice_init(void)
>> +{
>> +    int ret;
>> +
>> +    ret = tegra_pcie_init(true, true);
>> +    if (ret)
>> +        pr_err("tegra_pci_init() failed: %d\n", ret);
>> +}
>> +#endif
> 
> Given the size of some of these functions, is it worth even
> bothering with an #ifdef around them, especially as they are
> marked init.

The TrimSlice init function doesn't pull in anything beyond the raw
driver itself, but the Harmony and Paz00 functions do. I made everything
ifdef'd for consistency.

> How about having some sort of standard pcie binding for the pcie
> part?

Thierry Redding is working on a standardized binding and converting the
driver to a platform driver. As soon as that's complete and checked in,
we can remove some of these custom init functions.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree
  2012-05-17 21:21 [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree Stephen Warren
                   ` (2 preceding siblings ...)
  2012-05-22 10:17 ` [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe " Ben Dooks
@ 2012-06-04 17:46 ` Stephen Warren
  3 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2012-06-04 17:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/17/2012 03:21 PM, Stephen Warren wrote:
> There currently aren't bindings for the Tegra PCIe controller. Work on
> this is in progress, but not yet complete. Manually initialize PCIe when
> booting from device tree, in order to bring DT support to the same
> feature level as board files, which will in turn allow board files to be
> deprecated.
> 
> PCIe hosts the wired Ethernet controller on TrimSlice.
> 
> To support this, add infra-structure to board-dt-tegra20.c for board-
> specific initialization code. Once device tree support for the relevant
> features is in place, this code will be removed.

Applied for 3.6 (the series).

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-06-04 17:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-17 21:21 [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe when booting from device tree Stephen Warren
2012-05-17 21:21 ` [PATCH V2 2/3] ARM: tegra: harmony: init regulators, PCIe when booting from DT Stephen Warren
2012-05-17 21:21 ` [PATCH V2 3/3] ARM: tegra: paz00: enable WiFi rfkill when booting from device tree Stephen Warren
2012-05-22 10:17 ` [PATCH V2 1/3] ARM: tegra: trimslice: enable PCIe " Ben Dooks
2012-05-22 16:18   ` Stephen Warren
2012-06-04 17:46 ` Stephen Warren

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).