Skip to content

Commit 7530188

Browse files
JiafeiPankartben
authored andcommitted
drivers: clock_control: mcux_ccm: add ii2c clock support
Add I2C clock support for imx8m platforms. Signed-off-by: Jiafei Pan <[email protected]>
1 parent b97c1d7 commit 7530188

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

drivers/clock_control/clock_control_mcux_ccm.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017,2024 NXP
2+
* Copyright 2017, 2024-2025 NXP
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -81,6 +81,18 @@ static const clock_ip_name_t sai_clocks[] = {
8181
#endif
8282
#endif /* CONFIG_DAI_NXP_SAI */
8383

84+
#if defined(CONFIG_I2C_NXP_II2C)
85+
static const clock_ip_name_t i2c_clk_root[] = {
86+
kCLOCK_RootI2c1,
87+
kCLOCK_RootI2c2,
88+
kCLOCK_RootI2c3,
89+
kCLOCK_RootI2c4,
90+
#ifdef CONFIG_SOC_MIMX8ML8
91+
kCLOCK_RootI2c5,
92+
kCLOCK_RootI2c6,
93+
#endif
94+
};
95+
#endif
8496

8597
static int mcux_ccm_on(const struct device *dev,
8698
clock_control_subsys_t sub_system)
@@ -447,6 +459,31 @@ static int mcux_ccm_get_subsys_rate(const struct device *dev,
447459
(CLOCK_GetRootPostDivider(kCLOCK_RootEcspi3));
448460
break;
449461
#endif /* CONFIG_SPI_MCUX_ECSPI */
462+
463+
#if defined(CONFIG_I2C_NXP_II2C)
464+
case IMX_CCM_I2C1_CLK:
465+
case IMX_CCM_I2C2_CLK:
466+
case IMX_CCM_I2C3_CLK:
467+
case IMX_CCM_I2C4_CLK:
468+
#ifdef CONFIG_SOC_MIMX8ML8
469+
case IMX_CCM_I2C5_CLK:
470+
case IMX_CCM_I2C6_CLK:
471+
#endif
472+
{
473+
uint32_t instance = clock_name & IMX_CCM_INSTANCE_MASK;
474+
uint32_t i2c_mux = CLOCK_GetRootMux(i2c_clk_root[instance]);
475+
476+
if (i2c_mux == 0) {
477+
*rate = MHZ(24);
478+
} else if (i2c_mux == 1) {
479+
*rate = CLOCK_GetPllFreq(kCLOCK_SystemPll1Ctrl) /
480+
(CLOCK_GetRootPreDivider(i2c_clk_root[instance])) /
481+
(CLOCK_GetRootPostDivider(i2c_clk_root[instance])) /
482+
5; /* SYSTEM PLL1 DIV5 */
483+
}
484+
485+
} break;
486+
#endif
450487
}
451488

452489
return 0;

include/zephyr/dt-bindings/clock/imx_ccm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,11 @@
7272

7373
#define IMX_CCM_GPT_IPG_CLK 0x1300UL
7474

75+
#define IMX_CCM_I2C1_CLK 0x1400UL
76+
#define IMX_CCM_I2C2_CLK 0x1401UL
77+
#define IMX_CCM_I2C3_CLK 0x1402UL
78+
#define IMX_CCM_I2C4_CLK 0x1403UL
79+
#define IMX_CCM_I2C5_CLK 0x1404UL
80+
#define IMX_CCM_I2C6_CLK 0x1405UL
81+
7582
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_IMX_CCM_H_ */

0 commit comments

Comments
 (0)