xref: /utopia/UTPA2-700.0.x/modules/usb/hal/maserati/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 CHIPID_MUJI;
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[4] = {1, 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 if (uPort == 3)
47     {
48         utmi_base = 0x122080;
49         bc_base = 0x123660;
50     }
51     else
52     {
53         printf("HAL_USB_BC_Enable: invalid port number %d\n", uPort);
54         return;
55     }
56 
57     if (bEnable)
58     {
59         if ( !PortBCStaus[uPort] )
60         {
61             printf("USB BC mode enabled\n");
62             MDrv_WriteRegBit(utmi_base+0x01, ENABLE, 0x40); //IREF_PDN=1��b1. (utmi+0x01[6] )
63             MDrv_WriteRegBit(bc_base+0x03, ENABLE, 0x40); // [6]= reg_host_bc_en
64             MDrv_WriteRegBit(bc_base+0x0C, ENABLE, 0x40); // [6]= reg_into_host_bc_sw_tri
65             MDrv_Write2Byte(bc_base, 0x0); // [15:0] = bc_ctl_ov_en
66             MDrv_WriteRegBit(bc_base+0x0A, ENABLE, 0x80); // [7]=reg_bc_switch_en
67             PortBCStaus[uPort] = 1;
68         }
69     }
70     else
71     {
72         if ( PortBCStaus[uPort] )
73         {
74             printf("USB BC mode disabled\n");
75             MDrv_WriteRegBit(bc_base+0x0C, DISABLE, 0x40); // [6]= reg_into_host_bc_sw_tri
76             MDrv_WriteRegBit(bc_base+0x03, DISABLE, 0x40); // [6]= reg_host_bc_en
77             MDrv_WriteRegBit(utmi_base+0x01, DISABLE, 0x40); //IREF_PDN=1��b1. (utmi+0x01[6] )
78             PortBCStaus[uPort] = 0;
79         }
80     }
81 }
82 
83