ISI exception fixed. as expected, a sync fail. however, done head is
authorBernhard Urban <lewurm@gmx.net>
Sun, 20 Sep 2009 19:09:57 +0000 (21:09 +0200)
committerBernhard Urban <lewurm@gmx.net>
Sun, 20 Sep 2009 20:25:51 +0000 (22:25 +0200)
null. why?

usb/core/core.c
usb/host/at90usb1287-hcd.c [deleted file]
usb/host/at90usb1287.h [deleted file]
usb/host/ohci.c
usb/host/sl811hs-hcd.c [deleted file]
usb/host/sl811hs.h [deleted file]

index 1301e0a6c8b414fbefc9b1055f84522a1f783a12..14600fffa7351a1c3ca6f906af6aa027542555c6 100644 (file)
@@ -277,7 +277,6 @@ u16 usb_submit_irp(usb_irp *irp)
 
                /* control message are always 8 bytes */
                td->actlen = 8;
-               memcpy(mybuf, td->buffer, td->actlen);
 
                togl = 0;
                /* start with data0 */
diff --git a/usb/host/at90usb1287-hcd.c b/usb/host/at90usb1287-hcd.c
deleted file mode 100644 (file)
index 2ba0cae..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-  //
- * Copyright (c) 2007, Benedikt Sauter <sauter@ixbat.de>
- * All rights reserved.
- *
- * Short descripton of file: at90usb1287-hcdi.c
- *
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright 
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the following 
- *     disclaimer in the documentation and/or other materials provided 
- *     with the distribution.
- *   * Neither the name of the FH Augsburg nor the names of its 
- *     contributors may be used to endorse or promote products derived 
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "host.h"
-#include <wait.h>
-#include <stdlib.h>
-
-#include "at90usb1287.h"
-#include <avr/io.h>
-
-#include "uart.h"
-#include "wait.h"
-
-#include <core/core.h>
-#include <usbspec/usb11spec.h>
-
-void at90usb1287_roothub_probe();
-void at90usb1287_roothub_check();
-
-void at90usb1287_start_transfer();
-
-usb_device * device_on_downstream;
-
-
-/* cuurent transferdescriptor on port a and port b */
-usb_transfer_descriptor * td_usba;
-usb_transfer_descriptor * td_usbb;
-
-usb_driver at90usb1287_roothub = {
-  .name          = "at90usb1287_roothub",
-  .probe  = at90usb1287_roothub_probe,
-  .check  = at90usb1287_roothub_check,
-  .data          = NULL,
-};
-
-usb_device * device_on_downstream;
-
-/**
- * Find and initial root hub
- */
-void at90usb1287_roothub_probe()
-{
-  // called on n every new enumeration and at usb_register_driver  
-  // der sollte nach dem ersten aufruf igonriert werden
-  #if DEBUG
-  core.stdout("Probe: AT90USB1287 Root Hub\r\n");
-  #endif
-}
-
-/**
- * This function is called periodical, to notice
- * port changes after an hub
- */
-void at90usb1287_roothub_check()
-{
-  //USART_WriteHex(UHINT);
-  //UHINT = 0x00;
-  // disconnect 
-  if(UHINT & 0x02) {
-    device_on_downstream=NULL;
-    #if DEBUG
-    core.stdout("Device: Removed!\r\n");
-    #endif
-    //UHINT &= ~(1<<DDISCI);
-  } else {
-    // if connect 
-    if(device_on_downstream!=NULL) {
-      // normal transfer check for interrupt and isochonous endpoints
-      //USART_WriteHex(0x88);
-    } 
-    // check if device is connected 
-    else {
-      if(UHINT & 0x01) {
-       // found new device
-       #if DEBUG
-       core.stdout("Device: Found new one!\r\n");
-       #endif
-
-       if((USBSTA &   (1<<SPEED)) &&(USBSTA &   (1<<SPEED))){
-         // fullspeed
-         #if DEBUG
-         core.stdout("FS\r\n");
-         #endif
-       } else {
-         //lowspeed
-         #if DEBUG
-         core.stdout("LS\r\n");
-         #endif
-         // mark device as low speed
-       }
-       
-       //UHCON = (1<<SOFEN); /* host generate for FS SOF, and for LS keep-alive! */
-       //UHCON = (1<<RESET);
-
-       // SOF on etx
-       device_on_downstream = 1;       
-       //device_on_downstream = usb_add_device();      
-       //UHINT &= ~(1<<DCONNI);
-      }
-      else {
-       // wenn geraet nicht aktiviert ist das immer aufrufen! 
-      //USART_WriteHex(0x55);
-      }
-    }
-  }
-  UHINT = 0x00;
-       /* Usb_disable */
-       USBCON &= ~(1<<USBE);
-       /* Usb_enable */
-       USBCON |= (1<<USBE);
-       /* unfreeze clock */
-       UsbEnableClock();
-       /* usb attach */
-       UDCON   &= ~(1<<DETACH);
-       /* select host */
-       USBCON  |=  (1<<HOST);
-       /* disable vbus hw control */
-       OTGCON  |=  (1<<VBUSHWC);
-       /* enable vbus */
-       OTGCON  |=  (1<<VBUSREQ);
-
- }
-
-
-void hcdi_init()
-{ 
- /* register virtual root hub driver */
-  usb_register_driver(&at90usb1287_roothub);
-
-  /* enable regulator */
-  UHWCON |= (1<<UVREGE); 
-  /* force host mode */
-  UHWCON &= ~(1<<UIDE);
-  UHWCON &= ~(1<<UIMOD);
-
-  /* pll sart */
-  UsbSetPLL_CPU_Frequency();
-  UsbEnablePLL();
-  UsbWaitPLL_Locked();
-
-  /* Usb_disable */
-  USBCON &= ~(1<<USBE);
-  
-  /* Usb_enable */
-  USBCON |= (1<<USBE);
-  
-  /* unfreeze clock */
-  UsbEnableClock();
-
-  /* usb attach */
-  UDCON   &= ~(1<<DETACH);
-
-  /* enable uconv pin */
-  UsbDisableUVCON_PinControl();
-  UsbEnableUID_ModeSelection();
-
-  /* select host */
-  USBCON  |=  (1<<HOST);
-
-  /* disable vbus hw control */
-  OTGCON  |=  (1<<VBUSHWC);
-
-  // 4
-  /* enable vbus */
-  OTGCON  |=  (1<<VBUSREQ);
-  
-  UHIEN |= (1<<DDISCE);
-  UHIEN |= (1<<DCONNE);
-
-  UHIEN = 0xff;
- }
-
-/**
- * hcdi_enqueue takes usb_irp and split it into
- * several usb packeges (SETUP,IN,OUT)
- * In the usbstack they are transported with the
- * usb_transfer_descriptor data structure.
- */
-
-u8 hcdi_enqueue(usb_transfer_descriptor *td)
-{
-  #if LIBMODE
-  td_usba = td;
-  at90usb1287_start_transfer();
-  #endif
-  return 1;
-}
-
-
-u8 hcdi_dequeue(usb_transfer_descriptor *td)
-{
-  return 1;
-}
-
-
-
-void hcdi_irq()
-{
-}
-
-
-
-void at90usb1287_start_transfer()
-{
-  usb_transfer_descriptor * td;
-  //core.stdout("Transfer: Start!\r\n");
-
-  #if LIBMODE
-  /* choose next free port */
-  td = td_usba;
-  #endif
-
-  switch(td->pid) {
-    case USB_PID_SETUP:
-    break;
-    
-    case USB_PID_IN:
-    break;
-    
-    case USB_PID_OUT:
-    break;
-  }
-
-
-}
-
-
diff --git a/usb/host/at90usb1287.h b/usb/host/at90usb1287.h
deleted file mode 100644 (file)
index eb2ed07..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef _AT90USB_H
-#define _AT90USB_H
-// AT90USB/usb_drv.h
-// Macros for access to USB registers of Atmels AT90USB microcontrollers
-// This file contains low level register stuff as described in
-// Atmels AT90USB datasheet 7593D-AVR-07/06
-// S. Salewski 21-MAR-2007
-// B. Sauter (modified for usb host stack) 2007
-
-
-// A few macros for bit fiddling
-#define SetBit(adr, bit)                        (adr |=  (1<<bit))
-#define ClearBit(adr, bit)                      (adr &= ~(1<<bit))
-#define BitIsSet(adr, bit)                      (adr & (1<<bit))
-#define BitIsClear(adr, bit)                    (!(adr & (1<<bit)))
-
-
-
-// PLL clock for USB interface, section 6.11, page 50
-// PLLCSR (PLL Control and Status Register)
-// set PLL prescaler according to XTAL crystal frequency
-//#define UsbXTALFrequencyIs2MHz()              PLLCSR = (PLLCSR & ~(15<<1))
-//#define UsbXTALFrequencyIs4MHz()              PLLCSR = (PLLCSR & ~(15<<1)) | (1<<2)
-//#define UsbXTALFrequencyIs6MHz()              PLLCSR = (PLLCSR & ~(15<<1)) | (2<<2)
-//#define UsbXTALFrequencyIs8MHz()              PLLCSR = (PLLCSR & ~(15<<1)) | (3<<2)
-//#define UsbXTALFrequencyIs12MHz()             PLLCSR = (PLLCSR & ~(15<<1)) | (4<<2)
-//#define UsbXTALFrequencyIs16MHz()             PLLCSR = (PLLCSR & ~(15<<1)) | (5<<2)
-#if (F_CPU == 2000000)
-#define _pre_ 0
-#elif (F_CPU == 4000000)
-#define _pre_ 1
-#elif (F_CPU == 6000000)
-#define _pre_ 2
-#elif (F_CPU == 8000000)
-#define _pre_ 3
-#elif (F_CPU == 12000000)
-#define _pre_ 4
-#elif (F_CPU == 16000000)
-#define _pre_ 5
-#else
-  #error "XTAL-Frequency has to be 2, 4, 6, 8, 12 or 16 MHz for USB devices!"
-#endif
-#define UsbSetPLL_CPU_Frequency()              PLLCSR = (_pre_<<2)
-#define UsbEnablePLL()                          SetBit(PLLCSR, PLLE)
-#define UsbDisablePLL()                         ClearBit(PLLCSR, PLLE)
-#define UsbIsPLL_Locked()                       BitIsSet(PLLCSR, PLOCK)
-#define UsbWaitPLL_Locked()                     while (!(PLLCSR & (1<<PLOCK)));
-#define UsbEnableClock()                        ClearBit(USBCON, FRZCLK)
-
-//USB general registers, section 21.12.1, page 263 of datasheet
-// UHWCON (UsbHardWareCONfiguration)
-#define UsbSetDeviceMode()                SetBit(UHWCON, UIMOD)           // select host or device mode manually
-#define UsbSetHostMode()                  ClearBit(UHWCON, UIMOD)
-#define UsbEnableUID_ModeSelection()      SetBit(UHWCON, UIDE)            // enable mode selection by UID pin
-#define UsbDisableUID_ModeSelection()     ClearBit(UHWCON, UIDE)
-#define UsbEnableUVCON_PinControl()       SetBit(UHWCON, UVCONE)          // enable UVCON pin control, figure 21-7
-#define UsbDisableUVCON_PinControl()      ClearBit(UHWCON, UVCONE)
-#define UsbEnablePadsRegulator()          SetBit(UHWCON, UVREGE)          // USB pads (D+, D-) supply
-#define UsbDisablePadsRegulator()         ClearBit(UHWCON, UVREGE)
-
-// USBCON (USB CONfiguration)
-#define UsbEnableController()             SetBit(USBCON, USBE)            // USB controller enable
-#define UsbDisableController()            ClearBit(USBCON, USBE)          // reset and disable controller
-#define UsbIsControllerEnabled()          BitIsSet(USBCON, USBE)
-#define UsbSetHostModeReg()               SetBit(USBCON, HOST)            // select multiplexed controller registers
-#define UsbSetDeviceModeReg()             ClearBit(USBCON, HOST)          //
-#define UsbFreezeClock()                  SetBit(USBCON, FRZCLK)          // reduce power consumption
-#define UsbEnableClock()                  ClearBit(USBCON, FRZCLK)
-#define UsbIsClockFreezed()               BitIsSet(USBCON, FRZCLK)
-#define UsbEnableOTG_Pad()                SetBit(USBCON, OTGPADE)         // ??? is this the UID pad?
-#define UsbDisableOTG_Pad()               ClearBit(USBCON, OTGPADE)
-#define UsbEnableID_TransitionInt()       SetBit(USBCON, IDTE)            // enable ID transition interrupt generation
-#define UsbDisableID_TransitionInt()      ClearBit(USBCON, IDTE)
-#define UsbEnableVBUS_TransitionInt()     SetBit(USBCON, VBUSTE)          // enable VBUS transition interrupt
-#define UsbDisableVBUS_TransitionInt()    ClearBit(USBCON, VBUSTE)
-
-// USBSTA (USBSTAtus, read only)
-#define UsbIsFullSpeedMode()              BitIsSet(USBSTA, SPEED)         // set by hardware if controller is in fullspeed mode,
-#define UsbIsLowSpeedMode()               BitIsClear(USBSTA, SPEED)       // use in host mode only, indeterminate in device mode
-#define UsbIsUID_PinHigh()               BitIsSet(USBSTA, ID)            // query UID pad/pin
-#define UsbIsVBUS_PinHigh()              BitIsSet(USBSTA, VBUS)          // query VBUS pad/pin
-
-// USBINT (USBINTerrupt)
-#define UsbIsIDTI_FlagSet()              BitIsSet(USBINT, IDTI)          // set by hardware if ID pin transition detected
-#define UsbClearIDTI_Flag()              ClearBit(USBINT, IDTI)          // shall be cleared by software
-#define UsbIsVBUSTI_FlagSet()            BitIsSet(USBINT, VBUSTI)        // set by hardware if transition on VBUS pad is detected
-#define UsbClearVBUSTI_Flag()            ClearBit(USBINT, VBUSTI)        // shall be cleared by software
-
-#endif /* _AT90USB_H */
index 8d7f7d61f79b5994653430f2c865ba5f28e5a9bf..559aeab073ea126f6bc5a457221c68d0218f151d 100644 (file)
@@ -153,7 +153,6 @@ static void dbg_op_state()
        }
 }
 
-#if 1
 static void dbg_td_flag(u32 flag)
 {
        printf("**************** dbg_td_flag: 0x%08X ***************\n", flag);
@@ -165,16 +164,20 @@ static void dbg_td_flag(u32 flag)
        printf(" R: %X\n", (flag>>18)&1);
        printf("********************************************************\n");
 }
-#endif
 
 static void general_td_fill(struct general_td *dest, const usb_transfer_descriptor *src)
 {
-       dest->cbp = LE(virt_to_phys(src->buffer));
-
-       /* save virtual address here */
-       dest->bufaddr = (u32) src->buffer;
+       if(src->actlen) {
+               dest->cbp = LE(virt_to_phys(src->buffer));
+               dest->be = LE(LE(dest->cbp) + src->actlen - 1);
+               /* save virtual address here */
+               dest->bufaddr = (u32) src->buffer;
+       }
+       else {
+               dest->cbp = dest->be = LE(0);
+               dest->bufaddr = 0;
+       }
 
-       dest->be = src->actlen ? LE(LE(dest->cbp) + src->actlen - 1) : LE(0);
        dest->buflen = src->actlen;
 
        dest->flags &= LE(~OHCI_TD_DIRECTION_PID_MASK);
@@ -230,6 +233,9 @@ void hcdi_fire()
 {
        printf("<^>  <^>  <^> hcdi_fire(start)\n");
 
+       if(edhead == 0)
+               return;
+
        control_quirk(); //required? YES! :O ... erm... or no? :/ ... in fact I have no idea
        write32(OHCI0_HC_CTRL_HEAD_ED, virt_to_phys(edhead));
 
@@ -244,7 +250,7 @@ void hcdi_fire()
                dump_address(x, sizeof(struct general_td), "x(before)");
 
                if(x->buflen > 0) {
-                       sync_after_write((void*) x->cbp, x->buflen);
+                       sync_after_write((void*) phys_to_virt(LE(x->cbp)), x->buflen);
                        dump_address((void*) phys_to_virt(LE(x->cbp)), x->buflen, "x->cbp(before)");
                }
                x = phys_to_virt(LE(x->nexttd));
@@ -270,24 +276,23 @@ void hcdi_fire()
         u32 current = read32(OHCI0_HC_CTRL_CURRENT_ED);
         printf("current: 0x%08X\n", current);
         printf("+++++++++++++++++++++++++++++\n");
-        udelay(100000);
+        udelay(1000000);
 #endif
 
        sync_before_read(&hcca_oh0, sizeof(hcca_oh0));
        struct general_td *n = phys_to_virt(LE(hcca_oh0.done_head) & ~1);
        printf("done_head: 0x%08X\n", n);
-#if 1
+
        struct general_td *prev = 0, *next = 0;
        /* reverse done queue */
        while(virt_to_phys(n)) {
+               sync_before_read((void*) n, sizeof(struct general_td));
                printf("n: 0x%08X\n", n);
                printf("next: 0x%08X\n", next);
                printf("prev: 0x%08X\n", prev);
-               next = n;
-
-               sync_before_read((void*) n, sizeof(struct general_td));
 
-               n = (struct general_td*) phys_to_virt(LE(next->nexttd));
+               next = n;
+               n = (struct general_td*) phys_to_virt(LE(n->nexttd));
                next->nexttd = (u32) prev;
                prev = next;
        }
@@ -298,16 +303,23 @@ void hcdi_fire()
                if(prev) {
                        free(prev);
                }
+
                dump_address(n, sizeof(struct general_td), "n(after)");
 
-               sync_before_read((void*) n->bufaddr, n->buflen);
-               dump_address((void*) n->bufaddr, n->buflen, "n->bufaddr(after)");
+               if(n->buflen > 0) {
+                       sync_before_read((void*) n->bufaddr, n->buflen);
+                       dump_address((void*) n->bufaddr, n->buflen, "n->bufaddr(after)");
+               }
                dbg_td_flag(LE(n->flags));
-               n = prev = (struct general_td*) n->nexttd;
+               prev = n;
+               n = (struct general_td*) n->nexttd;
+       }
+       if(prev) {
+               free(prev);
        }
+
        hcca_oh0.done_head = 0;
        sync_after_write(&hcca_oh0, sizeof(hcca_oh0));
-#endif
 
        write32(OHCI0_HC_CONTROL, read32(OHCI0_HC_CONTROL)&~OHCI_CTRL_CLE);
 
diff --git a/usb/host/sl811hs-hcd.c b/usb/host/sl811hs-hcd.c
deleted file mode 100644 (file)
index 2270384..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (c) 2007, Benedikt Sauter <sauter@ixbat.de>
- * All rights reserved.
- *
- * Short descripton of file: sl811hs-hcdi.c
- *
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright 
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the following 
- *     disclaimer in the documentation and/or other materials provided 
- *     with the distribution.
- *   * Neither the name of the FH Augsburg nor the names of its 
- *     contributors may be used to endorse or promote products derived 
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "host.h"
-#include "sl811hs.h"
-#include <wait.h>
-#include <stdlib.h>
-
-#include "uart.h"
-#include "wait.h"
-
-#include <core/core.h>
-//#include <class/hub.h>
-#include <usbspec/usb11spec.h>
-
-void sl811_roothub_probe();
-void sl811_roothub_check();
-
-void sl811_start_transfer();
-
-usb_device * device_on_downstream;
-
-
-/* cuurent transferdescriptor on port a and port b */
-usb_transfer_descriptor * td_usba;
-usb_transfer_descriptor * td_usbb;
-
-usb_driver sl811_roothub = {
-  .name          = "sl811_roothub",
-  .probe  = sl811_roothub_probe,
-  .check  = sl811_roothub_check,
-  .data          = NULL,
-};
-
-/**
- * Find and initial root hub
- */
-void sl811_roothub_probe()
-{
-  // called on n every new enumeration and at usb_register_driver  
-  // der sollte nach dem ersten aufruf igonriert werden
-  // oder diese funktion bleibt einfach leer
-  #if DEBUG
-  core.stdout("Probe: SL811 Root Hub\r\n");
-  #endif
-}
-
-
-/**
- * This function is called periodical, to notice
- * port changes after an hub
- */
-void sl811_roothub_check()
-{
-  /* hier muss man nur dafuer sorgen wenn ein geaert angesteckt
-   * wird, dass der entsprechende port auf reset gesetzt wird
-   * damit das device die adresse 0 annimmt
-   * und dann muss man usb_add_device aufrufen
-   *
-   * wenn ein geraet entfernt wird muss man nur usb_remove_device aufrufen
-   * und es muss dabei das richtige geraet angegeben werden.
-   * dieses muss man sich wahrscheinlich intern im treiber
-   * merken...
-   */
-  // check for new device 
-  u16 *port_change = (u16*)sl811_roothub.data;
-  
-  u8 status = sl811_read(SL811_ISR);
-  sl811_write(SL811_ISR,SL811_ISR_DATA | SL811_ISR_SOFTIMER);
-
-  #define HUB_PORTSTATUS_C_PORT_CONNECTION 1
-  if((status & SL811_ISR_RESET)) {  // TODO und bit x von CTRL
-    // remove device if neccessary
-    if(device_on_downstream!=NULL){
-      #if USBMON
-      core.stdout("Remove Device!\r\n");
-      #endif
-      usb_remove_device(device_on_downstream);
-      device_on_downstream=NULL;
-    }
-    
-    sl811_write(SL811_ISR,SL811_ISR_RESET);
-  } else {
-    if((port_change[0] & HUB_PORTSTATUS_C_PORT_CONNECTION)){
-      #if USBMON
-      core.stdout("Find new Device!\r\n");
-      #endif
-      
-      /* init sof currently for fullspeed  (datasheet page 11)*/
-      sl811_write(SL811_CSOF,0xAE);
-      sl811_write(SL811_DATA,0xE0);
-
-      /* reset device that function can answer to address 0 */
-      sl811_write(SL811_IER,0x00);
-      sl811_write(SL811_CTRL,SL811_CTRL_ENABLESOF|SL811_CTRL_RESETENGINE);
-      sl811_write(SL811_ISR,0xff);
-      wait_ms(20);
-
-      /* start SOF generation */
-      sl811_write(SL811_CTRL,SL811_CTRL_ENABLESOF);
-      sl811_write(SL811_ISR,0xff);
-      sl811_write(SL811_E0BASE,SL811_EPCTRL_ARM);
-      wait_ms(50);
-      
-      device_on_downstream = usb_add_device();
-
-      /* set internate port state 1=device is online */
-      port_change[0]=0x00;
-
-    }
-  }
-
-  if((status & SL811_ISR_INSERT)){
-    port_change[0] |= HUB_PORTSTATUS_C_PORT_CONNECTION;
-    sl811_write(SL811_ISR,SL811_ISR_INSERT);
-  }
-
-}
-
-
-void hcdi_init()
-{
-  /* find and initial host controller */
-  sl811_init();
-  u8 rev = sl811_read(SL811_REV)>>4;
-
-  switch(rev) {
-    case 1:
-      #if USBMON
-      core.stdout("Host: SL811HS v1.2 found\r\n");
-      #endif
-    break;
-    case 2:
-      #if USBMON
-      core.stdout("Host: SL811HS v1.5 found\r\n");
-      #endif
-    break;
-    default:
-      #if USBMON 
-      core.stdout("Can't find SL811!\r\n"); 
-      #endif
-      return;
-  }
-  /* Disable interrupt, then wait 40 ms */
-  sl811_write(SL811_IER,0x00);
-
-  /* Initialize controller */
-  //sl811_write(SL811_CSOF,0xae);
-  sl811_write(SL811_CSOF,SL811_CSOF_MASTER);
-
-  /* clear interrupt status register with one read operation */
-  sl811_write(SL811_ISR,0xff);
-
-  /* data = hub flags */
-  u16 *port_change = (u16*)malloc(sizeof(u16));
-  port_change[0] = 0x00;
-  port_change[1] = 0x00;
-  sl811_roothub.data = (void*)port_change;
-  device_on_downstream = NULL;
-
-
-  /* register virtual root hub driver */
-  usb_register_driver(&sl811_roothub);
-
-  
-  /* activate interrupts */
-  sl811_write(SL811_IER,SL811_IER_USBA);
-}
-
-/**
- * hcdi_enqueue takes usb_irp and split it into
- * several usb packeges (SETUP,IN,OUT)
- * In the usbstack they are transported with the
- * usb_transfer_descriptor data structure.
- */
-
-u8 hcdi_enqueue(usb_transfer_descriptor *td)
-{
-  #if LIBMODE
-  td_usba = td;
-  sl811_start_transfer();
-  #endif
-  return 1;
-}
-
-
-u8 hcdi_dequeue(usb_transfer_descriptor *td)
-{
-  return 1;
-}
-
-
-
-void hcdi_irq()
-{
-  core.stdout("interrupt\r\n");
-  u8 state;
-  state = sl811_read(SL811_ISR);
-  if(state & SL811_ISR_USBA) {
-    core.stdout("a done\r\n");
-  }
-  if(state & SL811_ISR_USBB) {
-    core.stdout("b done\r\n");
-  }
-  if(state & SL811_ISR_RESET) {
-    core.stdout("reset\r\n");
-  }
-  
-  if(state & SL811_ISR_INSERT) {
-    core.stdout("insert\r\n");
-  }
-
-  sl811_write(SL811_ISR,0xFF);
-}
-
-
-
-void sl811_start_transfer()
-{
-  usb_transfer_descriptor * td;
-
-  #if LIBMODE
-  /* choose next free port */
-  td = td_usba;
-  /* disable a done interrupt */
-  sl811_write(SL811_IER,0x00); 
-  #endif
-
-  #if USBMON
-    //core.stdout("");
-  #endif
-
-  sl811_write(SL811_E0CONT,td->devaddress);    /* device address */
-  sl811_write(SL811_E0LEN,td->actlen);         /* number of bytes to transfer */
-  sl811_write(SL811_E0ADDR,cMemStart);         /* set address to buffer in sl811 ram */
-
-  switch(td->pid) {
-    case USB_PID_SETUP:
-      //core.stdout("*setup\r\n");
-      /* copy data into ram of sl811 */
-      sl811_write_buf(cMemStart,(unsigned char *)td->buffer,td->actlen);
-      
-      sl811_write(SL811_E0STAT,PID_SETUP|td->endpoint); /* set pid and ep */
-      sl811_write(SL811_E0CTRL,DATA0_WR);              /* send setup packet with DATA0 */
-      td->state = USB_TRANSFER_DESCR_SEND;
-
-      /* wait ack */
-      #if LIBMODE
-      while((sl811_read(SL811_ISR)&SL811_ISR_USBA)==0);
-      //wait_ms(1);
-      #endif
-
-    break;
-    
-    case USB_PID_IN:
-      //core.stdout("*in\r\n");
-      #if LIBMODE
-      wait_ms(2);
-      #endif
-      
-      sl811_write(SL811_E0STAT,PID_IN|td->endpoint); /* set pid and ep */
-      sl811_write(SL811_ISR,0xff);
-     
-      /* choose data0 or data1 */
-      if(td->togl)
-       sl811_write(SL811_E0CTRL,DATA1_RD);             /* send setup packet with DATA0 */
-      else
-       sl811_write(SL811_E0CTRL,DATA0_RD);             /* send setup packet with DATA0 */
-
-      td->state = USB_TRANSFER_DESCR_SEND;
-  
-      /* wait ack */
-      #if LIBMODE
-      while((sl811_read(SL811_ISR)&SL811_ISR_USBA)==0);
-      //wait_ms(1);
-      
-      /* copy received data from internal sl811 ram */
-      sl811_read_buf(cMemStart,(unsigned char *)td->buffer,td->actlen);
-      
-      #endif
-
-    break;
-    
-    case USB_PID_OUT:
-      //core.stdout("*out\r\n");
-      #if LIBMODE
-      wait_ms(2);
-      #endif
-
-      /* copy data into ram of sl811 */
-      if(td->actlen>0)
-       sl811_write_buf(cMemStart,(unsigned char *)td->buffer,td->actlen);
-
-      sl811_write(SL811_E0STAT,PID_OUT|td->endpoint); /* set pid and ep */
-  
-      /* choose data0 or data1 */
-      if(td->togl)
-       sl811_write(SL811_E0CTRL,DATA1_WR);             /* send setup packet with DATA0 */
-      else
-       sl811_write(SL811_E0CTRL,DATA0_WR);             /* send setup packet with DATA0 */
-
-      td->state = USB_TRANSFER_DESCR_SEND;
-
-      /* wait ack */
-      #if LIBMODE
-      while((sl811_read(SL811_ISR)&SL811_ISR_USBA)==0);
-      //wait_ms(1);
-      #endif
-
-    break;
-
-
-  }
-
-
-}
-
-
diff --git a/usb/host/sl811hs.h b/usb/host/sl811hs.h
deleted file mode 100644 (file)
index b5d8ab4..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2007, Benedikt Sauter <sauter@ixbat.de>
- * All rights reserved.
- *
- * Short descripton of file (sl811hs.h):
- * Register definitions of SL811, created from the datasheet
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright 
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the following 
- *     disclaimer in the documentation and/or other materials provided 
- *     with the distribution.
- *   * Neither the name of the FH Augsburg nor the names of its 
- *     contributors may be used to endorse or promote products derived 
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SL811HS_H
-#define _SL811HS_H
-
-/* prototypes for communication functions */
-void sl811_init();
-void sl811_reset();
-void sl811_write(u8 addr, u8 data);
-u8 sl811_read(u8 addr);
-
-void sl811_write_burst(u8 data);
-u8 sl811_read_burst();
-
-void sl811_write_buf(u8 addr, unsigned char *buffer,u8 size);
-void sl811_read_buf(u8 addr, unsigned char *buffer,u8 size);
-
-/*
- *  * ScanLogic SL811HS/T USB Host Controller
- *   */
-
-#define SL811_IDX_ADDR (0x00)
-#define SL811_IDX_DATA (0x01)
-#define SL811_PORTSIZE (0x02)
-
-#define SL811_E0BASE (0x00)    /* Base of Control0 */
-#define SL811_E0CTRL (0x00)    /* Host Control Register */
-#define SL811_E0ADDR (0x01)    /* Host Base Address */
-#define SL811_E0LEN  (0x02)    /* Host Base Length */
-#define SL811_E0STAT (0x03)    /* USB Status (Read) */
-#define SL811_E0PID  SL811_E0STAT      /* Host PID, Device Endpoint (Write) */
-#define SL811_E0CONT (0x04)    /* Transfer Count (Read) */
-#define SL811_E0DEV  SL811_E0CONT      /* Host Device Address (Write) */
-
-#define SL811_E1BASE (0x08)    /* Base of Control1 */
-#define SL811_E1CTRL (SL811_E1BASE + SL811_E0CTRL)
-#define SL811_E1ADDR (SL811_E1BASE + SL811_E0ADDR)
-#define SL811_E1LEN  (SL811_E1BASE + SL811_E0LEN)
-#define SL811_E1STAT (SL811_E1BASE + SL811_E0STAT)
-#define SL811_E1PID  (SL811_E1BASE + SL811_E0PID)
-#define SL811_E1CONT (SL811_E1BASE + SL811_E0CONT)
-#define SL811_E1DEV  (SL811_E1BASE + SL811_E0DEV)
-
-#define SL811_CTRL (0x05)    /* Control Register1 */
-#define SL811_IER  (0x06)    /* Interrupt Enable Register */
-#define SL811_ISR  (0x0d)    /* Interrupt Status Register */
-#define SL811_DATA (0x0e)    /* SOF Counter Low (Write) */
-#define SL811_REV  SL811_DATA /* HW Revision Register (Read) */
-#define SL811_CSOF  (0x0f)    /* SOF Counter High(R), Control2(W) */
-#define SL811_MEM  (0x10)    /* Memory Buffer (0x10 - 0xff) */
-
-#define SL811_EPCTRL_ARM         (0x01)
-#define SL811_EPCTRL_ENABLE  (0x02)
-#define SL811_EPCTRL_DIRECTION (0x04)
-#define SL811_EPCTRL_ISO         (0x10)
-#define SL811_EPCTRL_SOF         (0x20)
-#define SL811_EPCTRL_DATATOGGLE        (0x40)
-#define SL811_EPCTRL_PREAMBLE  (0x80)
-
-#define SL811_EPPID_PIDMASK  (0xf0)
-#define SL811_EPPID_EPMASK (0x0f)
-
-#define SL811_EPSTAT_ACK         (0x01)
-#define SL811_EPSTAT_ERROR (0x02)
-#define SL811_EPSTAT_TIMEOUT (0x04)
-#define SL811_EPSTAT_SEQUENCE  (0x08)
-#define SL811_EPSTAT_SETUP (0x10)
-#define SL811_EPSTAT_OVERFLOW  (0x20)
-#define SL811_EPSTAT_NAK         (0x40)
-#define SL811_EPSTAT_STALL (0x80)
-
-#define SL811_CTRL_ENABLESOF (0x01)
-#define SL811_CTRL_EOF2          (0x04)
-#define SL811_CTRL_RESETENGINE (0x08)
-#define SL811_CTRL_JKSTATE (0x10)
-#define SL811_CTRL_LOWSPEED  (0x20)
-#define SL811_CTRL_SUSPEND (0x40)
-
-#define SL811_IER_USBA (0x01)  /* USB-A done */
-#define SL811_IER_USBB (0x02)  /* USB-B done */
-#define SL811_IER_BABBLE         (0x04)  /* Babble detection */
-#define SL811_IER_SOFTIMER (0x10)  /* 1ms SOF timer */
-#define SL811_IER_INSERT         (0x20)  /* Slave Insert/Remove detection */
-#define SL811_IER_RESET          (0x40)  /* USB Reset/Resume */
-
-#define SL811_ISR_USBA (0x01)  /* USB-A done */
-#define SL811_ISR_USBB (0x02)  /* USB-B done */
-#define SL811_ISR_BABBLE         (0x04)  /* Babble detection */
-#define SL811_ISR_SOFTIMER (0x10)  /* 1ms SOF timer */
-#define SL811_ISR_INSERT         (0x20)  /* Slave Insert/Remove detection */
-#define SL811_ISR_RESET          (0x40)  /* USB Reset/Resume */
-#define SL811_ISR_DATA (0x80)  /* Value of the Data+ pin */
-
-#define SL811_REV_USBA (0x01)  /* USB-A */
-#define SL811_REV_USBB (0x02)  /* USB-B */
-#define SL811_REV_REVMASK  (0xf0)  /* HW Revision */
-#define SL811_REV_REVSL811H (0x00)  /* HW is SL811H */
-#define SL811_REV_REVSL811HS (0x10)  /* HW is SL811HS */
-
-#define SL811_CSOF_SOFMASK  (0x3f)  /* SOF High Counter */
-#define SL811_CSOF_POLARITY (0x40)  /* Change polarity */
-#define SL811_CSOF_MASTER (0x80)  /* Master/Slave selection */
-
-
-#define cMemStart 0x10
-#define ubufA    0x80
-#define ubufB    0xc0
-#define        uxferLen  0x40
-#define sMemSize  0xc0
-#define        cMemEnd   256
-
-
-#define EP0Buf 0x40
-#define EP0Len 0x40
-
-#define DATA0_WR  0x07
-#define DATA1_WR  0x47
-
-#define ZDATA0_WR 0x05
-#define ZDATA1_WR 0x45
-
-#define DATA0_RD  0x03
-#define DATA1_RD  0x43
-
-#define PID_SOF          0x50
-#define PID_SETUP 0xd0
-#define PID_IN   0x90
-#define PID_OUT          0x10
-#define PID_PRE          0xc0
-#define PID_NAK          0xa0
-#define PID_STALL 0xe0
-#define PID_DATA0 0x30
-#define PID_DATA1 0xb0
-
-
-#endif /* _SL811HS_H */
-