linux/drivers/usb/renesas_usbhs/common.h

/* SPDX-License-Identifier: GPL-1.0+ */
/*
 * Renesas USB driver
 *
 * Copyright (C) 2011 Renesas Solutions Corp.
 * Copyright (C) 2019 Renesas Electronics Corporation
 * Kuninori Morimoto <[email protected]>
 */
#ifndef RENESAS_USB_DRIVER_H
#define RENESAS_USB_DRIVER_H

#include <linux/clk.h>
#include <linux/extcon.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/usb/renesas_usbhs.h>

struct usbhs_priv;

#include "mod.h"
#include "pipe.h"

/*
 *
 *		register define
 *
 */
#define SYSCFG
#define BUSWAIT
#define DVSTCTR
#define TESTMODE
#define CFIFO
#define CFIFOSEL
#define CFIFOCTR
#define D0FIFO
#define D0FIFOSEL
#define D0FIFOCTR
#define D1FIFO
#define D1FIFOSEL
#define D1FIFOCTR
#define INTENB0
#define INTENB1
#define BRDYENB
#define NRDYENB
#define BEMPENB
#define INTSTS0
#define INTSTS1
#define BRDYSTS
#define NRDYSTS
#define BEMPSTS
#define FRMNUM
#define USBREQ
#define USBVAL
#define USBINDX
#define USBLENG
#define DCPCFG
#define DCPMAXP
#define DCPCTR
#define PIPESEL
#define PIPECFG
#define PIPEBUF
#define PIPEMAXP
#define PIPEPERI
#define PIPEnCTR
#define PIPE1TRE
#define PIPE1TRN
#define PIPE2TRE
#define PIPE2TRN
#define PIPE3TRE
#define PIPE3TRN
#define PIPE4TRE
#define PIPE4TRN
#define PIPE5TRE
#define PIPE5TRN
#define PIPEBTRE
#define PIPEBTRN
#define PIPECTRE
#define PIPECTRN
#define PIPEDTRE
#define PIPEDTRN
#define PIPEETRE
#define PIPEETRN
#define PIPEFTRE
#define PIPEFTRN
#define PIPE9TRE
#define PIPE9TRN
#define PIPEATRE
#define PIPEATRN
#define DEVADD0
#define DEVADD1
#define DEVADD2
#define DEVADD3
#define DEVADD4
#define DEVADD5
#define DEVADD6
#define DEVADD7
#define DEVADD8
#define DEVADD9
#define DEVADDA
#define D2FIFOSEL
#define D2FIFOCTR
#define D3FIFOSEL
#define D3FIFOCTR
#define SUSPMODE

/* SYSCFG */
#define SCKE
#define CNEN
#define HSE
#define DCFM
#define DRPD
#define DPRPU
#define USBE
#define UCKSEL
#define UPLLE

/* DVSTCTR */
#define EXTLP
#define PWEN
#define USBRST
#define UACT
#define RHST
#define RHST_LOW_SPEED
#define RHST_FULL_SPEED
#define RHST_HIGH_SPEED

/* CFIFOSEL */
#define DREQE
#define MBW_32

/* CFIFOCTR */
#define BVAL
#define BCLR
#define FRDY
#define DTLN_MASK

/* INTENB0 */
#define VBSE
#define RSME
#define SOFE
#define DVSE
#define CTRE
#define BEMPE
#define NRDYE
#define BRDYE

/* INTENB1 */
#define BCHGE
#define DTCHE
#define ATTCHE
#define EOFERRE
#define SIGNE
#define SACKE

/* INTSTS0 */
#define VBINT
#define DVST
#define CTRT
#define BEMP
#define BRDY
#define VBSTS
#define VALID

#define DVSQ_MASK
#define POWER_STATE
#define DEFAULT_STATE
#define ADDRESS_STATE
#define CONFIGURATION_STATE
#define SUSPENDED_STATE

#define CTSQ_MASK
#define IDLE_SETUP_STAGE
#define READ_DATA_STAGE
#define READ_STATUS_STAGE
#define WRITE_DATA_STAGE
#define WRITE_STATUS_STAGE
#define NODATA_STATUS_STAGE
#define SEQUENCE_ERROR

/* INTSTS1 */
#define OVRCR
#define BCHG
#define DTCH
#define ATTCH
#define EOFERR
#define SIGN
#define SACK

/* PIPECFG */
/* DCPCFG */
#define TYPE_NONE
#define TYPE_BULK
#define TYPE_INT
#define TYPE_ISO
#define BFRE
#define DBLB
#define SHTNAK
#define DIR_OUT

/* PIPEMAXP */
/* DCPMAXP */
#define DEVSEL_MASK
#define DCP_MAXP_MASK
#define PIPE_MAXP_MASK

/* PIPEBUF */
#define BUFSIZE_SHIFT
#define BUFSIZE_MASK
#define BUFNMB_MASK

/* PIPEnCTR */
/* DCPCTR */
#define BSTS
#define SUREQ
#define INBUFM
#define CSSTS
#define ACLRM
#define SQCLR
#define SQSET
#define SQMON
#define PBUSY
#define PID_MASK
#define PID_NAK
#define PID_BUF
#define PID_STALL10
#define PID_STALL11

#define CCPL

/* PIPEnTRE */
#define TRENB
#define TRCLR

/* FRMNUM */
#define FRNM_MASK

/* DEVADDn */
#define UPPHUB(x)
#define HUBPORT(x)
#define USBSPD(x)
#define USBSPD_SPEED_LOW
#define USBSPD_SPEED_FULL
#define USBSPD_SPEED_HIGH

/* SUSPMODE */
#define SUSPM

/*
 *		struct
 */
struct usbhs_priv {};

/*
 * common
 */
u16 usbhs_read(struct usbhs_priv *priv, u32 reg);
void usbhs_write(struct usbhs_priv *priv, u32 reg, u16 data);
void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data);

#define usbhs_lock(p, f)
#define usbhs_unlock(p, f)

int usbhs_get_id_as_gadget(struct platform_device *pdev);

/*
 * sysconfig
 */
void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable);
void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable);
void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable);
void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode);

/*
 * usb request
 */
void usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req);
void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req);

/*
 * bus
 */
void usbhs_bus_send_sof_enable(struct usbhs_priv *priv);
void usbhs_bus_send_reset(struct usbhs_priv *priv);
int usbhs_bus_get_speed(struct usbhs_priv *priv);
int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable);
int usbhsc_schedule_notify_hotplug(struct platform_device *pdev);

/*
 * frame
 */
int usbhs_frame_get_num(struct usbhs_priv *priv);

/*
 * device config
 */
int usbhs_set_device_config(struct usbhs_priv *priv, int devnum, u16 upphub,
			   u16 hubport, u16 speed);

/*
 * interrupt functions
 */
void usbhs_xxxsts_clear(struct usbhs_priv *priv, u16 sts_reg, u16 bit);

/*
 * data
 */
struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);
#define usbhs_get_dparam(priv, param)
#define usbhs_priv_to_pdev(priv)
#define usbhs_priv_to_dev(priv)
#define usbhs_priv_to_lock(priv)

#endif /* RENESAS_USB_DRIVER_H */