Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

importing files from sgs2 host driver (this removes kevinh's fixes th…

…ough)

Signed-off-by: stratosk <stratosk@albert.(none)>
  • Loading branch information...
commit eaccfe7a1c66d0c1bdb092bf132029fb449f4b53 1 parent 17f7137
@sztupy sztupy authored stratosk committed
Showing with 2,972 additions and 3,550 deletions.
  1. +6 −1 arch/arm/mach-s5pv210/mach-aries.c
  2. +1 −1  drivers/usb/host/s3c-otg/Makefile
  3. +8 −10 drivers/usb/host/s3c-otg/s3c-otg-common-common.h
  4. +6 −6 drivers/usb/host/s3c-otg/s3c-otg-common-const.h
  5. +52 −134 drivers/usb/host/s3c-otg/s3c-otg-common-datastruct.h
  6. +6 −5 drivers/usb/host/s3c-otg/s3c-otg-common-errorcode.h
  7. +10 −10 drivers/usb/host/s3c-otg/s3c-otg-common-regdef.h
  8. +23 −24 drivers/usb/host/s3c-otg/s3c-otg-hcdi-debug.h
  9. +183 −148 drivers/usb/host/s3c-otg/s3c-otg-hcdi-driver.c
  10. +8 −11 drivers/usb/host/s3c-otg/s3c-otg-hcdi-driver.h
  11. +371 −442 drivers/usb/host/s3c-otg/s3c-otg-hcdi-hcd.c
  12. +33 −25 drivers/usb/host/s3c-otg/s3c-otg-hcdi-hcd.h
  13. +178 −185 drivers/usb/host/s3c-otg/s3c-otg-hcdi-kal.h
  14. +71 −79 drivers/usb/host/s3c-otg/s3c-otg-hcdi-list.h
  15. +79 −75 drivers/usb/host/s3c-otg/s3c-otg-hcdi-memory.h
  16. +108 −144 drivers/usb/host/s3c-otg/s3c-otg-isr.c
  17. +7 −7 drivers/usb/host/s3c-otg/s3c-otg-isr.h
  18. +339 −444 drivers/usb/host/s3c-otg/s3c-otg-oci.c
  19. +10 −10 drivers/usb/host/s3c-otg/s3c-otg-oci.h
  20. +325 −403 drivers/usb/host/s3c-otg/s3c-otg-roothub.c
  21. +15 −32 drivers/usb/host/s3c-otg/s3c-otg-roothub.h
  22. +87 −127 drivers/usb/host/s3c-otg/s3c-otg-scheduler-ischeduler.c
  23. +47 −36 drivers/usb/host/s3c-otg/s3c-otg-scheduler-readyq.c
  24. +107 −151 drivers/usb/host/s3c-otg/s3c-otg-scheduler-scheduler.c
  25. +30 −34 drivers/usb/host/s3c-otg/s3c-otg-scheduler-scheduler.h
  26. +250 −319 drivers/usb/host/s3c-otg/s3c-otg-transfer-common.c
  27. +45 −52 drivers/usb/host/s3c-otg/s3c-otg-transfer-nonperiodic.c
  28. +36 −39 drivers/usb/host/s3c-otg/s3c-otg-transfer-periodic.c
  29. +12 −15 drivers/usb/host/s3c-otg/s3c-otg-transfer-transfer.h
  30. +110 −110 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-bulk.c
  31. +14 −14 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-bulk.h
  32. +4 −4 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-checker.h
  33. +82 −116 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-common.c
  34. +6 −6 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-common.h
  35. +163 −182 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-control.c
  36. +16 −17 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-control.h
  37. +110 −118 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-interrupt.c
  38. +14 −14 drivers/usb/host/s3c-otg/s3c-otg-transferchecker-interrupt.h
View
7 arch/arm/mach-s5pv210/mach-aries.c
@@ -5549,8 +5549,13 @@ void otg_host_phy_init(void)
{
__raw_writel(__raw_readl(S5P_USB_PHY_CONTROL)
|(0x1<<0), S5P_USB_PHY_CONTROL); /*USB PHY0 Enable */
+// from galaxy tab otg host:
+// __raw_writel((__raw_readl(S3C_USBOTG_PHYPWR)
+// &~(0x3<<3)&~(0x1<<0))|(0x1<<5), S3C_USBOTG_PHYPWR);
+// from galaxy s2 otg host:
__raw_writel((__raw_readl(S3C_USBOTG_PHYPWR)
- &~(0x3<<3)&~(0x1<<0))|(0x1<<5), S3C_USBOTG_PHYPWR);
+ &~(0x7<<3)&~(0x1<<0)), S3C_USBOTG_PHYPWR);
+
__raw_writel((__raw_readl(S3C_USBOTG_PHYCLK)
&~(0x1<<4))|(0x7<<0), S3C_USBOTG_PHYCLK);
View
2  drivers/usb/host/s3c-otg/Makefile
@@ -4,7 +4,7 @@
obj-$(CONFIG_USB_S3C_OTG_HOST) += s3c_otg_hcd.o
-s3c_otg_hcd-objs += s3c-otg-hcdi-driver.o s3c-otg-hcdi-hcd.o
+s3c_otg_hcd-objs += s3c-otg-hcdi-driver.o s3c-otg-hcdi-hcd.o
s3c_otg_hcd-objs += s3c-otg-transfer-common.o s3c-otg-transfer-nonperiodic.o \
s3c-otg-transfer-periodic.o
s3c_otg_hcd-objs += s3c-otg-scheduler-ischeduler.o s3c-otg-scheduler-scheduler.o \
View
18 drivers/usb/host/s3c-otg/s3c-otg-common-common.h
@@ -3,7 +3,7 @@
*
* @file s3c-otg-common-common.h
* @brief it includes common header files for all modules \n
- * @version
+ * @version
* ex)-# Jun 11,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Creating the initial version of this code \n
* @see None
@@ -23,17 +23,17 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
-
+
#ifndef _S3C_OTG_COMMON_COMMON_H_
#define _S3C_OTG_COMMON_COMMON_H_
-
+
#ifdef __cplusplus
extern "C"
{
#endif
-
+
//#include "s3c-otg-common-typedef.h"
-#include "s3c-otg-common-errorcode.h"
+#include "s3c-otg-common-errorcode.h"
#include <linux/errno.h>
#include <linux/usb.h>
@@ -43,9 +43,7 @@ extern "C"
//Kernel Version
#define KERNEL_2_6_21
-#define CHARGER_IC_TEST 0
-
-#ifdef __cplusplus
-}
-#endif
+#ifdef __cplusplus
+}
+#endif
#endif /* _S3C_OTG_COMMON_COMMON_H_ */
View
12 drivers/usb/host/s3c-otg/s3c-otg-common-const.h
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* [File Name] : s3c-otg-common-const.h
@@ -6,7 +6,7 @@
* [Author] : Yang Soon Yeal { syatom.yang@samsung.com }
* [Department] : System LSI Division/System SW Lab
* [Created Date]: 2008/06/03
- * [Revision History]
+ * [Revision History]
* (1) 2008/06/03 by Yang Soon Yeal { syatom.yang@samsung.com }
* - Created s3c-otg-common-const.h file and defines some constants.
*
@@ -27,8 +27,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
-#ifndef _CONST_TYPE_DEF_H_
-#define _CONST_TYPE_DEF_H_
+#ifndef _CONST_TYPE_DEF_H_
+#define _CONST_TYPE_DEF_H_
/*
// ----------------------------------------------------------------------------
@@ -47,9 +47,9 @@ extern "C"
/**
* @def OTG_PORT_NUMBER
- *
+ *
* @brief write~ description
- *
+ *
* describe in detail
*/
#define OTG_PORT_NUMBER 0
View
186 drivers/usb/host/s3c-otg/s3c-otg-common-datastruct.h
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* [File Name] : s3c-otg-common-datastruct.h
@@ -6,11 +6,11 @@
* [Author] : Yang Soon Yeal { syatom.yang@samsung.com }
* [Department] : System LSI Division/System SW Lab
* [Created Date]: 2008/06/03
- * [Revision History]
+ * [Revision History]
* (1) 2008/06/03 by Yang Soon Yeal { syatom.yang@samsung.com }
* - Created this file and defines Data Structure to be managed by Transfer.
* (2) 2008/08/18 by SeungSoo Yang ( ss1.yang@samsung.com )
- * - modifying ED structure
+ * - modifying ED structure
*
****************************************************************************/
/****************************************************************************
@@ -29,8 +29,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
-#ifndef _DATA_STRUCT_DEF_H
-#define _DATA_STRUCT_DEF_H
+#ifndef _DATA_STRUCT_DEF_H
+#define _DATA_STRUCT_DEF_H
/*
// ----------------------------------------------------------------------------
@@ -38,6 +38,8 @@
// ----------------------------------------------------------------------------
*/
+#include <linux/wakelock.h>
+#include <plat/s5p-otghost.h>
//#include "s3c-otg-common-typedef.h"
#include "s3c-otg-hcdi-list.h"
@@ -49,92 +51,13 @@ extern "C"
{
#endif
-typedef struct
-{
- u32 apll_lock; // 0x00
- u32 MPLL_LOCK; // 0x04
- u32 EPLL_LOCK; // 0x08
- u32 APLL_CON; // 0x0c
-
- u32 MPLL_CON; // 0x10
- u32 EPLL_CON0; // 0x14
- u32 EPLL_CON1; // 0x18
- u32 CLK_SRC; // 0x1c
-
- u32 CLK_DIV0; // 0x20
- u32 CLK_DIV1; // 0x24
- u32 CLK_DIV2; // 0x28
- u32 CLK_OUT; // 0x2c
-
- u32 HCLK_GATE; // 0x30
- u32 PCLK_GATE; // 0x34
- u32 SCLK_GATE; // 0x38
- u32 PAD0; // 0x3c
-
- u32 PAD1[48]; // 0x40~0xff
-
- u32 AHB_CON0; // 0x100
- u32 AHB_CON1; // 0x104
- u32 AHB_CON2; // 0x108
- u32 PAD2; // 0x10c
-
- u32 SDMA_SEL; // 0x110
- u32 SW_RST; // 0x114
- u32 SYS_ID; // 0x118
- u32 PAD3; // 0x11c
-
- u32 MEM_SYS_CFG; // 0x120
- u32 QOS_OVERRIDE0; // 0x124
- u32 QOS_OVERRIDE1; // 0x128
- u32 MEM_CFG_STAT; // 0x12c
-
- u32 PAD4[436]; // 0x130~0x7ff
-
- u32 PAD5; // 0x800
- u32 PWR_CFG; // 0x804
- u32 EINT_MASK; // 0x808
- u32 PAD6; // 0x80c
-
- u32 NORMAL_CFG; // 0x810
- u32 STOP_CFG; // 0x814
- u32 SLEEP_CFG; // 0x818
- u32 PAD7; // 0x81c
-
- u32 OSC_FREQ; // 0x820
- u32 OSC_STABLE; // 0x824
- u32 PWR_STABLE; // 0x828
- u32 FPC_STABLE; // 0x82c
-
- u32 MTC_STABLE; // 0x830
- u32 PAD8[3]; // 0x834~0x83f
-
- u32 PAD9[48]; // 0x840~0x8ff
-
- u32 OTHERS; // 0x900
- u32 RST_STAT; // 0x904
- u32 WAKEUP_STAT; // 0x908
- u32 BLK_PWR_STAT; // 0x90c
-
- u32 PAD10[60]; // 0x910~0x9ff
-
- u32 INFORM0; // 0xa00
- u32 INFORM1; // 0xa04
- u32 INFORM2; // 0xa08
- u32 INFORM3; // 0xa0c
-
- u32 INFORM4; // 0xa10
- u32 INFORM5; // 0xa14
- u32 INFORM6; // 0xa18
- u32 INFORM7; // 0xa1c
-} S3C6400_SYSCON_REG, *PS3C6400_SYSCON_REG;
-
typedef union _hcintmsk_t
{
- // raw register data
+ // raw register data
u32 d32;
- // register bits
- struct
+ // register bits
+ struct
{
unsigned xfercompl : 1;
unsigned chhltd : 1;
@@ -203,7 +126,7 @@ typedef struct standard_dev_req_info
bool is_data_stage;
u8 conrol_transfer_stage;
u32 vir_standard_dev_req_addr;
- u32 phy_standard_dev_req_addr;
+ u32 phy_standard_dev_req_addr;
}standard_dev_req_info_t;
@@ -211,7 +134,7 @@ typedef struct control_data_tgl_t
{
u8 setup_tgl;
u8 data_tgl;
- u8 status_tgl;
+ u8 status_tgl;
}control_data_tgl_t;
@@ -229,7 +152,7 @@ typedef struct ed_status
typedef struct ed_desc
-{
+{
u8 device_addr;
u8 endpoint_num;
bool is_ep_in;
@@ -274,10 +197,10 @@ typedef struct stransfer
typedef struct ed
{
- u32 ed_id;
+ u32 ed_id;
bool is_halted;
bool is_need_to_insert_scheduler;
- ed_dest_t ed_desc;
+ ed_dest_t ed_desc;
ed_status_t ed_status;
otg_list_head ed_list_entry;
otg_list_head td_list_entry;
@@ -290,11 +213,11 @@ typedef struct ed
typedef struct td
{
- u32 td_id;
+ u32 td_id;
ed_t *parent_ed_p;
void *call_back_func_p;
void *call_back_func_param_p;
- bool is_transferring;
+ bool is_transferring;
bool is_transfer_done;
u32 transferred_szie;
bool is_standard_dev_req;
@@ -307,7 +230,7 @@ typedef struct td
USB_ERROR_CODE error_code;
u32 err_cnt;
otg_list_head td_list_entry;
-
+
//Isochronous Transfer Specific
u32 isoch_packet_num;
isoch_packet_desc_t *isoch_packet_desc_p;
@@ -325,13 +248,13 @@ typedef struct td
//Define Data Structures of Scheduler.
typedef struct trans_ready_q
{
-bool is_periodic_transfer;
-otg_list_head trans_ready_q_list_head;
-u32 trans_ready_entry_num;
+ bool is_periodic_transfer;
+ otg_list_head trans_ready_q_list_head;
+ u32 trans_ready_entry_num;
-//In case of Periodic Transfer
-u32 total_perio_bus_bandwidth;
-u8 total_alloc_chnum;
+ //In case of Periodic Transfer
+ u32 total_perio_bus_bandwidth;
+ u8 total_alloc_chnum;
}trans_ready_q_t;//, *trans_ready_q_t *,**trans_ready_q_t **;
@@ -340,7 +263,7 @@ u8 total_alloc_chnum;
#define MAX_COUNT 10000
#define INT_ALL 0xffffffff
-typedef union _haint_t
+typedef union _haint_t
{
u32 d32;
struct
@@ -370,7 +293,7 @@ typedef union _gresetctl_t
/** raw register data */
u32 d32;
/** register bits */
- struct
+ struct
{
unsigned csftrst : 1;
unsigned hsftrst : 1;
@@ -381,7 +304,7 @@ typedef union _gresetctl_t
unsigned txfnum : 5;
unsigned reserved11_29 : 19;
unsigned dmareq : 1;
- unsigned ahbidle : 1;
+ unsigned ahbidle : 1;
} b;
} gresetctl_t;
@@ -527,7 +450,7 @@ typedef union _hcfg_t
u32 d32;
/** register bits */
- struct
+ struct
{
/** FS/LS Phy Clock Select */
unsigned fslspclksel : 2;
@@ -546,7 +469,7 @@ typedef union _hprt_t
/** raw register data */
u32 d32;
/** register bits */
- struct
+ struct
{
unsigned prtconnsts : 1;
unsigned prtconndet : 1;
@@ -612,7 +535,7 @@ typedef union _gintmsk_t
} gintmsk_t;
-typedef struct _hc_t
+typedef struct _hc_t
{
u8 hc_num; // Host channel number used for register address lookup
@@ -690,7 +613,7 @@ typedef union _hcchar_t
u32 d32;
// register bits
- struct
+ struct
{
// Maximum packet size in bytes
unsigned mps : 11;
@@ -698,9 +621,9 @@ typedef union _hcchar_t
// Endpoint number
unsigned epnum : 4;
- // 0: OUT, 1: IN
+ // 0: OUT, 1: IN
unsigned epdir : 1;
-#define HCDIR_OUT 0
+#define HCDIR_OUT 0
#define HCDIR_IN 1
unsigned reserved : 1;
@@ -708,43 +631,43 @@ typedef union _hcchar_t
// 0: Full/high speed device, 1: Low speed device
unsigned lspddev : 1;
- // 0: Control, 1: Isoc, 2: Bulk, 3: Intr
+ // 0: Control, 1: Isoc, 2: Bulk, 3: Intr
unsigned eptype : 2;
#define OTG_EP_TYPE_CONTROL 0
#define OTG_EP_TYPE_ISOC 1
#define OTG_EP_TYPE_BULK 2
#define OTG_EP_TYPE_INTR 3
- // Packets per frame for periodic transfers. 0 is reserved.
+ // Packets per frame for periodic transfers. 0 is reserved.
unsigned multicnt : 2;
- // Device address
+ // Device address
unsigned devaddr : 7;
// Frame to transmit periodic transaction.
// 0: even, 1: odd
unsigned oddfrm : 1;
- // Channel disable
+ // Channel disable
unsigned chdis : 1;
- // Channel enable
+ // Channel enable
unsigned chen : 1;
} b;
} hcchar_t;
typedef union _hctsiz_t
{
- // raw register data
+ // raw register data
u32 d32;
- // register bits
- struct
+ // register bits
+ struct
{
// Total transfer size in bytes
unsigned xfersize : 19;
- // Data packets to transfer
+ // Data packets to transfer
unsigned pktcnt : 10;
// Packet ID for next data packet
@@ -768,11 +691,11 @@ typedef union _hctsiz_t
typedef union _grxstsr_t
{
- // raw register data
+ // raw register data
u32 d32;
- // register bits
- struct
+ // register bits
+ struct
{
unsigned chnum : 4;
unsigned bcnt : 11;
@@ -784,11 +707,11 @@ typedef union _grxstsr_t
typedef union _hfir_t
{
- // raw register data
+ // raw register data
u32 d32;
- // register bits
- struct
+ // register bits
+ struct
{
unsigned frint : 16;
unsigned Reserved : 16;
@@ -801,7 +724,7 @@ typedef union _hfnum_t
u32 d32;
// register bits
- struct
+ struct
{
unsigned frnum : 16;
#define HFNUM_MAX_FRNUM 0x3FFF
@@ -814,7 +737,7 @@ typedef union grstctl_t
/** raw register data */
u32 d32;
/** register bits */
- struct
+ struct
{
unsigned csftrst : 1;
unsigned hsftrst : 1;
@@ -825,13 +748,10 @@ typedef union grstctl_t
unsigned txfnum : 5;
unsigned reserved11_29 : 19;
unsigned dmareq : 1;
- unsigned ahbidle : 1;
+ unsigned ahbidle : 1;
} b;
} grstctl_t;
-
-
-
typedef struct hc_info
{
hcintmsk_t hc_int_msk;
@@ -845,7 +765,7 @@ typedef struct hc_info
#define USB_MAXCHILDREN (31)
#endif
-typedef struct _usb_hub_descriptor_t
+typedef struct _usb_hub_descriptor_t
{
u8 desc_length;
u8 desc_type;
@@ -858,10 +778,8 @@ typedef struct _usb_hub_descriptor_t
u8 port_pwr_ctrl_mask[(USB_MAXCHILDREN + 1 + 7) / 8];
}usb_hub_descriptor_t;
-
#ifdef __cplusplus
}
#endif
-
#endif
View
11 drivers/usb/host/s3c-otg/s3c-otg-common-errorcode.h
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* [File Name] : s3c-otg-common-errorcode.h
@@ -6,7 +6,7 @@
* [Author] : Yang Soon Yeal { syatom.yang@samsung.com }
* [Department] : System LSI Division/System SW Lab
* [Created Date]: 2008/06/03
- * [Revision History]
+ * [Revision History]
* (1) 2008/06/03 by Yang Soon Yeal { syatom.yang@samsung.com }
* - Created this file.
* (2) 2008/08/18 by SeungSoo Yang ( ss1.yang@samsung.com )
@@ -29,8 +29,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
-#ifndef _ERROR_CODE_DEF_H
-#define _ERROR_CODE_DEF_H
+#ifndef _ERROR_CODE_DEF_H
+#define _ERROR_CODE_DEF_H
/*
// ----------------------------------------------------------------------------
@@ -62,6 +62,7 @@ typedef int USB_ERROR_CODE;
#define USB_ERR_NODEV -ENODEV
#define USB_ERR_NOMEM -ENOMEM
#define USB_ERR_NOSPACE -ENOSPC
+#define USB_ERR_NOIO -EIO
//OTG-HCD error code
#define USB_ERR_NOELEMENT -ENOENT
@@ -91,7 +92,7 @@ typedef int USB_ERROR_CODE;
#define USB_ERR_STATUS_XACTERR -EPROTO
#define USB_ERR_STATUS_STALL -EPIPE
#define USB_ERR_STATUS_BBLERR -EOVERFLOW
-#define USB_ERR_STATUS_AHBERR -EIO
+#define USB_ERR_STATUS_AHBERR -EIO
#define USB_ERR_STATUS_FRMOVRUN_OUT -ENOSR
#define USB_ERR_STATUS_FRMOVRUN_IN -ECOMM
#define USB_ERR_STATUS_SHORTREAD -EREMOTEIO
View
20 drivers/usb/host/s3c-otg/s3c-otg-common-regdef.h
@@ -1,13 +1,13 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
-* [File Name] : S3C6400_OtgDevice.h
-* [Description] :
-*
+* [File Name] : s3c-otg-common-regdef.h
+* [Description] :
+*
* [Author] : Kyu Hyeok Jang { kyuhyeok.jang@samsung.com }
* [Department] : System LSI Division/Embedded Software Center
* [Created Date]: 2007/12/15
-* [Revision History]
+* [Revision History]
* (1) 2007/12/15 by Kyu Hyeok Jang { kyuhyeok.jang@samsung.com }
* - Created
*
@@ -62,7 +62,7 @@ typedef struct {
#define GHWCFG2 0x048 // User HW Config2
#define GHWCFG3 0x04C // User HW Config3
#define GHWCFG4 0x050 // User HW Config4
-
+
#define HPTXFSIZ 0x100 // Host Periodic Transmit FIFO Size
#define DPTXFSIZ1 0x104 // Device Periodic Transmit FIFO-1 Size
#define DPTXFSIZ2 0x108 // Device Periodic Transmit FIFO-2 Size
@@ -157,7 +157,7 @@ typedef struct {
// IN_CSR2_REG Bit definitions
#define IN_DMA_INT_DISABLE 0x10
-#define SET_MODE_IN 0x20
+#define SET_MODE_IN 0x20
#define EPTYPE (0x3<<18)
#define SET_TYPE_CONTROL (0x0<<18)
@@ -205,7 +205,7 @@ typedef struct {
#define EP14_OUT_INT (0x1<<30)
#define EP15_OUT_INT (0x1<<31)
-// GOTGINT
+// GOTGINT
#define SesEndDet (0x1<<2)
// GRSTCTL
@@ -217,7 +217,7 @@ typedef struct {
#define CSftRst (0x1<<0)
#define CLEAR_ALL_EP_INTRS 0xffffffff
-
+
#define EP_INTERRUPT_DISABLE_ALL 0x0 // Bits to write to EP_INT_EN_REG - Use CLEAR
// DMA control register bit definitions
@@ -297,6 +297,6 @@ inline void ClearReg(
}
#endif
-#endif
+#endif
View
47 drivers/usb/host/s3c-otg/s3c-otg-hcdi-debug.h
@@ -1,9 +1,9 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* @file s3c-otg-hcdi-debug.c
* @brief It provides debug functions for display message \n
- * @version
+ * @version
* -# Jun 9,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Creating the initial version of this code \n
* -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com) \n
@@ -34,7 +34,7 @@ extern "C"
{
#endif
-#define OTG_DEBUG 1
+#define OTG_DEBUG
#ifdef OTG_DEBUG
#if 0
@@ -42,48 +42,47 @@ extern "C"
#endif
#define OTG_DBG_OTGHCDI_DRIVER true
-#define OTG_DBG_OTGHCDI_HCD false // not safe to turn on
-#define OTG_DBG_OTGHCDI_KAL true
-#define OTG_DBG_OTGHCDI_LIST false // too verbose
-#define OTG_DBG_OTGHCDI_MEM false // too verbost
-
-#define OTG_DBG_TRANSFER false
-#define OTG_DBG_SCHEDULE false // this breaks debugging
-#define OTG_DBG_SCHEDULE2 false
-#define OTG_DBG_SCHEDULE3 false
-#define OTG_DBG_OCI false // too verbose
-#define OTG_DBG_DONETRASF false
-#define OTG_DBG_ISR false
-#define OTG_DBG_ROOTHUB true
+#define OTG_DBG_OTGHCDI_HCD false
+#define OTG_DBG_OTGHCDI_KAL false
+#define OTG_DBG_OTGHCDI_LIST false
+#define OTG_DBG_OTGHCDI_MEM false
+
+#define OTG_DBG_TRANSFER false
+#define OTG_DBG_SCHEDULE false
+#define OTG_DBG_OCI false
+#define OTG_DBG_DONETRASF false
+#define OTG_DBG_ISR false
+#define OTG_DBG_ROOTHUB false
+
#include <linux/kernel.h> //for printk
#define otg_err(is_active, msg...) \
do{ if ((is_active) == true)\
{\
- printk("otg_err: in %s()::%05d ", __func__ , __LINE__); \
- printk("=> " msg); \
+ pr_err("otg_err: in %s()::%05d ", __func__ , __LINE__); \
+ pr_err("=> " msg); \
}\
}while(0)
#define otg_dbg(is_active, msg...) \
do{ if ((is_active) == true)\
{\
- printk("otg_dbg: in %s()::%05d ", __func__, __LINE__); \
- printk("=> " msg); \
+ pr_info("otg_dbg: in %s()::%05d ", __func__, __LINE__); \
+ pr_info("=> " msg); \
}\
}while(0)
#else //OTG_DEBUG
-# define otg_err(is_active, msg...) do{}while(0)
+# define otg_err(is_active, msg...) do{}while(0)
# define otg_dbg(is_active, msg...) do{}while(0)
#endif
-#ifdef __cplusplus
-}
-#endif
+#ifdef __cplusplus
+}
+#endif
#endif /* _S3C_OTG_HCDI_DEBUG_H_ */
View
331 drivers/usb/host/s3c-otg/s3c-otg-hcdi-driver.c
@@ -1,9 +1,9 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* @file s3c-otg-hcdi-driver.c
* @brief It provides functions related with module for OTGHCD driver. \n
- * @version
+ * @version
* -# Jun 9,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Creating the initial version of this code \n
* -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com) \n
@@ -11,7 +11,7 @@
* -# Aug 18,2008 v1.3 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Modifying for successful rmmod & disconnecting \n
* @see None
- *
+ *
****************************************************************************/
/****************************************************************************
* This program is free software; you can redistribute it and/or modify
@@ -30,89 +30,103 @@
****************************************************************************/
#include "s3c-otg-hcdi-driver.h"
-#include <linux/mfd/max8998.h>
+extern void otg_phy_off(void);
/**
* static int s5pc110_otg_drv_probe (struct platform_device *pdev)
- *
+ *
* @brief probe function of OTG hcd platform_driver
- *
+ *
* @param [in] pdev : pointer of platform_device of otg hcd platform_driver
- *
+ *
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If fail \n
- * @remark
+ * @remark
* it allocates resources of it and call other modules' init function.
* then call usb_create_hcd, usb_add_hcd, s5pc110_otghcd_start functions
*/
-static struct clk *otg_clock = NULL;
+struct usb_hcd* g_pUsbHcd = NULL;
-extern void max8998_ldo3_8_control(int enable, unsigned int flag);
+static void otg_power_work(struct work_struct *work)
+{
+ struct sec_otghost *otghost = container_of(work,
+ struct sec_otghost, work);
+ struct sec_otghost_data *hdata = otghost->otg_data;
+
+ if (hdata && hdata->set_pwr_cb) {
+ hdata->set_pwr_cb(0);
+#ifdef CONFIG_USB_HOST_NOTIFY
+ if (g_pUsbHcd)
+ host_state_notify(&g_pUsbHcd->ndev, NOTIFY_HOST_OVERCURRENT);
+#endif
+ } else {
+ otg_err(true, "invalid otghost data\n");
+ }
+}
static int s5pc110_otg_drv_probe (struct platform_device *pdev)
{
-
int ret_val = 0;
u32 reg_val = 0;
-
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
- "s3c_otg_drv_probe \n");
-
- otg_clock = clk_get(&pdev->dev, "otg");
- if (otg_clock == NULL) {
- otg_err(OTG_DBG_OTGHCDI_DRIVER,
- "failed to find otg clock source\n");
- return -ENOENT;
- }
- clk_enable(otg_clock);
- // chul2
- max8998_ldo3_8_control(1, LDO_USB);
- mdelay(1);
+ struct sec_otghost *otghost = NULL;
+ struct sec_otghost_data *otg_data = dev_get_platdata(&pdev->dev);
+
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER, "s3c_otg_drv_probe\n");
+
-///init for host mode
-/**
+ /*init for host mode*/
+ /**
Allocate memory for the base HCD & Initialize the base HCD.
-*/
+ */
g_pUsbHcd = usb_create_hcd(&s5pc110_otg_hc_driver, &pdev->dev,
- "s3cotg"/*pdev->dev.bus_id*/
- );
- if (g_pUsbHcd == NULL)
- {
+ "s3cotg");/*pdev->dev.bus_id*/
+ if (g_pUsbHcd == NULL) {
ret_val = -ENOMEM;
- otg_err(OTG_DBG_OTGHCDI_DRIVER,
+ otg_err(OTG_DBG_OTGHCDI_DRIVER,
"failed to usb_create_hcd\n");
goto err_out_clk;
}
+ /* mapping hcd resource & device resource*/
-// mapping hcd resource & device resource
-
g_pUsbHcd->rsrc_start = pdev->resource[0].start;
- g_pUsbHcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
+ g_pUsbHcd->rsrc_len = pdev->resource[0].end -
+ pdev->resource[0].start + 1;
- if (!request_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len, gHcdName))
- {
- otg_err(OTG_DBG_OTGHCDI_DRIVER,
+ if (!request_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len,
+ gHcdName)) {
+ otg_err(OTG_DBG_OTGHCDI_DRIVER,
"failed to request_mem_region\n");
- reg_val = -EBUSY;
+ ret_val = -EBUSY;
goto err_out_create_hcd;
}
-//Physical address => Virtual address
- g_pUsbHcd->regs = S3C_VA_OTG;
+ /* Physical address => Virtual address */
+ g_pUsbHcd->regs = S3C_VA_OTG;
g_pUsbHcd->self.otg_port = 1;
-
+
g_pUDCBase = (u8 *)g_pUsbHcd->regs;
- /// call others' init()
- reg_val = otg_hcd_init_modules();
- if( reg_val != USB_ERR_SUCCESS)
- {
- otg_err(OTG_DBG_OTGHCDI_DRIVER,
+ otghost = hcd_to_sec_otghost(g_pUsbHcd);
+
+ if (otghost == NULL) {
+ otg_err(true, "failed to get otghost hcd\n");
+ ret_val = USB_ERR_FAIL;
+ goto err_out_create_hcd;
+ }
+ otghost->otg_data = otg_data;
+
+ INIT_WORK(&otghost->work, otg_power_work);
+ otghost->wq = create_singlethread_workqueue("sec_otghostd");
+
+ /* call others' init() */
+ ret_val = otg_hcd_init_modules(otghost);
+ if (ret_val != USB_ERR_SUCCESS) {
+ otg_err(OTG_DBG_OTGHCDI_DRIVER,
"failed to otg_hcd_init_modules\n");
- reg_val = USB_ERR_FAIL;
+ ret_val = USB_ERR_FAIL;
goto err_out_create_hcd;
}
@@ -121,94 +135,118 @@ static int s5pc110_otg_drv_probe (struct platform_device *pdev)
* Read and verify the SNPSID register contents. The value should be
* 0x45F42XXX, which corresponds to "OT2", as in "OTG version 2.XX".
*/
- //reg_val = read_reg_32((unsigned int *)((u8 *)g_pUsbHcd->regs + 0x40));
-
- reg_val = read_reg_32(0x40);
- if ((reg_val & 0xFFFFF000) != 0x4F542000)
- {
- otg_err(OTG_DBG_OTGHCDI_DRIVER,
+ reg_val = read_reg_32(0x40);
+ if ((reg_val & 0xFFFFF000) != 0x4F542000) {
+ otg_err(OTG_DBG_OTGHCDI_DRIVER,
"Bad value for SNPSID: 0x%x\n", reg_val);
ret_val = -EINVAL;
goto err_out_create_hcd_init;
}
+#ifdef CONFIG_USB_HOST_NOTIFY
+ if (otg_data->host_notify) {
+ g_pUsbHcd->host_notify = otg_data->host_notify;
+ g_pUsbHcd->ndev.name = dev_name(&pdev->dev);
+ ret_val = host_notify_dev_register(&g_pUsbHcd->ndev);
+ if (ret_val) {
+ otg_err(OTG_DBG_OTGHCDI_DRIVER,
+ "Failed to host_notify_dev_register\n");
+ goto err_out_create_hcd_init;
+ }
+ }
+#endif
+#ifdef CONFIG_USB_SEC_WHITELIST
+ if (otg_data->sec_whlist_table_num)
+ g_pUsbHcd->sec_whlist_table_num = otg_data->sec_whlist_table_num;
+#endif
/*
* Finish generic HCD initialization and start the HCD. This function
* allocates the DMA buffer pool, registers the USB bus, requests the
* IRQ line, and calls s5pc110_otghcd_start method.
*/
- ret_val = usb_add_hcd(g_pUsbHcd, pdev->resource[1].start, IRQF_DISABLED);
- if (ret_val < 0)
- {
- goto err_out_create_hcd_init;
+ ret_val = usb_add_hcd(g_pUsbHcd,
+ pdev->resource[1].start, IRQF_DISABLED);
+ if (ret_val < 0) {
+ goto err_out_host_notify_register;
}
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
- "OTG HCD Initialized HCD, bus=%s, usbbus=%d\n",
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ "OTG HCD Initialized HCD, bus=%s, usbbus=%d\n",
"C110 OTG Controller", g_pUsbHcd->self.busnum);
- //otg_print_registers(); // sekang - for debug
+ /* otg_print_registers(); */
+
+ wake_lock_init(&otghost->wake_lock, WAKE_LOCK_SUSPEND, "usb_otg");
+ wake_lock(&otghost->wake_lock);
return USB_ERR_SUCCESS;
+err_out_host_notify_register:
+#ifdef CONFIG_USB_HOST_NOTIFY
+ host_notify_dev_unregister(&g_pUsbHcd->ndev);
+#endif
-err_out_create_hcd_init:
- otg_hcd_deinit_modules();
+err_out_create_hcd_init:
+ otg_hcd_deinit_modules(otghost);
release_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len);
-err_out_create_hcd:
+err_out_create_hcd:
usb_put_hcd(g_pUsbHcd);
-
+
err_out_clk:
-
+
return ret_val;
}
-//-------------------------------------------------------------------------------
/**
* static int s5pc110_otg_drv_remove (struct platform_device *dev)
- *
+ *
* @brief remove function of OTG hcd platform_driver
- *
+ *
* @param [in] pdev : pointer of platform_device of otg hcd platform_driver
- *
+ *
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If fail \n
- * @remark
+ * @remark
* This function is called when the otg device unregistered with the
* s5pc110_otg_driver. This happens, for example, when the rmmod command is
* executed. The device may or may not be electrically present. If it is
* present, the driver stops device processing. Any resources used on behalf
* of this device are freed.
*/
-static int s5pc110_otg_drv_remove (struct platform_device *dev)
-{
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
- "s5pc110_otg_drv_remove \n");
+static int s5pc110_otg_drv_remove (struct platform_device *dev)
+{
+ struct sec_otghost *otghost = NULL;
+
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER, "s5pc110_otg_drv_remove\n");
+
+ otghost = hcd_to_sec_otghost(g_pUsbHcd);
+
+#ifdef CONFIG_USB_HOST_NOTIFY
+ host_notify_dev_unregister(&g_pUsbHcd->ndev);
+#endif
+
+ otg_hcd_deinit_modules(otghost);
- otg_hcd_deinit_modules();
+ destroy_workqueue(otghost->wq);
+
+ wake_unlock(&otghost->wake_lock);
+ wake_lock_destroy(&otghost->wake_lock);
usb_remove_hcd(g_pUsbHcd);
-
+
release_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len);
usb_put_hcd(g_pUsbHcd);
- /*
- if (otg_clock != NULL) {
- clk_disable(otg_clock);
- clk_put(otg_clock);
- otg_clock = NULL;
- }
- */
-
+ otg_phy_off();
+
return USB_ERR_SUCCESS;
-}
-//-------------------------------------------------------------------------------
+}
/**
* @struct s5pc110_otg_driver
- *
- * @brief
+ *
+ * @brief
* This structure defines the methods to be called by a bus driver
* during the lifecycle of a device on that bus. Both drivers and
* devices are registered with a bus driver. The bus driver matches
@@ -217,7 +255,7 @@ static int s5pc110_otg_drv_remove (struct platform_device *dev)
*
* The probe function is called when the bus driver matches a device
* to this driver. The remove function is called when a device is
- * unregistered with the bus driver.
+ * unregistered with the bus driver.
*/
struct platform_driver s5pc110_otg_driver = {
.probe = s5pc110_otg_drv_probe,
@@ -228,15 +266,14 @@ struct platform_driver s5pc110_otg_driver = {
.owner = THIS_MODULE,
},
};
-//-------------------------------------------------------------------------------
/**
* static int __init s5pc110_otg_module_init(void)
- *
+ *
* @brief module_init function
- *
+ *
* @return it returns result of platform_driver_register
- * @remark
+ * @remark
* This function is called when the s5pc110_otg_driver is installed with the
* insmod command. It registers the s5pc110_otg_driver structure with the
* appropriate bus driver. This will cause the s5pc110_otg_driver_probe function
@@ -244,100 +281,98 @@ struct platform_driver s5pc110_otg_driver = {
* attributes defined for the device and driver in the special sysfs file
* system.
*/
-static int __init s5pc110_otg_module_init(void)
-{
+ /*
+static int __init s5pc110_otg_module_init(void)
+{
int ret_val = 0;
-
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
- "s3c_otg_module_init \n");
+
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ "s3c_otg_module_init \n");
ret_val = platform_driver_register(&s5pc110_otg_driver);
- if (ret_val < 0)
- {
- otg_err(OTG_DBG_OTGHCDI_DRIVER,
- "platform_driver_register \n");
+ if (ret_val < 0)
+ {
+ otg_err(OTG_DBG_OTGHCDI_DRIVER,
+ "platform_driver_register \n");
}
- return ret_val;
-}
-//-------------------------------------------------------------------------------
+ return ret_val;
+} */
/**
* static void __exit s5pc110_otg_module_exit(void)
- *
+ *
* @brief module_exit function
- *
- * @remark
+ *
+ * @remark
* This function is called when the driver is removed from the kernel
* with the rmmod command. The driver unregisters itself with its bus
- * driver.
+ * driver.
*/
-static void __exit s5pc110_otg_module_exit(void)
-{
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+static void __exit s5pc110_otg_module_exit(void)
+{
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"s3c_otg_module_exit \n");
platform_driver_unregister(&s5pc110_otg_driver);
-}
-//-------------------------------------------------------------------------------
+}
-// for debug
+/* for debug */
void otg_print_registers(void)
-{
- // USB PHY Control Registers
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+{
+ /* USB PHY Control Registers */
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"USB_CONTROL = 0x%x.\n", readl(0xfb10e80c));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"UPHYPWR = 0x%x.\n", readl(S3C_USBOTG_PHYPWR));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"UPHYCLK = 0x%x.\n", readl(S3C_USBOTG_PHYCLK));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"URSTCON = 0x%x.\n", readl(S3C_USBOTG_RSTCON));
- //OTG LINK Core registers (Core Global Registers)
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ /* OTG LINK Core registers (Core Global Registers) */
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GOTGCTL = 0x%x.\n", read_reg_32(GOTGCTL));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GOTGINT = 0x%x.\n", read_reg_32(GOTGINT));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GAHBCFG = 0x%x.\n", read_reg_32(GAHBCFG));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GUSBCFG = 0x%x.\n", read_reg_32(GUSBCFG));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GINTSTS = 0x%x.\n", read_reg_32(GINTSTS));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GINTMSK = 0x%x.\n", read_reg_32(GINTMSK));
- // Host Mode Registers
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ /* Host Mode Registers */
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"HCFG = 0x%x.\n", read_reg_32(HCFG));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"HPRT = 0x%x.\n", read_reg_32(HPRT));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"HFIR = 0x%x.\n", read_reg_32(HFIR));
- // Synopsys ID
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ /* Synopsys ID */
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GSNPSID = 0x%x.\n", read_reg_32(GSNPSID));
- // HWCFG
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ /* HWCFG */
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GHWCFG1 = 0x%x.\n", read_reg_32(GHWCFG1));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GHWCFG2 = 0x%x.\n", read_reg_32(GHWCFG2));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GHWCFG3 = 0x%x.\n", read_reg_32(GHWCFG3));
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"GHWCFG4 = 0x%x.\n", read_reg_32(GHWCFG4));
- // PCGCCTL
- otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
+ /* PCGCCTL */
+ otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
"PCGCCTL = 0x%x.\n", read_reg_32(PCGCCTL));
}
-
-
-// chul2
-//module_init(s5pc110_otg_module_init);
-//module_exit(s5pc110_otg_module_exit);
+/*
+module_init(s5pc110_otg_module_init);
+module_exit(s5pc110_otg_module_exit);
+*/
MODULE_DESCRIPTION("OTG USB HOST controller driver");
MODULE_AUTHOR("SAMSUNG / System LSI / EMSP");
View
19 drivers/usb/host/s3c-otg/s3c-otg-hcdi-driver.h
@@ -1,9 +1,9 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* @file s3c-otg-hcdi-driver.h
* @brief header of s3c-otg-hcdi-driver \n
- * @version
+ * @version
* -# Jun 9,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Creating the initial version of this code \n
* -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com) \n
@@ -50,7 +50,6 @@ extern "C"
#include <asm/irq.h> //for IRQ_OTG
#include <linux/clk.h>
-//#include <asm/io.h> //for ioremap
#include "s3c-otg-common-common.h"
#include "s3c-otg-common-regdef.h"
@@ -59,20 +58,18 @@ extern "C"
#include "s3c-otg-hcdi-hcd.h"
#include "s3c-otg-hcdi-kal.h"
-//struct clk* g_pOTG_clock = NULL;
-struct usb_hcd* g_pUsbHcd = NULL;
volatile u8 * g_pUDCBase;
static const char gHcdName[] = "EMSP_OTG_HCD";
-extern int otg_hcd_init_modules(void);
-extern void otg_hcd_deinit_modules(void);
+//extern int otg_hcd_init_modules(struct sec_otghost *otghost);
+//extern void otg_hcd_deinit_modules(struct sec_otghost *otghost);
-void otg_print_registers(void);
+//void otg_print_registers();
-#ifdef __cplusplus
-}
-#endif
+#ifdef __cplusplus
+}
+#endif
#endif /* _S3C_OTG_HCDI_DRIVER_H_ */
View
813 drivers/usb/host/s3c-otg/s3c-otg-hcdi-hcd.c
@@ -1,9 +1,9 @@
-/****************************************************************************
+/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* @file s3c-otg-hcdi-hcd.c
* @brief implementation of structure hc_drive \n
- * @version
+ * @version
* -# Jun 11,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Creating the initial version of this code \n
* -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com) \n
@@ -28,392 +28,369 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
-#include "s3c-otg-hcdi-hcd.h"
-static DEFINE_SPINLOCK(otg_hcd_spin_lock);
+#include "s3c-otg-hcdi-hcd.h"
/**
- * otg_hcd_init_modules()
- *
+ * otg_hcd_init_modules(struct sec_otghost *otghost)
+ *
* @brief call other modules' init functions
- *
+ *
* @return PASS : If success \n
* FAIL : If fail \n
*/
-int otg_hcd_init_modules(void)
-{
+int otg_hcd_init_modules(struct sec_otghost *otghost)
+{
unsigned long spin_lock_flag = 0;
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "otg_hcd_init_modules\n");
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "otg_hcd_init_modules\n");
+
+ spin_lock_init(&otghost->lock);
+
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
init_transfer();
init_scheduler();
- oci_init();
-
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
-
- return USB_ERR_SUCCESS;
+ oci_init(otghost);
+
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
+
+ return USB_ERR_SUCCESS;
};
/**
- * void otg_hcd_deinit_modules(void)
- *
+ * void otg_hcd_deinit_modules(struct sec_otghost *otghost)
+ *
* @brief call other modules' de-init functions
- *
+ *
* @return PASS : If success \n
* FAIL : If fail \n
*/
-void otg_hcd_deinit_modules(void)
-{
+void otg_hcd_deinit_modules(struct sec_otghost *otghost)
+{
unsigned long spin_lock_flag = 0;
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "otg_hcd_deinit_modules \n");
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "otg_hcd_deinit_modules \n");
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
- deinit_transfer();
-
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ deinit_transfer(otghost);
+
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
}
/**
* irqreturn_t (*s5pc110_otghcd_irq) (struct usb_hcd *hcd)
- *
- * @brief interrupt handler of otg irq
- *
- * @param [in] hcd : pointer of usb_hcd
- *
+ *
+ * @brief interrupt handler of otg irq
+ *
+ * @param [in] hcd : pointer of usb_hcd
+ *
* @return IRQ_HANDLED \n
*/
-irqreturn_t s5pc110_otghcd_irq(struct usb_hcd *hcd)
-{
-
- unsigned long spin_lock_flag = 0;
+irqreturn_t s5pc110_otghcd_irq(struct usb_hcd *hcd)
+{
+ struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
- /* otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "s5pc110_otghcd_irq \n"); */
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_irq \n");
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
- otg_handle_interrupt();
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_lock_otg(&otghost->lock);
+ otg_handle_interrupt(hcd);
+ spin_unlock_otg(&otghost->lock);
-
return IRQ_HANDLED;
-}
-//-------------------------------------------------------------------------------
-
+}
/**
- * int s5pc110_otghcd_start(struct usb_hcd *hcd)
- *
+ * int s5pc110_otghcd_start(struct usb_hcd *hcd)
+ *
* @brief initialize and start otg hcd
- *
- * @param [in] usb_hcd_p : pointer of usb_hcd
- *
+ *
+ * @param [in] usb_hcd_p : pointer of usb_hcd
+ *
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If call fail \n
*/
-int s5pc110_otghcd_start(struct usb_hcd *usb_hcd_p)
-{
+int s5pc110_otghcd_start(struct usb_hcd *usb_hcd_p)
+{
struct usb_bus *usb_bus_p;
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "s5pc110_otghcd_start \n");
-
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_start \n");
+
usb_bus_p = hcd_to_bus(usb_hcd_p);
- //* Initialize and connect root hub if one is not already attached */
+ /* Initialize and connect root hub if one is not already attached */
if (usb_bus_p->root_hub) {
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "OTG HCD Has Root Hub\n");
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "OTG HCD Has Root Hub\n");
- //* Inform the HUB driver to resume. */
+ /* Inform the HUB driver to resume. */
otg_usbcore_resume_roothub();
} else {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "OTG HCD Does Not Have Root Hub\n");
+ otg_err(OTG_DBG_OTGHCDI_HCD,
+ "OTG HCD Does Not Have Root Hub\n");
return USB_ERR_FAIL;
}
- usb_hcd_p->flags |= HCD_FLAG_POLL_RH;
+ usb_hcd_p->poll_rh = 1;
usb_hcd_p->uses_new_polling = 1;
-
- ///init bus state before enable irq
+
+ /* init bus state before enable irq */
usb_hcd_p->state = HC_STATE_RUNNING;
- oci_start();//enable irq
+ oci_start(); /* enable irq */
- return USB_ERR_SUCCESS;
-}
-//-------------------------------------------------------------------------------
+ return USB_ERR_SUCCESS;
+}
/**
* void s5pc110_otghcd_stop(struct usb_hcd *hcd)
- *
+ *
* @brief deinitialize and stop otg hcd
- *
- * @param [in] hcd : pointer of usb_hcd
- *
+ *
+ * @param [in] hcd : pointer of usb_hcd
+ *
*/
-void s5pc110_otghcd_stop(struct usb_hcd *hcd)
-{
+void s5pc110_otghcd_stop(struct usb_hcd *hcd)
+{
unsigned long spin_lock_flag = 0;
+ struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "s5pc110_otghcd_stop \n");
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_stop \n");
- otg_hcd_deinit_modules();
+ otg_hcd_deinit_modules(otghost);
+
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
oci_stop();
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
-}
-//-------------------------------------------------------------------------------
+ root_hub_feature(hcd, 0, ClearPortFeature, USB_PORT_FEAT_POWER, NULL);
+
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
+}
/**
* void s5pc110_otghcd_shutdown(struct usb_hcd *hcd)
- *
+ *
* @brief shutdown otg hcd
- *
- * @param [in] usb_hcd_p : pointer of usb_hcd
- *
+ *
+ * @param [in] usb_hcd_p : pointer of usb_hcd
+ *
*/
-void s5pc110_otghcd_shutdown(struct usb_hcd *usb_hcd_p)
-{
-
+void s5pc110_otghcd_shutdown(struct usb_hcd *usb_hcd_p)
+{
unsigned long spin_lock_flag = 0;
+ struct sec_otghost *otghost = hcd_to_sec_otghost(usb_hcd_p);
+
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_shutdown \n");
+ otg_hcd_deinit_modules(otghost);
+
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "s5pc110_otghcd_shutdown \n");
- otg_hcd_deinit_modules();
-
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
oci_stop();
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ root_hub_feature(usb_hcd_p, 0, ClearPortFeature, USB_PORT_FEAT_POWER, NULL);
+
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
- free_irq(IRQ_OTG, usb_hcd_p);
+ free_irq(IRQ_OTG, usb_hcd_p);
usb_hcd_p->state = HC_STATE_HALT;
otg_usbcore_hc_died();
-}
-//-------------------------------------------------------------------------------
+}
/**
- * int s5pc110_otghcd_get_frame_number(struct usb_hcd *hcd)
- *
+ * int s5pc110_otghcd_get_frame_number(struct usb_hcd *hcd)
+ *
* @brief get currnet frame number
- *
- * @param [in] hcd : pointer of usb_hcd
- *
+ *
+ * @param [in] hcd : pointer of usb_hcd
+ *
* @return ret : frame number \n
*/
-int s5pc110_otghcd_get_frame_number(struct usb_hcd *hcd)
-{
+int s5pc110_otghcd_get_frame_number(struct usb_hcd *hcd)
+{
int ret = 0;
unsigned long spin_lock_flag = 0;
+ struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "s5pc110_otghcd_get_frame_number \n");
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_get_frame_number \n");
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
ret = oci_get_frame_num();
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
+
return ret;
-}
-//-------------------------------------------------------------------------------
+}
/**
- * int s5pc110_otghcd_urb_enqueue()
- *
+ * int s5pc110_otghcd_urb_enqueue()
+ *
* @brief enqueue a urb to otg hcd
- *
+ *
* @param [in] hcd : pointer of usb_hcd
* [in] ep : pointer of usb_host_endpoint
* [in] urb : pointer of urb
- * [in] mem_flags : type of gfp_t
+ * [in] mem_flags : type of gfp_t
*
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If call fail \n
*/
-int
-s5pc110_otghcd_urb_enqueue
-(
- struct usb_hcd *hcd,
- struct urb *urb,
- gfp_t mem_flags
-)
-{
-
+int s5pc110_otghcd_urb_enqueue (struct usb_hcd *hcd,
+ struct urb *urb,
+ gfp_t mem_flags)
+{
int ret_val = 0;
u32 trans_flag = 0;
u32 return_td_addr = 0;
u8 dev_speed, ed_type = 0, additional_multi_count;
u16 max_packet_size;
-
+
u8 dev_addr = 0;
u8 ep_num = 0;
- bool f_is_ep_in = true;
+ bool f_is_ep_in = true;
u8 interval = 0;
u32 sched_frame = 0;
u8 hub_addr = 0;
- u8 hub_port = 0;
+ u8 hub_port = 0;
bool f_is_do_split = false;
ed_t *target_ed = NULL;
isoch_packet_desc_t *new_isoch_packet_desc = NULL;
unsigned long spin_lock_flag = 0;
+ struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
- otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_urb_enqueue %p\n", urb);
-
- /// check ep has ed_t or not
- if(!(urb->ep->hcpriv))
- {
- ///for getting dev_speed
- switch (urb->dev->speed)
- {
- case USB_SPEED_HIGH :
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "HS_OTG \n");
-
- dev_speed = HIGH_SPEED_OTG;
- break;
-
- case USB_SPEED_FULL :
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "FS_OTG \n");
-
- dev_speed = FULL_SPEED_OTG;
- break;
-
- case USB_SPEED_LOW :
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "LS_OTG \n");
-
- dev_speed = LOW_SPEED_OTG;
- break;
-
- default:
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "unKnown Device Speed \n");
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
- return USB_ERR_FAIL;
+ if (!otghost->port_flag.b.port_connect_status) {
+ printk(KERN_ERR"%s %d\n", __func__, __LINE__);
+ return USB_ERR_NOIO;
+ }
+
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
+
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_urb_enqueue \n");
+
+ /* check ep has ed_t or not */
+ if(!(urb->ep->hcpriv)) {
+ /* for getting dev_speed */
+ switch (urb->dev->speed) {
+ case USB_SPEED_HIGH :
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "HS_OTG \n");
+ dev_speed = HIGH_SPEED_OTG;
+ break;
+
+ case USB_SPEED_FULL :
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "FS_OTG \n");
+ dev_speed = FULL_SPEED_OTG;
+ break;
+
+ case USB_SPEED_LOW :
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "LS_OTG \n");
+ dev_speed = LOW_SPEED_OTG;
+ break;
+
+ default:
+ otg_err(OTG_DBG_OTGHCDI_HCD,
+ "unKnown Device Speed \n");
+ spin_unlock_irq_save_otg(&otghost->lock,
+ spin_lock_flag);
+ return USB_ERR_FAIL;
}
-
- ///for getting ed_type
- switch (usb_pipetype(urb->pipe))
- {
- case PIPE_BULK :
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "bulk transfer \n");
-
- ed_type = BULK_TRANSFER;
- break;
-
- case PIPE_INTERRUPT :
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "interrupt transfer \n");
-
- ed_type = INT_TRANSFER;
- break;
-
- case PIPE_CONTROL :
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "control transfer \n");
-
- ed_type = CONTROL_TRANSFER;
- break;
-
- case PIPE_ISOCHRONOUS :
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "isochronous transfer \n");
-
- ed_type = ISOCH_TRANSFER;
- break;
- default:
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "unKnown ep type \n");
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
- return USB_ERR_FAIL;
+
+ /* for getting ed_type */
+ switch (usb_pipetype(urb->pipe)) {
+ case PIPE_BULK :
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "bulk transfer \n");
+ ed_type = BULK_TRANSFER;
+ break;
+
+ case PIPE_INTERRUPT :
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "interrupt transfer \n");
+ ed_type = INT_TRANSFER;
+ break;
+
+ case PIPE_CONTROL :
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "control transfer \n");
+ ed_type = CONTROL_TRANSFER;
+ break;
+
+ case PIPE_ISOCHRONOUS :
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "isochronous transfer \n");
+ ed_type = ISOCH_TRANSFER;
+ break;
+ default:
+ otg_err(OTG_DBG_OTGHCDI_HCD, "unKnown ep type \n");
+ spin_unlock_irq_save_otg(&otghost->lock,
+ spin_lock_flag);
+ return USB_ERR_FAIL;
}
- max_packet_size = usb_maxpacket(urb->dev, urb->pipe, !(usb_pipein(urb->pipe)));
+ max_packet_size = usb_maxpacket(urb->dev, urb->pipe,
+ !(usb_pipein(urb->pipe)));
additional_multi_count = ((max_packet_size) >> 11) & 0x03;
dev_addr = usb_pipedevice(urb->pipe);
ep_num = usb_pipeendpoint(urb->pipe);
- f_is_ep_in = usb_pipein(urb->pipe) ? true : false;
+ f_is_ep_in = usb_pipein(urb->pipe) ? true : false;
interval = (u8)(urb->interval);
sched_frame = (u8)(urb->start_frame);
- //check
- if(urb->dev->tt == NULL)
- {
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "urb->dev->tt == NULL\n");
- hub_port = 0; //u8 hub_port
- hub_addr = 0; //u8 hub_addr,
+ /* check */
+ if(urb->dev->tt == NULL) {
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "urb->dev->tt == NULL\n");
+ hub_port = 0; /* u8 hub_port */
+ hub_addr = 0; /* u8 hub_addr */
}
- else
- {
- hub_port = (u8)(urb->dev->ttport); //u8 hub_port,
+ else {
+ hub_port = (u8)(urb->dev->ttport);
if (urb->dev->tt->hub) {
- if ( ((dev_speed == FULL_SPEED_OTG) || (dev_speed == LOW_SPEED_OTG)) &&
- (urb->dev->tt) && (urb->dev->tt->hub->devnum != 1)) {
+ if (((dev_speed == FULL_SPEED_OTG) ||
+ (dev_speed == LOW_SPEED_OTG)) &&
+ (urb->dev->tt) && (urb->dev->tt->hub->devnum != 1)) {
f_is_do_split = true;
}
-
- hub_addr = (u8)(urb->dev->tt->hub->devnum);//u8 hub_addr,
+ hub_addr = (u8)(urb->dev->tt->hub->devnum);
}
if (urb->dev->tt->multi) {
- hub_addr = 0x80;//u8 hub_addr,
+ hub_addr = 0x80;
}
}
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
+ otg_dbg(OTG_DBG_OTGHCDI_HCD,
"dev_spped =%d, hub_port=%d, hub_addr=%d\n",
dev_speed, hub_port, hub_addr);
ret_val = create_ed(&target_ed);
- if(ret_val != USB_ERR_SUCCESS)
- {
- otg_err(OTG_DBG_OTGHCDI_HCD,
+ if(ret_val != USB_ERR_SUCCESS) {
+ otg_err(OTG_DBG_OTGHCDI_HCD,
"fail to create_ed() \n");
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_unlock_irq_save_otg(&otghost->lock,
+ spin_lock_flag);
return ret_val;
}
- ret_val = init_ed( target_ed,
+ ret_val = init_ed( target_ed,
dev_addr,
ep_num,
- f_is_ep_in,
+ f_is_ep_in,
dev_speed,
ed_type,
- max_packet_size,
+ max_packet_size,
additional_multi_count,
interval,
- sched_frame,
+ sched_frame,
hub_addr,
hub_port,
f_is_do_split,
(void *)urb->ep);
-
- if(ret_val != USB_ERR_SUCCESS)
- {
- otg_err(OTG_DBG_OTGHCDI_HCD,
+
+ if(ret_val != USB_ERR_SUCCESS) {
+ otg_err(OTG_DBG_OTGHCDI_HCD,
"fail to init_ed() :err = %d \n",(int)ret_val);
otg_mem_free(target_ed);
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_unlock_irq_save_otg(&otghost->lock,
+ spin_lock_flag);
return USB_ERR_FAIL;
}
urb->ep->hcpriv = (void *)(target_ed);
- } // if(!(ep->hcpriv))
- else
- {
+ } /* if(!(ep->hcpriv)) */
+ else {
dev_addr = usb_pipedevice(urb->pipe);
- if(((ed_t *)(urb->ep->hcpriv))->ed_desc.device_addr != dev_addr)
- {
+ if(((ed_t *)(urb->ep->hcpriv))->ed_desc.device_addr != dev_addr) {
((ed_t *)urb->ep->hcpriv)->ed_desc.device_addr = dev_addr;
}
}
@@ -425,349 +402,301 @@ s5pc110_otghcd_urb_enqueue
if (urb->transfer_flags & URB_ISO_ASAP)
trans_flag += USB_TRANS_FLAG_ISO_ASYNCH;
- if(ed_type == ISOCH_TRANSFER)
- {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "ISO not yet supported \n");
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ if(ed_type == ISOCH_TRANSFER) {
+ otg_err(OTG_DBG_OTGHCDI_HCD, "ISO not yet supported \n");
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
if (!HC_IS_RUNNING(hcd->state)) {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "!HC_IS_RUNNING(hcd->state) \n");
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ otg_err(OTG_DBG_OTGHCDI_HCD, "!HC_IS_RUNNING(hcd->state) \n");
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return -USB_ERR_NODEV;
}
/* in case of unlink-during-submit */
if (urb->status != -EINPROGRESS) {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "urb->status is -EINPROGRESS\n");
+ otg_err(OTG_DBG_OTGHCDI_HCD, "urb->status is -EINPROGRESS\n");
urb->hcpriv = NULL;
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
usb_hcd_giveback_urb(hcd, urb, urb->status);
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
return USB_ERR_SUCCESS;
}
-
- ret_val = issue_transfer( target_ed, (void *)NULL, (void *)NULL,
- trans_flag,
- (usb_pipetype(urb->pipe) == PIPE_CONTROL)?true:false,
- (u32)urb->setup_packet, (u32)urb->setup_dma,
- (u32)urb->transfer_buffer, (u32)urb->transfer_dma,
- (u32)urb->transfer_buffer_length,
- (u32)urb->start_frame,(u32)urb->number_of_packets,
- new_isoch_packet_desc, (void *)urb, &return_td_addr);
-
- if(ret_val != USB_ERR_SUCCESS)
- {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "fail to issue_transfer() \n");
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+
+ ret_val = issue_transfer(otghost, target_ed, (void *)NULL, (void *)NULL,
+ trans_flag,
+ (usb_pipetype(urb->pipe) == PIPE_CONTROL)?true:false,
+ (u32)urb->setup_packet, (u32)urb->setup_dma,
+ (u32)urb->transfer_buffer, (u32)urb->transfer_dma,
+ (u32)urb->transfer_buffer_length,
+ (u32)urb->start_frame,(u32)urb->number_of_packets,
+ new_isoch_packet_desc, (void *)urb, &return_td_addr);
+
+ if(ret_val != USB_ERR_SUCCESS) {
+ otg_err(OTG_DBG_OTGHCDI_HCD, "fail to issue_transfer() \n");
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
urb->hcpriv = (void *)return_td_addr;
- otg_dbg(OTG_DBG_OTGHCDI_HCD, "exit s5pc110_otghcd_urb_enqueue %p, td=%p\n", urb, urb->hcpriv);
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_SUCCESS;
-}
-//-------------------------------------------------------------------------------
+}
/**
- * int s5pc110_otghcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb )
- *
+ * int s5pc110_otghcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb )
+ *
* @brief dequeue a urb to otg
- *
+ *
* @param [in] _hcd : pointer of usb_hcd
* [in] _urb : pointer of urb
- *
+ *
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If call fail \n
*/
-int s5pc110_otghcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb, int status)
-{
+int s5pc110_otghcd_urb_dequeue(
+ struct usb_hcd *_hcd, struct urb *_urb, int status)
+{
int ret_val = 0;
-
+ struct sec_otghost *otghost = hcd_to_sec_otghost(_hcd);
+
unsigned long spin_lock_flag = 0;
- td_t *cancel_td;
+ td_t *cancel_td = (td_t *)_urb->hcpriv;
- /* Dequeue should be performed only if endpoint is enabled */
- if (_urb->ep->enabled == 0)
- return USB_ERR_SUCCESS;
-
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
- // kevinh - important to read this from inside of the spinlock (so ISR can't change hcpriv first)
- cancel_td = (td_t *)_urb->hcpriv;
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_urb_dequeue \n");
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "s5pc110_otghcd_urb_dequeue %p, td=%p\n", _urb, cancel_td);
+ /* Dequeue should be performed only if endpoint is enabled */
+ if (_urb->ep->enabled == 0) {
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
+ usb_hcd_giveback_urb(_hcd, _urb, status);
+ return USB_ERR_SUCCESS;
+ }
- if (cancel_td == NULL)
- {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "cancel_td is NULL\n");
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ if (cancel_td == NULL) {
+ otg_err(OTG_DBG_OTGHCDI_HCD, "cancel_td is NULL\n");
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
+ otg_dbg(OTG_DBG_OTGHCDI_HCD,
"s5pc110_otghcd_urb_dequeue, status = %d\n", status);
- ret_val = usb_hcd_check_unlink_urb(_hcd, _urb, status);
- if( (ret_val) && (ret_val != -EIDRM) ){
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "ret_val = %d\n", ret_val);
+ ret_val = usb_hcd_check_unlink_urb(_hcd, _urb, status);
+ if( (ret_val) && (ret_val != -EIDRM) ) {
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "ret_val = %d\n", ret_val);
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
usb_hcd_giveback_urb(_hcd, _urb, status);
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
return ret_val;
}
if (!HC_IS_RUNNING(_hcd->state)) {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "!HC_IS_RUNNING(hcd->state) \n");
+ otg_err(OTG_DBG_OTGHCDI_HCD, "!HC_IS_RUNNING(hcd->state) \n");
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
otg_usbcore_giveback(cancel_td);
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
return USB_ERR_SUCCESS;
}
- // kevinh - we die in here
- ret_val = cancel_transfer(cancel_td->parent_ed_p, cancel_td);
- if(ret_val != USB_ERR_DEQUEUED && ret_val != USB_ERR_NOELEMENT)
- {
- // dump_stack(); // kevinh temp
-
- otg_err(OTG_DBG_OTGHCDI_DRIVER,
- "fail to cancel_transfer = %d\n", ret_val);
- otg_usbcore_giveback(cancel_td);
-
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ ret_val = cancel_transfer(otghost, cancel_td->parent_ed_p, cancel_td);
+ if(ret_val != USB_ERR_DEQUEUED && ret_val != USB_ERR_NOELEMENT) {
+ otg_err(OTG_DBG_OTGHCDI_HCD, "fail to cancel_transfer() \n");
+// otg_usbcore_giveback(cancel_td);
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
-
- if(ret_val == USB_ERR_DEQUEUED) {
-#if 0
- if(cancel_td->is_transferring) {
- if(cancel_to_transfer_td(cancel_td) != USB_ERR_SUCCESS) { // The ISR will call giveback and delete_td
- //printk("ISR was unable to cancel - we'll do it ourselves %p\n", cancel_td);
- otg_usbcore_giveback(cancel_td); // FIXME - why is this needed here?
- delete_td(cancel_td);
- }
- // else printk("I assume isr will cancel %p\n", cancel_td);
- }
- else {
- otg_usbcore_giveback(cancel_td);
- delete_td(cancel_td);
- }
-#else
- otg_usbcore_giveback(cancel_td);
- delete_td(cancel_td);
-#endif
- }
- // else printk("Ignoring missing td\n");
-
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+// otg_usbcore_giveback(cancel_td);
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_SUCCESS;
-}
-//-------------------------------------------------------------------------------
-
+}
/**
- * void s5pc110_otghcd_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
- *
+ * void s5pc110_otghcd_endpoint_disable(
+ * struct usb_hcd *hcd,
+ * struct usb_host_endpoint *ep)
+ *
* @brief disable a endpoint
- *
+ *
* @param [in] hcd : pointer of usb_hcd
* [in] ep : pointer of usb_host_endpoint
*/
-void s5pc110_otghcd_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
-{
+void s5pc110_otghcd_endpoint_disable(
+ struct usb_hcd *hcd,
+ struct usb_host_endpoint *ep)
+{
int ret_val = 0;
unsigned long spin_lock_flag = 0;
+ struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
+
+ otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_endpoint_disable \n");
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
- "s5pc110_otghcd_endpoint_disable \n");
-
if(!((ed_t *)ep->hcpriv))
return;
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
- ret_val = delete_ed((ed_t *)ep->hcpriv);
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
-
- if(ret_val != USB_ERR_SUCCESS)
- {
- otg_err(OTG_DBG_OTGHCDI_HCD,
- "fail to delete_ed() \n");
+
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
+ ret_val = delete_ed(otghost, (ed_t *)ep->hcpriv);
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
+
+ if(ret_val != USB_ERR_SUCCESS) {
+ otg_err(OTG_DBG_OTGHCDI_HCD, "fail to delete_ed() \n");
return ;
}
- //ep->hcpriv = NULL; delete_ed coveres it
-}
-//-------------------------------------------------------------------------------
-
+ /* ep->hcpriv = NULL; delete_ed coveres it */
+}
/**
- * int s5pc110_otghcd_hub_status_data(struct usb_hcd *_hcd, char *_buf)
- *
+ * int s5pc110_otghcd_hub_status_data(struct usb_hcd *_hcd, char *_buf)
+ *
* @brief get status of root hub
- *
+ *
* @param [in] _hcd : pointer of usb_hcd
* [inout] _buf : pointer of buffer for write a status data
*
* @return ret_val : return port status \n
*/
-int s5pc110_otghcd_hub_status_data(struct usb_hcd *_hcd, char *_buf)
-{
- int ret_val = 0;
- unsigned long spin_lock_flag = 0;
+int s5pc110_otghcd_hub_status_data(struct usb_hcd *_hcd, char *_buf)
+{
+ int ret_val = 0;
+ unsigned long spin_lock_flag = 0;
+ struct sec_otghost *otghost = hcd_to_sec_otghost(_hcd);
-// otg_dbg(OTG_DBG_OTGHCDI_HCD,
-// "s5pc110_otghcd_hub_status_data \n");
+ /* otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_hub_status_data \n"); */
/* if !USB_SUSPEND, root hub timers won't get shut down ... */
if (!HC_IS_RUNNING(_hcd->state)) {
- otg_dbg(OTG_DBG_OTGHCDI_HCD,
+ otg_dbg(OTG_DBG_OTGHCDI_HCD,
"_hcd->state is NOT HC_IS_RUNNING \n");
return 0;
}
- spin_lock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
- ret_val = get_otg_port_status(OTG_PORT_NUMBER, _buf);
- spin_unlock_irq_save_otg(&otg_hcd_spin_lock, spin_lock_flag);
+ spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
+ ret_val = get_otg_port_status(_hcd, OTG_PORT_NUMBER, _buf);
+ spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return (int)ret_val;
-}
-//-------------------------------------------------------------------------------
-
+}
/**
- * int s5pc110_otghcd_hub_control()
- *
+ * int s5pc110_otghcd_hub_control()
+ *
* @brief control root hub
- *
+ *
* @param [in] hcd : pointer of usb_hcd
* [in] typeReq : type of control request
* [in] value : value
* [in] index : index
* [in] buf_p : pointer of urb
- * [in] length : type of gfp_t
- *
+ * [in] length : type of gfp_t
+ *
* @return ret_val : return root_hub_feature \n
*/
int
-s5pc110_otghcd_hub_control
-(
- struct usb_hcd *hcd,
- u16 typeReq,
- u16 value,
- u16 index,
- char* buf_p,
- u16 length
+s5pc110_otghcd_hub_control (
+ struct usb_hcd *hcd,
+ u16 typeReq,
+ u16 value,