Unverified Commit 31455bbd authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown
Browse files

spi: pxa2xx_spi: Convert to use GPIO descriptors



This converts the PXA2xx SPI driver to use GPIO descriptors
exclusively to retrieve GPIO chip select lines.

The device tree and ACPI paths of the driver already use
descriptors, hence ->use_gpio_descriptors is already set and
this codepath is well tested.

Convert all the PXA boards providing chip select GPIOs as
platform data and drop the old GPIO chipselect handling in
favor of the core managing it exclusively.

Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: linux-arm-kernel@lists.infradead.org
Acked-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220125005836.494807-1-linus.walleij@linaro.org


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 20dc69ca
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ device. All fields are optional.
	u8 rx_threshold;
	u8 dma_burst_size;
	u32 timeout;
	int gpio_cs;
  };

The "pxa2xx_spi_chip.tx_threshold" and "pxa2xx_spi_chip.rx_threshold" fields are
@@ -146,7 +145,6 @@ field. Below is a sample configuration using the PXA255 NSSP.
	.rx_threshold = 8, /* SSP hardward FIFO threshold */
	.dma_burst_size = 8, /* Byte wide transfers used so 8 byte bursts */
	.timeout = 235, /* See Intel documentation */
	.gpio_cs = 2, /* Use external chip select */
  };

  static struct pxa2xx_spi_chip cs8405a_chip_info = {
@@ -154,7 +152,6 @@ field. Below is a sample configuration using the PXA255 NSSP.
	.rx_threshold = 8, /* SSP hardward FIFO threshold */
	.dma_burst_size = 8, /* Byte wide transfers used so 8 byte bursts */
	.timeout = 235, /* See Intel documentation */
	.gpio_cs = 3, /* Use external chip select */
  };

  static struct spi_board_info streetracer_spi_board_info[] __initdata = {
+11 −15
Original line number Diff line number Diff line
@@ -530,6 +530,16 @@ static struct pxa2xx_spi_controller corgi_spi_info = {
	.num_chipselect	= 3,
};

static struct gpiod_lookup_table corgi_spi_gpio_table = {
	.dev_id = "pxa2xx-spi.1",
	.table = {
		GPIO_LOOKUP_IDX("gpio-pxa", CORGI_GPIO_ADS7846_CS, "cs", 0, GPIO_ACTIVE_LOW),
		GPIO_LOOKUP_IDX("gpio-pxa", CORGI_GPIO_LCDCON_CS, "cs", 1, GPIO_ACTIVE_LOW),
		GPIO_LOOKUP_IDX("gpio-pxa", CORGI_GPIO_MAX1111_CS, "cs", 2, GPIO_ACTIVE_LOW),
		{ },
	},
};

static void corgi_wait_for_hsync(void)
{
	while (gpio_get_value(CORGI_GPIO_HSYNC))
@@ -548,10 +558,6 @@ static struct ads7846_platform_data corgi_ads7846_info = {
	.wait_for_sync		= corgi_wait_for_hsync,
};

static struct pxa2xx_spi_chip corgi_ads7846_chip = {
	.gpio_cs	= CORGI_GPIO_ADS7846_CS,
};

static void corgi_bl_kick_battery(void)
{
	void (*kick_batt)(void);
@@ -580,14 +586,6 @@ static struct corgi_lcd_platform_data corgi_lcdcon_info = {
	.kick_battery		= corgi_bl_kick_battery,
};

static struct pxa2xx_spi_chip corgi_lcdcon_chip = {
	.gpio_cs	= CORGI_GPIO_LCDCON_CS,
};

static struct pxa2xx_spi_chip corgi_max1111_chip = {
	.gpio_cs	= CORGI_GPIO_MAX1111_CS,
};

static struct spi_board_info corgi_spi_devices[] = {
	{
		.modalias	= "ads7846",
@@ -595,7 +593,6 @@ static struct spi_board_info corgi_spi_devices[] = {
		.bus_num	= 1,
		.chip_select	= 0,
		.platform_data	= &corgi_ads7846_info,
		.controller_data= &corgi_ads7846_chip,
		.irq		= PXA_GPIO_TO_IRQ(CORGI_GPIO_TP_INT),
	}, {
		.modalias	= "corgi-lcd",
@@ -603,18 +600,17 @@ static struct spi_board_info corgi_spi_devices[] = {
		.bus_num	= 1,
		.chip_select	= 1,
		.platform_data	= &corgi_lcdcon_info,
		.controller_data= &corgi_lcdcon_chip,
	}, {
		.modalias	= "max1111",
		.max_speed_hz	= 450000,
		.bus_num	= 1,
		.chip_select	= 2,
		.controller_data= &corgi_max1111_chip,
	},
};

static void __init corgi_init_spi(void)
{
	gpiod_add_lookup_table(&corgi_spi_gpio_table);
	pxa2xx_set_spi_info(1, &corgi_spi_info);
	gpiod_add_lookup_table(&corgi_lcdcon_gpio_table);
	spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices));
+9 −1
Original line number Diff line number Diff line
@@ -616,7 +616,6 @@ static struct pxa2xx_spi_chip tsc2046_chip = {
	.tx_threshold = 1,
	.rx_threshold = 2,
	.timeout      = 64,
	.gpio_cs      = GPIO88_HX4700_TSC2046_CS,
};

static struct spi_board_info tsc2046_board_info[] __initdata = {
@@ -635,6 +634,14 @@ static struct pxa2xx_spi_controller pxa_ssp2_master_info = {
	.enable_dma     = 1,
};

static struct gpiod_lookup_table pxa_ssp2_gpio_table = {
	.dev_id = "pxa2xx-spi.2",
	.table = {
		GPIO_LOOKUP_IDX("gpio-pxa", GPIO88_HX4700_TSC2046_CS, "cs", 0, GPIO_ACTIVE_LOW),
		{ },
	},
};

/*
 * External power
 */
@@ -896,6 +903,7 @@ static void __init hx4700_init(void)
	pxa_set_i2c_info(NULL);
	i2c_register_board_info(0, ARRAY_AND_SIZE(i2c_board_info));
	i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info));
	gpiod_add_lookup_table(&pxa_ssp2_gpio_table);
	pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
	spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));

+21 −5
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/gpio.h>
#include <linux/gpio/machine.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -42,7 +42,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
	.rx_threshold   = 128,
	.dma_burst_size = 8,
	.timeout        = 235,
	.gpio_cs        = ICONTROL_MCP251x_nCS1
};

static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
@@ -50,7 +49,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
	.rx_threshold   = 128,
	.dma_burst_size = 8,
	.timeout        = 235,
	.gpio_cs        = ICONTROL_MCP251x_nCS2
};

static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
@@ -58,7 +56,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
	.rx_threshold   = 128,
	.dma_burst_size = 8,
	.timeout        = 235,
	.gpio_cs        = ICONTROL_MCP251x_nCS3
};

static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
@@ -66,7 +63,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
	.rx_threshold   = 128,
	.dma_burst_size = 8,
	.timeout        = 235,
	.gpio_cs        = ICONTROL_MCP251x_nCS4
};

static const struct property_entry mcp251x_properties[] = {
@@ -143,6 +139,24 @@ struct platform_device pxa_spi_ssp4 = {
	}
};

static struct gpiod_lookup_table pxa_ssp3_gpio_table = {
	.dev_id = "pxa2xx-spi.3",
	.table = {
		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS1, "cs", 0, GPIO_ACTIVE_LOW),
		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS2, "cs", 1, GPIO_ACTIVE_LOW),
		{ },
	},
};

static struct gpiod_lookup_table pxa_ssp4_gpio_table = {
	.dev_id = "pxa2xx-spi.4",
	.table = {
		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS3, "cs", 0, GPIO_ACTIVE_LOW),
		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS4, "cs", 1, GPIO_ACTIVE_LOW),
		{ },
	},
};

static struct platform_device *icontrol_spi_devices[] __initdata = {
	&pxa_spi_ssp3,
	&pxa_spi_ssp4,
@@ -175,6 +189,8 @@ static mfp_cfg_t mfp_can_cfg[] __initdata = {
static void __init icontrol_can_init(void)
{
	pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
	gpiod_add_lookup_table(&pxa_ssp3_gpio_table);
	gpiod_add_lookup_table(&pxa_ssp4_gpio_table);
	platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
	spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
}
+9 −1
Original line number Diff line number Diff line
@@ -195,7 +195,6 @@ static struct pxa2xx_spi_controller littleton_spi_info = {
static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
	.rx_threshold	= 1,
	.tx_threshold	= 1,
	.gpio_cs	= LITTLETON_GPIO_LCD_CS,
};

static struct spi_board_info littleton_spi_devices[] __initdata = {
@@ -208,8 +207,17 @@ static struct spi_board_info littleton_spi_devices[] __initdata = {
	},
};

static struct gpiod_lookup_table littleton_spi_gpio_table = {
	.dev_id = "pxa2xx-spi.2",
	.table = {
		GPIO_LOOKUP_IDX("gpio-pxa", LITTLETON_GPIO_LCD_CS, "cs", 0, GPIO_ACTIVE_LOW),
		{ },
	},
};

static void __init littleton_init_spi(void)
{
	gpiod_add_lookup_table(&littleton_spi_gpio_table);
	pxa2xx_set_spi_info(2, &littleton_spi_info);
	spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
}
Loading