Commit | Line | Data |
---|---|---|
d40f3f15 TN |
1 | /* |
2 | * linux/arch/arm/mach-omap2/board-omap3logic.c | |
3 | * | |
4 | * Copyright (C) 2010 Li-Pro.Net | |
5 | * Stephan Linz <linz@li-pro.net> | |
6 | * | |
7 | * Copyright (C) 2010 Logic Product Development, Inc. | |
8 | * Peter Barada <peter.barada@logicpd.com> | |
9 | * | |
10 | * Modified from Beagle, EVM, and RX51 | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU General Public License version 2 as | |
14 | * published by the Free Software Foundation. | |
15 | */ | |
16 | ||
17 | #include <linux/kernel.h> | |
18 | #include <linux/init.h> | |
19 | #include <linux/platform_device.h> | |
20 | #include <linux/delay.h> | |
21 | #include <linux/err.h> | |
22 | #include <linux/clk.h> | |
23 | #include <linux/io.h> | |
24 | #include <linux/gpio.h> | |
25 | ||
26 | #include <linux/regulator/machine.h> | |
27 | ||
28 | #include <linux/i2c/twl.h> | |
8430281b | 29 | #include <linux/mmc/host.h> |
d40f3f15 TN |
30 | |
31 | #include <mach/hardware.h> | |
32 | #include <asm/mach-types.h> | |
33 | #include <asm/mach/arch.h> | |
34 | #include <asm/mach/map.h> | |
35 | ||
36 | #include "mux.h" | |
8430281b | 37 | #include "hsmmc.h" |
04aeae77 | 38 | #include "timer-gp.h" |
4814ced5 | 39 | #include "control.h" |
fbd8071c | 40 | #include "common-board-devices.h" |
d40f3f15 TN |
41 | |
42 | #include <plat/mux.h> | |
43 | #include <plat/board.h> | |
44 | #include <plat/common.h> | |
26428b5c | 45 | #include <plat/gpmc-smsc911x.h> |
d40f3f15 | 46 | #include <plat/gpmc.h> |
d40f3f15 | 47 | #include <plat/sdrc.h> |
d40f3f15 TN |
48 | |
49 | #define OMAP3LOGIC_SMSC911X_CS 1 | |
50 | ||
51 | #define OMAP3530_LV_SOM_MMC_GPIO_CD 110 | |
52 | #define OMAP3530_LV_SOM_MMC_GPIO_WP 126 | |
53 | #define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152 | |
54 | ||
55 | #define OMAP3_TORPEDO_MMC_GPIO_CD 127 | |
56 | #define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129 | |
57 | ||
58 | static struct regulator_consumer_supply omap3logic_vmmc1_supply = { | |
59 | .supply = "vmmc", | |
60 | }; | |
61 | ||
62 | /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */ | |
63 | static struct regulator_init_data omap3logic_vmmc1 = { | |
64 | .constraints = { | |
65 | .name = "VMMC1", | |
66 | .min_uV = 1850000, | |
67 | .max_uV = 3150000, | |
68 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
69 | | REGULATOR_MODE_STANDBY, | |
70 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
71 | | REGULATOR_CHANGE_MODE | |
72 | | REGULATOR_CHANGE_STATUS, | |
73 | }, | |
74 | .num_consumer_supplies = 1, | |
75 | .consumer_supplies = &omap3logic_vmmc1_supply, | |
76 | }; | |
77 | ||
78 | static struct twl4030_gpio_platform_data omap3logic_gpio_data = { | |
79 | .gpio_base = OMAP_MAX_GPIO_LINES, | |
80 | .irq_base = TWL4030_GPIO_IRQ_BASE, | |
81 | .irq_end = TWL4030_GPIO_IRQ_END, | |
82 | .use_leds = true, | |
83 | .pullups = BIT(1), | |
84 | .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | |
85 | | BIT(13) | BIT(15) | BIT(16) | BIT(17), | |
86 | }; | |
87 | ||
88 | static struct twl4030_platform_data omap3logic_twldata = { | |
89 | .irq_base = TWL4030_IRQ_BASE, | |
90 | .irq_end = TWL4030_IRQ_END, | |
91 | ||
92 | /* platform_data for children goes here */ | |
93 | .gpio = &omap3logic_gpio_data, | |
8430281b | 94 | .vmmc1 = &omap3logic_vmmc1, |
d40f3f15 TN |
95 | }; |
96 | ||
d40f3f15 TN |
97 | static int __init omap3logic_i2c_init(void) |
98 | { | |
fbd8071c | 99 | omap3_pmic_init("twl4030", &omap3logic_twldata); |
d40f3f15 TN |
100 | return 0; |
101 | } | |
102 | ||
8430281b TN |
103 | static struct omap2_hsmmc_info __initdata board_mmc_info[] = { |
104 | { | |
105 | .name = "external", | |
106 | .mmc = 1, | |
107 | .caps = MMC_CAP_4_BIT_DATA, | |
108 | .gpio_cd = -EINVAL, | |
109 | .gpio_wp = -EINVAL, | |
110 | }, | |
111 | {} /* Terminator */ | |
112 | }; | |
113 | ||
114 | static void __init board_mmc_init(void) | |
115 | { | |
116 | if (machine_is_omap3530_lv_som()) { | |
117 | /* OMAP3530 LV SOM board */ | |
118 | board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD; | |
119 | board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP; | |
120 | omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT); | |
121 | omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT); | |
122 | } else if (machine_is_omap3_torpedo()) { | |
123 | /* OMAP3 Torpedo board */ | |
124 | board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD; | |
125 | omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT); | |
126 | } else { | |
127 | /* unsupported board */ | |
128 | printk(KERN_ERR "%s(): unknown machine type\n", __func__); | |
129 | return; | |
130 | } | |
131 | ||
132 | omap2_hsmmc_init(board_mmc_info); | |
133 | /* link regulators to MMC adapters */ | |
134 | omap3logic_vmmc1_supply.dev = board_mmc_info[0].dev; | |
135 | } | |
136 | ||
26428b5c TN |
137 | static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = { |
138 | .cs = OMAP3LOGIC_SMSC911X_CS, | |
139 | .gpio_irq = -EINVAL, | |
140 | .gpio_reset = -EINVAL, | |
26428b5c TN |
141 | }; |
142 | ||
143 | /* TODO/FIXME (comment by Peter Barada, LogicPD): | |
144 | * Fix the PBIAS voltage for Torpedo MMC1 pins that | |
145 | * are used for other needs (IRQs, etc). */ | |
146 | static void omap3torpedo_fix_pbias_voltage(void) | |
147 | { | |
148 | u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE; | |
149 | u32 reg; | |
150 | ||
151 | if (machine_is_omap3_torpedo()) | |
152 | { | |
153 | /* Set the bias for the pin */ | |
154 | reg = omap_ctrl_readl(control_pbias_offset); | |
155 | ||
156 | reg &= ~OMAP343X_PBIASLITEPWRDNZ1; | |
157 | omap_ctrl_writel(reg, control_pbias_offset); | |
158 | ||
159 | /* 100ms delay required for PBIAS configuration */ | |
160 | msleep(100); | |
161 | ||
162 | reg |= OMAP343X_PBIASLITEVMODE1; | |
163 | reg |= OMAP343X_PBIASLITEPWRDNZ1; | |
164 | omap_ctrl_writel(reg | 0x300, control_pbias_offset); | |
165 | } | |
166 | } | |
167 | ||
168 | static inline void __init board_smsc911x_init(void) | |
169 | { | |
170 | if (machine_is_omap3530_lv_som()) { | |
171 | /* OMAP3530 LV SOM board */ | |
172 | board_smsc911x_data.gpio_irq = | |
173 | OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ; | |
174 | omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT); | |
175 | } else if (machine_is_omap3_torpedo()) { | |
176 | /* OMAP3 Torpedo board */ | |
177 | board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ; | |
178 | omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT); | |
179 | } else { | |
180 | /* unsupported board */ | |
181 | printk(KERN_ERR "%s(): unknown machine type\n", __func__); | |
182 | return; | |
183 | } | |
184 | ||
185 | gpmc_smsc911x_init(&board_smsc911x_data); | |
186 | } | |
187 | ||
3dc3bad6 | 188 | static void __init omap3logic_init_early(void) |
d40f3f15 | 189 | { |
4805734b PW |
190 | omap2_init_common_infrastructure(); |
191 | omap2_init_common_devices(NULL, NULL); | |
d40f3f15 TN |
192 | } |
193 | ||
26428b5c TN |
194 | #ifdef CONFIG_OMAP_MUX |
195 | static struct omap_board_mux board_mux[] __initdata = { | |
196 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
197 | }; | |
26428b5c TN |
198 | #endif |
199 | ||
d40f3f15 TN |
200 | static void __init omap3logic_init(void) |
201 | { | |
26428b5c TN |
202 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
203 | omap3torpedo_fix_pbias_voltage(); | |
d40f3f15 TN |
204 | omap3logic_i2c_init(); |
205 | omap_serial_init(); | |
8430281b | 206 | board_mmc_init(); |
26428b5c TN |
207 | board_smsc911x_init(); |
208 | ||
d40f3f15 TN |
209 | /* Ensure SDRC pins are mux'd for self-refresh */ |
210 | omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); | |
211 | omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT); | |
212 | } | |
213 | ||
214 | MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board") | |
d40f3f15 TN |
215 | .boot_params = 0x80000100, |
216 | .map_io = omap3_map_io, | |
3dc3bad6 | 217 | .init_early = omap3logic_init_early, |
741e3a89 | 218 | .init_irq = omap3_init_irq, |
d40f3f15 | 219 | .init_machine = omap3logic_init, |
e74984e4 | 220 | .timer = &omap3_timer, |
d40f3f15 TN |
221 | MACHINE_END |
222 | ||
223 | MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board") | |
d40f3f15 TN |
224 | .boot_params = 0x80000100, |
225 | .map_io = omap3_map_io, | |
3dc3bad6 | 226 | .init_early = omap3logic_init_early, |
741e3a89 | 227 | .init_irq = omap3_init_irq, |
d40f3f15 | 228 | .init_machine = omap3logic_init, |
e74984e4 | 229 | .timer = &omap3_timer, |
d40f3f15 | 230 | MACHINE_END |