1 /*
2  * Copyright (c) 2020 Nuvoton Technology Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _NUVOTON_NPCX_SOC_PINS_H_
8 #define _NUVOTON_NPCX_SOC_PINS_H_
9 
10 #include <stdint.h>
11 
12 #include "reg/reg_def.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /**
19  * @brief NPCX pin-mux configuration structure
20  *
21  * Used to indicate the device's corresponding DEVALT register/bit for
22  * pin-muxing and its polarity to enable alternative functionality.
23  */
24 struct npcx_alt {
25 	uint8_t group;
26 	uint8_t bit:3;
27 	uint8_t inverted:1;
28 	uint8_t reserved:4;
29 };
30 
31 /**
32  * @brief NPCX low-voltage configuration structure
33  *
34  * Used to indicate the device's corresponding LV_GPIO_CTL register/bit for
35  * low-voltage detection.
36  */
37 struct npcx_lvol {
38 	uint8_t ctrl:5; /** Related register index for low-voltage conf. */
39 	uint8_t bit:3; /** Related register bit for low-voltage conf. */
40 };
41 
42 /**
43  * @brief Select i2c port pads of i2c controller
44  *
45  * @param controller i2c controller device
46  * @param port index for i2c port pads
47  */
48 void npcx_pinctrl_i2c_port_sel(int controller, int port);
49 
50 /**
51  * @brief Force the internal SPI flash write-protect pin (WP) to low level to
52  * protect the flash Status registers.
53  */
54 int npcx_pinctrl_flash_write_protect_set(void);
55 
56 /**
57  * @brief Get write protection status
58  *
59  * @return 1 if write protection is set, 0 otherwise.
60  */
61 bool npcx_pinctrl_flash_write_protect_is_set(void);
62 
63 /**
64  * @brief Enable low-voltage input detection
65  *
66  * @param lvol_ctrl Related register index for low-voltage detection
67  * @param lvol_bit Related register bit for low-voltage detection
68  * @param enable True to enable low-voltage input detection, false to disable.
69  */
70 void npcx_lvol_set_detect_level(int lvol_ctrl, int lvol_bit, bool enable);
71 
72 /**
73  * @brief Get status of low-voltage input detection
74  *
75  * @param lvol_ctrl Related register index for low-voltage detection
76  * @param lvol_bit Related register bit for low-voltage detection
77  * @return True means the low-voltage power supply is enabled, otherwise disabled.
78  */
79 bool npcx_lvol_get_detect_level(int lvol_ctrl, int lvol_bit);
80 
81 /**
82  * @brief Select the host interface type
83  *
84  * @param hif_type host interface type
85  */
86 void npcx_host_interface_sel(enum npcx_hif_type hif_type);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* _NUVOTON_NPCX_SOC_PINS_H_ */
93