Commit b50113cb authored by Linus Walleij's avatar Linus Walleij

soc: ixp4xx: Add features from regmap helper

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220211223238.648934-7-linus.walleij@linaro.orgSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent bb3f6e55
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define __SOC_IXP4XX_CPU_H__ #define __SOC_IXP4XX_CPU_H__
#include <linux/io.h> #include <linux/io.h>
#include <linux/regmap.h>
#ifdef CONFIG_ARM #ifdef CONFIG_ARM
#include <asm/cputype.h> #include <asm/cputype.h>
#endif #endif
...@@ -23,6 +24,9 @@ ...@@ -23,6 +24,9 @@
#define IXP46X_PROCESSOR_ID_VALUE 0x69054200 /* including IXP455 */ #define IXP46X_PROCESSOR_ID_VALUE 0x69054200 /* including IXP455 */
#define IXP46X_PROCESSOR_ID_MASK 0xfffffff0 #define IXP46X_PROCESSOR_ID_MASK 0xfffffff0
/* Feature register in the expansion bus controller */
#define IXP4XX_EXP_CNFG2 0x2c
/* "fuse" bits of IXP_EXP_CFG2 */ /* "fuse" bits of IXP_EXP_CFG2 */
/* All IXP4xx CPUs */ /* All IXP4xx CPUs */
#define IXP4XX_FEATURE_RCOMP (1 << 0) #define IXP4XX_FEATURE_RCOMP (1 << 0)
...@@ -89,6 +93,22 @@ ...@@ -89,6 +93,22 @@
u32 ixp4xx_read_feature_bits(void); u32 ixp4xx_read_feature_bits(void);
void ixp4xx_write_feature_bits(u32 value); 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 #else
#define cpu_is_ixp42x_rev_a0() 0 #define cpu_is_ixp42x_rev_a0() 0
#define cpu_is_ixp42x() 0 #define cpu_is_ixp42x() 0
...@@ -101,6 +121,10 @@ static inline u32 ixp4xx_read_feature_bits(void) ...@@ -101,6 +121,10 @@ static inline u32 ixp4xx_read_feature_bits(void)
static inline void ixp4xx_write_feature_bits(u32 value) static inline void ixp4xx_write_feature_bits(u32 value)
{ {
} }
static inline u32 cpu_ixp4xx_features(struct regmap *rmap)
{
return 0;
}
#endif #endif
#endif /* _ASM_ARCH_CPU_H */ #endif /* _ASM_ARCH_CPU_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment