aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudeep Holla <sudeep.holla@arm.com>2016-01-14 12:58:02 -0500
committerSudeep Holla <sudeep.holla@arm.com>2016-02-16 04:26:27 -0500
commit2e8741599cf128ea27674d9ae93b46e847f820b4 (patch)
treec5d67204b4ec905d85667bb67bc4f776f830327c
parent3bdd884371b6fe68bb144aa4661d6a774a5417f1 (diff)
firmware: arm_scpi: add support for 64-bit sensor values
SCPI specification version 1.1 extended the sensor from 32-bit to 64-bit values in order to accommodate new sensor class with 64-bit requirements Since the SCPI driver sets the higher 32-bit for older protocol version to zeros, there's no need to explicitly check the SCPI protocol version and the backward compatibility is maintainted. Acked-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Punit Agrawal <punit.agrawal@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
-rw-r--r--drivers/firmware/arm_scpi.c8
-rw-r--r--drivers/hwmon/scpi-hwmon.c6
-rw-r--r--include/linux/scpi_protocol.h2
3 files changed, 9 insertions, 7 deletions
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index c32ac6e61ba2..7e3e595c9f30 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -231,7 +231,8 @@ struct _scpi_sensor_info {
231}; 231};
232 232
233struct sensor_value { 233struct sensor_value {
234 __le32 val; 234 __le32 lo_val;
235 __le32 hi_val;
235} __packed; 236} __packed;
236 237
237static struct scpi_drvinfo *scpi_info; 238static struct scpi_drvinfo *scpi_info;
@@ -525,7 +526,7 @@ static int scpi_sensor_get_info(u16 sensor_id, struct scpi_sensor_info *info)
525 return ret; 526 return ret;
526} 527}
527 528
528int scpi_sensor_get_value(u16 sensor, u32 *val) 529int scpi_sensor_get_value(u16 sensor, u64 *val)
529{ 530{
530 __le16 id = cpu_to_le16(sensor); 531 __le16 id = cpu_to_le16(sensor);
531 struct sensor_value buf; 532 struct sensor_value buf;
@@ -534,7 +535,8 @@ int scpi_sensor_get_value(u16 sensor, u32 *val)
534 ret = scpi_send_message(SCPI_CMD_SENSOR_VALUE, &id, sizeof(id), 535 ret = scpi_send_message(SCPI_CMD_SENSOR_VALUE, &id, sizeof(id),
535 &buf, sizeof(buf)); 536 &buf, sizeof(buf));
536 if (!ret) 537 if (!ret)
537 *val = le32_to_cpu(buf.val); 538 *val = (u64)le32_to_cpu(buf.hi_val) << 32 |
539 le32_to_cpu(buf.lo_val);
538 540
539 return ret; 541 return ret;
540} 542}
diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c
index 7e20567bc369..7101b14b5137 100644
--- a/drivers/hwmon/scpi-hwmon.c
+++ b/drivers/hwmon/scpi-hwmon.c
@@ -52,7 +52,7 @@ static int scpi_read_temp(void *dev, int *temp)
52 struct scpi_sensors *scpi_sensors = zone->scpi_sensors; 52 struct scpi_sensors *scpi_sensors = zone->scpi_sensors;
53 struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops; 53 struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;
54 struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id]; 54 struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];
55 u32 value; 55 u64 value;
56 int ret; 56 int ret;
57 57
58 ret = scpi_ops->sensor_get_value(sensor->info.sensor_id, &value); 58 ret = scpi_ops->sensor_get_value(sensor->info.sensor_id, &value);
@@ -70,7 +70,7 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf)
70 struct scpi_sensors *scpi_sensors = dev_get_drvdata(dev); 70 struct scpi_sensors *scpi_sensors = dev_get_drvdata(dev);
71 struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops; 71 struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;
72 struct sensor_data *sensor; 72 struct sensor_data *sensor;
73 u32 value; 73 u64 value;
74 int ret; 74 int ret;
75 75
76 sensor = container_of(attr, struct sensor_data, dev_attr_input); 76 sensor = container_of(attr, struct sensor_data, dev_attr_input);
@@ -79,7 +79,7 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf)
79 if (ret) 79 if (ret)
80 return ret; 80 return ret;
81 81
82 return sprintf(buf, "%u\n", value); 82 return sprintf(buf, "%llu\n", value);
83} 83}
84 84
85static ssize_t 85static ssize_t
diff --git a/include/linux/scpi_protocol.h b/include/linux/scpi_protocol.h
index 72ce932c69b2..ecd248d46281 100644
--- a/include/linux/scpi_protocol.h
+++ b/include/linux/scpi_protocol.h
@@ -68,7 +68,7 @@ struct scpi_ops {
68 struct scpi_dvfs_info *(*dvfs_get_info)(u8); 68 struct scpi_dvfs_info *(*dvfs_get_info)(u8);
69 int (*sensor_get_capability)(u16 *sensors); 69 int (*sensor_get_capability)(u16 *sensors);
70 int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *); 70 int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *);
71 int (*sensor_get_value)(u16, u32 *); 71 int (*sensor_get_value)(u16, u64 *);
72}; 72};
73 73
74#if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL) 74#if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)