Kuninori Morimoto | 5ac072e | 2009-03-03 16:22:00 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Renesas Technology Corp. SH7786 Urquell Support. |
| 3 | * |
| 4 | * Copyright (C) 2008 Kuninori Morimoto <morimoto.kuninori@renesas.com> |
| 5 | * Copyright (C) 2008 Yoshihiro Shimoda |
| 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License. See the file "COPYING" in the main directory of this archive |
| 9 | * for more details. |
| 10 | */ |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/fb.h> |
Kuninori Morimoto | 929ef1a | 2009-03-05 17:37:12 +0900 | [diff] [blame] | 14 | #include <linux/smc91x.h> |
Kuninori Morimoto | 5ac072e | 2009-03-03 16:22:00 +0900 | [diff] [blame] | 15 | #include <linux/mtd/physmap.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/gpio.h> |
| 18 | #include <linux/irq.h> |
| 19 | #include <mach/urquell.h> |
| 20 | #include <cpu/sh7786.h> |
| 21 | #include <asm/heartbeat.h> |
| 22 | #include <asm/sizes.h> |
| 23 | |
| 24 | static struct resource heartbeat_resources[] = { |
| 25 | [0] = { |
| 26 | .start = BOARDREG(SLEDR), |
| 27 | .end = BOARDREG(SLEDR), |
| 28 | .flags = IORESOURCE_MEM, |
| 29 | }, |
| 30 | }; |
| 31 | |
| 32 | static struct heartbeat_data heartbeat_data = { |
| 33 | .regsize = 16, |
| 34 | }; |
| 35 | |
| 36 | static struct platform_device heartbeat_device = { |
| 37 | .name = "heartbeat", |
| 38 | .id = -1, |
| 39 | .dev = { |
| 40 | .platform_data = &heartbeat_data, |
| 41 | }, |
| 42 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
| 43 | .resource = heartbeat_resources, |
| 44 | }; |
| 45 | |
Kuninori Morimoto | 929ef1a | 2009-03-05 17:37:12 +0900 | [diff] [blame] | 46 | static struct smc91x_platdata smc91x_info = { |
| 47 | .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, |
| 48 | }; |
| 49 | |
| 50 | static struct resource smc91x_eth_resources[] = { |
| 51 | [0] = { |
| 52 | .name = "SMC91C111" , |
| 53 | .start = 0x05800300, |
| 54 | .end = 0x0580030f, |
| 55 | .flags = IORESOURCE_MEM, |
| 56 | }, |
| 57 | [1] = { |
| 58 | .start = 11, |
| 59 | .flags = IORESOURCE_IRQ, |
| 60 | }, |
| 61 | }; |
| 62 | |
| 63 | static struct platform_device smc91x_eth_device = { |
| 64 | .name = "smc91x", |
| 65 | .num_resources = ARRAY_SIZE(smc91x_eth_resources), |
| 66 | .resource = smc91x_eth_resources, |
| 67 | .dev = { |
| 68 | .platform_data = &smc91x_info, |
| 69 | }, |
| 70 | }; |
| 71 | |
Kuninori Morimoto | 5ac072e | 2009-03-03 16:22:00 +0900 | [diff] [blame] | 72 | static struct mtd_partition nor_flash_partitions[] = { |
| 73 | { |
| 74 | .name = "loader", |
| 75 | .offset = 0x00000000, |
| 76 | .size = SZ_512K, |
| 77 | .mask_flags = MTD_WRITEABLE, /* Read-only */ |
| 78 | }, |
| 79 | { |
| 80 | .name = "bootenv", |
| 81 | .offset = MTDPART_OFS_APPEND, |
| 82 | .size = SZ_512K, |
| 83 | .mask_flags = MTD_WRITEABLE, /* Read-only */ |
| 84 | }, |
| 85 | { |
| 86 | .name = "kernel", |
| 87 | .offset = MTDPART_OFS_APPEND, |
| 88 | .size = SZ_4M, |
| 89 | }, |
| 90 | { |
| 91 | .name = "data", |
| 92 | .offset = MTDPART_OFS_APPEND, |
| 93 | .size = MTDPART_SIZ_FULL, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct physmap_flash_data nor_flash_data = { |
| 98 | .width = 2, |
| 99 | .parts = nor_flash_partitions, |
| 100 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 101 | }; |
| 102 | |
| 103 | static struct resource nor_flash_resources[] = { |
| 104 | [0] = { |
| 105 | .start = NOR_FLASH_ADDR, |
| 106 | .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1, |
| 107 | .flags = IORESOURCE_MEM, |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | static struct platform_device nor_flash_device = { |
| 112 | .name = "physmap-flash", |
| 113 | .dev = { |
| 114 | .platform_data = &nor_flash_data, |
| 115 | }, |
| 116 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 117 | .resource = nor_flash_resources, |
| 118 | }; |
| 119 | |
| 120 | static struct platform_device *urquell_devices[] __initdata = { |
| 121 | &heartbeat_device, |
Kuninori Morimoto | 929ef1a | 2009-03-05 17:37:12 +0900 | [diff] [blame] | 122 | &smc91x_eth_device, |
Kuninori Morimoto | 5ac072e | 2009-03-03 16:22:00 +0900 | [diff] [blame] | 123 | &nor_flash_device, |
| 124 | }; |
| 125 | |
| 126 | static int __init urquell_devices_setup(void) |
| 127 | { |
| 128 | /* USB */ |
| 129 | gpio_request(GPIO_FN_USB_OVC0, NULL); |
| 130 | gpio_request(GPIO_FN_USB_PENC0, NULL); |
| 131 | |
| 132 | return platform_add_devices(urquell_devices, |
| 133 | ARRAY_SIZE(urquell_devices)); |
| 134 | } |
| 135 | device_initcall(urquell_devices_setup); |
| 136 | |
| 137 | static void urquell_power_off(void) |
| 138 | { |
| 139 | __raw_writew(0xa5a5, UBOARDREG(SRSTR)); |
| 140 | } |
| 141 | |
Kuninori Morimoto | 929ef1a | 2009-03-05 17:37:12 +0900 | [diff] [blame] | 142 | static void __init urquell_init_irq(void) |
| 143 | { |
| 144 | plat_irq_setup_pins(IRQ_MODE_IRL3210_MASK); |
| 145 | } |
| 146 | |
Kuninori Morimoto | 5ac072e | 2009-03-03 16:22:00 +0900 | [diff] [blame] | 147 | /* Initialize the board */ |
| 148 | static void __init urquell_setup(char **cmdline_p) |
| 149 | { |
| 150 | printk(KERN_INFO "Renesas Technology Corp. Urquell support.\n"); |
| 151 | |
| 152 | pm_power_off = urquell_power_off; |
| 153 | } |
| 154 | |
| 155 | /* |
| 156 | * The Machine Vector |
| 157 | */ |
| 158 | static struct sh_machine_vector mv_urquell __initmv = { |
| 159 | .mv_name = "Urquell", |
| 160 | .mv_setup = urquell_setup, |
Kuninori Morimoto | 929ef1a | 2009-03-05 17:37:12 +0900 | [diff] [blame] | 161 | .mv_init_irq = urquell_init_irq, |
Kuninori Morimoto | 5ac072e | 2009-03-03 16:22:00 +0900 | [diff] [blame] | 162 | }; |