cregit-Linux how code gets into the kernel

Release 4.7 sound/soc/omap/mcbsp.c

Directory: sound/soc/omap
/*
 * sound/soc/omap/mcbsp.c
 *
 * Copyright (C) 2004 Nokia Corporation
 * Author: Samuel Ortiz <samuel.ortiz@nokia.com>
 *
 * Contact: Jarkko Nikula <jarkko.nikula@bitmer.com>
 *          Peter Ujfalusi <peter.ujfalusi@ti.com>
 *
 * 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/device.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>

#include <linux/platform_data/asoc-ti-mcbsp.h>

#include "mcbsp.h"


static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) { void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step; if (mcbsp->pdata->reg_size == 2) { ((u16 *)mcbsp->reg_cache)[reg] = (u16)val; writew_relaxed((u16)val, addr); } else { ((u32 *)mcbsp->reg_cache)[reg] = val; writel_relaxed(val, addr); } }

Contributors

PersonTokensPropCommitsCommitProp
janusz krzysztofikjanusz krzysztofik4747.47%233.33%
chandra shekharchandra shekhar2828.28%116.67%
jarkko nikulajarkko nikula2121.21%116.67%
victor kamenskyvictor kamensky22.02%116.67%
manjunath kondaiah gmanjunath kondaiah g11.01%116.67%
Total99100.00%6100.00%


static int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache) { void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step; if (mcbsp->pdata->reg_size == 2) { return !from_cache ? readw_relaxed(addr) : ((u16 *)mcbsp->reg_cache)[reg]; } else { return !from_cache ? readl_relaxed(addr) : ((u32 *)mcbsp->reg_cache)[reg]; } }

Contributors

PersonTokensPropCommitsCommitProp
janusz krzysztofikjanusz krzysztofik5255.91%233.33%
chandra shekharchandra shekhar2021.51%116.67%
jarkko nikulajarkko nikula1819.35%116.67%
victor kamenskyvictor kamensky22.15%116.67%
manjunath kondaiah gmanjunath kondaiah g11.08%116.67%
Total93100.00%6100.00%


static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) { writel_relaxed(val, mcbsp->st_data->io_base_st + reg); }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala2893.33%133.33%
manjunath kondaiah gmanjunath kondaiah g13.33%133.33%
victor kamenskyvictor kamensky13.33%133.33%
Total30100.00%3100.00%


static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg) { return readl_relaxed(mcbsp->st_data->io_base_st + reg); }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala2492.31%133.33%
manjunath kondaiah gmanjunath kondaiah g13.85%133.33%
victor kamenskyvictor kamensky13.85%133.33%
Total26100.00%3100.00%

#define MCBSP_READ(mcbsp, reg) \ omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 0) #define MCBSP_WRITE(mcbsp, reg, val) \ omap_mcbsp_write(mcbsp, OMAP_MCBSP_REG_##reg, val) #define MCBSP_READ_CACHE(mcbsp, reg) \ omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 1) #define MCBSP_ST_READ(mcbsp, reg) \ omap_mcbsp_st_read(mcbsp, OMAP_ST_REG_##reg) #define MCBSP_ST_WRITE(mcbsp, reg, val) \ omap_mcbsp_st_write(mcbsp, OMAP_ST_REG_##reg, val)
static void omap_mcbsp_dump_reg(struct omap_mcbsp *mcbsp) { dev_dbg(mcbsp->dev, "**** McBSP%d regs ****\n", mcbsp->id); dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n", MCBSP_READ(mcbsp, DRR2)); dev_dbg(mcbsp->dev, "DRR1: 0x%04x\n", MCBSP_READ(mcbsp, DRR1)); dev_dbg(mcbsp->dev, "DXR2: 0x%04x\n", MCBSP_READ(mcbsp, DXR2)); dev_dbg(mcbsp->dev, "DXR1: 0x%04x\n", MCBSP_READ(mcbsp, DXR1)); dev_dbg(mcbsp->dev, "SPCR2: 0x%04x\n", MCBSP_READ(mcbsp, SPCR2)); dev_dbg(mcbsp->dev, "SPCR1: 0x%04x\n", MCBSP_READ(mcbsp, SPCR1)); dev_dbg(mcbsp->dev, "RCR2: 0x%04x\n", MCBSP_READ(mcbsp, RCR2)); dev_dbg(mcbsp->dev, "RCR1: 0x%04x\n", MCBSP_READ(mcbsp, RCR1)); dev_dbg(mcbsp->dev, "XCR2: 0x%04x\n", MCBSP_READ(mcbsp, XCR2)); dev_dbg(mcbsp->dev, "XCR1: 0x%04x\n", MCBSP_READ(mcbsp, XCR1)); dev_dbg(mcbsp->dev, "SRGR2: 0x%04x\n", MCBSP_READ(mcbsp, SRGR2)); dev_dbg(mcbsp->dev, "SRGR1: 0x%04x\n", MCBSP_READ(mcbsp, SRGR1)); dev_dbg(mcbsp->dev, "PCR0: 0x%04x\n", MCBSP_READ(mcbsp, PCR0)); dev_dbg(mcbsp->dev, "***********************\n"); }

Contributors

PersonTokensPropCommitsCommitProp
tony lindgrentony lindgren14560.17%120.00%
eduardo valentineduardo valentin6125.31%120.00%
chandra shekharchandra shekhar208.30%120.00%
janusz krzysztofikjanusz krzysztofik135.39%120.00%
peter ujfalusipeter ujfalusi20.83%120.00%
Total241100.00%5100.00%


static irqreturn_t omap_mcbsp_irq_handler(int irq, void *dev_id) { struct omap_mcbsp *mcbsp = dev_id; u16 irqst; irqst = MCBSP_READ(mcbsp, IRQST); dev_dbg(mcbsp->dev, "IRQ callback : 0x%x\n", irqst); if (irqst & RSYNCERREN) dev_err(mcbsp->dev, "RX Frame Sync Error!\n"); if (irqst & RFSREN) dev_dbg(mcbsp->dev, "RX Frame Sync\n"); if (irqst & REOFEN) dev_dbg(mcbsp->dev, "RX End Of Frame\n"); if (irqst & RRDYEN) dev_dbg(mcbsp->dev, "RX Buffer Threshold Reached\n"); if (irqst & RUNDFLEN) dev_err(mcbsp->dev, "RX Buffer Underflow!\n"); if (irqst & ROVFLEN) dev_err(mcbsp->dev, "RX Buffer Overflow!\n"); if (irqst & XSYNCERREN) dev_err(mcbsp->dev, "TX Frame Sync Error!\n"); if (irqst & XFSXEN) dev_dbg(mcbsp->dev, "TX Frame Sync\n"); if (irqst & XEOFEN) dev_dbg(mcbsp->dev, "TX End Of Frame\n"); if (irqst & XRDYEN) dev_dbg(mcbsp->dev, "TX Buffer threshold Reached\n"); if (irqst & XUNDFLEN) dev_err(mcbsp->dev, "TX Buffer Underflow!\n"); if (irqst & XOVFLEN) dev_err(mcbsp->dev, "TX Buffer Overflow!\n"); if (irqst & XEMPTYEOFEN) dev_dbg(mcbsp->dev, "TX Buffer empty at end of frame\n"); MCBSP_WRITE(mcbsp, IRQST, irqst); return IRQ_HANDLED; }

Contributors

PersonTokensPropCommitsCommitProp
peter ujfalusipeter ujfalusi250100.00%1100.00%
Total250100.00%1100.00%


static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id) { struct omap_mcbsp *mcbsp_tx = dev_id; u16 irqst_spcr2; irqst_spcr2 = MCBSP_READ(mcbsp_tx, SPCR2); dev_dbg(mcbsp_tx->dev, "TX IRQ callback : 0x%x\n", irqst_spcr2); if (irqst_spcr2 & XSYNC_ERR) { dev_err(mcbsp_tx->dev, "TX Frame Sync Error! : 0x%x\n", irqst_spcr2); /* Writing zero to XSYNC_ERR clears the IRQ */ MCBSP_WRITE(mcbsp_tx, SPCR2, MCBSP_READ_CACHE(mcbsp_tx, SPCR2)); } return IRQ_HANDLED; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala3543.75%120.00%
tony lindgrentony lindgren3240.00%120.00%
janusz krzysztofikjanusz krzysztofik810.00%240.00%
eduardo valentineduardo valentin56.25%120.00%
Total80100.00%5100.00%


static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id) { struct omap_mcbsp *mcbsp_rx = dev_id; u16 irqst_spcr1; irqst_spcr1 = MCBSP_READ(mcbsp_rx, SPCR1); dev_dbg(mcbsp_rx->dev, "RX IRQ callback : 0x%x\n", irqst_spcr1); if (irqst_spcr1 & RSYNC_ERR) { dev_err(mcbsp_rx->dev, "RX Frame Sync Error! : 0x%x\n", irqst_spcr1); /* Writing zero to RSYNC_ERR clears the IRQ */ MCBSP_WRITE(mcbsp_rx, SPCR1, MCBSP_READ_CACHE(mcbsp_rx, SPCR1)); } return IRQ_HANDLED; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala3442.50%120.00%
tony lindgrentony lindgren3341.25%120.00%
janusz krzysztofikjanusz krzysztofik810.00%240.00%
eduardo valentineduardo valentin56.25%120.00%
Total80100.00%5100.00%

/* * 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(struct omap_mcbsp *mcbsp, const struct omap_mcbsp_reg_cfg *config) { dev_dbg(mcbsp->dev, "Configuring McBSP%d phys_base: 0x%08lx\n", mcbsp->id, mcbsp->phys_base); /* We write the given config */ MCBSP_WRITE(mcbsp, SPCR2, config->spcr2); MCBSP_WRITE(mcbsp, SPCR1, config->spcr1); MCBSP_WRITE(mcbsp, RCR2, config->rcr2); MCBSP_WRITE(mcbsp, RCR1, config->rcr1); MCBSP_WRITE(mcbsp, XCR2, config->xcr2); MCBSP_WRITE(mcbsp, XCR1, config->xcr1); MCBSP_WRITE(mcbsp, SRGR2, config->srgr2); MCBSP_WRITE(mcbsp, SRGR1, config->srgr1); MCBSP_WRITE(mcbsp, MCR2, config->mcr2); MCBSP_WRITE(mcbsp, MCR1, config->mcr1); MCBSP_WRITE(mcbsp, PCR0, config->pcr0); if (mcbsp->pdata->has_ccr) { MCBSP_WRITE(mcbsp, XCCR, config->xccr); MCBSP_WRITE(mcbsp, RCCR, config->rccr); } /* Enable wakeup behavior */ if (mcbsp->pdata->has_wakeup) MCBSP_WRITE(mcbsp, WAKEUPEN, XRDYEN | RRDYEN); /* Enable TX/RX sync error interrupts by default */ if (mcbsp->irq) MCBSP_WRITE(mcbsp, IRQEN, RSYNCERREN | XSYNCERREN); }

Contributors

PersonTokensPropCommitsCommitProp
tony lindgrentony lindgren13760.89%220.00%
peter ujfalusipeter ujfalusi4218.67%330.00%
janusz krzysztofikjanusz krzysztofik2611.56%110.00%
eduardo valentineduardo valentin94.00%110.00%
jarkko nikulajarkko nikula52.22%110.00%
russell kingrussell king31.33%110.00%
chandra shekharchandra shekhar31.33%110.00%
Total225100.00%10100.00%

/** * omap_mcbsp_dma_reg_params - returns the address of mcbsp data register * @id - mcbsp id * @stream - indicates the direction of data flow (rx or tx) * * Returns the address of mcbsp data transmit register or data receive register * to be used by DMA for transferring/receiving data based on the value of * @stream for the requested mcbsp given by @id */
static int omap_mcbsp_dma_reg_params(struct omap_mcbsp *mcbsp, unsigned int stream) { int data_reg; if (mcbsp->pdata->reg_size == 2) { if (stream) data_reg = OMAP_MCBSP_REG_DRR1; else data_reg = OMAP_MCBSP_REG_DXR1; } else { if (stream) data_reg = OMAP_MCBSP_REG_DRR; else data_reg = OMAP_MCBSP_REG_DXR; } return mcbsp->phys_dma_base + data_reg * mcbsp->pdata->reg_step; }

Contributors

PersonTokensPropCommitsCommitProp
kishon vijay abraham ikishon vijay abraham i4866.67%125.00%
jarkko nikulajarkko nikula1926.39%125.00%
peter ujfalusipeter ujfalusi56.94%250.00%
Total72100.00%4100.00%


static void omap_st_on(struct omap_mcbsp *mcbsp) { unsigned int w; if (mcbsp->pdata->enable_st_clock) mcbsp->pdata->enable_st_clock(mcbsp->id, 1); /* Disable Sidetone clock auto-gating for normal operation */ w = MCBSP_ST_READ(mcbsp, SYSCONFIG); MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w & ~(ST_AUTOIDLE)); /* Enable McBSP Sidetone */ w = MCBSP_READ(mcbsp, SSELCR); MCBSP_WRITE(mcbsp, SSELCR, w | SIDETONEEN); /* Enable Sidetone from Sidetone Core */ w = MCBSP_ST_READ(mcbsp, SSELCR); MCBSP_ST_WRITE(mcbsp, SSELCR, w | ST_SIDETONEEN); }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala3130.39%120.00%
eduardo valentineduardo valentin3029.41%120.00%
peter ujfalusipeter ujfalusi2423.53%120.00%
jarkko nikulajarkko nikula1413.73%120.00%
janusz krzysztofikjanusz krzysztofik32.94%120.00%
Total102100.00%5100.00%


static void omap_st_off(struct omap_mcbsp *mcbsp) { unsigned int w; w = MCBSP_ST_READ(mcbsp, SSELCR); MCBSP_ST_WRITE(mcbsp, SSELCR, w & ~(ST_SIDETONEEN)); w = MCBSP_READ(mcbsp, SSELCR); MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN)); /* Enable Sidetone clock auto-gating to reduce power consumption */ w = MCBSP_ST_READ(mcbsp, SYSCONFIG); MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w | ST_AUTOIDLE); if (mcbsp->pdata->enable_st_clock) mcbsp->pdata->enable_st_clock(mcbsp->id, 0); }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala4139.81%120.00%
peter ujfalusipeter ujfalusi3130.10%240.00%
eduardo valentineduardo valentin1716.50%120.00%
jarkko nikulajarkko nikula1413.59%120.00%
Total103100.00%5100.00%


static void omap_st_fir_write(struct omap_mcbsp *mcbsp, s16 *fir) { u16 val, i; val = MCBSP_ST_READ(mcbsp, SSELCR); if (val & ST_COEFFWREN) MCBSP_ST_WRITE(mcbsp, SSELCR, val & ~(ST_COEFFWREN)); MCBSP_ST_WRITE(mcbsp, SSELCR, val | ST_COEFFWREN); for (i = 0; i < 128; i++) MCBSP_ST_WRITE(mcbsp, SFIRCR, fir[i]); i = 0; val = MCBSP_ST_READ(mcbsp, SSELCR); while (!(val & ST_COEFFWRDONE) && (++i < 1000)) val = MCBSP_ST_READ(mcbsp, SSELCR); MCBSP_ST_WRITE(mcbsp, SSELCR, val & ~(ST_COEFFWREN)); if (i == 1000) dev_err(mcbsp->dev, "McBSP FIR load error!\n"); }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala14595.39%480.00%
eduardo valentineduardo valentin74.61%120.00%
Total152100.00%5100.00%


static void omap_st_chgain(struct omap_mcbsp *mcbsp) { u16 w; struct omap_mcbsp_st_data *st_data = mcbsp->st_data; w = MCBSP_ST_READ(mcbsp, SSELCR); MCBSP_ST_WRITE(mcbsp, SGAINCR, ST_CH0GAIN(st_data->ch0gain) | \ ST_CH1GAIN(st_data->ch1gain)); }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala54100.00%2100.00%
Total54100.00%2100.00%


int omap_st_set_chgain(struct omap_mcbsp *mcbsp, int channel, s16 chgain) { struct omap_mcbsp_st_data *st_data = mcbsp->st_data; int ret = 0; if (!st_data) return -ENOENT; spin_lock_irq(&mcbsp->lock); if (channel == 0) st_data->ch0gain = chgain; else if (channel == 1) st_data->ch1gain = chgain; else ret = -EINVAL; if (st_data->enabled) omap_st_chgain(mcbsp); spin_unlock_irq(&mcbsp->lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala6161.00%114.29%
tony lindgrentony lindgren2424.00%228.57%
peter ujfalusipeter ujfalusi88.00%228.57%
chandra shekharchandra shekhar55.00%114.29%
eduardo valentineduardo valentin22.00%114.29%
Total100100.00%7100.00%


int omap_st_get_chgain(struct omap_mcbsp *mcbsp, int channel, s16 *chgain) { struct omap_mcbsp_st_data *st_data = mcbsp->st_data; int ret = 0; if (!st_data) return -ENOENT; spin_lock_irq(&mcbsp->lock); if (channel == 0) *chgain = st_data->ch0gain; else if (channel == 1) *chgain = st_data->ch1gain; else ret = -EINVAL; spin_unlock_irq(&mcbsp->lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala4144.57%114.29%
tony lindgrentony lindgren2830.43%114.29%
peter ujfalusipeter ujfalusi1111.96%228.57%
chandra shekharchandra shekhar55.43%114.29%
janusz krzysztofikjanusz krzysztofik55.43%114.29%
eduardo valentineduardo valentin22.17%114.29%
Total92100.00%7100.00%


static int omap_st_start(struct omap_mcbsp *mcbsp) { struct omap_mcbsp_st_data *st_data = mcbsp->st_data; if (st_data->enabled && !st_data->running) { omap_st_fir_write(mcbsp, st_data->taps); omap_st_chgain(mcbsp); if (!mcbsp->free) { omap_st_on(mcbsp); st_data->running = 1; } } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala5375.71%250.00%
russell kingrussell king1622.86%125.00%
jarkko nikulajarkko nikula11.43%125.00%
Total70100.00%4100.00%


int omap_st_enable(struct omap_mcbsp *mcbsp) { struct omap_mcbsp_st_data *st_data = mcbsp->st_data; if (!st_data) return -ENODEV; spin_lock_irq(&mcbsp->lock); st_data->enabled = 1; omap_st_start(mcbsp); spin_unlock_irq(&mcbsp->lock); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala3051.72%114.29%
tony lindgrentony lindgren1729.31%114.29%
peter ujfalusipeter ujfalusi46.90%228.57%
janusz krzysztofikjanusz krzysztofik35.17%114.29%
chandra shekharchandra shekhar35.17%114.29%
eduardo valentineduardo valentin11.72%114.29%
Total58100.00%7100.00%


static int omap_st_stop(struct omap_mcbsp *mcbsp) { struct omap_mcbsp_st_data *st_data = mcbsp->st_data; if (st_data->running) { if (!mcbsp->free) { omap_st_off(mcbsp); st_data->running = 0; } } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala3364.71%125.00%
janusz krzysztofikjanusz krzysztofik1529.41%250.00%
tony lindgrentony lindgren35.88%125.00%
Total51100.00%4100.00%


int omap_st_disable(struct omap_mcbsp *mcbsp) { struct omap_mcbsp_st_data *st_data = mcbsp->st_data; int ret = 0; if (!st_data) return -ENODEV; spin_lock_irq(&mcbsp->lock); omap_st_stop(mcbsp); st_data->enabled = 0; spin_unlock_irq(&mcbsp->lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala3860.32%218.18%
chandra shekharchandra shekhar69.52%19.09%
peter ujfalusipeter ujfalusi69.52%218.18%
tony lindgrentony lindgren57.94%218.18%
russell kingrussell king34.76%19.09%
stanley miaostanley miao23.17%19.09%
janusz krzysztofikjanusz krzysztofik23.17%19.09%
eduardo valentineduardo valentin11.59%19.09%
Total63100.00%11100.00%


int omap_st_is_enabled(struct omap_mcbsp *mcbsp) { struct omap_mcbsp_st_data *st_data = mcbsp->st_data; if (!st_data) return -ENODEV; return st_data->enabled; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala2678.79%120.00%
peter ujfalusipeter ujfalusi412.12%240.00%
janusz krzysztofikjanusz krzysztofik26.06%120.00%
chandra shekharchandra shekhar13.03%120.00%
Total33100.00%5100.00%

/* * omap_mcbsp_set_rx_threshold configures the transmit threshold in words. * The threshold parameter is 1 based, and it is converted (threshold - 1) * for the THRSH2 register. */
void omap_mcbsp_set_tx_threshold(struct omap_mcbsp *mcbsp, u16 threshold) { if (mcbsp->pdata->buffer_size == 0) return; if (threshold && threshold <= mcbsp->max_tx_thres) MCBSP_WRITE(mcbsp, THRSH2, threshold - 1); }

Contributors

PersonTokensPropCommitsCommitProp
peter ujfalusipeter ujfalusi1635.56%233.33%
eero nurkkalaeero nurkkala1431.11%116.67%
jarkko nikulajarkko nikula1124.44%116.67%
janusz krzysztofikjanusz krzysztofik36.67%116.67%
tony lindgrentony lindgren12.22%116.67%
Total45100.00%6100.00%

/* * omap_mcbsp_set_rx_threshold configures the receive threshold in words. * The threshold parameter is 1 based, and it is converted (threshold - 1) * for the THRSH1 register. */
void omap_mcbsp_set_rx_threshold(struct omap_mcbsp *mcbsp, u16 threshold) { if (mcbsp->pdata->buffer_size == 0) return; if (threshold && threshold <= mcbsp->max_rx_thres) MCBSP_WRITE(mcbsp, THRSH1, threshold - 1); }

Contributors

PersonTokensPropCommitsCommitProp
peter ujfalusipeter ujfalusi1635.56%225.00%
jarkko nikulajarkko nikula1124.44%112.50%
tony lindgrentony lindgren613.33%112.50%
eero nurkkalaeero nurkkala613.33%112.50%
chandra shekharchandra shekhar48.89%112.50%
eduardo valentineduardo valentin12.22%112.50%
janusz krzysztofikjanusz krzysztofik12.22%112.50%
Total45100.00%8100.00%

/* * omap_mcbsp_get_tx_delay returns the number of used slots in the McBSP FIFO */
u16 omap_mcbsp_get_tx_delay(struct omap_mcbsp *mcbsp) { u16 buffstat; if (mcbsp->pdata->buffer_size == 0) return 0; /* Returns the number of free locations in the buffer */ buffstat = MCBSP_READ(mcbsp, XBUFFSTAT); /* Number of slots are different in McBSP ports */ return mcbsp->pdata->buffer_size - buffstat; }

Contributors

PersonTokensPropCommitsCommitProp
peter ujfalusipeter ujfalusi3371.74%375.00%
jarkko nikulajarkko nikula1328.26%125.00%
Total46100.00%4100.00%

/* * omap_mcbsp_get_rx_delay returns the number of free slots in the McBSP FIFO * to reach the threshold value (when the DMA will be triggered to read it) */
u16 omap_mcbsp_get_rx_delay(struct omap_mcbsp *mcbsp) { u16 buffstat, threshold; if (mcbsp->pdata->buffer_size == 0) return 0; /* Returns the number of used locations in the buffer */ buffstat = MCBSP_READ(mcbsp, RBUFFSTAT); /* RX threshold */ threshold = MCBSP_READ(mcbsp, THRSH1); /* Return the number of location till we reach the threshold limit */ if (threshold <= buffstat) return 0; else return threshold - buffstat; }

Contributors

PersonTokensPropCommitsCommitProp
peter ujfalusipeter ujfalusi5382.81%266.67%
jarkko nikulajarkko nikula1117.19%133.33%
Total64100.00%3100.00%


int omap_mcbsp_request(struct omap_mcbsp *mcbsp) { void *reg_cache; int err; reg_cache = kzalloc(mcbsp->reg_cache_size, GFP_KERNEL); if (!reg_cache) { return -ENOMEM; } spin_lock(&mcbsp->lock); if (!mcbsp->free) { dev_err(mcbsp->dev, "McBSP%d is currently in use\n", mcbsp->id); err = -EBUSY; goto err_kfree; } mcbsp->free = false; mcbsp->reg_cache = reg_cache; spin_unlock(&mcbsp->lock); if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) mcbsp->pdata->ops->request(mcbsp->id - 1); /* * Make sure that transmitter, receiver and sample-rate generator are * not running before activating IRQs. */ MCBSP_WRITE(mcbsp, SPCR1, 0); MCBSP_WRITE(mcbsp, SPCR2, 0); if (mcbsp->irq) { err = request_irq(mcbsp->irq, omap_mcbsp_irq_handler, 0, "McBSP", (void *)mcbsp); if (err != 0) { dev_err(mcbsp->dev, "Unable to request IRQ\n"); goto err_clk_disable; } } else { err = request_irq(mcbsp->tx_irq, omap_mcbsp_tx_irq_handler, 0, "McBSP TX", (void *)mcbsp); if (err != 0) { dev_err(mcbsp->dev, "Unable to request TX IRQ\n"); goto err_clk_disable; } err = request_irq(mcbsp->rx_irq, omap_mcbsp_rx_irq_handler, 0, "McBSP RX", (void *)mcbsp); if (err != 0) { dev_err(mcbsp->dev, "Unable to request RX IRQ\n"); goto err_free_irq; } } return 0; err_free_irq: free_irq(mcbsp->tx_irq, (void *)mcbsp); err_clk_disable: if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) mcbsp->pdata->ops->free(mcbsp->id - 1); /* Disable wakeup behavior */ if (mcbsp->pdata->has_wakeup) MCBSP_WRITE(mcbsp, WAKEUPEN, 0); spin_lock(&mcbsp->lock); mcbsp->free = true; mcbsp->reg_cache = NULL; err_kfree: spin_unlock(&mcbsp->lock); kfree(reg_cache); return err; }

Contributors

PersonTokensPropCommitsCommitProp
eero nurkkalaeero nurkkala23659.60%17.69%
peter ujfalusipeter ujfalusi5914.90%215.38%
tony lindgrentony lindgren4411.11%215.38%
jarkko nikulajarkko nikula174.29%215.38%
eduardo valentineduardo valentin164.04%215.38%
chandra shekharchandra shekhar112.78%17.69%
janusz krzysztofikjanusz krzysztofik112.78%215.38%
shubhrajyoti dattashubhrajyoti datta20.51%17.69%
Total396100.00%13100.00%


void omap_mcbsp_free(struct omap_mcbsp *mcbsp) { void *reg_cache; if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops