Skip to content

Commit a4207a1

Browse files
committed
Merge tag 'scmi-fixes-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/fixes
ARM SCMI fixes for v5.4 Couple of fixes: one in scmi reset driver initialising missed scmi handle and an other in scmi reset API implementation fixing the assignment of reset state * tag 'scmi-fixes-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: reset: reset-scmi: add missing handle initialisation firmware: arm_scmi: reset: fix reset_state assignment in scmi_domain_reset Link: https://lore.kernel.org/r/20190918142139.GA4370@bogus Signed-off-by: Olof Johansson <[email protected]>
2 parents b74d957 + 6142371 commit a4207a1

File tree

17 files changed

+982
-202
lines changed

17 files changed

+982
-202
lines changed

Documentation/devicetree/bindings/arm/arm,scmi.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ Required properties:
7373
as used by the firmware. Refer to platform details
7474
for your implementation for the IDs to use.
7575

76+
Reset signal bindings for the reset domains based on SCMI Message Protocol
77+
------------------------------------------------------------
78+
79+
This binding for the SCMI reset domain providers uses the generic reset
80+
signal binding[5].
81+
82+
Required properties:
83+
- #reset-cells : Should be 1. Contains the reset domain ID value used
84+
by SCMI commands.
85+
7686
SRAM and Shared Memory for SCMI
7787
-------------------------------
7888

@@ -93,6 +103,7 @@ Required sub-node properties:
93103
[2] Documentation/devicetree/bindings/power/power_domain.txt
94104
[3] Documentation/devicetree/bindings/thermal/thermal.txt
95105
[4] Documentation/devicetree/bindings/sram/sram.txt
106+
[5] Documentation/devicetree/bindings/reset/reset.txt
96107

97108
Example:
98109

@@ -152,6 +163,11 @@ firmware {
152163
reg = <0x15>;
153164
#thermal-sensor-cells = <1>;
154165
};
166+
167+
scmi_reset: protocol@16 {
168+
reg = <0x16>;
169+
#reset-cells = <1>;
170+
};
155171
};
156172
};
157173

@@ -166,6 +182,7 @@ hdlcd@7ff60000 {
166182
reg = <0 0x7ff60000 0 0x1000>;
167183
clocks = <&scmi_clk 4>;
168184
power-domains = <&scmi_devpd 1>;
185+
resets = <&scmi_reset 10>;
169186
};
170187

171188
thermal-zones {

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15575,6 +15575,7 @@ F: drivers/clk/clk-sc[mp]i.c
1557515575
F: drivers/cpufreq/sc[mp]i-cpufreq.c
1557615576
F: drivers/firmware/arm_scpi.c
1557715577
F: drivers/firmware/arm_scmi/
15578+
F: drivers/reset/reset-scmi.c
1557815579
F: include/linux/sc[mp]i_protocol.h
1557915580

1558015581
SYSTEM RESET/SHUTDOWN DRIVERS

drivers/clk/clk-scmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate,
6969
{
7070
struct scmi_clk *clk = to_scmi_clk(hw);
7171

72-
return clk->handle->clk_ops->rate_set(clk->handle, clk->id, 0, rate);
72+
return clk->handle->clk_ops->rate_set(clk->handle, clk->id, rate);
7373
}
7474

7575
static int scmi_clk_enable(struct clk_hw *hw)

drivers/firmware/arm_scmi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
obj-y = scmi-bus.o scmi-driver.o scmi-protocols.o
33
scmi-bus-y = bus.o
44
scmi-driver-y = driver.o
5-
scmi-protocols-y = base.o clock.o perf.o power.o sensors.o
5+
scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o
66
obj-$(CONFIG_ARM_SCMI_POWER_DOMAIN) += scmi_pm_domain.o

drivers/firmware/arm_scmi/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static int scmi_base_discover_agent_get(const struct scmi_handle *handle,
204204
if (ret)
205205
return ret;
206206

207-
*(__le32 *)t->tx.buf = cpu_to_le32(id);
207+
put_unaligned_le32(id, t->tx.buf);
208208

209209
ret = scmi_do_xfer(handle, t);
210210
if (!ret)

drivers/firmware/arm_scmi/clock.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct scmi_msg_resp_clock_describe_rates {
5656
struct scmi_clock_set_rate {
5757
__le32 flags;
5858
#define CLOCK_SET_ASYNC BIT(0)
59-
#define CLOCK_SET_DELAYED BIT(1)
59+
#define CLOCK_SET_IGNORE_RESP BIT(1)
6060
#define CLOCK_SET_ROUND_UP BIT(2)
6161
#define CLOCK_SET_ROUND_AUTO BIT(3)
6262
__le32 id;
@@ -67,6 +67,7 @@ struct scmi_clock_set_rate {
6767
struct clock_info {
6868
int num_clocks;
6969
int max_async_req;
70+
atomic_t cur_async_req;
7071
struct scmi_clock_info *clk;
7172
};
7273

@@ -106,7 +107,7 @@ static int scmi_clock_attributes_get(const struct scmi_handle *handle,
106107
if (ret)
107108
return ret;
108109

109-
*(__le32 *)t->tx.buf = cpu_to_le32(clk_id);
110+
put_unaligned_le32(clk_id, t->tx.buf);
110111
attr = t->rx.buf;
111112

112113
ret = scmi_do_xfer(handle, t);
@@ -203,39 +204,47 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value)
203204
if (ret)
204205
return ret;
205206

206-
*(__le32 *)t->tx.buf = cpu_to_le32(clk_id);
207+
put_unaligned_le32(clk_id, t->tx.buf);
207208

208209
ret = scmi_do_xfer(handle, t);
209-
if (!ret) {
210-
__le32 *pval = t->rx.buf;
211-
212-
*value = le32_to_cpu(*pval);
213-
*value |= (u64)le32_to_cpu(*(pval + 1)) << 32;
214-
}
210+
if (!ret)
211+
*value = get_unaligned_le64(t->rx.buf);
215212

216213
scmi_xfer_put(handle, t);
217214
return ret;
218215
}
219216

220217
static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id,
221-
u32 config, u64 rate)
218+
u64 rate)
222219
{
223220
int ret;
221+
u32 flags = 0;
224222
struct scmi_xfer *t;
225223
struct scmi_clock_set_rate *cfg;
224+
struct clock_info *ci = handle->clk_priv;
226225

227226
ret = scmi_xfer_get_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK,
228227
sizeof(*cfg), 0, &t);
229228
if (ret)
230229
return ret;
231230

231+
if (ci->max_async_req &&
232+
atomic_inc_return(&ci->cur_async_req) < ci->max_async_req)
233+
flags |= CLOCK_SET_ASYNC;
234+
232235
cfg = t->tx.buf;
233-
cfg->flags = cpu_to_le32(config);
236+
cfg->flags = cpu_to_le32(flags);
234237
cfg->id = cpu_to_le32(clk_id);
235238
cfg->value_low = cpu_to_le32(rate & 0xffffffff);
236239
cfg->value_high = cpu_to_le32(rate >> 32);
237240

238-
ret = scmi_do_xfer(handle, t);
241+
if (flags & CLOCK_SET_ASYNC)
242+
ret = scmi_do_xfer_with_response(handle, t);
243+
else
244+
ret = scmi_do_xfer(handle, t);
245+
246+
if (ci->max_async_req)
247+
atomic_dec(&ci->cur_async_req);
239248

240249
scmi_xfer_put(handle, t);
241250
return ret;

drivers/firmware/arm_scmi/common.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <linux/scmi_protocol.h>
1616
#include <linux/types.h>
1717

18+
#include <asm/unaligned.h>
19+
1820
#define PROTOCOL_REV_MINOR_MASK GENMASK(15, 0)
1921
#define PROTOCOL_REV_MAJOR_MASK GENMASK(31, 16)
2022
#define PROTOCOL_REV_MAJOR(x) (u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x)))
@@ -48,11 +50,11 @@ struct scmi_msg_resp_prot_version {
4850
/**
4951
* struct scmi_msg_hdr - Message(Tx/Rx) header
5052
*
51-
* @id: The identifier of the command being sent
52-
* @protocol_id: The identifier of the protocol used to send @id command
53-
* @seq: The token to identify the message. when a message/command returns,
54-
* the platform returns the whole message header unmodified including
55-
* the token
53+
* @id: The identifier of the message being sent
54+
* @protocol_id: The identifier of the protocol used to send @id message
55+
* @seq: The token to identify the message. When a message returns, the
56+
* platform returns the whole message header unmodified including the
57+
* token
5658
* @status: Status of the transfer once it's complete
5759
* @poll_completion: Indicate if the transfer needs to be polled for
5860
* completion or interrupt mode is used
@@ -84,17 +86,21 @@ struct scmi_msg {
8486
* @rx: Receive message, the buffer should be pre-allocated to store
8587
* message. If request-ACK protocol is used, we can reuse the same
8688
* buffer for the rx path as we use for the tx path.
87-
* @done: completion event
89+
* @done: command message transmit completion event
90+
* @async: pointer to delayed response message received event completion
8891
*/
8992
struct scmi_xfer {
9093
struct scmi_msg_hdr hdr;
9194
struct scmi_msg tx;
9295
struct scmi_msg rx;
9396
struct completion done;
97+
struct completion *async_done;
9498
};
9599

96100
void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
97101
int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
102+
int scmi_do_xfer_with_response(const struct scmi_handle *h,
103+
struct scmi_xfer *xfer);
98104
int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id,
99105
size_t tx_size, size_t rx_size, struct scmi_xfer **p);
100106
int scmi_handle_put(const struct scmi_handle *handle);

0 commit comments

Comments
 (0)