Input: synaptics-rmi4 - F34 device reflash support
Subsystems (2)
v5 cover Input: synaptics-rmi4 - F34 device reflash support
Hi-
Please find attached patches to add F34 firmware update to the RMI4 driver.
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
cheers
Nick
PATCH v5 1/7 Input: synaptics-rmi4 - factor out functions from probe
--- drivers/input/rmi4/rmi_driver.c | 139 +++++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 53 deletions(-)
drivers/input/rmi4/rmi_driver.c +86 -53
@@ -38,6 +38,8 @@ static void rmi_free_function_list(struct rmi_device *rmi_dev)struct rmi_function *fn, *tmp;struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev); +rmi_dbg (RMI_DEBUG_CORE , &rmi_dev->dev,"Freeing function list\n" ); + data->f01_container =NULL ;/* Doing it in the reverse order so F01 will be removed last */
@@ -842,15 +844,90 @@ static inline int rmi_driver_of_probe(struct device *dev, }#endif +static int rmi_probe_interrupts (struct rmi_driver_data *data) +{ +struct rmi_device *rmi_dev = data->rmi_dev; +struct device *dev = &rmi_dev->dev; +int irq_count; +size_t size; +void *irq_memory; +int retval; + +/* +* We need to count the IRQs and allocate their storage before scanning +* the PDT and creating the function entries, because adding a new +* function can trigger events that result in the IRQ related storage +* being accessed. +*/ +rmi_dbg (RMI_DEBUG_CORE , dev,"%s: Counting IRQs.\n" , __func__); + irq_count =0 ; + retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_count_irqs); +if (retval <0 ) { +dev_err (dev,"IRQ counting failed with code %d.\n" , retval); +return retval; + } + data->irq_count = irq_count; + data->num_of_irq_regs = (data->irq_count +7 ) /8 ; + + size =BITS_TO_LONGS (data->irq_count) *sizeof (unsigned long ); + irq_memory =devm_kzalloc (dev, size *4 ,GFP_KERNEL ); +if (!irq_memory) { +dev_err (dev,"Failed to allocate memory for irq masks.\n" ); +return retval; + } + + data->irq_status = irq_memory + size *0 ; + data->fn_irq_bits = irq_memory + size *1 ; + data->current_irq_mask = irq_memory + size *2 ; + data->new_irq_mask = irq_memory + size *3 ; + +return retval; +} + +static int rmi_init_functions (struct rmi_driver_data *data) +{ +struct rmi_device *rmi_dev = data->rmi_dev; +struct device *dev = &rmi_dev->dev; +int irq_count; +int retval; + + irq_count =0 ; +rmi_dbg (RMI_DEBUG_CORE , dev,"%s: Creating functions.\n" , __func__); + retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_create_function); +if (retval <0 ) { +dev_err (dev,"Function creation failed with code %d.\n" , + retval); + goto err_destroy_functions; + } + +if (!data->f01_container) { +dev_err (dev,"Missing F01 container!\n" ); + retval = -EINVAL ; + goto err_destroy_functions; + } + + retval =rmi_read_block (rmi_dev, + data->f01_container->fd.control_base_addr +1 , + data->current_irq_mask, data->num_of_irq_regs); +if (retval <0 ) { +dev_err (dev,"%s: Failed to read current IRQ mask.\n" , + __func__); + goto err_destroy_functions; + } + +return 0 ; + +err_destroy_functions: +rmi_free_function_list (rmi_dev); +return retval; +} +static int rmi_driver_probe (struct device *dev) {struct rmi_driver *rmi_driver;struct rmi_driver_data *data;struct rmi_device_platform_data *pdata;struct rmi_device *rmi_dev; -size_t size; -void *irq_memory; -int irq_count;int retval; rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Starting probe.\n",
@@ -916,35 +993,11 @@ static int rmi_driver_probe(struct device *dev) PDT_PROPERTIES_LOCATION, retval); } -/* -* We need to count the IRQs and allocate their storage before scanning -* the PDT and creating the function entries, because adding a new -* function can trigger events that result in the IRQ related storage -* being accessed. -*/ -rmi_dbg (RMI_DEBUG_CORE , dev,"Counting IRQs.\n" ); - irq_count =0 ; - retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_count_irqs); -if (retval <0 ) { -dev_err (dev,"IRQ counting failed with code %d.\n" , retval); - goto err; - } - data->irq_count = irq_count; - data->num_of_irq_regs = (data->irq_count +7 ) /8 ; -mutex_init (&data->irq_mutex); - size =BITS_TO_LONGS (data->irq_count) *sizeof (unsigned long ); - irq_memory =devm_kzalloc (dev, size *4 ,GFP_KERNEL ); -if (!irq_memory) { -dev_err (dev,"Failed to allocate memory for irq masks.\n" ); + retval =rmi_probe_interrupts (data); +if (retval) goto err; - } - - data->irq_status = irq_memory + size *0 ; - data->fn_irq_bits = irq_memory + size *1 ; - data->current_irq_mask = irq_memory + size *2 ; - data->new_irq_mask = irq_memory + size *3 ;if (rmi_dev->xport->input) {/*
@@ -961,36 +1014,16 @@ static int rmi_driver_probe(struct device *dev)dev_err (dev,"%s: Failed to allocate input device.\n" , __func__); retval = -ENOMEM ; - goto err_destroy_functions; + goto err; }rmi_driver_set_input_params (rmi_dev, data->input); data->input->phys =devm_kasprintf (dev,GFP_KERNEL ,"%s/input0" ,dev_name (dev)); } - irq_count =0 ; -rmi_dbg (RMI_DEBUG_CORE , dev,"Creating functions." ); - retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_create_function); -if (retval <0 ) { -dev_err (dev,"Function creation failed with code %d.\n" , - retval); - goto err_destroy_functions; - } - -if (!data->f01_container) { -dev_err (dev,"Missing F01 container!\n" ); - retval = -EINVAL ; - goto err_destroy_functions; - } - - retval =rmi_read_block (rmi_dev, - data->f01_container->fd.control_base_addr +1 , - data->current_irq_mask, data->num_of_irq_regs); -if (retval <0 ) { -dev_err (dev,"%s: Failed to read current IRQ mask.\n" , - __func__); - goto err_destroy_functions; - } + retval =rmi_init_functions (data); +if (retval) + goto err;if (data->input) {rmi_driver_set_input_name (rmi_dev, data->input);
Signature · 1 line
2.7.4
Re: [PATCH v5 1/7] Input: synaptics-rmi4 - factor out functions from probe
Quoted 2 lines · Nick Dyer
Signed-off-by Nick Dyer <[email protected]>Signed-off-by Benjamin Tissoires <[email protected]>
Applied, thank you.
Quoted 193 lines
--- drivers/input/rmi4/rmi_driver.c | 139 +++++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 53 deletions(-)drivers/input/rmi4/rmi_driver.c +86
-53@@ -38,6 +38,8 @@ static void rmi_free_function_list(struct rmi_device *rmi_dev)struct rmi_function *fn, *tmp;struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev); +rmi_dbg (RMI_DEBUG_CORE , &rmi_dev->dev,"Freeing function list\n" ); + data->f01_container =NULL ;/* Doing it in the reverse order so F01 will be removed last */ @@ -842,15 +844,90 @@ static inline int rmi_driver_of_probe(struct device *dev, }#endif +static int rmi_probe_interrupts (struct rmi_driver_data *data) +{ +struct rmi_device *rmi_dev = data->rmi_dev; +struct device *dev = &rmi_dev->dev; +int irq_count; +size_t size; +void *irq_memory; +int retval; + +/* +* We need to count the IRQs and allocate their storage before scanning +* the PDT and creating the function entries, because adding a new +* function can trigger events that result in the IRQ related storage +* being accessed. +*/ +rmi_dbg (RMI_DEBUG_CORE , dev,"%s: Counting IRQs.\n" , __func__); + irq_count =0 ; + retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_count_irqs); +if (retval <0 ) { +dev_err (dev,"IRQ counting failed with code %d.\n" , retval); +return retval; + } + data->irq_count = irq_count; + data->num_of_irq_regs = (data->irq_count +7 ) /8 ; + + size =BITS_TO_LONGS (data->irq_count) *sizeof (unsigned long ); + irq_memory =devm_kzalloc (dev, size *4 ,GFP_KERNEL ); +if (!irq_memory) { +dev_err (dev,"Failed to allocate memory for irq masks.\n" ); +return retval; + } + + data->irq_status = irq_memory + size *0 ; + data->fn_irq_bits = irq_memory + size *1 ; + data->current_irq_mask = irq_memory + size *2 ; + data->new_irq_mask = irq_memory + size *3 ; + +return retval; +} + +static int rmi_init_functions (struct rmi_driver_data *data) +{ +struct rmi_device *rmi_dev = data->rmi_dev; +struct device *dev = &rmi_dev->dev; +int irq_count; +int retval; + + irq_count =0 ; +rmi_dbg (RMI_DEBUG_CORE , dev,"%s: Creating functions.\n" , __func__); + retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_create_function); +if (retval <0 ) { +dev_err (dev,"Function creation failed with code %d.\n" , + retval); + goto err_destroy_functions; + } + +if (!data->f01_container) { +dev_err (dev,"Missing F01 container!\n" ); + retval = -EINVAL ; + goto err_destroy_functions; + } + + retval =rmi_read_block (rmi_dev, + data->f01_container->fd.control_base_addr +1 , + data->current_irq_mask, data->num_of_irq_regs); +if (retval <0 ) { +dev_err (dev,"%s: Failed to read current IRQ mask.\n" , + __func__); + goto err_destroy_functions; + } + +return 0 ; + +err_destroy_functions: +rmi_free_function_list (rmi_dev); +return retval; +} +static int rmi_driver_probe (struct device *dev) {struct rmi_driver *rmi_driver;struct rmi_driver_data *data;struct rmi_device_platform_data *pdata;struct rmi_device *rmi_dev; -size_t size; -void *irq_memory; -int irq_count;int retval; rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Starting probe.\n",@@ -916,35 +993,11 @@ static int rmi_driver_probe(struct device *dev) PDT_PROPERTIES_LOCATION, retval); } -/* -* We need to count the IRQs and allocate their storage before scanning -* the PDT and creating the function entries, because adding a new -* function can trigger events that result in the IRQ related storage -* being accessed. -*/ -rmi_dbg (RMI_DEBUG_CORE , dev,"Counting IRQs.\n" ); - irq_count =0 ; - retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_count_irqs); -if (retval <0 ) { -dev_err (dev,"IRQ counting failed with code %d.\n" , retval); - goto err; - } - data->irq_count = irq_count; - data->num_of_irq_regs = (data->irq_count +7 ) /8 ; -mutex_init (&data->irq_mutex); - size =BITS_TO_LONGS (data->irq_count) *sizeof (unsigned long ); - irq_memory =devm_kzalloc (dev, size *4 ,GFP_KERNEL ); -if (!irq_memory) { -dev_err (dev,"Failed to allocate memory for irq masks.\n" ); + retval =rmi_probe_interrupts (data); +if (retval) goto err; - } - - data->irq_status = irq_memory + size *0 ; - data->fn_irq_bits = irq_memory + size *1 ; - data->current_irq_mask = irq_memory + size *2 ; - data->new_irq_mask = irq_memory + size *3 ;if (rmi_dev->xport->input) {/* @@ -961,36 +1014,16 @@ static int rmi_driver_probe(struct device *dev)dev_err (dev,"%s: Failed to allocate input device.\n" , __func__); retval = -ENOMEM ; - goto err_destroy_functions; + goto err; }rmi_driver_set_input_params (rmi_dev, data->input); data->input->phys =devm_kasprintf (dev,GFP_KERNEL ,"%s/input0" ,dev_name (dev)); } - irq_count =0 ; -rmi_dbg (RMI_DEBUG_CORE , dev,"Creating functions." ); - retval =rmi_scan_pdt (rmi_dev, &irq_count, rmi_create_function); -if (retval <0 ) { -dev_err (dev,"Function creation failed with code %d.\n" , - retval); - goto err_destroy_functions; - } - -if (!data->f01_container) { -dev_err (dev,"Missing F01 container!\n" ); - retval = -EINVAL ; - goto err_destroy_functions; - } - - retval =rmi_read_block (rmi_dev, - data->f01_container->fd.control_base_addr +1 , - data->current_irq_mask, data->num_of_irq_regs); -if (retval <0 ) { -dev_err (dev,"%s: Failed to read current IRQ mask.\n" , - __func__); - goto err_destroy_functions; - } + retval =rmi_init_functions (data); +if (retval) + goto err;if (data->input) {rmi_driver_set_input_name (rmi_dev, data->input);Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
PATCH v5 2/7 Input: synaptics-rmi4 - add a couple of debug lines
In reply to Nick Dyer--- drivers/input/rmi4/rmi_bus.c | 3 +++ drivers/input/rmi4/rmi_driver.c | 1 + 2 files changed, 4 insertions(+)
drivers/input/rmi4/rmi_bus.c +3 -0
@@ -230,6 +230,9 @@ int rmi_register_function(struct rmi_function *fn)void rmi_unregister_function (struct rmi_function *fn) { +rmi_dbg (RMI_DEBUG_CORE , &fn->dev,"Unregistering F%02X.\n" , + fn->fd.function_number); +device_del (&fn->dev);of_node_put (fn->dev.of_node);put_device (&fn->dev);
drivers/input/rmi4/rmi_driver.c +1 -0
@@ -722,6 +722,7 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev,return RMI_SCAN_DONE ; } +rmi_dbg (RMI_DEBUG_CORE , &rmi_dev->dev,"Sending reset\n" ); error =rmi_write_block (rmi_dev, cmd_addr, &cmd_buf,1 );if (error) { dev_err(&rmi_dev->dev,
Signature · 1 line
2.7.4
Re: [PATCH v5 2/7] Input: synaptics-rmi4 - add a couple of debug lines
Quoted 1 line · Nick Dyer
Signed-off-by Nick Dyer <[email protected]>
Applied, thank you.
Quoted 34 lines
--- drivers/input/rmi4/rmi_bus.c | 3 +++ drivers/input/rmi4/rmi_driver.c | 1 + 2 files changed, 4 insertions(+)drivers/input/rmi4/rmi_bus.c +3
-0@@ -230,6 +230,9 @@ int rmi_register_function(struct rmi_function *fn)void rmi_unregister_function (struct rmi_function *fn) { +rmi_dbg (RMI_DEBUG_CORE , &fn->dev,"Unregistering F%02X.\n" , + fn->fd.function_number); +device_del (&fn->dev);of_node_put (fn->dev.of_node);put_device (&fn->dev);drivers/input/rmi4/rmi_driver.c +1
-0@@ -722,6 +722,7 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev,return RMI_SCAN_DONE ; } +rmi_dbg (RMI_DEBUG_CORE , &rmi_dev->dev,"Sending reset\n" ); error =rmi_write_block (rmi_dev, cmd_addr, &cmd_buf,1 );if (error) { dev_err(&rmi_dev->dev,Signature · 1 line
2.7.4
Signature · 1 line
Dmitry
PATCH v5 3/7 Input: synaptics-rmi4 - add support for F34 device reflash
In reply to Nick DyerAdd support for updating firmware, triggered by a sysfs attribute.
This patch has been tested on Synaptics S7300.
--- drivers/input/rmi4/Kconfig | 11 + drivers/input/rmi4/Makefile | 1 + drivers/input/rmi4/rmi_bus.c | 3 + drivers/input/rmi4/rmi_driver.c | 89 ++++++-- drivers/input/rmi4/rmi_driver.h | 24 ++ drivers/input/rmi4/rmi_f01.c | 6 + drivers/input/rmi4/rmi_f34.c | 494 ++++++++++++++++++++++++++++++++++++++++ drivers/input/rmi4/rmi_f34.h | 68 ++++++ include/linux/rmi.h | 1 + 9 files changed, 673 insertions(+), 24 deletions(-) create mode 100644 drivers/input/rmi4/rmi_f34.c create mode 100644 drivers/input/rmi4/rmi_f34.h
drivers/input/rmi4/Kconfig +11 -0
@@ -62,6 +62,17 @@ config RMI4_F30 Function 30 provides GPIO and LED support for RMI4 devices. This includes support for buttons on TouchPads and ClickPads. +config RMI4_F34 + bool "RMI4 Function 34 (Device reflash)" + depends on RMI4_CORE + select FW_LOADER + help + Say Y here if you want to add support for RMI4 function 34. + + Function 34 provides support for upgrading the firmware on the RMI4 + device via the firmware loader interface. This is triggered using a + sysfs attribute. + config RMI4_F54 bool "RMI4 Function 54 (Analog diagnostics)" depends on RMI4_CORE
drivers/input/rmi4/Makefile +1 -0
@@ -7,6 +7,7 @@ rmi_core-$(CONFIG_RMI4_2D_SENSOR) += rmi_2d_sensor.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_F54) += rmi_f54.o # Transports
drivers/input/rmi4/rmi_bus.c +3 -0
@@ -314,6 +314,9 @@ static struct rmi_function_handler *fn_handlers[] = {#ifdef CONFIG_RMI4_F30 &rmi_f30_handler,#endif +#ifdef CONFIG_RMI4_F34 + &rmi_f34_handler, +#endif #ifdef CONFIG_RMI4_F54 &rmi_f54_handler,#endif
drivers/input/rmi4/rmi_driver.c +65 -24
255 lines not on this page · raw message
drivers/input/rmi4/rmi_driver.h +24 -0
@@ -95,12 +95,36 @@ bool rmi_register_desc_has_subpacket(const struct rmi_register_desc_item *item,bool rmi_is_physical_driver (struct device_driver *);int rmi_register_physical_driver (void );void rmi_unregister_physical_driver (void ); +void rmi_free_function_list (struct rmi_device *rmi_dev); +int rmi_enable_sensor (struct rmi_device *rmi_dev); +int rmi_scan_pdt (struct rmi_device *rmi_dev,void *ctx, +int (*callback)(struct rmi_device *rmi_dev,void *ctx, +const struct pdt_entry *entry)); +int rmi_probe_interrupts (struct rmi_driver_data *data); +int rmi_init_functions (struct rmi_driver_data *data); +int rmi_initial_reset (struct rmi_device *rmi_dev,void *ctx, +const struct pdt_entry *pdt);char *rmi_f01_get_product_ID (struct rmi_function *fn); +#ifdef CONFIG_RMI4_F34 +int rmi_f34_create_sysfs (struct rmi_device *rmi_dev); +void rmi_f34_remove_sysfs (struct rmi_device *rmi_dev); +#else +static inline int rmi_f34_create_sysfs (struct rmi_device *rmi_dev) +{ +return 0 ; +} + +static inline void rmi_f34_remove_sysfs (struct rmi_device *rmi_dev) +{ +} +#endif /* CONFIG_RMI_F34 */ +extern struct rmi_function_handler rmi_f01_handler;extern struct rmi_function_handler rmi_f11_handler;extern struct rmi_function_handler rmi_f12_handler;extern struct rmi_function_handler rmi_f30_handler; +extern struct rmi_function_handler rmi_f34_handler;extern struct rmi_function_handler rmi_f54_handler;#endif
drivers/input/rmi4/rmi_f01.c +6 -0
@@ -62,6 +62,8 @@ struct f01_basic_properties {#define RMI_F01_STATUS_CODE (status) ((status) & 0x0f)/* The device has lost its configuration for some reason. */ #define RMI_F01_STATUS_UNCONFIGURED (status) (!!((status) & 0x80)) +/* The device is in bootloader mode */ +#define RMI_F01_STATUS_BOOTLOADER (status) ((status) & 0x40)/* Control register bits */
@@ -593,6 +595,10 @@ static int rmi_f01_attention(struct rmi_function *fn,return error; } +if (RMI_F01_STATUS_BOOTLOADER (device_status)) +dev_warn (&fn->dev, +"Device in bootloader mode, please update firmware\n" ); +if (RMI_F01_STATUS_UNCONFIGURED (device_status)) {dev_warn (&fn->dev,"Device reset detected.\n" ); error = rmi_dev->driver->reset_handler (rmi_dev);
drivers/input/rmi4/rmi_f34.c new file +494 -0
494 lines not on this page · raw message
drivers/input/rmi4/rmi_f34.h new file +68 -0
68 lines not on this page · raw message
include/linux/rmi.h +1 -0
@@ -330,6 +330,7 @@ struct rmi_driver_data {struct rmi_device *rmi_dev;struct rmi_function *f01_container; +struct rmi_function *f34_container;bool f01_bootloader_mode;u32 attn_count;
Signature · 1 line
2.7.4
Dmitry Torokhov
maintainerRe: [PATCH v5 3/7] Input: synaptics-rmi4 - add support for F34 device reflash
Quoted 79 lines · Nick Dyer
Add support for updating firmware, triggered by a sysfs attribute.
This patch has been tested on Synaptics S7300.
Signed-off-by Nick Dyer <[email protected]>Tested-by Chris Healy <[email protected]>--- drivers/input/rmi4/Kconfig | 11 + drivers/input/rmi4/Makefile | 1 + drivers/input/rmi4/rmi_bus.c | 3 + drivers/input/rmi4/rmi_driver.c | 89 ++++++-- drivers/input/rmi4/rmi_driver.h | 24 ++ drivers/input/rmi4/rmi_f01.c | 6 + drivers/input/rmi4/rmi_f34.c | 494 ++++++++++++++++++++++++++++++++++++++++ drivers/input/rmi4/rmi_f34.h | 68 ++++++ include/linux/rmi.h | 1 + 9 files changed, 673 insertions(+), 24 deletions(-) create mode 100644 drivers/input/rmi4/rmi_f34.c create mode 100644 drivers/input/rmi4/rmi_f34.hdrivers/input/rmi4/Kconfig +11
-0@@ -62,6 +62,17 @@ config RMI4_F30 Function 30 provides GPIO and LED support for RMI4 devices. This includes support for buttons on TouchPads and ClickPads. +config RMI4_F34 + bool "RMI4 Function 34 (Device reflash)" + depends on RMI4_CORE + select FW_LOADER + help + Say Y here if you want to add support for RMI4 function 34. + + Function 34 provides support for upgrading the firmware on the RMI4 + device via the firmware loader interface. This is triggered using a + sysfs attribute. + config RMI4_F54 bool "RMI4 Function 54 (Analog diagnostics)" depends on RMI4_COREdrivers/input/rmi4/Makefile +1
-0@@ -7,6 +7,7 @@ rmi_core-$(CONFIG_RMI4_2D_SENSOR) += rmi_2d_sensor.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_F54) += rmi_f54.o # Transportsdrivers/input/rmi4/rmi_bus.c +3
-0@@ -314,6 +314,9 @@ static struct rmi_function_handler *fn_handlers[] = {#ifdef CONFIG_RMI4_F30 &rmi_f30_handler,#endif +#ifdef CONFIG_RMI4_F34 + &rmi_f34_handler, +#endif #ifdef CONFIG_RMI4_F54 &rmi_f54_handler,#endif drivers/input/rmi4/rmi_driver.c +1
-1@@ -33,14 +33,21 @@#define RMI_DEVICE_RESET_CMD 0x01#define DEFAULT_RESET_DELAY_MS 100 -static void rmi_free_function_list (struct rmi_device *rmi_dev) +void rmi_free_function_list (struct rmi_device *rmi_dev) {
drivers/input/rmi4/rmi_driver.c line 47
Quoted 10 lines
drivers/input/rmi4/rmi_driver.c +4
-0struct rmi_function *fn, *tmp;struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev);rmi_dbg (RMI_DEBUG_CORE , &rmi_dev->dev,"Freeing function list\n" ); +mutex_lock (&data->irq_mutex); + data->f01_container =NULL ; + data->f34_container =NULL ; + data->irq_status =NULL ;
So you simply "lose" old irq_status memory and rely on devm clear it later? If anything it requires a comment, but I would like we did not leave stray memory.
Thanks.
Signature · 1 line
Dmitry
PATCH v5 4/7 Input: synaptics-rmi4 - add support for F34 V7 bootloader
In reply to Nick DyerPort firmware update code from Samsung Galaxy S7 driver into mainline framework.
This patch has been tested on Synaptics S7813.
--- drivers/input/rmi4/Makefile | 2 +- drivers/input/rmi4/rmi_driver.c | 56 +- drivers/input/rmi4/rmi_f34.c | 53 +- drivers/input/rmi4/rmi_f34.h | 374 +++++++++- drivers/input/rmi4/rmi_f34v7.c | 1459 +++++++++++++++++++++++++++++++++++++++ include/linux/rmi.h | 2 +- 6 files changed, 1896 insertions(+), 50 deletions(-) create mode 100644 drivers/input/rmi4/rmi_f34v7.c
drivers/input/rmi4/Makefile +1 -1
@@ -7,7 +7,7 @@ rmi_core-$(CONFIG_RMI4_2D_SENSOR) += rmi_2d_sensor.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 # Transports
drivers/input/rmi4/rmi_driver.c +33 -23
94 lines not on this page · raw message
drivers/input/rmi4/rmi_f34.c +30 -23
106 lines not on this page · raw message
drivers/input/rmi4/rmi_f34.h +372 -2
391 lines not on this page · raw message
drivers/input/rmi4/rmi_f34v7.c new file +1459 -0
1,459 lines not on this page · raw message
include/linux/rmi.h +1 -1
@@ -331,7 +331,7 @@ struct rmi_driver_data {struct rmi_function *f01_container;struct rmi_function *f34_container; -bool f01_bootloader_mode; +bool bootloader_mode;u32 attn_count;int num_of_irq_regs;
Signature · 1 line
2.7.4
PATCH v5 5/7 Input: synaptics-rmi4 - add sysfs attribute update_fw_status
In reply to Nick DyerThe status is the percentage complete, or once complete, zero for success or a negative return code.
--- drivers/input/rmi4/rmi_f34.c | 34 ++++++++++++++++++++++++++++++++++ drivers/input/rmi4/rmi_f34.h | 4 ++++ drivers/input/rmi4/rmi_f34v7.c | 14 ++++++++++++++ 3 files changed, 52 insertions(+)
drivers/input/rmi4/rmi_f34.c +34 -0
@@ -157,6 +157,9 @@ static int rmi_f34_write_blocks(struct f34_data *f34, const void *data, i + 1, block_count); data += f34->v5.block_size; + f34->update_progress += f34->v5.block_size; + f34->update_status = (f34->update_progress *100 ) / + f34->update_size; }return 0 ;
@@ -186,6 +189,8 @@ static int rmi_f34_flash_firmware(struct f34_data *f34,struct rmi_function *fn = f34->fn;int ret; + f34->update_progress =0 ; + f34->update_size = syn_fw->image_size + syn_fw->config_size;if (syn_fw->image_size) {dev_info (&fn->dev,"Erasing firmware...\n" ); ret = rmi_f34_command(f34, F34_ERASE_ALL,
@@ -277,12 +282,24 @@ int rmi_f34_update_firmware(struct f34_data *f34, const struct firmware *fw) ret =rmi_f34_flash_firmware (f34, syn_fw); + f34->update_status = ret;mutex_unlock (&f34->v5.flash_mutex); out:return ret; } +int rmi_f34_status (struct rmi_function *fn) +{ +struct f34_data *f34 =dev_get_drvdata (&fn->dev); + +/* +* The status is the percentage complete, or once complete, +* zero for success or a negative return code. +*/ +return f34->update_status; +} +static int rmi_firmware_update (struct rmi_driver_data *data,const struct firmware *fw) {
@@ -401,8 +418,25 @@ static ssize_t rmi_driver_update_fw_store(struct device *dev, static DEVICE_ATTR(update_fw, 0200, NULL, rmi_driver_update_fw_store); +static ssize_t rmi_driver_update_fw_status_show (struct device *dev, +struct device_attribute *dattr, +char *buf) +{ +struct rmi_driver_data *data =dev_get_drvdata (dev); +int update_status =0 ; + +if (data->f34_container) + update_status =rmi_f34_status (data->f34_container); + +return scnprintf (buf,PAGE_SIZE ,"%d\n" , update_status); +} + +static DEVICE_ATTR(update_fw_status, 0444, + rmi_driver_update_fw_status_show, NULL); +static struct attribute *rmi_firmware_attrs[] = { &dev_attr_update_fw.attr, + &dev_attr_update_fw_status.attr,NULL };
drivers/input/rmi4/rmi_f34.h +4 -0
@@ -425,6 +425,10 @@ struct f34_data {unsigned char bootloader_id[5 ];unsigned char configuration_id[SYNAPTICS_RMI4_CONFIG_ID_SIZE *2 +1 ]; +int update_status; +int update_progress; +int update_size; +union {struct f34v5_data v5;struct f34v7_data v7;
drivers/input/rmi4/rmi_f34v7.c +14 -0
@@ -926,6 +926,11 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34, block_ptr += (transfer * f34->v7.block_size); remaining -= transfer; + +if (command == v7_CMD_WRITE_FW) + f34->update_status =80 -70 *remaining/block_cnt; +else if (command == v7_CMD_WRITE_CONFIG) + f34->update_status =90 -10 *remaining/block_cnt; }while (remaining);return 0 ;
@@ -1281,6 +1286,8 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw)if (ret <0 ) goto fail; + f34->update_status =5 ; +if (!f34->v7.new_partition_table) { ret =rmi_f34v7_check_ui_firmware_size (f34);if (ret <0 )
@@ -1320,6 +1327,7 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw) __func__); } + f34->update_status =10 ;dev_info (&f34->fn->dev,"Writing firmware (%d bytes)...\n" , f34->v7.img.ui_firmware.size);
@@ -1344,6 +1352,8 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw) goto fail; } + f34->update_status =95 ; +if (f34->v7.new_partition_table) {if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) {dev_info (&f34->fn->dev,"Writing guest code...\n" );
@@ -1354,7 +1364,11 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw) } } + f34->update_status =0 ; +return 0 ; + fail: + f34->update_status = ret;return ret; }
Signature · 1 line
2.7.4
PATCH v5 6/7 Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
In reply to Nick Dyer--- drivers/input/rmi4/rmi_driver.c | 2 +- drivers/input/rmi4/rmi_driver.h | 5 +- drivers/input/rmi4/rmi_f01.c | 23 ++++++++- drivers/input/rmi4/rmi_f34.c | 110 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 3 deletions(-)
drivers/input/rmi4/rmi_driver.c +1 -1
@@ -307,7 +307,7 @@ static void rmi_driver_set_input_name(struct rmi_device *rmi_dev, struct input_dev *input) {struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev); -char *device_name =rmi_f01_get_product_ID (data->f01_container); +const char *device_name =rmi_f01_get_product_ID (data->f01_container);char *name; name = devm_kasprintf(&rmi_dev->dev, GFP_KERNEL,
drivers/input/rmi4/rmi_driver.h +4 -1
@@ -105,7 +105,10 @@ int rmi_init_functions(struct rmi_driver_data *data);int rmi_initial_reset (struct rmi_device *rmi_dev,void *ctx,const struct pdt_entry *pdt); -char *rmi_f01_get_product_ID (struct rmi_function *fn); +const char *rmi_f01_get_product_ID (struct rmi_function *fn); +u8 rmi_f01_get_manufacturer_ID (struct rmi_function *fn); +const char *rmi_f01_get_date_of_manufacture (struct rmi_function *fn); +u32 rmi_f01_get_firmware_ID (struct rmi_function *fn);#ifdef CONFIG_RMI4_F34 int rmi_f34_create_sysfs (struct rmi_device *rmi_dev);
drivers/input/rmi4/rmi_f01.c +22 -1
@@ -241,13 +241,34 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev,return 0 ; } -char *rmi_f01_get_product_ID (struct rmi_function *fn) +const char *rmi_f01_get_product_ID (struct rmi_function *fn) {struct f01_data *f01 =dev_get_drvdata (&fn->dev);return f01->properties.product_id; } +u8 rmi_f01_get_manufacturer_ID (struct rmi_function *fn) +{ +struct f01_data *f01 =dev_get_drvdata (&fn->dev); + +return f01->properties.manufacturer_id; +} + +const char *rmi_f01_get_date_of_manufacture (struct rmi_function *fn) +{ +struct f01_data *f01 =dev_get_drvdata (&fn->dev); + +return f01->properties.dom; +} + +u32 rmi_f01_get_firmware_ID (struct rmi_function *fn) +{ +struct f01_data *f01 =dev_get_drvdata (&fn->dev); + +return f01->properties.firmware_id; +} +#ifdef CONFIG_OF static int rmi_f01_of_probe (struct device *dev,struct rmi_device_platform_data *pdata)
drivers/input/rmi4/rmi_f34.c +110 -0
122 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 7/7 Input: synaptics-rmi4 - add package_id sysfs attribute
In reply to Nick Dyer--- drivers/input/rmi4/rmi_driver.h | 1 + drivers/input/rmi4/rmi_f01.c | 24 +++++++++++++++++++++++- drivers/input/rmi4/rmi_f34.c | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-)
drivers/input/rmi4/rmi_driver.h +1 -0
@@ -109,6 +109,7 @@ const char *rmi_f01_get_product_ID(struct rmi_function *fn);u8 rmi_f01_get_manufacturer_ID (struct rmi_function *fn);const char *rmi_f01_get_date_of_manufacture (struct rmi_function *fn);u32 rmi_f01_get_firmware_ID (struct rmi_function *fn); +u32 rmi_f01_get_package_ID (struct rmi_function *fn);#ifdef CONFIG_RMI4_F34 int rmi_f34_create_sysfs (struct rmi_device *rmi_dev);
drivers/input/rmi4/rmi_f01.c +23 -1
@@ -54,6 +54,7 @@ struct f01_basic_properties {u8 product_id[RMI_PRODUCT_ID_LENGTH +1 ];u16 productinfo;u32 firmware_id; +u32 package_id; };/* F01 device status bits */
@@ -220,8 +221,22 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev, has_build_id_query = !!(queries[0 ] &BIT (1 )); } -if (has_package_id_query) +if (has_package_id_query) { + ret =rmi_read_block (rmi_dev, prod_info_addr, + queries,4 ); +if (ret) { +dev_err (&rmi_dev->dev, +"Failed to read package info: %d\n" , + ret); +return ret; + } + + props->package_id = queries[3 ] <<24 | + queries[2 ] <<16 | + queries[1 ] <<8 | + queries[0 ]; prod_info_addr++; + }if (has_build_id_query) { ret = rmi_read_block(rmi_dev, prod_info_addr, queries,
@@ -269,6 +284,13 @@ u32 rmi_f01_get_firmware_ID(struct rmi_function *fn)return f01->properties.firmware_id; } +u32 rmi_f01_get_package_ID (struct rmi_function *fn) +{ +struct f01_data *f01 =dev_get_drvdata (&fn->dev); + +return f01->properties.package_id; +} +#ifdef CONFIG_OF static int rmi_f01_of_probe (struct device *dev,struct rmi_device_platform_data *pdata)
drivers/input/rmi4/rmi_f34.c +16 -0
@@ -485,6 +485,21 @@ static ssize_t rmi_driver_configuration_id_show(struct device *dev, static DEVICE_ATTR(configuration_id, 0444, rmi_driver_configuration_id_show, NULL); +static ssize_t rmi_driver_package_id_show (struct device *dev, +struct device_attribute *dattr, +char *buf) +{ +struct rmi_driver_data *data =dev_get_drvdata (dev); +struct rmi_function *fn = data->f01_container; + +u32 package_id =rmi_f01_get_package_ID (fn); + +return scnprintf (buf,PAGE_SIZE ,"%04x.%04x\n" , + package_id &0xffff , (package_id >>16 ) &0xffff ); +} + +static DEVICE_ATTR(package_id, 0444, rmi_driver_package_id_show, NULL); +static int rmi_firmware_update (struct rmi_driver_data *data,const struct firmware *fw);
@@ -544,6 +559,7 @@ static struct attribute *rmi_firmware_attrs[] = { &dev_attr_manufacturer_id.attr, &dev_attr_date_of_manufacture.attr, &dev_attr_product_id.attr, + &dev_attr_package_id.attr, &dev_attr_firmware_id.attr, &dev_attr_update_fw.attr, &dev_attr_update_fw_status.attr,
Signature · 1 line
2.7.4