Skip to content

Commit 94f9340

Browse files
mmahadevan108henrikbrixandersen
authored andcommitted
dts: nxp: Add sleep-output property
This property allows a user to specify the operation of a pin in sleep mode. By default, pins are configured to be output low in sleep mode. Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 01d3575 commit 94f9340

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

drivers/pinctrl/pinctrl_mci_io_mux.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/*
2-
* Copyright 2022 NXP
2+
* Copyright 2022, 2025 NXP
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

77
#include <zephyr/drivers/pinctrl.h>
88
#include <soc.h>
99

10+
#define NO_FORCE_OUTPUT 2
11+
1012
static MCI_IO_MUX_Type *mci_iomux =
1113
(MCI_IO_MUX_Type *)DT_REG_ADDR(DT_NODELABEL(pinctrl));
1214

@@ -59,6 +61,19 @@ static void configure_pin_props(uint32_t pin_mux, uint8_t gpio_idx)
5961
/* Set slew rate */
6062
set = IOMUX_PAD_GET_SLEW(pin_mux) << ((gpio_idx & 0xF) << 1);
6163
*slew_reg = (*slew_reg & ~mask) | set;
64+
65+
/* Set sleep force enable bit */
66+
mask = (0x1 << (gpio_idx & 0x1F));
67+
/* Check if we should force the pin to output in sleep mode */
68+
if (IOMUX_PAD_GET_SLEEP_FORCE(pin_mux) == NO_FORCE_OUTPUT) {
69+
/* Does not force output during sleep */
70+
*sleep_force_en = (*sleep_force_en & ~mask);
71+
} else {
72+
/* Enable forcing output during sleep */
73+
*sleep_force_en = (*sleep_force_en | mask);
74+
set = (IOMUX_PAD_GET_SLEEP_FORCE_VAL(pin_mux) << (gpio_idx & 0x1F));
75+
*sleep_force_val = (*sleep_force_val & ~mask) | set;
76+
}
6277
}
6378

6479
static void select_gpio_mode(uint8_t gpio_idx)

dts/bindings/pinctrl/nxp,mci-io-mux.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,15 @@ child-binding:
6969
1 - normal slew rate
7070
2 - fast slew rate
7171
3 - fastest slew rate (ultra)
72+
sleep-output:
73+
type: string
74+
default: "low"
75+
enum:
76+
- "low"
77+
- "high"
78+
- "disable"
79+
description: |
80+
Sets pin output level in sleep mode.
81+
0 - output level low
82+
1 - output level high
83+
2 - disable force output in sleep mode.

soc/nxp/rw/pinctrl_defs.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@
7474
/* Pin configuration settings */
7575
#define IOMUX_PAD_PULL(x) (((x) & 0x3) << 19)
7676
#define IOMUX_PAD_SLEW(x) (((x) & 0x3) << 21)
77-
#define IOMUX_PAD_SLEEP_FORCE(en, val) \
78-
((((en) & 0x1) << 24) | (((val) & 0x1) << 23))
77+
#define IOMUX_PAD_SLEEP_FORCE(en) (((en) & 0x3) << 23)
7978
#define IOMUX_PAD_GET_PULL(mux) (((mux) >> 19) & 0x3)
8079
#define IOMUX_PAD_GET_SLEW(mux) (((mux) >> 21) & 0x3)
81-
#define IOMUX_PAD_GET_SLEEP_FORCE_EN(mux) (((mux) >> 24) & 0x1)
80+
#define IOMUX_PAD_GET_SLEEP_FORCE(mux) (((mux) >> 23) & 0x3)
8281
#define IOMUX_PAD_GET_SLEEP_FORCE_VAL(mux) (((mux) >> 23) & 0x1)
8382

8483
/*

soc/nxp/rw/pinctrl_soc.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@ extern "C" {
2020

2121
typedef uint32_t pinctrl_soc_pin_t;
2222

23-
24-
#define Z_PINCTRL_IOMUX_PINCFG(node_id) \
25-
(IF_ENABLED(DT_PROP(node_id, bias_pull_down), \
26-
(IOMUX_PAD_PULL(0x2) |)) /* pull down */ \
27-
IF_ENABLED(DT_PROP(node_id, bias_pull_up), \
28-
(IOMUX_PAD_PULL(0x1) |)) /* pull up */ \
29-
IF_ENABLED(DT_NODE_HAS_PROP(node_id, sleep_output), /* force output */ \
30-
IOMUX_PAD_SLEEP_FORCE(0x1, DT_ENUM_IDX(node_id, sleep_output))) \
23+
#define Z_PINCTRL_IOMUX_PINCFG(node_id) \
24+
(IF_ENABLED(DT_PROP(node_id, bias_pull_down), \
25+
(IOMUX_PAD_PULL(0x2) |)) /* pull down */ \
26+
IF_ENABLED(DT_PROP(node_id, bias_pull_up), \
27+
(IOMUX_PAD_PULL(0x1) |)) /* pull up */ \
28+
IF_ENABLED(DT_NODE_HAS_PROP(node_id, sleep_output), \
29+
(IOMUX_PAD_SLEEP_FORCE(DT_ENUM_IDX(node_id, sleep_output)) |)) /* force output */ \
3130
IOMUX_PAD_SLEW(DT_ENUM_IDX(node_id, slew_rate))) /* slew rate */
3231

33-
3432
#define Z_PINCTRL_STATE_PIN_INIT(group, pin_prop, idx) \
3533
DT_PROP_BY_IDX(group, pin_prop, idx) | Z_PINCTRL_IOMUX_PINCFG(group),
3634

0 commit comments

Comments
 (0)