Skip to content

Commit d40037c

Browse files
mbolivar-nordicnashif
authored andcommitted
soc: nuvoton_npcx: use new DT pinctrl accessors
Update to use the new APIs. Fix a typo while I'm here. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 73c7f55 commit d40037c

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

soc/arm/nuvoton_npcx/common/soc_dt.h

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -121,39 +121,20 @@
121121
inst) \
122122
}
123123

124-
/**
125-
* @brief Get phandle from 'pinctrl-0' prop which type is 'phandles' at index
126-
* 'i'
127-
*
128-
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
129-
* @param i index of 'pinctrl-0' prop which type is 'phandles'
130-
* @return phandle from 'pinctrl-0' prop at index 'i'
131-
*/
132-
#define NPCX_DT_PHANDLE_FROM_PINCTRL(inst, i) \
133-
DT_INST_PHANDLE_BY_IDX(inst, pinctrl_0, i)
134-
135124
/**
136125
* @brief Construct a npcx_alt structure from 'pinctrl-0' property at index 'i'
137126
*
138127
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
139128
* @param i index of 'pinctrl-0' prop which type is 'phandles'
140129
* @return npcx_alt item from 'pinctrl-0' property at index 'i'
141130
*/
142-
#define NPCX_DT_ALT_ITEM_BY_IDX(inst, i) \
143-
{ \
144-
.group = DT_PHA(NPCX_DT_PHANDLE_FROM_PINCTRL(inst, i), alts, group), \
145-
.bit = DT_PHA(NPCX_DT_PHANDLE_FROM_PINCTRL(inst, i), alts, bit), \
146-
.inverted = DT_PHA(NPCX_DT_PHANDLE_FROM_PINCTRL(inst, i), alts, inv),\
131+
#define NPCX_DT_ALT_ITEM_BY_IDX(inst, i) \
132+
{ \
133+
.group = DT_PHA(DT_INST_PINCTRL_0(inst, i), alts, group), \
134+
.bit = DT_PHA(DT_INST_PINCTRL_0(inst, i), alts, bit), \
135+
.inverted = DT_PHA(DT_INST_PINCTRL_0(inst, i), alts, inv), \
147136
},
148137

149-
/**
150-
* @brief Length of npcx_alt structures in 'pinctrl-0' property
151-
*
152-
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
153-
* @return length of 'pinctrl-0' property which type is 'phandles'
154-
*/
155-
#define NPCX_DT_ALT_ITEMS_LEN(inst) DT_INST_PROP_LEN(inst, pinctrl_0)
156-
157138
/**
158139
* @brief Macro function to construct npcx_alt item in UTIL_LISTIFY extension.
159140
*
@@ -181,10 +162,10 @@
181162
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
182163
* @return an array of npcx_alt items.
183164
*/
184-
#define NPCX_DT_ALT_ITEMS_LIST(inst) { \
185-
UTIL_LISTIFY(NPCX_DT_ALT_ITEMS_LEN(inst), \
186-
NPCX_DT_ALT_ITEMS_FUNC, \
187-
inst) \
165+
#define NPCX_DT_ALT_ITEMS_LIST(inst) { \
166+
UTIL_LISTIFY(DT_INST_NUM_PINCTRLS_BY_IDX(inst, 0), \
167+
NPCX_DT_ALT_ITEMS_FUNC, \
168+
inst) \
188169
}
189170

190171
/**
@@ -221,15 +202,15 @@
221202
* @return phandle from 'pinctrl-0' prop at index 'i'
222203
*/
223204
#define NPCX_DT_IO_PHANDLE_FROM_PINCTRL(io_comp, inst, i) \
224-
NPCX_DT_COMP_INST_PHANDLE_BY_IDX(io_comp, inst, pinctrl_0, i)
205+
DT_PINCTRL_BY_IDX(NPCX_DT_COMP_INST(io_comp, inst), 0, i)
225206

226207
/**
227208
* @brief Construct a npcx_alt structure from 'pinctrl-0' property at index 'i'
228209
* from io-pads device with specific compatible.
229210
*
230211
* @param io_comp compatible string in devicetree file for io-pads device
231212
* @param inst instance number for compatible defined in io_comp.
232-
* @param i index of 'pinctrl_0' prop which type is 'phandles'
213+
* @param i index of 'pinctrl-0' prop which type is 'phandles'
233214
* @return npcx_alt item from 'pinctrl-0' property at index 'i'
234215
*/
235216
#define NPCX_DT_IO_ALT_ITEM_BY_IDX(io_comp, inst, i) \
@@ -251,7 +232,7 @@
251232
* @return length of 'pinctrl-0' property which type is 'phandles'
252233
*/
253234
#define NPCX_DT_IO_ALT_ITEMS_LEN(io_comp, inst) \
254-
DT_PROP_LEN(NPCX_DT_COMP_INST(io_comp, inst), pinctrl_0)
235+
DT_NUM_PINCTRLS_BY_IDX(NPCX_DT_COMP_INST(io_comp, inst), 0)
255236

256237
/**
257238
* @brief Macro function to construct npcx_alt item with specific compatible
@@ -607,7 +588,7 @@
607588
* @return phandle from 'pinctrl-0' prop at index 'i'
608589
*/
609590
#define NPCX_DT_PHANDLE_FROM_PSL_PINMUX_NODE(i) \
610-
DT_PHANDLE(NPCX_DT_PHANDLE_FROM_PSL_IN_NODE(i), pinctrl_0)
591+
DT_PINCTRL_0(NPCX_DT_PHANDLE_FROM_PSL_IN_NODE(i), 0)
611592

612593
/**
613594
* @brief Get phandle from 'polarity-0' prop which type is 'phandles' at index

0 commit comments

Comments
 (0)