* [PATCH v3 0/2] Synaptics RMI4 sysfs attributes
@ 2017-01-28 19:06 Nick Dyer
2017-01-28 19:06 ` [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Nick Dyer @ 2017-01-28 19:06 UTC (permalink / raw)
To: Chris Healy
Cc: Dmitry Torokhov, Andrew Duggan, Benjamin Tissoires, linux-input
Hi Dmitry-
Here are a couple of patches to add sysfs attributes useful in implementing a
firmware update system on Synaptics RMI4.
Changes in v3:
- Improved commit message and added Acks/Testeds.
- Stopped reporting 0 on success at Benjamin Tissoires' suggestion.
Changes in v2:
- Fixed bug in handling of update status in F34v7
regards
Nick Dyer
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status
2017-01-28 19:06 [PATCH v3 0/2] Synaptics RMI4 sysfs attributes Nick Dyer
@ 2017-01-28 19:06 ` Nick Dyer
2017-01-31 9:02 ` Dmitry Torokhov
2017-01-28 19:06 ` [PATCH v3 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
2017-01-30 10:08 ` [PATCH v3 0/2] Synaptics RMI4 sysfs attributes Benjamin Tissoires
2 siblings, 1 reply; 9+ messages in thread
From: Nick Dyer @ 2017-01-28 19:06 UTC (permalink / raw)
To: Chris Healy
Cc: Dmitry Torokhov, Andrew Duggan, Benjamin Tissoires, linux-input,
Nick Dyer
The attribute returns the percentage complete. If the firmware update fails, it
reports a negative error code.
Signed-off-by: Nick Dyer <nick@shmanahar.org>
Tested-by: Chris Healy <cphealy@gmail.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/input/rmi4/rmi_f34.c | 40 +++++++++++++++++++++++++++++++++++++++-
drivers/input/rmi4/rmi_f34.h | 4 ++++
drivers/input/rmi4/rmi_f34v7.c | 11 +++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index c3285ce..048e593 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -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,
@@ -283,6 +288,17 @@ 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)
{
@@ -346,7 +362,12 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
else
ret = rmi_f34_update_firmware(f34, fw);
- dev_info(&f34->fn->dev, "Firmware update complete, status:%d\n", ret);
+ if (ret) {
+ f34->update_status = ret;
+ dev_err(&f34->fn->dev, "Firmware update failed, status:%d\n", ret);
+ } else {
+ dev_info(&f34->fn->dev, "Firmware update complete\n");
+ }
rmi_disable_irq(rmi_dev, false);
@@ -414,8 +435,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
};
diff --git a/drivers/input/rmi4/rmi_f34.h b/drivers/input/rmi4/rmi_f34.h
index 2c21056..43a9134 100644
--- a/drivers/input/rmi4/rmi_f34.h
+++ b/drivers/input/rmi4/rmi_f34.h
@@ -301,6 +301,10 @@ struct f34_data {
unsigned char bootloader_id[5];
unsigned char configuration_id[CONFIG_ID_SIZE*2 + 1];
+ int update_status;
+ int update_progress;
+ int update_size;
+
union {
struct f34v5_data v5;
struct f34v7_data v7;
diff --git a/drivers/input/rmi4/rmi_f34v7.c b/drivers/input/rmi4/rmi_f34v7.c
index ca31f95..56c6c39 100644
--- a/drivers/input/rmi4/rmi_f34v7.c
+++ b/drivers/input/rmi4/rmi_f34v7.c
@@ -588,6 +588,7 @@ static int rmi_f34v7_check_ui_firmware_size(struct f34_data *f34)
u16 block_count;
block_count = f34->v7.img.ui_firmware.size / f34->v7.block_size;
+ f34->update_size += block_count;
if (block_count != f34->v7.blkcount.ui_firmware) {
dev_err(&f34->fn->dev,
@@ -604,6 +605,7 @@ static int rmi_f34v7_check_ui_config_size(struct f34_data *f34)
u16 block_count;
block_count = f34->v7.img.ui_config.size / f34->v7.block_size;
+ f34->update_size += block_count;
if (block_count != f34->v7.blkcount.ui_config) {
dev_err(&f34->fn->dev, "UI config size mismatch\n");
@@ -618,6 +620,7 @@ static int rmi_f34v7_check_dp_config_size(struct f34_data *f34)
u16 block_count;
block_count = f34->v7.img.dp_config.size / f34->v7.block_size;
+ f34->update_size += block_count;
if (block_count != f34->v7.blkcount.dp_config) {
dev_err(&f34->fn->dev, "Display config size mismatch\n");
@@ -632,6 +635,8 @@ static int rmi_f34v7_check_guest_code_size(struct f34_data *f34)
u16 block_count;
block_count = f34->v7.img.guest_code.size / f34->v7.block_size;
+ f34->update_size += block_count;
+
if (block_count != f34->v7.blkcount.guest_code) {
dev_err(&f34->fn->dev, "Guest code size mismatch\n");
return -EINVAL;
@@ -645,6 +650,7 @@ static int rmi_f34v7_check_bl_config_size(struct f34_data *f34)
u16 block_count;
block_count = f34->v7.img.bl_config.size / f34->v7.block_size;
+ f34->update_size += block_count;
if (block_count != f34->v7.blkcount.bl_config) {
dev_err(&f34->fn->dev, "Bootloader config size mismatch\n");
@@ -881,6 +887,9 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
block_ptr += (transfer * f34->v7.block_size);
remaining -= transfer;
+ f34->update_progress += transfer;
+ f34->update_status = (f34->update_progress * 100) /
+ f34->update_size;
} while (remaining);
return 0;
@@ -1191,6 +1200,8 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw)
rmi_f34v7_read_queries_bl_version(f34);
f34->v7.image = fw->data;
+ f34->update_progress = 0;
+ f34->update_size = 0;
ret = rmi_f34v7_parse_image_info(f34);
if (ret < 0)
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2017-01-28 19:06 [PATCH v3 0/2] Synaptics RMI4 sysfs attributes Nick Dyer
2017-01-28 19:06 ` [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
@ 2017-01-28 19:06 ` Nick Dyer
2017-01-31 9:02 ` Dmitry Torokhov
2017-01-30 10:08 ` [PATCH v3 0/2] Synaptics RMI4 sysfs attributes Benjamin Tissoires
2 siblings, 1 reply; 9+ messages in thread
From: Nick Dyer @ 2017-01-28 19:06 UTC (permalink / raw)
To: Chris Healy
Cc: Dmitry Torokhov, Andrew Duggan, Benjamin Tissoires, linux-input,
Nick Dyer
These attributes provide various bits of information which may be enumerated
under the RMI4 protocol to user space.
This may be useful for displaying the particular version which is in use, or
selecting the correct firmware to flash.
Signed-off-by: Nick Dyer <nick@shmanahar.org>
Tested-by: Chris Healy <cphealy@gmail.com>
---
drivers/input/rmi4/rmi_driver.c | 2 +-
drivers/input/rmi4/rmi_driver.h | 6 +-
drivers/input/rmi4/rmi_f01.c | 45 ++++++++++++++-
drivers/input/rmi4/rmi_f34.c | 123 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 172 insertions(+), 4 deletions(-)
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 30397cc..b398550 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -365,7 +365,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,
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
index 24f8f76..48b3131 100644
--- a/drivers/input/rmi4/rmi_driver.h
+++ b/drivers/input/rmi4/rmi_driver.h
@@ -104,7 +104,11 @@ 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);
+u32 rmi_f01_get_package_ID(struct rmi_function *fn);
#ifdef CONFIG_RMI4_F34
int rmi_f34_create_sysfs(struct rmi_device *rmi_dev);
diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index cae35c6..1b03f4d 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/of.h>
+#include <asm/unaligned.h>
#include "rmi_driver.h"
#define RMI_PRODUCT_ID_LENGTH 10
@@ -55,6 +56,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 */
@@ -221,8 +223,19 @@ 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, sizeof(__le64));
+ if (ret) {
+ dev_err(&rmi_dev->dev,
+ "Failed to read package info: %d\n",
+ ret);
+ return ret;
+ }
+
+ props->package_id = get_unaligned_le64(queries);
prod_info_addr++;
+ }
if (has_build_id_query) {
ret = rmi_read_block(rmi_dev, prod_info_addr, queries,
@@ -242,13 +255,41 @@ 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;
+}
+
+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)
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index 048e593..94fa118 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -398,6 +398,122 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
return ret;
}
+static ssize_t rmi_driver_manufacturer_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;
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ rmi_f01_get_manufacturer_ID(fn));
+}
+
+static DEVICE_ATTR(manufacturer_id, 0444,
+ rmi_driver_manufacturer_id_show, NULL);
+
+static ssize_t rmi_driver_dom_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;
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n",
+ rmi_f01_get_date_of_manufacture(fn));
+}
+
+static DEVICE_ATTR(date_of_manufacture, 0444, rmi_driver_dom_show, NULL);
+
+static ssize_t rmi_driver_product_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;
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n",
+ rmi_f01_get_product_ID(fn));
+}
+
+static DEVICE_ATTR(product_id, 0444,
+ rmi_driver_product_id_show, NULL);
+
+static ssize_t rmi_driver_firmware_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;
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ rmi_f01_get_firmware_ID(fn));
+}
+
+static DEVICE_ATTR(firmware_id, 0444,
+ rmi_driver_firmware_id_show, NULL);
+
+static ssize_t rmi_driver_bootloader_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->f34_container;
+ struct f34_data *f34;
+
+ if (fn) {
+ f34 = dev_get_drvdata(&fn->dev);
+
+ if (f34->bl_version == 5)
+ return scnprintf(buf, PAGE_SIZE, "%c%c\n",
+ f34->bootloader_id[0],
+ f34->bootloader_id[1]);
+ else
+ return scnprintf(buf, PAGE_SIZE, "V%d.%d\n",
+ f34->bootloader_id[1],
+ f34->bootloader_id[0]);
+ }
+
+ return 0;
+}
+
+static DEVICE_ATTR(bootloader_id, 0444,
+ rmi_driver_bootloader_id_show, NULL);
+
+static ssize_t rmi_driver_configuration_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->f34_container;
+ struct f34_data *f34;
+
+ if (fn) {
+ f34 = dev_get_drvdata(&fn->dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", f34->configuration_id);
+ }
+
+ return 0;
+}
+
+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);
@@ -452,6 +568,13 @@ static DEVICE_ATTR(update_fw_status, 0444,
rmi_driver_update_fw_status_show, NULL);
static struct attribute *rmi_firmware_attrs[] = {
+ &dev_attr_bootloader_id.attr,
+ &dev_attr_configuration_id.attr,
+ &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,
NULL
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/2] Synaptics RMI4 sysfs attributes
2017-01-28 19:06 [PATCH v3 0/2] Synaptics RMI4 sysfs attributes Nick Dyer
2017-01-28 19:06 ` [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
2017-01-28 19:06 ` [PATCH v3 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
@ 2017-01-30 10:08 ` Benjamin Tissoires
2 siblings, 0 replies; 9+ messages in thread
From: Benjamin Tissoires @ 2017-01-30 10:08 UTC (permalink / raw)
To: Nick Dyer; +Cc: Chris Healy, Dmitry Torokhov, Andrew Duggan, linux-input
On Jan 28 2017 or thereabouts, Nick Dyer wrote:
> Hi Dmitry-
>
> Here are a couple of patches to add sysfs attributes useful in implementing a
> firmware update system on Synaptics RMI4.
>
> Changes in v3:
> - Improved commit message and added Acks/Testeds.
> - Stopped reporting 0 on success at Benjamin Tissoires' suggestion.
> Changes in v2:
> - Fixed bug in handling of update status in F34v7
>
The series is:
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cheers,
Benjamin
> regards
>
> Nick Dyer
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2017-01-28 19:06 ` [PATCH v3 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
@ 2017-01-31 9:02 ` Dmitry Torokhov
2017-01-31 21:17 ` [PATCH v4] " Nick Dyer
0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2017-01-31 9:02 UTC (permalink / raw)
To: Nick Dyer; +Cc: Chris Healy, Andrew Duggan, Benjamin Tissoires, linux-input
On Sat, Jan 28, 2017 at 07:06:02PM +0000, Nick Dyer wrote:
> These attributes provide various bits of information which may be enumerated
> under the RMI4 protocol to user space.
>
> This may be useful for displaying the particular version which is in use, or
> selecting the correct firmware to flash.
>
> Signed-off-by: Nick Dyer <nick@shmanahar.org>
> Tested-by: Chris Healy <cphealy@gmail.com>
> ---
> drivers/input/rmi4/rmi_driver.c | 2 +-
> drivers/input/rmi4/rmi_driver.h | 6 +-
> drivers/input/rmi4/rmi_f01.c | 45 ++++++++++++++-
> drivers/input/rmi4/rmi_f34.c | 123 ++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 172 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 30397cc..b398550 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -365,7 +365,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,
> diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> index 24f8f76..48b3131 100644
> --- a/drivers/input/rmi4/rmi_driver.h
> +++ b/drivers/input/rmi4/rmi_driver.h
> @@ -104,7 +104,11 @@ 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);
> +u32 rmi_f01_get_package_ID(struct rmi_function *fn);
Why do we plumb this over to F34 instead of creating attributes when F01
is initialized? This data might be interesting to userspace even if F34
is disabled or not available.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status
2017-01-28 19:06 ` [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
@ 2017-01-31 9:02 ` Dmitry Torokhov
2017-01-31 23:43 ` Dmitry Torokhov
0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2017-01-31 9:02 UTC (permalink / raw)
To: Nick Dyer; +Cc: Chris Healy, Andrew Duggan, Benjamin Tissoires, linux-input
On Sat, Jan 28, 2017 at 07:06:01PM +0000, Nick Dyer wrote:
> The attribute returns the percentage complete. If the firmware update fails, it
> reports a negative error code.
>
> Signed-off-by: Nick Dyer <nick@shmanahar.org>
> Tested-by: Chris Healy <cphealy@gmail.com>
> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Applied, thank you.
> ---
> drivers/input/rmi4/rmi_f34.c | 40 +++++++++++++++++++++++++++++++++++++++-
> drivers/input/rmi4/rmi_f34.h | 4 ++++
> drivers/input/rmi4/rmi_f34v7.c | 11 +++++++++++
> 3 files changed, 54 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
> index c3285ce..048e593 100644
> --- a/drivers/input/rmi4/rmi_f34.c
> +++ b/drivers/input/rmi4/rmi_f34.c
> @@ -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,
> @@ -283,6 +288,17 @@ 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)
> {
> @@ -346,7 +362,12 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
> else
> ret = rmi_f34_update_firmware(f34, fw);
>
> - dev_info(&f34->fn->dev, "Firmware update complete, status:%d\n", ret);
> + if (ret) {
> + f34->update_status = ret;
> + dev_err(&f34->fn->dev, "Firmware update failed, status:%d\n", ret);
> + } else {
> + dev_info(&f34->fn->dev, "Firmware update complete\n");
> + }
>
> rmi_disable_irq(rmi_dev, false);
>
> @@ -414,8 +435,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
> };
>
> diff --git a/drivers/input/rmi4/rmi_f34.h b/drivers/input/rmi4/rmi_f34.h
> index 2c21056..43a9134 100644
> --- a/drivers/input/rmi4/rmi_f34.h
> +++ b/drivers/input/rmi4/rmi_f34.h
> @@ -301,6 +301,10 @@ struct f34_data {
> unsigned char bootloader_id[5];
> unsigned char configuration_id[CONFIG_ID_SIZE*2 + 1];
>
> + int update_status;
> + int update_progress;
> + int update_size;
> +
> union {
> struct f34v5_data v5;
> struct f34v7_data v7;
> diff --git a/drivers/input/rmi4/rmi_f34v7.c b/drivers/input/rmi4/rmi_f34v7.c
> index ca31f95..56c6c39 100644
> --- a/drivers/input/rmi4/rmi_f34v7.c
> +++ b/drivers/input/rmi4/rmi_f34v7.c
> @@ -588,6 +588,7 @@ static int rmi_f34v7_check_ui_firmware_size(struct f34_data *f34)
> u16 block_count;
>
> block_count = f34->v7.img.ui_firmware.size / f34->v7.block_size;
> + f34->update_size += block_count;
>
> if (block_count != f34->v7.blkcount.ui_firmware) {
> dev_err(&f34->fn->dev,
> @@ -604,6 +605,7 @@ static int rmi_f34v7_check_ui_config_size(struct f34_data *f34)
> u16 block_count;
>
> block_count = f34->v7.img.ui_config.size / f34->v7.block_size;
> + f34->update_size += block_count;
>
> if (block_count != f34->v7.blkcount.ui_config) {
> dev_err(&f34->fn->dev, "UI config size mismatch\n");
> @@ -618,6 +620,7 @@ static int rmi_f34v7_check_dp_config_size(struct f34_data *f34)
> u16 block_count;
>
> block_count = f34->v7.img.dp_config.size / f34->v7.block_size;
> + f34->update_size += block_count;
>
> if (block_count != f34->v7.blkcount.dp_config) {
> dev_err(&f34->fn->dev, "Display config size mismatch\n");
> @@ -632,6 +635,8 @@ static int rmi_f34v7_check_guest_code_size(struct f34_data *f34)
> u16 block_count;
>
> block_count = f34->v7.img.guest_code.size / f34->v7.block_size;
> + f34->update_size += block_count;
> +
> if (block_count != f34->v7.blkcount.guest_code) {
> dev_err(&f34->fn->dev, "Guest code size mismatch\n");
> return -EINVAL;
> @@ -645,6 +650,7 @@ static int rmi_f34v7_check_bl_config_size(struct f34_data *f34)
> u16 block_count;
>
> block_count = f34->v7.img.bl_config.size / f34->v7.block_size;
> + f34->update_size += block_count;
>
> if (block_count != f34->v7.blkcount.bl_config) {
> dev_err(&f34->fn->dev, "Bootloader config size mismatch\n");
> @@ -881,6 +887,9 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
>
> block_ptr += (transfer * f34->v7.block_size);
> remaining -= transfer;
> + f34->update_progress += transfer;
> + f34->update_status = (f34->update_progress * 100) /
> + f34->update_size;
> } while (remaining);
>
> return 0;
> @@ -1191,6 +1200,8 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw)
> rmi_f34v7_read_queries_bl_version(f34);
>
> f34->v7.image = fw->data;
> + f34->update_progress = 0;
> + f34->update_size = 0;
>
> ret = rmi_f34v7_parse_image_info(f34);
> if (ret < 0)
> --
> 2.7.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2017-01-31 9:02 ` Dmitry Torokhov
@ 2017-01-31 21:17 ` Nick Dyer
2017-01-31 23:51 ` Dmitry Torokhov
0 siblings, 1 reply; 9+ messages in thread
From: Nick Dyer @ 2017-01-31 21:17 UTC (permalink / raw)
To: Dmitry Torokhov, Chris Healy
Cc: Andrew Duggan, Benjamin Tissoires, linux-input, Nick Dyer
These attributes provide various bits of information which may be enumerated
under the RMI4 protocol to user space.
This may be useful for displaying the particular version which is in use, or
selecting the correct firmware to flash.
Signed-off-by: Nick Dyer <nick@shmanahar.org>
Tested-by: Chris Healy <cphealy@gmail.com>
---
Hi Dmitry-
Updated this patch so that attributes are exported via F01.
cheers
Nick
drivers/input/rmi4/rmi_driver.c | 2 +-
drivers/input/rmi4/rmi_driver.h | 2 +-
drivers/input/rmi4/rmi_f01.c | 109 +++++++++++++++++++++++++++++++++++++++-
drivers/input/rmi4/rmi_f34.c | 49 ++++++++++++++++++
4 files changed, 158 insertions(+), 4 deletions(-)
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index a37bdf0..d5816e7 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -365,7 +365,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,
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
index 24f8f76..a480333 100644
--- a/drivers/input/rmi4/rmi_driver.h
+++ b/drivers/input/rmi4/rmi_driver.h
@@ -104,7 +104,7 @@ 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);
#ifdef CONFIG_RMI4_F34
int rmi_f34_create_sysfs(struct rmi_device *rmi_dev);
diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index cae35c6..90e4fb6 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/of.h>
+#include <asm/unaligned.h>
#include "rmi_driver.h"
#define RMI_PRODUCT_ID_LENGTH 10
@@ -55,6 +56,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 */
@@ -221,8 +223,19 @@ 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, sizeof(__le64));
+ if (ret) {
+ dev_err(&rmi_dev->dev,
+ "Failed to read package info: %d\n",
+ ret);
+ return ret;
+ }
+
+ props->package_id = get_unaligned_le64(queries);
prod_info_addr++;
+ }
if (has_build_id_query) {
ret = rmi_read_block(rmi_dev, prod_info_addr, queries,
@@ -242,13 +255,95 @@ 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;
}
+static ssize_t rmi_driver_manufacturer_id_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct rmi_driver_data *data = dev_get_drvdata(dev);
+ struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ f01->properties.manufacturer_id);
+}
+
+static DEVICE_ATTR(manufacturer_id, 0444,
+ rmi_driver_manufacturer_id_show, NULL);
+
+static ssize_t rmi_driver_dom_show(struct device *dev,
+ struct device_attribute *dattr, char *buf)
+{
+ struct rmi_driver_data *data = dev_get_drvdata(dev);
+ struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n",
+ f01->properties.dom);
+}
+
+static DEVICE_ATTR(date_of_manufacture, 0444, rmi_driver_dom_show, NULL);
+
+static ssize_t rmi_driver_product_id_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct rmi_driver_data *data = dev_get_drvdata(dev);
+ struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n",
+ f01->properties.product_id);
+}
+
+static DEVICE_ATTR(product_id, 0444,
+ rmi_driver_product_id_show, NULL);
+
+static ssize_t rmi_driver_firmware_id_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct rmi_driver_data *data = dev_get_drvdata(dev);
+ struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ f01->properties.firmware_id);
+}
+
+static DEVICE_ATTR(firmware_id, 0444,
+ rmi_driver_firmware_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 f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
+
+ u32 package_id = f01->properties.package_id;
+
+ 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 struct attribute *rmi_f01_attrs[] = {
+ &dev_attr_manufacturer_id.attr,
+ &dev_attr_date_of_manufacture.attr,
+ &dev_attr_product_id.attr,
+ &dev_attr_firmware_id.attr,
+ &dev_attr_package_id.attr,
+ NULL
+};
+
+static struct attribute_group rmi_f01_attr_group = {
+ .attrs = rmi_f01_attrs,
+};
+
#ifdef CONFIG_OF
static int rmi_f01_of_probe(struct device *dev,
struct rmi_device_platform_data *pdata)
@@ -481,9 +576,18 @@ static int rmi_f01_probe(struct rmi_function *fn)
dev_set_drvdata(&fn->dev, f01);
+ error = sysfs_create_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group);
+ if (error)
+ dev_warn(&fn->dev, "Failed to create sysfs group: %d\n", error);
+
return 0;
}
+static void rmi_f01_remove(struct rmi_function *fn)
+{
+ sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group);
+}
+
static int rmi_f01_config(struct rmi_function *fn)
{
struct f01_data *f01 = dev_get_drvdata(&fn->dev);
@@ -623,6 +727,7 @@ struct rmi_function_handler rmi_f01_handler = {
},
.func = 0x01,
.probe = rmi_f01_probe,
+ .remove = rmi_f01_remove,
.config = rmi_f01_config,
.attention = rmi_f01_attention,
.suspend = rmi_f01_suspend,
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index 048e593..bb7acf2 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -398,6 +398,53 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
return ret;
}
+static ssize_t rmi_driver_bootloader_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->f34_container;
+ struct f34_data *f34;
+
+ if (fn) {
+ f34 = dev_get_drvdata(&fn->dev);
+
+ if (f34->bl_version == 5)
+ return scnprintf(buf, PAGE_SIZE, "%c%c\n",
+ f34->bootloader_id[0],
+ f34->bootloader_id[1]);
+ else
+ return scnprintf(buf, PAGE_SIZE, "V%d.%d\n",
+ f34->bootloader_id[1],
+ f34->bootloader_id[0]);
+ }
+
+ return 0;
+}
+
+static DEVICE_ATTR(bootloader_id, 0444,
+ rmi_driver_bootloader_id_show, NULL);
+
+static ssize_t rmi_driver_configuration_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->f34_container;
+ struct f34_data *f34;
+
+ if (fn) {
+ f34 = dev_get_drvdata(&fn->dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", f34->configuration_id);
+ }
+
+ return 0;
+}
+
+static DEVICE_ATTR(configuration_id, 0444,
+ rmi_driver_configuration_id_show, NULL);
+
static int rmi_firmware_update(struct rmi_driver_data *data,
const struct firmware *fw);
@@ -452,6 +499,8 @@ static DEVICE_ATTR(update_fw_status, 0444,
rmi_driver_update_fw_status_show, NULL);
static struct attribute *rmi_firmware_attrs[] = {
+ &dev_attr_bootloader_id.attr,
+ &dev_attr_configuration_id.attr,
&dev_attr_update_fw.attr,
&dev_attr_update_fw_status.attr,
NULL
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status
2017-01-31 9:02 ` Dmitry Torokhov
@ 2017-01-31 23:43 ` Dmitry Torokhov
0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2017-01-31 23:43 UTC (permalink / raw)
To: Nick Dyer; +Cc: Chris Healy, Andrew Duggan, Benjamin Tissoires, linux-input
On Tue, Jan 31, 2017 at 01:02:57AM -0800, Dmitry Torokhov wrote:
> On Sat, Jan 28, 2017 at 07:06:01PM +0000, Nick Dyer wrote:
> > The attribute returns the percentage complete. If the firmware update fails, it
> > reports a negative error code.
> >
> > Signed-off-by: Nick Dyer <nick@shmanahar.org>
> > Tested-by: Chris Healy <cphealy@gmail.com>
> > Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>
> Applied, thank you.
>
> > ---
> > drivers/input/rmi4/rmi_f34.c | 40 +++++++++++++++++++++++++++++++++++++++-
> > drivers/input/rmi4/rmi_f34.h | 4 ++++
> > drivers/input/rmi4/rmi_f34v7.c | 11 +++++++++++
> > 3 files changed, 54 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
> > index c3285ce..048e593 100644
> > --- a/drivers/input/rmi4/rmi_f34.c
> > +++ b/drivers/input/rmi4/rmi_f34.c
> > @@ -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;
By the way, this breaks on big endian boxes. I fixed it up locally.
Please try incorporating 'sparse' into your workflow.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2017-01-31 21:17 ` [PATCH v4] " Nick Dyer
@ 2017-01-31 23:51 ` Dmitry Torokhov
0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2017-01-31 23:51 UTC (permalink / raw)
To: Nick Dyer; +Cc: Chris Healy, Andrew Duggan, Benjamin Tissoires, linux-input
On Tue, Jan 31, 2017 at 09:17:17PM +0000, Nick Dyer wrote:
> These attributes provide various bits of information which may be enumerated
> under the RMI4 protocol to user space.
>
> This may be useful for displaying the particular version which is in use, or
> selecting the correct firmware to flash.
>
> Signed-off-by: Nick Dyer <nick@shmanahar.org>
> Tested-by: Chris Healy <cphealy@gmail.com>
> ---
>
> Hi Dmitry-
>
> Updated this patch so that attributes are exported via F01.
Applied, thank you.
>
> cheers
>
> Nick
>
> drivers/input/rmi4/rmi_driver.c | 2 +-
> drivers/input/rmi4/rmi_driver.h | 2 +-
> drivers/input/rmi4/rmi_f01.c | 109 +++++++++++++++++++++++++++++++++++++++-
> drivers/input/rmi4/rmi_f34.c | 49 ++++++++++++++++++
> 4 files changed, 158 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index a37bdf0..d5816e7 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -365,7 +365,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,
> diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> index 24f8f76..a480333 100644
> --- a/drivers/input/rmi4/rmi_driver.h
> +++ b/drivers/input/rmi4/rmi_driver.h
> @@ -104,7 +104,7 @@ 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);
>
> #ifdef CONFIG_RMI4_F34
> int rmi_f34_create_sysfs(struct rmi_device *rmi_dev);
> diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> index cae35c6..90e4fb6 100644
> --- a/drivers/input/rmi4/rmi_f01.c
> +++ b/drivers/input/rmi4/rmi_f01.c
> @@ -13,6 +13,7 @@
> #include <linux/slab.h>
> #include <linux/uaccess.h>
> #include <linux/of.h>
> +#include <asm/unaligned.h>
> #include "rmi_driver.h"
>
> #define RMI_PRODUCT_ID_LENGTH 10
> @@ -55,6 +56,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 */
> @@ -221,8 +223,19 @@ 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, sizeof(__le64));
> + if (ret) {
> + dev_err(&rmi_dev->dev,
> + "Failed to read package info: %d\n",
> + ret);
> + return ret;
> + }
> +
> + props->package_id = get_unaligned_le64(queries);
> prod_info_addr++;
> + }
>
> if (has_build_id_query) {
> ret = rmi_read_block(rmi_dev, prod_info_addr, queries,
> @@ -242,13 +255,95 @@ 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;
> }
>
> +static ssize_t rmi_driver_manufacturer_id_show(struct device *dev,
> + struct device_attribute *dattr,
> + char *buf)
> +{
> + struct rmi_driver_data *data = dev_get_drvdata(dev);
> + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%d\n",
> + f01->properties.manufacturer_id);
> +}
> +
> +static DEVICE_ATTR(manufacturer_id, 0444,
> + rmi_driver_manufacturer_id_show, NULL);
> +
> +static ssize_t rmi_driver_dom_show(struct device *dev,
> + struct device_attribute *dattr, char *buf)
> +{
> + struct rmi_driver_data *data = dev_get_drvdata(dev);
> + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%s\n",
> + f01->properties.dom);
> +}
> +
> +static DEVICE_ATTR(date_of_manufacture, 0444, rmi_driver_dom_show, NULL);
> +
> +static ssize_t rmi_driver_product_id_show(struct device *dev,
> + struct device_attribute *dattr,
> + char *buf)
> +{
> + struct rmi_driver_data *data = dev_get_drvdata(dev);
> + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%s\n",
> + f01->properties.product_id);
> +}
> +
> +static DEVICE_ATTR(product_id, 0444,
> + rmi_driver_product_id_show, NULL);
> +
> +static ssize_t rmi_driver_firmware_id_show(struct device *dev,
> + struct device_attribute *dattr,
> + char *buf)
> +{
> + struct rmi_driver_data *data = dev_get_drvdata(dev);
> + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%d\n",
> + f01->properties.firmware_id);
> +}
> +
> +static DEVICE_ATTR(firmware_id, 0444,
> + rmi_driver_firmware_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 f01_data *f01 = dev_get_drvdata(&data->f01_container->dev);
> +
> + u32 package_id = f01->properties.package_id;
> +
> + 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 struct attribute *rmi_f01_attrs[] = {
> + &dev_attr_manufacturer_id.attr,
> + &dev_attr_date_of_manufacture.attr,
> + &dev_attr_product_id.attr,
> + &dev_attr_firmware_id.attr,
> + &dev_attr_package_id.attr,
> + NULL
> +};
> +
> +static struct attribute_group rmi_f01_attr_group = {
> + .attrs = rmi_f01_attrs,
> +};
> +
> #ifdef CONFIG_OF
> static int rmi_f01_of_probe(struct device *dev,
> struct rmi_device_platform_data *pdata)
> @@ -481,9 +576,18 @@ static int rmi_f01_probe(struct rmi_function *fn)
>
> dev_set_drvdata(&fn->dev, f01);
>
> + error = sysfs_create_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group);
> + if (error)
> + dev_warn(&fn->dev, "Failed to create sysfs group: %d\n", error);
> +
> return 0;
> }
>
> +static void rmi_f01_remove(struct rmi_function *fn)
> +{
> + sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group);
> +}
> +
> static int rmi_f01_config(struct rmi_function *fn)
> {
> struct f01_data *f01 = dev_get_drvdata(&fn->dev);
> @@ -623,6 +727,7 @@ struct rmi_function_handler rmi_f01_handler = {
> },
> .func = 0x01,
> .probe = rmi_f01_probe,
> + .remove = rmi_f01_remove,
> .config = rmi_f01_config,
> .attention = rmi_f01_attention,
> .suspend = rmi_f01_suspend,
> diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
> index 048e593..bb7acf2 100644
> --- a/drivers/input/rmi4/rmi_f34.c
> +++ b/drivers/input/rmi4/rmi_f34.c
> @@ -398,6 +398,53 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
> return ret;
> }
>
> +static ssize_t rmi_driver_bootloader_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->f34_container;
> + struct f34_data *f34;
> +
> + if (fn) {
> + f34 = dev_get_drvdata(&fn->dev);
> +
> + if (f34->bl_version == 5)
> + return scnprintf(buf, PAGE_SIZE, "%c%c\n",
> + f34->bootloader_id[0],
> + f34->bootloader_id[1]);
> + else
> + return scnprintf(buf, PAGE_SIZE, "V%d.%d\n",
> + f34->bootloader_id[1],
> + f34->bootloader_id[0]);
> + }
> +
> + return 0;
> +}
> +
> +static DEVICE_ATTR(bootloader_id, 0444,
> + rmi_driver_bootloader_id_show, NULL);
> +
> +static ssize_t rmi_driver_configuration_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->f34_container;
> + struct f34_data *f34;
> +
> + if (fn) {
> + f34 = dev_get_drvdata(&fn->dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%s\n", f34->configuration_id);
> + }
> +
> + return 0;
> +}
> +
> +static DEVICE_ATTR(configuration_id, 0444,
> + rmi_driver_configuration_id_show, NULL);
> +
> static int rmi_firmware_update(struct rmi_driver_data *data,
> const struct firmware *fw);
>
> @@ -452,6 +499,8 @@ static DEVICE_ATTR(update_fw_status, 0444,
> rmi_driver_update_fw_status_show, NULL);
>
> static struct attribute *rmi_firmware_attrs[] = {
> + &dev_attr_bootloader_id.attr,
> + &dev_attr_configuration_id.attr,
> &dev_attr_update_fw.attr,
> &dev_attr_update_fw_status.attr,
> NULL
> --
> 2.7.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-01-31 23:51 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-28 19:06 [PATCH v3 0/2] Synaptics RMI4 sysfs attributes Nick Dyer
2017-01-28 19:06 ` [PATCH v3 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
2017-01-31 9:02 ` Dmitry Torokhov
2017-01-31 23:43 ` Dmitry Torokhov
2017-01-28 19:06 ` [PATCH v3 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
2017-01-31 9:02 ` Dmitry Torokhov
2017-01-31 21:17 ` [PATCH v4] " Nick Dyer
2017-01-31 23:51 ` Dmitry Torokhov
2017-01-30 10:08 ` [PATCH v3 0/2] Synaptics RMI4 sysfs attributes Benjamin Tissoires
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).