Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * KFR2R09 board support code |
| 3 | * |
| 4 | * Copyright (C) 2009 Magnus Damm |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file "COPYING" in the main directory of this archive |
| 8 | * for more details. |
| 9 | */ |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/platform_device.h> |
| 12 | #include <linux/interrupt.h> |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame] | 13 | #include <linux/mtd/physmap.h> |
Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 14 | #include <linux/delay.h> |
| 15 | #include <linux/clk.h> |
| 16 | #include <linux/gpio.h> |
Magnus Damm | 39a6bf1 | 2009-07-22 16:23:45 +0000 | [diff] [blame] | 17 | #include <linux/input.h> |
Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 18 | #include <asm/clock.h> |
| 19 | #include <asm/machvec.h> |
| 20 | #include <asm/io.h> |
Magnus Damm | 39a6bf1 | 2009-07-22 16:23:45 +0000 | [diff] [blame] | 21 | #include <asm/sh_keysc.h> |
Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 22 | #include <cpu/sh7724.h> |
| 23 | |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame] | 24 | static struct mtd_partition kfr2r09_nor_flash_partitions[] = |
| 25 | { |
| 26 | { |
| 27 | .name = "boot", |
| 28 | .offset = 0, |
| 29 | .size = (4 * 1024 * 1024), |
| 30 | .mask_flags = MTD_WRITEABLE, /* Read-only */ |
| 31 | }, |
| 32 | { |
| 33 | .name = "other", |
| 34 | .offset = MTDPART_OFS_APPEND, |
| 35 | .size = MTDPART_SIZ_FULL, |
| 36 | }, |
| 37 | }; |
| 38 | |
| 39 | static struct physmap_flash_data kfr2r09_nor_flash_data = { |
| 40 | .width = 2, |
| 41 | .parts = kfr2r09_nor_flash_partitions, |
| 42 | .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions), |
| 43 | }; |
| 44 | |
| 45 | static struct resource kfr2r09_nor_flash_resources[] = { |
| 46 | [0] = { |
| 47 | .name = "NOR Flash", |
| 48 | .start = 0x00000000, |
| 49 | .end = 0x03ffffff, |
| 50 | .flags = IORESOURCE_MEM, |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | static struct platform_device kfr2r09_nor_flash_device = { |
| 55 | .name = "physmap-flash", |
| 56 | .resource = kfr2r09_nor_flash_resources, |
| 57 | .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources), |
| 58 | .dev = { |
| 59 | .platform_data = &kfr2r09_nor_flash_data, |
| 60 | }, |
| 61 | }; |
| 62 | |
Magnus Damm | 39a6bf1 | 2009-07-22 16:23:45 +0000 | [diff] [blame] | 63 | static struct sh_keysc_info kfr2r09_sh_keysc_info = { |
| 64 | .mode = SH_KEYSC_MODE_1, /* KEYOUT0->4, KEYIN0->4 */ |
| 65 | .scan_timing = 3, |
| 66 | .delay = 10, |
| 67 | .keycodes = { |
| 68 | KEY_PHONE, KEY_CLEAR, KEY_MAIL, KEY_WWW, KEY_ENTER, |
| 69 | KEY_1, KEY_2, KEY_3, 0, KEY_UP, |
| 70 | KEY_4, KEY_5, KEY_6, 0, KEY_LEFT, |
| 71 | KEY_7, KEY_8, KEY_9, KEY_PROG1, KEY_RIGHT, |
| 72 | KEY_S, KEY_0, KEY_P, KEY_PROG2, KEY_DOWN, |
| 73 | 0, 0, 0, 0, 0 |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | static struct resource kfr2r09_sh_keysc_resources[] = { |
| 78 | [0] = { |
| 79 | .name = "KEYSC", |
| 80 | .start = 0x044b0000, |
| 81 | .end = 0x044b000f, |
| 82 | .flags = IORESOURCE_MEM, |
| 83 | }, |
| 84 | [1] = { |
| 85 | .start = 79, |
| 86 | .flags = IORESOURCE_IRQ, |
| 87 | }, |
| 88 | }; |
| 89 | |
| 90 | static struct platform_device kfr2r09_sh_keysc_device = { |
| 91 | .name = "sh_keysc", |
| 92 | .id = 0, /* "keysc0" clock */ |
| 93 | .num_resources = ARRAY_SIZE(kfr2r09_sh_keysc_resources), |
| 94 | .resource = kfr2r09_sh_keysc_resources, |
| 95 | .dev = { |
| 96 | .platform_data = &kfr2r09_sh_keysc_info, |
| 97 | }, |
Magnus Damm | 442c375 | 2009-07-31 07:48:21 +0000 | [diff] [blame^] | 98 | .archdata = { |
| 99 | .hwblk_id = HWBLK_KEYSC, |
| 100 | }, |
Magnus Damm | 39a6bf1 | 2009-07-22 16:23:45 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame] | 103 | static struct platform_device *kfr2r09_devices[] __initdata = { |
| 104 | &kfr2r09_nor_flash_device, |
Magnus Damm | 39a6bf1 | 2009-07-22 16:23:45 +0000 | [diff] [blame] | 105 | &kfr2r09_sh_keysc_device, |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | #define BSC_CS0BCR 0xfec10004 |
| 109 | #define BSC_CS0WCR 0xfec10024 |
| 110 | |
Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 111 | static int __init kfr2r09_devices_setup(void) |
| 112 | { |
| 113 | /* enable SCIF1 serial port for YC401 console support */ |
| 114 | gpio_request(GPIO_FN_SCIF1_RXD, NULL); |
| 115 | gpio_request(GPIO_FN_SCIF1_TXD, NULL); |
| 116 | |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame] | 117 | /* setup NOR flash at CS0 */ |
| 118 | ctrl_outl(0x36db0400, BSC_CS0BCR); |
| 119 | ctrl_outl(0x00000500, BSC_CS0WCR); |
| 120 | |
Magnus Damm | 39a6bf1 | 2009-07-22 16:23:45 +0000 | [diff] [blame] | 121 | /* setup KEYSC pins */ |
| 122 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
| 123 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
| 124 | gpio_request(GPIO_FN_KEYOUT2, NULL); |
| 125 | gpio_request(GPIO_FN_KEYOUT3, NULL); |
| 126 | gpio_request(GPIO_FN_KEYOUT4_IN6, NULL); |
| 127 | gpio_request(GPIO_FN_KEYIN0, NULL); |
| 128 | gpio_request(GPIO_FN_KEYIN1, NULL); |
| 129 | gpio_request(GPIO_FN_KEYIN2, NULL); |
| 130 | gpio_request(GPIO_FN_KEYIN3, NULL); |
| 131 | gpio_request(GPIO_FN_KEYIN4, NULL); |
| 132 | gpio_request(GPIO_FN_KEYOUT5_IN5, NULL); |
| 133 | |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame] | 134 | return platform_add_devices(kfr2r09_devices, |
| 135 | ARRAY_SIZE(kfr2r09_devices)); |
Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 136 | } |
| 137 | device_initcall(kfr2r09_devices_setup); |
| 138 | |
| 139 | /* Return the board specific boot mode pin configuration */ |
| 140 | static int kfr2r09_mode_pins(void) |
| 141 | { |
| 142 | /* MD0=1, MD1=1, MD2=0: Clock Mode 3 |
| 143 | * MD3=0: 16-bit Area0 Bus Width |
| 144 | * MD5=1: Little Endian |
| 145 | * MD8=1: Test Mode Disabled |
| 146 | */ |
| 147 | return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8; |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | * The Machine Vector |
| 152 | */ |
| 153 | static struct sh_machine_vector mv_kfr2r09 __initmv = { |
| 154 | .mv_name = "kfr2r09", |
| 155 | .mv_mode_pins = kfr2r09_mode_pins, |
| 156 | }; |