Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-omap1/board-h2.c
0004  *
0005  * Board specific inits for OMAP-1610 H2
0006  *
0007  * Copyright (C) 2001 RidgeRun, Inc.
0008  * Author: Greg Lonnon <glonnon@ridgerun.com>
0009  *
0010  * Copyright (C) 2002 MontaVista Software, Inc.
0011  *
0012  * Separated FPGA interrupts from innovator1510.c and cleaned up for 2.6
0013  * Copyright (C) 2004 Nokia Corporation by Tony Lindrgen <tony@atomide.com>
0014  *
0015  * H2 specific changes and cleanup
0016  * Copyright (C) 2004 Nokia Corporation by Imre Deak <imre.deak@nokia.com>
0017  */
0018 #include <linux/gpio.h>
0019 #include <linux/gpio/machine.h>
0020 #include <linux/kernel.h>
0021 #include <linux/platform_device.h>
0022 #include <linux/delay.h>
0023 #include <linux/i2c.h>
0024 #include <linux/mtd/mtd.h>
0025 #include <linux/mtd/platnand.h>
0026 #include <linux/mtd/physmap.h>
0027 #include <linux/input.h>
0028 #include <linux/mfd/tps65010.h>
0029 #include <linux/smc91x.h>
0030 #include <linux/omapfb.h>
0031 #include <linux/omap-dma.h>
0032 #include <linux/platform_data/gpio-omap.h>
0033 #include <linux/platform_data/keypad-omap.h>
0034 #include <linux/leds.h>
0035 
0036 #include <asm/mach-types.h>
0037 #include <asm/mach/arch.h>
0038 #include <asm/mach/map.h>
0039 
0040 #include "tc.h"
0041 #include "mux.h"
0042 #include "flash.h"
0043 #include "hardware.h"
0044 #include "usb.h"
0045 #include "common.h"
0046 #include "board-h2.h"
0047 
0048 /* The first 16 SoC GPIO lines are on this GPIO chip */
0049 #define OMAP_GPIO_LABEL         "gpio-0-15"
0050 
0051 /* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
0052 #define OMAP1610_ETHR_START     0x04000300
0053 
0054 static const unsigned int h2_keymap[] = {
0055     KEY(0, 0, KEY_LEFT),
0056     KEY(1, 0, KEY_RIGHT),
0057     KEY(2, 0, KEY_3),
0058     KEY(3, 0, KEY_F10),
0059     KEY(4, 0, KEY_F5),
0060     KEY(5, 0, KEY_9),
0061     KEY(0, 1, KEY_DOWN),
0062     KEY(1, 1, KEY_UP),
0063     KEY(2, 1, KEY_2),
0064     KEY(3, 1, KEY_F9),
0065     KEY(4, 1, KEY_F7),
0066     KEY(5, 1, KEY_0),
0067     KEY(0, 2, KEY_ENTER),
0068     KEY(1, 2, KEY_6),
0069     KEY(2, 2, KEY_1),
0070     KEY(3, 2, KEY_F2),
0071     KEY(4, 2, KEY_F6),
0072     KEY(5, 2, KEY_HOME),
0073     KEY(0, 3, KEY_8),
0074     KEY(1, 3, KEY_5),
0075     KEY(2, 3, KEY_F12),
0076     KEY(3, 3, KEY_F3),
0077     KEY(4, 3, KEY_F8),
0078     KEY(5, 3, KEY_END),
0079     KEY(0, 4, KEY_7),
0080     KEY(1, 4, KEY_4),
0081     KEY(2, 4, KEY_F11),
0082     KEY(3, 4, KEY_F1),
0083     KEY(4, 4, KEY_F4),
0084     KEY(5, 4, KEY_ESC),
0085     KEY(0, 5, KEY_F13),
0086     KEY(1, 5, KEY_F14),
0087     KEY(2, 5, KEY_F15),
0088     KEY(3, 5, KEY_F16),
0089     KEY(4, 5, KEY_SLEEP),
0090 };
0091 
0092 static struct mtd_partition h2_nor_partitions[] = {
0093     /* bootloader (U-Boot, etc) in first sector */
0094     {
0095           .name     = "bootloader",
0096           .offset       = 0,
0097           .size     = SZ_128K,
0098           .mask_flags   = MTD_WRITEABLE, /* force read-only */
0099     },
0100     /* bootloader params in the next sector */
0101     {
0102           .name     = "params",
0103           .offset       = MTDPART_OFS_APPEND,
0104           .size     = SZ_128K,
0105           .mask_flags   = 0,
0106     },
0107     /* kernel */
0108     {
0109           .name     = "kernel",
0110           .offset       = MTDPART_OFS_APPEND,
0111           .size     = SZ_2M,
0112           .mask_flags   = 0
0113     },
0114     /* file system */
0115     {
0116           .name     = "filesystem",
0117           .offset       = MTDPART_OFS_APPEND,
0118           .size     = MTDPART_SIZ_FULL,
0119           .mask_flags   = 0
0120     }
0121 };
0122 
0123 static struct physmap_flash_data h2_nor_data = {
0124     .width      = 2,
0125     .set_vpp    = omap1_set_vpp,
0126     .parts      = h2_nor_partitions,
0127     .nr_parts   = ARRAY_SIZE(h2_nor_partitions),
0128 };
0129 
0130 static struct resource h2_nor_resource = {
0131     /* This is on CS3, wherever it's mapped */
0132     .flags      = IORESOURCE_MEM,
0133 };
0134 
0135 static struct platform_device h2_nor_device = {
0136     .name       = "physmap-flash",
0137     .id     = 0,
0138     .dev        = {
0139         .platform_data  = &h2_nor_data,
0140     },
0141     .num_resources  = 1,
0142     .resource   = &h2_nor_resource,
0143 };
0144 
0145 static struct mtd_partition h2_nand_partitions[] = {
0146 #if 0
0147     /* REVISIT:  enable these partitions if you make NAND BOOT
0148      * work on your H2 (rev C or newer); published versions of
0149      * x-load only support P2 and H3.
0150      */
0151     {
0152         .name       = "xloader",
0153         .offset     = 0,
0154         .size       = 64 * 1024,
0155         .mask_flags = MTD_WRITEABLE,    /* force read-only */
0156     },
0157     {
0158         .name       = "bootloader",
0159         .offset     = MTDPART_OFS_APPEND,
0160         .size       = 256 * 1024,
0161         .mask_flags = MTD_WRITEABLE,    /* force read-only */
0162     },
0163     {
0164         .name       = "params",
0165         .offset     = MTDPART_OFS_APPEND,
0166         .size       = 192 * 1024,
0167     },
0168     {
0169         .name       = "kernel",
0170         .offset     = MTDPART_OFS_APPEND,
0171         .size       = 2 * SZ_1M,
0172     },
0173 #endif
0174     {
0175         .name       = "filesystem",
0176         .size       = MTDPART_SIZ_FULL,
0177         .offset     = MTDPART_OFS_APPEND,
0178     },
0179 };
0180 
0181 #define H2_NAND_RB_GPIO_PIN 62
0182 
0183 static int h2_nand_dev_ready(struct nand_chip *chip)
0184 {
0185     return gpio_get_value(H2_NAND_RB_GPIO_PIN);
0186 }
0187 
0188 static struct platform_nand_data h2_nand_platdata = {
0189     .chip   = {
0190         .nr_chips       = 1,
0191         .chip_offset        = 0,
0192         .nr_partitions      = ARRAY_SIZE(h2_nand_partitions),
0193         .partitions     = h2_nand_partitions,
0194         .options        = NAND_SAMSUNG_LP_OPTIONS,
0195     },
0196     .ctrl   = {
0197         .cmd_ctrl   = omap1_nand_cmd_ctl,
0198         .dev_ready  = h2_nand_dev_ready,
0199     },
0200 };
0201 
0202 static struct resource h2_nand_resource = {
0203     .flags      = IORESOURCE_MEM,
0204 };
0205 
0206 static struct platform_device h2_nand_device = {
0207     .name       = "gen_nand",
0208     .id     = 0,
0209     .dev        = {
0210         .platform_data  = &h2_nand_platdata,
0211     },
0212     .num_resources  = 1,
0213     .resource   = &h2_nand_resource,
0214 };
0215 
0216 static struct smc91x_platdata h2_smc91x_info = {
0217     .flags  = SMC91X_USE_16BIT | SMC91X_NOWAIT,
0218     .leda   = RPC_LED_100_10,
0219     .ledb   = RPC_LED_TX_RX,
0220 };
0221 
0222 static struct resource h2_smc91x_resources[] = {
0223     [0] = {
0224         .start  = OMAP1610_ETHR_START,      /* Physical */
0225         .end    = OMAP1610_ETHR_START + 0xf,
0226         .flags  = IORESOURCE_MEM,
0227     },
0228     [1] = {
0229         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
0230     },
0231 };
0232 
0233 static struct platform_device h2_smc91x_device = {
0234     .name       = "smc91x",
0235     .id     = 0,
0236     .dev    = {
0237         .platform_data  = &h2_smc91x_info,
0238     },
0239     .num_resources  = ARRAY_SIZE(h2_smc91x_resources),
0240     .resource   = h2_smc91x_resources,
0241 };
0242 
0243 static struct resource h2_kp_resources[] = {
0244     [0] = {
0245         .start  = INT_KEYBOARD,
0246         .end    = INT_KEYBOARD,
0247         .flags  = IORESOURCE_IRQ,
0248     },
0249 };
0250 
0251 static const struct matrix_keymap_data h2_keymap_data = {
0252     .keymap     = h2_keymap,
0253     .keymap_size    = ARRAY_SIZE(h2_keymap),
0254 };
0255 
0256 static struct omap_kp_platform_data h2_kp_data = {
0257     .rows       = 8,
0258     .cols       = 8,
0259     .keymap_data    = &h2_keymap_data,
0260     .rep        = true,
0261     .delay      = 9,
0262     .dbounce    = true,
0263 };
0264 
0265 static struct platform_device h2_kp_device = {
0266     .name       = "omap-keypad",
0267     .id     = -1,
0268     .dev        = {
0269         .platform_data = &h2_kp_data,
0270     },
0271     .num_resources  = ARRAY_SIZE(h2_kp_resources),
0272     .resource   = h2_kp_resources,
0273 };
0274 
0275 static const struct gpio_led h2_gpio_led_pins[] = {
0276     {
0277         .name       = "h2:red",
0278         .default_trigger = "heartbeat",
0279         .gpio       = 3,
0280     },
0281     {
0282         .name       = "h2:green",
0283         .default_trigger = "cpu0",
0284         .gpio       = OMAP_MPUIO(4),
0285     },
0286 };
0287 
0288 static struct gpio_led_platform_data h2_gpio_led_data = {
0289     .leds       = h2_gpio_led_pins,
0290     .num_leds   = ARRAY_SIZE(h2_gpio_led_pins),
0291 };
0292 
0293 static struct platform_device h2_gpio_leds = {
0294     .name   = "leds-gpio",
0295     .id = -1,
0296     .dev    = {
0297         .platform_data = &h2_gpio_led_data,
0298     },
0299 };
0300 
0301 static struct platform_device *h2_devices[] __initdata = {
0302     &h2_nor_device,
0303     &h2_nand_device,
0304     &h2_smc91x_device,
0305     &h2_kp_device,
0306     &h2_gpio_leds,
0307 };
0308 
0309 static void __init h2_init_smc91x(void)
0310 {
0311     if (gpio_request(0, "SMC91x irq") < 0) {
0312         printk("Error requesting gpio 0 for smc91x irq\n");
0313         return;
0314     }
0315 }
0316 
0317 static int tps_setup(struct i2c_client *client, void *context)
0318 {
0319     if (!IS_BUILTIN(CONFIG_TPS65010))
0320         return -ENOSYS;
0321 
0322     tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V |
0323                 TPS_LDO1_ENABLE | TPS_VLDO1_3_0V);
0324 
0325     return 0;
0326 }
0327 
0328 static struct tps65010_board tps_board = {
0329     .base       = H2_TPS_GPIO_BASE,
0330     .outmask    = 0x0f,
0331     .setup      = tps_setup,
0332 };
0333 
0334 static struct i2c_board_info __initdata h2_i2c_board_info[] = {
0335     {
0336         I2C_BOARD_INFO("tps65010", 0x48),
0337         .platform_data  = &tps_board,
0338     }, {
0339         .type = "isp1301_omap",
0340         .addr = 0x2d,
0341         .dev_name = "isp1301",
0342     },
0343 };
0344 
0345 static struct gpiod_lookup_table isp1301_gpiod_table = {
0346     .dev_id = "isp1301",
0347     .table = {
0348         /* Active low since the irq triggers on falling edge */
0349         GPIO_LOOKUP(OMAP_GPIO_LABEL, 2,
0350                 NULL, GPIO_ACTIVE_LOW),
0351         { },
0352     },
0353 };
0354 
0355 static struct omap_usb_config h2_usb_config __initdata = {
0356     /* usb1 has a Mini-AB port and external isp1301 transceiver */
0357     .otg        = 2,
0358 
0359 #if IS_ENABLED(CONFIG_USB_OMAP)
0360     .hmc_mode   = 19,   /* 0:host(off) 1:dev|otg 2:disabled */
0361     /* .hmc_mode    = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */
0362 #elif   IS_ENABLED(CONFIG_USB_OHCI_HCD)
0363     /* needs OTG cable, or NONSTANDARD (B-to-MiniB) */
0364     .hmc_mode   = 20,   /* 1:dev|otg(off) 1:host 2:disabled */
0365 #endif
0366 
0367     .pins[1]    = 3,
0368 };
0369 
0370 static const struct omap_lcd_config h2_lcd_config __initconst = {
0371     .ctrl_name  = "internal",
0372 };
0373 
0374 static void __init h2_init(void)
0375 {
0376     h2_init_smc91x();
0377 
0378     /* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
0379      * to address 0 by a dip switch), NAND on CS2B.  The NAND driver will
0380      * notice whether a NAND chip is enabled at probe time.
0381      *
0382      * FIXME revC boards (and H3) support NAND-boot, with a dip switch to
0383      * put NOR on CS2B and NAND (which on H2 may be 16bit) on CS3.  Try
0384      * detecting that in code here, to avoid probing every possible flash
0385      * configuration...
0386      */
0387     h2_nor_resource.end = h2_nor_resource.start = omap_cs3_phys();
0388     h2_nor_resource.end += SZ_32M - 1;
0389 
0390     h2_nand_resource.end = h2_nand_resource.start = OMAP_CS2B_PHYS;
0391     h2_nand_resource.end += SZ_4K - 1;
0392     BUG_ON(gpio_request(H2_NAND_RB_GPIO_PIN, "NAND ready") < 0);
0393     gpio_direction_input(H2_NAND_RB_GPIO_PIN);
0394 
0395     gpiod_add_lookup_table(&isp1301_gpiod_table);
0396 
0397     omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
0398     omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
0399 
0400     /* MMC:  card detect and WP */
0401     /* omap_cfg_reg(U19_ARMIO1); */     /* CD */
0402     omap_cfg_reg(BALLOUT_V8_ARMIO3);    /* WP */
0403 
0404     /* Mux pins for keypad */
0405     omap_cfg_reg(F18_1610_KBC0);
0406     omap_cfg_reg(D20_1610_KBC1);
0407     omap_cfg_reg(D19_1610_KBC2);
0408     omap_cfg_reg(E18_1610_KBC3);
0409     omap_cfg_reg(C21_1610_KBC4);
0410     omap_cfg_reg(G18_1610_KBR0);
0411     omap_cfg_reg(F19_1610_KBR1);
0412     omap_cfg_reg(H14_1610_KBR2);
0413     omap_cfg_reg(E20_1610_KBR3);
0414     omap_cfg_reg(E19_1610_KBR4);
0415     omap_cfg_reg(N19_1610_KBR5);
0416 
0417     /* GPIO based LEDs */
0418     omap_cfg_reg(P18_1610_GPIO3);
0419     omap_cfg_reg(MPUIO4);
0420 
0421     h2_smc91x_resources[1].start = gpio_to_irq(0);
0422     h2_smc91x_resources[1].end = gpio_to_irq(0);
0423     platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
0424     omap_serial_init();
0425 
0426     /* ISP1301 IRQ wired at M14 */
0427     omap_cfg_reg(M14_1510_GPIO2);
0428     h2_i2c_board_info[0].irq = gpio_to_irq(58);
0429     omap_register_i2c_bus(1, 100, h2_i2c_board_info,
0430                   ARRAY_SIZE(h2_i2c_board_info));
0431     omap1_usb_init(&h2_usb_config);
0432     h2_mmc_init();
0433 
0434     omapfb_set_lcd_config(&h2_lcd_config);
0435 }
0436 
0437 MACHINE_START(OMAP_H2, "TI-H2")
0438     /* Maintainer: Imre Deak <imre.deak@nokia.com> */
0439     .atag_offset    = 0x100,
0440     .map_io     = omap16xx_map_io,
0441     .init_early     = omap1_init_early,
0442     .init_irq   = omap1_init_irq,
0443     .handle_irq = omap1_handle_irq,
0444     .init_machine   = h2_init,
0445     .init_late  = omap1_init_late,
0446     .init_time  = omap1_timer_init,
0447     .restart    = omap1_restart,
0448 MACHINE_END