Skip to content

Commit 51da14e

Browse files
IoanaCiorneiLi Yang
authored andcommitted
soc: fsl: dpio: configure cache stashing destination
Depending on the SoC version and the CPU id, configure the cache stashing destination for a specific dpio. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: Li Yang <leoyang.li@nxp.com>
1 parent 390bf02 commit 51da14e

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

drivers/soc/fsl/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ config FSL_GUTS
2222
config FSL_MC_DPIO
2323
tristate "QorIQ DPAA2 DPIO driver"
2424
depends on FSL_MC_BUS
25+
select SOC_BUS
2526
help
2627
Driver for the DPAA2 DPIO object. A DPIO provides queue and
2728
buffer management facilities for software to interact with

drivers/soc/fsl/dpio/dpio-cmd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define DPIO_CMDID_DISABLE DPIO_CMD(0x003)
2727
#define DPIO_CMDID_GET_ATTR DPIO_CMD(0x004)
2828
#define DPIO_CMDID_RESET DPIO_CMD(0x005)
29+
#define DPIO_CMDID_SET_STASHING_DEST DPIO_CMD(0x120)
2930

3031
struct dpio_cmd_open {
3132
__le32 dpio_id;
@@ -47,4 +48,8 @@ struct dpio_rsp_get_attr {
4748
__le32 qbman_version;
4849
};
4950

51+
struct dpio_stashing_dest {
52+
u8 sdest;
53+
};
54+
5055
#endif /* _FSL_DPIO_CMD_H */

drivers/soc/fsl/dpio/dpio-driver.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/dma-mapping.h>
1515
#include <linux/delay.h>
1616
#include <linux/io.h>
17+
#include <linux/sys_soc.h>
1718

1819
#include <linux/fsl/mc.h>
1920
#include <soc/fsl/dpaa2-io.h>
@@ -32,6 +33,46 @@ struct dpio_priv {
3233

3334
static cpumask_var_t cpus_unused_mask;
3435

36+
static const struct soc_device_attribute ls1088a_soc[] = {
37+
{.family = "QorIQ LS1088A"},
38+
{ /* sentinel */ }
39+
};
40+
41+
static const struct soc_device_attribute ls2080a_soc[] = {
42+
{.family = "QorIQ LS2080A"},
43+
{ /* sentinel */ }
44+
};
45+
46+
static const struct soc_device_attribute ls2088a_soc[] = {
47+
{.family = "QorIQ LS2088A"},
48+
{ /* sentinel */ }
49+
};
50+
51+
static const struct soc_device_attribute lx2160a_soc[] = {
52+
{.family = "QorIQ LX2160A"},
53+
{ /* sentinel */ }
54+
};
55+
56+
static int dpaa2_dpio_get_cluster_sdest(struct fsl_mc_device *dpio_dev, int cpu)
57+
{
58+
int cluster_base, cluster_size;
59+
60+
if (soc_device_match(ls1088a_soc)) {
61+
cluster_base = 2;
62+
cluster_size = 4;
63+
} else if (soc_device_match(ls2080a_soc) ||
64+
soc_device_match(ls2088a_soc) ||
65+
soc_device_match(lx2160a_soc)) {
66+
cluster_base = 0;
67+
cluster_size = 2;
68+
} else {
69+
dev_err(&dpio_dev->dev, "unknown SoC version\n");
70+
return -1;
71+
}
72+
73+
return cluster_base + cpu / cluster_size;
74+
}
75+
3576
static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
3677
{
3778
struct device *dev = (struct device *)arg;
@@ -89,6 +130,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
89130
int err = -ENOMEM;
90131
struct device *dev = &dpio_dev->dev;
91132
int possible_next_cpu;
133+
int sdest;
92134

93135
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
94136
if (!priv)
@@ -145,6 +187,16 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
145187
desc.cpu = possible_next_cpu;
146188
cpumask_clear_cpu(possible_next_cpu, cpus_unused_mask);
147189

190+
sdest = dpaa2_dpio_get_cluster_sdest(dpio_dev, desc.cpu);
191+
if (sdest >= 0) {
192+
err = dpio_set_stashing_destination(dpio_dev->mc_io, 0,
193+
dpio_dev->mc_handle,
194+
sdest);
195+
if (err)
196+
dev_err(dev, "dpio_set_stashing_destination failed for cpu%d\n",
197+
desc.cpu);
198+
}
199+
148200
/*
149201
* Set the CENA regs to be the cache inhibited area of the portal to
150202
* avoid coherency issues if a user migrates to another core.

drivers/soc/fsl/dpio/dpio.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,22 @@ int dpio_get_attributes(struct fsl_mc_io *mc_io,
166166
return 0;
167167
}
168168

169+
int dpio_set_stashing_destination(struct fsl_mc_io *mc_io,
170+
u32 cmd_flags,
171+
u16 token,
172+
u8 sdest)
173+
{
174+
struct fsl_mc_command cmd = { 0 };
175+
struct dpio_stashing_dest *dpio_cmd;
176+
177+
cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_STASHING_DEST,
178+
cmd_flags, token);
179+
dpio_cmd = (struct dpio_stashing_dest *)cmd.params;
180+
dpio_cmd->sdest = sdest;
181+
182+
return mc_send_command(mc_io, &cmd);
183+
}
184+
169185
/**
170186
* dpio_get_api_version - Get Data Path I/O API version
171187
* @mc_io: Pointer to MC portal's DPIO object

drivers/soc/fsl/dpio/dpio.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ int dpio_get_attributes(struct fsl_mc_io *mc_io,
7575
u16 token,
7676
struct dpio_attr *attr);
7777

78+
int dpio_set_stashing_destination(struct fsl_mc_io *mc_io,
79+
u32 cmd_flags,
80+
u16 token,
81+
u8 dest);
82+
7883
int dpio_get_api_version(struct fsl_mc_io *mc_io,
7984
u32 cmd_flags,
8085
u16 *major_ver,

0 commit comments

Comments
 (0)