hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/spi/spi-s3c24xx.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2006 Ben Dooks
34 * Copyright 2006-2009 Simtec Electronics
45 * Ben Dooks <ben@simtec.co.uk>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
106 */
117
128 #include <linux/spinlock.h>
....@@ -23,16 +19,15 @@
2319 #include <linux/spi/spi.h>
2420 #include <linux/spi/spi_bitbang.h>
2521 #include <linux/spi/s3c24xx.h>
22
+#include <linux/spi/s3c24xx-fiq.h>
2623 #include <linux/module.h>
27
-
28
-#include <plat/regs-spi.h>
2924
3025 #include <asm/fiq.h>
3126
32
-#include "spi-s3c24xx-fiq.h"
27
+#include "spi-s3c24xx-regs.h"
3328
3429 /**
35
- * s3c24xx_spi_devstate - per device data
30
+ * struct s3c24xx_spi_devstate - per device data
3631 * @hz: Last frequency calculated for @sppre field.
3732 * @mode: Last mode setting for the @spcon field.
3833 * @spcon: Value to write to the SPCON register.
....@@ -231,23 +226,8 @@
231226 struct spi_fiq_code {
232227 u32 length;
233228 u32 ack_offset;
234
- u8 data[0];
229
+ u8 data[];
235230 };
236
-
237
-extern struct spi_fiq_code s3c24xx_spi_fiq_txrx;
238
-extern struct spi_fiq_code s3c24xx_spi_fiq_tx;
239
-extern struct spi_fiq_code s3c24xx_spi_fiq_rx;
240
-
241
-/**
242
- * ack_bit - turn IRQ into IRQ acknowledgement bit
243
- * @irq: The interrupt number
244
- *
245
- * Returns the bit to write to the interrupt acknowledge register.
246
- */
247
-static inline u32 ack_bit(unsigned int irq)
248
-{
249
- return 1 << (irq - IRQ_EINT0);
250
-}
251231
252232 /**
253233 * s3c24xx_spi_tryfiq - attempt to claim and setup FIQ for transfer
....@@ -265,6 +245,7 @@
265245 struct pt_regs regs;
266246 enum spi_fiq_mode mode;
267247 struct spi_fiq_code *code;
248
+ u32 *ack_ptr = NULL;
268249 int ret;
269250
270251 if (!hw->fiq_claimed) {
....@@ -287,13 +268,10 @@
287268 regs.uregs[fiq_rrx] = (long)hw->rx;
288269 regs.uregs[fiq_rtx] = (long)hw->tx + 1;
289270 regs.uregs[fiq_rcount] = hw->len - 1;
290
- regs.uregs[fiq_rirq] = (long)S3C24XX_VA_IRQ;
291271
292272 set_fiq_regs(&regs);
293273
294274 if (hw->fiq_mode != mode) {
295
- u32 *ack_ptr;
296
-
297275 hw->fiq_mode = mode;
298276
299277 switch (mode) {
....@@ -313,12 +291,10 @@
313291 BUG_ON(!code);
314292
315293 ack_ptr = (u32 *)&code->data[code->ack_offset];
316
- *ack_ptr = ack_bit(hw->irq);
317
-
318294 set_fiq_handler(&code->data, code->length);
319295 }
320296
321
- s3c24xx_set_fiq(hw->irq, true);
297
+ s3c24xx_set_fiq(hw->irq, ack_ptr, true);
322298
323299 hw->fiq_mode = mode;
324300 hw->fiq_inuse = 1;
....@@ -491,7 +467,6 @@
491467 struct s3c2410_spi_info *pdata;
492468 struct s3c24xx_spi *hw;
493469 struct spi_master *master;
494
- struct resource *res;
495470 int err = 0;
496471
497472 master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
....@@ -540,8 +515,7 @@
540515 dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);
541516
542517 /* find and map our resources */
543
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
544
- hw->regs = devm_ioremap_resource(&pdev->dev, res);
518
+ hw->regs = devm_platform_ioremap_resource(pdev, 0);
545519 if (IS_ERR(hw->regs)) {
546520 err = PTR_ERR(hw->regs);
547521 goto err_no_pdata;
....@@ -549,7 +523,6 @@
549523
550524 hw->irq = platform_get_irq(pdev, 0);
551525 if (hw->irq < 0) {
552
- dev_err(&pdev->dev, "No IRQ specified\n");
553526 err = -ENOENT;
554527 goto err_no_pdata;
555528 }