Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c

    r85a54b4 ra14f346  
    4848
    4949typedef struct {
    50         const char *name;
    51         match_id_t match_id;
    5250        hw_resource_list_t hw_resources;
    5351} rootamdm37x_fun_t;
    5452
    55 /* See amdm37x TRM page 3316 for these values */
    56 #define OHCI_BASE_ADDRESS   0x48064400
    57 #define OHCI_SIZE   1024
    58 #define EHCI_BASE_ADDRESS   0x48064800
    59 #define EHCI_SIZE   1024
    60 
    61 /* See amdm37x TRM page 1813 for these values */
    62 #define DSS_BASE_ADDRESS   0x48050000
    63 #define DSS_SIZE   512
    64 #define DISPC_BASE_ADDRESS   0x48050400
    65 #define DISPC_SIZE   1024
    66 #define VIDEO_ENC_BASE_ADDRESS   0x48050C00
    67 #define VIDEO_ENC_SIZE   256
    68 
     53/* See amdm37x TRM page. 3316 for these values */
     54#define OHCI_BASE_ADDRESS  0x48064400
     55#define OHCI_SIZE  1024
     56#define EHCI_BASE_ADDRESS  0x48064800
     57#define EHCI_SIZE  1024
    6958
    7059static hw_resource_t ohci_res[] = {
     
    9988};
    10089
    101 static hw_resource_t disp_res[] = {
    102         {
    103                 .type = MEM_RANGE,
    104                 .res.io_range = {
    105                         .address = DSS_BASE_ADDRESS,
    106                         .size = DSS_SIZE,
    107                         .endianness = LITTLE_ENDIAN
    108                 },
    109         },
    110         {
    111                 .type = MEM_RANGE,
    112                 .res.io_range = {
    113                         .address = DISPC_BASE_ADDRESS,
    114                         .size = DISPC_SIZE,
    115                         .endianness = LITTLE_ENDIAN
    116                 },
    117         },
    118         {
    119                 .type = MEM_RANGE,
    120                 .res.io_range = {
    121                         .address = VIDEO_ENC_BASE_ADDRESS,
    122                         .size = VIDEO_ENC_SIZE,
    123                         .endianness = LITTLE_ENDIAN
    124                 },
    125         },
    126         {
    127                 .type = INTERRUPT,
    128                 .res.interrupt = { .irq = 25 },
    129         },
    130 };
    131 
    132 static const rootamdm37x_fun_t amdm37x_funcs[] = {
    133 {
    134         .name = "ohci",
    135         .match_id = { .id = "usb/host=ohci", .score = 90 },
    136         .hw_resources = { .resources = ohci_res, .count = ARRAY_SIZE(ohci_res) }
    137 },
    138 {
    139         .name = "ehci",
    140         .match_id = { .id = "usb/host=ehci", .score = 90 },
    141         .hw_resources = { .resources = ehci_res, .count = ARRAY_SIZE(ehci_res) }
    142 },
    143 {
    144         .name = "fb",
    145         .match_id = { .id = "amdm37x&dispc", .score = 90 },
    146         .hw_resources = { .resources = disp_res, .count = ARRAY_SIZE(disp_res) }
    147 },
    148 };
    149 
     90static const rootamdm37x_fun_t ohci = {
     91        .hw_resources = {
     92            .resources = ohci_res,
     93            .count = sizeof(ohci_res)/sizeof(ohci_res[0]),
     94        }
     95};
     96
     97static const rootamdm37x_fun_t ehci = {
     98        .hw_resources = {
     99            .resources = ehci_res,
     100            .count = sizeof(ehci_res) / sizeof(ehci_res[0]),
     101        }
     102};
    150103
    151104static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode);
     
    161114};
    162115
    163 static int rootamdm37x_add_fun(ddf_dev_t *dev, const rootamdm37x_fun_t *fun)
    164 {
    165         assert(dev);
    166         assert(fun);
    167 
    168         ddf_msg(LVL_DEBUG, "Adding new function '%s'.", fun->name);
    169 
     116static int rootamdm37x_add_fun(ddf_dev_t *dev, const char *name,
     117    const char *str_match_id, const rootamdm37x_fun_t *fun)
     118{
     119        ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
     120       
    170121        /* Create new device function. */
    171         ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, fun->name);
     122        ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, name);
    172123        if (fnode == NULL)
    173124                return ENOMEM;
    174125       
    175126        /* Add match id */
    176         int ret = ddf_fun_add_match_id(fnode,
    177             fun->match_id.id, fun->match_id.score);
     127        int ret = ddf_fun_add_match_id(fnode, str_match_id, 100);
    178128        if (ret != EOK) {
    179129                ddf_fun_destroy(fnode);
     
    196146        ret = ddf_fun_bind(fnode);
    197147        if (ret != EOK) {
    198                 ddf_msg(LVL_ERROR, "Failed binding function %s.", fun->name);
     148                ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
    199149                ddf_fun_destroy(fnode);
    200150                return ret;
     
    239189
    240190        /* Register functions */
    241         for (unsigned i = 0; i < ARRAY_SIZE(amdm37x_funcs); ++i) {
    242                 if (rootamdm37x_add_fun(dev, &amdm37x_funcs[i]) != EOK)
    243                         ddf_msg(LVL_ERROR, "Failed to add %s function for "
    244                             "BeagleBoard-xM platform.", amdm37x_funcs[i].name);
    245         }
     191        if (rootamdm37x_add_fun(dev, "ohci", "usb/host=ohci", &ohci) != EOK)
     192                ddf_msg(LVL_ERROR, "Failed to add OHCI function for "
     193                    "BeagleBoard-xM platform.");
     194        if (rootamdm37x_add_fun(dev, "ehci", "usb/host=ehci", &ehci) != EOK)
     195                ddf_msg(LVL_ERROR, "Failed to add EHCI function for "
     196                    "BeagleBoard-xM platform.");
     197        if (rootamdm37x_add_fun(dev, "dispc", "amdm37x&dispc", &ehci) != EOK)
     198                ddf_msg(LVL_ERROR, "Failed to add dispc function for "
     199                    "BeagleBoard-xM platform.");
     200
    246201        return EOK;
    247202}
Note: See TracChangeset for help on using the changeset viewer.