linux/drivers/usb/musb/musb_core.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * MUSB OTG driver defines
 *
 * Copyright 2005 Mentor Graphics Corporation
 * Copyright (C) 2005-2006 by Texas Instruments
 * Copyright (C) 2006-2007 Nokia Corporation
 */

#ifndef __MUSB_CORE_H__
#define __MUSB_CORE_H__

#include <linux/slab.h>
#include <linux/list.h>
#include <linux/interrupt.h>
#include <linux/errno.h>
#include <linux/timer.h>
#include <linux/device.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/usb.h>
#include <linux/usb/otg.h>
#include <linux/usb/musb.h>
#include <linux/phy/phy.h>
#include <linux/workqueue.h>

struct musb;
struct musb_hw_ep;
struct musb_ep;
struct musb_qh;

/* Helper defines for struct musb->hwvers */
#define MUSB_HWVERS_MAJOR(x)
#define MUSB_HWVERS_MINOR(x)
#define MUSB_HWVERS_RC
#define MUSB_HWVERS_1300
#define MUSB_HWVERS_1400
#define MUSB_HWVERS_1800
#define MUSB_HWVERS_1900
#define MUSB_HWVERS_2000

#include "musb_debug.h"
#include "musb_dma.h"

#include "musb_io.h"

#include "musb_gadget.h"
#include <linux/usb/hcd.h>
#include "musb_host.h"

/* NOTE:  otg and peripheral-only state machines start at B_IDLE.
 * OTG or host-only go to A_IDLE when ID is sensed.
 */
#define is_peripheral_active(m)
#define is_host_active(m)

/****************************** CONSTANTS ********************************/

#ifndef MUSB_C_NUM_EPS
#define MUSB_C_NUM_EPS
#endif

#ifndef MUSB_MAX_END0_PACKET
#define MUSB_MAX_END0_PACKET
#endif

/* host side ep0 states */
enum musb_h_ep0_state {} __attribute__ ((packed));

/* peripheral side ep0 states */
enum musb_g_ep0_state {} __attribute__ ((packed));

/*
 * OTG protocol constants.  See USB OTG 1.3 spec,
 * sections 5.5 "Device Timings" and 6.6.5 "Timers".
 */
#define OTG_TIME_A_WAIT_VRISE
#define OTG_TIME_A_WAIT_BCON
#define OTG_TIME_A_AIDL_BDIS
#define OTG_TIME_B_ASE0_BRST

/****************************** FUNCTIONS ********************************/

#define MUSB_HST_MODE(_musb)
#define MUSB_DEV_MODE(_musb)

#define test_devctl_hst_mode(_x)

#define MUSB_MODE(musb)

/******************************** TYPES *************************************/

struct musb_io;

/**
 * struct musb_platform_ops - Operations passed to musb_core by HW glue layer
 * @quirks:	flags for platform specific quirks
 * @enable:	enable device
 * @disable:	disable device
 * @ep_offset:	returns the end point offset
 * @ep_select:	selects the specified end point
 * @fifo_mode:	sets the fifo mode
 * @fifo_offset: returns the fifo offset
 * @readb:	read 8 bits
 * @writeb:	write 8 bits
 * @clearb:	could be clear-on-readb or W1C
 * @readw:	read 16 bits
 * @writew:	write 16 bits
 * @clearw:	could be clear-on-readw or W1C
 * @read_fifo:	reads the fifo
 * @write_fifo:	writes to fifo
 * @get_toggle:	platform specific get toggle function
 * @set_toggle:	platform specific set toggle function
 * @dma_init:	platform specific dma init function
 * @dma_exit:	platform specific dma exit function
 * @init:	turns on clocks, sets up platform-specific registers, etc
 * @exit:	undoes @init
 * @set_mode:	forcefully changes operating mode
 * @try_idle:	tries to idle the IP
 * @recover:	platform-specific babble recovery
 * @vbus_status: returns vbus status if possible
 * @set_vbus:	forces vbus status
 * @pre_root_reset_end: called before the root usb port reset flag gets cleared
 * @post_root_reset_end: called after the root usb port reset flag gets cleared
 * @phy_callback: optional callback function for the phy to call
 */
struct musb_platform_ops {};

/*
 * struct musb_hw_ep - endpoint hardware (bidirectional)
 *
 * Ordered slightly for better cacheline locality.
 */
struct musb_hw_ep {};

static inline struct musb_request *next_in_request(struct musb_hw_ep *hw_ep)
{}

static inline struct musb_request *next_out_request(struct musb_hw_ep *hw_ep)
{}

struct musb_csr_regs {};

struct musb_context_registers {};

/*
 * struct musb - Driver instance data.
 */
struct musb {};

/* This must be included after struct musb is defined */
#include "musb_regs.h"

static inline struct musb *gadget_to_musb(struct usb_gadget *g)
{}

static inline char *musb_ep_xfertype_string(u8 type)
{}

static inline int musb_read_fifosize(struct musb *musb,
		struct musb_hw_ep *hw_ep, u8 epnum)
{}

static inline void musb_configure_ep0(struct musb *musb)
{}

/***************************** Glue it together *****************************/

extern const char musb_driver_name[];

extern void musb_stop(struct musb *musb);
extern void musb_start(struct musb *musb);

extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);

extern int musb_set_host(struct musb *musb);
extern int musb_set_peripheral(struct musb *musb);

extern void musb_load_testpacket(struct musb *);

extern irqreturn_t musb_interrupt(struct musb *);

extern void musb_hnp_stop(struct musb *musb);

int musb_queue_resume_work(struct musb *musb,
			   int (*callback)(struct musb *musb, void *data),
			   void *data);

static inline void musb_platform_set_vbus(struct musb *musb, int is_on)
{}

static inline void musb_platform_enable(struct musb *musb)
{}

static inline void musb_platform_disable(struct musb *musb)
{}

static inline int musb_platform_set_mode(struct musb *musb, u8 mode)
{}

static inline void musb_platform_try_idle(struct musb *musb,
		unsigned long timeout)
{}

static inline int  musb_platform_recover(struct musb *musb)
{}

static inline int musb_platform_get_vbus_status(struct musb *musb)
{}

static inline int musb_platform_init(struct musb *musb)
{}

static inline int musb_platform_exit(struct musb *musb)
{}

static inline void musb_platform_pre_root_reset_end(struct musb *musb)
{}

static inline void musb_platform_post_root_reset_end(struct musb *musb)
{}

static inline void musb_platform_clear_ep_rxintr(struct musb *musb, int epnum)
{}

static inline void musb_set_state(struct musb *musb,
				  enum usb_otg_state otg_state)
{}

static inline enum usb_otg_state musb_get_state(struct musb *musb)
{}

static inline const char *musb_otg_state_string(struct musb *musb)
{}

/*
 * gets the "dr_mode" property from DT and converts it into musb_mode
 * if the property is not found or not recognized returns MUSB_OTG
 */
extern enum musb_mode musb_get_mode(struct device *dev);

#endif	/* __MUSB_CORE_H__ */