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" |
| 19 | |
| 20 | struct pdata_init { |
| 21 | const char *compatible; |
| 22 | void (*fn)(void); |
| 23 | }; |
| 24 | |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 25 | /* |
| 26 | * Create alias for USB host PHY clock. |
| 27 | * Remove this when clock phandle can be provided via DT |
| 28 | */ |
| 29 | static void __init __used legacy_init_ehci_clk(char *clkname) |
| 30 | { |
| 31 | int ret; |
| 32 | |
| 33 | ret = clk_add_alias("main_clk", NULL, clkname, NULL); |
| 34 | if (ret) |
| 35 | pr_err("%s:Failed to add main_clk alias to %s :%d\n", |
| 36 | __func__, clkname, ret); |
| 37 | } |
| 38 | |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame^] | 39 | #if IS_ENABLED(CONFIG_WL12XX) |
| 40 | |
| 41 | static struct wl12xx_platform_data wl12xx __initdata; |
| 42 | |
| 43 | static void __init __used legacy_init_wl12xx(unsigned ref_clock, |
| 44 | unsigned tcxo_clock, |
| 45 | int gpio) |
| 46 | { |
| 47 | int res; |
| 48 | |
| 49 | wl12xx.board_ref_clock = ref_clock; |
| 50 | wl12xx.board_tcxo_clock = tcxo_clock; |
| 51 | wl12xx.irq = gpio_to_irq(gpio); |
| 52 | |
| 53 | res = wl12xx_set_platform_data(&wl12xx); |
| 54 | if (res) { |
| 55 | pr_err("error setting wl12xx data: %d\n", res); |
| 56 | return; |
| 57 | } |
| 58 | } |
| 59 | #else |
| 60 | static inline void legacy_init_wl12xx(unsigned ref_clock, |
| 61 | unsigned tcxo_clock, |
| 62 | int gpio) |
| 63 | { |
| 64 | } |
| 65 | #endif |
| 66 | |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 67 | #ifdef CONFIG_ARCH_OMAP4 |
| 68 | static void __init omap4_sdp_legacy_init(void) |
| 69 | { |
| 70 | omap_4430sdp_display_init_of(); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame^] | 71 | legacy_init_wl12xx(WL12XX_REFCLOCK_26, |
| 72 | WL12XX_TCXOCLOCK_26, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | static void __init omap4_panda_legacy_init(void) |
| 76 | { |
| 77 | omap4_panda_display_init_of(); |
| 78 | legacy_init_ehci_clk("auxclk3_ck"); |
Tony Lindgren | 5f0a2c6 | 2013-09-25 15:44:40 -0700 | [diff] [blame^] | 79 | legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53); |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 80 | } |
| 81 | #endif |
| 82 | |
| 83 | #ifdef CONFIG_SOC_OMAP5 |
| 84 | static void __init omap5_uevm_legacy_init(void) |
| 85 | { |
| 86 | legacy_init_ehci_clk("auxclk1_ck"); |
| 87 | } |
| 88 | #endif |
| 89 | |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 90 | static struct pdata_init pdata_quirks[] __initdata = { |
Tony Lindgren | 3e7a318 | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 91 | #ifdef CONFIG_ARCH_OMAP4 |
| 92 | { "ti,omap4-sdp", omap4_sdp_legacy_init, }, |
| 93 | { "ti,omap4-panda", omap4_panda_legacy_init, }, |
| 94 | #endif |
| 95 | #ifdef CONFIG_SOC_OMAP5 |
| 96 | { "ti,omap5-uevm", omap5_uevm_legacy_init, }, |
| 97 | #endif |
Tony Lindgren | 6a08e1e | 2013-09-25 15:44:39 -0700 | [diff] [blame] | 98 | { /* sentinel */ }, |
| 99 | }; |
| 100 | |
| 101 | void __init pdata_quirks_init(void) |
| 102 | { |
| 103 | struct pdata_init *quirks = pdata_quirks; |
| 104 | |
| 105 | while (quirks->compatible) { |
| 106 | if (of_machine_is_compatible(quirks->compatible)) { |
| 107 | if (quirks->fn) |
| 108 | quirks->fn(); |
| 109 | break; |
| 110 | } |
| 111 | quirks++; |
| 112 | } |
| 113 | } |