#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)
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,
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;
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);