diff options
author | Seung-Woo Kim <sw0312.kim@samsung.com> | 2023-08-18 15:34:10 +0900 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2023-08-18 18:18:10 +0900 |
commit | 11a8468c73f2db0f1b5da367936c52c6d9bc700e (patch) | |
tree | 543e73245b0689a3c7ed9188c99c91a078fbc9e0 | |
parent | 9ed5b31605b1c53aa59576929edcb4176e403a73 (diff) | |
download | linux-starfive-11a8468c73f2db0f1b5da367936c52c6d9bc700e.tar.gz linux-starfive-11a8468c73f2db0f1b5da367936c52c6d9bc700e.tar.bz2 linux-starfive-11a8468c73f2db0f1b5da367936c52c6d9bc700e.zip |
usb: cdns3-starfive: Add extcon usb gadget state with always connected
Add extcon usb gadget state and set usb gadget state as connected.
The cdns3-starfive usb c port in visionfive2 board only has usb
d-/d+ lines and vbus and ground lines are used for power supply.
Because of the H/W limitation, it is not possible to detect usb
c port connected state.
In Tizen, deviced configures usb gadget functions only with the
usb connected state, so, to support usb gadget functionality,
the usb state should be set.
Change-Id: I3e3a25a726c7205b3d9a5fd96d8557562bfda81f
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r-- | drivers/usb/cdns3/Kconfig | 11 | ||||
-rw-r--r-- | drivers/usb/cdns3/cdns3-starfive.c | 31 |
2 files changed, 42 insertions, 0 deletions
diff --git a/drivers/usb/cdns3/Kconfig b/drivers/usb/cdns3/Kconfig index 0a514b591527..b139e66dfbf3 100644 --- a/drivers/usb/cdns3/Kconfig +++ b/drivers/usb/cdns3/Kconfig @@ -131,3 +131,14 @@ config USB_CDNSP_HOST standard XHCI driver. endif + +if USB_CDNS3_STARFIVE + +config USB_CDNS3_STARFIVE_EXTCON + bool "Extcon USB state support on Cadence USB3 of Starfive SoC" + depends on EXTCON + help + Say Y here to enable external connector event of the StarFive SoC + platforms that contain Cadence USB3 controller core. + +endif diff --git a/drivers/usb/cdns3/cdns3-starfive.c b/drivers/usb/cdns3/cdns3-starfive.c index a99f98f85235..55ae4ac53cbf 100644 --- a/drivers/usb/cdns3/cdns3-starfive.c +++ b/drivers/usb/cdns3/cdns3-starfive.c @@ -19,6 +19,9 @@ #include <linux/regmap.h> #include <linux/reset.h> #include <linux/usb/otg.h> +#if IS_ENABLED(CONFIG_USB_CDNS3_STARFIVE_EXTCON) +#include <linux/extcon-provider.h> +#endif #include "core.h" #define USB_STRAP_HOST BIT(17) @@ -55,6 +58,9 @@ struct cdns_starfive { u32 stg_offset_328; u32 stg_offset_500; bool usb2_only; +#if IS_ENABLED(CONFIG_USB_CDNS3_STARFIVE_EXTCON) + struct extcon_dev *edev; +#endif }; static int cdns_mode_init(struct platform_device *pdev, @@ -163,11 +169,21 @@ err_clk_init: return ret; } +#if IS_ENABLED(CONFIG_USB_CDNS3_STARFIVE_EXTCON) +static const unsigned int supported_cable[] = { + EXTCON_USB, + EXTCON_NONE, +}; +#endif + static int cdns_starfive_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *node = pdev->dev.of_node; struct cdns_starfive *data; +#if IS_ENABLED(CONFIG_USB_CDNS3_STARFIVE_EXTCON) + struct extcon_dev *edev; +#endif unsigned int args[4]; const char *dr_mode; int ret; @@ -180,6 +196,21 @@ static int cdns_starfive_probe(struct platform_device *pdev) data->dev = dev; +#if IS_ENABLED(CONFIG_USB_CDNS3_STARFIVE_EXTCON) + edev = devm_extcon_dev_allocate(dev, supported_cable); + if (IS_ERR(edev)) + return PTR_ERR(edev); + + ret = devm_extcon_dev_register(dev, edev); + if (ret) + return ret; + + /* Set starfive cdns3 usb always connected because of hw limitation */ + extcon_set_state_sync(edev, EXTCON_USB, true); + + data->edev = edev; +#endif + data->stg_syscon = syscon_regmap_lookup_by_phandle_args(pdev->dev.of_node, "starfive,stg-syscon", 4, args); |