ath79: add support for TP-LINK Archer C7 v4
[openwrt/staging/jogo.git] / target / linux / brcm2708 / patches-4.9 / 950-0030-Main-bcm2708-bcm2709-linux-port.patch
1 From 9874eb6473865b9d975a7c3756099955e7454e21 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Sun, 12 May 2013 12:24:19 +0100
4 Subject: [PATCH] Main bcm2708/bcm2709 linux port
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Signed-off-by: popcornmix <popcornmix@gmail.com>
10 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
11
12 bcm2709: Drop platform smp and timer init code
13
14 irq-bcm2836 handles this through these functions:
15 bcm2835_init_local_timer_frequency()
16 bcm2836_arm_irqchip_smp_init()
17
18 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
19
20 bcm270x: Use watchdog for reboot/poweroff
21
22 The watchdog driver already has support for reboot/poweroff.
23 Make use of this and remove the code from the platform files.
24
25 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
26 ---
27 arch/arm/mach-bcm/Kconfig | 1 +
28 arch/arm/mach-bcm/board_bcm2835.c | 17 +++++++++++++++++
29 arch/arm/mm/proc-v6.S | 15 ++++++++++++---
30 drivers/irqchip/irq-bcm2835.c | 7 ++++++-
31 drivers/mailbox/bcm2835-mailbox.c | 18 ++++++++++++++++--
32 5 files changed, 52 insertions(+), 6 deletions(-)
33
34 --- a/arch/arm/mach-bcm/Kconfig
35 +++ b/arch/arm/mach-bcm/Kconfig
36 @@ -155,6 +155,7 @@ config ARCH_BCM2835
37 select FIQ
38 select PINCTRL
39 select PINCTRL_BCM2835
40 + select MFD_SYSCON if ARCH_MULTI_V7
41 help
42 This enables support for the Broadcom BCM2835 and BCM2836 SoCs.
43 This SoC is used in the Raspberry Pi and Roku 2 devices.
44 --- a/arch/arm/mach-bcm/board_bcm2835.c
45 +++ b/arch/arm/mach-bcm/board_bcm2835.c
46 @@ -16,17 +16,21 @@
47 #include <linux/irqchip.h>
48 #include <linux/of_address.h>
49 #include <linux/clk/bcm2835.h>
50 +#include <linux/broadcom/vc_cma.h>
51 #include <asm/system_info.h>
52
53 #include <asm/mach/arch.h>
54 #include <asm/mach/map.h>
55
56 +#include <linux/dma-mapping.h>
57 +
58 static void __init bcm2835_init(void)
59 {
60 struct device_node *np = of_find_node_by_path("/system");
61 u32 val;
62 u64 val64;
63
64 + vc_cma_early_init();
65 bcm2835_init_clocks();
66
67 if (!of_property_read_u32(np, "linux,revision", &val))
68 @@ -35,6 +39,17 @@ static void __init bcm2835_init(void)
69 system_serial_low = val64;
70 }
71
72 +static void __init bcm2835_init_early(void)
73 +{
74 + /* dwc_otg needs this for bounce buffers on non-aligned transfers */
75 + init_dma_coherent_pool_size(SZ_1M);
76 +}
77 +
78 +static void __init bcm2835_board_reserve(void)
79 +{
80 + vc_cma_reserve();
81 +}
82 +
83 static const char * const bcm2835_compat[] = {
84 #ifdef CONFIG_ARCH_MULTI_V6
85 "brcm,bcm2835",
86 @@ -47,5 +62,7 @@ static const char * const bcm2835_compat
87
88 DT_MACHINE_START(BCM2835, "BCM2835")
89 .init_machine = bcm2835_init,
90 + .reserve = bcm2835_board_reserve,
91 + .init_early = bcm2835_init_early,
92 .dt_compat = bcm2835_compat
93 MACHINE_END
94 --- a/arch/arm/mm/proc-v6.S
95 +++ b/arch/arm/mm/proc-v6.S
96 @@ -73,10 +73,19 @@ ENDPROC(cpu_v6_reset)
97 *
98 * IRQs are already disabled.
99 */
100 +
101 +/* See jira SW-5991 for details of this workaround */
102 ENTRY(cpu_v6_do_idle)
103 - mov r1, #0
104 - mcr p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
105 - mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
106 + .align 5
107 + mov r1, #2
108 +1: subs r1, #1
109 + nop
110 + mcreq p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
111 + mcreq p15, 0, r1, c7, c0, 4 @ wait for interrupt
112 + nop
113 + nop
114 + nop
115 + bne 1b
116 ret lr
117
118 ENTRY(cpu_v6_dcache_clean_area)
119 --- a/drivers/irqchip/irq-bcm2835.c
120 +++ b/drivers/irqchip/irq-bcm2835.c
121 @@ -54,7 +54,9 @@
122 #include <linux/regmap.h>
123
124 #include <asm/exception.h>
125 +#ifndef CONFIG_ARM64
126 #include <asm/mach/irq.h>
127 +#endif
128
129 /* Put the bank and irq (32 bits) into the hwirq */
130 #define MAKE_HWIRQ(b, n) (((b) << 5) | (n))
131 @@ -82,6 +84,7 @@
132 #define NR_BANKS 3
133 #define IRQS_PER_BANK 32
134 #define NUMBER_IRQS MAKE_HWIRQ(NR_BANKS, 0)
135 +#undef FIQ_START
136 #define FIQ_START (NR_IRQS_BANK0 + MAKE_HWIRQ(NR_BANKS - 1, 0))
137
138 static const int reg_pending[] __initconst = { 0x00, 0x04, 0x08 };
139 @@ -256,10 +259,12 @@ static int __init armctrl_of_init(struct
140 MAKE_HWIRQ(b, i) + NUMBER_IRQS);
141 BUG_ON(irq <= 0);
142 irq_set_chip(irq, &armctrl_chip);
143 - set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
144 + irq_set_probe(irq);
145 }
146 }
147 +#ifndef CONFIG_ARM64
148 init_FIQ(FIQ_START);
149 +#endif
150
151 return 0;
152 }
153 --- a/drivers/mailbox/bcm2835-mailbox.c
154 +++ b/drivers/mailbox/bcm2835-mailbox.c
155 @@ -51,12 +51,15 @@
156 #define MAIL1_WRT (ARM_0_MAIL1 + 0x00)
157 #define MAIL1_STA (ARM_0_MAIL1 + 0x18)
158
159 +/* On ARCH_BCM270x these come through <linux/interrupt.h> (arm_control.h ) */
160 +#ifndef ARM_MS_FULL
161 /* Status register: FIFO state. */
162 #define ARM_MS_FULL BIT(31)
163 #define ARM_MS_EMPTY BIT(30)
164
165 /* Configuration register: Enable interrupts. */
166 #define ARM_MC_IHAVEDATAIRQEN BIT(0)
167 +#endif
168
169 struct bcm2835_mbox {
170 void __iomem *regs;
171 @@ -151,7 +154,7 @@ static int bcm2835_mbox_probe(struct pla
172 return -ENOMEM;
173 spin_lock_init(&mbox->lock);
174
175 - ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
176 + ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
177 bcm2835_mbox_irq, 0, dev_name(dev), mbox);
178 if (ret) {
179 dev_err(dev, "Failed to register a mailbox IRQ handler: %d\n",
180 @@ -209,7 +212,18 @@ static struct platform_driver bcm2835_mb
181 .probe = bcm2835_mbox_probe,
182 .remove = bcm2835_mbox_remove,
183 };
184 -module_platform_driver(bcm2835_mbox_driver);
185 +
186 +static int __init bcm2835_mbox_init(void)
187 +{
188 + return platform_driver_register(&bcm2835_mbox_driver);
189 +}
190 +arch_initcall(bcm2835_mbox_init);
191 +
192 +static void __init bcm2835_mbox_exit(void)
193 +{
194 + platform_driver_unregister(&bcm2835_mbox_driver);
195 +}
196 +module_exit(bcm2835_mbox_exit);
197
198 MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
199 MODULE_DESCRIPTION("BCM2835 mailbox IPC driver");