From: Vardan Mikayelyan <mvar...@synopsys.com>

Add new device IDs for IOT gadget. Done changes in probe to
configure core accordingly depending on device ID value.

Signed-off-by: Vardan Mikayelyan <mvar...@synopsys.com>
Signed-off-by: John Youn <johny...@synopsys.com>
---
 drivers/usb/dwc2/core.h   | 18 ++++++++++++++++++
 drivers/usb/dwc2/params.c | 21 ++++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1ef602c..a59778e 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -954,6 +954,8 @@ struct dwc2_hsotg {
 #define DWC2_CORE_REV_2_94a    0x4f54294a
 #define DWC2_CORE_REV_3_00a    0x4f54300a
 #define DWC2_CORE_REV_3_10a    0x4f54310a
+#define DWC2_FS_IOT_REV_1_00a  0x5531100a
+#define DWC2_HS_IOT_REV_1_00a  0x5532100a
 
 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
        union dwc2_hcd_internal_flags {
@@ -1082,6 +1084,22 @@ enum dwc2_halt_status {
        DWC2_HC_XFER_URB_DEQUEUE,
 };
 
+/* Core version information */
+static inline bool dwc2_is_iot(struct dwc2_hsotg *hsotg)
+{
+       return (hsotg->hw_params.snpsid & 0xfff00000) == 0x55300000;
+}
+
+static inline bool dwc2_is_fs_iot(struct dwc2_hsotg *hsotg)
+{
+       return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55310000;
+}
+
+static inline bool dwc2_is_hs_iot(struct dwc2_hsotg *hsotg)
+{
+       return (hsotg->hw_params.snpsid & 0xffff0000) == 0x55320000;
+}
+
 /*
  * The following functions support initialization of the core driver component
  * and the DWC_otg controller
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 244ac0b..cbba6d5 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -1275,7 +1275,9 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
         */
        hw->snpsid = dwc2_readl(hsotg->regs + GSNPSID);
        if ((hw->snpsid & 0xfffff000) != 0x4f542000 &&
-           (hw->snpsid & 0xfffff000) != 0x4f543000) {
+           (hw->snpsid & 0xfffff000) != 0x4f543000 &&
+           (hw->snpsid & 0xffff0000) != 0x55310000 &&
+           (hw->snpsid & 0xffff0000) != 0x55320000) {
                dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n",
                        hw->snpsid);
                return -ENODEV;
@@ -1417,6 +1419,23 @@ int dwc2_init_params(struct dwc2_hsotg *hsotg)
        else
                params = params_default;
 
+       /*
+        * The IOT cores support ONLY descriptor DMA so we must
+        * explicitly enable them since the gadget does not
+        * automatically use them.
+        */
+       if (dwc2_is_hs_iot(hsotg)) {
+               params.g_dma = 1;
+               params.g_dma_desc = 1;
+       }
+
+       if (dwc2_is_fs_iot(hsotg)) {
+               params.g_dma = 1;
+               params.g_dma_desc = 1;
+               params.speed = DWC2_SPEED_PARAM_FULL;
+               params.phy_type = DWC2_PHY_TYPE_PARAM_FS;
+       }
+
        dwc2_set_parameters(hsotg, &params);
 
        return 0;
-- 
2.10.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to