linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: Qiang Zhao <qiang.zhao@nxp.com>, Leo Li <leoyang.li@nxp.com>
Cc: Scott Wood <oss@buserror.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Timur Tabi <timur@freescale.com>,
	Rasmus Villemoes <Rasmus.Villemoes@prevas.se>
Subject: [PATCH 4/4] soc/fsl/qe: qe.c: support fsl,qe-snums property
Date: Thu, 28 Feb 2019 10:30:43 +0000	[thread overview]
Message-ID: <20190228103026.9566-5-rasmus.villemoes@prevas.dk> (raw)
In-Reply-To: <20190228103026.9566-1-rasmus.villemoes@prevas.dk>

The current code assumes that the set of snum _values_ to populate the
snums[] array with is a function of the _number_ of snums
alone. However, reading table 4-30, and its footnotes, of the QUICC
Engine Block Reference Manual shows that that is a bit too naive.

As an alternative, this introduces a new binding fsl,qe-snums, which
automatically encodes both the number of snums and the actual values to
use. Conveniently, of_property_read_variable_u8_array does exactly
what we need.

For example, for the MPC8309, one would specify the property as

               fsl,qe-snums = /bits/ 8 <
                       0x88 0x89 0x98 0x99 0xa8 0xa9 0xb8 0xb9
                       0xc8 0xc9 0xd8 0xd9 0xe8 0xe9>;

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 .../devicetree/bindings/soc/fsl/cpm_qe/qe.txt      |  8 +++++++-
 drivers/soc/fsl/qe/qe.c                            | 14 +++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt
index d7afaff5faff..05f5f485562a 100644
--- a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt
@@ -18,7 +18,8 @@ Required properties:
 - reg : offset and length of the device registers.
 - bus-frequency : the clock frequency for QUICC Engine.
 - fsl,qe-num-riscs: define how many RISC engines the QE has.
-- fsl,qe-num-snums: define how many serial number(SNUM) the QE can use for the
+- fsl,qe-snums: This property has to be specified as '/bits/ 8' value,
+  defining the array of serial number (SNUM) values for the virtual
   threads.
 
 Optional properties:
@@ -34,6 +35,11 @@ Recommended properties
 - brg-frequency : the internal clock source frequency for baud-rate
   generators in Hz.
 
+Deprecated properties
+- fsl,qe-num-snums: define how many serial number(SNUM) the QE can use
+  for the threads. Use fsl,qe-snums instead to not only specify the
+  number of snums, but also their values.
+
 Example:
      qe@e0100000 {
 	#address-cells = <1>;
diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c
index 71beeb72eee4..049b36d6aeee 100644
--- a/drivers/soc/fsl/qe/qe.c
+++ b/drivers/soc/fsl/qe/qe.c
@@ -283,7 +283,6 @@ EXPORT_SYMBOL(qe_clock_source);
  */
 static void qe_snums_init(void)
 {
-	int i;
 	static const u8 snum_init_76[] = {
 		0x04, 0x05, 0x0C, 0x0D, 0x14, 0x15, 0x1C, 0x1D,
 		0x24, 0x25, 0x2C, 0x2D, 0x34, 0x35, 0x88, 0x89,
@@ -304,9 +303,22 @@ static void qe_snums_init(void)
 		0x28, 0x29, 0x38, 0x39, 0x48, 0x49, 0x58, 0x59,
 		0x68, 0x69, 0x78, 0x79, 0x80, 0x81,
 	};
+	struct device_node *qe;
 	const u8 *snum_init;
+	int i;
 
 	bitmap_zero(snum_state, QE_NUM_OF_SNUM);
+	qe = qe_get_device_node();
+	if (qe) {
+		i = of_property_read_variable_u8_array(qe, "fsl,qe-snums",
+						       snums, 14, QE_NUM_OF_SNUM);
+		of_node_put(qe);
+		if (i > 0) {
+			qe_num_of_snum = i;
+			return;
+		}
+	}
+
 	qe_num_of_snum = qe_get_num_of_snums();
 
 	if (qe_num_of_snum == 76)
-- 
2.20.1


  parent reply	other threads:[~2019-02-28 10:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-26  8:48 [RFC PATCH] soc/fsl/qe: support MPC8309 Rasmus Villemoes
2019-02-28  7:14 ` Qiang Zhao
2019-02-28  8:11   ` Rasmus Villemoes
2019-02-28 10:30     ` [PATCH 0/4] soc/fsl/qe: qe.c: cleanups and support for MPC8309 Rasmus Villemoes
2019-02-28 10:30       ` [PATCH 1/4] soc/fsl/qe: qe.c: drop useless static qualifier Rasmus Villemoes
2019-02-28 10:30       ` [PATCH 2/4] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Rasmus Villemoes
2019-02-28 10:30       ` [PATCH 3/4] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Rasmus Villemoes
2019-02-28 10:30       ` Rasmus Villemoes [this message]
2019-03-01  3:36         ` [PATCH 4/4] soc/fsl/qe: qe.c: support fsl,qe-snums property Qiang Zhao
2019-03-01  7:50           ` Rasmus Villemoes
2019-03-01  9:43             ` Qiang Zhao
2019-03-01 10:21               ` Rasmus Villemoes
2019-03-01 14:57                 ` [PATCH 5/4] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Rasmus Villemoes

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=20190228103026.9566-5-rasmus.villemoes@prevas.dk \
    --to=rasmus.villemoes@prevas.dk \
    --cc=Rasmus.Villemoes@prevas.se \
    --cc=leoyang.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oss@buserror.net \
    --cc=qiang.zhao@nxp.com \
    --cc=timur@freescale.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).