Skip to content

Commit 7b5780e

Browse files
RuibinChangcarlescufi
authored andcommitted
ITE drivers/kscan/it8xxx2: set KSI/KSO kbs mode by pinctrl driver
Set KSI/KSO kbs mode by pinctrl driver. Signed-off-by: Ruibin Chang <[email protected]>
1 parent 344c9c6 commit 7b5780e

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

boards/riscv/it8xxx2_evb/it8xxx2_evb.dts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,30 @@
148148
};
149149
&kscan0 {
150150
status = "okay";
151-
pinctrl-0 = <&kso16_gpc3_default
152-
&kso17_gpc5_default>;
151+
pinctrl-0 = <&ksi0_default
152+
&ksi1_default
153+
&ksi2_default
154+
&ksi3_default
155+
&ksi4_default
156+
&ksi5_default
157+
&ksi6_default
158+
&ksi7_default
159+
&kso0_default
160+
&kso1_default
161+
&kso2_default
162+
&kso3_default
163+
&kso4_default
164+
&kso5_default
165+
&kso6_default
166+
&kso7_default
167+
&kso8_default
168+
&kso9_default
169+
&kso10_default
170+
&kso11_default
171+
&kso12_default
172+
&kso13_default
173+
&kso14_default
174+
&kso15_default>;
153175
pinctrl-names = "default";
154176
};
155177
&peci0 {

drivers/kscan/kscan_ite_it8xxx2.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct kscan_it8xxx2_config {
5555
int irq;
5656
/* KSI[7:0] wake-up input source configuration list */
5757
const struct kscan_wuc_map_cfg *wuc_map_list;
58-
/* Keyboard scan alternate configuration */
58+
/* KSI[7:0]/KSO[17:0] keyboard scan alternate configuration */
5959
const struct pinctrl_dev_config *pcfg;
6060
/* KSO16 GPIO cells */
6161
struct gpio_dt_spec kso16_gpios;
@@ -425,19 +425,12 @@ static int kscan_it8xxx2_init(const struct device *dev)
425425
const struct kscan_it8xxx2_config *const config = dev->config;
426426
struct kscan_it8xxx2_data *data = dev->data;
427427
struct kscan_it8xxx2_regs *const inst = config->base;
428+
int status;
428429

429430
/* Disable wakeup and interrupt of KSI pins before configuring */
430431
keyboard_raw_enable_interrupt(dev, 0);
431432

432-
/*
433-
* Bit[2] = 1: Enable the internal pull-up of KSO[15:0] pins
434-
* Bit[0] = 1: Enable the open-drain mode of KSO[17:0] pins
435-
*/
436-
inst->KBS_KSOCTRL = (IT8XXX2_KBS_KSOOD | IT8XXX2_KBS_KSOPU);
437-
438433
#if (CONFIG_KSCAN_ITE_IT8XXX2_COLUMN_SIZE > 16)
439-
int status;
440-
441434
/*
442435
* For KSO[16] and KSO[17]:
443436
* 1.GPOTRC:
@@ -451,17 +444,18 @@ static int kscan_it8xxx2_init(const struct device *dev)
451444
*/
452445
gpio_pin_configure_dt(&config->kso16_gpios, GPIO_INPUT);
453446
gpio_pin_configure_dt(&config->kso17_gpios, GPIO_INPUT);
447+
#endif
448+
/*
449+
* Enable the internal pull-up and kbs mode of the KSI[7:0] pins.
450+
* Enable the internal pull-up and kbs mode of the KSO[15:0] pins.
451+
* Enable the open-drain mode of the KSO[17:0] pins.
452+
*/
454453
status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
455454
if (status < 0) {
456-
LOG_ERR("Failed to configure kscan pins");
455+
LOG_ERR("Failed to configure KSI[7:0] and KSO[17:0] pins");
457456
return status;
458457
}
459458

460-
#endif
461-
462-
/* Bit[2] = 1: Enable the internal pull-up of KSI[7:0] pins */
463-
inst->KBS_KSICTRL = IT8XXX2_KBS_KSIPU;
464-
465459
/* KSO[17:0] pins output low */
466460
inst->KBS_KSOL = 0x00;
467461
inst->KBS_KSOH1 = 0x00;

0 commit comments

Comments
 (0)