2 * Texas Instruments TNETV107X EVM Board Support
4 * Copyright (C) 2010 Texas Instruments
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/console.h>
18 #include <linux/dma-mapping.h>
19 #include <linux/interrupt.h>
20 #include <linux/gpio.h>
21 #include <linux/delay.h>
22 #include <linux/platform_device.h>
23 #include <linux/ratelimit.h>
24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/partitions.h>
26 #include <linux/input.h>
27 #include <linux/input/matrix_keypad.h>
28 #include <linux/spi/spi.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach-types.h>
33 #include <mach/irqs.h>
34 #include <mach/edma.h>
36 #include <mach/cp_intc.h>
37 #include <mach/tnetv107x.h>
39 #define EVM_MMC_WP_GPIO 21
40 #define EVM_MMC_CD_GPIO 24
41 #define EVM_SPI_CS_GPIO 54
43 static int initialize_gpio(int gpio
, char *desc
)
47 ret
= gpio_request(gpio
, desc
);
49 pr_err_ratelimited("cannot open %s gpio\n", desc
);
52 gpio_direction_input(gpio
);
56 static int mmc_get_cd(int index
)
61 gpio
= initialize_gpio(EVM_MMC_CD_GPIO
, "mmc card detect");
66 return gpio_get_value(gpio
) ? 0 : 1;
69 static int mmc_get_ro(int index
)
74 gpio
= initialize_gpio(EVM_MMC_WP_GPIO
, "mmc write protect");
79 return gpio_get_value(gpio
) ? 1 : 0;
82 static struct davinci_mmc_config mmc_config
= {
87 .caps
= MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
,
90 static const short sdio1_pins
[] __initconst
= {
91 TNETV107X_SDIO1_CLK_1
, TNETV107X_SDIO1_CMD_1
,
92 TNETV107X_SDIO1_DATA0_1
, TNETV107X_SDIO1_DATA1_1
,
93 TNETV107X_SDIO1_DATA2_1
, TNETV107X_SDIO1_DATA3_1
,
94 TNETV107X_GPIO21
, TNETV107X_GPIO24
,
98 static const short uart1_pins
[] __initconst
= {
99 TNETV107X_UART1_RD
, TNETV107X_UART1_TD
,
103 static const short ssp_pins
[] __initconst
= {
104 TNETV107X_SSP0_0
, TNETV107X_SSP0_1
, TNETV107X_SSP0_2
,
105 TNETV107X_SSP1_0
, TNETV107X_SSP1_1
, TNETV107X_SSP1_2
,
109 static struct mtd_partition nand_partitions
[] = {
110 /* bootloader (U-Boot, etc) in first 12 sectors */
112 .name
= "bootloader",
114 .size
= (12*SZ_128K
),
115 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
117 /* bootloader params in the next sector */
120 .offset
= MTDPART_OFS_NXTBLK
,
122 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
127 .offset
= MTDPART_OFS_NXTBLK
,
133 .name
= "filesystem",
134 .offset
= MTDPART_OFS_NXTBLK
,
135 .size
= MTDPART_SIZ_FULL
,
140 static struct davinci_nand_pdata nand_config
= {
143 .parts
= nand_partitions
,
144 .nr_parts
= ARRAY_SIZE(nand_partitions
),
145 .ecc_mode
= NAND_ECC_HW
,
146 .bbt_options
= NAND_BBT_USE_FLASH
,
150 static struct davinci_uart_config serial_config __initconst
= {
151 .enabled_uarts
= BIT(1),
154 static const uint32_t keymap
[] = {
155 KEY(0, 0, KEY_NUMERIC_1
),
156 KEY(0, 1, KEY_NUMERIC_2
),
157 KEY(0, 2, KEY_NUMERIC_3
),
158 KEY(0, 3, KEY_FN_F1
),
161 KEY(1, 0, KEY_NUMERIC_4
),
162 KEY(1, 1, KEY_NUMERIC_5
),
163 KEY(1, 2, KEY_NUMERIC_6
),
165 KEY(1, 4, KEY_FN_F2
),
167 KEY(2, 0, KEY_NUMERIC_7
),
168 KEY(2, 1, KEY_NUMERIC_8
),
169 KEY(2, 2, KEY_NUMERIC_9
),
171 KEY(2, 4, KEY_ENTER
),
173 KEY(3, 0, KEY_NUMERIC_STAR
),
174 KEY(3, 1, KEY_NUMERIC_0
),
175 KEY(3, 2, KEY_NUMERIC_POUND
),
177 KEY(3, 4, KEY_RIGHT
),
179 KEY(4, 0, KEY_FN_F3
),
180 KEY(4, 1, KEY_FN_F4
),
185 KEY(5, 0, KEY_VOLUMEDOWN
),
186 KEY(5, 1, KEY_VOLUMEUP
),
192 static const struct matrix_keymap_data keymap_data
= {
194 .keymap_size
= ARRAY_SIZE(keymap
),
197 static struct matrix_keypad_platform_data keypad_config
= {
198 .keymap_data
= &keymap_data
,
201 .debounce_ms
= 0, /* minimum */
202 .active_low
= 0, /* pull up realization */
206 static void spi_select_device(int cs
)
212 ret
= gpio_request(EVM_SPI_CS_GPIO
, "spi chipsel");
214 pr_err("cannot open spi chipsel gpio\n");
218 gpio
= EVM_SPI_CS_GPIO
;
219 gpio_direction_output(gpio
, 0);
226 return gpio_set_value(gpio
, cs
? 1 : 0);
229 static struct ti_ssp_spi_data spi_master_data
= {
231 .select
= spi_select_device
,
232 .iosel
= SSP_PIN_SEL(0, SSP_CLOCK
) | SSP_PIN_SEL(1, SSP_DATA
) |
233 SSP_PIN_SEL(2, SSP_CHIPSEL
) | SSP_PIN_SEL(3, SSP_IN
) |
237 static struct ti_ssp_data ssp_config
= {
238 .out_clock
= 250 * 1000,
241 .dev_name
= "ti-ssp-spi",
242 .pdata
= &spi_master_data
,
243 .pdata_size
= sizeof(spi_master_data
),
248 static struct tnetv107x_device_info evm_device_info __initconst
= {
249 .serial_config
= &serial_config
,
250 .mmc_config
[1] = &mmc_config
, /* controller 1 */
251 .nand_config
[0] = &nand_config
, /* chip select 0 */
252 .keypad_config
= &keypad_config
,
253 .ssp_config
= &ssp_config
,
256 static struct spi_board_info spi_info
[] __initconst
= {
259 static __init
void tnetv107x_evm_board_init(void)
261 davinci_cfg_reg_list(sdio1_pins
);
262 davinci_cfg_reg_list(uart1_pins
);
263 davinci_cfg_reg_list(ssp_pins
);
265 tnetv107x_devices_init(&evm_device_info
);
267 spi_register_board_info(spi_info
, ARRAY_SIZE(spi_info
));
270 #ifdef CONFIG_SERIAL_8250_CONSOLE
271 static int __init
tnetv107x_evm_console_init(void)
273 return add_preferred_console("ttyS", 0, "115200");
275 console_initcall(tnetv107x_evm_console_init
);
278 MACHINE_START(TNETV107X
, "TNETV107X EVM")
279 .atag_offset
= 0x100,
280 .map_io
= tnetv107x_init
,
281 .init_irq
= cp_intc_init
,
282 .init_time
= davinci_timer_init
,
283 .init_machine
= tnetv107x_evm_board_init
,
284 .init_late
= davinci_init_late
,
285 .dma_zone_size
= SZ_128M
,
286 .restart
= tnetv107x_restart
,