/* RSTINTCLR register bit mask */ #define IRQ_CLEAR 0x1
/* bit masks for keyboard interrupts*/ #define TC3589x_EVT_LOSS_INT 0x8 #define TC3589x_EVT_INT 0x4 #define TC3589x_KBD_LOSS_INT 0x2 #define TC3589x_KBD_INT 0x1
/* bit masks for keyboard interrupt clear*/ #define TC3589x_EVT_INT_CLR 0x2 #define TC3589x_KBD_INT_CLR 0x1
/** * struct tc3589x_keypad_platform_data - platform specific keypad data * @keymap_data: matrix scan code table for keycodes * @krow: mask for available rows, value is 0xFF * @kcol: mask for available columns, value is 0xFF * @debounce_period: platform specific debounce time * @settle_time: platform specific settle down time * @irqtype: type of interrupt, falling or rising edge * @enable_wakeup: specifies if keypad event can wake up system from sleep * @no_autorepeat: flag for auto repetition
*/ struct tc3589x_keypad_platform_data { conststruct matrix_keymap_data *keymap_data;
u8 krow;
u8 kcol;
u8 debounce_period;
u8 settle_time; unsignedlong irqtype; bool enable_wakeup; bool no_autorepeat;
};
/** * struct tc_keypad - data structure used by keypad driver * @tc3589x: pointer to tc35893 * @input: pointer to input device object * @board: keypad platform device * @krow: number of rows * @kcol: number of columns * @keymap: matrix scan code table for keycodes * @keypad_stopped: holds keypad status
*/ struct tc_keypad { struct tc3589x *tc3589x; struct input_dev *input; conststruct tc3589x_keypad_platform_data *board; unsignedint krow; unsignedint kcol; unsignedshort *keymap; bool keypad_stopped;
};
/* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE,
(board->krow << KP_ROW_SHIFT) | board->kcol); if (ret < 0) return ret;
/* configure dedicated key config, no dedicated key selected */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBCFG_LSB, DEDICATED_KEY_VAL); if (ret < 0) return ret;
ret = tc3589x_reg_write(tc3589x, TC3589x_KBCFG_MSB, DEDICATED_KEY_VAL); if (ret < 0) return ret;
/* Configure settle time */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG,
board->settle_time); if (ret < 0) return ret;
/* Configure debounce time */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE,
board->debounce_period); if (ret < 0) return ret;
/* Start of initialise keypad GPIOs */
ret = tc3589x_set_bits(tc3589x, TC3589x_IOCFG, 0x0, IOCFG_IG); if (ret < 0) return ret;
/* Configure pull-up resistors for all row GPIOs */
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG0_LSB,
TC3589x_PULLUP_ALL_MASK); if (ret < 0) return ret;
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG0_MSB,
TC3589x_PULLUP_ALL_MASK); if (ret < 0) return ret;
/* Configure pull-up resistors for all column GPIOs */
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG1_LSB,
TC3589x_PULLUP_ALL_MASK); if (ret < 0) return ret;
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG1_MSB,
TC3589x_PULLUP_ALL_MASK); if (ret < 0) return ret;
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG2_LSB,
TC3589x_PULLUP_ALL_MASK);
for (i = 0; i < TC35893_DATA_REGS * 2; i++) {
kbd_code = tc3589x_reg_read(tc3589x, TC3589x_EVTCODE_FIFO);
/* loop till fifo is empty and no more keys are pressed */ if (kbd_code == TC35893_KEYCODE_FIFO_EMPTY ||
kbd_code == TC35893_KEYCODE_FIFO_CLEAR) continue;
/* valid key is found */
col_index = kbd_code & KP_EVCODE_COL_MASK;
row_index = (kbd_code & KP_EVCODE_ROW_MASK) >> KP_ROW_SHIFT;
code = MATRIX_SCAN_CODE(row_index, col_index,
TC35893_KEYPAD_ROW_SHIFT);
up = kbd_code & KP_RELEASE_EVT_MASK;
error = input_register_device(input); if (error) {
dev_err(&pdev->dev, "Could not register input device\n"); return error;
}
/* let platform decide if keypad is a wakeup source or not */
device_init_wakeup(&pdev->dev, plat->enable_wakeup);
device_set_wakeup_capable(&pdev->dev, plat->enable_wakeup);
/* keypad is already off; we do nothing */ if (keypad->keypad_stopped) return 0;
/* if device is not a wakeup source, disable it for powersave */ if (!device_may_wakeup(&pdev->dev))
tc3589x_keypad_disable(keypad); else
enable_irq_wake(irq);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.