xref: /openbmc/linux/arch/arm/mach-omap1/io.c (revision f577ffd7)
1f577ffd7STony Lindgren /*
2f577ffd7STony Lindgren  * linux/arch/arm/mach-omap1/io.c
3f577ffd7STony Lindgren  *
4f577ffd7STony Lindgren  * OMAP1 I/O mapping code
5f577ffd7STony Lindgren  *
6f577ffd7STony Lindgren  * This program is free software; you can redistribute it and/or modify
7f577ffd7STony Lindgren  * it under the terms of the GNU General Public License version 2 as
8f577ffd7STony Lindgren  * published by the Free Software Foundation.
9f577ffd7STony Lindgren  */
10f577ffd7STony Lindgren 
11f577ffd7STony Lindgren #include <linux/config.h>
12f577ffd7STony Lindgren #include <linux/module.h>
13f577ffd7STony Lindgren #include <linux/kernel.h>
14f577ffd7STony Lindgren #include <linux/init.h>
15f577ffd7STony Lindgren 
16f577ffd7STony Lindgren #include <asm/mach/map.h>
17f577ffd7STony Lindgren #include <asm/io.h>
18f577ffd7STony Lindgren #include <asm/arch/tc.h>
19f577ffd7STony Lindgren 
20f577ffd7STony Lindgren #include "../clock.h"
21f577ffd7STony Lindgren 
22f577ffd7STony Lindgren extern void omap_check_revision(void);
23f577ffd7STony Lindgren 
24f577ffd7STony Lindgren /*
25f577ffd7STony Lindgren  * The machine specific code may provide the extra mapping besides the
26f577ffd7STony Lindgren  * default mapping provided here.
27f577ffd7STony Lindgren  */
28f577ffd7STony Lindgren static struct map_desc omap_io_desc[] __initdata = {
29f577ffd7STony Lindgren  { IO_VIRT,      	IO_PHYS,             IO_SIZE,        	   MT_DEVICE },
30f577ffd7STony Lindgren };
31f577ffd7STony Lindgren 
32f577ffd7STony Lindgren #ifdef CONFIG_ARCH_OMAP730
33f577ffd7STony Lindgren static struct map_desc omap730_io_desc[] __initdata = {
34f577ffd7STony Lindgren  { OMAP730_DSP_BASE,    OMAP730_DSP_START,    OMAP730_DSP_SIZE,    MT_DEVICE },
35f577ffd7STony Lindgren  { OMAP730_DSPREG_BASE, OMAP730_DSPREG_START, OMAP730_DSPREG_SIZE, MT_DEVICE },
36f577ffd7STony Lindgren  { OMAP730_SRAM_BASE,   OMAP730_SRAM_START,   OMAP730_SRAM_SIZE,   MT_DEVICE }
37f577ffd7STony Lindgren };
38f577ffd7STony Lindgren #endif
39f577ffd7STony Lindgren 
40f577ffd7STony Lindgren #ifdef CONFIG_ARCH_OMAP1510
41f577ffd7STony Lindgren static struct map_desc omap1510_io_desc[] __initdata = {
42f577ffd7STony Lindgren  { OMAP1510_DSP_BASE,    OMAP1510_DSP_START,    OMAP1510_DSP_SIZE,    MT_DEVICE },
43f577ffd7STony Lindgren  { OMAP1510_DSPREG_BASE, OMAP1510_DSPREG_START, OMAP1510_DSPREG_SIZE, MT_DEVICE },
44f577ffd7STony Lindgren  { OMAP1510_SRAM_BASE,   OMAP1510_SRAM_START,   OMAP1510_SRAM_SIZE,   MT_DEVICE }
45f577ffd7STony Lindgren };
46f577ffd7STony Lindgren #endif
47f577ffd7STony Lindgren 
48f577ffd7STony Lindgren #if defined(CONFIG_ARCH_OMAP16XX)
49f577ffd7STony Lindgren static struct map_desc omap1610_io_desc[] __initdata = {
50f577ffd7STony Lindgren  { OMAP16XX_DSP_BASE,    OMAP16XX_DSP_START,    OMAP16XX_DSP_SIZE,    MT_DEVICE },
51f577ffd7STony Lindgren  { OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_START, OMAP16XX_DSPREG_SIZE, MT_DEVICE },
52f577ffd7STony Lindgren  { OMAP16XX_SRAM_BASE,   OMAP16XX_SRAM_START,   OMAP1610_SRAM_SIZE,   MT_DEVICE }
53f577ffd7STony Lindgren };
54f577ffd7STony Lindgren 
55f577ffd7STony Lindgren static struct map_desc omap5912_io_desc[] __initdata = {
56f577ffd7STony Lindgren  { OMAP16XX_DSP_BASE,    OMAP16XX_DSP_START,    OMAP16XX_DSP_SIZE,    MT_DEVICE },
57f577ffd7STony Lindgren  { OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_START, OMAP16XX_DSPREG_SIZE, MT_DEVICE },
58f577ffd7STony Lindgren /*
59f577ffd7STony Lindgren  * The OMAP5912 has 250kByte internal SRAM. Because the mapping is baseed on page
60f577ffd7STony Lindgren  * size (4kByte), it seems that the last 2kByte (=0x800) of the 250kByte are not mapped.
61f577ffd7STony Lindgren  * Add additional 2kByte (0x800) so that the last page is mapped and the last 2kByte
62f577ffd7STony Lindgren  * can be used.
63f577ffd7STony Lindgren  */
64f577ffd7STony Lindgren  { OMAP16XX_SRAM_BASE,   OMAP16XX_SRAM_START,   OMAP5912_SRAM_SIZE + 0x800,   MT_DEVICE }
65f577ffd7STony Lindgren };
66f577ffd7STony Lindgren #endif
67f577ffd7STony Lindgren 
68f577ffd7STony Lindgren static int initialized = 0;
69f577ffd7STony Lindgren 
70f577ffd7STony Lindgren static void __init _omap_map_io(void)
71f577ffd7STony Lindgren {
72f577ffd7STony Lindgren 	initialized = 1;
73f577ffd7STony Lindgren 
74f577ffd7STony Lindgren 	/* We have to initialize the IO space mapping before we can run
75f577ffd7STony Lindgren 	 * cpu_is_omapxxx() macros. */
76f577ffd7STony Lindgren 	iotable_init(omap_io_desc, ARRAY_SIZE(omap_io_desc));
77f577ffd7STony Lindgren 	omap_check_revision();
78f577ffd7STony Lindgren 
79f577ffd7STony Lindgren #ifdef CONFIG_ARCH_OMAP730
80f577ffd7STony Lindgren 	if (cpu_is_omap730()) {
81f577ffd7STony Lindgren 		iotable_init(omap730_io_desc, ARRAY_SIZE(omap730_io_desc));
82f577ffd7STony Lindgren 	}
83f577ffd7STony Lindgren #endif
84f577ffd7STony Lindgren #ifdef CONFIG_ARCH_OMAP1510
85f577ffd7STony Lindgren 	if (cpu_is_omap1510()) {
86f577ffd7STony Lindgren 		iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc));
87f577ffd7STony Lindgren 	}
88f577ffd7STony Lindgren #endif
89f577ffd7STony Lindgren #if defined(CONFIG_ARCH_OMAP16XX)
90f577ffd7STony Lindgren 	if (cpu_is_omap1610() || cpu_is_omap1710()) {
91f577ffd7STony Lindgren 		iotable_init(omap1610_io_desc, ARRAY_SIZE(omap1610_io_desc));
92f577ffd7STony Lindgren 	}
93f577ffd7STony Lindgren 	if (cpu_is_omap5912()) {
94f577ffd7STony Lindgren 		iotable_init(omap5912_io_desc, ARRAY_SIZE(omap5912_io_desc));
95f577ffd7STony Lindgren 	}
96f577ffd7STony Lindgren #endif
97f577ffd7STony Lindgren 
98f577ffd7STony Lindgren 	/* REVISIT: Refer to OMAP5910 Errata, Advisory SYS_1: "Timeout Abort
99f577ffd7STony Lindgren 	 * on a Posted Write in the TIPB Bridge".
100f577ffd7STony Lindgren 	 */
101f577ffd7STony Lindgren 	omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL);
102f577ffd7STony Lindgren 	omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL);
103f577ffd7STony Lindgren 
104f577ffd7STony Lindgren 	/* Must init clocks early to assure that timer interrupt works
105f577ffd7STony Lindgren 	 */
106f577ffd7STony Lindgren 	clk_init();
107f577ffd7STony Lindgren }
108f577ffd7STony Lindgren 
109f577ffd7STony Lindgren /*
110f577ffd7STony Lindgren  * This should only get called from board specific init
111f577ffd7STony Lindgren  */
112f577ffd7STony Lindgren void omap_map_common_io(void)
113f577ffd7STony Lindgren {
114f577ffd7STony Lindgren 	if (!initialized)
115f577ffd7STony Lindgren 		_omap_map_io();
116f577ffd7STony Lindgren }
117