ocp: Add I2C control support for Adva TimeCard
PATCH 1/1 ocp: Add I2C control support for Adva TimeCard
- Load i2c-dev module to expose /dev/i2c-N character devices
- Add sysfs-based I2C bus control for Adva TimeCard model
Signed-off-by Sagi Maimon <[email protected]>
--- drivers/ptp/ptp_ocp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/ptp/ptp_ocp.c +30 -0
@@ -4224,6 +4224,34 @@ static const struct ocp_attr_group art_timecard_groups[] = { { }, }; +static ssize_t +i2c_bus_ctrl_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct ptp_ocp *bp =dev_get_drvdata (dev); + +if (!bp->pps_select) +return -ENODEV ; +return sysfs_emit (buf,"0x%08x\n" , +ioread32 (&bp->pps_select->__pad1)); +} + +static ssize_t +i2c_bus_ctrl_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct ptp_ocp *bp =dev_get_drvdata (dev); +u32 val; + +if (!bp->pps_select) +return -ENODEV ; +if (kstrtou32 (buf,0 , &val)) +return -EINVAL ; +iowrite32 (val, &bp->pps_select->__pad1); +return count; +} + +static DEVICE_ATTR_RW (i2c_bus_ctrl); +static struct attribute *adva_timecard_attrs[] = { &dev_attr_serialnum.attr, &dev_attr_gnss_sync.attr,
@@ -4272,6 +4300,7 @@ static struct attribute *adva_timecard_x1_attrs[] = { &dev_attr_ts_window_adjust.attr, &dev_attr_utc_tai_offset.attr, &dev_attr_tod_correction.attr, + &dev_attr_i2c_bus_ctrl.attr, NULL, };
@@ -5235,6 +5264,7 @@ ptp_ocp_init(void)const char *what;int err; +request_module ("i2c-dev" );ptp_ocp_debugfs_init (); what ="timecard class" ;
Signature · 1 line
2.47.0
Quoted 2 lines · Sagi Maimon
- Load i2c-dev module to expose
/dev/i2c-Ncharacter devices
- Add sysfs-based I2C bus control for Adva TimeCard model
A list like this suggests the patch should actually be two patches. Also, the commit message should answer the question "Why?". I can see what you have done by reading the patch. But Why have you done it?
drivers/ptp/ptp_ocp.c ptp_ocp_init(void) · line 5267
Quoted 1 line
drivers/ptp/ptp_ocp.c +1
-0+request_module ("i2c-dev" );
linux/drivers$ grep -r i2c-dev | grep request
grep: i2c/i2c-dev.o: binary file matches
No other drive does this. Why is this driver special?
Andrew
---
pw-bot: cr