dde_linux: make rpi usb drivers kernel independent

Ref #3180
This commit is contained in:
Stefan Kalkowski 2019-04-18 13:44:37 +02:00 committed by Christian Helmuth
parent d00bcac941
commit d5104aca05
7 changed files with 42 additions and 37 deletions

View File

@ -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

View File

@ -1,5 +0,0 @@
SRC_CC += spec/foc_rpi/dwc_irq.cc
vpath % $(REP_DIR)/src/lib/usb
CC_CXX_WARN_STRICT =

View File

@ -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);

View File

@ -1,7 +0,0 @@
/*
* \brief USB: DWC-OTG RaspberryPI Interrupt (base-foc)
* \author Reinier Millo Sánchez <rmillo@uclv.cu>
* \date 2015-06-21
*/
unsigned dwc_irq() { return 9; }

View File

@ -1,7 +0,0 @@
/*
* \brief USB: DWC-OTG RaspberryPI Interrupt (base-hw)
* \author Reinier Millo Sánchez <rmillo@uclv.cu>
* \date 2015-06-21
*/
unsigned dwc_irq() { return 17; }

View File

@ -0,0 +1,24 @@
/*
* \brief USB: DWC-OTG RaspberryPI Interrupt
* \author Stefan Kalkowski
* \date 2019-04-16
*/
#include <base/attached_rom_dataspace.h>
#include <drivers/defs/rpi.h>
#include <util/string.h>
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;
}

View File

@ -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);