blob: eff209b54825c552e9be1b011e436a7f70aa5f0d [file] [log] [blame]
developera5569782022-05-06 11:04:59 +08001--- a/drivers/crypto/inside-secure/safexcel.c
2+++ b/drivers/crypto/inside-secure/safexcel.c
3@@ -304,6 +304,11 @@
4 /* Enable access to all IFPP program memories */
5 writel(EIP197_PE_ICE_RAM_CTRL_FPP_PROG_EN,
6 EIP197_PE(priv) + EIP197_PE_ICE_RAM_CTRL(pe));
7+
8+ /* bypass the OCE, if present */
9+ if (priv->flags & EIP197_OCE)
10+ writel(EIP197_DEBUG_OCE_BYPASS, EIP197_PE(priv) +
11+ EIP197_PE_DEBUG(pe));
12 }
13
14 }
developer720571a2022-10-12 14:24:17 +080015@@ -403,13 +408,13 @@
16 const struct firmware *fw[FW_NB];
17 char fw_path[37], *dir = NULL;
18 int i, j, ret = 0, pe;
19- int ipuesz, ifppsz, minifw = 0;
20+ int ipuesz, ifppsz, minifw = 1;
21
22 if (priv->version == EIP197D_MRVL)
developera5569782022-05-06 11:04:59 +080023 dir = "eip197d";
24 else if (priv->version == EIP197B_MRVL ||
25 priv->version == EIP197_DEVBRD)
26- dir = "eip197b";
27+ dir = "eip197_minifw";
28 else
29 return -ENODEV;
30
developer720571a2022-10-12 14:24:17 +080031@@ -592,6 +597,11 @@
32 */
33 if (priv->flags & SAFEXCEL_HW_EIP197) {
34 val = readl(EIP197_HIA_AIC(priv) + EIP197_HIA_MST_CTRL);
35+ /* Clear axi_burst_size and rx_burst_size */
36+ val &= 0xffffff00;
37+ /* Set axi_burst_size = 3, rx_burst_size = 3 */
38+ val |= EIP197_MST_CTRL_RD_CACHE(3);
39+ val |= EIP197_MST_CTRL_WD_CACHE(3);
40 val |= EIP197_MST_CTRL_TX_MAX_CMD(5);
41 writel(val, EIP197_HIA_AIC(priv) + EIP197_HIA_MST_CTRL);
42 }
43@@ -792,6 +802,12 @@
developera5569782022-05-06 11:04:59 +080044 return ret;
45 }
46
47+ /* Allow clocks to be forced on for EIP197 */
48+ if (priv->flags & SAFEXCEL_HW_EIP197) {
49+ writel(0xffffffff, EIP197_HIA_GEN_CFG(priv) + EIP197_FORCE_CLOCK_ON);
50+ writel(0xffffffff, EIP197_HIA_GEN_CFG(priv) + EIP197_FORCE_CLOCK_ON2);
51+ }
52+
53 return safexcel_hw_setup_cdesc_rings(priv) ?:
54 safexcel_hw_setup_rdesc_rings(priv) ?:
55 0;
developer720571a2022-10-12 14:24:17 +080056@@ -1498,6 +1514,9 @@
developera5569782022-05-06 11:04:59 +080057 hwopt = readl(EIP197_GLOBAL(priv) + EIP197_OPTIONS);
58 hiaopt = readl(EIP197_HIA_AIC(priv) + EIP197_HIA_OPTIONS);
59
60+ priv->hwconfig.icever = 0;
61+ priv->hwconfig.ocever = 0;
62+ priv->hwconfig.psever = 0;
63 if (priv->flags & SAFEXCEL_HW_EIP197) {
64 /* EIP197 */
65 peopt = readl(EIP197_PE(priv) + EIP197_PE_OPTIONS(0));
developer720571a2022-10-12 14:24:17 +080066@@ -1516,8 +1535,37 @@
developera5569782022-05-06 11:04:59 +080067 EIP197_N_RINGS_MASK;
68 if (hiaopt & EIP197_HIA_OPT_HAS_PE_ARB)
69 priv->flags |= EIP197_PE_ARB;
70- if (EIP206_OPT_ICE_TYPE(peopt) == 1)
71+ if (EIP206_OPT_ICE_TYPE(peopt) == 1) {
72 priv->flags |= EIP197_ICE;
73+ /* Detect ICE EIP207 class. engine and version */
74+ version = readl(EIP197_PE(priv) +
75+ EIP197_PE_ICE_VERSION(0));
76+ if (EIP197_REG_LO16(version) != EIP207_VERSION_LE) {
77+ dev_err(dev, "EIP%d: ICE EIP207 not detected.\n",
78+ peid);
79+ return -ENODEV;
80+ }
81+ priv->hwconfig.icever = EIP197_VERSION_MASK(version);
82+ }
83+ if (EIP206_OPT_OCE_TYPE(peopt) == 1) {
84+ priv->flags |= EIP197_OCE;
85+ /* Detect EIP96PP packet stream editor and version */
86+ version = readl(EIP197_PE(priv) + EIP197_PE_PSE_VERSION(0));
87+ if (EIP197_REG_LO16(version) != EIP96_VERSION_LE) {
88+ dev_err(dev, "EIP%d: EIP96PP not detected.\n", peid);
89+ return -ENODEV;
90+ }
91+ priv->hwconfig.psever = EIP197_VERSION_MASK(version);
92+ /* Detect OCE EIP207 class. engine and version */
93+ version = readl(EIP197_PE(priv) +
94+ EIP197_PE_ICE_VERSION(0));
95+ if (EIP197_REG_LO16(version) != EIP207_VERSION_LE) {
96+ dev_err(dev, "EIP%d: OCE EIP207 not detected.\n",
97+ peid);
98+ return -ENODEV;
99+ }
100+ priv->hwconfig.ocever = EIP197_VERSION_MASK(version);
101+ }
102 /* If not a full TRC, then assume simple TRC */
103 if (!(hwopt & EIP197_OPT_HAS_TRC))
104 priv->flags |= EIP197_SIMPLE_TRC;
developer720571a2022-10-12 14:24:17 +0800105@@ -1555,13 +1603,14 @@
developera5569782022-05-06 11:04:59 +0800106 EIP197_PE_EIP96_OPTIONS(0));
107
108 /* Print single info line describing what we just detected */
109- dev_info(priv->dev, "EIP%d:%x(%d,%d,%d,%d)-HIA:%x(%d,%d,%d),PE:%x/%x,alg:%08x\n",
110+ dev_info(priv->dev, "EIP%d:%x(%d,%d,%d,%d)-HIA:%x(%d,%d,%d),PE:%x/%x(alg:%08x)/%x/%x/%x\n",
111 peid, priv->hwconfig.hwver, hwctg, priv->hwconfig.hwnumpes,
112 priv->hwconfig.hwnumrings, priv->hwconfig.hwnumraic,
113 priv->hwconfig.hiaver, priv->hwconfig.hwdataw,
114 priv->hwconfig.hwcfsize, priv->hwconfig.hwrfsize,
115 priv->hwconfig.ppver, priv->hwconfig.pever,
116- priv->hwconfig.algo_flags);
117+ priv->hwconfig.algo_flags, priv->hwconfig.icever,
118+ priv->hwconfig.ocever, priv->hwconfig.psever);
119
120 safexcel_configure(priv);
121
developer720571a2022-10-12 14:24:17 +0800122@@ -1690,6 +1739,7 @@
developera5569782022-05-06 11:04:59 +0800123 {
124 struct device *dev = &pdev->dev;
125 struct safexcel_crypto_priv *priv;
126+ struct resource *res;
127 int ret;
128
129 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
developer720571a2022-10-12 14:24:17 +0800130@@ -1701,7 +1751,11 @@
developera5569782022-05-06 11:04:59 +0800131
132 platform_set_drvdata(pdev, priv);
133
134- priv->base = devm_platform_ioremap_resource(pdev, 0);
135+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
136+ if (!res)
137+ return -EINVAL;
138+
139+ priv->base = devm_ioremap(dev, res->start, resource_size(res));
140 if (IS_ERR(priv->base)) {
141 dev_err(dev, "failed to get resource\n");
142 return PTR_ERR(priv->base);
143--- a/drivers/crypto/inside-secure/safexcel.h
144+++ b/drivers/crypto/inside-secure/safexcel.h
145@@ -22,6 +22,7 @@
146 #define EIP96_VERSION_LE 0x9f60
147 #define EIP201_VERSION_LE 0x36c9
148 #define EIP206_VERSION_LE 0x31ce
149+#define EIP207_VERSION_LE 0x30cf
150 #define EIP197_REG_LO16(reg) (reg & 0xffff)
151 #define EIP197_REG_HI16(reg) ((reg >> 16) & 0xffff)
152 #define EIP197_VERSION_MASK(reg) ((reg >> 16) & 0xfff)
153@@ -34,6 +35,7 @@
154
155 /* EIP206 OPTIONS ENCODING */
156 #define EIP206_OPT_ICE_TYPE(n) ((n>>8)&3)
157+#define EIP206_OPT_OCE_TYPE(n) ((n>>10)&3)
158
159 /* EIP197 OPTIONS ENCODING */
160 #define EIP197_OPT_HAS_TRC BIT(31)
161@@ -168,6 +170,7 @@
162 #define EIP197_PE_ICE_FPP_CTRL(n) (0x0d80 + (0x2000 * (n)))
163 #define EIP197_PE_ICE_PPTF_CTRL(n) (0x0e00 + (0x2000 * (n)))
164 #define EIP197_PE_ICE_RAM_CTRL(n) (0x0ff0 + (0x2000 * (n)))
165+#define EIP197_PE_ICE_VERSION(n) (0x0ffc + (0x2000 * (n)))
166 #define EIP197_PE_EIP96_TOKEN_CTRL(n) (0x1000 + (0x2000 * (n)))
167 #define EIP197_PE_EIP96_FUNCTION_EN(n) (0x1004 + (0x2000 * (n)))
168 #define EIP197_PE_EIP96_CONTEXT_CTRL(n) (0x1008 + (0x2000 * (n)))
169@@ -176,10 +179,15 @@
170 #define EIP197_PE_EIP96_FUNCTION2_EN(n) (0x1030 + (0x2000 * (n)))
171 #define EIP197_PE_EIP96_OPTIONS(n) (0x13f8 + (0x2000 * (n)))
172 #define EIP197_PE_EIP96_VERSION(n) (0x13fc + (0x2000 * (n)))
173+#define EIP197_PE_OCE_VERSION(n) (0x1bfc + (0x2000 * (n)))
174 #define EIP197_PE_OUT_DBUF_THRES(n) (0x1c00 + (0x2000 * (n)))
175 #define EIP197_PE_OUT_TBUF_THRES(n) (0x1d00 + (0x2000 * (n)))
176+#define EIP197_PE_PSE_VERSION(n) (0x1efc + (0x2000 * (n)))
177+#define EIP197_PE_DEBUG(n) (0x1ff4 + (0x2000 * (n)))
178 #define EIP197_PE_OPTIONS(n) (0x1ff8 + (0x2000 * (n)))
179 #define EIP197_PE_VERSION(n) (0x1ffc + (0x2000 * (n)))
180+#define EIP197_FORCE_CLOCK_ON2 0xffd8
181+#define EIP197_FORCE_CLOCK_ON 0xffe8
182 #define EIP197_MST_CTRL 0xfff4
183 #define EIP197_OPTIONS 0xfff8
184 #define EIP197_VERSION 0xfffc
185@@ -353,6 +361,9 @@
186 /* EIP197_PE_EIP96_TOKEN_CTRL2 */
187 #define EIP197_PE_EIP96_TOKEN_CTRL2_CTX_DONE BIT(3)
188
189+/* EIP197_PE_DEBUG */
190+#define EIP197_DEBUG_OCE_BYPASS BIT(1)
191+
192 /* EIP197_STRC_CONFIG */
193 #define EIP197_STRC_CONFIG_INIT BIT(31)
194 #define EIP197_STRC_CONFIG_LARGE_REC(s) (s<<8)
195@@ -777,6 +788,7 @@
196 EIP197_PE_ARB = BIT(2),
197 EIP197_ICE = BIT(3),
198 EIP197_SIMPLE_TRC = BIT(4),
199+ EIP197_OCE = BIT(5),
200 };
201
202 struct safexcel_hwconfig {
203@@ -784,7 +796,10 @@
204 int hwver;
205 int hiaver;
206 int ppver;
207+ int icever;
208 int pever;
209+ int ocever;
210+ int psever;
211 int hwdataw;
212 int hwcfsize;
213 int hwrfsize;