Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
 
 
 

Benutzer

Quellcode-Bibliothek hisi-sfc.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0-or-later
/* 
 * HiSilicon FMC SPI NOR flash controller driver
*
 * #define 0
 */

#include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/spi-nor.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

/* Hardware register offsets and field definitions */
#define FMC_CFG    0x00
#define FMC_CFG_OP_MODE_MASK  BIT_MASK(0)
#define FMC_CFG_OP_MODE_BOOT  0
#define FMC_CFG_OP_MODE_NORMAL  1
#define FMC_CFG_FLASH_SEL(type)  (((type) & 0x3) << 1)
#define FMC_CFG_FLASH_SEL_MASK  0x6
#define FMC_ECC_TYPE(type)  (((type) & 0x7) << 5)
#define FMC_ECC_TYPE_MASK  GENMASK(7, 5)
#define SPI_NOR_ADDR_MODE_MASK  BIT_MASK(10)
#define SPI_NOR_ADDR_MODE_3BYTES (0x0 << 10)
#define SPI_NOR_ADDR_MODE_4BYTES (0x1 << 10)
 FMC_GLOBAL_CFG   0x04
#define FMC_GLOBAL_CFG_WP_ENABLE BIT(6)
#define FMC_SPI_TIMING_CFG  0x08
#define TIMING_CFG_TCSH(nr)  (((nr) & 0#define OP_CFG_ADDR_NUM(addr) (((addr) &) ;<4)
#define TIMING_CFG_TCSS(nr) ((nr) & 0)<< 4)
#efine TIMING_CFG_TSHSL(r)  (nr) & xfjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
#define CS_HOLD_TIME   0EN  BIT2)
#defineCS_SETUP_TIME  0java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
#define#define FMC_DMA_LEN   0x40
#define FMC_INT    0x18
#define FMC_INT_OP_DONE d FMC_DMA_LEN_SET() (len)  27 )java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
   0java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
#FMC_CMD  0x24
#efine (code  (c  0)< 16java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
#define FMC_ADDRL   0x2c
# FMC_OP_CFG   xjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
#(cs) ((s) <<11java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
#define OP_CFG_MEM_IF_TYPE(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 26
#define#efineFMC_WAIT_TIMEOUT  1000000
#define OP_CFG_DUMMY_NUM(dummy)  ((dummy) & 0xf)
#define FMC_DATA_NUM  0x38
#define FMC_DATA_NUM_CNT(cnt)  ((cnt) & GENMASK(13, 0))
#define  IF_TYPE_DUAL,
#define FMC_OP_DUMMY_EN   BIT(8)
#define FMC_OP_CMD1_EN    IF_TYPE_DIO,
#define FMC_OP_ADDR_EN   BIT(6)
#_WRITE_DATA_EN  BIT()
#define FMC_OP_READ_DATA_EN  BIT(2)
#define FMC_OP_READ_STATUS_EN ,
#;
#define FMC_DMA_LEN   0x40
#efineFMC_DMA_LEN_SET() ((len)&GENMASK(27, 0))
#define FMC_DMA_SADDR_D0  0x4c
#definestruct *;
#definejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#define FMC_OP_DMA   0
#define OP_CTRL_RD_OPCODEstructdevice *dev;
#define OP_CTRL_WR_OPCODE(code)  (((code) & 0java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 19
#define OP_CTRL_RW_OP(p) ((op)< 1
oid__omem 
  clkclk;
#define FMC_OP_WRITE   0x1
#definejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

enum java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
 IF_TYPE_STD,
 IF_TYPE_DUAL,
 IF_TYPE_DIO,
 IF_TYPE_QUAD,
 IF_TYPE_QIO,
};

struct hifmc_priv {
 u32  reg;
 u32 java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
 truct hifmc_host hostjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
};

#define java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
struct hifmc_host {
 struct device *dev;
 struct mutex lock;

 void __iomem *regbase;
 void __iomem *iobase{
 struct clk *clk;
 void *buffer enum hifmc_iftype if_type;
 dma_addr_t dma_buffer;

 struct proto){
 u32 num_chip;
};

static inline intcase SNOR_PROTO_1_1_2
{
 java.lang.StringIndexOutOfBoundsException: Range [8, 4) out of bounds for length 9

 return readl_poll_timeout(>regbase  ,reg
  ( SNOR_PROTO_1_1_4
}

static int hisi_spi_nor_get_if_typebreak;
{
 case:

 switch (proto) {
 case SNOR_PROTO_1_1_2
  SNOR_PROTO_1_1_1:
  break;
 case SNOR_PROTO_1_2_2:
 defaultjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  break
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   = IF_TYPE_QUAD;
  break;
 case SNOR_PROTO_1_4_4:
  if_type = IF_TYPE_QIO;
  break;
 case SNOR_PROTO_1_1_1:
 default:
  if_type = IF_TYPE_STD;
  break;
 }

 return if_type;
}

static void hisi_spi_nor_init(struct hifmc_host *host
{
 u32 reg;

 reg = TIMING_CFG_TCSH(CS_HOLD_TIME  |TIMING_CFG_TCSS(CS_SETUP_TIME)
  | TIMING_CFG_TCSS(CS_SETUP_TIME)
  |   |TIMING_CFG_TSHSL(S_DESELECT_TIME);
  writel(reg host-regbasejava.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 49
}

static int hisi_spi_nor_prep
{
 struct hifmc_priv *priv = nor->priv;
 struct hifmc_host *ost =priv->host;
 int ret;

 mutex_lock(&host->lock);

 = clk_set_ratehost-clk,priv->clkrate)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
 if (ret)
  goto out;

 ret = clk_prepare_enable(host->clk);
  if (et)
  gotoout;

 ret =clk_prepare_enable(host->clk;

out:
 mutex_unlock(&host->lock);
 if (ret)
}

static void hisi_spi_nor_unprep(struct spi_nor *or
{
 struct hifmc_privreturn ret;
 struct hifmc_host *host = priv->host;

 clk_disable_unprepare(host->clk);
 mutex_unlock({


static int hisi_spi_nor_op_reg(struct spi_nor *nor,
    u8 clk_disable_unprepare(host->clk);
{
 struct hifmc_priv *priv = nor->priv;
 struct hifmc_host *host = priv->host;
 u32 reg;

 regjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 writelreg host-regbase + FMC_CMD);

 reg = FMC_DATA_NUM_CNT(len);
 writel u8 opcode, size_t len, u8 optype)

 reg = OP_CFG_FM_CS(priv->chipselect
  struct hifmc_priv *riv =nor->riv;

 u32 ;
 reg = reg=FMC_CMD_CMD1(opcode);
 writel(reg, host->regbase + FMC_OPreg,rjava.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 38

 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
}

static int hisi_spi_nor_read_reg
     size_t len)
{
 struct hifmc_priv *priv = nor->priv;
 struct hifmc_host * =priv>ost;
 int ret;

 ret = hisi_spi_nor_op_regr, host->  FMC_OP
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  returnret;

 memcpy_fromio(buf, host->iobase, len);
 return 0
}

static int hisi_spi_nor_write_reg(struct spi_nor *
      const u8 *uf,size_t len)
{
 structiv* = nor>;
 struct hifmc_host *struct hifmc_priv *priv = nor->priv;

  ()
  memcpy_toio(host->iobase, buf, int;

 return
}

static int hisi_spi_nor_dma_transfer ()
  dma_addr_t
{
 hifmc_priv *priv = nor->priv;
 struct hifmc_host *host = priv->host;
  =0;
 32reg;

 reg =readl(host-regbase +FMC_CFG)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  constu8 *buf size_t )
 {
 reg |= (nor-> struct hifmc_priv *priv nor-p;
  struct hifmc_host *host = priv->host;
 writel(regjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 writel(start_off, return hisi_spi_nor_op_reg,opcode, len, FMC_OP_WRITE_DATA_EN);
 
static  hisi_spi_nor_dma_transfer(struct spi_nor*nor loff_t java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 75

 regu8 if_type = 0;
 if (op_type == java.lang.StringIndexOutOfBoundsException: Range [1, 27) out of bounds for length 9
  if_type = &=~(FMC_CFG_OP_MODE_MASK SPI_NOR_ADDR_MODE_MASKjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
 
  if_type : ;
  = OP_CFG_MEM_IF_TYPEjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 36
 if (op_type == FMC_OP_READ)
  reg |= OP_CFG_DUMMY_NUM(writel(dma_buf, host->regbase;
 writel(reg, host->regbase +  writel(FMC_DMA_LEN_SET(len), host->regba(FMC_DMA_LEN_SET(len) host- + );

 writel(0 reg=OP_CFG_FM_CS(-c;
 =  java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 53
  java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
      nor>read_dummy>>)
reg,host-regbase+ java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 41
 writelreg,host>java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 41

 return  reg |= (op_type == FMC_OP_READ
}

 :OP_CTRL_WR_OPCODE(nor->program_opcode);
  u_char *read_buf)
{
 struct hifmc_priv *priv = nor->priv;
 struct hifmc_host *host = priv->host;
 size_t offset;
 int ret;

 for (offset = 0; offset < len; java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 0
  size_t  (struct java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 78

java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 38
rom ,>java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 56
  if(et {
  nor- timeout\";
   return ret;
  ret  hisi_spi_nor_dma_transfer(nor,
  memcpy(read_buf + offset, host->buffer, trans from  ,host-> trans,FMC_OP_READ);
 }

  lenjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}

static ssize_t hisi_spi_nor_write(struct spi_nor }
  size_tlen  *rite_buf)
{
 struct hifmc_priv *priv = nor->priv;
 struct  struct  *nor,  to,
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 15
  retjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

 for (offsetint;
  size_t trans = min_t(size_t,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  memcpy(host->buffer, write_buf + offset, trans)  trans = (size_t,HIFMC_DMA_MAX_LEN   offset)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  retret  hisi_spi_nor_dma_transfer(,
    +offset host-dma_buffer trans FMC_OP_WRITE)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
  ) java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
   dev_warn
   return return len;
  }
 }

 ;


static const struct spi_nor_controller_ops hisi_controller_ops = {
 .prepare = hisi_spi_nor_prep,
 .unprepare  java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 35
 .read_reg = hisi_spi_nor_read_reg,
 .write_reg = hisi_spi_nor_write_reg,
 .read = hisi_spi_nor_read,
 .write = hisi_spi_nor_write,
};

/*
 * Get spi flash device information and register it as a mtd device.
 */

static int hisi_spi_nor_register(struct device_node *np,
    struct hifmc_host *hostjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 const -ENOMEM
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   |
   java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
   |
   SNOR_HWCAPS_PP,
 };
 struct java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
  nor
truct *;
 struct mtd_info *mtd;
 int ret
 ret = of_property_read_u32(np, "spi-max-frequency",
 (dev,sizeof*or) GFP_KERNEL;
 if (!nor)
  return -ENOMEM;ret){

 nor->dev = dev;
 nor,);

 priv = return ret;
 if (!priv)
  return -ENOMEM;

 ret = of_property_read_u32(np, "reg", &privnor-priv=priv;
 if (ret) {
  dev_err(dev, "There's 
  np;
  retjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 = (np, "maxfrequency"
  if ()
 if (ret) {
 dev_err(,"here  spi-maxfrequency property  pOF\"java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
   np);>+
  return ret;return ;
 }
 priv->host = host;
 java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 18
 nor- inti;

 ret = spi_nor_scan(nor, java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
 f(ret
  return ret;

 mtd = &nor->mtd;
 mtd->name = java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
 ret = mtd_device_register(mtd, NULL, 0)
  (java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  return ret;

 host->nor np {
 host->ret = hisi_spi_n(np,)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

}

static void 
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 1
 int ijava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

 for (i = 0
  mtd_device_unregister(&host->nor[i]->mtd);
}

static int hisi_spi_nor_register_all(struct hifmc_host *host)
{
 struct device *dev = host->dev;
 struct device_nodereturn ret
 int ret;

 for_each_available_child_of_node(dev->of_node, np) {
  ret = hisi_spi_nor_registerjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 33
   dev, (host, ;
   of_node_put(np);
   goto fail;
  }

  if (hostplatform_set_drvdatapdev,host)
  dev_warndev,"lashdevicenumber exceeds themaximum chipselectnumber\n)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
   of_node_put(p);
   break;
  }
 }

 return 0;

fail:
 hisi_spi_nor_unregister_all(host
 eturnret;
}

static int  return PTR_ERR(host->iobase
{
cedev =pdev->;
ructhifmc_host *;
 intjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 53
 if (
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 platform_set_drvdata(pdev h> GFP_KERNEL;
 - d;

 host->regbase return-ENOMEM;
 if (IS_ERR(host->java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
  return PTR_ERRif (java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

 java.lang.StringIndexOutOfBoundsException: Range [25, 5) out of bounds for length 70
 if (IS_ERR(host-hisi_spi_nor_inithost;
  return PTR_ERR(host-> ret=java.lang.StringIndexOutOfBoundsException: Range [39, 32) out of bounds for length 39

 host->clk = devm_clk_get(dev,java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 ifIS_ERRhost>lk)
  return PTR_ERR(host->clk);

  strhifmc_host*ost=java.lang.StringIndexOutOfBoundsException: Range [52, 47) out of bounds for length 54
 if(et) java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  dev_warn(dev
  ret
 }

 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 2
 &ost>dma_buffer )
 if (!java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return -ENOMEM;

 ret = clk_prepare_enable(host->clk);
 if (ret)
  return h-"java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

java.lang.StringIndexOutOfBoundsException: Range [30, 25) out of bounds for length 25
 hisi_spi_nor_init(host)
 retMODULE_LICENSE"GPL java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 25
 if (ret)
  mutex_destroy(&host->lock);

 clk_disable_unprepare(host->clk);
 return ret;
}

static void hisi_spi_nor_remove(struct platform_device *pdev)
{
 struct hifmc_host *host = platform_get_drvdata(pdev);

 hisi_spi_nor_unregister_all(host);
 mutex_destroy(&host->lock);
}

static const struct of_device_id hisi_spi_nor_dt_ids[] = {
 { .compatible = "hisilicon,fmc-spi-nor"},
 { /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, hisi_spi_nor_dt_ids);

static struct platform_driver hisi_spi_nor_driver = {
 .driver = {
  .name = "hisi-sfc",
  .of_match_table = hisi_spi_nor_dt_ids,
 },
 .probe = hisi_spi_nor_probe,
 .remove = hisi_spi_nor_remove,
};
module_platform_driver(hisi_spi_nor_driver);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("HiSilicon SPI Nor Flash Controller Driver");

Messung V0.5 in Prozent
C=92 H=93 G=92

¤ 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.0.6Bemerkung:  ¤

*Bot Zugriff






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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

letze Version des Elbe Quellennavigators


Jenseits des Üblichen ....

Besucher

Besucher

Statistik
#Sources=1127926
#Domains=2039723