* [PATCH 0/2] Synaptics RMI4 sysfs attributes
@ 2016-12-30 18:43 Nick Dyer
2016-12-30 18:43 ` [PATCH 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
2016-12-30 18:43 ` [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
0 siblings, 2 replies; 6+ messages in thread
From: Nick Dyer @ 2016-12-30 18:43 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Andrew Duggan, Chris Healy, 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.
regards
Nick Dyer
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status
2016-12-30 18:43 [PATCH 0/2] Synaptics RMI4 sysfs attributes Nick Dyer
@ 2016-12-30 18:43 ` Nick Dyer
2016-12-30 18:43 ` [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
1 sibling, 0 replies; 6+ messages in thread
From: Nick Dyer @ 2016-12-30 18:43 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Andrew Duggan, Chris Healy, Benjamin Tissoires, linux-input, Nick Dyer
The status is the percentage complete, or once complete, zero for
success or a negative return code.
Signed-off-by: Nick Dyer <nick@shmanahar.org>
---
drivers/input/rmi4/rmi_f34.c | 34 ++++++++++++++++++++++++++++++++++
drivers/input/rmi4/rmi_f34.h | 4 ++++
drivers/input/rmi4/rmi_f34v7.c | 6 ++++++
3 files changed, 44 insertions(+)
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index c3285ce..d7709bc 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)
{
@@ -347,6 +363,7 @@ static int rmi_firmware_update(struct rmi_driver_data *data,
ret = rmi_f34_update_firmware(f34, fw);
dev_info(&f34->fn->dev, "Firmware update complete, status:%d\n", ret);
+ f34->update_status = ret;
rmi_disable_irq(rmi_dev, false);
@@ -414,8 +431,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..35a6cf6 100644
--- a/drivers/input/rmi4/rmi_f34v7.c
+++ b/drivers/input/rmi4/rmi_f34v7.c
@@ -366,6 +366,7 @@ static void rmi_f34v7_parse_partition_table(struct f34_data *f34,
rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
"%s: Partition entry %d: %*ph\n",
__func__, i, sizeof(struct partition_table), ptable);
+ f34->update_size += partition_length;
switch (ptable->partition_id & 0x1f) {
case CORE_CODE_PARTITION:
blkcount->ui_firmware = partition_length;
@@ -881,6 +882,9 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
block_ptr += (transfer * f34->v7.block_size);
remaining -= transfer;
+ f34->update_progress++;
+ f34->update_status = (f34->update_progress * 100) /
+ f34->update_size;
} while (remaining);
return 0;
@@ -1191,6 +1195,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] 6+ messages in thread
* [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2016-12-30 18:43 [PATCH 0/2] Synaptics RMI4 sysfs attributes Nick Dyer
2016-12-30 18:43 ` [PATCH 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
@ 2016-12-30 18:43 ` Nick Dyer
2017-01-20 13:42 ` Benjamin Tissoires
1 sibling, 1 reply; 6+ messages in thread
From: Nick Dyer @ 2016-12-30 18:43 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Andrew Duggan, Chris Healy, Benjamin Tissoires, linux-input, Nick Dyer
Signed-off-by: Nick Dyer <nick@shmanahar.org>
---
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 cb6efe6..e0359d6 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 d7709bc..b7b38c1 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -394,6 +394,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);
@@ -448,6 +564,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] 6+ messages in thread
* Re: [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2016-12-30 18:43 ` [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
@ 2017-01-20 13:42 ` Benjamin Tissoires
2017-01-22 20:12 ` Nick Dyer
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Tissoires @ 2017-01-20 13:42 UTC (permalink / raw)
To: Nick Dyer; +Cc: Dmitry Torokhov, Andrew Duggan, Chris Healy, linux-input
Hi Nick,
Well, first, you need a changelog explaining why you need custom sysfs
files.
Then, I really wonder if this is the best solution. You are trying to
solve a general problem in a specific way, while other drivers/devices
could benefit from reporting such information in a generic way.
I don't have a solution, but I know that we already had the case where
userspace wants to know which firmware is currently loaded on a
board[1].
A solution could be to add some ioctls to evdev to report those various
hardware IDs, but I am not so sure it will help in the RMI4 device while
in bootloader case.
If Dmitry agrees to take this one, I have nothing against it.
Cheers,
Benjamin
[1] https://bugs.freedesktop.org/show_bug.cgi?id=97912
On Dec 30 2016 or thereabouts, Nick Dyer wrote:
> Signed-off-by: Nick Dyer <nick@shmanahar.org>
> ---
> 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 cb6efe6..e0359d6 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 d7709bc..b7b38c1 100644
> --- a/drivers/input/rmi4/rmi_f34.c
> +++ b/drivers/input/rmi4/rmi_f34.c
> @@ -394,6 +394,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);
>
> @@ -448,6 +564,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 [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2017-01-20 13:42 ` Benjamin Tissoires
@ 2017-01-22 20:12 ` Nick Dyer
2017-01-22 21:49 ` Chris Healy
0 siblings, 1 reply; 6+ messages in thread
From: Nick Dyer @ 2017-01-22 20:12 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Dmitry Torokhov, Andrew Duggan, Chris Healy, linux-input
On Fri, Jan 20, 2017 at 02:42:52PM +0100, Benjamin Tissoires wrote:
> Subject: Re: [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for
> hardware IDs
>
> Hi Nick,
>
> Well, first, you need a changelog explaining why you need custom sysfs
> files.
It is for a firmware update system that works across a number of devices
supported by the synaptics-rmi4 driver. It needs to manage multiple
different versions of the firmware/hardware and which ones are
compatible with which. I will put it in the commit message: although
possibly the information would be useful even if you weren't trying to
update firmware.
> Then, I really wonder if this is the best solution. You are trying to
> solve a general problem in a specific way, while other drivers/devices
> could benefit from reporting such information in a generic way.
>
> I don't have a solution, but I know that we already had the case where
> userspace wants to know which firmware is currently loaded on a
> board[1].
>
> A solution could be to add some ioctls to evdev to report those various
> hardware IDs, but I am not so sure it will help in the RMI4 device while
> in bootloader case.
If we are trying to recover a broken device (eg corrupt firmware), we
might not have the information to register an input device anyway.
I agree that a generic solution to get this information would be nice.
But we would have to map the complexities of the underlying
hardware/firmware anyway - for example, an "input device" may have
multiple components with separate firmwares having individual versions.
So it would end up being a hierarchy with attributes of various types:
isn't that just sysfs?
> If Dmitry agrees to take this one, I have nothing against it.
>
> Cheers,
> Benjamin
>
> [1] https://bugs.freedesktop.org/show_bug.cgi?id=97912
>
> On Dec 30 2016 or thereabouts, Nick Dyer wrote:
> > Signed-off-by: Nick Dyer <nick@shmanahar.org>
> > ---
> > 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 cb6efe6..e0359d6 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 d7709bc..b7b38c1 100644
> > --- a/drivers/input/rmi4/rmi_f34.c
> > +++ b/drivers/input/rmi4/rmi_f34.c
> > @@ -394,6 +394,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);
> >
> > @@ -448,6 +564,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 [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs
2017-01-22 20:12 ` Nick Dyer
@ 2017-01-22 21:49 ` Chris Healy
0 siblings, 0 replies; 6+ messages in thread
From: Chris Healy @ 2017-01-22 21:49 UTC (permalink / raw)
To: Nick Dyer; +Cc: Benjamin Tissoires, Dmitry Torokhov, Andrew Duggan, linux-input
On Sun, Jan 22, 2017 at 12:12 PM, Nick Dyer <nick@shmanahar.org> wrote:
>
> On Fri, Jan 20, 2017 at 02:42:52PM +0100, Benjamin Tissoires wrote:
> > Subject: Re: [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for
> > hardware IDs
> >
> > Hi Nick,
> >
> > Well, first, you need a changelog explaining why you need custom sysfs
> > files.
>
> It is for a firmware update system that works across a number of devices
> supported by the synaptics-rmi4 driver. It needs to manage multiple
> different versions of the firmware/hardware and which ones are
> compatible with which. I will put it in the commit message: although
> possibly the information would be useful even if you weren't trying to
> update firmware.
In my use case, I have 6 different IFE (in flight entertainment)
system displays, all with the same kernel/rootfs running on them and
all with different size LCD and touchscreen. Across this 6 displays,
there are two different models of Synaptics touch controllers which
results in 2 different FW images and 6 different FW configs. This
results in there being 6 different loadable FW binaries. Each FW
binary includes the FW itself and an embedded configuration block.
When we perform a system SW upgrade, there is a touchscreen FW update
step which executes a shell script that uses these sysfs entries to
figure out which FW binary to load from /lib/firmware AND if the
latest FW/config is already loaded to the controller. This way we
don't execute a FW update if the FW/config is already the correct
version.
Having sysfs entries makes this process quite simple with a shell script.
>
> > Then, I really wonder if this is the best solution. You are trying to
> > solve a general problem in a specific way, while other drivers/devices
> > could benefit from reporting such information in a generic way.
> >
> > I don't have a solution, but I know that we already had the case where
> > userspace wants to know which firmware is currently loaded on a
> > board[1].
> >
> > A solution could be to add some ioctls to evdev to report those various
> > hardware IDs, but I am not so sure it will help in the RMI4 device while
> > in bootloader case.
>
> If we are trying to recover a broken device (eg corrupt firmware), we
> might not have the information to register an input device anyway.
>
> I agree that a generic solution to get this information would be nice.
> But we would have to map the complexities of the underlying
> hardware/firmware anyway - for example, an "input device" may have
> multiple components with separate firmwares having individual versions.
>
> So it would end up being a hierarchy with attributes of various types:
> isn't that just sysfs?
>
> > If Dmitry agrees to take this one, I have nothing against it.
> >
> > Cheers,
> > Benjamin
> >
> > [1] https://bugs.freedesktop.org/show_bug.cgi?id=97912
> >
> > On Dec 30 2016 or thereabouts, Nick Dyer wrote:
> > > Signed-off-by: Nick Dyer <nick@shmanahar.org>
> > > ---
> > > 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 cb6efe6..e0359d6 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 d7709bc..b7b38c1 100644
> > > --- a/drivers/input/rmi4/rmi_f34.c
> > > +++ b/drivers/input/rmi4/rmi_f34.c
> > > @@ -394,6 +394,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);
> > >
> > > @@ -448,6 +564,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 [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-22 21:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-30 18:43 [PATCH 0/2] Synaptics RMI4 sysfs attributes Nick Dyer
2016-12-30 18:43 ` [PATCH 1/2] Input: synaptics-rmi4 - add sysfs attribute update_fw_status Nick Dyer
2016-12-30 18:43 ` [PATCH 2/2] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
2017-01-20 13:42 ` Benjamin Tissoires
2017-01-22 20:12 ` Nick Dyer
2017-01-22 21:49 ` Chris Healy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.