Diff
Modified: trunk/sound/soc/blackfin/bf5xx-ad183x.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-ad183x.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-ad183x.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -29,7 +29,6 @@
#include <asm/portmux.h>
#include "../codecs/ad183x.h"
-#include "bf5xx-sport.h"
#include "bf5xx-tdm-pcm.h"
#include "bf5xx-tdm.h"
Modified: trunk/sound/soc/blackfin/bf5xx-ad193x.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-ad193x.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-ad193x.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -38,7 +38,6 @@
#include <asm/portmux.h>
#include "../codecs/ad193x.h"
-#include "bf5xx-sport.h"
#include "bf5xx-tdm-pcm.h"
#include "bf5xx-tdm.h"
Modified: trunk/sound/soc/blackfin/bf5xx-ad73311.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-ad73311.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-ad73311.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -44,6 +44,7 @@
#include <asm/portmux.h>
#include "../codecs/ad73311.h"
+
#include "bf5xx-sport.h"
#include "bf5xx-i2s-pcm.h"
Modified: trunk/sound/soc/blackfin/bf5xx-adau1361.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-adau1361.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-adau1361.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -19,8 +19,9 @@
#include <asm/dma.h>
#include <asm/portmux.h>
#include <linux/gpio.h>
+
#include "../codecs/adau1361.h"
-#include "bf5xx-sport.h"
+
#include "bf5xx-i2s-pcm.h"
static int bf5xx_adau1361_hw_params(struct snd_pcm_substream *substream,
Modified: trunk/sound/soc/blackfin/bf5xx-adau1373.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-adau1373.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-adau1373.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -19,8 +19,9 @@
#include <asm/dma.h>
#include <asm/portmux.h>
#include <linux/gpio.h>
+
#include "../codecs/adau1373.h"
-#include "bf5xx-sport.h"
+
#include "bf5xx-i2s-pcm.h"
/* PLL settings coefficients, Crystal here is 12.288MHz one.
Modified: trunk/sound/soc/blackfin/bf5xx-adau1381.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-adau1381.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-adau1381.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -19,8 +19,9 @@
#include <asm/dma.h>
#include <asm/portmux.h>
#include <linux/gpio.h>
+
#include "../codecs/adau1381.h"
-#include "bf5xx-sport.h"
+
#include "bf5xx-i2s-pcm.h"
static int bf5xx_adau1381_hw_params(struct snd_pcm_substream *substream,
Modified: trunk/sound/soc/blackfin/bf5xx-adau1761.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-adau1761.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-adau1761.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -19,8 +19,9 @@
#include <asm/dma.h>
#include <asm/portmux.h>
#include <linux/gpio.h>
+
#include "../codecs/adau1761.h"
-#include "bf5xx-sport.h"
+
#include "bf5xx-i2s-pcm.h"
static int bf5xx_adau1761_hw_params(struct snd_pcm_substream *substream,
Modified: trunk/sound/soc/blackfin/bf5xx-adav80x.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-adav80x.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-adav80x.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -19,8 +19,9 @@
#include <asm/dma.h>
#include <asm/portmux.h>
#include <linux/gpio.h>
+
#include "../codecs/adav80x.h"
-#include "bf5xx-sport.h"
+
#include "bf5xx-i2s-pcm.h"
static struct snd_soc_card bf5xx_adav80x;
Modified: trunk/sound/soc/blackfin/bf5xx-i2s.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-i2s.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-i2s.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -248,81 +248,23 @@
static int __devinit bf5xx_i2s_probe(struct platform_device *pdev)
{
struct sport_device *sport_handle;
- struct bf5xx_i2s_port *bf5xx_i2s;
- struct sport_param params;
- struct bfin_snd_platform_data *pdata;
- struct resource *res;
int ret;
- pr_debug("%s enter\n", __func__);
+ /* configure SPORT for I2S */
+ sport_handle = sport_init(pdev, 4, 2 * sizeof(u32),
+ sizeof(struct bf5xx_i2s_port));
+ if (!sport_handle)
+ return -ENODEV;
- /* request sport private data */
- bf5xx_i2s = kzalloc(sizeof(*bf5xx_i2s), GFP_KERNEL);
- if (!bf5xx_i2s)
- return -ENOMEM;
-
- pdata = pdev->dev.platform_data;
-
- params.num = pdev->id;
- params.pin_req = pdata->pin_req;
- params.private_data = bf5xx_i2s;
- params.wdsize = 4;
- params.dummy_count = 2 * sizeof(u32);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- pr_err("no MEM resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.regs = (struct sport_register *)res->start;
-
- /* first RX, then TX */
- res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
- if (!res) {
- pr_err("no rx DMA resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.dma_rx_chan = res->start;
-
- res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
- if (!res) {
- pr_err("no tx DMA resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.dma_tx_chan = res->start;
-
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!res) {
- pr_err("no irq resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.err_irq = res->start;
-
- /* request DMA for SPORT */
- sport_handle = sport_init(¶ms);
- if (!sport_handle) {
- ret = -ENODEV;
- goto sport_err;
- }
-
- platform_set_drvdata(pdev, sport_handle);
-
+ /* register with the ASoC layers */
ret = snd_soc_register_dai(&pdev->dev, &bf5xx_i2s_dai);
if (ret) {
pr_err("Failed to register DAI: %d\n", ret);
- goto dai_err;
+ sport_done(sport_handle);
+ return ret;
}
return 0;
-dai_err:
- sport_done(sport_handle);
-sport_err:
- kfree(bf5xx_i2s);
- return ret;
}
static int __devexit bf5xx_i2s_remove(struct platform_device *pdev)
@@ -365,4 +307,3 @@
MODULE_AUTHOR("Cliff Cai");
MODULE_DESCRIPTION("I2S driver for ADI Blackfin");
MODULE_LICENSE("GPL");
-
Modified: trunk/sound/soc/blackfin/bf5xx-sport.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-sport.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-sport.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -797,32 +797,83 @@
}
EXPORT_SYMBOL(sport_set_err_callback);
-struct sport_device *sport_init(struct sport_param *param)
+static int sport_config_pdev(struct platform_device *pdev, struct sport_param *param)
{
+ /* Extract settings from platform data */
+ struct bfin_snd_platform_data *pdata = pdev->dev.platform_data;
+ struct resource *res;
+
+ param->num = pdev->id;
+ param->pin_req = pdata->pin_req;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ pr_err("no MEM resource\n");
+ return -ENODEV;
+ }
+ param->regs = (struct sport_register *)res->start;
+
+ /* first RX, then TX */
+ res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+ if (!res) {
+ pr_err("no rx DMA resource\n");
+ return -ENODEV;
+ }
+ param->dma_rx_chan = res->start;
+
+ res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
+ if (!res) {
+ pr_err("no tx DMA resource\n");
+ return -ENODEV;
+ }
+ param->dma_tx_chan = res->start;
+
+ res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (!res) {
+ pr_err("no irq resource\n");
+ return -ENODEV;
+ }
+ param->err_irq = res->start;
+
+ return 0;
+}
+
+struct sport_device *sport_init(struct platform_device *pdev,
+ unsigned int wdsize, unsigned int dummy_count, size_t priv_size)
+{
int ret;
+ struct sport_param param;
struct sport_device *sport;
+
pr_debug("%s enter\n", __func__);
- BUG_ON(param->wdsize == 0 || param->dummy_count == 0);
- if (peripheral_request_list(param->pin_req, "soc-audio")) {
+ param.wdsize = wdsize;
+ param.dummy_count = dummy_count;
+ BUG_ON(param.wdsize == 0 || param.dummy_count == 0);
+
+ ret = sport_config_pdev(pdev, ¶m);
+ if (ret) {
+ pr_err("Invalid SPORT parameters\n");
+ return NULL;
+ }
+
+ if (peripheral_request_list(param.pin_req, "soc-audio")) {
pr_err("Requesting Peripherals failed\n");
return NULL;
}
- sport = kmalloc(sizeof(struct sport_device), GFP_KERNEL);
+ sport = kzalloc(sizeof(*sport), GFP_KERNEL);
if (!sport) {
pr_err("Failed to allocate for sport device\n");
goto __init_err0;
}
- memset(sport, 0, sizeof(struct sport_device));
- sport->num = param->num;
- sport->dma_rx_chan = param->dma_rx_chan;
- sport->dma_tx_chan = param->dma_tx_chan;
- sport->err_irq = param->err_irq;
- sport->regs = param->regs;
- sport->pin_req = param->pin_req;
- sport->private_data = param->private_data;
+ sport->num = param.num;
+ sport->dma_rx_chan = param.dma_rx_chan;
+ sport->dma_tx_chan = param.dma_tx_chan;
+ sport->err_irq = param.err_irq;
+ sport->regs = param.regs;
+ sport->pin_req = param.pin_req;
if (request_dma(sport->dma_rx_chan, "SPORT RX Data") == -EBUSY) {
pr_err("Failed to request RX dma %d\n", \
@@ -858,13 +909,19 @@
sport->dma_rx_chan, sport->dma_tx_chan,
sport->err_irq, sport->regs);
- sport->wdsize = param->wdsize;
- sport->dummy_count = param->dummy_count;
+ sport->wdsize = param.wdsize;
+ sport->dummy_count = param.dummy_count;
+ sport->private_data = kzalloc(priv_size, GFP_KERNEL);
+ if (!sport->private_data) {
+ pr_err("could not alloc priv data %zu bytes\n", priv_size);
+ goto __init_err4;
+ }
+
if (L1_DATA_A_LENGTH)
- sport->dummy_buf = l1_data_sram_zalloc(param->dummy_count * 2);
+ sport->dummy_buf = l1_data_sram_zalloc(param.dummy_count * 2);
else
- sport->dummy_buf = kzalloc(param->dummy_count * 2, GFP_KERNEL);
+ sport->dummy_buf = kzalloc(param.dummy_count * 2, GFP_KERNEL);
if (sport->dummy_buf == NULL) {
pr_err("Failed to allocate dummy buffer\n");
goto __error1;
@@ -881,6 +938,8 @@
goto __error3;
}
+ platform_set_drvdata(pdev, sport);
+
return sport;
__error3:
if (L1_DATA_A_LENGTH)
@@ -894,6 +953,8 @@
else
kfree(sport->dummy_buf);
__error1:
+ kfree(sport->private_data);
+__init_err4:
free_irq(sport->err_irq, sport);
__init_err3:
free_dma(sport->dma_tx_chan);
@@ -902,7 +963,7 @@
__init_err1:
kfree(sport);
__init_err0:
- peripheral_free_list(param->pin_req);
+ peripheral_free_list(param.pin_req);
return NULL;
}
EXPORT_SYMBOL(sport_init);
Modified: trunk/sound/soc/blackfin/bf5xx-sport.h (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-sport.h 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-sport.h 2011-03-27 09:24:18 UTC (rev 9781)
@@ -33,6 +33,7 @@
#include <linux/types.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
+#include <linux/platform_device.h>
#include <asm/dma.h>
#include <asm/bfin_sport.h>
@@ -117,7 +118,8 @@
void *private_data;
};
-struct sport_device *sport_init(struct sport_param *param);
+struct sport_device *sport_init(struct platform_device *pdev,
+ unsigned int wdsize, unsigned int dummy_count, size_t priv_size);
void sport_done(struct sport_device *sport);
Modified: trunk/sound/soc/blackfin/bf5xx-tdm.c (9780 => 9781)
--- trunk/sound/soc/blackfin/bf5xx-tdm.c 2011-03-27 08:41:50 UTC (rev 9780)
+++ trunk/sound/soc/blackfin/bf5xx-tdm.c 2011-03-27 09:24:18 UTC (rev 9781)
@@ -261,68 +261,14 @@
static int __devinit bfin_tdm_probe(struct platform_device *pdev)
{
struct sport_device *sport_handle;
- struct bf5xx_tdm_port *bf5xx_tdm;
- struct sport_param params;
- struct bfin_snd_platform_data *pdata;
- struct resource *res;
- int ret = 0;
+ int ret;
- /* request sport private data */
- bf5xx_tdm = kzalloc(sizeof(*bf5xx_tdm), GFP_KERNEL);
- if (!bf5xx_tdm)
- return -ENOMEM;
+ /* configure SPORT for TDM */
+ sport_handle = sport_init(pdev, 4, 8 * sizeof(u32),
+ sizeof(struct bf5xx_tdm_port));
+ if (!sport_handle)
+ return -ENODEV;
- pdata = pdev->dev.platform_data;
-
- params.num = pdev->id;
- params.pin_req = pdata->pin_req;
- params.private_data = bf5xx_tdm;
- params.wdsize = 4;
- params.dummy_count = 8 * sizeof(u32);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- pr_err("no MEM resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.regs = (struct sport_register *)res->start;
-
-
- /* first RX, then TX */
- res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
- if (!res) {
- pr_err("no rx DMA resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.dma_rx_chan = res->start;
-
- res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
- if (!res) {
- pr_err("no tx DMA resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.dma_tx_chan = res->start;
-
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!res) {
- pr_err("no irq resource\n");
- ret = -ENODEV;
- goto sport_err;
- }
- params.err_irq = res->start;
-
- /* request DMA for SPORT */
- sport_handle = sport_init(¶ms);
- if (!sport_handle) {
- ret = -ENODEV;
- goto sport_err;
- }
-
- platform_set_drvdata(pdev, sport_handle);
-
/* SPORT works in TDM mode */
ret = sport_set_multichannel(sport_handle, 8, 0xFF, 1);
if (ret) {
@@ -355,8 +301,6 @@
sport_config_err:
sport_done(sport_handle);
-sport_err:
- kfree(bf5xx_tdm);
return ret;
}