Changeset e646c61 in mainline


Ignore:
Timestamp:
2013-01-06T13:19:45Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be554d9
Parents:
5c058b6e
Message:

uhci: Add rh debug messages

Location:
uspace/drv/bus/usb/uhci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/hc.c

    r5c058b6e re646c61  
    243243        (void)hc_debug_checker;
    244244
    245         uhci_rh_init(&instance->rh, &instance->registers->ports[0]);
     245        uhci_rh_init(&instance->rh, instance->registers->ports, "uhci");
    246246
    247247        return EOK;
  • uspace/drv/bus/usb/uhci/uhci_rh.c

    r5c058b6e re646c61  
    6262static usbvirt_device_ops_t ops;
    6363
    64 int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports)
     64int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports, const char *name)
    6565{
    6666        assert(instance);
     
    6969        instance->reset_changed[0] = false;
    7070        instance->reset_changed[1] = false;
    71         return virthub_base_init(&instance->base, "uhci_rh", &ops, instance,
     71        return virthub_base_init(&instance->base, name, &ops, instance,
    7272            NULL, &hub_descriptor.header);
    7373}
     
    139139} while (0)
    140140
     141#define RH_DEBUG(d, port, msg, ...) \
     142        if ((int)port >= 0) \
     143                usb_log_debug("%s: rh-%d: " msg, d->name, port, ##__VA_ARGS__); \
     144        else \
     145                usb_log_debug("%s: rh: " msg, d->name, ##__VA_ARGS__) \
     146
    141147static int req_get_port_state(usbvirt_device_t *device,
    142148    const usb_device_request_setup_packet_t *setup_packet,
     
    152158        data[0] = ((value & STATUS_LINE_D_MINUS) ? 1 : 0)
    153159            | ((value & STATUS_LINE_D_PLUS) ? 2 : 0);
     160        RH_DEBUG(device, port, "Bus state %" PRIx8 "(source %" PRIx16")\n",
     161            data[0], value);
    154162        *act_size = 1;
    155163        return EOK;
     
    184192            ((hub->reset_changed[port] ? 1 : 0) << USB_HUB_FEATURE_C_PORT_RESET)
    185193        );
     194        RH_DEBUG(device, port, "Port status %" PRIx32 " (source %" PRIx16
     195            "%s)\n", uint32_usb2host(status), val,
     196            hub->reset_changed[port] ? "-reset" : "");
    186197        memcpy(data, &status, sizeof(status));
    187198        *act_size = sizeof(status);;
     
    197208        TEST_SIZE_INIT(0, port, hub);
    198209        const unsigned feature = uint16_usb2host(setup_packet->value);
    199         const uint16_t status = pio_read_16(hub->ports[port]) & ~STATUS_WC_BITS;
     210        const uint16_t status = pio_read_16(hub->ports[port]);
     211        const uint16_t val = status & (~STATUS_WC_BITS);
    200212        switch (feature) {
    201213        case USB_HUB_FEATURE_PORT_ENABLE:
    202                 pio_write_16(hub->ports[port], status & ~STATUS_ENABLED);
     214                RH_DEBUG(device, port, "Clear port enable (status %" PRIx16 ")\n",
     215                    status);
     216                pio_write_16(hub->ports[port], val & ~STATUS_ENABLED);
    203217                break;
    204218        case USB_HUB_FEATURE_PORT_SUSPEND:
    205                 pio_write_16(hub->ports[port], status &  ~STATUS_SUSPEND);
     219                RH_DEBUG(device, port, "Clear port suspend (status %" PRIx16 ")\n",
     220                    status);
     221                pio_write_16(hub->ports[port], val & ~STATUS_SUSPEND);
    206222                // TODO we should do resume magic
    207223                usb_log_warning("Resume is not implemented on port %u\n", port);
    208224                break;
    209225        case USB_HUB_FEATURE_PORT_POWER:
     226                RH_DEBUG(device, port, "Clear port power (status %" PRIx16 ")\n",
     227                    status);
    210228                /* We are always powered */
    211229                usb_log_warning("Tried to power off port %u\n", port);
    212230                break;
    213231        case USB_HUB_FEATURE_C_PORT_CONNECTION:
    214                 pio_write_16(hub->ports[port], status | STATUS_CONNECTED_CHANGED);
     232                RH_DEBUG(device, port, "Clear port conn change (status %" PRIx16
     233                    ")\n", status);
     234                pio_write_16(hub->ports[port], val | STATUS_CONNECTED_CHANGED);
    215235                break;
    216236        case USB_HUB_FEATURE_C_PORT_RESET:
    217                 hub->reset_changed[port] = 0;
     237                RH_DEBUG(device, port, "Clear port reset change (status %" PRIx16
     238                    ")\n", status);
     239                hub->reset_changed[port] = false;
    218240                break;
    219241        case USB_HUB_FEATURE_C_PORT_ENABLE:
     242                RH_DEBUG(device, port, "Clear port enable change (status %" PRIx16
     243                    ")\n", status);
    220244                pio_write_16(hub->ports[port], status | STATUS_ENABLED_CHANGED);
    221245                break;
    222246        case USB_HUB_FEATURE_C_PORT_SUSPEND:
     247                RH_DEBUG(device, port, "Clear port suspend change (status %" PRIx16
     248                    ")\n", status);
    223249                //TODO
    224250                return ENOTSUP;
    225251        case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
     252                RH_DEBUG(device, port, "Clear port OC change (status %" PRIx16
     253                    ")\n", status);
    226254                /* UHCI Does not report over current */
    227255                break;
    228256        default:
     257                RH_DEBUG(device, port, "Clear unknown feature %d (status %" PRIx16
     258                    ")\n", feature, status);
     259                usb_log_warning("Clearing feature %d is unsupported\n",
     260                    feature);
    229261                return ESTALL;
    230262        }
     
    243275        switch (feature) {
    244276        case USB_HUB_FEATURE_PORT_RESET:
     277                RH_DEBUG(device, port, "Set port reset before (status %" PRIx16
     278                    ")\n", status);
    245279                uhci_port_reset_enable(hub->ports[port]);
    246280                hub->reset_changed[port] = true;
     281                RH_DEBUG(device, port, "Set port reset after (status %" PRIx16
     282                    ")\n", pio_read_16(hub->ports[port]));
    247283                break;
    248284        case USB_HUB_FEATURE_PORT_SUSPEND:
     285                RH_DEBUG(device, port, "Set port suspend (status %" PRIx16
     286                    ")\n", status);
    249287                pio_write_16(hub->ports[port],
    250288                    (status & ~STATUS_WC_BITS) | STATUS_SUSPEND);
     
    252290                break;
    253291        case USB_HUB_FEATURE_PORT_POWER:
     292                RH_DEBUG(device, port, "Set port power (status %" PRIx16
     293                    ")\n", status);
    254294                /* We are always powered */
    255295                usb_log_warning("Tried to power port %u\n", port);
     
    258298        case USB_HUB_FEATURE_C_PORT_SUSPEND:
    259299        case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
     300                RH_DEBUG(device, port, "Set port change flag (status %" PRIx16
     301                    ")\n", status);
    260302                /* These are voluntary and don't have to be set
    261303                 * there is no way we could do it on UHCI anyway */
    262304                break;
    263305        default:
     306                RH_DEBUG(device, port, "Set unknown feature %d (status %" PRIx16
     307                    ")\n", feature, status);
     308                usb_log_warning("Setting feature %d is unsupported\n",
     309                    feature);
    264310                return ESTALL;
    265311        }
     
    343389};
    344390
    345 static int req_status_change_handler(usbvirt_device_t *dev,
     391static int req_status_change_handler(usbvirt_device_t *device,
    346392    usb_endpoint_t endpoint, usb_transfer_type_t tr_type,
    347393    void *buffer, size_t buffer_size, size_t *actual_size)
     
    349395        if (buffer_size < 1)
    350396                return ESTALL;
    351         uhci_rh_t *hub = virthub_get_data(dev);
     397        uhci_rh_t *hub = virthub_get_data(device);
    352398        assert(hub);
    353399
     400        const uint16_t status_a = pio_read_16(hub->ports[0]);
     401        const uint16_t status_b = pio_read_16(hub->ports[1]);
    354402        const uint8_t status =
    355             ((((pio_read_16(hub->ports[0]) & STATUS_CHANGE_BITS) != 0)
    356                 || hub->reset_changed[0]) ? 0x2 : 0) |
    357             ((((pio_read_16(hub->ports[1]) & STATUS_CHANGE_BITS) != 0)
    358                 || hub->reset_changed[1]) ? 0x4 : 0);
     403            ((((status_a & STATUS_CHANGE_BITS) != 0) || hub->reset_changed[0]) ?
     404                0x2 : 0) |
     405            ((((status_b & STATUS_CHANGE_BITS) != 0) || hub->reset_changed[1]) ?
     406                0x4 : 0);
     407
     408        RH_DEBUG(device, -1, "Event mask %" PRIx8
     409            " (status_a %" PRIx16 "%s),"
     410            " (status_b %" PRIx16 "%s)\n", status,
     411            status_a, hub->reset_changed[0] ? "-reset" : "",
     412            status_b, hub->reset_changed[1] ? "-reset" : "" );
    359413        ((uint8_t *)buffer)[0] = status;
    360414        *actual_size = 1;
  • uspace/drv/bus/usb/uhci/uhci_rh.h

    r5c058b6e re646c61  
    4949} uhci_rh_t;
    5050
    51 int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports);
     51int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports, const char *name);
    5252int uhci_rh_schedule(uhci_rh_t *instance, usb_transfer_batch_t *batch);
    5353static inline usb_address_t uhci_rh_get_address(uhci_rh_t *instance)
Note: See TracChangeset for help on using the changeset viewer.