linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-omap@vger.kernel.org
Cc: Nishanth Menon <nm@ti.com>, Paul Walmsley <paul@pwsan.com>,
	Dave Gerlach <d-gerlach@ti.com>,
	linux-kernel@vger.kernel.org, Tero Kristo <t-kristo@ti.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/12] ARM: OMAP2+: Add checks for device tree based sysconfig data
Date: Fri, 23 Feb 2018 13:00:57 -0800	[thread overview]
Message-ID: <20180223210100.86732-10-tony@atomide.com> (raw)
In-Reply-To: <20180223210100.86732-1-tony@atomide.com>

We can check the device tree based sysconfig data against the existing
platform data to make sure we're not introducing regressions. Then at
some point after the sysconfig data comes from device tree, we can just
drop the related platform data.

Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/omap_hwmod.c | 109 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 106 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -3062,6 +3062,53 @@ int __init omap_hwmod_setup_one(const char *oh_name)
 	return 0;
 }
 
+static void omap_hwmod_check_one(struct device *dev,
+				 const char *name, s8 v1, u8 v2)
+{
+	if (v1 < 0)
+		return;
+
+	if (v1 != v2)
+		dev_warn(dev, "%s %d != %d\n", name, v1, v2);
+}
+
+/**
+ * omap_hwmod_check_sysc - check sysc against platform sysc
+ * @dev: struct device
+ * @data: module data
+ * @sysc_fields: new sysc configuration
+ */
+static int omap_hwmod_check_sysc(struct device *dev,
+				 const struct ti_sysc_module_data *data,
+				 struct sysc_regbits *sysc_fields)
+{
+	const struct sysc_regbits *regbits = data->cap->regbits;
+
+	omap_hwmod_check_one(dev, "dmadisable_shift",
+			     regbits->dmadisable_shift,
+			     sysc_fields->dmadisable_shift);
+	omap_hwmod_check_one(dev, "midle_shift",
+			     regbits->midle_shift,
+			     sysc_fields->midle_shift);
+	omap_hwmod_check_one(dev, "sidle_shift",
+			     regbits->sidle_shift,
+			     sysc_fields->sidle_shift);
+	omap_hwmod_check_one(dev, "clkact_shift",
+			     regbits->clkact_shift,
+			     sysc_fields->clkact_shift);
+	omap_hwmod_check_one(dev, "enwkup_shift",
+			     regbits->enwkup_shift,
+			     sysc_fields->enwkup_shift);
+	omap_hwmod_check_one(dev, "srst_shift",
+			     regbits->srst_shift,
+			     sysc_fields->srst_shift);
+	omap_hwmod_check_one(dev, "autoidle_shift",
+			     regbits->autoidle_shift,
+			     sysc_fields->autoidle_shift);
+
+	return 0;
+}
+
 /**
  * omap_hwmod_init_regbits - init sysconfig specific register bits
  * @dev: struct device
@@ -3111,7 +3158,7 @@ static int omap_hwmod_init_regbits(struct device *dev,
 		return -EINVAL;
 	}
 
-	return 0;
+	return omap_hwmod_check_sysc(dev, data, *sysc_fields);
 }
 
 /**
@@ -3249,6 +3296,59 @@ int omap_hwmod_init_idlemodes(struct device *dev,
 	return 0;
 }
 
+/**
+ * omap_hwmod_check_module - check new module against platform data
+ * @dev: struct device
+ * @oh: module
+ * @data: new module data
+ * @sysc_fields: sysc register bits
+ * @rev_offs: revision register offset
+ * @sysc_offs: sysconfig register offset
+ * @syss_offs: sysstatus register offset
+ * @sysc_flags: sysc specific flags
+ * @idlemodes: sysc supported idlemodes
+ */
+static int omap_hwmod_check_module(struct device *dev,
+				   struct omap_hwmod *oh,
+				   const struct ti_sysc_module_data *data,
+				   struct sysc_regbits *sysc_fields,
+				   u32 rev_offs, u32 sysc_offs,
+				   u32 syss_offs, u32 sysc_flags,
+				   u32 idlemodes)
+{
+	if (!oh->class->sysc)
+		return -ENODEV;
+
+	if (sysc_fields != oh->class->sysc->sysc_fields)
+		dev_warn(dev, "sysc_fields %p != %p\n", sysc_fields,
+			 oh->class->sysc->sysc_fields);
+
+	if (rev_offs != oh->class->sysc->rev_offs)
+		dev_warn(dev, "rev_offs %08x != %08x\n", rev_offs,
+			 oh->class->sysc->rev_offs);
+	if (sysc_offs != oh->class->sysc->sysc_offs)
+		dev_warn(dev, "sysc_offs %08x != %08x\n", sysc_offs,
+			 oh->class->sysc->sysc_offs);
+	if (syss_offs != oh->class->sysc->syss_offs)
+		dev_warn(dev, "syss_offs %08x != %08x\n", syss_offs,
+			 oh->class->sysc->syss_offs);
+
+	if (sysc_flags != oh->class->sysc->sysc_flags)
+		dev_warn(dev, "sysc_flags %08x != %08x\n", sysc_flags,
+			 oh->class->sysc->sysc_flags);
+
+	if (idlemodes != oh->class->sysc->idlemodes)
+		dev_warn(dev, "idlemodes %08x != %08x\n", idlemodes,
+			 oh->class->sysc->idlemodes);
+
+	if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay)
+		dev_warn(dev, "srst_udelay %i != %i\n",
+			 data->cfg->srst_udelay,
+			 oh->class->sysc->srst_udelay);
+
+	return 0;
+}
+
 /**
  * omap_hwmod_allocate_module - allocate new module
  * @dev: struct device
@@ -3359,8 +3459,11 @@ int omap_hwmod_init_module(struct device *dev,
 	if (data->cfg->quirks & SYSC_QUIRK_NO_RESET_ON_INIT)
 		oh->flags |= HWMOD_INIT_NO_RESET;
 
-	if (oh->class->sysc)
-		return 0;
+	error = omap_hwmod_check_module(dev, oh, data, sysc_fields,
+					rev_offs, sysc_offs, syss_offs,
+					sysc_flags, idlemodes);
+	if (!error)
+		return error;
 
 	return omap_hwmod_allocate_module(dev, oh, data, sysc_fields,
 					  rev_offs, sysc_offs, syss_offs,
-- 
2.16.2

  parent reply	other threads:[~2018-02-23 21:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 21:00 [PATCH 00/12] Use dts data for ti-sysc to configure sysconfig Tony Lindgren
2018-02-23 21:00 ` [PATCH 01/12] bus: ti-sysc: Add fck clock alias for children with notifier_block Tony Lindgren
2018-02-23 21:00 ` [PATCH 02/12] bus: ti-sysc: Add suspend and resume handling Tony Lindgren
2018-02-23 21:00 ` [PATCH 03/12] bus: ti-sysc: Handle stdout-path for debug console Tony Lindgren
2018-02-23 21:00 ` [PATCH 04/12] bus: ti-sysc: Improve handling for no-reset-on-init and no-idle-on-init Tony Lindgren
2018-02-23 21:00 ` [PATCH 05/12] bus: ti-sysc: Remove unnecessary debugging statements Tony Lindgren
2018-02-23 21:00 ` [PATCH 06/12] bus: ti-sysc: Add support for platform data callbacks Tony Lindgren
2018-02-23 21:00 ` [PATCH 07/12] bus: ti-sysc: Handle some devices in omap_device compatible way Tony Lindgren
2018-03-01  0:37   ` Tony Lindgren
2018-02-23 21:00 ` [PATCH 08/12] ARM: OMAP2+: Add functions to allocate module data from device tree Tony Lindgren
2018-02-23 21:00 ` Tony Lindgren [this message]
2018-02-23 21:00 ` [PATCH 10/12] ARM: OMAP2+: Try to parse earlycon from parent too Tony Lindgren
2018-02-23 21:00 ` [PATCH 11/12] PM / AVS: SmartReflex: Prepare to use device tree based probing Tony Lindgren
2018-02-26 10:37   ` Rafael J. Wysocki
2018-02-26 21:34     ` Tony Lindgren
2018-03-01  3:07   ` Kevin Hilman
2018-03-01  3:49     ` Tony Lindgren
2018-02-23 21:01 ` [PATCH 12/12] ARM: OMAP2+: Enable ti-sysc to use device tree data for smartreflex Tony Lindgren
2018-02-23 21:41 ` [PATCH 0.5/12] ARM: OMAP2+: Prepare to pass auxdata " Tony Lindgren
2018-02-26  8:37   ` kbuild test robot
2018-02-26 22:23     ` Tony Lindgren

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=20180223210100.86732-10-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=d-gerlach@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=paul@pwsan.com \
    --cc=t-kristo@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).