add regmap-spi-avmm & Intel Max10 BMC chip support
Subsystems (4)
Xu Yilun
maintainerv3 cover add regmap-spi-avmm & Intel Max10 BMC chip support
This patchset adds the regmap-spi-avmm to support the Intel SPI Slave to AVMM Bus Bridge (spi-avmm) IP block. It also implements the usercase - the driver of Intel Max10 BMC chip which integrates this IP block.
Patch #1 implements the regmap-spi-avmm.
Patch #2 implements the mfd driver of Intel Max10 BMC chip.
Main changes from v1:
- Split out the regmap-spi-avmm module out of intel-m10-bmc module.
Main changes from v2:
- Refactor the code of regmap-spi-avmm.
- Rewrites the rx flow and simplifies the implementation, collapse some function calls.
- Add bounds checking every time we fill trans_buf & phy_buf.
- Try to configure spi mode on regmap init
- delete regmap_bus.reg_write/reg_read callbacks.
- Squash the bug fixing patch.
- Add the sub devices in mfd_cell for Max10 bmc driver.
- Improve comments and some minor fixes.
Xu Yilun (2):
regmap: add Intel SPI Slave to AVMM Bus Bridge support
mfd: intel-m10-bmc: add Max10 BMC chip support for Intel FPGA PAC
.../ABI/testing/sysfs-driver-intel-m10-bmc | 15 + drivers/base/regmap/Kconfig | 6 +- drivers/base/regmap/Makefile | 1 + drivers/base/regmap/regmap-spi-avmm.c | 735 +++++++++++++++++++++ drivers/mfd/Kconfig | 13 + drivers/mfd/Makefile | 2 + drivers/mfd/intel-m10-bmc.c | 169 +++++ include/linux/mfd/intel-m10-bmc.h | 57 ++ include/linux/regmap.h | 36 + 9 files changed, 1033 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-intel-m10-bmc create mode 100644 drivers/base/regmap/regmap-spi-avmm.c create mode 100644 drivers/mfd/intel-m10-bmc.c create mode 100644 include/linux/mfd/intel-m10-bmc.h
Signature · 1 line
2.7.4
Xu Yilun
maintainerPATCH v3 1/2 regmap: add Intel SPI Slave to AVMM Bus Bridge support
This patch add support for regmap APIs that are intended to be used by the drivers of some SPI slave chips which integrate the "SPI slave to Avalon Master Bridge" (spi-avmm) IP.
The spi-avmm IP acts as a bridge to convert encoded streams of bytes from the host to the chip's internal register read/write on Avalon bus. The driver implements the register read/write operations for a generic SPI master to access the sub devices behind spi-avmm bridge.
---
v2: Split out the regmap-spi-avmm as an independent module.
v3: rewrite the rx flow, now the driver reads one word and parse it
immediately into trans_buf. This simplifies the rx handling.
collapse some function calls.
Add bounds checking every time we fill trans_buf & phy_buf. Try to configure spi mode on regmap init.
delete regmap_bus.reg_write/reg_read callbacks. squash the bug fixing patch.
improve comments and minor fixes.
--- drivers/base/regmap/Kconfig | 6 +- drivers/base/regmap/Makefile | 1 + drivers/base/regmap/regmap-spi-avmm.c | 735 ++++++++++++++++++++++++++++++++++ include/linux/regmap.h | 36 ++ 4 files changed, 777 insertions(+), 1 deletion(-) create mode 100644 drivers/base/regmap/regmap-spi-avmm.c
drivers/base/regmap/Kconfig +5 -1
@@ -4,7 +4,7 @@ # subsystems should select the appropriate symbols. config REGMAP - default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SCCB || REGMAP_I3C) + default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM) select IRQ_DOMAIN if REGMAP_IRQ bool
@@ -53,3 +53,7 @@ config REGMAP_SCCB config REGMAP_I3C tristate depends on I3C + +config REGMAP_SPI_AVMM + tristate + depends on SPI
drivers/base/regmap/Makefile +1 -0
@@ -17,3 +17,4 @@ obj-$(CONFIG_REGMAP_W1) += regmap-w1.o obj-$(CONFIG_REGMAP_SOUNDWIRE) += regmap-sdw.o obj-$(CONFIG_REGMAP_SCCB) += regmap-sccb.o obj-$(CONFIG_REGMAP_I3C) += regmap-i3c.o +obj-$(CONFIG_REGMAP_SPI_AVMM) += regmap-spi-avmm.o
drivers/base/regmap/regmap-spi-avmm.c new file +735 -0
735 lines not on this page · raw message
include/linux/regmap.h +36 -0
@@ -567,6 +567,10 @@ struct regmap *__regmap_init_sdw(struct sdw_slave *sdw,const struct regmap_config *config, struct lock_class_key *lock_key, const char *lock_name); +struct regmap *__regmap_init_spi_avmm (struct spi_device *spi, +const struct regmap_config *config, +struct lock_class_key *lock_key, +const char *lock_name); struct regmap *__devm_regmap_init(struct device *dev, const struct regmap_bus *bus,
@@ -620,6 +624,10 @@ struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c,const struct regmap_config *config, struct lock_class_key *lock_key, const char *lock_name); +struct regmap *__devm_regmap_init_spi_avmm (struct spi_device *spi, +const struct regmap_config *config, +struct lock_class_key *lock_key, +const char *lock_name);/* * Wrapper for regmap_init macros to include a unique lockdep key and name * for each call. No-op if CONFIG_LOCKDEP is not set.
@@ -806,6 +814,19 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \ sdw, config) +/** +* regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave +* to AVMM Bus Bridge +* +* @spi: Device that will be interacted with +* @config: Configuration for register map +* +* The return value will be an ERR_PTR() on error or a valid pointer +* to a struct regmap. + */ +#define regmap_init_spi_avmm (spi, config) \ + __regmap_lockdep_wrapper(__regmap_init_spi_avmm, #config, \ + spi, config)/** * devm_regmap_init() - Initialise managed register map
@@ -993,6 +1014,21 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \ i3c, config) +/** +* devm_regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave +* to AVMM Bus Bridge +* +* @spi: Device that will be interacted with +* @config: Configuration for register map +* +* The return value will be an ERR_PTR() on error or a valid pointer +* to a struct regmap. The map will be automatically freed by the +* device management code. + */ +#define devm_regmap_init_spi_avmm (spi, config) \ + __regmap_lockdep_wrapper(__devm_regmap_init_spi_avmm, #config, \ + spi, config) +int regmap_mmio_attach_clk (struct regmap *map,struct clk *clk);void regmap_mmio_detach_clk (struct regmap *map);void regmap_exit (struct regmap *map);
Signature · 1 line
2.7.4
Xu Yilun
maintainerPATCH v3 2/2 mfd: intel-m10-bmc: add Max10 BMC chip support for Intel FPGA PAC
In reply to Xu YilunThis patch implements the basic functions of the BMC chip for some Intel FPGA PCIe Acceleration Cards (PAC). The BMC is implemented using the intel max10 CPLD.
This BMC chip is connected to FPGA by a SPI bus. To provide direct register access from FPGA, the "SPI slave to Avalon Master Bridge" (spi-avmm) IP is integrated in the chip. It converts encoded streams of bytes from the host to the internal register read/write on Avalon bus. So This driver uses the regmap-spi-avmm for register accessing.
---
v2: Split out the regmap-spi-avmm part.
Rename the file intel-m10-bmc-main.c to intel-m10-bmc.c, cause
there is only one source file left for this module now.
v3: add the sub devices in mfd_cell.
some minor fixes.
--- .../ABI/testing/sysfs-driver-intel-m10-bmc | 15 ++ drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 2 + drivers/mfd/intel-m10-bmc.c | 169 +++++++++++++++++++++ include/linux/mfd/intel-m10-bmc.h | 57 +++++++ 5 files changed, 256 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-intel-m10-bmc create mode 100644 drivers/mfd/intel-m10-bmc.c create mode 100644 include/linux/mfd/intel-m10-bmc.h
Documentation/ABI/testing/sysfs-driver-intel-m10-bmc new file +15 -0
@@ -0,0 +1,15 @@ +What: /sys/bus/spi/devices/.../bmc_version +Date: June 2020 +KernelVersion: 5.10 +Contact: Xu Yilun <[email protected]> +Description: Read only. Returns the hardware build version of Intel + MAX10 BMC chip. + Format: "0x%x". + +What: /sys/bus/spi/devices/.../bmcfw_version +Date: June 2020 +KernelVersion: 5.10 +Contact: Xu Yilun <[email protected]> +Description: Read only. Returns the firmware version of Intel MAX10 + BMC chip. + Format: "0x%x".
drivers/mfd/Kconfig +13 -0
@@ -2118,5 +2118,18 @@ config SGI_MFD_IOC3 If you have an SGI Origin, Octane, or a PCI IOC3 card, then say Y. Otherwise say N. +config MFD_INTEL_M10_BMC + tristate "Intel MAX10 Board Management Controller" + depends on SPI_MASTER + select REGMAP_SPI_AVMM + select MFD_CORE + help + Support for the Intel MAX10 board management controller using the + SPI interface. + + This driver provides common support for accessing the device, + additional drivers must be enabled in order to use the functionality + of the device. + endmenu endif
drivers/mfd/Makefile +2 -0
@@ -264,3 +264,5 @@ obj-$(CONFIG_MFD_STMFX) += stmfx.o obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o + +obj-$(CONFIG_MFD_INTEL_M10_BMC) += intel-m10-bmc.o
drivers/mfd/intel-m10-bmc.c new file +169 -0
169 lines not on this page · raw message
include/linux/mfd/intel-m10-bmc.h new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.7.4
Xu Yilun
maintainerHi Brown & jones:
I tried to refacor the regmap code and add comments in this patchset. I made big changes to the rx flow and remove some tricky parts in it.
Would it be more understandable than last version? I'm expecting your comments on it when you have time, thanks in advance.
Yilun
Quoted 42 lines · Xu Yilun
This patchset adds the regmap-spi-avmm to support the Intel SPI Slave to AVMM Bus Bridge (spi-avmm) IP block. It also implements the usercase - the driver of Intel Max10 BMC chip which integrates this IP block.
Patch #1 implements the regmap-spi-avmm.
Patch #2 implements the mfd driver of Intel Max10 BMC chip.Main changes from v1:
- Split out the regmap-spi-avmm module out of intel-m10-bmc module.Main changes from v2:
- Refactor the code of regmap-spi-avmm.
- Rewrites the rx flow and simplifies the implementation, collapse some function calls.
- Add bounds checking every time we filltrans_buf&phy_buf.
- Try to configure spi mode on regmap init
- delete regmap_bus.reg_write/reg_read callbacks.
- Squash the bug fixing patch.
- Add the sub devices inmfd_cellfor Max10 bmc driver.
- Improve comments and some minor fixes.Xu Yilun (2):
regmap: add Intel SPI Slave to AVMM Bus Bridge support
mfd: intel-m10-bmc: add Max10 BMC chip support for Intel FPGA PAC.../ABI/testing/sysfs-driver-intel-m10-bmc | 15 + drivers/base/regmap/Kconfig | 6 +- drivers/base/regmap/Makefile | 1 + drivers/base/regmap/regmap-spi-avmm.c | 735 +++++++++++++++++++++ drivers/mfd/Kconfig | 13 + drivers/mfd/Makefile | 2 + drivers/mfd/intel-m10-bmc.c | 169 +++++ include/linux/mfd/intel-m10-bmc.h | 57 ++ include/linux/regmap.h | 36 + 9 files changed, 1033 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-intel-m10-bmc create mode 100644 drivers/base/regmap/regmap-spi-avmm.c create mode 100644 drivers/mfd/intel-m10-bmc.c create mode 100644 include/linux/mfd/intel-m10-bmc.hSignature · 1 line
2.7.4
Quoted 7 lines · Xu Yilun
Hi Brown & jones:
I tried to refacor the regmap code and add comments in this patchset. I made big changes to the rx flow and remove some tricky parts in it.
Would it be more understandable than last version? I'm expecting your comments on it when you have time, thanks in advance.
Just resubmit please. We can review the code itself.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Xu Yilun
maintainerQuoted 11 lines · Lee Jones
Quoted 7 lines · Xu Yilun
Hi Brown & jones:
I tried to refacor the regmap code and add comments in this patchset. I made big changes to the rx flow and remove some tricky parts in it.
Would it be more understandable than last version? I'm expecting your comments on it when you have time, thanks in advance.
Just resubmit please. We can review the code itself.
Ok. I'll rebase it to 5.9-rc1 and resubmit it.
Thanks,
Yilun
Quoted 6 lines
Signature · 5 lines
-- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Tom Rix
reviewerYilun,
I was looking at the tx side a bit and think the padding function could be moved into the pkt/phy function. The pky/phy function already is looking for the eop's so reuse it and remove the search for eop and exchange the loops that do char moving and padding to mem* functions. The logic is something like. if (tb == tb_end - 1 && !eop_inserted) {
*pb = PKT_EOP;
p_eop = pb;
...
dst_pb = &br->phy_buf[aligned_len];
size_t s = pb - p_eop + 1;
/* move EOP and bytes after EOP to the end of aligned size */ memmove(dst_pb - s, p_eop, s);
/* fill the hole with PHY_IDLEs */
memset(p_eop, PHY_IDLE, aligned_len - br->phy_len); /* update the phy data length */
Tom
Quoted 21 lines · Xu Yilun
Quoted 10 lines · Lee Jones
Quoted 7 lines · Xu Yilun
Hi Brown & jones:
I tried to refacor the regmap code and add comments in this patchset. I made big changes to the rx flow and remove some tricky parts in it.
Would it be more understandable than last version? I'm expecting your comments on it when you have time, thanks in advance.
Just resubmit please. We can review the code itself.
Ok. I'll rebase it to 5.9-rc1 and resubmit it.
Thanks,
YilunQuoted 5 lines
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Xu Yilun
maintainerI think that's a good optimization. I'll include this change and send a v4.
Thanks.
Quoted 44 lines · Tom Rix
Yilun,
I was looking at the tx side a bit and think the padding function could be moved into the pkt/phy function. The pky/phy function already is looking for the eop's so reuse it and remove the search for eop and exchange the loops that do char moving and padding to mem* functions. The logic is something like. if (tb ==
tb_end- 1 && !eop_inserted) {
*pb =PKT_EOP;
p_eop= pb;...
dst_pb= &br->phy_buf[aligned_len];
size_ts = pb -p_eop+ 1;
/* move EOP and bytes after EOP to the end of aligned size */memmove(dst_pb - s, p_eop, s);
/* fill the hole withPHY_IDLEs*/
memset(p_eop, PHY_IDLE, aligned_len - br->phy_len); /* update the phy data length */Tom
Quoted 21 lines · Xu Yilun
Quoted 10 lines · Lee Jones
Quoted 7 lines · Xu Yilun
Hi Brown & jones:
I tried to refacor the regmap code and add comments in this patchset. I made big changes to the rx flow and remove some tricky parts in it.
Would it be more understandable than last version? I'm expecting your comments on it when you have time, thanks in advance.
Just resubmit please. We can review the code itself.
Ok. I'll rebase it to 5.9-rc1 and resubmit it.
Thanks,
YilunQuoted 5 lines
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog