/* * Changing this register will change the brightness * of every LED in the qt2160. It's a HW limitation.
*/ if (value != LED_OFF)
qt2160_write(client, QT2160_CMD_PWM_DUTY, value);
/* * Can't use SMBus block data read. Check for I2C functionality to speed * things up whenever possible. Otherwise we will be forced to read * sequentially.
*/ if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
error = i2c_smbus_write_byte(client, inireg + idx); if (error) {
dev_err(&client->dev, "couldn't send request. Returned %d\n", error); return error;
}
/* * Read all registers from General Status Register * to GPIOs register
*/
ret = qt2160_read_block(client, QT2160_CMD_GSTAT, regs, 6); if (ret) {
dev_err(&client->dev, "could not perform chip read.\n"); return;
}
staticbool qt2160_identify(struct i2c_client *client)
{ int id, ver, rev;
/* Read Chid ID to check if chip is valid */
id = qt2160_read(client, QT2160_CMD_CHIPID); if (id != QT2160_VALID_CHIPID) {
dev_err(&client->dev, "ID %d not supported\n", id); returnfalse;
}
/* Read chip firmware version */
ver = qt2160_read(client, QT2160_CMD_CODEVER); if (ver < 0) {
dev_err(&client->dev, "could not get firmware version\n"); returnfalse;
}
/* Read chip firmware revision */
rev = qt2160_read(client, QT2160_CMD_SUBVER); if (rev < 0) {
dev_err(&client->dev, "could not get firmware revision\n"); returnfalse;
}
dev_info(&client->dev, "AT42QT2160 firmware version %d.%d.%d\n",
ver >> 4, ver & 0xf, rev);
returntrue;
}
staticint qt2160_probe(struct i2c_client *client)
{ struct qt2160_data *qt2160; struct input_dev *input; int i; int error;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
dev_err(&client->dev, "%s adapter not supported\n",
dev_driver_string(&client->adapter->dev)); return -ENODEV;
}
if (!qt2160_identify(client)) return -ENODEV;
/* Chip is valid and active. Allocate structure */
qt2160 = devm_kzalloc(&client->dev, sizeof(*qt2160), GFP_KERNEL); if (!qt2160) return -ENOMEM;
input = devm_input_allocate_device(&client->dev); if (!input) return -ENOMEM;
qt2160->client = client;
qt2160->input = input;
input->name = "AT42QT2160 Touch Sense Keyboard";
input->id.bustype = BUS_I2C;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.