* [PATCH 0/2] Code update for mcbsp driver
@ 2008-04-14 15:52 Eduardo Valentin
2008-04-14 15:53 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Eduardo Valentin
0 siblings, 1 reply; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-14 15:52 UTC (permalink / raw)
To: linux-omap; +Cc: Eduardo
From: Eduardo <eduardo.valentin@indt.org.br>
Hi all,
This patch series updates the mcbsp driver. It cleans up several
coding style errors and also moves code to mach- specific place.
Comments are wellcome.
Cheers,
Eduardo Valentin (2):
PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
arch/arm/mach-omap1/Makefile | 2 +
arch/arm/mach-omap2/Makefile | 2 +
arch/arm/plat-omap/mcbsp.c | 501 ++++++++++---------------------------
include/asm-arm/arch-omap/mcbsp.h | 19 ++
4 files changed, 151 insertions(+), 373 deletions(-)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
2008-04-14 15:52 [PATCH 0/2] Code update for mcbsp driver Eduardo Valentin
@ 2008-04-14 15:53 ` Eduardo Valentin
2008-04-14 15:53 ` [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap Eduardo Valentin
2008-04-14 18:16 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Felipe Balbi
0 siblings, 2 replies; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-14 15:53 UTC (permalink / raw)
To: linux-omap; +Cc: Eduardo Valentin
From: Eduardo Valentin <eduardo.valentin@indt.org.br>
This patch fix lots of warnings and errors reported by
scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
arch/arm/plat-omap/mcbsp.c | 197 +++++++++++++++++++++++---------------------
1 files changed, 102 insertions(+), 95 deletions(-)
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 9cf83c4..28cd501 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -21,9 +21,8 @@
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/delay.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
+#include <linux/io.h>
+#include <linux/irq.h>
#include <asm/arch/dma.h>
#include <asm/arch/mux.h>
@@ -66,15 +65,15 @@ struct omap_mcbsp {
static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
#ifdef CONFIG_ARCH_OMAP1
-static struct clk *mcbsp_dsp_ck = 0;
-static struct clk *mcbsp_api_ck = 0;
-static struct clk *mcbsp_dspxor_ck = 0;
+static struct clk *mcbsp_dsp_ck;
+static struct clk *mcbsp_api_ck;
+static struct clk *mcbsp_dspxor_ck;
#endif
#ifdef CONFIG_ARCH_OMAP2
-static struct clk *mcbsp1_ick = 0;
-static struct clk *mcbsp1_fck = 0;
-static struct clk *mcbsp2_ick = 0;
-static struct clk *mcbsp2_fck = 0;
+static struct clk *mcbsp1_ick;
+static struct clk *mcbsp1_fck;
+static struct clk *mcbsp2_ick;
+static struct clk *mcbsp2_fck;
#endif
static void omap_mcbsp_dump_reg(u8 id)
@@ -104,6 +103,7 @@ static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2));
complete(&mcbsp_tx->tx_irq_completion);
+
return IRQ_HANDLED;
}
@@ -115,6 +115,7 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id)
OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR2));
complete(&mcbsp_rx->rx_irq_completion);
+
return IRQ_HANDLED;
}
@@ -146,19 +147,17 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
complete(&mcbsp_dma_rx->rx_dma_completion);
}
-
/*
* omap_mcbsp_config simply write a config to the
* appropriate McBSP.
* You either call this function or set the McBSP registers
* by yourself before calling omap_mcbsp_start().
*/
-
-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)
{
u32 io_base = mcbsp[id].io_base;
- DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id+1, io_base);
+ DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id + 1, io_base);
/* We write the given config */
OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2);
@@ -173,14 +172,14 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config
OMAP_MCBSP_WRITE(io_base, MCR1, config->mcr1);
OMAP_MCBSP_WRITE(io_base, PCR0, config->pcr0);
}
-
-
+EXPORT_SYMBOL(omap_mcbsp_config);
static int omap_mcbsp_check(unsigned int id)
{
if (cpu_is_omap730()) {
if (id > OMAP_MAX_MCBSP_COUNT - 1) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
+ id + 1);
return -1;
}
return 0;
@@ -188,7 +187,8 @@ static int omap_mcbsp_check(unsigned int id)
if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
if (id > OMAP_MAX_MCBSP_COUNT) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
+ id + 1);
return -1;
}
return 0;
@@ -263,7 +263,8 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
spin_lock(&mcbsp[id].lock);
if (!mcbsp[id].free) {
- printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
+ id + 1);
spin_unlock(&mcbsp[id].lock);
return -EINVAL;
}
@@ -274,6 +275,7 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_set_io_type);
int omap_mcbsp_request(unsigned int id)
{
@@ -305,7 +307,8 @@ int omap_mcbsp_request(unsigned int id)
spin_lock(&mcbsp[id].lock);
if (!mcbsp[id].free) {
- printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
+ id + 1);
spin_unlock(&mcbsp[id].lock);
return -1;
}
@@ -315,24 +318,23 @@ int omap_mcbsp_request(unsigned int id)
if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) {
/* We need to get IRQs here */
- err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, 0,
- "McBSP",
- (void *) (&mcbsp[id]));
+ err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler,
+ 0, "McBSP", (void *) (&mcbsp[id]));
if (err != 0) {
- printk(KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n",
- mcbsp[id].tx_irq, mcbsp[id].id);
+ printk(KERN_ERR "OMAP-McBSP: Unable to "
+ "request TX IRQ %d for McBSP%d\n",
+ mcbsp[id].tx_irq, mcbsp[id].id);
return err;
}
init_completion(&(mcbsp[id].tx_irq_completion));
-
- err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, 0,
- "McBSP",
- (void *) (&mcbsp[id]));
+ err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler,
+ 0, "McBSP", (void *) (&mcbsp[id]));
if (err != 0) {
- printk(KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n",
- mcbsp[id].rx_irq, mcbsp[id].id);
+ printk(KERN_ERR "OMAP-McBSP: Unable to "
+ "request RX IRQ %d for McBSP%d\n",
+ mcbsp[id].rx_irq, mcbsp[id].id);
free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
return err;
}
@@ -341,8 +343,8 @@ int omap_mcbsp_request(unsigned int id)
}
return 0;
-
}
+EXPORT_SYMBOL(omap_mcbsp_request);
void omap_mcbsp_free(unsigned int id)
{
@@ -370,7 +372,8 @@ void omap_mcbsp_free(unsigned int id)
spin_lock(&mcbsp[id].lock);
if (mcbsp[id].free) {
- printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n",
+ id + 1);
spin_unlock(&mcbsp[id].lock);
return;
}
@@ -384,6 +387,7 @@ void omap_mcbsp_free(unsigned int id)
free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
}
}
+EXPORT_SYMBOL(omap_mcbsp_free);
/*
* Here we start the McBSP, by enabling the sample
@@ -400,8 +404,8 @@ void omap_mcbsp_start(unsigned int id)
io_base = mcbsp[id].io_base;
- 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);
+ 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 */
w = OMAP_MCBSP_READ(io_base, SPCR2);
@@ -422,8 +426,8 @@ void omap_mcbsp_start(unsigned int id)
/* Dump McBSP Regs */
omap_mcbsp_dump_reg(id);
-
}
+EXPORT_SYMBOL(omap_mcbsp_start);
void omap_mcbsp_stop(unsigned int id)
{
@@ -435,7 +439,7 @@ void omap_mcbsp_stop(unsigned int id)
io_base = mcbsp[id].io_base;
- /* Reset transmitter */
+ /* Reset transmitter */
w = OMAP_MCBSP_READ(io_base, SPCR2);
OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1));
@@ -447,7 +451,7 @@ void omap_mcbsp_stop(unsigned int id)
w = OMAP_MCBSP_READ(io_base, SPCR2);
OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1 << 6));
}
-
+EXPORT_SYMBOL(omap_mcbsp_stop);
/* polled mcbsp i/o operations */
int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
@@ -480,10 +484,12 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
}
}
}
+
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_pollwrite);
-int omap_mcbsp_pollread(unsigned int id, u16 * buf)
+int omap_mcbsp_pollread(unsigned int id, u16 *buf)
{
u32 base = mcbsp[id].io_base;
/* if frame sync error - clear the error */
@@ -513,8 +519,10 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf)
}
}
*buf = readw(base + OMAP_MCBSP_REG_DRR1);
+
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_pollread);
/*
* IRQ based word transmission.
@@ -535,6 +543,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
}
+EXPORT_SYMBOL(omap_mcbsp_xmit_word);
u32 omap_mcbsp_recv_word(unsigned int id)
{
@@ -555,7 +564,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
return (word_lsb | (word_msb << 16));
}
-
+EXPORT_SYMBOL(omap_mcbsp_recv_word);
int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
{
@@ -577,7 +586,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
udelay(10);
- printk("McBSP transmitter not ready\n");
+ printk(KERN_ERR "McBSP transmitter not ready\n");
return -EAGAIN;
}
}
@@ -597,7 +606,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
udelay(10);
- printk("McBSP receiver not ready\n");
+ printk(KERN_ERR "McBSP receiver not ready\n");
return -EAGAIN;
}
}
@@ -609,8 +618,9 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
return 0;
}
+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)
{
u32 io_base = mcbsp[id].io_base, clock_word = 0;
omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
@@ -630,7 +640,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
udelay(10);
- printk("McBSP transmitter not ready\n");
+ printk(KERN_ERR "McBSP transmitter not ready\n");
return -EAGAIN;
}
}
@@ -650,7 +660,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
udelay(10);
- printk("McBSP receiver not ready\n");
+ printk(KERN_ERR "McBSP receiver not ready\n");
return -EAGAIN;
}
}
@@ -664,7 +674,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
return 0;
}
-
+EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
/*
* Simple DMA based buffer rx/tx routines.
@@ -673,7 +683,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
* For anything fancier, you should use your own customized DMA
* routines and callbacks.
*/
-int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
+int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
+ unsigned int length)
{
int dma_tx_ch;
int src_port = 0;
@@ -683,10 +694,12 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
if (omap_mcbsp_check(id) < 0)
return -EINVAL;
- if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX", omap_mcbsp_tx_dma_callback,
- &mcbsp[id],
- &dma_tx_ch)) {
- printk("OMAP-McBSP: Unable to request DMA channel for McBSP%d TX. Trying IRQ based TX\n", id+1);
+ if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
+ omap_mcbsp_tx_dma_callback,
+ &mcbsp[id],
+ &dma_tx_ch)) {
+ printk(KERN_ERR "OMAP-McBSP: Unable to request DMA channel for"
+ " McBSP%d TX. Trying IRQ based TX\n", id + 1);
return -EAGAIN;
}
mcbsp[id].dma_tx_lch = dma_tx_ch;
@@ -722,11 +735,13 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
omap_start_dma(mcbsp[id].dma_tx_lch);
wait_for_completion(&(mcbsp[id].tx_dma_completion));
+
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
-
-int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
+int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
+ unsigned int length)
{
int dma_rx_ch;
int src_port = 0;
@@ -736,10 +751,12 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
if (omap_mcbsp_check(id) < 0)
return -EINVAL;
- if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX", omap_mcbsp_rx_dma_callback,
- &mcbsp[id],
- &dma_rx_ch)) {
- printk("Unable to request DMA channel for McBSP%d RX. Trying IRQ based RX\n", id+1);
+ if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
+ omap_mcbsp_rx_dma_callback,
+ &mcbsp[id],
+ &dma_rx_ch)) {
+ printk(KERN_ERR "Unable to request DMA channel for McBSP%d RX."
+ " Trying IRQ based RX\n", id + 1);
return -EAGAIN;
}
mcbsp[id].dma_rx_lch = dma_rx_ch;
@@ -756,10 +773,10 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
sync_dev = mcbsp[id].dma_rx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
- OMAP_DMA_DATA_TYPE_S16,
- length >> 1, 1,
- OMAP_DMA_SYNC_ELEMENT,
- sync_dev, 0);
+ OMAP_DMA_DATA_TYPE_S16,
+ length >> 1, 1,
+ OMAP_DMA_SYNC_ELEMENT,
+ sync_dev, 0);
omap_set_dma_src_params(mcbsp[id].dma_rx_lch,
src_port,
@@ -768,16 +785,17 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
0, 0);
omap_set_dma_dest_params(mcbsp[id].dma_rx_lch,
- dest_port,
- OMAP_DMA_AMODE_POST_INC,
- buffer,
- 0, 0);
+ dest_port,
+ OMAP_DMA_AMODE_POST_INC,
+ buffer,
+ 0, 0);
omap_start_dma(mcbsp[id].dma_rx_lch);
wait_for_completion(&(mcbsp[id].rx_dma_completion));
+
return 0;
}
-
+EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
/*
* SPI wrapper.
@@ -785,7 +803,8 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
* this wrapper just need an omap_mcbsp_spi_cfg structure as an input.
* Once this is done, you can call omap_mcbsp_start().
*/
-void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg)
+void omap_mcbsp_set_spi_mode(unsigned int id,
+ const struct omap_mcbsp_spi_cfg *spi_cfg)
{
struct omap_mcbsp_reg_cfg mcbsp_cfg;
@@ -798,7 +817,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
mcbsp_cfg.rcr1 |= (RWDLEN1(spi_cfg->word_length) | RFRLEN1(0));
mcbsp_cfg.xcr1 |= (XWDLEN1(spi_cfg->word_length) | XFRLEN1(0));
- /* Clock stop mode */
+ /* Clock stop mode */
if (spi_cfg->clk_stp_mode == OMAP_MCBSP_CLK_STP_MODE_NO_DELAY)
mcbsp_cfg.spcr1 |= (1 << 12);
else
@@ -827,13 +846,12 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
if (spi_cfg->spi_mode == OMAP_MCBSP_SPI_MASTER) {
mcbsp_cfg.pcr0 |= CLKXM;
- mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div -1);
+ mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div - 1);
mcbsp_cfg.pcr0 |= FSXM;
mcbsp_cfg.srgr2 &= ~FSGM;
mcbsp_cfg.xcr2 |= XDATDLY(1);
mcbsp_cfg.rcr2 |= RDATDLY(1);
- }
- else {
+ } else {
mcbsp_cfg.pcr0 &= ~CLKXM;
mcbsp_cfg.srgr1 |= CLKGDV(1);
mcbsp_cfg.pcr0 &= ~FSXM;
@@ -846,7 +864,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
omap_mcbsp_config(id, &mcbsp_cfg);
}
-
+EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
/*
* McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
@@ -935,7 +953,7 @@ static int __init omap_mcbsp_init(void)
int mcbsp_count = 0, i;
static const struct omap_mcbsp_info *mcbsp_info;
- printk("Initializing OMAP McBSP system\n");
+ printk(KERN_INFO "Initializing OMAP McBSP system\n");
#ifdef CONFIG_ARCH_OMAP1
mcbsp_dsp_ck = clk_get(0, "dsp_ck");
@@ -957,22 +975,26 @@ static int __init omap_mcbsp_init(void)
#ifdef CONFIG_ARCH_OMAP2
mcbsp1_ick = clk_get(0, "mcbsp1_ick");
if (IS_ERR(mcbsp1_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp1_ick handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp1_ick handle.\n");
return PTR_ERR(mcbsp1_ick);
}
mcbsp1_fck = clk_get(0, "mcbsp1_fck");
if (IS_ERR(mcbsp1_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp1_fck handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp1_fck handle.\n");
return PTR_ERR(mcbsp1_fck);
}
mcbsp2_ick = clk_get(0, "mcbsp2_ick");
if (IS_ERR(mcbsp2_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp2_ick handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp2_ick handle.\n");
return PTR_ERR(mcbsp2_ick);
}
mcbsp2_fck = clk_get(0, "mcbsp2_fck");
if (IS_ERR(mcbsp2_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp2_fck handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp2_fck handle.\n");
return PTR_ERR(mcbsp2_fck);
}
#endif
@@ -1006,7 +1028,7 @@ static int __init omap_mcbsp_init(void)
if (i >= mcbsp_count) {
mcbsp[i].io_base = 0;
mcbsp[i].free = 0;
- continue;
+ continue;
}
mcbsp[i].id = i + 1;
mcbsp[i].free = 1;
@@ -1014,7 +1036,8 @@ static int __init omap_mcbsp_init(void)
mcbsp[i].dma_rx_lch = -1;
mcbsp[i].io_base = mcbsp_info[i].virt_base;
- mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO; /* Default I/O is IRQ based */
+ /* Default I/O is IRQ based */
+ mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
@@ -1026,19 +1049,3 @@ static int __init omap_mcbsp_init(void)
}
arch_initcall(omap_mcbsp_init);
-
-EXPORT_SYMBOL(omap_mcbsp_config);
-EXPORT_SYMBOL(omap_mcbsp_request);
-EXPORT_SYMBOL(omap_mcbsp_set_io_type);
-EXPORT_SYMBOL(omap_mcbsp_free);
-EXPORT_SYMBOL(omap_mcbsp_start);
-EXPORT_SYMBOL(omap_mcbsp_stop);
-EXPORT_SYMBOL(omap_mcbsp_pollread);
-EXPORT_SYMBOL(omap_mcbsp_pollwrite);
-EXPORT_SYMBOL(omap_mcbsp_xmit_word);
-EXPORT_SYMBOL(omap_mcbsp_recv_word);
-EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
-EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
-EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
-EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
-EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
--
1.5.5-rc3.GIT
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 15:53 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Eduardo Valentin
@ 2008-04-14 15:53 ` Eduardo Valentin
2008-04-14 18:18 ` Felipe Balbi
2008-04-14 18:16 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Felipe Balbi
1 sibling, 1 reply; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-14 15:53 UTC (permalink / raw)
To: linux-omap; +Cc: Eduardo Valentin
From: Eduardo Valentin <eduardo.valentin@indt.org.br>
This patch gets ride of ifdefs on mcbsp.c code.
It moves the mach specific code to mach-omap*.
Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
arch/arm/mach-omap1/Makefile | 2 +
arch/arm/mach-omap2/Makefile | 2 +
arch/arm/plat-omap/mcbsp.c | 346 +++++--------------------------------
include/asm-arm/arch-omap/mcbsp.h | 19 ++
4 files changed, 70 insertions(+), 299 deletions(-)
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index 6ebf23b..09246a7 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -5,6 +5,8 @@
# Common support
obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
+obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
+
obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 5157ff2..771f8e7 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -6,6 +6,8 @@
obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
devices.o serial.o gpmc.o timer-gp.o
+obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
+
# Functions loaded to SRAM
obj-$(CONFIG_ARCH_OMAP2) += sram24xx.o
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 28cd501..416bf7d 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -24,11 +24,8 @@
#include <linux/io.h>
#include <linux/irq.h>
-#include <asm/arch/dma.h>
-#include <asm/arch/mux.h>
-#include <asm/arch/irqs.h>
-#include <asm/arch/dsp_common.h>
#include <asm/arch/mcbsp.h>
+#include <asm/arch/dma.h>
#ifdef CONFIG_MCBSP_DEBUG
#define DBG(x...) printk(x)
@@ -64,17 +61,10 @@ struct omap_mcbsp {
};
static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
-#ifdef CONFIG_ARCH_OMAP1
-static struct clk *mcbsp_dsp_ck;
-static struct clk *mcbsp_api_ck;
-static struct clk *mcbsp_dspxor_ck;
-#endif
-#ifdef CONFIG_ARCH_OMAP2
-static struct clk *mcbsp1_ick;
-static struct clk *mcbsp1_fck;
-static struct clk *mcbsp2_ick;
-static struct clk *mcbsp2_fck;
-#endif
+static const struct omap_mcbsp_board_cfg *mcbsp_config;
+
+#define omap_mcbsp_check_invalid_id(id) (mcbsp_config && mcbsp_config->check \
+ && (mcbsp_config->check(id) < 0))
static void omap_mcbsp_dump_reg(u8 id)
{
@@ -174,90 +164,13 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
}
EXPORT_SYMBOL(omap_mcbsp_config);
-static int omap_mcbsp_check(unsigned int id)
-{
- if (cpu_is_omap730()) {
- if (id > OMAP_MAX_MCBSP_COUNT - 1) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
- id + 1);
- return -1;
- }
- return 0;
- }
-
- if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
- if (id > OMAP_MAX_MCBSP_COUNT) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
- id + 1);
- return -1;
- }
- return 0;
- }
-
- return -1;
-}
-
-#ifdef CONFIG_ARCH_OMAP1
-static void omap_mcbsp_dsp_request(void)
-{
- if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
- int ret;
-
- ret = omap_dsp_request_mem();
- if (ret < 0) {
- printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
- return;
- }
-
- clk_enable(mcbsp_dsp_ck);
- clk_enable(mcbsp_api_ck);
-
- /* enable 12MHz clock to mcbsp 1 & 3 */
- clk_enable(mcbsp_dspxor_ck);
-
- /*
- * DSP external peripheral reset
- * FIXME: This should be moved to dsp code
- */
- __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
- DSP_RSTCT2);
- }
-}
-
-static void omap_mcbsp_dsp_free(void)
-{
- if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
- omap_dsp_release_mem();
- clk_disable(mcbsp_dspxor_ck);
- clk_disable(mcbsp_dsp_ck);
- clk_disable(mcbsp_api_ck);
- }
-}
-#endif
-
-#ifdef CONFIG_ARCH_OMAP2
-static void omap2_mcbsp2_mux_setup(void)
-{
- if (cpu_is_omap2420()) {
- omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
- omap_cfg_reg(R14_24XX_MCBSP2_FSX);
- omap_cfg_reg(W15_24XX_MCBSP2_DR);
- omap_cfg_reg(V15_24XX_MCBSP2_DX);
- omap_cfg_reg(V14_24XX_GPIO117);
- }
- /*
- * Need to add MUX settings for OMAP 2430 SDP
- */
-}
-#endif
-
/*
* We can choose between IRQ based or polled IO.
* This needs to be called before omap_mcbsp_request().
*/
int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
{
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
spin_lock(&mcbsp[id].lock);
@@ -281,29 +194,11 @@ int omap_mcbsp_request(unsigned int id)
{
int err;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
-#ifdef CONFIG_ARCH_OMAP1
- /*
- * On 1510, 1610 and 1710, McBSP1 and McBSP3
- * are DSP public peripherals.
- */
- if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
- omap_mcbsp_dsp_request();
-#endif
-
-#ifdef CONFIG_ARCH_OMAP2
- if (cpu_is_omap24xx()) {
- if (id == OMAP_MCBSP1) {
- clk_enable(mcbsp1_ick);
- clk_enable(mcbsp1_fck);
- } else {
- clk_enable(mcbsp2_ick);
- clk_enable(mcbsp2_fck);
- }
- }
-#endif
+ if (mcbsp_config && mcbsp_config->request)
+ mcbsp_config->request(id);
spin_lock(&mcbsp[id].lock);
if (!mcbsp[id].free) {
@@ -348,27 +243,11 @@ EXPORT_SYMBOL(omap_mcbsp_request);
void omap_mcbsp_free(unsigned int id)
{
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
-#ifdef CONFIG_ARCH_OMAP1
- if (cpu_class_is_omap1()) {
- if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
- omap_mcbsp_dsp_free();
- }
-#endif
-
-#ifdef CONFIG_ARCH_OMAP2
- if (cpu_is_omap24xx()) {
- if (id == OMAP_MCBSP1) {
- clk_disable(mcbsp1_ick);
- clk_disable(mcbsp1_fck);
- } else {
- clk_disable(mcbsp2_ick);
- clk_disable(mcbsp2_fck);
- }
- }
-#endif
+ if (mcbsp_config && mcbsp_config->free)
+ mcbsp_config->free(id);
spin_lock(&mcbsp[id].lock);
if (mcbsp[id].free) {
@@ -399,7 +278,7 @@ void omap_mcbsp_start(unsigned int id)
u32 io_base;
u16 w;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
io_base = mcbsp[id].io_base;
@@ -434,7 +313,7 @@ void omap_mcbsp_stop(unsigned int id)
u32 io_base;
u16 w;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
io_base = mcbsp[id].io_base;
@@ -532,7 +411,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
u32 io_base;
omap_mcbsp_word_length word_length = mcbsp[id].tx_word_length;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
io_base = mcbsp[id].io_base;
@@ -551,7 +430,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
u16 word_lsb, word_msb = 0;
omap_mcbsp_word_length word_length = mcbsp[id].rx_word_length;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
io_base = mcbsp[id].io_base;
@@ -691,7 +570,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
int dest_port = 0;
int sync_dev = 0;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
@@ -712,7 +591,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
src_port = OMAP_DMA_PORT_TIPB;
dest_port = OMAP_DMA_PORT_EMIFF;
}
- if (cpu_is_omap24xx())
+ if (cpu_class_is_omap2())
sync_dev = mcbsp[id].dma_tx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
@@ -748,7 +627,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
int dest_port = 0;
int sync_dev = 0;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
@@ -769,7 +648,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
src_port = OMAP_DMA_PORT_TIPB;
dest_port = OMAP_DMA_PORT_EMIFF;
}
- if (cpu_is_omap24xx())
+ if (cpu_class_is_omap2())
sync_dev = mcbsp[id].dma_rx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
@@ -808,7 +687,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id,
{
struct omap_mcbsp_reg_cfg mcbsp_cfg;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
@@ -870,162 +749,19 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
* McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
* 730 has only 2 McBSP, and both of them are MPU peripherals.
*/
-struct omap_mcbsp_info {
- u32 virt_base;
- u8 dma_rx_sync, dma_tx_sync;
- u16 rx_irq, tx_irq;
-};
-
-#ifdef CONFIG_ARCH_OMAP730
-static const struct omap_mcbsp_info mcbsp_730[] = {
- [0] = { .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
- .rx_irq = INT_730_McBSP1RX,
- .tx_irq = INT_730_McBSP1TX },
- [1] = { .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
- .rx_irq = INT_730_McBSP2RX,
- .tx_irq = INT_730_McBSP2TX },
-};
-#endif
-
-#ifdef CONFIG_ARCH_OMAP15XX
-static const struct omap_mcbsp_info mcbsp_1510[] = {
- [0] = { .virt_base = OMAP1510_MCBSP1_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
- .rx_irq = INT_McBSP1RX,
- .tx_irq = INT_McBSP1TX },
- [1] = { .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
- .rx_irq = INT_1510_SPI_RX,
- .tx_irq = INT_1510_SPI_TX },
- [2] = { .virt_base = OMAP1510_MCBSP3_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
- .rx_irq = INT_McBSP3RX,
- .tx_irq = INT_McBSP3TX },
-};
-#endif
-
-#if defined(CONFIG_ARCH_OMAP16XX)
-static const struct omap_mcbsp_info mcbsp_1610[] = {
- [0] = { .virt_base = OMAP1610_MCBSP1_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
- .rx_irq = INT_McBSP1RX,
- .tx_irq = INT_McBSP1TX },
- [1] = { .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
- .rx_irq = INT_1610_McBSP2_RX,
- .tx_irq = INT_1610_McBSP2_TX },
- [2] = { .virt_base = OMAP1610_MCBSP3_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
- .rx_irq = INT_McBSP3RX,
- .tx_irq = INT_McBSP3TX },
-};
-#endif
-
-#if defined(CONFIG_ARCH_OMAP24XX)
-static const struct omap_mcbsp_info mcbsp_24xx[] = {
- [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
- .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
- .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
- .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
- },
- [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
- .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
- .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
- .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
- .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
- },
-};
-#endif
-
-static int __init omap_mcbsp_init(void)
+int __init omap_mcbsp_init(void)
{
- int mcbsp_count = 0, i;
- static const struct omap_mcbsp_info *mcbsp_info;
+ int i;
- printk(KERN_INFO "Initializing OMAP McBSP system\n");
-
-#ifdef CONFIG_ARCH_OMAP1
- mcbsp_dsp_ck = clk_get(0, "dsp_ck");
- if (IS_ERR(mcbsp_dsp_ck)) {
- printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
- return PTR_ERR(mcbsp_dsp_ck);
- }
- mcbsp_api_ck = clk_get(0, "api_ck");
- if (IS_ERR(mcbsp_api_ck)) {
- printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
- return PTR_ERR(mcbsp_api_ck);
- }
- mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
- if (IS_ERR(mcbsp_dspxor_ck)) {
- printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
- return PTR_ERR(mcbsp_dspxor_ck);
- }
-#endif
-#ifdef CONFIG_ARCH_OMAP2
- mcbsp1_ick = clk_get(0, "mcbsp1_ick");
- if (IS_ERR(mcbsp1_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp1_ick handle.\n");
- return PTR_ERR(mcbsp1_ick);
- }
- mcbsp1_fck = clk_get(0, "mcbsp1_fck");
- if (IS_ERR(mcbsp1_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp1_fck handle.\n");
- return PTR_ERR(mcbsp1_fck);
- }
- mcbsp2_ick = clk_get(0, "mcbsp2_ick");
- if (IS_ERR(mcbsp2_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp2_ick handle.\n");
- return PTR_ERR(mcbsp2_ick);
- }
- mcbsp2_fck = clk_get(0, "mcbsp2_fck");
- if (IS_ERR(mcbsp2_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp2_fck handle.\n");
- return PTR_ERR(mcbsp2_fck);
+ if (!mcbsp_config) {
+ printk(KERN_ERR "McBSP initialized without configuration\n");
+ return -EINVAL;
}
-#endif
-#ifdef CONFIG_ARCH_OMAP730
- if (cpu_is_omap730()) {
- mcbsp_info = mcbsp_730;
- mcbsp_count = ARRAY_SIZE(mcbsp_730);
- }
-#endif
-#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap15xx()) {
- mcbsp_info = mcbsp_1510;
- mcbsp_count = ARRAY_SIZE(mcbsp_1510);
- }
-#endif
-#if defined(CONFIG_ARCH_OMAP16XX)
- if (cpu_is_omap16xx()) {
- mcbsp_info = mcbsp_1610;
- mcbsp_count = ARRAY_SIZE(mcbsp_1610);
- }
-#endif
-#if defined(CONFIG_ARCH_OMAP24XX)
- if (cpu_is_omap24xx()) {
- mcbsp_info = mcbsp_24xx;
- mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
- omap2_mcbsp2_mux_setup();
- }
-#endif
+ printk(KERN_INFO "Initializing OMAP McBSP system\n");
+
for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
- if (i >= mcbsp_count) {
+ if (i >= ARRAY_SIZE(mcbsp_config->mcbsp_infos)) {
mcbsp[i].io_base = 0;
mcbsp[i].free = 0;
continue;
@@ -1035,17 +771,29 @@ static int __init omap_mcbsp_init(void)
mcbsp[i].dma_tx_lch = -1;
mcbsp[i].dma_rx_lch = -1;
- mcbsp[i].io_base = mcbsp_info[i].virt_base;
+ mcbsp[i].io_base = mcbsp_config->mcbsp_infos[i].virt_base;
/* Default I/O is IRQ based */
mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
- mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
- mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
- mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
- mcbsp[i].dma_tx_sync = mcbsp_info[i].dma_tx_sync;
+ mcbsp[i].tx_irq = mcbsp_config->mcbsp_infos[i].tx_irq;
+ mcbsp[i].rx_irq = mcbsp_config->mcbsp_infos[i].rx_irq;
+ mcbsp[i].dma_rx_sync = mcbsp_config->mcbsp_infos[i].dma_rx_sync;
+ mcbsp[i].dma_tx_sync = mcbsp_config->mcbsp_infos[i].dma_tx_sync;
spin_lock_init(&mcbsp[i].lock);
}
return 0;
}
-arch_initcall(omap_mcbsp_init);
+int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config)
+{
+ if (!config || !config->request || !config->free) {
+ printk(KERN_ERR "Invalid McBSP configuration\n");
+ return -EINVAL;
+ }
+
+ mcbsp_config = config;
+
+ return 0;
+
+}
+
diff --git a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
index b53c3b2..fc53a45 100644
--- a/include/asm-arm/arch-omap/mcbsp.h
+++ b/include/asm-arm/arch-omap/mcbsp.h
@@ -40,6 +40,9 @@
#define OMAP24XX_MCBSP1_BASE 0x48074000
#define OMAP24XX_MCBSP2_BASE 0x48076000
+#define OMAP34XX_MCBSP1_BASE 0x48074000
+#define OMAP34XX_MCBSP2_BASE 0x49022000
+
#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
#define OMAP_MCBSP_REG_DRR2 0x00
@@ -298,6 +301,22 @@ struct omap_mcbsp_spi_cfg {
omap_mcbsp_word_length word_length;
};
+/* Board specific configuration */
+struct omap_mcbsp_info {
+ u32 virt_base;
+ u8 dma_rx_sync, dma_tx_sync;
+ u16 rx_irq, tx_irq;
+};
+
+struct omap_mcbsp_board_cfg {
+ void (*request)(unsigned int);
+ void (*free)(unsigned int);
+ int (*check)(unsigned int);
+ struct omap_mcbsp_info mcbsp_infos[OMAP_MAX_MCBSP_COUNT];
+};
+
+int omap_mcbsp_init(void);
+int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config);
void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
int omap_mcbsp_request(unsigned int id);
void omap_mcbsp_free(unsigned int id);
--
1.5.5-rc3.GIT
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
2008-04-14 15:53 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Eduardo Valentin
2008-04-14 15:53 ` [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap Eduardo Valentin
@ 2008-04-14 18:16 ` Felipe Balbi
2008-04-14 20:24 ` Eduardo Valentin
1 sibling, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2008-04-14 18:16 UTC (permalink / raw)
To: Eduardo Valentin; +Cc: linux-omap, Eduardo Valentin
On Mon, Apr 14, 2008 at 11:53:00AM -0400, Eduardo Valentin wrote:
> From: Eduardo Valentin <eduardo.valentin@indt.org.br>
>
> This patch fix lots of warnings and errors reported by
> scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
Hi, if you're touching mcbsp.c could you please also take a look at
this:
$ scripts/checkpatch.pl --strict --file arch/arm/plat-omap/mcbsp.c
CHECK: spinlock_t definition without comment
#60: FILE: arm/plat-omap/mcbsp.c:60:
+ spinlock_t lock;
total: 0 errors, 0 warnings, 1 checks, 799 lines checked
arch/arm/plat-omap/mcbsp.c has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
maybe you could just add this comment and resend this same patch ?
--
Best Regards,
Felipe Balbi
me@felipebalbi.com
http://blog.felipebalbi.com
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 15:53 ` [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap Eduardo Valentin
@ 2008-04-14 18:18 ` Felipe Balbi
2008-04-14 20:11 ` Eduardo Valentin
0 siblings, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2008-04-14 18:18 UTC (permalink / raw)
To: Eduardo Valentin; +Cc: linux-omap, Eduardo Valentin
On Mon, Apr 14, 2008 at 11:53:01AM -0400, Eduardo Valentin wrote:
> From: Eduardo Valentin <eduardo.valentin@indt.org.br>
>
> This patch gets ride of ifdefs on mcbsp.c code.
> It moves the mach specific code to mach-omap*.
I don't see the new files here. Did you forgot to git add them?
in any case, this is a really good idea ;-)
>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> ---
> arch/arm/mach-omap1/Makefile | 2 +
> arch/arm/mach-omap2/Makefile | 2 +
> arch/arm/plat-omap/mcbsp.c | 346 +++++--------------------------------
> include/asm-arm/arch-omap/mcbsp.h | 19 ++
> 4 files changed, 70 insertions(+), 299 deletions(-)
>
> diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
> index 6ebf23b..09246a7 100644
> --- a/arch/arm/mach-omap1/Makefile
> +++ b/arch/arm/mach-omap1/Makefile
> @@ -5,6 +5,8 @@
> # Common support
> obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
> obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
>
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 5157ff2..771f8e7 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -6,6 +6,8 @@
> obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
> devices.o serial.o gpmc.o timer-gp.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> # Functions loaded to SRAM
> obj-$(CONFIG_ARCH_OMAP2) += sram24xx.o
>
> diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
> index 28cd501..416bf7d 100644
> --- a/arch/arm/plat-omap/mcbsp.c
> +++ b/arch/arm/plat-omap/mcbsp.c
> @@ -24,11 +24,8 @@
> #include <linux/io.h>
> #include <linux/irq.h>
>
> -#include <asm/arch/dma.h>
> -#include <asm/arch/mux.h>
> -#include <asm/arch/irqs.h>
> -#include <asm/arch/dsp_common.h>
> #include <asm/arch/mcbsp.h>
> +#include <asm/arch/dma.h>
>
> #ifdef CONFIG_MCBSP_DEBUG
> #define DBG(x...) printk(x)
> @@ -64,17 +61,10 @@ struct omap_mcbsp {
> };
>
> static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
> -#ifdef CONFIG_ARCH_OMAP1
> -static struct clk *mcbsp_dsp_ck;
> -static struct clk *mcbsp_api_ck;
> -static struct clk *mcbsp_dspxor_ck;
> -#endif
> -#ifdef CONFIG_ARCH_OMAP2
> -static struct clk *mcbsp1_ick;
> -static struct clk *mcbsp1_fck;
> -static struct clk *mcbsp2_ick;
> -static struct clk *mcbsp2_fck;
> -#endif
> +static const struct omap_mcbsp_board_cfg *mcbsp_config;
> +
> +#define omap_mcbsp_check_invalid_id(id) (mcbsp_config && mcbsp_config->check \
> + && (mcbsp_config->check(id) < 0))
>
> static void omap_mcbsp_dump_reg(u8 id)
> {
> @@ -174,90 +164,13 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
> }
> EXPORT_SYMBOL(omap_mcbsp_config);
>
> -static int omap_mcbsp_check(unsigned int id)
> -{
> - if (cpu_is_omap730()) {
> - if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
> - if (id > OMAP_MAX_MCBSP_COUNT) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - return -1;
> -}
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -static void omap_mcbsp_dsp_request(void)
> -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - int ret;
> -
> - ret = omap_dsp_request_mem();
> - if (ret < 0) {
> - printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
> - return;
> - }
> -
> - clk_enable(mcbsp_dsp_ck);
> - clk_enable(mcbsp_api_ck);
> -
> - /* enable 12MHz clock to mcbsp 1 & 3 */
> - clk_enable(mcbsp_dspxor_ck);
> -
> - /*
> - * DSP external peripheral reset
> - * FIXME: This should be moved to dsp code
> - */
> - __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> - DSP_RSTCT2);
> - }
> -}
> -
> -static void omap_mcbsp_dsp_free(void)
> -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - omap_dsp_release_mem();
> - clk_disable(mcbsp_dspxor_ck);
> - clk_disable(mcbsp_dsp_ck);
> - clk_disable(mcbsp_api_ck);
> - }
> -}
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> -static void omap2_mcbsp2_mux_setup(void)
> -{
> - if (cpu_is_omap2420()) {
> - omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> - omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> - omap_cfg_reg(W15_24XX_MCBSP2_DR);
> - omap_cfg_reg(V15_24XX_MCBSP2_DX);
> - omap_cfg_reg(V14_24XX_GPIO117);
> - }
> - /*
> - * Need to add MUX settings for OMAP 2430 SDP
> - */
> -}
> -#endif
> -
> /*
> * We can choose between IRQ based or polled IO.
> * This needs to be called before omap_mcbsp_request().
> */
> int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
> {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> spin_lock(&mcbsp[id].lock);
> @@ -281,29 +194,11 @@ int omap_mcbsp_request(unsigned int id)
> {
> int err;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - /*
> - * On 1510, 1610 and 1710, McBSP1 and McBSP3
> - * are DSP public peripherals.
> - */
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_request();
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_enable(mcbsp1_ick);
> - clk_enable(mcbsp1_fck);
> - } else {
> - clk_enable(mcbsp2_ick);
> - clk_enable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->request)
> + mcbsp_config->request(id);
>
> spin_lock(&mcbsp[id].lock);
> if (!mcbsp[id].free) {
> @@ -348,27 +243,11 @@ EXPORT_SYMBOL(omap_mcbsp_request);
>
> void omap_mcbsp_free(unsigned int id)
> {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - if (cpu_class_is_omap1()) {
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_free();
> - }
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_disable(mcbsp1_ick);
> - clk_disable(mcbsp1_fck);
> - } else {
> - clk_disable(mcbsp2_ick);
> - clk_disable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->free)
> + mcbsp_config->free(id);
>
> spin_lock(&mcbsp[id].lock);
> if (mcbsp[id].free) {
> @@ -399,7 +278,7 @@ void omap_mcbsp_start(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -434,7 +313,7 @@ void omap_mcbsp_stop(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -532,7 +411,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
> u32 io_base;
> omap_mcbsp_word_length word_length = mcbsp[id].tx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -551,7 +430,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
> u16 word_lsb, word_msb = 0;
> omap_mcbsp_word_length word_length = mcbsp[id].rx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> io_base = mcbsp[id].io_base;
> @@ -691,7 +570,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
> @@ -712,7 +591,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_tx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
> @@ -748,7 +627,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
> @@ -769,7 +648,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_rx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
> @@ -808,7 +687,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id,
> {
> struct omap_mcbsp_reg_cfg mcbsp_cfg;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
> @@ -870,162 +749,19 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> * 730 has only 2 McBSP, and both of them are MPU peripherals.
> */
> -struct omap_mcbsp_info {
> - u32 virt_base;
> - u8 dma_rx_sync, dma_tx_sync;
> - u16 rx_irq, tx_irq;
> -};
> -
> -#ifdef CONFIG_ARCH_OMAP730
> -static const struct omap_mcbsp_info mcbsp_730[] = {
> - [0] = { .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_730_McBSP1RX,
> - .tx_irq = INT_730_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_730_McBSP2RX,
> - .tx_irq = INT_730_McBSP2TX },
> -};
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP15XX
> -static const struct omap_mcbsp_info mcbsp_1510[] = {
> - [0] = { .virt_base = OMAP1510_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1510_SPI_RX,
> - .tx_irq = INT_1510_SPI_TX },
> - [2] = { .virt_base = OMAP1510_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP16XX)
> -static const struct omap_mcbsp_info mcbsp_1610[] = {
> - [0] = { .virt_base = OMAP1610_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1610_McBSP2_RX,
> - .tx_irq = INT_1610_McBSP2_TX },
> - [2] = { .virt_base = OMAP1610_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP24XX)
> -static const struct omap_mcbsp_info mcbsp_24xx[] = {
> - [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> - .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> - },
> - [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> - .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> - },
> -};
> -#endif
> -
> -static int __init omap_mcbsp_init(void)
> +int __init omap_mcbsp_init(void)
> {
> - int mcbsp_count = 0, i;
> - static const struct omap_mcbsp_info *mcbsp_info;
> + int i;
>
> - printk(KERN_INFO "Initializing OMAP McBSP system\n");
> -
> -#ifdef CONFIG_ARCH_OMAP1
> - mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> - if (IS_ERR(mcbsp_dsp_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
> - return PTR_ERR(mcbsp_dsp_ck);
> - }
> - mcbsp_api_ck = clk_get(0, "api_ck");
> - if (IS_ERR(mcbsp_api_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
> - return PTR_ERR(mcbsp_api_ck);
> - }
> - mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> - if (IS_ERR(mcbsp_dspxor_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
> - return PTR_ERR(mcbsp_dspxor_ck);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP2
> - mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> - if (IS_ERR(mcbsp1_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_ick handle.\n");
> - return PTR_ERR(mcbsp1_ick);
> - }
> - mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> - if (IS_ERR(mcbsp1_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_fck handle.\n");
> - return PTR_ERR(mcbsp1_fck);
> - }
> - mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> - if (IS_ERR(mcbsp2_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_ick handle.\n");
> - return PTR_ERR(mcbsp2_ick);
> - }
> - mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> - if (IS_ERR(mcbsp2_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_fck handle.\n");
> - return PTR_ERR(mcbsp2_fck);
> + if (!mcbsp_config) {
> + printk(KERN_ERR "McBSP initialized without configuration\n");
> + return -EINVAL;
> }
> -#endif
>
> -#ifdef CONFIG_ARCH_OMAP730
> - if (cpu_is_omap730()) {
> - mcbsp_info = mcbsp_730;
> - mcbsp_count = ARRAY_SIZE(mcbsp_730);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP15XX
> - if (cpu_is_omap15xx()) {
> - mcbsp_info = mcbsp_1510;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1510);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP16XX)
> - if (cpu_is_omap16xx()) {
> - mcbsp_info = mcbsp_1610;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1610);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP24XX)
> - if (cpu_is_omap24xx()) {
> - mcbsp_info = mcbsp_24xx;
> - mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
> - omap2_mcbsp2_mux_setup();
> - }
> -#endif
> + printk(KERN_INFO "Initializing OMAP McBSP system\n");
> +
> for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
> - if (i >= mcbsp_count) {
> + if (i >= ARRAY_SIZE(mcbsp_config->mcbsp_infos)) {
> mcbsp[i].io_base = 0;
> mcbsp[i].free = 0;
> continue;
> @@ -1035,17 +771,29 @@ static int __init omap_mcbsp_init(void)
> mcbsp[i].dma_tx_lch = -1;
> mcbsp[i].dma_rx_lch = -1;
>
> - mcbsp[i].io_base = mcbsp_info[i].virt_base;
> + mcbsp[i].io_base = mcbsp_config->mcbsp_infos[i].virt_base;
> /* Default I/O is IRQ based */
> mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
> - mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
> - mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
> - mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
> - mcbsp[i].dma_tx_sync = mcbsp_info[i].dma_tx_sync;
> + mcbsp[i].tx_irq = mcbsp_config->mcbsp_infos[i].tx_irq;
> + mcbsp[i].rx_irq = mcbsp_config->mcbsp_infos[i].rx_irq;
> + mcbsp[i].dma_rx_sync = mcbsp_config->mcbsp_infos[i].dma_rx_sync;
> + mcbsp[i].dma_tx_sync = mcbsp_config->mcbsp_infos[i].dma_tx_sync;
> spin_lock_init(&mcbsp[i].lock);
> }
>
> return 0;
> }
>
> -arch_initcall(omap_mcbsp_init);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config)
> +{
> + if (!config || !config->request || !config->free) {
> + printk(KERN_ERR "Invalid McBSP configuration\n");
> + return -EINVAL;
> + }
> +
> + mcbsp_config = config;
> +
> + return 0;
> +
> +}
> +
> diff --git a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
> index b53c3b2..fc53a45 100644
> --- a/include/asm-arm/arch-omap/mcbsp.h
> +++ b/include/asm-arm/arch-omap/mcbsp.h
> @@ -40,6 +40,9 @@
> #define OMAP24XX_MCBSP1_BASE 0x48074000
> #define OMAP24XX_MCBSP2_BASE 0x48076000
>
> +#define OMAP34XX_MCBSP1_BASE 0x48074000
> +#define OMAP34XX_MCBSP2_BASE 0x49022000
> +
> #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
>
> #define OMAP_MCBSP_REG_DRR2 0x00
> @@ -298,6 +301,22 @@ struct omap_mcbsp_spi_cfg {
> omap_mcbsp_word_length word_length;
> };
>
> +/* Board specific configuration */
> +struct omap_mcbsp_info {
> + u32 virt_base;
> + u8 dma_rx_sync, dma_tx_sync;
> + u16 rx_irq, tx_irq;
> +};
> +
> +struct omap_mcbsp_board_cfg {
> + void (*request)(unsigned int);
> + void (*free)(unsigned int);
> + int (*check)(unsigned int);
> + struct omap_mcbsp_info mcbsp_infos[OMAP_MAX_MCBSP_COUNT];
> +};
> +
> +int omap_mcbsp_init(void);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config);
> void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
> int omap_mcbsp_request(unsigned int id);
> void omap_mcbsp_free(unsigned int id);
> --
> 1.5.5-rc3.GIT
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best Regards,
Felipe Balbi
me@felipebalbi.com
http://blog.felipebalbi.com
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 18:18 ` Felipe Balbi
@ 2008-04-14 20:11 ` Eduardo Valentin
2008-04-14 20:11 ` Eduardo Valentin
0 siblings, 1 reply; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-14 20:11 UTC (permalink / raw)
To: linux-omap
Hi Balbi
On Mon, Apr 14, 2008 at 2:18 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> On Mon, Apr 14, 2008 at 11:53:01AM -0400, Eduardo Valentin wrote:
> > From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >
> > This patch gets ride of ifdefs on mcbsp.c code.
> > It moves the mach specific code to mach-omap*.
>
> I don't see the new files here. Did you forgot to git add them?
>
> in any case, this is a really good idea ;-)
>
>
Here is an updated version of this patch. Probably, I forgot to add them
while creating this patch. Maybe I used git commit -a -s without paying
attention.
Anyway, thanks for pointing that.
Cheers,
Eduardo Valentin
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 20:11 ` Eduardo Valentin
@ 2008-04-14 20:11 ` Eduardo Valentin
2008-04-14 20:23 ` Felipe Balbi
` (2 more replies)
0 siblings, 3 replies; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-14 20:11 UTC (permalink / raw)
To: linux-omap; +Cc: Eduardo Valentin
From: Eduardo Valentin <eduardo.valentin@indt.org.br>
This patch gets ride of ifdefs on mcbsp.c code.
It moves the mach specific code to mach-omap*.
Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
arch/arm/mach-omap1/Makefile | 2 +
arch/arm/mach-omap1/mcbsp.c | 202 +++++++++++++++++++++
arch/arm/mach-omap2/Makefile | 2 +
arch/arm/mach-omap2/mcbsp.c | 145 ++++++++++++++++
arch/arm/plat-omap/mcbsp.c | 346 +++++--------------------------------
include/asm-arm/arch-omap/mcbsp.h | 19 ++
6 files changed, 417 insertions(+), 299 deletions(-)
create mode 100644 arch/arm/mach-omap1/mcbsp.c
create mode 100644 arch/arm/mach-omap2/mcbsp.c
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index 6ebf23b..09246a7 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -5,6 +5,8 @@
# Common support
obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
+obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
+
obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
new file mode 100644
index 0000000..299f036
--- /dev/null
+++ b/arch/arm/mach-omap1/mcbsp.c
@@ -0,0 +1,202 @@
+/*
+ * linux/arch/arm/mach-omap1/mcbsp.c
+ *
+ * Copyright (C) 2008 Instituto Nokia de Tecnologia
+ * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Multichannel mode not supported.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/io.h>
+
+#include <asm/arch/dma.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/mcbsp.h>
+#include <asm/arch/dsp_common.h>
+
+static struct clk *mcbsp_dsp_ck;
+static struct clk *mcbsp_api_ck;
+static struct clk *mcbsp_dspxor_ck;
+
+static void omap_mcbsp_dsp_request(void)
+{
+ if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
+ int ret;
+
+ ret = omap_dsp_request_mem();
+ if (ret < 0) {
+ printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
+ return;
+ }
+
+ clk_enable(mcbsp_dsp_ck);
+ clk_enable(mcbsp_api_ck);
+
+ /* enable 12MHz clock to mcbsp 1 & 3 */
+ clk_enable(mcbsp_dspxor_ck);
+
+ /*
+ * DSP external peripheral reset
+ * FIXME: This should be moved to dsp code
+ */
+ __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
+ DSP_RSTCT2);
+ }
+}
+
+static void omap_mcbsp_dsp_free(void)
+{
+ if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
+ omap_dsp_release_mem();
+ clk_disable(mcbsp_dspxor_ck);
+ clk_disable(mcbsp_dsp_ck);
+ clk_disable(mcbsp_api_ck);
+ }
+}
+
+static int omap1_mcbsp_check(unsigned int id)
+{
+ if (cpu_is_omap730()) {
+ if (id > OMAP_MAX_MCBSP_COUNT - 1) {
+ 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) {
+ 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)
+{
+ /*
+ * On 1510, 1610 and 1710, McBSP1 and McBSP3
+ * are DSP public peripherals.
+ */
+ if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
+ omap_mcbsp_dsp_request();
+}
+
+static void omap1_mcbsp_free(unsigned int id)
+{
+ if (cpu_class_is_omap1()) {
+ if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
+ omap_mcbsp_dsp_free();
+ }
+}
+
+struct omap_mcbsp_board_cfg omap1_mcbsp_cfg = {
+ .check = omap1_mcbsp_check,
+ .request = omap1_mcbsp_request,
+ .free = omap1_mcbsp_free,
+ .mcbsp_infos =
+#ifdef CONFIG_ARCH_OMAP730
+ {
+ [0] = {
+ .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
+ .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
+ .rx_irq = INT_730_McBSP1RX,
+ .tx_irq = INT_730_McBSP1TX,
+ },
+ [1] = {
+ .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
+ .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
+ .rx_irq = INT_730_McBSP2RX,
+ .tx_irq = INT_730_McBSP2TX
+ },
+ },
+#elif defined(CONFIG_ARCH_OMAP15XX)
+ {
+ [0] = {
+ .virt_base = OMAP1510_MCBSP1_BASE,
+ .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
+ .rx_irq = INT_McBSP1RX,
+ .tx_irq = INT_McBSP1TX
+ },
+ [1] = {
+ .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
+ .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
+ .rx_irq = INT_1510_SPI_RX,
+ .tx_irq = INT_1510_SPI_TX
+ },
+ [2] = {
+ .virt_base = OMAP1510_MCBSP3_BASE,
+ .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
+ .rx_irq = INT_McBSP3RX,
+ .tx_irq = INT_McBSP3TX
+ },
+#elif defined(CONFIG_ARCH_OMAP16XX)
+ {
+ [0] = {
+ .virt_base = OMAP1610_MCBSP1_BASE,
+ .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
+ .rx_irq = INT_McBSP1RX,
+ .tx_irq = INT_McBSP1TX
+ },
+ [1] = {
+ .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
+ .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
+ .rx_irq = INT_1610_McBSP2_RX,
+ .tx_irq = INT_1610_McBSP2_TX
+ },
+ [2] = {
+ .virt_base = OMAP1610_MCBSP3_BASE,
+ .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
+ .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
+ .rx_irq = INT_McBSP3RX,
+ .tx_irq = INT_McBSP3TX
+ },
+ },
+#else
+NULL /* For .mcbsp_infos */
+#endif
+};
+
+int __init omap1_mcbsp_init(void)
+{
+ mcbsp_dsp_ck = clk_get(0, "dsp_ck");
+ if (IS_ERR(mcbsp_dsp_ck)) {
+ printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
+ return PTR_ERR(mcbsp_dsp_ck);
+ }
+ mcbsp_api_ck = clk_get(0, "api_ck");
+ if (IS_ERR(mcbsp_api_ck)) {
+ printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
+ return PTR_ERR(mcbsp_api_ck);
+ }
+ mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
+ if (IS_ERR(mcbsp_dspxor_ck)) {
+ printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
+ return PTR_ERR(mcbsp_dspxor_ck);
+ }
+
+ omap_mcbsp_register_board_cfg(&omap1_mcbsp_cfg);
+
+ return omap_mcbsp_init();
+}
+arch_initcall(omap1_mcbsp_init);
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 5157ff2..771f8e7 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -6,6 +6,8 @@
obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
devices.o serial.o gpmc.o timer-gp.o
+obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
+
# Functions loaded to SRAM
obj-$(CONFIG_ARCH_OMAP2) += sram24xx.o
diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
new file mode 100644
index 0000000..8c8b97f
--- /dev/null
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -0,0 +1,145 @@
+/*
+ * linux/arch/arm/mach-omap1/mcbsp.c
+ *
+ * Copyright (C) 2008 Instituto Nokia de Tecnologia
+ * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Multichannel mode not supported.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+
+#include <asm/arch/dma.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/mcbsp.h>
+
+static struct clk *mcbsp1_ick;
+static struct clk *mcbsp1_fck;
+static struct clk *mcbsp2_ick;
+static struct clk *mcbsp2_fck;
+
+static void omap2_mcbsp2_mux_setup(void)
+{
+ if (cpu_is_omap2420()) {
+ omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
+ omap_cfg_reg(R14_24XX_MCBSP2_FSX);
+ omap_cfg_reg(W15_24XX_MCBSP2_DR);
+ omap_cfg_reg(V15_24XX_MCBSP2_DX);
+ omap_cfg_reg(V14_24XX_GPIO117);
+ }
+ /*
+ * Need to add MUX settings for OMAP 2430 SDP
+ */
+}
+
+static int omap2_mcbsp_check(unsigned int id)
+{
+ if (cpu_class_is_omap2()) {
+ if (id > OMAP_MAX_MCBSP_COUNT) {
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
+ id + 1);
+ return -ENODEV;
+ }
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
+static void omap2_mcbsp_request(unsigned int id)
+{
+ if (cpu_class_is_omap2()) {
+ if (id == OMAP_MCBSP1) {
+ clk_enable(mcbsp1_ick);
+ clk_enable(mcbsp1_fck);
+ } else {
+ clk_enable(mcbsp2_ick);
+ clk_enable(mcbsp2_fck);
+ }
+ }
+}
+static void omap2_mcbsp_free(unsigned int id)
+{
+ if (cpu_class_is_omap2()) {
+ if (id == OMAP_MCBSP1) {
+ clk_disable(mcbsp1_ick);
+ clk_disable(mcbsp1_fck);
+ } else {
+ clk_disable(mcbsp2_ick);
+ clk_disable(mcbsp2_fck);
+ }
+ }
+}
+
+static const struct omap_mcbsp_board_cfg mcbsp_24xx_cfg = {
+ .check = omap2_mcbsp_check,
+ .request = omap2_mcbsp_request,
+ .free = omap2_mcbsp_free,
+ .mcbsp_infos = {
+ [0] = {
+#if defined(CONFIG_ARCH_OMAP24XX)
+ .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
+#elif defined(CONFIG_ARCH_OMAP34XX)
+ .virt_base = IO_ADDRESS(OMAP34XX_MCBSP1_BASE),
+#endif
+ .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
+ .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
+ .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
+ .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
+ },
+ [1] = {
+#if defined(CONFIG_ARCH_OMAP24XX)
+ .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
+#elif defined(CONFIG_ARCH_OMAP34XX)
+ .virt_base = IO_ADDRESS(OMAP34XX_MCBSP2_BASE),
+#endif
+ .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
+ .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
+ .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
+ .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
+ },
+ },
+};
+
+int __init omap2_mcbsp_init(void)
+{
+ mcbsp1_ick = clk_get(0, "mcbsp1_ick");
+ if (IS_ERR(mcbsp1_ick)) {
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp1_ick handle.\n");
+ return PTR_ERR(mcbsp1_ick);
+ }
+ mcbsp1_fck = clk_get(0, "mcbsp1_fck");
+ if (IS_ERR(mcbsp1_fck)) {
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp1_fck handle.\n");
+ return PTR_ERR(mcbsp1_fck);
+ }
+ mcbsp2_ick = clk_get(0, "mcbsp2_ick");
+ if (IS_ERR(mcbsp2_ick)) {
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp2_ick handle.\n");
+ return PTR_ERR(mcbsp2_ick);
+ }
+ mcbsp2_fck = clk_get(0, "mcbsp2_fck");
+ if (IS_ERR(mcbsp2_fck)) {
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp2_fck handle.\n");
+ return PTR_ERR(mcbsp2_fck);
+ }
+
+ if (cpu_class_is_omap2()) {
+ omap_mcbsp_register_board_cfg(&mcbsp_24xx_cfg);
+ omap2_mcbsp2_mux_setup();
+ }
+
+ return omap_mcbsp_init();
+}
+arch_initcall(omap2_mcbsp_init);
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 053de31..fdba002 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -24,11 +24,8 @@
#include <linux/io.h>
#include <linux/irq.h>
-#include <asm/arch/dma.h>
-#include <asm/arch/mux.h>
-#include <asm/arch/irqs.h>
-#include <asm/arch/dsp_common.h>
#include <asm/arch/mcbsp.h>
+#include <asm/arch/dma.h>
#ifdef CONFIG_MCBSP_DEBUG
#define DBG(x...) printk(x)
@@ -65,17 +62,10 @@ struct omap_mcbsp {
};
static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
-#ifdef CONFIG_ARCH_OMAP1
-static struct clk *mcbsp_dsp_ck;
-static struct clk *mcbsp_api_ck;
-static struct clk *mcbsp_dspxor_ck;
-#endif
-#ifdef CONFIG_ARCH_OMAP2
-static struct clk *mcbsp1_ick;
-static struct clk *mcbsp1_fck;
-static struct clk *mcbsp2_ick;
-static struct clk *mcbsp2_fck;
-#endif
+static const struct omap_mcbsp_board_cfg *mcbsp_config;
+
+#define omap_mcbsp_check_invalid_id(id) (mcbsp_config && mcbsp_config->check \
+ && (mcbsp_config->check(id) < 0))
static void omap_mcbsp_dump_reg(u8 id)
{
@@ -175,90 +165,13 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
}
EXPORT_SYMBOL(omap_mcbsp_config);
-static int omap_mcbsp_check(unsigned int id)
-{
- if (cpu_is_omap730()) {
- if (id > OMAP_MAX_MCBSP_COUNT - 1) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
- id + 1);
- return -1;
- }
- return 0;
- }
-
- if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
- if (id > OMAP_MAX_MCBSP_COUNT) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
- id + 1);
- return -1;
- }
- return 0;
- }
-
- return -1;
-}
-
-#ifdef CONFIG_ARCH_OMAP1
-static void omap_mcbsp_dsp_request(void)
-{
- if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
- int ret;
-
- ret = omap_dsp_request_mem();
- if (ret < 0) {
- printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
- return;
- }
-
- clk_enable(mcbsp_dsp_ck);
- clk_enable(mcbsp_api_ck);
-
- /* enable 12MHz clock to mcbsp 1 & 3 */
- clk_enable(mcbsp_dspxor_ck);
-
- /*
- * DSP external peripheral reset
- * FIXME: This should be moved to dsp code
- */
- __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
- DSP_RSTCT2);
- }
-}
-
-static void omap_mcbsp_dsp_free(void)
-{
- if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
- omap_dsp_release_mem();
- clk_disable(mcbsp_dspxor_ck);
- clk_disable(mcbsp_dsp_ck);
- clk_disable(mcbsp_api_ck);
- }
-}
-#endif
-
-#ifdef CONFIG_ARCH_OMAP2
-static void omap2_mcbsp2_mux_setup(void)
-{
- if (cpu_is_omap2420()) {
- omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
- omap_cfg_reg(R14_24XX_MCBSP2_FSX);
- omap_cfg_reg(W15_24XX_MCBSP2_DR);
- omap_cfg_reg(V15_24XX_MCBSP2_DX);
- omap_cfg_reg(V14_24XX_GPIO117);
- }
- /*
- * Need to add MUX settings for OMAP 2430 SDP
- */
-}
-#endif
-
/*
* We can choose between IRQ based or polled IO.
* This needs to be called before omap_mcbsp_request().
*/
int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
{
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
spin_lock(&mcbsp[id].lock);
@@ -282,29 +195,11 @@ int omap_mcbsp_request(unsigned int id)
{
int err;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
-#ifdef CONFIG_ARCH_OMAP1
- /*
- * On 1510, 1610 and 1710, McBSP1 and McBSP3
- * are DSP public peripherals.
- */
- if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
- omap_mcbsp_dsp_request();
-#endif
-
-#ifdef CONFIG_ARCH_OMAP2
- if (cpu_is_omap24xx()) {
- if (id == OMAP_MCBSP1) {
- clk_enable(mcbsp1_ick);
- clk_enable(mcbsp1_fck);
- } else {
- clk_enable(mcbsp2_ick);
- clk_enable(mcbsp2_fck);
- }
- }
-#endif
+ if (mcbsp_config && mcbsp_config->request)
+ mcbsp_config->request(id);
spin_lock(&mcbsp[id].lock);
if (!mcbsp[id].free) {
@@ -349,27 +244,11 @@ EXPORT_SYMBOL(omap_mcbsp_request);
void omap_mcbsp_free(unsigned int id)
{
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
-#ifdef CONFIG_ARCH_OMAP1
- if (cpu_class_is_omap1()) {
- if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
- omap_mcbsp_dsp_free();
- }
-#endif
-
-#ifdef CONFIG_ARCH_OMAP2
- if (cpu_is_omap24xx()) {
- if (id == OMAP_MCBSP1) {
- clk_disable(mcbsp1_ick);
- clk_disable(mcbsp1_fck);
- } else {
- clk_disable(mcbsp2_ick);
- clk_disable(mcbsp2_fck);
- }
- }
-#endif
+ if (mcbsp_config && mcbsp_config->free)
+ mcbsp_config->free(id);
spin_lock(&mcbsp[id].lock);
if (mcbsp[id].free) {
@@ -400,7 +279,7 @@ void omap_mcbsp_start(unsigned int id)
u32 io_base;
u16 w;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
io_base = mcbsp[id].io_base;
@@ -435,7 +314,7 @@ void omap_mcbsp_stop(unsigned int id)
u32 io_base;
u16 w;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
io_base = mcbsp[id].io_base;
@@ -533,7 +412,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
u32 io_base;
omap_mcbsp_word_length word_length = mcbsp[id].tx_word_length;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
io_base = mcbsp[id].io_base;
@@ -552,7 +431,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
u16 word_lsb, word_msb = 0;
omap_mcbsp_word_length word_length = mcbsp[id].rx_word_length;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
io_base = mcbsp[id].io_base;
@@ -692,7 +571,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
int dest_port = 0;
int sync_dev = 0;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
@@ -713,7 +592,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
src_port = OMAP_DMA_PORT_TIPB;
dest_port = OMAP_DMA_PORT_EMIFF;
}
- if (cpu_is_omap24xx())
+ if (cpu_class_is_omap2())
sync_dev = mcbsp[id].dma_tx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
@@ -749,7 +628,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
int dest_port = 0;
int sync_dev = 0;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return -EINVAL;
if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
@@ -770,7 +649,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
src_port = OMAP_DMA_PORT_TIPB;
dest_port = OMAP_DMA_PORT_EMIFF;
}
- if (cpu_is_omap24xx())
+ if (cpu_class_is_omap2())
sync_dev = mcbsp[id].dma_rx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
@@ -809,7 +688,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id,
{
struct omap_mcbsp_reg_cfg mcbsp_cfg;
- if (omap_mcbsp_check(id) < 0)
+ if (omap_mcbsp_check_invalid_id(id))
return;
memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
@@ -871,162 +750,19 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
* McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
* 730 has only 2 McBSP, and both of them are MPU peripherals.
*/
-struct omap_mcbsp_info {
- u32 virt_base;
- u8 dma_rx_sync, dma_tx_sync;
- u16 rx_irq, tx_irq;
-};
-
-#ifdef CONFIG_ARCH_OMAP730
-static const struct omap_mcbsp_info mcbsp_730[] = {
- [0] = { .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
- .rx_irq = INT_730_McBSP1RX,
- .tx_irq = INT_730_McBSP1TX },
- [1] = { .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
- .rx_irq = INT_730_McBSP2RX,
- .tx_irq = INT_730_McBSP2TX },
-};
-#endif
-
-#ifdef CONFIG_ARCH_OMAP15XX
-static const struct omap_mcbsp_info mcbsp_1510[] = {
- [0] = { .virt_base = OMAP1510_MCBSP1_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
- .rx_irq = INT_McBSP1RX,
- .tx_irq = INT_McBSP1TX },
- [1] = { .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
- .rx_irq = INT_1510_SPI_RX,
- .tx_irq = INT_1510_SPI_TX },
- [2] = { .virt_base = OMAP1510_MCBSP3_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
- .rx_irq = INT_McBSP3RX,
- .tx_irq = INT_McBSP3TX },
-};
-#endif
-
-#if defined(CONFIG_ARCH_OMAP16XX)
-static const struct omap_mcbsp_info mcbsp_1610[] = {
- [0] = { .virt_base = OMAP1610_MCBSP1_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
- .rx_irq = INT_McBSP1RX,
- .tx_irq = INT_McBSP1TX },
- [1] = { .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
- .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
- .rx_irq = INT_1610_McBSP2_RX,
- .tx_irq = INT_1610_McBSP2_TX },
- [2] = { .virt_base = OMAP1610_MCBSP3_BASE,
- .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
- .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
- .rx_irq = INT_McBSP3RX,
- .tx_irq = INT_McBSP3TX },
-};
-#endif
-
-#if defined(CONFIG_ARCH_OMAP24XX)
-static const struct omap_mcbsp_info mcbsp_24xx[] = {
- [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
- .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
- .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
- .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
- .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
- },
- [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
- .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
- .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
- .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
- .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
- },
-};
-#endif
-
-static int __init omap_mcbsp_init(void)
+int __init omap_mcbsp_init(void)
{
- int mcbsp_count = 0, i;
- static const struct omap_mcbsp_info *mcbsp_info;
+ int i;
- printk(KERN_INFO "Initializing OMAP McBSP system\n");
-
-#ifdef CONFIG_ARCH_OMAP1
- mcbsp_dsp_ck = clk_get(0, "dsp_ck");
- if (IS_ERR(mcbsp_dsp_ck)) {
- printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
- return PTR_ERR(mcbsp_dsp_ck);
- }
- mcbsp_api_ck = clk_get(0, "api_ck");
- if (IS_ERR(mcbsp_api_ck)) {
- printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
- return PTR_ERR(mcbsp_api_ck);
- }
- mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
- if (IS_ERR(mcbsp_dspxor_ck)) {
- printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
- return PTR_ERR(mcbsp_dspxor_ck);
- }
-#endif
-#ifdef CONFIG_ARCH_OMAP2
- mcbsp1_ick = clk_get(0, "mcbsp1_ick");
- if (IS_ERR(mcbsp1_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp1_ick handle.\n");
- return PTR_ERR(mcbsp1_ick);
- }
- mcbsp1_fck = clk_get(0, "mcbsp1_fck");
- if (IS_ERR(mcbsp1_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp1_fck handle.\n");
- return PTR_ERR(mcbsp1_fck);
- }
- mcbsp2_ick = clk_get(0, "mcbsp2_ick");
- if (IS_ERR(mcbsp2_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp2_ick handle.\n");
- return PTR_ERR(mcbsp2_ick);
- }
- mcbsp2_fck = clk_get(0, "mcbsp2_fck");
- if (IS_ERR(mcbsp2_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire "
- "mcbsp2_fck handle.\n");
- return PTR_ERR(mcbsp2_fck);
+ if (!mcbsp_config) {
+ printk(KERN_ERR "McBSP initialized without configuration\n");
+ return -EINVAL;
}
-#endif
-#ifdef CONFIG_ARCH_OMAP730
- if (cpu_is_omap730()) {
- mcbsp_info = mcbsp_730;
- mcbsp_count = ARRAY_SIZE(mcbsp_730);
- }
-#endif
-#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap15xx()) {
- mcbsp_info = mcbsp_1510;
- mcbsp_count = ARRAY_SIZE(mcbsp_1510);
- }
-#endif
-#if defined(CONFIG_ARCH_OMAP16XX)
- if (cpu_is_omap16xx()) {
- mcbsp_info = mcbsp_1610;
- mcbsp_count = ARRAY_SIZE(mcbsp_1610);
- }
-#endif
-#if defined(CONFIG_ARCH_OMAP24XX)
- if (cpu_is_omap24xx()) {
- mcbsp_info = mcbsp_24xx;
- mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
- omap2_mcbsp2_mux_setup();
- }
-#endif
+ printk(KERN_INFO "Initializing OMAP McBSP system\n");
+
for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
- if (i >= mcbsp_count) {
+ if (i >= ARRAY_SIZE(mcbsp_config->mcbsp_infos)) {
mcbsp[i].io_base = 0;
mcbsp[i].free = 0;
continue;
@@ -1036,17 +772,29 @@ static int __init omap_mcbsp_init(void)
mcbsp[i].dma_tx_lch = -1;
mcbsp[i].dma_rx_lch = -1;
- mcbsp[i].io_base = mcbsp_info[i].virt_base;
+ mcbsp[i].io_base = mcbsp_config->mcbsp_infos[i].virt_base;
/* Default I/O is IRQ based */
mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
- mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
- mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
- mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
- mcbsp[i].dma_tx_sync = mcbsp_info[i].dma_tx_sync;
+ mcbsp[i].tx_irq = mcbsp_config->mcbsp_infos[i].tx_irq;
+ mcbsp[i].rx_irq = mcbsp_config->mcbsp_infos[i].rx_irq;
+ mcbsp[i].dma_rx_sync = mcbsp_config->mcbsp_infos[i].dma_rx_sync;
+ mcbsp[i].dma_tx_sync = mcbsp_config->mcbsp_infos[i].dma_tx_sync;
spin_lock_init(&mcbsp[i].lock);
}
return 0;
}
-arch_initcall(omap_mcbsp_init);
+int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config)
+{
+ if (!config || !config->request || !config->free) {
+ printk(KERN_ERR "Invalid McBSP configuration\n");
+ return -EINVAL;
+ }
+
+ mcbsp_config = config;
+
+ return 0;
+
+}
+
diff --git a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
index b53c3b2..fc53a45 100644
--- a/include/asm-arm/arch-omap/mcbsp.h
+++ b/include/asm-arm/arch-omap/mcbsp.h
@@ -40,6 +40,9 @@
#define OMAP24XX_MCBSP1_BASE 0x48074000
#define OMAP24XX_MCBSP2_BASE 0x48076000
+#define OMAP34XX_MCBSP1_BASE 0x48074000
+#define OMAP34XX_MCBSP2_BASE 0x49022000
+
#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
#define OMAP_MCBSP_REG_DRR2 0x00
@@ -298,6 +301,22 @@ struct omap_mcbsp_spi_cfg {
omap_mcbsp_word_length word_length;
};
+/* Board specific configuration */
+struct omap_mcbsp_info {
+ u32 virt_base;
+ u8 dma_rx_sync, dma_tx_sync;
+ u16 rx_irq, tx_irq;
+};
+
+struct omap_mcbsp_board_cfg {
+ void (*request)(unsigned int);
+ void (*free)(unsigned int);
+ int (*check)(unsigned int);
+ struct omap_mcbsp_info mcbsp_infos[OMAP_MAX_MCBSP_COUNT];
+};
+
+int omap_mcbsp_init(void);
+int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config);
void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
int omap_mcbsp_request(unsigned int id);
void omap_mcbsp_free(unsigned int id);
--
1.5.5-rc3.GIT
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 20:11 ` Eduardo Valentin
@ 2008-04-14 20:23 ` Felipe Balbi
2008-04-15 9:38 ` Jarkko Nikula
2008-04-15 14:49 ` Chandra shekhar
2008-04-21 18:33 ` Tony Lindgren
2 siblings, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2008-04-14 20:23 UTC (permalink / raw)
To: Eduardo Valentin; +Cc: linux-omap, Eduardo Valentin
On Mon, Apr 14, 2008 at 04:11:31PM -0400, Eduardo Valentin wrote:
> From: Eduardo Valentin <eduardo.valentin@indt.org.br>
>
> This patch gets ride of ifdefs on mcbsp.c code.
> It moves the mach specific code to mach-omap*.
It looks ok, checkpatch.pl returns success, boot-test on n810 is fine
>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
Acked-by: Felipe Balbi <felipe.balbi@nokia.com>
> ---
> arch/arm/mach-omap1/Makefile | 2 +
> arch/arm/mach-omap1/mcbsp.c | 202 +++++++++++++++++++++
> arch/arm/mach-omap2/Makefile | 2 +
> arch/arm/mach-omap2/mcbsp.c | 145 ++++++++++++++++
> arch/arm/plat-omap/mcbsp.c | 346 +++++--------------------------------
> include/asm-arm/arch-omap/mcbsp.h | 19 ++
> 6 files changed, 417 insertions(+), 299 deletions(-)
> create mode 100644 arch/arm/mach-omap1/mcbsp.c
> create mode 100644 arch/arm/mach-omap2/mcbsp.c
>
> diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
> index 6ebf23b..09246a7 100644
> --- a/arch/arm/mach-omap1/Makefile
> +++ b/arch/arm/mach-omap1/Makefile
> @@ -5,6 +5,8 @@
> # Common support
> obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
> obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
>
> diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
> new file mode 100644
> index 0000000..299f036
> --- /dev/null
> +++ b/arch/arm/mach-omap1/mcbsp.c
> @@ -0,0 +1,202 @@
> +/*
> + * linux/arch/arm/mach-omap1/mcbsp.c
> + *
> + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Multichannel mode not supported.
> + */
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +
> +#include <asm/arch/dma.h>
> +#include <asm/arch/mux.h>
> +#include <asm/arch/cpu.h>
> +#include <asm/arch/mcbsp.h>
> +#include <asm/arch/dsp_common.h>
> +
> +static struct clk *mcbsp_dsp_ck;
> +static struct clk *mcbsp_api_ck;
> +static struct clk *mcbsp_dspxor_ck;
> +
> +static void omap_mcbsp_dsp_request(void)
> +{
> + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> + int ret;
> +
> + ret = omap_dsp_request_mem();
> + if (ret < 0) {
> + printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
> + return;
> + }
> +
> + clk_enable(mcbsp_dsp_ck);
> + clk_enable(mcbsp_api_ck);
> +
> + /* enable 12MHz clock to mcbsp 1 & 3 */
> + clk_enable(mcbsp_dspxor_ck);
> +
> + /*
> + * DSP external peripheral reset
> + * FIXME: This should be moved to dsp code
> + */
> + __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> + DSP_RSTCT2);
> + }
> +}
> +
> +static void omap_mcbsp_dsp_free(void)
> +{
> + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> + omap_dsp_release_mem();
> + clk_disable(mcbsp_dspxor_ck);
> + clk_disable(mcbsp_dsp_ck);
> + clk_disable(mcbsp_api_ck);
> + }
> +}
> +
> +static int omap1_mcbsp_check(unsigned int id)
> +{
> + if (cpu_is_omap730()) {
> + if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> + 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) {
> + 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)
> +{
> + /*
> + * On 1510, 1610 and 1710, McBSP1 and McBSP3
> + * are DSP public peripherals.
> + */
> + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> + omap_mcbsp_dsp_request();
> +}
> +
> +static void omap1_mcbsp_free(unsigned int id)
> +{
> + if (cpu_class_is_omap1()) {
> + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> + omap_mcbsp_dsp_free();
> + }
> +}
> +
> +struct omap_mcbsp_board_cfg omap1_mcbsp_cfg = {
> + .check = omap1_mcbsp_check,
> + .request = omap1_mcbsp_request,
> + .free = omap1_mcbsp_free,
> + .mcbsp_infos =
> +#ifdef CONFIG_ARCH_OMAP730
> + {
> + [0] = {
> + .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_730_McBSP1RX,
> + .tx_irq = INT_730_McBSP1TX,
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_730_McBSP2RX,
> + .tx_irq = INT_730_McBSP2TX
> + },
> + },
> +#elif defined(CONFIG_ARCH_OMAP15XX)
> + {
> + [0] = {
> + .virt_base = OMAP1510_MCBSP1_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_McBSP1RX,
> + .tx_irq = INT_McBSP1TX
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> + .rx_irq = INT_1510_SPI_RX,
> + .tx_irq = INT_1510_SPI_TX
> + },
> + [2] = {
> + .virt_base = OMAP1510_MCBSP3_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_McBSP3RX,
> + .tx_irq = INT_McBSP3TX
> + },
> +#elif defined(CONFIG_ARCH_OMAP16XX)
> + {
> + [0] = {
> + .virt_base = OMAP1610_MCBSP1_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_McBSP1RX,
> + .tx_irq = INT_McBSP1TX
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> + .rx_irq = INT_1610_McBSP2_RX,
> + .tx_irq = INT_1610_McBSP2_TX
> + },
> + [2] = {
> + .virt_base = OMAP1610_MCBSP3_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_McBSP3RX,
> + .tx_irq = INT_McBSP3TX
> + },
> + },
> +#else
> +NULL /* For .mcbsp_infos */
> +#endif
> +};
> +
> +int __init omap1_mcbsp_init(void)
> +{
> + mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> + if (IS_ERR(mcbsp_dsp_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
> + return PTR_ERR(mcbsp_dsp_ck);
> + }
> + mcbsp_api_ck = clk_get(0, "api_ck");
> + if (IS_ERR(mcbsp_api_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
> + return PTR_ERR(mcbsp_api_ck);
> + }
> + mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> + if (IS_ERR(mcbsp_dspxor_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
> + return PTR_ERR(mcbsp_dspxor_ck);
> + }
> +
> + omap_mcbsp_register_board_cfg(&omap1_mcbsp_cfg);
> +
> + return omap_mcbsp_init();
> +}
> +arch_initcall(omap1_mcbsp_init);
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 5157ff2..771f8e7 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -6,6 +6,8 @@
> obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
> devices.o serial.o gpmc.o timer-gp.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> # Functions loaded to SRAM
> obj-$(CONFIG_ARCH_OMAP2) += sram24xx.o
>
> diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
> new file mode 100644
> index 0000000..8c8b97f
> --- /dev/null
> +++ b/arch/arm/mach-omap2/mcbsp.c
> @@ -0,0 +1,145 @@
> +/*
> + * linux/arch/arm/mach-omap1/mcbsp.c
> + *
> + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Multichannel mode not supported.
> + */
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +
> +#include <asm/arch/dma.h>
> +#include <asm/arch/mux.h>
> +#include <asm/arch/cpu.h>
> +#include <asm/arch/mcbsp.h>
> +
> +static struct clk *mcbsp1_ick;
> +static struct clk *mcbsp1_fck;
> +static struct clk *mcbsp2_ick;
> +static struct clk *mcbsp2_fck;
> +
> +static void omap2_mcbsp2_mux_setup(void)
> +{
> + if (cpu_is_omap2420()) {
> + omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> + omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> + omap_cfg_reg(W15_24XX_MCBSP2_DR);
> + omap_cfg_reg(V15_24XX_MCBSP2_DX);
> + omap_cfg_reg(V14_24XX_GPIO117);
> + }
> + /*
> + * Need to add MUX settings for OMAP 2430 SDP
> + */
> +}
> +
> +static int omap2_mcbsp_check(unsigned int id)
> +{
> + if (cpu_class_is_omap2()) {
> + if (id > OMAP_MAX_MCBSP_COUNT) {
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> + id + 1);
> + return -ENODEV;
> + }
> + return 0;
> + }
> +
> + return -ENODEV;
> +}
> +
> +static void omap2_mcbsp_request(unsigned int id)
> +{
> + if (cpu_class_is_omap2()) {
> + if (id == OMAP_MCBSP1) {
> + clk_enable(mcbsp1_ick);
> + clk_enable(mcbsp1_fck);
> + } else {
> + clk_enable(mcbsp2_ick);
> + clk_enable(mcbsp2_fck);
> + }
> + }
> +}
> +static void omap2_mcbsp_free(unsigned int id)
> +{
> + if (cpu_class_is_omap2()) {
> + if (id == OMAP_MCBSP1) {
> + clk_disable(mcbsp1_ick);
> + clk_disable(mcbsp1_fck);
> + } else {
> + clk_disable(mcbsp2_ick);
> + clk_disable(mcbsp2_fck);
> + }
> + }
> +}
> +
> +static const struct omap_mcbsp_board_cfg mcbsp_24xx_cfg = {
> + .check = omap2_mcbsp_check,
> + .request = omap2_mcbsp_request,
> + .free = omap2_mcbsp_free,
> + .mcbsp_infos = {
> + [0] = {
> +#if defined(CONFIG_ARCH_OMAP24XX)
> + .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> +#elif defined(CONFIG_ARCH_OMAP34XX)
> + .virt_base = IO_ADDRESS(OMAP34XX_MCBSP1_BASE),
> +#endif
> + .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> + .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> + .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> + },
> + [1] = {
> +#if defined(CONFIG_ARCH_OMAP24XX)
> + .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> +#elif defined(CONFIG_ARCH_OMAP34XX)
> + .virt_base = IO_ADDRESS(OMAP34XX_MCBSP2_BASE),
> +#endif
> + .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> + .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> + .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> + },
> + },
> +};
> +
> +int __init omap2_mcbsp_init(void)
> +{
> + mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> + if (IS_ERR(mcbsp1_ick)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_ick handle.\n");
> + return PTR_ERR(mcbsp1_ick);
> + }
> + mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> + if (IS_ERR(mcbsp1_fck)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_fck handle.\n");
> + return PTR_ERR(mcbsp1_fck);
> + }
> + mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> + if (IS_ERR(mcbsp2_ick)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_ick handle.\n");
> + return PTR_ERR(mcbsp2_ick);
> + }
> + mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> + if (IS_ERR(mcbsp2_fck)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_fck handle.\n");
> + return PTR_ERR(mcbsp2_fck);
> + }
> +
> + if (cpu_class_is_omap2()) {
> + omap_mcbsp_register_board_cfg(&mcbsp_24xx_cfg);
> + omap2_mcbsp2_mux_setup();
> + }
> +
> + return omap_mcbsp_init();
> +}
> +arch_initcall(omap2_mcbsp_init);
> diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
> index 053de31..fdba002 100644
> --- a/arch/arm/plat-omap/mcbsp.c
> +++ b/arch/arm/plat-omap/mcbsp.c
> @@ -24,11 +24,8 @@
> #include <linux/io.h>
> #include <linux/irq.h>
>
> -#include <asm/arch/dma.h>
> -#include <asm/arch/mux.h>
> -#include <asm/arch/irqs.h>
> -#include <asm/arch/dsp_common.h>
> #include <asm/arch/mcbsp.h>
> +#include <asm/arch/dma.h>
>
> #ifdef CONFIG_MCBSP_DEBUG
> #define DBG(x...) printk(x)
> @@ -65,17 +62,10 @@ struct omap_mcbsp {
> };
>
> static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
> -#ifdef CONFIG_ARCH_OMAP1
> -static struct clk *mcbsp_dsp_ck;
> -static struct clk *mcbsp_api_ck;
> -static struct clk *mcbsp_dspxor_ck;
> -#endif
> -#ifdef CONFIG_ARCH_OMAP2
> -static struct clk *mcbsp1_ick;
> -static struct clk *mcbsp1_fck;
> -static struct clk *mcbsp2_ick;
> -static struct clk *mcbsp2_fck;
> -#endif
> +static const struct omap_mcbsp_board_cfg *mcbsp_config;
> +
> +#define omap_mcbsp_check_invalid_id(id) (mcbsp_config && mcbsp_config->check \
> + && (mcbsp_config->check(id) < 0))
>
> static void omap_mcbsp_dump_reg(u8 id)
> {
> @@ -175,90 +165,13 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
> }
> EXPORT_SYMBOL(omap_mcbsp_config);
>
> -static int omap_mcbsp_check(unsigned int id)
> -{
> - if (cpu_is_omap730()) {
> - if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
> - if (id > OMAP_MAX_MCBSP_COUNT) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - return -1;
> -}
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -static void omap_mcbsp_dsp_request(void)
> -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - int ret;
> -
> - ret = omap_dsp_request_mem();
> - if (ret < 0) {
> - printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
> - return;
> - }
> -
> - clk_enable(mcbsp_dsp_ck);
> - clk_enable(mcbsp_api_ck);
> -
> - /* enable 12MHz clock to mcbsp 1 & 3 */
> - clk_enable(mcbsp_dspxor_ck);
> -
> - /*
> - * DSP external peripheral reset
> - * FIXME: This should be moved to dsp code
> - */
> - __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> - DSP_RSTCT2);
> - }
> -}
> -
> -static void omap_mcbsp_dsp_free(void)
> -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - omap_dsp_release_mem();
> - clk_disable(mcbsp_dspxor_ck);
> - clk_disable(mcbsp_dsp_ck);
> - clk_disable(mcbsp_api_ck);
> - }
> -}
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> -static void omap2_mcbsp2_mux_setup(void)
> -{
> - if (cpu_is_omap2420()) {
> - omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> - omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> - omap_cfg_reg(W15_24XX_MCBSP2_DR);
> - omap_cfg_reg(V15_24XX_MCBSP2_DX);
> - omap_cfg_reg(V14_24XX_GPIO117);
> - }
> - /*
> - * Need to add MUX settings for OMAP 2430 SDP
> - */
> -}
> -#endif
> -
> /*
> * We can choose between IRQ based or polled IO.
> * This needs to be called before omap_mcbsp_request().
> */
> int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
> {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> spin_lock(&mcbsp[id].lock);
> @@ -282,29 +195,11 @@ int omap_mcbsp_request(unsigned int id)
> {
> int err;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - /*
> - * On 1510, 1610 and 1710, McBSP1 and McBSP3
> - * are DSP public peripherals.
> - */
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_request();
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_enable(mcbsp1_ick);
> - clk_enable(mcbsp1_fck);
> - } else {
> - clk_enable(mcbsp2_ick);
> - clk_enable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->request)
> + mcbsp_config->request(id);
>
> spin_lock(&mcbsp[id].lock);
> if (!mcbsp[id].free) {
> @@ -349,27 +244,11 @@ EXPORT_SYMBOL(omap_mcbsp_request);
>
> void omap_mcbsp_free(unsigned int id)
> {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - if (cpu_class_is_omap1()) {
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_free();
> - }
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_disable(mcbsp1_ick);
> - clk_disable(mcbsp1_fck);
> - } else {
> - clk_disable(mcbsp2_ick);
> - clk_disable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->free)
> + mcbsp_config->free(id);
>
> spin_lock(&mcbsp[id].lock);
> if (mcbsp[id].free) {
> @@ -400,7 +279,7 @@ void omap_mcbsp_start(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -435,7 +314,7 @@ void omap_mcbsp_stop(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -533,7 +412,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
> u32 io_base;
> omap_mcbsp_word_length word_length = mcbsp[id].tx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -552,7 +431,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
> u16 word_lsb, word_msb = 0;
> omap_mcbsp_word_length word_length = mcbsp[id].rx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> io_base = mcbsp[id].io_base;
> @@ -692,7 +571,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
> @@ -713,7 +592,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_tx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
> @@ -749,7 +628,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
> @@ -770,7 +649,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_rx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
> @@ -809,7 +688,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id,
> {
> struct omap_mcbsp_reg_cfg mcbsp_cfg;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
> @@ -871,162 +750,19 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> * 730 has only 2 McBSP, and both of them are MPU peripherals.
> */
> -struct omap_mcbsp_info {
> - u32 virt_base;
> - u8 dma_rx_sync, dma_tx_sync;
> - u16 rx_irq, tx_irq;
> -};
> -
> -#ifdef CONFIG_ARCH_OMAP730
> -static const struct omap_mcbsp_info mcbsp_730[] = {
> - [0] = { .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_730_McBSP1RX,
> - .tx_irq = INT_730_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_730_McBSP2RX,
> - .tx_irq = INT_730_McBSP2TX },
> -};
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP15XX
> -static const struct omap_mcbsp_info mcbsp_1510[] = {
> - [0] = { .virt_base = OMAP1510_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1510_SPI_RX,
> - .tx_irq = INT_1510_SPI_TX },
> - [2] = { .virt_base = OMAP1510_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP16XX)
> -static const struct omap_mcbsp_info mcbsp_1610[] = {
> - [0] = { .virt_base = OMAP1610_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1610_McBSP2_RX,
> - .tx_irq = INT_1610_McBSP2_TX },
> - [2] = { .virt_base = OMAP1610_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP24XX)
> -static const struct omap_mcbsp_info mcbsp_24xx[] = {
> - [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> - .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> - },
> - [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> - .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> - },
> -};
> -#endif
> -
> -static int __init omap_mcbsp_init(void)
> +int __init omap_mcbsp_init(void)
> {
> - int mcbsp_count = 0, i;
> - static const struct omap_mcbsp_info *mcbsp_info;
> + int i;
>
> - printk(KERN_INFO "Initializing OMAP McBSP system\n");
> -
> -#ifdef CONFIG_ARCH_OMAP1
> - mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> - if (IS_ERR(mcbsp_dsp_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
> - return PTR_ERR(mcbsp_dsp_ck);
> - }
> - mcbsp_api_ck = clk_get(0, "api_ck");
> - if (IS_ERR(mcbsp_api_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
> - return PTR_ERR(mcbsp_api_ck);
> - }
> - mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> - if (IS_ERR(mcbsp_dspxor_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
> - return PTR_ERR(mcbsp_dspxor_ck);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP2
> - mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> - if (IS_ERR(mcbsp1_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_ick handle.\n");
> - return PTR_ERR(mcbsp1_ick);
> - }
> - mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> - if (IS_ERR(mcbsp1_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_fck handle.\n");
> - return PTR_ERR(mcbsp1_fck);
> - }
> - mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> - if (IS_ERR(mcbsp2_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_ick handle.\n");
> - return PTR_ERR(mcbsp2_ick);
> - }
> - mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> - if (IS_ERR(mcbsp2_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_fck handle.\n");
> - return PTR_ERR(mcbsp2_fck);
> + if (!mcbsp_config) {
> + printk(KERN_ERR "McBSP initialized without configuration\n");
> + return -EINVAL;
> }
> -#endif
>
> -#ifdef CONFIG_ARCH_OMAP730
> - if (cpu_is_omap730()) {
> - mcbsp_info = mcbsp_730;
> - mcbsp_count = ARRAY_SIZE(mcbsp_730);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP15XX
> - if (cpu_is_omap15xx()) {
> - mcbsp_info = mcbsp_1510;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1510);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP16XX)
> - if (cpu_is_omap16xx()) {
> - mcbsp_info = mcbsp_1610;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1610);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP24XX)
> - if (cpu_is_omap24xx()) {
> - mcbsp_info = mcbsp_24xx;
> - mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
> - omap2_mcbsp2_mux_setup();
> - }
> -#endif
> + printk(KERN_INFO "Initializing OMAP McBSP system\n");
> +
> for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
> - if (i >= mcbsp_count) {
> + if (i >= ARRAY_SIZE(mcbsp_config->mcbsp_infos)) {
> mcbsp[i].io_base = 0;
> mcbsp[i].free = 0;
> continue;
> @@ -1036,17 +772,29 @@ static int __init omap_mcbsp_init(void)
> mcbsp[i].dma_tx_lch = -1;
> mcbsp[i].dma_rx_lch = -1;
>
> - mcbsp[i].io_base = mcbsp_info[i].virt_base;
> + mcbsp[i].io_base = mcbsp_config->mcbsp_infos[i].virt_base;
> /* Default I/O is IRQ based */
> mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
> - mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
> - mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
> - mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
> - mcbsp[i].dma_tx_sync = mcbsp_info[i].dma_tx_sync;
> + mcbsp[i].tx_irq = mcbsp_config->mcbsp_infos[i].tx_irq;
> + mcbsp[i].rx_irq = mcbsp_config->mcbsp_infos[i].rx_irq;
> + mcbsp[i].dma_rx_sync = mcbsp_config->mcbsp_infos[i].dma_rx_sync;
> + mcbsp[i].dma_tx_sync = mcbsp_config->mcbsp_infos[i].dma_tx_sync;
> spin_lock_init(&mcbsp[i].lock);
> }
>
> return 0;
> }
>
> -arch_initcall(omap_mcbsp_init);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config)
> +{
> + if (!config || !config->request || !config->free) {
> + printk(KERN_ERR "Invalid McBSP configuration\n");
> + return -EINVAL;
> + }
> +
> + mcbsp_config = config;
> +
> + return 0;
> +
> +}
> +
> diff --git a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
> index b53c3b2..fc53a45 100644
> --- a/include/asm-arm/arch-omap/mcbsp.h
> +++ b/include/asm-arm/arch-omap/mcbsp.h
> @@ -40,6 +40,9 @@
> #define OMAP24XX_MCBSP1_BASE 0x48074000
> #define OMAP24XX_MCBSP2_BASE 0x48076000
>
> +#define OMAP34XX_MCBSP1_BASE 0x48074000
> +#define OMAP34XX_MCBSP2_BASE 0x49022000
> +
> #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
>
> #define OMAP_MCBSP_REG_DRR2 0x00
> @@ -298,6 +301,22 @@ struct omap_mcbsp_spi_cfg {
> omap_mcbsp_word_length word_length;
> };
>
> +/* Board specific configuration */
> +struct omap_mcbsp_info {
> + u32 virt_base;
> + u8 dma_rx_sync, dma_tx_sync;
> + u16 rx_irq, tx_irq;
> +};
> +
> +struct omap_mcbsp_board_cfg {
> + void (*request)(unsigned int);
> + void (*free)(unsigned int);
> + int (*check)(unsigned int);
> + struct omap_mcbsp_info mcbsp_infos[OMAP_MAX_MCBSP_COUNT];
> +};
> +
> +int omap_mcbsp_init(void);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config);
> void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
> int omap_mcbsp_request(unsigned int id);
> void omap_mcbsp_free(unsigned int id);
> --
> 1.5.5-rc3.GIT
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best Regards,
Felipe Balbi
me@felipebalbi.com
http://blog.felipebalbi.com
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
2008-04-14 18:16 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Felipe Balbi
@ 2008-04-14 20:24 ` Eduardo Valentin
2008-04-14 20:24 ` Eduardo Valentin
0 siblings, 1 reply; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-14 20:24 UTC (permalink / raw)
To: linux-omap
On Mon, Apr 14, 2008 at 2:16 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> On Mon, Apr 14, 2008 at 11:53:00AM -0400, Eduardo Valentin wrote:
> > From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >
> > This patch fix lots of warnings and errors reported by
> > scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
>
> Hi, if you're touching mcbsp.c could you please also take a look at
> this:
>
> $ scripts/checkpatch.pl --strict --file arch/arm/plat-omap/mcbsp.c
> CHECK: spinlock_t definition without comment
> #60: FILE: arm/plat-omap/mcbsp.c:60:
> + spinlock_t lock;
>
> total: 0 errors, 0 warnings, 1 checks, 799 lines checked
>
> arch/arm/plat-omap/mcbsp.c has style problems, please review. If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
>
> maybe you could just add this comment and resend this same patch ?
>
For sure. And here is another updated version of the previous patch
with the comment.
> --
> Best Regards,
>
> Felipe Balbi
> me@felipebalbi.com
> http://blog.felipebalbi.com
>
--
Eduardo Bezerra Valentin
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
2008-04-14 20:24 ` Eduardo Valentin
@ 2008-04-14 20:24 ` Eduardo Valentin
2008-04-14 20:41 ` Felipe Balbi
0 siblings, 1 reply; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-14 20:24 UTC (permalink / raw)
To: linux-omap; +Cc: Eduardo Valentin
From: Eduardo Valentin <eduardo.valentin@indt.org.br>
This patch fix lots of warnings and errors reported by
scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
arch/arm/plat-omap/mcbsp.c | 198 +++++++++++++++++++++++---------------------
1 files changed, 103 insertions(+), 95 deletions(-)
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 9cf83c4..053de31 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -21,9 +21,8 @@
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/delay.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
+#include <linux/io.h>
+#include <linux/irq.h>
#include <asm/arch/dma.h>
#include <asm/arch/mux.h>
@@ -61,20 +60,21 @@ struct omap_mcbsp {
struct completion tx_dma_completion;
struct completion rx_dma_completion;
+ /* Protect the field .free, while checking if the mcbsp is in use */
spinlock_t lock;
};
static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
#ifdef CONFIG_ARCH_OMAP1
-static struct clk *mcbsp_dsp_ck = 0;
-static struct clk *mcbsp_api_ck = 0;
-static struct clk *mcbsp_dspxor_ck = 0;
+static struct clk *mcbsp_dsp_ck;
+static struct clk *mcbsp_api_ck;
+static struct clk *mcbsp_dspxor_ck;
#endif
#ifdef CONFIG_ARCH_OMAP2
-static struct clk *mcbsp1_ick = 0;
-static struct clk *mcbsp1_fck = 0;
-static struct clk *mcbsp2_ick = 0;
-static struct clk *mcbsp2_fck = 0;
+static struct clk *mcbsp1_ick;
+static struct clk *mcbsp1_fck;
+static struct clk *mcbsp2_ick;
+static struct clk *mcbsp2_fck;
#endif
static void omap_mcbsp_dump_reg(u8 id)
@@ -104,6 +104,7 @@ static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2));
complete(&mcbsp_tx->tx_irq_completion);
+
return IRQ_HANDLED;
}
@@ -115,6 +116,7 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id)
OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR2));
complete(&mcbsp_rx->rx_irq_completion);
+
return IRQ_HANDLED;
}
@@ -146,19 +148,17 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
complete(&mcbsp_dma_rx->rx_dma_completion);
}
-
/*
* omap_mcbsp_config simply write a config to the
* appropriate McBSP.
* You either call this function or set the McBSP registers
* by yourself before calling omap_mcbsp_start().
*/
-
-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)
{
u32 io_base = mcbsp[id].io_base;
- DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id+1, io_base);
+ DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id + 1, io_base);
/* We write the given config */
OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2);
@@ -173,14 +173,14 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config
OMAP_MCBSP_WRITE(io_base, MCR1, config->mcr1);
OMAP_MCBSP_WRITE(io_base, PCR0, config->pcr0);
}
-
-
+EXPORT_SYMBOL(omap_mcbsp_config);
static int omap_mcbsp_check(unsigned int id)
{
if (cpu_is_omap730()) {
if (id > OMAP_MAX_MCBSP_COUNT - 1) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
+ id + 1);
return -1;
}
return 0;
@@ -188,7 +188,8 @@ static int omap_mcbsp_check(unsigned int id)
if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
if (id > OMAP_MAX_MCBSP_COUNT) {
- printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
+ id + 1);
return -1;
}
return 0;
@@ -263,7 +264,8 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
spin_lock(&mcbsp[id].lock);
if (!mcbsp[id].free) {
- printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
+ id + 1);
spin_unlock(&mcbsp[id].lock);
return -EINVAL;
}
@@ -274,6 +276,7 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_set_io_type);
int omap_mcbsp_request(unsigned int id)
{
@@ -305,7 +308,8 @@ int omap_mcbsp_request(unsigned int id)
spin_lock(&mcbsp[id].lock);
if (!mcbsp[id].free) {
- printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
+ id + 1);
spin_unlock(&mcbsp[id].lock);
return -1;
}
@@ -315,24 +319,23 @@ int omap_mcbsp_request(unsigned int id)
if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) {
/* We need to get IRQs here */
- err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, 0,
- "McBSP",
- (void *) (&mcbsp[id]));
+ err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler,
+ 0, "McBSP", (void *) (&mcbsp[id]));
if (err != 0) {
- printk(KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n",
- mcbsp[id].tx_irq, mcbsp[id].id);
+ printk(KERN_ERR "OMAP-McBSP: Unable to "
+ "request TX IRQ %d for McBSP%d\n",
+ mcbsp[id].tx_irq, mcbsp[id].id);
return err;
}
init_completion(&(mcbsp[id].tx_irq_completion));
-
- err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, 0,
- "McBSP",
- (void *) (&mcbsp[id]));
+ err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler,
+ 0, "McBSP", (void *) (&mcbsp[id]));
if (err != 0) {
- printk(KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n",
- mcbsp[id].rx_irq, mcbsp[id].id);
+ printk(KERN_ERR "OMAP-McBSP: Unable to "
+ "request RX IRQ %d for McBSP%d\n",
+ mcbsp[id].rx_irq, mcbsp[id].id);
free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
return err;
}
@@ -341,8 +344,8 @@ int omap_mcbsp_request(unsigned int id)
}
return 0;
-
}
+EXPORT_SYMBOL(omap_mcbsp_request);
void omap_mcbsp_free(unsigned int id)
{
@@ -370,7 +373,8 @@ void omap_mcbsp_free(unsigned int id)
spin_lock(&mcbsp[id].lock);
if (mcbsp[id].free) {
- printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n", id + 1);
+ printk(KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n",
+ id + 1);
spin_unlock(&mcbsp[id].lock);
return;
}
@@ -384,6 +388,7 @@ void omap_mcbsp_free(unsigned int id)
free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
}
}
+EXPORT_SYMBOL(omap_mcbsp_free);
/*
* Here we start the McBSP, by enabling the sample
@@ -400,8 +405,8 @@ void omap_mcbsp_start(unsigned int id)
io_base = mcbsp[id].io_base;
- 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);
+ 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 */
w = OMAP_MCBSP_READ(io_base, SPCR2);
@@ -422,8 +427,8 @@ void omap_mcbsp_start(unsigned int id)
/* Dump McBSP Regs */
omap_mcbsp_dump_reg(id);
-
}
+EXPORT_SYMBOL(omap_mcbsp_start);
void omap_mcbsp_stop(unsigned int id)
{
@@ -435,7 +440,7 @@ void omap_mcbsp_stop(unsigned int id)
io_base = mcbsp[id].io_base;
- /* Reset transmitter */
+ /* Reset transmitter */
w = OMAP_MCBSP_READ(io_base, SPCR2);
OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1));
@@ -447,7 +452,7 @@ void omap_mcbsp_stop(unsigned int id)
w = OMAP_MCBSP_READ(io_base, SPCR2);
OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1 << 6));
}
-
+EXPORT_SYMBOL(omap_mcbsp_stop);
/* polled mcbsp i/o operations */
int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
@@ -480,10 +485,12 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
}
}
}
+
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_pollwrite);
-int omap_mcbsp_pollread(unsigned int id, u16 * buf)
+int omap_mcbsp_pollread(unsigned int id, u16 *buf)
{
u32 base = mcbsp[id].io_base;
/* if frame sync error - clear the error */
@@ -513,8 +520,10 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf)
}
}
*buf = readw(base + OMAP_MCBSP_REG_DRR1);
+
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_pollread);
/*
* IRQ based word transmission.
@@ -535,6 +544,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
}
+EXPORT_SYMBOL(omap_mcbsp_xmit_word);
u32 omap_mcbsp_recv_word(unsigned int id)
{
@@ -555,7 +565,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
return (word_lsb | (word_msb << 16));
}
-
+EXPORT_SYMBOL(omap_mcbsp_recv_word);
int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
{
@@ -577,7 +587,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
udelay(10);
- printk("McBSP transmitter not ready\n");
+ printk(KERN_ERR "McBSP transmitter not ready\n");
return -EAGAIN;
}
}
@@ -597,7 +607,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
udelay(10);
- printk("McBSP receiver not ready\n");
+ printk(KERN_ERR "McBSP receiver not ready\n");
return -EAGAIN;
}
}
@@ -609,8 +619,9 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
return 0;
}
+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)
{
u32 io_base = mcbsp[id].io_base, clock_word = 0;
omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
@@ -630,7 +641,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
udelay(10);
- printk("McBSP transmitter not ready\n");
+ printk(KERN_ERR "McBSP transmitter not ready\n");
return -EAGAIN;
}
}
@@ -650,7 +661,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
udelay(10);
OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
udelay(10);
- printk("McBSP receiver not ready\n");
+ printk(KERN_ERR "McBSP receiver not ready\n");
return -EAGAIN;
}
}
@@ -664,7 +675,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
return 0;
}
-
+EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
/*
* Simple DMA based buffer rx/tx routines.
@@ -673,7 +684,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
* For anything fancier, you should use your own customized DMA
* routines and callbacks.
*/
-int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
+int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
+ unsigned int length)
{
int dma_tx_ch;
int src_port = 0;
@@ -683,10 +695,12 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
if (omap_mcbsp_check(id) < 0)
return -EINVAL;
- if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX", omap_mcbsp_tx_dma_callback,
- &mcbsp[id],
- &dma_tx_ch)) {
- printk("OMAP-McBSP: Unable to request DMA channel for McBSP%d TX. Trying IRQ based TX\n", id+1);
+ if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
+ omap_mcbsp_tx_dma_callback,
+ &mcbsp[id],
+ &dma_tx_ch)) {
+ printk(KERN_ERR "OMAP-McBSP: Unable to request DMA channel for"
+ " McBSP%d TX. Trying IRQ based TX\n", id + 1);
return -EAGAIN;
}
mcbsp[id].dma_tx_lch = dma_tx_ch;
@@ -722,11 +736,13 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
omap_start_dma(mcbsp[id].dma_tx_lch);
wait_for_completion(&(mcbsp[id].tx_dma_completion));
+
return 0;
}
+EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
-
-int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
+int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
+ unsigned int length)
{
int dma_rx_ch;
int src_port = 0;
@@ -736,10 +752,12 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
if (omap_mcbsp_check(id) < 0)
return -EINVAL;
- if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX", omap_mcbsp_rx_dma_callback,
- &mcbsp[id],
- &dma_rx_ch)) {
- printk("Unable to request DMA channel for McBSP%d RX. Trying IRQ based RX\n", id+1);
+ if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
+ omap_mcbsp_rx_dma_callback,
+ &mcbsp[id],
+ &dma_rx_ch)) {
+ printk(KERN_ERR "Unable to request DMA channel for McBSP%d RX."
+ " Trying IRQ based RX\n", id + 1);
return -EAGAIN;
}
mcbsp[id].dma_rx_lch = dma_rx_ch;
@@ -756,10 +774,10 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
sync_dev = mcbsp[id].dma_rx_sync;
omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
- OMAP_DMA_DATA_TYPE_S16,
- length >> 1, 1,
- OMAP_DMA_SYNC_ELEMENT,
- sync_dev, 0);
+ OMAP_DMA_DATA_TYPE_S16,
+ length >> 1, 1,
+ OMAP_DMA_SYNC_ELEMENT,
+ sync_dev, 0);
omap_set_dma_src_params(mcbsp[id].dma_rx_lch,
src_port,
@@ -768,16 +786,17 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
0, 0);
omap_set_dma_dest_params(mcbsp[id].dma_rx_lch,
- dest_port,
- OMAP_DMA_AMODE_POST_INC,
- buffer,
- 0, 0);
+ dest_port,
+ OMAP_DMA_AMODE_POST_INC,
+ buffer,
+ 0, 0);
omap_start_dma(mcbsp[id].dma_rx_lch);
wait_for_completion(&(mcbsp[id].rx_dma_completion));
+
return 0;
}
-
+EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
/*
* SPI wrapper.
@@ -785,7 +804,8 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
* this wrapper just need an omap_mcbsp_spi_cfg structure as an input.
* Once this is done, you can call omap_mcbsp_start().
*/
-void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg)
+void omap_mcbsp_set_spi_mode(unsigned int id,
+ const struct omap_mcbsp_spi_cfg *spi_cfg)
{
struct omap_mcbsp_reg_cfg mcbsp_cfg;
@@ -798,7 +818,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
mcbsp_cfg.rcr1 |= (RWDLEN1(spi_cfg->word_length) | RFRLEN1(0));
mcbsp_cfg.xcr1 |= (XWDLEN1(spi_cfg->word_length) | XFRLEN1(0));
- /* Clock stop mode */
+ /* Clock stop mode */
if (spi_cfg->clk_stp_mode == OMAP_MCBSP_CLK_STP_MODE_NO_DELAY)
mcbsp_cfg.spcr1 |= (1 << 12);
else
@@ -827,13 +847,12 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
if (spi_cfg->spi_mode == OMAP_MCBSP_SPI_MASTER) {
mcbsp_cfg.pcr0 |= CLKXM;
- mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div -1);
+ mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div - 1);
mcbsp_cfg.pcr0 |= FSXM;
mcbsp_cfg.srgr2 &= ~FSGM;
mcbsp_cfg.xcr2 |= XDATDLY(1);
mcbsp_cfg.rcr2 |= RDATDLY(1);
- }
- else {
+ } else {
mcbsp_cfg.pcr0 &= ~CLKXM;
mcbsp_cfg.srgr1 |= CLKGDV(1);
mcbsp_cfg.pcr0 &= ~FSXM;
@@ -846,7 +865,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
omap_mcbsp_config(id, &mcbsp_cfg);
}
-
+EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
/*
* McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
@@ -935,7 +954,7 @@ static int __init omap_mcbsp_init(void)
int mcbsp_count = 0, i;
static const struct omap_mcbsp_info *mcbsp_info;
- printk("Initializing OMAP McBSP system\n");
+ printk(KERN_INFO "Initializing OMAP McBSP system\n");
#ifdef CONFIG_ARCH_OMAP1
mcbsp_dsp_ck = clk_get(0, "dsp_ck");
@@ -957,22 +976,26 @@ static int __init omap_mcbsp_init(void)
#ifdef CONFIG_ARCH_OMAP2
mcbsp1_ick = clk_get(0, "mcbsp1_ick");
if (IS_ERR(mcbsp1_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp1_ick handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp1_ick handle.\n");
return PTR_ERR(mcbsp1_ick);
}
mcbsp1_fck = clk_get(0, "mcbsp1_fck");
if (IS_ERR(mcbsp1_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp1_fck handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp1_fck handle.\n");
return PTR_ERR(mcbsp1_fck);
}
mcbsp2_ick = clk_get(0, "mcbsp2_ick");
if (IS_ERR(mcbsp2_ick)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp2_ick handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp2_ick handle.\n");
return PTR_ERR(mcbsp2_ick);
}
mcbsp2_fck = clk_get(0, "mcbsp2_fck");
if (IS_ERR(mcbsp2_fck)) {
- printk(KERN_ERR "mcbsp: could not acquire mcbsp2_fck handle.\n");
+ printk(KERN_ERR "mcbsp: could not acquire "
+ "mcbsp2_fck handle.\n");
return PTR_ERR(mcbsp2_fck);
}
#endif
@@ -1006,7 +1029,7 @@ static int __init omap_mcbsp_init(void)
if (i >= mcbsp_count) {
mcbsp[i].io_base = 0;
mcbsp[i].free = 0;
- continue;
+ continue;
}
mcbsp[i].id = i + 1;
mcbsp[i].free = 1;
@@ -1014,7 +1037,8 @@ static int __init omap_mcbsp_init(void)
mcbsp[i].dma_rx_lch = -1;
mcbsp[i].io_base = mcbsp_info[i].virt_base;
- mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO; /* Default I/O is IRQ based */
+ /* Default I/O is IRQ based */
+ mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
@@ -1026,19 +1050,3 @@ static int __init omap_mcbsp_init(void)
}
arch_initcall(omap_mcbsp_init);
-
-EXPORT_SYMBOL(omap_mcbsp_config);
-EXPORT_SYMBOL(omap_mcbsp_request);
-EXPORT_SYMBOL(omap_mcbsp_set_io_type);
-EXPORT_SYMBOL(omap_mcbsp_free);
-EXPORT_SYMBOL(omap_mcbsp_start);
-EXPORT_SYMBOL(omap_mcbsp_stop);
-EXPORT_SYMBOL(omap_mcbsp_pollread);
-EXPORT_SYMBOL(omap_mcbsp_pollwrite);
-EXPORT_SYMBOL(omap_mcbsp_xmit_word);
-EXPORT_SYMBOL(omap_mcbsp_recv_word);
-EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
-EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
-EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
-EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
-EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
--
1.5.5-rc3.GIT
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
2008-04-14 20:24 ` Eduardo Valentin
@ 2008-04-14 20:41 ` Felipe Balbi
2008-04-21 18:18 ` Tony Lindgren
0 siblings, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2008-04-14 20:41 UTC (permalink / raw)
To: Eduardo Valentin; +Cc: linux-omap, Eduardo Valentin
On Mon, Apr 14, 2008 at 04:24:53PM -0400, Eduardo Valentin wrote:
> From: Eduardo Valentin <eduardo.valentin@indt.org.br>
>
> This patch fix lots of warnings and errors reported by
> scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
Acked-by: Felipe Balbi <felipe.balbi@nokia.com>
> ---
> arch/arm/plat-omap/mcbsp.c | 198 +++++++++++++++++++++++---------------------
> 1 files changed, 103 insertions(+), 95 deletions(-)
>
> diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
> index 9cf83c4..053de31 100644
> --- a/arch/arm/plat-omap/mcbsp.c
> +++ b/arch/arm/plat-omap/mcbsp.c
> @@ -21,9 +21,8 @@
> #include <linux/err.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> -
> -#include <asm/io.h>
> -#include <asm/irq.h>
> +#include <linux/io.h>
> +#include <linux/irq.h>
>
> #include <asm/arch/dma.h>
> #include <asm/arch/mux.h>
> @@ -61,20 +60,21 @@ struct omap_mcbsp {
> struct completion tx_dma_completion;
> struct completion rx_dma_completion;
>
> + /* Protect the field .free, while checking if the mcbsp is in use */
> spinlock_t lock;
> };
>
> static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
> #ifdef CONFIG_ARCH_OMAP1
> -static struct clk *mcbsp_dsp_ck = 0;
> -static struct clk *mcbsp_api_ck = 0;
> -static struct clk *mcbsp_dspxor_ck = 0;
> +static struct clk *mcbsp_dsp_ck;
> +static struct clk *mcbsp_api_ck;
> +static struct clk *mcbsp_dspxor_ck;
> #endif
> #ifdef CONFIG_ARCH_OMAP2
> -static struct clk *mcbsp1_ick = 0;
> -static struct clk *mcbsp1_fck = 0;
> -static struct clk *mcbsp2_ick = 0;
> -static struct clk *mcbsp2_fck = 0;
> +static struct clk *mcbsp1_ick;
> +static struct clk *mcbsp1_fck;
> +static struct clk *mcbsp2_ick;
> +static struct clk *mcbsp2_fck;
> #endif
>
> static void omap_mcbsp_dump_reg(u8 id)
> @@ -104,6 +104,7 @@ static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
> OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2));
>
> complete(&mcbsp_tx->tx_irq_completion);
> +
> return IRQ_HANDLED;
> }
>
> @@ -115,6 +116,7 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id)
> OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR2));
>
> complete(&mcbsp_rx->rx_irq_completion);
> +
> return IRQ_HANDLED;
> }
>
> @@ -146,19 +148,17 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
> complete(&mcbsp_dma_rx->rx_dma_completion);
> }
>
> -
> /*
> * omap_mcbsp_config simply write a config to the
> * appropriate McBSP.
> * You either call this function or set the McBSP registers
> * by yourself before calling omap_mcbsp_start().
> */
> -
> -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)
> {
> u32 io_base = mcbsp[id].io_base;
>
> - DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id+1, io_base);
> + DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id + 1, io_base);
>
> /* We write the given config */
> OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2);
> @@ -173,14 +173,14 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config
> OMAP_MCBSP_WRITE(io_base, MCR1, config->mcr1);
> OMAP_MCBSP_WRITE(io_base, PCR0, config->pcr0);
> }
> -
> -
> +EXPORT_SYMBOL(omap_mcbsp_config);
>
> static int omap_mcbsp_check(unsigned int id)
> {
> if (cpu_is_omap730()) {
> if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> + id + 1);
> return -1;
> }
> return 0;
> @@ -188,7 +188,8 @@ static int omap_mcbsp_check(unsigned int id)
>
> if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
> if (id > OMAP_MAX_MCBSP_COUNT) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> + id + 1);
> return -1;
> }
> return 0;
> @@ -263,7 +264,8 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
> spin_lock(&mcbsp[id].lock);
>
> if (!mcbsp[id].free) {
> - printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
> + id + 1);
> spin_unlock(&mcbsp[id].lock);
> return -EINVAL;
> }
> @@ -274,6 +276,7 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
>
> return 0;
> }
> +EXPORT_SYMBOL(omap_mcbsp_set_io_type);
>
> int omap_mcbsp_request(unsigned int id)
> {
> @@ -305,7 +308,8 @@ int omap_mcbsp_request(unsigned int id)
>
> spin_lock(&mcbsp[id].lock);
> if (!mcbsp[id].free) {
> - printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
> + id + 1);
> spin_unlock(&mcbsp[id].lock);
> return -1;
> }
> @@ -315,24 +319,23 @@ int omap_mcbsp_request(unsigned int id)
>
> if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) {
> /* We need to get IRQs here */
> - err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, 0,
> - "McBSP",
> - (void *) (&mcbsp[id]));
> + err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler,
> + 0, "McBSP", (void *) (&mcbsp[id]));
> if (err != 0) {
> - printk(KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n",
> - mcbsp[id].tx_irq, mcbsp[id].id);
> + printk(KERN_ERR "OMAP-McBSP: Unable to "
> + "request TX IRQ %d for McBSP%d\n",
> + mcbsp[id].tx_irq, mcbsp[id].id);
> return err;
> }
>
> init_completion(&(mcbsp[id].tx_irq_completion));
>
> -
> - err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, 0,
> - "McBSP",
> - (void *) (&mcbsp[id]));
> + err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler,
> + 0, "McBSP", (void *) (&mcbsp[id]));
> if (err != 0) {
> - printk(KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n",
> - mcbsp[id].rx_irq, mcbsp[id].id);
> + printk(KERN_ERR "OMAP-McBSP: Unable to "
> + "request RX IRQ %d for McBSP%d\n",
> + mcbsp[id].rx_irq, mcbsp[id].id);
> free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
> return err;
> }
> @@ -341,8 +344,8 @@ int omap_mcbsp_request(unsigned int id)
> }
>
> return 0;
> -
> }
> +EXPORT_SYMBOL(omap_mcbsp_request);
>
> void omap_mcbsp_free(unsigned int id)
> {
> @@ -370,7 +373,8 @@ void omap_mcbsp_free(unsigned int id)
>
> spin_lock(&mcbsp[id].lock);
> if (mcbsp[id].free) {
> - printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n", id + 1);
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n",
> + id + 1);
> spin_unlock(&mcbsp[id].lock);
> return;
> }
> @@ -384,6 +388,7 @@ void omap_mcbsp_free(unsigned int id)
> free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
> }
> }
> +EXPORT_SYMBOL(omap_mcbsp_free);
>
> /*
> * Here we start the McBSP, by enabling the sample
> @@ -400,8 +405,8 @@ void omap_mcbsp_start(unsigned int id)
>
> io_base = mcbsp[id].io_base;
>
> - 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);
> + 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 */
> w = OMAP_MCBSP_READ(io_base, SPCR2);
> @@ -422,8 +427,8 @@ void omap_mcbsp_start(unsigned int id)
>
> /* Dump McBSP Regs */
> omap_mcbsp_dump_reg(id);
> -
> }
> +EXPORT_SYMBOL(omap_mcbsp_start);
>
> void omap_mcbsp_stop(unsigned int id)
> {
> @@ -435,7 +440,7 @@ void omap_mcbsp_stop(unsigned int id)
>
> io_base = mcbsp[id].io_base;
>
> - /* Reset transmitter */
> + /* Reset transmitter */
> w = OMAP_MCBSP_READ(io_base, SPCR2);
> OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1));
>
> @@ -447,7 +452,7 @@ void omap_mcbsp_stop(unsigned int id)
> w = OMAP_MCBSP_READ(io_base, SPCR2);
> OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1 << 6));
> }
> -
> +EXPORT_SYMBOL(omap_mcbsp_stop);
>
> /* polled mcbsp i/o operations */
> int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
> @@ -480,10 +485,12 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
> }
> }
> }
> +
> return 0;
> }
> +EXPORT_SYMBOL(omap_mcbsp_pollwrite);
>
> -int omap_mcbsp_pollread(unsigned int id, u16 * buf)
> +int omap_mcbsp_pollread(unsigned int id, u16 *buf)
> {
> u32 base = mcbsp[id].io_base;
> /* if frame sync error - clear the error */
> @@ -513,8 +520,10 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf)
> }
> }
> *buf = readw(base + OMAP_MCBSP_REG_DRR1);
> +
> return 0;
> }
> +EXPORT_SYMBOL(omap_mcbsp_pollread);
>
> /*
> * IRQ based word transmission.
> @@ -535,6 +544,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
> OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
> OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
> }
> +EXPORT_SYMBOL(omap_mcbsp_xmit_word);
>
> u32 omap_mcbsp_recv_word(unsigned int id)
> {
> @@ -555,7 +565,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
>
> return (word_lsb | (word_msb << 16));
> }
> -
> +EXPORT_SYMBOL(omap_mcbsp_recv_word);
>
> int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
> {
> @@ -577,7 +587,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
> udelay(10);
> OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
> udelay(10);
> - printk("McBSP transmitter not ready\n");
> + printk(KERN_ERR "McBSP transmitter not ready\n");
> return -EAGAIN;
> }
> }
> @@ -597,7 +607,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
> udelay(10);
> OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
> udelay(10);
> - printk("McBSP receiver not ready\n");
> + printk(KERN_ERR "McBSP receiver not ready\n");
> return -EAGAIN;
> }
> }
> @@ -609,8 +619,9 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
>
> return 0;
> }
> +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)
> {
> u32 io_base = mcbsp[id].io_base, clock_word = 0;
> omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
> @@ -630,7 +641,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
> udelay(10);
> OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
> udelay(10);
> - printk("McBSP transmitter not ready\n");
> + printk(KERN_ERR "McBSP transmitter not ready\n");
> return -EAGAIN;
> }
> }
> @@ -650,7 +661,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
> udelay(10);
> OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
> udelay(10);
> - printk("McBSP receiver not ready\n");
> + printk(KERN_ERR "McBSP receiver not ready\n");
> return -EAGAIN;
> }
> }
> @@ -664,7 +675,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
>
> return 0;
> }
> -
> +EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
>
> /*
> * Simple DMA based buffer rx/tx routines.
> @@ -673,7 +684,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
> * For anything fancier, you should use your own customized DMA
> * routines and callbacks.
> */
> -int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
> +int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> + unsigned int length)
> {
> int dma_tx_ch;
> int src_port = 0;
> @@ -683,10 +695,12 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> if (omap_mcbsp_check(id) < 0)
> return -EINVAL;
>
> - if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX", omap_mcbsp_tx_dma_callback,
> - &mcbsp[id],
> - &dma_tx_ch)) {
> - printk("OMAP-McBSP: Unable to request DMA channel for McBSP%d TX. Trying IRQ based TX\n", id+1);
> + if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
> + omap_mcbsp_tx_dma_callback,
> + &mcbsp[id],
> + &dma_tx_ch)) {
> + printk(KERN_ERR "OMAP-McBSP: Unable to request DMA channel for"
> + " McBSP%d TX. Trying IRQ based TX\n", id + 1);
> return -EAGAIN;
> }
> mcbsp[id].dma_tx_lch = dma_tx_ch;
> @@ -722,11 +736,13 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
>
> omap_start_dma(mcbsp[id].dma_tx_lch);
> wait_for_completion(&(mcbsp[id].tx_dma_completion));
> +
> return 0;
> }
> +EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
>
> -
> -int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
> +int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> + unsigned int length)
> {
> int dma_rx_ch;
> int src_port = 0;
> @@ -736,10 +752,12 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> if (omap_mcbsp_check(id) < 0)
> return -EINVAL;
>
> - if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX", omap_mcbsp_rx_dma_callback,
> - &mcbsp[id],
> - &dma_rx_ch)) {
> - printk("Unable to request DMA channel for McBSP%d RX. Trying IRQ based RX\n", id+1);
> + if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
> + omap_mcbsp_rx_dma_callback,
> + &mcbsp[id],
> + &dma_rx_ch)) {
> + printk(KERN_ERR "Unable to request DMA channel for McBSP%d RX."
> + " Trying IRQ based RX\n", id + 1);
> return -EAGAIN;
> }
> mcbsp[id].dma_rx_lch = dma_rx_ch;
> @@ -756,10 +774,10 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> sync_dev = mcbsp[id].dma_rx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
> - OMAP_DMA_DATA_TYPE_S16,
> - length >> 1, 1,
> - OMAP_DMA_SYNC_ELEMENT,
> - sync_dev, 0);
> + OMAP_DMA_DATA_TYPE_S16,
> + length >> 1, 1,
> + OMAP_DMA_SYNC_ELEMENT,
> + sync_dev, 0);
>
> omap_set_dma_src_params(mcbsp[id].dma_rx_lch,
> src_port,
> @@ -768,16 +786,17 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> 0, 0);
>
> omap_set_dma_dest_params(mcbsp[id].dma_rx_lch,
> - dest_port,
> - OMAP_DMA_AMODE_POST_INC,
> - buffer,
> - 0, 0);
> + dest_port,
> + OMAP_DMA_AMODE_POST_INC,
> + buffer,
> + 0, 0);
>
> omap_start_dma(mcbsp[id].dma_rx_lch);
> wait_for_completion(&(mcbsp[id].rx_dma_completion));
> +
> return 0;
> }
> -
> +EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
>
> /*
> * SPI wrapper.
> @@ -785,7 +804,8 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> * this wrapper just need an omap_mcbsp_spi_cfg structure as an input.
> * Once this is done, you can call omap_mcbsp_start().
> */
> -void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg)
> +void omap_mcbsp_set_spi_mode(unsigned int id,
> + const struct omap_mcbsp_spi_cfg *spi_cfg)
> {
> struct omap_mcbsp_reg_cfg mcbsp_cfg;
>
> @@ -798,7 +818,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
> mcbsp_cfg.rcr1 |= (RWDLEN1(spi_cfg->word_length) | RFRLEN1(0));
> mcbsp_cfg.xcr1 |= (XWDLEN1(spi_cfg->word_length) | XFRLEN1(0));
>
> - /* Clock stop mode */
> + /* Clock stop mode */
> if (spi_cfg->clk_stp_mode == OMAP_MCBSP_CLK_STP_MODE_NO_DELAY)
> mcbsp_cfg.spcr1 |= (1 << 12);
> else
> @@ -827,13 +847,12 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
>
> if (spi_cfg->spi_mode == OMAP_MCBSP_SPI_MASTER) {
> mcbsp_cfg.pcr0 |= CLKXM;
> - mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div -1);
> + mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div - 1);
> mcbsp_cfg.pcr0 |= FSXM;
> mcbsp_cfg.srgr2 &= ~FSGM;
> mcbsp_cfg.xcr2 |= XDATDLY(1);
> mcbsp_cfg.rcr2 |= RDATDLY(1);
> - }
> - else {
> + } else {
> mcbsp_cfg.pcr0 &= ~CLKXM;
> mcbsp_cfg.srgr1 |= CLKGDV(1);
> mcbsp_cfg.pcr0 &= ~FSXM;
> @@ -846,7 +865,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
>
> omap_mcbsp_config(id, &mcbsp_cfg);
> }
> -
> +EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
>
> /*
> * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> @@ -935,7 +954,7 @@ static int __init omap_mcbsp_init(void)
> int mcbsp_count = 0, i;
> static const struct omap_mcbsp_info *mcbsp_info;
>
> - printk("Initializing OMAP McBSP system\n");
> + printk(KERN_INFO "Initializing OMAP McBSP system\n");
>
> #ifdef CONFIG_ARCH_OMAP1
> mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> @@ -957,22 +976,26 @@ static int __init omap_mcbsp_init(void)
> #ifdef CONFIG_ARCH_OMAP2
> mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> if (IS_ERR(mcbsp1_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire mcbsp1_ick handle.\n");
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_ick handle.\n");
> return PTR_ERR(mcbsp1_ick);
> }
> mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> if (IS_ERR(mcbsp1_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire mcbsp1_fck handle.\n");
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_fck handle.\n");
> return PTR_ERR(mcbsp1_fck);
> }
> mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> if (IS_ERR(mcbsp2_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire mcbsp2_ick handle.\n");
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_ick handle.\n");
> return PTR_ERR(mcbsp2_ick);
> }
> mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> if (IS_ERR(mcbsp2_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire mcbsp2_fck handle.\n");
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_fck handle.\n");
> return PTR_ERR(mcbsp2_fck);
> }
> #endif
> @@ -1006,7 +1029,7 @@ static int __init omap_mcbsp_init(void)
> if (i >= mcbsp_count) {
> mcbsp[i].io_base = 0;
> mcbsp[i].free = 0;
> - continue;
> + continue;
> }
> mcbsp[i].id = i + 1;
> mcbsp[i].free = 1;
> @@ -1014,7 +1037,8 @@ static int __init omap_mcbsp_init(void)
> mcbsp[i].dma_rx_lch = -1;
>
> mcbsp[i].io_base = mcbsp_info[i].virt_base;
> - mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO; /* Default I/O is IRQ based */
> + /* Default I/O is IRQ based */
> + mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
> mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
> mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
> mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
> @@ -1026,19 +1050,3 @@ static int __init omap_mcbsp_init(void)
> }
>
> arch_initcall(omap_mcbsp_init);
> -
> -EXPORT_SYMBOL(omap_mcbsp_config);
> -EXPORT_SYMBOL(omap_mcbsp_request);
> -EXPORT_SYMBOL(omap_mcbsp_set_io_type);
> -EXPORT_SYMBOL(omap_mcbsp_free);
> -EXPORT_SYMBOL(omap_mcbsp_start);
> -EXPORT_SYMBOL(omap_mcbsp_stop);
> -EXPORT_SYMBOL(omap_mcbsp_pollread);
> -EXPORT_SYMBOL(omap_mcbsp_pollwrite);
> -EXPORT_SYMBOL(omap_mcbsp_xmit_word);
> -EXPORT_SYMBOL(omap_mcbsp_recv_word);
> -EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
> -EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
> -EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
> -EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
> -EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> --
> 1.5.5-rc3.GIT
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best Regards,
Felipe Balbi
me@felipebalbi.com
http://blog.felipebalbi.com
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 20:23 ` Felipe Balbi
@ 2008-04-15 9:38 ` Jarkko Nikula
2008-04-15 9:41 ` Eduardo Valentin
0 siblings, 1 reply; 22+ messages in thread
From: Jarkko Nikula @ 2008-04-15 9:38 UTC (permalink / raw)
To: me; +Cc: Eduardo Valentin, linux-omap, Eduardo Valentin
On Mon, 14 Apr 2008 23:23:39 +0300
"ext Felipe Balbi" <me@felipebalbi.com> wrote:
> On Mon, Apr 14, 2008 at 04:11:31PM -0400, Eduardo Valentin wrote:
> > From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >
> > This patch gets ride of ifdefs on mcbsp.c code.
> > It moves the mach specific code to mach-omap*.
>
> It looks ok, checkpatch.pl returns success, boot-test on n810 is fine
>
Works fine with my ASoC set on N810.
Jarkko
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-15 9:38 ` Jarkko Nikula
@ 2008-04-15 9:41 ` Eduardo Valentin
0 siblings, 0 replies; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-15 9:41 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: me, linux-omap, Eduardo Valentin
Hi Jarkko
On Tue, Apr 15, 2008 at 12:38 PM, Jarkko Nikula <jarkko.nikula@nokia.com> wrote:
> On Mon, 14 Apr 2008 23:23:39 +0300
> "ext Felipe Balbi" <me@felipebalbi.com> wrote:
>
> > On Mon, Apr 14, 2008 at 04:11:31PM -0400, Eduardo Valentin wrote:
> > > From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> > >
> > > This patch gets ride of ifdefs on mcbsp.c code.
> > > It moves the mach specific code to mach-omap*.
> >
> > It looks ok, checkpatch.pl returns success, boot-test on n810 is fine
> >
> Works fine with my ASoC set on N810.
Good to know :)
>
>
> Jarkko
>
--
Eduardo Bezerra Valentin
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 20:11 ` Eduardo Valentin
2008-04-14 20:23 ` Felipe Balbi
@ 2008-04-15 14:49 ` Chandra shekhar
2008-04-15 16:52 ` David Brownell
2008-04-21 18:33 ` Tony Lindgren
2 siblings, 1 reply; 22+ messages in thread
From: Chandra shekhar @ 2008-04-15 14:49 UTC (permalink / raw)
To: 'Eduardo Valentin', linux-omap; +Cc: 'Eduardo Valentin'
I had few suggestions.
1>
Clock structure can be moved to header file and create a structure.
So that instead of calling each clock by its name,( big problem for 2430 and 34xx
Which has 5 mcbsp instances) it can be called by Using mcbsp id.
Something like this can be done...
static char omap_mcbsp_ick[][12] = {"mcbsp1_ick\0",
"mcbsp2_ick\0",.........
};
static char omap_mcbsp_fck[][12] = {"mcbsp1_fck\0",
"mcbsp2_fck\0",.........
};
static struct omap_mcbsp_clocks {
struct clk *ick;
struct clk *fck;
} omap_mcbsp_clk[OMAP_MAX_MCBSP_COUNT];
clk_enable(omap_mcbsp_clk[id].ick);
Clk_get or clk_enable/disable will be much simplified.
2> mcbsp structure omap_mcbsp can be moved to header file too. This is to facilitate new
OMAP2 and OMAP3 specific APIs, who might use the structure.
Regards,
Chandra Shekhar
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of
> Eduardo Valentin
> Sent: Tuesday, April 15, 2008 1:42 AM
> To: linux-omap@vger.kernel.org
> Cc: Eduardo Valentin
> Subject: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach
> specific from plat-omap to mach-omap
>
> From: Eduardo Valentin <eduardo.valentin@indt.org.br>
>
> This patch gets ride of ifdefs on mcbsp.c code.
> It moves the mach specific code to mach-omap*.
>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> ---
> arch/arm/mach-omap1/Makefile | 2 +
> arch/arm/mach-omap1/mcbsp.c | 202 +++++++++++++++++++++
> arch/arm/mach-omap2/Makefile | 2 +
> arch/arm/mach-omap2/mcbsp.c | 145 ++++++++++++++++
> arch/arm/plat-omap/mcbsp.c | 346
> +++++--------------------------------
> include/asm-arm/arch-omap/mcbsp.h | 19 ++
> 6 files changed, 417 insertions(+), 299 deletions(-) create
> mode 100644 arch/arm/mach-omap1/mcbsp.c create mode 100644
> arch/arm/mach-omap2/mcbsp.c
>
> diff --git a/arch/arm/mach-omap1/Makefile
> b/arch/arm/mach-omap1/Makefile index 6ebf23b..09246a7 100644
> --- a/arch/arm/mach-omap1/Makefile
> +++ b/arch/arm/mach-omap1/Makefile
> @@ -5,6 +5,8 @@
> # Common support
> obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
> obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
>
> diff --git a/arch/arm/mach-omap1/mcbsp.c
> b/arch/arm/mach-omap1/mcbsp.c new file mode 100644 index
> 0000000..299f036
> --- /dev/null
> +++ b/arch/arm/mach-omap1/mcbsp.c
> @@ -0,0 +1,202 @@
> +/*
> + * linux/arch/arm/mach-omap1/mcbsp.c
> + *
> + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> + *
> + * This program is free software; you can redistribute it
> and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Multichannel mode not supported.
> + */
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +
> +#include <asm/arch/dma.h>
> +#include <asm/arch/mux.h>
> +#include <asm/arch/cpu.h>
> +#include <asm/arch/mcbsp.h>
> +#include <asm/arch/dsp_common.h>
> +
> +static struct clk *mcbsp_dsp_ck;
> +static struct clk *mcbsp_api_ck;
> +static struct clk *mcbsp_dspxor_ck;
> +
> +static void omap_mcbsp_dsp_request(void) {
> + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> + int ret;
> +
> + ret = omap_dsp_request_mem();
> + if (ret < 0) {
> + printk(KERN_ERR "Could not get dsp
> memory: %i\n", ret);
> + return;
> + }
> +
> + clk_enable(mcbsp_dsp_ck);
> + clk_enable(mcbsp_api_ck);
> +
> + /* enable 12MHz clock to mcbsp 1 & 3 */
> + clk_enable(mcbsp_dspxor_ck);
> +
> + /*
> + * DSP external peripheral reset
> + * FIXME: This should be moved to dsp code
> + */
> + __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> + DSP_RSTCT2);
> + }
> +}
> +
> +static void omap_mcbsp_dsp_free(void)
> +{
> + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> + omap_dsp_release_mem();
> + clk_disable(mcbsp_dspxor_ck);
> + clk_disable(mcbsp_dsp_ck);
> + clk_disable(mcbsp_api_ck);
> + }
> +}
> +
> +static int omap1_mcbsp_check(unsigned int id) {
> + if (cpu_is_omap730()) {
> + if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> + 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) {
> + 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) {
> + /*
> + * On 1510, 1610 and 1710, McBSP1 and McBSP3
> + * are DSP public peripherals.
> + */
> + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> + omap_mcbsp_dsp_request();
> +}
> +
> +static void omap1_mcbsp_free(unsigned int id) {
> + if (cpu_class_is_omap1()) {
> + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> + omap_mcbsp_dsp_free();
> + }
> +}
> +
> +struct omap_mcbsp_board_cfg omap1_mcbsp_cfg = {
> + .check = omap1_mcbsp_check,
> + .request = omap1_mcbsp_request,
> + .free = omap1_mcbsp_free,
> + .mcbsp_infos =
> +#ifdef CONFIG_ARCH_OMAP730
> + {
> + [0] = {
> + .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_730_McBSP1RX,
> + .tx_irq = INT_730_McBSP1TX,
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_730_McBSP2RX,
> + .tx_irq = INT_730_McBSP2TX
> + },
> + },
> +#elif defined(CONFIG_ARCH_OMAP15XX)
> + {
> + [0] = {
> + .virt_base = OMAP1510_MCBSP1_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_McBSP1RX,
> + .tx_irq = INT_McBSP1TX
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> + .rx_irq = INT_1510_SPI_RX,
> + .tx_irq = INT_1510_SPI_TX
> + },
> + [2] = {
> + .virt_base = OMAP1510_MCBSP3_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_McBSP3RX,
> + .tx_irq = INT_McBSP3TX
> + },
> +#elif defined(CONFIG_ARCH_OMAP16XX)
> + {
> + [0] = {
> + .virt_base = OMAP1610_MCBSP1_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_McBSP1RX,
> + .tx_irq = INT_McBSP1TX
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> + .rx_irq = INT_1610_McBSP2_RX,
> + .tx_irq = INT_1610_McBSP2_TX
> + },
> + [2] = {
> + .virt_base = OMAP1610_MCBSP3_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_McBSP3RX,
> + .tx_irq = INT_McBSP3TX
> + },
> + },
> +#else
> +NULL /* For .mcbsp_infos */
> +#endif
> +};
> +
> +int __init omap1_mcbsp_init(void)
> +{
> + mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> + if (IS_ERR(mcbsp_dsp_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire
> dsp_ck handle.\n");
> + return PTR_ERR(mcbsp_dsp_ck);
> + }
> + mcbsp_api_ck = clk_get(0, "api_ck");
> + if (IS_ERR(mcbsp_api_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire
> api_ck handle.\n");
> + return PTR_ERR(mcbsp_api_ck);
> + }
> + mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> + if (IS_ERR(mcbsp_dspxor_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire
> dspxor_ck handle.\n");
> + return PTR_ERR(mcbsp_dspxor_ck);
> + }
> +
> + omap_mcbsp_register_board_cfg(&omap1_mcbsp_cfg);
> +
> + return omap_mcbsp_init();
> +}
> +arch_initcall(omap1_mcbsp_init);
> diff --git a/arch/arm/mach-omap2/Makefile
> b/arch/arm/mach-omap2/Makefile index 5157ff2..771f8e7 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -6,6 +6,8 @@
> obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
> devices.o serial.o gpmc.o timer-gp.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> # Functions loaded to SRAM
> obj-$(CONFIG_ARCH_OMAP2) += sram24xx.o
>
> diff --git a/arch/arm/mach-omap2/mcbsp.c
> b/arch/arm/mach-omap2/mcbsp.c new file mode 100644 index
> 0000000..8c8b97f
> --- /dev/null
> +++ b/arch/arm/mach-omap2/mcbsp.c
> @@ -0,0 +1,145 @@
> +/*
> + * linux/arch/arm/mach-omap1/mcbsp.c
> + *
> + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> + *
> + * This program is free software; you can redistribute it
> and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Multichannel mode not supported.
> + */
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +
> +#include <asm/arch/dma.h>
> +#include <asm/arch/mux.h>
> +#include <asm/arch/cpu.h>
> +#include <asm/arch/mcbsp.h>
> +
> +static struct clk *mcbsp1_ick;
> +static struct clk *mcbsp1_fck;
> +static struct clk *mcbsp2_ick;
> +static struct clk *mcbsp2_fck;
> +
> +static void omap2_mcbsp2_mux_setup(void) {
> + if (cpu_is_omap2420()) {
> + omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> + omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> + omap_cfg_reg(W15_24XX_MCBSP2_DR);
> + omap_cfg_reg(V15_24XX_MCBSP2_DX);
> + omap_cfg_reg(V14_24XX_GPIO117);
> + }
> + /*
> + * Need to add MUX settings for OMAP 2430 SDP
> + */
> +}
> +
> +static int omap2_mcbsp_check(unsigned int id) {
> + if (cpu_class_is_omap2()) {
> + if (id > OMAP_MAX_MCBSP_COUNT) {
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d
> doesn't exist\n",
> + id + 1);
> + return -ENODEV;
> + }
> + return 0;
> + }
> +
> + return -ENODEV;
> +}
> +
> +static void omap2_mcbsp_request(unsigned int id) {
> + if (cpu_class_is_omap2()) {
> + if (id == OMAP_MCBSP1) {
> + clk_enable(mcbsp1_ick);
> + clk_enable(mcbsp1_fck);
> + } else {
> + clk_enable(mcbsp2_ick);
> + clk_enable(mcbsp2_fck);
> + }
> + }
> +}
> +static void omap2_mcbsp_free(unsigned int id) {
> + if (cpu_class_is_omap2()) {
> + if (id == OMAP_MCBSP1) {
> + clk_disable(mcbsp1_ick);
> + clk_disable(mcbsp1_fck);
> + } else {
> + clk_disable(mcbsp2_ick);
> + clk_disable(mcbsp2_fck);
> + }
> + }
> +}
> +
> +static const struct omap_mcbsp_board_cfg mcbsp_24xx_cfg = {
> + .check = omap2_mcbsp_check,
> + .request = omap2_mcbsp_request,
> + .free = omap2_mcbsp_free,
> + .mcbsp_infos = {
> + [0] = {
> +#if defined(CONFIG_ARCH_OMAP24XX)
> + .virt_base =
> IO_ADDRESS(OMAP24XX_MCBSP1_BASE), #elif
> +defined(CONFIG_ARCH_OMAP34XX)
> + .virt_base =
> IO_ADDRESS(OMAP34XX_MCBSP1_BASE), #endif
> + .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> + .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> + .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> + },
> + [1] = {
> +#if defined(CONFIG_ARCH_OMAP24XX)
> + .virt_base =
> IO_ADDRESS(OMAP24XX_MCBSP2_BASE), #elif
> +defined(CONFIG_ARCH_OMAP34XX)
> + .virt_base =
> IO_ADDRESS(OMAP34XX_MCBSP2_BASE), #endif
> + .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> + .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> + .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> + },
> + },
> +};
> +
> +int __init omap2_mcbsp_init(void)
> +{
> + mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> + if (IS_ERR(mcbsp1_ick)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_ick handle.\n");
> + return PTR_ERR(mcbsp1_ick);
> + }
> + mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> + if (IS_ERR(mcbsp1_fck)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_fck handle.\n");
> + return PTR_ERR(mcbsp1_fck);
> + }
> + mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> + if (IS_ERR(mcbsp2_ick)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_ick handle.\n");
> + return PTR_ERR(mcbsp2_ick);
> + }
> + mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> + if (IS_ERR(mcbsp2_fck)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_fck handle.\n");
> + return PTR_ERR(mcbsp2_fck);
> + }
> +
> + if (cpu_class_is_omap2()) {
> + omap_mcbsp_register_board_cfg(&mcbsp_24xx_cfg);
> + omap2_mcbsp2_mux_setup();
> + }
> +
> + return omap_mcbsp_init();
> +}
> +arch_initcall(omap2_mcbsp_init);
> diff --git a/arch/arm/plat-omap/mcbsp.c
> b/arch/arm/plat-omap/mcbsp.c index 053de31..fdba002 100644
> --- a/arch/arm/plat-omap/mcbsp.c
> +++ b/arch/arm/plat-omap/mcbsp.c
> @@ -24,11 +24,8 @@
> #include <linux/io.h>
> #include <linux/irq.h>
>
> -#include <asm/arch/dma.h>
> -#include <asm/arch/mux.h>
> -#include <asm/arch/irqs.h>
> -#include <asm/arch/dsp_common.h>
> #include <asm/arch/mcbsp.h>
> +#include <asm/arch/dma.h>
>
> #ifdef CONFIG_MCBSP_DEBUG
> #define DBG(x...) printk(x)
> @@ -65,17 +62,10 @@ struct omap_mcbsp {
> };
>
> static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
> -#ifdef CONFIG_ARCH_OMAP1 -static struct clk *mcbsp_dsp_ck;
> -static struct clk *mcbsp_api_ck; -static struct clk
> *mcbsp_dspxor_ck; -#endif -#ifdef CONFIG_ARCH_OMAP2 -static
> struct clk *mcbsp1_ick; -static struct clk *mcbsp1_fck;
> -static struct clk *mcbsp2_ick; -static struct clk
> *mcbsp2_fck; -#endif
> +static const struct omap_mcbsp_board_cfg *mcbsp_config;
> +
> +#define omap_mcbsp_check_invalid_id(id) (mcbsp_config
> && mcbsp_config->check \
> + &&
> (mcbsp_config->check(id) < 0))
>
> static void omap_mcbsp_dump_reg(u8 id)
> {
> @@ -175,90 +165,13 @@ void omap_mcbsp_config(unsigned int id,
> const struct omap_mcbsp_reg_cfg *config) }
> EXPORT_SYMBOL(omap_mcbsp_config);
>
> -static int omap_mcbsp_check(unsigned int id) -{
> - if (cpu_is_omap730()) {
> - if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d
> doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - if (cpu_is_omap15xx() || cpu_is_omap16xx() ||
> cpu_is_omap24xx()) {
> - if (id > OMAP_MAX_MCBSP_COUNT) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d
> doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - return -1;
> -}
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -static void omap_mcbsp_dsp_request(void) -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - int ret;
> -
> - ret = omap_dsp_request_mem();
> - if (ret < 0) {
> - printk(KERN_ERR "Could not get dsp
> memory: %i\n", ret);
> - return;
> - }
> -
> - clk_enable(mcbsp_dsp_ck);
> - clk_enable(mcbsp_api_ck);
> -
> - /* enable 12MHz clock to mcbsp 1 & 3 */
> - clk_enable(mcbsp_dspxor_ck);
> -
> - /*
> - * DSP external peripheral reset
> - * FIXME: This should be moved to dsp code
> - */
> - __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> - DSP_RSTCT2);
> - }
> -}
> -
> -static void omap_mcbsp_dsp_free(void)
> -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - omap_dsp_release_mem();
> - clk_disable(mcbsp_dspxor_ck);
> - clk_disable(mcbsp_dsp_ck);
> - clk_disable(mcbsp_api_ck);
> - }
> -}
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> -static void omap2_mcbsp2_mux_setup(void) -{
> - if (cpu_is_omap2420()) {
> - omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> - omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> - omap_cfg_reg(W15_24XX_MCBSP2_DR);
> - omap_cfg_reg(V15_24XX_MCBSP2_DX);
> - omap_cfg_reg(V14_24XX_GPIO117);
> - }
> - /*
> - * Need to add MUX settings for OMAP 2430 SDP
> - */
> -}
> -#endif
> -
> /*
> * We can choose between IRQ based or polled IO.
> * This needs to be called before omap_mcbsp_request().
> */
> int omap_mcbsp_set_io_type(unsigned int id,
> omap_mcbsp_io_type_t io_type) {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> spin_lock(&mcbsp[id].lock);
> @@ -282,29 +195,11 @@ int omap_mcbsp_request(unsigned int id) {
> int err;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - /*
> - * On 1510, 1610 and 1710, McBSP1 and McBSP3
> - * are DSP public peripherals.
> - */
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_request();
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_enable(mcbsp1_ick);
> - clk_enable(mcbsp1_fck);
> - } else {
> - clk_enable(mcbsp2_ick);
> - clk_enable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->request)
> + mcbsp_config->request(id);
>
> spin_lock(&mcbsp[id].lock);
> if (!mcbsp[id].free) {
> @@ -349,27 +244,11 @@ EXPORT_SYMBOL(omap_mcbsp_request);
>
> void omap_mcbsp_free(unsigned int id)
> {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - if (cpu_class_is_omap1()) {
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_free();
> - }
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_disable(mcbsp1_ick);
> - clk_disable(mcbsp1_fck);
> - } else {
> - clk_disable(mcbsp2_ick);
> - clk_disable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->free)
> + mcbsp_config->free(id);
>
> spin_lock(&mcbsp[id].lock);
> if (mcbsp[id].free) {
> @@ -400,7 +279,7 @@ void omap_mcbsp_start(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -435,7 +314,7 @@ void omap_mcbsp_stop(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -533,7 +412,7 @@ void omap_mcbsp_xmit_word(unsigned int
> id, u32 word)
> u32 io_base;
> omap_mcbsp_word_length word_length = mcbsp[id].tx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -552,7 +431,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
> u16 word_lsb, word_msb = 0;
> omap_mcbsp_word_length word_length = mcbsp[id].rx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> io_base = mcbsp[id].io_base;
> @@ -692,7 +571,7 @@ int omap_mcbsp_xmit_buffer(unsigned int
> id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
> @@ -713,7 +592,7 @@ int omap_mcbsp_xmit_buffer(unsigned int
> id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_tx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
> @@ -749,7 +628,7 @@ int omap_mcbsp_recv_buffer(unsigned int
> id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
> @@ -770,7 +649,7 @@ int omap_mcbsp_recv_buffer(unsigned int
> id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_rx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
> @@ -809,7 +688,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, {
> struct omap_mcbsp_reg_cfg mcbsp_cfg;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> memset(&mcbsp_cfg, 0, sizeof(struct
> omap_mcbsp_reg_cfg)); @@ -871,162 +750,19 @@
> EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> * 730 has only 2 McBSP, and both of them are MPU peripherals.
> */
> -struct omap_mcbsp_info {
> - u32 virt_base;
> - u8 dma_rx_sync, dma_tx_sync;
> - u16 rx_irq, tx_irq;
> -};
> -
> -#ifdef CONFIG_ARCH_OMAP730
> -static const struct omap_mcbsp_info mcbsp_730[] = {
> - [0] = { .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_730_McBSP1RX,
> - .tx_irq = INT_730_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_730_McBSP2RX,
> - .tx_irq = INT_730_McBSP2TX },
> -};
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP15XX
> -static const struct omap_mcbsp_info mcbsp_1510[] = {
> - [0] = { .virt_base = OMAP1510_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1510_SPI_RX,
> - .tx_irq = INT_1510_SPI_TX },
> - [2] = { .virt_base = OMAP1510_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP16XX)
> -static const struct omap_mcbsp_info mcbsp_1610[] = {
> - [0] = { .virt_base = OMAP1610_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1610_McBSP2_RX,
> - .tx_irq = INT_1610_McBSP2_TX },
> - [2] = { .virt_base = OMAP1610_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP24XX)
> -static const struct omap_mcbsp_info mcbsp_24xx[] = {
> - [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> - .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> - },
> - [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> - .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> - },
> -};
> -#endif
> -
> -static int __init omap_mcbsp_init(void)
> +int __init omap_mcbsp_init(void)
> {
> - int mcbsp_count = 0, i;
> - static const struct omap_mcbsp_info *mcbsp_info;
> + int i;
>
> - printk(KERN_INFO "Initializing OMAP McBSP system\n");
> -
> -#ifdef CONFIG_ARCH_OMAP1
> - mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> - if (IS_ERR(mcbsp_dsp_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire
> dsp_ck handle.\n");
> - return PTR_ERR(mcbsp_dsp_ck);
> - }
> - mcbsp_api_ck = clk_get(0, "api_ck");
> - if (IS_ERR(mcbsp_api_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire
> api_ck handle.\n");
> - return PTR_ERR(mcbsp_api_ck);
> - }
> - mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> - if (IS_ERR(mcbsp_dspxor_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire
> dspxor_ck handle.\n");
> - return PTR_ERR(mcbsp_dspxor_ck);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP2
> - mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> - if (IS_ERR(mcbsp1_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_ick handle.\n");
> - return PTR_ERR(mcbsp1_ick);
> - }
> - mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> - if (IS_ERR(mcbsp1_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_fck handle.\n");
> - return PTR_ERR(mcbsp1_fck);
> - }
> - mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> - if (IS_ERR(mcbsp2_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_ick handle.\n");
> - return PTR_ERR(mcbsp2_ick);
> - }
> - mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> - if (IS_ERR(mcbsp2_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_fck handle.\n");
> - return PTR_ERR(mcbsp2_fck);
> + if (!mcbsp_config) {
> + printk(KERN_ERR "McBSP initialized without
> configuration\n");
> + return -EINVAL;
> }
> -#endif
>
> -#ifdef CONFIG_ARCH_OMAP730
> - if (cpu_is_omap730()) {
> - mcbsp_info = mcbsp_730;
> - mcbsp_count = ARRAY_SIZE(mcbsp_730);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP15XX
> - if (cpu_is_omap15xx()) {
> - mcbsp_info = mcbsp_1510;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1510);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP16XX)
> - if (cpu_is_omap16xx()) {
> - mcbsp_info = mcbsp_1610;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1610);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP24XX)
> - if (cpu_is_omap24xx()) {
> - mcbsp_info = mcbsp_24xx;
> - mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
> - omap2_mcbsp2_mux_setup();
> - }
> -#endif
> + printk(KERN_INFO "Initializing OMAP McBSP system\n");
> +
> for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
> - if (i >= mcbsp_count) {
> + if (i >= ARRAY_SIZE(mcbsp_config->mcbsp_infos)) {
> mcbsp[i].io_base = 0;
> mcbsp[i].free = 0;
> continue;
> @@ -1036,17 +772,29 @@ static int __init omap_mcbsp_init(void)
> mcbsp[i].dma_tx_lch = -1;
> mcbsp[i].dma_rx_lch = -1;
>
> - mcbsp[i].io_base = mcbsp_info[i].virt_base;
> + mcbsp[i].io_base =
> mcbsp_config->mcbsp_infos[i].virt_base;
> /* Default I/O is IRQ based */
> mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
> - mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
> - mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
> - mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
> - mcbsp[i].dma_tx_sync = mcbsp_info[i].dma_tx_sync;
> + mcbsp[i].tx_irq = mcbsp_config->mcbsp_infos[i].tx_irq;
> + mcbsp[i].rx_irq = mcbsp_config->mcbsp_infos[i].rx_irq;
> + mcbsp[i].dma_rx_sync =
> mcbsp_config->mcbsp_infos[i].dma_rx_sync;
> + mcbsp[i].dma_tx_sync =
> mcbsp_config->mcbsp_infos[i].dma_tx_sync;
> spin_lock_init(&mcbsp[i].lock);
> }
>
> return 0;
> }
>
> -arch_initcall(omap_mcbsp_init);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg
> +*config) {
> + if (!config || !config->request || !config->free) {
> + printk(KERN_ERR "Invalid McBSP configuration\n");
> + return -EINVAL;
> + }
> +
> + mcbsp_config = config;
> +
> + return 0;
> +
> +}
> +
> diff --git a/include/asm-arm/arch-omap/mcbsp.h
> b/include/asm-arm/arch-omap/mcbsp.h
> index b53c3b2..fc53a45 100644
> --- a/include/asm-arm/arch-omap/mcbsp.h
> +++ b/include/asm-arm/arch-omap/mcbsp.h
> @@ -40,6 +40,9 @@
> #define OMAP24XX_MCBSP1_BASE 0x48074000
> #define OMAP24XX_MCBSP2_BASE 0x48076000
>
> +#define OMAP34XX_MCBSP1_BASE 0x48074000
> +#define OMAP34XX_MCBSP2_BASE 0x49022000
> +
> #if defined(CONFIG_ARCH_OMAP15XX) ||
> defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
>
> #define OMAP_MCBSP_REG_DRR2 0x00
> @@ -298,6 +301,22 @@ struct omap_mcbsp_spi_cfg {
> omap_mcbsp_word_length word_length;
> };
>
> +/* Board specific configuration */
> +struct omap_mcbsp_info {
> + u32 virt_base;
> + u8 dma_rx_sync, dma_tx_sync;
> + u16 rx_irq, tx_irq;
> +};
> +
> +struct omap_mcbsp_board_cfg {
> + void (*request)(unsigned int);
> + void (*free)(unsigned int);
> + int (*check)(unsigned int);
> + struct omap_mcbsp_info mcbsp_infos[OMAP_MAX_MCBSP_COUNT];
> +};
> +
> +int omap_mcbsp_init(void);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg
> +*config);
> void omap_mcbsp_config(unsigned int id, const struct
> omap_mcbsp_reg_cfg * config); int
> omap_mcbsp_request(unsigned int id); void
> omap_mcbsp_free(unsigned int id);
> --
> 1.5.5-rc3.GIT
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-omap" in the body of a message to
> majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-15 14:49 ` Chandra shekhar
@ 2008-04-15 16:52 ` David Brownell
2008-04-15 19:09 ` Tony Lindgren
0 siblings, 1 reply; 22+ messages in thread
From: David Brownell @ 2008-04-15 16:52 UTC (permalink / raw)
To: Chandra shekhar
Cc: 'Eduardo Valentin', linux-omap,
'Eduardo Valentin'
I've not been following these McBSP issues, but this
comment suggests to me that the clock API is just not
being used "correctly" here:
On Tuesday 15 April 2008, Chandra shekhar wrote:
> 1>
> Clock structure can be moved to header file and create a structure.
> So that instead of calling each clock by its name,( big problem for 2430 and 34xx
> Which has 5 mcbsp instances) it can be called by Using mcbsp id.
>
> Something like this can be done...
>
> static char omap_mcbsp_ick[][12] = {"mcbsp1_ick\0",
> "mcbsp2_ick\0",.........
>
> };
>
> static char omap_mcbsp_fck[][12] = {"mcbsp1_fck\0",
> "mcbsp2_fck\0",.........
> };
>
> static struct omap_mcbsp_clocks {
> struct clk *ick;
> struct clk *fck;
> } omap_mcbsp_clk[OMAP_MAX_MCBSP_COUNT];
>
> clk_enable(omap_mcbsp_clk[id].ick);
>
> Clk_get or clk_enable/disable will be much simplified.
The "correct" way to use the clock ACPI would be like:
struct device *mcbsp = ... something ... ;
struct clk *ick, *mck;
ick = clk_get(mcbsp, "ick");
fck = clk_get(mcbsp, "fck");
That is, don't expect clients to use names like "mcbsp2_fck" and
know which McBSP they're using ... just expect them to know
they have *some* module, and that its clock has generic names
such as "ick" and "fck".
Of course, working that way may involve a bunch of other changes...
- Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-15 16:52 ` David Brownell
@ 2008-04-15 19:09 ` Tony Lindgren
0 siblings, 0 replies; 22+ messages in thread
From: Tony Lindgren @ 2008-04-15 19:09 UTC (permalink / raw)
To: David Brownell
Cc: Chandra shekhar, 'Eduardo Valentin', linux-omap,
'Eduardo Valentin'
* David Brownell <david-b@pacbell.net> [080415 09:54]:
> I've not been following these McBSP issues, but this
> comment suggests to me that the clock API is just not
> being used "correctly" here:
>
> On Tuesday 15 April 2008, Chandra shekhar wrote:
> > 1>
> > Clock structure can be moved to header file and create a structure.
> > So that instead of calling each clock by its name,( big problem for 2430 and 34xx
> > Which has 5 mcbsp instances) it can be called by Using mcbsp id.
> >
> > Something like this can be done...
> >
> > static char omap_mcbsp_ick[][12] = {"mcbsp1_ick\0",
> > "mcbsp2_ick\0",.........
> >
> > };
> >
> > static char omap_mcbsp_fck[][12] = {"mcbsp1_fck\0",
> > "mcbsp2_fck\0",.........
> > };
> >
> > static struct omap_mcbsp_clocks {
> > struct clk *ick;
> > struct clk *fck;
> > } omap_mcbsp_clk[OMAP_MAX_MCBSP_COUNT];
> >
> > clk_enable(omap_mcbsp_clk[id].ick);
> >
> > Clk_get or clk_enable/disable will be much simplified.
>
> The "correct" way to use the clock ACPI would be like:
>
> struct device *mcbsp = ... something ... ;
> struct clk *ick, *mck;
>
> ick = clk_get(mcbsp, "ick");
> fck = clk_get(mcbsp, "fck");
>
> That is, don't expect clients to use names like "mcbsp2_fck" and
> know which McBSP they're using ... just expect them to know
> they have *some* module, and that its clock has generic names
> such as "ick" and "fck".
>
> Of course, working that way may involve a bunch of other changes...
Yes, that's right the right clock should be found automatically based
on the clock name and instance number.
Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
2008-04-14 20:41 ` Felipe Balbi
@ 2008-04-21 18:18 ` Tony Lindgren
0 siblings, 0 replies; 22+ messages in thread
From: Tony Lindgren @ 2008-04-21 18:18 UTC (permalink / raw)
To: Felipe Balbi; +Cc: Eduardo Valentin, linux-omap, Eduardo Valentin
* Felipe Balbi <me@felipebalbi.com> [080414 13:40]:
> On Mon, Apr 14, 2008 at 04:24:53PM -0400, Eduardo Valentin wrote:
> > From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >
> > This patch fix lots of warnings and errors reported by
> > scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> Acked-by: Felipe Balbi <felipe.balbi@nokia.com>
Pushing today.
Tony
> > ---
> > arch/arm/plat-omap/mcbsp.c | 198 +++++++++++++++++++++++---------------------
> > 1 files changed, 103 insertions(+), 95 deletions(-)
> >
> > diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
> > index 9cf83c4..053de31 100644
> > --- a/arch/arm/plat-omap/mcbsp.c
> > +++ b/arch/arm/plat-omap/mcbsp.c
> > @@ -21,9 +21,8 @@
> > #include <linux/err.h>
> > #include <linux/clk.h>
> > #include <linux/delay.h>
> > -
> > -#include <asm/io.h>
> > -#include <asm/irq.h>
> > +#include <linux/io.h>
> > +#include <linux/irq.h>
> >
> > #include <asm/arch/dma.h>
> > #include <asm/arch/mux.h>
> > @@ -61,20 +60,21 @@ struct omap_mcbsp {
> > struct completion tx_dma_completion;
> > struct completion rx_dma_completion;
> >
> > + /* Protect the field .free, while checking if the mcbsp is in use */
> > spinlock_t lock;
> > };
> >
> > static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
> > #ifdef CONFIG_ARCH_OMAP1
> > -static struct clk *mcbsp_dsp_ck = 0;
> > -static struct clk *mcbsp_api_ck = 0;
> > -static struct clk *mcbsp_dspxor_ck = 0;
> > +static struct clk *mcbsp_dsp_ck;
> > +static struct clk *mcbsp_api_ck;
> > +static struct clk *mcbsp_dspxor_ck;
> > #endif
> > #ifdef CONFIG_ARCH_OMAP2
> > -static struct clk *mcbsp1_ick = 0;
> > -static struct clk *mcbsp1_fck = 0;
> > -static struct clk *mcbsp2_ick = 0;
> > -static struct clk *mcbsp2_fck = 0;
> > +static struct clk *mcbsp1_ick;
> > +static struct clk *mcbsp1_fck;
> > +static struct clk *mcbsp2_ick;
> > +static struct clk *mcbsp2_fck;
> > #endif
> >
> > static void omap_mcbsp_dump_reg(u8 id)
> > @@ -104,6 +104,7 @@ static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
> > OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2));
> >
> > complete(&mcbsp_tx->tx_irq_completion);
> > +
> > return IRQ_HANDLED;
> > }
> >
> > @@ -115,6 +116,7 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id)
> > OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR2));
> >
> > complete(&mcbsp_rx->rx_irq_completion);
> > +
> > return IRQ_HANDLED;
> > }
> >
> > @@ -146,19 +148,17 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
> > complete(&mcbsp_dma_rx->rx_dma_completion);
> > }
> >
> > -
> > /*
> > * omap_mcbsp_config simply write a config to the
> > * appropriate McBSP.
> > * You either call this function or set the McBSP registers
> > * by yourself before calling omap_mcbsp_start().
> > */
> > -
> > -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)
> > {
> > u32 io_base = mcbsp[id].io_base;
> >
> > - DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id+1, io_base);
> > + DBG("OMAP-McBSP: McBSP%d io_base: 0x%8x\n", id + 1, io_base);
> >
> > /* We write the given config */
> > OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2);
> > @@ -173,14 +173,14 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config
> > OMAP_MCBSP_WRITE(io_base, MCR1, config->mcr1);
> > OMAP_MCBSP_WRITE(io_base, PCR0, config->pcr0);
> > }
> > -
> > -
> > +EXPORT_SYMBOL(omap_mcbsp_config);
> >
> > static int omap_mcbsp_check(unsigned int id)
> > {
> > if (cpu_is_omap730()) {
> > if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> > - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
> > + printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> > + id + 1);
> > return -1;
> > }
> > return 0;
> > @@ -188,7 +188,8 @@ static int omap_mcbsp_check(unsigned int id)
> >
> > if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
> > if (id > OMAP_MAX_MCBSP_COUNT) {
> > - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
> > + printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> > + id + 1);
> > return -1;
> > }
> > return 0;
> > @@ -263,7 +264,8 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
> > spin_lock(&mcbsp[id].lock);
> >
> > if (!mcbsp[id].free) {
> > - printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
> > + printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
> > + id + 1);
> > spin_unlock(&mcbsp[id].lock);
> > return -EINVAL;
> > }
> > @@ -274,6 +276,7 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
> >
> > return 0;
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_set_io_type);
> >
> > int omap_mcbsp_request(unsigned int id)
> > {
> > @@ -305,7 +308,8 @@ int omap_mcbsp_request(unsigned int id)
> >
> > spin_lock(&mcbsp[id].lock);
> > if (!mcbsp[id].free) {
> > - printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
> > + printk(KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n",
> > + id + 1);
> > spin_unlock(&mcbsp[id].lock);
> > return -1;
> > }
> > @@ -315,24 +319,23 @@ int omap_mcbsp_request(unsigned int id)
> >
> > if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) {
> > /* We need to get IRQs here */
> > - err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, 0,
> > - "McBSP",
> > - (void *) (&mcbsp[id]));
> > + err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler,
> > + 0, "McBSP", (void *) (&mcbsp[id]));
> > if (err != 0) {
> > - printk(KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n",
> > - mcbsp[id].tx_irq, mcbsp[id].id);
> > + printk(KERN_ERR "OMAP-McBSP: Unable to "
> > + "request TX IRQ %d for McBSP%d\n",
> > + mcbsp[id].tx_irq, mcbsp[id].id);
> > return err;
> > }
> >
> > init_completion(&(mcbsp[id].tx_irq_completion));
> >
> > -
> > - err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, 0,
> > - "McBSP",
> > - (void *) (&mcbsp[id]));
> > + err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler,
> > + 0, "McBSP", (void *) (&mcbsp[id]));
> > if (err != 0) {
> > - printk(KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n",
> > - mcbsp[id].rx_irq, mcbsp[id].id);
> > + printk(KERN_ERR "OMAP-McBSP: Unable to "
> > + "request RX IRQ %d for McBSP%d\n",
> > + mcbsp[id].rx_irq, mcbsp[id].id);
> > free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
> > return err;
> > }
> > @@ -341,8 +344,8 @@ int omap_mcbsp_request(unsigned int id)
> > }
> >
> > return 0;
> > -
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_request);
> >
> > void omap_mcbsp_free(unsigned int id)
> > {
> > @@ -370,7 +373,8 @@ void omap_mcbsp_free(unsigned int id)
> >
> > spin_lock(&mcbsp[id].lock);
> > if (mcbsp[id].free) {
> > - printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n", id + 1);
> > + printk(KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n",
> > + id + 1);
> > spin_unlock(&mcbsp[id].lock);
> > return;
> > }
> > @@ -384,6 +388,7 @@ void omap_mcbsp_free(unsigned int id)
> > free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
> > }
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_free);
> >
> > /*
> > * Here we start the McBSP, by enabling the sample
> > @@ -400,8 +405,8 @@ void omap_mcbsp_start(unsigned int id)
> >
> > io_base = mcbsp[id].io_base;
> >
> > - 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);
> > + 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 */
> > w = OMAP_MCBSP_READ(io_base, SPCR2);
> > @@ -422,8 +427,8 @@ void omap_mcbsp_start(unsigned int id)
> >
> > /* Dump McBSP Regs */
> > omap_mcbsp_dump_reg(id);
> > -
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_start);
> >
> > void omap_mcbsp_stop(unsigned int id)
> > {
> > @@ -435,7 +440,7 @@ void omap_mcbsp_stop(unsigned int id)
> >
> > io_base = mcbsp[id].io_base;
> >
> > - /* Reset transmitter */
> > + /* Reset transmitter */
> > w = OMAP_MCBSP_READ(io_base, SPCR2);
> > OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1));
> >
> > @@ -447,7 +452,7 @@ void omap_mcbsp_stop(unsigned int id)
> > w = OMAP_MCBSP_READ(io_base, SPCR2);
> > OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1 << 6));
> > }
> > -
> > +EXPORT_SYMBOL(omap_mcbsp_stop);
> >
> > /* polled mcbsp i/o operations */
> > int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
> > @@ -480,10 +485,12 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
> > }
> > }
> > }
> > +
> > return 0;
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_pollwrite);
> >
> > -int omap_mcbsp_pollread(unsigned int id, u16 * buf)
> > +int omap_mcbsp_pollread(unsigned int id, u16 *buf)
> > {
> > u32 base = mcbsp[id].io_base;
> > /* if frame sync error - clear the error */
> > @@ -513,8 +520,10 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf)
> > }
> > }
> > *buf = readw(base + OMAP_MCBSP_REG_DRR1);
> > +
> > return 0;
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_pollread);
> >
> > /*
> > * IRQ based word transmission.
> > @@ -535,6 +544,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
> > OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
> > OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_xmit_word);
> >
> > u32 omap_mcbsp_recv_word(unsigned int id)
> > {
> > @@ -555,7 +565,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
> >
> > return (word_lsb | (word_msb << 16));
> > }
> > -
> > +EXPORT_SYMBOL(omap_mcbsp_recv_word);
> >
> > int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
> > {
> > @@ -577,7 +587,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
> > udelay(10);
> > OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
> > udelay(10);
> > - printk("McBSP transmitter not ready\n");
> > + printk(KERN_ERR "McBSP transmitter not ready\n");
> > return -EAGAIN;
> > }
> > }
> > @@ -597,7 +607,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
> > udelay(10);
> > OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
> > udelay(10);
> > - printk("McBSP receiver not ready\n");
> > + printk(KERN_ERR "McBSP receiver not ready\n");
> > return -EAGAIN;
> > }
> > }
> > @@ -609,8 +619,9 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
> >
> > return 0;
> > }
> > +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)
> > {
> > u32 io_base = mcbsp[id].io_base, clock_word = 0;
> > omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
> > @@ -630,7 +641,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
> > udelay(10);
> > OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
> > udelay(10);
> > - printk("McBSP transmitter not ready\n");
> > + printk(KERN_ERR "McBSP transmitter not ready\n");
> > return -EAGAIN;
> > }
> > }
> > @@ -650,7 +661,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
> > udelay(10);
> > OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
> > udelay(10);
> > - printk("McBSP receiver not ready\n");
> > + printk(KERN_ERR "McBSP receiver not ready\n");
> > return -EAGAIN;
> > }
> > }
> > @@ -664,7 +675,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
> >
> > return 0;
> > }
> > -
> > +EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
> >
> > /*
> > * Simple DMA based buffer rx/tx routines.
> > @@ -673,7 +684,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
> > * For anything fancier, you should use your own customized DMA
> > * routines and callbacks.
> > */
> > -int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
> > +int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> > + unsigned int length)
> > {
> > int dma_tx_ch;
> > int src_port = 0;
> > @@ -683,10 +695,12 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> > if (omap_mcbsp_check(id) < 0)
> > return -EINVAL;
> >
> > - if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX", omap_mcbsp_tx_dma_callback,
> > - &mcbsp[id],
> > - &dma_tx_ch)) {
> > - printk("OMAP-McBSP: Unable to request DMA channel for McBSP%d TX. Trying IRQ based TX\n", id+1);
> > + if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
> > + omap_mcbsp_tx_dma_callback,
> > + &mcbsp[id],
> > + &dma_tx_ch)) {
> > + printk(KERN_ERR "OMAP-McBSP: Unable to request DMA channel for"
> > + " McBSP%d TX. Trying IRQ based TX\n", id + 1);
> > return -EAGAIN;
> > }
> > mcbsp[id].dma_tx_lch = dma_tx_ch;
> > @@ -722,11 +736,13 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> >
> > omap_start_dma(mcbsp[id].dma_tx_lch);
> > wait_for_completion(&(mcbsp[id].tx_dma_completion));
> > +
> > return 0;
> > }
> > +EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
> >
> > -
> > -int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
> > +int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> > + unsigned int length)
> > {
> > int dma_rx_ch;
> > int src_port = 0;
> > @@ -736,10 +752,12 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> > if (omap_mcbsp_check(id) < 0)
> > return -EINVAL;
> >
> > - if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX", omap_mcbsp_rx_dma_callback,
> > - &mcbsp[id],
> > - &dma_rx_ch)) {
> > - printk("Unable to request DMA channel for McBSP%d RX. Trying IRQ based RX\n", id+1);
> > + if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
> > + omap_mcbsp_rx_dma_callback,
> > + &mcbsp[id],
> > + &dma_rx_ch)) {
> > + printk(KERN_ERR "Unable to request DMA channel for McBSP%d RX."
> > + " Trying IRQ based RX\n", id + 1);
> > return -EAGAIN;
> > }
> > mcbsp[id].dma_rx_lch = dma_rx_ch;
> > @@ -756,10 +774,10 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> > sync_dev = mcbsp[id].dma_rx_sync;
> >
> > omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
> > - OMAP_DMA_DATA_TYPE_S16,
> > - length >> 1, 1,
> > - OMAP_DMA_SYNC_ELEMENT,
> > - sync_dev, 0);
> > + OMAP_DMA_DATA_TYPE_S16,
> > + length >> 1, 1,
> > + OMAP_DMA_SYNC_ELEMENT,
> > + sync_dev, 0);
> >
> > omap_set_dma_src_params(mcbsp[id].dma_rx_lch,
> > src_port,
> > @@ -768,16 +786,17 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> > 0, 0);
> >
> > omap_set_dma_dest_params(mcbsp[id].dma_rx_lch,
> > - dest_port,
> > - OMAP_DMA_AMODE_POST_INC,
> > - buffer,
> > - 0, 0);
> > + dest_port,
> > + OMAP_DMA_AMODE_POST_INC,
> > + buffer,
> > + 0, 0);
> >
> > omap_start_dma(mcbsp[id].dma_rx_lch);
> > wait_for_completion(&(mcbsp[id].rx_dma_completion));
> > +
> > return 0;
> > }
> > -
> > +EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
> >
> > /*
> > * SPI wrapper.
> > @@ -785,7 +804,8 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
> > * this wrapper just need an omap_mcbsp_spi_cfg structure as an input.
> > * Once this is done, you can call omap_mcbsp_start().
> > */
> > -void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg)
> > +void omap_mcbsp_set_spi_mode(unsigned int id,
> > + const struct omap_mcbsp_spi_cfg *spi_cfg)
> > {
> > struct omap_mcbsp_reg_cfg mcbsp_cfg;
> >
> > @@ -798,7 +818,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
> > mcbsp_cfg.rcr1 |= (RWDLEN1(spi_cfg->word_length) | RFRLEN1(0));
> > mcbsp_cfg.xcr1 |= (XWDLEN1(spi_cfg->word_length) | XFRLEN1(0));
> >
> > - /* Clock stop mode */
> > + /* Clock stop mode */
> > if (spi_cfg->clk_stp_mode == OMAP_MCBSP_CLK_STP_MODE_NO_DELAY)
> > mcbsp_cfg.spcr1 |= (1 << 12);
> > else
> > @@ -827,13 +847,12 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
> >
> > if (spi_cfg->spi_mode == OMAP_MCBSP_SPI_MASTER) {
> > mcbsp_cfg.pcr0 |= CLKXM;
> > - mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div -1);
> > + mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div - 1);
> > mcbsp_cfg.pcr0 |= FSXM;
> > mcbsp_cfg.srgr2 &= ~FSGM;
> > mcbsp_cfg.xcr2 |= XDATDLY(1);
> > mcbsp_cfg.rcr2 |= RDATDLY(1);
> > - }
> > - else {
> > + } else {
> > mcbsp_cfg.pcr0 &= ~CLKXM;
> > mcbsp_cfg.srgr1 |= CLKGDV(1);
> > mcbsp_cfg.pcr0 &= ~FSXM;
> > @@ -846,7 +865,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *
> >
> > omap_mcbsp_config(id, &mcbsp_cfg);
> > }
> > -
> > +EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> >
> > /*
> > * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> > @@ -935,7 +954,7 @@ static int __init omap_mcbsp_init(void)
> > int mcbsp_count = 0, i;
> > static const struct omap_mcbsp_info *mcbsp_info;
> >
> > - printk("Initializing OMAP McBSP system\n");
> > + printk(KERN_INFO "Initializing OMAP McBSP system\n");
> >
> > #ifdef CONFIG_ARCH_OMAP1
> > mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> > @@ -957,22 +976,26 @@ static int __init omap_mcbsp_init(void)
> > #ifdef CONFIG_ARCH_OMAP2
> > mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> > if (IS_ERR(mcbsp1_ick)) {
> > - printk(KERN_ERR "mcbsp: could not acquire mcbsp1_ick handle.\n");
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp1_ick handle.\n");
> > return PTR_ERR(mcbsp1_ick);
> > }
> > mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> > if (IS_ERR(mcbsp1_fck)) {
> > - printk(KERN_ERR "mcbsp: could not acquire mcbsp1_fck handle.\n");
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp1_fck handle.\n");
> > return PTR_ERR(mcbsp1_fck);
> > }
> > mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> > if (IS_ERR(mcbsp2_ick)) {
> > - printk(KERN_ERR "mcbsp: could not acquire mcbsp2_ick handle.\n");
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp2_ick handle.\n");
> > return PTR_ERR(mcbsp2_ick);
> > }
> > mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> > if (IS_ERR(mcbsp2_fck)) {
> > - printk(KERN_ERR "mcbsp: could not acquire mcbsp2_fck handle.\n");
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp2_fck handle.\n");
> > return PTR_ERR(mcbsp2_fck);
> > }
> > #endif
> > @@ -1006,7 +1029,7 @@ static int __init omap_mcbsp_init(void)
> > if (i >= mcbsp_count) {
> > mcbsp[i].io_base = 0;
> > mcbsp[i].free = 0;
> > - continue;
> > + continue;
> > }
> > mcbsp[i].id = i + 1;
> > mcbsp[i].free = 1;
> > @@ -1014,7 +1037,8 @@ static int __init omap_mcbsp_init(void)
> > mcbsp[i].dma_rx_lch = -1;
> >
> > mcbsp[i].io_base = mcbsp_info[i].virt_base;
> > - mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO; /* Default I/O is IRQ based */
> > + /* Default I/O is IRQ based */
> > + mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
> > mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
> > mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
> > mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
> > @@ -1026,19 +1050,3 @@ static int __init omap_mcbsp_init(void)
> > }
> >
> > arch_initcall(omap_mcbsp_init);
> > -
> > -EXPORT_SYMBOL(omap_mcbsp_config);
> > -EXPORT_SYMBOL(omap_mcbsp_request);
> > -EXPORT_SYMBOL(omap_mcbsp_set_io_type);
> > -EXPORT_SYMBOL(omap_mcbsp_free);
> > -EXPORT_SYMBOL(omap_mcbsp_start);
> > -EXPORT_SYMBOL(omap_mcbsp_stop);
> > -EXPORT_SYMBOL(omap_mcbsp_pollread);
> > -EXPORT_SYMBOL(omap_mcbsp_pollwrite);
> > -EXPORT_SYMBOL(omap_mcbsp_xmit_word);
> > -EXPORT_SYMBOL(omap_mcbsp_recv_word);
> > -EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
> > -EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
> > -EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
> > -EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
> > -EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> > --
> > 1.5.5-rc3.GIT
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> --
> Best Regards,
>
> Felipe Balbi
> me@felipebalbi.com
> http://blog.felipebalbi.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-14 20:11 ` Eduardo Valentin
2008-04-14 20:23 ` Felipe Balbi
2008-04-15 14:49 ` Chandra shekhar
@ 2008-04-21 18:33 ` Tony Lindgren
2008-04-22 6:29 ` Eduardo Valentin
2 siblings, 1 reply; 22+ messages in thread
From: Tony Lindgren @ 2008-04-21 18:33 UTC (permalink / raw)
To: Eduardo Valentin; +Cc: linux-omap, Eduardo Valentin
Hi,
Some comments below.
* Eduardo Valentin <edubezval@gmail.com> [080414 13:13]:
> From: Eduardo Valentin <eduardo.valentin@indt.org.br>
>
> This patch gets ride of ifdefs on mcbsp.c code.
> It moves the mach specific code to mach-omap*.
>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> ---
> arch/arm/mach-omap1/Makefile | 2 +
> arch/arm/mach-omap1/mcbsp.c | 202 +++++++++++++++++++++
> arch/arm/mach-omap2/Makefile | 2 +
> arch/arm/mach-omap2/mcbsp.c | 145 ++++++++++++++++
> arch/arm/plat-omap/mcbsp.c | 346 +++++--------------------------------
> include/asm-arm/arch-omap/mcbsp.h | 19 ++
> 6 files changed, 417 insertions(+), 299 deletions(-)
> create mode 100644 arch/arm/mach-omap1/mcbsp.c
> create mode 100644 arch/arm/mach-omap2/mcbsp.c
>
> diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
> index 6ebf23b..09246a7 100644
> --- a/arch/arm/mach-omap1/Makefile
> +++ b/arch/arm/mach-omap1/Makefile
> @@ -5,6 +5,8 @@
> # Common support
> obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
> obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
>
> diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
> new file mode 100644
> index 0000000..299f036
> --- /dev/null
> +++ b/arch/arm/mach-omap1/mcbsp.c
> @@ -0,0 +1,202 @@
> +/*
> + * linux/arch/arm/mach-omap1/mcbsp.c
> + *
> + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Multichannel mode not supported.
> + */
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +
> +#include <asm/arch/dma.h>
> +#include <asm/arch/mux.h>
> +#include <asm/arch/cpu.h>
> +#include <asm/arch/mcbsp.h>
> +#include <asm/arch/dsp_common.h>
> +
> +static struct clk *mcbsp_dsp_ck;
> +static struct clk *mcbsp_api_ck;
> +static struct clk *mcbsp_dspxor_ck;
> +
> +static void omap_mcbsp_dsp_request(void)
> +{
> + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> + int ret;
> +
> + ret = omap_dsp_request_mem();
> + if (ret < 0) {
> + printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
> + return;
> + }
> +
> + clk_enable(mcbsp_dsp_ck);
> + clk_enable(mcbsp_api_ck);
> +
> + /* enable 12MHz clock to mcbsp 1 & 3 */
> + clk_enable(mcbsp_dspxor_ck);
> +
> + /*
> + * DSP external peripheral reset
> + * FIXME: This should be moved to dsp code
> + */
> + __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> + DSP_RSTCT2);
> + }
> +}
How about just do an early return and leave out test for
cpu_is_omap15xx/16xx():
if (cpu_is_omap730())
return;
> +static void omap_mcbsp_dsp_free(void)
> +{
> + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> + omap_dsp_release_mem();
> + clk_disable(mcbsp_dspxor_ck);
> + clk_disable(mcbsp_dsp_ck);
> + clk_disable(mcbsp_api_ck);
> + }
> +}
Here too.
> +static int omap1_mcbsp_check(unsigned int id)
> +{
> + if (cpu_is_omap730()) {
> + if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> + 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) {
> + 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)
> +{
> + /*
> + * On 1510, 1610 and 1710, McBSP1 and McBSP3
> + * are DSP public peripherals.
> + */
> + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> + omap_mcbsp_dsp_request();
> +}
> +
> +static void omap1_mcbsp_free(unsigned int id)
> +{
> + if (cpu_class_is_omap1()) {
> + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> + omap_mcbsp_dsp_free();
> + }
> +}
Since these are all in mach-omap1, cpu_class_is_omap1() is always true,
so it can be left out.
> +struct omap_mcbsp_board_cfg omap1_mcbsp_cfg = {
> + .check = omap1_mcbsp_check,
> + .request = omap1_mcbsp_request,
> + .free = omap1_mcbsp_free,
> + .mcbsp_infos =
> +#ifdef CONFIG_ARCH_OMAP730
> + {
> + [0] = {
> + .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_730_McBSP1RX,
> + .tx_irq = INT_730_McBSP1TX,
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_730_McBSP2RX,
> + .tx_irq = INT_730_McBSP2TX
> + },
> + },
> +#elif defined(CONFIG_ARCH_OMAP15XX)
This should not be #elif, it's possible to compile in support for
multiple boards.
> + {
> + [0] = {
> + .virt_base = OMAP1510_MCBSP1_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_McBSP1RX,
> + .tx_irq = INT_McBSP1TX
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> + .rx_irq = INT_1510_SPI_RX,
> + .tx_irq = INT_1510_SPI_TX
> + },
> + [2] = {
> + .virt_base = OMAP1510_MCBSP3_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_McBSP3RX,
> + .tx_irq = INT_McBSP3TX
> + },
> +#elif defined(CONFIG_ARCH_OMAP16XX)
This too. See how this is handled for example in mux.c.
> + {
> + [0] = {
> + .virt_base = OMAP1610_MCBSP1_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> + .rx_irq = INT_McBSP1RX,
> + .tx_irq = INT_McBSP1TX
> + },
> + [1] = {
> + .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> + .rx_irq = INT_1610_McBSP2_RX,
> + .tx_irq = INT_1610_McBSP2_TX
> + },
> + [2] = {
> + .virt_base = OMAP1610_MCBSP3_BASE,
> + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> + .rx_irq = INT_McBSP3RX,
> + .tx_irq = INT_McBSP3TX
> + },
> + },
> +#else
> +NULL /* For .mcbsp_infos */
> +#endif
> +};
> +
> +int __init omap1_mcbsp_init(void)
> +{
> + mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> + if (IS_ERR(mcbsp_dsp_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
> + return PTR_ERR(mcbsp_dsp_ck);
> + }
I believe this will return error on 730 and init will fail.
> + mcbsp_api_ck = clk_get(0, "api_ck");
> + if (IS_ERR(mcbsp_api_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
> + return PTR_ERR(mcbsp_api_ck);
> + }
> + mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> + if (IS_ERR(mcbsp_dspxor_ck)) {
> + printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
> + return PTR_ERR(mcbsp_dspxor_ck);
> + }
This one too I guess.
> + omap_mcbsp_register_board_cfg(&omap1_mcbsp_cfg);
> +
> + return omap_mcbsp_init();
> +}
> +arch_initcall(omap1_mcbsp_init);
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 5157ff2..771f8e7 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -6,6 +6,8 @@
> obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
> devices.o serial.o gpmc.o timer-gp.o
>
> +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> +
> # Functions loaded to SRAM
> obj-$(CONFIG_ARCH_OMAP2) += sram24xx.o
>
> diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
> new file mode 100644
> index 0000000..8c8b97f
> --- /dev/null
> +++ b/arch/arm/mach-omap2/mcbsp.c
> @@ -0,0 +1,145 @@
> +/*
> + * linux/arch/arm/mach-omap1/mcbsp.c
> + *
Should be mach-omap2 above.
> + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Multichannel mode not supported.
> + */
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +
> +#include <asm/arch/dma.h>
> +#include <asm/arch/mux.h>
> +#include <asm/arch/cpu.h>
> +#include <asm/arch/mcbsp.h>
> +
> +static struct clk *mcbsp1_ick;
> +static struct clk *mcbsp1_fck;
> +static struct clk *mcbsp2_ick;
> +static struct clk *mcbsp2_fck;
> +
> +static void omap2_mcbsp2_mux_setup(void)
> +{
> + if (cpu_is_omap2420()) {
> + omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> + omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> + omap_cfg_reg(W15_24XX_MCBSP2_DR);
> + omap_cfg_reg(V15_24XX_MCBSP2_DX);
> + omap_cfg_reg(V14_24XX_GPIO117);
> + }
> + /*
> + * Need to add MUX settings for OMAP 2430 SDP
> + */
> +}
> +
> +static int omap2_mcbsp_check(unsigned int id)
> +{
> + if (cpu_class_is_omap2()) {
> + if (id > OMAP_MAX_MCBSP_COUNT) {
> + printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> + id + 1);
> + return -ENODEV;
> + }
> + return 0;
> + }
> +
> + return -ENODEV;
> +}
The cpu_class_is_omap2() above is not needed, it's always true.
> +static void omap2_mcbsp_request(unsigned int id)
> +{
> + if (cpu_class_is_omap2()) {
> + if (id == OMAP_MCBSP1) {
> + clk_enable(mcbsp1_ick);
> + clk_enable(mcbsp1_fck);
> + } else {
> + clk_enable(mcbsp2_ick);
> + clk_enable(mcbsp2_fck);
> + }
> + }
> +}
Here too. And a line break is missing between this and next function.
> +static void omap2_mcbsp_free(unsigned int id)
> +{
> + if (cpu_class_is_omap2()) {
> + if (id == OMAP_MCBSP1) {
> + clk_disable(mcbsp1_ick);
> + clk_disable(mcbsp1_fck);
> + } else {
> + clk_disable(mcbsp2_ick);
> + clk_disable(mcbsp2_fck);
> + }
> + }
> +}
Unnecessary cpu_class_is_omap2() here too.
> +static const struct omap_mcbsp_board_cfg mcbsp_24xx_cfg = {
> + .check = omap2_mcbsp_check,
> + .request = omap2_mcbsp_request,
> + .free = omap2_mcbsp_free,
> + .mcbsp_infos = {
> + [0] = {
> +#if defined(CONFIG_ARCH_OMAP24XX)
> + .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> +#elif defined(CONFIG_ARCH_OMAP34XX)
> + .virt_base = IO_ADDRESS(OMAP34XX_MCBSP1_BASE),
> +#endif
This #elif will add artificial blocker to compile in both 24xx and 34xx.
> + .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> + .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> + .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> + .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> + },
> + [1] = {
> +#if defined(CONFIG_ARCH_OMAP24XX)
> + .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> +#elif defined(CONFIG_ARCH_OMAP34XX)
> + .virt_base = IO_ADDRESS(OMAP34XX_MCBSP2_BASE),
> +#endif
Here too.
> + .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> + .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> + .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> + .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> + },
> + },
> +};
> +
> +int __init omap2_mcbsp_init(void)
> +{
> + mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> + if (IS_ERR(mcbsp1_ick)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_ick handle.\n");
> + return PTR_ERR(mcbsp1_ick);
> + }
> + mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> + if (IS_ERR(mcbsp1_fck)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp1_fck handle.\n");
> + return PTR_ERR(mcbsp1_fck);
> + }
> + mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> + if (IS_ERR(mcbsp2_ick)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_ick handle.\n");
> + return PTR_ERR(mcbsp2_ick);
> + }
> + mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> + if (IS_ERR(mcbsp2_fck)) {
> + printk(KERN_ERR "mcbsp: could not acquire "
> + "mcbsp2_fck handle.\n");
> + return PTR_ERR(mcbsp2_fck);
> + }
> +
> + if (cpu_class_is_omap2()) {
> + omap_mcbsp_register_board_cfg(&mcbsp_24xx_cfg);
> + omap2_mcbsp2_mux_setup();
> + }
Unnecessary cpu_class_is_omap2() here too.
> + return omap_mcbsp_init();
> +}
> +arch_initcall(omap2_mcbsp_init);
> diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
> index 053de31..fdba002 100644
> --- a/arch/arm/plat-omap/mcbsp.c
> +++ b/arch/arm/plat-omap/mcbsp.c
> @@ -24,11 +24,8 @@
> #include <linux/io.h>
> #include <linux/irq.h>
>
> -#include <asm/arch/dma.h>
> -#include <asm/arch/mux.h>
> -#include <asm/arch/irqs.h>
> -#include <asm/arch/dsp_common.h>
> #include <asm/arch/mcbsp.h>
> +#include <asm/arch/dma.h>
>
> #ifdef CONFIG_MCBSP_DEBUG
> #define DBG(x...) printk(x)
> @@ -65,17 +62,10 @@ struct omap_mcbsp {
> };
>
> static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
> -#ifdef CONFIG_ARCH_OMAP1
> -static struct clk *mcbsp_dsp_ck;
> -static struct clk *mcbsp_api_ck;
> -static struct clk *mcbsp_dspxor_ck;
> -#endif
> -#ifdef CONFIG_ARCH_OMAP2
> -static struct clk *mcbsp1_ick;
> -static struct clk *mcbsp1_fck;
> -static struct clk *mcbsp2_ick;
> -static struct clk *mcbsp2_fck;
> -#endif
> +static const struct omap_mcbsp_board_cfg *mcbsp_config;
> +
> +#define omap_mcbsp_check_invalid_id(id) (mcbsp_config && mcbsp_config->check \
> + && (mcbsp_config->check(id) < 0))
>
> static void omap_mcbsp_dump_reg(u8 id)
> {
> @@ -175,90 +165,13 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
> }
> EXPORT_SYMBOL(omap_mcbsp_config);
>
> -static int omap_mcbsp_check(unsigned int id)
> -{
> - if (cpu_is_omap730()) {
> - if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
> - if (id > OMAP_MAX_MCBSP_COUNT) {
> - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> - id + 1);
> - return -1;
> - }
> - return 0;
> - }
> -
> - return -1;
> -}
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -static void omap_mcbsp_dsp_request(void)
> -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - int ret;
> -
> - ret = omap_dsp_request_mem();
> - if (ret < 0) {
> - printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
> - return;
> - }
> -
> - clk_enable(mcbsp_dsp_ck);
> - clk_enable(mcbsp_api_ck);
> -
> - /* enable 12MHz clock to mcbsp 1 & 3 */
> - clk_enable(mcbsp_dspxor_ck);
> -
> - /*
> - * DSP external peripheral reset
> - * FIXME: This should be moved to dsp code
> - */
> - __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> - DSP_RSTCT2);
> - }
> -}
> -
> -static void omap_mcbsp_dsp_free(void)
> -{
> - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> - omap_dsp_release_mem();
> - clk_disable(mcbsp_dspxor_ck);
> - clk_disable(mcbsp_dsp_ck);
> - clk_disable(mcbsp_api_ck);
> - }
> -}
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> -static void omap2_mcbsp2_mux_setup(void)
> -{
> - if (cpu_is_omap2420()) {
> - omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> - omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> - omap_cfg_reg(W15_24XX_MCBSP2_DR);
> - omap_cfg_reg(V15_24XX_MCBSP2_DX);
> - omap_cfg_reg(V14_24XX_GPIO117);
> - }
> - /*
> - * Need to add MUX settings for OMAP 2430 SDP
> - */
> -}
> -#endif
> -
> /*
> * We can choose between IRQ based or polled IO.
> * This needs to be called before omap_mcbsp_request().
> */
> int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
> {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> spin_lock(&mcbsp[id].lock);
> @@ -282,29 +195,11 @@ int omap_mcbsp_request(unsigned int id)
> {
> int err;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - /*
> - * On 1510, 1610 and 1710, McBSP1 and McBSP3
> - * are DSP public peripherals.
> - */
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_request();
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_enable(mcbsp1_ick);
> - clk_enable(mcbsp1_fck);
> - } else {
> - clk_enable(mcbsp2_ick);
> - clk_enable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->request)
> + mcbsp_config->request(id);
>
> spin_lock(&mcbsp[id].lock);
> if (!mcbsp[id].free) {
> @@ -349,27 +244,11 @@ EXPORT_SYMBOL(omap_mcbsp_request);
>
> void omap_mcbsp_free(unsigned int id)
> {
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> -#ifdef CONFIG_ARCH_OMAP1
> - if (cpu_class_is_omap1()) {
> - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> - omap_mcbsp_dsp_free();
> - }
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP2
> - if (cpu_is_omap24xx()) {
> - if (id == OMAP_MCBSP1) {
> - clk_disable(mcbsp1_ick);
> - clk_disable(mcbsp1_fck);
> - } else {
> - clk_disable(mcbsp2_ick);
> - clk_disable(mcbsp2_fck);
> - }
> - }
> -#endif
> + if (mcbsp_config && mcbsp_config->free)
> + mcbsp_config->free(id);
>
> spin_lock(&mcbsp[id].lock);
> if (mcbsp[id].free) {
> @@ -400,7 +279,7 @@ void omap_mcbsp_start(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -435,7 +314,7 @@ void omap_mcbsp_stop(unsigned int id)
> u32 io_base;
> u16 w;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -533,7 +412,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
> u32 io_base;
> omap_mcbsp_word_length word_length = mcbsp[id].tx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> io_base = mcbsp[id].io_base;
> @@ -552,7 +431,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
> u16 word_lsb, word_msb = 0;
> omap_mcbsp_word_length word_length = mcbsp[id].rx_word_length;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> io_base = mcbsp[id].io_base;
> @@ -692,7 +571,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
> @@ -713,7 +592,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_tx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
> @@ -749,7 +628,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> int dest_port = 0;
> int sync_dev = 0;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return -EINVAL;
>
> if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
> @@ -770,7 +649,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> src_port = OMAP_DMA_PORT_TIPB;
> dest_port = OMAP_DMA_PORT_EMIFF;
> }
> - if (cpu_is_omap24xx())
> + if (cpu_class_is_omap2())
> sync_dev = mcbsp[id].dma_rx_sync;
>
> omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
> @@ -809,7 +688,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id,
> {
> struct omap_mcbsp_reg_cfg mcbsp_cfg;
>
> - if (omap_mcbsp_check(id) < 0)
> + if (omap_mcbsp_check_invalid_id(id))
> return;
>
> memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
> @@ -871,162 +750,19 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> * 730 has only 2 McBSP, and both of them are MPU peripherals.
> */
> -struct omap_mcbsp_info {
> - u32 virt_base;
> - u8 dma_rx_sync, dma_tx_sync;
> - u16 rx_irq, tx_irq;
> -};
> -
> -#ifdef CONFIG_ARCH_OMAP730
> -static const struct omap_mcbsp_info mcbsp_730[] = {
> - [0] = { .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_730_McBSP1RX,
> - .tx_irq = INT_730_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_730_McBSP2RX,
> - .tx_irq = INT_730_McBSP2TX },
> -};
> -#endif
> -
> -#ifdef CONFIG_ARCH_OMAP15XX
> -static const struct omap_mcbsp_info mcbsp_1510[] = {
> - [0] = { .virt_base = OMAP1510_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1510_SPI_RX,
> - .tx_irq = INT_1510_SPI_TX },
> - [2] = { .virt_base = OMAP1510_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP16XX)
> -static const struct omap_mcbsp_info mcbsp_1610[] = {
> - [0] = { .virt_base = OMAP1610_MCBSP1_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> - .rx_irq = INT_McBSP1RX,
> - .tx_irq = INT_McBSP1TX },
> - [1] = { .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> - .rx_irq = INT_1610_McBSP2_RX,
> - .tx_irq = INT_1610_McBSP2_TX },
> - [2] = { .virt_base = OMAP1610_MCBSP3_BASE,
> - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> - .rx_irq = INT_McBSP3RX,
> - .tx_irq = INT_McBSP3TX },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP24XX)
> -static const struct omap_mcbsp_info mcbsp_24xx[] = {
> - [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> - .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> - },
> - [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> - .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> - .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> - .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> - .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> - },
> -};
> -#endif
> -
> -static int __init omap_mcbsp_init(void)
> +int __init omap_mcbsp_init(void)
> {
> - int mcbsp_count = 0, i;
> - static const struct omap_mcbsp_info *mcbsp_info;
> + int i;
>
> - printk(KERN_INFO "Initializing OMAP McBSP system\n");
> -
> -#ifdef CONFIG_ARCH_OMAP1
> - mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> - if (IS_ERR(mcbsp_dsp_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
> - return PTR_ERR(mcbsp_dsp_ck);
> - }
> - mcbsp_api_ck = clk_get(0, "api_ck");
> - if (IS_ERR(mcbsp_api_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
> - return PTR_ERR(mcbsp_api_ck);
> - }
> - mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> - if (IS_ERR(mcbsp_dspxor_ck)) {
> - printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
> - return PTR_ERR(mcbsp_dspxor_ck);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP2
> - mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> - if (IS_ERR(mcbsp1_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_ick handle.\n");
> - return PTR_ERR(mcbsp1_ick);
> - }
> - mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> - if (IS_ERR(mcbsp1_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp1_fck handle.\n");
> - return PTR_ERR(mcbsp1_fck);
> - }
> - mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> - if (IS_ERR(mcbsp2_ick)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_ick handle.\n");
> - return PTR_ERR(mcbsp2_ick);
> - }
> - mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> - if (IS_ERR(mcbsp2_fck)) {
> - printk(KERN_ERR "mcbsp: could not acquire "
> - "mcbsp2_fck handle.\n");
> - return PTR_ERR(mcbsp2_fck);
> + if (!mcbsp_config) {
> + printk(KERN_ERR "McBSP initialized without configuration\n");
> + return -EINVAL;
> }
> -#endif
>
> -#ifdef CONFIG_ARCH_OMAP730
> - if (cpu_is_omap730()) {
> - mcbsp_info = mcbsp_730;
> - mcbsp_count = ARRAY_SIZE(mcbsp_730);
> - }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP15XX
> - if (cpu_is_omap15xx()) {
> - mcbsp_info = mcbsp_1510;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1510);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP16XX)
> - if (cpu_is_omap16xx()) {
> - mcbsp_info = mcbsp_1610;
> - mcbsp_count = ARRAY_SIZE(mcbsp_1610);
> - }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP24XX)
> - if (cpu_is_omap24xx()) {
> - mcbsp_info = mcbsp_24xx;
> - mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
> - omap2_mcbsp2_mux_setup();
> - }
> -#endif
> + printk(KERN_INFO "Initializing OMAP McBSP system\n");
> +
> for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
> - if (i >= mcbsp_count) {
> + if (i >= ARRAY_SIZE(mcbsp_config->mcbsp_infos)) {
> mcbsp[i].io_base = 0;
> mcbsp[i].free = 0;
> continue;
> @@ -1036,17 +772,29 @@ static int __init omap_mcbsp_init(void)
> mcbsp[i].dma_tx_lch = -1;
> mcbsp[i].dma_rx_lch = -1;
>
> - mcbsp[i].io_base = mcbsp_info[i].virt_base;
> + mcbsp[i].io_base = mcbsp_config->mcbsp_infos[i].virt_base;
> /* Default I/O is IRQ based */
> mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
> - mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
> - mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
> - mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
> - mcbsp[i].dma_tx_sync = mcbsp_info[i].dma_tx_sync;
> + mcbsp[i].tx_irq = mcbsp_config->mcbsp_infos[i].tx_irq;
> + mcbsp[i].rx_irq = mcbsp_config->mcbsp_infos[i].rx_irq;
> + mcbsp[i].dma_rx_sync = mcbsp_config->mcbsp_infos[i].dma_rx_sync;
> + mcbsp[i].dma_tx_sync = mcbsp_config->mcbsp_infos[i].dma_tx_sync;
> spin_lock_init(&mcbsp[i].lock);
> }
>
> return 0;
> }
>
> -arch_initcall(omap_mcbsp_init);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config)
> +{
> + if (!config || !config->request || !config->free) {
> + printk(KERN_ERR "Invalid McBSP configuration\n");
> + return -EINVAL;
> + }
> +
> + mcbsp_config = config;
> +
> + return 0;
> +
> +}
> +
> diff --git a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
> index b53c3b2..fc53a45 100644
> --- a/include/asm-arm/arch-omap/mcbsp.h
> +++ b/include/asm-arm/arch-omap/mcbsp.h
> @@ -40,6 +40,9 @@
> #define OMAP24XX_MCBSP1_BASE 0x48074000
> #define OMAP24XX_MCBSP2_BASE 0x48076000
>
> +#define OMAP34XX_MCBSP1_BASE 0x48074000
> +#define OMAP34XX_MCBSP2_BASE 0x49022000
> +
> #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
>
> #define OMAP_MCBSP_REG_DRR2 0x00
> @@ -298,6 +301,22 @@ struct omap_mcbsp_spi_cfg {
> omap_mcbsp_word_length word_length;
> };
>
> +/* Board specific configuration */
> +struct omap_mcbsp_info {
> + u32 virt_base;
> + u8 dma_rx_sync, dma_tx_sync;
> + u16 rx_irq, tx_irq;
> +};
> +
> +struct omap_mcbsp_board_cfg {
> + void (*request)(unsigned int);
> + void (*free)(unsigned int);
> + int (*check)(unsigned int);
> + struct omap_mcbsp_info mcbsp_infos[OMAP_MAX_MCBSP_COUNT];
> +};
> +
> +int omap_mcbsp_init(void);
> +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config);
> void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
> int omap_mcbsp_request(unsigned int id);
> void omap_mcbsp_free(unsigned int id);
> --
> 1.5.5-rc3.GIT
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-21 18:33 ` Tony Lindgren
@ 2008-04-22 6:29 ` Eduardo Valentin
2008-04-22 9:24 ` Syed Mohammed, Khasim
0 siblings, 1 reply; 22+ messages in thread
From: Eduardo Valentin @ 2008-04-22 6:29 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux-omap, Eduardo Valentin
Hi Tony,
I'll apply your comments and re-write mcbsp driver as a platform driver.
On top of that, each mcbsp will have a platformdata. This way we can get
struct device for each of configured mcbsp. And then use correctly the
clock framework. Of cource, modifications on mcbsp clock definitions is also
required.
I'll also try to keep the mcbsp API to another drivers which may need it,
so other part of the code will not be broken. A separeted series to
change the API
may be need. But for now let's update the mcbsp driver.
I'll repost this patch as another series soon.
Cheers,
On Mon, Apr 21, 2008 at 9:33 PM, Tony Lindgren <tony@atomide.com> wrote:
> Hi,
>
> Some comments below.
>
> * Eduardo Valentin <edubezval@gmail.com> [080414 13:13]:
>
>
> > From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >
> > This patch gets ride of ifdefs on mcbsp.c code.
> > It moves the mach specific code to mach-omap*.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> > ---
> > arch/arm/mach-omap1/Makefile | 2 +
> > arch/arm/mach-omap1/mcbsp.c | 202 +++++++++++++++++++++
> > arch/arm/mach-omap2/Makefile | 2 +
> > arch/arm/mach-omap2/mcbsp.c | 145 ++++++++++++++++
> > arch/arm/plat-omap/mcbsp.c | 346 +++++--------------------------------
> > include/asm-arm/arch-omap/mcbsp.h | 19 ++
> > 6 files changed, 417 insertions(+), 299 deletions(-)
> > create mode 100644 arch/arm/mach-omap1/mcbsp.c
> > create mode 100644 arch/arm/mach-omap2/mcbsp.c
> >
> > diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
> > index 6ebf23b..09246a7 100644
> > --- a/arch/arm/mach-omap1/Makefile
> > +++ b/arch/arm/mach-omap1/Makefile
> > @@ -5,6 +5,8 @@
> > # Common support
> > obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
> >
> > +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> > +
> > obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
> > obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
> >
> > diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
> > new file mode 100644
> > index 0000000..299f036
> > --- /dev/null
> > +++ b/arch/arm/mach-omap1/mcbsp.c
> > @@ -0,0 +1,202 @@
> > +/*
> > + * linux/arch/arm/mach-omap1/mcbsp.c
> > + *
> > + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> > + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + * Multichannel mode not supported.
> > + */
> > +#include <linux/module.h>
> > +#include <linux/init.h>
> > +#include <linux/clk.h>
> > +#include <linux/err.h>
> > +#include <linux/io.h>
> > +
> > +#include <asm/arch/dma.h>
> > +#include <asm/arch/mux.h>
> > +#include <asm/arch/cpu.h>
> > +#include <asm/arch/mcbsp.h>
> > +#include <asm/arch/dsp_common.h>
> > +
> > +static struct clk *mcbsp_dsp_ck;
> > +static struct clk *mcbsp_api_ck;
> > +static struct clk *mcbsp_dspxor_ck;
> > +
> > +static void omap_mcbsp_dsp_request(void)
> > +{
> > + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> > + int ret;
> > +
> > + ret = omap_dsp_request_mem();
> > + if (ret < 0) {
> > + printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
> > + return;
> > + }
> > +
> > + clk_enable(mcbsp_dsp_ck);
> > + clk_enable(mcbsp_api_ck);
> > +
> > + /* enable 12MHz clock to mcbsp 1 & 3 */
> > + clk_enable(mcbsp_dspxor_ck);
> > +
> > + /*
> > + * DSP external peripheral reset
> > + * FIXME: This should be moved to dsp code
> > + */
> > + __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> > + DSP_RSTCT2);
> > + }
> > +}
>
> How about just do an early return and leave out test for
> cpu_is_omap15xx/16xx():
>
> if (cpu_is_omap730())
> return;
>
>
>
> > +static void omap_mcbsp_dsp_free(void)
> > +{
> > + if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> > + omap_dsp_release_mem();
> > + clk_disable(mcbsp_dspxor_ck);
> > + clk_disable(mcbsp_dsp_ck);
> > + clk_disable(mcbsp_api_ck);
> > + }
> > +}
>
> Here too.
>
>
>
> > +static int omap1_mcbsp_check(unsigned int id)
> > +{
> > + if (cpu_is_omap730()) {
> > + if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> > + 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) {
> > + 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)
> > +{
> > + /*
> > + * On 1510, 1610 and 1710, McBSP1 and McBSP3
> > + * are DSP public peripherals.
> > + */
> > + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> > + omap_mcbsp_dsp_request();
> > +}
> > +
> > +static void omap1_mcbsp_free(unsigned int id)
> > +{
> > + if (cpu_class_is_omap1()) {
> > + if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> > + omap_mcbsp_dsp_free();
> > + }
> > +}
>
> Since these are all in mach-omap1, cpu_class_is_omap1() is always true,
> so it can be left out.
>
>
> > +struct omap_mcbsp_board_cfg omap1_mcbsp_cfg = {
> > + .check = omap1_mcbsp_check,
> > + .request = omap1_mcbsp_request,
> > + .free = omap1_mcbsp_free,
> > + .mcbsp_infos =
> > +#ifdef CONFIG_ARCH_OMAP730
> > + {
> > + [0] = {
> > + .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> > + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> > + .rx_irq = INT_730_McBSP1RX,
> > + .tx_irq = INT_730_McBSP1TX,
> > + },
> > + [1] = {
> > + .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> > + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> > + .rx_irq = INT_730_McBSP2RX,
> > + .tx_irq = INT_730_McBSP2TX
> > + },
> > + },
> > +#elif defined(CONFIG_ARCH_OMAP15XX)
>
> This should not be #elif, it's possible to compile in support for
> multiple boards.
>
>
>
> > + {
> > + [0] = {
> > + .virt_base = OMAP1510_MCBSP1_BASE,
> > + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> > + .rx_irq = INT_McBSP1RX,
> > + .tx_irq = INT_McBSP1TX
> > + },
> > + [1] = {
> > + .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> > + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> > + .rx_irq = INT_1510_SPI_RX,
> > + .tx_irq = INT_1510_SPI_TX
> > + },
> > + [2] = {
> > + .virt_base = OMAP1510_MCBSP3_BASE,
> > + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> > + .rx_irq = INT_McBSP3RX,
> > + .tx_irq = INT_McBSP3TX
> > + },
> > +#elif defined(CONFIG_ARCH_OMAP16XX)
>
> This too. See how this is handled for example in mux.c.
>
>
>
>
> > + {
> > + [0] = {
> > + .virt_base = OMAP1610_MCBSP1_BASE,
> > + .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> > + .rx_irq = INT_McBSP1RX,
> > + .tx_irq = INT_McBSP1TX
> > + },
> > + [1] = {
> > + .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> > + .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> > + .rx_irq = INT_1610_McBSP2_RX,
> > + .tx_irq = INT_1610_McBSP2_TX
> > + },
> > + [2] = {
> > + .virt_base = OMAP1610_MCBSP3_BASE,
> > + .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> > + .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> > + .rx_irq = INT_McBSP3RX,
> > + .tx_irq = INT_McBSP3TX
> > + },
> > + },
> > +#else
> > +NULL /* For .mcbsp_infos */
> > +#endif
> > +};
> > +
> > +int __init omap1_mcbsp_init(void)
> > +{
> > + mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> > + if (IS_ERR(mcbsp_dsp_ck)) {
> > + printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
> > + return PTR_ERR(mcbsp_dsp_ck);
> > + }
>
> I believe this will return error on 730 and init will fail.
>
>
>
> > + mcbsp_api_ck = clk_get(0, "api_ck");
> > + if (IS_ERR(mcbsp_api_ck)) {
> > + printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
> > + return PTR_ERR(mcbsp_api_ck);
> > + }
> > + mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> > + if (IS_ERR(mcbsp_dspxor_ck)) {
> > + printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
> > + return PTR_ERR(mcbsp_dspxor_ck);
> > + }
>
> This one too I guess.
>
>
>
> > + omap_mcbsp_register_board_cfg(&omap1_mcbsp_cfg);
> > +
> > + return omap_mcbsp_init();
> > +}
> > +arch_initcall(omap1_mcbsp_init);
> > diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> > index 5157ff2..771f8e7 100644
> > --- a/arch/arm/mach-omap2/Makefile
> > +++ b/arch/arm/mach-omap2/Makefile
> > @@ -6,6 +6,8 @@
> > obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
> > devices.o serial.o gpmc.o timer-gp.o
> >
> > +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
> > +
> > # Functions loaded to SRAM
> > obj-$(CONFIG_ARCH_OMAP2) += sram24xx.o
> >
> > diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
> > new file mode 100644
> > index 0000000..8c8b97f
> > --- /dev/null
> > +++ b/arch/arm/mach-omap2/mcbsp.c
> > @@ -0,0 +1,145 @@
> > +/*
> > + * linux/arch/arm/mach-omap1/mcbsp.c
> > + *
>
> Should be mach-omap2 above.
>
>
>
>
> > + * Copyright (C) 2008 Instituto Nokia de Tecnologia
> > + * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + * Multichannel mode not supported.
> > + */
> > +#include <linux/module.h>
> > +#include <linux/init.h>
> > +#include <linux/clk.h>
> > +#include <linux/err.h>
> > +
> > +#include <asm/arch/dma.h>
> > +#include <asm/arch/mux.h>
> > +#include <asm/arch/cpu.h>
> > +#include <asm/arch/mcbsp.h>
> > +
> > +static struct clk *mcbsp1_ick;
> > +static struct clk *mcbsp1_fck;
> > +static struct clk *mcbsp2_ick;
> > +static struct clk *mcbsp2_fck;
> > +
> > +static void omap2_mcbsp2_mux_setup(void)
> > +{
> > + if (cpu_is_omap2420()) {
> > + omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> > + omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> > + omap_cfg_reg(W15_24XX_MCBSP2_DR);
> > + omap_cfg_reg(V15_24XX_MCBSP2_DX);
> > + omap_cfg_reg(V14_24XX_GPIO117);
> > + }
> > + /*
> > + * Need to add MUX settings for OMAP 2430 SDP
> > + */
> > +}
> > +
> > +static int omap2_mcbsp_check(unsigned int id)
> > +{
> > + if (cpu_class_is_omap2()) {
> > + if (id > OMAP_MAX_MCBSP_COUNT) {
> > + printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> > + id + 1);
> > + return -ENODEV;
> > + }
> > + return 0;
> > + }
> > +
> > + return -ENODEV;
> > +}
>
> The cpu_class_is_omap2() above is not needed, it's always true.
>
>
>
> > +static void omap2_mcbsp_request(unsigned int id)
> > +{
> > + if (cpu_class_is_omap2()) {
> > + if (id == OMAP_MCBSP1) {
> > + clk_enable(mcbsp1_ick);
> > + clk_enable(mcbsp1_fck);
> > + } else {
> > + clk_enable(mcbsp2_ick);
> > + clk_enable(mcbsp2_fck);
> > + }
> > + }
> > +}
>
> Here too. And a line break is missing between this and next function.
>
>
>
> > +static void omap2_mcbsp_free(unsigned int id)
> > +{
> > + if (cpu_class_is_omap2()) {
> > + if (id == OMAP_MCBSP1) {
> > + clk_disable(mcbsp1_ick);
> > + clk_disable(mcbsp1_fck);
> > + } else {
> > + clk_disable(mcbsp2_ick);
> > + clk_disable(mcbsp2_fck);
> > + }
> > + }
> > +}
>
> Unnecessary cpu_class_is_omap2() here too.
>
>
>
> > +static const struct omap_mcbsp_board_cfg mcbsp_24xx_cfg = {
> > + .check = omap2_mcbsp_check,
> > + .request = omap2_mcbsp_request,
> > + .free = omap2_mcbsp_free,
> > + .mcbsp_infos = {
> > + [0] = {
> > +#if defined(CONFIG_ARCH_OMAP24XX)
> > + .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> > +#elif defined(CONFIG_ARCH_OMAP34XX)
> > + .virt_base = IO_ADDRESS(OMAP34XX_MCBSP1_BASE),
> > +#endif
>
> This #elif will add artificial blocker to compile in both 24xx and 34xx.
>
>
>
> > + .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> > + .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> > + .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> > + .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> > + },
> > + [1] = {
> > +#if defined(CONFIG_ARCH_OMAP24XX)
> > + .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> > +#elif defined(CONFIG_ARCH_OMAP34XX)
> > + .virt_base = IO_ADDRESS(OMAP34XX_MCBSP2_BASE),
> > +#endif
>
> Here too.
>
>
>
>
> > + .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> > + .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> > + .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> > + .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> > + },
> > + },
> > +};
> > +
> > +int __init omap2_mcbsp_init(void)
> > +{
> > + mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> > + if (IS_ERR(mcbsp1_ick)) {
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp1_ick handle.\n");
> > + return PTR_ERR(mcbsp1_ick);
> > + }
> > + mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> > + if (IS_ERR(mcbsp1_fck)) {
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp1_fck handle.\n");
> > + return PTR_ERR(mcbsp1_fck);
> > + }
> > + mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> > + if (IS_ERR(mcbsp2_ick)) {
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp2_ick handle.\n");
> > + return PTR_ERR(mcbsp2_ick);
> > + }
> > + mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> > + if (IS_ERR(mcbsp2_fck)) {
> > + printk(KERN_ERR "mcbsp: could not acquire "
> > + "mcbsp2_fck handle.\n");
> > + return PTR_ERR(mcbsp2_fck);
> > + }
> > +
> > + if (cpu_class_is_omap2()) {
> > + omap_mcbsp_register_board_cfg(&mcbsp_24xx_cfg);
> > + omap2_mcbsp2_mux_setup();
> > + }
>
> Unnecessary cpu_class_is_omap2() here too.
>
>
>
>
> > + return omap_mcbsp_init();
> > +}
> > +arch_initcall(omap2_mcbsp_init);
> > diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
> > index 053de31..fdba002 100644
> > --- a/arch/arm/plat-omap/mcbsp.c
> > +++ b/arch/arm/plat-omap/mcbsp.c
> > @@ -24,11 +24,8 @@
> > #include <linux/io.h>
> > #include <linux/irq.h>
> >
> > -#include <asm/arch/dma.h>
> > -#include <asm/arch/mux.h>
> > -#include <asm/arch/irqs.h>
> > -#include <asm/arch/dsp_common.h>
> > #include <asm/arch/mcbsp.h>
> > +#include <asm/arch/dma.h>
> >
> > #ifdef CONFIG_MCBSP_DEBUG
> > #define DBG(x...) printk(x)
> > @@ -65,17 +62,10 @@ struct omap_mcbsp {
> > };
> >
> > static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
> > -#ifdef CONFIG_ARCH_OMAP1
> > -static struct clk *mcbsp_dsp_ck;
> > -static struct clk *mcbsp_api_ck;
> > -static struct clk *mcbsp_dspxor_ck;
> > -#endif
> > -#ifdef CONFIG_ARCH_OMAP2
> > -static struct clk *mcbsp1_ick;
> > -static struct clk *mcbsp1_fck;
> > -static struct clk *mcbsp2_ick;
> > -static struct clk *mcbsp2_fck;
> > -#endif
> > +static const struct omap_mcbsp_board_cfg *mcbsp_config;
> > +
> > +#define omap_mcbsp_check_invalid_id(id) (mcbsp_config && mcbsp_config->check \
> > + && (mcbsp_config->check(id) < 0))
> >
> > static void omap_mcbsp_dump_reg(u8 id)
> > {
> > @@ -175,90 +165,13 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
> > }
> > EXPORT_SYMBOL(omap_mcbsp_config);
> >
> > -static int omap_mcbsp_check(unsigned int id)
> > -{
> > - if (cpu_is_omap730()) {
> > - if (id > OMAP_MAX_MCBSP_COUNT - 1) {
> > - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> > - id + 1);
> > - return -1;
> > - }
> > - return 0;
> > - }
> > -
> > - if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
> > - if (id > OMAP_MAX_MCBSP_COUNT) {
> > - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n",
> > - id + 1);
> > - return -1;
> > - }
> > - return 0;
> > - }
> > -
> > - return -1;
> > -}
> > -
> > -#ifdef CONFIG_ARCH_OMAP1
> > -static void omap_mcbsp_dsp_request(void)
> > -{
> > - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> > - int ret;
> > -
> > - ret = omap_dsp_request_mem();
> > - if (ret < 0) {
> > - printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
> > - return;
> > - }
> > -
> > - clk_enable(mcbsp_dsp_ck);
> > - clk_enable(mcbsp_api_ck);
> > -
> > - /* enable 12MHz clock to mcbsp 1 & 3 */
> > - clk_enable(mcbsp_dspxor_ck);
> > -
> > - /*
> > - * DSP external peripheral reset
> > - * FIXME: This should be moved to dsp code
> > - */
> > - __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1 << 1,
> > - DSP_RSTCT2);
> > - }
> > -}
> > -
> > -static void omap_mcbsp_dsp_free(void)
> > -{
> > - if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
> > - omap_dsp_release_mem();
> > - clk_disable(mcbsp_dspxor_ck);
> > - clk_disable(mcbsp_dsp_ck);
> > - clk_disable(mcbsp_api_ck);
> > - }
> > -}
> > -#endif
> > -
> > -#ifdef CONFIG_ARCH_OMAP2
> > -static void omap2_mcbsp2_mux_setup(void)
> > -{
> > - if (cpu_is_omap2420()) {
> > - omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
> > - omap_cfg_reg(R14_24XX_MCBSP2_FSX);
> > - omap_cfg_reg(W15_24XX_MCBSP2_DR);
> > - omap_cfg_reg(V15_24XX_MCBSP2_DX);
> > - omap_cfg_reg(V14_24XX_GPIO117);
> > - }
> > - /*
> > - * Need to add MUX settings for OMAP 2430 SDP
> > - */
> > -}
> > -#endif
> > -
> > /*
> > * We can choose between IRQ based or polled IO.
> > * This needs to be called before omap_mcbsp_request().
> > */
> > int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
> > {
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return -EINVAL;
> >
> > spin_lock(&mcbsp[id].lock);
> > @@ -282,29 +195,11 @@ int omap_mcbsp_request(unsigned int id)
> > {
> > int err;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return -EINVAL;
> >
> > -#ifdef CONFIG_ARCH_OMAP1
> > - /*
> > - * On 1510, 1610 and 1710, McBSP1 and McBSP3
> > - * are DSP public peripherals.
> > - */
> > - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> > - omap_mcbsp_dsp_request();
> > -#endif
> > -
> > -#ifdef CONFIG_ARCH_OMAP2
> > - if (cpu_is_omap24xx()) {
> > - if (id == OMAP_MCBSP1) {
> > - clk_enable(mcbsp1_ick);
> > - clk_enable(mcbsp1_fck);
> > - } else {
> > - clk_enable(mcbsp2_ick);
> > - clk_enable(mcbsp2_fck);
> > - }
> > - }
> > -#endif
> > + if (mcbsp_config && mcbsp_config->request)
> > + mcbsp_config->request(id);
> >
> > spin_lock(&mcbsp[id].lock);
> > if (!mcbsp[id].free) {
> > @@ -349,27 +244,11 @@ EXPORT_SYMBOL(omap_mcbsp_request);
> >
> > void omap_mcbsp_free(unsigned int id)
> > {
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return;
> >
> > -#ifdef CONFIG_ARCH_OMAP1
> > - if (cpu_class_is_omap1()) {
> > - if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
> > - omap_mcbsp_dsp_free();
> > - }
> > -#endif
> > -
> > -#ifdef CONFIG_ARCH_OMAP2
> > - if (cpu_is_omap24xx()) {
> > - if (id == OMAP_MCBSP1) {
> > - clk_disable(mcbsp1_ick);
> > - clk_disable(mcbsp1_fck);
> > - } else {
> > - clk_disable(mcbsp2_ick);
> > - clk_disable(mcbsp2_fck);
> > - }
> > - }
> > -#endif
> > + if (mcbsp_config && mcbsp_config->free)
> > + mcbsp_config->free(id);
> >
> > spin_lock(&mcbsp[id].lock);
> > if (mcbsp[id].free) {
> > @@ -400,7 +279,7 @@ void omap_mcbsp_start(unsigned int id)
> > u32 io_base;
> > u16 w;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return;
> >
> > io_base = mcbsp[id].io_base;
> > @@ -435,7 +314,7 @@ void omap_mcbsp_stop(unsigned int id)
> > u32 io_base;
> > u16 w;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return;
> >
> > io_base = mcbsp[id].io_base;
> > @@ -533,7 +412,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
> > u32 io_base;
> > omap_mcbsp_word_length word_length = mcbsp[id].tx_word_length;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return;
> >
> > io_base = mcbsp[id].io_base;
> > @@ -552,7 +431,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)
> > u16 word_lsb, word_msb = 0;
> > omap_mcbsp_word_length word_length = mcbsp[id].rx_word_length;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return -EINVAL;
> >
> > io_base = mcbsp[id].io_base;
> > @@ -692,7 +571,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> > int dest_port = 0;
> > int sync_dev = 0;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return -EINVAL;
> >
> > if (omap_request_dma(mcbsp[id].dma_tx_sync, "McBSP TX",
> > @@ -713,7 +592,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
> > src_port = OMAP_DMA_PORT_TIPB;
> > dest_port = OMAP_DMA_PORT_EMIFF;
> > }
> > - if (cpu_is_omap24xx())
> > + if (cpu_class_is_omap2())
> > sync_dev = mcbsp[id].dma_tx_sync;
> >
> > omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
> > @@ -749,7 +628,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> > int dest_port = 0;
> > int sync_dev = 0;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return -EINVAL;
> >
> > if (omap_request_dma(mcbsp[id].dma_rx_sync, "McBSP RX",
> > @@ -770,7 +649,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
> > src_port = OMAP_DMA_PORT_TIPB;
> > dest_port = OMAP_DMA_PORT_EMIFF;
> > }
> > - if (cpu_is_omap24xx())
> > + if (cpu_class_is_omap2())
> > sync_dev = mcbsp[id].dma_rx_sync;
> >
> > omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
> > @@ -809,7 +688,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id,
> > {
> > struct omap_mcbsp_reg_cfg mcbsp_cfg;
> >
> > - if (omap_mcbsp_check(id) < 0)
> > + if (omap_mcbsp_check_invalid_id(id))
> > return;
> >
> > memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
> > @@ -871,162 +750,19 @@ EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
> > * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> > * 730 has only 2 McBSP, and both of them are MPU peripherals.
> > */
> > -struct omap_mcbsp_info {
> > - u32 virt_base;
> > - u8 dma_rx_sync, dma_tx_sync;
> > - u16 rx_irq, tx_irq;
> > -};
> > -
> > -#ifdef CONFIG_ARCH_OMAP730
> > -static const struct omap_mcbsp_info mcbsp_730[] = {
> > - [0] = { .virt_base = io_p2v(OMAP730_MCBSP1_BASE),
> > - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> > - .rx_irq = INT_730_McBSP1RX,
> > - .tx_irq = INT_730_McBSP1TX },
> > - [1] = { .virt_base = io_p2v(OMAP730_MCBSP2_BASE),
> > - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> > - .rx_irq = INT_730_McBSP2RX,
> > - .tx_irq = INT_730_McBSP2TX },
> > -};
> > -#endif
> > -
> > -#ifdef CONFIG_ARCH_OMAP15XX
> > -static const struct omap_mcbsp_info mcbsp_1510[] = {
> > - [0] = { .virt_base = OMAP1510_MCBSP1_BASE,
> > - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> > - .rx_irq = INT_McBSP1RX,
> > - .tx_irq = INT_McBSP1TX },
> > - [1] = { .virt_base = io_p2v(OMAP1510_MCBSP2_BASE),
> > - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> > - .rx_irq = INT_1510_SPI_RX,
> > - .tx_irq = INT_1510_SPI_TX },
> > - [2] = { .virt_base = OMAP1510_MCBSP3_BASE,
> > - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> > - .rx_irq = INT_McBSP3RX,
> > - .tx_irq = INT_McBSP3TX },
> > -};
> > -#endif
> > -
> > -#if defined(CONFIG_ARCH_OMAP16XX)
> > -static const struct omap_mcbsp_info mcbsp_1610[] = {
> > - [0] = { .virt_base = OMAP1610_MCBSP1_BASE,
> > - .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
> > - .rx_irq = INT_McBSP1RX,
> > - .tx_irq = INT_McBSP1TX },
> > - [1] = { .virt_base = io_p2v(OMAP1610_MCBSP2_BASE),
> > - .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
> > - .rx_irq = INT_1610_McBSP2_RX,
> > - .tx_irq = INT_1610_McBSP2_TX },
> > - [2] = { .virt_base = OMAP1610_MCBSP3_BASE,
> > - .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
> > - .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
> > - .rx_irq = INT_McBSP3RX,
> > - .tx_irq = INT_McBSP3TX },
> > -};
> > -#endif
> > -
> > -#if defined(CONFIG_ARCH_OMAP24XX)
> > -static const struct omap_mcbsp_info mcbsp_24xx[] = {
> > - [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
> > - .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
> > - .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
> > - .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
> > - .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
> > - },
> > - [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
> > - .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
> > - .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
> > - .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
> > - .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
> > - },
> > -};
> > -#endif
> > -
> > -static int __init omap_mcbsp_init(void)
> > +int __init omap_mcbsp_init(void)
> > {
> > - int mcbsp_count = 0, i;
> > - static const struct omap_mcbsp_info *mcbsp_info;
> > + int i;
> >
> > - printk(KERN_INFO "Initializing OMAP McBSP system\n");
> > -
> > -#ifdef CONFIG_ARCH_OMAP1
> > - mcbsp_dsp_ck = clk_get(0, "dsp_ck");
> > - if (IS_ERR(mcbsp_dsp_ck)) {
> > - printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
> > - return PTR_ERR(mcbsp_dsp_ck);
> > - }
> > - mcbsp_api_ck = clk_get(0, "api_ck");
> > - if (IS_ERR(mcbsp_api_ck)) {
> > - printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
> > - return PTR_ERR(mcbsp_api_ck);
> > - }
> > - mcbsp_dspxor_ck = clk_get(0, "dspxor_ck");
> > - if (IS_ERR(mcbsp_dspxor_ck)) {
> > - printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
> > - return PTR_ERR(mcbsp_dspxor_ck);
> > - }
> > -#endif
> > -#ifdef CONFIG_ARCH_OMAP2
> > - mcbsp1_ick = clk_get(0, "mcbsp1_ick");
> > - if (IS_ERR(mcbsp1_ick)) {
> > - printk(KERN_ERR "mcbsp: could not acquire "
> > - "mcbsp1_ick handle.\n");
> > - return PTR_ERR(mcbsp1_ick);
> > - }
> > - mcbsp1_fck = clk_get(0, "mcbsp1_fck");
> > - if (IS_ERR(mcbsp1_fck)) {
> > - printk(KERN_ERR "mcbsp: could not acquire "
> > - "mcbsp1_fck handle.\n");
> > - return PTR_ERR(mcbsp1_fck);
> > - }
> > - mcbsp2_ick = clk_get(0, "mcbsp2_ick");
> > - if (IS_ERR(mcbsp2_ick)) {
> > - printk(KERN_ERR "mcbsp: could not acquire "
> > - "mcbsp2_ick handle.\n");
> > - return PTR_ERR(mcbsp2_ick);
> > - }
> > - mcbsp2_fck = clk_get(0, "mcbsp2_fck");
> > - if (IS_ERR(mcbsp2_fck)) {
> > - printk(KERN_ERR "mcbsp: could not acquire "
> > - "mcbsp2_fck handle.\n");
> > - return PTR_ERR(mcbsp2_fck);
> > + if (!mcbsp_config) {
> > + printk(KERN_ERR "McBSP initialized without configuration\n");
> > + return -EINVAL;
> > }
> > -#endif
> >
> > -#ifdef CONFIG_ARCH_OMAP730
> > - if (cpu_is_omap730()) {
> > - mcbsp_info = mcbsp_730;
> > - mcbsp_count = ARRAY_SIZE(mcbsp_730);
> > - }
> > -#endif
> > -#ifdef CONFIG_ARCH_OMAP15XX
> > - if (cpu_is_omap15xx()) {
> > - mcbsp_info = mcbsp_1510;
> > - mcbsp_count = ARRAY_SIZE(mcbsp_1510);
> > - }
> > -#endif
> > -#if defined(CONFIG_ARCH_OMAP16XX)
> > - if (cpu_is_omap16xx()) {
> > - mcbsp_info = mcbsp_1610;
> > - mcbsp_count = ARRAY_SIZE(mcbsp_1610);
> > - }
> > -#endif
> > -#if defined(CONFIG_ARCH_OMAP24XX)
> > - if (cpu_is_omap24xx()) {
> > - mcbsp_info = mcbsp_24xx;
> > - mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
> > - omap2_mcbsp2_mux_setup();
> > - }
> > -#endif
> > + printk(KERN_INFO "Initializing OMAP McBSP system\n");
> > +
> > for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
> > - if (i >= mcbsp_count) {
> > + if (i >= ARRAY_SIZE(mcbsp_config->mcbsp_infos)) {
> > mcbsp[i].io_base = 0;
> > mcbsp[i].free = 0;
> > continue;
> > @@ -1036,17 +772,29 @@ static int __init omap_mcbsp_init(void)
> > mcbsp[i].dma_tx_lch = -1;
> > mcbsp[i].dma_rx_lch = -1;
> >
> > - mcbsp[i].io_base = mcbsp_info[i].virt_base;
> > + mcbsp[i].io_base = mcbsp_config->mcbsp_infos[i].virt_base;
> > /* Default I/O is IRQ based */
> > mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO;
> > - mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
> > - mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
> > - mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
> > - mcbsp[i].dma_tx_sync = mcbsp_info[i].dma_tx_sync;
> > + mcbsp[i].tx_irq = mcbsp_config->mcbsp_infos[i].tx_irq;
> > + mcbsp[i].rx_irq = mcbsp_config->mcbsp_infos[i].rx_irq;
> > + mcbsp[i].dma_rx_sync = mcbsp_config->mcbsp_infos[i].dma_rx_sync;
> > + mcbsp[i].dma_tx_sync = mcbsp_config->mcbsp_infos[i].dma_tx_sync;
> > spin_lock_init(&mcbsp[i].lock);
> > }
> >
> > return 0;
> > }
> >
> > -arch_initcall(omap_mcbsp_init);
> > +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config)
> > +{
> > + if (!config || !config->request || !config->free) {
> > + printk(KERN_ERR "Invalid McBSP configuration\n");
> > + return -EINVAL;
> > + }
> > +
> > + mcbsp_config = config;
> > +
> > + return 0;
> > +
> > +}
> > +
> > diff --git a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
> > index b53c3b2..fc53a45 100644
> > --- a/include/asm-arm/arch-omap/mcbsp.h
> > +++ b/include/asm-arm/arch-omap/mcbsp.h
> > @@ -40,6 +40,9 @@
> > #define OMAP24XX_MCBSP1_BASE 0x48074000
> > #define OMAP24XX_MCBSP2_BASE 0x48076000
> >
> > +#define OMAP34XX_MCBSP1_BASE 0x48074000
> > +#define OMAP34XX_MCBSP2_BASE 0x49022000
> > +
> > #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
> >
> > #define OMAP_MCBSP_REG_DRR2 0x00
> > @@ -298,6 +301,22 @@ struct omap_mcbsp_spi_cfg {
> > omap_mcbsp_word_length word_length;
> > };
> >
> > +/* Board specific configuration */
> > +struct omap_mcbsp_info {
> > + u32 virt_base;
> > + u8 dma_rx_sync, dma_tx_sync;
> > + u16 rx_irq, tx_irq;
> > +};
> > +
> > +struct omap_mcbsp_board_cfg {
> > + void (*request)(unsigned int);
> > + void (*free)(unsigned int);
> > + int (*check)(unsigned int);
> > + struct omap_mcbsp_info mcbsp_infos[OMAP_MAX_MCBSP_COUNT];
> > +};
> > +
> > +int omap_mcbsp_init(void);
> > +int omap_mcbsp_register_board_cfg(const struct omap_mcbsp_board_cfg *config);
> > void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
> > int omap_mcbsp_request(unsigned int id);
> > void omap_mcbsp_free(unsigned int id);
> > --
> > 1.5.5-rc3.GIT
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Eduardo Bezerra Valentin
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-22 6:29 ` Eduardo Valentin
@ 2008-04-22 9:24 ` Syed Mohammed, Khasim
2008-04-22 9:38 ` Jarkko Nikula
0 siblings, 1 reply; 22+ messages in thread
From: Syed Mohammed, Khasim @ 2008-04-22 9:24 UTC (permalink / raw)
To: Eduardo Valentin, Tony Lindgren; +Cc: linux-omap, Eduardo Valentin
Hi Eduardo,
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> owner@vger.kernel.org] On Behalf Of Eduardo Valentin
> Sent: Tuesday, April 22, 2008 12:00 PM
> To: Tony Lindgren
> Cc: linux-omap@vger.kernel.org; Eduardo Valentin
> Subject: Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from
> plat-omap to mach-omap
>
> Hi Tony,
>
> I'll apply your comments and re-write mcbsp driver as a platform driver.
>
Good to know you are volunteering for upgrading McBSP driver.
Can you also make sure that McBSP driver uses DMA chaining APIs? With out chaining support McBSP Driver will be unusable for a real time audio playback.
Thanks
Regards,
Khasim
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-22 9:24 ` Syed Mohammed, Khasim
@ 2008-04-22 9:38 ` Jarkko Nikula
2008-04-22 10:10 ` Syed Mohammed, Khasim
0 siblings, 1 reply; 22+ messages in thread
From: Jarkko Nikula @ 2008-04-22 9:38 UTC (permalink / raw)
To: ext Syed Mohammed, Khasim
Cc: Eduardo Valentin, Tony Lindgren, linux-omap, Eduardo Valentin
On Tue, 22 Apr 2008 14:54:21 +0530
"ext Syed Mohammed, Khasim" <khasim@ti.com> wrote:
> Good to know you are volunteering for upgrading McBSP driver.
>
> Can you also make sure that McBSP driver uses DMA chaining APIs? With
> out chaining support McBSP Driver will be unusable for a real time
> audio playback.
>
Multichannel chaining is not necessary AFAIK because we can set up
OMAP DMA transfer so that interrupt is generated in end of each ALSA
period and then link channel with itself.
I did it so in my ASoC driver:
http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=linux-2.6-asoc.git;a=blob;f=sound/soc/omap/omap-pcm.c;h=62370202c649c5aac50e542626b574a7079909e2;hb=dev
In fact, my first version used the chaining API, until we figured out
this with Tony :-)
Jarkko
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap
2008-04-22 9:38 ` Jarkko Nikula
@ 2008-04-22 10:10 ` Syed Mohammed, Khasim
0 siblings, 0 replies; 22+ messages in thread
From: Syed Mohammed, Khasim @ 2008-04-22 10:10 UTC (permalink / raw)
To: Jarkko Nikula
Cc: Eduardo Valentin, Tony Lindgren, linux-omap, Eduardo Valentin
Hi Jarkko,
> -----Original Message-----
> From: Jarkko Nikula [mailto:jarkko.nikula@nokia.com]
> Sent: Tuesday, April 22, 2008 3:08 PM
> To: Syed Mohammed, Khasim
> Cc: Eduardo Valentin; Tony Lindgren; linux-omap@vger.kernel.org; Eduardo
> Valentin
> Subject: Re: [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from
> plat-omap to mach-omap
>
> On Tue, 22 Apr 2008 14:54:21 +0530
> "ext Syed Mohammed, Khasim" <khasim@ti.com> wrote:
>
> > Good to know you are volunteering for upgrading McBSP driver.
> >
> > Can you also make sure that McBSP driver uses DMA chaining APIs? With
> > out chaining support McBSP Driver will be unusable for a real time
> > audio playback.
> >
> Multichannel chaining is not necessary AFAIK because we can set up
> OMAP DMA transfer so that interrupt is generated in end of each ALSA
> period and then link channel with itself.
>
Thanks for giving this info, will check this out.
Regards,
Khasim
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2008-04-22 10:10 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-14 15:52 [PATCH 0/2] Code update for mcbsp driver Eduardo Valentin
2008-04-14 15:53 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Eduardo Valentin
2008-04-14 15:53 ` [PATCH 2/2] PLAT-OMAP: MCBSP: Move code mach specific from plat-omap to mach-omap Eduardo Valentin
2008-04-14 18:18 ` Felipe Balbi
2008-04-14 20:11 ` Eduardo Valentin
2008-04-14 20:11 ` Eduardo Valentin
2008-04-14 20:23 ` Felipe Balbi
2008-04-15 9:38 ` Jarkko Nikula
2008-04-15 9:41 ` Eduardo Valentin
2008-04-15 14:49 ` Chandra shekhar
2008-04-15 16:52 ` David Brownell
2008-04-15 19:09 ` Tony Lindgren
2008-04-21 18:33 ` Tony Lindgren
2008-04-22 6:29 ` Eduardo Valentin
2008-04-22 9:24 ` Syed Mohammed, Khasim
2008-04-22 9:38 ` Jarkko Nikula
2008-04-22 10:10 ` Syed Mohammed, Khasim
2008-04-14 18:16 ` [PATCH 1/2] PLAT-OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c Felipe Balbi
2008-04-14 20:24 ` Eduardo Valentin
2008-04-14 20:24 ` Eduardo Valentin
2008-04-14 20:41 ` Felipe Balbi
2008-04-21 18:18 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox