linux/drivers/input/keyboard/pmic8xxx-keypad.c

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
 */

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/of.h>
#include <linux/input/matrix_keypad.h>

#define PM8XXX_MAX_ROWS
#define PM8XXX_MAX_COLS
#define PM8XXX_ROW_SHIFT
#define PM8XXX_MATRIX_MAX_SIZE

#define PM8XXX_MIN_ROWS
#define PM8XXX_MIN_COLS

#define MAX_SCAN_DELAY
#define MIN_SCAN_DELAY

/* in nanoseconds */
#define MAX_ROW_HOLD_DELAY
#define MIN_ROW_HOLD_DELAY

#define MAX_DEBOUNCE_TIME
#define MIN_DEBOUNCE_TIME

#define KEYP_CTRL

#define KEYP_CTRL_EVNTS
#define KEYP_CTRL_EVNTS_MASK

#define KEYP_CTRL_SCAN_COLS_SHIFT
#define KEYP_CTRL_SCAN_COLS_MIN
#define KEYP_CTRL_SCAN_COLS_BITS

#define KEYP_CTRL_SCAN_ROWS_SHIFT
#define KEYP_CTRL_SCAN_ROWS_MIN
#define KEYP_CTRL_SCAN_ROWS_BITS

#define KEYP_CTRL_KEYP_EN

#define KEYP_SCAN

#define KEYP_SCAN_READ_STATE
#define KEYP_SCAN_DBOUNCE_SHIFT
#define KEYP_SCAN_PAUSE_SHIFT
#define KEYP_SCAN_ROW_HOLD_SHIFT

#define KEYP_TEST

#define KEYP_TEST_CLEAR_RECENT_SCAN
#define KEYP_TEST_CLEAR_OLD_SCAN
#define KEYP_TEST_READ_RESET
#define KEYP_TEST_DTEST_EN
#define KEYP_TEST_ABORT_READ

#define KEYP_TEST_DBG_SELECT_SHIFT

/* bits of these registers represent
 * '0' for key press
 * '1' for key release
 */
#define KEYP_RECENT_DATA
#define KEYP_OLD_DATA

#define KEYP_CLOCK_FREQ

/**
 * struct pmic8xxx_kp - internal keypad data structure
 * @num_cols: number of columns of keypad
 * @num_rows: number of row of keypad
 * @input: input device pointer for keypad
 * @regmap: regmap handle
 * @key_sense_irq: key press/release irq number
 * @key_stuck_irq: key stuck notification irq number
 * @keycodes: array to hold the key codes
 * @dev: parent device pointer
 * @keystate: present key press/release state
 * @stuckstate: present state when key stuck irq
 * @ctrl_reg: control register value
 */
struct pmic8xxx_kp {};

static u8 pmic8xxx_col_state(struct pmic8xxx_kp *kp, u8 col)
{}

/*
 * Synchronous read protocol for RevB0 onwards:
 *
 * 1. Write '1' to ReadState bit in KEYP_SCAN register
 * 2. Wait 2*32KHz clocks, so that HW can successfully enter read mode
 *    synchronously
 * 3. Read rows in old array first if events are more than one
 * 4. Read rows in recent array
 * 5. Wait 4*32KHz clocks
 * 6. Write '0' to ReadState bit of KEYP_SCAN register so that hw can
 *    synchronously exit read mode.
 */
static int pmic8xxx_chk_sync_read(struct pmic8xxx_kp *kp)
{}

static int pmic8xxx_kp_read_data(struct pmic8xxx_kp *kp, u16 *state,
					u16 data_reg, int read_rows)
{}

static int pmic8xxx_kp_read_matrix(struct pmic8xxx_kp *kp, u16 *new_state,
					 u16 *old_state)
{}

static void __pmic8xxx_kp_scan_matrix(struct pmic8xxx_kp *kp, u16 *new_state,
					 u16 *old_state)
{}

static bool pmic8xxx_detect_ghost_keys(struct pmic8xxx_kp *kp, u16 *new_state)
{}

static int pmic8xxx_kp_scan_matrix(struct pmic8xxx_kp *kp, unsigned int events)
{}

/*
 * NOTE: We are reading recent and old data registers blindly
 * whenever key-stuck interrupt happens, because events counter doesn't
 * get updated when this interrupt happens due to key stuck doesn't get
 * considered as key state change.
 *
 * We are not using old data register contents after they are being read
 * because it might report the key which was pressed before the key being stuck
 * as stuck key because it's pressed status is stored in the old data
 * register.
 */
static irqreturn_t pmic8xxx_kp_stuck_irq(int irq, void *data)
{}

static irqreturn_t pmic8xxx_kp_irq(int irq, void *data)
{}

static int pmic8xxx_kpd_init(struct pmic8xxx_kp *kp,
			     struct platform_device *pdev)
{}

static int pmic8xxx_kp_enable(struct pmic8xxx_kp *kp)
{}

static int pmic8xxx_kp_disable(struct pmic8xxx_kp *kp)
{}

static int pmic8xxx_kp_open(struct input_dev *dev)
{}

static void pmic8xxx_kp_close(struct input_dev *dev)
{}

/*
 * keypad controller should be initialized in the following sequence
 * only, otherwise it might get into FSM stuck state.
 *
 * - Initialize keypad control parameters, like no. of rows, columns,
 *   timing values etc.,
 * - configure rows and column gpios pull up/down.
 * - set irq edge type.
 * - enable the keypad controller.
 */
static int pmic8xxx_kp_probe(struct platform_device *pdev)
{}

static int pmic8xxx_kp_suspend(struct device *dev)
{}

static int pmic8xxx_kp_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(pm8xxx_kp_pm_ops,
				pmic8xxx_kp_suspend, pmic8xxx_kp_resume);

static const struct of_device_id pm8xxx_match_table[] =;
MODULE_DEVICE_TABLE(of, pm8xxx_match_table);

static struct platform_driver pmic8xxx_kp_driver =;
module_platform_driver();

MODULE_LICENSE();
MODULE_DESCRIPTION();
MODULE_ALIAS();
MODULE_AUTHOR();