hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/spi/spi-ep93xx.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Driver for Cirrus Logic EP93xx SPI controller.
34 *
....@@ -9,11 +10,7 @@
910 *
1011 * For more information about the SPI controller see documentation on Cirrus
1112 * Logic web site:
12
- * http://www.cirrus.com/en/pubs/manual/EP93xx_Users_Guide_UM1.pdf
13
- *
14
- * This program is free software; you can redistribute it and/or modify
15
- * it under the terms of the GNU General Public License version 2 as
16
- * published by the Free Software Foundation.
13
+ * https://www.cirrus.com/en/pubs/manual/EP93xx_Users_Guide_UM1.pdf
1714 */
1815
1916 #include <linux/io.h>
....@@ -28,14 +25,14 @@
2825 #include <linux/platform_device.h>
2926 #include <linux/sched.h>
3027 #include <linux/scatterlist.h>
31
-#include <linux/gpio.h>
3228 #include <linux/spi/spi.h>
3329
3430 #include <linux/platform_data/dma-ep93xx.h>
3531 #include <linux/platform_data/spi-ep93xx.h>
3632
3733 #define SSPCR0 0x0000
38
-#define SSPCR0_MODE_SHIFT 6
34
+#define SSPCR0_SPO BIT(6)
35
+#define SSPCR0_SPH BIT(7)
3936 #define SSPCR0_SCR_SHIFT 8
4037
4138 #define SSPCR1 0x0004
....@@ -163,7 +160,10 @@
163160 return err;
164161
165162 cr0 = div_scr << SSPCR0_SCR_SHIFT;
166
- cr0 |= (spi->mode & (SPI_CPHA | SPI_CPOL)) << SSPCR0_MODE_SHIFT;
163
+ if (spi->mode & SPI_CPOL)
164
+ cr0 |= SSPCR0_SPO;
165
+ if (spi->mode & SPI_CPHA)
166
+ cr0 |= SSPCR0_SPH;
167167 cr0 |= dss;
168168
169169 dev_dbg(&master->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
....@@ -214,7 +214,7 @@
214214
215215 /**
216216 * ep93xx_spi_read_write() - perform next RX/TX transfer
217
- * @espi: ep93xx SPI controller struct
217
+ * @master: SPI master
218218 *
219219 * This function transfers next bytes (or half-words) to/from RX/TX FIFOs. If
220220 * called several times, the whole transfer will be completed. Returns
....@@ -652,7 +652,6 @@
652652 struct resource *res;
653653 int irq;
654654 int error;
655
- int i;
656655
657656 info = dev_get_platdata(&pdev->dev);
658657 if (!info) {
....@@ -661,10 +660,8 @@
661660 }
662661
663662 irq = platform_get_irq(pdev, 0);
664
- if (irq < 0) {
665
- dev_err(&pdev->dev, "failed to get irq resources\n");
663
+ if (irq < 0)
666664 return -EBUSY;
667
- }
668665
669666 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
670667 if (!res) {
....@@ -676,6 +673,7 @@
676673 if (!master)
677674 return -ENOMEM;
678675
676
+ master->use_gpio_descriptors = true;
679677 master->prepare_transfer_hardware = ep93xx_spi_prepare_hardware;
680678 master->unprepare_transfer_hardware = ep93xx_spi_unprepare_hardware;
681679 master->prepare_message = ep93xx_spi_prepare_message;
....@@ -683,31 +681,11 @@
683681 master->bus_num = pdev->id;
684682 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
685683 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
686
-
687
- master->num_chipselect = info->num_chipselect;
688
- master->cs_gpios = devm_kcalloc(&master->dev,
689
- master->num_chipselect, sizeof(int),
690
- GFP_KERNEL);
691
- if (!master->cs_gpios) {
692
- error = -ENOMEM;
693
- goto fail_release_master;
694
- }
695
-
696
- for (i = 0; i < master->num_chipselect; i++) {
697
- master->cs_gpios[i] = info->chipselect[i];
698
-
699
- if (!gpio_is_valid(master->cs_gpios[i]))
700
- continue;
701
-
702
- error = devm_gpio_request_one(&pdev->dev, master->cs_gpios[i],
703
- GPIOF_OUT_INIT_HIGH,
704
- "ep93xx-spi");
705
- if (error) {
706
- dev_err(&pdev->dev, "could not request cs gpio %d\n",
707
- master->cs_gpios[i]);
708
- goto fail_release_master;
709
- }
710
- }
684
+ /*
685
+ * The SPI core will count the number of GPIO descriptors to figure
686
+ * out the number of chip selects available on the platform.
687
+ */
688
+ master->num_chipselect = 0;
711689
712690 platform_set_drvdata(pdev, master);
713691