Driver for the Atmel on-chip SSC on AT32AP and AT91.
PATCH 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
--- 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
Quoted 57 lines · On Mon, 16 Jul 2007 08:52:32 +0200 Hans-Christian Egtvedt…
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
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. endmenudrivers/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.odrivers/misc/atmel-ssc.c new file +11
-0@@ -0,0 +1,175 @@ +/* +* Atmel SSC driver +* +* Copyright (C) 2007 Atmel Corporation +* +* 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. +*/ + +#include <linux/platform_device.h>
drivers/misc/atmel-ssc.c line 21
Quoted 10 lines
drivers/misc/atmel-ssc.c new file +10
-0+#include <linux/list.h> +#include <linux/clk.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/list.h> +#include <linux/spinlock.h> +#include <linux/atmel-ssc.h> + +/* Serialize access to ssc_list and user count */ +static spinlock_t user_lock;
Use DEFINE_SPINLOCK() here, remove the runtime initialisation.
Quoted 24 lines
drivers/misc/atmel-ssc.c new file +24
-0+static LIST_HEAD (ssc_list); + +struct ssc_device *ssc_request (unsigned int ssc_num) +{ +int ssc_valid =0 ; +struct ssc_device *ssc; + +spin_lock (&user_lock); +list_for_each_entry (ssc, &ssc_list, list) { +if (ssc->pdev->id == ssc_num) { + ssc_valid =1 ; +break ; + } + } + +if (!ssc_valid) { +spin_unlock (&user_lock); +dev_dbg (&ssc->pdev->dev,"could not find requested device\n" ); +return ERR_PTR (-ENODEV ); + } + +if (ssc->user) { +spin_unlock (&user_lock); +dev_dbg (&ssc->pdev->dev,"module busy\n" );
drivers/misc/atmel-ssc.c line 55
Quoted 10 lines
drivers/misc/atmel-ssc.c new file +10
-0+return ERR_PTR (-EBUSY ); + } + ssc->user++; +spin_unlock (&user_lock); + +clk_enable (ssc->clk); + +return ssc; +} +EXPORT_SYMBOL (ssc_request);
All exports need justification, please. An additional paragraph in the changelog would suit.
I added this:
drivers/misc/atmel-ssc.c renamed from drivers/misc/atmel-ssc.c~driver-for-the-atmel-on-chip-ssc-on-at32ap-and-at91-fix +1 -2
@@ -18,7 +18,7 @@#include <linux/atmel-ssc.h> /* Serialize access to ssc_list and user count */ -static spinlock_t user_lock; +static DEFINE_SPINLOCK (user_lock);static LIST_HEAD (ssc_list);struct ssc_device *ssc_request (unsigned int ssc_num)
@@ -159,7 +159,6 @@ static struct platform_driver ssc_driverstatic int __init ssc_init (void ) { -spin_lock_init (&user_lock);return platform_driver_probe (&ssc_driver, ssc_probe); }module_init (ssc_init);
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Whoops, didn't notice that Andrew and LKML fell off Cc. Sorry.
Håvard
Quoted 41 lines · On Thu, 19 Jul 2007 11:01:22 +0200 Haavard Skinnemoen <[email protected]>…
Quoted 8 lines · On Thu, 19 Jul 2007 08:53:44 +0200 Hans-Christian Egtvedt…
Quoted 6 lines
Quoted 2 lines
+EXPORT_SYMBOL(ssc_request);
All exports need justification, please. An additional paragraph in the changelog would suit.
How are exports justified? Can they be removed since the user have to include <
linux/atmel-ssc.h> anyway?No, we do need these since modules are going to link to them.
The idea is that other drivers call these functions to obtain a reference to one of the SSC instances in the system. Such drivers typically implement some sort of serial frame-based protocol, e.g. i2s, by programming the SSC controller directly. This driver is out of the way after a protocol driver has successfully requested an instance.
So the protocol drivers need some kind of resource management in order to not step on each others' toes, and that's the reason for the export of
ssc_request()andssc_free().I'm not sure if anyone would have been very mad at me for sneaking this in through the avr32 tree, but I'd really like to know what others, in particular the AT91 people and David, think of this kind of thing before it ends up in mainline.
Feel free to add
to both patches (the driver and the fix) though. It's been through a few rounds of internal review.
Håvard
_______________________________________________
Kernel mailing list
[email protected]
http://duppen.flaskehals.net/cgi-bin/mailman/listinfo/kernel
Quoted 8 lines · Haavard Skinnemoen
Quoted 8 lines
So the protocol drivers need some kind of resource management in order to not step on each others' toes, and that's the reason for the export of
ssc_request()andssc_free().I'm not sure if anyone would have been very mad at me for sneaking this in through the avr32 tree, but I'd really like to know what others, in particular the AT91 people and David, think of this kind of thing before it ends up in mainline.
Does this work with both AT91 and AVR32 instances of SSC-to-at73c213 audio output hardware? Clearly it "should".
This "kind of thing" seems pretty routine. I see it all the time with timer modules and DMA channels ... as well as flexible serial links like this "SSC" module. (Other serial-link examples include McBSP on OMAP, SSP on PXA, and lots of non-AC97 audio data stream links.)
In this case a simple request/free interface is enough, since only one module will hook up to the external hardware. (Here, a Codec/AMP chip.) In other cases the request may imply a more complex choice algorithm than just matching IDs: the particular DMA channel or timer returned may not matter. So for now I think hardware-specific APIs are OK.
Thing is, these don't fit very nicely into the driver model since not all instances of that silicon module will use the same driver. One instance might manage a bidirectional audio stream through a codec; another might implement the control interface to that code using SPI; while a third might manage a custom data acquisition interface.
- Dave