Changeset 95c675b in mainline for uspace/drv/bus


Ignore:
Timestamp:
2017-10-17T13:11:35Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60af4cdb
Parents:
dbf32b1 (diff), a416d070 (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:

Merge mainline

Location:
uspace/drv/bus
Files:
4 added
10 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/adb/cuda_adb/Makefile

    rdbf32b1 r95c675b  
    2828
    2929USPACE_PREFIX = ../../../..
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
    3032BINARY = cuda_adb
    3133
    3234SOURCES = \
    33         cuda_adb.c
     35        cuda_adb.c \
     36        main.c
    3437
    3538include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/bus/adb/cuda_adb/cuda_hw.h

    rdbf32b1 r95c675b  
    3434 */
    3535
    36 #ifndef CUDA_ADB_H_
    37 #define CUDA_ADB_H_
     36#ifndef CUDA_HW_H_
     37#define CUDA_HW_H_
    3838
    39 #include <stddef.h>
    4039#include <stdint.h>
    41 #include <async.h>
    42 #include <fibril_synch.h>
    4340
    44 typedef struct {
     41typedef struct cuda_regs {
    4542        uint8_t b;
    4643        uint8_t pad0[0x1ff];
     
    9087        uint8_t anh;
    9188        uint8_t pad15[0x1ff];
    92 } cuda_t;
     89} cuda_regs_t;
     90
     91/** B register fields */
     92enum {
     93        TREQ    = 0x08,
     94        TACK    = 0x10,
     95        TIP     = 0x20
     96};
     97
     98/** IER register fields */
     99enum {
     100        IER_CLR = 0x00,
     101        IER_SET = 0x80,
     102
     103        SR_INT  = 0x04,
     104        ALL_INT = 0x7f
     105};
     106
     107/** ACR register fields */
     108enum {
     109        SR_OUT  = 0x10
     110};
     111
     112/** Packet types */
     113enum {
     114        PT_ADB  = 0x00,
     115        PT_CUDA = 0x01
     116};
     117
     118/** CUDA packet types */
     119enum {
     120        CPT_AUTOPOLL    = 0x01
     121};
    93122
    94123enum {
    95         CUDA_RCV_BUF_SIZE = 5
     124        ADB_MAX_ADDR    = 16
    96125};
    97 
    98 enum cuda_xfer_state {
    99         cx_listen,
    100         cx_receive,
    101         cx_rcv_end,
    102         cx_send_start,
    103         cx_send
    104 };
    105 
    106 typedef struct {
    107         service_id_t service_id;
    108         async_sess_t *client_sess;
    109 } adb_dev_t;
    110 
    111 typedef struct {
    112         cuda_t *cuda;
    113         uintptr_t cuda_physical;
    114 
    115         uint8_t rcv_buf[CUDA_RCV_BUF_SIZE];
    116         uint8_t snd_buf[CUDA_RCV_BUF_SIZE];
    117         size_t bidx;
    118         size_t snd_bytes;
    119         enum cuda_xfer_state xstate;
    120         fibril_mutex_t dev_lock;
    121 } cuda_instance_t;
    122126
    123127#endif
  • uspace/drv/bus/isa/i8237.c

    rdbf32b1 r95c675b  
    371371       
    372372        /* 16 bit transfers are a bit special */
    373         ddf_msg(LVL_DEBUG, "Unspoiled address %#" PRIx32 " (size %" PRIu16 ")",
     373        ddf_msg(LVL_DEBUG, "Unspoiled address %#" PRIx32 " (size %" PRIu32 ")",
    374374            pa, size);
    375375        if (is_dma16(channel)) {
     
    388388       
    389389        ddf_msg(LVL_DEBUG, "Setting channel %u to address %#" PRIx32 " "
    390             "(size %" PRIu16 "), mode %hhx.", channel, pa, size, mode);
     390            "(size %" PRIu32 "), mode %hhx.", channel, pa, size, mode);
    391391       
    392392        /* Mask DMA request */
  • uspace/drv/bus/isa/isa.c

    rdbf32b1 r95c675b  
    115115}
    116116
    117 static bool isa_fun_enable_interrupt(ddf_fun_t *fnode)
    118 {
    119         /* This is an old ugly way, copied from pci driver */
    120         assert(fnode);
     117static bool isa_fun_owns_interrupt(isa_fun_t *fun, int irq)
     118{
     119        const hw_resource_list_t *res = &fun->hw_resources;
     120
     121        /* Check that specified irq really belongs to the function */
     122        for (size_t i = 0; i < res->count; ++i) {
     123                if (res->resources[i].type == INTERRUPT &&
     124                    res->resources[i].res.interrupt.irq == irq) {
     125                        return true;
     126                }
     127        }
     128
     129        return false;
     130}
     131
     132static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
     133{
    121134        isa_fun_t *fun = isa_fun(fnode);
    122         assert(fun);
    123 
    124         const hw_resource_list_t *res = &fun->hw_resources;
    125         assert(res);
    126         for (size_t i = 0; i < res->count; ++i) {
    127                 if (res->resources[i].type == INTERRUPT) {
    128                         int rc = irc_enable_interrupt(
    129                             res->resources[i].res.interrupt.irq);
    130 
    131                         if (rc != EOK)
    132                                 return false;
    133                 }
    134         }
    135 
    136         return true;
     135
     136        if (!isa_fun_owns_interrupt(fun, irq))
     137                return EINVAL;
     138
     139        return irc_enable_interrupt(irq);
     140}
     141
     142static int isa_fun_disable_interrupt(ddf_fun_t *fnode, int irq)
     143{
     144        isa_fun_t *fun = isa_fun(fnode);
     145
     146        if (!isa_fun_owns_interrupt(fun, irq))
     147                return EINVAL;
     148
     149        return irc_disable_interrupt(irq);
     150}
     151
     152static int isa_fun_clear_interrupt(ddf_fun_t *fnode, int irq)
     153{
     154        isa_fun_t *fun = isa_fun(fnode);
     155
     156        if (!isa_fun_owns_interrupt(fun, irq))
     157                return EINVAL;
     158
     159        return irc_clear_interrupt(irq);
    137160}
    138161
     
    185208        .get_resource_list = isa_fun_get_resources,
    186209        .enable_interrupt = isa_fun_enable_interrupt,
     210        .disable_interrupt = isa_fun_disable_interrupt,
     211        .clear_interrupt = isa_fun_clear_interrupt,
    187212        .dma_channel_setup = isa_fun_setup_dma,
    188213        .dma_channel_remain = isa_fun_remain_dma,
     
    643668        list_initialize(&isa->functions);
    644669
    645         sess = ddf_dev_parent_sess_create(dev);
     670        sess = ddf_dev_parent_sess_get(dev);
    646671        if (sess == NULL) {
    647672                ddf_msg(LVL_ERROR, "isa_dev_add failed to connect to the "
  • uspace/drv/bus/pci/pciintel/pci.c

    rdbf32b1 r95c675b  
    9999}
    100100
    101 static bool pciintel_enable_interrupt(ddf_fun_t *fnode)
    102 {
    103         /* This is an old ugly way */
    104         assert(fnode);
    105         pci_fun_t *dev_data = pci_fun(fnode);
    106        
    107         size_t i = 0;
    108         hw_resource_list_t *res = &dev_data->hw_resources;
    109         for (; i < res->count; i++) {
    110                 if (res->resources[i].type == INTERRUPT) {
    111                         int rc = irc_enable_interrupt(
    112                             res->resources[i].res.interrupt.irq);
    113                        
    114                         if (rc != EOK)
    115                                 return false;
     101static int pciintel_fun_owns_interrupt(pci_fun_t *fun, int irq)
     102{
     103        size_t i;
     104        hw_resource_list_t *res = &fun->hw_resources;
     105       
     106        for (i = 0; i < res->count; i++) {
     107                if (res->resources[i].type == INTERRUPT &&
     108                    res->resources[i].res.interrupt.irq == irq) {
     109                        return true;
    116110                }
    117111        }
    118112       
    119         return true;
     113        return false;
     114}
     115
     116static int pciintel_enable_interrupt(ddf_fun_t *fnode, int irq)
     117{
     118        pci_fun_t *fun = pci_fun(fnode);
     119       
     120        if (!pciintel_fun_owns_interrupt(fun, irq))
     121                return EINVAL;
     122
     123        return irc_enable_interrupt(irq);
     124}
     125
     126static int pciintel_disable_interrupt(ddf_fun_t *fnode, int irq)
     127{
     128        pci_fun_t *fun = pci_fun(fnode);
     129       
     130        if (!pciintel_fun_owns_interrupt(fun, irq))
     131                return EINVAL;
     132
     133        return irc_disable_interrupt(irq);
     134}
     135
     136static int pciintel_clear_interrupt(ddf_fun_t *fnode, int irq)
     137{
     138        pci_fun_t *fun = pci_fun(fnode);
     139       
     140        if (!pciintel_fun_owns_interrupt(fun, irq))
     141                return EINVAL;
     142
     143        return irc_clear_interrupt(irq);
    120144}
    121145
     
    187211        .get_resource_list = &pciintel_get_resources,
    188212        .enable_interrupt = &pciintel_enable_interrupt,
     213        .disable_interrupt = &pciintel_disable_interrupt,
     214        .clear_interrupt = &pciintel_clear_interrupt,
    189215};
    190216
     
    683709        bus->dnode = dnode;
    684710       
    685         sess = ddf_dev_parent_sess_create(dnode);
     711        sess = ddf_dev_parent_sess_get(dnode);
    686712        if (sess == NULL) {
    687713                ddf_msg(LVL_ERROR, "pci_dev_add failed to connect to the "
  • uspace/drv/bus/usb/ehci/res.c

    rdbf32b1 r95c675b  
    3939#include <str_error.h>
    4040#include <assert.h>
    41 #include <devman.h>
     41#include <ddf/driver.h>
    4242#include <ddi.h>
    4343#include <usb/debug.h>
     
    176176        assert(device);
    177177
    178         async_sess_t *parent_sess = devman_parent_device_connect(
    179             ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    180         if (!parent_sess)
     178        async_sess_t *parent_sess = ddf_dev_parent_sess_get(device);
     179        if (parent_sess == NULL)
    181180                return ENOMEM;
    182181
  • uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.c

    rdbf32b1 r95c675b  
    7878
    7979        /* Allow less data on input. */
    80         if (dir == USB_DIRECTION_IN) {
     80        if (direction == USB_DIRECTION_IN) {
    8181                OHCI_MEM32_SET(instance->status, TD_STATUS_ROUND_FLAG);
    8282        }
  • uspace/drv/bus/usb/ohci/ohci_rh.c

    rdbf32b1 r95c675b  
    361361        case USB_HUB_FEATURE_C_PORT_RESET:        /*20*/
    362362                usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, "
    363                     "C_SUSPEND, C_OC or C_RESET on port %"PRIu16".\n", port);
     363                    "C_SUSPEND, C_OC or C_RESET on port %u.\n", port);
    364364                /* Bit offsets correspond to the feature number */
    365365                OHCI_WR(hub->registers->rh_port_status[port],
     
    410410        case USB_HUB_FEATURE_PORT_RESET:   /*4*/
    411411                usb_log_debug2("Setting port POWER, ENABLE, SUSPEND or RESET "
    412                     "on port %"PRIu16".\n", port);
     412                    "on port %u.\n", port);
    413413                /* Bit offsets correspond to the feature number */
    414414                OHCI_WR(hub->registers->rh_port_status[port], 1 << feature);
  • uspace/drv/bus/usb/uhci/main.c

    rdbf32b1 r95c675b  
    3636#include <assert.h>
    3737#include <ddf/driver.h>
    38 #include <devman.h>
    3938#include <errno.h>
    4039#include <io/log.h>
     
    123122        assert(device);
    124123
    125         async_sess_t *parent_sess = devman_parent_device_connect(
    126             ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    127         if (!parent_sess)
     124        async_sess_t *parent_sess = ddf_dev_parent_sess_get(device);
     125        if (parent_sess == NULL)
    128126                return ENOMEM;
    129127
    130128        /* See UHCI design guide page 45 for these values.
    131129         * Write all WC bits in USB legacy register */
    132         const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
    133 
    134         async_hangup(parent_sess);
    135         return rc;
     130        return pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
    136131}
    137132
  • uspace/drv/bus/usb/usbhub/status.h

    rdbf32b1 r95c675b  
    3535#define HUB_STATUS_H
    3636
    37 #include <stdbool.h>
    38 #include <stdint.h>
    3937#include <usb/dev/request.h>
    4038
  • uspace/drv/bus/usb/usbhub/usbhub.h

    rdbf32b1 r95c675b  
    3838#define DRV_USBHUB_USBHUB_H
    3939
    40 #include <ipc/devman.h>
    4140#include <ddf/driver.h>
    4241
     
    7271        /** Condition variable for pending_ops_count. */
    7372        fibril_condvar_t pending_ops_cv;
    74         /** Pointer to devman usbhub function. */
     73        /** Pointer to usbhub function. */
    7574        ddf_fun_t *hub_fun;
    7675        /** Status indicator */
  • uspace/drv/bus/usb/usbmid/explore.c

    rdbf32b1 r95c675b  
    132132 *
    133133 * @param dev Device to be explored.
    134  * @return Whether to accept this device from devman.
     134 * @return Whether to accept this device.
    135135 */
    136136int usbmid_explore_device(usb_device_t *dev)
Note: See TracChangeset for help on using the changeset viewer.