blob: 2b331d0bf9528662b8b2f4c1bf3547a7ff506167 [file] [log] [blame]
Mitchel Humpherysa35ec182012-11-19 11:04:35 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -07002 *
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
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080013#include <linux/err.h>
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -070014#include <linux/kernel.h>
15#include <linux/errno.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
18#include <linux/gpio.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
21#include <linux/of.h>
22#include <linux/of_address.h>
23#include <linux/of_platform.h>
24#include <linux/of_fdt.h>
25#include <linux/of_irq.h>
26#include <linux/memory.h>
27#ifdef CONFIG_ANDROID_PMEM
28#include <linux/android_pmem.h>
29#endif
David Keitelab876512013-02-19 12:01:07 -080030#include <linux/regulator/qpnp-regulator.h>
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -070031#include <asm/mach/map.h>
32#include <asm/hardware/gic.h>
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -070033#include <asm/mach/arch.h>
34#include <asm/mach/time.h>
35#include <mach/board.h>
36#include <mach/gpiomux.h>
37#include <mach/msm_iomap.h>
Syed Rameez Mustafaf1bdd712012-11-20 14:56:44 -080038#include <mach/restart.h>
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -070039#ifdef CONFIG_ION_MSM
40#include <mach/ion.h>
41#endif
42#include <mach/msm_memtypes.h>
43#include <mach/socinfo.h>
44#include <mach/board.h>
Matt Wagantall33d01f52012-02-23 23:27:44 -080045#include <mach/clk-provider.h>
Praveen Chidambaramde2a87b2012-12-20 16:13:53 -070046#include <mach/msm_smd.h>
47#include <mach/rpm-smd.h>
48#include <linux/msm_thermal.h>
Rohit Vaswani835707b2012-09-20 16:21:39 -070049#include "board-dt.h"
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -070050#include "clock.h"
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080051#include "platsmp.h"
Praveen Chidambaramde2a87b2012-12-20 16:13:53 -070052#include "spm.h"
53#include "lpm_resources.h"
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -070054
Mitchel Humpherys3c7c7122012-11-08 19:24:39 -080055static struct memtype_reserve msm8226_reserve_table[] __initdata = {
56 [MEMTYPE_SMI] = {
57 },
58 [MEMTYPE_EBI0] = {
59 .flags = MEMTYPE_FLAGS_1M_ALIGN,
60 },
61 [MEMTYPE_EBI1] = {
62 .flags = MEMTYPE_FLAGS_1M_ALIGN,
63 },
64};
65
66static int msm8226_paddr_to_memtype(unsigned int paddr)
67{
68 return MEMTYPE_EBI1;
69}
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -070070
Syed Rameez Mustafa51d4d182012-11-20 14:36:43 -080071static struct of_dev_auxdata msm8226_auxdata_lookup[] __initdata = {
72 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF9824000, \
73 "msm_sdcc.1", NULL),
74 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF98A4000, \
75 "msm_sdcc.2", NULL),
76 {}
77};
78
Mitchel Humpherys3c7c7122012-11-08 19:24:39 -080079static struct reserve_info msm8226_reserve_info __initdata = {
80 .memtype_reserve_table = msm8226_reserve_table,
81 .paddr_to_memtype = msm8226_paddr_to_memtype,
82};
83
84static void __init msm8226_early_memory(void)
85{
86 reserve_info = &msm8226_reserve_info;
Neeti Desaibfedbd32012-11-21 13:19:36 -080087 of_scan_flat_dt(dt_scan_for_memory_hole, msm8226_reserve_table);
Mitchel Humpherys3c7c7122012-11-08 19:24:39 -080088}
89
90static void __init msm8226_reserve(void)
91{
Neeti Desaibfedbd32012-11-21 13:19:36 -080092 reserve_info = &msm8226_reserve_info;
93 of_scan_flat_dt(dt_scan_for_memory_reserve, msm8226_reserve_table);
Mitchel Humpherys3c7c7122012-11-08 19:24:39 -080094 msm_reserve();
95}
96
Patrick Dalye682ac72013-01-22 15:21:37 -080097/*
98 * Used to satisfy dependencies for devices that need to be
99 * run early or in a particular order. Most likely your device doesn't fall
100 * into this category, and thus the driver should not be added here. The
101 * EPROBE_DEFER can satisfy most dependency problems.
102 */
Praveen Chidambaramde2a87b2012-12-20 16:13:53 -0700103void __init msm8226_add_drivers(void)
104{
105 msm_rpm_driver_init();
106 msm_lpmrs_module_init();
107 msm_spm_device_init();
David Keitelab876512013-02-19 12:01:07 -0800108 qpnp_regulator_init();
Patrick Dalyeb370ea2012-10-23 11:57:50 -0700109 if (machine_is_msm8226_rumi())
110 msm_clock_init(&msm8226_rumi_clock_init_data);
111 else
112 msm_clock_init(&msm8226_clock_init_data);
113
Praveen Chidambaramde2a87b2012-12-20 16:13:53 -0700114 msm_thermal_device_init();
115}
116
Syed Rameez Mustafae8156b42012-10-11 18:05:08 -0700117void __init msm8226_init(void)
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -0700118{
Syed Rameez Mustafa51d4d182012-11-20 14:36:43 -0800119 struct of_dev_auxdata *adata = msm8226_auxdata_lookup;
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800120
Abhimanyu Kapur91a0a502013-01-11 19:24:59 -0800121 if (socinfo_init() < 0)
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800122 pr_err("%s: socinfo_init() failed\n", __func__);
Syed Rameez Mustafa51d4d182012-11-20 14:36:43 -0800123
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700124 msm8226_init_gpiomux();
Syed Rameez Mustafa51d4d182012-11-20 14:36:43 -0800125 of_platform_populate(NULL, of_default_bus_match_table, adata, NULL);
Patrick Dalye682ac72013-01-22 15:21:37 -0800126 msm8226_add_drivers();
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -0700127}
128
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -0700129static const char *msm8226_dt_match[] __initconst = {
130 "qcom,msm8226",
131 NULL
132};
133
134DT_MACHINE_START(MSM8226_DT, "Qualcomm MSM 8226 (Flattened Device Tree)")
135 .map_io = msm_map_msm8226_io,
Praveen Chidambaramde2a87b2012-12-20 16:13:53 -0700136 .init_irq = msm_dt_init_irq,
Rohit Vaswani835707b2012-09-20 16:21:39 -0700137 .init_machine = msm8226_init,
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -0700138 .handle_irq = gic_handle_irq,
Rohit Vaswani835707b2012-09-20 16:21:39 -0700139 .timer = &msm_dt_timer,
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -0700140 .dt_compat = msm8226_dt_match,
Mitchel Humpherys3c7c7122012-11-08 19:24:39 -0800141 .reserve = msm8226_reserve,
Syed Rameez Mustafaf1bdd712012-11-20 14:56:44 -0800142 .init_very_early = msm8226_early_memory,
143 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -0800144 .smp = &arm_smp_ops,
Syed Rameez Mustafa878892c2012-08-23 17:30:32 -0700145MACHINE_END