|
|
@@ -586,8 +586,10 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
|
|
|
struct spi_master *master;
|
|
|
struct mpc8xxx_spi *mpc8xxx_spi;
|
|
|
struct fsl_espi_reg *reg_base;
|
|
|
- u32 regval;
|
|
|
- int i, ret = 0;
|
|
|
+ struct device_node *nc;
|
|
|
+ const __be32 *prop;
|
|
|
+ u32 regval, csmode;
|
|
|
+ int i, len, ret = 0;
|
|
|
|
|
|
master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
|
|
|
if (!master) {
|
|
|
@@ -634,8 +636,32 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
|
|
|
mpc8xxx_spi_write_reg(®_base->event, 0xffffffff);
|
|
|
|
|
|
/* Init eSPI CS mode register */
|
|
|
- for (i = 0; i < pdata->max_chipselect; i++)
|
|
|
- mpc8xxx_spi_write_reg(®_base->csmode[i], CSMODE_INIT_VAL);
|
|
|
+ for_each_available_child_of_node(master->dev.of_node, nc) {
|
|
|
+ /* get chip select */
|
|
|
+ prop = of_get_property(nc, "reg", &len);
|
|
|
+ if (!prop || len < sizeof(*prop))
|
|
|
+ continue;
|
|
|
+ i = be32_to_cpup(prop);
|
|
|
+ if (i < 0 || i >= pdata->max_chipselect)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ csmode = CSMODE_INIT_VAL;
|
|
|
+ /* check if CSBEF is set in device tree */
|
|
|
+ prop = of_get_property(nc, "fsl,csbef", &len);
|
|
|
+ if (prop && len >= sizeof(*prop)) {
|
|
|
+ csmode &= ~(CSMODE_BEF(0xf));
|
|
|
+ csmode |= CSMODE_BEF(be32_to_cpup(prop));
|
|
|
+ }
|
|
|
+ /* check if CSAFT is set in device tree */
|
|
|
+ prop = of_get_property(nc, "fsl,csaft", &len);
|
|
|
+ if (prop && len >= sizeof(*prop)) {
|
|
|
+ csmode &= ~(CSMODE_AFT(0xf));
|
|
|
+ csmode |= CSMODE_AFT(be32_to_cpup(prop));
|
|
|
+ }
|
|
|
+ mpc8xxx_spi_write_reg(®_base->csmode[i], csmode);
|
|
|
+
|
|
|
+ dev_info(dev, "cs=%d, init_csmode=0x%x\n", i, csmode);
|
|
|
+ }
|
|
|
|
|
|
/* Enable SPI interface */
|
|
|
regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
|