18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * linux/arch/sh/boards/se/770x/setup.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2000 Kazumoto Kojima 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Hitachi SolutionEngine Support. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci#include <linux/init.h> 118c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 128c2ecf20Sopenharmony_ci#include <linux/sh_eth.h> 138c2ecf20Sopenharmony_ci#include <mach-se/mach/se.h> 148c2ecf20Sopenharmony_ci#include <mach-se/mach/mrshpc.h> 158c2ecf20Sopenharmony_ci#include <asm/machvec.h> 168c2ecf20Sopenharmony_ci#include <asm/io.h> 178c2ecf20Sopenharmony_ci#include <asm/smc37c93x.h> 188c2ecf20Sopenharmony_ci#include <asm/heartbeat.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * Configure the Super I/O chip 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_cistatic void __init smsc_config(int index, int data) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci outb_p(index, INDEX_PORT); 268c2ecf20Sopenharmony_ci outb_p(data, DATA_PORT); 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* XXX: Another candidate for a more generic cchip machine vector */ 308c2ecf20Sopenharmony_cistatic void __init smsc_setup(char **cmdline_p) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci outb_p(CONFIG_ENTER, CONFIG_PORT); 338c2ecf20Sopenharmony_ci outb_p(CONFIG_ENTER, CONFIG_PORT); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci /* FDC */ 368c2ecf20Sopenharmony_ci smsc_config(CURRENT_LDN_INDEX, LDN_FDC); 378c2ecf20Sopenharmony_ci smsc_config(ACTIVATE_INDEX, 0x01); 388c2ecf20Sopenharmony_ci smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci /* AUXIO (GPIO): to use IDE1 */ 418c2ecf20Sopenharmony_ci smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO); 428c2ecf20Sopenharmony_ci smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */ 438c2ecf20Sopenharmony_ci smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci /* COM1 */ 468c2ecf20Sopenharmony_ci smsc_config(CURRENT_LDN_INDEX, LDN_COM1); 478c2ecf20Sopenharmony_ci smsc_config(ACTIVATE_INDEX, 0x01); 488c2ecf20Sopenharmony_ci smsc_config(IO_BASE_HI_INDEX, 0x03); 498c2ecf20Sopenharmony_ci smsc_config(IO_BASE_LO_INDEX, 0xf8); 508c2ecf20Sopenharmony_ci smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */ 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci /* COM2 */ 538c2ecf20Sopenharmony_ci smsc_config(CURRENT_LDN_INDEX, LDN_COM2); 548c2ecf20Sopenharmony_ci smsc_config(ACTIVATE_INDEX, 0x01); 558c2ecf20Sopenharmony_ci smsc_config(IO_BASE_HI_INDEX, 0x02); 568c2ecf20Sopenharmony_ci smsc_config(IO_BASE_LO_INDEX, 0xf8); 578c2ecf20Sopenharmony_ci smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci /* RTC */ 608c2ecf20Sopenharmony_ci smsc_config(CURRENT_LDN_INDEX, LDN_RTC); 618c2ecf20Sopenharmony_ci smsc_config(ACTIVATE_INDEX, 0x01); 628c2ecf20Sopenharmony_ci smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */ 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci /* XXX: PARPORT, KBD, and MOUSE will come here... */ 658c2ecf20Sopenharmony_ci outb_p(CONFIG_EXIT, CONFIG_PORT); 668c2ecf20Sopenharmony_ci} 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic struct resource cf_ide_resources[] = { 708c2ecf20Sopenharmony_ci [0] = { 718c2ecf20Sopenharmony_ci .start = PA_MRSHPC_IO + 0x1f0, 728c2ecf20Sopenharmony_ci .end = PA_MRSHPC_IO + 0x1f0 + 8, 738c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 748c2ecf20Sopenharmony_ci }, 758c2ecf20Sopenharmony_ci [1] = { 768c2ecf20Sopenharmony_ci .start = PA_MRSHPC_IO + 0x1f0 + 0x206, 778c2ecf20Sopenharmony_ci .end = PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8, 788c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 798c2ecf20Sopenharmony_ci }, 808c2ecf20Sopenharmony_ci [2] = { 818c2ecf20Sopenharmony_ci .start = IRQ_CFCARD, 828c2ecf20Sopenharmony_ci .flags = IORESOURCE_IRQ, 838c2ecf20Sopenharmony_ci }, 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic struct platform_device cf_ide_device = { 878c2ecf20Sopenharmony_ci .name = "pata_platform", 888c2ecf20Sopenharmony_ci .id = -1, 898c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(cf_ide_resources), 908c2ecf20Sopenharmony_ci .resource = cf_ide_resources, 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 }; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistatic struct heartbeat_data heartbeat_data = { 968c2ecf20Sopenharmony_ci .bit_pos = heartbeat_bit_pos, 978c2ecf20Sopenharmony_ci .nr_bits = ARRAY_SIZE(heartbeat_bit_pos), 988c2ecf20Sopenharmony_ci}; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cistatic struct resource heartbeat_resource = { 1018c2ecf20Sopenharmony_ci .start = PA_LED, 1028c2ecf20Sopenharmony_ci .end = PA_LED, 1038c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT, 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistatic struct platform_device heartbeat_device = { 1078c2ecf20Sopenharmony_ci .name = "heartbeat", 1088c2ecf20Sopenharmony_ci .id = -1, 1098c2ecf20Sopenharmony_ci .dev = { 1108c2ecf20Sopenharmony_ci .platform_data = &heartbeat_data, 1118c2ecf20Sopenharmony_ci }, 1128c2ecf20Sopenharmony_ci .num_resources = 1, 1138c2ecf20Sopenharmony_ci .resource = &heartbeat_resource, 1148c2ecf20Sopenharmony_ci}; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\ 1178c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7712) 1188c2ecf20Sopenharmony_ci/* SH771X Ethernet driver */ 1198c2ecf20Sopenharmony_cistatic struct sh_eth_plat_data sh_eth_plat = { 1208c2ecf20Sopenharmony_ci .phy = PHY_ID, 1218c2ecf20Sopenharmony_ci .phy_interface = PHY_INTERFACE_MODE_MII, 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistatic struct resource sh_eth0_resources[] = { 1258c2ecf20Sopenharmony_ci [0] = { 1268c2ecf20Sopenharmony_ci .start = SH_ETH0_BASE, 1278c2ecf20Sopenharmony_ci .end = SH_ETH0_BASE + 0x1B8 - 1, 1288c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1298c2ecf20Sopenharmony_ci }, 1308c2ecf20Sopenharmony_ci [1] = { 1318c2ecf20Sopenharmony_ci .start = SH_TSU_BASE, 1328c2ecf20Sopenharmony_ci .end = SH_TSU_BASE + 0x200 - 1, 1338c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1348c2ecf20Sopenharmony_ci }, 1358c2ecf20Sopenharmony_ci [2] = { 1368c2ecf20Sopenharmony_ci .start = SH_ETH0_IRQ, 1378c2ecf20Sopenharmony_ci .end = SH_ETH0_IRQ, 1388c2ecf20Sopenharmony_ci .flags = IORESOURCE_IRQ, 1398c2ecf20Sopenharmony_ci }, 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistatic struct platform_device sh_eth0_device = { 1438c2ecf20Sopenharmony_ci .name = "sh771x-ether", 1448c2ecf20Sopenharmony_ci .id = 0, 1458c2ecf20Sopenharmony_ci .dev = { 1468c2ecf20Sopenharmony_ci .platform_data = &sh_eth_plat, 1478c2ecf20Sopenharmony_ci }, 1488c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(sh_eth0_resources), 1498c2ecf20Sopenharmony_ci .resource = sh_eth0_resources, 1508c2ecf20Sopenharmony_ci}; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistatic struct resource sh_eth1_resources[] = { 1538c2ecf20Sopenharmony_ci [0] = { 1548c2ecf20Sopenharmony_ci .start = SH_ETH1_BASE, 1558c2ecf20Sopenharmony_ci .end = SH_ETH1_BASE + 0x1B8 - 1, 1568c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1578c2ecf20Sopenharmony_ci }, 1588c2ecf20Sopenharmony_ci [1] = { 1598c2ecf20Sopenharmony_ci .start = SH_TSU_BASE, 1608c2ecf20Sopenharmony_ci .end = SH_TSU_BASE + 0x200 - 1, 1618c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1628c2ecf20Sopenharmony_ci }, 1638c2ecf20Sopenharmony_ci [2] = { 1648c2ecf20Sopenharmony_ci .start = SH_ETH1_IRQ, 1658c2ecf20Sopenharmony_ci .end = SH_ETH1_IRQ, 1668c2ecf20Sopenharmony_ci .flags = IORESOURCE_IRQ, 1678c2ecf20Sopenharmony_ci }, 1688c2ecf20Sopenharmony_ci}; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_cistatic struct platform_device sh_eth1_device = { 1718c2ecf20Sopenharmony_ci .name = "sh771x-ether", 1728c2ecf20Sopenharmony_ci .id = 1, 1738c2ecf20Sopenharmony_ci .dev = { 1748c2ecf20Sopenharmony_ci .platform_data = &sh_eth_plat, 1758c2ecf20Sopenharmony_ci }, 1768c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(sh_eth1_resources), 1778c2ecf20Sopenharmony_ci .resource = sh_eth1_resources, 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci#endif 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistatic struct platform_device *se_devices[] __initdata = { 1828c2ecf20Sopenharmony_ci &heartbeat_device, 1838c2ecf20Sopenharmony_ci &cf_ide_device, 1848c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\ 1858c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7712) 1868c2ecf20Sopenharmony_ci &sh_eth0_device, 1878c2ecf20Sopenharmony_ci &sh_eth1_device, 1888c2ecf20Sopenharmony_ci#endif 1898c2ecf20Sopenharmony_ci}; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_cistatic int __init se_devices_setup(void) 1928c2ecf20Sopenharmony_ci{ 1938c2ecf20Sopenharmony_ci mrshpc_setup_windows(); 1948c2ecf20Sopenharmony_ci return platform_add_devices(se_devices, ARRAY_SIZE(se_devices)); 1958c2ecf20Sopenharmony_ci} 1968c2ecf20Sopenharmony_cidevice_initcall(se_devices_setup); 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci/* 1998c2ecf20Sopenharmony_ci * The Machine Vector 2008c2ecf20Sopenharmony_ci */ 2018c2ecf20Sopenharmony_cistatic struct sh_machine_vector mv_se __initmv = { 2028c2ecf20Sopenharmony_ci .mv_name = "SolutionEngine", 2038c2ecf20Sopenharmony_ci .mv_setup = smsc_setup, 2048c2ecf20Sopenharmony_ci .mv_init_irq = init_se_IRQ, 2058c2ecf20Sopenharmony_ci}; 206