Commit 9fc71e8f authored by Jorge Eduardo Candelaria's avatar Jorge Eduardo Candelaria Committed by Mark Brown

ASoC: McPDM: Use tabs for indentation

Indentation in initial support for McPDM driver was converted to spaces.
Use tabs to comply with open source coding-style.
Signed-off-by: default avatarJorge Eduardo Candelaria <jorge.candelaria@ti.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 6a1c7b7e
/* /*
* mcpdm.c -- McPDM interface driver * mcpdm.c -- McPDM interface driver
* *
* Author: Jorge Eduardo Candelaria <x0107209@ti.com> * Author: Jorge Eduardo Candelaria <x0107209@ti.com>
* Copyright (C) 2009 - Texas Instruments, Inc. * Copyright (C) 2009 - Texas Instruments, Inc.
...@@ -38,46 +38,46 @@ static struct omap_mcpdm *mcpdm; ...@@ -38,46 +38,46 @@ static struct omap_mcpdm *mcpdm;
static inline void omap_mcpdm_write(u16 reg, u32 val) static inline void omap_mcpdm_write(u16 reg, u32 val)
{ {
__raw_writel(val, mcpdm->io_base + reg); __raw_writel(val, mcpdm->io_base + reg);
} }
static inline int omap_mcpdm_read(u16 reg) static inline int omap_mcpdm_read(u16 reg)
{ {
return __raw_readl(mcpdm->io_base + reg); return __raw_readl(mcpdm->io_base + reg);
} }
static void omap_mcpdm_reg_dump(void) static void omap_mcpdm_reg_dump(void)
{ {
dev_dbg(mcpdm->dev, "***********************\n"); dev_dbg(mcpdm->dev, "***********************\n");
dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n", dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n",
omap_mcpdm_read(MCPDM_IRQSTATUS_RAW)); omap_mcpdm_read(MCPDM_IRQSTATUS_RAW));
dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n", dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n",
omap_mcpdm_read(MCPDM_IRQSTATUS)); omap_mcpdm_read(MCPDM_IRQSTATUS));
dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n", dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n",
omap_mcpdm_read(MCPDM_IRQENABLE_SET)); omap_mcpdm_read(MCPDM_IRQENABLE_SET));
dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n", dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n",
omap_mcpdm_read(MCPDM_IRQENABLE_CLR)); omap_mcpdm_read(MCPDM_IRQENABLE_CLR));
dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n", dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n",
omap_mcpdm_read(MCPDM_IRQWAKE_EN)); omap_mcpdm_read(MCPDM_IRQWAKE_EN));
dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n", dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n",
omap_mcpdm_read(MCPDM_DMAENABLE_SET)); omap_mcpdm_read(MCPDM_DMAENABLE_SET));
dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n", dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n",
omap_mcpdm_read(MCPDM_DMAENABLE_CLR)); omap_mcpdm_read(MCPDM_DMAENABLE_CLR));
dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n", dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n",
omap_mcpdm_read(MCPDM_DMAWAKEEN)); omap_mcpdm_read(MCPDM_DMAWAKEEN));
dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n", dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n",
omap_mcpdm_read(MCPDM_CTRL)); omap_mcpdm_read(MCPDM_CTRL));
dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n", dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n",
omap_mcpdm_read(MCPDM_DN_DATA)); omap_mcpdm_read(MCPDM_DN_DATA));
dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n", dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n",
omap_mcpdm_read(MCPDM_UP_DATA)); omap_mcpdm_read(MCPDM_UP_DATA));
dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n", dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n",
omap_mcpdm_read(MCPDM_FIFO_CTRL_DN)); omap_mcpdm_read(MCPDM_FIFO_CTRL_DN));
dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n", dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n",
omap_mcpdm_read(MCPDM_FIFO_CTRL_UP)); omap_mcpdm_read(MCPDM_FIFO_CTRL_UP));
dev_dbg(mcpdm->dev, "DN_OFFSET: 0x%04x\n", dev_dbg(mcpdm->dev, "DN_OFFSET: 0x%04x\n",
omap_mcpdm_read(MCPDM_DN_OFFSET)); omap_mcpdm_read(MCPDM_DN_OFFSET));
dev_dbg(mcpdm->dev, "***********************\n"); dev_dbg(mcpdm->dev, "***********************\n");
} }
/* /*
...@@ -86,26 +86,26 @@ static void omap_mcpdm_reg_dump(void) ...@@ -86,26 +86,26 @@ static void omap_mcpdm_reg_dump(void)
*/ */
static void omap_mcpdm_reset_capture(int reset) static void omap_mcpdm_reset_capture(int reset)
{ {
int ctrl = omap_mcpdm_read(MCPDM_CTRL); int ctrl = omap_mcpdm_read(MCPDM_CTRL);
if (reset) if (reset)
ctrl |= SW_UP_RST; ctrl |= SW_UP_RST;
else else
ctrl &= ~SW_UP_RST; ctrl &= ~SW_UP_RST;
omap_mcpdm_write(MCPDM_CTRL, ctrl); omap_mcpdm_write(MCPDM_CTRL, ctrl);
} }
static void omap_mcpdm_reset_playback(int reset) static void omap_mcpdm_reset_playback(int reset)
{ {
int ctrl = omap_mcpdm_read(MCPDM_CTRL); int ctrl = omap_mcpdm_read(MCPDM_CTRL);
if (reset) if (reset)
ctrl |= SW_DN_RST; ctrl |= SW_DN_RST;
else else
ctrl &= ~SW_DN_RST; ctrl &= ~SW_DN_RST;
omap_mcpdm_write(MCPDM_CTRL, ctrl); omap_mcpdm_write(MCPDM_CTRL, ctrl);
} }
/* /*
...@@ -114,14 +114,14 @@ static void omap_mcpdm_reset_playback(int reset) ...@@ -114,14 +114,14 @@ static void omap_mcpdm_reset_playback(int reset)
*/ */
void omap_mcpdm_start(int stream) void omap_mcpdm_start(int stream)
{ {
int ctrl = omap_mcpdm_read(MCPDM_CTRL); int ctrl = omap_mcpdm_read(MCPDM_CTRL);
if (stream) if (stream)
ctrl |= mcpdm->up_channels; ctrl |= mcpdm->up_channels;
else else
ctrl |= mcpdm->dn_channels; ctrl |= mcpdm->dn_channels;
omap_mcpdm_write(MCPDM_CTRL, ctrl); omap_mcpdm_write(MCPDM_CTRL, ctrl);
} }
/* /*
...@@ -130,14 +130,14 @@ void omap_mcpdm_start(int stream) ...@@ -130,14 +130,14 @@ void omap_mcpdm_start(int stream)
*/ */
void omap_mcpdm_stop(int stream) void omap_mcpdm_stop(int stream)
{ {
int ctrl = omap_mcpdm_read(MCPDM_CTRL); int ctrl = omap_mcpdm_read(MCPDM_CTRL);
if (stream) if (stream)
ctrl &= ~mcpdm->up_channels; ctrl &= ~mcpdm->up_channels;
else else
ctrl &= ~mcpdm->dn_channels; ctrl &= ~mcpdm->dn_channels;
omap_mcpdm_write(MCPDM_CTRL, ctrl); omap_mcpdm_write(MCPDM_CTRL, ctrl);
} }
/* /*
...@@ -146,38 +146,38 @@ void omap_mcpdm_stop(int stream) ...@@ -146,38 +146,38 @@ void omap_mcpdm_stop(int stream)
*/ */
int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink) int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink)
{ {
int irq_mask = 0; int irq_mask = 0;
int ctrl; int ctrl;
if (!uplink) if (!uplink)
return -EINVAL; return -EINVAL;
mcpdm->uplink = uplink; mcpdm->uplink = uplink;
/* Enable irq request generation */ /* Enable irq request generation */
irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK;
omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask);
/* Configure uplink threshold */ /* Configure uplink threshold */
if (uplink->threshold > UP_THRES_MAX) if (uplink->threshold > UP_THRES_MAX)
uplink->threshold = UP_THRES_MAX; uplink->threshold = UP_THRES_MAX;
omap_mcpdm_write(MCPDM_FIFO_CTRL_UP, uplink->threshold); omap_mcpdm_write(MCPDM_FIFO_CTRL_UP, uplink->threshold);
/* Configure DMA controller */ /* Configure DMA controller */
omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_UP_ENABLE); omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_UP_ENABLE);
/* Set pdm out format */ /* Set pdm out format */
ctrl = omap_mcpdm_read(MCPDM_CTRL); ctrl = omap_mcpdm_read(MCPDM_CTRL);
ctrl &= ~PDMOUTFORMAT; ctrl &= ~PDMOUTFORMAT;
ctrl |= uplink->format & PDMOUTFORMAT; ctrl |= uplink->format & PDMOUTFORMAT;
/* Uplink channels */ /* Uplink channels */
mcpdm->up_channels = uplink->channels & (PDM_UP_MASK | PDM_STATUS_MASK); mcpdm->up_channels = uplink->channels & (PDM_UP_MASK | PDM_STATUS_MASK);
omap_mcpdm_write(MCPDM_CTRL, ctrl); omap_mcpdm_write(MCPDM_CTRL, ctrl);
return 0; return 0;
} }
/* /*
...@@ -186,38 +186,38 @@ int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink) ...@@ -186,38 +186,38 @@ int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink)
*/ */
int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink) int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink)
{ {
int irq_mask = 0; int irq_mask = 0;
int ctrl; int ctrl;
if (!downlink) if (!downlink)
return -EINVAL; return -EINVAL;
mcpdm->downlink = downlink; mcpdm->downlink = downlink;
/* Enable irq request generation */ /* Enable irq request generation */
irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK;
omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask);
/* Configure uplink threshold */ /* Configure uplink threshold */
if (downlink->threshold > DN_THRES_MAX) if (downlink->threshold > DN_THRES_MAX)
downlink->threshold = DN_THRES_MAX; downlink->threshold = DN_THRES_MAX;
omap_mcpdm_write(MCPDM_FIFO_CTRL_DN, downlink->threshold); omap_mcpdm_write(MCPDM_FIFO_CTRL_DN, downlink->threshold);
/* Enable DMA request generation */ /* Enable DMA request generation */
omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_DN_ENABLE); omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_DN_ENABLE);
/* Set pdm out format */ /* Set pdm out format */
ctrl = omap_mcpdm_read(MCPDM_CTRL); ctrl = omap_mcpdm_read(MCPDM_CTRL);
ctrl &= ~PDMOUTFORMAT; ctrl &= ~PDMOUTFORMAT;
ctrl |= downlink->format & PDMOUTFORMAT; ctrl |= downlink->format & PDMOUTFORMAT;
/* Downlink channels */ /* Downlink channels */
mcpdm->dn_channels = downlink->channels & (PDM_DN_MASK | PDM_CMD_MASK); mcpdm->dn_channels = downlink->channels & (PDM_DN_MASK | PDM_CMD_MASK);
omap_mcpdm_write(MCPDM_CTRL, ctrl); omap_mcpdm_write(MCPDM_CTRL, ctrl);
return 0; return 0;
} }
/* /*
...@@ -226,24 +226,24 @@ int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink) ...@@ -226,24 +226,24 @@ int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink)
*/ */
int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink) int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink)
{ {
int irq_mask = 0; int irq_mask = 0;
if (!uplink) if (!uplink)
return -EINVAL; return -EINVAL;
/* Disable irq request generation */ /* Disable irq request generation */
irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK;
omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask);
/* Disable DMA request generation */ /* Disable DMA request generation */
omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_UP_ENABLE); omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_UP_ENABLE);
/* Clear Downlink channels */ /* Clear Downlink channels */
mcpdm->up_channels = 0; mcpdm->up_channels = 0;
mcpdm->uplink = NULL; mcpdm->uplink = NULL;
return 0; return 0;
} }
/* /*
...@@ -252,124 +252,124 @@ int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink) ...@@ -252,124 +252,124 @@ int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink)
*/ */
int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink) int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink)
{ {
int irq_mask = 0; int irq_mask = 0;
if (!downlink) if (!downlink)
return -EINVAL; return -EINVAL;
/* Disable irq request generation */ /* Disable irq request generation */
irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK;
omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask);
/* Disable DMA request generation */ /* Disable DMA request generation */
omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_DN_ENABLE); omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_DN_ENABLE);
/* clear Downlink channels */ /* clear Downlink channels */
mcpdm->dn_channels = 0; mcpdm->dn_channels = 0;
mcpdm->downlink = NULL; mcpdm->downlink = NULL;
return 0; return 0;
} }
static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id)
{ {
struct omap_mcpdm *mcpdm_irq = dev_id; struct omap_mcpdm *mcpdm_irq = dev_id;
int irq_status; int irq_status;
irq_status = omap_mcpdm_read(MCPDM_IRQSTATUS); irq_status = omap_mcpdm_read(MCPDM_IRQSTATUS);
/* Acknowledge irq event */ /* Acknowledge irq event */
omap_mcpdm_write(MCPDM_IRQSTATUS, irq_status); omap_mcpdm_write(MCPDM_IRQSTATUS, irq_status);
if (irq & MCPDM_DN_IRQ_FULL) { if (irq & MCPDM_DN_IRQ_FULL) {
dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status);
omap_mcpdm_reset_playback(1); omap_mcpdm_reset_playback(1);
omap_mcpdm_playback_open(mcpdm_irq->downlink); omap_mcpdm_playback_open(mcpdm_irq->downlink);
omap_mcpdm_reset_playback(0); omap_mcpdm_reset_playback(0);
} }
if (irq & MCPDM_DN_IRQ_EMPTY) { if (irq & MCPDM_DN_IRQ_EMPTY) {
dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status);
omap_mcpdm_reset_playback(1); omap_mcpdm_reset_playback(1);
omap_mcpdm_playback_open(mcpdm_irq->downlink); omap_mcpdm_playback_open(mcpdm_irq->downlink);
omap_mcpdm_reset_playback(0); omap_mcpdm_reset_playback(0);
} }
if (irq & MCPDM_DN_IRQ) { if (irq & MCPDM_DN_IRQ) {
dev_dbg(mcpdm_irq->dev, "DN write request\n"); dev_dbg(mcpdm_irq->dev, "DN write request\n");
} }
if (irq & MCPDM_UP_IRQ_FULL) { if (irq & MCPDM_UP_IRQ_FULL) {
dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status);
omap_mcpdm_reset_capture(1); omap_mcpdm_reset_capture(1);
omap_mcpdm_capture_open(mcpdm_irq->uplink); omap_mcpdm_capture_open(mcpdm_irq->uplink);
omap_mcpdm_reset_capture(0); omap_mcpdm_reset_capture(0);
} }
if (irq & MCPDM_UP_IRQ_EMPTY) { if (irq & MCPDM_UP_IRQ_EMPTY) {
dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status);
omap_mcpdm_reset_capture(1); omap_mcpdm_reset_capture(1);
omap_mcpdm_capture_open(mcpdm_irq->uplink); omap_mcpdm_capture_open(mcpdm_irq->uplink);
omap_mcpdm_reset_capture(0); omap_mcpdm_reset_capture(0);
} }
if (irq & MCPDM_UP_IRQ) { if (irq & MCPDM_UP_IRQ) {
dev_dbg(mcpdm_irq->dev, "UP write request\n"); dev_dbg(mcpdm_irq->dev, "UP write request\n");
} }
return IRQ_HANDLED; return IRQ_HANDLED;
} }
int omap_mcpdm_request(void) int omap_mcpdm_request(void)
{ {
int ret; int ret;
clk_enable(mcpdm->clk); clk_enable(mcpdm->clk);
spin_lock(&mcpdm->lock); spin_lock(&mcpdm->lock);
if (!mcpdm->free) { if (!mcpdm->free) {
dev_err(mcpdm->dev, "McPDM interface is in use\n"); dev_err(mcpdm->dev, "McPDM interface is in use\n");
spin_unlock(&mcpdm->lock); spin_unlock(&mcpdm->lock);
ret = -EBUSY; ret = -EBUSY;
goto err; goto err;
} }
mcpdm->free = 0; mcpdm->free = 0;
spin_unlock(&mcpdm->lock); spin_unlock(&mcpdm->lock);
/* Disable lines while request is ongoing */ /* Disable lines while request is ongoing */
omap_mcpdm_write(MCPDM_CTRL, 0x00); omap_mcpdm_write(MCPDM_CTRL, 0x00);
ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler,
0, "McPDM", (void *)mcpdm); 0, "McPDM", (void *)mcpdm);
if (ret) { if (ret) {
dev_err(mcpdm->dev, "Request for McPDM IRQ failed\n"); dev_err(mcpdm->dev, "Request for McPDM IRQ failed\n");
goto err; goto err;
} }
return 0; return 0;
err: err:
clk_disable(mcpdm->clk); clk_disable(mcpdm->clk);
return ret; return ret;
} }
void omap_mcpdm_free(void) void omap_mcpdm_free(void)
{ {
spin_lock(&mcpdm->lock); spin_lock(&mcpdm->lock);
if (mcpdm->free) { if (mcpdm->free) {
dev_err(mcpdm->dev, "McPDM interface is already free\n"); dev_err(mcpdm->dev, "McPDM interface is already free\n");
spin_unlock(&mcpdm->lock); spin_unlock(&mcpdm->lock);
return; return;
} }
mcpdm->free = 1; mcpdm->free = 1;
spin_unlock(&mcpdm->lock); spin_unlock(&mcpdm->lock);
clk_disable(mcpdm->clk); clk_disable(mcpdm->clk);
free_irq(mcpdm->irq, (void *)mcpdm); free_irq(mcpdm->irq, (void *)mcpdm);
} }
/* Enable/disable DC offset cancelation for the analog /* Enable/disable DC offset cancelation for the analog
...@@ -377,108 +377,108 @@ void omap_mcpdm_free(void) ...@@ -377,108 +377,108 @@ void omap_mcpdm_free(void)
*/ */
int omap_mcpdm_set_offset(int offset1, int offset2) int omap_mcpdm_set_offset(int offset1, int offset2)
{ {
int offset; int offset;
if ((offset1 > DN_OFST_MAX) || (offset2 > DN_OFST_MAX)) if ((offset1 > DN_OFST_MAX) || (offset2 > DN_OFST_MAX))
return -EINVAL; return -EINVAL;
offset = (offset1 << DN_OFST_RX1) | (offset2 << DN_OFST_RX2); offset = (offset1 << DN_OFST_RX1) | (offset2 << DN_OFST_RX2);
/* offset cancellation for channel 1 */ /* offset cancellation for channel 1 */
if (offset1) if (offset1)
offset |= DN_OFST_RX1_EN; offset |= DN_OFST_RX1_EN;
else else
offset &= ~DN_OFST_RX1_EN; offset &= ~DN_OFST_RX1_EN;
/* offset cancellation for channel 2 */ /* offset cancellation for channel 2 */
if (offset2) if (offset2)
offset |= DN_OFST_RX2_EN; offset |= DN_OFST_RX2_EN;
else else
offset &= ~DN_OFST_RX2_EN; offset &= ~DN_OFST_RX2_EN;
omap_mcpdm_write(MCPDM_DN_OFFSET, offset); omap_mcpdm_write(MCPDM_DN_OFFSET, offset);
return 0; return 0;
} }
static int __devinit omap_mcpdm_probe(struct platform_device *pdev) static int __devinit omap_mcpdm_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res;
int ret = 0; int ret = 0;
mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL); mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL);
if (!mcpdm) { if (!mcpdm) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "no resource\n"); dev_err(&pdev->dev, "no resource\n");
goto err_resource; goto err_resource;
} }
spin_lock_init(&mcpdm->lock); spin_lock_init(&mcpdm->lock);
mcpdm->free = 1; mcpdm->free = 1;
mcpdm->io_base = ioremap(res->start, resource_size(res)); mcpdm->io_base = ioremap(res->start, resource_size(res));
if (!mcpdm->io_base) { if (!mcpdm->io_base) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_resource; goto err_resource;
} }
mcpdm->irq = platform_get_irq(pdev, 0); mcpdm->irq = platform_get_irq(pdev, 0);
mcpdm->clk = clk_get(&pdev->dev, "pdm_ck"); mcpdm->clk = clk_get(&pdev->dev, "pdm_ck");
if (IS_ERR(mcpdm->clk)) { if (IS_ERR(mcpdm->clk)) {
ret = PTR_ERR(mcpdm->clk); ret = PTR_ERR(mcpdm->clk);
dev_err(&pdev->dev, "unable to get pdm_ck: %d\n", ret); dev_err(&pdev->dev, "unable to get pdm_ck: %d\n", ret);
goto err_clk; goto err_clk;
} }
mcpdm->dev = &pdev->dev; mcpdm->dev = &pdev->dev;
platform_set_drvdata(pdev, mcpdm); platform_set_drvdata(pdev, mcpdm);
return 0; return 0;
err_clk: err_clk:
iounmap(mcpdm->io_base); iounmap(mcpdm->io_base);
err_resource: err_resource:
kfree(mcpdm); kfree(mcpdm);
exit: exit:
return ret; return ret;
} }
static int __devexit omap_mcpdm_remove(struct platform_device *pdev) static int __devexit omap_mcpdm_remove(struct platform_device *pdev)
{ {
struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev); struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
clk_put(mcpdm_ptr->clk); clk_put(mcpdm_ptr->clk);
iounmap(mcpdm_ptr->io_base); iounmap(mcpdm_ptr->io_base);
mcpdm_ptr->clk = NULL; mcpdm_ptr->clk = NULL;
mcpdm_ptr->free = 0; mcpdm_ptr->free = 0;
mcpdm_ptr->dev = NULL; mcpdm_ptr->dev = NULL;
kfree(mcpdm_ptr); kfree(mcpdm_ptr);
return 0; return 0;
} }
static struct platform_driver omap_mcpdm_driver = { static struct platform_driver omap_mcpdm_driver = {
.probe = omap_mcpdm_probe, .probe = omap_mcpdm_probe,
.remove = __devexit_p(omap_mcpdm_remove), .remove = __devexit_p(omap_mcpdm_remove),
.driver = { .driver = {
.name = "omap-mcpdm", .name = "omap-mcpdm",
}, },
}; };
static struct platform_device *omap_mcpdm_device; static struct platform_device *omap_mcpdm_device;
static int __init omap_mcpdm_init(void) static int __init omap_mcpdm_init(void)
{ {
return platform_driver_register(&omap_mcpdm_driver); return platform_driver_register(&omap_mcpdm_driver);
} }
arch_initcall(omap_mcpdm_init); arch_initcall(omap_mcpdm_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment