2 * TI DaVinci DM646X EVM board
4 * Derived from: arch/arm/mach-davinci/board-evm.c
5 * Copyright (C) 2006 Texas Instruments.
7 * (C) 2007-2008, MontaVista Software, Inc.
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.
15 /**************************************************************************
17 **************************************************************************/
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/init.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>
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>
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>
43 #include <mach/dm646x.h>
44 #include <mach/common.h>
46 #include <mach/serial.h>
49 #include <mach/emac.h>
51 #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
52 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
58 /* CPLD Register 0 bits to control ATA */
59 #define DM646X_EVM_ATA_RST BIT(0)
60 #define DM646X_EVM_ATA_PWD BIT(1)
62 #define DM646X_EVM_PHY_MASK (0x2)
63 #define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
65 static struct davinci_uart_config uart_config __initdata
= {
66 .enabled_uarts
= (1 << 0),
69 /* CPLD Register 0 Client: used for I/O Control */
70 static int cpld_reg0_probe(struct i2c_client
*client
,
71 const struct i2c_device_id
*id
)
75 struct i2c_msg msg
[2] = {
90 /* Clear ATA_RSTn and ATA_PWD bits to enable ATA operation. */
91 i2c_transfer(client
->adapter
, msg
, 1);
92 data
&= ~(DM646X_EVM_ATA_RST
| DM646X_EVM_ATA_PWD
);
93 i2c_transfer(client
->adapter
, msg
+ 1, 1);
99 static const struct i2c_device_id cpld_reg_ids
[] = {
104 static struct i2c_driver dm6467evm_cpld_driver
= {
105 .driver
.name
= "cpld_reg0",
106 .id_table
= cpld_reg_ids
,
107 .probe
= cpld_reg0_probe
,
112 static struct gpio_led evm_leds
[] = {
113 { .name
= "DS1", .active_low
= 1, },
114 { .name
= "DS2", .active_low
= 1, },
115 { .name
= "DS3", .active_low
= 1, },
116 { .name
= "DS4", .active_low
= 1, },
119 static __initconst
struct gpio_led_platform_data evm_led_data
= {
120 .num_leds
= ARRAY_SIZE(evm_leds
),
124 static struct platform_device
*evm_led_dev
;
126 static int evm_led_setup(struct i2c_client
*client
, int gpio
,
127 unsigned int ngpio
, void *c
)
129 struct gpio_led
*leds
= evm_leds
;
137 evm_led_dev
= platform_device_alloc("leds-gpio", 0);
138 platform_device_add_data(evm_led_dev
, &evm_led_data
,
139 sizeof(evm_led_data
));
141 evm_led_dev
->dev
.parent
= &client
->dev
;
142 status
= platform_device_add(evm_led_dev
);
144 platform_device_put(evm_led_dev
);
150 static int evm_led_teardown(struct i2c_client
*client
, int gpio
,
151 unsigned ngpio
, void *c
)
154 platform_device_unregister(evm_led_dev
);
160 static int evm_sw_gpio
[4] = { -EINVAL
, -EINVAL
, -EINVAL
, -EINVAL
};
162 static int evm_sw_setup(struct i2c_client
*client
, int gpio
,
163 unsigned ngpio
, void *c
)
169 for (i
= 0; i
< 4; ++i
) {
170 snprintf(label
, 10, "user_sw%d", i
);
171 status
= gpio_request(gpio
, label
);
174 evm_sw_gpio
[i
] = gpio
++;
176 status
= gpio_direction_input(evm_sw_gpio
[i
]);
178 gpio_free(evm_sw_gpio
[i
]);
179 evm_sw_gpio
[i
] = -EINVAL
;
183 status
= gpio_export(evm_sw_gpio
[i
], 0);
185 gpio_free(evm_sw_gpio
[i
]);
186 evm_sw_gpio
[i
] = -EINVAL
;
192 for (i
= 0; i
< 4; ++i
) {
193 if (evm_sw_gpio
[i
] != -EINVAL
) {
194 gpio_free(evm_sw_gpio
[i
]);
195 evm_sw_gpio
[i
] = -EINVAL
;
201 static int evm_sw_teardown(struct i2c_client
*client
, int gpio
,
202 unsigned ngpio
, void *c
)
206 for (i
= 0; i
< 4; ++i
) {
207 if (evm_sw_gpio
[i
] != -EINVAL
) {
208 gpio_unexport(evm_sw_gpio
[i
]);
209 gpio_free(evm_sw_gpio
[i
]);
210 evm_sw_gpio
[i
] = -EINVAL
;
216 static int evm_pcf_setup(struct i2c_client
*client
, int gpio
,
217 unsigned int ngpio
, void *c
)
224 status
= evm_sw_setup(client
, gpio
, 4, c
);
228 return evm_led_setup(client
, gpio
+4, 4, c
);
231 static int evm_pcf_teardown(struct i2c_client
*client
, int gpio
,
232 unsigned int ngpio
, void *c
)
236 evm_sw_teardown(client
, gpio
, 4, c
);
237 evm_led_teardown(client
, gpio
+4, 4, c
);
242 static struct pcf857x_platform_data pcf_data
= {
243 .gpio_base
= DAVINCI_N_GPIO
+1,
244 .setup
= evm_pcf_setup
,
245 .teardown
= evm_pcf_teardown
,
248 /* Most of this EEPROM is unused, but U-Boot uses some data:
249 * - 0x7f00, 6 bytes Ethernet Address
250 * - ... newer boards may have more
253 static struct at24_platform_data eeprom_info
= {
254 .byte_len
= (256*1024) / 8,
256 .flags
= AT24_FLAG_ADDR16
,
257 .setup
= davinci_get_mac_addr
,
258 .context
= (void *)0x7f00,
261 static u8 dm646x_iis_serializer_direction
[] = {
262 TX_MODE
, RX_MODE
, INACTIVE_MODE
, INACTIVE_MODE
,
265 static u8 dm646x_dit_serializer_direction
[] = {
269 static struct snd_platform_data dm646x_evm_snd_data
[] = {
271 .clk_name
= "mcasp0",
272 .tx_dma_offset
= 0x400,
273 .rx_dma_offset
= 0x400,
274 .op_mode
= DAVINCI_MCASP_IIS_MODE
,
275 .num_serializer
= ARRAY_SIZE(dm646x_iis_serializer_direction
),
277 .serial_dir
= dm646x_iis_serializer_direction
,
278 .eventq_no
= EVENTQ_0
,
281 .clk_name
= "mcasp1",
282 .tx_dma_offset
= 0x400,
284 .op_mode
= DAVINCI_MCASP_DIT_MODE
,
285 .num_serializer
= ARRAY_SIZE(dm646x_dit_serializer_direction
),
287 .serial_dir
= dm646x_dit_serializer_direction
,
288 .eventq_no
= EVENTQ_0
,
292 static struct i2c_board_info __initdata i2c_info
[] = {
294 I2C_BOARD_INFO("24c256", 0x50),
295 .platform_data
= &eeprom_info
,
298 I2C_BOARD_INFO("pcf8574a", 0x38),
299 .platform_data
= &pcf_data
,
302 I2C_BOARD_INFO("cpld_reg0", 0x3a),
306 static struct davinci_i2c_platform_data i2c_pdata
= {
307 .bus_freq
= 100 /* kHz */,
308 .bus_delay
= 0 /* usec */,
311 static void __init
evm_init_i2c(void)
313 davinci_init_i2c(&i2c_pdata
);
314 i2c_add_driver(&dm6467evm_cpld_driver
);
315 i2c_register_board_info(1, i2c_info
, ARRAY_SIZE(i2c_info
));
318 static void __init
davinci_map_io(void)
323 static __init
void evm_init(void)
325 struct davinci_soc_info
*soc_info
= &davinci_soc_info
;
328 davinci_serial_init(&uart_config
);
329 dm646x_init_mcasp0(&dm646x_evm_snd_data
[0]);
330 dm646x_init_mcasp1(&dm646x_evm_snd_data
[1]);
335 soc_info
->emac_pdata
->phy_mask
= DM646X_EVM_PHY_MASK
;
336 soc_info
->emac_pdata
->mdio_max_freq
= DM646X_EVM_MDIO_FREQUENCY
;
339 static __init
void davinci_dm646x_evm_irq_init(void)
344 MACHINE_START(DAVINCI_DM6467_EVM
, "DaVinci DM646x EVM")
346 .io_pg_offst
= (__IO_ADDRESS(IO_PHYS
) >> 18) & 0xfffc,
347 .boot_params
= (0x80000100),
348 .map_io
= davinci_map_io
,
349 .init_irq
= davinci_dm646x_evm_irq_init
,
350 .timer
= &davinci_timer
,
351 .init_machine
= evm_init
,