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 | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 29 | /* |
| 30 | * Create alias for USB host PHY clock. |
| 31 | * Remove this when clock phandle can be provided via DT |
| 32 | */ |
| 33 | static void __init __used legacy_init_ehci_clk(char *clkname) |
| 34 | { |
| 35 | int ret; |
| 36 | |
| 37 | ret = clk_add_alias("main_clk", NULL, clkname, NULL); |
| 38 | if (ret) |
| 39 | pr_err("%s:Failed to add main_clk alias to %s :%d\n", |
| 40 | __func__, clkname, ret); |
| 41 | } |
| 42 | |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 43 | #if IS_ENABLED(CONFIG_WL12XX) |
| 44 | |
| 45 | static struct wl12xx_platform_data wl12xx __initdata; |
| 46 | |
| 47 | static void __init __used legacy_init_wl12xx(unsigned ref_clock, |
| 48 | unsigned tcxo_clock, |
| 49 | int gpio) |
| 50 | { |
| 51 | int res; |
| 52 | |
| 53 | wl12xx.board_ref_clock = ref_clock; |
| 54 | wl12xx.board_tcxo_clock = tcxo_clock; |
| 55 | wl12xx.irq = gpio_to_irq(gpio); |
| 56 | |
| 57 | res = wl12xx_set_platform_data(&wl12xx); |
| 58 | if (res) { |
| 59 | pr_err("error setting wl12xx data: %d\n", res); |
| 60 | return; |
| 61 | } |
| 62 | } |
| 63 | #else |
| 64 | static inline void legacy_init_wl12xx(unsigned ref_clock, |
| 65 | unsigned tcxo_clock, |
| 66 | int gpio) |
| 67 | { |
| 68 | } |
| 69 | #endif |
| 70 | |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 71 | #ifdef CONFIG_ARCH_OMAP3 |
| 72 | static void __init hsmmc2_internal_input_clk(void) |
| 73 | { |
| 74 | u32 reg; |
| 75 | |
| 76 | reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1); |
| 77 | reg |= OMAP2_MMCSDIO2ADPCLKISEL; |
| 78 | omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1); |
| 79 | } |
Javier Martinez Canillas | 15c9887 | 2013-10-09 11:19:18 +0200 | [diff] [blame] | 80 | |
| 81 | static void __init omap3_igep0020_legacy_init(void) |
| 82 | { |
| 83 | omap3_igep2_display_init_of(); |
| 84 | } |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 85 | #endif /* CONFIG_ARCH_OMAP3 */ |
| 86 | |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 87 | #ifdef CONFIG_ARCH_OMAP4 |
| 88 | static void __init omap4_sdp_legacy_init(void) |
| 89 | { |
| 90 | omap_4430sdp_display_init_of(); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 91 | legacy_init_wl12xx(WL12XX_REFCLOCK_26, |
| 92 | WL12XX_TCXOCLOCK_26, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | static void __init omap4_panda_legacy_init(void) |
| 96 | { |
| 97 | omap4_panda_display_init_of(); |
| 98 | legacy_init_ehci_clk("auxclk3_ck"); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 99 | legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 100 | } |
| 101 | #endif |
| 102 | |
| 103 | #ifdef CONFIG_SOC_OMAP5 |
| 104 | static void __init omap5_uevm_legacy_init(void) |
| 105 | { |
| 106 | legacy_init_ehci_clk("auxclk1_ck"); |
| 107 | } |
| 108 | #endif |
| 109 | |
Tony Lindgren | 30a69ef | 2013-10-10 15:45:13 -0700 | [diff] [blame^] | 110 | static struct pcs_pdata pcs_pdata; |
| 111 | |
| 112 | void omap_pcs_legacy_init(int irq, void (*rearm)(void)) |
| 113 | { |
| 114 | pcs_pdata.irq = irq; |
| 115 | pcs_pdata.rearm = rearm; |
| 116 | } |
| 117 | |
Tony Lindgren | 8651bd8 | 2013-10-10 15:45:12 -0700 | [diff] [blame] | 118 | struct of_dev_auxdata omap_auxdata_lookup[] __initdata = { |
Tony Lindgren | 30a69ef | 2013-10-10 15:45:13 -0700 | [diff] [blame^] | 119 | #ifdef CONFIG_ARCH_OMAP3 |
| 120 | OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata), |
| 121 | OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata), |
| 122 | #endif |
| 123 | #ifdef CONFIG_ARCH_OMAP4 |
| 124 | OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata), |
| 125 | OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata), |
| 126 | #endif |
Tony Lindgren | 8651bd8 | 2013-10-10 15:45:12 -0700 | [diff] [blame] | 127 | { /* sentinel */ }, |
| 128 | }; |
| 129 | |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 130 | static struct pdata_init pdata_quirks[] __initdata = { |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 131 | #ifdef CONFIG_ARCH_OMAP3 |
| 132 | { "nokia,omap3-n9", hsmmc2_internal_input_clk, }, |
| 133 | { "nokia,omap3-n950", hsmmc2_internal_input_clk, }, |
Javier Martinez Canillas | 15c9887 | 2013-10-09 11:19:18 +0200 | [diff] [blame] | 134 | { "isee,omap3-igep0020", omap3_igep0020_legacy_init, }, |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 135 | #endif |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 136 | #ifdef CONFIG_ARCH_OMAP4 |
| 137 | { "ti,omap4-sdp", omap4_sdp_legacy_init, }, |
| 138 | { "ti,omap4-panda", omap4_panda_legacy_init, }, |
| 139 | #endif |
| 140 | #ifdef CONFIG_SOC_OMAP5 |
| 141 | { "ti,omap5-uevm", omap5_uevm_legacy_init, }, |
| 142 | #endif |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 143 | { /* sentinel */ }, |
| 144 | }; |
| 145 | |
Tony Lindgren | 8651bd8 | 2013-10-10 15:45:12 -0700 | [diff] [blame] | 146 | void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table) |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 147 | { |
| 148 | struct pdata_init *quirks = pdata_quirks; |
| 149 | |
Tony Lindgren | 8651bd8 | 2013-10-10 15:45:12 -0700 | [diff] [blame] | 150 | omap_sdrc_init(NULL, NULL); |
| 151 | of_platform_populate(NULL, omap_dt_match_table, |
| 152 | omap_auxdata_lookup, NULL); |
| 153 | |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 154 | while (quirks->compatible) { |
| 155 | if (of_machine_is_compatible(quirks->compatible)) { |
| 156 | if (quirks->fn) |
| 157 | quirks->fn(); |
| 158 | break; |
| 159 | } |
| 160 | quirks++; |
| 161 | } |
| 162 | } |