Message ID | cover.1692507038.git.abdelalkuor@geotab.com |
---|---|
Headers | show |
Series | Add support for TPS25750 | expand |
On 20/08/2023 07:23, Abdel Alkuor wrote: > From: Abdel Alkuor <abdelalkuor@geotab.com> > > TPS25750 is USB Type-C controller and Power Delivery controller. > > TPS25750 needs to be configured after a cold reset. The configuration > can be applied either from an external EEPROM connected to the > controller or by a host using I2C. TI provides an online GUI that > can be used to generate the configuration binary. > Tool link: https://tinyurl.com/2s3watcm > P.S. It requires a TI account to be able to use the tool. > ... > + > +static void tps25750_remove(struct i2c_client *client) > +{ > + struct tps25750 *tps = i2c_get_clientdata(client); > + > + tps25750_disconnect(tps, 0); > + typec_unregister_port(tps->port); > + usb_role_switch_put(tps->role_sw); > + > + /* clear the patch by a hard reset */ > + tps25750_exec_normal_cmd(tps, TPS_4CC_GAID); > +} > + > +static int __maybe_unused tps25750_suspend(struct device *dev) > +{ > + /* TODO: should we remove the patch? */ > + return 0; > +} > + > +static int __maybe_unused tps25750_resume(struct device *dev) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + struct tps25750 *tps = i2c_get_clientdata(client); > + > + /* The controller needs to be reinitialized again Format is: /* * The.... > + * if it is powered off as config is not persisted > + */ > + return tps25750_init(tps); > +} > + > +static const struct dev_pm_ops tps25750_pm_ops = { > + SET_SYSTEM_SLEEP_PM_OPS(tps25750_suspend, tps25750_resume) > +}; > + > +static const struct of_device_id tps25750_of_match[] = { > + { .compatible = "ti,tps25750", }, > + {} > +}; > +MODULE_DEVICE_TABLE(of, tps25750_of_match); > + > +static const struct i2c_device_id tps25750_id[] = { > + { "tps25750" }, > + { } > +}; > +MODULE_DEVICE_TABLE(i2c, tps25750_id); > + > +static struct i2c_driver tps25750_i2c_driver = { > + .driver = { > + .name = "tps25750", > + .pm = pm_ptr(&tps25750_pm_ops), > + .of_match_table = of_match_ptr(tps25750_of_match), Drop of_match_ptr(). It will cause warnings. > + }, > + .probe_new = tps25750_probe, > + .remove = tps25750_remove, > + .id_table = tps25750_id, > +}; > +module_i2c_driver(tps25750_i2c_driver); Best regards, Krzysztof
On Sun, Aug 20, 2023 at 08:24:18AM +0200, Krzysztof Kozlowski wrote: > On 20/08/2023 07:23, Abdel Alkuor wrote: > > From: Abdel Alkuor <abdelalkuor@geotab.com> > > > > TPS25750 is USB Type-C controller and Power Delivery controller. > > > > TPS25750 needs to be configured after a cold reset. The configuration > > can be applied either from an external EEPROM connected to the > > controller or by a host using I2C. TI provides an online GUI that > > can be used to generate the configuration binary. > > Tool link: https://tinyurl.com/2s3watcm > > P.S. It requires a TI account to be able to use the tool. > > > ... > > > > + > > +static void tps25750_remove(struct i2c_client *client) > > +{ > > + struct tps25750 *tps = i2c_get_clientdata(client); > > + > > + tps25750_disconnect(tps, 0); > > + typec_unregister_port(tps->port); > > + usb_role_switch_put(tps->role_sw); > > + > > + /* clear the patch by a hard reset */ > > + tps25750_exec_normal_cmd(tps, TPS_4CC_GAID); > > +} > > + > > +static int __maybe_unused tps25750_suspend(struct device *dev) > > +{ > > + /* TODO: should we remove the patch? */ > > + return 0; > > +} > > + > > +static int __maybe_unused tps25750_resume(struct device *dev) > > +{ > > + struct i2c_client *client = to_i2c_client(dev); > > + struct tps25750 *tps = i2c_get_clientdata(client); > > + > > + /* The controller needs to be reinitialized again > > Format is: > > /* > * The.... > Fixed all mult-line comments in v4. > > + * if it is powered off as config is not persisted > > + */ > > + return tps25750_init(tps); > > +} > > + > > +static const struct dev_pm_ops tps25750_pm_ops = { > > + SET_SYSTEM_SLEEP_PM_OPS(tps25750_suspend, tps25750_resume) > > +}; > > + > > +static const struct of_device_id tps25750_of_match[] = { > > + { .compatible = "ti,tps25750", }, > > + {} > > +}; > > +MODULE_DEVICE_TABLE(of, tps25750_of_match); > > + > > +static const struct i2c_device_id tps25750_id[] = { > > + { "tps25750" }, > > + { } > > +}; > > +MODULE_DEVICE_TABLE(i2c, tps25750_id); > > + > > +static struct i2c_driver tps25750_i2c_driver = { > > + .driver = { > > + .name = "tps25750", > > + .pm = pm_ptr(&tps25750_pm_ops), > > + .of_match_table = of_match_ptr(tps25750_of_match), > > Drop of_match_ptr(). It will cause warnings. > Removed in v4. > > + }, > > + .probe_new = tps25750_probe, > > + .remove = tps25750_remove, > > + .id_table = tps25750_id, > > +}; > > +module_i2c_driver(tps25750_i2c_driver); > > > Best regards, > Krzysztof > Thanks, Abdel
From: Abdel Alkuor <abdelalkuor@geotab.com> TPS25750 is USB Type-C and PD controller. The device is highly configurable using App Customization online Tool developed by TI to generate loadable binary. TPS25750 supports three modes; PTCH, APP, and BOOT. A configuration can only be applied when the controller is on PTCH mode. The controller attempts to load a configuration from EEPROM on I2Cm bus. If no EEPROM is detected, then the driver tries to load a configuration on I2Cs bus using a firmware file defined in DT. The driver implements the binary loading sequence which can be found on pg.53 in TPS25750 Host Interface Technical Reference Manual (Rev. A) https://tinyurl.com/y9rkhu8a The driver only supports resume pm callback as power management is automatically controlled by the device. See pg.47 in TPS25750 datasheet https://tinyurl.com/3vfd2k43 v3: - PATCH 1: Fix node name - PATCH 2: Upload tps25750 driver patch v2: - PATCH 1: General properties clean up Abdel Alkuor (2): dt-bindings: usb: Add ti,tps25750 USB: typec: Add TI TPS25750 USB Type-C controller .../devicetree/bindings/usb/ti,tps25750.yaml | 81 ++ drivers/usb/typec/Kconfig | 13 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/tps25750.c | 1065 +++++++++++++++++ drivers/usb/typec/tps25750.h | 162 +++ 5 files changed, 1322 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ti,tps25750.yaml create mode 100644 drivers/usb/typec/tps25750.c create mode 100644 drivers/usb/typec/tps25750.h