From 80eddd87314dde7e0f94a429d54035c429aefea8 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Thu, 30 Mar 2017 22:29:19 +0200 Subject: [PATCH] usb: add OHCI support Fixes #2357 --- repos/dde_linux/README | 10 +++++----- repos/dde_linux/lib/mk/spec/x86/usb.inc | 2 +- repos/dde_linux/ports/dde_linux.hash | 2 +- repos/dde_linux/run/usb_hid.run | 2 +- repos/dde_linux/run/usb_net.run | 2 +- repos/dde_linux/run/usb_storage.run | 2 +- repos/dde_linux/run/usb_terminal.run | 2 +- repos/dde_linux/src/include/lx_emul/byteorder.h | 2 ++ repos/dde_linux/src/lib/usb/include/lx_emul.h | 1 + repos/dde_linux/src/lib/usb/include/platform.h | 10 ++++++++-- repos/dde_linux/src/lib/usb/lx_emul.cc | 10 ++++++++++ repos/dde_linux/src/lib/usb/raw/raw.cc | 2 ++ repos/dde_linux/src/lib/usb/spec/x86/platform.cc | 10 +++++++++- repos/dde_linux/usb.list | 7 +++++++ 14 files changed, 50 insertions(+), 14 deletions(-) diff --git a/repos/dde_linux/README b/repos/dde_linux/README index 00ae88a3e..a2228aa5d 100644 --- a/repos/dde_linux/README +++ b/repos/dde_linux/README @@ -9,7 +9,7 @@ Controller configuration The driver can be started using different or all USB controller types a platform offers (USB 1.0/2.0/3.0). Note that not all controllers are supported by all platforms. Controllers can be enabled as attribute in the config node of the -driver. Supported attributes are: 'uhci', 'ehci', and 'xhci'. +driver. Supported attributes are: 'uhci', 'ohci', 'ehci', and 'xhci'. Configuration snippet to enable UHCI and EHCI @@ -40,7 +40,7 @@ Configuration snippet: ! ! ! -! +! ! ! ! @@ -80,7 +80,7 @@ Configuration snippet: ! ! ! -! +! Network (Nic) @@ -119,7 +119,7 @@ Configuration snippet: ! ! ! -! +! ! ! ! @@ -150,7 +150,7 @@ access the device 'usb-1-6': ! ! ! -! +! ! ! ! diff --git a/repos/dde_linux/lib/mk/spec/x86/usb.inc b/repos/dde_linux/lib/mk/spec/x86/usb.inc index 199f93794..bd7f3a9b8 100644 --- a/repos/dde_linux/lib/mk/spec/x86/usb.inc +++ b/repos/dde_linux/lib/mk/spec/x86/usb.inc @@ -1,4 +1,4 @@ -SRC_C += $(addprefix usb/host/,pci-quirks.c uhci-hcd.c ehci-pci.c) +SRC_C += $(addprefix usb/host/,pci-quirks.c uhci-hcd.c ehci-pci.c ohci-hcd.c ohci-pci.c) SRC_C += usb/core/hcd-pci.c # diff --git a/repos/dde_linux/ports/dde_linux.hash b/repos/dde_linux/ports/dde_linux.hash index 2ff3fc02f..5cbaa5f38 100644 --- a/repos/dde_linux/ports/dde_linux.hash +++ b/repos/dde_linux/ports/dde_linux.hash @@ -1 +1 @@ -ed9880704fad6f3d85514dd47b65a5eb7bfbf16f +bf950a363006ca4414e3cbb7d96b4e9b009d788b diff --git a/repos/dde_linux/run/usb_hid.run b/repos/dde_linux/run/usb_hid.run index 1d3db4a06..379a5bc61 100644 --- a/repos/dde_linux/run/usb_hid.run +++ b/repos/dde_linux/run/usb_hid.run @@ -115,7 +115,7 @@ append config { - + diff --git a/repos/dde_linux/run/usb_net.run b/repos/dde_linux/run/usb_net.run index 1ae8b3991..7db1af4d0 100644 --- a/repos/dde_linux/run/usb_net.run +++ b/repos/dde_linux/run/usb_net.run @@ -59,7 +59,7 @@ set config { - + diff --git a/repos/dde_linux/run/usb_storage.run b/repos/dde_linux/run/usb_storage.run index fce5e8aeb..8eae6a82d 100644 --- a/repos/dde_linux/run/usb_storage.run +++ b/repos/dde_linux/run/usb_storage.run @@ -66,7 +66,7 @@ append config { - + diff --git a/repos/dde_linux/run/usb_terminal.run b/repos/dde_linux/run/usb_terminal.run index 25330cb1d..fc214fc85 100644 --- a/repos/dde_linux/run/usb_terminal.run +++ b/repos/dde_linux/run/usb_terminal.run @@ -73,7 +73,7 @@ append config { - + diff --git a/repos/dde_linux/src/include/lx_emul/byteorder.h b/repos/dde_linux/src/include/lx_emul/byteorder.h index e10018aaa..967dfe201 100644 --- a/repos/dde_linux/src/include/lx_emul/byteorder.h +++ b/repos/dde_linux/src/include/lx_emul/byteorder.h @@ -37,7 +37,9 @@ #define cpu_to_le16s __cpu_to_le16s #define cpu_to_be16 __cpu_to_be16 #define cpu_to_le32 __cpu_to_le32 +#define cpu_to_le32p __cpu_to_le32p #define cpu_to_be32 __cpu_to_be32 +#define cpu_to_be32p __cpu_to_be32p #define cpu_to_le32s __cpu_to_le32s #define cpu_to_le64 __cpu_to_le64 #define le16_to_cpup __le16_to_cpup diff --git a/repos/dde_linux/src/lib/usb/include/lx_emul.h b/repos/dde_linux/src/lib/usb/include/lx_emul.h index f48bb0a54..40431557a 100644 --- a/repos/dde_linux/src/lib/usb/include/lx_emul.h +++ b/repos/dde_linux/src/lib/usb/include/lx_emul.h @@ -1518,6 +1518,7 @@ enum { GFP_NOWAIT = 0x2000000u, }; +unsigned long get_zeroed_page(gfp_t gfp_mask); unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); #define __get_free_page(gfp_mask) __get_free_pages((gfp_mask), 0) diff --git a/repos/dde_linux/src/lib/usb/include/platform.h b/repos/dde_linux/src/lib/usb/include/platform.h index 5189ce2c1..492fb55a4 100644 --- a/repos/dde_linux/src/lib/usb/include/platform.h +++ b/repos/dde_linux/src/lib/usb/include/platform.h @@ -35,6 +35,7 @@ struct Services /* Controller types */ bool uhci = false; /* 1.0 */ + bool ohci = false; bool ehci = false; /* 2.0 */ bool xhci = false; /* 3.0 */ @@ -105,6 +106,11 @@ struct Services log("Enabled UHCI (USB 1.0/1.1) support"); } + if (config_node.attribute_value("ohci", false)) { + ohci = true; + log("Enabled OHCI (USB 1.0/1.1) support"); + } + if (config_node.attribute_value("ehci", false)) { ehci = true; log("Enabled EHCI (USB 2.0) support"); @@ -115,9 +121,9 @@ struct Services log("Enabled XHCI (USB 3.0) support"); } - if (!(uhci | ehci | xhci)) + if (!(uhci | ohci | ehci | xhci)) warning("Warning: No USB controllers enabled.\n" - "Use in your 'usb_drv' configuration"); + "Use in your 'usb_drv' configuration"); } }; diff --git a/repos/dde_linux/src/lib/usb/lx_emul.cc b/repos/dde_linux/src/lib/usb/lx_emul.cc index 4f95fed70..98ccc9e14 100644 --- a/repos/dde_linux/src/lib/usb/lx_emul.cc +++ b/repos/dde_linux/src/lib/usb/lx_emul.cc @@ -256,6 +256,16 @@ void *memscan(void *addr, int c, size_t size) } +/***************** + ** linux/gfp.h ** + *****************/ + +unsigned long get_zeroed_page(gfp_t gfp_mask) +{ + return (unsigned long)kzalloc(PAGE_SIZE, 0); +} + + /****************** ** linux/log2.h ** ******************/ diff --git a/repos/dde_linux/src/lib/usb/raw/raw.cc b/repos/dde_linux/src/lib/usb/raw/raw.cc index 8b906c7df..afdb8c6be 100644 --- a/repos/dde_linux/src/lib/usb/raw/raw.cc +++ b/repos/dde_linux/src/lib/usb/raw/raw.cc @@ -786,11 +786,13 @@ class Usb::Root : public Genode::Root_component bool const uhci = config.attribute_value("uhci", false); bool const ehci = config.attribute_value("ehci", false); bool const xhci = config.attribute_value("xhci", false); + bool const ohci = config.attribute_value("ohci", false); Genode::Reporter::Xml_generator xml(_config_reporter, [&] { if (uhci) xml.attribute("uhci", "yes"); if (ehci) xml.attribute("ehci", "yes"); if (xhci) xml.attribute("xhci", "yes"); + if (ohci) xml.attribute("ohci", "yes"); xml.append(config.content_base(), config.content_size()); }); diff --git a/repos/dde_linux/src/lib/usb/spec/x86/platform.cc b/repos/dde_linux/src/lib/usb/spec/x86/platform.cc index 77a3fb4ee..ac623a78b 100644 --- a/repos/dde_linux/src/lib/usb/spec/x86/platform.cc +++ b/repos/dde_linux/src/lib/usb/spec/x86/platform.cc @@ -18,6 +18,8 @@ extern "C" void module_ax88179_178a_driver_init(); extern "C" void module_usbnet_init(); extern "C" void module_ehci_hcd_init(); extern "C" void module_ehci_pci_init(); +extern "C" void module_ohci_hcd_mod_init(); +extern "C" void module_ohci_pci_init(); extern "C" void module_uhci_hcd_init(); extern "C" void module_xhci_hcd_init(); extern "C" void module_xhci_pci_init(); @@ -40,6 +42,12 @@ void platform_hcd_init(Services *s) module_ehci_pci_init(); } - if (s->uhci) + if (s->ohci) { + module_ohci_hcd_mod_init(); + module_ohci_pci_init(); + } + + if (s->uhci) { module_uhci_hcd_init(); + } } diff --git a/repos/dde_linux/usb.list b/repos/dde_linux/usb.list index d68057c2e..978308a33 100644 --- a/repos/dde_linux/usb.list +++ b/repos/dde_linux/usb.list @@ -68,6 +68,13 @@ linux-4.4.3/drivers/usb/host/ehci-q.c linux-4.4.3/drivers/usb/host/ehci-sched.c linux-4.4.3/drivers/usb/host/ehci-sysfs.c linux-4.4.3/drivers/usb/host/ehci-timer.c +linux-4.4.3/drivers/usb/host/ohci-hcd.c +linux-4.4.3/drivers/usb/host/ohci.h +linux-4.4.3/drivers/usb/host/ohci-hub.c +linux-4.4.3/drivers/usb/host/ohci-dbg.c +linux-4.4.3/drivers/usb/host/ohci-mem.c +linux-4.4.3/drivers/usb/host/ohci-q.c +linux-4.4.3/drivers/usb/host/ohci-pci.c linux-4.4.3/drivers/usb/host/pci-quirks.h linux-4.4.3/drivers/usb/host/pci-quirks.c linux-4.4.3/drivers/usb/host/uhci-debug.c