RFC: spi/sa1100: rewrite the SA1100 SPI driver
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
This heavily rewrites the SA1100 SPI driver and moves it to the SPI subsystem. I seriously doubt it will work (though you're encouraged to give it a spin). It is meant as a starting point for others who are able to pick up on it. I discussed this with Kristoffer some time back.
The Jornada 720 seems to be the only in-kernel user of the SSP, so the MCU driver (now called jornada720_ssp.c) is now an SPI device on the SPI bus, and the jornada720_ssp is just "some SPI device". Anything generic (like GPIO toggling to sync to the other side) is now in the SPI driver. The spinlock across transfers found in jornada720_ssp is probably not going to play well with the SPI subsystem so this has been replaced by a mutex.
--- arch/arm/include/asm/hardware/ssp.h | 28 -- arch/arm/mach-sa1100/Kconfig | 10 +- arch/arm/mach-sa1100/Makefile | 1 - arch/arm/mach-sa1100/include/mach/SA-1100.h | 88 +----- arch/arm/mach-sa1100/include/mach/sa1100-ssp.h | 15 + arch/arm/mach-sa1100/jornada720.c | 52 +++- arch/arm/mach-sa1100/jornada720_ssp.c | 79 ++--- arch/arm/mach-sa1100/ssp.c | 243 ------------- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/spi-sa1100.c | 461 ++++++++++++++++++++++++ 11 files changed, 569 insertions(+), 416 deletions(-) delete mode 100644 arch/arm/include/asm/hardware/ssp.h create mode 100644 arch/arm/mach-sa1100/include/mach/sa1100-ssp.h delete mode 100644 arch/arm/mach-sa1100/ssp.c create mode 100644 drivers/spi/spi-sa1100.c
arch/arm/include/asm/hardware/ssp.h deleted +0 -28
@@ -1,28 +0,0 @@ -/* -* ssp.h -* -* Copyright (C) 2003 Russell King, All Rights Reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -*/ -#ifndef SSP_H -#define SSP_H - -struct ssp_state { -unsigned int cr0; -unsigned int cr1; -}; - -int ssp_write_word (u16 data); -int ssp_read_word (u16 *data); -int ssp_flush (void ); -void ssp_enable (void ); -void ssp_disable (void ); -void ssp_save_state (struct ssp_state *ssp); -void ssp_restore_state (struct ssp_state *ssp); -int ssp_init (void ); -void ssp_exit (void ); - -#endif
arch/arm/mach-sa1100/Kconfig +2 -8
@@ -95,7 +95,8 @@ config SA1100_JORNADA720 config SA1100_JORNADA720_SSP bool "HP Jornada 720 Extended SSP driver" - select SA1100_SSP + select SPI + select SPI_SA1100 depends on SA1100_JORNADA720 help Say Y here if you have a HP Jornada 7xx handheld computer and you
@@ -157,13 +158,6 @@ config SA1100_SIMPAD like CL4 in additional it has a PCMCIA-Slot. For more information visit <http://www.usa.siemens.com/> or <http://www.siemens.ch/>. -config SA1100_SSP - tristate "Generic PIO SSP" - help - Say Y here to enable support for the generic PIO SSP driver. - This isn't for audio support, but for attached sensors and - other devices, eg for BadgePAD 4 sensor support. - endmenu endif
arch/arm/mach-sa1100/Makefile +0 -1
@@ -51,5 +51,4 @@ obj-$(CONFIG_LEDS) += $(led-y) # Miscellaneous functions obj-$(CONFIG_PM) += pm.o sleep.o -obj-$(CONFIG_SA1100_SSP) += ssp.o
arch/arm/mach-sa1100/include/mach/SA-1100.h +6 -82
102 lines not on this page · raw message
arch/arm/mach-sa1100/include/mach/sa1100-ssp.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Header file for the SA1100 SPI driver +*/ + +/** +* struct sa1100_ssp_plat_data - platform data for SA1100 SSP driver +* @en_gpio: GPIO pin to enable SSP device on the other end +* @rdy_gpio: GPIO pin to listen for ready flag for SSP device on other end - +* when this is given this GPIO pin will be polled for retrieveing +* words instead of using IRQ +*/ +struct sa1100_ssp_plat_data { +unsigned int en_gpio; +unsigned int rdy_gpio; +};
arch/arm/mach-sa1100/jornada720.c +45 -7
85 lines not on this page · raw message
arch/arm/mach-sa1100/jornada720_ssp.c +32 -47
149 lines not on this page · raw message
arch/arm/mach-sa1100/ssp.c deleted +0 -243
243 lines not on this page · raw message
drivers/spi/Kconfig +7 -0
@@ -305,6 +305,13 @@ config SPI_S3C64XX help SPI driver for Samsung S3C64XX and newer SoCs. +config SPI_SA1100 + tristate "SA1100 PIO SSP" + help + Say Y here to enable support for the SA1100 SSP/SPI driver. + This isn't for audio support, but for attached sensors and + other devices, eg for BadgePAD 4 sensor support. + config SPI_SH_MSIOF tristate "SuperH MSIOF SPI controller" depends on SUPERH && HAVE_CLK
drivers/spi/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_SPI_S3C24XX) += spi-s3c24xx-hw.o spi-s3c24xx-hw-y := spi-s3c24xx.o spi-s3c24xx-hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi-s3c24xx-fiq.o obj-$(CONFIG_SPI_S3C64XX) += spi-s3c64xx.o +obj-$(CONFIG_SPI_SA1100) += spi-sa1100.o obj-$(CONFIG_SPI_SH) += spi-sh.o obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o
drivers/spi/spi-sa1100.c new file +461 -0
461 lines not on this page · raw message
Signature · 1 line
1.7.7.5
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
Quoted 96 lines · Linus Walleij
arch/arm/mach-sa1100/include/mach/SA-1100.h +4
-80@@ -727,86 +727,10 @@#define MCCR1_F10MHz (MCCR1_CFS*1)/* Freq. (fmc) = ~ 10 MHz */ /* (9.585 MHz) */ - -/* -* Synchronous Serial Port (SSP) control registers -* -* Registers -* Ser4SSCR0 Serial port 4 Synchronous Serial Port (SSP) Control -* Register 0 (read/write). -* Ser4SSCR1 Serial port 4 Synchronous Serial Port (SSP) Control -* Register 1 (read/write). -* [Bits SPO and SP are only implemented in versions 2.0 -* (rev. = 8) and higher of the StrongARM SA-1100.] -* Ser4SSDR Serial port 4 Synchronous Serial Port (SSP) Data -* Register (read/write). -* Ser4SSSR Serial port 4 Synchronous Serial Port (SSP) Status -* Register (read/write). -* -* Clocks -* fxtl, Txtl Frequency, period of the system crystal (3.6864 MHz -* or 3.5795 MHz). -* fss, Tss Frequency, period of the SSP communication. -*/ - -#define Ser4SSCR0 __REG(0x80070060)/* Ser. port 4 SSP Control Reg. 0 */ -#define Ser4SSCR1 __REG(0x80070064)/* Ser. port 4 SSP Control Reg. 1 */ -#define Ser4SSDR __REG(0x8007006C)/* Ser. port 4 SSP Data Reg. */ -#define Ser4SSSR __REG(0x80070074)/* Ser. port 4 SSP Status Reg. */ - -#define SSCR0_DSS Fld (4, 0)/* Data Size - 1 Select [3..15] */ -#define SSCR0_DataSize (Size)/* Data Size Select [4..16] */ \ - (((Size) - 1) << FShft (SSCR0_DSS)) -#define SSCR0_FRF Fld (2, 4)/* FRame Format */ -#define SSCR0_Motorola/* Motorola Serial Peripheral */ \ -/* Interface (SPI) format */ \ - (0 << FShft (SSCR0_FRF)) -#define SSCR0_TI /* Texas Instruments Synchronous */ \ -/* Serial format */ \ - (1 << FShft (SSCR0_FRF)) -#define SSCR0_National/* National Microwire format */ \ - (2 << FShft (SSCR0_FRF)) -#define SSCR0_SSE 0x00000080/* SSP Enable */ -#define SSCR0_SCR Fld (8, 8)/* Serial Clock Rate divisor/2 - 1 */ -/* fss = fxtl/(2*(SCR + 1)) */ -/* Tss = 2*(SCR + 1)*Txtl */ -#define SSCR0_SerClkDiv (Div)/* Serial Clock Divisor [2..512] */ \ - (((Div) - 2)/2 << FShft (SSCR0_SCR)) -/* fss = fxtl/(2*Floor (Div/2)) */ -/* Tss = 2*Floor (Div/2)*Txtl */ -#define SSCR0_CeilSerClkDiv (Div)/* Ceil. of SerClkDiv [2..512] */ \ - (((Div) - 1)/2 << FShft (SSCR0_SCR)) -/* fss = fxtl/(2*Ceil (Div/2)) */ -/* Tss = 2*Ceil (Div/2)*Txtl */ - -#define SSCR1_RIE 0x00000001/* Receive FIFO 1/2-full or more */ -/* Interrupt Enable */ -#define SSCR1_TIE 0x00000002/* Transmit FIFO 1/2-full or less */ -/* Interrupt Enable */ -#define SSCR1_LBM 0x00000004/* Look-Back Mode */ -#define SSCR1_SPO 0x00000008/* Sample clock (SCLK) POlarity */ -#define SSCR1_SClkIactL (SSCR1_SPO*0)/* Sample Clock Inactive Low */ -#define SSCR1_SClkIactH (SSCR1_SPO*1)/* Sample Clock Inactive High */ -#define SSCR1_SP 0x00000010/* Sample clock (SCLK) Phase */ -#define SSCR1_SClk1P (SSCR1_SP*0)/* Sample Clock active 1 Period */ -/* after frame (SFRM, 1st edge) */ -#define SSCR1_SClk1_2P (SSCR1_SP*1)/* Sample Clock active 1/2 Period */ -/* after frame (SFRM, 1st edge) */ -#define SSCR1_ECS 0x00000020/* External Clock Select */ -#define SSCR1_IntClk (SSCR1_ECS*0)/* Internal Clock */ -#define SSCR1_ExtClk (SSCR1_ECS*1)/* External Clock (GPIO [19]) */ - -#define SSDR_DATA Fld (16, 0)/* receive/transmit DATA FIFOs */ - -#define SSSR_TNF 0x00000002/* Transmit FIFO Not Full (read) */ -#define SSSR_RNE 0x00000004/* Receive FIFO Not Empty (read) */ -#define SSSR_BSY 0x00000008/* SSP BuSY (read) */ -#define SSSR_TFS 0x00000010/* Transmit FIFO 1/2-full or less */ -/* Service request (read) */ -#define SSSR_RFS 0x00000020/* Receive FIFO 1/2-full or more */ -/* Service request (read) */ -#define SSSR_ROR 0x00000040/* Receive FIFO Over-Run */ - +/* The driver will contain the offsets for this peripheral */ +#define Ser4SSBase 0x80070000 +/* Ser. port 4 SSP Data Reg. needed by DMA defines */ +#define Ser4SSDR_DMA __REG(Ser4SSBase + 0x6C)/* * Operating System (OS) timer control registers
arch/arm/mach-sa1100/include/mach/SA-1100.h line 1719
Quoted 9 lines
arch/arm/mach-sa1100/include/mach/SA-1100.h +2
-2@@ -1789,10 +1713,10 @@ DDAR_Ser4MCP1Rc + DDAR_DevAdd (__PREG(Ser4MCDR1)))#define DDAR_Ser4SSPWr/* Ser. port 4 SSP Write (16 bits) */ \ (DDAR_DevWr + DDAR_Brst4 + DDAR_16BitDev + \ - DDAR_Ser4SSPTr + DDAR_DevAdd (__PREG(Ser4SSDR))) + DDAR_Ser4SSPTr + DDAR_DevAdd (__PREG(Ser4SSDR_DMA)))#define DDAR_Ser4SSPRd/* Ser. port 4 SSP Read (16 bits) */ \ (DDAR_DevRd + DDAR_Brst4 + DDAR_16BitDev + \ - DDAR_Ser4SSPRc + DDAR_DevAdd (__PREG(Ser4SSDR))) + DDAR_Ser4SSPRc + DDAR_DevAdd (__PREG(Ser4SSDR_DMA)))
Please don't delete the above definitions.
The SSP interface is more than just SPI (it's microwire and TI format, and I have a working ASoC driver for the Assabet.)
In addition, I also have a DMA engine driver for the DMA stuff on SA1100, which couples into a generic DMA engine ASoC platform driver (though only for playback).
Oh, and a SA1100 IrDA driver converted to use the DMA engine stuff...
Patches will be posted after the merge window closes.
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
Quoted 1 line · Russell King - ARM Linux
Please don't delete the above definitions.
OK don't want to break anything...
Quoted 2 lines
The SSP interface is more than just SPI (it's microwire and TI format, and I have a working ASoC driver for the Assabet.)
We usually merge drivers for microwire, TI, Motorola ... etc into drivers/spi as well. It's a good enough fit, the differences are very small. This is how we configure mode from the PL022 driver platform data:
/**
* enum ssp_interface - interfaces allowed for this SSP Controller
* @SSP_INTERFACE_MOTOROLA_SPI: Motorola Interface
* @SSP_INTERFACE_TI_SYNC_SERIAL: Texas Instrument Synchronous Serial
* interface
* @SSP_INTERFACE_NATIONAL_MICROWIRE: National Semiconductor Microwire
* interface
* @SSP_INTERFACE_UNIDIRECTIONAL: Unidirectional interface (STn8810
* &STn8815 only)
*/
enum ssp_interface {
SSP_INTERFACE_MOTOROLA_SPI, SSP_INTERFACE_TI_SYNC_SERIAL, SSP_INTERFACE_NATIONAL_MICROWIRE, SSP_INTERFACE_UNIDIRECTIONAL
};
Quoted 5 lines
In addition, I also have a DMA engine driver for the DMA stuff on SA1100, which couples into a generic DMA engine ASoC platform driver (though only for playback).
Oh, and a SA1100 IrDA driver converted to use the DMA engine stuff...
That's pretty cool :-)
Quoted 1 line
Patches will be posted after the merge window closes.
I think it's better if something like this is based on top of your patch stack so as not to disrupt addition of new functionality. It'd be nice if you could make the branch available once you push that stuff to -next.
Yours,
Linus Walleij
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
Quoted 9 lines · Linus Walleij
Quoted 2 lines · Russell King - ARM Linux
The SSP interface is more than just SPI (it's microwire and TI format, and I have a working ASoC driver for the Assabet.)
We usually merge drivers for microwire, TI, Motorola ... etc into
drivers/spias well. It's a good enough fit, the differences are very small. This is how we configure mode from the PL022 driver platform data:
By the way, the similarities between the SA1100 SSP and the PL022 SSP/SPI were striking so I had a look at the register maps, but while many of the registers are similarly named and many of the same bits exist these bits are in wildly different places, so it's not directly mergeable.
It looks like the PL022 SSP is a hardware based on the SA1100 SSP datasheet or even the VHDL code for it.
PrimeCell geneaology is one of these funny things, If I find genetic evidence, i.e. the hardware happen to have the same obscure bugs, then I cosider the ancestry proven...
Yours,
Linus Walleij
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
In reply to Linus WalleijQuoted 5 lines · Linus Walleij
Quoted 1 line · Russell King - ARM Linux
Please don't delete the above definitions.
Quoted 8 lines
OK don't want to break anything...
Quoted 2 lines
The SSP interface is more than just SPI (it's microwire and TI format, and I have a working ASoC driver for the Assabet.)
We usually merge drivers for microwire, TI, Motorola ... etc into
drivers/spias well. It's a good enough fit, the differences are very small. This is how we configure mode from the PL022 driver platform data:
How do you send audio data at 16-bit 2 channel 48kHz continuously with the SPI subsystem?
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
Quoted 11 lines · Russell King - ARM Linux
Quoted 10 lines · Linus Walleij
Quoted 1 line · Russell King - ARM Linux
Please don't delete the above definitions.
OK don't want to break anything...
Quoted 2 lines
The SSP interface is more than just SPI (it's microwire and TI format, and I have a working ASoC driver for the Assabet.)
Quoted 6 lines
Quoted 3 lines
We usually merge drivers for microwire, TI, Motorola ... etc into
drivers/spias well. It's a good enough fit, the differences are very small. This is how we configure mode from the PL022 driver platform data:How do you send audio data at 16-bit 2 channel 48kHz continuously with the SPI subsystem?
Actually, feel free to move these definitions; my ASoC SSP driver already contains a cleaner copy of them.
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
In reply to Russell King - ARM LinuxQuoted 8 lines · Russell King - ARM Linux
Quoted 3 lines · Linus Walleij
We usually merge drivers for microwire, TI, Motorola ... etc into
drivers/spias well. It's a good enough fit, the differences are very small. This is how we configure mode from the PL022 driver platform data:How do you send audio data at 16-bit 2 channel 48kHz continuously with the SPI subsystem?
Can't say because we haven't used it for audio transfers. However I am pretty convinced that it'd work because we're running a 20 Mbit data link on that SPI port.
To get the high data rates we have an internal message queue in the driver that saturates the SPI port. Sometimes we even start to run parts of the driver in parallel on two cores: CPU0 is handling IRQs from the driver while CPU1 is preparing messages to/from the SPI subsystem.
Yours,
Linus Walleij
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
Quoted 15 lines · Linus Walleij
Quoted 8 lines · Russell King - ARM Linux
Quoted 3 lines · Linus Walleij
We usually merge drivers for microwire, TI, Motorola ... etc into
drivers/spias well. It's a good enough fit, the differences are very small. This is how we configure mode from the PL022 driver platform data:How do you send audio data at 16-bit 2 channel 48kHz continuously with the SPI subsystem?
Can't say because we haven't used it for audio transfers. However I am pretty convinced that it'd work because we're running a 20 Mbit data link on that SPI port.
Quoted 5 lines
To get the high data rates we have an internal message queue in the driver that saturates the SPI port. Sometimes we even start to run parts of the driver in parallel on two cores: CPU0 is handling IRQs from the driver while CPU1 is preparing messages to/from the SPI subsystem.
It's not the hardware that is the issue, it is the SPI subsystem which is absolutely not set up for the kind of low-latency (note: not high-throughput) transfers that are wanted for audio streams.
g.
PATCH 1/1 RFC: spi/sa1100: rewrite the SA1100 SPI driver
In reply to Linus WalleijQuoted 15 lines · Linus Walleij
Quoted 8 lines · Russell King - ARM Linux
Quoted 3 lines · Linus Walleij
We usually merge drivers for microwire, TI, Motorola ... etc into
drivers/spias well. It's a good enough fit, the differences are very small. This is how we configure mode from the PL022 driver platform data:How do you send audio data at 16-bit 2 channel 48kHz continuously with the SPI subsystem?
Can't say because we haven't used it for audio transfers. However I am pretty convinced that it'd work because we're running a 20 Mbit data link on that SPI port.
Quoted 5 lines
To get the high data rates we have an internal message queue in the driver that saturates the SPI port. Sometimes we even start to run parts of the driver in parallel on two cores: CPU0 is handling IRQs from the driver while CPU1 is preparing messages to/from the SPI subsystem.
A SMP system, which SA1100 is not.
With audio on the SA1100, we have to keep both DMA transfer buffer pointers filled to ensure that audio does not suffer. I don't see submitting multiple SPI transfers into the SPI subsystem would be able to do that without waiting for the previous transfer to stop completely before starting the next - and that implies the DMA transfer completes before starting to program up the next one.
What I'm saying is that SPI will want DMA activity to complete _and_ end before it starts on the next transfer, which is going to create a break in the data output.
Given that audio here just requires the SSP to be configured, and then everything else is just DMA, I don't see why we need to waste cycles fiddling with the SPI subsystem with its inherent batching of transfers.