public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: linux-omap@vger.kernel.org
Cc: Felipe Balbi <me@felipebalbi.com>,
	Ragner Magalhaes <ragner.magalhaes@indt.org.br>,
	Eduardo Valentin <eduardo.valentin@indt.org.br>
Subject: [PATCH 01/19] Update audio driver for H2 board
Date: Fri, 18 Apr 2008 04:00:48 -0400	[thread overview]
Message-ID: <1208505666-13744-2-git-send-email-edubezval@gmail.com> (raw)
In-Reply-To: <1208505666-13744-1-git-send-email-edubezval@gmail.com>

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

This patch updates the audio driver based on tsc2101 chip
for H2 board. tsc2101 driver was updated against new spi
framework, but its audio driver for H2 wasn't.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 arch/arm/mach-omap1/board-h2.c           |   71 +++++++++++++++---------------
 sound/arm/omap/omap-alsa-tsc2101-mixer.c |    7 ++-
 sound/arm/omap/omap-alsa-tsc2101-mixer.h |    2 +
 sound/arm/omap/omap-alsa-tsc2101.c       |   28 ++++++++++--
 sound/arm/omap/omap-alsa-tsc2101.h       |    5 ++
 5 files changed, 70 insertions(+), 43 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index aa1f8af..4f8e6da 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -320,6 +320,40 @@ static void h2_lcd_dev_init(struct spi_device *tsc2101)
 	platform_device_register(&h2_lcd_device);
 }
 
+static struct omap_mcbsp_reg_cfg mcbsp_regs = {
+	.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
+	.spcr1 = RINTM(3) | RRST,
+	.rcr2  = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
+			RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
+	.rcr1  = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
+	.xcr2  = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
+			XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
+	.xcr1  = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
+	.srgr1 = FWID(15),
+	.srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
+	.pcr0  = CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
+	/*.pcr0 = CLKXP | CLKRP,*/        /* mcbsp: slave */
+};
+
+static struct omap_alsa_codec_config alsa_config = {
+	.name                   = "H2 TSC2101",
+	.mcbsp_regs_alsa        = &mcbsp_regs,
+};
+
+static struct platform_device h2_mcbsp1_device = {
+	.name	= "omap_alsa_mcbsp",
+	.id	= 1,
+	.dev = {
+		.platform_data	= &alsa_config,
+	},
+};
+
+static void h2_audio_dev_init(struct spi_device *tsc2101)
+{
+	h2_mcbsp1_device.dev.platform_data = tsc2101;
+	platform_device_register(&h2_mcbsp1_device);
+}
+
 static int h2_tsc2101_init(struct spi_device *spi)
 {
 	int r;
@@ -344,6 +378,7 @@ static int h2_tsc2101_init(struct spi_device *spi)
 	omap_cfg_reg(N15_1610_UWIRE_CS1);
 
 	h2_lcd_dev_init(spi);
+	h2_audio_dev_init(spi);
 
 	return 0;
 err:
@@ -386,48 +421,12 @@ static struct spi_board_info h2_spi_board_info[] __initdata = {
 	},
 };
 
-static struct omap_mcbsp_reg_cfg mcbsp_regs = {
-	.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
-	.spcr1 = RINTM(3) | RRST,
-	.rcr2  = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
-                RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
-	.rcr1  = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
-	.xcr2  = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
-                XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
-	.xcr1  = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
-	.srgr1 = FWID(15),
-	.srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
-
-	.pcr0  = CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
-	/*.pcr0 = CLKXP | CLKRP,*/        /* mcbsp: slave */
-};
-
-static struct omap_alsa_codec_config alsa_config = {
-	.name                   = "H2 TSC2101",
-	.mcbsp_regs_alsa        = &mcbsp_regs,
-	.codec_configure_dev    = NULL, /* tsc2101_configure, */
-	.codec_set_samplerate   = NULL, /* tsc2101_set_samplerate, */
-	.codec_clock_setup      = NULL, /* tsc2101_clock_setup, */
-	.codec_clock_on         = NULL, /* tsc2101_clock_on, */
-	.codec_clock_off        = NULL, /* tsc2101_clock_off, */
-	.get_default_samplerate = NULL, /* tsc2101_get_default_samplerate, */
-};
-
-static struct platform_device h2_mcbsp1_device = {
-	.name	= "omap_alsa_mcbsp",
-	.id	= 1,
-	.dev = {
-		.platform_data	= &alsa_config,
-	},
-};
-
 static struct platform_device *h2_devices[] __initdata = {
 	&h2_nor_device,
 	&h2_nand_device,
 	&h2_smc91x_device,
 	&h2_irda_device,
 	&h2_kp_device,
-	&h2_mcbsp1_device,
 };
 
 static void __init h2_init_smc91x(void)
diff --git a/sound/arm/omap/omap-alsa-tsc2101-mixer.c b/sound/arm/omap/omap-alsa-tsc2101-mixer.c
index 8faba95..09257d7 100644
--- a/sound/arm/omap/omap-alsa-tsc2101-mixer.c
+++ b/sound/arm/omap/omap-alsa-tsc2101-mixer.c
@@ -43,6 +43,7 @@
 #include "omap-alsa-tsc2101.h"
 #include "omap-alsa-tsc2101-mixer.h"
 
+#include <linux/spi/tsc2101.h>
 #include <linux/types.h>
 #include <sound/initval.h>
 #include <sound/control.h>
@@ -68,7 +69,8 @@ static int current_rec_src 		= REC_SRC_SINGLE_ENDED_MICIN_HED;
  */
 inline void omap_tsc2101_audio_write(u8 address, u16 data)
 {
-	omap_tsc2101_write(PAGE2_AUDIO_CODEC_REGISTERS, address, data);
+	tsc2101_write_sync(mcbsp_dev.tsc2101_dev, PAGE2_AUDIO_CODEC_REGISTERS,
+				address, data);
 }
 
 /* 
@@ -76,7 +78,8 @@ inline void omap_tsc2101_audio_write(u8 address, u16 data)
  */
 inline u16 omap_tsc2101_audio_read(u8 address)
 {
-	return (omap_tsc2101_read(PAGE2_AUDIO_CODEC_REGISTERS, address));
+	return (tsc2101_read_sync(mcbsp_dev.tsc2101_dev,
+					PAGE2_AUDIO_CODEC_REGISTERS, address));
 }
 
 /*
diff --git a/sound/arm/omap/omap-alsa-tsc2101-mixer.h b/sound/arm/omap/omap-alsa-tsc2101-mixer.h
index 513614c..b110b36 100644
--- a/sound/arm/omap/omap-alsa-tsc2101-mixer.h
+++ b/sound/arm/omap/omap-alsa-tsc2101-mixer.h
@@ -76,4 +76,6 @@
 
 #define TSC2101_AUDIO_CODEC_REGISTERS_PAGE2     (2)
 
+extern struct mcbsp_dev_info mcbsp_dev;
+
 #endif /*OMAPALSATSC2101MIXER_H_*/
diff --git a/sound/arm/omap/omap-alsa-tsc2101.c b/sound/arm/omap/omap-alsa-tsc2101.c
index 88ed046..1d8adc1 100644
--- a/sound/arm/omap/omap-alsa-tsc2101.c
+++ b/sound/arm/omap/omap-alsa-tsc2101.c
@@ -22,6 +22,7 @@
 #include <linux/soundcard.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/spi/tsc2101.h>
 #include <asm/io.h>
 #include <asm/arch/mcbsp.h>
 
@@ -38,6 +39,8 @@
 #include <asm/arch/omap-alsa.h>
 #include "omap-alsa-tsc2101.h"
 
+struct mcbsp_dev_info mcbsp_dev;
+
 static struct clk *tsc2101_mclk = 0;
 
 //#define DUMP_TSC2101_AUDIO_REGISTERS
@@ -143,7 +146,8 @@ static struct snd_pcm_hardware tsc2101_snd_omap_alsa_capture = {
  */
 inline void tsc2101_audio_write(u8 address, u16 data)
 {
-	omap_tsc2101_write(PAGE2_AUDIO_CODEC_REGISTERS, address, data);
+	tsc2101_write_sync(mcbsp_dev.tsc2101_dev, PAGE2_AUDIO_CODEC_REGISTERS,
+				address, data);
 }
 
 /* 
@@ -151,7 +155,8 @@ inline void tsc2101_audio_write(u8 address, u16 data)
  */
 inline u16 tsc2101_audio_read(u8 address)
 {
-	return (omap_tsc2101_read(PAGE2_AUDIO_CODEC_REGISTERS, address));
+	return (tsc2101_read_sync(mcbsp_dev.tsc2101_dev,
+					PAGE2_AUDIO_CODEC_REGISTERS, address));
 }
 
 #ifdef DUMP_TSC2101_AUDIO_REGISTERS
@@ -341,9 +346,9 @@ int tsc2101_clock_on(void)
 	       err);
 
 	// Now turn the audio on
-	omap_tsc2101_write(PAGE2_AUDIO_CODEC_REGISTERS,
-			TSC2101_CODEC_POWER_CTRL,
-			0x0000);	
+	tsc2101_write_sync(mcbsp_dev.tsc2101_dev, PAGE2_AUDIO_CODEC_REGISTERS,
+				TSC2101_CODEC_POWER_CTRL,
+				0x0000);
 	return 0;	
 }
 
@@ -382,9 +387,22 @@ int tsc2101_get_default_samplerate(void)
 
 static int __devinit snd_omap_alsa_tsc2101_probe(struct platform_device *pdev)
 {
+	struct spi_device *tsc2101;
 	int	ret;
 	struct	omap_alsa_codec_config *codec_cfg;
 	
+	tsc2101 = dev_get_drvdata(&pdev->dev);
+	if (tsc2101 == NULL) {
+		dev_err(&pdev->dev, "no platform data\n");
+		return -ENODEV;
+	}
+	if (strncmp(tsc2101->modalias, "tsc2101", 8) != 0) {
+		dev_err(&pdev->dev, "tsc2101 not found\n");
+		return -EINVAL;
+	}
+	mcbsp_dev.mcbsp_dev = pdev;
+	mcbsp_dev.tsc2101_dev = tsc2101;
+
 	codec_cfg = pdev->dev.platform_data;
 	if (codec_cfg != NULL) {
 		codec_cfg->hw_constraints_rates	= &tsc2101_hw_constraints_rates;
diff --git a/sound/arm/omap/omap-alsa-tsc2101.h b/sound/arm/omap/omap-alsa-tsc2101.h
index 85dccbb..73999a0 100644
--- a/sound/arm/omap/omap-alsa-tsc2101.h
+++ b/sound/arm/omap/omap-alsa-tsc2101.h
@@ -42,6 +42,11 @@
 
 #define PAGE2_AUDIO_CODEC_REGISTERS	(2)
 
+struct mcbsp_dev_info {
+	struct platform_device *mcbsp_dev;
+	struct spi_device *tsc2101_dev;
+};
+
 struct tsc2101_samplerate_reg_info {
 	u16 sample_rate;
 	u8 divisor;
-- 
1.5.5-rc3.GIT


  reply	other threads:[~2008-04-18  8:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-18  8:00 [PATCH 00/19] Update and clean up on sound/arm/omap/omap-alsa*[c,h] (take #2) Eduardo Valentin
2008-04-18  8:00 ` Eduardo Valentin [this message]
2008-04-18  8:00   ` [PATCH 02/19] Code clean-up for include/asm-arm/arch-omap/omap-alsa.h Eduardo Valentin
2008-04-18  8:00     ` [PATCH 03/19] Code clean-up for sound/arm/omap/omap-alsa-aic23.c Eduardo Valentin
2008-04-18  8:00       ` [PATCH 04/19] Code clean-up for sound/arm/omap/omap-alsa-aic23.h Eduardo Valentin
2008-04-18  8:00         ` [PATCH 05/19] Code clean-up for sound/arm/omap/omap-alsa-aic23-mixer.c Eduardo Valentin
2008-04-18  8:00           ` [PATCH 06/19] Code clean-up for sound/arm/omap/omap-alsa-dma.c Eduardo Valentin
2008-04-18  8:00             ` [PATCH 07/19] Code clean-up for sound/arm/omap/omap-alsa-dma.h Eduardo Valentin
2008-04-18  8:00               ` [PATCH 08/19] Code clean-up for sound/arm/omap/omap-alsa-sx1-mixer.c Eduardo Valentin
2008-04-18  8:00                 ` [PATCH 09/19] Code clean-up for sound/arm/omap/omap-alsa-sx1-mixer.h Eduardo Valentin
2008-04-18  8:00                   ` [PATCH 10/19] Code clean-up for sound/arm/omap/omap-alsa-sx1.c Eduardo Valentin
2008-04-18  8:00                     ` [PATCH 11/19] Code clean-up for sound/arm/omap/omap-alsa-sx1.h Eduardo Valentin
2008-04-18  8:00                       ` [PATCH 12/19] Code clean-up for sound/arm/omap/omap-alsa-tsc2101-mixer.c Eduardo Valentin
2008-04-18  8:01                         ` [PATCH 13/19] Code clean-up for sound/arm/omap/omap-alsa-tsc2101-mixer.h Eduardo Valentin
2008-04-18  8:01                           ` [PATCH 14/19] Code clean-up for sound/arm/omap/omap-alsa-tsc2101.c Eduardo Valentin
2008-04-18  8:01                             ` [PATCH 15/19] Code clean-up for sound/arm/omap/omap-alsa-tsc2101.h Eduardo Valentin
2008-04-18  8:01                               ` [PATCH 16/19] Code clean-up for sound/arm/omap/omap-alsa-tsc2102-mixer.c Eduardo Valentin
2008-04-18  8:01                                 ` [PATCH 17/19] Code clean-up for sound/arm/omap/omap-alsa-tsc2102.c Eduardo Valentin
2008-04-18  8:01                                   ` [PATCH 18/19] Code clean-up for sound/arm/omap/omap-alsa-tsc2102.h Eduardo Valentin
2008-04-18  8:01                                     ` [PATCH 19/19] Code clean-up for sound/arm/omap/omap-alsa.c Eduardo Valentin
2008-04-23 23:57 ` [PATCH 00/19] Update and clean up on sound/arm/omap/omap-alsa*[c,h] (take #2) Tony Lindgren
  -- strict thread matches above, loose matches on Subject: below --
2008-04-15 14:02 [PATCH 00/19] Update and clean up on sound/arm/omap/omap-alsa*[c,h] Eduardo Valentin
2008-04-15 14:02 ` [PATCH 01/19] Update audio driver for H2 board Eduardo Valentin
2008-04-17 23:59   ` Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208505666-13744-2-git-send-email-edubezval@gmail.com \
    --to=edubezval@gmail.com \
    --cc=eduardo.valentin@indt.org.br \
    --cc=linux-omap@vger.kernel.org \
    --cc=me@felipebalbi.com \
    --cc=ragner.magalhaes@indt.org.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox