Changeset 601fa93 in mainline


Ignore:
Timestamp:
2012-10-11T13:32:53Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7290ca0
Parents:
639d9dd5
Message:

rootamdm37x: Enable DPPL5 before accessing USB regs.

File:
1 edited

Legend:

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

    r639d9dd5 r601fa93  
    4747#include "usbtll.h"
    4848#include "core_cm.h"
     49#include "clock_control_cm.h"
    4950#include "usbhost_cm.h"
    5051
     
    121122static int usb_clocks(bool on)
    122123{
    123         usbhost_cm_regs_t *usb_host_cm = NULL;
    124         core_cm_regs_t *l4_core_cm = NULL;
    125 
    126         int ret = pio_enable((void*)USBHOST_CM_BASE_ADDRESS, USBHOST_CM_SIZE,
    127             (void**)&usb_host_cm);
    128         if (ret != EOK)
    129                 return ret;
    130 
    131         ret = pio_enable((void*)CORE_CM_BASE_ADDRESS, CORE_CM_SIZE,
    132             (void**)&l4_core_cm);
    133         if (ret != EOK)
    134                 return ret;
     124        static usbhost_cm_regs_t *usb_host_cm = NULL;
     125        static core_cm_regs_t *l4_core_cm = NULL;
     126        static clock_control_cm_regs_t *clock_control_cm = NULL;
     127
     128        if (!usb_host_cm) {
     129                const int ret = pio_enable((void*)USBHOST_CM_BASE_ADDRESS,
     130                    USBHOST_CM_SIZE, (void**)&usb_host_cm);
     131                if (ret != EOK)
     132                        return ret;
     133        }
     134
     135        if (!l4_core_cm) {
     136                const int ret = pio_enable((void*)CORE_CM_BASE_ADDRESS,
     137                    CORE_CM_SIZE, (void**)&l4_core_cm);
     138                if (ret != EOK)
     139                        return ret;
     140        }
     141
     142        if (!clock_control_cm) {
     143                const int ret = pio_enable((void*)CLOCK_CONTROL_CM_BASE_ADDRESS,
     144                    CLOCK_CONTROL_CM_SIZE, (void**)&clock_control_cm);
     145                if (ret != EOK)
     146                        return ret;
     147        }
    135148
    136149        assert(l4_core_cm);
    137150        assert(usb_host_cm);
     151        assert(clock_control_cm);
     152
     153        /* Always set DPLL5 to automatic */
     154        uint32_t reg = clock_control_cm->autoidle2_pll
     155        reg &= ~(CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK <<
     156            CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_SHIFT);
     157        reg |= (CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC <<
     158            CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_SHIFT);
     159        clock_control_cm->autoidle2_pll = reg;
     160
    138161        if (on) {
     162                /* Enable interface and function clock for USB TLL */
    139163                l4_core_cm->iclken3 |= CORE_CM_ICLKEN3_EN_USBTLL_FLAG;
    140164                l4_core_cm->fclken3 |= CORE_CM_FCLKEN3_EN_USBTLL_FLAG;
     165
     166                /* Enable interface and function clock for USB hosts */
    141167                usb_host_cm->iclken |= USBHOST_CM_ICLKEN_EN_USBHOST;
    142168                usb_host_cm->fclken |= USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG;
    143169                usb_host_cm->fclken |= USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG;
    144170        } else {
     171                /* Disable interface and function clock for USB hosts */
    145172                usb_host_cm->fclken &= ~USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG;
    146173                usb_host_cm->fclken &= ~USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG;
    147174                usb_host_cm->iclken &= ~USBHOST_CM_ICLKEN_EN_USBHOST;
     175
     176                /* Disable interface and function clock for USB TLL */
    148177                l4_core_cm->fclken3 &= ~CORE_CM_FCLKEN3_EN_USBTLL_FLAG;
    149178                l4_core_cm->iclken3 &= ~CORE_CM_ICLKEN3_EN_USBTLL_FLAG;
    150179        }
    151180
    152         //TODO Unmap those registers.
    153 
    154         return ret;
     181        return EOK;
    155182}
    156183
     
    263290        /* Add match id */
    264291        if (ddf_fun_add_match_id(fnode, str_match_id, 100) != EOK) {
    265                 // TODO This will try to free our data!
    266292                ddf_fun_destroy(fnode);
    267293                return false;
     
    275301        if (ddf_fun_bind(fnode) != EOK) {
    276302                ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
     303                // TODO This will try to free our data!
    277304                ddf_fun_destroy(fnode);
    278305                return false;
Note: See TracChangeset for help on using the changeset viewer.