Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/board-ldp.c |
| 3 | * |
| 4 | * Copyright (C) 2008 Texas Instruments Inc. |
| 5 | * Nishant Kamat <nskamat@ti.com> |
| 6 | * |
| 7 | * Modified from mach-omap2/board-3430sdp.c |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/input.h> |
| 19 | #include <linux/workqueue.h> |
| 20 | #include <linux/err.h> |
| 21 | #include <linux/clk.h> |
| 22 | #include <linux/spi/spi.h> |
| 23 | #include <linux/spi/ads7846.h> |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 24 | #include <linux/i2c/twl4030.h> |
Russell King | 9973022 | 2009-03-25 10:21:35 +0000 | [diff] [blame] | 25 | #include <linux/io.h> |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 26 | #include <linux/smsc911x.h> |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 27 | |
| 28 | #include <mach/hardware.h> |
| 29 | #include <asm/mach-types.h> |
| 30 | #include <asm/mach/arch.h> |
| 31 | #include <asm/mach/map.h> |
| 32 | |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 33 | #include <mach/mcspi.h> |
| 34 | #include <mach/gpio.h> |
| 35 | #include <mach/board.h> |
| 36 | #include <mach/common.h> |
| 37 | #include <mach/gpmc.h> |
| 38 | |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 39 | #include <asm/delay.h> |
| 40 | #include <mach/control.h> |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 41 | #include <mach/usb.h> |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 42 | |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 43 | #include "mmc-twl4030.h" |
| 44 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 45 | #define LDP_SMSC911X_CS 1 |
| 46 | #define LDP_SMSC911X_GPIO 152 |
Tony Lindgren | ec7558a | 2009-03-23 18:07:37 -0700 | [diff] [blame] | 47 | #define DEBUG_BASE 0x08000000 |
| 48 | #define LDP_ETHR_START DEBUG_BASE |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 49 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 50 | static struct resource ldp_smsc911x_resources[] = { |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 51 | [0] = { |
Tony Lindgren | ec7558a | 2009-03-23 18:07:37 -0700 | [diff] [blame] | 52 | .start = LDP_ETHR_START, |
| 53 | .end = LDP_ETHR_START + SZ_4K, |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 54 | .flags = IORESOURCE_MEM, |
| 55 | }, |
| 56 | [1] = { |
| 57 | .start = 0, |
| 58 | .end = 0, |
| 59 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 60 | }, |
| 61 | }; |
| 62 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 63 | static struct smsc911x_platform_config ldp_smsc911x_config = { |
| 64 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 65 | .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, |
| 66 | .flags = SMSC911X_USE_32BIT, |
| 67 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 68 | }; |
| 69 | |
| 70 | static struct platform_device ldp_smsc911x_device = { |
| 71 | .name = "smsc911x", |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 72 | .id = -1, |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 73 | .num_resources = ARRAY_SIZE(ldp_smsc911x_resources), |
| 74 | .resource = ldp_smsc911x_resources, |
| 75 | .dev = { |
| 76 | .platform_data = &ldp_smsc911x_config, |
| 77 | }, |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 80 | static inline void __init ldp_init_smsc911x(void) |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 81 | { |
| 82 | int eth_cs; |
| 83 | unsigned long cs_mem_base; |
| 84 | int eth_gpio = 0; |
| 85 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 86 | eth_cs = LDP_SMSC911X_CS; |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 87 | |
| 88 | if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 89 | printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n"); |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 90 | return; |
| 91 | } |
| 92 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 93 | ldp_smsc911x_resources[0].start = cs_mem_base + 0x0; |
| 94 | ldp_smsc911x_resources[0].end = cs_mem_base + 0xff; |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 95 | udelay(100); |
| 96 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 97 | eth_gpio = LDP_SMSC911X_GPIO; |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 98 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 99 | ldp_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio); |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 100 | |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 101 | if (gpio_request(eth_gpio, "smsc911x irq") < 0) { |
| 102 | printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n", |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 103 | eth_gpio); |
| 104 | return; |
| 105 | } |
| 106 | gpio_direction_input(eth_gpio); |
| 107 | } |
| 108 | |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 109 | static void __init omap_ldp_init_irq(void) |
| 110 | { |
Paul Walmsley | 87246b7 | 2009-01-28 12:27:39 -0700 | [diff] [blame] | 111 | omap2_init_common_hw(NULL); |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 112 | omap_init_irq(); |
| 113 | omap_gpio_init(); |
Steve Glendinning | 1c0e147 | 2009-01-23 17:09:13 +0000 | [diff] [blame] | 114 | ldp_init_smsc911x(); |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static struct omap_uart_config ldp_uart_config __initdata = { |
| 118 | .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)), |
| 119 | }; |
| 120 | |
Imre Deak | 49adf46 | 2009-05-28 14:04:00 -0700 | [diff] [blame^] | 121 | static struct platform_device ldp_lcd_device = { |
| 122 | .name = "ldp_lcd", |
| 123 | .id = -1, |
| 124 | }; |
| 125 | |
| 126 | static struct omap_lcd_config ldp_lcd_config __initdata = { |
| 127 | .ctrl_name = "internal", |
| 128 | }; |
| 129 | |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 130 | static struct omap_board_config_kernel ldp_config[] __initdata = { |
| 131 | { OMAP_TAG_UART, &ldp_uart_config }, |
Imre Deak | 49adf46 | 2009-05-28 14:04:00 -0700 | [diff] [blame^] | 132 | { OMAP_TAG_LCD, &ldp_lcd_config }, |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 133 | }; |
| 134 | |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 135 | static struct twl4030_gpio_platform_data ldp_gpio_data = { |
| 136 | .gpio_base = OMAP_MAX_GPIO_LINES, |
| 137 | .irq_base = TWL4030_GPIO_IRQ_BASE, |
| 138 | .irq_end = TWL4030_GPIO_IRQ_END, |
| 139 | }; |
| 140 | |
| 141 | static struct twl4030_platform_data ldp_twldata = { |
| 142 | .irq_base = TWL4030_IRQ_BASE, |
| 143 | .irq_end = TWL4030_IRQ_END, |
| 144 | |
| 145 | /* platform_data for children goes here */ |
| 146 | .gpio = &ldp_gpio_data, |
| 147 | }; |
| 148 | |
| 149 | static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = { |
| 150 | { |
| 151 | I2C_BOARD_INFO("twl4030", 0x48), |
| 152 | .flags = I2C_CLIENT_WAKE, |
| 153 | .irq = INT_34XX_SYS_NIRQ, |
| 154 | .platform_data = &ldp_twldata, |
| 155 | }, |
| 156 | }; |
| 157 | |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 158 | static int __init omap_i2c_init(void) |
| 159 | { |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 160 | omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo, |
| 161 | ARRAY_SIZE(ldp_i2c_boardinfo)); |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 162 | omap_register_i2c_bus(2, 400, NULL, 0); |
| 163 | omap_register_i2c_bus(3, 400, NULL, 0); |
| 164 | return 0; |
| 165 | } |
| 166 | |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 167 | static struct twl4030_hsmmc_info mmc[] __initdata = { |
| 168 | { |
| 169 | .mmc = 1, |
| 170 | .wires = 4, |
| 171 | .gpio_cd = -EINVAL, |
| 172 | .gpio_wp = -EINVAL, |
| 173 | }, |
| 174 | {} /* Terminator */ |
| 175 | }; |
| 176 | |
Imre Deak | 49adf46 | 2009-05-28 14:04:00 -0700 | [diff] [blame^] | 177 | static struct platform_device *ldp_devices[] __initdata = { |
| 178 | &ldp_smsc911x_device, |
| 179 | &ldp_lcd_device, |
| 180 | }; |
| 181 | |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 182 | static void __init omap_ldp_init(void) |
| 183 | { |
| 184 | omap_i2c_init(); |
Stanley.Miao | b1c056d | 2008-12-10 17:36:53 -0800 | [diff] [blame] | 185 | platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices)); |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 186 | omap_board_config = ldp_config; |
| 187 | omap_board_config_size = ARRAY_SIZE(ldp_config); |
| 188 | omap_serial_init(); |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 189 | twl4030_mmc_init(mmc); |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 190 | usb_musb_init(); |
Nishant Kamat | 4926565 | 2008-10-10 11:28:23 +0300 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static void __init omap_ldp_map_io(void) |
| 194 | { |
| 195 | omap2_set_globals_343x(); |
| 196 | omap2_map_common_io(); |
| 197 | } |
| 198 | |
| 199 | MACHINE_START(OMAP_LDP, "OMAP LDP board") |
| 200 | .phys_io = 0x48000000, |
| 201 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, |
| 202 | .boot_params = 0x80000100, |
| 203 | .map_io = omap_ldp_map_io, |
| 204 | .init_irq = omap_ldp_init_irq, |
| 205 | .init_machine = omap_ldp_init, |
| 206 | .timer = &omap_timer, |
| 207 | MACHINE_END |