Lines Matching +full:col +full:- +full:size

5  * SPDX-License-Identifier: Apache-2.0
34 /* Keyboard scan input (KSI) wake-up irq */
36 /* Size of keyboard inputs-wui mapping array */
59 const struct npcx_kbd_config *const config = dev->config; in npcx_kbd_set_detect_mode()
60 const struct input_kbd_matrix_common_config *common = &config->common; in npcx_kbd_set_detect_mode()
63 for (int i = 0; i < common->row_size; i++) { in npcx_kbd_set_detect_mode()
64 npcx_miwu_irq_get_and_clear_pending(&config->wui_maps[i]); in npcx_kbd_set_detect_mode()
67 irq_enable(config->irq); in npcx_kbd_set_detect_mode()
69 irq_disable(config->irq); in npcx_kbd_set_detect_mode()
73 static void npcx_kbd_drive_column(const struct device *dev, int col) in npcx_kbd_drive_column() argument
75 const struct npcx_kbd_config *config = dev->config; in npcx_kbd_drive_column()
76 const struct input_kbd_matrix_common_config *common = &config->common; in npcx_kbd_drive_column()
77 struct kbs_reg *const inst = config->base; in npcx_kbd_drive_column()
80 if (col >= common->col_size) { in npcx_kbd_drive_column()
81 LOG_ERR("invalid column: %d", col); in npcx_kbd_drive_column()
85 if (col == INPUT_KBD_MATRIX_COLUMN_DRIVE_NONE) { in npcx_kbd_drive_column()
88 } else if (col == INPUT_KBD_MATRIX_COLUMN_DRIVE_ALL) { in npcx_kbd_drive_column()
90 mask = ~BIT_MASK(common->col_size); in npcx_kbd_drive_column()
96 mask = ~BIT(col); in npcx_kbd_drive_column()
99 LOG_DBG("Drive col mask: %x", mask); in npcx_kbd_drive_column()
101 inst->KBSOUT0 = (mask & 0xFFFF); in npcx_kbd_drive_column()
102 inst->KBSOUT1 = ((mask >> 16) & 0x03); in npcx_kbd_drive_column()
107 const struct npcx_kbd_config *config = dev->config; in npcx_kbd_read_row()
108 const struct input_kbd_matrix_common_config *common = &config->common; in npcx_kbd_read_row()
109 struct kbs_reg *const inst = config->base; in npcx_kbd_read_row()
112 val = inst->KBSIN; in npcx_kbd_read_row()
115 val = ~val & BIT_MASK(common->row_size); in npcx_kbd_read_row()
125 /* KSI signal which has no wake-up input source */ in npcx_kbd_init_ksi_wui_callback()
126 if (wui->table == NPCX_MIWU_TABLE_NONE) { in npcx_kbd_init_ksi_wui_callback()
142 const struct npcx_kbd_config *const config = dev->config; in npcx_kbd_init()
143 const struct input_kbd_matrix_common_config *common = &config->common; in npcx_kbd_init()
144 struct npcx_kbd_data *const data = dev->data; in npcx_kbd_init()
145 struct kbs_reg *const inst = config->base; in npcx_kbd_init()
149 LOG_ERR("%s device not ready", clk_dev->name); in npcx_kbd_init()
150 return -ENODEV; in npcx_kbd_init()
154 ret = clock_control_on(clk_dev, (clock_control_subsys_t)&config->clk_cfg); in npcx_kbd_init()
157 return -EIO; in npcx_kbd_init()
160 /* Pull-up KBSIN0-7 internally */ in npcx_kbd_init()
161 inst->KBSINPU = 0xFF; in npcx_kbd_init()
166 * [6:7] - KBHDRV KBSOUTn signals output buffers are open-drain. in npcx_kbd_init()
167 * [3] - KBSINC Auto-increment of Buffer Data register is disabled in npcx_kbd_init()
168 * [2] - KBSIEN Interrupt of Auto-Scan is disabled in npcx_kbd_init()
169 * [1] - KBSMODE Key detection mechanism is implemented by firmware in npcx_kbd_init()
170 * [0] - START Write 0 to this field is not affected in npcx_kbd_init()
172 inst->KBSCTL = 0x00; in npcx_kbd_init()
175 * Select quasi-bidirectional buffers for KSO pins. It reduces the in npcx_kbd_init()
176 * low-to-high transition time. This feature only supports in npcx7. in npcx_kbd_init()
179 SET_FIELD(inst->KBSCTL, NPCX_KBSCTL_KBHDRV_FIELD, 0x01); in npcx_kbd_init()
185 if (common->row_size != ROW_SIZE) { in npcx_kbd_init()
186 LOG_ERR("Unexpected ROW_SIZE: %d != %d", common->row_size, ROW_SIZE); in npcx_kbd_init()
187 return -EINVAL; in npcx_kbd_init()
190 /* Configure wake-up input and callback for keyboard input signal */ in npcx_kbd_init()
191 for (int i = 0; i < common->row_size; i++) { in npcx_kbd_init()
193 dev, &data->ksi_callback[i], &config->wui_maps[i], in npcx_kbd_init()
197 /* Configure pin-mux for keyboard scan device */ in npcx_kbd_init()
198 ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); in npcx_kbd_init()
240 "only one nuvoton,npcx-kbd compatible node can be supported");
241 BUILD_ASSERT(IN_RANGE(DT_INST_PROP(0, row_size), 1, 8), "invalid row-size");
242 BUILD_ASSERT(IN_RANGE(DT_INST_PROP(0, col_size), 1, 18), "invalid col-size");