@@ -54,6 +54,8 @@ struct gpio_ite_cfg {
54
54
uint8_t has_volt_sel [8 ];
55
55
/* Number of pins per group of GPIO */
56
56
uint8_t num_pins ;
57
+ /* gpioksi, gpioksoh and gpioksol extended setting */
58
+ bool kbs_ctrl ;
57
59
};
58
60
59
61
/* Structure gpio_ite_data is about callback function */
@@ -159,25 +161,57 @@ static int gpio_ite_configure(const struct device *dev,
159
161
}
160
162
161
163
/* Set input or output. */
162
- if (flags & GPIO_OUTPUT ) {
163
- ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_OUTPUT ) &
164
- ~GPCR_PORT_PIN_MODE_INPUT ;
164
+ if (gpio_config -> kbs_ctrl ) {
165
+ /* Handle keyboard scan controller */
166
+ uint8_t ksxgctrlr = ECREG (reg_gpcr );
167
+
168
+ ksxgctrlr |= KSIX_KSOX_KBS_GPIO_MODE ;
169
+ if (flags & GPIO_OUTPUT ) {
170
+ ksxgctrlr |= KSIX_KSOX_GPIO_OUTPUT ;
171
+ } else {
172
+ ksxgctrlr &= ~KSIX_KSOX_GPIO_OUTPUT ;
173
+ }
174
+ ECREG (reg_gpcr ) = ksxgctrlr ;
165
175
} else {
166
- ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_INPUT ) &
176
+ /* Handle regular GPIO controller */
177
+ if (flags & GPIO_OUTPUT ) {
178
+ ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_OUTPUT ) &
179
+ ~GPCR_PORT_PIN_MODE_INPUT ;
180
+ } else {
181
+ ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_INPUT ) &
167
182
~GPCR_PORT_PIN_MODE_OUTPUT ;
183
+ }
168
184
}
169
185
170
186
/* Handle pullup / pulldown */
171
- if (flags & GPIO_PULL_UP ) {
172
- ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_PULLUP ) &
173
- ~GPCR_PORT_PIN_MODE_PULLDOWN ;
174
- } else if (flags & GPIO_PULL_DOWN ) {
175
- ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_PULLDOWN ) &
176
- ~GPCR_PORT_PIN_MODE_PULLUP ;
187
+ if (gpio_config -> kbs_ctrl ) {
188
+ /* Handle keyboard scan controller */
189
+ uint8_t ksxgctrlr = ECREG (reg_gpcr );
190
+
191
+ if (flags & GPIO_PULL_UP ) {
192
+ ksxgctrlr = (ksxgctrlr | KSIX_KSOX_GPIO_PULLUP ) &
193
+ ~KSIX_KSOX_GPIO_PULLDOWN ;
194
+ } else if (flags & GPIO_PULL_DOWN ) {
195
+ ksxgctrlr = (ksxgctrlr | KSIX_KSOX_GPIO_PULLDOWN ) &
196
+ ~KSIX_KSOX_GPIO_PULLUP ;
197
+ } else {
198
+ /* No pull up/down */
199
+ ksxgctrlr &= ~(KSIX_KSOX_GPIO_PULLUP | KSIX_KSOX_GPIO_PULLDOWN );
200
+ }
201
+ ECREG (reg_gpcr ) = ksxgctrlr ;
177
202
} else {
178
- /* No pull up/down */
179
- ECREG (reg_gpcr ) &= ~(GPCR_PORT_PIN_MODE_PULLUP |
180
- GPCR_PORT_PIN_MODE_PULLDOWN );
203
+ /* Handle regular GPIO controller */
204
+ if (flags & GPIO_PULL_UP ) {
205
+ ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_PULLUP ) &
206
+ ~GPCR_PORT_PIN_MODE_PULLDOWN ;
207
+ } else if (flags & GPIO_PULL_DOWN ) {
208
+ ECREG (reg_gpcr ) = (ECREG (reg_gpcr ) | GPCR_PORT_PIN_MODE_PULLDOWN ) &
209
+ ~GPCR_PORT_PIN_MODE_PULLUP ;
210
+ } else {
211
+ /* No pull up/down */
212
+ ECREG (reg_gpcr ) &= ~(GPCR_PORT_PIN_MODE_PULLUP |
213
+ GPCR_PORT_PIN_MODE_PULLDOWN );
214
+ }
181
215
}
182
216
183
217
unlock_and_return :
@@ -512,6 +546,7 @@ static const struct gpio_ite_cfg gpio_ite_cfg_##inst = { \
512
546
.gpio_irq = IT8XXX2_DT_GPIO_IRQ_LIST(inst), \
513
547
.has_volt_sel = DT_INST_PROP_OR(inst, has_volt_sel, {0}), \
514
548
.num_pins = DT_INST_PROP(inst, ngpios), \
549
+ .kbs_ctrl = DT_INST_PROP_OR(inst, keyboard_controller, 0), \
515
550
}; \
516
551
DEVICE_DT_INST_DEFINE(inst, \
517
552
gpio_ite_init, \
0 commit comments