svn commit: r307067 - head/sys/arm/broadcom/bcm2835
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Tue Oct 11 21:37:36 UTC 2016
Author: gonzo
Date: Tue Oct 11 21:37:34 2016
New Revision: 307067
URL: https://svnweb.freebsd.org/changeset/base/307067
Log:
Make intc driver compatible with upstream DTS
- Fix compatibility strings
- Properly decode upstream's two-cell interrupt specs. Our home-made dts
does not have two-cell interrupts so no need to preserve backward
compatibility
Modified:
head/sys/arm/broadcom/bcm2835/bcm2835_common.c
head/sys/arm/broadcom/bcm2835/bcm2835_intr.c
Modified: head/sys/arm/broadcom/bcm2835/bcm2835_common.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 11 20:31:59 2016 (r307066)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 11 21:37:34 2016 (r307067)
@@ -52,7 +52,8 @@ fdt_intc_decode_ic(phandle_t node, pcell
int *pol)
{
- if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic")) {
+ if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic") ||
+ fdt_is_compatible(node, "brcm,bcm2836-armctrl-ic")) {
*interrupt = fdt32_to_cpu(intr[0]);
*trig = INTR_TRIGGER_CONFORM;
*pol = INTR_POLARITY_CONFORM;
Modified: head/sys/arm/broadcom/bcm2835/bcm2835_intr.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Tue Oct 11 20:31:59 2016 (r307066)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Tue Oct 11 21:37:34 2016 (r307067)
@@ -270,6 +270,7 @@ bcm_intc_map_intr(device_t dev, struct i
u_int irq;
struct intr_map_data_fdt *daf;
struct bcm_intc_softc *sc;
+ bool valid;
if (data->type != INTR_MAP_DATA_FDT)
return (ENOTSUP);
@@ -277,8 +278,36 @@ bcm_intc_map_intr(device_t dev, struct i
daf = (struct intr_map_data_fdt *)data;
if (daf->ncells == 1)
irq = daf->cells[0];
- else if (daf->ncells == 2)
- irq = daf->cells[0] * 32 + daf->cells[1];
+ else if (daf->ncells == 2) {
+ valid = true;
+ switch (daf->cells[0]) {
+ case 0:
+ irq = daf->cells[1];
+ if (irq >= BANK1_START)
+ valid = false;
+ break;
+ case 1:
+ irq = daf->cells[1] + BANK1_START;
+ if (irq > BANK1_END)
+ valid = false;
+ break;
+ case 2:
+ irq = daf->cells[1] + BANK2_START;
+ if (irq > BANK2_END)
+ valid = false;
+ break;
+ default:
+ valid = false;
+ break;
+ }
+
+ if (!valid) {
+ device_printf(dev,
+ "invalid IRQ config: bank=%d, irq=%d\n",
+ daf->cells[0], daf->cells[1]);
+ return (EINVAL);
+ }
+ }
else
return (EINVAL);
@@ -355,7 +384,8 @@ bcm_intc_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic"))
+ if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic") &&
+ !ofw_bus_is_compatible(dev, "brcm,bcm2836-armctrl-ic"))
return (ENXIO);
device_set_desc(dev, "BCM2835 Interrupt Controller");
return (BUS_PROBE_DEFAULT);
More information about the svn-src-all
mailing list