blob: 660bfc5a70d7e26edd82ebc2db1368ff3d91eeee [file] [log] [blame]
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +03001/*
2 * linux/arch/arm/mach-omap2/board-omap3beagle.c
3 *
4 * Copyright (C) 2008 Texas Instruments
5 *
6 * Modified from mach-omap2/board-3430sdp.c
7 *
8 * Initial code: Syed Mohammed Khasim
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/delay.h>
19#include <linux/err.h>
20#include <linux/clk.h>
21#include <linux/io.h>
22#include <linux/leds.h>
Peter Ujfalusib8e21302012-11-07 15:25:30 +010023#include <linux/pwm.h>
24#include <linux/leds_pwm.h>
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030025#include <linux/gpio.h>
26#include <linux/input.h>
27#include <linux/gpio_keys.h>
Nishanth Menone4db1c72013-09-19 16:03:52 -050028#include <linux/pm_opp.h>
Kevin Hilman65bf7ca2012-10-22 11:08:27 -070029#include <linux/cpu.h>
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030030
31#include <linux/mtd/mtd.h>
32#include <linux/mtd/partitions.h>
33#include <linux/mtd/nand.h>
Sukumar Ghorai3a638332010-09-15 14:49:23 +000034#include <linux/mmc/host.h>
Kishon Vijay Abraham I51482be2013-02-06 18:58:50 +053035#include <linux/usb/phy.h>
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030036
David Brownellbb3b9d82009-05-28 14:04:03 -070037#include <linux/regulator/machine.h>
Santosh Shilimkarb07682b2009-12-13 20:05:51 +010038#include <linux/i2c/twl.h>
Tony Lindgren145d9c92009-01-15 13:09:53 +020039
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030040#include <asm/mach-types.h>
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43#include <asm/mach/flash.h>
44
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030045#include <video/omapdss.h>
Archit Tanejaa0d8dde2013-02-12 16:46:46 +053046#include <video/omap-panel-data.h>
Arnd Bergmann22037472012-08-24 15:21:06 +020047#include <linux/platform_data/mtd-nand-omap2.h>
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030048
Tony Lindgren6d026432012-10-24 15:05:45 -070049#include "common.h"
50#include "omap_device.h"
51#include "gpmc.h"
Tony Lindgrene4c060d2012-10-05 13:25:59 -070052#include "soc.h"
Tony Lindgrenca5742b2009-12-11 16:16:32 -080053#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080054#include "hsmmc.h"
Nishanth Menon87434102011-01-07 09:41:13 -060055#include "pm.h"
Afzal Mohammed2e618262012-02-29 18:11:56 +053056#include "board-flash.h"
Mike Rapoportfbd80712011-04-25 01:09:06 +030057#include "common-board-devices.h"
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030058
Afzal Mohammed2e618262012-02-29 18:11:56 +053059#define NAND_CS 0
60
Peter Ujfalusib8e21302012-11-07 15:25:30 +010061static struct pwm_lookup pwm_lookup[] = {
62 /* LEDB -> PMU_STAT */
63 PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat"),
64};
65
66static struct led_pwm pwm_leds[] = {
67 {
68 .name = "beagleboard::pmu_stat",
69 .max_brightness = 127,
70 .pwm_period_ns = 7812500,
71 },
72};
73
74static struct led_pwm_platform_data pwm_data = {
75 .num_leds = ARRAY_SIZE(pwm_leds),
76 .leds = pwm_leds,
77};
78
79static struct platform_device leds_pwm = {
80 .name = "leds_pwm",
81 .id = -1,
82 .dev = {
83 .platform_data = &pwm_data,
84 },
85};
86
Robert Nelson954bed02010-09-23 18:22:47 -070087/*
88 * OMAP3 Beagle revision
89 * Run time detection of Beagle revision is done by reading GPIO.
90 * GPIO ID -
91 * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
92 * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
93 * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -070094 * XMA/XMB = GPIO173, GPIO172, GPIO171: 0 0 0
95 * XMC = GPIO173, GPIO172, GPIO171: 0 1 0
Robert Nelson954bed02010-09-23 18:22:47 -070096 */
97enum {
98 OMAP3BEAGLE_BOARD_UNKN = 0,
99 OMAP3BEAGLE_BOARD_AXBX,
100 OMAP3BEAGLE_BOARD_C1_3,
101 OMAP3BEAGLE_BOARD_C4,
102 OMAP3BEAGLE_BOARD_XM,
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700103 OMAP3BEAGLE_BOARD_XMC,
Robert Nelson954bed02010-09-23 18:22:47 -0700104};
105
106static u8 omap3_beagle_version;
107
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700108/*
109 * Board-specific configuration
110 * Defaults to BeagleBoard-xMC
111 */
112static struct {
113 int mmc1_gpio_wp;
Roger Quadroscf7dd652013-05-08 16:48:00 -0700114 bool usb_pwr_level; /* 0 - Active Low, 1 - Active High */
Russ Dillaef2b892012-05-09 15:15:03 -0700115 int dvi_pd_gpio;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700116 int usr_button_gpio;
Russ Dill1afb82e2012-05-09 14:19:15 -0700117 int mmc_caps;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700118} beagle_config = {
119 .mmc1_gpio_wp = -EINVAL,
Roger Quadroscf7dd652013-05-08 16:48:00 -0700120 .usb_pwr_level = 0,
Russ Dillaef2b892012-05-09 15:15:03 -0700121 .dvi_pd_gpio = -EINVAL,
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700122 .usr_button_gpio = 4,
Russ Dill1afb82e2012-05-09 14:19:15 -0700123 .mmc_caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700124};
Robert Nelson954bed02010-09-23 18:22:47 -0700125
Igor Grinbergbc593f52011-05-03 18:22:09 +0300126static struct gpio omap3_beagle_rev_gpios[] __initdata = {
127 { 171, GPIOF_IN, "rev_id_0" },
128 { 172, GPIOF_IN, "rev_id_1" },
129 { 173, GPIOF_IN, "rev_id_2" },
130};
131
Robert Nelson954bed02010-09-23 18:22:47 -0700132static void __init omap3_beagle_init_rev(void)
133{
134 int ret;
135 u16 beagle_rev = 0;
136
137 omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
138 omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
139 omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
140
Igor Grinbergbc593f52011-05-03 18:22:09 +0300141 ret = gpio_request_array(omap3_beagle_rev_gpios,
142 ARRAY_SIZE(omap3_beagle_rev_gpios));
143 if (ret < 0) {
144 printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
145 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
146 return;
147 }
Robert Nelson954bed02010-09-23 18:22:47 -0700148
149 beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
150 | (gpio_get_value(173) << 2);
151
Tasslehoff Kjappfot5e2ffc32011-05-31 04:58:56 -0700152 gpio_free_array(omap3_beagle_rev_gpios,
153 ARRAY_SIZE(omap3_beagle_rev_gpios));
154
Robert Nelson954bed02010-09-23 18:22:47 -0700155 switch (beagle_rev) {
156 case 7:
157 printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
158 omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700159 beagle_config.mmc1_gpio_wp = 29;
Russ Dillaef2b892012-05-09 15:15:03 -0700160 beagle_config.dvi_pd_gpio = 170;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700161 beagle_config.usr_button_gpio = 7;
Robert Nelson954bed02010-09-23 18:22:47 -0700162 break;
163 case 6:
164 printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
165 omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700166 beagle_config.mmc1_gpio_wp = 23;
Russ Dillaef2b892012-05-09 15:15:03 -0700167 beagle_config.dvi_pd_gpio = 170;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700168 beagle_config.usr_button_gpio = 7;
Robert Nelson954bed02010-09-23 18:22:47 -0700169 break;
170 case 5:
171 printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
172 omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700173 beagle_config.mmc1_gpio_wp = 23;
Russ Dillaef2b892012-05-09 15:15:03 -0700174 beagle_config.dvi_pd_gpio = 170;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700175 beagle_config.usr_button_gpio = 7;
Robert Nelson954bed02010-09-23 18:22:47 -0700176 break;
177 case 0:
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700178 printk(KERN_INFO "OMAP3 Beagle Rev: xM Ax/Bx\n");
Robert Nelson954bed02010-09-23 18:22:47 -0700179 omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
Roger Quadroscf7dd652013-05-08 16:48:00 -0700180 beagle_config.usb_pwr_level = 1;
Russ Dill1afb82e2012-05-09 14:19:15 -0700181 beagle_config.mmc_caps &= ~MMC_CAP_8_BIT_DATA;
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700182 break;
183 case 2:
184 printk(KERN_INFO "OMAP3 Beagle Rev: xM C\n");
185 omap3_beagle_version = OMAP3BEAGLE_BOARD_XMC;
Russ Dill1afb82e2012-05-09 14:19:15 -0700186 beagle_config.mmc_caps &= ~MMC_CAP_8_BIT_DATA;
Robert Nelson954bed02010-09-23 18:22:47 -0700187 break;
188 default:
189 printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
190 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
191 }
Robert Nelson954bed02010-09-23 18:22:47 -0700192}
193
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300194static struct mtd_partition omap3beagle_nand_partitions[] = {
195 /* All the partition sizes are listed in terms of NAND block size */
196 {
197 .name = "X-Loader",
198 .offset = 0,
199 .size = 4 * NAND_BLOCK_SIZE,
200 .mask_flags = MTD_WRITEABLE, /* force read-only */
201 },
202 {
203 .name = "U-Boot",
204 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
205 .size = 15 * NAND_BLOCK_SIZE,
206 .mask_flags = MTD_WRITEABLE, /* force read-only */
207 },
208 {
209 .name = "U-Boot Env",
210 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
211 .size = 1 * NAND_BLOCK_SIZE,
212 },
213 {
214 .name = "Kernel",
215 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
216 .size = 32 * NAND_BLOCK_SIZE,
217 },
218 {
219 .name = "File System",
220 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
221 .size = MTDPART_SIZ_FULL,
222 },
223};
224
Koen Kooi044d32f2010-04-22 10:23:42 +0200225/* DSS */
226
Tomi Valkeinen53025562013-05-17 14:00:19 +0300227static struct connector_dvi_platform_data beagle_dvi_connector_pdata = {
228 .name = "dvi",
229 .source = "tfp410.0",
230 .i2c_bus_num = 3,
Bryan Wu89747c92010-11-17 13:34:34 +0000231};
232
Tomi Valkeinen53025562013-05-17 14:00:19 +0300233static struct platform_device beagle_dvi_connector_device = {
234 .name = "connector-dvi",
235 .id = 0,
236 .dev.platform_data = &beagle_dvi_connector_pdata,
Koen Kooi044d32f2010-04-22 10:23:42 +0200237};
238
Tomi Valkeinen53025562013-05-17 14:00:19 +0300239static struct encoder_tfp410_platform_data beagle_tfp410_pdata = {
240 .name = "tfp410.0",
241 .source = "dpi.0",
242 .data_lines = 24,
243 .power_down_gpio = -1,
244};
245
246static struct platform_device beagle_tfp410_device = {
247 .name = "tfp410",
248 .id = 0,
249 .dev.platform_data = &beagle_tfp410_pdata,
250};
251
252static struct connector_atv_platform_data beagle_tv_pdata = {
Koen Kooi044d32f2010-04-22 10:23:42 +0200253 .name = "tv",
Tomi Valkeinen53025562013-05-17 14:00:19 +0300254 .source = "venc.0",
255 .connector_type = OMAP_DSS_VENC_TYPE_SVIDEO,
256 .invert_polarity = false,
Koen Kooi044d32f2010-04-22 10:23:42 +0200257};
258
Tomi Valkeinen53025562013-05-17 14:00:19 +0300259static struct platform_device beagle_tv_connector_device = {
260 .name = "connector-analog-tv",
261 .id = 0,
262 .dev.platform_data = &beagle_tv_pdata,
Koen Kooi044d32f2010-04-22 10:23:42 +0200263};
264
265static struct omap_dss_board_info beagle_dss_data = {
Tomi Valkeinen53025562013-05-17 14:00:19 +0300266 .default_display_name = "dvi",
Koen Kooi044d32f2010-04-22 10:23:42 +0200267};
268
Paul Walmsley2e12bd72009-05-28 14:03:59 -0700269#include "sdram-micron-mt46h32m32lf-6.h"
270
Adrian Hunter68ff0422010-02-15 10:03:34 -0800271static struct omap2_hsmmc_info mmc[] = {
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800272 {
273 .mmc = 1,
Russ Dill1afb82e2012-05-09 14:19:15 -0700274 .caps = MMC_CAP_4_BIT_DATA,
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700275 .gpio_wp = -EINVAL,
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800276 .deferred = true,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800277 },
278 {} /* Terminator */
279};
280
Oleg Drokin786b01a2011-06-06 18:57:07 +0000281static struct regulator_consumer_supply beagle_vmmc1_supply[] = {
282 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
David Brownellbb3b9d82009-05-28 14:04:03 -0700283};
284
Oleg Drokin786b01a2011-06-06 18:57:07 +0000285static struct regulator_consumer_supply beagle_vsim_supply[] = {
286 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
David Brownellbb3b9d82009-05-28 14:04:03 -0700287};
288
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800289static struct gpio_led gpio_leds[];
290
Roger Quadros60226712013-03-20 17:44:43 +0200291static struct usbhs_phy_data phy_data[] = {
292 {
293 .port = 2,
294 .reset_gpio = 147,
295 .vcc_gpio = -1, /* updated in beagle_twl_gpio_setup */
296 .vcc_polarity = 1, /* updated in beagle_twl_gpio_setup */
Roger Quadros60226712013-03-20 17:44:43 +0200297 },
298};
299
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800300static int beagle_twl_gpio_setup(struct device *dev,
301 unsigned gpio, unsigned ngpio)
302{
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700303 int r;
Koen Kooi1bd9ef12011-01-12 00:23:29 +0000304
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700305 mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800306 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
Tony Lindgren145d9c92009-01-15 13:09:53 +0200307 mmc[0].gpio_cd = gpio + 0;
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800308 omap_hsmmc_late_init(mmc);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800309
Koen Kooi68fc3e12011-01-11 17:13:35 +0000310 /*
311 * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active
312 * high / others active low)
Igor Grinbergbc593f52011-05-03 18:22:09 +0300313 * DVI reset GPIO is different between beagle revisions
Koen Kooi1bd9ef12011-01-12 00:23:29 +0000314 */
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700315 /* Valid for all -xM revisions */
316 if (cpu_is_omap3630()) {
Igor Grinbergbc593f52011-05-03 18:22:09 +0300317 /*
318 * gpio + 1 on Xm controls the TFP410's enable line (active low)
319 * gpio + 2 control varies depending on the board rev as below:
320 * P7/P8 revisions(prototype): Camera EN
321 * A2+ revisions (production): LDO (DVI, serial, led blocks)
322 */
323 r = gpio_request_one(gpio + 1, GPIOF_OUT_INIT_LOW,
324 "nDVI_PWR_EN");
Koen Kooi1bd9ef12011-01-12 00:23:29 +0000325 if (r)
326 pr_err("%s: unable to configure nDVI_PWR_EN\n",
327 __func__);
Russ Dillaef2b892012-05-09 15:15:03 -0700328
329 beagle_config.dvi_pd_gpio = gpio + 2;
330
Igor Grinbergbc593f52011-05-03 18:22:09 +0300331 } else {
Igor Grinbergbc593f52011-05-03 18:22:09 +0300332 /*
333 * REVISIT: need ehci-omap hooks for external VBUS
334 * power switch and overcurrent detect
335 */
336 if (gpio_request_one(gpio + 1, GPIOF_IN, "EHCI_nOC"))
337 pr_err("%s: unable to configure EHCI_nOC\n", __func__);
Koen Kooi1bd9ef12011-01-12 00:23:29 +0000338 }
Tomi Valkeinen53025562013-05-17 14:00:19 +0300339 beagle_tfp410_pdata.power_down_gpio = beagle_config.dvi_pd_gpio;
340
341 platform_device_register(&beagle_tfp410_device);
342 platform_device_register(&beagle_dvi_connector_device);
343 platform_device_register(&beagle_tv_connector_device);
Koen Kooi1bd9ef12011-01-12 00:23:29 +0000344
Roger Quadros60226712013-03-20 17:44:43 +0200345 /* TWL4030_GPIO_MAX i.e. LED_GPO controls HS USB Port 2 power */
346 phy_data[0].vcc_gpio = gpio + TWL4030_GPIO_MAX;
347 phy_data[0].vcc_polarity = beagle_config.usb_pwr_level;
Igor Grinbergbc593f52011-05-03 18:22:09 +0300348
Roger Quadros60226712013-03-20 17:44:43 +0200349 usbhs_init_phys(phy_data, ARRAY_SIZE(phy_data));
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800350 return 0;
351}
352
353static struct twl4030_gpio_platform_data beagle_gpio_data = {
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800354 .use_leds = true,
355 .pullups = BIT(1),
356 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
357 | BIT(15) | BIT(16) | BIT(17),
358 .setup = beagle_twl_gpio_setup,
359};
360
David Brownellbb3b9d82009-05-28 14:04:03 -0700361/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
362static struct regulator_init_data beagle_vmmc1 = {
363 .constraints = {
364 .min_uV = 1850000,
365 .max_uV = 3150000,
366 .valid_modes_mask = REGULATOR_MODE_NORMAL
367 | REGULATOR_MODE_STANDBY,
368 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
369 | REGULATOR_CHANGE_MODE
370 | REGULATOR_CHANGE_STATUS,
371 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000372 .num_consumer_supplies = ARRAY_SIZE(beagle_vmmc1_supply),
373 .consumer_supplies = beagle_vmmc1_supply,
David Brownellbb3b9d82009-05-28 14:04:03 -0700374};
375
376/* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
377static struct regulator_init_data beagle_vsim = {
378 .constraints = {
379 .min_uV = 1800000,
380 .max_uV = 3000000,
381 .valid_modes_mask = REGULATOR_MODE_NORMAL
382 | REGULATOR_MODE_STANDBY,
383 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
384 | REGULATOR_CHANGE_MODE
385 | REGULATOR_CHANGE_STATUS,
386 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000387 .num_consumer_supplies = ARRAY_SIZE(beagle_vsim_supply),
388 .consumer_supplies = beagle_vsim_supply,
David Brownellbb3b9d82009-05-28 14:04:03 -0700389};
390
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800391static struct twl4030_platform_data beagle_twldata = {
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800392 /* platform_data for children goes here */
393 .gpio = &beagle_gpio_data,
David Brownellbb3b9d82009-05-28 14:04:03 -0700394 .vmmc1 = &beagle_vmmc1,
395 .vsim = &beagle_vsim,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800396};
397
Mathieu J. Poiriere3333f42010-09-23 18:22:48 -0700398static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
399 {
400 I2C_BOARD_INFO("eeprom", 0x50),
401 },
402};
403
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800404static int __init omap3_beagle_i2c_init(void)
405{
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300406 omap3_pmic_get_config(&beagle_twldata,
Kyle Mannacdcc9662011-08-11 22:33:15 -0500407 TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC |
408 TWL_COMMON_PDATA_AUDIO,
Peter Ujfalusib252b0ef2011-06-07 11:38:24 +0300409 TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
410
411 beagle_twldata.vpll2->constraints.name = "VDVI";
412
Mike Rapoportfbd80712011-04-25 01:09:06 +0300413 omap3_pmic_init("twl4030", &beagle_twldata);
Koen Kooi8ca7fe22009-03-04 10:07:42 -0800414 /* Bus 3 is attached to the DVI port where devices like the pico DLP
415 * projector don't work reliably with 400kHz */
Mathieu J. Poiriere3333f42010-09-23 18:22:48 -0700416 omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800417 return 0;
418}
419
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300420static struct gpio_led gpio_leds[] = {
421 {
422 .name = "beagleboard::usr0",
423 .default_trigger = "heartbeat",
424 .gpio = 150,
425 },
426 {
427 .name = "beagleboard::usr1",
428 .default_trigger = "mmc0",
429 .gpio = 149,
430 },
431};
432
433static struct gpio_led_platform_data gpio_led_info = {
434 .leds = gpio_leds,
435 .num_leds = ARRAY_SIZE(gpio_leds),
436};
437
438static struct platform_device leds_gpio = {
439 .name = "leds-gpio",
440 .id = -1,
441 .dev = {
442 .platform_data = &gpio_led_info,
443 },
444};
445
446static struct gpio_keys_button gpio_buttons[] = {
447 {
448 .code = BTN_EXTRA,
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700449 /* Dynamically assigned depending on board */
450 .gpio = -EINVAL,
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300451 .desc = "user",
452 .wakeup = 1,
453 },
454};
455
456static struct gpio_keys_platform_data gpio_key_info = {
457 .buttons = gpio_buttons,
458 .nbuttons = ARRAY_SIZE(gpio_buttons),
459};
460
461static struct platform_device keys_gpio = {
462 .name = "gpio-keys",
463 .id = -1,
464 .dev = {
465 .platform_data = &gpio_key_info,
466 },
467};
468
Kyle Mannacdcc9662011-08-11 22:33:15 -0500469static struct platform_device madc_hwmon = {
470 .name = "twl4030_madc_hwmon",
471 .id = -1,
472};
473
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300474static struct platform_device *omap3_beagle_devices[] __initdata = {
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300475 &leds_gpio,
476 &keys_gpio,
Kyle Mannacdcc9662011-08-11 22:33:15 -0500477 &madc_hwmon,
Peter Ujfalusib8e21302012-11-07 15:25:30 +0100478 &leds_pwm,
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300479};
480
Roger Quadros42973152013-02-14 10:13:48 +0200481static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
Keshava Munegowda181b2502011-03-01 20:08:16 +0530482 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
Felipe Balbi58a54912009-11-22 10:11:01 -0800483};
484
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800485#ifdef CONFIG_OMAP_MUX
486static struct omap_board_mux board_mux[] __initdata = {
487 { .reg_offset = OMAP_MUX_TERMINATOR },
488};
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800489#endif
490
Kevin Hilman65bf7ca2012-10-22 11:08:27 -0700491static int __init beagle_opp_init(void)
Nishanth Menon87434102011-01-07 09:41:13 -0600492{
493 int r = 0;
494
Kevin Hilman65bf7ca2012-10-22 11:08:27 -0700495 if (!machine_is_omap3_beagle())
496 return 0;
497
498 /* Initialize the omap3 opp table if not already created. */
499 r = omap3_opp_init();
Russell Kingc48cd652013-03-13 20:44:21 +0000500 if (r < 0 && (r != -EEXIST)) {
Nishanth Menon87434102011-01-07 09:41:13 -0600501 pr_err("%s: opp default init failed\n", __func__);
Kevin Hilman65bf7ca2012-10-22 11:08:27 -0700502 return r;
Nishanth Menon87434102011-01-07 09:41:13 -0600503 }
504
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700505 /* Custom OPP enabled for all xM versions */
506 if (cpu_is_omap3630()) {
Kevin Hilman8c7f6592011-07-21 11:43:48 -0700507 struct device *mpu_dev, *iva_dev;
Nishanth Menon87434102011-01-07 09:41:13 -0600508
Kevin Hilman65bf7ca2012-10-22 11:08:27 -0700509 mpu_dev = get_cpu_device(0);
Benoit Coussonb1621fc2011-08-16 14:01:23 +0200510 iva_dev = omap_device_get_by_hwmod_name("iva");
Kevin Hilman8c7f6592011-07-21 11:43:48 -0700511
Wei Yongjunc27f2de2013-10-30 13:23:21 +0800512 if (!mpu_dev || IS_ERR(iva_dev)) {
Nishanth Menon87434102011-01-07 09:41:13 -0600513 pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n",
Kevin Hilman8c7f6592011-07-21 11:43:48 -0700514 __func__, mpu_dev, iva_dev);
Kevin Hilman65bf7ca2012-10-22 11:08:27 -0700515 return -ENODEV;
Nishanth Menon87434102011-01-07 09:41:13 -0600516 }
517 /* Enable MPU 1GHz and lower opps */
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500518 r = dev_pm_opp_enable(mpu_dev, 800000000);
Nishanth Menon87434102011-01-07 09:41:13 -0600519 /* TODO: MPU 1GHz needs SR and ABB */
520
521 /* Enable IVA 800MHz and lower opps */
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500522 r |= dev_pm_opp_enable(iva_dev, 660000000);
Nishanth Menon87434102011-01-07 09:41:13 -0600523 /* TODO: DSP 800MHz needs SR and ABB */
524 if (r) {
525 pr_err("%s: failed to enable higher opp %d\n",
526 __func__, r);
527 /*
528 * Cleanup - disable the higher freqs - we dont care
529 * about the results
530 */
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500531 dev_pm_opp_disable(mpu_dev, 800000000);
532 dev_pm_opp_disable(iva_dev, 660000000);
Nishanth Menon87434102011-01-07 09:41:13 -0600533 }
534 }
Kevin Hilman65bf7ca2012-10-22 11:08:27 -0700535 return 0;
Nishanth Menon87434102011-01-07 09:41:13 -0600536}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -0800537omap_device_initcall(beagle_opp_init);
Nishanth Menon87434102011-01-07 09:41:13 -0600538
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300539static void __init omap3_beagle_init(void)
540{
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800541 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
Robert Nelson954bed02010-09-23 18:22:47 -0700542 omap3_beagle_init_rev();
Tony Lindgrend1589f02012-02-20 09:43:30 -0800543
Russ Dillaef2b892012-05-09 15:15:03 -0700544 if (gpio_is_valid(beagle_config.mmc1_gpio_wp))
Tony Lindgrend1589f02012-02-20 09:43:30 -0800545 omap_mux_init_gpio(beagle_config.mmc1_gpio_wp, OMAP_PIN_INPUT);
Russ Dill1afb82e2012-05-09 14:19:15 -0700546 mmc[0].caps = beagle_config.mmc_caps;
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800547 omap_hsmmc_init(mmc);
Tony Lindgrend1589f02012-02-20 09:43:30 -0800548
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800549 omap3_beagle_i2c_init();
Joel A Fernandes5fe8b4c2011-07-05 03:38:22 -0700550
551 gpio_buttons[0].gpio = beagle_config.usr_button_gpio;
552
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300553 platform_add_devices(omap3_beagle_devices,
554 ARRAY_SIZE(omap3_beagle_devices));
Russ Dillaef2b892012-05-09 15:15:03 -0700555 if (gpio_is_valid(beagle_config.dvi_pd_gpio))
556 omap_mux_init_gpio(beagle_config.dvi_pd_gpio, OMAP_PIN_OUTPUT);
Senthilvadivu Guruswamyd5e13222011-02-22 11:24:50 +0200557 omap_display_init(&beagle_dss_data);
Tomi Valkeinen53025562013-05-17 14:00:19 +0300558
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300559 omap_serial_init();
Tony Lindgrena4ca9db2011-08-22 23:57:23 -0700560 omap_sdrc_init(mt46h32m32lf6_sdrc_params,
561 mt46h32m32lf6_sdrc_params);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800562
Kishon Vijay Abraham I51482be2013-02-06 18:58:50 +0530563 usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
Mike Rapoport9e186302011-04-27 11:56:12 +0300564 usb_musb_init(NULL);
Roger Quadros60226712013-03-20 17:44:43 +0200565
Keshava Munegowda9e64bb12011-03-01 20:08:19 +0530566 usbhs_init(&usbhs_bdata);
Roger Quadros60226712013-03-20 17:44:43 +0200567
Afzal Mohammed2e618262012-02-29 18:11:56 +0530568 board_nand_init(omap3beagle_nand_partitions,
569 ARRAY_SIZE(omap3beagle_nand_partitions), NAND_CS,
570 NAND_BUSWIDTH_16, NULL);
Peter Ujfalusi40234bf2012-12-05 14:45:23 +0100571 omap_twl4030_audio_init("omap3beagle", NULL);
Jean Pihet9fb97412009-07-24 19:43:25 -0600572
Alexander Hollere2a346a2011-04-05 15:40:08 +0200573 /* Ensure msecure is mux'd to be able to set the RTC. */
574 omap_mux_init_signal("sys_drm_msecure", OMAP_PIN_OFF_OUTPUT_HIGH);
575
Jean Pihet9fb97412009-07-24 19:43:25 -0600576 /* Ensure SDRC pins are mux'd for self-refresh */
Tony Lindgren4896e392009-12-11 16:16:32 -0800577 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
578 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
Peter Ujfalusib8e21302012-11-07 15:25:30 +0100579
580 pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300581}
582
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300583MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
584 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400585 .atag_offset = 0x100,
Russell King71ee7da2010-05-23 10:18:16 +0100586 .reserve = omap_reserve,
Russell King - ARM Linux3dc3bad2011-02-14 15:40:20 -0800587 .map_io = omap3_map_io,
Tony Lindgren7b250af2011-10-04 18:26:28 -0700588 .init_early = omap3_init_early,
Tony Lindgrenbe732462011-09-26 15:25:22 -0700589 .init_irq = omap3_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100590 .handle_irq = omap3_intc_handle_irq,
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300591 .init_machine = omap3_beagle_init,
Shawn Guobbd707a2012-04-26 16:06:50 +0800592 .init_late = omap3_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700593 .init_time = omap3_secure_sync32k_timer_init,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600594 .restart = omap3xxx_restart,
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300595MACHINE_END