summaryrefslogtreecommitdiff
path: root/common/wmt_display/wmt-ost.c
diff options
context:
space:
mode:
authorKevin2014-11-15 11:48:36 +0800
committerKevin2014-11-15 11:48:36 +0800
commitd04075478d378d9e15f3e1abfd14b0bd124077d4 (patch)
tree733dd964582f388b9e3e367c249946cd32a2851f /common/wmt_display/wmt-ost.c
downloadFOSSEE-netbook-uboot-source-d04075478d378d9e15f3e1abfd14b0bd124077d4.tar.gz
FOSSEE-netbook-uboot-source-d04075478d378d9e15f3e1abfd14b0bd124077d4.tar.bz2
FOSSEE-netbook-uboot-source-d04075478d378d9e15f3e1abfd14b0bd124077d4.zip
init commit via android 4.4 uboot
Diffstat (limited to 'common/wmt_display/wmt-ost.c')
-rwxr-xr-xcommon/wmt_display/wmt-ost.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/common/wmt_display/wmt-ost.c b/common/wmt_display/wmt-ost.c
new file mode 100755
index 0000000..92b8417
--- /dev/null
+++ b/common/wmt_display/wmt-ost.c
@@ -0,0 +1,107 @@
+/*++
+Copyright (c) 2010 WonderMedia Technologies, Inc.
+
+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 program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+should have received a copy of the GNU General Public License along with this
+program. If not, see http://www.gnu.org/licenses/>.
+
+WonderMedia Technologies, Inc.
+4F, 531, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
+--*/
+#include <common.h>
+#include "vpp.h"
+
+static WMT_OST_REG *pWMTOST;
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+int wmt_write_ostc(void)
+{
+ unsigned int sw_counter = 30000;
+
+ while( pWMTOST->ostas & 0x10 ) {
+ if ( --sw_counter == 0 ) { // Need to be considered
+ printf("Count Write Active Busy\n");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int wmt_init_ost(void)
+{
+ //printf("wmt_init_ostimer\n");
+
+ if (pWMTOST == NULL)
+ pWMTOST = (WMT_OST_REG *)0xd8130100;
+
+ if (pWMTOST->ostctrl&0x01)
+ return 0;
+
+ pWMTOST->ostctrl = 0;
+ pWMTOST->ostwe = 0;
+
+ if (wmt_write_ostc())
+ return -1;
+
+ pWMTOST->ostct = 0;
+
+ pWMTOST->ostctrl = 1;
+
+ return 0;
+}
+
+int wmt_read_ostc(int *val)
+{
+ unsigned int sw_counter = 300000;
+
+ if (pWMTOST == NULL) {
+ if (wmt_init_ost())
+ return -1;
+ }
+
+ if ( (pWMTOST->ostctrl & 0x02 ) == 0 )
+ pWMTOST->ostctrl |= 0x02;
+
+ // Check OS Timer Count Value is Valid
+ while ( (pWMTOST->ostas & 0x20) == 0x20 ) {
+ if ( --sw_counter == 0 ) { // Need to be considered
+ printf("Read Count Request Fail\n");
+ break;
+ }
+ }
+ //*val = (int)pWMTOST->ostct; //Charles
+ *val = (int)pWMTOST->ostct/3;
+ return 0;
+}
+
+int wmt_delayus(int us)
+{
+ int count = 100;
+ int before,after;
+
+ //us = us*3;
+
+ if (wmt_read_ostc(&before))
+ return -1;
+ while(1) {
+ while(--count);
+ if (wmt_read_ostc(&after))
+ return -1;
+ if ((after - before) >= us) {
+ //printf("request = %d , result = %d\n",us,(after - before));
+ break;
+ }
+ count = 100;
+ }
+ return 0;
+}
+