ARM: tegra: pm269: sdhci: Support for PM269
Pradeep Goudagunta [Wed, 4 May 2011 11:31:23 +0000 (16:31 +0530)]
Added support to read board ID and then configure clk frequency for
WiFi and SDCARD_WP gpio initialization.

Bug 823160

Original-Change-Id: Ia05c8258b275541c2130fc8a038a8fc4348a5866
Reviewed-on: http://git-master/r/30373
Reviewed-by: Niket Sirsi <nsirsi@nvidia.com>
Tested-by: Niket Sirsi <nsirsi@nvidia.com>

Rebase-Id: Re4a5c9ef539f2273f3a108972c0890fc343fe86e

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

index 701c8bb..a89f60f 100644 (file)
@@ -33,6 +33,7 @@
 
 #define CARDHU_SD_CD TEGRA_GPIO_PI5
 #define CARDHU_SD_WP TEGRA_GPIO_PT3
+#define PM269_SD_WP TEGRA_GPIO_PZ4
 
 static struct resource sdhci_resource0[] = {
        [0] = {
@@ -86,7 +87,7 @@ static struct tegra_sdhci_platform_data tegra_sdhci_platform_data0 = {
        .slot_rail_name = NULL,
        .vdd_max_uv = -1,
        .vdd_min_uv = -1,
-       .max_clk = 48000000,
+       .max_clk = 0,
        .is_8bit_supported = false,
 };
 
@@ -122,41 +123,14 @@ 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,
-       .vdd_rail_name = NULL,
-       .slot_rail_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,
-       .vdd_rail_name = "vddio_sdmmc3",
-       .slot_rail_name = "vddio_sd_slot",
-       .vdd_max_uv = 3300000,
-       .vdd_min_uv = 3300000,
-       .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 = {
@@ -164,6 +138,9 @@ 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 = {
@@ -218,50 +195,61 @@ static int cardhu_sd_wp_gpio_init(void)
        return 0;
 }
 
+static int pm269_sd_wp_gpio_init(void)
+{
+       unsigned int rc = 0;
+
+       rc = gpio_request(PM269_SD_WP, "write_protect");
+       if (rc) {
+               pr_err("Write protect gpio request failed:%d\n", rc);
+               return rc;
+       }
+
+       tegra_gpio_enable(PM269_SD_WP);
+
+       rc = gpio_direction_input(PM269_SD_WP);
+       if (rc) {
+               pr_err("Unable to configure direction for write protect gpio:%d\n", rc);
+               return rc;
+       }
+
+       return 0;
+}
+
 int __init cardhu_sdhci_init(void)
 {
        unsigned int rc = 0;
        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();
+               tegra_sdhci_platform_data2.max_clk = 12000000;
+               rc = pm269_sd_wp_gpio_init();
                if (!rc) {
-                       tegra_pm269_sdhci_platform_data2.cd_gpio =
-                                                       CARDHU_SD_CD;
-                       tegra_pm269_sdhci_platform_data2.cd_gpio_polarity = 0;
+                       tegra_sdhci_platform_data0.wp_gpio = PM269_SD_WP;
+                       tegra_sdhci_platform_data0.wp_gpio_polarity = 1;
                }
-
-               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;
-               }
+               tegra_sdhci_platform_data2.max_clk = 48000000;
                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_device3);
+       platform_device_register(&tegra_sdhci_device2);
 
-               platform_device_register(&tegra_sdhci_device0);
+       /* 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;
        }
 
+
+
+       platform_device_register(&tegra_sdhci_device0);
+
        return 0;
 }