Skip to content

Commit fa5af88

Browse files
author
Herton R. Krzesinski
committed
Merge: Provide support for SPI on Arm SystemReady IR devices (imx8 and nvidia orin)
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1949 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071848 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122415 Omitted-fix: 3672bb8 "spi: mediatek: skip delays if they are 0" Omitted-fix: be44918 "gpio: 74x164: Add SPI device ID table" Omitted-fix: a3e1693 "misc: gehc: Add SPI ID table" Omitted-fix: 9e2cd44 "eeprom: at25: Add SPI ID table" Omitted-fix: 137879f "eeprom: 93xx46: Add SPI device ID table" Omitted-fix: 2a2a795 "fpga: ice40-spi: Add SPI device ID table" Omitted-fix: ceef324 "ASoC: pcm179x: Add missing entries SPI to device ID table" Omitted-fix: 0cc3687 "ASoC: cs4341: Add SPI device ID table" Omitted-fix: 8719a17 "rtc: ds1302: Add SPI ID table" Omitted-fix: 5c4c2c8 "Input: ariel-pwrbutton - add SPI device ID table" Omitted-fix: 4ea673e "mfd: altr_a10sr: Add SPI device ID table" Omitted-fix: d5fa859 "mfd: cpcap: Add SPI device ID table" Omitted-fix: c5c7f06 "mfd: sprd: Add SPI device ID table" Omitted-fix: 03748d4 "iio: st_pressure_spi: Add missing entries SPI to device ID table" Omitted-fix: 7eba41f "tpm_tis_spi: Add missing SPI ID" Omitted-fix: 88362eb "net: dsa: b53: Add SPI ID table" Omitted-fix: 27a030e "mtd: dataflash: Add device-tree SPI IDs" Omitted-fix: 69a6d06 "mtd: mchp48l640: Add SPI ID table" Omitted-fix: bc7ee2e "mtd: mchp23k256: Add SPI ID table" Omitted-fix: 855fe49 "net: dsa: sja1105: silent spi_device_id warnings" Omitted-fix: 1774559 "net: dsa: vitesse-vsc73xx: silent spi_device_id warnings" Omitted-fix: c5cdb92 "ARM: pxa2xx: Fix GPIO descriptor tables" Omitted-fix: ac4f834 "mtd: dataflash: Add SPI ID table" Omitted-fix: 36acf80 "spi: meson-spicc: do not rely on busy flag in pow2 clk ops" Omitted-fix: f427527 "eeprom: 93xx46: fix MODULE_DEVICE_TABLE" Omitted-fix: 15e66fc "staging: fbtft: add macro FBTFT_REGISTER_SPI_DRIVER" Omitted-fix: 1bba199 "net: vertexcom: mse102x: Silence no spi_device_id warnings" Omitted-fix: a42f363 "media: ir-spi: silence no spi_device_id warnings" Omitted-fix: 4eb61e1 "iio: adc: ti-ads131e08: Silence no spi_device_id warnings" Omitted-fix: 35dab73 "iio: accel: sca3300: Silence no spi_device_id warning" Omitted-fix: 2830265 "iio: adc: ad9467: Silence no spi_device_id warnings" Omitted-fix: 935779e "iio: adc: ad7192: Silence no spi_device_id warnings" Omitted-fix: 3a25874 "iio: adc: ad7124: Silence no spi_device_id warnings" Omitted-fix: 5f71994 "mmc: spi: Add device-tree SPI IDs" Omitted-fix: 6840615 "spi: spidev: Add SPI ID table" Omitted-fix: fffc84f "spi: spidev: Make probe to fail early if a spidev compatible is used" All of the above omitted fixes are for devices not enabled or not present in RHEL Omitted-fix: e3dc139 spi: Make spi_alloc_device and spi_add_device public again Revumatic mentions this one as a maybe, but it is in this MR with a different sha1 (941bffd) Update drivers/spi for currently enabled SPI devices and enable the tegra210 SPI driver for Nvidia's Orin and Grace platforms. Signed-off-by: Mark Salter <msalter@redhat.com> Approved-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Dean Nelson <dnelson@redhat.com> Approved-by: Eric Chanudet <echanude@redhat.com> Approved-by: Brian Masney <bmasney@redhat.com> Approved-by: Andrew Halaney <ahalaney@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 5558b23 + e862a0b commit fa5af88

36 files changed

+2032
-1431
lines changed

Documentation/spi/pxa2xx.rst

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ device. All fields are optional.
101101
u8 rx_threshold;
102102
u8 dma_burst_size;
103103
u32 timeout;
104-
u8 enable_loopback;
105-
void (*cs_control)(u32 command);
106104
};
107105

108106
The "pxa2xx_spi_chip.tx_threshold" and "pxa2xx_spi_chip.rx_threshold" fields are
@@ -128,16 +126,6 @@ dependent on the SPI bus speed ("spi_board_info.max_speed_hz") and the specific
128126
slave device. Please note that the PXA2xx SSP 1 does not support trailing byte
129127
timeouts and must busy-wait any trailing bytes.
130128

131-
The "pxa2xx_spi_chip.enable_loopback" field is used to place the SSP porting
132-
into internal loopback mode. In this mode the SSP controller internally
133-
connects the SSPTX pin to the SSPRX pin. This is useful for initial setup
134-
testing.
135-
136-
The "pxa2xx_spi_chip.cs_control" field is used to point to a board specific
137-
function for asserting/deasserting a slave device chip select. If the field is
138-
NULL, the pxa2xx_spi master controller driver assumes that the SSP port is
139-
configured to use GPIO or SSPFRM instead.
140-
141129
NOTE: the SPI driver cannot control the chip select if SSPFRM is used, so the
142130
chipselect is dropped after each spi_transfer. Most devices need chip select
143131
asserted around the complete message. Use SSPFRM as a GPIO (through a descriptor)
@@ -152,38 +140,18 @@ field. Below is a sample configuration using the PXA255 NSSP.
152140

153141
::
154142

155-
/* Chip Select control for the CS8415A SPI slave device */
156-
static void cs8415a_cs_control(u32 command)
157-
{
158-
if (command & PXA2XX_CS_ASSERT)
159-
GPCR(2) = GPIO_bit(2);
160-
else
161-
GPSR(2) = GPIO_bit(2);
162-
}
163-
164-
/* Chip Select control for the CS8405A SPI slave device */
165-
static void cs8405a_cs_control(u32 command)
166-
{
167-
if (command & PXA2XX_CS_ASSERT)
168-
GPCR(3) = GPIO_bit(3);
169-
else
170-
GPSR(3) = GPIO_bit(3);
171-
}
172-
173143
static struct pxa2xx_spi_chip cs8415a_chip_info = {
174144
.tx_threshold = 8, /* SSP hardward FIFO threshold */
175145
.rx_threshold = 8, /* SSP hardward FIFO threshold */
176146
.dma_burst_size = 8, /* Byte wide transfers used so 8 byte bursts */
177147
.timeout = 235, /* See Intel documentation */
178-
.cs_control = cs8415a_cs_control, /* Use external chip select */
179148
};
180149

181150
static struct pxa2xx_spi_chip cs8405a_chip_info = {
182151
.tx_threshold = 8, /* SSP hardward FIFO threshold */
183152
.rx_threshold = 8, /* SSP hardward FIFO threshold */
184153
.dma_burst_size = 8, /* Byte wide transfers used so 8 byte bursts */
185154
.timeout = 235, /* See Intel documentation */
186-
.cs_control = cs8405a_cs_control, /* Use external chip select */
187155
};
188156

189157
static struct spi_board_info streetracer_spi_board_info[] __initdata = {

Documentation/spi/spi-summary.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,6 @@ certainly includes SPI devices hooked up through the card connectors!
336336
Non-static Configurations
337337
^^^^^^^^^^^^^^^^^^^^^^^^^
338338

339-
Developer boards often play by different rules than product boards, and one
340-
example is the potential need to hotplug SPI devices and/or controllers.
341-
342-
For those cases you might need to use spi_busnum_to_master() to look
343-
up the spi bus master, and will likely need spi_new_device() to provide the
344-
board info based on the board that was hotplugged. Of course, you'd later
345-
call at least spi_unregister_device() when that board is removed.
346-
347339
When Linux includes support for MMC/SD/SDIO/DataFlash cards through SPI, those
348340
configurations will also be dynamic. Fortunately, such devices all support
349341
basic device identification probes, so they should hotplug normally.

arch/arm/mach-pxa/corgi.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,16 @@ static struct pxa2xx_spi_controller corgi_spi_info = {
530530
.num_chipselect = 3,
531531
};
532532

533+
static struct gpiod_lookup_table corgi_spi_gpio_table = {
534+
.dev_id = "pxa2xx-spi.1",
535+
.table = {
536+
GPIO_LOOKUP_IDX("gpio-pxa", CORGI_GPIO_ADS7846_CS, "cs", 0, GPIO_ACTIVE_LOW),
537+
GPIO_LOOKUP_IDX("gpio-pxa", CORGI_GPIO_LCDCON_CS, "cs", 1, GPIO_ACTIVE_LOW),
538+
GPIO_LOOKUP_IDX("gpio-pxa", CORGI_GPIO_MAX1111_CS, "cs", 2, GPIO_ACTIVE_LOW),
539+
{ },
540+
},
541+
};
542+
533543
static void corgi_wait_for_hsync(void)
534544
{
535545
while (gpio_get_value(CORGI_GPIO_HSYNC))
@@ -548,10 +558,6 @@ static struct ads7846_platform_data corgi_ads7846_info = {
548558
.wait_for_sync = corgi_wait_for_hsync,
549559
};
550560

551-
static struct pxa2xx_spi_chip corgi_ads7846_chip = {
552-
.gpio_cs = CORGI_GPIO_ADS7846_CS,
553-
};
554-
555561
static void corgi_bl_kick_battery(void)
556562
{
557563
void (*kick_batt)(void);
@@ -580,41 +586,31 @@ static struct corgi_lcd_platform_data corgi_lcdcon_info = {
580586
.kick_battery = corgi_bl_kick_battery,
581587
};
582588

583-
static struct pxa2xx_spi_chip corgi_lcdcon_chip = {
584-
.gpio_cs = CORGI_GPIO_LCDCON_CS,
585-
};
586-
587-
static struct pxa2xx_spi_chip corgi_max1111_chip = {
588-
.gpio_cs = CORGI_GPIO_MAX1111_CS,
589-
};
590-
591589
static struct spi_board_info corgi_spi_devices[] = {
592590
{
593591
.modalias = "ads7846",
594592
.max_speed_hz = 1200000,
595593
.bus_num = 1,
596594
.chip_select = 0,
597595
.platform_data = &corgi_ads7846_info,
598-
.controller_data= &corgi_ads7846_chip,
599596
.irq = PXA_GPIO_TO_IRQ(CORGI_GPIO_TP_INT),
600597
}, {
601598
.modalias = "corgi-lcd",
602599
.max_speed_hz = 50000,
603600
.bus_num = 1,
604601
.chip_select = 1,
605602
.platform_data = &corgi_lcdcon_info,
606-
.controller_data= &corgi_lcdcon_chip,
607603
}, {
608604
.modalias = "max1111",
609605
.max_speed_hz = 450000,
610606
.bus_num = 1,
611607
.chip_select = 2,
612-
.controller_data= &corgi_max1111_chip,
613608
},
614609
};
615610

616611
static void __init corgi_init_spi(void)
617612
{
613+
gpiod_add_lookup_table(&corgi_spi_gpio_table);
618614
pxa2xx_set_spi_info(1, &corgi_spi_info);
619615
gpiod_add_lookup_table(&corgi_lcdcon_gpio_table);
620616
spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices));

arch/arm/mach-pxa/hx4700.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ static struct pxa2xx_spi_chip tsc2046_chip = {
616616
.tx_threshold = 1,
617617
.rx_threshold = 2,
618618
.timeout = 64,
619-
.gpio_cs = GPIO88_HX4700_TSC2046_CS,
620619
};
621620

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

637+
static struct gpiod_lookup_table pxa_ssp2_gpio_table = {
638+
.dev_id = "pxa2xx-spi.2",
639+
.table = {
640+
GPIO_LOOKUP_IDX("gpio-pxa", GPIO88_HX4700_TSC2046_CS, "cs", 0, GPIO_ACTIVE_LOW),
641+
{ },
642+
},
643+
};
644+
638645
/*
639646
* External power
640647
*/
@@ -896,6 +903,7 @@ static void __init hx4700_init(void)
896903
pxa_set_i2c_info(NULL);
897904
i2c_register_board_info(0, ARRAY_AND_SIZE(i2c_board_info));
898905
i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info));
906+
gpiod_add_lookup_table(&pxa_ssp2_gpio_table);
899907
pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
900908
spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));
901909

arch/arm/mach-pxa/icontrol.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/irq.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/property.h>
16-
#include <linux/gpio.h>
16+
#include <linux/gpio/machine.h>
1717

1818
#include <asm/mach-types.h>
1919
#include <asm/mach/arch.h>
@@ -42,31 +42,27 @@ static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
4242
.rx_threshold = 128,
4343
.dma_burst_size = 8,
4444
.timeout = 235,
45-
.gpio_cs = ICONTROL_MCP251x_nCS1
4645
};
4746

4847
static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
4948
.tx_threshold = 8,
5049
.rx_threshold = 128,
5150
.dma_burst_size = 8,
5251
.timeout = 235,
53-
.gpio_cs = ICONTROL_MCP251x_nCS2
5452
};
5553

5654
static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
5755
.tx_threshold = 8,
5856
.rx_threshold = 128,
5957
.dma_burst_size = 8,
6058
.timeout = 235,
61-
.gpio_cs = ICONTROL_MCP251x_nCS3
6259
};
6360

6461
static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
6562
.tx_threshold = 8,
6663
.rx_threshold = 128,
6764
.dma_burst_size = 8,
6865
.timeout = 235,
69-
.gpio_cs = ICONTROL_MCP251x_nCS4
7066
};
7167

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

142+
static struct gpiod_lookup_table pxa_ssp3_gpio_table = {
143+
.dev_id = "pxa2xx-spi.3",
144+
.table = {
145+
GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS1, "cs", 0, GPIO_ACTIVE_LOW),
146+
GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS2, "cs", 1, GPIO_ACTIVE_LOW),
147+
{ },
148+
},
149+
};
150+
151+
static struct gpiod_lookup_table pxa_ssp4_gpio_table = {
152+
.dev_id = "pxa2xx-spi.4",
153+
.table = {
154+
GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS3, "cs", 0, GPIO_ACTIVE_LOW),
155+
GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS4, "cs", 1, GPIO_ACTIVE_LOW),
156+
{ },
157+
},
158+
};
159+
146160
static struct platform_device *icontrol_spi_devices[] __initdata = {
147161
&pxa_spi_ssp3,
148162
&pxa_spi_ssp4,
@@ -175,6 +189,8 @@ static mfp_cfg_t mfp_can_cfg[] __initdata = {
175189
static void __init icontrol_can_init(void)
176190
{
177191
pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
192+
gpiod_add_lookup_table(&pxa_ssp3_gpio_table);
193+
gpiod_add_lookup_table(&pxa_ssp4_gpio_table);
178194
platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
179195
spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
180196
}

arch/arm/mach-pxa/littleton.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ static struct pxa2xx_spi_controller littleton_spi_info = {
195195
static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
196196
.rx_threshold = 1,
197197
.tx_threshold = 1,
198-
.gpio_cs = LITTLETON_GPIO_LCD_CS,
199198
};
200199

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

210+
static struct gpiod_lookup_table littleton_spi_gpio_table = {
211+
.dev_id = "pxa2xx-spi.2",
212+
.table = {
213+
GPIO_LOOKUP_IDX("gpio-pxa", LITTLETON_GPIO_LCD_CS, "cs", 0, GPIO_ACTIVE_LOW),
214+
{ },
215+
},
216+
};
217+
211218
static void __init littleton_init_spi(void)
212219
{
220+
gpiod_add_lookup_table(&littleton_spi_gpio_table);
213221
pxa2xx_set_spi_info(2, &littleton_spi_info);
214222
spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
215223
}

arch/arm/mach-pxa/magician.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,15 +938,22 @@ struct pxa2xx_spi_chip tsc2046_chip_info = {
938938
.tx_threshold = 1,
939939
.rx_threshold = 2,
940940
.timeout = 64,
941-
/* NOTICE must be GPIO, incompatibility with hw PXA SPI framing */
942-
.gpio_cs = GPIO14_MAGICIAN_TSC2046_CS,
943941
};
944942

945943
static struct pxa2xx_spi_controller magician_spi_info = {
946944
.num_chipselect = 1,
947945
.enable_dma = 1,
948946
};
949947

948+
static struct gpiod_lookup_table magician_spi_gpio_table = {
949+
.dev_id = "pxa2xx-spi.2",
950+
.table = {
951+
/* NOTICE must be GPIO, incompatibility with hw PXA SPI framing */
952+
GPIO_LOOKUP_IDX("gpio-pxa", GPIO14_MAGICIAN_TSC2046_CS, "cs", 0, GPIO_ACTIVE_LOW),
953+
{ },
954+
},
955+
};
956+
950957
static struct spi_board_info ads7846_spi_board_info[] __initdata = {
951958
{
952959
.modalias = "ads7846",
@@ -1031,6 +1038,7 @@ static void __init magician_init(void)
10311038
} else
10321039
pr_err("LCD detection: CPLD mapping failed\n");
10331040

1041+
gpiod_add_lookup_table(&magician_spi_gpio_table);
10341042
pxa2xx_set_spi_info(2, &magician_spi_info);
10351043
spi_register_board_info(ARRAY_AND_SIZE(ads7846_spi_board_info));
10361044

arch/arm/mach-pxa/poodle.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ static struct pxa2xx_spi_controller poodle_spi_info = {
197197
.num_chipselect = 1,
198198
};
199199

200+
static struct gpiod_lookup_table poodle_spi_gpio_table = {
201+
.dev_id = "pxa2xx-spi.1",
202+
.table = {
203+
GPIO_LOOKUP_IDX("gpio-pxa", POODLE_GPIO_TP_CS, "cs", 0, GPIO_ACTIVE_LOW),
204+
{ },
205+
},
206+
};
207+
200208
static struct ads7846_platform_data poodle_ads7846_info = {
201209
.model = 7846,
202210
.vref_delay_usecs = 100,
@@ -205,23 +213,19 @@ static struct ads7846_platform_data poodle_ads7846_info = {
205213
.gpio_pendown = POODLE_GPIO_TP_INT,
206214
};
207215

208-
static struct pxa2xx_spi_chip poodle_ads7846_chip = {
209-
.gpio_cs = POODLE_GPIO_TP_CS,
210-
};
211-
212216
static struct spi_board_info poodle_spi_devices[] = {
213217
{
214218
.modalias = "ads7846",
215219
.max_speed_hz = 10000,
216220
.bus_num = 1,
217221
.platform_data = &poodle_ads7846_info,
218-
.controller_data= &poodle_ads7846_chip,
219222
.irq = PXA_GPIO_TO_IRQ(POODLE_GPIO_TP_INT),
220223
},
221224
};
222225

223226
static void __init poodle_init_spi(void)
224227
{
228+
gpiod_add_lookup_table(&poodle_spi_gpio_table);
225229
pxa2xx_set_spi_info(1, &poodle_spi_info);
226230
spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
227231
}

0 commit comments

Comments
 (0)