ARM: tegra: Create IOMMU map at board_init w/ PLATFORM_IOMMUABLE
Hiroshi Doyu [Mon, 16 Jul 2012 08:10:06 +0000 (11:10 +0300)]
Create IOMMU map at board_init with CONFIG_PLATFORM_IOMMUABLE enabled.

Change-Id: I204b98c145420535821c4cbf03fa61765e619ec1
Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com>
Reviewed-on: http://git-master/r/121219
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

arch/arm/mach-tegra/board-cardhu.c
arch/arm/mach-tegra/board-enterprise.c
arch/arm/mach-tegra/board-kai.c
arch/arm/mach-tegra/board-p1852.c
arch/arm/mach-tegra/devices.c
arch/arm/mach-tegra/devices.h

index 390b564..237dd5f 100644 (file)
@@ -792,9 +792,6 @@ static struct platform_device *cardhu_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_rtc_device,
        &tegra_udc_device,
-#if defined(CONFIG_TEGRA_IOVMM_SMMU) ||  defined(CONFIG_TEGRA_IOMMU_SMMU)
-       &tegra_smmu_device,
-#endif
        &tegra_wdt0_device,
        &tegra_wdt1_device,
        &tegra_wdt2_device,
@@ -1392,6 +1389,7 @@ static void __init tegra_cardhu_init(void)
                                ARRAY_SIZE(throttle_list));
        tegra_clk_init_from_table(cardhu_clk_init_table);
        tegra_enable_pinmux();
+       tegra_smmu_init();
        cardhu_pinmux_init();
        cardhu_i2c_init();
        cardhu_spi_init();
index ceaa60b..2aeb1a0 100644 (file)
@@ -572,9 +572,6 @@ static struct platform_device *enterprise_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_rtc_device,
        &tegra_udc_device,
-#if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
-       &tegra_smmu_device,
-#endif
        &tegra_wdt0_device,
        &tegra_wdt1_device,
        &tegra_wdt2_device,
@@ -988,6 +985,7 @@ static void __init tegra_enterprise_init(void)
                                ARRAY_SIZE(throttle_list));
        tegra_clk_init_from_table(enterprise_clk_init_table);
        tegra_enable_pinmux();
+       tegra_smmu_init();
        enterprise_pinmux_init();
        enterprise_i2c_init();
        enterprise_uart_init();
index bc44bba..2033de3 100644 (file)
@@ -622,9 +622,6 @@ static struct platform_device *kai_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_rtc_device,
        &tegra_udc_device,
-#if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
-       &tegra_smmu_device,
-#endif
        &tegra_wdt0_device,
        &tegra_wdt1_device,
        &tegra_wdt2_device,
@@ -864,6 +861,7 @@ static void __init tegra_kai_init(void)
                                ARRAY_SIZE(throttle_list));
        tegra_clk_init_from_table(kai_clk_init_table);
        tegra_enable_pinmux();
+       tegra_smmu_init();
        kai_pinmux_init();
        kai_i2c_init();
        kai_spi_init();
index e3c0174..46c1ffb 100644 (file)
@@ -362,9 +362,6 @@ static struct platform_device tegra_camera = {
 };
 
 static struct platform_device *p1852_devices[] __initdata = {
-#if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
-       &tegra_smmu_device,
-#endif
 #if defined(CONFIG_TEGRA_AVP)
        &tegra_avp_device,
 #endif
@@ -631,6 +628,7 @@ static void __init tegra_p1852_init(void)
        tegra_init_board_info();
        tegra_clk_init_from_table(p1852_clk_init_table);
        tegra_enable_pinmux();
+       tegra_smmu_init();
        p1852_pinmux_init();
        p1852_i2c_init();
        p1852_i2s_audio_init();
index 3386f45..75f1706 100644 (file)
 #include <mach/usb_phy.h>
 #include <mach/tegra_smmu.h>
 
+#ifdef CONFIG_PLATFORM_IOMMUABLE
+#include <asm/dma-iommu.h>
+#endif
+
 #include "gpio-names.h"
 #include "devices.h"
 
@@ -1705,6 +1709,30 @@ int tegra_smmu_window_count(void)
 {
        return ARRAY_SIZE(tegra_smmu);
 }
+
+#ifdef CONFIG_PLATFORM_IOMMUABLE
+static void tegra_smmu_map_init(struct platform_device *pdev)
+{
+       struct dma_iommu_mapping *map;
+
+       map = arm_iommu_create_mapping(&platform_bus_type,
+                                      TEGRA_IOMMU_BASE, TEGRA_IOMMU_SIZE, 0);
+       if (IS_ERR(map))
+               dev_err(&pdev->dev, "Failed create IOVA map %08x-%08x\n",
+                       TEGRA_IOMMU_BASE,
+                       TEGRA_IOMMU_BASE + TEGRA_IOMMU_SIZE - 1);
+}
+#else
+static inline void tegra_smmu_map_init(struct platform_device *pdev)
+{
+}
+#endif
+
+void tegra_smmu_init(void)
+{
+       platform_device_register(&tegra_smmu_device);
+       tegra_smmu_map_init(&tegra_smmu_device);
+}
 #endif
 
 #if defined(CONFIG_ARCH_TEGRA_2x_SOC)
index 1eecd39..7526f48 100644 (file)
@@ -170,4 +170,12 @@ extern struct platform_device tegra_cec_device;
 
 void __init tegra_init_debug_uart_rate(void);
 
+#if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
+extern void tegra_smmu_init(void);
+#else
+static inline void tegra_smmu_init(void)
+{
+}
+#endif
+
 #endif