Skip to content

Commit

Permalink
mfd: intel-m10-bmc: Create m10bmc_sys_update_bits()
Browse files Browse the repository at this point in the history
Wrap regmap_update_bits() with m10bmc_sys_update_bits() in order to be
able to add additional checks into it.

Co-developed-by: Russ Weight <[email protected]>
Signed-off-by: Russ Weight <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
Reviewed-by: Xu Yilun <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
ij-intel authored and lag-linaro committed Jun 15, 2023
1 parent b3ecc7f commit c452e3b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
30 changes: 14 additions & 16 deletions drivers/fpga/intel-m10-bmc-sec-update.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,11 @@ static enum fw_upload_err rsu_update_init(struct m10bmc_sec *sec)
u32 doorbell_reg, progress, status;
int ret, err;

ret = regmap_update_bits(sec->m10bmc->regmap,
csr_map->base + csr_map->doorbell,
DRBL_RSU_REQUEST | DRBL_HOST_STATUS,
DRBL_RSU_REQUEST |
FIELD_PREP(DRBL_HOST_STATUS,
HOST_STATUS_IDLE));
ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell,
DRBL_RSU_REQUEST | DRBL_HOST_STATUS,
DRBL_RSU_REQUEST |
FIELD_PREP(DRBL_HOST_STATUS,
HOST_STATUS_IDLE));
if (ret)
return FW_UPLOAD_ERR_RW_ERROR;

Expand Down Expand Up @@ -450,11 +449,10 @@ static enum fw_upload_err rsu_send_data(struct m10bmc_sec *sec)
u32 doorbell_reg, status;
int ret;

ret = regmap_update_bits(sec->m10bmc->regmap,
csr_map->base + csr_map->doorbell,
DRBL_HOST_STATUS,
FIELD_PREP(DRBL_HOST_STATUS,
HOST_STATUS_WRITE_DONE));
ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell,
DRBL_HOST_STATUS,
FIELD_PREP(DRBL_HOST_STATUS,
HOST_STATUS_WRITE_DONE));
if (ret)
return FW_UPLOAD_ERR_RW_ERROR;

Expand Down Expand Up @@ -517,11 +515,10 @@ static enum fw_upload_err rsu_cancel(struct m10bmc_sec *sec)
if (rsu_prog(doorbell) != RSU_PROG_READY)
return FW_UPLOAD_ERR_BUSY;

ret = regmap_update_bits(sec->m10bmc->regmap,
csr_map->base + csr_map->doorbell,
DRBL_HOST_STATUS,
FIELD_PREP(DRBL_HOST_STATUS,
HOST_STATUS_ABORT_RSU));
ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell,
DRBL_HOST_STATUS,
FIELD_PREP(DRBL_HOST_STATUS,
HOST_STATUS_ABORT_RSU));
if (ret)
return FW_UPLOAD_ERR_RW_ERROR;

Expand Down Expand Up @@ -764,3 +761,4 @@ module_platform_driver(intel_m10bmc_sec_driver);
MODULE_AUTHOR("Intel Corporation");
MODULE_DESCRIPTION("Intel MAX10 BMC Secure Update");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(INTEL_M10_BMC_CORE);
9 changes: 9 additions & 0 deletions drivers/mfd/intel-m10-bmc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
#include <linux/mfd/intel-m10-bmc.h>
#include <linux/module.h>

int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset,
unsigned int msk, unsigned int val)
{
const struct m10bmc_csr_map *csr_map = m10bmc->info->csr_map;

return regmap_update_bits(m10bmc->regmap, csr_map->base + offset, msk, val);
}
EXPORT_SYMBOL_NS_GPL(m10bmc_sys_update_bits, INTEL_M10_BMC_CORE);

static ssize_t bmc_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
Expand Down
4 changes: 4 additions & 0 deletions include/linux/mfd/intel-m10-bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ struct intel_m10bmc {
*
* m10bmc_raw_read - read m10bmc register per addr
* m10bmc_sys_read - read m10bmc system register per offset
* m10bmc_sys_update_bits - update m10bmc system register per offset
*/
static inline int
m10bmc_raw_read(struct intel_m10bmc *m10bmc, unsigned int addr,
Expand Down Expand Up @@ -282,6 +283,9 @@ static inline int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offs
return m10bmc_raw_read(m10bmc, csr_map->base + offset, val);
}

int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset,
unsigned int msk, unsigned int val);

/*
* MAX10 BMC Core support
*/
Expand Down

0 comments on commit c452e3b

Please sign in to comment.