linux/drivers/usb/cdns3/drd.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Cadence USB3 and USBSSP DRD header file.
 *
 * Copyright (C) 2018-2020 Cadence.
 *
 * Author: Pawel Laszczak <[email protected]>
 */
#ifndef __LINUX_CDNS3_DRD
#define __LINUX_CDNS3_DRD

#include <linux/usb/otg.h>
#include "core.h"

/*  DRD register interface for version v1 of cdns3 driver. */
struct cdns3_otg_regs {};

/*  DRD register interface for version v0 of cdns3 driver. */
struct cdns3_otg_legacy_regs {};

/* DRD register interface for cdnsp driver */
struct cdnsp_otg_regs {};

/* CDNSP driver supports 0x000403xx Cadence USB controller family. */
#define OTG_CDNSP_CHECK_DID(did)

/* CDNS3 driver supports 0x000402xx Cadence USB controller family. */
#define OTG_CDNS3_CHECK_DID(did)

/*
 * Common registers interface for both CDNS3 and CDNSP version of DRD.
 */
struct cdns_otg_common_regs {};

/*
 * Interrupt related registers. This registers are mapped in different
 * location for CDNSP controller.
 */
struct cdns_otg_irq_regs {};

/* CDNS_RID - bitmasks */
#define CDNS_RID(p)

/* CDNS_VID - bitmasks */
#define CDNS_DID(p)

/* OTGCMD - bitmasks */
/* "Request the bus for Device mode. */
#define OTGCMD_DEV_BUS_REQ
/* Request the bus for Host mode */
#define OTGCMD_HOST_BUS_REQ
/* Enable OTG mode. */
#define OTGCMD_OTG_EN
/* Disable OTG mode */
#define OTGCMD_OTG_DIS
/*"Configure OTG as A-Device. */
#define OTGCMD_A_DEV_EN
/*"Configure OTG as A-Device. */
#define OTGCMD_A_DEV_DIS
/* Drop the bus for Device mod	e. */
#define OTGCMD_DEV_BUS_DROP
/* Drop the bus for Host mode*/
#define OTGCMD_HOST_BUS_DROP
/* Power Down USBSS-DEV - only for CDNS3.*/
#define OTGCMD_DEV_POWER_OFF
/* Power Down CDNSXHCI - only for CDNS3. */
#define OTGCMD_HOST_POWER_OFF

/* OTGIEN - bitmasks */
/* ID change interrupt enable */
#define OTGIEN_ID_CHANGE_INT
/* Vbusvalid fall detected interrupt enable.*/
#define OTGIEN_VBUSVALID_RISE_INT
/* Vbusvalid fall detected interrupt enable */
#define OTGIEN_VBUSVALID_FALL_INT

/* OTGSTS - bitmasks */
/*
 * Current value of the ID pin. It is only valid when idpullup in
 *  OTGCTRL1_TYPE register is set to '1'.
 */
#define OTGSTS_ID_VALUE
/* Current value of the vbus_valid */
#define OTGSTS_VBUS_VALID
/* Current value of the b_sess_vld */
#define OTGSTS_SESSION_VALID
/*Device mode is active*/
#define OTGSTS_DEV_ACTIVE
/* Host mode is active. */
#define OTGSTS_HOST_ACTIVE
/* OTG Controller not ready. */
#define OTGSTS_OTG_NRDY_MASK
#define OTGSTS_OTG_NRDY(p)
/*
 * 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)
#define OTGSTS_STRAP_NO_DEFAULT_CFG
#define OTGSTS_STRAP_HOST_OTG
#define OTGSTS_STRAP_HOST
#define OTGSTS_STRAP_GADGET
#define OTGSTS_CDNSP_STRAP_HOST
#define OTGSTS_CDNSP_STRAP_GADGET

/* Host mode is turned on. */
#define OTGSTS_CDNS3_XHCI_READY
#define OTGSTS_CDNSP_XHCI_READY

/* "Device mode is turned on .*/
#define OTGSTS_CDNS3_DEV_READY
#define OTGSTS_CDNSP_DEV_READY

/* OTGSTATE- bitmasks */
#define OTGSTATE_DEV_STATE_MASK
#define OTGSTATE_HOST_STATE_MASK
#define OTGSTATE_HOST_STATE_IDLE
#define OTGSTATE_HOST_STATE_VBUS_FALL
#define OTGSTATE_HOST_STATE(p)

/* OTGREFCLK - bitmasks */
#define OTGREFCLK_STB_CLK_SWITCH_EN

/* SUPS_CTRL - bitmasks */
#define SUSP_CTRL_SUSPEND_RESIDENCY_ENABLE

/* OVERRIDE - bitmasks */
#define OVERRIDE_IDPULLUP
/* Only for CDNS3_CONTROLLER_V0 version */
#define OVERRIDE_IDPULLUP_V0
/* Vbusvalid/Sesvalid override select. */
#define OVERRIDE_SESS_VLD_SEL

/* PHYRST_CFG - bitmasks */
#define PHYRST_CFG_PHYRST_A_ENABLE

#define CDNS3_ID_PERIPHERAL
#define CDNS3_ID_HOST

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);
bool cdns_power_is_lost(struct cdns *cdns);
#endif /* __LINUX_CDNS3_DRD */