From 5cf87ceb3062e39daa6448d9ece79533cd7306c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Sun, 15 Dec 2013 14:22:15 +0000 Subject: [PATCH] --- BaS_gcc/flash_scripts/flash_firebee_bas.bdm | 50 +-------------------- BaS_gcc/sources/dma.c | 4 -- BaS_gcc/sources/interrupts.c | 1 + BaS_gcc/sources/pci.c | 11 ++++- BaS_gcc/sources/sysinit.c | 1 + BaS_gcc/sources/usb.c | 16 ++++--- 6 files changed, 23 insertions(+), 60 deletions(-) diff --git a/BaS_gcc/flash_scripts/flash_firebee_bas.bdm b/BaS_gcc/flash_scripts/flash_firebee_bas.bdm index 0ccad0f..85f580d 100755 --- a/BaS_gcc/flash_scripts/flash_firebee_bas.bdm +++ b/BaS_gcc/flash_scripts/flash_firebee_bas.bdm @@ -44,7 +44,7 @@ sleep 10 # use system sdram as flashlib scratch area. # TODO: plugin flashing seems to work o.k. now for smaller binaries, while it doesn't for larger ones (EmuTOS) yet. # This seems to be related to large flash buffers and PC-relative adressing of the plugin -flash-plugin 0x1000 0xf000 flash29.plugin +#flash-plugin 0x1000 0xf000 flash29.plugin # notify flashlib that we have flash at address 0xE0000000, length 0x7FFFFF, plugin is flash29 flash 0xE0000000 @@ -57,53 +57,7 @@ flash 0xE0000000 erase 0xE0000000 0x000000 erase-wait 0xE0000000 -erase 0xE0000000 0x001000 -erase-wait 0xE0000000 -erase 0xE0000000 0x002000 -erase-wait 0xE0000000 -erase 0xE0000000 0x003000 -erase-wait 0xE0000000 -erase 0xE0000000 0x004000 -erase-wait 0xE0000000 -erase 0xE0000000 0x005000 -erase-wait 0xE0000000 -erase 0xE0000000 0x006000 -erase-wait 0xE0000000 -erase 0xE0000000 0x007000 -erase-wait 0xE0000000 -erase 0xE0000000 0x008000 -erase-wait 0xE0000000 -erase 0xE0000000 0x010000 -erase-wait 0xE0000000 -erase 0xE0000000 0x018000 -erase-wait 0xE0000000 -erase 0xE0000000 0x020000 -erase-wait 0xE0000000 -erase 0xE0000000 0x028000 -erase-wait 0xE0000000 -erase 0xE0000000 0x014000 -erase-wait 0xE0000000 -erase 0xE0000000 0x015000 -erase-wait 0xE0000000 -erase 0xE0000000 0x016000 -erase-wait 0xE0000000 -erase 0xE0000000 0x017000 -erase-wait 0xE0000000 -erase 0xE0000000 0x018000 -erase-wait 0xE0000000 -erase 0xE0000000 0x019000 -erase-wait 0xE0000000 -erase 0xE0000000 0x01a000 -erase-wait 0xE0000000 -erase 0xE0000000 0x01b000 -erase-wait 0xE0000000 -erase 0xE0000000 0x01c000 -erase-wait 0xE0000000 -erase 0xE0000000 0x01d000 -erase-wait 0xE0000000 -erase 0xE0000000 0x01e000 -erase-wait 0xE0000000 -erase 0xE0000000 0x01f000 +erase 0xE0000000 0x100000 erase-wait 0xE0000000 load -v ../firebee/bas.elf wait diff --git a/BaS_gcc/sources/dma.c b/BaS_gcc/sources/dma.c index 00e1180..89d5860 100644 --- a/BaS_gcc/sources/dma.c +++ b/BaS_gcc/sources/dma.c @@ -105,8 +105,6 @@ void *dma_memcpy(void *dst, void *src, size_t n) int dma_init(void) { int res; - int version; - char *long_version; xprintf("MCD DMA API initialization: "); res = MCD_initDma((dmaRegs *) &_MBAR[0x8000], SYS_SRAM, MCD_RELOC_TASKS | MCD_COMM_PREFETCH_EN); @@ -115,8 +113,6 @@ int dma_init(void) xprintf("DMA API initialization failed (0x%x)\r\n", res); return 0; } - version = MCD_getVersion(&long_version); - xprintf("DMA API version %d.%d initialized. Tasks are at %p\r\n", version / 0xff, version % 0xff, SYS_SRAM); // test dma_memcpy((void *) 0x10000, (void *) 0x03e00000, 0x00100000); /* copy one megabyte of flash to RAM */ diff --git a/BaS_gcc/sources/interrupts.c b/BaS_gcc/sources/interrupts.c index c54f523..e092c1f 100644 --- a/BaS_gcc/sources/interrupts.c +++ b/BaS_gcc/sources/interrupts.c @@ -28,6 +28,7 @@ #include "bas_printf.h" #include "exceptions.h" #include "interrupts.h" +#include "bas_printf.h" extern void (*rt_vbr[])(void); #define VBR rt_vbr diff --git a/BaS_gcc/sources/pci.c b/BaS_gcc/sources/pci.c index 93a8e81..cdb7351 100644 --- a/BaS_gcc/sources/pci.c +++ b/BaS_gcc/sources/pci.c @@ -41,9 +41,9 @@ #endif /* DEBUG_PCI */ #if MACHINE_FIREBEE -#define pci_config_wait() wait(20000); /* FireBee USB not properly detected otherwise */ +#define pci_config_wait() wait(40000); /* FireBee USB not properly detected otherwise !?? */ #elif MACHINE_M5484LITE -#define pci_config_wait() do { ; } while (0) +#define pci_config_wait() do { __asm__ __volatile("tpf" :::); } while (0) #endif /* @@ -443,6 +443,7 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) uint32_t address; int32_t handle; int16_t index = - 1; + uint8_t il; struct pci_rd *descriptors; int i; uint32_t value; @@ -556,6 +557,12 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) barnum++; } + + /* check if device requests an interrupt */ + il = pci_read_config_byte(handle, PCIIPR); + xprintf("device requests interrupts on interrupt pin %d\r\n", il); + + /* if so, register interrupts */ } } /* mark end of resource chain */ diff --git a/BaS_gcc/sources/sysinit.c b/BaS_gcc/sources/sysinit.c index 1bdff18..dd572f1 100644 --- a/BaS_gcc/sources/sysinit.c +++ b/BaS_gcc/sources/sysinit.c @@ -45,6 +45,7 @@ #include "m5484l.h" #endif /* MACHINE_M5484LITE */ +#include "dma.h" #include "mod_devicetable.h" #include "pci_ids.h" #include "usb.h" diff --git a/BaS_gcc/sources/usb.c b/BaS_gcc/sources/usb.c index 2df8ce9..a0a4063 100644 --- a/BaS_gcc/sources/usb.c +++ b/BaS_gcc/sources/usb.c @@ -326,7 +326,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, * Let's wait a while for the timeout to elapse. * It has no real use, but it keeps the interface happy. */ - wait(timeout * 1000); + wait(timeout); return -1; } return dev->act_len; @@ -1075,6 +1075,7 @@ void usb_scan_devices(void *priv) usb_dev[(bus_index * USB_MAX_DEVICE) + i].devnum = -1; } dev_index[bus_index] = 0; + /* device 0 is always present (root hub, so let it analyze) */ dev = usb_alloc_new_device(bus_index, priv); if (usb_new_device(dev)) @@ -1108,7 +1109,7 @@ void usb_scan_devices(void *priv) * Probes device for being a hub and configurate it */ -//#define USB_HUB_DEBUG +#define USB_HUB_DEBUG #ifdef USB_HUB_DEBUG #define dbg_hub(fmt, args...) xprintf(fmt , ##args) @@ -1159,6 +1160,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub) { int i; struct usb_device *dev; + dev = hub->pusb_dev; /* Enable power to the ports */ dbg_hub("enabling power on all ports\r\n"); @@ -1200,6 +1202,7 @@ static int hub_port_reset(struct usb_device *dev, int port, unsigned short *port int tries; struct usb_port_status portsts; unsigned short portstatus, portchange; + dbg_hub("hub_port_reset: resetting port %d...\r\n", port + 1); for (tries = 0; tries < MAX_TRIES; tries++) { @@ -1209,7 +1212,7 @@ static int hub_port_reset(struct usb_device *dev, int port, unsigned short *port vTaskDelay((200*configTICK_RATE_HZ)/1000); else #endif - wait(200 * 1000); + wait(400); if (usb_get_port_status(dev, port + 1, &portsts) < 0) { dbg_hub("get_port_status failed status %lX\r\n", dev->status); @@ -1229,7 +1232,7 @@ static int hub_port_reset(struct usb_device *dev, int port, unsigned short *port vTaskDelay((200*configTICK_RATE_HZ)/1000); else #endif - wait(200 * 1000); + wait(200); } if (tries == MAX_TRIES) { @@ -1284,7 +1287,7 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port) vTaskDelay((200*configTICK_RATE_HZ)/1000); else #endif - wait(200 * 1000); + wait(200); /* Reset the port */ if (hub_port_reset(dev, port, &portstatus) < 0) { @@ -1296,7 +1299,7 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port) vTaskDelay((200*configTICK_RATE_HZ)/1000); else #endif - wait(200 * 1000); + wait(200); /* Allocate a new device struct for it */ usb = usb_alloc_new_device(dev->usbnum, dev->priv_hcd); if (portstatus & USB_PORT_STAT_HIGH_SPEED) @@ -1340,6 +1343,7 @@ static void usb_hub_events(struct usb_device *dev) { struct usb_port_status portsts; unsigned short portstatus, portchange; + if (usb_get_port_status(dev, i + 1, &portsts) < 0) { dbg_hub("get_port_status failed\r\n");