Changeset cc44f7e in mainline for uspace/drv/uhci-rhd/main.c


Ignore:
Timestamp:
2011-02-28T13:04:21Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b5644c, 494eaf7, 51b46f2
Parents:
81c508c (diff), dced52a (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:

hc and rh work

Support for low speed devices
RH iospace obtained from parent hc driver
proper hc initialization
Debug messages reworked
intelpci adressspace size fix (read the warning)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/main.c

    r81c508c rcc44f7e  
    3333 */
    3434#include <ddf/driver.h>
     35#include <devman.h>
     36#include <device/hw_res.h>
    3537#include <usb_iface.h>
    3638#include <usb/ddfiface.h>
     
    4345
    4446#define NAME "uhci-rhd"
     47static int hc_get_my_registers(ddf_dev_t *dev,
     48    uintptr_t *io_reg_address, size_t *io_reg_size);
    4549
    4650static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
     
    8084        }
    8185
    82         /* TODO: get register values from hc */
    83         int ret = uhci_root_hub_init(rh, (void*)0xc030, 4, device);
     86        uintptr_t io_regs = 0;
     87        size_t io_size = 0;
     88
     89        int ret = hc_get_my_registers(device, &io_regs, &io_size);
     90        assert(ret == EOK);
     91
     92        /* TODO: verify values from hc */
     93        usb_log_info("I/O regs at 0x%X (size %zu).\n", io_regs, io_size);
     94        ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
    8495        if (ret != EOK) {
    8596                usb_log_error("Failed(%d) to initialize driver instance.\n", ret);
     
    102113        .driver_ops = &uhci_rh_driver_ops
    103114};
    104 
     115/*----------------------------------------------------------------------------*/
    105116int main(int argc, char *argv[])
    106117{
    107         usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
     118        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    108119        return ddf_driver_main(&uhci_rh_driver);
     120}
     121/*----------------------------------------------------------------------------*/
     122int hc_get_my_registers(ddf_dev_t *dev,
     123    uintptr_t *io_reg_address, size_t *io_reg_size)
     124{
     125        assert(dev != NULL);
     126
     127        int parent_phone = devman_parent_device_connect(dev->handle,
     128            IPC_FLAG_BLOCKING);
     129        if (parent_phone < 0) {
     130                return parent_phone;
     131        }
     132
     133        int rc;
     134
     135        hw_resource_list_t hw_resources;
     136        rc = hw_res_get_resource_list(parent_phone, &hw_resources);
     137        if (rc != EOK) {
     138                goto leave;
     139        }
     140
     141        uintptr_t io_address = 0;
     142        size_t io_size = 0;
     143        bool io_found = false;
     144
     145        size_t i;
     146        for (i = 0; i < hw_resources.count; i++) {
     147                hw_resource_t *res = &hw_resources.resources[i];
     148                switch (res->type) {
     149                        case IO_RANGE:
     150                                io_address = (uintptr_t)
     151                                    res->res.io_range.address;
     152                                io_size = res->res.io_range.size;
     153                                io_found = true;
     154                                break;
     155                        default:
     156                                break;
     157                }
     158        }
     159
     160        if (!io_found) {
     161                rc = ENOENT;
     162                goto leave;
     163        }
     164
     165        if (io_reg_address != NULL) {
     166                *io_reg_address = io_address;
     167        }
     168        if (io_reg_size != NULL) {
     169                *io_reg_size = io_size;
     170        }
     171        rc = EOK;
     172leave:
     173        async_hangup(parent_phone);
     174
     175        return rc;
    109176}
    110177/**
Note: See TracChangeset for help on using the changeset viewer.