Skip to content

Commit 8e07e21

Browse files
danieldegrassedleach02
authored andcommitted
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 <[email protected]>
1 parent ff8ba4e commit 8e07e21

File tree

4 files changed

+13
-50
lines changed

4 files changed

+13
-50
lines changed

drivers/clock_control/clock_control_lpc11u6x.c

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <zephyr/device.h>
1111

1212
#include <zephyr/drivers/clock_control/lpc11u6x_clock_control.h>
13-
#include <zephyr/drivers/pinmux.h>
1413

1514
#include "clock_control_lpc11u6x.h"
1615

@@ -74,43 +73,6 @@ static void syscon_ahb_clock_enable(struct lpc11u6x_syscon_regs *syscon,
7473
}
7574
}
7675

77-
#if defined(CONFIG_CLOCK_CONTROL_LPC11U6X_PLL_SRC_SYSOSC) \
78-
&& DT_INST_NODE_HAS_PROP(0, pinmuxs)
79-
/**
80-
* @brief: configure system oscillator pins.
81-
*
82-
* This system oscillator pins and their configurations are retrieved from the
83-
* "pinmuxs" property of the DT clock controller node.
84-
*/
85-
static void pinmux_enable_sysosc(void)
86-
{
87-
const struct device *pinmux_dev;
88-
uint32_t pin, func;
89-
90-
pinmux_dev = device_get_binding(
91-
DT_LABEL(DT_INST_PHANDLE_BY_NAME(0, pinmuxs, xtalin)));
92-
if (!pinmux_dev) {
93-
return;
94-
}
95-
pin = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalin, pin);
96-
func = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalin, function);
97-
98-
pinmux_pin_set(pinmux_dev, pin, func);
99-
100-
pinmux_dev = device_get_binding(
101-
DT_LABEL(DT_INST_PHANDLE_BY_NAME(0, pinmuxs, xtalout)));
102-
if (!pinmux_dev) {
103-
return;
104-
}
105-
pin = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalout, pin);
106-
func = DT_INST_PHA_BY_NAME(0, pinmuxs, xtalout, function);
107-
108-
pinmux_pin_set(pinmux_dev, pin, func);
109-
}
110-
#else
111-
#define pinmux_enable_sysosc() do { } while (0)
112-
#endif
113-
11476
static void syscon_peripheral_reset(struct lpc11u6x_syscon_regs *syscon,
11577
uint32_t mask, bool reset)
11678
{
@@ -347,7 +309,7 @@ static int lpc11u6x_syscon_init(const struct device *dev)
347309
/* Configure PLL input */
348310
syscon_set_pll_src(cfg->syscon, LPC11U6X_SYS_PLL_CLK_SEL_SYSOSC);
349311

350-
pinmux_enable_sysosc();
312+
pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT);
351313

352314
#elif defined(CONFIG_CLOCK_CONTROL_LPC11U6X_PLL_SRC_IRC)
353315
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 = {
381343
.get_rate = lpc11u6x_clock_control_get_rate,
382344
};
383345

346+
347+
PINCTRL_DT_INST_DEFINE(0);
348+
384349
static const struct lpc11u6x_syscon_config syscon_config = {
385350
.syscon = (struct lpc11u6x_syscon_regs *) DT_INST_REG_ADDR(0),
351+
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
386352
};
387353

388354
static struct lpc11u6x_syscon_data syscon_data;

drivers/clock_control/clock_control_lpc11u6x.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_CONTROL_LPC11U6X_H_
88
#define ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_CONTROL_LPC11U6X_H_
99

10+
#include <zephyr/drivers/pinctrl.h>
11+
1012
#define LPC11U6X_SYS_AHB_CLK_CTRL_I2C0 (1 << 5)
1113
#define LPC11U6X_SYS_AHB_CLK_CTRL_GPIO (1 << 6)
1214
#define LPC11U6X_SYS_AHB_CLK_CTRL_USART0 (1 << 12)
@@ -132,6 +134,7 @@ struct lpc11u6x_syscon_regs {
132134

133135
struct lpc11u6x_syscon_config {
134136
struct lpc11u6x_syscon_regs *syscon;
137+
const struct pinctrl_dev_config *pincfg;
135138
};
136139

137140
struct lpc11u6x_syscon_data {

dts/arm/nxp/nxp_lpc11u6x.dtsi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#size-cells = <1>;
6161
ranges = <0x0 0x40044000 0x150>;
6262
pinctrl: pinctrl {
63-
compatible = "nxp,lpc-iocon-pinctrl";
63+
compatible = "nxp,lpc11u6x-pinctrl";
6464
};
6565
/* PIO0_0 to PIO0_23 */
6666
pio0: pio0@0 {
@@ -164,8 +164,6 @@
164164
#clock-cells = <1>;
165165
reg = <0x40048000 0x400>;
166166
label = "SYSCON";
167-
pinmuxs = <&pinmux2 0 1>, <&pinmux2 1 1>;
168-
pinmux-names = "XTALIN", "XTALOUT";
169167
};
170168

171169
uart0: serial@40008000 {

dts/bindings/clock/nxp,lpc11u6x-syscon.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: LPC11U6X clock controller node
55

66
compatible: "nxp,lpc11u6x-syscon"
77

8-
include: [clock-controller.yaml, base.yaml]
8+
include: [clock-controller.yaml, pinctrl-device.yaml, base.yaml]
99

1010
properties:
1111
reg:
@@ -14,15 +14,11 @@ properties:
1414
label:
1515
required: true
1616

17-
pinmuxs:
18-
type: phandle-array
17+
pinctrl-0:
1918
required: true
20-
description: system oscillator pinmux configuration
2119

22-
pinmux-names:
23-
type: string-array
24-
required: false
25-
description: system oscillator pins names
20+
pinctrl-names:
21+
required: true
2622

2723
"#clock-cells":
2824
const: 1

0 commit comments

Comments
 (0)