Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: it8xxx2_kbd: add a kso-ignore-mask property #80684

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions drivers/input/input_ite_it8xxx2_kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct it8xxx2_kbd_config {
struct gpio_dt_spec kso16_gpios;
/* KSO17 GPIO cells */
struct gpio_dt_spec kso17_gpios;
/* Mask of signals to ignore */
uint32_t kso_ignore_mask;
};

struct it8xxx2_kbd_data {
Expand All @@ -59,7 +61,7 @@ static void it8xxx2_kbd_drive_column(const struct device *dev, int col)
const struct it8xxx2_kbd_config *const config = dev->config;
const struct input_kbd_matrix_common_config *common = &config->common;
struct kscan_it8xxx2_regs *const inst = config->base;
const uint32_t kso_mask = BIT_MASK(common->col_size);
const uint32_t kso_mask = BIT_MASK(common->col_size) & ~config->kso_ignore_mask;
const uint8_t ksol_mask = kso_mask & 0xff;
const uint8_t ksoh1_mask = (kso_mask >> 8) & 0xff;
uint32_t kso_val;
Expand All @@ -76,17 +78,14 @@ static void it8xxx2_kbd_drive_column(const struct device *dev, int col)
kso_val = kso_mask ^ BIT(col);
}

/* Set KSO[17:0] output data */
inst->KBS_KSOL = (inst->KBS_KSOL & ~ksol_mask) | (kso_val & ksol_mask);
/*
* Disable global interrupts for critical section
* The KBS_KSOH1 register contains both keyboard and GPIO output settings.
/* Set KSO[17:0] output data, disable global interrupts for critical section.
* The KBS_KSO* registers contains both keyboard and GPIO output settings.
* Not all bits are for the keyboard will be driven, so a critical section
* is needed to avoid race conditions.
*/
key = irq_lock();
inst->KBS_KSOL = (inst->KBS_KSOL & ~ksol_mask) | (kso_val & ksol_mask);
inst->KBS_KSOH1 = (inst->KBS_KSOH1 & ~ksoh1_mask) | ((kso_val >> 8) & ksoh1_mask);
/* Restore interrupts */
irq_unlock(key);

if (common->col_size > 16) {
Expand Down Expand Up @@ -153,7 +152,7 @@ static int it8xxx2_kbd_init(const struct device *dev)
const struct input_kbd_matrix_common_config *common = &config->common;
struct it8xxx2_kbd_data *data = dev->data;
struct kscan_it8xxx2_regs *const inst = config->base;
const uint32_t kso_mask = BIT_MASK(common->col_size);
const uint32_t kso_mask = BIT_MASK(common->col_size) & ~config->kso_ignore_mask;
const uint8_t ksol_mask = kso_mask & 0xff;
const uint8_t ksoh1_mask = (kso_mask >> 8) & 0xff;
int status;
Expand Down Expand Up @@ -248,6 +247,7 @@ static const struct it8xxx2_kbd_config it8xxx2_kbd_cfg_0 = {
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
.kso16_gpios = GPIO_DT_SPEC_INST_GET(0, kso16_gpios),
.kso17_gpios = GPIO_DT_SPEC_INST_GET(0, kso17_gpios),
.kso_ignore_mask = DT_INST_PROP(0, kso_ignore_mask),
};

static struct it8xxx2_kbd_data it8xxx2_kbd_data_0;
Expand Down
8 changes: 8 additions & 0 deletions dts/bindings/input/ite,it8xxx2-kbd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ properties:
description: |
The KSO17 pin for the selected port.

kso-ignore-mask:
type: int
default: 0
description: |
Bitmask of KSO signals to ignore, this can be used to instruct the driver
to skip KSO signals between 0 and (col-size - 1) that are used as GPIOs.
Default to 0 (no signals masked).

pinctrl-0:
required: true

Expand Down
Loading