drivers: clock_control: mcux_mcg: add driver for NXP Kinetis MCG
Add driver shim for the NXP Kinetis Multipurpose Clock Generator (MCG) module. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
210455a0ae
commit
a9a839179f
7 changed files with 118 additions and 0 deletions
|
@ -242,6 +242,7 @@
|
|||
/include/device.h @wentongwu @nashif
|
||||
/include/display/ @vanwinkeljan
|
||||
/include/display/framebuf.h @gnuless
|
||||
/include/dt-bindings/clock/kinetis_mcg.h @henrikbrixandersen
|
||||
/include/dt-bindings/clock/kinetis_scg.h @henrikbrixandersen
|
||||
/include/dt-bindings/pcie/ @gnuless
|
||||
/include/dt-bindings/usb/usb.h @galak @finikorg
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
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_MCG clock_control_mcux_mcg.c)
|
||||
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_MCUX_PCC clock_control_mcux_pcc.c)
|
||||
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_MCUX_SCG clock_control_mcux_scg.c)
|
||||
zephyr_sources_ifdef(CONFIG_CLOCK_CONTROL_MCUX_SIM clock_control_mcux_sim.c)
|
||||
|
|
|
@ -31,6 +31,8 @@ source "drivers/clock_control/Kconfig.beetle"
|
|||
|
||||
source "drivers/clock_control/Kconfig.mcux_ccm"
|
||||
|
||||
source "drivers/clock_control/Kconfig.mcux_mcg"
|
||||
|
||||
source "drivers/clock_control/Kconfig.mcux_pcc"
|
||||
|
||||
source "drivers/clock_control/Kconfig.mcux_scg"
|
||||
|
|
12
drivers/clock_control/Kconfig.mcux_mcg
Normal file
12
drivers/clock_control/Kconfig.mcux_mcg
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Kconfig - MCUXpresso SDK MCG
|
||||
#
|
||||
# Copyright (c) 2019 Vestas Wind Systems A/S
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
menuconfig CLOCK_CONTROL_MCUX_MCG
|
||||
bool "MCUX MCG driver"
|
||||
depends on HAS_MCG
|
||||
help
|
||||
Enable support for mcux mcg driver.
|
64
drivers/clock_control/clock_control_mcux_mcg.c
Normal file
64
drivers/clock_control/clock_control_mcux_mcg.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Vestas Wind Systems A/S
|
||||
*
|
||||
* Based on clock_control_mcux_sim.c, which is:
|
||||
* Copyright (c) 2017, NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <drivers/clock_control.h>
|
||||
#include <dt-bindings/clock/kinetis_mcg.h>
|
||||
#include <soc.h>
|
||||
#include <fsl_clock.h>
|
||||
|
||||
#define LOG_LEVEL CONFIG_CLOCK_CONTROL_LOG_LEVEL
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(clock_control_mcg);
|
||||
|
||||
static int mcux_mcg_on(struct device *dev, clock_control_subsys_t sub_system)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_mcg_off(struct device *dev, clock_control_subsys_t sub_system)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_mcg_get_rate(struct device *dev,
|
||||
clock_control_subsys_t sub_system,
|
||||
u32_t *rate)
|
||||
{
|
||||
clock_name_t clock_name;
|
||||
|
||||
switch ((u32_t) sub_system) {
|
||||
case KINETIS_MCG_FIXED_FREQ_CLK:
|
||||
clock_name = kCLOCK_McgFixedFreqClk;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Unsupported clock name");
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
*rate = CLOCK_GetFreq(clock_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_mcg_init(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct clock_control_driver_api mcux_mcg_driver_api = {
|
||||
.on = mcux_mcg_on,
|
||||
.off = mcux_mcg_off,
|
||||
.get_rate = mcux_mcg_get_rate,
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(mcux_mcg, DT_MCG_NAME,
|
||||
&mcux_mcg_init,
|
||||
NULL, NULL,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&mcux_mcg_driver_api);
|
26
dts/bindings/arm/nxp,kinetis-mcg.yaml
Normal file
26
dts/bindings/arm/nxp,kinetis-mcg.yaml
Normal file
|
@ -0,0 +1,26 @@
|
|||
#
|
||||
# Copyright (c) 2019 Vestas Wind Systems A/S
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
title: NXP Kinetis Multipurpose Clock Generator (MCG)
|
||||
|
||||
description: >
|
||||
This is a representation of the NXP Kinetis MCG IP node
|
||||
|
||||
inherits:
|
||||
!include base.yaml
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
constraint: "nxp,kinetis-mcg"
|
||||
|
||||
reg:
|
||||
category: required
|
||||
|
||||
label:
|
||||
category: required
|
||||
|
||||
"#cells":
|
||||
- name
|
12
include/dt-bindings/clock/kinetis_mcg.h
Normal file
12
include/dt-bindings/clock/kinetis_mcg.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Vestas Wind Systems A/S
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_MCG_H_
|
||||
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_MCG_H_
|
||||
|
||||
#define KINETIS_MCG_FIXED_FREQ_CLK 0
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_MCG_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue