18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * linux/arch/arm/mach-omap1/io.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * OMAP1 I/O mapping code 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/module.h> 98c2ecf20Sopenharmony_ci#include <linux/kernel.h> 108c2ecf20Sopenharmony_ci#include <linux/init.h> 118c2ecf20Sopenharmony_ci#include <linux/io.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <asm/tlb.h> 148c2ecf20Sopenharmony_ci#include <asm/mach/map.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <mach/mux.h> 178c2ecf20Sopenharmony_ci#include <mach/tc.h> 188c2ecf20Sopenharmony_ci#include <linux/omap-dma.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include "iomap.h" 218c2ecf20Sopenharmony_ci#include "common.h" 228c2ecf20Sopenharmony_ci#include "clock.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * The machine specific code may provide the extra mapping besides the 268c2ecf20Sopenharmony_ci * default mapping provided here. 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_cistatic struct map_desc omap_io_desc[] __initdata = { 298c2ecf20Sopenharmony_ci { 308c2ecf20Sopenharmony_ci .virtual = OMAP1_IO_VIRT, 318c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(OMAP1_IO_PHYS), 328c2ecf20Sopenharmony_ci .length = OMAP1_IO_SIZE, 338c2ecf20Sopenharmony_ci .type = MT_DEVICE 348c2ecf20Sopenharmony_ci } 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850) 388c2ecf20Sopenharmony_cistatic struct map_desc omap7xx_io_desc[] __initdata = { 398c2ecf20Sopenharmony_ci { 408c2ecf20Sopenharmony_ci .virtual = OMAP7XX_DSP_BASE, 418c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(OMAP7XX_DSP_START), 428c2ecf20Sopenharmony_ci .length = OMAP7XX_DSP_SIZE, 438c2ecf20Sopenharmony_ci .type = MT_DEVICE 448c2ecf20Sopenharmony_ci }, { 458c2ecf20Sopenharmony_ci .virtual = OMAP7XX_DSPREG_BASE, 468c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(OMAP7XX_DSPREG_START), 478c2ecf20Sopenharmony_ci .length = OMAP7XX_DSPREG_SIZE, 488c2ecf20Sopenharmony_ci .type = MT_DEVICE 498c2ecf20Sopenharmony_ci } 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci#endif 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP15XX 548c2ecf20Sopenharmony_cistatic struct map_desc omap1510_io_desc[] __initdata = { 558c2ecf20Sopenharmony_ci { 568c2ecf20Sopenharmony_ci .virtual = OMAP1510_DSP_BASE, 578c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(OMAP1510_DSP_START), 588c2ecf20Sopenharmony_ci .length = OMAP1510_DSP_SIZE, 598c2ecf20Sopenharmony_ci .type = MT_DEVICE 608c2ecf20Sopenharmony_ci }, { 618c2ecf20Sopenharmony_ci .virtual = OMAP1510_DSPREG_BASE, 628c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(OMAP1510_DSPREG_START), 638c2ecf20Sopenharmony_ci .length = OMAP1510_DSPREG_SIZE, 648c2ecf20Sopenharmony_ci .type = MT_DEVICE 658c2ecf20Sopenharmony_ci } 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci#endif 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP16XX) 708c2ecf20Sopenharmony_cistatic struct map_desc omap16xx_io_desc[] __initdata = { 718c2ecf20Sopenharmony_ci { 728c2ecf20Sopenharmony_ci .virtual = OMAP16XX_DSP_BASE, 738c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(OMAP16XX_DSP_START), 748c2ecf20Sopenharmony_ci .length = OMAP16XX_DSP_SIZE, 758c2ecf20Sopenharmony_ci .type = MT_DEVICE 768c2ecf20Sopenharmony_ci }, { 778c2ecf20Sopenharmony_ci .virtual = OMAP16XX_DSPREG_BASE, 788c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(OMAP16XX_DSPREG_START), 798c2ecf20Sopenharmony_ci .length = OMAP16XX_DSPREG_SIZE, 808c2ecf20Sopenharmony_ci .type = MT_DEVICE 818c2ecf20Sopenharmony_ci } 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci#endif 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* 868c2ecf20Sopenharmony_ci * Maps common IO regions for omap1 878c2ecf20Sopenharmony_ci */ 888c2ecf20Sopenharmony_cistatic void __init omap1_map_common_io(void) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci iotable_init(omap_io_desc, ARRAY_SIZE(omap_io_desc)); 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850) 948c2ecf20Sopenharmony_civoid __init omap7xx_map_io(void) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci omap1_map_common_io(); 978c2ecf20Sopenharmony_ci iotable_init(omap7xx_io_desc, ARRAY_SIZE(omap7xx_io_desc)); 988c2ecf20Sopenharmony_ci} 998c2ecf20Sopenharmony_ci#endif 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP15XX 1028c2ecf20Sopenharmony_civoid __init omap15xx_map_io(void) 1038c2ecf20Sopenharmony_ci{ 1048c2ecf20Sopenharmony_ci omap1_map_common_io(); 1058c2ecf20Sopenharmony_ci iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc)); 1068c2ecf20Sopenharmony_ci} 1078c2ecf20Sopenharmony_ci#endif 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP16XX) 1108c2ecf20Sopenharmony_civoid __init omap16xx_map_io(void) 1118c2ecf20Sopenharmony_ci{ 1128c2ecf20Sopenharmony_ci omap1_map_common_io(); 1138c2ecf20Sopenharmony_ci iotable_init(omap16xx_io_desc, ARRAY_SIZE(omap16xx_io_desc)); 1148c2ecf20Sopenharmony_ci} 1158c2ecf20Sopenharmony_ci#endif 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* 1188c2ecf20Sopenharmony_ci * Common low-level hardware init for omap1. 1198c2ecf20Sopenharmony_ci */ 1208c2ecf20Sopenharmony_civoid __init omap1_init_early(void) 1218c2ecf20Sopenharmony_ci{ 1228c2ecf20Sopenharmony_ci omap_check_revision(); 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci /* REVISIT: Refer to OMAP5910 Errata, Advisory SYS_1: "Timeout Abort 1258c2ecf20Sopenharmony_ci * on a Posted Write in the TIPB Bridge". 1268c2ecf20Sopenharmony_ci */ 1278c2ecf20Sopenharmony_ci omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL); 1288c2ecf20Sopenharmony_ci omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL); 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci /* Must init clocks early to assure that timer interrupt works 1318c2ecf20Sopenharmony_ci */ 1328c2ecf20Sopenharmony_ci omap1_clk_init(); 1338c2ecf20Sopenharmony_ci omap1_mux_init(); 1348c2ecf20Sopenharmony_ci} 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_civoid __init omap1_init_late(void) 1378c2ecf20Sopenharmony_ci{ 1388c2ecf20Sopenharmony_ci omap_serial_wakeup_init(); 1398c2ecf20Sopenharmony_ci} 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* 1428c2ecf20Sopenharmony_ci * NOTE: Please use ioremap + __raw_read/write where possible instead of these 1438c2ecf20Sopenharmony_ci */ 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ciu8 omap_readb(u32 pa) 1468c2ecf20Sopenharmony_ci{ 1478c2ecf20Sopenharmony_ci return __raw_readb(OMAP1_IO_ADDRESS(pa)); 1488c2ecf20Sopenharmony_ci} 1498c2ecf20Sopenharmony_ciEXPORT_SYMBOL(omap_readb); 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciu16 omap_readw(u32 pa) 1528c2ecf20Sopenharmony_ci{ 1538c2ecf20Sopenharmony_ci return __raw_readw(OMAP1_IO_ADDRESS(pa)); 1548c2ecf20Sopenharmony_ci} 1558c2ecf20Sopenharmony_ciEXPORT_SYMBOL(omap_readw); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ciu32 omap_readl(u32 pa) 1588c2ecf20Sopenharmony_ci{ 1598c2ecf20Sopenharmony_ci return __raw_readl(OMAP1_IO_ADDRESS(pa)); 1608c2ecf20Sopenharmony_ci} 1618c2ecf20Sopenharmony_ciEXPORT_SYMBOL(omap_readl); 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_civoid omap_writeb(u8 v, u32 pa) 1648c2ecf20Sopenharmony_ci{ 1658c2ecf20Sopenharmony_ci __raw_writeb(v, OMAP1_IO_ADDRESS(pa)); 1668c2ecf20Sopenharmony_ci} 1678c2ecf20Sopenharmony_ciEXPORT_SYMBOL(omap_writeb); 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_civoid omap_writew(u16 v, u32 pa) 1708c2ecf20Sopenharmony_ci{ 1718c2ecf20Sopenharmony_ci __raw_writew(v, OMAP1_IO_ADDRESS(pa)); 1728c2ecf20Sopenharmony_ci} 1738c2ecf20Sopenharmony_ciEXPORT_SYMBOL(omap_writew); 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_civoid omap_writel(u32 v, u32 pa) 1768c2ecf20Sopenharmony_ci{ 1778c2ecf20Sopenharmony_ci __raw_writel(v, OMAP1_IO_ADDRESS(pa)); 1788c2ecf20Sopenharmony_ci} 1798c2ecf20Sopenharmony_ciEXPORT_SYMBOL(omap_writel); 180