Changeset 8d40181 in mainline


Ignore:
Timestamp:
2013-09-21T03:25:31Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ea69749f
Parents:
c898236
Message:

ohci,uhci,ehci: Use library provided 'get_registers' function

Location:
uspace/drv/bus/usb
Files:
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/main.c

    rc898236 r8d40181  
    6767{
    6868        assert(device);
    69 
    70         addr_range_t reg_range;
    71         int irq = 0;
    72 
    73         int ret = get_my_registers(device, &reg_range, &irq);
    74         if (ret != EOK) {
    75                 usb_log_error("Failed to get memory addresses for %" PRIun
    76                     ": %s.\n", ddf_dev_get_handle(device), str_error(ret));
     69        hw_res_list_parsed_t hw_res;
     70        int ret = hcd_ddf_get_registers(device, &hw_res);
     71        if (ret != EOK ||
     72            hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
     73                usb_log_error("Failed to get register memory addresses "
     74                    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
     75                    str_error(ret));
    7776                return ret;
    7877        }
     78        addr_range_t regs = hw_res.mem_ranges.ranges[0];
     79        const int irq = hw_res.irqs.irqs[0];
     80        hw_res_list_parsed_clean(&hw_res);
    7981
    8082        usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n",
    81             RNGABSPTR(reg_range), RNGSZ(reg_range), irq);
     83            RNGABSPTR(regs), RNGSZ(regs), irq);
    8284
    83         ret = disable_legacy(device, &reg_range);
     85        ret = disable_legacy(device, &regs);
    8486        if (ret != EOK) {
    8587                usb_log_error("Failed to disable legacy USB: %s.\n",
  • uspace/drv/bus/usb/ehci/res.c

    rc898236 r8d40181  
    6666#define DEFAULT_WAIT 1000
    6767#define WAIT_STEP 10
    68 
    69 
    70 /** Get address of registers and IRQ for given device.
    71  *
    72  * @param[in] dev Device asking for the addresses.
    73  * @param[out] mem_regs_p Pointer to the register range.
    74  * @param[out] irq_no IRQ assigned to the device.
    75  * @return Error code.
    76  */
    77 int get_my_registers(ddf_dev_t *dev,
    78     addr_range_t *mem_regs_p, int *irq_no)
    79 {
    80         assert(dev);
    81        
    82         async_sess_t *parent_sess = devman_parent_device_connect(
    83             EXCHANGE_SERIALIZE, ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
    84         if (!parent_sess)
    85                 return ENOMEM;
    86        
    87         hw_res_list_parsed_t hw_res;
    88         hw_res_list_parsed_init(&hw_res);
    89         const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
    90         async_hangup(parent_sess);
    91         if (ret != EOK) {
    92                 return ret;
    93         }
    94 
    95         if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
    96                 hw_res_list_parsed_clean(&hw_res);
    97                 return ENOENT;
    98         }
    99 
    100         if (mem_regs_p)
    101                 *mem_regs_p = hw_res.mem_ranges.ranges[0];
    102         if (irq_no)
    103                 *irq_no = hw_res.irqs.irqs[0];
    104 
    105         hw_res_list_parsed_clean(&hw_res);
    106         return EOK;
    107 }
    10868
    10969/** Implements BIOS hands-off routine as described in EHCI spec
  • uspace/drv/bus/usb/ehci/res.h

    rc898236 r8d40181  
    3939#include <device/hw_res_parsed.h>
    4040
    41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *);
    42 int enable_interrupts(ddf_dev_t *);
    4341int disable_legacy(ddf_dev_t *, addr_range_t *);
    4442
  • uspace/drv/bus/usb/ohci/Makefile

    rc898236 r8d40181  
    5252        ohci_endpoint.c \
    5353        ohci_rh.c \
    54         res.c \
    5554        hw_struct/endpoint_descriptor.c \
    5655        hw_struct/transfer_descriptor.c
  • uspace/drv/bus/usb/ohci/ohci.c

    rc898236 r8d40181  
    4343
    4444#include "ohci.h"
    45 #include "res.h"
    4645#include "hc.h"
    47 
    4846
    4947
     
    8078int device_setup_ohci(ddf_dev_t *device)
    8179{
    82 
    83         addr_range_t regs;
    84         int irq = 0;
    85 
    86         int ret = get_my_registers(device, &regs, &irq);
    87         if (ret != EOK) {
     80        hw_res_list_parsed_t hw_res;
     81        int ret = hcd_ddf_get_registers(device, &hw_res);
     82        if (ret != EOK ||
     83            hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
    8884                usb_log_error("Failed to get register memory addresses "
    8985                    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
     
    9187                return ret;
    9288        }
     89        addr_range_t regs = hw_res.mem_ranges.ranges[0];
     90        const int irq = hw_res.irqs.irqs[0];
     91        hw_res_list_parsed_clean(&hw_res);
     92
    9393
    9494        usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
  • uspace/drv/bus/usb/uhci/res.c

    rc898236 r8d40181  
    4343#include "res.h"
    4444
    45 /** Get I/O address of registers and IRQ for given device.
    46  *
    47  * @param[in] dev Device asking for the addresses.
    48  * @param[out] io_regs_p Pointer to register I/O range.
    49  * @param[out] irq_no IRQ assigned to the device.
    50  * @return Error code.
    51  */
    52 int get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p, int *irq_no)
    53 {
    54         assert(dev);
    55 
    56         async_sess_t *parent_sess =
    57             devman_parent_device_connect(EXCHANGE_SERIALIZE,
    58             ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
    59         if (!parent_sess)
    60                 return ENOMEM;
    61 
    62         hw_res_list_parsed_t hw_res;
    63         hw_res_list_parsed_init(&hw_res);
    64         const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
    65         async_hangup(parent_sess);
    66         if (ret != EOK) {
    67                 return ret;
    68         }
    69 
    70         /* We want one irq and one io range. */
    71         if (hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
    72                 hw_res_list_parsed_clean(&hw_res);
    73                 return EINVAL;
    74         }
    75 
    76         if (io_regs_p)
    77                 *io_regs_p = hw_res.io_ranges.ranges[0];
    78         if (irq_no)
    79                 *irq_no = hw_res.irqs.irqs[0];
    80 
    81         hw_res_list_parsed_clean(&hw_res);
    82         return EOK;
    83 }
    84 
    8545/** Call the PCI driver with a request to clear legacy support register
    8646 *
  • uspace/drv/bus/usb/uhci/res.h

    rc898236 r8d40181  
    3939#include <device/hw_res_parsed.h>
    4040
    41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *);
    42 int enable_interrupts(ddf_dev_t *);
    4341int disable_legacy(ddf_dev_t *);
    4442
  • uspace/drv/bus/usb/uhci/uhci.c

    rc898236 r8d40181  
    7777int device_setup_uhci(ddf_dev_t *device)
    7878{
    79         if (!device)
    80                 return EBADMEM;
     79        assert(device);
    8180
    82         addr_range_t regs;
    83         int irq = 0;
    84 
    85         int ret = get_my_registers(device, &regs, &irq);
    86         if (ret != EOK) {
    87                 usb_log_error("Failed to get I/O addresses for %" PRIun ": %s.\n",
    88                     ddf_dev_get_handle(device), str_error(ret));
     81        hw_res_list_parsed_t hw_res;
     82        int ret = hcd_ddf_get_registers(device, &hw_res);
     83        if (ret != EOK ||
     84            hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
     85                usb_log_error("Failed to get register memory addresses "
     86                    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
     87                    str_error(ret));
    8988                return ret;
    9089        }
     90        addr_range_t regs = hw_res.io_ranges.ranges[0];
     91        const int irq = hw_res.irqs.irqs[0];
     92        hw_res_list_parsed_clean(&hw_res);
     93
    9194        usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n",
    9295            RNGABSPTR(regs), RNGSZ(regs), irq);
Note: See TracChangeset for help on using the changeset viewer.