drivers: clock_control: convert lpc11u6x syscon driver to pinctrl
convert lpc11u6x syscon clock driver to pin control, and remove all pinmux usage from driver and syscon dts node. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
ff8ba4e0f7
commit
8e07e21424
|
@ -10,7 +10,6 @@
|
||||||
#include <zephyr/device.h>
|
#include <zephyr/device.h>
|
||||||
|
|
||||||
#include <zephyr/drivers/clock_control/lpc11u6x_clock_control.h>
|
#include <zephyr/drivers/clock_control/lpc11u6x_clock_control.h>
|
||||||
#include <zephyr/drivers/pinmux.h>
|
|
||||||
|
|
||||||
#include "clock_control_lpc11u6x.h"
|
#include "clock_control_lpc11u6x.h"
|
||||||
|
|
||||||
|
@ -74,43 +73,6 @@ static void syscon_ahb_clock_enable(struct lpc11u6x_syscon_regs *syscon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_CLOCK_CONTROL_LPC11U6X_PLL_SRC_SYSOSC) \
|
|
||||||
&& DT_INST_NODE_HAS_PROP(0, pinmuxs)
|
|
||||||
/**
|
|
||||||
* @brief: configure system oscillator pins.
|
|
||||||
*
|
|
||||||
* This system oscillator pins and their configurations are retrieved from the
|
|
||||||
* "pinmuxs" property of the DT clock controller node.
|
|
||||||
*/
|
|
||||||
static void pinmux_enable_sysosc(void)
|
|
||||||
{
|
|
||||||
const struct device *pinmux_dev;
|
|
||||||
uint32_t pin, func;
|
|
||||||
|
|
||||||
pinmux_dev = device_get_binding(
|
|
||||||
DT_LABEL(DT_INST_PHANDLE_BY_NAME(0, pinmuxs, xtalin)));
|
|
||||||
if (!pinmux_dev) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pin = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalin, pin);
|
|
||||||
func = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalin, function);
|
|
||||||
|
|
||||||
pinmux_pin_set(pinmux_dev, pin, func);
|
|
||||||
|
|
||||||
pinmux_dev = device_get_binding(
|
|
||||||
DT_LABEL(DT_INST_PHANDLE_BY_NAME(0, pinmuxs, xtalout)));
|
|
||||||
if (!pinmux_dev) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pin = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalout, pin);
|
|
||||||
func = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalout, function);
|
|
||||||
|
|
||||||
pinmux_pin_set(pinmux_dev, pin, func);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define pinmux_enable_sysosc() do { } while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void syscon_peripheral_reset(struct lpc11u6x_syscon_regs *syscon,
|
static void syscon_peripheral_reset(struct lpc11u6x_syscon_regs *syscon,
|
||||||
uint32_t mask, bool reset)
|
uint32_t mask, bool reset)
|
||||||
{
|
{
|
||||||
|
@ -347,7 +309,7 @@ static int lpc11u6x_syscon_init(const struct device *dev)
|
||||||
/* Configure PLL input */
|
/* Configure PLL input */
|
||||||
syscon_set_pll_src(cfg->syscon, LPC11U6X_SYS_PLL_CLK_SEL_SYSOSC);
|
syscon_set_pll_src(cfg->syscon, LPC11U6X_SYS_PLL_CLK_SEL_SYSOSC);
|
||||||
|
|
||||||
pinmux_enable_sysosc();
|
pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
|
||||||
#elif defined(CONFIG_CLOCK_CONTROL_LPC11U6X_PLL_SRC_IRC)
|
#elif defined(CONFIG_CLOCK_CONTROL_LPC11U6X_PLL_SRC_IRC)
|
||||||
syscon_power_up(cfg->syscon, LPC11U6X_PDRUNCFG_IRC_PD, true);
|
syscon_power_up(cfg->syscon, LPC11U6X_PDRUNCFG_IRC_PD, true);
|
||||||
|
@ -381,8 +343,12 @@ static const struct clock_control_driver_api lpc11u6x_clock_control_api = {
|
||||||
.get_rate = lpc11u6x_clock_control_get_rate,
|
.get_rate = lpc11u6x_clock_control_get_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
PINCTRL_DT_INST_DEFINE(0);
|
||||||
|
|
||||||
static const struct lpc11u6x_syscon_config syscon_config = {
|
static const struct lpc11u6x_syscon_config syscon_config = {
|
||||||
.syscon = (struct lpc11u6x_syscon_regs *) DT_INST_REG_ADDR(0),
|
.syscon = (struct lpc11u6x_syscon_regs *) DT_INST_REG_ADDR(0),
|
||||||
|
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpc11u6x_syscon_data syscon_data;
|
static struct lpc11u6x_syscon_data syscon_data;
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#ifndef ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_CONTROL_LPC11U6X_H_
|
#ifndef ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_CONTROL_LPC11U6X_H_
|
||||||
#define ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_CONTROL_LPC11U6X_H_
|
#define ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_CONTROL_LPC11U6X_H_
|
||||||
|
|
||||||
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
|
|
||||||
#define LPC11U6X_SYS_AHB_CLK_CTRL_I2C0 (1 << 5)
|
#define LPC11U6X_SYS_AHB_CLK_CTRL_I2C0 (1 << 5)
|
||||||
#define LPC11U6X_SYS_AHB_CLK_CTRL_GPIO (1 << 6)
|
#define LPC11U6X_SYS_AHB_CLK_CTRL_GPIO (1 << 6)
|
||||||
#define LPC11U6X_SYS_AHB_CLK_CTRL_USART0 (1 << 12)
|
#define LPC11U6X_SYS_AHB_CLK_CTRL_USART0 (1 << 12)
|
||||||
|
@ -132,6 +134,7 @@ struct lpc11u6x_syscon_regs {
|
||||||
|
|
||||||
struct lpc11u6x_syscon_config {
|
struct lpc11u6x_syscon_config {
|
||||||
struct lpc11u6x_syscon_regs *syscon;
|
struct lpc11u6x_syscon_regs *syscon;
|
||||||
|
const struct pinctrl_dev_config *pincfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lpc11u6x_syscon_data {
|
struct lpc11u6x_syscon_data {
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
#size-cells = <1>;
|
#size-cells = <1>;
|
||||||
ranges = <0x0 0x40044000 0x150>;
|
ranges = <0x0 0x40044000 0x150>;
|
||||||
pinctrl: pinctrl {
|
pinctrl: pinctrl {
|
||||||
compatible = "nxp,lpc-iocon-pinctrl";
|
compatible = "nxp,lpc11u6x-pinctrl";
|
||||||
};
|
};
|
||||||
/* PIO0_0 to PIO0_23 */
|
/* PIO0_0 to PIO0_23 */
|
||||||
pio0: pio0@0 {
|
pio0: pio0@0 {
|
||||||
|
@ -164,8 +164,6 @@
|
||||||
#clock-cells = <1>;
|
#clock-cells = <1>;
|
||||||
reg = <0x40048000 0x400>;
|
reg = <0x40048000 0x400>;
|
||||||
label = "SYSCON";
|
label = "SYSCON";
|
||||||
pinmuxs = <&pinmux2 0 1>, <&pinmux2 1 1>;
|
|
||||||
pinmux-names = "XTALIN", "XTALOUT";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uart0: serial@40008000 {
|
uart0: serial@40008000 {
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: LPC11U6X clock controller node
|
||||||
|
|
||||||
compatible: "nxp,lpc11u6x-syscon"
|
compatible: "nxp,lpc11u6x-syscon"
|
||||||
|
|
||||||
include: [clock-controller.yaml, base.yaml]
|
include: [clock-controller.yaml, pinctrl-device.yaml, base.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -14,15 +14,11 @@ properties:
|
||||||
label:
|
label:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
pinmuxs:
|
pinctrl-0:
|
||||||
type: phandle-array
|
|
||||||
required: true
|
required: true
|
||||||
description: system oscillator pinmux configuration
|
|
||||||
|
|
||||||
pinmux-names:
|
pinctrl-names:
|
||||||
type: string-array
|
required: true
|
||||||
required: false
|
|
||||||
description: system oscillator pins names
|
|
||||||
|
|
||||||
"#clock-cells":
|
"#clock-cells":
|
||||||
const: 1
|
const: 1
|
||||||
|
|
Loading…
Reference in a new issue