Input: synaptics-rmi4 - add support for F34 V7 bootloader
Subsystems (2)
PATCH v8 1/1 Input: synaptics-rmi4 - add support for F34 V7 bootloader
Port firmware update code from Samsung Galaxy S7 driver into mainline framework.
This patch has been tested on Synaptics S7813.
---
Hi Dmitry-
Thanks for the useful review, here is an updated version.
This patch applies on top of dtor/synaptics-rmi4. The F34 V1 support has already been merged.
Changes in v8:
- Address Dmitry Torokhov review comments.
Changes in v7:
- Removed bitfields (would cause issues on big endian archs)
Changes in v6:
- Properly free irq_memory in rmi_free_function_list()
- Split out the sysfs changes for now
- Various coding style improvements to the V7 patch (now checkpatch clean)
Changes in v5:
- Improve split between for different versions (req. Bjorn Andersson)
- Address a couple of kbuild test robot issues
- Fix a bug with configuration ID on V7
Changes in v4:
- Add support for v7 bootloaders and fix numerous issues
- Add sysfs attributes for retrieving various hardware IDs
- Add a couple of debug lines to core
Changes in v3:
- Only attempt to flash on F34 V0 (later versions have different register map)
Changes in v2:
- Resolved reliability issues with locking and teardown/re-probe
- Add #ifdefs for CONFIG_RMI4_F34 in rmi_driver.c
- Slightly improve debug
- Tested by Chris Healy
drivers/input/rmi4/Makefile | 2 +- drivers/input/rmi4/rmi_driver.c | 56 +- drivers/input/rmi4/rmi_f34.c | 40 +- drivers/input/rmi4/rmi_f34.h | 252 ++++++- drivers/input/rmi4/rmi_f34v7.c | 1405 +++++++++++++++++++++++++++++++++++++++ include/linux/rmi.h | 2 +- 6 files changed, 1722 insertions(+), 35 deletions(-) create mode 100644 drivers/input/rmi4/rmi_f34v7.c
drivers/input/rmi4/Makefile +1 -1
@@ -8,7 +8,7 @@ rmi_core-$(CONFIG_RMI4_F03) += rmi_f03.o rmi_core-$(CONFIG_RMI4_F11) += rmi_f11.o rmi_core-$(CONFIG_RMI4_F12) += rmi_f12.o rmi_core-$(CONFIG_RMI4_F30) += rmi_f30.o -rmi_core-$(CONFIG_RMI4_F34) += rmi_f34.o +rmi_core-$(CONFIG_RMI4_F34) += rmi_f34.o rmi_f34v7.o rmi_core-$(CONFIG_RMI4_F54) += rmi_f54.o rmi_core-$(CONFIG_RMI4_F55) += rmi_f55.o
drivers/input/rmi4/rmi_driver.c +33 -23
94 lines not on this page · raw message
drivers/input/rmi4/rmi_f34.c +33 -7
@@ -12,6 +12,7 @@#include <linux/firmware.h> #include <asm/unaligned.h> #include <asm/unaligned.h> +#include <linux/bitops.h> #include "rmi_driver.h" #include "rmi_f34.h"
@@ -105,6 +106,9 @@ static int rmi_f34_attention(struct rmi_function *fn, unsigned long *irq_bits)struct f34_data *f34 =dev_get_drvdata (&fn->dev);int ret; +if (f34->bl_version !=5 ) +return 0 ; + ret =rmi_read (f34->fn->rmi_dev, f34->v5.ctrl_address, &f34->v5.status);rmi_dbg (RMI_DEBUG_FN , &fn->dev,"%s: status: %#02x, ret: %d\n" , __func__, f34->v5.status, ret);
@@ -292,17 +296,24 @@ static int rmi_firmware_update(struct rmi_driver_data *data,return -EINVAL ; } -/* Only version 0 currently supported */ -if (data->f34_container->fd.function_version !=0 ) { + f34 =dev_get_drvdata (&data->f34_container->dev); + +if (f34->bl_version ==7 ) { +if (data->pdt_props &HAS_BSR ) { +dev_err (dev,"%s: LTS not supported\n" , __func__); +return -ENODEV ; + } + }else if (f34->bl_version !=5 ) {dev_warn (dev,"F34 V%d not supported!\n" , data->f34_container->fd.function_version);return -ENODEV ; } - f34 =dev_get_drvdata (&data->f34_container->dev); -/* Enter flash mode */ - ret =rmi_f34_enable_flash (f34); +if (f34->bl_version ==7 ) + ret =rmi_f34v7_start_reflash (f34, fw); +else + ret =rmi_f34_enable_flash (f34);if (ret)return ret;
@@ -319,7 +330,7 @@ static int rmi_firmware_update(struct rmi_driver_data *data,if (ret)return ret; -if (!data->f01_bootloader_mode || !data->f34_container) { +if (!data->bootloader_mode || !data->f34_container) {dev_warn (dev,"%s: No F34 present or not in bootloader!\n" , __func__);return -EINVAL ;
@@ -330,7 +341,10 @@ static int rmi_firmware_update(struct rmi_driver_data *data, f34 =dev_get_drvdata (&data->f34_container->dev);/* Perform firmware update */ - ret =rmi_f34_update_firmware (f34, fw); +if (f34->bl_version ==7 ) + ret =rmi_f34v7_do_reflash (f34, fw); +else + ret =rmi_f34_update_firmware (f34, fw);dev_info (&f34->fn->dev,"Firmware update complete, status:%d\n" , ret);
@@ -363,6 +377,9 @@ static int rmi_firmware_update(struct rmi_driver_data *data,return ret; } +static int rmi_firmware_update (struct rmi_driver_data *data, +const struct firmware *fw); +static ssize_t rmi_driver_update_fw_store (struct device *dev,struct device_attribute *dattr,const char *buf,size_t count)
@@ -411,6 +428,7 @@ static int rmi_f34_probe(struct rmi_function *fn)struct f34_data *f34;unsigned char f34_queries[9 ];bool has_config_id; +u8 version = fn->fd.function_version;int ret; f34 =devm_kzalloc (&fn->dev,sizeof (struct f34_data ),GFP_KERNEL );
@@ -420,6 +438,14 @@ static int rmi_f34_probe(struct rmi_function *fn) f34->fn = fn;dev_set_drvdata (&fn->dev, f34); +/* v5 code only supported version 0, try V7 probe */ +if (version >0 ) +return rmi_f34v7_probe (f34); +else if (version !=0 ) +return -ENODEV ; + + f34->bl_version =5 ; + ret =rmi_read_block (fn->rmi_dev, fn->fd.query_base_addr, f34_queries,sizeof (f34_queries));if (ret) {
drivers/input/rmi4/rmi_f34.h +249 -3
268 lines not on this page · raw message
drivers/input/rmi4/rmi_f34v7.c new file +1405 -0
1,405 lines not on this page · raw message
include/linux/rmi.h +1 -1
@@ -342,7 +342,7 @@ struct rmi_driver_data {struct rmi_function *f01_container;struct rmi_function *f34_container; -bool f01_bootloader_mode; +bool bootloader_mode;int num_of_irq_regs;int irq_count;
Signature · 1 line
2.7.4
Dmitry Torokhov
maintainerHi Nick,
Quoted 7 lines · Nick Dyer
drivers/input/rmi4/rmi_f34v7.c new file +7
-0+static void rmi_f34v7_parse_img_header_10_bl_container (struct f34_data *f34, +const u8 *image) +{ +int i; +u8 num_of_containers; +unsigned int addr; +unsigned int container_id;
drivers/input/rmi4/rmi_f34v7.c line 1078
Quoted 10 lines
drivers/input/rmi4/rmi_f34v7.c new file +10
-0+unsigned int length; +const u8 *content; +struct container_descriptor *descriptor; + +BUG_ON (f34->v7.img.bootloader.size <4 ); + + num_of_containers = (f34->v7.img.bootloader.size -4 ) /4 ; + +for (i =1 ; i <= num_of_containers; i++) { + addr =le32_to_cpu (f34->v7.img.bootloader.data + (i *4 ));
This cannot possibly be right. "f34->v7.img.bootloader.data + (i * 4)" is a pointer in memory, you should not be converting it from le32.
Did you mean to use le32_to_cpup((__le32 *)(f34->v7.img.bootloader.data
+ (i * 4))) ?
Thanks.
Signature · 1 line
Dmitry
Quoted 22 lines · Dmitry Torokhov
Quoted 7 lines · Nick Dyer
drivers/input/rmi4/rmi_f34v7.c new file +7
-0+static void rmi_f34v7_parse_img_header_10_bl_container (struct f34_data *f34, +const u8 *image) +{ +int i; +u8 num_of_containers; +unsigned int addr; +unsigned int container_id;drivers/input/rmi4/rmi_f34v7.c line 1078
Quoted 10 lines
drivers/input/rmi4/rmi_f34v7.c new file +10
-0+unsigned int length; +const u8 *content; +struct container_descriptor *descriptor; + +BUG_ON (f34->v7.img.bootloader.size <4 ); + + num_of_containers = (f34->v7.img.bootloader.size -4 ) /4 ; + +for (i =1 ; i <= num_of_containers; i++) { + addr =le32_to_cpu (f34->v7.img.bootloader.data + (i *4 ));This cannot possibly be right. "
f34->v7.img.bootloader.data+ (i * 4)" is a pointer in memory, you should not be converting it from le32.
Quoted 2 lines
Did you mean to use le32_to_cpup((__le32 *)(f34->v7.img.bootloader.data
+ (i * 4))) ?
You're quit right. It should be get_unaligned_le32() to read an offset address from the firmware image. Will be fixed in v9.
Nick