Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm into next
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-msm / board-msm7x30.c
1 /* Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 #include <linux/gpio.h>
18 #include <linux/kernel.h>
19 #include <linux/irq.h>
20 #include <linux/platform_device.h>
21 #include <linux/delay.h>
22 #include <linux/io.h>
23 #include <linux/smsc911x.h>
24 #include <linux/usb/msm_hsusb.h>
25 #include <linux/clkdev.h>
26 #include <linux/memblock.h>
27
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/memory.h>
31 #include <asm/setup.h>
32
33 #include <mach/clk.h>
34 #include <mach/msm_iomap.h>
35 #include <mach/dma.h>
36
37 #include <mach/vreg.h>
38 #include "devices.h"
39 #include "gpiomux.h"
40 #include "proc_comm.h"
41 #include "common.h"
42
43 static void __init msm7x30_fixup(struct tag *tag, char **cmdline)
44 {
45         for (; tag->hdr.size; tag = tag_next(tag))
46                 if (tag->hdr.tag == ATAG_MEM && tag->u.mem.start == 0x200000) {
47                         tag->u.mem.start = 0;
48                         tag->u.mem.size += SZ_2M;
49                 }
50 }
51
52 static void __init msm7x30_reserve(void)
53 {
54         memblock_remove(0x0, SZ_2M);
55 }
56
57 static int hsusb_phy_init_seq[] = {
58         0x30, 0x32,     /* Enable and set Pre-Emphasis Depth to 20% */
59         0x02, 0x36,     /* Disable CDR Auto Reset feature */
60         -1
61 };
62
63 static int hsusb_link_clk_reset(struct clk *link_clk, bool assert)
64 {
65         int ret;
66
67         if (assert) {
68                 ret = clk_reset(link_clk, CLK_RESET_ASSERT);
69                 if (ret)
70                         pr_err("usb hs_clk assert failed\n");
71         } else {
72                 ret = clk_reset(link_clk, CLK_RESET_DEASSERT);
73                 if (ret)
74                         pr_err("usb hs_clk deassert failed\n");
75         }
76         return ret;
77 }
78
79 static int hsusb_phy_clk_reset(struct clk *phy_clk)
80 {
81         int ret;
82
83         ret = clk_reset(phy_clk, CLK_RESET_ASSERT);
84         if (ret) {
85                 pr_err("usb phy clk assert failed\n");
86                 return ret;
87         }
88         usleep_range(10000, 12000);
89         ret = clk_reset(phy_clk, CLK_RESET_DEASSERT);
90         if (ret)
91                 pr_err("usb phy clk deassert failed\n");
92         return ret;
93 }
94
95 static struct msm_otg_platform_data msm_otg_pdata = {
96         .phy_init_seq           = hsusb_phy_init_seq,
97         .mode                   = USB_DR_MODE_PERIPHERAL,
98         .otg_control            = OTG_PHY_CONTROL,
99         .link_clk_reset         = hsusb_link_clk_reset,
100         .phy_clk_reset          = hsusb_phy_clk_reset,
101 };
102
103 struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {
104 #ifdef CONFIG_SERIAL_MSM_CONSOLE
105         [49] = { /* UART2 RFR */
106                 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
107                              GPIOMUX_FUNC_2 | GPIOMUX_VALID,
108         },
109         [50] = { /* UART2 CTS */
110                 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
111                              GPIOMUX_FUNC_2 | GPIOMUX_VALID,
112         },
113         [51] = { /* UART2 RX */
114                 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
115                              GPIOMUX_FUNC_2 | GPIOMUX_VALID,
116         },
117         [52] = { /* UART2 TX */
118                 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
119                              GPIOMUX_FUNC_2 | GPIOMUX_VALID,
120         },
121 #endif
122 };
123
124 static struct platform_device *devices[] __initdata = {
125         &msm_clock_7x30,
126         &msm_device_gpio_7x30,
127 #if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
128         &msm_device_uart2,
129 #endif
130         &msm_device_smd,
131         &msm_device_otg,
132         &msm_device_hsusb,
133         &msm_device_hsusb_host,
134 };
135
136 static void __init msm7x30_init_irq(void)
137 {
138         msm_init_irq();
139 }
140
141 static void __init msm7x30_init(void)
142 {
143         msm_device_otg.dev.platform_data = &msm_otg_pdata;
144         msm_device_hsusb.dev.parent = &msm_device_otg.dev;
145         msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;
146
147         platform_add_devices(devices, ARRAY_SIZE(devices));
148 }
149
150 static void __init msm7x30_map_io(void)
151 {
152         msm_map_msm7x30_io();
153 }
154
155 static void __init msm7x30_init_late(void)
156 {
157         smd_debugfs_init();
158 }
159
160 MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
161         .atag_offset = 0x100,
162         .fixup = msm7x30_fixup,
163         .reserve = msm7x30_reserve,
164         .map_io = msm7x30_map_io,
165         .init_irq = msm7x30_init_irq,
166         .init_machine = msm7x30_init,
167         .init_late = msm7x30_init_late,
168         .init_time      = msm7x30_timer_init,
169 MACHINE_END
170
171 MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
172         .atag_offset = 0x100,
173         .fixup = msm7x30_fixup,
174         .reserve = msm7x30_reserve,
175         .map_io = msm7x30_map_io,
176         .init_irq = msm7x30_init_irq,
177         .init_machine = msm7x30_init,
178         .init_late = msm7x30_init_late,
179         .init_time      = msm7x30_timer_init,
180 MACHINE_END
181
182 MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
183         .atag_offset = 0x100,
184         .fixup = msm7x30_fixup,
185         .reserve = msm7x30_reserve,
186         .map_io = msm7x30_map_io,
187         .init_irq = msm7x30_init_irq,
188         .init_machine = msm7x30_init,
189         .init_late = msm7x30_init_late,
190         .init_time      = msm7x30_timer_init,
191 MACHINE_END