Skip to contentSkip to conversation

Some improvement for Intel MAX 10 MFD drivers

PATCH In review Xu Yilun 2 participants 6 messages Mar 10, 2021

Subsystems (2)
lore
Share & tools
lore

Xu Yilun

author maintainer
#0 lore raw

v4 cover Some improvement for Intel MAX 10 MFD drivers

This patchset is some improvements for intel-m10-bmc and its subdevs.

Main changes from v1:
- Add a patch (#2) to simplify the definition of the legacy version reg.
- Add a patch (#4), add entry in MAINTAINERS for intel-m10-bmc mfd driver and the subdev drivers.

Main changes from v2:
- Add Tom Rix as the reviewer for intel-m10-bmc mfd driver and the subdev drivers.
- Rebased to 5.12-rc1

Main changes from v3:
- Improve the comments for valid version check.

Matthew Gerlach (1):
mfd: intel-m10-bmc: Add access table configuration to the regmap

Xu Yilun (3):
mfd: intel-m10-bmc: Fix the register access range
mfd: intel-m10-bmc: Simplify the legacy version reg definition
MAINTAINERS: Add entry for Intel MAX 10 mfd driver

 MAINTAINERS                       | 10 ++++++++++
 drivers/mfd/intel-m10-bmc.c       | 30 ++++++++++++++++++++----------
 include/linux/mfd/intel-m10-bmc.h |  7 +++++--
 3 files changed, 35 insertions(+), 12 deletions(-)
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v4 1/4 mfd: intel-m10-bmc: Fix the register access range

This patch fixes the max register address of MAX 10 BMC. The range 0x20000000 ~ 0x200000fc are for control registers of the QSPI flash controller, which are not accessible to host.

---
v2: no change.
v3: no change, rebased to 5.12-rc1
v4: add Lee's Acked-by, no other change.

---
 include/linux/mfd/intel-m10-bmc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/intel-m10-bmc.h +1 -1
index 74d4e19..9b54ca1 100644
@@ -11,7 +11,7 @@
 
 #define M10BMC_LEGACY_SYS_BASE		0x300400
 #define M10BMC_SYS_BASE			0x300800
-#define M10BMC_MEM_END			0x200000fc
+#define M10BMC_MEM_END			0x1fffffff
 
 /* Register offset of system registers */
 #define NIOS2_FW_VERSION		0x0
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH v4 2/4 mfd: intel-m10-bmc: Simplify the legacy version reg definition

In reply to Xu Yilun

The version register is the only one in the legacy I/O space to be accessed, so it is not necessary to define the legacy base & version register offset. A direct definition of the legacy version register address would be fine.

---
v3: no change, rebased to 5.12-rc1
v4: improve the comments for valid version check.

---
 drivers/mfd/intel-m10-bmc.c       | 17 +++++++----------
 include/linux/mfd/intel-m10-bmc.h |  2 +-
 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/mfd/intel-m10-bmc.c +7 -10
index 06c9775..90d0448 100644
@@ -116,17 +116,14 @@ static int check_m10bmc_version(struct intel_m10bmc *ddata)
 	int ret;
 
 	/*
-	 * This check is to filter out the very old legacy BMC versions,
-	 * M10BMC_LEGACY_SYS_BASE is the offset to this old block of mmio
-	 * registers. In the old BMC chips, the BMC version info is stored
-	 * in this old version register (M10BMC_LEGACY_SYS_BASE +
-	 * M10BMC_BUILD_VER), so its read out value would have not been
-	 * LEGACY_INVALID (0xffffffff). But in new BMC chips that the
-	 * driver supports, the value of this register should be
-	 * LEGACY_INVALID.
+	 * This check is to filter out the very old legacy BMC versions. In the
+	 * old BMC chips, the BMC version info is stored in the old version
+	 * register (M10BMC_LEGACY_BUILD_VER), so its read out value would have
+	 * not been M10BMC_VER_LEGACY_INVALID (0xffffffff). But in new BMC
+	 * chips that the driver supports, the value of this register should be
+	 * M10BMC_VER_LEGACY_INVALID.
 	 */
-	ret = m10bmc_raw_read(ddata,
-			      M10BMC_LEGACY_SYS_BASE + M10BMC_BUILD_VER, &v);
+	ret = m10bmc_raw_read(ddata, M10BMC_LEGACY_BUILD_VER, &v);
 	if (ret)
 		return -ENODEV;
 
include/linux/mfd/intel-m10-bmc.h +1 -1
index 9b54ca1..4f1071f 100644
@@ -9,7 +9,7 @@
 
 #include <linux/regmap.h>
 
-#define M10BMC_LEGACY_SYS_BASE		0x300400
+#define M10BMC_LEGACY_BUILD_VER		0x300468
 #define M10BMC_SYS_BASE			0x300800
 #define M10BMC_MEM_END			0x1fffffff
 
Signature · 1 line
2.7.4
author maintainer
#3 lore raw

PATCH v4 3/4 mfd: intel-m10-bmc: Add access table configuration to the regmap

In reply to Xu Yilun

From: Matthew Gerlach <[email protected]>

This patch adds access tables to the MAX 10 BMC regmap. This prevents the host from accessing the unwanted I/O space. It also filters out the invalid outputs when reading the regmap debugfs interface.

---
v2: Use the new macro M10BMC_LEGACY_BUILD_VER
v3: No change, rebased to 5.12-rc1
v4: Add Lee's Acked-by, no other change

---
 drivers/mfd/intel-m10-bmc.c       | 13 +++++++++++++
 include/linux/mfd/intel-m10-bmc.h |  5 ++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
drivers/mfd/intel-m10-bmc.c +13 -0
index 90d0448..1161933 100644
@@ -23,10 +23,23 @@ static struct mfd_cell m10bmc_pacn3000_subdevs[] = {
 	{ .name = "n3000bmc-secure" },
 };
 
+static const struct regmap_range m10bmc_regmap_range[] = {
+	regmap_reg_range(M10BMC_LEGACY_BUILD_VER, M10BMC_LEGACY_BUILD_VER),
+	regmap_reg_range(M10BMC_SYS_BASE, M10BMC_SYS_END),
+	regmap_reg_range(M10BMC_FLASH_BASE, M10BMC_FLASH_END),
+};
+
+static const struct regmap_access_table m10bmc_access_table = {
+	.yes_ranges	= m10bmc_regmap_range,
+	.n_yes_ranges	= ARRAY_SIZE(m10bmc_regmap_range),
+};
+
 static struct regmap_config intel_m10bmc_regmap_config = {
 	.reg_bits = 32,
 	.val_bits = 32,
 	.reg_stride = 4,
+	.wr_table = &m10bmc_access_table,
+	.rd_table = &m10bmc_access_table,
 	.max_register = M10BMC_MEM_END,
 };
 
include/linux/mfd/intel-m10-bmc.h +4 -1
index 4f1071f..c4eb38c 100644
@@ -11,7 +11,10 @@
 
 #define M10BMC_LEGACY_BUILD_VER		0x300468
 #define M10BMC_SYS_BASE			0x300800
-#define M10BMC_MEM_END			0x1fffffff
+#define M10BMC_SYS_END			0x300fff
+#define M10BMC_FLASH_BASE		0x10000000
+#define M10BMC_FLASH_END		0x1fffffff
+#define M10BMC_MEM_END			M10BMC_FLASH_END
 
 /* Register offset of system registers */
 #define NIOS2_FW_VERSION		0x0
Signature · 1 line
2.7.4
author maintainer
#4 lore raw

PATCH v4 4/4 MAINTAINERS: Add entry for Intel MAX 10 mfd driver

In reply to Xu Yilun

This patch adds maintainer info for Intel MAX 10 mfd driver.

---
v3: Add Tom Rix as the reviewer.
v4: Add Lee's Acked-by, no other change.

---
 MAINTAINERS | 10 ++++++++++
 1 file changed, 10 insertions(+)
MAINTAINERS +10 -0
index b58a469..ab31c01 100644
@@ -9116,6 +9116,16 @@ F:	include/linux/mei_cl_bus.h
 F:	include/uapi/linux/mei.h
 F:	samples/mei/*
 
+INTEL MAX 10 BMC MFD DRIVER
+M:	Xu Yilun <[email protected]>
+R:	Tom Rix <[email protected]>
+S:	Maintained
+F:	Documentation/ABI/testing/sysfs-driver-intel-m10-bmc
+F:	Documentation/hwmon/intel-m10-bmc-hwmon.rst
+F:	drivers/hwmon/intel-m10-bmc-hwmon.c
+F:	drivers/mfd/intel-m10-bmc.c
+F:	include/linux/mfd/intel-m10-bmc.h
+
 INTEL MENLOW THERMAL DRIVER
 M:	Sujith Thomas <[email protected]>
 L:	[email protected]
Signature · 1 line
2.7.4
#5 lore raw
In reply to Xu Yilun
Quoted 7 lines · Xu Yilun

This patchset is some improvements for intel-m10-bmc and its subdevs.

Main changes from v1:
- Add a patch (#2) to simplify the definition of the legacy version reg.
- Add a patch (#4), add entry in MAINTAINERS for intel-m10-bmc mfd driver and the subdev drivers.

Quoted 7 lines

Main changes from v2:
- Add Tom Rix as the reviewer for intel-m10-bmc mfd driver and the subdev drivers.
- Rebased to 5.12-rc1

Main changes from v3:
- Improve the comments for valid version check.

Good enough.

All applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog