Index: firmware/export/config.h =================================================================== --- firmware/export/config.h (Revision 23543) +++ firmware/export/config.h (Arbeitskopie) @@ -275,6 +275,7 @@ #define USBOTG_JZ4740 4740 /* Ingenic Jz4740/Jz4732 */ #define USBOTG_AS3525 3525 /* AMS AS3525 */ #define USBOTG_S3C6400X 6400 /* Samsung S3C6400X, also used in the S5L8701 */ +#define USBOTG_S3C2440 2440 /* Samsung S3C2440 */ /* Multiple cores */ #define CPU 0 Index: firmware/export/config-mini2440.h =================================================================== --- firmware/export/config-mini2440.h (Revision 23543) +++ firmware/export/config-mini2440.h (Arbeitskopie) @@ -138,9 +138,18 @@ #define MAX_CONTRAST_SETTING 63 #define DEFAULT_CONTRAST_SETTING 47 /* Match boot contrast */ + +/* USB On-the-go */ +#define CONFIG_USBOTG USBOTG_S3C2440 + /* USB */ -/* TODO:#define HAVE_USBSTACK */ -#define USB_NONE +#define HAVE_USBSTACK +#define USE_ROCKBOX_USB +#define USB_VENDOR_ID 0x05ac +#define USB_PRODUCT_ID 0x120a +#define USB_NUM_ENDPOINTS 5 +#define USE_ROCKBOX_USB +#define USB_DEVBSS_ATTR __attribute__((aligned(16))) #define HAVE_SERIAL Index: firmware/SOURCES =================================================================== --- firmware/SOURCES (Revision 23543) +++ firmware/SOURCES (Arbeitskopie) @@ -303,6 +303,8 @@ target/arm/as3525/usb-drv-as3525.c #elif CONFIG_USBOTG == USBOTG_ISP1583 drivers/isp1583.c +#elif CONFIG_USBOTG == USBOTG_S3C2440 +target/arm/s3c2440/usb-s3c2440.c #endif #else /* !defined(HAVE_USBSTACK) */ #if CONFIG_USBOTG == USBOTG_ISP1362 Index: firmware/target/arm/s3c2440/usb-s3c2440.c =================================================================== --- firmware/target/arm/s3c2440/usb-s3c2440.c (Revision 0) +++ firmware/target/arm/s3c2440/usb-s3c2440.c (Revision 0) @@ -0,0 +1,262 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: usb-s3c6400x.c 23335 2009-10-24 20:31:40Z theseven $ + * + * Copyright (C) 2009 by Dominik Wenger + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "usb.h" + +#include "cpu.h" +#include "system.h" +#include "kernel.h" +#include "panic.h" + +#include "uart-s3c2440.h" + +#ifdef HAVE_USBSTACK +#include "usb_ch9.h" +#include "usb_core.h" +#include +#include "sprintf.h" +#include "power.h" + + + +struct ep_type +{ + bool active; + bool busy; + bool done; + int rc; + int size; + struct wakeup complete; +} ; + +static struct ep_type endpoints[5]; +static struct usb_ctrlrequest ctrlreq USB_DEVBSS_ATTR; + +int usb_drv_port_speed(void) +{ + //TODO + return 0; +} +int usb_drv_request_endpoint(int type, int dir) +{ + uart_printf("usb_drv_request_endpoint\n"); + int ret = -1; + return ret; +} + +void usb_drv_release_endpoint(int ep) +{ + uart_printf("usb_drv_release_endpoint\n"); +} + +static void usb_reset(void) +{ + uart_printf("usb_reset\n"); + +} + +/* IRQ handler */ +void USBD(void) +{ + /* save index */ + int idx = INDEX_REG; + + /* read status regs */ + int usb_status = USB_INT_REG; + int ep_status = EP_INT_REG; + int pwr_status = PWR_REG; + + /* clear interrupt */ + USB_INT_REG = USB_INT_REG; + + if (usb_status & (1<<2)) /* bus reset */ + { + uart_printf("reset int\n"); + /* setup ep 0 */ + INDEX_REG = 0x0; + MAXP_REG = 0x1; + + EP0_CSR = (1<<7)|(1<<6); + FUNC_ADDR_REG = 0x80; + usb_core_bus_reset(); + } + + if( usb_status & (1<<1)) + { + uart_printf("resume int\n"); + } + + if(usb_status & (1<<0)) + { + uart_printf("suspend int\n"); + } + + if(ep_status != 0) + { + uart_printf("USB ep int: usbstat: %02x epstat: %02x pwr: %02x\n", + usb_status,ep_status,pwr_status); + + } + + + /* restore index */ + INDEX_REG = idx; + + /* ack interrupt */ + SRCPND = USBD_MASK; + INTPND = USBD_MASK; + + +} +void usb_drv_set_address(int address) +{ + uart_printf("usb_drv_set_address\n"); + FUNC_ADDR_REG = 0x80 |address; +} +int usb_drv_send(int endpoint, void *ptr, int length) +{ + uart_printf("usb_drv_send\n"); + + return -1; +} + +int usb_drv_send_nonblocking(int endpoint, void *ptr, int length) +{ + uart_printf("usb_drv_send_nonblocking\n"); + + return 0; +} + +int usb_drv_recv(int endpoint, void* ptr, int length) +{ + uart_printf("usb_drv_recv\n"); + + return 0; +} + +void usb_drv_cancel_all_transfers(void) +{ + uart_printf("usb_drv_cancel_all_transvers\n"); + +} + +void usb_drv_set_test_mode(int mode) +{ + (void)mode; +} + +bool usb_drv_stalled(int endpoint, bool in) +{ + uart_printf("usb_drv_stalled\n"); + return false; +} + +void usb_drv_stall(int endpoint, bool stall, bool in) +{ + uart_printf("usb_drv_stall\n"); + +} + +void usb_drv_init(void) +{ + uart_printf("usb_drv_init\n"); + + /* Enable USB clock */ + CLKCON |= (1<<7); + + EP_INT_EN_REG = 0x0; + + USB_INT_EN_REG = 0x0; + /* configure usb pads */ + MISCCR &= ~((1<<3)|(1<<13)); + /* dont disable usb clock */ + CLKSLOW &= ~(1<<7); + + int temp = EP_INT_REG; + temp = USB_INT_REG; + EP_INT_REG = 0xff; + USB_INT_REG = 0xff; + + /*enable usb interrupts for reset and resume/suspend */ + USB_INT_EN_REG |= (1<<2) | (1<<0); + + /*enable ep interrupts */ + EP_INT_EN_REG = 0xff; + + /* pullup enable */ /* TODO is it GPC or GPG ? */ + s3c_regclr32(&INTMSK, USBD_MASK); + +} + +void usb_drv_exit(void) +{ + uart_printf("usb_drv_exist"); +} + +void usb_init_device(void) +{ + uart_printf("usb_init_device\n"); + unsigned int i; + for (i = 0; i < sizeof(endpoints)/sizeof(struct ep_type); i++) + wakeup_init(&endpoints[i].complete); + usb_drv_init(); +} + +void usb_enable(bool on) +{ + uart_printf("usb_enable %d\n",on); + usb_core_init(); + + + // if (on) usb_core_init(); + // else usb_core_exit(); +} + +void usb_attach(void) +{ + usb_enable(true); +} + +int usb_detect(void) +{ + + if (GPCDAT&(1<<5)) + return USB_EXTRACTED; + return USB_INSERTED; +} + +#else +void usb_init_device(void) +{ +} + +void usb_enable(bool on) +{ + (void)on; +} + +/* Always return false for now */ +int usb_detect(void) +{ + return USB_EXTRACTED; +} +#endif