clock_control: Introduce mcux ccm driver
Adds a new clock control driver for i.MX SoCs that have the clock control module (CCM). Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
8a1d3b5b11
commit
0f3b490905
7 changed files with 142 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_BEETLE beetle_clock_control.c)
|
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_BEETLE beetle_clock_control.c)
|
||||||
|
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_MCUX_CCM clock_control_mcux_ccm.c)
|
||||||
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_MCUX_SIM clock_control_mcux_sim.c)
|
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_MCUX_SIM clock_control_mcux_sim.c)
|
||||||
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF5 nrf5_power_clock.c)
|
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF5 nrf5_power_clock.c)
|
||||||
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_QUARK_SE quark_se_clock_control.c)
|
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_QUARK_SE quark_se_clock_control.c)
|
||||||
|
|
|
@ -49,6 +49,8 @@ source "drivers/clock_control/Kconfig.stm32"
|
||||||
|
|
||||||
source "drivers/clock_control/Kconfig.beetle"
|
source "drivers/clock_control/Kconfig.beetle"
|
||||||
|
|
||||||
|
source "drivers/clock_control/Kconfig.mcux_ccm"
|
||||||
|
|
||||||
source "drivers/clock_control/Kconfig.mcux_sim"
|
source "drivers/clock_control/Kconfig.mcux_sim"
|
||||||
|
|
||||||
endif # CLOCK_CONTROL
|
endif # CLOCK_CONTROL
|
||||||
|
|
14
drivers/clock_control/Kconfig.mcux_ccm
Normal file
14
drivers/clock_control/Kconfig.mcux_ccm
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Kconfig - MCUXpresso SDK CCM
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017, NXP
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
menuconfig CLOCK_CONTROL_MCUX_CCM
|
||||||
|
bool
|
||||||
|
prompt "MCUX CCM driver"
|
||||||
|
depends on HAS_MCUX_CCM
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Enable support for mcux ccm driver.
|
64
drivers/clock_control/clock_control_mcux_ccm.c
Normal file
64
drivers/clock_control/clock_control_mcux_ccm.c
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017, NXP
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <errno.h>
|
||||||
|
#include <soc.h>
|
||||||
|
#include <clock_control.h>
|
||||||
|
#include <dt-bindings/clock/imx_ccm.h>
|
||||||
|
#include <fsl_clock.h>
|
||||||
|
|
||||||
|
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_CLOCK_CONTROL_LEVEL
|
||||||
|
#include <logging/sys_log.h>
|
||||||
|
|
||||||
|
static int mcux_ccm_on(struct device *dev,
|
||||||
|
clock_control_subsys_t sub_system)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mcux_ccm_off(struct device *dev,
|
||||||
|
clock_control_subsys_t sub_system)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mcux_ccm_get_subsys_rate(struct device *dev,
|
||||||
|
clock_control_subsys_t sub_system,
|
||||||
|
u32_t *rate)
|
||||||
|
{
|
||||||
|
u32_t clock_name = (u32_t) sub_system;
|
||||||
|
|
||||||
|
switch (clock_name) {
|
||||||
|
case IMX_CCM_LPUART_CLK:
|
||||||
|
if (CLOCK_GetMux(kCLOCK_UartMux) == 0) {
|
||||||
|
*rate = CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6
|
||||||
|
/ (CLOCK_GetDiv(kCLOCK_UartDiv) + 1);
|
||||||
|
} else {
|
||||||
|
*rate = CLOCK_GetOscFreq()
|
||||||
|
/ (CLOCK_GetDiv(kCLOCK_UartDiv) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mcux_ccm_init(struct device *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct clock_control_driver_api mcux_ccm_driver_api = {
|
||||||
|
.on = mcux_ccm_on,
|
||||||
|
.off = mcux_ccm_off,
|
||||||
|
.get_rate = mcux_ccm_get_subsys_rate,
|
||||||
|
};
|
||||||
|
|
||||||
|
DEVICE_AND_API_INIT(mcux_ccm, CONFIG_MCUX_CCM_NAME,
|
||||||
|
&mcux_ccm_init,
|
||||||
|
NULL, NULL,
|
||||||
|
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||||
|
&mcux_ccm_driver_api);
|
39
dts/bindings/clock/nxp,imx-ccm.yaml
Normal file
39
dts/bindings/clock/nxp,imx-ccm.yaml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017, NXP
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
---
|
||||||
|
title: i.MX Clock Controller Module (CCM)
|
||||||
|
id: nxp,imx-ccm
|
||||||
|
version: 0.1
|
||||||
|
|
||||||
|
description: >
|
||||||
|
This is a representation of the i.MX CCM IP node
|
||||||
|
|
||||||
|
properties:
|
||||||
|
- compatible:
|
||||||
|
type: string
|
||||||
|
category: required
|
||||||
|
description: compatible strings
|
||||||
|
constraint: "nxp,imx-ccm"
|
||||||
|
|
||||||
|
- reg:
|
||||||
|
type: int
|
||||||
|
description: mmio register space
|
||||||
|
generation: define
|
||||||
|
category: required
|
||||||
|
|
||||||
|
- label:
|
||||||
|
type: string
|
||||||
|
category: required
|
||||||
|
description: Human readable string describing the device (used by Zephyr for API name)
|
||||||
|
generation: define
|
||||||
|
|
||||||
|
cell_string: CCM_CLK
|
||||||
|
|
||||||
|
"#cells":
|
||||||
|
- name
|
||||||
|
- offset
|
||||||
|
- bits
|
||||||
|
...
|
|
@ -18,6 +18,12 @@ config HAS_MCUX_ADC16
|
||||||
help
|
help
|
||||||
Set if the 16-bit ADC (ADC16) module is present in the SoC.
|
Set if the 16-bit ADC (ADC16) module is present in the SoC.
|
||||||
|
|
||||||
|
config HAS_MCUX_CCM
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Set if the clock control module (CCM) module is present in the SoC.
|
||||||
|
|
||||||
config HAS_MCUX_FTM
|
config HAS_MCUX_FTM
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
16
include/dt-bindings/clock/imx_ccm.h
Normal file
16
include/dt-bindings/clock/imx_ccm.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017, NXP
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __IMX_CCM_H
|
||||||
|
#define __IMX_CCM_H
|
||||||
|
|
||||||
|
#define IMX_CCM_CORESYS_CLK 0
|
||||||
|
#define IMX_CCM_PLATFORM_CLK 1
|
||||||
|
#define IMX_CCM_BUS_CLK 2
|
||||||
|
#define IMX_CCM_LPUART_CLK 3
|
||||||
|
#define IMX_CCM_LPI2C_CLK 4
|
||||||
|
|
||||||
|
#endif /* __IMX_CCM_H */
|
Loading…
Add table
Add a link
Reference in a new issue