Ignore:
Timestamp:
2012-11-04T12:18:47Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
360823ca
Parents:
57912af3
Message:

rootamdm37x: Minor refactoring.

File:
1 edited

Legend:

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

    r57912af3 re5e2d73  
    112112}
    113113
    114 static int usb_clocks(amdm37x_t *device, bool on)
    115 {
     114/** Set DPLL3,4,5 to autoidle
     115 * @param device Register map.
     116 */
     117static void dpll_autoidle(amdm37x_t *device)
     118{
     119        assert(device);
    116120        /* Set DPLL3 to automatic */
    117121        pio_change_32(&device->cm.clocks->autoidle_pll,
     
    128132            CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC,
    129133            CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK, 5);
    130 
    131 
    132 #ifdef DEBUG_CM
    133         printf("DPLL5 could be on: %"PRIx32" %"PRIx32".\n",
    134             pio_read_32((ioport32_t*)&device->cm.clocks->idlest_ckgen),
    135             pio_read_32((ioport32_t*)&device->cm.clocks->idlest2_ckgen));
    136 #endif
    137 
     134}
     135
     136/** Enable/disable function and interface clocks for USBTLL and USBHOST.
     137 * @param device Register map.
     138 * @param on True to swoitch clocks on.
     139 */
     140static void usb_clocks_enable(amdm37x_t *device, bool on)
     141{
    138142        if (on) {
    139143                /* Enable interface and function clock for USB TLL */
     
    168172                    CORE_CM_FCLKEN3_EN_USBTLL_FLAG, 5);
    169173        }
    170 
    171         return EOK;
    172174}
    173175
     
    179181static int usb_tll_init(amdm37x_t *device)
    180182{
    181 
    182183        /* Reset USB TLL */
    183184        pio_set_32(&device->tll->sysconfig, TLL_SYSCONFIG_SOFTRESET_FLAG, 5);
     
    340341        }
    341342
    342         ret = usb_clocks(device, true);
    343         if (ret != EOK) {
    344                 ddf_msg(LVL_FATAL, "Failed to enable USB HC clocks!.\n");
    345                 return ret;
    346         }
    347 
     343        /* Set dplls to automatic */
     344        dpll_autoidle(device);
     345
     346        /* Enable function and interface clocks */
     347        usb_clocks_enable(device, true);
     348
     349        /* Init TLL */
    348350        ret = usb_tll_init(device);
    349351        if (ret != EOK) {
    350352                ddf_msg(LVL_FATAL, "Failed to init USB TLL!.\n");
    351                 usb_clocks(device, false);
     353                usb_clocks_enable(device, false);
    352354                return ret;
    353355        }
Note: See TracChangeset for help on using the changeset viewer.