Lines Matching +full:wakeup +full:- +full:controller
3 * SPDX-License-Identifier: Apache-2.0
15 #include <zephyr/dt-bindings/interrupt-controller/it8xxx2-wuc.h>
35 /* Keyboard scan controller base address */
37 /* Keyboard scan input (KSI) wake-up irq */
39 /* KSI[7:0] wake-up input source configuration list */
53 /* KSI[7:0] wake-up interrupt status mask */
61 const struct it8xxx2_kbd_config *const config = dev->config; in it8xxx2_kbd_drive_column()
62 const struct input_kbd_matrix_common_config *common = &config->common; in it8xxx2_kbd_drive_column()
63 struct kscan_it8xxx2_regs *const inst = config->base; in it8xxx2_kbd_drive_column()
64 const uint32_t kso_mask = BIT_MASK(common->col_size) & ~config->kso_ignore_mask; in it8xxx2_kbd_drive_column()
70 /* Tri-state all outputs */ in it8xxx2_kbd_drive_column()
87 inst->KBS_KSOL = (inst->KBS_KSOL & ~ksol_mask) | (kso_val & ksol_mask); in it8xxx2_kbd_drive_column()
88 inst->KBS_KSOH1 = (inst->KBS_KSOH1 & ~ksoh1_mask) | ((kso_val >> 8) & ksoh1_mask); in it8xxx2_kbd_drive_column()
91 if (common->col_size > 16) { in it8xxx2_kbd_drive_column()
92 inst->KBS_KSOH2 = (kso_val >> 16) & 0xff; in it8xxx2_kbd_drive_column()
98 const struct it8xxx2_kbd_config *const config = dev->config; in it8xxx2_kbd_read_row()
99 struct kscan_it8xxx2_regs *const inst = config->base; in it8xxx2_kbd_read_row()
101 /* Bits are active-low, so toggle it (return 1 means key pressed) */ in it8xxx2_kbd_read_row()
102 return (inst->KBS_KSI ^ 0xff); in it8xxx2_kbd_read_row()
107 const struct it8xxx2_kbd_config *const config = dev->config; in it8xxx2_kbd_isr()
108 struct it8xxx2_kbd_data *data = dev->data; in it8xxx2_kbd_isr()
111 * W/C wakeup interrupt status of KSI[7:0] pins in it8xxx2_kbd_isr()
116 it8xxx2_wuc_clear_status(config->wuc_map_list[0].wucs, in it8xxx2_kbd_isr()
117 data->ksi_pin_mask); in it8xxx2_kbd_isr()
120 ite_intc_isr_clear(config->irq); in it8xxx2_kbd_isr()
127 const struct it8xxx2_kbd_config *const config = dev->config; in it8xxx2_kbd_set_detect_mode()
128 struct it8xxx2_kbd_data *data = dev->data; in it8xxx2_kbd_set_detect_mode()
132 * W/C wakeup interrupt status of KSI[7:0] pins in it8xxx2_kbd_set_detect_mode()
137 it8xxx2_wuc_clear_status(config->wuc_map_list[0].wucs, in it8xxx2_kbd_set_detect_mode()
138 data->ksi_pin_mask); in it8xxx2_kbd_set_detect_mode()
141 ite_intc_isr_clear(config->irq); in it8xxx2_kbd_set_detect_mode()
143 irq_enable(config->irq); in it8xxx2_kbd_set_detect_mode()
145 irq_disable(config->irq); in it8xxx2_kbd_set_detect_mode()
151 const struct it8xxx2_kbd_config *const config = dev->config; in it8xxx2_kbd_init()
152 const struct input_kbd_matrix_common_config *common = &config->common; in it8xxx2_kbd_init()
153 struct it8xxx2_kbd_data *data = dev->data; in it8xxx2_kbd_init()
154 struct kscan_it8xxx2_regs *const inst = config->base; in it8xxx2_kbd_init()
155 const uint32_t kso_mask = BIT_MASK(common->col_size) & ~config->kso_ignore_mask; in it8xxx2_kbd_init()
160 /* Disable wakeup and interrupt of KSI pins before configuring */ in it8xxx2_kbd_init()
163 if (common->col_size > 16) { in it8xxx2_kbd_init()
167 * Bit[x] = 1b: Enable the open-drain mode of KSO pin in it8xxx2_kbd_init()
170 * Bit[2] = 1b: Enable the internal pull-up of KSO pin in it8xxx2_kbd_init()
176 gpio_pin_configure_dt(&config->kso16_gpios, GPIO_INPUT); in it8xxx2_kbd_init()
177 gpio_pin_configure_dt(&config->kso17_gpios, GPIO_INPUT); in it8xxx2_kbd_init()
180 * Enable the internal pull-up and kbs mode of the KSI[7:0] pins. in it8xxx2_kbd_init()
181 * Enable the internal pull-up and kbs mode of the KSO[15:0] pins. in it8xxx2_kbd_init()
182 * Enable the open-drain mode of the KSO[17:0] pins. in it8xxx2_kbd_init()
184 status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); in it8xxx2_kbd_init()
191 inst->KBS_KSOL = inst->KBS_KSOL & ~ksol_mask; in it8xxx2_kbd_init()
192 inst->KBS_KSOH1 = inst->KBS_KSOH1 & ~ksoh1_mask; in it8xxx2_kbd_init()
193 if (common->col_size > 16) { in it8xxx2_kbd_init()
194 inst->KBS_KSOH2 = 0x00; in it8xxx2_kbd_init()
198 /* Select wakeup interrupt falling-edge triggered of KSI[7:0] pins */ in it8xxx2_kbd_init()
199 it8xxx2_wuc_set_polarity(config->wuc_map_list[i].wucs, in it8xxx2_kbd_init()
200 config->wuc_map_list[i].mask, in it8xxx2_kbd_init()
202 /* W/C wakeup interrupt status of KSI[7:0] pins */ in it8xxx2_kbd_init()
203 it8xxx2_wuc_clear_status(config->wuc_map_list[i].wucs, in it8xxx2_kbd_init()
204 config->wuc_map_list[i].mask); in it8xxx2_kbd_init()
205 /* Enable wakeup interrupt of KSI[7:0] pins */ in it8xxx2_kbd_init()
206 it8xxx2_wuc_enable(config->wuc_map_list[i].wucs, in it8xxx2_kbd_init()
207 config->wuc_map_list[i].mask); in it8xxx2_kbd_init()
210 * We want to clear KSI[7:0] pins status at a time when wakeup in it8xxx2_kbd_init()
213 if (config->wuc_map_list[i].wucs != config->wuc_map_list[0].wucs) { in it8xxx2_kbd_init()
216 data->ksi_pin_mask |= config->wuc_map_list[i].mask; in it8xxx2_kbd_init()
220 ite_intc_isr_clear(config->irq); in it8xxx2_kbd_init()
266 "only one ite,it8xxx2-kbd compatible node can be supported");
267 BUILD_ASSERT(IN_RANGE(DT_INST_PROP(0, row_size), 1, 8), "invalid row-size");
268 BUILD_ASSERT(IN_RANGE(DT_INST_PROP(0, col_size), 1, 18), "invalid col-size");