Commit 87a6b618 authored by chandra shekhar's avatar chandra shekhar Committed by Tony Lindgren

Dynamic allocation for mcbsp devices. and related changes

This patch provides dynamic allocation for mcbsp device.
no. of  mcbsp for each cpu is determined at runtime and accordingly memory is
allocated. id check macro definition has been changed.

Signed-off-by:  chandra shekhar x0044955@ti.com
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 42e11feb
...@@ -103,30 +103,6 @@ static inline void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk) ...@@ -103,30 +103,6 @@ static inline void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk)
{ } { }
#endif #endif
static int omap1_mcbsp_check(unsigned int id)
{
/* REVISIT: Check correctly for number of registered McBSPs */
if (cpu_is_omap730()) {
if (id > OMAP_MAX_MCBSP_COUNT - 2) {
printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
id + 1);
return -ENODEV;
}
return 0;
}
if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
if (id > OMAP_MAX_MCBSP_COUNT - 1) {
printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
id + 1);
return -ENODEV;
}
return 0;
}
return -ENODEV;
}
static void omap1_mcbsp_request(unsigned int id) static void omap1_mcbsp_request(unsigned int id)
{ {
/* /*
...@@ -151,7 +127,6 @@ static void omap1_mcbsp_free(unsigned int id) ...@@ -151,7 +127,6 @@ static void omap1_mcbsp_free(unsigned int id)
} }
static struct omap_mcbsp_ops omap1_mcbsp_ops = { static struct omap_mcbsp_ops omap1_mcbsp_ops = {
.check = omap1_mcbsp_check,
.request = omap1_mcbsp_request, .request = omap1_mcbsp_request,
.free = omap1_mcbsp_free, .free = omap1_mcbsp_free,
}; };
...@@ -262,6 +237,18 @@ int __init omap1_mcbsp_init(void) ...@@ -262,6 +237,18 @@ int __init omap1_mcbsp_init(void)
} }
} }
if (cpu_is_omap730())
omap_mcbsp_count = OMAP730_MCBSP_PDATA_SZ;
if (cpu_is_omap15xx())
omap_mcbsp_count = OMAP15XX_MCBSP_PDATA_SZ;
if (cpu_is_omap16xx())
omap_mcbsp_count = OMAP16XX_MCBSP_PDATA_SZ;
mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
GFP_KERNEL);
if (!mcbsp_ptr)
return -ENOMEM;
if (cpu_is_omap730()) if (cpu_is_omap730())
omap_mcbsp_register_board_cfg(omap730_mcbsp_pdata, omap_mcbsp_register_board_cfg(omap730_mcbsp_pdata,
OMAP730_MCBSP_PDATA_SZ); OMAP730_MCBSP_PDATA_SZ);
......
...@@ -117,18 +117,8 @@ static void omap2_mcbsp_request(unsigned int id) ...@@ -117,18 +117,8 @@ static void omap2_mcbsp_request(unsigned int id)
omap2_mcbsp2_mux_setup(); omap2_mcbsp2_mux_setup();
} }
static int omap2_mcbsp_check(unsigned int id)
{
if (id > OMAP_MAX_MCBSP_COUNT - 1) {
printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
return -ENODEV;
}
return 0;
}
static struct omap_mcbsp_ops omap2_mcbsp_ops = { static struct omap_mcbsp_ops omap2_mcbsp_ops = {
.request = omap2_mcbsp_request, .request = omap2_mcbsp_request,
.check = omap2_mcbsp_check,
}; };
#ifdef CONFIG_ARCH_OMAP24XX #ifdef CONFIG_ARCH_OMAP24XX
...@@ -195,10 +185,19 @@ static int __init omap2_mcbsp_init(void) ...@@ -195,10 +185,19 @@ static int __init omap2_mcbsp_init(void)
clk_register(&omap_mcbsp_clks[i].clk); clk_register(&omap_mcbsp_clks[i].clk);
} }
if (cpu_is_omap24xx())
omap_mcbsp_count = OMAP24XX_MCBSP_PDATA_SZ;
if (cpu_is_omap34xx())
omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ;
mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
GFP_KERNEL);
if (!mcbsp_ptr)
return -ENOMEM;
if (cpu_is_omap24xx()) if (cpu_is_omap24xx())
omap_mcbsp_register_board_cfg(omap24xx_mcbsp_pdata, omap_mcbsp_register_board_cfg(omap24xx_mcbsp_pdata,
OMAP24XX_MCBSP_PDATA_SZ); OMAP24XX_MCBSP_PDATA_SZ);
if (cpu_is_omap34xx()) if (cpu_is_omap34xx())
omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata, omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
OMAP34XX_MCBSP_PDATA_SZ); OMAP34XX_MCBSP_PDATA_SZ);
......
...@@ -160,13 +160,6 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, ...@@ -160,13 +160,6 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
{ {
int i; int i;
if (size > OMAP_MAX_MCBSP_COUNT) {
printk(KERN_WARNING "Registered too many McBSPs platform_data."
" Using maximum (%d) available.\n",
OMAP_MAX_MCBSP_COUNT);
size = OMAP_MAX_MCBSP_COUNT;
}
omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *), omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
GFP_KERNEL); GFP_KERNEL);
if (!omap_mcbsp_devices) { if (!omap_mcbsp_devices) {
......
...@@ -27,43 +27,44 @@ ...@@ -27,43 +27,44 @@
#include <asm/arch/dma.h> #include <asm/arch/dma.h>
#include <asm/arch/mcbsp.h> #include <asm/arch/mcbsp.h>
static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT]; struct omap_mcbsp **mcbsp_ptr;
int omap_mcbsp_count;
#define omap_mcbsp_check_valid_id(id) (mcbsp[id].pdata && \ #define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
mcbsp[id].pdata->ops && \ #define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
mcbsp[id].pdata->ops->check && \
(mcbsp[id].pdata->ops->check(id) == 0))
static void omap_mcbsp_dump_reg(u8 id) static void omap_mcbsp_dump_reg(u8 id)
{ {
dev_dbg(mcbsp[id].dev, "**** McBSP%d regs ****\n", mcbsp[id].id); struct omap_mcbsp *mcbsp = id_to_mcbsp_ptr(id);
dev_dbg(mcbsp[id].dev, "DRR2: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, DRR2)); dev_dbg(mcbsp->dev, "**** McBSP%d regs ****\n", mcbsp->id);
dev_dbg(mcbsp[id].dev, "DRR1: 0x%04x\n", dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, DRR1)); OMAP_MCBSP_READ(mcbsp->io_base, DRR2));
dev_dbg(mcbsp[id].dev, "DXR2: 0x%04x\n", dev_dbg(mcbsp->dev, "DRR1: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, DXR2)); OMAP_MCBSP_READ(mcbsp->io_base, DRR1));
dev_dbg(mcbsp[id].dev, "DXR1: 0x%04x\n", dev_dbg(mcbsp->dev, "DXR2: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, DXR1)); OMAP_MCBSP_READ(mcbsp->io_base, DXR2));
dev_dbg(mcbsp[id].dev, "SPCR2: 0x%04x\n", dev_dbg(mcbsp->dev, "DXR1: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, SPCR2)); OMAP_MCBSP_READ(mcbsp->io_base, DXR1));
dev_dbg(mcbsp[id].dev, "SPCR1: 0x%04x\n", dev_dbg(mcbsp->dev, "SPCR2: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, SPCR1)); OMAP_MCBSP_READ(mcbsp->io_base, SPCR2));
dev_dbg(mcbsp[id].dev, "RCR2: 0x%04x\n", dev_dbg(mcbsp->dev, "SPCR1: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, RCR2)); OMAP_MCBSP_READ(mcbsp->io_base, SPCR1));
dev_dbg(mcbsp[id].dev, "RCR1: 0x%04x\n", dev_dbg(mcbsp->dev, "RCR2: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, RCR1)); OMAP_MCBSP_READ(mcbsp->io_base, RCR2));
dev_dbg(mcbsp[id].dev, "XCR2: 0x%04x\n", dev_dbg(mcbsp->dev, "RCR1: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, XCR2)); OMAP_MCBSP_READ(mcbsp->io_base, RCR1));
dev_dbg(mcbsp[id].dev, "XCR1: 0x%04x\n", dev_dbg(mcbsp->dev, "XCR2: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, XCR1)); OMAP_MCBSP_READ(mcbsp->io_base, XCR2));
dev_dbg(mcbsp[id].dev, "SRGR2: 0x%04x\n", dev_dbg(mcbsp->dev, "XCR1: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, SRGR2)); OMAP_MCBSP_READ(mcbsp->io_base, XCR1));
dev_dbg(mcbsp[id].dev, "SRGR1: 0x%04x\n", dev_dbg(mcbsp->dev, "SRGR2: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, SRGR1)); OMAP_MCBSP_READ(mcbsp->io_base, SRGR2));
dev_dbg(mcbsp[id].dev, "PCR0: 0x%04x\n", dev_dbg(mcbsp->dev, "SRGR1: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp[id].io_base, PCR0)); OMAP_MCBSP_READ(mcbsp->io_base, SRGR1));
dev_dbg(mcbsp[id].dev, "***********************\n"); dev_dbg(mcbsp->dev, "PCR0: 0x%04x\n",
OMAP_MCBSP_READ(mcbsp->io_base, PCR0));
dev_dbg(mcbsp->dev, "***********************\n");
} }
static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id) static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
...@@ -126,16 +127,18 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data) ...@@ -126,16 +127,18 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
*/ */
void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config) void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
{ {
struct omap_mcbsp *mcbsp;
u32 io_base; u32 io_base;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return; return;
} }
mcbsp = id_to_mcbsp_ptr(id);
io_base = mcbsp[id].io_base; io_base = mcbsp->io_base;
dev_dbg(mcbsp[id].dev, "Configuring McBSP%d io_base: 0x%8x\n", dev_dbg(mcbsp->dev, "Configuring McBSP%d io_base: 0x%8x\n",
mcbsp[id].id, io_base); mcbsp->id, io_base);
/* We write the given config */ /* We write the given config */
OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2); OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2);
...@@ -158,23 +161,26 @@ EXPORT_SYMBOL(omap_mcbsp_config); ...@@ -158,23 +161,26 @@ EXPORT_SYMBOL(omap_mcbsp_config);
*/ */
int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type) int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
{ {
struct omap_mcbsp *mcbsp;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV; return -ENODEV;
} }
mcbsp = id_to_mcbsp_ptr(id);
spin_lock(&mcbsp[id].lock); spin_lock(&mcbsp->lock);
if (!mcbsp[id].free) { if (!mcbsp->free) {
dev_err(mcbsp[id].dev, "McBSP%d is currently in use\n", dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
mcbsp[id].id); mcbsp->id);
spin_unlock(&mcbsp[id].lock); spin_unlock(&mcbsp->lock);
return -EINVAL; return -EINVAL;
} }
mcbsp[id].io_type = io_type; mcbsp->io_type = io_type;
spin_unlock(&mcbsp[id].lock); spin_unlock(&mcbsp->lock);
return 0; return 0;
} }
...@@ -182,53 +188,55 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type); ...@@ -182,53 +188,55 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type);
int omap_mcbsp_request(unsigned int id) int omap_mcbsp_request(unsigned int id)
{ {
struct omap_mcbsp *mcbsp;
int err; int err;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV; return -ENODEV;
} }
mcbsp = id_to_mcbsp_ptr(id);
if (mcbsp[id].pdata->ops->request) if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
mcbsp[id].pdata->ops->request(id); mcbsp->pdata->ops->request(id);
clk_enable(mcbsp[id].clk); clk_enable(mcbsp->clk);
spin_lock(&mcbsp[id].lock); spin_lock(&mcbsp->lock);
if (!mcbsp[id].free) { if (!mcbsp->free) {
dev_err(mcbsp[id].dev, "McBSP%d is currently in use\n", dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
mcbsp[id].id); mcbsp->id);
spin_unlock(&mcbsp[id].lock); spin_unlock(&mcbsp->lock);
return -1; return -1;
} }
mcbsp[id].free = 0; mcbsp->free = 0;
spin_unlock(&mcbsp[id].lock); spin_unlock(&mcbsp->lock);
if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) { if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
/* We need to get IRQs here */ /* We need to get IRQs here */
err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, err = request_irq(mcbsp->tx_irq, omap_mcbsp_tx_irq_handler,
0, "McBSP", (void *) (&mcbsp[id])); 0, "McBSP", (void *)mcbsp);
if (err != 0) { if (err != 0) {
dev_err(mcbsp[id].dev, "Unable to request TX IRQ %d " dev_err(mcbsp->dev, "Unable to request TX IRQ %d "
"for McBSP%d\n", mcbsp[id].tx_irq, "for McBSP%d\n", mcbsp->tx_irq,
mcbsp[id].id); mcbsp->id);
return err; return err;
} }
init_completion(&(mcbsp[id].tx_irq_completion)); init_completion(&mcbsp->tx_irq_completion);
err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, err = request_irq(mcbsp->rx_irq, omap_mcbsp_rx_irq_handler,
0, "McBSP", (void *) (&mcbsp[id])); 0, "McBSP", (void *)mcbsp);
if (err != 0) { if (err != 0) {
dev_err(mcbsp[id].dev, "Unable to request RX IRQ %d " dev_err(mcbsp->dev, "Unable to request RX IRQ %d "
"for McBSP%d\n", mcbsp[id].rx_irq, "for McBSP%d\n", mcbsp->rx_irq,
mcbsp[id].id); mcbsp->id);
free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id])); free_irq(mcbsp->tx_irq, (void *)mcbsp);
return err; return err;
} }
init_completion(&(mcbsp[id].rx_irq_completion)); init_completion(&mcbsp->rx_irq_completion);
} }
return 0; return 0;
...@@ -237,31 +245,34 @@ EXPORT_SYMBOL(omap_mcbsp_request); ...@@ -237,31 +245,34 @@ EXPORT_SYMBOL(omap_mcbsp_request);
void omap_mcbsp_free(unsigned int id) void omap_mcbsp_free(unsigned int id)
{ {
struct omap_mcbsp *mcbsp;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return; return;
} }
mcbsp = id_to_mcbsp_ptr(id);
if (mcbsp[id].pdata->ops->free) if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free)
mcbsp[id].pdata->ops->free(id); mcbsp->pdata->ops->free(id);
clk_disable(mcbsp[id].clk); clk_disable(mcbsp->clk);
spin_lock(&mcbsp[id].lock); spin_lock(&mcbsp->lock);
if (mcbsp[id].free) { if (mcbsp->free) {
dev_err(mcbsp[id].dev, "McBSP%d was not reserved\n", dev_err(mcbsp->dev, "McBSP%d was not reserved\n",
mcbsp[id].id); mcbsp->id);
spin_unlock(&mcbsp[id].lock); spin_unlock(&mcbsp->lock);
return; return;
} }
mcbsp[id].free = 1; mcbsp->free = 1;
spin_unlock(&mcbsp[id].lock); spin_unlock(&mcbsp->lock);
if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) { if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
/* Free IRQs */ /* Free IRQs */
free_irq(mcbsp[id].rx_irq, (void *) (&mcbsp[id])); free_irq(mcbsp->rx_irq, (void *)mcbsp);
free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id])); free_irq(mcbsp->tx_irq, (void *)mcbsp);
} }
} }
EXPORT_SYMBOL(omap_mcbsp_free); EXPORT_SYMBOL(omap_mcbsp_free);
...@@ -273,6 +284,7 @@ EXPORT_SYMBOL(omap_mcbsp_free); ...@@ -273,6 +284,7 @@ EXPORT_SYMBOL(omap_mcbsp_free);
*/ */
void omap_mcbsp_start(unsigned int id) void omap_mcbsp_start(unsigned int id)
{ {
struct omap_mcbsp *mcbsp;
u32 io_base; u32 io_base;
u16 w; u16 w;
...@@ -280,11 +292,11 @@ void omap_mcbsp_start(unsigned int id) ...@@ -280,11 +292,11 @@ void omap_mcbsp_start(unsigned int id)
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return; return;
} }
mcbsp = id_to_mcbsp_ptr(id);
io_base = mcbsp->io_base;
io_base = mcbsp[id].io_base; mcbsp->rx_word_length = (OMAP_MCBSP_READ(io_base, RCR1) >> 5) & 0x7;
mcbsp->tx_word_length = (OMAP_MCBSP_READ(io_base, XCR1) >> 5) & 0x7;
mcbsp[id].rx_word_length = (OMAP_MCBSP_READ(io_base, RCR1) >> 5) & 0x7;
mcbsp[id].tx_word_length = (OMAP_MCBSP_READ(io_base, XCR1) >> 5) & 0x7;
/* Start the sample generator */ /* Start the sample generator */
w = OMAP_MCBSP_READ(io_base, SPCR2); w = OMAP_MCBSP_READ(io_base, SPCR2);
...@@ -310,6 +322,7 @@ EXPORT_SYMBOL(omap_mcbsp_start); ...@@ -310,6 +322,7 @@ EXPORT_SYMBOL(omap_mcbsp_start);
void omap_mcbsp_stop(unsigned int id) void omap_mcbsp_stop(unsigned int id)
{ {
struct omap_mcbsp *mcbsp;
u32 io_base; u32 io_base;
u16 w; u16 w;
...@@ -318,7 +331,8 @@ void omap_mcbsp_stop(unsigned int id) ...@@ -318,7 +331,8 @@ void omap_mcbsp_stop(unsigned int id)
return; return;
} }
io_base = mcbsp[id].io_base; mcbsp = id_to_mcbsp_ptr(id);
io_base = mcbsp->io_base;
/* Reset transmitter */ /* Reset transmitter */
w = OMAP_MCBSP_READ(io_base, SPCR2); w = OMAP_MCBSP_READ(io_base, SPCR2);
...@@ -337,6 +351,7 @@ EXPORT_SYMBOL(omap_mcbsp_stop); ...@@ -337,6 +351,7 @@ EXPORT_SYMBOL(omap_mcbsp_stop);
/* polled mcbsp i/o operations */ /* polled mcbsp i/o operations */
int omap_mcbsp_pollwrite(unsigned int id, u16 buf) int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
{ {
struct omap_mcbsp *mcbsp;
u32 base; u32 base;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
...@@ -344,7 +359,9 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf) ...@@ -344,7 +359,9 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
return -ENODEV; return -ENODEV;
} }
base = mcbsp[id].io_base; mcbsp = id_to_mcbsp_ptr(id);
base = mcbsp->io_base;
writew(buf, base + OMAP_MCBSP_REG_DXR1); writew(buf, base + OMAP_MCBSP_REG_DXR1);
/* if frame sync error - clear the error */ /* if frame sync error - clear the error */
if (readw(base + OMAP_MCBSP_REG_SPCR2) & XSYNC_ERR) { if (readw(base + OMAP_MCBSP_REG_SPCR2) & XSYNC_ERR) {
...@@ -366,8 +383,8 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf) ...@@ -366,8 +383,8 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
(XRST), (XRST),
base + OMAP_MCBSP_REG_SPCR2); base + OMAP_MCBSP_REG_SPCR2);
udelay(10); udelay(10);
dev_err(mcbsp[id].dev, "Could not write to" dev_err(mcbsp->dev, "Could not write to"
" McBSP%d Register\n", mcbsp[id].id); " McBSP%d Register\n", mcbsp->id);
return -2; return -2;
} }
} }
...@@ -379,14 +396,16 @@ EXPORT_SYMBOL(omap_mcbsp_pollwrite); ...@@ -379,14 +396,16 @@ EXPORT_SYMBOL(omap_mcbsp_pollwrite);
int omap_mcbsp_pollread(unsigned int id, u16 *buf) int omap_mcbsp_pollread(unsigned int id, u16 *buf)
{ {
struct omap_mcbsp *mcbsp;
u32 base; u32 base;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV; return -ENODEV;
} }
mcbsp = id_to_mcbsp_ptr(id);
base = mcbsp[id].io_base; base = mcbsp->io_base;
/* if frame sync error - clear the error */ /* if frame sync error - clear the error */
if (readw(base + OMAP_MCBSP_REG_SPCR1) & RSYNC_ERR) { if (readw(base + OMAP_MCBSP_REG_SPCR1) & RSYNC_ERR) {
/* clear error */ /* clear error */
...@@ -407,8 +426,8 @@ int omap_mcbsp_pollread(unsigned int id, u16 *buf) ...@@ -407,8 +426,8 @@ int omap_mcbsp_pollread(unsigned int id, u16 *buf)
(RRST), (RRST),
base + OMAP_MCBSP_REG_SPCR1); base + OMAP_MCBSP_REG_SPCR1);
udelay(10); udelay(10);
dev_err(mcbsp[id].dev, "Could not read from" dev_err(mcbsp->dev, "Could not read from"
" McBSP%d Register\n", mcbsp[id].id); " McBSP%d Register\n", mcbsp->id);
return -2; return -2;
} }
} }
...@@ -424,6 +443,7 @@ EXPORT_SYMBOL(omap_mcbsp_pollread); ...@@ -424,6 +443,7 @@ EXPORT_SYMBOL(omap_mcbsp_pollread);
*/ */
void omap_mcbsp_xmit_word(unsigned int id, u32 word) void omap_mcbsp_xmit_word(unsigned int id, u32 word)
{ {
struct omap_mcbsp *mcbsp;
u32 io_base; u32 io_base;
omap_mcbsp_word_length word_length; omap_mcbsp_word_length word_length;
...@@ -432,10 +452,11 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word) ...@@ -432,10 +452,11 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
return; return;
} }
io_base = mcbsp[id].io_base; mcbsp = id_to_mcbsp_ptr(id);
word_length = mcbsp[id].tx_word_length; io_base = mcbsp->io_base;
word_length = mcbsp->tx_word_length;
wait_for_completion(&(mcbsp[id].tx_irq_completion)); wait_for_completion(&mcbsp->tx_irq_completion);
if (word_length > OMAP_MCBSP_WORD_16) if (word_length > OMAP_MCBSP_WORD_16)
OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16); OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
...@@ -445,6 +466,7 @@ EXPORT_SYMBOL(omap_mcbsp_xmit_word); ...@@ -445,6 +466,7 @@ EXPORT_SYMBOL(omap_mcbsp_xmit_word);
u32 omap_mcbsp_recv_word(unsigned int id) u32 omap_mcbsp_recv_word(unsigned int id)
{ {
struct omap_mcbsp *mcbsp;
u32 io_base; u32 io_base;
u16 word_lsb, word_msb = 0; u16 word_lsb, word_msb = 0;
omap_mcbsp_word_length word_length; omap_mcbsp_word_length word_length;
...@@ -453,11 +475,12 @@ u32 omap_mcbsp_recv_word(unsigned int id) ...@@ -453,11 +475,12 @@ u32 omap_mcbsp_recv_word(unsigned int id)
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV; return -ENODEV;
} }
mcbsp = id_to_mcbsp_ptr(id);
word_length = mcbsp[id].rx_word_length; word_length = mcbsp->rx_word_length;
io_base = mcbsp[id].io_base; io_base = mcbsp->io_base;
wait_for_completion(&(mcbsp[id].rx_irq_completion)); wait_for_completion(&mcbsp->rx_irq_completion);
if (word_length > OMAP_MCBSP_WORD_16) if (word_length > OMAP_MCBSP_WORD_16)
word_msb = OMAP_MCBSP_READ(io_base, DRR2); word_msb = OMAP_MCBSP_READ(io_base, DRR2);
...@@ -469,6 +492,7 @@ EXPORT_SYMBOL(omap_mcbsp_recv_word); ...@@ -469,6 +492,7 @@ EXPORT_SYMBOL(omap_mcbsp_recv_word);
int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word) int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
{ {
struct omap_mcbsp *mcbsp;
u32 io_base; u32 io_base;
omap_mcbsp_word_length tx_word_length; omap_mcbsp_word_length tx_word_length;
omap_mcbsp_word_length rx_word_length; omap_mcbsp_word_length rx_word_length;
...@@ -478,10 +502,10 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word) ...@@ -478,10 +502,10 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV; return -ENODEV;
} }
mcbsp = id_to_mcbsp_ptr(id);
io_base = mcbsp[id].io_base; io_base = mcbsp->io_base;
tx_word_length = mcbsp[id].tx_word_length; tx_word_length = mcbsp->tx_word_length;
rx_word_length = mcbsp[id].rx_word_length; rx_word_length = mcbsp->rx_word_length;
if (tx_word_length != rx_word_length) if (tx_word_length != rx_word_length)
return -EINVAL; return -EINVAL;
...@@ -496,8 +520,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word) ...@@ -496,8 +520,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
udelay(10); udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST); OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
udelay(10); udelay(10);
dev_err(mcbsp[id].dev, "McBSP%d transmitter not " dev_err(mcbsp->dev, "McBSP%d transmitter not "
"ready\n", mcbsp[id].id); "ready\n", mcbsp->id);
return -EAGAIN; return -EAGAIN;
} }
} }
...@@ -517,8 +541,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word) ...@@ -517,8 +541,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
udelay(10); udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST); OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
udelay(10); udelay(10);
dev_err(mcbsp[id].dev, "McBSP%d receiver not " dev_err(mcbsp->dev, "McBSP%d receiver not "
"ready\n", mcbsp[id].id); "ready\n", mcbsp->id);
return -EAGAIN; return -EAGAIN;
} }
} }
...@@ -534,6 +558,7 @@ EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll); ...@@ -534,6 +558,7 @@ EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word) int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
{ {
struct omap_mcbsp *mcbsp;
u32 io_base, clock_word = 0; u32 io_base, clock_word = 0;
omap_mcbsp_word_length tx_word_length; omap_mcbsp_word_length tx_word_length;
omap_mcbsp_word_length rx_word_length; omap_mcbsp_word_length rx_word_length;
...@@ -544,9 +569,11 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word) ...@@ -544,9 +569,11 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
return -ENODEV; return -ENODEV;
} }
io_base = mcbsp[id].io_base; mcbsp = id_to_mcbsp_ptr(id);
tx_word_length = mcbsp[id].tx_word_length; io_base = mcbsp->io_base;
rx_word_length = mcbsp[id].rx_word_length;
tx_word_length = mcbsp->tx_word_length;
rx_word_length = mcbsp->rx_word_length;
if (tx_word_length != rx_word_length) if (tx_word_length != rx_word_length)
return -EINVAL; return -EINVAL;
...@@ -561,8 +588,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word) ...@@ -561,8 +588,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
udelay(10); udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST); OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
udelay(10); udelay(10);
dev_err(mcbsp[id].dev, "McBSP%d transmitter not " dev_err(mcbsp->dev, "McBSP%d transmitter not "
"ready\n", mcbsp[id].id); "ready\n", mcbsp->id);
return -EAGAIN; return -EAGAIN;
} }
} }
...@@ -582,8 +609,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word) ...@@ -582,8 +609,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
udelay(10); udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST); OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
udelay(10); udelay(10);
dev_err(mcbsp[id].dev, "McBSP%d receiver not " dev_err(mcbsp->dev, "McBSP%d receiver not "
"ready\n", mcbsp[id].id); "ready\n", mcbsp->id);
return -EAGAIN; return -EAGAIN;
} }
} }
...@@ -609,6 +636,7 @@ EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll); ...@@ -609,6 +636,7 @@ EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
unsigned int length) unsigned int length)
{ {
struct omap_mcbsp *mcbsp;
int dma_tx_ch; int dma_tx_ch;
int src_port = 0; int src_port = 0;
int dest_port = 0; int dest_port = 0;
...@@ -618,50 +646,51 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, ...@@ -618,50 +646,51 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV; return -ENODEV;
} }
mcbsp = id_to_mcbsp_ptr(id);
if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX", if (omap_request_dma(mcbsp->dma_tx_sync, "McBSP TX",
omap_mcbsp_tx_dma_callback, omap_mcbsp_tx_dma_callback,
&mcbsp[id], mcbsp,
&dma_tx_ch)) { &dma_tx_ch)) {
dev_err(mcbsp[id].dev, " Unable to request DMA channel for " dev_err(mcbsp->dev, " Unable to request DMA channel for "
"McBSP%d TX. Trying IRQ based TX\n", "McBSP%d TX. Trying IRQ based TX\n",
mcbsp[id].id); mcbsp->id);
return -EAGAIN; return -EAGAIN;
} }
mcbsp[id].dma_tx_lch = dma_tx_ch; mcbsp->dma_tx_lch = dma_tx_ch;
dev_err(mcbsp[id].dev, "McBSP%d TX DMA on channel %d\n", mcbsp[id].id, dev_err(mcbsp->dev, "McBSP%d TX DMA on channel %d\n", mcbsp->id,
dma_tx_ch); dma_tx_ch);
init_completion(&(mcbsp[id].tx_dma_completion)); init_completion(&mcbsp->tx_dma_completion);
if (cpu_class_is_omap1()) { if (cpu_class_is_omap1()) {
src_port = OMAP_DMA_PORT_TIPB; src_port = OMAP_DMA_PORT_TIPB;
dest_port = OMAP_DMA_PORT_EMIFF; dest_port = OMAP_DMA_PORT_EMIFF;
} }
if (cpu_class_is_omap2()) if (cpu_class_is_omap2())
sync_dev = mcbsp[id].dma_tx_sync; sync_dev = mcbsp->dma_tx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch, omap_set_dma_transfer_params(mcbsp->dma_tx_lch,
OMAP_DMA_DATA_TYPE_S16, OMAP_DMA_DATA_TYPE_S16,
length >> 1, 1, length >> 1, 1,
OMAP_DMA_SYNC_ELEMENT, OMAP_DMA_SYNC_ELEMENT,
sync_dev, 0); sync_dev, 0);
omap_set_dma_dest_params(mcbsp[id].dma_tx_lch, omap_set_dma_dest_params(mcbsp->dma_tx_lch,
src_port, src_port,
OMAP_DMA_AMODE_CONSTANT, OMAP_DMA_AMODE_CONSTANT,
mcbsp[id].io_base + OMAP_MCBSP_REG_DXR1, mcbsp->io_base + OMAP_MCBSP_REG_DXR1,
0, 0); 0, 0);
omap_set_dma_src_params(mcbsp[id].dma_tx_lch, omap_set_dma_src_params(mcbsp->dma_tx_lch,
dest_port, dest_port,
OMAP_DMA_AMODE_POST_INC, OMAP_DMA_AMODE_POST_INC,
buffer, buffer,
0, 0); 0, 0);
omap_start_dma(mcbsp[id].dma_tx_lch); omap_start_dma(mcbsp->dma_tx_lch);
wait_for_completion(&(mcbsp[id].tx_dma_completion)); wait_for_completion(&mcbsp->tx_dma_completion);
return 0; return 0;
} }
...@@ -670,6 +699,7 @@ EXPORT_SYMBOL(omap_mcbsp_xmit_buffer); ...@@ -670,6 +699,7 @@ EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
unsigned int length) unsigned int length)
{ {
struct omap_mcbsp *mcbsp;
int dma_rx_ch; int dma_rx_ch;
int src_port = 0; int src_port = 0;
int dest_port = 0; int dest_port = 0;
...@@ -679,50 +709,51 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, ...@@ -679,50 +709,51 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV; return -ENODEV;
} }
mcbsp = id_to_mcbsp_ptr(id);
if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX", if (omap_request_dma(mcbsp->dma_rx_sync, "McBSP RX",
omap_mcbsp_rx_dma_callback, omap_mcbsp_rx_dma_callback,
&mcbsp[id], mcbsp,
&dma_rx_ch)) { &dma_rx_ch)) {
dev_err(mcbsp[id].dev, "Unable to request DMA channel for " dev_err(mcbsp->dev, "Unable to request DMA channel for "
"McBSP%d RX. Trying IRQ based RX\n", "McBSP%d RX. Trying IRQ based RX\n",
mcbsp[id].id); mcbsp->id);
return -EAGAIN; return -EAGAIN;
} }
mcbsp[id].dma_rx_lch = dma_rx_ch; mcbsp->dma_rx_lch = dma_rx_ch;
dev_err(mcbsp[id].dev, "McBSP%d RX DMA on channel %d\n", mcbsp[id].id, dev_err(mcbsp->dev, "McBSP%d RX DMA on channel %d\n", mcbsp->id,
dma_rx_ch); dma_rx_ch);
init_completion(&(mcbsp[id].rx_dma_completion)); init_completion(&mcbsp->rx_dma_completion);
if (cpu_class_is_omap1()) { if (cpu_class_is_omap1()) {
src_port = OMAP_DMA_PORT_TIPB; src_port = OMAP_DMA_PORT_TIPB;
dest_port = OMAP_DMA_PORT_EMIFF; dest_port = OMAP_DMA_PORT_EMIFF;
} }
if (cpu_class_is_omap2()) if (cpu_class_is_omap2())
sync_dev = mcbsp[id].dma_rx_sync; sync_dev = mcbsp->dma_rx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch, omap_set_dma_transfer_params(mcbsp->dma_rx_lch,
OMAP_DMA_DATA_TYPE_S16, OMAP_DMA_DATA_TYPE_S16,
length >> 1, 1, length >> 1, 1,
OMAP_DMA_SYNC_ELEMENT, OMAP_DMA_SYNC_ELEMENT,
sync_dev, 0); sync_dev, 0);
omap_set_dma_src_params(mcbsp[id].dma_rx_lch, omap_set_dma_src_params(mcbsp->dma_rx_lch,
src_port, src_port,
OMAP_DMA_AMODE_CONSTANT, OMAP_DMA_AMODE_CONSTANT,
mcbsp[id].io_base + OMAP_MCBSP_REG_DRR1, mcbsp->io_base + OMAP_MCBSP_REG_DRR1,
0, 0); 0, 0);
omap_set_dma_dest_params(mcbsp[id].dma_rx_lch, omap_set_dma_dest_params(mcbsp->dma_rx_lch,
dest_port, dest_port,
OMAP_DMA_AMODE_POST_INC, OMAP_DMA_AMODE_POST_INC,
buffer, buffer,
0, 0); 0, 0);
omap_start_dma(mcbsp[id].dma_rx_lch); omap_start_dma(mcbsp->dma_rx_lch);
wait_for_completion(&(mcbsp[id].rx_dma_completion)); wait_for_completion(&mcbsp->rx_dma_completion);
return 0; return 0;
} }
...@@ -737,12 +768,14 @@ EXPORT_SYMBOL(omap_mcbsp_recv_buffer); ...@@ -737,12 +768,14 @@ EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
void omap_mcbsp_set_spi_mode(unsigned int id, void omap_mcbsp_set_spi_mode(unsigned int id,
const struct omap_mcbsp_spi_cfg *spi_cfg) const struct omap_mcbsp_spi_cfg *spi_cfg)
{ {
struct omap_mcbsp *mcbsp;
struct omap_mcbsp_reg_cfg mcbsp_cfg; struct omap_mcbsp_reg_cfg mcbsp_cfg;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return; return;
} }
mcbsp = id_to_mcbsp_ptr(id);
memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg)); memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
...@@ -806,6 +839,7 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode); ...@@ -806,6 +839,7 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
static int __init omap_mcbsp_probe(struct platform_device *pdev) static int __init omap_mcbsp_probe(struct platform_device *pdev)
{ {
struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
struct omap_mcbsp *mcbsp;
int id = pdev->id - 1; int id = pdev->id - 1;
int ret = 0; int ret = 0;
...@@ -818,40 +852,47 @@ static int __init omap_mcbsp_probe(struct platform_device *pdev) ...@@ -818,40 +852,47 @@ static int __init omap_mcbsp_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id); dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id);
if (id >= OMAP_MAX_MCBSP_COUNT) { if (id >= omap_mcbsp_count) {
dev_err(&pdev->dev, "Invalid McBSP device id (%d)\n", id); dev_err(&pdev->dev, "Invalid McBSP device id (%d)\n", id);
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
spin_lock_init(&mcbsp[id].lock); mcbsp = kzalloc(sizeof(struct omap_mcbsp), GFP_KERNEL);
mcbsp[id].id = id + 1; if (!mcbsp) {
mcbsp[id].free = 1; ret = -ENOMEM;
mcbsp[id].dma_tx_lch = -1; goto exit;
mcbsp[id].dma_rx_lch = -1; }
mcbsp_ptr[id] = mcbsp;
spin_lock_init(&mcbsp->lock);
mcbsp->id = id + 1;
mcbsp->free = 1;
mcbsp->dma_tx_lch = -1;
mcbsp->dma_rx_lch = -1;
mcbsp[id].io_base = pdata->virt_base; mcbsp->io_base = pdata->virt_base;
/* Default I/O is IRQ based */ /* Default I/O is IRQ based */
mcbsp[id].io_type = OMAP_MCBSP_IRQ_IO; mcbsp->io_type = OMAP_MCBSP_IRQ_IO;
mcbsp[id].tx_irq = pdata->tx_irq; mcbsp->tx_irq = pdata->tx_irq;
mcbsp[id].rx_irq = pdata->rx_irq; mcbsp->rx_irq = pdata->rx_irq;
mcbsp[id].dma_rx_sync = pdata->dma_rx_sync; mcbsp->dma_rx_sync = pdata->dma_rx_sync;
mcbsp[id].dma_tx_sync = pdata->dma_tx_sync; mcbsp->dma_tx_sync = pdata->dma_tx_sync;
if (pdata->clk_name) if (pdata->clk_name)
mcbsp[id].clk = clk_get(&pdev->dev, pdata->clk_name); mcbsp->clk = clk_get(&pdev->dev, pdata->clk_name);
if (IS_ERR(mcbsp[id].clk)) { if (IS_ERR(mcbsp->clk)) {
mcbsp[id].free = 0; mcbsp->free = 0;
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Invalid clock configuration for McBSP%d.\n", "Invalid clock configuration for McBSP%d.\n",
mcbsp[id].id); mcbsp->id);
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
mcbsp[id].pdata = pdata; mcbsp->pdata = pdata;
mcbsp[id].dev = &pdev->dev; mcbsp->dev = &pdev->dev;
platform_set_drvdata(pdev, &mcbsp[id]); platform_set_drvdata(pdev, mcbsp);
exit: exit:
return ret; return ret;
......
...@@ -81,9 +81,6 @@ ...@@ -81,9 +81,6 @@
#define OMAP_MCBSP_REG_XCERG 0x3A #define OMAP_MCBSP_REG_XCERG 0x3A
#define OMAP_MCBSP_REG_XCERH 0x3C #define OMAP_MCBSP_REG_XCERH 0x3C
#define OMAP_MAX_MCBSP_COUNT 3
#define MAX_MCBSP_CLOCKS 3
#define AUDIO_MCBSP_DATAWRITE (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1) #define AUDIO_MCBSP_DATAWRITE (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1)
#define AUDIO_MCBSP_DATAREAD (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1) #define AUDIO_MCBSP_DATAREAD (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1)
...@@ -125,9 +122,6 @@ ...@@ -125,9 +122,6 @@
#define OMAP_MCBSP_REG_XCERG 0x74 #define OMAP_MCBSP_REG_XCERG 0x74
#define OMAP_MCBSP_REG_XCERH 0x78 #define OMAP_MCBSP_REG_XCERH 0x78
#define OMAP_MAX_MCBSP_COUNT 2
#define MAX_MCBSP_CLOCKS 2
#define AUDIO_MCBSP_DATAWRITE (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1) #define AUDIO_MCBSP_DATAWRITE (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
#define AUDIO_MCBSP_DATAREAD (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1) #define AUDIO_MCBSP_DATAREAD (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
...@@ -311,7 +305,6 @@ struct omap_mcbsp_spi_cfg { ...@@ -311,7 +305,6 @@ struct omap_mcbsp_spi_cfg {
struct omap_mcbsp_ops { struct omap_mcbsp_ops {
void (*request)(unsigned int); void (*request)(unsigned int);
void (*free)(unsigned int); void (*free)(unsigned int);
int (*check)(unsigned int);
}; };
struct omap_mcbsp_platform_data { struct omap_mcbsp_platform_data {
...@@ -352,6 +345,8 @@ struct omap_mcbsp { ...@@ -352,6 +345,8 @@ struct omap_mcbsp {
struct omap_mcbsp_platform_data *pdata; struct omap_mcbsp_platform_data *pdata;
struct clk *clk; struct clk *clk;
}; };
extern struct omap_mcbsp **mcbsp_ptr;
extern int omap_mcbsp_count;
int omap_mcbsp_init(void); int omap_mcbsp_init(void);
void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment