0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #include <linux/gpio.h>
0029 #include <linux/gpio/machine.h>
0030 #include <linux/kernel.h>
0031 #include <linux/init.h>
0032 #include <linux/platform_device.h>
0033 #include <linux/interrupt.h>
0034 #include <linux/irq.h>
0035 #include <linux/i2c.h>
0036 #include <linux/leds.h>
0037 #include <linux/smc91x.h>
0038 #include <linux/omapfb.h>
0039 #include <linux/mtd/mtd.h>
0040 #include <linux/mtd/partitions.h>
0041 #include <linux/mtd/physmap.h>
0042 #include <linux/mfd/tps65010.h>
0043 #include <linux/platform_data/gpio-omap.h>
0044 #include <linux/platform_data/omap1_bl.h>
0045 #include <linux/soc/ti/omap1-io.h>
0046
0047 #include <asm/mach-types.h>
0048 #include <asm/mach/arch.h>
0049 #include <asm/mach/map.h>
0050
0051 #include "tc.h"
0052 #include "flash.h"
0053 #include "mux.h"
0054 #include "hardware.h"
0055 #include "usb.h"
0056 #include "common.h"
0057
0058
0059 #define OMAP_GPIO_LABEL "gpio-0-15"
0060
0061
0062 #define OMAP_OSK_ETHR_START 0x04800300
0063
0064
0065
0066
0067 #define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 )
0068 # define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0)
0069 # define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1)
0070 # define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2)
0071 # define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3)
0072 # define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4)
0073 # define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5)
0074
0075 static struct mtd_partition osk_partitions[] = {
0076
0077 {
0078 .name = "bootloader",
0079 .offset = 0,
0080 .size = SZ_128K,
0081 .mask_flags = MTD_WRITEABLE,
0082 },
0083
0084 {
0085 .name = "params",
0086 .offset = MTDPART_OFS_APPEND,
0087 .size = SZ_128K,
0088 .mask_flags = 0,
0089 }, {
0090 .name = "kernel",
0091 .offset = MTDPART_OFS_APPEND,
0092 .size = SZ_2M,
0093 .mask_flags = 0
0094 }, {
0095 .name = "filesystem",
0096 .offset = MTDPART_OFS_APPEND,
0097 .size = MTDPART_SIZ_FULL,
0098 .mask_flags = 0
0099 }
0100 };
0101
0102 static struct physmap_flash_data osk_flash_data = {
0103 .width = 2,
0104 .set_vpp = omap1_set_vpp,
0105 .parts = osk_partitions,
0106 .nr_parts = ARRAY_SIZE(osk_partitions),
0107 };
0108
0109 static struct resource osk_flash_resource = {
0110
0111 .flags = IORESOURCE_MEM,
0112 };
0113
0114 static struct platform_device osk5912_flash_device = {
0115 .name = "physmap-flash",
0116 .id = 0,
0117 .dev = {
0118 .platform_data = &osk_flash_data,
0119 },
0120 .num_resources = 1,
0121 .resource = &osk_flash_resource,
0122 };
0123
0124 static struct smc91x_platdata osk5912_smc91x_info = {
0125 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
0126 .leda = RPC_LED_100_10,
0127 .ledb = RPC_LED_TX_RX,
0128 };
0129
0130 static struct resource osk5912_smc91x_resources[] = {
0131 [0] = {
0132 .start = OMAP_OSK_ETHR_START,
0133 .end = OMAP_OSK_ETHR_START + 0xf,
0134 .flags = IORESOURCE_MEM,
0135 },
0136 [1] = {
0137 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
0138 },
0139 };
0140
0141 static struct platform_device osk5912_smc91x_device = {
0142 .name = "smc91x",
0143 .id = -1,
0144 .dev = {
0145 .platform_data = &osk5912_smc91x_info,
0146 },
0147 .num_resources = ARRAY_SIZE(osk5912_smc91x_resources),
0148 .resource = osk5912_smc91x_resources,
0149 };
0150
0151 static struct resource osk5912_cf_resources[] = {
0152 [0] = {
0153 .flags = IORESOURCE_IRQ,
0154 },
0155 [1] = {
0156 .flags = IORESOURCE_MEM,
0157 },
0158 };
0159
0160 static struct platform_device osk5912_cf_device = {
0161 .name = "omap_cf",
0162 .id = -1,
0163 .num_resources = ARRAY_SIZE(osk5912_cf_resources),
0164 .resource = osk5912_cf_resources,
0165 };
0166
0167 static struct platform_device *osk5912_devices[] __initdata = {
0168 &osk5912_flash_device,
0169 &osk5912_smc91x_device,
0170 &osk5912_cf_device,
0171 };
0172
0173 static const struct gpio_led tps_leds[] = {
0174
0175
0176
0177 { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9",
0178 .default_trigger = "disk-activity", },
0179 { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", },
0180 { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1,
0181 .default_trigger = "heartbeat", },
0182 };
0183
0184 static struct gpio_led_platform_data tps_leds_data = {
0185 .num_leds = 3,
0186 .leds = tps_leds,
0187 };
0188
0189 static struct platform_device osk5912_tps_leds = {
0190 .name = "leds-gpio",
0191 .id = 0,
0192 .dev.platform_data = &tps_leds_data,
0193 };
0194
0195 static int osk_tps_setup(struct i2c_client *client, void *context)
0196 {
0197 if (!IS_BUILTIN(CONFIG_TPS65010))
0198 return -ENOSYS;
0199
0200
0201
0202
0203 gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
0204 gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);
0205
0206 gpio_free(OSK_TPS_GPIO_USB_PWR_EN);
0207
0208
0209 tps65010_set_gpio_out_value(GPIO2, HIGH);
0210
0211
0212 gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
0213 gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);
0214
0215
0216 gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
0217 gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
0218
0219
0220
0221 tps65010_set_led(LED1, BLINK);
0222
0223
0224 tps65010_set_led(LED2, OFF);
0225
0226
0227 tps65010_set_low_pwr(ON);
0228
0229
0230 tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
0231 | TPS_LDO1_ENABLE);
0232
0233
0234 osk5912_tps_leds.dev.parent = &client->dev;
0235 platform_device_register(&osk5912_tps_leds);
0236
0237 return 0;
0238 }
0239
0240 static struct tps65010_board tps_board = {
0241 .base = OSK_TPS_GPIO_BASE,
0242 .outmask = 0x0f,
0243 .setup = osk_tps_setup,
0244 };
0245
0246 static struct i2c_board_info __initdata osk_i2c_board_info[] = {
0247 {
0248
0249 I2C_BOARD_INFO("tps65010", 0x48),
0250 .dev_name = "tps65010",
0251 .platform_data = &tps_board,
0252
0253 },
0254 {
0255 I2C_BOARD_INFO("tlv320aic23", 0x1B),
0256 },
0257
0258
0259
0260 };
0261
0262 static void __init osk_init_smc91x(void)
0263 {
0264 u32 l;
0265
0266 if ((gpio_request(0, "smc_irq")) < 0) {
0267 printk("Error requesting gpio 0 for smc91x irq\n");
0268 return;
0269 }
0270
0271
0272 l = omap_readl(EMIFS_CCS(1));
0273 l |= 0x3;
0274 omap_writel(l, EMIFS_CCS(1));
0275 }
0276
0277 static void __init osk_init_cf(int seg)
0278 {
0279 struct resource *res = &osk5912_cf_resources[1];
0280
0281 omap_cfg_reg(M7_1610_GPIO62);
0282 if ((gpio_request(62, "cf_irq")) < 0) {
0283 printk("Error requesting gpio 62 for CF irq\n");
0284 return;
0285 }
0286
0287 switch (seg) {
0288
0289 case 1:
0290 res->start = OMAP_CS1_PHYS;
0291 break;
0292 case 2:
0293 res->start = OMAP_CS2_PHYS;
0294 break;
0295 case 3:
0296 res->start = omap_cs3_phys();
0297 break;
0298 }
0299
0300 res->end = res->start + SZ_8K - 1;
0301 osk5912_cf_device.dev.platform_data = (void *)(uintptr_t)seg;
0302
0303
0304
0305
0306
0307 pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", __func__,
0308 seg, omap_readl(EMIFS_CCS(seg)), omap_readl(EMIFS_ACS(seg)));
0309 omap_writel(0x0004a1b3, EMIFS_CCS(seg));
0310 omap_writel(0x00000000, EMIFS_ACS(seg));
0311
0312
0313 irq_set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING);
0314 }
0315
0316 static struct gpiod_lookup_table osk_usb_gpio_table = {
0317 .dev_id = "ohci",
0318 .table = {
0319
0320 GPIO_LOOKUP("tps65010", 0, "power", GPIO_ACTIVE_HIGH),
0321 GPIO_LOOKUP(OMAP_GPIO_LABEL, 9, "overcurrent",
0322 GPIO_ACTIVE_HIGH),
0323 },
0324 };
0325
0326 static struct omap_usb_config osk_usb_config __initdata = {
0327
0328
0329
0330
0331 #if IS_ENABLED(CONFIG_USB_OMAP)
0332 .register_dev = 1,
0333 .hmc_mode = 0,
0334 #else
0335 .register_host = 1,
0336 .hmc_mode = 16,
0337 .rwc = 1,
0338 #endif
0339 .pins[0] = 2,
0340 };
0341
0342 #ifdef CONFIG_OMAP_OSK_MISTRAL
0343 static const struct omap_lcd_config osk_lcd_config __initconst = {
0344 .ctrl_name = "internal",
0345 };
0346 #endif
0347
0348 #ifdef CONFIG_OMAP_OSK_MISTRAL
0349
0350 #include <linux/input.h>
0351 #include <linux/property.h>
0352 #include <linux/spi/spi.h>
0353 #include <linux/spi/ads7846.h>
0354
0355 #include <linux/platform_data/keypad-omap.h>
0356
0357 static const struct property_entry mistral_at24_properties[] = {
0358 PROPERTY_ENTRY_U32("pagesize", 16),
0359 { }
0360 };
0361
0362 static const struct software_node mistral_at24_node = {
0363 .properties = mistral_at24_properties,
0364 };
0365
0366 static struct i2c_board_info __initdata mistral_i2c_board_info[] = {
0367 {
0368
0369 I2C_BOARD_INFO("24c04", 0x50),
0370 .swnode = &mistral_at24_node,
0371 },
0372
0373
0374
0375 };
0376
0377 static const unsigned int osk_keymap[] = {
0378
0379 KEY(0, 0, KEY_F1),
0380 KEY(3, 0, KEY_UP),
0381 KEY(1, 1, KEY_LEFTCTRL),
0382 KEY(2, 1, KEY_LEFT),
0383 KEY(0, 2, KEY_SPACE),
0384 KEY(1, 2, KEY_ESC),
0385 KEY(2, 2, KEY_DOWN),
0386 KEY(2, 3, KEY_ENTER),
0387 KEY(3, 3, KEY_RIGHT),
0388 };
0389
0390 static const struct matrix_keymap_data osk_keymap_data = {
0391 .keymap = osk_keymap,
0392 .keymap_size = ARRAY_SIZE(osk_keymap),
0393 };
0394
0395 static struct omap_kp_platform_data osk_kp_data = {
0396 .rows = 8,
0397 .cols = 8,
0398 .keymap_data = &osk_keymap_data,
0399 .delay = 9,
0400 };
0401
0402 static struct resource osk5912_kp_resources[] = {
0403 [0] = {
0404 .start = INT_KEYBOARD,
0405 .end = INT_KEYBOARD,
0406 .flags = IORESOURCE_IRQ,
0407 },
0408 };
0409
0410 static struct platform_device osk5912_kp_device = {
0411 .name = "omap-keypad",
0412 .id = -1,
0413 .dev = {
0414 .platform_data = &osk_kp_data,
0415 },
0416 .num_resources = ARRAY_SIZE(osk5912_kp_resources),
0417 .resource = osk5912_kp_resources,
0418 };
0419
0420 static struct omap_backlight_config mistral_bl_data = {
0421 .default_intensity = 0xa0,
0422 };
0423
0424 static struct platform_device mistral_bl_device = {
0425 .name = "omap-bl",
0426 .id = -1,
0427 .dev = {
0428 .platform_data = &mistral_bl_data,
0429 },
0430 };
0431
0432 static struct platform_device osk5912_lcd_device = {
0433 .name = "lcd_osk",
0434 .id = -1,
0435 };
0436
0437 static const struct gpio_led mistral_gpio_led_pins[] = {
0438 {
0439 .name = "mistral:red",
0440 .default_trigger = "heartbeat",
0441 .gpio = 3,
0442 },
0443 {
0444 .name = "mistral:green",
0445 .default_trigger = "cpu0",
0446 .gpio = OMAP_MPUIO(4),
0447 },
0448 };
0449
0450 static struct gpio_led_platform_data mistral_gpio_led_data = {
0451 .leds = mistral_gpio_led_pins,
0452 .num_leds = ARRAY_SIZE(mistral_gpio_led_pins),
0453 };
0454
0455 static struct platform_device mistral_gpio_leds = {
0456 .name = "leds-gpio",
0457 .id = -1,
0458 .dev = {
0459 .platform_data = &mistral_gpio_led_data,
0460 },
0461 };
0462
0463 static struct platform_device *mistral_devices[] __initdata = {
0464 &osk5912_kp_device,
0465 &mistral_bl_device,
0466 &osk5912_lcd_device,
0467 &mistral_gpio_leds,
0468 };
0469
0470 static int mistral_get_pendown_state(void)
0471 {
0472 return !gpio_get_value(4);
0473 }
0474
0475 static const struct ads7846_platform_data mistral_ts_info = {
0476 .model = 7846,
0477 .vref_delay_usecs = 100,
0478 .x_plate_ohms = 419,
0479 .y_plate_ohms = 486,
0480 .get_pendown_state = mistral_get_pendown_state,
0481 };
0482
0483 static struct spi_board_info __initdata mistral_boardinfo[] = { {
0484
0485 .modalias = "ads7846",
0486 .platform_data = &mistral_ts_info,
0487 .max_speed_hz = 120000
0488 * 26 ,
0489 .bus_num = 2,
0490 .chip_select = 0,
0491 } };
0492
0493 static irqreturn_t
0494 osk_mistral_wake_interrupt(int irq, void *ignored)
0495 {
0496 return IRQ_HANDLED;
0497 }
0498
0499 static void __init osk_mistral_init(void)
0500 {
0501
0502
0503
0504
0505
0506
0507
0508 omap_cfg_reg(J15_1610_CAM_LCLK);
0509 omap_cfg_reg(J18_1610_CAM_D7);
0510 omap_cfg_reg(J19_1610_CAM_D6);
0511 omap_cfg_reg(J14_1610_CAM_D5);
0512 omap_cfg_reg(K18_1610_CAM_D4);
0513 omap_cfg_reg(K19_1610_CAM_D3);
0514 omap_cfg_reg(K15_1610_CAM_D2);
0515 omap_cfg_reg(K14_1610_CAM_D1);
0516 omap_cfg_reg(L19_1610_CAM_D0);
0517 omap_cfg_reg(L18_1610_CAM_VS);
0518 omap_cfg_reg(L15_1610_CAM_HS);
0519 omap_cfg_reg(M19_1610_CAM_RSTZ);
0520 omap_cfg_reg(Y15_1610_CAM_OUTCLK);
0521
0522
0523 omap_cfg_reg(H19_1610_CAM_EXCLK);
0524 omap_cfg_reg(W13_1610_CCP_CLKM);
0525 omap_cfg_reg(Y12_1610_CCP_CLKP);
0526
0527
0528 omap_cfg_reg(W14_1610_CCP_DATAP);
0529
0530
0531 if (gpio_request(11, "cam_pwdn") == 0) {
0532 omap_cfg_reg(N20_1610_GPIO11);
0533 gpio_direction_output(11, 0);
0534 } else
0535 pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
0536
0537
0538
0539 gpio_request(6, "ts_busy");
0540 gpio_direction_input(6);
0541
0542 omap_cfg_reg(P20_1610_GPIO4);
0543 gpio_request(4, "ts_int");
0544 gpio_direction_input(4);
0545 irq_set_irq_type(gpio_to_irq(4), IRQ_TYPE_EDGE_FALLING);
0546
0547 mistral_boardinfo[0].irq = gpio_to_irq(4);
0548 spi_register_board_info(mistral_boardinfo,
0549 ARRAY_SIZE(mistral_boardinfo));
0550
0551
0552
0553
0554
0555
0556
0557
0558 omap_cfg_reg(N15_1610_MPUIO2);
0559 if (gpio_request(OMAP_MPUIO(2), "wakeup") == 0) {
0560 int ret = 0;
0561 int irq = gpio_to_irq(OMAP_MPUIO(2));
0562
0563 gpio_direction_input(OMAP_MPUIO(2));
0564 irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
0565
0566
0567
0568 ret = request_irq(irq,
0569 &osk_mistral_wake_interrupt,
0570 IRQF_SHARED, "mistral_wakeup",
0571 &osk_mistral_wake_interrupt);
0572 if (ret != 0) {
0573 gpio_free(OMAP_MPUIO(2));
0574 printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
0575 ret);
0576 } else
0577 enable_irq_wake(irq);
0578 } else
0579 printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
0580
0581
0582
0583
0584 omap_cfg_reg(PWL);
0585 if (gpio_request(2, "lcd_pwr") == 0)
0586 gpio_direction_output(2, 1);
0587
0588
0589
0590
0591 omap_cfg_reg(P18_1610_GPIO3);
0592 omap_cfg_reg(MPUIO4);
0593
0594 i2c_register_board_info(1, mistral_i2c_board_info,
0595 ARRAY_SIZE(mistral_i2c_board_info));
0596
0597 platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
0598 }
0599 #else
0600 static void __init osk_mistral_init(void) { }
0601 #endif
0602
0603 #define EMIFS_CS3_VAL (0x88013141)
0604
0605 static void __init osk_init(void)
0606 {
0607 u32 l;
0608
0609 osk_init_smc91x();
0610 osk_init_cf(2);
0611
0612
0613
0614
0615
0616
0617 l = omap_readl(EMIFS_CCS(3));
0618 if (l != EMIFS_CS3_VAL)
0619 omap_writel(EMIFS_CS3_VAL, EMIFS_CCS(3));
0620
0621 osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
0622 osk_flash_resource.end += SZ_32M - 1;
0623 osk5912_smc91x_resources[1].start = gpio_to_irq(0);
0624 osk5912_smc91x_resources[1].end = gpio_to_irq(0);
0625 osk5912_cf_resources[0].start = gpio_to_irq(62);
0626 osk5912_cf_resources[0].end = gpio_to_irq(62);
0627 platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
0628
0629 l = omap_readl(USB_TRANSCEIVER_CTRL);
0630 l |= (3 << 1);
0631 omap_writel(l, USB_TRANSCEIVER_CTRL);
0632
0633 gpiod_add_lookup_table(&osk_usb_gpio_table);
0634 omap1_usb_init(&osk_usb_config);
0635
0636
0637
0638 if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
0639 gpio_direction_input(OMAP_MPUIO(1));
0640
0641 omap_serial_init();
0642 osk_i2c_board_info[0].irq = gpio_to_irq(OMAP_MPUIO(1));
0643 omap_register_i2c_bus(1, 400, osk_i2c_board_info,
0644 ARRAY_SIZE(osk_i2c_board_info));
0645 osk_mistral_init();
0646
0647 #ifdef CONFIG_OMAP_OSK_MISTRAL
0648 omapfb_set_lcd_config(&osk_lcd_config);
0649 #endif
0650
0651 }
0652
0653 MACHINE_START(OMAP_OSK, "TI-OSK")
0654
0655 .atag_offset = 0x100,
0656 .map_io = omap16xx_map_io,
0657 .init_early = omap1_init_early,
0658 .init_irq = omap1_init_irq,
0659 .handle_irq = omap1_handle_irq,
0660 .init_machine = osk_init,
0661 .init_late = omap1_init_late,
0662 .init_time = omap1_timer_init,
0663 .restart = omap1_restart,
0664 MACHINE_END