mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-30 16:40:44 +09:00
Merge with /home/wd/git/u-boot/custodian/u-boot-usb
This commit is contained in:
commit
19901c6320
@ -438,6 +438,20 @@ Changes for U-Boot 1.1.5:
|
||||
|
||||
* Call serial_initialize() before first debug() is used.
|
||||
|
||||
* Code cleanup
|
||||
|
||||
* Various USB related patches
|
||||
- Add support for mpc8xx USB device.
|
||||
- Add support for Common Device Class - Abstract Control Model USB console.
|
||||
- Add support for flow control in USB slave devices.
|
||||
- Add support for switching between gserial and cdc_acm using environment.
|
||||
- Minor changes to usbdcore_omap1510.c usbdcore_omap1510.h
|
||||
- Update usbcore slightly to ease host enumeration.
|
||||
- Fix non-portable endian problems in usbdcore and usbdcore_ep0.
|
||||
- Add AdderUSB_config as a defconfig to enable usage of the USB console
|
||||
by default with the Adder87x U-Boot port.
|
||||
Patch by Bryan O'Donoghue <bodonoghue@codehermit.ie>, 29 May 2006
|
||||
|
||||
* Cleanup trab board for GCC-4.x
|
||||
|
||||
* VoiceBlue update: use new MTD flash partitioning methods, use more
|
||||
|
5
Makefile
5
Makefile
@ -122,7 +122,7 @@ ifeq ($(HOSTARCH),$(ARCH))
|
||||
CROSS_COMPILE =
|
||||
else
|
||||
ifeq ($(ARCH),ppc)
|
||||
CROSS_COMPILE = powerpc-linux-
|
||||
CROSS_COMPILE = ppc_8xx-
|
||||
endif
|
||||
ifeq ($(ARCH),arm)
|
||||
CROSS_COMPILE = arm-linux-
|
||||
@ -657,6 +657,9 @@ AdderII_config \
|
||||
@echo "#define CONFIG_MPC852T" > $(obj)include/config.h)
|
||||
@$(MKCONFIG) -a Adder ppc mpc8xx adder
|
||||
|
||||
AdderUSB_config: unconfig
|
||||
@./mkconfig -a AdderUSB ppc mpc8xx adder
|
||||
|
||||
ADS860_config \
|
||||
FADS823_config \
|
||||
FADS850SAR_config \
|
||||
|
66
README
66
README
@ -249,6 +249,7 @@ The following options need to be configured:
|
||||
CONFIG_SA1110
|
||||
CONFIG_ARM7
|
||||
CONFIG_PXA250
|
||||
CONFIG_PXA27X
|
||||
CONFIG_CPU_MONAHANS
|
||||
|
||||
MicroBlaze based CPUs:
|
||||
@ -893,6 +894,71 @@ The following options need to be configured:
|
||||
CONFIG_USB_CONFIG
|
||||
for differential drivers: 0x00001000
|
||||
for single ended drivers: 0x00005000
|
||||
CFG_USB_EVENT_POLL
|
||||
May be defined to allow interrupt polling
|
||||
instead of using asynchronous interrupts
|
||||
|
||||
- USB Device:
|
||||
Define the below if you wish to use the USB console.
|
||||
Once firmware is rebuilt from a serial console issue the
|
||||
command "setenv stdin usbtty; setenv stdout usbtty" and
|
||||
attach your usb cable. The Unix command "dmesg" should print
|
||||
it has found a new device. The environment variable usbtty
|
||||
can be set to gserial or cdc_acm to enable your device to
|
||||
appear to a USB host as a Linux gserial device or a
|
||||
Common Device Class Abstract Control Model serial device.
|
||||
If you select usbtty = gserial you should be able to enumerate
|
||||
a Linux host by
|
||||
# modprobe usbserial vendor=0xVendorID product=0xProductID
|
||||
else if using cdc_acm, simply setting the environment
|
||||
variable usbtty to be cdc_acm should suffice. The following
|
||||
might be defined in YourBoardName.h
|
||||
|
||||
CONFIG_USB_DEVICE
|
||||
Define this to build a UDC device
|
||||
|
||||
CONFIG_USB_TTY
|
||||
Define this to have a tty type of device available to
|
||||
talk to the UDC device
|
||||
|
||||
CFG_CONSOLE_IS_IN_ENV
|
||||
Define this if you want stdin, stdout &/or stderr to
|
||||
be set to usbtty.
|
||||
|
||||
mpc8xx:
|
||||
CFG_USB_EXTC_CLK 0xBLAH
|
||||
Derive USB clock from external clock "blah"
|
||||
- CFG_USB_EXTC_CLK 0x02
|
||||
|
||||
CFG_USB_BRG_CLK 0xBLAH
|
||||
Derive USB clock from brgclk
|
||||
- CFG_USB_BRG_CLK 0x04
|
||||
|
||||
If you have a USB-IF assigned VendorID then you may wish to
|
||||
define your own vendor specific values either in BoardName.h
|
||||
or directly in usbd_vendor_info.h. If you don't define
|
||||
CONFIG_USBD_MANUFACTURER, CONFIG_USBD_PRODUCT_NAME,
|
||||
CONFIG_USBD_VENDORID and CONFIG_USBD_PRODUCTID, then U-Boot
|
||||
should pretend to be a Linux device to it's target host.
|
||||
|
||||
CONFIG_USBD_MANUFACTURER
|
||||
Define this string as the name of your company for
|
||||
- CONFIG_USBD_MANUFACTURER "my company"
|
||||
|
||||
CONFIG_USBD_PRODUCT_NAME
|
||||
Define this string as the name of your product
|
||||
- CONFIG_USBD_PRODUCT_NAME "acme usb device"
|
||||
|
||||
CONFIG_USBD_VENDORID
|
||||
Define this as your assigned Vendor ID from the USB
|
||||
Implementors Forum. This *must* be a genuine Vendor ID
|
||||
to avoid polluting the USB namespace.
|
||||
- CONFIG_USBD_VENDORID 0xFFFF
|
||||
|
||||
CONFIG_USBD_PRODUCTID
|
||||
Define this as the unique Product ID
|
||||
for your device
|
||||
- CONFIG_USBD_PRODUCTID 0xFFFF
|
||||
|
||||
|
||||
- MMC Support:
|
||||
|
@ -1,10 +1,6 @@
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
||||
* Marius Groeger <mgroeger@sysgo.de>
|
||||
* (C) Copyright 2006
|
||||
* DENX Software Engineering
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
@ -98,7 +94,6 @@ int board_late_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Magic Key Handling, mainly copied from board/lwmon/lwmon.c
|
||||
*/
|
||||
@ -324,6 +319,12 @@ static void init_DA9030()
|
||||
return;
|
||||
}
|
||||
|
||||
val = 0x80;
|
||||
if(i2c_write(addr, IRQ_MASK_B, 1, &val, 1)) {
|
||||
printf("Error accessing DA9030 via i2c.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
i2c_reg_write(addr, REG_CONTROL_1_97, 0xfd); /* disable LDO1, enable LDO6 */
|
||||
i2c_reg_write(addr, LDO2_3, 0xd1); /* LDO2 =1,9V, LDO3=3,1V */
|
||||
i2c_reg_write(addr, LDO4_5, 0xcc); /* LDO2 =1,9V, LDO3=3,1V */
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#ifdef CONFIG_AUTO_UPDATE
|
||||
|
||||
#ifndef CONFIG_USB_OHCI
|
||||
#ifndef CONFIG_USB_OHCI_NEW
|
||||
#error "must define CONFIG_USB_OHCI"
|
||||
#endif
|
||||
|
||||
|
@ -129,7 +129,11 @@ static int usb_kbd_testc(void)
|
||||
static int usb_kbd_getc(void)
|
||||
{
|
||||
char c;
|
||||
while(usb_in_pointer==usb_out_pointer);
|
||||
while(usb_in_pointer==usb_out_pointer) {
|
||||
#ifdef CFG_USB_EVENT_POLL
|
||||
usb_event_poll();
|
||||
#endif
|
||||
}
|
||||
if((usb_out_pointer+1)==USB_KBD_BUFFER_LEN)
|
||||
usb_out_pointer=0;
|
||||
else
|
||||
|
@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
|
||||
LIB = $(obj)lib$(SOC).a
|
||||
|
||||
COBJS = bcm5221.o dm9161.o ether.o i2c.o interrupts.o \
|
||||
lxt972.o serial.o usb_ohci.o
|
||||
lxt972.o serial.o usb.o
|
||||
SOBJS = lowlevel_init.o
|
||||
|
||||
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
|
||||
|
53
cpu/arm920t/at91rm9200/usb.c
Normal file
53
cpu/arm920t/at91rm9200/usb.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* (C) Copyright 2006
|
||||
* DENX Software Engineering <mk@denx.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_NEW) && defined(CFG_USB_OHCI_CPU_INIT)
|
||||
# ifdef CONFIG_AT91RM9200
|
||||
|
||||
#include <asm/arch/hardware.h>
|
||||
|
||||
int usb_cpu_init()
|
||||
{
|
||||
/* Enable USB host clock. */
|
||||
*AT91C_PMC_SCER = AT91C_PMC_UHP; /* 48MHz clock enabled for UHP */
|
||||
*AT91C_PMC_PCER = 1 << AT91C_ID_UHP; /* Peripheral Clock Enable Register */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_stop()
|
||||
{
|
||||
/* Initialization failed */
|
||||
*AT91C_PMC_PCDR = 1 << AT91C_ID_UHP; /* Peripheral Clock Disable Register */
|
||||
*AT91C_PMC_SCDR = AT91C_PMC_UHP; /* 48MHz clock disabled for UHP */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_init_fail()
|
||||
{
|
||||
usb_cpu_stop();
|
||||
}
|
||||
|
||||
# endif /* CONFIG_AT91RM9200 */
|
||||
#endif /* defined(CONFIG_USB_OHCI) && defined(CFG_USB_OHCI_CPU_INIT) */
|
@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
|
||||
LIB = $(obj)lib$(SOC).a
|
||||
|
||||
COBJS = i2c.o interrupts.o serial.o speed.o \
|
||||
usb_ohci.o
|
||||
usb.o
|
||||
|
||||
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
|
||||
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
|
||||
|
72
cpu/arm920t/s3c24x0/usb.c
Normal file
72
cpu/arm920t/s3c24x0/usb.c
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* (C) Copyright 2006
|
||||
* DENX Software Engineering <mk@denx.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_NEW) && defined(CFG_USB_OHCI_CPU_INIT)
|
||||
# if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
|
||||
|
||||
#if defined(CONFIG_S3C2400)
|
||||
# include <s3c2400.h>
|
||||
#elif defined(CONFIG_S3C2410)
|
||||
# include <s3c2410.h>
|
||||
#endif
|
||||
|
||||
int usb_cpu_init (void)
|
||||
{
|
||||
|
||||
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
/*
|
||||
* Set the 48 MHz UPLL clocking. Values are taken from
|
||||
* "PLL value selection guide", 6-23, s3c2400_UM.pdf.
|
||||
*/
|
||||
clk_power->UPLLCON = ((40 << 12) + (1 << 4) + 2);
|
||||
gpio->MISCCR |= 0x8; /* 1 = use pads related USB for USB host */
|
||||
|
||||
/*
|
||||
* Enable USB host clock.
|
||||
*/
|
||||
clk_power->CLKCON |= (1 << 4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_stop (void)
|
||||
{
|
||||
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
|
||||
/* may not want to do this */
|
||||
clk_power->CLKCON &= ~(1 << 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_init_fail (void)
|
||||
{
|
||||
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
|
||||
clk_power->CLKCON &= ~(1 << 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif /* defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) */
|
||||
#endif /* defined(CONFIG_USB_OHCI) && defined(CFG_USB_OHCI_CPU_INIT) */
|
@ -28,7 +28,7 @@ LIB = $(obj)lib$(CPU).a
|
||||
START = start.o
|
||||
SOBJS = io.o firmware_sc_task_bestcomm.impl.o firmware_sc_task.impl.o
|
||||
COBJS = i2c.o traps.o cpu.o cpu_init.o fec.o ide.o interrupts.o \
|
||||
loadtask.o pci_mpc5200.o serial.o speed.o usb_ohci.o
|
||||
loadtask.o pci_mpc5200.o serial.o speed.o usb_ohci.o usb.o
|
||||
|
||||
SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
|
||||
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
|
||||
|
54
cpu/mpc5xxx/usb.c
Normal file
54
cpu/mpc5xxx/usb.c
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* (C) Copyright 2007
|
||||
* Markus Klotzbuecher, DENX Software Engineering <mk@denx.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_NEW) && defined(CFG_USB_OHCI_CPU_INIT)
|
||||
|
||||
#include <mpc5xxx.h>
|
||||
|
||||
int usb_cpu_init()
|
||||
{
|
||||
/* Set the USB Clock */
|
||||
*(vu_long *)MPC5XXX_CDM_48_FDC = CONFIG_USB_CLOCK;
|
||||
|
||||
/* remove all USB bits first before ORing in ours */
|
||||
*(vu_long *)MPC5XXX_GPS_PORT_CONFIG &= ~0x00807000;
|
||||
|
||||
/* Activate USB port */
|
||||
*(vu_long *)MPC5XXX_GPS_PORT_CONFIG |= CONFIG_USB_CONFIG;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_stop()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_init_fail()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_USB_OHCI) && defined(CFG_USB_OHCI_CPU_INIT) */
|
@ -27,12 +27,12 @@ LIB = $(obj)lib$(CPU).a
|
||||
|
||||
START = start.o resetvec.o kgdb.o
|
||||
SOBJS = dcr.o
|
||||
COBJS = 405gp_pci.o 4xx_enet.o \
|
||||
COBJS = 405gp_pci.o 440spe_pcie.o 4xx_enet.o \
|
||||
bedbug_405.o commproc.o \
|
||||
cpu.o cpu_init.o gpio.o i2c.o interrupts.o \
|
||||
miiphy.o ndfc.o sdram.o serial.o \
|
||||
40x_spd_sdram.o 44x_spd_ddr.o 44x_spd_ddr2.o speed.o \
|
||||
tlb.o traps.o usb_ohci.o usbdev.o \
|
||||
tlb.o traps.o usb_ohci.o usb.o usbdev.o \
|
||||
440spe_pcie.o
|
||||
|
||||
SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
|
||||
|
50
cpu/ppc4xx/usb.c
Normal file
50
cpu/ppc4xx/usb.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* (C) Copyright 2007
|
||||
* Markus Klotzbuecher, DENX Software Engineering <mk@denx.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_NEW) && defined(CFG_USB_OHCI_CPU_INIT)
|
||||
|
||||
#include "usbdev.h"
|
||||
|
||||
int usb_cpu_init()
|
||||
{
|
||||
|
||||
#if defined(CONFIG_440EP) || defined(CONFIG_440EPX)
|
||||
usb_dev_init();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_stop()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_init_fail()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_USB_OHCI) && defined(CFG_USB_OHCI_CPU_INIT) */
|
@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
|
||||
LIB = $(obj)lib$(CPU).a
|
||||
|
||||
START = start.o
|
||||
COBJS = serial.o interrupts.o cpu.o i2c.o pxafb.o mmc.o
|
||||
COBJS = serial.o interrupts.o cpu.o i2c.o pxafb.o mmc.o usb.o
|
||||
|
||||
SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
|
||||
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
|
||||
|
79
cpu/pxa/usb.c
Normal file
79
cpu/pxa/usb.c
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* (C) Copyright 2006
|
||||
* Markus Klotzbuecher, DENX Software Engineering <mk@denx.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_NEW) && defined(CFG_USB_OHCI_CPU_INIT)
|
||||
# if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
|
||||
|
||||
#include <asm/arch/pxa-regs.h>
|
||||
|
||||
int usb_cpu_init()
|
||||
{
|
||||
#if defined(CONFIG_CPU_MONAHANS)
|
||||
/* Enable USB host clock. */
|
||||
CKENA |= (CKENA_2_USBHOST | CKENA_20_UDC);
|
||||
udelay(100);
|
||||
#endif
|
||||
#if defined(CONFIG_PXA27X)
|
||||
/* Enable USB host clock. */
|
||||
CKEN |= CKEN10_USBHOST;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CPU_MONAHANS)
|
||||
/* Configure Port 2 for Host (USB Client Registers) */
|
||||
UP2OCR = 0x3000c;
|
||||
#endif
|
||||
|
||||
UHCHR |= UHCHR_FHR;
|
||||
wait_ms(11);
|
||||
UHCHR &= ~UHCHR_FHR;
|
||||
|
||||
UHCHR |= UHCHR_FSBIR;
|
||||
while (UHCHR & UHCHR_FSBIR)
|
||||
udelay(1);
|
||||
|
||||
#if defined(CONFIG_CPU_MONAHANS)
|
||||
UHCHR &= ~UHCHR_SSEP0;
|
||||
#endif
|
||||
#if defined(CONFIG_PXA27X)
|
||||
UHCHR &= ~UHCHR_SSEP2;
|
||||
#endif
|
||||
UHCHR &= ~UHCHR_SSEP1;
|
||||
UHCHR &= ~UHCHR_SSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_stop()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_cpu_init_fail()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X) */
|
||||
#endif /* defined(CONFIG_USB_OHCI) && defined(CFG_USB_OHCI_CPU_INIT) */
|
60
doc/README.generic_usb_ohci
Normal file
60
doc/README.generic_usb_ohci
Normal file
@ -0,0 +1,60 @@
|
||||
Notes on the the generic USB-OHCI driver
|
||||
========================================
|
||||
|
||||
This driver (drivers/usb_ohci.[ch]) is the result of the merge of
|
||||
various existing OHCI drivers that were basically identical beside
|
||||
cpu/board dependant initalization. This initalization has been moved
|
||||
into cpu/board directories and are called via the hooks below.
|
||||
|
||||
Configuration options
|
||||
----------------------
|
||||
|
||||
CONFIG_USB_OHCI_NEW: enable the new OHCI driver
|
||||
|
||||
CFG_USB_OHCI_BOARD_INIT: call the board dependant hooks:
|
||||
|
||||
- extern int usb_board_init(void);
|
||||
- extern int usb_board_stop(void);
|
||||
- extern int usb_cpu_init_fail(void);
|
||||
|
||||
CFG_USB_OHCI_CPU_INIT: call the cpu dependant hooks:
|
||||
|
||||
- extern int usb_cpu_init(void);
|
||||
- extern int usb_cpu_stop(void);
|
||||
- extern int usb_cpu_init_fail(void);
|
||||
|
||||
CFG_USB_OHCI_REGS_BASE: defines the base address of the OHCI
|
||||
registers
|
||||
|
||||
CFG_USB_OHCI_SLOT_NAME: slot name
|
||||
|
||||
CFG_USB_OHCI_MAX_ROOT_PORTS: maximal number of ports of the
|
||||
root hub.
|
||||
|
||||
|
||||
Endianness issues
|
||||
------------------
|
||||
|
||||
The USB bus operates in little endian, but unfortunately there are
|
||||
OHCI controllers that operate in big endian such as ppc4xx and
|
||||
mpc5xxx. For these the config option
|
||||
|
||||
CFG_OHCI_BE_CONTROLLER
|
||||
|
||||
needs to be defined.
|
||||
|
||||
|
||||
PCI Controllers
|
||||
----------------
|
||||
|
||||
You'll need to define
|
||||
|
||||
CONFIG_PCI_OHCI
|
||||
|
||||
PCI Controllers need to do byte swapping on register accesses, so they
|
||||
should to define:
|
||||
|
||||
CFG_OHCI_SWAP_REG_ACCESS
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ COBJS = 3c589.o 5701rls.o ali512x.o ata_piix.o atmel_usart.o \
|
||||
bcm570x.o bcm570x_autoneg.o cfb_console.o cfi_flash.o \
|
||||
cs8900.o ct69000.o dataflash.o dc2114x.o dm9000x.o \
|
||||
e1000.o eepro100.o enc28j60.o \
|
||||
i8042.o inca-ip_sw.o keyboard.o \
|
||||
i8042.o inca-ip_sw.o isp116x-hcd.o keyboard.o \
|
||||
lan91c96.o macb.o \
|
||||
natsemi.o ne2000.o netarm_eth.o netconsole.o \
|
||||
ns16550.o ns8382x.o ns87308.o ns7520_eth.o omap1510_i2c.o \
|
||||
@ -47,7 +47,9 @@ COBJS = 3c589.o 5701rls.o ali512x.o ata_piix.o atmel_usart.o \
|
||||
status_led.o sym53c8xx.o systemace.o ahci.o \
|
||||
ti_pci1410a.o tigon3.o tsec.o \
|
||||
tsi108_eth.o tsi108_i2c.o tsi108_pci.o \
|
||||
usbdcore.o usbdcore_ep0.o usbdcore_omap1510.o usbtty.o \
|
||||
usb_ohci.o \
|
||||
usbdcore.o usbdcore_ep0.o usbdcore_mpc8xx.o usbdcore_omap1510.o \
|
||||
usbtty.o \
|
||||
videomodes.o w83c553f.o \
|
||||
ks8695eth.o \
|
||||
pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o \
|
||||
|
1413
drivers/isp116x-hcd.c
Normal file
1413
drivers/isp116x-hcd.c
Normal file
File diff suppressed because it is too large
Load Diff
489
drivers/isp116x.h
Normal file
489
drivers/isp116x.h
Normal file
@ -0,0 +1,489 @@
|
||||
/*
|
||||
* ISP116x register declarations and HCD data structures
|
||||
*
|
||||
* Copyright (C) 2007 Rodolfo Giometti <giometti@linux.it>
|
||||
* Copyright (C) 2007 Eurotech S.p.A. <info@eurotech.it>
|
||||
* Copyright (C) 2005 Olav Kongas <ok@artecdesign.ee>
|
||||
* Portions:
|
||||
* Copyright (C) 2004 Lothar Wassmann
|
||||
* Copyright (C) 2004 Psion Teklogix
|
||||
* Copyright (C) 2004 David Brownell
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(fmt, args...) \
|
||||
printf("isp116x: %s: " fmt "\n" , __FUNCTION__ , ## args)
|
||||
#else
|
||||
#define DBG(fmt, args...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
# define VDBG DBG
|
||||
#else
|
||||
# define VDBG(fmt, args...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#define ERR(fmt, args...) \
|
||||
printf("isp116x: %s: " fmt "\n" , __FUNCTION__ , ## args)
|
||||
#define WARN(fmt, args...) \
|
||||
printf("isp116x: %s: " fmt "\n" , __FUNCTION__ , ## args)
|
||||
#define INFO(fmt, args...) \
|
||||
printf("isp116x: " fmt "\n" , ## args)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* us of 1ms frame */
|
||||
#define MAX_LOAD_LIMIT 850
|
||||
|
||||
/* Full speed: max # of bytes to transfer for a single urb
|
||||
at a time must be < 1024 && must be multiple of 64.
|
||||
832 allows transfering 4kiB within 5 frames. */
|
||||
#define MAX_TRANSFER_SIZE_FULLSPEED 832
|
||||
|
||||
/* Low speed: there is no reason to schedule in very big
|
||||
chunks; often the requested long transfers are for
|
||||
string descriptors containing short strings. */
|
||||
#define MAX_TRANSFER_SIZE_LOWSPEED 64
|
||||
|
||||
/* Bytetime (us), a rough indication of how much time it
|
||||
would take to transfer a byte of useful data over USB */
|
||||
#define BYTE_TIME_FULLSPEED 1
|
||||
#define BYTE_TIME_LOWSPEED 20
|
||||
|
||||
/* Buffer sizes */
|
||||
#define ISP116x_BUF_SIZE 4096
|
||||
#define ISP116x_ITL_BUFSIZE 0
|
||||
#define ISP116x_ATL_BUFSIZE ((ISP116x_BUF_SIZE) - 2*(ISP116x_ITL_BUFSIZE))
|
||||
|
||||
#define ISP116x_WRITE_OFFSET 0x80
|
||||
|
||||
/* --- ISP116x registers/bits ---------------------------------------------- */
|
||||
|
||||
#define HCREVISION 0x00
|
||||
#define HCCONTROL 0x01
|
||||
#define HCCONTROL_HCFS (3 << 6) /* host controller
|
||||
functional state */
|
||||
#define HCCONTROL_USB_RESET (0 << 6)
|
||||
#define HCCONTROL_USB_RESUME (1 << 6)
|
||||
#define HCCONTROL_USB_OPER (2 << 6)
|
||||
#define HCCONTROL_USB_SUSPEND (3 << 6)
|
||||
#define HCCONTROL_RWC (1 << 9) /* remote wakeup connected */
|
||||
#define HCCONTROL_RWE (1 << 10) /* remote wakeup enable */
|
||||
#define HCCMDSTAT 0x02
|
||||
#define HCCMDSTAT_HCR (1 << 0) /* host controller reset */
|
||||
#define HCCMDSTAT_SOC (3 << 16) /* scheduling overrun count */
|
||||
#define HCINTSTAT 0x03
|
||||
#define HCINT_SO (1 << 0) /* scheduling overrun */
|
||||
#define HCINT_WDH (1 << 1) /* writeback of done_head */
|
||||
#define HCINT_SF (1 << 2) /* start frame */
|
||||
#define HCINT_RD (1 << 3) /* resume detect */
|
||||
#define HCINT_UE (1 << 4) /* unrecoverable error */
|
||||
#define HCINT_FNO (1 << 5) /* frame number overflow */
|
||||
#define HCINT_RHSC (1 << 6) /* root hub status change */
|
||||
#define HCINT_OC (1 << 30) /* ownership change */
|
||||
#define HCINT_MIE (1 << 31) /* master interrupt enable */
|
||||
#define HCINTENB 0x04
|
||||
#define HCINTDIS 0x05
|
||||
#define HCFMINTVL 0x0d
|
||||
#define HCFMREM 0x0e
|
||||
#define HCFMNUM 0x0f
|
||||
#define HCLSTHRESH 0x11
|
||||
#define HCRHDESCA 0x12
|
||||
#define RH_A_NDP (0x3 << 0) /* # downstream ports */
|
||||
#define RH_A_PSM (1 << 8) /* power switching mode */
|
||||
#define RH_A_NPS (1 << 9) /* no power switching */
|
||||
#define RH_A_DT (1 << 10) /* device type (mbz) */
|
||||
#define RH_A_OCPM (1 << 11) /* overcurrent protection
|
||||
mode */
|
||||
#define RH_A_NOCP (1 << 12) /* no overcurrent protection */
|
||||
#define RH_A_POTPGT (0xff << 24) /* power on -> power good
|
||||
time */
|
||||
#define HCRHDESCB 0x13
|
||||
#define RH_B_DR (0xffff << 0) /* device removable flags */
|
||||
#define RH_B_PPCM (0xffff << 16) /* port power control mask */
|
||||
#define HCRHSTATUS 0x14
|
||||
#define RH_HS_LPS (1 << 0) /* local power status */
|
||||
#define RH_HS_OCI (1 << 1) /* over current indicator */
|
||||
#define RH_HS_DRWE (1 << 15) /* device remote wakeup
|
||||
enable */
|
||||
#define RH_HS_LPSC (1 << 16) /* local power status change */
|
||||
#define RH_HS_OCIC (1 << 17) /* over current indicator
|
||||
change */
|
||||
#define RH_HS_CRWE (1 << 31) /* clear remote wakeup
|
||||
enable */
|
||||
#define HCRHPORT1 0x15
|
||||
#define RH_PS_CCS (1 << 0) /* current connect status */
|
||||
#define RH_PS_PES (1 << 1) /* port enable status */
|
||||
#define RH_PS_PSS (1 << 2) /* port suspend status */
|
||||
#define RH_PS_POCI (1 << 3) /* port over current
|
||||
indicator */
|
||||
#define RH_PS_PRS (1 << 4) /* port reset status */
|
||||
#define RH_PS_PPS (1 << 8) /* port power status */
|
||||
#define RH_PS_LSDA (1 << 9) /* low speed device attached */
|
||||
#define RH_PS_CSC (1 << 16) /* connect status change */
|
||||
#define RH_PS_PESC (1 << 17) /* port enable status change */
|
||||
#define RH_PS_PSSC (1 << 18) /* port suspend status
|
||||
change */
|
||||
#define RH_PS_OCIC (1 << 19) /* over current indicator
|
||||
change */
|
||||
#define RH_PS_PRSC (1 << 20) /* port reset status change */
|
||||
#define HCRHPORT_CLRMASK (0x1f << 16)
|
||||
#define HCRHPORT2 0x16
|
||||
#define HCHWCFG 0x20
|
||||
#define HCHWCFG_15KRSEL (1 << 12)
|
||||
#define HCHWCFG_CLKNOTSTOP (1 << 11)
|
||||
#define HCHWCFG_ANALOG_OC (1 << 10)
|
||||
#define HCHWCFG_DACK_MODE (1 << 8)
|
||||
#define HCHWCFG_EOT_POL (1 << 7)
|
||||
#define HCHWCFG_DACK_POL (1 << 6)
|
||||
#define HCHWCFG_DREQ_POL (1 << 5)
|
||||
#define HCHWCFG_DBWIDTH_MASK (0x03 << 3)
|
||||
#define HCHWCFG_DBWIDTH(n) (((n) << 3) & HCHWCFG_DBWIDTH_MASK)
|
||||
#define HCHWCFG_INT_POL (1 << 2)
|
||||
#define HCHWCFG_INT_TRIGGER (1 << 1)
|
||||
#define HCHWCFG_INT_ENABLE (1 << 0)
|
||||
#define HCDMACFG 0x21
|
||||
#define HCDMACFG_BURST_LEN_MASK (0x03 << 5)
|
||||
#define HCDMACFG_BURST_LEN(n) (((n) << 5) & HCDMACFG_BURST_LEN_MASK)
|
||||
#define HCDMACFG_BURST_LEN_1 HCDMACFG_BURST_LEN(0)
|
||||
#define HCDMACFG_BURST_LEN_4 HCDMACFG_BURST_LEN(1)
|
||||
#define HCDMACFG_BURST_LEN_8 HCDMACFG_BURST_LEN(2)
|
||||
#define HCDMACFG_DMA_ENABLE (1 << 4)
|
||||
#define HCDMACFG_BUF_TYPE_MASK (0x07 << 1)
|
||||
#define HCDMACFG_CTR_SEL (1 << 2)
|
||||
#define HCDMACFG_ITLATL_SEL (1 << 1)
|
||||
#define HCDMACFG_DMA_RW_SELECT (1 << 0)
|
||||
#define HCXFERCTR 0x22
|
||||
#define HCuPINT 0x24
|
||||
#define HCuPINT_SOF (1 << 0)
|
||||
#define HCuPINT_ATL (1 << 1)
|
||||
#define HCuPINT_AIIEOT (1 << 2)
|
||||
#define HCuPINT_OPR (1 << 4)
|
||||
#define HCuPINT_SUSP (1 << 5)
|
||||
#define HCuPINT_CLKRDY (1 << 6)
|
||||
#define HCuPINTENB 0x25
|
||||
#define HCCHIPID 0x27
|
||||
#define HCCHIPID_MASK 0xff00
|
||||
#define HCCHIPID_MAGIC 0x6100
|
||||
#define HCSCRATCH 0x28
|
||||
#define HCSWRES 0x29
|
||||
#define HCSWRES_MAGIC 0x00f6
|
||||
#define HCITLBUFLEN 0x2a
|
||||
#define HCATLBUFLEN 0x2b
|
||||
#define HCBUFSTAT 0x2c
|
||||
#define HCBUFSTAT_ITL0_FULL (1 << 0)
|
||||
#define HCBUFSTAT_ITL1_FULL (1 << 1)
|
||||
#define HCBUFSTAT_ATL_FULL (1 << 2)
|
||||
#define HCBUFSTAT_ITL0_DONE (1 << 3)
|
||||
#define HCBUFSTAT_ITL1_DONE (1 << 4)
|
||||
#define HCBUFSTAT_ATL_DONE (1 << 5)
|
||||
#define HCRDITL0LEN 0x2d
|
||||
#define HCRDITL1LEN 0x2e
|
||||
#define HCITLPORT 0x40
|
||||
#define HCATLPORT 0x41
|
||||
|
||||
/* PTD accessor macros. */
|
||||
#define PTD_GET_COUNT(p) (((p)->count & PTD_COUNT_MSK) >> 0)
|
||||
#define PTD_COUNT(v) (((v) << 0) & PTD_COUNT_MSK)
|
||||
#define PTD_GET_TOGGLE(p) (((p)->count & PTD_TOGGLE_MSK) >> 10)
|
||||
#define PTD_TOGGLE(v) (((v) << 10) & PTD_TOGGLE_MSK)
|
||||
#define PTD_GET_ACTIVE(p) (((p)->count & PTD_ACTIVE_MSK) >> 11)
|
||||
#define PTD_ACTIVE(v) (((v) << 11) & PTD_ACTIVE_MSK)
|
||||
#define PTD_GET_CC(p) (((p)->count & PTD_CC_MSK) >> 12)
|
||||
#define PTD_CC(v) (((v) << 12) & PTD_CC_MSK)
|
||||
#define PTD_GET_MPS(p) (((p)->mps & PTD_MPS_MSK) >> 0)
|
||||
#define PTD_MPS(v) (((v) << 0) & PTD_MPS_MSK)
|
||||
#define PTD_GET_SPD(p) (((p)->mps & PTD_SPD_MSK) >> 10)
|
||||
#define PTD_SPD(v) (((v) << 10) & PTD_SPD_MSK)
|
||||
#define PTD_GET_LAST(p) (((p)->mps & PTD_LAST_MSK) >> 11)
|
||||
#define PTD_LAST(v) (((v) << 11) & PTD_LAST_MSK)
|
||||
#define PTD_GET_EP(p) (((p)->mps & PTD_EP_MSK) >> 12)
|
||||
#define PTD_EP(v) (((v) << 12) & PTD_EP_MSK)
|
||||
#define PTD_GET_LEN(p) (((p)->len & PTD_LEN_MSK) >> 0)
|
||||
#define PTD_LEN(v) (((v) << 0) & PTD_LEN_MSK)
|
||||
#define PTD_GET_DIR(p) (((p)->len & PTD_DIR_MSK) >> 10)
|
||||
#define PTD_DIR(v) (((v) << 10) & PTD_DIR_MSK)
|
||||
#define PTD_GET_B5_5(p) (((p)->len & PTD_B5_5_MSK) >> 13)
|
||||
#define PTD_B5_5(v) (((v) << 13) & PTD_B5_5_MSK)
|
||||
#define PTD_GET_FA(p) (((p)->faddr & PTD_FA_MSK) >> 0)
|
||||
#define PTD_FA(v) (((v) << 0) & PTD_FA_MSK)
|
||||
#define PTD_GET_FMT(p) (((p)->faddr & PTD_FMT_MSK) >> 7)
|
||||
#define PTD_FMT(v) (((v) << 7) & PTD_FMT_MSK)
|
||||
|
||||
/* Hardware transfer status codes -- CC from ptd->count */
|
||||
#define TD_CC_NOERROR 0x00
|
||||
#define TD_CC_CRC 0x01
|
||||
#define TD_CC_BITSTUFFING 0x02
|
||||
#define TD_CC_DATATOGGLEM 0x03
|
||||
#define TD_CC_STALL 0x04
|
||||
#define TD_DEVNOTRESP 0x05
|
||||
#define TD_PIDCHECKFAIL 0x06
|
||||
#define TD_UNEXPECTEDPID 0x07
|
||||
#define TD_DATAOVERRUN 0x08
|
||||
#define TD_DATAUNDERRUN 0x09
|
||||
/* 0x0A, 0x0B reserved for hardware */
|
||||
#define TD_BUFFEROVERRUN 0x0C
|
||||
#define TD_BUFFERUNDERRUN 0x0D
|
||||
/* 0x0E, 0x0F reserved for HCD */
|
||||
#define TD_NOTACCESSED 0x0F
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define LOG2_PERIODIC_SIZE 5 /* arbitrary; this matches OHCI */
|
||||
#define PERIODIC_SIZE (1 << LOG2_PERIODIC_SIZE)
|
||||
|
||||
/* Philips transfer descriptor */
|
||||
struct ptd {
|
||||
u16 count;
|
||||
#define PTD_COUNT_MSK (0x3ff << 0)
|
||||
#define PTD_TOGGLE_MSK (1 << 10)
|
||||
#define PTD_ACTIVE_MSK (1 << 11)
|
||||
#define PTD_CC_MSK (0xf << 12)
|
||||
u16 mps;
|
||||
#define PTD_MPS_MSK (0x3ff << 0)
|
||||
#define PTD_SPD_MSK (1 << 10)
|
||||
#define PTD_LAST_MSK (1 << 11)
|
||||
#define PTD_EP_MSK (0xf << 12)
|
||||
u16 len;
|
||||
#define PTD_LEN_MSK (0x3ff << 0)
|
||||
#define PTD_DIR_MSK (3 << 10)
|
||||
#define PTD_DIR_SETUP (0)
|
||||
#define PTD_DIR_OUT (1)
|
||||
#define PTD_DIR_IN (2)
|
||||
#define PTD_B5_5_MSK (1 << 13)
|
||||
u16 faddr;
|
||||
#define PTD_FA_MSK (0x7f << 0)
|
||||
#define PTD_FMT_MSK (1 << 7)
|
||||
} __attribute__ ((packed, aligned(2)));
|
||||
|
||||
struct isp116x_ep {
|
||||
struct usb_device *udev;
|
||||
struct ptd ptd;
|
||||
|
||||
u8 maxpacket;
|
||||
u8 epnum;
|
||||
u8 nextpid;
|
||||
|
||||
u16 length; /* of current packet */
|
||||
unsigned char *data; /* to databuf */
|
||||
|
||||
u16 error_count;
|
||||
};
|
||||
|
||||
/* URB struct */
|
||||
#define N_URB_TD 48
|
||||
#define URB_DEL 1
|
||||
typedef struct {
|
||||
struct isp116x_ep *ed;
|
||||
void *transfer_buffer; /* (in) associated data buffer */
|
||||
int actual_length; /* (return) actual transfer length */
|
||||
unsigned long pipe; /* (in) pipe information */
|
||||
#if 0
|
||||
int state;
|
||||
#endif
|
||||
} urb_priv_t;
|
||||
|
||||
struct isp116x_platform_data {
|
||||
/* Enable internal resistors on downstream ports */
|
||||
unsigned sel15Kres:1;
|
||||
/* On-chip overcurrent detection */
|
||||
unsigned oc_enable:1;
|
||||
/* Enable wakeup by devices on usb bus (e.g. wakeup
|
||||
by attachment/detachment or by device activity
|
||||
such as moving a mouse). When chosen, this option
|
||||
prevents stopping internal clock, increasing
|
||||
thereby power consumption in suspended state. */
|
||||
unsigned remote_wakeup_enable:1;
|
||||
};
|
||||
|
||||
struct isp116x {
|
||||
u16 *addr_reg;
|
||||
u16 *data_reg;
|
||||
|
||||
struct isp116x_platform_data *board;
|
||||
|
||||
struct dentry *dentry;
|
||||
unsigned long stat1, stat2, stat4, stat8, stat16;
|
||||
|
||||
/* Status flags */
|
||||
unsigned disabled:1;
|
||||
unsigned sleeping:1;
|
||||
|
||||
/* Root hub registers */
|
||||
u32 rhdesca;
|
||||
u32 rhdescb;
|
||||
u32 rhstatus;
|
||||
u32 rhport[2];
|
||||
|
||||
/* Schedule for the current frame */
|
||||
struct isp116x_ep *atl_active;
|
||||
int atl_buflen;
|
||||
int atl_bufshrt;
|
||||
int atl_last_dir;
|
||||
int atl_finishing;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
|
||||
/* Inter-io delay (ns). The chip is picky about access timings; it
|
||||
* expects at least:
|
||||
* 150ns delay between consecutive accesses to DATA_REG,
|
||||
* 300ns delay between access to ADDR_REG and DATA_REG
|
||||
* OE, WE MUST NOT be changed during these intervals
|
||||
*/
|
||||
#if defined(UDELAY)
|
||||
#define isp116x_delay(h,d) udelay(d)
|
||||
#else
|
||||
#define isp116x_delay(h,d) do {} while (0)
|
||||
#endif
|
||||
|
||||
static inline void isp116x_write_addr(struct isp116x *isp116x, unsigned reg)
|
||||
{
|
||||
writew(reg & 0xff, isp116x->addr_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
}
|
||||
|
||||
static inline void isp116x_write_data16(struct isp116x *isp116x, u16 val)
|
||||
{
|
||||
writew(val, isp116x->data_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
}
|
||||
|
||||
static inline void isp116x_raw_write_data16(struct isp116x *isp116x, u16 val)
|
||||
{
|
||||
__raw_writew(val, isp116x->data_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
}
|
||||
|
||||
static inline u16 isp116x_read_data16(struct isp116x *isp116x)
|
||||
{
|
||||
u16 val;
|
||||
|
||||
val = readw(isp116x->data_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline u16 isp116x_raw_read_data16(struct isp116x *isp116x)
|
||||
{
|
||||
u16 val;
|
||||
|
||||
val = __raw_readw(isp116x->data_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void isp116x_write_data32(struct isp116x *isp116x, u32 val)
|
||||
{
|
||||
writew(val & 0xffff, isp116x->data_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
writew(val >> 16, isp116x->data_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
}
|
||||
|
||||
static inline u32 isp116x_read_data32(struct isp116x *isp116x)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = (u32) readw(isp116x->data_reg);
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
val |= ((u32) readw(isp116x->data_reg)) << 16;
|
||||
isp116x_delay(isp116x, UDELAY);
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Let's keep register access functions out of line. Hint:
|
||||
we wait at least 150 ns at every access.
|
||||
*/
|
||||
static u16 isp116x_read_reg16(struct isp116x *isp116x, unsigned reg)
|
||||
{
|
||||
isp116x_write_addr(isp116x, reg);
|
||||
return isp116x_read_data16(isp116x);
|
||||
}
|
||||
|
||||
static u32 isp116x_read_reg32(struct isp116x *isp116x, unsigned reg)
|
||||
{
|
||||
isp116x_write_addr(isp116x, reg);
|
||||
return isp116x_read_data32(isp116x);
|
||||
}
|
||||
|
||||
static void isp116x_write_reg16(struct isp116x *isp116x, unsigned reg,
|
||||
unsigned val)
|
||||
{
|
||||
isp116x_write_addr(isp116x, reg | ISP116x_WRITE_OFFSET);
|
||||
isp116x_write_data16(isp116x, (u16) (val & 0xffff));
|
||||
}
|
||||
|
||||
static void isp116x_write_reg32(struct isp116x *isp116x, unsigned reg,
|
||||
unsigned val)
|
||||
{
|
||||
isp116x_write_addr(isp116x, reg | ISP116x_WRITE_OFFSET);
|
||||
isp116x_write_data32(isp116x, (u32) val);
|
||||
}
|
||||
|
||||
/* --- USB HUB constants (not OHCI-specific; see hub.h) -------------------- */
|
||||
|
||||
/* destination of request */
|
||||
#define RH_INTERFACE 0x01
|
||||
#define RH_ENDPOINT 0x02
|
||||
#define RH_OTHER 0x03
|
||||
|
||||
#define RH_CLASS 0x20
|
||||
#define RH_VENDOR 0x40
|
||||
|
||||
/* Requests: bRequest << 8 | bmRequestType */
|
||||
#define RH_GET_STATUS 0x0080
|
||||
#define RH_CLEAR_FEATURE 0x0100
|
||||
#define RH_SET_FEATURE 0x0300
|
||||
#define RH_SET_ADDRESS 0x0500
|
||||
#define RH_GET_DESCRIPTOR 0x0680
|
||||
#define RH_SET_DESCRIPTOR 0x0700
|
||||
#define RH_GET_CONFIGURATION 0x0880
|
||||
#define RH_SET_CONFIGURATION 0x0900
|
||||
#define RH_GET_STATE 0x0280
|
||||
#define RH_GET_INTERFACE 0x0A80
|
||||
#define RH_SET_INTERFACE 0x0B00
|
||||
#define RH_SYNC_FRAME 0x0C80
|
||||
/* Our Vendor Specific Request */
|
||||
#define RH_SET_EP 0x2000
|
||||
|
||||
/* Hub port features */
|
||||
#define RH_PORT_CONNECTION 0x00
|
||||
#define RH_PORT_ENABLE 0x01
|
||||
#define RH_PORT_SUSPEND 0x02
|
||||
#define RH_PORT_OVER_CURRENT 0x03
|
||||
#define RH_PORT_RESET 0x04
|
||||
#define RH_PORT_POWER 0x08
|
||||
#define RH_PORT_LOW_SPEED 0x09
|
||||
|
||||
#define RH_C_PORT_CONNECTION 0x10
|
||||
#define RH_C_PORT_ENABLE 0x11
|
||||
#define RH_C_PORT_SUSPEND 0x12
|
||||
#define RH_C_PORT_OVER_CURRENT 0x13
|
||||
#define RH_C_PORT_RESET 0x14
|
||||
|
||||
/* Hub features */
|
||||
#define RH_C_HUB_LOCAL_POWER 0x00
|
||||
#define RH_C_HUB_OVER_CURRENT 0x01
|
||||
|
||||
#define RH_DEVICE_REMOTE_WAKEUP 0x00
|
||||
#define RH_ENDPOINT_STALL 0x01
|
||||
|
||||
#define RH_ACK 0x01
|
||||
#define RH_REQ_ERR -1
|
||||
#define RH_NACK 0x00
|
@ -1,5 +1,11 @@
|
||||
/*
|
||||
* URB OHCI HCD (Host Controller Driver) for USB on the AT91RM9200.
|
||||
* URB OHCI HCD (Host Controller Driver) for USB on the AT91RM9200 and PCI bus.
|
||||
*
|
||||
* Interrupt support is added. Now, it has been tested
|
||||
* on ULI1575 chip and works well with USB keyboard.
|
||||
*
|
||||
* (C) Copyright 2007
|
||||
* Zhang Wei, Freescale Semiconductor, Inc. <wei.zhang@freescale.com>
|
||||
*
|
||||
* (C) Copyright 2003
|
||||
* Gary Jennejohn, DENX Software Engineering <gj@denx.de>
|
||||
@ -21,7 +27,7 @@
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
@ -32,38 +38,66 @@
|
||||
*/
|
||||
/*
|
||||
* IMPORTANT NOTES
|
||||
* 1 - you MUST define LITTLEENDIAN in the configuration file for the
|
||||
* board or this driver will NOT work!
|
||||
* 1 - Read doc/README.generic_usb_ohci
|
||||
* 2 - this driver is intended for use with USB Mass Storage Devices
|
||||
* (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes!
|
||||
* 3 - when running on a PQFP208 AT91RM9200, define CONFIG_AT91C_PQFP_UHPBUG
|
||||
* (BBB) and USB keyboard. There is NO support for Isochronous pipes!
|
||||
* 2 - when running on a PQFP208 AT91RM9200, define CONFIG_AT91C_PQFP_UHPBUG
|
||||
* to activate workaround for bug #41 or this driver will NOT work!
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
/* #include <pci.h> no PCI on the S3C24X0 */
|
||||
|
||||
#ifdef CONFIG_USB_OHCI
|
||||
#ifdef CONFIG_USB_OHCI_NEW
|
||||
|
||||
#include <asm/arch/hardware.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#if defined(CONFIG_PCI_OHCI)
|
||||
# include <pci.h>
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
#include <usb.h>
|
||||
#include "usb_ohci.h"
|
||||
|
||||
#define OHCI_USE_NPS /* force NoPowerSwitching mode */
|
||||
#if defined(CONFIG_ARM920T) || \
|
||||
defined(CONFIG_S3C2400) || \
|
||||
defined(CONFIG_S3C2410) || \
|
||||
defined(CONFIG_440EP) || \
|
||||
defined(CONFIG_PCI_OHCI) || \
|
||||
defined(CONFIG_MPC5200)
|
||||
# define OHCI_USE_NPS /* force NoPowerSwitching mode */
|
||||
#endif
|
||||
|
||||
#undef OHCI_VERBOSE_DEBUG /* not always helpful */
|
||||
#undef DEBUG
|
||||
#undef SHOW_INFO
|
||||
#undef OHCI_FILL_TRACE
|
||||
|
||||
/* For initializing controller (mask in an HCFS mode too) */
|
||||
#define OHCI_CONTROL_INIT \
|
||||
(OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
|
||||
|
||||
#define readl(a) (*((vu_long *)(a)))
|
||||
#define writel(a, b) (*((vu_long *)(b)) = ((vu_long)a))
|
||||
/*
|
||||
* e.g. PCI controllers need this
|
||||
*/
|
||||
#ifdef CFG_OHCI_SWAP_REG_ACCESS
|
||||
# define readl(a) __swap_32(*((vu_long *)(a)))
|
||||
# define writel(a, b) (*((vu_long *)(b)) = __swap_32((vu_long)a))
|
||||
#else
|
||||
# define readl(a) (*((vu_long *)(a)))
|
||||
# define writel(a, b) (*((vu_long *)(b)) = ((vu_long)a))
|
||||
#endif /* CFG_OHCI_SWAP_REG_ACCESS */
|
||||
|
||||
#define min_t(type,x,y) ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
|
||||
|
||||
#undef DEBUG
|
||||
#ifdef CONFIG_PCI_OHCI
|
||||
static struct pci_device_id ohci_pci_ids[] = {
|
||||
{0x10b9, 0x5237}, /* ULI1575 PCI OHCI module ids */
|
||||
/* Please add supported PCI OHCI controller ids here */
|
||||
{0, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg)
|
||||
#else
|
||||
@ -77,8 +111,13 @@
|
||||
#define info(format, arg...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#define m16_swap(x) swap_16(x)
|
||||
#define m32_swap(x) swap_32(x)
|
||||
#ifdef CFG_OHCI_BE_CONTROLLER
|
||||
# define m16_swap(x) cpu_to_be16(x)
|
||||
# define m32_swap(x) cpu_to_be32(x)
|
||||
#else
|
||||
# define m16_swap(x) cpu_to_le16(x)
|
||||
# define m32_swap(x) cpu_to_le32(x)
|
||||
#endif /* CFG_OHCI_BE_CONTROLLER */
|
||||
|
||||
/* global ohci_t */
|
||||
static ohci_t gohci;
|
||||
@ -88,13 +127,13 @@ struct ohci_hcca ghcca[1];
|
||||
struct ohci_hcca *phcca;
|
||||
/* this allocates EDs for all possible endpoints */
|
||||
struct ohci_device ohci_dev;
|
||||
/* urb_priv */
|
||||
urb_priv_t urb_priv;
|
||||
/* RHSC flag */
|
||||
int got_rhsc;
|
||||
/* device which was disconnected */
|
||||
struct usb_device *devgone;
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
|
||||
@ -147,6 +186,7 @@ static void urb_free_priv (urb_priv_t * urb)
|
||||
}
|
||||
}
|
||||
}
|
||||
free(urb);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -157,11 +197,10 @@ static int sohci_get_current_frame_number (struct usb_device * dev);
|
||||
/* debug| print the main components of an URB
|
||||
* small: 0) header + data packets 1) just header */
|
||||
|
||||
static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffer,
|
||||
static void pkt_print (urb_priv_t *purb, struct usb_device * dev,
|
||||
unsigned long pipe, void * buffer,
|
||||
int transfer_len, struct devrequest * setup, char * str, int small)
|
||||
{
|
||||
urb_priv_t * purb = &urb_priv;
|
||||
|
||||
dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx",
|
||||
str,
|
||||
sohci_get_current_frame_number (dev),
|
||||
@ -170,7 +209,7 @@ static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffe
|
||||
usb_pipeout (pipe)? 'O': 'I',
|
||||
usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"):
|
||||
(usb_pipecontrol (pipe)? "CTRL": "BULK"),
|
||||
purb->actual_length,
|
||||
(purb ? purb->actual_length : 0),
|
||||
transfer_len, dev->status);
|
||||
#ifdef OHCI_VERBOSE_DEBUG
|
||||
if (!small) {
|
||||
@ -184,10 +223,11 @@ static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffe
|
||||
}
|
||||
if (transfer_len > 0 && buffer) {
|
||||
printf (__FILE__ ": data(%d/%d):",
|
||||
purb->actual_length,
|
||||
(purb ? purb->actual_length : 0),
|
||||
transfer_len);
|
||||
len = usb_pipeout (pipe)?
|
||||
transfer_len: purb->actual_length;
|
||||
transfer_len:
|
||||
(purb ? purb->actual_length : 0);
|
||||
for (i = 0; i < 16 && i < len; i++)
|
||||
printf (" %02x", ((__u8 *) buffer) [i]);
|
||||
printf ("%s\n", i < len? "...": "");
|
||||
@ -383,13 +423,17 @@ static void ohci_dump (ohci_t *controller, int verbose)
|
||||
|
||||
/* get a transfer request */
|
||||
|
||||
int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int transfer_len, struct devrequest *setup, int interval)
|
||||
int sohci_submit_job(urb_priv_t *urb, struct devrequest *setup)
|
||||
{
|
||||
ohci_t *ohci;
|
||||
ed_t * ed;
|
||||
urb_priv_t *purb_priv;
|
||||
urb_priv_t *purb_priv = urb;
|
||||
int i, size = 0;
|
||||
struct usb_device *dev = urb->dev;
|
||||
unsigned long pipe = urb->pipe;
|
||||
void *buffer = urb->transfer_buffer;
|
||||
int transfer_len = urb->transfer_buffer_length;
|
||||
int interval = urb->interval;
|
||||
|
||||
ohci = &gohci;
|
||||
|
||||
@ -400,8 +444,11 @@ int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* we're about to begin a new transaction here so mark the URB unfinished */
|
||||
urb->finished = 0;
|
||||
|
||||
/* every endpoint has a ed, locate and fill it */
|
||||
if (!(ed = ep_add_ed (dev, pipe))) {
|
||||
if (!(ed = ep_add_ed (dev, pipe, interval, 1))) {
|
||||
err("sohci_submit_job: ENOMEM");
|
||||
return -1;
|
||||
}
|
||||
@ -415,13 +462,17 @@ int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
size = (transfer_len == 0)? 2:
|
||||
(transfer_len - 1) / 4096 + 3;
|
||||
break;
|
||||
case PIPE_INTERRUPT: /* 1 TD */
|
||||
size = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
ed->purb = urb;
|
||||
|
||||
if (size >= (N_URB_TD - 1)) {
|
||||
err("need %d TDs, only have %d", size, N_URB_TD);
|
||||
return -1;
|
||||
}
|
||||
purb_priv = &urb_priv;
|
||||
purb_priv->pipe = pipe;
|
||||
|
||||
/* fill the private part of the URB */
|
||||
@ -457,6 +508,40 @@ int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int sohci_return_job(struct ohci *hc, urb_priv_t *urb)
|
||||
{
|
||||
struct ohci_regs *regs = hc->regs;
|
||||
|
||||
switch (usb_pipetype (urb->pipe)) {
|
||||
case PIPE_INTERRUPT:
|
||||
/* implicitly requeued */
|
||||
if (urb->dev->irq_handle &&
|
||||
(urb->dev->irq_act_len = urb->actual_length)) {
|
||||
writel (OHCI_INTR_WDH, ®s->intrenable);
|
||||
readl (®s->intrenable); /* PCI posting flush */
|
||||
urb->dev->irq_handle(urb->dev);
|
||||
writel (OHCI_INTR_WDH, ®s->intrdisable);
|
||||
readl (®s->intrdisable); /* PCI posting flush */
|
||||
}
|
||||
urb->actual_length = 0;
|
||||
td_submit_job (
|
||||
urb->dev,
|
||||
urb->pipe,
|
||||
urb->transfer_buffer,
|
||||
urb->transfer_buffer_length,
|
||||
NULL,
|
||||
urb,
|
||||
urb->interval);
|
||||
break;
|
||||
case PIPE_CONTROL:
|
||||
case PIPE_BULK:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -470,6 +555,59 @@ static int sohci_get_current_frame_number (struct usb_device *usb_dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* ED handling functions
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/* search for the right branch to insert an interrupt ed into the int tree
|
||||
* do some load ballancing;
|
||||
* returns the branch and
|
||||
* sets the interval to interval = 2^integer (ld (interval)) */
|
||||
|
||||
static int ep_int_ballance (ohci_t * ohci, int interval, int load)
|
||||
{
|
||||
int i, branch = 0;
|
||||
|
||||
/* search for the least loaded interrupt endpoint
|
||||
* branch of all 32 branches
|
||||
*/
|
||||
for (i = 0; i < 32; i++)
|
||||
if (ohci->ohci_int_load [branch] > ohci->ohci_int_load [i])
|
||||
branch = i;
|
||||
|
||||
branch = branch % interval;
|
||||
for (i = branch; i < 32; i += interval)
|
||||
ohci->ohci_int_load [i] += load;
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* 2^int( ld (inter)) */
|
||||
|
||||
static int ep_2_n_interval (int inter)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; ((inter >> i) > 1 ) && (i < 5); i++);
|
||||
return 1 << i;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* the int tree is a binary tree
|
||||
* in order to process it sequentially the indexes of the branches have to be mapped
|
||||
* the mapping reverses the bits of a word of num_bits length */
|
||||
|
||||
static int ep_rev (int num_bits, int word)
|
||||
{
|
||||
int i, wout = 0;
|
||||
|
||||
for (i = 0; i < num_bits; i++)
|
||||
wout |= (((word >> i) & 1) << (num_bits - i - 1));
|
||||
return wout;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* ED handling functions
|
||||
*-------------------------------------------------------------------------*/
|
||||
@ -479,8 +617,15 @@ static int sohci_get_current_frame_number (struct usb_device *usb_dev)
|
||||
static int ep_link (ohci_t *ohci, ed_t *edi)
|
||||
{
|
||||
volatile ed_t *ed = edi;
|
||||
int int_branch;
|
||||
int i;
|
||||
int inter;
|
||||
int interval;
|
||||
int load;
|
||||
__u32 * ed_p;
|
||||
|
||||
ed->state = ED_OPER;
|
||||
ed->int_interval = 0;
|
||||
|
||||
switch (ed->type) {
|
||||
case PIPE_CONTROL:
|
||||
@ -488,7 +633,7 @@ static int ep_link (ohci_t *ohci, ed_t *edi)
|
||||
if (ohci->ed_controltail == NULL) {
|
||||
writel (ed, &ohci->regs->ed_controlhead);
|
||||
} else {
|
||||
ohci->ed_controltail->hwNextED = m32_swap (ed);
|
||||
ohci->ed_controltail->hwNextED = m32_swap ((unsigned long)ed);
|
||||
}
|
||||
ed->ed_prev = ohci->ed_controltail;
|
||||
if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
|
||||
@ -504,7 +649,7 @@ static int ep_link (ohci_t *ohci, ed_t *edi)
|
||||
if (ohci->ed_bulktail == NULL) {
|
||||
writel (ed, &ohci->regs->ed_bulkhead);
|
||||
} else {
|
||||
ohci->ed_bulktail->hwNextED = m32_swap (ed);
|
||||
ohci->ed_bulktail->hwNextED = m32_swap ((unsigned long)ed);
|
||||
}
|
||||
ed->ed_prev = ohci->ed_bulktail;
|
||||
if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
|
||||
@ -514,19 +659,59 @@ static int ep_link (ohci_t *ohci, ed_t *edi)
|
||||
}
|
||||
ohci->ed_bulktail = edi;
|
||||
break;
|
||||
|
||||
case PIPE_INTERRUPT:
|
||||
load = ed->int_load;
|
||||
interval = ep_2_n_interval (ed->int_period);
|
||||
ed->int_interval = interval;
|
||||
int_branch = ep_int_ballance (ohci, interval, load);
|
||||
ed->int_branch = int_branch;
|
||||
|
||||
for (i = 0; i < ep_rev (6, interval); i += inter) {
|
||||
inter = 1;
|
||||
for (ed_p = &(ohci->hcca->int_table[ep_rev (5, i) + int_branch]);
|
||||
(*ed_p != 0) && (((ed_t *)ed_p)->int_interval >= interval);
|
||||
ed_p = &(((ed_t *)ed_p)->hwNextED))
|
||||
inter = ep_rev (6, ((ed_t *)ed_p)->int_interval);
|
||||
ed->hwNextED = *ed_p;
|
||||
*ed_p = m32_swap(ed);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* scan the periodic table to find and unlink this ED */
|
||||
static void periodic_unlink ( struct ohci *ohci, volatile struct ed *ed,
|
||||
unsigned index, unsigned period)
|
||||
{
|
||||
for (; index < NUM_INTS; index += period) {
|
||||
__u32 *ed_p = &ohci->hcca->int_table [index];
|
||||
|
||||
/* ED might have been unlinked through another path */
|
||||
while (*ed_p != 0) {
|
||||
if (((struct ed *)m32_swap (ed_p)) == ed) {
|
||||
*ed_p = ed->hwNextED;
|
||||
break;
|
||||
}
|
||||
ed_p = & (((struct ed *)m32_swap (ed_p))->hwNextED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* unlink an ed from one of the HC chains.
|
||||
* just the link to the ed is unlinked.
|
||||
* the link from the ed still points to another operational ed or 0
|
||||
* so the HC can eventually finish the processing of the unlinked ed */
|
||||
|
||||
static int ep_unlink (ohci_t *ohci, ed_t *ed)
|
||||
static int ep_unlink (ohci_t *ohci, ed_t *edi)
|
||||
{
|
||||
volatile ed_t *ed = edi;
|
||||
int i;
|
||||
|
||||
ed->hwINFO |= m32_swap (OHCI_ED_SKIP);
|
||||
|
||||
switch (ed->type) {
|
||||
@ -563,6 +748,12 @@ static int ep_unlink (ohci_t *ohci, ed_t *ed)
|
||||
((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
|
||||
}
|
||||
break;
|
||||
|
||||
case PIPE_INTERRUPT:
|
||||
periodic_unlink (ohci, ed, 0, 1);
|
||||
for (i = ed->int_branch; i < 32; i += ed->int_interval)
|
||||
ohci->ohci_int_load[i] -= ed->int_load;
|
||||
break;
|
||||
}
|
||||
ed->state = ED_UNLINK;
|
||||
return 0;
|
||||
@ -571,13 +762,16 @@ static int ep_unlink (ohci_t *ohci, ed_t *ed)
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
|
||||
* but the USB stack is a little bit stateless so we do it at every transaction
|
||||
* if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK
|
||||
* in all other cases the state is left unchanged
|
||||
* the ed info fields are setted anyway even though most of them should not change */
|
||||
|
||||
static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
|
||||
/* add/reinit an endpoint; this should be done once at the
|
||||
* usb_set_configuration command, but the USB stack is a little bit
|
||||
* stateless so we do it at every transaction if the state of the ed
|
||||
* is ED_NEW then a dummy td is added and the state is changed to
|
||||
* ED_UNLINK in all other cases the state is left unchanged the ed
|
||||
* info fields are setted anyway even though most of them should not
|
||||
* change
|
||||
*/
|
||||
static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe,
|
||||
int interval, int load)
|
||||
{
|
||||
td_t *td;
|
||||
ed_t *ed_ret;
|
||||
@ -596,7 +790,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
|
||||
ed->hwINFO = m32_swap (OHCI_ED_SKIP); /* skip ed */
|
||||
/* dummy td; end of td list for ed */
|
||||
td = td_alloc (usb_dev);
|
||||
ed->hwTailP = m32_swap (td);
|
||||
ed->hwTailP = m32_swap ((unsigned long)td);
|
||||
ed->hwHeadP = ed->hwTailP;
|
||||
ed->state = ED_UNLINK;
|
||||
ed->type = usb_pipetype (pipe);
|
||||
@ -610,6 +804,11 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
|
||||
| usb_pipeslow (pipe) << 13
|
||||
| usb_maxpacket (usb_dev, pipe) << 16);
|
||||
|
||||
if (ed->type == PIPE_INTERRUPT && ed->state == ED_UNLINK) {
|
||||
ed->int_period = interval;
|
||||
ed->int_load = load;
|
||||
}
|
||||
|
||||
return ed_ret;
|
||||
}
|
||||
|
||||
@ -654,13 +853,12 @@ static void td_fill (ohci_t *ohci, unsigned int info,
|
||||
data = 0;
|
||||
|
||||
td->hwINFO = m32_swap (info);
|
||||
td->hwCBP = m32_swap (data);
|
||||
td->hwCBP = m32_swap ((unsigned long)data);
|
||||
if (data)
|
||||
td->hwBE = m32_swap (data + len - 1);
|
||||
td->hwBE = m32_swap ((unsigned long)(data + len - 1));
|
||||
else
|
||||
td->hwBE = 0;
|
||||
td->hwNextTD = m32_swap (td_pt);
|
||||
td->hwPSW [0] = m16_swap (((__u32)data & 0x0FFF) | 0xE000);
|
||||
td->hwNextTD = m32_swap ((unsigned long)td_pt);
|
||||
|
||||
/* append to queue */
|
||||
td->ed->hwTailP = td->hwNextTD;
|
||||
@ -725,6 +923,13 @@ static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buf
|
||||
if (!ohci->sleeping)
|
||||
writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
|
||||
break;
|
||||
|
||||
case PIPE_INTERRUPT:
|
||||
info = usb_pipeout (urb->pipe)?
|
||||
TD_CC | TD_DP_OUT | toggle:
|
||||
TD_CC | TD_R | TD_DP_IN | toggle;
|
||||
td_fill (ohci, info, data, data_len, dev, cnt++, urb);
|
||||
break;
|
||||
}
|
||||
if (urb->length != cnt)
|
||||
dbg("TD LENGTH %d != CNT %d", urb->length, cnt);
|
||||
@ -740,7 +945,7 @@ static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buf
|
||||
static void dl_transfer_length(td_t * td)
|
||||
{
|
||||
__u32 tdINFO, tdBE, tdCBP;
|
||||
urb_priv_t *lurb_priv = &urb_priv;
|
||||
urb_priv_t *lurb_priv = td->ed->purb;
|
||||
|
||||
tdINFO = m32_swap (td->hwINFO);
|
||||
tdBE = m32_swap (td->hwBE);
|
||||
@ -777,7 +982,7 @@ static td_t * dl_reverse_done_list (ohci_t *ohci)
|
||||
td_list = (td_t *)td_list_hc;
|
||||
|
||||
if (TD_CC_GET (m32_swap (td_list->hwINFO))) {
|
||||
lurb_priv = &urb_priv;
|
||||
lurb_priv = td_list->ed->purb;
|
||||
dbg(" USB-error/status: %x : %p",
|
||||
TD_CC_GET (m32_swap (td_list->hwINFO)), td_list);
|
||||
if (td_list->ed->hwHeadP & m32_swap (0x1)) {
|
||||
@ -789,6 +994,9 @@ static td_t * dl_reverse_done_list (ohci_t *ohci)
|
||||
} else
|
||||
td_list->ed->hwHeadP &= m32_swap (0xfffffff2);
|
||||
}
|
||||
#ifdef CONFIG_MPC5200
|
||||
td_list->hwNextTD = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
td_list->next_dl_td = td_rev;
|
||||
@ -814,10 +1022,10 @@ static int dl_done_list (ohci_t *ohci, td_t *td_list)
|
||||
while (td_list) {
|
||||
td_list_next = td_list->next_dl_td;
|
||||
|
||||
lurb_priv = &urb_priv;
|
||||
tdINFO = m32_swap (td_list->hwINFO);
|
||||
|
||||
ed = td_list->ed;
|
||||
lurb_priv = ed->purb;
|
||||
|
||||
dl_transfer_length(td_list);
|
||||
|
||||
@ -828,7 +1036,24 @@ static int dl_done_list (ohci_t *ohci, td_t *td_list)
|
||||
stat = cc_to_error[cc];
|
||||
}
|
||||
|
||||
if (ed->state != ED_NEW) {
|
||||
/* see if this done list makes for all TD's of current URB,
|
||||
* and mark the URB finished if so */
|
||||
if (++(lurb_priv->td_cnt) == lurb_priv->length) {
|
||||
#if 1
|
||||
if ((ed->state & (ED_OPER | ED_UNLINK)) &&
|
||||
(lurb_priv->state != URB_DEL))
|
||||
#else
|
||||
if ((ed->state & (ED_OPER | ED_UNLINK)))
|
||||
#endif
|
||||
lurb_priv->finished = sohci_return_job(ohci,
|
||||
lurb_priv);
|
||||
else
|
||||
dbg("dl_done_list: strange.., ED state %x, ed->state\n");
|
||||
} else
|
||||
dbg("dl_done_list: processing TD %x, len %x\n", lurb_priv->td_cnt,
|
||||
lurb_priv->length);
|
||||
if (ed->state != ED_NEW &&
|
||||
(usb_pipetype (lurb_priv->pipe) != PIPE_INTERRUPT)) {
|
||||
edHeadP = m32_swap (ed->hwHeadP) & 0xfffffff0;
|
||||
edTailP = m32_swap (ed->hwTailP);
|
||||
|
||||
@ -974,7 +1199,6 @@ int rh_check_port_status(ohci_t *controller)
|
||||
#ifdef CONFIG_AT91C_PQFP_UHPBUG
|
||||
ndp = (ndp == 2) ? 1:0;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < ndp; i++) {
|
||||
temp = roothub_portstatus (controller, i);
|
||||
/* check for a device disconnect */
|
||||
@ -1003,8 +1227,7 @@ static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
|
||||
__u16 wLength;
|
||||
|
||||
#ifdef DEBUG
|
||||
urb_priv.actual_length = 0;
|
||||
pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
|
||||
pkt_print(NULL, dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
|
||||
#else
|
||||
wait_ms(1);
|
||||
#endif
|
||||
@ -1014,9 +1237,9 @@ pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
|
||||
}
|
||||
|
||||
bmRType_bReq = cmd->requesttype | (cmd->request << 8);
|
||||
wValue = m16_swap (cmd->value);
|
||||
wIndex = m16_swap (cmd->index);
|
||||
wLength = m16_swap (cmd->length);
|
||||
wValue = cpu_to_le16 (cmd->value);
|
||||
wIndex = cpu_to_le16 (cmd->index);
|
||||
wLength = cpu_to_le16 (cmd->length);
|
||||
|
||||
info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x",
|
||||
dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength);
|
||||
@ -1031,17 +1254,17 @@ pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
|
||||
*/
|
||||
|
||||
case RH_GET_STATUS:
|
||||
*(__u16 *) data_buf = m16_swap (1); OK (2);
|
||||
*(__u16 *) data_buf = cpu_to_le16 (1); OK (2);
|
||||
case RH_GET_STATUS | RH_INTERFACE:
|
||||
*(__u16 *) data_buf = m16_swap (0); OK (2);
|
||||
*(__u16 *) data_buf = cpu_to_le16 (0); OK (2);
|
||||
case RH_GET_STATUS | RH_ENDPOINT:
|
||||
*(__u16 *) data_buf = m16_swap (0); OK (2);
|
||||
*(__u16 *) data_buf = cpu_to_le16 (0); OK (2);
|
||||
case RH_GET_STATUS | RH_CLASS:
|
||||
*(__u32 *) data_buf = m32_swap (
|
||||
*(__u32 *) data_buf = cpu_to_le32 (
|
||||
RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE));
|
||||
OK (4);
|
||||
case RH_GET_STATUS | RH_OTHER | RH_CLASS:
|
||||
*(__u32 *) data_buf = m32_swap (RD_RH_PORTSTAT); OK (4);
|
||||
*(__u32 *) data_buf = cpu_to_le32 (RD_RH_PORTSTAT); OK (4);
|
||||
|
||||
case RH_CLEAR_FEATURE | RH_ENDPOINT:
|
||||
switch (wValue) {
|
||||
@ -1088,7 +1311,9 @@ pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
|
||||
WR_RH_PORTSTAT (RH_PS_PRS);
|
||||
OK (0);
|
||||
case (RH_PORT_POWER):
|
||||
WR_RH_PORTSTAT (RH_PS_PPS ); OK (0);
|
||||
WR_RH_PORTSTAT (RH_PS_PPS );
|
||||
wait_ms(100);
|
||||
OK (0);
|
||||
case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/
|
||||
if (RD_RH_PORTSTAT & RH_PS_CCS)
|
||||
WR_RH_PORTSTAT (RH_PS_PES );
|
||||
@ -1170,7 +1395,7 @@ pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
|
||||
}
|
||||
|
||||
len = min_t(unsigned int, leni,
|
||||
min_t(unsigned int, data_buf [0], wLength));
|
||||
min_t(unsigned int, data_buf [0], wLength));
|
||||
OK (len);
|
||||
}
|
||||
|
||||
@ -1196,9 +1421,7 @@ pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
|
||||
dev->status = stat;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (transfer_len)
|
||||
urb_priv.actual_length = transfer_len;
|
||||
pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/);
|
||||
pkt_print(NULL, dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/);
|
||||
#else
|
||||
wait_ms(1);
|
||||
#endif
|
||||
@ -1216,6 +1439,16 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int stat = 0;
|
||||
int maxsize = usb_maxpacket(dev, pipe);
|
||||
int timeout;
|
||||
urb_priv_t *urb;
|
||||
|
||||
urb = malloc(sizeof(urb_priv_t));
|
||||
memset(urb, 0, sizeof(urb_priv_t));
|
||||
|
||||
urb->dev = dev;
|
||||
urb->pipe = pipe;
|
||||
urb->transfer_buffer = buffer;
|
||||
urb->transfer_buffer_length = transfer_len;
|
||||
urb->interval = interval;
|
||||
|
||||
/* device pulled? Shortcut the action. */
|
||||
if (devgone == dev) {
|
||||
@ -1224,8 +1457,8 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
urb_priv.actual_length = 0;
|
||||
pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
|
||||
urb->actual_length = 0;
|
||||
pkt_print(urb, dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
|
||||
#else
|
||||
wait_ms(1);
|
||||
#endif
|
||||
@ -1235,13 +1468,15 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) {
|
||||
if (sohci_submit_job(urb, setup) < 0) {
|
||||
err("sohci_submit_job failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
wait_ms(10);
|
||||
/* ohci_dump_status(&gohci); */
|
||||
#endif
|
||||
|
||||
/* allow more time for a BULK device to react - some are slow */
|
||||
#define BULK_TO 5000 /* timeout in milliseconds */
|
||||
@ -1258,51 +1493,47 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
stat = USB_ST_CRC_ERR;
|
||||
break;
|
||||
}
|
||||
if (stat >= 0 && stat != 0xff) {
|
||||
|
||||
/* NOTE: since we are not interrupt driven in U-Boot and always
|
||||
* handle only one URB at a time, we cannot assume the
|
||||
* transaction finished on the first successful return from
|
||||
* hc_interrupt().. unless the flag for current URB is set,
|
||||
* meaning that all TD's to/from device got actually
|
||||
* transferred and processed. If the current URB is not
|
||||
* finished we need to re-iterate this loop so as
|
||||
* hc_interrupt() gets called again as there needs to be some
|
||||
* more TD's to process still */
|
||||
if ((stat >= 0) && (stat != 0xff) && (urb->finished)) {
|
||||
/* 0xff is returned for an SF-interrupt */
|
||||
break;
|
||||
}
|
||||
|
||||
if (--timeout) {
|
||||
wait_ms(1);
|
||||
if (!urb->finished)
|
||||
dbg("\%");
|
||||
|
||||
} else {
|
||||
err("CTL:TIMEOUT ");
|
||||
dbg("submit_common_msg: TO status %x\n", stat);
|
||||
urb->finished = 1;
|
||||
stat = USB_ST_CRC_ERR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* we got an Root Hub Status Change interrupt */
|
||||
if (got_rhsc) {
|
||||
#ifdef DEBUG
|
||||
ohci_dump_roothub (&gohci, 1);
|
||||
#endif
|
||||
got_rhsc = 0;
|
||||
/* abuse timeout */
|
||||
timeout = rh_check_port_status(&gohci);
|
||||
if (timeout >= 0) {
|
||||
#if 0 /* this does nothing useful, but leave it here in case that changes */
|
||||
/* the called routine adds 1 to the passed value */
|
||||
usb_hub_port_connect_change(gohci.rh.dev, timeout - 1);
|
||||
#endif
|
||||
/*
|
||||
* XXX
|
||||
* This is potentially dangerous because it assumes
|
||||
* that only one device is ever plugged in!
|
||||
*/
|
||||
devgone = dev;
|
||||
}
|
||||
}
|
||||
|
||||
dev->status = stat;
|
||||
dev->act_len = transfer_len;
|
||||
|
||||
#ifdef DEBUG
|
||||
pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe));
|
||||
pkt_print(urb, dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe));
|
||||
#else
|
||||
wait_ms(1);
|
||||
#endif
|
||||
|
||||
/* free TDs in urb_priv */
|
||||
urb_free_priv (&urb_priv);
|
||||
if (usb_pipetype (pipe) != PIPE_INTERRUPT)
|
||||
urb_free_priv (urb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1321,8 +1552,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
|
||||
info("submit_control_msg");
|
||||
#ifdef DEBUG
|
||||
urb_priv.actual_length = 0;
|
||||
pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
|
||||
pkt_print(NULL, dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
|
||||
#else
|
||||
wait_ms(1);
|
||||
#endif
|
||||
@ -1345,7 +1575,8 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int transfer_len, int interval)
|
||||
{
|
||||
info("submit_int_msg");
|
||||
return -1;
|
||||
return submit_common_msg(dev, pipe, buffer, transfer_len, NULL,
|
||||
interval);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
@ -1381,7 +1612,8 @@ static int hc_reset (ohci_t *ohci)
|
||||
readl(&ohci->regs->control));
|
||||
|
||||
/* Reset USB (needed by some controllers) */
|
||||
writel (0, &ohci->regs->control);
|
||||
ohci->hc_control = 0;
|
||||
writel (ohci->hc_control, &ohci->regs->control);
|
||||
|
||||
/* HC Reset requires max 10 us delay */
|
||||
writel (OHCI_HCR, &ohci->regs->cmdstatus);
|
||||
@ -1458,26 +1690,38 @@ static int hc_start (ohci_t * ohci)
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* Poll USB interrupt. */
|
||||
void usb_event_poll(void)
|
||||
{
|
||||
hc_interrupt();
|
||||
}
|
||||
|
||||
/* an interrupt happens */
|
||||
|
||||
static int
|
||||
hc_interrupt (void)
|
||||
static int hc_interrupt (void)
|
||||
{
|
||||
ohci_t *ohci = &gohci;
|
||||
struct ohci_regs *regs = ohci->regs;
|
||||
int ints;
|
||||
int stat = -1;
|
||||
|
||||
if ((ohci->hcca->done_head != 0) && !(m32_swap (ohci->hcca->done_head) & 0x01)) {
|
||||
ints = OHCI_INTR_WDH;
|
||||
} else {
|
||||
ints = readl (®s->intrstatus);
|
||||
if ((ohci->hcca->done_head != 0) &&
|
||||
!(m32_swap (ohci->hcca->done_head) & 0x01)) {
|
||||
ints = OHCI_INTR_WDH;
|
||||
} else if ((ints = readl (®s->intrstatus)) == ~(u32)0) {
|
||||
ohci->disabled++;
|
||||
err ("%s device removed!", ohci->slot_name);
|
||||
return -1;
|
||||
} else if ((ints &= readl (®s->intrenable)) == 0) {
|
||||
dbg("hc_interrupt: returning..\n");
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
/* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */
|
||||
|
||||
if (ints & OHCI_INTR_RHSC) {
|
||||
got_rhsc = 1;
|
||||
stat = 0xff;
|
||||
}
|
||||
|
||||
if (ints & OHCI_INTR_UE) {
|
||||
@ -1502,8 +1746,10 @@ hc_interrupt (void)
|
||||
if (ints & OHCI_INTR_WDH) {
|
||||
wait_ms(1);
|
||||
writel (OHCI_INTR_WDH, ®s->intrdisable);
|
||||
(void)readl (®s->intrdisable); /* flush */
|
||||
stat = dl_done_list (&gohci, dl_reverse_done_list (&gohci));
|
||||
writel (OHCI_INTR_WDH, ®s->intrenable);
|
||||
(void)readl (®s->intrdisable); /* flush */
|
||||
}
|
||||
|
||||
if (ints & OHCI_INTR_SO) {
|
||||
@ -1549,14 +1795,22 @@ static char ohci_inited = 0;
|
||||
|
||||
int usb_lowlevel_init(void)
|
||||
{
|
||||
/*
|
||||
* Enable USB host clock.
|
||||
*/
|
||||
*AT91C_PMC_SCER = AT91C_PMC_UHP; /* 48MHz clock enabled for UHP */
|
||||
*AT91C_PMC_PCER = 1 << AT91C_ID_UHP; /* Peripheral Clock Enable Register */
|
||||
#ifdef CONFIG_PCI_OHCI
|
||||
pci_dev_t pdev;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_OHCI_CPU_INIT
|
||||
/* cpu dependant init */
|
||||
if(usb_cpu_init())
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_OHCI_BOARD_INIT
|
||||
/* board dependant init */
|
||||
if(usb_board_init())
|
||||
return -1;
|
||||
#endif
|
||||
memset (&gohci, 0, sizeof (ohci_t));
|
||||
memset (&urb_priv, 0, sizeof (urb_priv_t));
|
||||
|
||||
/* align the storage */
|
||||
if ((__u32)&ghcca[0] & 0xff) {
|
||||
@ -1582,29 +1836,60 @@ int usb_lowlevel_init(void)
|
||||
gohci.disabled = 1;
|
||||
gohci.sleeping = 0;
|
||||
gohci.irq = -1;
|
||||
gohci.regs = (struct ohci_regs *)AT91_USB_HOST_BASE;
|
||||
#ifdef CONFIG_PCI_OHCI
|
||||
pdev = pci_find_devices(ohci_pci_ids, 0);
|
||||
|
||||
if (pdev != -1) {
|
||||
u16 vid, did;
|
||||
u32 base;
|
||||
pci_read_config_word(pdev, PCI_VENDOR_ID, &vid);
|
||||
pci_read_config_word(pdev, PCI_DEVICE_ID, &did);
|
||||
printf("OHCI pci controller (%04x, %04x) found @(%d:%d:%d)\n",
|
||||
vid, did, (pdev >> 16) & 0xff,
|
||||
(pdev >> 11) & 0x1f, (pdev >> 8) & 0x7);
|
||||
pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &base);
|
||||
printf("OHCI regs address 0x%08x\n", base);
|
||||
gohci.regs = (struct ohci_regs *)base;
|
||||
} else
|
||||
return -1;
|
||||
#else
|
||||
gohci.regs = (struct ohci_regs *)CFG_USB_OHCI_REGS_BASE;
|
||||
#endif
|
||||
|
||||
gohci.flags = 0;
|
||||
gohci.slot_name = "at91rm9200";
|
||||
gohci.slot_name = CFG_USB_OHCI_SLOT_NAME;
|
||||
|
||||
if (hc_reset (&gohci) < 0) {
|
||||
hc_release_ohci (&gohci);
|
||||
/* Initialization failed */
|
||||
*AT91C_PMC_PCER = AT91C_ID_UHP;
|
||||
*AT91C_PMC_SCDR = 1 << AT91C_PMC_UHP; /* 48MHz clock disabled for UHP */
|
||||
err ("can't reset usb-%s", gohci.slot_name);
|
||||
#ifdef CFG_USB_OHCI_BOARD_INIT
|
||||
/* board dependant cleanup */
|
||||
usb_board_init_fail();
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_OHCI_CPU_INIT
|
||||
/* cpu dependant cleanup */
|
||||
usb_cpu_init_fail();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME this is a second HC reset; why?? */
|
||||
/* writel (gohci.hc_control = OHCI_USB_RESET, &gohci.regs->control);
|
||||
wait_ms (10);*/
|
||||
|
||||
/* writel(gohci.hc_control = OHCI_USB_RESET, &gohci.regs->control);
|
||||
wait_ms(10); */
|
||||
if (hc_start (&gohci) < 0) {
|
||||
err ("can't start usb-%s", gohci.slot_name);
|
||||
hc_release_ohci (&gohci);
|
||||
/* Initialization failed */
|
||||
*AT91C_PMC_PCER = AT91C_ID_UHP;
|
||||
*AT91C_PMC_SCDR = 1 << AT91C_PMC_UHP; /* 48MHz clock disabled for UHP */
|
||||
#ifdef CFG_USB_OHCI_BOARD_INIT
|
||||
/* board dependant cleanup */
|
||||
usb_board_stop();
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_OHCI_CPU_INIT
|
||||
/* cpu dependant cleanup */
|
||||
usb_cpu_stop();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1626,10 +1911,19 @@ int usb_lowlevel_stop(void)
|
||||
/* TODO release any interrupts, etc. */
|
||||
/* call hc_release_ohci() here ? */
|
||||
hc_reset (&gohci);
|
||||
/* may not want to do this */
|
||||
*AT91C_PMC_PCER = 1 << AT91C_ID_UHP;
|
||||
*AT91C_PMC_SCDR = 1 << AT91C_PMC_UHP; /* 48MHz clock disabled for UHP */
|
||||
|
||||
#ifdef CFG_USB_OHCI_BOARD_INIT
|
||||
/* board dependant cleanup */
|
||||
if(usb_board_stop())
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_OHCI_CPU_INIT
|
||||
/* cpu dependant cleanup */
|
||||
if(usb_cpu_stop())
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_USB_OHCI */
|
||||
#endif /* CONFIG_USB_OHCI_NEW */
|
@ -7,6 +7,15 @@
|
||||
* usb-ohci.h
|
||||
*/
|
||||
|
||||
/* functions for doing board or CPU specific setup/cleanup */
|
||||
extern int usb_board_init(void);
|
||||
extern int usb_board_stop(void);
|
||||
extern int usb_board_init_fail(void);
|
||||
|
||||
extern int usb_cpu_init(void);
|
||||
extern int usb_cpu_stop(void);
|
||||
extern int usb_cpu_init_fail(void);
|
||||
|
||||
|
||||
static int cc_to_error[16] = {
|
||||
|
||||
@ -55,7 +64,8 @@ struct ed {
|
||||
struct ed *ed_rm_list;
|
||||
|
||||
struct usb_device *usb_dev;
|
||||
__u32 unused[3];
|
||||
void *purb;
|
||||
__u32 unused[2];
|
||||
} __attribute((aligned(16)));
|
||||
typedef struct ed ed_t;
|
||||
|
||||
@ -104,7 +114,9 @@ struct td {
|
||||
__u32 hwNextTD; /* Next TD Pointer */
|
||||
__u32 hwBE; /* Memory Buffer End Pointer */
|
||||
|
||||
/* #ifndef CONFIG_MPC5200 /\* this seems wrong *\/ */
|
||||
__u16 hwPSW[MAXPSW];
|
||||
/* #endif */
|
||||
__u8 unused;
|
||||
__u8 index;
|
||||
struct ed *ed;
|
||||
@ -128,8 +140,13 @@ typedef struct td td_t;
|
||||
#define NUM_INTS 32 /* part of the OHCI standard */
|
||||
struct ohci_hcca {
|
||||
__u32 int_table[NUM_INTS]; /* Interrupt ED table */
|
||||
#if defined(CONFIG_MPC5200)
|
||||
__u16 pad1; /* set to 0 on each frame_no change */
|
||||
__u16 frame_no; /* current frame number */
|
||||
#else
|
||||
__u16 frame_no; /* current frame number */
|
||||
__u16 pad1; /* set to 0 on each frame_no change */
|
||||
#endif
|
||||
__u32 done_head; /* info returned for an interrupt */
|
||||
u8 reserved_for_hc[116];
|
||||
} __attribute((aligned(256)));
|
||||
@ -138,7 +155,9 @@ struct ohci_hcca {
|
||||
/*
|
||||
* Maximum number of root hub ports.
|
||||
*/
|
||||
#define MAX_ROOT_PORTS 15 /* maximum OHCI root hub ports */
|
||||
#ifndef CFG_USB_OHCI_MAX_ROOT_PORTS
|
||||
# error "CFG_USB_OHCI_MAX_ROOT_PORTS undefined!"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is the structure of the OHCI controller's memory mapped I/O
|
||||
@ -172,7 +191,7 @@ struct ohci_regs {
|
||||
__u32 a;
|
||||
__u32 b;
|
||||
__u32 status;
|
||||
__u32 portstatus[MAX_ROOT_PORTS];
|
||||
__u32 portstatus[CFG_USB_OHCI_MAX_ROOT_PORTS];
|
||||
} roothub;
|
||||
} __attribute((aligned(32)));
|
||||
|
||||
@ -331,9 +350,14 @@ typedef struct
|
||||
ed_t *ed;
|
||||
__u16 length; /* number of tds associated with this request */
|
||||
__u16 td_cnt; /* number of tds already serviced */
|
||||
struct usb_device *dev;
|
||||
int state;
|
||||
unsigned long pipe;
|
||||
void *transfer_buffer;
|
||||
int transfer_buffer_length;
|
||||
int interval;
|
||||
int actual_length;
|
||||
int finished;
|
||||
td_t *td[N_URB_TD]; /* list pointer to all corresponding TDs associated with this request */
|
||||
} urb_priv_t;
|
||||
#define URB_DEL 1
|
||||
@ -357,6 +381,7 @@ typedef struct ohci {
|
||||
|
||||
struct ohci_regs *regs; /* OHCI controller's memory */
|
||||
|
||||
int ohci_int_load[32]; /* load of the 32 Interrupt Chains (for load balancing)*/
|
||||
ed_t *ed_rm_list[2]; /* lists of all endpoints to be removed */
|
||||
ed_t *ed_bulktail; /* last endpoint of bulk list */
|
||||
ed_t *ed_controltail; /* last endpoint of control list */
|
||||
@ -379,7 +404,8 @@ struct ohci_device {
|
||||
/* endpoint */
|
||||
static int ep_link(ohci_t * ohci, ed_t * ed);
|
||||
static int ep_unlink(ohci_t * ohci, ed_t * ed);
|
||||
static ed_t * ep_add_ed(struct usb_device * usb_dev, unsigned long pipe);
|
||||
static ed_t * ep_add_ed(struct usb_device * usb_dev, unsigned long pipe,
|
||||
int interval, int load);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
@ -2,6 +2,9 @@
|
||||
* (C) Copyright 2003
|
||||
* Gerry Hamel, geh@ti.com, Texas Instruments
|
||||
*
|
||||
* (C) Copyright 2006
|
||||
* Bryan O'Donoghue, deckard@CodeHermit.ie
|
||||
*
|
||||
* Based on
|
||||
* linux/drivers/usbd/ep0.c
|
||||
*
|
||||
@ -39,11 +42,17 @@
|
||||
* function driver. This may need to change.
|
||||
*
|
||||
* XXX
|
||||
*
|
||||
* As alluded to above, a simple callback cdc_recv_setup has been implemented
|
||||
* in the usb_device data structure to facilicate passing
|
||||
* Common Device Class packets to a function driver.
|
||||
*
|
||||
* XXX
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#if defined(CONFIG_OMAP1510) && defined(CONFIG_USB_DEVICE)
|
||||
#if defined(CONFIG_USB_DEVICE)
|
||||
#include "usbdcore.h"
|
||||
|
||||
#if 0
|
||||
@ -69,7 +78,7 @@ static int ep0_get_status (struct usb_device_instance *device,
|
||||
char *cp;
|
||||
|
||||
urb->actual_length = 2;
|
||||
cp = urb->buffer;
|
||||
cp = (char*)urb->buffer;
|
||||
cp[0] = cp[1] = 0;
|
||||
|
||||
switch (requesttype) {
|
||||
@ -115,7 +124,7 @@ static int ep0_get_one (struct usb_device_instance *device, struct urb *urb,
|
||||
*
|
||||
* Copy configuration data to urb transfer buffer if there is room for it.
|
||||
*/
|
||||
static void copy_config (struct urb *urb, void *data, int max_length,
|
||||
void copy_config (struct urb *urb, void *data, int max_length,
|
||||
int max_buf)
|
||||
{
|
||||
int available;
|
||||
@ -128,10 +137,7 @@ static void copy_config (struct urb *urb, void *data, int max_length,
|
||||
dbg_ep0 (1, "data is NULL");
|
||||
return;
|
||||
}
|
||||
if (!(length = *(unsigned char *) data)) {
|
||||
dbg_ep0 (1, "length is zero");
|
||||
return;
|
||||
}
|
||||
length = max_length;
|
||||
|
||||
if (length > max_length) {
|
||||
dbg_ep0 (1, "length: %d >= max_length: %d", length,
|
||||
@ -192,7 +198,7 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
|
||||
|
||||
/* setup tx urb */
|
||||
urb->actual_length = 0;
|
||||
cp = urb->buffer;
|
||||
cp = (char*)urb->buffer;
|
||||
|
||||
dbg_ep0 (2, "%s", USBD_DEVICE_DESCRIPTORS (descriptor_type));
|
||||
|
||||
@ -200,7 +206,6 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
|
||||
case USB_DESCRIPTOR_TYPE_DEVICE:
|
||||
{
|
||||
struct usb_device_descriptor *device_descriptor;
|
||||
|
||||
if (!
|
||||
(device_descriptor =
|
||||
usbd_device_device_descriptor (device, port))) {
|
||||
@ -214,20 +219,16 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
|
||||
/* correct the correct control endpoint 0 max packet size into the descriptor */
|
||||
device_descriptor =
|
||||
(struct usb_device_descriptor *) urb->buffer;
|
||||
device_descriptor->bMaxPacketSize0 =
|
||||
urb->device->bus->maxpacketsize;
|
||||
|
||||
}
|
||||
/*dbg_ep0(3, "copied device configuration, actual_length: %x", urb->actual_length); */
|
||||
dbg_ep0(3, "copied device configuration, actual_length: 0x%x", urb->actual_length);
|
||||
break;
|
||||
|
||||
case USB_DESCRIPTOR_TYPE_CONFIGURATION:
|
||||
{
|
||||
int bNumInterface;
|
||||
struct usb_configuration_descriptor
|
||||
*configuration_descriptor;
|
||||
struct usb_device_descriptor *device_descriptor;
|
||||
|
||||
if (!
|
||||
(device_descriptor =
|
||||
usbd_device_device_descriptor (device, port))) {
|
||||
@ -251,130 +252,35 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
|
||||
index);
|
||||
return -1;
|
||||
}
|
||||
dbg_ep0(0, "attempt to copy %d bytes to urb\n",cpu_to_le16(configuration_descriptor->wTotalLength));
|
||||
copy_config (urb, configuration_descriptor,
|
||||
sizeof (struct
|
||||
usb_configuration_descriptor),
|
||||
|
||||
cpu_to_le16(configuration_descriptor->wTotalLength),
|
||||
max);
|
||||
|
||||
|
||||
/* iterate across interfaces for specified configuration */
|
||||
dbg_ep0 (0, "bNumInterfaces: %d",
|
||||
configuration_descriptor->bNumInterfaces);
|
||||
for (bNumInterface = 0;
|
||||
bNumInterface <
|
||||
configuration_descriptor->bNumInterfaces;
|
||||
bNumInterface++) {
|
||||
|
||||
int bAlternateSetting;
|
||||
struct usb_interface_instance
|
||||
*interface_instance;
|
||||
|
||||
dbg_ep0 (3, "[%d] bNumInterfaces: %d",
|
||||
bNumInterface,
|
||||
configuration_descriptor->bNumInterfaces);
|
||||
|
||||
if (! (interface_instance = usbd_device_interface_instance (device,
|
||||
port, index, bNumInterface)))
|
||||
{
|
||||
dbg_ep0 (3, "[%d] interface_instance NULL",
|
||||
bNumInterface);
|
||||
return -1;
|
||||
}
|
||||
/* iterate across interface alternates */
|
||||
for (bAlternateSetting = 0;
|
||||
bAlternateSetting < interface_instance->alternates;
|
||||
bAlternateSetting++) {
|
||||
/*int class; */
|
||||
int bNumEndpoint;
|
||||
struct usb_interface_descriptor *interface_descriptor;
|
||||
|
||||
struct usb_alternate_instance *alternate_instance;
|
||||
|
||||
dbg_ep0 (3, "[%d:%d] alternates: %d",
|
||||
bNumInterface,
|
||||
bAlternateSetting,
|
||||
interface_instance->alternates);
|
||||
|
||||
if (! (alternate_instance = usbd_device_alternate_instance (device, port, index, bNumInterface, bAlternateSetting))) {
|
||||
dbg_ep0 (3, "[%d] alternate_instance NULL",
|
||||
bNumInterface);
|
||||
return -1;
|
||||
}
|
||||
/* copy descriptor for this interface */
|
||||
copy_config (urb, alternate_instance->interface_descriptor,
|
||||
sizeof (struct usb_interface_descriptor),
|
||||
max);
|
||||
|
||||
/*dbg_ep0(3, "[%d:%d] classes: %d endpoints: %d", bNumInterface, bAlternateSetting, */
|
||||
/* alternate_instance->classes, alternate_instance->endpoints); */
|
||||
|
||||
/* iterate across classes for this alternate interface */
|
||||
#if 0
|
||||
for (class = 0;
|
||||
class < alternate_instance->classes;
|
||||
class++) {
|
||||
struct usb_class_descriptor *class_descriptor;
|
||||
/*dbg_ep0(3, "[%d:%d:%d] classes: %d", bNumInterface, bAlternateSetting, */
|
||||
/* class, alternate_instance->classes); */
|
||||
if (!(class_descriptor = usbd_device_class_descriptor_index (device, port, index, bNumInterface, bAlternateSetting, class))) {
|
||||
dbg_ep0 (3, "[%d] class NULL",
|
||||
class);
|
||||
return -1;
|
||||
}
|
||||
/* copy descriptor for this class */
|
||||
copy_config (urb, class_descriptor,
|
||||
sizeof (struct usb_class_descriptor),
|
||||
max);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* iterate across endpoints for this alternate interface */
|
||||
interface_descriptor = alternate_instance->interface_descriptor;
|
||||
for (bNumEndpoint = 0;
|
||||
bNumEndpoint < alternate_instance->endpoints;
|
||||
bNumEndpoint++) {
|
||||
struct usb_endpoint_descriptor *endpoint_descriptor;
|
||||
dbg_ep0 (3, "[%d:%d:%d] endpoint: %d",
|
||||
bNumInterface,
|
||||
bAlternateSetting,
|
||||
bNumEndpoint,
|
||||
interface_descriptor->
|
||||
bNumEndpoints);
|
||||
if (!(endpoint_descriptor = usbd_device_endpoint_descriptor_index (device, port, index, bNumInterface, bAlternateSetting, bNumEndpoint))) {
|
||||
dbg_ep0 (3, "[%d] endpoint NULL",
|
||||
bNumEndpoint);
|
||||
return -1;
|
||||
}
|
||||
/* copy descriptor for this endpoint */
|
||||
copy_config (urb, endpoint_descriptor,
|
||||
sizeof (struct usb_endpoint_descriptor),
|
||||
max);
|
||||
}
|
||||
}
|
||||
}
|
||||
dbg_ep0 (3, "lengths: %d %d",
|
||||
le16_to_cpu (configuration_descriptor->wTotalLength),
|
||||
urb->actual_length);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case USB_DESCRIPTOR_TYPE_STRING:
|
||||
{
|
||||
struct usb_string_descriptor *string_descriptor;
|
||||
|
||||
if (!(string_descriptor = usbd_get_string (index))) {
|
||||
serial_printf("Invalid string index %d\n", index);
|
||||
return -1;
|
||||
}
|
||||
/*dbg_ep0(3, "string_descriptor: %p", string_descriptor); */
|
||||
dbg_ep0(3, "string_descriptor: %p length %d", string_descriptor, string_descriptor->bLength);
|
||||
copy_config (urb, string_descriptor, string_descriptor->bLength, max);
|
||||
}
|
||||
break;
|
||||
case USB_DESCRIPTOR_TYPE_INTERFACE:
|
||||
serial_printf("USB_DESCRIPTOR_TYPE_INTERFACE - error not implemented\n");
|
||||
return -1;
|
||||
case USB_DESCRIPTOR_TYPE_ENDPOINT:
|
||||
serial_printf("USB_DESCRIPTOR_TYPE_ENDPOINT - error not implemented\n");
|
||||
return -1;
|
||||
case USB_DESCRIPTOR_TYPE_HID:
|
||||
{
|
||||
serial_printf("USB_DESCRIPTOR_TYPE_HID - error not implemented\n");
|
||||
return -1; /* unsupported at this time */
|
||||
#if 0
|
||||
int bNumInterface =
|
||||
@ -403,6 +309,7 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
|
||||
break;
|
||||
case USB_DESCRIPTOR_TYPE_REPORT:
|
||||
{
|
||||
serial_printf("USB_DESCRIPTOR_TYPE_REPORT - error not implemented\n");
|
||||
return -1; /* unsupported at this time */
|
||||
#if 0
|
||||
int bNumInterface =
|
||||
@ -434,12 +341,19 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER:
|
||||
{
|
||||
/* If a USB device supports both a full speed and low speed operation
|
||||
* we must send a Device_Qualifier descriptor here
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
dbg_ep0 (1, "urb: buffer: %p buffer_length: %2d actual_length: %2d packet size: %2d",
|
||||
dbg_ep0 (1, "urb: buffer: %p buffer_length: %2d actual_length: %2d tx_packetSize: %2d",
|
||||
urb->buffer, urb->buffer_length, urb->actual_length,
|
||||
device->bus->endpoint_array[0].tx_packetSize);
|
||||
/*
|
||||
@ -495,6 +409,12 @@ int ep0_recv_setup (struct urb *urb)
|
||||
|
||||
/* handle USB Standard Request (c.f. USB Spec table 9-2) */
|
||||
if ((request->bmRequestType & USB_REQ_TYPE_MASK) != 0) {
|
||||
if(device->device_state <= STATE_CONFIGURED){
|
||||
/* Attempt to handle a CDC specific request if we are
|
||||
* in the configured state.
|
||||
*/
|
||||
return device->cdc_recv_setup(request,urb);
|
||||
}
|
||||
dbg_ep0 (1, "non standard request: %x",
|
||||
request->bmRequestType & USB_REQ_TYPE_MASK);
|
||||
return -1; /* Stall here */
|
||||
@ -567,6 +487,7 @@ int ep0_recv_setup (struct urb *urb)
|
||||
le16_to_cpu (request->wValue) & 0xff);
|
||||
|
||||
case USB_REQ_GET_CONFIGURATION:
|
||||
serial_printf("get config %d\n", device->configuration);
|
||||
return ep0_get_one (device, urb,
|
||||
device->configuration);
|
||||
|
||||
@ -642,7 +563,6 @@ int ep0_recv_setup (struct urb *urb)
|
||||
/*dbg_ep0(2, "address: %d %d %d", */
|
||||
/* request->wValue, le16_to_cpu(request->wValue), device->address); */
|
||||
|
||||
serial_printf ("DEVICE_ADDRESS_ASSIGNED.. event?\n");
|
||||
return 0;
|
||||
|
||||
case USB_REQ_SET_DESCRIPTOR: /* XXX should we support this? */
|
||||
@ -653,9 +573,10 @@ int ep0_recv_setup (struct urb *urb)
|
||||
/* c.f. 9.4.7 - the top half of wValue is reserved */
|
||||
/* */
|
||||
if ((device->configuration =
|
||||
le16_to_cpu (request->wValue) & 0x7f) != 0) {
|
||||
le16_to_cpu (request->wValue) & 0xFF80) != 0) {
|
||||
/* c.f. 9.4.7 - zero is the default or addressed state, in our case this */
|
||||
/* is the same is configuration zero */
|
||||
serial_printf("error setting dev->config to zero!\n");
|
||||
device->configuration = 0; /* TBR - ?????? */
|
||||
}
|
||||
/* reset interface and alternate settings */
|
||||
|
1400
drivers/usbdcore_mpc8xx.c
Normal file
1400
drivers/usbdcore_mpc8xx.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1517,4 +1517,31 @@ void udc_startup_events (struct usb_device_instance *device)
|
||||
udc_enable (device);
|
||||
}
|
||||
|
||||
/**
|
||||
* udc_irq - do pseudo interrupts
|
||||
*/
|
||||
void udc_irq(void)
|
||||
{
|
||||
/* Loop while we have interrupts.
|
||||
* If we don't do this, the input chain
|
||||
* polling delay is likely to miss
|
||||
* host requests.
|
||||
*/
|
||||
while (inw (UDC_IRQ_SRC) & ~UDC_SOF_Flg) {
|
||||
/* Handle any new IRQs */
|
||||
omap1510_udc_irq ();
|
||||
omap1510_udc_noniso_irq ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Flow control */
|
||||
void udc_set_nak(int epid)
|
||||
{
|
||||
/* TODO: implement this functionality in omap1510 */
|
||||
}
|
||||
|
||||
void udc_unset_nak (int epid)
|
||||
{
|
||||
/* TODO: implement this functionality in omap1510 */
|
||||
}
|
||||
#endif
|
||||
|
717
drivers/usbtty.c
717
drivers/usbtty.c
@ -2,6 +2,9 @@
|
||||
* (C) Copyright 2003
|
||||
* Gerry Hamel, geh@ti.com, Texas Instruments
|
||||
*
|
||||
* (C) Copyright 2006
|
||||
* Bryan O'Donoghue, bodonoghue@codehermit.ie
|
||||
*
|
||||
* 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
|
||||
@ -25,19 +28,41 @@
|
||||
#include <circbuf.h>
|
||||
#include <devices.h>
|
||||
#include "usbtty.h"
|
||||
#include "usb_cdc_acm.h"
|
||||
#include "usbdescriptors.h"
|
||||
#include <config.h> /* If defined, override Linux identifiers with
|
||||
* vendor specific ones */
|
||||
|
||||
#if 0
|
||||
#define TTYDBG(fmt,args...) serial_printf("[%s] %s %d: "fmt, __FILE__,__FUNCTION__,__LINE__,##args)
|
||||
#define TTYDBG(fmt,args...)\
|
||||
serial_printf("[%s] %s %d: "fmt, __FILE__,__FUNCTION__,__LINE__,##args)
|
||||
#else
|
||||
#define TTYDBG(fmt,args...) do{}while(0)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define TTYERR(fmt,args...) serial_printf("ERROR![%s] %s %d: "fmt, __FILE__,__FUNCTION__,__LINE__,##args)
|
||||
#if 1
|
||||
#define TTYERR(fmt,args...)\
|
||||
serial_printf("ERROR![%s] %s %d: "fmt, __FILE__,__FUNCTION__,\
|
||||
__LINE__,##args)
|
||||
#else
|
||||
#define TTYERR(fmt,args...) do{}while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines
|
||||
*/
|
||||
#define NUM_CONFIGS 1
|
||||
#define MAX_INTERFACES 2
|
||||
#define NUM_ENDPOINTS 3
|
||||
#define ACM_TX_ENDPOINT 3
|
||||
#define ACM_RX_ENDPOINT 2
|
||||
#define GSERIAL_TX_ENDPOINT 2
|
||||
#define GSERIAL_RX_ENDPOINT 1
|
||||
#define NUM_ACM_INTERFACES 2
|
||||
#define NUM_GSERIAL_INTERFACES 1
|
||||
#define CONFIG_USBD_DATA_INTERFACE_STR "Bulk Data Interface"
|
||||
#define CONFIG_USBD_CTRL_INTERFACE_STR "Control Interface"
|
||||
|
||||
/*
|
||||
* Buffers to hold input and output data
|
||||
*/
|
||||
@ -50,157 +75,336 @@ static circbuf_t usbtty_output;
|
||||
* Instance variables
|
||||
*/
|
||||
static device_t usbttydev;
|
||||
static struct usb_device_instance device_instance[1];
|
||||
static struct usb_bus_instance bus_instance[1];
|
||||
static struct usb_device_instance device_instance[1];
|
||||
static struct usb_bus_instance bus_instance[1];
|
||||
static struct usb_configuration_instance config_instance[NUM_CONFIGS];
|
||||
static struct usb_interface_instance interface_instance[NUM_INTERFACES];
|
||||
static struct usb_alternate_instance alternate_instance[NUM_INTERFACES];
|
||||
static struct usb_endpoint_instance endpoint_instance[NUM_ENDPOINTS+1]; /* one extra for control endpoint */
|
||||
|
||||
/*
|
||||
* Static allocation of urbs
|
||||
*/
|
||||
#define RECV_ENDPOINT 1
|
||||
#define TX_ENDPOINT 2
|
||||
static struct usb_interface_instance interface_instance[MAX_INTERFACES];
|
||||
static struct usb_alternate_instance alternate_instance[MAX_INTERFACES];
|
||||
/* one extra for control endpoint */
|
||||
static struct usb_endpoint_instance endpoint_instance[NUM_ENDPOINTS+1];
|
||||
|
||||
/*
|
||||
* Global flag
|
||||
*/
|
||||
int usbtty_configured_flag = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Serial number
|
||||
*/
|
||||
static char serial_number[16];
|
||||
|
||||
|
||||
/*
|
||||
* Descriptors
|
||||
* Descriptors, Strings, Local variables.
|
||||
*/
|
||||
|
||||
/* defined and used by usbdcore_ep0.c */
|
||||
extern struct usb_string_descriptor **usb_strings;
|
||||
|
||||
/* Indicies, References */
|
||||
static unsigned short rx_endpoint = 0;
|
||||
static unsigned short tx_endpoint = 0;
|
||||
static unsigned short interface_count = 0;
|
||||
static struct usb_string_descriptor *usbtty_string_table[STR_COUNT];
|
||||
|
||||
/* USB Descriptor Strings */
|
||||
static u8 wstrLang[4] = {4,USB_DT_STRING,0x9,0x4};
|
||||
static u8 wstrManufacturer[2 + 2*(sizeof(CONFIG_USBD_MANUFACTURER)-1)];
|
||||
static u8 wstrProduct[2 + 2*(sizeof(CONFIG_USBD_PRODUCT_NAME)-1)];
|
||||
static u8 wstrSerial[2 + 2*(sizeof(serial_number) - 1)];
|
||||
static u8 wstrConfiguration[2 + 2*(sizeof(CONFIG_USBD_CONFIGURATION_STR)-1)];
|
||||
static u8 wstrInterface[2 + 2*(sizeof(CONFIG_USBD_INTERFACE_STR)-1)];
|
||||
|
||||
static struct usb_string_descriptor *usbtty_string_table[] = {
|
||||
(struct usb_string_descriptor*)wstrLang,
|
||||
(struct usb_string_descriptor*)wstrManufacturer,
|
||||
(struct usb_string_descriptor*)wstrProduct,
|
||||
(struct usb_string_descriptor*)wstrSerial,
|
||||
(struct usb_string_descriptor*)wstrConfiguration,
|
||||
(struct usb_string_descriptor*)wstrInterface
|
||||
};
|
||||
extern struct usb_string_descriptor **usb_strings; /* defined and used by omap1510_ep0.c */
|
||||
static u8 wstrDataInterface[2 + 2*(sizeof(CONFIG_USBD_DATA_INTERFACE_STR)-1)];
|
||||
static u8 wstrCtrlInterface[2 + 2*(sizeof(CONFIG_USBD_DATA_INTERFACE_STR)-1)];
|
||||
|
||||
/* Standard USB Data Structures */
|
||||
static struct usb_interface_descriptor interface_descriptors[MAX_INTERFACES];
|
||||
static struct usb_endpoint_descriptor *ep_descriptor_ptrs[NUM_ENDPOINTS];
|
||||
static struct usb_configuration_descriptor *configuration_descriptor = 0;
|
||||
static struct usb_device_descriptor device_descriptor = {
|
||||
bLength: sizeof(struct usb_device_descriptor),
|
||||
bDescriptorType: USB_DT_DEVICE,
|
||||
bcdUSB: USB_BCD_VERSION,
|
||||
bDeviceClass: USBTTY_DEVICE_CLASS,
|
||||
bDeviceSubClass: USBTTY_DEVICE_SUBCLASS,
|
||||
bDeviceProtocol: USBTTY_DEVICE_PROTOCOL,
|
||||
bMaxPacketSize0: EP0_MAX_PACKET_SIZE,
|
||||
idVendor: CONFIG_USBD_VENDORID,
|
||||
idProduct: CONFIG_USBD_PRODUCTID,
|
||||
bcdDevice: USBTTY_BCD_DEVICE,
|
||||
iManufacturer: STR_MANUFACTURER,
|
||||
iProduct: STR_PRODUCT,
|
||||
iSerialNumber: STR_SERIAL,
|
||||
bNumConfigurations: NUM_CONFIGS
|
||||
};
|
||||
static struct usb_configuration_descriptor config_descriptors[NUM_CONFIGS] = {
|
||||
{
|
||||
bLength: sizeof(struct usb_configuration_descriptor),
|
||||
bDescriptorType: USB_DT_CONFIG,
|
||||
wTotalLength: (sizeof(struct usb_configuration_descriptor)*NUM_CONFIGS) +
|
||||
(sizeof(struct usb_interface_descriptor)*NUM_INTERFACES) +
|
||||
(sizeof(struct usb_endpoint_descriptor)*NUM_ENDPOINTS),
|
||||
bNumInterfaces: NUM_INTERFACES,
|
||||
bConfigurationValue: 1,
|
||||
iConfiguration: STR_CONFIG,
|
||||
bmAttributes: BMATTRIBUTE_SELF_POWERED | BMATTRIBUTE_RESERVED,
|
||||
bMaxPower: USBTTY_MAXPOWER
|
||||
},
|
||||
.bLength = sizeof(struct usb_device_descriptor),
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = cpu_to_le16(USB_BCD_VERSION),
|
||||
.bDeviceSubClass = 0x00,
|
||||
.bDeviceProtocol = 0x00,
|
||||
.bMaxPacketSize0 = EP0_MAX_PACKET_SIZE,
|
||||
.idVendor = cpu_to_le16(CONFIG_USBD_VENDORID),
|
||||
.bcdDevice = cpu_to_le16(USBTTY_BCD_DEVICE),
|
||||
.iManufacturer = STR_MANUFACTURER,
|
||||
.iProduct = STR_PRODUCT,
|
||||
.iSerialNumber = STR_SERIAL,
|
||||
.bNumConfigurations = NUM_CONFIGS
|
||||
};
|
||||
static struct usb_interface_descriptor interface_descriptors[NUM_INTERFACES] = {
|
||||
{
|
||||
bLength: sizeof(struct usb_interface_descriptor),
|
||||
bDescriptorType: USB_DT_INTERFACE,
|
||||
bInterfaceNumber: 0,
|
||||
bAlternateSetting: 0,
|
||||
bNumEndpoints: NUM_ENDPOINTS,
|
||||
bInterfaceClass: USBTTY_INTERFACE_CLASS,
|
||||
bInterfaceSubClass: USBTTY_INTERFACE_SUBCLASS,
|
||||
bInterfaceProtocol: USBTTY_INTERFACE_PROTOCOL,
|
||||
iInterface: STR_INTERFACE
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* Static CDC ACM specific descriptors
|
||||
*/
|
||||
|
||||
struct acm_config_desc {
|
||||
struct usb_configuration_descriptor configuration_desc;
|
||||
|
||||
/* Master Interface */
|
||||
struct usb_interface_descriptor interface_desc;
|
||||
|
||||
struct usb_class_header_function_descriptor usb_class_header;
|
||||
struct usb_class_call_management_descriptor usb_class_call_mgt;
|
||||
struct usb_class_abstract_control_descriptor usb_class_acm;
|
||||
struct usb_class_union_function_descriptor usb_class_union;
|
||||
struct usb_endpoint_descriptor notification_endpoint;
|
||||
|
||||
/* Slave Interface */
|
||||
struct usb_interface_descriptor data_class_interface;
|
||||
struct usb_endpoint_descriptor
|
||||
data_endpoints[NUM_ENDPOINTS-1] __attribute__((packed));
|
||||
} __attribute__((packed));
|
||||
|
||||
static struct acm_config_desc acm_configuration_descriptors[NUM_CONFIGS] = {
|
||||
{
|
||||
.configuration_desc ={
|
||||
.bLength =
|
||||
sizeof(struct usb_configuration_descriptor),
|
||||
.bDescriptorType = USB_DT_CONFIG,
|
||||
.wTotalLength =
|
||||
cpu_to_le16(sizeof(struct acm_config_desc)),
|
||||
.bNumInterfaces = NUM_ACM_INTERFACES,
|
||||
.bConfigurationValue = 1,
|
||||
.iConfiguration = STR_CONFIG,
|
||||
.bmAttributes =
|
||||
BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
|
||||
.bMaxPower = USBTTY_MAXPOWER
|
||||
},
|
||||
/* Interface 1 */
|
||||
.interface_desc = {
|
||||
.bLength = sizeof(struct usb_interface_descriptor),
|
||||
.bDescriptorType = USB_DT_INTERFACE,
|
||||
.bInterfaceNumber = 0,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 0x01,
|
||||
.bInterfaceClass =
|
||||
COMMUNICATIONS_INTERFACE_CLASS_CONTROL,
|
||||
.bInterfaceSubClass = COMMUNICATIONS_ACM_SUBCLASS,
|
||||
.bInterfaceProtocol = COMMUNICATIONS_V25TER_PROTOCOL,
|
||||
.iInterface = STR_CTRL_INTERFACE,
|
||||
},
|
||||
.usb_class_header = {
|
||||
.bFunctionLength =
|
||||
sizeof(struct usb_class_header_function_descriptor),
|
||||
.bDescriptorType = CS_INTERFACE,
|
||||
.bDescriptorSubtype = USB_ST_HEADER,
|
||||
.bcdCDC = cpu_to_le16(110),
|
||||
},
|
||||
.usb_class_call_mgt = {
|
||||
.bFunctionLength =
|
||||
sizeof(struct usb_class_call_management_descriptor),
|
||||
.bDescriptorType = CS_INTERFACE,
|
||||
.bDescriptorSubtype = USB_ST_CMF,
|
||||
.bmCapabilities = 0x00,
|
||||
.bDataInterface = 0x01,
|
||||
},
|
||||
.usb_class_acm = {
|
||||
.bFunctionLength =
|
||||
sizeof(struct usb_class_abstract_control_descriptor),
|
||||
.bDescriptorType = CS_INTERFACE,
|
||||
.bDescriptorSubtype = USB_ST_ACMF,
|
||||
.bmCapabilities = 0x00,
|
||||
},
|
||||
.usb_class_union = {
|
||||
.bFunctionLength =
|
||||
sizeof(struct usb_class_union_function_descriptor),
|
||||
.bDescriptorType = CS_INTERFACE,
|
||||
.bDescriptorSubtype = USB_ST_UF,
|
||||
.bMasterInterface = 0x00,
|
||||
.bSlaveInterface0 = 0x01,
|
||||
},
|
||||
.notification_endpoint = {
|
||||
.bLength =
|
||||
sizeof(struct usb_endpoint_descriptor),
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = 0x01 | USB_DIR_IN,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_INT,
|
||||
.wMaxPacketSize
|
||||
= cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
|
||||
.bInterval = 0xFF,
|
||||
},
|
||||
|
||||
/* Interface 2 */
|
||||
.data_class_interface = {
|
||||
.bLength =
|
||||
sizeof(struct usb_interface_descriptor),
|
||||
.bDescriptorType = USB_DT_INTERFACE,
|
||||
.bInterfaceNumber = 0x01,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = 0x02,
|
||||
.bInterfaceClass =
|
||||
COMMUNICATIONS_INTERFACE_CLASS_DATA,
|
||||
.bInterfaceSubClass = DATA_INTERFACE_SUBCLASS_NONE,
|
||||
.bInterfaceProtocol = DATA_INTERFACE_PROTOCOL_NONE,
|
||||
.iInterface = STR_DATA_INTERFACE,
|
||||
},
|
||||
.data_endpoints = {
|
||||
{
|
||||
.bLength =
|
||||
sizeof(struct usb_endpoint_descriptor),
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = 0x02 | USB_DIR_OUT,
|
||||
.bmAttributes =
|
||||
USB_ENDPOINT_XFER_BULK,
|
||||
.wMaxPacketSize =
|
||||
cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
|
||||
.bInterval = 0xFF,
|
||||
},
|
||||
{
|
||||
.bLength =
|
||||
sizeof(struct usb_endpoint_descriptor),
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = 0x03 | USB_DIR_IN,
|
||||
.bmAttributes =
|
||||
USB_ENDPOINT_XFER_BULK,
|
||||
.wMaxPacketSize =
|
||||
cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
|
||||
.bInterval = 0xFF,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
static struct usb_endpoint_descriptor ep_descriptors[NUM_ENDPOINTS] = {
|
||||
{
|
||||
bLength: sizeof(struct usb_endpoint_descriptor),
|
||||
bDescriptorType: USB_DT_ENDPOINT,
|
||||
bEndpointAddress: CONFIG_USBD_SERIAL_OUT_ENDPOINT | USB_DIR_OUT,
|
||||
bmAttributes: USB_ENDPOINT_XFER_BULK,
|
||||
wMaxPacketSize: CONFIG_USBD_SERIAL_OUT_PKTSIZE,
|
||||
bInterval: 0
|
||||
},
|
||||
{
|
||||
bLength: sizeof(struct usb_endpoint_descriptor),
|
||||
bDescriptorType: USB_DT_ENDPOINT,
|
||||
bEndpointAddress: CONFIG_USBD_SERIAL_IN_ENDPOINT | USB_DIR_IN,
|
||||
bmAttributes: USB_ENDPOINT_XFER_BULK,
|
||||
wMaxPacketSize: CONFIG_USBD_SERIAL_IN_PKTSIZE,
|
||||
bInterval: 0
|
||||
},
|
||||
{
|
||||
bLength: sizeof(struct usb_endpoint_descriptor),
|
||||
bDescriptorType: USB_DT_ENDPOINT,
|
||||
bEndpointAddress: CONFIG_USBD_SERIAL_INT_ENDPOINT | USB_DIR_IN,
|
||||
bmAttributes: USB_ENDPOINT_XFER_INT,
|
||||
wMaxPacketSize: CONFIG_USBD_SERIAL_INT_PKTSIZE,
|
||||
bInterval: 0
|
||||
},
|
||||
|
||||
static struct rs232_emu rs232_desc={
|
||||
.dter = 115200,
|
||||
.stop_bits = 0x00,
|
||||
.parity = 0x00,
|
||||
.data_bits = 0x08
|
||||
};
|
||||
static struct usb_endpoint_descriptor *ep_descriptor_ptrs[NUM_ENDPOINTS] = {
|
||||
&(ep_descriptors[0]),
|
||||
&(ep_descriptors[1]),
|
||||
&(ep_descriptors[2]),
|
||||
|
||||
|
||||
/*
|
||||
* Static Generic Serial specific data
|
||||
*/
|
||||
|
||||
|
||||
struct gserial_config_desc {
|
||||
|
||||
struct usb_configuration_descriptor configuration_desc;
|
||||
struct usb_interface_descriptor
|
||||
interface_desc[NUM_GSERIAL_INTERFACES] __attribute__((packed));
|
||||
struct usb_endpoint_descriptor
|
||||
data_endpoints[NUM_ENDPOINTS] __attribute__((packed));
|
||||
|
||||
} __attribute__((packed));
|
||||
|
||||
static struct gserial_config_desc
|
||||
gserial_configuration_descriptors[NUM_CONFIGS] ={
|
||||
{
|
||||
.configuration_desc ={
|
||||
.bLength = sizeof(struct usb_configuration_descriptor),
|
||||
.bDescriptorType = USB_DT_CONFIG,
|
||||
.wTotalLength =
|
||||
cpu_to_le16(sizeof(struct gserial_config_desc)),
|
||||
.bNumInterfaces = NUM_GSERIAL_INTERFACES,
|
||||
.bConfigurationValue = 1,
|
||||
.iConfiguration = STR_CONFIG,
|
||||
.bmAttributes =
|
||||
BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
|
||||
.bMaxPower = USBTTY_MAXPOWER
|
||||
},
|
||||
.interface_desc = {
|
||||
{
|
||||
.bLength =
|
||||
sizeof(struct usb_interface_descriptor),
|
||||
.bDescriptorType = USB_DT_INTERFACE,
|
||||
.bInterfaceNumber = 0,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = NUM_ENDPOINTS,
|
||||
.bInterfaceClass =
|
||||
COMMUNICATIONS_INTERFACE_CLASS_VENDOR,
|
||||
.bInterfaceSubClass =
|
||||
COMMUNICATIONS_NO_SUBCLASS,
|
||||
.bInterfaceProtocol =
|
||||
COMMUNICATIONS_NO_PROTOCOL,
|
||||
.iInterface = STR_DATA_INTERFACE
|
||||
},
|
||||
},
|
||||
.data_endpoints = {
|
||||
{
|
||||
.bLength =
|
||||
sizeof(struct usb_endpoint_descriptor),
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = 0x01 | USB_DIR_OUT,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_BULK,
|
||||
.wMaxPacketSize =
|
||||
cpu_to_le16(CONFIG_USBD_SERIAL_OUT_PKTSIZE),
|
||||
.bInterval= 0xFF,
|
||||
},
|
||||
{
|
||||
.bLength =
|
||||
sizeof(struct usb_endpoint_descriptor),
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = 0x02 | USB_DIR_IN,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_BULK,
|
||||
.wMaxPacketSize =
|
||||
cpu_to_le16(CONFIG_USBD_SERIAL_IN_PKTSIZE),
|
||||
.bInterval = 0xFF,
|
||||
},
|
||||
{
|
||||
.bLength =
|
||||
sizeof(struct usb_endpoint_descriptor),
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = 0x03 | USB_DIR_IN,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_INT,
|
||||
.wMaxPacketSize =
|
||||
cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
|
||||
.bInterval = 0xFF,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* Static Function Prototypes
|
||||
*/
|
||||
|
||||
static void usbtty_init_strings (void);
|
||||
static void usbtty_init_instances (void);
|
||||
static void usbtty_init_endpoints (void);
|
||||
static void usbtty_init_terminal_type(short type);
|
||||
static void usbtty_event_handler (struct usb_device_instance *device,
|
||||
usb_device_event_t event, int data);
|
||||
static int usbtty_cdc_setup(struct usb_device_request *request,
|
||||
struct urb *urb);
|
||||
static int usbtty_configured (void);
|
||||
static int write_buffer (circbuf_t * buf);
|
||||
static int fill_buffer (circbuf_t * buf);
|
||||
|
||||
void usbtty_poll (void);
|
||||
|
||||
/* utility function for converting char* to wide string used by USB */
|
||||
static void str2wide (char *str, u16 * wide)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < strlen (str) && str[i]; i++)
|
||||
wide[i] = (u16) str[i];
|
||||
for (i = 0; i < strlen (str) && str[i]; i++){
|
||||
#if defined(__LITTLE_ENDIAN)
|
||||
wide[i] = (u16) str[i];
|
||||
#elif defined(__BIG_ENDIAN)
|
||||
wide[i] = ((u16)(str[i])<<8);
|
||||
#else
|
||||
#error "__LITTLE_ENDIAN or __BIG_ENDIAN undefined"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
static void usbtty_init_strings (void);
|
||||
static void usbtty_init_instances (void);
|
||||
static void usbtty_init_endpoints (void);
|
||||
|
||||
static void usbtty_event_handler (struct usb_device_instance *device,
|
||||
usb_device_event_t event, int data);
|
||||
static int usbtty_configured (void);
|
||||
|
||||
static int write_buffer (circbuf_t * buf);
|
||||
static int fill_buffer (circbuf_t * buf);
|
||||
|
||||
void usbtty_poll (void);
|
||||
static void pretend_interrupts (void);
|
||||
|
||||
|
||||
/*
|
||||
* Test whether a character is in the RX buffer
|
||||
*/
|
||||
|
||||
int usbtty_tstc (void)
|
||||
{
|
||||
struct usb_endpoint_instance *endpoint =
|
||||
&endpoint_instance[rx_endpoint];
|
||||
|
||||
/* If no input data exists, allow more RX to be accepted */
|
||||
if(usbtty_input.size <= 0){
|
||||
udc_unset_nak(endpoint->endpoint_address&0x03);
|
||||
}
|
||||
|
||||
usbtty_poll ();
|
||||
return (usbtty_input.size > 0);
|
||||
}
|
||||
@ -210,15 +414,21 @@ int usbtty_tstc (void)
|
||||
* otherwise. When the function is succesfull, the character read is
|
||||
* written into its argument c.
|
||||
*/
|
||||
|
||||
int usbtty_getc (void)
|
||||
{
|
||||
char c;
|
||||
struct usb_endpoint_instance *endpoint =
|
||||
&endpoint_instance[rx_endpoint];
|
||||
|
||||
while (usbtty_input.size <= 0) {
|
||||
udc_unset_nak(endpoint->endpoint_address&0x03);
|
||||
usbtty_poll ();
|
||||
}
|
||||
|
||||
buf_pop (&usbtty_input, &c, 1);
|
||||
udc_set_nak(endpoint->endpoint_address&0x03);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -238,7 +448,6 @@ void usbtty_putc (const char c)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* usbtty_puts() helper function for finding the next '\n' in a string */
|
||||
static int next_nl_pos (const char *s)
|
||||
{
|
||||
@ -252,8 +461,9 @@ static int next_nl_pos (const char *s)
|
||||
}
|
||||
|
||||
/*
|
||||
* Output a string to the usb client port.
|
||||
* Output a string to the usb client port - implementing flow control
|
||||
*/
|
||||
|
||||
static void __usbtty_puts (const char *str, int len)
|
||||
{
|
||||
int maxlen = usbtty_output.totalsize;
|
||||
@ -261,22 +471,19 @@ static void __usbtty_puts (const char *str, int len)
|
||||
|
||||
/* break str into chunks < buffer size, if needed */
|
||||
while (len > 0) {
|
||||
usbtty_poll ();
|
||||
|
||||
space = maxlen - usbtty_output.size;
|
||||
|
||||
/* Empty buffer here, if needed, to ensure space... */
|
||||
if (space <= 0) {
|
||||
if (space) {
|
||||
write_buffer (&usbtty_output);
|
||||
space = maxlen - usbtty_output.size;
|
||||
if (space <= 0) {
|
||||
space = len; /* allow old data to be overwritten. */
|
||||
}
|
||||
|
||||
n = MIN (space, MIN (len, maxlen));
|
||||
buf_push (&usbtty_output, str, n);
|
||||
|
||||
str += n;
|
||||
len -= n;
|
||||
}
|
||||
|
||||
n = MIN (space, MIN (len, maxlen));
|
||||
buf_push (&usbtty_output, str, n);
|
||||
|
||||
str += n;
|
||||
len -= n;
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,8 +520,10 @@ int drv_usbtty_init (void)
|
||||
{
|
||||
int rc;
|
||||
char * sn;
|
||||
char * tt;
|
||||
int snlen;
|
||||
|
||||
/* Ger seiral number */
|
||||
if (!(sn = getenv("serial#"))) {
|
||||
sn = "000000000000";
|
||||
}
|
||||
@ -327,6 +536,14 @@ int drv_usbtty_init (void)
|
||||
memcpy (serial_number, sn, snlen);
|
||||
serial_number[snlen] = '\0';
|
||||
|
||||
/* Decide on which type of UDC device to be.
|
||||
*/
|
||||
|
||||
if(!(tt = getenv("usbtty"))) {
|
||||
tt = "generic";
|
||||
}
|
||||
usbtty_init_terminal_type(strcmp(tt,"cdc_acm"));
|
||||
|
||||
/* prepare buffers... */
|
||||
buf_init (&usbtty_input, USBTTY_BUFFER_SIZE);
|
||||
buf_init (&usbtty_output, USBTTY_BUFFER_SIZE);
|
||||
@ -337,7 +554,7 @@ int drv_usbtty_init (void)
|
||||
usbtty_init_strings ();
|
||||
usbtty_init_instances ();
|
||||
|
||||
udc_startup_events (device_instance); /* Enable our device, initialize udc pointers */
|
||||
udc_startup_events (device_instance);/* Enable dev, init udc pointers */
|
||||
udc_connect (); /* Enable pullup for host detection */
|
||||
|
||||
usbtty_init_endpoints ();
|
||||
@ -362,30 +579,48 @@ static void usbtty_init_strings (void)
|
||||
{
|
||||
struct usb_string_descriptor *string;
|
||||
|
||||
usbtty_string_table[STR_LANG] =
|
||||
(struct usb_string_descriptor*)wstrLang;
|
||||
|
||||
string = (struct usb_string_descriptor *) wstrManufacturer;
|
||||
string->bLength = sizeof (wstrManufacturer);
|
||||
string->bLength = sizeof(wstrManufacturer);
|
||||
string->bDescriptorType = USB_DT_STRING;
|
||||
str2wide (CONFIG_USBD_MANUFACTURER, string->wData);
|
||||
usbtty_string_table[STR_MANUFACTURER]=string;
|
||||
|
||||
|
||||
string = (struct usb_string_descriptor *) wstrProduct;
|
||||
string->bLength = sizeof (wstrProduct);
|
||||
string->bLength = sizeof(wstrProduct);
|
||||
string->bDescriptorType = USB_DT_STRING;
|
||||
str2wide (CONFIG_USBD_PRODUCT_NAME, string->wData);
|
||||
usbtty_string_table[STR_PRODUCT]=string;
|
||||
|
||||
|
||||
string = (struct usb_string_descriptor *) wstrSerial;
|
||||
string->bLength = 2 + 2*strlen(serial_number);
|
||||
string->bLength = sizeof(serial_number);
|
||||
string->bDescriptorType = USB_DT_STRING;
|
||||
str2wide (serial_number, string->wData);
|
||||
usbtty_string_table[STR_SERIAL]=string;
|
||||
|
||||
|
||||
string = (struct usb_string_descriptor *) wstrConfiguration;
|
||||
string->bLength = sizeof (wstrConfiguration);
|
||||
string->bLength = sizeof(wstrConfiguration);
|
||||
string->bDescriptorType = USB_DT_STRING;
|
||||
str2wide (CONFIG_USBD_CONFIGURATION_STR, string->wData);
|
||||
usbtty_string_table[STR_CONFIG]=string;
|
||||
|
||||
string = (struct usb_string_descriptor *) wstrInterface;
|
||||
string->bLength = sizeof (wstrInterface);
|
||||
|
||||
string = (struct usb_string_descriptor *) wstrDataInterface;
|
||||
string->bLength = sizeof(wstrDataInterface);
|
||||
string->bDescriptorType = USB_DT_STRING;
|
||||
str2wide (CONFIG_USBD_INTERFACE_STR, string->wData);
|
||||
str2wide (CONFIG_USBD_DATA_INTERFACE_STR, string->wData);
|
||||
usbtty_string_table[STR_DATA_INTERFACE]=string;
|
||||
|
||||
string = (struct usb_string_descriptor *) wstrCtrlInterface;
|
||||
string->bLength = sizeof(wstrCtrlInterface);
|
||||
string->bDescriptorType = USB_DT_STRING;
|
||||
str2wide (CONFIG_USBD_CTRL_INTERFACE_STR, string->wData);
|
||||
usbtty_string_table[STR_CTRL_INTERFACE]=string;
|
||||
|
||||
/* Now, initialize the string table for ep0 handling */
|
||||
usb_strings = usbtty_string_table;
|
||||
@ -400,6 +635,7 @@ static void usbtty_init_instances (void)
|
||||
device_instance->device_state = STATE_INIT;
|
||||
device_instance->device_descriptor = &device_descriptor;
|
||||
device_instance->event = usbtty_event_handler;
|
||||
device_instance->cdc_recv_setup = usbtty_cdc_setup;
|
||||
device_instance->bus = bus_instance;
|
||||
device_instance->configurations = NUM_CONFIGS;
|
||||
device_instance->configuration_instance_array = config_instance;
|
||||
@ -415,8 +651,8 @@ static void usbtty_init_instances (void)
|
||||
/* configuration instance */
|
||||
memset (config_instance, 0,
|
||||
sizeof (struct usb_configuration_instance));
|
||||
config_instance->interfaces = NUM_INTERFACES;
|
||||
config_instance->configuration_descriptor = config_descriptors;
|
||||
config_instance->interfaces = interface_count;
|
||||
config_instance->configuration_descriptor = configuration_descriptor;
|
||||
config_instance->interface_instance_array = interface_instance;
|
||||
|
||||
/* interface instance */
|
||||
@ -447,17 +683,22 @@ static void usbtty_init_instances (void)
|
||||
sizeof (struct usb_endpoint_instance));
|
||||
|
||||
endpoint_instance[i].endpoint_address =
|
||||
ep_descriptors[i - 1].bEndpointAddress;
|
||||
ep_descriptor_ptrs[i - 1]->bEndpointAddress;
|
||||
|
||||
endpoint_instance[i].rcv_attributes =
|
||||
ep_descriptor_ptrs[i - 1]->bmAttributes;
|
||||
|
||||
endpoint_instance[i].rcv_packetSize =
|
||||
ep_descriptors[i - 1].wMaxPacketSize;
|
||||
endpoint_instance[i].rcv_attributes =
|
||||
ep_descriptors[i - 1].bmAttributes;
|
||||
le16_to_cpu(ep_descriptor_ptrs[i - 1]->wMaxPacketSize);
|
||||
|
||||
endpoint_instance[i].tx_attributes =
|
||||
ep_descriptor_ptrs[i - 1]->bmAttributes;
|
||||
|
||||
endpoint_instance[i].tx_packetSize =
|
||||
ep_descriptors[i - 1].wMaxPacketSize;
|
||||
le16_to_cpu(ep_descriptor_ptrs[i - 1]->wMaxPacketSize);
|
||||
|
||||
endpoint_instance[i].tx_attributes =
|
||||
ep_descriptors[i - 1].bmAttributes;
|
||||
ep_descriptor_ptrs[i - 1]->bmAttributes;
|
||||
|
||||
urb_link_init (&endpoint_instance[i].rcv);
|
||||
urb_link_init (&endpoint_instance[i].rdy);
|
||||
@ -480,13 +721,79 @@ static void usbtty_init_endpoints (void)
|
||||
int i;
|
||||
|
||||
bus_instance->max_endpoints = NUM_ENDPOINTS + 1;
|
||||
for (i = 0; i <= NUM_ENDPOINTS; i++) {
|
||||
for (i = 1; i <= NUM_ENDPOINTS; i++) {
|
||||
udc_setup_ep (device_instance, i, &endpoint_instance[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* usbtty_init_terminal_type
|
||||
*
|
||||
* Do some late binding for our device type.
|
||||
*/
|
||||
static void usbtty_init_terminal_type(short type)
|
||||
{
|
||||
switch(type){
|
||||
/* CDC ACM */
|
||||
case 0:
|
||||
/* Assign endpoint descriptors */
|
||||
ep_descriptor_ptrs[0] =
|
||||
&acm_configuration_descriptors[0].notification_endpoint;
|
||||
ep_descriptor_ptrs[1] =
|
||||
&acm_configuration_descriptors[0].data_endpoints[0];
|
||||
ep_descriptor_ptrs[2] =
|
||||
&acm_configuration_descriptors[0].data_endpoints[1];
|
||||
|
||||
/*********************************************************************************/
|
||||
/* Enumerate Device Descriptor */
|
||||
device_descriptor.bDeviceClass =
|
||||
COMMUNICATIONS_DEVICE_CLASS;
|
||||
device_descriptor.idProduct =
|
||||
cpu_to_le16(CONFIG_USBD_PRODUCTID_CDCACM);
|
||||
|
||||
/* Assign endpoint indices */
|
||||
tx_endpoint = ACM_TX_ENDPOINT;
|
||||
rx_endpoint = ACM_RX_ENDPOINT;
|
||||
|
||||
/* Configuration Descriptor */
|
||||
configuration_descriptor =
|
||||
(struct usb_configuration_descriptor*)
|
||||
&acm_configuration_descriptors;
|
||||
|
||||
/* Interface count */
|
||||
interface_count = NUM_ACM_INTERFACES;
|
||||
break;
|
||||
|
||||
/* BULK IN/OUT & Default */
|
||||
case 1:
|
||||
default:
|
||||
/* Assign endpoint descriptors */
|
||||
ep_descriptor_ptrs[0] =
|
||||
&gserial_configuration_descriptors[0].data_endpoints[0];
|
||||
ep_descriptor_ptrs[1] =
|
||||
&gserial_configuration_descriptors[0].data_endpoints[1];
|
||||
ep_descriptor_ptrs[2] =
|
||||
&gserial_configuration_descriptors[0].data_endpoints[2];
|
||||
|
||||
/* Enumerate Device Descriptor */
|
||||
device_descriptor.bDeviceClass = 0xFF;
|
||||
device_descriptor.idProduct =
|
||||
cpu_to_le16(CONFIG_USBD_PRODUCTID_GSERIAL);
|
||||
|
||||
/* Assign endpoint indices */
|
||||
tx_endpoint = GSERIAL_TX_ENDPOINT;
|
||||
rx_endpoint = GSERIAL_RX_ENDPOINT;
|
||||
|
||||
/* Configuration Descriptor */
|
||||
configuration_descriptor =
|
||||
(struct usb_configuration_descriptor*)
|
||||
&gserial_configuration_descriptors;
|
||||
|
||||
/* Interface count */
|
||||
interface_count = NUM_GSERIAL_INTERFACES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static struct urb *next_urb (struct usb_device_instance *device,
|
||||
struct usb_endpoint_instance *endpoint)
|
||||
@ -526,27 +833,39 @@ static int write_buffer (circbuf_t * buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (buf->size) {
|
||||
struct usb_endpoint_instance *endpoint =
|
||||
&endpoint_instance[tx_endpoint];
|
||||
struct urb *current_urb = NULL;
|
||||
|
||||
struct usb_endpoint_instance *endpoint =
|
||||
&endpoint_instance[TX_ENDPOINT];
|
||||
struct urb *current_urb = NULL;
|
||||
current_urb = next_urb (device_instance, endpoint);
|
||||
/* TX data still exists - send it now
|
||||
*/
|
||||
if(endpoint->sent < current_urb->actual_length){
|
||||
if(udc_endpoint_write (endpoint)){
|
||||
/* Write pre-empted by RX */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (buf->size) {
|
||||
char *dest;
|
||||
|
||||
int space_avail;
|
||||
int popnum, popped;
|
||||
int total = 0;
|
||||
|
||||
/* Break buffer into urb sized pieces, and link each to the endpoint */
|
||||
/* Break buffer into urb sized pieces,
|
||||
* and link each to the endpoint
|
||||
*/
|
||||
while (buf->size > 0) {
|
||||
current_urb = next_urb (device_instance, endpoint);
|
||||
|
||||
if (!current_urb) {
|
||||
TTYERR ("current_urb is NULL, buf->size %d\n",
|
||||
buf->size);
|
||||
return total;
|
||||
}
|
||||
|
||||
dest = current_urb->buffer +
|
||||
dest = (char*)current_urb->buffer +
|
||||
current_urb->actual_length;
|
||||
|
||||
space_avail =
|
||||
@ -562,14 +881,19 @@ static int write_buffer (circbuf_t * buf)
|
||||
current_urb->actual_length += popped;
|
||||
total += popped;
|
||||
|
||||
/* If endpoint->last == 0, then transfers have not started on this endpoint */
|
||||
/* If endpoint->last == 0, then transfers have
|
||||
* not started on this endpoint
|
||||
*/
|
||||
if (endpoint->last == 0) {
|
||||
udc_endpoint_write (endpoint);
|
||||
if(udc_endpoint_write (endpoint)){
|
||||
/* Write pre-empted by RX */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
} /* end while */
|
||||
}/* end while */
|
||||
return total;
|
||||
} /* end if tx_urb */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -577,18 +901,22 @@ static int write_buffer (circbuf_t * buf)
|
||||
static int fill_buffer (circbuf_t * buf)
|
||||
{
|
||||
struct usb_endpoint_instance *endpoint =
|
||||
&endpoint_instance[RECV_ENDPOINT];
|
||||
&endpoint_instance[rx_endpoint];
|
||||
|
||||
if (endpoint->rcv_urb && endpoint->rcv_urb->actual_length) {
|
||||
unsigned int nb = endpoint->rcv_urb->actual_length;
|
||||
unsigned int nb = 0;
|
||||
char *src = (char *) endpoint->rcv_urb->buffer;
|
||||
unsigned int rx_avail = buf->totalsize - buf->size;
|
||||
|
||||
buf_push (buf, src, nb);
|
||||
endpoint->rcv_urb->actual_length = 0;
|
||||
if(rx_avail >= endpoint->rcv_urb->actual_length){
|
||||
|
||||
nb = endpoint->rcv_urb->actual_length;
|
||||
buf_push (buf, src, nb);
|
||||
endpoint->rcv_urb->actual_length = 0;
|
||||
|
||||
}
|
||||
return nb;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -597,7 +925,7 @@ static int usbtty_configured (void)
|
||||
return usbtty_configured_flag;
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
static void usbtty_event_handler (struct usb_device_instance *device,
|
||||
usb_device_event_t event, int data)
|
||||
@ -619,8 +947,34 @@ static void usbtty_event_handler (struct usb_device_instance *device,
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
int usbtty_cdc_setup(struct usb_device_request *request, struct urb *urb)
|
||||
{
|
||||
switch (request->bRequest){
|
||||
|
||||
case ACM_SET_CONTROL_LINE_STATE: /* Implies DTE ready */
|
||||
break;
|
||||
case ACM_SEND_ENCAPSULATED_COMMAND : /* Required */
|
||||
break;
|
||||
case ACM_SET_LINE_ENCODING : /* DTE stop/parity bits
|
||||
* per character */
|
||||
break;
|
||||
case ACM_GET_ENCAPSULATED_RESPONSE : /* request response */
|
||||
break;
|
||||
case ACM_GET_LINE_ENCODING : /* request DTE rate,
|
||||
* stop/parity bits */
|
||||
memcpy (urb->buffer , &rs232_desc, sizeof(rs232_desc));
|
||||
urb->actual_length = sizeof(rs232_desc);
|
||||
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/*
|
||||
* Since interrupt handling has not yet been implemented, we use this function
|
||||
@ -630,36 +984,29 @@ static void usbtty_event_handler (struct usb_device_instance *device,
|
||||
void usbtty_poll (void)
|
||||
{
|
||||
/* New interrupts? */
|
||||
pretend_interrupts ();
|
||||
udc_irq();
|
||||
|
||||
/* Write any output data to host buffer (do this before checking interrupts to avoid missing one) */
|
||||
/* Write any output data to host buffer
|
||||
* (do this before checking interrupts to avoid missing one)
|
||||
*/
|
||||
if (usbtty_configured ()) {
|
||||
write_buffer (&usbtty_output);
|
||||
}
|
||||
|
||||
/* New interrupts? */
|
||||
pretend_interrupts ();
|
||||
udc_irq();
|
||||
|
||||
/* Check for new data from host.. (do this after checking interrupts to get latest data) */
|
||||
/* Check for new data from host..
|
||||
* (do this after checking interrupts to get latest data)
|
||||
*/
|
||||
if (usbtty_configured ()) {
|
||||
fill_buffer (&usbtty_input);
|
||||
}
|
||||
|
||||
/* New interrupts? */
|
||||
pretend_interrupts ();
|
||||
udc_irq();
|
||||
|
||||
}
|
||||
|
||||
static void pretend_interrupts (void)
|
||||
{
|
||||
/* Loop while we have interrupts.
|
||||
* If we don't do this, the input chain
|
||||
* polling delay is likely to miss
|
||||
* host requests.
|
||||
*/
|
||||
while (inw (UDC_IRQ_SRC) & ~UDC_SOF_Flg) {
|
||||
/* Handle any new IRQs */
|
||||
omap1510_udc_irq ();
|
||||
omap1510_udc_noniso_irq ();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -2,6 +2,9 @@
|
||||
* (C) Copyright 2003
|
||||
* Gerry Hamel, geh@ti.com, Texas Instruments
|
||||
*
|
||||
* (C) Copyright 2006
|
||||
* Bryan O'Donoghue, bodonoghue@codehermit.ie, CodeHermit
|
||||
*
|
||||
* 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
|
||||
@ -21,44 +24,47 @@
|
||||
#ifndef __USB_TTY_H__
|
||||
#define __USB_TTY_H__
|
||||
|
||||
|
||||
#include "usbdcore.h"
|
||||
#if defined(CONFIG_PPC)
|
||||
#include "usbdcore_mpc8xx.h"
|
||||
#elif defined(CONFIG_ARM)
|
||||
#include "usbdcore_omap1510.h"
|
||||
#endif
|
||||
|
||||
#include <version_autogenerated.h>
|
||||
|
||||
#define NUM_CONFIGS 1
|
||||
#define NUM_INTERFACES 1
|
||||
#define NUM_ENDPOINTS 3
|
||||
/* If no VendorID/ProductID is defined in config.h, pretend to be Linux
|
||||
* DO NOT Reuse this Vendor/Product setup with protocol incompatible devices */
|
||||
|
||||
#define CONFIG_USBD_VENDORID 0x0525 /* Linux/NetChip */
|
||||
#define CONFIG_USBD_PRODUCTID_GSERIAL 0xa4a6 /* gserial */
|
||||
#define CONFIG_USBD_PRODUCTID_CDCACM 0xa4a7 /* CDC ACM */
|
||||
#define CONFIG_USBD_MANUFACTURER "Das U-Boot"
|
||||
#define CONFIG_USBD_PRODUCT_NAME U_BOOT_VERSION
|
||||
|
||||
#define EP0_MAX_PACKET_SIZE 64
|
||||
|
||||
#define CONFIG_USBD_CONFIGURATION_STR "TTY via USB"
|
||||
#define CONFIG_USBD_INTERFACE_STR "Simple Serial Data Interface - Bulk Mode"
|
||||
|
||||
|
||||
#define CONFIG_USBD_SERIAL_OUT_ENDPOINT 2
|
||||
#define CONFIG_USBD_SERIAL_OUT_PKTSIZE 64
|
||||
#define CONFIG_USBD_SERIAL_IN_ENDPOINT 1
|
||||
#define CONFIG_USBD_SERIAL_IN_PKTSIZE 64
|
||||
#define CONFIG_USBD_SERIAL_INT_ENDPOINT 5
|
||||
#define CONFIG_USBD_SERIAL_INT_PKTSIZE 16
|
||||
|
||||
#define CONFIG_USBD_SERIAL_OUT_ENDPOINT UDC_OUT_ENDPOINT
|
||||
#define CONFIG_USBD_SERIAL_OUT_PKTSIZE UDC_OUT_PACKET_SIZE
|
||||
#define CONFIG_USBD_SERIAL_IN_ENDPOINT UDC_IN_ENDPOINT
|
||||
#define CONFIG_USBD_SERIAL_IN_PKTSIZE UDC_IN_PACKET_SIZE
|
||||
#define CONFIG_USBD_SERIAL_INT_ENDPOINT UDC_INT_ENDPOINT
|
||||
#define CONFIG_USBD_SERIAL_INT_PKTSIZE UDC_INT_PACKET_SIZE
|
||||
#define CONFIG_USBD_SERIAL_BULK_PKTSIZE UDC_BULK_PACKET_SIZE
|
||||
|
||||
#define USBTTY_DEVICE_CLASS COMMUNICATIONS_DEVICE_CLASS
|
||||
#define USBTTY_DEVICE_SUBCLASS COMMUNICATIONS_NO_SUBCLASS
|
||||
#define USBTTY_DEVICE_PROTOCOL COMMUNICATIONS_NO_PROTOCOL
|
||||
|
||||
#define USBTTY_INTERFACE_CLASS 0xFF /* Vendor Specific */
|
||||
#define USBTTY_INTERFACE_SUBCLASS 0x02
|
||||
#define USBTTY_INTERFACE_PROTOCOL 0x01
|
||||
#define USBTTY_BCD_DEVICE 0x00
|
||||
#define USBTTY_MAXPOWER 0x00
|
||||
|
||||
#define USBTTY_BCD_DEVICE 0x0
|
||||
#define USBTTY_MAXPOWER 0x0
|
||||
|
||||
#define STR_MANUFACTURER 1
|
||||
#define STR_PRODUCT 2
|
||||
#define STR_SERIAL 3
|
||||
#define STR_CONFIG 4
|
||||
#define STR_INTERFACE 5
|
||||
#define STR_LANG 0x00
|
||||
#define STR_MANUFACTURER 0x01
|
||||
#define STR_PRODUCT 0x02
|
||||
#define STR_SERIAL 0x03
|
||||
#define STR_CONFIG 0x04
|
||||
#define STR_DATA_INTERFACE 0x05
|
||||
#define STR_CTRL_INTERFACE 0x06
|
||||
#define STR_COUNT 0x07
|
||||
|
||||
#endif
|
||||
|
@ -592,9 +592,11 @@ typedef void (*ExcpHndlr) (void) ;
|
||||
#define PMC_REG_BASE __REG(0x40500400) /* Primary Modem Codec */
|
||||
#define SMC_REG_BASE __REG(0x40500500) /* Secondary Modem Codec */
|
||||
|
||||
|
||||
/*
|
||||
* USB Device Controller
|
||||
*/
|
||||
#ifndef CONFIG_CPU_MONAHANS
|
||||
#define UDC_RES1 __REG(0x40600004) /* UDC Undocumented - Reserved1 */
|
||||
#define UDC_RES2 __REG(0x40600008) /* UDC Undocumented - Reserved2 */
|
||||
#define UDC_RES3 __REG(0x4060000C) /* UDC Undocumented - Reserved3 */
|
||||
@ -749,11 +751,28 @@ typedef void (*ExcpHndlr) (void) ;
|
||||
#define USIR1_IR13 (1 << 5) /* Interrup request ep 13 */
|
||||
#define USIR1_IR14 (1 << 6) /* Interrup request ep 14 */
|
||||
#define USIR1_IR15 (1 << 7) /* Interrup request ep 15 */
|
||||
#endif /* ! CONFIG_CPU_MONAHANS */
|
||||
|
||||
#if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
|
||||
|
||||
/*
|
||||
* USB Client Controller (incomplete)
|
||||
*/
|
||||
#define UDCCR __REG(0x40600000)
|
||||
#define UDCICR0 __REG(0x40600004)
|
||||
#define UDCCIR0 __REG(0x40600008)
|
||||
#define UDCISR0 __REG(0x4060000c)
|
||||
#define UDCSIR1 __REG(0x40600010)
|
||||
#define UDCFNR __REG(0x40600014)
|
||||
#define UDCOTGICR __REG(0x40600018)
|
||||
#define UDCOTGISR __REG(0x4060001c)
|
||||
#define UP2OCR __REG(0x40600020)
|
||||
#define UP3OCR __REG(0x40600024)
|
||||
|
||||
#if defined(CONFIG_PXA27X)
|
||||
/*
|
||||
* USB Host Controller
|
||||
*/
|
||||
#define OHCI_REGS_BASE 0x4C000000 /* required for ohci driver */
|
||||
#define UHCREV __REG(0x4C000000)
|
||||
#define UHCHCON __REG(0x4C000004)
|
||||
#define UHCCOMS __REG(0x4C000008)
|
||||
|
51
include/configs/AdderUSB.h
Normal file
51
include/configs/AdderUSB.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2006 CodeHermit.
|
||||
* Bryan O'Donoghue <bodonoghue@codehermit.ie>
|
||||
*
|
||||
* Provides support for USB console on the Analogue & Micro Adder87x
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __ADDERUSB__
|
||||
#define __ADDERUSB__
|
||||
|
||||
/* Include the board port */
|
||||
#include "Adder.h"
|
||||
|
||||
#define CONFIG_USB_DEVICE /* Include UDC driver */
|
||||
#define CONFIG_USB_TTY /* Bind the TTY driver to UDC */
|
||||
#define CFG_USB_EXTC_CLK 0x02 /* Oscillator on EXTC_CLK 2 */
|
||||
#define CFG_USB_BRG_CLK 0x04 /* or use Baud rate generator 0x04 */
|
||||
#define CFG_CONSOLE_IS_IN_ENV /* Console is in env */
|
||||
|
||||
/* If you have a USB-IF assigned VendorID then you may wish to define
|
||||
* your own vendor specific values either in BoardName.h or directly in
|
||||
* usbd_vendor_info.h
|
||||
*/
|
||||
|
||||
/*
|
||||
#define CONFIG_USBD_MANUFACTURER "CodeHermit.ie"
|
||||
#define CONFIG_USBD_PRODUCT_NAME "Das U-Boot"
|
||||
#define CONFIG_USBD_VENDORID 0xFFFF
|
||||
#define CONFIG_USBD_PRODUCTID_GSERIAL 0xFFFF
|
||||
#define CONFIG_USBD_PRODUCTID_CDCACM 0xFFFE
|
||||
*/
|
||||
|
||||
#endif /* __ADDERUSB_H__ */
|
@ -84,10 +84,15 @@
|
||||
#define CONFIG_ISO_PARTITION
|
||||
|
||||
/* USB */
|
||||
#if 1
|
||||
#define CONFIG_USB_OHCI
|
||||
#define CONFIG_USB_OHCI_NEW
|
||||
#define ADD_USB_CMD CFG_CMD_USB | CFG_CMD_FAT
|
||||
#define CONFIG_USB_STORAGE
|
||||
#endif
|
||||
#define CFG_OHCI_BE_CONTROLLER
|
||||
#undef CFG_USB_OHCI_BOARD_INIT
|
||||
#define CFG_USB_OHCI_CPU_INIT 1
|
||||
#define CFG_USB_OHCI_REGS_BASE MPC5XXX_USB
|
||||
#define CFG_USB_OHCI_SLOT_NAME "mpc5200"
|
||||
#define CFG_USB_OHCI_MAX_ROOT_PORTS 15
|
||||
|
||||
#define CONFIG_TIMESTAMP /* Print image info with timestamp */
|
||||
|
||||
|
@ -338,6 +338,17 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
|
||||
#undef CONFIG_EEPRO100
|
||||
#undef CONFIG_TULIP
|
||||
|
||||
/************************************************************
|
||||
* USB support
|
||||
************************************************************/
|
||||
#define CONFIG_PCI_OHCI 1
|
||||
#define CONFIG_USB_OHCI_NEW 1
|
||||
#define CONFIG_USB_KEYBOARD 1
|
||||
#define CFG_DEVICE_DEREGISTER
|
||||
#define CFG_USB_EVENT_POLL 1
|
||||
#define CFG_USB_OHCI_SLOT_NAME "ohci_pci"
|
||||
#define CFG_USB_OHCI_MAX_ROOT_PORTS 15
|
||||
|
||||
#if !defined(CONFIG_PCI_PNP)
|
||||
#define PCI_ENET0_IOADDR 0xe0000000
|
||||
#define PCI_ENET0_MEMADDR 0xe0000000
|
||||
|
@ -130,8 +130,18 @@
|
||||
|
||||
/* USB */
|
||||
#if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
|
||||
#define CONFIG_USB_OHCI
|
||||
#define CONFIG_USB_OHCI_NEW
|
||||
#define ADD_USB_CMD CFG_CMD_USB | CFG_CMD_FAT
|
||||
#define CONFIG_USB_STORAGE
|
||||
|
||||
#undef CFG_USB_OHCI_BOARD_INIT
|
||||
#define CFG_USB_OHCI_CPU_INIT
|
||||
#define CFG_USB_OHCI_REGS_BASE MPC5XXX_USB
|
||||
#define CFG_USB_OHCI_SLOT_NAME "mpc5200"
|
||||
#define CFG_USB_OHCI_MAX_ROOT_PORTS 15
|
||||
|
||||
#else
|
||||
#define ADD_USB_CMD 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_CAM5200
|
||||
|
@ -118,6 +118,18 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* USB */
|
||||
#define CONFIG_USB_OHCI_NEW 1
|
||||
#define CONFIG_USB_STORAGE 1
|
||||
#define CONFIG_DOS_PARTITION 1
|
||||
|
||||
#undef CFG_USB_OHCI_BOARD_INIT
|
||||
#define CFG_USB_OHCI_CPU_INIT 1
|
||||
#define CFG_USB_OHCI_REGS_BASE OHCI_REGS_BASE
|
||||
#define CFG_USB_OHCI_SLOT_NAME "delta"
|
||||
#define CFG_USB_OHCI_MAX_ROOT_PORTS 3
|
||||
|
||||
#define LITTLEENDIAN 1 /* used by usb_ohci.c */
|
||||
|
||||
#define CONFIG_BOOTDELAY -1
|
||||
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b
|
||||
|
@ -101,12 +101,18 @@
|
||||
|
||||
#undef CONFIG_MODEM_SUPPORT /* disable modem initialization stuff */
|
||||
|
||||
#define CONFIG_USB_OHCI 1
|
||||
#define CONFIG_USB_OHCI_NEW 1
|
||||
#define CONFIG_USB_KEYBOARD 1
|
||||
#define CONFIG_USB_STORAGE 1
|
||||
#define CONFIG_DOS_PARTITION 1
|
||||
#define CONFIG_AT91C_PQFP_UHPBUG 1
|
||||
|
||||
#undef CFG_USB_OHCI_BOARD_INIT
|
||||
#define CFG_USB_OHCI_CPU_INIT 1
|
||||
#define CFG_USB_OHCI_REGS_BASE AT91_USB_HOST_BASE
|
||||
#define CFG_USB_OHCI_SLOT_NAME "at91rm9200"
|
||||
#define CFG_USB_OHCI_MAX_ROOT_PORTS 15
|
||||
|
||||
#undef CONFIG_HARD_I2C
|
||||
|
||||
#ifdef CONFIG_HARD_I2C
|
||||
@ -123,7 +129,6 @@
|
||||
|
||||
#define CONFIG_BOOTDELAY 3
|
||||
|
||||
|
||||
#if !defined(CONFIG_HARD_I2C)
|
||||
#define CONFIG_TIMESTAMP
|
||||
#endif
|
||||
@ -173,7 +178,7 @@
|
||||
|
||||
#define CONFIG_NR_DRAM_BANKS 1
|
||||
#define PHYS_SDRAM 0x20000000
|
||||
#define PHYS_SDRAM_SIZE 0x08000000 /* 128 megs */
|
||||
#define PHYS_SDRAM_SIZE 0x08000000 /* 128 megs */
|
||||
|
||||
#define CFG_MEMTEST_START PHYS_SDRAM
|
||||
#define CFG_MEMTEST_END CFG_MEMTEST_START + PHYS_SDRAM_SIZE - 262144
|
||||
|
@ -80,10 +80,17 @@
|
||||
#define CFG_EEPROM_PAGE_WRITE_DELAY_MS 10
|
||||
|
||||
/* USB stuff */
|
||||
#define CONFIG_USB_OHCI 1
|
||||
#define CONFIG_USB_OHCI_NEW 1
|
||||
#define CONFIG_USB_STORAGE 1
|
||||
#define CONFIG_DOS_PARTITION 1
|
||||
|
||||
#undef CFG_USB_OHCI_BOARD_INIT
|
||||
#define CFG_USB_OHCI_CPU_INIT 1
|
||||
|
||||
#define CFG_USB_OHCI_REGS_BASE 0x14200000
|
||||
#define CFG_USB_OHCI_SLOT_NAME "s3c2400"
|
||||
#define CFG_USB_OHCI_MAX_ROOT_PORTS 15
|
||||
|
||||
/*
|
||||
* Size of malloc() pool
|
||||
*/
|
||||
|
@ -233,8 +233,15 @@
|
||||
|
||||
#ifdef CONFIG_440EP
|
||||
/* USB */
|
||||
#define CONFIG_USB_OHCI
|
||||
#define CONFIG_USB_OHCI_NEW
|
||||
#define CONFIG_USB_STORAGE
|
||||
#define CFG_OHCI_BE_CONTROLLER
|
||||
|
||||
#undef CFG_USB_OHCI_BOARD_INIT
|
||||
#define CFG_USB_OHCI_CPU_INIT 1
|
||||
#define CFG_USB_OHCI_REGS_BASE (CFG_PERIPHERAL_BASE | 0x1000)
|
||||
#define CFG_USB_OHCI_SLOT_NAME "ppc440"
|
||||
#define CFG_USB_OHCI_MAX_ROOT_PORTS 15
|
||||
|
||||
/* Comment this out to enable USB 1.1 device */
|
||||
#define USB_2_0_DEVICE
|
||||
|
@ -104,3 +104,15 @@
|
||||
#define SYS_CONTROL_A_HWRES_ENABLE (1<<2)
|
||||
#define SYS_CONTROL_A_WDOG_ACTION (1<<3)
|
||||
#define SYS_CONTROL_A_WATCHDOG (1<<7)
|
||||
|
||||
#define MISC_CONTROLB_USB_INT_RISING (1<<2)
|
||||
#define MISC_CONTROLB_SESSION_VALID_EN (1<<3)
|
||||
|
||||
#define USB_PUMP_USBVE (1<<0)
|
||||
#define USB_PUMP_USBVEP (1<<1)
|
||||
#define USB_PUMP_SRP_DETECT (1<<2)
|
||||
#define USB_PUMP_SESSION_VALID (1<<3)
|
||||
#define USB_PUMP_VBUS_VALID_4_0 (1<<4)
|
||||
#define USB_PUMP_VBUS_VALID_4_4 (1<<5)
|
||||
#define USB_PUMP_EN_USBVE (1<<6)
|
||||
#define USB_PUMP_EN_USBVEP (1<<7)
|
||||
|
@ -169,7 +169,10 @@ struct usb_device {
|
||||
* this is how the lowlevel part communicate with the outer world
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || defined (CONFIG_USB_SL811HS)
|
||||
#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || \
|
||||
defined(CONFIG_USB_OHCI_NEW) || defined (CONFIG_USB_SL811HS) || \
|
||||
defined(CONFIG_USB_ISP116X_HCD)
|
||||
|
||||
int usb_lowlevel_init(void);
|
||||
int usb_lowlevel_stop(void);
|
||||
int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,int transfer_len);
|
||||
@ -177,6 +180,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int transfer_len,struct devrequest *setup);
|
||||
int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int transfer_len, int interval);
|
||||
void usb_event_poll(void);
|
||||
|
||||
/* Defines */
|
||||
#define USB_UHCI_VEND_ID 0x8086
|
||||
@ -230,16 +234,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
|
||||
|
||||
/* big endian -> little endian conversion */
|
||||
/* some CPUs are already little endian e.g. the ARM920T */
|
||||
#ifdef LITTLEENDIAN
|
||||
#define swap_16(x) ((unsigned short)(x))
|
||||
#define swap_32(x) ((unsigned long)(x))
|
||||
#else
|
||||
#define swap_16(x) \
|
||||
#define __swap_16(x) \
|
||||
({ unsigned short x_ = (unsigned short)x; \
|
||||
(unsigned short)( \
|
||||
((x_ & 0x00FFU) << 8) | ((x_ & 0xFF00U) >> 8) ); \
|
||||
})
|
||||
#define swap_32(x) \
|
||||
#define __swap_32(x) \
|
||||
({ unsigned long x_ = (unsigned long)x; \
|
||||
(unsigned long)( \
|
||||
((x_ & 0x000000FFUL) << 24) | \
|
||||
@ -247,6 +247,13 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
|
||||
((x_ & 0x00FF0000UL) >> 8) | \
|
||||
((x_ & 0xFF000000UL) >> 24) ); \
|
||||
})
|
||||
|
||||
#ifdef LITTLEENDIAN
|
||||
# define swap_16(x) (x)
|
||||
# define swap_32(x) (x)
|
||||
#else
|
||||
# define swap_16(x) __swap_16(x)
|
||||
# define swap_32(x) __swap_32(x)
|
||||
#endif /* LITTLEENDIAN */
|
||||
|
||||
/*
|
||||
|
43
include/usb_cdc_acm.h
Normal file
43
include/usb_cdc_acm.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* (C) Copyright 2006
|
||||
* Bryan O'Donoghue, deckard@codehermit.ie, CodeHermit
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/* ACM Control Requests */
|
||||
#define ACM_SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define ACM_GET_ENCAPSULATED_RESPONSE 0x01
|
||||
#define ACM_SET_COMM_FEATURE 0x02
|
||||
#define ACM_GET_COMM_FEATRUE 0x03
|
||||
#define ACM_CLEAR_COMM_FEATURE 0x04
|
||||
#define ACM_SET_LINE_ENCODING 0x20
|
||||
#define ACM_GET_LINE_ENCODING 0x21
|
||||
#define ACM_SET_CONTROL_LINE_STATE 0x22
|
||||
#define ACM_SEND_BREAK 0x23
|
||||
|
||||
/* ACM Notification Codes */
|
||||
#define ACM_NETWORK_CONNECTION 0x00
|
||||
#define ACM_RESPONSE_AVAILABLE 0x01
|
||||
#define ACM_SERIAL_STATE 0x20
|
||||
|
||||
/* Format of response expected by a ACM_GET_LINE_ENCODING request */
|
||||
struct rs232_emu{
|
||||
unsigned long dter;
|
||||
unsigned char stop_bits;
|
||||
unsigned char parity;
|
||||
unsigned char data_bits;
|
||||
}__attribute__((packed));
|
@ -576,6 +576,9 @@ struct usb_device_instance {
|
||||
|
||||
void (*event) (struct usb_device_instance *device, usb_device_event_t event, int data);
|
||||
|
||||
/* Do cdc device specific control requests */
|
||||
int (*cdc_recv_setup)(struct usb_device_request *request, struct urb *urb);
|
||||
|
||||
/* bus interface */
|
||||
struct usb_bus_instance *bus; /* which bus interface driver */
|
||||
|
||||
|
210
include/usbdcore_mpc8xx.h
Normal file
210
include/usbdcore_mpc8xx.h
Normal file
@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Bryan O'Donoghue, CodeHermit
|
||||
* bodonoghue@codehermit.ie
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <commproc.h>
|
||||
|
||||
/* Mode Register */
|
||||
#define USMOD_EN 0x01
|
||||
#define USMOD_HOST 0x02
|
||||
#define USMOD_TEST 0x04
|
||||
#define USMOD_SFTE 0x08
|
||||
#define USMOD_RESUME 0x40
|
||||
#define USMOD_LSS 0x80
|
||||
|
||||
/* Endpoint Registers */
|
||||
#define USEP_RHS_NORM 0x00
|
||||
#define USEP_RHS_IGNORE 0x01
|
||||
#define USEP_RHS_NAK 0x02
|
||||
#define USEP_RHS_STALL 0x03
|
||||
|
||||
#define USEP_THS_NORM 0x00
|
||||
#define USEP_THS_IGNORE 0x04
|
||||
#define USEP_THS_NAK 0x08
|
||||
#define USEP_THS_STALL 0x0C
|
||||
|
||||
#define USEP_RTE 0x10
|
||||
#define USEP_MF 0x20
|
||||
|
||||
#define USEP_TM_CONTROL 0x00
|
||||
#define USEP_TM_INT 0x100
|
||||
#define USEP_TM_BULK 0x200
|
||||
#define USEP_TM_ISO 0x300
|
||||
|
||||
/* Command Register */
|
||||
#define USCOM_EP0 0x00
|
||||
#define USCOM_EP1 0x01
|
||||
#define USCOM_EP2 0x02
|
||||
#define USCOM_EP3 0x03
|
||||
|
||||
#define USCOM_FLUSH 0x40
|
||||
#define USCOM_STR 0x80
|
||||
|
||||
/* Event Register */
|
||||
#define USB_E_RXB 0x0001
|
||||
#define USB_E_TXB 0x0002
|
||||
#define USB_E_BSY 0x0004
|
||||
#define USB_E_SOF 0x0008
|
||||
#define USB_E_TXE1 0x0010
|
||||
#define USB_E_TXE2 0x0020
|
||||
#define USB_E_TXE3 0x0040
|
||||
#define USB_E_TXE4 0x0080
|
||||
#define USB_TX_ERRMASK (USB_E_TXE1|USB_E_TXE2|USB_E_TXE3|USB_E_TXE4)
|
||||
#define USB_E_IDLE 0x0100
|
||||
#define USB_E_RESET 0x0200
|
||||
|
||||
/* Mask Register */
|
||||
#define USBS_IDLE 0x01
|
||||
|
||||
/* RX Buffer Descriptor */
|
||||
#define RX_BD_OV 0x02
|
||||
#define RX_BD_CR 0x04
|
||||
#define RX_BD_AB 0x08
|
||||
#define RX_BD_NO 0x10
|
||||
#define RX_BD_PID_DATA0 0x00
|
||||
#define RX_BD_PID_DATA1 0x40
|
||||
#define RX_BD_PID_SETUP 0x80
|
||||
#define RX_BD_F 0x400
|
||||
#define RX_BD_L 0x800
|
||||
#define RX_BD_I 0x1000
|
||||
#define RX_BD_W 0x2000
|
||||
#define RX_BD_E 0x8000
|
||||
|
||||
/* Useful masks */
|
||||
#define RX_BD_PID_BITMASK (RX_BD_PID_DATA1 | RX_BD_PID_SETUP)
|
||||
#define STALL_BITMASK (USEP_THS_STALL | USEP_RHS_STALL)
|
||||
#define NAK_BITMASK (USEP_THS_NAK | USEP_RHS_NAK)
|
||||
#define CBD_TX_BITMASK (TX_BD_R | TX_BD_L | TX_BD_TC | TX_BD_I | TX_BD_CNF)
|
||||
|
||||
/* TX Buffer Descriptor */
|
||||
#define TX_BD_UN 0x02
|
||||
#define TX_BD_TO 0x04
|
||||
#define TX_BD_NO_PID 0x00
|
||||
#define TX_BD_PID_DATA0 0x80
|
||||
#define TX_BD_PID_DATA1 0xC0
|
||||
#define TX_BD_CNF 0x200
|
||||
#define TX_BD_TC 0x400
|
||||
#define TX_BD_L 0x800
|
||||
#define TX_BD_I 0x1000
|
||||
#define TX_BD_W 0x2000
|
||||
#define TX_BD_R 0x8000
|
||||
|
||||
/* Implementation specific defines */
|
||||
|
||||
#define EP_MIN_PACKET_SIZE 0x08
|
||||
#define MAX_ENDPOINTS 0x04
|
||||
#define FIFO_SIZE 0x10
|
||||
#define EP_MAX_PKT FIFO_SIZE
|
||||
#define TX_RING_SIZE 0x04
|
||||
#define RX_RING_SIZE 0x06
|
||||
#define USB_MAX_PKT 0x40
|
||||
#define TOGGLE_TX_PID(x) x= ((~x)&0x40)|0x80
|
||||
#define TOGGLE_RX_PID(x) x^= 0x40
|
||||
#define EP_ATTACHED 0x01 /* Endpoint has a urb attached or not */
|
||||
#define EP_SEND_ZLP 0x02 /* Send ZLP y/n ? */
|
||||
|
||||
#define PROFF_USB 0x00000000
|
||||
#define CPM_USB_BASE 0x00000A00
|
||||
|
||||
/* UDC device defines */
|
||||
#define EP0_MAX_PACKET_SIZE EP_MAX_PKT
|
||||
#define UDC_OUT_ENDPOINT 0x02
|
||||
#define UDC_OUT_PACKET_SIZE EP_MIN_PACKET_SIZE
|
||||
#define UDC_IN_ENDPOINT 0x03
|
||||
#define UDC_IN_PACKET_SIZE EP_MIN_PACKET_SIZE
|
||||
#define UDC_INT_ENDPOINT 0x01
|
||||
#define UDC_INT_PACKET_SIZE UDC_IN_PACKET_SIZE
|
||||
#define UDC_BULK_PACKET_SIZE EP_MIN_PACKET_SIZE
|
||||
|
||||
struct mpc8xx_ep {
|
||||
struct urb * urb;
|
||||
unsigned char pid;
|
||||
unsigned char sc;
|
||||
volatile cbd_t * prx;
|
||||
};
|
||||
|
||||
typedef struct mpc8xx_usb{
|
||||
char usmod; /* Mode Register */
|
||||
char usaddr; /* Slave Address Register */
|
||||
char uscom; /* Command Register */
|
||||
char res1; /* Reserved */
|
||||
ushort usep[4];
|
||||
ulong res2; /* Reserved */
|
||||
ushort usber; /* Event Register */
|
||||
ushort res3; /* Reserved */
|
||||
ushort usbmr; /* Mask Register */
|
||||
char res4; /* Reserved */
|
||||
char usbs; /* Status Register */
|
||||
char res5[8]; /* Reserved */
|
||||
}usb_t;
|
||||
|
||||
typedef struct mpc8xx_parameter_ram{
|
||||
ushort ep0ptr; /* Endpoint Pointer Register 0 */
|
||||
ushort ep1ptr; /* Endpoint Pointer Register 1 */
|
||||
ushort ep2ptr; /* Endpoint Pointer Register 2 */
|
||||
ushort ep3ptr; /* Endpoint Pointer Register 3 */
|
||||
uint rstate; /* Receive state */
|
||||
uint rptr; /* Receive internal data pointer */
|
||||
ushort frame_n; /* Frame number */
|
||||
ushort rbcnt; /* Receive byte count */
|
||||
uint rtemp; /* Receive temp cp use only */
|
||||
uint rxusb; /* Rx Data Temp */
|
||||
ushort rxuptr; /* Rx microcode return address temp */
|
||||
}usb_pram_t;
|
||||
|
||||
typedef struct endpoint_parameter_block_pointer{
|
||||
ushort rbase; /* RxBD base address */
|
||||
ushort tbase; /* TxBD base address */
|
||||
char rfcr; /* Rx Function code */
|
||||
char tfcr; /* Tx Function code */
|
||||
ushort mrblr; /* Maximum Receive Buffer Length */
|
||||
ushort rbptr; /* RxBD pointer Next Buffer Descriptor */
|
||||
ushort tbptr; /* TxBD pointer Next Buffer Descriptor */
|
||||
ulong tstate; /* Transmit internal state */
|
||||
ulong tptr; /* Transmit internal data pointer */
|
||||
ushort tcrc; /* Transmit temp CRC */
|
||||
ushort tbcnt; /* Transmit internal bye count */
|
||||
ulong ttemp; /* Tx temp */
|
||||
ushort txuptr; /* Tx microcode return address */
|
||||
ushort res1; /* Reserved */
|
||||
}usb_epb_t;
|
||||
|
||||
typedef enum mpc8xx_udc_state{
|
||||
STATE_NOT_READY,
|
||||
STATE_ERROR,
|
||||
STATE_READY,
|
||||
}mpc8xx_udc_state_t;
|
||||
|
||||
/* Declarations */
|
||||
int udc_init(void);
|
||||
void udc_irq(void);
|
||||
int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
|
||||
void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
|
||||
struct usb_endpoint_instance *endpoint);
|
||||
void udc_connect(void);
|
||||
void udc_disconnect(void);
|
||||
void udc_enable(struct usb_device_instance *device);
|
||||
void udc_disable(void);
|
||||
void udc_startup_events(struct usb_device_instance *device);
|
||||
|
||||
/* Flow control */
|
||||
void udc_set_nak(int epid);
|
||||
void udc_unset_nak (int epid);
|
@ -161,10 +161,20 @@
|
||||
#define UDC_VBUS_CTRL (1 << 19)
|
||||
#define UDC_VBUS_MODE (1 << 18)
|
||||
|
||||
/* OMAP Endpoint parameters */
|
||||
#define EP0_MAX_PACKET_SIZE 64
|
||||
#define UDC_OUT_ENDPOINT 2
|
||||
#define UDC_OUT_PACKET_SIZE 64
|
||||
#define UDC_IN_ENDPOINT 1
|
||||
#define UDC_IN_PACKET_SIZE 64
|
||||
#define UDC_INT_ENDPOINT 5
|
||||
#define UDC_INT_PKTSIZE 16
|
||||
#define UDC_BULK_PKTSIZE 16
|
||||
|
||||
void omap1510_udc_irq(void);
|
||||
void omap1510_udc_noniso_irq(void);
|
||||
|
||||
void udc_irq (void);
|
||||
/* Flow control */
|
||||
void udc_set_nak(int epid);
|
||||
void udc_unset_nak (int epid);
|
||||
|
||||
/* Higher level functions for abstracting away from specific device */
|
||||
void udc_endpoint_write(struct usb_endpoint_instance *endpoint);
|
||||
|
@ -92,33 +92,42 @@
|
||||
#define COMMUNICATIONS_DEVICE_CLASS 0x02
|
||||
|
||||
/* c.f. CDC 4.2 Table 15 */
|
||||
#define COMMUNICATIONS_INTERFACE_CLASS 0x02
|
||||
#define COMMUNICATIONS_INTERFACE_CLASS_CONTROL 0x02
|
||||
#define COMMUNICATIONS_INTERFACE_CLASS_DATA 0x0A
|
||||
#define COMMUNICATIONS_INTERFACE_CLASS_VENDOR 0x0FF
|
||||
|
||||
/* c.f. CDC 4.3 Table 16 */
|
||||
#define COMMUNICATIONS_NO_SUBCLASS 0x00
|
||||
#define COMMUNICATIONS_NO_SUBCLASS 0x00
|
||||
#define COMMUNICATIONS_DLCM_SUBCLASS 0x01
|
||||
#define COMMUNICATIONS_ACM_SUBCLASS 0x02
|
||||
#define COMMUNICATIONS_TCM_SUBCLASS 0x03
|
||||
#define COMMUNICATIONS_ACM_SUBCLASS 0x02
|
||||
#define COMMUNICATIONS_TCM_SUBCLASS 0x03
|
||||
#define COMMUNICATIONS_MCCM_SUBCLASS 0x04
|
||||
#define COMMUNICATIONS_CCM_SUBCLASS 0x05
|
||||
#define COMMUNICATIONS_CCM_SUBCLASS 0x05
|
||||
#define COMMUNICATIONS_ENCM_SUBCLASS 0x06
|
||||
#define COMMUNICATIONS_ANCM_SUBCLASS 0x07
|
||||
|
||||
/* c.f. WMCD 5.1 */
|
||||
#define COMMUNICATIONS_WHCM_SUBCLASS 0x08
|
||||
#define COMMUNICATIONS_DMM_SUBCLASS 0x09
|
||||
#define COMMUNICATIONS_DMM_SUBCLASS 0x09
|
||||
#define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
|
||||
#define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
|
||||
|
||||
/* c.f. CDC 4.6 Table 18 */
|
||||
/* c.f. CDC 4.4 Table 17 */
|
||||
#define COMMUNICATIONS_NO_PROTOCOL 0x00
|
||||
#define COMMUNICATIONS_V25TER_PROTOCOL 0x01 /*Common AT Hayes compatible*/
|
||||
|
||||
/* c.f. CDC 4.5 Table 18 */
|
||||
#define DATA_INTERFACE_CLASS 0x0a
|
||||
|
||||
/* c.f. CDC 4.6 No Table */
|
||||
#define DATA_INTERFACE_SUBCLASS_NONE 0x00 /* No subclass pertinent */
|
||||
|
||||
/* c.f. CDC 4.7 Table 19 */
|
||||
#define COMMUNICATIONS_NO_PROTOCOL 0x00
|
||||
#define DATA_INTERFACE_PROTOCOL_NONE 0x00 /* No class protcol required */
|
||||
|
||||
|
||||
/* c.f. CDC 5.2.3 Table 24 */
|
||||
#define CS_INTERFACE 0x24
|
||||
#define CS_INTERFACE 0x24
|
||||
#define CS_ENDPOINT 0x25
|
||||
|
||||
/*
|
||||
@ -128,7 +137,7 @@
|
||||
* c.f. WMCD 5.3 Table 5.3
|
||||
*/
|
||||
|
||||
#define USB_ST_HEADER 0x00
|
||||
#define USB_ST_HEADER 0x00
|
||||
#define USB_ST_CMF 0x01
|
||||
#define USB_ST_ACMF 0x02
|
||||
#define USB_ST_DLMF 0x03
|
||||
@ -137,18 +146,18 @@
|
||||
#define USB_ST_UF 0x06
|
||||
#define USB_ST_CSF 0x07
|
||||
#define USB_ST_TOMF 0x08
|
||||
#define USB_ST_USBTF 0x09
|
||||
#define USB_ST_USBTF 0x09
|
||||
#define USB_ST_NCT 0x0a
|
||||
#define USB_ST_PUF 0x0b
|
||||
#define USB_ST_EUF 0x0c
|
||||
#define USB_ST_MCMF 0x0d
|
||||
#define USB_ST_CCMF 0x0e
|
||||
#define USB_ST_ENF 0x0f
|
||||
#define USB_ST_ATMNF 0x10
|
||||
#define USB_ST_ATMNF 0x10
|
||||
|
||||
#define USB_ST_WHCM 0x11
|
||||
#define USB_ST_MDLM 0x12
|
||||
#define USB_ST_MDLMD 0x13
|
||||
#define USB_ST_MDLMD 0x13
|
||||
#define USB_ST_DMM 0x14
|
||||
#define USB_ST_OBEX 0x15
|
||||
#define USB_ST_CS 0x16
|
||||
@ -312,7 +321,8 @@ struct usb_class_union_function_descriptor {
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubtype; /* 0x06 */
|
||||
u8 bMasterInterface;
|
||||
u8 bSlaveInterface0[0];
|
||||
/* u8 bSlaveInterface0[0]; */
|
||||
u8 bSlaveInterface0;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct usb_class_country_selection_descriptor {
|
||||
|
Loading…
Reference in New Issue
Block a user