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