Changeset c188c62 in mainline for uspace/drv/bus/adb/cuda_adb/main.c


Ignore:
Timestamp:
2017-10-05T18:00:52Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
81b9d3e
Parents:
e27e36e
Message:

CUDA driver should use hw_res to obtain HW configuration.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/adb/cuda_adb/main.c

    re27e36e rc188c62  
    3535#include <ddf/driver.h>
    3636#include <ddf/log.h>
     37#include <device/hw_res_parsed.h>
    3738#include <errno.h>
    3839#include <stdio.h>
     
    6162};
    6263
     64static int cuda_get_res(ddf_dev_t *dev, cuda_res_t *res)
     65{
     66        async_sess_t *parent_sess;
     67        hw_res_list_parsed_t hw_res;
     68        int rc;
     69
     70        parent_sess = ddf_dev_parent_sess_create(dev);
     71        if (parent_sess == NULL)
     72                return ENOMEM;
     73
     74        hw_res_list_parsed_init(&hw_res);
     75        rc = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
     76        if (rc != EOK)
     77                return rc;
     78
     79        if (hw_res.io_ranges.count != 1) {
     80                rc = EINVAL;
     81                goto error;
     82        }
     83
     84        res->base = RNGABS(hw_res.io_ranges.ranges[0]);
     85
     86        if (hw_res.irqs.count != 1) {
     87                rc = EINVAL;
     88                goto error;
     89        }
     90
     91        res->irq = hw_res.irqs.irqs[0];
     92
     93        return EOK;
     94error:
     95        hw_res_list_parsed_clean(&hw_res);
     96        return rc;
     97}
     98
    6399static int cuda_dev_add(ddf_dev_t *dev)
    64100{
    65101        cuda_t *cuda;
     102        cuda_res_t cuda_res;
     103        int rc;
    66104
    67         printf("cuda_dev_add\n");
    68105        ddf_msg(LVL_DEBUG, "cuda_dev_add(%p)", dev);
    69106        cuda = ddf_dev_data_alloc(dev, sizeof(cuda_t));
     
    75112        cuda->dev = dev;
    76113        list_initialize(&cuda->devs);
    77         printf("call cuda_add\n");
    78         int rc = cuda_add(cuda);
    79         printf("cuda_add->%d\n", rc);
    80         return rc;
     114
     115        rc = cuda_get_res(dev, &cuda_res);
     116        if (rc != EOK) {
     117                ddf_msg(LVL_ERROR, "Failed getting hardware resource list.\n");
     118                return EIO;
     119        }
     120
     121        return cuda_add(cuda, &cuda_res);
    81122}
    82123
Note: See TracChangeset for help on using the changeset viewer.