Skip to content

Commit 3ffe4f3

Browse files
committed
drivers: pinctrl: add iopctl driver for RT 3 digital platforms
RT3 digital platforms won't reuse lpc_iocon driver, new iopctl driver have been developed for iopctl IP. Due to RT700 have multi iopctl instances, add code to handle the index value recorded in new pinctrl header file Signed-off-by: Lucien Zhao <[email protected]>
1 parent c0a0e6a commit 3ffe4f3

File tree

8 files changed

+117
-23
lines changed

8 files changed

+117
-23
lines changed

doc/releases/migration-guide-4.1.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ LVGL
3939
Device Drivers and Devicetree
4040
*****************************
4141

42+
* The :dtcompatible: ``nxp,lpc-iocon`` and ``nxp,rt-iocon-pinctrl`` driver won't be used
43+
for RT 3 digital platforms.
44+
New :dtcompatible:`nxp,iopctl` and :dtcompatible:`nxp,rt-iopctl-pinctrl` have been created
45+
for iopctl IP on RT 3 digital platforms. Change iocon node to iopctl0 node on RT500/600
46+
platforms. New pinctrl model add instance index parameter in pin header files, however,
47+
for the application layer, the pin macro name will not change. So it means application
48+
layer won't be affected by changes in the driver layer.(:github:`81086`)
49+
example:
50+
51+
.. code-block:: devicetree
52+
53+
/ {
54+
iopctl0: iopctl@4000 {
55+
compatible = "nxp,iopctl";
56+
reg = <0x4000 0x1000>;
57+
status = "okay";
58+
pinctrl: pinctrl {
59+
compatible = "nxp,rt-iopctl-pinctrl";
60+
};
61+
};
62+
4263
Controller Area Network (CAN)
4364
=============================
4465

drivers/pinctrl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ zephyr_library_sources_ifdef(CONFIG_PINCTRL_MCHP_XEC pinctrl_mchp_xec.c)
2020
zephyr_library_sources_ifdef(CONFIG_PINCTRL_IMX pinctrl_imx.c)
2121
zephyr_library_sources_ifdef(CONFIG_PINCTRL_SIFIVE pinctrl_sifive.c)
2222
zephyr_library_sources_ifdef(CONFIG_PINCTRL_NXP_IOCON pinctrl_lpc_iocon.c)
23+
zephyr_library_sources_ifdef(CONFIG_PINCTRL_NXP_IOPCTL pinctrl_iopctl.c)
2324
zephyr_library_sources_ifdef(CONFIG_PINCTRL_CC13XX_CC26XX pinctrl_cc13xx_cc26xx.c)
2425
zephyr_library_sources_ifdef(CONFIG_PINCTRL_ESP32 pinctrl_esp32.c)
2526
zephyr_library_sources_ifdef(CONFIG_PINCTRL_RV32M1 pinctrl_rv32m1.c)

drivers/pinctrl/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ source "drivers/pinctrl/Kconfig.xec"
4949
source "drivers/pinctrl/Kconfig.imx"
5050
source "drivers/pinctrl/Kconfig.sifive"
5151
source "drivers/pinctrl/Kconfig.lpc_iocon"
52+
source "drivers/pinctrl/Kconfig.iopctl"
5253
source "drivers/pinctrl/Kconfig.cc13xx_cc26xx"
5354
source "drivers/pinctrl/Kconfig.esp32"
5455
source "drivers/pinctrl/Kconfig.rv32m1"

drivers/pinctrl/Kconfig.iopctl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2024 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config PINCTRL_NXP_IOPCTL
5+
bool "IOPCTL Pin controller driver for NXP MCUs"
6+
default y
7+
depends on DT_HAS_NXP_RT_IOPCTL_PINCTRL_ENABLED
8+
help
9+
Enable pin controller driver for NXP MCUs

drivers/pinctrl/Kconfig.lpc_iocon

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# Copyright 2022, NXP
1+
# Copyright 2022,2024 NXP
22
# SPDX-License-Identifier: Apache-2.0
33

44
config PINCTRL_NXP_IOCON
55
bool "IOCON Pin controller driver for NXP LPC MCUs"
66
default y
77
depends on DT_HAS_NXP_LPC_IOCON_PINCTRL_ENABLED || \
8-
DT_HAS_NXP_LPC11U6X_PINCTRL_ENABLED || \
9-
DT_HAS_NXP_RT_IOCON_PINCTRL_ENABLED
8+
DT_HAS_NXP_LPC11U6X_PINCTRL_ENABLED
109
help
1110
Enable pin controller driver for NXP LPC MCUs

drivers/pinctrl/pinctrl_iopctl.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2024 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#define DT_DRV_COMPAT nxp_iopctl
8+
9+
#include <zephyr/drivers/pinctrl.h>
10+
#include <zephyr/init.h>
11+
12+
#define OFFSET(mux) (((mux) & 0xFFF00000) >> 20)
13+
#define INDEX(mux) (((mux) & 0xF0000) >> 16)
14+
#define Z_PINCTRL_IOPCTL_PIN_MASK 0xFFF
15+
16+
/* IOPCTL register addresses. */
17+
static uint32_t *iopctl[] = {
18+
#if (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(iopctl0)))
19+
(uint32_t *)DT_REG_ADDR(DT_NODELABEL(iopctl0)),
20+
#else
21+
NULL,
22+
#endif
23+
#if (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(iopctl1)))
24+
(uint32_t *)DT_REG_ADDR(DT_NODELABEL(iopctl1)),
25+
#else
26+
NULL,
27+
#endif
28+
#if (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(iopctl2)))
29+
(uint32_t *)DT_REG_ADDR(DT_NODELABEL(iopctl2)),
30+
#else
31+
NULL,
32+
#endif
33+
};
34+
35+
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
36+
{
37+
for (uint8_t i = 0; i < pin_cnt; i++) {
38+
uint32_t pin_mux = pins[i];
39+
uint32_t index = INDEX(pin_mux);
40+
uint32_t offset = OFFSET(pin_mux);
41+
42+
if (index < ARRAY_SIZE(iopctl)) {
43+
/* Set pinmux */
44+
*(iopctl[index] + offset) = (pin_mux & Z_PINCTRL_IOPCTL_PIN_MASK);
45+
} else {
46+
return -EINVAL;
47+
}
48+
}
49+
50+
return 0;
51+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2024 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: IO PAD Controller (IOPCTL)
5+
6+
compatible: "nxp,iopctl"
7+
8+
include: base.yaml
9+
10+
properties:
11+
reg:
12+
required: true

dts/bindings/pinctrl/nxp,rt-iocon-pinctrl.yaml renamed to dts/bindings/pinctrl/nxp,rt-iopctl-pinctrl.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Copyright 2022, NXP
1+
# Copyright 2022,2024 NXP
22
# SPDX-License-Identifier: Apache-2.0
33

44
description: |
5-
RT600/RT500 pin control node. This node defines pin configurations in pin
5+
RT700/RT600/RT500 pin control node. This node defines pin configurations in pin
66
groups, and has the 'pinctrl' node identifier in the SOC's devicetree. Each
77
group within the pin configuration defines a peripheral's pin configuration.
88
Each numbered subgroup represents pins with shared configuration for that
@@ -21,31 +21,31 @@ description: |
2121
2222
If only the required properties are supplied, the ICON_PIO register will
2323
be assigned the following values:
24-
IOCON_FUNC=<pin mux selection>,
25-
IOCON_PUPDENA = 0,
26-
IOCON_PUPDSEL = 0,
27-
IOCON_IBENA = 0,
28-
IOCON_SLEWRATE = <slew-rate selection>,
29-
IOCON_FULLDRIVE = <drive-strength selection>,
30-
IOCON_AMENA = 0,
31-
IOCON_ODENA = 0,
32-
IOCON_IIENA = 0,
24+
IOPCTL_FUNC=<pin mux selection>,
25+
IOPCTL_PUPDENA = 0,
26+
IOPCTL_PUPDSEL = 0,
27+
IOPCTL_IBENA = 0,
28+
IOPCTL_SLEWRATE = <slew-rate selection>,
29+
IOPCTL_FULLDRIVE = <drive-strength selection>,
30+
IOPCTL_AMENA = 0,
31+
IOPCTL_ODENA = 0,
32+
IOPCTL_IIENA = 0,
3333
3434
Note the inherited pinctrl properties defined below have the following effects:
35-
drive-open-drain: IOCON_ODENA=1
36-
bias-pull-up: IOCON_PUPDENA=1, IOCON_PUPSEL=1
37-
bias-pull-down: IOCON_PUPDENA=1, IOCON_PUPSEL=0
38-
input-enable: IOCON_IBENA=1
35+
drive-open-drain: IOPCTL_ODENA=1
36+
bias-pull-up: IOPCTL_PUPDENA=1, IOPCTL_PUPSEL=1
37+
bias-pull-down: IOPCTL_PUPDENA=1, IOPCTL_PUPSEL=0
38+
input-enable: IOPCTL_IBENA=1
3939
40-
compatible: "nxp,rt-iocon-pinctrl"
40+
compatible: "nxp,rt-iopctl-pinctrl"
4141

4242
include: base.yaml
4343

4444
child-binding:
45-
description: iMX RT IOCON pin controller pin group
45+
description: iMX RT IOPCTL pin controller pin group
4646
child-binding:
4747
description: |
48-
iMX RT IOCON pin controller pin configuration node
48+
iMX RT IOPCTL pin controller pin configuration node
4949
5050
include:
5151
- name: pincfg-node.yaml
@@ -69,7 +69,7 @@ child-binding:
6969
- "normal"
7070
- "slow"
7171
description: |
72-
Pin output slew rate. Sets the SLEWRATE field in the IOCON register.
72+
Pin output slew rate. Sets the SLEWRATE field in the IOPCTL register.
7373
0 SLEWRATE_0- normal mode, output slew rate is standard
7474
1 SLEWRATE_1- slow mode, output slew rate is slower
7575
drive-strength:
@@ -80,7 +80,7 @@ child-binding:
8080
- "high"
8181
description: |
8282
Pin output drive strength. Sets the FULLDRIVE field in the
83-
IOCON register.
83+
IOPCTL register.
8484
0 FULLDRIVE_0- Normal output drive mode
8585
1 FULLDRIVE_1- Full output drive mode, output strength is twice
8686
the drive strength of normal drive mode.

0 commit comments

Comments
 (0)