Input: tegra-kbc - allow skipping setting up some of GPIO pins
Allow marking some of GPIO pins as ignored to to avoid continuously generating KBC input events. Signed-off-by: Shridhar Rasal <srasal@nvidia.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
8491ee1093
commit
023cea0ecf
|
@ -31,8 +31,14 @@
|
|||
#define KBC_MAX_COL 8
|
||||
#define KBC_MAX_KEY (KBC_MAX_ROW * KBC_MAX_COL)
|
||||
|
||||
enum tegra_pin_type {
|
||||
PIN_CFG_IGNORE,
|
||||
PIN_CFG_COL,
|
||||
PIN_CFG_ROW,
|
||||
};
|
||||
|
||||
struct tegra_kbc_pin_cfg {
|
||||
bool is_row;
|
||||
enum tegra_pin_type type;
|
||||
unsigned char num;
|
||||
};
|
||||
|
||||
|
|
|
@ -468,10 +468,18 @@ static void tegra_kbc_config_pins(struct tegra_kbc *kbc)
|
|||
row_cfg &= ~r_mask;
|
||||
col_cfg &= ~c_mask;
|
||||
|
||||
if (pdata->pin_cfg[i].is_row)
|
||||
switch (pdata->pin_cfg[i].type) {
|
||||
case PIN_CFG_ROW:
|
||||
row_cfg |= ((pdata->pin_cfg[i].num << 1) | 1) << r_shft;
|
||||
else
|
||||
break;
|
||||
|
||||
case PIN_CFG_COL:
|
||||
col_cfg |= ((pdata->pin_cfg[i].num << 1) | 1) << c_shft;
|
||||
break;
|
||||
|
||||
case PIN_CFG_IGNORE:
|
||||
break;
|
||||
}
|
||||
|
||||
writel(row_cfg, kbc->mmio + r_offs);
|
||||
writel(col_cfg, kbc->mmio + c_offs);
|
||||
|
@ -576,7 +584,8 @@ tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,
|
|||
for (i = 0; i < KBC_MAX_GPIO; i++) {
|
||||
const struct tegra_kbc_pin_cfg *pin_cfg = &pdata->pin_cfg[i];
|
||||
|
||||
if (pin_cfg->is_row) {
|
||||
switch (pin_cfg->type) {
|
||||
case PIN_CFG_ROW:
|
||||
if (pin_cfg->num >= KBC_MAX_ROW) {
|
||||
dev_err(dev,
|
||||
"pin_cfg[%d]: invalid row number %d\n",
|
||||
|
@ -584,13 +593,25 @@ tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,
|
|||
return false;
|
||||
}
|
||||
(*num_rows)++;
|
||||
} else {
|
||||
break;
|
||||
|
||||
case PIN_CFG_COL:
|
||||
if (pin_cfg->num >= KBC_MAX_COL) {
|
||||
dev_err(dev,
|
||||
"pin_cfg[%d]: invalid column number %d\n",
|
||||
i, pin_cfg->num);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case PIN_CFG_IGNORE:
|
||||
break;
|
||||
|
||||
default:
|
||||
dev_err(dev,
|
||||
"pin_cfg[%d]: invalid entry type %d\n",
|
||||
pin_cfg->type, pin_cfg->num);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,7 +628,6 @@ tegra_kbc_dt_parse_pdata(struct platform_device *pdev)
|
|||
if (!np)
|
||||
return NULL;
|
||||
|
||||
pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return NULL;
|
||||
|
||||
|
@ -629,12 +649,12 @@ tegra_kbc_dt_parse_pdata(struct platform_device *pdev)
|
|||
*/
|
||||
for (i = 0; i < KBC_MAX_ROW; i++) {
|
||||
pdata->pin_cfg[i].num = i;
|
||||
pdata->pin_cfg[i].is_row = true;
|
||||
pdata->pin_cfg[i].type = PIN_CFG_ROW;
|
||||
}
|
||||
|
||||
for (i = 0; i < KBC_MAX_COL; i++) {
|
||||
pdata->pin_cfg[KBC_MAX_ROW + i].num = i;
|
||||
pdata->pin_cfg[KBC_MAX_ROW + i].is_row = false;
|
||||
pdata->pin_cfg[KBC_MAX_ROW + i].type = PIN_CFG_COL;
|
||||
}
|
||||
|
||||
return pdata;
|
||||
|
|
Loading…
Reference in New Issue