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 | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 14 | #include <linux/wl12xx.h> |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 15 | |
| 16 | #include "common.h" |
| 17 | #include "common-board-devices.h" |
| 18 | #include "dss-common.h" |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 19 | #include "control.h" |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 20 | |
| 21 | struct pdata_init { |
| 22 | const char *compatible; |
| 23 | void (*fn)(void); |
| 24 | }; |
| 25 | |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 26 | /* |
| 27 | * Create alias for USB host PHY clock. |
| 28 | * Remove this when clock phandle can be provided via DT |
| 29 | */ |
| 30 | static void __init __used legacy_init_ehci_clk(char *clkname) |
| 31 | { |
| 32 | int ret; |
| 33 | |
| 34 | ret = clk_add_alias("main_clk", NULL, clkname, NULL); |
| 35 | if (ret) |
| 36 | pr_err("%s:Failed to add main_clk alias to %s :%d\n", |
| 37 | __func__, clkname, ret); |
| 38 | } |
| 39 | |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 40 | #if IS_ENABLED(CONFIG_WL12XX) |
| 41 | |
| 42 | static struct wl12xx_platform_data wl12xx __initdata; |
| 43 | |
| 44 | static void __init __used legacy_init_wl12xx(unsigned ref_clock, |
| 45 | unsigned tcxo_clock, |
| 46 | int gpio) |
| 47 | { |
| 48 | int res; |
| 49 | |
| 50 | wl12xx.board_ref_clock = ref_clock; |
| 51 | wl12xx.board_tcxo_clock = tcxo_clock; |
| 52 | wl12xx.irq = gpio_to_irq(gpio); |
| 53 | |
| 54 | res = wl12xx_set_platform_data(&wl12xx); |
| 55 | if (res) { |
| 56 | pr_err("error setting wl12xx data: %d\n", res); |
| 57 | return; |
| 58 | } |
| 59 | } |
| 60 | #else |
| 61 | static inline void legacy_init_wl12xx(unsigned ref_clock, |
| 62 | unsigned tcxo_clock, |
| 63 | int gpio) |
| 64 | { |
| 65 | } |
| 66 | #endif |
| 67 | |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 68 | #ifdef CONFIG_ARCH_OMAP3 |
| 69 | static void __init hsmmc2_internal_input_clk(void) |
| 70 | { |
| 71 | u32 reg; |
| 72 | |
| 73 | reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1); |
| 74 | reg |= OMAP2_MMCSDIO2ADPCLKISEL; |
| 75 | omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1); |
| 76 | } |
Javier Martinez Canillas | 15c9887 | 2013-10-09 11:19:18 +0200 | [diff] [blame^] | 77 | |
| 78 | static void __init omap3_igep0020_legacy_init(void) |
| 79 | { |
| 80 | omap3_igep2_display_init_of(); |
| 81 | } |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 82 | #endif /* CONFIG_ARCH_OMAP3 */ |
| 83 | |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 84 | #ifdef CONFIG_ARCH_OMAP4 |
| 85 | static void __init omap4_sdp_legacy_init(void) |
| 86 | { |
| 87 | omap_4430sdp_display_init_of(); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 88 | legacy_init_wl12xx(WL12XX_REFCLOCK_26, |
| 89 | WL12XX_TCXOCLOCK_26, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | static void __init omap4_panda_legacy_init(void) |
| 93 | { |
| 94 | omap4_panda_display_init_of(); |
| 95 | legacy_init_ehci_clk("auxclk3_ck"); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame] | 96 | legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 97 | } |
| 98 | #endif |
| 99 | |
| 100 | #ifdef CONFIG_SOC_OMAP5 |
| 101 | static void __init omap5_uevm_legacy_init(void) |
| 102 | { |
| 103 | legacy_init_ehci_clk("auxclk1_ck"); |
| 104 | } |
| 105 | #endif |
| 106 | |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 107 | static struct pdata_init pdata_quirks[] __initdata = { |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 108 | #ifdef CONFIG_ARCH_OMAP3 |
| 109 | { "nokia,omap3-n9", hsmmc2_internal_input_clk, }, |
| 110 | { "nokia,omap3-n950", hsmmc2_internal_input_clk, }, |
Javier Martinez Canillas | 15c9887 | 2013-10-09 11:19:18 +0200 | [diff] [blame^] | 111 | { "isee,omap3-igep0020", omap3_igep0020_legacy_init, }, |
Aaro Koskinen | faf4bd4 | 2013-09-24 22:28:15 +0300 | [diff] [blame] | 112 | #endif |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 113 | #ifdef CONFIG_ARCH_OMAP4 |
| 114 | { "ti,omap4-sdp", omap4_sdp_legacy_init, }, |
| 115 | { "ti,omap4-panda", omap4_panda_legacy_init, }, |
| 116 | #endif |
| 117 | #ifdef CONFIG_SOC_OMAP5 |
| 118 | { "ti,omap5-uevm", omap5_uevm_legacy_init, }, |
| 119 | #endif |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 120 | { /* sentinel */ }, |
| 121 | }; |
| 122 | |
| 123 | void __init pdata_quirks_init(void) |
| 124 | { |
| 125 | struct pdata_init *quirks = pdata_quirks; |
| 126 | |
| 127 | while (quirks->compatible) { |
| 128 | if (of_machine_is_compatible(quirks->compatible)) { |
| 129 | if (quirks->fn) |
| 130 | quirks->fn(); |
| 131 | break; |
| 132 | } |
| 133 | quirks++; |
| 134 | } |
| 135 | } |