Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. 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 | |
| 13 | #include <linux/err.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/of.h> |
| 16 | #include <linux/of_address.h> |
| 17 | #include <linux/of_platform.h> |
| 18 | #include <linux/memory.h> |
| 19 | #include <asm/hardware/gic.h> |
| 20 | #include <asm/mach/map.h> |
| 21 | #include <asm/mach/arch.h> |
| 22 | #include <mach/board.h> |
| 23 | #include <mach/gpiomux.h> |
| 24 | #include <mach/msm_iomap.h> |
Laura Abbott | e17c533 | 2013-03-05 14:21:43 -0800 | [diff] [blame] | 25 | #include <mach/msm_memtypes.h> |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 26 | #include <mach/msm_smd.h> |
| 27 | #include <mach/restart.h> |
| 28 | #include <mach/socinfo.h> |
| 29 | #include <mach/clk-provider.h> |
| 30 | #include "board-dt.h" |
| 31 | #include "clock.h" |
| 32 | #include "devices.h" |
| 33 | #include "platsmp.h" |
| 34 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 35 | static struct memtype_reserve apq8084_reserve_table[] __initdata = { |
Laura Abbott | e17c533 | 2013-03-05 14:21:43 -0800 | [diff] [blame] | 36 | [MEMTYPE_SMI] = { |
| 37 | }, |
| 38 | [MEMTYPE_EBI0] = { |
| 39 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 40 | }, |
| 41 | [MEMTYPE_EBI1] = { |
| 42 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 43 | }, |
| 44 | }; |
| 45 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 46 | static int apq8084_paddr_to_memtype(phys_addr_t paddr) |
Laura Abbott | e17c533 | 2013-03-05 14:21:43 -0800 | [diff] [blame] | 47 | { |
| 48 | return MEMTYPE_EBI1; |
| 49 | } |
| 50 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 51 | static struct reserve_info apq8084_reserve_info __initdata = { |
| 52 | .memtype_reserve_table = apq8084_reserve_table, |
| 53 | .paddr_to_memtype = apq8084_paddr_to_memtype, |
Laura Abbott | e17c533 | 2013-03-05 14:21:43 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
David Ng | 7b838c2 | 2013-04-11 17:38:37 -0700 | [diff] [blame] | 56 | static struct of_dev_auxdata apq8084_auxdata_lookup[] __initdata = { |
| 57 | OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF9824000, \ |
| 58 | "msm_sdcc.1", NULL), |
| 59 | OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF98A4000, \ |
| 60 | "msm_sdcc.2", NULL), |
| 61 | {} |
| 62 | }; |
| 63 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 64 | void __init apq8084_reserve(void) |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 65 | { |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 66 | reserve_info = &apq8084_reserve_info; |
| 67 | of_scan_flat_dt(dt_scan_for_memory_reserve, apq8084_reserve_table); |
Laura Abbott | e17c533 | 2013-03-05 14:21:43 -0800 | [diff] [blame] | 68 | msm_reserve(); |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 69 | } |
| 70 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 71 | static void __init apq8084_early_memory(void) |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 72 | { |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 73 | reserve_info = &apq8084_reserve_info; |
| 74 | of_scan_flat_dt(dt_scan_for_memory_hole, apq8084_reserve_table); |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 77 | /* |
| 78 | * Used to satisfy dependencies for devices that need to be |
| 79 | * run early or in a particular order. Most likely your device doesn't fall |
| 80 | * into this category, and thus the driver should not be added here. The |
| 81 | * EPROBE_DEFER can satisfy most dependency problems. |
| 82 | */ |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 83 | void __init apq8084_add_drivers(void) |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 84 | { |
| 85 | msm_smd_init(); |
Tianyi Gou | 30e19b8 | 2013-05-06 20:53:24 -0700 | [diff] [blame] | 86 | msm_clock_init(&msm8084_clock_init_data); |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 89 | static void __init apq8084_map_io(void) |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 90 | { |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 91 | msm_map_8084_io(); |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 94 | void __init apq8084_init(void) |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 95 | { |
David Ng | 7b838c2 | 2013-04-11 17:38:37 -0700 | [diff] [blame] | 96 | struct of_dev_auxdata *adata = apq8084_auxdata_lookup; |
| 97 | |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 98 | if (socinfo_init() < 0) |
| 99 | pr_err("%s: socinfo_init() failed\n", __func__); |
| 100 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 101 | apq8084_init_gpiomux(); |
Stepan Moskovchenko | 7d8cdcaa | 2013-04-25 17:10:55 -0700 | [diff] [blame] | 102 | board_dt_populate(adata); |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 103 | apq8084_add_drivers(); |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 106 | void __init apq8084_init_very_early(void) |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 107 | { |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 108 | apq8084_early_memory(); |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 109 | } |
| 110 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 111 | static const char *apq8084_dt_match[] __initconst = { |
| 112 | "qcom,apq8084", |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 113 | NULL |
| 114 | }; |
| 115 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 116 | DT_MACHINE_START(APQ8084_DT, "Qualcomm APQ 8084 (Flattened Device Tree)") |
| 117 | .map_io = apq8084_map_io, |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 118 | .init_irq = msm_dt_init_irq, |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 119 | .init_machine = apq8084_init, |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 120 | .handle_irq = gic_handle_irq, |
| 121 | .timer = &msm_dt_timer, |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 122 | .dt_compat = apq8084_dt_match, |
| 123 | .reserve = apq8084_reserve, |
| 124 | .init_very_early = apq8084_init_very_early, |
Stepan Moskovchenko | fb941ac | 2013-01-24 15:59:24 -0800 | [diff] [blame] | 125 | .restart = msm_restart, |
| 126 | .smp = &msm8974_smp_ops, |
| 127 | MACHINE_END |