From: Faiz Abbas <faiz_abbas@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH 4/5] spi: omap3_spi: Read platform data in ofdata_to_platdata()
Date: Wed, 2 Sep 2020 16:48:03 +0530 [thread overview]
Message-ID: <20200902111804.22043-5-faiz_abbas@ti.com> (raw)
In-Reply-To: <20200902111804.22043-1-faiz_abbas@ti.com>
Add an ofdata_to_platdata() callback to access dts in U-boot and
access all platform data in it. This prepares the driver for supporting
both device tree as well as static platform data structures in SPL.
Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
---
drivers/spi/omap3_spi.c | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index fbf9575851..08daacf6f0 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -482,17 +482,10 @@ static int omap3_spi_set_wordlen(struct udevice *dev, unsigned int wordlen)
static int omap3_spi_probe(struct udevice *dev)
{
struct omap3_spi_priv *priv = dev_get_priv(dev);
- const void *blob = gd->fdt_blob;
- int node = dev_of_offset(dev);
+ struct omap3_spi_plat *plat = dev_get_platdata(dev);
- struct omap2_mcspi_platform_config* data =
- (struct omap2_mcspi_platform_config*)dev_get_driver_data(dev);
-
- priv->regs = (struct mcspi *)(dev_read_addr(dev) + data->regs_offset);
- if (fdtdec_get_bool(blob, node, "ti,pindir-d0-out-d1-in"))
- priv->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
- else
- priv->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT;
+ priv->regs = plat->regs;
+ priv->pin_dir = plat->pin_dir;
priv->wordlen = SPI_DEFAULT_WORDLEN;
spi_reset(priv->regs);
@@ -544,6 +537,7 @@ static const struct dm_spi_ops omap3_spi_ops = {
*/
};
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
static struct omap2_mcspi_platform_config omap2_pdata = {
.regs_offset = 0,
};
@@ -552,16 +546,37 @@ static struct omap2_mcspi_platform_config omap4_pdata = {
.regs_offset = OMAP4_MCSPI_REG_OFFSET,
};
+static int omap3_spi_ofdata_to_platdata(struct udevice *dev)
+{
+ struct omap2_mcspi_platform_config *data =
+ (struct omap2_mcspi_platform_config *)dev_get_driver_data(dev);
+ struct omap3_spi_plat *plat = dev_get_platdata(dev);
+
+ plat->regs = (struct mcspi *)(dev_read_addr(dev) + data->regs_offset);
+
+ if (dev_read_bool(dev, "ti,pindir-d0-out-d1-in"))
+ plat->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
+ else
+ plat->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT;
+
+ return 0;
+}
+
static const struct udevice_id omap3_spi_ids[] = {
{ .compatible = "ti,omap2-mcspi", .data = (ulong)&omap2_pdata },
{ .compatible = "ti,omap4-mcspi", .data = (ulong)&omap4_pdata },
{ }
};
-
+#endif
U_BOOT_DRIVER(omap3_spi) = {
.name = "omap3_spi",
.id = UCLASS_SPI,
+ .flags = DM_FLAG_PRE_RELOC,
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
.of_match = omap3_spi_ids,
+ .ofdata_to_platdata = omap3_spi_ofdata_to_platdata,
+ .platdata_auto_alloc_size = sizeof(struct omap3_spi_plat),
+#endif
.probe = omap3_spi_probe,
.ops = &omap3_spi_ops,
.priv_auto_alloc_size = sizeof(struct omap3_spi_priv),
--
2.17.1
next prev parent reply other threads:[~2020-09-02 11:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-02 11:17 [PATCH 0/5] Add spi boot support to am335x-icev2 Faiz Abbas
2020-09-02 11:18 ` [PATCH 1/5] arm: dts: am335x-icev2: Add spi node Faiz Abbas
2020-09-02 11:18 ` [PATCH 2/5] configs: Add spiboot support for am335x Faiz Abbas
2020-09-07 11:29 ` Lokesh Vutla
2020-09-02 11:18 ` [PATCH 3/5] spi: spi-uclass: Block dm_scan_fdt_dev with OF_CONTROL to prevent build failures Faiz Abbas
2020-09-07 6:39 ` Lokesh Vutla
2020-09-10 17:59 ` Jagan Teki
2020-09-02 11:18 ` Faiz Abbas [this message]
2020-09-07 12:12 ` [PATCH 4/5] spi: omap3_spi: Read platform data in ofdata_to_platdata() Vignesh Raghavendra
2020-09-07 12:13 ` Vignesh Raghavendra
2020-09-02 11:18 ` [PATCH 5/5] arm: mach-omap2: am33xx: Add device structure for spi Faiz Abbas
2020-09-07 6:38 ` Lokesh Vutla
2020-09-07 7:06 ` Faiz Abbas
2020-09-07 8:18 ` Vignesh Raghavendra
2020-09-07 10:32 ` Faiz Abbas
2020-09-07 12:19 ` Vignesh Raghavendra
2020-09-08 12:26 ` Faiz Abbas
2020-09-11 2:46 ` [PATCH 0/5] Add spi boot support to am335x-icev2 Lokesh Vutla
2020-09-11 4:37 ` Faiz Abbas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200902111804.22043-5-faiz_abbas@ti.com \
--to=faiz_abbas@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox