Lines Matching +full:clock +full:- +full:freq
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
56 * This file defines the clock configuration for the OMAP4xxx series of
61 * - There is a top level omap_prcm module that defines all OMAP SoC drivers
65 * configuring the clock - this file is the 'donkey' for OMAP44xx devices.
67 * - The key bit in this file is the omap_clk_devmap array, it's
71 * - In essence you just need to define some callbacks for each of the
74 * - The other thing that is worth noting is that when the omap_prcm device
78 * individual clock callback handlers.
83 * is no longer a separate functional and interface clock for each module,
84 * instead there is typically an interface clock that spans many modules.
97 * Address offsets from the PRM memory region to the top level clock control
125 * Address offsets from the CM1 memory region to the top level clock control
138 * Address offsets from the CM2 memory region to the top level clock control
166 {"ti,omap4-cm1", (uintptr_t)CM1_INSTANCE},
167 {"ti,omap4-cm2", (uintptr_t)CM2_INSTANCE},
168 {"ti,omap4-prm", (uintptr_t)PRM_INSTANCE},
183 static int omap4_clk_generic_get_source_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
186 static int omap4_clk_gptimer_get_source_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
189 static int omap4_clk_hsmmc_get_source_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
196 static int omap4_clk_get_sysclk_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
197 static int omap4_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
200 * omap_clk_devmap - Array of clock devices available on OMAP4xxx devices
203 * for clock activate, deactivate, etc. It is used by the top level omap_prcm
328 * omap4_clk_details - Stores details for all the different clocks supported
330 * Whenever an operation on a clock is being performed (activated, deactivated,
366 OMAP4_GENERIC_CLOCK_DETAILS(TIMER1_CLK, -1, PRM_INSTANCE,
368 OMAP4_GENERIC_CLOCK_DETAILS(TIMER2_CLK, -1, CM2_INSTANCE,
370 OMAP4_GENERIC_CLOCK_DETAILS(TIMER3_CLK, -1, CM2_INSTANCE,
372 OMAP4_GENERIC_CLOCK_DETAILS(TIMER4_CLK, -1, CM2_INSTANCE,
374 OMAP4_GENERIC_CLOCK_DETAILS(TIMER5_CLK, -1, CM1_INSTANCE,
376 OMAP4_GENERIC_CLOCK_DETAILS(TIMER6_CLK, -1, CM1_INSTANCE,
378 OMAP4_GENERIC_CLOCK_DETAILS(TIMER7_CLK, -1, CM1_INSTANCE,
380 OMAP4_GENERIC_CLOCK_DETAILS(TIMER8_CLK, -1, CM1_INSTANCE,
382 OMAP4_GENERIC_CLOCK_DETAILS(TIMER9_CLK, -1, CM2_INSTANCE,
384 OMAP4_GENERIC_CLOCK_DETAILS(TIMER10_CLK, -1, CM2_INSTANCE,
386 OMAP4_GENERIC_CLOCK_DETAILS(TIMER11_CLK, -1, CM2_INSTANCE,
390 OMAP4_GENERIC_CLOCK_DETAILS(MMC1_CLK, -1, CM2_INSTANCE,
392 OMAP4_GENERIC_CLOCK_DETAILS(MMC2_CLK, -1, CM2_INSTANCE,
402 OMAP4_GENERIC_CLOCK_DETAILS(GPIO1_CLK, -1, PRM_INSTANCE,
404 OMAP4_GENERIC_CLOCK_DETAILS(GPIO2_CLK, -1, CM2_INSTANCE,
406 OMAP4_GENERIC_CLOCK_DETAILS(GPIO3_CLK, -1, CM2_INSTANCE,
408 OMAP4_GENERIC_CLOCK_DETAILS(GPIO4_CLK, -1, CM2_INSTANCE,
410 OMAP4_GENERIC_CLOCK_DETAILS(GPIO5_CLK, -1, CM2_INSTANCE,
412 OMAP4_GENERIC_CLOCK_DETAILS(GPIO6_CLK, -1, CM2_INSTANCE,
416 OMAP4_GENERIC_CLOCK_DETAILS(SDMA_CLK, -1, CM2_INSTANCE,
420 OMAP4_GENERIC_CLOCK_DETAILS(I2C1_CLK, -1, CM2_INSTANCE,
422 OMAP4_GENERIC_CLOCK_DETAILS(I2C2_CLK, -1, CM2_INSTANCE,
424 OMAP4_GENERIC_CLOCK_DETAILS(I2C3_CLK, -1, CM2_INSTANCE,
426 OMAP4_GENERIC_CLOCK_DETAILS(I2C4_CLK, -1, CM2_INSTANCE,
433 * MAX_MODULE_ENABLE_WAIT - the number of loops to wait for the module to come
440 * ARRAY_SIZE - Macro to return the number of elements in a static const array.
446 * omap4_clk_details - writes a 32-bit value to one of the timer registers
460 for (walker = g_omap4_clk_details; walker->id != INVALID_CLK_IDENT; walker++) { in omap4_clk_details()
461 if (id == walker->id) in omap4_clk_details()
482 if (sc->sc_instance == module_instance) in omap4_prcm_get_instance_softc()
490 * omap4_clk_generic_activate - checks if a module is accessible
511 clk_details = omap4_clk_details(clkdev->id); in omap4_clk_generic_activate()
516 sc = omap4_prcm_get_instance_softc(clk_details->instance); in omap4_clk_generic_activate()
520 clk_mem_res = sc->sc_res; in omap4_clk_generic_activate()
526 * generic - the have at least two fielda called MODULEMODE and IDLEST. in omap4_clk_generic_activate()
528 clksel = bus_read_4(clk_mem_res, clk_details->clksel_reg); in omap4_clk_generic_activate()
530 clksel |= clk_details->enable_mode; in omap4_clk_generic_activate()
531 bus_write_4(clk_mem_res, clk_details->clksel_reg, clksel); in omap4_clk_generic_activate()
539 clksel = bus_read_4(clk_mem_res, clk_details->clksel_reg); in omap4_clk_generic_activate()
547 printf("Error: failed to enable module with clock %d\n", clkdev->id); in omap4_clk_generic_activate()
548 printf("Error: 0x%08x => 0x%08x\n", clk_details->clksel_reg, clksel); in omap4_clk_generic_activate()
556 * omap4_clk_generic_deactivate - checks if a module is accessible
577 clk_details = omap4_clk_details(clkdev->id); in omap4_clk_generic_deactivate()
582 sc = omap4_prcm_get_instance_softc(clk_details->instance); in omap4_clk_generic_deactivate()
586 clk_mem_res = sc->sc_res; in omap4_clk_generic_deactivate()
592 * generic - the have at least two fielda called MODULEMODE and IDLEST. in omap4_clk_generic_deactivate()
594 clksel = bus_read_4(clk_mem_res, clk_details->clksel_reg); in omap4_clk_generic_deactivate()
597 bus_write_4(clk_mem_res, clk_details->clksel_reg, clksel); in omap4_clk_generic_deactivate()
603 * omap4_clk_generic_set_source - checks if a module is accessible
625 * omap4_clk_generic_accessible - checks if a module is accessible
646 clk_details = omap4_clk_details(clkdev->id); in omap4_clk_generic_accessible()
651 sc = omap4_prcm_get_instance_softc(clk_details->instance); in omap4_clk_generic_accessible()
655 clk_mem_res = sc->sc_res; in omap4_clk_generic_accessible()
660 clksel = bus_read_4(clk_mem_res, clk_details->clksel_reg); in omap4_clk_generic_accessible()
670 * omap4_clk_generic_get_source_freq - checks if a module is accessible
685 unsigned int *freq in omap4_clk_generic_get_source_freq() argument
688 struct omap4_clk_details* clk_details = omap4_clk_details(clkdev->id); in omap4_clk_generic_get_source_freq()
694 if (freq) in omap4_clk_generic_get_source_freq()
695 *freq = (unsigned int)clk_details->src_freq; in omap4_clk_generic_get_source_freq()
701 * omap4_clk_gptimer_set_source - checks if a module is accessible
722 clk_details = omap4_clk_details(clkdev->id); in omap4_clk_gptimer_set_source()
727 sc = omap4_prcm_get_instance_softc(clk_details->instance); in omap4_clk_gptimer_set_source()
731 clk_mem_res = sc->sc_res; in omap4_clk_gptimer_set_source()
742 * omap4_clk_gptimer_get_source_freq - checks if a module is accessible
757 unsigned int *freq in omap4_clk_gptimer_get_source_freq() argument
766 clk_details = omap4_clk_details(clkdev->id); in omap4_clk_gptimer_get_source_freq()
771 sc = omap4_prcm_get_instance_softc(clk_details->instance); in omap4_clk_gptimer_get_source_freq()
775 clk_mem_res = sc->sc_res; in omap4_clk_gptimer_get_source_freq()
780 /* Need to read the CLKSEL field to determine the clock source */ in omap4_clk_gptimer_get_source_freq()
781 clksel = bus_read_4(clk_mem_res, clk_details->clksel_reg); in omap4_clk_gptimer_get_source_freq()
788 if (freq) in omap4_clk_gptimer_get_source_freq()
789 *freq = src_freq; in omap4_clk_gptimer_get_source_freq()
795 * omap4_clk_hsmmc_set_source - sets the source clock (freq)
796 * @clkdev: pointer to the clockdev structure (id field will contain clock id)
798 * The MMC 1 and 2 clocks can be source from either a 64MHz or 96MHz clock.
815 clk_details = omap4_clk_details(clkdev->id); in omap4_clk_hsmmc_set_source()
820 sc = omap4_prcm_get_instance_softc(clk_details->instance); in omap4_clk_hsmmc_set_source()
824 clk_mem_res = sc->sc_res; in omap4_clk_hsmmc_set_source()
829 /* For MMC modules 3, 4 & 5 you can't change the freq, it's always 48MHz */ in omap4_clk_hsmmc_set_source()
830 if ((clkdev->id == MMC3_CLK) || (clkdev->id == MMC4_CLK) || in omap4_clk_hsmmc_set_source()
831 (clkdev->id == MMC5_CLK)) { in omap4_clk_hsmmc_set_source()
837 clksel = bus_read_4(clk_mem_res, clk_details->clksel_reg); in omap4_clk_hsmmc_set_source()
839 /* Bit 24 is set if 96MHz clock or cleared for 64MHz clock */ in omap4_clk_hsmmc_set_source()
847 bus_write_4(clk_mem_res, clk_details->clksel_reg, clksel); in omap4_clk_hsmmc_set_source()
853 * omap4_clk_hsmmc_get_source_freq - checks if a module is accessible
854 * @clkdev: pointer to the clockdev structure (id field will contain clock id)
866 unsigned int *freq in omap4_clk_hsmmc_get_source_freq() argument
875 clk_details = omap4_clk_details(clkdev->id); in omap4_clk_hsmmc_get_source_freq()
880 sc = omap4_prcm_get_instance_softc(clk_details->instance); in omap4_clk_hsmmc_get_source_freq()
884 clk_mem_res = sc->sc_res; in omap4_clk_hsmmc_get_source_freq()
889 switch (clkdev->id) { in omap4_clk_hsmmc_get_source_freq()
892 /* Need to read the CLKSEL field to determine the clock source */ in omap4_clk_hsmmc_get_source_freq()
893 clksel = bus_read_4(clk_mem_res, clk_details->clksel_reg); in omap4_clk_hsmmc_get_source_freq()
909 if (freq) in omap4_clk_hsmmc_get_source_freq()
910 *freq = src_freq; in omap4_clk_hsmmc_get_source_freq()
916 * omap4_clk_get_sysclk_freq - gets the sysclk frequency
919 * Read the clocking information from the power-control/boot-strap registers,
927 unsigned int *freq) in omap4_clk_get_sysclk_freq() argument
937 /* Read the input clock freq from the configuration register (CM_SYS_CLKSEL) */ in omap4_clk_get_sysclk_freq()
938 clksel = bus_read_4(sc->sc_res, CM_SYS_CLKSEL_OFFSET); in omap4_clk_get_sysclk_freq()
961 panic("%s: Invalid clock freq", __func__); in omap4_clk_get_sysclk_freq()
965 if (freq) in omap4_clk_get_sysclk_freq()
966 *freq = sysclk; in omap4_clk_get_sysclk_freq()
972 * omap4_clk_get_arm_fclk_freq - gets the MPU clock frequency
974 * @freq: pointer which upon return will contain the freq in hz
978 * in the freq variable.
985 unsigned int *freq) in omap4_clk_get_arm_fclk_freq() argument
999 clksel = bus_read_4(sc->sc_res, CM_CLKSEL_DPLL_MPU); in omap4_clk_get_arm_fclk_freq()
1004 /* Get the system clock freq */ in omap4_clk_get_arm_fclk_freq()
1007 /* Calculate the MPU freq */ in omap4_clk_get_arm_fclk_freq()
1011 if (freq) in omap4_clk_get_arm_fclk_freq()
1012 *freq = mpuclk; in omap4_clk_get_arm_fclk_freq()
1018 * omap4_clk_hsusbhost_activate - activates the USB clocks for the given module
1019 * @clkdev: pointer to the clock device structure.
1078 switch (clkdev->id) { in omap4_clk_hsusbhost_activate()
1081 * - INIT_L4_ICLK (will be enabled by bootloader) in omap4_clk_hsusbhost_activate()
1082 * - TLL_CH0_FCLK in omap4_clk_hsusbhost_activate()
1083 * - TLL_CH1_FCLK in omap4_clk_hsusbhost_activate()
1087 clk_mem_res = sc->sc_res; in omap4_clk_hsusbhost_activate()
1097 clksel |= (0x1 << 8); /* USB-HOST optional clock: USB_CH0_CLK */ in omap4_clk_hsusbhost_activate()
1098 clksel |= (0x1 << 9); /* USB-HOST optional clock: USB_CH1_CLK */ in omap4_clk_hsusbhost_activate()
1109 * - INIT_L4_ICLK (will be enabled by bootloader) in omap4_clk_hsusbhost_activate()
1110 * - INIT_L3_ICLK (will be enabled by bootloader) in omap4_clk_hsusbhost_activate()
1111 * - INIT_48MC_FCLK in omap4_clk_hsusbhost_activate()
1112 * - UTMI_ROOT_GFCLK (UTMI only, create a new clock for that ?) in omap4_clk_hsusbhost_activate()
1113 * - UTMI_P1_FCLK (UTMI only, create a new clock for that ?) in omap4_clk_hsusbhost_activate()
1114 * - UTMI_P2_FCLK (UTMI only, create a new clock for that ?) in omap4_clk_hsusbhost_activate()
1115 * - HSIC_P1_60 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_activate()
1116 * - HSIC_P1_480 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_activate()
1117 * - HSIC_P2_60 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_activate()
1118 * - HSIC_P2_480 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_activate()
1122 clk_mem_res = sc->sc_res; in omap4_clk_hsusbhost_activate()
1126 if (clkdev->id == USBHSHOST_CLK) { in omap4_clk_hsusbhost_activate()
1130 clksel |= (0x1 << 15); /* USB-HOST clock control: FUNC48MCLK */ in omap4_clk_hsusbhost_activate()
1133 else if (clkdev->id == USBP1_UTMI_CLK) in omap4_clk_hsusbhost_activate()
1135 else if (clkdev->id == USBP2_UTMI_CLK) in omap4_clk_hsusbhost_activate()
1138 else if (clkdev->id == USBP1_HSIC_CLK) in omap4_clk_hsusbhost_activate()
1140 else if (clkdev->id == USBP2_HSIC_CLK) in omap4_clk_hsusbhost_activate()
1160 printf("Error: HERE failed to enable module with clock %d\n", clkdev->id); in omap4_clk_hsusbhost_activate()
1169 * omap4_clk_generic_deactivate - checks if a module is accessible
1170 * @clkdev: pointer to the clock device structure.
1193 switch (clkdev->id) { in omap4_clk_hsusbhost_deactivate()
1196 clk_mem_res = sc->sc_res; in omap4_clk_hsusbhost_deactivate()
1212 * - INIT_L4_ICLK (will be enabled by bootloader) in omap4_clk_hsusbhost_deactivate()
1213 * - INIT_L3_ICLK (will be enabled by bootloader) in omap4_clk_hsusbhost_deactivate()
1214 * - INIT_48MC_FCLK in omap4_clk_hsusbhost_deactivate()
1215 * - UTMI_ROOT_GFCLK (UTMI only, create a new clock for that ?) in omap4_clk_hsusbhost_deactivate()
1216 * - UTMI_P1_FCLK (UTMI only, create a new clock for that ?) in omap4_clk_hsusbhost_deactivate()
1217 * - UTMI_P2_FCLK (UTMI only, create a new clock for that ?) in omap4_clk_hsusbhost_deactivate()
1218 * - HSIC_P1_60 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_deactivate()
1219 * - HSIC_P1_480 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_deactivate()
1220 * - HSIC_P2_60 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_deactivate()
1221 * - HSIC_P2_480 (HSIC only, create a new clock for that ?) in omap4_clk_hsusbhost_deactivate()
1225 clk_mem_res = sc->sc_res; in omap4_clk_hsusbhost_deactivate()
1230 if (clkdev->id == USBHSHOST_CLK) { in omap4_clk_hsusbhost_deactivate()
1234 clksel &= ~(0x1 << 15); /* USB-HOST clock control: FUNC48MCLK */ in omap4_clk_hsusbhost_deactivate()
1237 else if (clkdev->id == USBP1_UTMI_CLK) in omap4_clk_hsusbhost_deactivate()
1239 else if (clkdev->id == USBP2_UTMI_CLK) in omap4_clk_hsusbhost_deactivate()
1242 else if (clkdev->id == USBP1_HSIC_CLK) in omap4_clk_hsusbhost_deactivate()
1244 else if (clkdev->id == USBP2_HSIC_CLK) in omap4_clk_hsusbhost_deactivate()
1259 * omap4_clk_hsusbhost_accessible - checks if a module is accessible
1260 * @clkdev: pointer to the clock device structure.
1284 if (clkdev->id == USBTLL_CLK) { in omap4_clk_hsusbhost_accessible()
1286 clk_mem_res = sc->sc_res; in omap4_clk_hsusbhost_accessible()
1289 else if (clkdev->id == USBHSHOST_CLK) { in omap4_clk_hsusbhost_accessible()
1291 clk_mem_res = sc->sc_res; in omap4_clk_hsusbhost_accessible()
1308 * omap4_clk_hsusbhost_set_source - sets the source clocks
1309 * @clkdev: pointer to the clock device structure.
1310 * @clksrc: the clock source ID for the given clock.
1335 if (clkdev->id == USBP1_PHY_CLK) in omap4_clk_hsusbhost_set_source()
1337 else if (clkdev->id != USBP2_PHY_CLK) in omap4_clk_hsusbhost_set_source()
1343 clk_mem_res = sc->sc_res; in omap4_clk_hsusbhost_set_source()
1347 /* Set the clock source to either external or internal */ in omap4_clk_hsusbhost_set_source()
1370 bus_write_4(sc->sc_res, PRM_RSTCTRL, in omap4_prcm_reset()
1371 bus_read_4(sc->sc_res, PRM_RSTCTRL) | PRM_RSTCTRL_RESET); in omap4_prcm_reset()
1372 bus_read_4(sc->sc_res, PRM_RSTCTRL); in omap4_prcm_reset()
1376 * omap4_prcm_probe - probe function for the driver
1396 if ((int)ocd->ocd_data == 0) in omap4_prcm_probe()
1399 switch ((int)ocd->ocd_data) { in omap4_prcm_probe()
1401 device_set_desc(dev, "TI OMAP Power, Reset and Clock Management (PRM)"); in omap4_prcm_probe()
1404 device_set_desc(dev, "TI OMAP Power, Reset and Clock Management (C1)"); in omap4_prcm_probe()
1407 device_set_desc(dev, "TI OMAP Power, Reset and Clock Management (C2)"); in omap4_prcm_probe()
1410 device_printf(dev, "unknown instance type: %d\n", (int)ocd->ocd_data); in omap4_prcm_probe()
1418 * omap_prcm_attach - attach function for the driver
1441 sc->sc_instance = (int)ocd->ocd_data; in omap4_prcm_attach()
1443 sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rid, in omap4_prcm_attach()
1445 if (sc->sc_res == NULL) { in omap4_prcm_attach()
1459 unsigned int freq; in omap4_prcm_new_pass() local
1461 if (sc->attach_done || in omap4_prcm_new_pass()
1466 sc->attach_done = 1; in omap4_prcm_new_pass()
1471 * initialized. Should be replaced with proper clock framework in omap4_prcm_new_pass()
1474 omap4_clk_get_arm_fclk_freq(NULL, &freq); in omap4_prcm_new_pass()
1475 arm_tmr_change_frequency(freq / 2); in omap4_prcm_new_pass()