Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: sh-msiof: Configure MSIOF sync signal timing in device tree

The MSIOF controller has DTDL and SYNCDL in SITMDR1 register. So,
this patch adds new properties like the following commit:
d0fb47a5237d8b9576113568bacfd27892308b62
(spi: fsl-espi: Configure FSL eSPI CSBEF and CSAFT)

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Yoshihiro Shimoda and committed by
Mark Brown
3110628d 97bf6af1

+65
+16
Documentation/devicetree/bindings/spi/sh-msiof.txt
··· 30 30 specifiers, one for transmission, and one for 31 31 reception. 32 32 - dma-names : Must contain a list of two DMA names, "tx" and "rx". 33 + - renesas,dtdl : delay sync signal (setup) in transmit mode. 34 + Must contain one of the following values: 35 + 0 (no bit delay) 36 + 50 (0.5-clock-cycle delay) 37 + 100 (1-clock-cycle delay) 38 + 150 (1.5-clock-cycle delay) 39 + 200 (2-clock-cycle delay) 40 + 41 + - renesas,syncdl : delay sync signal (hold) in transmit mode. 42 + Must contain one of the following values: 43 + 0 (no bit delay) 44 + 50 (0.5-clock-cycle delay) 45 + 100 (1-clock-cycle delay) 46 + 150 (1.5-clock-cycle delay) 47 + 200 (2-clock-cycle delay) 48 + 300 (3-clock-cycle delay) 33 49 34 50 Optional properties, deprecated for soctype-specific bindings: 35 51 - renesas,tx-fifo-size : Overrides the default tx fifo size given in words
+47
drivers/spi/spi-sh-msiof.c
··· 82 82 #define MDR1_SYNCMD_LR 0x30000000 /* L/R mode */ 83 83 #define MDR1_SYNCAC_SHIFT 25 /* Sync Polarity (1 = Active-low) */ 84 84 #define MDR1_BITLSB_SHIFT 24 /* MSB/LSB First (1 = LSB first) */ 85 + #define MDR1_DTDL_SHIFT 20 /* Data Pin Bit Delay for MSIOF_SYNC */ 86 + #define MDR1_SYNCDL_SHIFT 16 /* Frame Sync Signal Timing Delay */ 85 87 #define MDR1_FLD_MASK 0x000000c0 /* Frame Sync Signal Interval (0-3) */ 86 88 #define MDR1_FLD_SHIFT 2 87 89 #define MDR1_XXSTP 0x00000001 /* Transmission/Reception Stop on FIFO */ ··· 281 279 sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr); 282 280 } 283 281 282 + static u32 sh_msiof_get_delay_bit(u32 dtdl_or_syncdl) 283 + { 284 + /* 285 + * DTDL/SYNCDL bit : p->info->dtdl or p->info->syncdl 286 + * b'000 : 0 287 + * b'001 : 100 288 + * b'010 : 200 289 + * b'011 (SYNCDL only) : 300 290 + * b'101 : 50 291 + * b'110 : 150 292 + */ 293 + if (dtdl_or_syncdl % 100) 294 + return dtdl_or_syncdl / 100 + 5; 295 + else 296 + return dtdl_or_syncdl / 100; 297 + } 298 + 299 + static u32 sh_msiof_spi_get_dtdl_and_syncdl(struct sh_msiof_spi_priv *p) 300 + { 301 + u32 val; 302 + 303 + if (!p->info) 304 + return 0; 305 + 306 + /* check if DTDL and SYNCDL is allowed value */ 307 + if (p->info->dtdl > 200 || p->info->syncdl > 300) { 308 + dev_warn(&p->pdev->dev, "DTDL or SYNCDL is too large\n"); 309 + return 0; 310 + } 311 + 312 + /* check if the sum of DTDL and SYNCDL becomes an integer value */ 313 + if ((p->info->dtdl + p->info->syncdl) % 100) { 314 + dev_warn(&p->pdev->dev, "the sum of DTDL/SYNCDL is not good\n"); 315 + return 0; 316 + } 317 + 318 + val = sh_msiof_get_delay_bit(p->info->dtdl) << MDR1_DTDL_SHIFT; 319 + val |= sh_msiof_get_delay_bit(p->info->syncdl) << MDR1_SYNCDL_SHIFT; 320 + 321 + return val; 322 + } 323 + 284 324 static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p, 285 325 u32 cpol, u32 cpha, 286 326 u32 tx_hi_z, u32 lsb_first, u32 cs_high) ··· 340 296 tmp = MDR1_SYNCMD_SPI | 1 << MDR1_FLD_SHIFT | MDR1_XXSTP; 341 297 tmp |= !cs_high << MDR1_SYNCAC_SHIFT; 342 298 tmp |= lsb_first << MDR1_BITLSB_SHIFT; 299 + tmp |= sh_msiof_spi_get_dtdl_and_syncdl(p); 343 300 sh_msiof_write(p, TMDR1, tmp | MDR1_TRMD | TMDR1_PCON); 344 301 if (p->chipdata->master_flags & SPI_MASTER_MUST_TX) { 345 302 /* These bits are reserved if RX needs TX */ ··· 997 952 &info->tx_fifo_override); 998 953 of_property_read_u32(np, "renesas,rx-fifo-size", 999 954 &info->rx_fifo_override); 955 + of_property_read_u32(np, "renesas,dtdl", &info->dtdl); 956 + of_property_read_u32(np, "renesas,syncdl", &info->syncdl); 1000 957 1001 958 info->num_chipselect = num_cs; 1002 959
+2
include/linux/spi/sh_msiof.h
··· 7 7 u16 num_chipselect; 8 8 unsigned int dma_tx_id; 9 9 unsigned int dma_rx_id; 10 + u32 dtdl; 11 + u32 syncdl; 10 12 }; 11 13 12 14 #endif /* __SPI_SH_MSIOF_H__ */