@@ -43,6 +43,7 @@
#define QT2160_CMD_SUBVER 7
#define QT2160_CMD_CALIBRATE 10
#define QT2160_CMD_RESET 11
+#define QT2160_CMD_LP_MODE 12
#define QT2160_CMD_BURST_REP 13
#define QT2160_CMD_NEG_DRIFT 15
#define QT2160_CMD_POS_DRIFT 16
@@ -66,6 +67,9 @@
#define QT2160_CYCLE_INTERVAL (2*HZ)
+#define QT2160_LP_MODE_DEFAULT_VALUE (1)
+#define QT2160_LP_MODE_SLEEP_VALUE (0)
+
#define QT2160_SLIDE_RESOLUTION (8)
#define QT2160_SLIDE_HYSTERESIS (10)
#define QT2160_SLIDE_MAX_VALUE (0xFF)
@@ -529,6 +533,34 @@ static int __devexit qt2160_remove(struct i2c_client *client)
return 0;
}
+#ifdef CONFIG_PM
+static int qt2160_suspend(struct i2c_client *client, pm_message_t message)
+{
+ int error;
+
+ error = i2c_smbus_write_byte_data(client, QT2160_CMD_LP_MODE,
+ QT2160_LP_MODE_SLEEP_VALUE);
+ if (error)
+ dev_err(&client->dev, "could not write power config\n");
+ return error;
+}
+
+static int qt2160_resume(struct i2c_client *client)
+{
+ int error;
+ u8 lp_mode_val = QT2160_LP_MODE_DEFAULT_VALUE;
+
+ error = i2c_smbus_write_byte_data(client, QT2160_CMD_LP_MODE,
+ lp_mode_val);
+ if (error)
+ dev_err(&client->dev, "could not write power config\n");
+ return error;
+}
+#else
+#define qt2160_suspend NULL
+#define qt2160_resume NULL
+#endif
+
static const struct i2c_device_id qt2160_idtable[] = {
{ "qt2160", 0, },
{ }
@@ -545,6 +577,8 @@ static struct i2c_driver qt2160_driver = {
.id_table = qt2160_idtable,
.probe = qt2160_probe,
.remove = __devexit_p(qt2160_remove),
+ .suspend = qt2160_suspend,
+ .resume = qt2160_resume,
};
static int __init qt2160_init(void)