Message ID | 20231214230850.379863-15-rdbabiera@google.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | usb: typec: add SOP' support to the tcpm and alt mode drivers | expand |
Hi RD, kernel test robot noticed the following build warnings: [auto build test WARNING on usb/usb-testing] [also build test WARNING on usb/usb-next usb/usb-linus linus/master v6.7-rc5 next-20231215] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/RD-Babiera/usb-typec-altmodes-add-typec_cable_ops-to-typec_altmode/20231215-071339 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20231214230850.379863-15-rdbabiera%40google.com patch subject: [PATCH v2 01/12] usb: typec: altmodes: add typec_cable_ops to typec_altmode config: alpha-randconfig-r071-20231216 (https://download.01.org/0day-ci/archive/20231216/202312161038.P8GnRTgA-lkp@intel.com/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231216/202312161038.P8GnRTgA-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312161038.P8GnRTgA-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/usb/typec/bus.c:260: warning: expecting prototype for typec_altmode_enter(). Prototype was for typec_cable_altmode_enter() instead >> drivers/usb/typec/bus.c:290: warning: expecting prototype for typec_altmode_exit(). Prototype was for typec_cable_altmode_exit() instead >> drivers/usb/typec/bus.c:323: warning: expecting prototype for typec_altmode_vdm(). Prototype was for typec_cable_altmode_vdm() instead vim +260 drivers/usb/typec/bus.c 249 250 /** 251 * typec_altmode_enter - Enter Mode 252 * @adev: The alternate mode 253 * @sop: Cable plug target for Enter Mode command 254 * @vdo: VDO for the Enter Mode command 255 * 256 * Alternate mode drivers use this function to enter mode on the cable plug. 257 * If the alternate mode does not require VDO, @vdo must be NULL. 258 */ 259 int typec_cable_altmode_enter(struct typec_altmode *adev, enum typec_plug_index sop, u32 *vdo) > 260 { 261 struct altmode *partner = to_altmode(adev)->partner; 262 struct typec_altmode *pdev; 263 264 if (!adev || adev->active) 265 return 0; 266 267 if (!partner) 268 return -ENODEV; 269 270 pdev = &partner->adev; 271 272 if (!pdev->active) 273 return -EPERM; 274 275 if (!pdev->cable_ops || !pdev->cable_ops->enter) 276 return -EOPNOTSUPP; 277 278 return pdev->cable_ops->enter(pdev, sop, vdo); 279 } 280 EXPORT_SYMBOL_GPL(typec_cable_altmode_enter); 281 282 /** 283 * typec_altmode_exit - Exit Mode 284 * @adev: The alternate mode 285 * @sop: Cable plug target for Exit Mode command 286 * 287 * The alternate mode drivers use this function to exit mode on the cable plug. 288 */ 289 int typec_cable_altmode_exit(struct typec_altmode *adev, enum typec_plug_index sop) > 290 { 291 struct altmode *partner = to_altmode(adev)->partner; 292 struct typec_altmode *pdev; 293 294 if (!adev || !adev->active) 295 return 0; 296 297 if (!partner) 298 return -ENODEV; 299 300 pdev = &partner->adev; 301 302 if (!pdev->cable_ops || !pdev->cable_ops->exit) 303 return -EOPNOTSUPP; 304 305 return pdev->cable_ops->exit(pdev, sop); 306 } 307 EXPORT_SYMBOL_GPL(typec_cable_altmode_exit); 308 309 /** 310 * typec_altmode_vdm - Send Vendor Defined Messages (VDM) between the cable plug and port. 311 * @adev: Alternate mode handle 312 * @sop: Cable plug target for VDM 313 * @header: VDM Header 314 * @vdo: Array of Vendor Defined Data Objects 315 * @count: Number of Data Objects 316 * 317 * The alternate mode drivers use this function for SVID specific communication 318 * with the cable plugs. The port drivers use it to deliver the Structured VDMs 319 * received from the cable plugs to the alternate mode drivers. 320 */ 321 int typec_cable_altmode_vdm(struct typec_altmode *adev, enum typec_plug_index sop, 322 const u32 header, const u32 *vdo, int count) > 323 { 324 struct altmode *altmode; 325 struct typec_altmode *pdev; 326 327 if (!adev) 328 return 0; 329 330 altmode = to_altmode(adev); 331 332 if (is_typec_plug(adev->dev.parent)) { 333 if (!altmode->partner) 334 return -ENODEV; 335 pdev = &altmode->partner->adev; 336 } else { 337 if (!altmode->plug[sop]) 338 return -ENODEV; 339 pdev = &altmode->plug[sop]->adev; 340 } 341 342 if (!pdev->cable_ops || !pdev->cable_ops->vdm) 343 return -EOPNOTSUPP; 344 345 return pdev->cable_ops->vdm(pdev, sop, header, vdo, count); 346 } 347 EXPORT_SYMBOL_GPL(typec_cable_altmode_vdm); 348
Hi RD, kernel test robot noticed the following build warnings: [auto build test WARNING on usb/usb-testing] [also build test WARNING on usb/usb-next usb/usb-linus linus/master v6.7-rc5 next-20231215] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/RD-Babiera/usb-typec-altmodes-add-typec_cable_ops-to-typec_altmode/20231215-071339 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20231214230850.379863-15-rdbabiera%40google.com patch subject: [PATCH v2 01/12] usb: typec: altmodes: add typec_cable_ops to typec_altmode config: arc-randconfig-001-20231215 (https://download.01.org/0day-ci/archive/20231217/202312172234.6in6om5p-lkp@intel.com/config) compiler: arc-elf-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231217/202312172234.6in6om5p-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312172234.6in6om5p-lkp@intel.com/ All warnings (new ones prefixed by >>): >> scripts/kernel-doc: drivers/usb/typec/bus.c:260: warning: expecting prototype for typec_altmode_enter(). Prototype was for typec_cable_altmode_enter() instead >> scripts/kernel-doc: drivers/usb/typec/bus.c:290: warning: expecting prototype for typec_altmode_exit(). Prototype was for typec_cable_altmode_exit() instead >> scripts/kernel-doc: drivers/usb/typec/bus.c:323: warning: expecting prototype for typec_altmode_vdm(). Prototype was for typec_cable_altmode_vdm() instead
diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c index e95ec7e382bb..009447082fd5 100644 --- a/drivers/usb/typec/bus.c +++ b/drivers/usb/typec/bus.c @@ -244,6 +244,108 @@ typec_altmode_get_partner(struct typec_altmode *adev) } EXPORT_SYMBOL_GPL(typec_altmode_get_partner); +/* -------------------------------------------------------------------------- */ +/* API for cable alternate modes */ + +/** + * typec_altmode_enter - Enter Mode + * @adev: The alternate mode + * @sop: Cable plug target for Enter Mode command + * @vdo: VDO for the Enter Mode command + * + * Alternate mode drivers use this function to enter mode on the cable plug. + * If the alternate mode does not require VDO, @vdo must be NULL. + */ +int typec_cable_altmode_enter(struct typec_altmode *adev, enum typec_plug_index sop, u32 *vdo) +{ + struct altmode *partner = to_altmode(adev)->partner; + struct typec_altmode *pdev; + + if (!adev || adev->active) + return 0; + + if (!partner) + return -ENODEV; + + pdev = &partner->adev; + + if (!pdev->active) + return -EPERM; + + if (!pdev->cable_ops || !pdev->cable_ops->enter) + return -EOPNOTSUPP; + + return pdev->cable_ops->enter(pdev, sop, vdo); +} +EXPORT_SYMBOL_GPL(typec_cable_altmode_enter); + +/** + * typec_altmode_exit - Exit Mode + * @adev: The alternate mode + * @sop: Cable plug target for Exit Mode command + * + * The alternate mode drivers use this function to exit mode on the cable plug. + */ +int typec_cable_altmode_exit(struct typec_altmode *adev, enum typec_plug_index sop) +{ + struct altmode *partner = to_altmode(adev)->partner; + struct typec_altmode *pdev; + + if (!adev || !adev->active) + return 0; + + if (!partner) + return -ENODEV; + + pdev = &partner->adev; + + if (!pdev->cable_ops || !pdev->cable_ops->exit) + return -EOPNOTSUPP; + + return pdev->cable_ops->exit(pdev, sop); +} +EXPORT_SYMBOL_GPL(typec_cable_altmode_exit); + +/** + * typec_altmode_vdm - Send Vendor Defined Messages (VDM) between the cable plug and port. + * @adev: Alternate mode handle + * @sop: Cable plug target for VDM + * @header: VDM Header + * @vdo: Array of Vendor Defined Data Objects + * @count: Number of Data Objects + * + * The alternate mode drivers use this function for SVID specific communication + * with the cable plugs. The port drivers use it to deliver the Structured VDMs + * received from the cable plugs to the alternate mode drivers. + */ +int typec_cable_altmode_vdm(struct typec_altmode *adev, enum typec_plug_index sop, + const u32 header, const u32 *vdo, int count) +{ + struct altmode *altmode; + struct typec_altmode *pdev; + + if (!adev) + return 0; + + altmode = to_altmode(adev); + + if (is_typec_plug(adev->dev.parent)) { + if (!altmode->partner) + return -ENODEV; + pdev = &altmode->partner->adev; + } else { + if (!altmode->plug[sop]) + return -ENODEV; + pdev = &altmode->plug[sop]->adev; + } + + if (!pdev->cable_ops || !pdev->cable_ops->vdm) + return -EOPNOTSUPP; + + return pdev->cable_ops->vdm(pdev, sop, header, vdo, count); +} +EXPORT_SYMBOL_GPL(typec_cable_altmode_vdm); + /* -------------------------------------------------------------------------- */ /* API for the alternate mode drivers */ diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 16a670828dde..86b5a8414b89 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -2277,6 +2277,25 @@ void typec_port_register_altmodes(struct typec_port *port, } EXPORT_SYMBOL_GPL(typec_port_register_altmodes); +/** + * typec_port_register_cable_ops - Register typec_cable_ops to port altmodes + * @altmodes: USB Type-C Port's altmode vector + * @max_altmodes: The maximum number of alt modes supported by the port + * @ops: Cable alternate mode vector + */ +void typec_port_register_cable_ops(struct typec_altmode **altmodes, int max_altmodes, + const struct typec_cable_ops *ops) +{ + int i; + + for (i = 0; i < max_altmodes; i++) { + if (!altmodes[i]) + return; + altmodes[i]->cable_ops = ops; + } +} +EXPORT_SYMBOL_GPL(typec_port_register_cable_ops); + /** * typec_register_port - Register a USB Type-C Port * @parent: Parent device diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index a05d6f6f2536..38f93d72fd1b 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -18,6 +18,7 @@ struct typec_cable; struct typec_plug; struct typec_port; struct typec_altmode_ops; +struct typec_cable_ops; struct fwnode_handle; struct device; @@ -157,6 +158,9 @@ void typec_port_register_altmodes(struct typec_port *port, const struct typec_altmode_ops *ops, void *drvdata, struct typec_altmode **altmodes, size_t n); +void typec_port_register_cable_ops(struct typec_altmode **altmodes, int max_altmodes, + const struct typec_cable_ops *ops); + void typec_unregister_altmode(struct typec_altmode *altmode); struct typec_port *typec_altmode2port(struct typec_altmode *alt); diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h index 28aeef8f9e7b..72ec8058543a 100644 --- a/include/linux/usb/typec_altmode.h +++ b/include/linux/usb/typec_altmode.h @@ -20,6 +20,7 @@ struct typec_altmode_ops; * @active: Tells has the mode been entered or not * @desc: Optional human readable description of the mode * @ops: Operations vector from the driver + * @cable_ops: Cable operations vector from the driver. */ struct typec_altmode { struct device dev; @@ -30,6 +31,7 @@ struct typec_altmode { char *desc; const struct typec_altmode_ops *ops; + const struct typec_cable_ops *cable_ops; }; #define to_typec_altmode(d) container_of(d, struct typec_altmode, dev) @@ -75,6 +77,24 @@ int typec_altmode_notify(struct typec_altmode *altmode, unsigned long conf, const struct typec_altmode * typec_altmode_get_partner(struct typec_altmode *altmode); +/** + * struct typec_cable_ops - Cable alternate mode operations vector + * @enter: Operations to be executed with Enter Mode Command + * @exit: Operations to be executed with Exit Mode Command + * @vdm: Callback for SVID specific commands + */ +struct typec_cable_ops { + int (*enter)(struct typec_altmode *altmode, enum typec_plug_index sop, u32 *vdo); + int (*exit)(struct typec_altmode *altmode, enum typec_plug_index sop); + int (*vdm)(struct typec_altmode *altmode, enum typec_plug_index sop, + const u32 hdr, const u32 *vdo, int cnt); +}; + +int typec_cable_altmode_enter(struct typec_altmode *altmode, enum typec_plug_index sop, u32 *vdo); +int typec_cable_altmode_exit(struct typec_altmode *altmode, enum typec_plug_index sop); +int typec_cable_altmode_vdm(struct typec_altmode *altmode, enum typec_plug_index sop, + const u32 header, const u32 *vdo, int count); + /* * These are the connector states (USB, Safe and Alt Mode) defined in USB Type-C * Specification. SVID specific connector states are expected to follow and
Add typec_cable_ops struct for enter, exit, and vdm. The struct is added to typec_altmode so port alt modes can have access to partner and cable specific callbacks, and alt mode drivers can specify operations over SOP' and SOP'' without modifying the existing API. typec_port_register_cable_ops is added as a new symbol for port drivers to use to register cable operations to their registered port alt modes. Signed-off-by: RD Babiera <rdbabiera@google.com> --- drivers/usb/typec/bus.c | 102 ++++++++++++++++++++++++++++++ drivers/usb/typec/class.c | 19 ++++++ include/linux/usb/typec.h | 4 ++ include/linux/usb/typec_altmode.h | 20 ++++++ 4 files changed, 145 insertions(+)