blob: 99dd184f50f141bf4ac7ba3128f040de57ea2416 [file] [log] [blame]
Kalle Valo63138812009-08-28 10:51:38 -07001/*
2 * linux/arch/arm/mach-omap2/board-n8x0.c
3 *
4 * Copyright (C) 2005-2009 Nokia Corporation
5 * Author: Juha Yrjola <juha.yrjola@nokia.com>
6 *
7 * Modified from mach-omap2/board-generic.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/clk.h>
15#include <linux/delay.h>
16#include <linux/gpio.h>
17#include <linux/init.h>
18#include <linux/io.h>
Aaro Koskinen0857ba32012-11-18 18:36:19 +020019#include <linux/irq.h>
Kalle Valo63138812009-08-28 10:51:38 -070020#include <linux/stddef.h>
Tony Lindgren9418c652010-02-26 15:31:12 -080021#include <linux/i2c.h>
Kalle Valo63138812009-08-28 10:51:38 -070022#include <linux/spi/spi.h>
23#include <linux/usb/musb.h>
Aaro Koskinen0857ba32012-11-18 18:36:19 +020024#include <linux/platform_data/i2c-cbus-gpio.h>
Arnd Bergmann22037472012-08-24 15:21:06 +020025#include <linux/platform_data/spi-omap2-mcspi.h>
26#include <linux/platform_data/mtd-onenand-omap2.h>
Tony Lindgren7bd3b612012-10-15 13:53:41 -070027#include <linux/mfd/menelaus.h>
Jarkko Nikula366498d2010-08-20 09:36:28 +030028#include <sound/tlv320aic3x.h>
Kalle Valo63138812009-08-28 10:51:38 -070029
30#include <asm/mach/arch.h>
31#include <asm/mach-types.h>
32
Tony Lindgren4e653312011-11-10 22:45:17 +010033#include "common.h"
Tony Lindgren68f39e72012-10-15 12:09:43 -070034#include "mmc.h"
Tony Lindgren810ac2a2013-11-25 15:17:10 -080035#include "soc.h"
Tony Lindgrenbd8f0fc2010-07-05 16:31:38 +030036#include "mux.h"
Afzal Mohammedb6ab13e2012-09-29 10:32:42 +053037#include "gpmc-onenand.h"
Tony Lindgrenbd8f0fc2010-07-05 16:31:38 +030038
Francisco Alecrim97b9ad12010-03-10 18:52:24 -080039#define TUSB6010_ASYNC_CS 1
40#define TUSB6010_SYNC_CS 4
41#define TUSB6010_GPIO_INT 58
42#define TUSB6010_GPIO_ENABLE 0
43#define TUSB6010_DMACHAN 0x3f
44
Tony Lindgrenc8f27e92013-11-25 15:17:09 -080045#define NOKIA_N810_WIMAX (1 << 2)
46#define NOKIA_N810 (1 << 1)
47#define NOKIA_N800 (1 << 0)
48
49static u32 board_caps;
50
51#define board_is_n800() (board_caps & NOKIA_N800)
52#define board_is_n810() (board_caps & NOKIA_N810)
53#define board_is_n810_wimax() (board_caps & NOKIA_N810_WIMAX)
54
55static void board_check_revision(void)
56{
57 if (of_have_populated_dt()) {
58 if (of_machine_is_compatible("nokia,n800"))
59 board_caps = NOKIA_N800;
60 else if (of_machine_is_compatible("nokia,n810"))
61 board_caps = NOKIA_N810;
62 else if (of_machine_is_compatible("nokia,n810-wimax"))
63 board_caps = NOKIA_N810_WIMAX;
64 } else {
65 if (machine_is_nokia_n800())
66 board_caps = NOKIA_N800;
67 else if (machine_is_nokia_n810())
68 board_caps = NOKIA_N810;
69 else if (machine_is_nokia_n810_wimax())
70 board_caps = NOKIA_N810_WIMAX;
71 }
72
73 if (!board_caps)
74 pr_err("Unknown board\n");
75}
76
Aaro Koskinen0857ba32012-11-18 18:36:19 +020077#if defined(CONFIG_I2C_CBUS_GPIO) || defined(CONFIG_I2C_CBUS_GPIO_MODULE)
78static struct i2c_cbus_platform_data n8x0_cbus_data = {
79 .clk_gpio = 66,
80 .dat_gpio = 65,
81 .sel_gpio = 64,
82};
83
84static struct platform_device n8x0_cbus_device = {
85 .name = "i2c-cbus-gpio",
86 .id = 3,
87 .dev = {
88 .platform_data = &n8x0_cbus_data,
89 },
90};
91
92static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
93 {
94 I2C_BOARD_INFO("retu-mfd", 0x01),
95 },
96};
97
98static void __init n8x0_cbus_init(void)
99{
100 const int retu_irq_gpio = 108;
101
102 if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
103 return;
104 irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
105 n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
106 i2c_register_board_info(3, n8x0_i2c_board_info_3,
107 ARRAY_SIZE(n8x0_i2c_board_info_3));
108 platform_device_register(&n8x0_cbus_device);
109}
110#else /* CONFIG_I2C_CBUS_GPIO */
111static void __init n8x0_cbus_init(void)
112{
113}
114#endif /* CONFIG_I2C_CBUS_GPIO */
115
Arnd Bergmann9a35f872011-10-02 16:45:47 +0200116#if defined(CONFIG_USB_MUSB_TUSB6010) || defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
Francisco Alecrim97b9ad12010-03-10 18:52:24 -0800117/*
118 * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
119 * 1.5 V voltage regulators of PM companion chip. Companion chip will then
120 * provide then PGOOD signal to TUSB6010 which will release it from reset.
121 */
122static int tusb_set_power(int state)
123{
124 int i, retval = 0;
125
126 if (state) {
127 gpio_set_value(TUSB6010_GPIO_ENABLE, 1);
128 msleep(1);
129
130 /* Wait until TUSB6010 pulls INT pin down */
131 i = 100;
132 while (i && gpio_get_value(TUSB6010_GPIO_INT)) {
133 msleep(1);
134 i--;
135 }
136
137 if (!i) {
138 printk(KERN_ERR "tusb: powerup failed\n");
139 retval = -ENODEV;
140 }
141 } else {
142 gpio_set_value(TUSB6010_GPIO_ENABLE, 0);
143 msleep(10);
144 }
145
146 return retval;
147}
148
149static struct musb_hdrc_config musb_config = {
150 .multipoint = 1,
151 .dyn_fifo = 1,
152 .num_eps = 16,
153 .ram_bits = 12,
154};
155
156static struct musb_hdrc_platform_data tusb_data = {
Francisco Alecrim97b9ad12010-03-10 18:52:24 -0800157 .mode = MUSB_OTG,
Francisco Alecrim97b9ad12010-03-10 18:52:24 -0800158 .set_power = tusb_set_power,
159 .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */
160 .power = 100, /* Max 100 mA VBUS for host mode */
161 .config = &musb_config,
162};
163
164static void __init n8x0_usb_init(void)
165{
166 int ret = 0;
167 static char announce[] __initdata = KERN_INFO "TUSB 6010\n";
168
169 /* PM companion chip power control pin */
Igor Grinbergbc593f52011-05-03 18:22:09 +0300170 ret = gpio_request_one(TUSB6010_GPIO_ENABLE, GPIOF_OUT_INIT_LOW,
171 "TUSB6010 enable");
Francisco Alecrim97b9ad12010-03-10 18:52:24 -0800172 if (ret != 0) {
173 printk(KERN_ERR "Could not get TUSB power GPIO%i\n",
174 TUSB6010_GPIO_ENABLE);
175 return;
176 }
Francisco Alecrim97b9ad12010-03-10 18:52:24 -0800177 tusb_set_power(0);
178
179 ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2,
180 TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS,
181 TUSB6010_GPIO_INT, TUSB6010_DMACHAN);
182 if (ret != 0)
183 goto err;
184
185 printk(announce);
186
187 return;
188
189err:
190 gpio_free(TUSB6010_GPIO_ENABLE);
191}
192#else
193
194static void __init n8x0_usb_init(void) {}
195
Felipe Balbi7c925542010-12-01 14:23:48 +0200196#endif /*CONFIG_USB_MUSB_TUSB6010 */
Francisco Alecrim97b9ad12010-03-10 18:52:24 -0800197
198
Kalle Valo63138812009-08-28 10:51:38 -0700199static struct omap2_mcspi_device_config p54spi_mcspi_config = {
200 .turbo_mode = 0,
Kalle Valo63138812009-08-28 10:51:38 -0700201};
202
203static struct spi_board_info n800_spi_board_info[] __initdata = {
204 {
205 .modalias = "p54spi",
206 .bus_num = 2,
207 .chip_select = 0,
208 .max_speed_hz = 48000000,
209 .controller_data = &p54spi_mcspi_config,
210 },
211};
212
213#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
214 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
215
216static struct mtd_partition onenand_partitions[] = {
217 {
218 .name = "bootloader",
219 .offset = 0,
220 .size = 0x20000,
221 .mask_flags = MTD_WRITEABLE, /* Force read-only */
222 },
223 {
224 .name = "config",
225 .offset = MTDPART_OFS_APPEND,
226 .size = 0x60000,
227 },
228 {
229 .name = "kernel",
230 .offset = MTDPART_OFS_APPEND,
231 .size = 0x200000,
232 },
233 {
234 .name = "initfs",
235 .offset = MTDPART_OFS_APPEND,
236 .size = 0x400000,
237 },
238 {
239 .name = "rootfs",
240 .offset = MTDPART_OFS_APPEND,
241 .size = MTDPART_SIZ_FULL,
242 },
243};
244
Aaro Koskinena1a92e62010-12-02 15:51:23 +0000245static struct omap_onenand_platform_data board_onenand_data[] = {
246 {
247 .cs = 0,
248 .gpio_irq = 26,
249 .parts = onenand_partitions,
250 .nr_parts = ARRAY_SIZE(onenand_partitions),
251 .flags = ONENAND_SYNC_READ,
252 }
Kalle Valo63138812009-08-28 10:51:38 -0700253};
Kalle Valo63138812009-08-28 10:51:38 -0700254#endif
255
Tony Lindgren9418c652010-02-26 15:31:12 -0800256#if defined(CONFIG_MENELAUS) && \
257 (defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE))
258
259/*
260 * On both N800 and N810, only the first of the two MMC controllers is in use.
261 * The two MMC slots are multiplexed via Menelaus companion chip over I2C.
262 * On N800, both slots are powered via Menelaus. On N810, only one of the
263 * slots is powered via Menelaus. The N810 EMMC is powered via GPIO.
264 *
265 * VMMC slot 1 on both N800 and N810
266 * VDCDC3_APE and VMCS2_APE slot 2 on N800
267 * GPIO23 and GPIO9 slot 2 EMMC on N810
268 *
269 */
270#define N8X0_SLOT_SWITCH_GPIO 96
271#define N810_EMMC_VSD_GPIO 23
Tony Lindgren1dea5c62010-04-21 15:27:24 -0700272#define N810_EMMC_VIO_GPIO 9
Tony Lindgren9418c652010-02-26 15:31:12 -0800273
Tony Lindgren49b87c62012-03-06 11:49:28 -0800274static int slot1_cover_open;
275static int slot2_cover_open;
276static struct device *mmc_device;
277
Tony Lindgren9418c652010-02-26 15:31:12 -0800278static int n8x0_mmc_switch_slot(struct device *dev, int slot)
279{
280#ifdef CONFIG_MMC_DEBUG
281 dev_dbg(dev, "Choose slot %d\n", slot + 1);
282#endif
283 gpio_set_value(N8X0_SLOT_SWITCH_GPIO, slot);
284 return 0;
285}
286
287static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
288 int power_on, int vdd)
289{
290 int mV;
291
292#ifdef CONFIG_MMC_DEBUG
293 dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
294 power_on ? "on" : "off", vdd);
295#endif
296 if (slot == 0) {
297 if (!power_on)
298 return menelaus_set_vmmc(0);
299 switch (1 << vdd) {
300 case MMC_VDD_33_34:
301 case MMC_VDD_32_33:
302 case MMC_VDD_31_32:
303 mV = 3100;
304 break;
305 case MMC_VDD_30_31:
306 mV = 3000;
307 break;
308 case MMC_VDD_28_29:
309 mV = 2800;
310 break;
311 case MMC_VDD_165_195:
312 mV = 1850;
313 break;
314 default:
315 BUG();
316 }
317 return menelaus_set_vmmc(mV);
318 } else {
319 if (!power_on)
320 return menelaus_set_vdcdc(3, 0);
321 switch (1 << vdd) {
322 case MMC_VDD_33_34:
323 case MMC_VDD_32_33:
324 mV = 3300;
325 break;
326 case MMC_VDD_30_31:
327 case MMC_VDD_29_30:
328 mV = 3000;
329 break;
330 case MMC_VDD_28_29:
331 case MMC_VDD_27_28:
332 mV = 2800;
333 break;
334 case MMC_VDD_24_25:
335 case MMC_VDD_23_24:
336 mV = 2400;
337 break;
338 case MMC_VDD_22_23:
339 case MMC_VDD_21_22:
340 mV = 2200;
341 break;
342 case MMC_VDD_20_21:
343 mV = 2000;
344 break;
345 case MMC_VDD_165_195:
346 mV = 1800;
347 break;
348 default:
349 BUG();
350 }
351 return menelaus_set_vdcdc(3, mV);
352 }
353 return 0;
354}
355
356static void n810_set_power_emmc(struct device *dev,
357 int power_on)
358{
359 dev_dbg(dev, "Set EMMC power %s\n", power_on ? "on" : "off");
360
361 if (power_on) {
362 gpio_set_value(N810_EMMC_VSD_GPIO, 1);
363 msleep(1);
Tony Lindgren1dea5c62010-04-21 15:27:24 -0700364 gpio_set_value(N810_EMMC_VIO_GPIO, 1);
Tony Lindgren9418c652010-02-26 15:31:12 -0800365 msleep(1);
366 } else {
Tony Lindgren1dea5c62010-04-21 15:27:24 -0700367 gpio_set_value(N810_EMMC_VIO_GPIO, 0);
Tony Lindgren9418c652010-02-26 15:31:12 -0800368 msleep(50);
369 gpio_set_value(N810_EMMC_VSD_GPIO, 0);
370 msleep(50);
371 }
372}
373
374static int n8x0_mmc_set_power(struct device *dev, int slot, int power_on,
375 int vdd)
376{
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800377 if (board_is_n800() || slot == 0)
Tony Lindgren9418c652010-02-26 15:31:12 -0800378 return n8x0_mmc_set_power_menelaus(dev, slot, power_on, vdd);
379
380 n810_set_power_emmc(dev, power_on);
381
382 return 0;
383}
384
385static int n8x0_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
386{
387 int r;
388
389 dev_dbg(dev, "Set slot %d bus mode %s\n", slot + 1,
390 bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
391 BUG_ON(slot != 0 && slot != 1);
392 slot++;
393 switch (bus_mode) {
394 case MMC_BUSMODE_OPENDRAIN:
395 r = menelaus_set_mmc_opendrain(slot, 1);
396 break;
397 case MMC_BUSMODE_PUSHPULL:
398 r = menelaus_set_mmc_opendrain(slot, 0);
399 break;
400 default:
401 BUG();
402 }
403 if (r != 0 && printk_ratelimit())
404 dev_err(dev, "MMC: unable to set bus mode for slot %d\n",
405 slot);
406 return r;
407}
408
409static int n8x0_mmc_get_cover_state(struct device *dev, int slot)
410{
411 slot++;
412 BUG_ON(slot != 1 && slot != 2);
413 if (slot == 1)
414 return slot1_cover_open;
415 else
416 return slot2_cover_open;
417}
418
419static void n8x0_mmc_callback(void *data, u8 card_mask)
420{
421 int bit, *openp, index;
422
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800423 if (board_is_n800()) {
Tony Lindgren9418c652010-02-26 15:31:12 -0800424 bit = 1 << 1;
425 openp = &slot2_cover_open;
426 index = 1;
427 } else {
428 bit = 1;
429 openp = &slot1_cover_open;
430 index = 0;
431 }
432
433 if (card_mask & bit)
434 *openp = 1;
435 else
436 *openp = 0;
437
Tony Lindgrend5171102012-02-20 10:00:03 -0800438#ifdef CONFIG_MMC_OMAP
Tony Lindgren9418c652010-02-26 15:31:12 -0800439 omap_mmc_notify_cover_event(mmc_device, index, *openp);
Tony Lindgrend5171102012-02-20 10:00:03 -0800440#else
441 pr_warn("MMC: notify cover event not available\n");
442#endif
Tony Lindgren9418c652010-02-26 15:31:12 -0800443}
444
Tony Lindgren9418c652010-02-26 15:31:12 -0800445static int n8x0_mmc_late_init(struct device *dev)
446{
447 int r, bit, *openp;
448 int vs2sel;
449
450 mmc_device = dev;
451
452 r = menelaus_set_slot_sel(1);
453 if (r < 0)
454 return r;
455
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800456 if (board_is_n800())
Tony Lindgren9418c652010-02-26 15:31:12 -0800457 vs2sel = 0;
458 else
459 vs2sel = 2;
460
461 r = menelaus_set_mmc_slot(2, 0, vs2sel, 1);
462 if (r < 0)
463 return r;
464
465 n8x0_mmc_set_power(dev, 0, MMC_POWER_ON, 16); /* MMC_VDD_28_29 */
466 n8x0_mmc_set_power(dev, 1, MMC_POWER_ON, 16);
467
468 r = menelaus_set_mmc_slot(1, 1, 0, 1);
469 if (r < 0)
470 return r;
471 r = menelaus_set_mmc_slot(2, 1, vs2sel, 1);
472 if (r < 0)
473 return r;
474
475 r = menelaus_get_slot_pin_states();
476 if (r < 0)
477 return r;
478
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800479 if (board_is_n800()) {
Tony Lindgren9418c652010-02-26 15:31:12 -0800480 bit = 1 << 1;
481 openp = &slot2_cover_open;
482 } else {
483 bit = 1;
484 openp = &slot1_cover_open;
485 slot2_cover_open = 0;
486 }
487
488 /* All slot pin bits seem to be inversed until first switch change */
489 if (r == 0xf || r == (0xf & ~bit))
490 r = ~r;
491
492 if (r & bit)
493 *openp = 1;
494 else
495 *openp = 0;
496
497 r = menelaus_register_mmc_callback(n8x0_mmc_callback, NULL);
498
499 return r;
500}
501
502static void n8x0_mmc_shutdown(struct device *dev)
503{
504 int vs2sel;
505
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800506 if (board_is_n800())
Tony Lindgren9418c652010-02-26 15:31:12 -0800507 vs2sel = 0;
508 else
509 vs2sel = 2;
510
511 menelaus_set_mmc_slot(1, 0, 0, 0);
512 menelaus_set_mmc_slot(2, 0, vs2sel, 0);
513}
514
515static void n8x0_mmc_cleanup(struct device *dev)
516{
517 menelaus_unregister_mmc_callback();
518
519 gpio_free(N8X0_SLOT_SWITCH_GPIO);
520
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800521 if (board_is_n810()) {
Tony Lindgren9418c652010-02-26 15:31:12 -0800522 gpio_free(N810_EMMC_VSD_GPIO);
Tony Lindgren1dea5c62010-04-21 15:27:24 -0700523 gpio_free(N810_EMMC_VIO_GPIO);
Tony Lindgren9418c652010-02-26 15:31:12 -0800524 }
525}
526
527/*
528 * MMC controller1 has two slots that are multiplexed via I2C.
529 * MMC controller2 is not in use.
530 */
531static struct omap_mmc_platform_data mmc1_data = {
Tony Lindgrenfa590c92013-11-25 15:17:10 -0800532 .nr_slots = 0,
Tony Lindgren9418c652010-02-26 15:31:12 -0800533 .switch_slot = n8x0_mmc_switch_slot,
534 .init = n8x0_mmc_late_init,
535 .cleanup = n8x0_mmc_cleanup,
536 .shutdown = n8x0_mmc_shutdown,
537 .max_freq = 24000000,
Tony Lindgren9418c652010-02-26 15:31:12 -0800538 .slots[0] = {
539 .wires = 4,
540 .set_power = n8x0_mmc_set_power,
541 .set_bus_mode = n8x0_mmc_set_bus_mode,
542 .get_cover_state = n8x0_mmc_get_cover_state,
543 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_30_31 |
544 MMC_VDD_32_33 | MMC_VDD_33_34,
545 .name = "internal",
546 },
547 .slots[1] = {
548 .set_power = n8x0_mmc_set_power,
549 .set_bus_mode = n8x0_mmc_set_bus_mode,
550 .get_cover_state = n8x0_mmc_get_cover_state,
551 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_20_21 |
552 MMC_VDD_21_22 | MMC_VDD_22_23 |
553 MMC_VDD_23_24 | MMC_VDD_24_25 |
554 MMC_VDD_27_28 | MMC_VDD_28_29 |
555 MMC_VDD_29_30 | MMC_VDD_30_31 |
556 MMC_VDD_32_33 | MMC_VDD_33_34,
557 .name = "external",
558 },
559};
560
561static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
562
Igor Grinbergbc593f52011-05-03 18:22:09 +0300563static struct gpio n810_emmc_gpios[] __initdata = {
564 { N810_EMMC_VSD_GPIO, GPIOF_OUT_INIT_LOW, "MMC slot 2 Vddf" },
565 { N810_EMMC_VIO_GPIO, GPIOF_OUT_INIT_LOW, "MMC slot 2 Vdd" },
566};
Tony Lindgren9418c652010-02-26 15:31:12 -0800567
Igor Grinbergbc593f52011-05-03 18:22:09 +0300568static void __init n8x0_mmc_init(void)
Tony Lindgren9418c652010-02-26 15:31:12 -0800569{
570 int err;
571
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800572 if (board_is_n810()) {
Tony Lindgren9418c652010-02-26 15:31:12 -0800573 mmc1_data.slots[0].name = "external";
574
575 /*
576 * Some Samsung Movinand chips do not like open-ended
577 * multi-block reads and fall to braind-dead state
578 * while doing so. Reducing the number of blocks in
579 * the transfer or delays in clock disable do not help
580 */
581 mmc1_data.slots[1].name = "internal";
582 mmc1_data.slots[1].ban_openended = 1;
583 }
584
Igor Grinbergbc593f52011-05-03 18:22:09 +0300585 err = gpio_request_one(N8X0_SLOT_SWITCH_GPIO, GPIOF_OUT_INIT_LOW,
586 "MMC slot switch");
Tony Lindgren9418c652010-02-26 15:31:12 -0800587 if (err)
Tony Lindgren1dea5c62010-04-21 15:27:24 -0700588 return;
Tony Lindgren9418c652010-02-26 15:31:12 -0800589
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800590 if (board_is_n810()) {
Igor Grinbergbc593f52011-05-03 18:22:09 +0300591 err = gpio_request_array(n810_emmc_gpios,
592 ARRAY_SIZE(n810_emmc_gpios));
Tony Lindgren9418c652010-02-26 15:31:12 -0800593 if (err) {
594 gpio_free(N8X0_SLOT_SWITCH_GPIO);
Tony Lindgren1dea5c62010-04-21 15:27:24 -0700595 return;
Tony Lindgren9418c652010-02-26 15:31:12 -0800596 }
Tony Lindgren9418c652010-02-26 15:31:12 -0800597 }
598
Tony Lindgrenfa590c92013-11-25 15:17:10 -0800599 mmc1_data.nr_slots = 2;
Tony Lindgren9418c652010-02-26 15:31:12 -0800600 mmc_data[0] = &mmc1_data;
Tony Lindgren810ac2a2013-11-25 15:17:10 -0800601 if (!of_have_populated_dt())
602 omap242x_init_mmc(mmc_data);
Tony Lindgren9418c652010-02-26 15:31:12 -0800603}
604#else
Tony Lindgrenfa590c92013-11-25 15:17:10 -0800605static struct omap_mmc_platform_data mmc1_data;
Tony Lindgren9418c652010-02-26 15:31:12 -0800606void __init n8x0_mmc_init(void)
607{
608}
Tony Lindgren9418c652010-02-26 15:31:12 -0800609#endif /* CONFIG_MMC_OMAP */
610
611#ifdef CONFIG_MENELAUS
612
613static int n8x0_auto_sleep_regulators(void)
614{
615 u32 val;
616 int ret;
617
618 val = EN_VPLL_SLEEP | EN_VMMC_SLEEP \
619 | EN_VAUX_SLEEP | EN_VIO_SLEEP \
620 | EN_VMEM_SLEEP | EN_DC3_SLEEP \
621 | EN_VC_SLEEP | EN_DC2_SLEEP;
622
623 ret = menelaus_set_regulator_sleep(1, val);
624 if (ret < 0) {
Paul Walmsley7852ec02012-07-26 00:54:26 -0600625 pr_err("Could not set regulators to sleep on menelaus: %u\n",
626 ret);
Tony Lindgren9418c652010-02-26 15:31:12 -0800627 return ret;
628 }
629 return 0;
630}
631
632static int n8x0_auto_voltage_scale(void)
633{
634 int ret;
635
636 ret = menelaus_set_vcore_hw(1400, 1050);
637 if (ret < 0) {
Paul Walmsley7852ec02012-07-26 00:54:26 -0600638 pr_err("Could not set VCORE voltage on menelaus: %u\n", ret);
Tony Lindgren9418c652010-02-26 15:31:12 -0800639 return ret;
640 }
641 return 0;
642}
643
644static int n8x0_menelaus_late_init(struct device *dev)
645{
646 int ret;
647
648 ret = n8x0_auto_voltage_scale();
649 if (ret < 0)
650 return ret;
651 ret = n8x0_auto_sleep_regulators();
652 if (ret < 0)
653 return ret;
654 return 0;
655}
656
Jarkko Nikulaa7f97d22010-08-20 09:36:28 +0300657#else
658static int n8x0_menelaus_late_init(struct device *dev)
659{
660 return 0;
661}
662#endif
Tony Lindgren9418c652010-02-26 15:31:12 -0800663
Jarkko Nikulaa7f97d22010-08-20 09:36:28 +0300664static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
Tony Lindgren9418c652010-02-26 15:31:12 -0800665 .late_init = n8x0_menelaus_late_init,
666};
667
Jarkko Nikulaa7f97d22010-08-20 09:36:28 +0300668static struct i2c_board_info __initdata n8x0_i2c_board_info_1[] __initdata = {
669 {
670 I2C_BOARD_INFO("menelaus", 0x72),
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700671 .irq = 7 + OMAP_INTC_START,
Jarkko Nikulaa7f97d22010-08-20 09:36:28 +0300672 .platform_data = &n8x0_menelaus_platform_data,
673 },
674};
Tony Lindgren9418c652010-02-26 15:31:12 -0800675
Jarkko Nikula366498d2010-08-20 09:36:28 +0300676static struct aic3x_pdata n810_aic33_data __initdata = {
677 .gpio_reset = 118,
678};
679
680static struct i2c_board_info n810_i2c_board_info_2[] __initdata = {
681 {
682 I2C_BOARD_INFO("tlv320aic3x", 0x18),
683 .platform_data = &n810_aic33_data,
684 },
685};
Tony Lindgren9418c652010-02-26 15:31:12 -0800686
Tony Lindgrenbd8f0fc2010-07-05 16:31:38 +0300687#ifdef CONFIG_OMAP_MUX
688static struct omap_board_mux board_mux[] __initdata = {
Jarkko Nikula04be1e92010-08-20 09:36:28 +0300689 /* I2S codec port pins for McBSP block */
690 OMAP2420_MUX(EAC_AC_SCLK, OMAP_MUX_MODE1 | OMAP_PIN_INPUT),
691 OMAP2420_MUX(EAC_AC_FS, OMAP_MUX_MODE1 | OMAP_PIN_INPUT),
692 OMAP2420_MUX(EAC_AC_DIN, OMAP_MUX_MODE1 | OMAP_PIN_INPUT),
693 OMAP2420_MUX(EAC_AC_DOUT, OMAP_MUX_MODE1 | OMAP_PIN_OUTPUT),
Tony Lindgrenbd8f0fc2010-07-05 16:31:38 +0300694 { .reg_offset = OMAP_MUX_TERMINATOR },
695};
Tony Lindgren0b50c692010-12-22 18:42:36 -0800696
697static struct omap_device_pad serial2_pads[] __initdata = {
698 {
699 .name = "uart3_rx_irrx.uart3_rx_irrx",
700 .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
701 .enable = OMAP_MUX_MODE0,
702 .idle = OMAP_MUX_MODE3 /* Mux as GPIO for idle */
703 },
704};
705
706static inline void board_serial_init(void)
707{
708 struct omap_board_data bdata;
709
710 bdata.flags = 0;
711 bdata.pads = NULL;
712 bdata.pads_cnt = 0;
713
714 bdata.id = 0;
Deepak Kc86845db2011-11-09 17:33:38 +0530715 omap_serial_init_port(&bdata, NULL);
Tony Lindgren0b50c692010-12-22 18:42:36 -0800716
717 bdata.id = 1;
Deepak Kc86845db2011-11-09 17:33:38 +0530718 omap_serial_init_port(&bdata, NULL);
Tony Lindgren0b50c692010-12-22 18:42:36 -0800719
720 bdata.id = 2;
721 bdata.pads = serial2_pads;
722 bdata.pads_cnt = ARRAY_SIZE(serial2_pads);
Deepak Kc86845db2011-11-09 17:33:38 +0530723 omap_serial_init_port(&bdata, NULL);
Tony Lindgren0b50c692010-12-22 18:42:36 -0800724}
725
726#else
727
728static inline void board_serial_init(void)
729{
730 omap_serial_init();
731}
732
Tony Lindgrenbd8f0fc2010-07-05 16:31:38 +0300733#endif
734
Tony Lindgren810ac2a2013-11-25 15:17:10 -0800735static int __init n8x0_late_initcall(void)
736{
737 if (!board_caps)
738 return -ENODEV;
739
740 gpmc_onenand_init(board_onenand_data);
741 n8x0_mmc_init();
742 n8x0_usb_init();
743 if (!of_have_populated_dt())
744 n8x0_cbus_init();
745
746 return 0;
747}
748omap_late_initcall(n8x0_late_initcall);
749
Tony Lindgrenfa590c92013-11-25 15:17:10 -0800750/*
751 * Legacy init pdata init for n8x0. Note that we want to follow the
752 * I2C bus numbering starting at 0 for device tree like other omaps.
753 */
754void * __init n8x0_legacy_init(void)
755{
756 board_check_revision();
757 spi_register_board_info(n800_spi_board_info,
758 ARRAY_SIZE(n800_spi_board_info));
759 i2c_register_board_info(0, n8x0_i2c_board_info_1,
760 ARRAY_SIZE(n8x0_i2c_board_info_1));
761 if (board_is_n810())
762 i2c_register_board_info(1, n810_i2c_board_info_2,
763 ARRAY_SIZE(n810_i2c_board_info_2));
764
765 return &mmc1_data;
766}
767
Kalle Valo63138812009-08-28 10:51:38 -0700768static void __init n8x0_init_machine(void)
769{
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800770 board_check_revision();
Tony Lindgrenbd8f0fc2010-07-05 16:31:38 +0300771 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC);
Kalle Valo63138812009-08-28 10:51:38 -0700772 /* FIXME: add n810 spi devices */
773 spi_register_board_info(n800_spi_board_info,
774 ARRAY_SIZE(n800_spi_board_info));
Jarkko Nikulaa7f97d22010-08-20 09:36:28 +0300775 omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
776 ARRAY_SIZE(n8x0_i2c_board_info_1));
Jarkko Nikula366498d2010-08-20 09:36:28 +0300777 omap_register_i2c_bus(2, 400, NULL, 0);
Tony Lindgrenc8f27e92013-11-25 15:17:09 -0800778 if (board_is_n810())
Jarkko Nikula366498d2010-08-20 09:36:28 +0300779 i2c_register_board_info(2, n810_i2c_board_info_2,
780 ARRAY_SIZE(n810_i2c_board_info_2));
Tony Lindgren810ac2a2013-11-25 15:17:10 -0800781 if (!of_have_populated_dt()) {
782 board_serial_init();
783 omap_sdrc_init(NULL, NULL);
784 }
Kalle Valo63138812009-08-28 10:51:38 -0700785}
786
787MACHINE_START(NOKIA_N800, "Nokia N800")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400788 .atag_offset = 0x100,
Russell King71ee7da2010-05-23 10:18:16 +0100789 .reserve = omap_reserve,
Tony Lindgrene990a402011-09-26 14:52:55 -0700790 .map_io = omap242x_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700791 .init_early = omap2420_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700792 .init_irq = omap2_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100793 .handle_irq = omap2_intc_handle_irq,
Kalle Valo63138812009-08-28 10:51:38 -0700794 .init_machine = n8x0_init_machine,
Shawn Guobbd707a2012-04-26 16:06:50 +0800795 .init_late = omap2420_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700796 .init_time = omap2_sync32k_timer_init,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600797 .restart = omap2xxx_restart,
Kalle Valo63138812009-08-28 10:51:38 -0700798MACHINE_END
799
800MACHINE_START(NOKIA_N810, "Nokia N810")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400801 .atag_offset = 0x100,
Russell King71ee7da2010-05-23 10:18:16 +0100802 .reserve = omap_reserve,
Tony Lindgrene990a402011-09-26 14:52:55 -0700803 .map_io = omap242x_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700804 .init_early = omap2420_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700805 .init_irq = omap2_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100806 .handle_irq = omap2_intc_handle_irq,
Kalle Valo63138812009-08-28 10:51:38 -0700807 .init_machine = n8x0_init_machine,
Shawn Guobbd707a2012-04-26 16:06:50 +0800808 .init_late = omap2420_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700809 .init_time = omap2_sync32k_timer_init,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600810 .restart = omap2xxx_restart,
Kalle Valo63138812009-08-28 10:51:38 -0700811MACHINE_END
812
813MACHINE_START(NOKIA_N810_WIMAX, "Nokia N810 WiMAX")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400814 .atag_offset = 0x100,
Russell King71ee7da2010-05-23 10:18:16 +0100815 .reserve = omap_reserve,
Tony Lindgrene990a402011-09-26 14:52:55 -0700816 .map_io = omap242x_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700817 .init_early = omap2420_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700818 .init_irq = omap2_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100819 .handle_irq = omap2_intc_handle_irq,
Kalle Valo63138812009-08-28 10:51:38 -0700820 .init_machine = n8x0_init_machine,
Shawn Guobbd707a2012-04-26 16:06:50 +0800821 .init_late = omap2420_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700822 .init_time = omap2_sync32k_timer_init,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600823 .restart = omap2xxx_restart,
Kalle Valo63138812009-08-28 10:51:38 -0700824MACHINE_END