forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/soc/fsl/qe/gpio.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * QUICC Engine GPIOs
34 *
45 * Copyright (c) MontaVista Software, Inc. 2008.
56 *
67 * 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.
128 */
139
1410 #include <linux/kernel.h>
....@@ -45,13 +41,13 @@
4541 container_of(mm_gc, struct qe_gpio_chip, mm_gc);
4642 struct qe_pio_regs __iomem *regs = mm_gc->regs;
4743
48
- qe_gc->cpdata = in_be32(&regs->cpdata);
44
+ qe_gc->cpdata = qe_ioread32be(&regs->cpdata);
4945 qe_gc->saved_regs.cpdata = qe_gc->cpdata;
50
- qe_gc->saved_regs.cpdir1 = in_be32(&regs->cpdir1);
51
- qe_gc->saved_regs.cpdir2 = in_be32(&regs->cpdir2);
52
- qe_gc->saved_regs.cppar1 = in_be32(&regs->cppar1);
53
- qe_gc->saved_regs.cppar2 = in_be32(&regs->cppar2);
54
- qe_gc->saved_regs.cpodr = in_be32(&regs->cpodr);
46
+ qe_gc->saved_regs.cpdir1 = qe_ioread32be(&regs->cpdir1);
47
+ qe_gc->saved_regs.cpdir2 = qe_ioread32be(&regs->cpdir2);
48
+ qe_gc->saved_regs.cppar1 = qe_ioread32be(&regs->cppar1);
49
+ qe_gc->saved_regs.cppar2 = qe_ioread32be(&regs->cppar2);
50
+ qe_gc->saved_regs.cpodr = qe_ioread32be(&regs->cpodr);
5551 }
5652
5753 static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio)
....@@ -60,7 +56,7 @@
6056 struct qe_pio_regs __iomem *regs = mm_gc->regs;
6157 u32 pin_mask = 1 << (QE_PIO_PINS - 1 - gpio);
6258
63
- return !!(in_be32(&regs->cpdata) & pin_mask);
59
+ return !!(qe_ioread32be(&regs->cpdata) & pin_mask);
6460 }
6561
6662 static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
....@@ -78,7 +74,7 @@
7874 else
7975 qe_gc->cpdata &= ~pin_mask;
8076
81
- out_be32(&regs->cpdata, qe_gc->cpdata);
77
+ qe_iowrite32be(qe_gc->cpdata, &regs->cpdata);
8278
8379 spin_unlock_irqrestore(&qe_gc->lock, flags);
8480 }
....@@ -105,7 +101,7 @@
105101 }
106102 }
107103
108
- out_be32(&regs->cpdata, qe_gc->cpdata);
104
+ qe_iowrite32be(qe_gc->cpdata, &regs->cpdata);
109105
110106 spin_unlock_irqrestore(&qe_gc->lock, flags);
111107 }
....@@ -164,7 +160,6 @@
164160 {
165161 struct qe_pin *qe_pin;
166162 struct gpio_chip *gc;
167
- struct of_mm_gpio_chip *mm_gc;
168163 struct qe_gpio_chip *qe_gc;
169164 int err;
170165 unsigned long flags;
....@@ -190,7 +185,6 @@
190185 goto err0;
191186 }
192187
193
- mm_gc = to_of_mm_gpio_chip(gc);
194188 qe_gc = gpiochip_get_data(gc);
195189
196190 spin_lock_irqsave(&qe_gc->lock, flags);
....@@ -259,11 +253,15 @@
259253 spin_lock_irqsave(&qe_gc->lock, flags);
260254
261255 if (second_reg) {
262
- clrsetbits_be32(&regs->cpdir2, mask2, sregs->cpdir2 & mask2);
263
- clrsetbits_be32(&regs->cppar2, mask2, sregs->cppar2 & mask2);
256
+ qe_clrsetbits_be32(&regs->cpdir2, mask2,
257
+ sregs->cpdir2 & mask2);
258
+ qe_clrsetbits_be32(&regs->cppar2, mask2,
259
+ sregs->cppar2 & mask2);
264260 } else {
265
- clrsetbits_be32(&regs->cpdir1, mask2, sregs->cpdir1 & mask2);
266
- clrsetbits_be32(&regs->cppar1, mask2, sregs->cppar1 & mask2);
261
+ qe_clrsetbits_be32(&regs->cpdir1, mask2,
262
+ sregs->cpdir1 & mask2);
263
+ qe_clrsetbits_be32(&regs->cppar1, mask2,
264
+ sregs->cppar1 & mask2);
267265 }
268266
269267 if (sregs->cpdata & mask1)
....@@ -271,8 +269,8 @@
271269 else
272270 qe_gc->cpdata &= ~mask1;
273271
274
- out_be32(&regs->cpdata, qe_gc->cpdata);
275
- clrsetbits_be32(&regs->cpodr, mask1, sregs->cpodr & mask1);
272
+ qe_iowrite32be(qe_gc->cpdata, &regs->cpdata);
273
+ qe_clrsetbits_be32(&regs->cpodr, mask1, sregs->cpodr & mask1);
276274
277275 spin_unlock_irqrestore(&qe_gc->lock, flags);
278276 }