npcx: scfg: pinmux: cleanup unused functions and macro

Clean up unused pinmux function 'npcx_pinctrl_mux_configure()' and
related 'NPCX_DT_IO_ALT*' macro functions.

Please refer https://issuetracker.google.com/234861079 for more detail.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
This commit is contained in:
Mulin Chao 2022-06-06 23:16:17 -07:00 committed by Carles Cufí
parent 16699c6a5e
commit 3468a02f72
7 changed files with 21 additions and 213 deletions

View file

@ -41,7 +41,7 @@
* no_ks000-17 - PIN21.20.17.16.15.14.13.12.11.10.07.06.05.04.
* 82.83.03.B1
*/
pinctrl-0 = <>;
pinmux = <>;
};
def-lvol-io-list {

View file

@ -22,7 +22,7 @@
/ {
def-io-conf-list {
pinctrl-0 = <&alt0_gpio_no_spip
pinmux = <&alt0_gpio_no_spip
&alt0_gpio_no_fpip
&alt1_no_pwrgd
&alta_no_peci_en

View file

@ -22,7 +22,7 @@
/ {
def-io-conf-list {
pinctrl-0 = <&alt0_gpio_no_spip
pinmux = <&alt0_gpio_no_spip
&alt0_gpio_no_fpip
&alt1_no_pwrgd
&alta_no_peci_en

View file

@ -8,7 +8,7 @@ compatible: "nuvoton,npcx-pinctrl-def"
include: [base.yaml]
properties:
pinctrl-0:
pinmux:
type: phandles
required: true
description: list of configurations of pinmux controllers need to set

View file

@ -26,15 +26,22 @@ struct npcx_scfg_config {
* Get io list which default functionality are not IOs. Then switch them to
* GPIO in pin-mux init function.
*
* def_io_conf: def-io-conf-list {
* compatible = "nuvoton,npcx-pinctrl-def";
* pinctrl-0 = <&alt0_gpio_no_spip
* &alt0_gpio_no_fpip
* ...>;
* def-io-conf-list {
* pinmux = <&alt0_gpio_no_spip
* &alt0_gpio_no_fpip
* ...>;
* };
*/
static const struct npcx_alt def_alts[] =
NPCX_DT_IO_ALT_ITEMS_LIST(nuvoton_npcx_pinctrl_def, 0);
#define NPCX_NO_GPIO_ALT_ITEM(node_id, prop, idx) { \
.group = DT_PHA(DT_PROP_BY_IDX(node_id, prop, idx), alts, group), \
.bit = DT_PHA(DT_PROP_BY_IDX(node_id, prop, idx), alts, bit), \
.inverted = DT_PHA(DT_PROP_BY_IDX(node_id, prop, idx), alts, inv), \
},
static const struct npcx_alt def_alts[] = {
DT_FOREACH_PROP_ELEM(DT_INST(0, nuvoton_npcx_pinctrl_def), pinmux,
NPCX_NO_GPIO_ALT_ITEM)
};
static const struct npcx_lvol def_lvols[] = NPCX_DT_IO_LVOL_ITEMS_DEF_LIST;
@ -73,16 +80,6 @@ static void npcx_pinctrl_alt_sel(const struct npcx_alt *alt, int alt_func)
}
/* Platform specific pin-control functions */
void npcx_pinctrl_mux_configure(const struct npcx_alt *alts_list,
uint8_t alts_size, int altfunc)
{
int i;
for (i = 0; i < alts_size; i++, alts_list++) {
npcx_pinctrl_alt_sel(alts_list, altfunc);
}
}
void npcx_lvol_pads_configure(void)
{
const uint32_t scfg_base = npcx_scfg_cfg.base_scfg;
@ -229,7 +226,9 @@ static int npcx_scfg_init(const struct device *dev)
}
/* Change all pads whose default functionality isn't IO to GPIO */
npcx_pinctrl_mux_configure(def_alts, ARRAY_SIZE(def_alts), 0);
for (int i = 0; i < ARRAY_SIZE(def_alts); i++) {
npcx_pinctrl_alt_sel(&def_alts[i], 0);
}
/* Configure default low-voltage pads */
npcx_lvol_pads_configure();

View file

@ -125,161 +125,6 @@
inst) \
}
/**
* @brief Construct a npcx_alt structure from 'pinctrl-0' property at index 'i'
*
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
* @param i index of 'pinctrl-0' prop which type is 'phandles'
* @return npcx_alt item from 'pinctrl-0' property at index 'i'
*/
#define NPCX_DT_ALT_ITEM_BY_IDX(inst, i) \
{ \
.group = DT_PHA(DT_INST_PINCTRL_0(inst, i), alts, group), \
.bit = DT_PHA(DT_INST_PINCTRL_0(inst, i), alts, bit), \
.inverted = DT_PHA(DT_INST_PINCTRL_0(inst, i), alts, inv), \
}
/**
* @brief Macro function to construct npcx_alt item in UTIL_LISTIFY extension.
*
* @param child child index in UTIL_LISTIFY extension.
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
* @return macro function to construct a npcx_alt structure.
*/
#define NPCX_DT_ALT_ITEMS_FUNC(child, inst) NPCX_DT_ALT_ITEM_BY_IDX(inst, child)
/**
* @brief Macro function to construct a list of npcx_alt items with compatible
* defined in DT_DRV_COMPAT by UTIL_LISTIFY func
*
* Example devicetree fragment:
* / {
* uart1: serial@400c4000 {
* pinctrl-0 = <&alta_uart1_sl1>;
* ...
* };
* };
*
* Example usage:
* const struct npcx_alt uart_alts[] = NPCX_DT_ALT_ITEMS_LIST(inst);
*
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
* @return an array of npcx_alt items.
*/
#define NPCX_DT_ALT_ITEMS_LIST(inst) { \
LISTIFY(DT_INST_NUM_PINCTRLS_BY_IDX(inst, 0), \
NPCX_DT_ALT_ITEMS_FUNC, (,), \
inst) \
}
/**
* @brief Node identifier for an instance of a specific compatible
*
* @param compat specific compatible of devices in device-tree file
* @param inst instance number
* @return a node identifier for the node with "io_comp" compatible and
* instance number "inst"
*/
#define NPCX_DT_COMP_INST(compat, inst) DT_INST(inst, compat)
/**
* @brief Get a specific compatible instance's node identifier for a phandle in
* a property.
*
* @param compat specific compatible of devices in device-tree file
* @param inst instance number
* @param prop lowercase-and-underscores property name in "inst"
* with type "phandle", "phandles" or "phandle-array"
* @param idx index into "prop"
* @return a node identifier for the phandle at index "idx" in "prop"
*/
#define NPCX_DT_COMP_INST_PHANDLE_BY_IDX(compat, inst, prop, idx) \
DT_PHANDLE_BY_IDX(NPCX_DT_COMP_INST(compat, inst), prop, idx)
/**
* @brief Get phandle from 'pinctrl-0' prop which type is 'phandles' at index
* 'i' from io-pads device with specific compatible.
*
* @param io_comp compatible string in devicetree file for io-pads device
* @param inst instance number for compatible defined in io_comp.
* @param i index of 'pinctrl-0' prop which type is 'phandles'
* @return phandle from 'pinctrl-0' prop at index 'i'
*/
#define NPCX_DT_IO_PHANDLE_FROM_PINCTRL(io_comp, inst, i) \
DT_PINCTRL_BY_IDX(NPCX_DT_COMP_INST(io_comp, inst), 0, i)
/**
* @brief Construct a npcx_alt structure from 'pinctrl-0' property at index 'i'
* from io-pads device with specific compatible.
*
* @param io_comp compatible string in devicetree file for io-pads device
* @param inst instance number for compatible defined in io_comp.
* @param i index of 'pinctrl-0' prop which type is 'phandles'
* @return npcx_alt item from 'pinctrl-0' property at index 'i'
*/
#define NPCX_DT_IO_ALT_ITEM_BY_IDX(io_comp, inst, i) \
{ \
.group = DT_PHA(NPCX_DT_IO_PHANDLE_FROM_PINCTRL(io_comp, inst, i), \
alts, group), \
.bit = DT_PHA(NPCX_DT_IO_PHANDLE_FROM_PINCTRL(io_comp, inst, i), \
alts, bit), \
.inverted = DT_PHA(NPCX_DT_IO_PHANDLE_FROM_PINCTRL(io_comp, inst, i),\
alts, inv), \
}
/**
* @brief Length of npcx_alt structures in 'pinctrl-0' property of specific
* compatible io-pads device
*
* @param io_comp compatible string in devicetree file for io-pads device
* @param inst instance number for compatible defined in io_comp.
* @return length of 'pinctrl-0' property which type is 'phandles'
*/
#define NPCX_DT_IO_ALT_ITEMS_LEN(io_comp, inst) \
DT_NUM_PINCTRLS_BY_IDX(NPCX_DT_COMP_INST(io_comp, inst), 0)
/**
* @brief Macro function to construct npcx_alt item with specific compatible
* string in UTIL_LISTIFY extension.
*
* @param child child index in UTIL_LISTIFY extension.
* @param inst instance number for compatible defined in io_comp.
* @param io_comp compatible string in devicetree file for io-pads device
* @return macro function to construct a npcx_alt structure.
*/
#define NPCX_DT_IO_ALT_ITEMS_FUNC(child, inst, io_comp) \
NPCX_DT_IO_ALT_ITEM_BY_IDX(io_comp, inst, child)
/**
* @brief Macro function to construct a list of npcx_alt items with specific
* compatible string by UTIL_LISTIFY func
*
* Example devicetree fragment:
* / {
* host_uart: io_host_uart {
* compatible = "nuvoton,npcx-host-uart";
*
* pinctrl-0 = <&altb_rxd_sl &altb_txd_sl
* &altb_rts_sl &altb_cts_sl
* &altb_ri_sl &altb_dtr_bout_sl
* &altb_dcd_sl &altb_dsr_sl>;
* ...
* };
* };
*
* Example usage:
* const struct npcx_alt host_uart_alts[] =
* NPCX_DT_IO_ALT_ITEMS_LIST(nuvoton_npcx_host_uart, 0);
* @param io_comp compatible string in devicetree file for io-pads device
* @param inst instance number for compatible defined in io_comp.
* @return an array of npcx_alt items.
*/
#define NPCX_DT_IO_ALT_ITEMS_LIST(io_comp, inst) { \
LISTIFY(NPCX_DT_IO_ALT_ITEMS_LEN(io_comp, inst), \
NPCX_DT_IO_ALT_ITEMS_FUNC, (,), \
inst, io_comp) \
}
/**
* @brief Get phandle from "name" property which contains wui information.
*

View file

@ -62,42 +62,6 @@ struct npcx_psl_in {
struct npcx_alt polarity;
};
/**
* @brief Select device pin-mux to I/O or its alternative functionality
*
* Example devicetree fragment:
* / {
* uart1: serial@400c4000 {
* //altfunc 0: PIN64.65, otherwise CR_SIN1 CR_SOUT1
* pinctrl = <&altc_uart1_sl2>;
* ...
* };
*
* kscan0: kscan@400a3000 {
* //altfunc 0: PIN31.xx PIN21.xx, otherwise KSO0-x KSI0-x
* pinctrl = <&alt7_no_ksi0_sl ...
* &alt8_no_kso00_sl ...>;
* ...
* };
* };
*
* Example usage:
* - Pinmux configuration list
* const struct npcx_alt alts_list[] = NPCX_DT_ALT_ITEMS_LIST(inst);
* - Change pinmux to UART:
* npcx_pinctrl_mux_configure(alts_list, ARRAY_SIZE(alts_list), 1);
* - Change pinmux back to GPIO64.65:
* npcx_pinctrl_mux_configure(alts_list, ARRAY_SIZE(alts_list), 0);
*
* Please refer more details in Table 3. (Pin Multiplexing Configuration).
*
* @param alts_list Pointer to pin-mux configuration list for specific device
* @param alts_size Pin-mux configuration list size
* @param altfunc 0: set pin-mux to GPIO, otherwise specific functionality
*/
void npcx_pinctrl_mux_configure(const struct npcx_alt *alts_list,
uint8_t alts_size, int altfunc);
/**
* @brief Select i2c port pads of i2c controller
*