1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * linux/arch/arm/mach-omap1/io.c 4 * 5 * OMAP1 I/O mapping code 6 */ 7 8 #include <linux/module.h> 9 #include <linux/kernel.h> 10 #include <linux/init.h> 11 #include <linux/io.h> 12 #include <linux/omap-dma.h> 13 14 #include <asm/tlb.h> 15 #include <asm/mach/map.h> 16 17 #include "tc.h" 18 #include "mux.h" 19 #include "iomap.h" 20 #include "common.h" 21 #include "clock.h" 22 23 /* 24 * The machine specific code may provide the extra mapping besides the 25 * default mapping provided here. 26 */ 27 static struct map_desc omap_io_desc[] __initdata = { 28 { 29 .virtual = OMAP1_IO_VIRT, 30 .pfn = __phys_to_pfn(OMAP1_IO_PHYS), 31 .length = OMAP1_IO_SIZE, 32 .type = MT_DEVICE 33 } 34 }; 35 36 #if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850) 37 static struct map_desc omap7xx_io_desc[] __initdata = { 38 { 39 .virtual = OMAP7XX_DSP_BASE, 40 .pfn = __phys_to_pfn(OMAP7XX_DSP_START), 41 .length = OMAP7XX_DSP_SIZE, 42 .type = MT_DEVICE 43 }, { 44 .virtual = OMAP7XX_DSPREG_BASE, 45 .pfn = __phys_to_pfn(OMAP7XX_DSPREG_START), 46 .length = OMAP7XX_DSPREG_SIZE, 47 .type = MT_DEVICE 48 } 49 }; 50 #endif 51 52 #ifdef CONFIG_ARCH_OMAP15XX 53 static struct map_desc omap1510_io_desc[] __initdata = { 54 { 55 .virtual = OMAP1510_DSP_BASE, 56 .pfn = __phys_to_pfn(OMAP1510_DSP_START), 57 .length = OMAP1510_DSP_SIZE, 58 .type = MT_DEVICE 59 }, { 60 .virtual = OMAP1510_DSPREG_BASE, 61 .pfn = __phys_to_pfn(OMAP1510_DSPREG_START), 62 .length = OMAP1510_DSPREG_SIZE, 63 .type = MT_DEVICE 64 } 65 }; 66 #endif 67 68 #if defined(CONFIG_ARCH_OMAP16XX) 69 static struct map_desc omap16xx_io_desc[] __initdata = { 70 { 71 .virtual = OMAP16XX_DSP_BASE, 72 .pfn = __phys_to_pfn(OMAP16XX_DSP_START), 73 .length = OMAP16XX_DSP_SIZE, 74 .type = MT_DEVICE 75 }, { 76 .virtual = OMAP16XX_DSPREG_BASE, 77 .pfn = __phys_to_pfn(OMAP16XX_DSPREG_START), 78 .length = OMAP16XX_DSPREG_SIZE, 79 .type = MT_DEVICE 80 } 81 }; 82 #endif 83 84 /* 85 * Maps common IO regions for omap1 86 */ 87 static void __init omap1_map_common_io(void) 88 { 89 iotable_init(omap_io_desc, ARRAY_SIZE(omap_io_desc)); 90 } 91 92 #if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850) 93 void __init omap7xx_map_io(void) 94 { 95 omap1_map_common_io(); 96 iotable_init(omap7xx_io_desc, ARRAY_SIZE(omap7xx_io_desc)); 97 } 98 #endif 99 100 #ifdef CONFIG_ARCH_OMAP15XX 101 void __init omap15xx_map_io(void) 102 { 103 omap1_map_common_io(); 104 iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc)); 105 } 106 #endif 107 108 #if defined(CONFIG_ARCH_OMAP16XX) 109 void __init omap16xx_map_io(void) 110 { 111 omap1_map_common_io(); 112 iotable_init(omap16xx_io_desc, ARRAY_SIZE(omap16xx_io_desc)); 113 } 114 #endif 115 116 /* 117 * Common low-level hardware init for omap1. 118 */ 119 void __init omap1_init_early(void) 120 { 121 omap_check_revision(); 122 123 /* REVISIT: Refer to OMAP5910 Errata, Advisory SYS_1: "Timeout Abort 124 * on a Posted Write in the TIPB Bridge". 125 */ 126 omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL); 127 omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL); 128 129 /* Must init clocks early to assure that timer interrupt works 130 */ 131 omap1_clk_init(); 132 omap1_mux_init(); 133 } 134 135 void __init omap1_init_late(void) 136 { 137 omap_serial_wakeup_init(); 138 } 139 140 /* 141 * NOTE: Please use ioremap + __raw_read/write where possible instead of these 142 */ 143 144 u8 omap_readb(u32 pa) 145 { 146 return __raw_readb(OMAP1_IO_ADDRESS(pa)); 147 } 148 EXPORT_SYMBOL(omap_readb); 149 150 u16 omap_readw(u32 pa) 151 { 152 return __raw_readw(OMAP1_IO_ADDRESS(pa)); 153 } 154 EXPORT_SYMBOL(omap_readw); 155 156 u32 omap_readl(u32 pa) 157 { 158 return __raw_readl(OMAP1_IO_ADDRESS(pa)); 159 } 160 EXPORT_SYMBOL(omap_readl); 161 162 void omap_writeb(u8 v, u32 pa) 163 { 164 __raw_writeb(v, OMAP1_IO_ADDRESS(pa)); 165 } 166 EXPORT_SYMBOL(omap_writeb); 167 168 void omap_writew(u16 v, u32 pa) 169 { 170 __raw_writew(v, OMAP1_IO_ADDRESS(pa)); 171 } 172 EXPORT_SYMBOL(omap_writew); 173 174 void omap_writel(u32 v, u32 pa) 175 { 176 __raw_writel(v, OMAP1_IO_ADDRESS(pa)); 177 } 178 EXPORT_SYMBOL(omap_writel); 179