0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/gpio.h>
0011 #include <linux/kernel.h>
0012 #include <linux/init.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/delay.h>
0015 #include <linux/mtd/mtd.h>
0016 #include <linux/mtd/platnand.h>
0017 #include <linux/mtd/physmap.h>
0018 #include <linux/input.h>
0019 #include <linux/smc91x.h>
0020 #include <linux/omapfb.h>
0021 #include <linux/platform_data/keypad-omap.h>
0022 #include <linux/soc/ti/omap1-io.h>
0023
0024 #include <asm/mach-types.h>
0025 #include <asm/mach/arch.h>
0026 #include <asm/mach/map.h>
0027
0028 #include "tc.h"
0029 #include "mux.h"
0030 #include "flash.h"
0031 #include "hardware.h"
0032 #include "iomap.h"
0033 #include "common.h"
0034 #include "fpga.h"
0035
0036 static const unsigned int p2_keymap[] = {
0037 KEY(0, 0, KEY_UP),
0038 KEY(1, 0, KEY_RIGHT),
0039 KEY(2, 0, KEY_LEFT),
0040 KEY(3, 0, KEY_DOWN),
0041 KEY(4, 0, KEY_ENTER),
0042 KEY(0, 1, KEY_F10),
0043 KEY(1, 1, KEY_SEND),
0044 KEY(2, 1, KEY_END),
0045 KEY(3, 1, KEY_VOLUMEDOWN),
0046 KEY(4, 1, KEY_VOLUMEUP),
0047 KEY(5, 1, KEY_RECORD),
0048 KEY(0, 2, KEY_F9),
0049 KEY(1, 2, KEY_3),
0050 KEY(2, 2, KEY_6),
0051 KEY(3, 2, KEY_9),
0052 KEY(4, 2, KEY_KPDOT),
0053 KEY(0, 3, KEY_BACK),
0054 KEY(1, 3, KEY_2),
0055 KEY(2, 3, KEY_5),
0056 KEY(3, 3, KEY_8),
0057 KEY(4, 3, KEY_0),
0058 KEY(5, 3, KEY_KPSLASH),
0059 KEY(0, 4, KEY_HOME),
0060 KEY(1, 4, KEY_1),
0061 KEY(2, 4, KEY_4),
0062 KEY(3, 4, KEY_7),
0063 KEY(4, 4, KEY_KPASTERISK),
0064 KEY(5, 4, KEY_POWER),
0065 };
0066
0067 static struct smc91x_platdata smc91x_info = {
0068 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
0069 .leda = RPC_LED_100_10,
0070 .ledb = RPC_LED_TX_RX,
0071 };
0072
0073 static struct resource smc91x_resources[] = {
0074 [0] = {
0075 .start = H2P2_DBG_FPGA_ETHR_START,
0076 .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
0077 .flags = IORESOURCE_MEM,
0078 },
0079 [1] = {
0080 .start = INT_7XX_MPU_EXT_NIRQ,
0081 .end = 0,
0082 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
0083 },
0084 };
0085
0086 static struct mtd_partition nor_partitions[] = {
0087
0088 {
0089 .name = "bootloader",
0090 .offset = 0,
0091 .size = SZ_128K,
0092 .mask_flags = MTD_WRITEABLE,
0093 },
0094
0095 {
0096 .name = "params",
0097 .offset = MTDPART_OFS_APPEND,
0098 .size = SZ_128K,
0099 .mask_flags = 0,
0100 },
0101
0102 {
0103 .name = "kernel",
0104 .offset = MTDPART_OFS_APPEND,
0105 .size = SZ_2M,
0106 .mask_flags = 0
0107 },
0108
0109 {
0110 .name = "rootfs",
0111 .offset = MTDPART_OFS_APPEND,
0112 .size = MTDPART_SIZ_FULL,
0113 .mask_flags = 0
0114 },
0115 };
0116
0117 static struct physmap_flash_data nor_data = {
0118 .width = 2,
0119 .set_vpp = omap1_set_vpp,
0120 .parts = nor_partitions,
0121 .nr_parts = ARRAY_SIZE(nor_partitions),
0122 };
0123
0124 static struct resource nor_resource = {
0125 .start = OMAP_CS0_PHYS,
0126 .end = OMAP_CS0_PHYS + SZ_32M - 1,
0127 .flags = IORESOURCE_MEM,
0128 };
0129
0130 static struct platform_device nor_device = {
0131 .name = "physmap-flash",
0132 .id = 0,
0133 .dev = {
0134 .platform_data = &nor_data,
0135 },
0136 .num_resources = 1,
0137 .resource = &nor_resource,
0138 };
0139
0140 #define P2_NAND_RB_GPIO_PIN 62
0141
0142 static int nand_dev_ready(struct nand_chip *chip)
0143 {
0144 return gpio_get_value(P2_NAND_RB_GPIO_PIN);
0145 }
0146
0147 static struct platform_nand_data nand_data = {
0148 .chip = {
0149 .nr_chips = 1,
0150 .chip_offset = 0,
0151 .options = NAND_SAMSUNG_LP_OPTIONS,
0152 },
0153 .ctrl = {
0154 .cmd_ctrl = omap1_nand_cmd_ctl,
0155 .dev_ready = nand_dev_ready,
0156 },
0157 };
0158
0159 static struct resource nand_resource = {
0160 .start = OMAP_CS3_PHYS,
0161 .end = OMAP_CS3_PHYS + SZ_4K - 1,
0162 .flags = IORESOURCE_MEM,
0163 };
0164
0165 static struct platform_device nand_device = {
0166 .name = "gen_nand",
0167 .id = 0,
0168 .dev = {
0169 .platform_data = &nand_data,
0170 },
0171 .num_resources = 1,
0172 .resource = &nand_resource,
0173 };
0174
0175 static struct platform_device smc91x_device = {
0176 .name = "smc91x",
0177 .id = 0,
0178 .dev = {
0179 .platform_data = &smc91x_info,
0180 },
0181 .num_resources = ARRAY_SIZE(smc91x_resources),
0182 .resource = smc91x_resources,
0183 };
0184
0185 static struct resource kp_resources[] = {
0186 [0] = {
0187 .start = INT_7XX_MPUIO_KEYPAD,
0188 .end = INT_7XX_MPUIO_KEYPAD,
0189 .flags = IORESOURCE_IRQ,
0190 },
0191 };
0192
0193 static const struct matrix_keymap_data p2_keymap_data = {
0194 .keymap = p2_keymap,
0195 .keymap_size = ARRAY_SIZE(p2_keymap),
0196 };
0197
0198 static struct omap_kp_platform_data kp_data = {
0199 .rows = 8,
0200 .cols = 8,
0201 .keymap_data = &p2_keymap_data,
0202 .delay = 4,
0203 .dbounce = true,
0204 };
0205
0206 static struct platform_device kp_device = {
0207 .name = "omap-keypad",
0208 .id = -1,
0209 .dev = {
0210 .platform_data = &kp_data,
0211 },
0212 .num_resources = ARRAY_SIZE(kp_resources),
0213 .resource = kp_resources,
0214 };
0215
0216 static struct platform_device *devices[] __initdata = {
0217 &nor_device,
0218 &nand_device,
0219 &smc91x_device,
0220 &kp_device,
0221 };
0222
0223 static const struct omap_lcd_config perseus2_lcd_config __initconst = {
0224 .ctrl_name = "internal",
0225 };
0226
0227 static void __init perseus2_init_smc91x(void)
0228 {
0229 __raw_writeb(1, H2P2_DBG_FPGA_LAN_RESET);
0230 mdelay(50);
0231 __raw_writeb(__raw_readb(H2P2_DBG_FPGA_LAN_RESET) & ~1,
0232 H2P2_DBG_FPGA_LAN_RESET);
0233 mdelay(50);
0234 }
0235
0236 static void __init omap_perseus2_init(void)
0237 {
0238
0239
0240
0241
0242
0243 omap_writew(omap_readw(OMAP7XX_DSP_M_CTL) & ~1, OMAP7XX_DSP_M_CTL);
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254 omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_0);
0255 omap_writel(0x00000088, OMAP7XX_FLASH_ACFG_0);
0256
0257
0258
0259
0260
0261 omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_1);
0262 omap_writel(0x00000000, OMAP7XX_FLASH_ACFG_1);
0263
0264
0265
0266
0267
0268 omap_writel(omap_readl(OMAP7XX_IO_CONF_9) & 0x1FFFFFFF,
0269 OMAP7XX_IO_CONF_9);
0270
0271 perseus2_init_smc91x();
0272
0273 BUG_ON(gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0);
0274 gpio_direction_input(P2_NAND_RB_GPIO_PIN);
0275
0276 omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
0277 omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
0278
0279
0280 omap_cfg_reg(E2_7XX_KBR0);
0281 omap_cfg_reg(J7_7XX_KBR1);
0282 omap_cfg_reg(E1_7XX_KBR2);
0283 omap_cfg_reg(F3_7XX_KBR3);
0284 omap_cfg_reg(D2_7XX_KBR4);
0285 omap_cfg_reg(C2_7XX_KBC0);
0286 omap_cfg_reg(D3_7XX_KBC1);
0287 omap_cfg_reg(E4_7XX_KBC2);
0288 omap_cfg_reg(F4_7XX_KBC3);
0289 omap_cfg_reg(E3_7XX_KBC4);
0290
0291 if (IS_ENABLED(CONFIG_SPI_OMAP_UWIRE)) {
0292
0293 int val = omap_readl(OMAP7XX_IO_CONF_9) & ~0x00EEE000;
0294 omap_writel(val | 0x00AAA000, OMAP7XX_IO_CONF_9);
0295 }
0296
0297 platform_add_devices(devices, ARRAY_SIZE(devices));
0298
0299 omap_serial_init();
0300 omap_register_i2c_bus(1, 100, NULL, 0);
0301
0302 omapfb_set_lcd_config(&perseus2_lcd_config);
0303 }
0304
0305
0306 static struct map_desc omap_perseus2_io_desc[] __initdata = {
0307 {
0308 .virtual = H2P2_DBG_FPGA_BASE,
0309 .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
0310 .length = H2P2_DBG_FPGA_SIZE,
0311 .type = MT_DEVICE
0312 }
0313 };
0314
0315 static void __init omap_perseus2_map_io(void)
0316 {
0317 omap7xx_map_io();
0318 iotable_init(omap_perseus2_io_desc,
0319 ARRAY_SIZE(omap_perseus2_io_desc));
0320 }
0321
0322 MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
0323
0324 .atag_offset = 0x100,
0325 .map_io = omap_perseus2_map_io,
0326 .init_early = omap1_init_early,
0327 .init_irq = omap1_init_irq,
0328 .handle_irq = omap1_handle_irq,
0329 .init_machine = omap_perseus2_init,
0330 .init_late = omap1_init_late,
0331 .init_time = omap1_timer_init,
0332 .restart = omap1_restart,
0333 MACHINE_END