/*--------------------------------------------------------------------------*
 * drivers/usb/mcd/usb_mcd_ioctl.h
 * 
 * USB controller driver
 * 
 * Copyright 2005,2006 Sony Corporation
 *
 * This file is part of the Inventra Controller Driver for Linux.
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *---------------------------------------------------------------------------*/

#ifndef _USB_MCD_IOCTL_H_
#define _USB_MCD_IOCTL_H_

/* Gadget IOCTL code */
#define USB_IOCTL_FIFO_RESET		1	/* reset FIFO map */
#define USB_IOCTL_FIFO_MAP		2	/* map FIFO */
#define USB_IOCTL_FIFO_DUMP		3	/* dump FIFO settings */
#define USB_IOCTL_TESTMODE		4	/* Test mode settings */
#define USB_IOCTL_DMA_SET		5	/* DMA transfer enable settings */

#define USB_IOCTL_TESTMODE_NORMAL       0	/* TESTMODE_NORMAL */
#define USB_IOCTL_TESTMODE_TEST_J       1	/* TEST_J */
#define USB_IOCTL_TESTMODE_TEST_K       2	/* TEST_K */
#define USB_IOCTL_TESTMODE_SE0_NAK      3	/* SE0_NAK */
#define USB_IOCTL_TESTMODE_TEST_PACKET  4	/* TEST_PACKET */
#define USB_IOCTL_TESTMODE_FORCE_ENABLE 5	/* FORCE_ENABLE */

#define USB_MCD_DMA_SETOFF		0	/* DMA disable used in
                                                   USB_IOCTL_DMA_SET */
#define USB_MCD_DMA_SETON		1	/* DMA enable used in
                                                   USB_IOCTL_DMA_SET */

/*
 * iocontrol parameter for dynamic FIFO operations
 * @filed bEpAdr endpoint address
 * @filed wSize FIFO size
 * @filed bType specify 2 when double buffer or 1 when single buffer
 */
struct usb_ioctl_fifo_param {
	uint8_t bEpAdr;
	uint16_t wSize;
	uint8_t bType;
};

/*
 * IO control inline function
 *
 * @param gadget gadget controller driver
 * @param code control code
 * @param param parameter data
 */
static inline int
usb_gadget_ioctl(struct usb_gadget *gadget, unsigned code, unsigned long param)
{
	if (!gadget->ops->ioctl)
		return -EOPNOTSUPP;
	return gadget->ops->ioctl(gadget, code, param);
}

/*
 * IO control inline function
 *
 * @param bEp_num : a number of EP [0-0x0F]
 * @param bDma_ena : to select 
 *		whether DMA transfer is valid or not
 *			0: disable
 *			1: enable
 */
struct usb_ioctl_dmaset_param {
	uint8_t bEp_num;
	uint8_t bDma_ena;
};

#endif				/* _USB_MCD_IOCTL_H_ */
