Commit b4b58f58 authored by Chandra Shekhar's avatar Chandra Shekhar Committed by Tony Lindgren

ARM: OMAP: Allocate McBSP devices dynamically

Based on Chandra's earlier patches in linux-omap tree.

Note that omap1_mcbsp_check and omap2_mcbsp_check are no longer
needed as there's now omap_mcbsp_check_valid_id() defined.

Also some functions can now be marked __init.
Signed-off-by: default avatarChandra Shekhar <x0044955@ti.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 25cef225
...@@ -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);
......
...@@ -28,7 +28,7 @@ struct mcbsp_internal_clk { ...@@ -28,7 +28,7 @@ struct mcbsp_internal_clk {
int n_childs; int n_childs;
}; };
#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) #if defined(CONFIG_ARCH_OMAP24XX)
static void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk) static void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk)
{ {
const char *clk_names[] = { "mcbsp_ick", "mcbsp_fck" }; const char *clk_names[] = { "mcbsp_ick", "mcbsp_fck" };
...@@ -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
...@@ -185,7 +175,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { ...@@ -185,7 +175,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
#define OMAP34XX_MCBSP_PDATA_SZ 0 #define OMAP34XX_MCBSP_PDATA_SZ 0
#endif #endif
int __init omap2_mcbsp_init(void) static int __init omap2_mcbsp_init(void)
{ {
int i; int i;
...@@ -195,14 +185,20 @@ int __init omap2_mcbsp_init(void) ...@@ -195,14 +185,20 @@ 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())
omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
OMAP34XX_MCBSP_PDATA_SZ);
return omap_mcbsp_init(); return omap_mcbsp_init();
} }
arch_initcall(omap2_mcbsp_init); arch_initcall(omap2_mcbsp_init);
...@@ -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)
...@@ -91,12 +88,14 @@ ...@@ -91,12 +88,14 @@
#define AUDIO_DMA_TX OMAP_DMA_MCBSP1_TX #define AUDIO_DMA_TX OMAP_DMA_MCBSP1_TX
#define AUDIO_DMA_RX OMAP_DMA_MCBSP1_RX #define AUDIO_DMA_RX OMAP_DMA_MCBSP1_RX
#elif defined(CONFIG_ARCH_OMAP24XX) #elif defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
#define OMAP_MCBSP_REG_DRR2 0x00 #define OMAP_MCBSP_REG_DRR2 0x00
#define OMAP_MCBSP_REG_DRR1 0x04 #define OMAP_MCBSP_REG_DRR1 0x04
#define OMAP_MCBSP_REG_DXR2 0x08 #define OMAP_MCBSP_REG_DXR2 0x08
#define OMAP_MCBSP_REG_DXR1 0x0C #define OMAP_MCBSP_REG_DXR1 0x0C
#define OMAP_MCBSP_REG_DRR 0x00
#define OMAP_MCBSP_REG_DXR 0x08
#define OMAP_MCBSP_REG_SPCR2 0x10 #define OMAP_MCBSP_REG_SPCR2 0x10
#define OMAP_MCBSP_REG_SPCR1 0x14 #define OMAP_MCBSP_REG_SPCR1 0x14
#define OMAP_MCBSP_REG_RCR2 0x18 #define OMAP_MCBSP_REG_RCR2 0x18
...@@ -124,9 +123,9 @@ ...@@ -124,9 +123,9 @@
#define OMAP_MCBSP_REG_RCERH 0x70 #define OMAP_MCBSP_REG_RCERH 0x70
#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_MCBSP_REG_SYSCON 0x8C
#define OMAP_MAX_MCBSP_COUNT 2 #define OMAP_MCBSP_REG_XCCR 0xAC
#define MAX_MCBSP_CLOCKS 2 #define OMAP_MCBSP_REG_RCCR 0xB0
#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)
...@@ -137,10 +136,6 @@ ...@@ -137,10 +136,6 @@
#endif #endif
#define OMAP_MCBSP_READ(base, reg) __raw_readw((base) + OMAP_MCBSP_REG_##reg)
#define OMAP_MCBSP_WRITE(base, reg, val) __raw_writew((val), (base) + OMAP_MCBSP_REG_##reg)
/************************** McBSP SPCR1 bit definitions ***********************/ /************************** McBSP SPCR1 bit definitions ***********************/
#define RRST 0x0001 #define RRST 0x0001
#define RRDY 0x0002 #define RRDY 0x0002
...@@ -151,6 +146,7 @@ ...@@ -151,6 +146,7 @@
#define DXENA 0x0080 #define DXENA 0x0080
#define CLKSTP(value) ((value)<<11) /* bits 11:12 */ #define CLKSTP(value) ((value)<<11) /* bits 11:12 */
#define RJUST(value) ((value)<<13) /* bits 13:14 */ #define RJUST(value) ((value)<<13) /* bits 13:14 */
#define ALB 0x8000
#define DLB 0x8000 #define DLB 0x8000
/************************** McBSP SPCR2 bit definitions ***********************/ /************************** McBSP SPCR2 bit definitions ***********************/
...@@ -228,6 +224,17 @@ ...@@ -228,6 +224,17 @@
#define XPABLK(value) ((value)<<5) /* Bits 5:6 */ #define XPABLK(value) ((value)<<5) /* Bits 5:6 */
#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */ #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
/*********************** McBSP XCCR bit definitions *************************/
#define DILB 0x0020
#define XDMAEN 0x0008
#define XDISABLE 0x0001
/********************** McBSP RCCR bit definitions *************************/
#define RDMAEN 0x0008
#define RDISABLE 0x0001
/********************** McBSP SYSCONFIG bit definitions ********************/
#define SOFTRST 0x0002
/* we don't do multichannel for now */ /* we don't do multichannel for now */
struct omap_mcbsp_reg_cfg { struct omap_mcbsp_reg_cfg {
...@@ -311,7 +318,6 @@ struct omap_mcbsp_spi_cfg { ...@@ -311,7 +318,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 {
...@@ -353,6 +359,8 @@ struct omap_mcbsp { ...@@ -353,6 +359,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,
...@@ -377,5 +385,6 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * ...@@ -377,5 +385,6 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
/* Polled read/write functions */ /* Polled read/write functions */
int omap_mcbsp_pollread(unsigned int id, u16 * buf); int omap_mcbsp_pollread(unsigned int id, u16 * buf);
int omap_mcbsp_pollwrite(unsigned int id, u16 buf); int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
#endif #endif
This diff is collapsed.
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