2020-07-02 15:44:38 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Nuvoton Technology Corporation.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NUVOTON_NPCX_SOC_DT_H_
|
|
|
|
#define _NUVOTON_NPCX_SOC_DT_H_
|
|
|
|
|
2021-04-25 23:46:04 -07:00
|
|
|
/**
|
|
|
|
* @brief Like DT_PROP(), but expand parameters with
|
|
|
|
* DT_ENUM_UPPER_TOKEN not DT_PROP
|
|
|
|
*
|
|
|
|
* If the prop exists, this expands to DT_ENUM_UPPER_TOKEN(node_id, prop).
|
|
|
|
* The default_value parameter is not expanded in this case.
|
|
|
|
*
|
|
|
|
* Otherwise, this expands to default_value.
|
|
|
|
*
|
|
|
|
* @param node_id node identifier
|
|
|
|
* @param prop lowercase-and-underscores property name
|
|
|
|
* @param default_value a fallback value to expand to
|
|
|
|
* @return the property's enum upper token value or default_value
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PROP_ENUM_OR(node_id, prop, default_value) \
|
|
|
|
COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
|
2021-05-17 17:24:27 +02:00
|
|
|
(DT_STRING_UPPER_TOKEN(node_id, prop)), (default_value))
|
2021-04-25 23:46:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Like DT_INST_PROP_OR(), but expand parameters with
|
|
|
|
* NPCX_DT_PROP_ENUM_OR not DT_PROP_OR
|
|
|
|
* @param inst instance number
|
|
|
|
* @param prop lowercase-and-underscores property name
|
|
|
|
* @param default_value a fallback value to expand to
|
|
|
|
* @return the property's enum upper token value or default_value
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_INST_PROP_ENUM_OR(inst, prop, default_value) \
|
|
|
|
NPCX_DT_PROP_ENUM_OR(DT_DRV_INST(inst), prop, default_value)
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Construct a npcx_clk_cfg item from first item in 'clocks' prop which
|
|
|
|
* type is 'phandle-array' to handle "clock-cells" in current driver.
|
|
|
|
*
|
|
|
|
* Example devicetree fragment:
|
|
|
|
* / {
|
|
|
|
* uart1: serial@400c4000 {
|
|
|
|
* clocks = <&pcc NPCX_CLOCK_BUS_APB2 NPCX_PWDWN_CTL1 4>;
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
* };
|
|
|
|
*
|
2020-12-24 00:44:26 -08:00
|
|
|
* Example usage:
|
2020-12-06 23:41:07 -08:00
|
|
|
* const struct npcx_clk_cfg clk_cfg = NPCX_DT_CLK_CFG_ITEM(inst);
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
|
|
|
* @return npcx_clk_cfg item.
|
2020-07-02 15:44:38 +08:00
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_CLK_CFG_ITEM(inst) \
|
2020-07-02 15:44:38 +08:00
|
|
|
{ \
|
2021-04-25 23:46:04 -07:00
|
|
|
.bus = NPCX_DT_INST_PROP_ENUM_OR(inst, clock_bus, \
|
|
|
|
DT_PHA(DT_DRV_INST(inst), clocks, bus)), \
|
2020-07-02 15:44:38 +08:00
|
|
|
.ctrl = DT_PHA(DT_DRV_INST(inst), clocks, ctl), \
|
|
|
|
.bit = DT_PHA(DT_DRV_INST(inst), clocks, bit), \
|
|
|
|
}
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Construct a npcx_clk_cfg structure from 'clocks' property at index 'i'
|
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
|
|
|
* @param i index of clocks prop which type is 'phandle-array'
|
|
|
|
* @return npcx_clk_cfg item from 'clocks' property at index 'i'
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_CLK_CFG_ITEM_BY_IDX(inst, i) \
|
2020-09-10 17:39:44 +08:00
|
|
|
{ \
|
|
|
|
.bus = DT_CLOCKS_CELL_BY_IDX(DT_DRV_INST(inst), i, bus), \
|
|
|
|
.ctrl = DT_CLOCKS_CELL_BY_IDX(DT_DRV_INST(inst), i, ctl), \
|
|
|
|
.bit = DT_CLOCKS_CELL_BY_IDX(DT_DRV_INST(inst), i, bit), \
|
|
|
|
},
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Length of 'clocks' property which type is 'phandle-array'
|
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
|
|
|
* @return length of 'clocks' property which type is 'phandle-array'
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_CLK_CFG_ITEMS_LEN(inst) DT_INST_PROP_LEN(inst, clocks)
|
2020-09-10 17:39:44 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Macro function to construct npcx_clk_cfg 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_clk_cfg structure.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_CLK_CFG_ITEMS_FUNC(child, inst) \
|
|
|
|
NPCX_DT_CLK_CFG_ITEM_BY_IDX(inst, child)
|
2020-09-10 17:39:44 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Macro function to construct a list of npcx_clk_cfg items by
|
|
|
|
* UTIL_LISTIFY func
|
|
|
|
*
|
|
|
|
* Example devicetree fragment:
|
|
|
|
* / {
|
|
|
|
* host_sub: lpc@400c1000 {
|
|
|
|
* clocks = <&pcc NPCX_CLOCK_BUS_APB3 NPCX_PWDWN_CTL5 3>,
|
|
|
|
* <&pcc NPCX_CLOCK_BUS_APB3 NPCX_PWDWN_CTL5 4>,
|
|
|
|
* <&pcc NPCX_CLOCK_BUS_APB3 NPCX_PWDWN_CTL5 5>,
|
|
|
|
* <&pcc NPCX_CLOCK_BUS_APB3 NPCX_PWDWN_CTL5 6>,
|
|
|
|
* <&pcc NPCX_CLOCK_BUS_APB3 NPCX_PWDWN_CTL5 7>;
|
|
|
|
* ...
|
|
|
|
* };
|
2020-12-24 00:44:26 -08:00
|
|
|
* Example usage:
|
2020-12-06 23:41:07 -08:00
|
|
|
* const struct npcx_clk_cfg clk_cfg[] = NPCX_DT_CLK_CFG_ITEMS_LIST(0);
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
|
|
|
* @return an array of npcx_clk_cfg items.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_CLK_CFG_ITEMS_LIST(inst) { \
|
|
|
|
UTIL_LISTIFY(NPCX_DT_CLK_CFG_ITEMS_LEN(inst), \
|
|
|
|
NPCX_DT_CLK_CFG_ITEMS_FUNC, \
|
2020-09-10 17:39:44 +08:00
|
|
|
inst) \
|
|
|
|
}
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2020-10-21 10:57:53 +08:00
|
|
|
* @brief Construct a npcx_alt structure from 'pinctrl-0' property at index 'i'
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
2020-12-06 23:41:07 -08:00
|
|
|
* @param i index of 'pinctrl-0' prop which type is 'phandles'
|
2020-10-21 10:57:53 +08:00
|
|
|
* @return npcx_alt item from 'pinctrl-0' property at index 'i'
|
2020-09-15 17:21:45 +08:00
|
|
|
*/
|
2021-08-12 07:12:26 -07:00
|
|
|
#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), \
|
2020-07-02 17:34:21 +08:00
|
|
|
},
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @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.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_ALT_ITEMS_FUNC(child, inst) NPCX_DT_ALT_ITEM_BY_IDX(inst, child)
|
2020-07-02 17:34:21 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2020-12-06 23:41:07 -08:00
|
|
|
* @brief Macro function to construct a list of npcx_alt items with compatible
|
|
|
|
* defined in DT_DRV_COMPAT by UTIL_LISTIFY func
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* Example devicetree fragment:
|
|
|
|
* / {
|
|
|
|
* uart1: serial@400c4000 {
|
2020-10-21 10:57:53 +08:00
|
|
|
* pinctrl-0 = <&alta_uart1_sl1>;
|
2020-09-15 17:21:45 +08:00
|
|
|
* ...
|
|
|
|
* };
|
2020-12-06 23:41:07 -08:00
|
|
|
* };
|
|
|
|
*
|
2020-12-24 00:44:26 -08:00
|
|
|
* Example usage:
|
2020-12-06 23:41:07 -08:00
|
|
|
* 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.
|
|
|
|
*/
|
2021-08-12 07:12:26 -07:00
|
|
|
#define NPCX_DT_ALT_ITEMS_LIST(inst) { \
|
|
|
|
UTIL_LISTIFY(DT_INST_NUM_PINCTRLS_BY_IDX(inst, 0), \
|
|
|
|
NPCX_DT_ALT_ITEMS_FUNC, \
|
|
|
|
inst) \
|
2020-12-06 23:41:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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) \
|
2021-08-12 07:12:26 -07:00
|
|
|
DT_PINCTRL_BY_IDX(NPCX_DT_COMP_INST(io_comp, inst), 0, i)
|
2020-12-06 23:41:07 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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.
|
2021-08-12 07:12:26 -07:00
|
|
|
* @param i index of 'pinctrl-0' prop which type is 'phandles'
|
2020-12-06 23:41:07 -08:00
|
|
|
* @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) \
|
2021-08-12 07:12:26 -07:00
|
|
|
DT_NUM_PINCTRLS_BY_IDX(NPCX_DT_COMP_INST(io_comp, inst), 0)
|
2020-12-06 23:41:07 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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";
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
2020-10-21 10:57:53 +08:00
|
|
|
* pinctrl-0 = <&altb_rxd_sl &altb_txd_sl
|
2020-09-15 17:21:45 +08:00
|
|
|
* &altb_rts_sl &altb_cts_sl
|
|
|
|
* &altb_ri_sl &altb_dtr_bout_sl
|
|
|
|
* &altb_dcd_sl &altb_dsr_sl>;
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
* };
|
|
|
|
*
|
2020-12-24 00:44:26 -08:00
|
|
|
* Example usage:
|
2020-12-06 23:41:07 -08:00
|
|
|
* 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.
|
2020-09-15 17:21:45 +08:00
|
|
|
* @return an array of npcx_alt items.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_IO_ALT_ITEMS_LIST(io_comp, inst) { \
|
|
|
|
UTIL_LISTIFY(NPCX_DT_IO_ALT_ITEMS_LEN(io_comp, inst), \
|
|
|
|
NPCX_DT_IO_ALT_ITEMS_FUNC, \
|
|
|
|
inst, io_comp) \
|
2020-07-02 17:34:21 +08:00
|
|
|
}
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Get phandle from "name" property which contains wui information.
|
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
|
|
|
* @param name property 'name' which type is 'phandle' and contains wui info.
|
|
|
|
* @return phandle from 'name' property.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_PHANDLE_FROM_WUI_NAME(inst, name) \
|
2020-09-15 17:21:45 +08:00
|
|
|
DT_INST_PHANDLE(inst, name)
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Construct a npcx_wui structure from 'name' property
|
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
|
|
|
* @param name property 'name'which type is 'phandle' and contains wui info.
|
|
|
|
* @return npcx_wui item from 'name' property.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_WUI_ITEM_BY_NAME(inst, name) \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
{ \
|
2020-12-06 23:41:07 -08:00
|
|
|
.table = DT_PROP(DT_PHANDLE(NPCX_DT_PHANDLE_FROM_WUI_NAME(inst, \
|
|
|
|
name), miwus), index), \
|
|
|
|
.group = DT_PHA(NPCX_DT_PHANDLE_FROM_WUI_NAME(inst, name), miwus, \
|
|
|
|
group), \
|
|
|
|
.bit = DT_PHA(NPCX_DT_PHANDLE_FROM_WUI_NAME(inst, name), miwus, \
|
|
|
|
bit), \
|
2020-09-15 17:21:45 +08:00
|
|
|
}
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2021-03-22 23:57:51 -07:00
|
|
|
* @brief Get phandle from 'wui-maps' prop which type is 'phandles' at index 'i'
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
2021-03-22 23:57:51 -07:00
|
|
|
* @param i index of 'wui-maps' prop which type is 'phandles'
|
|
|
|
* @return phandle from 'wui-maps' prop at index 'i'
|
2020-09-15 17:21:45 +08:00
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_PHANDLE_FROM_WUI_MAPS(inst, i) \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
DT_INST_PHANDLE_BY_IDX(inst, wui_maps, i)
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2021-03-22 23:57:51 -07:00
|
|
|
* @brief Construct a npcx_wui structure from wui-maps property at index 'i'
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
2021-03-22 23:57:51 -07:00
|
|
|
* @param i index of 'wui-maps' prop which type is 'phandles'
|
2020-09-15 17:21:45 +08:00
|
|
|
* @return npcx_wui item at index 'i'
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_WUI_ITEM_BY_IDX(inst, i) \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
{ \
|
2020-12-06 23:41:07 -08:00
|
|
|
.table = DT_PROP(DT_PHANDLE(NPCX_DT_PHANDLE_FROM_WUI_MAPS(inst, i), \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
miwus), index), \
|
2020-12-06 23:41:07 -08:00
|
|
|
.group = DT_PHA(NPCX_DT_PHANDLE_FROM_WUI_MAPS(inst, i), miwus, \
|
|
|
|
group), \
|
|
|
|
.bit = DT_PHA(NPCX_DT_PHANDLE_FROM_WUI_MAPS(inst, i), miwus, bit), \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
},
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2021-03-22 23:57:51 -07:00
|
|
|
* @brief Length of npcx_wui structures in 'wui-maps' property
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
2021-03-22 23:57:51 -07:00
|
|
|
* @return length of 'wui-maps' prop which type is 'phandles'
|
2020-09-15 17:21:45 +08:00
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_WUI_ITEMS_LEN(inst) DT_INST_PROP_LEN(inst, wui_maps)
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Macro function to construct a list of npcx_wui items by UTIL_LISTIFY
|
|
|
|
*
|
|
|
|
* @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_wui structure.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_WUI_ITEMS_FUNC(child, inst) NPCX_DT_WUI_ITEM_BY_IDX(inst, child)
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Macro function to construct a list of npcx_wui items by UTIL_LISTIFY
|
|
|
|
* func.
|
|
|
|
*
|
|
|
|
* Example devicetree fragment:
|
|
|
|
* / {
|
|
|
|
* uart1: serial@400c4000 {
|
2021-03-22 23:57:51 -07:00
|
|
|
* uart-rx = <&wui_cr_sin1>;
|
2020-09-15 17:21:45 +08:00
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* gpio0: gpio@40081000 {
|
2021-03-22 23:57:51 -07:00
|
|
|
* wui-maps = <&wui_io00 &wui_io01 &wui_io02 &wui_io03
|
2020-09-15 17:21:45 +08:00
|
|
|
* &wui_io04 &wui_io05 &wui_io06 &wui_io07>;
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
* };
|
|
|
|
*
|
2020-12-24 00:44:26 -08:00
|
|
|
* Example usage:
|
2020-12-06 23:41:07 -08:00
|
|
|
* const struct npcx_wui wui_map = NPCX_DT_PHANDLE_FROM_WUI_NAME(inst, uart_rx);
|
|
|
|
* const struct npcx_wui wui_maps[] = NPCX_DT_WUI_ITEMS_LIST(inst);
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
|
|
|
* @param inst instance number for compatible defined in DT_DRV_COMPAT.
|
|
|
|
* @return an array of npcx_wui items.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_WUI_ITEMS_LIST(inst) { \
|
|
|
|
UTIL_LISTIFY(NPCX_DT_WUI_ITEMS_LEN(inst), \
|
|
|
|
NPCX_DT_WUI_ITEMS_FUNC, \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
inst) \
|
|
|
|
}
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Get a node from path '/npcx_miwus_map/map_miwu(0/1/2)_groups'
|
|
|
|
*
|
|
|
|
* @param i index of npcx miwu devices
|
|
|
|
* @return node identifier with that path.
|
|
|
|
*/
|
2021-04-26 01:28:21 -07:00
|
|
|
#define NPCX_DT_NODE_FROM_MIWU_MAP(i) DT_PATH(npcx_miwus_int_map, \
|
2020-12-06 23:41:07 -08:00
|
|
|
map_miwu##i##_groups)
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Get the index prop from parent MIWU device node.
|
|
|
|
*
|
|
|
|
* @param child index in UTIL_LISTIFY extension.
|
|
|
|
* @return 'index' prop value of the node which compatible type is
|
|
|
|
* "nuvoton,npcx-miwu".
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_MIWU_IRQ_TABLE_IDX(child) \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
DT_PROP(DT_PHANDLE(DT_PARENT(child), parent), index)
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Macro function for DT_FOREACH_CHILD to generate a IRQ_CONNECT
|
|
|
|
* implementation.
|
|
|
|
*
|
|
|
|
* @param child index in UTIL_LISTIFY extension.
|
|
|
|
* @return implementation to initialize interrupts of MIWU groups and enable
|
|
|
|
* them.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_MIWU_IRQ_CONNECT_IMPL_CHILD_FUNC(child) \
|
|
|
|
NPCX_DT_MIWU_IRQ_CONNECT_IMPL_CHILD_FUNC_OBJ(child);
|
|
|
|
|
|
|
|
#define NPCX_DT_MIWU_IRQ_CONNECT_IMPL_CHILD_FUNC_OBJ(child) \
|
|
|
|
do { \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
IRQ_CONNECT(DT_PROP(child, irq), \
|
|
|
|
DT_PROP(child, irq_prio), \
|
2020-12-06 23:41:07 -08:00
|
|
|
NPCX_MIWU_ISR_FUNC(NPCX_DT_MIWU_IRQ_TABLE_IDX(child)), \
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
DT_PROP(child, group_mask), \
|
|
|
|
0); \
|
|
|
|
irq_enable(DT_PROP(child, irq)); \
|
2020-12-06 23:41:07 -08:00
|
|
|
} while (0)
|
2020-07-02 17:34:21 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2021-04-26 01:28:21 -07:00
|
|
|
* @brief Get a child node from path '/npcx-espi-vws-map/name'.
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
2021-04-26 01:28:21 -07:00
|
|
|
* @param name a path which name is /npcx-espi-vws-map/'name'.
|
2020-09-15 17:21:45 +08:00
|
|
|
* @return child node identifier with that path.
|
|
|
|
*/
|
2021-04-26 01:28:21 -07:00
|
|
|
#define NPCX_DT_NODE_FROM_VWTABLE(name) DT_CHILD(DT_PATH(npcx_espi_vws_map), \
|
2020-12-06 23:41:07 -08:00
|
|
|
name)
|
2020-09-10 17:39:44 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2021-04-12 19:38:20 -07:00
|
|
|
* @brief Get phandle from vw-wui property of child node with that path.
|
2020-09-15 17:21:45 +08:00
|
|
|
*
|
2021-04-26 01:28:21 -07:00
|
|
|
* @param name path which name is /npcx-espi-vws-map/'name'.
|
2021-04-12 19:38:20 -07:00
|
|
|
* @return phandle from "vw-wui" prop of child node with that path.
|
2020-09-15 17:21:45 +08:00
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_PHANDLE_VW_WUI(name) DT_PHANDLE(NPCX_DT_NODE_FROM_VWTABLE( \
|
2021-04-12 19:38:20 -07:00
|
|
|
name), vw_wui)
|
2020-09-10 17:39:44 +08:00
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
2021-04-12 19:38:20 -07:00
|
|
|
* @brief Construct a npcx_wui structure from vw-wui property of a child node
|
2020-09-15 17:21:45 +08:00
|
|
|
* with that path.
|
|
|
|
*
|
2021-04-26 01:28:21 -07:00
|
|
|
* @param name a path which name is /npcx-espi-vws-map/'name'.
|
2020-09-15 17:21:45 +08:00
|
|
|
* @return npcx_wui item with that path.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_VW_WUI_ITEM(name) \
|
2020-09-10 17:39:44 +08:00
|
|
|
{ \
|
2020-12-06 23:41:07 -08:00
|
|
|
.table = DT_PROP(DT_PHANDLE(NPCX_DT_PHANDLE_VW_WUI(name), miwus), \
|
|
|
|
index),\
|
|
|
|
.group = DT_PHA(NPCX_DT_PHANDLE_VW_WUI(name), miwus, group), \
|
|
|
|
.bit = DT_PHA(NPCX_DT_PHANDLE_VW_WUI(name), miwus, bit), \
|
2020-09-10 17:39:44 +08:00
|
|
|
}
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Construct a npcx espi device configuration of vw input signal from
|
|
|
|
* a child node with that path.
|
|
|
|
*
|
|
|
|
* @signal vw input signal name.
|
2021-04-26 01:28:21 -07:00
|
|
|
* @param name a path which name is /npcx-espi-vws-map/'name'.
|
2020-09-15 17:21:45 +08:00
|
|
|
* @return npcx_vw_in_config item with that path.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_VW_IN_CONF(signal, name) \
|
2020-09-10 17:39:44 +08:00
|
|
|
{ \
|
|
|
|
.sig = signal, \
|
2020-12-06 23:41:07 -08:00
|
|
|
.reg_idx = DT_PROP_BY_IDX(NPCX_DT_NODE_FROM_VWTABLE(name), vw_reg, \
|
|
|
|
0), \
|
|
|
|
.bitmask = DT_PROP_BY_IDX(NPCX_DT_NODE_FROM_VWTABLE(name), vw_reg, \
|
|
|
|
1), \
|
|
|
|
.vw_wui = NPCX_DT_VW_WUI_ITEM(name), \
|
2020-09-10 17:39:44 +08:00
|
|
|
}
|
|
|
|
|
2020-09-15 17:21:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Construct a npcx espi device configuration of vw output signal from
|
|
|
|
* a child node with that path.
|
|
|
|
*
|
|
|
|
* @signal vw output signal name.
|
2021-04-26 01:28:21 -07:00
|
|
|
* @param name a path which name is /npcx-espi-vws-map/'name'.
|
2020-09-15 17:21:45 +08:00
|
|
|
* @return npcx_vw_in_config item with that path.
|
|
|
|
*/
|
2020-12-06 23:41:07 -08:00
|
|
|
#define NPCX_DT_VW_OUT_CONF(signal, name) \
|
2020-09-10 17:39:44 +08:00
|
|
|
{ \
|
|
|
|
.sig = signal, \
|
2020-12-06 23:41:07 -08:00
|
|
|
.reg_idx = DT_PROP_BY_IDX(NPCX_DT_NODE_FROM_VWTABLE(name), vw_reg, \
|
|
|
|
0), \
|
|
|
|
.bitmask = DT_PROP_BY_IDX(NPCX_DT_NODE_FROM_VWTABLE(name), vw_reg, \
|
|
|
|
1), \
|
2020-09-10 17:39:44 +08:00
|
|
|
}
|
|
|
|
|
2020-12-24 00:44:26 -08:00
|
|
|
/**
|
|
|
|
* @brief Get a node from path '/def_lvol_io_list' which has a property
|
2021-03-22 23:57:51 -07:00
|
|
|
* 'lvol-io-pads' contains low-voltage configurations and need to set
|
2020-12-24 00:44:26 -08:00
|
|
|
* by default.
|
|
|
|
*
|
|
|
|
* @return node identifier with that path.
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_NODE_DEF_LVOL_LIST DT_PATH(def_lvol_io_list)
|
|
|
|
|
|
|
|
/**
|
2021-03-22 23:57:51 -07:00
|
|
|
* @brief Length of npcx_lvol structures in 'lvol-io-pads' property
|
2020-12-24 00:44:26 -08:00
|
|
|
*
|
2021-03-22 23:57:51 -07:00
|
|
|
* @return length of 'lvol-io-pads' prop which type is 'phandles'
|
2020-12-24 00:44:26 -08:00
|
|
|
*/
|
|
|
|
#define NPCX_DT_LVOL_ITEMS_LEN DT_PROP_LEN(NPCX_DT_NODE_DEF_LVOL_LIST, \
|
|
|
|
lvol_io_pads)
|
|
|
|
|
|
|
|
/**
|
2021-03-22 23:57:51 -07:00
|
|
|
* @brief Get phandle from 'lvol-io-pads' prop which type is 'phandles' at index
|
2020-12-24 00:44:26 -08:00
|
|
|
* 'i'
|
|
|
|
*
|
2021-03-22 23:57:51 -07:00
|
|
|
* @param i index of 'lvol-io-pads' prop which type is 'phandles'
|
|
|
|
* @return phandle from 'lvol-io-pads' prop at index 'i'
|
2020-12-24 00:44:26 -08:00
|
|
|
*/
|
|
|
|
#define NPCX_DT_PHANDLE_FROM_LVOL_IO_PADS(i) \
|
|
|
|
DT_PHANDLE_BY_IDX(NPCX_DT_NODE_DEF_LVOL_LIST, lvol_io_pads, i)
|
|
|
|
|
|
|
|
/**
|
2021-03-22 23:57:51 -07:00
|
|
|
* @brief Construct a npcx_lvol structure from 'lvol-io-pads' property at index
|
2020-12-24 00:44:26 -08:00
|
|
|
* 'i'.
|
|
|
|
*
|
2021-03-22 23:57:51 -07:00
|
|
|
* @param i index of 'lvol-io-pads' prop which type is 'phandles'
|
|
|
|
* @return npcx_lvol item from 'lvol-io-pads' property at index 'i'
|
2020-12-24 00:44:26 -08:00
|
|
|
*/
|
|
|
|
#define NPCX_DT_LVOL_ITEMS_BY_IDX(i, _) \
|
|
|
|
{ \
|
|
|
|
.io_port = DT_PHA(NPCX_DT_PHANDLE_FROM_LVOL_IO_PADS(i), \
|
|
|
|
lvols, io_port), \
|
|
|
|
.io_bit = DT_PHA(NPCX_DT_PHANDLE_FROM_LVOL_IO_PADS(i), \
|
|
|
|
lvols, io_bit), \
|
|
|
|
.ctrl = DT_PHA(NPCX_DT_PHANDLE_FROM_LVOL_IO_PADS(i), \
|
|
|
|
lvols, ctrl), \
|
|
|
|
.bit = DT_PHA(NPCX_DT_PHANDLE_FROM_LVOL_IO_PADS(i), \
|
|
|
|
lvols, bit), \
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Macro function to construct a list of npcx_lvol items by UTIL_LISTIFY
|
|
|
|
* func.
|
|
|
|
*
|
|
|
|
* Example devicetree fragment:
|
|
|
|
* / {
|
|
|
|
* def_lvol_io_list {
|
|
|
|
* compatible = "nuvoton,npcx-lvolctrl-def";
|
2021-03-22 23:57:51 -07:00
|
|
|
* lvol-io-pads = <&lvol_io90 // I2C1_SCL0 1.8V support
|
2020-12-24 00:44:26 -08:00
|
|
|
* &lvol_io87>; // I2C1_SDA0 1,8V support
|
|
|
|
* };
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* Example usage:
|
|
|
|
* static const struct npcx_lvol def_lvols[] = NPCX_DT_IO_LVOL_ITEMS_DEF_LIST;
|
|
|
|
*
|
|
|
|
* @return an array of npcx_lvol items which configure low-voltage support
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_IO_LVOL_ITEMS_DEF_LIST { \
|
|
|
|
UTIL_LISTIFY(NPCX_DT_LVOL_ITEMS_LEN, \
|
|
|
|
NPCX_DT_LVOL_ITEMS_BY_IDX, _) \
|
|
|
|
}
|
|
|
|
|
2021-03-03 21:38:12 -08:00
|
|
|
/**
|
|
|
|
* @brief Get a node from path '/vsby-psl-in-list' which has a property
|
|
|
|
* 'psl-in-pads' contains Power Switch Logic (PSL) input pads which are
|
|
|
|
* in charge of detecting wake-up events on VSBY power domain.
|
|
|
|
*
|
|
|
|
* @return node identifier with that path.
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_NODE_PSL_IN_LIST DT_PATH(vsby_psl_in_list)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Length of npcx_psl_in structures in 'psl-in-pads' property
|
|
|
|
*
|
|
|
|
* @return length of 'psl-in-pads' prop which type is 'phandles'
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PSL_IN_ITEMS_LEN DT_PROP_LEN(NPCX_DT_NODE_PSL_IN_LIST, \
|
|
|
|
psl_in_pads)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get phandle from 'psl-in-pads' prop which type is 'phandles' at index
|
|
|
|
* 'i'
|
|
|
|
*
|
|
|
|
* @param i index of 'psl-in-pads' prop which type is 'phandles'
|
|
|
|
* @return phandle from 'psl-in-pads' prop at index 'i'
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PHANDLE_FROM_PSL_IN_NODE(i) \
|
|
|
|
DT_PHANDLE_BY_IDX(NPCX_DT_NODE_PSL_IN_LIST, psl_in_pads, i)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get phandle from 'pinctrl-0' prop which type is 'phandles' at index
|
|
|
|
* 'i'
|
|
|
|
*
|
|
|
|
* @param i index of 'psl-in-pads' prop which type is 'phandles'
|
|
|
|
* @return phandle from 'pinctrl-0' prop at index 'i'
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PHANDLE_FROM_PSL_PINMUX_NODE(i) \
|
2021-08-12 07:12:26 -07:00
|
|
|
DT_PINCTRL_0(NPCX_DT_PHANDLE_FROM_PSL_IN_NODE(i), 0)
|
2021-03-03 21:38:12 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get phandle from 'polarity-0' prop which type is 'phandles' at index
|
|
|
|
* 'i'
|
|
|
|
*
|
|
|
|
* @param i index of 'psl-in-pads' prop which type is 'phandles'
|
|
|
|
* @return phandle from 'polarity-0' prop at index 'i'
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PHANDLE_FROM_PSL_POLARITY_NODE(i) \
|
|
|
|
DT_PHANDLE(NPCX_DT_PHANDLE_FROM_PSL_IN_NODE(i), polarity_0)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Construct a npcx_alt structure from 'pinctrl-0' property at index 'i'
|
|
|
|
* of 'psl-in-pads' prop.
|
|
|
|
*
|
|
|
|
* @param i index of 'psl-in-pads' prop which type is 'phandles'
|
|
|
|
* @return npcx_alt item from 'pinctrl-0' property at index 'i'
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PSL_IN_ALT_CONF_BY_IDX(i) \
|
|
|
|
{ \
|
|
|
|
.group = DT_PHA(NPCX_DT_PHANDLE_FROM_PSL_PINMUX_NODE(i), alts, group), \
|
|
|
|
.bit = DT_PHA(NPCX_DT_PHANDLE_FROM_PSL_PINMUX_NODE(i), alts, bit), \
|
|
|
|
.inverted = DT_PHA(NPCX_DT_PHANDLE_FROM_PSL_PINMUX_NODE(i), alts, inv), \
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Construct a npcx_alt structure from 'polarity-0' property at index 'i'
|
|
|
|
* of 'psl-in-pads' prop.
|
|
|
|
*
|
|
|
|
* @param i index of 'psl-in-pads' prop which type is 'phandles'
|
|
|
|
* @return npcx_alt item from 'pinctrl-0' property at index 'i'
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PSL_IN_POL_CONF_BY_IDX(i) \
|
|
|
|
{ \
|
|
|
|
.group = DT_PHA(NPCX_DT_PHANDLE_FROM_PSL_POLARITY_NODE(i), alts, group), \
|
|
|
|
.bit = DT_PHA(NPCX_DT_PHANDLE_FROM_PSL_POLARITY_NODE(i), alts, bit), \
|
|
|
|
.inverted = DT_PHA(NPCX_DT_PHANDLE_FROM_PSL_POLARITY_NODE(i), alts, inv), \
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Construct a npcx_psl_in structure from 'psl-in-pads' property at index
|
|
|
|
* 'i'
|
|
|
|
*
|
|
|
|
* @param i index of 'psl-in-pads' prop which type is 'phandles'
|
|
|
|
* @return npcx_psl_in item from 'psl-in-pads' property at index 'i'
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PSL_IN_ITEMS_BY_IDX(i, _) \
|
|
|
|
{ \
|
|
|
|
.flag = DT_PROP(NPCX_DT_PHANDLE_FROM_PSL_IN_NODE(i), flag), \
|
|
|
|
.offset = DT_PROP(NPCX_DT_PHANDLE_FROM_PSL_IN_NODE(i), offset),\
|
|
|
|
.pinctrl = NPCX_DT_PSL_IN_ALT_CONF_BY_IDX(i) \
|
|
|
|
.polarity = NPCX_DT_PSL_IN_POL_CONF_BY_IDX(i) \
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Macro function to construct a list of npcx_psl_in items by
|
|
|
|
* UTIL_LISTIFY func.
|
|
|
|
*
|
|
|
|
* Example devicetree fragment:
|
|
|
|
* / {
|
|
|
|
* vsby-psl-in-list {
|
|
|
|
* psl-in-pads = <&psl_in1>;
|
|
|
|
* };
|
|
|
|
* };
|
|
|
|
* &psl_in1 {
|
|
|
|
* flag = <NPCX_PSL_FALLING_EDGE>;
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* Example usage:
|
|
|
|
* static const struct npcx_psl_in psl_in_confs[] = NPCX_DT_PSL_IN_ITEMS_LIST;
|
|
|
|
*
|
|
|
|
* @return an array of npcx_psl_in items which configures PSL input pads
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PSL_IN_ITEMS_LIST { \
|
|
|
|
UTIL_LISTIFY(NPCX_DT_PSL_IN_ITEMS_LEN, \
|
|
|
|
NPCX_DT_PSL_IN_ITEMS_BY_IDX, _) \
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get base address of corresponding GPIO controller for enabling PSL
|
|
|
|
* output.
|
|
|
|
*
|
|
|
|
* @param @param inst number for devices with compatible 'nuvoton_npcx_psl_out'.
|
|
|
|
* @return base address of corresponding GPIO controller
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PSL_OUT_CONTROLLER(inst) DT_REG_ADDR_BY_IDX(DT_PHANDLE_BY_IDX( \
|
|
|
|
DT_INST(inst, nuvoton_npcx_psl_out), controller, 0), 0)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get pin of corresponding GPIO controller for enabling PSL output.
|
|
|
|
*
|
|
|
|
* @param @param inst number for devices with compatible 'nuvoton_npcx_psl_out'.
|
|
|
|
* @return pin of corresponding GPIO controller.
|
|
|
|
*/
|
|
|
|
#define NPCX_DT_PSL_OUT_PIN(inst) DT_PROP(DT_INST(inst, nuvoton_npcx_psl_out), \
|
|
|
|
pin)
|
|
|
|
|
2021-07-30 17:22:44 +08:00
|
|
|
/**
|
|
|
|
* @brief Check if the host interface type is automatically configured by
|
|
|
|
* booter.
|
|
|
|
*
|
|
|
|
* @return TRUE - if the host interface is configured by booter,
|
|
|
|
* FALSE - otherwise.
|
|
|
|
*/
|
|
|
|
#define NPCX_BOOTER_IS_HIF_TYPE_SET() \
|
|
|
|
DT_PROP(DT_PATH(booter_variant), hif_type_auto)
|
|
|
|
|
2020-07-02 15:44:38 +08:00
|
|
|
#endif /* _NUVOTON_NPCX_SOC_DT_H_ */
|