History

firmware: arm_scmi: Add SCMI v3.1 protocol extended names support

Using the common protocol helper implementation add support for all new SCMIv3.1 extended names commands related to all protocols with the exception of SENSOR_AXIS_GET_NAME.

Cristian Marussi committed 4 years ago

Commit b260fcc1 parent 5c873d18 files · +104 −19Browse files

Unified · Split

8 files
  1. drivers/firmware/arm_scmi/clock.c +18 −3
  2. drivers/firmware/arm_scmi/perf.c +18 −4
  3. drivers/firmware/arm_scmi/power.c +20 −5
  4. drivers/firmware/arm_scmi/protocols.h +2 −0
  5. drivers/firmware/arm_scmi/reset.c +18 −4
  6. drivers/firmware/arm_scmi/sensors.c +14 −1
  7. drivers/firmware/arm_scmi/voltage.c +13 −1
  8. include/linux/scmi_protocol.h +1 −1
drivers/firmware/arm_scmi/clock.c+18−3
@@ -16,6 +16,7 @@ enum scmi_clock_protocol_cmd { · 15 unmodified lines
1616 CLOCK_RATE_SET = 0x5,
1717 CLOCK_RATE_GET = 0x6,
1818 CLOCK_CONFIG_SET = 0x7,
19+ CLOCK_NAME_GET = 0x8,
1920 };
2021
2122 struct scmi_msg_resp_clock_protocol_attributes {
@@ -27,7 +28,8 @@ struct scmi_msg_resp_clock_protocol_attributes { · 5 unmodified lines
2728 struct scmi_msg_resp_clock_attributes {
2829 __le32 attributes;
2930 #define CLOCK_ENABLE BIT(0)
30− u8 name[SCMI_MAX_STR_SIZE];
31+#define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(29))
32+ u8 name[SCMI_SHORT_NAME_MAX_SIZE];
3133 __le32 clock_enable_latency;
3234 };
3335
@@ -108,9 +110,11 @@ scmi_clock_protocol_attributes_get(const struct scmi_protocol_handle *ph, · 74 unmodified lines
108110 }
109111
110112 static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
111− u32 clk_id, struct scmi_clock_info *clk)
113+ u32 clk_id, struct scmi_clock_info *clk,
114+ u32 version)
112115 {
113116 int ret;
117+ u32 attributes;
114118 struct scmi_xfer *t;
115119 struct scmi_msg_resp_clock_attributes *attr;
116120
@@ -124,6 +128,7 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, · 7 unmodified lines
124128
125129 ret = ph->xops->do_xfer(ph, t);
126130 if (!ret) {
131+ attributes = le32_to_cpu(attr->attributes);
127132 strlcpy(clk->name, attr->name, SCMI_MAX_STR_SIZE);
128133 /* Is optional field clock_enable_latency provided ? */
129134 if (t->rx.len == sizeof(*attr))
@@ -132,6 +137,16 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, · 2 unmodified lines
132137 }
133138
134139 ph->xops->xfer_put(ph, t);
140+
141+ /*
142+ * If supported overwrite short name with the extended one;
143+ * on error just carry on and use already provided short name.
144+ */
145+ if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x2 &&
146+ SUPPORTS_EXTENDED_NAMES(attributes))
147+ ph->hops->extended_name_get(ph, CLOCK_NAME_GET, clk_id,
148+ clk->name, SCMI_MAX_STR_SIZE);
149+
135150 return ret;
136151 }
137152
@@ -400,7 +415,7 @@ static int scmi_clock_protocol_init(const struct scmi_protocol_handle *ph) · 262 unmodified lines
400415 for (clkid = 0; clkid < cinfo->num_clocks; clkid++) {
401416 struct scmi_clock_info *clk = cinfo->clk + clkid;
402417
403− ret = scmi_clock_attributes_get(ph, clkid, clk);
418+ ret = scmi_clock_attributes_get(ph, clkid, clk, version);
404419 if (!ret)
405420 scmi_clock_describe_rates_get(ph, clkid, clk);
406421 }
drivers/firmware/arm_scmi/perf.c+18−4
@@ -32,6 +32,7 @@ enum scmi_performance_protocol_cmd { · 31 unmodified lines
3232 PERF_NOTIFY_LIMITS = 0x9,
3333 PERF_NOTIFY_LEVEL = 0xa,
3434 PERF_DESCRIBE_FASTCHANNEL = 0xb,
35+ PERF_DOMAIN_NAME_GET = 0xc,
3536 };
3637
3738 struct scmi_opp {
@@ -56,10 +57,11 @@ struct scmi_msg_resp_perf_domain_attributes { · 18 unmodified lines
5657 #define SUPPORTS_PERF_LIMIT_NOTIFY(x) ((x) & BIT(29))
5758 #define SUPPORTS_PERF_LEVEL_NOTIFY(x) ((x) & BIT(28))
5859 #define SUPPORTS_PERF_FASTCHANNELS(x) ((x) & BIT(27))
60+#define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(26))
5961 __le32 rate_limit_us;
6062 __le32 sustained_freq_khz;
6163 __le32 sustained_perf_level;
62− u8 name[SCMI_MAX_STR_SIZE];
64+ u8 name[SCMI_SHORT_NAME_MAX_SIZE];
6365 };
6466
6567 struct scmi_msg_perf_describe_levels {
@@ -209,9 +211,11 @@ static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph, · 143 unmodified lines
209211
210212 static int
211213 scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
212− u32 domain, struct perf_dom_info *dom_info)
214+ u32 domain, struct perf_dom_info *dom_info,
215+ u32 version)
213216 {
214217 int ret;
218+ u32 flags;
215219 struct scmi_xfer *t;
216220 struct scmi_msg_resp_perf_domain_attributes *attr;
217221
@@ -225,7 +229,7 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, · 7 unmodified lines
225229
226230 ret = ph->xops->do_xfer(ph, t);
227231 if (!ret) {
228− u32 flags = le32_to_cpu(attr->flags);
232+ flags = le32_to_cpu(attr->flags);
229233
230234 dom_info->set_limits = SUPPORTS_SET_LIMITS(flags);
231235 dom_info->set_perf = SUPPORTS_SET_PERF_LVL(flags);
@@ -248,6 +252,16 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, · 16 unmodified lines
248252 }
249253
250254 ph->xops->xfer_put(ph, t);
255+
256+ /*
257+ * If supported overwrite short name with the extended one;
258+ * on error just carry on and use already provided short name.
259+ */
260+ if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 &&
261+ SUPPORTS_EXTENDED_NAMES(flags))
262+ ph->hops->extended_name_get(ph, PERF_DOMAIN_NAME_GET, domain,
263+ dom_info->name, SCMI_MAX_STR_SIZE);
264+
251265 return ret;
252266 }
253267
@@ -902,7 +916,7 @@ static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph) · 648 unmodified lines
902916 for (domain = 0; domain < pinfo->num_domains; domain++) {
903917 struct perf_dom_info *dom = pinfo->dom_info + domain;
904918
905− scmi_perf_domain_attributes_get(ph, domain, dom);
919+ scmi_perf_domain_attributes_get(ph, domain, dom, version);
906920 scmi_perf_describe_levels_get(ph, domain, dom);
907921
908922 if (dom->perf_fastchannels)
drivers/firmware/arm_scmi/power.c+20−5
@@ -18,6 +18,7 @@ enum scmi_power_protocol_cmd { · 17 unmodified lines
1818 POWER_STATE_SET = 0x4,
1919 POWER_STATE_GET = 0x5,
2020 POWER_STATE_NOTIFY = 0x6,
21+ POWER_DOMAIN_NAME_GET = 0x8,
2122 };
2223
2324 struct scmi_msg_resp_power_attributes {
@@ -33,7 +34,8 @@ struct scmi_msg_resp_power_domain_attributes { · 9 unmodified lines
3334 #define SUPPORTS_STATE_SET_NOTIFY(x) ((x) & BIT(31))
3435 #define SUPPORTS_STATE_SET_ASYNC(x) ((x) & BIT(30))
3536 #define SUPPORTS_STATE_SET_SYNC(x) ((x) & BIT(29))
36− u8 name[SCMI_MAX_STR_SIZE];
37+#define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(27))
38+ u8 name[SCMI_SHORT_NAME_MAX_SIZE];
3739 };
3840
3941 struct scmi_power_set_state {
@@ -97,9 +99,11 @@ static int scmi_power_attributes_get(const struct scmi_protocol_handle *ph, · 57 unmodified lines
9799
98100 static int
99101 scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph,
100− u32 domain, struct power_dom_info *dom_info)
102+ u32 domain, struct power_dom_info *dom_info,
103+ u32 version)
101104 {
102105 int ret;
106+ u32 flags;
103107 struct scmi_xfer *t;
104108 struct scmi_msg_resp_power_domain_attributes *attr;
105109
@@ -113,15 +117,26 @@ scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph, · 7 unmodified lines
113117
114118 ret = ph->xops->do_xfer(ph, t);
115119 if (!ret) {
116− u32 flags = le32_to_cpu(attr->flags);
120+ flags = le32_to_cpu(attr->flags);
117121
118122 dom_info->state_set_notify = SUPPORTS_STATE_SET_NOTIFY(flags);
119123 dom_info->state_set_async = SUPPORTS_STATE_SET_ASYNC(flags);
120124 dom_info->state_set_sync = SUPPORTS_STATE_SET_SYNC(flags);
121125 strlcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
122126 }
123−
124127 ph->xops->xfer_put(ph, t);
128+
129+ /*
130+ * If supported overwrite short name with the extended one;
131+ * on error just carry on and use already provided short name.
132+ */
133+ if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 &&
134+ SUPPORTS_EXTENDED_NAMES(flags)) {
135+ ph->hops->extended_name_get(ph, POWER_DOMAIN_NAME_GET,
136+ domain, dom_info->name,
137+ SCMI_MAX_STR_SIZE);
138+ }
139+
125140 return ret;
126141 }
127142
@@ -308,7 +323,7 @@ static int scmi_power_protocol_init(const struct scmi_protocol_handle *ph) · 180 unmodified lines
308323 for (domain = 0; domain < pinfo->num_domains; domain++) {
309324 struct power_dom_info *dom = pinfo->dom_info + domain;
310325
311− scmi_power_domain_attributes_get(ph, domain, dom);
326+ scmi_power_domain_attributes_get(ph, domain, dom, version);
312327 }
313328
314329 pinfo->version = version;
drivers/firmware/arm_scmi/protocols.h+2−0
@@ -24,6 +24,8 @@ · 23 unmodified lines
2424
2525 #include <asm/unaligned.h>
2626
27+#define SCMI_SHORT_NAME_MAX_SIZE 16
28+
2729 #define PROTOCOL_REV_MINOR_MASK GENMASK(15, 0)
2830 #define PROTOCOL_REV_MAJOR_MASK GENMASK(31, 16)
2931 #define PROTOCOL_REV_MAJOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x))))
drivers/firmware/arm_scmi/reset.c+18−4
@@ -17,6 +17,7 @@ enum scmi_reset_protocol_cmd { · 16 unmodified lines
1717 RESET_DOMAIN_ATTRIBUTES = 0x3,
1818 RESET = 0x4,
1919 RESET_NOTIFY = 0x5,
20+ RESET_DOMAIN_NAME_GET = 0x6,
2021 };
2122
2223 #define NUM_RESET_DOMAIN_MASK 0xffff
@@ -26,8 +27,9 @@ struct scmi_msg_resp_reset_domain_attributes { · 3 unmodified lines
2627 __le32 attributes;
2728 #define SUPPORTS_ASYNC_RESET(x) ((x) & BIT(31))
2829 #define SUPPORTS_NOTIFY_RESET(x) ((x) & BIT(30))
30+#define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(29))
2931 __le32 latency;
30− u8 name[SCMI_MAX_STR_SIZE];
32+ u8 name[SCMI_SHORT_NAME_MAX_SIZE];
3133 };
3234
3335 struct scmi_msg_reset_domain_reset {
@@ -89,9 +91,11 @@ static int scmi_reset_attributes_get(const struct scmi_protocol_handle *ph, · 55 unmodified lines
8991
9092 static int
9193 scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph,
92− u32 domain, struct reset_dom_info *dom_info)
94+ u32 domain, struct reset_dom_info *dom_info,
95+ u32 version)
9396 {
9497 int ret;
98+ u32 attributes;
9599 struct scmi_xfer *t;
96100 struct scmi_msg_resp_reset_domain_attributes *attr;
97101
@@ -105,7 +109,7 @@ scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph, · 7 unmodified lines
105109
106110 ret = ph->xops->do_xfer(ph, t);
107111 if (!ret) {
108− u32 attributes = le32_to_cpu(attr->attributes);
112+ attributes = le32_to_cpu(attr->attributes);
109113
110114 dom_info->async_reset = SUPPORTS_ASYNC_RESET(attributes);
111115 dom_info->reset_notify = SUPPORTS_NOTIFY_RESET(attributes);
@@ -116,6 +120,16 @@ scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph, · 4 unmodified lines
116120 }
117121
118122 ph->xops->xfer_put(ph, t);
123+
124+ /*
125+ * If supported overwrite short name with the extended one;
126+ * on error just carry on and use already provided short name.
127+ */
128+ if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 &&
129+ SUPPORTS_EXTENDED_NAMES(attributes))
130+ ph->hops->extended_name_get(ph, RESET_DOMAIN_NAME_GET, domain,
131+ dom_info->name, SCMI_MAX_STR_SIZE);
132+
119133 return ret;
120134 }
121135
@@ -320,7 +334,7 @@ static int scmi_reset_protocol_init(const struct scmi_protocol_handle *ph) · 198 unmodified lines
320334 for (domain = 0; domain < pinfo->num_domains; domain++) {
321335 struct reset_dom_info *dom = pinfo->dom_info + domain;
322336
323− scmi_reset_domain_attributes_get(ph, domain, dom);
337+ scmi_reset_domain_attributes_get(ph, domain, dom, version);
324338 }
325339
326340 pinfo->version = version;
drivers/firmware/arm_scmi/sensors.c+14−1
@@ -27,6 +27,7 @@ enum scmi_sensor_protocol_cmd { · 26 unmodified lines
2727 SENSOR_CONFIG_GET = 0x9,
2828 SENSOR_CONFIG_SET = 0xA,
2929 SENSOR_CONTINUOUS_UPDATE_NOTIFY = 0xB,
30+ SENSOR_NAME_GET = 0xC,
3031 };
3132
3233 struct scmi_msg_resp_sensor_attributes {
@@ -71,6 +72,7 @@ struct scmi_msg_resp_sensor_description { · 38 unmodified lines
7172 __le32 attributes_low;
7273 /* Common attributes_low macros */
7374 #define SUPPORTS_ASYNC_READ(x) FIELD_GET(BIT(31), (x))
75+#define SUPPORTS_EXTENDED_NAMES(x) FIELD_GET(BIT(29), (x))
7476 #define NUM_TRIP_POINTS(x) FIELD_GET(GENMASK(7, 0), (x))
7577 __le32 attributes_high;
7678 /* Common attributes_high macros */
@@ -78,7 +80,7 @@ struct scmi_msg_resp_sensor_description { · 1 unmodified line
7880 #define SENSOR_SCALE_SIGN BIT(4)
7981 #define SENSOR_SCALE_EXTEND GENMASK(31, 5)
8082 #define SENSOR_TYPE(x) FIELD_GET(GENMASK(7, 0), (x))
81− u8 name[SCMI_MAX_STR_SIZE];
83+ u8 name[SCMI_SHORT_NAME_MAX_SIZE];
8284 /* only for version > 2.0 */
8385 __le32 power;
8486 __le32 resolution;
@@ -519,6 +521,17 @@ static int scmi_sensor_description_get(const struct scmi_protocol_handle *ph, · 434 unmodified lines
519521 SCMI_MAX_NUM_SENSOR_AXIS);
520522 strlcpy(s->name, sdesc->name, SCMI_MAX_STR_SIZE);
521523
524+ /*
525+ * If supported overwrite short name with the extended
526+ * one; on error just carry on and use already provided
527+ * short name.
528+ */
529+ if (PROTOCOL_REV_MAJOR(si->version) >= 0x3 &&
530+ SUPPORTS_EXTENDED_NAMES(attrl))
531+ ph->hops->extended_name_get(ph, SENSOR_NAME_GET,
532+ s->id, s->name,
533+ SCMI_MAX_STR_SIZE);
534+
522535 if (s->extended_scalar_attrs) {
523536 s->sensor_power = le32_to_cpu(sdesc->power);
524537 dsize += sizeof(sdesc->power);
drivers/firmware/arm_scmi/voltage.c+13−1
@@ -21,13 +21,15 @@ enum scmi_voltage_protocol_cmd { · 20 unmodified lines
2121 VOLTAGE_CONFIG_GET = 0x6,
2222 VOLTAGE_LEVEL_SET = 0x7,
2323 VOLTAGE_LEVEL_GET = 0x8,
24+ VOLTAGE_DOMAIN_NAME_GET = 0x09,
2425 };
2526
2627 #define NUM_VOLTAGE_DOMAINS(x) ((u16)(FIELD_GET(VOLTAGE_DOMS_NUM_MASK, (x))))
2728
2829 struct scmi_msg_resp_domain_attributes {
2930 __le32 attr;
30− u8 name[SCMI_MAX_STR_SIZE];
31+#define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(30))
32+ u8 name[SCMI_SHORT_NAME_MAX_SIZE];
3133 };
3234
3335 struct scmi_msg_cmd_describe_levels {
@@ -149,6 +151,16 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph, · 115 unmodified lines
149151 v->attributes = le32_to_cpu(resp_dom->attr);
150152 strlcpy(v->name, resp_dom->name, SCMI_MAX_STR_SIZE);
151153
154+ /*
155+ * If supported overwrite short name with the extended one;
156+ * on error just carry on and use already provided short name.
157+ */
158+ if (PROTOCOL_REV_MAJOR(vinfo->version) >= 0x2 &&
159+ SUPPORTS_EXTENDED_NAMES(v->attributes))
160+ ph->hops->extended_name_get(ph, VOLTAGE_DOMAIN_NAME_GET,
161+ v->id, v->name,
162+ SCMI_MAX_STR_SIZE);
163+
152164 cmd = tl->tx.buf;
153165 /* ...then retrieve domain levels descriptions */
154166 do {
include/linux/scmi_protocol.h+1−1
@@ -13,7 +13,7 @@ · 12 unmodified lines
1313 #include <linux/notifier.h>
1414 #include <linux/types.h>
1515
16−#define SCMI_MAX_STR_SIZE 16
16+#define SCMI_MAX_STR_SIZE 64
1717 #define SCMI_MAX_NUM_RATES 16
1818
1919 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t