Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752803AbaFFHbj (ORCPT ); Fri, 6 Jun 2014 03:31:39 -0400 Received: from relay-s04-hub006.domainlocalhost.com ([74.115.207.217]:38435 "EHLO relay-S04-HUB006.domainlocalhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752522AbaFFH3N (ORCPT ); Fri, 6 Jun 2014 03:29:13 -0400 Content-Type: multipart/mixed; boundary="_000_77BC725C9062764F874D79F51E1F1A8F4406C8E4S04MBX0101s04lo_" From: Dudley Du To: Dmitry Torokhov , "Rafael J. Wysocki" , Alan Stern CC: Benson Leung , Lily Rui , "Daniel Kurtz" , "linux-kernel@vger.kernel.org" , "linux-input@vger.kernel.org" Subject: [PATCH v2 9/14] input: cyapa: add gen3 trackpad device read firmware image function supported Thread-Topic: [PATCH v2 9/14] input: cyapa: add gen3 trackpad device read firmware image function supported Thread-Index: Ac+BWOzJPIh1Vy0uRvy9B48DS0G8TQ== Date: Fri, 6 Jun 2014 07:29:11 +0000 Message-ID: <77BC725C9062764F874D79F51E1F1A8F4406C8E4@S04-MBX01-01.s04.local> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: <77BC725C9062764F874D79F51E1F1A8F4406C8E4@S04-MBX01-01.s04.local> x-originating-ip: [10.30.12.146] MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --_000_77BC725C9062764F874D79F51E1F1A8F4406C8E4S04MBX0101s04lo_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Add read firmware image function supported for gen3 trackpad device, which its function is supplied through cyapa core read_fw interface. TEST=3Dtest on Chomebooks. Signed-off-by: Du, Dudley --- diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_g= en3.c index 9ffdbc1..e903e62 100644 --- a/drivers/input/mouse/cyapa_gen3.c +++ b/drivers/input/mouse/cyapa_gen3.c @@ -689,6 +689,35 @@ static int cyapa_gen3_write_fw_block(struct cyapa *cya= pa, return ret; } +/* + * A firmware block read command reads 16 bytes of data from flash startin= g + * from a given address. The 12-byte block read command has the format: + * <0xff> + * + * <0xff> - every command starts with 0xff + * - the read command value is 0x3c + * - read commands include an 8-byte key: { 00 01 02 03 04 05 06 = 07 } + * - Memory address (16-bit, big-endian) + * + * The command is followed by an i2c block read to read the 16 bytes of da= ta. + */ +static int cyapa_gen3_read_fw_bytes(struct cyapa *cyapa, u16 addr, u8 *dat= a) +{ + int ret; + u8 cmd[] =3D { 0xff, 0x3c, 0, 1, 2, 3, 4, 5, 6, 7, addr >> 8, addr = }; + + ret =3D cyapa_gen3_write_buffer(cyapa, cmd, sizeof(cmd)); + if (ret) + return ret; + + /* read data buffer starting from offset 16 */ + ret =3D cyapa_i2c_reg_read_block(cyapa, 16, CYAPA_FW_READ_SIZE, dat= a); + if (ret !=3D CYAPA_FW_READ_SIZE) + return (ret < 0) ? ret : -EIO; + + return 0; +} + static int cyapa_gen3_do_fw_update(struct cyapa *cyapa, const struct firmware *fw) { @@ -724,6 +753,47 @@ static int cyapa_gen3_do_fw_update(struct cyapa *cyapa= , return 0; } +/* + * Read the entire firmware image into ->read_fw_image. + * If the ->read_fw_image has already been allocated, then this function + * doesn't do anything and just returns 0. + * If an error occurs while reading the image, ->read_fw_image is freed, a= nd + * the error is returned. + * + * The firmware is a fixed size (CYAPA_FW_SIZE), and is read out in + * fixed length (CYAPA_FW_READ_SIZE) chunks. + */ +static int cyapa_gen3_read_fw(struct cyapa *cyapa) +{ + int ret; + int addr; + + ret =3D cyapa_gen3_bl_enter(cyapa); + if (ret) + goto err; + + cyapa->read_fw_image =3D kmalloc(CYAPA_FW_SIZE, GFP_KERNEL); + if (!cyapa->read_fw_image) { + ret =3D -ENOMEM; + goto err; + } + + for (addr =3D 0; addr < CYAPA_FW_SIZE; addr +=3D CYAPA_FW_READ_SIZE= ) { + ret =3D cyapa_gen3_read_fw_bytes(cyapa, CYAPA_FW_HDR_START = + addr, + &cyapa->read_fw_image[addr]); + if (ret) { + kfree(cyapa->read_fw_image); + cyapa->read_fw_image =3D NULL; + break; + } + } + +err: + if (cyapa->read_fw_image) + cyapa->read_fw_image_size =3D CYAPA_FW_SIZE; + return ret; +} + static ssize_t cyapa_gen3_do_calibrate(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1122,7 +1192,7 @@ const struct cyapa_dev_ops cyapa_gen3_ops =3D { cyapa_gen3_show_baseline, cyapa_gen3_do_calibrate, - NULL, + cyapa_gen3_read_fw, NULL, NULL, This message and any attachments may contain Cypress (or its subsidiaries) = confidential information. If it has been received in error, please advise t= he sender and immediately delete this message. --_000_77BC725C9062764F874D79F51E1F1A8F4406C8E4S04MBX0101s04lo_ Content-Disposition: attachment; filename="winmail.dat" Content-Transfer-Encoding: base64 Content-Type: application/ms-tnef; name="winmail.dat" eJ8+IpdoAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEJgAEAIQAAADVCRTVDMENB MjQ1QTczNEE5NjJFODMzMDkzRURBODI1ACwHAQ2ABAACAAAAAgACAAEFgAMADgAAAN4HBgAGAAcA HQALAAUAJQEBIIADAA4AAADeBwYABgAHAB0ACwAFACUBAQiABwAYAAAASVBNLk1pY3Jvc29mdCBN YWlsLk5vdGUAMQgBBIABAF4AAABbUEFUQ0ggdjIgOS8xNF0gaW5wdXQ6IGN5YXBhOiBhZGQgZ2Vu MyB0cmFja3BhZCBkZXZpY2UgcmVhZCBmaXJtd2FyZSBpbWFnZSBmdW5jdGlvbiBzdXBwb3J0ZWQA hyABA5AGAIAUAABKAAAAAgF/AAEAAABCAAAAPDc3QkM3MjVDOTA2Mjc2NEY4NzRENzlGNTFFMUYx QThGNDQwNkM4RTRAUzA0LU1CWDAxLTAxLnMwNC5sb2NhbD4AAAALAB8OAQAAAAIBCRABAAAAFggA ABIIAAAOEgAATFpGdeIGtLNhAApmY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AAAAADAAAAAAAAARgAAAAAOhQAAAAAAAAMAAIAI IAYAAAAAAMAAAAAAAABGAAAAABiFAAAAAAAACwAAgAggBgAAAAAAwAAAAAAAAEYAAAAAgoUAAAAA AAADAA00/T8AAB8AAICGAwIAAAAAAMAAAAAAAABGAQAAACAAAAB4AC0AbQBzAC0AaABhAHMALQBh AHQAdABhAGMAaAAAAAEAAAACAAAAAAAAAB8AAICGAwIAAAAAAMAAAAAAAABGAQAAACIAAAB4AC0A bwByAGkAZwBpAG4AYQB0AGkAbgBnAC0AaQBwAAAAAAABAAAAHgAAAFsAMQAwAC4AMwAwAC4AMQAy AC4AMQA0ADYAXQAAAAAAa9Q= --_000_77BC725C9062764F874D79F51E1F1A8F4406C8E4S04MBX0101s04lo_-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/