18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * SH3 Setup code for SH7710, SH7712 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2006 - 2009 Paul Mundt 68c2ecf20Sopenharmony_ci * Copyright (C) 2007 Nobuhiro Iwamatsu 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 98c2ecf20Sopenharmony_ci#include <linux/init.h> 108c2ecf20Sopenharmony_ci#include <linux/irq.h> 118c2ecf20Sopenharmony_ci#include <linux/serial.h> 128c2ecf20Sopenharmony_ci#include <linux/serial_sci.h> 138c2ecf20Sopenharmony_ci#include <linux/sh_timer.h> 148c2ecf20Sopenharmony_ci#include <linux/sh_intc.h> 158c2ecf20Sopenharmony_ci#include <asm/rtc.h> 168c2ecf20Sopenharmony_ci#include <asm/platform_early.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cienum { 198c2ecf20Sopenharmony_ci UNUSED = 0, 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci /* interrupt sources */ 228c2ecf20Sopenharmony_ci IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, 238c2ecf20Sopenharmony_ci DMAC1, SCIF0, SCIF1, DMAC2, IPSEC, 248c2ecf20Sopenharmony_ci EDMAC0, EDMAC1, EDMAC2, 258c2ecf20Sopenharmony_ci SIOF0, SIOF1, 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci TMU0, TMU1, TMU2, 288c2ecf20Sopenharmony_ci RTC, WDT, REF, 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic struct intc_vect vectors[] __initdata = { 328c2ecf20Sopenharmony_ci /* IRQ0->5 are handled in setup-sh3.c */ 338c2ecf20Sopenharmony_ci INTC_VECT(DMAC1, 0x800), INTC_VECT(DMAC1, 0x820), 348c2ecf20Sopenharmony_ci INTC_VECT(DMAC1, 0x840), INTC_VECT(DMAC1, 0x860), 358c2ecf20Sopenharmony_ci INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0), 368c2ecf20Sopenharmony_ci INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0), 378c2ecf20Sopenharmony_ci INTC_VECT(SCIF1, 0x900), INTC_VECT(SCIF1, 0x920), 388c2ecf20Sopenharmony_ci INTC_VECT(SCIF1, 0x940), INTC_VECT(SCIF1, 0x960), 398c2ecf20Sopenharmony_ci INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0), 408c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_SUBTYPE_SH7710 418c2ecf20Sopenharmony_ci INTC_VECT(IPSEC, 0xbe0), 428c2ecf20Sopenharmony_ci#endif 438c2ecf20Sopenharmony_ci INTC_VECT(EDMAC0, 0xc00), INTC_VECT(EDMAC1, 0xc20), 448c2ecf20Sopenharmony_ci INTC_VECT(EDMAC2, 0xc40), 458c2ecf20Sopenharmony_ci INTC_VECT(SIOF0, 0xe00), INTC_VECT(SIOF0, 0xe20), 468c2ecf20Sopenharmony_ci INTC_VECT(SIOF0, 0xe40), INTC_VECT(SIOF0, 0xe60), 478c2ecf20Sopenharmony_ci INTC_VECT(SIOF1, 0xe80), INTC_VECT(SIOF1, 0xea0), 488c2ecf20Sopenharmony_ci INTC_VECT(SIOF1, 0xec0), INTC_VECT(SIOF1, 0xee0), 498c2ecf20Sopenharmony_ci INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), 508c2ecf20Sopenharmony_ci INTC_VECT(TMU2, 0x440), 518c2ecf20Sopenharmony_ci INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0), 528c2ecf20Sopenharmony_ci INTC_VECT(RTC, 0x4c0), 538c2ecf20Sopenharmony_ci INTC_VECT(WDT, 0x560), 548c2ecf20Sopenharmony_ci INTC_VECT(REF, 0x580), 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistatic struct intc_prio_reg prio_registers[] __initdata = { 588c2ecf20Sopenharmony_ci { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } }, 598c2ecf20Sopenharmony_ci { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } }, 608c2ecf20Sopenharmony_ci { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } }, 618c2ecf20Sopenharmony_ci { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } }, 628c2ecf20Sopenharmony_ci { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } }, 638c2ecf20Sopenharmony_ci { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC, DMAC2 } }, 648c2ecf20Sopenharmony_ci { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } }, 658c2ecf20Sopenharmony_ci { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } }, 668c2ecf20Sopenharmony_ci { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } }, 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, NULL, 708c2ecf20Sopenharmony_ci NULL, prio_registers, NULL); 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistatic struct resource rtc_resources[] = { 738c2ecf20Sopenharmony_ci [0] = { 748c2ecf20Sopenharmony_ci .start = 0xa413fec0, 758c2ecf20Sopenharmony_ci .end = 0xa413fec0 + 0x1e, 768c2ecf20Sopenharmony_ci .flags = IORESOURCE_IO, 778c2ecf20Sopenharmony_ci }, 788c2ecf20Sopenharmony_ci [1] = { 798c2ecf20Sopenharmony_ci .start = evt2irq(0x480), 808c2ecf20Sopenharmony_ci .flags = IORESOURCE_IRQ, 818c2ecf20Sopenharmony_ci }, 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_cistatic struct sh_rtc_platform_info rtc_info = { 858c2ecf20Sopenharmony_ci .capabilities = RTC_CAP_4_DIGIT_YEAR, 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistatic struct platform_device rtc_device = { 898c2ecf20Sopenharmony_ci .name = "sh-rtc", 908c2ecf20Sopenharmony_ci .id = -1, 918c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(rtc_resources), 928c2ecf20Sopenharmony_ci .resource = rtc_resources, 938c2ecf20Sopenharmony_ci .dev = { 948c2ecf20Sopenharmony_ci .platform_data = &rtc_info, 958c2ecf20Sopenharmony_ci }, 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic struct plat_sci_port scif0_platform_data = { 998c2ecf20Sopenharmony_ci .scscr = SCSCR_REIE | SCSCR_CKE1, 1008c2ecf20Sopenharmony_ci .type = PORT_SCIF, 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistatic struct resource scif0_resources[] = { 1048c2ecf20Sopenharmony_ci DEFINE_RES_MEM(0xa4400000, 0x100), 1058c2ecf20Sopenharmony_ci DEFINE_RES_IRQ(evt2irq(0x880)), 1068c2ecf20Sopenharmony_ci}; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistatic struct platform_device scif0_device = { 1098c2ecf20Sopenharmony_ci .name = "sh-sci", 1108c2ecf20Sopenharmony_ci .id = 0, 1118c2ecf20Sopenharmony_ci .resource = scif0_resources, 1128c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(scif0_resources), 1138c2ecf20Sopenharmony_ci .dev = { 1148c2ecf20Sopenharmony_ci .platform_data = &scif0_platform_data, 1158c2ecf20Sopenharmony_ci }, 1168c2ecf20Sopenharmony_ci}; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cistatic struct plat_sci_port scif1_platform_data = { 1198c2ecf20Sopenharmony_ci .scscr = SCSCR_REIE | SCSCR_CKE1, 1208c2ecf20Sopenharmony_ci .type = PORT_SCIF, 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistatic struct resource scif1_resources[] = { 1248c2ecf20Sopenharmony_ci DEFINE_RES_MEM(0xa4410000, 0x100), 1258c2ecf20Sopenharmony_ci DEFINE_RES_IRQ(evt2irq(0x900)), 1268c2ecf20Sopenharmony_ci}; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cistatic struct platform_device scif1_device = { 1298c2ecf20Sopenharmony_ci .name = "sh-sci", 1308c2ecf20Sopenharmony_ci .id = 1, 1318c2ecf20Sopenharmony_ci .resource = scif1_resources, 1328c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(scif1_resources), 1338c2ecf20Sopenharmony_ci .dev = { 1348c2ecf20Sopenharmony_ci .platform_data = &scif1_platform_data, 1358c2ecf20Sopenharmony_ci }, 1368c2ecf20Sopenharmony_ci}; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cistatic struct sh_timer_config tmu0_platform_data = { 1398c2ecf20Sopenharmony_ci .channels_mask = 7, 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistatic struct resource tmu0_resources[] = { 1438c2ecf20Sopenharmony_ci DEFINE_RES_MEM(0xa412fe90, 0x28), 1448c2ecf20Sopenharmony_ci DEFINE_RES_IRQ(evt2irq(0x400)), 1458c2ecf20Sopenharmony_ci DEFINE_RES_IRQ(evt2irq(0x420)), 1468c2ecf20Sopenharmony_ci DEFINE_RES_IRQ(evt2irq(0x440)), 1478c2ecf20Sopenharmony_ci}; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistatic struct platform_device tmu0_device = { 1508c2ecf20Sopenharmony_ci .name = "sh-tmu-sh3", 1518c2ecf20Sopenharmony_ci .id = 0, 1528c2ecf20Sopenharmony_ci .dev = { 1538c2ecf20Sopenharmony_ci .platform_data = &tmu0_platform_data, 1548c2ecf20Sopenharmony_ci }, 1558c2ecf20Sopenharmony_ci .resource = tmu0_resources, 1568c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(tmu0_resources), 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistatic struct platform_device *sh7710_devices[] __initdata = { 1608c2ecf20Sopenharmony_ci &scif0_device, 1618c2ecf20Sopenharmony_ci &scif1_device, 1628c2ecf20Sopenharmony_ci &tmu0_device, 1638c2ecf20Sopenharmony_ci &rtc_device, 1648c2ecf20Sopenharmony_ci}; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistatic int __init sh7710_devices_setup(void) 1678c2ecf20Sopenharmony_ci{ 1688c2ecf20Sopenharmony_ci return platform_add_devices(sh7710_devices, 1698c2ecf20Sopenharmony_ci ARRAY_SIZE(sh7710_devices)); 1708c2ecf20Sopenharmony_ci} 1718c2ecf20Sopenharmony_ciarch_initcall(sh7710_devices_setup); 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_cistatic struct platform_device *sh7710_early_devices[] __initdata = { 1748c2ecf20Sopenharmony_ci &scif0_device, 1758c2ecf20Sopenharmony_ci &scif1_device, 1768c2ecf20Sopenharmony_ci &tmu0_device, 1778c2ecf20Sopenharmony_ci}; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_civoid __init plat_early_device_setup(void) 1808c2ecf20Sopenharmony_ci{ 1818c2ecf20Sopenharmony_ci sh_early_platform_add_devices(sh7710_early_devices, 1828c2ecf20Sopenharmony_ci ARRAY_SIZE(sh7710_early_devices)); 1838c2ecf20Sopenharmony_ci} 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_civoid __init plat_irq_setup(void) 1868c2ecf20Sopenharmony_ci{ 1878c2ecf20Sopenharmony_ci register_intc_controller(&intc_desc); 1888c2ecf20Sopenharmony_ci plat_irq_setup_sh3(); 1898c2ecf20Sopenharmony_ci} 190