xref: /linux/arch/sh/boards/mach-sh03/setup.c (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2da2014a2SPaul Mundt /*
3da2014a2SPaul Mundt  * linux/arch/sh/boards/sh03/setup.c
4da2014a2SPaul Mundt  *
5da2014a2SPaul Mundt  * Copyright (C) 2004  Interface Co.,Ltd. Saito.K
6da2014a2SPaul Mundt  *
7da2014a2SPaul Mundt  */
8da2014a2SPaul Mundt 
9da2014a2SPaul Mundt #include <linux/init.h>
10da2014a2SPaul Mundt #include <linux/irq.h>
11da2014a2SPaul Mundt #include <linux/pci.h>
12da2014a2SPaul Mundt #include <linux/platform_device.h>
138db806ecSPaul Mundt #include <linux/ata_platform.h>
14da2014a2SPaul Mundt #include <asm/io.h>
15da2014a2SPaul Mundt #include <asm/rtc.h>
160764bff4SPaul Mundt #include <mach-sh03/mach/io.h>
170764bff4SPaul Mundt #include <mach-sh03/mach/sh03.h>
18da2014a2SPaul Mundt #include <asm/addrspace.h>
19da2014a2SPaul Mundt 
init_sh03_IRQ(void)20da2014a2SPaul Mundt static void __init init_sh03_IRQ(void)
21da2014a2SPaul Mundt {
22da2014a2SPaul Mundt 	plat_irq_setup_pins(IRQ_MODE_IRQ);
23da2014a2SPaul Mundt }
24da2014a2SPaul Mundt 
252ea40decSPaul Mundt static struct resource cf_ide_resources[] = {
262ea40decSPaul Mundt 	[0] = {
272ea40decSPaul Mundt 		.start  = 0x1f0,
282ea40decSPaul Mundt 		.end    = 0x1f0 + 8,
292ea40decSPaul Mundt 		.flags  = IORESOURCE_IO,
302ea40decSPaul Mundt 	},
312ea40decSPaul Mundt 	[1] = {
322ea40decSPaul Mundt 		.start  = 0x1f0 + 0x206,
332ea40decSPaul Mundt 		.end    = 0x1f0 +8 + 0x206 + 8,
342ea40decSPaul Mundt 		.flags  = IORESOURCE_IO,
352ea40decSPaul Mundt 	},
362ea40decSPaul Mundt 	[2] = {
372ea40decSPaul Mundt 		.start  = IRL2_IRQ,
382ea40decSPaul Mundt 		.flags  = IORESOURCE_IRQ,
392ea40decSPaul Mundt 	},
402ea40decSPaul Mundt };
418db806ecSPaul Mundt 
428db806ecSPaul Mundt static struct platform_device cf_ide_device = {
438db806ecSPaul Mundt 	.name		= "pata_platform",
448db806ecSPaul Mundt 	.id		= -1,
458db806ecSPaul Mundt 	.num_resources	= ARRAY_SIZE(cf_ide_resources),
468db806ecSPaul Mundt 	.resource	= cf_ide_resources,
478db806ecSPaul Mundt };
488db806ecSPaul Mundt 
49da2014a2SPaul Mundt static struct resource heartbeat_resources[] = {
50da2014a2SPaul Mundt 	[0] = {
51da2014a2SPaul Mundt 		.start	= 0xa0800000,
52da2014a2SPaul Mundt 		.end	= 0xa0800000,
53da2014a2SPaul Mundt 		.flags	= IORESOURCE_MEM,
54da2014a2SPaul Mundt 	},
55da2014a2SPaul Mundt };
56da2014a2SPaul Mundt 
57da2014a2SPaul Mundt static struct platform_device heartbeat_device = {
58da2014a2SPaul Mundt 	.name		= "heartbeat",
59da2014a2SPaul Mundt 	.id		= -1,
60da2014a2SPaul Mundt 	.num_resources	= ARRAY_SIZE(heartbeat_resources),
61da2014a2SPaul Mundt 	.resource	= heartbeat_resources,
62da2014a2SPaul Mundt };
63da2014a2SPaul Mundt 
64da2014a2SPaul Mundt static struct platform_device *sh03_devices[] __initdata = {
65da2014a2SPaul Mundt 	&heartbeat_device,
668db806ecSPaul Mundt 	&cf_ide_device,
67da2014a2SPaul Mundt };
68da2014a2SPaul Mundt 
sh03_devices_setup(void)69da2014a2SPaul Mundt static int __init sh03_devices_setup(void)
70da2014a2SPaul Mundt {
718db806ecSPaul Mundt 	pgprot_t prot;
728db806ecSPaul Mundt 	unsigned long paddrbase;
738db806ecSPaul Mundt 	void *cf_ide_base;
748db806ecSPaul Mundt 
758db806ecSPaul Mundt 	/* open I/O area window */
768db806ecSPaul Mundt 	paddrbase = virt_to_phys((void *)PA_AREA5_IO);
778db806ecSPaul Mundt 	prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
78f3360934SPaul Mundt 	cf_ide_base = ioremap_prot(paddrbase, PAGE_SIZE, pgprot_val(prot));
798db806ecSPaul Mundt 	if (!cf_ide_base) {
808db806ecSPaul Mundt 		printk("allocate_cf_area : can't open CF I/O window!\n");
818db806ecSPaul Mundt 		return -ENOMEM;
828db806ecSPaul Mundt 	}
838db806ecSPaul Mundt 
848db806ecSPaul Mundt 	/* IDE cmd address : 0x1f0-0x1f7 and 0x3f6 */
852ea40decSPaul Mundt 	cf_ide_resources[0].start += (unsigned long)cf_ide_base;
862ea40decSPaul Mundt 	cf_ide_resources[0].end   += (unsigned long)cf_ide_base;
872ea40decSPaul Mundt 	cf_ide_resources[1].start += (unsigned long)cf_ide_base;
882ea40decSPaul Mundt 	cf_ide_resources[1].end   += (unsigned long)cf_ide_base;
898db806ecSPaul Mundt 
90da2014a2SPaul Mundt 	return platform_add_devices(sh03_devices, ARRAY_SIZE(sh03_devices));
91da2014a2SPaul Mundt }
9295d210ceSNobuhiro Iwamatsu device_initcall(sh03_devices_setup);
93da2014a2SPaul Mundt 
94da2014a2SPaul Mundt static struct sh_machine_vector mv_sh03 __initmv = {
95da2014a2SPaul Mundt 	.mv_name		= "Interface (CTP/PCI-SH03)",
96da2014a2SPaul Mundt 	.mv_init_irq		= init_sh03_IRQ,
97da2014a2SPaul Mundt };
98