drivers: clock_control: clock_control_mcux_syscon: make clock IDs unique
Syscon clock driver previously used a sequence where clock IDs increased sequentially. This had a few disadvantages: - if a new SOC was introduced with more instances of a given IP, the clock ID could not be sequential with the remaining IDs - chance of collisions between clock IDs was relatively high To resolve this, define LPC clock IDs using a bitmask macro. Note that the CTIMER clock IDs are used within SOC clock files to perform clock init, and the macro requires that the clock ID expand to an integer rather than a expression with bitshifts (hence why the macro is not used for these IDs) Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
dadbe105f2
commit
81ec61c085
|
@ -197,19 +197,19 @@ static int mcux_lpc_syscon_clock_control_get_subsys_rate(
|
|||
#endif /* defined(CONFIG_CAN_MCUX_MCAN) */
|
||||
|
||||
#if defined(CONFIG_COUNTER_MCUX_CTIMER) || defined(CONFIG_PWM_MCUX_CTIMER)
|
||||
case (MCUX_CTIMER0_CLK + MCUX_CTIMER_CLK_OFFSET):
|
||||
case MCUX_CTIMER0_CLK:
|
||||
*rate = CLOCK_GetCTimerClkFreq(0);
|
||||
break;
|
||||
case (MCUX_CTIMER1_CLK + MCUX_CTIMER_CLK_OFFSET):
|
||||
case MCUX_CTIMER1_CLK:
|
||||
*rate = CLOCK_GetCTimerClkFreq(1);
|
||||
break;
|
||||
case (MCUX_CTIMER2_CLK + MCUX_CTIMER_CLK_OFFSET):
|
||||
case MCUX_CTIMER2_CLK:
|
||||
*rate = CLOCK_GetCTimerClkFreq(2);
|
||||
break;
|
||||
case (MCUX_CTIMER3_CLK + MCUX_CTIMER_CLK_OFFSET):
|
||||
case MCUX_CTIMER3_CLK:
|
||||
*rate = CLOCK_GetCTimerClkFreq(3);
|
||||
break;
|
||||
case (MCUX_CTIMER4_CLK + MCUX_CTIMER_CLK_OFFSET):
|
||||
case MCUX_CTIMER4_CLK:
|
||||
*rate = CLOCK_GetCTimerClkFreq(4);
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -300,7 +300,7 @@ static const struct counter_driver_api mcux_ctimer_driver_api = {
|
|||
.base = (CTIMER_Type *)DT_INST_REG_ADDR(id), \
|
||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(id)), \
|
||||
.clock_subsys = \
|
||||
(clock_control_subsys_t)(DT_INST_CLOCKS_CELL(id, name) + MCUX_CTIMER_CLK_OFFSET),\
|
||||
(clock_control_subsys_t)(DT_INST_CLOCKS_CELL(id, name)),\
|
||||
.mode = DT_INST_PROP(id, mode), \
|
||||
.input = DT_INST_PROP(id, input), \
|
||||
.prescale = DT_INST_PROP(id, prescale), \
|
||||
|
|
|
@ -7,63 +7,70 @@
|
|||
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_
|
||||
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_
|
||||
|
||||
#define MCUX_FLEXCOMM0_CLK 0
|
||||
#define MCUX_FLEXCOMM1_CLK 1
|
||||
#define MCUX_FLEXCOMM2_CLK 2
|
||||
#define MCUX_FLEXCOMM3_CLK 3
|
||||
#define MCUX_FLEXCOMM4_CLK 4
|
||||
#define MCUX_FLEXCOMM5_CLK 5
|
||||
#define MCUX_FLEXCOMM6_CLK 6
|
||||
#define MCUX_FLEXCOMM7_CLK 7
|
||||
#define MCUX_FLEXCOMM8_CLK 8
|
||||
#define MCUX_FLEXCOMM9_CLK 9
|
||||
#define MCUX_FLEXCOMM10_CLK 10
|
||||
#define MCUX_FLEXCOMM11_CLK 11
|
||||
#define MCUX_FLEXCOMM12_CLK 12
|
||||
#define MCUX_FLEXCOMM13_CLK 13
|
||||
#define MCUX_HS_SPI_CLK 14
|
||||
#define MCUX_FLEXCOMM14_CLK MCUX_HS_SPI_CLK
|
||||
#define MCUX_PMIC_I2C_CLK 15
|
||||
#define MCUX_HS_SPI1_CLK 16
|
||||
/* Note- clock identifiers in this file must be unique,
|
||||
* as the driver uses them in a switch case
|
||||
*/
|
||||
|
||||
#define MCUX_USDHC1_CLK 20
|
||||
#define MCUX_USDHC2_CLK 21
|
||||
|
||||
#define MCUX_CTIMER_CLK_OFFSET 22
|
||||
#define MCUX_LPC_CLK_ID(high, low) ((high << 8) | (low))
|
||||
|
||||
/* These IDs are used within SOC macros, and thus cannot be defined
|
||||
* using the standard MCUX_LPC_CLK_ID form
|
||||
*/
|
||||
#define MCUX_CTIMER0_CLK 0
|
||||
#define MCUX_CTIMER1_CLK 1
|
||||
#define MCUX_CTIMER2_CLK 2
|
||||
#define MCUX_CTIMER3_CLK 3
|
||||
#define MCUX_CTIMER4_CLK 4
|
||||
|
||||
#define MCUX_MCAN_CLK 27
|
||||
#define MCUX_FLEXCOMM0_CLK MCUX_LPC_CLK_ID(0x01, 0x00)
|
||||
#define MCUX_FLEXCOMM1_CLK MCUX_LPC_CLK_ID(0x01, 0x01)
|
||||
#define MCUX_FLEXCOMM2_CLK MCUX_LPC_CLK_ID(0x01, 0x02)
|
||||
#define MCUX_FLEXCOMM3_CLK MCUX_LPC_CLK_ID(0x01, 0x03)
|
||||
#define MCUX_FLEXCOMM4_CLK MCUX_LPC_CLK_ID(0x01, 0x04)
|
||||
#define MCUX_FLEXCOMM5_CLK MCUX_LPC_CLK_ID(0x01, 0x05)
|
||||
#define MCUX_FLEXCOMM6_CLK MCUX_LPC_CLK_ID(0x01, 0x06)
|
||||
#define MCUX_FLEXCOMM7_CLK MCUX_LPC_CLK_ID(0x01, 0x07)
|
||||
#define MCUX_FLEXCOMM8_CLK MCUX_LPC_CLK_ID(0x01, 0x08)
|
||||
#define MCUX_FLEXCOMM9_CLK MCUX_LPC_CLK_ID(0x01, 0x09)
|
||||
#define MCUX_FLEXCOMM10_CLK MCUX_LPC_CLK_ID(0x01, 0x0A)
|
||||
#define MCUX_FLEXCOMM11_CLK MCUX_LPC_CLK_ID(0x01, 0x0B)
|
||||
#define MCUX_FLEXCOMM12_CLK MCUX_LPC_CLK_ID(0x01, 0x0C)
|
||||
#define MCUX_FLEXCOMM13_CLK MCUX_LPC_CLK_ID(0x01, 0x0D)
|
||||
#define MCUX_HS_SPI_CLK MCUX_LPC_CLK_ID(0x01, 0x0E)
|
||||
#define MCUX_FLEXCOMM14_CLK MCUX_HS_SPI_CLK
|
||||
#define MCUX_PMIC_I2C_CLK MCUX_LPC_CLK_ID(0x01, 0x0F)
|
||||
#define MCUX_HS_SPI1_CLK MCUX_LPC_CLK_ID(0x01, 0x10)
|
||||
|
||||
#define MCUX_BUS_CLK 28
|
||||
#define MCUX_USDHC1_CLK MCUX_LPC_CLK_ID(0x02, 0x00)
|
||||
#define MCUX_USDHC2_CLK MCUX_LPC_CLK_ID(0x02, 0x01)
|
||||
|
||||
#define MCUX_SDIF_CLK 29
|
||||
#define MCUX_MCAN_CLK MCUX_LPC_CLK_ID(0x03, 0x00)
|
||||
|
||||
#define MCUX_I3C_CLK 30
|
||||
#define MCUX_BUS_CLK MCUX_LPC_CLK_ID(0x04, 0x00)
|
||||
|
||||
#define MCUX_MIPI_DSI_DPHY_CLK 31
|
||||
#define MCUX_MIPI_DSI_ESC_CLK 32
|
||||
#define MCUX_SDIF_CLK MCUX_LPC_CLK_ID(0x05, 0x00)
|
||||
|
||||
#define MCUX_LCDIF_PIXEL_CLK 33
|
||||
#define MCUX_I3C_CLK MCUX_LPC_CLK_ID(0x06, 0x00)
|
||||
|
||||
#define MCUX_SCTIMER_CLK 34
|
||||
#define MCUX_MIPI_DSI_DPHY_CLK MCUX_LPC_CLK_ID(0x07, 0x00)
|
||||
#define MCUX_MIPI_DSI_ESC_CLK MCUX_LPC_CLK_ID(0x07, 0x01)
|
||||
|
||||
#define MCUX_DMIC_CLK 35
|
||||
#define MCUX_LCDIF_PIXEL_CLK MCUX_LPC_CLK_ID(0x08, 0x00)
|
||||
|
||||
#define MCUX_FLEXSPI_CLK 36
|
||||
#define MCUX_FLEXSPI2_CLK 37
|
||||
#define MCUX_SCTIMER_CLK MCUX_LPC_CLK_ID(0x09, 0x00)
|
||||
|
||||
#define MCUX_MRT_CLK 40
|
||||
#define MCUX_DMIC_CLK MCUX_LPC_CLK_ID(0x0A, 0x00)
|
||||
|
||||
#define MCUX_PORT0_CLK 41
|
||||
#define MCUX_PORT1_CLK 42
|
||||
#define MCUX_PORT2_CLK 43
|
||||
#define MCUX_PORT3_CLK 44
|
||||
#define MCUX_PORT4_CLK 45
|
||||
#define MCUX_PORT5_CLK 46
|
||||
#define MCUX_FLEXSPI_CLK MCUX_LPC_CLK_ID(0x0A, 0x00)
|
||||
#define MCUX_FLEXSPI2_CLK MCUX_LPC_CLK_ID(0x0A, 0x01)
|
||||
|
||||
#define MCUX_MRT_CLK MCUX_LPC_CLK_ID(0x0B, 0x00)
|
||||
|
||||
#define MCUX_PORT0_CLK MCUX_LPC_CLK_ID(0x0C, 0x00)
|
||||
#define MCUX_PORT1_CLK MCUX_LPC_CLK_ID(0x0C, 0x01)
|
||||
#define MCUX_PORT2_CLK MCUX_LPC_CLK_ID(0x0C, 0x02)
|
||||
#define MCUX_PORT3_CLK MCUX_LPC_CLK_ID(0x0C, 0x03)
|
||||
#define MCUX_PORT4_CLK MCUX_LPC_CLK_ID(0x0C, 0x04)
|
||||
#define MCUX_PORT5_CLK MCUX_LPC_CLK_ID(0x0C, 0x05)
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_ */
|
||||
|
|
Loading…
Reference in a new issue