1/*
2 * Board support file for Nokia RM-680/696.
3 *
4 * Copyright (C) 2010 Nokia
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
11#include <linux/io.h>
12#include <linux/i2c.h>
13#include <linux/gpio.h>
14#include <linux/init.h>
15#include <linux/i2c/twl.h>
16#include <linux/platform_device.h>
17#include <linux/regulator/fixed.h>
18#include <linux/regulator/machine.h>
19#include <linux/regulator/consumer.h>
20
21#include <asm/mach/arch.h>
22#include <asm/mach-types.h>
23
24#include <plat/i2c.h>
25#include <plat/mmc.h>
26#include <plat/usb.h>
27#include <plat/gpmc.h>
28#include "common.h"
29#include <plat/onenand.h>
30
31#include "mux.h"
32#include "hsmmc.h"
33#include "sdram-nokia.h"
34#include "common-board-devices.h"
35
36static struct regulator_consumer_supply rm680_vemmc_consumers[] = {
37	REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
38};
39
40/* Fixed regulator for internal eMMC */
41static struct regulator_init_data rm680_vemmc = {
42	.constraints =	{
43		.name			= "rm680_vemmc",
44		.valid_modes_mask	= REGULATOR_MODE_NORMAL
45					| REGULATOR_MODE_STANDBY,
46		.valid_ops_mask		= REGULATOR_CHANGE_STATUS
47					| REGULATOR_CHANGE_MODE,
48	},
49	.num_consumer_supplies		= ARRAY_SIZE(rm680_vemmc_consumers),
50	.consumer_supplies		= rm680_vemmc_consumers,
51};
52
53static struct fixed_voltage_config rm680_vemmc_config = {
54	.supply_name		= "VEMMC",
55	.microvolts		= 2900000,
56	.gpio			= 157,
57	.startup_delay		= 150,
58	.enable_high		= 1,
59	.init_data		= &rm680_vemmc,
60};
61
62static struct platform_device rm680_vemmc_device = {
63	.name			= "reg-fixed-voltage",
64	.dev			= {
65		.platform_data	= &rm680_vemmc_config,
66	},
67};
68
69static struct platform_device *rm680_peripherals_devices[] __initdata = {
70	&rm680_vemmc_device,
71};
72
73/* TWL */
74static struct twl4030_gpio_platform_data rm680_gpio_data = {
75	.gpio_base		= OMAP_MAX_GPIO_LINES,
76	.irq_base		= TWL4030_GPIO_IRQ_BASE,
77	.irq_end		= TWL4030_GPIO_IRQ_END,
78	.pullups		= BIT(0),
79	.pulldowns		= BIT(1) | BIT(2) | BIT(8) | BIT(15),
80};
81
82static struct twl4030_platform_data rm680_twl_data = {
83	.gpio			= &rm680_gpio_data,
84	/* add rest of the children here */
85};
86
87static void __init rm680_i2c_init(void)
88{
89	omap3_pmic_get_config(&rm680_twl_data, TWL_COMMON_PDATA_USB, 0);
90	omap_pmic_init(1, 2900, "twl5031", INT_34XX_SYS_NIRQ, &rm680_twl_data);
91	omap_register_i2c_bus(2, 400, NULL, 0);
92	omap_register_i2c_bus(3, 400, NULL, 0);
93}
94
95#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
96	defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
97static struct omap_onenand_platform_data board_onenand_data[] = {
98	{
99		.gpio_irq	= 65,
100		.flags		= ONENAND_SYNC_READWRITE,
101	}
102};
103#endif
104
105/* eMMC */
106static struct omap2_hsmmc_info mmc[] __initdata = {
107	{
108		.name		= "internal",
109		.mmc		= 2,
110		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED,
111		.gpio_cd	= -EINVAL,
112		.gpio_wp	= -EINVAL,
113	},
114	{ /* Terminator */ }
115};
116
117static void __init rm680_peripherals_init(void)
118{
119	platform_add_devices(rm680_peripherals_devices,
120				ARRAY_SIZE(rm680_peripherals_devices));
121	rm680_i2c_init();
122	gpmc_onenand_init(board_onenand_data);
123	omap_hsmmc_init(mmc);
124}
125
126#ifdef CONFIG_OMAP_MUX
127static struct omap_board_mux board_mux[] __initdata = {
128	{ .reg_offset = OMAP_MUX_TERMINATOR },
129};
130#endif
131
132static void __init rm680_init(void)
133{
134	struct omap_sdrc_params *sdrc_params;
135
136	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
137	omap_serial_init();
138
139	sdrc_params = nokia_get_sdram_timings();
140	omap_sdrc_init(sdrc_params, sdrc_params);
141
142	usb_musb_init(NULL);
143	rm680_peripherals_init();
144}
145
146MACHINE_START(NOKIA_RM680, "Nokia RM-680 board")
147	.atag_offset	= 0x100,
148	.reserve	= omap_reserve,
149	.map_io		= omap3_map_io,
150	.init_early	= omap3630_init_early,
151	.init_irq	= omap3_init_irq,
152	.handle_irq	= omap3_intc_handle_irq,
153	.init_machine	= rm680_init,
154	.timer		= &omap3_timer,
155	.restart	= omap_prcm_restart,
156MACHINE_END
157
158MACHINE_START(NOKIA_RM696, "Nokia RM-696 board")
159	.atag_offset	= 0x100,
160	.reserve	= omap_reserve,
161	.map_io		= omap3_map_io,
162	.init_early	= omap3630_init_early,
163	.init_irq	= omap3_init_irq,
164	.handle_irq	= omap3_intc_handle_irq,
165	.init_machine	= rm680_init,
166	.timer		= &omap3_timer,
167	.restart	= omap_prcm_restart,
168MACHINE_END
169