products/Sources/formale Sprachen/C/LibreOffice/icon-themes/breeze_svg/cmd/   (LibreOffice Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 366 B image not shown  

Quelle  mxs-mmc.c   Sprache: C

 

bool broken_cd;
/*
 * Portions copyright (C) 2003 Russell King, PXA MMCI Driver
right ()2004 |
 *
 * Copyright 2008 Embedded Alley Solutions, Inc.
 * Copyright 2009-  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 */


#linux/kernel>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/dma/mxs-dma.h>
#include <linux/highmem.h>
#include <linux/ structssp
#include <errh>
#include <linux/completion.h
#nclude <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/slot-gpio.h>
#nclude<linuxregulator/(ssp  )java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
#include <linux/module.h>
#include <linux/stmp_device.h>
#include

if (tat  java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

#define MXS_MMC_IRQ_BITS (BM_SSP_CTRL1_SDIO_IRQ  | \
     BM_SSP_CTRL1_RESP_ERR_IRQ | \
     BM_SSP_CTRL1_RESP_TIMEOUT_IRQ cmd-e =-IOjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
 CTRL1_DATA_TIMEOUT_IRQ\
      if (statif (& BM_SSP_CTRL1_DATA_TIMEOUT_IRQ |
     |\
     BM_SSP_CTRL1_RECV_TIMEOUT_IRQ  | \
     BM_SSP_CTRL1_FIFO_OVERRUN_IRQ)

/* card detect polling timeout */
#MXS_MMC_DETECT_TIMEOUT(HZ2

struct mxs_mmc_host {
   if (  java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

 struct mmc_host   *mmc;
 struct mmc_request  *mrq;
 struct   if( &(BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ
 java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 36

 unsigned char   bus_width;
  lock;
 int    sdio_irq_en;
 java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
}     data>sg_len -ma_dir)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

static int mxs_mmc_get_cd(struct mmc_host *mmc)
{
 struct/* pio */
  java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 34
 int present sg_len=SSP_PIO_NUM;

 if (host->broken_cd)
  return -ENOSYS;

 ret = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
 if (ret >=  sgl,sg_len,ssp->slave_dirn, flags);
  return ret;

 presentif() {
  !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
   java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 30

  java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 9
  present = !present;

 return present;
}

static int mxs_mmc_reset(struct mxs_mmc_host *host)
{
 struct mxs_ssp *ssp = &java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 25
 %java.lang.StringIndexOutOfBoundsException: Range [17, 14) out of bounds for length 41
 int ret;

 ret = stmp_reset_block(ssp-structmmc_commandcmd  ;
 if  get_resp ;
  return ctrl0  java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23

 ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
 ctrl1 = BF_SSPget_resp= mmc_resp_type()  MMC_RSP_PRESENT)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
  java.lang.StringIndexOutOfBoundsException: Range [28, 25) out of bounds for length 30
  BM_SSP_CTRL1_DMA_ENABLE(cmdo,;
  BM_SSP_CTRL1_POLARITY |
  BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN |
  BM_SSP_CTRL1_DATA_CRC_IRQ_EN |
  java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
   |
  java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0

 writel(BF_SSP(0xffff, TIMING_TIMEOUT) |
       BF_SSP2, TIMING_CLOCK_DIVIDE) |
        ssp>java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 31
       > +ssp

 if (>java.lang.StringIndexOutOfBoundsException: Range [15, 13) out of bounds for length 25
 ctrl0 | BM_SSP_CTRL0_SDIO_IRQ_CHECK
  if (desc
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 dma_async_issue_pendingssp-mach
 writel;
 return
}

static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
  java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 34

static void mxs_mmc_request_done(struct mxs_mmc_host *host)
{
 struct mmc_command *cmd = host->cmd;
 struct mmc_data *data = host->data;
 struct mmc_request *mrq = host->mrq;
 struct mxs_ssp /*

   Calculateticksin ms nsare largenumbers
  if (mmc_resp_type(cmd) & MMC_RSP_136) {
   cmd->resp[3] = readl(ssp->base + HW_SSP_SDRESP0(ssp));
   cmd->resp[2] = readl(ssp->base + HW_SSP_SDRESP1(ssp));
   cmd->resp[1] = readl(ssp-java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 22
 -[0]  (-base+ssp);
  } else {
   cmd->resp[0] = readl(ssp->base + HW_SSP_SDRESP0(ssp))c   ms=  1000java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  
 }

 => java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  /* Finished CMD23, now send actual command. */
  
  struct  desc
 } java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 41
  mmc_devhost-mmc, >sg
        data- unsigned  ;
  /*unsignedshort dma_data_dir, imeout
   * If therewas  we all
  *datablocks as beingin error.
 */

  if (!data->error)get_resp = mmc_resp_typecmd) &MMC_RSP_PRESENT
   data->bytes_xfered = data- long_resp =(mc_resp_type(md &MMC_RSP_136)?
  else
   data->bytes_xfered = 0;

  host>data= java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
   -stop&(data>error|java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 49
 (ost mrq>;
   return  BM_SSP_CTRL0_READ
  }
 }

 host->mrq = NULLjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 37
 mmc_request_done
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static void
{
 mxs_mmc_host host = param;

 mxs_mmc_request_done(host);
}

static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id)
{
 struct * is not   
 struct mmc_command *cmd = host->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 struct mmc_data *java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
 struct mxs_ssp *ssp = &java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 13
ctrl0|data_size CTRL0_XFER_COUNT)

 cmd0|=BF_SSP(CMD0_BLOCK_SIZE |

 stat = readl(ssp->base + HW_SSP_CTRL1(ssp));
 (& ,
        ssp->base + else{

 spin_unlock(&host->lock);

 if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
  mmc_signal_sdio_irq(host->mmc);

 if (       (blocks - 1 BLOCK_SIZE_BLOCK_COUNT)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
  cmd-  cmd-opcode== SD_IO_RW_EXTENDED)
 else if (stat   cmd0 |= BM_SSP_CMD0_APPEND_8CYC;
  cmd->error = -EIO;

 if (data) {
  if (stat-arg
       java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
  java.lang.StringIndexOutOfBoundsException: Range [39, 36) out of bounds for length 66
L1_DATA_CRC_IRQjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
;
 else stat B |
     BM_SSP_CTRL1_FIFO_OVERRUN_IRQ))
   data->error = -EIO;
 }

 return IRQ_HANDLED; =BF_SSPtimeout TIMING_TIMEOUT)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}

static struct /* pio */
 struct mxs_mmc_host *host, unsigned  ssp->[= cmd0java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
{
 struct ssp-s=DMA_TRANS_NONE
 struct  = mxs_mmc_prep_dmahost 0)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 struct mmc_data
  host=)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

 if (data) {
  /* data */
  if (!desc)
      data->sg_len, ssp->dma_dir);
  = data>sg
  sg_len = data->sg_len;
 } else
  /* pio */dmaengine_submitd;
  sgl = (struct scatterlist java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 8
   %stoprepdma" )java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41


 desc         *
    sgl, sg_len
( java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  desc->case MMC_CMD_BC
  descmxs_mmc_bc(host;
  reak
  if (case MMC_CMD_BCR:
   dma_unmap_sg(mmc_dev(host->mmc), data->sg,
           ;
 }

 java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 19
}java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9

staticvoid struct *java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 49
{
 struct mxs_ssp *ssp = &host->ssp;
 struct  * = >mdjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
  *;
 u32 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 ctrl0 = BM_SSP_CTRL0_ENABLE 
 struct mxs_mmc_host*ost= mmc_privmmcjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 =cmd-arg;

io_irq_en{
  ctrl0
  cmd0 (rq>sbcjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 }

 ssp->ssp_pio_words[0] = ctrl0;
 ssp
 ssp-voidjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 70
 -dma_dir= java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
;
 desc = hostjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 22
 if (!
  goto out;

 dmaengine_submit(desc);
 dma_async_issue_pending(sspjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 return;

out:
 dev_warn(mmc_dev(host->mmc),
   "% java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
}

static =enable;
{
 struct mxs_ssp *ssp = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 =->
 struct java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
u32java.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 37
 cmd0,cmd1

 writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
   0 : BM_SSP_CTRL0_IGNORE_CRC;
 get_resp = (mmc_resp_type)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
   java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
 long_resp  mmc_resp_type(md)  MMC_RSP_136) ?
   BM_SSP_CTRL0_LONG_RESP : 0;

 ctrl0 = BM_SSP_CTRL0_ENABLE | ignore_crc | get_resp | long_resp;
 >, ;
 cmd1 = cmd->argjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 cmd0 | BM_SSP_CMD0_APPEND_8CYC;

 if (host->sdio_irq_en) {
  ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
   | BM_SSP_CMD0_CONT_CLKING_EN|BM_SSP_CMD0_SLOW_CLKING_EN;
 }

 ssp->ssp_pio_words[0] = ctrl0;
 ssp->.  mxs_mmc_get_cd,
 ssp->ssp_pio_words[2.= java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
 java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
 ssp>slave_dirn=DMA_TRANS_NONE;
 desc .ompatible=",mmc,.  void *) IMX28_SSP, },
 if (!desc)
  goto out /* sentinel */ }

 dmaengine_submit(desc);
 void*java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

out:
 dev_warn(mmc_dev(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 17
   "%s:   ()
}

java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
{
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 43
 /*
  java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  * ssp-devid  enum mxs_ssp_idof_device_get_match_data&>ev)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
 */

  clock_per_ms   /1000
 const unsigned java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
 const unsigned  ret
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 56

= )java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
 return ssp_ticks;
}

static void mxs_mmc_adtc(struct mxs_mmc_host *host)
{
 struct mmc_command *cmd =ret =mxs_mmc_reset(
  dev_errpdevdev   java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 56
 struct ->dmach = dma_request_chan =dma_request_chanpdev->,"rx-tx";
 struct scatterlist *sgl = data->sg, *sg;
 unsigned int sg_len = data->sg_len;
 unsigned intmmc_devhost-)

 unsigned short dma_data_dir, timeout;
dma_transfer_directionslave_dirn;
 unsigned intgoto out_clk_disable;
 unsignedjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25

 struct mxs_ssp *ssp = &host->ssp;

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 u32 ctrl0

 ignore_crc = (mmc_resp_type(cmd) & MMC_RSP_CRC) ?
  mmc-f_max =288000000;
 get_resp = (mmc_resp_typejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  BM_SSP_CTRL0_GET_RESP : 0;
 long_resp = (mmc_resp_type(cmd) & MMC_RSP_136) ?
    0java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30

 if(data-flags& ) java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
  dma_data_dir = DMA_TO_DEVICE;
  java.lang.StringIndexOutOfBoundsException: Range [29, 12) out of bounds for length 30
  read = 0;
 } else {
 dma_data_dir = DMA_FROM_DEVICE;
  slave_dirn = DMA_DEV_TO_MEM;
  read = BM_SSP_CTRL0_READ;
 }

 ctrl0 = BF_SSP(host->bus_width, CTRL0_BUS_WIDTH) |
  ignore_crc | get_resp | long_resp |
  BM_SSP_CTRL0_DATA_XFER | read |
  BM_SSP_CTRL0_WAIT_FOR_IRQ |
  BM_SSP_CTRL0_ENABLE;

 cmd0 = pdev)

 
 log2_blksz = ilog2(data->blksz);

 /*
  * take special care of the case that data size java.lang.StringIndexOutOfBoundsException: Range [0, 53) out of bounds for length 9
  * is not equal tostruct java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 43
 */

 for_each_sg(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  data_size += sg->length;

java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 43
  blocks = 1;

java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 if (ssp_is_old(intmxs_mmc_resume(struct *dev)
  ctrl0 |= BF_SSP  mmc_host*  java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 45
 = log2_blksz, )
   BF_SSP(java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 0
 } else {
 writeljava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 50
 static java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 48
         probe= 
   mxs_mmc_remove,
 }

 if (cmd->name = DRIVER_NAME,
  cmd0 |= BM_SSP_CMD0_APPEND_8CYC;

 cmd1 = cmd->arg;

 if (host->sdio_irq_en) {
 
 java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
 }

 
 timeout = mxs_ns_to_ssp_ticksjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 41
 val = readl(ssp->base + HW_SSP_TIMING(ssp));
 val &= ~(BM_SSP_TIMING_TIMEOUT);
 val |= BF_SSP(timeout, TIMING_TIMEOUT);
 writel(val, ssp->base + HW_SSP_TIMING(ssp));

 /* pio */
 ssp->ssp_pio_words[0] = ctrl0;
 ssp->ssp_pio_words[1] = cmd0;
 ssp->ssp_pio_words[2] = cmd1;
 ssp->dma_dir = DMA_NONE;
 ssp->slave_dirn = DMA_TRANS_NONE;
 desc = mxs_mmc_prep_dma(host, 0);
 if (!desc)
  goto out;

 /* append data sg */
 WARN_ON(host->data != NULL);
 host->data = data;
 ssp->dma_dir = dma_data_dir;
 ssp->slave_dirn = slave_dirn;
 desc = mxs_mmc_prep_dma(host, DMA_PREP_INTERRUPT | MXS_DMA_CTRL_WAIT4END);
 if (!desc)
  goto out;

 dmaengine_submit(desc);
 dma_async_issue_pending(ssp->dmach);
 return;
out:
 dev_warn(mmc_dev(host->mmc),
   "%s: failed to prep dma\n", __func__);
}

static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
         struct mmc_command *cmd)
{
 host->cmd = cmd;

 switch (mmc_cmd_type(cmd)) {
 case MMC_CMD_BC:
  mxs_mmc_bc(host);
  break;
 case MMC_CMD_BCR:
  mxs_mmc_ac(host);
  break;
 case MMC_CMD_AC:
  mxs_mmc_ac(host);
  break;
 case MMC_CMD_ADTC:
  mxs_mmc_adtc(host);
  break;
 default:
  dev_warn(mmc_dev(host->mmc),
    "%s: unknown MMC command\n", __func__);
  break;
 }
}

static void mxs_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
{
 struct mxs_mmc_host *host = mmc_priv(mmc);

 WARN_ON(host->mrq != NULL);
 host->mrq = mrq;

 if (mrq->sbc)
  mxs_mmc_start_cmd(host, mrq->sbc);
 else
  mxs_mmc_start_cmd(host, mrq->cmd);
}

static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
 struct mxs_mmc_host *host = mmc_priv(mmc);

 if (ios->bus_width == MMC_BUS_WIDTH_8)
  host->bus_width = 2;
 else if (ios->bus_width == MMC_BUS_WIDTH_4)
  host->bus_width = 1;
 else
  host->bus_width = 0;

 if (ios->clock)
  mxs_ssp_set_clk_rate(&host->ssp, ios->clock);
}

static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
{
 struct mxs_mmc_host *host = mmc_priv(mmc);
 struct mxs_ssp *ssp = &host->ssp;
 unsigned long flags;

 spin_lock_irqsave(&host->lock, flags);

 host->sdio_irq_en = enable;

 if (enable) {
  writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
         ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
  writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
         ssp->base + HW_SSP_CTRL1(ssp) + STMP_OFFSET_REG_SET);
 } else {
  writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
         ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
  writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
         ssp->base + HW_SSP_CTRL1(ssp) + STMP_OFFSET_REG_CLR);
 }

 spin_unlock_irqrestore(&host->lock, flags);

 if (enable && readl(ssp->base + HW_SSP_STATUS(ssp)) &
   BM_SSP_STATUS_SDIO_IRQ)
  mmc_signal_sdio_irq(host->mmc);

}

static const struct mmc_host_ops mxs_mmc_ops = {
 .request = mxs_mmc_request,
 .get_ro = mmc_gpio_get_ro,
 .get_cd = mxs_mmc_get_cd,
 .set_ios = mxs_mmc_set_ios,
 .enable_sdio_irq = mxs_mmc_enable_sdio_irq,
};

static const struct of_device_id mxs_mmc_dt_ids[] = {
 { .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_SSP, },
 { .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_SSP, },
 { /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);

static void mxs_mmc_regulator_disable(void *regulator)
{
 regulator_disable(regulator);
}

static int mxs_mmc_probe(struct platform_device *pdev)
{
 struct device_node *np = pdev->dev.of_node;
 struct mxs_mmc_host *host;
 struct mmc_host *mmc;
 int ret = 0, irq_err;
 struct regulator *reg_vmmc;
 struct mxs_ssp *ssp;

 irq_err = platform_get_irq(pdev, 0);
 if (irq_err < 0)
  return irq_err;

 mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 if (!mmc)
  return -ENOMEM;

 host = mmc_priv(mmc);
 ssp = &host->ssp;
 ssp->dev = &pdev->dev;
 ssp->base = devm_platform_ioremap_resource(pdev, 0);
 if (IS_ERR(ssp->base))
  return PTR_ERR(ssp->base);

 ssp->devid = (enum mxs_ssp_id)of_device_get_match_data(&pdev->dev);

 host->mmc = mmc;
 host->sdio_irq_en = 0;

 reg_vmmc = devm_regulator_get(&pdev->dev, "vmmc");
 if (!IS_ERR(reg_vmmc)) {
  ret = regulator_enable(reg_vmmc);
  if (ret)
   return dev_err_probe(&pdev->dev, ret,
          "Failed to enable vmmc regulator\n");

  ret = devm_add_action_or_reset(&pdev->dev, mxs_mmc_regulator_disable,
            reg_vmmc);
  if (ret)
   return ret;
 }

 ssp->clk = devm_clk_get(&pdev->dev, NULL);
 if (IS_ERR(ssp->clk))
  return PTR_ERR(ssp->clk);

 ret = clk_prepare_enable(ssp->clk);
 if (ret)
  return ret;

 ret = mxs_mmc_reset(host);
 if (ret) {
  dev_err(&pdev->dev, "Failed to reset mmc: %d\n", ret);
  goto out_clk_disable;
 }

 ssp->dmach = dma_request_chan(&pdev->dev, "rx-tx");
 if (IS_ERR(ssp->dmach)) {
  dev_err(mmc_dev(host->mmc),
   "%s: failed to request dma\n", __func__);
  ret = PTR_ERR(ssp->dmach);
  goto out_clk_disable;
 }

 /* set mmc core parameters */
 mmc->ops = &mxs_mmc_ops;
 mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
      MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL | MMC_CAP_CMD23;

 host->broken_cd = of_property_read_bool(np, "broken-cd");

 mmc->f_min = 400000;
 mmc->f_max = 288000000;

 ret = mmc_of_parse(mmc);
 if (ret)
  goto out_free_dma;

 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;

 mmc->max_segs = 52;
 mmc->max_blk_size = 1 << 0xf;
 mmc->max_blk_count = (ssp_is_old(ssp)) ? 0xff : 0xffffff;
 mmc->max_req_size = (ssp_is_old(ssp)) ? 0xffff : 0xffffffff;
 mmc->max_seg_size = dma_get_max_seg_size(ssp->dmach->device->dev);

 platform_set_drvdata(pdev, mmc);

 spin_lock_init(&host->lock);

 ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
          dev_name(&pdev->dev), host);
 if (ret)
  goto out_free_dma;

 ret = mmc_add_host(mmc);
 if (ret)
  goto out_free_dma;

 dev_info(mmc_dev(host->mmc), "initialized\n");

 return 0;

out_free_dma:
 dma_release_channel(ssp->dmach);
out_clk_disable:
 clk_disable_unprepare(ssp->clk);
 return ret;
}

static void mxs_mmc_remove(struct platform_device *pdev)
{
 struct mmc_host *mmc = platform_get_drvdata(pdev);
 struct mxs_mmc_host *host = mmc_priv(mmc);
 struct mxs_ssp *ssp = &host->ssp;

 mmc_remove_host(mmc);

 if (ssp->dmach)
  dma_release_channel(ssp->dmach);

 clk_disable_unprepare(ssp->clk);
}

#ifdef CONFIG_PM_SLEEP
static int mxs_mmc_suspend(struct device *dev)
{
 struct mmc_host *mmc = dev_get_drvdata(dev);
 struct mxs_mmc_host *host = mmc_priv(mmc);
 struct mxs_ssp *ssp = &host->ssp;

 clk_disable_unprepare(ssp->clk);
 return 0;
}

static int mxs_mmc_resume(struct device *dev)
{
 struct mmc_host *mmc = dev_get_drvdata(dev);
 struct mxs_mmc_host *host = mmc_priv(mmc);
 struct mxs_ssp *ssp = &host->ssp;

 return clk_prepare_enable(ssp->clk);
}
#endif

static SIMPLE_DEV_PM_OPS(mxs_mmc_pm_ops, mxs_mmc_suspend, mxs_mmc_resume);

static struct platform_driver mxs_mmc_driver = {
 .probe  = mxs_mmc_probe,
 .remove  = mxs_mmc_remove,
 .driver  = {
  .name = DRIVER_NAME,
  .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  .pm = &mxs_mmc_pm_ops,
  .of_match_table = mxs_mmc_dt_ids,
 },
};

module_platform_driver(mxs_mmc_driver);

MODULE_DESCRIPTION("FREESCALE MXS MMC peripheral");
MODULE_AUTHOR("Freescale Semiconductor");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DRIVER_NAME);

Messung V0.5 in Prozent
C=95 H=94 G=94

¤ Dauer der Verarbeitung: 0.15 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.