Changeset 063ae706 in mainline


Ignore:
Timestamp:
2012-04-05T05:27:06Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fb8dcb4
Parents:
712a10b
Message:

rootamdm37x: Add USB TLL and UHH headers, TLL initialization stub.

Location:
uspace/drv/infrastructure/rootamdm37x
Files:
2 added
1 edited

Legend:

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

    r712a10b r063ae706  
    4343#include <ddi.h>
    4444
     45#include "uhh.h"
     46#include "usbtll.h"
     47
    4548#define NAME  "rootamdm37x"
    4649
    4750/** Obtain function soft-state from DDF function node */
    48 #define ROOTMAC_FUN(fnode) \
     51#define ROOTARM_FUN(fnode) \
    4952        ((rootamdm37x_fun_t *) (fnode)->driver_data)
    5053
     
    5356} rootamdm37x_fun_t;
    5457
     58#define OHCI_BASE_ADDRESS  0x48064400
     59#define OHCI_SIZE  1024
     60#define EHCI_BASE_ADDRESS  0x48064800
     61#define EHCI_SIZE  1024
     62
    5563static hw_resource_t ohci_res[] = {
    5664        {
     
    5866                /* See amdm37x TRM page. 3316 for these values */
    5967                .res.io_range = {
    60                         .address = 0x48064400,
    61                         .size = 1024,
     68                        .address = OHCI_BASE_ADDRESS,
     69                        .size = OHCI_SIZE,
    6270                        .endianness = LITTLE_ENDIAN
    6371                },
     
    6674                .type = INTERRUPT,
    6775                .res.interrupt = { .irq = 76 },
    68         },
    69 };
    70 
    71 static hw_resource_t ehci_res[] = {
    72         {
    73                 .type = MEM_RANGE,
    74                 /* See amdm37x TRM page. 3316 for these values */
    75                 .res.io_range = {
    76                         .address = 0x48064800,
    77                         .size = 1024,
    78                         .endianness = LITTLE_ENDIAN
    79                 },
    80         },
    81         {
    82                 .type = INTERRUPT,
    83                 .res.interrupt = { .irq = 77 },
    8476        },
    8577};
     
    9284};
    9385
     86static hw_resource_t ehci_res[] = {
     87        {
     88                .type = MEM_RANGE,
     89                /* See amdm37x TRM page. 3316 for these values */
     90                .res.io_range = {
     91                        .address = EHCI_BASE_ADDRESS,
     92                        .size = EHCI_SIZE,
     93                        .endianness = LITTLE_ENDIAN
     94                },
     95        },
     96        {
     97                .type = INTERRUPT,
     98                .res.interrupt = { .irq = 77 },
     99        },
     100};
     101
    94102static const rootamdm37x_fun_t ehci = {
    95103        .hw_resources = {
     
    99107};
    100108
    101 
    102 static ddf_dev_ops_t rootamdm37x_fun_ops;
     109static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode);
     110static bool rootamdm37x_enable_interrupt(ddf_fun_t *fun);
     111
     112static hw_res_ops_t fun_hw_res_ops = {
     113        .get_resource_list = &rootamdm37x_get_resources,
     114        .enable_interrupt = &rootamdm37x_enable_interrupt,
     115};
     116
     117static ddf_dev_ops_t rootamdm37x_fun_ops =
     118{
     119        .interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops
     120};
     121
     122static int usb_clocks(bool on)
     123{
     124        uint32_t *usb_host_cm = NULL;
     125        uint32_t *l4_core_cm = NULL;
     126
     127        int ret = pio_enable((void*)0x48005400, 8192, (void**)&usb_host_cm);
     128        if (ret != EOK)
     129                return ret;
     130
     131        ret = pio_enable((void*)0x48004a00, 8192, (void**)&l4_core_cm);
     132        if (ret != EOK)
     133                return ret;
     134
     135        assert(l4_core_cm);
     136        assert(usb_host_cm);
     137        if (on) {
     138                l4_core_cm[0xe] |= 0x4;  /* iclk */
     139                l4_core_cm[0x3] |= 0x4;  /* fclk */
     140
     141                /* offset 0x10 (0x4 int32)[0] enables fclk,
     142                 * offset 0x00 (0x0 int32)[0 and 1] enables iclk,
     143                 * offset 0x30 (0xc int32)[0] enables autoidle
     144                 */
     145                usb_host_cm[0x4] = 0x1;
     146                usb_host_cm[0x0] = 0x3;
     147                usb_host_cm[0xc] = 0x1;
     148        } else {
     149                usb_host_cm[0xc] = 0;
     150                usb_host_cm[0x0] = 0;
     151                usb_host_cm[0x4] = 0;
     152                l4_core_cm[0xe] &= ~0x4;
     153                l4_core_cm[0x3] &= ~0x4;
     154        }
     155
     156        return ret;
     157}
     158
     159static int usb_tll_init()
     160{
     161        return EOK;
     162}
    103163
    104164static bool rootamdm37x_add_fun(ddf_dev_t *dev, const char *name,
     
    151211}
    152212
    153 /** Get the root device.
     213/** Add the root device.
    154214 *
    155215 * @param dev Device which is root of the whole device tree
     
    161221static int rootamdm37x_dev_add(ddf_dev_t *dev)
    162222{
    163         {
    164         /* Enable USB host clocks */
    165         uint32_t *reg = NULL;
    166         const int ret = pio_enable((void*)0x48005400, 8192, (void**)&reg);
    167         assert(ret == EOK);
    168         assert(reg);
    169         /* offset 0x10 (0x4 int32)[0] enables fclk,
    170          * offset 0x00 (0x0 int32)[0 and 1] enables iclk,
    171          * offset 0x30 (0xc int32)[0] enables autoidle
    172          */
    173         reg[0x4] = 0x1;
    174         reg[0x0] = 0x3;
    175         reg[0xc] = 0x1;
     223        int ret = usb_clocks(true);
     224        if (ret != EOK) {
     225                ddf_msg(LVL_FATAL, "Failed to enable USB HC clocks!.\n");
     226                return ret;
     227        }
     228
     229        ret = usb_tll_init();
     230        if (ret != EOK) {
     231                ddf_msg(LVL_FATAL, "Failed to init USB TLL!.\n");
     232                usb_clocks(false);
     233                return ret;
    176234        }
    177235
     
    200258static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode)
    201259{
    202         rootamdm37x_fun_t *fun = ROOTMAC_FUN(fnode);
     260        rootamdm37x_fun_t *fun = ROOTARM_FUN(fnode);
    203261        assert(fun != NULL);
    204        
    205262        return &fun->hw_resources;
    206263}
     
    209266{
    210267        /* TODO */
    211        
    212268        return false;
    213269}
    214 
    215 static hw_res_ops_t fun_hw_res_ops = {
    216         .get_resource_list = &rootamdm37x_get_resources,
    217         .enable_interrupt = &rootamdm37x_enable_interrupt
    218 };
    219270
    220271int main(int argc, char *argv[])
     
    222273        printf("%s: HelenOS AM/DM37x(OMAP37x) platform driver\n", NAME);
    223274        ddf_log_init(NAME, LVL_ERROR);
    224         rootamdm37x_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
    225275        return ddf_driver_main(&rootamdm37x_driver);
    226276}
Note: See TracChangeset for help on using the changeset viewer.