Skip to content

Commit 14ccbee

Browse files
Figo-zhangRuss Weight
authored andcommitted
mfd: intel-m10-bmc: adding flash sysfs entry
Adding sysfs entries for reading some flash partitions from userspace.
1 parent 5c6ccd7 commit 14ccbee

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

Documentation/ABI/testing/sysfs-driver-intel-m10-bmc-log

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,27 @@ Description: Read/write. This sysfs node controls the frequency (in
1010
update frequency. Reading from this file will return the
1111
same integer value.
1212
Format: "%u".
13+
14+
What: /sys/bus/platform/devices/intel-m10-bmc-log.*.auto/bmc_event_log
15+
Date: April 2021
16+
KernelVersion: 5.13
17+
Contact: Tianfei zhang <tianfei.zhang@intel.com>
18+
Description: Read-only. This file returns the contents of the "error log"
19+
partition in flash. This partition includes the error info for
20+
the BMC.
21+
22+
What: /sys/bus/platform/devices/intel-m10-bmc-log.*.auto/fpga_image_directory
23+
Date: April 2021
24+
KernelVersion: 5.13
25+
Contact: Tianfei zhang <tianfei.zhang@intel.com>
26+
Description: Read-only. This file returns the contents of the "FPGA image
27+
directory" partition in flash. This partition includes
28+
information like the FPGA Image versions and state.
29+
30+
What: /sys/bus/platform/devices/intel-m10-bmc-log.*.auto/bom_info
31+
Date: April 2021
32+
KernelVersion: 5.13
33+
Contact: Tianfei zhang <tianfei.zhang@intel.com>
34+
Description: Read-only. This file returns the contents of the "BOM info"
35+
partition in flash. This partition includes information such
36+
as the BOM critical components, PBA#, MMID.

drivers/mfd/intel-m10-bmc-log.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,60 @@ time_sync_frequency_show(struct device *dev, struct device_attribute *attr,
7878
}
7979
static DEVICE_ATTR_RW(time_sync_frequency);
8080

81+
static ssize_t flash_bin_read(struct kobject *kobj, char *buf, u32 addr,
82+
loff_t off, size_t count)
83+
{
84+
struct device *dev = container_of(kobj, struct device, kobj);
85+
struct m10bmc_log *ddata = dev_get_drvdata(dev);
86+
int ret;
87+
88+
if (!ddata->m10bmc->ops.flash_read)
89+
return -ENODEV;
90+
91+
ret = ddata->m10bmc->ops.flash_read(ddata->m10bmc, buf,
92+
addr + off, count);
93+
if (ret) {
94+
dev_err(ddata->dev, "failed to read flash %x\n", addr);
95+
return -EIO;
96+
}
97+
98+
return count;
99+
}
100+
101+
static ssize_t
102+
bmc_event_log_read(struct file *filp, struct kobject *kobj,
103+
struct bin_attribute *bin_attr, char *buf,
104+
loff_t off, size_t count)
105+
{
106+
return flash_bin_read(kobj, buf, PMCI_ERROR_LOG_ADDR, off,
107+
count);
108+
}
109+
static BIN_ATTR_RO(bmc_event_log, PMCI_ERROR_LOG_SIZE);
110+
111+
static ssize_t
112+
fpga_image_directory_read(struct file *filp, struct kobject *kobj,
113+
struct bin_attribute *bin_attr, char *buf,
114+
loff_t off, size_t count)
115+
{
116+
return flash_bin_read(kobj, buf, PMCI_FPGA_IMAGE_DIR_ADDR, off,
117+
count);
118+
}
119+
static BIN_ATTR_RO(fpga_image_directory, PMCI_FPGA_IMAGE_DIR_SIZE);
120+
121+
static ssize_t bom_info_read(struct file *filp, struct kobject *kobj,
122+
struct bin_attribute *bin_attr, char *buf,
123+
loff_t off, size_t count)
124+
{
125+
return flash_bin_read(kobj, buf, PMCI_BOM_INFO_ADDR, off,
126+
count);
127+
}
128+
static BIN_ATTR_RO(bom_info, PMCI_BOM_INFO_SIZE);
129+
81130
static struct attribute *m10bmc_log_attrs[] = {
82131
&dev_attr_time_sync_frequency.attr,
132+
&bin_attr_bmc_event_log.attr,
133+
&bin_attr_fpga_image_directory.attr,
134+
&bin_attr_bom_info.attr,
83135
NULL,
84136
};
85137
ATTRIBUTE_GROUPS(m10bmc_log);

include/linux/mfd/intel-m10-bmc.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ enum m10bmc_type {
223223
#define PMCI_FPGA_RECONF_PAGE GENMASK(22, 20)
224224
#define PMCI_FPGA_RP_LOAD BIT(23)
225225

226+
#define PMCI_ERROR_LOG_ADDR 0x7fb0000
227+
#define PMCI_ERROR_LOG_SIZE 0x40000
228+
229+
#define PMCI_FPGA_IMAGE_DIR_ADDR 0x7ff6000
230+
#define PMCI_FPGA_IMAGE_DIR_SIZE 0x3000
231+
232+
#define PMCI_BOM_INFO_ADDR 0x7ff0000
233+
#define PMCI_BOM_INFO_SIZE 0x2000
234+
226235
#define m10bmc_base(m10bmc) ((m10bmc)->csr->base)
227236
#define doorbell_reg(m10bmc) ((m10bmc)->csr->doorbell)
228237
#define auth_result_reg(m10bmc) ((m10bmc)->csr->auth_result)

0 commit comments

Comments
 (0)