David Brown | 56e2d8a | 2011-08-04 02:01:02 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010, 2011, Code Aurora Forum. All rights reserved. |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [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. |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/io.h> |
Steve Muckle | 9161d30 | 2010-02-11 11:50:40 -0800 | [diff] [blame] | 16 | #include <linux/irq.h> |
David Brown | 56e2d8a | 2011-08-04 02:01:02 -0700 | [diff] [blame] | 17 | #include <linux/irqdomain.h> |
| 18 | #include <linux/of.h> |
| 19 | #include <linux/of_address.h> |
David Brown | 2b7b9a7 | 2012-04-23 15:34:20 -0700 | [diff] [blame] | 20 | #include <linux/of_irq.h> |
David Brown | 56e2d8a | 2011-08-04 02:01:02 -0700 | [diff] [blame] | 21 | #include <linux/of_platform.h> |
Stephen Boyd | 9e775ad | 2011-08-12 00:14:28 +0100 | [diff] [blame] | 22 | #include <linux/memblock.h> |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 23 | |
| 24 | #include <asm/mach-types.h> |
| 25 | #include <asm/mach/arch.h> |
| 26 | #include <asm/hardware/gic.h> |
Stephen Boyd | 9e775ad | 2011-08-12 00:14:28 +0100 | [diff] [blame] | 27 | #include <asm/setup.h> |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 28 | |
| 29 | #include <mach/board.h> |
| 30 | #include <mach/msm_iomap.h> |
| 31 | |
Stephen Boyd | 47a6770 | 2011-10-25 09:35:19 -0700 | [diff] [blame] | 32 | static void __init msm8x60_fixup(struct tag *tag, char **cmdline, |
| 33 | struct meminfo *mi) |
Stephen Boyd | 9e775ad | 2011-08-12 00:14:28 +0100 | [diff] [blame] | 34 | { |
| 35 | for (; tag->hdr.size; tag = tag_next(tag)) |
| 36 | if (tag->hdr.tag == ATAG_MEM && |
| 37 | tag->u.mem.start == 0x40200000) { |
| 38 | tag->u.mem.start = 0x40000000; |
| 39 | tag->u.mem.size += SZ_2M; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | static void __init msm8x60_reserve(void) |
| 44 | { |
| 45 | memblock_remove(0x40000000, SZ_2M); |
| 46 | } |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 47 | |
| 48 | static void __init msm8x60_map_io(void) |
| 49 | { |
| 50 | msm_map_msm8x60_io(); |
| 51 | } |
| 52 | |
David Brown | 2b7b9a7 | 2012-04-23 15:34:20 -0700 | [diff] [blame] | 53 | #ifdef CONFIG_OF |
| 54 | static struct of_device_id msm_dt_gic_match[] __initdata = { |
| 55 | { .compatible = "qcom,msm-8660-qgic", .data = gic_of_init }, |
| 56 | {} |
| 57 | }; |
| 58 | #endif |
| 59 | |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 60 | static void __init msm8x60_init_irq(void) |
| 61 | { |
David Brown | 2b7b9a7 | 2012-04-23 15:34:20 -0700 | [diff] [blame] | 62 | if (!of_have_populated_dt()) |
| 63 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, |
| 64 | (void *)MSM_QGIC_CPU_BASE); |
| 65 | #ifdef CONFIG_OF |
| 66 | else |
| 67 | of_irq_init(msm_dt_gic_match); |
| 68 | #endif |
Steve Muckle | 9161d30 | 2010-02-11 11:50:40 -0800 | [diff] [blame] | 69 | |
| 70 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ |
| 71 | writel(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); |
| 72 | |
| 73 | /* RUMI does not adhere to GIC spec by enabling STIs by default. |
| 74 | * Enable/clear is supposed to be RO for STIs, but is RW on RUMI. |
| 75 | */ |
Steve Muckle | 57bbf1c | 2010-01-07 12:51:10 -0800 | [diff] [blame] | 76 | if (!machine_is_msm8x60_sim()) |
| 77 | writel(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET); |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | static void __init msm8x60_init(void) |
| 81 | { |
| 82 | } |
| 83 | |
David Brown | 56e2d8a | 2011-08-04 02:01:02 -0700 | [diff] [blame] | 84 | #ifdef CONFIG_OF |
| 85 | static struct of_dev_auxdata msm_auxdata_lookup[] __initdata = { |
| 86 | {} |
| 87 | }; |
| 88 | |
David Brown | 56e2d8a | 2011-08-04 02:01:02 -0700 | [diff] [blame] | 89 | static void __init msm8x60_dt_init(void) |
| 90 | { |
David Brown | 56e2d8a | 2011-08-04 02:01:02 -0700 | [diff] [blame] | 91 | if (of_machine_is_compatible("qcom,msm8660-surf")) { |
| 92 | printk(KERN_INFO "Init surf UART registers\n"); |
| 93 | msm8x60_init_uart12dm(); |
| 94 | } |
| 95 | |
| 96 | of_platform_populate(NULL, of_default_bus_match_table, |
| 97 | msm_auxdata_lookup, NULL); |
| 98 | } |
| 99 | |
| 100 | static const char *msm8x60_fluid_match[] __initdata = { |
| 101 | "qcom,msm8660-fluid", |
| 102 | "qcom,msm8660-surf", |
| 103 | NULL |
| 104 | }; |
| 105 | #endif /* CONFIG_OF */ |
| 106 | |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 107 | MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3") |
Stephen Boyd | 9e775ad | 2011-08-12 00:14:28 +0100 | [diff] [blame] | 108 | .fixup = msm8x60_fixup, |
| 109 | .reserve = msm8x60_reserve, |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 110 | .map_io = msm8x60_map_io, |
| 111 | .init_irq = msm8x60_init_irq, |
Marc Zyngier | 041f777 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 112 | .handle_irq = gic_handle_irq, |
Steve Muckle | a55df6e | 2010-01-07 12:43:24 -0800 | [diff] [blame] | 113 | .init_machine = msm8x60_init, |
| 114 | .timer = &msm_timer, |
| 115 | MACHINE_END |
Steve Muckle | 49b76f7 | 2010-03-19 17:00:08 -0700 | [diff] [blame] | 116 | |
| 117 | MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF") |
Stephen Boyd | 9e775ad | 2011-08-12 00:14:28 +0100 | [diff] [blame] | 118 | .fixup = msm8x60_fixup, |
| 119 | .reserve = msm8x60_reserve, |
Steve Muckle | 49b76f7 | 2010-03-19 17:00:08 -0700 | [diff] [blame] | 120 | .map_io = msm8x60_map_io, |
| 121 | .init_irq = msm8x60_init_irq, |
Marc Zyngier | 041f777 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 122 | .handle_irq = gic_handle_irq, |
Steve Muckle | 49b76f7 | 2010-03-19 17:00:08 -0700 | [diff] [blame] | 123 | .init_machine = msm8x60_init, |
| 124 | .timer = &msm_timer, |
| 125 | MACHINE_END |
Steve Muckle | 57bbf1c | 2010-01-07 12:51:10 -0800 | [diff] [blame] | 126 | |
| 127 | MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR") |
Stephen Boyd | 9e775ad | 2011-08-12 00:14:28 +0100 | [diff] [blame] | 128 | .fixup = msm8x60_fixup, |
| 129 | .reserve = msm8x60_reserve, |
Steve Muckle | 57bbf1c | 2010-01-07 12:51:10 -0800 | [diff] [blame] | 130 | .map_io = msm8x60_map_io, |
| 131 | .init_irq = msm8x60_init_irq, |
Marc Zyngier | 041f777 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 132 | .handle_irq = gic_handle_irq, |
Steve Muckle | 57bbf1c | 2010-01-07 12:51:10 -0800 | [diff] [blame] | 133 | .init_machine = msm8x60_init, |
| 134 | .timer = &msm_timer, |
| 135 | MACHINE_END |
Gregory Bean | 69b7f6f | 2010-04-04 22:29:02 -0700 | [diff] [blame] | 136 | |
| 137 | MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA") |
Stephen Boyd | 9e775ad | 2011-08-12 00:14:28 +0100 | [diff] [blame] | 138 | .fixup = msm8x60_fixup, |
| 139 | .reserve = msm8x60_reserve, |
Gregory Bean | 69b7f6f | 2010-04-04 22:29:02 -0700 | [diff] [blame] | 140 | .map_io = msm8x60_map_io, |
| 141 | .init_irq = msm8x60_init_irq, |
Marc Zyngier | 041f777 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 142 | .handle_irq = gic_handle_irq, |
Gregory Bean | 69b7f6f | 2010-04-04 22:29:02 -0700 | [diff] [blame] | 143 | .init_machine = msm8x60_init, |
| 144 | .timer = &msm_timer, |
| 145 | MACHINE_END |
David Brown | 56e2d8a | 2011-08-04 02:01:02 -0700 | [diff] [blame] | 146 | |
| 147 | #ifdef CONFIG_OF |
| 148 | /* TODO: General device tree support for all MSM. */ |
| 149 | DT_MACHINE_START(MSM_DT, "Qualcomm MSM (Flattened Device Tree)") |
| 150 | .map_io = msm8x60_map_io, |
| 151 | .init_irq = msm8x60_init_irq, |
| 152 | .init_machine = msm8x60_dt_init, |
| 153 | .timer = &msm_timer, |
| 154 | .dt_compat = msm8x60_fluid_match, |
| 155 | MACHINE_END |
| 156 | #endif /* CONFIG_OF */ |