1 // SPDX-License-Identifier: GPL-2.0
3 * arch/sh/boards/renesas/r7780rp/setup.c
5 * Renesas Solutions Highlander Support.
7 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
8 * Copyright (C) 2005 - 2008 Paul Mundt
10 * This contains support for the R7780RP-1, R7780MP, and R7785RP
13 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/ata_platform.h>
17 #include <linux/types.h>
18 #include <linux/mtd/physmap.h>
19 #include <linux/i2c.h>
20 #include <linux/irq.h>
21 #include <linux/interrupt.h>
22 #include <linux/usb/r8a66597.h>
23 #include <linux/usb/m66592.h>
24 #include <linux/clkdev.h>
25 #include <net/ax88796.h>
26 #include <asm/machvec.h>
27 #include <mach/highlander.h>
28 #include <asm/clock.h>
29 #include <asm/heartbeat.h>
31 #include <asm/io_trapped.h>
33 static struct r8a66597_platdata r8a66597_data
= {
34 .xtal
= R8A66597_PLATDATA_XTAL_12MHZ
,
38 static struct resource r8a66597_usb_host_resources
[] = {
42 .flags
= IORESOURCE_MEM
,
45 .start
= IRQ_EXT1
, /* irq number */
47 .flags
= IORESOURCE_IRQ
| IRQF_TRIGGER_LOW
,
51 static struct platform_device r8a66597_usb_host_device
= {
52 .name
= "r8a66597_hcd",
55 .dma_mask
= NULL
, /* don't use dma */
56 .coherent_dma_mask
= 0xffffffff,
57 .platform_data
= &r8a66597_data
,
59 .num_resources
= ARRAY_SIZE(r8a66597_usb_host_resources
),
60 .resource
= r8a66597_usb_host_resources
,
63 static struct m66592_platdata usbf_platdata
= {
64 .xtal
= M66592_PLATDATA_XTAL_24MHZ
,
68 static struct resource m66592_usb_peripheral_resources
[] = {
73 .flags
= IORESOURCE_MEM
,
77 .start
= IRQ_EXT4
, /* irq number */
79 .flags
= IORESOURCE_IRQ
,
83 static struct platform_device m66592_usb_peripheral_device
= {
87 .dma_mask
= NULL
, /* don't use dma */
88 .coherent_dma_mask
= 0xffffffff,
89 .platform_data
= &usbf_platdata
,
91 .num_resources
= ARRAY_SIZE(m66592_usb_peripheral_resources
),
92 .resource
= m66592_usb_peripheral_resources
,
95 static struct resource cf_ide_resources
[] = {
97 .start
= PA_AREA5_IO
+ 0x1000,
98 .end
= PA_AREA5_IO
+ 0x1000 + 0x08 - 1,
99 .flags
= IORESOURCE_MEM
,
102 .start
= PA_AREA5_IO
+ 0x80c,
103 .end
= PA_AREA5_IO
+ 0x80c + 0x16 - 1,
104 .flags
= IORESOURCE_MEM
,
108 .flags
= IORESOURCE_IRQ
,
112 static struct pata_platform_info pata_info
= {
116 static struct platform_device cf_ide_device
= {
117 .name
= "pata_platform",
119 .num_resources
= ARRAY_SIZE(cf_ide_resources
),
120 .resource
= cf_ide_resources
,
122 .platform_data
= &pata_info
,
126 static struct resource heartbeat_resources
[] = {
130 .flags
= IORESOURCE_MEM
,
134 #ifndef CONFIG_SH_R7785RP
135 static unsigned char heartbeat_bit_pos
[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
137 static struct heartbeat_data heartbeat_data
= {
138 .bit_pos
= heartbeat_bit_pos
,
139 .nr_bits
= ARRAY_SIZE(heartbeat_bit_pos
),
143 static struct platform_device heartbeat_device
= {
147 /* R7785RP has a slightly more sensible FPGA.. */
148 #ifndef CONFIG_SH_R7785RP
150 .platform_data
= &heartbeat_data
,
153 .num_resources
= ARRAY_SIZE(heartbeat_resources
),
154 .resource
= heartbeat_resources
,
157 static struct ax_plat_data ax88796_platdata
= {
158 .flags
= AXFLG_HAS_93CX6
,
164 static struct resource ax88796_resources
[] = {
166 #ifdef CONFIG_SH_R7780RP
168 .end
= 0xa5800400 + (0x20 * 0x2) - 1,
171 .end
= 0xa4100400 + (0x20 * 0x2) - 1,
173 .flags
= IORESOURCE_MEM
,
176 .start
= IRQ_AX88796
,
178 .flags
= IORESOURCE_IRQ
,
182 static struct platform_device ax88796_device
= {
187 .platform_data
= &ax88796_platdata
,
190 .num_resources
= ARRAY_SIZE(ax88796_resources
),
191 .resource
= ax88796_resources
,
194 static struct mtd_partition nor_flash_partitions
[] = {
197 .offset
= 0x00000000,
202 .offset
= MTDPART_OFS_APPEND
,
207 .offset
= MTDPART_OFS_APPEND
,
208 .size
= 4 * 1024 * 1024,
212 .offset
= MTDPART_OFS_APPEND
,
213 .size
= MTDPART_SIZ_FULL
,
217 static struct physmap_flash_data nor_flash_data
= {
219 .parts
= nor_flash_partitions
,
220 .nr_parts
= ARRAY_SIZE(nor_flash_partitions
),
223 /* This config is flash board for mass production. */
224 static struct resource nor_flash_resources
[] = {
226 .start
= PA_NORFLASH_ADDR
,
227 .end
= PA_NORFLASH_ADDR
+ PA_NORFLASH_SIZE
- 1,
228 .flags
= IORESOURCE_MEM
,
232 static struct platform_device nor_flash_device
= {
233 .name
= "physmap-flash",
235 .platform_data
= &nor_flash_data
,
237 .num_resources
= ARRAY_SIZE(nor_flash_resources
),
238 .resource
= nor_flash_resources
,
241 static struct resource smbus_resources
[] = {
244 .end
= PA_SMCR
+ 0x100 - 1,
245 .flags
= IORESOURCE_MEM
,
250 .flags
= IORESOURCE_IRQ
,
254 static struct platform_device smbus_device
= {
255 .name
= "i2c-highlander",
257 .num_resources
= ARRAY_SIZE(smbus_resources
),
258 .resource
= smbus_resources
,
261 static struct i2c_board_info __initdata highlander_i2c_devices
[] = {
263 I2C_BOARD_INFO("r2025sd", 0x32),
267 static struct platform_device
*r7780rp_devices
[] __initdata
= {
268 &r8a66597_usb_host_device
,
269 &m66592_usb_peripheral_device
,
273 #ifndef CONFIG_SH_R7780RP
279 * The CF is connected using a 16-bit bus where 8-bit operations are
280 * unsupported. The linux ata driver is however using 8-bit operations, so
281 * insert a trapped io filter to convert 8-bit operations into 16-bit.
283 static struct trapped_io cf_trapped_io
= {
284 .resource
= cf_ide_resources
,
286 .minimum_bus_width
= 16,
289 static int __init
r7780rp_devices_setup(void)
293 #ifndef CONFIG_SH_R7780RP
294 if (register_trapped_io(&cf_trapped_io
) == 0)
295 ret
|= platform_device_register(&cf_ide_device
);
298 ret
|= platform_add_devices(r7780rp_devices
,
299 ARRAY_SIZE(r7780rp_devices
));
301 ret
|= i2c_register_board_info(0, highlander_i2c_devices
,
302 ARRAY_SIZE(highlander_i2c_devices
));
306 device_initcall(r7780rp_devices_setup
);
309 * Platform specific clocks
311 static int ivdr_clk_enable(struct clk
*clk
)
313 __raw_writew(__raw_readw(PA_IVDRCTL
) | (1 << IVDR_CK_ON
), PA_IVDRCTL
);
317 static void ivdr_clk_disable(struct clk
*clk
)
319 __raw_writew(__raw_readw(PA_IVDRCTL
) & ~(1 << IVDR_CK_ON
), PA_IVDRCTL
);
322 static struct sh_clk_ops ivdr_clk_ops
= {
323 .enable
= ivdr_clk_enable
,
324 .disable
= ivdr_clk_disable
,
327 static struct clk ivdr_clk
= {
328 .ops
= &ivdr_clk_ops
,
331 static struct clk
*r7780rp_clocks
[] = {
335 static struct clk_lookup lookups
[] = {
337 CLKDEV_CON_ID("ivdr_clk", &ivdr_clk
),
340 static void r7780rp_power_off(void)
342 if (mach_is_r7780mp() || mach_is_r7785rp())
343 __raw_writew(0x0001, PA_POFF
);
347 * Initialize the board
349 static void __init
highlander_setup(char **cmdline_p
)
351 u16 ver
= __raw_readw(PA_VERREG
);
354 printk(KERN_INFO
"Renesas Solutions Highlander %s support.\n",
355 mach_is_r7780rp() ? "R7780RP-1" :
356 mach_is_r7780mp() ? "R7780MP" :
359 printk(KERN_INFO
"Board version: %d (revision %d), "
360 "FPGA version: %d (revision %d)\n",
361 (ver
>> 12) & 0xf, (ver
>> 8) & 0xf,
362 (ver
>> 4) & 0xf, ver
& 0xf);
364 highlander_plat_pinmux_setup();
367 * Enable the important clocks right away..
369 for (i
= 0; i
< ARRAY_SIZE(r7780rp_clocks
); i
++) {
370 struct clk
*clk
= r7780rp_clocks
[i
];
376 clkdev_add_table(lookups
, ARRAY_SIZE(lookups
));
378 __raw_writew(0x0000, PA_OBLED
); /* Clear LED. */
380 if (mach_is_r7780rp())
381 __raw_writew(0x0001, PA_SDPOW
); /* SD Power ON */
383 __raw_writew(__raw_readw(PA_IVDRCTL
) | 0x01, PA_IVDRCTL
); /* Si13112 */
385 pm_power_off
= r7780rp_power_off
;
388 static unsigned char irl2irq
[HL_NR_IRL
];
390 static int highlander_irq_demux(int irq
)
392 if (irq
>= HL_NR_IRL
|| irq
< 0 || !irl2irq
[irq
])
398 static void __init
highlander_init_irq(void)
400 unsigned char *ucp
= highlander_plat_irq_setup();
403 plat_irq_setup_pins(IRQ_MODE_IRL3210
);
404 memcpy(irl2irq
, ucp
, HL_NR_IRL
);
411 static struct sh_machine_vector mv_highlander __initmv
= {
412 .mv_name
= "Highlander",
413 .mv_setup
= highlander_setup
,
414 .mv_init_irq
= highlander_init_irq
,
415 .mv_irq_demux
= highlander_irq_demux
,