]>
Commit | Line | Data |
---|---|---|
57a58a2e CC |
1 | /* |
2 | * Texas Instruments TNETV107X EVM Board Support | |
3 | * | |
4 | * Copyright (C) 2010 Texas Instruments | |
5 | * | |
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. | |
9 | * | |
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. | |
14 | */ | |
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 <asm/mach/arch.h> | |
27 | #include <asm/mach-types.h> | |
28 | ||
29 | #include <mach/irqs.h> | |
30 | #include <mach/edma.h> | |
31 | #include <mach/mux.h> | |
32 | #include <mach/cp_intc.h> | |
33 | #include <mach/tnetv107x.h> | |
34 | ||
35 | #define EVM_MMC_WP_GPIO 21 | |
36 | #define EVM_MMC_CD_GPIO 24 | |
37 | ||
38 | static int initialize_gpio(int gpio, char *desc) | |
39 | { | |
40 | int ret; | |
41 | ||
42 | ret = gpio_request(gpio, desc); | |
43 | if (ret < 0) { | |
44 | pr_err_ratelimited("cannot open %s gpio\n", desc); | |
45 | return -ENOSYS; | |
46 | } | |
47 | gpio_direction_input(gpio); | |
48 | return gpio; | |
49 | } | |
50 | ||
51 | static int mmc_get_cd(int index) | |
52 | { | |
53 | static int gpio; | |
54 | ||
55 | if (!gpio) | |
56 | gpio = initialize_gpio(EVM_MMC_CD_GPIO, "mmc card detect"); | |
57 | ||
58 | if (gpio < 0) | |
59 | return gpio; | |
60 | ||
61 | return gpio_get_value(gpio) ? 0 : 1; | |
62 | } | |
63 | ||
64 | static int mmc_get_ro(int index) | |
65 | { | |
66 | static int gpio; | |
67 | ||
68 | if (!gpio) | |
69 | gpio = initialize_gpio(EVM_MMC_WP_GPIO, "mmc write protect"); | |
70 | ||
71 | if (gpio < 0) | |
72 | return gpio; | |
73 | ||
74 | return gpio_get_value(gpio) ? 1 : 0; | |
75 | } | |
76 | ||
77 | static struct davinci_mmc_config mmc_config = { | |
78 | .get_cd = mmc_get_cd, | |
79 | .get_ro = mmc_get_ro, | |
80 | .wires = 4, | |
81 | .max_freq = 50000000, | |
82 | .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, | |
83 | .version = MMC_CTLR_VERSION_1, | |
84 | }; | |
85 | ||
86 | static const short sdio1_pins[] __initdata = { | |
87 | TNETV107X_SDIO1_CLK_1, TNETV107X_SDIO1_CMD_1, | |
88 | TNETV107X_SDIO1_DATA0_1, TNETV107X_SDIO1_DATA1_1, | |
89 | TNETV107X_SDIO1_DATA2_1, TNETV107X_SDIO1_DATA3_1, | |
90 | TNETV107X_GPIO21, TNETV107X_GPIO24, | |
91 | -1 | |
92 | }; | |
93 | ||
94 | static const short uart1_pins[] __initdata = { | |
95 | TNETV107X_UART1_RD, TNETV107X_UART1_TD, | |
96 | -1 | |
97 | }; | |
98 | ||
99 | static struct mtd_partition nand_partitions[] = { | |
100 | /* bootloader (U-Boot, etc) in first 12 sectors */ | |
101 | { | |
102 | .name = "bootloader", | |
103 | .offset = 0, | |
104 | .size = (12*SZ_128K), | |
105 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
106 | }, | |
107 | /* bootloader params in the next sector */ | |
108 | { | |
109 | .name = "params", | |
110 | .offset = MTDPART_OFS_NXTBLK, | |
111 | .size = SZ_128K, | |
112 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
113 | }, | |
114 | /* kernel */ | |
115 | { | |
116 | .name = "kernel", | |
117 | .offset = MTDPART_OFS_NXTBLK, | |
118 | .size = SZ_4M, | |
119 | .mask_flags = 0, | |
120 | }, | |
121 | /* file system */ | |
122 | { | |
123 | .name = "filesystem", | |
124 | .offset = MTDPART_OFS_NXTBLK, | |
125 | .size = MTDPART_SIZ_FULL, | |
126 | .mask_flags = 0, | |
127 | } | |
128 | }; | |
129 | ||
130 | static struct davinci_nand_pdata nand_config = { | |
131 | .mask_cle = 0x4000, | |
132 | .mask_ale = 0x2000, | |
133 | .parts = nand_partitions, | |
134 | .nr_parts = ARRAY_SIZE(nand_partitions), | |
135 | .ecc_mode = NAND_ECC_HW, | |
136 | .options = NAND_USE_FLASH_BBT, | |
137 | .ecc_bits = 1, | |
138 | }; | |
139 | ||
140 | static struct davinci_uart_config serial_config __initconst = { | |
141 | .enabled_uarts = BIT(1), | |
142 | }; | |
143 | ||
144 | static struct tnetv107x_device_info evm_device_info __initconst = { | |
145 | .serial_config = &serial_config, | |
146 | .mmc_config[1] = &mmc_config, /* controller 1 */ | |
147 | .nand_config[0] = &nand_config, /* chip select 0 */ | |
148 | }; | |
149 | ||
150 | static __init void tnetv107x_evm_board_init(void) | |
151 | { | |
152 | davinci_cfg_reg_list(sdio1_pins); | |
153 | davinci_cfg_reg_list(uart1_pins); | |
154 | ||
155 | tnetv107x_devices_init(&evm_device_info); | |
156 | } | |
157 | ||
158 | #ifdef CONFIG_SERIAL_8250_CONSOLE | |
159 | static int __init tnetv107x_evm_console_init(void) | |
160 | { | |
161 | return add_preferred_console("ttyS", 0, "115200"); | |
162 | } | |
163 | console_initcall(tnetv107x_evm_console_init); | |
164 | #endif | |
165 | ||
166 | MACHINE_START(TNETV107X, "TNETV107X EVM") | |
167 | .phys_io = TNETV107X_IO_BASE, | |
168 | .io_pg_offst = (TNETV107X_IO_VIRT >> 18) & 0xfffc, | |
169 | .boot_params = (TNETV107X_DDR_BASE + 0x100), | |
170 | .map_io = tnetv107x_init, | |
171 | .init_irq = cp_intc_init, | |
172 | .timer = &davinci_timer, | |
173 | .init_machine = tnetv107x_evm_board_init, | |
174 | MACHINE_END |