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> |
| 17 | #include <asm/clock.h> |
| 18 | #include <asm/machvec.h> |
| 19 | #include <asm/io.h> |
| 20 | #include <cpu/sh7724.h> |
| 21 | |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame^] | 22 | static struct mtd_partition kfr2r09_nor_flash_partitions[] = |
| 23 | { |
| 24 | { |
| 25 | .name = "boot", |
| 26 | .offset = 0, |
| 27 | .size = (4 * 1024 * 1024), |
| 28 | .mask_flags = MTD_WRITEABLE, /* Read-only */ |
| 29 | }, |
| 30 | { |
| 31 | .name = "other", |
| 32 | .offset = MTDPART_OFS_APPEND, |
| 33 | .size = MTDPART_SIZ_FULL, |
| 34 | }, |
| 35 | }; |
| 36 | |
| 37 | static struct physmap_flash_data kfr2r09_nor_flash_data = { |
| 38 | .width = 2, |
| 39 | .parts = kfr2r09_nor_flash_partitions, |
| 40 | .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions), |
| 41 | }; |
| 42 | |
| 43 | static struct resource kfr2r09_nor_flash_resources[] = { |
| 44 | [0] = { |
| 45 | .name = "NOR Flash", |
| 46 | .start = 0x00000000, |
| 47 | .end = 0x03ffffff, |
| 48 | .flags = IORESOURCE_MEM, |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | static struct platform_device kfr2r09_nor_flash_device = { |
| 53 | .name = "physmap-flash", |
| 54 | .resource = kfr2r09_nor_flash_resources, |
| 55 | .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources), |
| 56 | .dev = { |
| 57 | .platform_data = &kfr2r09_nor_flash_data, |
| 58 | }, |
| 59 | }; |
| 60 | |
| 61 | static struct platform_device *kfr2r09_devices[] __initdata = { |
| 62 | &kfr2r09_nor_flash_device, |
| 63 | }; |
| 64 | |
| 65 | #define BSC_CS0BCR 0xfec10004 |
| 66 | #define BSC_CS0WCR 0xfec10024 |
| 67 | |
Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 68 | static int __init kfr2r09_devices_setup(void) |
| 69 | { |
| 70 | /* enable SCIF1 serial port for YC401 console support */ |
| 71 | gpio_request(GPIO_FN_SCIF1_RXD, NULL); |
| 72 | gpio_request(GPIO_FN_SCIF1_TXD, NULL); |
| 73 | |
Magnus Damm | a366aa64 | 2009-07-22 16:22:28 +0000 | [diff] [blame^] | 74 | /* setup NOR flash at CS0 */ |
| 75 | ctrl_outl(0x36db0400, BSC_CS0BCR); |
| 76 | ctrl_outl(0x00000500, BSC_CS0WCR); |
| 77 | |
| 78 | return platform_add_devices(kfr2r09_devices, |
| 79 | ARRAY_SIZE(kfr2r09_devices)); |
Magnus Damm | e7d1651 | 2009-07-22 16:20:54 +0000 | [diff] [blame] | 80 | } |
| 81 | device_initcall(kfr2r09_devices_setup); |
| 82 | |
| 83 | /* Return the board specific boot mode pin configuration */ |
| 84 | static int kfr2r09_mode_pins(void) |
| 85 | { |
| 86 | /* MD0=1, MD1=1, MD2=0: Clock Mode 3 |
| 87 | * MD3=0: 16-bit Area0 Bus Width |
| 88 | * MD5=1: Little Endian |
| 89 | * MD8=1: Test Mode Disabled |
| 90 | */ |
| 91 | return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8; |
| 92 | } |
| 93 | |
| 94 | /* |
| 95 | * The Machine Vector |
| 96 | */ |
| 97 | static struct sh_machine_vector mv_kfr2r09 __initmv = { |
| 98 | .mv_name = "kfr2r09", |
| 99 | .mv_mode_pins = kfr2r09_mode_pins, |
| 100 | }; |