1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * linux/arch/sh/boards/sh03/setup.c 4 * 5 * Copyright (C) 2004 Interface Co.,Ltd. Saito.K 6 * 7 */ 8 9 #include <linux/init.h> 10 #include <linux/irq.h> 11 #include <linux/pci.h> 12 #include <linux/platform_device.h> 13 #include <linux/ata_platform.h> 14 #include <asm/io.h> 15 #include <asm/rtc.h> 16 #include <mach-sh03/mach/io.h> 17 #include <mach-sh03/mach/sh03.h> 18 #include <asm/addrspace.h> 19 20 static void __init init_sh03_IRQ(void) 21 { 22 plat_irq_setup_pins(IRQ_MODE_IRQ); 23 } 24 25 /* arch/sh/boards/sh03/rtc.c */ 26 void sh03_time_init(void); 27 28 static void __init sh03_setup(char **cmdline_p) 29 { 30 board_time_init = sh03_time_init; 31 } 32 33 static struct resource cf_ide_resources[] = { 34 [0] = { 35 .start = 0x1f0, 36 .end = 0x1f0 + 8, 37 .flags = IORESOURCE_IO, 38 }, 39 [1] = { 40 .start = 0x1f0 + 0x206, 41 .end = 0x1f0 +8 + 0x206 + 8, 42 .flags = IORESOURCE_IO, 43 }, 44 [2] = { 45 .start = IRL2_IRQ, 46 .flags = IORESOURCE_IRQ, 47 }, 48 }; 49 50 static struct platform_device cf_ide_device = { 51 .name = "pata_platform", 52 .id = -1, 53 .num_resources = ARRAY_SIZE(cf_ide_resources), 54 .resource = cf_ide_resources, 55 }; 56 57 static struct resource heartbeat_resources[] = { 58 [0] = { 59 .start = 0xa0800000, 60 .end = 0xa0800000, 61 .flags = IORESOURCE_MEM, 62 }, 63 }; 64 65 static struct platform_device heartbeat_device = { 66 .name = "heartbeat", 67 .id = -1, 68 .num_resources = ARRAY_SIZE(heartbeat_resources), 69 .resource = heartbeat_resources, 70 }; 71 72 static struct platform_device *sh03_devices[] __initdata = { 73 &heartbeat_device, 74 &cf_ide_device, 75 }; 76 77 static int __init sh03_devices_setup(void) 78 { 79 pgprot_t prot; 80 unsigned long paddrbase; 81 void *cf_ide_base; 82 83 /* open I/O area window */ 84 paddrbase = virt_to_phys((void *)PA_AREA5_IO); 85 prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16); 86 cf_ide_base = ioremap_prot(paddrbase, PAGE_SIZE, pgprot_val(prot)); 87 if (!cf_ide_base) { 88 printk("allocate_cf_area : can't open CF I/O window!\n"); 89 return -ENOMEM; 90 } 91 92 /* IDE cmd address : 0x1f0-0x1f7 and 0x3f6 */ 93 cf_ide_resources[0].start += (unsigned long)cf_ide_base; 94 cf_ide_resources[0].end += (unsigned long)cf_ide_base; 95 cf_ide_resources[1].start += (unsigned long)cf_ide_base; 96 cf_ide_resources[1].end += (unsigned long)cf_ide_base; 97 98 return platform_add_devices(sh03_devices, ARRAY_SIZE(sh03_devices)); 99 } 100 device_initcall(sh03_devices_setup); 101 102 static struct sh_machine_vector mv_sh03 __initmv = { 103 .mv_name = "Interface (CTP/PCI-SH03)", 104 .mv_setup = sh03_setup, 105 .mv_init_irq = init_sh03_IRQ, 106 }; 107