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) {
......
This diff is collapsed.
...@@ -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