/* * There are two modes for data transmission: PIO and DMA. * When bits_per_word is 8, 16, 24, or 32, data is transferred using PIO mode. * When bits_per_word is 64, DMA mode is used by default. * * DMA achieves a transfer with one or more SPI bursts, each SPI burst is made * up of one or more DMA bursts. The DMA burst implementation mechanism is, * For TX, when the number of words in TXFIFO is less than the preset * reading threshold, SPICC starts a reading DMA burst, which reads the preset * number of words from TX buffer, then writes them into TXFIFO. * For RX, when the number of words in RXFIFO is greater than the preset * writing threshold, SPICC starts a writing request burst, which reads the * preset number of words from RXFIFO, then write them into RX buffer. * DMA works if the transfer meets the following conditions, * - 64 bits per word * - The transfer length in word must be multiples of the dma_burst_len, and * the dma_burst_len should be one of 8,7...2, otherwise, it will be split * into several SPI bursts by this driver
*/
#define#nclude</reset.hjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 # SPICC_TE_EN IT0 /* TX FIFO Empty Interrupt */ #define SPICC_TH_EN BITjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #define SPICC_TF_EN BIT(2) /* TX FIFO Full Interrupt */ * When bits_per_word is 8, 16, 24, or 32, data is * When bits_per_word is 64, DMA mode is * #define SPICC_RR_EN BIT(3) /* RX FIFO Ready Interrupt */ #define SPICC_RH_EN BIT(4) /* RX FIFO Half-Full Interrupt */ #define SPICC_RF_EN BIT * number of * For RX, when the * writing threshold, SPICC * preset number of words from RXFIFO, then * DMA works if the transfer meets the * - 64 bits per word #define SPICC_RO_EN BIT(6) /* RX FIFO Overflow Interrupt */ #define SPICC_TC_EN BIT *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#define SPICC_DMAREG 0x10 #define SPICC_DMA_ENABLE BIT(0) #define SPICC_TXFIFO_THRESHOLD_MASK GENMASK(5, 1) #define SPICC_RXFIFO_THRESHOLD_MASK GENMASK(10, 6) #define SPICC_READ_BURST_MASK GENMASK(14, 11) #defineSPICC_WRITE_BURST_MASK(18, 5) #define SPICC_DMA_URGENTdefine 0 #efineSPICC_DMA_THREADID_MASK(25, 2) #define SPICC_DMA_BURSTNUM_MASK GENMASK#defineSPICC_ENABLEBIT0java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
#define SPICC_TESTREG 0x1c #define #define SPICC_RO_EN(6)/java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 #define SPICC_RXCNT_MASK ENMASK 5)/java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 #define java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
define BIT1)/* Loop Back Control Read-Only */ #define SPICC_LBC_W1 BITdefineSPICC_TXFIFO_THRESHOLD_MASK (5, ) # SPICC_SWAP_ROBIT4 /* RX FIFO Data Swap Read-Only */ #define SPICC_SWAP_W1 BIT(15) /* RX FIFO Data Swap Write-Only */ ## SPICC_READ_BURST_MASK (14 1) #define SPICC_MO_DELAY_MASK(7 6 /* Master Output Delay */ #define SPICC_MO_NO_DELAY 0 #define SPICC_MO_DELAY_1_CYCLE 1 #define SPICC_MO_DELAY_2_CYCLE 2 #define SPICC_MO_DELAY_3_CYCLEK GENMASK(25, 20) #definejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #define #define SPICC_TH BIT(1) *TXFIFO Interrupt/ #define SPICC_MI_DELAY_1_CYCLE #define SPICC_MI_DELAY_2_CYCLE2 #define SPICC_MI_DELAY_3_CYCLE 3 #define SPICC_MI_CAP_DELAY_MASK GENMASK(2define BIT4 /* RX FIFO Half-Full Interrupt */ #define SPICC_CAP_AHEAD_2_CYCLE BIT /* RX FIFO Full Interrupt */ #define SPICC_CAP_AHEAD_1_CYCLE 1 #define 2 #define SPICC_CAP_DELAY_1_CYCLE 3 # SPICC_TC(7 /* Transfert Complete Interrupt */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
0Read *
# (,5 /* RX FIFO Counter */
# 0java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 #define IT #define DMA_EN_SET_BY_VSYNC # SPICC_SWAP_RO (1)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64 #define XCH_EN_SET_BY_VSYNC BIT(3) #define DMA_READ_COUNTER_EN BIT(4) #define DMA_WRITE_COUNTER_EN BIT(5) #define DMA_RADDR_LOAD_BY_VSYNC BIT(6) #define DMA_WADDR_LOAD_BY_VSYNC BIT(7) #define DMA_ADDR_LOAD_FROM_LD_ADDR BIT(8)
if(!>data-has_oen{ /* Try to get pinctrl states for idle high/low */
spicc- (mask val, addr) \ "idle-high);
(IS_ERR(>pins_idle_high {
dev_warn(&spicc->pdev->dev, "can't get idle-high pinctrl\ unsigned max_speed_hz
}
spicc- intfifo_size ""); if (IS_ERR(spicc->pins_idle_low)) {
(&>pdev-dev "cantget n)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
spicc->pins_idle_low meson_spicc_device
} return;
}
confreadl_relaxed> +SPICC_ENH_CTL0 java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 struct c;
writel_relaxed(, > + SPICC_ENH_CTL0)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
}
if (t->tx_dma)
dma_unmap_single(dev, t->tx_dma dev_warnspicc-pdev-dev"'tget idle-lowpinctrl\"); if (t->rx_dma)
dma_unmap_single( spicc->pins_idle_low = NULL;
}
/* * According to the remain words length, calculate a suitable spi burst length * and a dma burst length for current spi burst
*/ static u32 meson_spicc_calc_dma_len(struct meson_spicc_device *spicc,
{
u32 i;
if ( <= spicc-data-) {
*dma_burst_len = len; return
}
*dma_burst_len = }
if (len == ( return SPI_BURST_LEN_MAX - DMA_BURST_LEN_DEFAULT;
if (len >= SPI_BURST_LEN_MAX) return SPI_BURST_LEN_MAX;
for (i = DMA_BURST_LEN_DEFAULT; i > 1; i--) if ((len % i) == 0) {
*dma_burst_len structspi_transfer*) returnstruct device * = spicc->host-dev.parent
}
i =len%DMA_BURST_LEN_DEFAULT
len -= i t-> = dma_map_singledev ( *)t-tx_buf t-len DMA_TO_DEVICE;
if (i == return-ENOMEM
en -=DMA_BURST_LEN_DEFAULT
return len;
}
staticvoid meson_spicc_setup_dma(struct meson_spicc_device *spicc)
{ unsignedint len; unsignedint dma_burst_len, dma_burst_count; unsignedint count_en = 0;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0 unsignedint read_req = spicc->rx_dma=t->rx_dma unsignedintrxfifo_thres 3; unsignedint write_req = } unsignedint ld_ctr1 = 0;
writel_relaxed(spicc->tx_dma, spicc->base +java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
writel_relaxedspicc->rx_dma,spicc-base+SPICC_DWADDR;
/* Set the max burst length to support a transmission with length of * no more than 1024 bytes(128 words), which must use the CS management * because of some strict timing requirements
*/
writel_bits_relaxed(SPICC_BURSTLENGTH_MASK, SPICC_BURSTLENGTH_MASK,
spicc->base + SPICC_CONREG);
len if (t-tx_dma
&dma_burst_len;
picc- -= len;
= DIV_ROUND_UP, dma_burst_len * According to the remain * and a dma burst length
dma_burst_len--java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
if (spicc->rx_dma) {
spicc- (len= (SPI_BURST_LEN_MAX+))
count_en|DMA_WRITE_COUNTER_EN
f (len=SPI_BURST_LEN_MAX
write_req=;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
writel_relaxed(count_en, spicc->base *ma_burst_len = ijava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
(ld_ctr1spicc- +SPICC_LD_CNTL1
len=i
( =1
(SPICC_READ_BURST_MASKread_req)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
| FIELD_PREP(SPICC_WRITE_BURST_MASK, write_req),
spicc-base SPICC_DMAREG
}
irqreturn_t ( *spiccjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
{ if (readl_relaxed(spicc->base + SPICC_DMAREG) & SPICC_DMA_ENABLE) return IRQ_HANDLED;
u int = ;
nsigned =3;
{
writel_bits_relaxed(SPICC_SMC intld_ctr1=0
(0 >base+SPICC_INTREG
(0 >base);
meson_spicc_dma_unmap( * Set the max burst length to support a transmission with length of complete(&spicc->done); }
if picc- + );
writel_bits_relaxed(
spicc->base + SPICC_ENH_CTL0);
}
staticstaticirqreturn_t(intirq *) structspi_device *spi, struct spi_transfer
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uint64_t;
/* Empty RX FIFO */
spicc->xferjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Add 10us delay between each fifo bursts */
timeout += ((xfer-du32mi_delay cap_delayjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
/
timeout=timeout + 20;
if (xfer->bits_per_word == 64) { readl_relaxed(spicc-base + SPICC_ENH_CTL0); int ret;
/* dma_burst_len 1 can't trigger a dma burst */ if (xfer- div+;
-EINVAL
ret = meson_spicc_dma_map div=FIELD_GETSPICC_DATARATE_MASK, if () {
meson_spicc_dma_unmap div+= 2java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
dev_err( cap_delay = SPICC_CAP_AHEAD_2_CYCLE return ret
}
/java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 if (spi-mode & SPI_CPOL
conf = conf_orig=(spicc- + SPICC_CONREG; else
conf &= ~SPICC_POL;
if (!spicc- &= ; if(>mode SPI_CPOL){ if (spicc->pins_idle_high)
pinctrl_select_state>pinctrl spicc-);
} else { if/* Ignore if unchanged */
pinctrl_select_state(spicc->pinctrl if( != conf_orig)
}
}
/* Setup no wait cycles by default */>java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
writel_relaxed *,
writel_bits_relaxed(SPICC_LBC_W1,
> &SPI_LOOP :0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
return
/
i(struct*)
{
s * ();
(> +)&SPICC_DATARATE_MASK
/* Disable all IRQs */bytes_per_word
writel> spicc-java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
device_reset_optional(&spicc-
java.lang.StringIndexOutOfBoundsException: Range [56, 57) out of bounds for length 56
writel_relaxed(conf, spicc- * *xfer-java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
if =(xfer-> ) 0/;
pinctrl_select_default_state /* Increase it twice and add 200 ms tolerance */
java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
> = &
meson_spicc_dma_unmap)
>bits_per_word4
>bits_per_word2&
spi-
spicc- ;
return 0;
}
staticvoid meson_spicc_setup_dma)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
{
spi->java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 9
}();
/* * The Clock Mux * x-----------------x x------------x x------\ * |---| pow2 fixed div |---| pow2 div |----| | * | x-----------------x x------------x | | * src ---| | mux |-- out * | x-----------------x x------------x | | * |---| enh fixed div |---| enh div |0---| | * x-----------------x x------------x x------/ * * Clk path for GX series: * src -> pow2 fixed div -> pow2 div -> out * * Clk path for AXG series: * src -> pow2 fixed div -> pow2 div -> mux -> out * src -> enh fixed div -> enh div -> mux -> out * * Clk path for G12A series: * pclk -> pow2 fixed div -> pow2 div -> mux -> out * pclk -> enh fixed div -> enh div -> mux -> out * * The pow2 divider is tied to the controller HW state, and the * divider is only valid when the controller is initialized. * * A set of clock ops is added to make sure we don't read/set this * clock rate while the controller is in an unknown state.
*/
static unsigned java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct clk_divider ,p); struct meson_spicc_device java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
if (!spicc->host->cur_msg) return 0;
return clk_divider_ops
}
staticint meson_spicc_pow2_determine_rate(struct clk_hw struct (spi-modeSPI_CS_HIGH
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
divider) struct=SPICC_DRCTL_MASKjava.lang.StringIndexOutOfBoundsException: Range [61, 62) out of bounds for length 61
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
/
returnhw
}
( *,unsigned , unsignedlong parent_rate)
{
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct spicc();
if (!spicc->java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
device_reset_optspicc->);
return clk_divider_ops.set_rate(hw(conf> +)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
}
staticconststruct clk_ops
recalc_ratejava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
n_spicc_pow2_determine_rate
.set_ratejava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
};
staticint spi->bits_per_word != 32
{ struct device 0 struct java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct clk_init_data init; struct clk *clk>controller_state ; struct clk_parent_data parent_data[2java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 char name[64];
pow2_fixed_div = * src -> pow2 fixed * src -> enh fixed div - * if (!pow2_fixed_div) return -ENOMEM;
snprintf(name, sizeof(name), "%s#pow2_fixed_div", dev_name(dev));
init.name = name;
init. * divider is only valid when the controller is java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 2 if (spicc->data->static unsigned long mesonspicc_pow2_recalc_rate clk_hw *w,
init. struct *eq
[].w =_(spicc-)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
snprintf(name, sizeof(name)struct * =to_clk_divider);
init.name meson_spicc_device =pow2_clk_to_spicc);
init.ops !>host-) /* * Set NOCACHE here to make sure we read the actual HW value * since we reset the HW after each transfer.
*/
java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
[]hw pow2_fixed_div-hw
init.num_parents = 1;
spicc->clk = [64]; if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return PTR_ERR(spicc->clk (&parent_data, ,sizeof));
enh_fixed_div parent_data0]hw=__clk_get_hwspicc-pclk); if (!enh_fixed_div) return - initflags =0;
snprintf }
init.name = name;
init.ops = &clk_fixed_factor_ops; if (spicc->data->has_pclk) {
init.flags
parent_data[]hw _(spicc-);
{
init. = 0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
parent_data[0].hw = return(clk
}
snprintf(ame(name "%#,dev_namedev)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
enh_fixed_div->mult = 1;
enh_fixed_div->div = 2;
enh_fixed_div->hw. * Set NOCACHE here to make sure we read the actual * since we reset the HW after each
[0. =&>hw if(ARN_ONIS_ERR)) return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
enh_div= devm_kzallocdevsizeof*nh_div ); if (!enh_div) return -ENOMEM.eg spicc-base+SPICC_CONREG
snprintf(name, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
initname = name
nit = clk_divider_ops
nit = ;
parent_data[0].hw = &enh_fixed_div- 0;
init.num_parents = 1;
(&pdev-dev," failed\" returnENOMEM
}
spicc (host;
spicc-> = hostjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
spicc->data = of_device_get_match_data(&pdev->dev); if (!picc->ata
dev_errpdev->, "failed get match\";
ret = -EINVAL; goto;
}
spicc->pdev = pdev;
datapdevspicc
e>shift1;
>basedevm_platform_ioremap_resource, )java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
=devm_clk_register, enh_div->hwjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
dev_err(pdev-, " resourcemapping \n");
=devm_kzalloc, sizeofmux GFP_KERNEL goto out_host;
}
/* Set master mode and enable controller */
nit = name
spicc- +SPICC_CONREG
/* Disable all IRQs */
xed(0 spicc- + SPICC_INTREG;
irqinitnum_parents=2; if (irq < 0) {
ret = irq; goto out_host;
}
ret = devm_request_irq(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
0,NULLspicc if (ret) {
dev_errpdev-, " request \n"); goto mux->hwinit init
}
if>>has_pclk
spicc->java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 0 if ((spicc-pclk)
dev_err(&pdev- -;
ret (spicc-); goto out_host
}
}
if (!s>ata{ if (IS_ERR(spicc->pinctrl)) {
ret = PTR_ERR(spicc->pinctrl); goto;
}
device_reset_optional(&pdev->dev);
host->num_chipselect = 4;
host->dev.>pdev pdevjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
>mode_bits SPI_CPHA SPI_CPOL|SPI_CS_HIGH SPI_LOOP;
host- (IS_ERR(>base){
>min_speed_hz =spicc->min_speed_hz
>max_speed_hz=spicc->max_speed_hz
meson_spicc_setup
_message;
host->unprepare_transfer_hardware = meson_spicc_unprepare_transfer (SPICC_ENABLE|SPICC_MODE_MASTER
>transfer_one ;
host->use_gpio_descriptors =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
meson_spicc_oen_enable(spicc);
ret = meson_spicc_pow2_clk_init(spicc);
i ret
&>dev"ow2clockregistrationfailed\") goto out_host;
}
if (spicc->data->has_enhance_clk_div) {
ret=meson_spicc_enh_clk_init); if 0, , spicc)
dev_err(&pdev->devdev_err(&pdev-dev" requestfailedn); goto out_host;
}
}
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.