Changeset c188c62 in mainline for uspace/drv/platform/mac/mac.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/platform/mac/mac.c

    re27e36e rc188c62  
    11/*
    22 * Copyright (c) 2011 Martin Decky
     3 * Copyright (c) 2017 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4041#include <errno.h>
    4142#include <ops/hw_res.h>
     43#include <ops/pio_window.h>
    4244#include <stdio.h>
    4345#include <sysinfo.h>
     
    4749typedef struct {
    4850        hw_resource_list_t hw_resources;
     51        pio_window_t pio_window;
    4952} mac_fun_t;
    5053
    51 static hw_resource_t adb_regs[] = {
     54static hw_resource_t adb_res[] = {
    5255        {
    5356                .type = IO_RANGE,
     
    5558                        .address = 0,
    5659                        .size = 0x2000,
    57                         .relative = false,
     60                        .relative = true,
    5861                        .endianness = BIG_ENDIAN
     62                }
     63        },
     64        {
     65                .type = INTERRUPT,
     66                .res.interrupt = {
     67                        .irq = 0 /* patched at run time */
    5968                }
    6069        },
     
    6372static mac_fun_t adb_data = {
    6473        .hw_resources = {
    65                 1,
    66                 adb_regs
     74                sizeof(adb_res) / sizeof(adb_res[0]),
     75                adb_res
     76        },
     77        .pio_window = {
     78                .io = {
     79                        .base = 0, /* patched at run time */
     80                        .size = 0x2000
     81                }
    6782        }
    6883};
     
    99114
    100115/** Obtain function soft-state from DDF function node */
    101 static mac_fun_t *mac_fun(ddf_fun_t *fnode)
    102 {
    103         return ddf_fun_data_get(fnode);
     116static mac_fun_t *mac_fun(ddf_fun_t *ddf_fun)
     117{
     118        return ddf_fun_data_get(ddf_fun);
     119}
     120
     121static pio_window_t *mac_get_pio_window(ddf_fun_t *ddf_fun)
     122{
     123        mac_fun_t *fun = mac_fun(ddf_fun);
     124        return &fun->pio_window;
    104125}
    105126
     
    159180        int rc;
    160181        uintptr_t cuda_physical;
     182        sysarg_t cuda_inr;
    161183#if 0
    162184        /* Register functions */
     
    171193        if (rc != EOK)
    172194                return EIO;
    173 
    174         adb_regs[0].res.io_range.address = cuda_physical;
     195        rc = sysinfo_get_value("cuda.inr", &cuda_inr);
     196        if (rc != EOK)
     197                return EIO;
     198
     199        adb_data.pio_window.io.base = cuda_physical;
     200        adb_res[1].res.interrupt.irq = cuda_inr;
    175201
    176202        if (!mac_add_fun(dev, "adb", "cuda_adb", &adb_data)) {
     
    208234}
    209235
     236static pio_window_ops_t fun_pio_window_ops = {
     237        .get_pio_window = &mac_get_pio_window
     238};
     239
    210240static hw_res_ops_t fun_hw_res_ops = {
    211241        .get_resource_list = &mac_get_resources,
     
    218248        ddf_log_init(NAME);
    219249        mac_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
     250        mac_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops;
    220251        return ddf_driver_main(&mac_driver);
    221252}
Note: See TracChangeset for help on using the changeset viewer.