Skip to content

Commit 21ae190

Browse files
committed
spi: pxa2xx: Drop linux/spi/pxa2xx_spi.h
Merge series from Andy Shevchenko <[email protected]>: As Arnd suggested we may drop linux/spi/pxa2xx_spi.h as most of its content is being used solely internally to SPI subsystem (PXA2xx drivers). Hence this refactoring series with the additional win of getting rid of legacy documentation. Note, that we have the only user of a single plain integer field in the entire kernel for that. Switching to software nodes does not diminish any of type checking as we only pass an integer.
2 parents aa9db10 + b5ec398 commit 21ae190

File tree

8 files changed

+87
-381
lines changed

8 files changed

+87
-381
lines changed

Documentation/spi/pxa2xx.rst

Lines changed: 0 additions & 208 deletions
This file was deleted.

arch/arm/mach-pxa/spitz.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#include <linux/i2c.h>
1919
#include <linux/platform_data/i2c-pxa.h>
2020
#include <linux/platform_data/pca953x.h>
21+
#include <linux/property.h>
2122
#include <linux/spi/spi.h>
2223
#include <linux/spi/ads7846.h>
2324
#include <linux/spi/corgi_lcd.h>
24-
#include <linux/spi/pxa2xx_spi.h>
2525
#include <linux/mtd/sharpsl.h>
2626
#include <linux/mtd/physmap.h>
2727
#include <linux/input-event-codes.h>
@@ -569,10 +569,6 @@ static struct spi_board_info spitz_spi_devices[] = {
569569
},
570570
};
571571

572-
static struct pxa2xx_spi_controller spitz_spi_info = {
573-
.num_chipselect = 3,
574-
};
575-
576572
static struct gpiod_lookup_table spitz_spi_gpio_table = {
577573
.dev_id = "spi2",
578574
.table = {
@@ -583,10 +579,20 @@ static struct gpiod_lookup_table spitz_spi_gpio_table = {
583579
},
584580
};
585581

582+
static const struct property_entry spitz_spi_properties[] = {
583+
PROPERTY_ENTRY_U32("num-cs", 3),
584+
{ }
585+
};
586+
587+
static const struct software_node spitz_spi_node = {
588+
.properties = spitz_spi_properties,
589+
};
590+
586591
static void __init spitz_spi_init(void)
587592
{
588593
struct platform_device *pd;
589594
int id = 2;
595+
int err;
590596

591597
if (machine_is_akita())
592598
gpiod_add_lookup_table(&akita_lcdcon_gpio_table);
@@ -601,8 +607,13 @@ static void __init spitz_spi_init(void)
601607
if (pd == NULL) {
602608
pr_err("pxa2xx-spi: failed to allocate device id %d\n", id);
603609
} else {
604-
pd->dev.platform_data = &spitz_spi_info;
605-
platform_device_add(pd);
610+
err = device_add_software_node(&pd->dev, &spitz_spi_node);
611+
if (err) {
612+
platform_device_put(pd);
613+
pr_err("pxa2xx-spi: failed to add software node\n");
614+
} else {
615+
platform_device_add(pd);
616+
}
606617
}
607618

608619
spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));

drivers/spi/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ config SPI_PXA2XX
832832
select PXA_SSP if ARCH_PXA || ARCH_MMP
833833
help
834834
This enables using a PXA2xx or Sodaville SSP port as a SPI master
835-
controller. The driver can be configured to use any SSP port and
836-
additional documentation can be found a Documentation/spi/pxa2xx.rst.
835+
controller. The driver can be configured to use any SSP port.
837836

838837
config SPI_PXA2XX_PCI
839838
def_tristate SPI_PXA2XX && PCI && COMMON_CLK

drivers/spi/spi-pxa2xx-dma.c

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66
* Author: Mika Westerberg <[email protected]>
77
*/
88

9-
#include <linux/device.h>
9+
#include <linux/atomic.h>
10+
#include <linux/dev_printk.h>
1011
#include <linux/dma-mapping.h>
1112
#include <linux/dmaengine.h>
13+
#include <linux/errno.h>
14+
#include <linux/irqreturn.h>
1215
#include <linux/scatterlist.h>
13-
#include <linux/sizes.h>
16+
#include <linux/string.h>
17+
#include <linux/types.h>
1418

15-
#include <linux/spi/pxa2xx_spi.h>
1619
#include <linux/spi/spi.h>
1720

1821
#include "spi-pxa2xx.h"
1922

23+
struct device;
24+
2025
static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data,
2126
bool error)
2227
{
@@ -63,8 +68,6 @@ pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
6368
enum dma_transfer_direction dir,
6469
struct spi_transfer *xfer)
6570
{
66-
struct chip_data *chip =
67-
spi_get_ctldata(drv_data->controller->cur_msg->spi);
6871
enum dma_slave_buswidth width;
6972
struct dma_slave_config cfg;
7073
struct dma_chan *chan;
@@ -89,14 +92,14 @@ pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
8992
if (dir == DMA_MEM_TO_DEV) {
9093
cfg.dst_addr = drv_data->ssp->phys_base + SSDR;
9194
cfg.dst_addr_width = width;
92-
cfg.dst_maxburst = chip->dma_burst_size;
95+
cfg.dst_maxburst = drv_data->controller_info->dma_burst_size;
9396

9497
sgt = &xfer->tx_sg;
9598
chan = drv_data->controller->dma_tx;
9699
} else {
97100
cfg.src_addr = drv_data->ssp->phys_base + SSDR;
98101
cfg.src_addr_width = width;
99-
cfg.src_maxburst = chip->dma_burst_size;
102+
cfg.src_maxburst = drv_data->controller_info->dma_burst_size;
100103

101104
sgt = &xfer->rx_sg;
102105
chan = drv_data->controller->dma_rx;
@@ -220,24 +223,3 @@ void pxa2xx_spi_dma_release(struct driver_data *drv_data)
220223
controller->dma_tx = NULL;
221224
}
222225
}
223-
224-
int pxa2xx_spi_set_dma_burst_and_threshold(struct chip_data *chip,
225-
struct spi_device *spi,
226-
u8 bits_per_word, u32 *burst_code,
227-
u32 *threshold)
228-
{
229-
struct pxa2xx_spi_chip *chip_info = spi->controller_data;
230-
struct driver_data *drv_data = spi_controller_get_devdata(spi->controller);
231-
u32 dma_burst_size = drv_data->controller_info->dma_burst_size;
232-
233-
/*
234-
* If the DMA burst size is given in chip_info we use that,
235-
* otherwise we use the default. Also we use the default FIFO
236-
* thresholds for now.
237-
*/
238-
*burst_code = chip_info ? chip_info->dma_burst_size : dma_burst_size;
239-
*threshold = SSCR1_RxTresh(RX_THRESH_DFLT)
240-
| SSCR1_TxTresh(TX_THRESH_DFLT);
241-
242-
return 0;
243-
}

drivers/spi/spi-pxa2xx-pci.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@
66
* Copyright (C) 2016, 2021 Intel Corporation
77
*/
88
#include <linux/clk-provider.h>
9+
#include <linux/device.h>
10+
#include <linux/err.h>
911
#include <linux/module.h>
1012
#include <linux/pci.h>
1113
#include <linux/platform_device.h>
12-
13-
#include <linux/spi/pxa2xx_spi.h>
14+
#include <linux/property.h>
15+
#include <linux/sprintf.h>
16+
#include <linux/string.h>
17+
#include <linux/types.h>
1418

1519
#include <linux/dmaengine.h>
1620
#include <linux/platform_data/dma-dw.h>
1721

22+
#include "spi-pxa2xx.h"
23+
1824
#define PCI_DEVICE_ID_INTEL_QUARK_X1000 0x0935
1925
#define PCI_DEVICE_ID_INTEL_BYT 0x0f0e
2026
#define PCI_DEVICE_ID_INTEL_MRFLD 0x1194

0 commit comments

Comments
 (0)