[U-Boot] omap3 spi registers

Martin Hejnfelt mh at newtec.dk
Wed May 18 13:51:37 CEST 2016


Hi Vignesh,

How about something like this, naming and so on shamelessly stolen
from the linux kernel:

Index: u-boot-2016.05/drivers/spi/omap3_spi.c
===================================================================
--- u-boot-2016.05.orig/drivers/spi/omap3_spi.c 2016-05-16
16:40:32.000000000 +0200
+++ u-boot-2016.05/drivers/spi/omap3_spi.c 2016-05-18 13:46:18.810353297 +0200
@@ -35,6 +35,12 @@
 #define OMAP3_MCSPI4_BASE 0x480BA000
 #endif

+#define OMAP4_MCSPI_REG_OFFSET 0x100
+
+struct omap2_mcspi_platform_config {
+        unsigned int regs_offset;
+};
+
 /* per-register bitmasks */
 #define OMAP3_MCSPI_SYSCONFIG_SMARTIDLE (2 << 3)
 #define OMAP3_MCSPI_SYSCONFIG_ENAWAKEUP BIT(2)
@@ -623,7 +629,10 @@
  const void *blob = gd->fdt_blob;
  int node = dev->of_offset;

- priv->regs = (struct mcspi *)dev_get_addr(dev);
+ struct omap2_mcspi_platform_config* data =
+ (struct omap2_mcspi_platform_config*)dev_get_driver_data(dev);
+
+ priv->regs = (struct mcspi *)(dev_get_addr(dev) + data->regs_offset);
  priv->pin_dir = fdtdec_get_uint(blob, node, "ti,pindir-d0-out-d1-in",
     MCSPI_PINDIR_D0_IN_D1_OUT);
  priv->wordlen = SPI_DEFAULT_WORDLEN;
@@ -662,9 +671,17 @@
  */
 };

+static struct omap2_mcspi_platform_config omap2_pdata = {
+        .regs_offset = 0,
+};
+
+static struct omap2_mcspi_platform_config omap4_pdata = {
+        .regs_offset = OMAP4_MCSPI_REG_OFFSET,
+};
+
 static const struct udevice_id omap3_spi_ids[] = {
- { .compatible = "ti,omap2-mcspi" },
- { .compatible = "ti,omap4-mcspi" },
+ { .compatible = "ti,omap2-mcspi", .data = (ulong)&omap2_pdata },
+ { .compatible = "ti,omap4-mcspi", .data = (ulong)&omap4_pdata },
  { }
 };

Best regards,
Martin Hejnfelt


More information about the U-Boot mailing list