Skip to content

Commit 4fa62e8

Browse files
MrVanShawn Guo
authored andcommitted
firmware: arm_scmi: imx: Support getting syslog of MISC protocol
MISC protocol supports getting system log regarding system sleep latency, wakeup interrupt and etc. Add the API for user to retrieve the information from SM. Signed-off-by: Peng Fan <peng.fan@nxp.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
1 parent 8f0b4cc commit 4fa62e8

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum scmi_imx_misc_protocol_cmd {
2828
SCMI_IMX_MISC_DISCOVER_BUILD_INFO = 0x6,
2929
SCMI_IMX_MISC_CTRL_NOTIFY = 0x8,
3030
SCMI_IMX_MISC_CFG_INFO_GET = 0xC,
31+
SCMI_IMX_MISC_SYSLOG_GET = 0xD,
3132
SCMI_IMX_MISC_BOARD_INFO = 0xE,
3233
};
3334

@@ -89,6 +90,19 @@ struct scmi_imx_misc_cfg_info_out {
8990
u8 cfgname[MISC_MAX_CFGNAME];
9091
};
9192

93+
struct scmi_imx_misc_syslog_in {
94+
__le32 flags;
95+
__le32 index;
96+
};
97+
98+
#define REMAINING(x) le32_get_bits((x), GENMASK(31, 20))
99+
#define RETURNED(x) le32_get_bits((x), GENMASK(11, 0))
100+
101+
struct scmi_imx_misc_syslog_out {
102+
__le32 numlogflags;
103+
__le32 syslog[];
104+
};
105+
92106
static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph,
93107
struct scmi_imx_misc_info *mi)
94108
{
@@ -371,10 +385,79 @@ static int scmi_imx_misc_cfg_info_get(const struct scmi_protocol_handle *ph)
371385
return ret;
372386
}
373387

388+
struct scmi_imx_misc_syslog_ipriv {
389+
u32 *array;
390+
u16 *size;
391+
};
392+
393+
static void iter_misc_syslog_prepare_message(void *message, u32 desc_index,
394+
const void *priv)
395+
{
396+
struct scmi_imx_misc_syslog_in *msg = message;
397+
398+
msg->flags = cpu_to_le32(0);
399+
msg->index = cpu_to_le32(desc_index);
400+
}
401+
402+
static int iter_misc_syslog_update_state(struct scmi_iterator_state *st,
403+
const void *response, void *priv)
404+
{
405+
const struct scmi_imx_misc_syslog_out *r = response;
406+
struct scmi_imx_misc_syslog_ipriv *p = priv;
407+
408+
st->num_returned = RETURNED(r->numlogflags);
409+
st->num_remaining = REMAINING(r->numlogflags);
410+
*p->size = st->num_returned + st->num_remaining;
411+
412+
return 0;
413+
}
414+
415+
static int
416+
iter_misc_syslog_process_response(const struct scmi_protocol_handle *ph,
417+
const void *response,
418+
struct scmi_iterator_state *st, void *priv)
419+
{
420+
const struct scmi_imx_misc_syslog_out *r = response;
421+
struct scmi_imx_misc_syslog_ipriv *p = priv;
422+
423+
p->array[st->desc_index + st->loop_idx] =
424+
le32_to_cpu(r->syslog[st->loop_idx]);
425+
426+
return 0;
427+
}
428+
429+
static int scmi_imx_misc_syslog_get(const struct scmi_protocol_handle *ph, u16 *size,
430+
void *array)
431+
{
432+
struct scmi_iterator_ops ops = {
433+
.prepare_message = iter_misc_syslog_prepare_message,
434+
.update_state = iter_misc_syslog_update_state,
435+
.process_response = iter_misc_syslog_process_response,
436+
};
437+
struct scmi_imx_misc_syslog_ipriv ipriv = {
438+
.array = array,
439+
.size = size,
440+
};
441+
void *iter;
442+
443+
if (!array || !size || !*size)
444+
return -EINVAL;
445+
446+
iter = ph->hops->iter_response_init(ph, &ops, *size, SCMI_IMX_MISC_SYSLOG_GET,
447+
sizeof(struct scmi_imx_misc_syslog_in),
448+
&ipriv);
449+
if (IS_ERR(iter))
450+
return PTR_ERR(iter);
451+
452+
/* If firmware return NOT SUPPORTED, propagate value to caller */
453+
return ph->hops->iter_response_run(iter);
454+
}
455+
374456
static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = {
375457
.misc_ctrl_set = scmi_imx_misc_ctrl_set,
376458
.misc_ctrl_get = scmi_imx_misc_ctrl_get,
377459
.misc_ctrl_req_notify = scmi_imx_misc_ctrl_notify,
460+
.misc_syslog = scmi_imx_misc_syslog_get,
378461
};
379462

380463
static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph)

include/linux/scmi_imx_protocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct scmi_imx_misc_proto_ops {
5959
u32 *num, u32 *val);
6060
int (*misc_ctrl_req_notify)(const struct scmi_protocol_handle *ph,
6161
u32 ctrl_id, u32 evt_id, u32 flags);
62+
int (*misc_syslog)(const struct scmi_protocol_handle *ph, u16 *size,
63+
void *array);
6264
};
6365

6466
/* See LMM_ATTRIBUTES in imx95.rst */

0 commit comments

Comments
 (0)