diff --git a/repos/dde_linux/lib/mk/spec/hw/rpi_usb.mk b/repos/dde_linux/lib/mk/rpi_usb.mk similarity index 61% rename from repos/dde_linux/lib/mk/spec/hw/rpi_usb.mk rename to repos/dde_linux/lib/mk/rpi_usb.mk index c0a258c5d2..79c80375c5 100644 --- a/repos/dde_linux/lib/mk/spec/hw/rpi_usb.mk +++ b/repos/dde_linux/lib/mk/rpi_usb.mk @@ -1,4 +1,4 @@ -SRC_CC += spec/hw_rpi/dwc_irq.cc +SRC_CC += spec/rpi/dwc_irq.cc vpath % $(REP_DIR)/src/lib/usb diff --git a/repos/dde_linux/lib/mk/spec/foc/rpi_usb.mk b/repos/dde_linux/lib/mk/spec/foc/rpi_usb.mk deleted file mode 100644 index d3783cf0c2..0000000000 --- a/repos/dde_linux/lib/mk/spec/foc/rpi_usb.mk +++ /dev/null @@ -1,5 +0,0 @@ -SRC_CC += spec/foc_rpi/dwc_irq.cc - -vpath % $(REP_DIR)/src/lib/usb - -CC_CXX_WARN_STRICT = diff --git a/repos/dde_linux/src/drivers/usb_host/spec/rpi/platform.cc b/repos/dde_linux/src/drivers/usb_host/spec/rpi/platform.cc index 15f1926692..d089ff74d1 100644 --- a/repos/dde_linux/src/drivers/usb_host/spec/rpi/platform.cc +++ b/repos/dde_linux/src/drivers/usb_host/spec/rpi/platform.cc @@ -28,7 +28,7 @@ using namespace Genode; -unsigned dwc_irq(); +unsigned dwc_irq(Genode::Env&); /************************************************ @@ -41,13 +41,6 @@ enum { }; -static resource _dwc_otg_resource[] = -{ - { DWC_BASE, DWC_BASE + DWC_SIZE - 1, "dwc_otg", IORESOURCE_MEM }, - { dwc_irq(), dwc_irq(), "dwc_otg-irq" /* name unused */, IORESOURCE_IRQ } -}; - - /******************* ** Init function ** *******************/ @@ -55,8 +48,15 @@ static resource _dwc_otg_resource[] = extern "C" void module_dwc_otg_driver_init(); extern bool fiq_enable, fiq_fsm_enable; -void platform_hcd_init(Genode::Env &, Services *services) +void platform_hcd_init(Genode::Env &env, Services *services) { + unsigned irq = dwc_irq(env); + static resource _dwc_otg_resource[] = + { + { DWC_BASE, DWC_BASE + DWC_SIZE - 1, "dwc_otg", IORESOURCE_MEM }, + { irq, irq, "dwc_otg-irq" /* name unused */, IORESOURCE_IRQ } + }; + /* enable USB power */ Platform::Connection platform(services->env); platform.power_state(Platform::Session::POWER_USB_HCD, true); diff --git a/repos/dde_linux/src/lib/usb/spec/foc_rpi/dwc_irq.cc b/repos/dde_linux/src/lib/usb/spec/foc_rpi/dwc_irq.cc deleted file mode 100644 index 5bf1d827bd..0000000000 --- a/repos/dde_linux/src/lib/usb/spec/foc_rpi/dwc_irq.cc +++ /dev/null @@ -1,7 +0,0 @@ -/* - * \brief USB: DWC-OTG RaspberryPI Interrupt (base-foc) - * \author Reinier Millo Sánchez - * \date 2015-06-21 - */ - -unsigned dwc_irq() { return 9; } diff --git a/repos/dde_linux/src/lib/usb/spec/hw_rpi/dwc_irq.cc b/repos/dde_linux/src/lib/usb/spec/hw_rpi/dwc_irq.cc deleted file mode 100644 index b29b243320..0000000000 --- a/repos/dde_linux/src/lib/usb/spec/hw_rpi/dwc_irq.cc +++ /dev/null @@ -1,7 +0,0 @@ -/* - * \brief USB: DWC-OTG RaspberryPI Interrupt (base-hw) - * \author Reinier Millo Sánchez - * \date 2015-06-21 - */ - -unsigned dwc_irq() { return 17; } diff --git a/repos/dde_linux/src/lib/usb/spec/rpi/dwc_irq.cc b/repos/dde_linux/src/lib/usb/spec/rpi/dwc_irq.cc new file mode 100644 index 0000000000..a6b9db85bf --- /dev/null +++ b/repos/dde_linux/src/lib/usb/spec/rpi/dwc_irq.cc @@ -0,0 +1,24 @@ +/* + * \brief USB: DWC-OTG RaspberryPI Interrupt + * \author Stefan Kalkowski + * \date 2019-04-16 + */ + +#include +#include +#include + +unsigned dwc_irq(Genode::Env &env) +{ + using namespace Genode; + + static Attached_rom_dataspace rom(env, "platform_info"); + static unsigned offset = 0; + try { + String<32> kernel_name = + rom.xml().sub_node("kernel").attribute_value("name", String<32>()); + if (kernel_name == "hw") offset += Rpi::GPU_IRQ_BASE; + } catch (...) { } + + return offset + 9; +} diff --git a/repos/dde_linux/src/lib/usb/spec/rpi/platform.cc b/repos/dde_linux/src/lib/usb/spec/rpi/platform.cc index 771c016403..df9c708748 100644 --- a/repos/dde_linux/src/lib/usb/spec/rpi/platform.cc +++ b/repos/dde_linux/src/lib/usb/spec/rpi/platform.cc @@ -28,7 +28,7 @@ using namespace Genode; -unsigned dwc_irq(); +unsigned dwc_irq(Genode::Env&); /************************************************ @@ -41,13 +41,6 @@ enum { }; -static resource _dwc_otg_resource[] = -{ - { DWC_BASE, DWC_BASE + DWC_SIZE - 1, "dwc_otg", IORESOURCE_MEM }, - { dwc_irq(), dwc_irq(), "dwc_otg-irq" /* name unused */, IORESOURCE_IRQ } -}; - - /*************************************** ** Supplement to lx_emul environment ** ***************************************/ @@ -162,6 +155,13 @@ extern "C" int module_smsc95xx_driver_init(); void platform_hcd_init(Env &env, Services *services) { + unsigned irq = dwc_irq(env); + static resource _dwc_otg_resource[] = + { + { DWC_BASE, DWC_BASE + DWC_SIZE - 1, "dwc_otg", IORESOURCE_MEM }, + { irq, irq, "dwc_otg-irq" /* name unused */, IORESOURCE_IRQ } + }; + /* enable USB power */ Platform::Connection platform(env); platform.power_state(Platform::Session::POWER_USB_HCD, true);