Abhimanyu Kapur | 032b1f4 | 2013-01-18 00:10:50 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 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 | |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 13 | #include <linux/gpio.h> |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 14 | #include <linux/kernel.h> |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 15 | #include <linux/of.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 16 | #include <linux/of_irq.h> |
Abhimanyu Kapur | 032b1f4 | 2013-01-18 00:10:50 -0800 | [diff] [blame] | 17 | #include <linux/of_fdt.h> |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 18 | #include <linux/mfd/wcd9xxx/core.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 19 | #include <asm/arch_timer.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 20 | #include <asm/mach/time.h> |
Abhimanyu Kapur | 032b1f4 | 2013-01-18 00:10:50 -0800 | [diff] [blame] | 21 | #include <asm/mach/map.h> |
Rohit Vaswani | 7af3b53 | 2012-09-21 10:54:49 -0700 | [diff] [blame] | 22 | #include <asm/hardware/cache-l2x0.h> |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 23 | #include <asm/hardware/gic.h> |
| 24 | #include <mach/mpm.h> |
| 25 | #include <mach/qpnp-int.h> |
Abhimanyu Kapur | 032b1f4 | 2013-01-18 00:10:50 -0800 | [diff] [blame] | 26 | #include <mach/msm_iomap.h> |
Rohit Vaswani | 7af3b53 | 2012-09-21 10:54:49 -0700 | [diff] [blame] | 27 | #include <mach/scm.h> |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 28 | |
| 29 | #include "board-dt.h" |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 30 | |
Rohit Vaswani | 7af3b53 | 2012-09-21 10:54:49 -0700 | [diff] [blame] | 31 | #define SCM_SVC_L2CC_PL310 16 |
| 32 | #define L2CC_PL310_CTRL_ID 1 |
| 33 | #define L2CC_PL310_ON 1 |
| 34 | |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 35 | static void __init msm_dt_timer_init(void) |
| 36 | { |
Sathish Ambley | 2f27a17 | 2012-03-16 10:46:28 -0700 | [diff] [blame] | 37 | arch_timer_of_register(); |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 38 | } |
| 39 | |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 40 | struct sys_timer msm_dt_timer = { |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 41 | .init = msm_dt_timer_init |
| 42 | }; |
| 43 | |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 44 | static struct of_device_id irq_match[] __initdata = { |
| 45 | { .compatible = "qcom,msm-qgic2", .data = gic_of_init, }, |
| 46 | { .compatible = "qcom,msm-gpio", .data = msm_gpio_of_init, }, |
| 47 | { .compatible = "qcom,spmi-pmic-arb", .data = qpnpint_of_init, }, |
| 48 | { .compatible = "qcom,wcd9xxx-irq", .data = wcd9xxx_irq_of_init, }, |
| 49 | {} |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 52 | static struct of_device_id mpm_match[] __initdata = { |
| 53 | {.compatible = "qcom,mpm-v2", }, |
| 54 | {} |
| 55 | }; |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 56 | |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 57 | void __init msm_dt_init_irq(void) |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 58 | { |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 59 | struct device_node *node; |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 60 | |
Rohit Vaswani | 750bee1 | 2012-09-20 16:18:10 -0700 | [diff] [blame] | 61 | of_irq_init(irq_match); |
| 62 | node = of_find_matching_node(NULL, mpm_match); |
| 63 | |
| 64 | WARN_ON(!node); |
| 65 | |
| 66 | if (node) |
| 67 | of_mpm_init(node); |
| 68 | } |
Rohit Vaswani | 835707b | 2012-09-20 16:21:39 -0700 | [diff] [blame] | 69 | |
| 70 | void __init msm_dt_init_irq_nompm(void) |
| 71 | { |
| 72 | of_irq_init(irq_match); |
| 73 | } |
Rohit Vaswani | 7af3b53 | 2012-09-21 10:54:49 -0700 | [diff] [blame] | 74 | |
| 75 | void __init msm_dt_init_irq_l2x0(void) |
| 76 | { |
| 77 | scm_call_atomic1(SCM_SVC_L2CC_PL310, L2CC_PL310_CTRL_ID, L2CC_PL310_ON); |
| 78 | l2x0_of_init(0, ~0UL); |
| 79 | msm_dt_init_irq(); |
| 80 | } |
Abhimanyu Kapur | 032b1f4 | 2013-01-18 00:10:50 -0800 | [diff] [blame] | 81 | |
| 82 | int __init msm_scan_dt_map_imem(unsigned long node, const char *uname, |
| 83 | int depth, void *data) |
| 84 | { |
| 85 | unsigned int *imem_prop; |
| 86 | unsigned long imem_prop_len; |
| 87 | struct map_desc map; |
| 88 | int ret; |
| 89 | const char *compat = "qcom,msm-imem"; |
| 90 | |
| 91 | ret = of_flat_dt_is_compatible(node, compat); |
| 92 | |
| 93 | if (!ret) |
| 94 | return 0; |
| 95 | |
| 96 | imem_prop = of_get_flat_dt_prop(node, "reg", |
| 97 | &imem_prop_len); |
| 98 | |
| 99 | if (!imem_prop) { |
| 100 | WARN(1, "IMEM reg field not found\n"); |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | if (imem_prop_len != (2*sizeof(u32))) { |
| 105 | WARN(1, "IMEM range malformed\n"); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | map.virtual = (unsigned long)MSM_IMEM_BASE; |
| 110 | map.pfn = __phys_to_pfn(be32_to_cpu(imem_prop[0])); |
| 111 | map.length = be32_to_cpu(imem_prop[1]); |
| 112 | map.type = MT_DEVICE; |
| 113 | iotable_init(&map, 1); |
| 114 | pr_info("IMEM DT static mapping successful\n"); |
| 115 | |
| 116 | return 1; |
| 117 | } |
Stepan Moskovchenko | 7d8cdcaa | 2013-04-25 17:10:55 -0700 | [diff] [blame] | 118 | |
| 119 | void __init board_dt_populate(struct of_dev_auxdata *adata) |
| 120 | { |
| 121 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 122 | |
| 123 | /* Explicitly parent the /soc devices to the root node to preserve |
| 124 | * the kernel ABI (sysfs structure, etc) until userspace is updated |
| 125 | */ |
| 126 | of_platform_populate(of_find_node_by_path("/soc"), |
| 127 | of_default_bus_match_table, adata, NULL); |
| 128 | } |