Skip to contentSkip to conversation

ARM: OMAP3: Update McBSP with changes in struct omap_mcbsp

PATCH New [email protected] 1 participant 1 message Nov 19, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: OMAP3: Update McBSP with changes in struct omap_mcbsp

From: Misael Lopez Cruz <[email protected]>

This patch updates McBSP driver with the changes in "struct omap_mcbsp". omap_mcbsp structure suffered some changes because of a virtual/physical addresses fix and McBSP driver was not properly updated. It was causing DMA transaction errors and several compilation warnings.

Signed-off-by Misael Lopez Cruz <mesak82gmail.com>
---
 arch/arm/mach-omap2/mcbsp.c             |  107 ++++++++++++++++++-------------
 arch/arm/plat-omap/include/mach/mcbsp.h |   58 ++++++++--------
 arch/arm/plat-omap/mcbsp.c              |   11 +++-
 3 files changed, 100 insertions(+), 76 deletions(-)
arch/arm/mach-omap2/mcbsp.c +62 -45
index ce726c5..359147e 100644
@@ -156,7 +156,8 @@ static void omap2_mcbsp_request(unsigned int id)
 static void  mcbsp_power_settings(unsigned int id, int level)
 {
 	struct omap_mcbsp *mcbsp;
-	u32 io_base;
+	void __iomem *io_base;
+
 	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
@@ -196,7 +197,8 @@ void omap2_mcbsp_config(unsigned int id,
 			 const struct omap_mcbsp_reg_cfg *config)
 {
 	struct omap_mcbsp *mcbsp;
-	u32 io_base;
+	void __iomem *io_base;
+
 	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 	omap_mcbsp_write(io_base, OMAP_MCBSP_REG_XCCR, config->xccr);
@@ -210,7 +212,8 @@ static struct omap_mcbsp_ops omap2_mcbsp_ops = {
 static void omap2_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
 {
 	struct omap_mcbsp *mcbsp_dma_rx = data;
-	u32 io_base;
+	void __iomem *io_base;
+
 	io_base = mcbsp_dma_rx->io_base;
 
 	/* If we are at the last transfer, Shut down the reciever */
@@ -229,7 +232,8 @@ static void omap2_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
 static void omap2_mcbsp_tx_dma_callback(int lch, u16 ch_status, void *data)
 {
 	struct omap_mcbsp *mcbsp_dma_tx = data;
-	u32 io_base;
+	void __iomem *io_base;
+
 	io_base = mcbsp_dma_tx->io_base;
 
 	/* If we are at the last transfer, Shut down the Transmitter */
@@ -318,9 +322,11 @@ void omap2_mcbsp_set_srg_cfg_param(unsigned int id, int interface_mode,
 					struct omap_mcbsp_reg_cfg *mcbsp_cfg,
 					struct omap_mcbsp_srg_fsg_cfg *param)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 	u32 clk_rate, clkgdv;
+
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	mcbsp->interface_mode = interface_mode;
@@ -433,9 +439,10 @@ EXPORT_SYMBOL(omap2_mcbsp_params_cfg);
  */
 void omap2_mcbsp_set_srg_fsg(unsigned int id, u8 state)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	if (state == OMAP_MCBSP_DISABLE_FSG_SRG) {
@@ -460,14 +467,15 @@ void omap2_mcbsp_set_srg_fsg(unsigned int id, u8 state)
  */
 int omap2_mcbsp_stop_datatx(unsigned int id)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	if (mcbsp->dma_tx_lch != -1) {
@@ -491,14 +499,15 @@ EXPORT_SYMBOL(omap2_mcbsp_stop_datatx);
  */
 int omap2_mcbsp_stop_datarx(u32 id)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	if (mcbsp->dma_rx_lch != -1) {
@@ -523,8 +532,8 @@ EXPORT_SYMBOL(omap2_mcbsp_stop_datarx);
  */
 int omap2_mcbsp_reset(unsigned int id)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 	int counter = 0;
 	int wait_for_reset = 10000;
 
@@ -533,6 +542,7 @@ int omap2_mcbsp_reset(unsigned int id)
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	omap_mcbsp_write(io_base, OMAP_MCBSP_REG_SYSCON,
@@ -562,7 +572,7 @@ EXPORT_SYMBOL(omap2_mcbsp_reset);
  */
 int omap2_mcbsp_transmitter_index(int id, int *ei, int *fi)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
+	struct omap_mcbsp *mcbsp;
 	int eix = 0, fix = 0;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
@@ -570,6 +580,8 @@ int omap2_mcbsp_transmitter_index(int id, int *ei, int *fi)
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
+
 	if ((!ei) || (!fi)) {
 		printk(KERN_ERR	"OMAP_McBSP: Invalid ei and fi params \n");
 		goto txinx_err;
@@ -604,7 +616,7 @@ EXPORT_SYMBOL(omap2_mcbsp_transmitter_index);
  */
 int omap2_mcbsp_receiver_index(int id, int *ei, int *fi)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
+	struct omap_mcbsp *mcbsp;
 	int eix = 0, fix = 0;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
@@ -612,6 +624,8 @@ int omap2_mcbsp_receiver_index(int id, int *ei, int *fi)
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
+
 	if ((!ei) || (!fi)) {
 		printk(KERN_ERR	"OMAP_McBSP: Invalid ei and fi params x\n");
 		goto rxinx_err;
@@ -646,13 +660,15 @@ EXPORT_SYMBOL(omap2_mcbsp_receiver_index);
  */
 int omap2_mcbsp_set_xrst(unsigned int id, u8 state)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
+
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	if (state == OMAP_MCBSP_XRST_DISABLE)
@@ -674,13 +690,15 @@ EXPORT_SYMBOL(omap2_mcbsp_set_xrst);
  */
 int omap2_mcbsp_set_rrst(unsigned int id, u8 state)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
+
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	if (state == OMAP_MCBSP_RRST_DISABLE)
@@ -702,14 +720,15 @@ EXPORT_SYMBOL(omap2_mcbsp_set_rrst);
  */
 int omap2_mcbsp_rxmultich_enable(unsigned int id, u8 state)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	if (state == OMAP_MCBSP_RXMUTICH_ENABLE) {
@@ -742,15 +761,15 @@ EXPORT_SYMBOL(omap2_mcbsp_rxmultich_enable);
  */
 int omap2_mcbsp_txmultich_enable(unsigned int id, u32 state)
 {
-
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	if (state == OMAP_MCBSP_TXMUTICH_ENABLE) {
@@ -787,14 +806,15 @@ EXPORT_SYMBOL(omap2_mcbsp_txmultich_enable);
 int omap2_mcbsp_txmultich_cfg(unsigned int id, u8 part_mode, u8 parta_enable,
 					 u8 partb_enable, u32 ch_enable)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	/* check for valid partition mode */
@@ -826,14 +846,15 @@ EXPORT_SYMBOL(omap2_mcbsp_txmultich_cfg);
 int omap2_mcbsp_rxmultich_cfg(unsigned int id, u8 part_mode,
 			       u8 parta_enable, u8 partb_enable, u32 ch_enable)
 {
-	struct omap_mcbsp *mcbsp = mcbsp_ptr[id];
-	u32 io_base;
+	struct omap_mcbsp *mcbsp;
+	void __iomem *io_base;
 
 	if (!omap_mcbsp_check_valid_id(id)) {
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
 
 	/* check for valid partition mode */
@@ -861,7 +882,7 @@ int omap2_mcbsp_dma_recv_params(unsigned int id,
 				omap_mcbsp_dma_transfer_params *rp)
 {
 	struct omap_mcbsp *mcbsp;
-	u32 io_base;
+	void __iomem *io_base;
 	int err, chain_id = -1;
 	struct omap_dma_channel_params rx_params;
 	u32  dt = 0;
@@ -971,10 +992,9 @@ int omap2_mcbsp_dma_trans_params(unsigned int id,
 				omap_mcbsp_dma_transfer_params *tp)
 {
 	struct omap_mcbsp *mcbsp;
-
+	void __iomem *io_base;
 	struct omap_dma_channel_params tx_params;
 	int err = 0, chain_id = -1;
-	u32 io_base;
 	u32 dt = 0;
 #ifdef CONFIG_USE_MCBSP_FIFO
 	u32 mcbsp_fifo_size;
@@ -1088,7 +1108,7 @@ int omap2_mcbsp_receive_data(unsigned int id, void *cbdata,
 			     dma_addr_t buf_start_addr, u32 buf_size)
 {
 	struct omap_mcbsp *mcbsp;
-	u32 io_base;
+	void __iomem *io_base;
 	int enable_rx = 0;
 	int e_count = 0;
 	int f_count = 0;
@@ -1104,9 +1124,7 @@ int omap2_mcbsp_receive_data(unsigned int id, void *cbdata,
 	}
 
 	mcbsp = id_to_mcbsp_ptr(id);
-
 	io_base = mcbsp->io_base;
-
 	mcbsp->rx_cb_arg = cbdata;
 
 	/* Auto RRST handling logic - disable the Reciever before 1st dma */
@@ -1192,7 +1210,7 @@ int omap2_mcbsp_receive_data(unsigned int id, void *cbdata,
 		buf_start_addr += mcbsp->rx_word_length;
 
 	if (omap_dma_chain_a_transfer(mcbsp->dma_rx_lch,
-			mcbsp->phy_base + OMAP_MCBSP_REG_DRR, buf_start_addr,
+			mcbsp->phys_base + OMAP_MCBSP_REG_DRR, buf_start_addr,
 			e_count, f_count, mcbsp) < 0) {
 		printk(KERN_ERR " Buffer chaining failed \n");
 		return -EINVAL;
@@ -1227,7 +1245,7 @@ int omap2_mcbsp_send_data(unsigned int id, void *cbdata,
 			  dma_addr_t buf_start_addr, u32 buf_size)
 {
 	struct omap_mcbsp *mcbsp;
-	u32 io_base;
+	void __iomem *io_base;
 	u8 enable_tx = 0;
 	int e_count = 0;
 	int f_count = 0;
@@ -1236,10 +1254,9 @@ int omap2_mcbsp_send_data(unsigned int id, void *cbdata,
 		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
 		return -ENODEV;
 	}
-	mcbsp = id_to_mcbsp_ptr(id);
 
+	mcbsp = id_to_mcbsp_ptr(id);
 	io_base = mcbsp->io_base;
-
 	mcbsp->tx_cb_arg = cbdata;
 
 	/* Auto RRST handling logic - disable the Reciever before 1st dma */
@@ -1277,7 +1294,7 @@ int omap2_mcbsp_send_data(unsigned int id, void *cbdata,
 		buf_start_addr += mcbsp->tx_word_length;
 
 	if (omap_dma_chain_a_transfer(mcbsp->dma_tx_lch,
-		buf_start_addr,	mcbsp->phy_base + OMAP_MCBSP_REG_DXR,
+		buf_start_addr,	mcbsp->phys_base + OMAP_MCBSP_REG_DXR,
 		e_count, f_count, mcbsp) < 0)
 			return -EINVAL;
 
@@ -1385,7 +1402,7 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
 #ifdef CONFIG_ARCH_OMAP34XX
 static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
 	{
-		.phy_base	= OMAP34XX_MCBSP1_BASE,
+		.phys_base	= OMAP34XX_MCBSP1_BASE,
 		.dma_rx_sync	= OMAP24XX_DMA_MCBSP1_RX,
 		.dma_tx_sync	= OMAP24XX_DMA_MCBSP1_TX,
 		.rx_irq		= INT_24XX_MCBSP1_IRQ_RX,
@@ -1394,7 +1411,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
 		.clk_name	= "mcbsp_clk",
 	},
 	{
-		.phy_base	= OMAP34XX_MCBSP2_BASE,
+		.phys_base	= OMAP34XX_MCBSP2_BASE,
 		.dma_rx_sync	= OMAP24XX_DMA_MCBSP2_RX,
 		.dma_tx_sync	= OMAP24XX_DMA_MCBSP2_TX,
 		.rx_irq		= INT_24XX_MCBSP2_IRQ_RX,
@@ -1403,7 +1420,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
 		.clk_name	= "mcbsp_clk",
 	},
 	{
-		.phy_base	= OMAP34XX_MCBSP3_BASE,
+		.phys_base	= OMAP34XX_MCBSP3_BASE,
 		.dma_rx_sync	= OMAP24XX_DMA_MCBSP3_RX,
 		.dma_tx_sync	= OMAP24XX_DMA_MCBSP3_TX,
 		.rx_irq		= INT_24XX_MCBSP3_IRQ_RX,
@@ -1412,7 +1429,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
 		.clk_name	= "mcbsp_clk",
 	},
 	{
-		.phy_base	= OMAP34XX_MCBSP4_BASE,
+		.phys_base	= OMAP34XX_MCBSP4_BASE,
 		.dma_rx_sync	= OMAP24XX_DMA_MCBSP4_RX,
 		.dma_tx_sync	= OMAP24XX_DMA_MCBSP4_TX,
 		.rx_irq		= INT_24XX_MCBSP4_IRQ_RX,
@@ -1421,7 +1438,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
 		.clk_name	= "mcbsp_clk",
 	},
 	{
-		.phy_base	= OMAP34XX_MCBSP5_BASE,
+		.phys_base	= OMAP34XX_MCBSP5_BASE,
 		.dma_rx_sync	= OMAP24XX_DMA_MCBSP5_RX,
 		.dma_tx_sync	= OMAP24XX_DMA_MCBSP5_TX,
 		.rx_irq		= INT_24XX_MCBSP5_IRQ_RX,
arch/arm/plat-omap/include/mach/mcbsp.h +29 -29

95 lines not on this page · raw message

arch/arm/plat-omap/mcbsp.c +9 -2
index 8d6cc35..906e8e3 100644
@@ -52,6 +52,9 @@ int omap_mcbsp_read(void __iomem *io_base, u16 reg)
 #define OMAP_MCBSP_WRITE(base, reg, val) \
 			omap_mcbsp_write(base, OMAP_MCBSP_REG_##reg, val)
 
+#define omap_mcbsp_check_valid_id(id)	(id < omap_mcbsp_count)
+#define id_to_mcbsp_ptr(id)		mcbsp_ptr[id];
+
 static void omap_mcbsp_dump_reg(u8 id)
 {
 	struct omap_mcbsp *mcbsp = id_to_mcbsp_ptr(id);
@@ -224,6 +227,8 @@ int omap_mcbsp_request(unsigned int id)
 	if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
 		mcbsp->pdata->ops->request(id);
 
+	clk_enable(mcbsp->clk);
+
 	spin_lock(&mcbsp->lock);
 	if (!mcbsp->free) {
 		dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
@@ -283,6 +288,8 @@ void omap_mcbsp_free(unsigned int id)
 	if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free)
 		mcbsp->pdata->ops->free(id);
 
+	clk_disable(mcbsp->clk);
+
 	spin_lock(&mcbsp->lock);
 	if (mcbsp->free) {
 		dev_err(mcbsp->dev, "McBSP%d was not reserved\n",
@@ -897,8 +904,8 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
 	mcbsp->dma_tx_lch = -1;
 	mcbsp->dma_rx_lch = -1;
 
-	mcbsp->phys_base = pdata->phy_base;
-	mcbsp->io_base = ioremap(pdata->phy_base, SZ_4K);
+	mcbsp->phys_base = pdata->phys_base;
+	mcbsp->io_base = ioremap(pdata->phys_base, SZ_4K);
 	if (!mcbsp->io_base) {
 		ret = -ENOMEM;
 		goto err_ioremap;
Signature · 1 line
1.5.6.3