1 /* 2 * Clock and power management. This exposes the combined functionality 3 * provided by the X1600 and related SoCs. The power management 4 * functionality could be exposed using a separate driver. 5 * 6 * Copyright (C) 2017, 2018, 2020, 2021, 2023, 7 * 2024 Paul Boddie <paul@boddie.org.uk> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation; either version 2 of 12 * the License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * Boston, MA 02110-1301, USA 23 */ 24 25 #include <l4/devices/hw_mmio_register_block.h> 26 #include "cpm-x1600.h" 27 28 29 30 // Register locations. 31 32 enum Regs : unsigned 33 { 34 Clock_control = 0x000, // CPCCR 35 Low_power_control = 0x004, // LCR 36 Clock_gate0 = 0x020, // CLKGR0 37 Clock_gate1 = 0x028, // CLKGR1 38 Sleep_control = 0x024, // OPCR (oscillator and power control) 39 Clock_status = 0x0d4, // CPCSR 40 41 Divider_can0 = 0x0a0, // CAN0CDR 42 Divider_can1 = 0x0a8, // CAN1CDR 43 Divider_cdbus = 0x0ac, // CDBUSCDR 44 Divider_cim = 0x078, // CIMCDR 45 Divider_ddr = 0x02c, // DDRCDR 46 Divider_mac = 0x054, // MACCDR 47 Divider0_i2s0 = 0x060, // I2S0CDR 48 Divider1_i2s0 = 0x070, // I2S0CDR1 49 Divider0_i2s1 = 0x07c, // I2S1CDR (from X2000 manual) 50 Divider1_i2s1 = 0x080, // I2S1CDR1 (from X2000 manual) 51 Divider_lcd = 0x064, // LPCDR 52 Divider_macphy0 = 0x0e4, // MPHY0C 53 Divider_msc0 = 0x068, // MSC0CDR 54 Divider_msc1 = 0x0a4, // MSC1CDR 55 Divider_pwm = 0x06c, // PWMCDR 56 Divider_sfc = 0x074, // SFCCDR 57 Divider_ssi = 0x05c, // SSICDR 58 59 Cpm_interrupt = 0x0b0, // CPM_INTR 60 Cpm_interrupt_en = 0x0b4, // CPM_INTRE 61 Cpm_swi = 0x0bc, // CPM_SFTINT 62 Cpm_scratch = 0x034, // CPSPR 63 Cpm_scratch_prot = 0x038, // CPSPPR 64 65 Gate_ddr = 0x0d0, // DRCG 66 67 Usb_param_control0 = 0x03c, // USBPCR 68 Usb_reset_detect = 0x040, // USBRDT 69 Usb_vbus_jitter = 0x044, // USBVBFIL 70 Usb_param_control1 = 0x048, // USBPCR1 71 72 Pll_control = 0x00c, // CPPCR 73 Pll_control_A = 0x010, // CPAPCR 74 Pll_control_M = 0x014, // CPMPCR 75 Pll_control_E = 0x018, // CPEPCR 76 Pll_fraction_A = 0x084, // CPAPACR 77 Pll_fraction_M = 0x088, // CPMPACR 78 Pll_fraction_E = 0x08c, // CPEPACR 79 }; 80 81 82 83 // Register field definitions. 84 85 static Field Clock_source_main (Clock_control, 3, 30), // SEL_SRC (output to SCLK_A) 86 Clock_source_cpu (Clock_control, 3, 28), // SEL_CPLL (output to CCLK) 87 Clock_source_hclock0 (Clock_control, 3, 26), // SEL_H0PLL (output to AHB0) 88 Clock_source_hclock2 (Clock_control, 3, 24), // SEL_H2PLL (output to AHB2) 89 Clock_source_can0 (Divider_can0, 3, 30), // CA0CS 90 Clock_source_can1 (Divider_can1, 3, 30), // CA1CS 91 Clock_source_cdbus (Divider_cdbus, 3, 30), // CDCS 92 Clock_source_cim (Divider_cim, 3, 30), // CIMPCS 93 Clock_source_ddr (Divider_ddr, 3, 30), // DCS 94 Clock_source_i2s0 (Divider0_i2s0, 1, 30), // I2PCS 95 Clock_source_i2s1 (Divider0_i2s1, 1, 30), // I2PCS 96 Clock_source_lcd (Divider_lcd, 3, 30), // LPCS 97 Clock_source_mac (Divider_mac, 3, 30), // MACPCS 98 Clock_source_msc0 (Divider_msc0, 3, 30), // MPCS 99 Clock_source_msc1 (Divider_msc1, 3, 30), // MPCS 100 Clock_source_pwm (Divider_pwm, 3, 30), // PWMPCS 101 Clock_source_rtc (Sleep_control, 0x01, 2), // ERCS 102 Clock_source_sfc (Divider_sfc, 3, 30), // SFCS 103 Clock_source_ssi (Divider_ssi, 3, 30), // SPCS 104 105 Clock_busy_cpu (Clock_status, 1, 0), 106 Clock_busy_hclock0 (Clock_status, 1, 1), 107 Clock_busy_hclock2 (Clock_status, 1, 2), 108 Clock_busy_ddr (Divider_ddr, 1, 28), 109 Clock_busy_mac (Divider_mac, 1, 28), 110 Clock_busy_lcd (Divider_lcd, 1, 28), 111 Clock_busy_msc0 (Divider_msc0, 1, 28), 112 Clock_busy_msc1 (Divider_msc1, 1, 28), 113 Clock_busy_sfc (Divider_sfc, 1, 28), 114 Clock_busy_ssi (Divider_ssi, 1, 28), 115 Clock_busy_cim (Divider_cim, 1, 28), 116 Clock_busy_pwm (Divider_pwm, 1, 28), 117 Clock_busy_can0 (Divider_can0, 1, 28), 118 Clock_busy_can1 (Divider_can1, 1, 28), 119 Clock_busy_cdbus (Divider_cdbus, 1, 28), 120 121 Clock_change_enable_cpu (Clock_control, 1, 22), 122 Clock_change_enable_ahb0 (Clock_control, 1, 21), 123 Clock_change_enable_ahb2 (Clock_control, 1, 20), 124 Clock_change_enable_ddr (Divider_ddr, 1, 29), 125 Clock_change_enable_mac (Divider_mac, 1, 29), 126 Clock_gate_i2s0 (Divider0_i2s0, 1, 29), // CE_I2S is gate, not change enable 127 Clock_gate_i2s1 (Divider0_i2s1, 1, 29), // CE_I2S is gate, not change enable 128 Clock_change_enable_lcd (Divider_lcd, 1, 29), 129 Clock_change_enable_msc0 (Divider_msc0, 1, 29), 130 Clock_change_enable_msc1 (Divider_msc1, 1, 29), 131 Clock_change_enable_sfc (Divider_sfc, 1, 29), 132 Clock_change_enable_ssi (Divider_ssi, 1, 29), 133 Clock_change_enable_cim (Divider_cim, 1, 29), 134 Clock_change_enable_pwm (Divider_pwm, 1, 29), 135 Clock_change_enable_can0 (Divider_can0, 1, 29), 136 Clock_change_enable_can1 (Divider_can1, 1, 29), 137 Clock_change_enable_cdbus (Divider_cdbus, 1, 29), 138 139 Clock_divider_cpu (Clock_control, 0x0f, 0), // CDIV 140 Clock_divider_hclock0 (Clock_control, 0x0f, 8), // H0DIV (fast AHB peripherals) 141 Clock_divider_hclock2 (Clock_control, 0x0f, 12), // H2DIV (fast AHB peripherals) 142 Clock_divider_l2cache (Clock_control, 0x0f, 4), // L2CDIV 143 Clock_divider_pclock (Clock_control, 0x0f, 16), // PDIV (slow APB peripherals) 144 Clock_divider_can0 (Divider_can0, 0xff, 0), // CAN0CDR 145 Clock_divider_can1 (Divider_can1, 0xff, 0), // CAN1CDR 146 Clock_divider_cdbus (Divider_cdbus, 0xff, 0), // CDBUSCDR 147 Clock_divider_cim (Divider_cim, 0xff, 0), // CIMCDR 148 Clock_divider_ddr (Divider_ddr, 0x0f, 0), // DDRCDR 149 Clock_divider_i2s0_m (Divider0_i2s0, 0x1ff, 20), // I2SDIV_M 150 Clock_divider_i2s0_n (Divider0_i2s0, 0xfffff, 0), // I2SDIV_N 151 Clock_divider_i2s0_d (Divider1_i2s0, 0xfffff, 0), // I2SDIV_D 152 Clock_divider_i2s1_m (Divider0_i2s1, 0x1ff, 20), // I2SDIV_M 153 Clock_divider_i2s1_n (Divider0_i2s1, 0xfffff, 0), // I2SDIV_N 154 Clock_divider_i2s1_d (Divider1_i2s1, 0xfffff, 0), // I2SDIV_D 155 Clock_divider_lcd (Divider_lcd, 0xff, 0), // LPCDR 156 Clock_divider_mac (Divider_mac, 0xff, 0), // MACCDR 157 Clock_divider_msc0 (Divider_msc0, 0xff, 0), // MSC0CDR 158 Clock_divider_msc1 (Divider_msc1, 0xff, 0), // MSC1CDR 159 Clock_divider_pwm (Divider_pwm, 0x0f, 0), // PWMCDR 160 Clock_divider_sfc (Divider_sfc, 0xff, 0), // SFCCDR 161 Clock_divider_ssi (Divider_ssi, 0xff, 0), // SSICDR 162 163 Clock_divider_i2s0_n_auto (Divider1_i2s0, 1, 31), // I2S_NEN 164 Clock_divider_i2s0_d_auto (Divider1_i2s0, 1, 30), // I2S_DEN 165 Clock_divider_i2s1_n_auto (Divider1_i2s1, 1, 31), // I2S_NEN 166 Clock_divider_i2s1_d_auto (Divider1_i2s1, 1, 30), // I2S_DEN 167 168 Clock_gate_main (Clock_control, 1, 23, true), // GATE_SCLKA 169 Clock_gate_ddr (Clock_gate0, 1, 31, true), // DDR 170 Clock_gate_ahb0 (Clock_gate0, 1, 29, true), // AHB0 171 Clock_gate_apb0 (Clock_gate0, 1, 28, true), // APB0 172 Clock_gate_rtc (Clock_gate0, 1, 27, true), // RTC 173 Clock_gate_aes (Clock_gate0, 1, 24, true), // AES 174 Clock_gate_lcd_pixel (Clock_gate0, 1, 23, true), // LCD 175 Clock_gate_cim (Clock_gate0, 1, 22, true), // CIM 176 Clock_gate_dma (Clock_gate0, 1, 21, true), // PDMA 177 Clock_gate_ost (Clock_gate0, 1, 20, true), // OST 178 Clock_gate_ssi0 (Clock_gate0, 1, 19, true), // SSI0 179 Clock_gate_timer (Clock_gate0, 1, 18, true), // TCU 180 Clock_gate_dtrng (Clock_gate0, 1, 17, true), // DTRNG 181 Clock_gate_uart2 (Clock_gate0, 1, 16, true), // UART2 182 Clock_gate_uart1 (Clock_gate0, 1, 15, true), // UART1 183 Clock_gate_uart0 (Clock_gate0, 1, 14, true), // UART0 184 Clock_gate_sadc (Clock_gate0, 1, 13, true), // SADC 185 Clock_gate_aic (Clock_gate0, 1, 11, true), // AUDIO 186 Clock_gate_ssi_slv (Clock_gate0, 1, 10, true), // SSI_SLV 187 Clock_gate_i2c1 (Clock_gate0, 1, 8, true), // I2C1 188 Clock_gate_i2c0 (Clock_gate0, 1, 7, true), // I2C0 189 Clock_gate_msc1 (Clock_gate0, 1, 5, true), // MSC1 190 Clock_gate_msc0 (Clock_gate0, 1, 4, true), // MSC0 191 Clock_gate_otg (Clock_gate0, 1, 3, true), // OTG 192 Clock_gate_sfc (Clock_gate0, 1, 2, true), // SFC 193 Clock_gate_efuse (Clock_gate0, 1, 1, true), // EFUSE 194 Clock_gate_nemc (Clock_gate0, 1, 0, true), // NEMC 195 Clock_gate_arb (Clock_gate1, 1, 30, true), // ARB 196 Clock_gate_mipi_csi (Clock_gate1, 1, 28, true), // MIPI_CSI 197 Clock_gate_intc (Clock_gate1, 1, 26, true), // INTC 198 Clock_gate_gmac0 (Clock_gate1, 1, 23, true), // GMAC0 199 Clock_gate_uart3 (Clock_gate1, 1, 16, true), // UART3 200 Clock_gate_i2s0_tx (Clock_gate1, 1, 9, true), // I2S0_dev_tclk 201 Clock_gate_i2s0_rx (Clock_gate1, 1, 8, true), // I2S0_dev_rclk 202 Clock_gate_hash (Clock_gate1, 1, 6, true), // HASH 203 Clock_gate_pwm (Clock_gate1, 1, 5, true), // PWM 204 Clock_gate_cdbus (Clock_gate1, 1, 2, true), // CDBUS 205 Clock_gate_can1 (Clock_gate1, 1, 1, true), // CAN1 206 Clock_gate_can0 (Clock_gate1, 1, 0, true), // CAN0 207 Clock_gate_usb_phy (Sleep_control, 1, 23, true), // gate_usbphy_clk 208 209 Pll_enable_A (Pll_control_A, 1, 0), // APLLEN 210 Pll_enable_E (Pll_control_E, 1, 0), // EPLLEN 211 Pll_enable_M (Pll_control_M, 1, 0), // MPLLEN 212 213 Pll_stable_A (Pll_control_A, 1, 3), // APLL_ON 214 Pll_stable_E (Pll_control_E, 1, 3), // EPLL_ON 215 Pll_stable_M (Pll_control_M, 1, 3), // MPLL_ON 216 217 Pll_bypass_A (Pll_control_A, 1, 30), // APLL_BP 218 Pll_bypass_E (Pll_control_E, 1, 26), // EPLL_BP 219 Pll_bypass_M (Pll_control_M, 1, 28), // MPLL_BP 220 221 Pll_multiplier_A (Pll_control_A, 0xfff, 20), // APLLM 222 Pll_multiplier_E (Pll_control_E, 0x3f, 20), // EPLLM (observed) 223 Pll_multiplier_M (Pll_control_M, 0xfff, 20), // MPLLM 224 225 Pll_input_division_A (Pll_control_A, 0x3f, 14), // APLLN 226 Pll_input_division_E (Pll_control_E, 0x3f, 14), // EPLLN 227 Pll_input_division_M (Pll_control_M, 0x3f, 14), // MPLLN 228 229 Pll_output_division1_A (Pll_control_A, 0x07, 11), // APLLOD1 230 Pll_output_division1_E (Pll_control_E, 0x07, 11), // EPLLOD1 231 Pll_output_division1_M (Pll_control_M, 0x07, 11), // MPLLOD1 232 233 Pll_output_division0_A (Pll_control_A, 0x07, 8), // APLLOD0 234 Pll_output_division0_E (Pll_control_E, 0x07, 8), // EPLLOD0 235 Pll_output_division0_M (Pll_control_M, 0x07, 8); // MPLLOD0 236 237 238 239 // Multiplexer instances. 240 241 #define Clocks(...) ((enum Clock_identifiers []) {__VA_ARGS__}) 242 #define Specific(CLOCK) ((enum Clock_identifiers) (CLOCK)) 243 244 static Mux mux_external (Clock_external), 245 246 // Clocks being propagated to others. 247 248 mux_hclock0 (Clock_hclock0), 249 mux_hclock2 (Clock_hclock2), 250 mux_pclock (Clock_pclock), 251 mux_hclock2_pclock (Clock_hclock2_pclock), 252 mux_i2s0_rx (Clock_i2s0), 253 mux_i2s0_tx (Clock_i2s1), 254 mux_usb_phy (Specific(Clock_usb_phy_12MHz)), 255 256 // Main peripheral and bus clock sources. 257 258 mux_bus (4, Clocks(Clock_main, Clock_pll_M, Clock_pll_E, Clock_external)), 259 mux_core (3, Clocks(Clock_none, Clock_main, Clock_pll_M)), 260 mux_dev (3, Clocks(Clock_main, Clock_pll_M, Clock_pll_E)), 261 mux_main (3, Clocks(Clock_none, Clock_external, Clock_pll_A)), 262 mux_i2s (2, Clocks(Clock_main, Clock_pll_E)), 263 mux_rtc (2, Clocks(Clock_external_div_512, Clock_rtc_external)); 264 265 266 267 // Clock instances. 268 269 static Clock_null clock_none; 270 271 static Clock_passive clock_external(24000000), 272 clock_rtc_external(32768), 273 clock_usb_phy_12MHz(12000000); 274 275 // Note the use of extra parentheses due to the annoying C++ "most vexing parse" 276 // problem. See: https://en.wikipedia.org/wiki/Most_vexing_parse 277 278 static Clock clock_aic((Source(mux_hclock2)), (Control(Clock_gate_aic))), 279 280 clock_dma((Source(mux_hclock2)), (Control(Clock_gate_dma))), 281 282 clock_i2c0((Source(mux_pclock)), (Control(Clock_gate_i2c0))), 283 284 clock_i2c1((Source(mux_pclock)), (Control(Clock_gate_i2c1))), 285 286 clock_i2s0(Source(mux_i2s, Clock_source_i2s0), Control(Clock_gate_i2s0)), 287 288 clock_i2s1(Source(mux_i2s, Clock_source_i2s1), Control(Clock_gate_i2s1)), 289 290 clock_main(Source(mux_main, Clock_source_main), Control(Clock_gate_main)), 291 292 clock_mipi_csi((Source(mux_hclock0)), Control(Clock_gate_mipi_csi)), 293 294 clock_nemc((Source(mux_hclock2)), (Control(Clock_gate_nemc))), 295 296 clock_otg0((Source(mux_hclock2)), (Control(Clock_gate_otg))), 297 298 clock_rtc(Source(mux_rtc, Clock_source_rtc), (Control(Clock_gate_rtc))), 299 300 clock_sadc((Source(mux_hclock2)), (Control(Clock_gate_sadc))), 301 302 // Input pins can also be configured for the timer. 303 // NOTE: Support the prescaling for EXCLK. 304 305 clock_timer((Source(mux_external)), (Control(Clock_gate_timer))), 306 307 clock_uart0((Source(mux_external)), (Control(Clock_gate_uart0))), 308 309 clock_uart1((Source(mux_external)), (Control(Clock_gate_uart1))), 310 311 clock_uart2((Source(mux_external)), (Control(Clock_gate_uart2))), 312 313 clock_uart3((Source(mux_external)), (Control(Clock_gate_uart3))), 314 315 clock_usb_phy((Source(mux_usb_phy)), (Control(Clock_gate_usb_phy))), 316 317 // Special parent clock for hclock2 and pclock. 318 319 clock_hclock2_pclock(Source(mux_core, Clock_source_hclock2), 320 Control(Clock_gate_apb0, Clock_change_enable_ahb2)); 321 322 static Clock_divided 323 clock_can0(Source(mux_bus, Clock_source_can0), 324 Control(Clock_gate_can0, Clock_change_enable_can0, Clock_busy_can0), 325 Divider(Clock_divider_can0)), 326 327 clock_can1(Source(mux_bus, Clock_source_can1), 328 Control(Clock_gate_can1, Clock_change_enable_can1, Clock_busy_can1), 329 Divider(Clock_divider_can1)), 330 331 clock_cdbus(Source(mux_dev, Clock_source_cdbus), 332 Control(Clock_gate_cdbus, Clock_change_enable_cdbus, Clock_busy_cdbus), 333 Divider(Clock_divider_cdbus)), 334 335 clock_cim(Source(mux_dev, Clock_source_cim), 336 Control(Clock_gate_cim, Clock_change_enable_cim, Clock_busy_cim), 337 Divider(Clock_divider_cim)), 338 339 clock_cpu(Source(mux_core, Clock_source_cpu), 340 Control(Field::undefined, Clock_change_enable_cpu, Clock_busy_cpu), 341 Divider(Clock_divider_cpu)), 342 343 clock_ddr(Source(mux_core, Clock_source_ddr), 344 Control(Clock_gate_ddr, Clock_change_enable_ddr, Clock_busy_ddr), 345 Divider(Clock_divider_ddr)), 346 347 clock_hclock0(Source(mux_core, Clock_source_hclock0), 348 Control(Clock_gate_ahb0, Clock_change_enable_ahb0), 349 Divider(Clock_divider_hclock0)), 350 351 clock_hclock2((Source(mux_hclock2_pclock)), (Divider(Clock_divider_hclock2))), 352 353 clock_l2cache(Source(mux_core, Clock_source_cpu), 354 Control(Field::undefined, Clock_change_enable_cpu, Clock_busy_cpu), 355 Divider(Clock_divider_l2cache)), 356 357 clock_lcd_pixel(Source(mux_dev, Clock_source_lcd), 358 Control(Clock_gate_lcd_pixel, Clock_change_enable_lcd, Clock_busy_lcd), 359 Divider(Clock_divider_lcd)), 360 361 clock_mac(Source(mux_dev, Clock_source_mac), 362 Control(Clock_gate_gmac0, Clock_change_enable_mac, Clock_busy_mac), 363 Divider(Clock_divider_mac)), 364 365 clock_msc0(Source(mux_dev, Clock_source_msc0), 366 Control(Clock_gate_msc0, Clock_change_enable_msc0, Clock_busy_msc0), 367 Divider(Clock_divider_msc0, 2)), 368 369 clock_msc1(Source(mux_dev, Clock_source_msc1), 370 Control(Clock_gate_msc1, Clock_change_enable_msc1, Clock_busy_msc1), 371 Divider(Clock_divider_msc1, 2)), 372 373 clock_pclock((Source(mux_hclock2_pclock)), (Divider(Clock_divider_pclock))), 374 375 clock_pwm0(Source(mux_dev, Clock_source_pwm), 376 Control(Clock_gate_pwm, Clock_change_enable_pwm, Clock_busy_pwm), 377 Divider(Clock_divider_pwm)), 378 379 clock_sfc(Source(mux_dev, Clock_source_sfc), 380 Control(Clock_gate_sfc, Clock_change_enable_sfc, Clock_busy_sfc), 381 Divider(Clock_divider_sfc)), 382 383 clock_ssi0(Source(mux_dev, Clock_source_ssi), 384 Control(Clock_gate_ssi0, Clock_change_enable_ssi, Clock_busy_ssi), 385 Divider(Clock_divider_ssi)); 386 387 static Clock_divided_fixed 388 clock_external_div_512((Source(mux_external)), (Divider_fixed(512))); 389 390 static Clock_divided_i2s 391 clock_i2s0_rx(Source(mux_i2s0_rx), 392 Control(Clock_gate_i2s0_rx), 393 Divider_i2s(Clock_divider_i2s0_m, Clock_divider_i2s0_n, 394 Clock_divider_i2s0_d, Clock_divider_i2s0_n_auto, 395 Clock_divider_i2s0_d_auto)), 396 397 clock_i2s0_tx(Source(mux_i2s0_tx), 398 Control(Clock_gate_i2s0_tx), 399 Divider_i2s(Clock_divider_i2s1_m, Clock_divider_i2s1_n, 400 Clock_divider_i2s1_d, Clock_divider_i2s1_n_auto, 401 Clock_divider_i2s1_d_auto)); 402 403 const double x1600_pll_intermediate_min = 600000000, 404 x1600_pll_intermediate_max = 2400000000; 405 406 static Pll clock_pll_A(Source(mux_external), 407 Control_pll(Pll_enable_A, Pll_stable_A, Pll_bypass_A), 408 Divider_pll(Pll_multiplier_A, Pll_input_division_A, 409 Pll_output_division0_A, Pll_output_division1_A, 410 x1600_pll_intermediate_min, x1600_pll_intermediate_max)), 411 412 clock_pll_E(Source(mux_external), 413 Control_pll(Pll_enable_E, Pll_stable_E, Pll_bypass_E), 414 Divider_pll(Pll_multiplier_E, Pll_input_division_E, 415 Pll_output_division0_E, Pll_output_division1_E, 416 x1600_pll_intermediate_min, x1600_pll_intermediate_max)), 417 418 clock_pll_M(Source(mux_external), 419 Control_pll(Pll_enable_M, Pll_stable_M, Pll_bypass_M), 420 Divider_pll(Pll_multiplier_M, Pll_input_division_M, 421 Pll_output_division0_M, Pll_output_division1_M, 422 x1600_pll_intermediate_min, x1600_pll_intermediate_max)); 423 424 425 426 // Clock register. 427 428 static Clock_base *clocks[Clock_x1600_identifier_count] = { 429 &clock_none, 430 431 &clock_aic, 432 &clock_none, // Clock_aic_bitclk 433 &clock_none, // Clock_aic_pclk 434 &clock_can0, 435 &clock_can1, 436 &clock_cdbus, 437 &clock_cim, 438 &clock_cpu, 439 &clock_ddr, 440 &clock_dma, 441 &clock_none, // Clock_emac 442 &clock_external, 443 &clock_external_div_512, 444 &clock_hclock0, 445 &clock_hclock2, 446 &clock_hclock2_pclock, 447 &clock_none, // Clock_hdmi 448 &clock_i2c0, 449 &clock_i2c1, 450 &clock_none, // Clock_i2c2 451 &clock_none, // Clock_i2c3 452 &clock_none, // Clock_i2c4 453 &clock_i2s0, // supplies i2s0_rx 454 &clock_i2s0_rx, 455 &clock_i2s0_tx, 456 &clock_i2s1, // supplies i2s0_tx 457 &clock_none, // Clock_i2s1_rx 458 &clock_none, // Clock_i2s1_tx 459 &clock_none, // Clock_kbc 460 &clock_l2cache, 461 &clock_none, // Clock_lcd 462 &clock_lcd_pixel, 463 &clock_none, // Clock_lcd_pixel1 464 &clock_mac, 465 &clock_main, 466 &clock_mipi_csi, 467 &clock_none, // Clock_msc 468 &clock_msc0, 469 &clock_msc1, 470 &clock_none, // Clock_msc2 471 &clock_nemc, 472 &clock_otg0, 473 &clock_none, // Clock_otg1 474 &clock_pclock, 475 &clock_none, // Clock_pcm 476 &clock_pll_A, 477 &clock_pll_E, 478 &clock_pll_M, 479 &clock_none, // Clock_pll_V 480 &clock_pwm0, 481 &clock_none, // Clock_pwm1 482 &clock_rtc, 483 &clock_rtc_external, 484 &clock_sadc, 485 &clock_none, // Clock_scc 486 &clock_sfc, 487 &clock_none, // Clock_ssi 488 &clock_ssi0, 489 &clock_none, // Clock_ssi1 490 &clock_none, // Clock_ssi2 491 &clock_timer, 492 &clock_uart0, 493 &clock_uart1, 494 &clock_uart2, 495 &clock_uart3, 496 &clock_none, // Clock_uart4 497 &clock_none, // Clock_udc 498 &clock_none, // Clock_uhc 499 &clock_none, // Clock_uprt 500 &clock_usb_phy, 501 &clock_none, // Clock_vpu 502 503 /* X1600-specific clocks. */ 504 505 &clock_usb_phy_12MHz, 506 }; 507 508 509 510 // Peripheral abstraction. 511 512 Cpm_x1600_chip::Cpm_x1600_chip(l4_addr_t addr) 513 : Cpm_chip(addr, clocks) 514 { 515 } 516 517 518 519 // C language interface functions. 520 521 void 522 *x1600_cpm_init(l4_addr_t cpm_base) 523 { 524 return (void *) new Cpm_x1600_chip(cpm_base); 525 } 526 527 const char * 528 x1600_cpm_clock_type(void *cpm, enum Clock_identifiers clock) 529 { 530 return static_cast<Cpm_x1600_chip *>(cpm)->clock_type(clock); 531 } 532 533 int 534 x1600_cpm_have_clock(void *cpm, enum Clock_identifiers clock) 535 { 536 return static_cast<Cpm_x1600_chip *>(cpm)->have_clock(clock); 537 } 538 539 void 540 x1600_cpm_start_clock(void *cpm, enum Clock_identifiers clock) 541 { 542 static_cast<Cpm_x1600_chip *>(cpm)->start_clock(clock); 543 } 544 545 void 546 x1600_cpm_stop_clock(void *cpm, enum Clock_identifiers clock) 547 { 548 static_cast<Cpm_x1600_chip *>(cpm)->stop_clock(clock); 549 } 550 551 int 552 x1600_cpm_get_parameters(void *cpm, enum Clock_identifiers clock, uint32_t parameters[]) 553 { 554 return static_cast<Cpm_x1600_chip *>(cpm)->get_parameters(clock, parameters); 555 } 556 557 int 558 x1600_cpm_set_parameters(void *cpm, enum Clock_identifiers clock, int num_parameters, uint32_t parameters[]) 559 { 560 return static_cast<Cpm_x1600_chip *>(cpm)->set_parameters(clock, num_parameters, parameters); 561 } 562 563 uint8_t 564 x1600_cpm_get_source(void *cpm, enum Clock_identifiers clock) 565 { 566 return static_cast<Cpm_x1600_chip *>(cpm)->get_source(clock); 567 } 568 569 void 570 x1600_cpm_set_source(void *cpm, enum Clock_identifiers clock, uint8_t source) 571 { 572 static_cast<Cpm_x1600_chip *>(cpm)->set_source(clock, source); 573 } 574 575 enum Clock_identifiers 576 x1600_cpm_get_source_clock(void *cpm, enum Clock_identifiers clock) 577 { 578 return static_cast<Cpm_x1600_chip *>(cpm)->get_source_clock(clock); 579 } 580 581 void 582 x1600_cpm_set_source_clock(void *cpm, enum Clock_identifiers clock, enum Clock_identifiers source) 583 { 584 static_cast<Cpm_x1600_chip *>(cpm)->set_source_clock(clock, source); 585 } 586 587 uint64_t 588 x1600_cpm_get_source_frequency(void *cpm, enum Clock_identifiers clock) 589 { 590 return static_cast<Cpm_x1600_chip *>(cpm)->get_source_frequency(clock); 591 } 592 593 uint64_t 594 x1600_cpm_get_frequency(void *cpm, enum Clock_identifiers clock) 595 { 596 return static_cast<Cpm_x1600_chip *>(cpm)->get_frequency(clock); 597 } 598 599 int 600 x1600_cpm_set_frequency(void *cpm, enum Clock_identifiers clock, uint64_t frequency) 601 { 602 return static_cast<Cpm_x1600_chip *>(cpm)->set_frequency(clock, frequency); 603 }