[U-Boot] [PATCH v3 5/6] spi: kirkwood: Get drvdata in .ofdata_to_platdata

Jagan Teki jagan at amarulasolutions.com
Mon May 7 09:11:00 UTC 2018


Get the is_errata_50mhz_ac in .ofdata_to_platdata, and
reuse it in .set_mode this can eventually initialized
dt code at once and adding room to add platdata.

Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 drivers/spi/kirkwood_spi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 1ad8cdee64..4850a2b955 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -249,6 +249,7 @@ struct mvebu_spi_dev {
 
 struct mvebu_spi_platdata {
 	struct kwspi_registers *spireg;
+	bool is_errata_50mhz_ac;
 };
 
 struct mvebu_spi_priv {
@@ -310,7 +311,6 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
 {
 	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
 	struct kwspi_registers *reg = plat->spireg;
-	const struct mvebu_spi_dev *drvdata;
 	u32 data = readl(&reg->cfg);
 
 	data &= ~(KWSPI_CPHA | KWSPI_CPOL | KWSPI_RXLSBF | KWSPI_TXLSBF);
@@ -324,8 +324,7 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
 
 	writel(data, &reg->cfg);
 
-	drvdata = (struct mvebu_spi_dev *)dev_get_driver_data(bus);
-	if (drvdata->is_errata_50mhz_ac)
+	if (plat->is_errata_50mhz_ac)
 		mvebu_spi_50mhz_ac_timing_erratum(bus, mode);
 
 	return 0;
@@ -368,8 +367,11 @@ static int mvebu_spi_probe(struct udevice *bus)
 static int mvebu_spi_ofdata_to_platdata(struct udevice *bus)
 {
 	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+	const struct mvebu_spi_dev *drvdata =
+		(struct mvebu_spi_dev *)dev_get_driver_data(bus);
 
 	plat->spireg = (struct kwspi_registers *)devfdt_get_addr(bus);
+	plat->is_errata_50mhz_ac = drvdata->is_errata_50mhz_ac;
 
 	return 0;
 }
-- 
2.14.3



More information about the U-Boot mailing list