Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset f3378ba in mainline


Ignore:
Timestamp:
2012-04-08T05:53:34Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
3b5c119, 81716eb, 90924df, e3a050c7
Parents:
41455a22 (diff), 5b7ba8d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

USB HC: Minor fixes, cleanup, and refactoring.

Tested on qemu,vbox, n10/ich7.

Location:
uspace/drv/bus/usb
Files:
1 added
1 deleted
7 edited
5 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/Makefile

    r41455a22 rf3378ba  
    4343SOURCES = \
    4444        main.c \
    45         pci.c
     45        res.c
    4646
    4747include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/bus/usb/ehci/main.c

    r41455a22 rf3378ba  
    4444#include <usb/host/hcd.h>
    4545
    46 #include "pci.h"
     46#include "res.h"
    4747
    4848#define NAME "ehci"
     
    8181        int irq = 0;
    8282
    83         int ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
     83        int ret = get_my_registers(device, &reg_base, &reg_size, &irq);
    8484        CHECK_RET_RETURN(ret,
    8585            "Failed to get memory addresses for %" PRIun ": %s.\n",
     
    8888            reg_base, reg_size, irq);
    8989
    90         ret = pci_disable_legacy(device, reg_base, reg_size, irq);
     90        ret = disable_legacy(device, reg_base, reg_size);
    9191        CHECK_RET_RETURN(ret,
    9292            "Failed to disable legacy USB: %s.\n", str_error(ret));
  • uspace/drv/bus/usb/ehci/res.h

    r41455a22 rf3378ba  
    3838#include <ddf/driver.h>
    3939
    40 int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
    41 int pci_enable_interrupts(const ddf_dev_t *);
    42 int pci_disable_legacy(const ddf_dev_t *, uintptr_t, size_t, int);
     40int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
     41int enable_interrupts(const ddf_dev_t *);
     42int disable_legacy(const ddf_dev_t *, uintptr_t, size_t);
    4343
    4444#endif
  • uspace/drv/bus/usb/ohci/Makefile

    r41455a22 rf3378ba  
    5050        ohci_batch.c \
    5151        ohci_endpoint.c \
    52         pci.c \
     52        res.c \
    5353        root_hub.c \
    5454        hw_struct/endpoint_descriptor.c \
  • uspace/drv/bus/usb/ohci/hw_struct/hcca.h

    r41455a22 rf3378ba  
    4646        uint16_t pad1;
    4747        uint32_t done_head;
    48         uint32_t reserved[29];
    49 } __attribute__((packed, aligned)) hcca_t;
     48        uint32_t reserved[30];
     49} hcca_t;
    5050
    5151static inline void * hcca_get(void)
  • uspace/drv/bus/usb/ohci/ohci.c

    r41455a22 rf3378ba  
    4242
    4343#include "ohci.h"
    44 #include "pci.h"
     44#include "res.h"
    4545#include "hc.h"
    4646
     
    180180        int irq = 0;
    181181
    182         ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
     182        ret = get_my_registers(device, &reg_base, &reg_size, &irq);
    183183        CHECK_RET_DEST_FREE_RETURN(ret,
    184184            "Failed to get register memory addresses for %" PRIun ": %s.\n",
     
    211211        /* Try to enable interrupts */
    212212        bool interrupts = false;
    213         ret = pci_enable_interrupts(device);
     213        ret = enable_interrupts(device);
    214214        if (ret != EOK) {
    215215                usb_log_warning("Failed to enable interrupts: %s."
  • uspace/drv/bus/usb/ohci/res.c

    r41455a22 rf3378ba  
    3838#include <errno.h>
    3939#include <assert.h>
    40 #include <as.h>
    4140#include <devman.h>
    42 #include <ddi.h>
    43 #include <libarch/ddi.h>
    4441#include <device/hw_res_parsed.h>
    4542
    4643#include <usb/debug.h>
    47 #include <pci_dev_iface.h>
    4844
    49 #include "pci.h"
     45#include "res.h"
    5046
    5147/** Get address of registers and IRQ for given device.
     
    5753 * @return Error code.
    5854 */
    59 int pci_get_my_registers(ddf_dev_t *dev,
     55int get_my_registers(const ddf_dev_t *dev,
    6056    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
    6157{
     
    9894 * @return Error code.
    9995 */
    100 int pci_enable_interrupts(ddf_dev_t *device)
     96int enable_interrupts(const ddf_dev_t *device)
    10197{
    10298        async_sess_t *parent_sess =
     
    106102                return ENOMEM;
    107103       
    108         bool enabled = hw_res_enable_interrupt(parent_sess);
     104        const bool enabled = hw_res_enable_interrupt(parent_sess);
    109105        async_hangup(parent_sess);
    110106       
  • uspace/drv/bus/usb/ohci/res.h

    r41455a22 rf3378ba  
    3232 * PCI related functions needed by OHCI driver.
    3333 */
    34 #ifndef DRV_OHCI_PCI_H
    35 #define DRV_OHCI_PCI_H
     34#ifndef DRV_OHCI_RES_H
     35#define DRV_OHCI_RES_H
    3636
    3737#include <ddf/driver.h>
    3838
    39 int pci_get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
    40 int pci_enable_interrupts(ddf_dev_t *);
    41 int pci_disable_legacy(ddf_dev_t *);
     39int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
     40int enable_interrupts(const ddf_dev_t *);
    4241
    4342#endif
  • uspace/drv/bus/usb/uhci/Makefile

    r41455a22 rf3378ba  
    4444        hc.c \
    4545        main.c \
    46         pci.c \
     46        res.c \
    4747        root_hub.c \
    4848        transfer_list.c \
  • uspace/drv/bus/usb/uhci/res.c

    r41455a22 rf3378ba  
    3939#include <devman.h>
    4040#include <device/hw_res_parsed.h>
     41#include <device/pci.h>
    4142
    42 #include <usb/debug.h>
    43 #include <pci_dev_iface.h>
    44 
    45 #include "pci.h"
     43#include "res.h"
    4644
    4745/** Get I/O address of registers and IRQ for given device.
     
    5351 * @return Error code.
    5452 */
    55 int pci_get_my_registers(const ddf_dev_t *dev,
     53int get_my_registers(const ddf_dev_t *dev,
    5654    uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no)
    5755{
    5856        assert(dev);
    59         assert(io_reg_address);
    60         assert(io_reg_size);
    61         assert(irq_no);
    6257
    6358        async_sess_t *parent_sess =
     
    9792 * @return Error code.
    9893 */
    99 int pci_enable_interrupts(const ddf_dev_t *device)
     94int enable_interrupts(const ddf_dev_t *device)
    10095{
    10196        async_sess_t *parent_sess =
     
    116111 * @return Error code.
    117112 */
    118 int pci_disable_legacy(const ddf_dev_t *device)
     113int disable_legacy(const ddf_dev_t *device)
    119114{
    120115        assert(device);
    121116
    122         async_sess_t *parent_sess =
    123             devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
    124             IPC_FLAG_BLOCKING);
     117        async_sess_t *parent_sess = devman_parent_device_connect(
     118            EXCHANGE_SERIALIZE, device->handle, IPC_FLAG_BLOCKING);
    125119        if (!parent_sess)
    126120                return ENOMEM;
    127121
    128         /* See UHCI design guide for these values p.45,
    129          * write all WC bits in USB legacy register */
    130         const sysarg_t address = 0xc0;
    131         const sysarg_t value = 0xaf00;
     122        /* See UHCI design guide page 45 for these values.
     123         * Write all WC bits in USB legacy register */
     124        const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
    132125
    133         async_exch_t *exch = async_exchange_begin(parent_sess);
    134 
    135         const int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
    136             IPC_M_CONFIG_SPACE_WRITE_16, address, value);
    137 
    138         async_exchange_end(exch);
    139126        async_hangup(parent_sess);
    140 
    141127        return rc;
    142128}
  • uspace/drv/bus/usb/uhci/res.h

    r41455a22 rf3378ba  
    3838#include <ddf/driver.h>
    3939
    40 int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
    41 int pci_enable_interrupts(const ddf_dev_t *);
    42 int pci_disable_legacy(const ddf_dev_t *);
     40int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
     41int enable_interrupts(const ddf_dev_t *);
     42int disable_legacy(const ddf_dev_t *);
    4343
    4444#endif
  • uspace/drv/bus/usb/uhci/uhci.c

    r41455a22 rf3378ba  
    4141
    4242#include "uhci.h"
    43 #include "pci.h"
    44 
     43
     44#include "res.h"
    4545#include "hc.h"
    4646#include "root_hub.h"
     
    4949 * and USB root hub */
    5050typedef struct uhci {
    51         /** Pointer to DDF represenation of UHCI host controller */
     51        /** Pointer to DDF representation of UHCI host controller */
    5252        ddf_fun_t *hc_fun;
    53         /** Pointer to DDF represenation of UHCI root hub */
     53        /** Pointer to DDF representation of UHCI root hub */
    5454        ddf_fun_t *rh_fun;
    5555
    56         /** Internal driver's represenation of UHCI host controller */
     56        /** Internal driver's representation of UHCI host controller */
    5757        hc_t hc;
    58         /** Internal driver's represenation of UHCI root hub */
     58        /** Internal driver's representation of UHCI root hub */
    5959        rh_t rh;
    6060} uhci_t;
     
    187187        int irq = 0;
    188188
    189         ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
     189        ret = get_my_registers(device, &reg_base, &reg_size, &irq);
    190190        CHECK_RET_DEST_FREE_RETURN(ret,
    191191            "Failed to get I/O addresses for %" PRIun ": %s.\n",
     
    194194            (void *) reg_base, reg_size, irq);
    195195
    196         ret = pci_disable_legacy(device);
     196        ret = disable_legacy(device);
    197197        CHECK_RET_DEST_FREE_RETURN(ret,
    198198            "Failed to disable legacy USB: %s.\n", str_error(ret));
     
    220220
    221221        bool interrupts = false;
    222         ret = pci_enable_interrupts(device);
     222        ret = enable_interrupts(device);
    223223        if (ret != EOK) {
    224224                usb_log_warning("Failed to enable interrupts: %s."
Note: See TracChangeset for help on using the changeset viewer.