ARM: tegra: pm269: Enable sd card
Pradeep Goudagunta [Tue, 29 Mar 2011 15:14:25 +0000 (20:14 +0530)]
-Support to select sd card dynamically by reading board-id.
-Enable sd card for BOARD_PM269.

Original-Change-Id: I1504df353a07880a1c495ce44be2d3371d00f5ff
Reviewed-on: http://git-master/r/24693
Tested-by: Pradeep Goudagunta <pgoudagunta@nvidia.com>
Reviewed-by: Venkata Nageswara Penumarty <vpenumarty@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Original-Change-Id: I76cdfe4be34bc5375976954343482c376f3a1202

Rebase-Id: R5154d5fcee2e6d53102d346522595db9c16c9b77

arch/arm/mach-tegra/board-cardhu-sdhci.c

index 4d08580..3368010 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "gpio-names.h"
 #include "board.h"
+#include "board-cardhu.h"
 
 #define CARDHU_SD_CD TEGRA_GPIO_PI5
 #define CARDHU_SD_WP TEGRA_GPIO_PT3
@@ -115,14 +116,39 @@ static struct tegra_sdhci_platform_data tegra_sdhci_platform_data3 = {
        .is_8bit_supported = true,
 };
 
+static struct tegra_sdhci_platform_data tegra_pm269_sdhci_platform_data0 = {
+       .clk_id = NULL,
+       .force_hs = 0,
+       .cd_gpio = -1,
+       .wp_gpio = -1,
+       .power_gpio = -1,
+       .tap_delay = 6,
+       .is_voltage_switch_supported = false,
+       .vsd_name = NULL,
+       .vsd_slot_name = NULL,
+       .max_clk = 48000000,
+       .is_8bit_supported = false,
+};
+
+static struct tegra_sdhci_platform_data tegra_pm269_sdhci_platform_data2 = {
+       .clk_id = NULL,
+       .force_hs = 1,
+       .cd_gpio = -1,
+       .wp_gpio = -1,
+       .power_gpio = -1,
+       .tap_delay = 6,
+       .is_voltage_switch_supported = false,
+       .vsd_name = "vddio_sdmmc3",
+       .vsd_slot_name = "vddio_sd_slot",
+       .max_clk = 48000000,
+       .is_8bit_supported = false,
+};
+
 static struct platform_device tegra_sdhci_device0 = {
        .name           = "sdhci-tegra",
        .id             = 0,
        .resource       = sdhci_resource0,
        .num_resources  = ARRAY_SIZE(sdhci_resource0),
-       .dev = {
-               .platform_data = &tegra_sdhci_platform_data0,
-       },
 };
 
 static struct platform_device tegra_sdhci_device2 = {
@@ -130,9 +156,6 @@ static struct platform_device tegra_sdhci_device2 = {
        .id             = 2,
        .resource       = sdhci_resource2,
        .num_resources  = ARRAY_SIZE(sdhci_resource2),
-       .dev = {
-               .platform_data = &tegra_sdhci_platform_data2,
-       },
 };
 
 static struct platform_device tegra_sdhci_device3 = {
@@ -190,21 +213,47 @@ static int cardhu_sd_wp_gpio_init(void)
 int __init cardhu_sdhci_init(void)
 {
        unsigned int rc = 0;
-       platform_device_register(&tegra_sdhci_device3);
-       platform_device_register(&tegra_sdhci_device2);
-
-       /* Fix ME: The gpios have to enabled for hot plug support */
-       rc = cardhu_sd_cd_gpio_init();
-       if (!rc) {
-               tegra_sdhci_platform_data0.cd_gpio = CARDHU_SD_CD;
-               tegra_sdhci_platform_data0.cd_gpio_polarity = 0;
-       }
-       rc = cardhu_sd_wp_gpio_init();
-       if (!rc) {
-               tegra_sdhci_platform_data0.wp_gpio = CARDHU_SD_WP;
-               tegra_sdhci_platform_data0.wp_gpio_polarity = 1;
+       struct board_info board_info;
+       tegra_get_board_info(&board_info);
+       if (board_info.board_id == BOARD_PM269) {
+               tegra_sdhci_device2.dev.platform_data =
+                       &tegra_pm269_sdhci_platform_data2;
+               tegra_sdhci_device0.dev.platform_data =
+                       &tegra_pm269_sdhci_platform_data0;
+               platform_device_register(&tegra_sdhci_device3);
+
+               /* Fix ME: The gpios have to enabled for hot plug support */
+               rc = cardhu_sd_cd_gpio_init();
+               if (!rc) {
+                       tegra_pm269_sdhci_platform_data2.cd_gpio =
+                                                       CARDHU_SD_CD;
+                       tegra_pm269_sdhci_platform_data2.cd_gpio_polarity = 0;
+               }
+
+               platform_device_register(&tegra_sdhci_device2);
+
+       } else {
+               tegra_sdhci_device2.dev.platform_data =
+                       &tegra_sdhci_platform_data2;
+               tegra_sdhci_device0.dev.platform_data =
+                       &tegra_sdhci_platform_data0;
+               platform_device_register(&tegra_sdhci_device3);
+               platform_device_register(&tegra_sdhci_device2);
+
+               /* Fix ME: The gpios have to enabled for hot plug support */
+               rc = cardhu_sd_cd_gpio_init();
+               if (!rc) {
+                       tegra_sdhci_platform_data0.cd_gpio = CARDHU_SD_CD;
+                       tegra_sdhci_platform_data0.cd_gpio_polarity = 0;
+               }
+               rc = cardhu_sd_wp_gpio_init();
+               if (!rc) {
+                       tegra_sdhci_platform_data0.wp_gpio = CARDHU_SD_WP;
+                       tegra_sdhci_platform_data0.wp_gpio_polarity = 1;
+               }
+
+               platform_device_register(&tegra_sdhci_device0);
        }
 
-       platform_device_register(&tegra_sdhci_device0);
        return 0;
 }