From ae15a012302d62edecab8d051fed33c0570385d5 Mon Sep 17 00:00:00 2001 From: Guochun Huang Date: Fri, 21 Apr 2023 01:31:11 +0000 Subject: [PATCH] mfd: max96755f: Add patgen_mode debug node Enable pattern: echo 2 > /sys/bus/i2c/devices/x-0040/patgen_mode Disable pattern: echo 0 > /sys/bus/i2c/devices/x-0040/patgen_mode Change-Id: I5bf970210b14f93599a36c78703e53252546da5b Signed-off-by: Guochun Huang --- drivers/mfd/max96755f.c | 20 ++++++++++++++++++++ include/linux/mfd/max96755f.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/mfd/max96755f.c b/drivers/mfd/max96755f.c index 6b7b10339ecf..eef5ef2f1ff5 100644 --- a/drivers/mfd/max96755f.c +++ b/drivers/mfd/max96755f.c @@ -195,8 +195,28 @@ static ssize_t line_fault_monitor_show(struct device *device, static DEVICE_ATTR_RO(line_fault_monitor); +static ssize_t patgen_mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct max96755f *max96755f = dev_get_drvdata(dev); + u8 patgen_mode; + int ret; + + ret = kstrtou8(buf, 0, &patgen_mode); + if (ret) + return ret; + + regmap_update_bits(max96755f->regmap, 0x01e5, PATGEN_MODE, + FIELD_PREP(PATGEN_MODE, patgen_mode)); + + return count; +} +static DEVICE_ATTR_WO(patgen_mode); + static struct attribute *max96755f_attrs[] = { &dev_attr_line_fault_monitor.attr, + &dev_attr_patgen_mode.attr, NULL }; diff --git a/include/linux/mfd/max96755f.h b/include/linux/mfd/max96755f.h index 74b0fff0d24e..eae6da60f66f 100644 --- a/include/linux/mfd/max96755f.h +++ b/include/linux/mfd/max96755f.h @@ -79,6 +79,9 @@ /* 0170h */ #define SPI_EN BIT(0) +/* 01e5h */ +#define PATGEN_MODE GENMASK(1, 0) + /* 02beh */ #define RES_CFG BIT(7) #define TX_PRIO BIT(6)