Re: [PATCH 0/2] mpc5200 ac97 gpio reset
On Wed, Jun 9, 2010 at 2:13 AM, Wolfgang Denk w...@denx.de wrote: Dear Jon Smirl, In message aanlktimis90kr5uqhdbq02osd94dn08soitm51ylr...@mail.gmail.com you wrote: Would making a change in uboot be a better solution? Eric, can you verify if changing uboot also fixes the problem? To me it seems better if the driver itself does what needs to be done instead of relying on specific settings that may or may not be done in U-Boot. Keep in mind that drivers may be loaded as modules, and that we even see cases where the same port serves multiple purposes by loading different driver modules (yes, this is not exactly a clever idea, but hardware designers come up with such solutions). Someone with a scope can verify this, but my understanding of what happens is that uboot by default puts the pins into GPIO mode. Linux boots and reprograms the pins into AC97 mode. When the pins are reprogrammed it generates glitches on the reset line. About half of the time these glitches put the attached codec into test mode. Once the chip is in test mode it won't respond to normal commands. Does the opposite happen? What if uboot has the pins in AC97 mode and Linux reprograms them into GPIO mode. Will it also put the chip into test mode? The piece of information I've been missing is an understanding of what is making the glitches that trigger test mode. Another strategy would be to leave reset as is. If the chip is unresponsive send it the commands to get it out of test mode. That could be made part of the reset logic in the Linux driver. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de The typical page layout program is nothing more than an electronic light table for cutting and pasting documents. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/2] mpc5200 ac97 gpio reset
On Wed, Jun 9, 2010 at 10:32 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Wed, Jun 09, 2010 at 10:21:40AM -0400, Eric Millbrandt wrote: [Please fix your MUA to word wrap paragraphs to within 80 characters, I've reflowed the text below.] From the MPC5200B user manual: Some AC97 devices goes to a test mode, if the Sync line is high during the Res line is low (reset phase). To avoid this behavior the Sync line must be also forced to zero during the reset phase. To do that, the pin muxing should switch to GPIO mode and the GPIO control register should be used to control the output lines. Please include this quote in the changelog for the patch, if this a documented workaround from the vendor that's a very different thing to something that you've found happens to work on your systems (which is more what your changelog sounded like). Mark, is there a way to ask the chip if it is in test mode? We need to be sure that's whats happening and it isn't some other glitch. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/2] mpc5200 ac97 gpio reset
On Tue, Jun 8, 2010 at 12:46 PM, Eric Millbrandt emillbra...@dekaresearch.com wrote: These patches reimplement the reset fuction in the ac97 to use gpio pins instead of using the mpc5200 ac97 reset functionality in the psc. This avoids a problem in which attached ac97 devices go into test mode appear unresponsive. I'm aware of this problem but I was unable to solve it when I first wrote the driver. I didn't have access to a scope so I wasn't able to figure out what was causing the lock up. I worked around it by looping in reset until the chip did actually reset, but Mark wouldn't let me submit that code. A while ago Maximilian Mueth maximilian.mu...@mp-ndt.de sent me a note saying another solution was to configure the PSC into AC97 mode in uboot. His impression was that uboot was setting PSC into its default mode. Then Linux booted and set the PSC into AC97 mode. The transition from default mode into AC97 mode caused glitches on the AC97 reset pins and triggered test mode. Would making a change in uboot be a better solution? Eric, can you verify if changing uboot also fixes the problem? I'm glad were finally getting to the root cause of the problem. These patches were tested on a pcm030 baseboard and on custom hardware with a wm9715 audio codec/touchscreen controller. Eric Millbrandt --- Eric Millbrandt (2): powerpc/5200: Export port-config sound/soc: mpc5200_psc_ac97: Use gpio pins for cold reset. arch/powerpc/boot/dts/lite5200.dts | 3 + arch/powerpc/boot/dts/lite5200b.dts | 3 + arch/powerpc/boot/dts/pcm030.dts | 3 + arch/powerpc/boot/dts/pcm032.dts | 3 + arch/powerpc/include/asm/mpc52xx.h | 2 + arch/powerpc/platforms/52xx/mpc52xx_common.c | 61 +++ sound/soc/fsl/mpc5200_dma.h | 5 ++ sound/soc/fsl/mpc5200_psc_ac97.c | 83 - 8 files changed, 159 insertions(+), 4 deletions(-) -DISCLAIMER: an automatically appended disclaimer may follow. By posting- -to a public e-mail mailing list I hereby grant permission to distribute- -and copy this message.- This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message. Thank you. Please consider the environment before printing this email. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense
On Sat, Nov 7, 2009 at 3:12 PM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Sat, Nov 07, 2009 at 11:51:16AM -0700, Grant Likely wrote: On Sat, Nov 7, 2009 at 5:51 AM, Jon Smirl jonsm...@gmail.com wrote: current period. My understanding of ALSA is that the application is supposed to make sure there is enough silence in the buffer to handle the lag between notification that the last period with valid data has been played out and the stop trigger. This is certainly the most robust approach for applications. For a large proportion of hardware it won't matter too much since they're able to shut down the audio very quickly but that can't be entirely relied upon, especially at higher rates on slower machines. I can comment but no access to test equipment... Playing invalid data always happens in the current ALSA model. The only question is does enough of it play to be audible. on the mpc5200 batched driver... At the end of song ALSA only pads out the last period with silence. When this buffer is fully enqueued the DMA hardware generates an interrupt. The DMA hardware also begins enqueuing the next period. Now we start a race. Can ALSA come back from that interrupt and stop the playing of the enqueued data before it makes it out of the FIFO? An mpc5200 is slow enough that the CPU never makes it back in time. This isn't a latency problem, it never makes it back in time. Latency issues just make it play more invalid data. There are two solutions: 1) tell me where the end of the valid data is. That allows me to program the hardware to not enqueue the invalid data. 2) For batched hardware, pad an extra period with silence after the end of the stream. (that what zeroing the buffer before handing it back to ALSA I believe this race is present in all ALSA drivers. It's just a lot harder to hit on different hardware. For example to hit it on Intel HDA which is non-batched hardware, the song would need to end right at the end of a period. Then the interrupt latency would need to be bad enough that some invalid data got played. But x86 CPUs are very fast so it is rare for the interrupt latency to be bad enough that the stream doesn't get stopped in time. occur. That says to me that the real problem is an unbounded latency caused by another part of the kernel (the tty console in this case). That's certainly not going to help anything here - if a delay is introduced in telling the hardware to shut down the DMA then that increases the chance for the DMA controller to start pushing valid audio data from the buffer to the audio interface. A much cleaner solution would be for ALSA to provide a field that indicates the last valid address in the ring buffer system. Then in the driver's buffer complete callback I could get that value and reprogram the DMA engine not to run off the end of valid data. As each buffer completes I would reread the value and update the DMA stop address. You also need the last valid address field when DMA is first started. ... assuming that audio needs to stop exactly at the end of valid data. But if the last few periods are silence, then this assumption isn't true. Indeed, it makes the whole thing much more reliable. Providing a final valid data point to the driver would possibly even make things worse since if it were used then you'd have the equivalent race where the application has initialized some data but not yet managed to update the driver to tell it it's being handed over; if the driver just carries on running through the data there's a reasonable chance nobody will notice that case. That's an under run condition. ALSA would need to track how many periods the driver has queue. If ALSA has received enough interrupts to know that the driver is playing the last period, it would not be safe to just tack the data onto the end. You would also need to call into the driver with a 'append' call. That's because it isn't possible for ALSA to deterministically know if the last period has finished playing or not. In the 'append' call implementation the driver would determine if the DMA hardware was still running and restart it if needed. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense
On Wed, Nov 11, 2009 at 1:37 PM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Wed, Nov 11, 2009 at 11:38:06AM -0500, Jon Smirl wrote: There are two solutions: 1) tell me where the end of the valid data is. That allows me to program the hardware to not enqueue the invalid data. 2) For batched hardware, pad an extra period with silence after the end of the stream. (that what zeroing the buffer before handing it back to ALSA You've also got the option of lying about where the hardware is in some form in order to give you more headroom. I'm not sure what you mean by batched hardware here. SNDRV_PCM_INFO_BATCH Hardware that can't give you the DMA position except at the end of DMA transfers. I believe this race is present in all ALSA drivers. It's just a lot harder to hit on different hardware. For example to hit it on Intel HDA which is non-batched hardware, the song would need to end right at the end of a period. Then the interrupt latency would need to be bad enough that some invalid data got played. But x86 CPUs are very fast so it is rare for the interrupt latency to be bad enough that the stream doesn't get stopped in time. The potential is there for this to happen on any hardware, yes. On the other hand, it's not been a pressing issue elswhere - including on things like older ARM systems which aren't exactly noted for their snappy performance. It really does sound like there's something special going on with these systems that's at least somewhat unique to them. Providing a final valid data point to the driver would possibly even make things worse since if it were used then you'd have the equivalent race where the application has initialized some data but not yet managed to update the driver to tell it it's being handed over; if the driver That's an under run condition. Yes, of course - the issue is that this approach encourages them, making the system less robust if things are on the edge. The mpc5200 seems to be not just on the edge but comfortably beyond it for some reason. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense
On Wed, Nov 11, 2009 at 2:24 PM, Grant Likely grant.lik...@secretlab.ca wrote: On Wed, Nov 11, 2009 at 11:37 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Wed, Nov 11, 2009 at 11:38:06AM -0500, Jon Smirl wrote: Providing a final valid data point to the driver would possibly even make things worse since if it were used then you'd have the equivalent race where the application has initialized some data but not yet managed to update the driver to tell it it's being handed over; if the driver That's an under run condition. Yes, of course - the issue is that this approach encourages them, making the system less robust if things are on the edge. The mpc5200 seems to be not just on the edge but comfortably beyond it for some reason. I can't reproduce the issue at all as long at the dev_dbg() statement in the trigger stop path is disabled. With it enabled, I hear the problem every time. The 5200 may not be a speedy beast, but it is plenty fast enough to shut down the audio stream before stale data starts getting played out. fast enough - you just said it is a race. I've been saying it is a race too. There are two options: 1) Eliminate the race by developing a system to deterministically flag the end of valid data. 2) Fudge everything around making it almost impossible to lose the race, but the race is still there. The dev_dbg() aggravates the race until it is obviously visible every time. A deterministic solution would not be impacted by the dev_dbg(). Implementing a deterministic solution requires support from ALSA core. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense
On Wed, Nov 11, 2009 at 4:57 PM, Grant Likely grant.lik...@secretlab.ca wrote: On Wed, Nov 11, 2009 at 2:34 PM, Jon Smirl jonsm...@gmail.com wrote: On Wed, Nov 11, 2009 at 2:24 PM, Grant Likely grant.lik...@secretlab.ca wrote: On Wed, Nov 11, 2009 at 11:37 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Wed, Nov 11, 2009 at 11:38:06AM -0500, Jon Smirl wrote: Providing a final valid data point to the driver would possibly even make things worse since if it were used then you'd have the equivalent race where the application has initialized some data but not yet managed to update the driver to tell it it's being handed over; if the driver That's an under run condition. Yes, of course - the issue is that this approach encourages them, making the system less robust if things are on the edge. The mpc5200 seems to be not just on the edge but comfortably beyond it for some reason. I can't reproduce the issue at all as long at the dev_dbg() statement in the trigger stop path is disabled. With it enabled, I hear the problem every time. The 5200 may not be a speedy beast, but it is plenty fast enough to shut down the audio stream before stale data starts getting played out. fast enough - you just said it is a race. I've been saying it is a race too. Yes, it is a race; but not the kind that is dangerous. Audio playout is always a real-time problem; whether in the middle of a stream or at the end. If the CPU gets nailed with an unbounded latency, then there will be audible artifacts - Regardless of whether the driver knows where the end of data is or not. If it does know, then audio will stutter. If it doesn't know, then there will be repeated samples. Both are nasty to the human ear. So, making the driver do extra work to keep the extra data in sync will probably force larger minimum latencies for playout (trouble for VoIP apps) so the CPU can keep up, and won't help one iota for making audio better. I don't think it is that much more work for ALSA to provide an accessible field indicating the end of valid data. It's already tracking appl_ptr. Appl_ptr just needs to be translated into a physical DMA buffer address and we've been making mistakes doing that translation. The real solution is to fix the worst case latencies. There are two options: 1) Eliminate the race by developing a system to deterministically flag the end of valid data. 2) Fudge everything around making it almost impossible to lose the race, but the race is still there. 3) eliminate the unbounded latencies (fix the PSC driver and/or use a real time kernel) 4) make sure userspace fills all the periods with silence before triggering stop. Gstreamer seems to already do this. I suspect pulseaudio does the same. The dev_dbg() aggravates the race until it is obviously visible every time. A deterministic solution would not be impacted by the dev_dbg(). But it still wouldn't help a bit when the same latency occurs in the middle of playback. The deterministic solution of tracking the end of valid data ensures that under run will be silent instead of playing invalid data. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense
-stream == SNDRV_PCM_STREAM_CAPTURE) bcom_gen_bd_rx_reset(s-bcom_task); - for (i = 0; i runtime-periods; i++) - if (!bcom_queue_full(s-bcom_task)) - psc_dma_bcom_enqueue_next_buffer(s); - } else { + else bcom_gen_bd_tx_reset(s-bcom_task); - psc_dma_bcom_enqueue_tx(s); - } + + for (i = 0; i runtime-periods; i++) + if (!bcom_queue_full(s-bcom_task)) + psc_dma_bcom_enqueue_next_buffer(s); bcom_enable(s-bcom_task); spin_unlock_irqrestore(psc_dma-lock, flags); diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index 529f7a0..d9c741b 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -19,8 +19,6 @@ */ struct psc_dma_stream { struct snd_pcm_runtime *runtime; - snd_pcm_uframes_t appl_ptr; - int active; struct psc_dma *psc_dma; struct bcom_task *bcom_task; -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense
On Sat, Nov 7, 2009 at 7:51 AM, Jon Smirl jonsm...@gmail.com wrote: On Sat, Nov 7, 2009 at 3:34 AM, Grant Likely grant.lik...@secretlab.ca wrote: Sound drivers PCM DMA is supposed to free-run until told to stop by the trigger callback. The current code tries to track appl_ptr, to avoid stale buffer data getting played out at the end of the data stream. Unfortunately it also results in race conditions which can cause the audio to stall. I leave in an hour and I will be off net for a week so I can't look at these. There is a surefire way to fix this but I have resisted doing it because it is fixing a symptom not a cause. Simply have the driver zero out the buffer in the completion interrupt before handing it back to ALSA. Then if ALSA lets us play invalid data the invalid data will be silence. I implemented this and it works every time. Downside is a big memset() in an IRQ handler. The problem at end of stream works like this: last buffer containing music plays this buffer has been padded with zero to make a full sample interrupt occurs at end of buffer --- at this point the next chained buffer starts playing, it is full of junk --- this chaining happens in hardware Alsa processes the callback and sends stop stream --- oops, too late, buffer full of noise has already played several samples --- these samples of noise are clearly audible. --- they are usually a fragment from earlier in the song. Using aplay with short clips like the action sounds for pidgin, etc makes these noise bursts obviously visible. To fix this you need a mechanism to determine where the valid data in the buffering system ends and noise starts. Once you know the extent of the valid data we can keep the DMA channel programmed to not play invalid data. You can play off the end of valid data two ways; under run when ALSA doesn't supply data fast enough and end of buffer. ALSA does not provide information on where valid data ends in easily consumable form so I've been trying to reconstruct it from appl_ptr. A much cleaner solution would be for ALSA to provide a field that indicates the last valid address in the ring buffer system. Then in the driver's buffer complete callback I could get that value and reprogram the DMA engine not to run off the end of valid data. As each buffer completes I would reread the value and update the DMA stop address. You also need the last valid address field when DMA is first started. Signed-off-by: Grant Likely grant.lik...@secretlab.ca --- sound/soc/fsl/mpc5200_dma.c | 52 +++ sound/soc/fsl/mpc5200_dma.h | 2 -- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 986d3c8..4e47586 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -65,36 +65,6 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) s-period_next = (s-period_next + 1) % s-runtime-periods; } -static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) -{ - if (s-appl_ptr s-runtime-control-appl_ptr) { - /* - * In this case s-runtime-control-appl_ptr has wrapped around. - * Play the data to the end of the boundary, then wrap our own - * appl_ptr back around. - */ - while (s-appl_ptr s-runtime-boundary) { - if (bcom_queue_full(s-bcom_task)) - return; - - s-appl_ptr += s-runtime-period_size; - - psc_dma_bcom_enqueue_next_buffer(s); - } - s-appl_ptr -= s-runtime-boundary; - } - - while (s-appl_ptr s-runtime-control-appl_ptr) { - - if (bcom_queue_full(s-bcom_task)) - return; - - s-appl_ptr += s-runtime-period_size; - - psc_dma_bcom_enqueue_next_buffer(s); - } -} - /* Bestcomm DMA irq handler */ static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream) { @@ -107,8 +77,9 @@ static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream) bcom_retrieve_buffer(s-bcom_task, NULL, NULL); s-period_current = (s-period_current+1) % s-runtime-periods; + + psc_dma_bcom_enqueue_next_buffer(s); } - psc_dma_bcom_enqueue_tx(s); spin_unlock(s-psc_dma-lock); /* If the stream is active, then also inform the PCM middle layer @@ -182,28 +153,21 @@ static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd) s-period_next = 0; s-period_current = 0; s-active = 1; - - /* track appl_ptr so that we have a better chance of detecting - * end of stream and not over running
Re: lite5200b kernel not booting
On Thu, Sep 24, 2009 at 10:41 AM, Asier Llano Palacios asierll...@gmail.com wrote: Hi Grant, We've been working with a lite5200b for a while, we have been working with the ppc platform in linux 2.6.x for 5 years and it worked properly until 2.6.25 included. We want to switch to the powerpc platform but it doesn't seem to work. After the bootloader (tested with the uboot 1.2.0 and 2009.08) starts the cuImage.lite5200 it doesn't show anything in the console. I'd like to know if the lite5200b is still supported and which version is known to work with it and what is the default configuration. I want to test it like the developers do, until I configure it myself. I've managed to do some debugging in assembler, to know that it works properly until DCACHE is enabled in setup_common_caches of arch/powerpc/kernel/cpu_setup_6xx.S. If I skip enabling the DCACHE it continues properly until the MMU is enabled. I'm only debugging it writing to the serial port registers in assembler, so I'm not very sure if it continues properly or if I am not able to debug it after the DCACHE is enabled or the MMU is enabled. I want to debug it with a JTAG debugger, but I still don't have one (do you recommend me anyone?). No one has tried the Macraigor USB wiggler on the mpc5200 and reported back if it works. Chart says it is supported... http://www.macraigor.com/cpus.htm It's a $250 device so it would good to know if it works. http://www.macraigor.com/usbWiggler.htm uboot 1.2 is very old. That may be the cause of your problems. For example old u-boots don't initialize the PCI hardware correctly on systems that don't have PCI implemented. In general the current powerpc kernel works fine on the mpc5200b. We are running it on four different CPU boards but I don't have a lite5200b. We use the Phytec dev boards. We've never had any trouble with them. http://www.phytec.de/de/produkte/rapid-development-kits/linux-kits/produktdetails.html?tx_ttproducts_pi1[backPID]=270tx_ttproducts_pi1[product]=62cHash=6fbc8dcdb2 http://www.phytec.com/products/rdk/PowerPC/phyCORE-MPC5200B-tinyRDK.html Kind regards and thank you for the help, Asier ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
mpc5200, reboots will idle
I've been getting unexplained reboots. This one printed a dump. Does it make sense to anyone? The system was just sitting idle at a command prompt. r...@phycore:~ Bad trap at PC: c00098f0, SR: 1000, vector=100 Oops: Exception in kernel mode, sig: 5 [#1] dspeak01 Modules linked in: NIP: c00098f0 LR: c00098f0 CTR: c000f0bc git REGS: c040fee0 TRAP: 0100 Not tainted (2.6.31-rc1-efika) (actually rc6, commit 894ef820b10d77) MSR: 1000 ME CR: 2428 XER: 2000 TASK = c03dd3e8[0] 'swapper' THREAD: c040e000 6GPR00: c040ff90 c03dd3e8 0080 0090c000 00e0 cba3e1bd 00049032 6GPR08: 0001 c040e000 2422 0002 63694880 10068248 03fbc000 04079000 6GPR16: ff7fffbf ffaf7fbf fffe f83f 3002 03f580b6 0001 6GPR24: 03fba97c c0418000 c041 c041 c0417f2c 0008 c040e03c NIP [c00098f0] cpu_idle+0x94/0xd4 LR [c00098f0] cpu_idle+0x94/0xd4 Call Trace: [c040ff90] [c000992c] cpu_idle+0xd0/0xd4 (unreliable) [c040ffb0] [c0003e54] rest_init+0x5c/0x88 [c040ffc0] [c03b17c0] start_kernel+0x2a0/0x2b4 [c040fff0] [3438] 0x3438 Instruction dump: 7ca6 70090004 4e800421 7c00f828 ---[ end trace dafbcb51fa4ab255 ]--- Kernel panic - not syncing: Attempted to kill the idle task! Call Trace: [c040fcf0] [c00088cc] show_stack+0x4c/0x14c (unreliable) [c040fd30] [c02bda4c] panic+0x8c/0x170 [c040fd80] [c002ab74] do_exit+0x60/0x594 [c040fdc0] [c0011848] kernel_bad_stack+0x0/0x4c [c040fde0] [c00119e4] _exception+0x58/0x150 [c040fed0] [c0014050] ret_from_except_full+0x0/0x4c --- Exception: 100 at cpu_idle+0x94/0xd4 LR = cpu_idle+0x94/0xd4 [c040ff90] [c000992c] cpu_idle+0xd0/0xd4 (unreliable) [c040ffb0] [c0003e54] rest_init+0x5c/0x88 [c040ffc0] [c03b17c0] start_kernel+0x2a0/0x2b4 [c040fff0] [3438] 0x3438 Rebooting in 180 seconds.. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH V2] Use clock freqency from the device tree to calculate correct MPC5200 PSC clock.
Use clock freqency from the device tree to calculate correct MPC5200 PSC clock. Previous code had errors or used a constant. This versions computes the right clock based on the xtal and register settings. Adjusted from previous version to rebase onto current Linus tree. Signed-off-by: Jon Smirl jonsm...@gmail.com --- arch/powerpc/include/asm/mpc52xx.h |2 +- arch/powerpc/platforms/52xx/mpc52xx_common.c | 26 -- drivers/spi/mpc52xx_psc_spi.c|8 +--- sound/soc/fsl/mpc5200_psc_i2s.c | 12 +--- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/include/asm/mpc52xx.h b/arch/powerpc/include/asm/mpc52xx.h index cadd398..1ca8a0e 100644 --- a/arch/powerpc/include/asm/mpc52xx.h +++ b/arch/powerpc/include/asm/mpc52xx.h @@ -285,7 +285,7 @@ struct mpc52xx_rtc { extern void mpc5200_setup_xlb_arbiter(void); extern void mpc52xx_declare_of_platform_devices(void); extern void mpc52xx_map_common_devices(void); -extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv); +extern int mpc52xx_set_psc_clkdiv(int psc_id, int freq); extern unsigned int mpc52xx_get_xtal_freq(struct device_node *node); extern void mpc52xx_restart(char *cmd); diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c index a46bad0..8a19156 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c @@ -110,6 +110,8 @@ static struct of_device_id mpc52xx_cdm_ids[] __initdata = { {} }; +static u32 mpc52xx_fsystem; /* fsystem clock on mpc5200 */ + /** * mpc52xx_map_common_devices: iomap devices required by common code */ @@ -117,6 +119,7 @@ void __init mpc52xx_map_common_devices(void) { struct device_node *np; + u32 val; /* mpc52xx_wdt is mapped here and used in mpc52xx_restart, * possibly from a interrupt context. wdt is only implement @@ -133,8 +136,16 @@ mpc52xx_map_common_devices(void) /* Clock Distribution Module, used by PSC clock setting function */ np = of_find_matching_node(NULL, mpc52xx_cdm_ids); + mpc52xx_fsystem = mpc5xxx_get_bus_frequency(np); mpc52xx_cdm = of_iomap(np, 0); of_node_put(np); + + /* compute fsystem, it is either 4 or 8 times the bus freq */ + val = in_be32(mpc52xx_cdm-rstcfg); + if (val (1 5)) + mpc52xx_fsystem *= 8; + else + mpc52xx_fsystem *= 4; } /** @@ -143,17 +154,28 @@ mpc52xx_map_common_devices(void) * @psc_id: id of psc port; must be 1,2,3 or 6 * @clkdiv: clock divider value to put into CDM PSC register. */ -int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv) +int mpc52xx_set_psc_clkdiv(int psc_id, int freq) { unsigned long flags; u16 __iomem *reg; u32 val; - u32 mask; + u32 mask, clkdiv, err; u32 mclken_div; if (!mpc52xx_cdm) return -ENODEV; + /* figure out the closest frequency the hardware can make */ + clkdiv = mpc52xx_fsystem / freq; + err = mpc52xx_fsystem % freq; + if (err freq / 2) + clkdiv++; + /* hardware is not very flexible, there will be significant error */ + /* frequency error = fsystem / clkdiv - freq; */ + + /* hardware adds one to the divisor */ + clkdiv -= 1; + mclken_div = 0x8000 | (clkdiv 0x1FF); switch (psc_id) { case 1: reg = mpc52xx_cdm-mclken_div_psc1; mask = 0x20; break; diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 1b74d5c..d000edc 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c @@ -32,7 +32,6 @@ struct mpc52xx_psc_spi { /* fsl_spi_platform data */ void (*cs_control)(struct spi_device *spi, bool on); - u32 sysclk; /* driver internal data */ struct mpc52xx_psc __iomem *psc; @@ -312,12 +311,9 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) { struct mpc52xx_psc __iomem *psc = mps-psc; struct mpc52xx_psc_fifo __iomem *fifo = mps-fifo; - u32 mclken_div; int ret = 0; - /* default sysclk is 512MHz */ - mclken_div = (mps-sysclk ? mps-sysclk : 51200) / MCLK; - mpc52xx_set_psc_clkdiv(psc_id, mclken_div); + mpc52xx_set_psc_clkdiv(psc_id, MCLK); /* Reset the PSC into a known state */ out_8(psc-command, MPC52xx_PSC_RST_RX); @@ -382,12 +378,10 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, dev_warn(dev, probe called without platform data, no cs_control function will be called\n); mps-cs_control = NULL; - mps-sysclk = 0; master-bus_num = bus_num; master-num_chipselect = 255; } else { mps-cs_control
PSC clock divider
mpc52xx_set_psc_clkdiv() has problems. It take the clk divider as a parameter. But this divisor is not always gettting calculated correctly. My code in i2s was doing it wrong. Take this snippet from the SPI driver, it just assumes a fsystem of 512Mhz. fsystem is 533Mhz on my boards. /* default sysclk is 512MHz */ mclken_div = (mps-sysclk ? mps-sysclk : 51200) / MCLK; mpc52xx_set_psc_clkdiv(psc_id, mclken_div); Is it also not accounting for the hardware adding one to the divisor. I've change i2s to this: if (!fsystem) { np = of_find_matching_node(NULL, mpc52xx_cdm_ids); mpc52xx_cdm = of_iomap(np, 0); fsystem = mpc5xxx_get_bus_frequency(np); of_node_put(np); val = in_be32(mpc52xx_cdm-rstcfg); if (val (1 5)) fsystem *= 8; else fsystem *= 4; iounmap(mpc52xx_cdm); } clkdiv = fsystem / freq; err = fsystem % freq; if (err freq / 2) clkdiv++; dev_dbg(psc_dma-dev, psc_i2s_set_sysclk(clkdiv %d freq error=%dHz)\n, clkdiv, (fsystem / clkdiv - freq)); /* PSC is 1-6 */ /* Hardware adds 1 to divisor */ return mpc52xx_set_psc_clkdiv(psc_dma-id + 1, clkdiv - 1); Should I modify mpc52xx_set_psc_clkdiv() to take in a frequency and them move this code into mpc52xx_common.c? That allows the sysclk parameter to be eliminated for SPI. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] Use clock freqency from the device tree to calculate correct MPC5200 PSC clock.
Use clock freqency from the device tree to calculate correct MPC5200 PSC clock. Previous code had errors or used a constant. This versions computes the right clock based on the xtal and register settings. --- arch/powerpc/include/asm/mpc52xx.h |2 +- arch/powerpc/platforms/52xx/mpc52xx_common.c | 26 -- drivers/spi/mpc52xx_psc_spi.c|8 +--- sound/soc/fsl/mpc5200_psc_i2s.c | 11 +-- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/include/asm/mpc52xx.h b/arch/powerpc/include/asm/mpc52xx.h index cadd398..1ca8a0e 100644 --- a/arch/powerpc/include/asm/mpc52xx.h +++ b/arch/powerpc/include/asm/mpc52xx.h @@ -285,7 +285,7 @@ struct mpc52xx_rtc { extern void mpc5200_setup_xlb_arbiter(void); extern void mpc52xx_declare_of_platform_devices(void); extern void mpc52xx_map_common_devices(void); -extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv); +extern int mpc52xx_set_psc_clkdiv(int psc_id, int freq); extern unsigned int mpc52xx_get_xtal_freq(struct device_node *node); extern void mpc52xx_restart(char *cmd); diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c index a46bad0..f81fb03 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c @@ -110,6 +110,8 @@ static struct of_device_id mpc52xx_cdm_ids[] __initdata = { {} }; +static u32 fsystem; /* fsystem clock on mpc5200 */ + /** * mpc52xx_map_common_devices: iomap devices required by common code */ @@ -117,6 +119,7 @@ void __init mpc52xx_map_common_devices(void) { struct device_node *np; + u32 val; /* mpc52xx_wdt is mapped here and used in mpc52xx_restart, * possibly from a interrupt context. wdt is only implement @@ -133,8 +136,16 @@ mpc52xx_map_common_devices(void) /* Clock Distribution Module, used by PSC clock setting function */ np = of_find_matching_node(NULL, mpc52xx_cdm_ids); + fsystem = mpc5xxx_get_bus_frequency(np); mpc52xx_cdm = of_iomap(np, 0); of_node_put(np); + + /* compute fsystem, it is either 4 or 8 times the bus freq */ + val = in_be32(mpc52xx_cdm-rstcfg); + if (val (1 5)) + fsystem *= 8; + else + fsystem *= 4; } /** @@ -143,17 +154,28 @@ mpc52xx_map_common_devices(void) * @psc_id: id of psc port; must be 1,2,3 or 6 * @clkdiv: clock divider value to put into CDM PSC register. */ -int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv) +int mpc52xx_set_psc_clkdiv(int psc_id, int freq) { unsigned long flags; u16 __iomem *reg; u32 val; - u32 mask; + u32 mask, clkdiv, err; u32 mclken_div; if (!mpc52xx_cdm) return -ENODEV; + /* figure out the closest frequency the hardware can make */ + clkdiv = fsystem / freq; + err = fsystem % freq; + if (err freq / 2) + clkdiv++; + /* hardware is not very flexible, there will be significant error */ + /* frequency error = fsystem / clkdiv - freq; */ + + /* hardware adds one to the divisor */ + clkdiv -= 1; + mclken_div = 0x8000 | (clkdiv 0x1FF); switch (psc_id) { case 1: reg = mpc52xx_cdm-mclken_div_psc1; mask = 0x20; break; diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index d2a04d6..5c8e621 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c @@ -33,7 +33,6 @@ struct mpc52xx_psc_spi { /* fsl_spi_platform data */ void (*cs_control)(struct spi_device *spi, bool on); - u32 sysclk; /* driver internal data */ struct mpc52xx_psc __iomem *psc; @@ -313,12 +312,9 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) { struct mpc52xx_psc __iomem *psc = mps-psc; struct mpc52xx_psc_fifo __iomem *fifo = mps-fifo; - u32 mclken_div; int ret = 0; - /* default sysclk is 512MHz */ - mclken_div = (mps-sysclk ? mps-sysclk : 51200) / MCLK; - mpc52xx_set_psc_clkdiv(psc_id, mclken_div); + mpc52xx_set_psc_clkdiv(psc_id, MCLK); /* Reset the PSC into a known state */ out_8(psc-command, MPC52xx_PSC_RST_RX); @@ -383,12 +379,10 @@ static int __init mpc52xx_psc_spi_do_probe(struct of_device *op, u32 regaddr, dev_warn(op-dev, probe called without platform data, no cs_control function will be called\n); mps-cs_control = NULL; - mps-sysclk = 0; master-bus_num = bus_num; master-num_chipselect = 255; } else { mps-cs_control = pdata-cs_control; - mps-sysclk = pdata-sysclk; master-bus_num = pdata-bus_num; master-num_chipselect =
[PATCH V2] Use clock freqency from the device tree to calculate correct MPC5200 PSC clock.
Use clock freqency from the device tree to calculate correct MPC5200 PSC clock. Previous code had errors or used a constant. This versions computes the right clock based on the xtal and register settings. Signed-off-by: Jon Smirl jonsm...@gmail.com --- arch/powerpc/include/asm/mpc52xx.h |2 +- arch/powerpc/platforms/52xx/mpc52xx_common.c | 26 -- drivers/spi/mpc52xx_psc_spi.c|8 +--- sound/soc/fsl/mpc5200_psc_i2s.c | 11 +-- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/include/asm/mpc52xx.h b/arch/powerpc/include/asm/mpc52xx.h index cadd398..1ca8a0e 100644 --- a/arch/powerpc/include/asm/mpc52xx.h +++ b/arch/powerpc/include/asm/mpc52xx.h @@ -285,7 +285,7 @@ struct mpc52xx_rtc { extern void mpc5200_setup_xlb_arbiter(void); extern void mpc52xx_declare_of_platform_devices(void); extern void mpc52xx_map_common_devices(void); -extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv); +extern int mpc52xx_set_psc_clkdiv(int psc_id, int freq); extern unsigned int mpc52xx_get_xtal_freq(struct device_node *node); extern void mpc52xx_restart(char *cmd); diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c index a46bad0..8a19156 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c @@ -110,6 +110,8 @@ static struct of_device_id mpc52xx_cdm_ids[] __initdata = { {} }; +static u32 mpc52xx_fsystem; /* fsystem clock on mpc5200 */ + /** * mpc52xx_map_common_devices: iomap devices required by common code */ @@ -117,6 +119,7 @@ void __init mpc52xx_map_common_devices(void) { struct device_node *np; + u32 val; /* mpc52xx_wdt is mapped here and used in mpc52xx_restart, * possibly from a interrupt context. wdt is only implement @@ -133,8 +136,16 @@ mpc52xx_map_common_devices(void) /* Clock Distribution Module, used by PSC clock setting function */ np = of_find_matching_node(NULL, mpc52xx_cdm_ids); + mpc52xx_fsystem = mpc5xxx_get_bus_frequency(np); mpc52xx_cdm = of_iomap(np, 0); of_node_put(np); + + /* compute fsystem, it is either 4 or 8 times the bus freq */ + val = in_be32(mpc52xx_cdm-rstcfg); + if (val (1 5)) + mpc52xx_fsystem *= 8; + else + mpc52xx_fsystem *= 4; } /** @@ -143,17 +154,28 @@ mpc52xx_map_common_devices(void) * @psc_id: id of psc port; must be 1,2,3 or 6 * @clkdiv: clock divider value to put into CDM PSC register. */ -int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv) +int mpc52xx_set_psc_clkdiv(int psc_id, int freq) { unsigned long flags; u16 __iomem *reg; u32 val; - u32 mask; + u32 mask, clkdiv, err; u32 mclken_div; if (!mpc52xx_cdm) return -ENODEV; + /* figure out the closest frequency the hardware can make */ + clkdiv = mpc52xx_fsystem / freq; + err = mpc52xx_fsystem % freq; + if (err freq / 2) + clkdiv++; + /* hardware is not very flexible, there will be significant error */ + /* frequency error = fsystem / clkdiv - freq; */ + + /* hardware adds one to the divisor */ + clkdiv -= 1; + mclken_div = 0x8000 | (clkdiv 0x1FF); switch (psc_id) { case 1: reg = mpc52xx_cdm-mclken_div_psc1; mask = 0x20; break; diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index d2a04d6..5c8e621 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c @@ -33,7 +33,6 @@ struct mpc52xx_psc_spi { /* fsl_spi_platform data */ void (*cs_control)(struct spi_device *spi, bool on); - u32 sysclk; /* driver internal data */ struct mpc52xx_psc __iomem *psc; @@ -313,12 +312,9 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) { struct mpc52xx_psc __iomem *psc = mps-psc; struct mpc52xx_psc_fifo __iomem *fifo = mps-fifo; - u32 mclken_div; int ret = 0; - /* default sysclk is 512MHz */ - mclken_div = (mps-sysclk ? mps-sysclk : 51200) / MCLK; - mpc52xx_set_psc_clkdiv(psc_id, mclken_div); + mpc52xx_set_psc_clkdiv(psc_id, MCLK); /* Reset the PSC into a known state */ out_8(psc-command, MPC52xx_PSC_RST_RX); @@ -383,12 +379,10 @@ static int __init mpc52xx_psc_spi_do_probe(struct of_device *op, u32 regaddr, dev_warn(op-dev, probe called without platform data, no cs_control function will be called\n); mps-cs_control = NULL; - mps-sysclk = 0; master-bus_num = bus_num; master-num_chipselect = 255; } else { mps-cs_control = pdata-cs_control; - mps-sysclk = pdata-sysclk
Re: [PATCH 1/2] ASoC: Fix mpc5200-psc-ac97 to ensure the data ready bit is cleared
On Thu, Jul 2, 2009 at 1:57 PM, Grant Likelygrant.lik...@secretlab.ca wrote: From: Grant Likely grant.lik...@secretlab.ca When doing register reads, it is possible for there to be a stale data ready bit set which will cause subsequent reads to return prematurely with incorrect data. This patch fixes the issues by ensuring stale data is cleared before starting another transaction. Signed-off-by: Grant Likely grant.lik...@secretlab.ca Acked-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_psc_ac97.c | 4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 794a247..9b8503f 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -41,6 +41,10 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) pr_err(timeout on ac97 bus (rdy)\n); return -ENODEV; } + + /* Force clear the data valid bit */ + in_be32(psc_dma-psc_regs-ac97_data); + /* Send the read */ out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] ASoC: add locking to mpc5200-psc-ac97 driver
On Thu, Jul 2, 2009 at 1:57 PM, Grant Likelygrant.lik...@secretlab.ca wrote: From: Grant Likely grant.lik...@secretlab.ca AC97 bus register read/write hooks need to provide locking, but the mpc5200-psc-ac97 driver does not. This patch adds a mutex around the register access routines. Signed-off-by: Grant Likely grant.lik...@secretlab.ca Acked-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_dma.c | 1 + sound/soc/fsl/mpc5200_dma.h | 1 + sound/soc/fsl/mpc5200_psc_ac97.c | 13 - 3 files changed, 14 insertions(+), 1 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index efec33a..f0a2d40 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -456,6 +456,7 @@ int mpc5200_audio_dma_create(struct of_device *op) return -ENODEV; spin_lock_init(psc_dma-lock); + mutex_init(psc_dma-mutex); psc_dma-id = be32_to_cpu(*prop); psc_dma-irq = irq; psc_dma-psc_regs = regs; diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index 2000803..8d396bb 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -55,6 +55,7 @@ struct psc_dma { unsigned int irq; struct device *dev; spinlock_t lock; + struct mutex mutex; u32 sicr; uint sysclk; int imr; diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 9b8503f..7eb5499 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -34,11 +34,14 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) int status; unsigned int val; + mutex_lock(psc_dma-mutex); + /* Wait for command send status zero = ready */ status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) MPC52xx_PSC_SR_CMDSEND), 100, 0); if (status == 0) { pr_err(timeout on ac97 bus (rdy)\n); + mutex_unlock(psc_dma-mutex); return -ENODEV; } @@ -54,16 +57,19 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) if (status == 0) { pr_err(timeout on ac97 read (val) %x\n, in_be16(psc_dma-psc_regs-sr_csr.status)); + mutex_unlock(psc_dma-mutex); return -ENODEV; } /* Get the data */ val = in_be32(psc_dma-psc_regs-ac97_data); if (((val 24) 0x7f) != reg) { pr_err(reg echo error on ac97 read\n); + mutex_unlock(psc_dma-mutex); return -ENODEV; } val = (val 8) 0x; + mutex_unlock(psc_dma-mutex); return (unsigned short) val; } @@ -72,16 +78,21 @@ static void psc_ac97_write(struct snd_ac97 *ac97, { int status; + mutex_lock(psc_dma-mutex); + /* Wait for command status zero = ready */ status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) MPC52xx_PSC_SR_CMDSEND), 100, 0); if (status == 0) { pr_err(timeout on ac97 bus (write)\n); - return; + goto out; } /* Write data */ out_be32(psc_dma-psc_regs-ac97_cmd, ((reg 0x7f) 24) | (val 8)); + + out: + mutex_unlock(psc_dma-mutex); } static void psc_ac97_warm_reset(struct snd_ac97 *ac97) -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] alsa/soc: add locking to mpc5200-psc-ac97 driver
On Wed, Jul 1, 2009 at 4:56 AM, Wolfram Sangw.s...@pengutronix.de wrote: Hi Jon, Wolfram, do you have any way to test the on the Phytec hardware? The WM9712 on the baseboard supports a touchscreen, is it brought out to a header? Sorry, I didn't get it: Shall I test something specific? I don't own a touchscreen. AFAIK no one has ever plugged a touchscreen into the PCM-973 to see if works since there hasn't been a driver previously. Just do a general test so that you can tell customers that it works. The touchscreen connector is X19 BTW (assuming a PCM-973 baseboard). Regards, Wolfram -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkpLJMEACgkQD27XaX1/VRs/cwCgn7p7ffxr8WGoW7MwALkBMKtD VtYAoIa5/viinyvFF5cQP3BvH9WP3a5I =Zrq3 -END PGP SIGNATURE- -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] alsa/soc: add locking to mpc5200-psc-ac97 driver
On Tue, Jun 30, 2009 at 12:50 PM, Grant Likelygrant.lik...@secretlab.ca wrote: On Tue, Jun 30, 2009 at 12:18 AM, Wolfram Sangw.s...@pengutronix.de wrote: + + /* Force clear the data valid bit */ + in_be32(psc_dma-psc_regs-ac97_data); + No mutex involved here. I think this is either a separate patch or it needs at least to be mentioned in the patch description. Oops, that was sloppy. Yes, I'll put this into a separate patch. Thanks. Now that you have added the mutexes, do you ever need to force clear the valid bit? Maybe log an error if this happens so that we can track down why. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] alsa/soc: add locking to mpc5200-psc-ac97 driver
On Tue, Jun 30, 2009 at 2:18 AM, Wolfram Sangw.s...@pengutronix.de wrote: Wolfram, do you have any way to test the on the Phytec hardware? The WM9712 on the baseboard supports a touchscreen, is it brought out to a header? Hi Grant, On Mon, Jun 29, 2009 at 05:42:21PM -0600, Grant Likely wrote: From: Grant Likely grant.lik...@secretlab.ca AC97 bus register read/write hooks need to provide locking, but the mpc5200-psc-ac97 driver does not. This patch adds a mutex around the register access routines. Signed-off-by: Grant Likely grant.lik...@secretlab.ca --- sound/soc/fsl/mpc5200_dma.c | 1 + sound/soc/fsl/mpc5200_dma.h | 1 + sound/soc/fsl/mpc5200_psc_ac97.c | 17 - 3 files changed, 18 insertions(+), 1 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index efec33a..f0a2d40 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -456,6 +456,7 @@ int mpc5200_audio_dma_create(struct of_device *op) return -ENODEV; spin_lock_init(psc_dma-lock); + mutex_init(psc_dma-mutex); psc_dma-id = be32_to_cpu(*prop); psc_dma-irq = irq; psc_dma-psc_regs = regs; diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index 2000803..8d396bb 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -55,6 +55,7 @@ struct psc_dma { unsigned int irq; struct device *dev; spinlock_t lock; + struct mutex mutex; u32 sicr; uint sysclk; int imr; diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 794a247..7eb5499 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -34,13 +34,20 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) int status; unsigned int val; + mutex_lock(psc_dma-mutex); + /* Wait for command send status zero = ready */ status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) MPC52xx_PSC_SR_CMDSEND), 100, 0); if (status == 0) { pr_err(timeout on ac97 bus (rdy)\n); + mutex_unlock(psc_dma-mutex); return -ENODEV; } + + /* Force clear the data valid bit */ + in_be32(psc_dma-psc_regs-ac97_data); + No mutex involved here. I think this is either a seperate patch or it needs at least to be mentioned in the patch description. /* Send the read */ out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); @@ -50,16 +57,19 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) if (status == 0) { pr_err(timeout on ac97 read (val) %x\n, in_be16(psc_dma-psc_regs-sr_csr.status)); + mutex_unlock(psc_dma-mutex); return -ENODEV; } /* Get the data */ val = in_be32(psc_dma-psc_regs-ac97_data); if (((val 24) 0x7f) != reg) { pr_err(reg echo error on ac97 read\n); + mutex_unlock(psc_dma-mutex); return -ENODEV; } val = (val 8) 0x; + mutex_unlock(psc_dma-mutex); return (unsigned short) val; } @@ -68,16 +78,21 @@ static void psc_ac97_write(struct snd_ac97 *ac97, { int status; + mutex_lock(psc_dma-mutex); + /* Wait for command status zero = ready */ status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) MPC52xx_PSC_SR_CMDSEND), 100, 0); if (status == 0) { pr_err(timeout on ac97 bus (write)\n); - return; + goto out; } /* Write data */ out_be32(psc_dma-psc_regs-ac97_cmd, ((reg 0x7f) 24) | (val 8)); + + out: + mutex_unlock(psc_dma-mutex); } static void psc_ac97_warm_reset(struct snd_ac97 *ac97) ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkpJrkcACgkQD27XaX1/VRsY/QCgyx8IMANjokbNnrOQlXINRLeW lT4AnAy3ES9r3wriGkRN7ivnLA3zyRHb =RUPr -END PGP SIGNATURE- -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] alsa/soc: add locking to mpc5200-psc-ac97 driver
On Mon, Jun 29, 2009 at 7:42 PM, Grant Likelygrant.lik...@secretlab.ca wrote: From: Grant Likely grant.lik...@secretlab.ca AC97 bus register read/write hooks need to provide locking, but the mpc5200-psc-ac97 driver does not. This patch adds a mutex around the register access routines. Does your touchscreen driver use this mutex? Or was this mutex needed just for the AC97 driver? -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/2] alsa/soc: Fix typo in MPC5200 PSC AC97 driver Kconfig
On Sun, Jun 28, 2009 at 3:41 AM, Grant Likelygrant.lik...@secretlab.ca wrote: From: Grant Likely grant.lik...@secretlab.ca ALSA SoC drivers should be specify SND_SOC_AC97_BUS instead, not AC97_BUS. Without SND_SOC_AC97_BUS defined, an AC97 device will not get correctly registered on the AC97 bus, which prevents thinks like the WM9712 touchscreen driver from getting probed. Tested against 2.6.31-rc1. Signed-off-by: Grant Likely grant.lik...@secretlab.ca Acked-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 5dbebf8..5661876 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -33,7 +33,7 @@ config SND_SOC_MPC5200_I2S config SND_SOC_MPC5200_AC97 tristate Freescale MPC5200 PSC in AC97 mode driver depends on PPC_MPC52xx PPC_BESTCOMM - select AC97_BUS + select SND_SOC_AC97_BUS select SND_MPC52xx_DMA select PPC_BESTCOMM_GEN_BD help -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] sound/soc: remove BROKEN from Efika and pcm030 fabric drivers
On Sun, Jun 28, 2009 at 3:42 AM, Grant Likelygrant.lik...@secretlab.ca wrote: From: Grant Likely grant.lik...@secretlab.ca The needed spin_event_timeout() macro is now merged in from the powerpc tree, so these drivers are no longer broken. This reverts commit 0c0e09e21a9e7bc6ca54e06ef3d497255ca26383 (ASoC: Mark MPC5200 AC97 as BROKEN until PowerPC merge issues are resolved) Tested against 2.6.31-rc1. Signed-off-by: Grant Likely grant.lik...@secretlab.ca Acked-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 5661876..8cb65cc 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -41,7 +41,7 @@ config SND_SOC_MPC5200_AC97 config SND_MPC52xx_SOC_PCM030 tristate SoC AC97 Audio support for Phytec pcm030 and WM9712 - depends on PPC_MPC5200_SIMPLE BROKEN + depends on PPC_MPC5200_SIMPLE select SND_SOC_MPC5200_AC97 select SND_SOC_WM9712 help @@ -50,7 +50,7 @@ config SND_MPC52xx_SOC_PCM030 config SND_MPC52xx_SOC_EFIKA tristate SoC AC97 Audio support for bbplan Efika and STAC9766 - depends on PPC_EFIKA BROKEN + depends on PPC_EFIKA select SND_SOC_MPC5200_AC97 select SND_SOC_STAC9766 help -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] Have git ignore generated files from dtc compile
--- arch/powerpc/boot/.gitignore | 10 ++ scripts/dtc/.gitignore |5 + 2 files changed, 15 insertions(+), 0 deletions(-) create mode 100644 scripts/dtc/.gitignore diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore index d57aa5c..dab1b41 100644 --- a/arch/powerpc/boot/.gitignore +++ b/arch/powerpc/boot/.gitignore @@ -37,3 +37,13 @@ zImage.pseries zconf.h zlib.h zutil.h +fdt.c +fdt.h +fdt_ro.c +fdt_rw.c +fdt_strerror.c +fdt_sw.c +fdt_wip.c +libfdt.h +libfdt_internal.h + diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore new file mode 100644 index 000..095acb4 --- /dev/null +++ b/scripts/dtc/.gitignore @@ -0,0 +1,5 @@ +dtc +dtc-lexer.lex.c +dtc-parser.tab.c +dtc-parser.tab.h + ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] Have git ignore generated files from dtc compile
Have git ignore generated files from dtc compile Signed-off-by: Jon Smirl jonsm...@gmail.com --- arch/powerpc/boot/.gitignore | 10 ++ scripts/dtc/.gitignore |5 + 2 files changed, 15 insertions(+), 0 deletions(-) create mode 100644 scripts/dtc/.gitignore diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore index d57aa5c..dab1b41 100644 --- a/arch/powerpc/boot/.gitignore +++ b/arch/powerpc/boot/.gitignore @@ -37,3 +37,13 @@ zImage.pseries zconf.h zlib.h zutil.h +fdt.c +fdt.h +fdt_ro.c +fdt_rw.c +fdt_strerror.c +fdt_sw.c +fdt_wip.c +libfdt.h +libfdt_internal.h + diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore new file mode 100644 index 000..095acb4 --- /dev/null +++ b/scripts/dtc/.gitignore @@ -0,0 +1,5 @@ +dtc +dtc-lexer.lex.c +dtc-parser.tab.c +dtc-parser.tab.h + ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
build failure in PPC mpc5200_psc_ac97
The new driver for AC97 on the mpc5200 has landed in front of Timur's patch implementing spin_event_timeout(). Timur's patch is in powerpc-next which hasn't been merged yet. mpc5200_psc_ac97 will build ok after this merge happens. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Missing some interrupts
On Sat, Jun 6, 2009 at 9:17 AM, wael showairshowair2...@yahoo.com wrote: Hi All, i have a freescale board, that contains MPC8555 processor DSP-core there is a GPIO connecting the DSP-core into an input pin of the OpenPIC of the MPC8555 processor. i test one interrupt from the DSP-core to the MPC8555 processor where i configure this interrupt line to be edge-triggered (falling edge) i receive it successfully but when i generate this interrupt 10 successive times using for loop i just receive 2 interrupts? why can't i receive the 8 other interrupts? i print the value of every irq number inside do_IRQ i found that i receive the DSP-interrupt just only twice. do u have any suggestions to solve this problem? i want to make sure that i can receive 10 interrupts Don't do a printk() with interrupts disabled. A printk() takes 1.5ms on a mpc5200. -- View this message in context: http://www.nabble.com/Missing-some-interrupts-tp23901807p23901807.html Sent from the linuxppc-dev mailing list archive at Nabble.com. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [BUILD FAILURE 02/04] Next June 04:PPC64 randconfig [drivers/usb/host/ohci-hcd.o]
On Thu, Jun 4, 2009 at 9:31 AM, Subrata Modak subr...@linux.vnet.ibm.com wrote: CC drivers/usb/host/ohci-hcd.o In file included from drivers/usb/host/ohci-hcd.c:1060: drivers/usb/host/ohci-ppc-of.c:242:2: error: #error No endianess selected for ppc-of-ohci make[3]: *** [drivers/usb/host/ohci-hcd.o] Error 1 make[2]: *** [drivers/usb/host] Error 2 make[1]: *** [drivers/usb] Error 2 make: *** [drivers] Error 2 I reported this earlier, and there were some discussions: http://groups.google.co.kr/group/linux.kernel/browse_thread/thread/edff9d5572d3d225 Proposed patch by Arnd should fix this. It has not been merged. http://lkml.org/lkml/2009/4/22/49 -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: PWM class? (was: Re: MPC52xx simple GPIO support)
On Wed, Jun 3, 2009 at 9:22 AM, Anton Vorontsov avoront...@ru.mvista.com wrote: On Wed, Jun 03, 2009 at 02:42:26PM +0200, Stefan Strobl wrote: [...] The led class provides support for setting the brightness, which obviously the gpio driver doesn't support. The hardware (mpc52xx_gpt) would support it in PWM mode though. I'm now wandering how this could be best implemented. 1) - Create some PWM class similar to the GPIO class - Add support for PWM mode in mpc52xx_gpt.c that uses that PWM class - And add an interface for the LED to use the PWM class 2) - Create an LED driver that accesses the mpc52xx_gpt directly. I think I would be overwhelmed trying to implement (1) but am confident to do (2). What do you think is the right approach? I'd suggest creating a generic PWM class, i.e. PWMLIB, alike to GPIOLIB. (2) can be an acceptable approach for now, but for the long-term solution (1) is the way to go. What happened to this one? http://ozlabs.org/pipermail/linuxppc-dev/2008-October/063562.html The non-lib PWM API is already there, see include/linux/pwm.h, and arch/arm/mach-pxa/pwm.c as an implementation example. Note that PXA implementation is SOC-specific, which is not very good. So I'd suggest creating drivers/pwm/pwmlib.c, borrowing ideas from gpiolib. And then we can reuse drivers/leds/leds-pwm.c driver (of course, after adding appropriate OF code into it). Sure, as you've said, it could be quite boringly to implement, could take quite some time to pass all review cycles etc. But someday someone will have to do this. :-) -- Anton Vorontsov email: cbouatmai...@gmail.com irc://irc.freenode.net/bd2 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH V3 4/4] Fabric bindings for STAC9766 on the Efika
On Thu, May 28, 2009 at 10:00 AM, Peter Korsgaard jac...@sunsite.dk wrote: Jon == Jon Smirl jonsm...@gmail.com writes: Hi, Jon Fabric bindings for STAC9766 AC97 codec on the Efika. Jon Signed-off-by: Jon Smirl jonsm...@gmail.com Jon --- Jon sound/soc/fsl/Kconfig | 8 +++ Jon sound/soc/fsl/Makefile | 1 Jon sound/soc/fsl/efika-audio-fabric.c | 95 Jon 3 files changed, 104 insertions(+), 0 deletions(-) Jon create mode 100644 sound/soc/fsl/efika-audio-fabric.c Jon diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig Jon index 79579ae..f571c6e 100644 Jon --- a/sound/soc/fsl/Kconfig Jon +++ b/sound/soc/fsl/Kconfig Jon @@ -47,3 +47,11 @@ config SND_MPC52xx_SOC_PCM030 Jon help Jon Say Y if you want to add support for sound on the Phytec pcm030 baseboard. Jon +config SND_MPC52xx_SOC_EFIKA Jon + tristate SoC AC97 Audio support for bbplan Efika and STAC9766 Jon + depends on PPC_EFIKA Jon + select SND_SOC_MPC5200_AC97 Jon + select SND_SOC_STAC9766 Jon + help Jon + Say Y if you want to add support for sound on the Efika. Jon + Wouldn't it make more sense to make this default y when it has such specific dependencies and is so deep down in the tree - Most efika users probably want to enable this if they have enabled ALSA and SND_SOC? I can change it in the next round of updates. Right now I'd like to get some people testing it and maybe doing some patches to enhance it. For example I know he code has a problem where about 5% of the time the codec doesn't reset right on boot. Someone needs to put an oscilloscope on the codec chip and tell me why it is failing. -- Bye, Peter Korsgaard -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [Solved/Patch Question] Weird 5200/mtd-ram problem
On Wed, May 27, 2009 at 3:54 PM, Albrecht Dreß albrecht.dr...@arcor.de wrote: Hi all: Am 25.05.09 23:47 schrieb(en) Wolfram Sang: A word or long copy of 0x0055aaff with U-Boot works fine, but a byte copy filled the whole ram with 0x. The reason is apparently that the chip is attached to the local bus in 16-bit mode, which is incompatible with byte accesses. However, the Local Bus doesn't provide low byte or high byte indicators in non-muxed mode. How is this supposed to work then? Hmm, as I feared... we were bitten by this, too: http://thread.gmane.org/gmane.linux.drivers.mtd/21521 There is no generic solution yet :( At least for my case, I could completely (afaict) solve the problem, i.e. I can now access the 16-bit nv ram as mtd char and block device, the latter with jffs2. I would like to submit a patch, but I actually don't know exactly how... The solution itself is quite simple: add a new method which works like memcpy_toio, but respects the fact that no single bytes may be written (reading through memcpy_fromio works painlessly). I think this function should go into arch/powerpc/kernel/io.c, depending upon CONFIG_PPC_MPC52xx, and the prototype into arch/powerpc/include/asm/io.h, right? The harder part is to actually call this function properly. I now call it in include/linux/mtd/map.h, function inline_map_copy_to(), if CONFIG_PPC_MPC52xx is defined and if map-bankwidth is 2. However, is it acceptable to have a processor-type dependency in a top-level include file? Or what would be the proper way to implement it? This is an old jffs2 patch that was addressing this same problem. diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index 272872d..c982adc 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c @@ -16,6 +16,7 @@ #include linux/pagemap.h #include linux/crc32.h #include linux/compiler.h +#include asm/io.h #include nodelist.h #include summary.h #include debug.h @@ -505,7 +506,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo sumptr = kmalloc(sumlen, GFP_KERNEL); if (!sumptr) return -ENOMEM; - memcpy(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len); + memcpy_fromio(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len); } if (buf_len sumlen) { /* Need to read more so that the entire summary node is present */ @@ -1035,7 +1036,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo if (!fd) { return -ENOMEM; } - memcpy(fd-name, rd-name, checkedlen); + memcpy_fromio(fd-name, rd-name, checkedlen); fd-name[checkedlen] = 0; crc = crc32(0, fd-name, rd-nsize); Thanks, Albrecht. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH V4 0/5] AC97 driver for mpc5200
On Mon, May 25, 2009 at 11:44 PM, Timur Tabi ti...@freescale.com wrote: On Mon, May 25, 2009 at 5:15 PM, Jon Smirl jonsm...@gmail.com wrote: The macro spin_event_timeout() takes a condition and timeout value My patch is already set to go through the powerpc tree, so there's no need to repost it here. Please, you changed the title of the patch. I'm changing the code, I removed the ! on the rc. Geert just asked to have it changed to an in-line too. I forgot to add the title line so it used the beginning of the comment. -- Timur Tabi Linux kernel developer at Freescale -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V5 0/5] AC97 driver for mpc5200
Version 5. Modified to use spin_event_timeout() as originally written. --- Jon Smirl (5): Fabric bindings for STAC9766 on the Efika Support for AC97 on Phytec pmc030 base board. AC97 driver for mpc5200 Main rewite of the mpc5200 audio DMA code powerpc: introduce macro spin_event_timeout() arch/powerpc/include/asm/delay.h| 33 +++ sound/soc/fsl/Kconfig | 27 ++ sound/soc/fsl/Makefile |5 sound/soc/fsl/efika-audio-fabric.c | 90 +++ sound/soc/fsl/mpc5200_dma.c | 442 ++- sound/soc/fsl/mpc5200_dma.h | 33 +-- sound/soc/fsl/mpc5200_psc_ac97.c| 331 ++ sound/soc/fsl/mpc5200_psc_ac97.h| 15 + sound/soc/fsl/mpc5200_psc_i2s.c | 247 +++- sound/soc/fsl/mpc5200_psc_i2s.h | 12 + sound/soc/fsl/pcm030-audio-fabric.c | 90 +++ 11 files changed, 934 insertions(+), 391 deletions(-) create mode 100644 sound/soc/fsl/efika-audio-fabric.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V5 1/5] powerpc: introduce macro spin_event_timeout()
The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns the result of the condition when the loop was terminated. This primary purpose of this macro is to poll on a hardware register until a status bit changes. The timeout ensures that the loop still terminates if the bit doesn't change as expected. This macro makes it easier for driver developers to perform this kind of operation properly. Signed-off-by: Timur Tabi ti...@freescale.com --- arch/powerpc/include/asm/delay.h | 33 + 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h index f9200a6..af4a270 100644 --- a/arch/powerpc/include/asm/delay.h +++ b/arch/powerpc/include/asm/delay.h @@ -2,8 +2,11 @@ #define _ASM_POWERPC_DELAY_H #ifdef __KERNEL__ +#include asm/time.h + /* * Copyright 1996, Paul Mackerras. + * Copyright (C) 2009 Freescale Semiconductor, Inc. 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 @@ -30,5 +33,35 @@ extern void udelay(unsigned long usecs); #define mdelay(n) udelay((n) * 1000) #endif +/** + * spin_event_timeout - spin until a condition gets true or a timeout elapses + * @condition: a C expression to evalate + * @timeout: timeout, in microseconds + * @delay: the number of microseconds to delay between eache evaluation of + * @condition + * @rc: the last value of the condition + * + * The process spins until the condition evaluates to true (non-zero) or the + * timeout elapses. Upon exit, @rc contains the value of the condition. This + * allows you to test the condition without incurring any side effects. + * + * This primary purpose of this macro is to poll on a hardware register + * until a status bit changes. The timeout ensures that the loop still + * terminates even if the bit never changes. The delay is for devices that + * need a delay in between successive reads. + * + * gcc will optimize out the if-statement if @delay is a constant. + */ +#define spin_event_timeout(condition, timeout, delay, rc) \ +{ \ + unsigned long __loops = tb_ticks_per_usec * timeout;\ + unsigned long __start = get_tbl(); \ + while (!(rc = (condition)) (tb_ticks_since(__start) = __loops)) \ + if (delay) \ + udelay(delay); \ + else\ + cpu_relax();\ +} + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_DELAY_H */ ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V5 2/5] Main rewite of the mpc5200 audio DMA code
Rewrite the mpc5200 audio DMA code to support both I2S and AC97. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |1 sound/soc/fsl/mpc5200_dma.c | 442 --- sound/soc/fsl/mpc5200_dma.h | 33 +-- sound/soc/fsl/mpc5200_psc_i2s.c | 247 -- sound/soc/fsl/mpc5200_psc_i2s.h | 12 + 5 files changed, 344 insertions(+), 391 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index dc79bdf..1918c78 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -25,7 +25,6 @@ config SND_SOC_MPC8610_HPCD config SND_SOC_MPC5200_I2S tristate Freescale MPC5200 PSC in I2S mode driver depends on PPC_MPC52xx PPC_BESTCOMM - select SND_SOC_OF_SIMPLE select SND_MPC52xx_DMA select PPC_BESTCOMM_GEN_BD help diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 6850392..efec33a 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -3,23 +3,13 @@ * ALSA SoC Platform driver * * Copyright (C) 2008 Secret Lab Technologies Ltd. + * Copyright (C) 2009 Jon Smirl, Digispeaker */ -#include linux/init.h #include linux/module.h -#include linux/interrupt.h -#include linux/device.h -#include linux/delay.h #include linux/of_device.h -#include linux/of_platform.h -#include linux/dma-mapping.h -#include sound/core.h -#include sound/pcm.h -#include sound/pcm_params.h -#include sound/initval.h #include sound/soc.h -#include sound/soc-of-simple.h #include sysdev/bestcomm/bestcomm.h #include sysdev/bestcomm/gen_bd.h @@ -27,10 +17,6 @@ #include mpc5200_dma.h -MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca); -MODULE_DESCRIPTION(Freescale MPC5200 PSC in DMA mode ASoC Driver); -MODULE_LICENSE(GPL); - /* * Interrupt handlers */ @@ -50,7 +36,7 @@ static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma) if (psc_dma-capture.active (isr MPC52xx_PSC_IMR_ORERR)) psc_dma-stats.overrun_count++; - out_8(regs-command, 4 4); /* reset the error status */ + out_8(regs-command, MPC52xx_PSC_RST_ERR_STAT); return IRQ_HANDLED; } @@ -81,21 +67,36 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) s-period_next_pt = s-period_start; } +static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) +{ + while (s-appl_ptr s-runtime-control-appl_ptr) { + + if (bcom_queue_full(s-bcom_task)) + return; + + s-appl_ptr += s-period_size; + + psc_dma_bcom_enqueue_next_buffer(s); + } +} + /* Bestcomm DMA irq handler */ -static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) +static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream) { struct psc_dma_stream *s = _psc_dma_stream; + spin_lock(s-psc_dma-lock); /* For each finished period, dequeue the completed period buffer * and enqueue a new one in it's place. */ while (bcom_buffer_done(s-bcom_task)) { bcom_retrieve_buffer(s-bcom_task, NULL, NULL); + s-period_current_pt += s-period_bytes; if (s-period_current_pt = s-period_end) s-period_current_pt = s-period_start; - psc_dma_bcom_enqueue_next_buffer(s); - bcom_enable(s-bcom_task); } + psc_dma_bcom_enqueue_tx(s); + spin_unlock(s-psc_dma-lock); /* If the stream is active, then also inform the PCM middle layer * of the period finished event. */ @@ -105,49 +106,33 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) return IRQ_HANDLED; } -/** - * psc_dma_startup: create a new substream - * - * This is the first function called when a stream is opened. - * - * If this is the first stream open, then grab the IRQ and program most of - * the PSC registers. - */ -int psc_dma_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static irqreturn_t psc_dma_bcom_irq_rx(int irq, void *_psc_dma_stream) { - struct snd_soc_pcm_runtime *rtd = substream-private_data; - struct psc_dma *psc_dma = rtd-dai-cpu_dai-private_data; - int rc; + struct psc_dma_stream *s = _psc_dma_stream; - dev_dbg(psc_dma-dev, psc_dma_startup(substream=%p)\n, substream); + spin_lock(s-psc_dma-lock); + /* For each finished period, dequeue the completed period buffer +* and enqueue a new one in it's place. */ + while (bcom_buffer_done(s-bcom_task)) { + bcom_retrieve_buffer(s-bcom_task, NULL, NULL); - if (!psc_dma-playback.active - !psc_dma-capture.active) { - /* Setup the IRQs */ - rc = request_irq(psc_dma-irq, psc_dma_status_irq, IRQF_SHARED
[PATCH V5 3/5] AC97 driver for mpc5200
AC97 driver for mpc5200 I've implemented retries for when the AC97 hardware doesn't reset on first try. About 10% of the time both the Efika and pcm030 AC97 codecs don't reset on first try and need to be poked multiple times. Failure is indicated by not having the link clock start ticking. Every once in a while even five pokes won't get the link started and I have to power cycle. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig| 11 + sound/soc/fsl/Makefile |1 sound/soc/fsl/mpc5200_psc_ac97.c | 331 ++ sound/soc/fsl/mpc5200_psc_ac97.h | 15 ++ 4 files changed, 358 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 1918c78..3bce952 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -29,3 +29,14 @@ config SND_SOC_MPC5200_I2S select PPC_BESTCOMM_GEN_BD help Say Y here to support the MPC5200 PSCs in I2S mode. + +config SND_SOC_MPC5200_AC97 + tristate Freescale MPC5200 PSC in AC97 mode driver + depends on PPC_MPC52xx PPC_BESTCOMM + select AC97_BUS + select SND_MPC52xx_DMA + select PPC_BESTCOMM_GEN_BD + help + Say Y here to support the MPC5200 PSCs in AC97 mode. + + diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 7731ef2..14631a1 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -13,4 +13,5 @@ obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o # MPC5200 Platform Support obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o +obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c new file mode 100644 index 000..9f2df15 --- /dev/null +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -0,0 +1,331 @@ +/* + * linux/sound/mpc5200-ac97.c -- AC97 support for the Freescale MPC52xx chip. + * + * Copyright (C) 2009 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * 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/module.h +#include linux/of_device.h +#include linux/of_platform.h + +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/time.h +#include asm/delay.h +#include asm/mpc52xx_psc.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h + +#define DRV_NAME mpc5200-psc-ac97 + +/* ALSA only supports a single AC97 device so static is recommend here */ +static struct psc_dma *psc_dma; + +static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) +{ + int rc; + unsigned int val; + + /* Wait for command send status zero = ready */ + spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); + if (rc == 0) { + pr_err(timeout on ac97 bus (rdy)\n); + return -ENODEV; + } + /* Send the read */ + out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); + + /* Wait for the answer */ + spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_DATA_VAL), 100, 0, rc); + if (rc == 0) { + pr_err(timeout on ac97 read (val) %x\n, + in_be16(psc_dma-psc_regs-sr_csr.status)); + return -ENODEV; + } + /* Get the data */ + val = in_be32(psc_dma-psc_regs-ac97_data); + if (((val 24) 0x7f) != reg) { + pr_err(reg echo error on ac97 read\n); + return -ENODEV; + } + val = (val 8) 0x; + + return (unsigned short) val; +} + +static void psc_ac97_write(struct snd_ac97 *ac97, + unsigned short reg, unsigned short val) +{ + int rc; + + /* Wait for command status zero = ready */ + spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); + if (rc == 0) { + pr_err(timeout on ac97 bus (write)\n); + return; + } + /* Write data */ + out_be32(psc_dma-psc_regs-ac97_cmd, + ((reg 0x7f) 24) | (val 8)); +} + +static void psc_ac97_warm_reset(struct snd_ac97 *ac97) +{ + int rc; + struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; + + out_be32(regs-sicr, psc_dma-sicr | MPC52xx_PSC_SICR_AWR); + spin_event_timeout(0, 3, 0, rc); + out_be32(regs-sicr, psc_dma-sicr); +} + +static void psc_ac97_cold_reset(struct snd_ac97 *ac97) +{ + int rc
[PATCH V5 4/5] Support for AC97 on Phytec pmc030 base board.
Support for AC97 on Phytec pmc030 base board. A wm9712 AC97 codec is used. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |7 +++ sound/soc/fsl/Makefile |3 + sound/soc/fsl/pcm030-audio-fabric.c | 90 +++ 3 files changed, 100 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 3bce952..79579ae 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -39,4 +39,11 @@ config SND_SOC_MPC5200_AC97 help Say Y here to support the MPC5200 PSCs in AC97 mode. +config SND_MPC52xx_SOC_PCM030 + tristate SoC AC97 Audio support for Phytec pcm030 and WM9712 + depends on PPC_MPC5200_SIMPLE + select SND_SOC_MPC5200_AC97 + select SND_SOC_WM9712 + help + Say Y if you want to add support for sound on the Phytec pcm030 baseboard. diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 14631a1..66d88c8 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -15,3 +15,6 @@ obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o +# MPC5200 Machine Support +obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o + diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c new file mode 100644 index 000..8766f7a --- /dev/null +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -0,0 +1,90 @@ +/* + * Phytec pcm030 driver for the PSC of the Freescale MPC52xx + * configured as AC97 interface + * + * Copyright 2008 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h +#include ../codecs/wm9712.h + +static struct snd_soc_device device; +static struct snd_soc_card card; + +static struct snd_soc_dai_link pcm030_fabric_dai[] = { +{ + .name = AC97, + .stream_name = AC97 Analog, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_HIFI], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], +}, +{ + .name = AC97, + .stream_name = AC97 IEC958, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_AUX], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], +}, +}; + +static __init int pcm030_fabric_init(void) +{ + struct platform_device *pdev; + int rc; + + if (!machine_is_compatible(phytec,pcm030)) + return -ENODEV; + + card.platform = mpc5200_audio_dma_platform; + card.name = pcm030; + card.dai_link = pcm030_fabric_dai; + card.num_links = ARRAY_SIZE(pcm030_fabric_dai); + + device.card = card; + device.codec_dev = soc_codec_dev_wm9712; + + pdev = platform_device_alloc(soc-audio, 1); + if (!pdev) { + pr_err(pcm030_fabric_init: platform_device_alloc() failed\n); + return -ENODEV; + } + + platform_set_drvdata(pdev, device); + device.dev = pdev-dev; + + rc = platform_device_add(pdev); + if (rc) { + pr_err(pcm030_fabric_init: platform_device_add() failed\n); + return -ENODEV; + } + return 0; +} + +module_init(pcm030_fabric_init); + + +MODULE_AUTHOR(Jon Smirl jonsm...@gmail.com); +MODULE_DESCRIPTION(DRV_NAME : mpc5200 pcm030 fabric driver); +MODULE_LICENSE(GPL); + ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH V5 1/5] powerpc: introduce macro spin_event_timeout()
On Tue, May 26, 2009 at 9:03 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Tue, May 26, 2009 at 08:34:06AM -0400, Jon Smirl wrote: The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns the result of the condition when the loop was terminated. As previously mentioned you need to submit any changes you want to make here as incremental patches against the PowerPC tree rather than as an entire new patch. If you are forwarding on copies of the patch you really ought to preserve Timur's authorship too with a From line in the mail. I have reverted back to TImur's original patch so you can just drop this patch if that is easier for you. You'll just need to coordinate the landing so that things land in the right order. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/2 v8] powerpc: introduce macro spin_event_timeout()
On Tue, May 26, 2009 at 12:20 PM, Geoff Thorpe geoff.tho...@freescale.com wrote: Timur Tabi wrote: On Mon, May 25, 2009 at 12:46 PM, Jon Smirl jonsm...@gmail.com wrote: I just tried using this. The !rc has the effect of making the error return be zero instead the normal not zero. You're confused. It's not a return code, it's a return value. I guess I should have called the parameter ret instead of rc, but I didn't expect people to get confused. 'rc' is the value of the expression when the loop terminates. That's what makes the most sense, because the developer will want to know what that value is. If you're expression happens to rely on negative logic (e.g. wait until a bit is cleared), then of course it's going to appear backwards when you test it. I've just been going through some hassles associated with wait_event variants and their return codes. Eg. wait_event_interruptible()'s return value is documented as; The function will return -ERESTARTSYS if it was interrupted by a signal and 0 if @condition evaluated to true. And wait_event_timeout()'s return value is; The function returns 0 if the @timeout elapsed, and the remaining jiffies if the condition evaluated to true before the timeout elapsed. In all cases it seems, they don't return the what the expression evaluates to, but instead return an indication about the wait outcome. This is why I've taken to doing things like; wait_event_***(queue, !(ret = try_something())); That's a good trick, if you want the result of the condition pass the assignment in. That frees up the return value to indicate the error of the time out expiring. I'd really like to keep a consistent if(rc!=0)error; model. So from this user's perspective (FWIW), it would come as a surprise if the return value reflected the evaluated expression rather than what happened w.r.t. the spin/timeout. Cheers, Geoff -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH V4 2/5] Main rewite of the mpc5200 audio DMA code
On Tue, May 26, 2009 at 12:51 PM, Grant Likely grant.lik...@secretlab.ca wrote: On Tue, May 26, 2009 at 5:01 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Mon, May 25, 2009 at 06:15:09PM -0400, Jon Smirl wrote: Rewrite the mpc5200 audio DMA code to support both I2S and AC97. Signed-off-by: Jon Smirl jonsm...@gmail.com Grant, I'm OK with that if you are? Acked-by: Grant Likely grant.lik...@secretlab.ca Put in the V5 version this one has this in the h file: -int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai); +/* whack this after Timur's patch is merged in to arch/powerpc/include/asm/delay.h */ +#define spin_event_timeout(condition, timeout, delay, rc) \ +{ \ + unsigned long __loops = tb_ticks_per_usec * timeout;\ + unsigned long __start = get_tbl(); \ + while ((rc = (condition)) (tb_ticks_since(__start) = __loops)) \ + if (delay) \ + udelay(delay); \ + else\ + cpu_relax();\ +} +/* whack this after Timur's patch is merged in to arch/powerpc/include/asm/delay.h */ -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/2 v8] powerpc: introduce macro spin_event_timeout()
On Tue, May 26, 2009 at 1:03 PM, Timur Tabi ti...@freescale.com wrote: Geoff Thorpe wrote: So from this user's perspective (FWIW), it would come as a surprise if the return value reflected the evaluated expression rather than what happened w.r.t. the spin/timeout. It shouldn't come as a surprise because I've thoroughly documented the behavior. I also think returning the actual value of the expression is better than a return code. Remember, the primary purpose of this macro is to wait for a hardware register to change. Contrast this to wait_event_xxx, which usually queries a variable. Therefore, the hardware register may set multiple bits. For instance, you could do this: ret = spin_event_timeout(in_be32(x) 0x14, ...); if (ret 0x10) do something here if (ret 0x04) do something else here If (ret == 0) timeout_happened; That's the part that looks wrong. I think the ability to do this is more important than making the code as similar as possible to wait_event_xxx. Why not this? rc = spin_event_timeout(result = (in_be32(x) 0x14), ...); if (rc) timeout_happened; if (result 0x10) do something here if (result 0x04) do something else here Then if I don't care about the result (which I think is the common case)... rc = spin_event_timeout(in_be32(x) 0x14, ...); if (rc) timeout_happened; -- Timur Tabi Linux kernel developer at Freescale -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/2 v8] powerpc: introduce macro spin_event_timeout()
On Tue, May 26, 2009 at 2:17 PM, Timur Tabi ti...@freescale.com wrote: Geoff Thorpe wrote: rc = spin_event_timeout((ret = in_be32(x) 0x14), ...); It's an interesting idea, but I have two problems with it: 1) This approach is that it depends on the internals of the macro. That is, you're sneaking in an assignment in the hopes that the code will behave properly. You see that the current code evaluates the condition only once, so it works. The code will look like this: 2) Unlike the wait_event_xxx macros, I believe that the actual evaluated expression is important to the caller. So 90% of the time, the caller is going to pass in ret = (condition), which means it makes more sense to have this as a built-in feature of the macro. The only time you need the result is when you are waiting on multiple bits. I don't think looping while waiting on multiple bits is the common case. So if you're okay with v9 of the patch, please ACK it. I'll ACK ths so that I can get my driver in. But every time I used this function I got it wrong on the first try. This is going to be a source of bugs. -- Timur Tabi Linux kernel developer at Freescale ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH] Modify mpc5200 AC97 driver to use V9 of spin_event_timeout()
The function signature for spin_event_timeout() has changed in version V9. Adjust the mpc5200 AC97 driver to use the new function. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_psc_ac97.c | 30 ++ 1 files changed, 14 insertions(+), 16 deletions(-) diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 9f2df15..bab80ac 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -31,13 +31,13 @@ static struct psc_dma *psc_dma; static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - int rc; + int status; unsigned int val; /* Wait for command send status zero = ready */ - spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); - if (rc == 0) { + status= spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0); + if (status == 0) { pr_err(timeout on ac97 bus (rdy)\n); return -ENODEV; } @@ -45,9 +45,9 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); /* Wait for the answer */ - spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_DATA_VAL), 100, 0, rc); - if (rc == 0) { + status = spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_DATA_VAL), 100, 0); + if (status == 0) { pr_err(timeout on ac97 read (val) %x\n, in_be16(psc_dma-psc_regs-sr_csr.status)); return -ENODEV; @@ -66,12 +66,12 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) static void psc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - int rc; + int status; /* Wait for command status zero = ready */ - spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); - if (rc == 0) { + status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0); + if (status == 0) { pr_err(timeout on ac97 bus (write)\n); return; } @@ -82,24 +82,22 @@ static void psc_ac97_write(struct snd_ac97 *ac97, static void psc_ac97_warm_reset(struct snd_ac97 *ac97) { - int rc; struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; out_be32(regs-sicr, psc_dma-sicr | MPC52xx_PSC_SICR_AWR); - spin_event_timeout(0, 3, 0, rc); + spin_event_timeout(0, 3, 0); out_be32(regs-sicr, psc_dma-sicr); } static void psc_ac97_cold_reset(struct snd_ac97 *ac97) { - int rc; struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; /* Do a cold reset */ out_8(regs-op1, MPC52xx_PSC_OP_RES); - spin_event_timeout(0, 10, 0, rc); + spin_event_timeout(0, 10, 0); out_8(regs-op0, MPC52xx_PSC_OP_RES); - spin_event_timeout(0, 50, 0, rc); + spin_event_timeout(0, 50, 0); psc_ac97_warm_reset(ac97); } ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH] Modify mpc5200 AC97 driver to use V9 of spin_event_timeout()
On Tue, May 26, 2009 at 8:38 PM, Timur Tabi ti...@freescale.com wrote: On Tue, May 26, 2009 at 7:25 PM, Jon Smirl jonsm...@gmail.com wrote: - spin_event_timeout(0, 10, 0, rc); + spin_event_timeout(0, 10, 0); out_8(regs-op0, MPC52xx_PSC_OP_RES); - spin_event_timeout(0, 50, 0, rc); + spin_event_timeout(0, 50, 0); Jon, I'm still hoping you'll explain why you're not using udelay() here. Because Grant didn't want me doing udelay(50) just to delay things in order to give the AC97 controller time to initialize. Your function lets me loop on cpu_relax() for 50us. I have to delay 50us because ALSA tries to access the hardware immediately after the function returns. -- Timur Tabi Linux kernel developer at Freescale -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH] Modify mpc5200 AC97 driver to use V9 of spin_event_timeout()
On Tue, May 26, 2009 at 8:53 PM, Timur Tabi ti...@freescale.com wrote: On Tue, May 26, 2009 at 7:44 PM, Jon Smirl jonsm...@gmail.com wrote: Because Grant didn't want me doing udelay(50) just to delay things in order to give the AC97 controller time to initialize. Your function lets me loop on cpu_relax() for 50us. But udelay() calls HMT_low(), which is like cpu_relax(). Then why did you need to make your routine that calls cpu_relax()? I don't know what goes on in the guts of HMT_low() and cpu_relax(), when you guys decide which one I should use let me know and I can adjust the patch. The hardware needs a minimum 50us pause. It doesn't matter if the pause is more than that. If the CPU has something to keep it busy for a few milliseconds that's fine. -- Timur Tabi Linux kernel developer at Freescale -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V2] Modify mpc5200 AC97 driver to use V9 of spin_event_timeout()
The function signature for spin_event_timeout() has changed in version V9. Adjust the mpc5200 AC97 driver to use the new function. v2 - switch back to udelay() for fixed timeouts. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_psc_ac97.c | 30 ++ 1 files changed, 14 insertions(+), 16 deletions(-) diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 9f2df15..4342b51 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -31,13 +31,13 @@ static struct psc_dma *psc_dma; static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - int rc; + int status; unsigned int val; /* Wait for command send status zero = ready */ - spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); - if (rc == 0) { + status= spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0); + if (status == 0) { pr_err(timeout on ac97 bus (rdy)\n); return -ENODEV; } @@ -45,9 +45,9 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); /* Wait for the answer */ - spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_DATA_VAL), 100, 0, rc); - if (rc == 0) { + status = spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_DATA_VAL), 100, 0); + if (status == 0) { pr_err(timeout on ac97 read (val) %x\n, in_be16(psc_dma-psc_regs-sr_csr.status)); return -ENODEV; @@ -66,12 +66,12 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) static void psc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - int rc; + int status; /* Wait for command status zero = ready */ - spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); - if (rc == 0) { + status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0); + if (status == 0) { pr_err(timeout on ac97 bus (write)\n); return; } @@ -82,24 +82,22 @@ static void psc_ac97_write(struct snd_ac97 *ac97, static void psc_ac97_warm_reset(struct snd_ac97 *ac97) { - int rc; struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; out_be32(regs-sicr, psc_dma-sicr | MPC52xx_PSC_SICR_AWR); - spin_event_timeout(0, 3, 0, rc); + udelay(3); out_be32(regs-sicr, psc_dma-sicr); } static void psc_ac97_cold_reset(struct snd_ac97 *ac97) { - int rc; struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; /* Do a cold reset */ out_8(regs-op1, MPC52xx_PSC_OP_RES); - spin_event_timeout(0, 10, 0, rc); + udelay(10); out_8(regs-op0, MPC52xx_PSC_OP_RES); - spin_event_timeout(0, 50, 0, rc); + udelat(50); psc_ac97_warm_reset(ac97); } ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V3] Modify mpc5200 AC97 driver to use V9 of spin_event_timeout()
The function signature for spin_event_timeout() has changed in version V9. Adjust the mpc5200 AC97 driver to use the new function. v2 - switch back to udelay() for fixed timeouts. v3 - forgot about driver being market broken, fix typo Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_psc_ac97.c | 30 ++ 1 files changed, 14 insertions(+), 16 deletions(-) diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 9f2df15..794a247 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -31,13 +31,13 @@ static struct psc_dma *psc_dma; static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - int rc; + int status; unsigned int val; /* Wait for command send status zero = ready */ - spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); - if (rc == 0) { + status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0); + if (status == 0) { pr_err(timeout on ac97 bus (rdy)\n); return -ENODEV; } @@ -45,9 +45,9 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); /* Wait for the answer */ - spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_DATA_VAL), 100, 0, rc); - if (rc == 0) { + status = spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_DATA_VAL), 100, 0); + if (status == 0) { pr_err(timeout on ac97 read (val) %x\n, in_be16(psc_dma-psc_regs-sr_csr.status)); return -ENODEV; @@ -66,12 +66,12 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) static void psc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - int rc; + int status; /* Wait for command status zero = ready */ - spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) - MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); - if (rc == 0) { + status = spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0); + if (status == 0) { pr_err(timeout on ac97 bus (write)\n); return; } @@ -82,24 +82,22 @@ static void psc_ac97_write(struct snd_ac97 *ac97, static void psc_ac97_warm_reset(struct snd_ac97 *ac97) { - int rc; struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; out_be32(regs-sicr, psc_dma-sicr | MPC52xx_PSC_SICR_AWR); - spin_event_timeout(0, 3, 0, rc); + udelay(3); out_be32(regs-sicr, psc_dma-sicr); } static void psc_ac97_cold_reset(struct snd_ac97 *ac97) { - int rc; struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; /* Do a cold reset */ out_8(regs-op1, MPC52xx_PSC_OP_RES); - spin_event_timeout(0, 10, 0, rc); + udelay(10); out_8(regs-op0, MPC52xx_PSC_OP_RES); - spin_event_timeout(0, 50, 0, rc); + udelay(50); psc_ac97_warm_reset(ac97); } ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH V3 3/4] Support for AC97 on Phytec pmc030 base board.
On Mon, May 25, 2009 at 2:34 AM, Grant Likely grant.lik...@secretlab.ca wrote: On Sun, May 24, 2009 at 7:38 PM, Jon Smirl jonsm...@gmail.com wrote: This is ugly. I'd really rather have a generic mechanism for creating a fabric driver based on the OF data. But failing that, it seems to me that this platform device registration should be done in the platform code (arch/powerpc/platforms/52xx). Doing it in a module init looks wrong. I'm all for deleting it as soon as AC97 is capable of auto-loading. I thought it was better to leave it in the sound directories to keep it isolated since the intention is to remove it when possible. BTW, my binding files are quite simple compared to mpc8610_hpcd.c. I was trying to do a sort of generic matching mechanism with the of simple stuff; but admittedly it was hacky and half-assed. However, I do still think it is viable to have OF hooks that kick in when codec and machine drivers are registered. If linkage data is encoded in the device tree, then generic code should be able to hook them up; pulling additional data out of the device tree as needed to configure the coded. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH V3 2/4] AC97 driver for mpc5200
On Mon, May 25, 2009 at 6:26 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: + spin_lock(psc_dma-lock); + out_be32(psc_dma-psc_regs-ac97_slots, psc_dma-slots); + spin_unlock(psc_dma-lock); + break; This locking looks wrong - I'd expect it to also cover the modification of psc_dma-slots? Otherwise it's hard to see what it buys you. Grant, why are you spin locking around register access? -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/2 v8] powerpc: introduce macro spin_event_timeout()
On Tue, May 19, 2009 at 3:26 PM, Timur Tabi ti...@freescale.com wrote: The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns the result of the condition when the loop was terminated. This primary purpose of this macro is to poll on a hardware register until a status bit changes. The timeout ensures that the loop still terminates if the bit doesn't change as expected. This macro makes it easier for driver developers to perform this kind of operation properly. I just tried using this. The !rc has the effect of making the error return be zero instead the normal not zero. /* Wait for command send status zero = ready */ spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); if (rc == 0) { pr_err(timeout on ac97 bus (rdy)\n); return -ENODEV; } I want the register to be zero, would this be more obvious? /* Wait for command send status zero = ready */ spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); if (rc != 0) { pr_err(timeout on ac97 bus (rdy)\n); return -ENODEV; } Signed-off-by: Timur Tabi ti...@freescale.com --- v8: added a copyright notice arch/powerpc/include/asm/delay.h | 33 + 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h index f9200a6..af4a270 100644 --- a/arch/powerpc/include/asm/delay.h +++ b/arch/powerpc/include/asm/delay.h @@ -2,8 +2,11 @@ #define _ASM_POWERPC_DELAY_H #ifdef __KERNEL__ +#include asm/time.h + /* * Copyright 1996, Paul Mackerras. + * Copyright (C) 2009 Freescale Semiconductor, Inc. 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 @@ -30,5 +33,35 @@ extern void udelay(unsigned long usecs); #define mdelay(n) udelay((n) * 1000) #endif +/** + * spin_event_timeout - spin until a condition gets true or a timeout elapses + * @condition: a C expression to evalate + * @timeout: timeout, in microseconds + * @delay: the number of microseconds to delay between eache evaluation of + * @condition + * @rc: the last value of the condition + * + * The process spins until the condition evaluates to true (non-zero) or the + * timeout elapses. Upon exit, @rc contains the value of the condition. This + * allows you to test the condition without incurring any side effects. + * + * This primary purpose of this macro is to poll on a hardware register + * until a status bit changes. The timeout ensures that the loop still + * terminates even if the bit never changes. The delay is for devices that + * need a delay in between successive reads. + * + * gcc will optimize out the if-statement if @delay is a constant. + */ +#define spin_event_timeout(condition, timeout, delay, rc) \ +{ \ + unsigned long __loops = tb_ticks_per_usec * timeout; \ + unsigned long __start = get_tbl(); \ + while (!(rc = (condition)) (tb_ticks_since(__start) = __loops)) \ + if (delay) \ + udelay(delay); \ + else \ + cpu_relax(); \ +} + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_DELAY_H */ -- 1.6.0.6 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V4 0/5] AC97 driver for mpc5200
Version 4. Changed timeouts to use relax_cpu() instead of udelay(). Fixed locking to lock bestcomm instead of registers. Code reorg as requested in the various comments. Removed sysfs over/underrun reporting. Removed reset retries. Removing the retries makes the driver fail to load about 5% of the time. An oscilliscope is needed to figure out what is going on with failed resets. Both pcm030 and Efika ocasionally fail to reset and they use different codec chips. --- Jon Smirl (5): Fabric bindings for STAC9766 on the Efika Support for AC97 on Phytec pmc030 base board. AC97 driver for mpc5200 Main rewite of the mpc5200 audio DMA code The macro spin_event_timeout() takes a condition and timeout value arch/powerpc/include/asm/delay.h| 33 +++ sound/soc/fsl/Kconfig | 27 ++ sound/soc/fsl/Makefile |5 sound/soc/fsl/efika-audio-fabric.c | 90 +++ sound/soc/fsl/mpc5200_dma.c | 442 ++- sound/soc/fsl/mpc5200_dma.h | 43 ++- sound/soc/fsl/mpc5200_psc_ac97.c| 331 ++ sound/soc/fsl/mpc5200_psc_ac97.h| 15 + sound/soc/fsl/mpc5200_psc_i2s.c | 247 +++- sound/soc/fsl/mpc5200_psc_i2s.h | 12 + sound/soc/fsl/pcm030-audio-fabric.c | 90 +++ 11 files changed, 946 insertions(+), 389 deletions(-) create mode 100644 sound/soc/fsl/efika-audio-fabric.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value
(in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns the result of the condition when the loop was terminated. This primary purpose of this macro is to poll on a hardware register until a status bit changes. The timeout ensures that the loop still terminates if the bit doesn't change as expected. This macro makes it easier for driver developers to perform this kind of operation properly. Signed-off-by: Timur Tabi ti...@freescale.com --- arch/powerpc/include/asm/delay.h | 33 + 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h index f9200a6..fedf037 100644 --- a/arch/powerpc/include/asm/delay.h +++ b/arch/powerpc/include/asm/delay.h @@ -2,8 +2,11 @@ #define _ASM_POWERPC_DELAY_H #ifdef __KERNEL__ +#include asm/time.h + /* * Copyright 1996, Paul Mackerras. + * Copyright (C) 2009 Freescale Semiconductor, Inc. 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 @@ -30,5 +33,35 @@ extern void udelay(unsigned long usecs); #define mdelay(n) udelay((n) * 1000) #endif +/** + * spin_event_timeout - spin until a condition gets true or a timeout elapses + * @condition: a C expression to evalate + * @timeout: timeout, in microseconds + * @delay: the number of microseconds to delay between eache evaluation of + * @condition + * @rc: the last value of the condition + * + * The process spins until the condition evaluates to true (non-zero) or the + * timeout elapses. Upon exit, @rc contains the value of the condition. This + * allows you to test the condition without incurring any side effects. + * + * This primary purpose of this macro is to poll on a hardware register + * until a status bit changes. The timeout ensures that the loop still + * terminates even if the bit never changes. The delay is for devices that + * need a delay in between successive reads. + * + * gcc will optimize out the if-statement if @delay is a constant. + */ +#define spin_event_timeout(condition, timeout, delay, rc) \ +{ \ + unsigned long __loops = tb_ticks_per_usec * timeout;\ + unsigned long __start = get_tbl(); \ + while ((rc = (condition)) (tb_ticks_since(__start) = __loops)) \ + if (delay) \ + udelay(delay); \ + else\ + cpu_relax();\ +} + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_DELAY_H */ ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V4 2/5] Main rewite of the mpc5200 audio DMA code
Rewrite the mpc5200 audio DMA code to support both I2S and AC97. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |1 sound/soc/fsl/mpc5200_dma.c | 442 --- sound/soc/fsl/mpc5200_dma.h | 43 ++-- sound/soc/fsl/mpc5200_psc_i2s.c | 247 -- sound/soc/fsl/mpc5200_psc_i2s.h | 12 + 5 files changed, 356 insertions(+), 389 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index dc79bdf..1918c78 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -25,7 +25,6 @@ config SND_SOC_MPC8610_HPCD config SND_SOC_MPC5200_I2S tristate Freescale MPC5200 PSC in I2S mode driver depends on PPC_MPC52xx PPC_BESTCOMM - select SND_SOC_OF_SIMPLE select SND_MPC52xx_DMA select PPC_BESTCOMM_GEN_BD help diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 6850392..efec33a 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -3,23 +3,13 @@ * ALSA SoC Platform driver * * Copyright (C) 2008 Secret Lab Technologies Ltd. + * Copyright (C) 2009 Jon Smirl, Digispeaker */ -#include linux/init.h #include linux/module.h -#include linux/interrupt.h -#include linux/device.h -#include linux/delay.h #include linux/of_device.h -#include linux/of_platform.h -#include linux/dma-mapping.h -#include sound/core.h -#include sound/pcm.h -#include sound/pcm_params.h -#include sound/initval.h #include sound/soc.h -#include sound/soc-of-simple.h #include sysdev/bestcomm/bestcomm.h #include sysdev/bestcomm/gen_bd.h @@ -27,10 +17,6 @@ #include mpc5200_dma.h -MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca); -MODULE_DESCRIPTION(Freescale MPC5200 PSC in DMA mode ASoC Driver); -MODULE_LICENSE(GPL); - /* * Interrupt handlers */ @@ -50,7 +36,7 @@ static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma) if (psc_dma-capture.active (isr MPC52xx_PSC_IMR_ORERR)) psc_dma-stats.overrun_count++; - out_8(regs-command, 4 4); /* reset the error status */ + out_8(regs-command, MPC52xx_PSC_RST_ERR_STAT); return IRQ_HANDLED; } @@ -81,21 +67,36 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) s-period_next_pt = s-period_start; } +static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) +{ + while (s-appl_ptr s-runtime-control-appl_ptr) { + + if (bcom_queue_full(s-bcom_task)) + return; + + s-appl_ptr += s-period_size; + + psc_dma_bcom_enqueue_next_buffer(s); + } +} + /* Bestcomm DMA irq handler */ -static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) +static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream) { struct psc_dma_stream *s = _psc_dma_stream; + spin_lock(s-psc_dma-lock); /* For each finished period, dequeue the completed period buffer * and enqueue a new one in it's place. */ while (bcom_buffer_done(s-bcom_task)) { bcom_retrieve_buffer(s-bcom_task, NULL, NULL); + s-period_current_pt += s-period_bytes; if (s-period_current_pt = s-period_end) s-period_current_pt = s-period_start; - psc_dma_bcom_enqueue_next_buffer(s); - bcom_enable(s-bcom_task); } + psc_dma_bcom_enqueue_tx(s); + spin_unlock(s-psc_dma-lock); /* If the stream is active, then also inform the PCM middle layer * of the period finished event. */ @@ -105,49 +106,33 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) return IRQ_HANDLED; } -/** - * psc_dma_startup: create a new substream - * - * This is the first function called when a stream is opened. - * - * If this is the first stream open, then grab the IRQ and program most of - * the PSC registers. - */ -int psc_dma_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static irqreturn_t psc_dma_bcom_irq_rx(int irq, void *_psc_dma_stream) { - struct snd_soc_pcm_runtime *rtd = substream-private_data; - struct psc_dma *psc_dma = rtd-dai-cpu_dai-private_data; - int rc; + struct psc_dma_stream *s = _psc_dma_stream; - dev_dbg(psc_dma-dev, psc_dma_startup(substream=%p)\n, substream); + spin_lock(s-psc_dma-lock); + /* For each finished period, dequeue the completed period buffer +* and enqueue a new one in it's place. */ + while (bcom_buffer_done(s-bcom_task)) { + bcom_retrieve_buffer(s-bcom_task, NULL, NULL); - if (!psc_dma-playback.active - !psc_dma-capture.active) { - /* Setup the IRQs */ - rc = request_irq(psc_dma-irq, psc_dma_status_irq, IRQF_SHARED
[PATCH V4 3/5] AC97 driver for mpc5200
AC97 driver for mpc5200 I've implemented retries for when the AC97 hardware doesn't reset on first try. About 10% of the time both the Efika and pcm030 AC97 codecs don't reset on first try and need to be poked multiple times. Failure is indicated by not having the link clock start ticking. Every once in a while even five pokes won't get the link started and I have to power cycle. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig| 11 + sound/soc/fsl/Makefile |1 sound/soc/fsl/mpc5200_psc_ac97.c | 331 ++ sound/soc/fsl/mpc5200_psc_ac97.h | 15 ++ 4 files changed, 358 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 1918c78..3bce952 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -29,3 +29,14 @@ config SND_SOC_MPC5200_I2S select PPC_BESTCOMM_GEN_BD help Say Y here to support the MPC5200 PSCs in I2S mode. + +config SND_SOC_MPC5200_AC97 + tristate Freescale MPC5200 PSC in AC97 mode driver + depends on PPC_MPC52xx PPC_BESTCOMM + select AC97_BUS + select SND_MPC52xx_DMA + select PPC_BESTCOMM_GEN_BD + help + Say Y here to support the MPC5200 PSCs in AC97 mode. + + diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 7731ef2..14631a1 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -13,4 +13,5 @@ obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o # MPC5200 Platform Support obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o +obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c new file mode 100644 index 000..3e6838c --- /dev/null +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -0,0 +1,331 @@ +/* + * linux/sound/mpc5200-ac97.c -- AC97 support for the Freescale MPC52xx chip. + * + * Copyright (C) 2009 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * 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/module.h +#include linux/of_device.h +#include linux/of_platform.h + +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/time.h +#include asm/delay.h +#include asm/mpc52xx_psc.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h + +#define DRV_NAME mpc5200-psc-ac97 + +/* ALSA only supports a single AC97 device so static is recommend here */ +static struct psc_dma *psc_dma; + +static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) +{ + int rc; + unsigned int val; + + /* Wait for command send status zero = ready */ + spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); + if (rc != 0) { + pr_err(timeout on ac97 bus (rdy)\n); + return -ENODEV; + } + /* Send the read */ + out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); + + /* Wait for the answer */ + spin_event_timeout(!(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_DATA_VAL), 100, 0, rc); + if (rc != 0) { + pr_err(timeout on ac97 read (val) %x\n, + in_be16(psc_dma-psc_regs-sr_csr.status)); + return -ENODEV; + } + /* Get the data */ + val = in_be32(psc_dma-psc_regs-ac97_data); + if (((val 24) 0x7f) != reg) { + pr_err(reg echo error on ac97 read\n); + return -ENODEV; + } + val = (val 8) 0x; + + return (unsigned short) val; +} + +static void psc_ac97_write(struct snd_ac97 *ac97, + unsigned short reg, unsigned short val) +{ + int rc; + + /* Wait for command status zero = ready */ + spin_event_timeout((in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND), 100, 0, rc); + if (rc != 0) { + pr_err(timeout on ac97 bus (write)\n); + return; + } + /* Write data */ + out_be32(psc_dma-psc_regs-ac97_cmd, + ((reg 0x7f) 24) | (val 8)); +} + +static void psc_ac97_warm_reset(struct snd_ac97 *ac97) +{ + int rc; + struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; + + out_be32(regs-sicr, psc_dma-sicr | MPC52xx_PSC_SICR_AWR); + spin_event_timeout(1, 3, 0, rc); + out_be32(regs-sicr, psc_dma-sicr); +} + +static void psc_ac97_cold_reset(struct snd_ac97 *ac97) +{ + int rc
[PATCH V4 4/5] Support for AC97 on Phytec pmc030 base board.
Support for AC97 on Phytec pmc030 base board. A wm9712 AC97 codec is used. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |7 +++ sound/soc/fsl/Makefile |3 + sound/soc/fsl/pcm030-audio-fabric.c | 90 +++ 3 files changed, 100 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 3bce952..79579ae 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -39,4 +39,11 @@ config SND_SOC_MPC5200_AC97 help Say Y here to support the MPC5200 PSCs in AC97 mode. +config SND_MPC52xx_SOC_PCM030 + tristate SoC AC97 Audio support for Phytec pcm030 and WM9712 + depends on PPC_MPC5200_SIMPLE + select SND_SOC_MPC5200_AC97 + select SND_SOC_WM9712 + help + Say Y if you want to add support for sound on the Phytec pcm030 baseboard. diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 14631a1..66d88c8 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -15,3 +15,6 @@ obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o +# MPC5200 Machine Support +obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o + diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c new file mode 100644 index 000..8766f7a --- /dev/null +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -0,0 +1,90 @@ +/* + * Phytec pcm030 driver for the PSC of the Freescale MPC52xx + * configured as AC97 interface + * + * Copyright 2008 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h +#include ../codecs/wm9712.h + +static struct snd_soc_device device; +static struct snd_soc_card card; + +static struct snd_soc_dai_link pcm030_fabric_dai[] = { +{ + .name = AC97, + .stream_name = AC97 Analog, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_HIFI], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], +}, +{ + .name = AC97, + .stream_name = AC97 IEC958, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_AUX], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], +}, +}; + +static __init int pcm030_fabric_init(void) +{ + struct platform_device *pdev; + int rc; + + if (!machine_is_compatible(phytec,pcm030)) + return -ENODEV; + + card.platform = mpc5200_audio_dma_platform; + card.name = pcm030; + card.dai_link = pcm030_fabric_dai; + card.num_links = ARRAY_SIZE(pcm030_fabric_dai); + + device.card = card; + device.codec_dev = soc_codec_dev_wm9712; + + pdev = platform_device_alloc(soc-audio, 1); + if (!pdev) { + pr_err(pcm030_fabric_init: platform_device_alloc() failed\n); + return -ENODEV; + } + + platform_set_drvdata(pdev, device); + device.dev = pdev-dev; + + rc = platform_device_add(pdev); + if (rc) { + pr_err(pcm030_fabric_init: platform_device_add() failed\n); + return -ENODEV; + } + return 0; +} + +module_init(pcm030_fabric_init); + + +MODULE_AUTHOR(Jon Smirl jonsm...@gmail.com); +MODULE_DESCRIPTION(DRV_NAME : mpc5200 pcm030 fabric driver); +MODULE_LICENSE(GPL); + ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V4 5/5] Fabric bindings for STAC9766 on the Efika
Fabric bindings for STAC9766 AC97 codec on the Efika. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |8 +++ sound/soc/fsl/Makefile |1 sound/soc/fsl/efika-audio-fabric.c | 90 3 files changed, 99 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/efika-audio-fabric.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 79579ae..f571c6e 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -47,3 +47,11 @@ config SND_MPC52xx_SOC_PCM030 help Say Y if you want to add support for sound on the Phytec pcm030 baseboard. +config SND_MPC52xx_SOC_EFIKA + tristate SoC AC97 Audio support for bbplan Efika and STAC9766 + depends on PPC_EFIKA + select SND_SOC_MPC5200_AC97 + select SND_SOC_STAC9766 + help + Say Y if you want to add support for sound on the Efika. + diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 66d88c8..a83a739 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -17,4 +17,5 @@ obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o # MPC5200 Machine Support obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o +obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c new file mode 100644 index 000..85b0e75 --- /dev/null +++ b/sound/soc/fsl/efika-audio-fabric.c @@ -0,0 +1,90 @@ +/* + * Efika driver for the PSC of the Freescale MPC52xx + * configured as AC97 interface + * + * Copyright 2008 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h +#include ../codecs/stac9766.h + +static struct snd_soc_device device; +static struct snd_soc_card card; + +static struct snd_soc_dai_link efika_fabric_dai[] = { +{ + .name = AC97, + .stream_name = AC97 Analog, + .codec_dai = stac9766_dai[STAC9766_DAI_AC97_ANALOG], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], +}, +{ + .name = AC97, + .stream_name = AC97 IEC958, + .codec_dai = stac9766_dai[STAC9766_DAI_AC97_DIGITAL], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], +}, +}; + +static __init int efika_fabric_init(void) +{ + struct platform_device *pdev; + int rc; + + if (!machine_is_compatible(bplan,efika)) + return -ENODEV; + + card.platform = mpc5200_audio_dma_platform; + card.name = Efika; + card.dai_link = efika_fabric_dai; + card.num_links = ARRAY_SIZE(efika_fabric_dai); + + device.card = card; + device.codec_dev = soc_codec_dev_stac9766; + + pdev = platform_device_alloc(soc-audio, 1); + if (!pdev) { + pr_err(efika_fabric_init: platform_device_alloc() failed\n); + return -ENODEV; + } + + platform_set_drvdata(pdev, device); + device.dev = pdev-dev; + + rc = platform_device_add(pdev); + if (rc) { + pr_err(efika_fabric_init: platform_device_add() failed\n); + return -ENODEV; + } + return 0; +} + +module_init(efika_fabric_init); + + +MODULE_AUTHOR(Jon Smirl jonsm...@gmail.com); +MODULE_DESCRIPTION(DRV_NAME : mpc5200 Efika fabric driver); +MODULE_LICENSE(GPL); + ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH V2 0/9] mpc5200 audio rework for AC97
On Sun, May 24, 2009 at 7:08 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: I'm not aware of any CODEC drivers which can't currently be built and used as modules. If you mean load via the normal device model then yes, that'd be very good (and is in progress) but it's another issue and as I explained last time AC97 poses particular problems there. I mean load via the normal device model. For example the AC97 drivers need to be loadable by the codec id. There's no entry in scripts/mod/file2alias.c for dynamically loading the modules. They don't have an id_table. My AC97 driver is detecting the codec id and printing it before trying to access the codec driver. I can convert that to a load_module() call when the drivers are ready. The core needs to detect if a specific codec id can't be supported to fall back to the generic AC97 driver. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH V2 1/9] Register the wm9712 DAIs on module load
On Sun, May 24, 2009 at 7:11 AM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Sat, May 23, 2009 at 07:12:57PM -0400, Jon Smirl wrote: Register the wm9712 DAIs on module load Signed-off-by: Jon Smirl jonsm...@gmail.com Why do you wish to do this - ASoC does not require or use DAI registration for AC97 CODECs? Then what is wrong with my binding code? If I take out the registration my bind fails. static struct snd_soc_dai_link pcm030_fabric_dai[] = { { .name = AC97, .stream_name = AC97 Analog, .codec_dai = wm9712_dai[WM9712_DAI_AC97_HIFI], .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], }, { .name = AC97, .stream_name = AC97 IEC958, .codec_dai = wm9712_dai[WM9712_DAI_AC97_AUX], .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], }, }; static __init int pcm030_fabric_init(void) { struct platform_device *pdev; int rc; if (!machine_is_compatible(phytec,pcm030)) return -ENODEV; card.platform = mpc5200_audio_dma_platform; card.name = pcm030; card.dai_link = pcm030_fabric_dai; card.num_links = ARRAY_SIZE(pcm030_fabric_dai); device.card = card; device.codec_dev = soc_codec_dev_wm9712; pdev = platform_device_alloc(soc-audio, 1); if (!pdev) { pr_err(pcm030_fabric_init: platform_device_alloc() failed\n); return -ENODEV; } platform_set_drvdata(pdev, device); device.dev = pdev-dev; rc = platform_device_add(pdev); if (rc) { pr_err(pcm030_fabric_init: platform_device_add() failed\n); return -ENODEV; } return 0; } Advanced Linux Sound Architecture Driver Version 1.0.19. No device for DAI stac9766 analog No device for DAI stac9766 IEC958 No device for DAI tas5504 irq: irq 129 on host /soc5...@f000/interrupt-control...@500 mapped to virtual irq 129 irq: irq 194 on host /soc5...@f000/interrupt-control...@500 mapped to virtual irq 194 irq: irq 195 on host /soc5...@f000/interrupt-control...@500 mapped to virtual irq 195 mpc5200-psc-ac97 f0002000.ac97: Codec ID is 574d 4c12 ALSA device list: No soundcards found. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH V2 1/9] Register the wm9712 DAIs on module load
Output with SOC DEBUG turned on: Advanced Linux Sound Architecture Driver Version 1.0.19. No device for DAI stac9766 analog Registered DAI 'stac9766 analog' No device for DAI stac9766 IEC958 Registered DAI 'stac9766 IEC958' No device for DAI tas5504 Registered DAI 'tas5504' Registered platform 'mpc5200-psc-audio' irq: irq 129 on host /soc5...@f000/interrupt-control...@500 mapped to virtual irq 129 irq: irq 194 on host /soc5...@f000/interrupt-control...@500 mapped to virtual irq 194 irq: irq 195 on host /soc5...@f000/interrupt-control...@500 mapped to virtual irq 195 Registered DAI 'AC97' Registered DAI 'SPDIF' mpc5200-psc-ac97 f0002000.ac97: Codec ID is 574d 4c12 soc-audio soc-audio.1: DAI AC97 HiFi not registered soc-audio soc-audio.1: Registered card 'pcm030' ALSA device list: No soundcards found. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH V2 5/9] Main rewite of the mpc5200 audio DMA code
On Sun, May 24, 2009 at 2:55 PM, Wolfram Sang w.s...@pengutronix.de wrote: Rewrite the mpc5200 audio DMA code to support both I2S and AC97. Make it more robust. Why is it more robust? I've implemented retries for when the AC97 hardware doesn't reset on first try. About 10% of the time both the Efika and pcm030 AC97 codecs don't reset on first try and need to be poked multiple times. Failure is indicated by not having the link clock start ticking. Every once in a while even five pokes won't get the link started and I have to power cycle. I don't have an oscilloscope, after I get these basic drivers in maybe someone can put a scope on this and figure out why reset is failing. I've read the various datasheets and I believe my reset pulses have the correct timings. -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoZmA0ACgkQD27XaX1/VRvugwCgsluxfp1rJH2MVFMTH6Yqo8bX dnIAn1z0QRIFEUJa0XpGFE937siwf8Cy =M0wP -END PGP SIGNATURE- -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V3 0/4] mpc5200 audio rework for AC97
The following series implements audio support for the mpc5200. It adds an AC97 driver and STAC9766 codec driver. Board support for the Efika and Phytec pcm030 are also included. I've tried to implement the feedback received on the previous two versions. based on commit 0bc53a67ac831ec84f730a657dbcadd80a589ef5 on broonie/for-2.6.31 at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git --- Jon Smirl (4): Fabric bindings for STAC9766 on the Efika Support for AC97 on Phytec pmc030 base board. AC97 driver for mpc5200 Main rewite of the mpc5200 audio DMA code sound/soc/fsl/Kconfig | 27 ++ sound/soc/fsl/Makefile |5 sound/soc/fsl/efika-audio-fabric.c | 95 +++ sound/soc/fsl/mpc5200_dma.c | 504 +++ sound/soc/fsl/mpc5200_dma.h | 33 +- sound/soc/fsl/mpc5200_psc_ac97.c| 392 +++ sound/soc/fsl/mpc5200_psc_ac97.h| 15 + sound/soc/fsl/mpc5200_psc_i2s.c | 247 +++-- sound/soc/fsl/mpc5200_psc_i2s.h | 12 + sound/soc/fsl/pcm030-audio-fabric.c | 95 +++ 10 files changed, 1036 insertions(+), 389 deletions(-) create mode 100644 sound/soc/fsl/efika-audio-fabric.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V3 1/4] Main rewite of the mpc5200 audio DMA code
Rewrite the mpc5200 audio DMA code to support both I2S and AC97. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |1 sound/soc/fsl/mpc5200_dma.c | 504 ++- sound/soc/fsl/mpc5200_dma.h | 33 +-- sound/soc/fsl/mpc5200_psc_i2s.c | 247 +++ sound/soc/fsl/mpc5200_psc_i2s.h | 12 + 5 files changed, 408 insertions(+), 389 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index dc79bdf..1918c78 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -25,7 +25,6 @@ config SND_SOC_MPC8610_HPCD config SND_SOC_MPC5200_I2S tristate Freescale MPC5200 PSC in I2S mode driver depends on PPC_MPC52xx PPC_BESTCOMM - select SND_SOC_OF_SIMPLE select SND_MPC52xx_DMA select PPC_BESTCOMM_GEN_BD help diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 6850392..4e1f1f8 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -3,23 +3,13 @@ * ALSA SoC Platform driver * * Copyright (C) 2008 Secret Lab Technologies Ltd. + * Copyright (C) 2009 Jon Smirl, Digispeaker */ -#include linux/init.h #include linux/module.h -#include linux/interrupt.h -#include linux/device.h -#include linux/delay.h #include linux/of_device.h -#include linux/of_platform.h -#include linux/dma-mapping.h -#include sound/core.h -#include sound/pcm.h -#include sound/pcm_params.h -#include sound/initval.h #include sound/soc.h -#include sound/soc-of-simple.h #include sysdev/bestcomm/bestcomm.h #include sysdev/bestcomm/gen_bd.h @@ -27,10 +17,6 @@ #include mpc5200_dma.h -MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca); -MODULE_DESCRIPTION(Freescale MPC5200 PSC in DMA mode ASoC Driver); -MODULE_LICENSE(GPL); - /* * Interrupt handlers */ @@ -50,7 +36,7 @@ static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma) if (psc_dma-capture.active (isr MPC52xx_PSC_IMR_ORERR)) psc_dma-stats.overrun_count++; - out_8(regs-command, 4 4); /* reset the error status */ + out_8(regs-command, MPC52xx_PSC_RST_ERR_STAT); return IRQ_HANDLED; } @@ -81,8 +67,21 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) s-period_next_pt = s-period_start; } +static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) +{ + while (s-appl_ptr s-runtime-control-appl_ptr) { + + if (bcom_queue_full(s-bcom_task)) + return; + + s-appl_ptr += s-period_size; + + psc_dma_bcom_enqueue_next_buffer(s); + } +} + /* Bestcomm DMA irq handler */ -static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) +static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream) { struct psc_dma_stream *s = _psc_dma_stream; @@ -90,12 +89,12 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) * and enqueue a new one in it's place. */ while (bcom_buffer_done(s-bcom_task)) { bcom_retrieve_buffer(s-bcom_task, NULL, NULL); + s-period_current_pt += s-period_bytes; if (s-period_current_pt = s-period_end) s-period_current_pt = s-period_start; - psc_dma_bcom_enqueue_next_buffer(s); - bcom_enable(s-bcom_task); } + psc_dma_bcom_enqueue_tx(s); /* If the stream is active, then also inform the PCM middle layer * of the period finished event. */ @@ -105,49 +104,31 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) return IRQ_HANDLED; } -/** - * psc_dma_startup: create a new substream - * - * This is the first function called when a stream is opened. - * - * If this is the first stream open, then grab the IRQ and program most of - * the PSC registers. - */ -int psc_dma_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static irqreturn_t psc_dma_bcom_irq_rx(int irq, void *_psc_dma_stream) { - struct snd_soc_pcm_runtime *rtd = substream-private_data; - struct psc_dma *psc_dma = rtd-dai-cpu_dai-private_data; - int rc; + struct psc_dma_stream *s = _psc_dma_stream; - dev_dbg(psc_dma-dev, psc_dma_startup(substream=%p)\n, substream); + /* For each finished period, dequeue the completed period buffer +* and enqueue a new one in it's place. */ + while (bcom_buffer_done(s-bcom_task)) { + bcom_retrieve_buffer(s-bcom_task, NULL, NULL); - if (!psc_dma-playback.active - !psc_dma-capture.active) { - /* Setup the IRQs */ - rc = request_irq(psc_dma-irq, psc_dma_status_irq, IRQF_SHARED, -psc-dma-status, psc_dma); - rc |= request_irq(psc_dma
[PATCH V3 2/4] AC97 driver for mpc5200
AC97 driver for mpc5200 I've implemented retries for when the AC97 hardware doesn't reset on first try. About 10% of the time both the Efika and pcm030 AC97 codecs don't reset on first try and need to be poked multiple times. Failure is indicated by not having the link clock start ticking. Every once in a while even five pokes won't get the link started and I have to power cycle. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig| 11 + sound/soc/fsl/Makefile |1 sound/soc/fsl/mpc5200_psc_ac97.c | 392 ++ sound/soc/fsl/mpc5200_psc_ac97.h | 15 + 4 files changed, 419 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 1918c78..3bce952 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -29,3 +29,14 @@ config SND_SOC_MPC5200_I2S select PPC_BESTCOMM_GEN_BD help Say Y here to support the MPC5200 PSCs in I2S mode. + +config SND_SOC_MPC5200_AC97 + tristate Freescale MPC5200 PSC in AC97 mode driver + depends on PPC_MPC52xx PPC_BESTCOMM + select AC97_BUS + select SND_MPC52xx_DMA + select PPC_BESTCOMM_GEN_BD + help + Say Y here to support the MPC5200 PSCs in AC97 mode. + + diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 7731ef2..14631a1 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -13,4 +13,5 @@ obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o # MPC5200 Platform Support obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o +obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c new file mode 100644 index 000..480b677 --- /dev/null +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -0,0 +1,392 @@ +/* + * linux/sound/mpc5200-ac97.c -- AC97 support for the Freescale MPC52xx chip. + * + * Copyright (C) 2009 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * 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/module.h +#include linux/of_device.h +#include linux/of_platform.h + +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mpc52xx_psc.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h + +#define DRV_NAME mpc5200-psc-ac97 + +/* ALSA only supports a single AC97 device so static is recommend here */ +static struct psc_dma *psc_dma; + +static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) +{ + int timeout; + unsigned int val; + + spin_lock(psc_dma-lock); + + /* Wait for it to be ready */ + timeout = 1000; + while ((--timeout) (in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND)) + udelay(10); + + if (!timeout) { + pr_err(timeout on ac97 bus (rdy)\n); + return 0x; + } + + /* Do the read */ + out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); + + /* Wait for the answer */ + timeout = 1000; + while ((--timeout) !(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_DATA_VAL)) + udelay(10); + + if (!timeout) { + pr_err(timeout on ac97 read (val) %x\n, + in_be16(psc_dma-psc_regs-sr_csr.status)); + return 0x; + } + + /* Get the data */ + val = in_be32(psc_dma-psc_regs-ac97_data); + if (((val24) 0x7f) != reg) { + pr_err(reg echo error on ac97 read\n); + return 0x; + } + val = (val 8) 0x; + + spin_unlock(psc_dma-lock); + return (unsigned short) val; +} + +static void psc_ac97_write(struct snd_ac97 *ac97, + unsigned short reg, unsigned short val) +{ + int timeout; + + spin_lock(psc_dma-lock); + + /* Wait for it to be ready */ + timeout = 1000; + while ((--timeout) (in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND)) + udelay(10); + + if (!timeout) { + pr_err(timeout on ac97 write\n); + return; + } + + /* Write data */ + out_be32(psc_dma-psc_regs-ac97_cmd, + ((reg 0x7f) 24) | (val 8)); + + spin_unlock(psc_dma-lock); +} + +static void psc_ac97_warm_reset(struct snd_ac97 *ac97) +{ + struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs
[PATCH V3 3/4] Support for AC97 on Phytec pmc030 base board.
Support for AC97 on Phytec pmc030 base board. A wm9712 AC97 codec is used. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |7 +++ sound/soc/fsl/Makefile |3 + sound/soc/fsl/pcm030-audio-fabric.c | 95 +++ 3 files changed, 105 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 3bce952..79579ae 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -39,4 +39,11 @@ config SND_SOC_MPC5200_AC97 help Say Y here to support the MPC5200 PSCs in AC97 mode. +config SND_MPC52xx_SOC_PCM030 + tristate SoC AC97 Audio support for Phytec pcm030 and WM9712 + depends on PPC_MPC5200_SIMPLE + select SND_SOC_MPC5200_AC97 + select SND_SOC_WM9712 + help + Say Y if you want to add support for sound on the Phytec pcm030 baseboard. diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 14631a1..66d88c8 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -15,3 +15,6 @@ obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o +# MPC5200 Machine Support +obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o + diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c new file mode 100644 index 000..2c426d5 --- /dev/null +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -0,0 +1,95 @@ +/* + * Phytec pcm030 driver for the PSC of the Freescale MPC52xx + * configured as AC97 interface + * + * Copyright 2008 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h +#include ../codecs/wm9712.h + +static struct snd_soc_device device; +static struct snd_soc_card card; + +static struct snd_soc_dai_link pcm030_fabric_dai[] = { +{ + .name = AC97, + .stream_name = AC97 Analog, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_HIFI], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], +}, +{ + .name = AC97, + .stream_name = AC97 IEC958, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_AUX], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], +}, +}; + +static __init int pcm030_fabric_init(void) +{ + struct platform_device *pdev; + int rc; + + if (!machine_is_compatible(phytec,pcm030)) + return -ENODEV; + + card.platform = mpc5200_audio_dma_platform; + card.name = pcm030; + card.dai_link = pcm030_fabric_dai; + card.num_links = ARRAY_SIZE(pcm030_fabric_dai); + + device.card = card; + device.codec_dev = soc_codec_dev_wm9712; + + pdev = platform_device_alloc(soc-audio, 1); + if (!pdev) { + pr_err(pcm030_fabric_init: platform_device_alloc() failed\n); + return -ENODEV; + } + + platform_set_drvdata(pdev, device); + device.dev = pdev-dev; + + rc = platform_device_add(pdev); + if (rc) { + pr_err(pcm030_fabric_init: platform_device_add() failed\n); + return -ENODEV; + } + return 0; +} + +static __exit void pcm030_fabric_exit(void) +{ +} + +module_init(pcm030_fabric_init); +module_exit(pcm030_fabric_exit); + + +MODULE_AUTHOR(Jon Smirl jonsm...@gmail.com); +MODULE_DESCRIPTION(DRV_NAME : mpc5200 pcm030 fabric driver); +MODULE_LICENSE(GPL); + ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V3 4/4] Fabric bindings for STAC9766 on the Efika
Fabric bindings for STAC9766 AC97 codec on the Efika. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |8 +++ sound/soc/fsl/Makefile |1 sound/soc/fsl/efika-audio-fabric.c | 95 3 files changed, 104 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/efika-audio-fabric.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 79579ae..f571c6e 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -47,3 +47,11 @@ config SND_MPC52xx_SOC_PCM030 help Say Y if you want to add support for sound on the Phytec pcm030 baseboard. +config SND_MPC52xx_SOC_EFIKA + tristate SoC AC97 Audio support for bbplan Efika and STAC9766 + depends on PPC_EFIKA + select SND_SOC_MPC5200_AC97 + select SND_SOC_STAC9766 + help + Say Y if you want to add support for sound on the Efika. + diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 66d88c8..a83a739 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -17,4 +17,5 @@ obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o # MPC5200 Machine Support obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o +obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c new file mode 100644 index 000..4b7ed2b --- /dev/null +++ b/sound/soc/fsl/efika-audio-fabric.c @@ -0,0 +1,95 @@ +/* + * Efika driver for the PSC of the Freescale MPC52xx + * configured as AC97 interface + * + * Copyright 2008 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h +#include ../codecs/stac9766.h + +static struct snd_soc_device device; +static struct snd_soc_card card; + +static struct snd_soc_dai_link efika_fabric_dai[] = { +{ + .name = AC97, + .stream_name = AC97 Analog, + .codec_dai = stac9766_dai[STAC9766_DAI_AC97_ANALOG], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], +}, +{ + .name = AC97, + .stream_name = AC97 IEC958, + .codec_dai = stac9766_dai[STAC9766_DAI_AC97_DIGITAL], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], +}, +}; + +static __init int efika_fabric_init(void) +{ + struct platform_device *pdev; + int rc; + + if (!machine_is_compatible(bplan,efika)) + return -ENODEV; + + card.platform = mpc5200_audio_dma_platform; + card.name = Efika; + card.dai_link = efika_fabric_dai; + card.num_links = ARRAY_SIZE(efika_fabric_dai); + + device.card = card; + device.codec_dev = soc_codec_dev_stac9766; + + pdev = platform_device_alloc(soc-audio, 1); + if (!pdev) { + pr_err(efika_fabric_init: platform_device_alloc() failed\n); + return -ENODEV; + } + + platform_set_drvdata(pdev, device); + device.dev = pdev-dev; + + rc = platform_device_add(pdev); + if (rc) { + pr_err(efika_fabric_init: platform_device_add() failed\n); + return -ENODEV; + } + return 0; +} + +static __exit void efika_fabric_exit(void) +{ +} + +module_init(efika_fabric_init); +module_exit(efika_fabric_exit); + + +MODULE_AUTHOR(Jon Smirl jonsm...@gmail.com); +MODULE_DESCRIPTION(DRV_NAME : mpc5200 Efika fabric driver); +MODULE_LICENSE(GPL); + ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V2 0/9] mpc5200 audio rework for AC97
The following series implements audio support for the mpc5200. It adds an AC97 driver and STAC9766 codec driver. Board support for the Efika and Phytec pcm030 are also included. Mark is not enthused about soc-of-simple.c so rather than extend it for AC97 I altered the drivers to not use it. Instead they use the old way of manually binding everything. Mark would like to see OF binding more closely integrated to the core. Once a proper solution for OF binding is agreed upon it is easy to convert the existing drivers. A first step would be converting the existing codec drivers so that they can be dynamically loaded. Grant, please check over the spin locking on register access. I'm not clear on why and when the registers have to be protected. Once these basic drivers are in-kernel and more people are testing them, I can add more features like pause/resume, power management, etc based on feedback. I2S will get examined in more detail for the next kernel cycle. Our multi-channel prototype I2S hardware is just about working. Once I get the multi-channel hardware I will implement and heavily test a lot more I2S capability. --- Jon Smirl (9): Support for AC97 on Phytec pmc030 base board. Fabric bindings for STAC9766 on the Efika AC97 driver for mpc5200 Codec for STAC9766 used on the Efika Main rewite of the mpc5200 audio DMA code Add a few more mpc5200 PSC defines Rename the PSC functions to DMA Basic split of mpc5200 DMA code out from mpc5200_psc_i2s Register the wm9712 DAIs on module load sound/soc/fsl/Kconfig | 31 + sound/soc/fsl/Makefile |7 sound/soc/fsl/efika-audio-fabric.c | 94 sound/soc/fsl/mpc5200_dma.c | 635 ++ sound/soc/fsl/mpc5200_dma.h | 80 sound/soc/fsl/mpc5200_psc_ac97.c| 394 ++ sound/soc/fsl/mpc5200_psc_ac97.h| 15 + sound/soc/fsl/mpc5200_psc_i2s.c | 750 ++- sound/soc/fsl/mpc5200_psc_i2s.h | 12 + sound/soc/fsl/pcm030-audio-fabric.c | 94 10 files changed, 1414 insertions(+), 698 deletions(-) create mode 100644 sound/soc/fsl/efika-audio-fabric.c create mode 100644 sound/soc/fsl/mpc5200_dma.c create mode 100644 sound/soc/fsl/mpc5200_dma.h create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V2 1/9] Register the wm9712 DAIs on module load
Register the wm9712 DAIs on module load Signed-off-by: Jon Smirl jonsm...@gmail.com --- 0 files changed, 0 insertions(+), 0 deletions(-) diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 1fd4e88..49ad987 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -742,6 +742,18 @@ struct snd_soc_codec_device soc_codec_dev_wm9712 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712); +static int __init wm9712_modinit(void) +{ + return snd_soc_register_dais(wm9712_dai, ARRAY_SIZE(wm9712_dai)); +} +module_init(wm9712_modinit); + +static void __exit wm9712_exit(void) +{ + snd_soc_unregister_dais(wm9712_dai, ARRAY_SIZE(wm9712_dai)); +} +module_exit(wm9712_exit); + MODULE_DESCRIPTION(ASoC WM9711/WM9712 driver); MODULE_AUTHOR(Liam Girdwood); MODULE_LICENSE(GPL); ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V2 2/9] Basic split of mpc5200 DMA code out from mpc5200_psc_i2s
Basic split of mpc5200 DMA code out from i2s into a standalone file. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |4 sound/soc/fsl/Makefile |2 sound/soc/fsl/mpc5200_dma.c | 458 + sound/soc/fsl/mpc5200_dma.h | 81 +++ sound/soc/fsl/mpc5200_psc_i2s.c | 485 --- 5 files changed, 547 insertions(+), 483 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_dma.c create mode 100644 sound/soc/fsl/mpc5200_dma.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 9fc9082..dc79bdf 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,5 +1,8 @@ config SND_SOC_OF_SIMPLE tristate + +config SND_MPC52xx_DMA + tristate # ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers # for the SSI and the Elo DMA controller. You will still need to select @@ -23,6 +26,7 @@ config SND_SOC_MPC5200_I2S tristate Freescale MPC5200 PSC in I2S mode driver depends on PPC_MPC52xx PPC_BESTCOMM select SND_SOC_OF_SIMPLE + select SND_MPC52xx_DMA select PPC_BESTCOMM_GEN_BD help Say Y here to support the MPC5200 PSCs in I2S mode. diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index f85134c..7731ef2 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -10,5 +10,7 @@ snd-soc-fsl-ssi-objs := fsl_ssi.o snd-soc-fsl-dma-objs := fsl_dma.o obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o +# MPC5200 Platform Support +obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c new file mode 100644 index 000..4bae8d6 --- /dev/null +++ b/sound/soc/fsl/mpc5200_dma.c @@ -0,0 +1,458 @@ +/* + * Freescale MPC5200 PSC DMA + * ALSA SoC Platform driver + * + * Copyright (C) 2008 Secret Lab Technologies Ltd. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include sysdev/bestcomm/bestcomm.h +#include sysdev/bestcomm/gen_bd.h +#include asm/mpc52xx_psc.h + +#include mpc5200_dma.h + +MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca); +MODULE_DESCRIPTION(Freescale MPC5200 PSC in DMA mode ASoC Driver); +MODULE_LICENSE(GPL); + +/* + * Interrupt handlers + */ +static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) +{ + struct psc_i2s *psc_i2s = _psc_i2s; + struct mpc52xx_psc __iomem *regs = psc_i2s-psc_regs; + u16 isr; + + isr = in_be16(regs-mpc52xx_psc_isr); + + /* Playback underrun error */ + if (psc_i2s-playback.active (isr MPC52xx_PSC_IMR_TXEMP)) + psc_i2s-stats.underrun_count++; + + /* Capture overrun error */ + if (psc_i2s-capture.active (isr MPC52xx_PSC_IMR_ORERR)) + psc_i2s-stats.overrun_count++; + + out_8(regs-command, 4 4); /* reset the error status */ + + return IRQ_HANDLED; +} + +/** + * psc_i2s_bcom_enqueue_next_buffer - Enqueue another audio buffer + * @s: pointer to stream private data structure + * + * Enqueues another audio period buffer into the bestcomm queue. + * + * Note: The routine must only be called when there is space available in + * the queue. Otherwise the enqueue will fail and the audio ring buffer + * will get out of sync + */ +static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s) +{ + struct bcom_bd *bd; + + /* Prepare and enqueue the next buffer descriptor */ + bd = bcom_prepare_next_buffer(s-bcom_task); + bd-status = s-period_bytes; + bd-data[0] = s-period_next_pt; + bcom_submit_next_buffer(s-bcom_task, NULL); + + /* Update for next period */ + s-period_next_pt += s-period_bytes; + if (s-period_next_pt = s-period_end) + s-period_next_pt = s-period_start; +} + +/* Bestcomm DMA irq handler */ +static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) +{ + struct psc_i2s_stream *s = _psc_i2s_stream; + + /* For each finished period, dequeue the completed period buffer +* and enqueue a new one in it's place. */ + while (bcom_buffer_done(s-bcom_task)) { + bcom_retrieve_buffer(s-bcom_task, NULL, NULL); + s-period_current_pt += s-period_bytes; + if (s-period_current_pt = s-period_end) + s-period_current_pt = s-period_start; + psc_i2s_bcom_enqueue_next_buffer(s); + bcom_enable(s-bcom_task); + } + + /* If the stream is active, then also inform the PCM
[PATCH V2 3/9] Rename the PSC functions to DMA
Rename the functions in the mpc5200 DMA file from i2s based names to dma ones to reflect the file they are in. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_dma.c | 194 --- sound/soc/fsl/mpc5200_dma.h | 26 +++-- sound/soc/fsl/mpc5200_psc_i2s.c | 160 3 files changed, 190 insertions(+), 190 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 4bae8d6..6850392 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -34,21 +34,21 @@ MODULE_LICENSE(GPL); /* * Interrupt handlers */ -static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) +static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma) { - struct psc_i2s *psc_i2s = _psc_i2s; - struct mpc52xx_psc __iomem *regs = psc_i2s-psc_regs; + struct psc_dma *psc_dma = _psc_dma; + struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; u16 isr; isr = in_be16(regs-mpc52xx_psc_isr); /* Playback underrun error */ - if (psc_i2s-playback.active (isr MPC52xx_PSC_IMR_TXEMP)) - psc_i2s-stats.underrun_count++; + if (psc_dma-playback.active (isr MPC52xx_PSC_IMR_TXEMP)) + psc_dma-stats.underrun_count++; /* Capture overrun error */ - if (psc_i2s-capture.active (isr MPC52xx_PSC_IMR_ORERR)) - psc_i2s-stats.overrun_count++; + if (psc_dma-capture.active (isr MPC52xx_PSC_IMR_ORERR)) + psc_dma-stats.overrun_count++; out_8(regs-command, 4 4); /* reset the error status */ @@ -56,7 +56,7 @@ static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) } /** - * psc_i2s_bcom_enqueue_next_buffer - Enqueue another audio buffer + * psc_dma_bcom_enqueue_next_buffer - Enqueue another audio buffer * @s: pointer to stream private data structure * * Enqueues another audio period buffer into the bestcomm queue. @@ -65,7 +65,7 @@ static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) * the queue. Otherwise the enqueue will fail and the audio ring buffer * will get out of sync */ -static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s) +static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) { struct bcom_bd *bd; @@ -82,9 +82,9 @@ static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s) } /* Bestcomm DMA irq handler */ -static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) +static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) { - struct psc_i2s_stream *s = _psc_i2s_stream; + struct psc_dma_stream *s = _psc_dma_stream; /* For each finished period, dequeue the completed period buffer * and enqueue a new one in it's place. */ @@ -93,7 +93,7 @@ static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) s-period_current_pt += s-period_bytes; if (s-period_current_pt = s-period_end) s-period_current_pt = s-period_start; - psc_i2s_bcom_enqueue_next_buffer(s); + psc_dma_bcom_enqueue_next_buffer(s); bcom_enable(s-bcom_task); } @@ -106,39 +106,39 @@ static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) } /** - * psc_i2s_startup: create a new substream + * psc_dma_startup: create a new substream * * This is the first function called when a stream is opened. * * If this is the first stream open, then grab the IRQ and program most of * the PSC registers. */ -int psc_i2s_startup(struct snd_pcm_substream *substream, +int psc_dma_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; - struct psc_i2s *psc_i2s = rtd-dai-cpu_dai-private_data; + struct psc_dma *psc_dma = rtd-dai-cpu_dai-private_data; int rc; - dev_dbg(psc_i2s-dev, psc_i2s_startup(substream=%p)\n, substream); + dev_dbg(psc_dma-dev, psc_dma_startup(substream=%p)\n, substream); - if (!psc_i2s-playback.active - !psc_i2s-capture.active) { + if (!psc_dma-playback.active + !psc_dma-capture.active) { /* Setup the IRQs */ - rc = request_irq(psc_i2s-irq, psc_i2s_status_irq, IRQF_SHARED, -psc-i2s-status, psc_i2s); - rc |= request_irq(psc_i2s-capture.irq, - psc_i2s_bcom_irq, IRQF_SHARED, - psc-i2s-capture, psc_i2s-capture); - rc |= request_irq(psc_i2s-playback.irq, - psc_i2s_bcom_irq, IRQF_SHARED, - psc-i2s-playback, psc_i2s-playback); + rc = request_irq(psc_dma-irq, psc_dma_status_irq, IRQF_SHARED
[PATCH V2 5/9] Main rewite of the mpc5200 audio DMA code
Rewrite the mpc5200 audio DMA code to support both I2S and AC97. Make it more robust. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |1 sound/soc/fsl/mpc5200_dma.c | 505 ++- sound/soc/fsl/mpc5200_dma.h | 29 +- sound/soc/fsl/mpc5200_psc_i2s.c | 243 +++ sound/soc/fsl/mpc5200_psc_i2s.h | 12 + 5 files changed, 407 insertions(+), 383 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index dc79bdf..1918c78 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -25,7 +25,6 @@ config SND_SOC_MPC8610_HPCD config SND_SOC_MPC5200_I2S tristate Freescale MPC5200 PSC in I2S mode driver depends on PPC_MPC52xx PPC_BESTCOMM - select SND_SOC_OF_SIMPLE select SND_MPC52xx_DMA select PPC_BESTCOMM_GEN_BD help diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 6850392..95df860 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -3,23 +3,13 @@ * ALSA SoC Platform driver * * Copyright (C) 2008 Secret Lab Technologies Ltd. + * Copyright (C) 2009 Jon Smirl, Digispeaker */ -#include linux/init.h #include linux/module.h -#include linux/interrupt.h -#include linux/device.h -#include linux/delay.h #include linux/of_device.h -#include linux/of_platform.h -#include linux/dma-mapping.h -#include sound/core.h -#include sound/pcm.h -#include sound/pcm_params.h -#include sound/initval.h #include sound/soc.h -#include sound/soc-of-simple.h #include sysdev/bestcomm/bestcomm.h #include sysdev/bestcomm/gen_bd.h @@ -27,10 +17,6 @@ #include mpc5200_dma.h -MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca); -MODULE_DESCRIPTION(Freescale MPC5200 PSC in DMA mode ASoC Driver); -MODULE_LICENSE(GPL); - /* * Interrupt handlers */ @@ -50,7 +36,7 @@ static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma) if (psc_dma-capture.active (isr MPC52xx_PSC_IMR_ORERR)) psc_dma-stats.overrun_count++; - out_8(regs-command, 4 4); /* reset the error status */ + out_8(regs-command, MPC52xx_PSC_RST_ERR_STAT); return IRQ_HANDLED; } @@ -81,8 +67,21 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) s-period_next_pt = s-period_start; } +static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) +{ + while (s-appl_ptr s-runtime-control-appl_ptr) { + + if (bcom_queue_full(s-bcom_task)) + return; + + s-appl_ptr += s-period_size; + + psc_dma_bcom_enqueue_next_buffer(s); + } +} + /* Bestcomm DMA irq handler */ -static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) +static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream) { struct psc_dma_stream *s = _psc_dma_stream; @@ -90,12 +89,12 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) * and enqueue a new one in it's place. */ while (bcom_buffer_done(s-bcom_task)) { bcom_retrieve_buffer(s-bcom_task, NULL, NULL); + s-period_current_pt += s-period_bytes; if (s-period_current_pt = s-period_end) s-period_current_pt = s-period_start; - psc_dma_bcom_enqueue_next_buffer(s); - bcom_enable(s-bcom_task); } + psc_dma_bcom_enqueue_tx(s); /* If the stream is active, then also inform the PCM middle layer * of the period finished event. */ @@ -105,49 +104,31 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) return IRQ_HANDLED; } -/** - * psc_dma_startup: create a new substream - * - * This is the first function called when a stream is opened. - * - * If this is the first stream open, then grab the IRQ and program most of - * the PSC registers. - */ -int psc_dma_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static irqreturn_t psc_dma_bcom_irq_rx(int irq, void *_psc_dma_stream) { - struct snd_soc_pcm_runtime *rtd = substream-private_data; - struct psc_dma *psc_dma = rtd-dai-cpu_dai-private_data; - int rc; + struct psc_dma_stream *s = _psc_dma_stream; - dev_dbg(psc_dma-dev, psc_dma_startup(substream=%p)\n, substream); + /* For each finished period, dequeue the completed period buffer +* and enqueue a new one in it's place. */ + while (bcom_buffer_done(s-bcom_task)) { + bcom_retrieve_buffer(s-bcom_task, NULL, NULL); - if (!psc_dma-playback.active - !psc_dma-capture.active) { - /* Setup the IRQs */ - rc = request_irq(psc_dma-irq, psc_dma_status_irq, IRQF_SHARED, -psc-dma-status, psc_dma); - rc
[PATCH V2 6/9] Codec for STAC9766 used on the Efika
AC97 codec for STAC9766 used on the Efika. Datasheet: http://www.idt.com/products/getDoc.cfm?docID=13134007 Signed-off-by: Jon Smirl jonsm...@gmail.com --- 0 files changed, 0 insertions(+), 0 deletions(-) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 7f78b65..cb07d9b 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -19,6 +19,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_CS4270 if I2C select SND_SOC_PCM3008 select SND_SOC_SSM2602 if I2C + select SND_SOC_STAC9766 if SND_SOC_AC97_BUS select SND_SOC_TLV320AIC23 if I2C select SND_SOC_TLV320AIC26 if SPI_MASTER select SND_SOC_TLV320AIC3X if I2C @@ -93,6 +94,9 @@ config SND_SOC_PCM3008 config SND_SOC_SSM2602 tristate +config SND_SOC_STAC9766 + tristate + config SND_SOC_TLV320AIC23 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 70c55fa..46c007c 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -7,6 +7,7 @@ snd-soc-cs4270-objs := cs4270.o snd-soc-l3-objs := l3.o snd-soc-pcm3008-objs := pcm3008.o snd-soc-ssm2602-objs := ssm2602.o +snd-soc-stac9766-objs := stac9766.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic26-objs := tlv320aic26.o snd-soc-tlv320aic3x-objs := tlv320aic3x.o @@ -42,6 +43,7 @@ obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o +obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c new file mode 100644 index 000..7740cd5 --- /dev/null +++ b/sound/soc/codecs/stac9766.c @@ -0,0 +1,470 @@ +/* + * stac9766.c -- ALSA SoC STAC9766 codec support + * + * Copyright 2009 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Features:- + * + * o Support for AC97 Codec, S/PDIF + */ + +#include linux/init.h +#include linux/module.h +#include linux/device.h +#include sound/core.h +#include sound/pcm.h +#include sound/ac97_codec.h +#include sound/initval.h +#include sound/pcm_params.h +#include sound/soc.h +#include sound/tlv.h +#include sound/soc-of-simple.h + +#include stac9766.h + +#define STAC9766_VERSION 0.10 + +/* + * STAC9766 register cache + */ +static const u16 stac9766_reg[] = { + 0x6A90, 0x8000, 0x8000, 0x8000, /* 6 */ + 0x, 0x, 0x8008, 0x8008, /* e */ + 0x8808, 0x8808, 0x8808, 0x8808, /* 16 */ + 0x8808, 0x, 0x8000, 0x, /* 1e */ + 0x, 0x, 0x, 0x000f, /* 26 */ + 0x0a05, 0x0400, 0xbb80, 0x, /* 2e */ + 0x, 0xbb80, 0x, 0x, /* 36 */ + 0x, 0x2000, 0x, 0x0100, /* 3e */ + 0x, 0x, 0x0080, 0x, /* 46 */ + 0x, 0x, 0x0003, 0x, /* 4e */ + 0x, 0x, 0x, 0x, /* 56 */ + 0x4000, 0x, 0x, 0x, /* 5e */ + 0x1201, 0x, 0x, 0x, /* 66 */ + 0x, 0x, 0x, 0x, /* 6e */ + 0x, 0x, 0x, 0x0006, /* 76 */ + 0x, 0x, 0x, 0x, /* 7e */ +}; + +static const char *stac9766_record_mux[] = {Mic, CD, Video, AUX, Line, Stereo Mix, Mono Mix, Phone}; +static const char *stac9766_mono_mux[] = {Mix, Mic}; +static const char *stac9766_mic_mux[] = {Mic1, Mic2}; +static const char *stac9766_SPDIF_mux[] = {PCM, ADC Record}; +static const char *stac9766_popbypass_mux[] = {Normal, Bypass Mixer}; +static const char *stac9766_record_all_mux[] = {All analog, Analog plus DAC}; +static const char *stac9766_boost1[] = {0dB, 10dB}; +static const char *stac9766_boost2[] = {0dB, 20dB}; +static const char *stac9766_stereo_mic[] = {Off, On}; + +static const struct soc_enum stac9766_record_enum = + SOC_ENUM_DOUBLE(AC97_REC_SEL, 8, 0, 8, stac9766_record_mux); +static const struct soc_enum stac9766_mono_enum = + SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 9, 2, stac9766_mono_mux); +static const struct soc_enum stac9766_mic_enum = + SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 8, 2, stac9766_mic_mux); +static const struct soc_enum stac9766_SPDIF_enum = + SOC_ENUM_SINGLE(AC97_STAC_DA_CONTROL, 1, 2, stac9766_SPDIF_mux); +static const struct soc_enum stac9766_popbypass_enum = + SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, stac9766_popbypass_mux); +static const struct soc_enum stac9766_record_all_enum = + SOC_ENUM_SINGLE(AC97_STAC_ANALOG_SPECIAL
[PATCH V2 7/9] AC97 driver for mpc5200
AC97 driver for mpc5200 Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig| 11 + sound/soc/fsl/Makefile |1 sound/soc/fsl/mpc5200_psc_ac97.c | 394 ++ sound/soc/fsl/mpc5200_psc_ac97.h | 15 + 4 files changed, 421 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.c create mode 100644 sound/soc/fsl/mpc5200_psc_ac97.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 1918c78..3bce952 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -29,3 +29,14 @@ config SND_SOC_MPC5200_I2S select PPC_BESTCOMM_GEN_BD help Say Y here to support the MPC5200 PSCs in I2S mode. + +config SND_SOC_MPC5200_AC97 + tristate Freescale MPC5200 PSC in AC97 mode driver + depends on PPC_MPC52xx PPC_BESTCOMM + select AC97_BUS + select SND_MPC52xx_DMA + select PPC_BESTCOMM_GEN_BD + help + Say Y here to support the MPC5200 PSCs in AC97 mode. + + diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 7731ef2..14631a1 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -13,4 +13,5 @@ obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o # MPC5200 Platform Support obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o +obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c new file mode 100644 index 000..fa1bb9a --- /dev/null +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -0,0 +1,394 @@ +/* + * linux/sound/mpc5200-ac97.c -- AC97 support for the Freescale MPC52xx chip. + * + * Copyright (C) 2009 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * 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/module.h +#include linux/of_device.h +#include linux/of_platform.h + +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mpc52xx_psc.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h + +#define DRV_NAME mpc5200-psc-ac97 + +/* ALSA only supports a single AC97 device so static is recommend here */ +static struct psc_dma *psc_dma; + +static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) +{ + int timeout; + unsigned int val; + + spin_lock(psc_dma-lock); + + /* Wait for it to be ready */ + timeout = 1000; + while ((--timeout) (in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND) ) + udelay(10); + + if (!timeout) { + pr_err(timeout on ac97 bus (rdy)\n); + return 0x; + } + + /* Do the read */ + out_be32(psc_dma-psc_regs-ac97_cmd, (131) | ((reg 0x7f) 24)); + + /* Wait for the answer */ + timeout = 1000; + while ((--timeout) !(in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_DATA_VAL) ) + udelay(10); + + if (!timeout) { + pr_err(timeout on ac97 read (val) %x\n, in_be16(psc_dma-psc_regs-sr_csr.status)); + return 0x; + } + + /* Get the data */ + val = in_be32(psc_dma-psc_regs-ac97_data); + if ( ((val24) 0x7f) != reg ) { + pr_err(reg echo error on ac97 read\n); + return 0x; + } + val = (val 8) 0x; + + spin_unlock(psc_dma-lock); + return (unsigned short) val; +} + +static void psc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) +{ + int timeout; + + spin_lock(psc_dma-lock); + + /* Wait for it to be ready */ + timeout = 1000; + while ((--timeout) (in_be16(psc_dma-psc_regs-sr_csr.status) + MPC52xx_PSC_SR_CMDSEND) ) + udelay(10); + + if (!timeout) { + pr_err(timeout on ac97 write\n); + return; + } + + /* Write data */ + out_be32(psc_dma-psc_regs-ac97_cmd, ((reg 0x7f) 24) | (val 8)); + + spin_unlock(psc_dma-lock); +} + +static void psc_ac97_cold_reset(struct snd_ac97 *ac97) +{ + struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; + + /* Do a cold reset */ + out_8(regs-op1, MPC52xx_PSC_OP_RES); + udelay(10); + out_8(regs-op0, MPC52xx_PSC_OP_RES); + udelay(50); + + /* PSC recover from cold reset (cfr user manual, not sure if useful) */ + out_be32(regs-sicr, in_be32(regs-sicr)); +} + +static void psc_ac97_warm_reset(struct snd_ac97 *ac97) +{ + struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; + + out_be32(regs-sicr
[PATCH V2 8/9] Fabric bindings for STAC9766 on the Efika
Fabric bindings for STAC9766 AC97 codec on the Efika. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |8 +++ sound/soc/fsl/Makefile |3 + sound/soc/fsl/efika-audio-fabric.c | 94 3 files changed, 105 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/efika-audio-fabric.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 3bce952..edd8516 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -39,4 +39,12 @@ config SND_SOC_MPC5200_AC97 help Say Y here to support the MPC5200 PSCs in AC97 mode. +config SND_MPC52xx_SOC_EFIKA + tristate SoC AC97 Audio support for bbplan Efika and STAC9766 + depends on PPC_EFIKA + select SND_SOC_MPC5200_AC97 + select SND_SOC_STAC9766 + help + Say Y if you want to add support for sound on the Efika. + diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 14631a1..f406470 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -15,3 +15,6 @@ obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o +# MPC5200 Machine Support +obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o + diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c new file mode 100644 index 000..5126a81 --- /dev/null +++ b/sound/soc/fsl/efika-audio-fabric.c @@ -0,0 +1,94 @@ +/* + * Efika driver for the PSC of the Freescale MPC52xx configured as AC97 interface + * + * Copyright 2008 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h +#include ../codecs/stac9766.h + +static struct snd_soc_device device; +static struct snd_soc_card card; + +static struct snd_soc_dai_link efika_fabric_dai[] = { +{ + .name = AC97, + .stream_name = AC97 Analog, + .codec_dai = stac9766_dai[STAC9766_DAI_AC97_ANALOG], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], +}, +{ + .name = AC97, + .stream_name = AC97 IEC958, + .codec_dai = stac9766_dai[STAC9766_DAI_AC97_DIGITAL], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], +}, +}; + +static __init int efika_fabric_init(void) +{ + struct platform_device *pdev; + int rc; + + if (!machine_is_compatible(bplan,efika)) + return -ENODEV; + + card.platform = mpc5200_audio_dma_platform; + card.name = Efika; + card.dai_link = efika_fabric_dai; + card.num_links = ARRAY_SIZE(efika_fabric_dai); + + device.card = card; + device.codec_dev = soc_codec_dev_stac9766; + + pdev = platform_device_alloc(soc-audio, 1); + if (!pdev) { + pr_err(efika_fabric_init: platform_device_alloc() failed\n); + return -ENODEV; + } + + platform_set_drvdata(pdev, device); + device.dev = pdev-dev; + + rc = platform_device_add(pdev); + if (rc) { + pr_err(efika_fabric_init: platform_device_add() failed\n); + return -ENODEV; + } + return 0; +} + +static __exit void efika_fabric_exit(void) +{ +} + +module_init(efika_fabric_init); +module_exit(efika_fabric_exit); + + +MODULE_AUTHOR(Jon Smirl jonsm...@gmail.com); +MODULE_DESCRIPTION(DRV_NAME : mpc5200 Efika fabric driver); +MODULE_LICENSE(GPL); + ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V2 9/9] Support for AC97 on Phytec pmc030 base board.
Support for AC97 on Phytec pmc030 base board. A wm9712 AC97 codec is used. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |7 +++ sound/soc/fsl/Makefile |1 sound/soc/fsl/pcm030-audio-fabric.c | 94 +++ 3 files changed, 102 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/pcm030-audio-fabric.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index edd8516..5080e3e 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -47,4 +47,11 @@ config SND_MPC52xx_SOC_EFIKA help Say Y if you want to add support for sound on the Efika. +config SND_MPC52xx_SOC_PCM030 + tristate SoC AC97 Audio support for Phytec pcm030 and WM9712 + depends on PPC_MPC5200_SIMPLE + select SND_SOC_MPC5200_AC97 + select SND_SOC_WM9712 + help + Say Y if you want to add support for sound on the Phytec pcm030 baseboard. diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index f406470..5806d11 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -17,4 +17,5 @@ obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o # MPC5200 Machine Support obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o +obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c new file mode 100644 index 000..4bd957a --- /dev/null +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -0,0 +1,94 @@ +/* + * Phytec pcm030 driver for the PSC of the Freescale MPC52xx configured as AC97 interface + * + * Copyright 2008 Jon Smirl, Digispeaker + * Author: Jon Smirl jonsm...@gmail.com + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include mpc5200_dma.h +#include mpc5200_psc_ac97.h +#include ../codecs/wm9712.h + +static struct snd_soc_device device; +static struct snd_soc_card card; + +static struct snd_soc_dai_link pcm030_fabric_dai[] = { +{ + .name = AC97, + .stream_name = AC97 Analog, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_HIFI], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_NORMAL], +}, +{ + .name = AC97, + .stream_name = AC97 IEC958, + .codec_dai = wm9712_dai[WM9712_DAI_AC97_AUX], + .cpu_dai = psc_ac97_dai[MPC5200_AC97_SPDIF], +}, +}; + +static __init int pcm030_fabric_init(void) +{ + struct platform_device *pdev; + int rc; + + if (!machine_is_compatible(phytec,pcm030)) + return -ENODEV; + + card.platform = mpc5200_audio_dma_platform; + card.name = pcm030; + card.dai_link = pcm030_fabric_dai; + card.num_links = ARRAY_SIZE(pcm030_fabric_dai); + + device.card = card; + device.codec_dev = soc_codec_dev_wm9712; + + pdev = platform_device_alloc(soc-audio, 1); + if (!pdev) { + pr_err(pcm030_fabric_init: platform_device_alloc() failed\n); + return -ENODEV; + } + + platform_set_drvdata(pdev, device); + device.dev = pdev-dev; + + rc = platform_device_add(pdev); + if (rc) { + pr_err(pcm030_fabric_init: platform_device_add() failed\n); + return -ENODEV; + } + return 0; +} + +static __exit void pcm030_fabric_exit(void) +{ +} + +module_init(pcm030_fabric_init); +module_exit(pcm030_fabric_exit); + + +MODULE_AUTHOR(Jon Smirl jonsm...@gmail.com); +MODULE_DESCRIPTION(DRV_NAME : mpc5200 pcm030 fabric driver); +MODULE_LICENSE(GPL); + ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH V2 0/9] mpc5200 audio rework for AC97
On Sat, May 23, 2009 at 7:12 PM, Jon Smirl jonsm...@gmail.com wrote: The following series implements audio support for the mpc5200. It adds an AC97 driver and STAC9766 codec driver. Board support for the Efika and Phytec pcm030 are also included. Series is based on branch for-2.6.31 commit 0154724d487586241c1ad57cfd348ed2ff2274e2 at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V2 4/9] Add a few more mpc5200 PSC defines
Add a few more mpc5200 PSC defines. More bit fields defines for mpc5200 PSC registers. This patch is going in via Grant's tree. Signed-off-by: Jon Smirl jonsm...@gmail.com --- 0 files changed, 0 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/mpc52xx_psc.h b/arch/powerpc/include/asm/mpc52xx_psc.h index a218da6..fb84120 100644 --- a/arch/powerpc/include/asm/mpc52xx_psc.h +++ b/arch/powerpc/include/asm/mpc52xx_psc.h @@ -28,6 +28,10 @@ #define MPC52xx_PSC_MAXNUM 6 /* Programmable Serial Controller (PSC) status register bits */ +#define MPC52xx_PSC_SR_UNEX_RX 0x0001 +#define MPC52xx_PSC_SR_DATA_VAL0x0002 +#define MPC52xx_PSC_SR_DATA_OVR0x0004 +#define MPC52xx_PSC_SR_CMDSEND 0x0008 #define MPC52xx_PSC_SR_CDE 0x0080 #define MPC52xx_PSC_SR_RXRDY 0x0100 #define MPC52xx_PSC_SR_RXFULL 0x0200 @@ -61,6 +65,12 @@ #define MPC52xx_PSC_RXTX_FIFO_EMPTY0x0001 /* PSC interrupt status/mask bits */ +#define MPC52xx_PSC_IMR_UNEX_RX_SLOT 0x0001 +#define MPC52xx_PSC_IMR_DATA_VALID 0x0002 +#define MPC52xx_PSC_IMR_DATA_OVR 0x0004 +#define MPC52xx_PSC_IMR_CMD_SEND 0x0008 +#define MPC52xx_PSC_IMR_ERROR 0x0040 +#define MPC52xx_PSC_IMR_DEOF 0x0080 #define MPC52xx_PSC_IMR_TXRDY 0x0100 #define MPC52xx_PSC_IMR_RXRDY 0x0200 #define MPC52xx_PSC_IMR_DB 0x0400 @@ -117,6 +127,7 @@ #define MPC52xx_PSC_SICR_SIM_FIR (0x6 24) #define MPC52xx_PSC_SICR_SIM_CODEC_24 (0x7 24) #define MPC52xx_PSC_SICR_SIM_CODEC_32 (0xf 24) +#define MPC52xx_PSC_SICR_AWR (1 30) #define MPC52xx_PSC_SICR_GENCLK(1 23) #define MPC52xx_PSC_SICR_I2S (1 22) #define MPC52xx_PSC_SICR_CLKPOL(1 21) ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] mpc52xx_psc_spi: Convert to cs_control callback
On Thu, Apr 30, 2009 at 6:31 PM, Anton Vorontsov avoront...@ru.mvista.com wrote: mpc52xx_psc_spi driver is the last user of the legacy activate_cs and deactivate_cs callbacks, so convert the driver to the cs_control This driver is missing a call to of_register_spi_devices(master, op-node); Here's how I added it, but it could be done more cleanly. diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 68c77a9..fe0658a 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c @@ -22,6 +22,7 @@ #include linux/delay.h #include linux/spi/spi.h #include linux/fsl_devices.h +#include linux/of_spi.h #include asm/mpc52xx.h #include asm/mpc52xx_psc.h @@ -370,24 +371,24 @@ static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) } /* bus_num is used only for the case dev-platform_data == NULL */ -static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, +static int __init mpc52xx_psc_spi_do_probe(struct of_device *op, u32 regaddr, u32 size, unsigned int irq, s16 bus_num) { - struct fsl_spi_platform_data *pdata = dev-platform_data; + struct fsl_spi_platform_data *pdata = op-dev.platform_data; struct mpc52xx_psc_spi *mps; struct spi_master *master; int ret; - master = spi_alloc_master(dev, sizeof *mps); + master = spi_alloc_master(op-dev, sizeof *mps); if (master == NULL) return -ENOMEM; - dev_set_drvdata(dev, master); + dev_set_drvdata(op-dev, master); mps = spi_master_get_devdata(master); mps-irq = irq; if (pdata == NULL) { - dev_warn(dev, probe called without platform data, no + dev_warn(op-dev, probe called without platform data, no (de)activate_cs function will be called\n); mps-activate_cs = NULL; mps-deactivate_cs = NULL; @@ -407,7 +408,7 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, mps-psc = ioremap(regaddr, size); if (!mps-psc) { - dev_err(dev, could not ioremap I/O port range\n); + dev_err(op-dev, could not ioremap I/O port range\n); ret = -EFAULT; goto free_master; } @@ -439,6 +440,8 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, if (ret 0) goto unreg_master; + of_register_spi_devices(master, op-node); + return ret; unreg_master: @@ -495,7 +498,7 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, id = *psc_nump + 1; } - return mpc52xx_psc_spi_do_probe(op-dev, (u32)regaddr64, (u32)size64, + return mpc52xx_psc_spi_do_probe(op, (u32)regaddr64, (u32)size64, irq_of_parse_and_map(op-node, 0), id); } -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH] Add a few more mpc5200 PSC defines
Add a few more mpc5200 PSC defines. More bit fields defines for mpc5200 PSC registers Signed-off-by: Jon Smirl jonsm...@gmail.com --- arch/powerpc/include/asm/mpc52xx_psc.h | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/mpc52xx_psc.h b/arch/powerpc/include/asm/mpc52xx_psc.h index a218da6..fb84120 100644 --- a/arch/powerpc/include/asm/mpc52xx_psc.h +++ b/arch/powerpc/include/asm/mpc52xx_psc.h @@ -28,6 +28,10 @@ #define MPC52xx_PSC_MAXNUM 6 /* Programmable Serial Controller (PSC) status register bits */ +#define MPC52xx_PSC_SR_UNEX_RX 0x0001 +#define MPC52xx_PSC_SR_DATA_VAL0x0002 +#define MPC52xx_PSC_SR_DATA_OVR0x0004 +#define MPC52xx_PSC_SR_CMDSEND 0x0008 #define MPC52xx_PSC_SR_CDE 0x0080 #define MPC52xx_PSC_SR_RXRDY 0x0100 #define MPC52xx_PSC_SR_RXFULL 0x0200 @@ -61,6 +65,12 @@ #define MPC52xx_PSC_RXTX_FIFO_EMPTY0x0001 /* PSC interrupt status/mask bits */ +#define MPC52xx_PSC_IMR_UNEX_RX_SLOT 0x0001 +#define MPC52xx_PSC_IMR_DATA_VALID 0x0002 +#define MPC52xx_PSC_IMR_DATA_OVR 0x0004 +#define MPC52xx_PSC_IMR_CMD_SEND 0x0008 +#define MPC52xx_PSC_IMR_ERROR 0x0040 +#define MPC52xx_PSC_IMR_DEOF 0x0080 #define MPC52xx_PSC_IMR_TXRDY 0x0100 #define MPC52xx_PSC_IMR_RXRDY 0x0200 #define MPC52xx_PSC_IMR_DB 0x0400 @@ -117,6 +127,7 @@ #define MPC52xx_PSC_SICR_SIM_FIR (0x6 24) #define MPC52xx_PSC_SICR_SIM_CODEC_24 (0x7 24) #define MPC52xx_PSC_SICR_SIM_CODEC_32 (0xf 24) +#define MPC52xx_PSC_SICR_AWR (1 30) #define MPC52xx_PSC_SICR_GENCLK(1 23) #define MPC52xx_PSC_SICR_I2S (1 22) #define MPC52xx_PSC_SICR_CLKPOL(1 21) ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] Add a few more mpc5200 PSC defines
On Fri, May 22, 2009 at 11:33 AM, Grant Likely grant.lik...@secretlab.ca wrote: On Fri, May 22, 2009 at 9:25 AM, Jon Smirl jonsm...@gmail.com wrote: Add a few more mpc5200 PSC defines. More bit fields defines for mpc5200 PSC registers Signed-off-by: Jon Smirl jonsm...@gmail.com Thanks Jon, What are you adding these defines for (so I can add it to the commit log)? AC97 support g. --- arch/powerpc/include/asm/mpc52xx_psc.h | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/mpc52xx_psc.h b/arch/powerpc/include/asm/mpc52xx_psc.h index a218da6..fb84120 100644 --- a/arch/powerpc/include/asm/mpc52xx_psc.h +++ b/arch/powerpc/include/asm/mpc52xx_psc.h @@ -28,6 +28,10 @@ #define MPC52xx_PSC_MAXNUM 6 /* Programmable Serial Controller (PSC) status register bits */ +#define MPC52xx_PSC_SR_UNEX_RX 0x0001 +#define MPC52xx_PSC_SR_DATA_VAL 0x0002 +#define MPC52xx_PSC_SR_DATA_OVR 0x0004 +#define MPC52xx_PSC_SR_CMDSEND 0x0008 #define MPC52xx_PSC_SR_CDE 0x0080 #define MPC52xx_PSC_SR_RXRDY 0x0100 #define MPC52xx_PSC_SR_RXFULL 0x0200 @@ -61,6 +65,12 @@ #define MPC52xx_PSC_RXTX_FIFO_EMPTY 0x0001 /* PSC interrupt status/mask bits */ +#define MPC52xx_PSC_IMR_UNEX_RX_SLOT 0x0001 +#define MPC52xx_PSC_IMR_DATA_VALID 0x0002 +#define MPC52xx_PSC_IMR_DATA_OVR 0x0004 +#define MPC52xx_PSC_IMR_CMD_SEND 0x0008 +#define MPC52xx_PSC_IMR_ERROR 0x0040 +#define MPC52xx_PSC_IMR_DEOF 0x0080 #define MPC52xx_PSC_IMR_TXRDY 0x0100 #define MPC52xx_PSC_IMR_RXRDY 0x0200 #define MPC52xx_PSC_IMR_DB 0x0400 @@ -117,6 +127,7 @@ #define MPC52xx_PSC_SICR_SIM_FIR (0x6 24) #define MPC52xx_PSC_SICR_SIM_CODEC_24 (0x7 24) #define MPC52xx_PSC_SICR_SIM_CODEC_32 (0xf 24) +#define MPC52xx_PSC_SICR_AWR (1 30) #define MPC52xx_PSC_SICR_GENCLK (1 23) #define MPC52xx_PSC_SICR_I2S (1 22) #define MPC52xx_PSC_SICR_CLKPOL (1 21) -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Audio and mpc5200 bestcomm tasks
ALSA really wants to dynamically know the address of the current DMA location while transfers are active. This is an important piece of implementing pause/resume. Pause doesn't work too well if there is 2s of music already queued. The work around is to know the sample rate and use the jiffy count to estimate how far into the buffer DMA has progressed. But that's not as accurate as just asking the DMA hardware. I poked around in the SRAM data and couldn't find the address. Is it there or can the Bestcomm tasks be modified to leave it somewhere visible? -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: mpc5200 fec error
On Wed, May 20, 2009 at 9:42 AM, Eric Millbrandt emillbra...@dekaresearch.com wrote: I am able to reproduce the error using 2.6.29.2-rt11. I was able to mitigate the problem by raising the priority of the transmit irq. However when running an NFS server on the pcm030 under high cpu load I now get [ 132.477503] net eth0: FEC_IEVENT_RFIFO_ERROR [ 132.892329] net eth0: FEC_IEVENT_RFIFO_ERROR [ 133.884109] net eth0: FEC_IEVENT_RFIFO_ERROR [ 134.876059] net eth0: FEC_IEVENT_RFIFO_ERROR Raising the priority of the rx irq does not seem to fix this problem though. Hi Eric, This error has been seen before in non-rt kernels. I haven't had the chance to track it down and kill it yet. I believe there are locking issues associated with it. Uuuh, I recall this message. Kept me busy for some time :( You might try this patch which helped in our situation. === Subject: Enable XLB pipelining for MPC5200B From: Wolfram Sang w.s...@pengutronix.de Enable pipelining as it helps getting rid of FEC problems. Not intended for upstream, this must be dealt differently there. This patch is disabled by default. The bootloader should enable this feature. So, this patch is only intended to be used where the bootloader does it in a wrong manner and can't be replaced. Signed-off-by: Wolfram Sang w.s...@pengutronix.de Acked-by: Juergen Beisert j.beis...@pengutronix.de --- arch/powerpc/platforms/52xx/mpc52xx_common.c | 7 +++ 1 file changed, 7 insertions(+) Index: arch/powerpc/platforms/52xx/mpc52xx_common.c === --- arch/powerpc/platforms/52xx/mpc52xx_common.c.orig +++ arch/powerpc/platforms/52xx/mpc52xx_common.c @@ -107,6 +107,13 @@ mpc5200_setup_xlb_arbiter(void) */ if ((mfspr(SPRN_SVR) MPC5200_SVR_MASK) == MPC5200_SVR) out_be32(xlb-config, in_be32(xlb-config) | MPC52xx_XLB_CFG_PLDIS); +#if 0 + /* + * Enable pipelining, fixes FEC problems. The previous workaround is not + * needed, as we have an MPC5200B (not A). + */ + out_be32(xlb-config, in_be32(xlb-config) ~MPC52xx_XLB_CFG_PLDIS); +#endif iounmap(xlb); } -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | Wolfram, Thanks, but no luck with this patch. It was already setup correctly by U-Boot. I don't see where this gets enabled in the u-boot source. Have you added it locally? These are the only two I see: cpu/mpc5xxx/cpu_init.c: *(vu_long *)(MPC5XXX_XLBARB + 0x40) |= (1 13); cpu/mpc5xxx/cpu_init.c: *(vu_long *)(MPC5XXX_XLBARB + 0x40) |= (1 15); -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/pcm030.dts: add i2c eeprom and delete cruft
On Wed, May 20, 2009 at 4:07 AM, Wolfram Sang w.s...@pengutronix.de wrote: Add a node for the i2c eeprom and delete the superflous gpio-example. Signed-off-by: Wolfram Sang w.s...@pengutronix.de Cc: Grant Likely grant.lik...@secretlab.ca Cc: linuxppc-dev@ozlabs.org --- arch/powerpc/boot/dts/pcm030.dts | 26 -- 1 files changed, 4 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/boot/dts/pcm030.dts b/arch/powerpc/boot/dts/pcm030.dts index 8958347..33ce488 100644 --- a/arch/powerpc/boot/dts/pcm030.dts +++ b/arch/powerpc/boot/dts/pcm030.dts @@ -258,34 +258,16 @@ compatible = nxp,pcf8563; reg = 0x51; }; - /* FIXME: EEPROM */ + eep...@52 { + compatible = at24,24c32; + reg = 0x52; + }; Grant suggested this earlier... eep...@52 { compatible = atmel,24c32, eeprom; reg = 0x52; }; }; s...@8000 { compatible = fsl,mpc5200b-sram,fsl,mpc5200-sram; reg = 0x8000 0x4000; }; - - /* This is only an example device to show the usage of gpios. It maps all available - * gpios to the gpio-provider device. - */ - gpio { - compatible = gpio-provider; - - /* mpc52xx exp.con patchfield */ - gpios = gpio_wkup 0 0 /* GPIO_WKUP_7 11d jp13-3 */ - gpio_wkup 1 0 /* GPIO_WKUP_6 14c */ - gpio_wkup 6 0 /* PSC2_4 43c x5-11 */ - gpio_simple 2 0 /* IRDA_1 24c x7-6 set GPS_PORT_CONFIG[IRDA] = 0 */ - gpio_simple 3 0 /* IRDA_0 x8-5 set GPS_PORT_CONFIG[IRDA] = 0 */ - gpt2 0 0 /* timer2 12d x4-4 */ - gpt3 0 0 /* timer3 13d x6-4 */ - gpt4 0 0 /* timer4 61c x2-16 */ - gpt5 0 0 /* timer5 44c x7-11 */ - gpt6 0 0 /* timer6 60c x8-15 */ - gpt7 0 0 /* timer7 36a x17-9 */ - ; - }; }; ...@fd00 { -- 1.6.2 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/pcm030.dts: add i2c eeprom and delete cruft
On Wed, May 20, 2009 at 11:53 AM, Wolfram Sang w.s...@pengutronix.de wrote: - /* FIXME: EEPROM */ + eep...@52 { + compatible = at24,24c32; + reg = 0x52; + }; Grant suggested this earlier... eep...@52 { compatible = atmel,24c32, eeprom; reg = 0x52; }; Can you give me a pointer? I just found this thread Grant, what do you want here? http://ozlabs.org/pipermail/devicetree-discuss/2008-July/08.html but not the result you proposed. Regards, Wolfram -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoUJ4oACgkQD27XaX1/VRsSbwCgo1o//DG1wjKGR7BY1lkRxOAi 8kIAoJghKuhKMNBDXUhA4sWj/vRfDoDV =Bmoy -END PGP SIGNATURE- -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: mpc5200 fec error
On Wed, May 20, 2009 at 11:28 AM, Eric Millbrandt emillbra...@dekaresearch.com wrote: -Original Message- From: Jon Smirl [mailto:jonsm...@gmail.com] Sent: Wednesday, May 20, 2009 11:15 To: Eric Millbrandt Cc: Wolfram Sang; Grant Likely; linuxppc-dev@ozlabs.org Subject: Re: mpc5200 fec error On Wed, May 20, 2009 at 9:42 AM, Eric Millbrandt emillbra...@dekaresearch.com wrote: I am able to reproduce the error using 2.6.29.2-rt11. I was able to mitigate the problem by raising the priority of the transmit irq. However when running an NFS server on the pcm030 under high cpu load I now get [ 132.477503] net eth0: FEC_IEVENT_RFIFO_ERROR [ 132.892329] net eth0: FEC_IEVENT_RFIFO_ERROR [ 133.884109] net eth0: FEC_IEVENT_RFIFO_ERROR [ 134.876059] net eth0: FEC_IEVENT_RFIFO_ERROR Raising the priority of the rx irq does not seem to fix this problem though. Hi Eric, This error has been seen before in non-rt kernels. I haven't had the chance to track it down and kill it yet. I believe there are locking issues associated with it. Uuuh, I recall this message. Kept me busy for some time :( You might try this patch which helped in our situation. === Subject: Enable XLB pipelining for MPC5200B From: Wolfram Sang w.s...@pengutronix.de Enable pipelining as it helps getting rid of FEC problems. Not intended for upstream, this must be dealt differently there. This patch is disabled by default. The bootloader should enable this feature. So, this patch is only intended to be used where the bootloader does it in a wrong manner and can't be replaced. Signed-off-by: Wolfram Sang w.s...@pengutronix.de Acked-by: Juergen Beisert j.beis...@pengutronix.de --- arch/powerpc/platforms/52xx/mpc52xx_common.c | 7 +++ 1 file changed, 7 insertions(+) Index: arch/powerpc/platforms/52xx/mpc52xx_common.c === --- arch/powerpc/platforms/52xx/mpc52xx_common.c.orig +++ arch/powerpc/platforms/52xx/mpc52xx_common.c @@ -107,6 +107,13 @@ mpc5200_setup_xlb_arbiter(void) */ if ((mfspr(SPRN_SVR) MPC5200_SVR_MASK) == MPC5200_SVR) out_be32(xlb-config, in_be32(xlb-config) | MPC52xx_XLB_CFG_PLDIS); +#if 0 + /* + * Enable pipelining, fixes FEC problems. The previous workaround is not + * needed, as we have an MPC5200B (not A). + */ + out_be32(xlb-config, in_be32(xlb-config) ~MPC52xx_XLB_CFG_PLDIS); +#endif iounmap(xlb); } -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | Wolfram, Thanks, but no luck with this patch. It was already setup correctly by U-Boot. I don't see where this gets enabled in the u-boot source. Have you added it locally? These are the only two I see: cpu/mpc5xxx/cpu_init.c: *(vu_long *)(MPC5XXX_XLBARB + 0x40) |= (1 13); cpu/mpc5xxx/cpu_init.c: *(vu_long *)(MPC5XXX_XLBARB + 0x40) |= (1 15); -- Jon Smirl jonsm...@gmail.com If you look a few more lines down you should see # if defined(CFG_XLB_PIPELINING) /* Enable piplining */ *(vu_long *)(MPC5XXX_XLBARB + 0x40) = ~(1 31); # endif I obtained the u-boot sources directly from phytec, for my phyCore, so I am not sure if they added it. It is ok in main u-boot source. I just missed the lower section. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Using archaic I2C with OF
On Fri, May 1, 2009 at 9:04 AM, Gary Thomas g...@mlbassoc.com wrote: I'd like to use an existing I2C driver (a touchscreen device) with my 834x based platform. How do I arrange to provide platform data (i2c_client-dev.platform_data) from my OF world? It is easier to convert the i2c driver to work in the current model. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Using archaic I2C with OF
On Fri, May 1, 2009 at 10:39 AM, Jon Smirl jonsm...@gmail.com wrote: On Fri, May 1, 2009 at 9:04 AM, Gary Thomas g...@mlbassoc.com wrote: I'd like to use an existing I2C driver (a touchscreen device) with my 834x based platform. How do I arrange to provide platform data (i2c_client-dev.platform_data) from my OF world? It is easier to convert the i2c driver to work in the current model. All in-tree drivers have already been converted. -- Jon Smirl jonsm...@gmail.com -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Using archaic I2C with OF
On Fri, May 1, 2009 at 10:50 AM, Gary Thomas g...@mlbassoc.com wrote: Jon Smirl wrote: On Fri, May 1, 2009 at 10:39 AM, Jon Smirl jonsm...@gmail.com wrote: On Fri, May 1, 2009 at 9:04 AM, Gary Thomas g...@mlbassoc.com wrote: I'd like to use an existing I2C driver (a touchscreen device) with my 834x based platform. How do I arrange to provide platform data (i2c_client-dev.platform_data) from my OF world? It is easier to convert the i2c driver to work in the current model. All in-tree drivers have already been converted. I'm looking at drivers/input/touchscreen/tsc2007.c (the one I need) from Kumar's 'next' tree. It most definitely still uses the old model. Can you suggest another place to look? Post this on the i2c list. Jean has made an effort to convert all drivers. He must have missed that one. -- Gary Thomas | Consulting for the MLB Associates | Embedded world -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V1 0/3] Split the DMA core out from mpc5200_psc_i2s.c
Patch series to separate out the mpc5200 core DMA routines from mpc5200_psc_i2s.c into a standalone mpc5200_dma.c. No intention to change how anything works, this is just a code reorg needed for later patches to build on. --- Jon Smirl (3): Rename exports in mpc5200_dma.c Rename the PSC functions to DMA Basic split of mpc5200 DMA code out from mpc5200_psc_i2s sound/soc/fsl/Kconfig |4 sound/soc/fsl/Makefile |2 sound/soc/fsl/mpc5200_dma.c | 463 sound/soc/fsl/mpc5200_dma.h | 81 + sound/soc/fsl/mpc5200_psc_i2s.c | 644 +-- 5 files changed, 632 insertions(+), 562 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_dma.c create mode 100644 sound/soc/fsl/mpc5200_dma.h -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH V1 1/3] Basic split of mpc5200 DMA code out from mpc5200_psc_i2s
Basic split of mpc5200 DMA code out from i2s into a standalone file. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/Kconfig |4 sound/soc/fsl/Makefile |2 sound/soc/fsl/mpc5200_dma.c | 457 + sound/soc/fsl/mpc5200_dma.h | 81 +++ sound/soc/fsl/mpc5200_psc_i2s.c | 484 --- 5 files changed, 546 insertions(+), 482 deletions(-) create mode 100644 sound/soc/fsl/mpc5200_dma.c create mode 100644 sound/soc/fsl/mpc5200_dma.h diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 9fc9082..dc79bdf 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,5 +1,8 @@ config SND_SOC_OF_SIMPLE tristate + +config SND_MPC52xx_DMA + tristate # ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers # for the SSI and the Elo DMA controller. You will still need to select @@ -23,6 +26,7 @@ config SND_SOC_MPC5200_I2S tristate Freescale MPC5200 PSC in I2S mode driver depends on PPC_MPC52xx PPC_BESTCOMM select SND_SOC_OF_SIMPLE + select SND_MPC52xx_DMA select PPC_BESTCOMM_GEN_BD help Say Y here to support the MPC5200 PSCs in I2S mode. diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index f85134c..7731ef2 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -10,5 +10,7 @@ snd-soc-fsl-ssi-objs := fsl_ssi.o snd-soc-fsl-dma-objs := fsl_dma.o obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o +# MPC5200 Platform Support +obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c new file mode 100644 index 000..cccaff4 --- /dev/null +++ b/sound/soc/fsl/mpc5200_dma.c @@ -0,0 +1,457 @@ +/* + * Freescale MPC5200 PSC DMA + * ALSA SoC Platform driver + * + * Copyright (C) 2008 Secret Lab Technologies Ltd. + */ + +#include linux/init.h +#include linux/module.h +#include linux/interrupt.h +#include linux/device.h +#include linux/delay.h +#include linux/of_device.h +#include linux/of_platform.h +#include linux/dma-mapping.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/initval.h +#include sound/soc.h +#include sound/soc-of-simple.h + +#include sysdev/bestcomm/bestcomm.h +#include sysdev/bestcomm/gen_bd.h +#include asm/mpc52xx_psc.h + +#include mpc5200_dma.h + +MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca); +MODULE_DESCRIPTION(Freescale MPC5200 PSC in DMA mode ASoC Driver); +MODULE_LICENSE(GPL); + +/* + * Interrupt handlers + */ +static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) +{ + struct psc_i2s *psc_i2s = _psc_i2s; + struct mpc52xx_psc __iomem *regs = psc_i2s-psc_regs; + u16 isr; + + isr = in_be16(regs-mpc52xx_psc_isr); + + /* Playback underrun error */ + if (psc_i2s-playback.active (isr MPC52xx_PSC_IMR_TXEMP)) + psc_i2s-stats.underrun_count++; + + /* Capture overrun error */ + if (psc_i2s-capture.active (isr MPC52xx_PSC_IMR_ORERR)) + psc_i2s-stats.overrun_count++; + + out_8(regs-command, 4 4); /* reset the error status */ + + return IRQ_HANDLED; +} + +/** + * psc_i2s_bcom_enqueue_next_buffer - Enqueue another audio buffer + * @s: pointer to stream private data structure + * + * Enqueues another audio period buffer into the bestcomm queue. + * + * Note: The routine must only be called when there is space available in + * the queue. Otherwise the enqueue will fail and the audio ring buffer + * will get out of sync + */ +static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s) +{ + struct bcom_bd *bd; + + /* Prepare and enqueue the next buffer descriptor */ + bd = bcom_prepare_next_buffer(s-bcom_task); + bd-status = s-period_bytes; + bd-data[0] = s-period_next_pt; + bcom_submit_next_buffer(s-bcom_task, NULL); + + /* Update for next period */ + s-period_next_pt += s-period_bytes; + if (s-period_next_pt = s-period_end) + s-period_next_pt = s-period_start; +} + +/* Bestcomm DMA irq handler */ +static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) +{ + struct psc_i2s_stream *s = _psc_i2s_stream; + + /* For each finished period, dequeue the completed period buffer +* and enqueue a new one in it's place. */ + while (bcom_buffer_done(s-bcom_task)) { + bcom_retrieve_buffer(s-bcom_task, NULL, NULL); + s-period_current_pt += s-period_bytes; + if (s-period_current_pt = s-period_end) + s-period_current_pt = s-period_start; + psc_i2s_bcom_enqueue_next_buffer(s); + bcom_enable(s-bcom_task); + } + + /* If the stream is active, then also inform the PCM
[PATCH V1 3/3] Rename exports in mpc5200_dma.c
Rename the public DMA exports into the global name space so that the DMA code can be built as a module. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_dma.c | 18 -- sound/soc/fsl/mpc5200_dma.h | 10 +- sound/soc/fsl/mpc5200_psc_i2s.c | 14 +++--- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index c82ef75..df73755 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -113,7 +113,7 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) * If this is the first stream open, then grab the IRQ and program most of * the PSC registers. */ -int psc_dma_startup(struct snd_pcm_substream *substream, +int mpc5200_dma_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; @@ -145,13 +145,16 @@ int psc_dma_startup(struct snd_pcm_substream *substream, return 0; } +EXPORT_SYMBOL_GPL(mpc5200_dma_startup); -int psc_dma_hw_free(struct snd_pcm_substream *substream, +int mpc5200_dma_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { snd_pcm_set_runtime_buffer(substream, NULL); return 0; } +EXPORT_SYMBOL_GPL(mpc5200_dma_hw_free); + /** * psc_dma_trigger: start and stop the DMA transfer. @@ -159,7 +162,7 @@ int psc_dma_hw_free(struct snd_pcm_substream *substream, * This function is called by ALSA to start, stop, pause, and resume the DMA * transfer of data. */ -int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd, +int mpc5200_dma_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; @@ -269,13 +272,15 @@ int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd, return 0; } +EXPORT_SYMBOL_GPL(mpc5200_dma_trigger); + /** * psc_dma_shutdown: shutdown the data transfer on a stream * * Shutdown the PSC if there are no other substreams open. */ -void psc_dma_shutdown(struct snd_pcm_substream *substream, +void mpc5200_dma_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; @@ -303,6 +308,7 @@ void psc_dma_shutdown(struct snd_pcm_substream *substream, free_irq(psc_dma-playback.irq, psc_dma-playback); } } +EXPORT_SYMBOL_GPL(mpc5200_dma_shutdown); /* - * The PSC DMA 'ASoC platform' driver @@ -448,10 +454,10 @@ static void psc_dma_pcm_free(struct snd_pcm *pcm) } } -struct snd_soc_platform psc_dma_pcm_soc_platform = { +struct snd_soc_platform mpc5200_dma_platform = { .name = mpc5200-psc-audio, .pcm_ops= psc_dma_pcm_ops, .pcm_new= psc_dma_pcm_new, .pcm_free = psc_dma_pcm_free, }; - +EXPORT_SYMBOL_GPL(mpc5200_dma_platform); diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index a33232c..e52b90e 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -64,18 +64,18 @@ struct psc_dma { }; -int psc_dma_startup(struct snd_pcm_substream *substream, +int mpc5200_dma_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai); -int psc_dma_hw_free(struct snd_pcm_substream *substream, +int mpc5200_dma_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai); -void psc_dma_shutdown(struct snd_pcm_substream *substream, +void mpc5200_dma_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai); -int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd, +int mpc5200_dma_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai); -extern struct snd_soc_platform psc_dma_pcm_soc_platform; +extern struct snd_soc_platform mpc5200_dma_platform; #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */ diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c index 12a7917..a4a439c 100644 --- a/sound/soc/fsl/mpc5200_psc_i2s.c +++ b/sound/soc/fsl/mpc5200_psc_i2s.c @@ -140,11 +140,11 @@ static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format) * psc_i2s_dai_template: template CPU Digital Audio Interface */ static struct snd_soc_dai_ops psc_i2s_dai_ops = { - .startup= psc_dma_startup, + .startup= mpc5200_dma_startup, .hw_params = psc_i2s_hw_params, - .hw_free= psc_dma_hw_free, - .shutdown = psc_dma_shutdown, - .trigger= psc_dma_trigger, + .hw_free= mpc5200_dma_hw_free
[PATCH V1 2/3] Rename the PSC functions to DMA
Rename the functions in the mpc5200 DMA file from i2s to dma to reflect the file they are in. Signed-off-by: Jon Smirl jonsm...@gmail.com --- sound/soc/fsl/mpc5200_dma.c | 194 --- sound/soc/fsl/mpc5200_dma.h | 26 +++-- sound/soc/fsl/mpc5200_psc_i2s.c | 160 3 files changed, 190 insertions(+), 190 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index cccaff4..c82ef75 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -34,21 +34,21 @@ MODULE_LICENSE(GPL); /* * Interrupt handlers */ -static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) +static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma) { - struct psc_i2s *psc_i2s = _psc_i2s; - struct mpc52xx_psc __iomem *regs = psc_i2s-psc_regs; + struct psc_dma *psc_dma = _psc_dma; + struct mpc52xx_psc __iomem *regs = psc_dma-psc_regs; u16 isr; isr = in_be16(regs-mpc52xx_psc_isr); /* Playback underrun error */ - if (psc_i2s-playback.active (isr MPC52xx_PSC_IMR_TXEMP)) - psc_i2s-stats.underrun_count++; + if (psc_dma-playback.active (isr MPC52xx_PSC_IMR_TXEMP)) + psc_dma-stats.underrun_count++; /* Capture overrun error */ - if (psc_i2s-capture.active (isr MPC52xx_PSC_IMR_ORERR)) - psc_i2s-stats.overrun_count++; + if (psc_dma-capture.active (isr MPC52xx_PSC_IMR_ORERR)) + psc_dma-stats.overrun_count++; out_8(regs-command, 4 4); /* reset the error status */ @@ -56,7 +56,7 @@ static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) } /** - * psc_i2s_bcom_enqueue_next_buffer - Enqueue another audio buffer + * psc_dma_bcom_enqueue_next_buffer - Enqueue another audio buffer * @s: pointer to stream private data structure * * Enqueues another audio period buffer into the bestcomm queue. @@ -65,7 +65,7 @@ static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) * the queue. Otherwise the enqueue will fail and the audio ring buffer * will get out of sync */ -static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s) +static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) { struct bcom_bd *bd; @@ -82,9 +82,9 @@ static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s) } /* Bestcomm DMA irq handler */ -static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) +static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) { - struct psc_i2s_stream *s = _psc_i2s_stream; + struct psc_dma_stream *s = _psc_dma_stream; /* For each finished period, dequeue the completed period buffer * and enqueue a new one in it's place. */ @@ -93,7 +93,7 @@ static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) s-period_current_pt += s-period_bytes; if (s-period_current_pt = s-period_end) s-period_current_pt = s-period_start; - psc_i2s_bcom_enqueue_next_buffer(s); + psc_dma_bcom_enqueue_next_buffer(s); bcom_enable(s-bcom_task); } @@ -106,39 +106,39 @@ static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) } /** - * psc_i2s_startup: create a new substream + * psc_dma_startup: create a new substream * * This is the first function called when a stream is opened. * * If this is the first stream open, then grab the IRQ and program most of * the PSC registers. */ -int psc_i2s_startup(struct snd_pcm_substream *substream, +int psc_dma_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; - struct psc_i2s *psc_i2s = rtd-dai-cpu_dai-private_data; + struct psc_dma *psc_dma = rtd-dai-cpu_dai-private_data; int rc; - dev_dbg(psc_i2s-dev, psc_i2s_startup(substream=%p)\n, substream); + dev_dbg(psc_dma-dev, psc_dma_startup(substream=%p)\n, substream); - if (!psc_i2s-playback.active - !psc_i2s-capture.active) { + if (!psc_dma-playback.active + !psc_dma-capture.active) { /* Setup the IRQs */ - rc = request_irq(psc_i2s-irq, psc_i2s_status_irq, IRQF_SHARED, -psc-i2s-status, psc_i2s); - rc |= request_irq(psc_i2s-capture.irq, - psc_i2s_bcom_irq, IRQF_SHARED, - psc-i2s-capture, psc_i2s-capture); - rc |= request_irq(psc_i2s-playback.irq, - psc_i2s_bcom_irq, IRQF_SHARED, - psc-i2s-playback, psc_i2s-playback); + rc = request_irq(psc_dma-irq, psc_dma_status_irq, IRQF_SHARED, +psc
Re: [PATCH V1 3/3] Rename exports in mpc5200_dma.c
On Mon, Apr 27, 2009 at 12:08 AM, Grant Likely grant.lik...@secretlab.ca wrote: On Sun, Apr 26, 2009 at 1:53 PM, Jon Smirl jonsm...@gmail.com wrote: Rename the public DMA exports into the global name space so that the DMA code can be built as a module. Signed-off-by: Jon Smirl jonsm...@gmail.com Nack. mpc5200_dma is too generic for the global namespace... (in fact, I should also relook at the previous patch; I might need to nack my ack). Some variant of 'mpc5200_psc_snd_dma' would be more appropriate. Even mpc5200_psc_dma is too generic because other non-sound PSC modes can use DMA also. I'll change it to mpc5200_audio_dma and resend this to the series to the alsa list. Does your stuff still work with these patches? I want to get these mechanical changes in so we can focus on the real changes in my later patches. g. --- sound/soc/fsl/mpc5200_dma.c | 18 -- sound/soc/fsl/mpc5200_dma.h | 10 +- sound/soc/fsl/mpc5200_psc_i2s.c | 14 +++--- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index c82ef75..df73755 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -113,7 +113,7 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) * If this is the first stream open, then grab the IRQ and program most of * the PSC registers. */ -int psc_dma_startup(struct snd_pcm_substream *substream, +int mpc5200_dma_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; @@ -145,13 +145,16 @@ int psc_dma_startup(struct snd_pcm_substream *substream, return 0; } +EXPORT_SYMBOL_GPL(mpc5200_dma_startup); -int psc_dma_hw_free(struct snd_pcm_substream *substream, +int mpc5200_dma_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { snd_pcm_set_runtime_buffer(substream, NULL); return 0; } +EXPORT_SYMBOL_GPL(mpc5200_dma_hw_free); + /** * psc_dma_trigger: start and stop the DMA transfer. @@ -159,7 +162,7 @@ int psc_dma_hw_free(struct snd_pcm_substream *substream, * This function is called by ALSA to start, stop, pause, and resume the DMA * transfer of data. */ -int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd, +int mpc5200_dma_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; @@ -269,13 +272,15 @@ int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd, return 0; } +EXPORT_SYMBOL_GPL(mpc5200_dma_trigger); + /** * psc_dma_shutdown: shutdown the data transfer on a stream * * Shutdown the PSC if there are no other substreams open. */ -void psc_dma_shutdown(struct snd_pcm_substream *substream, +void mpc5200_dma_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream-private_data; @@ -303,6 +308,7 @@ void psc_dma_shutdown(struct snd_pcm_substream *substream, free_irq(psc_dma-playback.irq, psc_dma-playback); } } +EXPORT_SYMBOL_GPL(mpc5200_dma_shutdown); /* - * The PSC DMA 'ASoC platform' driver @@ -448,10 +454,10 @@ static void psc_dma_pcm_free(struct snd_pcm *pcm) } } -struct snd_soc_platform psc_dma_pcm_soc_platform = { +struct snd_soc_platform mpc5200_dma_platform = { .name = mpc5200-psc-audio, .pcm_ops = psc_dma_pcm_ops, .pcm_new = psc_dma_pcm_new, .pcm_free = psc_dma_pcm_free, }; - +EXPORT_SYMBOL_GPL(mpc5200_dma_platform); diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index a33232c..e52b90e 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -64,18 +64,18 @@ struct psc_dma { }; -int psc_dma_startup(struct snd_pcm_substream *substream, +int mpc5200_dma_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai); -int psc_dma_hw_free(struct snd_pcm_substream *substream, +int mpc5200_dma_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai); -void psc_dma_shutdown(struct snd_pcm_substream *substream, +void mpc5200_dma_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai); -int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd, +int mpc5200_dma_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai); -extern struct snd_soc_platform psc_dma_pcm_soc_platform; +extern struct snd_soc_platform mpc5200_dma_platform; #endif
mpc5200 and dma_ops
Inside the ASoC code there a dma_alloc_coherent() call. This call is failing because dma_ops is null. --kernel BUG at /home/jonsmirl/fs/arch/powerpc/include/asm/dma-mapping.h:237! The device is soc-audio which is a platform_device. How do I get dma_ops filled in for a mpc5200 platform device? -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: mpc5200 and dma_ops
On Fri, Apr 17, 2009 at 8:58 PM, Jon Smirl jonsm...@gmail.com wrote: Inside the ASoC code there a dma_alloc_coherent() call. This call is failing because dma_ops is null. --kernel BUG at /home/jonsmirl/fs/arch/powerpc/include/asm/dma-mapping.h:237! The device is soc-audio which is a platform_device. How do I get dma_ops filled in for a mpc5200 platform device? That was a wild goose chase. If the device pointer is null it will trigger this bug_on() which has nothing to do with the real problem. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [RFC 1/2] powerpc/5200: add general purpose timer API for the MPC5200
I'm using a GPT pin in input capture mode to implement IR. I attached my GPT driver code. I can convert to your API. That's a really cheap way to do IR, just IR sensor, resistor and a cap. I also have an in-kernel IR system but Christoph (lirc maintainer) won't consider it. He is a microkernel type - he wants everything in user space. My in-kernel version is tiny, less than 10K. It turns IR events into keystrokes on a virtual keyboard device. This is my old device tree, what should the new one look like? i...@670 { /* General Purpose Timer 6 in Input mode */ compatible = gpt-ir; cell-index = 7; reg = 0x670 0x10; interrupts = 0x1 0x10 0x0; interrupt-parent = mpc5200_pic; }; -- Jon Smirl jonsm...@gmail.com jds-lirc-gpt Description: Binary data ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/mpc52xx: add Phytec phyCORE-MPC5200B-IO board (pcm032)
On Tue, Mar 3, 2009 at 3:12 AM, Robert Schwebel r.schwe...@pengutronix.de wrote: On Sun, Mar 01, 2009 at 09:33:16PM -0700, Grant Likely wrote: On Sun, Mar 1, 2009 at 7:19 PM, Jon Smirl jonsm...@gmail.com wrote: Would it be easier to get Pengutronix to release a new u-boot for the pcm030? I'm using U-Boot 1.2.0-mpc5200b-tiny-2 (Apr 17 2007 - 11:49:20). Only if it is a chip IO setup problem (like port_config or clock setup). Otherwise the kernel should be setting up the PCI controller correctly. Regardless, I don't think the kernel should be crashing when PCI is in a funny state. Ack; I didn't follow the thread in detail, but if possible I'd like to avoid bootloader updates; it's quite a lot of effort because there are thousends of devices in the field, not to mention the whole qualification mechanics at Phytec. On a pcm030 1245-1 u-boot-1.2.0-mpc5200b-tiny-3, boots ok and PCI is initialized correctly. The readme is not clear that tiny-3 should be used on 1245.1 hardware. http://www.pengutronix.de/oselas/bsp/phytec/download/phyCORE-MPC5200B-tiny/Readme This phrase implies the tiny-3 should only be used on 1245.2 hardware. U-Boot binary to be used with OSELAS.BSP-Phytec-phyCORE-MPC5200B-tiny-6 (board revision 1245.2) Where is the difference between the 1245.0, 1245.1 and 1245.2 hardware documented? Wolfram can check the issue when being back in the office. rsc -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/mpc52xx: add Phytec phyCORE-MPC5200B-IO board (pcm032)
On Sun, Mar 1, 2009 at 9:48 AM, Grant Likely grant.lik...@secretlab.ca wrote: On Sun, Mar 1, 2009 at 3:18 AM, Wolfram Sang w.s...@pengutronix.de wrote: Hi Grant, thanks for the review! On Thu, Feb 26, 2009 at 10:31:24PM -0700, Grant Likely wrote: Thanks for the patch Wolfram. Comments below. On Wed, Feb 25, 2009 at 8:32 AM, Wolfram Sang w.s...@pengutronix.de wrote: Signed-off-by: Wolfram Sang w.s...@pengutronix.de --- arch/powerpc/boot/dts/pcm032.dts | 391 +++ arch/powerpc/configs/52xx/pcm032_defconfig | 1394 ++ Do you really need a separate defconfig for this board? Can it be merged with an existing defconfig? Will have a look if I can make a pcm03x_defconfig out of pcm030_defconfig. Cool, thanks. motionpro.dts is a good example of what it should look like. Ah, thanks for the pointer. Will have a look there. Guess I'll need to update pcm030.dts later, too (from which I copied this one). Will rewrite the localbus-node addressing the comments you gave. pcm030.dts in mainline doesn't have a localbus node. I've been using this on my pcm030 locally. pcm030 doesn't have a PCI socket but it can be added via the expansion bus. With just the basic pcm030 hardware, if I uncomment the pci node I sometimes hang on boot. l...@ff00 { compatible = fsl,lpb, simple-bus; #address-cells = 2; #size-cells = 1; ranges = 0 0 0xff00 0x0100; fl...@0 { compatible = cfi-flash; reg = 0 0 0x0100; bank-width = 2; device-width = 2; #size-cells = 1; #address-cells = 1; partit...@0 { label = ubootl; reg = 0x 0x0004; }; partit...@4 { label = kernel; reg = 0x0004 0x001c; }; partit...@20 { label = jffs2; reg = 0x0020 0x00D0; }; partit...@f0 { label = uboot; reg = 0x00f0 0x0004; }; partit...@f4 { label = oftree; reg = 0x00f4 0x0004; }; partit...@f8 { label = space; reg = 0x00f8 0x0008; }; }; }; /* p...@fd00 { #interrupt-cells = 1; #size-cells = 2; #address-cells = 3; device_type = pci; compatible = fsl,mpc5200b-pci,fsl,mpc5200-pci; reg = 0xfd00 0x100; interrupt-map-mask = 0xf800 0x0 0x0 0x7; interrupt-map = 0xc000 0x0 0x0 0x1 mpc5200_pic 0x0 0x0 0x3 / 1st slot / 0xc000 0x0 0x0 0x2 mpc5200_pic 0x1 0x1 0x3 0xc000 0x0 0x0 0x3 mpc5200_pic 0x1 0x2 0x3 0xc000 0x0 0x0 0x4 mpc5200_pic 0x1 0x3 0x3 0xc800 0x0 0x0 0x1 mpc5200_pic 0x1 0x1 0x3 / 2nd slot / 0xc800 0x0 0x0 0x2 mpc5200_pic 0x1 0x2 0x3 0xc800 0x0 0x0 0x3 mpc5200_pic 0x1 0x3 0x3 0xc800 0x0 0x0 0x4 mpc5200_pic 0x0 0x0 0x3; clock-frequency = 0; // From boot loader interrupts = 0x2 0x8 0x0 0x2 0x9 0x0 0x2 0xa 0x0; interrupt-parent = mpc5200_pic; bus-range = 0 0; ranges = 0x4200 0x0 0x8000 0x8000 0x0 0x2000 0x0200 0x0 0xa000 0xa000 0x0 0x1000 0x0100 0x0 0x 0xb000 0x0 0x0100; }; */ g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/mpc52xx: add Phytec phyCORE-MPC5200B-IO board (pcm032)
On Sun, Mar 1, 2009 at 7:37 PM, Jon Smirl jonsm...@gmail.com wrote: Just tried it on pcm030. If I uncomment the reg line the kernel won't boot at all. I don't get any output. I hooked up a serial console instead of netcat. ## Booting image at 0050 ... Image Name: Linux-2.6.29-rc6-efika Created: 2009-03-02 0:28:31 UTC Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size:1776985 Bytes = 1.7 MB Load Address: Entry Point: Verifying Checksum ... OK Uncompressing Kernel Image ... OK Booting using flat device tree at 0x40 Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) Memory: 61028k/65536k available (3520k kernel code, 4448k reserved, 156k data, 122k bss, 168k init) SLUB: Genslabs=12, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 Calibrating delay loop... 66.28 BogoMIPS (lpj=110848) Mount-cache hash table entries: 512 net_namespace: 296 bytes NET: Registered protocol family 16 PCI: Probing PCI hardware PCI: Scanning bus :00 Machine check in kernel mode. Caused by (from SRR1=41030): Transfer error ack signal Oops: Machine check, sig: 7 [#1] dspeak01 Modules linked in: NIP: c001be94 LR: c0158cb4 CTR: c001be04 REGS: c3823de0 TRAP: 0200 Not tainted (2.6.29-rc6-efika) MSR: 00041030 ME,IR,DR CR: 2822 XER: 2000 TASK = c3824000[1] 'swapper' THREAD: c3822000 GPR00: 8000 c3823e90 c3824000 c3856000 0004 c3823eb8 GPR08: c03a9848 fcffc000 08bc 0020213c 8222 ffef 03ffe000 GPR16: 0001 007ffc00 03ff8838 0004 GPR24: c3823eb8 0004 c03c c3856000 NIP [c001be94] mpc52xx_pci_read_config+0x90/0xec LR [c0158cb4] pci_bus_read_config_dword+0x4c/0x74 Call Trace: [c3823e90] [c0091238] ifind+0x18/0x6c (unreliable) [c3823eb0] [c0158cb4] pci_bus_read_config_dword+0x4c/0x74 [c3823ee0] [c0278a90] pci_scan_single_device+0x24/0x4b0 [c3823f10] [c0159d50] pci_scan_slot+0x2c/0x84 [c3823f30] [c027b2d4] pci_scan_child_bus+0x40/0x108 [c3823f50] [c0351c34] pcibios_init+0xdc/0x190 [c3823f70] [c00038f4] do_one_initcall+0x58/0x19c [c3823fe0] [c034614c] kernel_init+0x74/0xe0 [c3823ff0] [c00133d4] kernel_thread+0x4c/0x68 Instruction dump: 817e0040 5400801e 7c004b78 5769063a 64008000 7d290378 7c0004ac 912b 7c0004ac 813e0044 7c0004ac 7d604c2c 0c0b 4c00012c 2f9c0004 57601ef8 ---[ end trace 31fd0ba7d8756001 ]--- Kernel panic - not syncing: Attempted to kill init! Rebooting in 180 seconds.. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/mpc52xx: add Phytec phyCORE-MPC5200B-IO board (pcm032)
=0x0,size=0x2,blocks=128 Searching for RedBoot partition table in ff00.flash at offset 0xfe No RedBoot partition table detected in ff00.flash Creating 6 MTD partitions on ff00.flash: 0x-0x0004 : ubootl 0x0004-0x0020 : kernel 0x0020-0x00f0 : jffs2 0x00f0-0x00f4 : uboot 0x00f4-0x00f8 : oftree 0x00f8-0x0100 : space mpc52xx-spi ff00.spi: mode fault; is port_config correct? mpc52xx-spi: probe of ff00.spi failed with error -5 ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver ppc-of-ohci f0001000.usb: OF OHCI ppc-of-ohci f0001000.usb: new USB bus registered, assigned bus number 1 ppc-of-ohci f0001000.usb: irq 134, io mem 0xf0001000 usb usb1: configuration #1 chosen from 1 choice hub 1-0:1.0: USB hub found hub 1-0:1.0: 2 ports detected ir-gpt f670.ir0: ir_gpt_of_probe input: GPT IR Receiver as /class/input/input0 evbug.c: Connected device: input0 (GPT IR Receiver at unknown) ir-gpt f670.ir0: ir_gpt_of_probe irq=80 ir-gpt f670.ir0: ir_gpt_of_probe request irq rc=0 GPT IR Receiver driver usbcore: registered new interface driver ir_mceusb2 rtc-pcf8563 1-0051: chip found, driver version 0.4.3 rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc0 at24 1-0052: 4096 byte 24c32 EEPROM (writable) usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver Advanced Linux Sound Architecture Driver Version 1.0.18a. tas5504 0-001b: probing tas5504 i2c device registering ASoC codec driver: /soc5...@f000/i...@3d00/co...@1b tas5504 0-001b: I2C device initialized registering ASoC platform driver: /soc5...@f000/i...@2200 looking for codec: /soc5...@f000/i...@3d00/co...@1b platform--codec match achieved; registering machine ALSA device list: No soundcards found. TCP cubic registered NET: Registered protocol family 17 RPC: Registered udp transport module. RPC: Registered tcp transport module. rtc-pcf8563 1-0051: low voltage detected, date/time is not reliable. rtc-pcf8563 1-0051: retrieved date/time is not valid. rtc-pcf8563 1-0051: hctosys: invalid date/time Sending DHCP requests ., OK IP-Config: Got DHCP answer from 192.168.1.1, my address is 192.168.1.11 IP-Config: Complete: device=eth0, addr=192.168.1.11, mask=255.255.255.0, gw=192.168.1.1, host=Phytec, domain=is-a-geek.net, nis-domain=(none), bootserver=192.168.1.1, rootserver=192.168.1.4, rootpath= Looking up port of RPC 13/3 on 192.168.1.4 Looking up port of RPC 15/3 on 192.168.1.4 VFS: Mounted root (nfs filesystem) on device 0:15. Freeing unused kernel memory: 168k init rtc-pcf8563 1-0051: low voltage detected, date/time is not reliable. rtc-pcf8563 1-0051: retrieved date/time is not valid. IRQ 131/mpc52xx_psc_uart: IRQF_DISABLED is not guaranteed on shared IRQs -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/mpc52xx: add Phytec phyCORE-MPC5200B-IO board (pcm032)
On Sun, Mar 1, 2009 at 8:07 PM, Grant Likely grant.lik...@secretlab.ca wrote: On Sun, Mar 1, 2009 at 5:46 PM, Jon Smirl jonsm...@gmail.com wrote: On Sun, Mar 1, 2009 at 7:37 PM, Jon Smirl jonsm...@gmail.com wrote: Just tried it on pcm030. If I uncomment the reg line the kernel won't boot at all. I don't get any output. I hooked up a serial console instead of netcat. PCI: Probing PCI hardware PCI: Scanning bus :00 Machine check in kernel mode. Caused by (from SRR1=41030): Transfer error ack signal Oops: Machine check, sig: 7 [#1] dspeak01 Yeah, there current PCI driver in mainline expects the bootloader to set stuff up for PCI to work. I've fixed some of it, and the fix is queued up in Ben's -next tree. Can you try Ben's -next tree? with benh-next... Bytes transferred = 7681 (1e01 hex) ## Booting image at 0050 ... Image Name: Linux-2.6.29-rc5-efika Created: 2009-03-02 2:13:17 UTC Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size:1778436 Bytes = 1.7 MB Load Address: Entry Point: Verifying Checksum ... OK Uncompressing Kernel Image ... OK Booting using flat device tree at 0x40 Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) Memory: 61028k/65536k available (3524k kernel code, 4448k reserved, 156k data, 122k bss, 168k init) SLUB: Genslabs=12, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 Calibrating delay loop... 66.28 BogoMIPS (lpj=110848) Mount-cache hash table entries: 512 net_namespace: 296 bytes NET: Registered protocol family 16 PCI: Probing PCI hardware PCI: Scanning bus :00 long pause Machine check in kernel mode. Caused by (from SRR1=41030): Transfer error ack signal Oops: Machine check, sig: 7 [#1] dspeak01 Modules linked in: NIP: c001c3bc LR: c0158ed0 CTR: c001c32c REGS: c3823de0 TRAP: 0200 Not tainted (2.6.29-rc5-efika) MSR: 00041030 ME,IR,DR CR: 2822 XER: 2000 TASK = c3824000[1] 'swapper' THREAD: c3822000 GPR00: 8000 c3823e90 c3824000 c3856000 0004 c3823eb8 GPR08: c03a9848 fcffc000 08bc 0020213c 8222 ffef 03ffe000 GPR16: 0001 007ffc00 03ff8838 0004 GPR24: c3823eb8 0004 c03c c3856000 NIP [c001c3bc] mpc52xx_pci_read_config+0x90/0xec LR [c0158ed0] pci_bus_read_config_dword+0x4c/0x74 Call Trace: [c3823e90] [c00915dc] ifind+0x18/0x6c (unreliable) [c3823eb0] [c0158ed0] pci_bus_read_config_dword+0x4c/0x74 [c3823ee0] [c0279090] pci_scan_single_device+0x24/0x4b0 [c3823f10] [c0159f6c] pci_scan_slot+0x2c/0x84 [c3823f30] [c027bae8] pci_scan_child_bus+0x40/0x108 [c3823f50] [c0352c44] pcibios_init+0xdc/0x190 [c3823f70] [c00038f4] do_one_initcall+0x58/0x19c [c3823fe0] [c034714c] kernel_init+0x74/0xe0 [c3823ff0] [c00133d4] kernel_thread+0x4c/0x68 Instruction dump: 817e0040 5400801e 7c004b78 5769063a 64008000 7d290378 7c0004ac 912b 7c0004ac 813e0044 7c0004ac 7d604c2c 0c0b 4c00012c 2f9c0004 57601ef8 ---[ end trace 31fd0ba7d8756001 ]--- Kernel panic - not syncing: Attempted to kill init! Rebooting in 180 seconds.. Thanks, g. Modules linked in: NIP: c001be94 LR: c0158cb4 CTR: c001be04 REGS: c3823de0 TRAP: 0200 Not tainted (2.6.29-rc6-efika) MSR: 00041030 ME,IR,DR CR: 2822 XER: 2000 TASK = c3824000[1] 'swapper' THREAD: c3822000 GPR00: 8000 c3823e90 c3824000 c3856000 0004 c3823eb8 GPR08: c03a9848 fcffc000 08bc 0020213c 8222 ffef 03ffe000 GPR16: 0001 007ffc00 03ff8838 0004 GPR24: c3823eb8 0004 c03c c3856000 NIP [c001be94] mpc52xx_pci_read_config+0x90/0xec LR [c0158cb4] pci_bus_read_config_dword+0x4c/0x74 Call Trace: [c3823e90] [c0091238] ifind+0x18/0x6c (unreliable) [c3823eb0] [c0158cb4] pci_bus_read_config_dword+0x4c/0x74 [c3823ee0] [c0278a90] pci_scan_single_device+0x24/0x4b0 [c3823f10] [c0159d50] pci_scan_slot+0x2c/0x84 [c3823f30] [c027b2d4] pci_scan_child_bus+0x40/0x108 [c3823f50] [c0351c34] pcibios_init+0xdc/0x190 [c3823f70] [c00038f4] do_one_initcall+0x58/0x19c [c3823fe0] [c034614c] kernel_init+0x74/0xe0 [c3823ff0] [c00133d4] kernel_thread+0x4c/0x68 Instruction dump: 817e0040 5400801e 7c004b78 5769063a 64008000 7d290378 7c0004ac 912b 7c0004ac 813e0044 7c0004ac 7d604c2c 0c0b 4c00012c 2f9c0004 57601ef8 ---[ end trace 31fd0ba7d8756001 ]--- Kernel panic - not syncing: Attempted to kill init! Rebooting in 180 seconds.. -- Jon Smirl jonsm...@gmail.com -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- Jon Smirl jonsm...@gmail.com ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev