Skip to content

Commit 1228cc5

Browse files
author
Russ Weight
committed
mfd: intel-m10-bmc: Sysfs for time_sync_frequency
Add a sysfs node, time_sync_frequency to, to allow the frequency of timestamp synchronization with the BMC to be modified from the default of 60 seconds. Signed-off-by: Russ Weight <russell.h.weight@intel.com>
1 parent 6cbe087 commit 1228cc5

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
What: /sys/bus/platform/devices/intel-m10-bmc-log.*.auto/time_sync_frequency
2+
Date: Mar 2021
3+
KernelVersion: 5.12
4+
Contact: Russ Weight <russell.h.weight@intel.com>
5+
Description: Read/write. This sysfs node controls the frequency (in
6+
seconds) that the host writes to the MAX10 BMC registers
7+
to synchronize the timestamp registers used for the BMC
8+
error log. Write zero to stop the timestamp synchronization.
9+
Write a non-zero integer value to restart or modify the
10+
update frequency. Reading from this file will return the
11+
same integer value.
12+
Format: "%u".

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,42 @@ static void m10bmc_log_time_sync(struct work_struct *work)
4848
schedule_delayed_work(&log->dwork, log->freq_s * HZ);
4949
}
5050

51+
static ssize_t
52+
time_sync_frequency_store(struct device *dev, struct device_attribute *attr,
53+
const char *buf, size_t count)
54+
{
55+
struct m10bmc_log *ddata = dev_get_drvdata(dev);
56+
unsigned int ret, old_freq = ddata->freq_s;
57+
58+
ret = kstrtouint(buf, 0, &ddata->freq_s);
59+
if (ret)
60+
return ret;
61+
62+
if (old_freq)
63+
cancel_delayed_work_sync(&ddata->dwork);
64+
65+
if (ddata->freq_s)
66+
m10bmc_log_time_sync(&ddata->dwork.work);
67+
68+
return count;
69+
}
70+
71+
static ssize_t
72+
time_sync_frequency_show(struct device *dev, struct device_attribute *attr,
73+
char *buf)
74+
{
75+
struct m10bmc_log *ddata = dev_get_drvdata(dev);
76+
77+
return sysfs_emit(buf, "%u\n", ddata->freq_s);
78+
}
79+
static DEVICE_ATTR_RW(time_sync_frequency);
80+
81+
static struct attribute *m10bmc_log_attrs[] = {
82+
&dev_attr_time_sync_frequency.attr,
83+
NULL,
84+
};
85+
ATTRIBUTE_GROUPS(m10bmc_log);
86+
5187
static int m10bmc_log_probe(struct platform_device *pdev)
5288
{
5389
struct m10bmc_log *ddata;
@@ -78,6 +114,10 @@ static int m10bmc_log_remove(struct platform_device *pdev)
78114
static struct platform_driver intel_m10bmc_log_driver = {
79115
.probe = m10bmc_log_probe,
80116
.remove = m10bmc_log_remove,
117+
.driver = {
118+
.name = "n6010bmc-log",
119+
.dev_groups = m10bmc_log_groups,
120+
},
81121
};
82122
module_platform_driver(intel_m10bmc_log_driver);
83123

0 commit comments

Comments
 (0)