Skip to content

Commit 296f556

Browse files
Russ WeightLee Jones
authored andcommitted
mfd: intel-m10-bmc: Expose MAC address and count
Create two sysfs entries for exposing the MAC address and count from the MAX10 BMC register space. The MAC address is the first in a sequential block of MAC addresses reserved for the FPGA card. The MAC count is the number of MAC addresses in the reserved block. Signed-off-by: Russ Weight <russell.h.weight@intel.com> Signed-off-by: Xu Yilun <yilun.xu@intel.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 92eba68 commit 296f556

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,24 @@ Contact: Xu Yilun <yilun.xu@intel.com>
1313
Description: Read only. Returns the firmware version of Intel MAX10
1414
BMC chip.
1515
Format: "0x%x".
16+
17+
What: /sys/bus/spi/devices/.../mac_address
18+
Date: January 2021
19+
KernelVersion: 5.12
20+
Contact: Russ Weight <russell.h.weight@intel.com>
21+
Description: Read only. Returns the first MAC address in a block
22+
of sequential MAC addresses assigned to the board
23+
that is managed by the Intel MAX10 BMC. It is stored in
24+
FLASH storage and is mirrored in the MAX10 BMC register
25+
space.
26+
Format: "%02x:%02x:%02x:%02x:%02x:%02x".
27+
28+
What: /sys/bus/spi/devices/.../mac_count
29+
Date: January 2021
30+
KernelVersion: 5.12
31+
Contact: Russ Weight <russell.h.weight@intel.com>
32+
Description: Read only. Returns the number of sequential MAC
33+
addresses assigned to the board managed by the Intel
34+
MAX10 BMC. This value is stored in FLASH and is mirrored
35+
in the MAX10 BMC register space.
36+
Format: "%u".

drivers/mfd/intel-m10-bmc.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,52 @@ static ssize_t bmcfw_version_show(struct device *dev,
6060
}
6161
static DEVICE_ATTR_RO(bmcfw_version);
6262

63+
static ssize_t mac_address_show(struct device *dev,
64+
struct device_attribute *attr, char *buf)
65+
{
66+
struct intel_m10bmc *max10 = dev_get_drvdata(dev);
67+
unsigned int macaddr_low, macaddr_high;
68+
int ret;
69+
70+
ret = m10bmc_sys_read(max10, M10BMC_MAC_LOW, &macaddr_low);
71+
if (ret)
72+
return ret;
73+
74+
ret = m10bmc_sys_read(max10, M10BMC_MAC_HIGH, &macaddr_high);
75+
if (ret)
76+
return ret;
77+
78+
return sysfs_emit(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n",
79+
(u8)FIELD_GET(M10BMC_MAC_BYTE1, macaddr_low),
80+
(u8)FIELD_GET(M10BMC_MAC_BYTE2, macaddr_low),
81+
(u8)FIELD_GET(M10BMC_MAC_BYTE3, macaddr_low),
82+
(u8)FIELD_GET(M10BMC_MAC_BYTE4, macaddr_low),
83+
(u8)FIELD_GET(M10BMC_MAC_BYTE5, macaddr_high),
84+
(u8)FIELD_GET(M10BMC_MAC_BYTE6, macaddr_high));
85+
}
86+
static DEVICE_ATTR_RO(mac_address);
87+
88+
static ssize_t mac_count_show(struct device *dev,
89+
struct device_attribute *attr, char *buf)
90+
{
91+
struct intel_m10bmc *max10 = dev_get_drvdata(dev);
92+
unsigned int macaddr_high;
93+
int ret;
94+
95+
ret = m10bmc_sys_read(max10, M10BMC_MAC_HIGH, &macaddr_high);
96+
if (ret)
97+
return ret;
98+
99+
return sysfs_emit(buf, "%u\n",
100+
(u8)FIELD_GET(M10BMC_MAC_COUNT, macaddr_high));
101+
}
102+
static DEVICE_ATTR_RO(mac_count);
103+
63104
static struct attribute *m10bmc_attrs[] = {
64105
&dev_attr_bmc_version.attr,
65106
&dev_attr_bmcfw_version.attr,
107+
&dev_attr_mac_address.attr,
108+
&dev_attr_mac_count.attr,
66109
NULL,
67110
};
68111
ATTRIBUTE_GROUPS(m10bmc);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515

1616
/* Register offset of system registers */
1717
#define NIOS2_FW_VERSION 0x0
18+
#define M10BMC_MAC_LOW 0x10
19+
#define M10BMC_MAC_BYTE4 GENMASK(7, 0)
20+
#define M10BMC_MAC_BYTE3 GENMASK(15, 8)
21+
#define M10BMC_MAC_BYTE2 GENMASK(23, 16)
22+
#define M10BMC_MAC_BYTE1 GENMASK(31, 24)
23+
#define M10BMC_MAC_HIGH 0x14
24+
#define M10BMC_MAC_BYTE6 GENMASK(7, 0)
25+
#define M10BMC_MAC_BYTE5 GENMASK(15, 8)
26+
#define M10BMC_MAC_COUNT GENMASK(23, 16)
1827
#define M10BMC_TEST_REG 0x3c
1928
#define M10BMC_BUILD_VER 0x68
2029
#define M10BMC_VER_MAJOR_MSK GENMASK(23, 16)

0 commit comments

Comments
 (0)