davinci: Kconfig: update default defconfig
[deliverable/linux.git] / arch / arm / mach-davinci / board-dm646x-evm.c
CommitLineData
e38d92fd
KH
1/*
2 * TI DaVinci DM646X EVM board
3 *
4 * Derived from: arch/arm/mach-davinci/board-evm.c
5 * Copyright (C) 2006 Texas Instruments.
6 *
7 * (C) 2007-2008, MontaVista Software, Inc.
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 *
13 */
14
15/**************************************************************************
16 * Included Files
17 **************************************************************************/
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/fs.h>
23#include <linux/major.h>
24#include <linux/root_dev.h>
25#include <linux/dma-mapping.h>
26#include <linux/serial.h>
27#include <linux/serial_8250.h>
28#include <linux/leds.h>
29#include <linux/gpio.h>
30#include <linux/io.h>
31#include <linux/platform_device.h>
32#include <linux/i2c.h>
33#include <linux/i2c/at24.h>
34#include <linux/i2c/pcf857x.h>
35#include <linux/etherdevice.h>
36
37#include <asm/setup.h>
38#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
41#include <asm/mach/flash.h>
42
43#include <mach/dm646x.h>
44#include <mach/common.h>
45#include <mach/psc.h>
46#include <mach/serial.h>
47#include <mach/i2c.h>
ac7b75b5
KH
48#include <mach/mmc.h>
49#include <mach/emac.h>
50
51#define DM646X_EVM_PHY_MASK (0x2)
52#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
53
e38d92fd
KH
54static struct davinci_uart_config uart_config __initdata = {
55 .enabled_uarts = (1 << 0),
56};
57
58/* LEDS */
59
60static struct gpio_led evm_leds[] = {
61 { .name = "DS1", .active_low = 1, },
62 { .name = "DS2", .active_low = 1, },
63 { .name = "DS3", .active_low = 1, },
64 { .name = "DS4", .active_low = 1, },
65};
66
67static __initconst struct gpio_led_platform_data evm_led_data = {
68 .num_leds = ARRAY_SIZE(evm_leds),
69 .leds = evm_leds,
70};
71
72static struct platform_device *evm_led_dev;
73
74static int evm_led_setup(struct i2c_client *client, int gpio,
75 unsigned int ngpio, void *c)
76{
77 struct gpio_led *leds = evm_leds;
78 int status;
79
80 while (ngpio--) {
81 leds->gpio = gpio++;
82 leds++;
83 };
84
85 evm_led_dev = platform_device_alloc("leds-gpio", 0);
86 platform_device_add_data(evm_led_dev, &evm_led_data,
87 sizeof(evm_led_data));
88
89 evm_led_dev->dev.parent = &client->dev;
90 status = platform_device_add(evm_led_dev);
91 if (status < 0) {
92 platform_device_put(evm_led_dev);
93 evm_led_dev = NULL;
94 }
95 return status;
96}
97
98static int evm_led_teardown(struct i2c_client *client, int gpio,
99 unsigned ngpio, void *c)
100{
101 if (evm_led_dev) {
102 platform_device_unregister(evm_led_dev);
103 evm_led_dev = NULL;
104 }
105 return 0;
106}
107
108static int evm_sw_gpio[4] = { -EINVAL, -EINVAL, -EINVAL, -EINVAL };
109
110static int evm_sw_setup(struct i2c_client *client, int gpio,
111 unsigned ngpio, void *c)
112{
113 int status;
114 int i;
115 char label[10];
116
117 for (i = 0; i < 4; ++i) {
118 snprintf(label, 10, "user_sw%d", i);
119 status = gpio_request(gpio, label);
120 if (status)
121 goto out_free;
122 evm_sw_gpio[i] = gpio++;
123
124 status = gpio_direction_input(evm_sw_gpio[i]);
125 if (status) {
126 gpio_free(evm_sw_gpio[i]);
127 evm_sw_gpio[i] = -EINVAL;
128 goto out_free;
129 }
130
131 status = gpio_export(evm_sw_gpio[i], 0);
132 if (status) {
133 gpio_free(evm_sw_gpio[i]);
134 evm_sw_gpio[i] = -EINVAL;
135 goto out_free;
136 }
137 }
138 return status;
139out_free:
140 for (i = 0; i < 4; ++i) {
141 if (evm_sw_gpio[i] != -EINVAL) {
142 gpio_free(evm_sw_gpio[i]);
143 evm_sw_gpio[i] = -EINVAL;
144 }
145 }
146 return status;
147}
148
149static int evm_sw_teardown(struct i2c_client *client, int gpio,
150 unsigned ngpio, void *c)
151{
152 int i;
153
154 for (i = 0; i < 4; ++i) {
155 if (evm_sw_gpio[i] != -EINVAL) {
156 gpio_unexport(evm_sw_gpio[i]);
157 gpio_free(evm_sw_gpio[i]);
158 evm_sw_gpio[i] = -EINVAL;
159 }
160 }
161 return 0;
162}
163
164static int evm_pcf_setup(struct i2c_client *client, int gpio,
165 unsigned int ngpio, void *c)
166{
167 int status;
168
169 if (ngpio < 8)
170 return -EINVAL;
171
172 status = evm_sw_setup(client, gpio, 4, c);
173 if (status)
174 return status;
175
176 return evm_led_setup(client, gpio+4, 4, c);
177}
178
179static int evm_pcf_teardown(struct i2c_client *client, int gpio,
180 unsigned int ngpio, void *c)
181{
182 BUG_ON(ngpio < 8);
183
184 evm_sw_teardown(client, gpio, 4, c);
185 evm_led_teardown(client, gpio+4, 4, c);
186
187 return 0;
188}
189
190static struct pcf857x_platform_data pcf_data = {
191 .gpio_base = DAVINCI_N_GPIO+1,
192 .setup = evm_pcf_setup,
193 .teardown = evm_pcf_teardown,
194};
195
196/* Most of this EEPROM is unused, but U-Boot uses some data:
197 * - 0x7f00, 6 bytes Ethernet Address
198 * - ... newer boards may have more
199 */
e38d92fd
KH
200
201static struct at24_platform_data eeprom_info = {
202 .byte_len = (256*1024) / 8,
203 .page_size = 64,
204 .flags = AT24_FLAG_ADDR16,
b14dc0f9
MG
205 .setup = davinci_get_mac_addr,
206 .context = (void *)0x7f00,
e38d92fd
KH
207};
208
25acf553
C
209static u8 dm646x_iis_serializer_direction[] = {
210 TX_MODE, RX_MODE, INACTIVE_MODE, INACTIVE_MODE,
211};
212
213static u8 dm646x_dit_serializer_direction[] = {
214 TX_MODE,
215};
216
217static struct snd_platform_data dm646x_evm_snd_data[] = {
218 {
219 .clk_name = "mcasp0",
220 .tx_dma_offset = 0x400,
221 .rx_dma_offset = 0x400,
222 .op_mode = DAVINCI_MCASP_IIS_MODE,
223 .num_serializer = ARRAY_SIZE(dm646x_iis_serializer_direction),
224 .tdm_slots = 2,
225 .serial_dir = dm646x_iis_serializer_direction,
226 .eventq_no = EVENTQ_0,
227 },
228 {
229 .clk_name = "mcasp1",
230 .tx_dma_offset = 0x400,
231 .rx_dma_offset = 0,
232 .op_mode = DAVINCI_MCASP_DIT_MODE,
233 .num_serializer = ARRAY_SIZE(dm646x_dit_serializer_direction),
234 .tdm_slots = 32,
235 .serial_dir = dm646x_dit_serializer_direction,
236 .eventq_no = EVENTQ_0,
237 },
238};
239
e38d92fd
KH
240static struct i2c_board_info __initdata i2c_info[] = {
241 {
242 I2C_BOARD_INFO("24c256", 0x50),
243 .platform_data = &eeprom_info,
244 },
245 {
246 I2C_BOARD_INFO("pcf8574a", 0x38),
247 .platform_data = &pcf_data,
248 },
249};
250
251static struct davinci_i2c_platform_data i2c_pdata = {
252 .bus_freq = 100 /* kHz */,
253 .bus_delay = 0 /* usec */,
254};
255
256static void __init evm_init_i2c(void)
257{
258 davinci_init_i2c(&i2c_pdata);
259 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
260}
261
262static void __init davinci_map_io(void)
263{
e38d92fd
KH
264 dm646x_init();
265}
266
267static __init void evm_init(void)
268{
972412b6
MG
269 struct davinci_soc_info *soc_info = &davinci_soc_info;
270
e38d92fd
KH
271 evm_init_i2c();
272 davinci_serial_init(&uart_config);
25acf553
C
273 dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
274 dm646x_init_mcasp1(&dm646x_evm_snd_data[1]);
972412b6
MG
275
276 soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK;
277 soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY;
e38d92fd
KH
278}
279
280static __init void davinci_dm646x_evm_irq_init(void)
281{
282 davinci_irq_init();
283}
284
285MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
286 .phys_io = IO_PHYS,
287 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
288 .boot_params = (0x80000100),
289 .map_io = davinci_map_io,
290 .init_irq = davinci_dm646x_evm_irq_init,
291 .timer = &davinci_timer,
292 .init_machine = evm_init,
293MACHINE_END
294
This page took 0.05171 seconds and 5 git commands to generate.