xref: /utopia/UTPA2-700.0.x/modules/usb/hal/mustang/usbhost/halUSB.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
4 // All rights reserved.
5 //
6 // Unless otherwise stipulated in writing, any and all information contained
7 // herein regardless in any format shall remain the sole proprietary of
8 // MStar Semiconductor Inc. and be kept in strict confidence
9 // ("MStar Confidential Information") by the recipient.
10 // Any unauthorized act including without limitation unauthorized disclosure,
11 // copying, use, reproduction, sale, distribution, modification, disassembling,
12 // reverse engineering and compiling of the contents of MStar Confidential
13 // Information is unlawful and strictly prohibited. MStar hereby reserves the
14 // rights to any and all damages, losses, costs and expenses resulting therefrom.
15 //
16 ////////////////////////////////////////////////////////////////////////////////
17 
18 #include "../../../drv/usbhost/include/drvGlobal.h"
19 #include "../../../drv/usbhost/include/_drvUSB.h"
20 
HAL_USB_GetChipID(void)21 U16 HAL_USB_GetChipID(void)
22 {
23     return MDrv_Read2Byte(0x1ecc);
24 }
25 
HAL_USB_BC_Enable(U8 uPort,BOOLEAN bEnable)26 void HAL_USB_BC_Enable(U8 uPort, BOOLEAN bEnable)
27 {
28     static U8 PortBCStaus[3] = {1, 1, 1}; //Set port BC enabled at first time
29     U32 utmi_base, bc_base;
30 
31     if (uPort == 0)
32     {
33         utmi_base = 0x103A80;
34         bc_base = 0x123600;
35     }
36     else if (uPort == 1)
37     {
38         utmi_base = 0x103A00;
39         bc_base = 0x123620;
40     }
41     else if (uPort == 2)
42     {
43         utmi_base = 0x103900;
44         bc_base = 0x123640;
45     }
46     else
47     {
48         printf("HAL_USB_BC_Enable: invalid port number %d\n", uPort);
49         return;
50     }
51 
52     if (bEnable)
53     {
54         if ( !PortBCStaus[uPort] )
55         {
56             printf("USB BC mode enabled\n");
57             MDrv_WriteRegBit(utmi_base+0x01, ENABLE, 0x40); //IREF_PDN=1��b1. (utmi+0x01[6] )
58             MDrv_WriteRegBit(bc_base+0x03, ENABLE, 0x40); // [6]= reg_host_bc_en
59             MDrv_WriteRegBit(bc_base+0x0C, ENABLE, 0x40); // [6]= reg_into_host_bc_sw_tri
60             MDrv_Write2Byte(bc_base, 0x0); // [15:0] = bc_ctl_ov_en
61             MDrv_WriteRegBit(bc_base+0x0A, ENABLE, 0x80); // [7]=reg_bc_switch_en
62             PortBCStaus[uPort] = 1;
63         }
64     }
65     else
66     {
67         if ( PortBCStaus[uPort] )
68         {
69             printf("USB BC mode disabled\n");
70             MDrv_WriteRegBit(bc_base+0x0C, DISABLE, 0x40); // [6]= reg_into_host_bc_sw_tri
71             MDrv_WriteRegBit(bc_base+0x03, DISABLE, 0x40); // [6]= reg_host_bc_en
72             MDrv_WriteRegBit(utmi_base+0x01, DISABLE, 0x40); //IREF_PDN=1��b1. (utmi+0x01[6] )
73             PortBCStaus[uPort] = 0;
74         }
75     }
76 }
77 
78