hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/soc/fsl/qe/ucc_slow.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2006 Freescale Semiconductor, Inc. All rights reserved.
34 *
....@@ -6,11 +7,6 @@
67 *
78 * Description:
89 * QE UCC Slow API Set - UCC Slow specific routines implementations.
9
- *
10
- * This program is free software; you can redistribute it and/or modify it
11
- * under the terms of the GNU General Public License as published by the
12
- * Free Software Foundation; either version 2 of the License, or (at your
13
- * option) any later version.
1410 */
1511 #include <linux/kernel.h>
1612 #include <linux/errno.h>
....@@ -76,13 +72,13 @@
7672
7773 void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode)
7874 {
79
- struct ucc_slow *us_regs;
75
+ struct ucc_slow __iomem *us_regs;
8076 u32 gumr_l;
8177
8278 us_regs = uccs->us_regs;
8379
8480 /* Enable reception and/or transmission on this UCC. */
85
- gumr_l = in_be32(&us_regs->gumr_l);
81
+ gumr_l = qe_ioread32be(&us_regs->gumr_l);
8682 if (mode & COMM_DIR_TX) {
8783 gumr_l |= UCC_SLOW_GUMR_L_ENT;
8884 uccs->enabled_tx = 1;
....@@ -91,19 +87,19 @@
9187 gumr_l |= UCC_SLOW_GUMR_L_ENR;
9288 uccs->enabled_rx = 1;
9389 }
94
- out_be32(&us_regs->gumr_l, gumr_l);
90
+ qe_iowrite32be(gumr_l, &us_regs->gumr_l);
9591 }
9692 EXPORT_SYMBOL(ucc_slow_enable);
9793
9894 void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode)
9995 {
100
- struct ucc_slow *us_regs;
96
+ struct ucc_slow __iomem *us_regs;
10197 u32 gumr_l;
10298
10399 us_regs = uccs->us_regs;
104100
105101 /* Disable reception and/or transmission on this UCC. */
106
- gumr_l = in_be32(&us_regs->gumr_l);
102
+ gumr_l = qe_ioread32be(&us_regs->gumr_l);
107103 if (mode & COMM_DIR_TX) {
108104 gumr_l &= ~UCC_SLOW_GUMR_L_ENT;
109105 uccs->enabled_tx = 0;
....@@ -112,7 +108,7 @@
112108 gumr_l &= ~UCC_SLOW_GUMR_L_ENR;
113109 uccs->enabled_rx = 0;
114110 }
115
- out_be32(&us_regs->gumr_l, gumr_l);
111
+ qe_iowrite32be(gumr_l, &us_regs->gumr_l);
116112 }
117113 EXPORT_SYMBOL(ucc_slow_disable);
118114
....@@ -126,7 +122,7 @@
126122 u32 i;
127123 struct ucc_slow __iomem *us_regs;
128124 u32 gumr;
129
- struct qe_bd *bd;
125
+ struct qe_bd __iomem *bd;
130126 u32 id;
131127 u32 command;
132128 int ret = 0;
....@@ -158,6 +154,9 @@
158154 __func__);
159155 return -ENOMEM;
160156 }
157
+ uccs->rx_base_offset = -1;
158
+ uccs->tx_base_offset = -1;
159
+ uccs->us_pram_offset = -1;
161160
162161 /* Fill slow UCC structure */
163162 uccs->us_info = us_info;
....@@ -169,21 +168,14 @@
169168 return -ENOMEM;
170169 }
171170
172
- uccs->saved_uccm = 0;
173
- uccs->p_rx_frame = 0;
174171 us_regs = uccs->us_regs;
175
- uccs->p_ucce = (u16 *) & (us_regs->ucce);
176
- uccs->p_uccm = (u16 *) & (us_regs->uccm);
177
-#ifdef STATISTICS
178
- uccs->rx_frames = 0;
179
- uccs->tx_frames = 0;
180
- uccs->rx_discarded = 0;
181
-#endif /* STATISTICS */
172
+ uccs->p_ucce = &us_regs->ucce;
173
+ uccs->p_uccm = &us_regs->uccm;
182174
183175 /* Get PRAM base */
184176 uccs->us_pram_offset =
185177 qe_muram_alloc(UCC_SLOW_PRAM_SIZE, ALIGNMENT_OF_UCC_SLOW_PRAM);
186
- if (IS_ERR_VALUE(uccs->us_pram_offset)) {
178
+ if (uccs->us_pram_offset < 0) {
187179 printk(KERN_ERR "%s: cannot allocate MURAM for PRAM", __func__);
188180 ucc_slow_free(uccs);
189181 return -ENOMEM;
....@@ -202,7 +194,7 @@
202194 return ret;
203195 }
204196
205
- out_be16(&uccs->us_pram->mrblr, us_info->max_rx_buf_length);
197
+ qe_iowrite16be(us_info->max_rx_buf_length, &uccs->us_pram->mrblr);
206198
207199 INIT_LIST_HEAD(&uccs->confQ);
208200
....@@ -210,10 +202,9 @@
210202 uccs->rx_base_offset =
211203 qe_muram_alloc(us_info->rx_bd_ring_len * sizeof(struct qe_bd),
212204 QE_ALIGNMENT_OF_BD);
213
- if (IS_ERR_VALUE(uccs->rx_base_offset)) {
205
+ if (uccs->rx_base_offset < 0) {
214206 printk(KERN_ERR "%s: cannot allocate %u RX BDs\n", __func__,
215207 us_info->rx_bd_ring_len);
216
- uccs->rx_base_offset = 0;
217208 ucc_slow_free(uccs);
218209 return -ENOMEM;
219210 }
....@@ -221,9 +212,8 @@
221212 uccs->tx_base_offset =
222213 qe_muram_alloc(us_info->tx_bd_ring_len * sizeof(struct qe_bd),
223214 QE_ALIGNMENT_OF_BD);
224
- if (IS_ERR_VALUE(uccs->tx_base_offset)) {
215
+ if (uccs->tx_base_offset < 0) {
225216 printk(KERN_ERR "%s: cannot allocate TX BDs", __func__);
226
- uccs->tx_base_offset = 0;
227217 ucc_slow_free(uccs);
228218 return -ENOMEM;
229219 }
....@@ -232,27 +222,27 @@
232222 bd = uccs->confBd = uccs->tx_bd = qe_muram_addr(uccs->tx_base_offset);
233223 for (i = 0; i < us_info->tx_bd_ring_len - 1; i++) {
234224 /* clear bd buffer */
235
- out_be32(&bd->buf, 0);
225
+ qe_iowrite32be(0, &bd->buf);
236226 /* set bd status and length */
237
- out_be32((u32 *) bd, 0);
227
+ qe_iowrite32be(0, (u32 __iomem *)bd);
238228 bd++;
239229 }
240230 /* for last BD set Wrap bit */
241
- out_be32(&bd->buf, 0);
242
- out_be32((u32 *) bd, cpu_to_be32(T_W));
231
+ qe_iowrite32be(0, &bd->buf);
232
+ qe_iowrite32be(T_W, (u32 __iomem *)bd);
243233
244234 /* Init Rx bds */
245235 bd = uccs->rx_bd = qe_muram_addr(uccs->rx_base_offset);
246236 for (i = 0; i < us_info->rx_bd_ring_len - 1; i++) {
247237 /* set bd status and length */
248
- out_be32((u32*)bd, 0);
238
+ qe_iowrite32be(0, (u32 __iomem *)bd);
249239 /* clear bd buffer */
250
- out_be32(&bd->buf, 0);
240
+ qe_iowrite32be(0, &bd->buf);
251241 bd++;
252242 }
253243 /* for last BD set Wrap bit */
254
- out_be32((u32*)bd, cpu_to_be32(R_W));
255
- out_be32(&bd->buf, 0);
244
+ qe_iowrite32be(R_W, (u32 __iomem *)bd);
245
+ qe_iowrite32be(0, &bd->buf);
256246
257247 /* Set GUMR (For more details see the hardware spec.). */
258248 /* gumr_h */
....@@ -273,11 +263,11 @@
273263 gumr |= UCC_SLOW_GUMR_H_TXSY;
274264 if (us_info->rtsm)
275265 gumr |= UCC_SLOW_GUMR_H_RTSM;
276
- out_be32(&us_regs->gumr_h, gumr);
266
+ qe_iowrite32be(gumr, &us_regs->gumr_h);
277267
278268 /* gumr_l */
279
- gumr = us_info->tdcr | us_info->rdcr | us_info->tenc | us_info->renc |
280
- us_info->diag | us_info->mode;
269
+ gumr = (u32)us_info->tdcr | (u32)us_info->rdcr | (u32)us_info->tenc |
270
+ (u32)us_info->renc | (u32)us_info->diag | (u32)us_info->mode;
281271 if (us_info->tci)
282272 gumr |= UCC_SLOW_GUMR_L_TCI;
283273 if (us_info->rinv)
....@@ -286,18 +276,18 @@
286276 gumr |= UCC_SLOW_GUMR_L_TINV;
287277 if (us_info->tend)
288278 gumr |= UCC_SLOW_GUMR_L_TEND;
289
- out_be32(&us_regs->gumr_l, gumr);
279
+ qe_iowrite32be(gumr, &us_regs->gumr_l);
290280
291281 /* Function code registers */
292282
293283 /* if the data is in cachable memory, the 'global' */
294284 /* in the function code should be set. */
295
- uccs->us_pram->tbmr = UCC_BMR_BO_BE;
296
- uccs->us_pram->rbmr = UCC_BMR_BO_BE;
285
+ qe_iowrite8(UCC_BMR_BO_BE, &uccs->us_pram->tbmr);
286
+ qe_iowrite8(UCC_BMR_BO_BE, &uccs->us_pram->rbmr);
297287
298288 /* rbase, tbase are offsets from MURAM base */
299
- out_be16(&uccs->us_pram->rbase, uccs->rx_base_offset);
300
- out_be16(&uccs->us_pram->tbase, uccs->tx_base_offset);
289
+ qe_iowrite16be(uccs->rx_base_offset, &uccs->us_pram->rbase);
290
+ qe_iowrite16be(uccs->tx_base_offset, &uccs->us_pram->tbase);
301291
302292 /* Mux clocking */
303293 /* Grant Support */
....@@ -327,14 +317,14 @@
327317 }
328318
329319 /* Set interrupt mask register at UCC level. */
330
- out_be16(&us_regs->uccm, us_info->uccm_mask);
320
+ qe_iowrite16be(us_info->uccm_mask, &us_regs->uccm);
331321
332322 /* First, clear anything pending at UCC level,
333323 * otherwise, old garbage may come through
334324 * as soon as the dam is opened. */
335325
336326 /* Writing '1' clears */
337
- out_be16(&us_regs->ucce, 0xffff);
327
+ qe_iowrite16be(0xffff, &us_regs->ucce);
338328
339329 /* Issue QE Init command */
340330 if (us_info->init_tx && us_info->init_rx)
....@@ -356,14 +346,9 @@
356346 if (!uccs)
357347 return;
358348
359
- if (uccs->rx_base_offset)
360
- qe_muram_free(uccs->rx_base_offset);
361
-
362
- if (uccs->tx_base_offset)
363
- qe_muram_free(uccs->tx_base_offset);
364
-
365
- if (uccs->us_pram)
366
- qe_muram_free(uccs->us_pram_offset);
349
+ qe_muram_free(uccs->rx_base_offset);
350
+ qe_muram_free(uccs->tx_base_offset);
351
+ qe_muram_free(uccs->us_pram_offset);
367352
368353 if (uccs->us_regs)
369354 iounmap(uccs->us_regs);