Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 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> |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 11 | #include <linux/gpio.h> |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 12 | #include <linux/init.h> |
| 13 | #include <linux/kernel.h> |
Tony Lindgren | 8651bd8 | 2013-10-10 15:45:12 -0700 | [diff] [blame] | 14 | #include <linux/of_platform.h> |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 15 | #include <linux/wl12xx.h> |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 16 | |
Tony Lindgren | 30a69ef | 2013-10-10 15:45:13 -0700 | [diff] [blame] | 17 | #include <linux/platform_data/pinctrl-single.h> |
| 18 | |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 19 | #include "common.h" |
| 20 | #include "common-board-devices.h" |
| 21 | #include "dss-common.h" |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 22 | #include "control.h" |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 23 | |
| 24 | struct pdata_init { |
| 25 | const char *compatible; |
| 26 | void (*fn)(void); |
| 27 | }; |
| 28 | |
Tony Lindgren | fa590c9 | 2013-11-25 15:17:10 -0800 | [diff] [blame^] | 29 | struct of_dev_auxdata omap_auxdata_lookup[]; |
| 30 | |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 31 | /* |
| 32 | * Create alias for USB host PHY clock. |
| 33 | * Remove this when clock phandle can be provided via DT |
| 34 | */ |
| 35 | static void __init __used legacy_init_ehci_clk(char *clkname) |
| 36 | { |
| 37 | int ret; |
| 38 | |
| 39 | ret = clk_add_alias("main_clk", NULL, clkname, NULL); |
| 40 | if (ret) |
| 41 | pr_err("%s:Failed to add main_clk alias to %s :%d\n", |
| 42 | __func__, clkname, ret); |
| 43 | } |
| 44 | |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 45 | #if IS_ENABLED(CONFIG_WL12XX) |
| 46 | |
| 47 | static struct wl12xx_platform_data wl12xx __initdata; |
| 48 | |
| 49 | static void __init __used legacy_init_wl12xx(unsigned ref_clock, |
| 50 | unsigned tcxo_clock, |
| 51 | int gpio) |
| 52 | { |
| 53 | int res; |
| 54 | |
| 55 | wl12xx.board_ref_clock = ref_clock; |
| 56 | wl12xx.board_tcxo_clock = tcxo_clock; |
| 57 | wl12xx.irq = gpio_to_irq(gpio); |
| 58 | |
| 59 | res = wl12xx_set_platform_data(&wl12xx); |
| 60 | if (res) { |
| 61 | pr_err("error setting wl12xx data: %d\n", res); |
| 62 | return; |
| 63 | } |
| 64 | } |
| 65 | #else |
| 66 | static inline void legacy_init_wl12xx(unsigned ref_clock, |
| 67 | unsigned tcxo_clock, |
| 68 | int gpio) |
| 69 | { |
| 70 | } |
| 71 | #endif |
| 72 | |
Tony Lindgren | fa590c9 | 2013-11-25 15:17:10 -0800 | [diff] [blame^] | 73 | #ifdef CONFIG_MACH_NOKIA_N8X0 |
| 74 | static void __init omap2420_n8x0_legacy_init(void) |
| 75 | { |
| 76 | omap_auxdata_lookup[0].platform_data = n8x0_legacy_init(); |
| 77 | } |
| 78 | #else |
| 79 | #define omap2420_n8x0_legacy_init NULL |
| 80 | #endif |
| 81 | |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 82 | #ifdef CONFIG_ARCH_OMAP3 |
| 83 | static void __init hsmmc2_internal_input_clk(void) |
| 84 | { |
| 85 | u32 reg; |
| 86 | |
| 87 | reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1); |
| 88 | reg |= OMAP2_MMCSDIO2ADPCLKISEL; |
| 89 | omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1); |
| 90 | } |
Javier Martinez Canillas | 15c9887 | 2013-10-09 11:19:18 +0200 | [diff] [blame] | 91 | |
| 92 | static void __init omap3_igep0020_legacy_init(void) |
| 93 | { |
| 94 | omap3_igep2_display_init_of(); |
| 95 | } |
Tony Lindgren | 79b39f7 | 2013-10-11 09:20:54 -0700 | [diff] [blame] | 96 | |
| 97 | static void __init omap3_evm_legacy_init(void) |
| 98 | { |
| 99 | legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149); |
| 100 | } |
| 101 | |
| 102 | static void __init omap3_zoom_legacy_init(void) |
| 103 | { |
| 104 | legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162); |
| 105 | } |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 106 | #endif /* CONFIG_ARCH_OMAP3 */ |
| 107 | |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 108 | #ifdef CONFIG_ARCH_OMAP4 |
| 109 | static void __init omap4_sdp_legacy_init(void) |
| 110 | { |
| 111 | omap_4430sdp_display_init_of(); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 112 | legacy_init_wl12xx(WL12XX_REFCLOCK_26, |
| 113 | WL12XX_TCXOCLOCK_26, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static void __init omap4_panda_legacy_init(void) |
| 117 | { |
| 118 | omap4_panda_display_init_of(); |
| 119 | legacy_init_ehci_clk("auxclk3_ck"); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 120 | legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 121 | } |
| 122 | #endif |
| 123 | |
| 124 | #ifdef CONFIG_SOC_OMAP5 |
| 125 | static void __init omap5_uevm_legacy_init(void) |
| 126 | { |
| 127 | legacy_init_ehci_clk("auxclk1_ck"); |
| 128 | } |
| 129 | #endif |
| 130 | |
Tony Lindgren | 30a69ef | 2013-10-10 15:45:13 -0700 | [diff] [blame] | 131 | static struct pcs_pdata pcs_pdata; |
| 132 | |
| 133 | void omap_pcs_legacy_init(int irq, void (*rearm)(void)) |
| 134 | { |
| 135 | pcs_pdata.irq = irq; |
| 136 | pcs_pdata.rearm = rearm; |
| 137 | } |
| 138 | |
Tony Lindgren | 036582f | 2013-11-25 15:17:09 -0800 | [diff] [blame] | 139 | /* |
| 140 | * Few boards still need auxdata populated before we populate |
| 141 | * the dev entries in of_platform_populate(). |
| 142 | */ |
| 143 | static struct pdata_init auxdata_quirks[] __initdata = { |
Tony Lindgren | fa590c9 | 2013-11-25 15:17:10 -0800 | [diff] [blame^] | 144 | #ifdef CONFIG_SOC_OMAP2420 |
| 145 | { "nokia,n800", omap2420_n8x0_legacy_init, }, |
| 146 | { "nokia,n810", omap2420_n8x0_legacy_init, }, |
| 147 | { "nokia,n810-wimax", omap2420_n8x0_legacy_init, }, |
| 148 | #endif |
Tony Lindgren | 036582f | 2013-11-25 15:17:09 -0800 | [diff] [blame] | 149 | { /* sentinel */ }, |
| 150 | }; |
| 151 | |
Tony Lindgren | 8651bd8 | 2013-10-10 15:45:12 -0700 | [diff] [blame] | 152 | struct of_dev_auxdata omap_auxdata_lookup[] __initdata = { |
Tony Lindgren | 036582f | 2013-11-25 15:17:09 -0800 | [diff] [blame] | 153 | #ifdef CONFIG_MACH_NOKIA_N8X0 |
| 154 | OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL), |
| 155 | #endif |
Tony Lindgren | 30a69ef | 2013-10-10 15:45:13 -0700 | [diff] [blame] | 156 | #ifdef CONFIG_ARCH_OMAP3 |
| 157 | OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata), |
| 158 | OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata), |
| 159 | #endif |
| 160 | #ifdef CONFIG_ARCH_OMAP4 |
| 161 | OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata), |
| 162 | OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata), |
| 163 | #endif |
Tony Lindgren | 8651bd8 | 2013-10-10 15:45:12 -0700 | [diff] [blame] | 164 | { /* sentinel */ }, |
| 165 | }; |
| 166 | |
Tony Lindgren | 036582f | 2013-11-25 15:17:09 -0800 | [diff] [blame] | 167 | /* |
| 168 | * Few boards still need to initialize some legacy devices with |
| 169 | * platform data until the drivers support device tree. |
| 170 | */ |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 171 | static struct pdata_init pdata_quirks[] __initdata = { |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 172 | #ifdef CONFIG_ARCH_OMAP3 |
Tony Lindgren | edd5eb4 | 2013-11-25 14:23:45 -0800 | [diff] [blame] | 173 | { "nokia,omap3-n900", hsmmc2_internal_input_clk, }, |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 174 | { "nokia,omap3-n9", hsmmc2_internal_input_clk, }, |
| 175 | { "nokia,omap3-n950", hsmmc2_internal_input_clk, }, |
Javier Martinez Canillas | 15c9887 | 2013-10-09 11:19:18 +0200 | [diff] [blame] | 176 | { "isee,omap3-igep0020", omap3_igep0020_legacy_init, }, |
Tony Lindgren | 79b39f7 | 2013-10-11 09:20:54 -0700 | [diff] [blame] | 177 | { "ti,omap3-evm-37xx", omap3_evm_legacy_init, }, |
| 178 | { "ti,omap3-zoom3", omap3_zoom_legacy_init, }, |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 179 | #endif |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 180 | #ifdef CONFIG_ARCH_OMAP4 |
| 181 | { "ti,omap4-sdp", omap4_sdp_legacy_init, }, |
| 182 | { "ti,omap4-panda", omap4_panda_legacy_init, }, |
| 183 | #endif |
| 184 | #ifdef CONFIG_SOC_OMAP5 |
| 185 | { "ti,omap5-uevm", omap5_uevm_legacy_init, }, |
| 186 | #endif |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 187 | { /* sentinel */ }, |
| 188 | }; |
| 189 | |
Tony Lindgren | 036582f | 2013-11-25 15:17:09 -0800 | [diff] [blame] | 190 | static void pdata_quirks_check(struct pdata_init *quirks) |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 191 | { |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 192 | while (quirks->compatible) { |
| 193 | if (of_machine_is_compatible(quirks->compatible)) { |
| 194 | if (quirks->fn) |
| 195 | quirks->fn(); |
| 196 | break; |
| 197 | } |
| 198 | quirks++; |
| 199 | } |
| 200 | } |
Tony Lindgren | 036582f | 2013-11-25 15:17:09 -0800 | [diff] [blame] | 201 | |
| 202 | void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table) |
| 203 | { |
| 204 | omap_sdrc_init(NULL, NULL); |
| 205 | pdata_quirks_check(auxdata_quirks); |
| 206 | of_platform_populate(NULL, omap_dt_match_table, |
| 207 | omap_auxdata_lookup, NULL); |
| 208 | pdata_quirks_check(pdata_quirks); |
| 209 | } |