/*------------------------------------------------------------------------
. ev44b0_usb.c
.
. This is a USB driver for Philips's PDIUSBD12 single-chip USB device.
.
. (C) Copyright 2003
. MICETEK International Inc., Shanghai China
. Qin Wei <[email protected]>
.
.
. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
.
.
. author:
. Qin Wei ( [email protected] )
. History:
. 01/14/03 Qin Wei
----------------------------------------------------------------------------*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/wait.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/poll.h>
#include <linux/miscdevice.h>
#include <linux/init.h>
#include <linux/compiler.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
#include <asm/hardware.h>
#include "ev44b0_usb.h"
#define EV44B0II_USB_MODULE_NAME "usb"
#define USB_BULK_MAJOR 0x55
static const char usb_driver_version[] =
"EV44B0II USB driver v1.0 (2003-01-09) Qinwei, MICETEK Shanghai";
#define CONFIG_USBD12_BASE 0x4000000
#define verbose 0
#define Usb_Base_Address CONFIG_USBD12_BASE
static char *usb_bulk_id = "ev44b0ii usb";
static volatile char USB_CONNECT_FLAG = 0;
#define MAXUSBBUFFERLEN 1024
static unsigned char gbuffer[MAXUSBBUFFERLEN];
static unsigned char controlbuffer0[64];
struct ev44b0ii_usb_priv gusb;
//****************************************************************************
//
// This structure defines the setup packet received from the host via the
// control out endpoint. This sturcture is padded at the end to the maximum
// control endpoint transfer size.
//
//****************************************************************************
typedef struct
{
unsigned char bmRequestType;
unsigned char bRequest;
unsigned short wValue;
unsigned short wIndex;
unsigned short wLength;
} ControlTransfer;
//****************************************************************************
//
// The following structure contains the persistent state of the USB interface.
//
//****************************************************************************
static struct
{
// The currently selected USB configuration.
unsigned long ulConfiguration;
// The buffer of data that is being sent to the control endpoint.
const unsigned char *pucControlIn;
// The number of bytes to be sent to the control endpoint.
unsigned long ulControlInCount;
// The buffer of data that is being received from the control endpoint.
ControlTransfer sControlOut;
// The buffer of data that is being sent to the bulk endpoint.
const unsigned char *pucBulkIn;
// The number of bytes to be sent to the bulk endpoint.
unsigned long ulBulkInCount;
// The buffer of data that is being received from the bulk endpoint.
unsigned char *pucBulkOut;
// The number of bytes still to be read from the bulk endpoint.
unsigned long ulBulkOutCount;
const unsigned char *pucACKIn;
unsigned long ulACKInCount;
unsigned char *pucCommandOut;
unsigned long ulCommandOutCount;
} sUSB;
//****************************************************************************
//
// This is the configuration descriptor for the digital audio player. See the
// USB specification for the definition of this descriptor.
//
//****************************************************************************
static const unsigned char ucDeviceDescriptor[] =
{
0x12, // bLength
0x01, // bDescriptorType
0x00, 0x01, // bcdUSB
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
0x10, // bMaxPacketSize0
0x5e, 0x04, // idVendor
0x0a, 0x93, // idProduct
0x00, 0x01, // bcdDevice
0x01, // iManufacturer
0x02, // iProduct
0x00, // iSerial Number
0x01 // bNumConfigurations
};
//****************************************************************************
//
// This is the configuration descriptor for the digital audio player. See the
// USB specification for the definition of this descriptor.
//
//****************************************************************************
static const unsigned char ucConfigurationDescriptor[] =
{
//
// The configuration descriptor structure.
//
0x09, // bLength
0x02, // bDescriptorType
0x20, // wTotalLength
0x00, // bCorrection
0x01, // bNumInterfaces
0x01, // bConfigurationValue
0x00, // iConfiguration
0x40, // bmAttributes
0x00, // MaxPower
//
// The interface descriptor structure.
//
0x09, // bLength
0x04, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x02, // bNumEndpoints
0x00, // bInterfaceClass
0x00, // bInterfaceSubClass
0x00, // bInterfaceProtocol
0x00, // iInterface
//
// The endpoint descriptor structure.
//
0x07, // bLength
0x05, // bDescriptorType
0x82, // bEndpointAddress
0x02, // bmAttributes
0x40, 0x00, // wMaxPacketSize
0x00, // bInterval
//
// The endpoint descriptor structure.
//
0x07, // bLength
0x05, // bDescriptorType
0x02, // bEndpointAddress
0x02, // bmAttributes
0x40, 0x00, // wMaxPacketSize
0x00 // bInterval
};
//****************************************************************************
//
// String descriptor 0 for the digital audio player. This defines the
// languages supported by the string descriptors. See the USB specification
// for the definition of this descriptor.
//
//****************************************************************************
static const unsigned char ucString0[] =
{
0x04, // bLength
0x03, // bDescriptorType
0x09, 0x04 // wLANGID[0] -> US English
};
//****************************************************************************
//
// String descriptor 1 for the digital audio player. This defines the
//