Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 708ec60 in mainline


Ignore:
Timestamp:
2012-04-06T18:13:18Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
87739fb
Parents:
2096871
Message:

rootamdm37x: Replace magic numbers with proper register struct and defines.

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

Legend:

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

    r2096871 r708ec60  
    4545#include "uhh.h"
    4646#include "usbtll.h"
     47#include "core_cm.h"
     48#include "usbhost_cm.h"
    4749
    4850#define NAME  "rootamdm37x"
     
    122124static int usb_clocks(bool on)
    123125{
    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);
     126        usbhost_cm_regs_t *usb_host_cm = NULL;
     127        core_cm_regs_t *l4_core_cm = NULL;
     128
     129        int ret = pio_enable((void*)USBHOST_CM_BASE_ADDRESS, USBHOST_CM_SIZE,
     130            (void**)&usb_host_cm);
    128131        if (ret != EOK)
    129132                return ret;
    130133
    131         ret = pio_enable((void*)0x48004a00, 8192, (void**)&l4_core_cm);
     134        ret = pio_enable((void*)CORE_CM_BASE_ADDRESS, CORE_CM_SIZE,
     135            (void**)&l4_core_cm);
    132136        if (ret != EOK)
    133137                return ret;
     
    136140        assert(usb_host_cm);
    137141        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;
     142                l4_core_cm->iclken3 |= CORE_CM_ICLKEN3_EN_USBTLL_FLAG;
     143                l4_core_cm->fclken3 |= CORE_CM_FCLKEN3_EN_USBTLL_FLAG;
     144                usb_host_cm->iclken |= USBHOST_CM_ICLKEN_EN_USBHOST;
     145                usb_host_cm->fclken |= USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG;
     146                usb_host_cm->fclken |= USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG;
    148147        } 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         }
     148                usb_host_cm->fclken &= ~USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG;
     149                usb_host_cm->fclken &= ~USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG;
     150                usb_host_cm->iclken &= ~USBHOST_CM_ICLKEN_EN_USBHOST;
     151                l4_core_cm->fclken3 &= ~CORE_CM_FCLKEN3_EN_USBTLL_FLAG;
     152                l4_core_cm->iclken3 &= ~CORE_CM_ICLKEN3_EN_USBTLL_FLAG;
     153        }
     154
     155        //TODO Unmap those registers.
    155156
    156157        return ret;
     
    159160static int usb_tll_init()
    160161{
     162        tll_regs_t *usb_tll = NULL;
     163        uhh_regs_t *uhh_conf = NULL;
     164
     165        int ret = pio_enable((void*)AMDM37x_USBTLL_BASE_ADDRESS,
     166            AMDM37x_USBTLL_SIZE, (void**)&usb_tll);
     167        if (ret != EOK)
     168                return ret;
     169
     170        ret = pio_enable((void*)AMDM37x_UHH_BASE_ADDRESS,
     171            AMDM37x_UHH_SIZE, (void**)&uhh_conf);
     172        if (ret != EOK)
     173                return ret;
     174
     175        /* Reset USB tll */
     176        usb_tll->sysconfig |= TLL_SYSCONFIG_SOFTRESET_FLAG;
     177        ddf_msg(LVL_DEBUG2, "Waiting for USB TLL reset");
     178        while (!(usb_tll->sysstatus & TLL_SYSSTATUS_RESET_DONE_FLAG));
     179        ddf_msg(LVL_DEBUG, "USB TLL Reset done.");
     180
    161181        return EOK;
    162182}
Note: See TracChangeset for help on using the changeset viewer.