diff mbox

ARM: tegra: Add pinmux board file for Cardhu

Message ID 1327511715-27350-1-git-send-email-swarren@nvidia.com
State Superseded, archived
Headers show

Commit Message

Stephen Warren Jan. 25, 2012, 5:15 p.m. UTC
For now, this just sets up the pinmux and GPIOs required for the SD
card slot.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Peter De Schrijver <pdeschrijver@nvidia.com>
---
This will hopefully be replaced by the pinmux DT binding in the near
future, but until that happens, Tegra30 pinmux functionality needs to
be exposed somehow to unblock getting drivers tested on Tegra30.

This of course depends on my recently posted patches that implement a
pinctrl subsystem driver for Tegra.

(Peter said: Boot tested on Cardhu, MMC still doesn't work but that might
have another rootcause...)

 arch/arm/mach-tegra/Makefile              |    1 +
 arch/arm/mach-tegra/board-cardhu-pinmux.c |   60 +++++++++++++++++++++++++++++
 arch/arm/mach-tegra/board-cardhu.h        |   28 +++++++++++++
 arch/arm/mach-tegra/board-dt-tegra30.c    |   25 +++++++++++-
 arch/arm/mach-tegra/board-pinmux.c        |    2 +-
 5 files changed, 114 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-tegra/board-cardhu-pinmux.c
 create mode 100644 arch/arm/mach-tegra/board-cardhu.h

Comments

Olof Johansson Feb. 1, 2012, 7:39 a.m. UTC | #1
On Wed, Jan 25, 2012 at 10:15:15AM -0700, Stephen Warren wrote:
> For now, this just sets up the pinmux and GPIOs required for the SD
> card slot.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Tested-by: Peter De Schrijver <pdeschrijver@nvidia.com>
> ---
> This will hopefully be replaced by the pinmux DT binding in the near
> future, but until that happens, Tegra30 pinmux functionality needs to
> be exposed somehow to unblock getting drivers tested on Tegra30.
> 
> This of course depends on my recently posted patches that implement a
> pinctrl subsystem driver for Tegra.
> 
> (Peter said: Boot tested on Cardhu, MMC still doesn't work but that might
> have another rootcause...)

Thanks, applied.


-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Olof Johansson Feb. 1, 2012, 7:45 a.m. UTC | #2
On Tue, Jan 31, 2012 at 11:39 PM, Olof Johansson <olof@lixom.net> wrote:
> On Wed, Jan 25, 2012 at 10:15:15AM -0700, Stephen Warren wrote:
>> For now, this just sets up the pinmux and GPIOs required for the SD
>> card slot.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> Tested-by: Peter De Schrijver <pdeschrijver@nvidia.com>
>> ---
>> This will hopefully be replaced by the pinmux DT binding in the near
>> future, but until that happens, Tegra30 pinmux functionality needs to
>> be exposed somehow to unblock getting drivers tested on Tegra30.
>>
>> This of course depends on my recently posted patches that implement a
>> pinctrl subsystem driver for Tegra.
>>
>> (Peter said: Boot tested on Cardhu, MMC still doesn't work but that might
>> have another rootcause...)
>
> Thanks, applied.

Actually, dropped again until the pinctrl stuff lands for the obvious
reason. I'll revisit shortly.


-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index b78bda8..49ff80c 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -11,6 +11,7 @@  obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += tegra2_clocks.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)		+= tegra2_emc.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)		+= board-dt-tegra30.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)		+= tegra30_clocks.o
+obj-$(CONFIG_ARCH_TEGRA_3x_SOC)		+= board-cardhu-pinmux.o
 obj-$(CONFIG_SMP)                       += platsmp.o localtimer.o headsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)               += hotplug.o
 obj-$(CONFIG_TEGRA_SYSTEM_DMA)		+= dma.o apbio.o
diff --git a/arch/arm/mach-tegra/board-cardhu-pinmux.c b/arch/arm/mach-tegra/board-cardhu-pinmux.c
new file mode 100644
index 0000000..2590650
--- /dev/null
+++ b/arch/arm/mach-tegra/board-cardhu-pinmux.c
@@ -0,0 +1,60 @@ 
+/*
+ * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <linux/kernel.h>
+
+#include <mach/gpio-tegra.h>
+
+#include "board-cardhu.h"
+#include "board-pinmux.h"
+
+static struct pinmux_map cardhu_map[] = {
+	TEGRA_PINMUX_MAP("sdmmc1_dat0_py7", "sdmmc1"),
+	TEGRA_PINMUX_MAP("sdmmc1_dat1_py6", "sdmmc1"),
+	TEGRA_PINMUX_MAP("sdmmc1_dat2_py5", "sdmmc1"),
+	TEGRA_PINMUX_MAP("sdmmc1_dat3_py4", "sdmmc1"),
+	TEGRA_PINMUX_MAP("sdmmc1_clk_pz0",  "sdmmc1"),
+	TEGRA_PINMUX_MAP("sdmmc1_cmd_pz1",  "sdmmc1"),
+};
+
+struct tegra_board_pinmux_pg_conf cardhu_pg[] = {
+	{"sdmmc1_dat0_py7", TEGRA_PINCONFIG_PULL_NONE, TEGRA_PINCONFIG_DRIVEN},
+	{"sdmmc1_dat1_py6", TEGRA_PINCONFIG_PULL_NONE, TEGRA_PINCONFIG_DRIVEN},
+	{"sdmmc1_dat2_py5", TEGRA_PINCONFIG_PULL_NONE, TEGRA_PINCONFIG_DRIVEN},
+	{"sdmmc1_dat3_py4", TEGRA_PINCONFIG_PULL_NONE, TEGRA_PINCONFIG_DRIVEN},
+	{"sdmmc1_clk_pz0",  TEGRA_PINCONFIG_PULL_NONE, TEGRA_PINCONFIG_DRIVEN},
+	{"sdmmc1_cmd_pz1",  TEGRA_PINCONFIG_PULL_NONE, TEGRA_PINCONFIG_DRIVEN},
+};
+
+static struct tegra_gpio_table gpio_table[] = {
+	{ .gpio = TEGRA_GPIO_SD1_CD,		.enable = true  },
+	{ .gpio = TEGRA_GPIO_SD1_WP,		.enable = true  },
+};
+
+static struct tegra_board_pinmux_conf conf = {
+	.maps = cardhu_map,
+	.map_count = ARRAY_SIZE(cardhu_map),
+	.pgs = cardhu_pg,
+	.pg_count = ARRAY_SIZE(cardhu_pg),
+	.gpios = gpio_table,
+	.gpio_count = ARRAY_SIZE(gpio_table),
+};
+
+void cardhu_pinmux_init(void)
+{
+	tegra_board_pinmux_init(&conf, NULL);
+}
diff --git a/arch/arm/mach-tegra/board-cardhu.h b/arch/arm/mach-tegra/board-cardhu.h
new file mode 100644
index 0000000..184410e
--- /dev/null
+++ b/arch/arm/mach-tegra/board-cardhu.h
@@ -0,0 +1,28 @@ 
+/*
+ * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef _MACH_TEGRA_BOARD_CARDHU_H
+#define _MACH_TEGRA_BOARD_CARDHU_H
+
+#include "gpio-names.h"
+
+#define TEGRA_GPIO_SD1_CD		TEGRA_GPIO_PI5
+#define TEGRA_GPIO_SD1_WP		TEGRA_GPIO_PT3
+
+void cardhu_pinmux_init(void);
+
+#endif
diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c b/arch/arm/mach-tegra/board-dt-tegra30.c
index b4124b1..918cbbf 100644
--- a/arch/arm/mach-tegra/board-dt-tegra30.c
+++ b/arch/arm/mach-tegra/board-dt-tegra30.c
@@ -3,7 +3,7 @@ 
  *
  * NVIDIA Tegra30 device tree board support
  *
- * Copyright (C) 2011 NVIDIA Corporation
+ * Copyright (C) 2011-2012 NVIDIA Corporation
  *
  * Derived from:
  *
@@ -36,12 +36,16 @@ 
 #include "board.h"
 #include "clock.h"
 
+void cardhu_pinmux_init(void);
+
 static struct of_device_id tegra_dt_match_table[] __initdata = {
 	{ .compatible = "simple-bus", },
 	{}
 };
 
 struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {
+	OF_DEV_AUXDATA("nvidia,tegra30-pinmux", 0x70000868, "tegra-pinmux", NULL),
+	OF_DEV_AUXDATA("nvidia,tegra20-gpio", 0x6000d000, "tegra-gpio", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000000, "sdhci-tegra.0", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000200, "sdhci-tegra.1", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000400, "sdhci-tegra.2", NULL),
@@ -60,10 +64,29 @@  static __initdata struct tegra_clk_init_table tegra_dt_clk_init_table[] = {
 	{ NULL,		NULL,		0,		0},
 };
 
+static struct {
+	char *machine;
+	void (*init)(void);
+} pinmux_configs[] = {
+	{ "nvidia,cardhu", cardhu_pinmux_init },
+};
+
 static void __init tegra30_dt_init(void)
 {
+	int i;
+
 	tegra_clk_init_from_table(tegra_dt_clk_init_table);
 
+	for (i = 0; i < ARRAY_SIZE(pinmux_configs); i++) {
+		if (of_machine_is_compatible(pinmux_configs[i].machine)) {
+			pinmux_configs[i].init();
+			break;
+		}
+	}
+
+	WARN(i == ARRAY_SIZE(pinmux_configs),
+		"Unknown platform! Pinmuxing not initialized\n");
+
 	of_platform_populate(NULL, tegra_dt_match_table,
 				tegra30_auxdata_lookup, NULL);
 }
diff --git a/arch/arm/mach-tegra/board-pinmux.c b/arch/arm/mach-tegra/board-pinmux.c
index 4e18e14..0e145b6 100644
--- a/arch/arm/mach-tegra/board-pinmux.c
+++ b/arch/arm/mach-tegra/board-pinmux.c
@@ -147,6 +147,6 @@  void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
 
 	bus_register_notifier(&platform_bus_type, &nb);
 
-	if (!of_machine_is_compatible("nvidia,tegra20"))
+	if (!of_have_populated_dt())
 		platform_add_devices(devices, ARRAY_SIZE(devices));
 }