TI816X: Update common OMAP machine specific sources
[deliverable/linux.git] / arch / arm / mach-omap2 / board-omap3logic.c
CommitLineData
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"
d40f3f15
TN
40
41#include <plat/mux.h>
42#include <plat/board.h>
43#include <plat/common.h>
26428b5c 44#include <plat/gpmc-smsc911x.h>
d40f3f15 45#include <plat/gpmc.h>
d40f3f15 46#include <plat/sdrc.h>
d40f3f15
TN
47
48#define OMAP3LOGIC_SMSC911X_CS 1
49
50#define OMAP3530_LV_SOM_MMC_GPIO_CD 110
51#define OMAP3530_LV_SOM_MMC_GPIO_WP 126
52#define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152
53
54#define OMAP3_TORPEDO_MMC_GPIO_CD 127
55#define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129
56
57static struct regulator_consumer_supply omap3logic_vmmc1_supply = {
58 .supply = "vmmc",
59};
60
61/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
62static struct regulator_init_data omap3logic_vmmc1 = {
63 .constraints = {
64 .name = "VMMC1",
65 .min_uV = 1850000,
66 .max_uV = 3150000,
67 .valid_modes_mask = REGULATOR_MODE_NORMAL
68 | REGULATOR_MODE_STANDBY,
69 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
70 | REGULATOR_CHANGE_MODE
71 | REGULATOR_CHANGE_STATUS,
72 },
73 .num_consumer_supplies = 1,
74 .consumer_supplies = &omap3logic_vmmc1_supply,
75};
76
77static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
78 .gpio_base = OMAP_MAX_GPIO_LINES,
79 .irq_base = TWL4030_GPIO_IRQ_BASE,
80 .irq_end = TWL4030_GPIO_IRQ_END,
81 .use_leds = true,
82 .pullups = BIT(1),
83 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8)
84 | BIT(13) | BIT(15) | BIT(16) | BIT(17),
85};
86
87static struct twl4030_platform_data omap3logic_twldata = {
88 .irq_base = TWL4030_IRQ_BASE,
89 .irq_end = TWL4030_IRQ_END,
90
91 /* platform_data for children goes here */
92 .gpio = &omap3logic_gpio_data,
8430281b 93 .vmmc1 = &omap3logic_vmmc1,
d40f3f15
TN
94};
95
96static struct i2c_board_info __initdata omap3logic_i2c_boardinfo[] = {
97 {
98 I2C_BOARD_INFO("twl4030", 0x48),
99 .flags = I2C_CLIENT_WAKE,
100 .irq = INT_34XX_SYS_NIRQ,
101 .platform_data = &omap3logic_twldata,
102 },
103};
104
105static int __init omap3logic_i2c_init(void)
106{
107 omap_register_i2c_bus(1, 2600, omap3logic_i2c_boardinfo,
108 ARRAY_SIZE(omap3logic_i2c_boardinfo));
109 return 0;
110}
111
8430281b
TN
112static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
113 {
114 .name = "external",
115 .mmc = 1,
116 .caps = MMC_CAP_4_BIT_DATA,
117 .gpio_cd = -EINVAL,
118 .gpio_wp = -EINVAL,
119 },
120 {} /* Terminator */
121};
122
123static void __init board_mmc_init(void)
124{
125 if (machine_is_omap3530_lv_som()) {
126 /* OMAP3530 LV SOM board */
127 board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
128 board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
129 omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
130 omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
131 } else if (machine_is_omap3_torpedo()) {
132 /* OMAP3 Torpedo board */
133 board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
134 omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
135 } else {
136 /* unsupported board */
137 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
138 return;
139 }
140
141 omap2_hsmmc_init(board_mmc_info);
142 /* link regulators to MMC adapters */
143 omap3logic_vmmc1_supply.dev = board_mmc_info[0].dev;
144}
145
26428b5c
TN
146static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
147 .cs = OMAP3LOGIC_SMSC911X_CS,
148 .gpio_irq = -EINVAL,
149 .gpio_reset = -EINVAL,
150 .flags = IORESOURCE_IRQ_LOWLEVEL,
151};
152
153/* TODO/FIXME (comment by Peter Barada, LogicPD):
154 * Fix the PBIAS voltage for Torpedo MMC1 pins that
155 * are used for other needs (IRQs, etc). */
156static void omap3torpedo_fix_pbias_voltage(void)
157{
158 u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
159 u32 reg;
160
161 if (machine_is_omap3_torpedo())
162 {
163 /* Set the bias for the pin */
164 reg = omap_ctrl_readl(control_pbias_offset);
165
166 reg &= ~OMAP343X_PBIASLITEPWRDNZ1;
167 omap_ctrl_writel(reg, control_pbias_offset);
168
169 /* 100ms delay required for PBIAS configuration */
170 msleep(100);
171
172 reg |= OMAP343X_PBIASLITEVMODE1;
173 reg |= OMAP343X_PBIASLITEPWRDNZ1;
174 omap_ctrl_writel(reg | 0x300, control_pbias_offset);
175 }
176}
177
178static inline void __init board_smsc911x_init(void)
179{
180 if (machine_is_omap3530_lv_som()) {
181 /* OMAP3530 LV SOM board */
182 board_smsc911x_data.gpio_irq =
183 OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ;
184 omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT);
185 } else if (machine_is_omap3_torpedo()) {
186 /* OMAP3 Torpedo board */
187 board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ;
188 omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT);
189 } else {
190 /* unsupported board */
191 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
192 return;
193 }
194
195 gpmc_smsc911x_init(&board_smsc911x_data);
196}
197
3dc3bad6 198static void __init omap3logic_init_early(void)
d40f3f15 199{
4805734b
PW
200 omap2_init_common_infrastructure();
201 omap2_init_common_devices(NULL, NULL);
d40f3f15
TN
202}
203
26428b5c
TN
204#ifdef CONFIG_OMAP_MUX
205static struct omap_board_mux board_mux[] __initdata = {
206 { .reg_offset = OMAP_MUX_TERMINATOR },
207};
26428b5c
TN
208#endif
209
d40f3f15
TN
210static void __init omap3logic_init(void)
211{
26428b5c
TN
212 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
213 omap3torpedo_fix_pbias_voltage();
d40f3f15
TN
214 omap3logic_i2c_init();
215 omap_serial_init();
8430281b 216 board_mmc_init();
26428b5c
TN
217 board_smsc911x_init();
218
d40f3f15
TN
219 /* Ensure SDRC pins are mux'd for self-refresh */
220 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
221 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
222}
223
224MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
d40f3f15
TN
225 .boot_params = 0x80000100,
226 .map_io = omap3_map_io,
3dc3bad6
RKAL
227 .init_early = omap3logic_init_early,
228 .init_irq = omap_init_irq,
d40f3f15
TN
229 .init_machine = omap3logic_init,
230 .timer = &omap_timer,
231MACHINE_END
232
233MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
d40f3f15
TN
234 .boot_params = 0x80000100,
235 .map_io = omap3_map_io,
3dc3bad6
RKAL
236 .init_early = omap3logic_init_early,
237 .init_irq = omap_init_irq,
d40f3f15
TN
238 .init_machine = omap3logic_init,
239 .timer = &omap_timer,
240MACHINE_END
This page took 0.060759 seconds and 5 git commands to generate.