]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/blob - arch/arm/mach-omap2/pdata-quirks.c
ARM: OMAP2+: use separate IOMMU pdata to fix DRA7 IPU1 boot
[android-sdk/kernel-video.git] / arch / arm / mach-omap2 / pdata-quirks.c
1 /*
2  * Legacy platform_data quirks
3  *
4  * Copyright (C) 2013 Texas Instruments
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/clk.h>
11 #include <linux/davinci_emac.h>
12 #include <linux/gpio.h>
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/of_platform.h>
16 #include <linux/wl12xx.h>
18 #include <linux/platform_data/pinctrl-single.h>
19 #include <linux/platform_data/iommu-omap.h>
21 #include "am35xx.h"
22 #include "common.h"
23 #include "common-board-devices.h"
24 #include "dss-common.h"
25 #include "control.h"
26 #include "omap-secure.h"
27 #include "soc.h"
28 #include "omap_device.h"
30 struct pdata_init {
31         const char *compatible;
32         void (*fn)(void);
33 };
35 struct of_dev_auxdata omap_auxdata_lookup[];
36 static struct twl4030_gpio_platform_data twl_gpio_auxdata;
38 #if IS_ENABLED(CONFIG_OMAP_IOMMU)
39 int omap_iommu_set_pwrdm_constraint(struct platform_device *pdev, bool request,
40                                     u8 *pwrst);
41 #else
42 static inline int omap_iommu_set_pwrdm_constraint(struct platform_device *pdev,
43                                                   bool request, u8 *pwrst)
44 {
45         return 0;
46 }
47 #endif
49 #if IS_ENABLED(CONFIG_WL12XX)
51 static struct wl12xx_platform_data wl12xx __initdata;
53 static void __init __used legacy_init_wl12xx(unsigned ref_clock,
54                                              unsigned tcxo_clock,
55                                              int gpio)
56 {
57         int res;
59         wl12xx.board_ref_clock = ref_clock;
60         wl12xx.board_tcxo_clock = tcxo_clock;
61         wl12xx.irq = gpio_to_irq(gpio);
63         res = wl12xx_set_platform_data(&wl12xx);
64         if (res) {
65                 pr_err("error setting wl12xx data: %d\n", res);
66                 return;
67         }
68 }
69 #else
70 static inline void legacy_init_wl12xx(unsigned ref_clock,
71                                       unsigned tcxo_clock,
72                                       int gpio)
73 {
74 }
75 #endif
77 #ifdef CONFIG_MACH_NOKIA_N8X0
78 static void __init omap2420_n8x0_legacy_init(void)
79 {
80         omap_auxdata_lookup[0].platform_data = n8x0_legacy_init();
81 }
82 #else
83 #define omap2420_n8x0_legacy_init       NULL
84 #endif
86 #ifdef CONFIG_ARCH_OMAP3
87 static void __init hsmmc2_internal_input_clk(void)
88 {
89         u32 reg;
91         reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
92         reg |= OMAP2_MMCSDIO2ADPCLKISEL;
93         omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
94 }
96 static struct iommu_platform_data omap3_iommu_pdata = {
97         .reset_name = "mmu",
98         .assert_reset = omap_device_assert_hardreset,
99         .deassert_reset = omap_device_deassert_hardreset,
100         .device_enable = omap_device_enable,
101         .device_idle = omap_device_idle,
102 };
104 static struct iommu_platform_data omap3_iommu_isp_pdata = {
105         .device_enable = omap_device_enable,
106         .device_idle = omap_device_idle,
107 };
109 static int omap3_sbc_t3730_twl_callback(struct device *dev,
110                                            unsigned gpio,
111                                            unsigned ngpio)
113         int res;
115         res = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH,
116                                "wlan rst");
117         if (res)
118                 return res;
120         gpio_export(gpio, 0);
122         return 0;
125 static void __init omap3_sbc_t3730_twl_init(void)
127         twl_gpio_auxdata.setup = omap3_sbc_t3730_twl_callback;
130 static void __init omap3_sbc_t3730_legacy_init(void)
132         legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 136);
133         omap_ads7846_init(1, 57, 0, NULL);
136 static void __init omap3_igep0020_legacy_init(void)
140 static void __init omap3_evm_legacy_init(void)
142         legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149);
145 static void __init omap3_zoom_legacy_init(void)
147         legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162);
150 static void am35xx_enable_emac_int(void)
152         u32 v;
154         v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
155         v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
156               AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
157         omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
158         omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
161 static void am35xx_disable_emac_int(void)
163         u32 v;
165         v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
166         v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
167         omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
168         omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
171 static struct emac_platform_data am35xx_emac_pdata = {
172         .interrupt_enable       = am35xx_enable_emac_int,
173         .interrupt_disable      = am35xx_disable_emac_int,
174 };
176 static void __init am3517_evm_legacy_init(void)
178         u32 v;
180         v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
181         v &= ~AM35XX_CPGMACSS_SW_RST;
182         omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
183         omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */
186 static void __init nokia_n900_legacy_init(void)
188         hsmmc2_internal_input_clk();
190         if (omap_type() == OMAP2_DEVICE_TYPE_SEC) {
191                 if (IS_ENABLED(CONFIG_ARM_ERRATA_430973)) {
192                         pr_info("RX-51: Enabling ARM errata 430973 workaround\n");
193                         /* set IBE to 1 */
194                         rx51_secure_update_aux_cr(BIT(6), 0);
195                 } else {
196                         pr_warning("RX-51: Not enabling ARM errata 430973 workaround\n");
197                         pr_warning("Thumb binaries may crash randomly without this workaround\n");
198                 }
199         }
201 #endif /* CONFIG_ARCH_OMAP3 */
203 #ifdef CONFIG_ARCH_OMAP4
204 static void __init omap4_sdp_legacy_init(void)
206         legacy_init_wl12xx(WL12XX_REFCLOCK_26,
207                            WL12XX_TCXOCLOCK_26, 53);
210 static void __init omap4_panda_legacy_init(void)
212         legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
214 #endif
216 #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
217         defined(CONFIG_SOC_DRA7XX)
218 static struct iommu_platform_data omap4_iommu_pdata = {
219         .reset_name = "mmu_cache",
220         .assert_reset = omap_device_assert_hardreset,
221         .deassert_reset = omap_device_deassert_hardreset,
222         .device_enable = omap_device_enable,
223         .device_idle = omap_device_idle,
224 };
225 #endif
227 #ifdef CONFIG_SOC_DRA7XX
228 static struct iommu_platform_data dra7_dsp_mmu_edma_pdata = {
229         .device_enable = omap_device_enable,
230         .device_idle = omap_device_idle,
231 };
233 static struct iommu_platform_data dra7_ipu1_iommu_pdata = {
234         .reset_name = "mmu_cache",
235         .assert_reset = omap_device_assert_hardreset,
236         .deassert_reset = omap_device_deassert_hardreset,
237         .device_enable = omap_device_enable,
238         .device_idle = omap_device_idle,
239         .set_pwrdm_constraint = omap_iommu_set_pwrdm_constraint,
240 };
241 #endif
243 #ifdef CONFIG_SOC_AM33XX
244 static void __init am335x_evmsk_legacy_init(void)
246         legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 31);
248 #endif
250 #ifdef CONFIG_SOC_OMAP5
251 static void __init omap5_uevm_legacy_init(void)
254 #endif
256 static struct pcs_pdata pcs_pdata;
258 void omap_pcs_legacy_init(int irq, void (*rearm)(void))
260         pcs_pdata.irq = irq;
261         pcs_pdata.rearm = rearm;
264 /*
265  * GPIOs for TWL are initialized by the I2C bus and need custom
266  * handing until DSS has device tree bindings.
267  */
268 void omap_auxdata_legacy_init(struct device *dev)
270         if (dev->platform_data)
271                 return;
273         if (strcmp("twl4030-gpio", dev_name(dev)))
274                 return;
276         dev->platform_data = &twl_gpio_auxdata;
279 /*
280  * Few boards still need auxdata populated before we populate
281  * the dev entries in of_platform_populate().
282  */
283 static struct pdata_init auxdata_quirks[] __initdata = {
284 #ifdef CONFIG_SOC_OMAP2420
285         { "nokia,n800", omap2420_n8x0_legacy_init, },
286         { "nokia,n810", omap2420_n8x0_legacy_init, },
287         { "nokia,n810-wimax", omap2420_n8x0_legacy_init, },
288 #endif
289 #ifdef CONFIG_ARCH_OMAP3
290         { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_twl_init, },
291 #endif
292         { /* sentinel */ },
293 };
295 struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
296 #ifdef CONFIG_MACH_NOKIA_N8X0
297         OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
298 #endif
299 #ifdef CONFIG_ARCH_OMAP3
300         OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
301         OF_DEV_AUXDATA("ti,omap3-padconf", 0x480025a0, "480025a0.pinmux", &pcs_pdata),
302         OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
303         OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
304                        &omap3_iommu_pdata),
305         OF_DEV_AUXDATA("ti,omap2-iommu", 0x480bd400, "480bd400.mmu",
306                        &omap3_iommu_isp_pdata),
307         /* Only on am3517 */
308         OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
309         OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
310                        &am35xx_emac_pdata),
311 #endif
312 #ifdef CONFIG_SOC_AM43XX
313         OF_DEV_AUXDATA("ti,am437-padconf", 0x44e10800, "44e10800.pinmux", &pcs_pdata),
314 #endif
315 #ifdef CONFIG_ARCH_OMAP4
316         OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
317         OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
318 #endif
319 #ifdef CONFIG_SOC_OMAP5
320         OF_DEV_AUXDATA("ti,omap5-padconf", 0x4a002840, "4a002840.pinmux", &pcs_pdata),
321         OF_DEV_AUXDATA("ti,omap5-padconf", 0x4ae0c840, "4ae0c840.pinmux", &pcs_pdata),
322 #endif
323 #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
324         OF_DEV_AUXDATA("ti,omap4-iommu", 0x4a066000, "4a066000.mmu",
325                        &omap4_iommu_pdata),
326         OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu",
327                        &omap4_iommu_pdata),
328 #endif
329 #ifdef CONFIG_SOC_DRA7XX
330         OF_DEV_AUXDATA("ti,dra7-padconf", 0x4a003400, "4a003400.pinmux", &pcs_pdata),
331         OF_DEV_AUXDATA("ti,dra7-iommu", 0x40d01000, "40d01000.mmu",
332                        &omap4_iommu_pdata),
333         OF_DEV_AUXDATA("ti,dra7-iommu", 0x40d02000, "40d02000.mmu",
334                        &dra7_dsp_mmu_edma_pdata),
335         OF_DEV_AUXDATA("ti,dra7-iommu", 0x41501000, "41501000.mmu",
336                        &omap4_iommu_pdata),
337         OF_DEV_AUXDATA("ti,dra7-iommu", 0x41502000, "41502000.mmu",
338                        &dra7_dsp_mmu_edma_pdata),
339         OF_DEV_AUXDATA("ti,dra7-iommu", 0x55082000, "55082000.mmu",
340                        &omap4_iommu_pdata),
341         OF_DEV_AUXDATA("ti,dra7-iommu", 0x58882000, "58882000.mmu",
342                        &dra7_ipu1_iommu_pdata),
343 #endif
344         { /* sentinel */ },
345 };
347 /*
348  * Few boards still need to initialize some legacy devices with
349  * platform data until the drivers support device tree.
350  */
351 static struct pdata_init pdata_quirks[] __initdata = {
352 #ifdef CONFIG_ARCH_OMAP3
353         { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_legacy_init, },
354         { "nokia,omap3-n900", nokia_n900_legacy_init, },
355         { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
356         { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
357         { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
358         { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
359         { "ti,omap3-zoom3", omap3_zoom_legacy_init, },
360         { "ti,am3517-evm", am3517_evm_legacy_init, },
361 #endif
362 #ifdef CONFIG_ARCH_OMAP4
363         { "ti,omap4-sdp", omap4_sdp_legacy_init, },
364         { "ti,omap4-panda", omap4_panda_legacy_init, },
365 #endif
366 #ifdef CONFIG_SOC_AM33XX
367         { "ti,am335x-evmsk", am335x_evmsk_legacy_init, },
368 #endif
369 #ifdef CONFIG_SOC_OMAP5
370         { "ti,omap5-uevm", omap5_uevm_legacy_init, },
371 #endif
372         { /* sentinel */ },
373 };
375 static void pdata_quirks_check(struct pdata_init *quirks)
377         while (quirks->compatible) {
378                 if (of_machine_is_compatible(quirks->compatible)) {
379                         if (quirks->fn)
380                                 quirks->fn();
381                         break;
382                 }
383                 quirks++;
384         }
387 void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
389         omap_sdrc_init(NULL, NULL);
390         pdata_quirks_check(auxdata_quirks);
391         of_platform_populate(NULL, omap_dt_match_table,
392                              omap_auxdata_lookup, NULL);
393         pdata_quirks_check(pdata_quirks);