Skip to content

Commit 5172365

Browse files
Devarsh Thakkarmathieupoirier
authored andcommitted
remoteproc: k3-r5: Use separate compatible string for TI AM62x SoC family
AM62 and AM62A SoCs use single core R5F which is a new scenario different than the one being used with CLUSTER_MODE_SINGLECPU which is for utilizing a single core from a set of cores available in R5F cluster present in the SoC. To support this single core scenario map it with newly defined CLUSTER_MODE_SINGLECORE and use it when compatible is set to ti,am62-r5fss. Also set PROC_BOOT_CFG_FLAG_R5_SINGLE_CORE config for CLUSTER_MODE_SINGLECORE too as it is required by R5 core when it is being as general purpose core instead of device manager. For IPC-only mode when config flag PROC_BOOT_CFG_FLAG_R5_SINGLE_CORE is set, skip overriding to CLUSTER_MODE_SINGLECPU when CLUSTER_MODE_SINGLECORE is set as same flag is applicable for single core configuration too. Signed-off-by: Devarsh Thakkar <devarsht@ti.com> Link: https://lore.kernel.org/r/20230327152832.923480-4-devarsht@ti.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent f3d81b4 commit 5172365

1 file changed

Lines changed: 47 additions & 12 deletions

File tree

drivers/remoteproc/ti_k3_r5_remoteproc.c

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,30 @@ struct k3_r5_mem {
7171
/*
7272
* All cluster mode values are not applicable on all SoCs. The following
7373
* are the modes supported on various SoCs:
74-
* Split mode : AM65x, J721E, J7200 and AM64x SoCs
75-
* LockStep mode : AM65x, J721E and J7200 SoCs
76-
* Single-CPU mode : AM64x SoCs only
74+
* Split mode : AM65x, J721E, J7200 and AM64x SoCs
75+
* LockStep mode : AM65x, J721E and J7200 SoCs
76+
* Single-CPU mode : AM64x SoCs only
77+
* Single-Core mode : AM62x, AM62A SoCs
7778
*/
7879
enum cluster_mode {
7980
CLUSTER_MODE_SPLIT = 0,
8081
CLUSTER_MODE_LOCKSTEP,
8182
CLUSTER_MODE_SINGLECPU,
83+
CLUSTER_MODE_SINGLECORE
8284
};
8385

8486
/**
8587
* struct k3_r5_soc_data - match data to handle SoC variations
8688
* @tcm_is_double: flag to denote the larger unified TCMs in certain modes
8789
* @tcm_ecc_autoinit: flag to denote the auto-initialization of TCMs for ECC
8890
* @single_cpu_mode: flag to denote if SoC/IP supports Single-CPU mode
91+
* @is_single_core: flag to denote if SoC/IP has only single core R5
8992
*/
9093
struct k3_r5_soc_data {
9194
bool tcm_is_double;
9295
bool tcm_ecc_autoinit;
9396
bool single_cpu_mode;
97+
bool is_single_core;
9498
};
9599

96100
/**
@@ -838,7 +842,8 @@ static int k3_r5_rproc_configure(struct k3_r5_rproc *kproc)
838842

839843
core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem);
840844
if (cluster->mode == CLUSTER_MODE_LOCKSTEP ||
841-
cluster->mode == CLUSTER_MODE_SINGLECPU) {
845+
cluster->mode == CLUSTER_MODE_SINGLECPU ||
846+
cluster->mode == CLUSTER_MODE_SINGLECORE) {
842847
core = core0;
843848
} else {
844849
core = kproc->core;
@@ -877,7 +882,8 @@ static int k3_r5_rproc_configure(struct k3_r5_rproc *kproc)
877882
* with the bit configured, so program it only on
878883
* permitted cores
879884
*/
880-
if (cluster->mode == CLUSTER_MODE_SINGLECPU) {
885+
if (cluster->mode == CLUSTER_MODE_SINGLECPU ||
886+
cluster->mode == CLUSTER_MODE_SINGLECORE) {
881887
set_cfg = PROC_BOOT_CFG_FLAG_R5_SINGLE_CORE;
882888
} else {
883889
/*
@@ -1069,6 +1075,7 @@ static void k3_r5_adjust_tcm_sizes(struct k3_r5_rproc *kproc)
10691075

10701076
if (cluster->mode == CLUSTER_MODE_LOCKSTEP ||
10711077
cluster->mode == CLUSTER_MODE_SINGLECPU ||
1078+
cluster->mode == CLUSTER_MODE_SINGLECORE ||
10721079
!cluster->soc_data->tcm_is_double)
10731080
return;
10741081

@@ -1145,7 +1152,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
11451152
single_cpu = cfg & PROC_BOOT_CFG_FLAG_R5_SINGLE_CORE ? 1 : 0;
11461153
lockstep_en = cfg & PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ? 1 : 0;
11471154

1148-
if (single_cpu)
1155+
if (single_cpu && mode != CLUSTER_MODE_SINGLECORE)
11491156
mode = CLUSTER_MODE_SINGLECPU;
11501157
if (lockstep_en)
11511158
mode = CLUSTER_MODE_LOCKSTEP;
@@ -1265,9 +1272,12 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)
12651272
goto err_add;
12661273
}
12671274

1268-
/* create only one rproc in lockstep mode or single-cpu mode */
1275+
/* create only one rproc in lockstep, single-cpu or
1276+
* single core mode
1277+
*/
12691278
if (cluster->mode == CLUSTER_MODE_LOCKSTEP ||
1270-
cluster->mode == CLUSTER_MODE_SINGLECPU)
1279+
cluster->mode == CLUSTER_MODE_SINGLECPU ||
1280+
cluster->mode == CLUSTER_MODE_SINGLECORE)
12711281
break;
12721282
}
12731283

@@ -1710,19 +1720,33 @@ static int k3_r5_probe(struct platform_device *pdev)
17101720
/*
17111721
* default to most common efuse configurations - Split-mode on AM64x
17121722
* and LockStep-mode on all others
1723+
* default to most common efuse configurations -
1724+
* Split-mode on AM64x
1725+
* Single core on AM62x
1726+
* LockStep-mode on all others
17131727
*/
1714-
cluster->mode = data->single_cpu_mode ?
1728+
if (!data->is_single_core)
1729+
cluster->mode = data->single_cpu_mode ?
17151730
CLUSTER_MODE_SPLIT : CLUSTER_MODE_LOCKSTEP;
1731+
else
1732+
cluster->mode = CLUSTER_MODE_SINGLECORE;
17161733
}
17171734

1718-
if (cluster->mode == CLUSTER_MODE_SINGLECPU && !data->single_cpu_mode) {
1735+
if ((cluster->mode == CLUSTER_MODE_SINGLECPU && !data->single_cpu_mode) ||
1736+
(cluster->mode == CLUSTER_MODE_SINGLECORE && !data->is_single_core)) {
17191737
dev_err(dev, "Cluster mode = %d is not supported on this SoC\n", cluster->mode);
17201738
return -EINVAL;
17211739
}
17221740

17231741
num_cores = of_get_available_child_count(np);
1724-
if (num_cores != 2) {
1725-
dev_err(dev, "MCU cluster requires both R5F cores to be enabled, num_cores = %d\n",
1742+
if (num_cores != 2 && !data->is_single_core) {
1743+
dev_err(dev, "MCU cluster requires both R5F cores to be enabled but num_cores is set to = %d\n",
1744+
num_cores);
1745+
return -ENODEV;
1746+
}
1747+
1748+
if (num_cores != 1 && data->is_single_core) {
1749+
dev_err(dev, "SoC supports only single core R5 but num_cores is set to %d\n",
17261750
num_cores);
17271751
return -ENODEV;
17281752
}
@@ -1764,25 +1788,36 @@ static const struct k3_r5_soc_data am65_j721e_soc_data = {
17641788
.tcm_is_double = false,
17651789
.tcm_ecc_autoinit = false,
17661790
.single_cpu_mode = false,
1791+
.is_single_core = false,
17671792
};
17681793

17691794
static const struct k3_r5_soc_data j7200_j721s2_soc_data = {
17701795
.tcm_is_double = true,
17711796
.tcm_ecc_autoinit = true,
17721797
.single_cpu_mode = false,
1798+
.is_single_core = false,
17731799
};
17741800

17751801
static const struct k3_r5_soc_data am64_soc_data = {
17761802
.tcm_is_double = true,
17771803
.tcm_ecc_autoinit = true,
17781804
.single_cpu_mode = true,
1805+
.is_single_core = false,
1806+
};
1807+
1808+
static const struct k3_r5_soc_data am62_soc_data = {
1809+
.tcm_is_double = false,
1810+
.tcm_ecc_autoinit = true,
1811+
.single_cpu_mode = false,
1812+
.is_single_core = true,
17791813
};
17801814

17811815
static const struct of_device_id k3_r5_of_match[] = {
17821816
{ .compatible = "ti,am654-r5fss", .data = &am65_j721e_soc_data, },
17831817
{ .compatible = "ti,j721e-r5fss", .data = &am65_j721e_soc_data, },
17841818
{ .compatible = "ti,j7200-r5fss", .data = &j7200_j721s2_soc_data, },
17851819
{ .compatible = "ti,am64-r5fss", .data = &am64_soc_data, },
1820+
{ .compatible = "ti,am62-r5fss", .data = &am62_soc_data, },
17861821
{ .compatible = "ti,j721s2-r5fss", .data = &j7200_j721s2_soc_data, },
17871822
{ /* sentinel */ },
17881823
};

0 commit comments

Comments
 (0)