0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/gpio.h>
0016 #include <linux/kernel.h>
0017 #include <linux/init.h>
0018 #include <linux/platform_device.h>
0019 #include <linux/delay.h>
0020 #include <linux/mtd/mtd.h>
0021 #include <linux/mtd/partitions.h>
0022 #include <linux/mtd/physmap.h>
0023 #include <linux/input.h>
0024 #include <linux/smc91x.h>
0025 #include <linux/omapfb.h>
0026 #include <linux/platform_data/keypad-omap.h>
0027
0028 #include <asm/mach-types.h>
0029 #include <asm/mach/arch.h>
0030 #include <asm/mach/map.h>
0031
0032 #include "tc.h"
0033 #include "mux.h"
0034 #include "flash.h"
0035 #include "hardware.h"
0036 #include "usb.h"
0037 #include "iomap.h"
0038 #include "common.h"
0039 #include "mmc.h"
0040
0041
0042 #define INNOVATOR1610_ETHR_START 0x04000300
0043
0044 static const unsigned int innovator_keymap[] = {
0045 KEY(0, 0, KEY_F1),
0046 KEY(3, 0, KEY_DOWN),
0047 KEY(1, 1, KEY_F2),
0048 KEY(2, 1, KEY_RIGHT),
0049 KEY(0, 2, KEY_F3),
0050 KEY(1, 2, KEY_F4),
0051 KEY(2, 2, KEY_UP),
0052 KEY(2, 3, KEY_ENTER),
0053 KEY(3, 3, KEY_LEFT),
0054 };
0055
0056 static struct mtd_partition innovator_partitions[] = {
0057
0058 {
0059 .name = "bootloader",
0060 .offset = 0,
0061 .size = SZ_128K,
0062 .mask_flags = MTD_WRITEABLE,
0063 },
0064
0065 {
0066 .name = "params",
0067 .offset = MTDPART_OFS_APPEND,
0068 .size = SZ_128K,
0069 .mask_flags = 0,
0070 },
0071
0072 {
0073 .name = "kernel",
0074 .offset = MTDPART_OFS_APPEND,
0075 .size = SZ_2M,
0076 .mask_flags = 0
0077 },
0078
0079 {
0080 .name = "rootfs",
0081 .offset = MTDPART_OFS_APPEND,
0082 .size = SZ_16M - SZ_2M - 2 * SZ_128K,
0083 .mask_flags = 0
0084 },
0085
0086 {
0087 .name = "filesystem",
0088 .offset = MTDPART_OFS_APPEND,
0089 .size = MTDPART_SIZ_FULL,
0090 .mask_flags = 0
0091 }
0092 };
0093
0094 static struct physmap_flash_data innovator_flash_data = {
0095 .width = 2,
0096 .set_vpp = omap1_set_vpp,
0097 .parts = innovator_partitions,
0098 .nr_parts = ARRAY_SIZE(innovator_partitions),
0099 };
0100
0101 static struct resource innovator_flash_resource = {
0102 .start = OMAP_CS0_PHYS,
0103 .end = OMAP_CS0_PHYS + SZ_32M - 1,
0104 .flags = IORESOURCE_MEM,
0105 };
0106
0107 static struct platform_device innovator_flash_device = {
0108 .name = "physmap-flash",
0109 .id = 0,
0110 .dev = {
0111 .platform_data = &innovator_flash_data,
0112 },
0113 .num_resources = 1,
0114 .resource = &innovator_flash_resource,
0115 };
0116
0117 static struct resource innovator_kp_resources[] = {
0118 [0] = {
0119 .start = INT_KEYBOARD,
0120 .end = INT_KEYBOARD,
0121 .flags = IORESOURCE_IRQ,
0122 },
0123 };
0124
0125 static const struct matrix_keymap_data innovator_keymap_data = {
0126 .keymap = innovator_keymap,
0127 .keymap_size = ARRAY_SIZE(innovator_keymap),
0128 };
0129
0130 static struct omap_kp_platform_data innovator_kp_data = {
0131 .rows = 8,
0132 .cols = 8,
0133 .keymap_data = &innovator_keymap_data,
0134 .delay = 4,
0135 };
0136
0137 static struct platform_device innovator_kp_device = {
0138 .name = "omap-keypad",
0139 .id = -1,
0140 .dev = {
0141 .platform_data = &innovator_kp_data,
0142 },
0143 .num_resources = ARRAY_SIZE(innovator_kp_resources),
0144 .resource = innovator_kp_resources,
0145 };
0146
0147 static struct smc91x_platdata innovator_smc91x_info = {
0148 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
0149 .leda = RPC_LED_100_10,
0150 .ledb = RPC_LED_TX_RX,
0151 };
0152
0153 #ifdef CONFIG_ARCH_OMAP15XX
0154
0155 #include <linux/spi/spi.h>
0156 #include <linux/spi/ads7846.h>
0157
0158
0159
0160 static struct map_desc innovator1510_io_desc[] __initdata = {
0161 {
0162 .virtual = OMAP1510_FPGA_BASE,
0163 .pfn = __phys_to_pfn(OMAP1510_FPGA_START),
0164 .length = OMAP1510_FPGA_SIZE,
0165 .type = MT_DEVICE
0166 }
0167 };
0168
0169 static struct resource innovator1510_smc91x_resources[] = {
0170 [0] = {
0171 .start = OMAP1510_FPGA_ETHR_START,
0172 .end = OMAP1510_FPGA_ETHR_START + 0xf,
0173 .flags = IORESOURCE_MEM,
0174 },
0175 [1] = {
0176 .start = OMAP1510_INT_ETHER,
0177 .end = OMAP1510_INT_ETHER,
0178 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
0179 },
0180 };
0181
0182 static struct platform_device innovator1510_smc91x_device = {
0183 .name = "smc91x",
0184 .id = 0,
0185 .dev = {
0186 .platform_data = &innovator_smc91x_info,
0187 },
0188 .num_resources = ARRAY_SIZE(innovator1510_smc91x_resources),
0189 .resource = innovator1510_smc91x_resources,
0190 };
0191
0192 static struct platform_device innovator1510_lcd_device = {
0193 .name = "lcd_inn1510",
0194 .id = -1,
0195 .dev = {
0196 .platform_data = (void __force *)OMAP1510_FPGA_LCD_PANEL_CONTROL,
0197 }
0198 };
0199
0200 static struct platform_device innovator1510_spi_device = {
0201 .name = "spi_inn1510",
0202 .id = -1,
0203 };
0204
0205 static struct platform_device *innovator1510_devices[] __initdata = {
0206 &innovator_flash_device,
0207 &innovator1510_smc91x_device,
0208 &innovator_kp_device,
0209 &innovator1510_lcd_device,
0210 &innovator1510_spi_device,
0211 };
0212
0213 static int innovator_get_pendown_state(void)
0214 {
0215 return !(__raw_readb(OMAP1510_FPGA_TOUCHSCREEN) & (1 << 5));
0216 }
0217
0218 static const struct ads7846_platform_data innovator1510_ts_info = {
0219 .model = 7846,
0220 .vref_delay_usecs = 100,
0221 .x_plate_ohms = 419,
0222 .y_plate_ohms = 486,
0223 .get_pendown_state = innovator_get_pendown_state,
0224 };
0225
0226 static struct spi_board_info __initdata innovator1510_boardinfo[] = { {
0227
0228 .modalias = "ads7846",
0229 .platform_data = &innovator1510_ts_info,
0230 .irq = OMAP1510_INT_FPGA_TS,
0231 .max_speed_hz = 120000
0232 * 26 ,
0233 .bus_num = 10,
0234 .chip_select = 0,
0235 } };
0236
0237 #endif
0238
0239 #ifdef CONFIG_ARCH_OMAP16XX
0240
0241 static struct resource innovator1610_smc91x_resources[] = {
0242 [0] = {
0243 .start = INNOVATOR1610_ETHR_START,
0244 .end = INNOVATOR1610_ETHR_START + 0xf,
0245 .flags = IORESOURCE_MEM,
0246 },
0247 [1] = {
0248 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
0249 },
0250 };
0251
0252 static struct platform_device innovator1610_smc91x_device = {
0253 .name = "smc91x",
0254 .id = 0,
0255 .dev = {
0256 .platform_data = &innovator_smc91x_info,
0257 },
0258 .num_resources = ARRAY_SIZE(innovator1610_smc91x_resources),
0259 .resource = innovator1610_smc91x_resources,
0260 };
0261
0262 static struct platform_device innovator1610_lcd_device = {
0263 .name = "inn1610_lcd",
0264 .id = -1,
0265 };
0266
0267 static struct platform_device *innovator1610_devices[] __initdata = {
0268 &innovator_flash_device,
0269 &innovator1610_smc91x_device,
0270 &innovator_kp_device,
0271 &innovator1610_lcd_device,
0272 };
0273
0274 #endif
0275
0276 static void __init innovator_init_smc91x(void)
0277 {
0278 if (cpu_is_omap1510()) {
0279 __raw_writeb(__raw_readb(OMAP1510_FPGA_RST) & ~1,
0280 OMAP1510_FPGA_RST);
0281 udelay(750);
0282 } else {
0283 if (gpio_request(0, "SMC91x irq") < 0) {
0284 printk("Error requesting gpio 0 for smc91x irq\n");
0285 return;
0286 }
0287 }
0288 }
0289
0290 #ifdef CONFIG_ARCH_OMAP15XX
0291
0292
0293
0294 static int innovator_omap_ohci_transceiver_power(int on)
0295 {
0296 if (on)
0297 __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL)
0298 | ((1 << 5) | (1 << 3)),
0299 INNOVATOR_FPGA_CAM_USB_CONTROL);
0300 else
0301 __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL)
0302 & ~((1 << 5) | (1 << 3)),
0303 INNOVATOR_FPGA_CAM_USB_CONTROL);
0304
0305 return 0;
0306 }
0307
0308 static struct omap_usb_config innovator1510_usb_config __initdata = {
0309
0310 .hmc_mode = 4,
0311
0312 .register_host = 1,
0313 .pins[1] = 6,
0314 .pins[2] = 6,
0315
0316 .register_dev = 1,
0317 .pins[0] = 2,
0318
0319 .transceiver_power = innovator_omap_ohci_transceiver_power,
0320 };
0321
0322 static const struct omap_lcd_config innovator1510_lcd_config __initconst = {
0323 .ctrl_name = "internal",
0324 };
0325 #endif
0326
0327 #ifdef CONFIG_ARCH_OMAP16XX
0328 static struct omap_usb_config h2_usb_config __initdata = {
0329
0330 .otg = 2,
0331
0332 #if IS_ENABLED(CONFIG_USB_OMAP)
0333 .hmc_mode = 19,
0334
0335 #elif IS_ENABLED(CONFIG_USB_OHCI_HCD)
0336
0337 .hmc_mode = 20,
0338 #endif
0339
0340 .pins[1] = 3,
0341 };
0342
0343 static const struct omap_lcd_config innovator1610_lcd_config __initconst = {
0344 .ctrl_name = "internal",
0345 };
0346 #endif
0347
0348 #if IS_ENABLED(CONFIG_MMC_OMAP)
0349
0350 static int mmc_set_power(struct device *dev, int slot, int power_on,
0351 int vdd)
0352 {
0353 if (power_on)
0354 __raw_writeb(__raw_readb(OMAP1510_FPGA_POWER) | (1 << 3),
0355 OMAP1510_FPGA_POWER);
0356 else
0357 __raw_writeb(__raw_readb(OMAP1510_FPGA_POWER) & ~(1 << 3),
0358 OMAP1510_FPGA_POWER);
0359
0360 return 0;
0361 }
0362
0363
0364
0365
0366
0367
0368 static struct omap_mmc_platform_data mmc1_data = {
0369 .nr_slots = 1,
0370 .slots[0] = {
0371 .set_power = mmc_set_power,
0372 .wires = 4,
0373 .name = "mmcblk",
0374 },
0375 };
0376
0377 static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
0378
0379 static void __init innovator_mmc_init(void)
0380 {
0381 mmc_data[0] = &mmc1_data;
0382 omap1_init_mmc(mmc_data, OMAP15XX_NR_MMC);
0383 }
0384
0385 #else
0386 static inline void innovator_mmc_init(void)
0387 {
0388 }
0389 #endif
0390
0391 static void __init innovator_init(void)
0392 {
0393 if (cpu_is_omap1510())
0394 omap1510_fpga_init_irq();
0395 innovator_init_smc91x();
0396
0397 #ifdef CONFIG_ARCH_OMAP15XX
0398 if (cpu_is_omap1510()) {
0399 unsigned char reg;
0400
0401
0402 omap_cfg_reg(UART1_TX);
0403 omap_cfg_reg(UART1_RTS);
0404 omap_cfg_reg(UART2_TX);
0405 omap_cfg_reg(UART2_RTS);
0406 omap_cfg_reg(UART3_TX);
0407 omap_cfg_reg(UART3_RX);
0408
0409 reg = __raw_readb(OMAP1510_FPGA_POWER);
0410 reg |= OMAP1510_FPGA_PCR_COM1_EN;
0411 __raw_writeb(reg, OMAP1510_FPGA_POWER);
0412 udelay(10);
0413
0414 reg = __raw_readb(OMAP1510_FPGA_POWER);
0415 reg |= OMAP1510_FPGA_PCR_COM2_EN;
0416 __raw_writeb(reg, OMAP1510_FPGA_POWER);
0417 udelay(10);
0418
0419 platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
0420 spi_register_board_info(innovator1510_boardinfo,
0421 ARRAY_SIZE(innovator1510_boardinfo));
0422 }
0423 #endif
0424 #ifdef CONFIG_ARCH_OMAP16XX
0425 if (!cpu_is_omap1510()) {
0426 innovator1610_smc91x_resources[1].start = gpio_to_irq(0);
0427 innovator1610_smc91x_resources[1].end = gpio_to_irq(0);
0428 platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
0429 }
0430 #endif
0431
0432 #ifdef CONFIG_ARCH_OMAP15XX
0433 if (cpu_is_omap1510()) {
0434 omap1_usb_init(&innovator1510_usb_config);
0435 omapfb_set_lcd_config(&innovator1510_lcd_config);
0436 }
0437 #endif
0438 #ifdef CONFIG_ARCH_OMAP16XX
0439 if (cpu_is_omap1610()) {
0440 omap1_usb_init(&h2_usb_config);
0441 omapfb_set_lcd_config(&innovator1610_lcd_config);
0442 }
0443 #endif
0444 omap_serial_init();
0445 omap_register_i2c_bus(1, 100, NULL, 0);
0446 innovator_mmc_init();
0447 }
0448
0449
0450
0451
0452
0453
0454 static void __init innovator_map_io(void)
0455 {
0456 #ifdef CONFIG_ARCH_OMAP15XX
0457 omap15xx_map_io();
0458
0459 iotable_init(innovator1510_io_desc, ARRAY_SIZE(innovator1510_io_desc));
0460 udelay(10);
0461
0462
0463 pr_debug("Innovator FPGA Rev %d.%d Board Rev %d\n",
0464 __raw_readb(OMAP1510_FPGA_REV_HIGH),
0465 __raw_readb(OMAP1510_FPGA_REV_LOW),
0466 __raw_readb(OMAP1510_FPGA_BOARD_REV));
0467 #endif
0468 }
0469
0470 MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
0471
0472 .atag_offset = 0x100,
0473 .map_io = innovator_map_io,
0474 .init_early = omap1_init_early,
0475 .init_irq = omap1_init_irq,
0476 .handle_irq = omap1_handle_irq,
0477 .init_machine = innovator_init,
0478 .init_late = omap1_init_late,
0479 .init_time = omap1_timer_init,
0480 .restart = omap1_restart,
0481 MACHINE_END