| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2006 Freescale Semiconductor, Inc. All rights reserved. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Description: |
|---|
| 8 | 9 | * 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. |
|---|
| 14 | 10 | */ |
|---|
| 15 | 11 | #include <linux/kernel.h> |
|---|
| 16 | 12 | #include <linux/errno.h> |
|---|
| .. | .. |
|---|
| 76 | 72 | |
|---|
| 77 | 73 | void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode) |
|---|
| 78 | 74 | { |
|---|
| 79 | | - struct ucc_slow *us_regs; |
|---|
| 75 | + struct ucc_slow __iomem *us_regs; |
|---|
| 80 | 76 | u32 gumr_l; |
|---|
| 81 | 77 | |
|---|
| 82 | 78 | us_regs = uccs->us_regs; |
|---|
| 83 | 79 | |
|---|
| 84 | 80 | /* 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); |
|---|
| 86 | 82 | if (mode & COMM_DIR_TX) { |
|---|
| 87 | 83 | gumr_l |= UCC_SLOW_GUMR_L_ENT; |
|---|
| 88 | 84 | uccs->enabled_tx = 1; |
|---|
| .. | .. |
|---|
| 91 | 87 | gumr_l |= UCC_SLOW_GUMR_L_ENR; |
|---|
| 92 | 88 | uccs->enabled_rx = 1; |
|---|
| 93 | 89 | } |
|---|
| 94 | | - out_be32(&us_regs->gumr_l, gumr_l); |
|---|
| 90 | + qe_iowrite32be(gumr_l, &us_regs->gumr_l); |
|---|
| 95 | 91 | } |
|---|
| 96 | 92 | EXPORT_SYMBOL(ucc_slow_enable); |
|---|
| 97 | 93 | |
|---|
| 98 | 94 | void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode) |
|---|
| 99 | 95 | { |
|---|
| 100 | | - struct ucc_slow *us_regs; |
|---|
| 96 | + struct ucc_slow __iomem *us_regs; |
|---|
| 101 | 97 | u32 gumr_l; |
|---|
| 102 | 98 | |
|---|
| 103 | 99 | us_regs = uccs->us_regs; |
|---|
| 104 | 100 | |
|---|
| 105 | 101 | /* 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); |
|---|
| 107 | 103 | if (mode & COMM_DIR_TX) { |
|---|
| 108 | 104 | gumr_l &= ~UCC_SLOW_GUMR_L_ENT; |
|---|
| 109 | 105 | uccs->enabled_tx = 0; |
|---|
| .. | .. |
|---|
| 112 | 108 | gumr_l &= ~UCC_SLOW_GUMR_L_ENR; |
|---|
| 113 | 109 | uccs->enabled_rx = 0; |
|---|
| 114 | 110 | } |
|---|
| 115 | | - out_be32(&us_regs->gumr_l, gumr_l); |
|---|
| 111 | + qe_iowrite32be(gumr_l, &us_regs->gumr_l); |
|---|
| 116 | 112 | } |
|---|
| 117 | 113 | EXPORT_SYMBOL(ucc_slow_disable); |
|---|
| 118 | 114 | |
|---|
| .. | .. |
|---|
| 126 | 122 | u32 i; |
|---|
| 127 | 123 | struct ucc_slow __iomem *us_regs; |
|---|
| 128 | 124 | u32 gumr; |
|---|
| 129 | | - struct qe_bd *bd; |
|---|
| 125 | + struct qe_bd __iomem *bd; |
|---|
| 130 | 126 | u32 id; |
|---|
| 131 | 127 | u32 command; |
|---|
| 132 | 128 | int ret = 0; |
|---|
| .. | .. |
|---|
| 158 | 154 | __func__); |
|---|
| 159 | 155 | return -ENOMEM; |
|---|
| 160 | 156 | } |
|---|
| 157 | + uccs->rx_base_offset = -1; |
|---|
| 158 | + uccs->tx_base_offset = -1; |
|---|
| 159 | + uccs->us_pram_offset = -1; |
|---|
| 161 | 160 | |
|---|
| 162 | 161 | /* Fill slow UCC structure */ |
|---|
| 163 | 162 | uccs->us_info = us_info; |
|---|
| .. | .. |
|---|
| 169 | 168 | return -ENOMEM; |
|---|
| 170 | 169 | } |
|---|
| 171 | 170 | |
|---|
| 172 | | - uccs->saved_uccm = 0; |
|---|
| 173 | | - uccs->p_rx_frame = 0; |
|---|
| 174 | 171 | 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; |
|---|
| 182 | 174 | |
|---|
| 183 | 175 | /* Get PRAM base */ |
|---|
| 184 | 176 | uccs->us_pram_offset = |
|---|
| 185 | 177 | 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) { |
|---|
| 187 | 179 | printk(KERN_ERR "%s: cannot allocate MURAM for PRAM", __func__); |
|---|
| 188 | 180 | ucc_slow_free(uccs); |
|---|
| 189 | 181 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 202 | 194 | return ret; |
|---|
| 203 | 195 | } |
|---|
| 204 | 196 | |
|---|
| 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); |
|---|
| 206 | 198 | |
|---|
| 207 | 199 | INIT_LIST_HEAD(&uccs->confQ); |
|---|
| 208 | 200 | |
|---|
| .. | .. |
|---|
| 210 | 202 | uccs->rx_base_offset = |
|---|
| 211 | 203 | qe_muram_alloc(us_info->rx_bd_ring_len * sizeof(struct qe_bd), |
|---|
| 212 | 204 | QE_ALIGNMENT_OF_BD); |
|---|
| 213 | | - if (IS_ERR_VALUE(uccs->rx_base_offset)) { |
|---|
| 205 | + if (uccs->rx_base_offset < 0) { |
|---|
| 214 | 206 | printk(KERN_ERR "%s: cannot allocate %u RX BDs\n", __func__, |
|---|
| 215 | 207 | us_info->rx_bd_ring_len); |
|---|
| 216 | | - uccs->rx_base_offset = 0; |
|---|
| 217 | 208 | ucc_slow_free(uccs); |
|---|
| 218 | 209 | return -ENOMEM; |
|---|
| 219 | 210 | } |
|---|
| .. | .. |
|---|
| 221 | 212 | uccs->tx_base_offset = |
|---|
| 222 | 213 | qe_muram_alloc(us_info->tx_bd_ring_len * sizeof(struct qe_bd), |
|---|
| 223 | 214 | QE_ALIGNMENT_OF_BD); |
|---|
| 224 | | - if (IS_ERR_VALUE(uccs->tx_base_offset)) { |
|---|
| 215 | + if (uccs->tx_base_offset < 0) { |
|---|
| 225 | 216 | printk(KERN_ERR "%s: cannot allocate TX BDs", __func__); |
|---|
| 226 | | - uccs->tx_base_offset = 0; |
|---|
| 227 | 217 | ucc_slow_free(uccs); |
|---|
| 228 | 218 | return -ENOMEM; |
|---|
| 229 | 219 | } |
|---|
| .. | .. |
|---|
| 232 | 222 | bd = uccs->confBd = uccs->tx_bd = qe_muram_addr(uccs->tx_base_offset); |
|---|
| 233 | 223 | for (i = 0; i < us_info->tx_bd_ring_len - 1; i++) { |
|---|
| 234 | 224 | /* clear bd buffer */ |
|---|
| 235 | | - out_be32(&bd->buf, 0); |
|---|
| 225 | + qe_iowrite32be(0, &bd->buf); |
|---|
| 236 | 226 | /* set bd status and length */ |
|---|
| 237 | | - out_be32((u32 *) bd, 0); |
|---|
| 227 | + qe_iowrite32be(0, (u32 __iomem *)bd); |
|---|
| 238 | 228 | bd++; |
|---|
| 239 | 229 | } |
|---|
| 240 | 230 | /* 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); |
|---|
| 243 | 233 | |
|---|
| 244 | 234 | /* Init Rx bds */ |
|---|
| 245 | 235 | bd = uccs->rx_bd = qe_muram_addr(uccs->rx_base_offset); |
|---|
| 246 | 236 | for (i = 0; i < us_info->rx_bd_ring_len - 1; i++) { |
|---|
| 247 | 237 | /* set bd status and length */ |
|---|
| 248 | | - out_be32((u32*)bd, 0); |
|---|
| 238 | + qe_iowrite32be(0, (u32 __iomem *)bd); |
|---|
| 249 | 239 | /* clear bd buffer */ |
|---|
| 250 | | - out_be32(&bd->buf, 0); |
|---|
| 240 | + qe_iowrite32be(0, &bd->buf); |
|---|
| 251 | 241 | bd++; |
|---|
| 252 | 242 | } |
|---|
| 253 | 243 | /* 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); |
|---|
| 256 | 246 | |
|---|
| 257 | 247 | /* Set GUMR (For more details see the hardware spec.). */ |
|---|
| 258 | 248 | /* gumr_h */ |
|---|
| .. | .. |
|---|
| 273 | 263 | gumr |= UCC_SLOW_GUMR_H_TXSY; |
|---|
| 274 | 264 | if (us_info->rtsm) |
|---|
| 275 | 265 | gumr |= UCC_SLOW_GUMR_H_RTSM; |
|---|
| 276 | | - out_be32(&us_regs->gumr_h, gumr); |
|---|
| 266 | + qe_iowrite32be(gumr, &us_regs->gumr_h); |
|---|
| 277 | 267 | |
|---|
| 278 | 268 | /* 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; |
|---|
| 281 | 271 | if (us_info->tci) |
|---|
| 282 | 272 | gumr |= UCC_SLOW_GUMR_L_TCI; |
|---|
| 283 | 273 | if (us_info->rinv) |
|---|
| .. | .. |
|---|
| 286 | 276 | gumr |= UCC_SLOW_GUMR_L_TINV; |
|---|
| 287 | 277 | if (us_info->tend) |
|---|
| 288 | 278 | gumr |= UCC_SLOW_GUMR_L_TEND; |
|---|
| 289 | | - out_be32(&us_regs->gumr_l, gumr); |
|---|
| 279 | + qe_iowrite32be(gumr, &us_regs->gumr_l); |
|---|
| 290 | 280 | |
|---|
| 291 | 281 | /* Function code registers */ |
|---|
| 292 | 282 | |
|---|
| 293 | 283 | /* if the data is in cachable memory, the 'global' */ |
|---|
| 294 | 284 | /* 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); |
|---|
| 297 | 287 | |
|---|
| 298 | 288 | /* 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); |
|---|
| 301 | 291 | |
|---|
| 302 | 292 | /* Mux clocking */ |
|---|
| 303 | 293 | /* Grant Support */ |
|---|
| .. | .. |
|---|
| 327 | 317 | } |
|---|
| 328 | 318 | |
|---|
| 329 | 319 | /* 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); |
|---|
| 331 | 321 | |
|---|
| 332 | 322 | /* First, clear anything pending at UCC level, |
|---|
| 333 | 323 | * otherwise, old garbage may come through |
|---|
| 334 | 324 | * as soon as the dam is opened. */ |
|---|
| 335 | 325 | |
|---|
| 336 | 326 | /* Writing '1' clears */ |
|---|
| 337 | | - out_be16(&us_regs->ucce, 0xffff); |
|---|
| 327 | + qe_iowrite16be(0xffff, &us_regs->ucce); |
|---|
| 338 | 328 | |
|---|
| 339 | 329 | /* Issue QE Init command */ |
|---|
| 340 | 330 | if (us_info->init_tx && us_info->init_rx) |
|---|
| .. | .. |
|---|
| 356 | 346 | if (!uccs) |
|---|
| 357 | 347 | return; |
|---|
| 358 | 348 | |
|---|
| 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); |
|---|
| 367 | 352 | |
|---|
| 368 | 353 | if (uccs->us_regs) |
|---|
| 369 | 354 | iounmap(uccs->us_regs); |
|---|