blob: da57b0fcda14c5c2ca0ac92e1da076f7176763ee [file] [log] [blame]
Nishant Kamat49265652008-10-10 11:28:23 +03001/*
2 * linux/arch/arm/mach-omap2/board-ldp.c
3 *
4 * Copyright (C) 2008 Texas Instruments Inc.
5 * Nishant Kamat <nskamat@ti.com>
6 *
7 * Modified from mach-omap2/board-3430sdp.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/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/delay.h>
18#include <linux/input.h>
19#include <linux/workqueue.h>
20#include <linux/err.h>
21#include <linux/clk.h>
22#include <linux/spi/spi.h>
23#include <linux/spi/ads7846.h>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080024#include <linux/i2c/twl4030.h>
Russell King99730222009-03-25 10:21:35 +000025#include <linux/io.h>
Steve Glendinning1c0e1472009-01-23 17:09:13 +000026#include <linux/smsc911x.h>
Nishant Kamat49265652008-10-10 11:28:23 +030027
28#include <mach/hardware.h>
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
Nishant Kamat49265652008-10-10 11:28:23 +030033#include <mach/mcspi.h>
34#include <mach/gpio.h>
35#include <mach/board.h>
36#include <mach/common.h>
37#include <mach/gpmc.h>
38
Nishant Kamat49265652008-10-10 11:28:23 +030039#include <asm/delay.h>
40#include <mach/control.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070041#include <mach/usb.h>
Nishant Kamat49265652008-10-10 11:28:23 +030042
Tony Lindgren90c62bf2008-12-10 17:37:17 -080043#include "mmc-twl4030.h"
44
Steve Glendinning1c0e1472009-01-23 17:09:13 +000045#define LDP_SMSC911X_CS 1
46#define LDP_SMSC911X_GPIO 152
Tony Lindgrenec7558a2009-03-23 18:07:37 -070047#define DEBUG_BASE 0x08000000
48#define LDP_ETHR_START DEBUG_BASE
Stanley.Miaob1c056d2008-12-10 17:36:53 -080049
Steve Glendinning1c0e1472009-01-23 17:09:13 +000050static struct resource ldp_smsc911x_resources[] = {
Stanley.Miaob1c056d2008-12-10 17:36:53 -080051 [0] = {
Tony Lindgrenec7558a2009-03-23 18:07:37 -070052 .start = LDP_ETHR_START,
53 .end = LDP_ETHR_START + SZ_4K,
Stanley.Miaob1c056d2008-12-10 17:36:53 -080054 .flags = IORESOURCE_MEM,
55 },
56 [1] = {
57 .start = 0,
58 .end = 0,
59 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
60 },
61};
62
Steve Glendinning1c0e1472009-01-23 17:09:13 +000063static struct smsc911x_platform_config ldp_smsc911x_config = {
64 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
65 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
66 .flags = SMSC911X_USE_32BIT,
67 .phy_interface = PHY_INTERFACE_MODE_MII,
68};
69
70static struct platform_device ldp_smsc911x_device = {
71 .name = "smsc911x",
Stanley.Miaob1c056d2008-12-10 17:36:53 -080072 .id = -1,
Steve Glendinning1c0e1472009-01-23 17:09:13 +000073 .num_resources = ARRAY_SIZE(ldp_smsc911x_resources),
74 .resource = ldp_smsc911x_resources,
75 .dev = {
76 .platform_data = &ldp_smsc911x_config,
77 },
Stanley.Miaob1c056d2008-12-10 17:36:53 -080078};
79
80static struct platform_device *ldp_devices[] __initdata = {
Steve Glendinning1c0e1472009-01-23 17:09:13 +000081 &ldp_smsc911x_device,
Stanley.Miaob1c056d2008-12-10 17:36:53 -080082};
83
Steve Glendinning1c0e1472009-01-23 17:09:13 +000084static inline void __init ldp_init_smsc911x(void)
Stanley.Miaob1c056d2008-12-10 17:36:53 -080085{
86 int eth_cs;
87 unsigned long cs_mem_base;
88 int eth_gpio = 0;
89
Steve Glendinning1c0e1472009-01-23 17:09:13 +000090 eth_cs = LDP_SMSC911X_CS;
Stanley.Miaob1c056d2008-12-10 17:36:53 -080091
92 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
Steve Glendinning1c0e1472009-01-23 17:09:13 +000093 printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
Stanley.Miaob1c056d2008-12-10 17:36:53 -080094 return;
95 }
96
Steve Glendinning1c0e1472009-01-23 17:09:13 +000097 ldp_smsc911x_resources[0].start = cs_mem_base + 0x0;
98 ldp_smsc911x_resources[0].end = cs_mem_base + 0xff;
Stanley.Miaob1c056d2008-12-10 17:36:53 -080099 udelay(100);
100
Steve Glendinning1c0e1472009-01-23 17:09:13 +0000101 eth_gpio = LDP_SMSC911X_GPIO;
Stanley.Miaob1c056d2008-12-10 17:36:53 -0800102
Steve Glendinning1c0e1472009-01-23 17:09:13 +0000103 ldp_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
Stanley.Miaob1c056d2008-12-10 17:36:53 -0800104
Steve Glendinning1c0e1472009-01-23 17:09:13 +0000105 if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
106 printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
Stanley.Miaob1c056d2008-12-10 17:36:53 -0800107 eth_gpio);
108 return;
109 }
110 gpio_direction_input(eth_gpio);
111}
112
Nishant Kamat49265652008-10-10 11:28:23 +0300113static void __init omap_ldp_init_irq(void)
114{
Paul Walmsley87246b72009-01-28 12:27:39 -0700115 omap2_init_common_hw(NULL);
Nishant Kamat49265652008-10-10 11:28:23 +0300116 omap_init_irq();
117 omap_gpio_init();
Steve Glendinning1c0e1472009-01-23 17:09:13 +0000118 ldp_init_smsc911x();
Nishant Kamat49265652008-10-10 11:28:23 +0300119}
120
121static struct omap_uart_config ldp_uart_config __initdata = {
122 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
123};
124
125static struct omap_board_config_kernel ldp_config[] __initdata = {
126 { OMAP_TAG_UART, &ldp_uart_config },
127};
128
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800129static struct twl4030_gpio_platform_data ldp_gpio_data = {
130 .gpio_base = OMAP_MAX_GPIO_LINES,
131 .irq_base = TWL4030_GPIO_IRQ_BASE,
132 .irq_end = TWL4030_GPIO_IRQ_END,
133};
134
135static struct twl4030_platform_data ldp_twldata = {
136 .irq_base = TWL4030_IRQ_BASE,
137 .irq_end = TWL4030_IRQ_END,
138
139 /* platform_data for children goes here */
140 .gpio = &ldp_gpio_data,
141};
142
143static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
144 {
145 I2C_BOARD_INFO("twl4030", 0x48),
146 .flags = I2C_CLIENT_WAKE,
147 .irq = INT_34XX_SYS_NIRQ,
148 .platform_data = &ldp_twldata,
149 },
150};
151
Nishant Kamat49265652008-10-10 11:28:23 +0300152static int __init omap_i2c_init(void)
153{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800154 omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
155 ARRAY_SIZE(ldp_i2c_boardinfo));
Nishant Kamat49265652008-10-10 11:28:23 +0300156 omap_register_i2c_bus(2, 400, NULL, 0);
157 omap_register_i2c_bus(3, 400, NULL, 0);
158 return 0;
159}
160
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800161static struct twl4030_hsmmc_info mmc[] __initdata = {
162 {
163 .mmc = 1,
164 .wires = 4,
165 .gpio_cd = -EINVAL,
166 .gpio_wp = -EINVAL,
167 },
168 {} /* Terminator */
169};
170
Nishant Kamat49265652008-10-10 11:28:23 +0300171static void __init omap_ldp_init(void)
172{
173 omap_i2c_init();
Stanley.Miaob1c056d2008-12-10 17:36:53 -0800174 platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
Nishant Kamat49265652008-10-10 11:28:23 +0300175 omap_board_config = ldp_config;
176 omap_board_config_size = ARRAY_SIZE(ldp_config);
177 omap_serial_init();
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800178 twl4030_mmc_init(mmc);
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700179 usb_musb_init();
Nishant Kamat49265652008-10-10 11:28:23 +0300180}
181
182static void __init omap_ldp_map_io(void)
183{
184 omap2_set_globals_343x();
185 omap2_map_common_io();
186}
187
188MACHINE_START(OMAP_LDP, "OMAP LDP board")
189 .phys_io = 0x48000000,
190 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
191 .boot_params = 0x80000100,
192 .map_io = omap_ldp_map_io,
193 .init_irq = omap_ldp_init_irq,
194 .init_machine = omap_ldp_init,
195 .timer = &omap_timer,
196MACHINE_END