Title: Controlling the CCM_CCR Clock Control Module Using devmem2 Command on Phytec Mira Access IMX6
In this article, we will discuss how to control the CCM_CCR clock control module using the devmem2 command on the Phytec Mira Access IMX6 board. The CCM_CCR module is responsible for controlling the clock frequencies of various peripherals in the system.
Prerequisites
Before we begin, ensure that you have the following:
- Phytec Mira Access IMX6 board
- U-Boot and Linux kernel installed
- Access to the board's UART console
- Basic understanding of the IMX6 processor and its peripherals
Accessing the CCM_CCR Module
To access the CCM_CCR module, we will use the devmem2 command, which allows us to read from and write to memory-mapped devices.
First, open a terminal and access the UART console. Then, use the following command to open the memory-mapped address of the CCM_CCR module:
root@phyboard-mira-imx6-3:i2c-0# devmem2 0x20x20c4000 w /dev/mem
Replace 0x20x20c4000 with the correct memory-mapped address of the CCM_CCR module on your board.
Reading and Writing to the CCM_CCR Registers
The CCM_CCR module consists of several registers that control the clock frequencies of various peripherals. To read or write to these registers, we need to know their offsets from the base address.
For example, to read the value of the Clock Control Register (CCR), use the following command:
root@phyboard-mira-imx6-3:i2c-0# devmem2 0x20x20c4000 0x04 r
This command reads the value of the CCR register and displays it in the terminal.
To write a value to the CCR register, use the following command:
root@phyboard-mira-imx6-3:i2c-0# devmem2 0x20x20c4000 0x04 w 0x5a55
This command writes the value 0x5a55 to the CCR register.
Example: Setting the CPU Clock Frequency
Let's say we want to set the CPU clock frequency to 1200 MHz. To do this, we need to write the appropriate value to the CPU_DIV register.
First, find the offset of the CPU_DIV register from the base address of the CCM_CCR module. In the IMX6, the CPU_DIV register is at offset 0x08.
Next, calculate the value to write to the CPU_DIV register. The formula to calculate the CPU_DIV value is:
CPU_DIV = (PLL_INPUT_FREQ / CPU_FREQ) - 1
For a CPU frequency of 1200 MHz and a PLL input frequency of 480 MHz, the CPU_DIV value is:
CPU_DIV = (480 MHz / 1200 MHz) - 1 = 0x3c
Finally, write the calculated value to the CPU_DIV register:
root@phyboard-mira-imx6-3:i2c-0# devmem2 0x20x20c4000 0x08 w 0x3c
Summary
In this article, we learned how to control the CCM_CCR clock control module using the devmem2 command on the Phytec Mira Access IMX6 board. We discussed how to access the CCM_CCR module, read and write to its registers, and set the CPU clock frequency as an example.
References
- NXP IMX6 Quad Application Processor User Guide: https://www.nxp.com/docs/en/user-guide/UM10205.pdf
- NXP IMX6 Clock Control Module User Guide: https://www.nxp.com/docs/en/user-guide/UM10204.pdf
- devmem2 Manual Page: https://www.kernel.org/doc/man-pages/online/pages/man1/devmem2.1.html