Skip to content

Commit fcd382b

Browse files
MrVanmathieupoirier
authored andcommitted
remoteproc: imx_rproc: Support i.MX8QM
Most logic are same as i.MX8QXP, but i.MX8QM has two general purpose M4 cores, the two cores runs independently and they have different resource id, different start address from SCFW view. Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent c94ea66 commit fcd382b

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

drivers/remoteproc/imx_rproc.c

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2017 Pengutronix, Oleksij Rempel <[email protected]>
44
*/
55

6+
#include <dt-bindings/firmware/imx/rsrc.h>
67
#include <linux/arm-smccc.h>
78
#include <linux/clk.h>
89
#include <linux/err.h>
@@ -75,10 +76,13 @@ struct imx_rproc_mem {
7576
size_t size;
7677
};
7778

78-
/* att flags */
79+
/* att flags: lower 16 bits specifying core, higher 16 bits for flags */
7980
/* M4 own area. Can be mapped at probe */
80-
#define ATT_OWN BIT(1)
81-
#define ATT_IOMEM BIT(2)
81+
#define ATT_OWN BIT(31)
82+
#define ATT_IOMEM BIT(30)
83+
84+
#define ATT_CORE_MASK 0xffff
85+
#define ATT_CORE(I) BIT((I))
8286

8387
static int imx_rproc_detach_pd(struct rproc *rproc);
8488

@@ -101,6 +105,7 @@ struct imx_rproc {
101105
u32 rsrc_id; /* resource id */
102106
u32 entry; /* cpu start address */
103107
int num_pd;
108+
u32 core_index;
104109
struct device **pd_dev;
105110
struct device_link **pd_dev_link;
106111
};
@@ -131,6 +136,19 @@ static const struct imx_rproc_att imx_rproc_att_imx93[] = {
131136
{ 0xD0000000, 0xa0000000, 0x10000000, 0 },
132137
};
133138

139+
static const struct imx_rproc_att imx_rproc_att_imx8qm[] = {
140+
/* dev addr , sys addr , size , flags */
141+
{ 0x08000000, 0x08000000, 0x10000000, 0},
142+
/* TCML */
143+
{ 0x1FFE0000, 0x34FE0000, 0x00020000, ATT_OWN | ATT_IOMEM | ATT_CORE(0)},
144+
{ 0x1FFE0000, 0x38FE0000, 0x00020000, ATT_OWN | ATT_IOMEM | ATT_CORE(1)},
145+
/* TCMU */
146+
{ 0x20000000, 0x35000000, 0x00020000, ATT_OWN | ATT_IOMEM | ATT_CORE(0)},
147+
{ 0x20000000, 0x39000000, 0x00020000, ATT_OWN | ATT_IOMEM | ATT_CORE(1)},
148+
/* DDR (Data) */
149+
{ 0x80000000, 0x80000000, 0x60000000, 0 },
150+
};
151+
134152
static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = {
135153
{ 0x08000000, 0x08000000, 0x10000000, 0 },
136154
/* TCML/U */
@@ -281,6 +299,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
281299
.method = IMX_RPROC_MMIO,
282300
};
283301

302+
static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qm = {
303+
.att = imx_rproc_att_imx8qm,
304+
.att_size = ARRAY_SIZE(imx_rproc_att_imx8qm),
305+
.method = IMX_RPROC_SCU_API,
306+
};
307+
284308
static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = {
285309
.att = imx_rproc_att_imx8qxp,
286310
.att_size = ARRAY_SIZE(imx_rproc_att_imx8qxp),
@@ -397,6 +421,17 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,
397421
for (i = 0; i < dcfg->att_size; i++) {
398422
const struct imx_rproc_att *att = &dcfg->att[i];
399423

424+
/*
425+
* Ignore entries not belong to current core:
426+
* i.MX8QM has dual general M4_[0,1] cores, M4_0's own entries
427+
* has "ATT_CORE(0) & BIT(0)" true, M4_1's own entries has
428+
* "ATT_CORE(1) & BIT(1)" true.
429+
*/
430+
if (att->flags & ATT_CORE_MASK) {
431+
if (!((BIT(priv->core_index)) & (att->flags & ATT_CORE_MASK)))
432+
continue;
433+
}
434+
400435
if (da >= att->da && da + len < att->da + att->size) {
401436
unsigned int offset = da - att->da;
402437

@@ -852,6 +887,11 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
852887
return ret;
853888
}
854889

890+
if (priv->rsrc_id == IMX_SC_R_M4_1_PID0)
891+
priv->core_index = 1;
892+
else
893+
priv->core_index = 0;
894+
855895
/*
856896
* If Mcore resource is not owned by Acore partition, It is kicked by ROM,
857897
* and Linux could only do IPC with Mcore and nothing else.
@@ -1048,6 +1088,7 @@ static const struct of_device_id imx_rproc_of_match[] = {
10481088
{ .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn },
10491089
{ .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn },
10501090
{ .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp },
1091+
{ .compatible = "fsl,imx8qm-cm4", .data = &imx_rproc_cfg_imx8qm },
10511092
{ .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp },
10521093
{ .compatible = "fsl,imx93-cm33", .data = &imx_rproc_cfg_imx93 },
10531094
{},

0 commit comments

Comments
 (0)