Modified: trunk/drivers/input/keyboard/adp5589-keys.c (9074 => 9075)
--- trunk/drivers/input/keyboard/adp5589-keys.c 2010-08-10 08:30:57 UTC (rev 9074)
+++ trunk/drivers/input/keyboard/adp5589-keys.c 2010-08-10 12:10:57 UTC (rev 9075)
@@ -55,6 +55,10 @@
#define LOCK_STAT (1 << 5)
#define KEC 0xF
+/* PIN_CONFIG_D Register */
+#define C4_EXTEND_CFG (1 << 6) /* RESET2 */
+#define R4_EXTEND_CFG (1 << 5) /* RESET1 */
+
/* LOCK_CFG */
#define LOCK_EN (1 << 0)
@@ -77,6 +81,7 @@
unsigned short keycode[ADP5589_KEYMAPSIZE];
const struct adp5589_gpi_map *gpimap;
unsigned short gpimapsize;
+ unsigned extend_cfg;
#ifdef CONFIG_GPIOLIB
unsigned char gpiomap[MAXGPIO];
bool export_gpio;
@@ -195,6 +200,12 @@
for (i = 0; i < kpad->gpimapsize; i++)
pin_used[kpad->gpimap[i].pin - ADP5589_GPI_PIN_BASE] = true;
+ if (kpad->extend_cfg & R4_EXTEND_CFG)
+ pin_used[4] = true;
+
+ if (kpad->extend_cfg & C4_EXTEND_CFG)
+ pin_used[12] = true;
+
for (i = 0; i < MAXGPIO; i++)
if (!pin_used[i])
kpad->gpiomap[n_unused++] = i;
@@ -340,8 +351,19 @@
return IRQ_HANDLED;
}
-static int __devinit adp5589_setup(struct i2c_client *client)
+static int __devinit adp5589_get_evcode(struct adp5589_kpad *kpad, unsigned short key)
{
+ int i;
+ for (i = 0; i < ADP5589_KEYMAPSIZE; i++)
+ if (key == kpad->keycode[i])
+ return (i + 1) | KEY_EV_PRESSED;
+
+ dev_err(&kpad->client->dev, "RESET/UNLOCK key not in keycode map\n");
+ return -EINVAL;
+}
+static int __devinit adp5589_setup(struct adp5589_kpad *kpad)
+{
+ struct i2c_client *client = kpad->client;
const struct adp5589_kpad_platform_data *pdata =
client->dev.platform_data;
int i, ret;
@@ -412,6 +434,37 @@
}
}
+ if (pdata->reset1_key_1 && pdata->reset1_key_2 &&
+ pdata->reset1_key_3) {
+ ret |= adp5589_write(client, ADP5589_RESET1_EVENT_A,
+ adp5589_get_evcode(kpad,
+ pdata->reset1_key_1));
+ ret |= adp5589_write(client, ADP5589_RESET1_EVENT_B,
+ adp5589_get_evcode(kpad,
+ pdata->reset1_key_2));
+ ret |= adp5589_write(client, ADP5589_RESET1_EVENT_C,
+ adp5589_get_evcode(kpad,
+ pdata->reset1_key_3));
+ kpad->extend_cfg |= R4_EXTEND_CFG;
+ }
+
+ if (pdata->reset2_key_1 && pdata->reset2_key_2) {
+ ret |= adp5589_write(client, ADP5589_RESET2_EVENT_A,
+ adp5589_get_evcode(kpad,
+ pdata->reset2_key_1));
+ ret |= adp5589_write(client, ADP5589_RESET2_EVENT_B,
+ adp5589_get_evcode(kpad,
+ pdata->reset2_key_2));
+ kpad->extend_cfg |= C4_EXTEND_CFG;
+ }
+
+ if (kpad->extend_cfg) {
+ ret |= adp5589_write(client, ADP5589_RESET_CFG,
+ pdata->reset_cfg);
+ ret |= adp5589_write(client, ADP5589_PIN_CONFIG_D,
+ kpad->extend_cfg);
+ }
+
for (i = 0; i <= ADP_BANK(MAXGPIO); i++)
ret |= adp5589_write(client, ADP5589_DEBOUNCE_DIS_A + i,
pdata->debounce_dis_mask >> (i * 8));
@@ -603,7 +656,7 @@
goto err_unreg_dev;
}
- error = adp5589_setup(client);
+ error = adp5589_setup(kpad);
if (error)
goto err_free_irq;
Modified: trunk/include/linux/input/adp5589.h (9074 => 9075)
--- trunk/include/linux/input/adp5589.h 2010-08-10 08:30:57 UTC (rev 9074)
+++ trunk/include/linux/input/adp5589.h 2010-08-10 12:10:57 UTC (rev 9075)
@@ -89,7 +89,6 @@
#define ADP5589_GENERAL_CFG 0x4D
#define ADP5589_INT_EN 0x4E
-
#define ADP5589_DEVICE_ID_MASK 0xF
/* Put one of these structures in i2c_board_info platform_data */
@@ -139,6 +138,27 @@
#define ADP5589_SCAN_CYCLE_30ms 2
#define ADP5589_SCAN_CYCLE_40ms 3
+/* RESET_CFG */
+#define RESET_PULSE_WIDTH_500us 0
+#define RESET_PULSE_WIDTH_1ms 1
+#define RESET_PULSE_WIDTH_2ms 2
+#define RESET_PULSE_WIDTH_10ms 3
+
+#define RESET_TRIG_TIME_0ms (0 << 2)
+#define RESET_TRIG_TIME_1000ms (1 << 2)
+#define RESET_TRIG_TIME_1500ms (2 << 2)
+#define RESET_TRIG_TIME_2000ms (3 << 2)
+#define RESET_TRIG_TIME_2500ms (4 << 2)
+#define RESET_TRIG_TIME_3000ms (5 << 2)
+#define RESET_TRIG_TIME_3500ms (6 << 2)
+#define RESET_TRIG_TIME_4000ms (7 << 2)
+
+#define RESET_PASSTHRU_EN (1 << 5)
+#define RESET1_POL_HIGH (1 << 6)
+#define RESET1_POL_LOW (0 << 6)
+#define RESET2_POL_HIGH (1 << 7)
+#define RESET2_POL_LOW (0 << 7)
+
/* Mask Bits:
* C C C C C C C C C C C | R R R R R R R R
* 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
@@ -161,6 +181,12 @@
unsigned char unlock_key2; /* Unlock Key 2 */
unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable */
unsigned char scan_cycle_time; /* Time between consecutive scan cycles */
+ unsigned char reset_cfg; /* Reset config */
+ unsigned short reset1_key_1; /* Reset Key 1 */
+ unsigned short reset1_key_2; /* Reset Key 2 */
+ unsigned short reset1_key_3; /* Reset Key 3 */
+ unsigned short reset2_key_1; /* Reset Key 1 */
+ unsigned short reset2_key_2; /* Reset Key 2 */
unsigned debounce_dis_mask; /* Disable debounce mask */
unsigned pull_dis_mask; /* Disable all pull resistors mask */
unsigned pullup_en_100k; /* Pull-Up 100k Enable Mask */