drivers_aocpu: init drivers_aocpu [1/1]
PD#SWPL-66844
Problem:
init drivers_aocpu
Solution:
init drivers_aocpu
Verify:
N/A
Signed-off-by: Kelvin Zhang <kelvin.zhang@amlogic.com>
Change-Id: Iadc845929b1cead1375024a8ad4723334bad4015
diff --git a/timer_source/timer_source.c b/timer_source/timer_source.c
new file mode 100644
index 0000000..327d078
--- /dev/null
+++ b/timer_source/timer_source.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2014-2018 Amlogic, Inc. All rights reserved.
+ *
+ * All information contained herein is Amlogic confidential.
+ *
+ * This software is provided to you pursuant to Software License Agreement
+ * (SLA) with Amlogic Inc ("Amlogic"). This software may be used
+ * only in accordance with the terms of this agreement.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification is strictly prohibited without prior written permission from
+ * Amlogic.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *//*
+ * Copyright (C) 2014-2018 Amlogic, Inc. All rights reserved.
+ *
+ * All information contained herein is Amlogic confidential.
+ *
+ * This software is provided to you pursuant to Software License Agreement
+ * (SLA) with Amlogic Inc ("Amlogic"). This software may be used
+ * only in accordance with the terms of this agreement.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification is strictly prohibited without prior written permission from
+ * Amlogic.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "register.h"
+#include "common.h"
+#include "stdio.h"
+#include "timer_source.h"
+
+
+uint32_t timere_read(void)
+{
+ uint32_t time = 0;
+ unsigned long long te = 0, temp = 0;
+
+ /*timeE high+low, first read low, second read high*/
+ te = REG32(TIMERE_LOW_REG);
+ temp = REG32(TIMERE_HIG_REG);
+ te += (temp << 32);
+ te = te/1000000;
+ time = (uint32_t)te;
+ //printf("----------time_e: %us\n", time);
+ return time;
+}
+
+unsigned long long timere_read_us(void)
+{
+ unsigned long long te = 0, temp = 0;
+
+ /*timeE high+low, first read low, second read high*/
+ te = REG32(TIMERE_LOW_REG);
+ temp = REG32(TIMERE_HIG_REG);
+ te += (temp << 32);
+
+ return te;
+}
+
+void udelay(uint32_t uS)
+{
+ unsigned long long t0;
+
+ if (uS == 0)
+ return;
+ t0 = timere_read_us();
+ while (timere_read_us() - t0 < uS);
+}
+
+void mdelay(uint32_t mS)
+{
+ if (mS == 0)
+ return;
+ while (mS--) {
+ udelay(1000);
+ }
+}