Add i2c-cp2615
Subsystems (3)
Bence Csókás
maintainerv3 cover Add i2c-cp2615
For a hardware project, I need the I2C master of SiLabs' CP2615 chip to be visible from under Linux. This patchset adds i2c-cp2615, a driver which sets up an i2c_adapter for said chip.
Changes in v3:
* Fixed SPDX header
* Added I2C_AQ_NO_REP_START adapter quirk to i2c.h
* Added I2C_AQ_NO_ZERO_LEN | I2C_AQ_NO_REP_START to CP2615's quirk flags
* Made the driver only bind to the IOP interface
* Return -ENXIO instead of -ECOMM when the device does not ACK
* Formatting, fix almost all warnings and checks from checkpatch --strict
* CamelCase checks remain. These identifiers were taken from SiLabs' Application Note, I thought it made sense to preserve these as-is.
Bence Csókás (2):
i2c: Add I2C_AQ_NO_REP_START adapter quirk
Adding i2c-cp2615: i2c support for Silicon Labs' CP2615 Digital Audio
Bridge
drivers/i2c/busses/Kconfig | 10 ++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-cp2615.c | 279 ++++++++++++++++++++++++++++++++ include/linux/i2c.h | 2 + 4 files changed, 292 insertions(+) create mode 100644 drivers/i2c/busses/i2c-cp2615.c
Signature · 1 line
2.31.0
Bence Csókás
maintainerPATCH v3 1/2 i2c: Add I2C_AQ_NO_REP_START adapter quirk
This quirk signifies that the adapter cannot do a repeated START, it always issues a STOP condition after transfers.
--- include/linux/i2c.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/i2c.h +2 -0
@@ -687,6 +687,8 @@ struct i2c_adapter_quirks {#define I2C_AQ_NO_ZERO_LEN_READ BIT(5)#define I2C_AQ_NO_ZERO_LEN_WRITE BIT(6)#define I2C_AQ_NO_ZERO_LEN (I2C_AQ_NO_ZERO_LEN_READ | I2C_AQ_NO_ZERO_LEN_WRITE) +/* adapter cannot do repeated START */ +#define I2C_AQ_NO_REP_START BIT(7)/* * i2c_adapter is the structure used to identify a physical i2c bus along
Signature · 1 line
2.31.0
Bence Csókás
maintainerPATCH v3 2/2 Adding i2c-cp2615: i2c support for Silicon Labs' CP2615 Digital Audio Bridge
In reply to Bence CsókásCreate an i2c_adapter for CP2615's I2C master interface by implementing parts of the CP2615's I/O Protocol (IOP)
--- drivers/i2c/busses/Kconfig | 10 ++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-cp2615.c | 279 ++++++++++++++++++++++++++++++++ 3 files changed, 290 insertions(+) create mode 100644 drivers/i2c/busses/i2c-cp2615.c
drivers/i2c/busses/Kconfig +10 -0
@@ -1227,6 +1227,16 @@ config I2C_DLN2 This driver can also be built as a module. If so, the module will be called i2c-dln2. +config I2C_CP2615 + tristate "Silicon Labs CP2615 USB sound card and I2C adapter" + depends on USB + help + If you say yes to this option, support will be included for Silicon + Labs CP2615's I2C interface. + + This driver can also be built as a module. If so, the module + will be called i2c-cp2615. + config I2C_PARPORT tristate "Parallel port adapter" depends on PARPORT
drivers/i2c/busses/Makefile +1 -0
@@ -127,6 +127,7 @@ obj-$(CONFIG_I2C_ZX2967) += i2c-zx2967.o # External I2C/SMBus adapter drivers obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o obj-$(CONFIG_I2C_DLN2) += i2c-dln2.o +obj-$(CONFIG_I2C_CP2615) += i2c-cp2615.o obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o
drivers/i2c/busses/i2c-cp2615.c new file +279 -0
279 lines not on this page · raw message
Signature · 1 line
2.31.0
kernel test robot
build botRe: [PATCH v3 2/2] Adding i2c-cp2615: i2c support for Silicon Labs' CP2615 Digital Audio Bridge
Thank you for the patch! Yet something to improve:
Hi "Bence,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v5.12-rc3 next-20210319]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Bence-Cs-k-s/Add-i2c-cp2615/20210318-193822 base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7aa4ceb301ef5116752aef6e09f6ff845dedc106
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Bence-Cs-k-s/Add-i2c-cp2615/20210318-193822
git checkout 7aa4ceb301ef5116752aef6e09f6ff845dedc106
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/i2c/busses/i2c-cp2615.c:78:5: warning: no previous prototype for 'cp2615_init_iop_msg' [-Wmissing-prototypes]
78 | int cp2615_init_iop_msg(struct cp2615_iop_msg *ret, enum cp2615_iop_msg_type msg,
| ^~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:96:5: warning: no previous prototype for 'cp2615_init_i2c_msg' [-Wmissing-prototypes]
96 | int cp2615_init_i2c_msg(struct cp2615_iop_msg *ret, const struct cp2615_i2c_transfer *data)
| ^~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:102:5: warning: no previous prototype for 'cp2615_check_status' [-Wmissing-prototypes]
102 | int cp2615_check_status(enum cp2615_i2c_status status)
| ^~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:266:1: warning: data definition has no type or storage class
266 | MODULE_DEVICE_TABLE(usb, id_table);
| ^~~~~~~~~~~~~~~~~~~
>> drivers/i2c/busses/i2c-cp2615.c:266:1: error: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' [-Werror=implicit-int]
drivers/i2c/busses/i2c-cp2615.c:266:1: warning: parameter names (without types) in function declaration
In file included from include/linux/device.h:32,
from include/linux/acpi.h:15,
from include/linux/i2c.h:13,
from drivers/i2c/busses/i2c-cp2615.c:9:
include/linux/device/driver.h:263:1: warning: data definition has no type or storage class
263 | module_init(__driver##_init); \
| ^~~~~~~~~~~
include/linux/usb.h:1303:2: note: in expansion of macro 'module_driver'
1303 | module_driver(__usb_driver, usb_register, \
| ^~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:275:1: note: in expansion of macro 'module_usb_driver'
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~
>> include/linux/device/driver.h:263:1: error: type defaults to 'int' in declaration of 'module_init' [-Werror=implicit-int]
263 | module_init(__driver##_init); \
| ^~~~~~~~~~~
include/linux/usb.h:1303:2: note: in expansion of macro 'module_driver'
1303 | module_driver(__usb_driver, usb_register, \
| ^~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:275:1: note: in expansion of macro 'module_usb_driver'
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:7,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/linux/i2c.h:13,
from drivers/i2c/busses/i2c-cp2615.c:9:
include/linux/export.h:19:30: warning: parameter names (without types) in function declaration
19 | #define THIS_MODULE ((struct module *)0)
| ^~~~~~
include/linux/usb.h:1290:30: note: in expansion of macro 'THIS_MODULE'
1290 | usb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
| ^~~~~~~~~~~
include/linux/device/driver.h:261:9: note: in expansion of macro 'usb_register'
261 | return __register(&(__driver) , ##__VA_ARGS__); \
| ^~~~~~~~~~
include/linux/usb.h:1303:2: note: in expansion of macro 'module_driver'
1303 | module_driver(__usb_driver, usb_register, \
| ^~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:275:1: note: in expansion of macro 'module_usb_driver'
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/device.h:32,
from include/linux/acpi.h:15,
from include/linux/i2c.h:13,
from drivers/i2c/busses/i2c-cp2615.c:9:
include/linux/device/driver.h:268:1: warning: data definition has no type or storage class
268 | module_exit(__driver##_exit);
| ^~~~~~~~~~~
include/linux/usb.h:1303:2: note: in expansion of macro 'module_driver'
1303 | module_driver(__usb_driver, usb_register, \
| ^~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:275:1: note: in expansion of macro 'module_usb_driver'
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~
>> include/linux/device/driver.h:268:1: error: type defaults to 'int' in declaration of 'module_exit' [-Werror=implicit-int]
268 | module_exit(__driver##_exit);
| ^~~~~~~~~~~
include/linux/usb.h:1303:2: note: in expansion of macro 'module_driver'
1303 | module_driver(__usb_driver, usb_register, \
| ^~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:275:1: note: in expansion of macro 'module_usb_driver'
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:7,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/linux/i2c.h:13,
from drivers/i2c/busses/i2c-cp2615.c:9:
include/linux/export.h:19:30: warning: parameter names (without types) in function declaration
19 | #define THIS_MODULE ((struct module *)0)
| ^~~~~~
include/linux/usb.h:1290:30: note: in expansion of macro 'THIS_MODULE'
1290 | usb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
| ^~~~~~~~~~~
include/linux/device/driver.h:261:9: note: in expansion of macro 'usb_register'
261 | return __register(&(__driver) , ##__VA_ARGS__); \
| ^~~~~~~~~~
include/linux/usb.h:1303:2: note: in expansion of macro 'module_driver'
1303 | module_driver(__usb_driver, usb_register, \
| ^~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:275:1: note: in expansion of macro 'module_usb_driver'
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~
>> drivers/i2c/busses/i2c-cp2615.c:277:15: error: expected declaration specifiers or '...' before string constant
277 | MODULE_AUTHOR("Bence Csókás <[email protected]>");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:278:20: error: expected declaration specifiers or '...' before string constant
278 | MODULE_DESCRIPTION("CP2615 I2C bus driver");
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:279:16: error: expected declaration specifiers or '...' before string constant
279 | MODULE_LICENSE("GPL");
| ^~~~~
In file included from include/linux/device.h:32,
from include/linux/acpi.h:15,
from include/linux/i2c.h:13,
from drivers/i2c/busses/i2c-cp2615.c:9:
drivers/i2c/busses/i2c-cp2615.c:275:19: warning: 'cp2615_i2c_driver_init' defined but not used [-Wunused-function]
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~
include/linux/device/driver.h:259:19: note: in definition of macro 'module_driver'
259 | static int __init __driver##_init(void) \
| ^~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:275:1: note: in expansion of macro 'module_usb_driver'
275 | module_usb_driver(cp2615_i2c_driver);
| ^~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +266 drivers/i2c/busses/i2c-cp2615.c
265
> 266 MODULE_DEVICE_TABLE(usb, id_table);
267
268 static struct usb_driver cp2615_i2c_driver = {
269 .name = "i2c-cp2615",
270 .probe = cp2615_i2c_probe,
271 .disconnect = cp2615_i2c_remove,
272 .id_table = id_table,
273 };
274
275 module_usb_driver(cp2615_i2c_driver);
276
> 277 MODULE_AUTHOR("Bence Csókás <[email protected]>");---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v3 2/2] Adding i2c-cp2615: i2c support for Silicon Labs' CP2615 Digital Audio Bridge
In reply to Bence CsókásQuoted 4 lines · Bence Csókás
Create an
i2c_adapterfor CP2615's I2C master interface by implementing parts of the CP2615's I/O Protocol (IOP)Signed-off-by Bence Csókás <[email protected]>
So, my code checkers report:
SPARSEdrivers/i2c/busses/i2c-cp2615.c:88:21: warning: incorrect type in assignment (different base types)drivers/i2c/busses/i2c-cp2615.c:88:21: expected unsigned short [usertype] lengthdrivers/i2c/busses/i2c-cp2615.c:88:21: got restricted __be16 [usertype]drivers/i2c/busses/i2c-cp2615.c:89:18: warning: incorrect type in assignment (different base types)drivers/i2c/busses/i2c-cp2615.c:89:18: expected unsigned short [usertype] msgdrivers/i2c/busses/i2c-cp2615.c:89:18: got restricted __be16 [usertype]drivers/i2c/busses/i2c-cp2615.c:78:5: warning: symbol 'cp2615_init_iop_msg' was not declared. Should it be static? drivers/i2c/busses/i2c-cp2615.c:96:5: warning: symbol 'cp2615_init_i2c_msg' was not declared. Should it be static? drivers/i2c/busses/i2c-cp2615.c:102:5: warning: symbol 'cp2615_check_status' was not declared. Should it be static? drivers/i2c/busses/i2c-cp2615.c:131:41: warning: cast to restricted __be16drivers/i2c/busses/i2c-cp2615.c:131:41: warning: cast to restricted __be16drivers/i2c/busses/i2c-cp2615.c:131:41: warning: cast to restricted __be16drivers/i2c/busses/i2c-cp2615.c:131:41: warning: cast to restricted __be16drivers/i2c/busses/i2c-cp2615.c:148:25: warning: restricted __be16 degrades to integerdrivers/i2c/busses/i2c-cp2615.c:212:27: warning: symbol 'cp2615_i2c_quirks' was not declared. Should it be static?
CPPCHECKdrivers/i2c/busses/i2c-cp2615.c:258:9: warning: Identical condition and return expression 'ret', return value is always 0 [identicalConditionAfterEarlyExit]
return ret;
^
CC drivers/i2c/busses/i2c-cp2615.o
drivers/i2c/busses/i2c-cp2615.c:78:5: warning: no previous prototype for ‘cp2615_init_iop_msg’ [-Wmissing-prototypes]
78 | int cp2615_init_iop_msg(struct cp2615_iop_msg *ret, enum cp2615_iop_msg_type msg,
| ^~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:96:5: warning: no previous prototype for ‘cp2615_init_i2c_msg’ [-Wmissing-prototypes]
96 | int cp2615_init_i2c_msg(struct cp2615_iop_msg *ret, const struct cp2615_i2c_transfer *data)
| ^~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c:102:5: warning: no previous prototype for ‘cp2615_check_status’ [-Wmissing-prototypes]
102 | int cp2615_check_status(enum cp2615_i2c_status status)
| ^~~~~~~~~~~~~~~~~~~
drivers/i2c/busses/i2c-cp2615.c: In function ‘cp2615_i2c_probe’:
drivers/i2c/busses/i2c-cp2615.c:244:2: warning: ‘strncpy’ specified bound 48 equals destination size [-Wstringop-truncation]
244 | strncpy(adap->name, usbdev->serial, sizeof(adap->name));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The missing 'static' are what buildbot also reported and are correct. Please check the others if they need action. Especially the strncpy thing.
Other than that, it looks good. I like that you bind to the IOP interface only. Keeping the CamelCase is also OK.
Re: [PATCH v3 2/2] Adding i2c-cp2615: i2c support for Silicon Labs' CP2615 Digital Audio Bridge
In reply to Bence CsókásOh, and are you willing to maintain the driver? If so, please add an entry to the MAINTAINERS file. Thanks!
Bence Csókás
maintainerRe: [PATCH v3 2/2] Adding i2c-cp2615: i2c support for Silicon Labs' CP2615 Digital Audio Bridge
Quoted 4 lines
drivers/i2c/busses/i2c-cp2615.c:88:21: warning: incorrect type in assignment (different base types)drivers/i2c/busses/i2c-cp2615.c:88:21: expected unsigned short [usertype] lengthdrivers/i2c/busses/i2c-cp2615.c:88:21: got restricted__be16[usertype]
...
Yes, I have already converted to using __be16 where needed, it will be in the next version of the patch I send.
Quoted 3 lines
drivers/i2c/busses/i2c-cp2615.c:78:5: warning: symbol 'cp2615_init_iop_msg' was not declared. Should it be static?drivers/i2c/busses/i2c-cp2615.c:96:5: warning: symbol 'cp2615_init_i2c_msg' was not declared. Should it be static?drivers/i2c/busses/i2c-cp2615.c:102:5: warning: symbol 'cp2615_check_status' was not declared. Should it be static?
I can forward declare these (copying from the header I used in v1 of the patch), but I'm not sure I understand the rationale behind these warnings...
Quoted 1 line
drivers/i2c/busses/i2c-cp2615.c:212:27: warning: symbol 'cp2615_i2c_quirks' was not declared. Should it be static?
Especially this. I think I will make this static instead, since it won't ever be exported to any other module.
Quoted 1 line
The missing 'static' are what buildbot also reported and are correct.
The lkp bot complained about MODULE_DEVICE_TABLE and MODULE_AUTHOR, which, again, I don't see what is wrong with it.
Quoted 1 line
drivers/i2c/busses/i2c-cp2615.c:244:2: warning: ‘strncpy’ specified bound 48 equals destination size [-Wstringop-truncation]
I thought this was the correct way of strncpy... Time to RTFM then, I guess :)
Quoted 2 lines
Oh, and are you willing to maintain the driver? If so, please add an entry to the
MAINTAINERSfile. Thanks!
Sure!
I will now send an updated patch, with few additions too.
Re: [PATCH v3 2/2] Adding i2c-cp2615: i2c support for Silicon Labs' CP2615 Digital Audio Bridge
Quoted 7 lines
Quoted 4 lines
drivers/i2c/busses/i2c-cp2615.c:78:5: warning: symbol 'cp2615_init_iop_msg' was not declared. Should it be static?drivers/i2c/busses/i2c-cp2615.c:96:5: warning: symbol 'cp2615_init_i2c_msg' was not declared. Should it be static?drivers/i2c/busses/i2c-cp2615.c:102:5: warning: symbol 'cp2615_check_status' was not declared. Should it be static?I can forward declare these (copying from the header I used in v1 of the patch), but I'm not sure I understand the rationale behind these warnings...
Just make them static and all is good.
Quoted 3 lines
Quoted 1 line
drivers/i2c/busses/i2c-cp2615.c:212:27: warning: symbol 'cp2615_i2c_quirks' was not declared. Should it be static?Especially this. I think I will make this static instead, since it won't ever be exported to any other module.
Exactly.
Quoted 3 lines
Quoted 1 line
The missing 'static' are what buildbot also reported and are correct.
The lkp bot complained about
MODULE_DEVICE_TABLEandMODULE_AUTHOR, which, again, I don't see what is wrong with it.
Yeah, that may be a false positive.
Quoted 1 line
I will now send an updated patch, with few additions too.
Cool, thanks!