Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * TI DA830/OMAP L137 EVM board |
| 3 | * |
| 4 | * Author: Mark A. Greer <mgreer@mvista.com> |
| 5 | * Derived from: arch/arm/mach-davinci/board-dm644x-evm.c |
| 6 | * |
| 7 | * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under |
| 8 | * the terms of the GNU General Public License version 2. This program |
| 9 | * is licensed "as is" without any warranty of any kind, whether express |
| 10 | * or implied. |
| 11 | */ |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/console.h> |
Steve Chen | 13e1f04 | 2009-09-15 18:15:06 -0700 | [diff] [blame^] | 16 | #include <linux/gpio.h> |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 17 | #include <linux/i2c.h> |
Steve Chen | 13e1f04 | 2009-09-15 18:15:06 -0700 | [diff] [blame^] | 18 | #include <linux/i2c/pcf857x.h> |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 19 | #include <linux/i2c/at24.h> |
| 20 | |
| 21 | #include <asm/mach-types.h> |
| 22 | #include <asm/mach/arch.h> |
| 23 | |
| 24 | #include <mach/common.h> |
| 25 | #include <mach/irqs.h> |
| 26 | #include <mach/cp_intc.h> |
Mark A. Greer | 32bf078 | 2009-08-28 15:05:21 -0700 | [diff] [blame] | 27 | #include <mach/mux.h> |
David A. Griego | 2eb30c8 | 2009-09-15 18:10:20 -0700 | [diff] [blame] | 28 | #include <mach/gpio.h> |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 29 | #include <mach/da8xx.h> |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 30 | #include <mach/asp.h> |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 31 | |
| 32 | #define DA830_EVM_PHY_MASK 0x0 |
| 33 | #define DA830_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */ |
| 34 | |
| 35 | static struct at24_platform_data da830_evm_i2c_eeprom_info = { |
| 36 | .byte_len = SZ_256K / 8, |
| 37 | .page_size = 64, |
| 38 | .flags = AT24_FLAG_ADDR16, |
| 39 | .setup = davinci_get_mac_addr, |
| 40 | .context = (void *)0x7f00, |
| 41 | }; |
| 42 | |
Steve Chen | 13e1f04 | 2009-09-15 18:15:06 -0700 | [diff] [blame^] | 43 | static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio, |
| 44 | unsigned ngpio, void *context) |
| 45 | { |
| 46 | gpio_request(gpio + 6, "MUX_MODE"); |
| 47 | #ifdef CONFIG_DA830_UI_LCD |
| 48 | gpio_direction_output(gpio + 6, 0); |
| 49 | #else /* Must be NAND or NOR */ |
| 50 | gpio_direction_output(gpio + 6, 1); |
| 51 | #endif |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio, |
| 56 | unsigned ngpio, void *context) |
| 57 | { |
| 58 | gpio_free(gpio + 6); |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | static struct pcf857x_platform_data da830_evm_ui_expander_info = { |
| 63 | .gpio_base = DAVINCI_N_GPIO, |
| 64 | .setup = da830_evm_ui_expander_setup, |
| 65 | .teardown = da830_evm_ui_expander_teardown, |
| 66 | }; |
| 67 | |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 68 | static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { |
| 69 | { |
| 70 | I2C_BOARD_INFO("24c256", 0x50), |
| 71 | .platform_data = &da830_evm_i2c_eeprom_info, |
| 72 | }, |
Chaithrika U S | 1a7ff8f | 2009-08-25 15:20:05 +0300 | [diff] [blame] | 73 | { |
| 74 | I2C_BOARD_INFO("tlv320aic3x", 0x18), |
Steve Chen | 13e1f04 | 2009-09-15 18:15:06 -0700 | [diff] [blame^] | 75 | }, |
| 76 | { |
| 77 | I2C_BOARD_INFO("pcf8574", 0x3f), |
| 78 | .platform_data = &da830_evm_ui_expander_info, |
| 79 | }, |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = { |
| 83 | .bus_freq = 100, /* kHz */ |
| 84 | .bus_delay = 0, /* usec */ |
| 85 | }; |
| 86 | |
| 87 | static struct davinci_uart_config da830_evm_uart_config __initdata = { |
| 88 | .enabled_uarts = 0x7, |
| 89 | }; |
| 90 | |
Mark A. Greer | 32bf078 | 2009-08-28 15:05:21 -0700 | [diff] [blame] | 91 | static const short da830_evm_mcasp1_pins[] = { |
| 92 | DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1, |
| 93 | DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5, |
| 94 | DA830_ACLKR1, DA830_AXR1_6, DA830_AXR1_7, DA830_AXR1_8, DA830_AXR1_10, |
| 95 | DA830_AXR1_11, |
| 96 | -1 |
| 97 | }; |
| 98 | |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 99 | static u8 da830_iis_serializer_direction[] = { |
| 100 | RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, |
| 101 | INACTIVE_MODE, TX_MODE, INACTIVE_MODE, INACTIVE_MODE, |
| 102 | INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, |
| 103 | }; |
| 104 | |
| 105 | static struct snd_platform_data da830_evm_snd_data = { |
| 106 | .tx_dma_offset = 0x2000, |
| 107 | .rx_dma_offset = 0x2000, |
| 108 | .op_mode = DAVINCI_MCASP_IIS_MODE, |
| 109 | .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction), |
| 110 | .tdm_slots = 2, |
| 111 | .serial_dir = da830_iis_serializer_direction, |
| 112 | .eventq_no = EVENTQ_0, |
| 113 | .version = MCASP_VERSION_2, |
| 114 | .txnumevt = 1, |
| 115 | .rxnumevt = 1, |
| 116 | }; |
| 117 | |
David A. Griego | 2eb30c8 | 2009-09-15 18:10:20 -0700 | [diff] [blame] | 118 | /* |
| 119 | * GPIO2[1] is used as MMC_SD_WP and GPIO2[2] as MMC_SD_INS. |
| 120 | */ |
| 121 | static const short da830_evm_mmc_sd_pins[] = { |
| 122 | DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2, |
| 123 | DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5, |
| 124 | DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK, |
| 125 | DA830_MMCSD_CMD, DA830_GPIO2_1, DA830_GPIO2_2, |
| 126 | -1 |
| 127 | }; |
| 128 | |
| 129 | #define DA830_MMCSD_WP_PIN GPIO_TO_PIN(2, 1) |
| 130 | |
| 131 | static int da830_evm_mmc_get_ro(int index) |
| 132 | { |
| 133 | return gpio_get_value(DA830_MMCSD_WP_PIN); |
| 134 | } |
| 135 | |
| 136 | static struct davinci_mmc_config da830_evm_mmc_config = { |
| 137 | .get_ro = da830_evm_mmc_get_ro, |
| 138 | .wires = 4, |
| 139 | .version = MMC_CTLR_VERSION_2, |
| 140 | }; |
| 141 | |
| 142 | static inline void da830_evm_init_mmc(void) |
| 143 | { |
| 144 | int ret; |
| 145 | |
| 146 | ret = da8xx_pinmux_setup(da830_evm_mmc_sd_pins); |
| 147 | if (ret) { |
| 148 | pr_warning("da830_evm_init: mmc/sd mux setup failed: %d\n", |
| 149 | ret); |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | ret = gpio_request(DA830_MMCSD_WP_PIN, "MMC WP"); |
| 154 | if (ret) { |
| 155 | pr_warning("da830_evm_init: can not open GPIO %d\n", |
| 156 | DA830_MMCSD_WP_PIN); |
| 157 | return; |
| 158 | } |
| 159 | gpio_direction_input(DA830_MMCSD_WP_PIN); |
| 160 | |
| 161 | ret = da8xx_register_mmcsd0(&da830_evm_mmc_config); |
| 162 | if (ret) { |
| 163 | pr_warning("da830_evm_init: mmc/sd registration failed: %d\n", |
| 164 | ret); |
| 165 | gpio_free(DA830_MMCSD_WP_PIN); |
| 166 | } |
| 167 | } |
| 168 | |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 169 | static __init void da830_evm_init(void) |
| 170 | { |
| 171 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
| 172 | int ret; |
| 173 | |
| 174 | ret = da8xx_register_edma(); |
| 175 | if (ret) |
| 176 | pr_warning("da830_evm_init: edma registration failed: %d\n", |
| 177 | ret); |
| 178 | |
Sudhakar Rajashekhara | c96b56c | 2009-07-16 05:45:32 -0400 | [diff] [blame] | 179 | ret = da8xx_pinmux_setup(da830_i2c0_pins); |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 180 | if (ret) |
| 181 | pr_warning("da830_evm_init: i2c0 mux setup failed: %d\n", |
| 182 | ret); |
| 183 | |
| 184 | ret = da8xx_register_i2c(0, &da830_evm_i2c_0_pdata); |
| 185 | if (ret) |
| 186 | pr_warning("da830_evm_init: i2c0 registration failed: %d\n", |
| 187 | ret); |
| 188 | |
| 189 | soc_info->emac_pdata->phy_mask = DA830_EVM_PHY_MASK; |
| 190 | soc_info->emac_pdata->mdio_max_freq = DA830_EVM_MDIO_FREQUENCY; |
| 191 | soc_info->emac_pdata->rmii_en = 1; |
| 192 | |
Sudhakar Rajashekhara | c96b56c | 2009-07-16 05:45:32 -0400 | [diff] [blame] | 193 | ret = da8xx_pinmux_setup(da830_cpgmac_pins); |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 194 | if (ret) |
| 195 | pr_warning("da830_evm_init: cpgmac mux setup failed: %d\n", |
| 196 | ret); |
| 197 | |
| 198 | ret = da8xx_register_emac(); |
| 199 | if (ret) |
| 200 | pr_warning("da830_evm_init: emac registration failed: %d\n", |
| 201 | ret); |
| 202 | |
| 203 | ret = da8xx_register_watchdog(); |
| 204 | if (ret) |
| 205 | pr_warning("da830_evm_init: watchdog registration failed: %d\n", |
| 206 | ret); |
| 207 | |
| 208 | davinci_serial_init(&da830_evm_uart_config); |
| 209 | i2c_register_board_info(1, da830_evm_i2c_devices, |
| 210 | ARRAY_SIZE(da830_evm_i2c_devices)); |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 211 | |
Mark A. Greer | 32bf078 | 2009-08-28 15:05:21 -0700 | [diff] [blame] | 212 | ret = da8xx_pinmux_setup(da830_evm_mcasp1_pins); |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 213 | if (ret) |
| 214 | pr_warning("da830_evm_init: mcasp1 mux setup failed: %d\n", |
| 215 | ret); |
| 216 | |
Mark A. Greer | b8864aa | 2009-08-28 15:05:02 -0700 | [diff] [blame] | 217 | da8xx_register_mcasp(1, &da830_evm_snd_data); |
David A. Griego | 2eb30c8 | 2009-09-15 18:10:20 -0700 | [diff] [blame] | 218 | |
| 219 | da830_evm_init_mmc(); |
Steve Chen | 13e1f04 | 2009-09-15 18:15:06 -0700 | [diff] [blame^] | 220 | |
| 221 | #ifdef CONFIG_DA830_UI_LCD |
| 222 | ret = da8xx_pinmux_setup(da830_lcdcntl_pins); |
| 223 | if (ret) |
| 224 | pr_warning("da830_evm_init: lcdcntl mux setup failed: %d\n", |
| 225 | ret); |
| 226 | |
| 227 | ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata); |
| 228 | if (ret) |
| 229 | pr_warning("da830_evm_init: lcd setup failed: %d\n", ret); |
| 230 | #endif |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
| 234 | static int __init da830_evm_console_init(void) |
| 235 | { |
| 236 | return add_preferred_console("ttyS", 2, "115200"); |
| 237 | } |
| 238 | console_initcall(da830_evm_console_init); |
| 239 | #endif |
| 240 | |
| 241 | static __init void da830_evm_irq_init(void) |
| 242 | { |
| 243 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
| 244 | |
| 245 | cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA830_N_CP_INTC_IRQ, |
| 246 | soc_info->intc_irq_prios); |
| 247 | } |
| 248 | |
| 249 | static void __init da830_evm_map_io(void) |
| 250 | { |
| 251 | da830_init(); |
| 252 | } |
| 253 | |
Kevin Hilman | baf09a4 | 2009-07-08 08:32:27 -0700 | [diff] [blame] | 254 | MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP L137 EVM") |
Mark A. Greer | 8593790 | 2009-06-03 18:41:53 -0700 | [diff] [blame] | 255 | .phys_io = IO_PHYS, |
| 256 | .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc, |
| 257 | .boot_params = (DA8XX_DDR_BASE + 0x100), |
| 258 | .map_io = da830_evm_map_io, |
| 259 | .init_irq = da830_evm_irq_init, |
| 260 | .timer = &davinci_timer, |
| 261 | .init_machine = da830_evm_init, |
| 262 | MACHINE_END |