aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mx5/board-mx51_efikamx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-mx5/board-mx51_efikamx.c')
-rw-r--r--arch/arm/mach-mx5/board-mx51_efikamx.c211
1 files changed, 72 insertions, 139 deletions
diff --git a/arch/arm/mach-mx5/board-mx51_efikamx.c b/arch/arm/mach-mx5/board-mx51_efikamx.c
index b7946f8e8d40..acab1911cb3c 100644
--- a/arch/arm/mach-mx5/board-mx51_efikamx.c
+++ b/arch/arm/mach-mx5/board-mx51_efikamx.c
@@ -25,6 +25,9 @@
25#include <linux/fsl_devices.h> 25#include <linux/fsl_devices.h>
26#include <linux/spi/flash.h> 26#include <linux/spi/flash.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/mfd/mc13892.h>
29#include <linux/regulator/machine.h>
30#include <linux/regulator/consumer.h>
28 31
29#include <mach/common.h> 32#include <mach/common.h>
30#include <mach/hardware.h> 33#include <mach/hardware.h>
@@ -40,8 +43,7 @@
40 43
41#include "devices-imx51.h" 44#include "devices-imx51.h"
42#include "devices.h" 45#include "devices.h"
43 46#include "efika.h"
44#define MX51_USB_PLL_DIV_24_MHZ 0x01
45 47
46#define EFIKAMX_PCBID0 IMX_GPIO_NR(3, 16) 48#define EFIKAMX_PCBID0 IMX_GPIO_NR(3, 16)
47#define EFIKAMX_PCBID1 IMX_GPIO_NR(3, 17) 49#define EFIKAMX_PCBID1 IMX_GPIO_NR(3, 17)
@@ -53,13 +55,14 @@
53 55
54#define EFIKAMX_POWER_KEY IMX_GPIO_NR(2, 31) 56#define EFIKAMX_POWER_KEY IMX_GPIO_NR(2, 31)
55 57
56#define EFIKAMX_SPI_CS0 IMX_GPIO_NR(4, 24)
57#define EFIKAMX_SPI_CS1 IMX_GPIO_NR(4, 25)
58
59/* board 1.1 doesn't have same reset gpio */ 58/* board 1.1 doesn't have same reset gpio */
60#define EFIKAMX_RESET1_1 IMX_GPIO_NR(3, 2) 59#define EFIKAMX_RESET1_1 IMX_GPIO_NR(3, 2)
61#define EFIKAMX_RESET IMX_GPIO_NR(1, 4) 60#define EFIKAMX_RESET IMX_GPIO_NR(1, 4)
62 61
62#define EFIKAMX_POWEROFF IMX_GPIO_NR(4, 13)
63
64#define EFIKAMX_PMIC IMX_GPIO_NR(1, 6)
65
63/* the pci ids pin have pull up. they're driven low according to board id */ 66/* the pci ids pin have pull up. they're driven low according to board id */
64#define MX51_PAD_PCBID0 IOMUX_PAD(0x518, 0x130, 3, 0x0, 0, PAD_CTL_PUS_100K_UP) 67#define MX51_PAD_PCBID0 IOMUX_PAD(0x518, 0x130, 3, 0x0, 0, PAD_CTL_PUS_100K_UP)
65#define MX51_PAD_PCBID1 IOMUX_PAD(0x51C, 0x134, 3, 0x0, 0, PAD_CTL_PUS_100K_UP) 68#define MX51_PAD_PCBID1 IOMUX_PAD(0x51C, 0x134, 3, 0x0, 0, PAD_CTL_PUS_100K_UP)
@@ -67,38 +70,11 @@
67#define MX51_PAD_PWRKEY IOMUX_PAD(0x48c, 0x0f8, 1, 0x0, 0, PAD_CTL_PUS_100K_UP | PAD_CTL_PKE) 70#define MX51_PAD_PWRKEY IOMUX_PAD(0x48c, 0x0f8, 1, 0x0, 0, PAD_CTL_PUS_100K_UP | PAD_CTL_PKE)
68 71
69static iomux_v3_cfg_t mx51efikamx_pads[] = { 72static iomux_v3_cfg_t mx51efikamx_pads[] = {
70 /* UART1 */
71 MX51_PAD_UART1_RXD__UART1_RXD,
72 MX51_PAD_UART1_TXD__UART1_TXD,
73 MX51_PAD_UART1_RTS__UART1_RTS,
74 MX51_PAD_UART1_CTS__UART1_CTS,
75 /* board id */ 73 /* board id */
76 MX51_PAD_PCBID0, 74 MX51_PAD_PCBID0,
77 MX51_PAD_PCBID1, 75 MX51_PAD_PCBID1,
78 MX51_PAD_PCBID2, 76 MX51_PAD_PCBID2,
79 77
80 /* SD 1 */
81 MX51_PAD_SD1_CMD__SD1_CMD,
82 MX51_PAD_SD1_CLK__SD1_CLK,
83 MX51_PAD_SD1_DATA0__SD1_DATA0,
84 MX51_PAD_SD1_DATA1__SD1_DATA1,
85 MX51_PAD_SD1_DATA2__SD1_DATA2,
86 MX51_PAD_SD1_DATA3__SD1_DATA3,
87
88 /* SD 2 */
89 MX51_PAD_SD2_CMD__SD2_CMD,
90 MX51_PAD_SD2_CLK__SD2_CLK,
91 MX51_PAD_SD2_DATA0__SD2_DATA0,
92 MX51_PAD_SD2_DATA1__SD2_DATA1,
93 MX51_PAD_SD2_DATA2__SD2_DATA2,
94 MX51_PAD_SD2_DATA3__SD2_DATA3,
95
96 /* SD/MMC WP/CD */
97 MX51_PAD_GPIO1_0__SD1_CD,
98 MX51_PAD_GPIO1_1__SD1_WP,
99 MX51_PAD_GPIO1_7__SD2_WP,
100 MX51_PAD_GPIO1_8__SD2_CD,
101
102 /* leds */ 78 /* leds */
103 MX51_PAD_CSI1_D9__GPIO3_13, 79 MX51_PAD_CSI1_D9__GPIO3_13,
104 MX51_PAD_CSI1_VSYNC__GPIO3_14, 80 MX51_PAD_CSI1_VSYNC__GPIO3_14,
@@ -107,64 +83,12 @@ static iomux_v3_cfg_t mx51efikamx_pads[] = {
107 /* power key */ 83 /* power key */
108 MX51_PAD_PWRKEY, 84 MX51_PAD_PWRKEY,
109 85
110 /* spi */
111 MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI,
112 MX51_PAD_CSPI1_MISO__ECSPI1_MISO,
113 MX51_PAD_CSPI1_SS0__GPIO4_24,
114 MX51_PAD_CSPI1_SS1__GPIO4_25,
115 MX51_PAD_CSPI1_RDY__ECSPI1_RDY,
116 MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK,
117
118 /* reset */ 86 /* reset */
119 MX51_PAD_DI1_PIN13__GPIO3_2, 87 MX51_PAD_DI1_PIN13__GPIO3_2,
120 MX51_PAD_GPIO1_4__GPIO1_4, 88 MX51_PAD_GPIO1_4__GPIO1_4,
121};
122 89
123/* Serial ports */ 90 /* power off */
124#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) 91 MX51_PAD_CSI2_VSYNC__GPIO4_13,
125static const struct imxuart_platform_data uart_pdata = {
126 .flags = IMXUART_HAVE_RTSCTS,
127};
128
129static inline void mxc_init_imx_uart(void)
130{
131 imx51_add_imx_uart(0, &uart_pdata);
132 imx51_add_imx_uart(1, &uart_pdata);
133 imx51_add_imx_uart(2, &uart_pdata);
134}
135#else /* !SERIAL_IMX */
136static inline void mxc_init_imx_uart(void)
137{
138}
139#endif /* SERIAL_IMX */
140
141/* This function is board specific as the bit mask for the plldiv will also
142 * be different for other Freescale SoCs, thus a common bitmask is not
143 * possible and cannot get place in /plat-mxc/ehci.c.
144 */
145static int initialize_otg_port(struct platform_device *pdev)
146{
147 u32 v;
148 void __iomem *usb_base;
149 void __iomem *usbother_base;
150 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
151 if (!usb_base)
152 return -ENOMEM;
153 usbother_base = (void __iomem *)(usb_base + MX5_USBOTHER_REGS_OFFSET);
154
155 /* Set the PHY clock to 19.2MHz */
156 v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
157 v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;
158 v |= MX51_USB_PLL_DIV_24_MHZ;
159 __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
160 iounmap(usb_base);
161 return 0;
162}
163
164static struct mxc_usbh_platform_data dr_utmi_config = {
165 .init = initialize_otg_port,
166 .portsc = MXC_EHCI_UTMI_16BIT,
167 .flags = MXC_EHCI_INTERNAL_PHY,
168}; 92};
169 93
170/* PCBID2 PCBID1 PCBID0 STATE 94/* PCBID2 PCBID1 PCBID0 STATE
@@ -265,47 +189,6 @@ static const struct gpio_keys_platform_data mx51_efikamx_powerkey_data __initcon
265 .nbuttons = ARRAY_SIZE(mx51_efikamx_powerkey), 189 .nbuttons = ARRAY_SIZE(mx51_efikamx_powerkey),
266}; 190};
267 191
268static struct mtd_partition mx51_efikamx_spi_nor_partitions[] = {
269 {
270 .name = "u-boot",
271 .offset = 0,
272 .size = SZ_256K,
273 },
274 {
275 .name = "config",
276 .offset = MTDPART_OFS_APPEND,
277 .size = SZ_64K,
278 },
279};
280
281static struct flash_platform_data mx51_efikamx_spi_flash_data = {
282 .name = "spi_flash",
283 .parts = mx51_efikamx_spi_nor_partitions,
284 .nr_parts = ARRAY_SIZE(mx51_efikamx_spi_nor_partitions),
285 .type = "sst25vf032b",
286};
287
288static struct spi_board_info mx51_efikamx_spi_board_info[] __initdata = {
289 {
290 .modalias = "m25p80",
291 .max_speed_hz = 25000000,
292 .bus_num = 0,
293 .chip_select = 1,
294 .platform_data = &mx51_efikamx_spi_flash_data,
295 .irq = -1,
296 },
297};
298
299static int mx51_efikamx_spi_cs[] = {
300 EFIKAMX_SPI_CS0,
301 EFIKAMX_SPI_CS1,
302};
303
304static const struct spi_imx_master mx51_efikamx_spi_pdata __initconst = {
305 .chipselect = mx51_efikamx_spi_cs,
306 .num_chipselect = ARRAY_SIZE(mx51_efikamx_spi_cs),
307};
308
309void mx51_efikamx_reset(void) 192void mx51_efikamx_reset(void)
310{ 193{
311 if (system_rev == 0x11) 194 if (system_rev == 0x11)
@@ -314,14 +197,53 @@ void mx51_efikamx_reset(void)
314 gpio_direction_output(EFIKAMX_RESET, 0); 197 gpio_direction_output(EFIKAMX_RESET, 0);
315} 198}
316 199
317static void __init mxc_board_init(void) 200static struct regulator *pwgt1, *pwgt2, *coincell;
201
202static void mx51_efikamx_power_off(void)
203{
204 if (!IS_ERR(coincell))
205 regulator_disable(coincell);
206
207 if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
208 regulator_disable(pwgt2);
209 regulator_disable(pwgt1);
210 }
211 gpio_direction_output(EFIKAMX_POWEROFF, 1);
212}
213
214static int __init mx51_efikamx_power_init(void)
215{
216 if (machine_is_mx51_efikamx()) {
217 pwgt1 = regulator_get(NULL, "pwgt1");
218 pwgt2 = regulator_get(NULL, "pwgt2");
219 if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
220 regulator_enable(pwgt1);
221 regulator_enable(pwgt2);
222 }
223 gpio_request(EFIKAMX_POWEROFF, "poweroff");
224 pm_power_off = mx51_efikamx_power_off;
225
226 /* enable coincell charger. maybe need a small power driver ? */
227 coincell = regulator_get(NULL, "coincell");
228 if (!IS_ERR(coincell)) {
229 regulator_set_voltage(coincell, 3000000, 3000000);
230 regulator_enable(coincell);
231 }
232
233 regulator_has_full_constraints();
234 }
235
236 return 0;
237}
238late_initcall(mx51_efikamx_power_init);
239
240static void __init mx51_efikamx_init(void)
318{ 241{
319 mxc_iomux_v3_setup_multiple_pads(mx51efikamx_pads, 242 mxc_iomux_v3_setup_multiple_pads(mx51efikamx_pads,
320 ARRAY_SIZE(mx51efikamx_pads)); 243 ARRAY_SIZE(mx51efikamx_pads));
244 efika_board_common_init();
245
321 mx51_efikamx_board_id(); 246 mx51_efikamx_board_id();
322 mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
323 mxc_init_imx_uart();
324 imx51_add_sdhci_esdhc_imx(0, NULL);
325 247
326 /* on < 1.2 boards both SD controllers are used */ 248 /* on < 1.2 boards both SD controllers are used */
327 if (system_rev < 0x12) { 249 if (system_rev < 0x12) {
@@ -332,10 +254,6 @@ static void __init mxc_board_init(void)
332 platform_device_register(&mx51_efikamx_leds_device); 254 platform_device_register(&mx51_efikamx_leds_device);
333 imx51_add_gpio_keys(&mx51_efikamx_powerkey_data); 255 imx51_add_gpio_keys(&mx51_efikamx_powerkey_data);
334 256
335 spi_register_board_info(mx51_efikamx_spi_board_info,
336 ARRAY_SIZE(mx51_efikamx_spi_board_info));
337 imx51_add_ecspi(0, &mx51_efikamx_spi_pdata);
338
339 if (system_rev == 0x11) { 257 if (system_rev == 0x11) {
340 gpio_request(EFIKAMX_RESET1_1, "reset"); 258 gpio_request(EFIKAMX_RESET1_1, "reset");
341 gpio_direction_output(EFIKAMX_RESET1_1, 1); 259 gpio_direction_output(EFIKAMX_RESET1_1, 1);
@@ -343,6 +261,20 @@ static void __init mxc_board_init(void)
343 gpio_request(EFIKAMX_RESET, "reset"); 261 gpio_request(EFIKAMX_RESET, "reset");
344 gpio_direction_output(EFIKAMX_RESET, 1); 262 gpio_direction_output(EFIKAMX_RESET, 1);
345 } 263 }
264
265 /*
266 * enable wifi by default only on mx
267 * sb and mx have same wlan pin but the value to enable it are
268 * different :/
269 */
270 gpio_request(EFIKA_WLAN_EN, "wlan_en");
271 gpio_direction_output(EFIKA_WLAN_EN, 0);
272 msleep(10);
273
274 gpio_request(EFIKA_WLAN_RESET, "wlan_rst");
275 gpio_direction_output(EFIKA_WLAN_RESET, 0);
276 msleep(10);
277 gpio_set_value(EFIKA_WLAN_RESET, 1);
346} 278}
347 279
348static void __init mx51_efikamx_timer_init(void) 280static void __init mx51_efikamx_timer_init(void)
@@ -350,15 +282,16 @@ static void __init mx51_efikamx_timer_init(void)
350 mx51_clocks_init(32768, 24000000, 22579200, 24576000); 282 mx51_clocks_init(32768, 24000000, 22579200, 24576000);
351} 283}
352 284
353static struct sys_timer mxc_timer = { 285static struct sys_timer mx51_efikamx_timer = {
354 .init = mx51_efikamx_timer_init, 286 .init = mx51_efikamx_timer_init,
355}; 287};
356 288
357MACHINE_START(MX51_EFIKAMX, "Genesi EfikaMX nettop") 289MACHINE_START(MX51_EFIKAMX, "Genesi EfikaMX nettop")
358 /* Maintainer: Amit Kucheria <amit.kucheria@linaro.org> */ 290 /* Maintainer: Amit Kucheria <amit.kucheria@linaro.org> */
359 .boot_params = MX51_PHYS_OFFSET + 0x100, 291 .boot_params = MX51_PHYS_OFFSET + 0x100,
360 .map_io = mx51_map_io, 292 .map_io = mx51_map_io,
293 .init_early = imx51_init_early,
361 .init_irq = mx51_init_irq, 294 .init_irq = mx51_init_irq,
362 .init_machine = mxc_board_init, 295 .timer = &mx51_efikamx_timer,
363 .timer = &mxc_timer, 296 .init_machine = mx51_efikamx_init,
364MACHINE_END 297MACHINE_END