All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: linux-arm-kernel@lists.infradead.org,
	Imre Kaloz <kaloz@openwrt.org>,
	Krzysztof Halasa <khalasa@piap.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 06/13 v2] soc: ixp4xx: Add features from regmap helper
Date: Fri, 11 Feb 2022 23:32:31 +0100	[thread overview]
Message-ID: <20220211223238.648934-7-linus.walleij@linaro.org> (raw)
In-Reply-To: <20220211223238.648934-1-linus.walleij@linaro.org>

If we want to read the CFG2 register on the expansion bus and
apply the inversion and check for some hardcoded versions this
helper comes in handy.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- No changes.
---
 include/linux/soc/ixp4xx/cpu.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/linux/soc/ixp4xx/cpu.h b/include/linux/soc/ixp4xx/cpu.h
index 88bd8de0e803..48c2e241ac83 100644
--- a/include/linux/soc/ixp4xx/cpu.h
+++ b/include/linux/soc/ixp4xx/cpu.h
@@ -9,6 +9,7 @@
 #define __SOC_IXP4XX_CPU_H__
 
 #include <linux/io.h>
+#include <linux/regmap.h>
 #ifdef CONFIG_ARM
 #include <asm/cputype.h>
 #endif
@@ -23,6 +24,9 @@
 #define IXP46X_PROCESSOR_ID_VALUE	0x69054200 /* including IXP455 */
 #define IXP46X_PROCESSOR_ID_MASK	0xfffffff0
 
+/* Feature register in the expansion bus controller */
+#define IXP4XX_EXP_CNFG2		0x2c
+
 /* "fuse" bits of IXP_EXP_CFG2 */
 /* All IXP4xx CPUs */
 #define IXP4XX_FEATURE_RCOMP		(1 << 0)
@@ -89,6 +93,22 @@
 
 u32 ixp4xx_read_feature_bits(void);
 void ixp4xx_write_feature_bits(u32 value);
+static inline u32 cpu_ixp4xx_features(struct regmap *rmap)
+{
+	u32 val;
+
+	regmap_read(rmap, IXP4XX_EXP_CNFG2, &val);
+	/* For some reason this register is inverted */
+	val = ~val;
+	if (cpu_is_ixp42x_rev_a0())
+		return IXP42X_FEATURE_MASK & ~(IXP4XX_FEATURE_RCOMP |
+					       IXP4XX_FEATURE_AES);
+	if (cpu_is_ixp42x())
+		return val & IXP42X_FEATURE_MASK;
+	if (cpu_is_ixp43x())
+		return val & IXP43X_FEATURE_MASK;
+	return val & IXP46X_FEATURE_MASK;
+}
 #else
 #define cpu_is_ixp42x_rev_a0()		0
 #define cpu_is_ixp42x()			0
@@ -101,6 +121,10 @@ static inline u32 ixp4xx_read_feature_bits(void)
 static inline void ixp4xx_write_feature_bits(u32 value)
 {
 }
+static inline u32 cpu_ixp4xx_features(struct regmap *rmap)
+{
+	return 0;
+}
 #endif
 
 #endif  /* _ASM_ARCH_CPU_H */
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-02-11 22:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 22:32 [PATCH 00/13 v2] IXP4xx spring cleaning Linus Walleij
2022-02-11 22:32 ` [PATCH 01/13 v2] ARM: ixp4xx: Delete Gateway 7001 boardfiles Linus Walleij
2022-02-11 22:32 ` [PATCH 02/13 v2] ARM: ixp4xx: Delete the Goramo MLR boardfile Linus Walleij
2022-02-11 22:32 ` [PATCH 03/13 v2] ARM: ixp4xx: Delete old PCI driver Linus Walleij
2022-02-11 22:32 ` [PATCH 04/13 v2] ARM: ixp4xx: Drop stale Kconfig entry Linus Walleij
2022-02-11 22:32 ` [PATCH 05/13 v2] ARM: ixp4xx: Drop UDC info setting function Linus Walleij
2022-02-11 22:32 ` Linus Walleij [this message]
2022-02-11 22:32 ` [PATCH 07/13 v2] soc: ixp4xx-npe: Access syscon regs using regmap Linus Walleij
2022-02-11 22:32 ` [PATCH 08/13 v2] net: ixp4xx_eth: Drop platform data support Linus Walleij
2022-02-11 22:32   ` Linus Walleij
2022-02-12  0:37   ` Jakub Kicinski
2022-02-12  0:37     ` Jakub Kicinski
2022-02-11 22:32 ` [PATCH 09/13 v2] net: ixp4xx_hss: Check features using syscon Linus Walleij
2022-02-11 22:32   ` Linus Walleij
2022-02-12  0:38   ` Jakub Kicinski
2022-02-12  0:38     ` Jakub Kicinski
2022-02-11 22:32 ` [PATCH 10/13 v2] ARM: ixp4xx: Remove feature bit accessors Linus Walleij
2022-02-11 22:32 ` [PATCH 11/13 v2] ARM: ixp4xx: Drop custom DMA coherency and bouncing Linus Walleij
2022-02-11 22:32   ` Linus Walleij
2022-02-11 22:32 ` [PATCH 12/13 v2] ARM: ixp4xx: Drop all common code Linus Walleij
2022-02-11 22:32 ` [PATCH 13/13 v2] ARM: ixp4xx: Convert to SPARSE_IRQ and P2V Linus Walleij

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=20220211223238.648934-7-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=kaloz@openwrt.org \
    --cc=khalasa@piap.pl \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.