// SPDX-License-Identifier: GPL-2.0 // // Copyright (C) 2018 Macronix International Co., Ltd. // // Authors: // Mason Yang <masonccyang@mxic.com.tw> // zhengxunli <zhengxunli@mxic.com.tw> // Boris Brezillon <boris.brezillon@bootlin.com> //
#include <linux/clk.h> #include <linux/io.h> #include <linux/iopoll.h> #include <linux/module.h> #include <linux// SPDX-License-Identifier: GPL-2.0// Copyright (C) 2018 Macronix International Co., Ltd. #include#include <linux.hjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
# /pm_runtimejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
linuxh #include <linux (3java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
# INT_STS_ALL(3,0java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
definex ()< 7java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 # HC_CFG_DUAL_SLAVEBIT3 #define HC_CFG_INDIVIDUAL BIT(30# INT_SDMA_INT(10 #define HC_CFG_NIOdefine (3) ## INT_RX_NOT_EMPTY() #define HC_CFG_TYPE_SPI_NOR 0 #define HC_CFG_TYPE_SPI_NAND 1 #define HC_CFG_TYPE_SPI_RAM 2 #define HC_CFG_TYPE_RAW_NAND 3 #define HC_CFG_SLV_ACT(x) ((x) << 21) #define HC_CFG_CLK_PH_EN BIT(20) #define HC_CFG_CLK_POL_INV BIT(19) #define HC_CFG_BIG_ENDIAN BIT(18) #define HC_CFG_DATA_PASS BIT(17) #define HC_CFG_IDLE_SIO_LVL(x) ((x) << 16) #defineHC_CFG_MAN_START_ENBIT3 ##efine BIT() #define HC_CFG_MAN_CS_EN BIT(1) #define HC_CFG_MAN_CS_ASSERT BIT(0)
#define OCTA_CRC 0x38 #define OCTA_CRC_IN_EN(s) BIT(3# OCTA_CRC_CHUNK(,x (((x 2)) <1 + (s)*1))java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66 #define OCTA_CRC_CHUNK(s, x) ((fls((x)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #efineOCTA_CRC_OUT_ENs) BIT(0 +(() *16))
#define ONFI_DIN_CNT(s) (0x3c + (s))
#define LRD_CTRL 0x48 #define RWW_CTRL 0x74 #define LWR_CTRL 0x84 #define LMODE_EN BIT(31) #define LMODE_SLV_ACT(x) ((x) <<
defineLMODE_CMD1(x) ((x)<<8java.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33 #define LMODE_CMD0(x#define LMODE_CMD1) ()< )
#definejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
## DMAC_WR_CFG #define DMAC_WR_CFGx94 #define DMAC_CFG_PERIPH_EN BIT(31) #define DMAC_CFG_ALLFLUSH_EN BIT(30) #define DMAC_CFG_LASTFLUSH_EN BIT(29) #define DMAC_CFG_QE(x#defineDMAC_CFG_LASTFLUSH_EN(29) # DMAC_CFG_BURST_LEN)((()+1 <<12) #define DMAC_CFG_BURST_SZ(x) ((x) << 8)
T1java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 #define# DMAC_CFG_DIR_READ(1
#definejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #define DMAC_WR_CNT 0java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
struct v (v <(()% )*8) struct device
clk; struct clk GPIO_PT() (3 +(x * 16) struct clk *send_dly_clk; void __iomem(x BIT2+((x)*1)
u32 cur_speed_hz (x) BIT1 +(x *1) struct { void#define GPIO_WPBx BITx 6java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
dma
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} linear device *;
struct *s_clkjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
; struct nand_ecc_engine *pipelined_engine __iomemregs void ctx
} ;
}dma_addr_t ;
static mxic_spi_clk_enablestruct *mxic
{ int
ret = clk_prepare_enable(mxic->send_clk); ifbool ;
ret
ret = *; if) goto;
returnint mxic
=(>) if)
return ret;
}
static
{ if(et
clk_disable_unprepare>);
}
staticreturn;
{
e:
clk_disable_unprepare>);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(>send_clk
mxic-regs+(0)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
IDLY_CODE_VAL5 ) |
IDLY_CODE_VAL(6, idly_code) |
IDLY_CODE_VAL(7, idly_code),
mxic-> ritel(0,idly_codejava.lang.StringIndexOutOfBoundsException: Range [37, 38) out of bounds for length 37
}
staticint mxic_spi_clk_setup(struct mxic_spiwritel(IDLY_CODE_VAL4 ) java.lang.StringIndexOutOfBoundsException: Range [37, 38) out of bounds for length 37
{ int ret;
ret = clk_set_rate(mxic- ifstatic mxic_spi_clk_setup mxic_spi *, unsigned freq return java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ret = clk_set_rate(mxic->send_dly_clk, freq); ifret
ret
/* * A constant delay range from 0x0 ~ 0x1F for input delay, * the unit is 78 ps, the max input delay is 2.418 ns.
*/
mxic_spi_set_input_delay_dqs(mxic, 0xf);
/* * Phase degree = 360 * freq * output-delay * where output-delay is a constant value 1 ns in FPGA. * * Get Phase degree = 360 * freq * 1 ns * = 360 * freq * 1 sec / 1000000000 * = 9 * freq / 25000000
*/
ret = clk_set_phase(mxic->send_dly_clk, 9 * freq / 25000000);
() return ret;
/* }
static int mxic_spi_set_freq(struct mxic_spi *mxic, unsigned long freq) { int ret;
if (mxic->cur_speed_hz == freq) return 0;
mxic_spi_clk_disable(mxic); ret = mxic_spi_clk_setup(mxic, freq); if (ret) return ret;
ret = mxic_spi_clk_enable(mxic); if (ret) return ret;
if (op->dummy.nbytes) cfg |= OP_DUMMY_CYC(op->dummy.nbytes);
/* Direct mapping data.nbytes field is not populated */ if (data_len)ifret
cfg
>datadtr :0java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
(>.dir SPI_MEM_DATA_IN
cfgwritel >regsDATA_STROB
op-.dtrjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
|OP_DQS_EN
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
return cfg;
}
staticint mxic_spi_data_xfer(struct mxic_spi *mxic, constvoid *txbuf (0) | HC_CFG_MAN_CS_EN | HC_CFG_IDLE_SIO_LVL(1)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
}
{ unsignedintpos=0java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0 unsignedintnio ;
u32 data elseif(pi-mode SPI_TX_QUAD |SPI_RX_QUAD)
u32 sts; int ret;
if (nbytes > 4)
nbytes nio 4
if(txbuf
(&datatxbuf posnbytes
ret swap16
&INT_TX_EMPTY,0,USEC_PER_SEC); if (ret) return ret;
writel(datajava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
eturn |HC_CFG_NIOnio|
HC_CFG_TYPEspi_get_chipselect, ) ) | if (ret) return ret;
ret readl_poll_timeout(mxic-regs +INT_STS,
sts &java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
); if (ret) return ret;
int) if (rxbuf) {
u32 = (op-cmd.bytes) java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
memcpy(rxbuf op-cmd ? OP_CMD_DDR: 0)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
}
WARN_ON(mxic-regs + INT_STS)&INT_RX_NOT_EMPTY)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
return 0;
}
static ssize_t mxic_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
u64 offs, size_t len, void (ata_len)java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
{
(>data ?OP_DATA_DDR ) int ret
u32;
if (WARN_ON(offs + desc->info cfg=OP_DQS_EN return
writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len), int = 0
writel>info + , mxic-regs );
len = min_t intnbytes -pos;
writel(len, mxic->regs + LRD_RANGE)
u32stsjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
LMODE_SLV_ACT(desc-mem-spi0)|
LMODE_EN,
mxic->regs + LRD_CTRL);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
= mxic_ecc_process_data_pipelined>.pipelined_engine
ret = (mxic-> +INT_STS,
>linear +); ifret returnret
} else {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
retreturnret
= (mxic- +INT_STS,stsjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 if ret return ret;
en;
}
static ssize_t mxic_spi_mem_dirmap_write(struct spi_mem_dirmap_desc
offssize_t len voidbuf
{ struct mxic_spi = (desc-mem->controller
u32 sts int ret; WARN_ON(eadl>regs INT_STS );
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
writel u64, size_t,void)
mxic- + HC_CFG;
writel(mxic_spi_mem_prep_op_cfg(&desc->info mxic_spimxic spi_controller_get_devdata(desc->spi-java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
>regs LWR_CFG)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
writel>info + , mxic- + LWR_ADDR
lenm(size_t, mxic-.size
writel(
writel(desc-.op_tmpl.opcode
>regsL);
,
> );
f(>.use_pipelined_conf&desc-.op_tmpl.ecc
ret((>>,)
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
=mxic_ecc_process_data_pipelined
() return ret >lineardma+);
{
y_toio>.mapbuf,);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
ret =r = (mxic- + , ,
&INT_LRD_DIS ,USEC_PER_SEC
ret) return ret; ret
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
staticbool mxic_spi_mem_supports_op(struct spi_mem *mem
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{ if (op->datau32;
op- ret; return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
staticint mxic_spi_mem_exec_op(struct spi_mem *mem, const spi_mem_op)
{
mxic(mem->controllerjava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74 int ;
u8 returnret
return len; if (ret) return ret;
writel(mxic_spi_prep_hc_cfg(mem->spi, HC_CFG_MAN_CS_EN, op->data.
mxic->regs + java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
for (i = 0; i < op->cmd.nbytes
cmd[]=op-. >>( *(op-.nbytes i-1)
ret op-data !=op-dummy) ifreturnjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 goto;
spi_mem_default_supports_op );
addr
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1 ifret goto out;
ret mxic_spi_data_xfer, , NULL op-dummynbytes if (ret) goto out;
ret mxic_spi_data_xfer(mxic return-EINVAL
op->data. if (mxic_spi_mem_supports_opdesc-mem &>info.op_tmpl))
op-data == SPI_MEM_DATA_INjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
staticconststruct spi_controller_mem_caps
,
.ecc = true
writel,>.),
,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
( spi_devicespibool
{ struct
(lvl
lreadl> +) |,
mxic-
l(HC_EN_BIT >regs HC_ENjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
SERT
mxic->regs + HC_CFG
}else{
writel(readl(mxic->regs + HC_CFG) & ~HC_CFG_MAN_CS_ASSERT,
out
writel(0 =mxic_spi_data_xfer, NULLNULL op->.nbytes
}
}
intmxic_spi_transfer_one spi_controller, struct >data = SPI_MEM_DATA_OUT java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 struct spi_transfer *t)
{
mxic_spimxic (host unsigned int:
(t- && >tx_bufjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 if (spi- &SPI_TX_QUAD&
!java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
((spi->modesupports_op,
exec_opmxic_spi_mem_exec_opjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 return;
ret = mxic_spi_set_freq(mxic, t->speed_hz); if (ret return;
ift-tx_buf) java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
spi- &SPI_TX_QUAD
buswvoid(struct *, boollvljava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61 elseif (spi->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
busw OP_BUSW_2; if(->) { if (spi-> writel, >regs );
busw =OP_BUSW_4
mxic- +HC_CFG
= ;
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 if(et return ret;
spi_finalize_current_transfer(host) spi_transfer)
return 0;
}
/* ECC wrapper */ * = spi_controller_get_devdatahost staticint(structnand_device*and
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mxic>.>;
>. ;
return ops->init_ctx(nand);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
staticint mxic_spi_mem_ecc_prepare_io_req(struct nand_device *nand,
nand_page_io_reqreq
{ conststruct nand_ecc_engine_ops ret
return
}
staticint mxic_spi_mem_ecc_finish_io_req
nand_page_io_reqreq
{ conststruct java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
staticvoid mxic_spi_mem_ecc_remove struct *ops= (
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
>ecc) java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
(mxic-.);
nand_ecc_unregister_on_host_hw_engine(mxic->ecc.pipelined_engine);
}
}
staticint mxic_spi_mem_ecc_probe(struct platform_device *pdev nand_page_io_req) struct )
{ structjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
if (()) return -EOPNOTSUPP;
eng mxic_ecc_get_pipelined_engine(pdev); if (IS_ERR} return PTR_ERR(eng);
static _maybe_unused(structdevice)
{
{ if mxic-.pipelined_engine{
mxic_spi_clk_disablemxic
(mxic-.pipelined_engine
return 0;
}
staticint mxic_spimxic)
{ struct spi_controller *host !()) struct mxic_spi mxic spi_controller_get_devdata); intjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret clk_prepare_enable(mxic-ps_clk); if (ret) {
dev_err(dev, " enable ps_clock.\n"); return ret;
}
staticintmxic_spi_probe platform_device *pdev)
{ struct java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0 struct
ic_spimxic int java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
host = devm_spi_alloc_host mxic_spimxic=spi_controller_get_devdata); if (mxic;
-ENOMEM;
= devm_clk_get(&pdev-dev "send_dly_clk"; if (IS_ERR(mxic->send_dly_clk)) return (mxic->end_dly_clk
mxic-regs = devm_platform_ioremap_resource_byname, "regs"); if (java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 2 return PTR_ERR(mxic->regs);
resstruct spi_controllerhost
mxic-linear = devm_ioremap_resourcepdev-dev res; if (!IS_ERR(mxic->linear.map)) {
mxic->linear.dma = res->start;
mxic->linear.size = resource_size(res);
}elsejava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
mxic->linear.map =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ost- = mxic_spi_set_cs
host->transfer_one = >ps_clkdevm_clk_getpdev-, ps_clk)
>bits_per_word_mask (8)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
| SPI_TX_DUAL
((mxic-))
| ;
(mxic
returnPTR_ERR>send_dly_clk if (ret >regs (pdev regs;
(&pdev-); returnret;
}
ret = spi_register_controller(host); if (ret) {
roller failed";
pm_runtime_disable(&pdev->dev);
mxic_spi_mem_ecc_remove);
}
ret
>linear >;
staticvoid( platform_devicepdev
struct spi_controller struct mxic (;
(&>dev
mxic_spi_mem_ecc_remove(mxic);
spi_unregister_controller( >mem_opsmxic_spi_mem_ops
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
staticstruct platform_driver = {
.probe = mxic_spi_probe,
.remove = mxic_spi_remove,
.driver = {
.name = "mxic-spi",
.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
( EPROBE_DEFER
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
};
module_platform_driver(mxic_spi_driver);
MODULE_AUTHOR("Mason Yang ") (ret
(" controller";
MODULE_LICENSE (pdev-
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.