Changeset 52e020b in mainline for uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
- Timestamp:
- 2012-11-19T16:07:27Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 68338c6
- Parents:
- bfc6e11
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
rbfc6e11 r52e020b 51 51 #include "cm/clock_control.h" 52 52 #include "cm/usbhost.h" 53 #include "prm/clock_control.h" 53 54 54 55 #define NAME "rootamdm37x" … … 62 63 usbhost_cm_regs_t *usbhost; 63 64 } cm; 65 struct { 66 clock_control_prm_regs_t *clocks; 67 } prm; 64 68 } amdm37x_t; 65 69 … … 87 91 ret = pio_enable((void*)CLOCK_CONTROL_CM_BASE_ADDRESS, 88 92 CLOCK_CONTROL_CM_SIZE, (void**)&device->cm.clocks); 93 if (ret != EOK) 94 return ret; 95 96 ret = pio_enable((void*)CLOCK_CONTROL_PRM_BASE_ADDRESS, 97 CLOCK_CONTROL_PRM_SIZE, (void**)&device->prm.clocks); 89 98 if (ret != EOK) 90 99 return ret; … … 106 115 pio_trace_enable(device->cm.usbhost, USBHOST_CM_SIZE, log, (void*)USBHOST_CM_BASE_ADDRESS); 107 116 pio_trace_enable(device->uhh, AMDM37x_UHH_SIZE, log, (void*)AMDM37x_UHH_BASE_ADDRESS); 117 pio_trace_enable(device->prm.clocks, CLOCK_CONTROL_PRM_SIZE, log, (void*)CLOCK_CONTROL_PRM_BASE_ADDRESS); 108 118 } 109 119 return EOK; 110 120 } 111 121 112 /** Set DPLL3,4,5 to autoidle 122 123 124 /** Set DPLLs 1,2,3,4,5 to ON (locked) and autoidle. 113 125 * @param device Register map. 114 */ 115 static void dpll_autoidle(amdm37x_t *device) 126 * 127 * The idea is to get all DPLLs running and make hw control their power mode, 128 * based on the module requirements (module ICLKs and FCLKs). 129 */ 130 static void dpll_on_autoidle(amdm37x_t *device) 116 131 { 117 132 assert(device); 118 /* Set DPLL3 to automatic */ 133 /* Get SYS_CLK value, it is used as reference clock by all DPLLs */ 134 const unsigned base_clk = pio_read_32(&device->prm.clocks->clksel) 135 & CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK; 136 const unsigned base_freq = sys_clk_freq_kHz(base_clk); 137 ddf_msg(LVL_DEBUG, "Base frequency: %d.%dMhz", 138 base_freq / 1000, base_freq % 1000); 139 140 141 /* DPLL1 provides MPU(CPU) clock. 142 * It uses SYS_CLK as reference clock and core clock (DPLL3) as 143 * high frequency bypass (MPU then runs on L3 interconnect freq). 144 * It should be setup by fw or u-boot.*/ 145 // TODO: set to autoidle to save power. 146 // TODO: compute current MPU frequency. 147 148 /* DPLL2 provides IVA(video acceleration) clock. 149 * It uses SYS_CLK as reference clokc and core clock (DPLL3) as 150 * high frequency bypass (IVA runs on L3 freq). 151 */ 152 // TODO: We can probably turn this off entirely. IVA is left unused. 153 // TODO: Set at least to autoidle to save power 154 155 /* DPLL3 provides tons of clocks: 156 * CORE_CLK, COREX2_CLK, DSS_TV_CLK, 12M_CLK, 48M_CLK, 96M_CLK, L3_ICLK, 157 * and L4_ICLK. It uses SYS_CLK as reference clock and low frequency 158 * bypass. It should be setup by fw or u-boot as it controls critical 159 * interconnects. 160 */ 161 162 /* Set DPLL3 to automatic to save power */ 119 163 pio_change_32(&device->cm.clocks->autoidle_pll, 120 164 CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC, 121 165 CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_MASK, 5); 122 166 123 /* Set DPLL4 to automatic */ 167 /* DPLL4 provides peripheral domain clocks: 168 * CAM_MCLK, EMU_PER_ALWON_CLK, DSS1_ALWON_FCLK, and 96M_ALWON_FCLK. 169 * It uses SYS_CLK as reference clock and low frequency bypass. 170 * 96M clock is used by McBSP[1,5], MMC[1,2,3], I2C[1,2,3], so 171 * we can probably turn this off entirely (DSS is still non-functional). 172 */ 173 /* Set DPLL4 to automatic to save power*/ 124 174 pio_change_32(&device->cm.clocks->autoidle_pll, 125 175 CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_AUTOMATIC, 126 176 CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_MASK, 5); 127 177 178 /* DPLL5 provide peripheral domain clocks: 120M_FCLK. 179 * It uses SYS_CLK as reference clock and low frequency bypass. 180 * 120M clock is used by HS USB and USB TLL. 181 */ 182 // TODO setup DPLL5 128 183 /* Set DPLL5 to automatic */ 129 184 pio_change_32(&device->cm.clocks->autoidle2_pll, … … 341 396 } 342 397 343 /* Set dplls to automatic */344 dpll_ autoidle(device);398 /* Set dplls to ON and automatic */ 399 dpll_on_autoidle(device); 345 400 346 401 /* Enable function and interface clocks */
Note:
See TracChangeset
for help on using the changeset viewer.