mm: Support fadvise without CONFIG_MMU
[sfrench/cifs-2.6.git] / arch / arm / mach-shmobile / board-armadillo800eva-reference.c
1 /*
2  * armadillo 800 eva board support
3  *
4  * Copyright (C) 2012 Renesas Solutions Corp.
5  * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #include <linux/clk.h>
23 #include <linux/err.h>
24 #include <linux/kernel.h>
25 #include <linux/gpio.h>
26 #include <linux/io.h>
27
28 #include <asm/mach/arch.h>
29 #include <asm/hardware/cache-l2x0.h>
30
31 #include "common.h"
32 #include "r8a7740.h"
33
34 /*
35  * CON1         Camera Module
36  * CON2         Extension Bus
37  * CON3         HDMI Output
38  * CON4         Composite Video Output
39  * CON5         H-UDI JTAG
40  * CON6         ARM JTAG
41  * CON7         SD1
42  * CON8         SD2
43  * CON9         RTC BackUp
44  * CON10        Monaural Mic Input
45  * CON11        Stereo Headphone Output
46  * CON12        Audio Line Output(L)
47  * CON13        Audio Line Output(R)
48  * CON14        AWL13 Module
49  * CON15        Extension
50  * CON16        LCD1
51  * CON17        LCD2
52  * CON19        Power Input
53  * CON20        USB1
54  * CON21        USB2
55  * CON22        Serial
56  * CON23        LAN
57  * CON24        USB3
58  * LED1         Camera LED (Yellow)
59  * LED2         Power LED (Green)
60  * LED3-LED6    User LED (Yellow)
61  * LED7         LAN link LED (Green)
62  * LED8         LAN activity LED (Yellow)
63  */
64
65 /*
66  * DipSwitch
67  *
68  *                    SW1
69  *
70  * -12345678-+---------------+----------------------------
71  *  1        | boot          | hermit
72  *  0        | boot          | OS auto boot
73  * -12345678-+---------------+----------------------------
74  *   00      | boot device   | eMMC
75  *   10      | boot device   | SDHI0 (CON7)
76  *   01      | boot device   | -
77  *   11      | boot device   | Extension Buss (CS0)
78  * -12345678-+---------------+----------------------------
79  *     0     | Extension Bus | D8-D15 disable, eMMC enable
80  *     1     | Extension Bus | D8-D15 enable,  eMMC disable
81  * -12345678-+---------------+----------------------------
82  *      0    | SDHI1         | COM8 disable, COM14 enable
83  *      1    | SDHI1         | COM8 enable,  COM14 disable
84  * -12345678-+---------------+----------------------------
85  *       0   | USB0          | COM20 enable,  COM24 disable
86  *       1   | USB0          | COM20 disable, COM24 enable
87  * -12345678-+---------------+----------------------------
88  *        00 | JTAG          | SH-X2
89  *        10 | JTAG          | ARM
90  *        01 | JTAG          | -
91  *        11 | JTAG          | Boundary Scan
92  *-----------+---------------+----------------------------
93  */
94
95 /*
96  * FSI-WM8978
97  *
98  * this command is required when playback.
99  *
100  * # amixer set "Headphone" 50
101  *
102  * this command is required when capture.
103  *
104  * # amixer set "Input PGA" 15
105  * # amixer set "Left Input Mixer MicP" on
106  * # amixer set "Left Input Mixer MicN" on
107  * # amixer set "Right Input Mixer MicN" on
108  * # amixer set "Right Input Mixer MicP" on
109  */
110
111 /*
112  * USB function
113  *
114  * When you use USB Function,
115  * set SW1.6 ON, and connect cable to CN24.
116  *
117  * USBF needs workaround on R8A7740 chip.
118  * These are a little bit complex.
119  * see
120  *      usbhsf_power_ctrl()
121  */
122
123 static void __init eva_clock_init(void)
124 {
125         struct clk *system      = clk_get(NULL, "system_clk");
126         struct clk *xtal1       = clk_get(NULL, "extal1");
127         struct clk *usb24s      = clk_get(NULL, "usb24s");
128         struct clk *fsibck      = clk_get(NULL, "fsibck");
129
130         if (IS_ERR(system)      ||
131             IS_ERR(xtal1)       ||
132             IS_ERR(usb24s)      ||
133             IS_ERR(fsibck)) {
134                 pr_err("armadillo800eva board clock init failed\n");
135                 goto clock_error;
136         }
137
138         /* armadillo 800 eva extal1 is 24MHz */
139         clk_set_rate(xtal1, 24000000);
140
141         /* usb24s use extal1 (= system) clock (= 24MHz) */
142         clk_set_parent(usb24s, system);
143
144         /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
145         clk_set_rate(fsibck, 12288000);
146
147 clock_error:
148         if (!IS_ERR(system))
149                 clk_put(system);
150         if (!IS_ERR(xtal1))
151                 clk_put(xtal1);
152         if (!IS_ERR(usb24s))
153                 clk_put(usb24s);
154         if (!IS_ERR(fsibck))
155                 clk_put(fsibck);
156 }
157
158 /*
159  * board init
160  */
161 static void __init eva_init(void)
162 {
163         r8a7740_clock_init(MD_CK0 | MD_CK2);
164         eva_clock_init();
165
166         r8a7740_meram_workaround();
167
168 #ifdef CONFIG_CACHE_L2X0
169         /* Shared attribute override enable, 32K*8way */
170         l2x0_init(IOMEM(0xf0002000), 0x00400000, 0xc20f0fff);
171 #endif
172
173         r8a7740_add_standard_devices_dt();
174
175         r8a7740_pm_init();
176 }
177
178 #define RESCNT2 IOMEM(0xe6188020)
179 static void eva_restart(enum reboot_mode mode, const char *cmd)
180 {
181         /* Do soft power on reset */
182         writel(1 << 31, RESCNT2);
183 }
184
185 static const char *eva_boards_compat_dt[] __initdata = {
186         "renesas,armadillo800eva-reference",
187         NULL,
188 };
189
190 DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva-reference")
191         .map_io         = r8a7740_map_io,
192         .init_early     = shmobile_init_delay,
193         .init_irq       = r8a7740_init_irq_of,
194         .init_machine   = eva_init,
195         .init_late      = shmobile_init_late,
196         .dt_compat      = eva_boards_compat_dt,
197         .restart        = eva_restart,
198 MACHINE_END