From 566fe1eb1beea1d46e4ef542250ea4137c890dc0 Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Mon, 11 Sep 2023 20:36:39 +0200 Subject: [PATCH] [pddf] Enable deselect logic for CPLDMUX (#14631) This feature was meant to be enabled but was accidentally left disabled. Also downgrades the select/deselect messages to KERN_INFO to reduce log spam. Fixes #14546. Signed-off-by: Christian Svensson --- .../cpldmux/driver/pddf_cpldmux_driver.c | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c b/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c index 2c914b92b..0696819ea 100755 --- a/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c +++ b/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c @@ -27,12 +27,40 @@ extern PDDF_CPLDMUX_DATA pddf_cpldmux_data; -/* Users may overwrite these select and delsect functions as per their requirements - * by overwriting them in custom driver +/* Users may overwrite these select and delsect functions as per their requirements + * by overwriting them in custom driver. + * + * Example driver skeleton: + * + * #include + * #include + * .. + * .. + * #include "pddf_cpldmux_defs.h" + * + * extern PDDF_CPLDMUX_OPS pddf_cpldmux_ops; + * + * int cpldmux_byte_write(struct i2c_client *client, u8 regaddr, u8 val) + * { + * // Provide custom implementation here + * } + * + * int pddf_cpldmux_deselect(struct i2c_mux_core *muxc, uint32_t chan) + * { + * // Provide the custom implementation here + * } + * + * static int __init pddf_custom_cpldmux_init(void) + * { + * pddf_cpldmux_ops.deselect = pddf_cpldmux_deselect; + * pddf_cpldmux_ops.byte_write = cpldmux_byte_write; + * return 0; + * } */ + PDDF_CPLDMUX_OPS pddf_cpldmux_ops = { .select = pddf_cpldmux_select_default, - .deselect = NULL, /* pddf_cpldmux_deselct_default */ + .deselect = pddf_cpldmux_deselect_default, }; EXPORT_SYMBOL(pddf_cpldmux_ops); @@ -69,7 +97,7 @@ int pddf_cpldmux_select_default(struct i2c_mux_core *muxc, uint32_t chan) if ( (pdata->chan_cache!=1) || (private->last_chan!=chan) ) { sdata = &pdata->chan_data[chan]; - pddf_dbg(CPLDMUX, KERN_ERR "%s: Writing 0x%x at 0x%x offset of cpld 0x%x to enable chan %d\n", __FUNCTION__, sdata->cpld_sel, sdata->cpld_offset, sdata->cpld_devaddr, chan); + pddf_dbg(CPLDMUX, KERN_INFO "%s: Writing 0x%x at 0x%x offset of cpld 0x%x to enable chan %d\n", __FUNCTION__, sdata->cpld_sel, sdata->cpld_offset, sdata->cpld_devaddr, chan); ret = cpldmux_byte_write(pdata->cpld, sdata->cpld_offset, (uint8_t)(sdata->cpld_sel & 0xff)); private->last_chan = chan; } @@ -93,7 +121,7 @@ int pddf_cpldmux_deselect_default(struct i2c_mux_core *muxc, uint32_t chan) } sdata = &pdata->chan_data[chan]; - pddf_dbg(CPLDMUX, KERN_ERR "%s: Writing 0x%x at 0x%x offset of cpld 0x%x to disable chan %d", __FUNCTION__, sdata->cpld_desel, sdata->cpld_offset, sdata->cpld_devaddr, chan); + pddf_dbg(CPLDMUX, KERN_INFO "%s: Writing 0x%x at 0x%x offset of cpld 0x%x to disable chan %d", __FUNCTION__, sdata->cpld_desel, sdata->cpld_offset, sdata->cpld_devaddr, chan); ret = cpldmux_byte_write(pdata->cpld, sdata->cpld_offset, (uint8_t)(sdata->cpld_desel)); return ret; }