arm: tegra: cardhu: Provide list of clock source to spi driver
Laxman Dewangan [Fri, 15 Jul 2011 16:44:29 +0000 (21:44 +0530)]
Providing list of clock source to the spi driver so that driver can
select best clock source which gives minimum error for desired speed.

bug 851642

Original-Change-Id: Id7e4b332f57b209f0ebd3f03cc8190b4c8d7ab6a
Reviewed-on: http://git-master/r/41241
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: R534fda0233310be9cb61ae63a02acad4cbe13f12

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

index b026b5a..76cbb3a 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/spi/spi.h>
 #include <linux/i2c/atmel_mxt_ts.h>
 #include <linux/tegra_uart.h>
+#include <linux/spi-tegra.h>
 
 #include <sound/wm8903.h>
 
@@ -359,6 +360,45 @@ static struct platform_device tegra_camera = {
        .id = -1,
 };
 
+static struct platform_device *cardhu_spi_devices[] __initdata = {
+       &tegra_spi_device4,
+};
+
+struct spi_clk_parent spi_parent_clk[] = {
+       [0] = {.name = "pll_p"},
+       [1] = {.name = "pll_m"},
+       [2] = {.name = "clk_m"},
+};
+
+static struct tegra_spi_platform_data cardhu_spi_pdata = {
+       .is_dma_based           = true,
+       .max_dma_buffer         = (16 * 1024),
+       .is_clkon_always        = false,
+       .max_rate               = 100000000,
+};
+
+static void __init cardhu_spi_init(void)
+{
+       int i;
+       struct clk *c;
+
+       for (i = 0; i < ARRAY_SIZE(spi_parent_clk); ++i) {
+               c = tegra_get_clock_by_name(spi_parent_clk[i].name);
+               if (IS_ERR_OR_NULL(c)) {
+                       pr_err("Not able to get the clock for %s\n",
+                                               spi_parent_clk[i].name);
+                       continue;
+               }
+               spi_parent_clk[i].parent_clk = c;
+               spi_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
+       }
+       cardhu_spi_pdata.parent_clk_list = spi_parent_clk;
+       cardhu_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk);
+       tegra_spi_device4.dev.platform_data = &cardhu_spi_pdata;
+       platform_add_devices(cardhu_spi_devices,
+                               ARRAY_SIZE(cardhu_spi_devices));
+}
+
 static struct tegra_wm8903_platform_data cardhu_audio_pdata = {
        .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
        .gpio_hp_det            = TEGRA_GPIO_HP_DET,
@@ -389,7 +429,6 @@ static struct platform_device *cardhu_devices[] __initdata = {
        &tegra_avp_device,
 #endif
        &tegra_camera,
-       &tegra_spi_device4,
 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
        &tegra_se_device,
 #endif
@@ -645,6 +684,7 @@ static void __init tegra_cardhu_init(void)
        tegra_clk_init_from_table(cardhu_clk_init_table);
        cardhu_pinmux_init();
        cardhu_i2c_init();
+       cardhu_spi_init();
        cardhu_usb_init();
 #ifdef CONFIG_TEGRA_EDP_LIMITS
        cardhu_edp_init();