| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * QUICC Engine GPIOs |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) MontaVista Software, Inc. 2008. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 9 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 10 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 11 | | - * option) any later version. |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | |
|---|
| 14 | 10 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 45 | 41 | container_of(mm_gc, struct qe_gpio_chip, mm_gc); |
|---|
| 46 | 42 | struct qe_pio_regs __iomem *regs = mm_gc->regs; |
|---|
| 47 | 43 | |
|---|
| 48 | | - qe_gc->cpdata = in_be32(®s->cpdata); |
|---|
| 44 | + qe_gc->cpdata = qe_ioread32be(®s->cpdata); |
|---|
| 49 | 45 | qe_gc->saved_regs.cpdata = qe_gc->cpdata; |
|---|
| 50 | | - qe_gc->saved_regs.cpdir1 = in_be32(®s->cpdir1); |
|---|
| 51 | | - qe_gc->saved_regs.cpdir2 = in_be32(®s->cpdir2); |
|---|
| 52 | | - qe_gc->saved_regs.cppar1 = in_be32(®s->cppar1); |
|---|
| 53 | | - qe_gc->saved_regs.cppar2 = in_be32(®s->cppar2); |
|---|
| 54 | | - qe_gc->saved_regs.cpodr = in_be32(®s->cpodr); |
|---|
| 46 | + qe_gc->saved_regs.cpdir1 = qe_ioread32be(®s->cpdir1); |
|---|
| 47 | + qe_gc->saved_regs.cpdir2 = qe_ioread32be(®s->cpdir2); |
|---|
| 48 | + qe_gc->saved_regs.cppar1 = qe_ioread32be(®s->cppar1); |
|---|
| 49 | + qe_gc->saved_regs.cppar2 = qe_ioread32be(®s->cppar2); |
|---|
| 50 | + qe_gc->saved_regs.cpodr = qe_ioread32be(®s->cpodr); |
|---|
| 55 | 51 | } |
|---|
| 56 | 52 | |
|---|
| 57 | 53 | static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio) |
|---|
| .. | .. |
|---|
| 60 | 56 | struct qe_pio_regs __iomem *regs = mm_gc->regs; |
|---|
| 61 | 57 | u32 pin_mask = 1 << (QE_PIO_PINS - 1 - gpio); |
|---|
| 62 | 58 | |
|---|
| 63 | | - return !!(in_be32(®s->cpdata) & pin_mask); |
|---|
| 59 | + return !!(qe_ioread32be(®s->cpdata) & pin_mask); |
|---|
| 64 | 60 | } |
|---|
| 65 | 61 | |
|---|
| 66 | 62 | static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) |
|---|
| .. | .. |
|---|
| 78 | 74 | else |
|---|
| 79 | 75 | qe_gc->cpdata &= ~pin_mask; |
|---|
| 80 | 76 | |
|---|
| 81 | | - out_be32(®s->cpdata, qe_gc->cpdata); |
|---|
| 77 | + qe_iowrite32be(qe_gc->cpdata, ®s->cpdata); |
|---|
| 82 | 78 | |
|---|
| 83 | 79 | spin_unlock_irqrestore(&qe_gc->lock, flags); |
|---|
| 84 | 80 | } |
|---|
| .. | .. |
|---|
| 105 | 101 | } |
|---|
| 106 | 102 | } |
|---|
| 107 | 103 | |
|---|
| 108 | | - out_be32(®s->cpdata, qe_gc->cpdata); |
|---|
| 104 | + qe_iowrite32be(qe_gc->cpdata, ®s->cpdata); |
|---|
| 109 | 105 | |
|---|
| 110 | 106 | spin_unlock_irqrestore(&qe_gc->lock, flags); |
|---|
| 111 | 107 | } |
|---|
| .. | .. |
|---|
| 164 | 160 | { |
|---|
| 165 | 161 | struct qe_pin *qe_pin; |
|---|
| 166 | 162 | struct gpio_chip *gc; |
|---|
| 167 | | - struct of_mm_gpio_chip *mm_gc; |
|---|
| 168 | 163 | struct qe_gpio_chip *qe_gc; |
|---|
| 169 | 164 | int err; |
|---|
| 170 | 165 | unsigned long flags; |
|---|
| .. | .. |
|---|
| 190 | 185 | goto err0; |
|---|
| 191 | 186 | } |
|---|
| 192 | 187 | |
|---|
| 193 | | - mm_gc = to_of_mm_gpio_chip(gc); |
|---|
| 194 | 188 | qe_gc = gpiochip_get_data(gc); |
|---|
| 195 | 189 | |
|---|
| 196 | 190 | spin_lock_irqsave(&qe_gc->lock, flags); |
|---|
| .. | .. |
|---|
| 259 | 253 | spin_lock_irqsave(&qe_gc->lock, flags); |
|---|
| 260 | 254 | |
|---|
| 261 | 255 | if (second_reg) { |
|---|
| 262 | | - clrsetbits_be32(®s->cpdir2, mask2, sregs->cpdir2 & mask2); |
|---|
| 263 | | - clrsetbits_be32(®s->cppar2, mask2, sregs->cppar2 & mask2); |
|---|
| 256 | + qe_clrsetbits_be32(®s->cpdir2, mask2, |
|---|
| 257 | + sregs->cpdir2 & mask2); |
|---|
| 258 | + qe_clrsetbits_be32(®s->cppar2, mask2, |
|---|
| 259 | + sregs->cppar2 & mask2); |
|---|
| 264 | 260 | } else { |
|---|
| 265 | | - clrsetbits_be32(®s->cpdir1, mask2, sregs->cpdir1 & mask2); |
|---|
| 266 | | - clrsetbits_be32(®s->cppar1, mask2, sregs->cppar1 & mask2); |
|---|
| 261 | + qe_clrsetbits_be32(®s->cpdir1, mask2, |
|---|
| 262 | + sregs->cpdir1 & mask2); |
|---|
| 263 | + qe_clrsetbits_be32(®s->cppar1, mask2, |
|---|
| 264 | + sregs->cppar1 & mask2); |
|---|
| 267 | 265 | } |
|---|
| 268 | 266 | |
|---|
| 269 | 267 | if (sregs->cpdata & mask1) |
|---|
| .. | .. |
|---|
| 271 | 269 | else |
|---|
| 272 | 270 | qe_gc->cpdata &= ~mask1; |
|---|
| 273 | 271 | |
|---|
| 274 | | - out_be32(®s->cpdata, qe_gc->cpdata); |
|---|
| 275 | | - clrsetbits_be32(®s->cpodr, mask1, sregs->cpodr & mask1); |
|---|
| 272 | + qe_iowrite32be(qe_gc->cpdata, ®s->cpdata); |
|---|
| 273 | + qe_clrsetbits_be32(®s->cpodr, mask1, sregs->cpodr & mask1); |
|---|
| 276 | 274 | |
|---|
| 277 | 275 | spin_unlock_irqrestore(&qe_gc->lock, flags); |
|---|
| 278 | 276 | } |
|---|