diff options
author | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2023-04-12 17:24:14 +0200 |
---|---|---|
committer | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2023-05-22 09:45:42 +0200 |
commit | 5e78c76c79a7d6b46f774e5ba4af665d0b471324 (patch) | |
tree | 3ec31899477fef503f865fc7d078a77c08c2d6ea /bsps/arm/imxrt/i2c/imxrt-lpi2c.c | |
parent | bsps/imxrt1052: PLL config based on speed grade (diff) | |
download | rtems-5e78c76c79a7d6b46f774e5ba4af665d0b471324.tar.bz2 |
bsps/imxrt: Get clock for IMXRT11xx in drivers
The mcux_sdk has a different interface for getting the clock for
IMXRT11xx than for getting it in IMXRT10xx. Adapt simple drivers to
support that interface.
Diffstat (limited to '')
-rw-r--r-- | bsps/arm/imxrt/i2c/imxrt-lpi2c.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/bsps/arm/imxrt/i2c/imxrt-lpi2c.c b/bsps/arm/imxrt/i2c/imxrt-lpi2c.c index ac3d35b356..9b983f24af 100644 --- a/bsps/arm/imxrt/i2c/imxrt-lpi2c.c +++ b/bsps/arm/imxrt/i2c/imxrt-lpi2c.c @@ -373,12 +373,15 @@ static int imxrt_lpi2c_hw_init(struct imxrt_lpi2c_bus *bus) return 0; } -static uint32_t imxrt_lpi2c_get_src_freq(void) +static uint32_t imxrt_lpi2c_get_src_freq(clock_ip_name_t clock_ip) { uint32_t freq; +#if IMXRT_IS_MIMXRT10xx uint32_t mux; uint32_t divider; + (void) clock_ip; /* Not necessary for i.MXRT1050 */ + mux = CLOCK_GetMux(kCLOCK_Lpi2cMux); divider = 1; @@ -396,6 +399,17 @@ static uint32_t imxrt_lpi2c_get_src_freq(void) divider *= CLOCK_GetDiv(kCLOCK_Lpi2cDiv) + 1; freq /= divider; +#elif IMXRT_IS_MIMXRT11xx + /* + * FIXME: A future version of the mcux_sdk might provide a better method to + * get the clock instead of this hack. + */ + clock_root_t clock_root = clock_ip + kCLOCK_Root_Lpi2c1 - kCLOCK_Lpi2c1; + + freq = CLOCK_GetRootClockFreq(clock_root); +#else + #error Getting I2C frequency is not implemented for this chip. +#endif return freq; } @@ -457,7 +471,7 @@ void imxrt_lpi2c_init(void) } bus->clock_ip = imxrt_lpi2c_clock_ip(bus->regs); - bus->src_clock_hz = imxrt_lpi2c_get_src_freq(); + bus->src_clock_hz = imxrt_lpi2c_get_src_freq(bus->clock_ip); eno = imxrt_lpi2c_hw_init(bus); if (eno != 0) { |