Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * sh7372 processor support |
| 3 | * |
| 4 | * Copyright (C) 2010 Magnus Damm |
| 5 | * Copyright (C) 2008 Yoshihiro Shimoda |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/interrupt.h> |
| 23 | #include <linux/irq.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/delay.h> |
| 26 | #include <linux/input.h> |
| 27 | #include <linux/io.h> |
| 28 | #include <linux/serial_sci.h> |
| 29 | #include <linux/sh_intc.h> |
| 30 | #include <linux/sh_timer.h> |
| 31 | #include <mach/hardware.h> |
| 32 | #include <asm/mach-types.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | |
Kuninori Morimoto | c1909cc | 2010-03-11 10:42:47 +0000 | [diff] [blame^] | 35 | /* SCIF */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 36 | static struct plat_sci_port scif0_platform_data = { |
| 37 | .mapbase = 0xe6c40000, |
| 38 | .flags = UPF_BOOT_AUTOCONF, |
| 39 | .type = PORT_SCIF, |
| 40 | .irqs = { 80, 80, 80, 80 }, |
| 41 | }; |
| 42 | |
| 43 | static struct platform_device scif0_device = { |
| 44 | .name = "sh-sci", |
| 45 | .id = 0, |
| 46 | .dev = { |
| 47 | .platform_data = &scif0_platform_data, |
| 48 | }, |
| 49 | }; |
| 50 | |
| 51 | static struct plat_sci_port scif1_platform_data = { |
| 52 | .mapbase = 0xe6c50000, |
| 53 | .flags = UPF_BOOT_AUTOCONF, |
| 54 | .type = PORT_SCIF, |
| 55 | .irqs = { 81, 81, 81, 81 }, |
| 56 | }; |
| 57 | |
| 58 | static struct platform_device scif1_device = { |
| 59 | .name = "sh-sci", |
| 60 | .id = 1, |
| 61 | .dev = { |
| 62 | .platform_data = &scif1_platform_data, |
| 63 | }, |
| 64 | }; |
| 65 | |
| 66 | static struct plat_sci_port scif2_platform_data = { |
| 67 | .mapbase = 0xe6c60000, |
| 68 | .flags = UPF_BOOT_AUTOCONF, |
| 69 | .type = PORT_SCIF, |
| 70 | .irqs = { 82, 82, 82, 82 }, |
| 71 | }; |
| 72 | |
| 73 | static struct platform_device scif2_device = { |
| 74 | .name = "sh-sci", |
| 75 | .id = 2, |
| 76 | .dev = { |
| 77 | .platform_data = &scif2_platform_data, |
| 78 | }, |
| 79 | }; |
| 80 | |
| 81 | static struct plat_sci_port scif3_platform_data = { |
| 82 | .mapbase = 0xe6c70000, |
| 83 | .flags = UPF_BOOT_AUTOCONF, |
| 84 | .type = PORT_SCIF, |
| 85 | .irqs = { 83, 83, 83, 83 }, |
| 86 | }; |
| 87 | |
| 88 | static struct platform_device scif3_device = { |
| 89 | .name = "sh-sci", |
| 90 | .id = 3, |
| 91 | .dev = { |
| 92 | .platform_data = &scif3_platform_data, |
| 93 | }, |
| 94 | }; |
| 95 | |
| 96 | static struct plat_sci_port scif4_platform_data = { |
| 97 | .mapbase = 0xe6c80000, |
| 98 | .flags = UPF_BOOT_AUTOCONF, |
| 99 | .type = PORT_SCIF, |
| 100 | .irqs = { 89, 89, 89, 89 }, |
| 101 | }; |
| 102 | |
| 103 | static struct platform_device scif4_device = { |
| 104 | .name = "sh-sci", |
| 105 | .id = 4, |
| 106 | .dev = { |
| 107 | .platform_data = &scif4_platform_data, |
| 108 | }, |
| 109 | }; |
| 110 | |
| 111 | static struct plat_sci_port scif5_platform_data = { |
| 112 | .mapbase = 0xe6cb0000, |
| 113 | .flags = UPF_BOOT_AUTOCONF, |
| 114 | .type = PORT_SCIF, |
| 115 | .irqs = { 90, 90, 90, 90 }, |
| 116 | }; |
| 117 | |
| 118 | static struct platform_device scif5_device = { |
| 119 | .name = "sh-sci", |
| 120 | .id = 5, |
| 121 | .dev = { |
| 122 | .platform_data = &scif5_platform_data, |
| 123 | }, |
| 124 | }; |
| 125 | |
| 126 | static struct plat_sci_port scif6_platform_data = { |
| 127 | .mapbase = 0xe6c30000, |
| 128 | .flags = UPF_BOOT_AUTOCONF, |
| 129 | .type = PORT_SCIF, |
| 130 | .irqs = { 91, 91, 91, 91 }, |
| 131 | }; |
| 132 | |
| 133 | static struct platform_device scif6_device = { |
| 134 | .name = "sh-sci", |
| 135 | .id = 6, |
| 136 | .dev = { |
| 137 | .platform_data = &scif6_platform_data, |
| 138 | }, |
| 139 | }; |
| 140 | |
Kuninori Morimoto | c1909cc | 2010-03-11 10:42:47 +0000 | [diff] [blame^] | 141 | /* CMT */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 142 | static struct sh_timer_config cmt10_platform_data = { |
| 143 | .name = "CMT10", |
| 144 | .channel_offset = 0x10, |
| 145 | .timer_bit = 0, |
| 146 | .clk = "r_clk", |
| 147 | .clockevent_rating = 125, |
| 148 | .clocksource_rating = 125, |
| 149 | }; |
| 150 | |
| 151 | static struct resource cmt10_resources[] = { |
| 152 | [0] = { |
| 153 | .name = "CMT10", |
| 154 | .start = 0xe6138010, |
| 155 | .end = 0xe613801b, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | }, |
| 158 | [1] = { |
| 159 | .start = 72, |
| 160 | .flags = IORESOURCE_IRQ, |
| 161 | }, |
| 162 | }; |
| 163 | |
| 164 | static struct platform_device cmt10_device = { |
| 165 | .name = "sh_cmt", |
| 166 | .id = 10, |
| 167 | .dev = { |
| 168 | .platform_data = &cmt10_platform_data, |
| 169 | }, |
| 170 | .resource = cmt10_resources, |
| 171 | .num_resources = ARRAY_SIZE(cmt10_resources), |
| 172 | }; |
| 173 | |
Kuninori Morimoto | c1909cc | 2010-03-11 10:42:47 +0000 | [diff] [blame^] | 174 | /* I2C */ |
| 175 | static struct resource iic0_resources[] = { |
| 176 | [0] = { |
| 177 | .name = "IIC0", |
| 178 | .start = 0xFFF20000, |
| 179 | .end = 0xFFF20425 - 1, |
| 180 | .flags = IORESOURCE_MEM, |
| 181 | }, |
| 182 | [1] = { |
| 183 | .start = intcs_evt2irq(0xe00), |
| 184 | .end = intcs_evt2irq(0xe60), |
| 185 | .flags = IORESOURCE_IRQ, |
| 186 | }, |
| 187 | }; |
| 188 | |
| 189 | static struct platform_device iic0_device = { |
| 190 | .name = "i2c-sh_mobile", |
| 191 | .id = 0, /* "i2c0" clock */ |
| 192 | .num_resources = ARRAY_SIZE(iic0_resources), |
| 193 | .resource = iic0_resources, |
| 194 | }; |
| 195 | |
| 196 | static struct resource iic1_resources[] = { |
| 197 | [0] = { |
| 198 | .name = "IIC1", |
| 199 | .start = 0xE6C20000, |
| 200 | .end = 0xE6C20425 - 1, |
| 201 | .flags = IORESOURCE_MEM, |
| 202 | }, |
| 203 | [1] = { |
| 204 | .start = 44, |
| 205 | .end = 47, |
| 206 | .flags = IORESOURCE_IRQ, |
| 207 | }, |
| 208 | }; |
| 209 | |
| 210 | static struct platform_device iic1_device = { |
| 211 | .name = "i2c-sh_mobile", |
| 212 | .id = 1, /* "i2c1" clock */ |
| 213 | .num_resources = ARRAY_SIZE(iic1_resources), |
| 214 | .resource = iic1_resources, |
| 215 | }; |
| 216 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 217 | static struct platform_device *sh7372_early_devices[] __initdata = { |
| 218 | &scif0_device, |
| 219 | &scif1_device, |
| 220 | &scif2_device, |
| 221 | &scif3_device, |
| 222 | &scif4_device, |
| 223 | &scif5_device, |
| 224 | &scif6_device, |
| 225 | &cmt10_device, |
Kuninori Morimoto | c1909cc | 2010-03-11 10:42:47 +0000 | [diff] [blame^] | 226 | &iic0_device, |
| 227 | &iic1_device, |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | void __init sh7372_add_standard_devices(void) |
| 231 | { |
| 232 | platform_add_devices(sh7372_early_devices, |
| 233 | ARRAY_SIZE(sh7372_early_devices)); |
| 234 | } |
| 235 | |
| 236 | #define SMSTPCR3 0xe615013c |
| 237 | #define SMSTPCR3_CMT1 (1 << 29) |
| 238 | |
| 239 | void __init sh7372_add_early_devices(void) |
| 240 | { |
| 241 | /* enable clock to CMT1 */ |
| 242 | __raw_writel(__raw_readl(SMSTPCR3) & ~SMSTPCR3_CMT1, SMSTPCR3); |
| 243 | |
| 244 | early_platform_add_devices(sh7372_early_devices, |
| 245 | ARRAY_SIZE(sh7372_early_devices)); |
| 246 | } |