Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/boards/renesas/r7780rp/setup.c |
| 3 | * |
| 4 | * Copyright (C) 2002 Atom Create Engineering Co., Ltd. |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 5 | * Copyright (C) 2005 - 2007 Paul Mundt |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 6 | * |
| 7 | * Renesas Solutions Highlander R7780RP-1 Support. |
| 8 | * |
| 9 | * This file is subject to the terms and conditions of the GNU General Public |
| 10 | * License. See the file "COPYING" in the main directory of this archive |
| 11 | * for more details. |
| 12 | */ |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 15 | #include <linux/pata_platform.h> |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 16 | #include <asm/machvec.h> |
Paul Mundt | 082c44d | 2006-10-19 16:16:18 +0900 | [diff] [blame] | 17 | #include <asm/r7780rp.h> |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 18 | #include <asm/clock.h> |
| 19 | #include <asm/io.h> |
| 20 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 21 | extern void init_r7780rp_IRQ(void); |
| 22 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 23 | static struct resource m66596_usb_host_resources[] = { |
| 24 | [0] = { |
| 25 | .start = 0xa4800000, |
| 26 | .end = 0xa4ffffff, |
| 27 | .flags = IORESOURCE_MEM, |
| 28 | }, |
| 29 | [1] = { |
| 30 | .start = 6, /* irq number */ |
| 31 | .end = 6, |
| 32 | .flags = IORESOURCE_IRQ, |
| 33 | }, |
| 34 | }; |
| 35 | |
| 36 | static struct platform_device m66596_usb_host_device = { |
| 37 | .name = "m66596-hcd", |
| 38 | .id = 0, |
| 39 | .dev = { |
| 40 | .dma_mask = NULL, /* don't use dma */ |
| 41 | .coherent_dma_mask = 0xffffffff, |
| 42 | }, |
| 43 | .num_resources = ARRAY_SIZE(m66596_usb_host_resources), |
| 44 | .resource = m66596_usb_host_resources, |
| 45 | }; |
| 46 | |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 47 | static struct resource cf_ide_resources[] = { |
| 48 | [0] = { |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 49 | .start = PA_AREA5_IO + 0x1000, |
| 50 | .end = PA_AREA5_IO + 0x1000 + 0x08 - 1, |
| 51 | .flags = IORESOURCE_MEM, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 52 | }, |
| 53 | [1] = { |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 54 | .start = PA_AREA5_IO + 0x80c, |
| 55 | .end = PA_AREA5_IO + 0x80c + 0x16 - 1, |
| 56 | .flags = IORESOURCE_MEM, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 57 | }, |
| 58 | [2] = { |
| 59 | #ifdef CONFIG_SH_R7780MP |
| 60 | .start = 1, |
| 61 | #else |
| 62 | .start = 4, |
| 63 | #endif |
| 64 | .flags = IORESOURCE_IRQ, |
| 65 | }, |
| 66 | }; |
| 67 | |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 68 | static struct pata_platform_info pata_info = { |
| 69 | .ioport_shift = 1, |
| 70 | }; |
| 71 | |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 72 | static struct platform_device cf_ide_device = { |
| 73 | .name = "pata_platform", |
| 74 | .id = -1, |
| 75 | .num_resources = ARRAY_SIZE(cf_ide_resources), |
| 76 | .resource = cf_ide_resources, |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 77 | .dev = { |
| 78 | .platform_data = &pata_info, |
| 79 | }, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 80 | }; |
| 81 | |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 82 | static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 }; |
| 83 | |
| 84 | static struct resource heartbeat_resources[] = { |
| 85 | [0] = { |
| 86 | .start = PA_OBLED, |
| 87 | .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1, |
| 88 | .flags = IORESOURCE_MEM, |
| 89 | }, |
| 90 | }; |
| 91 | |
| 92 | static struct platform_device heartbeat_device = { |
| 93 | .name = "heartbeat", |
| 94 | .id = -1, |
| 95 | .dev = { |
| 96 | .platform_data = heartbeat_bit_pos, |
| 97 | }, |
| 98 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
| 99 | .resource = heartbeat_resources, |
| 100 | }; |
| 101 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 102 | static struct platform_device *r7780rp_devices[] __initdata = { |
| 103 | &m66596_usb_host_device, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 104 | &cf_ide_device, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 105 | &heartbeat_device, |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | static int __init r7780rp_devices_setup(void) |
| 109 | { |
| 110 | return platform_add_devices(r7780rp_devices, |
| 111 | ARRAY_SIZE(r7780rp_devices)); |
| 112 | } |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 113 | |
| 114 | /* |
| 115 | * Platform specific clocks |
| 116 | */ |
| 117 | static void ivdr_clk_enable(struct clk *clk) |
| 118 | { |
| 119 | ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL); |
| 120 | } |
| 121 | |
| 122 | static void ivdr_clk_disable(struct clk *clk) |
| 123 | { |
| 124 | ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL); |
| 125 | } |
| 126 | |
| 127 | static struct clk_ops ivdr_clk_ops = { |
| 128 | .enable = ivdr_clk_enable, |
| 129 | .disable = ivdr_clk_disable, |
| 130 | }; |
| 131 | |
| 132 | static struct clk ivdr_clk = { |
| 133 | .name = "ivdr_clk", |
| 134 | .ops = &ivdr_clk_ops, |
| 135 | }; |
| 136 | |
| 137 | static struct clk *r7780rp_clocks[] = { |
| 138 | &ivdr_clk, |
| 139 | }; |
| 140 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 141 | static void r7780rp_power_off(void) |
| 142 | { |
| 143 | #ifdef CONFIG_SH_R7780MP |
| 144 | ctrl_outw(0x0001, PA_POFF); |
| 145 | #endif |
| 146 | } |
| 147 | |
| 148 | /* |
| 149 | * Initialize the board |
| 150 | */ |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 151 | static void __init r7780rp_setup(char **cmdline_p) |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 152 | { |
| 153 | u16 ver = ctrl_inw(PA_VERREG); |
| 154 | int i; |
| 155 | |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 156 | device_initcall(r7780rp_devices_setup); |
| 157 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 158 | printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n"); |
| 159 | |
| 160 | printk(KERN_INFO "Board version: %d (revision %d), " |
| 161 | "FPGA version: %d (revision %d)\n", |
| 162 | (ver >> 12) & 0xf, (ver >> 8) & 0xf, |
| 163 | (ver >> 4) & 0xf, ver & 0xf); |
| 164 | |
| 165 | /* |
| 166 | * Enable the important clocks right away.. |
| 167 | */ |
| 168 | for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) { |
| 169 | struct clk *clk = r7780rp_clocks[i]; |
| 170 | |
| 171 | clk_register(clk); |
| 172 | clk_enable(clk); |
| 173 | } |
| 174 | |
| 175 | ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */ |
| 176 | #ifndef CONFIG_SH_R7780MP |
| 177 | ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */ |
| 178 | #endif |
Paul Mundt | 2c081e7 | 2006-12-25 18:28:33 +0900 | [diff] [blame] | 179 | ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */ |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 180 | |
| 181 | pm_power_off = r7780rp_power_off; |
| 182 | } |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 183 | |
| 184 | /* |
| 185 | * The Machine Vector |
| 186 | */ |
| 187 | struct sh_machine_vector mv_r7780rp __initmv = { |
| 188 | .mv_name = "Highlander R7780RP-1", |
| 189 | .mv_setup = r7780rp_setup, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 190 | .mv_nr_irqs = 109, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 191 | .mv_init_irq = init_r7780rp_IRQ, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 192 | }; |
| 193 | ALIAS_MV(r7780rp) |