Input: tegra-kbc - allow skipping setting up some of GPIO pins
authorShridhar Rasal <srasal@nvidia.com>
Fri, 3 Feb 2012 08:27:30 +0000 (00:27 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 3 Feb 2012 08:29:06 +0000 (00:29 -0800)
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>
arch/arm/mach-tegra/include/mach/kbc.h
drivers/input/keyboard/tegra-kbc.c

index d34ecd1bea63cfb0ea34ce76915d23124b772b3e..a13025612939101fb14f89aecb7043c69adc6464 100644 (file)
 #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;
 };
 
index b307a46ecef1114d935ddf3f02fc117215923f97..dc19432c665be24d07e22c9a909376f43a75509a 100644 (file)
@@ -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;