Skip to content

Commit e1632b0

Browse files
committed
Merge pull request #634 from notro/dt
BCM2708: Add core Device Tree support
2 parents 8b06f99 + ba97112 commit e1632b0

File tree

6 files changed

+174
-0
lines changed

6 files changed

+174
-0
lines changed

arch/arm/boot/dts/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ dtb-$(CONFIG_ARCH_AT91) += sama5d35ek.dtb
5050
dtb-$(CONFIG_ARCH_AT91) += sama5d36ek.dtb
5151

5252
dtb-$(CONFIG_ARCH_ATLAS6) += atlas6-evb.dtb
53+
dtb-$(CONFIG_BCM2708_DT) += bcm2708-rpi-b.dtb
5354
dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb
5455
dtb-$(CONFIG_ARCH_BCM_5301X) += bcm4708-netgear-r6250.dtb
5556
dtb-$(CONFIG_ARCH_BCM_MOBILE) += bcm28155-ap.dtb \

arch/arm/boot/dts/bcm2708-rpi-b.dts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/dts-v1/;
2+
3+
/include/ "bcm2708.dtsi"
4+
5+
/ {
6+
compatible = "brcm,bcm2708";
7+
model = "Raspberry Pi";
8+
};

arch/arm/boot/dts/bcm2708.dtsi

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/include/ "skeleton.dtsi"
2+
3+
/ {
4+
compatible = "brcm,bcm2708";
5+
model = "BCM2708";
6+
7+
interrupt-parent = <&intc>;
8+
9+
chosen {
10+
/*
11+
bootargs must be 1024 characters long because the
12+
VC bootloader can't expand it
13+
*/
14+
bootargs = "console=ttyAMA0 ";
15+
};
16+
17+
axi {
18+
compatible = "simple-bus";
19+
#address-cells = <1>;
20+
#size-cells = <1>;
21+
ranges = <0x7e000000 0x20000000 0x02000000>;
22+
23+
intc: interrupt-controller {
24+
compatible = "brcm,bcm2708-armctrl-ic";
25+
reg = <0x7e00b200 0x200>;
26+
interrupt-controller;
27+
#interrupt-cells = <2>;
28+
};
29+
};
30+
31+
clocks {
32+
compatible = "simple-bus";
33+
#address-cells = <1>;
34+
#size-cells = <0>;
35+
};
36+
};

arch/arm/mach-bcm2708/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ config MACH_BCM2708
99
help
1010
Include support for the Broadcom(R) BCM2708 platform.
1111

12+
config BCM2708_DT
13+
bool "BCM2708 Device Tree support"
14+
depends on MACH_BCM2708
15+
default n
16+
select USE_OF
17+
help
18+
Enable Device Tree support for BCM2708
19+
1220
config BCM2708_GPIO
1321
bool "BCM2708 gpio support"
1422
depends on MACH_BCM2708

arch/arm/mach-bcm2708/armctrl.c

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <linux/version.h>
2424
#include <linux/syscore_ops.h>
2525
#include <linux/interrupt.h>
26+
#include <linux/irqdomain.h>
27+
#include <linux/of.h>
2628

2729
#include <asm/mach/irq.h>
2830
#include <mach/hardware.h>
@@ -79,6 +81,100 @@ static void armctrl_unmask_irq(struct irq_data *d)
7981
}
8082
}
8183

84+
#ifdef CONFIG_OF
85+
86+
#define NR_IRQS_BANK0 21
87+
#define NR_BANKS 3 + 1 /* bank 3 is used for GPIO interrupts */
88+
#define IRQS_PER_BANK 32
89+
90+
/* from drivers/irqchip/irq-bcm2835.c */
91+
static int armctrl_xlate(struct irq_domain *d, struct device_node *ctrlr,
92+
const u32 *intspec, unsigned int intsize,
93+
unsigned long *out_hwirq, unsigned int *out_type)
94+
{
95+
if (WARN_ON(intsize != 2))
96+
return -EINVAL;
97+
98+
if (WARN_ON(intspec[0] >= NR_BANKS))
99+
return -EINVAL;
100+
101+
if (WARN_ON(intspec[1] >= IRQS_PER_BANK))
102+
return -EINVAL;
103+
104+
if (WARN_ON(intspec[0] == 0 && intspec[1] >= NR_IRQS_BANK0))
105+
return -EINVAL;
106+
107+
if (intspec[0] == 0)
108+
*out_hwirq = ARM_IRQ0_BASE + intspec[1];
109+
else if (intspec[0] == 1)
110+
*out_hwirq = ARM_IRQ1_BASE + intspec[1];
111+
else if (intspec[0] == 2)
112+
*out_hwirq = ARM_IRQ2_BASE + intspec[1];
113+
else
114+
*out_hwirq = GPIO_IRQ_START + intspec[1];
115+
116+
/* reverse remap_irqs[] */
117+
switch (*out_hwirq) {
118+
case INTERRUPT_VC_JPEG:
119+
*out_hwirq = INTERRUPT_JPEG;
120+
break;
121+
case INTERRUPT_VC_USB:
122+
*out_hwirq = INTERRUPT_USB;
123+
break;
124+
case INTERRUPT_VC_3D:
125+
*out_hwirq = INTERRUPT_3D;
126+
break;
127+
case INTERRUPT_VC_DMA2:
128+
*out_hwirq = INTERRUPT_DMA2;
129+
break;
130+
case INTERRUPT_VC_DMA3:
131+
*out_hwirq = INTERRUPT_DMA3;
132+
break;
133+
case INTERRUPT_VC_I2C:
134+
*out_hwirq = INTERRUPT_I2C;
135+
break;
136+
case INTERRUPT_VC_SPI:
137+
*out_hwirq = INTERRUPT_SPI;
138+
break;
139+
case INTERRUPT_VC_I2SPCM:
140+
*out_hwirq = INTERRUPT_I2SPCM;
141+
break;
142+
case INTERRUPT_VC_SDIO:
143+
*out_hwirq = INTERRUPT_SDIO;
144+
break;
145+
case INTERRUPT_VC_UART:
146+
*out_hwirq = INTERRUPT_UART;
147+
break;
148+
case INTERRUPT_VC_ARASANSDIO:
149+
*out_hwirq = INTERRUPT_ARASANSDIO;
150+
break;
151+
}
152+
153+
*out_type = IRQ_TYPE_NONE;
154+
return 0;
155+
}
156+
157+
static struct irq_domain_ops armctrl_ops = {
158+
.xlate = armctrl_xlate
159+
};
160+
161+
void __init armctrl_dt_init(void)
162+
{
163+
struct device_node *np;
164+
struct irq_domain *domain;
165+
166+
np = of_find_compatible_node(NULL, NULL, "brcm,bcm2708-armctrl-ic");
167+
if (!np)
168+
return;
169+
170+
domain = irq_domain_add_legacy(np, NR_IRQS, IRQ_ARMCTRL_START, 0,
171+
&armctrl_ops, NULL);
172+
WARN_ON(!domain);
173+
}
174+
#else
175+
void __init armctrl_dt_init(void) { }
176+
#endif /* CONFIG_OF */
177+
82178
#if defined(CONFIG_PM)
83179

84180
/* for kernels 3.xx use the new syscore_ops apis but for older kernels use the sys dev class */
@@ -215,5 +311,6 @@ int __init armctrl_init(void __iomem * base, unsigned int irq_start,
215311

216312
armctrl_pm_register(base, irq_start, resume_sources);
217313
init_FIQ(FIQ_START);
314+
armctrl_dt_init();
218315
return 0;
219316
}

arch/arm/mach-bcm2708/bcm2708.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/cnt32_to_63.h>
3434
#include <linux/io.h>
3535
#include <linux/module.h>
36+
#include <linux/of_platform.h>
3637
#include <linux/spi/spi.h>
3738
#include <linux/w1-gpio.h>
3839

@@ -762,6 +763,22 @@ static void bcm2708_power_off(void)
762763
}
763764
}
764765

766+
#ifdef CONFIG_OF
767+
static void __init bcm2708_dt_init(void)
768+
{
769+
int ret;
770+
771+
of_clk_init(NULL);
772+
ret = of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
773+
if (ret) {
774+
pr_err("of_platform_populate failed: %d\n", ret);
775+
BUG();
776+
}
777+
}
778+
#else
779+
static void __init bcm2708_dt_init(void) { }
780+
#endif /* CONFIG_OF */
781+
765782
void __init bcm2708_init(void)
766783
{
767784
int i;
@@ -773,6 +790,7 @@ void __init bcm2708_init(void)
773790
pm_power_off = bcm2708_power_off;
774791

775792
bcm2708_init_clocks();
793+
bcm2708_dt_init();
776794

777795
bcm_register_device(&bcm2708_dmaman_device);
778796
bcm_register_device(&bcm2708_vcio_device);
@@ -996,6 +1014,11 @@ static void __init board_reserve(void)
9961014
#endif
9971015
}
9981016

1017+
static const char * const bcm2708_compat[] = {
1018+
"brcm,bcm2708",
1019+
NULL
1020+
};
1021+
9991022
MACHINE_START(BCM2708, "BCM2708")
10001023
/* Maintainer: Broadcom Europe Ltd. */
10011024
.map_io = bcm2708_map_io,
@@ -1005,6 +1028,7 @@ MACHINE_START(BCM2708, "BCM2708")
10051028
.init_early = bcm2708_init_early,
10061029
.reserve = board_reserve,
10071030
.restart = bcm2708_restart,
1031+
.dt_compat = bcm2708_compat,
10081032
MACHINE_END
10091033

10101034
module_param(boardrev, uint, 0644);

0 commit comments

Comments
 (0)