Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Tony Lindgren | dbdf9ce | 2005-07-10 19:58:11 +0100 | [diff] [blame] | 2 | * linux/arch/arm/mach-omap1/board-osk.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Board specific init for OMAP5912 OSK |
| 5 | * |
| 6 | * Written by Dirk Behme <dirk.behme@de.bosch.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2 of the License, or (at your |
| 11 | * option) any later version. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 16 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 19 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 20 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License along |
| 25 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 26 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | */ |
| 28 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/init.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 31 | #include <linux/platform_device.h> |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 32 | #include <linux/interrupt.h> |
| 33 | |
| 34 | #include <linux/mtd/mtd.h> |
| 35 | #include <linux/mtd/partitions.h> |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 36 | #include <linux/input.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | #include <asm/hardware.h> |
| 39 | #include <asm/mach-types.h> |
| 40 | #include <asm/mach/arch.h> |
| 41 | #include <asm/mach/map.h> |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 42 | #include <asm/mach/flash.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | #include <asm/arch/gpio.h> |
| 45 | #include <asm/arch/usb.h> |
| 46 | #include <asm/arch/mux.h> |
| 47 | #include <asm/arch/tc.h> |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 48 | #include <asm/arch/keypad.h> |
Tony Lindgren | d48af15 | 2005-07-10 19:58:17 +0100 | [diff] [blame] | 49 | #include <asm/arch/common.h> |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 50 | #include <asm/arch/mcbsp.h> |
| 51 | #include <asm/arch/omap-alsa.h> |
| 52 | |
| 53 | static int osk_keymap[] = { |
| 54 | KEY(0, 0, KEY_F1), |
| 55 | KEY(0, 3, KEY_UP), |
| 56 | KEY(1, 1, KEY_LEFTCTRL), |
| 57 | KEY(1, 2, KEY_LEFT), |
| 58 | KEY(2, 0, KEY_SPACE), |
| 59 | KEY(2, 1, KEY_ESC), |
| 60 | KEY(2, 2, KEY_DOWN), |
| 61 | KEY(3, 2, KEY_ENTER), |
| 62 | KEY(3, 3, KEY_RIGHT), |
| 63 | 0 |
| 64 | }; |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 67 | static struct mtd_partition osk_partitions[] = { |
| 68 | /* bootloader (U-Boot, etc) in first sector */ |
| 69 | { |
| 70 | .name = "bootloader", |
| 71 | .offset = 0, |
| 72 | .size = SZ_128K, |
| 73 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 74 | }, |
| 75 | /* bootloader params in the next sector */ |
| 76 | { |
| 77 | .name = "params", |
| 78 | .offset = MTDPART_OFS_APPEND, |
| 79 | .size = SZ_128K, |
| 80 | .mask_flags = 0, |
| 81 | }, { |
| 82 | .name = "kernel", |
| 83 | .offset = MTDPART_OFS_APPEND, |
| 84 | .size = SZ_2M, |
| 85 | .mask_flags = 0 |
| 86 | }, { |
| 87 | .name = "filesystem", |
| 88 | .offset = MTDPART_OFS_APPEND, |
| 89 | .size = MTDPART_SIZ_FULL, |
| 90 | .mask_flags = 0 |
| 91 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 94 | static struct flash_platform_data osk_flash_data = { |
| 95 | .map_name = "cfi_probe", |
| 96 | .width = 2, |
| 97 | .parts = osk_partitions, |
| 98 | .nr_parts = ARRAY_SIZE(osk_partitions), |
| 99 | }; |
| 100 | |
| 101 | static struct resource osk_flash_resource = { |
| 102 | /* this is on CS3, wherever it's mapped */ |
| 103 | .flags = IORESOURCE_MEM, |
| 104 | }; |
| 105 | |
| 106 | static struct platform_device osk5912_flash_device = { |
| 107 | .name = "omapflash", |
| 108 | .id = 0, |
| 109 | .dev = { |
| 110 | .platform_data = &osk_flash_data, |
| 111 | }, |
| 112 | .num_resources = 1, |
| 113 | .resource = &osk_flash_resource, |
| 114 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | static struct resource osk5912_smc91x_resources[] = { |
| 117 | [0] = { |
| 118 | .start = OMAP_OSK_ETHR_START, /* Physical */ |
| 119 | .end = OMAP_OSK_ETHR_START + 0xf, |
| 120 | .flags = IORESOURCE_MEM, |
| 121 | }, |
| 122 | [1] = { |
| 123 | .start = OMAP_GPIO_IRQ(0), |
| 124 | .end = OMAP_GPIO_IRQ(0), |
| 125 | .flags = IORESOURCE_IRQ, |
| 126 | }, |
| 127 | }; |
| 128 | |
| 129 | static struct platform_device osk5912_smc91x_device = { |
| 130 | .name = "smc91x", |
| 131 | .id = -1, |
| 132 | .num_resources = ARRAY_SIZE(osk5912_smc91x_resources), |
| 133 | .resource = osk5912_smc91x_resources, |
| 134 | }; |
| 135 | |
| 136 | static struct resource osk5912_cf_resources[] = { |
| 137 | [0] = { |
| 138 | .start = OMAP_GPIO_IRQ(62), |
| 139 | .end = OMAP_GPIO_IRQ(62), |
| 140 | .flags = IORESOURCE_IRQ, |
| 141 | }, |
| 142 | }; |
| 143 | |
| 144 | static struct platform_device osk5912_cf_device = { |
| 145 | .name = "omap_cf", |
| 146 | .id = -1, |
| 147 | .dev = { |
| 148 | .platform_data = (void *) 2 /* CS2 */, |
| 149 | }, |
| 150 | .num_resources = ARRAY_SIZE(osk5912_cf_resources), |
| 151 | .resource = osk5912_cf_resources, |
| 152 | }; |
| 153 | |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 154 | #define DEFAULT_BITPERSAMPLE 16 |
| 155 | |
| 156 | static struct omap_mcbsp_reg_cfg mcbsp_regs = { |
| 157 | .spcr2 = FREE | FRST | GRST | XRST | XINTM(3), |
| 158 | .spcr1 = RINTM(3) | RRST, |
| 159 | .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) | |
| 160 | RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0), |
| 161 | .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16), |
| 162 | .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) | |
| 163 | XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG, |
| 164 | .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16), |
| 165 | .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1), |
| 166 | .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1), |
| 167 | /*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */ |
| 168 | .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */ |
| 169 | }; |
| 170 | |
| 171 | static struct omap_alsa_codec_config alsa_config = { |
| 172 | .name = "OSK AIC23", |
| 173 | .mcbsp_regs_alsa = &mcbsp_regs, |
| 174 | .codec_configure_dev = NULL, // aic23_configure, |
| 175 | .codec_set_samplerate = NULL, // aic23_set_samplerate, |
| 176 | .codec_clock_setup = NULL, // aic23_clock_setup, |
| 177 | .codec_clock_on = NULL, // aic23_clock_on, |
| 178 | .codec_clock_off = NULL, // aic23_clock_off, |
| 179 | .get_default_samplerate = NULL, // aic23_get_default_samplerate, |
| 180 | }; |
| 181 | |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 182 | static struct platform_device osk5912_mcbsp1_device = { |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 183 | .name = "omap_alsa_mcbsp", |
| 184 | .id = 1, |
| 185 | .dev = { |
| 186 | .platform_data = &alsa_config, |
| 187 | }, |
| 188 | }; |
| 189 | |
| 190 | static struct resource osk5912_kp_resources[] = { |
| 191 | [0] = { |
| 192 | .start = INT_KEYBOARD, |
| 193 | .end = INT_KEYBOARD, |
| 194 | .flags = IORESOURCE_IRQ, |
| 195 | }, |
| 196 | }; |
| 197 | |
| 198 | static struct omap_kp_platform_data osk_kp_data = { |
| 199 | .rows = 8, |
| 200 | .cols = 8, |
| 201 | .keymap = osk_keymap, |
| 202 | }; |
| 203 | |
| 204 | static struct platform_device osk5912_kp_device = { |
| 205 | .name = "omap-keypad", |
| 206 | .id = -1, |
| 207 | .dev = { |
| 208 | .platform_data = &osk_kp_data, |
| 209 | }, |
| 210 | .num_resources = ARRAY_SIZE(osk5912_kp_resources), |
| 211 | .resource = osk5912_kp_resources, |
| 212 | }; |
| 213 | |
| 214 | static struct platform_device osk5912_lcd_device = { |
| 215 | .name = "lcd_osk", |
| 216 | .id = -1, |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 217 | }; |
| 218 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | static struct platform_device *osk5912_devices[] __initdata = { |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 220 | &osk5912_flash_device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | &osk5912_smc91x_device, |
| 222 | &osk5912_cf_device, |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 223 | &osk5912_mcbsp1_device, |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 224 | &osk5912_kp_device, |
| 225 | &osk5912_lcd_device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | }; |
| 227 | |
| 228 | static void __init osk_init_smc91x(void) |
| 229 | { |
| 230 | if ((omap_request_gpio(0)) < 0) { |
| 231 | printk("Error requesting gpio 0 for smc91x irq\n"); |
| 232 | return; |
| 233 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
| 235 | /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */ |
Tony Lindgren | 3179a01 | 2005-11-10 14:26:48 +0000 | [diff] [blame] | 236 | EMIFS_CCS(1) |= 0x3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | static void __init osk_init_cf(void) |
| 240 | { |
| 241 | omap_cfg_reg(M7_1610_GPIO62); |
| 242 | if ((omap_request_gpio(62)) < 0) { |
| 243 | printk("Error requesting gpio 62 for CF irq\n"); |
| 244 | return; |
| 245 | } |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 246 | /* the CF I/O IRQ is really active-low */ |
| 247 | set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 250 | static void __init osk_init_irq(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | { |
Tony Lindgren | 87bd63f | 2006-02-08 22:06:46 +0000 | [diff] [blame] | 252 | omap1_init_common_hw(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | omap_init_irq(); |
| 254 | omap_gpio_init(); |
| 255 | osk_init_smc91x(); |
| 256 | osk_init_cf(); |
| 257 | } |
| 258 | |
| 259 | static struct omap_usb_config osk_usb_config __initdata = { |
| 260 | /* has usb host connector (A) ... for development it can also |
| 261 | * be used, with a NONSTANDARD gender-bending cable/dongle, as |
| 262 | * a peripheral. |
| 263 | */ |
| 264 | #ifdef CONFIG_USB_GADGET_OMAP |
| 265 | .register_dev = 1, |
| 266 | .hmc_mode = 0, |
| 267 | #else |
| 268 | .register_host = 1, |
| 269 | .hmc_mode = 16, |
| 270 | .rwc = 1, |
| 271 | #endif |
| 272 | .pins[0] = 2, |
| 273 | }; |
| 274 | |
Tony Lindgren | 3179a01 | 2005-11-10 14:26:48 +0000 | [diff] [blame] | 275 | static struct omap_uart_config osk_uart_config __initdata = { |
| 276 | .enabled_uarts = (1 << 0), |
| 277 | }; |
| 278 | |
| 279 | static struct omap_lcd_config osk_lcd_config __initdata = { |
Tony Lindgren | 3179a01 | 2005-11-10 14:26:48 +0000 | [diff] [blame] | 280 | .ctrl_name = "internal", |
| 281 | }; |
| 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | static struct omap_board_config_kernel osk_config[] = { |
| 284 | { OMAP_TAG_USB, &osk_usb_config }, |
Tony Lindgren | 3179a01 | 2005-11-10 14:26:48 +0000 | [diff] [blame] | 285 | { OMAP_TAG_UART, &osk_uart_config }, |
| 286 | { OMAP_TAG_LCD, &osk_lcd_config }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | }; |
| 288 | |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 289 | #ifdef CONFIG_OMAP_OSK_MISTRAL |
| 290 | |
| 291 | #ifdef CONFIG_PM |
| 292 | static irqreturn_t |
| 293 | osk_mistral_wake_interrupt(int irq, void *ignored, struct pt_regs *regs) |
| 294 | { |
| 295 | return IRQ_HANDLED; |
| 296 | } |
| 297 | #endif |
| 298 | |
| 299 | static void __init osk_mistral_init(void) |
| 300 | { |
| 301 | /* FIXME here's where to feed in framebuffer, touchpad, and |
| 302 | * keyboard setup ... not in the drivers for those devices! |
| 303 | * |
| 304 | * NOTE: we could actually tell if there's a Mistral board |
| 305 | * attached, e.g. by trying to read something from the ads7846. |
| 306 | * But this is too early for that... |
| 307 | */ |
| 308 | |
| 309 | /* the sideways button (SW1) is for use as a "wakeup" button */ |
| 310 | omap_cfg_reg(N15_1610_MPUIO2); |
| 311 | if (omap_request_gpio(OMAP_MPUIO(2)) == 0) { |
| 312 | int ret = 0; |
| 313 | omap_set_gpio_direction(OMAP_MPUIO(2), 1); |
| 314 | set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING); |
| 315 | #ifdef CONFIG_PM |
| 316 | /* share the IRQ in case someone wants to use the |
| 317 | * button for more than wakeup from system sleep. |
| 318 | */ |
| 319 | ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), |
| 320 | &osk_mistral_wake_interrupt, |
| 321 | SA_SHIRQ, "mistral_wakeup", |
| 322 | &osk_mistral_wake_interrupt); |
| 323 | if (ret != 0) { |
| 324 | omap_free_gpio(OMAP_MPUIO(2)); |
| 325 | printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n", |
| 326 | ret); |
| 327 | } else |
| 328 | enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2))); |
| 329 | #endif |
| 330 | } else |
| 331 | printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n"); |
| 332 | } |
| 333 | #else |
| 334 | static void __init osk_mistral_init(void) { } |
| 335 | #endif |
| 336 | |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 337 | #define EMIFS_CS3_VAL (0x88013141) |
| 338 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | static void __init osk_init(void) |
| 340 | { |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame^] | 341 | /* Workaround for wrong CS3 (NOR flash) timing |
| 342 | * There are some U-Boot versions out there which configure |
| 343 | * wrong CS3 memory timings. This mainly leads to CRC |
| 344 | * or similiar errors if you use NOR flash (e.g. with JFFS2) |
| 345 | */ |
| 346 | if (EMIFS_CCS(3) != EMIFS_CS3_VAL) |
| 347 | EMIFS_CCS(3) = EMIFS_CS3_VAL; |
| 348 | |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 349 | osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys(); |
| 350 | osk_flash_resource.end += SZ_32M - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices)); |
| 352 | omap_board_config = osk_config; |
| 353 | omap_board_config_size = ARRAY_SIZE(osk_config); |
| 354 | USB_TRANSCEIVER_CTRL_REG |= (3 << 1); |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 355 | |
Tony Lindgren | 3179a01 | 2005-11-10 14:26:48 +0000 | [diff] [blame] | 356 | omap_serial_init(); |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 357 | osk_mistral_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | static void __init osk_map_io(void) |
| 361 | { |
Tony Lindgren | 87bd63f | 2006-02-08 22:06:46 +0000 | [diff] [blame] | 362 | omap1_map_common_io(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | MACHINE_START(OMAP_OSK, "TI-OSK") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 366 | /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */ |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 367 | .phys_io = 0xfff00000, |
| 368 | .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc, |
| 369 | .boot_params = 0x10000100, |
| 370 | .map_io = osk_map_io, |
| 371 | .init_irq = osk_init_irq, |
| 372 | .init_machine = osk_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | .timer = &omap_timer, |
| 374 | MACHINE_END |