mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 10:46:25 +00:00
dde_linux: usb host controller driver version 4.16
This commit is contained in:
parent
9d712b2ce9
commit
b02f483841
@ -30,6 +30,20 @@ proc need_usb_hid { } {
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# Return name of the USB driver binary
|
||||
#
|
||||
proc usb_host_drv_binary { } {
|
||||
if {[have_spec arndale]} { return arndale_usb_host_drv }
|
||||
if {[have_spec panda]} { return panda_usb_host_drv }
|
||||
if {[have_spec rpi]} { return rpi_usb_host_drv }
|
||||
if {[have_spec wand_quad]} { return wand_quad_usb_host_drv }
|
||||
if {[have_spec odroid_x2]} { return odroid_x2_usb_host_drv }
|
||||
if {[have_spec x86]} { return x86_pc_usb_host_drv }
|
||||
return no_usb_drv_available
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# Return name of the NIC driver binary
|
||||
#
|
||||
|
33
repos/dde_linux/lib/import/import-usb_host_include.mk
Normal file
33
repos/dde_linux/lib/import/import-usb_host_include.mk
Normal file
@ -0,0 +1,33 @@
|
||||
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_host
|
||||
|
||||
# architecture-dependent includes
|
||||
ifeq ($(filter-out $(SPECS),x86),)
|
||||
ARCH_SRC_INC_DIR += $(REP_DIR)/src/include/spec/x86
|
||||
ifeq ($(filter-out $(SPECS),32bit),)
|
||||
ARCH_SRC_INC_DIR += $(REP_DIR)/src/include/spec/x86_32
|
||||
endif # 32bit
|
||||
ifeq ($(filter-out $(SPECS),64bit),)
|
||||
ARCH_SRC_INC_DIR += $(REP_DIR)/src/include/spec/x86_64
|
||||
endif # 64bit
|
||||
endif # x86
|
||||
|
||||
ifeq ($(filter-out $(SPECS),arm),)
|
||||
ARCH_SRC_INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||
ifeq ($(filter-out $(SPECS),arm_v6),)
|
||||
ARCH_SRC_INC_DIR += $(REP_DIR)/src/include/spec/arm_v6
|
||||
endif # arm_v6
|
||||
ifeq ($(filter-out $(SPECS),arm_v7),)
|
||||
ARCH_SRC_INC_DIR += $(REP_DIR)/src/include/spec/arm_v7
|
||||
endif # arm_v7
|
||||
endif # arm
|
||||
|
||||
|
||||
#
|
||||
# The order of include-search directories is important, we need to look into
|
||||
# 'contrib' before falling back to our custom 'lx_emul.h' header.
|
||||
#
|
||||
INC_DIR += $(ARCH_SRC_INC_DIR)
|
||||
INC_DIR += $(USB_CONTRIB_DIR)/include
|
||||
INC_DIR += $(USB_CONTRIB_DIR)/include/uapi
|
||||
INC_DIR += $(USB_CONTRIB_DIR)/drivers/usb/core
|
||||
INC_DIR += $(LIB_CACHE_DIR)/usb_host_include/include/include/include
|
37
repos/dde_linux/lib/mk/usb_host_include.mk
Normal file
37
repos/dde_linux/lib/mk/usb_host_include.mk
Normal file
@ -0,0 +1,37 @@
|
||||
ifeq ($(called_from_lib_mk),yes)
|
||||
|
||||
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_host
|
||||
LX_EMUL_H := $(REP_DIR)/src/drivers/usb_host/lx_emul.h
|
||||
|
||||
#
|
||||
# Determine the header files included by the contrib code. For each
|
||||
# of these header files we create a symlink to 'lx_emul.h'.
|
||||
#
|
||||
SCAN_DIRS := $(addprefix $(USB_CONTRIB_DIR)/include/, asm-generic linux uapi) \
|
||||
$(addprefix $(USB_CONTRIB_DIR)/, drivers lib)
|
||||
GEN_INCLUDES := $(shell grep -rIh "^\# *include .*\/" $(SCAN_DIRS) |\
|
||||
sed "s/^\# *include [^<\"]*[<\"]\([^>\"]*\)[>\"].*/\1/" |\
|
||||
sort | uniq)
|
||||
#
|
||||
# Filter out original Linux headers that exist in the contrib directory
|
||||
#
|
||||
NO_GEN_INCLUDES := $(shell cd $(USB_CONTRIB_DIR)/; find include -name "*.h" |\
|
||||
sed "s/.\///" | sed "s/.*include\///")
|
||||
GEN_INCLUDES := $(filter-out $(NO_GEN_INCLUDES),$(GEN_INCLUDES))
|
||||
|
||||
#
|
||||
# Put Linux headers in 'GEN_INC' dir, since some include use "../../" paths use
|
||||
# three level include hierarchy
|
||||
#
|
||||
GEN_INC := $(shell pwd)/include/include/include
|
||||
GEN_INCLUDES := $(addprefix $(GEN_INC)/,$(GEN_INCLUDES))
|
||||
|
||||
all: $(GEN_INCLUDES)
|
||||
|
||||
$(GEN_INCLUDES):
|
||||
$(VERBOSE)mkdir -p $(dir $@)
|
||||
$(VERBOSE)ln -s $(LX_EMUL_H) $@
|
||||
|
||||
endif
|
||||
|
||||
CC_CXX_WARN_STRICT =
|
493
repos/dde_linux/patches/usb_host_mem.patch
Normal file
493
repos/dde_linux/patches/usb_host_mem.patch
Normal file
@ -0,0 +1,493 @@
|
||||
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
|
||||
index c821b4b..5accd4d 100644
|
||||
--- a/drivers/usb/core/config.c
|
||||
+++ b/drivers/usb/core/config.c
|
||||
@@ -706,7 +706,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
|
||||
}
|
||||
|
||||
len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j;
|
||||
- config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL);
|
||||
+ config->intf_cache[i] = intfc = kzalloc(len, GFP_LX_DMA);
|
||||
if (!intfc)
|
||||
return -ENOMEM;
|
||||
kref_init(&intfc->ref);
|
||||
@@ -817,16 +817,16 @@ int usb_get_configuration(struct usb_device *dev)
|
||||
}
|
||||
|
||||
length = ncfg * sizeof(struct usb_host_config);
|
||||
- dev->config = kzalloc(length, GFP_KERNEL);
|
||||
+ dev->config = kzalloc(length, GFP_LX_DMA);
|
||||
if (!dev->config)
|
||||
goto err2;
|
||||
|
||||
length = ncfg * sizeof(char *);
|
||||
- dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
|
||||
+ dev->rawdescriptors = kzalloc(length, GFP_LX_DMA);
|
||||
if (!dev->rawdescriptors)
|
||||
goto err2;
|
||||
|
||||
- desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
|
||||
+ desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_LX_DMA);
|
||||
if (!desc)
|
||||
goto err2;
|
||||
|
||||
@@ -855,7 +855,7 @@ int usb_get_configuration(struct usb_device *dev)
|
||||
USB_DT_CONFIG_SIZE);
|
||||
|
||||
/* Now that we know the length, get the whole thing */
|
||||
- bigbuffer = kmalloc(length, GFP_KERNEL);
|
||||
+ bigbuffer = kmalloc(length, GFP_LX_DMA);
|
||||
if (!bigbuffer) {
|
||||
result = -ENOMEM;
|
||||
goto err;
|
||||
@@ -928,7 +928,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
|
||||
__u8 cap_type;
|
||||
int ret;
|
||||
|
||||
- bos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_KERNEL);
|
||||
+ bos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_LX_DMA);
|
||||
if (!bos)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -949,12 +949,12 @@ int usb_get_bos_descriptor(struct usb_device *dev)
|
||||
if (total_len < length)
|
||||
return -EINVAL;
|
||||
|
||||
- dev->bos = kzalloc(sizeof(struct usb_host_bos), GFP_KERNEL);
|
||||
+ dev->bos = kzalloc(sizeof(struct usb_host_bos), GFP_LX_DMA);
|
||||
if (!dev->bos)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Now let's get the whole BOS descriptor set */
|
||||
- buffer = kzalloc(total_len, GFP_KERNEL);
|
||||
+ buffer = kzalloc(total_len, GFP_LX_DMA);
|
||||
if (!buffer) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
|
||||
index fc32391..919c9e9 100644
|
||||
--- a/drivers/usb/core/hcd.c
|
||||
+++ b/drivers/usb/core/hcd.c
|
||||
@@ -507,7 +507,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
|
||||
* USB hub descriptor.
|
||||
*/
|
||||
tbuf_size = max_t(u16, sizeof(struct usb_hub_descriptor), wLength);
|
||||
- tbuf = kzalloc(tbuf_size, GFP_KERNEL);
|
||||
+ tbuf = kzalloc(tbuf_size, GFP_LX_DMA);
|
||||
if (!tbuf) {
|
||||
status = -ENOMEM;
|
||||
goto err_alloc;
|
||||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
|
||||
index c5c1f6c..5bd400f 100644
|
||||
--- a/drivers/usb/core/hub.c
|
||||
+++ b/drivers/usb/core/hub.c
|
||||
@@ -706,7 +706,7 @@ resubmit:
|
||||
if (hub->quiescing)
|
||||
return;
|
||||
|
||||
- status = usb_submit_urb(hub->urb, GFP_ATOMIC);
|
||||
+ status = usb_submit_urb(hub->urb, GFP_LX_DMA);
|
||||
if (status != 0 && status != -ENODEV && status != -EPERM)
|
||||
dev_err(hub->intfdev, "resubmit --> %d\n", status);
|
||||
}
|
||||
@@ -1310,20 +1310,20 @@ static int hub_configure(struct usb_hub *hub,
|
||||
unsigned full_load;
|
||||
unsigned maxchild;
|
||||
|
||||
- hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL);
|
||||
+ hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_LX_DMA);
|
||||
if (!hub->buffer) {
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL);
|
||||
+ hub->status = kmalloc(sizeof(*hub->status), GFP_LX_DMA);
|
||||
if (!hub->status) {
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
mutex_init(&hub->status_mutex);
|
||||
|
||||
- hub->descriptor = kzalloc(sizeof(*hub->descriptor), GFP_KERNEL);
|
||||
+ hub->descriptor = kzalloc(sizeof(*hub->descriptor), GFP_LX_DMA);
|
||||
if (!hub->descriptor) {
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
@@ -1565,7 +1565,7 @@ static int hub_configure(struct usb_hub *hub,
|
||||
if (maxp > sizeof(*hub->buffer))
|
||||
maxp = sizeof(*hub->buffer);
|
||||
|
||||
- hub->urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
+ hub->urb = usb_alloc_urb(0, GFP_LX_DMA);
|
||||
if (!hub->urb) {
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
@@ -4713,7 +4713,7 @@ check_highspeed(struct usb_hub *hub, struct usb_device *udev, int port1)
|
||||
if (udev->quirks & USB_QUIRK_DEVICE_QUALIFIER)
|
||||
return;
|
||||
|
||||
- qual = kmalloc(sizeof *qual, GFP_KERNEL);
|
||||
+ qual = kmalloc(sizeof *qual, GFP_LX_DMA);
|
||||
if (qual == NULL)
|
||||
return;
|
||||
|
||||
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
|
||||
index b3f98e0..3442858 100644
|
||||
--- a/drivers/usb/core/message.c
|
||||
+++ b/drivers/usb/core/message.c
|
||||
@@ -237,7 +237,7 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
|
||||
if (!ep || len < 0)
|
||||
return -EINVAL;
|
||||
|
||||
- urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
+ urb = usb_alloc_urb(0, GFP_LX_DMA);
|
||||
if (!urb)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -990,7 +989,7 @@ int usb_get_status(struct usb_device *dev, int recip, int type, int target,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- status = kmalloc(length, GFP_KERNEL);
|
||||
+ status = kmalloc(length, GFP_LX_DMA);
|
||||
if (!status)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2084,7 +2083,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config)
|
||||
{
|
||||
struct set_config_request *req;
|
||||
|
||||
- req = kmalloc(sizeof(*req), GFP_KERNEL);
|
||||
+ req = kmalloc(sizeof(*req), GFP_LX_DMA);
|
||||
if (!req)
|
||||
return -ENOMEM;
|
||||
req->udev = udev;
|
||||
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
|
||||
index 0a84661..f427b75 100644
|
||||
--- a/drivers/usb/host/ehci-hub.c
|
||||
+++ b/drivers/usb/host/ehci-hub.c
|
||||
@@ -749,7 +749,7 @@ static struct urb *request_single_step_set_feature_urb(
|
||||
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
|
||||
struct usb_host_endpoint *ep;
|
||||
|
||||
- urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
+ urb = usb_alloc_urb(0, GFP_LX_DMA);
|
||||
if (!urb)
|
||||
return NULL;
|
||||
|
||||
@@ -804,11 +803,11 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
|
||||
ehci_err(ehci, "No device attached to the RootHub\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
- buf = kmalloc(USB_DT_DEVICE_SIZE, GFP_KERNEL);
|
||||
+ buf = kmalloc(USB_DT_DEVICE_SIZE, GFP_LX_DMA);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
- dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
|
||||
+ dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_LX_DMA);
|
||||
if (!dr) {
|
||||
kfree(buf);
|
||||
return -ENOMEM;
|
||||
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
|
||||
index 3276304..8b9e337 100644
|
||||
--- a/drivers/usb/host/ehci-q.c
|
||||
+++ b/drivers/usb/host/ehci-q.c
|
||||
@@ -1020,7 +1020,7 @@ static struct ehci_qh *qh_append_tds (
|
||||
qh = (struct ehci_qh *) *ptr;
|
||||
if (unlikely (qh == NULL)) {
|
||||
/* can't sleep here, we have ehci->lock... */
|
||||
- qh = qh_make (ehci, urb, GFP_ATOMIC);
|
||||
+ qh = qh_make (ehci, urb, GFP_LX_DMA);
|
||||
*ptr = qh;
|
||||
}
|
||||
if (likely (qh != NULL)) {
|
||||
@@ -1172,7 +1172,7 @@ static int submit_single_step_set_feature(
|
||||
head = &qtd_list;
|
||||
|
||||
/* URBs map to sequences of QTDs: one logical transaction */
|
||||
- qtd = ehci_qtd_alloc(ehci, GFP_KERNEL);
|
||||
+ qtd = ehci_qtd_alloc(ehci, GFP_LX_DMA);
|
||||
if (unlikely(!qtd))
|
||||
return -1;
|
||||
list_add_tail(&qtd->qtd_list, head);
|
||||
@@ -1193,7 +1193,7 @@ static int submit_single_step_set_feature(
|
||||
sizeof(struct usb_ctrlrequest),
|
||||
QTD_IOC | token | (2 /* "setup" */ << 8), 8);
|
||||
|
||||
- submit_async(ehci, urb, &qtd_list, GFP_ATOMIC);
|
||||
+ submit_async(ehci, urb, &qtd_list, GFP_LX_DMA);
|
||||
return 0; /*Return now; we shall come back after 15 seconds*/
|
||||
}
|
||||
|
||||
@@ -1221,7 +1221,7 @@ static int submit_single_step_set_feature(
|
||||
token |= QTD_TOGGLE; /* force DATA1 */
|
||||
|
||||
qtd_prev = qtd;
|
||||
- qtd = ehci_qtd_alloc(ehci, GFP_ATOMIC);
|
||||
+ qtd = ehci_qtd_alloc(ehci, GFP_LX_DMA);
|
||||
if (unlikely(!qtd))
|
||||
goto cleanup;
|
||||
qtd->urb = urb;
|
||||
@@ -1231,7 +1231,7 @@ static int submit_single_step_set_feature(
|
||||
/* Interrupt after STATUS completion */
|
||||
qtd_fill(ehci, qtd, 0, 0, token | QTD_IOC, 0);
|
||||
|
||||
- submit_async(ehci, urb, &qtd_list, GFP_KERNEL);
|
||||
+ submit_async(ehci, urb, &qtd_list, GFP_LX_DMA);
|
||||
|
||||
return 0;
|
||||
|
||||
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
|
||||
index ac7d4ac..1eb1fc7 100644
|
||||
--- a/drivers/usb/host/ohci-dbg.c
|
||||
+++ b/drivers/usb/host/ohci-dbg.c
|
||||
@@ -683,7 +683,7 @@ static int fill_buffer(struct debug_buffer *buf)
|
||||
int ret = 0;
|
||||
|
||||
if (!buf->page)
|
||||
- buf->page = (char *)get_zeroed_page(GFP_KERNEL);
|
||||
+ buf->page = (char *)get_zeroed_page(GFP_LX_DMA);
|
||||
|
||||
if (!buf->page) {
|
||||
ret = -ENOMEM;
|
||||
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
|
||||
index d088c34..2211b20 100644
|
||||
--- a/drivers/usb/host/ohci-hcd.c
|
||||
+++ b/drivers/usb/host/ohci-hcd.c
|
||||
@@ -506,7 +506,7 @@ static int ohci_init (struct ohci_hcd *ohci)
|
||||
ohci->prev_frame_no = IO_WATCHDOG_OFF;
|
||||
|
||||
ohci->hcca = dma_alloc_coherent (hcd->self.controller,
|
||||
- sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL);
|
||||
+ sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_LX_DMA);
|
||||
if (!ohci->hcca)
|
||||
return -ENOMEM;
|
||||
|
||||
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
|
||||
index f9c3947..99a1696 100644
|
||||
--- a/drivers/usb/host/uhci-hcd.c
|
||||
+++ b/drivers/usb/host/uhci-hcd.c
|
||||
@@ -602,7 +602,7 @@ static int uhci_start(struct usb_hcd *hcd)
|
||||
|
||||
uhci->frame = dma_zalloc_coherent(uhci_dev(uhci),
|
||||
UHCI_NUMFRAMES * sizeof(*uhci->frame),
|
||||
- &uhci->frame_dma_handle, GFP_KERNEL);
|
||||
+ &uhci->frame_dma_handle, GFP_LX_DMA);
|
||||
if (!uhci->frame) {
|
||||
dev_err(uhci_dev(uhci),
|
||||
"unable to allocate consistent memory for frame list\n");
|
||||
@@ -610,7 +610,7 @@ static int uhci_start(struct usb_hcd *hcd)
|
||||
}
|
||||
|
||||
uhci->frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci->frame_cpu),
|
||||
- GFP_KERNEL);
|
||||
+ GFP_LX_DMA);
|
||||
if (!uhci->frame_cpu)
|
||||
goto err_alloc_frame_cpu;
|
||||
|
||||
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
|
||||
index 35fcb82..3a0cff5 100644
|
||||
--- a/drivers/usb/host/uhci-q.c
|
||||
+++ b/drivers/usb/host/uhci-q.c
|
||||
@@ -108,7 +108,7 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci)
|
||||
dma_addr_t dma_handle;
|
||||
struct uhci_td *td;
|
||||
|
||||
- td = dma_pool_alloc(uhci->td_pool, GFP_ATOMIC, &dma_handle);
|
||||
+ td = dma_pool_alloc(uhci->td_pool, GFP_LX_DMA, &dma_handle);
|
||||
if (!td)
|
||||
return NULL;
|
||||
|
||||
@@ -248,7 +248,7 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
|
||||
dma_addr_t dma_handle;
|
||||
struct uhci_qh *qh;
|
||||
|
||||
- qh = dma_pool_zalloc(uhci->qh_pool, GFP_ATOMIC, &dma_handle);
|
||||
+ qh = dma_pool_zalloc(uhci->qh_pool, GFP_LX_DMA, &dma_handle);
|
||||
if (!qh)
|
||||
return NULL;
|
||||
|
||||
@@ -724,7 +724,7 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
|
||||
{
|
||||
struct urb_priv *urbp;
|
||||
|
||||
- urbp = kmem_cache_zalloc(uhci_up_cachep, GFP_ATOMIC);
|
||||
+ urbp = kmem_cache_zalloc(uhci_up_cachep, GFP_LX_DMA);
|
||||
if (!urbp)
|
||||
return NULL;
|
||||
|
||||
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
|
||||
index 72ebbc9..0e815a8 100644
|
||||
--- a/drivers/usb/host/xhci-hub.c
|
||||
+++ b/drivers/usb/host/xhci-hub.c
|
||||
@@ -404,7 +404,7 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
|
||||
if (GET_EP_CTX_STATE(ep_ctx) != EP_STATE_RUNNING)
|
||||
continue;
|
||||
|
||||
- command = xhci_alloc_command(xhci, false, GFP_NOWAIT);
|
||||
+ command = xhci_alloc_command(xhci, false, GFP_LX_DMA);
|
||||
if (!command) {
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
ret = -ENOMEM;
|
||||
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
|
||||
index 332420d..e037aaf 100644
|
||||
--- a/drivers/usb/host/xhci-mem.c
|
||||
+++ b/drivers/usb/host/xhci-mem.c
|
||||
@@ -2135,7 +2135,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
|
||||
rhub->psi_count = XHCI_EXT_PORT_PSIC(temp);
|
||||
if (rhub->psi_count) {
|
||||
rhub->psi = kcalloc(rhub->psi_count, sizeof(*rhub->psi),
|
||||
- GFP_KERNEL);
|
||||
+ GFP_LX_DMA);
|
||||
if (!rhub->psi)
|
||||
rhub->psi_count = 0;
|
||||
|
||||
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
|
||||
index daa94c3..028891a 100644
|
||||
--- a/drivers/usb/host/xhci-ring.c
|
||||
+++ b/drivers/usb/host/xhci-ring.c
|
||||
@@ -1141,7 +1141,7 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id,
|
||||
if (xhci->quirks & XHCI_RESET_EP_QUIRK) {
|
||||
struct xhci_command *command;
|
||||
|
||||
- command = xhci_alloc_command(xhci, false, GFP_ATOMIC);
|
||||
+ command = xhci_alloc_command(xhci, false, GFP_LX_DMA);
|
||||
if (!command)
|
||||
return;
|
||||
|
||||
@@ -1821,7 +1821,7 @@ static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci,
|
||||
{
|
||||
struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
|
||||
struct xhci_command *command;
|
||||
- command = xhci_alloc_command(xhci, false, GFP_ATOMIC);
|
||||
+ command = xhci_alloc_command(xhci, false, GFP_LX_DMA);
|
||||
if (!command)
|
||||
return;
|
||||
|
||||
@@ -3906,7 +3906,7 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
|
||||
reserved_trbs++;
|
||||
|
||||
ret = prepare_ring(xhci, xhci->cmd_ring, EP_STATE_RUNNING,
|
||||
- reserved_trbs, GFP_ATOMIC);
|
||||
+ reserved_trbs, GFP_LX_DMA);
|
||||
if (ret < 0) {
|
||||
xhci_err(xhci, "ERR: No room for command on command ring\n");
|
||||
if (command_must_succeed)
|
||||
@@ -4040,7 +4040,7 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
|
||||
}
|
||||
|
||||
/* This function gets called from contexts where it cannot sleep */
|
||||
- cmd = xhci_alloc_command(xhci, false, GFP_ATOMIC);
|
||||
+ cmd = xhci_alloc_command(xhci, false, GFP_LX_DMA);
|
||||
if (!cmd)
|
||||
return;
|
||||
|
||||
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
|
||||
index 5d37700..1945abb 100644
|
||||
--- a/drivers/usb/host/xhci.c
|
||||
+++ b/drivers/usb/host/xhci.c
|
||||
@@ -602,7 +604,7 @@ int xhci_run(struct usb_hcd *hcd)
|
||||
if (xhci->quirks & XHCI_NEC_HOST) {
|
||||
struct xhci_command *command;
|
||||
|
||||
- command = xhci_alloc_command(xhci, false, GFP_KERNEL);
|
||||
+ command = xhci_alloc_command(xhci, false, GFP_LX_DMA);
|
||||
if (!command)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1244,7 +1246,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
|
||||
* changes max packet sizes.
|
||||
*/
|
||||
|
||||
- command = xhci_alloc_command(xhci, true, GFP_KERNEL);
|
||||
+ command = xhci_alloc_command(xhci, true, GFP_LX_DMA);
|
||||
if (!command)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1355,7 +1357,7 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
|
||||
switch (usb_endpoint_type(&urb->ep->desc)) {
|
||||
|
||||
case USB_ENDPOINT_XFER_CONTROL:
|
||||
- ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb,
|
||||
+ ret = xhci_queue_ctrl_tx(xhci, GFP_LX_DMA, urb,
|
||||
slot_id, ep_index);
|
||||
break;
|
||||
case USB_ENDPOINT_XFER_BULK:
|
||||
@@ -1366,18 +1368,18 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
- ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb,
|
||||
+ ret = xhci_queue_bulk_tx(xhci, GFP_LX_DMA, urb,
|
||||
slot_id, ep_index);
|
||||
break;
|
||||
|
||||
|
||||
case USB_ENDPOINT_XFER_INT:
|
||||
- ret = xhci_queue_intr_tx(xhci, GFP_ATOMIC, urb,
|
||||
+ ret = xhci_queue_intr_tx(xhci, GFP_LX_DMA, urb,
|
||||
slot_id, ep_index);
|
||||
break;
|
||||
|
||||
case USB_ENDPOINT_XFER_ISOC:
|
||||
- ret = xhci_queue_isoc_tx_prepare(xhci, GFP_ATOMIC, urb,
|
||||
+ ret = xhci_queue_isoc_tx_prepare(xhci, GFP_LX_DMA, urb,
|
||||
slot_id, ep_index);
|
||||
}
|
||||
|
||||
@@ -1499,7 +1501,7 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
|
||||
* the first cancellation to be handled.
|
||||
*/
|
||||
if (!(ep->ep_state & EP_STOP_CMD_PENDING)) {
|
||||
- command = xhci_alloc_command(xhci, false, GFP_ATOMIC);
|
||||
+ command = xhci_alloc_command(xhci, false, GFP_LX_DMA);
|
||||
if (!command) {
|
||||
ret = -ENOMEM;
|
||||
goto done;
|
||||
@@ -2684,7 +2686,7 @@ static int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
|
||||
xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
|
||||
virt_dev = xhci->devs[udev->slot_id];
|
||||
|
||||
- command = xhci_alloc_command(xhci, true, GFP_KERNEL);
|
||||
+ command = xhci_alloc_command(xhci, true, GFP_LX_DMA);
|
||||
if (!command)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -3560,7 +3562,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)
|
||||
u32 state;
|
||||
int ret = 0;
|
||||
|
||||
- command = xhci_alloc_command(xhci, false, GFP_KERNEL);
|
||||
+ command = xhci_alloc_command(xhci, false, GFP_LX_DMA);
|
||||
if (!command)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -3622,7 +3624,7 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
|
||||
int ret, slot_id;
|
||||
struct xhci_command *command;
|
||||
|
||||
- command = xhci_alloc_command(xhci, true, GFP_KERNEL);
|
||||
+ command = xhci_alloc_command(xhci, true, GFP_LX_DMA);
|
||||
if (!command)
|
||||
return 0;
|
||||
|
||||
@@ -3755,7 +3757,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
|
||||
}
|
||||
}
|
||||
|
||||
- command = xhci_alloc_command(xhci, true, GFP_KERNEL);
|
||||
+ command = xhci_alloc_command(xhci, true, GFP_LX_DMA);
|
||||
if (!command) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
@@ -4688,7 +4690,7 @@ static int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
|
||||
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
if (hdev->speed == USB_SPEED_HIGH &&
|
||||
- xhci_alloc_tt_info(xhci, vdev, hdev, tt, GFP_ATOMIC)) {
|
||||
+ xhci_alloc_tt_info(xhci, vdev, hdev, tt, GFP_LX_DMA)) {
|
||||
xhci_dbg(xhci, "Could not allocate xHCI TT structure.\n");
|
||||
xhci_free_command(xhci, config_cmd);
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
12
repos/dde_linux/patches/usb_host_omap.patch
Normal file
12
repos/dde_linux/patches/usb_host_omap.patch
Normal file
@ -0,0 +1,12 @@
|
||||
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
|
||||
index 8d8bafc..3c3f71c 100644
|
||||
--- a/drivers/usb/host/ehci-omap.c
|
||||
+++ b/drivers/usb/host/ehci-omap.c
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <linux/clk.h>
|
||||
#include <linux/usb.h>
|
||||
#include <linux/usb/hcd.h>
|
||||
+#include <linux/usb/phy.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
|
@ -1 +1 @@
|
||||
4a6dd8a8cd9919910a4988a1218b2de29016349a
|
||||
d0b8fe75d35d994df3bc98161d5d7558513a5d4a
|
||||
|
@ -2,21 +2,25 @@ LICENSE := GPLv2
|
||||
VERSION := 2
|
||||
DOWNLOADS := dwc_otg.git usb.archive intel_fb.archive lxip.archive \
|
||||
wifi.archive fec.archive libnl.archive wpa_supplicant.git \
|
||||
fw.archive
|
||||
fw.archive usb_host.archive dwc_otg_host.git
|
||||
|
||||
#
|
||||
# Tools
|
||||
#
|
||||
$(call check_tool,flex)
|
||||
$(call check_tool,bison)
|
||||
|
||||
FLEX = flex
|
||||
YACC = bison
|
||||
|
||||
#
|
||||
# The git checkout checks for the existence of SRC_DIR, which is created by the
|
||||
# Linux extraction, therefore make sure to checkout the GIT sources first.
|
||||
#
|
||||
usb.archive: dwc_otg.git
|
||||
usb_host.archive: dwc_otg_host.git
|
||||
|
||||
|
||||
#
|
||||
# The git checkout checks for the existence of SRC_DIR, which is created by the
|
||||
# Linux extraction, therefore make sure to checkout the GIT sources first.
|
||||
#
|
||||
usb.archive: dwc_otg.git
|
||||
|
||||
#
|
||||
# USB
|
||||
#
|
||||
@ -28,6 +32,17 @@ DIR(usb) := $(SRC_DIR_USB)
|
||||
TAR_OPT(usb) := --strip-components=1 --files-from - < <(sed 's/-x.x.x/-$(VERSION_USB)/g' $(REP_DIR)/usb.list)
|
||||
HASH_INPUT += $(REP_DIR)/usb.list
|
||||
|
||||
#
|
||||
# USB host controller
|
||||
#
|
||||
SRC_DIR_USB_HOST := src/drivers/usb_host
|
||||
VERSION_USB_HOST := 4.16.3
|
||||
URL(usb_host) := https://www.kernel.org/pub/linux/kernel/v4.x/linux-$(VERSION_USB_HOST).tar.xz
|
||||
SHA(usb_host) := 0d6971a81da97e38b974c5eba31a74803bfe41aabc46d406c3acda56306c81a3
|
||||
DIR(usb_host) := $(SRC_DIR_USB_HOST)
|
||||
TAR_OPT(usb_host) := --strip-components=1 --files-from - < <(sed 's/-x.x.x/-$(VERSION_USB_HOST)/g' $(REP_DIR)/usb_host.list)
|
||||
HASH_INPUT += $(REP_DIR)/usb_host.list
|
||||
|
||||
#
|
||||
# Raspberry Pi USB controller
|
||||
#
|
||||
@ -35,6 +50,10 @@ URL(dwc_otg) := https://github.com/ssumpf/dwc_otg.git
|
||||
REV(dwc_otg) := r3
|
||||
DIR(dwc_otg) := $(SRC_DIR_USB)/drivers/usb/host/dwc_otg
|
||||
|
||||
URL(dwc_otg_host) := https://github.com/skalk/dwc_otg.git
|
||||
REV(dwc_otg_host) := r4
|
||||
DIR(dwc_otg_host) := $(SRC_DIR_USB_HOST)/drivers/usb/host
|
||||
|
||||
|
||||
#
|
||||
# Intel framebuffer driver
|
||||
@ -112,6 +131,7 @@ PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/libnl*.pa
|
||||
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/wifi*.patch)))
|
||||
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/lxip*.patch)))
|
||||
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/intel*.patch)))
|
||||
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/usb_host*.patch)))
|
||||
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/usb*.patch)))
|
||||
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/intel*.patch)))
|
||||
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/fec_*.patch)))
|
||||
@ -147,6 +167,11 @@ PATCH_OPT(patches/usb_usbnet.patch) := $(USB_OPT)
|
||||
PATCH_OPT(patches/usb_rndis.patch) := $(USB_OPT)
|
||||
PATCH_OPT(patches/usb_tv64.patch) := $(USB_OPT)
|
||||
|
||||
# USB HOST
|
||||
USB_HOST_OPT = -p1 -d$(SRC_DIR_USB_HOST)
|
||||
PATCH_OPT(patches/usb_host_mem.patch) := $(USB_HOST_OPT)
|
||||
PATCH_OPT(patches/usb_host_omap.patch) := $(USB_HOST_OPT)
|
||||
|
||||
# INTEL FB
|
||||
PATCH_OPT(patches/intel_fb_backlight.patch) := -p1 -d$(SRC_DIR_INTEL_FB)
|
||||
PATCH_OPT(patches/intel_fb_drm.patch) := -p1 -d$(SRC_DIR_INTEL_FB)
|
||||
|
66
repos/dde_linux/src/drivers/usb_host/README
Normal file
66
repos/dde_linux/src/drivers/usb_host/README
Normal file
@ -0,0 +1,66 @@
|
||||
USB host controller driver
|
||||
##########################
|
||||
|
||||
Allows access to USB devices via the 'Usb' session interface.
|
||||
|
||||
Configuration snippet:
|
||||
|
||||
!<start name="usb_host_drv">
|
||||
! <resource name="RAM" quantum="10M"/>
|
||||
! <provides><service name="Usb"/></provides>
|
||||
! <config>
|
||||
! <report devices="yes"/>
|
||||
! </config>
|
||||
!</start>
|
||||
|
||||
The optional 'devices' report lists the connected devices and gets updated
|
||||
when devices are added or removed.
|
||||
|
||||
Example report:
|
||||
|
||||
!<devices>
|
||||
! <device label="usb-1-2" vendor_id="0x046d" product_id="0xc077" bus="0x0001" dev="0x0002" class="0x03"/>
|
||||
! <device label="usb-1-1" vendor_id="0x1d6b" product_id="0x0002" bus="0x0001" dev="0x0001" class="0x09"/>
|
||||
!</devices>
|
||||
|
||||
For every device a unique identifier is generated that is used to access the
|
||||
USB device. Only devices that have a valid policy configured at the USB driver
|
||||
can be accessed by a client. The following configuration allows 'comp1' to
|
||||
access the device 'usb-1-6':
|
||||
|
||||
!<start name="usb_drv">
|
||||
! <resource name="RAM" quantum="8M"/>
|
||||
! <provides><service name="Usb"/></provides>
|
||||
! <config uhci="yes" ohci="yes" ehci="yes" xhci="yes">
|
||||
! <raw>
|
||||
! <report devices="yes"/>
|
||||
! <policy label="comp1 -> usb-1-6" vendor_id="0x13fe" product_id="0x5200" bus="0x0001" dev="0x0006"/>
|
||||
! </raw>
|
||||
! </config>
|
||||
!</start>
|
||||
|
||||
In addition to the mandatory 'label' attribute the policy node also
|
||||
contains optional attribute tuples of which at least one has to be present.
|
||||
The 'vendor_id' and 'product_id' tuple selects a device regardless of its
|
||||
location on the USB bus and is mostly used in static configurations. The
|
||||
'bus' and 'dev' tuple selects a specific device via its bus locations and
|
||||
device address. It is mostly used in dynamic configurations because the device
|
||||
address is not fixed and may change every time the same device is plugged in.
|
||||
If the class attribute is defined only, the usb host controller driver allows
|
||||
access to all devives of that class. In that case the actual device is chosen
|
||||
by the last label given when a session gets opened.
|
||||
|
||||
|
||||
BIOS Handoff
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Per default the USB driver performs a hand off of the USB controller from the
|
||||
BIOS, since it still may access the controller when booting, for example, from
|
||||
a USB device. The BIOS hand off induces the execution of BIOS/SMM USB driver
|
||||
code and potentially DMA operations. Unfortunately, some ACPI tables report
|
||||
wrong RMRR information, which implicates IOMMU faults on illegal DMA
|
||||
operations and consequently the hand off may fail after noticeably long
|
||||
timeouts. Therefore, the hand off can be disabled in the USB driver
|
||||
configuration like follows.
|
||||
|
||||
! <config bios_handoff="no"/>
|
1229
repos/dde_linux/src/drivers/usb_host/dummies.c
Normal file
1229
repos/dde_linux/src/drivers/usb_host/dummies.c
Normal file
File diff suppressed because it is too large
Load Diff
1091
repos/dde_linux/src/drivers/usb_host/lx_emul.cc
Normal file
1091
repos/dde_linux/src/drivers/usb_host/lx_emul.cc
Normal file
File diff suppressed because it is too large
Load Diff
1825
repos/dde_linux/src/drivers/usb_host/lx_emul.h
Normal file
1825
repos/dde_linux/src/drivers/usb_host/lx_emul.h
Normal file
File diff suppressed because it is too large
Load Diff
171
repos/dde_linux/src/drivers/usb_host/main.cc
Normal file
171
repos/dde_linux/src/drivers/usb_host/main.cc
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* \brief Startup USB driver library
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2013-02-20
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
/* Genode */
|
||||
#include <base/component.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/sleep.h>
|
||||
|
||||
/* Local */
|
||||
#include <signal.h>
|
||||
#include <lx_emul.h>
|
||||
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/pci.h>
|
||||
#include <lx_kit/irq.h>
|
||||
#include <lx_kit/malloc.h>
|
||||
#include <lx_kit/scheduler.h>
|
||||
#include <lx_kit/timer.h>
|
||||
#include <lx_kit/work.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
extern "C" int subsys_usb_init();
|
||||
extern "C" void module_raw_driver_init();
|
||||
extern "C" void start_input_service(void *ep, void *services);
|
||||
|
||||
struct workqueue_struct *system_power_efficient_wq;
|
||||
struct workqueue_struct *system_wq;
|
||||
struct workqueue_struct *tasklet_wq;
|
||||
|
||||
void breakpoint() { Genode::log("BREAK"); }
|
||||
|
||||
extern "C" int stdout_write(const char *);
|
||||
|
||||
static void run_linux(void *s)
|
||||
{
|
||||
Services *services = (Services *)s;
|
||||
|
||||
system_power_efficient_wq = alloc_workqueue("system_power_efficient_wq", 0, 0);
|
||||
system_wq = alloc_workqueue("system_wq", 0, 0);
|
||||
tasklet_wq = alloc_workqueue("tasklet_wq", 0, 0);
|
||||
|
||||
/* low level interface */
|
||||
module_raw_driver_init();
|
||||
|
||||
/* USB */
|
||||
subsys_usb_init();
|
||||
|
||||
/* host controller */
|
||||
platform_hcd_init(services);
|
||||
|
||||
while (true)
|
||||
Lx::scheduler().current()->block_and_schedule();
|
||||
}
|
||||
|
||||
|
||||
static void start_usb_driver(Genode::Env &env)
|
||||
{
|
||||
/* initialize USB env */
|
||||
Lx_kit::construct_env(env);
|
||||
|
||||
/* sets up backend alloc needed by malloc */
|
||||
backend_alloc_init(env, env.ram(), Lx_kit::env().heap());
|
||||
|
||||
Lx::malloc_init(env, Lx_kit::env().heap());
|
||||
|
||||
static Services services(env);
|
||||
|
||||
Raw::init(env, services.raw_report_device_list);
|
||||
|
||||
Lx::scheduler(&env);
|
||||
Lx::timer(&env, &env.ep(), &Lx_kit::env().heap(), &jiffies);
|
||||
|
||||
Lx::Irq::irq(&env.ep(), &Lx_kit::env().heap());
|
||||
Lx::Work::work_queue(&Lx_kit::env().heap());
|
||||
|
||||
static Lx::Task linux(run_linux, &services, "linux", Lx::Task::PRIORITY_0,
|
||||
Lx::scheduler());
|
||||
|
||||
Lx::scheduler().schedule();
|
||||
}
|
||||
|
||||
namespace Usb_driver {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Driver_starter { virtual void start_driver() = 0; };
|
||||
struct Main;
|
||||
}
|
||||
|
||||
|
||||
struct Usb_driver::Main : Driver_starter
|
||||
{
|
||||
Env &_env;
|
||||
|
||||
/*
|
||||
* Defer the startup of the USB driver until the first configuration
|
||||
* becomes available. This is needed in scenarios where the configuration
|
||||
* is dynamically generated and supplied to the USB driver via the
|
||||
* report-ROM service.
|
||||
*/
|
||||
struct Initial_config_handler
|
||||
{
|
||||
Driver_starter &_driver_starter;
|
||||
|
||||
Attached_rom_dataspace _config;
|
||||
|
||||
Signal_handler<Initial_config_handler> _config_handler;
|
||||
|
||||
void _handle_config()
|
||||
{
|
||||
_config.update();
|
||||
|
||||
if (_config.xml().type() == "config")
|
||||
_driver_starter.start_driver();
|
||||
}
|
||||
|
||||
Initial_config_handler(Env &env, Driver_starter &driver_starter)
|
||||
:
|
||||
_driver_starter(driver_starter),
|
||||
_config(env, "config"),
|
||||
_config_handler(env.ep(), *this, &Initial_config_handler::_handle_config)
|
||||
{
|
||||
_config.sigh(_config_handler);
|
||||
_handle_config();
|
||||
}
|
||||
};
|
||||
|
||||
void _handle_start()
|
||||
{
|
||||
if (_initial_config_handler.constructed()) {
|
||||
_initial_config_handler.destruct();
|
||||
start_usb_driver(_env);
|
||||
}
|
||||
}
|
||||
|
||||
Signal_handler<Main> _start_handler {
|
||||
_env.ep(), *this, &Main::_handle_start };
|
||||
|
||||
Reconstructible<Initial_config_handler> _initial_config_handler { _env, *this };
|
||||
|
||||
/*
|
||||
* Called from 'Initial_config_handler'
|
||||
*/
|
||||
void start_driver() override
|
||||
{
|
||||
Signal_transmitter(_start_handler).submit();
|
||||
}
|
||||
|
||||
Main(Env &env) : _env(env) { }
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
/* XXX execute constructors of global statics */
|
||||
env.exec_static_constructors();
|
||||
|
||||
static Usb_driver::Main main(env);
|
||||
}
|
50
repos/dde_linux/src/drivers/usb_host/platform.h
Normal file
50
repos/dde_linux/src/drivers/usb_host/platform.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* \brief Platform specific definitions
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2012-07-06
|
||||
*
|
||||
* These functions have to be implemented on all supported platforms.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#ifndef _PLATFORM_H_
|
||||
#define _PLATFORM_H_
|
||||
|
||||
#include <base/log.h>
|
||||
#include <util/xml_node.h>
|
||||
#include <irq_session/capability.h>
|
||||
|
||||
#include <lx_kit/env.h>
|
||||
|
||||
struct Services
|
||||
{
|
||||
Genode::Env &env;
|
||||
|
||||
/* report generation */
|
||||
bool raw_report_device_list = false;
|
||||
|
||||
Services(Genode::Env &env) : env(env)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
Genode::Xml_node config_node = Lx_kit::env().config_rom().xml();
|
||||
|
||||
try {
|
||||
Genode::Xml_node node_report = config_node.sub_node("report");
|
||||
raw_report_device_list = node_report.attribute_value("devices", false);
|
||||
} catch (...) { }
|
||||
}
|
||||
};
|
||||
|
||||
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram, Genode::Allocator &alloc);
|
||||
|
||||
void platform_hcd_init(Services *services);
|
||||
Genode::Irq_session_capability platform_irq_activate(int irq);
|
||||
|
||||
#endif /* _PLATFORM_H_ */
|
1135
repos/dde_linux/src/drivers/usb_host/raw.cc
Normal file
1135
repos/dde_linux/src/drivers/usb_host/raw.cc
Normal file
File diff suppressed because it is too large
Load Diff
12
repos/dde_linux/src/drivers/usb_host/raw.h
Normal file
12
repos/dde_linux/src/drivers/usb_host/raw.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef _RAW_H_
|
||||
#define _RAW_H_
|
||||
|
||||
struct usb_device;
|
||||
struct usb_driver;
|
||||
|
||||
extern struct usb_device_driver raw_driver;
|
||||
extern struct usb_driver raw_intf_driver;
|
||||
|
||||
int raw_notify(struct notifier_block *nb, unsigned long action, void *data);
|
||||
|
||||
#endif /* _RAW_H_ */
|
94
repos/dde_linux/src/drivers/usb_host/raw_driver.c
Normal file
94
repos/dde_linux/src/drivers/usb_host/raw_driver.c
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* \brief Low level USB access driver
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2014-11-11
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#include <linux/usb.h>
|
||||
#include "raw.h"
|
||||
|
||||
static int raw_probe(struct usb_device *udev)
|
||||
{
|
||||
printk("RAW: vendor: %x product: %x dev %p\n",
|
||||
udev->descriptor.idVendor, udev->descriptor.idProduct, udev);
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static void raw_disconnect(struct usb_device *udev)
|
||||
{
|
||||
printk("driver disconnect called\n");
|
||||
}
|
||||
|
||||
|
||||
struct usb_device_driver raw_driver =
|
||||
{
|
||||
.name = "raw",
|
||||
.probe = raw_probe,
|
||||
.disconnect = raw_disconnect,
|
||||
.supports_autosuspend = 0,
|
||||
};
|
||||
|
||||
|
||||
static int raw_intf_probe(struct usb_interface *intf,
|
||||
struct usb_device_id const *id)
|
||||
{
|
||||
struct usb_device *udev = interface_to_usbdev(intf);
|
||||
|
||||
printk("RAW_INTF: vendor: %04x product: %04x\n", udev->descriptor.idVendor,
|
||||
udev->descriptor.idProduct);
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
void raw_intf_disconnect(struct usb_interface *intf) { }
|
||||
|
||||
static const struct usb_device_id raw_intf_id_table[] = {
|
||||
{ .driver_info = 1 }
|
||||
};
|
||||
|
||||
|
||||
struct usb_driver raw_intf_driver =
|
||||
{
|
||||
.name = "rawintf",
|
||||
.probe = raw_intf_probe,
|
||||
.disconnect = raw_intf_disconnect,
|
||||
.supports_autosuspend = 0,
|
||||
};
|
||||
|
||||
|
||||
struct notifier_block usb_nb =
|
||||
{
|
||||
.notifier_call = raw_notify
|
||||
};
|
||||
|
||||
|
||||
static int raw_driver_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
if ((err = usb_register_device_driver(&raw_driver, THIS_MODULE)))
|
||||
return err;
|
||||
|
||||
printk("RAW: driver registered\n");
|
||||
|
||||
if ((err = usb_register(&raw_intf_driver)))
|
||||
return err;
|
||||
|
||||
printk("RAW: interface driver registered\n");
|
||||
|
||||
usb_register_notify(&usb_nb);
|
||||
|
||||
printk("RAW: notify function registered\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(raw_driver_init);
|
52
repos/dde_linux/src/drivers/usb_host/signal.h
Normal file
52
repos/dde_linux/src/drivers/usb_host/signal.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* \brief Main-signal receiver and signal-helper functions
|
||||
* \author Sebastian Sumpf <sebastian.sumpf@genode-labs.com>
|
||||
* \date 2012-05-23
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#ifndef _SIGNAL_H_
|
||||
#define _SIGNAL_H_
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
#include <base/signal.h>
|
||||
|
||||
static bool const verbose = false;
|
||||
|
||||
/**
|
||||
* Helper that holds sender and entrypoint
|
||||
*/
|
||||
class Signal_helper
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Env &_env;
|
||||
Genode::Signal_transmitter _sender;
|
||||
|
||||
public:
|
||||
|
||||
Signal_helper(Genode::Env &env) : _env(env) { }
|
||||
|
||||
Genode::Entrypoint &ep() { return _env.ep(); }
|
||||
Genode::Signal_transmitter &sender() { return _sender; }
|
||||
Genode::Parent &parent() { return _env.parent(); }
|
||||
Genode::Env &env() { return _env; }
|
||||
Genode::Ram_session &ram() { return _env.ram(); }
|
||||
Genode::Region_map &rm() { return _env.rm(); }
|
||||
};
|
||||
|
||||
|
||||
namespace Raw
|
||||
{
|
||||
void init(Genode::Env &env, bool report_device_list);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _SIGNAL_H_ */
|
87
repos/dde_linux/src/drivers/usb_host/spec/arm/platform.cc
Normal file
87
repos/dde_linux/src/drivers/usb_host/spec/arm/platform.cc
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* \brief ARM specific implemenations used on all SOCs
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2016-04-25
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#include <base/attached_io_mem_dataspace.h>
|
||||
#include <base/env.h>
|
||||
|
||||
#include <lx_emul.h>
|
||||
|
||||
#include <lx_kit/backend_alloc.h>
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/irq.h>
|
||||
|
||||
|
||||
/****************************
|
||||
** lx_kit/backend_alloc.h **
|
||||
****************************/
|
||||
|
||||
void backend_alloc_init(Genode::Env&, Genode::Ram_session&,
|
||||
Genode::Allocator&)
|
||||
{
|
||||
/* intentionally left blank */
|
||||
}
|
||||
|
||||
|
||||
Genode::Ram_dataspace_capability
|
||||
Lx::backend_alloc(Genode::addr_t size, Genode::Cache_attribute cached) {
|
||||
return Lx_kit::env().env().ram().alloc(size, cached); }
|
||||
|
||||
|
||||
void Lx::backend_free(Genode::Ram_dataspace_capability cap) {
|
||||
return Lx_kit::env().env().ram().free(cap); }
|
||||
|
||||
|
||||
/***********************
|
||||
** linux/interrupt.h **
|
||||
***********************/
|
||||
|
||||
extern "C" int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
|
||||
const char *name, void *dev)
|
||||
{
|
||||
Lx::Irq::irq().request_irq(Platform::Device::create(Lx_kit::env().env(), irq), handler, dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler, unsigned long irqflags, const char *devname, void *dev_id)
|
||||
{
|
||||
Lx::Irq::irq().request_irq(Platform::Device::create(Lx_kit::env().env(), irq), handler, dev_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
** asm-generic/io.h **
|
||||
**********************/
|
||||
|
||||
void *_ioremap(phys_addr_t phys_addr, unsigned long size, int wc)
|
||||
{
|
||||
try {
|
||||
Genode::Attached_io_mem_dataspace *ds =
|
||||
new(Lx::Malloc::mem())
|
||||
Genode::Attached_io_mem_dataspace(Lx_kit::env().env(), phys_addr, size, !!wc);
|
||||
return ds->local_addr<void>();
|
||||
} catch (...) {
|
||||
panic("Failed to request I/O memory: [%lx,%lx)", phys_addr, phys_addr + size);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *ioremap(phys_addr_t offset, unsigned long size)
|
||||
{
|
||||
return _ioremap(offset, size, 0);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* \brief Platform_device implementation for ARM
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2016-04-25
|
||||
*
|
||||
* Note: Throw away when there exists a plaform device implementation for ARM
|
||||
* in generic code
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#ifndef _ARM__PLATFORM_DEVICE__PLATFORM_DEVICE_H_
|
||||
#define _ARM__PLATFORM_DEVICE__PLATFORM_DEVICE_H_
|
||||
|
||||
|
||||
#include <lx_emul/extern_c_begin.h>
|
||||
#include <lx_emul/printf.h>
|
||||
#include <lx_emul/extern_c_end.h>
|
||||
|
||||
#include <lx_kit/malloc.h>
|
||||
#include <platform_device/device.h>
|
||||
|
||||
#include <irq_session/connection.h>
|
||||
#include <util/list.h>
|
||||
#include <util/reconstructible.h>
|
||||
|
||||
|
||||
namespace Platform { struct Device; }
|
||||
|
||||
struct Platform::Device : Platform::Abstract_device, Genode::List<Device>::Element
|
||||
{
|
||||
Genode::Env &env;
|
||||
|
||||
unsigned irq_num;
|
||||
Genode::Constructible<Genode::Irq_connection> irq_connection;
|
||||
|
||||
Device(Genode::Env &env, unsigned irq) : env(env), irq_num(irq) { }
|
||||
|
||||
unsigned vendor_id() { return ~0U; }
|
||||
unsigned device_id() { return ~0U; }
|
||||
|
||||
Genode::Irq_session_capability irq(Genode::uint8_t) override
|
||||
{
|
||||
irq_connection.construct(env, irq_num);
|
||||
return irq_connection->cap();
|
||||
}
|
||||
|
||||
Genode::Io_mem_session_capability io_mem(Genode::uint8_t,
|
||||
Genode::Cache_attribute,
|
||||
Genode::addr_t, Genode::size_t) override
|
||||
{
|
||||
lx_printf("%s: not implemented\n", __PRETTY_FUNCTION__);
|
||||
return Genode::Io_mem_session_capability();
|
||||
}
|
||||
|
||||
static Genode::List<Device> &list()
|
||||
{
|
||||
static Genode::List<Device> l;
|
||||
return l;
|
||||
}
|
||||
|
||||
static Device &create(Genode::Env &env, unsigned irq_num)
|
||||
{
|
||||
Device *d;
|
||||
for (d = list().first(); d; d = d->next())
|
||||
if (d->irq_num == irq_num)
|
||||
return *d;
|
||||
|
||||
d = new (Lx::Malloc::mem()) Device(env, irq_num);
|
||||
list().insert(d);
|
||||
|
||||
return *d;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _ARM__PLATFORM_DEVICE__PLATFORM_DEVICE_H_ */
|
340
repos/dde_linux/src/drivers/usb_host/spec/arndale/platform.cc
Normal file
340
repos/dde_linux/src/drivers/usb_host/spec/arndale/platform.cc
Normal file
@ -0,0 +1,340 @@
|
||||
/*
|
||||
* \brief EHCI for Arndale initialization code
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2013-02-20
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
/* Genode */
|
||||
#include <drivers/defs/arndale.h>
|
||||
#include <base/attached_io_mem_dataspace.h>
|
||||
#include <io_mem_session/connection.h>
|
||||
#include <regulator/consts.h>
|
||||
#include <regulator_session/connection.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <util/mmio.h>
|
||||
|
||||
/* Emulation */
|
||||
#include <lx_emul.h>
|
||||
#include <platform.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
enum {
|
||||
EHCI_BASE = 0x12110000,
|
||||
DWC3_BASE = 0x12000000,
|
||||
DWC3_PHY_BASE = 0x12100000,
|
||||
GPIO_BASE = 0x11400000,
|
||||
EHCI_IRQ = Arndale::USB_HOST20_IRQ,
|
||||
DWC3_IRQ = Arndale::USB_DRD30_IRQ,
|
||||
};
|
||||
|
||||
static resource _ehci[] =
|
||||
{
|
||||
{ EHCI_BASE, EHCI_BASE + 0xfff, "ehci", IORESOURCE_MEM },
|
||||
{ EHCI_IRQ, EHCI_IRQ, "ehci-irq", IORESOURCE_IRQ },
|
||||
};
|
||||
|
||||
static resource _dwc3[] =
|
||||
{
|
||||
{ DWC3_BASE, DWC3_BASE + 0xcfff, "dwc3", IORESOURCE_MEM },
|
||||
{ DWC3_IRQ, DWC3_IRQ, "dwc3-irq", IORESOURCE_IRQ },
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EHCI controller
|
||||
*/
|
||||
struct Ehci : Genode::Mmio
|
||||
{
|
||||
Ehci(addr_t const mmio_base) : Mmio(mmio_base)
|
||||
{
|
||||
write<Cmd>(0);
|
||||
|
||||
/* reset */
|
||||
write<Cmd::Reset>(1);
|
||||
|
||||
while(read<Cmd::Reset>())
|
||||
msleep(1);
|
||||
}
|
||||
|
||||
struct Cmd : Register<0x10, 32>
|
||||
{
|
||||
struct Reset : Bitfield<1, 1> { };
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Gpio handling
|
||||
*/
|
||||
struct Gpio_bank {
|
||||
unsigned con;
|
||||
unsigned dat;
|
||||
};
|
||||
|
||||
|
||||
static inline
|
||||
unsigned con_mask(unsigned val) { return 0xf << ((val) << 2); }
|
||||
|
||||
|
||||
static inline
|
||||
unsigned con_sfr(unsigned x, unsigned v) { return (v) << ((x) << 2); }
|
||||
|
||||
|
||||
static void gpio_cfg_pin(Gpio_bank *bank, int gpio, int cfg)
|
||||
{
|
||||
unsigned int value;
|
||||
|
||||
value = readl(&bank->con);
|
||||
value &= ~con_mask(gpio);
|
||||
value |= con_sfr(gpio, cfg);
|
||||
writel(value, &bank->con);
|
||||
}
|
||||
|
||||
|
||||
static void gpio_direction_output(Gpio_bank *bank, int gpio, int en)
|
||||
{
|
||||
unsigned int value;
|
||||
enum { GPIO_OUTPUT = 0x1 };
|
||||
|
||||
gpio_cfg_pin(bank, gpio, GPIO_OUTPUT);
|
||||
|
||||
value = readl(&bank->dat);
|
||||
value &= ~(0x1 << gpio);
|
||||
if (en)
|
||||
value |= 0x1 << gpio;
|
||||
writel(value, &bank->dat);
|
||||
}
|
||||
|
||||
|
||||
static void arndale_ehci_init(Genode::Env &env)
|
||||
{
|
||||
enum Gpio_offset { D1 = 0x180, X3 = 0xc60 };
|
||||
|
||||
/* enable USB3 clock and power up */
|
||||
static Regulator::Connection reg_clk(env, Regulator::CLK_USB20);
|
||||
reg_clk.state(true);
|
||||
|
||||
static Regulator::Connection reg_pwr(env, Regulator::PWR_USB20);
|
||||
reg_pwr.state(true);
|
||||
|
||||
/* reset hub via GPIO */
|
||||
Io_mem_connection io_gpio(env, GPIO_BASE, 0x1000);
|
||||
addr_t gpio_base = (addr_t)env.rm().attach(io_gpio.dataspace());
|
||||
|
||||
Gpio_bank *d1 = reinterpret_cast<Gpio_bank *>(gpio_base + D1);
|
||||
Gpio_bank *x3 = reinterpret_cast<Gpio_bank *>(gpio_base + X3);
|
||||
|
||||
/* hub reset */
|
||||
gpio_direction_output(x3, 5, 0);
|
||||
/* hub connect */
|
||||
gpio_direction_output(d1, 7, 0);
|
||||
|
||||
gpio_direction_output(x3, 5, 1);
|
||||
gpio_direction_output(d1, 7, 1);
|
||||
|
||||
env.rm().detach(gpio_base);
|
||||
|
||||
/* reset ehci controller */
|
||||
Io_mem_connection io_ehci(env, EHCI_BASE, 0x1000);
|
||||
addr_t ehci_base = (addr_t)env.rm().attach(io_ehci.dataspace());
|
||||
|
||||
Ehci ehci(ehci_base);
|
||||
env.rm().detach(ehci_base);
|
||||
}
|
||||
|
||||
|
||||
struct Phy_usb3 : Genode::Mmio
|
||||
{
|
||||
struct Link_system : Register<0x4, 32>
|
||||
{
|
||||
struct Fladj : Bitfield<1, 6> { };
|
||||
struct Ehci_version_control : Bitfield<27, 1> { };
|
||||
};
|
||||
|
||||
struct Phy_utmi : Register<0x8, 32> { };
|
||||
|
||||
struct Phy_clk_rst : Register<0x10, 32>
|
||||
{
|
||||
struct Common_onn : Bitfield<0, 1> { };
|
||||
struct Port_reset : Bitfield<1, 1> { };
|
||||
struct Ref_clk_sel : Bitfield<2, 2> { };
|
||||
struct Retenablen : Bitfield<4, 1> { };
|
||||
struct Fsel : Bitfield<5, 6> { };
|
||||
struct Mpll_mult : Bitfield<11, 7> { };
|
||||
struct Ref_ssp_en : Bitfield<19, 1> { };
|
||||
struct Ssc_en : Bitfield<20, 1> { };
|
||||
struct Ssc_ref_clk_sel : Bitfield<23, 8> { };
|
||||
};
|
||||
|
||||
struct Phy_reg0 : Register<0x14, 32> { };
|
||||
|
||||
struct Phy_param0 : Register<0x1c, 32>
|
||||
{
|
||||
struct Loss_level : Bitfield<26, 5> { };
|
||||
struct Ref_use_pad : Bitfield<31, 1> { };
|
||||
};
|
||||
|
||||
struct Phy_param1 : Register<0x20, 32>
|
||||
{
|
||||
struct Pcs_txdeemph : Bitfield<0, 5> { };
|
||||
};
|
||||
|
||||
struct Phy_test : Register<0x28, 32>
|
||||
{
|
||||
struct Power_down_ssb_hsb : Bitfield<2, 2> { };
|
||||
};
|
||||
|
||||
struct Phy_batchg : Register<0x30, 32>
|
||||
{
|
||||
struct Utmi_clksel : Bitfield<2, 1> { };
|
||||
};
|
||||
|
||||
struct Phy_resume : Register<0x34, 32> { };
|
||||
|
||||
Phy_usb3 (Genode::Env & env, addr_t const base) : Mmio(base)
|
||||
{
|
||||
Timer::Connection timer(env);
|
||||
|
||||
/* reset */
|
||||
write<Phy_reg0>(0);
|
||||
|
||||
/* clock source */
|
||||
write<Phy_param0::Ref_use_pad>(0);
|
||||
|
||||
/* set Loss-of-Signal Detector sensitivity */
|
||||
write<Phy_param0::Loss_level>(0x9);
|
||||
write<Phy_resume>(0);
|
||||
|
||||
/*
|
||||
* Setting the Frame length Adj value[6:1] to default 0x20
|
||||
* See xHCI 1.0 spec, 5.2.4
|
||||
*/
|
||||
write<Link_system::Ehci_version_control>(1);
|
||||
write<Link_system::Fladj>(0x20);
|
||||
|
||||
/* set Tx De-Emphasis level */
|
||||
write<Phy_param1::Pcs_txdeemph>(0x1c);
|
||||
|
||||
/* set clock */
|
||||
write<Phy_batchg::Utmi_clksel>(1);
|
||||
|
||||
/* PHYTEST POWERDOWN Control */
|
||||
write<Phy_test::Power_down_ssb_hsb>(0);
|
||||
|
||||
/* UTMI power */
|
||||
enum { OTG_DISABLE = (1 << 6) };
|
||||
write<Phy_utmi>(OTG_DISABLE);
|
||||
|
||||
/* setup clock */
|
||||
Phy_clk_rst::access_t clk = 0;
|
||||
|
||||
/*
|
||||
* Use same reference clock for high speed
|
||||
* as for super speed
|
||||
*/
|
||||
Phy_clk_rst::Ref_clk_sel::set(clk, 0x2);
|
||||
/* 24 MHz */
|
||||
Phy_clk_rst::Fsel::set(clk, 0x2a);
|
||||
Phy_clk_rst::Mpll_mult::set(clk, 0x68);
|
||||
Phy_clk_rst::Ssc_ref_clk_sel::set(clk, 0x88);
|
||||
|
||||
/* port reset */
|
||||
Phy_clk_rst::Port_reset::set(clk, 1);
|
||||
|
||||
/* digital power supply in normal operating mode */
|
||||
Phy_clk_rst::Retenablen::set(clk, 1);
|
||||
/* enable ref clock for SS function */
|
||||
Phy_clk_rst::Ref_ssp_en::set(clk, 1);
|
||||
/* enable spread spectrum */
|
||||
Phy_clk_rst::Ssc_en::set(clk, 1);
|
||||
/* power down HS Bias and PLL blocks in suspend mode */
|
||||
Phy_clk_rst::Common_onn::set(clk, 1);
|
||||
|
||||
write<Phy_clk_rst>(clk);
|
||||
timer.usleep(10);
|
||||
write<Phy_clk_rst::Port_reset>(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static void arndale_xhci_init(Genode::Env &env)
|
||||
{
|
||||
/* enable USB3 clock and power up */
|
||||
static Regulator::Connection reg_clk(env, Regulator::CLK_USB30);
|
||||
reg_clk.state(true);
|
||||
|
||||
static Regulator::Connection reg_pwr(env, Regulator::PWR_USB30);
|
||||
reg_pwr.state(true);
|
||||
|
||||
/* setup PHY */
|
||||
Attached_io_mem_dataspace io_phy(env, DWC3_PHY_BASE, 0x1000);
|
||||
Phy_usb3 phy(env, (addr_t)io_phy.local_addr<addr_t>());
|
||||
}
|
||||
|
||||
|
||||
extern "C" void module_ehci_exynos_init();
|
||||
extern "C" void module_dwc3_driver_init();
|
||||
extern "C" void module_xhci_plat_init();
|
||||
|
||||
|
||||
void ehci_setup(Services *services)
|
||||
{
|
||||
/* register EHCI controller */
|
||||
module_ehci_exynos_init();
|
||||
|
||||
/* setup controller */
|
||||
arndale_ehci_init(services->env);
|
||||
|
||||
/* setup EHCI-controller platform device */
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"exynos-ehci";
|
||||
pdev->id = 0;
|
||||
pdev->num_resources = 2;
|
||||
pdev->resource = _ehci;
|
||||
|
||||
/*needed for DMA buffer allocation. See 'hcd_buffer_alloc' in 'buffer.c' */
|
||||
static u64 dma_mask = ~(u64)0;
|
||||
pdev->dev.dma_mask = &dma_mask;
|
||||
pdev->dev.coherent_dma_mask = ~0;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
||||
|
||||
|
||||
void xhci_setup(Services *services)
|
||||
{
|
||||
module_dwc3_driver_init();
|
||||
module_xhci_plat_init();
|
||||
|
||||
arndale_xhci_init(services->env);
|
||||
|
||||
/* setup DWC3-controller platform device */
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"dwc3";
|
||||
pdev->id = 0;
|
||||
pdev->num_resources = 2;
|
||||
pdev->resource = _dwc3;
|
||||
|
||||
/*needed for DMA buffer allocation. See 'hcd_buffer_alloc' in 'buffer.c' */
|
||||
static u64 dma_mask = ~(u64)0;
|
||||
pdev->dev.dma_mask = &dma_mask;
|
||||
pdev->dev.coherent_dma_mask = ~0;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
||||
|
||||
|
||||
void platform_hcd_init(Services *services)
|
||||
{
|
||||
ehci_setup(services);
|
||||
xhci_setup(services);
|
||||
}
|
22
repos/dde_linux/src/drivers/usb_host/spec/arndale/target.mk
Normal file
22
repos/dde_linux/src/drivers/usb_host/spec/arndale/target.mk
Normal file
@ -0,0 +1,22 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/target.inc
|
||||
|
||||
TARGET = arndale_usb_host_drv
|
||||
REQUIRES = arndale
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/drivers/usb_host/spec/arm
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||
|
||||
SRC_CC += spec/arm/platform.cc
|
||||
SRC_CC += spec/arndale/platform.cc
|
||||
|
||||
SRC_C += usb/dwc3/core.c
|
||||
SRC_C += usb/dwc3/dwc3-exynos.c
|
||||
SRC_C += usb/dwc3/host.c
|
||||
SRC_C += usb/host/ehci-exynos.c
|
||||
SRC_C += usb/host/xhci-plat.c
|
||||
|
||||
CC_OPT += -DCONFIG_USB_EHCI_TT_NEWSCHED=1
|
||||
CC_OPT += -DCONFIG_USB_DWC3_HOST=1
|
||||
CC_OPT += -DCONFIG_USB_OTG_UTILS=1
|
||||
CC_OPT += -DCONFIG_USB_XHCI_PLATFORM=1
|
||||
CC_OPT += -DDWC3_QUIRK
|
207
repos/dde_linux/src/drivers/usb_host/spec/odroid_x2/platform.cc
Normal file
207
repos/dde_linux/src/drivers/usb_host/spec/odroid_x2/platform.cc
Normal file
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* \brief EHCI for Odroid-x2 initializaion code
|
||||
* \author Sebastian Sumpf
|
||||
* \author Alexy Gallardo Segura <alexy@uclv.cu>
|
||||
* \author Humberto Lopez Leon <humberto@uclv.cu>
|
||||
* \author Reinir Millo Sanchez <rmillo@uclv.cu>
|
||||
* \date 2015-07-08
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
/* Genode */
|
||||
#include <drivers/defs/odroid_x2.h>
|
||||
#include <base/attached_io_mem_dataspace.h>
|
||||
#include <io_mem_session/connection.h>
|
||||
#include <regulator/consts.h>
|
||||
#include <regulator_session/connection.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <util/mmio.h>
|
||||
#include <gpio_session/connection.h>
|
||||
|
||||
/* Emulation */
|
||||
#include <lx_emul.h>
|
||||
#include <platform.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
enum Usb_masks {
|
||||
PHY0_NORMAL_MASK = 0x39 << 0,
|
||||
PHY0_SWRST_MASK = 0x7 << 0,
|
||||
PHY1_STD_NORMAL_MASK = 0x7 << 6,
|
||||
EXYNOS4X12_HSIC0_NORMAL_MASK = 0x7 << 9,
|
||||
EXYNOS4X12_HSIC1_NORMAL_MASK = 0x7 << 12,
|
||||
EXYNOS4X12_HOST_LINK_PORT_SWRST_MASK = 0xf << 7,
|
||||
EXYNOS4X12_PHY1_SWRST_MASK = 0xf << 3,
|
||||
};
|
||||
|
||||
enum {
|
||||
/*The EHCI base is taken from linux kernel */
|
||||
EHCI_BASE = 0x12580000,
|
||||
GPIO_BASE = 0x11000000,
|
||||
USBOTG = 0x125B0000,
|
||||
EHCI_IRQ = Odroid_x2::USB_HOST20_IRQ,
|
||||
};
|
||||
|
||||
static resource _ehci[] =
|
||||
{
|
||||
{ EHCI_BASE, EHCI_BASE + 0xfff, "ehci", IORESOURCE_MEM },
|
||||
{ EHCI_IRQ, EHCI_IRQ, "ehci-irq", IORESOURCE_IRQ },
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EHCI controller
|
||||
*/
|
||||
struct Ehci : Genode::Mmio
|
||||
{
|
||||
Ehci(addr_t const mmio_base) : Mmio(mmio_base)
|
||||
{
|
||||
write<Cmd>(0);
|
||||
|
||||
/* reset */
|
||||
write<Cmd::Reset>(1);
|
||||
|
||||
while(read<Cmd::Reset>())
|
||||
msleep(1);
|
||||
}
|
||||
|
||||
struct Cmd : Register<0x10, 32>
|
||||
{
|
||||
struct Reset : Bitfield<1, 1> { };
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* USB OTG handling
|
||||
*/
|
||||
struct Usb_otg : Genode::Mmio
|
||||
{
|
||||
Usb_otg(Genode::Env &env, Genode::addr_t base)
|
||||
: Genode::Mmio (base)
|
||||
{
|
||||
Timer::Connection timer(env);
|
||||
unsigned int rstcon_mask = 0;
|
||||
unsigned int phyclk_mask = 5;
|
||||
unsigned int phypwr_mask = 0;
|
||||
|
||||
/*set the clock of device*/
|
||||
write<Phyclk>(phyclk_mask);
|
||||
rstcon_mask= read<Phyclk>();
|
||||
|
||||
/* set to normal of Device */
|
||||
phypwr_mask= read<Phypwr>() & ~PHY0_NORMAL_MASK;
|
||||
write<Phypwr>(phypwr_mask);
|
||||
|
||||
/* set to normal of Host */
|
||||
phypwr_mask=read<Phypwr>();
|
||||
phypwr_mask &= ~(PHY1_STD_NORMAL_MASK
|
||||
|EXYNOS4X12_HSIC0_NORMAL_MASK
|
||||
|EXYNOS4X12_HSIC1_NORMAL_MASK);
|
||||
write<Phypwr>(phypwr_mask);
|
||||
|
||||
/* reset both PHY and Link of Device */
|
||||
rstcon_mask = read<Rstcon>() | PHY0_SWRST_MASK;
|
||||
write<Rstcon>(rstcon_mask);
|
||||
timer.usleep(10);
|
||||
rstcon_mask &= ~PHY0_SWRST_MASK;
|
||||
write<Rstcon>(rstcon_mask);
|
||||
|
||||
/* reset both PHY and Link of Host */
|
||||
rstcon_mask = read<Rstcon>()
|
||||
|EXYNOS4X12_HOST_LINK_PORT_SWRST_MASK
|
||||
|EXYNOS4X12_PHY1_SWRST_MASK;
|
||||
write<Rstcon>(rstcon_mask);
|
||||
timer.usleep(10);
|
||||
rstcon_mask &= ~(EXYNOS4X12_HOST_LINK_PORT_SWRST_MASK
|
||||
|EXYNOS4X12_PHY1_SWRST_MASK);
|
||||
write<Rstcon>(rstcon_mask);
|
||||
timer.usleep(10);
|
||||
}
|
||||
struct Phypwr : Register <0x0,32>{};
|
||||
struct Phyclk : Register <0x4,32>{};
|
||||
struct Rstcon : Register <0x8,32>{};
|
||||
};
|
||||
|
||||
static void clock_pwr_init(Genode::Env &env)
|
||||
{
|
||||
/* enable USB2 clock and power up */
|
||||
static Regulator::Connection reg_clk(env, Regulator::CLK_USB20);
|
||||
reg_clk.state(true);
|
||||
|
||||
static Regulator::Connection reg_pwr(env, Regulator::PWR_USB20);
|
||||
reg_pwr.state(true);
|
||||
}
|
||||
|
||||
static void usb_phy_init(Genode::Env &env)
|
||||
{
|
||||
Io_mem_connection io_usbotg(env, USBOTG, 0x1000);
|
||||
addr_t usbotg_base = (addr_t)env.rm().attach(io_usbotg.dataspace());
|
||||
Usb_otg usbotg(env, usbotg_base);
|
||||
env.rm().detach(usbotg_base);
|
||||
}
|
||||
|
||||
static void odroidx2_ehci_init(Genode::Env &env)
|
||||
{
|
||||
clock_pwr_init(env);
|
||||
usb_phy_init(env);
|
||||
|
||||
/* reset hub via GPIO */
|
||||
enum { X30 = 294, X34 = 298, X35 = 299 };
|
||||
|
||||
Gpio::Connection gpio_x30(env, X30);
|
||||
Gpio::Connection gpio_x34(env, X34);
|
||||
Gpio::Connection gpio_x35(env, X35);
|
||||
|
||||
/* Set Ref freq 0 => 24MHz, 1 => 26MHz*/
|
||||
/* Odroid Us have it at 24MHz, Odroid Xs at 26MHz */
|
||||
gpio_x30.write(true);
|
||||
|
||||
/* Disconnect, Reset, Connect */
|
||||
gpio_x34.write(false);
|
||||
gpio_x35.write(false);
|
||||
gpio_x35.write(true);
|
||||
gpio_x34.write(true);
|
||||
|
||||
/* reset ehci controller */
|
||||
Io_mem_connection io_ehci(env, EHCI_BASE, 0x1000);
|
||||
addr_t ehci_base = (addr_t)env.rm().attach(io_ehci.dataspace());
|
||||
|
||||
Ehci ehci(ehci_base);
|
||||
|
||||
env.rm().detach(ehci_base);
|
||||
}
|
||||
|
||||
extern "C" void module_ehci_exynos_init();
|
||||
extern "C" int module_usbnet_init();
|
||||
extern "C" int module_smsc95xx_driver_init();
|
||||
|
||||
|
||||
void platform_hcd_init(Services *services)
|
||||
{
|
||||
/* register EHCI controller */
|
||||
module_ehci_exynos_init();
|
||||
|
||||
/* setup controller */
|
||||
odroidx2_ehci_init(services->env);
|
||||
|
||||
/* setup EHCI-controller platform device */
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"exynos-ehci";
|
||||
pdev->id = 0;
|
||||
pdev->num_resources = 2;
|
||||
pdev->resource = _ehci;
|
||||
|
||||
/*needed for DMA buffer allocation. See 'hcd_buffer_alloc' in 'buffer.c' */
|
||||
static u64 dma_mask = ~(u64)0;
|
||||
pdev->dev.dma_mask = &dma_mask;
|
||||
pdev->dev.coherent_dma_mask = ~0;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/target.inc
|
||||
|
||||
TARGET = odroid_x2_usb_host_drv
|
||||
REQUIRES = odroid_x2
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/drivers/usb_host/spec/arm
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||
|
||||
SRC_CC += spec/arm/platform.cc
|
||||
SRC_CC += spec/odroid_x2/platform.cc
|
||||
|
||||
SRC_C += usb/host/ehci-exynos.c
|
||||
|
||||
CC_OPT += -DCONFIG_USB_OTG_UTILS=1
|
309
repos/dde_linux/src/drivers/usb_host/spec/panda/platform.cc
Normal file
309
repos/dde_linux/src/drivers/usb_host/spec/panda/platform.cc
Normal file
@ -0,0 +1,309 @@
|
||||
/*
|
||||
* \brief EHCI for OMAP4
|
||||
* \author Sebastian Sumpf <sebastian.sumpf@genode-labs.com>
|
||||
* \date 2012-06-20
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
#include <drivers/defs/panda.h>
|
||||
#include <gpio_session/connection.h>
|
||||
#include <io_mem_session/connection.h>
|
||||
#include <util/mmio.h>
|
||||
|
||||
#include <lx_emul.h>
|
||||
|
||||
#include <linux/platform_data/usb-omap.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
/**
|
||||
* Base addresses
|
||||
*/
|
||||
enum {
|
||||
EHCI_BASE = 0x4a064c00,
|
||||
UHH_BASE = 0x4a064000,
|
||||
TLL_BASE = 0x4a062000,
|
||||
SCRM_BASE = 0x4a30a000,
|
||||
CAM_BASE = 0x4a009000, /* used for L3INIT_CM2 */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Inerrupt numbers
|
||||
*/
|
||||
enum { IRQ_EHCI = Panda::HSUSB_EHCI_IRQ };
|
||||
|
||||
|
||||
/**
|
||||
* Resources for platform device
|
||||
*/
|
||||
static resource _ehci[] =
|
||||
{
|
||||
{ EHCI_BASE, EHCI_BASE + 0x400 - 1, "ehci", IORESOURCE_MEM },
|
||||
{ IRQ_EHCI, IRQ_EHCI, "ehci-irq", IORESOURCE_IRQ },
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Port informations for platform device
|
||||
*/
|
||||
static struct ehci_hcd_omap_platform_data _ehci_data;
|
||||
|
||||
|
||||
/**
|
||||
* Enables USB clocks
|
||||
*/
|
||||
struct Clocks : Genode::Mmio
|
||||
{
|
||||
Clocks(Genode::addr_t const mmio_base) : Mmio(mmio_base)
|
||||
{
|
||||
write<Usb_phy_clk>(0x101);
|
||||
write<Usb_host_clk>(0x1008002);
|
||||
write<Usb_tll_clk>(0x1);
|
||||
}
|
||||
|
||||
struct Usb_host_clk : Register<0x358, 32> { };
|
||||
struct Usb_tll_clk : Register<0x368, 32> { };
|
||||
struct Usb_phy_clk : Register<0x3e0, 32> { };
|
||||
|
||||
template <typename T> void update(unsigned val)
|
||||
{
|
||||
typename T::access_t access = read<T>();
|
||||
access |= val;
|
||||
write<T>(access);
|
||||
};
|
||||
|
||||
void dump()
|
||||
{
|
||||
Usb_host_clk::access_t a1 = read<Usb_host_clk>();
|
||||
Usb_tll_clk::access_t a3 = read<Usb_tll_clk>();
|
||||
Usb_phy_clk::access_t a4 = read<Usb_phy_clk>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Panda board reference USB clock
|
||||
*/
|
||||
struct Aux3 : Genode::Mmio
|
||||
{
|
||||
Aux3(addr_t const mmio_base) : Mmio(mmio_base)
|
||||
{
|
||||
enable();
|
||||
}
|
||||
|
||||
/* the clock register */
|
||||
struct Aux3_clk : Register<0x31c, 32>
|
||||
{
|
||||
struct Src_select : Bitfield<1, 2> { };
|
||||
struct Div : Bitfield<16, 4> { enum { DIV_2 = 1 }; };
|
||||
struct Enable : Bitfield<8, 1> { enum { ON = 1 }; };
|
||||
};
|
||||
|
||||
/* clock source register */
|
||||
struct Aux_src : Register<0x110, 32, true> { };
|
||||
|
||||
void enable()
|
||||
{
|
||||
/* select system clock */
|
||||
write<Aux3_clk::Src_select>(0);
|
||||
|
||||
/* set to 19.2 Mhz */
|
||||
write<Aux3_clk::Div>(Aux3_clk::Div::DIV_2);
|
||||
|
||||
/* enable clock */
|
||||
write<Aux3_clk::Enable>(Aux3_clk::Enable::ON);
|
||||
|
||||
/* enable_ext = 1 | enable_int = 1| mode = 0x01 */
|
||||
write<Aux_src>(0xd);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* ULPI transceiverless link
|
||||
*/
|
||||
struct Tll : Genode::Mmio
|
||||
{
|
||||
Tll(addr_t const mmio_base) : Mmio(mmio_base)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
struct Sys_config : Register<0x10, 32>
|
||||
{
|
||||
struct Soft_reset : Bitfield<1, 1> { };
|
||||
struct Cactivity : Bitfield<8, 1> { };
|
||||
struct Sidle_mode : Bitfield<3, 2> { };
|
||||
struct Ena_wakeup : Bitfield<2, 1> { };
|
||||
};
|
||||
|
||||
struct Sys_status : Register<0x14, 32> { };
|
||||
|
||||
void reset()
|
||||
{
|
||||
write<Sys_config>(0x0);
|
||||
|
||||
/* reset */
|
||||
write<Sys_config::Soft_reset>(0x1);
|
||||
|
||||
while(!read<Sys_status>())
|
||||
msleep(1);
|
||||
|
||||
/* disable IDLE, enable wake up, enable auto gating */
|
||||
write<Sys_config::Cactivity>(1);
|
||||
write<Sys_config::Sidle_mode>(1);
|
||||
write<Sys_config::Ena_wakeup>(1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* USB high-speed host
|
||||
*/
|
||||
struct Uhh : Genode::Mmio
|
||||
{
|
||||
Uhh(addr_t const mmio_base) : Mmio(mmio_base)
|
||||
{
|
||||
/* diable idle and standby */
|
||||
write<Sys_config::Idle>(1);
|
||||
write<Sys_config::Standby>(1);
|
||||
|
||||
/* set ports to external phy */
|
||||
write<Host_config::P1_mode>(0);
|
||||
write<Host_config::P2_mode>(0);
|
||||
}
|
||||
|
||||
struct Sys_config : Register<0x10, 32>
|
||||
{
|
||||
struct Idle : Bitfield<2, 2> { };
|
||||
struct Standby : Bitfield<4, 2> { };
|
||||
};
|
||||
|
||||
struct Host_config : Register<0x40, 32>
|
||||
{
|
||||
struct P1_mode : Bitfield<16, 2> { };
|
||||
struct P2_mode : Bitfield<18, 2> { };
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EHCI controller
|
||||
*/
|
||||
struct Ehci : Genode::Mmio
|
||||
{
|
||||
Ehci(addr_t const mmio_base) : Mmio(mmio_base)
|
||||
{
|
||||
write<Cmd>(0);
|
||||
|
||||
/* reset */
|
||||
write<Cmd::Reset>(1);
|
||||
|
||||
while(read<Cmd::Reset>())
|
||||
msleep(1);
|
||||
}
|
||||
|
||||
struct Cmd : Register<0x10, 32>
|
||||
{
|
||||
struct Reset : Bitfield<1, 1> { };
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the USB controller from scratch, since the boot loader might not
|
||||
* do it or even disable USB.
|
||||
*/
|
||||
static void omap_ehci_init(Genode::Env &env)
|
||||
{
|
||||
/* taken from the Panda board manual */
|
||||
enum { HUB_POWER = 1, HUB_NRESET = 62, ULPI_PHY_TYPE = 182 };
|
||||
|
||||
/* SCRM */
|
||||
Io_mem_connection io_scrm(env, SCRM_BASE, 0x1000);
|
||||
addr_t scrm_base = (addr_t)env.rm().attach(io_scrm.dataspace());
|
||||
|
||||
/* enable reference clock */
|
||||
Aux3 aux3(scrm_base);
|
||||
|
||||
/* init GPIO */
|
||||
Gpio::Connection gpio_power(env, HUB_POWER);
|
||||
Gpio::Connection gpio_reset(env, HUB_NRESET);
|
||||
|
||||
/* disable the hub power and reset before init */
|
||||
gpio_power.direction(Gpio::Session::OUT);
|
||||
gpio_reset.direction(Gpio::Session::OUT);
|
||||
gpio_power.write(false);
|
||||
gpio_reset.write(true);
|
||||
|
||||
/* enable clocks */
|
||||
Io_mem_connection io_clock(env, CAM_BASE, 0x1000);
|
||||
addr_t clock_base = (addr_t)env.rm().attach(io_clock.dataspace());
|
||||
Clocks c(clock_base);
|
||||
|
||||
/* reset TLL */
|
||||
Io_mem_connection io_tll(env, TLL_BASE, 0x1000);
|
||||
addr_t tll_base = (addr_t)env.rm().attach(io_tll.dataspace());
|
||||
Tll t(tll_base);
|
||||
|
||||
/* reset host */
|
||||
Io_mem_connection io_uhh(env, UHH_BASE, 0x1000);
|
||||
addr_t uhh_base = (addr_t)env.rm().attach(io_uhh.dataspace());
|
||||
Uhh uhh(uhh_base);
|
||||
|
||||
/* enable hub power */
|
||||
gpio_power.write(true);
|
||||
|
||||
/* reset EHCI */
|
||||
addr_t ehci_base = uhh_base + 0xc00;
|
||||
Ehci ehci(ehci_base);
|
||||
|
||||
addr_t base[] = { scrm_base, clock_base, tll_base, uhh_base, 0 };
|
||||
for (int i = 0; base[i]; i++)
|
||||
env.rm().detach(base[i]);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void module_ehci_omap_init();
|
||||
extern "C" int module_usbnet_init();
|
||||
extern "C" int module_smsc95xx_driver_init();
|
||||
|
||||
void platform_hcd_init(Services *services)
|
||||
{
|
||||
/* register EHCI controller */
|
||||
module_ehci_omap_init();
|
||||
|
||||
/* initialize EHCI */
|
||||
omap_ehci_init(services->env);
|
||||
|
||||
/* setup EHCI-controller platform device */
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"ehci-omap";
|
||||
pdev->id = 0;
|
||||
pdev->num_resources = 2;
|
||||
pdev->resource = _ehci;
|
||||
|
||||
|
||||
_ehci_data.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY;
|
||||
_ehci_data.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED;
|
||||
_ehci_data.phy_reset = 0;
|
||||
pdev->dev.platform_data = &_ehci_data;
|
||||
|
||||
/*
|
||||
* Needed for DMA buffer allocation. See 'hcd_buffer_alloc' in 'buffer.c'
|
||||
*/
|
||||
static u64 dma_mask = ~(u64)0;
|
||||
pdev->dev.dma_mask = &dma_mask;
|
||||
pdev->dev.coherent_dma_mask = ~0;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
15
repos/dde_linux/src/drivers/usb_host/spec/panda/target.mk
Normal file
15
repos/dde_linux/src/drivers/usb_host/spec/panda/target.mk
Normal file
@ -0,0 +1,15 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/target.inc
|
||||
|
||||
TARGET = panda_usb_host_drv
|
||||
REQUIRES = panda
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/drivers/usb_host/spec/arm
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||
|
||||
SRC_CC += spec/arm/platform.cc
|
||||
SRC_CC += spec/panda/platform.cc
|
||||
SRC_C += usb/host/ehci-omap.c
|
||||
|
||||
CC_OPT += -DCONFIG_USB_EHCI_HCD_OMAP=1
|
||||
CC_OPT += -DCONFIG_USB_EHCI_TT_NEWSCHED=1
|
||||
CC_OPT += -DCONFIG_EXTCON=1
|
84
repos/dde_linux/src/drivers/usb_host/spec/rpi/platform.cc
Normal file
84
repos/dde_linux/src/drivers/usb_host/spec/rpi/platform.cc
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* \brief USB initialization for Raspberry Pi
|
||||
* \author Norman Feske
|
||||
* \date 2013-09-11
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <io_mem_session/connection.h>
|
||||
#include <util/mmio.h>
|
||||
#include <platform_session/connection.h>
|
||||
|
||||
|
||||
/* emulation */
|
||||
#include <platform.h>
|
||||
#include <lx_emul.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
/* dwc-otg */
|
||||
#define new new_
|
||||
#include <dwc_otg_dbg.h>
|
||||
#undef new
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
unsigned dwc_irq();
|
||||
|
||||
|
||||
/************************************************
|
||||
** Resource info passed to the dwc_otg driver **
|
||||
************************************************/
|
||||
|
||||
enum {
|
||||
DWC_BASE = 0x20980000,
|
||||
DWC_SIZE = 0x20000,
|
||||
};
|
||||
|
||||
|
||||
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 **
|
||||
*******************/
|
||||
|
||||
extern "C" void module_dwc_otg_driver_init();
|
||||
extern bool fiq_enable, fiq_fsm_enable;
|
||||
|
||||
void platform_hcd_init(Services *services)
|
||||
{
|
||||
/* enable USB power */
|
||||
Platform::Connection platform(services->env);
|
||||
platform.power_state(Platform::Session::POWER_USB_HCD, true);
|
||||
|
||||
/* disable fiq optimization */
|
||||
fiq_enable = false;
|
||||
fiq_fsm_enable = false;
|
||||
|
||||
module_dwc_otg_driver_init();
|
||||
|
||||
/* setup host-controller platform device */
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"dwc_otg";
|
||||
pdev->id = 0;
|
||||
pdev->num_resources = sizeof(_dwc_otg_resource)/sizeof(resource);
|
||||
pdev->resource = _dwc_otg_resource;
|
||||
|
||||
/* needed for DMA buffer allocation. See 'hcd_buffer_alloc' in 'buffer.c' */
|
||||
static u64 dma_mask = ~(u64)0;
|
||||
pdev->dev.dma_mask = &dma_mask;
|
||||
pdev->dev.coherent_dma_mask = ~0;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
49
repos/dde_linux/src/drivers/usb_host/spec/rpi/target.mk
Normal file
49
repos/dde_linux/src/drivers/usb_host/spec/rpi/target.mk
Normal file
@ -0,0 +1,49 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/target.inc
|
||||
|
||||
TARGET = rpi_usb_host_drv
|
||||
REQUIRES = rpi
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/drivers/usb_host/spec/arm
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||
|
||||
SRC_CC += spec/arm/platform.cc
|
||||
SRC_CC += spec/rpi/platform.cc
|
||||
|
||||
SRC_C += dwc_common_port/dwc_cc.c
|
||||
SRC_C += dwc_common_port/dwc_common_linux.c
|
||||
SRC_C += dwc_common_port/dwc_crypto.c
|
||||
SRC_C += dwc_common_port/dwc_dh.c
|
||||
SRC_C += dwc_common_port/dwc_mem.c
|
||||
SRC_C += dwc_common_port/dwc_modpow.c
|
||||
SRC_C += dwc_common_port/dwc_notifier.c
|
||||
SRC_C += dwc_otg/dwc_otg_adp.c
|
||||
SRC_C += dwc_otg/dwc_otg_attr.c
|
||||
SRC_C += dwc_otg/dwc_otg_cfi.c
|
||||
SRC_C += dwc_otg/dwc_otg_cil.c
|
||||
SRC_C += dwc_otg/dwc_otg_cil_intr.c
|
||||
SRC_C += dwc_otg/dwc_otg_driver.c
|
||||
SRC_C += dwc_otg/dwc_otg_hcd.c
|
||||
SRC_C += dwc_otg/dwc_otg_hcd_ddma.c
|
||||
SRC_C += dwc_otg/dwc_otg_hcd_intr.c
|
||||
SRC_C += dwc_otg/dwc_otg_hcd_linux.c
|
||||
SRC_C += dwc_otg/dwc_otg_hcd_queue.c
|
||||
|
||||
CC_OPT += -DDWC_LINUX -DPLATFORM_INTERFACE
|
||||
|
||||
# needed for 'ehci-hcd.c', which we don't use on the rpi, but it is still
|
||||
# part of the generic usb USB driver
|
||||
CC_OPT += -DCONFIG_USB_EHCI_PCI=1
|
||||
|
||||
# for 'dwc_otg_hcd_linux.c' for enabling the FIQ, which we don't use anyway
|
||||
CC_OPT += -DINTERRUPT_VC_USB=9
|
||||
|
||||
# for 'dwc_otg_driver.c' for preventing calls to set_irq_type
|
||||
CC_OPT += -DIRQF_TRIGGER_LOW=1
|
||||
|
||||
INC_DIR += $(LX_CONTRIB_DIR)/drivers/usb/host/dwc_common_port \
|
||||
$(LX_CONTRIB_DIR)/drivers/usb/host/dwc_otg \
|
||||
$(REP_DIR)/src/lib/usb_host/spec/arm
|
||||
|
||||
vpath %.c $(LX_CONTRIB_DIR)/drivers/usb/host
|
||||
|
||||
LIBS += rpi_usb
|
132
repos/dde_linux/src/drivers/usb_host/spec/wand_quad/platform.cc
Normal file
132
repos/dde_linux/src/drivers/usb_host/spec/wand_quad/platform.cc
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* \brief EHCI for Freescale i.MX6
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2018-04-11
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#include <platform.h>
|
||||
#include <lx_emul.h>
|
||||
|
||||
extern "C" int module_ci_hdrc_platform_register();
|
||||
extern "C" int module_ci_hdrc_imx_driver_init();
|
||||
extern "C" int module_usbmisc_imx_driver_init();
|
||||
extern "C" int postcore_mxs_phy_module_init();
|
||||
|
||||
extern "C" void module_ehci_hcd_init();
|
||||
extern "C" void module_xhci_hcd_init();
|
||||
|
||||
void platform_hcd_init(Services *services)
|
||||
{
|
||||
module_ehci_hcd_init();
|
||||
module_ci_hdrc_platform_register();
|
||||
postcore_mxs_phy_module_init();
|
||||
module_usbmisc_imx_driver_init();
|
||||
module_ci_hdrc_imx_driver_init();
|
||||
|
||||
/* USB PHY initialization */
|
||||
{
|
||||
static resource usbphy_res[] =
|
||||
{
|
||||
{ 0x020ca000, 0x020cafff, "usbphy", IORESOURCE_MEM },
|
||||
{ 77, 77, "usbphy-irq", IORESOURCE_IRQ },
|
||||
};
|
||||
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"mxs_phy";
|
||||
pdev->id = 0;
|
||||
pdev->num_resources = 2;
|
||||
pdev->resource = usbphy_res;
|
||||
|
||||
pdev->dev.of_node = (device_node*)kzalloc(sizeof(device_node), 0);
|
||||
pdev->dev.of_node->properties = (property*)kzalloc(sizeof(property), 0);
|
||||
pdev->dev.of_node->properties->name = "compatible";
|
||||
pdev->dev.of_node->properties->value = (void*)"fsl,imx6q-usbphy";
|
||||
pdev->dev.of_node->properties->next = (property*)kzalloc(sizeof(property), 0);
|
||||
pdev->dev.of_node->properties->next->name = "fsl,anatop";
|
||||
pdev->dev.of_node->properties->next->value = (void*)0xdeaddead;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
||||
|
||||
device_node * usbmisc_of_node = nullptr;
|
||||
|
||||
/* USB MISC initialization */
|
||||
{
|
||||
static resource usbmisc_res[] = { { 0x02184800, 0x021849ff, "usbmisc", IORESOURCE_MEM }, };
|
||||
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"usbmisc_imx";
|
||||
pdev->id = 1;
|
||||
pdev->num_resources = 1;
|
||||
pdev->resource = usbmisc_res;
|
||||
|
||||
pdev->dev.of_node = (device_node*)kzalloc(sizeof(device_node), 0);
|
||||
pdev->dev.of_node->properties = (property*)kzalloc(sizeof(property), 0);
|
||||
pdev->dev.of_node->properties->name = "compatible";
|
||||
pdev->dev.of_node->properties->value = (void*)"fsl,imx6q-usbmisc";
|
||||
pdev->dev.of_node->dev = &pdev->dev;
|
||||
usbmisc_of_node = pdev->dev.of_node;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
||||
|
||||
/* setup EHCI-controller platform device */
|
||||
{
|
||||
static resource ehci_res[] =
|
||||
{
|
||||
{ 0x02184200, 0x021843ff, "imx_usb", IORESOURCE_MEM },
|
||||
{ 72, 72, "imx_usb-irq", IORESOURCE_IRQ },
|
||||
};
|
||||
|
||||
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
|
||||
pdev->name = (char *)"imx_usb";
|
||||
pdev->id = 2;
|
||||
pdev->num_resources = 2;
|
||||
pdev->resource = ehci_res;
|
||||
|
||||
pdev->dev.of_node = (device_node*)kzalloc(sizeof(device_node), 0);
|
||||
pdev->dev.of_node->properties = (property*)kzalloc(sizeof(property), 0);
|
||||
pdev->dev.of_node->properties->name = "compatible";
|
||||
pdev->dev.of_node->properties->value = (void*)"fsl,imx6q-usb";
|
||||
pdev->dev.of_node->properties->next = (property*)kzalloc(sizeof(property), 0);
|
||||
pdev->dev.of_node->properties->next->name = "fsl,usbmisc";
|
||||
pdev->dev.of_node->properties->next->value = (void*)usbmisc_of_node;
|
||||
pdev->dev.of_node->properties->next->next = (property*)kzalloc(sizeof(property), 0);
|
||||
pdev->dev.of_node->properties->next->next->name = "dr_mode";
|
||||
pdev->dev.of_node->properties->next->next->value = (void*)"host";
|
||||
|
||||
/*
|
||||
* Needed for DMA buffer allocation. See 'hcd_buffer_alloc' in 'buffer.c'
|
||||
*/
|
||||
static u64 dma_mask = ~(u64)0;
|
||||
pdev->dev.dma_mask = &dma_mask;
|
||||
pdev->dev.coherent_dma_mask = ~0;
|
||||
|
||||
platform_device_register(pdev);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int devm_extcon_register_notifier(struct device *dev, struct extcon_dev *edev, unsigned int id, struct notifier_block *nb)
|
||||
{
|
||||
BUG();
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
|
||||
{
|
||||
BUG();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" int extcon_get_state(struct extcon_dev *edev, unsigned int id)
|
||||
{
|
||||
BUG();
|
||||
return -1;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/target.inc
|
||||
|
||||
TARGET = wand_quad_usb_host_drv
|
||||
REQUIRES = wand_quad
|
||||
|
||||
SRC_C += usb/chipidea/ci_hdrc_imx.c
|
||||
SRC_C += usb/chipidea/core.c
|
||||
SRC_C += usb/chipidea/host.c
|
||||
SRC_C += usb/chipidea/otg.c
|
||||
SRC_C += usb/chipidea/usbmisc_imx.c
|
||||
SRC_C += usb/phy/phy-mxs-usb.c
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/drivers/usb_host/spec/arm
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/arm
|
||||
|
||||
SRC_CC += spec/arm/platform.cc
|
||||
SRC_CC += spec/wand_quad/platform.cc
|
||||
|
||||
CC_OPT += -DCONFIG_USB_CHIPIDEA
|
||||
CC_OPT += -DCONFIG_USB_CHIPIDEA_HOST
|
||||
CC_OPT += -DCONFIG_USB_EHCI_HCD
|
||||
CC_OPT += -DCONFIG_USB_EHCI_ROOT_HUB_TT
|
||||
CC_OPT += -DCONFIG_USB_MXS_PHY
|
||||
CC_OPT += -DCONFIG_USB_EHCI_TT_NEWSCHED=1
|
||||
CC_OPT += -DCONFIG_EXTCON=1
|
||||
|
||||
CC_C_OPT += -Wno-incompatible-pointer-types
|
223
repos/dde_linux/src/drivers/usb_host/spec/x86/platform.cc
Normal file
223
repos/dde_linux/src/drivers/usb_host/spec/x86/platform.cc
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* \brief PCI device handling
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2016-04-25
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/allocator.h>
|
||||
#include <base/entrypoint.h>
|
||||
#include <base/lock.h>
|
||||
#include <base/signal.h>
|
||||
#include <util/misc_math.h>
|
||||
|
||||
#include <lx_emul.h>
|
||||
#include <platform.h>
|
||||
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/irq.h>
|
||||
#include <lx_kit/pci_dev_registry.h>
|
||||
#include <lx_kit/malloc.h>
|
||||
#include <lx_kit/mapped_io_mem_range.h>
|
||||
|
||||
#include <lx_emul/impl/io.h>
|
||||
#include <lx_emul/impl/pci_resource.h>
|
||||
|
||||
|
||||
/**
|
||||
* Quirks
|
||||
*/
|
||||
extern "C" void __pci_fixup_quirk_usb_early_handoff(void *data);
|
||||
|
||||
|
||||
/**
|
||||
* List of pci devices from platform driver
|
||||
*/
|
||||
class Pci_dev_list
|
||||
{
|
||||
private:
|
||||
|
||||
struct Element : public Lx_kit::List<Element>::Element
|
||||
{
|
||||
Platform::Device_capability cap;
|
||||
|
||||
Element(Platform::Device_capability cap) : cap(cap) { }
|
||||
};
|
||||
|
||||
Lx_kit::List<Element> _pci_caps;
|
||||
|
||||
public:
|
||||
|
||||
Pci_dev_list()
|
||||
{
|
||||
/*
|
||||
* Obtain first device, the operation may exceed the session quota.
|
||||
* So we use the 'with_upgrade' mechanism.
|
||||
*/
|
||||
Platform::Device_capability cap =
|
||||
Lx::pci()->with_upgrade([&] () {
|
||||
return Lx::pci()->first_device(); });
|
||||
|
||||
/*
|
||||
* Iterate over the devices of the platform session.
|
||||
*/
|
||||
while (cap.valid()) {
|
||||
|
||||
_pci_caps.insert(new (Lx::Malloc::mem()) Element(cap));
|
||||
|
||||
/* try next one. Upgrade session quota on demand.*/
|
||||
Lx::pci()->with_upgrade([&] () {
|
||||
cap = Lx::pci()->next_device(cap); });
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FUNC>
|
||||
void for_each_pci_device(FUNC const &func)
|
||||
{
|
||||
for (Element *e = _pci_caps.first(); e; e = e->next())
|
||||
func(e->cap);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Pci_dev_list *pci_dev_list()
|
||||
{
|
||||
static Pci_dev_list _list;
|
||||
return &_list;
|
||||
}
|
||||
|
||||
|
||||
extern "C" int pci_register_driver(struct pci_driver *driver)
|
||||
{
|
||||
driver->driver.name = driver->name;
|
||||
|
||||
pci_device_id const *id_table = driver->id_table;
|
||||
if (!id_table)
|
||||
return -ENODEV;
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
bool found = false;
|
||||
|
||||
auto lamda = [&] (Platform::Device_capability cap) {
|
||||
|
||||
Platform::Device_client client(cap);
|
||||
|
||||
/* request device ID from platform driver */
|
||||
unsigned const class_code = client.class_code();
|
||||
|
||||
/* look if we find the device ID in the driver's 'id_table' */
|
||||
pci_device_id const *matching_id = nullptr;
|
||||
for (pci_device_id const *id = id_table; id->device; id++) {
|
||||
|
||||
lx_log(DEBUG_PCI,"idclass: %x idclassm: %x devclass %x", id->class_,
|
||||
id->class_mask, class_code);
|
||||
|
||||
/* check for drivers that support any device for a given class */
|
||||
if (id->device != (unsigned)PCI_ANY_ID || !id->class_mask)
|
||||
continue;
|
||||
|
||||
if ((id->class_ & id->class_mask) == (class_code & id->class_mask)) {
|
||||
matching_id = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* skip device that is not handled by driver */
|
||||
if (!matching_id)
|
||||
return false;
|
||||
|
||||
/* create 'pci_dev' struct for matching device */
|
||||
Lx::Pci_dev *pci_dev = new (Lx::Malloc::mem()) Lx::Pci_dev(cap);
|
||||
|
||||
/* enable ioremap to work */
|
||||
Lx::pci_dev_registry()->insert(pci_dev);
|
||||
|
||||
/* register driver at the 'pci_dev' struct */
|
||||
pci_dev->dev.driver = &driver->driver;
|
||||
|
||||
/*
|
||||
* This quirk handles device handoff from BIOS, since the BIOS may still
|
||||
* access the USB controller after bootup. For this the ext cap register of
|
||||
* the PCI config space is checked
|
||||
*/
|
||||
if (Lx_kit::env().config_rom().xml().attribute_value("bios_handoff", true))
|
||||
__pci_fixup_quirk_usb_early_handoff(pci_dev);
|
||||
|
||||
/* call probe function of the Linux driver */
|
||||
if (driver->probe(pci_dev, matching_id)) {
|
||||
|
||||
/* if the probing failed, revert the creation of 'pci_dev' */
|
||||
pci_dev_put(pci_dev);
|
||||
return false;
|
||||
}
|
||||
|
||||
found = true;
|
||||
|
||||
/* multiple device support continue */
|
||||
return true;
|
||||
};
|
||||
|
||||
pci_dev_list()->for_each_pci_device(lamda);
|
||||
|
||||
return found ? 0 : -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
/***********************
|
||||
** linux/interrupt.h **
|
||||
***********************/
|
||||
|
||||
int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
|
||||
const char *name, void *dev)
|
||||
{
|
||||
for (Lx::Pci_dev *pci_dev = Lx::pci_dev_registry()->first(); pci_dev; pci_dev = pci_dev->next())
|
||||
if (pci_dev->irq == irq) {
|
||||
Lx::Irq::irq().request_irq(pci_dev->client(), handler, dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
/*********************************
|
||||
** Platform backend alloc init **
|
||||
*********************************/
|
||||
|
||||
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram,
|
||||
Genode::Allocator &alloc)
|
||||
{
|
||||
Lx::pci_init(env, ram, alloc);
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
||||
void platform_hcd_init(Services *s)
|
||||
{
|
||||
module_xhci_hcd_init();
|
||||
module_xhci_pci_init();
|
||||
|
||||
/* ehci_hcd should always be loaded before uhci_hcd and ohci_hcd, not after */
|
||||
module_ehci_hcd_init();
|
||||
module_ehci_pci_init();
|
||||
|
||||
module_ohci_hcd_mod_init();
|
||||
module_ohci_pci_init();
|
||||
|
||||
module_uhci_hcd_init();
|
||||
}
|
24
repos/dde_linux/src/drivers/usb_host/spec/x86/target.inc
Normal file
24
repos/dde_linux/src/drivers/usb_host/spec/x86/target.inc
Normal file
@ -0,0 +1,24 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/target.inc
|
||||
|
||||
TARGET = x86_pc_usb_host_drv
|
||||
|
||||
INC_DIR += $(REP_DIR)/src_drivers/usb_host/spec/x86
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/x86
|
||||
|
||||
SRC_C += usb/core/hcd-pci.c
|
||||
SRC_C += usb/host/ehci-pci.c
|
||||
SRC_C += usb/host/ohci-hcd.c
|
||||
SRC_C += usb/host/ohci-pci.c
|
||||
SRC_C += usb/host/pci-quirks.c
|
||||
SRC_C += usb/host/uhci-hcd.c
|
||||
SRC_C += usb/host/xhci-pci.c
|
||||
|
||||
SRC_CC += lx_kit/mapped_io_mem_range.cc
|
||||
SRC_CC += lx_kit/pci.cc
|
||||
|
||||
SRC_CC += spec/x86/platform.cc
|
||||
|
||||
CC_OPT += -DCONFIG_PCI=1
|
||||
CC_OPT += -DCONFIG_USB_PCI=1
|
||||
CC_OPT += -DCONFIG_USB_EHCI_PCI=1
|
||||
CC_OPT += -DCONFIG_USB_XHCI_HCD=1
|
@ -0,0 +1,4 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/spec/x86/target.inc
|
||||
|
||||
REQUIRES = x86_32
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/x86_32
|
@ -0,0 +1,4 @@
|
||||
include $(REP_DIR)/src/drivers/usb_host/spec/x86/target.inc
|
||||
|
||||
REQUIRES = x86_64
|
||||
INC_DIR += $(REP_DIR)/src/include/spec/x86_64
|
66
repos/dde_linux/src/drivers/usb_host/target.inc
Normal file
66
repos/dde_linux/src/drivers/usb_host/target.inc
Normal file
@ -0,0 +1,66 @@
|
||||
LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_host
|
||||
SRC_CC = main.cc lx_emul.cc raw.cc
|
||||
SRC_C = dummies.c raw_driver.c
|
||||
LIBS = base usb_host_include lx_kit_setjmp
|
||||
CC_CXX_WARN_STRICT =
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/drivers/usb_host
|
||||
INC_DIR += $(REP_DIR)/src/include
|
||||
|
||||
# lx_kit
|
||||
SRC_CC += lx_kit/printf.cc
|
||||
SRC_CC += lx_kit/work.cc
|
||||
SRC_CC += lx_kit/timer.cc
|
||||
SRC_CC += lx_kit/scheduler.cc
|
||||
SRC_CC += lx_kit/irq.cc
|
||||
SRC_CC += lx_kit/malloc.cc
|
||||
SRC_CC += lx_kit/env.cc
|
||||
|
||||
# contrib code
|
||||
SRC_C += usb/common/common.c
|
||||
SRC_C += usb/core/buffer.c
|
||||
SRC_C += usb/core/config.c
|
||||
SRC_C += usb/core/devices.c
|
||||
SRC_C += usb/core/driver.c
|
||||
SRC_C += usb/core/endpoint.c
|
||||
SRC_C += usb/core/file.c
|
||||
SRC_C += usb/core/generic.c
|
||||
SRC_C += usb/core/hcd.c
|
||||
SRC_C += usb/core/hub.c
|
||||
SRC_C += usb/core/message.c
|
||||
SRC_C += usb/core/notify.c
|
||||
SRC_C += usb/core/port.c
|
||||
SRC_C += usb/core/quirks.c
|
||||
SRC_C += usb/core/urb.c
|
||||
SRC_C += usb/core/usb.c
|
||||
SRC_C += usb/host/ehci-hcd.c
|
||||
SRC_C += usb/host/xhci-dbg.c
|
||||
SRC_C += usb/host/xhci-hub.c
|
||||
SRC_C += usb/host/xhci-mem.c
|
||||
SRC_C += usb/host/xhci-ring.c
|
||||
SRC_C += usb/host/xhci.c
|
||||
SRC_C += lib/ctype.c
|
||||
SRC_C += lib/find_bit.c
|
||||
|
||||
CC_OPT += -U__linux__
|
||||
CC_OPT += -D__KERNEL__
|
||||
CC_OPT += -DCONFIG_USB_DEVICEFS=1
|
||||
CC_OPT += -DCONFIG_HOTPLUG=1
|
||||
CC_OPT += -DCONFIG_USB_PHY=1
|
||||
CC_OPT += -DCONFIG_HAS_DMA=1
|
||||
CC_C_OPT += -std=gnu89
|
||||
CC_C_OPT += -Wno-pointer-sign
|
||||
CC_C_OPT += -Wno-unused-variable
|
||||
CC_C_OPT += -Wno-unused-function
|
||||
CC_C_OPT += -Wno-implicit-int
|
||||
CC_C_OPT += -Wno-unused-but-set-variable
|
||||
CC_C_OPT += -Wno-uninitialized
|
||||
CC_C_OPT += -Wno-maybe-uninitialized
|
||||
CC_C_OPT += -Wno-unused-label
|
||||
CC_C_OPT += -Wno-format
|
||||
|
||||
vpath lib/ctype.c $(LX_CONTRIB_DIR)
|
||||
vpath lib/find_bit.c $(LX_CONTRIB_DIR)
|
||||
vpath %.c $(LX_CONTRIB_DIR)/drivers
|
||||
vpath %.cc $(REP_DIR)/src
|
||||
vpath % $(REP_DIR)/src/drivers/usb_host
|
135
repos/dde_linux/usb_host.list
Normal file
135
repos/dde_linux/usb_host.list
Normal file
@ -0,0 +1,135 @@
|
||||
linux-x.x.x/drivers/usb/chipidea/bits.h
|
||||
linux-x.x.x/drivers/usb/chipidea/ci.h
|
||||
linux-x.x.x/drivers/usb/chipidea/ci_hdrc_imx.c
|
||||
linux-x.x.x/drivers/usb/chipidea/ci_hdrc_imx.h
|
||||
linux-x.x.x/drivers/usb/chipidea/ci_hdrc_msm.c
|
||||
linux-x.x.x/drivers/usb/chipidea/ci_hdrc_usb2.c
|
||||
linux-x.x.x/drivers/usb/chipidea/ci_hdrc_zevio.c
|
||||
linux-x.x.x/drivers/usb/chipidea/core.c
|
||||
linux-x.x.x/drivers/usb/chipidea/host.c
|
||||
linux-x.x.x/drivers/usb/chipidea/host.h
|
||||
linux-x.x.x/drivers/usb/chipidea/otg.c
|
||||
linux-x.x.x/drivers/usb/chipidea/otg.h
|
||||
linux-x.x.x/drivers/usb/chipidea/otg_fsm.h
|
||||
linux-x.x.x/drivers/usb/chipidea/udc.h
|
||||
linux-x.x.x/drivers/usb/chipidea/usbmisc_imx.c
|
||||
linux-x.x.x/drivers/usb/common/common.c
|
||||
linux-x.x.x/drivers/usb/core/buffer.c
|
||||
linux-x.x.x/drivers/usb/core/config.c
|
||||
linux-x.x.x/drivers/usb/core/devices.c
|
||||
linux-x.x.x/drivers/usb/core/driver.c
|
||||
linux-x.x.x/drivers/usb/core/endpoint.c
|
||||
linux-x.x.x/drivers/usb/core/file.c
|
||||
linux-x.x.x/drivers/usb/core/generic.c
|
||||
linux-x.x.x/drivers/usb/core/hcd.c
|
||||
linux-x.x.x/drivers/usb/core/hcd-pci.c
|
||||
linux-x.x.x/drivers/usb/core/hub.h
|
||||
linux-x.x.x/drivers/usb/core/hub.c
|
||||
linux-x.x.x/drivers/usb/core/message.c
|
||||
linux-x.x.x/drivers/usb/core/otg_whitelist.h
|
||||
linux-x.x.x/drivers/usb/core/notify.c
|
||||
linux-x.x.x/drivers/usb/core/port.c
|
||||
linux-x.x.x/drivers/usb/core/quirks.c
|
||||
linux-x.x.x/drivers/usb/core/urb.c
|
||||
linux-x.x.x/drivers/usb/core/usb.h
|
||||
linux-x.x.x/drivers/usb/core/usb.c
|
||||
linux-x.x.x/drivers/usb/dwc3/core.c
|
||||
linux-x.x.x/drivers/usb/dwc3/core.h
|
||||
linux-x.x.x/drivers/usb/dwc3/debug.h
|
||||
linux-x.x.x/drivers/usb/dwc3/dwc3-exynos.c
|
||||
linux-x.x.x/drivers/usb/dwc3/gadget.h
|
||||
linux-x.x.x/drivers/usb/dwc3/host.c
|
||||
linux-x.x.x/drivers/usb/dwc3/io.h
|
||||
linux-x.x.x/drivers/usb/dwc3/trace.h
|
||||
linux-x.x.x/drivers/usb/host/ehci-dbg.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-exynos.c
|
||||
linux-x.x.x/drivers/usb/host/ehci.h
|
||||
linux-x.x.x/drivers/usb/host/ehci-hcd.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-hub.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-mem.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-omap.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-pci.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-q.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-sched.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-sysfs.c
|
||||
linux-x.x.x/drivers/usb/host/ehci-timer.c
|
||||
linux-x.x.x/drivers/usb/host/ohci-hcd.c
|
||||
linux-x.x.x/drivers/usb/host/ohci.h
|
||||
linux-x.x.x/drivers/usb/host/ohci-hub.c
|
||||
linux-x.x.x/drivers/usb/host/ohci-dbg.c
|
||||
linux-x.x.x/drivers/usb/host/ohci-mem.c
|
||||
linux-x.x.x/drivers/usb/host/ohci-q.c
|
||||
linux-x.x.x/drivers/usb/host/ohci-pci.c
|
||||
linux-x.x.x/drivers/usb/host/pci-quirks.h
|
||||
linux-x.x.x/drivers/usb/host/pci-quirks.c
|
||||
linux-x.x.x/drivers/usb/host/uhci-debug.c
|
||||
linux-x.x.x/drivers/usb/host/uhci-hcd.h
|
||||
linux-x.x.x/drivers/usb/host/uhci-hcd.c
|
||||
linux-x.x.x/drivers/usb/host/uhci-hub.c
|
||||
linux-x.x.x/drivers/usb/host/uhci-pci.c
|
||||
linux-x.x.x/drivers/usb/host/uhci-q.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-dbg.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-dbgcap.h
|
||||
linux-x.x.x/drivers/usb/host/xhci-debugfs.h
|
||||
linux-x.x.x/drivers/usb/host/xhci-ext-caps.h
|
||||
linux-x.x.x/drivers/usb/host/xhci.h
|
||||
linux-x.x.x/drivers/usb/host/xhci-hub.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-mem.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-mtk.h
|
||||
linux-x.x.x/drivers/usb/host/xhci-mvebu.h
|
||||
linux-x.x.x/drivers/usb/host/xhci-rcar.h
|
||||
linux-x.x.x/drivers/usb/host/xhci.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-pci.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-plat.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-plat.h
|
||||
linux-x.x.x/drivers/usb/host/xhci-ring.c
|
||||
linux-x.x.x/drivers/usb/host/xhci-trace.h
|
||||
linux-x.x.x/drivers/usb/phy/phy-mxs-usb.c
|
||||
linux-x.x.x/include/asm-generic/atomic64.h
|
||||
linux-x.x.x/include/asm-generic/bitops/__ffs.h
|
||||
linux-x.x.x/include/asm-generic/bitops/__fls.h
|
||||
linux-x.x.x/include/asm-generic/bitops/fls64.h
|
||||
linux-x.x.x/include/asm-generic/bitops/non-atomic.h
|
||||
linux-x.x.x/include/asm-generic/ioctl.h
|
||||
linux-x.x.x/include/linux/ctype.h
|
||||
linux-x.x.x/include/linux/extcon.h
|
||||
linux-x.x.x/include/linux/hiddev.h
|
||||
linux-x.x.x/include/linux/hid.h
|
||||
linux-x.x.x/include/linux/input.h
|
||||
linux-x.x.x/include/linux/input/mt.h
|
||||
linux-x.x.x/include/linux/kfifo.h
|
||||
linux-x.x.x/include/linux/list.h
|
||||
linux-x.x.x/include/linux/log2.h
|
||||
linux-x.x.x/include/linux/mod_devicetable.h
|
||||
linux-x.x.x/include/linux/netdev_features.h
|
||||
linux-x.x.x/include/linux/pci_ids.h
|
||||
linux-x.x.x/include/linux/platform_data/usb-omap.h
|
||||
linux-x.x.x/include/linux/power_supply.h
|
||||
linux-x.x.x/include/linux/rbtree.h
|
||||
linux-x.x.x/include/linux/refcount.h
|
||||
linux-x.x.x/include/linux/swab.h
|
||||
linux-x.x.x/include/linux/usb.h
|
||||
linux-x.x.x/include/linux/usb_usual.h
|
||||
linux-x.x.x/include/linux/usb/ch9.h
|
||||
linux-x.x.x/include/linux/usb/chipidea.h
|
||||
linux-x.x.x/include/linux/usb/cdc.h
|
||||
linux-x.x.x/include/linux/usb/ehci-dbgp.h
|
||||
linux-x.x.x/include/linux/usb/ehci_def.h
|
||||
linux-x.x.x/include/linux/usb/hcd.h
|
||||
linux-x.x.x/include/linux/io-64-nonatomic-lo-hi.h
|
||||
linux-x.x.x/include/linux/usb/of.h
|
||||
linux-x.x.x/include/linux/usb/otg.h
|
||||
linux-x.x.x/include/linux/usb/otg-fsm.h
|
||||
linux-x.x.x/include/linux/usb/phy.h
|
||||
linux-x.x.x/include/linux/usb/quirks.h
|
||||
linux-x.x.x/include/uapi/asm-generic/ioctl.h
|
||||
linux-x.x.x/include/uapi/linux/byteorder/little_endian.h
|
||||
linux-x.x.x/include/uapi/linux/pci_regs.h
|
||||
linux-x.x.x/include/uapi/linux/stat.h
|
||||
linux-x.x.x/include/uapi/linux/swab.h
|
||||
linux-x.x.x/include/uapi/linux/usb/ch11.h
|
||||
linux-x.x.x/include/uapi/linux/usb/ch9.h
|
||||
linux-x.x.x/include/uapi/linux/usb/charger.h
|
||||
linux-x.x.x/include/uapi/linux/usb/cdc.h
|
||||
linux-x.x.x/lib/ctype.c
|
||||
linux-x.x.x/lib/find_bit.c
|
@ -7,7 +7,7 @@ set use_qemu [have_include "power_on/qemu"]
|
||||
set build_components {
|
||||
core init
|
||||
drivers/timer
|
||||
drivers/usb
|
||||
drivers/usb_host
|
||||
drivers/usb_block
|
||||
server/report_rom
|
||||
test/blk/cli
|
||||
@ -70,33 +70,33 @@ append config {
|
||||
<default-policy report="usb_drv -> devices"/>
|
||||
</config>
|
||||
</start>
|
||||
<start name="usb_drv" caps="120">
|
||||
<resource name="RAM" quantum="16M"/>
|
||||
<start name="usb_drv" caps="120"> }
|
||||
append config "<binary name=\"[usb_host_drv_binary]\"/>"
|
||||
append config {
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<provides> <service name="Usb"/> </provides>
|
||||
<config uhci="yes" ehci="yes" xhci="yes">
|
||||
<raw>
|
||||
<report devices="no"/>}
|
||||
<config>
|
||||
<report devices="no"/>}
|
||||
append_if [expr !$use_qemu] config {
|
||||
<!--
|
||||
The order is important because only the first policy is
|
||||
picked up - an entry may be moved to the front to test the
|
||||
corresponding device.
|
||||
-->
|
||||
<!-- zte open c needs interface="3" -->
|
||||
<default-policy vendor_id="0x19d2" product_id="0x1350"/>
|
||||
<!-- kingston -->
|
||||
<default-policy vendor_id="0x0951" product_id="0x1666"/>
|
||||
<!-- voyager gt stick -->
|
||||
<default-policy vendor_id="0x1b1c" product_id="0x1a09"/>
|
||||
<!-- usb3 hdd adapter -->
|
||||
<default-policy vendor_id="0x174c" product_id="0x5106"/>
|
||||
<!-- lenovo disc -->
|
||||
<default-policy vendor_id="0x0984" product_id="0x0066"/>
|
||||
<!--
|
||||
The order is important because only the first policy is
|
||||
picked up - an entry may be moved to the front to test the
|
||||
corresponding device.
|
||||
-->
|
||||
<!-- zte open c needs interface="3" -->
|
||||
<default-policy vendor_id="0x19d2" product_id="0x1350"/>
|
||||
<!-- kingston -->
|
||||
<default-policy vendor_id="0x0951" product_id="0x1666"/>
|
||||
<!-- voyager gt stick -->
|
||||
<default-policy vendor_id="0x1b1c" product_id="0x1a09"/>
|
||||
<!-- usb3 hdd adapter -->
|
||||
<default-policy vendor_id="0x174c" product_id="0x5106"/>
|
||||
<!-- lenovo disc -->
|
||||
<default-policy vendor_id="0x0984" product_id="0x0066"/>
|
||||
}
|
||||
append_if $use_qemu config {
|
||||
<default-policy bus="0x001" dev="0x002"/> }
|
||||
<default-policy bus="0x001" dev="0x002"/> }
|
||||
append config {
|
||||
</raw>
|
||||
</config>
|
||||
<route>
|
||||
<service name="Report"> <child name="report_rom"/> </service>
|
||||
@ -137,11 +137,12 @@ install_config $config
|
||||
|
||||
# generic modules
|
||||
set boot_modules {
|
||||
core init timer report_rom usb_drv usb_block_drv
|
||||
core init timer report_rom usb_block_drv
|
||||
test-blk-cli test-blk-bench
|
||||
ld.lib.so
|
||||
}
|
||||
|
||||
append boot_modules [usb_host_drv_binary]
|
||||
lappend_if [have_spec gpio] boot_modules [gpio_drv]
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
Loading…
Reference in New Issue
Block a user