Driver for the Atmel on-chip SSC on AT32AP and AT91.
PATCH RESEND 1/1 Driver for the Atmel on-chip SSC on AT32AP and AT91.
The Synchronous Serial Controller (SSC) on Atmel microprocessors are capable of tranceiving many frame based protocols, like I2S. Tested on the AT32AP7000/ATSTK1000.
This driver is used in the ALSA sound driver for the AT73C213 external DAC on the ATSTK1000 development board for AVR32. This sound driver will be submitted soon.
Hardware documentation can be found in the AT32AP7000 data sheet, which can be downloaded from http://www.atmel.com/dyn/products/datasheets.asp?family_id=682
I am sorry if anybody is receiving this twice, but it seems like this patch was eaten by my mail server the first time I sent it.
--- drivers/misc/Kconfig | 10 ++ drivers/misc/Makefile | 1 + drivers/misc/atmel-ssc.c | 175 +++++++++++++++++++++++++ include/linux/atmel-ssc.h | 312 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 498 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/atmel-ssc.c create mode 100644 include/linux/atmel-ssc.h
drivers/misc/Kconfig +10 -0
@@ -187,5 +187,15 @@ config THINKPAD_ACPI_BAY If you are not sure, say Y here. +config ATMEL_SSC + tristate "Device driver for Atmel SSC peripheral" + depends on AVR32 || ARCH_AT91 + ---help--- + This option enables device driver support for Atmel Syncronized + Serial Communication peripheral (SSC). + + The SSC peripheral supports a wide variety of serial frame based + communications, i.e. I2S, SPI, etc. + If unsure, say N. endmenu
drivers/misc/Makefile +1 -0
@@ -14,3 +14,4 @@ obj-$(CONFIG_PHANTOM) += phantom.o obj-$(CONFIG_SGI_IOC4) += ioc4.o obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o +obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
drivers/misc/atmel-ssc.c new file +175 -0
175 lines not on this page · raw message
include/linux/atmel-ssc.h new file +312 -0
312 lines not on this page · raw message
Signature · 7 lines
1.5.2.3 -- With kind regards, Hans-Christian Egtvedt, siv.ing. (M.Sc.) Applications Engineer - AVR32 System Solutions - Atmel Norway
hi Hans-Christian,
Quoted 3 lines
This driver is used in the ALSA sound driver for the AT73C213 external DAC on the ATSTK1000 development board for AVR32. This sound driver will be submitted soon.
Seems to be more of an SCC unit allocation library, but OK.
I've also forwarded a copy of the patch to Frank Mandarino <[email protected]> for his comments. He maintains the current AT91 SSC & ALSA support. <sound/soc/at91/>
include/linux/atmel-ssc.h line 45
Quoted 7 lines
include/linux/atmel-ssc.h new file +7
-0+/* SSC Receive Clock Mode Register */ +#define SSC_RCMR 0x00000010 +#define SSC_RCMR_CKG_SIZE 2 +#define SSC_RCMR_CKG_OFFSET 6 +#define SSC_RCMR_CKI_SIZE 1 +#define SSC_RCMR_CKI_OFFSET 5 +#define SSC_RCMR_CKO_SIZE 3
I'm personally not a fan of the register & bit definition format the AVR32 driver seem to use.
Can we not rather move the existing include/asm-arm/arch-at91/at91_ssc.h to somewhere shared as atmel_ssc.h ?
Regards,
Andrew Victor
Quoted 7 lines · Andrew Victor
hi Hans-Christian,
Quoted 3 lines
This driver is used in the ALSA sound driver for the AT73C213 external DAC on the ATSTK1000 development board for AVR32. This sound driver will be submitted soon.
Seems to be more of an SCC unit allocation library, but OK.
Correct, makes it easier for other modules to request the SSC peripheral and get access to the registers and irq.
The AT73C213 sound driver was submitted to the alsa-dev list.
Quoted 4 lines
I've also forwarded a copy of the patch to Frank Mandarino <[email protected]> for his comments. He maintains the current AT91 SSC & ALSA support. <
sound/soc/at91/>
Quoted 12 lines
include/linux/atmel-ssc.h line 45
Quoted 7 lines
include/linux/atmel-ssc.h new file +7
-0+/* SSC Receive Clock Mode Register */ +#define SSC_RCMR 0x00000010 +#define SSC_RCMR_CKG_SIZE 2 +#define SSC_RCMR_CKG_OFFSET 6 +#define SSC_RCMR_CKI_SIZE 1 +#define SSC_RCMR_CKI_OFFSET 5 +#define SSC_RCMR_CKO_SIZE 3I'm personally not a fan of the register & bit definition format the AVR32 driver seem to use.
Can we not rather move the existinginclude/asm-arm/arch-at91/at91_ssc.hto somewhere shared asatmel_ssc.h?
I disagree, by using the model above the user does not have to know the bit field offsets as they will need with the defines in include/asm-arm/arch-at91/at91_ssc.h.
Just an example from sound/soc/at91/at91-ssc.c
rcmr = (( ssc_p->rcmr_period << 24) & AT91_SSC_PERIOD)
| (( 1 << 16) & AT91_SSC_STTDLY) | (( AT91_SSC_START_FALLING_RF ) & AT91_SSC_START) | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI) | (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO) | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
Would with the header style for atmel-ssc be:
rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period)
| SSC_BF(RCMR_STTDLY, 1) | SSC_BF(RCMR_START, 4) | SSC_BF(RCMR_CKI, 1) | SSC_BF(RCMR_CKO, 0) | SSC_BF(RCMR_CKS, 0);
I find the latter more readable and compact, the user also does not need to know the offset of the different bit-fields.
I agree that describing names for the different bit-fields is nice. Similar to the way the AVR32 standalone headers are built up.
Signature · 4 lines
With kind regards, Hans-Christian Egtvedt, siv.ing. (M.Sc.) Applications Engineer - AVR32 System Solutions - Atmel Norway
hi Hans-Christian,
Quoted 8 lines
Just an example from
sound/soc/at91/at91-ssc.crcmr = ((
ssc_p->rcmr_period<< 24) &AT91_SSC_PERIOD)| (( 1 << 16) & AT91_SSC_STTDLY) | (( AT91_SSC_START_FALLING_RF ) & AT91_SSC_START) | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI) | (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO) | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
Well, I didn't write the above, so it's more complex than it needs to be.
For bitfields where the user can input any value we would usually add to the header:
#define AT91_SSC_STTDLY_(x) ((x) << 16)
#define AT91_SSC_PERIOD_(x) ((x) << 24)
Then it can simply be re-written as:
rcmr = AT91_SSC_PERIOD(ssc_p->rcmr_period)
| AT91_SSC_STTDLY(1) | AT91_SSC_START_FALLING_RF | AT91_SSC_CK_RISING | AT91_SSC_CKO_NONE | AT91_SSC_CKS_DIV;
Quoted 11 lines
Would with the header style for atmel-ssc be:
rcmr =
SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period)| SSC_BF(RCMR_STTDLY, 1) | SSC_BF(RCMR_START, 4) | SSC_BF(RCMR_CKI, 1) | SSC_BF(RCMR_CKO, 0) | SSC_BF(RCMR_CKS, 0);I find the latter more readable and compact, the user also does not need to know the offset of the different bit-fields.
But the user does then constantly have to refer to the datasheet to determine what CKI = 1 or CKS = 0 means.
Regards,
Andrew Victor
Hi Andrew,
Quoted 18 lines · Andrew Victor
Quoted 8 lines
Just an example from
sound/soc/at91/at91-ssc.crcmr = ((
ssc_p->rcmr_period<< 24) &AT91_SSC_PERIOD)| (( 1 << 16) & AT91_SSC_STTDLY) | (( AT91_SSC_START_FALLING_RF ) & AT91_SSC_START) | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI) | (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO) | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);Well, I didn't write the above, so it's more complex than it needs to be.
For bitfields where the user can input any value we would usually add to
the header:#define AT91_SSC_STTDLY_(x) ((x) << 16) #define AT91_SSC_PERIOD_(x) ((x) << 24)
Quoted 8 lines
Then it can simply be re-written as:
rcmr =
AT91_SSC_PERIOD(ssc_p->rcmr_period)| AT91_SSC_STTDLY(1) | AT91_SSC_START_FALLING_RF | AT91_SSC_CK_RISING | AT91_SSC_CKO_NONE | AT91_SSC_CKS_DIV;
This is more sane and readable.
Quoted 9 lines
Quoted 9 lines
Would with the header style for atmel-ssc be:
rcmr =
SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period)| SSC_BF(RCMR_STTDLY, 1) | SSC_BF(RCMR_START, 4) | SSC_BF(RCMR_CKI, 1) | SSC_BF(RCMR_CKO, 0) | SSC_BF(RCMR_CKS, 0);
Quoted 6 lines
Quoted 1 line
I find the latter more readable and compact, the user also does not
need
Quoted 1 line
to know the offset of the different bit-fields.
But the user does then constantly have to refer to the datasheet to determine what CKI = 1 or CKS = 0 means.
As I said two lines furter down, I think these defines are nice. Will adding bit-field descriptors make the SSC driver more usable by the AT91 people?
I guess there is also the possibility to include the ARM headers for that architecture and use the definitions in the header file for AVR32.
Signature · 4 lines
With kind regards, Hans-Christian Egtvedt, siv.ing. (M.Sc.) Applications Engineer - AVR32 System Solutions - Atmel Norway