1 From 09071b501014528984b158bc5408d8a738ef6883 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 11 Mar 2012 15:59:39 +0100
4 Subject: [PATCH 50/70] MIPS: adds ifxhcd
7 arch/mips/lantiq/xway/Makefile | 2 +-
8 arch/mips/lantiq/xway/dev-ifxhcd.c | 45 +
9 arch/mips/lantiq/xway/dev-ifxhcd.h | 17 +
10 arch/mips/lantiq/xway/sysctrl.c | 2 +
11 drivers/usb/Kconfig | 2 +
12 drivers/usb/Makefile | 2 +
13 drivers/usb/ifxhcd/Kconfig | 58 +
14 drivers/usb/ifxhcd/Makefile | 85 +
15 drivers/usb/ifxhcd/TagHistory | 171 ++
16 drivers/usb/ifxhcd/ifxhcd.c | 2523 +++++++++++++++++++++++
17 drivers/usb/ifxhcd/ifxhcd.h | 628 ++++++
18 drivers/usb/ifxhcd/ifxhcd_es.c | 549 +++++
19 drivers/usb/ifxhcd/ifxhcd_intr.c | 3742 +++++++++++++++++++++++++++++++++++
20 drivers/usb/ifxhcd/ifxhcd_queue.c | 418 ++++
21 drivers/usb/ifxhcd/ifxusb_cif.c | 1458 ++++++++++++++
22 drivers/usb/ifxhcd/ifxusb_cif.h | 665 +++++++
23 drivers/usb/ifxhcd/ifxusb_cif_d.c | 458 +++++
24 drivers/usb/ifxhcd/ifxusb_cif_h.c | 846 ++++++++
25 drivers/usb/ifxhcd/ifxusb_ctl.c | 1385 +++++++++++++
26 drivers/usb/ifxhcd/ifxusb_driver.c | 970 +++++++++
27 drivers/usb/ifxhcd/ifxusb_plat.h | 1018 ++++++++++
28 drivers/usb/ifxhcd/ifxusb_regs.h | 1420 +++++++++++++
29 drivers/usb/ifxhcd/ifxusb_version.h | 5 +
30 23 files changed, 16468 insertions(+), 1 deletions(-)
31 create mode 100644 arch/mips/lantiq/xway/dev-ifxhcd.c
32 create mode 100644 arch/mips/lantiq/xway/dev-ifxhcd.h
33 create mode 100644 drivers/usb/ifxhcd/Kconfig
34 create mode 100644 drivers/usb/ifxhcd/Makefile
35 create mode 100644 drivers/usb/ifxhcd/TagHistory
36 create mode 100644 drivers/usb/ifxhcd/ifxhcd.c
37 create mode 100644 drivers/usb/ifxhcd/ifxhcd.h
38 create mode 100644 drivers/usb/ifxhcd/ifxhcd_es.c
39 create mode 100644 drivers/usb/ifxhcd/ifxhcd_intr.c
40 create mode 100644 drivers/usb/ifxhcd/ifxhcd_queue.c
41 create mode 100644 drivers/usb/ifxhcd/ifxusb_cif.c
42 create mode 100644 drivers/usb/ifxhcd/ifxusb_cif.h
43 create mode 100644 drivers/usb/ifxhcd/ifxusb_cif_d.c
44 create mode 100644 drivers/usb/ifxhcd/ifxusb_cif_h.c
45 create mode 100644 drivers/usb/ifxhcd/ifxusb_ctl.c
46 create mode 100644 drivers/usb/ifxhcd/ifxusb_driver.c
47 create mode 100644 drivers/usb/ifxhcd/ifxusb_plat.h
48 create mode 100644 drivers/usb/ifxhcd/ifxusb_regs.h
49 create mode 100644 drivers/usb/ifxhcd/ifxusb_version.h
51 --- a/arch/mips/lantiq/xway/Makefile
52 +++ b/arch/mips/lantiq/xway/Makefile
54 -obj-y := sysctrl.o reset.o gpio.o gpio_stp.o gpio_ebu.o devices.o dma.o clk.o prom.o nand.o timer.o
55 +obj-y := sysctrl.o reset.o gpio.o gpio_stp.o gpio_ebu.o devices.o dma.o clk.o prom.o nand.o timer.o dev-ifxhcd.o
57 obj-$(CONFIG_LANTIQ_MACH_EASY50712) += mach-easy50712.o
58 obj-$(CONFIG_LANTIQ_MACH_EASY50601) += mach-easy50601.o
60 +++ b/arch/mips/lantiq/xway/dev-ifxhcd.c
63 + * This program is free software; you can redistribute it and/or modify
64 + * it under the terms of the GNU General Public License as published by
65 + * the Free Software Foundation; either version 2 of the License, or
66 + * (at your option) any later version.
68 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
71 +#include <linux/init.h>
72 +#include <linux/module.h>
73 +#include <linux/types.h>
74 +#include <linux/string.h>
75 +#include <linux/mtd/physmap.h>
76 +#include <linux/kernel.h>
77 +#include <linux/reboot.h>
78 +#include <linux/platform_device.h>
79 +#include <linux/leds.h>
80 +#include <linux/etherdevice.h>
81 +#include <linux/reboot.h>
82 +#include <linux/time.h>
83 +#include <linux/io.h>
84 +#include <linux/gpio.h>
85 +#include <linux/leds.h>
87 +#include <asm/bootinfo.h>
90 +#include <lantiq_soc.h>
91 +#include <lantiq_irq.h>
92 +#include <lantiq_platform.h>
94 +static u64 dmamask = (u32)0x1fffffff;
96 +static struct platform_device platform_dev = {
97 + .name = "ifxusb_hcd",
98 + .dev.dma_mask = &dmamask,
102 +xway_register_hcd(int *pins)
104 + platform_dev.dev.platform_data = pins;
105 + return platform_device_register(&platform_dev);
108 +++ b/arch/mips/lantiq/xway/dev-ifxhcd.h
111 + * This program is free software; you can redistribute it and/or modify
112 + * it under the terms of the GNU General Public License as published by
113 + * the Free Software Foundation; either version 2 of the License, or
114 + * (at your option) any later version.
116 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
119 +#ifndef _LTQ_DEV_HCD_H__
120 +#define _LTQ_DEV_HCD_H__
122 +#include <lantiq_platform.h>
124 +extern void __init xway_register_hcd(int *pin);
127 --- a/arch/mips/lantiq/xway/sysctrl.c
128 +++ b/arch/mips/lantiq/xway/sysctrl.c
129 @@ -166,6 +166,8 @@ void __init ltq_soc_init(void)
130 clkdev_add_pmu("ltq_pcie", "pdi", 1, PMU1_PCIE_PDI);
131 clkdev_add_pmu("ltq_pcie", "ctl", 1, PMU1_PCIE_CTL);
132 clkdev_add_pmu("ltq_pcie", "ahb", 0, PMU_AHBM | PMU_AHBS);
133 + clkdev_add_pmu("usb0", NULL, 0, (1<<6) | 1);
134 + clkdev_add_pmu("usb1", NULL, 0, (1<<26) | (1<<27));
136 clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(),
137 ltq_danube_io_region_clock());
138 --- a/drivers/usb/Kconfig
139 +++ b/drivers/usb/Kconfig
140 @@ -183,4 +183,6 @@ source "drivers/usb/gadget/Kconfig"
142 source "drivers/usb/otg/Kconfig"
144 +source "drivers/usb/ifxhcd/Kconfig"
147 --- a/drivers/usb/Makefile
148 +++ b/drivers/usb/Makefile
149 @@ -57,3 +57,5 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg/
150 obj-$(CONFIG_USB_GADGET) += gadget/
152 obj-$(CONFIG_USB_COMMON) += usb-common.o
154 +obj-$(CONFIG_USB_HOST_IFX) += ifxhcd/
156 +++ b/drivers/usb/ifxhcd/Kconfig
160 + tristate "Infineon USB Host Controller Driver"
164 + Infineon USB Host Controller
166 +config USB_HOST_IFX_B
167 + bool "USB host mode on core 1 and 2"
168 + depends on USB_HOST_IFX
170 + Both cores run as host
172 +#config USB_HOST_IFX_1
173 +#config USB_HOST_IFX_2
176 +#config IFX_AMAZON_SE
178 + depends on USB_HOST_IFX
182 + depends on USB_HOST_IFX
185 +#config USB_HOST_IFX_FORCE_USB11
186 +# bool "Forced USB1.1"
187 +# depends on USB_HOST_IFX
190 +# force to be USB 1.1
192 +#config USB_HOST_IFX_WITH_HS_ELECT_TST
193 +# bool "With HS_Electrical Test"
194 +# depends on USB_HOST_IFX
197 +# With USBIF HSET routines
199 +#config USB_HOST_IFX_WITH_ISO
200 +# bool "With ISO transfer"
201 +# depends on USB_HOST_IFX
204 +# With USBIF ISO transfer
206 +config USB_HOST_IFX_UNALIGNED_ADJ
208 + depends on USB_HOST_IFX
210 + USB_HOST_IFX_UNALIGNED_ADJ
212 +#config USB_HOST_IFX_UNALIGNED_CHK
213 +#config USB_HOST_IFX_UNALIGNED_NONE
217 +++ b/drivers/usb/ifxhcd/Makefile
221 +# Makefile for USB Core files and filesystem
223 + ifxusb_host-objs := ifxusb_driver.o
224 + ifxusb_host-objs += ifxusb_ctl.o
225 + ifxusb_host-objs += ifxusb_cif.o
226 + ifxusb_host-objs += ifxusb_cif_h.o
227 + ifxusb_host-objs += ifxhcd.o
228 + ifxusb_host-objs += ifxhcd_es.o
229 + ifxusb_host-objs += ifxhcd_intr.o
230 + ifxusb_host-objs += ifxhcd_queue.o
232 +ifeq ($(CONFIG_IFX_TWINPASS),y)
233 + EXTRA_CFLAGS += -D__IS_TWINPASS__
235 +ifeq ($(CONFIG_IFX_DANUBE),y)
236 + EXTRA_CFLAGS += -D__IS_DANUBE__
238 +ifeq ($(CONFIG_IFX_AMAZON_SE),y)
239 + EXTRA_CFLAGS += -D__IS_AMAZON_SE__
241 +ifeq ($(CONFIG_IFX_AR9),y)
242 + EXTRA_CFLAGS += -D__IS_AR9__
244 +ifeq ($(CONFIG_IFX_AMAZON_S),y)
245 + EXTRA_CFLAGS += -D__IS_AR9__
247 +ifeq ($(CONFIG_IFX_VR9),y)
248 + EXTRA_CFLAGS += -D__IS_VR9__
251 +ifeq ($(CONFIG_USB_HOST_IFX),y)
252 + EXTRA_CFLAGS += -Dlinux -D__LINUX__
253 + EXTRA_CFLAGS += -D__IS_HOST__
254 + EXTRA_CFLAGS += -D__KERNEL__
257 +ifeq ($(CONFIG_USB_HOST_IFX),m)
258 + EXTRA_CFLAGS += -Dlinux -D__LINUX__
259 + EXTRA_CFLAGS += -D__IS_HOST__
260 + EXTRA_CFLAGS += -D__KERNEL__
263 +ifeq ($(CONFIG_USB_DEBUG),y)
264 + EXTRA_CFLAGS += -D__DEBUG__
265 + EXTRA_CFLAGS += -D__ENABLE_DUMP__
268 +ifeq ($(CONFIG_USB_HOST_IFX_B),y)
269 + EXTRA_CFLAGS += -D__IS_DUAL__
271 +ifeq ($(CONFIG_USB_HOST_IFX_1),y)
272 + EXTRA_CFLAGS += -D__IS_FIRST__
274 +ifeq ($(CONFIG_USB_HOST_IFX_2),y)
275 + EXTRA_CFLAGS += -D__IS_SECOND__
278 +ifeq ($(CONFIG_USB_HOST_IFX_FORCE_USB11),y)
279 + EXTRA_CFLAGS += -D__FORCE_USB11__
281 +ifeq ($(CONFIG_USB_HOST_IFX_WITH_HS_ELECT_TST),y)
282 + EXTRA_CFLAGS += -D__WITH_HS_ELECT_TST__
284 +ifeq ($(CONFIG_USB_HOST_IFX_WITH_ISO),y)
285 + EXTRA_CFLAGS += -D__EN_ISOC__
287 +ifeq ($(CONFIG_USB_HOST_IFX_UNALIGNED_ADJ),y)
288 + EXTRA_CFLAGS += -D__UNALIGNED_BUFFER_ADJ__
290 +ifeq ($(CONFIG_USB_HOST_IFX_UNALIGNED_CHK),y)
291 + EXTRA_CFLAGS += -D__UNALIGNED_BUFFER_CHK__
294 +# EXTRA_CFLAGS += -D__DYN_SOF_INTR__
295 + EXTRA_CFLAGS += -D__UEIP__
296 +# EXTRA_CFLAGS += -D__EN_ISOC__
297 +# EXTRA_CFLAGS += -D__EN_ISOC_SPLIT__
299 +## 20110628 AVM/WK New flag for less SOF IRQs
300 + EXTRA_CFLAGS += -D__USE_TIMER_4_SOF__
302 +obj-$(CONFIG_USB_HOST_IFX) += ifxusb_host.o
305 +++ b/drivers/usb/ifxhcd/TagHistory
309 ++----------------------------------------------------------------------+
310 +| TAG: svn://embeddedvm/home/SVN/drivers/usb_host20/tags/5.18-r240-non_musb_ar9_vr9-SOF_Timer_Fixed
311 +| Erzeugt mit SVN-Tagger Version 3.74.
312 ++----------------------------------------------------------------------+
313 +FIX - Korrektur bei der SOF-Timer/IRQ Steuerung. (Bug in Tag 5.17)
314 +FIX - Fehlerbehandlung an mehreren Stellen korrigiert bzw. eingebaut.
318 ++----------------------------------------------------------------------+
319 +| TAG: svn://embeddedvm/home/SVN/drivers/usb_host20/tags/5.17-r237-non_musb_ar9_vr9-2_6_32_41_Kompatibel
320 +| Erzeugt mit SVN-Tagger Version 3.73.
321 ++----------------------------------------------------------------------+
322 +FIX - Kompatiblität zum Update auf Kernel 2.6.32-41. Weiterhin für 28er geeignet.
323 +ENH - Reduktion der Interrruptlast durch Nutzung eines hrtimers anstatt SOF-IRQ.
327 ++----------------------------------------------------------------------+
328 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.16-r208-non_musb_ar9_vr9-20110421_Zero_Paket_Optimiert
329 +| Erzeugt mit SVN-Tagger Version 3.66.
330 ++----------------------------------------------------------------------+
332 +FIX - VR9 / AR9 - Zero Packet. Optimierung korrigiert.
336 ++----------------------------------------------------------------------+
337 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.15-r205-non_musb_ar9_vr9-20110421_Zero_Paket_WA_funktioniert
338 +| Erzeugt mit SVN-Tagger Version 3.66.
339 ++----------------------------------------------------------------------+
341 +FIX - VR9 / AR9 - "Zero Packet" funktioniert nun wirklich. Letzter Tag hatte einen Bug.
345 ++----------------------------------------------------------------------+
346 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.14-r202-non_musb_ar9_vr9-20110420_Zero_Paket_WA
347 +| Erzeugt mit SVN-Tagger Version 3.66.
348 ++----------------------------------------------------------------------+
350 +FIX - VR9 / AR9 - Zero Packet Workaround: ZLP wird nun geschickt wenn URB_ZERO_PACKET aktiv ist.
351 + Wird von LTE Altair Firmware benoetig.
355 ++----------------------------------------------------------------------+
356 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.13-r199-non_musb_ar9_vr9-20110310_Init_Fix
357 +| Erzeugt mit SVN-Tagger Version 3.64.
358 ++----------------------------------------------------------------------+
360 +FIX - VR9 / AR9 - Timing der Initialisierungsphase angepasst zum Kernel 2.6.28 mit UGW-4.3.1.
364 ++----------------------------------------------------------------------+
365 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.12-r184-non_musb_ar9_vr9-20110118_Full_Speed_Fix
366 +| Erzeugt mit SVN-Tagger Version 3.58.
367 ++----------------------------------------------------------------------+
368 +AR9/VR9 (3370,6840,7320):
369 +Makefile - FIX - (Workaround) Debug Modus hilft gegen Enumerationsfehler bei Full Speed Drucker.
373 ++----------------------------------------------------------------------+
374 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.11-r175-non_musb_ar9_vr9-20101220_VR9_2_Ports_DMA_Fix
375 +| Erzeugt mit SVN-Tagger Version 3.58.
376 ++----------------------------------------------------------------------+
378 +FIX - VR9 - Workaround DMA Burst Size. Wenn beiden USB Ports benutzt werden, geht der USB Host nicht mehr.
382 ++----------------------------------------------------------------------+
383 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.10-r169-non_musb_ar9_vr9-Fix_Spontan_Reboot
384 +| Erzeugt mit SVN-Tagger Version 3.58.
385 ++----------------------------------------------------------------------+
387 +FIX - Endlosschleife führte zu einem spontanen Reboot.
391 ++----------------------------------------------------------------------+
392 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.9-r166-non_musb_ar9_vr9-20101112_deferred_completion
393 +| Erzeugt mit SVN-Tagger Version 3.58.
394 ++----------------------------------------------------------------------+
396 +ENH - Deferred URB Completion Mechanismus eingebaut. Nun ca. 10% schneller bei usb-storage.
398 +FIX - PING Flow Control gefixt.
399 +FIX - Channel Halt wird nun immer angerufen. (Split Transaction wurde nicht erfolgreich gestoppt).
400 +FIX - Spinlock Benutzung verbessert. Mehr Stabilitaet.
402 +CHG - Ubersetztungsoption __DEBUG__ ist nun abhaengig von CONFIG_USB_DEBUG
406 ++----------------------------------------------------------------------+
407 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.8-r149-non_musb_ar9_vr9-20100827_LTE_Interrupt_EP_Fix
408 +| Erzeugt mit SVN-Tagger Version 3.57.
409 ++----------------------------------------------------------------------+
410 +AR9/VR9 - FIX - Interrupt Packets gingen verloren, wegen falschem Timing beim OddFrame Bit.
414 ++----------------------------------------------------------------------+
415 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.7-r142-non_musb_ar9_vr9-20100728_Unaligned_Buf_Fix
416 +| Erzeugt mit SVN-Tagger Version 3.57.
417 ++----------------------------------------------------------------------+
418 +FIX - "Unaligned Data" Flag wieder nach Transfer geloescht.
422 ++----------------------------------------------------------------------+
423 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.6-r133-non_musb_ar9_vr9-20100714_Toggle_Datenverlust_Fix
424 +| Erzeugt mit SVN-Tagger Version 3.57.
425 ++----------------------------------------------------------------------+
426 +TL5508 - Einige UMTS Modems funktionierten nicht korrekt an der 7320 (AR9).
427 +FIX - USB Data Toggle des usbcore benutzen. Datenverlust nach EP-Halt.
431 ++----------------------------------------------------------------------+
432 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.5-r130-non_musb_ar9_vr9-20100712_USB_Ports_abschaltbar
433 +| Erzeugt mit SVN-Tagger Version 3.57.
434 ++----------------------------------------------------------------------+
435 +Power - Fix - Beide USB Port abschaltbar bei rmmod.
436 +rmmod - FIX - URB_Dequeue funktionierte beim Entladen des Treibers nicht (mehrere Ursachen).
440 ++----------------------------------------------------------------------+
441 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.4-r126-non_musb_ar9_vr9-20100701_Lost_Interrupt_Workaround
442 +| Erzeugt mit SVN-Tagger Version 3.57.
443 ++----------------------------------------------------------------------+
444 +FIX - Workaround wegen verpasstem Interrupt, bei Full-Speed Interrupt EP.
447 ++----------------------------------------------------------------------+
448 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.3-r123-non_musb_ar9_vr9-20100630_UMTS_Fixes
449 +| Erzeugt mit SVN-Tagger Version 3.57.
450 ++----------------------------------------------------------------------+
451 +FIX - Full-Speed Interrupt Endpoint hinter Hi-Speed Hub funktioniert nun (UMTS Modems)
452 +FIX - usb_hcd_link_urb_from_ep API von USBCore muss benutzt werden.
453 +FIX - Interrupt URBs nicht bei NAK completen.
456 ++----------------------------------------------------------------------+
457 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.2-r114-non_musb_ar9_vr9-20100520_StickAndSurf_funktioniert
458 +| Erzeugt mit SVN-Tagger Version 3.56.
459 ++----------------------------------------------------------------------+
460 +- Merge mit neuen LANTIQ Sourcen "3.0alpha B100312"
461 +- Fix - Spin_lock eingebaut, Stick&Surf funktioniert nun
463 +- DEP - CONFIG_USB_HOST_IFX_WITH_ISO wird nicht unterstuetzt: In der Kernel Config deaktivieren.
467 ++----------------------------------------------------------------------+
468 +| TAG: svn://EmbeddedVM/home/SVN/drivers/usb_host20/tags/5.1-r107-non_musb_ar9_vr9-20100505_IFXUSB_Host_mit_Energiemonitor
469 +| Erzeugt mit SVN-Tagger Version 3.56.
470 ++----------------------------------------------------------------------+
471 +USB Host Treiber für AR9 und VR9
472 +--------------------------------
473 +FIX - Toggle Error nach STALL - Einfacher Workaround - Nun werden Massenspeicherpartitionen erkannt!
474 +AVM_POWERMETER - USB Energiemonitor Support.
476 +Bekanntes Problem: Stick and Surf funktioniert nur sporadisch, weil CONTROL_IRQ manchmal ausbleibt.
479 +++ b/drivers/usb/ifxhcd/ifxhcd.c
481 +/*****************************************************************************
482 + ** FILE NAME : ifxhcd.c
483 + ** PROJECT : IFX USB sub-system V3
484 + ** MODULES : IFX USB sub-system Host and Device driver
485 + ** SRC VERSION : 1.0
486 + ** DATE : 1/Jan/2009
487 + ** AUTHOR : Chen, Howard
488 + ** DESCRIPTION : This file contains the structures, constants, and interfaces for
489 + ** the Host Contoller Driver (HCD).
491 + ** The Host Controller Driver (HCD) is responsible for translating requests
492 + ** from the USB Driver into the appropriate actions on the IFXUSB controller.
493 + ** It isolates the USBD from the specifics of the controller by providing an
494 + ** API to the USBD.
495 + *****************************************************************************/
499 + \ingroup IFXUSB_DRIVER_V3
500 + \brief This file contains the implementation of the HCD. In Linux,
501 + the HCD implements the hc_driver API.
504 +#include <linux/version.h>
505 +#include "ifxusb_version.h"
507 +#include <linux/kernel.h>
508 +#include <linux/module.h>
509 +#include <linux/moduleparam.h>
510 +#include <linux/init.h>
512 +#include <linux/device.h>
514 +#include <linux/errno.h>
515 +#include <linux/list.h>
516 +#include <linux/interrupt.h>
517 +#include <linux/string.h>
519 +#include <linux/dma-mapping.h>
522 +#include "ifxusb_plat.h"
523 +#include "ifxusb_regs.h"
524 +#include "ifxusb_cif.h"
527 +#include <asm/irq.h>
529 +#ifdef CONFIG_AVM_POWERMETER
530 +#include <linux/avm_power.h>
531 +#endif /*--- #ifdef CONFIG_AVM_POWERMETER ---*/
534 + static void dump_urb_info(struct urb *_urb, char* _fn_name);
535 + static void dump_channel_info(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh);
540 + \brief Sets the final status of an URB and returns it to the device driver. Any
541 + required cleanup of the URB is performed.
543 +void ifxhcd_complete_urb(ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status)
545 + struct urb *urb=NULL;
546 + unsigned long flags = 0;
548 + /*== AVM/BC 20101111 Function called with Lock ==*/
549 + //SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
551 + if (!list_empty(&_urbd->urbd_list_entry))
552 + list_del_init (&_urbd->urbd_list_entry);
556 + IFX_ERROR("%s: invalid urb\n",__func__);
557 + /*== AVM/BC 20101111 Function called with Lock ==*/
558 + //SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
565 + if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
567 + IFX_PRINT("%s: _urbd %p, urb %p, device %d, ep %d %s/%s, status=%d\n",
568 + __func__, _urbd,_urbd->urb, usb_pipedevice(_urbd->urb->pipe),
569 + usb_pipeendpoint(_urbd->urb->pipe),
570 + usb_pipein(_urbd->urb->pipe) ? "IN" : "OUT",
571 + (_urbd->is_in) ? "IN" : "OUT",
573 + if (_urbd->epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
576 + for (i = 0; i < _urbd->urb->number_of_packets; i++)
577 + IFX_PRINT(" ISO Desc %d status: %d\n", i, _urbd->urb->iso_frame_desc[i].status);
583 + IFX_ERROR("%s: invalid epqd\n",__func__);
585 + #if defined(__UNALIGNED_BUFFER_ADJ__)
586 + else if(_urbd->is_active)
588 + if( _urbd->epqh->aligned_checked &&
589 + _urbd->epqh->using_aligned_buf &&
590 + _urbd->xfer_buff &&
592 + memcpy(_urbd->xfer_buff,_urbd->epqh->aligned_buf,_urbd->xfer_len);
593 + _urbd->epqh->using_aligned_buf=0;
594 + _urbd->epqh->using_aligned_setup=0;
595 + _urbd->epqh->aligned_checked=0;
599 + urb->status = _status;
603 + usb_hcd_unlink_urb_from_ep(ifxhcd_to_syshcd(_ifxhcd), urb);
604 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
606 +// usb_hcd_giveback_urb(ifxhcd_to_syshcd(_ifxhcd), urb);
607 + usb_hcd_giveback_urb(ifxhcd_to_syshcd(_ifxhcd), urb, _status);
609 + /*== AVM/BC 20100630 - 2.6.28 needs HCD link/unlink URBs ==*/
610 + SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
613 +/*== AVM/BC 20101111 URB Complete deferred
614 + * Must be called with Spinlock
618 + \brief Inserts an urbd structur in the completion list. The urbd will be
619 + later completed by select_eps_sub
621 +void defer_ifxhcd_complete_urb(ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status)
624 + _urbd->status = _status;
626 + //Unlink Urbd from epqh / Insert it into the complete list
627 + list_move_tail(&_urbd->urbd_list_entry, &_ifxhcd->urbd_complete_list);
632 + \brief Processes all the URBs in a single EPQHs. Completes them with
633 + status and frees the URBD.
636 +void kill_all_urbs_in_epqh(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh, int _status)
638 + struct list_head *urbd_item;
639 + ifxhcd_urbd_t *urbd;
644 + for (urbd_item = _epqh->urbd_list.next;
645 + urbd_item != &_epqh->urbd_list;
646 + urbd_item = _epqh->urbd_list.next)
648 + urbd = list_entry(urbd_item, ifxhcd_urbd_t, urbd_list_entry);
649 + ifxhcd_complete_urb(_ifxhcd, urbd, _status);
655 + \brief Free all EPS in one Processes all the URBs in a single list of EPQHs. Completes them with
656 + -ETIMEDOUT and frees the URBD.
659 +void epqh_list_free(ifxhcd_hcd_t *_ifxhcd, struct list_head *_epqh_list)
661 + struct list_head *item;
662 + ifxhcd_epqh_t *epqh;
666 + if (_epqh_list->next == NULL) /* The list hasn't been initialized yet. */
669 + /* Ensure there are no URBDs or URBs left. */
670 + for (item = _epqh_list->next; item != _epqh_list; item = _epqh_list->next)
672 + epqh = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
673 + kill_all_urbs_in_epqh(_ifxhcd, epqh, -ETIMEDOUT);
674 + ifxhcd_epqh_free(epqh);
681 +void epqh_list_free_all(ifxhcd_hcd_t *_ifxhcd)
683 + unsigned long flags;
685 + /*== AVM/BC 20101111 - 2.6.28 Needs Spinlock ==*/
686 + SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
688 + epqh_list_free(_ifxhcd, &_ifxhcd->epqh_np_active );
689 + epqh_list_free(_ifxhcd, &_ifxhcd->epqh_np_ready );
690 + epqh_list_free(_ifxhcd, &_ifxhcd->epqh_intr_active );
691 + epqh_list_free(_ifxhcd, &_ifxhcd->epqh_intr_ready );
693 + epqh_list_free(_ifxhcd, &_ifxhcd->epqh_isoc_active );
694 + epqh_list_free(_ifxhcd, &_ifxhcd->epqh_isoc_ready );
696 + epqh_list_free(_ifxhcd, &_ifxhcd->epqh_stdby );
698 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
704 + \brief This function is called to handle the disconnection of host port.
706 +int32_t ifxhcd_disconnect(ifxhcd_hcd_t *_ifxhcd)
708 + IFX_DEBUGPL(DBG_HCDV, "%s(%p)\n", __func__, _ifxhcd);
710 + /* Set status flags for the hub driver. */
711 + _ifxhcd->flags.b.port_connect_status_change = 1;
712 + _ifxhcd->flags.b.port_connect_status = 0;
715 + * Shutdown any transfers in process by clearing the Tx FIFO Empty
716 + * interrupt mask and status bits and disabling subsequent host
717 + * channel interrupts.
720 + gint_data_t intr = { .d32 = 0 };
721 + intr.b.nptxfempty = 1;
722 + intr.b.ptxfempty = 1;
724 + ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gintmsk, intr.d32, 0);
725 + ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gintsts, intr.d32, 0);
728 + /* Respond with an error status to all URBs in the schedule. */
729 + epqh_list_free_all(_ifxhcd);
731 + /* Clean up any host channels that were in use. */
734 + ifxhcd_hc_t *channel;
735 + ifxusb_hc_regs_t *hc_regs;
736 + hcchar_data_t hcchar;
739 + num_channels = _ifxhcd->core_if.params.host_channels;
741 + for (i = 0; i < num_channels; i++)
743 + channel = &_ifxhcd->ifxhc[i];
744 + if (list_empty(&channel->hc_list_entry))
746 + hc_regs = _ifxhcd->core_if.hc_regs[i];
747 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
750 + /* Halt the channel. */
751 + hcchar.b.chdis = 1;
752 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
754 + list_add_tail(&channel->hc_list_entry, &_ifxhcd->free_hc_list);
755 + ifxhcd_hc_cleanup(&_ifxhcd->core_if, channel);
764 + \brief Frees secondary storage associated with the ifxhcd_hcd structure contained
765 + in the struct usb_hcd field.
767 +static void ifxhcd_freeextra(struct usb_hcd *_syshcd)
769 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
771 + IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD FREE\n");
773 + /* Free memory for EPQH/URBD lists */
774 + epqh_list_free_all(ifxhcd);
776 + /* Free memory for the host channels. */
777 + ifxusb_free_buf(ifxhcd->status_buf);
780 +#ifdef __USE_TIMER_4_SOF__
781 +static enum hrtimer_restart ifxhcd_timer_func(struct hrtimer *timer) {
782 + ifxhcd_hcd_t *ifxhcd = container_of(timer, ifxhcd_hcd_t, hr_timer);
784 + ifxhcd_handle_intr(ifxhcd);
786 + return HRTIMER_NORESTART;
791 + \brief Initializes the HCD. This function allocates memory for and initializes the
792 + static parts of the usb_hcd and ifxhcd_hcd structures. It also registers the
793 + USB bus with the core and calls the hc_driver->start() function. It returns
794 + a negative error on failure.
796 +int ifxhcd_init(ifxhcd_hcd_t *_ifxhcd)
799 + struct usb_hcd *syshcd = NULL;
801 + IFX_DEBUGPL(DBG_HCD, "IFX USB HCD INIT\n");
803 + spin_lock_init(&_ifxhcd->lock);
804 +#ifdef __USE_TIMER_4_SOF__
805 + hrtimer_init(&_ifxhcd->hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
806 + _ifxhcd->hr_timer.function = ifxhcd_timer_func;
808 + _ifxhcd->hc_driver.description = _ifxhcd->core_if.core_name;
809 + _ifxhcd->hc_driver.product_desc = "IFX USB Controller";
810 + //_ifxhcd->hc_driver.hcd_priv_size = sizeof(ifxhcd_hcd_t);
811 + _ifxhcd->hc_driver.hcd_priv_size = sizeof(unsigned long);
812 + _ifxhcd->hc_driver.irq = ifxhcd_irq;
813 + _ifxhcd->hc_driver.flags = HCD_MEMORY | HCD_USB2;
814 + _ifxhcd->hc_driver.start = ifxhcd_start;
815 + _ifxhcd->hc_driver.stop = ifxhcd_stop;
816 + //_ifxhcd->hc_driver.reset =
817 + //_ifxhcd->hc_driver.suspend =
818 + //_ifxhcd->hc_driver.resume =
819 + _ifxhcd->hc_driver.urb_enqueue = ifxhcd_urb_enqueue;
820 + _ifxhcd->hc_driver.urb_dequeue = ifxhcd_urb_dequeue;
821 + _ifxhcd->hc_driver.endpoint_disable = ifxhcd_endpoint_disable;
822 + _ifxhcd->hc_driver.get_frame_number = ifxhcd_get_frame_number;
823 + _ifxhcd->hc_driver.hub_status_data = ifxhcd_hub_status_data;
824 + _ifxhcd->hc_driver.hub_control = ifxhcd_hub_control;
825 + //_ifxhcd->hc_driver.hub_suspend =
826 + //_ifxhcd->hc_driver.hub_resume =
828 + /* Allocate memory for and initialize the base HCD and */
829 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
830 + syshcd = usb_create_hcd(&_ifxhcd->hc_driver, _ifxhcd->dev, _ifxhcd->core_if.core_name);
832 + syshcd = usb_create_hcd(&_ifxhcd->hc_driver, _ifxhcd->dev, _ifxhcd->dev->bus_id);
835 + if (syshcd == NULL)
841 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
842 + syshcd->has_tt = 1;
845 + syshcd->rsrc_start = (unsigned long)_ifxhcd->core_if.core_global_regs;
846 + syshcd->regs = (void *)_ifxhcd->core_if.core_global_regs;
847 + syshcd->self.otg_port = 0;
849 + //*((unsigned long *)(&(syshcd->hcd_priv)))=(unsigned long)_ifxhcd;
850 + //*((unsigned long *)(&(syshcd->hcd_priv[0])))=(unsigned long)_ifxhcd;
851 + syshcd->hcd_priv[0]=(unsigned long)_ifxhcd;
852 + _ifxhcd->syshcd=syshcd;
854 + INIT_LIST_HEAD(&_ifxhcd->epqh_np_active );
855 + INIT_LIST_HEAD(&_ifxhcd->epqh_np_ready );
856 + INIT_LIST_HEAD(&_ifxhcd->epqh_intr_active );
857 + INIT_LIST_HEAD(&_ifxhcd->epqh_intr_ready );
859 + INIT_LIST_HEAD(&_ifxhcd->epqh_isoc_active );
860 + INIT_LIST_HEAD(&_ifxhcd->epqh_isoc_ready );
862 + INIT_LIST_HEAD(&_ifxhcd->epqh_stdby );
863 + INIT_LIST_HEAD(&_ifxhcd->urbd_complete_list);
866 + * Create a host channel descriptor for each host channel implemented
867 + * in the controller. Initialize the channel descriptor array.
869 + INIT_LIST_HEAD(&_ifxhcd->free_hc_list);
871 + int num_channels = _ifxhcd->core_if.params.host_channels;
873 + for (i = 0; i < num_channels; i++)
875 + _ifxhcd->ifxhc[i].hc_num = i;
876 + IFX_DEBUGPL(DBG_HCDV, "HCD Added channel #%d\n", i);
880 + /* Set device flags indicating whether the HCD supports DMA. */
881 + if(_ifxhcd->dev->dma_mask)
882 + *(_ifxhcd->dev->dma_mask) = ~0;
883 + _ifxhcd->dev->coherent_dma_mask = ~0;
886 + * Finish generic HCD initialization and start the HCD. This function
887 + * allocates the DMA buffer pool, registers the USB bus, requests the
888 + * IRQ line, and calls ifxusb_hcd_start method.
890 +// retval = usb_add_hcd(syshcd, _ifxhcd->core_if.irq, SA_INTERRUPT|SA_SHIRQ);
891 + retval = usb_add_hcd(syshcd, _ifxhcd->core_if.irq, IRQF_DISABLED | IRQF_SHARED );
896 + * Allocate space for storing data on status transactions. Normally no
897 + * data is sent, but this space acts as a bit bucket. This must be
898 + * done after usb_add_hcd since that function allocates the DMA buffer
901 + _ifxhcd->status_buf = ifxusb_alloc_buf(IFXHCD_STATUS_BUF_SIZE, 1);
903 + if (_ifxhcd->status_buf)
905 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
906 + IFX_DEBUGPL(DBG_HCD, "IFX USB HCD Initialized, bus=%s, usbbus=%d\n", _ifxhcd->core_if.core_name, syshcd->self.busnum);
908 + IFX_DEBUGPL(DBG_HCD, "IFX USB HCD Initialized, bus=%s, usbbus=%d\n", _ifxhcd->dev->bus_id, syshcd->self.busnum);
912 + IFX_ERROR("%s: status_buf allocation failed\n", __func__);
914 + /* Error conditions */
915 + usb_remove_hcd(syshcd);
917 + ifxhcd_freeextra(syshcd);
918 + usb_put_hcd(syshcd);
924 + \brief Removes the HCD.
925 + Frees memory and resources associated with the HCD and deregisters the bus.
927 +void ifxhcd_remove(ifxhcd_hcd_t *_ifxhcd)
929 + struct usb_hcd *syshcd = ifxhcd_to_syshcd(_ifxhcd);
931 + IFX_DEBUGPL(DBG_HCD, "IFX USB HCD REMOVE\n");
933 +/* == AVM/WK 20100709 - Fix: Order changed, disable IRQs not before remove_hcd == */
935 + usb_remove_hcd(syshcd);
937 + /* Turn off all interrupts */
938 + ifxusb_wreg (&_ifxhcd->core_if.core_global_regs->gintmsk, 0);
939 + ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gahbcfg, 1, 0);
941 + ifxhcd_freeextra(syshcd);
943 + usb_put_hcd(syshcd);
949 +/* =========================================================================
950 + * Linux HC Driver Functions
951 + * ========================================================================= */
954 + \brief Initializes the IFXUSB controller and its root hub and prepares it for host
955 + mode operation. Activates the root port. Returns 0 on success and a negative
956 + error code on failure.
957 + Called by USB stack.
959 +int ifxhcd_start(struct usb_hcd *_syshcd)
961 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
962 + ifxusb_core_if_t *core_if = &ifxhcd->core_if;
963 + struct usb_bus *bus;
965 + IFX_DEBUGPL(DBG_HCD, "IFX USB HCD START\n");
967 + bus = hcd_to_bus(_syshcd);
969 + /* Initialize the bus state. */
970 + _syshcd->state = HC_STATE_RUNNING;
972 + /* Initialize and connect root hub if one is not already attached */
975 + IFX_DEBUGPL(DBG_HCD, "IFX USB HCD Has Root Hub\n");
976 + /* Inform the HUB driver to resume. */
977 + usb_hcd_resume_root_hub(_syshcd);
980 + ifxhcd->flags.d32 = 0;
982 + /* Put all channels in the free channel list and clean up channel states.*/
984 + struct list_head *item;
985 + item = ifxhcd->free_hc_list.next;
986 + while (item != &ifxhcd->free_hc_list)
989 + item = ifxhcd->free_hc_list.next;
993 + int num_channels = ifxhcd->core_if.params.host_channels;
995 + for (i = 0; i < num_channels; i++)
997 + ifxhcd_hc_t *channel;
998 + channel = &ifxhcd->ifxhc[i];
999 + list_add_tail(&channel->hc_list_entry, &ifxhcd->free_hc_list);
1000 + ifxhcd_hc_cleanup(&ifxhcd->core_if, channel);
1003 + /* Initialize the USB core for host mode operation. */
1005 + ifxusb_host_enable_interrupts(core_if);
1006 + ifxusb_enable_global_interrupts(core_if);
1007 + ifxusb_phy_power_on (core_if);
1009 + ifxusb_vbus_init(core_if);
1011 + /* Turn on the vbus power. */
1013 + hprt0_data_t hprt0;
1014 + hprt0.d32 = ifxusb_read_hprt0(core_if);
1016 + IFX_PRINT("Init: Power Port (%d)\n", hprt0.b.prtpwr);
1017 + if (hprt0.b.prtpwr == 0 )
1019 + hprt0.b.prtpwr = 1;
1020 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1021 + ifxusb_vbus_on(core_if);
1029 + \brief Halts the IFXUSB host mode operations in a clean manner. USB transfers are
1032 +void ifxhcd_stop(struct usb_hcd *_syshcd)
1034 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
1035 + hprt0_data_t hprt0 = { .d32=0 };
1037 + IFX_DEBUGPL(DBG_HCD, "IFX USB HCD STOP\n");
1039 + /* Turn off all interrupts. */
1040 + ifxusb_disable_global_interrupts(&ifxhcd->core_if );
1041 + ifxusb_host_disable_interrupts(&ifxhcd->core_if );
1042 +#ifdef __USE_TIMER_4_SOF__
1043 + hrtimer_cancel(&ifxhcd->hr_timer);
1046 + * The root hub should be disconnected before this function is called.
1047 + * The disconnect will clear the URBD lists (via ..._hcd_urb_dequeue)
1048 + * and the EPQH lists (via ..._hcd_endpoint_disable).
1051 + /* Turn off the vbus power */
1052 + IFX_PRINT("PortPower off\n");
1054 + ifxusb_vbus_off(&ifxhcd->core_if );
1056 + ifxusb_vbus_free(&ifxhcd->core_if );
1058 + hprt0.b.prtpwr = 0;
1059 + ifxusb_wreg(ifxhcd->core_if.hprt0, hprt0.d32);
1064 + \brief Returns the current frame number
1066 +int ifxhcd_get_frame_number(struct usb_hcd *_syshcd)
1068 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
1069 + hfnum_data_t hfnum;
1071 + hfnum.d32 = ifxusb_rreg(&ifxhcd->core_if.host_global_regs->hfnum);
1073 + return hfnum.b.frnum;
1077 + \brief Starts processing a USB transfer request specified by a USB Request Block
1078 + (URB). mem_flags indicates the type of memory allocation to use while
1079 + processing this URB.
1081 +int ifxhcd_urb_enqueue( struct usb_hcd *_syshcd,
1082 + /*--- struct usb_host_endpoint *_sysep, Parameter im 2.6.28 entfallen ---*/
1087 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
1088 + struct usb_host_endpoint *_sysep = ifxhcd_urb_to_endpoint(_urb);
1089 + ifxhcd_epqh_t *epqh;
1092 + if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
1093 + dump_urb_info(_urb, "ifxusb_hcd_urb_enqueue");
1094 + #endif //__DEBUG__
1096 + if (!ifxhcd->flags.b.port_connect_status) /* No longer connected. */
1099 + #ifndef __EN_ISOC__
1100 + if(usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
1102 + IFX_ERROR("ISOC transfer not supported!!!\n");
1107 + retval=ifxhcd_urbd_create (ifxhcd,_urb);
1111 + IFX_ERROR("IFXUSB HCD URB Enqueue failed creating URBD\n");
1114 + epqh = (ifxhcd_epqh_t *) _sysep->hcpriv;
1115 + ifxhcd_epqh_ready(ifxhcd, epqh);
1117 + select_eps(ifxhcd);
1118 + //enable_sof(ifxhcd);
1120 + gint_data_t gintsts;
1122 + gintsts.b.sofintr = 1;
1123 + ifxusb_mreg(&ifxhcd->core_if.core_global_regs->gintmsk, 0,gintsts.d32);
1130 + \brief Aborts/cancels a USB transfer request. Always returns 0 to indicate
1133 +int ifxhcd_urb_dequeue( struct usb_hcd *_syshcd,
1134 + struct urb *_urb, int status /* Parameter neu in 2.6.28 */)
1136 + unsigned long flags;
1137 + ifxhcd_hcd_t *ifxhcd;
1138 + ifxhcd_urbd_t *urbd;
1139 + ifxhcd_epqh_t *epqh;
1143 + struct usb_host_endpoint *_sysep;
1145 + IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD URB Dequeue\n");
1147 + #ifndef __EN_ISOC__
1148 + if(usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
1152 + _sysep = ifxhcd_urb_to_endpoint(_urb);
1154 + ifxhcd = syshcd_to_ifxhcd(_syshcd);
1156 + SPIN_LOCK_IRQSAVE(&ifxhcd->lock, flags);
1158 + /*== AVM/BC 20100630 - 2.6.28 needs HCD link/unlink URBs ==*/
1159 + rc = usb_hcd_check_unlink_urb(_syshcd, _urb, status);
1161 + SPIN_UNLOCK_IRQRESTORE(&ifxhcd->lock, flags);
1165 + urbd = (ifxhcd_urbd_t *) _urb->hcpriv;
1168 + epqh = (ifxhcd_epqh_t *) _sysep->hcpriv;
1170 + epqh = (ifxhcd_epqh_t *) urbd->epqh;
1172 + if(epqh!=urbd->epqh)
1173 + IFX_ERROR("%s inconsistant epqh %p %p\n",__func__,epqh,urbd->epqh);
1176 + if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
1178 + dump_urb_info(_urb, "ifxhcd_urb_dequeue");
1179 + if (epqh->is_active)
1180 + dump_channel_info(ifxhcd, epqh);
1182 + #endif //__DEBUG__
1185 + epqh->is_active=0;
1186 + else if (!ifxhcd->flags.b.port_connect_status)
1187 + epqh->is_active=0;
1188 + else if (epqh->is_active && urbd->is_active)
1190 + /*== AVM/WK 20100709 - halt channel only if really started ==*/
1191 + //if (epqh->hc->xfer_started && !epqh->hc->wait_for_sof) {
1192 + /*== AVM/WK 20101112 - halt channel if started ==*/
1193 + if (epqh->hc->xfer_started) {
1195 + * If still connected (i.e. in host mode), halt the
1196 + * channel so it can be used for other transfers. If
1197 + * no longer connected, the host registers can't be
1198 + * written to halt the channel since the core is in
1201 + /* == 20110803 AVM/WK FIX propagate status == */
1202 + if (_urb->status == -EINPROGRESS) {
1203 + _urb->status = status;
1205 + ifxhcd_hc_halt(&ifxhcd->core_if, epqh->hc, HC_XFER_URB_DEQUEUE);
1213 + SPIN_UNLOCK_IRQRESTORE(&ifxhcd->lock, flags);
1217 + list_del_init(&urbd->urbd_list_entry);
1220 + /*== AVM/BC 20100630 - 2.6.28 needs HCD link/unlink URBs ==*/
1221 + usb_hcd_unlink_urb_from_ep(_syshcd, _urb);
1223 + SPIN_UNLOCK_IRQRESTORE(&ifxhcd->lock, flags);
1224 + _urb->hcpriv = NULL;
1225 +// usb_hcd_giveback_urb(_syshcd, _urb);
1226 + usb_hcd_giveback_urb(_syshcd, _urb, status /* neu in 2.6.28 */);
1227 + select_eps(ifxhcd);
1236 + \brief Frees resources in the IFXUSB controller related to a given endpoint. Also
1237 + clears state in the HCD related to the endpoint. Any URBs for the endpoint
1238 + must already be dequeued.
1240 +void ifxhcd_endpoint_disable( struct usb_hcd *_syshcd,
1241 + struct usb_host_endpoint *_sysep)
1243 + ifxhcd_epqh_t *epqh;
1244 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
1245 + unsigned long flags;
1249 + IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD EP DISABLE: _bEndpointAddress=0x%02x, "
1250 + "endpoint=%d\n", _sysep->desc.bEndpointAddress,
1251 + ifxhcd_ep_addr_to_endpoint(_sysep->desc.bEndpointAddress));
1253 + SPIN_LOCK_IRQSAVE(&ifxhcd->lock, flags);
1254 + if((uint32_t)_sysep>=0x80000000 && (uint32_t)_sysep->hcpriv>=(uint32_t)0x80000000)
1256 + epqh = (ifxhcd_epqh_t *)(_sysep->hcpriv);
1257 + if (epqh && epqh->sysep==_sysep)
1260 +#if 1 /*== AVM/BC 20101111 CHG Option active: Kill URBs when disabling EP ==*/
1261 + while (!list_empty(&epqh->urbd_list))
1263 + if (retry++ > 250)
1265 + IFX_WARN("IFXUSB HCD EP DISABLE:"
1266 + " URBD List for this endpoint is not empty\n");
1269 + kill_all_urbs_in_epqh(ifxhcd, epqh, -ETIMEDOUT);
1272 + while (!list_empty(&epqh->urbd_list))
1274 + /** Check that the QTD list is really empty */
1275 + if (retry++ > 250)
1277 + IFX_WARN("IFXUSB HCD EP DISABLE:"
1278 + " URBD List for this endpoint is not empty\n");
1281 + SPIN_UNLOCK_IRQRESTORE(&ifxhcd->lock, flags);
1282 + schedule_timeout_uninterruptible(1);
1283 + SPIN_LOCK_IRQSAVE(&ifxhcd->lock, flags);
1287 + ifxhcd_epqh_free(epqh);
1288 + _sysep->hcpriv = NULL;
1291 + SPIN_UNLOCK_IRQRESTORE(&ifxhcd->lock, flags);
1296 + \brief Handles host mode interrupts for the IFXUSB controller. Returns IRQ_NONE if
1297 + * there was no interrupt to handle. Returns IRQ_HANDLED if there was a valid
1300 + * This function is called by the USB core when an interrupt occurs
1302 +irqreturn_t ifxhcd_irq(struct usb_hcd *_syshcd)
1304 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
1307 + //mask_and_ack_ifx_irq (ifxhcd->core_if.irq);
1308 + retval = ifxhcd_handle_intr(ifxhcd);
1309 + return IRQ_RETVAL(retval);
1314 + \brief Handles host mode Over Current Interrupt
1316 +irqreturn_t ifxhcd_oc_irq(int _irq , void *_dev)
1318 + ifxhcd_hcd_t *ifxhcd = _dev;
1321 + ifxhcd->flags.b.port_over_current_change = 1;
1322 + ifxusb_vbus_off(&ifxhcd->core_if);
1323 + IFX_DEBUGP("OC INTERRUPT # %d\n",ifxhcd->core_if.core_no);
1325 + //mask_and_ack_ifx_irq (_irq);
1326 + return IRQ_RETVAL(retval);
1330 + \brief Creates Status Change bitmap for the root hub and root port. The bitmap is
1331 + returned in buf. Bit 0 is the status change indicator for the root hub. Bit 1
1332 + is the status change indicator for the single root port. Returns 1 if either
1333 + change indicator is 1, otherwise returns 0.
1335 +int ifxhcd_hub_status_data(struct usb_hcd *_syshcd, char *_buf)
1337 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
1340 + _buf[0] |= (ifxhcd->flags.b.port_connect_status_change ||
1341 + ifxhcd->flags.b.port_reset_change ||
1342 + ifxhcd->flags.b.port_enable_change ||
1343 + ifxhcd->flags.b.port_suspend_change ||
1344 + ifxhcd->flags.b.port_over_current_change) << 1;
1349 + IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD HUB STATUS DATA:"
1350 + " Root port status changed\n");
1351 + IFX_DEBUGPL(DBG_HCDV, " port_connect_status_change: %d\n",
1352 + ifxhcd->flags.b.port_connect_status_change);
1353 + IFX_DEBUGPL(DBG_HCDV, " port_reset_change: %d\n",
1354 + ifxhcd->flags.b.port_reset_change);
1355 + IFX_DEBUGPL(DBG_HCDV, " port_enable_change: %d\n",
1356 + ifxhcd->flags.b.port_enable_change);
1357 + IFX_DEBUGPL(DBG_HCDV, " port_suspend_change: %d\n",
1358 + ifxhcd->flags.b.port_suspend_change);
1359 + IFX_DEBUGPL(DBG_HCDV, " port_over_current_change: %d\n",
1360 + ifxhcd->flags.b.port_over_current_change);
1362 + #endif //__DEBUG__
1363 + return (_buf[0] != 0);
1366 +#ifdef __WITH_HS_ELECT_TST__
1367 + extern void do_setup(ifxusb_core_if_t *_core_if) ;
1368 + extern void do_in_ack(ifxusb_core_if_t *_core_if);
1369 +#endif //__WITH_HS_ELECT_TST__
1372 + \brief Handles hub class-specific requests.
1374 +int ifxhcd_hub_control( struct usb_hcd *_syshcd,
1383 + ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
1384 + ifxusb_core_if_t *core_if = &ifxhcd->core_if;
1385 + struct usb_hub_descriptor *desc;
1386 + hprt0_data_t hprt0 = {.d32 = 0};
1388 + uint32_t port_status;
1392 + case ClearHubFeature:
1393 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1394 + "ClearHubFeature 0x%x\n", _wValue);
1397 + case C_HUB_LOCAL_POWER:
1398 + case C_HUB_OVER_CURRENT:
1399 + /* Nothing required here */
1403 + IFX_ERROR ("IFXUSB HCD - "
1404 + "ClearHubFeature request %xh unknown\n", _wValue);
1407 + case ClearPortFeature:
1408 + if (!_wIndex || _wIndex > 1)
1413 + case USB_PORT_FEAT_ENABLE:
1414 + IFX_DEBUGPL (DBG_ANY, "IFXUSB HCD HUB CONTROL - "
1415 + "ClearPortFeature USB_PORT_FEAT_ENABLE\n");
1416 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1417 + hprt0.b.prtena = 1;
1418 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1420 + case USB_PORT_FEAT_SUSPEND:
1421 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1422 + "ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
1423 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1424 + hprt0.b.prtres = 1;
1425 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1426 + /* Clear Resume bit */
1428 + hprt0.b.prtres = 0;
1429 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1431 + case USB_PORT_FEAT_POWER:
1432 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1433 + "ClearPortFeature USB_PORT_FEAT_POWER\n");
1434 + #ifdef __IS_DUAL__
1435 + ifxusb_vbus_off(core_if);
1437 + ifxusb_vbus_off(core_if);
1439 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1440 + hprt0.b.prtpwr = 0;
1441 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1443 + case USB_PORT_FEAT_INDICATOR:
1444 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1445 + "ClearPortFeature USB_PORT_FEAT_INDICATOR\n");
1446 + /* Port inidicator not supported */
1448 + case USB_PORT_FEAT_C_CONNECTION:
1449 + /* Clears drivers internal connect status change
1451 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1452 + "ClearPortFeature USB_PORT_FEAT_C_CONNECTION\n");
1453 + ifxhcd->flags.b.port_connect_status_change = 0;
1455 + case USB_PORT_FEAT_C_RESET:
1456 + /* Clears the driver's internal Port Reset Change
1458 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1459 + "ClearPortFeature USB_PORT_FEAT_C_RESET\n");
1460 + ifxhcd->flags.b.port_reset_change = 0;
1462 + case USB_PORT_FEAT_C_ENABLE:
1463 + /* Clears the driver's internal Port
1464 + * Enable/Disable Change flag */
1465 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1466 + "ClearPortFeature USB_PORT_FEAT_C_ENABLE\n");
1467 + ifxhcd->flags.b.port_enable_change = 0;
1469 + case USB_PORT_FEAT_C_SUSPEND:
1470 + /* Clears the driver's internal Port Suspend
1471 + * Change flag, which is set when resume signaling on
1472 + * the host port is complete */
1473 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1474 + "ClearPortFeature USB_PORT_FEAT_C_SUSPEND\n");
1475 + ifxhcd->flags.b.port_suspend_change = 0;
1477 + case USB_PORT_FEAT_C_OVER_CURRENT:
1478 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1479 + "ClearPortFeature USB_PORT_FEAT_C_OVER_CURRENT\n");
1480 + ifxhcd->flags.b.port_over_current_change = 0;
1484 + IFX_ERROR ("IFXUSB HCD - "
1485 + "ClearPortFeature request %xh "
1486 + "unknown or unsupported\n", _wValue);
1489 + case GetHubDescriptor:
1490 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1491 + "GetHubDescriptor\n");
1492 + desc = (struct usb_hub_descriptor *)_buf;
1493 + desc->bDescLength = 9;
1494 + desc->bDescriptorType = 0x29;
1495 + desc->bNbrPorts = 1;
1496 + desc->wHubCharacteristics = 0x08;
1497 + desc->bPwrOn2PwrGood = 1;
1498 + desc->bHubContrCurrent = 0;
1499 +// desc->bitmap[0] = 0;
1500 +// desc->bitmap[1] = 0xff;
1502 + case GetHubStatus:
1503 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1504 + "GetHubStatus\n");
1505 + memset (_buf, 0, 4);
1507 + case GetPortStatus:
1508 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1509 + "GetPortStatus\n");
1510 + if (!_wIndex || _wIndex > 1)
1513 +# ifdef CONFIG_AVM_POWERMETER
1515 + /* first port only, but 2 Hosts */
1516 + static unsigned char ucOldPower1 = 255;
1517 + static unsigned char ucOldPower2 = 255;
1519 + unsigned char ucNewPower = 0;
1520 + struct usb_device *childdev = _syshcd->self.root_hub->children[0];
1522 + if (childdev != NULL) {
1523 + ucNewPower = (childdev->actconfig != NULL)
1524 + ? childdev->actconfig->desc.bMaxPower
1525 + : 50;/* default: 50 means 100 mA*/
1527 + if (_syshcd->self.busnum == 1) {
1528 + if (ucOldPower1 != ucNewPower) {
1529 + ucOldPower1 = ucNewPower;
1530 + printk (KERN_INFO "IFXHCD#1: AVM Powermeter changed to %u mA\n", ucNewPower*2);
1531 + PowerManagmentRessourceInfo(powerdevice_usb_host, ucNewPower*2);
1534 + if (ucOldPower2 != ucNewPower) {
1535 + ucOldPower2 = ucNewPower;
1536 + printk (KERN_INFO "IFXHCD#2: AVM Powermeter changed to %u mA\n", ucNewPower*2);
1537 + PowerManagmentRessourceInfo(powerdevice_usb_host2, ucNewPower*2);
1541 +# endif /*--- #ifdef CONFIG_AVM_POWERMETER ---*/
1544 + if (ifxhcd->flags.b.port_connect_status_change)
1545 + port_status |= (1 << USB_PORT_FEAT_C_CONNECTION);
1546 + if (ifxhcd->flags.b.port_enable_change)
1547 + port_status |= (1 << USB_PORT_FEAT_C_ENABLE);
1548 + if (ifxhcd->flags.b.port_suspend_change)
1549 + port_status |= (1 << USB_PORT_FEAT_C_SUSPEND);
1550 + if (ifxhcd->flags.b.port_reset_change)
1551 + port_status |= (1 << USB_PORT_FEAT_C_RESET);
1552 + if (ifxhcd->flags.b.port_over_current_change)
1554 + IFX_ERROR("Device Not Supported\n");
1555 + port_status |= (1 << USB_PORT_FEAT_C_OVER_CURRENT);
1557 + if (!ifxhcd->flags.b.port_connect_status)
1560 + * The port is disconnected, which means the core is
1561 + * either in device mode or it soon will be. Just
1562 + * return 0's for the remainder of the port status
1563 + * since the port register can't be read if the core
1564 + * is in device mode.
1566 + *((u32 *) _buf) = cpu_to_le32(port_status);
1570 + hprt0.d32 = ifxusb_rreg(core_if->hprt0);
1571 + IFX_DEBUGPL(DBG_HCDV, " HPRT0: 0x%08x\n", hprt0.d32);
1572 + if (hprt0.b.prtconnsts)
1573 + port_status |= (1 << USB_PORT_FEAT_CONNECTION);
1574 + if (hprt0.b.prtena)
1575 + port_status |= (1 << USB_PORT_FEAT_ENABLE);
1576 + if (hprt0.b.prtsusp)
1577 + port_status |= (1 << USB_PORT_FEAT_SUSPEND);
1578 + if (hprt0.b.prtovrcurract)
1579 + port_status |= (1 << USB_PORT_FEAT_OVER_CURRENT);
1580 + if (hprt0.b.prtrst)
1581 + port_status |= (1 << USB_PORT_FEAT_RESET);
1582 + if (hprt0.b.prtpwr)
1583 + port_status |= (1 << USB_PORT_FEAT_POWER);
1584 +/* if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
1585 + port_status |= (1 << USB_PORT_FEAT_HIGHSPEED);
1586 + else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
1587 + port_status |= (1 << USB_PORT_FEAT_LOWSPEED);*/
1588 + if (hprt0.b.prttstctl)
1589 + port_status |= (1 << USB_PORT_FEAT_TEST);
1590 + /* USB_PORT_FEAT_INDICATOR unsupported always 0 */
1591 + *((u32 *) _buf) = cpu_to_le32(port_status);
1593 + case SetHubFeature:
1594 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1595 + "SetHubFeature\n");
1596 + /* No HUB features supported */
1598 + case SetPortFeature:
1599 + if (_wValue != USB_PORT_FEAT_TEST && (!_wIndex || _wIndex > 1))
1602 + * The port is disconnected, which means the core is
1603 + * either in device mode or it soon will be. Just
1604 + * return without doing anything since the port
1605 + * register can't be written if the core is in device
1608 + if (!ifxhcd->flags.b.port_connect_status)
1612 + case USB_PORT_FEAT_SUSPEND:
1613 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1614 + "SetPortFeature - USB_PORT_FEAT_SUSPEND\n");
1615 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1616 + hprt0.b.prtsusp = 1;
1617 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1618 + //IFX_PRINT( "SUSPEND: HPRT0=%0x\n", hprt0.d32);
1619 + /* Suspend the Phy Clock */
1621 + pcgcctl_data_t pcgcctl = {.d32=0};
1622 + pcgcctl.b.stoppclk = 1;
1623 + ifxusb_wreg(core_if->pcgcctl, pcgcctl.d32);
1626 + case USB_PORT_FEAT_POWER:
1627 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1628 + "SetPortFeature - USB_PORT_FEAT_POWER\n");
1629 + ifxusb_vbus_on (core_if);
1630 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1631 + hprt0.b.prtpwr = 1;
1632 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1634 + case USB_PORT_FEAT_RESET:
1635 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1636 + "SetPortFeature - USB_PORT_FEAT_RESET\n");
1637 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1638 + hprt0.b.prtrst = 1;
1639 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1640 + /* Clear reset bit in 10ms (FS/LS) or 50ms (HS) */
1642 + hprt0.b.prtrst = 0;
1643 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1645 + #ifdef __WITH_HS_ELECT_TST__
1646 + case USB_PORT_FEAT_TEST:
1649 + gint_data_t gintmsk;
1650 + t = (_wIndex >> 8); /* MSB wIndex USB */
1651 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1652 + "SetPortFeature - USB_PORT_FEAT_TEST %d\n", t);
1653 + warn("USB_PORT_FEAT_TEST %d\n", t);
1656 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1657 + hprt0.b.prttstctl = t;
1658 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1660 + else if (t == 6) /* HS_HOST_PORT_SUSPEND_RESUME */
1662 + /* Save current interrupt mask */
1663 + gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
1665 + /* Disable all interrupts while we muck with
1666 + * the hardware directly
1668 + ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
1670 + /* 15 second delay per the test spec */
1673 + /* Drive suspend on the root port */
1674 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1675 + hprt0.b.prtsusp = 1;
1676 + hprt0.b.prtres = 0;
1677 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1679 + /* 15 second delay per the test spec */
1682 + /* Drive resume on the root port */
1683 + hprt0.d32 = ifxusb_read_hprt0 (core_if);
1684 + hprt0.b.prtsusp = 0;
1685 + hprt0.b.prtres = 1;
1686 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1689 + /* Clear the resume bit */
1690 + hprt0.b.prtres = 0;
1691 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
1693 + /* Restore interrupts */
1694 + ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
1696 + else if (t == 7) /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup */
1698 + /* Save current interrupt mask */
1699 + gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
1701 + /* Disable all interrupts while we muck with
1702 + * the hardware directly
1704 + ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
1706 + /* 15 second delay per the test spec */
1709 + /* Send the Setup packet */
1710 + do_setup(core_if);
1712 + /* 15 second delay so nothing else happens for awhile */
1715 + /* Restore interrupts */
1716 + ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
1719 + else if (t == 8) /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute */
1721 + /* Save current interrupt mask */
1722 + gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
1724 + /* Disable all interrupts while we muck with
1725 + * the hardware directly
1727 + ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
1729 + /* Send the Setup packet */
1730 + do_setup(core_if);
1732 + /* 15 second delay so nothing else happens for awhile */
1735 + /* Send the In and Ack packets */
1736 + do_in_ack(core_if);
1738 + /* 15 second delay so nothing else happens for awhile */
1741 + /* Restore interrupts */
1742 + ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
1746 + #endif //__WITH_HS_ELECT_TST__
1747 + case USB_PORT_FEAT_INDICATOR:
1748 + IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
1749 + "SetPortFeature - USB_PORT_FEAT_INDICATOR\n");
1750 + /* Not supported */
1754 + IFX_ERROR ("IFXUSB HCD - "
1755 + "SetPortFeature request %xh "
1756 + "unknown or unsupported\n", _wValue);
1762 + IFX_WARN ("IFXUSB HCD - "
1763 + "Unknown hub control request type or invalid typeReq: %xh wIndex: %xh wValue: %xh\n",
1764 + _typeReq, _wIndex, _wValue);
1771 + \brief Assigns transactions from a URBD to a free host channel and initializes the
1772 + host channel to perform the transactions. The host channel is removed from
1774 + \param _ifxhcd The HCD state structure.
1775 + \param _epqh Transactions from the first URBD for this EPQH are selected and assigned to a free host channel.
1777 +static int assign_and_init_hc(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh)
1779 + ifxhcd_hc_t *ifxhc;
1780 + ifxhcd_urbd_t *urbd;
1783 + IFX_DEBUGPL(DBG_HCDV, "%s(%p,%p)\n", __func__, _ifxhcd, _epqh);
1785 + if(list_empty(&_epqh->urbd_list))
1788 + ifxhc = list_entry(_ifxhcd->free_hc_list.next, ifxhcd_hc_t, hc_list_entry);
1789 + /* Remove the host channel from the free list. */
1790 + list_del_init(&ifxhc->hc_list_entry);
1792 + urbd = list_entry(_epqh->urbd_list.next, ifxhcd_urbd_t, urbd_list_entry);
1795 + _epqh->hc = ifxhc;
1796 + _epqh->urbd = urbd;
1797 + ifxhc->epqh = _epqh;
1799 + urbd->is_active=1;
1802 + * Use usb_pipedevice to determine device address. This address is
1803 + * 0 before the SET_ADDRESS command and the correct address afterward.
1805 + ifxhc->dev_addr = usb_pipedevice(urb->pipe);
1806 + ifxhc->ep_num = usb_pipeendpoint(urb->pipe);
1808 + ifxhc->xfer_started = 0;
1810 + if (urb->dev->speed == USB_SPEED_LOW) ifxhc->speed = IFXUSB_EP_SPEED_LOW;
1811 + else if (urb->dev->speed == USB_SPEED_FULL) ifxhc->speed = IFXUSB_EP_SPEED_FULL;
1812 + else ifxhc->speed = IFXUSB_EP_SPEED_HIGH;
1814 + ifxhc->mps = _epqh->mps;
1815 + ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
1817 + ifxhc->ep_type = _epqh->ep_type;
1819 + if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
1821 + ifxhc->control_phase=IFXHCD_CONTROL_SETUP;
1823 + ifxhc->data_pid_start = IFXUSB_HC_PID_SETUP;
1824 + ifxhc->xfer_buff = urbd->setup_buff;
1825 + ifxhc->xfer_len = 8;
1826 + ifxhc->xfer_count = 0;
1827 + ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
1831 + ifxhc->is_in = urbd->is_in;
1832 + ifxhc->xfer_buff = urbd->xfer_buff;
1833 + ifxhc->xfer_len = urbd->xfer_len;
1834 + ifxhc->xfer_count = 0;
1835 + /* == AVM/WK 20100710 Fix - Use toggle of usbcore ==*/
1836 + //ifxhc->data_pid_start = _epqh->data_toggle;
1837 + ifxhc->data_pid_start = usb_gettoggle (urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout (urb->pipe))
1838 + ? IFXUSB_HC_PID_DATA1
1839 + : IFXUSB_HC_PID_DATA0;
1841 + ifxhc->short_rw =0;
1843 + ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
1845 + #ifdef __EN_ISOC__
1846 + if(_epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
1848 + struct usb_iso_packet_descriptor *frame_desc;
1849 + frame_desc = &urb->iso_frame_desc[urbd->isoc_frame_index];
1850 + ifxhc->xfer_buff += frame_desc->offset + urbd->isoc_split_offset;
1851 + ifxhc->xfer_len = frame_desc->length - urbd->isoc_split_offset;
1852 + if (ifxhc->isoc_xact_pos == IFXUSB_HCSPLIT_XACTPOS_ALL)
1854 + if (ifxhc->xfer_len <= 188)
1855 + ifxhc->isoc_xact_pos = IFXUSB_HCSPLIT_XACTPOS_ALL;
1857 + ifxhc->isoc_xact_pos = IFXUSB_HCSPLIT_XACTPOS_BEGIN;
1864 + if (_ifxhcd->core_if.snpsid < 0x4f54271a && ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
1868 + /* Set the split attributes */
1870 + if (_epqh->need_split) {
1872 + ifxhc->hub_addr = urb->dev->tt->hub->devnum;
1873 + ifxhc->port_addr = urb->dev->ttport;
1876 + //ifxhc->uint16_t pkt_count_limit
1879 + hcint_data_t hc_intr_mask;
1880 + uint8_t hc_num = ifxhc->hc_num;
1881 + ifxusb_hc_regs_t *hc_regs = _ifxhcd->core_if.hc_regs[hc_num];
1883 + /* Clear old interrupt conditions for this host channel. */
1884 + hc_intr_mask.d32 = 0xFFFFFFFF;
1885 + hc_intr_mask.b.reserved = 0;
1886 + ifxusb_wreg(&hc_regs->hcint, hc_intr_mask.d32);
1888 + /* Enable channel interrupts required for this transfer. */
1889 + hc_intr_mask.d32 = 0;
1890 + hc_intr_mask.b.chhltd = 1;
1891 + hc_intr_mask.b.ahberr = 1;
1893 + ifxusb_wreg(&hc_regs->hcintmsk, hc_intr_mask.d32);
1895 + /* Enable the top level host channel interrupt. */
1897 + uint32_t intr_enable;
1898 + intr_enable = (1 << hc_num);
1899 + ifxusb_mreg(&_ifxhcd->core_if.host_global_regs->haintmsk, 0, intr_enable);
1902 + /* Make sure host channel interrupts are enabled. */
1904 + gint_data_t gintmsk ={.d32 = 0};
1905 + gintmsk.b.hcintr = 1;
1906 + ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk, 0, gintmsk.d32);
1910 + * Program the HCCHARn register with the endpoint characteristics for
1911 + * the current transfer.
1914 + hcchar_data_t hcchar;
1917 + hcchar.b.devaddr = ifxhc->dev_addr;
1918 + hcchar.b.epnum = ifxhc->ep_num;
1919 + hcchar.b.lspddev = (ifxhc->speed == IFXUSB_EP_SPEED_LOW);
1920 + hcchar.b.eptype = ifxhc->ep_type;
1921 + hcchar.b.mps = ifxhc->mps;
1922 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
1924 + IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n", __func__, ifxhc->hc_num);
1925 + IFX_DEBUGPL(DBG_HCDV, " Dev Addr: %d\n" , hcchar.b.devaddr);
1926 + IFX_DEBUGPL(DBG_HCDV, " Ep Num: %d\n" , hcchar.b.epnum);
1927 + IFX_DEBUGPL(DBG_HCDV, " Is Low Speed: %d\n", hcchar.b.lspddev);
1928 + IFX_DEBUGPL(DBG_HCDV, " Ep Type: %d\n" , hcchar.b.eptype);
1929 + IFX_DEBUGPL(DBG_HCDV, " Max Pkt: %d\n" , hcchar.b.mps);
1930 + IFX_DEBUGPL(DBG_HCDV, " Multi Cnt: %d\n" , hcchar.b.multicnt);
1932 + /* Program the HCSPLIT register for SPLITs */
1934 + hcsplt_data_t hcsplt;
1939 + IFX_DEBUGPL(DBG_HCDV, "Programming HC %d with split --> %s\n", ifxhc->hc_num,
1940 + (ifxhc->split==2) ? "CSPLIT" : "SSPLIT");
1941 + hcsplt.b.spltena = 1;
1942 + hcsplt.b.compsplt = (ifxhc->split==2);
1943 + #ifdef __EN_ISOC__
1944 + if(_epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
1945 + hcsplt.b.xactpos = ifxhc->isoc_xact_pos;
1948 + hcsplt.b.xactpos = IFXUSB_HCSPLIT_XACTPOS_ALL;
1949 + hcsplt.b.hubaddr = ifxhc->hub_addr;
1950 + hcsplt.b.prtaddr = ifxhc->port_addr;
1951 + IFX_DEBUGPL(DBG_HCDV, " comp split %d\n" , hcsplt.b.compsplt);
1952 + IFX_DEBUGPL(DBG_HCDV, " xact pos %d\n" , hcsplt.b.xactpos);
1953 + IFX_DEBUGPL(DBG_HCDV, " hub addr %d\n" , hcsplt.b.hubaddr);
1954 + IFX_DEBUGPL(DBG_HCDV, " port addr %d\n" , hcsplt.b.prtaddr);
1955 + IFX_DEBUGPL(DBG_HCDV, " is_in %d\n" , ifxhc->is_in);
1956 + IFX_DEBUGPL(DBG_HCDV, " Max Pkt: %d\n" , ifxhc->mps);
1957 + IFX_DEBUGPL(DBG_HCDV, " xferlen: %d\n" , ifxhc->xfer_len);
1959 + ifxusb_wreg(&hc_regs->hcsplt, hcsplt.d32);
1963 + ifxhc->nak_retry_r=ifxhc->nak_retry=0;
1964 + ifxhc->nak_countdown_r=ifxhc->nak_countdown=0;
1975 + else if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
1984 + else if(_epqh->ep_type==IFXUSB_EP_TYPE_BULK)
1988 +// ifxhc->nak_retry_r=ifxhc->nak_retry=nak_retry_max;
1989 +// ifxhc->nak_countdown_r=ifxhc->nak_countdown=nak_countdown_max;
1995 + else if(_epqh->ep_type==IFXUSB_EP_TYPE_INTR)
2004 + else if(_epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
2018 + \brief This function selects transactions from the HCD transfer schedule and
2019 + assigns them to available host channels. It is called from HCD interrupt
2020 + handler functions.
2022 +static void select_eps_sub(ifxhcd_hcd_t *_ifxhcd)
2024 + struct list_head *epqh_ptr;
2025 + struct list_head *urbd_ptr;
2026 + ifxhcd_epqh_t *epqh;
2027 + ifxhcd_urbd_t *urbd;
2030 + /*== AVM/BC 20101111 Function called with Lock ==*/
2032 +// #ifdef __DEBUG__
2033 +// IFX_DEBUGPL(DBG_HCD, " ifxhcd_select_ep\n");
2036 + /* Process entries in the periodic ready list. */
2037 + #ifdef __EN_ISOC__
2038 + epqh_ptr = _ifxhcd->epqh_isoc_ready.next;
2039 + while (epqh_ptr != &_ifxhcd->epqh_isoc_ready && !list_empty(&_ifxhcd->free_hc_list))
2041 + epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, epqh_list_entry);
2042 + epqh_ptr = epqh_ptr->next;
2043 + if(epqh->period_do)
2045 + if(assign_and_init_hc(_ifxhcd, epqh))
2047 + IFX_DEBUGPL(DBG_HCD, " select_eps ISOC\n");
2048 + list_move_tail(&epqh->epqh_list_entry, &_ifxhcd->epqh_isoc_active);
2049 + epqh->is_active=1;
2051 + epqh->period_do=0;
2057 + epqh_ptr = _ifxhcd->epqh_intr_ready.next;
2058 + while (epqh_ptr != &_ifxhcd->epqh_intr_ready && !list_empty(&_ifxhcd->free_hc_list))
2060 + epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, epqh_list_entry);
2061 + epqh_ptr = epqh_ptr->next;
2062 + if(epqh->period_do)
2064 + if(assign_and_init_hc(_ifxhcd, epqh))
2066 + IFX_DEBUGPL(DBG_HCD, " select_eps INTR\n");
2067 + list_move_tail(&epqh->epqh_list_entry, &_ifxhcd->epqh_intr_active);
2068 + epqh->is_active=1;
2070 + epqh->period_do=0;
2075 + epqh_ptr = _ifxhcd->epqh_np_ready.next;
2076 + while (epqh_ptr != &_ifxhcd->epqh_np_ready && !list_empty(&_ifxhcd->free_hc_list)) // may need to preserve at lease one for period
2078 + epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, epqh_list_entry);
2079 + epqh_ptr = epqh_ptr->next;
2080 + if(assign_and_init_hc(_ifxhcd, epqh))
2082 + IFX_DEBUGPL(DBG_HCD, " select_eps CTRL/BULK\n");
2083 + list_move_tail(&epqh->epqh_list_entry, &_ifxhcd->epqh_np_active);
2084 + epqh->is_active=1;
2089 + /*== AVM/BC 20101111 Function called with Lock ==*/
2090 + process_channels_sub(_ifxhcd);
2092 + /* AVM/BC 20101111 Urbds completion loop */
2093 + while (!list_empty(&_ifxhcd->urbd_complete_list))
2095 + urbd_ptr = _ifxhcd->urbd_complete_list.next;
2096 + list_del_init(urbd_ptr);
2098 + urbd = list_entry(urbd_ptr, ifxhcd_urbd_t, urbd_list_entry);
2100 + ifxhcd_complete_urb(_ifxhcd, urbd, urbd->status);
2106 +static void select_eps_func(unsigned long data)
2108 + unsigned long flags;
2110 + ifxhcd_hcd_t *ifxhcd;
2111 + ifxhcd=((ifxhcd_hcd_t *)data);
2113 + /* AVM/BC 20101111 select_eps_in_use flag removed */
2115 + SPIN_LOCK_IRQSAVE(&ifxhcd->lock, flags);
2117 + /*if(ifxhcd->select_eps_in_use){
2118 + SPIN_UNLOCK_IRQRESTORE(&ifxhcd->lock, flags);
2121 + ifxhcd->select_eps_in_use=1;
2124 + select_eps_sub(ifxhcd);
2126 + //ifxhcd->select_eps_in_use=0;
2128 + SPIN_UNLOCK_IRQRESTORE(&ifxhcd->lock, flags);
2131 +void select_eps(ifxhcd_hcd_t *_ifxhcd)
2135 + if(!_ifxhcd->select_eps.func)
2137 + _ifxhcd->select_eps.next = NULL;
2138 + _ifxhcd->select_eps.state = 0;
2139 + atomic_set( &_ifxhcd->select_eps.count, 0);
2140 + _ifxhcd->select_eps.func = select_eps_func;
2141 + _ifxhcd->select_eps.data = (unsigned long)_ifxhcd;
2143 + tasklet_schedule(&_ifxhcd->select_eps);
2147 + unsigned long flags;
2149 + /* AVM/BC 20101111 select_eps_in_use flag removed */
2151 + SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
2153 + /*if(_ifxhcd->select_eps_in_use){
2154 + printk ("select_eps non_irq: busy\n");
2155 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
2158 + _ifxhcd->select_eps_in_use=1;
2161 + select_eps_sub(_ifxhcd);
2163 + //_ifxhcd->select_eps_in_use=0;
2165 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
2172 +static void process_unaligned( ifxhcd_epqh_t *_epqh)
2174 + #if defined(__UNALIGNED_BUFFER_ADJ__)
2175 + if(!_epqh->aligned_checked)
2177 + uint32_t xfer_len;
2178 + xfer_len=_epqh->urbd->xfer_len;
2179 + if(_epqh->urbd->is_in && xfer_len<_epqh->mps)
2180 + xfer_len = _epqh->mps;
2181 + _epqh->using_aligned_buf=0;
2183 + if(xfer_len > 0 && ((unsigned long)_epqh->urbd->xfer_buff) & 3)
2185 + if( _epqh->aligned_buf
2186 + && _epqh->aligned_buf_len > 0
2187 + && _epqh->aligned_buf_len < xfer_len
2190 + ifxusb_free_buf(_epqh->aligned_buf);
2191 + _epqh->aligned_buf=NULL;
2192 + _epqh->aligned_buf_len=0;
2194 + if(! _epqh->aligned_buf || ! _epqh->aligned_buf_len)
2196 + _epqh->aligned_buf = ifxusb_alloc_buf(xfer_len, _epqh->urbd->is_in);
2197 + if(_epqh->aligned_buf)
2198 + _epqh->aligned_buf_len = xfer_len;
2200 + if(_epqh->aligned_buf)
2202 + if(!_epqh->urbd->is_in)
2203 + memcpy(_epqh->aligned_buf, _epqh->urbd->xfer_buff, xfer_len);
2204 + _epqh->using_aligned_buf=1;
2205 + _epqh->hc->xfer_buff = _epqh->aligned_buf;
2208 + IFX_WARN("%s():%d\n",__func__,__LINE__);
2210 + if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
2212 + _epqh->using_aligned_setup=0;
2213 + if(((unsigned long)_epqh->urbd->setup_buff) & 3)
2215 + if(! _epqh->aligned_setup)
2216 + _epqh->aligned_setup = ifxusb_alloc_buf(8,0);
2217 + if(_epqh->aligned_setup)
2219 + memcpy(_epqh->aligned_setup, _epqh->urbd->setup_buff, 8);
2220 + _epqh->using_aligned_setup=1;
2223 + IFX_WARN("%s():%d\n",__func__,__LINE__);
2224 + _epqh->hc->xfer_buff = _epqh->aligned_setup;
2228 + #elif defined(__UNALIGNED_BUFFER_CHK__)
2229 + if(!_epqh->aligned_checked)
2231 + if(_epqh->urbd->is_in)
2233 + if(_epqh->urbd->xfer_len==0)
2234 + IFX_WARN("%s():%d IN xfer while length is zero \n",__func__,__LINE__);
2236 + if(_epqh->urbd->xfer_len < _epqh->mps)
2237 + IFX_WARN("%s():%d IN xfer while length < mps \n",__func__,__LINE__);
2239 + if(((unsigned long)_epqh->urbd->xfer_buff) & 3)
2240 + IFX_WARN("%s():%d IN xfer Buffer UNALIGNED\n",__func__,__LINE__);
2245 + if(_epqh->urbd->xfer_len > 0 && (((unsigned long)_epqh->urbd->xfer_buff) & 3) )
2246 + IFX_WARN("%s():%d OUT xfer Buffer UNALIGNED\n",__func__,__LINE__);
2249 + if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
2251 + if(((unsigned long)_epqh->urbd->setup_buff) & 3)
2252 + IFX_WARN("%s():%d SETUP xfer Buffer UNALIGNED\n",__func__,__LINE__);
2256 + _epqh->aligned_checked=1;
2263 +void process_channels_sub(ifxhcd_hcd_t *_ifxhcd)
2265 + ifxhcd_epqh_t *epqh;
2266 + struct list_head *epqh_item;
2267 + struct ifxhcd_hc *hc;
2269 + #ifdef __EN_ISOC__
2270 + if (!list_empty(&_ifxhcd->epqh_isoc_active))
2272 + for (epqh_item = _ifxhcd->epqh_isoc_active.next;
2273 + epqh_item != &_ifxhcd->epqh_isoc_active;
2276 + epqh = list_entry(epqh_item, ifxhcd_epqh_t, epqh_list_entry);
2277 + epqh_item = epqh_item->next;
2279 + if(hc && !hc->xfer_started && epqh->period_do)
2285 + //epqh->ping_state = 0;
2286 + process_unaligned(epqh);
2287 + hc->wait_for_sof=epqh->wait_for_sof;
2288 + epqh->wait_for_sof=0;
2289 + ifxhcd_hc_start(&_ifxhcd->core_if, hc);
2290 + epqh->period_do=0;
2292 + gint_data_t gintsts = {.d32 = 0};
2293 + gintsts.b.sofintr = 1;
2294 + ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk,0, gintsts.d32);
2302 + if (!list_empty(&_ifxhcd->epqh_intr_active))
2304 + for (epqh_item = _ifxhcd->epqh_intr_active.next;
2305 + epqh_item != &_ifxhcd->epqh_intr_active;
2308 + epqh = list_entry(epqh_item, ifxhcd_epqh_t, epqh_list_entry);
2309 + epqh_item = epqh_item->next;
2311 + if(hc && !hc->xfer_started && epqh->period_do)
2317 + //epqh->ping_state = 0;
2318 + process_unaligned(epqh);
2319 + hc->wait_for_sof=epqh->wait_for_sof;
2320 + epqh->wait_for_sof=0;
2321 + ifxhcd_hc_start(&_ifxhcd->core_if, hc);
2322 + epqh->period_do=0;
2323 +#ifdef __USE_TIMER_4_SOF__
2324 + /* AVM/WK change: let hc_start decide, if irq is needed */
2327 + gint_data_t gintsts = {.d32 = 0};
2328 + gintsts.b.sofintr = 1;
2329 + ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk,0, gintsts.d32);
2338 + if (!list_empty(&_ifxhcd->epqh_np_active))
2340 + for (epqh_item = _ifxhcd->epqh_np_active.next;
2341 + epqh_item != &_ifxhcd->epqh_np_active;
2344 + epqh = list_entry(epqh_item, ifxhcd_epqh_t, epqh_list_entry);
2345 + epqh_item = epqh_item->next;
2349 + if(!hc->xfer_started)
2353 + //|| hc->split_counter == 0
2356 + //epqh->ping_state = 0;
2357 + process_unaligned(epqh);
2358 + hc->wait_for_sof=epqh->wait_for_sof;
2359 + epqh->wait_for_sof=0;
2360 + ifxhcd_hc_start(&_ifxhcd->core_if, hc);
2368 +void process_channels(ifxhcd_hcd_t *_ifxhcd)
2370 + unsigned long flags;
2372 + /* AVM/WK Fix: use spin_lock instead busy flag
2374 + SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
2376 + //if(_ifxhcd->process_channels_in_use)
2378 + //_ifxhcd->process_channels_in_use=1;
2380 + process_channels_sub(_ifxhcd);
2381 + //_ifxhcd->process_channels_in_use=0;
2382 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
2386 +#ifdef __HC_XFER_TIMEOUT__
2387 + static void hc_xfer_timeout(unsigned long _ptr)
2389 + hc_xfer_info_t *xfer_info = (hc_xfer_info_t *)_ptr;
2390 + int hc_num = xfer_info->hc->hc_num;
2391 + IFX_WARN("%s: timeout on channel %d\n", __func__, hc_num);
2392 + IFX_WARN(" start_hcchar_val 0x%08x\n", xfer_info->hc->start_hcchar_val);
2396 +void ifxhcd_hc_dumb_rx(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc,uint8_t *dump_buf)
2398 + ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
2399 + hctsiz_data_t hctsiz= { .d32=0 };
2400 + hcchar_data_t hcchar;
2403 + _ifxhc->xfer_len = _ifxhc->mps;
2404 + hctsiz.b.xfersize = _ifxhc->mps;
2405 + hctsiz.b.pktcnt = 0;
2406 + hctsiz.b.pid = _ifxhc->data_pid_start;
2407 + ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
2409 + ifxusb_wreg(&hc_regs->hcdma, (uint32_t)(CPHYSADDR( ((uint32_t)(dump_buf)))));
2412 + hcint_data_t hcint= { .d32=0 };
2416 + hcint.d32 =0xFFFFFFFF;
2417 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
2420 + /* Set host channel enable after all other setup is complete. */
2421 + hcchar.b.chen = 1;
2422 + hcchar.b.chdis = 0;
2423 + hcchar.b.epdir = 1;
2424 + IFX_DEBUGPL(DBG_HCDV, " HCCHART: 0x%08x\n", hcchar.d32);
2425 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
2429 + \brief This function trigger a data transfer for a host channel and
2430 + starts the transfer.
2432 + For a PING transfer in Slave mode, the Do Ping bit is set in the HCTSIZ
2433 + register along with a packet count of 1 and the channel is enabled. This
2434 + causes a single PING transaction to occur. Other fields in HCTSIZ are
2435 + simply set to 0 since no data transfer occurs in this case.
2437 + For a PING transfer in DMA mode, the HCTSIZ register is initialized with
2438 + all the information required to perform the subsequent data transfer. In
2439 + addition, the Do Ping bit is set in the HCTSIZ register. In this case, the
2440 + controller performs the entire PING protocol, then starts the data
2442 + \param _core_if Pointer of core_if structure
2443 + \param _ifxhc Information needed to initialize the host channel. The xfer_len
2444 + value may be reduced to accommodate the max widths of the XferSize and
2445 + PktCnt fields in the HCTSIZn register. The multi_count value may be changed
2446 + to reflect the final xfer_len value.
2448 +void ifxhcd_hc_start(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc)
2450 + hctsiz_data_t hctsiz= { .d32=0 };
2451 + hcchar_data_t hcchar;
2452 + uint32_t max_hc_xfer_size = _core_if->params.max_transfer_size;
2453 + uint16_t max_hc_pkt_count = _core_if->params.max_packet_count;
2454 + ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
2455 + hfnum_data_t hfnum;
2457 + hctsiz.b.dopng = 0;
2458 +// if(_ifxhc->do_ping && !_ifxhc->is_in) hctsiz.b.dopng = 1;
2460 + _ifxhc->nak_countdown=_ifxhc->nak_countdown_r;
2462 + /* AVM/BC 20101111 Workaround: Always PING if HI-Speed Out and xfer_len > 0 */
2463 + if(/*_ifxhc->do_ping &&*/
2464 + (!_ifxhc->is_in) &&
2465 + (_ifxhc->speed == IFXUSB_EP_SPEED_HIGH) &&
2466 + ((_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK) || ((_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL) && (_ifxhc->control_phase != IFXHCD_CONTROL_SETUP))) &&
2469 + hctsiz.b.dopng = 1;
2471 + _ifxhc->xfer_started = 1;
2473 + if(_ifxhc->epqh->pkt_count_limit > 0 && _ifxhc->epqh->pkt_count_limit < max_hc_pkt_count )
2475 + max_hc_pkt_count=_ifxhc->epqh->pkt_count_limit;
2476 + if(max_hc_pkt_count * _ifxhc->mps < max_hc_xfer_size)
2477 + max_hc_xfer_size = max_hc_pkt_count * _ifxhc->mps;
2479 + if (_ifxhc->split > 0)
2482 + gint_data_t gintsts = {.d32 = 0};
2483 + gintsts.b.sofintr = 1;
2484 + ifxusb_mreg(&_core_if->core_global_regs->gintmsk,0, gintsts.d32);
2487 + _ifxhc->start_pkt_count = 1;
2488 + if(!_ifxhc->is_in && _ifxhc->split>1) // OUT CSPLIT
2489 + _ifxhc->xfer_len = 0;
2490 + if (_ifxhc->xfer_len > _ifxhc->mps)
2491 + _ifxhc->xfer_len = _ifxhc->mps;
2492 + if (_ifxhc->xfer_len > 188)
2493 + _ifxhc->xfer_len = 188;
2495 + else if(_ifxhc->is_in)
2497 + _ifxhc->short_rw = 0;
2498 + if (_ifxhc->xfer_len > 0)
2500 + if (_ifxhc->xfer_len > max_hc_xfer_size)
2501 + _ifxhc->xfer_len = max_hc_xfer_size - _ifxhc->mps + 1;
2502 + _ifxhc->start_pkt_count = (_ifxhc->xfer_len + _ifxhc->mps - 1) / _ifxhc->mps;
2503 + if (_ifxhc->start_pkt_count > max_hc_pkt_count)
2504 + _ifxhc->start_pkt_count = max_hc_pkt_count;
2506 + else /* Need 1 packet for transfer length of 0. */
2507 + _ifxhc->start_pkt_count = 1;
2508 + _ifxhc->xfer_len = _ifxhc->start_pkt_count * _ifxhc->mps;
2510 + else //non-split out
2512 + if (_ifxhc->xfer_len == 0)
2514 + /*== AVM/BC WK 20110421 ZERO PACKET Workaround: Is not an error ==*/
2515 + //if(_ifxhc->short_rw==0)
2516 + // printk(KERN_INFO "%s() line %d: ZLP write without short_rw set!\n",__func__,__LINE__);
2517 + _ifxhc->start_pkt_count = 1;
2521 + if (_ifxhc->xfer_len > max_hc_xfer_size)
2523 + _ifxhc->start_pkt_count = (max_hc_xfer_size / _ifxhc->mps);
2524 + _ifxhc->xfer_len = _ifxhc->start_pkt_count * _ifxhc->mps;
2528 + _ifxhc->start_pkt_count = (_ifxhc->xfer_len+_ifxhc->mps-1) / _ifxhc->mps;
2529 +// if(_ifxhc->start_pkt_count * _ifxhc->mps == _ifxhc->xfer_len )
2530 +// _ifxhc->start_pkt_count += _ifxhc->short_rw;
2531 + /*== AVM/BC WK 20110421 ZERO PACKET Workaround / check if short_rw is needed ==*/
2532 + if(_ifxhc->start_pkt_count * _ifxhc->mps != _ifxhc->xfer_len )
2533 + _ifxhc->short_rw = 0;
2538 + #ifdef __EN_ISOC__
2539 + if (_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
2541 + /* Set up the initial PID for the transfer. */
2543 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
2545 + if (_ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
2547 + if (_ifxhc->is_in)
2549 + if (_ifxhc->multi_count == 1)
2550 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
2551 + else if (_ifxhc->multi_count == 2)
2552 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
2554 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA2;
2558 + if (_ifxhc->multi_count == 1)
2559 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
2561 + _ifxhc->data_pid_start = IFXUSB_HC_PID_MDATA;
2565 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
2570 + hctsiz.b.xfersize = _ifxhc->xfer_len;
2571 + hctsiz.b.pktcnt = _ifxhc->start_pkt_count;
2572 + hctsiz.b.pid = _ifxhc->data_pid_start;
2574 + ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
2577 + IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n", __func__, _ifxhc->hc_num);
2578 + IFX_DEBUGPL(DBG_HCDV, " Xfer Size: %d\n", hctsiz.b.xfersize);
2579 + IFX_DEBUGPL(DBG_HCDV, " Num Pkts: %d\n" , hctsiz.b.pktcnt);
2580 + IFX_DEBUGPL(DBG_HCDV, " Start PID: %d\n", hctsiz.b.pid);
2581 + IFX_DEBUGPL(DBG_HCDV, " DMA: 0x%08x\n", (uint32_t)(CPHYSADDR( ((uint32_t)(_ifxhc->xfer_buff))+ _ifxhc->xfer_count )));
2582 + ifxusb_wreg(&hc_regs->hcdma, (uint32_t)(CPHYSADDR( ((uint32_t)(_ifxhc->xfer_buff))+ _ifxhc->xfer_count )));
2584 + /* Start the split */
2585 + if (_ifxhc->split>0)
2587 + hcsplt_data_t hcsplt;
2588 + hcsplt.d32 = ifxusb_rreg (&hc_regs->hcsplt);
2589 + hcsplt.b.spltena = 1;
2590 + if (_ifxhc->split>1)
2591 + hcsplt.b.compsplt = 1;
2593 + hcsplt.b.compsplt = 0;
2595 + #ifdef __EN_ISOC__
2596 + if (_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
2597 + hcsplt.b.xactpos = _ifxhc->isoc_xact_pos;
2600 + hcsplt.b.xactpos = IFXUSB_HCSPLIT_XACTPOS_ALL;// if not ISO
2601 + ifxusb_wreg(&hc_regs->hcsplt, hcsplt.d32);
2602 + IFX_DEBUGPL(DBG_HCDV, " SPLIT: XACT_POS:0x%08x\n", hcsplt.d32);
2605 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
2606 +// hcchar.b.multicnt = _ifxhc->multi_count;
2607 + hcchar.b.multicnt = 1;
2610 + _ifxhc->start_hcchar_val = hcchar.d32;
2611 + if (hcchar.b.chdis)
2612 + IFX_WARN("%s: chdis set, channel %d, hcchar 0x%08x\n",
2613 + __func__, _ifxhc->hc_num, hcchar.d32);
2616 + /* Set host channel enable after all other setup is complete. */
2617 + hcchar.b.chen = 1;
2618 + hcchar.b.chdis = 0;
2619 + hcchar.b.epdir = _ifxhc->is_in;
2620 + _ifxhc->hcchar=hcchar.d32;
2622 + IFX_DEBUGPL(DBG_HCDV, " HCCHART: 0x%08x\n", _ifxhc->hcchar);
2624 + /* == 20110901 AVM/WK Fix: Clear IRQ flags in any case ==*/
2626 + hcint_data_t hcint= { .d32=0 };
2627 + hcint.d32 =0xFFFFFFFF;
2628 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
2631 + if(_ifxhc->wait_for_sof==0)
2633 + hcint_data_t hcint;
2635 + hcint.d32=ifxusb_rreg(&hc_regs->hcintmsk);
2639 + /* == 20110901 AVM/WK Fix: We don't need NOT YET IRQ ==*/
2641 + if(_ifxhc->nak_countdown_r)
2643 + ifxusb_wreg(&hc_regs->hcintmsk, hcint.d32);
2645 + /* AVM WK / BC 20100827
2646 + * MOVED. Oddframe updated inmediatly before write HCChar Register.
2648 + if (_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || _ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
2650 + hfnum.d32 = ifxusb_rreg(&_core_if->host_global_regs->hfnum);
2651 + /* 1 if _next_ frame is odd, 0 if it's even */
2652 + hcchar.b.oddfrm = (hfnum.b.frnum & 0x1) ? 0 : 1;
2653 + _ifxhc->hcchar=hcchar.d32;
2656 + ifxusb_wreg(&hc_regs->hcchar, _ifxhc->hcchar);
2657 +#ifdef __USE_TIMER_4_SOF__
2659 + //activate SOF IRQ
2660 + gint_data_t gintsts = {.d32 = 0};
2661 + gintsts.b.sofintr = 1;
2662 + ifxusb_mreg(&_core_if->core_global_regs->gintmsk,0, gintsts.d32);
2666 + #ifdef __HC_XFER_TIMEOUT__
2667 + /* Start a timer for this transfer. */
2668 + init_timer(&_ifxhc->hc_xfer_timer);
2669 + _ifxhc->hc_xfer_timer.function = hc_xfer_timeout;
2670 + _ifxhc->hc_xfer_timer.core_if = _core_if;
2671 + _ifxhc->hc_xfer_timer.hc = _ifxhc;
2672 + _ifxhc->hc_xfer_timer.data = (unsigned long)(&_ifxhc->hc_xfer_info);
2673 + _ifxhc->hc_xfer_timer.expires = jiffies + (HZ*10);
2674 + add_timer(&_ifxhc->hc_xfer_timer);
2679 + \brief Attempts to halt a host channel. This function should only be called
2680 + to abort a transfer in DMA mode. Under normal circumstances in DMA mode, the
2681 + controller halts the channel when the transfer is complete or a condition
2682 + occurs that requires application intervention.
2684 + In DMA mode, always sets the Channel Enable and Channel Disable bits of the
2685 + HCCHARn register. The controller ensures there is space in the request
2686 + queue before submitting the halt request.
2688 + Some time may elapse before the core flushes any posted requests for this
2689 + host channel and halts. The Channel Halted interrupt handler completes the
2690 + deactivation of the host channel.
2692 +void ifxhcd_hc_halt(ifxusb_core_if_t *_core_if,
2693 + ifxhcd_hc_t *_ifxhc,
2694 + ifxhcd_halt_status_e _halt_status)
2696 + hcchar_data_t hcchar;
2697 + ifxusb_hc_regs_t *hc_regs;
2699 + hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
2701 + WARN_ON(_halt_status == HC_XFER_NO_HALT_STATUS);
2703 + if (_halt_status == HC_XFER_URB_DEQUEUE ||
2704 + _halt_status == HC_XFER_AHB_ERR)
2707 + * Disable all channel interrupts except Ch Halted. The URBD
2708 + * and EPQH state associated with this transfer has been cleared
2709 + * (in the case of URB_DEQUEUE), so the channel needs to be
2710 + * shut down carefully to prevent crashes.
2712 + hcint_data_t hcintmsk;
2714 + hcintmsk.b.chhltd = 1;
2715 + ifxusb_wreg(&hc_regs->hcintmsk, hcintmsk.d32);
2718 + * Make sure no other interrupts besides halt are currently
2719 + * pending. Handling another interrupt could cause a crash due
2720 + * to the URBD and EPQH state.
2722 + ifxusb_wreg(&hc_regs->hcint, ~hcintmsk.d32);
2725 + * Make sure the halt status is set to URB_DEQUEUE or AHB_ERR
2726 + * even if the channel was already halted for some other
2729 + _ifxhc->halt_status = _halt_status;
2731 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
2732 + if (hcchar.b.chen == 0)
2735 + * The channel is either already halted or it hasn't
2736 + * started yet. In DMA mode, the transfer may halt if
2737 + * it finishes normally or a condition occurs that
2738 + * requires driver intervention. Don't want to halt
2739 + * the channel again. In either Slave or DMA mode,
2740 + * it's possible that the transfer has been assigned
2741 + * to a channel, but not started yet when an URB is
2742 + * dequeued. Don't want to halt a channel that hasn't
2749 + if (_ifxhc->halting)
2752 + * A halt has already been issued for this channel. This might
2753 + * happen when a transfer is aborted by a higher level in
2757 + IFX_PRINT("*** %s: Channel %d, _hc->halting already set ***\n",
2758 + __func__, _ifxhc->hc_num);
2760 + //ifxusb_dump_global_registers(_core_if); */
2761 + //ifxusb_dump_host_registers(_core_if); */
2764 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
2765 + /* == AVM/WK 20100709 halt channel only if enabled ==*/
2766 + if (hcchar.b.chen) {
2767 + _ifxhc->halting = 1;
2768 + hcchar.b.chdis = 1;
2770 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
2771 + _ifxhc->halt_status = _halt_status;
2774 + IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n" , __func__, _ifxhc->hc_num);
2775 + IFX_DEBUGPL(DBG_HCDV, " hcchar: 0x%08x\n" , hcchar.d32);
2776 + IFX_DEBUGPL(DBG_HCDV, " halting: %d\n" , _ifxhc->halting);
2777 + IFX_DEBUGPL(DBG_HCDV, " halt_status: %d\n" , _ifxhc->halt_status);
2783 + \brief Clears a host channel.
2785 +void ifxhcd_hc_cleanup(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc)
2787 + ifxusb_hc_regs_t *hc_regs;
2789 + _ifxhc->xfer_started = 0;
2791 + * Clear channel interrupt enables and any unhandled channel interrupt
2794 + hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
2795 + ifxusb_wreg(&hc_regs->hcintmsk, 0);
2796 + ifxusb_wreg(&hc_regs->hcint, 0xFFFFFFFF);
2798 + #ifdef __HC_XFER_TIMEOUT__
2799 + del_timer(&_ifxhc->hc_xfer_timer);
2803 + hcchar_data_t hcchar;
2804 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
2805 + if (hcchar.b.chdis)
2806 + IFX_WARN("%s: chdis set, channel %d, hcchar 0x%08x\n", __func__, _ifxhc->hc_num, hcchar.d32);
2819 + static void dump_urb_info(struct urb *_urb, char* _fn_name)
2821 + IFX_PRINT("%s, urb %p\n" , _fn_name, _urb);
2822 + IFX_PRINT(" Device address: %d\n", usb_pipedevice(_urb->pipe));
2823 + IFX_PRINT(" Endpoint: %d, %s\n" , usb_pipeendpoint(_urb->pipe),
2824 + (usb_pipein(_urb->pipe) ? "IN" : "OUT"));
2825 + IFX_PRINT(" Endpoint type: %s\n",
2826 + ({ char *pipetype;
2827 + switch (usb_pipetype(_urb->pipe)) {
2828 + case PIPE_CONTROL: pipetype = "CONTROL"; break;
2829 + case PIPE_BULK: pipetype = "BULK"; break;
2830 + case PIPE_INTERRUPT: pipetype = "INTERRUPT"; break;
2831 + case PIPE_ISOCHRONOUS: pipetype = "ISOCHRONOUS"; break;
2832 + default: pipetype = "UNKNOWN"; break;
2836 + IFX_PRINT(" Speed: %s\n",
2838 + switch (_urb->dev->speed) {
2839 + case USB_SPEED_HIGH: speed = "HIGH"; break;
2840 + case USB_SPEED_FULL: speed = "FULL"; break;
2841 + case USB_SPEED_LOW: speed = "LOW"; break;
2842 + default: speed = "UNKNOWN"; break;
2846 + IFX_PRINT(" Max packet size: %d\n",
2847 + usb_maxpacket(_urb->dev, _urb->pipe, usb_pipeout(_urb->pipe)));
2848 + IFX_PRINT(" Data buffer length: %d\n", _urb->transfer_buffer_length);
2849 + IFX_PRINT(" Transfer buffer: %p, Transfer DMA: %p\n",
2850 + _urb->transfer_buffer, (void *)_urb->transfer_dma);
2851 + IFX_PRINT(" Setup buffer: %p, Setup DMA: %p\n",
2852 + _urb->setup_packet, (void *)_urb->setup_dma);
2853 + IFX_PRINT(" Interval: %d\n", _urb->interval);
2854 + if (usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
2857 + for (i = 0; i < _urb->number_of_packets; i++)
2859 + IFX_PRINT(" ISO Desc %d:\n", i);
2860 + IFX_PRINT(" offset: %d, length %d\n",
2861 + _urb->iso_frame_desc[i].offset,
2862 + _urb->iso_frame_desc[i].length);
2867 + static void dump_channel_info(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh)
2869 + if (_epqh->hc != NULL)
2871 + ifxhcd_hc_t *hc = _epqh->hc;
2872 + struct list_head *item;
2873 + ifxhcd_epqh_t *epqh_item;
2875 + ifxusb_hc_regs_t *hc_regs;
2877 + hcchar_data_t hcchar;
2878 + hcsplt_data_t hcsplt;
2879 + hctsiz_data_t hctsiz;
2882 + hc_regs = _ifxhcd->core_if.hc_regs[hc->hc_num];
2883 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
2884 + hcsplt.d32 = ifxusb_rreg(&hc_regs->hcsplt);
2885 + hctsiz.d32 = ifxusb_rreg(&hc_regs->hctsiz);
2886 + hcdma = ifxusb_rreg(&hc_regs->hcdma);
2888 + IFX_PRINT(" Assigned to channel %d:\n" , hc->hc_num);
2889 + IFX_PRINT(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar.d32, hcsplt.d32);
2890 + IFX_PRINT(" hctsiz 0x%08x, hcdma 0x%08x\n" , hctsiz.d32, hcdma);
2891 + IFX_PRINT(" dev_addr: %d, ep_num: %d, is_in: %d\n",
2892 + hc->dev_addr, hc->ep_num, hc->is_in);
2893 + IFX_PRINT(" ep_type: %d\n" , hc->ep_type);
2894 + IFX_PRINT(" max_packet_size: %d\n", hc->mps);
2895 + IFX_PRINT(" data_pid_start: %d\n" , hc->data_pid_start);
2896 + IFX_PRINT(" xfer_started: %d\n" , hc->xfer_started);
2897 + IFX_PRINT(" halt_status: %d\n" , hc->halt_status);
2898 + IFX_PRINT(" xfer_buff: %p\n" , hc->xfer_buff);
2899 + IFX_PRINT(" xfer_len: %d\n" , hc->xfer_len);
2900 + IFX_PRINT(" epqh: %p\n" , hc->epqh);
2901 + IFX_PRINT(" NP Active:\n");
2902 + list_for_each(item, &_ifxhcd->epqh_np_active)
2904 + epqh_item = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
2905 + IFX_PRINT(" %p\n", epqh_item);
2907 + IFX_PRINT(" NP Ready:\n");
2908 + list_for_each(item, &_ifxhcd->epqh_np_ready)
2910 + epqh_item = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
2911 + IFX_PRINT(" %p\n", epqh_item);
2913 + IFX_PRINT(" INTR Active:\n");
2914 + list_for_each(item, &_ifxhcd->epqh_intr_active)
2916 + epqh_item = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
2917 + IFX_PRINT(" %p\n", epqh_item);
2919 + IFX_PRINT(" INTR Ready:\n");
2920 + list_for_each(item, &_ifxhcd->epqh_intr_ready)
2922 + epqh_item = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
2923 + IFX_PRINT(" %p\n", epqh_item);
2925 + #ifdef __EN_ISOC__
2926 + IFX_PRINT(" ISOC Active:\n");
2927 + list_for_each(item, &_ifxhcd->epqh_isoc_active)
2929 + epqh_item = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
2930 + IFX_PRINT(" %p\n", epqh_item);
2932 + IFX_PRINT(" ISOC Ready:\n");
2933 + list_for_each(item, &_ifxhcd->epqh_isoc_ready)
2935 + epqh_item = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
2936 + IFX_PRINT(" %p\n", epqh_item);
2939 + IFX_PRINT(" Standby:\n");
2940 + list_for_each(item, &_ifxhcd->epqh_stdby)
2942 + epqh_item = list_entry(item, ifxhcd_epqh_t, epqh_list_entry);
2943 + IFX_PRINT(" %p\n", epqh_item);
2951 + \brief This function writes a packet into the Tx FIFO associated with the Host
2952 + Channel. For a channel associated with a non-periodic EP, the non-periodic
2953 + Tx FIFO is written. For a channel associated with a periodic EP, the
2954 + periodic Tx FIFO is written. This function should only be called in Slave
2957 + Upon return the xfer_buff and xfer_count fields in _hc are incremented by
2958 + then number of bytes written to the Tx FIFO.
2961 +#ifdef __ENABLE_DUMP__
2962 + void ifxhcd_dump_state(ifxhcd_hcd_t *_ifxhcd)
2966 + num_channels = _ifxhcd->core_if.params.host_channels;
2968 + IFX_PRINT("************************************************************\n");
2969 + IFX_PRINT("HCD State:\n");
2970 + IFX_PRINT(" Num channels: %d\n", num_channels);
2971 + for (i = 0; i < num_channels; i++) {
2972 + ifxhcd_hc_t *hc = &_ifxhcd->ifxhc[i];
2973 + IFX_PRINT(" Channel %d:\n", hc->hc_num);
2974 + IFX_PRINT(" dev_addr: %d, ep_num: %d, ep_is_in: %d\n",
2975 + hc->dev_addr, hc->ep_num, hc->is_in);
2976 + IFX_PRINT(" speed: %d\n" , hc->speed);
2977 + IFX_PRINT(" ep_type: %d\n" , hc->ep_type);
2978 + IFX_PRINT(" mps: %d\n", hc->mps);
2979 + IFX_PRINT(" data_pid_start: %d\n" , hc->data_pid_start);
2980 + IFX_PRINT(" xfer_started: %d\n" , hc->xfer_started);
2981 + IFX_PRINT(" xfer_buff: %p\n" , hc->xfer_buff);
2982 + IFX_PRINT(" xfer_len: %d\n" , hc->xfer_len);
2983 + IFX_PRINT(" xfer_count: %d\n" , hc->xfer_count);
2984 + IFX_PRINT(" halting: %d\n" , hc->halting);
2985 + IFX_PRINT(" halt_status: %d\n" , hc->halt_status);
2986 + IFX_PRINT(" split: %d\n" , hc->split);
2987 + IFX_PRINT(" hub_addr: %d\n" , hc->hub_addr);
2988 + IFX_PRINT(" port_addr: %d\n" , hc->port_addr);
2989 + #ifdef __EN_ISOC__
2990 + IFX_PRINT(" isoc_xact_pos: %d\n" , hc->isoc_xact_pos);
2992 + IFX_PRINT(" epqh: %p\n" , hc->epqh);
2993 + IFX_PRINT(" short_rw: %d\n" , hc->short_rw);
2994 + IFX_PRINT(" do_ping: %d\n" , hc->do_ping);
2995 + IFX_PRINT(" control_phase: %d\n" , hc->control_phase);
2996 + IFX_PRINT(" pkt_count_limit: %d\n", hc->epqh->pkt_count_limit);
2997 + IFX_PRINT(" start_pkt_count: %d\n" , hc->start_pkt_count);
2999 + IFX_PRINT("************************************************************\n");
3002 +#endif //__ENABLE_DUMP__
3005 +++ b/drivers/usb/ifxhcd/ifxhcd.h
3007 +/*****************************************************************************
3008 + ** FILE NAME : ifxhcd.h
3009 + ** PROJECT : IFX USB sub-system V3
3010 + ** MODULES : IFX USB sub-system Host and Device driver
3011 + ** SRC VERSION : 1.0
3012 + ** DATE : 1/Jan/2009
3013 + ** AUTHOR : Chen, Howard
3014 + ** DESCRIPTION : This file contains the structures, constants, and interfaces for
3015 + ** the Host Contoller Driver (HCD).
3017 + ** The Host Controller Driver (HCD) is responsible for translating requests
3018 + ** from the USB Driver into the appropriate actions on the IFXUSB controller.
3019 + ** It isolates the USBD from the specifics of the controller by providing an
3020 + ** API to the USBD.
3023 + ** REFERENCE : Synopsys DWC-OTG Driver 2.7
3025 + ** Version Control Section **
3029 + ** $Log$ Revision history
3030 +*****************************************************************************/
3033 + \defgroup IFXUSB_HCD HCD Interface
3034 + \ingroup IFXUSB_DRIVER_V3
3035 + \brief The Host Controller Driver (HCD) is responsible for translating requests
3036 + from the USB Driver into the appropriate actions on the IFXUSB controller.
3037 + It isolates the USBD from the specifics of the controller by providing an
3044 + \ingroup IFXUSB_DRIVER_V3
3045 + \brief This file contains the structures, constants, and interfaces for
3046 + the Host Contoller Driver (HCD).
3049 +#if !defined(__IFXHCD_H__)
3050 +#define __IFXHCD_H__
3052 +#include <linux/list.h>
3053 +#include <linux/usb.h>
3055 +#ifdef __USE_TIMER_4_SOF__
3056 +#include <linux/hrtimer.h>
3058 +#include <linux/usb/hcd.h>
3060 +#include "ifxusb_cif.h"
3061 +#include "ifxusb_plat.h"
3066 + \addtogroup IFXUSB_HCD
3070 +/* Phases for control transfers.*/
3071 +typedef enum ifxhcd_control_phase {
3072 + IFXHCD_CONTROL_SETUP,
3073 + IFXHCD_CONTROL_DATA,
3074 + IFXHCD_CONTROL_STATUS
3075 +} ifxhcd_control_phase_e;
3077 +/* Reasons for halting a host channel. */
3078 +typedef enum ifxhcd_halt_status
3080 + HC_XFER_NO_HALT_STATUS, // Initial
3081 + HC_XFER_COMPLETE, // Xact complete without error, upward
3082 + HC_XFER_URB_COMPLETE, // Xfer complete without error, short upward
3083 + HC_XFER_STALL, // HC stopped abnormally, upward/downward
3084 + HC_XFER_XACT_ERR, // HC stopped abnormally, upward
3085 + HC_XFER_FRAME_OVERRUN, // HC stopped abnormally, upward
3086 + HC_XFER_BABBLE_ERR, // HC stopped abnormally, upward
3087 + HC_XFER_AHB_ERR, // HC stopped abnormally, upward
3088 + HC_XFER_DATA_TOGGLE_ERR,
3089 + HC_XFER_URB_DEQUEUE, // HC stopper manually, downward
3090 + HC_XFER_NAK // HC stopped by nak monitor, downward
3091 +} ifxhcd_halt_status_e;
3093 +struct ifxhcd_urbd;
3095 +struct ifxhcd_epqh ;
3099 + \brief A URB Descriptor (URBD) holds the state of a bulk, control,
3100 + interrupt, or isochronous transfer. A single URBD is created for each URB
3101 + (of one of these types) submitted to the HCD. The transfer associated with
3102 + a URBD may require one or multiple transactions.
3104 + A URBD is linked to a EP Queue Head, which is entered in either the
3105 + isoc, intr or non-periodic schedule for execution. When a URBD is chosen for
3106 + execution, some or all of its transactions may be executed. After
3107 + execution, the state of the URBD is updated. The URBD may be retired if all
3108 + its transactions are complete or if an error occurred. Otherwise, it
3109 + remains in the schedule so more transactions can be executed later.
3111 +typedef struct ifxhcd_urbd {
3112 + struct list_head urbd_list_entry; // Hook for EPQH->urbd_list and ifxhcd->urbd_complete_list
3113 + struct urb *urb; /*!< URB for this transfer */
3115 + // struct list_head urb_list;
3116 + // struct list_head anchor_list;
3117 + // struct usb_anchor * anchor;
3118 + // struct usb_device * dev;
3119 + // struct usb_host_endpoint * ep;
3120 + // unsigned int pipe;
3122 + // unsigned int transfer_flags;
3123 + // void * transfer_buffer;
3124 + // dma_addr_t transfer_dma;
3125 + // u32 transfer_buffer_length;
3126 + // u32 actual_length;
3127 + // unsigned char * setup_packet;
3128 + // dma_addr_t setup_dma;
3129 + // int start_frame;
3130 + // int number_of_packets;
3132 + // int error_count;
3133 + // void * context;
3134 + // usb_complete_t complete;
3135 + // struct usb_iso_packet_descriptor iso_frame_desc[0];
3137 + //urb_list For use by current owner of the URB.
3138 + //anchor_list membership in the list of an anchor
3139 + //anchor to anchor URBs to a common mooring
3140 + //dev Identifies the USB device to perform the request.
3141 + //ep Points to the endpoint's data structure. Will
3142 + // eventually replace pipe.
3143 + //pipe Holds endpoint number, direction, type, and more.
3144 + // Create these values with the eight macros available; u
3145 + // sb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is
3146 + // "ctrl", "bulk", "int" or "iso". For example
3147 + // usb_sndbulkpipe or usb_rcvintpipe. Endpoint numbers
3148 + // range from zero to fifteen. Note that "in" endpoint two
3149 + // is a different endpoint (and pipe) from "out" endpoint
3150 + // two. The current configuration controls the existence,
3151 + // type, and maximum packet size of any given endpoint.
3152 + //status This is read in non-iso completion functions to get
3153 + // the status of the particular request. ISO requests
3154 + // only use it to tell whether the URB was unlinked;
3155 + // detailed status for each frame is in the fields of
3156 + // the iso_frame-desc.
3157 + //transfer_flags A variety of flags may be used to affect how URB
3158 + // submission, unlinking, or operation are handled.
3159 + // Different kinds of URB can use different flags.
3160 + // URB_SHORT_NOT_OK
3162 + // URB_NO_TRANSFER_DMA_MAP
3163 + // URB_NO_SETUP_DMA_MAP
3165 + // URB_ZERO_PACKET
3166 + // URB_NO_INTERRUPT
3167 + //transfer_buffer This identifies the buffer to (or from) which the I/O
3168 + // request will be performed (unless URB_NO_TRANSFER_DMA_MAP
3169 + // is set). This buffer must be suitable for DMA; allocate it
3170 + // with kmalloc or equivalent. For transfers to "in"
3171 + // endpoints, contents of this buffer will be modified. This
3172 + // buffer is used for the data stage of control transfers.
3173 + //transfer_dma When transfer_flags includes URB_NO_TRANSFER_DMA_MAP, the
3174 + // device driver is saying that it provided this DMA address,
3175 + // which the host controller driver should use in preference
3176 + // to the transfer_buffer.
3177 + //transfer_buffer_length How big is transfer_buffer. The transfer may be broken
3178 + // up into chunks according to the current maximum packet size
3179 + // for the endpoint, which is a function of the configuration
3180 + // and is encoded in the pipe. When the length is zero, neither
3181 + // transfer_buffer nor transfer_dma is used.
3182 + //actual_length This is read in non-iso completion functions, and it tells
3183 + // how many bytes (out of transfer_buffer_length) were transferred.
3184 + // It will normally be the same as requested, unless either an error
3185 + // was reported or a short read was performed. The URB_SHORT_NOT_OK
3186 + // transfer flag may be used to make such short reads be reported
3188 + //setup_packet Only used for control transfers, this points to eight bytes of
3189 + // setup data. Control transfers always start by sending this data
3190 + // to the device. Then transfer_buffer is read or written, if needed.
3191 + //setup_dma For control transfers with URB_NO_SETUP_DMA_MAP set, the device
3192 + // driver has provided this DMA address for the setup packet. The
3193 + // host controller driver should use this in preference to setup_packet.
3194 + //start_frame Returns the initial frame for isochronous transfers.
3195 + //number_of_packets Lists the number of ISO transfer buffers.
3196 + //interval Specifies the polling interval for interrupt or isochronous transfers.
3197 + // The units are frames (milliseconds) for for full and low speed devices,
3198 + // and microframes (1/8 millisecond) for highspeed ones.
3199 + //error_count Returns the number of ISO transfers that reported errors.
3200 + //context For use in completion functions. This normally points to request-specific
3201 + // driver context.
3202 + //complete Completion handler. This URB is passed as the parameter to the completion
3203 + // function. The completion function may then do what it likes with the URB,
3204 + // including resubmitting or freeing it.
3205 + //iso_frame_desc[0] Used to provide arrays of ISO transfer buffers and to collect the transfer
3206 + // status for each buffer.
3208 + struct ifxhcd_epqh *epqh;
3209 + // Actual data portion, not SETUP or STATUS in case of CTRL XFER
3211 + uint8_t *setup_buff; /*!< Pointer to the entire transfer buffer. (CPU accessable)*/
3212 + uint8_t *xfer_buff; /*!< Pointer to the entire transfer buffer. (CPU accessable)*/
3213 + uint32_t xfer_len; /*!< Total number of bytes to transfer in this xfer. */
3214 + unsigned is_in :1;
3215 + unsigned is_active:1;
3218 + uint8_t error_count; /*!< Holds the number of bus errors that have occurred for a transaction
3219 + within this transfer.
3221 + /*== AVM/BC 20101111 Needed for URB Complete List ==*/
3223 + // For ISOC XFER only
3224 + #ifdef __EN_ISOC__
3225 + int isoc_frame_index; /*!< Index of the next frame descriptor for an isochronous transfer. A
3226 + frame descriptor describes the buffer position and length of the
3227 + data to be transferred in the next scheduled (micro)frame of an
3228 + isochronous transfer. It also holds status for that transaction.
3229 + The frame index starts at 0.
3231 + // For SPLITed ISOC XFER only
3232 + uint8_t isoc_split_pos; /*!< Position of the ISOC split on full/low speed */
3233 + uint16_t isoc_split_offset;/*!< Position of the ISOC split in the buffer for the current frame */
3238 + \brief A EP Queue Head (EPQH) holds the static characteristics of an endpoint and
3239 + maintains a list of transfers (URBDs) for that endpoint. A EPQH structure may
3240 + be entered in either the isoc, intr or non-periodic schedule.
3243 +typedef struct ifxhcd_epqh {
3244 + struct list_head epqh_list_entry; // Hook for EP Queues
3245 + struct list_head urbd_list; /*!< List of URBDs for this EPQH. */
3246 + struct ifxhcd_hc *hc; /*!< Host channel currently processing transfers for this EPQH. */
3247 + struct ifxhcd_urbd *urbd; /*!< URBD currently assigned to a host channel for this EPQH. */
3248 + struct usb_host_endpoint *sysep;
3249 + uint8_t ep_type; /*!< Endpoint type. One of the following values:
3250 + - IFXUSB_EP_TYPE_CTRL
3251 + - IFXUSB_EP_TYPE_ISOC
3252 + - IFXUSB_EP_TYPE_BULK
3253 + - IFXUSB_EP_TYPE_INTR
3255 + uint16_t mps; /*!< wMaxPacketSize Field of Endpoint Descriptor. */
3257 + /* == AVM/WK 20100710 Fix - Use toggle of usbcore ==*/
3258 + /*uint8_t data_toggle;*/ /*!< Determines the PID of the next data packet
3259 + One of the following values:
3260 + - IFXHCD_HC_PID_DATA0
3261 + - IFXHCD_HC_PID_DATA1
3263 + uint8_t is_active;
3265 + uint8_t pkt_count_limit;
3266 + #ifdef __EPQD_DESTROY_TIMEOUT__
3267 + struct timer_list destroy_timer;
3270 + uint16_t wait_for_sof;
3271 + uint8_t need_split; /*!< Full/low speed endpoint on high-speed hub requires split. */
3272 + uint16_t interval; /*!< Interval between transfers in (micro)frames. (for INTR)*/
3274 + uint16_t period_counter; /*!< Interval between transfers in (micro)frames. */
3275 + uint8_t period_do;
3277 + uint8_t aligned_checked;
3279 + #if defined(__UNALIGNED_BUFFER_ADJ__)
3280 + uint8_t using_aligned_setup;
3281 + uint8_t *aligned_setup;
3282 + uint8_t using_aligned_buf;
3283 + uint8_t *aligned_buf;
3284 + unsigned aligned_buf_len : 19;
3287 + uint8_t *dump_buf;
3291 +#if defined(__HC_XFER_TIMEOUT__)
3292 + struct ifxusb_core_if;
3294 + typedef struct hc_xfer_info
3296 + struct ifxusb_core_if *core_if;
3297 + struct ifxhcd_hc *hc;
3299 +#endif //defined(__HC_XFER_TIMEOUT__)
3303 + \brief Host channel descriptor. This structure represents the state of a single
3304 + host channel when acting in host mode. It contains the data items needed to
3305 + transfer packets to an endpoint via a host channel.
3307 +typedef struct ifxhcd_hc
3309 + struct list_head hc_list_entry ; // Hook to free hc
3310 + struct ifxhcd_epqh *epqh ; /*!< EP Queue Head for the transfer being processed by this channel. */
3312 + uint8_t hc_num ; /*!< Host channel number used for register address lookup */
3313 + uint8_t *xfer_buff ; /*!< Pointer to the entire transfer buffer. */
3314 + uint32_t xfer_count ; /*!< Number of bytes transferred so far. The offset of the begin of the buf */
3315 + uint32_t xfer_len ; /*!< Total number of bytes to transfer in this xfer. */
3316 + uint16_t start_pkt_count ; /*!< Packet count at start of transfer. Used to calculate the actual xfer size*/
3317 + ifxhcd_halt_status_e halt_status; /*!< Reason for halting the host channel. */
3319 + unsigned dev_addr : 7; /*!< Device to access */
3320 + unsigned ep_num : 4; /*!< EP to access */
3321 + unsigned is_in : 1; /*!< EP direction. 0: OUT, 1: IN */
3322 + unsigned speed : 2; /*!< EP speed. */
3323 + unsigned ep_type : 2; /*!< Endpoint type. */
3324 + unsigned mps :11; /*!< Max packet size in bytes */
3325 + unsigned data_pid_start : 2; /*!< PID for initial transaction. */
3326 + unsigned do_ping : 1; /*!< Set to 1 to indicate that a PING request should be issued on this
3327 + channel. If 0, process normally.
3330 + unsigned xfer_started : 1; /*!< Flag to indicate whether the transfer has been started. Set to 1 if
3331 + it has been started, 0 otherwise.
3333 + unsigned halting : 1; /*!< Set to 1 if the host channel has been halted, but the core is not
3334 + finished flushing queued requests. Otherwise 0.
3336 + unsigned short_rw : 1; /*!< When Tx, means termination needed.
3337 + When Rx, indicate Short Read */
3338 + /* Split settings for the host channel */
3339 + unsigned split : 2; /*!< Split: 0-Non Split, 1-SSPLIT, 2&3 CSPLIT */
3341 + /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
3342 + unsigned nyet_count;
3345 + unsigned nak_retry_r : 16;
3346 + unsigned nak_retry : 16;
3347 + #define nak_retry_max 40000
3348 + unsigned nak_countdown : 8;
3349 + unsigned nak_countdown_r: 8;
3350 + #define nak_countdown_max 1
3352 + uint16_t wait_for_sof;
3353 + ifxhcd_control_phase_e control_phase; /*!< Current phase for control transfers (Setup, Data, or Status). */
3354 + uint32_t ssplit_out_xfer_count; /*!< How many bytes transferred during SSPLIT OUT */
3356 + uint32_t start_hcchar_val;
3358 + #ifdef __HC_XFER_TIMEOUT__
3359 + hc_xfer_info_t hc_xfer_info;
3360 + struct timer_list hc_xfer_timer;
3364 + /* Split settings for the host channel */
3365 + uint8_t hub_addr; /*!< Address of high speed hub */
3366 + uint8_t port_addr; /*!< Port of the low/full speed device */
3367 + #ifdef __EN_ISOC__
3368 + uint8_t isoc_xact_pos; /*!< Split transaction position */
3374 + \brief This structure holds the state of the HCD, including the non-periodic and
3375 + periodic schedules.
3377 +typedef struct ifxhcd_hcd
3379 + struct device *dev;
3380 + struct hc_driver hc_driver;
3381 + ifxusb_core_if_t core_if; /*!< Pointer to the core interface structure. */
3382 + struct usb_hcd *syshcd;
3384 + volatile union ifxhcd_internal_flags
3389 + unsigned port_connect_status_change : 1;
3390 + unsigned port_connect_status : 1;
3391 + unsigned port_reset_change : 1;
3392 + unsigned port_enable_change : 1;
3393 + unsigned port_suspend_change : 1;
3394 + unsigned port_over_current_change : 1;
3395 + unsigned reserved : 27;
3397 + } flags; /*!< Internal HCD Flags */
3399 + struct ifxhcd_hc ifxhc[MAX_EPS_CHANNELS]; /*!< Array of pointers to the host channel descriptors. Allows accessing
3400 + a host channel descriptor given the host channel number. This is
3401 + useful in interrupt handlers.
3403 + struct list_head free_hc_list; /*!< Free host channels in the controller. This is a list of ifxhcd_hc_t items. */
3404 + uint8_t *status_buf; /*!< Buffer to use for any data received during the status phase of a
3405 + control transfer. Normally no data is transferred during the status
3406 + phase. This buffer is used as a bit bucket.
3408 + #define IFXHCD_STATUS_BUF_SIZE 64
3410 + struct list_head epqh_np_active; // with URBD, with HC
3411 + struct list_head epqh_np_ready; // with URBD, No HC
3413 + struct list_head epqh_intr_active; // with URBD, with HC
3414 + struct list_head epqh_intr_ready; // with URBD, no pass, No HC
3416 + #ifdef __EN_ISOC__
3417 + struct list_head epqh_isoc_active; // with URBD, with HC
3418 + struct list_head epqh_isoc_ready; // with URBD, no pass, No HC
3421 + /*== AVM/BC 20101111 URB Complete List ==*/
3422 + struct list_head urbd_complete_list;
3424 + struct list_head epqh_stdby;
3426 + /* AVM/BC 20101111 flags removed */
3427 + //unsigned process_channels_in_use : 1;
3428 + //unsigned select_eps_in_use : 1;
3430 + struct tasklet_struct select_eps; /*!< Tasket to do a reset */
3431 + uint32_t lastframe;
3433 +#ifdef __USE_TIMER_4_SOF__
3434 + struct hrtimer hr_timer;
3438 +/* Gets the ifxhcd_hcd from a struct usb_hcd */
3439 +static inline ifxhcd_hcd_t *syshcd_to_ifxhcd(struct usb_hcd *syshcd)
3441 + return (ifxhcd_hcd_t *)(syshcd->hcd_priv[0]);
3444 +/* Gets the struct usb_hcd that contains a ifxhcd_hcd_t. */
3445 +static inline struct usb_hcd *ifxhcd_to_syshcd(ifxhcd_hcd_t *ifxhcd)
3447 + return (struct usb_hcd *)(ifxhcd->syshcd);
3450 +/*! \brief HCD Create/Destroy Functions */
3452 + extern int ifxhcd_init (ifxhcd_hcd_t *_ifxhcd);
3453 + extern void ifxhcd_remove(ifxhcd_hcd_t *_ifxhcd);
3456 +/*! \brief Linux HC Driver API Functions */
3458 +extern int ifxhcd_start(struct usb_hcd *hcd);
3459 +extern void ifxhcd_stop (struct usb_hcd *hcd);
3460 +extern int ifxhcd_get_frame_number(struct usb_hcd *hcd);
3464 + \brief This function does the setup for a data transfer for a host channel and
3465 + starts the transfer. May be called in either Slave mode or DMA mode. In
3466 + Slave mode, the caller must ensure that there is sufficient space in the
3467 + request queue and Tx Data FIFO.
3469 + For an OUT transfer in Slave mode, it loads a data packet into the
3470 + appropriate FIFO. If necessary, additional data packets will be loaded in
3473 + For an IN transfer in Slave mode, a data packet is requested. The data
3474 + packets are unloaded from the Rx FIFO in the Host ISR. If necessary,
3475 + additional data packets are requested in the Host ISR.
3477 + For a PING transfer in Slave mode, the Do Ping bit is set in the HCTSIZ
3478 + register along with a packet count of 1 and the channel is enabled. This
3479 + causes a single PING transaction to occur. Other fields in HCTSIZ are
3480 + simply set to 0 since no data transfer occurs in this case.
3482 + For a PING transfer in DMA mode, the HCTSIZ register is initialized with
3483 + all the information required to perform the subsequent data transfer. In
3484 + addition, the Do Ping bit is set in the HCTSIZ register. In this case, the
3485 + controller performs the entire PING protocol, then starts the data
3488 + @param _ifxhc Information needed to initialize the host channel. The xfer_len
3489 + value may be reduced to accommodate the max widths of the XferSize and
3490 + PktCnt fields in the HCTSIZn register. The multi_count value may be changed
3491 + to reflect the final xfer_len value.
3493 +extern void ifxhcd_hc_start(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc);
3495 +//extern int ifxhcd_urb_enqueue(struct usb_hcd *_syshcd, struct usb_host_endpoint *_sysep, struct urb *_urb, gfp_t mem_flags);
3496 +//extern int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb);
3497 +extern irqreturn_t ifxhcd_irq(struct usb_hcd *_syshcd);
3498 +int ifxhcd_urb_enqueue( struct usb_hcd *_syshcd,
3499 + /*--- struct usb_host_endpoint *_sysep, Parameter im 2.6.28 entfallen ---*/
3501 + gfp_t _mem_flags);
3502 +int ifxhcd_urb_dequeue( struct usb_hcd *_syshcd,
3503 + struct urb *_urb, int status /* Parameter neu in 2.6.28 */);
3505 +extern void ifxhcd_endpoint_disable(struct usb_hcd *_syshcd, struct usb_host_endpoint *_sysep);
3507 +extern int ifxhcd_hub_status_data(struct usb_hcd *_syshcd, char *_buf);
3508 +extern int ifxhcd_hub_control( struct usb_hcd *_syshcd,
3517 +/*! \brief Transaction Execution Functions */
3519 +extern void ifxhcd_complete_urb (ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status);
3523 +/*! \brief Deferred Transaction Execution Functions */
3526 +/*== AVM/BC 20101111 URB Complete List ==*/
3527 +extern void defer_ifxhcd_complete_urb (ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status);
3530 + \brief Clears the transfer state for a host channel. This function is normally
3531 + called after a transfer is done and the host channel is being released.
3533 +extern void ifxhcd_hc_cleanup(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc);
3536 + \brief Attempts to halt a host channel. This function should only be called in
3537 + Slave mode or to abort a transfer in either Slave mode or DMA mode. Under
3538 + normal circumstances in DMA mode, the controller halts the channel when the
3539 + transfer is complete or a condition occurs that requires application
3542 + In slave mode, checks for a free request queue entry, then sets the Channel
3543 + Enable and Channel Disable bits of the Host Channel Characteristics
3544 + register of the specified channel to intiate the halt. If there is no free
3545 + request queue entry, sets only the Channel Disable bit of the HCCHARn
3546 + register to flush requests for this channel. In the latter case, sets a
3547 + flag to indicate that the host channel needs to be halted when a request
3548 + queue slot is open.
3550 + In DMA mode, always sets the Channel Enable and Channel Disable bits of the
3551 + HCCHARn register. The controller ensures there is space in the request
3552 + queue before submitting the halt request.
3554 + Some time may elapse before the core flushes any posted requests for this
3555 + host channel and halts. The Channel Halted interrupt handler completes the
3556 + deactivation of the host channel.
3558 +extern void ifxhcd_hc_halt(ifxusb_core_if_t *_core_if,
3559 + ifxhcd_hc_t *_ifxhc,
3560 + ifxhcd_halt_status_e _halt_status);
3563 + \brief Prepares a host channel for transferring packets to/from a specific
3564 + endpoint. The HCCHARn register is set up with the characteristics specified
3565 + in _ifxhc. Host channel interrupts that may need to be serviced while this
3566 + transfer is in progress are enabled.
3568 +extern void ifxhcd_hc_init(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc);
3571 + \brief This function is called to handle the disconnection of host port.
3573 +int32_t ifxhcd_disconnect(ifxhcd_hcd_t *_ifxhcd);
3576 +/*! \brief Interrupt Handler Functions */
3578 +extern irqreturn_t ifxhcd_oc_irq(int _irq, void *_dev);
3580 +extern int32_t ifxhcd_handle_oc_intr(ifxhcd_hcd_t *_ifxhcd);
3581 +extern int32_t ifxhcd_handle_intr (ifxhcd_hcd_t *_ifxhcd);
3585 +/*! \brief Schedule Queue Functions */
3587 +extern ifxhcd_epqh_t *ifxhcd_epqh_create (ifxhcd_hcd_t *_ifxhcd, struct urb *_urb);
3588 +extern void ifxhcd_epqh_free ( ifxhcd_epqh_t *_epqh);
3589 +extern void select_eps (ifxhcd_hcd_t *_ifxhcd);
3590 +extern void process_channels(ifxhcd_hcd_t *_ifxhcd);
3591 +extern void process_channels_sub(ifxhcd_hcd_t *_ifxhcd);
3592 +extern void complete_channel(ifxhcd_hcd_t *_ifxhcd, ifxhcd_hc_t *_ifxhc, ifxhcd_urbd_t *_urbd);
3593 +extern void ifxhcd_epqh_ready(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh);
3594 +extern void ifxhcd_epqh_active(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh);
3595 +extern void ifxhcd_epqh_idle(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh);
3596 +extern void ifxhcd_epqh_idle_periodic(ifxhcd_epqh_t *_epqh);
3597 +extern int ifxhcd_urbd_create (ifxhcd_hcd_t *_ifxhcd,struct urb *_urb);
3600 +/*! \brief Gets the usb_host_endpoint associated with an URB. */
3601 +static inline struct usb_host_endpoint *ifxhcd_urb_to_endpoint(struct urb *_urb)
3603 + struct usb_device *dev = _urb->dev;
3604 + int ep_num = usb_pipeendpoint(_urb->pipe);
3606 + return (usb_pipein(_urb->pipe))?(dev->ep_in[ep_num]):(dev->ep_out[ep_num]);
3610 + * \brief Gets the endpoint number from a _bEndpointAddress argument. The endpoint is
3611 + * qualified with its direction (possible 32 endpoints per device).
3613 +#define ifxhcd_ep_addr_to_endpoint(_bEndpointAddress_) ((_bEndpointAddress_ & USB_ENDPOINT_NUMBER_MASK) | \
3614 + ((_bEndpointAddress_ & USB_DIR_IN) != 0) << 4)
3617 +/* AVM/WK: not needed?
3619 +extern struct usb_device *usb_alloc_dev (struct usb_device *parent, struct usb_bus *, unsigned port);
3620 +extern int usb_add_hcd (struct usb_hcd *syshcd, unsigned int irqnum, unsigned long irqflags);
3621 +extern void usb_remove_hcd (struct usb_hcd *syshcd);
3622 +extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, struct device *dev, char *bus_name);
3623 +extern void usb_hcd_giveback_urb (struct usb_hcd *syshcd, struct urb *urb);
3624 +extern void usb_put_hcd (struct usb_hcd *syshcd);
3625 +extern long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount);
3628 +/** Internal Functions */
3629 +void ifxhcd_dump_state(ifxhcd_hcd_t *_ifxhcd);
3630 +extern char *syserr(int errno);
3632 +/*@}*//*IFXUSB_HCD*/
3634 +#endif // __IFXHCD_H__
3636 +++ b/drivers/usb/ifxhcd/ifxhcd_es.c
3638 +/*****************************************************************************
3639 + ** FILE NAME : ifxhcd_es.c
3640 + ** PROJECT : IFX USB sub-system V3
3641 + ** MODULES : IFX USB sub-system Host and Device driver
3642 + ** SRC VERSION : 1.0
3643 + ** DATE : 1/Jan/2009
3644 + ** AUTHOR : Chen, Howard
3645 + ** DESCRIPTION : The file contain function to enable host mode USB-IF Electrical Test function.
3646 + *****************************************************************************/
3650 + \ingroup IFXUSB_DRIVER_V3
3651 + \brief The file contain function to enable host mode USB-IF Electrical Test function.
3654 +#include <linux/version.h>
3655 +#include "ifxusb_version.h"
3657 +#include <linux/kernel.h>
3659 +#include <linux/errno.h>
3661 +#include <linux/dma-mapping.h>
3663 +#include "ifxusb_plat.h"
3664 +#include "ifxusb_regs.h"
3665 +#include "ifxusb_cif.h"
3666 +#include "ifxhcd.h"
3669 +#ifdef __WITH_HS_ELECT_TST__
3671 + * Quick and dirty hack to implement the HS Electrical Test
3672 + * SINGLE_STEP_GET_DEVICE_DESCRIPTOR feature.
3674 + * This code was copied from our userspace app "hset". It sends a
3675 + * Get Device Descriptor control sequence in two parts, first the
3676 + * Setup packet by itself, followed some time later by the In and
3677 + * Ack packets. Rather than trying to figure out how to add this
3678 + * functionality to the normal driver code, we just hijack the
3679 + * hardware, using these two function to drive the hardware
3684 + void do_setup(ifxusb_core_if_t *_core_if)
3687 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
3688 + ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
3689 + ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
3690 + uint32_t *data_fifo = _core_if->data_fifo[0];
3692 + gint_data_t gintsts;
3693 + hctsiz_data_t hctsiz;
3694 + hcchar_data_t hcchar;
3695 + haint_data_t haint;
3696 + hcint_data_t hcint;
3699 + /* Enable HAINTs */
3700 + ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
3702 + /* Enable HCINTs */
3703 + ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
3705 + /* Read GINTSTS */
3706 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3707 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
3710 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
3711 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
3714 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
3715 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
3718 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3719 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
3722 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
3725 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
3727 + /* Clear GINTSTS */
3728 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
3730 + /* Read GINTSTS */
3731 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3732 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
3735 + * Send Setup packet (Get Device Descriptor)
3738 + /* Make sure channel is disabled */
3739 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3740 + if (hcchar.b.chen) {
3741 + //fprintf(stderr, "Channel already enabled 1, HCCHAR = %08x\n", hcchar.d32);
3742 + hcchar.b.chdis = 1;
3743 + // hcchar.b.chen = 1;
3744 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
3748 + /* Read GINTSTS */
3749 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3750 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
3753 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
3754 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
3757 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
3758 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
3761 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3762 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
3765 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
3768 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
3770 + /* Clear GINTSTS */
3771 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
3773 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3774 + //if (hcchar.b.chen) {
3775 + // fprintf(stderr, "** Channel _still_ enabled 1, HCCHAR = %08x **\n", hcchar.d32);
3781 + hctsiz.b.xfersize = 8;
3782 + hctsiz.b.pktcnt = 1;
3783 + hctsiz.b.pid = IFXUSB_HC_PID_SETUP;
3784 + ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
3787 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3788 + hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
3789 + hcchar.b.epdir = 0;
3790 + hcchar.b.epnum = 0;
3792 + hcchar.b.chen = 1;
3793 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
3795 + /* Fill FIFO with Setup data for Get Device Descriptor */
3796 + ifxusb_wreg(data_fifo++, 0x01000680);
3797 + ifxusb_wreg(data_fifo++, 0x00080000);
3799 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3800 + //fprintf(stderr, "Waiting for HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
3802 + /* Wait for host channel interrupt */
3804 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3805 + } while (gintsts.b.hcintr == 0);
3807 + //fprintf(stderr, "Got HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
3809 + /* Disable HCINTs */
3810 + ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
3812 + /* Disable HAINTs */
3813 + ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
3816 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
3817 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
3820 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
3821 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
3824 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3825 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
3828 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
3831 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
3833 + /* Clear GINTSTS */
3834 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
3836 + /* Read GINTSTS */
3837 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3838 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
3841 + void do_in_ack(ifxusb_core_if_t *_core_if)
3844 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
3845 + ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
3846 + ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
3847 + uint32_t *data_fifo = _core_if->data_fifo[0];
3849 + gint_data_t gintsts;
3850 + hctsiz_data_t hctsiz;
3851 + hcchar_data_t hcchar;
3852 + haint_data_t haint;
3853 + hcint_data_t hcint;
3854 + grxsts_data_t grxsts;
3856 + /* Enable HAINTs */
3857 + ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
3859 + /* Enable HCINTs */
3860 + ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
3862 + /* Read GINTSTS */
3863 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3864 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
3867 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
3868 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
3871 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
3872 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
3875 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3876 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
3879 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
3882 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
3884 + /* Clear GINTSTS */
3885 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
3887 + /* Read GINTSTS */
3888 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3889 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
3892 + * Receive Control In packet
3895 + /* Make sure channel is disabled */
3896 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3897 + if (hcchar.b.chen) {
3898 + //fprintf(stderr, "Channel already enabled 2, HCCHAR = %08x\n", hcchar.d32);
3899 + hcchar.b.chdis = 1;
3900 + hcchar.b.chen = 1;
3901 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
3905 + /* Read GINTSTS */
3906 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3907 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
3910 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
3911 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
3914 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
3915 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
3918 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3919 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
3922 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
3925 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
3927 + /* Clear GINTSTS */
3928 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
3930 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3931 + //if (hcchar.b.chen) {
3932 + // fprintf(stderr, "** Channel _still_ enabled 2, HCCHAR = %08x **\n", hcchar.d32);
3938 + hctsiz.b.xfersize = 8;
3939 + hctsiz.b.pktcnt = 1;
3940 + hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
3941 + ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
3944 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
3945 + hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
3946 + hcchar.b.epdir = 1;
3947 + hcchar.b.epnum = 0;
3949 + hcchar.b.chen = 1;
3950 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
3952 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3953 + //fprintf(stderr, "Waiting for RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
3955 + /* Wait for receive status queue interrupt */
3957 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3958 + } while (gintsts.b.rxstsqlvl == 0);
3960 + //fprintf(stderr, "Got RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
3963 + grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
3964 + //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
3966 + /* Clear RXSTSQLVL in GINTSTS */
3968 + gintsts.b.rxstsqlvl = 1;
3969 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
3971 + switch (grxsts.hb.pktsts) {
3972 + case IFXUSB_HSTS_DATA_UPDT:
3973 + /* Read the data into the host buffer */
3974 + if (grxsts.hb.bcnt > 0) {
3976 + int word_count = (grxsts.hb.bcnt + 3) / 4;
3978 + for (i = 0; i < word_count; i++) {
3979 + (void)ifxusb_rreg(data_fifo++);
3983 + //fprintf(stderr, "Received %u bytes\n", (unsigned)grxsts.hb.bcnt);
3987 + //fprintf(stderr, "** Unexpected GRXSTS packet status 1 **\n");
3991 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3992 + //fprintf(stderr, "Waiting for RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
3994 + /* Wait for receive status queue interrupt */
3996 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
3997 + } while (gintsts.b.rxstsqlvl == 0);
3999 + //fprintf(stderr, "Got RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
4002 + grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
4003 + //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
4005 + /* Clear RXSTSQLVL in GINTSTS */
4007 + gintsts.b.rxstsqlvl = 1;
4008 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
4010 + switch (grxsts.hb.pktsts) {
4011 + case IFXUSB_HSTS_XFER_COMP:
4015 + //fprintf(stderr, "** Unexpected GRXSTS packet status 2 **\n");
4019 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4020 + //fprintf(stderr, "Waiting for HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
4022 + /* Wait for host channel interrupt */
4024 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4025 + } while (gintsts.b.hcintr == 0);
4027 + //fprintf(stderr, "Got HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
4030 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
4031 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
4034 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
4035 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
4038 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
4039 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
4042 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
4045 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
4047 + /* Clear GINTSTS */
4048 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
4050 + /* Read GINTSTS */
4051 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4052 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
4054 + // usleep(100000);
4059 + * Send handshake packet
4063 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
4064 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
4067 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
4068 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
4071 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
4072 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
4075 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
4078 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
4080 + /* Clear GINTSTS */
4081 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
4083 + /* Read GINTSTS */
4084 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4085 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
4087 + /* Make sure channel is disabled */
4088 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
4089 + if (hcchar.b.chen) {
4090 + //fprintf(stderr, "Channel already enabled 3, HCCHAR = %08x\n", hcchar.d32);
4091 + hcchar.b.chdis = 1;
4092 + hcchar.b.chen = 1;
4093 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
4097 + /* Read GINTSTS */
4098 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4099 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
4102 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
4103 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
4106 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
4107 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
4110 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
4111 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
4114 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
4117 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
4119 + /* Clear GINTSTS */
4120 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
4122 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
4123 + //if (hcchar.b.chen) {
4124 + // fprintf(stderr, "** Channel _still_ enabled 3, HCCHAR = %08x **\n", hcchar.d32);
4130 + hctsiz.b.xfersize = 0;
4131 + hctsiz.b.pktcnt = 1;
4132 + hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
4133 + ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
4136 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
4137 + hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
4138 + hcchar.b.epdir = 0;
4139 + hcchar.b.epnum = 0;
4141 + hcchar.b.chen = 1;
4142 + ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
4144 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4145 + //fprintf(stderr, "Waiting for HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
4147 + /* Wait for host channel interrupt */
4149 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4150 + } while (gintsts.b.hcintr == 0);
4152 + //fprintf(stderr, "Got HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
4154 + /* Disable HCINTs */
4155 + ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
4157 + /* Disable HAINTs */
4158 + ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
4161 + haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
4162 + //fprintf(stderr, "HAINT: %08x\n", haint.d32);
4165 + hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
4166 + //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
4169 + hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
4170 + //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
4173 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
4176 + ifxusb_wreg(&hc_global_regs->haint, haint.d32);
4178 + /* Clear GINTSTS */
4179 + ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
4181 + /* Read GINTSTS */
4182 + gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
4183 + //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
4185 +#endif //__WITH_HS_ELECT_TST__
4188 +++ b/drivers/usb/ifxhcd/ifxhcd_intr.c
4190 +/*****************************************************************************
4191 + ** FILE NAME : ifxhcd_intr.c
4192 + ** PROJECT : IFX USB sub-system V3
4193 + ** MODULES : IFX USB sub-system Host and Device driver
4194 + ** SRC VERSION : 1.0
4195 + ** DATE : 1/Jan/2009
4196 + ** AUTHOR : Chen, Howard
4197 + ** DESCRIPTION : This file contains the implementation of the HCD Interrupt handlers.
4198 + *****************************************************************************/
4201 + \file ifxhcd_intr.c
4202 + \ingroup IFXUSB_DRIVER_V3
4203 + \brief This file contains the implementation of the HCD Interrupt handlers.
4207 +#include <linux/version.h>
4208 +#include "ifxusb_version.h"
4210 +#include "ifxusb_plat.h"
4211 +#include "ifxusb_regs.h"
4212 +#include "ifxusb_cif.h"
4214 +#include "ifxhcd.h"
4216 +/* AVM/WK 20100520*/
4218 +#error AVM/WK: CONFIG_USB_HOST_IFX_WITH_ISO currently not supported!
4221 +/* Macro used to clear one channel interrupt */
4222 +#define clear_hc_int(_hc_regs_,_intr_) \
4224 + hcint_data_t hcint_clear = {.d32 = 0}; \
4225 + hcint_clear.b._intr_ = 1; \
4226 + ifxusb_wreg(&((_hc_regs_)->hcint), hcint_clear.d32); \
4230 + * Macro used to disable one channel interrupt. Channel interrupts are
4231 + * disabled when the channel is halted or released by the interrupt handler.
4232 + * There is no need to handle further interrupts of that type until the
4233 + * channel is re-assigned. In fact, subsequent handling may cause crashes
4234 + * because the channel structures are cleaned up when the channel is released.
4236 +#define disable_hc_int(_hc_regs_,_intr_) \
4238 + hcint_data_t hcintmsk = {.d32 = 0}; \
4239 + hcintmsk.b._intr_ = 1; \
4240 + ifxusb_mreg(&((_hc_regs_)->hcintmsk), hcintmsk.d32, 0); \
4243 +#define enable_hc_int(_hc_regs_,_intr_) \
4245 + hcint_data_t hcintmsk = {.d32 = 0}; \
4246 + hcintmsk.b._intr_ = 1; \
4247 + ifxusb_mreg(&((_hc_regs_)->hcintmsk),0, hcintmsk.d32); \
4251 + * Save the starting data toggle for the next transfer. The data toggle is
4252 + * saved in the QH for non-control transfers and it's saved in the QTD for
4253 + * control transfers.
4255 +uint8_t read_data_toggle(ifxusb_hc_regs_t *_hc_regs)
4257 + hctsiz_data_t hctsiz;
4258 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
4259 + return(hctsiz.b.pid);
4263 +static void release_channel_dump(ifxhcd_hc_t *ifxhc,
4265 + ifxhcd_epqh_t *epqh,
4266 + ifxhcd_urbd_t *urbd,
4267 + ifxhcd_halt_status_e halt_status)
4270 + printk(KERN_INFO);
4271 + switch (halt_status)
4273 + case HC_XFER_NO_HALT_STATUS:
4274 + printk("HC_XFER_NO_HALT_STATUS");break;
4275 + case HC_XFER_URB_COMPLETE:
4276 + printk("HC_XFER_URB_COMPLETE");break;
4277 + case HC_XFER_AHB_ERR:
4278 + printk("HC_XFER_AHB_ERR");break;
4279 + case HC_XFER_STALL:
4280 + printk("HC_XFER_STALL");break;
4281 + case HC_XFER_BABBLE_ERR:
4282 + printk("HC_XFER_BABBLE_ERR");break;
4283 + case HC_XFER_XACT_ERR:
4284 + printk("HC_XFER_XACT_ERR");break;
4285 + case HC_XFER_URB_DEQUEUE:
4286 + printk("HC_XFER_URB_DEQUEUE");break;
4287 + case HC_XFER_FRAME_OVERRUN:
4288 + printk("HC_XFER_FRAME_OVERRUN");break;
4289 + case HC_XFER_DATA_TOGGLE_ERR:
4290 + printk("HC_XFER_DATA_TOGGLE_ERR");break;
4292 + printk("HC_XFER_NAK");break;
4293 + case HC_XFER_COMPLETE:
4294 + printk("HC_XFER_COMPLETE");break;
4296 + printk("KNOWN");break;
4299 + printk("Ch %d %s%s S%d " , ifxhc->hc_num
4300 + ,(ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL)?"CTRL-":
4301 + ((ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)?"BULK-":
4302 + ((ifxhc->ep_type == IFXUSB_EP_TYPE_INTR)?"INTR-":
4303 + ((ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)?"ISOC-":"????"
4307 + ,(ifxhc->is_in)?"IN":"OUT"
4311 + printk(" [NULL HC] ");
4312 + printk("urb=%p epqh=%p urbd=%p\n",urb,epqh,urbd);
4316 + printk(KERN_INFO " Device address: %d\n", usb_pipedevice(urb->pipe));
4317 + printk(KERN_INFO " Endpoint: %d, %s\n", usb_pipeendpoint(urb->pipe),
4318 + (usb_pipein(urb->pipe) ? "IN" : "OUT"));
4319 + printk(KERN_INFO " Endpoint type: %s\n",
4321 + switch (usb_pipetype(urb->pipe)) {
4322 + case PIPE_CONTROL: pipetype = "CTRL"; break;
4323 + case PIPE_BULK: pipetype = "BULK"; break;
4324 + case PIPE_INTERRUPT: pipetype = "INTR"; break;
4325 + case PIPE_ISOCHRONOUS: pipetype = "ISOC"; break;
4326 + default: pipetype = "????"; break;
4328 + printk(KERN_INFO " Speed: %s\n",
4330 + switch (urb->dev->speed) {
4331 + case USB_SPEED_HIGH: speed = "HS"; break;
4332 + case USB_SPEED_FULL: speed = "FS"; break;
4333 + case USB_SPEED_LOW: speed = "LS"; break;
4334 + default: speed = "????"; break;
4336 + printk(KERN_INFO " Max packet size: %d\n",
4337 + usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)));
4338 + printk(KERN_INFO " Data buffer length: %d\n", urb->transfer_buffer_length);
4339 + printk(KERN_INFO " Transfer buffer: %p, Transfer DMA: %p\n",
4340 + urb->transfer_buffer, (void *)urb->transfer_dma);
4341 + printk(KERN_INFO " Setup buffer: %p, Setup DMA: %p\n",
4342 + urb->setup_packet, (void *)urb->setup_dma);
4343 + printk(KERN_INFO " Interval: %d\n", urb->interval);
4344 + switch (urb->status)
4346 + case HC_XFER_NO_HALT_STATUS:
4347 + printk(KERN_INFO " STATUS:HC_XFER_NO_HALT_STATUS\n");break;
4348 + case HC_XFER_URB_COMPLETE:
4349 + printk(KERN_INFO " STATUS:HC_XFER_URB_COMPLETE\n");break;
4350 + case HC_XFER_AHB_ERR:
4351 + printk(KERN_INFO " STATUS:HC_XFER_AHB_ERR\n");break;
4352 + case HC_XFER_STALL:
4353 + printk(KERN_INFO " STATUS:HC_XFER_STALL\n");break;
4354 + case HC_XFER_BABBLE_ERR:
4355 + printk(KERN_INFO " STATUS:HC_XFER_BABBLE_ERR\n");break;
4356 + case HC_XFER_XACT_ERR:
4357 + printk(KERN_INFO " STATUS:HC_XFER_XACT_ERR\n");break;
4358 + case HC_XFER_URB_DEQUEUE:
4359 + printk(KERN_INFO " STATUS:HC_XFER_URB_DEQUEUE\n");break;
4360 + case HC_XFER_FRAME_OVERRUN:
4361 + printk(KERN_INFO " STATUS:HC_XFER_FRAME_OVERRUN\n");break;
4362 + case HC_XFER_DATA_TOGGLE_ERR:
4363 + printk(KERN_INFO " STATUS:HC_XFER_DATA_TOGGLE_ERR\n");break;
4364 + case HC_XFER_COMPLETE:
4365 + printk(KERN_INFO " STATUS:HC_XFER_COMPLETE\n");break;
4367 + printk(KERN_INFO " STATUS:KNOWN\n");break;
4374 +static void release_channel(ifxhcd_hcd_t *_ifxhcd,
4375 + ifxhcd_hc_t *_ifxhc,
4376 + ifxhcd_halt_status_e _halt_status)
4378 + ifxusb_hc_regs_t *hc_regs = _ifxhcd->core_if.hc_regs[_ifxhc->hc_num];
4379 + struct urb *urb = NULL;
4380 + ifxhcd_epqh_t *epqh = NULL;
4381 + ifxhcd_urbd_t *urbd = NULL;
4383 + IFX_DEBUGPL(DBG_HCDV, " %s: channel %d, halt_status %d\n",
4384 + __func__, _ifxhc->hc_num, _halt_status);
4386 + epqh=_ifxhc->epqh;
4389 + IFX_ERROR("%s epqh=null\n",__func__);
4394 + IFX_ERROR("%s urbd=null\n",__func__);
4399 + IFX_ERROR("%s urb =null\n",__func__);
4401 + /* == AVM/WK 20100710 Fix - Use toggle of usbcore ==*/
4402 + unsigned toggle = (read_data_toggle(hc_regs) == IFXUSB_HC_PID_DATA0)? 0: 1;
4403 + usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), usb_pipeout(urb->pipe), toggle);
4406 + //epqh->data_toggle = read_data_toggle(hc_regs);
4410 + switch (_halt_status)
4412 + case HC_XFER_NO_HALT_STATUS:
4413 + IFX_ERROR("%s: No halt_status, channel %d\n", __func__, _ifxhc->hc_num);
4415 + case HC_XFER_COMPLETE:
4416 + IFX_ERROR("%s: Inavalid halt_status HC_XFER_COMPLETE, channel %d\n", __func__, _ifxhc->hc_num);
4418 + case HC_XFER_URB_COMPLETE:
4419 + case HC_XFER_URB_DEQUEUE:
4420 + case HC_XFER_AHB_ERR:
4421 + case HC_XFER_XACT_ERR:
4422 + case HC_XFER_FRAME_OVERRUN:
4424 + /* == 20110803 AVM/WK FIX set status, if still in progress == */
4425 + if (urb->status == -EINPROGRESS) {
4426 + switch (_halt_status) {
4427 + case HC_XFER_URB_COMPLETE:
4430 + case HC_XFER_URB_DEQUEUE:
4431 + urb->status = -ECONNRESET;
4433 + case HC_XFER_AHB_ERR:
4434 + case HC_XFER_XACT_ERR:
4435 + case HC_XFER_FRAME_OVERRUN:
4436 + urb->status = -EPROTO;
4442 + /*== AVM/BC 20101111 Deferred Complete ==*/
4443 + defer_ifxhcd_complete_urb(_ifxhcd, urbd, urb->status);
4447 + IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
4448 + release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
4451 + ifxhcd_epqh_idle(_ifxhcd, epqh);
4454 + IFX_WARN("WARNING %s():%d epqh=%p\n",__func__,__LINE__,epqh);
4455 + release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
4458 + list_add_tail(&_ifxhc->hc_list_entry, &_ifxhcd->free_hc_list);
4459 + ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
4461 + case HC_XFER_STALL:
4462 + release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
4464 + /*== AVM/BC 20101111 Deferred Complete ==*/
4465 + defer_ifxhcd_complete_urb(_ifxhcd, urbd, -EPIPE);
4467 + IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
4470 +// epqh->data_toggle = 0;
4471 + ifxhcd_epqh_idle(_ifxhcd, epqh);
4474 + IFX_WARN("WARNING %s():%d epqh=%p\n",__func__,__LINE__,epqh);
4475 + list_add_tail(&_ifxhc->hc_list_entry, &_ifxhcd->free_hc_list);
4476 + ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
4479 + release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
4482 + //ifxhcd_complete_urb(_ifxhcd, urbd, -ETIMEDOUT);
4484 + /*== AVM/BC 20101111 Deferred Complete ==*/
4485 + defer_ifxhcd_complete_urb(_ifxhcd, urbd, urb->status);
4488 + IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
4490 + ifxhcd_epqh_idle(_ifxhcd, epqh);
4492 + IFX_WARN("WARNING %s():%d epqh=%p\n",__func__,__LINE__,epqh);
4493 + list_add_tail(&_ifxhc->hc_list_entry, &_ifxhcd->free_hc_list);
4494 + ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
4496 + case HC_XFER_BABBLE_ERR:
4497 + case HC_XFER_DATA_TOGGLE_ERR:
4498 + release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
4500 + /*== AVM/BC 20101111 Deferred Complete ==*/
4501 + defer_ifxhcd_complete_urb(_ifxhcd, urbd, -EOVERFLOW);
4503 + IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
4505 + ifxhcd_epqh_idle(_ifxhcd, epqh);
4507 + IFX_WARN("WARNING %s():%d epqh=%p\n",__func__,__LINE__,epqh);
4508 + list_add_tail(&_ifxhc->hc_list_entry, &_ifxhcd->free_hc_list);
4509 + ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
4512 + select_eps(_ifxhcd);
4516 + * Updates the state of the URB after a Transfer Complete interrupt on the
4517 + * host channel. Updates the actual_length field of the URB based on the
4518 + * number of bytes transferred via the host channel. Sets the URB status
4519 + * if the data transfer is finished.
4521 + * @return 1 if the data transfer specified by the URB is completely finished,
4524 +static int update_urb_state_xfer_comp(ifxhcd_hc_t *_ifxhc,
4525 + ifxusb_hc_regs_t *_hc_regs,
4527 + ifxhcd_urbd_t *_urbd)
4529 + int xfer_done = 0;
4531 + if (_ifxhc->is_in)
4533 + hctsiz_data_t hctsiz;
4534 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
4535 + _urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
4536 + if ((hctsiz.b.xfersize != 0) || (_urb->actual_length >= _urb->transfer_buffer_length))
4540 + /* 20110805 AVM/WK Workaround: catch overflow error here, hardware does not */
4541 + if (_urb->actual_length > _urb->transfer_buffer_length) {
4542 + _urb->status = -EOVERFLOW;
4545 + if (_urb->actual_length < _urb->transfer_buffer_length && _urb->transfer_flags & URB_SHORT_NOT_OK)
4546 + _urb->status = -EREMOTEIO;
4553 + if (_ifxhc->split)
4554 + _urb->actual_length += _ifxhc->ssplit_out_xfer_count;
4556 + _urb->actual_length += _ifxhc->xfer_len;
4558 + if (_urb->actual_length >= _urb->transfer_buffer_length)
4560 + /*== AVM/BC WK 20110421 ZERO PACKET Workaround ==*/
4561 + if ((_ifxhc->short_rw == 1) && ( _ifxhc->xfer_len > 0) && ( _ifxhc->xfer_len % _ifxhc->mps == 0 ))
4563 + _ifxhc->short_rw = 0;
4564 + //Transfer not finished. Another iteration for ZLP.
4576 + hctsiz_data_t hctsiz;
4577 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
4578 + IFX_DEBUGPL(DBG_HCDV, "IFXUSB: %s: %s, channel %d\n",
4579 + __func__, (_ifxhc->is_in ? "IN" : "OUT"), _ifxhc->hc_num);
4580 + IFX_DEBUGPL(DBG_HCDV, " hc->xfer_len %d\n", _ifxhc->xfer_len);
4581 + IFX_DEBUGPL(DBG_HCDV, " hctsiz.xfersize %d\n", hctsiz.b.xfersize);
4582 + IFX_DEBUGPL(DBG_HCDV, " urb->transfer_buffer_length %d\n",
4583 + _urb->transfer_buffer_length);
4584 + IFX_DEBUGPL(DBG_HCDV, " urb->actual_length %d\n", _urb->actual_length);
4590 +/*== AVM/BC 20101111 Function called with Lock ==*/
4592 +void complete_channel(ifxhcd_hcd_t *_ifxhcd,
4593 + ifxhcd_hc_t *_ifxhc,
4594 + ifxhcd_urbd_t *_urbd)
4596 + ifxusb_hc_regs_t *hc_regs = _ifxhcd->core_if.hc_regs[_ifxhc->hc_num];
4597 + struct urb *urb = NULL;
4598 + ifxhcd_epqh_t *epqh = NULL;
4599 + int urb_xfer_done;
4601 + IFX_DEBUGPL(DBG_HCD, "--Complete Channel %d : \n", _ifxhc->hc_num);
4605 + IFX_ERROR("ERROR %s():%d urbd=%p\n",__func__,__LINE__,_urbd);
4610 + epqh = _urbd->epqh;
4614 + IFX_ERROR("ERROR %s():%d urb=%p epqh=%p\n",__func__,__LINE__,urb,epqh);
4618 + _ifxhc->do_ping=0;
4620 + if (_ifxhc->split)
4621 + _ifxhc->split = 1;
4623 + switch (epqh->ep_type)
4625 + case IFXUSB_EP_TYPE_CTRL:
4626 + switch (_ifxhc->control_phase)
4628 + case IFXHCD_CONTROL_SETUP:
4629 + IFX_DEBUGPL(DBG_HCDV, " Control setup transaction done\n");
4630 + if (_urbd->xfer_len > 0)
4632 + _ifxhc->control_phase = IFXHCD_CONTROL_DATA;
4633 + _ifxhc->is_in = _urbd->is_in;
4634 + _ifxhc->xfer_len = _urbd->xfer_len;
4635 + #if defined(__UNALIGNED_BUFFER_ADJ__)
4636 + if(epqh->using_aligned_buf)
4637 + _ifxhc->xfer_buff = epqh->aligned_buf;
4640 + _ifxhc->xfer_buff = _urbd->xfer_buff;
4644 + _ifxhc->control_phase = IFXHCD_CONTROL_STATUS;
4645 + _ifxhc->is_in = 1;
4646 + _ifxhc->xfer_len = 0;
4647 + _ifxhc->xfer_buff = _ifxhcd->status_buf;
4650 + _ifxhc->short_rw =0;
4652 + _ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
4653 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
4654 + _ifxhc->xfer_count = 0;
4655 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
4656 + /*== AVM/BC 20101111 Lock not needed ==*/
4657 + process_channels_sub(_ifxhcd);
4659 + case IFXHCD_CONTROL_DATA:
4660 + urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
4661 + if (urb_xfer_done)
4663 + _ifxhc->control_phase = IFXHCD_CONTROL_STATUS;
4664 + _ifxhc->is_in = (_urbd->is_in)?0:1;
4665 + _ifxhc->xfer_len = 0;
4666 + _ifxhc->xfer_count = 0;
4667 + _ifxhc->xfer_buff = _ifxhcd->status_buf;
4668 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
4669 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
4671 + _ifxhc->short_rw =0;
4673 + _ifxhc->short_rw =1;
4677 + _ifxhc->xfer_len = _urbd->xfer_len - urb->actual_length;
4678 + _ifxhc->xfer_count = urb->actual_length;
4679 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
4680 + _ifxhc->data_pid_start = read_data_toggle(hc_regs);
4682 + /*== AVM/BC 20101111 Lock not needed ==*/
4683 + process_channels_sub(_ifxhcd);
4685 + case IFXHCD_CONTROL_STATUS:
4686 + if (urb->status == -EINPROGRESS)
4688 + release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
4692 + case IFXUSB_EP_TYPE_BULK:
4693 + IFX_DEBUGPL(DBG_HCDV, " Bulk transfer complete\n");
4694 + urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
4695 + if (urb_xfer_done)
4696 + release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
4699 + _ifxhc->xfer_len = _urbd->xfer_len - urb->actual_length;
4700 + _ifxhc->xfer_count = urb->actual_length;
4701 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
4702 + _ifxhc->data_pid_start = read_data_toggle(hc_regs);
4703 + /*== AVM/BC 20101111 Lock not needed ==*/
4704 + process_channels_sub(_ifxhcd);
4707 + case IFXUSB_EP_TYPE_INTR:
4708 + urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
4709 + release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
4711 + case IFXUSB_EP_TYPE_ISOC:
4712 +// if (_urbd->isoc_split_pos == IFXUSB_HCSPLIT_XACTPOS_ALL)
4713 +// halt_status = update_isoc_urb_state(_ifxhcd, _ifxhc, hc_regs, _urbd, HC_XFER_COMPLETE);
4714 +// complete_periodic_xfer(_ifxhcd, _ifxhc, hc_regs, _urbd, halt_status);
4715 + urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
4716 + release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
4723 +void showint(uint32_t val_hcint
4724 + ,uint32_t val_hcintmsk
4725 + ,uint32_t val_hctsiz)
4728 + hcint_data_t hcint = {.d32 = val_hcint};
4729 + hcint_data_t hcintmsk = {.d32 = val_hcintmsk};
4731 + printk(KERN_INFO " WITH FLAG: Sz:%08x I:%08X/M:%08X %s%s%s%s%s%s%s%s%s%s\n"
4732 + ,val_hctsiz,hcint.d32 ,hcintmsk.d32
4733 + ,(hcint.b.datatglerr || hcintmsk.b.datatglerr)?
4735 + (hcint.b.datatglerr && hcintmsk.b.datatglerr)?"datatglerr[*/*] ":
4737 + (hcint.b.datatglerr)?"datatglerr[*/] ":"datatglerr[/*] "
4741 + ,(hcint.b.frmovrun || hcintmsk.b.frmovrun)?
4743 + (hcint.b.frmovrun && hcintmsk.b.frmovrun)?"frmovrun[*/*] ":
4745 + (hcint.b.frmovrun)?"frmovrun[*/] ":"frmovrun[/*] "
4749 + ,(hcint.b.bblerr || hcintmsk.b.bblerr)?
4751 + (hcint.b.bblerr && hcintmsk.b.bblerr)?"bblerr[*/*] ":
4753 + (hcint.b.bblerr)?"bblerr[*/] ":"bblerr[/*] "
4757 + ,(hcint.b.xacterr || hcintmsk.b.xacterr)?
4759 + (hcint.b.xacterr && hcintmsk.b.xacterr)?"xacterr[*/*] ":
4761 + (hcint.b.xacterr)?"xacterr[*/] ":"xacterr[/*] "
4765 + ,(hcint.b.nyet || hcintmsk.b.nyet)?
4767 + (hcint.b.nyet && hcintmsk.b.nyet)?"nyet[*/*] ":
4769 + (hcint.b.nyet)?"nyet[*/] ":"nyet[/*] "
4773 + ,(hcint.b.nak || hcintmsk.b.nak)?
4775 + (hcint.b.nak && hcintmsk.b.nak)?"nak[*/*] ":
4777 + (hcint.b.nak)?"nak[*/] ":"nak[/*] "
4781 + ,(hcint.b.ack || hcintmsk.b.ack)?
4783 + (hcint.b.ack && hcintmsk.b.ack)?"ack[*/*] ":
4785 + (hcint.b.ack)?"ack[*/] ":"ack[/*] "
4789 + ,(hcint.b.stall || hcintmsk.b.stall)?
4791 + (hcint.b.stall && hcintmsk.b.stall)?"stall[*/*] ":
4793 + (hcint.b.stall)?"stall[*/] ":"stall[/*] "
4797 + ,(hcint.b.ahberr || hcintmsk.b.ahberr)?
4799 + (hcint.b.ahberr && hcintmsk.b.ahberr)?"ahberr[*/*] ":
4801 + (hcint.b.ahberr)?"ahberr[*/] ":"ahberr[/*] "
4805 + ,(hcint.b.xfercomp || hcintmsk.b.xfercomp)?
4807 + (hcint.b.xfercomp && hcintmsk.b.xfercomp)?"xfercomp[*/*] ":
4809 + (hcint.b.xfercomp)?"xfercomp[*/] ":"xfercomp[/*] "
4818 +extern void ifxhcd_hc_dumb_rx(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc,uint8_t *dump_buf);
4820 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4821 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4822 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4823 +static int32_t chhltd_ctrlbulk_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
4824 + ifxhcd_hc_t *_ifxhc,
4825 + ifxusb_hc_regs_t *_hc_regs,
4826 + ifxhcd_urbd_t *_urbd)
4828 + hcint_data_t hcint;
4829 + hcint_data_t hcintmsk;
4830 + hctsiz_data_t hctsiz;
4832 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
4833 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
4834 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
4836 + disable_hc_int(_hc_regs,ack);
4837 + disable_hc_int(_hc_regs,nak);
4838 + disable_hc_int(_hc_regs,nyet);
4839 + _ifxhc->do_ping = 0;
4841 + if(_ifxhc->halt_status == HC_XFER_NAK)
4843 + if(_ifxhc->nak_retry_r)
4845 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
4846 + _ifxhc->nak_retry--;
4847 + if(_ifxhc->nak_retry)
4849 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
4850 + _ifxhc->xfer_count = _urbd->urb->actual_length;
4851 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
4852 + _ifxhc->wait_for_sof = 1;
4853 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
4854 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
4858 + _ifxhc->wait_for_sof = 0;
4859 + release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
4864 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
4865 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
4866 + _ifxhc->xfer_count = _urbd->urb->actual_length;
4867 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
4868 + _ifxhc->wait_for_sof = 1;
4869 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
4870 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
4875 + if (hcint.b.xfercomp)
4877 + _urbd->error_count =0;
4878 + _ifxhc->wait_for_sof =0;
4879 + complete_channel(_ifxhcd, _ifxhc, _urbd);
4882 + else if (hcint.b.stall)
4884 + _urbd->error_count =0;
4885 + _ifxhc->wait_for_sof =0;
4888 + if(hctsiz.b.pktcnt==0)
4889 + complete_channel(_ifxhcd, _ifxhc, _urbd);
4893 + // Stall FIFO compensation.
4896 + sz2=_ifxhc->start_pkt_count - hctsiz.b.pktcnt;
4898 + sz1=_ifxhc->xfer_len - hctsiz.b.xfersize;
4901 + ifxhcd_hc_dumb_rx(&_ifxhcd->core_if, _ifxhc,_ifxhc->epqh->dump_buf);
4903 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
4904 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
4908 + else if (hcint.b.bblerr)
4910 + _urbd->error_count =0;
4911 + _ifxhc->wait_for_sof =0;
4915 + if(hctsiz.b.pktcnt==0)
4916 + complete_channel(_ifxhcd, _ifxhc, _urbd);
4919 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
4920 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
4923 + else if (hcint.b.xacterr)
4927 + if(hctsiz.b.pktcnt==0)
4929 + _urbd->error_count =0;
4930 + _ifxhc->wait_for_sof =0;
4931 + complete_channel(_ifxhcd, _ifxhc, _urbd);
4936 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
4937 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
4938 + _ifxhc->xfer_count = _urbd->urb->actual_length;
4939 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
4941 + /* 20110803 AVM/WK FIX: Reset error count on any handshake */
4942 + if (hcint.b.nak || hcint.b.nyet || hcint.b.ack) {
4943 + _urbd->error_count = 1;
4945 + _urbd->error_count++;
4948 + if (_urbd->error_count >= 3)
4950 + _urbd->error_count =0;
4951 + _ifxhc->wait_for_sof =0;
4952 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
4956 + _ifxhc->wait_for_sof = 1;
4957 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
4962 + else if(hcint.b.datatglerr )
4964 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
4966 + if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
4967 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
4969 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
4970 + _ifxhc->wait_for_sof = 1;
4971 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
4972 + _ifxhc->xfer_count = _urbd->urb->actual_length;
4973 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
4975 + release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
4979 + else if(hcint.b.frmovrun )
4981 +IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT0 FRMOVRUN [should be Period only]\n",__func__,__LINE__);
4982 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
4983 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
4986 + else if(hcint.b.nyet )
4988 +IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT0 NYET [should be Out only]\n",__func__,__LINE__);
4989 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
4993 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4994 +static int32_t chhltd_ctrlbulk_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
4995 + ifxhcd_hc_t *_ifxhc,
4996 + ifxusb_hc_regs_t *_hc_regs,
4997 + ifxhcd_urbd_t *_urbd)
4999 + hcint_data_t hcint;
5000 + hcint_data_t hcintmsk;
5001 + hctsiz_data_t hctsiz;
5002 + int out_nak_enh = 0;
5005 +static int first=0;
5008 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
5011 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
5012 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
5013 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
5016 +if(!first&& _ifxhc->ep_type == IFXUSB_EP_TYPE_BULK
5017 + &&(hcint.b.stall || hcint.b.datatglerr || hcint.b.frmovrun || hcint.b.bblerr || hcint.b.xacterr) && !hcint.b.ack)
5019 + showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5021 + printk(KERN_INFO " [%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X] \n"
5022 + ,*(_ifxhc->xfer_buff+ 0),*(_ifxhc->xfer_buff+ 1),*(_ifxhc->xfer_buff+ 2),*(_ifxhc->xfer_buff+ 3)
5023 + ,*(_ifxhc->xfer_buff+ 4),*(_ifxhc->xfer_buff+ 5),*(_ifxhc->xfer_buff+ 6),*(_ifxhc->xfer_buff+ 7)
5024 + ,*(_ifxhc->xfer_buff+ 8),*(_ifxhc->xfer_buff+ 9),*(_ifxhc->xfer_buff+10),*(_ifxhc->xfer_buff+11)
5025 + ,*(_ifxhc->xfer_buff+12),*(_ifxhc->xfer_buff+13),*(_ifxhc->xfer_buff+14),*(_ifxhc->xfer_buff+15));
5027 + printk(KERN_INFO " [_urbd->urb->actual_length:%08X _ifxhc->start_pkt_count:%08X hctsiz.b.pktcnt:%08X ,_urbd->xfer_len:%08x] \n"
5028 + ,_urbd->urb->actual_length
5029 + ,_ifxhc->start_pkt_count
5031 + ,_urbd->xfer_len);
5035 + if(_ifxhc->halt_status == HC_XFER_NAK)
5037 + if(_ifxhc->nak_retry_r)
5039 + _ifxhc->nak_retry--;
5040 + if(_ifxhc->nak_retry)
5042 + if(_ifxhc->xfer_len!=0)
5043 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5044 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5045 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5046 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5047 + _ifxhc->wait_for_sof = 1;
5048 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
5049 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5053 + _ifxhc->wait_for_sof = 0;
5054 + release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
5059 + if(_ifxhc->xfer_len!=0)
5060 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5061 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5062 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5063 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5064 + _ifxhc->wait_for_sof = 1;
5065 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
5066 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5071 + if (hcint.b.xfercomp)
5073 + disable_hc_int(_hc_regs,ack);
5074 + disable_hc_int(_hc_regs,nak);
5075 + disable_hc_int(_hc_regs,nyet);
5076 + _urbd->error_count =0;
5077 + if(_ifxhc->xfer_len==0 && !hcint.b.ack && hcint.b.nak)
5079 + // Walkaround: When sending ZLP and receive NAK but also issue CMPT intr
5080 + // Solution: NoSplit: Resend at next SOF
5081 + // Split : Resend at next SOF with SSPLIT
5082 + if(hcint.b.nyet && !out_nak_enh)
5083 + _ifxhc->do_ping = 1;
5085 + _ifxhc->do_ping = 0;
5086 + _ifxhc->xfer_len = 0;
5087 + _ifxhc->xfer_count = 0;
5088 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
5089 + _ifxhc->wait_for_sof = 1;
5090 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5094 + _ifxhc->wait_for_sof = 0;
5095 + _ifxhc->do_ping = 0;
5096 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5100 + else if (hcint.b.stall)
5102 + disable_hc_int(_hc_regs,ack);
5103 + disable_hc_int(_hc_regs,nak);
5104 + disable_hc_int(_hc_regs,nyet);
5105 + _urbd->error_count =0;
5106 + _ifxhc->wait_for_sof =0;
5107 + _ifxhc->do_ping =0;
5111 + if(hctsiz.b.pktcnt==0)
5112 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5116 + if(_ifxhc->xfer_len!=0)
5117 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5118 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
5122 + else if (hcint.b.xacterr)
5126 + if(hctsiz.b.pktcnt==0)
5128 + disable_hc_int(_hc_regs,ack);
5129 + disable_hc_int(_hc_regs,nak);
5130 + disable_hc_int(_hc_regs,nyet);
5131 + _urbd->error_count =0;
5132 + _ifxhc->wait_for_sof =0;
5133 + _ifxhc->do_ping =0;
5134 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5139 + if(_ifxhc->xfer_len!=0)
5140 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5141 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5142 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5143 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5145 + if (hcint.b.nak || hcint.b.nyet || hcint.b.ack)
5147 + _urbd->error_count =0;
5148 + _ifxhc->wait_for_sof =1;
5149 + enable_hc_int(_hc_regs,ack);
5150 + enable_hc_int(_hc_regs,nak);
5151 + enable_hc_int(_hc_regs,nyet);
5153 + _ifxhc->do_ping =1;
5155 + _ifxhc->do_ping =0;
5156 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5160 + _urbd->error_count ++ ;
5161 + if (_urbd->error_count == 3)
5163 + disable_hc_int(_hc_regs,ack);
5164 + disable_hc_int(_hc_regs,nak);
5165 + disable_hc_int(_hc_regs,nyet);
5166 + _urbd->error_count =0;
5167 + _ifxhc->wait_for_sof =0;
5168 + _ifxhc->do_ping =0;
5169 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
5173 + enable_hc_int(_hc_regs,ack);
5174 + enable_hc_int(_hc_regs,nak);
5175 + enable_hc_int(_hc_regs,nyet);
5176 + _ifxhc->wait_for_sof =1;
5178 + _ifxhc->do_ping =1;
5180 + _ifxhc->do_ping =0;
5181 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5187 + else if(hcint.b.bblerr )
5189 +IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT0 BABBLE [should be IN only]\n",__func__,__LINE__);
5190 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5191 + _ifxhc->do_ping = 0;
5192 + if(_ifxhc->xfer_len!=0)
5193 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5194 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
5197 + else if(hcint.b.nak || hcint.b.nyet)
5203 + if(hctsiz.b.pktcnt==0)
5205 + _urbd->error_count =0;
5206 + _ifxhc->wait_for_sof =0;
5207 + _ifxhc->do_ping =0;
5208 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5214 + _ifxhc->do_ping =1;
5216 + _ifxhc->do_ping =0;
5217 + if(_ifxhc->xfer_len!=0)
5219 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5220 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5221 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5223 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5224 + _ifxhc->wait_for_sof = 1;
5225 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5230 + else if(hcint.b.datatglerr )
5232 +IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT0 DATATGLERR [should be IN only]\n",__func__,__LINE__);
5233 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5234 + _urbd->error_count =0;
5235 + _ifxhc->wait_for_sof =0;
5236 + _ifxhc->do_ping =0;
5237 + release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
5240 + else if(hcint.b.frmovrun )
5242 +IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT0 FRMOVRUN [should be PERIODIC only]\n",__func__,__LINE__);
5243 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5244 + _urbd->error_count =0;
5245 + _ifxhc->wait_for_sof =0;
5246 + _ifxhc->do_ping =0;
5247 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
5252 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5253 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5254 +static int32_t chhltd_intr_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
5255 + ifxhcd_hc_t *_ifxhc,
5256 + ifxusb_hc_regs_t *_hc_regs,
5257 + ifxhcd_urbd_t *_urbd)
5259 + hcint_data_t hcint;
5260 + hcint_data_t hcintmsk;
5261 + hctsiz_data_t hctsiz;
5263 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
5264 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
5265 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
5266 + disable_hc_int(_hc_regs,ack);
5267 + disable_hc_int(_hc_regs,nak);
5268 + disable_hc_int(_hc_regs,nyet);
5269 + _ifxhc->do_ping =0;
5271 + if(_ifxhc->halt_status == HC_XFER_NAK)
5273 + if(_ifxhc->nak_retry_r)
5275 + _ifxhc->nak_retry--;
5276 + if(_ifxhc->nak_retry)
5278 + if(_ifxhc->xfer_len!=0)
5279 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5280 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5281 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5282 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5283 + _ifxhc->wait_for_sof = 1;
5284 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
5285 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5289 + _ifxhc->wait_for_sof = 0;
5290 + release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
5295 + if(_ifxhc->xfer_len!=0)
5296 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5297 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5298 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5299 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5300 + _ifxhc->wait_for_sof = 1;
5301 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
5302 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5307 + if(hcint.b.xfercomp )
5309 + _urbd->error_count =0;
5310 + //restart INTR immediately
5312 + if(hctsiz.b.pktcnt>0)
5314 + // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
5315 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
5316 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
5317 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5322 + _ifxhc->wait_for_sof =0;
5323 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5327 + else if (hcint.b.stall)
5329 + _urbd->error_count =0;
5330 + _ifxhc->wait_for_sof =0;
5332 + // Don't care shortcut
5334 + if(hctsiz.b.pktcnt==0)
5335 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5339 + // Stall FIFO compensation.
5342 + sz2=_ifxhc->start_pkt_count - hctsiz.b.pktcnt;
5344 + sz1=_ifxhc->xfer_len - hctsiz.b.xfersize;
5347 + ifxhcd_hc_dumb_rx(&_ifxhcd->core_if, _ifxhc,_ifxhc->epqh->dump_buf);
5349 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
5350 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
5356 + else if (hcint.b.bblerr)
5358 + _urbd->error_count =0;
5359 + _ifxhc->wait_for_sof =0;
5361 + // Don't care shortcut
5363 + if(hctsiz.b.pktcnt==0)
5364 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5368 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
5369 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
5373 + else if (hcint.b.nak || hcint.b.datatglerr || hcint.b.frmovrun)
5375 + _urbd->error_count =0;
5376 + //restart INTR immediately
5378 + if(hctsiz.b.pktcnt>0)
5380 + // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
5381 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
5382 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
5383 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5388 + _ifxhc->wait_for_sof =0;
5389 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5393 + else if (hcint.b.xacterr)
5397 + if(hctsiz.b.pktcnt==0)
5399 + _urbd->error_count =0;
5400 + _ifxhc->wait_for_sof =0;
5401 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5406 + /* 20110803 AVM/WK FIX: Reset error count on any handshake */
5407 + if (hcint.b.nak || hcint.b.nyet || hcint.b.ack) {
5408 + _urbd->error_count = 1;
5410 + _urbd->error_count++;
5413 + if(_urbd->error_count>=3)
5415 + _urbd->error_count =0;
5416 + _ifxhc->wait_for_sof =0;
5417 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
5421 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
5422 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5427 + else if(hcint.b.nyet )
5429 +IFX_WARN("%s() %d Warning INTR IN SPLIT0 NYET [should be OUT only]\n",__func__,__LINE__);
5430 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5435 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5436 +static int32_t chhltd_intr_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
5437 + ifxhcd_hc_t *_ifxhc,
5438 + ifxusb_hc_regs_t *_hc_regs,
5439 + ifxhcd_urbd_t *_urbd)
5441 + hcint_data_t hcint;
5442 + hcint_data_t hcintmsk;
5443 + hctsiz_data_t hctsiz;
5444 + int out_nak_enh = 0;
5446 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
5449 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
5450 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
5451 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
5453 + if(_ifxhc->halt_status == HC_XFER_NAK)
5455 + if(_ifxhc->nak_retry_r)
5457 + _ifxhc->nak_retry--;
5458 + if(_ifxhc->nak_retry)
5460 + if(_ifxhc->xfer_len!=0)
5461 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5462 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5463 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5464 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5465 + _ifxhc->wait_for_sof = 1;
5466 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
5467 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5471 + _ifxhc->wait_for_sof = 0;
5472 + release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
5477 + if(_ifxhc->xfer_len!=0)
5478 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5479 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5480 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5481 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5482 + _ifxhc->wait_for_sof = 1;
5483 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
5484 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5489 + if(hcint.b.xfercomp )
5491 + disable_hc_int(_hc_regs,ack);
5492 + disable_hc_int(_hc_regs,nak);
5493 + disable_hc_int(_hc_regs,nyet);
5494 + _urbd->error_count =0;
5495 + //restart INTR immediately
5497 + if(hctsiz.b.pktcnt>0)
5499 + // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
5500 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
5501 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
5502 + if(hcint.b.nyet && !out_nak_enh )
5503 + _ifxhc->do_ping =1;
5505 + _ifxhc->do_ping =0;
5506 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5511 + _ifxhc->wait_for_sof =0;
5512 + _ifxhc->do_ping =0;
5513 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5517 + else if (hcint.b.stall)
5519 + disable_hc_int(_hc_regs,ack);
5520 + disable_hc_int(_hc_regs,nyet);
5521 + disable_hc_int(_hc_regs,nak);
5522 + _urbd->error_count =0;
5523 + _ifxhc->wait_for_sof =0;
5524 + _ifxhc->do_ping =0;
5526 + // Don't care shortcut
5528 + if(hctsiz.b.pktcnt==0)
5529 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5533 + if(_ifxhc->xfer_len!=0)// !_ifxhc->is_in
5534 + _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
5535 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
5539 + else if(hcint.b.nak || hcint.b.frmovrun )
5541 + disable_hc_int(_hc_regs,ack);
5542 + disable_hc_int(_hc_regs,nyet);
5543 + disable_hc_int(_hc_regs,nak);
5544 + _urbd->error_count =0;
5545 + //restart INTR immediately
5547 + if(hctsiz.b.pktcnt>0)
5549 + // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
5550 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
5551 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
5553 + _ifxhc->do_ping =1;
5555 + _ifxhc->do_ping =0;
5556 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5561 + _ifxhc->wait_for_sof =0;
5562 + _ifxhc->do_ping =0;
5563 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5567 + else if(hcint.b.xacterr )
5571 + if(hctsiz.b.pktcnt==0)
5573 + _urbd->error_count =0;
5574 + _ifxhc->wait_for_sof =0;
5575 + _ifxhc->do_ping =0;
5576 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5581 + /* 20110803 AVM/WK FIX: Reset error count on any handshake */
5582 + if (hcint.b.nak || hcint.b.nyet || hcint.b.ack) {
5583 + _urbd->error_count = 1;
5585 + _urbd->error_count++;
5588 + if(_urbd->error_count>=3)
5590 + _urbd->error_count =0;
5591 + _ifxhc->wait_for_sof =0;
5592 + _ifxhc->do_ping =0;
5593 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
5597 + //_ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
5598 + //if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
5599 + _ifxhc->wait_for_sof=1;
5601 + _ifxhc->do_ping =1;
5603 + _ifxhc->do_ping =0;
5605 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5610 + else if(hcint.b.bblerr )
5612 +IFX_WARN("%s() %d Warning INTR OUT SPLIT0 BABBLEERR [should be IN only]\n",__func__,__LINE__);
5613 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5614 + _urbd->error_count =0;
5615 + _ifxhc->wait_for_sof =0;
5616 + _ifxhc->do_ping =0;
5617 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
5620 + else if(hcint.b.datatglerr )
5622 +IFX_WARN("%s() %d Warning INTR OUT SPLIT0 DATATGLERR\n",__func__,__LINE__);
5623 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5624 + _urbd->error_count =0;
5625 + _ifxhc->wait_for_sof =0;
5626 + _ifxhc->do_ping =0;
5627 + release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
5632 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5633 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5634 +static int32_t chhltd_isoc_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
5635 + ifxhcd_hc_t *_ifxhc,
5636 + ifxusb_hc_regs_t *_hc_regs,
5637 + ifxhcd_urbd_t *_urbd)
5639 + #if defined(__EN_ISOC__)
5640 + hcint_data_t hcint;
5641 + hcint_data_t hcintmsk;
5642 + hctsiz_data_t hctsiz;
5644 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
5645 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
5646 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
5648 + if (hcint.b.xfercomp || hcint.b.frmovrun)
5650 + _urbd->error_count=0;
5651 + disable_hc_int(_hc_regs,ack);
5652 + disable_hc_int(_hc_regs,nak);
5653 + disable_hc_int(_hc_regs,nyet);
5654 + _ifxhc->wait_for_sof = 0;
5655 + if (hcint.b.xfercomp)
5656 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5658 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
5660 + else if (hcint.b.xacterr || hcint.b.bblerr)
5663 + if(hctsiz.b.pktcnt==0)
5665 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5670 + sz2=_ifxhc->start_pkt_count - hctsiz.b.pktcnt;
5672 + sz1=_ifxhc->xfer_len - hctsiz.b.xfersize;
5675 + ifxhcd_hc_dumb_rx(&_ifxhcd->core_if, _ifxhc,_ifxhc->epqh->dump_buf);
5676 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
5677 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5678 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5679 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5680 + _urbd->error_count++;
5681 + if(_urbd->error_count>=3)
5683 + _urbd->error_count=0;
5684 + _ifxhc->wait_for_sof = 0;
5685 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
5686 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
5690 + _ifxhc->wait_for_sof = 1;
5691 + enable_hc_int(_hc_regs,ack);
5692 + enable_hc_int(_hc_regs,nak);
5693 + enable_hc_int(_hc_regs,nyet);
5694 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5699 + else if(hcint.b.datatglerr )
5703 + else if(hcint.b.stall )
5711 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5712 +static int32_t chhltd_isoc_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
5713 + ifxhcd_hc_t *_ifxhc,
5714 + ifxusb_hc_regs_t *_hc_regs,
5715 + ifxhcd_urbd_t *_urbd)
5717 + #if defined(__EN_ISOC__)
5718 + hcint_data_t hcint;
5719 + hcint_data_t hcintmsk;
5720 + hctsiz_data_t hctsiz;
5721 + int out_nak_enh = 0;
5723 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
5726 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
5727 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
5728 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
5730 + if (hcint.b.xfercomp)
5732 + _urbd->error_count=0;
5733 + disable_hc_int(_hc_regs,ack);
5734 + disable_hc_int(_hc_regs,nak);
5735 + disable_hc_int(_hc_regs,nyet);
5736 + _ifxhc->wait_for_sof = 0;
5737 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5740 + else if (hcint.b.frmovrun)
5743 + _urbd->error_count=0;
5744 + disable_hc_int(_hc_regs,ack);
5745 + disable_hc_int(_hc_regs,nak);
5746 + disable_hc_int(_hc_regs,nyet);
5747 + _ifxhc->wait_for_sof = 0;
5748 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
5751 + else if(hcint.b.datatglerr )
5755 + else if(hcint.b.bblerr )
5758 + if(hctsiz.b.pktcnt==0)
5760 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5765 + sz2=_ifxhc->start_pkt_count - hctsiz.b.pktcnt;
5767 + sz1=_ifxhc->xfer_len - hctsiz.b.xfersize;
5770 + ifxhcd_hc_dumb_rx(&_ifxhcd->core_if, _ifxhc,_ifxhc->epqh->dump_buf);
5771 + _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
5772 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
5773 + _ifxhc->xfer_count = _urbd->urb->actual_length;
5774 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5775 + _urbd->error_count++;
5776 + if(_urbd->error_count>=3)
5778 + _urbd->error_count=0;
5779 + _ifxhc->wait_for_sof = 0;
5780 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
5784 + _ifxhc->wait_for_sof = 1;
5785 + enable_hc_int(_hc_regs,ack);
5786 + enable_hc_int(_hc_regs,nak);
5787 + enable_hc_int(_hc_regs,nyet);
5788 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5793 + else if(hcint.b.xacterr )
5795 + if(hctsiz.b.pktcnt==0)
5797 + complete_channel(_ifxhcd, _ifxhc, _urbd);
5800 + _urbd->error_count++;
5801 + if(_urbd->error_count>=3)
5803 + _urbd->error_count=0;
5804 + _ifxhc->wait_for_sof = 0;
5805 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
5809 + _ifxhc->wait_for_sof = 1;
5810 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5814 + else if(hcint.b.stall )
5822 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5823 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5824 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5825 +static int32_t chhltd_ctrlbulk_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
5826 + ifxhcd_hc_t *_ifxhc,
5827 + ifxusb_hc_regs_t *_hc_regs,
5828 + ifxhcd_urbd_t *_urbd)
5830 + hcint_data_t hcint;
5831 + hcint_data_t hcintmsk;
5832 + hctsiz_data_t hctsiz;
5834 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
5835 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
5836 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
5838 + disable_hc_int(_hc_regs,ack);
5839 + disable_hc_int(_hc_regs,nak);
5840 + disable_hc_int(_hc_regs,nyet);
5842 + _ifxhc->do_ping =0;
5846 + _urbd->error_count=0;
5848 + _ifxhc->wait_for_sof = 8;
5849 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
5850 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5853 + else if (hcint.b.nak)
5855 + _ifxhc->wait_for_sof = 1;
5856 + _urbd->error_count = 0;
5857 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5860 + else if (hcint.b.xacterr)
5862 + _urbd->error_count++;
5863 + if(_urbd->error_count>=3)
5865 + _urbd->error_count=0;
5866 + _ifxhc->wait_for_sof =0;
5867 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
5871 + _ifxhc->wait_for_sof =1;
5872 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5876 + else if(hcint.b.bblerr )
5878 + _urbd->error_count =0;
5879 + _ifxhc->wait_for_sof =0;
5880 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
5883 + else if(hcint.b.stall )
5885 + _urbd->error_count =0;
5886 + _ifxhc->wait_for_sof =0;
5887 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
5890 + else if(hcint.b.datatglerr )
5892 +IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 HC_XFER_DATA_TOGGLE_ERR\n",__func__,__LINE__);
5893 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5894 + _urbd->error_count =0;
5895 + _ifxhc->wait_for_sof =0;
5896 + release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
5899 + else if(hcint.b.frmovrun )
5901 +IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 HC_XFER_FRAME_OVERRUN\n",__func__,__LINE__);
5902 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5903 + _urbd->error_count =0;
5904 + _ifxhc->wait_for_sof =0;
5905 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
5908 + else if(hcint.b.nyet )
5910 +IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 NYET\n",__func__,__LINE__);
5911 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5913 + else if(hcint.b.xfercomp )
5915 +IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 COMPLETE\n",__func__,__LINE__);
5916 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5920 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5921 +static int32_t chhltd_ctrlbulk_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
5922 + ifxhcd_hc_t *_ifxhc,
5923 + ifxusb_hc_regs_t *_hc_regs,
5924 + ifxhcd_urbd_t *_urbd)
5926 + hcint_data_t hcint;
5927 + hcint_data_t hcintmsk;
5928 + hctsiz_data_t hctsiz;
5929 + int out_nak_enh = 0;
5932 +static int first=0;
5935 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
5938 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
5939 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
5940 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
5941 + disable_hc_int(_hc_regs,ack);
5942 + disable_hc_int(_hc_regs,nak);
5943 + disable_hc_int(_hc_regs,nyet);
5946 + if(!first&& _ifxhc->ep_type == IFXUSB_EP_TYPE_BULK
5947 + &&(hcint.b.stall || hcint.b.datatglerr || hcint.b.frmovrun || hcint.b.bblerr || hcint.b.xacterr) && !hcint.b.ack)
5949 + showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5951 + printk(KERN_INFO " [%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X] \n"
5952 + ,*(_ifxhc->xfer_buff+ 0),*(_ifxhc->xfer_buff+ 1),*(_ifxhc->xfer_buff+ 2),*(_ifxhc->xfer_buff+ 3)
5953 + ,*(_ifxhc->xfer_buff+ 4),*(_ifxhc->xfer_buff+ 5),*(_ifxhc->xfer_buff+ 6),*(_ifxhc->xfer_buff+ 7)
5954 + ,*(_ifxhc->xfer_buff+ 8),*(_ifxhc->xfer_buff+ 9),*(_ifxhc->xfer_buff+10),*(_ifxhc->xfer_buff+11)
5955 + ,*(_ifxhc->xfer_buff+12),*(_ifxhc->xfer_buff+13),*(_ifxhc->xfer_buff+14),*(_ifxhc->xfer_buff+15));
5957 + printk(KERN_INFO " [_urbd->urb->actual_length:%08X _ifxhc->start_pkt_count:%08X hctsiz.b.pktcnt:%08X ,_urbd->xfer_len:%08x] \n"
5958 + ,_urbd->urb->actual_length
5959 + ,_ifxhc->start_pkt_count
5961 + ,_urbd->xfer_len);
5967 + _urbd->error_count=0;
5968 + if (_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK || _ifxhc->control_phase != IFXHCD_CONTROL_SETUP)
5969 + _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
5971 + _ifxhc->wait_for_sof =8;
5972 + _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
5973 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5976 + else if(hcint.b.nyet)
5978 +IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT1 NYET\n",__func__,__LINE__);
5979 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
5980 + _urbd->error_count=0;
5981 + if (_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK || _ifxhc->control_phase != IFXHCD_CONTROL_SETUP)
5982 + _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
5984 + _ifxhc->wait_for_sof =1;
5985 + _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
5986 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
5989 + else if(hcint.b.nak )
5991 + _ifxhc->wait_for_sof =1;
5993 + _ifxhc->do_ping =1;
5995 + _ifxhc->do_ping =0;
5996 + _urbd->error_count =0;
5997 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6000 + else if(hcint.b.xacterr )
6002 + _urbd->error_count++;
6003 + if(_urbd->error_count>=3)
6005 + _urbd->error_count=0;
6006 + _ifxhc->wait_for_sof =0;
6007 + _ifxhc->do_ping =0;
6008 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
6012 + _ifxhc->wait_for_sof =1;
6013 + _ifxhc->do_ping =1;
6014 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6018 + else if(hcint.b.datatglerr )
6020 + _urbd->error_count =0;
6021 + _ifxhc->wait_for_sof =0;
6022 + _ifxhc->do_ping =0;
6023 + release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
6026 + else if(hcint.b.bblerr )
6028 + _urbd->error_count =0;
6029 + _ifxhc->wait_for_sof =0;
6030 + _ifxhc->do_ping =0;
6031 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
6034 + else if(hcint.b.stall )
6036 + _urbd->error_count =0;
6037 + _ifxhc->wait_for_sof =0;
6038 + _ifxhc->do_ping =0;
6039 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6042 + else if(hcint.b.frmovrun )
6044 +IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT1 HC_XFER_FRAME_OVERRUN\n",__func__,__LINE__);
6045 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6046 + _urbd->error_count =0;
6047 + _ifxhc->wait_for_sof =0;
6048 + _ifxhc->do_ping =0;
6049 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
6052 + else if(hcint.b.xfercomp )
6054 + printk(KERN_INFO "%s() %d Warning CTRLBULK OUT SPLIT1 COMPLETE\n",__func__,__LINE__);
6058 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6059 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6060 +static int32_t chhltd_intr_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
6061 + ifxhcd_hc_t *_ifxhc,
6062 + ifxusb_hc_regs_t *_hc_regs,
6063 + ifxhcd_urbd_t *_urbd)
6065 + hcint_data_t hcint;
6066 + hcint_data_t hcintmsk;
6067 + hctsiz_data_t hctsiz;
6069 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6070 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6071 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6073 + disable_hc_int(_hc_regs,ack);
6074 + disable_hc_int(_hc_regs,nak);
6075 + disable_hc_int(_hc_regs,nyet);
6077 + _ifxhc->do_ping =0;
6081 + /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
6082 + _ifxhc->nyet_count=0;
6084 + _urbd->error_count=0;
6086 + _ifxhc->wait_for_sof = 0;
6087 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
6088 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6091 + else if(hcint.b.nak )
6093 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6094 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6095 + _urbd->error_count=0;
6096 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6099 + else if(hcint.b.xacterr )
6101 + hcchar_data_t hcchar;
6102 + hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
6103 + _urbd->error_count=hcchar.b.multicnt;
6104 + if(_urbd->error_count>=3)
6106 + _urbd->error_count=0;
6107 + _ifxhc->wait_for_sof = 0;
6108 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
6112 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6113 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6114 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6118 + else if(hcint.b.stall )
6120 + _urbd->error_count =0;
6121 + _ifxhc->wait_for_sof =0;
6122 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6125 + else if(hcint.b.bblerr )
6127 + _urbd->error_count =0;
6128 + _ifxhc->wait_for_sof =0;
6129 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
6132 + else if(hcint.b.frmovrun )
6134 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6135 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6136 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6139 + else if(hcint.b.datatglerr )
6141 +IFX_WARN( "%s() %d Warning INTR IN SPLIT1 DATATGLERR\n",__func__,__LINE__);
6142 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6143 + _urbd->error_count =0;
6144 + _ifxhc->wait_for_sof =0;
6145 + release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
6148 + else if(hcint.b.xfercomp )
6150 +IFX_WARN("%s() %d Warning INTR IN SPLIT1 COMPLETE\n",__func__,__LINE__);
6151 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6155 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6156 +static int32_t chhltd_intr_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
6157 + ifxhcd_hc_t *_ifxhc,
6158 + ifxusb_hc_regs_t *_hc_regs,
6159 + ifxhcd_urbd_t *_urbd)
6161 + hcint_data_t hcint;
6162 + hcint_data_t hcintmsk;
6163 + hctsiz_data_t hctsiz;
6164 + int out_nak_enh = 0;
6166 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
6169 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6170 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6171 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6173 + disable_hc_int(_hc_regs,ack);
6174 + disable_hc_int(_hc_regs,nak);
6175 + disable_hc_int(_hc_regs,nyet);
6179 + /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
6180 + _ifxhc->nyet_count=0;
6182 + _urbd->error_count=0;
6183 + _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
6185 + _ifxhc->wait_for_sof = 0;
6186 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
6187 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6190 + else if(hcint.b.nyet)
6192 +IFX_WARN("%s() %d Warning INTR OUT SPLIT1 NYET\n",__func__,__LINE__);
6193 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6194 + _urbd->error_count=0;
6195 + _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
6197 + _ifxhc->wait_for_sof = 0;
6198 + _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
6199 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6202 + else if(hcint.b.nak )
6204 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6205 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6206 + _urbd->error_count =0;
6207 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6210 + else if(hcint.b.frmovrun )
6212 + _urbd->error_count =0;
6213 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6214 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6215 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6218 + else if(hcint.b.xacterr )
6220 + hcchar_data_t hcchar;
6221 + hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
6222 + _urbd->error_count=hcchar.b.multicnt;
6223 + if(_urbd->error_count>=3)
6225 + _urbd->error_count=0;
6226 + _ifxhc->wait_for_sof =0;
6227 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
6231 + enable_hc_int(_hc_regs,ack);
6232 + enable_hc_int(_hc_regs,nak);
6233 + enable_hc_int(_hc_regs,nyet);
6234 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6235 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6236 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6240 + else if(hcint.b.datatglerr )
6242 +IFX_WARN("%s() %d Warning INTR IN SPLIT1 DATATGLERR\n",__func__,__LINE__);
6243 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6244 + _urbd->error_count =0;
6245 + _ifxhc->wait_for_sof =0;
6246 + release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
6249 + else if(hcint.b.bblerr )
6251 +IFX_WARN("%s() %d Warning INTR IN SPLIT1 BABBLEERR\n",__func__,__LINE__);
6252 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6253 + _urbd->error_count =0;
6254 + _ifxhc->wait_for_sof =0;
6255 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
6258 + else if(hcint.b.stall )
6260 +IFX_WARN("%s() %d Warning INTR IN SPLIT1 STALL\n",__func__,__LINE__);
6261 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6262 + _urbd->error_count =0;
6263 + _ifxhc->wait_for_sof =0;
6264 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6267 + else if(hcint.b.xfercomp )
6269 +IFX_WARN("%s() %d Warning INTR IN SPLIT1 COMPLETE\n",__func__,__LINE__);
6270 +showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6274 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6275 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6276 +static int32_t chhltd_isoc_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
6277 + ifxhcd_hc_t *_ifxhc,
6278 + ifxusb_hc_regs_t *_hc_regs,
6279 + ifxhcd_urbd_t *_urbd)
6281 + #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
6282 + hcint_data_t hcint;
6283 + hcint_data_t hcintmsk;
6284 + hctsiz_data_t hctsiz;
6286 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6287 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6288 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6293 + else if(hcint.b.frmovrun )
6295 + Rewind Buffer Pointers
6296 + Retry Start Split (in next b_interval ¡V 1 uF)
6298 + else if(hcint.b.datatglerr )
6302 + else if(hcint.b.bblerr )
6306 + else if(hcint.b.xacterr )
6310 + else if(hcint.b.stall )
6314 + else if(hcint.b.nak )
6318 + else if(hcint.b.xfercomp )
6322 + else if(hcint.b.nyet)
6329 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6330 +static int32_t chhltd_isoc_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
6331 + ifxhcd_hc_t *_ifxhc,
6332 + ifxusb_hc_regs_t *_hc_regs,
6333 + ifxhcd_urbd_t *_urbd)
6335 + #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
6336 + hcint_data_t hcint;
6337 + hcint_data_t hcintmsk;
6338 + hctsiz_data_t hctsiz;
6339 + int out_nak_enh = 0;
6341 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
6344 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6345 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6346 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6349 + Do Next Start Split (in next b_interval ¡V 1 uF)
6351 + else if(hcint.b.frmovrun )
6353 + Do Next Transaction in next frame.
6355 + else if(hcint.b.datatglerr )
6359 + else if(hcint.b.bblerr )
6363 + else if(hcint.b.xacterr )
6367 + else if(hcint.b.stall )
6371 + else if(hcint.b.nak )
6375 + else if(hcint.b.xfercomp )
6379 + else if(hcint.b.nyet)
6386 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6387 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6388 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6389 +static int32_t chhltd_ctrlbulk_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
6390 + ifxhcd_hc_t *_ifxhc,
6391 + ifxusb_hc_regs_t *_hc_regs,
6392 + ifxhcd_urbd_t *_urbd)
6394 + hcint_data_t hcint;
6395 + hcint_data_t hcintmsk;
6396 + hctsiz_data_t hctsiz;
6398 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6399 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6400 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6401 + disable_hc_int(_hc_regs,ack);
6402 + disable_hc_int(_hc_regs,nak);
6403 + disable_hc_int(_hc_regs,nyet);
6405 + _ifxhc->do_ping = 0;
6407 + if (hcint.b.xfercomp)
6409 + _urbd->error_count =0;
6410 + _ifxhc->wait_for_sof = 0;
6412 + complete_channel(_ifxhcd, _ifxhc, _urbd);
6415 + else if (hcint.b.nak)
6417 + _urbd->error_count=0;
6419 + _ifxhc->split = 1;
6420 + _ifxhc->wait_for_sof = 1;
6421 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6422 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6423 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6426 + else if(hcint.b.nyet)
6428 + _urbd->error_count=0;
6429 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
6430 + _ifxhc->wait_for_sof = 1;
6431 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6434 + else if(hcint.b.stall || hcint.b.bblerr )
6436 + _urbd->error_count=0;
6437 + _ifxhc->wait_for_sof = 0;
6438 + if (hcint.b.stall)
6439 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6440 + else if(hcint.b.bblerr )
6441 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
6444 + else if(hcint.b.xacterr )
6446 + _urbd->error_count++;
6447 + if(_urbd->error_count>=3)
6449 + _urbd->error_count=0;
6450 + _ifxhc->wait_for_sof = 0;
6451 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
6456 + _ifxhc->wait_for_sof = 1;
6457 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6458 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6459 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6463 + else if(hcint.b.datatglerr )
6465 + if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
6466 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
6468 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
6470 + _ifxhc->wait_for_sof = 1;
6471 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6472 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6473 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6476 + else if(hcint.b.frmovrun )
6478 + _urbd->error_count=0;
6479 + _ifxhc->wait_for_sof = 0;
6480 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
6485 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6486 +static int32_t chhltd_ctrlbulk_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
6487 + ifxhcd_hc_t *_ifxhc,
6488 + ifxusb_hc_regs_t *_hc_regs,
6489 + ifxhcd_urbd_t *_urbd)
6491 + hcint_data_t hcint;
6492 + hcint_data_t hcintmsk;
6493 + hctsiz_data_t hctsiz;
6494 + int out_nak_enh = 0;
6497 +static int first=0;
6500 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
6503 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6504 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6505 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6506 + disable_hc_int(_hc_regs,ack);
6507 + disable_hc_int(_hc_regs,nak);
6508 + disable_hc_int(_hc_regs,nyet);
6511 + if(!first&& _ifxhc->ep_type == IFXUSB_EP_TYPE_BULK
6512 + &&(hcint.b.stall || hcint.b.datatglerr || hcint.b.frmovrun || hcint.b.bblerr || hcint.b.xacterr) && !hcint.b.ack)
6514 + showint( hcint.d32,hcintmsk.d32,hctsiz.d32);
6516 + printk(KERN_INFO " [%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X] \n"
6517 + ,*(_ifxhc->xfer_buff+ 0),*(_ifxhc->xfer_buff+ 1),*(_ifxhc->xfer_buff+ 2),*(_ifxhc->xfer_buff+ 3)
6518 + ,*(_ifxhc->xfer_buff+ 4),*(_ifxhc->xfer_buff+ 5),*(_ifxhc->xfer_buff+ 6),*(_ifxhc->xfer_buff+ 7)
6519 + ,*(_ifxhc->xfer_buff+ 8),*(_ifxhc->xfer_buff+ 9),*(_ifxhc->xfer_buff+10),*(_ifxhc->xfer_buff+11)
6520 + ,*(_ifxhc->xfer_buff+12),*(_ifxhc->xfer_buff+13),*(_ifxhc->xfer_buff+14),*(_ifxhc->xfer_buff+15));
6522 + printk(KERN_INFO " [_urbd->urb->actual_length:%08X _ifxhc->start_pkt_count:%08X hctsiz.b.pktcnt:%08X ,_urbd->xfer_len:%08x] \n"
6523 + ,_urbd->urb->actual_length
6524 + ,_ifxhc->start_pkt_count
6526 + ,_urbd->xfer_len);
6530 + if(hcint.b.xfercomp )
6532 + _urbd->error_count=0;
6534 + _ifxhc->do_ping= 0;
6536 + if(_ifxhc->xfer_len==0 && !hcint.b.ack && (hcint.b.nak || hcint.b.nyet))
6538 + // Walkaround: When sending ZLP and receive NYEY or NAK but also issue CMPT intr
6539 + // Solution: NoSplit: Resend at next SOF
6540 + // Split : Resend at next SOF with SSPLIT
6541 + _ifxhc->xfer_len = 0;
6542 + _ifxhc->xfer_count = 0;
6543 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
6544 + _ifxhc->wait_for_sof = 1;
6545 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6550 + _ifxhc->wait_for_sof = 0;
6551 + complete_channel(_ifxhcd, _ifxhc, _urbd);
6555 + else if(hcint.b.nak )
6557 + _urbd->error_count=0;
6559 + _ifxhc->split = 1;
6560 + _ifxhc->wait_for_sof = 1;
6562 + _ifxhc->do_ping =1;
6564 + _ifxhc->do_ping =0;
6565 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6566 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6567 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6570 + else if(hcint.b.nyet)
6572 + //Retry Complete Split
6573 + // Issue Retry instantly on next SOF, without gothrough process_channels
6574 + _urbd->error_count=0;
6575 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
6576 + _ifxhc->wait_for_sof = 1;
6577 + _ifxhc->do_ping = 0;
6578 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6581 + else if(hcint.b.stall )
6583 + _urbd->error_count=0;
6584 + _ifxhc->wait_for_sof = 0;
6585 + _ifxhc->do_ping = 0;
6586 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6589 + else if(hcint.b.xacterr )
6591 + _urbd->error_count++;
6592 + if(_urbd->error_count>=3)
6594 + _urbd->error_count=0;
6595 + _ifxhc->wait_for_sof = 0;
6596 + _ifxhc->do_ping = 0;
6597 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
6602 + _ifxhc->wait_for_sof = 1;
6604 + _ifxhc->do_ping =1;
6606 + _ifxhc->do_ping =0;
6607 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6608 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6609 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6613 + else if(hcint.b.datatglerr )
6615 + if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
6616 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
6618 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
6620 + _ifxhc->wait_for_sof = 1;
6622 + _ifxhc->do_ping =1;
6624 + _ifxhc->do_ping =0;
6625 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6626 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6627 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6630 + else if(hcint.b.frmovrun )
6632 + _urbd->error_count=0;
6633 + _ifxhc->wait_for_sof = 0;
6634 + _ifxhc->do_ping = 0;
6635 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
6638 + else if(hcint.b.bblerr )
6640 + _urbd->error_count=0;
6641 + _ifxhc->wait_for_sof = 0;
6642 + _ifxhc->do_ping = 0;
6643 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
6648 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6649 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6650 +static int32_t chhltd_intr_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
6651 + ifxhcd_hc_t *_ifxhc,
6652 + ifxusb_hc_regs_t *_hc_regs,
6653 + ifxhcd_urbd_t *_urbd)
6655 + hcint_data_t hcint;
6656 + hcint_data_t hcintmsk;
6657 + hctsiz_data_t hctsiz;
6659 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6660 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6661 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6662 + disable_hc_int(_hc_regs,ack);
6663 + disable_hc_int(_hc_regs,nak);
6664 + disable_hc_int(_hc_regs,nyet);
6665 + _ifxhc->do_ping = 0;
6667 + if (hcint.b.xfercomp )
6669 + _urbd->error_count=0;
6670 + _ifxhc->wait_for_sof = 0;
6672 + complete_channel(_ifxhcd, _ifxhc, _urbd);
6675 + else if(hcint.b.nak )
6677 + _urbd->error_count=0;
6678 + _ifxhc->split = 1;
6679 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6680 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6681 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6682 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6683 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6686 + else if(hcint.b.nyet)
6688 + _urbd->error_count=0;
6689 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
6690 + _ifxhc->wait_for_sof = 0;
6692 + /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
6693 + _ifxhc->nyet_count++;
6694 + if(_ifxhc->nyet_count > 2) {
6695 + _ifxhc->split = 1;
6696 + _ifxhc->nyet_count = 0;
6697 + _ifxhc->wait_for_sof = 5;
6700 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6703 + else if(hcint.b.frmovrun || hcint.b.bblerr || hcint.b.stall )
6705 + _urbd->error_count=0;
6706 + _ifxhc->wait_for_sof = 0;
6707 + if (hcint.b.stall)
6708 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6709 + else if(hcint.b.bblerr )
6710 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
6711 + else if(hcint.b.frmovrun )
6712 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
6715 + else if(hcint.b.xacterr )
6717 + hcchar_data_t hcchar;
6718 + hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
6719 + _urbd->error_count=hcchar.b.multicnt;
6720 + if(_urbd->error_count>=3)
6722 + _urbd->error_count=0;
6723 + _ifxhc->wait_for_sof = 0;
6724 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
6729 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6730 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6731 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6732 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6733 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6737 + else if(hcint.b.datatglerr )
6739 + if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
6740 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
6742 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
6744 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6745 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6746 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6747 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6748 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6753 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6754 +static int32_t chhltd_intr_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
6755 + ifxhcd_hc_t *_ifxhc,
6756 + ifxusb_hc_regs_t *_hc_regs,
6757 + ifxhcd_urbd_t *_urbd)
6759 + hcint_data_t hcint;
6760 + hcint_data_t hcintmsk;
6761 + hctsiz_data_t hctsiz;
6762 + int out_nak_enh = 0;
6764 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
6767 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6768 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6769 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6770 + disable_hc_int(_hc_regs,ack);
6771 + disable_hc_int(_hc_regs,nak);
6772 + disable_hc_int(_hc_regs,nyet);
6774 + if(hcint.b.xfercomp )
6776 + _urbd->error_count=0;
6777 + _ifxhc->wait_for_sof = 0;
6779 + _ifxhc->do_ping = 0;
6780 + complete_channel(_ifxhcd, _ifxhc, _urbd);
6783 + else if(hcint.b.nak )
6785 + _urbd->error_count=0;
6786 + _ifxhc->split = 1;
6787 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6788 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6790 + _ifxhc->do_ping =1;
6792 + _ifxhc->do_ping =0;
6793 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6794 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6795 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6798 + else if(hcint.b.nyet)
6800 + _urbd->error_count=0;
6801 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
6802 + _ifxhc->wait_for_sof = 0;
6803 + _ifxhc->do_ping = 0;
6805 + /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
6806 + _ifxhc->nyet_count++;
6807 + if(_ifxhc->nyet_count > 2) {
6808 + _ifxhc->split = 1;
6809 + _ifxhc->nyet_count = 0;
6810 + _ifxhc->wait_for_sof = 5;
6813 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6816 + else if(hcint.b.stall || hcint.b.frmovrun)
6818 + _urbd->error_count=0;
6819 + _ifxhc->wait_for_sof = 0;
6820 + _ifxhc->do_ping = 0;
6821 + if (hcint.b.stall)
6822 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6823 + else if(hcint.b.frmovrun )
6824 + release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
6827 + else if(hcint.b.xacterr )
6829 + hcchar_data_t hcchar;
6830 + hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
6831 + _urbd->error_count=hcchar.b.multicnt;
6832 + if(_urbd->error_count>=3)
6834 + _urbd->error_count=0;
6835 + _ifxhc->wait_for_sof = 0;
6836 + _ifxhc->do_ping = 0;
6837 + release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
6842 + _ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
6843 + if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
6845 + _ifxhc->do_ping =1;
6847 + _ifxhc->do_ping =0;
6848 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6849 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6850 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6854 + else if(hcint.b.datatglerr )
6856 + if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
6857 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
6859 + _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
6862 + _ifxhc->do_ping =1;
6864 + _ifxhc->do_ping =0;
6865 + _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
6866 + _ifxhc->xfer_count = _urbd->urb->actual_length;
6867 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6870 + else if(hcint.b.bblerr )
6872 + _urbd->error_count=0;
6873 + _ifxhc->wait_for_sof = 0;
6874 + _ifxhc->do_ping = 0;
6875 + release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
6880 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6881 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6882 +static int32_t chhltd_isoc_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
6883 + ifxhcd_hc_t *_ifxhc,
6884 + ifxusb_hc_regs_t *_hc_regs,
6885 + ifxhcd_urbd_t *_urbd)
6887 + #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
6888 + hcint_data_t hcint;
6889 + hcint_data_t hcintmsk;
6890 + hctsiz_data_t hctsiz;
6892 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6893 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6894 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6895 + if(hcint.b.xfercomp )
6897 + disable_hc_int(_hc_regs,ack);
6898 + disable_hc_int(_hc_regs,nak);
6899 + disable_hc_int(_hc_regs,nyet);
6900 + _urbd->error_count=0;
6901 + _ifxhc->wait_for_sof = 0;
6903 + complete_channel(_ifxhcd, _ifxhc, _urbd);
6906 + else if(hcint.b.nak )
6908 + Retry Start Split (in next b_interval ¡V 1 uF)
6910 + else if(hcint.b.nyet)
6912 + //Do Next Complete Split
6913 + // Issue Retry instantly on next SOF, without gothrough process_channels
6914 + _urbd->error_count=0;
6915 + //disable_hc_int(_hc_regs,ack);
6916 + //disable_hc_int(_hc_regs,nak);
6917 + //disable_hc_int(_hc_regs,datatglerr);
6918 + _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
6919 + _ifxhc->wait_for_sof = 1;
6920 + ifxhcd_hc_start(&_ifxhcd->core_if, _ifxhc);
6923 + else if(hcint.b.frmovrun || hcint.b.stall || hcint.b.bblerr)
6925 + _urbd->error_count=0;
6926 + disable_hc_int(_hc_regs,ack);
6927 + disable_hc_int(_hc_regs,nyet);
6928 + disable_hc_int(_hc_regs,nak);
6929 + _ifxhc->wait_for_sof = 0;
6931 + //if(hctsiz.b.pktcnt==0)
6933 + // complete_channel(_ifxhcd, _ifxhc, _urbd);
6937 + // _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
6938 + if (hcint.b.stall)
6939 + release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
6940 + else if(hcint.b.frmovrun )
6941 + else if(hcint.b.bblerr )
6944 + else if(hcint.b.xacterr )
6946 + Rewind Buffer Pointers
6947 + if (HCCHARn.EC = = 3) // ERR response received
6950 + Do Next Start Split (in next frame)
6954 + De-allocate Channel
6957 + else if(hcint.b.datatglerr )
6961 + else if(hcint.b.ack )
6968 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6969 +static int32_t chhltd_isoc_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
6970 + ifxhcd_hc_t *_ifxhc,
6971 + ifxusb_hc_regs_t *_hc_regs,
6972 + ifxhcd_urbd_t *_urbd)
6974 + #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
6975 + hcint_data_t hcint;
6976 + hcint_data_t hcintmsk;
6977 + hctsiz_data_t hctsiz;
6978 + int out_nak_enh = 0;
6980 + if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
6983 + hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
6984 + hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
6985 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
6990 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6991 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6992 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6994 +static int32_t handle_hc_chhltd_intr(ifxhcd_hcd_t *_ifxhcd,
6995 + ifxhcd_hc_t *_ifxhc,
6996 + ifxusb_hc_regs_t *_hc_regs,
6997 + ifxhcd_urbd_t *_urbd)
6999 + IFX_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: Channel Halted--\n", _ifxhc->hc_num);
7001 + _ifxhc->halting = 0;
7002 + _ifxhc->xfer_started = 0;
7004 + if (_ifxhc->halt_status == HC_XFER_URB_DEQUEUE ||
7005 + _ifxhc->halt_status == HC_XFER_AHB_ERR) {
7007 + * Just release the channel. A dequeue can happen on a
7008 + * transfer timeout. In the case of an AHB Error, the channel
7009 + * was forced to halt because there's no way to gracefully
7012 + release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
7016 + if (_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL || _ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
7018 + if (_ifxhc->split==0)
7021 + return (chhltd_ctrlbulk_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7023 + return (chhltd_ctrlbulk_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7025 + else if(_ifxhc->split==1)
7028 + return (chhltd_ctrlbulk_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7030 + return (chhltd_ctrlbulk_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7032 + else if(_ifxhc->split==2)
7035 + return (chhltd_ctrlbulk_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7037 + return (chhltd_ctrlbulk_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7040 + else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR)
7042 + if (_ifxhc->split==0)
7045 + return (chhltd_intr_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7047 + return (chhltd_intr_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7049 + else if(_ifxhc->split==1)
7052 + return (chhltd_intr_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7054 + return (chhltd_intr_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7056 + else if(_ifxhc->split==2)
7059 + return (chhltd_intr_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7061 + return (chhltd_intr_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7064 + else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
7066 + if (_ifxhc->split==0)
7069 + return (chhltd_isoc_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7071 + return (chhltd_isoc_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7073 + else if(_ifxhc->split==1)
7076 + return (chhltd_isoc_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7078 + return (chhltd_isoc_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7080 + else if(_ifxhc->split==2)
7083 + return (chhltd_isoc_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7085 + return (chhltd_isoc_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
7092 + * Handles a host channel AHB error interrupt. This handler is only called in
7095 +static void hc_other_intr_dump(ifxhcd_hcd_t *_ifxhcd,
7096 + ifxhcd_hc_t *_ifxhc,
7097 + ifxusb_hc_regs_t *_hc_regs,
7098 + ifxhcd_urbd_t *_urbd)
7101 + hcchar_data_t hcchar;
7102 + hcsplt_data_t hcsplt;
7103 + hctsiz_data_t hctsiz;
7105 + struct urb *urb = _urbd->urb;
7106 + hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
7107 + hcsplt.d32 = ifxusb_rreg(&_hc_regs->hcsplt);
7108 + hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
7109 + hcdma = ifxusb_rreg(&_hc_regs->hcdma);
7111 + IFX_ERROR("Channel %d\n", _ifxhc->hc_num);
7112 + IFX_ERROR(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar.d32, hcsplt.d32);
7113 + IFX_ERROR(" hctsiz 0x%08x, hcdma 0x%08x\n", hctsiz.d32, hcdma);
7114 + IFX_ERROR(" Device address: %d\n", usb_pipedevice(urb->pipe));
7115 + IFX_ERROR(" Endpoint: %d, %s\n", usb_pipeendpoint(urb->pipe),
7116 + (usb_pipein(urb->pipe) ? "IN" : "OUT"));
7117 + IFX_ERROR(" Endpoint type: %s\n",
7119 + switch (usb_pipetype(urb->pipe)) {
7120 + case PIPE_CONTROL: pipetype = "CTRL"; break;
7121 + case PIPE_BULK: pipetype = "BULK"; break;
7122 + case PIPE_INTERRUPT: pipetype = "INTR"; break;
7123 + case PIPE_ISOCHRONOUS: pipetype = "ISOC"; break;
7124 + default: pipetype = "????"; break;
7126 + IFX_ERROR(" Speed: %s\n",
7128 + switch (urb->dev->speed) {
7129 + case USB_SPEED_HIGH: speed = "HS"; break;
7130 + case USB_SPEED_FULL: speed = "FS"; break;
7131 + case USB_SPEED_LOW: speed = "LS"; break;
7132 + default: speed = "????"; break;
7134 + IFX_ERROR(" Max packet size: %d\n",
7135 + usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)));
7136 + IFX_ERROR(" Data buffer length: %d\n", urb->transfer_buffer_length);
7137 + IFX_ERROR(" Transfer buffer: %p, Transfer DMA: %p\n",
7138 + urb->transfer_buffer, (void *)urb->transfer_dma);
7139 + IFX_ERROR(" Setup buffer: %p, Setup DMA: %p\n",
7140 + urb->setup_packet, (void *)urb->setup_dma);
7141 + IFX_ERROR(" Interval: %d\n", urb->interval);
7142 + #endif //__DEBUG__
7146 + * Handles a host channel ACK interrupt. This interrupt is enabled when
7147 + * errors occur, and during Start Split transactions.
7149 +static int32_t handle_hc_ack_intr(ifxhcd_hcd_t *_ifxhcd,
7150 + ifxhcd_hc_t *_ifxhc,
7151 + ifxusb_hc_regs_t *_hc_regs,
7152 + ifxhcd_urbd_t *_urbd)
7154 + _urbd->error_count=0;
7155 + if(_ifxhc->nak_countdown_r)
7157 + _ifxhc->nak_retry=_ifxhc->nak_retry_r;
7158 + _ifxhc->nak_countdown=_ifxhc->nak_countdown_r;
7161 + disable_hc_int(_hc_regs,nak);
7162 + disable_hc_int(_hc_regs,ack);
7167 + * Handles a host channel ACK interrupt. This interrupt is enabled when
7168 + * errors occur, and during Start Split transactions.
7170 +static int32_t handle_hc_nak_intr(ifxhcd_hcd_t *_ifxhcd,
7171 + ifxhcd_hc_t *_ifxhc,
7172 + ifxusb_hc_regs_t *_hc_regs,
7173 + ifxhcd_urbd_t *_urbd)
7176 + _urbd->error_count=0;
7178 + if(_ifxhc->nak_countdown_r)
7180 + _ifxhc->nak_countdown--;
7181 + if(!_ifxhc->nak_countdown)
7183 + _ifxhc->nak_countdown=_ifxhc->nak_countdown_r;
7184 + disable_hc_int(_hc_regs,ack);
7185 + disable_hc_int(_hc_regs,nak);
7186 + ifxhcd_hc_halt(&_ifxhcd->core_if, _ifxhc, HC_XFER_NAK);
7189 + enable_hc_int(_hc_regs,ack);
7193 + disable_hc_int(_hc_regs,ack);
7194 + disable_hc_int(_hc_regs,nak);
7200 + * Handles a host channel AHB error interrupt. This handler is only called in
7203 +static int32_t handle_hc_ahberr_intr(ifxhcd_hcd_t *_ifxhcd,
7204 + ifxhcd_hc_t *_ifxhc,
7205 + ifxusb_hc_regs_t *_hc_regs,
7206 + ifxhcd_urbd_t *_urbd)
7208 + IFX_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
7209 + "AHB Error--\n", _ifxhc->hc_num);
7210 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7212 + ifxhcd_hc_halt(&_ifxhcd->core_if, _ifxhc, HC_XFER_AHB_ERR);
7219 +static int32_t handle_hc_datatglerr_intr(ifxhcd_hcd_t *_ifxhcd,
7220 + ifxhcd_hc_t *_ifxhc,
7221 + ifxusb_hc_regs_t *_hc_regs,
7222 + ifxhcd_urbd_t *_urbd)
7224 + IFX_ERROR( "--Host Channel %d Interrupt: "
7225 + "DATATOGGLE Error--\n", _ifxhc->hc_num);
7226 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7227 + disable_hc_int(_hc_regs,datatglerr);
7234 + * Interrupts which should not been triggered
7236 +static int32_t handle_hc_frmovrun_intr(ifxhcd_hcd_t *_ifxhcd,
7237 + ifxhcd_hc_t *_ifxhc,
7238 + ifxusb_hc_regs_t *_hc_regs,
7239 + ifxhcd_urbd_t *_urbd)
7241 + IFX_ERROR( "--Host Channel %d Interrupt: "
7242 + "FrameOverRun Error--\n", _ifxhc->hc_num);
7243 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7244 + disable_hc_int(_hc_regs,frmovrun);
7248 +static int32_t handle_hc_bblerr_intr(ifxhcd_hcd_t *_ifxhcd,
7249 + ifxhcd_hc_t *_ifxhc,
7250 + ifxusb_hc_regs_t *_hc_regs,
7251 + ifxhcd_urbd_t *_urbd)
7253 + IFX_ERROR( "--Host Channel %d Interrupt: "
7254 + "BBL Error--\n", _ifxhc->hc_num);
7255 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7256 + disable_hc_int(_hc_regs,bblerr);
7260 +static int32_t handle_hc_xacterr_intr(ifxhcd_hcd_t *_ifxhcd,
7261 + ifxhcd_hc_t *_ifxhc,
7262 + ifxusb_hc_regs_t *_hc_regs,
7263 + ifxhcd_urbd_t *_urbd)
7265 + IFX_ERROR( "--Host Channel %d Interrupt: "
7266 + "XACT Error--\n", _ifxhc->hc_num);
7267 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7268 + disable_hc_int(_hc_regs,xacterr);
7272 +static int32_t handle_hc_nyet_intr(ifxhcd_hcd_t *_ifxhcd,
7273 + ifxhcd_hc_t *_ifxhc,
7274 + ifxusb_hc_regs_t *_hc_regs,
7275 + ifxhcd_urbd_t *_urbd)
7277 + IFX_ERROR( "--Host Channel %d Interrupt: "
7278 + "NYET--\n", _ifxhc->hc_num);
7279 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7280 + _urbd->error_count=0;
7281 + disable_hc_int(_hc_regs,nyet);
7285 +static int32_t handle_hc_stall_intr(ifxhcd_hcd_t *_ifxhcd,
7286 + ifxhcd_hc_t *_ifxhc,
7287 + ifxusb_hc_regs_t *_hc_regs,
7288 + ifxhcd_urbd_t *_urbd)
7290 + IFX_ERROR( "--Host Channel %d Interrupt: "
7291 + "STALL--\n", _ifxhc->hc_num);
7292 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7293 + disable_hc_int(_hc_regs,stall);
7297 +static int32_t handle_hc_xfercomp_intr(ifxhcd_hcd_t *_ifxhcd,
7298 + ifxhcd_hc_t *_ifxhc,
7299 + ifxusb_hc_regs_t *_hc_regs,
7300 + ifxhcd_urbd_t *_urbd)
7302 + IFX_ERROR( "--Host Channel %d Interrupt: "
7303 + "XFERCOMP--\n", _ifxhc->hc_num);
7304 + hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
7305 + disable_hc_int(_hc_regs,xfercomp);
7311 +/* This interrupt indicates that the specified host channels has a pending
7312 + * interrupt. There are multiple conditions that can cause each host channel
7313 + * interrupt. This function determines which conditions have occurred for this
7314 + * host channel interrupt and handles them appropriately. */
7315 +static int32_t handle_hc_n_intr (ifxhcd_hcd_t *_ifxhcd, uint32_t _num)
7317 + uint32_t hcintval,hcintmsk;
7318 + hcint_data_t hcint;
7319 + ifxhcd_hc_t *ifxhc;
7320 + ifxusb_hc_regs_t *hc_regs;
7321 + ifxhcd_urbd_t *urbd;
7322 + unsigned long flags;
7326 + IFX_DEBUGPL(DBG_HCDV, "--Host Channel Interrupt--, Channel %d\n", _num);
7328 + /*== AVM/BC 20101111 Lock needed ==*/
7329 + SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
7331 + ifxhc = &_ifxhcd->ifxhc[_num];
7332 + hc_regs = _ifxhcd->core_if.hc_regs[_num];
7334 + hcintval = ifxusb_rreg(&hc_regs->hcint);
7335 + hcintmsk = ifxusb_rreg(&hc_regs->hcintmsk);
7336 + hcint.d32 = hcintval & hcintmsk;
7337 + IFX_DEBUGPL(DBG_HCDV, " 0x%08x & 0x%08x = 0x%08x\n",
7338 + hcintval, hcintmsk, hcint.d32);
7340 + urbd = list_entry(ifxhc->epqh->urbd_list.next, ifxhcd_urbd_t, urbd_list_entry);
7342 + if (hcint.b.datatglerr)
7343 + retval |= handle_hc_datatglerr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7344 + if (hcint.b.frmovrun)
7345 + retval |= handle_hc_frmovrun_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7346 + if (hcint.b.bblerr)
7347 + retval |= handle_hc_bblerr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7348 + if (hcint.b.xacterr)
7349 + retval |= handle_hc_xacterr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7351 + retval |= handle_hc_nyet_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7353 + retval |= handle_hc_ack_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7355 + retval |= handle_hc_nak_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7356 + if (hcint.b.stall)
7357 + retval |= handle_hc_stall_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7358 + if (hcint.b.ahberr) {
7359 + clear_hc_int(hc_regs, ahberr);
7360 + retval |= handle_hc_ahberr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7362 + if (hcint.b.chhltd) {
7363 + /* == 20110901 AVM/WK Fix: Flag must not be cleared after restart of channel ==*/
7364 + clear_hc_int(hc_regs, chhltd);
7365 + retval |= handle_hc_chhltd_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7367 + if (hcint.b.xfercomp)
7368 + retval |= handle_hc_xfercomp_intr(_ifxhcd, ifxhc, hc_regs, urbd);
7370 + /* == 20110901 AVM/WK Fix: Never clear possibly new intvals ==*/
7371 + //ifxusb_wreg(&hc_regs->hcint,hcintval);
7373 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
7383 +static uint8_t update_interval_counter(ifxhcd_epqh_t *_epqh,uint32_t _diff)
7385 + if(_diff>=_epqh->period_counter)
7387 + _epqh->period_do=1;
7388 + if(_diff>_epqh->interval)
7389 + _epqh->period_counter=1;
7391 + _epqh->period_counter=_epqh->period_counter+_epqh->interval-_diff;
7394 + _epqh->period_counter=_epqh->period_counter-_diff;
7402 + * Handles the start-of-frame interrupt in host mode. Non-periodic
7403 + * transactions may be queued to the DWC_otg controller for the current
7404 + * (micro)frame. Periodic transactions may be queued to the controller for the
7405 + * next (micro)frame.
7407 +static int32_t handle_sof_intr (ifxhcd_hcd_t *_ifxhcd)
7409 + #ifdef __DYN_SOF_INTR__
7410 + uint8_t with_count_down=0;
7412 + uint8_t active_on=0;
7413 + uint8_t ready_on=0;
7414 + struct list_head *epqh_entry;
7415 + ifxhcd_epqh_t *epqh;
7416 + hfnum_data_t hfnum;
7419 + unsigned long flags;
7420 +#ifdef __USE_TIMER_4_SOF__
7421 + uint32_t wait_for_sof = 0x10000;
7424 + SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
7428 + ifxusb_hc_regs_t *hc_regs;
7430 + num_channels = _ifxhcd->core_if.params.host_channels;
7432 +// AVM/WK moved block here due to use of SOF timer
7433 + hfnum.d32 = ifxusb_rreg(&_ifxhcd->core_if.host_global_regs->hfnum);
7434 + fndiff = hfnum.b.frnum;
7435 + fndiff+= 0x00004000;
7436 + fndiff-= _ifxhcd->lastframe ;
7437 + fndiff&= 0x00003FFF;
7438 + if(!fndiff) fndiff =1;
7440 + for (i = 0; i < num_channels; i++)
7442 + if(_ifxhcd->ifxhc[i].wait_for_sof && _ifxhcd->ifxhc[i].xfer_started)
7444 +#ifdef __USE_TIMER_4_SOF__
7445 + if (_ifxhcd->ifxhc[i].wait_for_sof > fndiff) {
7446 + _ifxhcd->ifxhc[i].wait_for_sof -= fndiff;
7448 + _ifxhcd->ifxhc[i].wait_for_sof = 0;
7451 + _ifxhcd->ifxhc[i].wait_for_sof--;
7453 + if(_ifxhcd->ifxhc[i].wait_for_sof==0)
7455 + hcint_data_t hcint= { .d32=0 };
7456 + hc_regs = _ifxhcd->core_if.hc_regs[i];
7458 + hcint.d32 =0xFFFFFFFF;
7459 + ifxusb_wreg(&hc_regs->hcint, hcint.d32);
7461 + hcint.d32=ifxusb_rreg(&hc_regs->hcintmsk);
7464 + /* == 20110901 AVM/WK Fix: We don't need NOT YET IRQ ==*/
7466 + _ifxhcd->ifxhc[i].nak_countdown=_ifxhcd->ifxhc[i].nak_countdown_r;
7467 + if(_ifxhcd->ifxhc[i].nak_countdown_r)
7469 + ifxusb_wreg(&hc_regs->hcintmsk, hcint.d32);
7471 + /* AVM WK / BC 20100827
7472 + * FIX: Packet was ignored because of wrong Oddframe bit
7474 + if (_ifxhcd->ifxhc[i].ep_type == IFXUSB_EP_TYPE_INTR || _ifxhcd->ifxhc[i].ep_type == IFXUSB_EP_TYPE_ISOC)
7476 + hcchar_data_t hcchar;
7477 + hcchar.d32 = _ifxhcd->ifxhc[i].hcchar;
7478 + hfnum.d32 = ifxusb_rreg(&_ifxhcd->core_if.host_global_regs->hfnum);
7479 + /* 1 if _next_ frame is odd, 0 if it's even */
7480 + hcchar.b.oddfrm = (hfnum.b.frnum & 0x1) ? 0 : 1;
7481 + _ifxhcd->ifxhc[i].hcchar = hcchar.d32;
7484 + ifxusb_wreg(&hc_regs->hcchar, _ifxhcd->ifxhc[i].hcchar);
7489 + _ifxhcd->ifxhc[i].wait_for_sof=0;
7491 +#ifdef __USE_TIMER_4_SOF__
7492 + if (_ifxhcd->ifxhc[i].wait_for_sof && (wait_for_sof > _ifxhcd->ifxhc[i].wait_for_sof)) {
7493 + wait_for_sof = _ifxhcd->ifxhc[i].wait_for_sof;
7500 + #ifdef __EN_ISOC__
7501 + #error ISOC not supported: missing SOF code
7502 + epqh_entry = _ifxhcd->epqh_isoc_active.next;
7503 + while (epqh_entry != &_ifxhcd->epqh_isoc_active)
7505 + epqh = list_entry(epqh_entry, ifxhcd_epqh_t, epqh_list_entry);
7506 + epqh_entry = epqh_entry->next;
7507 + #ifdef __DYN_SOF_INTR__
7508 + with_count_down=1;
7510 + active_on+=update_interval_counter(epqh,fndiff);
7514 + epqh_entry = _ifxhcd->epqh_isoc_ready.next;
7515 + while (epqh_entry != &_ifxhcd->epqh_isoc_ready)
7517 + epqh = list_entry(epqh_entry, ifxhcd_epqh_t, epqh_list_entry);
7518 + epqh_entry = epqh_entry->next;
7519 + #ifdef __DYN_SOF_INTR__
7520 + with_count_down=1;
7522 + ready_on+=update_interval_counter(epqh,fndiff);
7527 + epqh_entry = _ifxhcd->epqh_intr_active.next;
7528 + while (epqh_entry != &_ifxhcd->epqh_intr_active)
7530 + epqh = list_entry(epqh_entry, ifxhcd_epqh_t, epqh_list_entry);
7531 + epqh_entry = epqh_entry->next;
7532 + #ifdef __DYN_SOF_INTR__
7533 + with_count_down=1;
7535 +#ifdef __USE_TIMER_4_SOF__
7536 + if (update_interval_counter(epqh,fndiff)) {
7540 + if (epqh->period_counter && (wait_for_sof > epqh->period_counter)) {
7541 + wait_for_sof = epqh->period_counter;
7545 + active_on+=update_interval_counter(epqh,fndiff);
7550 + epqh_entry = _ifxhcd->epqh_intr_ready.next;
7551 + while (epqh_entry != &_ifxhcd->epqh_intr_ready)
7553 + epqh = list_entry(epqh_entry, ifxhcd_epqh_t, epqh_list_entry);
7554 + epqh_entry = epqh_entry->next;
7555 + #ifdef __DYN_SOF_INTR__
7556 + with_count_down=1;
7558 +#ifdef __USE_TIMER_4_SOF__
7559 + if (update_interval_counter(epqh,fndiff)) {
7563 + if (epqh->period_counter && (wait_for_sof > epqh->period_counter)) {
7564 + wait_for_sof = epqh->period_counter;
7568 + ready_on+=update_interval_counter(epqh,fndiff);
7573 + epqh_entry = _ifxhcd->epqh_stdby.next;
7574 + while (epqh_entry != &_ifxhcd->epqh_stdby)
7576 + epqh = list_entry(epqh_entry, ifxhcd_epqh_t, epqh_list_entry);
7577 + epqh_entry = epqh_entry->next;
7578 + if(epqh->period_counter > 0 ) {
7579 +#ifdef __USE_TIMER_4_SOF__
7580 + if (epqh->period_counter > fndiff) {
7581 + epqh->period_counter -= fndiff;
7583 + epqh->period_counter = 0;
7586 + epqh->period_counter --;
7588 + #ifdef __DYN_SOF_INTR__
7589 + with_count_down=1;
7592 + if(epqh->period_counter == 0) {
7593 + ifxhcd_epqh_idle_periodic(epqh);
7595 +#ifdef __USE_TIMER_4_SOF__
7597 + if (wait_for_sof > epqh->period_counter) {
7598 + wait_for_sof = epqh->period_counter;
7603 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
7606 + select_eps(_ifxhcd);
7607 + else if(active_on)
7608 + process_channels(_ifxhcd);
7610 + /* Clear interrupt */
7612 + gint_data_t gintsts;
7614 + gintsts.b.sofintr = 1;
7615 + ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
7617 + #ifdef __DYN_SOF_INTR__
7618 + if(!with_count_down)
7619 + ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk, gintsts.d32,0);
7621 +#ifdef __USE_TIMER_4_SOF__
7622 + wait_for_sof &= 0xFFFF; // reduce to 16 Bits.
7624 + if(wait_for_sof == 1) {
7626 + gint_data_t gintsts;
7628 + gintsts.b.sofintr = 1;
7629 + ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk, 0,gintsts.d32);
7632 + ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk, gintsts.d32,0);
7633 + if (wait_for_sof > 1) {
7634 + // use timer, not SOF IRQ
7635 + hprt0_data_t hprt0;
7637 + hprt0.d32 = ifxusb_read_hprt0 (&_ifxhcd->core_if);
7638 + if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED) {
7639 + ktime = ktime_set(0, wait_for_sof * 125 * 1000); /*--- wakeup in n*125usec ---*/
7641 + ktime = ktime_set(0, wait_for_sof * (1000*1000)); /*--- wakeup in n*1000usec ---*/
7643 + hrtimer_start(&_ifxhcd->hr_timer, ktime, HRTIMER_MODE_REL);
7648 + _ifxhcd->lastframe=hfnum.b.frnum;
7654 +/* There are multiple conditions that can cause a port interrupt. This function
7655 + * determines which interrupt conditions have occurred and handles them
7656 + * appropriately. */
7657 +static int32_t handle_port_intr (ifxhcd_hcd_t *_ifxhcd)
7660 + hprt0_data_t hprt0;
7661 + hprt0_data_t hprt0_modify;
7664 + hprt0_modify.d32 = ifxusb_rreg(_ifxhcd->core_if.hprt0);
7666 + /* Clear appropriate bits in HPRT0 to clear the interrupt bit in
7669 + hprt0_modify.b.prtena = 0;
7670 + hprt0_modify.b.prtconndet = 0;
7671 + hprt0_modify.b.prtenchng = 0;
7672 + hprt0_modify.b.prtovrcurrchng = 0;
7674 + /* Port Connect Detected
7675 + * Set flag and clear if detected */
7676 + if (hprt0.b.prtconndet) {
7677 + IFX_DEBUGPL(DBG_HCD, "--Port Interrupt HPRT0=0x%08x "
7678 + "Port Connect Detected--\n", hprt0.d32);
7679 + _ifxhcd->flags.b.port_connect_status_change = 1;
7680 + _ifxhcd->flags.b.port_connect_status = 1;
7681 + hprt0_modify.b.prtconndet = 1;
7683 + /* The Hub driver asserts a reset when it sees port connect
7684 + * status change flag */
7688 + /* Port Enable Changed
7689 + * Clear if detected - Set internal flag if disabled */
7690 + if (hprt0.b.prtenchng) {
7692 + IFX_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
7693 + "Port Enable Changed--\n", hprt0.d32);
7694 + hprt0_modify.b.prtenchng = 1;
7695 + if (hprt0.b.prtena == 1)
7696 + /* Port has been enabled set the reset change flag */
7697 + _ifxhcd->flags.b.port_reset_change = 1;
7699 + _ifxhcd->flags.b.port_enable_change = 1;
7703 + /* Overcurrent Change Interrupt */
7705 + if (hprt0.b.prtovrcurrchng) {
7706 + IFX_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
7707 + "Port Overcurrent Changed--\n", hprt0.d32);
7708 + _ifxhcd->flags.b.port_over_current_change = 1;
7709 + hprt0_modify.b.prtovrcurrchng = 1;
7713 + /* Clear Port Interrupts */
7714 + ifxusb_wreg(_ifxhcd->core_if.hprt0, hprt0_modify.d32);
7719 + * This interrupt indicates that SUSPEND state has been detected on
7721 + * No Functioning in Host Mode
7723 +static int32_t handle_usb_suspend_intr(ifxhcd_hcd_t *_ifxhcd)
7725 + gint_data_t gintsts;
7726 + IFX_DEBUGP("USB SUSPEND RECEIVED!\n");
7727 + /* Clear interrupt */
7729 + gintsts.b.usbsuspend = 1;
7730 + ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
7735 + * This interrupt indicates that the IFXUSB controller has detected a
7736 + * resume or remote wakeup sequence. If the IFXUSB controller is in
7737 + * low power mode, the handler must brings the controller out of low
7738 + * power mode. The controller automatically begins resume
7739 + * signaling. The handler schedules a time to stop resume signaling.
7741 +static int32_t handle_wakeup_detected_intr(ifxhcd_hcd_t *_ifxhcd)
7743 + gint_data_t gintsts;
7744 + hprt0_data_t hprt0 = {.d32=0};
7745 + pcgcctl_data_t pcgcctl = {.d32=0};
7746 + ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
7748 + IFX_DEBUGPL(DBG_ANY, "++Resume and Remote Wakeup Detected Interrupt++\n");
7751 + * Clear the Resume after 70ms. (Need 20 ms minimum. Use 70 ms
7752 + * so that OPT tests pass with all PHYs).
7754 + /* Restart the Phy Clock */
7755 + pcgcctl.b.stoppclk = 1;
7756 + ifxusb_mreg(core_if->pcgcctl, pcgcctl.d32, 0);
7759 + /* Now wait for 70 ms. */
7760 + hprt0.d32 = ifxusb_read_hprt0( core_if );
7761 + IFX_DEBUGPL(DBG_ANY,"Resume: HPRT0=%0x\n", hprt0.d32);
7763 + hprt0.b.prtres = 0; /* Resume */
7764 + ifxusb_wreg(core_if->hprt0, hprt0.d32);
7765 + IFX_DEBUGPL(DBG_ANY,"Clear Resume: HPRT0=%0x\n", ifxusb_rreg(core_if->hprt0));
7767 + /* Clear interrupt */
7769 + gintsts.b.wkupintr = 1;
7770 + ifxusb_wreg(&core_if->core_global_regs->gintsts, gintsts.d32);
7775 + * This interrupt indicates that a device is initiating the Session
7776 + * Request Protocol to request the host to turn on bus power so a new
7777 + * session can begin. The handler responds by turning on bus power. If
7778 + * the DWC_otg controller is in low power mode, the handler brings the
7779 + * controller out of low power mode before turning on bus power.
7781 +static int32_t handle_session_req_intr(ifxhcd_hcd_t *_ifxhcd)
7783 + /* Clear interrupt */
7784 + gint_data_t gintsts = { .d32 = 0 };
7785 + gintsts.b.sessreqintr = 1;
7786 + ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
7791 + * This interrupt indicates that a device has been disconnected from
7794 +static int32_t handle_disconnect_intr(ifxhcd_hcd_t *_ifxhcd)
7796 + gint_data_t gintsts;
7798 + ifxhcd_disconnect(_ifxhcd);
7801 + gintsts.b.disconnect = 1;
7802 + ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
7807 + * This function handles the Connector ID Status Change Interrupt. It
7808 + * reads the OTG Interrupt Register (GOTCTL) to determine whether this
7809 + * is a Device to Host Mode transition or a Host Mode to Device
7811 + * This only occurs when the cable is connected/removed from the PHY
7814 +static int32_t handle_conn_id_status_change_intr(ifxhcd_hcd_t *_ifxhcd)
7816 + gint_data_t gintsts;
7818 + IFX_WARN("ID Status Change Interrupt: currently in %s mode\n",
7819 + ifxusb_mode(&_ifxhcd->core_if) ? "Host" : "Device");
7822 + gintsts.b.conidstschng = 1;
7823 + ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
7827 +static int32_t handle_otg_intr(ifxhcd_hcd_t *_ifxhcd)
7829 + ifxusb_core_global_regs_t *global_regs = _ifxhcd->core_if.core_global_regs;
7830 + gotgint_data_t gotgint;
7831 + gotgint.d32 = ifxusb_rreg( &global_regs->gotgint);
7832 + /* Clear GOTGINT */
7833 + ifxusb_wreg (&global_regs->gotgint, gotgint.d32);
7837 +/** This function will log a debug message */
7838 +static int32_t handle_mode_mismatch_intr(ifxhcd_hcd_t *_ifxhcd)
7840 + gint_data_t gintsts;
7842 + IFX_WARN("Mode Mismatch Interrupt: currently in %s mode\n",
7843 + ifxusb_mode(&_ifxhcd->core_if) ? "Host" : "Device");
7845 + gintsts.b.modemismatch = 1;
7846 + ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
7850 +/** This function handles interrupts for the HCD. */
7851 +int32_t ifxhcd_handle_intr (ifxhcd_hcd_t *_ifxhcd)
7855 + ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
7856 + /* AVM/BC 20101111 Unnecesary variable removed*/
7857 + //gint_data_t gintsts,gintsts2;
7858 + gint_data_t gintsts;
7860 + /* Check if HOST Mode */
7861 + if (ifxusb_is_device_mode(core_if))
7863 + IFX_ERROR("%s() CRITICAL! IN DEVICE MODE\n", __func__);
7867 + gintsts.d32 = ifxusb_read_core_intr(core_if);
7873 + if (gintsts.b.modemismatch)
7875 + retval |= handle_mode_mismatch_intr(_ifxhcd);
7876 + gintsts.b.modemismatch=0;
7878 + if (gintsts.b.otgintr)
7880 + retval |= handle_otg_intr(_ifxhcd);
7881 + gintsts.b.otgintr=0;
7883 + if (gintsts.b.conidstschng)
7885 + retval |= handle_conn_id_status_change_intr(_ifxhcd);
7886 + gintsts.b.conidstschng=0;
7888 + if (gintsts.b.disconnect)
7890 + retval |= handle_disconnect_intr(_ifxhcd);
7891 + gintsts.b.disconnect=0;
7893 + if (gintsts.b.sessreqintr)
7895 + retval |= handle_session_req_intr(_ifxhcd);
7896 + gintsts.b.sessreqintr=0;
7898 + if (gintsts.b.wkupintr)
7900 + retval |= handle_wakeup_detected_intr(_ifxhcd);
7901 + gintsts.b.wkupintr=0;
7903 + if (gintsts.b.usbsuspend)
7905 + retval |= handle_usb_suspend_intr(_ifxhcd);
7906 + gintsts.b.usbsuspend=0;
7910 + if (gintsts.b.sofintr)
7912 + retval |= handle_sof_intr (_ifxhcd);
7913 + gintsts.b.sofintr=0;
7915 + if (gintsts.b.portintr)
7917 + retval |= handle_port_intr (_ifxhcd);
7918 + gintsts.b.portintr=0;
7920 + if (gintsts.b.hcintr)
7923 + haint_data_t haint;
7924 + haint.d32 = ifxusb_read_host_all_channels_intr(core_if);
7925 + for (i=0; i< core_if->params.host_channels; i++)
7926 + if (haint.b2.chint & (1 << i))
7927 + retval |= handle_hc_n_intr (_ifxhcd, i);
7928 + gintsts.b.hcintr=0;
7933 +++ b/drivers/usb/ifxhcd/ifxhcd_queue.c
7935 +/*****************************************************************************
7936 + ** FILE NAME : ifxhcd_queue.c
7937 + ** PROJECT : IFX USB sub-system V3
7938 + ** MODULES : IFX USB sub-system Host and Device driver
7939 + ** SRC VERSION : 1.0
7940 + ** DATE : 1/Jan/2009
7941 + ** AUTHOR : Chen, Howard
7942 + ** DESCRIPTION : This file contains the functions to manage Queue Heads and Queue
7943 + ** Transfer Descriptors.
7944 + *****************************************************************************/
7947 + \file ifxhcd_queue.c
7948 + \ingroup IFXUSB_DRIVER_V3
7949 + \brief This file contains the functions to manage Queue Heads and Queue
7950 + Transfer Descriptors.
7952 +#include <linux/version.h>
7953 +#include "ifxusb_version.h"
7955 +#include <linux/kernel.h>
7956 +#include <linux/module.h>
7957 +#include <linux/moduleparam.h>
7958 +#include <linux/init.h>
7959 +#include <linux/device.h>
7960 +#include <linux/errno.h>
7961 +#include <linux/list.h>
7962 +#include <linux/interrupt.h>
7963 +#include <linux/string.h>
7965 +#include "ifxusb_plat.h"
7966 +#include "ifxusb_regs.h"
7967 +#include "ifxusb_cif.h"
7968 +#include "ifxhcd.h"
7970 +#ifdef __EPQD_DESTROY_TIMEOUT__
7971 + #define epqh_self_destroy_timeout 5
7972 + static void eqph_destroy_func(unsigned long _ptr)
7974 + ifxhcd_epqh_t *epqh=(ifxhcd_epqh_t *)_ptr;
7977 + ifxhcd_epqh_free (epqh);
7982 +#define SCHEDULE_SLOP 10
7985 + \brief This function allocates and initializes a EPQH.
7987 + \param _ifxhcd The HCD state structure for the USB Host controller.
7988 + \param[in] _urb Holds the information about the device/endpoint that we need
7989 + to initialize the EPQH.
7991 + \return Returns pointer to the newly allocated EPQH, or NULL on error.
7993 +ifxhcd_epqh_t *ifxhcd_epqh_create (ifxhcd_hcd_t *_ifxhcd, struct urb *_urb)
7995 + ifxhcd_epqh_t *epqh;
7997 + hprt0_data_t hprt0;
7998 + struct usb_host_endpoint *sysep = ifxhcd_urb_to_endpoint(_urb);
8000 + /* Allocate memory */
8001 +// epqh=(ifxhcd_epqh_t *) kmalloc (sizeof(ifxhcd_epqh_t), GFP_KERNEL);
8002 + epqh=(ifxhcd_epqh_t *) kmalloc (sizeof(ifxhcd_epqh_t), GFP_ATOMIC);
8007 + memset (epqh, 0, sizeof (ifxhcd_epqh_t));
8009 + epqh->sysep=sysep;
8011 + /* Initialize EPQH */
8012 + switch (usb_pipetype(_urb->pipe))
8014 + case PIPE_CONTROL : epqh->ep_type = IFXUSB_EP_TYPE_CTRL; break;
8015 + case PIPE_BULK : epqh->ep_type = IFXUSB_EP_TYPE_BULK; break;
8016 + case PIPE_ISOCHRONOUS: epqh->ep_type = IFXUSB_EP_TYPE_ISOC; break;
8017 + case PIPE_INTERRUPT : epqh->ep_type = IFXUSB_EP_TYPE_INTR; break;
8020 + //epqh->data_toggle = IFXUSB_HC_PID_DATA0;
8022 + epqh->mps = usb_maxpacket(_urb->dev, _urb->pipe, !(usb_pipein(_urb->pipe)));
8024 + hprt0.d32 = ifxusb_read_hprt0 (&_ifxhcd->core_if);
8026 + INIT_LIST_HEAD(&epqh->urbd_list);
8027 + INIT_LIST_HEAD(&epqh->epqh_list_entry);
8030 + epqh->dump_buf = ifxusb_alloc_buf(epqh->mps, 0);
8032 + /* FS/LS Enpoint on HS Hub
8033 + * NOT virtual root hub */
8034 + epqh->need_split = 0;
8035 + epqh->pkt_count_limit=0;
8036 + if(epqh->ep_type == IFXUSB_EP_TYPE_BULK && !(usb_pipein(_urb->pipe)) )
8037 + epqh->pkt_count_limit=4;
8038 + if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED &&
8039 + ((_urb->dev->speed == USB_SPEED_LOW) ||
8040 + (_urb->dev->speed == USB_SPEED_FULL)) &&
8041 + (_urb->dev->tt) && (_urb->dev->tt->hub->devnum != 1))
8043 + IFX_DEBUGPL(DBG_HCD, "QH init: EP %d: TT found at hub addr %d, for port %d\n",
8044 + usb_pipeendpoint(_urb->pipe), _urb->dev->tt->hub->devnum,
8045 + _urb->dev->ttport);
8046 + epqh->need_split = 1;
8047 + epqh->pkt_count_limit=1;
8050 + if (epqh->ep_type == IFXUSB_EP_TYPE_INTR ||
8051 + epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
8053 + /* Compute scheduling parameters once and save them. */
8054 + epqh->interval = _urb->interval;
8055 + if(epqh->need_split)
8056 + epqh->interval *= 8;
8059 + epqh->period_counter=0;
8060 + epqh->is_active=0;
8062 + #ifdef __EPQD_DESTROY_TIMEOUT__
8063 + /* Start a timer for this transfer. */
8064 + init_timer(&epqh->destroy_timer);
8065 + epqh->destroy_timer.function = eqph_destroy_func;
8066 + epqh->destroy_timer.data = (unsigned long)(epqh);
8070 + IFX_DEBUGPL(DBG_HCD , "IFXUSB HCD EPQH Initialized\n");
8071 + IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - epqh = %p\n", epqh);
8072 + IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Device Address = %d EP %d, %s\n",
8073 + _urb->dev->devnum,
8074 + usb_pipeendpoint(_urb->pipe),
8075 + usb_pipein(_urb->pipe) == USB_DIR_IN ? "IN" : "OUT");
8076 + IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Speed = %s\n",
8077 + ({ char *speed; switch (_urb->dev->speed) {
8078 + case USB_SPEED_LOW: speed = "low" ; break;
8079 + case USB_SPEED_FULL: speed = "full"; break;
8080 + case USB_SPEED_HIGH: speed = "high"; break;
8081 + default: speed = "?"; break;
8083 + IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Type = %s\n",
8085 + char *type; switch (epqh->ep_type)
8087 + case IFXUSB_EP_TYPE_ISOC: type = "isochronous"; break;
8088 + case IFXUSB_EP_TYPE_INTR: type = "interrupt" ; break;
8089 + case IFXUSB_EP_TYPE_CTRL: type = "control" ; break;
8090 + case IFXUSB_EP_TYPE_BULK: type = "bulk" ; break;
8091 + default: type = "?"; break;
8095 + if (epqh->ep_type == IFXUSB_EP_TYPE_INTR)
8096 + IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - interval = %d\n", epqh->interval);
8108 + \brief Free the EPQH. EPQH should already be removed from a list.
8109 + URBD list should already be empty if called from URB Dequeue.
8111 + \param[in] _epqh The EPQH to free.
8113 +void ifxhcd_epqh_free (ifxhcd_epqh_t *_epqh)
8115 + unsigned long flags;
8117 + if(_epqh->sysep) _epqh->sysep->hcpriv=NULL;
8118 + _epqh->sysep=NULL;
8123 + /* Free each QTD in the QTD list */
8124 + local_irq_save (flags);
8125 + if (!list_empty(&_epqh->urbd_list))
8126 + IFX_WARN("%s() invalid epqh state\n",__func__);
8128 + #if defined(__UNALIGNED_BUFFER_ADJ__)
8129 + if(_epqh->aligned_buf)
8130 + ifxusb_free_buf(_epqh->aligned_buf);
8131 + if(_epqh->aligned_setup)
8132 + ifxusb_free_buf(_epqh->aligned_setup);
8135 + if (!list_empty(&_epqh->epqh_list_entry))
8136 + list_del_init(&_epqh->epqh_list_entry);
8138 + #ifdef __EPQD_DESTROY_TIMEOUT__
8139 + del_timer(&_epqh->destroy_timer);
8141 + if(_epqh->dump_buf)
8142 + ifxusb_free_buf(_epqh->dump_buf);
8143 + _epqh->dump_buf=0;
8147 + local_irq_restore (flags);
8151 + \brief This function adds a EPQH to
8153 + \return 0 if successful, negative error code otherwise.
8155 +void ifxhcd_epqh_ready(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh)
8157 + unsigned long flags;
8158 + local_irq_save(flags);
8159 + if (list_empty(&_epqh->epqh_list_entry))
8161 + #ifdef __EN_ISOC__
8162 + if (_epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
8163 + list_add_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_isoc_ready);
8166 + if(_epqh->ep_type == IFXUSB_EP_TYPE_INTR)
8167 + list_add_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_intr_ready);
8169 + list_add_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_np_ready);
8170 + _epqh->is_active=0;
8172 + else if(!_epqh->is_active)
8174 + #ifdef __EN_ISOC__
8175 + if (_epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
8176 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_isoc_ready);
8179 + if(_epqh->ep_type == IFXUSB_EP_TYPE_INTR)
8180 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_intr_ready);
8182 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_np_ready);
8184 + #ifdef __EPQD_DESTROY_TIMEOUT__
8185 + del_timer(&_epqh->destroy_timer);
8187 + local_irq_restore(flags);
8190 +void ifxhcd_epqh_active(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh)
8192 + unsigned long flags;
8193 + local_irq_save(flags);
8194 + if (list_empty(&_epqh->epqh_list_entry))
8195 + IFX_WARN("%s() invalid epqh state\n",__func__);
8196 + #ifdef __EN_ISOC__
8197 + if (_epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
8198 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_isoc_active);
8201 + if(_epqh->ep_type == IFXUSB_EP_TYPE_INTR)
8202 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_intr_active);
8204 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_np_active);
8205 + _epqh->is_active=1;
8206 + #ifdef __EPQD_DESTROY_TIMEOUT__
8207 + del_timer(&_epqh->destroy_timer);
8209 + local_irq_restore(flags);
8212 +void ifxhcd_epqh_idle(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh)
8214 + unsigned long flags;
8215 + local_irq_save(flags);
8217 + if (list_empty(&_epqh->urbd_list))
8219 + if(_epqh->ep_type == IFXUSB_EP_TYPE_ISOC || _epqh->ep_type == IFXUSB_EP_TYPE_INTR)
8221 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_stdby);
8225 + list_del_init(&_epqh->epqh_list_entry);
8226 + #ifdef __EPQD_DESTROY_TIMEOUT__
8227 + del_timer(&_epqh->destroy_timer);
8228 + _epqh->destroy_timer.expires = jiffies + (HZ*epqh_self_destroy_timeout);
8229 + add_timer(&_epqh->destroy_timer );
8235 + #ifdef __EN_ISOC__
8236 + if (_epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
8237 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_isoc_ready);
8240 + if(_epqh->ep_type == IFXUSB_EP_TYPE_INTR)
8241 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_intr_ready);
8243 + list_move_tail(&_epqh->epqh_list_entry, &_ifxhcd->epqh_np_ready);
8245 + _epqh->is_active=0;
8246 + local_irq_restore(flags);
8250 +void ifxhcd_epqh_idle_periodic(ifxhcd_epqh_t *_epqh)
8252 + unsigned long flags;
8253 + if(_epqh->ep_type != IFXUSB_EP_TYPE_ISOC && _epqh->ep_type != IFXUSB_EP_TYPE_INTR)
8256 + local_irq_save(flags);
8258 + if (list_empty(&_epqh->epqh_list_entry))
8259 + IFX_WARN("%s() invalid epqh state\n",__func__);
8260 + if (!list_empty(&_epqh->urbd_list))
8261 + IFX_WARN("%s() invalid epqh state(not empty)\n",__func__);
8263 + _epqh->is_active=0;
8264 + list_del_init(&_epqh->epqh_list_entry);
8265 + #ifdef __EPQD_DESTROY_TIMEOUT__
8266 + del_timer(&_epqh->destroy_timer);
8267 + _epqh->destroy_timer.expires = jiffies + (HZ*epqh_self_destroy_timeout);
8268 + add_timer(&_epqh->destroy_timer );
8271 + local_irq_restore(flags);
8275 +int ifxhcd_urbd_create (ifxhcd_hcd_t *_ifxhcd,struct urb *_urb)
8277 + ifxhcd_urbd_t *urbd;
8278 + struct usb_host_endpoint *sysep;
8279 + ifxhcd_epqh_t *epqh;
8280 + unsigned long flags;
8281 + /* == AVM/WK 20100714 retval correctly initialized ==*/
8282 + int retval = -ENOMEM;
8284 + /*== AVM/BC 20100630 - Spinlock ==*/
8285 + //local_irq_save(flags);
8286 + SPIN_LOCK_IRQSAVE(&_ifxhcd->lock, flags);
8288 +// urbd = (ifxhcd_urbd_t *) kmalloc (sizeof(ifxhcd_urbd_t), GFP_KERNEL);
8289 + urbd = (ifxhcd_urbd_t *) kmalloc (sizeof(ifxhcd_urbd_t), GFP_ATOMIC);
8290 + if (urbd != NULL) /* Initializes a QTD structure.*/
8293 + memset (urbd, 0, sizeof (ifxhcd_urbd_t));
8295 + sysep = ifxhcd_urb_to_endpoint(_urb);
8296 + epqh = (ifxhcd_epqh_t *)sysep->hcpriv;
8299 + epqh = ifxhcd_epqh_create (_ifxhcd, _urb);
8304 + //local_irq_restore (flags);
8305 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
8308 + sysep->hcpriv = epqh;
8311 + INIT_LIST_HEAD(&urbd->urbd_list_entry);
8313 + /*== AVM/BC 20100630 - 2.6.28 needs HCD link/unlink URBs ==*/
8314 + retval = usb_hcd_link_urb_to_ep(ifxhcd_to_syshcd(_ifxhcd), _urb);
8316 + if (unlikely(retval)){
8319 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
8323 + list_add_tail(&urbd->urbd_list_entry, &epqh->urbd_list);
8325 + _urb->hcpriv = urbd;
8328 + urbd->is_in=usb_pipein(_urb->pipe) ? 1 : 0;;
8330 + urbd->xfer_len=_urb->transfer_buffer_length;
8331 +#define URB_NO_SETUP_DMA_MAP 0
8333 + if(urbd->xfer_len>0)
8335 + if(_urb->transfer_flags && URB_NO_TRANSFER_DMA_MAP)
8336 + urbd->xfer_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->transfer_dma));
8338 + urbd->xfer_buff = (uint8_t *) _urb->transfer_buffer;
8340 + if(epqh->ep_type == IFXUSB_EP_TYPE_CTRL)
8342 + if(_urb->transfer_flags && URB_NO_SETUP_DMA_MAP)
8343 + urbd->setup_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->setup_dma));
8345 + urbd->setup_buff = (uint8_t *) _urb->setup_packet;
8348 + //local_irq_restore (flags);
8349 + SPIN_UNLOCK_IRQRESTORE(&_ifxhcd->lock, flags);
8354 +++ b/drivers/usb/ifxhcd/ifxusb_cif.c
8356 +/*****************************************************************************
8357 + ** FILE NAME : ifxusb_cif.c
8358 + ** PROJECT : IFX USB sub-system V3
8359 + ** MODULES : IFX USB sub-system Host and Device driver
8360 + ** SRC VERSION : 1.0
8361 + ** DATE : 1/Jan/2009
8362 + ** AUTHOR : Chen, Howard
8363 + ** DESCRIPTION : The Core Interface provides basic services for accessing and
8364 + ** managing the IFX USB hardware. These services are used by both the
8365 + ** Host Controller Driver and the Peripheral Controller Driver.
8366 + *****************************************************************************/
8369 + \file ifxusb_cif.c
8370 + \ingroup IFXUSB_DRIVER_V3
8371 + \brief This file contains the interface to the IFX USB Core.
8374 +#include <linux/clk.h>
8375 +#include <linux/version.h>
8376 +#include "ifxusb_version.h"
8378 +#include <asm/byteorder.h>
8379 +#include <asm/unaligned.h>
8382 +#include <linux/jiffies.h>
8383 +#include <linux/platform_device.h>
8384 +#include <linux/kernel.h>
8385 +#include <linux/ioport.h>
8387 +#if defined(__UEIP__)
8388 +// #include <asm/ifx/ifx_pmu.h>
8389 +// #include <ifx_pmu.h>
8393 +#include "ifxusb_plat.h"
8394 +#include "ifxusb_regs.h"
8395 +#include "ifxusb_cif.h"
8398 +#ifdef __IS_DEVICE__
8399 + #include "ifxpcd.h"
8403 + #include "ifxhcd.h"
8406 +#include <linux/mm.h>
8408 +#include <linux/gfp.h>
8410 +#if defined(__UEIP__)
8411 +// #include <asm/ifx/ifx_board.h>
8412 + //#include <ifx_board.h>
8415 +//#include <asm/ifx/ifx_gpio.h>
8416 +//#include <ifx_gpio.h>
8417 +#if defined(__UEIP__)
8418 +// #include <asm/ifx/ifx_led.h>
8419 + //#include <ifx_led.h>
8424 +#if defined(__UEIP__)
8425 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
8426 + #ifndef USB_CTRL_PMU_SETUP
8427 + #define USB_CTRL_PMU_SETUP(__x) USB0_CTRL_PMU_SETUP(__x)
8429 + #ifndef USB_PHY_PMU_SETUP
8430 + #define USB_PHY_PMU_SETUP(__x) USB0_PHY_PMU_SETUP(__x)
8432 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
8433 +#endif // defined(__UEIP__)
8436 + \brief This function is called to allocate buffer of specified size.
8437 + The allocated buffer is mapped into DMA accessable address.
8438 + \param size Size in BYTE to be allocated
8439 + \param clear 0: don't do clear after buffer allocated, other: do clear to zero
8440 + \return 0/NULL: Fail; uncached pointer of allocated buffer
8442 +void *ifxusb_alloc_buf(size_t size, int clear)
8444 + uint32_t *cached,*uncached;
8445 + uint32_t totalsize,page;
8450 + size=(size+3)&0xFFFFFFFC;
8451 + totalsize=size + 12;
8452 + page=get_order(totalsize);
8454 + cached = (void *) __get_free_pages(( GFP_ATOMIC | GFP_DMA), page);
8458 + IFX_PRINT("%s Allocation Failed size:%d\n",__func__,size);
8462 + uncached = (uint32_t *)(KSEG1ADDR(cached));
8464 + memset(uncached, 0, totalsize);
8466 + *(uncached+0)=totalsize;
8467 + *(uncached+1)=page;
8468 + *(uncached+2)=(uint32_t)cached;
8469 + return (void *)(uncached+3);
8474 + \brief This function is called to free allocated buffer.
8475 + \param vaddr the uncached pointer of the buffer
8477 +void ifxusb_free_buf(void *vaddr)
8479 + uint32_t totalsize,page;
8480 + uint32_t *cached,*uncached;
8486 + totalsize=*(uncached+0);
8487 + page=*(uncached+1);
8488 + cached=(uint32_t *)(*(uncached+2));
8489 + if(totalsize && page==get_order(totalsize) && cached==(uint32_t *)(KSEG0ADDR(uncached)))
8491 + free_pages((unsigned long)cached, page);
8494 + // the memory is not allocated by ifxusb_alloc_buf. Allowed but must be careful.
8502 + \brief This function is called to initialize the IFXUSB CSR data
8503 + structures. The register addresses in the device and host
8504 + structures are initialized from the base address supplied by the
8505 + caller. The calling function must make the OS calls to get the
8506 + base address of the IFXUSB controller registers.
8508 + \param _core_if Pointer of core_if structure
8509 + \param _irq irq number
8510 + \param _reg_base_addr Base address of IFXUSB core registers
8511 + \param _fifo_base_addr Fifo base address
8512 + \param _fifo_dbg_addr Fifo debug address
8513 + \return 0: success;
8515 +int ifxusb_core_if_init(ifxusb_core_if_t *_core_if,
8517 + uint32_t _reg_base_addr,
8518 + uint32_t _fifo_base_addr,
8519 + uint32_t _fifo_dbg_addr)
8522 + uint32_t *reg_base =NULL;
8523 + uint32_t *fifo_base =NULL;
8524 + uint32_t *fifo_dbg =NULL;
8528 + IFX_DEBUGPL(DBG_CILV, "%s(%p,%d,0x%08X,0x%08X,0x%08X)\n", __func__,
8535 + if( _core_if == NULL)
8537 + IFX_ERROR("%s() invalid _core_if\n", __func__);
8542 + //memset(_core_if, 0, sizeof(ifxusb_core_if_t));
8544 + _core_if->irq=_irq;
8546 + reg_base =ioremap_nocache(_reg_base_addr , IFXUSB_IOMEM_SIZE );
8547 + fifo_base =ioremap_nocache(_fifo_base_addr, IFXUSB_FIFOMEM_SIZE);
8548 + fifo_dbg =ioremap_nocache(_fifo_dbg_addr , IFXUSB_FIFODBG_SIZE);
8549 + if( reg_base == NULL || fifo_base == NULL || fifo_dbg == NULL)
8551 + IFX_ERROR("%s() usb ioremap() failed\n", __func__);
8556 + _core_if->core_global_regs = (ifxusb_core_global_regs_t *)reg_base;
8559 + * Attempt to ensure this device is really a IFXUSB Controller.
8560 + * Read and verify the SNPSID register contents. The value should be
8565 + snpsid = ifxusb_rreg(&_core_if->core_global_regs->gsnpsid);
8566 + if ((snpsid & 0xFFFFF000) != 0x4F542000)
8568 + IFX_ERROR("%s() snpsid error(0x%08x) failed\n", __func__,snpsid);
8572 + _core_if->snpsid=snpsid;
8575 + #ifdef __IS_HOST__
8576 + _core_if->host_global_regs = (ifxusb_host_global_regs_t *)
8577 + ((uint32_t)reg_base + IFXUSB_HOST_GLOBAL_REG_OFFSET);
8578 + _core_if->hprt0 = (uint32_t*)((uint32_t)reg_base + IFXUSB_HOST_PORT_REGS_OFFSET);
8580 + for (i=0; i<MAX_EPS_CHANNELS; i++)
8582 + _core_if->hc_regs[i] = (ifxusb_hc_regs_t *)
8583 + ((uint32_t)reg_base + IFXUSB_HOST_CHAN_REGS_OFFSET +
8584 + (i * IFXUSB_CHAN_REGS_OFFSET));
8585 + IFX_DEBUGPL(DBG_CILV, "hc_reg[%d]->hcchar=%p\n",
8586 + i, &_core_if->hc_regs[i]->hcchar);
8588 + #endif //__IS_HOST__
8590 + #ifdef __IS_DEVICE__
8591 + _core_if->dev_global_regs =
8592 + (ifxusb_device_global_regs_t *)((uint32_t)reg_base + IFXUSB_DEV_GLOBAL_REG_OFFSET);
8594 + for (i=0; i<MAX_EPS_CHANNELS; i++)
8596 + _core_if->in_ep_regs[i] = (ifxusb_dev_in_ep_regs_t *)
8597 + ((uint32_t)reg_base + IFXUSB_DEV_IN_EP_REG_OFFSET +
8598 + (i * IFXUSB_EP_REG_OFFSET));
8599 + _core_if->out_ep_regs[i] = (ifxusb_dev_out_ep_regs_t *)
8600 + ((uint32_t)reg_base + IFXUSB_DEV_OUT_EP_REG_OFFSET +
8601 + (i * IFXUSB_EP_REG_OFFSET));
8602 + IFX_DEBUGPL(DBG_CILV, "in_ep_regs[%d]->diepctl=%p/%p %p/0x%08X/0x%08X\n",
8603 + i, &_core_if->in_ep_regs[i]->diepctl, _core_if->in_ep_regs[i],
8604 + reg_base,IFXUSB_DEV_IN_EP_REG_OFFSET,(i * IFXUSB_EP_REG_OFFSET)
8606 + IFX_DEBUGPL(DBG_CILV, "out_ep_regs[%d]->doepctl=%p/%p %p/0x%08X/0x%08X\n",
8607 + i, &_core_if->out_ep_regs[i]->doepctl, _core_if->out_ep_regs[i],
8608 + reg_base,IFXUSB_DEV_OUT_EP_REG_OFFSET,(i * IFXUSB_EP_REG_OFFSET)
8611 + #endif //__IS_DEVICE__
8613 + /* Setting the FIFO and other Address. */
8614 + for (i=0; i<MAX_EPS_CHANNELS; i++)
8616 + _core_if->data_fifo[i] = fifo_base + (i * IFXUSB_DATA_FIFO_SIZE);
8617 + IFX_DEBUGPL(DBG_CILV, "data_fifo[%d]=0x%08x\n",
8618 + i, (unsigned)_core_if->data_fifo[i]);
8621 + _core_if->data_fifo_dbg = fifo_dbg;
8622 + _core_if->pcgcctl = (uint32_t*)(((uint32_t)reg_base) + IFXUSB_PCGCCTL_OFFSET);
8625 + * Store the contents of the hardware configuration registers here for
8626 + * easy access later.
8628 + _core_if->hwcfg1.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg1);
8629 + _core_if->hwcfg2.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg2);
8630 + _core_if->hwcfg3.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg3);
8631 + _core_if->hwcfg4.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg4);
8633 + IFX_DEBUGPL(DBG_CILV,"hwcfg1=%08x\n",_core_if->hwcfg1.d32);
8634 + IFX_DEBUGPL(DBG_CILV,"hwcfg2=%08x\n",_core_if->hwcfg2.d32);
8635 + IFX_DEBUGPL(DBG_CILV,"hwcfg3=%08x\n",_core_if->hwcfg3.d32);
8636 + IFX_DEBUGPL(DBG_CILV,"hwcfg4=%08x\n",_core_if->hwcfg4.d32);
8639 + #ifdef __DED_FIFO__
8640 + IFX_PRINT("Waiting for PHY Clock Lock!\n");
8641 + while(!( ifxusb_rreg(&_core_if->core_global_regs->grxfsiz) & (1<<9)))
8644 + IFX_PRINT("PHY Clock Locked!\n");
8645 + //ifxusb_clean_spram(_core_if,128*1024/4);
8648 + /* Create new workqueue and init works */
8650 + _core_if->wq_usb = create_singlethread_workqueue(_core_if->core_name);
8652 + if(_core_if->wq_usb == 0)
8654 + IFX_DEBUGPL(DBG_CIL, "Creation of wq_usb failed\n");
8659 + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
8660 + INIT_WORK(&core_if->w_conn_id, w_conn_id_status_change, core_if);
8661 + INIT_WORK(&core_if->w_wkp, w_wakeup_detected, core_if);
8663 + INIT_WORK(&core_if->w_conn_id, w_conn_id_status_change);
8664 + INIT_DELAYED_WORK(&core_if->w_wkp, w_wakeup_detected);
8670 + if( reg_base != NULL) iounmap(reg_base );
8671 + if( fifo_base != NULL) iounmap(fifo_base);
8672 + if( fifo_dbg != NULL) iounmap(fifo_dbg );
8677 + \brief This function free the mapped address in the IFXUSB CSR data structures.
8678 + \param _core_if Pointer of core_if structure
8680 +void ifxusb_core_if_remove(ifxusb_core_if_t *_core_if)
8682 + /* Disable all interrupts */
8683 + if( _core_if->core_global_regs != NULL)
8685 + ifxusb_mreg( &_core_if->core_global_regs->gahbcfg, 1, 0);
8686 + ifxusb_wreg( &_core_if->core_global_regs->gintmsk, 0);
8689 + if( _core_if->core_global_regs != NULL) iounmap(_core_if->core_global_regs );
8690 + if( _core_if->data_fifo[0] != NULL) iounmap(_core_if->data_fifo[0] );
8691 + if( _core_if->data_fifo_dbg != NULL) iounmap(_core_if->data_fifo_dbg );
8694 + if (_core_if->wq_usb)
8695 + destroy_workqueue(_core_if->wq_usb);
8697 + memset(_core_if, 0, sizeof(ifxusb_core_if_t));
8704 + \brief This function enbles the controller's Global Interrupt in the AHB Config register.
8705 + \param _core_if Pointer of core_if structure
8707 +void ifxusb_enable_global_interrupts( ifxusb_core_if_t *_core_if )
8709 + gahbcfg_data_t ahbcfg ={ .d32 = 0};
8710 + ahbcfg.b.glblintrmsk = 1; /* Enable interrupts */
8711 + ifxusb_mreg(&_core_if->core_global_regs->gahbcfg, 0, ahbcfg.d32);
8715 + \brief This function disables the controller's Global Interrupt in the AHB Config register.
8716 + \param _core_if Pointer of core_if structure
8718 +void ifxusb_disable_global_interrupts( ifxusb_core_if_t *_core_if )
8720 + gahbcfg_data_t ahbcfg ={ .d32 = 0};
8721 + ahbcfg.b.glblintrmsk = 1; /* Enable interrupts */
8722 + ifxusb_mreg(&_core_if->core_global_regs->gahbcfg, ahbcfg.d32, 0);
8729 + \brief Flush Tx and Rx FIFO.
8730 + \param _core_if Pointer of core_if structure
8732 +void ifxusb_flush_both_fifo( ifxusb_core_if_t *_core_if )
8734 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
8735 + volatile grstctl_t greset ={ .d32 = 0};
8738 + IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "%s\n", __func__);
8739 + greset.b.rxfflsh = 1;
8740 + greset.b.txfflsh = 1;
8741 + greset.b.txfnum = 0x10;
8742 + greset.b.intknqflsh=1;
8743 + greset.b.hstfrm=1;
8744 + ifxusb_wreg( &global_regs->grstctl, greset.d32 );
8748 + greset.d32 = ifxusb_rreg( &global_regs->grstctl);
8749 + if (++count > 10000)
8751 + IFX_WARN("%s() HANG! GRSTCTL=%0x\n", __func__, greset.d32);
8754 + } while (greset.b.rxfflsh == 1 || greset.b.txfflsh == 1);
8755 + /* Wait for 3 PHY Clocks*/
8760 + \brief Flush a Tx FIFO.
8761 + \param _core_if Pointer of core_if structure
8762 + \param _num Tx FIFO to flush. ( 0x10 for ALL TX FIFO )
8764 +void ifxusb_flush_tx_fifo( ifxusb_core_if_t *_core_if, const int _num )
8766 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
8767 + volatile grstctl_t greset ={ .d32 = 0};
8770 + IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "Flush Tx FIFO %d\n", _num);
8772 + greset.b.intknqflsh=1;
8773 + greset.b.txfflsh = 1;
8774 + greset.b.txfnum = _num;
8775 + ifxusb_wreg( &global_regs->grstctl, greset.d32 );
8779 + greset.d32 = ifxusb_rreg( &global_regs->grstctl);
8780 + if (++count > 10000&&(_num==0 ||_num==0x10))
8782 + IFX_WARN("%s() HANG! GRSTCTL=%0x GNPTXSTS=0x%08x\n",
8783 + __func__, greset.d32,
8784 + ifxusb_rreg( &global_regs->gnptxsts));
8787 + } while (greset.b.txfflsh == 1);
8788 + /* Wait for 3 PHY Clocks*/
8794 + \brief Flush Rx FIFO.
8795 + \param _core_if Pointer of core_if structure
8797 +void ifxusb_flush_rx_fifo( ifxusb_core_if_t *_core_if )
8799 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
8800 + volatile grstctl_t greset ={ .d32 = 0};
8803 + IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "%s\n", __func__);
8804 + greset.b.rxfflsh = 1;
8805 + ifxusb_wreg( &global_regs->grstctl, greset.d32 );
8809 + greset.d32 = ifxusb_rreg( &global_regs->grstctl);
8810 + if (++count > 10000)
8812 + IFX_WARN("%s() HANG! GRSTCTL=%0x\n", __func__, greset.d32);
8815 + } while (greset.b.rxfflsh == 1);
8816 + /* Wait for 3 PHY Clocks*/
8821 +#define SOFT_RESET_DELAY 100
8824 + \brief Do a soft reset of the core. Be careful with this because it
8825 + resets all the internal state machines of the core.
8826 + \param _core_if Pointer of core_if structure
8828 +int ifxusb_core_soft_reset(ifxusb_core_if_t *_core_if)
8830 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
8831 + volatile grstctl_t greset ={ .d32 = 0};
8834 + IFX_DEBUGPL(DBG_CILV, "%s\n", __func__);
8835 + /* Wait for AHB master IDLE state. */
8839 + greset.d32 = ifxusb_rreg( &global_regs->grstctl);
8840 + if (++count > 100000)
8842 + IFX_WARN("%s() HANG! AHB Idle GRSTCTL=%0x %x\n", __func__,
8843 + greset.d32, greset.b.ahbidle);
8846 + } while (greset.b.ahbidle == 0);
8850 + /* Core Soft Reset */
8852 + greset.b.csftrst = 1;
8853 + ifxusb_wreg( &global_regs->grstctl, greset.d32 );
8855 + #ifdef SOFT_RESET_DELAY
8856 + MDELAY(SOFT_RESET_DELAY);
8862 + greset.d32 = ifxusb_rreg( &global_regs->grstctl);
8863 + if (++count > 100000)
8865 + IFX_WARN("%s() HANG! Soft Reset GRSTCTL=%0x\n", __func__, greset.d32);
8868 + } while (greset.b.csftrst == 1);
8870 + #ifdef SOFT_RESET_DELAY
8871 + MDELAY(SOFT_RESET_DELAY);
8875 + #if defined(__IS_VR9__)
8876 + if(_core_if->core_no==0)
8878 + set_bit (4, VR9_RCU_USBRESET2);
8880 + clear_bit (4, VR9_RCU_USBRESET2);
8884 + set_bit (5, VR9_RCU_USBRESET2);
8886 + clear_bit (5, VR9_RCU_USBRESET2);
8889 + #endif //defined(__IS_VR9__)
8891 + IFX_PRINT("USB core #%d soft-reset\n",_core_if->core_no);
8897 + \brief Turn on the USB Core Power
8898 + \param _core_if Pointer of core_if structure
8900 +void ifxusb_power_on (ifxusb_core_if_t *_core_if)
8902 + struct clk *clk0 = clk_get_sys("usb0", NULL);
8903 + struct clk *clk1 = clk_get_sys("usb1", NULL);
8904 + // set clock gating
8905 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
8906 + #if defined(__UEIP__)
8908 + #if defined(__IS_TWINPASS) || defined(__IS_DANUBE__)
8909 + set_bit (4, (volatile unsigned long *)DANUBE_CGU_IFCCR);
8910 + set_bit (5, (volatile unsigned long *)DANUBE_CGU_IFCCR);
8911 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
8912 + #if defined(__IS_AMAZON_SE__)
8913 + // clear_bit (4, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
8914 + clear_bit (5, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
8915 + #endif //defined(__IS_AMAZON_SE__)
8916 + #if defined(__IS_AR9__)
8917 + set_bit (0, (volatile unsigned long *)AR9_CGU_IFCCR);
8918 + set_bit (1, (volatile unsigned long *)AR9_CGU_IFCCR);
8919 + #endif //defined(__IS_AR9__)
8920 + #if defined(__IS_VR9__)
8921 +// set_bit (0, (volatile unsigned long *)VR9_CGU_IFCCR);
8922 +// set_bit (1, (volatile unsigned long *)VR9_CGU_IFCCR);
8923 + #endif //defined(__IS_VR9__)
8928 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
8929 + USB_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
8930 + //#if defined(__IS_TWINPASS__)
8931 + // ifxusb_enable_afe_oc();
8933 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
8934 + #if defined(__IS_AR9__) || defined(__IS_VR9__)
8935 + if(_core_if->core_no==0)
8937 +// USB0_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
8940 +// USB1_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
8941 + #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
8943 + if(_core_if->core_global_regs)
8945 + // PHY configurations.
8946 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
8947 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
8948 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
8949 + #if defined(__IS_AMAZON_SE__)
8950 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
8951 + #endif //defined(__IS_AMAZON_SE__)
8952 + #if defined(__IS_AR9__)
8953 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
8954 + #endif //defined(__IS_AR9__)
8955 + #if defined(__IS_VR9__)
8956 + //ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
8957 + #endif //defined(__IS_VR9__)
8959 + #else //defined(__UEIP__)
8960 + #if defined(__IS_TWINPASS) || defined(__IS_DANUBE__)
8961 + set_bit (4, (volatile unsigned long *)DANUBE_CGU_IFCCR);
8962 + set_bit (5, (volatile unsigned long *)DANUBE_CGU_IFCCR);
8963 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
8964 + #if defined(__IS_AMAZON_SE__)
8965 + // clear_bit (4, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
8966 + clear_bit (5, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
8967 + #endif //defined(__IS_AMAZON_SE__)
8968 + #if defined(__IS_AR9__)
8969 + set_bit (0, (volatile unsigned long *)AMAZON_S_CGU_IFCCR);
8970 + set_bit (1, (volatile unsigned long *)AMAZON_S_CGU_IFCCR);
8971 + #endif //defined(__IS_AR9__)
8976 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
8977 + clear_bit (6, (volatile unsigned long *)DANUBE_PMU_PWDCR);//USB
8978 + clear_bit (9, (volatile unsigned long *)DANUBE_PMU_PWDCR);//DSL
8979 + clear_bit (15, (volatile unsigned long *)DANUBE_PMU_PWDCR);//AHB
8980 + #if defined(__IS_TWINPASS__)
8981 + ifxusb_enable_afe_oc();
8983 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
8984 + #if defined(__IS_AMAZON_SE__)
8985 + clear_bit (6, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
8986 + clear_bit (9, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
8987 + clear_bit (15, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
8988 + #endif //defined(__IS_AMAZON_SE__)
8989 + #if defined(__IS_AR9__)
8990 + if(_core_if->core_no==0)
8991 + clear_bit (6, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
8993 + clear_bit (27, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
8994 + clear_bit (9, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//DSL
8995 + clear_bit (15, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//AHB
8996 + #endif //defined(__IS_AR9__)
8998 + if(_core_if->core_global_regs)
9000 + // PHY configurations.
9001 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9002 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9003 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9004 + #if defined(__IS_AMAZON_SE__)
9005 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9006 + #endif //defined(__IS_AMAZON_SE__)
9007 + #if defined(__IS_AR9__)
9008 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9009 + #endif //defined(__IS_AR9__)
9012 + #endif //defined(__UEIP__)
9016 + \brief Turn off the USB Core Power
9017 + \param _core_if Pointer of core_if structure
9019 +void ifxusb_power_off (ifxusb_core_if_t *_core_if)
9021 + struct clk *clk0 = clk_get_sys("usb0", NULL);
9022 + struct clk *clk1 = clk_get_sys("usb1", NULL);
9023 + ifxusb_phy_power_off (_core_if);
9026 + #if defined(__UEIP__)
9027 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
9028 + USB_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
9029 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
9030 + #if defined(__IS_AR9__) || defined(__IS_VR9__)
9031 + if(_core_if->core_no==0)
9032 + clk_disable(clk0);
9033 + //USB0_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
9035 + clk_disable(clk1);
9036 + //USB1_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
9037 + #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
9038 + #else //defined(__UEIP__)
9039 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9040 + set_bit (6, (volatile unsigned long *)DANUBE_PMU_PWDCR);//USB
9041 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9042 + #if defined(__IS_AMAZON_SE__)
9043 + set_bit (6, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);//USB
9044 + #endif //defined(__IS_AMAZON_SE__)
9045 + #if defined(__IS_AR9__)
9046 + if(_core_if->core_no==0)
9047 + set_bit (6, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
9049 + set_bit (27, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
9050 + #endif //defined(__IS_AR9__)
9051 + #endif //defined(__UEIP__)
9055 + \brief Turn on the USB PHY Power
9056 + \param _core_if Pointer of core_if structure
9058 +void ifxusb_phy_power_on (ifxusb_core_if_t *_core_if)
9060 + struct clk *clk0 = clk_get_sys("usb0", NULL);
9061 + struct clk *clk1 = clk_get_sys("usb1", NULL);
9062 + #if defined(__UEIP__)
9063 + if(_core_if->core_global_regs)
9065 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9066 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9067 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9068 + #if defined(__IS_AMAZON_SE__)
9069 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9070 + #endif //defined(__IS_AMAZON_SE__)
9071 + #if defined(__IS_AR9__)
9072 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9073 + #endif //defined(__IS_AR9__)
9074 + #if defined(__IS_VR9_S__)
9075 + if(_core_if->core_no==0)
9076 + set_bit (0, VR9_RCU_USB_ANA_CFG1A);
9078 + set_bit (0, VR9_RCU_USB_ANA_CFG1B);
9079 + #endif //defined(__IS_VR9__)
9082 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
9083 + USB_PHY_PMU_SETUP(IFX_PMU_ENABLE);
9084 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
9085 + #if defined(__IS_AR9__) || defined(__IS_VR9__)
9086 + if(_core_if->core_no==0)
9088 + //USB0_PHY_PMU_SETUP(IFX_PMU_ENABLE);
9091 + //USB1_PHY_PMU_SETUP(IFX_PMU_ENABLE);
9092 + #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
9094 + // PHY configurations.
9095 + if(_core_if->core_global_regs)
9097 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9098 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9099 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9100 + #if defined(__IS_AMAZON_SE__)
9101 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9102 + #endif //defined(__IS_AMAZON_SE__)
9103 + #if defined(__IS_AR9__)
9104 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9105 + #endif //defined(__IS_AR9__)
9106 + #if defined(__IS_VR9_S__)
9107 + if(_core_if->core_no==0)
9108 + set_bit (0, VR9_RCU_USB_ANA_CFG1A);
9110 + set_bit (0, VR9_RCU_USB_ANA_CFG1B);
9111 + #endif //defined(__IS_VR9__)
9113 + #else //defined(__UEIP__)
9114 + // PHY configurations.
9115 + if(_core_if->core_global_regs)
9117 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9118 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9119 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9120 + #if defined(__IS_AMAZON_SE__)
9121 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9122 + #endif //defined(__IS_AMAZON_SE__)
9123 + #if defined(__IS_AR9__)
9124 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9125 + #endif //defined(__IS_AR9__)
9128 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9129 + clear_bit (0, (volatile unsigned long *)DANUBE_PMU_PWDCR);//PHY
9130 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9131 + #if defined(__IS_AMAZON_SE__)
9132 + clear_bit (0, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
9133 + #endif //defined(__IS_AMAZON_SE__)
9134 + #if defined(__IS_AR9__)
9135 + if(_core_if->core_no==0)
9136 + clear_bit (0, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
9138 + clear_bit (26, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
9139 + #endif //defined(__IS_AR9__)
9141 + // PHY configurations.
9142 + if(_core_if->core_global_regs)
9144 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9145 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9146 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9147 + #if defined(__IS_AMAZON_SE__)
9148 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9149 + #endif //defined(__IS_AMAZON_SE__)
9150 + #if defined(__IS_AR9__)
9151 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9152 + #endif //defined(__IS_AR9__)
9154 + #endif //defined(__UEIP__)
9159 + \brief Turn off the USB PHY Power
9160 + \param _core_if Pointer of core_if structure
9162 +void ifxusb_phy_power_off (ifxusb_core_if_t *_core_if)
9164 + struct clk *clk0 = clk_get_sys("usb0", NULL);
9165 + struct clk *clk1 = clk_get_sys("usb1", NULL);
9166 + #if defined(__UEIP__)
9167 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
9168 + USB_PHY_PMU_SETUP(IFX_PMU_DISABLE);
9169 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
9170 + #if defined(__IS_AR9__) || defined(__IS_VR9__)
9171 + if(_core_if->core_no==0)
9172 + clk_disable(clk0);
9173 + //USB0_PHY_PMU_SETUP(IFX_PMU_DISABLE);
9175 + clk_disable(clk1);
9176 + //USB1_PHY_PMU_SETUP(IFX_PMU_DISABLE);
9177 + #endif // defined(__IS_AR9__) || defined(__IS_VR9__)
9178 + #else //defined(__UEIP__)
9179 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9180 + set_bit (0, (volatile unsigned long *)DANUBE_PMU_PWDCR);//PHY
9181 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9182 + #if defined(__IS_AMAZON_SE__)
9183 + set_bit (0, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);//PHY
9184 + #endif //defined(__IS_AMAZON_SE__)
9185 + #if defined(__IS_AR9__)
9186 + if(_core_if->core_no==0)
9187 + set_bit (0, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
9189 + set_bit (26, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
9190 + #endif //defined(__IS_AR9__)
9191 + #endif //defined(__UEIP__)
9196 + \brief Reset on the USB Core RCU
9197 + \param _core_if Pointer of core_if structure
9199 +#if defined(__IS_VR9__)
9200 + int already_hard_reset=0;
9202 +void ifxusb_hard_reset(ifxusb_core_if_t *_core_if)
9204 + #if defined(__UEIP__)
9205 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9206 + #if defined (__IS_HOST__)
9207 + clear_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9208 + #elif defined (__IS_DEVICE__)
9209 + set_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9211 + #endif //defined(__IS_AMAZON_SE__)
9213 + #if defined(__IS_AMAZON_SE__)
9214 + #if defined (__IS_HOST__)
9215 + clear_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9216 + #elif defined (__IS_DEVICE__)
9217 + set_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9219 + #endif //defined(__IS_AMAZON_SE__)
9221 + #if defined(__IS_AR9__)
9222 + if(_core_if->core_no==0)
9224 + #if defined (__IS_HOST__)
9225 + clear_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
9226 + #elif defined (__IS_DEVICE__)
9227 + set_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
9232 + #if defined (__IS_HOST__)
9233 + clear_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
9234 + #elif defined (__IS_DEVICE__)
9235 + set_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
9238 + #endif //defined(__IS_AR9__)
9240 + #if defined(__IS_VR9__)
9241 + if(_core_if->core_no==0)
9243 + #if defined (__IS_HOST__)
9244 + clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
9245 + #elif defined (__IS_DEVICE__)
9246 + set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
9251 + #if defined (__IS_HOST__)
9252 + clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
9253 + #elif defined (__IS_DEVICE__)
9254 + set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
9257 + #endif //defined(__IS_VR9__)
9260 + // set the HC's byte-order to big-endian
9261 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9262 + set_bit (DANUBE_USBCFG_HOST_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9263 + clear_bit (DANUBE_USBCFG_SLV_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9264 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9265 + #if defined(__IS_AMAZON_SE__)
9266 + set_bit (AMAZON_SE_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9267 + clear_bit (AMAZON_SE_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9268 + #endif //defined(__IS_AMAZON_SE__)
9269 + #if defined(__IS_AR9__)
9270 + if(_core_if->core_no==0)
9272 + set_bit (AR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
9273 + clear_bit (AR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
9277 + set_bit (AR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
9278 + clear_bit (AR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
9280 + #endif //defined(__IS_AR9__)
9281 + #if defined(__IS_VR9__)
9282 + if(_core_if->core_no==0)
9284 + set_bit (VR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
9285 + clear_bit (VR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
9289 + set_bit (VR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
9290 + clear_bit (VR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
9292 + #endif //defined(__IS_VR9__)
9294 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9295 + set_bit (4, DANUBE_RCU_RESET);
9297 + clear_bit (4, DANUBE_RCU_RESET);
9298 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9300 + #if defined(__IS_AMAZON_SE__)
9301 + set_bit (4, AMAZON_SE_RCU_RESET);
9303 + clear_bit (4, AMAZON_SE_RCU_RESET);
9305 + #endif //defined(__IS_AMAZON_SE__)
9307 + #if defined(__IS_AR9__)
9308 + if(_core_if->core_no==0)
9310 + set_bit (4, AR9_RCU_USBRESET);
9312 + clear_bit (4, AR9_RCU_USBRESET);
9316 + set_bit (28, AR9_RCU_USBRESET);
9318 + clear_bit (28, AR9_RCU_USBRESET);
9321 + #endif //defined(__IS_AR9__)
9322 + #if defined(__IS_VR9__)
9323 + if(!already_hard_reset)
9325 + set_bit (4, VR9_RCU_USBRESET);
9327 + clear_bit (4, VR9_RCU_USBRESET);
9329 + already_hard_reset=1;
9331 + #endif //defined(__IS_VR9__)
9333 + #if defined(__IS_TWINPASS__)
9334 + ifxusb_enable_afe_oc();
9337 + if(_core_if->core_global_regs)
9339 + // PHY configurations.
9340 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9341 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9342 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9343 + #if defined(__IS_AMAZON_SE__)
9344 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9345 + #endif //defined(__IS_AMAZON_SE__)
9346 + #if defined(__IS_AR9__)
9347 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9348 + #endif //defined(__IS_AR9__)
9349 + #if defined(__IS_VR9__)
9350 + // ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9351 + #endif //defined(__IS_VR9__)
9353 + #else //defined(__UEIP__)
9354 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9355 + #if defined (__IS_HOST__)
9356 + clear_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9357 + #elif defined (__IS_DEVICE__)
9358 + set_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9360 + #endif //defined(__IS_AMAZON_SE__)
9362 + #if defined(__IS_AMAZON_SE__)
9363 + #if defined (__IS_HOST__)
9364 + clear_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9365 + #elif defined (__IS_DEVICE__)
9366 + set_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9368 + #endif //defined(__IS_AMAZON_SE__)
9370 + #if defined(__IS_AR9__)
9371 + if(_core_if->core_no==0)
9373 + #if defined (__IS_HOST__)
9374 + clear_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
9375 + #elif defined (__IS_DEVICE__)
9376 + set_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
9381 + #if defined (__IS_HOST__)
9382 + clear_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
9383 + #elif defined (__IS_DEVICE__)
9384 + set_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
9387 + #endif //defined(__IS_AR9__)
9389 + // set the HC's byte-order to big-endian
9390 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9391 + set_bit (DANUBE_USBCFG_HOST_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9392 + clear_bit (DANUBE_USBCFG_SLV_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
9393 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9394 + #if defined(__IS_AMAZON_SE__)
9395 + set_bit (AMAZON_SE_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9396 + clear_bit (AMAZON_SE_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
9397 + #endif //defined(__IS_AMAZON_SE__)
9398 + #if defined(__IS_AR9__)
9399 + if(_core_if->core_no==0)
9401 + set_bit (AMAZON_S_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
9402 + clear_bit (AMAZON_S_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
9406 + set_bit (AMAZON_S_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
9407 + clear_bit (AMAZON_S_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
9409 + #endif //defined(__IS_AR9__)
9411 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9412 + set_bit (4, DANUBE_RCU_RESET);
9413 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9414 + #if defined(__IS_AMAZON_SE__)
9415 + set_bit (4, AMAZON_SE_RCU_RESET);
9416 + #endif //defined(__IS_AMAZON_SE__)
9417 + #if defined(__IS_AR9__)
9418 + if(_core_if->core_no==0)
9420 + set_bit (4, AMAZON_S_RCU_USBRESET);
9424 + set_bit (28, AMAZON_S_RCU_USBRESET);
9426 + #endif //defined(__IS_AR9__)
9430 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9431 + clear_bit (4, DANUBE_RCU_RESET);
9432 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9433 + #if defined(__IS_AMAZON_SE__)
9434 + clear_bit (4, AMAZON_SE_RCU_RESET);
9435 + #endif //defined(__IS_AMAZON_SE__)
9436 + #if defined(__IS_AR9__)
9437 + if(_core_if->core_no==0)
9439 + clear_bit (4, AMAZON_S_RCU_USBRESET);
9443 + clear_bit (28, AMAZON_S_RCU_USBRESET);
9445 + #endif //defined(__IS_AR9__)
9449 + #if defined(__IS_TWINPASS__)
9450 + ifxusb_enable_afe_oc();
9453 + if(_core_if->core_global_regs)
9455 + // PHY configurations.
9456 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9457 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9458 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
9459 + #if defined(__IS_AMAZON_SE__)
9460 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9461 + #endif //defined(__IS_AMAZON_SE__)
9462 + #if defined(__IS_AR9__)
9463 + ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
9464 + #endif //defined(__IS_AR9__)
9466 + #endif //defined(__UEIP__)
9469 +#if defined(__GADGET_LED__) || defined(__HOST_LED__)
9470 + #if defined(__UEIP__)
9471 + static void *g_usb_led_trigger = NULL;
9474 + void ifxusb_led_init(ifxusb_core_if_t *_core_if)
9476 + #if defined(__UEIP__)
9477 + if ( !g_usb_led_trigger )
9479 + ifx_led_trigger_register("usb_link", &g_usb_led_trigger);
9480 + if ( g_usb_led_trigger != NULL )
9482 + struct ifx_led_trigger_attrib attrib = {0};
9483 + attrib.delay_on = 250;
9484 + attrib.delay_off = 250;
9485 + attrib.timeout = 2000;
9486 + attrib.def_value = 1;
9487 + attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
9488 + IFX_DEBUGP("Reg USB LED!!\n");
9489 + ifx_led_trigger_set_attrib(g_usb_led_trigger, &attrib);
9492 + #endif //defined(__UEIP__)
9495 + void ifxusb_led_free(ifxusb_core_if_t *_core_if)
9497 + #if defined(__UEIP__)
9498 + if ( g_usb_led_trigger )
9500 + ifx_led_trigger_deregister(g_usb_led_trigger);
9501 + g_usb_led_trigger = NULL;
9503 + #endif //defined(__UEIP__)
9507 + \brief Turn off the USB 5V VBus Power
9508 + \param _core_if Pointer of core_if structure
9510 + void ifxusb_led(ifxusb_core_if_t *_core_if)
9512 + #if defined(__UEIP__)
9513 + if(g_usb_led_trigger)
9514 + ifx_led_trigger_activate(g_usb_led_trigger);
9516 + #endif //defined(__UEIP__)
9518 +#endif // defined(__GADGET_LED__) || defined(__HOST_LED__)
9522 +#if defined(__IS_HOST__) && defined(__DO_OC_INT__) && defined(__DO_OC_INT_ENABLE__)
9524 + \brief Turn on the OC Int
9526 + void ifxusb_oc_int_on()
9528 + #if defined(__UEIP__)
9530 + #if defined(__IS_TWINPASS__)
9531 + irq_enable(DANUBE_USB_OC_INT);
9533 + #endif //defined(__UEIP__)
9536 + \brief Turn off the OC Int
9538 + void ifxusb_oc_int_off()
9540 + #if defined(__UEIP__)
9542 + #if defined(__IS_TWINPASS__)
9543 + irq_disable(DANUBE_USB_OC_INT);
9545 + #endif //defined(__UEIP__)
9547 +#endif //defined(__IS_HOST__) && defined(__DO_OC_INT__) && defined(__DO_OC_INT_ENABLE__)
9549 +/* internal routines for debugging */
9550 +void ifxusb_dump_msg(const u8 *buf, unsigned int length)
9553 + unsigned int start, num, i;
9554 + char line[52], *p;
9556 + if (length >= 512)
9559 + while (length > 0)
9561 + num = min(length, 16u);
9563 + for (i = 0; i < num; ++i)
9567 + sprintf(p, " %02x", buf[i]);
9571 + IFX_PRINT( "%6x: %s\n", start, line);
9579 +/* This functions reads the SPRAM and prints its content */
9580 +void ifxusb_dump_spram(ifxusb_core_if_t *_core_if)
9582 +#ifdef __ENABLE_DUMP__
9583 + volatile uint8_t *addr, *start_addr, *end_addr;
9585 + IFX_PRINT("SPRAM Data:\n");
9586 + start_addr = (void*)_core_if->core_global_regs;
9587 + IFX_PRINT("Base Address: 0x%8X\n", (uint32_t)start_addr);
9589 + start_addr = (void*)_core_if->data_fifo_dbg;
9590 + IFX_PRINT("Starting Address: 0x%8X\n", (uint32_t)start_addr);
9592 + size=_core_if->hwcfg3.b.dfifo_depth;
9597 + end_addr = (void*)_core_if->data_fifo_dbg;
9600 + for(addr = start_addr; addr < end_addr; addr+=16)
9602 + IFX_PRINT("0x%8X:\t%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", (uint32_t)addr,
9603 + addr[ 0], addr[ 1], addr[ 2], addr[ 3],
9604 + addr[ 4], addr[ 5], addr[ 6], addr[ 7],
9605 + addr[ 8], addr[ 9], addr[10], addr[11],
9606 + addr[12], addr[13], addr[14], addr[15]
9610 +#endif //__ENABLE_DUMP__
9616 +/* This function reads the core global registers and prints them */
9617 +void ifxusb_dump_registers(ifxusb_core_if_t *_core_if)
9619 +#ifdef __ENABLE_DUMP__
9621 + volatile uint32_t *addr;
9622 + #ifdef __IS_DEVICE__
9623 + volatile uint32_t *addri,*addro;
9626 + IFX_PRINT("Core Global Registers\n");
9627 + addr=&_core_if->core_global_regs->gotgctl;
9628 + IFX_PRINT("GOTGCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9629 + addr=&_core_if->core_global_regs->gotgint;
9630 + IFX_PRINT("GOTGINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9631 + addr=&_core_if->core_global_regs->gahbcfg;
9632 + IFX_PRINT("GAHBCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9633 + addr=&_core_if->core_global_regs->gusbcfg;
9634 + IFX_PRINT("GUSBCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9635 + addr=&_core_if->core_global_regs->grstctl;
9636 + IFX_PRINT("GRSTCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9637 + addr=&_core_if->core_global_regs->gintsts;
9638 + IFX_PRINT("GINTSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9639 + addr=&_core_if->core_global_regs->gintmsk;
9640 + IFX_PRINT("GINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9641 + addr=&_core_if->core_global_regs->gi2cctl;
9642 + IFX_PRINT("GI2CCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9643 + addr=&_core_if->core_global_regs->gpvndctl;
9644 + IFX_PRINT("GPVNDCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9645 + addr=&_core_if->core_global_regs->ggpio;
9646 + IFX_PRINT("GGPIO @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9647 + addr=&_core_if->core_global_regs->guid;
9648 + IFX_PRINT("GUID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9649 + addr=&_core_if->core_global_regs->gsnpsid;
9650 + IFX_PRINT("GSNPSID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9651 + addr=&_core_if->core_global_regs->ghwcfg1;
9652 + IFX_PRINT("GHWCFG1 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9653 + addr=&_core_if->core_global_regs->ghwcfg2;
9654 + IFX_PRINT("GHWCFG2 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9655 + addr=&_core_if->core_global_regs->ghwcfg3;
9656 + IFX_PRINT("GHWCFG3 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9657 + addr=&_core_if->core_global_regs->ghwcfg4;
9658 + IFX_PRINT("GHWCFG4 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9660 + addr=_core_if->pcgcctl;
9661 + IFX_PRINT("PCGCCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9663 + addr=&_core_if->core_global_regs->grxfsiz;
9664 + IFX_PRINT("GRXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9666 + #ifdef __IS_HOST__
9667 + addr=&_core_if->core_global_regs->gnptxfsiz;
9668 + IFX_PRINT("GNPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9669 + addr=&_core_if->core_global_regs->hptxfsiz;
9670 + IFX_PRINT("HPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9671 + #endif //__IS_HOST__
9673 + #ifdef __IS_DEVICE__
9674 + #ifdef __DED_FIFO__
9675 + addr=&_core_if->core_global_regs->gnptxfsiz;
9676 + IFX_PRINT("GNPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9677 + for (i=0; i<= _core_if->hwcfg4.b.num_in_eps; i++)
9679 + addr=&_core_if->core_global_regs->dptxfsiz_dieptxf[i];
9680 + IFX_PRINT("DPTXFSIZ[%d] @0x%08X : 0x%08X\n",i,(uint32_t)addr,ifxusb_rreg(addr));
9683 + addr=&_core_if->core_global_regs->gnptxfsiz;
9684 + IFX_PRINT("TXFSIZ[00] @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9685 + for (i=0; i< _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
9687 + addr=&_core_if->core_global_regs->dptxfsiz_dieptxf[i];
9688 + IFX_PRINT("TXFSIZ[%02d] @0x%08X : 0x%08X\n",i+1,(uint32_t)addr,ifxusb_rreg(addr));
9691 + #endif //__IS_DEVICE__
9693 + #ifdef __IS_HOST__
9694 + IFX_PRINT("Host Global Registers\n");
9695 + addr=&_core_if->host_global_regs->hcfg;
9696 + IFX_PRINT("HCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9697 + addr=&_core_if->host_global_regs->hfir;
9698 + IFX_PRINT("HFIR @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9699 + addr=&_core_if->host_global_regs->hfnum;
9700 + IFX_PRINT("HFNUM @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9701 + addr=&_core_if->host_global_regs->hptxsts;
9702 + IFX_PRINT("HPTXSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9703 + addr=&_core_if->host_global_regs->haint;
9704 + IFX_PRINT("HAINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9705 + addr=&_core_if->host_global_regs->haintmsk;
9706 + IFX_PRINT("HAINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9707 + addr= _core_if->hprt0;
9708 + IFX_PRINT("HPRT0 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9710 + for (i=0; i<MAX_EPS_CHANNELS; i++)
9712 + IFX_PRINT("Host Channel %d Specific Registers\n", i);
9713 + addr=&_core_if->hc_regs[i]->hcchar;
9714 + IFX_PRINT("HCCHAR @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9715 + addr=&_core_if->hc_regs[i]->hcsplt;
9716 + IFX_PRINT("HCSPLT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9717 + addr=&_core_if->hc_regs[i]->hcint;
9718 + IFX_PRINT("HCINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9719 + addr=&_core_if->hc_regs[i]->hcintmsk;
9720 + IFX_PRINT("HCINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9721 + addr=&_core_if->hc_regs[i]->hctsiz;
9722 + IFX_PRINT("HCTSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9723 + addr=&_core_if->hc_regs[i]->hcdma;
9724 + IFX_PRINT("HCDMA @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9726 + #endif //__IS_HOST__
9728 + #ifdef __IS_DEVICE__
9729 + IFX_PRINT("Device Global Registers\n");
9730 + addr=&_core_if->dev_global_regs->dcfg;
9731 + IFX_PRINT("DCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9732 + addr=&_core_if->dev_global_regs->dctl;
9733 + IFX_PRINT("DCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9734 + addr=&_core_if->dev_global_regs->dsts;
9735 + IFX_PRINT("DSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9736 + addr=&_core_if->dev_global_regs->diepmsk;
9737 + IFX_PRINT("DIEPMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9738 + addr=&_core_if->dev_global_regs->doepmsk;
9739 + IFX_PRINT("DOEPMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9740 + addr=&_core_if->dev_global_regs->daintmsk;
9741 + IFX_PRINT("DAINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9742 + addr=&_core_if->dev_global_regs->daint;
9743 + IFX_PRINT("DAINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9744 + addr=&_core_if->dev_global_regs->dvbusdis;
9745 + IFX_PRINT("DVBUSID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9746 + addr=&_core_if->dev_global_regs->dvbuspulse;
9747 + IFX_PRINT("DVBUSPULSE @0x%08X : 0x%08X\n", (uint32_t)addr,ifxusb_rreg(addr));
9749 + addr=&_core_if->dev_global_regs->dtknqr1;
9750 + IFX_PRINT("DTKNQR1 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
9751 + if (_core_if->hwcfg2.b.dev_token_q_depth > 6) {
9752 + addr=&_core_if->dev_global_regs->dtknqr2;
9753 + IFX_PRINT("DTKNQR2 @0x%08X : 0x%08X\n", (uint32_t)addr,ifxusb_rreg(addr));
9756 + if (_core_if->hwcfg2.b.dev_token_q_depth > 14)
9758 + addr=&_core_if->dev_global_regs->dtknqr3_dthrctl;
9759 + IFX_PRINT("DTKNQR3_DTHRCTL @0x%08X : 0x%08X\n", (uint32_t)addr, ifxusb_rreg(addr));
9762 + if (_core_if->hwcfg2.b.dev_token_q_depth > 22)
9764 + addr=&_core_if->dev_global_regs->dtknqr4_fifoemptymsk;
9765 + IFX_PRINT("DTKNQR4 @0x%08X : 0x%08X\n", (uint32_t)addr, ifxusb_rreg(addr));
9768 + //for (i=0; i<= MAX_EPS_CHANNELS; i++)
9769 + //for (i=0; i<= 10; i++)
9770 + for (i=0; i<= 3; i++)
9772 + IFX_PRINT("Device EP %d Registers\n", i);
9773 + addri=&_core_if->in_ep_regs[i]->diepctl;addro=&_core_if->out_ep_regs[i]->doepctl;
9774 + IFX_PRINT("DEPCTL I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
9775 + addro=&_core_if->out_ep_regs[i]->doepfn;
9776 + IFX_PRINT("DEPFN I: O: 0x%08X\n",ifxusb_rreg(addro));
9777 + addri=&_core_if->in_ep_regs[i]->diepint;addro=&_core_if->out_ep_regs[i]->doepint;
9778 + IFX_PRINT("DEPINT I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
9779 + addri=&_core_if->in_ep_regs[i]->dieptsiz;addro=&_core_if->out_ep_regs[i]->doeptsiz;
9780 + IFX_PRINT("DETSIZ I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
9781 + addri=&_core_if->in_ep_regs[i]->diepdma;addro=&_core_if->out_ep_regs[i]->doepdma;
9782 + IFX_PRINT("DEPDMA I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
9783 + addri=&_core_if->in_ep_regs[i]->dtxfsts;
9784 + IFX_PRINT("DTXFSTS I: 0x%08X\n",ifxusb_rreg(addri) );
9785 + addri=&_core_if->in_ep_regs[i]->diepdmab;addro=&_core_if->out_ep_regs[i]->doepdmab;
9786 + IFX_PRINT("DEPDMAB I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
9788 + #endif //__IS_DEVICE__
9789 +#endif //__ENABLE_DUMP__
9792 +void ifxusb_clean_spram(ifxusb_core_if_t *_core_if,uint32_t dwords)
9794 + volatile uint32_t *addr1,*addr2, *start_addr, *end_addr;
9799 + start_addr = (uint32_t *)_core_if->data_fifo_dbg;
9801 + end_addr = (uint32_t *)_core_if->data_fifo_dbg;
9802 + end_addr += dwords;
9804 + IFX_PRINT("Clearning SPRAM: 0x%8X-0x%8X\n", (uint32_t)start_addr,(uint32_t)end_addr);
9805 + for(addr1 = start_addr; addr1 < end_addr; addr1+=4)
9807 + for(addr2 = addr1; addr2 < addr1+4; addr2++)
9808 + *addr2=0x00000000;
9810 + IFX_PRINT("Clearning SPRAM: 0x%8X-0x%8X Done\n", (uint32_t)start_addr,(uint32_t)end_addr);
9815 +++ b/drivers/usb/ifxhcd/ifxusb_cif.h
9817 +/*****************************************************************************
9818 + ** FILE NAME : ifxusb_cif.h
9819 + ** PROJECT : IFX USB sub-system V3
9820 + ** MODULES : IFX USB sub-system Host and Device driver
9821 + ** SRC VERSION : 1.0
9822 + ** DATE : 1/Jan/2009
9823 + ** AUTHOR : Chen, Howard
9824 + ** DESCRIPTION : The Core Interface provides basic services for accessing and
9825 + ** managing the IFX USB hardware. These services are used by both the
9826 + ** Host Controller Driver and the Peripheral Controller Driver.
9829 + ** REFERENCE : IFX hardware ref handbook for each plateforms
9831 + ** Version Control Section **
9835 + ** $Log$ Revision history
9836 +*****************************************************************************/
9839 + \defgroup IFXUSB_DRIVER_V3 IFX USB SS Project
9840 + \brief IFX USB subsystem V3.x
9844 + \defgroup IFXUSB_CIF Core Interface APIs
9845 + \ingroup IFXUSB_DRIVER_V3
9846 + \brief The Core Interface provides basic services for accessing and
9847 + managing the IFXUSB hardware. These services are used by both the
9848 + Host Controller Driver and the Peripheral Controller Driver.
9853 + \file ifxusb_cif.h
9854 + \ingroup IFXUSB_DRIVER_V3
9855 + \brief This file contains the interface to the IFX USB Core.
9858 +#if !defined(__IFXUSB_CIF_H__)
9859 +#define __IFXUSB_CIF_H__
9861 +#include <linux/workqueue.h>
9863 +#include <linux/version.h>
9864 +#include <asm/param.h>
9866 +#include "ifxusb_plat.h"
9867 +#include "ifxusb_regs.h"
9870 + #include "linux/timer.h"
9873 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9875 +#define IFXUSB_PARAM_SPEED_HIGH 0
9876 +#define IFXUSB_PARAM_SPEED_FULL 1
9878 +#define IFXUSB_EP_SPEED_LOW 0
9879 +#define IFXUSB_EP_SPEED_FULL 1
9880 +#define IFXUSB_EP_SPEED_HIGH 2
9882 +#define IFXUSB_EP_TYPE_CTRL 0
9883 +#define IFXUSB_EP_TYPE_ISOC 1
9884 +#define IFXUSB_EP_TYPE_BULK 2
9885 +#define IFXUSB_EP_TYPE_INTR 3
9887 +#define IFXUSB_HC_PID_DATA0 0
9888 +#define IFXUSB_HC_PID_DATA2 1
9889 +#define IFXUSB_HC_PID_DATA1 2
9890 +#define IFXUSB_HC_PID_MDATA 3
9891 +#define IFXUSB_HC_PID_SETUP 3
9895 + \addtogroup IFXUSB_CIF
9900 + \struct ifxusb_params
9901 + \brief IFXUSB Parameters structure.
9902 + This structure is used for both importing from insmod stage and run-time storage.
9903 + These parameters define how the IFXUSB controller should be configured.
9905 +typedef struct ifxusb_params
9907 + int32_t dma_burst_size; /*!< The DMA Burst size (applicable only for Internal DMA
9908 + Mode). 0(for single), 1(incr), 4(incr4), 8(incr8) 16(incr16)
9910 + /* Translate this to GAHBCFG values */
9911 + int32_t speed; /*!< Specifies the maximum speed of operation in host and device mode.
9912 + The actual speed depends on the speed of the attached device and
9913 + the value of phy_type. The actual speed depends on the speed of the
9915 + 0 - High Speed (default)
9919 + int32_t data_fifo_size; /*!< Total number of dwords in the data FIFO memory. This
9920 + memory includes the Rx FIFO, non-periodic Tx FIFO, and periodic
9924 + #ifdef __IS_DEVICE__
9925 + int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in device mode.
9930 + int32_t tx_fifo_size[MAX_EPS_CHANNELS]; /*!< Number of dwords in each of the Tx FIFOs in device mode.
9933 + #ifdef __DED_FIFO__
9934 + int32_t thr_ctl; /*!< Threshold control on/off */
9935 + int32_t tx_thr_length; /*!< Threshold length for Tx */
9936 + int32_t rx_thr_length; /*!< Threshold length for Rx*/
9938 + #else //__IS_HOST__
9939 + int32_t host_channels; /*!< The number of host channel registers to use.
9943 + int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in host mode.
9947 + int32_t nperio_tx_fifo_size;/*!< Number of dwords in the non-periodic Tx FIFO in host mode.
9951 + int32_t perio_tx_fifo_size; /*!< Number of dwords in the host periodic Tx FIFO.
9954 + #endif //__IS_HOST__
9956 + int32_t max_transfer_size; /*!< The maximum transfer size supported in bytes.
9960 + int32_t max_packet_count; /*!< The maximum number of packets in a transfer.
9961 + 15 to 511 (default 511)
9963 + int32_t phy_utmi_width; /*!< Specifies the UTMI+ Data Width.
9964 + 8 or 16 bits (default 16)
9967 + int32_t turn_around_time_hs; /*!< Specifies the Turn-Around time at HS*/
9968 + int32_t turn_around_time_fs; /*!< Specifies the Turn-Around time at FS*/
9970 + int32_t timeout_cal_hs; /*!< Specifies the Timeout_Calibration at HS*/
9971 + int32_t timeout_cal_fs; /*!< Specifies the Timeout_Calibration at FS*/
9974 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9975 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9978 + \struct ifxusb_core_if
9979 + \brief The ifx_core_if structure contains information needed to manage
9980 + the IFX USB controller acting in either host or device mode. It
9981 + represents the programming view of the controller as a whole.
9983 +typedef struct ifxusb_core_if
9985 + ifxusb_params_t params; /*!< Run-time Parameters */
9987 + uint8_t core_no; /*!< core number (used as id when multi-core case */
9988 + char *core_name; /*!< core name used for registration and informative purpose*/
9989 + int irq; /*!< irq number this core is hooked */
9991 + /*****************************************************************
9992 + * Structures and pointers to physical register interface.
9993 + *****************************************************************/
9994 + /** Core Global registers starting at offset 000h. */
9995 + ifxusb_core_global_regs_t *core_global_regs; /*!< pointer to Core Global Registers, offset at 000h */
9997 + /** Host-specific registers */
9998 + #ifdef __IS_HOST__
9999 + /** Host Global Registers starting at offset 400h.*/
10000 + ifxusb_host_global_regs_t *host_global_regs; /*!< pointer to Host Global Registers, offset at 400h */
10001 + #define IFXUSB_HOST_GLOBAL_REG_OFFSET 0x400
10002 + /** Host Port 0 Control and Status Register */
10003 + volatile uint32_t *hprt0; /*!< pointer to HPRT0 Registers, offset at 440h */
10004 + #define IFXUSB_HOST_PORT_REGS_OFFSET 0x440
10005 + /** Host Channel Specific Registers at offsets 500h-5FCh. */
10006 + ifxusb_hc_regs_t *hc_regs[MAX_EPS_CHANNELS]; /*!< pointer to Host-Channel n Registers, offset at 500h */
10007 + #define IFXUSB_HOST_CHAN_REGS_OFFSET 0x500
10008 + #define IFXUSB_CHAN_REGS_OFFSET 0x20
10011 + /** Device-specific registers */
10012 + #ifdef __IS_DEVICE__
10013 + /** Device Global Registers starting at offset 800h */
10014 + ifxusb_device_global_regs_t *dev_global_regs; /*!< pointer to Device Global Registers, offset at 800h */
10015 + #define IFXUSB_DEV_GLOBAL_REG_OFFSET 0x800
10017 + /** Device Logical IN Endpoint-Specific Registers 900h-AFCh */
10018 + ifxusb_dev_in_ep_regs_t *in_ep_regs[MAX_EPS_CHANNELS]; /*!< pointer to Device IN-EP Registers, offset at 900h */
10019 + #define IFXUSB_DEV_IN_EP_REG_OFFSET 0x900
10020 + #define IFXUSB_EP_REG_OFFSET 0x20
10021 + /** Device Logical OUT Endpoint-Specific Registers B00h-CFCh */
10022 + ifxusb_dev_out_ep_regs_t *out_ep_regs[MAX_EPS_CHANNELS];/*!< pointer to Device OUT-EP Registers, offset at 900h */
10023 + #define IFXUSB_DEV_OUT_EP_REG_OFFSET 0xB00
10026 + /** Power and Clock Gating Control Register */
10027 + volatile uint32_t *pcgcctl; /*!< pointer to Power and Clock Gating Control Registers, offset at E00h */
10028 + #define IFXUSB_PCGCCTL_OFFSET 0xE00
10030 + /** Push/pop addresses for endpoints or host channels.*/
10031 + uint32_t *data_fifo[MAX_EPS_CHANNELS]; /*!< pointer to FIFO access windows, offset at 1000h */
10032 + #define IFXUSB_DATA_FIFO_OFFSET 0x1000
10033 + #define IFXUSB_DATA_FIFO_SIZE 0x1000
10035 + uint32_t *data_fifo_dbg; /*!< pointer to FIFO debug windows, offset at 1000h */
10037 + /** Hardware Configuration -- stored here for convenience.*/
10038 + hwcfg1_data_t hwcfg1; /*!< preserved Hardware Configuration 1 */
10039 + hwcfg2_data_t hwcfg2; /*!< preserved Hardware Configuration 2 */
10040 + hwcfg3_data_t hwcfg3; /*!< preserved Hardware Configuration 3 */
10041 + hwcfg4_data_t hwcfg4; /*!< preserved Hardware Configuration 3 */
10042 + uint32_t snpsid; /*!< preserved SNPSID */
10044 + /*****************************************************************
10045 + * Run-time informations.
10046 + *****************************************************************/
10047 + /* Set to 1 if the core PHY interface bits in USBCFG have been initialized. */
10048 + uint8_t phy_init_done; /*!< indicated PHY is initialized. */
10050 + #ifdef __IS_HOST__
10051 + uint8_t queuing_high_bandwidth; /*!< Host mode, Queueing High Bandwidth. */
10053 +} ifxusb_core_if_t;
10055 +/*@}*//*IFXUSB_CIF*/
10059 + \fn void *ifxusb_alloc_buf(size_t size, int clear)
10060 + \brief This function is called to allocate buffer of specified size.
10061 + The allocated buffer is mapped into DMA accessable address.
10062 + \param size Size in BYTE to be allocated
10063 + \param clear 0: don't do clear after buffer allocated, other: do clear to zero
10064 + \return 0/NULL: Fail; uncached pointer of allocated buffer
10065 + \ingroup IFXUSB_CIF
10067 +extern void *ifxusb_alloc_buf(size_t size, int clear);
10070 + \fn void ifxusb_free_buf(void *vaddr)
10071 + \brief This function is called to free allocated buffer.
10072 + \param vaddr the uncached pointer of the buffer
10073 + \ingroup IFXUSB_CIF
10075 +extern void ifxusb_free_buf(void *vaddr);
10078 + \fn int ifxusb_core_if_init(ifxusb_core_if_t *_core_if,
10080 + uint32_t _reg_base_addr,
10081 + uint32_t _fifo_base_addr,
10082 + uint32_t _fifo_dbg_addr)
10083 + \brief This function is called to initialize the IFXUSB CSR data
10084 + structures. The register addresses in the device and host
10085 + structures are initialized from the base address supplied by the
10086 + caller. The calling function must make the OS calls to get the
10087 + base address of the IFXUSB controller registers.
10088 + \param _core_if Pointer of core_if structure
10089 + \param _irq irq number
10090 + \param _reg_base_addr Base address of IFXUSB core registers
10091 + \param _fifo_base_addr Fifo base address
10092 + \param _fifo_dbg_addr Fifo debug address
10093 + \return 0: success;
10094 + \ingroup IFXUSB_CIF
10096 +extern int ifxusb_core_if_init(ifxusb_core_if_t *_core_if,
10098 + uint32_t _reg_base_addr,
10099 + uint32_t _fifo_base_addr,
10100 + uint32_t _fifo_dbg_addr);
10104 + \fn void ifxusb_core_if_remove(ifxusb_core_if_t *_core_if)
10105 + \brief This function free the mapped address in the IFXUSB CSR data structures.
10106 + \param _core_if Pointer of core_if structure
10107 + \ingroup IFXUSB_CIF
10109 +extern void ifxusb_core_if_remove(ifxusb_core_if_t *_core_if);
10112 + \fn void ifxusb_enable_global_interrupts( ifxusb_core_if_t *_core_if )
10113 + \brief This function enbles the controller's Global Interrupt in the AHB Config register.
10114 + \param _core_if Pointer of core_if structure
10116 +extern void ifxusb_enable_global_interrupts( ifxusb_core_if_t *_core_if );
10119 + \fn void ifxusb_disable_global_interrupts( ifxusb_core_if_t *_core_if )
10120 + \brief This function disables the controller's Global Interrupt in the AHB Config register.
10121 + \param _core_if Pointer of core_if structure
10122 + \ingroup IFXUSB_CIF
10124 +extern void ifxusb_disable_global_interrupts( ifxusb_core_if_t *_core_if );
10127 + \fn void ifxusb_flush_tx_fifo( ifxusb_core_if_t *_core_if, const int _num )
10128 + \brief Flush a Tx FIFO.
10129 + \param _core_if Pointer of core_if structure
10130 + \param _num Tx FIFO to flush. ( 0x10 for ALL TX FIFO )
10131 + \ingroup IFXUSB_CIF
10133 +extern void ifxusb_flush_tx_fifo( ifxusb_core_if_t *_core_if, const int _num );
10136 + \fn void ifxusb_flush_rx_fifo( ifxusb_core_if_t *_core_if )
10137 + \brief Flush Rx FIFO.
10138 + \param _core_if Pointer of core_if structure
10139 + \ingroup IFXUSB_CIF
10141 +extern void ifxusb_flush_rx_fifo( ifxusb_core_if_t *_core_if );
10144 + \fn void ifxusb_flush_both_fifo( ifxusb_core_if_t *_core_if )
10145 + \brief Flush ALL Rx and Tx FIFO.
10146 + \param _core_if Pointer of core_if structure
10147 + \ingroup IFXUSB_CIF
10149 +extern void ifxusb_flush_both_fifo( ifxusb_core_if_t *_core_if );
10153 + \fn int ifxusb_core_soft_reset(ifxusb_core_if_t *_core_if)
10154 + \brief Do core a soft reset of the core. Be careful with this because it
10155 + resets all the internal state machines of the core.
10156 + \param _core_if Pointer of core_if structure
10157 + \ingroup IFXUSB_CIF
10159 +extern int ifxusb_core_soft_reset(ifxusb_core_if_t *_core_if);
10163 + \brief Turn on the USB Core Power
10164 + \param _core_if Pointer of core_if structure
10165 + \ingroup IFXUSB_CIF
10167 +extern void ifxusb_power_on (ifxusb_core_if_t *_core_if);
10170 + \fn void ifxusb_power_off (ifxusb_core_if_t *_core_if)
10171 + \brief Turn off the USB Core Power
10172 + \param _core_if Pointer of core_if structure
10173 + \ingroup IFXUSB_CIF
10175 +extern void ifxusb_power_off (ifxusb_core_if_t *_core_if);
10178 + \fn void ifxusb_phy_power_on (ifxusb_core_if_t *_core_if)
10179 + \brief Turn on the USB PHY Power
10180 + \param _core_if Pointer of core_if structure
10181 + \ingroup IFXUSB_CIF
10183 +extern void ifxusb_phy_power_on (ifxusb_core_if_t *_core_if);
10186 + \fn void ifxusb_phy_power_off (ifxusb_core_if_t *_core_if)
10187 + \brief Turn off the USB PHY Power
10188 + \param _core_if Pointer of core_if structure
10189 + \ingroup IFXUSB_CIF
10191 +extern void ifxusb_phy_power_off (ifxusb_core_if_t *_core_if);
10194 + \fn void ifxusb_hard_reset(ifxusb_core_if_t *_core_if)
10195 + \brief Reset on the USB Core RCU
10196 + \param _core_if Pointer of core_if structure
10197 + \ingroup IFXUSB_CIF
10199 +extern void ifxusb_hard_reset(ifxusb_core_if_t *_core_if);
10201 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10204 +#ifdef __IS_HOST__
10206 + \fn void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
10207 + \brief This function initializes the IFXUSB controller registers for Host mode.
10208 + This function flushes the Tx and Rx FIFOs and it flushes any entries in the
10210 + \param _core_if Pointer of core_if structure
10211 + \param _params parameters to be set
10212 + \ingroup IFXUSB_CIF
10214 + extern void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
10217 + \fn void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if)
10218 + \brief This function enables the Host mode interrupts.
10219 + \param _core_if Pointer of core_if structure
10220 + \ingroup IFXUSB_CIF
10222 + extern void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if);
10225 + \fn void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if)
10226 + \brief This function disables the Host mode interrupts.
10227 + \param _core_if Pointer of core_if structure
10228 + \ingroup IFXUSB_CIF
10230 + extern void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if);
10232 + #if defined(__IS_TWINPASS__)
10233 + extern void ifxusb_enable_afe_oc(void);
10237 + \fn void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
10238 + \brief This function init the VBUS control.
10239 + \param _core_if Pointer of core_if structure
10240 + \ingroup IFXUSB_CIF
10242 + extern void ifxusb_vbus_init(ifxusb_core_if_t *_core_if);
10245 + \fn void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
10246 + \brief This function free the VBUS control.
10247 + \param _core_if Pointer of core_if structure
10248 + \ingroup IFXUSB_CIF
10250 + extern void ifxusb_vbus_free(ifxusb_core_if_t *_core_if);
10253 + \fn void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
10254 + \brief Turn on the USB 5V VBus Power
10255 + \param _core_if Pointer of core_if structure
10256 + \ingroup IFXUSB_CIF
10258 + extern void ifxusb_vbus_on(ifxusb_core_if_t *_core_if);
10261 + \fn void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
10262 + \brief Turn off the USB 5V VBus Power
10263 + \param _core_if Pointer of core_if structure
10264 + \ingroup IFXUSB_CIF
10266 + extern void ifxusb_vbus_off(ifxusb_core_if_t *_core_if);
10269 + \fn int ifxusb_vbus(ifxusb_core_if_t *_core_if)
10270 + \brief Read Current VBus status
10271 + \param _core_if Pointer of core_if structure
10272 + \ingroup IFXUSB_CIF
10274 + extern int ifxusb_vbus(ifxusb_core_if_t *_core_if);
10276 + #if defined(__DO_OC_INT__) && defined(__DO_OC_INT_ENABLE__)
10278 + \fn void ifxusb_oc_int_on(void)
10279 + \brief Turn on the OC interrupt
10280 + \ingroup IFXUSB_CIF
10282 + extern void ifxusb_oc_int_on(void);
10285 + \fn void ifxusb_oc_int_off(void)
10286 + \brief Turn off the OC interrupt
10287 + \ingroup IFXUSB_CIF
10289 + extern void ifxusb_oc_int_off(void);
10290 + #endif //defined(__DO_OC_INT__) && defined(__DO_OC_INT_ENABLE__)
10293 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10296 +#ifdef __IS_DEVICE__
10298 + \fn void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if)
10299 + \brief This function enables the Device mode interrupts.
10300 + \param _core_if Pointer of core_if structure
10301 + \ingroup IFXUSB_CIF
10303 + extern void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if);
10306 + \fn uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if)
10307 + \brief Gets the current USB frame number. This is the frame number from the last SOF packet.
10308 + \param _core_if Pointer of core_if structure
10309 + \ingroup IFXUSB_CIF
10311 + extern uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if);
10314 + \fn void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in)
10315 + \brief Set the EP STALL.
10316 + \param _core_if Pointer of core_if structure
10317 + \param _epno EP number
10318 + \param _is_in 1: is IN transfer
10319 + \ingroup IFXUSB_CIF
10321 + extern void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in);
10324 + \fn void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in)
10325 + \brief Set the EP STALL.
10326 + \param _core_if Pointer of core_if structure
10327 + \param _epno EP number
10328 + \param _ep_type EP Type
10329 + \ingroup IFXUSB_CIF
10331 + extern void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in);
10334 + \fn void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
10335 + \brief This function initializes the IFXUSB controller registers for Device mode.
10336 + This function flushes the Tx and Rx FIFOs and it flushes any entries in the
10338 + This function validate the imported parameters and store the result in the CIF structure.
10340 + \param _core_if Pointer of core_if structure
10341 + \param _params structure of inported parameters
10342 + \ingroup IFXUSB_CIF
10344 + extern void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
10347 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10349 +#if defined(__GADGET_LED__) || defined(__HOST_LED__)
10351 + \fn void ifxusb_led_init(ifxusb_core_if_t *_core_if)
10352 + \brief This function init the LED control.
10353 + \param _core_if Pointer of core_if structure
10354 + \ingroup IFXUSB_CIF
10356 + extern void ifxusb_led_init(ifxusb_core_if_t *_core_if);
10359 + \fn void ifxusb_led_free(ifxusb_core_if_t *_core_if)
10360 + \brief This function free the LED control.
10361 + \param _core_if Pointer of core_if structure
10362 + \ingroup IFXUSB_CIF
10364 + extern void ifxusb_led_free(ifxusb_core_if_t *_core_if);
10367 + \fn void ifxusb_led(ifxusb_core_if_t *_core_if)
10368 + \brief This function trigger the LED access.
10369 + \param _core_if Pointer of core_if structure
10370 + \ingroup IFXUSB_CIF
10372 + extern void ifxusb_led(ifxusb_core_if_t *_core_if);
10375 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10377 +/* internal routines for debugging */
10378 +extern void ifxusb_dump_msg(const u8 *buf, unsigned int length);
10379 +extern void ifxusb_dump_spram(ifxusb_core_if_t *_core_if);
10380 +extern void ifxusb_dump_registers(ifxusb_core_if_t *_core_if);
10381 +extern void ifxusb_clean_spram(ifxusb_core_if_t *_core_if,uint32_t dwords);
10383 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10385 +static inline uint32_t ifxusb_read_core_intr(ifxusb_core_if_t *_core_if)
10387 + return (ifxusb_rreg(&_core_if->core_global_regs->gintsts) &
10388 + (ifxusb_rreg(&_core_if->core_global_regs->gintmsk)
10389 +#ifdef __USE_TIMER_4_SOF__
10390 + | IFXUSB_SOF_INTR_MASK
10395 +static inline uint32_t ifxusb_read_otg_intr (ifxusb_core_if_t *_core_if)
10397 + return (ifxusb_rreg (&_core_if->core_global_regs->gotgint));
10400 +static inline uint32_t ifxusb_mode(ifxusb_core_if_t *_core_if)
10402 + return (ifxusb_rreg( &_core_if->core_global_regs->gintsts ) & 0x1);
10404 +static inline uint8_t ifxusb_is_device_mode(ifxusb_core_if_t *_core_if)
10406 + return (ifxusb_mode(_core_if) != 1);
10408 +static inline uint8_t ifxusb_is_host_mode(ifxusb_core_if_t *_core_if)
10410 + return (ifxusb_mode(_core_if) == 1);
10413 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10415 +#ifdef __IS_HOST__
10416 + static inline uint32_t ifxusb_read_hprt0(ifxusb_core_if_t *_core_if)
10418 + hprt0_data_t hprt0;
10419 + hprt0.d32 = ifxusb_rreg(_core_if->hprt0);
10420 + hprt0.b.prtena = 0;
10421 + hprt0.b.prtconndet = 0;
10422 + hprt0.b.prtenchng = 0;
10423 + hprt0.b.prtovrcurrchng = 0;
10424 + return hprt0.d32;
10427 + static inline uint32_t ifxusb_read_host_all_channels_intr (ifxusb_core_if_t *_core_if)
10429 + return (ifxusb_rreg (&_core_if->host_global_regs->haint));
10432 + static inline uint32_t ifxusb_read_host_channel_intr (ifxusb_core_if_t *_core_if, int hc_num)
10434 + return (ifxusb_rreg (&_core_if->hc_regs[hc_num]->hcint));
10438 +#ifdef __IS_DEVICE__
10439 + static inline uint32_t ifxusb_read_dev_all_in_ep_intr(ifxusb_core_if_t *_core_if)
10442 + v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
10443 + ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
10444 + return (v & 0xffff);
10447 + static inline uint32_t ifxusb_read_dev_all_out_ep_intr(ifxusb_core_if_t *_core_if)
10450 + v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
10451 + ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
10452 + return ((v & 0xffff0000) >> 16);
10455 + static inline uint32_t ifxusb_read_dev_in_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
10458 + v = ifxusb_rreg(&_core_if->in_ep_regs[_ep_num]->diepint) &
10459 + ifxusb_rreg(&_core_if->dev_global_regs->diepmsk);
10463 + static inline uint32_t ifxusb_read_dev_out_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
10466 + v = ifxusb_rreg(&_core_if->out_ep_regs[_ep_num]->doepint) &
10467 + ifxusb_rreg(&_core_if->dev_global_regs->doepmsk);
10473 +extern void ifxusb_attr_create (void *_dev);
10475 +extern void ifxusb_attr_remove (void *_dev);
10477 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10479 +#endif // !defined(__IFXUSB_CIF_H__)
10483 +++ b/drivers/usb/ifxhcd/ifxusb_cif_d.c
10485 +/*****************************************************************************
10486 + ** FILE NAME : ifxusb_cif_d.c
10487 + ** PROJECT : IFX USB sub-system V3
10488 + ** MODULES : IFX USB sub-system Host and Device driver
10489 + ** SRC VERSION : 1.0
10490 + ** DATE : 1/Jan/2009
10491 + ** AUTHOR : Chen, Howard
10492 + ** DESCRIPTION : The Core Interface provides basic services for accessing and
10493 + ** managing the IFX USB hardware. These services are used by the
10494 + ** Peripheral Controller Driver only.
10495 + *****************************************************************************/
10498 + \file ifxusb_cif_d.c
10499 + \ingroup IFXUSB_DRIVER_V3
10500 + \brief This file contains the interface to the IFX USB Core.
10503 +#include <linux/version.h>
10504 +#include "ifxusb_version.h"
10507 +#include <asm/byteorder.h>
10508 +#include <asm/unaligned.h>
10511 + #include <linux/jiffies.h>
10514 +#include "ifxusb_plat.h"
10515 +#include "ifxusb_regs.h"
10516 +#include "ifxusb_cif.h"
10518 +#include "ifxpcd.h"
10523 + \brief Initializes the DevSpd field of the DCFG register depending on the PHY type
10524 + and the enumeration speed of the device.
10525 + \param _core_if Pointer of core_if structure
10527 +void ifxusb_dev_init_spd(ifxusb_core_if_t *_core_if)
10530 + dcfg_data_t dcfg;
10532 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
10533 + if (_core_if->params.speed == IFXUSB_PARAM_SPEED_FULL)
10534 + /* High speed PHY running at full speed */
10537 + /* High speed PHY running at high speed and full speed*/
10540 + IFX_DEBUGPL(DBG_CIL, "Initializing DCFG.DevSpd to 0x%1x\n", val);
10541 + dcfg.d32 = ifxusb_rreg(&_core_if->dev_global_regs->dcfg);
10542 + dcfg.b.devspd = val;
10543 + ifxusb_wreg(&_core_if->dev_global_regs->dcfg, dcfg.d32);
10548 + \brief This function enables the Device mode interrupts.
10549 + \param _core_if Pointer of core_if structure
10551 +void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if)
10553 + gint_data_t intr_mask ={ .d32 = 0};
10554 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
10556 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
10557 + IFX_DEBUGPL(DBG_CIL, "%s()\n", __func__);
10559 + /* Clear any pending OTG Interrupts */
10560 + ifxusb_wreg( &global_regs->gotgint, 0xFFFFFFFF);
10562 + /* Clear any pending interrupts */
10563 + ifxusb_wreg( &global_regs->gintsts, 0xFFFFFFFF);
10565 + /* Enable the interrupts in the GINTMSK.*/
10566 + intr_mask.b.modemismatch = 1;
10567 + intr_mask.b.conidstschng = 1;
10568 + intr_mask.b.wkupintr = 1;
10569 + intr_mask.b.disconnect = 1;
10570 + intr_mask.b.usbsuspend = 1;
10572 + intr_mask.b.usbreset = 1;
10573 + intr_mask.b.enumdone = 1;
10574 + intr_mask.b.inepintr = 1;
10575 + intr_mask.b.outepintr = 1;
10576 + intr_mask.b.erlysuspend = 1;
10577 + #ifndef __DED_FIFO__
10578 +// intr_mask.b.epmismatch = 1;
10581 + ifxusb_mreg( &global_regs->gintmsk, intr_mask.d32, intr_mask.d32);
10582 + IFX_DEBUGPL(DBG_CIL, "%s() gintmsk=%0x\n", __func__, ifxusb_rreg( &global_regs->gintmsk));
10586 + \brief Gets the current USB frame number. This is the frame number from the last SOF packet.
10587 + \param _core_if Pointer of core_if structure
10589 +uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if)
10591 + dsts_data_t dsts;
10592 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
10593 + dsts.d32 = ifxusb_rreg(&_core_if->dev_global_regs->dsts);
10594 + /* read current frame/microfreme number from DSTS register */
10595 + return dsts.b.soffn;
10600 + \brief Set the EP STALL.
10602 +void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in)
10604 + depctl_data_t depctl;
10605 + volatile uint32_t *depctl_addr;
10607 + IFX_DEBUGPL(DBG_PCD, "%s ep%d-%s\n", __func__, _epno, (_is_in?"IN":"OUT"));
10609 + depctl_addr = (_is_in)? (&(_core_if->in_ep_regs [_epno]->diepctl)):
10610 + (&(_core_if->out_ep_regs[_epno]->doepctl));
10611 + depctl.d32 = ifxusb_rreg(depctl_addr);
10612 + depctl.b.stall = 1;
10614 + if (_is_in && depctl.b.epena)
10615 + depctl.b.epdis = 1;
10617 + ifxusb_wreg(depctl_addr, depctl.d32);
10618 + IFX_DEBUGPL(DBG_PCD,"DEPCTL=%0x\n",ifxusb_rreg(depctl_addr));
10623 +\brief Clear the EP STALL.
10625 +void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in)
10627 + depctl_data_t depctl;
10628 + volatile uint32_t *depctl_addr;
10630 + IFX_DEBUGPL(DBG_PCD, "%s ep%d-%s\n", __func__, _epno, (_is_in?"IN":"OUT"));
10632 + depctl_addr = (_is_in)? (&(_core_if->in_ep_regs [_epno]->diepctl)):
10633 + (&(_core_if->out_ep_regs[_epno]->doepctl));
10635 + depctl.d32 = ifxusb_rreg(depctl_addr);
10636 + /* clear the stall bits */
10637 + depctl.b.stall = 0;
10640 + * USB Spec 9.4.5: For endpoints using data toggle, regardless
10641 + * of whether an endpoint has the Halt feature set, a
10642 + * ClearFeature(ENDPOINT_HALT) request always results in the
10643 + * data toggle being reinitialized to DATA0.
10645 + if (_ep_type == IFXUSB_EP_TYPE_INTR || _ep_type == IFXUSB_EP_TYPE_BULK)
10646 + depctl.b.setd0pid = 1; /* DATA0 */
10648 + ifxusb_wreg(depctl_addr, depctl.d32);
10649 + IFX_DEBUGPL(DBG_PCD,"DEPCTL=%0x\n",ifxusb_rreg(depctl_addr));
10654 + \brief This function initializes the IFXUSB controller registers for Device mode.
10655 + This function flushes the Tx and Rx FIFOs and it flushes any entries in the
10657 + \param _core_if Pointer of core_if structure
10658 + \param _params parameters to be set
10660 +void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
10662 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
10664 + gusbcfg_data_t usbcfg ={.d32 = 0};
10665 + gahbcfg_data_t ahbcfg ={.d32 = 0};
10666 + dcfg_data_t dcfg ={.d32 = 0};
10667 + grstctl_t resetctl ={.d32 = 0};
10668 + gotgctl_data_t gotgctl ={.d32 = 0};
10673 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
10674 + IFX_DEBUGPL(DBG_CILV, "%s(%p)\n",__func__,_core_if);
10676 + /* Copy Params */
10677 + _core_if->params.dma_burst_size = _params->dma_burst_size;
10678 + _core_if->params.speed = _params->speed;
10679 + if(_params->max_transfer_size < 2048 || _params->max_transfer_size > ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1) )
10680 + _core_if->params.max_transfer_size = ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1);
10682 + _core_if->params.max_transfer_size = _params->max_transfer_size;
10684 + if(_params->max_packet_count < 16 || _params->max_packet_count > ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1) )
10685 + _core_if->params.max_packet_count= ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1);
10687 + _core_if->params.max_packet_count= _params->max_packet_count;
10688 + _core_if->params.phy_utmi_width = _params->phy_utmi_width;
10689 + _core_if->params.turn_around_time_hs = _params->turn_around_time_hs;
10690 + _core_if->params.turn_around_time_fs = _params->turn_around_time_fs;
10691 + _core_if->params.timeout_cal_hs = _params->timeout_cal_hs;
10692 + _core_if->params.timeout_cal_fs = _params->timeout_cal_fs;
10694 + #ifdef __DED_FIFO__
10695 + _core_if->params.thr_ctl = _params->thr_ctl;
10696 + _core_if->params.tx_thr_length = _params->tx_thr_length;
10697 + _core_if->params.rx_thr_length = _params->rx_thr_length;
10700 + /* Reset the Controller */
10703 + while(ifxusb_core_soft_reset( _core_if ))
10704 + ifxusb_hard_reset(_core_if);
10705 + } while (ifxusb_is_host_mode(_core_if));
10707 + usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
10709 + #if defined(__DED_FIFO__)
10710 + usbcfg.b.ForceDevMode = 1;
10711 + usbcfg.b.ForceHstMode = 0;
10714 + usbcfg.b.term_sel_dl_pulse = 0;
10715 + ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
10717 + /* This programming sequence needs to happen in FS mode before any other
10718 + * programming occurs */
10719 + /* High speed PHY. */
10720 + if (!_core_if->phy_init_done)
10722 + _core_if->phy_init_done = 1;
10723 + /* HS PHY parameters. These parameters are preserved
10724 + * during soft reset so only program the first time. Do
10725 + * a soft reset immediately after setting phyif. */
10726 + usbcfg.b.ulpi_utmi_sel = 0; //UTMI+
10727 + usbcfg.b.phyif = ( _core_if->params.phy_utmi_width == 16)?1:0;
10728 + ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
10729 + /* Reset after setting the PHY parameters */
10730 + ifxusb_core_soft_reset( _core_if );
10733 + /* Program the GAHBCFG Register.*/
10734 + switch (_core_if->params.dma_burst_size)
10737 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE;
10740 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR;
10743 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4;
10746 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8;
10749 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16;
10752 + ahbcfg.b.dmaenable = 1;
10753 + ifxusb_wreg(&global_regs->gahbcfg, ahbcfg.d32);
10755 + /* Program the GUSBCFG register. */
10756 + usbcfg.d32 = ifxusb_rreg( &global_regs->gusbcfg );
10757 + usbcfg.b.hnpcap = 0;
10758 + usbcfg.b.srpcap = 0;
10759 + ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
10761 + /* Restart the Phy Clock */
10762 + ifxusb_wreg(_core_if->pcgcctl, 0);
10764 + /* Device configuration register */
10765 + ifxusb_dev_init_spd(_core_if);
10766 + dcfg.d32 = ifxusb_rreg( &_core_if->dev_global_regs->dcfg);
10767 + dcfg.b.perfrint = IFXUSB_DCFG_FRAME_INTERVAL_80;
10768 + #if defined(__DED_FIFO__)
10769 + #if defined(__DESC_DMA__)
10770 + dcfg.b.descdma = 1;
10772 + dcfg.b.descdma = 0;
10776 + ifxusb_wreg( &_core_if->dev_global_regs->dcfg, dcfg.d32 );
10778 + /* Configure data FIFO sizes */
10779 + _core_if->params.data_fifo_size = _core_if->hwcfg3.b.dfifo_depth;
10780 + _core_if->params.rx_fifo_size = ifxusb_rreg(&global_regs->grxfsiz);
10781 + IFX_DEBUGPL(DBG_CIL, "Initial: FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
10782 + IFX_DEBUGPL(DBG_CIL, " Rx FIFO Size=0x%06X\n", _core_if->params.rx_fifo_size);
10784 + _core_if->params.tx_fifo_size[0]= ifxusb_rreg(&global_regs->gnptxfsiz) >> 16;
10786 + #ifdef __DED_FIFO__
10787 + for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
10788 + _core_if->params.tx_fifo_size[i] =
10789 + ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i-1]) >> 16;
10791 + for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
10792 + _core_if->params.tx_fifo_size[i+1] =
10793 + ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i]) >> 16;
10797 + #ifdef __DED_FIFO__
10798 + for (i=0; i <= _core_if->hwcfg4.b.num_in_eps; i++)
10799 + IFX_DEBUGPL(DBG_CIL, " Tx[%02d] FIFO Size=0x%06X\n",i, _core_if->params.tx_fifo_size[i]);
10801 + IFX_DEBUGPL(DBG_CIL, " NPTx FIFO Size=0x%06X\n", _core_if->params.tx_fifo_size[0]);
10802 + for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
10803 + IFX_DEBUGPL(DBG_CIL, " PTx[%02d] FIFO Size=0x%06X\n",i, _core_if->params.tx_fifo_size[i+1]);
10808 + fifosize_data_t txfifosize;
10809 + if(_params->data_fifo_size >=0 && _params->data_fifo_size < _core_if->params.data_fifo_size)
10810 + _core_if->params.data_fifo_size = _params->data_fifo_size;
10813 + if(_params->rx_fifo_size >=0 && _params->rx_fifo_size < _core_if->params.rx_fifo_size)
10814 + _core_if->params.rx_fifo_size = _params->rx_fifo_size;
10815 + if(_core_if->params.data_fifo_size < _core_if->params.rx_fifo_size)
10816 + _core_if->params.rx_fifo_size = _core_if->params.data_fifo_size;
10817 + ifxusb_wreg( &global_regs->grxfsiz, _core_if->params.rx_fifo_size);
10819 + for (i=0; i < MAX_EPS_CHANNELS; i++)
10820 + if(_params->tx_fifo_size[i] >=0 && _params->tx_fifo_size[i] < _core_if->params.tx_fifo_size[i])
10821 + _core_if->params.tx_fifo_size[i] = _params->tx_fifo_size[i];
10823 + txfifosize.b.startaddr = _core_if->params.rx_fifo_size;
10824 + #ifdef __DED_FIFO__
10825 + if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[0] > _core_if->params.data_fifo_size)
10826 + _core_if->params.tx_fifo_size[0]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
10827 + txfifosize.b.depth=_core_if->params.tx_fifo_size[0];
10828 + ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
10829 + txfifosize.b.startaddr += _core_if->params.tx_fifo_size[0];
10830 + for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
10832 + if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[i] > _core_if->params.data_fifo_size)
10833 + _core_if->params.tx_fifo_size[i]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
10834 + txfifosize.b.depth=_core_if->params.tx_fifo_size[i];
10835 + ifxusb_wreg( &global_regs->dptxfsiz_dieptxf[i-1], txfifosize.d32);
10836 + txfifosize.b.startaddr += _core_if->params.tx_fifo_size[i];
10839 + if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[0] > _core_if->params.data_fifo_size)
10840 + _core_if->params.tx_fifo_size[0]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
10841 + txfifosize.b.depth=_core_if->params.tx_fifo_size[0];
10842 + ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
10843 + txfifosize.b.startaddr += _core_if->params.tx_fifo_size[0];
10844 + for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
10846 + if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[i+1] > _core_if->params.data_fifo_size)
10847 + _core_if->params.tx_fifo_size[i+1]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
10848 + //txfifosize.b.depth=_core_if->params.tx_fifo_size[i+1];
10849 + ifxusb_wreg( &global_regs->dptxfsiz_dieptxf[i], txfifosize.d32);
10850 + txfifosize.b.startaddr += _core_if->params.tx_fifo_size[i+1];
10857 + fifosize_data_t fifosize;
10858 + IFX_DEBUGPL(DBG_CIL, "Result : FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
10860 + IFX_DEBUGPL(DBG_CIL, " Rx FIFO =0x%06X Sz=0x%06X\n", 0,ifxusb_rreg(&global_regs->grxfsiz));
10861 + #ifdef __DED_FIFO__
10862 + fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
10863 + IFX_DEBUGPL(DBG_CIL, " Tx[00] FIFO =0x%06X Sz=0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
10864 + for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
10866 + fifosize.d32=ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i-1]);
10867 + IFX_DEBUGPL(DBG_CIL, " Tx[%02d] FIFO 0x%06X Sz=0x%06X\n",i, fifosize.b.startaddr,fifosize.b.depth);
10870 + fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
10871 + IFX_DEBUGPL(DBG_CIL, " NPTx FIFO =0x%06X Sz=0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
10872 + for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
10874 + fifosize.d32=ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i]);
10875 + IFX_DEBUGPL(DBG_CIL, " PTx[%02d] FIFO 0x%06X Sz=0x%06X\n",i, fifosize.b.startaddr,fifosize.b.depth);
10881 + /* Clear Host Set HNP Enable in the OTG Control Register */
10882 + gotgctl.b.hstsethnpen = 1;
10883 + ifxusb_mreg( &global_regs->gotgctl, gotgctl.d32, 0);
10885 + /* Flush the FIFOs */
10886 + ifxusb_flush_tx_fifo(_core_if, 0x10); /* all Tx FIFOs */
10887 + ifxusb_flush_rx_fifo(_core_if);
10889 + /* Flush the Learning Queue. */
10890 + resetctl.b.intknqflsh = 1;
10891 + ifxusb_wreg( &global_regs->grstctl, resetctl.d32);
10893 + /* Clear all pending Device Interrupts */
10894 + ifxusb_wreg( &_core_if->dev_global_regs->diepmsk , 0 );
10895 + ifxusb_wreg( &_core_if->dev_global_regs->doepmsk , 0 );
10896 + ifxusb_wreg( &_core_if->dev_global_regs->daint , 0xFFFFFFFF );
10897 + ifxusb_wreg( &_core_if->dev_global_regs->daintmsk, 0 );
10899 + dir=_core_if->hwcfg1.d32;
10900 + for (i=0; i <= _core_if->hwcfg2.b.num_dev_ep ; i++,dir>>=2)
10902 + depctl_data_t depctl;
10903 + if((dir&0x03)==0 || (dir&0x03) ==1)
10905 + depctl.d32 = ifxusb_rreg(&_core_if->in_ep_regs[i]->diepctl);
10906 + if (depctl.b.epena)
10909 + depctl.b.epdis = 1;
10910 + depctl.b.snak = 1;
10914 + ifxusb_wreg( &_core_if->in_ep_regs[i]->diepctl, depctl.d32);
10915 + #ifndef __DESC_DMA__
10916 + ifxusb_wreg( &_core_if->in_ep_regs[i]->dieptsiz, 0);
10918 + ifxusb_wreg( &_core_if->in_ep_regs[i]->diepdma, 0);
10919 + ifxusb_wreg( &_core_if->in_ep_regs[i]->diepint, 0xFF);
10922 + if((dir&0x03)==0 || (dir&0x03) ==2)
10924 + depctl.d32 = ifxusb_rreg(&_core_if->out_ep_regs[i]->doepctl);
10925 + if (depctl.b.epena)
10928 + depctl.b.epdis = 1;
10929 + depctl.b.snak = 1;
10933 + ifxusb_wreg( &_core_if->out_ep_regs[i]->doepctl, depctl.d32);
10934 + #ifndef __DESC_DMA__
10935 + ifxusb_wreg( &_core_if->out_ep_regs[i]->doeptsiz, 0);
10937 + ifxusb_wreg( &_core_if->out_ep_regs[i]->doepdma, 0);
10938 + ifxusb_wreg( &_core_if->out_ep_regs[i]->doepint, 0xFF);
10944 +++ b/drivers/usb/ifxhcd/ifxusb_cif_h.c
10946 +/*****************************************************************************
10947 + ** FILE NAME : ifxusb_cif_h.c
10948 + ** PROJECT : IFX USB sub-system V3
10949 + ** MODULES : IFX USB sub-system Host and Device driver
10950 + ** SRC VERSION : 1.0
10951 + ** DATE : 1/Jan/2009
10952 + ** AUTHOR : Chen, Howard
10953 + ** DESCRIPTION : The Core Interface provides basic services for accessing and
10954 + ** managing the IFX USB hardware. These services are used by the
10955 + ** Host Controller Driver only.
10956 + *****************************************************************************/
10959 + \file ifxusb_cif_h.c
10960 + \ingroup IFXUSB_DRIVER_V3
10961 + \brief This file contains the interface to the IFX USB Core.
10963 +#include <linux/version.h>
10964 +#include "ifxusb_version.h"
10966 +#include <asm/byteorder.h>
10967 +#include <asm/unaligned.h>
10970 + #include <linux/jiffies.h>
10972 +#include <linux/platform_device.h>
10973 +#include <linux/kernel.h>
10974 +#include <linux/ioport.h>
10975 +#if defined(__UEIP__)
10976 +// #include <asm/ifx/ifx_board.h>
10979 +//#include <asm/ifx/ifx_gpio.h>
10980 +#if defined(__UEIP__)
10981 +// #include <asm/ifx/ifx_led.h>
10984 +#include "ifxusb_plat.h"
10985 +#include "ifxusb_regs.h"
10986 +#include "ifxusb_cif.h"
10988 +#include "ifxhcd.h"
10990 +#if !defined(__UEIP__)
10991 + #undef __USING_LED_AS_GPIO__
10996 + \brief This function enables the Host mode interrupts.
10997 + \param _core_if Pointer of core_if structure
10999 +void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if)
11001 + gint_data_t intr_mask ={ .d32 = 0};
11002 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
11004 + IFX_DEBUGPL(DBG_CIL, "%s()\n", __func__);
11006 + /* Clear any pending OTG Interrupts */
11007 + ifxusb_wreg( &global_regs->gotgint, 0xFFFFFFFF);
11009 + /* Clear any pending interrupts */
11010 + ifxusb_wreg( &global_regs->gintsts, 0xFFFFFFFF);
11012 + /* Enable the interrupts in the GINTMSK.*/
11014 + /* Common interrupts */
11015 + intr_mask.b.modemismatch = 1;
11016 + intr_mask.b.conidstschng = 1;
11017 + intr_mask.b.wkupintr = 1;
11018 + intr_mask.b.disconnect = 1;
11019 + intr_mask.b.usbsuspend = 1;
11021 + /* Host interrupts */
11022 + intr_mask.b.sofintr = 1;
11023 + intr_mask.b.portintr = 1;
11024 + intr_mask.b.hcintr = 1;
11026 + ifxusb_mreg( &global_regs->gintmsk, intr_mask.d32, intr_mask.d32);
11027 + IFX_DEBUGPL(DBG_CIL, "%s() gintmsk=%0x\n", __func__, ifxusb_rreg( &global_regs->gintmsk));
11031 + \brief This function disables the Host mode interrupts.
11032 + \param _core_if Pointer of core_if structure
11034 +void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if)
11036 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
11038 + IFX_DEBUGPL(DBG_CILV, "%s()\n", __func__);
11041 + ifxusb_wreg( &global_regs->gintmsk, 0);
11043 + /* Common interrupts */
11045 + gint_data_t intr_mask ={.d32 = 0};
11046 + intr_mask.b.modemismatch = 1;
11047 + intr_mask.b.rxstsqlvl = 1;
11048 + intr_mask.b.conidstschng = 1;
11049 + intr_mask.b.wkupintr = 1;
11050 + intr_mask.b.disconnect = 1;
11051 + intr_mask.b.usbsuspend = 1;
11053 + /* Host interrupts */
11054 + intr_mask.b.sofintr = 1;
11055 + intr_mask.b.portintr = 1;
11056 + intr_mask.b.hcintr = 1;
11057 + intr_mask.b.ptxfempty = 1;
11058 + intr_mask.b.nptxfempty = 1;
11059 + ifxusb_mreg(&global_regs->gintmsk, intr_mask.d32, 0);
11065 + \brief This function initializes the IFXUSB controller registers for Host mode.
11066 + This function flushes the Tx and Rx FIFOs and it flushes any entries in the
11068 + \param _core_if Pointer of core_if structure
11069 + \param _params parameters to be set
11071 +void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
11073 + ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
11075 + gusbcfg_data_t usbcfg ={.d32 = 0};
11076 + gahbcfg_data_t ahbcfg ={.d32 = 0};
11077 + gotgctl_data_t gotgctl ={.d32 = 0};
11081 + IFX_DEBUGPL(DBG_CILV, "%s(%p)\n",__func__,_core_if);
11083 + /* Copy Params */
11085 + _core_if->params.dma_burst_size = _params->dma_burst_size;
11086 + _core_if->params.speed = _params->speed;
11087 + _core_if->params.max_transfer_size = _params->max_transfer_size;
11088 + _core_if->params.max_packet_count = _params->max_packet_count;
11089 + _core_if->params.phy_utmi_width = _params->phy_utmi_width;
11090 + _core_if->params.turn_around_time_hs = _params->turn_around_time_hs;
11091 + _core_if->params.turn_around_time_fs = _params->turn_around_time_fs;
11092 + _core_if->params.timeout_cal_hs = _params->timeout_cal_hs;
11093 + _core_if->params.timeout_cal_fs = _params->timeout_cal_fs;
11095 + /* Reset the Controller */
11098 + while(ifxusb_core_soft_reset( _core_if ))
11099 + ifxusb_hard_reset(_core_if);
11100 + } while (ifxusb_is_device_mode(_core_if));
11102 + usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
11103 +// usbcfg.b.ulpi_ext_vbus_drv = 1;
11104 + usbcfg.b.term_sel_dl_pulse = 0;
11105 + ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
11107 + /* This programming sequence needs to happen in FS mode before any other
11108 + * programming occurs */
11109 + /* High speed PHY. */
11110 + if (!_core_if->phy_init_done)
11112 + _core_if->phy_init_done = 1;
11113 + /* HS PHY parameters. These parameters are preserved
11114 + * during soft reset so only program the first time. Do
11115 + * a soft reset immediately after setting phyif. */
11116 + usbcfg.b.ulpi_utmi_sel = 0; //UTMI+
11117 + usbcfg.b.phyif = ( _core_if->params.phy_utmi_width == 16)?1:0;
11118 + ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
11119 + /* Reset after setting the PHY parameters */
11120 + ifxusb_core_soft_reset( _core_if );
11123 + usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
11124 +// usbcfg.b.ulpi_fsls = 0;
11125 +// usbcfg.b.ulpi_clk_sus_m = 0;
11126 + ifxusb_wreg(&global_regs->gusbcfg, usbcfg.d32);
11128 + /* Program the GAHBCFG Register.*/
11129 + switch (_core_if->params.dma_burst_size)
11132 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE;
11135 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR;
11138 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4;
11141 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8;
11144 + ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16;
11147 + ahbcfg.b.dmaenable = 1;
11148 + ifxusb_wreg(&global_regs->gahbcfg, ahbcfg.d32);
11150 + /* Program the GUSBCFG register. */
11151 + usbcfg.d32 = ifxusb_rreg( &global_regs->gusbcfg );
11152 + usbcfg.b.hnpcap = 0;
11153 + usbcfg.b.srpcap = 0;
11154 + ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
11156 + /* Restart the Phy Clock */
11157 + ifxusb_wreg(_core_if->pcgcctl, 0);
11159 + /* Initialize Host Configuration Register */
11161 + hcfg_data_t hcfg;
11162 + hcfg.d32 = ifxusb_rreg(&_core_if->host_global_regs->hcfg);
11163 + hcfg.b.fslspclksel = IFXUSB_HCFG_30_60_MHZ;
11164 + if (_params->speed == IFXUSB_PARAM_SPEED_FULL)
11165 + hcfg.b.fslssupp = 1;
11166 + ifxusb_wreg(&_core_if->host_global_regs->hcfg, hcfg.d32);
11169 + _core_if->params.host_channels=(_core_if->hwcfg2.b.num_host_chan + 1);
11171 + if(_params->host_channels>0 && _params->host_channels < _core_if->params.host_channels)
11172 + _core_if->params.host_channels = _params->host_channels;
11174 + /* Configure data FIFO sizes */
11175 + _core_if->params.data_fifo_size = _core_if->hwcfg3.b.dfifo_depth;
11176 + _core_if->params.rx_fifo_size = ifxusb_rreg(&global_regs->grxfsiz);
11177 + _core_if->params.nperio_tx_fifo_size= ifxusb_rreg(&global_regs->gnptxfsiz) >> 16;
11178 + _core_if->params.perio_tx_fifo_size = ifxusb_rreg(&global_regs->hptxfsiz) >> 16;
11179 + IFX_DEBUGPL(DBG_CIL, "Initial: FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
11180 + IFX_DEBUGPL(DBG_CIL, " Rx FIFO Size=0x%06X\n", _core_if->params.rx_fifo_size);
11181 + IFX_DEBUGPL(DBG_CIL, " NPTx FIFO Size=0x%06X\n", _core_if->params.nperio_tx_fifo_size);
11182 + IFX_DEBUGPL(DBG_CIL, " PTx FIFO Size=0x%06X\n", _core_if->params.perio_tx_fifo_size);
11185 + fifosize_data_t txfifosize;
11186 + if(_params->data_fifo_size >=0 && _params->data_fifo_size < _core_if->params.data_fifo_size)
11187 + _core_if->params.data_fifo_size = _params->data_fifo_size;
11189 + if( _params->rx_fifo_size >= 0 && _params->rx_fifo_size < _core_if->params.rx_fifo_size)
11190 + _core_if->params.rx_fifo_size = _params->rx_fifo_size;
11191 + if( _params->nperio_tx_fifo_size >=0 && _params->nperio_tx_fifo_size < _core_if->params.nperio_tx_fifo_size)
11192 + _core_if->params.nperio_tx_fifo_size = _params->nperio_tx_fifo_size;
11193 + if( _params->perio_tx_fifo_size >=0 && _params->perio_tx_fifo_size < _core_if->params.perio_tx_fifo_size)
11194 + _core_if->params.perio_tx_fifo_size = _params->perio_tx_fifo_size;
11196 + if(_core_if->params.data_fifo_size < _core_if->params.rx_fifo_size)
11197 + _core_if->params.rx_fifo_size = _core_if->params.data_fifo_size;
11198 + ifxusb_wreg( &global_regs->grxfsiz, _core_if->params.rx_fifo_size);
11199 + txfifosize.b.startaddr = _core_if->params.rx_fifo_size;
11201 + if(txfifosize.b.startaddr + _core_if->params.nperio_tx_fifo_size > _core_if->params.data_fifo_size)
11202 + _core_if->params.nperio_tx_fifo_size = _core_if->params.data_fifo_size - txfifosize.b.startaddr;
11203 + txfifosize.b.depth=_core_if->params.nperio_tx_fifo_size;
11204 + ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
11205 + txfifosize.b.startaddr += _core_if->params.nperio_tx_fifo_size;
11207 + if(txfifosize.b.startaddr + _core_if->params.perio_tx_fifo_size > _core_if->params.data_fifo_size)
11208 + _core_if->params.perio_tx_fifo_size = _core_if->params.data_fifo_size - txfifosize.b.startaddr;
11209 + txfifosize.b.depth=_core_if->params.perio_tx_fifo_size;
11210 + ifxusb_wreg( &global_regs->hptxfsiz, txfifosize.d32);
11211 + txfifosize.b.startaddr += _core_if->params.perio_tx_fifo_size;
11216 + fifosize_data_t fifosize;
11217 + IFX_DEBUGPL(DBG_CIL, "Result : FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
11219 + fifosize.d32=ifxusb_rreg(&global_regs->grxfsiz);
11220 + IFX_DEBUGPL(DBG_CIL, " Rx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
11221 + fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
11222 + IFX_DEBUGPL(DBG_CIL, " NPTx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
11223 + fifosize.d32=ifxusb_rreg(&global_regs->hptxfsiz);
11224 + IFX_DEBUGPL(DBG_CIL, " PTx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
11228 + /* Clear Host Set HNP Enable in the OTG Control Register */
11229 + gotgctl.b.hstsethnpen = 1;
11230 + ifxusb_mreg( &global_regs->gotgctl, gotgctl.d32, 0);
11232 + /* Flush the FIFOs */
11233 + ifxusb_flush_tx_fifo(_core_if, 0x10); /* all Tx FIFOs */
11234 + ifxusb_flush_rx_fifo(_core_if);
11236 + for (i = 0; i < _core_if->hwcfg2.b.num_host_chan + 1; i++)
11238 + hcchar_data_t hcchar;
11239 + hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
11240 + hcchar.b.chen = 0;
11241 + hcchar.b.chdis = 1;
11242 + hcchar.b.epdir = 0;
11243 + ifxusb_wreg(&_core_if->hc_regs[i]->hcchar, hcchar.d32);
11245 + /* Halt all channels to put them into a known state. */
11246 + for (i = 0; i < _core_if->hwcfg2.b.num_host_chan + 1; i++)
11248 + hcchar_data_t hcchar;
11251 + hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
11252 + hcchar.b.chen = 1;
11253 + hcchar.b.chdis = 1;
11254 + hcchar.b.epdir = 0;
11255 + ifxusb_wreg(&_core_if->hc_regs[i]->hcchar, hcchar.d32);
11257 + IFX_DEBUGPL(DBG_HCDV, "%s: Halt channel %d\n", __func__, i);
11259 + hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
11260 + if (++count > 1000)
11262 + IFX_ERROR("%s: Unable to clear halt on channel %d\n", __func__, i);
11265 + } while (hcchar.b.chen);
11269 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11271 +#if defined(__UEIP__)
11272 + #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
11273 + int ifxusb_vbus_status =-1;
11276 + #if defined(IFX_GPIO_USB_VBUS1) || defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
11277 + int ifxusb_vbus1_status =-1;
11280 + #if defined(IFX_GPIO_USB_VBUS2) || defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
11281 + int ifxusb_vbus2_status =-1;
11284 + #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
11285 + static void *g_usb_vbus_trigger = NULL;
11287 + #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
11288 + static void *g_usb_vbus1_trigger = NULL;
11290 + #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
11291 + static void *g_usb_vbus2_trigger = NULL;
11294 + #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11295 + int ifxusb_vbus_gpio_inited=0;
11298 +#else //defined(__UEIP__)
11299 + int ifxusb_vbus_gpio_inited=0;
11302 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11304 +void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
11306 + #if defined(__UEIP__)
11307 + #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
11308 + if ( !g_usb_vbus_trigger )
11310 + ifx_led_trigger_register("USB_VBUS", &g_usb_vbus_trigger);
11311 + if ( g_usb_vbus_trigger != NULL )
11313 + struct ifx_led_trigger_attrib attrib = {0};
11314 + attrib.delay_on = 0;
11315 + attrib.delay_off = 0;
11316 + attrib.timeout = 0;
11317 + attrib.def_value = 0;
11318 + attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
11319 + IFX_DEBUGP("Reg USB power!!\n");
11320 + ifx_led_trigger_set_attrib(g_usb_vbus_trigger, &attrib);
11321 + ifxusb_vbus_status =0;
11325 + #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
11326 + if(_core_if->core_no==0 && !g_usb_vbus1_trigger )
11328 + ifx_led_trigger_register("USB_VBUS1", &g_usb_vbus1_trigger);
11329 + if ( g_usb_vbus1_trigger != NULL )
11331 + struct ifx_led_trigger_attrib attrib = {0};
11332 + attrib.delay_on = 0;
11333 + attrib.delay_off = 0;
11334 + attrib.timeout = 0;
11335 + attrib.def_value = 0;
11336 + attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
11337 + IFX_DEBUGP("Reg USB1 power!!\n");
11338 + ifx_led_trigger_set_attrib(g_usb_vbus1_trigger, &attrib);
11339 + ifxusb_vbus1_status =0;
11343 + #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
11344 + if(_core_if->core_no==1 && !g_usb_vbus2_trigger )
11346 + ifx_led_trigger_register("USB_VBUS2", &g_usb_vbus2_trigger);
11347 + if ( g_usb_vbus2_trigger != NULL )
11349 + struct ifx_led_trigger_attrib attrib = {0};
11350 + attrib.delay_on = 0;
11351 + attrib.delay_off = 0;
11352 + attrib.timeout = 0;
11353 + attrib.def_value = 0;
11354 + attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
11355 + IFX_DEBUGP("Reg USB2 power!!\n");
11356 + ifx_led_trigger_set_attrib(g_usb_vbus2_trigger, &attrib);
11357 + ifxusb_vbus2_status =0;
11362 + #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11363 + /* == 20100712 AVM/WK use gpio_inited as bitmask == */
11364 + if(ifxusb_vbus_gpio_inited == 0)
11366 + if(!ifx_gpio_register(IFX_GPIO_MODULE_USB))
11368 + IFX_DEBUGP("Register USB VBus through GPIO OK!!\n");
11369 + #ifdef IFX_GPIO_USB_VBUS
11370 + ifxusb_vbus_status =0;
11371 + #endif //IFX_GPIO_USB_VBUS
11372 + #ifdef IFX_GPIO_USB_VBUS1
11373 + ifxusb_vbus1_status=0;
11374 + #endif //IFX_GPIO_USB_VBUS1
11375 + #ifdef IFX_GPIO_USB_VBUS2
11376 + ifxusb_vbus2_status=0;
11377 + #endif //IFX_GPIO_USB_VBUS2
11378 + ifxusb_vbus_gpio_inited|= (1<<_core_if->core_no);
11381 + IFX_PRINT("Register USB VBus Failed!!\n");
11383 + ifxusb_vbus_gpio_inited|= (1<<_core_if->core_no);
11385 + #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11386 + #endif //defined(__UEIP__)
11389 +void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
11391 + #if defined(__UEIP__)
11392 + #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
11393 + if ( g_usb_vbus_trigger )
11395 + ifx_led_trigger_deregister(g_usb_vbus_trigger);
11396 + g_usb_vbus_trigger = NULL;
11397 + ifxusb_vbus_status =-1;
11400 + #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
11401 + if(_core_if->core_no==0 && g_usb_vbus1_trigger )
11403 + ifx_led_trigger_deregister(g_usb_vbus1_trigger);
11404 + g_usb_vbus1_trigger = NULL;
11405 + ifxusb_vbus1_status =-1;
11408 + #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
11409 + if(_core_if->core_no==1 && g_usb_vbus2_trigger )
11411 + ifx_led_trigger_deregister(g_usb_vbus2_trigger);
11412 + g_usb_vbus2_trigger = NULL;
11413 + ifxusb_vbus2_status =-1;
11417 + #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11418 + /* == 20100712 AVM/WK use gpio_inited as bitmask == */
11419 + if((ifxusb_vbus_gpio_inited & (1<<_core_if->core_no)) == ifxusb_vbus_gpio_inited)
11421 + ifx_gpio_deregister(IFX_GPIO_MODULE_USB);
11422 + #ifdef IFX_GPIO_USB_VBUS
11423 + ifxusb_vbus_status =-1;
11424 + #endif //IFX_GPIO_USB_VBUS
11425 + #ifdef IFX_GPIO_USB_VBUS1
11426 + ifxusb_vbus1_status=-1;
11427 + #endif //IFX_GPIO_USB_VBUS1
11428 + #ifdef IFX_GPIO_USB_VBUS2
11429 + ifxusb_vbus2_status=-1;
11430 + #endif //IFX_GPIO_USB_VBUS2
11432 + ifxusb_vbus_gpio_inited &= ~(1<<_core_if->core_no);
11433 + #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11434 + #endif //defined(__UEIP__)
11439 + \brief Turn on the USB 5V VBus Power
11440 + \param _core_if Pointer of core_if structure
11442 +void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
11444 + IFX_DEBUGP("SENDING VBus POWER UP\n");
11445 + #if defined(__UEIP__)
11446 + #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
11447 + if ( g_usb_vbus_trigger && ifxusb_vbus_status==0)
11449 + ifx_led_trigger_activate(g_usb_vbus_trigger);
11450 + IFX_DEBUGP("Enable USB power!!\n");
11451 + ifxusb_vbus_status=1;
11454 + #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
11455 + if(_core_if->core_no==0 && g_usb_vbus1_trigger && ifxusb_vbus1_status==0)
11457 + ifx_led_trigger_activate(g_usb_vbus1_trigger);
11458 + IFX_DEBUGP("Enable USB1 power!!\n");
11459 + ifxusb_vbus1_status=1;
11462 + #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
11463 + if(_core_if->core_no==1 && g_usb_vbus2_trigger && ifxusb_vbus2_status==0)
11465 + ifx_led_trigger_activate(g_usb_vbus2_trigger);
11466 + IFX_DEBUGP("Enable USB2 power!!\n");
11467 + ifxusb_vbus2_status=1;
11471 + #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11472 + if(ifxusb_vbus_gpio_inited)
11474 + #if defined(IFX_GPIO_USB_VBUS)
11475 + if(ifxusb_vbus_status==0)
11477 + ifx_gpio_output_set(IFX_GPIO_USB_VBUS,IFX_GPIO_MODULE_USB);
11478 + ifxusb_vbus_status=1;
11481 + #if defined(IFX_GPIO_USB_VBUS1)
11482 + if(_core_if->core_no==0 && ifxusb_vbus1_status==0)
11484 + ifx_gpio_output_set(IFX_GPIO_USB_VBUS1,IFX_GPIO_MODULE_USB);
11485 + ifxusb_vbus1_status=1;
11488 + #if defined(IFX_GPIO_USB_VBUS2)
11489 + if(_core_if->core_no==1 && ifxusb_vbus2_status==0)
11491 + ifx_gpio_output_set(IFX_GPIO_USB_VBUS2,IFX_GPIO_MODULE_USB);
11492 + ifxusb_vbus2_status=1;
11496 + #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11498 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
11499 + ifxusb_vbus_status=1;
11500 + //usb_set_vbus_on();
11501 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
11502 + #if defined(__IS_AMAZON_SE__)
11503 + set_bit (4, (volatile unsigned long *)AMAZON_SE_GPIO_P0_OUT);
11504 + ifxusb_vbus_status=1;
11505 + #endif //defined(__IS_AMAZON_SE__)
11506 + #if defined(__IS_AR9__)
11507 + if(_core_if->core_no==0)
11509 + if (bsp_port_reserve_pin(1, 13, PORT_MODULE_USB) != 0)
11511 + IFX_PRINT("Can't enable USB1 5.5V power!!\n");
11514 + bsp_port_clear_altsel0(1, 13, PORT_MODULE_USB);
11515 + bsp_port_clear_altsel1(1, 13, PORT_MODULE_USB);
11516 + bsp_port_set_dir_out(1, 13, PORT_MODULE_USB);
11517 + bsp_port_set_pudsel(1, 13, PORT_MODULE_USB);
11518 + bsp_port_set_puden(1, 13, PORT_MODULE_USB);
11519 + bsp_port_set_output(1, 13, PORT_MODULE_USB);
11520 + IFX_DEBUGP("Enable USB1 power!!\n");
11521 + ifxusb_vbus1_status=1;
11525 + if (bsp_port_reserve_pin(3, 4, PORT_MODULE_USB) != 0)
11527 + IFX_PRINT("Can't enable USB2 5.5V power!!\n");
11530 + bsp_port_clear_altsel0(3, 4, PORT_MODULE_USB);
11531 + bsp_port_clear_altsel1(3, 4, PORT_MODULE_USB);
11532 + bsp_port_set_dir_out(3, 4, PORT_MODULE_USB);
11533 + bsp_port_set_pudsel(3, 4, PORT_MODULE_USB);
11534 + bsp_port_set_puden(3, 4, PORT_MODULE_USB);
11535 + bsp_port_set_output(3, 4, PORT_MODULE_USB);
11536 + IFX_DEBUGP("Enable USB2 power!!\n");
11537 + ifxusb_vbus2_status=1;
11539 + #endif //defined(__IS_AR9__)
11540 + #if defined(__IS_VR9__)
11541 + if(_core_if->core_no==0)
11543 + ifxusb_vbus1_status=1;
11547 + ifxusb_vbus2_status=1;
11549 + #endif //defined(__IS_VR9__)
11550 + #endif //defined(__UEIP__)
11555 + \brief Turn off the USB 5V VBus Power
11556 + \param _core_if Pointer of core_if structure
11558 +void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
11560 + IFX_DEBUGP("SENDING VBus POWER OFF\n");
11562 + #if defined(__UEIP__)
11563 + #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
11564 + if ( g_usb_vbus_trigger && ifxusb_vbus_status==1)
11566 + ifx_led_trigger_deactivate(g_usb_vbus_trigger);
11567 + IFX_DEBUGP("Disable USB power!!\n");
11568 + ifxusb_vbus_status=0;
11571 + #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
11572 + if(_core_if->core_no==0 && g_usb_vbus1_trigger && ifxusb_vbus1_status==1)
11574 + ifx_led_trigger_deactivate(g_usb_vbus1_trigger);
11575 + IFX_DEBUGP("Disable USB1 power!!\n");
11576 + ifxusb_vbus1_status=0;
11579 + #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
11580 + if(_core_if->core_no==1 && g_usb_vbus2_trigger && ifxusb_vbus2_status==1)
11582 + ifx_led_trigger_deactivate(g_usb_vbus2_trigger);
11583 + IFX_DEBUGP("Disable USB2 power!!\n");
11584 + ifxusb_vbus2_status=0;
11588 + #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11589 + if(ifxusb_vbus_gpio_inited)
11591 + #if defined(IFX_GPIO_USB_VBUS)
11592 + if(ifxusb_vbus_status==1)
11594 + ifx_gpio_output_clear(IFX_GPIO_USB_VBUS,IFX_GPIO_MODULE_USB);
11595 + ifxusb_vbus_status=0;
11598 + #if defined(IFX_GPIO_USB_VBUS1)
11599 + if(_core_if->core_no==0 && ifxusb_vbus1_status==1)
11601 + ifx_gpio_output_clear(IFX_GPIO_USB_VBUS1,IFX_GPIO_MODULE_USB);
11602 + ifxusb_vbus1_status=0;
11605 + #if defined(IFX_GPIO_USB_VBUS2)
11606 + if(_core_if->core_no==1 && ifxusb_vbus2_status==1)
11608 + ifx_gpio_output_clear(IFX_GPIO_USB_VBUS2,IFX_GPIO_MODULE_USB);
11609 + ifxusb_vbus2_status=0;
11613 + #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
11615 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
11616 + ifxusb_vbus_status=0;
11617 + //usb_set_vbus_on();
11618 + #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
11619 + #if defined(__IS_AMAZON_SE__)
11620 + clear_bit (4, (volatile unsigned long *)AMAZON_SE_GPIO_P0_OUT);
11621 + ifxusb_vbus_status=0;
11622 + #endif //defined(__IS_AMAZON_SE__)
11623 + #if defined(__IS_AR9__)
11624 + if(_core_if->core_no==0)
11626 + if (bsp_port_reserve_pin(1, 13, PORT_MODULE_USB) != 0) {
11627 + IFX_PRINT("Can't Disable USB1 5.5V power!!\n");
11630 + bsp_port_clear_altsel0(1, 13, PORT_MODULE_USB);
11631 + bsp_port_clear_altsel1(1, 13, PORT_MODULE_USB);
11632 + bsp_port_set_dir_out(1, 13, PORT_MODULE_USB);
11633 + bsp_port_set_pudsel(1, 13, PORT_MODULE_USB);
11634 + bsp_port_set_puden(1, 13, PORT_MODULE_USB);
11635 + bsp_port_clear_output(1, 13, PORT_MODULE_USB);
11636 + IFX_DEBUGP("Disable USB1 power!!\n");
11637 + ifxusb_vbus1_status=0;
11641 + if (bsp_port_reserve_pin(3, 4, PORT_MODULE_USB) != 0) {
11642 + IFX_PRINT("Can't Disable USB2 5.5V power!!\n");
11645 + bsp_port_clear_altsel0(3, 4, PORT_MODULE_USB);
11646 + bsp_port_clear_altsel1(3, 4, PORT_MODULE_USB);
11647 + bsp_port_set_dir_out(3, 4, PORT_MODULE_USB);
11648 + bsp_port_set_pudsel(3, 4, PORT_MODULE_USB);
11649 + bsp_port_set_puden(3, 4, PORT_MODULE_USB);
11650 + bsp_port_clear_output(3, 4, PORT_MODULE_USB);
11651 + IFX_DEBUGP("Disable USB2 power!!\n");
11653 + ifxusb_vbus2_status=0;
11655 + #endif //defined(__IS_AR9__)
11656 + #if defined(__IS_VR9__)
11657 + if(_core_if->core_no==0)
11659 + ifxusb_vbus1_status=0;
11663 + ifxusb_vbus2_status=0;
11665 + #endif //defined(__IS_VR9__)
11666 + #endif //defined(__UEIP__)
11672 + \brief Read Current VBus status
11673 + \param _core_if Pointer of core_if structure
11675 +int ifxusb_vbus(ifxusb_core_if_t *_core_if)
11677 +#if defined(__UEIP__)
11678 + #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
11679 + return (ifxusb_vbus_status);
11682 + #if defined(IFX_GPIO_USB_VBUS1) || defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
11683 + if(_core_if->core_no==0)
11684 + return (ifxusb_vbus1_status);
11687 + #if defined(IFX_GPIO_USB_VBUS2) || defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
11688 + if(_core_if->core_no==1)
11689 + return (ifxusb_vbus2_status);
11691 +#else //defined(__UEIP__)
11696 +#if defined(__UEIP__)
11698 + #if defined(__IS_TWINPASS__)
11699 + #define ADSL_BASE 0x20000
11700 + #define CRI_BASE 0x31F00
11701 + #define CRI_CCR0 CRI_BASE + 0x00
11702 + #define CRI_CCR1 CRI_BASE + 0x01*4
11703 + #define CRI_CDC0 CRI_BASE + 0x02*4
11704 + #define CRI_CDC1 CRI_BASE + 0x03*4
11705 + #define CRI_RST CRI_BASE + 0x04*4
11706 + #define CRI_MASK0 CRI_BASE + 0x05*4
11707 + #define CRI_MASK1 CRI_BASE + 0x06*4
11708 + #define CRI_MASK2 CRI_BASE + 0x07*4
11709 + #define CRI_STATUS0 CRI_BASE + 0x08*4
11710 + #define CRI_STATUS1 CRI_BASE + 0x09*4
11711 + #define CRI_STATUS2 CRI_BASE + 0x0A*4
11712 + #define CRI_AMASK0 CRI_BASE + 0x0B*4
11713 + #define CRI_AMASK1 CRI_BASE + 0x0C*4
11714 + #define CRI_UPDCTL CRI_BASE + 0x0D*4
11715 + #define CRI_MADST CRI_BASE + 0x0E*4
11716 + // 0x0f is missing
11717 + #define CRI_EVENT0 CRI_BASE + 0x10*4
11718 + #define CRI_EVENT1 CRI_BASE + 0x11*4
11719 + #define CRI_EVENT2 CRI_BASE + 0x12*4
11721 + #define IRI_I_ENABLE 0x32000
11722 + #define STY_SMODE 0x3c004
11723 + #define AFE_TCR_0 0x3c0dc
11724 + #define AFE_ADDR_ADDR 0x3c0e8
11725 + #define AFE_RDATA_ADDR 0x3c0ec
11726 + #define AFE_WDATA_ADDR 0x3c0f0
11727 + #define AFE_CONFIG 0x3c0f4
11728 + #define AFE_SERIAL_CFG 0x3c0fc
11730 + #define DFE_BASE_ADDR 0xBE116000
11731 + //#define DFE_BASE_ADDR 0x9E116000
11733 + #define MEI_FR_ARCINT_C (DFE_BASE_ADDR + 0x0000001C)
11734 + #define MEI_DBG_WADDR_C (DFE_BASE_ADDR + 0x00000024)
11735 + #define MEI_DBG_RADDR_C (DFE_BASE_ADDR + 0x00000028)
11736 + #define MEI_DBG_DATA_C (DFE_BASE_ADDR + 0x0000002C)
11737 + #define MEI_DBG_DECO_C (DFE_BASE_ADDR + 0x00000030)
11738 + #define MEI_DBG_MASTER_C (DFE_BASE_ADDR + 0x0000003C)
11740 + static void WriteARCmem(uint32_t addr, uint32_t data)
11742 + writel(1 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
11743 + writel(1 ,(volatile uint32_t *)MEI_DBG_DECO_C );
11744 + writel(addr ,(volatile uint32_t *)MEI_DBG_WADDR_C );
11745 + writel(data ,(volatile uint32_t *)MEI_DBG_DATA_C );
11746 + while( (ifxusb_rreg((volatile uint32_t *)MEI_FR_ARCINT_C) & 0x20) != 0x20 ){};
11747 + writel(0 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
11748 + IFX_DEBUGP("WriteARCmem %08x %08x\n",addr,data);
11751 + static uint32_t ReadARCmem(uint32_t addr)
11754 + writel(1 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
11755 + writel(1 ,(volatile uint32_t *)MEI_DBG_DECO_C );
11756 + writel(addr ,(volatile uint32_t *)MEI_DBG_RADDR_C );
11757 + while( (ifxusb_rreg((volatile uint32_t *)MEI_FR_ARCINT_C) & 0x20) != 0x20 ){};
11758 + data = ifxusb_rreg((volatile uint32_t *)MEI_DBG_DATA_C );
11759 + writel(0 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
11760 + IFX_DEBUGP("ReadARCmem %08x %08x\n",addr,data);
11764 + void ifxusb_enable_afe_oc(void)
11766 + /* Start the clock */
11767 + WriteARCmem(CRI_UPDCTL ,0x00000008);
11768 + WriteARCmem(CRI_CCR0 ,0x00000014);
11769 + WriteARCmem(CRI_CCR1 ,0x00000500);
11770 + WriteARCmem(AFE_CONFIG ,0x000001c8);
11771 + WriteARCmem(AFE_SERIAL_CFG,0x00000016); // (DANUBE_PCI_CFG_BASE+(1<<addrline))AFE serial interface clock & data latch edge
11772 + WriteARCmem(AFE_TCR_0 ,0x00000002);
11773 + //Take afe out of reset
11774 + WriteARCmem(AFE_CONFIG ,0x000000c0);
11775 + WriteARCmem(IRI_I_ENABLE ,0x00000101);
11776 + WriteARCmem(STY_SMODE ,0x00001980);
11778 + ReadARCmem(CRI_UPDCTL );
11779 + ReadARCmem(CRI_CCR0 );
11780 + ReadARCmem(CRI_CCR1 );
11781 + ReadARCmem(AFE_CONFIG );
11782 + ReadARCmem(AFE_SERIAL_CFG); // (DANUBE_PCI_CFG_BASE+(1<<addrline))AFE serial interface clock & data latch edge
11783 + ReadARCmem(AFE_TCR_0 );
11784 + ReadARCmem(AFE_CONFIG );
11785 + ReadARCmem(IRI_I_ENABLE );
11786 + ReadARCmem(STY_SMODE );
11788 + #endif //defined(__IS_TWINPASS__)
11789 +#endif //defined(__UEIP__)
11793 +++ b/drivers/usb/ifxhcd/ifxusb_ctl.c
11795 +/*****************************************************************************
11796 + ** FILE NAME : ifxusb_ctl.c
11797 + ** PROJECT : IFX USB sub-system V3
11798 + ** MODULES : IFX USB sub-system Host and Device driver
11799 + ** SRC VERSION : 1.0
11800 + ** DATE : 1/Jan/2009
11801 + ** AUTHOR : Chen, Howard
11802 + ** DESCRIPTION : Implementing the procfs and sysfs for IFX USB driver
11803 + *****************************************************************************/
11805 +/*! \file ifxusb_ctl.c
11806 + \ingroup IFXUSB_DRIVER_V3
11807 + \brief Implementing the procfs and sysfs for IFX USB driver
11810 +#include <linux/version.h>
11811 +#include "ifxusb_version.h"
11814 +#include <linux/proc_fs.h>
11815 +#include <asm/byteorder.h>
11816 +#include <asm/unaligned.h>
11817 +#include <asm/uaccess.h>
11819 +#include "ifxusb_plat.h"
11820 +#include "ifxusb_regs.h"
11821 +#include "ifxusb_cif.h"
11823 +#ifdef __IS_DEVICE__
11824 + #include "ifxpcd.h"
11827 +#ifdef __IS_HOST__
11828 + #include "ifxhcd.h"
11831 +#include <linux/device.h>
11832 +#include <linux/platform_device.h>
11833 +#include <linux/gfp.h>
11836 +#ifdef __IS_HOST__
11837 + extern char ifxusb_driver_name[];
11839 + #ifdef __IS_DUAL__
11840 + extern ifxhcd_hcd_t ifxusb_hcd_1;
11841 + extern ifxhcd_hcd_t ifxusb_hcd_2;
11842 + extern char ifxusb_hcd_name_1[];
11843 + extern char ifxusb_hcd_name_2[];
11845 + extern ifxhcd_hcd_t ifxusb_hcd;
11846 + extern char ifxusb_hcd_name[];
11851 +#ifdef __IS_DEVICE__
11852 + extern char ifxusb_driver_name[];
11854 + extern ifxpcd_pcd_t ifxusb_pcd;
11855 + extern char ifxusb_pcd_name[];
11859 +//Attributes for sysfs (for 2.6 only)
11861 +extern struct device_attribute dev_attr_dbglevel;
11863 +#ifdef __IS_DUAL__
11864 + extern struct device_attribute dev_attr_dump_params_1;
11865 + extern struct device_attribute dev_attr_dump_params_2;
11867 + extern struct device_attribute dev_attr_dump_params;
11870 +#ifdef __IS_DUAL__
11871 + extern struct device_attribute dev_attr_mode_1;
11872 + extern struct device_attribute dev_attr_mode_2;
11874 + extern struct device_attribute dev_attr_mode;
11877 +#ifdef __IS_HOST__
11878 + #ifdef __IS_DUAL__
11879 + extern struct device_attribute dev_attr_buspower_1;
11880 + extern struct device_attribute dev_attr_buspower_2;
11881 + extern struct device_attribute dev_attr_bussuspend_1;
11882 + extern struct device_attribute dev_attr_bussuspend_2;
11883 + extern struct device_attribute dev_attr_busconnected_1;
11884 + extern struct device_attribute dev_attr_busconnected_2;
11885 + extern struct device_attribute dev_attr_connectspeed_1;
11886 + extern struct device_attribute dev_attr_connectspeed_1;
11888 + extern struct device_attribute dev_attr_buspower;
11889 + extern struct device_attribute dev_attr_bussuspend;
11890 + extern struct device_attribute dev_attr_busconnected;
11891 + extern struct device_attribute dev_attr_connectspeed;
11893 +#endif //__IS_HOST__
11895 +#ifdef __IS_DEVICE__
11896 + extern struct device_attribute dev_attr_devspeed;
11897 + extern struct device_attribute dev_attr_enumspeed;
11898 +#endif //__IS_DEVICE__
11900 +#ifdef __ENABLE_DUMP__
11901 + #ifdef __IS_DUAL__
11902 + extern struct device_attribute dev_attr_dump_reg_1;
11903 + extern struct device_attribute dev_attr_dump_reg_2;
11904 + extern struct device_attribute dev_attr_dump_spram_1;
11905 + extern struct device_attribute dev_attr_dump_spram_2;
11906 + #ifdef __IS_HOST__
11907 + extern struct device_attribute dev_attr_dump_host_state_1;
11908 + extern struct device_attribute dev_attr_dump_host_state_2;
11912 + extern struct device_attribute dev_attr_dump_reg;
11913 + extern struct device_attribute dev_attr_dump_spram;
11914 + #ifdef __IS_HOST__
11915 + extern struct device_attribute dev_attr_dump_host_state;
11919 +#endif //__ENABLE_DUMP__
11922 +/////////////////////////////////////////////////////////////////////////////////////////////////////
11923 +/////////////////////////////////////////////////////////////////////////////////////////////////////
11924 +/////////////////////////////////////////////////////////////////////////////////////////////////////
11926 +static ssize_t procfs_dbglevel_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
11928 + #ifdef __IS_HOST__
11929 + return sprintf( buf, "%08X\n",h_dbg_lvl );
11931 + return sprintf( buf, "%08X\n",d_dbg_lvl );
11935 +static ssize_t procfs_dbglevel_store(struct file *file, const char *buffer, unsigned long count, void *data)
11940 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
11942 + value = simple_strtoul(buf, NULL, 16);
11943 + #ifdef __IS_HOST__
11944 + h_dbg_lvl =value;
11946 + d_dbg_lvl =value;
11948 + //turn on and off power
11952 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
11953 + static ssize_t sysfs_dbglevel_show( struct device *_dev, struct device_attribute *attr,char *buf)
11955 + static ssize_t sysfs_dbglevel_show( struct device *_dev, char *buf)
11958 + #ifdef __IS_HOST__
11959 + return sprintf( buf, "%08X\n",h_dbg_lvl );
11961 + return sprintf( buf, "%08X\n",d_dbg_lvl );
11965 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
11966 + static ssize_t sysfs_dbglevel_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
11968 + static ssize_t sysfs_dbglevel_store( struct device *_dev, const char *buffer, size_t count )
11974 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
11976 + value = simple_strtoul(buf, NULL, 16);
11977 + #ifdef __IS_HOST__
11978 + h_dbg_lvl =value;
11980 + d_dbg_lvl =value;
11982 + //turn on and off power
11986 +DEVICE_ATTR(dbglevel, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
11989 +/////////////////////////////////////////////////////////////////////////////////////////////////////
11990 +/////////////////////////////////////////////////////////////////////////////////////////////////////
11991 +/////////////////////////////////////////////////////////////////////////////////////////////////////
11993 +static void ifxusb_dump_params(ifxusb_core_if_t *_core_if);
11995 +#ifdef __IS_DUAL__
11996 + static void dump_params_1(void)
11998 + ifxusb_dump_params(&ifxusb_hcd_1.core_if);
12000 + static void dump_params_2(void)
12002 + ifxusb_dump_params(&ifxusb_hcd_2.core_if);
12005 + static ssize_t procfs_dump_params_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12010 + static ssize_t procfs_dump_params_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12016 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12017 + static ssize_t sysfs_dump_params_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12019 + static ssize_t sysfs_dump_params_show_1( struct device *_dev,char *buf)
12025 + DEVICE_ATTR(dump_params_1, S_IRUGO|S_IWUSR, sysfs_dump_params_show_1, NULL);
12027 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12028 + static ssize_t sysfs_dump_params_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12030 + static ssize_t sysfs_dump_params_show_2( struct device *_dev,char *buf)
12037 + DEVICE_ATTR(dump_params_2, S_IRUGO|S_IWUSR, sysfs_dump_params_show_2, NULL);
12039 + static void dump_params(void)
12041 + #ifdef __IS_HOST__
12042 + ifxusb_dump_params(&ifxusb_hcd.core_if);
12044 + ifxusb_dump_params(&ifxusb_pcd.core_if);
12048 + static ssize_t procfs_dump_params_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12054 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12055 + static ssize_t sysfs_dump_params_show( struct device *_dev, struct device_attribute *attr,char *buf)
12057 + static ssize_t sysfs_dump_params_show( struct device *_dev,char *buf)
12063 + DEVICE_ATTR(dump_params, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
12066 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12067 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12068 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12070 +#ifdef __IS_DUAL__
12071 + static ssize_t mode_show_1(char *buf)
12073 + if((ifxusb_rreg(&ifxusb_hcd_1.core_if.core_global_regs->gintsts ) & 0x1) == 1)
12074 + return sprintf( buf, "HOST\n" );
12076 + return sprintf( buf, "DEVICE(INCORRECT!)\n" );
12079 + static ssize_t mode_show_2(char *buf)
12081 + if((ifxusb_rreg(&ifxusb_hcd_2.core_if.core_global_regs->gintsts ) & 0x1) == 1)
12082 + return sprintf( buf, "HOST\n" );
12084 + return sprintf( buf, "DEVICE(INCORRECT!)\n" );
12087 + static ssize_t procfs_mode_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12089 + return mode_show_1(buf);
12091 + static ssize_t procfs_mode_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12093 + return mode_show_2(buf);
12096 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12097 + static ssize_t sysfs_mode_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12099 + static ssize_t sysfs_mode_show_1( struct device *_dev,char *buf)
12102 + return mode_show_1(buf);
12105 + DEVICE_ATTR(mode_1, S_IRUGO|S_IWUSR, sysfs_mode_show_1, 0);
12107 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12108 + static ssize_t sysfs_mode_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12110 + static ssize_t sysfs_mode_show_2( struct device *_dev,char *buf)
12113 + return mode_show_2(buf);
12115 + DEVICE_ATTR(mode_2, S_IRUGO|S_IWUSR, sysfs_mode_show_2, NULL);
12117 + static ssize_t mode_show(char *buf)
12119 + #ifdef __IS_HOST__
12120 + if((ifxusb_rreg(&ifxusb_hcd.core_if.core_global_regs->gintsts ) & 0x1) == 1)
12121 + return sprintf( buf, "HOST\n" );
12123 + return sprintf( buf, "DEVICE(INCORRECT!)\n" );
12125 + if((ifxusb_rreg(&ifxusb_pcd.core_if.core_global_regs->gintsts ) & 0x1) != 1)
12126 + return sprintf( buf, "DEVICE\n" );
12128 + return sprintf( buf, "HOST(INCORRECT!)\n" );
12131 + static ssize_t procfs_mode_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12133 + return mode_show(buf);
12135 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12136 + static ssize_t sysfs_mode_show( struct device *_dev, struct device_attribute *attr,char *buf)
12138 + static ssize_t sysfs_mode_show( struct device *_dev, char *buf)
12141 + return mode_show(buf);
12143 + DEVICE_ATTR(mode, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
12146 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12147 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12148 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12150 +#ifdef __IS_HOST__
12151 + #ifdef __IS_DUAL__
12152 + static ssize_t buspower_show_1(char *buf)
12154 + if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==1) return sprintf( buf, "1\n" );
12155 + if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==0) return sprintf( buf, "0\n" );
12156 + return sprintf( buf, "UNKNOWN\n" );
12158 + static void buspower_store_1(uint32_t value)
12160 + if (value==1) ifxusb_vbus_on (&ifxusb_hcd_1.core_if);
12161 + else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_1.core_if);
12163 + static ssize_t buspower_show_2(char *buf)
12165 + if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==1) return sprintf( buf, "1\n" );
12166 + if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==0) return sprintf( buf, "0\n" );
12167 + return sprintf( buf, "UNKNOWN\n" );
12169 + static void buspower_store_2(uint32_t value)
12171 + if (value==1) ifxusb_vbus_on (&ifxusb_hcd_2.core_if);
12172 + else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_2.core_if);
12174 + static ssize_t procfs_buspower_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12176 + return buspower_show_1(buf);
12178 + static ssize_t procfs_buspower_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
12183 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
12185 + value = simple_strtoul(buf, NULL, 16);
12186 + buspower_store_1(value);
12189 + static ssize_t procfs_buspower_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12191 + return buspower_show_2(buf);
12193 + static ssize_t procfs_buspower_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
12198 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
12200 + value = simple_strtoul(buf, NULL, 16);
12201 + buspower_store_2(value);
12205 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12206 + static ssize_t sysfs_buspower_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12208 + static ssize_t sysfs_buspower_show_1( struct device *_dev,char *buf)
12211 + return buspower_show_1(buf);
12213 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12214 + static ssize_t sysfs_buspower_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
12216 + static ssize_t sysfs_buspower_store_1( struct device *_dev, const char *buffer, size_t count )
12222 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
12224 + value = simple_strtoul(buf, NULL, 16);
12225 + buspower_store_1(value);
12228 + DEVICE_ATTR(buspower_1, S_IRUGO|S_IWUSR, sysfs_buspower_show_1, sysfs_buspower_store_1);
12230 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12231 + static ssize_t sysfs_buspower_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12233 + static ssize_t sysfs_buspower_show_2( struct device *_dev,char *buf)
12236 + return buspower_show_2(buf);
12238 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12239 + static ssize_t sysfs_buspower_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
12241 + static ssize_t sysfs_buspower_store_2( struct device *_dev, const char *buffer, size_t count )
12247 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
12249 + value = simple_strtoul(buf, NULL, 16);
12250 + buspower_store_2(value);
12253 + DEVICE_ATTR(buspower_2, S_IRUGO|S_IWUSR, sysfs_buspower_show_2, sysfs_buspower_store_2);
12255 + static ssize_t buspower_show(char *buf)
12257 + if(ifxusb_vbus (&ifxusb_hcd.core_if)==1) return sprintf( buf, "1\n" );
12258 + if(ifxusb_vbus (&ifxusb_hcd.core_if)==0) return sprintf( buf, "0\n" );
12259 + return sprintf( buf, "UNKNOWN\n" );
12261 + static void buspower_store(uint32_t value)
12263 + if (value==1) ifxusb_vbus_on (&ifxusb_hcd.core_if);
12264 + else if(value==0) ifxusb_vbus_off(&ifxusb_hcd.core_if);
12266 + static ssize_t procfs_buspower_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12268 + return buspower_show(buf);
12270 + static ssize_t procfs_buspower_store(struct file *file, const char *buffer, unsigned long count, void *data)
12275 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
12277 + value = simple_strtoul(buf, NULL, 16);
12278 + buspower_store(value);
12281 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12282 + static ssize_t sysfs_buspower_show( struct device *_dev, struct device_attribute *attr,char *buf)
12284 + static ssize_t sysfs_buspower_show( struct device *_dev, char *buf)
12287 + return buspower_show(buf);
12289 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12290 + static ssize_t sysfs_buspower_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
12292 + static ssize_t sysfs_buspower_store( struct device *_dev, const char *buffer, size_t count )
12298 + if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
12300 + value = simple_strtoul(buf, NULL, 16);
12301 + buspower_store(value);
12304 + DEVICE_ATTR(buspower, S_IRUGO|S_IWUSR, sysfs_buspower_show, sysfs_buspower_store);
12307 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12308 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12309 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12312 + #ifdef __IS_DUAL__
12313 + static ssize_t bussuspend_show_1(char *buf)
12315 + hprt0_data_t val;
12316 + val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
12317 + return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
12319 + static ssize_t bussuspend_show_2(char *buf)
12321 + hprt0_data_t val;
12322 + val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
12323 + return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
12326 + static ssize_t procfs_bussuspend_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12328 + return bussuspend_show_1(buf);
12330 + static ssize_t procfs_bussuspend_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12332 + return bussuspend_show_2(buf);
12334 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12335 + static ssize_t sysfs_bussuspend_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12337 + static ssize_t sysfs_bussuspend_show_1( struct device *_dev,char *buf)
12340 + return bussuspend_show_1(buf);
12342 + DEVICE_ATTR(bussuspend_1, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_1, 0);
12343 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12344 + static ssize_t sysfs_bussuspend_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12346 + static ssize_t sysfs_bussuspend_show_2( struct device *_dev,char *buf)
12349 + return bussuspend_show_2(buf);
12351 + DEVICE_ATTR(bussuspend_2, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_2, 0);
12353 + static ssize_t bussuspend_show(char *buf)
12355 + hprt0_data_t val;
12356 + val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
12357 + return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
12359 + static ssize_t procfs_bussuspend_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12361 + return bussuspend_show(buf);
12364 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12365 + static ssize_t sysfs_bussuspend_show( struct device *_dev, struct device_attribute *attr,char *buf)
12367 + static ssize_t sysfs_bussuspend_show( struct device *_dev, char *buf)
12370 + return bussuspend_show(buf);
12372 + DEVICE_ATTR(bussuspend, S_IRUGO|S_IWUSR, sysfs_bussuspend_show, 0);
12375 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12376 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12377 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12379 + #ifdef __IS_DUAL__
12380 + static ssize_t busconnected_show_1(char *buf)
12382 + hprt0_data_t val;
12383 + val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
12384 + return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
12386 + static ssize_t busconnected_show_2(char *buf)
12388 + hprt0_data_t val;
12389 + val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
12390 + return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
12393 + static ssize_t procfs_busconnected_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12395 + return busconnected_show_1(buf);
12397 + static ssize_t procfs_busconnected_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12399 + return busconnected_show_2(buf);
12401 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12402 + static ssize_t sysfs_busconnected_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12404 + static ssize_t sysfs_busconnected_show_1( struct device *_dev,char *buf)
12407 + return busconnected_show_1(buf);
12409 + DEVICE_ATTR(busconnected_1, S_IRUGO|S_IWUSR, sysfs_busconnected_show_1, 0);
12410 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12411 + static ssize_t sysfs_busconnected_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12413 + static ssize_t sysfs_busconnected_show_2( struct device *_dev,char *buf)
12416 + return busconnected_show_2(buf);
12418 + DEVICE_ATTR(busconnected_2, S_IRUGO|S_IWUSR, sysfs_busconnected_show_2, 0);
12420 + static ssize_t busconnected_show(char *buf)
12422 + hprt0_data_t val;
12423 + val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
12424 + return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
12426 + static ssize_t procfs_busconnected_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12428 + return busconnected_show(buf);
12431 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12432 + static ssize_t sysfs_busconnected_show( struct device *_dev, struct device_attribute *attr,char *buf)
12434 + static ssize_t sysfs_busconnected_show( struct device *_dev, char *buf)
12437 + return busconnected_show(buf);
12439 + DEVICE_ATTR(busconnected, S_IRUGO|S_IWUSR, sysfs_busconnected_show, 0);
12442 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12443 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12444 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12446 + #ifdef __IS_DUAL__
12447 + static ssize_t connectspeed_show_1(char *buf)
12449 + hprt0_data_t val;
12450 + val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
12451 + if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
12452 + if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
12453 + if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
12454 + return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
12456 + static ssize_t connectspeed_show_2(char *buf)
12458 + hprt0_data_t val;
12459 + val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
12460 + if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
12461 + if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
12462 + if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
12463 + return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
12466 + static ssize_t procfs_connectspeed_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12468 + return connectspeed_show_1(buf);
12470 + static ssize_t procfs_connectspeed_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12472 + return connectspeed_show_2(buf);
12474 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12475 + static ssize_t sysfs_connectspeed_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12477 + static ssize_t sysfs_connectspeed_show_1( struct device *_dev,char *buf)
12480 + return connectspeed_show_1(buf);
12482 + DEVICE_ATTR(connectspeed_1, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_1, 0);
12483 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12484 + static ssize_t sysfs_connectspeed_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12486 + static ssize_t sysfs_connectspeed_show_2( struct device *_dev,char *buf)
12489 + return connectspeed_show_2(buf);
12491 + DEVICE_ATTR(connectspeed_2, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_2, 0);
12493 + static ssize_t connectspeed_show(char *buf)
12495 + hprt0_data_t val;
12496 + val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
12497 + if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
12498 + if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
12499 + if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
12500 + return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
12503 + static ssize_t procfs_connectspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12505 + return connectspeed_show(buf);
12508 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12509 + static ssize_t sysfs_connectspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
12511 + static ssize_t sysfs_connectspeed_show( struct device *_dev, char *buf)
12514 + return connectspeed_show(buf);
12516 + DEVICE_ATTR(connectspeed, S_IRUGO|S_IWUSR, sysfs_connectspeed_show, 0);
12518 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12519 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12520 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12524 +#ifdef __IS_DEVICE__
12525 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12526 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12527 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12528 + static ssize_t devspeed_show(char *buf)
12531 + val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dcfg);
12532 + if( val.b.devspd ==0) return sprintf (buf, "Dev Speed = High (%d)\n", val.b.devspd);
12533 + if( val.b.devspd ==1) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
12534 + if( val.b.devspd ==3) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
12535 + return sprintf (buf, "Dev Speed = Unknown (%d)\n", val.b.devspd);
12538 + static ssize_t procfs_devspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12540 + return devspeed_show(buf);
12543 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12544 + static ssize_t sysfs_devspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
12546 + static ssize_t sysfs_devspeed_show( struct device *_dev, char *buf)
12549 + return devspeed_show(buf);
12551 + DEVICE_ATTR(devspeed, S_IRUGO|S_IWUSR, sysfs_devspeed_show, 0);
12553 + static ssize_t enumspeed_show(char *buf)
12556 + val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dsts);
12557 + if( val.b.enumspd ==0) return sprintf (buf, "Enum Speed = High (%d)\n", val.b.enumspd);
12558 + if( val.b.enumspd ==1) return sprintf (buf, "Enum Speed = Full (%d)\n", val.b.enumspd);
12559 + if( val.b.enumspd ==2) return sprintf (buf, "Enum Speed = Low (%d)\n", val.b.enumspd);
12560 + return sprintf (buf, "Enum Speed = invalid(%d)\n", val.b.enumspd);
12563 + static ssize_t procfs_enumspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12565 + return enumspeed_show(buf);
12568 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12569 + static ssize_t sysfs_enumspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
12571 + static ssize_t sysfs_enumspeed_show( struct device *_dev, char *buf)
12574 + return enumspeed_show(buf);
12576 + DEVICE_ATTR(enumspeed, S_IRUGO|S_IWUSR, sysfs_enumspeed_show, 0);
12577 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12578 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12579 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12583 +//////////////////////////////////////////////////////////////////////////////////
12584 +#ifdef __ENABLE_DUMP__
12586 + #ifdef __IS_DUAL__
12587 + static void dump_reg_1(void)
12589 + ifxusb_dump_registers(&ifxusb_hcd_1.core_if);
12591 + static void dump_reg_2(void)
12593 + ifxusb_dump_registers(&ifxusb_hcd_2.core_if);
12596 + static ssize_t procfs_dump_reg_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12601 + static ssize_t procfs_dump_reg_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12606 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12607 + static ssize_t sysfs_dump_reg_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12609 + static ssize_t sysfs_dump_reg_show_1( struct device *_dev,char *buf)
12615 + DEVICE_ATTR(dump_reg_1, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_1, 0);
12616 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12617 + static ssize_t sysfs_dump_reg_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12619 + static ssize_t sysfs_dump_reg_show_2( struct device *_dev,char *buf)
12625 + DEVICE_ATTR(dump_reg_2, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_2, 0);
12627 + static void dump_reg(void)
12629 + #ifdef __IS_HOST__
12630 + ifxusb_dump_registers(&ifxusb_hcd.core_if);
12632 + #ifdef __IS_DEVICE__
12633 + ifxusb_dump_registers(&ifxusb_pcd.core_if);
12636 + static ssize_t procfs_dump_reg_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12641 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12642 + static ssize_t sysfs_dump_reg_show( struct device *_dev, struct device_attribute *attr,char *buf)
12644 + static ssize_t sysfs_dump_reg_show( struct device *_dev,char *buf)
12650 + DEVICE_ATTR(dump_reg, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
12654 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12655 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12656 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12658 + #ifdef __IS_DUAL__
12659 + static void dump_spram_1(void)
12661 + ifxusb_dump_spram(&ifxusb_hcd_1.core_if);
12663 + static void dump_spram_2(void)
12665 + ifxusb_dump_spram(&ifxusb_hcd_2.core_if);
12668 + static ssize_t procfs_dump_spram_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12673 + static ssize_t procfs_dump_spram_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12678 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12679 + static ssize_t sysfs_dump_spram_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12681 + static ssize_t sysfs_dump_spram_show_1( struct device *_dev,char *buf)
12687 + DEVICE_ATTR(dump_spram_1, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_1, 0);
12689 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12690 + static ssize_t sysfs_dump_spram_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12692 + static ssize_t sysfs_dump_spram_show_2( struct device *_dev,char *buf)
12698 + DEVICE_ATTR(dump_spram_2, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_2, 0);
12700 + static void dump_spram(void)
12702 + #ifdef __IS_HOST__
12703 + ifxusb_dump_spram(&ifxusb_hcd.core_if);
12705 + #ifdef __IS_DEVICE__
12706 + ifxusb_dump_spram(&ifxusb_pcd.core_if);
12709 + static ssize_t procfs_dump_spram_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12714 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12715 + static ssize_t sysfs_dump_spram_show( struct device *_dev, struct device_attribute *attr,char *buf)
12717 + static ssize_t sysfs_dump_spram_show( struct device *_dev,char *buf)
12723 + DEVICE_ATTR(dump_spram, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
12725 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12726 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12727 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12729 + #ifdef __IS_HOST__
12730 + #ifdef __IS_DUAL__
12731 + static ssize_t procfs_dump_host_state_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12733 + ifxhcd_dump_state(&ifxusb_hcd_1);
12736 + static ssize_t procfs_dump_host_state_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12738 + ifxhcd_dump_state(&ifxusb_hcd_2);
12741 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12742 + static ssize_t sysfs_dump_host_state_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
12744 + static ssize_t sysfs_dump_host_state_show_1( struct device *_dev,char *buf)
12747 + ifxhcd_dump_state(&ifxusb_hcd_1);
12750 + DEVICE_ATTR(dump_host_state_1, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_1, 0);
12751 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12752 + static ssize_t sysfs_dump_host_state_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
12754 + static ssize_t sysfs_dump_host_state_show_2( struct device *_dev,char *buf)
12757 + ifxhcd_dump_state(&ifxusb_hcd_2);
12760 + DEVICE_ATTR(dump_host_state_2, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_2, 0);
12762 + static ssize_t procfs_dump_host_state_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
12764 + ifxhcd_dump_state(&ifxusb_hcd);
12767 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
12768 + static ssize_t sysfs_dump_host_state_show( struct device *_dev, struct device_attribute *attr,char *buf)
12770 + static ssize_t sysfs_dump_host_state_show( struct device *_dev,char *buf)
12773 + ifxhcd_dump_state(&ifxusb_hcd);
12776 + DEVICE_ATTR(dump_host_state, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show, 0);
12779 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12780 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12781 +/////////////////////////////////////////////////////////////////////////////////////////////////////
12783 + #endif //IS_HOST_
12785 +#endif //__ENABLE_DUMP__
12787 +//////////////////////////////////////////////////////////////////////////////////
12789 +static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw);
12790 +static void ifx_proc_delproc(char *funcname);
12792 +//////////////////////////////////////////////////////////////////////////////////
12795 + \brief This function create the sysfs and procfs entries
12796 + \param[in] _dev Pointer of device structure, if applied
12798 +void ifxusb_attr_create (void *_dev)
12802 + struct device *dev = (struct device *) _dev;
12804 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
12805 + error = ifx_proc_addproc("dbglevel", procfs_dbglevel_show, procfs_dbglevel_store);
12806 + error = device_create_file(dev, &dev_attr_dbglevel);
12808 + #ifdef __IS_DUAL__
12809 + error = ifx_proc_addproc("dump_params_1", procfs_dump_params_show_1, NULL);
12810 + error = ifx_proc_addproc("dump_params_2", procfs_dump_params_show_2, NULL);
12811 + error = device_create_file(dev, &dev_attr_dump_params_1);
12812 + error = device_create_file(dev, &dev_attr_dump_params_2);
12814 + error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL);
12815 + error = device_create_file(dev, &dev_attr_dump_params);
12818 + #ifdef __IS_DUAL__
12819 + error = ifx_proc_addproc("mode_1", procfs_mode_show_1, NULL);
12820 + error = ifx_proc_addproc("mode_2", procfs_mode_show_2, NULL);
12821 + error = device_create_file(dev, &dev_attr_mode_1);
12822 + error = device_create_file(dev, &dev_attr_mode_2);
12824 + error = ifx_proc_addproc("mode", procfs_mode_show, NULL);
12825 + error = device_create_file(dev, &dev_attr_mode);
12828 + #ifdef __IS_HOST__
12829 + #ifdef __IS_DUAL__
12830 + error = ifx_proc_addproc("buspower_1", procfs_buspower_show_1, procfs_buspower_store_1);
12831 + error = ifx_proc_addproc("buspower_2", procfs_buspower_show_2, procfs_buspower_store_2);
12832 + error = device_create_file(dev, &dev_attr_buspower_1);
12833 + error = device_create_file(dev, &dev_attr_buspower_2);
12835 + error = ifx_proc_addproc("buspower", procfs_buspower_show, procfs_buspower_store);
12836 + error = device_create_file(dev, &dev_attr_buspower);
12839 + #ifdef __IS_DUAL__
12840 + error = ifx_proc_addproc("bussuspend_1", procfs_bussuspend_show_1, NULL);
12841 + error = ifx_proc_addproc("bussuspend_2", procfs_bussuspend_show_2, NULL);
12842 + error = device_create_file(dev, &dev_attr_bussuspend_1);
12843 + error = device_create_file(dev, &dev_attr_bussuspend_2);
12845 + error = ifx_proc_addproc("bussuspend", procfs_bussuspend_show, NULL);
12846 + error = device_create_file(dev, &dev_attr_bussuspend);
12849 + #ifdef __IS_DUAL__
12850 + error = ifx_proc_addproc("busconnected_1", procfs_busconnected_show_1, NULL);
12851 + error = ifx_proc_addproc("busconnected_2", procfs_busconnected_show_2, NULL);
12852 + error = device_create_file(dev, &dev_attr_busconnected_1);
12853 + error = device_create_file(dev, &dev_attr_busconnected_2);
12855 + error = ifx_proc_addproc("busconnected", procfs_busconnected_show, NULL);
12856 + error = device_create_file(dev, &dev_attr_busconnected);
12859 + #ifdef __IS_DUAL__
12860 + error = ifx_proc_addproc("connectspeed_1", procfs_connectspeed_show_1, NULL);
12861 + error = ifx_proc_addproc("connectspeed_2", procfs_connectspeed_show_2, NULL);
12862 + error = device_create_file(dev, &dev_attr_connectspeed_1);
12863 + error = device_create_file(dev, &dev_attr_connectspeed_2);
12865 + error = ifx_proc_addproc("connectspeed", procfs_connectspeed_show, NULL);
12866 + error = device_create_file(dev, &dev_attr_connectspeed);
12870 + #ifdef __IS_DEVICE__
12871 + error = ifx_proc_addproc("devspeed", procfs_devspeed_show, NULL);
12872 + error = device_create_file(dev, &dev_attr_devspeed);
12873 + error = ifx_proc_addproc("enumspeed", procfs_enumspeed_show, NULL);
12874 + error = device_create_file(dev, &dev_attr_enumspeed);
12877 + //////////////////////////////////////////////////////
12878 + #ifdef __ENABLE_DUMP__
12879 + #ifdef __IS_DUAL__
12880 + error = ifx_proc_addproc("dump_reg_1", procfs_dump_reg_show_1, NULL);
12881 + error = ifx_proc_addproc("dump_reg_2", procfs_dump_reg_show_2, NULL);
12882 + error = device_create_file(dev, &dev_attr_dump_reg_1);
12883 + error = device_create_file(dev, &dev_attr_dump_reg_2);
12885 + error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL);
12886 + error = device_create_file(dev, &dev_attr_dump_reg);
12889 + #ifdef __IS_DUAL__
12890 + error = ifx_proc_addproc("dump_spram_1", procfs_dump_spram_show_1, NULL);
12891 + error = ifx_proc_addproc("dump_spram_2", procfs_dump_spram_show_2, NULL);
12892 + error = device_create_file(dev, &dev_attr_dump_spram_1);
12893 + error = device_create_file(dev, &dev_attr_dump_spram_2);
12895 + error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL);
12896 + error = device_create_file(dev, &dev_attr_dump_spram);
12899 + #ifdef __IS_HOST__
12900 + #ifdef __IS_DUAL__
12901 + error = ifx_proc_addproc("dump_host_state_1", procfs_dump_host_state_show_1, NULL);
12902 + error = ifx_proc_addproc("dump_host_state_2", procfs_dump_host_state_show_2, NULL);
12903 + error = device_create_file(dev, &dev_attr_dump_host_state_1);
12904 + error = device_create_file(dev, &dev_attr_dump_host_state_2);
12906 + error = ifx_proc_addproc("dump_host_state", procfs_dump_host_state_show, NULL);
12907 + error = device_create_file(dev, &dev_attr_dump_host_state);
12910 + #endif //__ENABLE_DUMP__
12911 + //////////////////////////////////////////////////////
12916 + \brief This function remove the sysfs and procfs entries
12917 + \param[in] _dev Pointer of device structure, if applied
12919 +void ifxusb_attr_remove (void *_dev)
12921 + struct device *dev = (struct device *) _dev;
12923 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
12924 + ifx_proc_delproc("dbglevel");
12925 + device_remove_file(dev, &dev_attr_dbglevel);
12927 + #ifdef __IS_DUAL__
12928 + ifx_proc_delproc("dump_params_1");
12929 + ifx_proc_delproc("dump_params_2");
12930 + device_remove_file(dev, &dev_attr_dump_params_1);
12931 + device_remove_file(dev, &dev_attr_dump_params_2);
12933 + ifx_proc_delproc("dump_params");
12934 + device_remove_file(dev, &dev_attr_dump_params);
12937 + #ifdef __IS_DUAL__
12938 + ifx_proc_delproc("mode_1");
12939 + ifx_proc_delproc("mode_2");
12940 + device_remove_file(dev, &dev_attr_mode_1);
12941 + device_remove_file(dev, &dev_attr_mode_2);
12943 + ifx_proc_delproc("mode");
12944 + device_remove_file(dev, &dev_attr_mode);
12947 + #ifdef __IS_HOST__
12948 + #ifdef __IS_DUAL__
12949 + ifx_proc_delproc("buspower_1");
12950 + ifx_proc_delproc("buspower_2");
12951 + device_remove_file(dev, &dev_attr_buspower_1);
12952 + device_remove_file(dev, &dev_attr_buspower_2);
12954 + ifx_proc_delproc("buspower");
12955 + device_remove_file(dev, &dev_attr_buspower);
12958 + #ifdef __IS_DUAL__
12959 + ifx_proc_delproc("bussuspend_1");
12960 + ifx_proc_delproc("bussuspend_2");
12961 + device_remove_file(dev, &dev_attr_bussuspend_1);
12962 + device_remove_file(dev, &dev_attr_bussuspend_2);
12964 + ifx_proc_delproc("bussuspend");
12965 + device_remove_file(dev, &dev_attr_bussuspend);
12968 + #ifdef __IS_DUAL__
12969 + ifx_proc_delproc("busconnected_1");
12970 + ifx_proc_delproc("busconnected_2");
12971 + device_remove_file(dev, &dev_attr_busconnected_1);
12972 + device_remove_file(dev, &dev_attr_busconnected_2);
12974 + ifx_proc_delproc("busconnected");
12975 + device_remove_file(dev, &dev_attr_busconnected);
12978 + #ifdef __IS_DUAL__
12979 + ifx_proc_delproc("connectspeed_1");
12980 + ifx_proc_delproc("connectspeed_2");
12981 + device_remove_file(dev, &dev_attr_connectspeed_1);
12982 + device_remove_file(dev, &dev_attr_connectspeed_2);
12984 + ifx_proc_delproc("connectspeed");
12985 + device_remove_file(dev, &dev_attr_connectspeed);
12989 + #ifdef __IS_DEVICE__
12990 + ifx_proc_delproc("devspeed");
12991 + device_remove_file(dev, &dev_attr_devspeed);
12992 + ifx_proc_delproc("enumspeed");
12993 + device_remove_file(dev, &dev_attr_enumspeed);
12996 + #ifdef __ENABLE_DUMP__
12997 + #ifdef __IS_DUAL__
12998 + ifx_proc_delproc("dump_reg_1");
12999 + ifx_proc_delproc("dump_reg_2");
13000 + device_remove_file(dev, &dev_attr_dump_reg_1);
13001 + device_remove_file(dev, &dev_attr_dump_reg_2);
13003 + ifx_proc_delproc("dump_reg");
13004 + device_remove_file(dev, &dev_attr_dump_reg);
13007 + #ifdef __IS_DUAL__
13008 + ifx_proc_delproc("dump_spram_1");
13009 + ifx_proc_delproc("dump_spram_2");
13010 + device_remove_file(dev, &dev_attr_dump_spram_1);
13011 + device_remove_file(dev, &dev_attr_dump_spram_2);
13013 + ifx_proc_delproc("dump_spram");
13014 + device_remove_file(dev, &dev_attr_dump_spram);
13017 + #ifdef __IS_HOST__
13018 + #ifdef __IS_DUAL__
13019 + ifx_proc_delproc("dump_host_state_1");
13020 + ifx_proc_delproc("dump_host_state_2");
13021 + device_remove_file(dev, &dev_attr_dump_host_state_1);
13022 + device_remove_file(dev, &dev_attr_dump_host_state_2);
13024 + ifx_proc_delproc("dump_host_state");
13025 + device_remove_file(dev, &dev_attr_dump_host_state);
13028 + #endif //__ENABLE_DUMP__
13029 + /* AVM/WK fix: del IFXUSB root dir*/
13030 + ifx_proc_delproc(NULL);
13033 +static struct proc_dir_entry * proc_ifx_root = NULL;
13035 +/* initialize the proc file system and make a dir named /proc/[name] */
13036 +static void ifx_proc_init(void)
13038 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13039 + proc_ifx_root = proc_mkdir(ifxusb_driver_name, (void *)0);
13040 + if (!proc_ifx_root){
13041 + IFX_PRINT("%s proc initialization failed! \n", ifxusb_driver_name);
13046 +/* proc file system add function for debugging. */
13047 +static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw)
13049 + struct proc_dir_entry *pe;
13050 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13051 + if (!proc_ifx_root)
13054 + if (hookfuncw == NULL)
13056 + pe = create_proc_read_entry(funcname, S_IRUGO, proc_ifx_root, hookfuncr, NULL);
13059 + IFX_PRINT("ERROR in creating read proc entry (%s)! \n", funcname);
13065 + pe = create_proc_entry(funcname, S_IRUGO | S_IWUGO, proc_ifx_root);
13068 + pe->read_proc = hookfuncr;
13069 + pe->write_proc = hookfuncw;
13073 + IFX_PRINT("ERROR in creating proc entry (%s)! \n", funcname);
13081 +/* proc file system del function for removing module. */
13082 +static void ifx_proc_delproc(char *funcname)
13085 + if (funcname != NULL) {
13086 + remove_proc_entry(funcname, proc_ifx_root);
13088 + remove_proc_entry(ifxusb_driver_name, NULL);
13089 + proc_ifx_root = NULL;
13093 +static void ifxusb_dump_params(ifxusb_core_if_t *_core_if)
13095 + ifxusb_params_t *params=&_core_if->params;
13097 + #ifdef __IS_HOST__
13098 + IFX_PRINT("IFXUSB Dump Parameters ( Host Mode) \n");
13099 + #endif //__IS_HOST__
13100 + #ifdef __IS_DEVICE__
13101 + IFX_PRINT("IFXUSB Dump Parameters ( Device Mode) \n");
13102 + #endif //__IS_DEVICE__
13104 + #ifdef __DESC_DMA__
13105 + IFX_PRINT("DMA: Hermes DMA\n");
13107 + IFX_PRINT("DMA: Non-Desc DMA\n");
13109 + IFX_PRINT(" Burst size: %d\n",params->dma_burst_size);
13111 + if (params->speed==1)
13112 + IFX_PRINT("Full Speed only\n");
13113 + else if(params->speed==0)
13114 + IFX_PRINT("Full/Hign Speed\n");
13116 + IFX_PRINT("Unkonwn setting (%d) for Speed\n",params->speed);
13118 + IFX_PRINT("Total Data FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
13119 + params->data_fifo_size,params->data_fifo_size,
13120 + params->data_fifo_size*4, params->data_fifo_size*4
13123 + #ifdef __IS_DEVICE__
13124 + IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
13125 + params->rx_fifo_size,params->rx_fifo_size,
13126 + params->rx_fifo_size*4, params->rx_fifo_size*4
13130 + for(i=0;i<MAX_EPS_CHANNELS;i++)
13132 + IFX_PRINT("Tx FIFO #%d size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",i,
13133 + params->tx_fifo_size[i],params->tx_fifo_size[i],
13134 + params->tx_fifo_size[i]*4, params->tx_fifo_size[i]*4
13138 + #ifdef __DED_FIFO__
13139 + IFX_PRINT("Treshold : %s Rx:%d Tx:%d \n",
13140 + (params->thr_ctl)?"On":"Off",params->tx_thr_length,params->rx_thr_length);
13142 + #else //__IS_HOST__
13143 + IFX_PRINT("Host Channels: %d\n",params->host_channels);
13145 + IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
13146 + params->data_fifo_size,params->data_fifo_size,
13147 + params->data_fifo_size*4, params->data_fifo_size*4
13150 + IFX_PRINT("NP Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
13151 + params->nperio_tx_fifo_size,params->nperio_tx_fifo_size,
13152 + params->nperio_tx_fifo_size*4, params->nperio_tx_fifo_size*4
13155 + IFX_PRINT(" P Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
13156 + params->perio_tx_fifo_size,params->perio_tx_fifo_size,
13157 + params->perio_tx_fifo_size*4, params->perio_tx_fifo_size*4
13159 + #endif //__IS_HOST__
13161 + IFX_PRINT("Max Transfer size: %d(0x%06X) Bytes\n",
13162 + params->max_transfer_size,params->max_transfer_size
13164 + IFX_PRINT("Max Packet Count: %d(0x%06X)\n",
13165 + params->max_packet_count,params->max_packet_count
13168 + IFX_PRINT("PHY UTMI Width: %d\n",params->phy_utmi_width);
13170 + IFX_PRINT("Turn Around Time: HS:%d FS:%d\n",params->turn_around_time_hs,params->turn_around_time_fs);
13171 + IFX_PRINT("Timeout Calibration: HS:%d FS:%d\n",params->timeout_cal_hs,params->timeout_cal_fs);
13174 + IFX_PRINT("==================================================\n");
13175 + IFX_PRINT("End of Parameters Dump\n");
13176 + IFX_PRINT("==================================================\n");
13181 +++ b/drivers/usb/ifxhcd/ifxusb_driver.c
13183 +/*****************************************************************************
13184 + ** FILE NAME : ifxusb_driver.c
13185 + ** PROJECT : IFX USB sub-system V3
13186 + ** MODULES : IFX USB sub-system Host and Device driver
13187 + ** SRC VERSION : 1.0
13188 + ** DATE : 1/Jan/2009
13189 + ** AUTHOR : Chen, Howard
13190 + ** DESCRIPTION : The provides the initialization and cleanup entry
13191 + ** points for the IFX USB driver. This module can be
13192 + ** dynamically loaded with insmod command or built-in
13193 + ** with kernel. When loaded or executed the ifxusb_driver_init
13194 + ** function is called. When the module is removed (using rmmod),
13195 + ** the ifxusb_driver_cleanup function is called.
13196 + *****************************************************************************/
13199 + \file ifxusb_driver.c
13200 + \brief This file contains the loading/unloading interface to the Linux driver.
13203 +#include <linux/version.h>
13204 +#include "ifxusb_version.h"
13206 +#include <linux/kernel.h>
13207 +#include <linux/module.h>
13208 +#include <linux/moduleparam.h>
13209 +#include <linux/init.h>
13211 +#include <linux/device.h>
13212 +#include <linux/platform_device.h>
13214 +#include <linux/errno.h>
13215 +#include <linux/types.h>
13216 +#include <linux/stat.h> /* permission constants */
13217 +#include <linux/gpio.h>
13218 +#include <lantiq_soc.h>
13220 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
13221 + #include <linux/irq.h>
13224 +#include <asm/io.h>
13226 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
13227 + #include <asm/irq.h>
13230 +#include "ifxusb_plat.h"
13232 +#include "ifxusb_cif.h"
13234 +#ifdef __IS_HOST__
13235 + #include "ifxhcd.h"
13237 + #define USB_DRIVER_DESC "IFX USB HCD driver"
13238 + const char ifxusb_driver_name[] = "ifxusb_hcd";
13240 + #ifdef __IS_DUAL__
13241 + ifxhcd_hcd_t ifxusb_hcd_1;
13242 + ifxhcd_hcd_t ifxusb_hcd_2;
13243 + const char ifxusb_hcd_name_1[] = "ifxusb_hcd_1";
13244 + const char ifxusb_hcd_name_2[] = "ifxusb_hcd_2";
13246 + ifxhcd_hcd_t ifxusb_hcd;
13247 + const char ifxusb_hcd_name[] = "ifxusb_hcd";
13250 + #if defined(__DO_OC_INT__)
13251 + static unsigned int oc_int_installed=0;
13252 + static ifxhcd_hcd_t *oc_int_id=NULL;
13256 +#ifdef __IS_DEVICE__
13257 + #include "ifxpcd.h"
13259 + #define USB_DRIVER_DESC "IFX USB PCD driver"
13260 + const char ifxusb_driver_name[] = "ifxusb_pcd";
13262 + ifxpcd_pcd_t ifxusb_pcd;
13263 + const char ifxusb_pcd_name[] = "ifxusb_pcd";
13266 +/* Global Debug Level Mask. */
13267 +#ifdef __IS_HOST__
13268 + uint32_t h_dbg_lvl = 0x00;
13271 +#ifdef __IS_DEVICE__
13272 + uint32_t d_dbg_lvl = 0x00;
13275 +ifxusb_params_t ifxusb_module_params;
13277 +static void parse_parms(void);
13280 +#include <lantiq_irq.h>
13281 +#define IFX_USB0_IR (INT_NUM_IM1_IRL0 + 22)
13282 +#define IFX_USB1_IR (INT_NUM_IM2_IRL0 + 19)
13285 + \brief This function is called when a driver is unregistered. This happens when
13286 + the rmmod command is executed. The device may or may not be electrically
13287 + present. If it is present, the driver stops device processing. Any resources
13288 + used on behalf of this device are freed.
13290 +static int ifxusb_driver_remove(struct platform_device *_dev)
13292 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13293 + #ifdef __IS_HOST__
13294 + #if defined(__DO_OC_INT__)
13295 + #if defined(__DO_OC_INT_ENABLE__)
13296 + ifxusb_oc_int_off();
13299 + if(oc_int_installed && oc_int_id)
13300 + free_irq((unsigned int)IFXUSB_OC_IRQ, oc_int_id );
13301 + oc_int_installed=0;
13305 + #if defined(__IS_DUAL__)
13306 + ifxhcd_remove(&ifxusb_hcd_1);
13307 + ifxusb_core_if_remove(&ifxusb_hcd_1.core_if );
13308 + ifxhcd_remove(&ifxusb_hcd_2);
13309 + ifxusb_core_if_remove(&ifxusb_hcd_2.core_if );
13311 + ifxhcd_remove(&ifxusb_hcd);
13312 + ifxusb_core_if_remove(&ifxusb_hcd.core_if );
13316 + #ifdef __IS_DEVICE__
13318 + ifxusb_core_if_remove(&ifxusb_pcd.core_if );
13321 + /* Remove the device attributes */
13323 + ifxusb_attr_remove(&_dev->dev);
13329 +/* Function to setup the structures to control one usb core running as host*/
13330 +#ifdef __IS_HOST__
13332 + \brief inlined by ifxusb_driver_probe(), handling host mode probing. Run at each host core.
13334 + static inline int ifxusb_driver_probe_h(ifxhcd_hcd_t *_hcd,
13336 + uint32_t _iobase,
13337 + uint32_t _fifomem,
13338 + uint32_t _fifodbg
13343 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13345 +#ifdef __DEV_NEW__
13346 + ifxusb_power_off (&_hcd->core_if);
13347 + ifxusb_phy_power_off (&_hcd->core_if); // Test
13349 +#endif //__DEV_NEW__
13350 + ifxusb_power_on (&_hcd->core_if);
13352 + ifxusb_phy_power_on (&_hcd->core_if); // Test
13354 + ifxusb_hard_reset(&_hcd->core_if);
13355 + retval =ifxusb_core_if_init(&_hcd->core_if,
13363 + ifxusb_host_core_init(&_hcd->core_if,&ifxusb_module_params);
13365 + ifxusb_disable_global_interrupts( &_hcd->core_if);
13367 + /* The driver is now initialized and need to be registered into Linux USB sub-system */
13369 + retval = ifxhcd_init(_hcd); // hook the hcd into usb ss
13373 + IFX_ERROR("_hcd_init failed\n");
13377 + //ifxusb_enable_global_interrupts( _hcd->core_if ); // this should be done at hcd_start , including hcd_interrupt
13380 +#endif //__IS_HOST__
13382 +#ifdef __IS_DEVICE__
13384 + \brief inlined by ifxusb_driver_probe(), handling device mode probing.
13386 + static inline int ifxusb_driver_probe_d(ifxpcd_pcd_t *_pcd,
13388 + uint32_t _iobase,
13389 + uint32_t _fifomem,
13390 + uint32_t _fifodbg
13395 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13396 +#ifdef __DEV_NEW__
13397 + ifxusb_power_off (&_pcd->core_if);
13398 + ifxusb_phy_power_off (&_pcd->core_if); // Test
13400 +#endif // __DEV_NEW__
13401 + ifxusb_power_on (&_pcd->core_if);
13403 + ifxusb_phy_power_on (&_pcd->core_if); // Test
13405 + ifxusb_hard_reset(&_pcd->core_if);
13406 + retval =ifxusb_core_if_init(&_pcd->core_if,
13414 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13415 + ifxusb_dev_core_init(&_pcd->core_if,&ifxusb_module_params);
13417 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13418 + ifxusb_disable_global_interrupts( &_pcd->core_if);
13420 + /* The driver is now initialized and need to be registered into
13421 + Linux USB Gadget sub-system
13423 + retval = ifxpcd_init();
13424 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13428 + IFX_ERROR("_pcd_init failed\n");
13431 + //ifxusb_enable_global_interrupts( _pcd->core_if ); // this should be done at gadget bind or start
13434 +#endif //__IS_DEVICE__
13439 + \brief This function is called by module management in 2.6 kernel or by ifxusb_driver_init with 2.4 kernel
13440 + It is to probe and setup IFXUSB core(s).
13442 +static int ifxusb_driver_probe(struct platform_device *_dev)
13445 + int *pins = _dev->dev.platform_data;
13446 + if (ltq_is_vr9()) {
13447 + gpio_request(6, "id1");
13448 + gpio_request(9, "id2");
13449 + gpio_direction_input(6);
13450 + gpio_direction_input(9);
13454 + gpio_request(pins[0], "vbus1");
13455 + gpio_direction_output(pins[0], 1);
13457 + if (pins[1] && ltq_is_vr9()) {
13458 + gpio_request(pins[1], "vbus2");
13459 + gpio_direction_output(pins[1], 1);
13462 + // Parsing and store the parameters
13463 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13466 + #ifdef __IS_HOST__
13467 + #if defined(__IS_DUAL__)
13468 + memset(&ifxusb_hcd_1, 0, sizeof(ifxhcd_hcd_t));
13469 + memset(&ifxusb_hcd_2, 0, sizeof(ifxhcd_hcd_t));
13471 + ifxusb_hcd_1.core_if.core_no=0;
13472 + ifxusb_hcd_2.core_if.core_no=1;
13473 + ifxusb_hcd_1.core_if.core_name=(char *)ifxusb_hcd_name_1;
13474 + ifxusb_hcd_2.core_if.core_name=(char *)ifxusb_hcd_name_2;
13476 + ifxusb_hcd_1.dev=&_dev->dev;
13477 + ifxusb_hcd_2.dev=&_dev->dev;
13479 + retval = ifxusb_driver_probe_h(&ifxusb_hcd_1,
13481 + IFXUSB1_IOMEM_BASE,
13482 + IFXUSB1_FIFOMEM_BASE,
13483 + IFXUSB1_FIFODBG_BASE
13486 + goto ifxusb_driver_probe_fail;
13488 + retval = ifxusb_driver_probe_h(&ifxusb_hcd_2,
13490 + IFXUSB2_IOMEM_BASE,
13491 + IFXUSB2_FIFOMEM_BASE,
13492 + IFXUSB2_FIFODBG_BASE
13495 + goto ifxusb_driver_probe_fail;
13497 + #elif defined(__IS_FIRST__)
13498 + memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
13500 + ifxusb_hcd.core_if.core_no=0;
13501 + ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
13503 + ifxusb_hcd.dev=&_dev->dev;
13505 + retval = ifxusb_driver_probe_h(&ifxusb_hcd,
13507 + IFXUSB1_IOMEM_BASE,
13508 + IFXUSB1_FIFOMEM_BASE,
13509 + IFXUSB1_FIFODBG_BASE
13512 + goto ifxusb_driver_probe_fail;
13514 + #elif defined(__IS_SECOND__)
13515 + memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
13517 + ifxusb_hcd.core_if.core_no=1;
13518 + ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
13520 + ifxusb_hcd.dev=&_dev->dev;
13522 + retval = ifxusb_driver_probe_h(&ifxusb_hcd,
13524 + IFXUSB2_IOMEM_BASE,
13525 + IFXUSB2_FIFOMEM_BASE,
13526 + IFXUSB2_FIFODBG_BASE
13529 + goto ifxusb_driver_probe_fail;
13532 + memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
13534 + ifxusb_hcd.core_if.core_no=0;
13535 + ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
13537 + ifxusb_hcd.dev=&_dev->dev;
13539 + retval = ifxusb_driver_probe_h(&ifxusb_hcd,
13541 + IFXUSB_IOMEM_BASE,
13542 + IFXUSB_FIFOMEM_BASE,
13543 + IFXUSB_FIFODBG_BASE
13546 + goto ifxusb_driver_probe_fail;
13549 + #if defined(__DO_OC_INT__)
13550 + IFXUSB_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for irq%d\n", IFXUSB_OC_IRQ);
13551 + #if defined(__IS_DUAL__)
13552 + request_irq((unsigned int)IFXUSB_OC_IRQ, &ifx_hcd_oc_irq,
13553 +// SA_INTERRUPT|SA_SHIRQ, "ifxusb_oc", (void *)&ifxusb_hcd_1);
13554 + IRQF_DISABLED | IRQF_SHARED, "ifxusb_oc", (void *)&ifxusb_hcd_1);
13555 + oc_int_id=&ifxusb_hcd_1;
13557 + request_irq((unsigned int)IFXUSB_OC_IRQ, &ifx_hcd_oc_irq,
13558 +// SA_INTERRUPT|SA_SHIRQ, "ifxusb_oc", (void *)&ifxusb_hcd);
13559 + IRQF_DISABLED | IRQF_SHARED, "ifxusb_oc", (void *)&ifxusb_hcd);
13560 + oc_int_id=&ifxusb_hcd;
13562 + oc_int_installed=1;
13564 + #if defined(__DO_OC_INT_ENABLE__)
13565 + ifxusb_oc_int_on();
13571 + #ifdef __IS_DEVICE__
13572 + memset(&ifxusb_pcd, 0, sizeof(ifxpcd_pcd_t));
13573 + ifxusb_pcd.core_if.core_name=(char *)&ifxusb_pcd_name[0];
13575 + ifxusb_pcd.dev=&_dev->dev;
13577 + #if defined(__IS_FIRST__)
13578 + ifxusb_pcd.core_if.core_no=0;
13579 + retval = ifxusb_driver_probe_d(&ifxusb_pcd,
13581 + IFXUSB1_IOMEM_BASE,
13582 + IFXUSB1_FIFOMEM_BASE,
13583 + IFXUSB1_FIFODBG_BASE
13585 + #elif defined(__IS_SECOND__)
13586 + ifxusb_pcd.core_if.core_no=1;
13587 + retval = ifxusb_driver_probe_d(&ifxusb_pcd,
13589 + IFXUSB2_IOMEM_BASE,
13590 + IFXUSB2_FIFOMEM_BASE,
13591 + IFXUSB2_FIFODBG_BASE
13594 + ifxusb_pcd.core_if.core_no=0;
13595 + retval = ifxusb_driver_probe_d(&ifxusb_pcd,
13597 + IFXUSB_IOMEM_BASE,
13598 + IFXUSB_FIFOMEM_BASE,
13599 + IFXUSB_FIFODBG_BASE
13603 + goto ifxusb_driver_probe_fail;
13606 + ifxusb_attr_create(&_dev->dev);
13610 +ifxusb_driver_probe_fail:
13611 + ifxusb_driver_remove(_dev);
13618 + \brief This function is called when the ifxusb_driver is installed with the insmod command.
13622 +static struct platform_driver ifxusb_driver = {
13624 + .name = ifxusb_driver_name,
13625 + .owner = THIS_MODULE,
13627 + .probe = ifxusb_driver_probe,
13628 + .remove = ifxusb_driver_remove,
13631 +int __init ifxusb_driver_init(void)
13635 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13636 + IFX_PRINT("%s: version %s\n", ifxusb_driver_name, IFXUSB_VERSION);
13638 + retval = platform_driver_register(&ifxusb_driver);
13640 + if (retval < 0) {
13641 + IFX_ERROR("%s retval=%d\n", __func__, retval);
13648 + int __init ifxusb_driver_init(void)
13651 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13652 + IFX_PRINT("%s: version %s\n", ifxusb_driver_name, IFXUSB_VERSION);
13653 + retval = ifxusb_driver_probe();
13655 + if (retval < 0) {
13656 + IFX_ERROR("%s retval=%d\n", __func__, retval);
13664 +module_init(ifxusb_driver_init);
13668 + \brief This function is called when the driver is removed from the kernel
13669 + with the rmmod command. The driver unregisters itself with its bus
13673 +void __exit ifxusb_driver_cleanup(void)
13675 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13677 + platform_driver_unregister(&ifxusb_driver);
13679 + IFX_PRINT("%s module removed\n", ifxusb_driver_name);
13682 + void __exit ifxusb_driver_cleanup(void)
13684 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13685 + ifxusb_driver_remove();
13686 + IFX_PRINT("%s module removed\n", ifxusb_driver_name);
13689 +module_exit(ifxusb_driver_cleanup);
13693 +MODULE_DESCRIPTION(USB_DRIVER_DESC);
13694 +MODULE_AUTHOR("Infineon");
13695 +MODULE_LICENSE("GPL");
13699 +// Parameters set when loaded
13700 +//static long dbg_lvl =0xFFFFFFFF;
13701 +static long dbg_lvl =0;
13702 +static short dma_burst_size =-1;
13703 +static short speed =-1;
13704 +static long data_fifo_size =-1;
13705 +#ifdef __IS_DEVICE__
13706 + static long rx_fifo_size =-1;
13707 + #ifdef __DED_FIFO__
13708 + static long tx_fifo_size_00 =-1;
13709 + static long tx_fifo_size_01 =-1;
13710 + static long tx_fifo_size_02 =-1;
13711 + static long tx_fifo_size_03 =-1;
13712 + static long tx_fifo_size_04 =-1;
13713 + static long tx_fifo_size_05 =-1;
13714 + static long tx_fifo_size_06 =-1;
13715 + static long tx_fifo_size_07 =-1;
13716 + static long tx_fifo_size_08 =-1;
13717 + static long tx_fifo_size_09 =-1;
13718 + static long tx_fifo_size_10 =-1;
13719 + static long tx_fifo_size_11 =-1;
13720 + static long tx_fifo_size_12 =-1;
13721 + static long tx_fifo_size_13 =-1;
13722 + static long tx_fifo_size_14 =-1;
13723 + static long tx_fifo_size_15 =-1;
13724 + static short thr_ctl=-1;
13725 + static long tx_thr_length =-1;
13726 + static long rx_thr_length =-1;
13728 + static long nperio_tx_fifo_size =-1;
13729 + static long perio_tx_fifo_size_01 =-1;
13730 + static long perio_tx_fifo_size_02 =-1;
13731 + static long perio_tx_fifo_size_03 =-1;
13732 + static long perio_tx_fifo_size_04 =-1;
13733 + static long perio_tx_fifo_size_05 =-1;
13734 + static long perio_tx_fifo_size_06 =-1;
13735 + static long perio_tx_fifo_size_07 =-1;
13736 + static long perio_tx_fifo_size_08 =-1;
13737 + static long perio_tx_fifo_size_09 =-1;
13738 + static long perio_tx_fifo_size_10 =-1;
13739 + static long perio_tx_fifo_size_11 =-1;
13740 + static long perio_tx_fifo_size_12 =-1;
13741 + static long perio_tx_fifo_size_13 =-1;
13742 + static long perio_tx_fifo_size_14 =-1;
13743 + static long perio_tx_fifo_size_15 =-1;
13745 + static short dev_endpoints =-1;
13748 +#ifdef __IS_HOST__
13749 + static long rx_fifo_size =-1;
13750 + static long nperio_tx_fifo_size =-1;
13751 + static long perio_tx_fifo_size =-1;
13752 + static short host_channels =-1;
13755 +static long max_transfer_size =-1;
13756 +static long max_packet_count =-1;
13757 +static long phy_utmi_width =-1;
13758 +static long turn_around_time_hs =-1;
13759 +static long turn_around_time_fs =-1;
13760 +static long timeout_cal_hs =-1;
13761 +static long timeout_cal_fs =-1;
13764 + \brief Parsing the parameters taken when module load
13766 +static void parse_parms(void)
13769 + IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
13770 + #ifdef __IS_HOST__
13771 + h_dbg_lvl=dbg_lvl;
13773 + #ifdef __IS_DEVICE__
13774 + d_dbg_lvl=dbg_lvl;
13777 + switch(dma_burst_size)
13784 + ifxusb_module_params.dma_burst_size=dma_burst_size;
13787 + ifxusb_module_params.dma_burst_size=default_param_dma_burst_size;
13790 + if(speed==0 || speed==1)
13791 + ifxusb_module_params.speed=speed;
13793 + ifxusb_module_params.speed=default_param_speed;
13795 + if(max_transfer_size>=2048 && max_transfer_size<=65535)
13796 + ifxusb_module_params.max_transfer_size=max_transfer_size;
13798 + ifxusb_module_params.max_transfer_size=default_param_max_transfer_size;
13800 + if(max_packet_count>=15 && max_packet_count<=511)
13801 + ifxusb_module_params.max_packet_count=max_packet_count;
13803 + ifxusb_module_params.max_packet_count=default_param_max_packet_count;
13805 + switch(phy_utmi_width)
13809 + ifxusb_module_params.phy_utmi_width=phy_utmi_width;
13812 + ifxusb_module_params.phy_utmi_width=default_param_phy_utmi_width;
13815 + if(turn_around_time_hs>=0 && turn_around_time_hs<=7)
13816 + ifxusb_module_params.turn_around_time_hs=turn_around_time_hs;
13818 + ifxusb_module_params.turn_around_time_hs=default_param_turn_around_time_hs;
13820 + if(turn_around_time_fs>=0 && turn_around_time_fs<=7)
13821 + ifxusb_module_params.turn_around_time_fs=turn_around_time_fs;
13823 + ifxusb_module_params.turn_around_time_fs=default_param_turn_around_time_fs;
13825 + if(timeout_cal_hs>=0 && timeout_cal_hs<=7)
13826 + ifxusb_module_params.timeout_cal_hs=timeout_cal_hs;
13828 + ifxusb_module_params.timeout_cal_hs=default_param_timeout_cal_hs;
13830 + if(timeout_cal_fs>=0 && timeout_cal_fs<=7)
13831 + ifxusb_module_params.timeout_cal_fs=timeout_cal_fs;
13833 + ifxusb_module_params.timeout_cal_fs=default_param_timeout_cal_fs;
13835 + if(data_fifo_size>=32 && data_fifo_size<=32768)
13836 + ifxusb_module_params.data_fifo_size=data_fifo_size;
13838 + ifxusb_module_params.data_fifo_size=default_param_data_fifo_size;
13840 + #ifdef __IS_HOST__
13841 + if(host_channels>=1 && host_channels<=16)
13842 + ifxusb_module_params.host_channels=host_channels;
13844 + ifxusb_module_params.host_channels=default_param_host_channels;
13846 + if(rx_fifo_size>=16 && rx_fifo_size<=32768)
13847 + ifxusb_module_params.rx_fifo_size=rx_fifo_size;
13849 + ifxusb_module_params.rx_fifo_size=default_param_rx_fifo_size;
13851 + if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
13852 + ifxusb_module_params.nperio_tx_fifo_size=nperio_tx_fifo_size;
13854 + ifxusb_module_params.nperio_tx_fifo_size=default_param_nperio_tx_fifo_size;
13856 + if(perio_tx_fifo_size>=16 && perio_tx_fifo_size<=32768)
13857 + ifxusb_module_params.perio_tx_fifo_size=perio_tx_fifo_size;
13859 + ifxusb_module_params.perio_tx_fifo_size=default_param_perio_tx_fifo_size;
13860 + #endif //__IS_HOST__
13862 + #ifdef __IS_DEVICE__
13863 + if(rx_fifo_size>=16 && rx_fifo_size<=32768)
13864 + ifxusb_module_params.rx_fifo_size=rx_fifo_size;
13866 + ifxusb_module_params.rx_fifo_size=default_param_rx_fifo_size;
13867 + #ifdef __DED_FIFO__
13868 + if(tx_fifo_size_00>=16 && tx_fifo_size_00<=32768)
13869 + ifxusb_module_params.tx_fifo_size[ 0]=tx_fifo_size_00;
13871 + ifxusb_module_params.tx_fifo_size[ 0]=default_param_tx_fifo_size_00;
13872 + if(tx_fifo_size_01>=0 && tx_fifo_size_01<=32768)
13873 + ifxusb_module_params.tx_fifo_size[ 1]=tx_fifo_size_01;
13875 + ifxusb_module_params.tx_fifo_size[ 1]=default_param_tx_fifo_size_01;
13876 + if(tx_fifo_size_02>=0 && tx_fifo_size_02<=32768)
13877 + ifxusb_module_params.tx_fifo_size[ 2]=tx_fifo_size_02;
13879 + ifxusb_module_params.tx_fifo_size[ 2]=default_param_tx_fifo_size_02;
13880 + if(tx_fifo_size_03>=0 && tx_fifo_size_03<=32768)
13881 + ifxusb_module_params.tx_fifo_size[ 3]=tx_fifo_size_03;
13883 + ifxusb_module_params.tx_fifo_size[ 3]=default_param_tx_fifo_size_03;
13884 + if(tx_fifo_size_04>=0 && tx_fifo_size_04<=32768)
13885 + ifxusb_module_params.tx_fifo_size[ 4]=tx_fifo_size_04;
13887 + ifxusb_module_params.tx_fifo_size[ 4]=default_param_tx_fifo_size_04;
13888 + if(tx_fifo_size_05>=0 && tx_fifo_size_05<=32768)
13889 + ifxusb_module_params.tx_fifo_size[ 5]=tx_fifo_size_05;
13891 + ifxusb_module_params.tx_fifo_size[ 5]=default_param_tx_fifo_size_05;
13892 + if(tx_fifo_size_06>=0 && tx_fifo_size_06<=32768)
13893 + ifxusb_module_params.tx_fifo_size[ 6]=tx_fifo_size_06;
13895 + ifxusb_module_params.tx_fifo_size[ 6]=default_param_tx_fifo_size_06;
13896 + if(tx_fifo_size_07>=0 && tx_fifo_size_07<=32768)
13897 + ifxusb_module_params.tx_fifo_size[ 7]=tx_fifo_size_07;
13899 + ifxusb_module_params.tx_fifo_size[ 7]=default_param_tx_fifo_size_07;
13900 + if(tx_fifo_size_08>=0 && tx_fifo_size_08<=32768)
13901 + ifxusb_module_params.tx_fifo_size[ 8]=tx_fifo_size_08;
13903 + ifxusb_module_params.tx_fifo_size[ 8]=default_param_tx_fifo_size_08;
13904 + if(tx_fifo_size_09>=0 && tx_fifo_size_09<=32768)
13905 + ifxusb_module_params.tx_fifo_size[ 9]=tx_fifo_size_09;
13907 + ifxusb_module_params.tx_fifo_size[ 9]=default_param_tx_fifo_size_09;
13908 + if(tx_fifo_size_10>=0 && tx_fifo_size_10<=32768)
13909 + ifxusb_module_params.tx_fifo_size[10]=tx_fifo_size_10;
13911 + ifxusb_module_params.tx_fifo_size[10]=default_param_tx_fifo_size_10;
13912 + if(tx_fifo_size_11>=0 && tx_fifo_size_11<=32768)
13913 + ifxusb_module_params.tx_fifo_size[11]=tx_fifo_size_11;
13915 + ifxusb_module_params.tx_fifo_size[11]=default_param_tx_fifo_size_11;
13916 + if(tx_fifo_size_12>=0 && tx_fifo_size_12<=32768)
13917 + ifxusb_module_params.tx_fifo_size[12]=tx_fifo_size_12;
13919 + ifxusb_module_params.tx_fifo_size[12]=default_param_tx_fifo_size_12;
13920 + if(tx_fifo_size_13>=0 && tx_fifo_size_13<=32768)
13921 + ifxusb_module_params.tx_fifo_size[13]=tx_fifo_size_13;
13923 + ifxusb_module_params.tx_fifo_size[13]=default_param_tx_fifo_size_13;
13924 + if(tx_fifo_size_14>=0 && tx_fifo_size_14<=32768)
13925 + ifxusb_module_params.tx_fifo_size[14]=tx_fifo_size_14;
13927 + ifxusb_module_params.tx_fifo_size[14]=default_param_tx_fifo_size_14;
13928 + if(tx_fifo_size_15>=0 && tx_fifo_size_15<=32768)
13929 + ifxusb_module_params.tx_fifo_size[15]=tx_fifo_size_15;
13931 + ifxusb_module_params.tx_fifo_size[15]=default_param_tx_fifo_size_15;
13932 + if(thr_ctl==0 || thr_ctl==1)
13933 + ifxusb_module_params.thr_ctl=thr_ctl;
13935 + ifxusb_module_params.thr_ctl=default_param_thr_ctl;
13936 + if(tx_thr_length>=16 && tx_thr_length<=511)
13937 + ifxusb_module_params.tx_thr_length=tx_thr_length;
13939 + ifxusb_module_params.tx_thr_length=default_param_tx_thr_length;
13940 + if(rx_thr_length>=16 && rx_thr_length<=511)
13941 + ifxusb_module_params.rx_thr_length=rx_thr_length;
13943 + ifxusb_module_params.rx_thr_length=default_param_rx_thr_length;
13944 + #else //__DED_FIFO__
13945 + if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
13946 + ifxusb_module_params.tx_fifo_size[ 0]=nperio_tx_fifo_size;
13948 + ifxusb_module_params.tx_fifo_size[ 0]=default_param_nperio_tx_fifo_size;
13949 + if(perio_tx_fifo_size_01>=0 && perio_tx_fifo_size_01<=32768)
13950 + ifxusb_module_params.tx_fifo_size[ 1]=perio_tx_fifo_size_01;
13952 + ifxusb_module_params.tx_fifo_size[ 1]=default_param_perio_tx_fifo_size_01;
13953 + if(perio_tx_fifo_size_02>=0 && perio_tx_fifo_size_02<=32768)
13954 + ifxusb_module_params.tx_fifo_size[ 2]=perio_tx_fifo_size_02;
13956 + ifxusb_module_params.tx_fifo_size[ 2]=default_param_perio_tx_fifo_size_02;
13957 + if(perio_tx_fifo_size_03>=0 && perio_tx_fifo_size_03<=32768)
13958 + ifxusb_module_params.tx_fifo_size[ 3]=perio_tx_fifo_size_03;
13960 + ifxusb_module_params.tx_fifo_size[ 3]=default_param_perio_tx_fifo_size_03;
13961 + if(perio_tx_fifo_size_04>=0 && perio_tx_fifo_size_04<=32768)
13962 + ifxusb_module_params.tx_fifo_size[ 4]=perio_tx_fifo_size_04;
13964 + ifxusb_module_params.tx_fifo_size[ 4]=default_param_perio_tx_fifo_size_04;
13965 + if(perio_tx_fifo_size_05>=0 && perio_tx_fifo_size_05<=32768)
13966 + ifxusb_module_params.tx_fifo_size[ 5]=perio_tx_fifo_size_05;
13968 + ifxusb_module_params.tx_fifo_size[ 5]=default_param_perio_tx_fifo_size_05;
13969 + if(perio_tx_fifo_size_06>=0 && perio_tx_fifo_size_06<=32768)
13970 + ifxusb_module_params.tx_fifo_size[ 6]=perio_tx_fifo_size_06;
13972 + ifxusb_module_params.tx_fifo_size[ 6]=default_param_perio_tx_fifo_size_06;
13973 + if(perio_tx_fifo_size_07>=0 && perio_tx_fifo_size_07<=32768)
13974 + ifxusb_module_params.tx_fifo_size[ 7]=perio_tx_fifo_size_07;
13976 + ifxusb_module_params.tx_fifo_size[ 7]=default_param_perio_tx_fifo_size_07;
13977 + if(perio_tx_fifo_size_08>=0 && perio_tx_fifo_size_08<=32768)
13978 + ifxusb_module_params.tx_fifo_size[ 8]=perio_tx_fifo_size_08;
13980 + ifxusb_module_params.tx_fifo_size[ 8]=default_param_perio_tx_fifo_size_08;
13981 + if(perio_tx_fifo_size_09>=0 && perio_tx_fifo_size_09<=32768)
13982 + ifxusb_module_params.tx_fifo_size[ 9]=perio_tx_fifo_size_09;
13984 + ifxusb_module_params.tx_fifo_size[ 9]=default_param_perio_tx_fifo_size_09;
13985 + if(perio_tx_fifo_size_10>=0 && perio_tx_fifo_size_10<=32768)
13986 + ifxusb_module_params.tx_fifo_size[10]=perio_tx_fifo_size_10;
13988 + ifxusb_module_params.tx_fifo_size[10]=default_param_perio_tx_fifo_size_10;
13989 + if(perio_tx_fifo_size_11>=0 && perio_tx_fifo_size_11<=32768)
13990 + ifxusb_module_params.tx_fifo_size[11]=perio_tx_fifo_size_11;
13992 + ifxusb_module_params.tx_fifo_size[11]=default_param_perio_tx_fifo_size_11;
13993 + if(perio_tx_fifo_size_12>=0 && perio_tx_fifo_size_12<=32768)
13994 + ifxusb_module_params.tx_fifo_size[12]=perio_tx_fifo_size_12;
13996 + ifxusb_module_params.tx_fifo_size[12]=default_param_perio_tx_fifo_size_12;
13997 + if(perio_tx_fifo_size_13>=0 && perio_tx_fifo_size_13<=32768)
13998 + ifxusb_module_params.tx_fifo_size[13]=perio_tx_fifo_size_13;
14000 + ifxusb_module_params.tx_fifo_size[13]=default_param_perio_tx_fifo_size_13;
14001 + if(perio_tx_fifo_size_14>=0 && perio_tx_fifo_size_14<=32768)
14002 + ifxusb_module_params.tx_fifo_size[14]=perio_tx_fifo_size_14;
14004 + ifxusb_module_params.tx_fifo_size[14]=default_param_perio_tx_fifo_size_14;
14005 + if(perio_tx_fifo_size_15>=0 && perio_tx_fifo_size_15<=32768)
14006 + ifxusb_module_params.tx_fifo_size[15]=perio_tx_fifo_size_15;
14008 + ifxusb_module_params.tx_fifo_size[15]=default_param_perio_tx_fifo_size_15;
14009 + #endif //__DED_FIFO__
14010 + #endif //__IS_DEVICE__
14019 +module_param(dbg_lvl, long, 0444);
14020 +MODULE_PARM_DESC(dbg_lvl, "Debug level.");
14022 +module_param(dma_burst_size, short, 0444);
14023 +MODULE_PARM_DESC(dma_burst_size, "DMA Burst Size 0, 1, 4, 8, 16");
14025 +module_param(speed, short, 0444);
14026 +MODULE_PARM_DESC(speed, "Speed 0=High Speed 1=Full Speed");
14028 +module_param(data_fifo_size, long, 0444);
14029 +MODULE_PARM_DESC(data_fifo_size, "Total number of words in the data FIFO memory 32-32768");
14031 +#ifdef __IS_DEVICE__
14032 + module_param(rx_fifo_size, long, 0444);
14033 + MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
14035 + #ifdef __DED_FIFO__
14036 + module_param(tx_fifo_size_00, long, 0444);
14037 + MODULE_PARM_DESC(tx_fifo_size_00, "Number of words in the Tx FIFO #00 16-32768");
14038 + module_param(tx_fifo_size_01, long, 0444);
14039 + MODULE_PARM_DESC(tx_fifo_size_01, "Number of words in the Tx FIFO #01 0-32768");
14040 + module_param(tx_fifo_size_02, long, 0444);
14041 + MODULE_PARM_DESC(tx_fifo_size_02, "Number of words in the Tx FIFO #02 0-32768");
14042 + module_param(tx_fifo_size_03, long, 0444);
14043 + MODULE_PARM_DESC(tx_fifo_size_03, "Number of words in the Tx FIFO #03 0-32768");
14044 + module_param(tx_fifo_size_04, long, 0444);
14045 + MODULE_PARM_DESC(tx_fifo_size_04, "Number of words in the Tx FIFO #04 0-32768");
14046 + module_param(tx_fifo_size_05, long, 0444);
14047 + MODULE_PARM_DESC(tx_fifo_size_05, "Number of words in the Tx FIFO #05 0-32768");
14048 + module_param(tx_fifo_size_06, long, 0444);
14049 + MODULE_PARM_DESC(tx_fifo_size_06, "Number of words in the Tx FIFO #06 0-32768");
14050 + module_param(tx_fifo_size_07, long, 0444);
14051 + MODULE_PARM_DESC(tx_fifo_size_07, "Number of words in the Tx FIFO #07 0-32768");
14052 + module_param(tx_fifo_size_08, long, 0444);
14053 + MODULE_PARM_DESC(tx_fifo_size_08, "Number of words in the Tx FIFO #08 0-32768");
14054 + module_param(tx_fifo_size_09, long, 0444);
14055 + MODULE_PARM_DESC(tx_fifo_size_09, "Number of words in the Tx FIFO #09 0-32768");
14056 + module_param(tx_fifo_size_10, long, 0444);
14057 + MODULE_PARM_DESC(tx_fifo_size_10, "Number of words in the Tx FIFO #10 0-32768");
14058 + module_param(tx_fifo_size_11, long, 0444);
14059 + MODULE_PARM_DESC(tx_fifo_size_11, "Number of words in the Tx FIFO #11 0-32768");
14060 + module_param(tx_fifo_size_12, long, 0444);
14061 + MODULE_PARM_DESC(tx_fifo_size_12, "Number of words in the Tx FIFO #12 0-32768");
14062 + module_param(tx_fifo_size_13, long, 0444);
14063 + MODULE_PARM_DESC(tx_fifo_size_13, "Number of words in the Tx FIFO #13 0-32768");
14064 + module_param(tx_fifo_size_14, long, 0444);
14065 + MODULE_PARM_DESC(tx_fifo_size_14, "Number of words in the Tx FIFO #14 0-32768");
14066 + module_param(tx_fifo_size_15, long, 0444);
14067 + MODULE_PARM_DESC(tx_fifo_size_15, "Number of words in the Tx FIFO #15 0-32768");
14069 + module_param(thr_ctl, short, 0444);
14070 + MODULE_PARM_DESC(thr_ctl, "0=Without 1=With Theshold Ctrl");
14072 + module_param(tx_thr_length, long, 0444);
14073 + MODULE_PARM_DESC(tx_thr_length, "TX Threshold length");
14075 + module_param(rx_thr_length, long, 0444);
14076 + MODULE_PARM_DESC(rx_thr_length, "RX Threshold length");
14079 + module_param(nperio_tx_fifo_size, long, 0444);
14080 + MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
14082 + module_param(perio_tx_fifo_size_01, long, 0444);
14083 + MODULE_PARM_DESC(perio_tx_fifo_size_01, "Number of words in the periodic Tx FIFO #01 0-32768");
14084 + module_param(perio_tx_fifo_size_02, long, 0444);
14085 + MODULE_PARM_DESC(perio_tx_fifo_size_02, "Number of words in the periodic Tx FIFO #02 0-32768");
14086 + module_param(perio_tx_fifo_size_03, long, 0444);
14087 + MODULE_PARM_DESC(perio_tx_fifo_size_03, "Number of words in the periodic Tx FIFO #03 0-32768");
14088 + module_param(perio_tx_fifo_size_04, long, 0444);
14089 + MODULE_PARM_DESC(perio_tx_fifo_size_04, "Number of words in the periodic Tx FIFO #04 0-32768");
14090 + module_param(perio_tx_fifo_size_05, long, 0444);
14091 + MODULE_PARM_DESC(perio_tx_fifo_size_05, "Number of words in the periodic Tx FIFO #05 0-32768");
14092 + module_param(perio_tx_fifo_size_06, long, 0444);
14093 + MODULE_PARM_DESC(perio_tx_fifo_size_06, "Number of words in the periodic Tx FIFO #06 0-32768");
14094 + module_param(perio_tx_fifo_size_07, long, 0444);
14095 + MODULE_PARM_DESC(perio_tx_fifo_size_07, "Number of words in the periodic Tx FIFO #07 0-32768");
14096 + module_param(perio_tx_fifo_size_08, long, 0444);
14097 + MODULE_PARM_DESC(perio_tx_fifo_size_08, "Number of words in the periodic Tx FIFO #08 0-32768");
14098 + module_param(perio_tx_fifo_size_09, long, 0444);
14099 + MODULE_PARM_DESC(perio_tx_fifo_size_09, "Number of words in the periodic Tx FIFO #09 0-32768");
14100 + module_param(perio_tx_fifo_size_10, long, 0444);
14101 + MODULE_PARM_DESC(perio_tx_fifo_size_10, "Number of words in the periodic Tx FIFO #10 0-32768");
14102 + module_param(perio_tx_fifo_size_11, long, 0444);
14103 + MODULE_PARM_DESC(perio_tx_fifo_size_11, "Number of words in the periodic Tx FIFO #11 0-32768");
14104 + module_param(perio_tx_fifo_size_12, long, 0444);
14105 + MODULE_PARM_DESC(perio_tx_fifo_size_12, "Number of words in the periodic Tx FIFO #12 0-32768");
14106 + module_param(perio_tx_fifo_size_13, long, 0444);
14107 + MODULE_PARM_DESC(perio_tx_fifo_size_13, "Number of words in the periodic Tx FIFO #13 0-32768");
14108 + module_param(perio_tx_fifo_size_14, long, 0444);
14109 + MODULE_PARM_DESC(perio_tx_fifo_size_14, "Number of words in the periodic Tx FIFO #14 0-32768");
14110 + module_param(perio_tx_fifo_size_15, long, 0444);
14111 + MODULE_PARM_DESC(perio_tx_fifo_size_15, "Number of words in the periodic Tx FIFO #15 0-32768");
14112 + #endif//__DED_FIFO__
14113 + module_param(dev_endpoints, short, 0444);
14114 + MODULE_PARM_DESC(dev_endpoints, "The number of endpoints in addition to EP0 available for device mode 1-15");
14117 +#ifdef __IS_HOST__
14118 + module_param(rx_fifo_size, long, 0444);
14119 + MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
14121 + module_param(nperio_tx_fifo_size, long, 0444);
14122 + MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
14124 + module_param(perio_tx_fifo_size, long, 0444);
14125 + MODULE_PARM_DESC(perio_tx_fifo_size, "Number of words in the host periodic Tx FIFO 16-32768");
14127 + module_param(host_channels, short, 0444);
14128 + MODULE_PARM_DESC(host_channels, "The number of host channel registers to use 1-16");
14131 +module_param(max_transfer_size, long, 0444);
14132 +MODULE_PARM_DESC(max_transfer_size, "The maximum transfer size supported in bytes 2047-65535");
14134 +module_param(max_packet_count, long, 0444);
14135 +MODULE_PARM_DESC(max_packet_count, "The maximum number of packets in a transfer 15-511");
14137 +module_param(phy_utmi_width, long, 0444);
14138 +MODULE_PARM_DESC(phy_utmi_width, "Specifies the UTMI+ Data Width 8 or 16 bits");
14140 +module_param(turn_around_time_hs, long, 0444);
14141 +MODULE_PARM_DESC(turn_around_time_hs, "Turn-Around time for HS");
14143 +module_param(turn_around_time_fs, long, 0444);
14144 +MODULE_PARM_DESC(turn_around_time_fs, "Turn-Around time for FS");
14146 +module_param(timeout_cal_hs, long, 0444);
14147 +MODULE_PARM_DESC(timeout_cal_hs, "Timeout Cal for HS");
14149 +module_param(timeout_cal_fs, long, 0444);
14150 +MODULE_PARM_DESC(timeout_cal_fs, "Timeout Cal for FS");
14154 +++ b/drivers/usb/ifxhcd/ifxusb_plat.h
14156 +/*****************************************************************************
14157 + ** FILE NAME : ifxusb_plat.h
14158 + ** PROJECT : IFX USB sub-system V3
14159 + ** MODULES : IFX USB sub-system Host and Device driver
14160 + ** SRC VERSION : 1.0
14161 + ** DATE : 1/Jan/2009
14162 + ** AUTHOR : Chen, Howard
14163 + ** DESCRIPTION : This file contains the Platform Specific constants, interfaces
14164 + ** (functions and macros).
14166 + ** COMPILER : gcc
14167 + ** REFERENCE : IFX hardware ref handbook for each plateforms
14169 + ** Version Control Section **
14173 + ** $Log$ Revision history
14174 + *****************************************************************************/
14178 + \defgroup IFXUSB_PLATEFORM_DEFINITION Platform Specific constants, interfaces (functions and macros).
14179 + \ingroup IFXUSB_DRIVER_V3
14180 + \brief Maintain plateform specific definitions and macros in this file.
14181 + Each plateform has its own definition zone.
14185 + \defgroup IFXUSB_PLATEFORM_MEM_ADDR Definition of memory address and size and default parameters
14186 + \ingroup IFXUSB_PLATEFORM_DEFINITION
14190 + \defgroup IFXUSB_DBG_ROUTINE Routines for debug message
14191 + \ingroup IFXUSB_PLATEFORM_DEFINITION
14195 +/*! \file ifxusb_plat.h
14196 + \ingroup IFXUSB_DRIVER_V3
14197 + \brief This file contains the Platform Specific constants, interfaces (functions and macros).
14200 +#if !defined(__IFXUSB_PLAT_H__)
14201 +#define __IFXUSB_PLAT_H__
14204 +#include <linux/types.h>
14205 +#include <linux/slab.h>
14206 +#include <linux/list.h>
14207 +#include <linux/delay.h>
14208 +#include <asm/io.h>
14211 +#define IFXUSB_IOMEM_SIZE 0x00001000
14212 +#define IFXUSB_FIFOMEM_SIZE 0x00010000
14213 +#define IFXUSB_FIFODBG_SIZE 0x00020000
14218 + \addtogroup IFXUSB_PLATEFORM_MEM_ADDR
14221 +#if defined(__UEIP__)
14222 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
14223 +// #define IFXUSB_IRQ 54
14224 + #define IFXUSB_IOMEM_BASE 0x1e101000
14225 + #define IFXUSB_FIFOMEM_BASE 0x1e120000
14226 + #define IFXUSB_FIFODBG_BASE 0x1e140000
14227 +// #define IFXUSB_OC_IRQ 151
14229 + #ifndef DANUBE_RCU_BASE_ADDR
14230 + #define DANUBE_RCU_BASE_ADDR (0xBF203000)
14233 + #ifndef DANUBE_CGU
14234 + #define DANUBE_CGU (0xBF103000)
14236 + #ifndef DANUBE_CGU_IFCCR
14237 + #define DANUBE_CGU_IFCCR ((volatile unsigned long *)(DANUBE_CGU+ 0x0018))
14239 + #ifndef DANUBE_PMU
14240 + #define DANUBE_PMU (KSEG1+0x1F102000)
14242 + #ifndef DANUBE_PMU_PWDCR
14243 + #define DANUBE_PMU_PWDCR ((volatile unsigned long *)(DANUBE_PMU+0x001C))
14246 + #ifndef DANUBE_GPIO_P0_OUT
14247 + #define DANUBE_GPIO_P0_OUT (0xBF103000+0x10)
14248 + #define DANUBE_GPIO_P0_DIR (0xBF103000+0x18)
14249 + #define DANUBE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14250 + #define DANUBE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14251 + #define DANUBE_GPIO_P0_OD (0xBF103000+0x24)
14252 + #define DANUBE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14253 + #define DANUBE_GPIO_P0_PUDEN (0xBF103000+0x30)
14254 + #define DANUBE_GPIO_P1_OUT (0xBF103000+0x40)
14255 + #define DANUBE_GPIO_P1_DIR (0xBF103000+0x48)
14256 + #define DANUBE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14257 + #define DANUBE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14258 + #define DANUBE_GPIO_P1_OD (0xBF103000+0x54)
14259 + #define DANUBE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14260 + #define DANUBE_GPIO_P1_PUDEN (0xBF103000+0x60)
14263 + #define DANUBE_RCU_USBCFG ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x18))
14264 + #define DANUBE_RCU_RESET ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x10))
14265 + #define DANUBE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14266 + #define DANUBE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14267 + #define DANUBE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
14269 + #define default_param_dma_burst_size 4
14271 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14273 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14274 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14275 + #define default_param_phy_utmi_width 16
14277 + #define default_param_turn_around_time_hs 4
14278 + #define default_param_turn_around_time_fs 4
14279 + #define default_param_timeout_cal_hs -1 //(NoChange)
14280 + #define default_param_timeout_cal_fs -1 //(NoChange)
14282 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
14284 + #ifdef __IS_HOST__
14285 + #define default_param_host_channels -1 //(Max, hwcfg)
14286 + #define default_param_rx_fifo_size 640
14287 + #define default_param_nperio_tx_fifo_size 640
14288 + #define default_param_perio_tx_fifo_size 768
14289 + #endif //__IS_HOST__
14291 + #ifdef __IS_DEVICE__
14292 + #ifdef __DED_INTR__
14293 + #define default_param_rx_fifo_size 1024
14294 + #define default_param_nperio_tx_fifo_size 1016
14295 + #define default_param_perio_tx_fifo_size_01 8
14297 + #define default_param_rx_fifo_size 1024
14298 + #define default_param_nperio_tx_fifo_size 1024
14299 + #define default_param_perio_tx_fifo_size_01 0
14301 + #define default_param_perio_tx_fifo_size_02 0
14302 + #define default_param_perio_tx_fifo_size_03 0
14303 + #define default_param_perio_tx_fifo_size_04 0
14304 + #define default_param_perio_tx_fifo_size_05 0
14305 + #define default_param_perio_tx_fifo_size_06 0
14306 + #define default_param_perio_tx_fifo_size_07 0
14307 + #define default_param_perio_tx_fifo_size_08 0
14308 + #define default_param_perio_tx_fifo_size_09 0
14309 + #define default_param_perio_tx_fifo_size_10 0
14310 + #define default_param_perio_tx_fifo_size_11 0
14311 + #define default_param_perio_tx_fifo_size_12 0
14312 + #define default_param_perio_tx_fifo_size_13 0
14313 + #define default_param_perio_tx_fifo_size_14 0
14314 + #define default_param_perio_tx_fifo_size_15 0
14315 + #endif //__IS_DEVICE__
14317 + #elif defined(__IS_AMAZON_SE__)
14318 + //#include <asm/amazon_se/amazon_se.h>
14319 + //#include <asm/amazon_se/irq.h>
14321 +// #define IFXUSB_IRQ 31
14322 + #define IFXUSB_IOMEM_BASE 0x1e101000
14323 + #define IFXUSB_FIFOMEM_BASE 0x1e120000
14324 + #define IFXUSB_FIFODBG_BASE 0x1e140000
14325 +// #define IFXUSB_OC_IRQ 20
14327 + #ifndef AMAZON_SE_RCU_BASE_ADDR
14328 + #define AMAZON_SE_RCU_BASE_ADDR (0xBF203000)
14330 + #define AMAZON_SE_RCU_USBCFG ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x18))
14331 + #define AMAZON_SE_RCU_RESET ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x10))
14332 + #define AMAZON_SE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14333 + #define AMAZON_SE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14334 + #define AMAZON_SE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
14336 + #ifndef AMAZON_SE_GPIO_P0_OUT
14337 + #define AMAZON_SE_GPIO_P0_OUT (0xBF103000+0x10)
14338 + #define AMAZON_SE_GPIO_P0_DIR (0xBF103000+0x18)
14339 + #define AMAZON_SE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14340 + #define AMAZON_SE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14341 + #define AMAZON_SE_GPIO_P0_OD (0xBF103000+0x24)
14342 + #define AMAZON_SE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14343 + #define AMAZON_SE_GPIO_P0_PUDEN (0xBF103000+0x30)
14344 + #define AMAZON_SE_GPIO_P1_OUT (0xBF103000+0x40)
14345 + #define AMAZON_SE_GPIO_P1_DIR (0xBF103000+0x48)
14346 + #define AMAZON_SE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14347 + #define AMAZON_SE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14348 + #define AMAZON_SE_GPIO_P1_OD (0xBF103000+0x54)
14349 + #define AMAZON_SE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14350 + #define AMAZON_SE_GPIO_P1_PUDEN (0xBF103000+0x60)
14353 + #ifndef AMAZON_SE_CGU
14354 + #define AMAZON_SE_CGU (0xBF103000)
14356 + #ifndef AMAZON_SE_CGU_IFCCR
14357 + #define AMAZON_SE_CGU_IFCCR ((volatile unsigned long *)(AMAZON_SE_CGU+ 0x0018))
14359 + #ifndef AMAZON_SE_PMU
14360 + #define AMAZON_SE_PMU (KSEG1+0x1F102000)
14362 + #ifndef AMAZON_SE_PMU_PWDCR
14363 + #define AMAZON_SE_PMU_PWDCR ((volatile unsigned long *)(AMAZON_SE_PMU+0x001C))
14366 + #define default_param_dma_burst_size 4
14368 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14370 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14371 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14372 + #define default_param_phy_utmi_width 16
14374 + #define default_param_turn_around_time_hs 4 //(NoChange)
14375 + #define default_param_turn_around_time_fs 4 //(NoChange)
14376 + #define default_param_timeout_cal_hs -1 //(NoChange)
14377 + #define default_param_timeout_cal_fs -1 //(NoChange)
14379 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
14381 + #ifdef __IS_HOST__
14382 + #define default_param_host_channels -1 //(Max, hwcfg)
14383 + #define default_param_rx_fifo_size 240
14384 + #define default_param_nperio_tx_fifo_size 240
14385 + #define default_param_perio_tx_fifo_size 32
14386 + #endif //__IS_HOST__
14387 + #ifdef __IS_DEVICE__
14388 + #ifdef __DED_INTR__
14389 + #define default_param_rx_fifo_size 256
14390 + #define default_param_nperio_tx_fifo_size 248
14391 + #define default_param_perio_tx_fifo_size_01 8
14393 + #define default_param_rx_fifo_size 256
14394 + #define default_param_nperio_tx_fifo_size 256
14395 + #define default_param_perio_tx_fifo_size_01 0
14397 + #define default_param_perio_tx_fifo_size_02 0
14398 + #define default_param_perio_tx_fifo_size_03 0
14399 + #define default_param_perio_tx_fifo_size_04 0
14400 + #define default_param_perio_tx_fifo_size_05 0
14401 + #define default_param_perio_tx_fifo_size_06 0
14402 + #define default_param_perio_tx_fifo_size_07 0
14403 + #define default_param_perio_tx_fifo_size_08 0
14404 + #define default_param_perio_tx_fifo_size_09 0
14405 + #define default_param_perio_tx_fifo_size_10 0
14406 + #define default_param_perio_tx_fifo_size_11 0
14407 + #define default_param_perio_tx_fifo_size_12 0
14408 + #define default_param_perio_tx_fifo_size_13 0
14409 + #define default_param_perio_tx_fifo_size_14 0
14410 + #define default_param_perio_tx_fifo_size_15 0
14411 + #endif //__IS_DEVICE__
14413 + #elif defined(__IS_AR9__)
14414 +// #define IFXUSB1_IRQ 54
14415 + #define IFXUSB1_IOMEM_BASE 0x1E101000
14416 + #define IFXUSB1_FIFOMEM_BASE 0x1E120000
14417 + #define IFXUSB1_FIFODBG_BASE 0x1E140000
14419 +// #define IFXUSB2_IRQ 83
14420 + #define IFXUSB2_IOMEM_BASE 0x1E106000
14421 + #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
14422 + #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
14424 +// #define IFXUSB_OC_IRQ 60
14426 + #ifndef AR9_RCU_BASE_ADDR
14427 + #define AR9_RCU_BASE_ADDR (0xBF203000)
14431 + #define AR9_CGU (0xBF103000)
14433 + #ifndef AR9_CGU_IFCCR
14434 + #define AR9_CGU_IFCCR ((volatile unsigned long *)(AR9_CGU+ 0x0018))
14438 + #define AR9_PMU (KSEG1+0x1F102000)
14440 + #ifndef AR9_PMU_PWDCR
14441 + #define AR9_PMU_PWDCR ((volatile unsigned long *)(AR9_PMU+0x001C))
14444 + #ifndef AR9_GPIO_P0_OUT
14445 + #define AR9_GPIO_P0_OUT (0xBF103000+0x10)
14446 + #define AR9_GPIO_P0_DIR (0xBF103000+0x18)
14447 + #define AR9_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14448 + #define AR9_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14449 + #define AR9_GPIO_P0_OD (0xBF103000+0x24)
14450 + #define AR9_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14451 + #define AR9_GPIO_P0_PUDEN (0xBF103000+0x30)
14452 + #define AR9_GPIO_P1_OUT (0xBF103000+0x40)
14453 + #define AR9_GPIO_P1_DIR (0xBF103000+0x48)
14454 + #define AR9_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14455 + #define AR9_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14456 + #define AR9_GPIO_P1_OD (0xBF103000+0x54)
14457 + #define AR9_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14458 + #define AR9_GPIO_P1_PUDEN (0xBF103000+0x60)
14461 + #define AR9_RCU_USB1CFG ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x18))
14462 + #define AR9_RCU_USB2CFG ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x34))
14463 + #define AR9_RCU_USBRESET ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x10))
14464 + #define AR9_USBCFG_ARB 7 //
14465 + #define AR9_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14466 + #define AR9_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14467 + #define AR9_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
14469 + #define default_param_dma_burst_size 4
14471 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14473 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14474 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14475 + #define default_param_phy_utmi_width 16
14477 + #define default_param_turn_around_time_hs 4 //(NoChange)
14478 + #define default_param_turn_around_time_fs 4 //(NoChange)
14479 + #define default_param_timeout_cal_hs -1 //(NoChange)
14480 + #define default_param_timeout_cal_fs -1 //(NoChange)
14482 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
14484 + #ifdef __IS_HOST__
14485 + #define default_param_host_channels -1 //(Max, hwcfg)
14486 + #define default_param_rx_fifo_size 240
14487 + #define default_param_nperio_tx_fifo_size 240
14488 + #define default_param_perio_tx_fifo_size 32
14489 + #endif //__IS_HOST__
14490 + #ifdef __IS_DEVICE__
14491 + #ifdef __DED_INTR__
14492 + #define default_param_rx_fifo_size 256
14493 +// #define default_param_nperio_tx_fifo_size 248
14494 +// #define default_param_perio_tx_fifo_size_01 8
14495 + #define default_param_nperio_tx_fifo_size 252
14496 + #define default_param_perio_tx_fifo_size_01 4
14498 + #define default_param_rx_fifo_size 256
14499 + #define default_param_nperio_tx_fifo_size 256
14500 + #define default_param_perio_tx_fifo_size_01 0
14502 + #define default_param_perio_tx_fifo_size_02 0
14503 + #define default_param_perio_tx_fifo_size_03 0
14504 + #define default_param_perio_tx_fifo_size_04 0
14505 + #define default_param_perio_tx_fifo_size_05 0
14506 + #define default_param_perio_tx_fifo_size_06 0
14507 + #define default_param_perio_tx_fifo_size_07 0
14508 + #define default_param_perio_tx_fifo_size_08 0
14509 + #define default_param_perio_tx_fifo_size_09 0
14510 + #define default_param_perio_tx_fifo_size_10 0
14511 + #define default_param_perio_tx_fifo_size_11 0
14512 + #define default_param_perio_tx_fifo_size_12 0
14513 + #define default_param_perio_tx_fifo_size_13 0
14514 + #define default_param_perio_tx_fifo_size_14 0
14515 + #define default_param_perio_tx_fifo_size_15 0
14516 + #endif //__IS_DEVICE__
14518 + #elif defined(__IS_VR9__)
14519 +// #define IFXUSB1_IRQ 54
14520 + #define IFXUSB1_IOMEM_BASE 0x1E101000
14521 + #define IFXUSB1_FIFOMEM_BASE 0x1E120000
14522 + #define IFXUSB1_FIFODBG_BASE 0x1E140000
14524 +// #define IFXUSB2_IRQ 83
14525 + #define IFXUSB2_IOMEM_BASE 0x1E106000
14526 + #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
14527 + #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
14528 +// #define IFXUSB_OC_IRQ 60
14530 + #ifndef VR9_RCU_BASE_ADDR
14531 + #define VR9_RCU_BASE_ADDR (0xBF203000)
14535 + #define VR9_CGU (0xBF103000)
14537 + #ifndef VR9_CGU_IFCCR
14538 + #define VR9_CGU_IFCCR ((volatile unsigned long *)(VR9_CGU+ 0x0018))
14542 + #define VR9_PMU (KSEG1+0x1F102000)
14544 + #ifndef VR9_PMU_PWDCR
14545 + #define VR9_PMU_PWDCR ((volatile unsigned long *)(VR9_PMU+0x001C))
14548 + #ifndef VR9_GPIO_P0_OUT
14549 + #define VR9_GPIO_P0_OUT (0xBF103000+0x10)
14550 + #define VR9_GPIO_P0_DIR (0xBF103000+0x18)
14551 + #define VR9_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14552 + #define VR9_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14553 + #define VR9_GPIO_P0_OD (0xBF103000+0x24)
14554 + #define VR9_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14555 + #define VR9_GPIO_P0_PUDEN (0xBF103000+0x30)
14556 + #define VR9_GPIO_P1_OUT (0xBF103000+0x40)
14557 + #define VR9_GPIO_P1_DIR (0xBF103000+0x48)
14558 + #define VR9_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14559 + #define VR9_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14560 + #define VR9_GPIO_P1_OD (0xBF103000+0x54)
14561 + #define VR9_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14562 + #define VR9_GPIO_P1_PUDEN (0xBF103000+0x60)
14565 + #define VR9_RCU_USB1CFG ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x18))
14566 + #define VR9_RCU_USB2CFG ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x34))
14567 + #define VR9_RCU_USB_ANA_CFG1A ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x38))
14568 + #define VR9_RCU_USB_ANA_CFG1B ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x3C))
14569 + #define VR9_RCU_USBRESET ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x10))
14570 + #define VR9_RCU_USBRESET2 ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x48))
14571 + #define VR9_USBCFG_ARB 7 //
14572 + #define VR9_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14573 + #define VR9_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14574 + #define VR9_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
14576 + /*== AVM/BC 20101220 Workaround VR9 DMA burst size ==
14577 + * Using 2 Devices in diferent ports cause a general USB Host Error.
14578 + * Workaround found in UGW4.3
14580 +// #define default_param_dma_burst_size 4 //(ALL)
14582 + #define default_param_dma_burst_size 0 //(ALL)
14584 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14586 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14587 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14588 + #define default_param_phy_utmi_width 16
14590 + #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
14591 + #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
14592 + #define default_param_timeout_cal_hs -1 //(NoChange)
14593 + #define default_param_timeout_cal_fs -1 //(NoChange)
14595 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
14597 + #ifdef __IS_HOST__
14598 + #define default_param_host_channels -1 //(Max, hwcfg)
14599 + #define default_param_rx_fifo_size 240
14600 + #define default_param_nperio_tx_fifo_size 240
14601 + #define default_param_perio_tx_fifo_size 32
14602 + #endif //__IS_HOST__
14603 + #ifdef __IS_DEVICE__
14605 + #define default_param_rx_fifo_size 256
14606 + #define default_param_tx_fifo_size_00 -1
14607 + #define default_param_tx_fifo_size_01 -1
14608 + #define default_param_tx_fifo_size_02 -1
14610 + #define default_param_rx_fifo_size 256
14611 + #define default_param_tx_fifo_size_00 32
14612 + #define default_param_tx_fifo_size_01 200
14613 + #define default_param_tx_fifo_size_02 8
14615 + #define default_param_tx_fifo_size_03 -1
14616 + #define default_param_tx_fifo_size_04 -1
14617 + #define default_param_tx_fifo_size_05 -1
14618 + #define default_param_tx_fifo_size_06 -1
14619 + #define default_param_tx_fifo_size_07 -1
14620 + #define default_param_tx_fifo_size_08 -1
14621 + #define default_param_tx_fifo_size_09 -1
14622 + #define default_param_tx_fifo_size_10 -1
14623 + #define default_param_tx_fifo_size_11 -1
14624 + #define default_param_tx_fifo_size_12 -1
14625 + #define default_param_tx_fifo_size_13 -1
14626 + #define default_param_tx_fifo_size_14 -1
14627 + #define default_param_tx_fifo_size_15 -1
14628 + #define default_param_dma_unalgned_tx -1
14629 + #define default_param_dma_unalgned_rx -1
14630 + #define default_param_thr_ctl -1
14631 + #define default_param_tx_thr_length -1
14632 + #define default_param_rx_thr_length -1
14633 + #endif //__IS_DEVICE__
14634 + #else // __IS_VR9__
14635 + #error "Please choose one platform!!"
14636 + #endif // __IS_VR9__
14639 + #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
14640 +// #define IFXUSB_IRQ 54
14641 + #define IFXUSB_IOMEM_BASE 0x1e101000
14642 + #define IFXUSB_FIFOMEM_BASE 0x1e120000
14643 + #define IFXUSB_FIFODBG_BASE 0x1e140000
14644 +// #define IFXUSB_OC_IRQ 151
14647 + #ifndef DANUBE_RCU_BASE_ADDR
14648 + #define DANUBE_RCU_BASE_ADDR (0xBF203000)
14651 + #ifndef DANUBE_CGU
14652 + #define DANUBE_CGU (0xBF103000)
14654 + #ifndef DANUBE_CGU_IFCCR
14655 + #define DANUBE_CGU_IFCCR ((volatile unsigned long *)(DANUBE_CGU+ 0x0018))
14657 + #ifndef DANUBE_PMU
14658 + #define DANUBE_PMU (KSEG1+0x1F102000)
14660 + #ifndef DANUBE_PMU_PWDCR
14661 + #define DANUBE_PMU_PWDCR ((volatile unsigned long *)(DANUBE_PMU+0x001C))
14664 + #ifndef DANUBE_GPIO_P0_OUT
14665 + #define DANUBE_GPIO_P0_OUT (0xBF103000+0x10)
14666 + #define DANUBE_GPIO_P0_DIR (0xBF103000+0x18)
14667 + #define DANUBE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14668 + #define DANUBE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14669 + #define DANUBE_GPIO_P0_OD (0xBF103000+0x24)
14670 + #define DANUBE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14671 + #define DANUBE_GPIO_P0_PUDEN (0xBF103000+0x30)
14672 + #define DANUBE_GPIO_P1_OUT (0xBF103000+0x40)
14673 + #define DANUBE_GPIO_P1_DIR (0xBF103000+0x48)
14674 + #define DANUBE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14675 + #define DANUBE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14676 + #define DANUBE_GPIO_P1_OD (0xBF103000+0x54)
14677 + #define DANUBE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14678 + #define DANUBE_GPIO_P1_PUDEN (0xBF103000+0x60)
14682 + #define DANUBE_RCU_USBCFG ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x18))
14683 + #define DANUBE_RCU_RESET ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x10))
14684 + #define DANUBE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14685 + #define DANUBE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14686 + #define DANUBE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
14688 + #define default_param_dma_burst_size 4
14690 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14692 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14693 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14694 + #define default_param_phy_utmi_width 16
14696 + #define default_param_turn_around_time_hs 4 //(NoChange)
14697 + #define default_param_turn_around_time_fs 4 //(NoChange)
14698 + #define default_param_timeout_cal_hs -1 //(NoChange)
14699 + #define default_param_timeout_cal_fs -1 //(NoChange)
14701 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
14702 + #ifdef __IS_HOST__
14703 + #define default_param_host_channels -1 //(Max, hwcfg)
14704 + #define default_param_rx_fifo_size 640
14705 + #define default_param_nperio_tx_fifo_size 640
14706 + #define default_param_perio_tx_fifo_size 768
14707 + #endif //__IS_HOST__
14709 + #ifdef __IS_DEVICE__
14710 + #ifdef __DED_INTR__
14711 + #define default_param_rx_fifo_size 1024
14712 + #define default_param_nperio_tx_fifo_size 1016
14713 + #define default_param_perio_tx_fifo_size_01 8
14715 + #define default_param_rx_fifo_size 1024
14716 + #define default_param_nperio_tx_fifo_size 1024
14717 + #define default_param_perio_tx_fifo_size_01 0
14719 + #define default_param_perio_tx_fifo_size_02 0
14720 + #define default_param_perio_tx_fifo_size_03 0
14721 + #define default_param_perio_tx_fifo_size_04 0
14722 + #define default_param_perio_tx_fifo_size_05 0
14723 + #define default_param_perio_tx_fifo_size_06 0
14724 + #define default_param_perio_tx_fifo_size_07 0
14725 + #define default_param_perio_tx_fifo_size_08 0
14726 + #define default_param_perio_tx_fifo_size_09 0
14727 + #define default_param_perio_tx_fifo_size_10 0
14728 + #define default_param_perio_tx_fifo_size_11 0
14729 + #define default_param_perio_tx_fifo_size_12 0
14730 + #define default_param_perio_tx_fifo_size_13 0
14731 + #define default_param_perio_tx_fifo_size_14 0
14732 + #define default_param_perio_tx_fifo_size_15 0
14733 + #endif //__IS_DEVICE__
14735 + #elif defined(__IS_AMAZON_SE__)
14736 + #include <asm/amazon_se/amazon_se.h>
14737 + //#include <asm/amazon_se/irq.h>
14739 +// #define IFXUSB_IRQ 31
14740 + #define IFXUSB_IOMEM_BASE 0x1e101000
14741 + #define IFXUSB_FIFOMEM_BASE 0x1e120000
14742 + #define IFXUSB_FIFODBG_BASE 0x1e140000
14743 +// #define IFXUSB_OC_IRQ 20
14745 + #define AMAZON_SE_RCU_USBCFG ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x18))
14746 + #define AMAZON_SE_RCU_RESET ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x10))
14747 + #define AMAZON_SE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14748 + #define AMAZON_SE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14749 + #define AMAZON_SE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
14751 + #ifndef AMAZON_SE_GPIO_P0_OUT
14752 + #define AMAZON_SE_GPIO_P0_OUT (0xBF103000+0x10)
14753 + #define AMAZON_SE_GPIO_P0_DIR (0xBF103000+0x18)
14754 + #define AMAZON_SE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14755 + #define AMAZON_SE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14756 + #define AMAZON_SE_GPIO_P0_OD (0xBF103000+0x24)
14757 + #define AMAZON_SE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14758 + #define AMAZON_SE_GPIO_P0_PUDEN (0xBF103000+0x30)
14759 + #define AMAZON_SE_GPIO_P1_OUT (0xBF103000+0x40)
14760 + #define AMAZON_SE_GPIO_P1_DIR (0xBF103000+0x48)
14761 + #define AMAZON_SE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14762 + #define AMAZON_SE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14763 + #define AMAZON_SE_GPIO_P1_OD (0xBF103000+0x54)
14764 + #define AMAZON_SE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14765 + #define AMAZON_SE_GPIO_P1_PUDEN (0xBF103000+0x60)
14769 + #ifndef AMAZON_SE_CGU
14770 + #define AMAZON_SE_CGU (0xBF103000)
14772 + #ifndef AMAZON_SE_CGU_IFCCR
14773 + #define AMAZON_SE_CGU_IFCCR ((volatile unsigned long *)(AMAZON_SE_CGU+ 0x0018))
14775 + #ifndef AMAZON_SE_PMU
14776 + #define AMAZON_SE_PMU (KSEG1+0x1F102000)
14778 + #ifndef AMAZON_SE_PMU_PWDCR
14779 + #define AMAZON_SE_PMU_PWDCR ((volatile unsigned long *)(AMAZON_SE_PMU+0x001C))
14782 + #define default_param_dma_burst_size 4
14784 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14786 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14787 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14788 + #define default_param_phy_utmi_width 16
14790 + #define default_param_turn_around_time_hs 4 //(NoChange)
14791 + #define default_param_turn_around_time_fs 4 //(NoChange)
14792 + #define default_param_timeout_cal_hs -1 //(NoChange)
14793 + #define default_param_timeout_cal_fs -1 //(NoChange)
14795 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
14797 + #ifdef __IS_HOST__
14798 + #define default_param_host_channels -1 //(Max, hwcfg)
14799 + #define default_param_rx_fifo_size 240
14800 + #define default_param_nperio_tx_fifo_size 240
14801 + #define default_param_perio_tx_fifo_size 32
14802 + #endif //__IS_HOST__
14803 + #ifdef __IS_DEVICE__
14804 + #ifdef __DED_INTR__
14805 + #define default_param_rx_fifo_size 256
14806 + #define default_param_nperio_tx_fifo_size 248
14807 + #define default_param_perio_tx_fifo_size_01 8
14809 + #define default_param_rx_fifo_size 256
14810 + #define default_param_nperio_tx_fifo_size 256
14811 + #define default_param_perio_tx_fifo_size_01 0
14813 + #define default_param_perio_tx_fifo_size_02 0
14814 + #define default_param_perio_tx_fifo_size_03 0
14815 + #define default_param_perio_tx_fifo_size_04 0
14816 + #define default_param_perio_tx_fifo_size_05 0
14817 + #define default_param_perio_tx_fifo_size_06 0
14818 + #define default_param_perio_tx_fifo_size_07 0
14819 + #define default_param_perio_tx_fifo_size_08 0
14820 + #define default_param_perio_tx_fifo_size_09 0
14821 + #define default_param_perio_tx_fifo_size_10 0
14822 + #define default_param_perio_tx_fifo_size_11 0
14823 + #define default_param_perio_tx_fifo_size_12 0
14824 + #define default_param_perio_tx_fifo_size_13 0
14825 + #define default_param_perio_tx_fifo_size_14 0
14826 + #define default_param_perio_tx_fifo_size_15 0
14827 + #endif //__IS_DEVICE__
14829 + #elif defined(__IS_AR9__)
14830 +// #define IFXUSB1_IRQ 54
14831 + #define IFXUSB1_IOMEM_BASE 0x1E101000
14832 + #define IFXUSB1_FIFOMEM_BASE 0x1E120000
14833 + #define IFXUSB1_FIFODBG_BASE 0x1E140000
14835 +// #define IFXUSB2_IRQ 83
14836 + #define IFXUSB2_IOMEM_BASE 0x1E106000
14837 + #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
14838 + #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
14840 +// #define IFXUSB_OC_IRQ 60
14842 + #ifndef AMAZON_S_RCU_BASE_ADDR
14843 + #define AMAZON_S_RCU_BASE_ADDR (0xBF203000)
14846 + #ifndef AMAZON_S_CGU
14847 + #define AMAZON_S_CGU (0xBF103000)
14849 + #ifndef AMAZON_S_CGU_IFCCR
14850 + #define AMAZON_S_CGU_IFCCR ((volatile unsigned long *)(AMAZON_S_CGU+ 0x0018))
14853 + #ifndef AMAZON_S_PMU
14854 + #define AMAZON_S_PMU (KSEG1+0x1F102000)
14856 + #ifndef AMAZON_S_PMU_PWDCR
14857 + #define AMAZON_S_PMU_PWDCR ((volatile unsigned long *)(AMAZON_S_PMU+0x001C))
14860 + #ifndef AMAZON_S_GPIO_P0_OUT
14861 + #define AMAZON_S_GPIO_P0_OUT (0xBF103000+0x10)
14862 + #define AMAZON_S_GPIO_P0_DIR (0xBF103000+0x18)
14863 + #define AMAZON_S_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14864 + #define AMAZON_S_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14865 + #define AMAZON_S_GPIO_P0_OD (0xBF103000+0x24)
14866 + #define AMAZON_S_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14867 + #define AMAZON_S_GPIO_P0_PUDEN (0xBF103000+0x30)
14868 + #define AMAZON_S_GPIO_P1_OUT (0xBF103000+0x40)
14869 + #define AMAZON_S_GPIO_P1_DIR (0xBF103000+0x48)
14870 + #define AMAZON_S_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14871 + #define AMAZON_S_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14872 + #define AMAZON_S_GPIO_P1_OD (0xBF103000+0x54)
14873 + #define AMAZON_S_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14874 + #define AMAZON_S_GPIO_P1_PUDEN (0xBF103000+0x60)
14877 + #define AMAZON_S_RCU_USB1CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x18))
14878 + #define AMAZON_S_RCU_USB2CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x34))
14879 + #define AMAZON_S_RCU_USBRESET ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x10))
14880 + #define AMAZON_S_USBCFG_ARB 7 //
14881 + #define AMAZON_S_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14882 + #define AMAZON_S_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14883 + #define AMAZON_S_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
14885 + #define default_param_dma_burst_size 4
14887 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14889 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14890 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14891 + #define default_param_phy_utmi_width 16
14893 + #define default_param_turn_around_time_hs 4 //(NoChange)
14894 + #define default_param_turn_around_time_fs 4 //(NoChange)
14895 + #define default_param_timeout_cal_hs -1 //(NoChange)
14896 + #define default_param_timeout_cal_fs -1 //(NoChange)
14898 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
14900 + #ifdef __IS_HOST__
14901 + #define default_param_host_channels -1 //(Max, hwcfg)
14902 + #define default_param_rx_fifo_size 240
14903 + #define default_param_nperio_tx_fifo_size 240
14904 + #define default_param_perio_tx_fifo_size 32
14905 + #endif //__IS_HOST__
14906 + #ifdef __IS_DEVICE__
14907 + #ifdef __DED_INTR__
14908 + #define default_param_rx_fifo_size 256
14909 + #define default_param_nperio_tx_fifo_size 248
14910 + #define default_param_perio_tx_fifo_size_01 8
14912 + #define default_param_rx_fifo_size 256
14913 + #define default_param_nperio_tx_fifo_size 256
14914 + #define default_param_perio_tx_fifo_size_01 0
14916 + #define default_param_perio_tx_fifo_size_02 0
14917 + #define default_param_perio_tx_fifo_size_03 0
14918 + #define default_param_perio_tx_fifo_size_04 0
14919 + #define default_param_perio_tx_fifo_size_05 0
14920 + #define default_param_perio_tx_fifo_size_06 0
14921 + #define default_param_perio_tx_fifo_size_07 0
14922 + #define default_param_perio_tx_fifo_size_08 0
14923 + #define default_param_perio_tx_fifo_size_09 0
14924 + #define default_param_perio_tx_fifo_size_10 0
14925 + #define default_param_perio_tx_fifo_size_11 0
14926 + #define default_param_perio_tx_fifo_size_12 0
14927 + #define default_param_perio_tx_fifo_size_13 0
14928 + #define default_param_perio_tx_fifo_size_14 0
14929 + #define default_param_perio_tx_fifo_size_15 0
14930 + #endif //__IS_DEVICE__
14932 + #elif defined(__IS_VR9__)
14933 +// #define IFXUSB1_IRQ 54
14934 + #define IFXUSB1_IOMEM_BASE 0x1E101000
14935 + #define IFXUSB1_FIFOMEM_BASE 0x1E120000
14936 + #define IFXUSB1_FIFODBG_BASE 0x1E140000
14938 +// #define IFXUSB2_IRQ 83
14939 + #define IFXUSB2_IOMEM_BASE 0x1E106000
14940 + #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
14941 + #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
14942 +// #define IFXUSB_OC_IRQ 60
14944 + #ifndef AMAZON_S_RCU_BASE_ADDR
14945 + #define AMAZON_S_RCU_BASE_ADDR (0xBF203000)
14948 + #ifndef AMAZON_S_CGU
14949 + #define AMAZON_S_CGU (0xBF103000)
14951 + #ifndef AMAZON_S_CGU_IFCCR
14952 + #define AMAZON_S_CGU_IFCCR ((volatile unsigned long *)(AMAZON_S_CGU+ 0x0018))
14955 + #ifndef AMAZON_S_PMU
14956 + #define AMAZON_S_PMU (KSEG1+0x1F102000)
14958 + #ifndef AMAZON_S_PMU_PWDCR
14959 + #define AMAZON_S_PMU_PWDCR ((volatile unsigned long *)(AMAZON_S_PMU+0x001C))
14962 + #ifndef AMAZON_S_GPIO_P0_OUT
14963 + #define AMAZON_S_GPIO_P0_OUT (0xBF103000+0x10)
14964 + #define AMAZON_S_GPIO_P0_DIR (0xBF103000+0x18)
14965 + #define AMAZON_S_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
14966 + #define AMAZON_S_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
14967 + #define AMAZON_S_GPIO_P0_OD (0xBF103000+0x24)
14968 + #define AMAZON_S_GPIO_P0_PUDSEL (0xBF103000+0x2C)
14969 + #define AMAZON_S_GPIO_P0_PUDEN (0xBF103000+0x30)
14970 + #define AMAZON_S_GPIO_P1_OUT (0xBF103000+0x40)
14971 + #define AMAZON_S_GPIO_P1_DIR (0xBF103000+0x48)
14972 + #define AMAZON_S_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
14973 + #define AMAZON_S_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
14974 + #define AMAZON_S_GPIO_P1_OD (0xBF103000+0x54)
14975 + #define AMAZON_S_GPIO_P1_PUDSEL (0xBF103000+0x5C)
14976 + #define AMAZON_S_GPIO_P1_PUDEN (0xBF103000+0x60)
14979 + #define AMAZON_S_RCU_USB1CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x18))
14980 + #define AMAZON_S_RCU_USB2CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x34))
14981 + #define AMAZON_S_RCU_USBRESET ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x10))
14982 + #define AMAZON_S_USBCFG_ARB 7 //
14983 + #define AMAZON_S_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
14984 + #define AMAZON_S_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
14985 + #define AMAZON_S_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
14987 + #define default_param_dma_burst_size 4 //(ALL)
14989 + #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
14991 + #define default_param_max_transfer_size -1 //(Max, hwcfg)
14992 + #define default_param_max_packet_count -1 //(Max, hwcfg)
14993 + #define default_param_phy_utmi_width 16
14995 + #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
14996 + #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
14997 + #define default_param_timeout_cal_hs -1 //(NoChange)
14998 + #define default_param_timeout_cal_fs -1 //(NoChange)
15000 + #define default_param_data_fifo_size -1 //(Max, hwcfg)
15002 + #ifdef __IS_HOST__
15003 + #define default_param_host_channels -1 //(Max, hwcfg)
15004 + #define default_param_rx_fifo_size 240
15005 + #define default_param_nperio_tx_fifo_size 240
15006 + #define default_param_perio_tx_fifo_size 32
15007 + #endif //__IS_HOST__
15008 + #ifdef __IS_DEVICE__
15009 + #define default_param_rx_fifo_size 256
15010 + #define default_param_tx_fifo_size_00 -1
15011 + #define default_param_tx_fifo_size_01 -1
15012 + #define default_param_tx_fifo_size_02 -1
15013 + #define default_param_tx_fifo_size_03 -1
15014 + #define default_param_tx_fifo_size_04 -1
15015 + #define default_param_tx_fifo_size_05 -1
15016 + #define default_param_tx_fifo_size_06 -1
15017 + #define default_param_tx_fifo_size_07 -1
15018 + #define default_param_tx_fifo_size_08 -1
15019 + #define default_param_tx_fifo_size_09 -1
15020 + #define default_param_tx_fifo_size_10 -1
15021 + #define default_param_tx_fifo_size_11 -1
15022 + #define default_param_tx_fifo_size_12 -1
15023 + #define default_param_tx_fifo_size_13 -1
15024 + #define default_param_tx_fifo_size_14 -1
15025 + #define default_param_tx_fifo_size_15 -1
15026 + #define default_param_dma_unalgned_tx -1
15027 + #define default_param_dma_unalgned_rx -1
15028 + #define default_param_thr_ctl -1
15029 + #define default_param_tx_thr_length -1
15030 + #define default_param_rx_thr_length -1
15031 + #endif //__IS_DEVICE__
15032 + #else // __IS_VR9__
15033 + #error "Please choose one platform!!"
15034 + #endif // __IS_VR9__
15037 +/*@}*//*IFXUSB_PLATEFORM_MEM_ADDR*/
15039 +/////////////////////////////////////////////////////////////////////////
15041 +#ifdef __IS_HOST__
15042 + #ifdef CONFIG_USB_HOST_IFX_FORCE_USB11
15043 + #undef default_param_speed
15044 + #define default_param_speed IFXUSB_PARAM_SPEED_FULL
15047 +#ifdef __IS_DEVICE__
15048 + #ifndef CONFIG_USB_GADGET_DUALSPEED
15049 + #undef default_param_speed
15050 + #define default_param_speed IFXUSB_PARAM_SPEED_FULL
15054 +/////////////////////////////////////////////////////////////////////////
15056 +static __inline__ void UDELAY( const uint32_t _usecs )
15058 + udelay( _usecs );
15061 +static __inline__ void MDELAY( const uint32_t _msecs )
15063 + mdelay( _msecs );
15066 +static __inline__ void SPIN_LOCK( spinlock_t *_lock )
15068 + spin_lock(_lock);
15071 +static __inline__ void SPIN_UNLOCK( spinlock_t *_lock )
15073 + spin_unlock(_lock);
15076 +#define SPIN_LOCK_IRQSAVE( _l, _f ) \
15078 + spin_lock_irqsave(_l,_f); \
15081 +#define SPIN_UNLOCK_IRQRESTORE( _l,_f ) \
15083 + spin_unlock_irqrestore(_l,_f); \
15086 +/////////////////////////////////////////////////////////////////////////
15088 + \addtogroup IFXUSB_DBG_ROUTINE
15091 +#ifdef __IS_HOST__
15092 + extern uint32_t h_dbg_lvl;
15095 +#ifdef __IS_DEVICE__
15096 + extern uint32_t d_dbg_lvl;
15099 +/*! \brief When debug level has the DBG_CIL bit set, display CIL Debug messages. */
15100 +#define DBG_CIL (0x2)
15101 +/*! \brief When debug level has the DBG_CILV bit set, display CIL Verbose debug messages */
15102 +#define DBG_CILV (0x20)
15103 +/*! \brief When debug level has the DBG_PCD bit set, display PCD (Device) debug messages */
15104 +#define DBG_PCD (0x4)
15105 +/*! \brief When debug level has the DBG_PCDV set, display PCD (Device) Verbose debug messages */
15106 +#define DBG_PCDV (0x40)
15107 +/*! \brief When debug level has the DBG_HCD bit set, display Host debug messages */
15108 +#define DBG_HCD (0x8)
15109 +/*! \brief When debug level has the DBG_HCDV bit set, display Verbose Host debug messages */
15110 +#define DBG_HCDV (0x80)
15111 +/*! \brief When debug level has the DBG_HCD_URB bit set, display enqueued URBs in host mode. */
15112 +#define DBG_HCD_URB (0x800)
15113 +/*! \brief When debug level has any bit set, display debug messages */
15114 +#define DBG_ANY (0xFF)
15115 +/*! \brief All debug messages off */
15118 +#define DBG_ENTRY (0x8000)
15120 +#define IFXUSB "IFXUSB: "
15123 + \fn inline uint32_t SET_DEBUG_LEVEL( const uint32_t _new )
15124 + \brief Set the Debug Level variable.
15125 + \param _new 32-bit mask of debug level.
15126 + \return previous debug level
15128 +static inline uint32_t SET_DEBUG_LEVEL( const uint32_t _new )
15130 + #ifdef __IS_HOST__
15131 + uint32_t old = h_dbg_lvl;
15132 + h_dbg_lvl = _new;
15135 + #ifdef __IS_DEVICE__
15136 + uint32_t old = d_dbg_lvl;
15137 + d_dbg_lvl = _new;
15143 + #ifdef __IS_HOST__
15144 + # define IFX_DEBUGPL(lvl, x...) do{ if ((lvl)&h_dbg_lvl)printk( KERN_DEBUG IFXUSB x ); }while(0)
15145 + # define CHK_DEBUG_LEVEL(level) ((level) & h_dbg_lvl)
15148 + #ifdef __IS_DEVICE__
15149 + # define IFX_DEBUGPL(lvl, x...) do{ if ((lvl)&d_dbg_lvl)printk( KERN_DEBUG IFXUSB x ); }while(0)
15150 + # define CHK_DEBUG_LEVEL(level) ((level) & d_dbg_lvl)
15153 + # define IFX_DEBUGP(x...) IFX_DEBUGPL(DBG_ANY, x )
15155 + # define IFX_DEBUGPL(lvl, x...) do{}while(0)
15156 + # define IFX_DEBUGP(x...)
15157 + # define CHK_DEBUG_LEVEL(level) (0)
15158 +#endif //__DEBUG__
15160 +/* Print an Error message. */
15161 +#define IFX_ERROR(x...) printk( KERN_ERR IFXUSB x )
15162 +/* Print a Warning message. */
15163 +#define IFX_WARN(x...) printk( KERN_WARNING IFXUSB x )
15164 +/* Print a notice (normal but significant message). */
15165 +#define IFX_NOTICE(x...) printk( KERN_NOTICE IFXUSB x )
15166 +/* Basic message printing. */
15167 +#define IFX_PRINT(x...) printk( KERN_INFO IFXUSB x )
15169 +/*@}*//*IFXUSB_DBG_ROUTINE*/
15172 +#endif //__IFXUSB_PLAT_H__
15175 +++ b/drivers/usb/ifxhcd/ifxusb_regs.h
15177 +/*****************************************************************************
15178 + ** FILE NAME : ifxusb_regs.h
15179 + ** PROJECT : IFX USB sub-system V3
15180 + ** MODULES : IFX USB sub-system Host and Device driver
15181 + ** SRC VERSION : 1.0
15182 + ** DATE : 1/Jan/2009
15183 + ** AUTHOR : Chen, Howard
15184 + ** DESCRIPTION : This file contains the data structures for accessing the IFXUSB core
15186 + ** The application interfaces with the USB core by reading from and
15187 + ** writing to the Control and Status Register (CSR) space through the
15188 + ** AHB Slave interface. These registers are 32 bits wide, and the
15189 + ** addresses are 32-bit-block aligned.
15190 + ** CSRs are classified as follows:
15191 + ** - Core Global Registers
15192 + ** - Device Mode Registers
15193 + ** - Device Global Registers
15194 + ** - Device Endpoint Specific Registers
15195 + ** - Host Mode Registers
15196 + ** - Host Global Registers
15197 + ** - Host Port CSRs
15198 + ** - Host Channel Specific Registers
15200 + ** Only the Core Global registers can be accessed in both Device and
15201 + ** Host modes. When the USB core is operating in one mode, either
15202 + ** Device or Host, the application must not access registers from the
15203 + ** other mode. When the core switches from one mode to another, the
15204 + ** registers in the new mode of operation must be reprogrammed as they
15205 + ** would be after a power-on reset.
15207 + ** COMPILER : gcc
15208 + ** REFERENCE : Synopsys DWC-OTG Driver 2.7
15210 + ** Version Control Section **
15214 + ** $Log$ Revision history
15215 +*****************************************************************************/
15220 + \defgroup IFXUSB_CSR_DEFINITION Control and Status Register bit-map definition
15221 + \ingroup IFXUSB_DRIVER_V3
15222 + \brief Data structures for accessing the IFXUSB core registers.
15223 + The application interfaces with the USB core by reading from and
15224 + writing to the Control and Status Register (CSR) space through the
15225 + AHB Slave interface. These registers are 32 bits wide, and the
15226 + addresses are 32-bit-block aligned.
15227 + CSRs are classified as follows:
15228 + - Core Global Registers
15229 + - Device Mode Registers
15230 + - Device Global Registers
15231 + - Device Endpoint Specific Registers
15232 + - Host Mode Registers
15233 + - Host Global Registers
15235 + - Host Channel Specific Registers
15237 + Only the Core Global registers can be accessed in both Device andHost modes.
15238 + When the USB core is operating in one mode, either Device or Host, the
15239 + application must not access registers from the other mode. When the core
15240 + switches from one mode to another, the registers in the new mode of operation
15241 + must be reprogrammed as they would be after a power-on reset.
15245 + \defgroup IFXUSB_CSR_DEVICE_GLOBAL_REG Device Mode Registers
15246 + \ingroup IFXUSB_CSR_DEFINITION
15247 + \brief Bit-mapped structure to access Device Mode Global Registers
15251 + \defgroup IFXUSB_CSR_DEVICE_EP_REG Device Mode EP Registers
15252 + \ingroup IFXUSB_CSR_DEFINITION
15253 + \brief Bit-mapped structure to access Device Mode EP Registers
15254 + There will be one set of endpoint registers per logical endpoint
15256 + These registers are visible only in Device mode and must not be
15257 + accessed in Host mode, as the results are unknown.
15261 + \defgroup IFXUSB_CSR_DEVICE_DMA_DESC Device mode scatter dma descriptor strusture
15262 + \ingroup IFXUSB_CSR_DEFINITION
15263 + \brief Bit-mapped structure to DMA descriptor
15268 + \defgroup IFXUSB_CSR_HOST_GLOBAL_REG Host Mode Registers
15269 + \ingroup IFXUSB_CSR_DEFINITION
15270 + \brief Bit-mapped structure to access Host Mode Global Registers
15274 + \defgroup IFXUSB_CSR_HOST_HC_REG Host Mode HC Registers
15275 + \ingroup IFXUSB_CSR_DEFINITION
15276 + \brief Bit-mapped structure to access Host Mode Host Channel Registers
15277 + There will be one set of endpoint registers per host channel
15279 + These registers are visible only in Host mode and must not be
15280 + accessed in Device mode, as the results are unknown.
15284 + \defgroup IFXUSB_CSR_PWR_CLK_GATING_REG Power and Clock Gating Control Register
15285 + \ingroup IFXUSB_CSR_DEFINITION
15286 + \brief Bit-mapped structure to Power and Clock Gating Control Register
15297 + \defgroup IFXUSB_CSR_CORE_GLOBAL_REG Core Global Registers
15298 + \ingroup IFXUSB_CSR_DEFINITION
15299 + \brief Bit-mapped structure to access Core Global Registers
15302 + \defgroup IFXUSB_CSR_CORE_GLOBAL_REG Core Global Registers
15303 + \ingroup IFXUSB_CSR_DEFINITION
15304 + \brief Bit-mapped structure to access Core Global Registers
15316 + \file ifxusb_regs.h
15317 + \ingroup IFXUSB_DRIVER_V3
15318 + \brief This file contains the data structures for accessing the IFXUSB core registers.
15322 +#ifndef __IFXUSB_REGS_H__
15323 +#define __IFXUSB_REGS_H__
15325 +/****************************************************************************/
15327 +#define MAX_PERIO_FIFOS 15 /** Maximum number of Periodic FIFOs */
15328 +#define MAX_TX_FIFOS 15 /** Maximum number of Periodic FIFOs */
15329 +#define MAX_EPS_CHANNELS 16 /** Maximum number of Endpoints/HostChannels */
15331 +/****************************************************************************/
15334 + \addtogroup IFXUSB_CSR_ACCESS_MACROS
15338 +//#define RecordRegRW
15341 + \fn static __inline__ uint32_t ifxusb_rreg( volatile uint32_t *_reg)
15342 + \brief Reads the content of a register.
15343 + \param _reg address of register to read.
15344 + \return contents of the register.
15346 +static __inline__ uint32_t ifxusb_rreg( volatile uint32_t *_reg)
15348 + #ifdef RecordRegRW
15353 + return (*(_reg));
15359 + \fn static __inline__ void ifxusb_wreg( volatile uint32_t *_reg, const uint32_t _value)
15360 + \brief Writes a register with a 32 bit value.
15361 + \param _reg address of register to write.
15362 + \param _value value to write to _reg.
15364 +static __inline__ void ifxusb_wreg( volatile uint32_t *_reg, const uint32_t _value)
15366 + #ifdef RecordRegRW
15367 + printk(KERN_INFO "[W %p<-%08X]\n",_reg,_value);
15374 + \fn static __inline__ void ifxusb_mreg( volatile uint32_t *_reg, const uint32_t _clear_mask, const uint32_t _set_mask)
15375 + \brief Modifies bit values in a register. Using the
15376 + algorithm: (reg_contents & ~clear_mask) | set_mask.
15377 + \param _reg address of register to modify.
15378 + \param _clear_mask bit mask to be cleared.
15379 + \param _set_mask bit mask to be set.
15381 +static __inline__ void ifxusb_mreg( volatile uint32_t *_reg, const uint32_t _clear_mask, const uint32_t _set_mask)
15384 + #ifdef RecordRegRW
15388 + r&=(~_clear_mask);
15391 + printk(KERN_INFO "[M %p->%08X+%08X/%08X<-%08X]\n",_reg,r,_clear_mask,_set_mask,r);
15394 + v&=(~_clear_mask);
15400 +/*@}*//*IFXUSB_CSR_ACCESS_MACROS*/
15401 +/****************************************************************************/
15404 + \addtogroup IFXUSB_CSR_CORE_GLOBAL_REG
15409 + \struct ifxusb_core_global_regs
15410 + \brief IFXUSB Core registers .
15411 + The ifxusb_core_global_regs structure defines the size
15412 + and relative field offsets for the Core Global registers.
15414 +typedef struct ifxusb_core_global_regs
15416 + volatile uint32_t gotgctl; /*!< 000h OTG Control and Status Register. */
15417 + volatile uint32_t gotgint; /*!< 004h OTG Interrupt Register. */
15418 + volatile uint32_t gahbcfg; /*!< 008h Core AHB Configuration Register. */
15419 + volatile uint32_t gusbcfg; /*!< 00Ch Core USB Configuration Register. */
15420 + volatile uint32_t grstctl; /*!< 010h Core Reset Register. */
15421 + volatile uint32_t gintsts; /*!< 014h Core Interrupt Register. */
15422 + volatile uint32_t gintmsk; /*!< 018h Core Interrupt Mask Register. */
15423 + volatile uint32_t grxstsr; /*!< 01Ch Receive Status Queue Read Register (Read Only). */
15424 + volatile uint32_t grxstsp; /*!< 020h Receive Status Queue Read & POP Register (Read Only). */
15425 + volatile uint32_t grxfsiz; /*!< 024h Receive FIFO Size Register. */
15426 + volatile uint32_t gnptxfsiz; /*!< 028h Non Periodic Transmit FIFO Size Register. */
15427 + volatile uint32_t gnptxsts; /*!< 02Ch Non Periodic Transmit FIFO/Queue Status Register (Read Only). */
15428 + volatile uint32_t gi2cctl; /*!< 030h I2C Access Register. */
15429 + volatile uint32_t gpvndctl; /*!< 034h PHY Vendor Control Register. */
15430 + volatile uint32_t ggpio; /*!< 038h General Purpose Input/Output Register. */
15431 + volatile uint32_t guid; /*!< 03Ch User ID Register. */
15432 + volatile uint32_t gsnpsid; /*!< 040h Synopsys ID Register (Read Only). */
15433 + volatile uint32_t ghwcfg1; /*!< 044h User HW Config1 Register (Read Only). */
15434 + volatile uint32_t ghwcfg2; /*!< 048h User HW Config2 Register (Read Only). */
15435 + volatile uint32_t ghwcfg3; /*!< 04Ch User HW Config3 Register (Read Only). */
15436 + volatile uint32_t ghwcfg4; /*!< 050h User HW Config4 Register (Read Only). */
15437 + volatile uint32_t reserved[43]; /*!< 054h Reserved 054h-0FFh */
15438 + volatile uint32_t hptxfsiz; /*!< 100h Host Periodic Transmit FIFO Size Register. */
15439 + volatile uint32_t dptxfsiz_dieptxf[15];/*!< 104h + (FIFO_Number-1)*04h, 1 <= FIFO Number <= 15.
15440 + Device Periodic Transmit FIFO#n Register if dedicated
15441 + fifos are disabled, otherwise Device Transmit FIFO#n
15444 +} ifxusb_core_global_regs_t;
15447 + \brief Bits of the Core OTG Control and Status Register (GOTGCTL).
15449 +typedef union gotgctl_data
15453 + unsigned reserved21_31 : 11;
15454 + unsigned currmod : 1 ; /*!< 20 */
15455 + unsigned bsesvld : 1 ; /*!< 19 */
15456 + unsigned asesvld : 1 ; /*!< 18 */
15457 + unsigned reserved17 : 1 ;
15458 + unsigned conidsts : 1 ; /*!< 16 */
15459 + unsigned reserved12_15 : 4 ;
15460 + unsigned devhnpen : 1 ; /*!< 11 */
15461 + unsigned hstsethnpen : 1 ; /*!< 10 */
15462 + unsigned hnpreq : 1 ; /*!< 09 */
15463 + unsigned hstnegscs : 1 ; /*!< 08 */
15464 + unsigned reserved2_7 : 6 ;
15465 + unsigned sesreq : 1 ; /*!< 01 */
15466 + unsigned sesreqscs : 1 ; /*!< 00 */
15471 + \brief Bit fields of the Core OTG Interrupt Register (GOTGINT).
15473 +typedef union gotgint_data
15478 + unsigned reserved31_20 : 12;
15479 + unsigned debdone : 1 ; /*!< 19 Debounce Done */
15480 + unsigned adevtoutchng : 1 ; /*!< 18 A-Device Timeout Change */
15481 + unsigned hstnegdet : 1 ; /*!< 17 Host Negotiation Detected */
15482 + unsigned reserver10_16 : 7 ;
15483 + unsigned hstnegsucstschng : 1 ; /*!< 09 Host Negotiation Success Status Change */
15484 + unsigned sesreqsucstschng : 1 ; /*!< 08 Session Request Success Status Change */
15485 + unsigned reserved3_7 : 5 ;
15486 + unsigned sesenddet : 1 ; /*!< 02 Session End Detected */
15487 + unsigned reserved0_1 : 2 ;
15492 + \brief Bit fields of the Core AHB Configuration Register (GAHBCFG).
15494 +typedef union gahbcfg_data
15499 + unsigned reserved9_31 : 23;
15500 + unsigned ptxfemplvl : 1 ; /*!< 08 Periodic FIFO empty level trigger condition*/
15501 + unsigned nptxfemplvl : 1 ; /*!< 07 Non-Periodic FIFO empty level trigger condition*/
15502 + #define IFXUSB_GAHBCFG_TXFEMPTYLVL_EMPTY 1
15503 + #define IFXUSB_GAHBCFG_TXFEMPTYLVL_HALFEMPTY 0
15504 + unsigned reserved : 1 ;
15505 + unsigned dmaenable : 1 ; /*!< 05 DMA enable*/
15506 + #define IFXUSB_GAHBCFG_DMAENABLE 1
15507 + unsigned hburstlen : 4 ; /*!< 01-04 DMA Burst-length*/
15508 + #define IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE 0
15509 + #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR 1
15510 + #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4 3
15511 + #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8 5
15512 + #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16 7
15513 + unsigned glblintrmsk : 1 ; /*!< 00 USB Global Interrupt Enable */
15514 + #define IFXUSB_GAHBCFG_GLBINT_ENABLE 1
15519 + \brief Bit fields of the Core USB Configuration Register (GUSBCFG).
15521 +typedef union gusbcfg_data
15526 + unsigned reserved31 : 1;
15527 + unsigned ForceDevMode : 1; /*!< 30 Force Device Mode */
15528 + unsigned ForceHstMode : 1; /*!< 29 Force Host Mode */
15529 + unsigned TxEndDelay : 1; /*!< 28 Tx End Delay */
15530 + unsigned reserved2723 : 5;
15531 + unsigned term_sel_dl_pulse : 1; /*!< 22 TermSel DLine Pulsing Selection */
15532 + unsigned reserved2117 : 5;
15533 + unsigned otgutmifssel : 1; /*!< 16 UTMIFS Select */
15534 + unsigned phylpwrclksel : 1; /*!< 15 PHY Low-Power Clock Select */
15535 + unsigned reserved14 : 1;
15536 + unsigned usbtrdtim : 4; /*!< 13-10 USB Turnaround Time */
15537 + unsigned hnpcap : 1; /*!< 09 HNP-Capable */
15538 + unsigned srpcap : 1; /*!< 08 SRP-Capable */
15539 + unsigned reserved07 : 1;
15540 + unsigned physel : 1; /*!< 06 USB 2.0 High-Speed PHY or
15541 + USB 1.1 Full-Speed Serial
15542 + Transceiver Select */
15543 + unsigned fsintf : 1; /*!< 05 Full-Speed Serial Interface Select */
15544 + unsigned ulpi_utmi_sel : 1; /*!< 04 ULPI or UTMI+ Select */
15545 + unsigned phyif : 1; /*!< 03 PHY Interface */
15546 + unsigned toutcal : 3; /*!< 00-02 HS/FS Timeout Calibration */
15551 + \brief Bit fields of the Core Reset Register (GRSTCTL).
15553 +typedef union grstctl_data
15558 + unsigned ahbidle : 1; /*!< 31 AHB Master Idle. Indicates the AHB Master State
15559 + Machine is in IDLE condition. */
15560 + unsigned dmareq : 1; /*!< 30 DMA Request Signal. Indicated DMA request is in
15561 + probress. Used for debug purpose. */
15562 + unsigned reserved11_29 :19;
15563 + unsigned txfnum : 5; /*!< 10-06 TxFIFO Number (TxFNum) to be flushed.
15564 + 0x00: Non Periodic TxFIFO Flush or TxFIFO 0
15565 + 0x01-0x0F: Periodic TxFIFO Flush or TxFIFO n
15566 + 0x10: Flush all TxFIFO
15568 + unsigned txfflsh : 1; /*!< 05 TxFIFO Flush */
15569 + unsigned rxfflsh : 1; /*!< 04 RxFIFO Flush */
15570 + unsigned intknqflsh : 1; /*!< 03 In Token Sequence Learning Queue Flush (Device Only) */
15571 + unsigned hstfrm : 1; /*!< 02 Host Frame Counter Reset (Host Only) */
15572 + unsigned hsftrst : 1; /*!< 01 Hclk Soft Reset */
15574 + unsigned csftrst : 1; /*!< 00 Core Soft Reset
15575 + The application can flush the control logic in the
15576 + entire core using this bit. This bit resets the
15577 + pipelines in the AHB Clock domain as well as the
15578 + PHY Clock domain.
15579 + The state machines are reset to an IDLE state, the
15580 + control bits in the CSRs are cleared, all the
15581 + transmit FIFOs and the receive FIFO are flushed.
15582 + The status mask bits that control the generation of
15583 + the interrupt, are cleared, to clear the
15584 + interrupt. The interrupt status bits are not
15585 + cleared, so the application can get the status of
15586 + any events that occurred in the core after it has
15588 + Any transactions on the AHB are terminated as soon
15589 + as possible following the protocol. Any
15590 + transactions on the USB are terminated immediately.
15591 + The configuration settings in the CSRs are
15592 + unchanged, so the software doesn't have to
15593 + reprogram these registers (Device
15594 + Configuration/Host Configuration/Core System
15595 + Configuration/Core PHY Configuration).
15596 + The application can write to this bit, any time it
15597 + wants to reset the core. This is a self clearing
15598 + bit and the core clears this bit after all the
15599 + necessary logic is reset in the core, which may
15600 + take several clocks, depending on the current state
15607 + \brief Bit fields of the Core Interrupt Mask Register (GINTMSK) and
15608 + Core Interrupt Register (GINTSTS).
15610 +typedef union gint_data
15613 + #define IFXUSB_SOF_INTR_MASK 0x0008
15616 + unsigned wkupintr : 1; /*!< 31 Resume/Remote Wakeup Detected Interrupt */
15617 + unsigned sessreqintr : 1; /*!< 30 Session Request/New Session Detected Interrupt */
15618 + unsigned disconnect : 1; /*!< 29 Disconnect Detected Interrupt */
15619 + unsigned conidstschng : 1; /*!< 28 Connector ID Status Change */
15620 + unsigned reserved27 : 1;
15621 + unsigned ptxfempty : 1; /*!< 26 Periodic TxFIFO Empty */
15622 + unsigned hcintr : 1; /*!< 25 Host Channels Interrupt */
15623 + unsigned portintr : 1; /*!< 24 Host Port Interrupt */
15624 + unsigned reserved23 : 1;
15625 + unsigned fetsuspmsk : 1; /*!< 22 Data Fetch Suspended */
15626 + unsigned incomplisoout : 1; /*!< 21 Incomplete IsochronousOUT/Period Transfer */
15627 + unsigned incomplisoin : 1; /*!< 20 Incomplete Isochronous IN Transfer */
15628 + unsigned outepintr : 1; /*!< 19 OUT Endpoints Interrupt */
15629 + unsigned inepintr : 1; /*!< 18 IN Endpoints Interrupt */
15630 + unsigned epmismatch : 1; /*!< 17 Endpoint Mismatch Interrupt */
15631 + unsigned reserved16 : 1;
15632 + unsigned eopframe : 1; /*!< 15 End of Periodic Frame Interrupt */
15633 + unsigned isooutdrop : 1; /*!< 14 Isochronous OUT Packet Dropped Interrupt */
15634 + unsigned enumdone : 1; /*!< 13 Enumeration Done */
15635 + unsigned usbreset : 1; /*!< 12 USB Reset */
15636 + unsigned usbsuspend : 1; /*!< 11 USB Suspend */
15637 + unsigned erlysuspend : 1; /*!< 10 Early Suspend */
15638 + unsigned i2cintr : 1; /*!< 09 I2C Interrupt */
15639 + unsigned reserved8 : 1;
15640 + unsigned goutnakeff : 1; /*!< 07 Global OUT NAK Effective */
15641 + unsigned ginnakeff : 1; /*!< 06 Global Non-periodic IN NAK Effective */
15642 + unsigned nptxfempty : 1; /*!< 05 Non-periodic TxFIFO Empty */
15643 + unsigned rxstsqlvl : 1; /*!< 04 Receive FIFO Non-Empty */
15644 + unsigned sofintr : 1; /*!< 03 Start of (u)Frame */
15645 + unsigned otgintr : 1; /*!< 02 OTG Interrupt */
15646 + unsigned modemismatch : 1; /*!< 01 Mode Mismatch Interrupt */
15647 + unsigned reserved0 : 1;
15652 + \brief Bit fields in the Receive Status Read and Pop Registers (GRXSTSR, GRXSTSP)
15654 +typedef union grxsts_data
15659 + unsigned reserved : 7;
15660 + unsigned fn : 4; /*!< 24-21 Frame Number */
15661 + unsigned pktsts : 4; /*!< 20-17 Packet Status */
15662 + #define IFXUSB_DSTS_DATA_UPDT 0x2 // OUT Data Packet
15663 + #define IFXUSB_DSTS_XFER_COMP 0x3 // OUT Data Transfer Complete
15664 + #define IFXUSB_DSTS_GOUT_NAK 0x1 // Global OUT NAK
15665 + #define IFXUSB_DSTS_SETUP_COMP 0x4 // Setup Phase Complete
15666 + #define IFXUSB_DSTS_SETUP_UPDT 0x6 // SETUP Packet
15667 + unsigned dpid : 2; /*!< 16-15 Data PID */
15668 + unsigned bcnt :11; /*!< 14-04 Byte Count */
15669 + unsigned epnum : 4; /*!< 03-00 Endpoint Number */
15673 + unsigned reserved :11;
15674 + unsigned pktsts : 4; /*!< 20-17 Packet Status */
15675 + #define IFXUSB_HSTS_DATA_UPDT 0x2 // OUT Data Packet
15676 + #define IFXUSB_HSTS_XFER_COMP 0x3 // OUT Data Transfer Complete
15677 + #define IFXUSB_HSTS_DATA_TOGGLE_ERR 0x5 // DATA TOGGLE Error
15678 + #define IFXUSB_HSTS_CH_HALTED 0x7 // Channel Halted
15679 + unsigned dpid : 2; /*!< 16-15 Data PID */
15680 + unsigned bcnt :11; /*!< 14-04 Byte Count */
15681 + unsigned chnum : 4; /*!< 03-00 Channel Number */
15686 + \brief Bit fields in the FIFO Size Registers (HPTXFSIZ, GNPTXFSIZ, DPTXFSIZn).
15688 +typedef union fifosize_data
15693 + unsigned depth : 16; /*!< 31-16 TxFIFO Depth (in DWord)*/
15694 + unsigned startaddr : 16; /*!< 15-00 RAM Starting address */
15696 +} fifosize_data_t;
15699 + \brief Bit fields in the Non-Periodic Transmit FIFO/Queue Status Register (GNPTXSTS).
15702 +typedef union gnptxsts_data
15707 + unsigned reserved : 1;
15708 + unsigned nptxqtop_chnep : 4; /*!< 30-27 Channel/EP Number of top of the Non-Periodic
15709 + Transmit Request Queue
15711 + unsigned nptxqtop_token : 2; /*!< 26-25 Token Type top of the Non-Periodic
15712 + Transmit Request Queue
15714 + 1 - Zero Length OUT
15715 + 2 - PING/Complete Split
15718 + unsigned nptxqtop_terminate : 1; /*!< 24 Terminate (Last entry for the selected
15720 + unsigned nptxqspcavail : 8; /*!< 23-16 Transmit Request Queue Space Available */
15721 + unsigned nptxfspcavail :16; /*!< 15-00 TxFIFO Space Avail (in DWord)*/
15723 +} gnptxsts_data_t;
15727 + \brief Bit fields in the Transmit FIFO Status Register (DTXFSTS).
15729 +typedef union dtxfsts_data
15734 + unsigned reserved : 16;
15735 + unsigned txfspcavail : 16; /*!< 15-00 TxFIFO Space Avail (in DWord)*/
15741 + \brief Bit fields in the I2C Control Register (I2CCTL).
15743 +typedef union gi2cctl_data
15748 + unsigned bsydne : 1; /*!< 31 I2C Busy/Done*/
15749 + unsigned rw : 1; /*!< 30 Read/Write Indicator */
15750 + unsigned reserved : 2;
15751 + unsigned i2cdevaddr : 2; /*!< 27-26 I2C Device Address */
15752 + unsigned i2csuspctl : 1; /*!< 25 I2C Suspend Control */
15753 + unsigned ack : 1; /*!< 24 I2C ACK */
15754 + unsigned i2cen : 1; /*!< 23 I2C Enable */
15755 + unsigned addr : 7; /*!< 22-16 I2C Address */
15756 + unsigned regaddr : 8; /*!< 15-08 I2C Register Addr */
15757 + unsigned rwdata : 8; /*!< I2C Read/Write Data */
15763 + \brief Bit fields in the User HW Config1 Register.
15765 +typedef union hwcfg1_data
15770 + unsigned ep_dir15 : 2; /*!< Direction of each EP
15771 + 0: BIDIR (IN and OUT) endpoint
15776 + unsigned ep_dir14 : 2;
15777 + unsigned ep_dir13 : 2;
15778 + unsigned ep_dir12 : 2;
15779 + unsigned ep_dir11 : 2;
15780 + unsigned ep_dir10 : 2;
15781 + unsigned ep_dir09 : 2;
15782 + unsigned ep_dir08 : 2;
15783 + unsigned ep_dir07 : 2;
15784 + unsigned ep_dir06 : 2;
15785 + unsigned ep_dir05 : 2;
15786 + unsigned ep_dir04 : 2;
15787 + unsigned ep_dir03 : 2;
15788 + unsigned ep_dir02 : 2;
15789 + unsigned ep_dir01 : 2;
15790 + unsigned ep_dir00 : 2;
15795 + \brief Bit fields in the User HW Config2 Register.
15797 +typedef union hwcfg2_data
15802 + unsigned reserved31 : 1;
15803 + unsigned dev_token_q_depth : 5; /*!< 30-26 Device Mode IN Token Sequence Learning Queue Depth */
15804 + unsigned host_perio_tx_q_depth : 2; /*!< 25-24 Host Mode Periodic Request Queue Depth */
15805 + unsigned nonperio_tx_q_depth : 2; /*!< 23-22 Non-periodic Request Queue Depth */
15806 + unsigned rx_status_q_depth : 2; /*!< 21-20 Multi Processor Interrupt Enabled */
15807 + unsigned dynamic_fifo : 1; /*!< 19 Dynamic FIFO Sizing Enabled */
15808 + unsigned perio_ep_supported : 1; /*!< 18 Periodic OUT Channels Supported in Host Mode */
15809 + unsigned num_host_chan : 4; /*!< 17-14 Number of Host Channels */
15810 + unsigned num_dev_ep : 4; /*!< 13-10 Number of Device Endpoints */
15811 + unsigned fs_phy_type : 2; /*!< 09-08 Full-Speed PHY Interface Type */
15812 + #define IFXUSB_HWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0
15813 + #define IFXUSB_HWCFG2_FS_PHY_TYPE_DEDICATE 1
15814 + #define IFXUSB_HWCFG2_FS_PHY_TYPE_UTMI 2
15815 + #define IFXUSB_HWCFG2_FS_PHY_TYPE_ULPI 3
15816 + unsigned hs_phy_type : 2; /*!< 07-06 High-Speed PHY Interface Type */
15817 + #define IFXUSB_HWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0
15818 + #define IFXUSB_HWCFG2_HS_PHY_TYPE_UTMI 1
15819 + #define IFXUSB_HWCFG2_HS_PHY_TYPE_ULPI 2
15820 + #define IFXUSB_HWCFG2_HS_PHY_TYPE_UTMI_ULPI 3
15821 + unsigned point2point : 1; /*!< 05 Point-to-Point */
15822 + unsigned architecture : 2; /*!< 04-03 Architecture */
15823 + #define IFXUSB_HWCFG2_ARCH_SLAVE_ONLY 0
15824 + #define IFXUSB_HWCFG2_ARCH_EXT_DMA 1
15825 + #define IFXUSB_HWCFG2_ARCH_INT_DMA 2
15826 + unsigned op_mode : 3; /*!< 02-00 Mode of Operation */
15827 + #define IFXUSB_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG 0
15828 + #define IFXUSB_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG 1
15829 + #define IFXUSB_HWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE_OTG 2
15830 + #define IFXUSB_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3
15831 + #define IFXUSB_HWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4
15832 + #define IFXUSB_HWCFG2_OP_MODE_SRP_CAPABLE_HOST 5
15833 + #define IFXUSB_HWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6
15838 + \brief Bit fields in the User HW Config3 Register.
15840 +typedef union hwcfg3_data
15845 + unsigned dfifo_depth :16; /*!< 31-16 DFIFO Depth */
15846 + unsigned reserved15_12 : 4;
15847 + unsigned synch_reset_type : 1; /*!< 11 Reset Style for Clocked always Blocks in RTL */
15848 + unsigned optional_features : 1; /*!< 10 Optional Features Removed */
15849 + unsigned vendor_ctrl_if : 1; /*!< 09 Vendor Control Interface Support */
15850 + unsigned i2c : 1; /*!< 08 I2C Selection */
15851 + unsigned otg_func : 1; /*!< 07 OTG Function Enabled */
15852 + unsigned packet_size_cntr_width : 3; /*!< 06-04 Width of Packet Size Counters */
15853 + unsigned xfer_size_cntr_width : 4; /*!< 03-00 Width of Transfer Size Counters */
15858 + \brief Bit fields in the User HW Config4
15859 + * Register. Read the register into the <i>d32</i> element then read
15860 + * out the bits using the <i>b</i>it elements.
15862 +typedef union hwcfg4_data
15867 + unsigned desc_dma_dyn : 1; /*!< 31 Scatter/Gather DMA */
15868 + unsigned desc_dma : 1; /*!< 30 Scatter/Gather DMA configuration */
15869 + unsigned num_in_eps : 4; /*!< 29-26 Number of Device Mode IN Endpoints Including Control Endpoints */
15870 + unsigned ded_fifo_en : 1; /*!< 25 Enable Dedicated Transmit FIFO for device IN Endpoints */
15871 + unsigned session_end_filt_en : 1; /*!< 24 session_end Filter Enabled */
15872 + unsigned b_valid_filt_en : 1; /*!< 23 b_valid Filter Enabled */
15873 + unsigned a_valid_filt_en : 1; /*!< 22 a_valid Filter Enabled */
15874 + unsigned vbus_valid_filt_en : 1; /*!< 21 vbus_valid Filter Enabled */
15875 + unsigned iddig_filt_en : 1; /*!< 20 iddig Filter Enable */
15876 + unsigned num_dev_mode_ctrl_ep : 4; /*!< 19-16 Number of Device Mode Control Endpoints in Addition to Endpoint 0 */
15877 + unsigned utmi_phy_data_width : 2; /*!< 15-14 UTMI+ PHY/ULPI-to-Internal UTMI+ Wrapper Data Width */
15878 + unsigned reserved13_06 : 8;
15879 + unsigned min_ahb_freq : 1; /*!< 05 Minimum AHB Frequency Less Than 60 MHz */
15880 + unsigned power_optimiz : 1; /*!< 04 Enable Power Optimization? */
15881 + unsigned num_dev_perio_in_ep : 4; /*!< 03-00 Number of Device Mode Periodic IN Endpoints */
15885 +/*@}*//*IFXUSB_CSR_CORE_GLOBAL_REG*/
15887 +/****************************************************************************/
15889 + \addtogroup IFXUSB_CSR_DEVICE_GLOBAL_REG
15894 + \struct ifxusb_dev_global_regs
15895 + \brief IFXUSB Device Mode Global registers. Offsets 800h-BFFh
15896 + The ifxusb_dev_global_regs structure defines the size
15897 + and relative field offsets for the Device Global registers.
15898 + These registers are visible only in Device mode and must not be
15899 + accessed in Host mode, as the results are unknown.
15901 +typedef struct ifxusb_dev_global_regs
15903 + volatile uint32_t dcfg; /*!< 800h Device Configuration Register. */
15904 + volatile uint32_t dctl; /*!< 804h Device Control Register. */
15905 + volatile uint32_t dsts; /*!< 808h Device Status Register (Read Only). */
15907 + volatile uint32_t diepmsk; /*!< 810h Device IN Endpoint Common Interrupt Mask Register. */
15908 + volatile uint32_t doepmsk; /*!< 814h Device OUT Endpoint Common Interrupt Mask Register. */
15909 + volatile uint32_t daint; /*!< 818h Device All Endpoints Interrupt Register. */
15910 + volatile uint32_t daintmsk; /*!< 81Ch Device All Endpoints Interrupt Mask Register. */
15911 + volatile uint32_t dtknqr1; /*!< 820h Device IN Token Queue Read Register-1 (Read Only). */
15912 + volatile uint32_t dtknqr2; /*!< 824h Device IN Token Queue Read Register-2 (Read Only). */
15913 + volatile uint32_t dvbusdis; /*!< 828h Device VBUS discharge Register.*/
15914 + volatile uint32_t dvbuspulse; /*!< 82Ch Device VBUS Pulse Register. */
15915 + volatile uint32_t dtknqr3_dthrctl; /*!< 830h Device IN Token Queue Read Register-3 (Read Only).
15916 + Device Thresholding control register (Read/Write)
15918 + volatile uint32_t dtknqr4_fifoemptymsk; /*!< 834h Device IN Token Queue Read Register-4 (Read Only).
15919 + Device IN EPs empty Inr. Mask Register (Read/Write)
15921 +} ifxusb_device_global_regs_t;
15924 + \brief Bit fields in the Device Configuration Register.
15927 +typedef union dcfg_data
15932 + unsigned reserved31_26 : 6;
15933 + unsigned perschintvl : 2; /*!< 25-24 Periodic Scheduling Interval */
15934 + unsigned descdma : 1; /*!< 23 Enable Descriptor DMA in Device mode */
15935 + unsigned epmscnt : 5; /*!< 22-18 In Endpoint Mis-match count */
15936 + unsigned reserved13_17 : 5;
15937 + unsigned perfrint : 2; /*!< 12-11 Periodic Frame Interval */
15938 + #define IFXUSB_DCFG_FRAME_INTERVAL_80 0
15939 + #define IFXUSB_DCFG_FRAME_INTERVAL_85 1
15940 + #define IFXUSB_DCFG_FRAME_INTERVAL_90 2
15941 + #define IFXUSB_DCFG_FRAME_INTERVAL_95 3
15942 + unsigned devaddr : 7; /*!< 10-04 Device Addresses */
15943 + unsigned reserved3 : 1;
15944 + unsigned nzstsouthshk : 1; /*!< 02 Non Zero Length Status OUT Handshake */
15945 + #define IFXUSB_DCFG_SEND_STALL 1
15946 + unsigned devspd : 2; /*!< 01-00 Device Speed */
15951 + \brief Bit fields in the Device Control Register.
15953 +typedef union dctl_data
15958 + unsigned reserved16_31 :16;
15959 + unsigned ifrmnum : 1; /*!< 15 Ignore Frame Number for ISOC EPs */
15960 + unsigned gmc : 2; /*!< 14-13 Global Multi Count */
15961 + unsigned gcontbna : 1; /*!< 12 Global Continue on BNA */
15962 + unsigned pwronprgdone : 1; /*!< 11 Power-On Programming Done */
15963 + unsigned cgoutnak : 1; /*!< 10 Clear Global OUT NAK */
15964 + unsigned sgoutnak : 1; /*!< 09 Set Global OUT NAK */
15965 + unsigned cgnpinnak : 1; /*!< 08 Clear Global Non-Periodic IN NAK */
15966 + unsigned sgnpinnak : 1; /*!< 07 Set Global Non-Periodic IN NAK */
15967 + unsigned tstctl : 3; /*!< 06-04 Test Control */
15968 + unsigned goutnaksts : 1; /*!< 03 Global OUT NAK Status */
15969 + unsigned gnpinnaksts : 1; /*!< 02 Global Non-Periodic IN NAK Status */
15970 + unsigned sftdiscon : 1; /*!< 01 Soft Disconnect */
15971 + unsigned rmtwkupsig : 1; /*!< 00 Remote Wakeup */
15977 + \brief Bit fields in the Device Status Register.
15979 +typedef union dsts_data
15984 + unsigned reserved22_31 :10;
15985 + unsigned soffn :14; /*!< 21-08 Frame or Microframe Number of the received SOF */
15986 + unsigned reserved4_7 : 4;
15987 + unsigned errticerr : 1; /*!< 03 Erratic Error */
15988 + unsigned enumspd : 2; /*!< 02-01 Enumerated Speed */
15989 + #define IFXUSB_DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ 0
15990 + #define IFXUSB_DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ 1
15991 + #define IFXUSB_DSTS_ENUMSPD_LS_PHY_6MHZ 2
15992 + #define IFXUSB_DSTS_ENUMSPD_FS_PHY_48MHZ 3
15993 + unsigned suspsts : 1; /*!< 00 Suspend Status */
15998 + \brief Bit fields in the Device IN EP Interrupt Register
15999 + and the Device IN EP Common Mask Register.
16001 +typedef union diepint_data
16006 + unsigned reserved14_31 :18;
16007 + unsigned nakmsk : 1; /*!< 13 NAK interrupt Mask */
16008 + unsigned reserved10_12 : 3;
16009 + unsigned bna : 1; /*!< 09 BNA Interrupt mask */
16010 + unsigned txfifoundrn : 1; /*!< 08 Fifo Underrun Mask */
16011 + unsigned emptyintr : 1; /*!< 07 IN Endpoint HAK Effective mask */
16012 + unsigned inepnakeff : 1; /*!< 06 IN Endpoint HAK Effective mask */
16013 + unsigned intknepmis : 1; /*!< 05 IN Token Received with EP mismatch mask */
16014 + unsigned intktxfemp : 1; /*!< 04 IN Token received with TxF Empty mask */
16015 + unsigned timeout : 1; /*!< 03 TimeOUT Handshake mask (non-ISOC EPs) */
16016 + unsigned ahberr : 1; /*!< 02 AHB Error mask */
16017 + unsigned epdisabled : 1; /*!< 01 Endpoint disable mask */
16018 + unsigned xfercompl : 1; /*!< 00 Transfer complete mask */
16024 + \brief Bit fields in the Device OUT EP Interrupt Register and
16025 + Device OUT EP Common Interrupt Mask Register.
16027 +typedef union doepint_data
16032 + unsigned reserved15_31 :17;
16033 + unsigned nyetmsk : 1; /*!< 14 NYET Interrupt */
16034 + unsigned nakmsk : 1; /*!< 13 NAK Interrupt */
16035 + unsigned bbleerrmsk : 1; /*!< 12 Babble Interrupt */
16036 + unsigned reserved10_11 : 2;
16037 + unsigned bna : 1; /*!< 09 BNA Interrupt */
16038 + unsigned outpkterr : 1; /*!< 08 OUT packet Error */
16039 + unsigned reserved07 : 1;
16040 + unsigned back2backsetup : 1; /*!< 06 Back-to-Back SETUP Packets Received */
16041 + unsigned stsphsercvd : 1; /*!< 05 */
16042 + unsigned outtknepdis : 1; /*!< 04 OUT Token Received when Endpoint Disabled */
16043 + unsigned setup : 1; /*!< 03 Setup Phase Done (contorl EPs) */
16044 + unsigned ahberr : 1; /*!< 02 AHB Error */
16045 + unsigned epdisabled : 1; /*!< 01 Endpoint disable */
16046 + unsigned xfercompl : 1; /*!< 00 Transfer complete */
16052 + \brief Bit fields in the Device All EP Interrupt Registers.
16054 +typedef union daint_data
16059 + unsigned out : 16; /*!< 31-16 OUT Endpoint bits */
16060 + unsigned in : 16; /*!< 15-00 IN Endpoint bits */
16064 + /** OUT Endpoint bits */
16065 + unsigned outep15 : 1;
16066 + unsigned outep14 : 1;
16067 + unsigned outep13 : 1;
16068 + unsigned outep12 : 1;
16069 + unsigned outep11 : 1;
16070 + unsigned outep10 : 1;
16071 + unsigned outep09 : 1;
16072 + unsigned outep08 : 1;
16073 + unsigned outep07 : 1;
16074 + unsigned outep06 : 1;
16075 + unsigned outep05 : 1;
16076 + unsigned outep04 : 1;
16077 + unsigned outep03 : 1;
16078 + unsigned outep02 : 1;
16079 + unsigned outep01 : 1;
16080 + unsigned outep00 : 1;
16081 + /** IN Endpoint bits */
16082 + unsigned inep15 : 1;
16083 + unsigned inep14 : 1;
16084 + unsigned inep13 : 1;
16085 + unsigned inep12 : 1;
16086 + unsigned inep11 : 1;
16087 + unsigned inep10 : 1;
16088 + unsigned inep09 : 1;
16089 + unsigned inep08 : 1;
16090 + unsigned inep07 : 1;
16091 + unsigned inep06 : 1;
16092 + unsigned inep05 : 1;
16093 + unsigned inep04 : 1;
16094 + unsigned inep03 : 1;
16095 + unsigned inep02 : 1;
16096 + unsigned inep01 : 1;
16097 + unsigned inep00 : 1;
16103 + \brief Bit fields in the Device IN Token Queue Read Registers.
16105 +typedef union dtknq1_data
16110 + unsigned epnums0_5 :24; /*!< 31-08 EP Numbers of IN Tokens 0 ... 4 */
16111 + unsigned wrap_bit : 1; /*!< 07 write pointer has wrapped */
16112 + unsigned reserved05_06 : 2;
16113 + unsigned intknwptr : 5; /*!< 04-00 In Token Queue Write Pointer */
16119 + \brief Bit fields in Threshold control Register
16121 +typedef union dthrctl_data
16126 + unsigned reserved26_31 : 6;
16127 + unsigned rx_thr_len : 9; /*!< 25-17 Rx Thr. Length */
16128 + unsigned rx_thr_en : 1; /*!< 16 Rx Thr. Enable */
16129 + unsigned reserved11_15 : 5;
16130 + unsigned tx_thr_len : 9; /*!< 10-02 Tx Thr. Length */
16131 + unsigned iso_thr_en : 1; /*!< 01 ISO Tx Thr. Enable */
16132 + unsigned non_iso_thr_en : 1; /*!< 00 non ISO Tx Thr. Enable */
16136 +/*@}*//*IFXUSB_CSR_DEVICE_GLOBAL_REG*/
16138 +/****************************************************************************/
16141 + \addtogroup IFXUSB_CSR_DEVICE_EP_REG
16146 + \struct ifxusb_dev_in_ep_regs
16147 + \brief Device Logical IN Endpoint-Specific Registers.
16148 + There will be one set of endpoint registers per logical endpoint
16150 + each EP's IN EP Register are offset at :
16151 + 900h + * (ep_num * 20h)
16154 +typedef struct ifxusb_dev_in_ep_regs
16156 + volatile uint32_t diepctl; /*!< 00h: Endpoint Control Register */
16157 + uint32_t reserved04; /*!< 04h: */
16158 + volatile uint32_t diepint; /*!< 08h: Endpoint Interrupt Register */
16159 + uint32_t reserved0C; /*!< 0Ch: */
16160 + volatile uint32_t dieptsiz; /*!< 10h: Endpoint Transfer Size Register.*/
16161 + volatile uint32_t diepdma; /*!< 14h: Endpoint DMA Address Register. */
16162 + volatile uint32_t dtxfsts; /*!< 18h: Endpoint Transmit FIFO Status Register. */
16163 + volatile uint32_t diepdmab; /*!< 1Ch: Endpoint DMA Buffer Register. */
16164 +} ifxusb_dev_in_ep_regs_t;
16167 + \brief Device Logical OUT Endpoint-Specific Registers.
16168 + There will be one set of endpoint registers per logical endpoint
16170 + each EP's OUT EP Register are offset at :
16171 + B00h + * (ep_num * 20h) + 00h
16173 +typedef struct ifxusb_dev_out_ep_regs
16175 + volatile uint32_t doepctl; /*!< 00h: Endpoint Control Register */
16176 + volatile uint32_t doepfn; /*!< 04h: Endpoint Frame number Register */
16177 + volatile uint32_t doepint; /*!< 08h: Endpoint Interrupt Register */
16178 + uint32_t reserved0C; /*!< 0Ch: */
16179 + volatile uint32_t doeptsiz; /*!< 10h: Endpoint Transfer Size Register.*/
16180 + volatile uint32_t doepdma; /*!< 14h: Endpoint DMA Address Register. */
16181 + uint32_t reserved18; /*!< 18h: */
16182 + volatile uint32_t doepdmab; /*!< 1Ch: Endpoint DMA Buffer Register. */
16183 +} ifxusb_dev_out_ep_regs_t;
16187 + \brief Bit fields in the Device EP Control
16190 +typedef union depctl_data
16195 + unsigned epena : 1; /*!< 31 Endpoint Enable */
16196 + unsigned epdis : 1; /*!< 30 Endpoint Disable */
16197 + unsigned setd1pid : 1; /*!< 29 Set DATA1 PID (INTR/Bulk IN and OUT endpoints) */
16198 + unsigned setd0pid : 1; /*!< 28 Set DATA0 PID (INTR/Bulk IN and OUT endpoints) */
16199 + unsigned snak : 1; /*!< 27 Set NAK */
16200 + unsigned cnak : 1; /*!< 26 Clear NAK */
16201 + unsigned txfnum : 4; /*!< 25-22 Tx Fifo Number */
16202 + unsigned stall : 1; /*!< 21 Stall Handshake */
16203 + unsigned snp : 1; /*!< 20 Snoop Mode */
16204 + unsigned eptype : 2; /*!< 19-18 Endpoint Type
16210 + unsigned naksts : 1; /*!< 17 NAK Status */
16211 + unsigned dpid : 1; /*!< 16 Endpoint DPID (INTR/Bulk IN and OUT endpoints) */
16212 + unsigned usbactep : 1; /*!< 15 USB Active Endpoint */
16213 + unsigned nextep : 4; /*!< 14-11 Next Endpoint */
16214 + unsigned mps :11; /*!< 10-00 Maximum Packet Size */
16215 + #define IFXUSB_DEP0CTL_MPS_64 0
16216 + #define IFXUSB_DEP0CTL_MPS_32 1
16217 + #define IFXUSB_DEP0CTL_MPS_16 2
16218 + #define IFXUSB_DEP0CTL_MPS_8 3
16224 + \brief Bit fields in the Device EP Transfer Size Register. (EP0 and EPn)
16226 +typedef union deptsiz_data
16231 + unsigned reserved31 : 1;
16232 + unsigned supcnt : 2; /*!< 30-29 Setup Packet Count */
16233 + unsigned reserved20_28 : 9;
16234 + unsigned pktcnt : 1; /*!< 19 Packet Count */
16235 + unsigned reserved7_18 :12;
16236 + unsigned xfersize : 7; /*!< 06-00 Transfer size */
16240 + unsigned reserved : 1;
16241 + unsigned mc : 2; /*!< 30-29 Multi Count */
16242 + unsigned pktcnt :10; /*!< 28-19 Packet Count */
16243 + unsigned xfersize :19; /*!< 18-00 Transfer size */
16247 +/*@}*//*IFXUSB_CSR_DEVICE_EP_REG*/
16248 +/****************************************************************************/
16251 + \addtogroup IFXUSB_CSR_DEVICE_DMA_DESC
16255 + \struct desc_sts_data
16256 + \brief Bit fields in the DMA Descriptor status quadlet.
16258 +typedef union desc_sts_data
16262 + unsigned bs : 2; /*!< 31-30 Buffer Status */
16263 + #define BS_HOST_READY 0x0
16264 + #define BS_DMA_BUSY 0x1
16265 + #define BS_DMA_DONE 0x2
16266 + #define BS_HOST_BUSY 0x3
16267 + unsigned sts : 2; /*!< 29-28 Receive/Trasmit Status */
16268 + #define RTS_SUCCESS 0x0
16269 + #define RTS_BUFFLUSH 0x1
16270 + #define RTS_RESERVED 0x2
16271 + #define RTS_BUFERR 0x3
16272 + unsigned l : 1; /*!< 27 Last */
16273 + unsigned sp : 1; /*!< 26 Short Packet */
16274 + unsigned ioc : 1; /*!< 25 Interrupt On Complete */
16275 + unsigned sr : 1; /*!< 24 Setup Packet received */
16276 + unsigned mtrf : 1; /*!< 23 Multiple Transfer */
16277 + unsigned reserved16_22 : 7;
16278 + unsigned bytes :16; /*!< 15-00 Transfer size in bytes */
16280 + uint32_t d32; /*!< DMA Descriptor data buffer pointer */
16281 +} desc_sts_data_t;
16283 +/*@}*//*IFXUSB_CSR_DEVICE_DMA_DESC*/
16284 +/****************************************************************************/
16287 + \addtogroup IFXUSB_CSR_HOST_GLOBAL_REG
16291 + \struct ifxusb_host_global_regs
16292 + \brief IFXUSB Host Mode Global registers. Offsets 400h-7FFh
16293 + The ifxusb_host_global_regs structure defines the size
16294 + and relative field offsets for the Host Global registers.
16295 + These registers are visible only in Host mode and must not be
16296 + accessed in Device mode, as the results are unknown.
16298 +typedef struct ifxusb_host_global_regs
16300 + volatile uint32_t hcfg; /*!< 400h Host Configuration Register. */
16301 + volatile uint32_t hfir; /*!< 404h Host Frame Interval Register. */
16302 + volatile uint32_t hfnum; /*!< 408h Host Frame Number / Frame Remaining Register. */
16303 + uint32_t reserved40C;
16304 + volatile uint32_t hptxsts; /*!< 410h Host Periodic Transmit FIFO/ Queue Status Register. */
16305 + volatile uint32_t haint; /*!< 414h Host All Channels Interrupt Register. */
16306 + volatile uint32_t haintmsk; /*!< 418h Host All Channels Interrupt Mask Register. */
16307 +} ifxusb_host_global_regs_t;
16310 + \brief Bit fields in the Host Configuration Register.
16312 +typedef union hcfg_data
16317 + unsigned reserved31_03 :29;
16318 + unsigned fslssupp : 1; /*!< 02 FS/LS Only Support */
16319 + unsigned fslspclksel : 2; /*!< 01-00 FS/LS Phy Clock Select */
16320 + #define IFXUSB_HCFG_30_60_MHZ 0
16321 + #define IFXUSB_HCFG_48_MHZ 1
16322 + #define IFXUSB_HCFG_6_MHZ 2
16327 + \brief Bit fields in the Host Frame Interval Register.
16329 +typedef union hfir_data
16334 + unsigned reserved : 16;
16335 + unsigned frint : 16; /*!< 15-00 Frame Interval */
16340 + \brief Bit fields in the Host Frame Time Remaing/Number Register.
16342 +typedef union hfnum_data
16347 + unsigned frrem : 16; /*!< 31-16 Frame Time Remaining */
16348 + unsigned frnum : 16; /*!< 15-00 Frame Number*/
16349 + #define IFXUSB_HFNUM_MAX_FRNUM 0x3FFF
16354 + \brief Bit fields in the Host Periodic Transmit FIFO/Queue Status Register
16356 +typedef union hptxsts_data
16358 + /** raw register data */
16362 + /** Top of the Periodic Transmit Request Queue
16363 + * - bit 24 - Terminate (last entry for the selected channel)
16365 + unsigned ptxqtop_odd : 1; /*!< 31 Top of the Periodic Transmit Request
16366 + Queue Odd/even microframe*/
16367 + unsigned ptxqtop_chnum : 4; /*!< 30-27 Top of the Periodic Transmit Request
16368 + Channel Number */
16369 + unsigned ptxqtop_token : 2; /*!< 26-25 Top of the Periodic Transmit Request
16375 + unsigned ptxqtop_terminate : 1; /*!< 24 Top of the Periodic Transmit Request
16376 + Terminate (last entry for the selected channel)*/
16377 + unsigned ptxqspcavail : 8; /*!< 23-16 Periodic Transmit Request Queue Space Available */
16378 + unsigned ptxfspcavail :16; /*!< 15-00 Periodic Transmit Data FIFO Space Available */
16383 + \brief Bit fields in the Host Port Control and Status Register.
16385 +typedef union hprt0_data
16390 + unsigned reserved19_31 :13;
16391 + unsigned prtspd : 2; /*!< 18-17 Port Speed */
16392 + #define IFXUSB_HPRT0_PRTSPD_HIGH_SPEED 0
16393 + #define IFXUSB_HPRT0_PRTSPD_FULL_SPEED 1
16394 + #define IFXUSB_HPRT0_PRTSPD_LOW_SPEED 2
16395 + unsigned prttstctl : 4; /*!< 16-13 Port Test Control */
16396 + unsigned prtpwr : 1; /*!< 12 Port Power */
16397 + unsigned prtlnsts : 2; /*!< 11-10 Port Line Status */
16398 + unsigned reserved9 : 1;
16399 + unsigned prtrst : 1; /*!< 08 Port Reset */
16400 + unsigned prtsusp : 1; /*!< 07 Port Suspend */
16401 + unsigned prtres : 1; /*!< 06 Port Resume */
16402 + unsigned prtovrcurrchng : 1; /*!< 05 Port Overcurrent Change */
16403 + unsigned prtovrcurract : 1; /*!< 04 Port Overcurrent Active */
16404 + unsigned prtenchng : 1; /*!< 03 Port Enable/Disable Change */
16405 + unsigned prtena : 1; /*!< 02 Port Enable */
16406 + unsigned prtconndet : 1; /*!< 01 Port Connect Detected */
16407 + unsigned prtconnsts : 1; /*!< 00 Port Connect Status */
16412 + \brief Bit fields in the Host All Interrupt Register.
16414 +typedef union haint_data
16419 + unsigned reserved : 16;
16420 + unsigned ch15 : 1;
16421 + unsigned ch14 : 1;
16422 + unsigned ch13 : 1;
16423 + unsigned ch12 : 1;
16424 + unsigned ch11 : 1;
16425 + unsigned ch10 : 1;
16426 + unsigned ch09 : 1;
16427 + unsigned ch08 : 1;
16428 + unsigned ch07 : 1;
16429 + unsigned ch06 : 1;
16430 + unsigned ch05 : 1;
16431 + unsigned ch04 : 1;
16432 + unsigned ch03 : 1;
16433 + unsigned ch02 : 1;
16434 + unsigned ch01 : 1;
16435 + unsigned ch00 : 1;
16439 + unsigned reserved : 16;
16440 + unsigned chint : 16;
16443 +/*@}*//*IFXUSB_CSR_HOST_GLOBAL_REG*/
16444 +/****************************************************************************/
16446 + \addtogroup IFXUSB_CSR_HOST_HC_REG
16450 + \brief Host Channel Specific Registers
16451 + There will be one set of hc registers per host channelimplemented.
16452 + each HC's Register are offset at :
16453 + 500h + * (hc_num * 20h)
16455 +typedef struct ifxusb_hc_regs
16457 + volatile uint32_t hcchar; /*!< 00h Host Channel Characteristic Register.*/
16458 + volatile uint32_t hcsplt; /*!< 04h Host Channel Split Control Register.*/
16459 + volatile uint32_t hcint; /*!< 08h Host Channel Interrupt Register. */
16460 + volatile uint32_t hcintmsk; /*!< 0Ch Host Channel Interrupt Mask Register. */
16461 + volatile uint32_t hctsiz; /*!< 10h Host Channel Transfer Size Register. */
16462 + volatile uint32_t hcdma; /*!< 14h Host Channel DMA Address Register. */
16463 + uint32_t reserved[2]; /*!< 18h Reserved. */
16464 +} ifxusb_hc_regs_t;
16468 + \brief Bit fields in the Host Channel Characteristics Register.
16470 +typedef union hcchar_data
16475 + unsigned chen : 1; /*!< 31 Channel enable */
16476 + unsigned chdis : 1; /*!< 30 Channel disable */
16477 + unsigned oddfrm : 1; /*!< 29 Frame to transmit periodic transaction */
16478 + unsigned devaddr : 7; /*!< 28-22 Device address */
16479 + unsigned multicnt : 2; /*!< 21-20 Packets per frame for periodic transfers */
16480 + unsigned eptype : 2; /*!< 19-18 0: Control, 1: Isoc, 2: Bulk, 3: Intr */
16481 + unsigned lspddev : 1; /*!< 17 0: Full/high speed device, 1: Low speed device */
16482 + unsigned reserved : 1;
16483 + unsigned epdir : 1; /*!< 15 0: OUT, 1: IN */
16484 + unsigned epnum : 4; /*!< 14-11 Endpoint number */
16485 + unsigned mps :11; /*!< 10-00 Maximum packet size in bytes */
16490 + \brief Bit fields in the Host Channel Split Control Register
16492 +typedef union hcsplt_data
16497 + unsigned spltena : 1; /*!< 31 Split Enble */
16498 + unsigned reserved :14;
16499 + unsigned compsplt : 1; /*!< 16 Do Complete Split */
16500 + unsigned xactpos : 2; /*!< 15-14 Transaction Position */
16501 + #define IFXUSB_HCSPLIT_XACTPOS_MID 0
16502 + #define IFXUSB_HCSPLIT_XACTPOS_END 1
16503 + #define IFXUSB_HCSPLIT_XACTPOS_BEGIN 2
16504 + #define IFXUSB_HCSPLIT_XACTPOS_ALL 3
16505 + unsigned hubaddr : 7; /*!< 13-07 Hub Address */
16506 + unsigned prtaddr : 7; /*!< 06-00 Port Address */
16511 + \brief Bit fields in the Host Interrupt Register.
16513 +typedef union hcint_data
16518 + unsigned reserved :21;
16519 + unsigned datatglerr : 1; /*!< 10 Data Toggle Error */
16520 + unsigned frmovrun : 1; /*!< 09 Frame Overrun */
16521 + unsigned bblerr : 1; /*!< 08 Babble Error */
16522 + unsigned xacterr : 1; /*!< 07 Transaction Err */
16523 + unsigned nyet : 1; /*!< 06 NYET Response Received */
16524 + unsigned ack : 1; /*!< 05 ACK Response Received */
16525 + unsigned nak : 1; /*!< 04 NAK Response Received */
16526 + unsigned stall : 1; /*!< 03 STALL Response Received */
16527 + unsigned ahberr : 1; /*!< 02 AHB Error */
16528 + unsigned chhltd : 1; /*!< 01 Channel Halted */
16529 + unsigned xfercomp : 1; /*!< 00 Channel Halted */
16535 + \brief Bit fields in the Host Channel Transfer Size
16538 +typedef union hctsiz_data
16544 + unsigned dopng : 1; /*!< 31 Do PING protocol when 1 */
16546 + * Packet ID for next data packet
16550 + * 3: MDATA (non-Control), SETUP (Control)
16552 + unsigned pid : 2; /*!< 30-29 Packet ID for next data packet
16556 + 3: MDATA (non-Control), SETUP (Control)
16558 + #define IFXUSB_HCTSIZ_DATA0 0
16559 + #define IFXUSB_HCTSIZ_DATA1 2
16560 + #define IFXUSB_HCTSIZ_DATA2 1
16561 + #define IFXUSB_HCTSIZ_MDATA 3
16562 + #define IFXUSB_HCTSIZ_SETUP 3
16563 + unsigned pktcnt :10; /*!< 28-19 Data packets to transfer */
16564 + unsigned xfersize :19; /*!< 18-00 Total transfer size in bytes */
16568 +/*@}*//*IFXUSB_CSR_HOST_HC_REG*/
16570 +/****************************************************************************/
16573 + \addtogroup IFXUSB_CSR_PWR_CLK_GATING_REG
16577 + \brief Bit fields in the Power and Clock Gating Control Register
16579 +typedef union pcgcctl_data
16584 + unsigned reserved : 27;
16585 + unsigned physuspended : 1; /*!< 04 PHY Suspended */
16586 + unsigned rstpdwnmodule : 1; /*!< 03 Reset Power Down Modules */
16587 + unsigned pwrclmp : 1; /*!< 02 Power Clamp */
16588 + unsigned gatehclk : 1; /*!< 01 Gate Hclk */
16589 + unsigned stoppclk : 1; /*!< 00 Stop Pclk */
16592 +/*@}*//*IFXUSB_CSR_PWR_CLK_GATING_REG*/
16594 +/****************************************************************************/
16596 +#endif //__IFXUSB_REGS_H__
16598 +++ b/drivers/usb/ifxhcd/ifxusb_version.h
16601 +#ifndef IFXUSB_VERSION
16602 +#define IFXUSB_VERSION "3.0alpha B100312"