]> Git Repo - J-linux.git/blobdiff - drivers/usb/cdns3/drd.h
Merge tag 'linux-kselftest-kunit-5.12-rc1' of git://git.kernel.org/pub/scm/linux...
[J-linux.git] / drivers / usb / cdns3 / drd.h
index f1ccae285a16dbd40e03ec3a4607b4140025dde5..9724acdecbbb0fbe8bde1df2d6276a75e2206659 100644 (file)
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Cadence USB3 DRD header file.
+ * Cadence USB3 and USBSSP DRD header file.
  *
- * Copyright (C) 2018-2019 Cadence.
+ * Copyright (C) 2018-2020 Cadence.
  *
  * Author: Pawel Laszczak <[email protected]>
  */
 #define __LINUX_CDNS3_DRD
 
 #include <linux/usb/otg.h>
-#include <linux/phy/phy.h>
 #include "core.h"
 
-/*  DRD register interface for version v1. */
+/*  DRD register interface for version v1 of cdns3 driver. */
 struct cdns3_otg_regs {
        __le32 did;
        __le32 rid;
@@ -38,7 +37,7 @@ struct cdns3_otg_regs {
        __le32 ctrl2;
 };
 
-/*  DRD register interface for version v0. */
+/*  DRD register interface for version v0 of cdns3 driver. */
 struct cdns3_otg_legacy_regs {
        __le32 cmd;
        __le32 sts;
@@ -57,14 +56,45 @@ struct cdns3_otg_legacy_regs {
        __le32 ctrl1;
 };
 
+/* DRD register interface for cdnsp driver */
+struct cdnsp_otg_regs {
+       __le32 did;
+       __le32 rid;
+       __le32 cfgs1;
+       __le32 cfgs2;
+       __le32 cmd;
+       __le32 sts;
+       __le32 state;
+       __le32 ien;
+       __le32 ivect;
+       __le32 tmr;
+       __le32 simulate;
+       __le32 adpbc_sts;
+       __le32 adp_ramp_time;
+       __le32 adpbc_ctrl1;
+       __le32 adpbc_ctrl2;
+       __le32 override;
+       __le32 vbusvalid_dbnc_cfg;
+       __le32 sessvalid_dbnc_cfg;
+       __le32 susp_timing_ctrl;
+};
+
+#define OTG_CDNSP_DID  0x0004034E
+
 /*
- * Common registers interface for both version of DRD.
+ * Common registers interface for both CDNS3 and CDNSP version of DRD.
  */
-struct cdns3_otg_common_regs {
+struct cdns_otg_common_regs {
        __le32 cmd;
        __le32 sts;
        __le32 state;
-       __le32 different1;
+};
+
+/*
+ * Interrupt related registers. This registers are mapped in different
+ * location for CDNSP controller.
+ */
+struct cdns_otg_irq_regs {
        __le32 ien;
        __le32 ivect;
 };
@@ -92,9 +122,9 @@ struct cdns3_otg_common_regs {
 #define OTGCMD_DEV_BUS_DROP            BIT(8)
 /* Drop the bus for Host mode*/
 #define OTGCMD_HOST_BUS_DROP           BIT(9)
-/* Power Down USBSS-DEV*/
+/* Power Down USBSS-DEV - only for CDNS3.*/
 #define OTGCMD_DEV_POWER_OFF           BIT(11)
-/* Power Down CDNSXHCI. */
+/* Power Down CDNSXHCI - only for CDNS3. */
 #define OTGCMD_HOST_POWER_OFF          BIT(12)
 
 /* OTGIEN - bitmasks */
@@ -123,20 +153,31 @@ struct cdns3_otg_common_regs {
 #define OTGSTS_OTG_NRDY_MASK           BIT(11)
 #define OTGSTS_OTG_NRDY(p)             ((p) & OTGSTS_OTG_NRDY_MASK)
 /*
- * Value of the strap pins.
+ * Value of the strap pins for:
+ * CDNS3:
  * 000 - no default configuration
  * 010 - Controller initiall configured as Host
  * 100 - Controller initially configured as Device
+ * CDNSP:
+ * 000 - No default configuration.
+ * 010 - Controller initiall configured as Host.
+ * 100 - Controller initially configured as Device.
  */
 #define OTGSTS_STRAP(p)                        (((p) & GENMASK(14, 12)) >> 12)
 #define OTGSTS_STRAP_NO_DEFAULT_CFG    0x00
 #define OTGSTS_STRAP_HOST_OTG          0x01
 #define OTGSTS_STRAP_HOST              0x02
 #define OTGSTS_STRAP_GADGET            0x04
+#define OTGSTS_CDNSP_STRAP_HOST                0x01
+#define OTGSTS_CDNSP_STRAP_GADGET      0x02
+
 /* Host mode is turned on. */
-#define OTGSTS_XHCI_READY              BIT(26)
+#define OTGSTS_CDNS3_XHCI_READY                BIT(26)
+#define OTGSTS_CDNSP_XHCI_READY                BIT(27)
+
 /* "Device mode is turned on .*/
-#define OTGSTS_DEV_READY               BIT(27)
+#define OTGSTS_CDNS3_DEV_READY         BIT(27)
+#define OTGSTS_CDNSP_DEV_READY         BIT(26)
 
 /* OTGSTATE- bitmasks */
 #define OTGSTATE_DEV_STATE_MASK                GENMASK(2, 0)
@@ -152,6 +193,8 @@ struct cdns3_otg_common_regs {
 #define OVERRIDE_IDPULLUP              BIT(0)
 /* Only for CDNS3_CONTROLLER_V0 version */
 #define OVERRIDE_IDPULLUP_V0           BIT(24)
+/* Vbusvalid/Sesvalid override select. */
+#define OVERRIDE_SESS_VLD_SEL          BIT(10)
 
 /* PHYRST_CFG - bitmasks */
 #define PHYRST_CFG_PHYRST_A_ENABLE     BIT(0)
@@ -159,17 +202,18 @@ struct cdns3_otg_common_regs {
 #define CDNS3_ID_PERIPHERAL            1
 #define CDNS3_ID_HOST                  0
 
-bool cdns3_is_host(struct cdns3 *cdns);
-bool cdns3_is_device(struct cdns3 *cdns);
-int cdns3_get_id(struct cdns3 *cdns);
-int cdns3_get_vbus(struct cdns3 *cdns);
-int cdns3_drd_init(struct cdns3 *cdns);
-int cdns3_drd_exit(struct cdns3 *cdns);
-int cdns3_drd_update_mode(struct cdns3 *cdns);
-int cdns3_drd_gadget_on(struct cdns3 *cdns);
-void cdns3_drd_gadget_off(struct cdns3 *cdns);
-int cdns3_drd_host_on(struct cdns3 *cdns);
-void cdns3_drd_host_off(struct cdns3 *cdns);
-int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode);
+bool cdns_is_host(struct cdns *cdns);
+bool cdns_is_device(struct cdns *cdns);
+int cdns_get_id(struct cdns *cdns);
+int cdns_get_vbus(struct cdns *cdns);
+void cdns_clear_vbus(struct cdns *cdns);
+void cdns_set_vbus(struct cdns *cdns);
+int cdns_drd_init(struct cdns *cdns);
+int cdns_drd_exit(struct cdns *cdns);
+int cdns_drd_update_mode(struct cdns *cdns);
+int cdns_drd_gadget_on(struct cdns *cdns);
+void cdns_drd_gadget_off(struct cdns *cdns);
+int cdns_drd_host_on(struct cdns *cdns);
+void cdns_drd_host_off(struct cdns *cdns);
 
 #endif /* __LINUX_CDNS3_DRD */
This page took 0.035375 seconds and 4 git commands to generate.