BelaPlatform / bela-image-builder

Scripts to build a Bela image from scratch
MIT License
37 stars 16 forks source link

allow user space to disable mcasp interrupts #52

Closed giuliomoro closed 5 years ago

giuliomoro commented 7 years ago

Aa suggested by @henrix:

diff --git a/drivers/irqchip/irq-omap-intc.c b/drivers/irqchip/irq-omap-intc.c
index 26b4049..be3b81d 100644
--- a/drivers/irqchip/irq-omap-intc.c
+++ b/drivers/irqchip/irq-omap-intc.c
@@ -340,8 +340,8 @@ static int __init omap_init_irq(u32 base, struct device_node *node)
        ret = omap_init_irq_legacy(base, NULL);
    }

-   if (ret == 0)
-       omap_irq_enable_protection();
+   //if (ret == 0)
+       //omap_irq_enable_protection();

    return ret;
 }
giuliomoro commented 6 years ago

These could help:

//#include <linux/irqnr.h>
//extern struct irq_desc *irq_to_desc(unsigned int irq);
//desc->irq_data
// irqd_irq_masked(&desc->irq_data)
//kernel/irq/internals.h,
//void mask_irq(struct irq_desc *desc)
//void unmask_irq(struct irq_desc *desc)

Otherwise, just (unsafely?) memmap and write to the set register (as it's currently done from core/PRU.cpp ).

giuliomoro commented 6 years ago

so, the IRQ channels are declared in dtb-rebuilder/src/arm/am33xx.dtsi :

             mcasp0: mcasp@48038000 {
                        compatible = "ti,am33xx-mcasp-audio";
                        ti,hwmods = "mcasp0";
                        reg = <0x48038000 0x2000>,
                              <0x46000000 0x400000>;
                        reg-names = "mpu", "dat";
                        interrupts = <80>, <81>;
                        interrupt-names = "tx", "rx";
                        status = "disabled";
                        dmas = <&edma 8 2>,
                                <&edma 9 2>;
                        dma-names = "tx", "rx";
                };

The driver sound/soc/davinci/davinci-mcasp.c retrieves the interrupt numbers from the device tree: calling platform_get_irq_byname(pdev, "rx"); and platform_get_irq_byname(pdev, "tx"); and does not complain if such irq names are not declared ( in fact the documentation says that they are optional).

I think the correct solution would therefore be to remove the interrupt-names property, so that the driver will not be able to retrieve the interrupt numbers and thus it will not unmask those interrupts. However, I cannot find docs on how to delete properties from device-tree overlays (it should be possible from a device tree with, e.g.: /delete-property/interrupt-names;), so my second best option is to add

                        interrupt-names = "dummytx", "dummyrx";

in the dtbo. This is tested and works ok.

@LBDonovan @henrix do you see anything wrong with the above?

Side note: the driver itself simply toggles the interrupt mask bits (calling mcasp_set_bits(), which in turn does a raw write), instead of calling any of the specific kernel functions mentioned above. Maybe it assumes that it will be the only driver to toggle those very bits?