#define TM2_TOUCHKEY_LED_VOLTAGE_MIN   2500000
 #define TM2_TOUCHKEY_LED_VOLTAGE_MAX   3300000
 
-enum {
-       TM2_TOUCHKEY_KEY_MENU = 0x1,
-       TM2_TOUCHKEY_KEY_BACK,
-};
-
 struct touchkey_variant {
        u8 keycode_reg;
        u8 base_reg;
        struct regulator *vdd;
        struct regulator_bulk_data regulators[2];
        const struct touchkey_variant *variant;
+       u32 keycodes[4];
+       int num_keycodes;
 };
 
 static const struct touchkey_variant tm2_touchkey_variant = {
 {
        struct tm2_touchkey_data *touchkey = devid;
        int data;
-       int key;
+       int index;
+       int i;
 
        data = i2c_smbus_read_byte_data(touchkey->client,
                                        touchkey->variant->keycode_reg);
                goto out;
        }
 
-       switch (data & TM2_TOUCHKEY_BIT_KEYCODE) {
-       case TM2_TOUCHKEY_KEY_MENU:
-               key = KEY_PHONE;
-               break;
-
-       case TM2_TOUCHKEY_KEY_BACK:
-               key = KEY_BACK;
-               break;
-
-       default:
+       index = (data & TM2_TOUCHKEY_BIT_KEYCODE) - 1;
+       if (index < 0 || index >= touchkey->num_keycodes) {
                dev_warn(&touchkey->client->dev,
-                        "unhandled keycode, data %#02x\n", data);
+                        "invalid keycode index %d\n", index);
                goto out;
        }
 
        if (data & TM2_TOUCHKEY_BIT_PRESS_EV) {
-               input_report_key(touchkey->input_dev, KEY_PHONE, 0);
-               input_report_key(touchkey->input_dev, KEY_BACK, 0);
+               for (i = 0; i < touchkey->num_keycodes; i++)
+                       input_report_key(touchkey->input_dev,
+                                        touchkey->keycodes[i], 0);
        } else {
-               input_report_key(touchkey->input_dev, key, 1);
+               input_report_key(touchkey->input_dev,
+                                touchkey->keycodes[index], 1);
        }
 
        input_sync(touchkey->input_dev);
 static int tm2_touchkey_probe(struct i2c_client *client,
                              const struct i2c_device_id *id)
 {
+       struct device_node *np = client->dev.of_node;
        struct tm2_touchkey_data *touchkey;
        int error;
+       int i;
 
        if (!i2c_check_functionality(client->adapter,
                        I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) {
        /* Save VDD for easy access */
        touchkey->vdd = touchkey->regulators[1].consumer;
 
+       touchkey->num_keycodes = of_property_read_variable_u32_array(np,
+                                       "linux,keycodes", touchkey->keycodes, 0,
+                                       ARRAY_SIZE(touchkey->keycodes));
+       if (touchkey->num_keycodes <= 0) {
+               /* default keycodes */
+               touchkey->keycodes[0] = KEY_PHONE;
+               touchkey->keycodes[1] = KEY_BACK;
+               touchkey->num_keycodes = 2;
+       }
+
        error = tm2_touchkey_power_enable(touchkey);
        if (error) {
                dev_err(&client->dev, "failed to power up device: %d\n", error);
        touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
        touchkey->input_dev->id.bustype = BUS_I2C;
 
-       input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE);
-       input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK);
+       for (i = 0; i < touchkey->num_keycodes; i++)
+               input_set_capability(touchkey->input_dev, EV_KEY,
+                                    touchkey->keycodes[i]);
 
        error = input_register_device(touchkey->input_dev);
        if (error) {