diff options
| -rw-r--r-- | Documentation/devicetree/bindings/spi/fsl-spi.txt | 6 | ||||
| -rw-r--r-- | drivers/spi/spi-fsl-espi.c | 34 |
2 files changed, 36 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/spi/fsl-spi.txt b/Documentation/devicetree/bindings/spi/fsl-spi.txt index b032dd76e9d2..a2331372068c 100644 --- a/Documentation/devicetree/bindings/spi/fsl-spi.txt +++ b/Documentation/devicetree/bindings/spi/fsl-spi.txt | |||
| @@ -42,6 +42,10 @@ Required properties: | |||
| 42 | - interrupts : should contain eSPI interrupt, the device has one interrupt. | 42 | - interrupts : should contain eSPI interrupt, the device has one interrupt. |
| 43 | - fsl,espi-num-chipselects : the number of the chipselect signals. | 43 | - fsl,espi-num-chipselects : the number of the chipselect signals. |
| 44 | 44 | ||
| 45 | Optional properties: | ||
| 46 | - fsl,csbef: chip select assertion time in bits before frame starts | ||
| 47 | - fsl,csaft: chip select negation time in bits after frame ends | ||
| 48 | |||
| 45 | Example: | 49 | Example: |
| 46 | spi@110000 { | 50 | spi@110000 { |
| 47 | #address-cells = <1>; | 51 | #address-cells = <1>; |
| @@ -51,4 +55,6 @@ Example: | |||
| 51 | interrupts = <53 0x2>; | 55 | interrupts = <53 0x2>; |
| 52 | interrupt-parent = <&mpic>; | 56 | interrupt-parent = <&mpic>; |
| 53 | fsl,espi-num-chipselects = <4>; | 57 | fsl,espi-num-chipselects = <4>; |
| 58 | fsl,csbef = <1>; | ||
| 59 | fsl,csaft = <1>; | ||
| 54 | }; | 60 | }; |
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index e767f5831b9c..24096c84e9c4 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
| @@ -586,8 +586,10 @@ static struct spi_master * fsl_espi_probe(struct device *dev, | |||
| 586 | struct spi_master *master; | 586 | struct spi_master *master; |
| 587 | struct mpc8xxx_spi *mpc8xxx_spi; | 587 | struct mpc8xxx_spi *mpc8xxx_spi; |
| 588 | struct fsl_espi_reg *reg_base; | 588 | struct fsl_espi_reg *reg_base; |
| 589 | u32 regval; | 589 | struct device_node *nc; |
| 590 | int i, ret = 0; | 590 | const __be32 *prop; |
| 591 | u32 regval, csmode; | ||
| 592 | int i, len, ret = 0; | ||
| 591 | 593 | ||
| 592 | master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi)); | 594 | master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi)); |
| 593 | if (!master) { | 595 | if (!master) { |
| @@ -634,8 +636,32 @@ static struct spi_master * fsl_espi_probe(struct device *dev, | |||
| 634 | mpc8xxx_spi_write_reg(®_base->event, 0xffffffff); | 636 | mpc8xxx_spi_write_reg(®_base->event, 0xffffffff); |
| 635 | 637 | ||
| 636 | /* Init eSPI CS mode register */ | 638 | /* Init eSPI CS mode register */ |
| 637 | for (i = 0; i < pdata->max_chipselect; i++) | 639 | for_each_available_child_of_node(master->dev.of_node, nc) { |
| 638 | mpc8xxx_spi_write_reg(®_base->csmode[i], CSMODE_INIT_VAL); | 640 | /* get chip select */ |
| 641 | prop = of_get_property(nc, "reg", &len); | ||
| 642 | if (!prop || len < sizeof(*prop)) | ||
| 643 | continue; | ||
| 644 | i = be32_to_cpup(prop); | ||
| 645 | if (i < 0 || i >= pdata->max_chipselect) | ||
| 646 | continue; | ||
| 647 | |||
| 648 | csmode = CSMODE_INIT_VAL; | ||
| 649 | /* check if CSBEF is set in device tree */ | ||
| 650 | prop = of_get_property(nc, "fsl,csbef", &len); | ||
| 651 | if (prop && len >= sizeof(*prop)) { | ||
| 652 | csmode &= ~(CSMODE_BEF(0xf)); | ||
| 653 | csmode |= CSMODE_BEF(be32_to_cpup(prop)); | ||
| 654 | } | ||
| 655 | /* check if CSAFT is set in device tree */ | ||
| 656 | prop = of_get_property(nc, "fsl,csaft", &len); | ||
| 657 | if (prop && len >= sizeof(*prop)) { | ||
| 658 | csmode &= ~(CSMODE_AFT(0xf)); | ||
| 659 | csmode |= CSMODE_AFT(be32_to_cpup(prop)); | ||
| 660 | } | ||
| 661 | mpc8xxx_spi_write_reg(®_base->csmode[i], csmode); | ||
| 662 | |||
| 663 | dev_info(dev, "cs=%d, init_csmode=0x%x\n", i, csmode); | ||
| 664 | } | ||
| 639 | 665 | ||
| 640 | /* Enable SPI interface */ | 666 | /* Enable SPI interface */ |
| 641 | regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; | 667 | regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; |
