blob: f035d7836e554533ccd816099ea1e068daef0ab4 [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>
Nishant Kamat49265652008-10-10 11:28:23 +030025
26#include <mach/hardware.h>
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30
Nishant Kamat49265652008-10-10 11:28:23 +030031#include <mach/mcspi.h>
32#include <mach/gpio.h>
33#include <mach/board.h>
34#include <mach/common.h>
35#include <mach/gpmc.h>
36
37#include <asm/io.h>
38#include <asm/delay.h>
39#include <mach/control.h>
40
Tony Lindgren90c62bf2008-12-10 17:37:17 -080041#include "mmc-twl4030.h"
42
Tony Lindgrenec7558a2009-03-23 18:07:37 -070043#define LDP_SMC911X_CS 1
44#define LDP_SMC911X_GPIO 152
45#define DEBUG_BASE 0x08000000
46#define LDP_ETHR_START DEBUG_BASE
Stanley.Miaob1c056d2008-12-10 17:36:53 -080047
48static struct resource ldp_smc911x_resources[] = {
49 [0] = {
Tony Lindgrenec7558a2009-03-23 18:07:37 -070050 .start = LDP_ETHR_START,
51 .end = LDP_ETHR_START + SZ_4K,
Stanley.Miaob1c056d2008-12-10 17:36:53 -080052 .flags = IORESOURCE_MEM,
53 },
54 [1] = {
55 .start = 0,
56 .end = 0,
57 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
58 },
59};
60
61static struct platform_device ldp_smc911x_device = {
62 .name = "smc911x",
63 .id = -1,
64 .num_resources = ARRAY_SIZE(ldp_smc911x_resources),
65 .resource = ldp_smc911x_resources,
66};
67
68static struct platform_device *ldp_devices[] __initdata = {
69 &ldp_smc911x_device,
70};
71
72static inline void __init ldp_init_smc911x(void)
73{
74 int eth_cs;
75 unsigned long cs_mem_base;
76 int eth_gpio = 0;
77
78 eth_cs = LDP_SMC911X_CS;
79
80 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
81 printk(KERN_ERR "Failed to request GPMC mem for smc911x\n");
82 return;
83 }
84
85 ldp_smc911x_resources[0].start = cs_mem_base + 0x0;
Russell King07555c92009-03-02 22:29:37 -080086 ldp_smc911x_resources[0].end = cs_mem_base + 0xff;
Stanley.Miaob1c056d2008-12-10 17:36:53 -080087 udelay(100);
88
89 eth_gpio = LDP_SMC911X_GPIO;
90
91 ldp_smc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
92
Jarkko Nikula73069e32009-01-15 13:09:52 +020093 if (gpio_request(eth_gpio, "smc911x irq") < 0) {
Stanley.Miaob1c056d2008-12-10 17:36:53 -080094 printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
95 eth_gpio);
96 return;
97 }
98 gpio_direction_input(eth_gpio);
99}
100
Nishant Kamat49265652008-10-10 11:28:23 +0300101static void __init omap_ldp_init_irq(void)
102{
103 omap2_init_common_hw();
104 omap_init_irq();
105 omap_gpio_init();
Stanley.Miaob1c056d2008-12-10 17:36:53 -0800106 ldp_init_smc911x();
Nishant Kamat49265652008-10-10 11:28:23 +0300107}
108
109static struct omap_uart_config ldp_uart_config __initdata = {
110 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
111};
112
113static struct omap_board_config_kernel ldp_config[] __initdata = {
114 { OMAP_TAG_UART, &ldp_uart_config },
115};
116
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800117static struct twl4030_gpio_platform_data ldp_gpio_data = {
118 .gpio_base = OMAP_MAX_GPIO_LINES,
119 .irq_base = TWL4030_GPIO_IRQ_BASE,
120 .irq_end = TWL4030_GPIO_IRQ_END,
121};
122
123static struct twl4030_platform_data ldp_twldata = {
124 .irq_base = TWL4030_IRQ_BASE,
125 .irq_end = TWL4030_IRQ_END,
126
127 /* platform_data for children goes here */
128 .gpio = &ldp_gpio_data,
129};
130
131static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
132 {
133 I2C_BOARD_INFO("twl4030", 0x48),
134 .flags = I2C_CLIENT_WAKE,
135 .irq = INT_34XX_SYS_NIRQ,
136 .platform_data = &ldp_twldata,
137 },
138};
139
Nishant Kamat49265652008-10-10 11:28:23 +0300140static int __init omap_i2c_init(void)
141{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800142 omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
143 ARRAY_SIZE(ldp_i2c_boardinfo));
Nishant Kamat49265652008-10-10 11:28:23 +0300144 omap_register_i2c_bus(2, 400, NULL, 0);
145 omap_register_i2c_bus(3, 400, NULL, 0);
146 return 0;
147}
148
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800149static struct twl4030_hsmmc_info mmc[] __initdata = {
150 {
151 .mmc = 1,
152 .wires = 4,
153 .gpio_cd = -EINVAL,
154 .gpio_wp = -EINVAL,
155 },
156 {} /* Terminator */
157};
158
Nishant Kamat49265652008-10-10 11:28:23 +0300159static void __init omap_ldp_init(void)
160{
161 omap_i2c_init();
Stanley.Miaob1c056d2008-12-10 17:36:53 -0800162 platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
Nishant Kamat49265652008-10-10 11:28:23 +0300163 omap_board_config = ldp_config;
164 omap_board_config_size = ARRAY_SIZE(ldp_config);
165 omap_serial_init();
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800166 twl4030_mmc_init(mmc);
Nishant Kamat49265652008-10-10 11:28:23 +0300167}
168
169static void __init omap_ldp_map_io(void)
170{
171 omap2_set_globals_343x();
172 omap2_map_common_io();
173}
174
175MACHINE_START(OMAP_LDP, "OMAP LDP board")
176 .phys_io = 0x48000000,
177 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
178 .boot_params = 0x80000100,
179 .map_io = omap_ldp_map_io,
180 .init_irq = omap_ldp_init_irq,
181 .init_machine = omap_ldp_init,
182 .timer = &omap_timer,
183MACHINE_END