products/aocpu: Split proudct code into a dir with board. [1/1]

PD#SWPL-61630

Problem:
Split proudct code into a dir with board.

Solution:
Split proudct code into a dir with board.

Verify:
T5W_AT301/AT309

Change-Id: I5c2465a4a42554caaf09a35875468f4d87b0eaf7
Signed-off-by: Xiaohu.Huang <xiaohu.huang@amlogic.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad7c01d..b23984d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,11 +6,10 @@
 target_include_directories(${TARGET_NAME} PUBLIC include)
 
 aml_sources(
-	util.c
-	fsm.c
-	btwake.c
-	keypad.c
-	power.c
-	main.c
+	${BOARD}/fsm.c
+	${BOARD}/btwake.c
+	${BOARD}/keypad.c
+	${BOARD}/power.c
+	${BOARD}/main.c
 )
 
diff --git a/am301_t950d4/CMakeLists.txt b/am301_t950d4/CMakeLists.txt
new file mode 100644
index 0000000..d529828
--- /dev/null
+++ b/am301_t950d4/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.13.1)
+project(aml-rtos)
+
+include($ENV{SDK_BASE}/build/cmake/root.cmake)
+
+message(STATUS "#################${SDK_BASE}/products/${PRODUCT}/${BOARD}/include")
+
+target_include_directories(${TARGET_NAME} PUBLIC include)
+
+aml_sources(
+	util.c
+	fsm.c
+	btwake.c
+	keypad.c
+	power.c
+	main.c
+)
+
diff --git a/btwake.c b/am301_t950d4/btwake.c
similarity index 100%
rename from btwake.c
rename to am301_t950d4/btwake.c
diff --git a/fsm.c b/am301_t950d4/fsm.c
similarity index 100%
rename from fsm.c
rename to am301_t950d4/fsm.c
diff --git a/include/keypad.h b/am301_t950d4/include/keypad.h
similarity index 100%
rename from include/keypad.h
rename to am301_t950d4/include/keypad.h
diff --git a/include/power.h b/am301_t950d4/include/power.h
similarity index 100%
rename from include/power.h
rename to am301_t950d4/include/power.h
diff --git a/keypad.c b/am301_t950d4/keypad.c
similarity index 100%
rename from keypad.c
rename to am301_t950d4/keypad.c
diff --git a/main.c b/am301_t950d4/main.c
similarity index 100%
rename from main.c
rename to am301_t950d4/main.c
diff --git a/power.c b/am301_t950d4/power.c
similarity index 100%
rename from power.c
rename to am301_t950d4/power.c
diff --git a/util.c b/am301_t950d4/util.c
similarity index 100%
rename from util.c
rename to am301_t950d4/util.c
diff --git a/btwake.c b/at301_t962d4/btwake.c
similarity index 100%
copy from btwake.c
copy to at301_t962d4/btwake.c
diff --git a/fsm.c b/at301_t962d4/fsm.c
similarity index 100%
copy from fsm.c
copy to at301_t962d4/fsm.c
diff --git a/include/keypad.h b/at301_t962d4/include/keypad.h
similarity index 100%
copy from include/keypad.h
copy to at301_t962d4/include/keypad.h
diff --git a/include/power.h b/at301_t962d4/include/power.h
similarity index 100%
copy from include/power.h
copy to at301_t962d4/include/power.h
diff --git a/keypad.c b/at301_t962d4/keypad.c
similarity index 100%
copy from keypad.c
copy to at301_t962d4/keypad.c
diff --git a/main.c b/at301_t962d4/main.c
similarity index 100%
copy from main.c
copy to at301_t962d4/main.c
diff --git a/at301_t962d4/power.c b/at301_t962d4/power.c
new file mode 100644
index 0000000..b5001f0
--- /dev/null
+++ b/at301_t962d4/power.c
@@ -0,0 +1,232 @@
+/*
+ * 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 "FreeRTOS.h"
+#include "common.h"
+#include "gpio.h"
+#include "ir.h"
+#include "suspend.h"
+#include "task.h"
+#include "gpio.h"
+#include "pwm.h"
+#include "pwm_plat.h"
+#include "keypad.h"
+
+#include "hdmi_cec.h"
+
+/*#define CONFIG_ETH_WAKEUP*/
+
+#ifdef CONFIG_ETH_WAKEUP
+#include "interrupt_control.h"
+#include "eth.h"
+#include "irq.h"
+#endif
+
+static TaskHandle_t cecTask = NULL;
+static int vdd_ee;
+static int vdd_cpu;
+
+static IRPowerKey_t prvPowerKeyList[] = {
+	{ 0xef10fe01, IR_NORMAL}, /* ref tv pwr */
+	{ 0xba45bd02, IR_NORMAL}, /* small ir pwr */
+	{ 0xef10fb04, IR_NORMAL}, /* old ref tv pwr */
+	{ 0xf20dfe01, IR_NORMAL},
+	{ 0xe51afb04, IR_NORMAL},
+	{ 0x3ac5bd02, IR_CUSTOM},
+	{}
+        /* add more */
+};
+
+static void vIRHandler(IRPowerKey_t *pkey)
+{
+	uint32_t buf[4] = {0};
+	if (pkey->type == IR_NORMAL)
+		buf[0] = REMOTE_WAKEUP;
+	else if (pkey->type == IR_CUSTOM)
+		buf[0] = REMOTE_CUS_WAKEUP;
+
+        /* do sth below  to wakeup*/
+	STR_Wakeup_src_Queue_Send_FromISR(buf);
+};
+
+void str_hw_init(void);
+void str_hw_disable(void);
+void str_power_on(int shutdown_flag);
+void str_power_off(int shutdown_flag);
+void Bt_GpioIRQRegister(void);
+void Bt_GpioIRQFree(void);
+
+void str_hw_init(void)
+{
+	/*enable device & wakeup source interrupt*/
+	vIRInit(MODE_HARD_NEC, GPIOD_5, PIN_FUNC1, prvPowerKeyList, ARRAY_SIZE(prvPowerKeyList), vIRHandler);
+#ifdef CONFIG_ETH_WAKEUP
+	vETHInit(IRQ_ETH_PMT_NUM,eth_handler_t5);
+#endif
+	xTaskCreate(vCEC_task, "CECtask", configMINIMAL_STACK_SIZE,
+		    NULL, CEC_TASK_PRI, &cecTask);
+	vBackupAndClearGpioIrqReg();
+	vKeyPadInit();
+	vGpioIRQInit();
+	Bt_GpioIRQRegister();
+}
+
+
+void str_hw_disable(void)
+{
+	/*disable wakeup source interrupt*/
+	vIRDeint();
+#ifdef CONFIG_ETH_WAKEUP
+	vETHDeint_t5();
+#endif
+	if (cecTask) {
+		vTaskDelete(cecTask);
+		cec_req_irq(0);
+	}
+	Bt_GpioIRQFree();
+	vKeyPadDeinit();
+	vRestoreGpioIrqReg();
+}
+
+void str_power_on(int shutdown_flag)
+{
+	int ret;
+
+	/***set vdd_ee val***/
+	ret = vPwmMesonsetvoltage(VDDEE_VOLT,vdd_ee);
+	if (ret < 0) {
+		printf("vdd_EE pwm set fail\n");
+		return;
+	}
+
+	/***set vdd_ee val***/
+	ret = vPwmMesonsetvoltage(VDDCPU_VOLT,vdd_cpu);
+	if (ret < 0) {
+		printf("vdd_CPU pwm set fail\n");
+		return;
+	}
+
+	/***power on vcc3.3***/
+	ret = xGpioSetDir(GPIOD_10,GPIO_DIR_OUT);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio dir fail\n");
+		return;
+	}
+
+	ret = xGpioSetValue(GPIOD_10,GPIO_LEVEL_HIGH);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio val fail\n");
+		return;
+	}
+
+	if (shutdown_flag) {
+		/***power on VDDQ/VDDCPU***/
+		ret = xGpioSetDir(GPIOD_4,GPIO_DIR_OUT);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio dir fail\n");
+			return;
+		}
+
+		ret = xGpioSetValue(GPIOD_4,GPIO_LEVEL_HIGH);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio val fail\n");
+			return;
+		}
+		/*Wait 200ms for VDDCPU statble*/
+		vTaskDelay(pdMS_TO_TICKS(200));
+	}
+
+	/***power on 5v***/
+	REG32(AO_GPIO_TEST_N) = REG32(AO_GPIO_TEST_N) | (1 << 31);
+}
+
+void str_power_off(int shutdown_flag)
+{
+	int ret;
+
+	printf("poweroff 5v\n");
+	printf("0x%x\n", REG32(AO_GPIO_TEST_N));
+
+	REG32(AO_GPIO_TEST_N) = (REG32(AO_GPIO_TEST_N) << 1) >> 1;
+
+	if (shutdown_flag) {
+		/***power off VDDQ/VDDCPU***/
+		ret = xGpioSetDir(GPIOD_4,GPIO_DIR_OUT);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio dir fail\n");
+			return;
+		}
+
+		ret = xGpioSetValue(GPIOD_4,GPIO_LEVEL_LOW);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio val fail\n");
+			return;
+		}
+	}
+
+	/***power off vcc3.3***/
+	ret = xGpioSetDir(GPIOD_10,GPIO_DIR_OUT);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio dir fail\n");
+		return;
+	}
+
+#ifndef CONFIG_ETH_WAKEUP
+	ret= xGpioSetValue(GPIOD_10,GPIO_LEVEL_LOW);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio val fail\n");
+		return;
+	}
+#endif
+
+	/***set vdd_cpu val***/
+	vdd_cpu = vPwmMesongetvoltage(VDDCPU_VOLT);
+	if (vdd_cpu < 0) {
+		printf("vdd_CPU pwm get fail\n");
+		return;
+	}
+
+	ret = vPwmMesonsetvoltage(VDDCPU_VOLT,700);
+	if (ret < 0) {
+		printf("vdd_CPU pwm set fail\n");
+		return;
+	}
+
+	/***set vdd_ee val***/
+	vdd_ee = vPwmMesongetvoltage(VDDEE_VOLT);
+	if (vdd_ee < 0) {
+		printf("vdd_EE pwm get fail\n");
+		return;
+	}
+
+	ret = vPwmMesonsetvoltage(VDDEE_VOLT,770);
+	if (ret < 0) {
+		printf("vdd_EE pwm set fail\n");
+		return;
+	}
+
+	//REG32( ((0x0000 << 2) + 0xff638c00)) = 0;
+}
+
diff --git a/util.c b/at301_t962d4/util.c
similarity index 100%
copy from util.c
copy to at301_t962d4/util.c
diff --git a/btwake.c b/at309_t962d4/btwake.c
similarity index 100%
copy from btwake.c
copy to at309_t962d4/btwake.c
diff --git a/fsm.c b/at309_t962d4/fsm.c
similarity index 100%
copy from fsm.c
copy to at309_t962d4/fsm.c
diff --git a/include/keypad.h b/at309_t962d4/include/keypad.h
similarity index 100%
copy from include/keypad.h
copy to at309_t962d4/include/keypad.h
diff --git a/include/power.h b/at309_t962d4/include/power.h
similarity index 100%
copy from include/power.h
copy to at309_t962d4/include/power.h
diff --git a/keypad.c b/at309_t962d4/keypad.c
similarity index 100%
copy from keypad.c
copy to at309_t962d4/keypad.c
diff --git a/main.c b/at309_t962d4/main.c
similarity index 100%
copy from main.c
copy to at309_t962d4/main.c
diff --git a/at309_t962d4/power.c b/at309_t962d4/power.c
new file mode 100644
index 0000000..b5001f0
--- /dev/null
+++ b/at309_t962d4/power.c
@@ -0,0 +1,232 @@
+/*
+ * 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 "FreeRTOS.h"
+#include "common.h"
+#include "gpio.h"
+#include "ir.h"
+#include "suspend.h"
+#include "task.h"
+#include "gpio.h"
+#include "pwm.h"
+#include "pwm_plat.h"
+#include "keypad.h"
+
+#include "hdmi_cec.h"
+
+/*#define CONFIG_ETH_WAKEUP*/
+
+#ifdef CONFIG_ETH_WAKEUP
+#include "interrupt_control.h"
+#include "eth.h"
+#include "irq.h"
+#endif
+
+static TaskHandle_t cecTask = NULL;
+static int vdd_ee;
+static int vdd_cpu;
+
+static IRPowerKey_t prvPowerKeyList[] = {
+	{ 0xef10fe01, IR_NORMAL}, /* ref tv pwr */
+	{ 0xba45bd02, IR_NORMAL}, /* small ir pwr */
+	{ 0xef10fb04, IR_NORMAL}, /* old ref tv pwr */
+	{ 0xf20dfe01, IR_NORMAL},
+	{ 0xe51afb04, IR_NORMAL},
+	{ 0x3ac5bd02, IR_CUSTOM},
+	{}
+        /* add more */
+};
+
+static void vIRHandler(IRPowerKey_t *pkey)
+{
+	uint32_t buf[4] = {0};
+	if (pkey->type == IR_NORMAL)
+		buf[0] = REMOTE_WAKEUP;
+	else if (pkey->type == IR_CUSTOM)
+		buf[0] = REMOTE_CUS_WAKEUP;
+
+        /* do sth below  to wakeup*/
+	STR_Wakeup_src_Queue_Send_FromISR(buf);
+};
+
+void str_hw_init(void);
+void str_hw_disable(void);
+void str_power_on(int shutdown_flag);
+void str_power_off(int shutdown_flag);
+void Bt_GpioIRQRegister(void);
+void Bt_GpioIRQFree(void);
+
+void str_hw_init(void)
+{
+	/*enable device & wakeup source interrupt*/
+	vIRInit(MODE_HARD_NEC, GPIOD_5, PIN_FUNC1, prvPowerKeyList, ARRAY_SIZE(prvPowerKeyList), vIRHandler);
+#ifdef CONFIG_ETH_WAKEUP
+	vETHInit(IRQ_ETH_PMT_NUM,eth_handler_t5);
+#endif
+	xTaskCreate(vCEC_task, "CECtask", configMINIMAL_STACK_SIZE,
+		    NULL, CEC_TASK_PRI, &cecTask);
+	vBackupAndClearGpioIrqReg();
+	vKeyPadInit();
+	vGpioIRQInit();
+	Bt_GpioIRQRegister();
+}
+
+
+void str_hw_disable(void)
+{
+	/*disable wakeup source interrupt*/
+	vIRDeint();
+#ifdef CONFIG_ETH_WAKEUP
+	vETHDeint_t5();
+#endif
+	if (cecTask) {
+		vTaskDelete(cecTask);
+		cec_req_irq(0);
+	}
+	Bt_GpioIRQFree();
+	vKeyPadDeinit();
+	vRestoreGpioIrqReg();
+}
+
+void str_power_on(int shutdown_flag)
+{
+	int ret;
+
+	/***set vdd_ee val***/
+	ret = vPwmMesonsetvoltage(VDDEE_VOLT,vdd_ee);
+	if (ret < 0) {
+		printf("vdd_EE pwm set fail\n");
+		return;
+	}
+
+	/***set vdd_ee val***/
+	ret = vPwmMesonsetvoltage(VDDCPU_VOLT,vdd_cpu);
+	if (ret < 0) {
+		printf("vdd_CPU pwm set fail\n");
+		return;
+	}
+
+	/***power on vcc3.3***/
+	ret = xGpioSetDir(GPIOD_10,GPIO_DIR_OUT);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio dir fail\n");
+		return;
+	}
+
+	ret = xGpioSetValue(GPIOD_10,GPIO_LEVEL_HIGH);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio val fail\n");
+		return;
+	}
+
+	if (shutdown_flag) {
+		/***power on VDDQ/VDDCPU***/
+		ret = xGpioSetDir(GPIOD_4,GPIO_DIR_OUT);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio dir fail\n");
+			return;
+		}
+
+		ret = xGpioSetValue(GPIOD_4,GPIO_LEVEL_HIGH);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio val fail\n");
+			return;
+		}
+		/*Wait 200ms for VDDCPU statble*/
+		vTaskDelay(pdMS_TO_TICKS(200));
+	}
+
+	/***power on 5v***/
+	REG32(AO_GPIO_TEST_N) = REG32(AO_GPIO_TEST_N) | (1 << 31);
+}
+
+void str_power_off(int shutdown_flag)
+{
+	int ret;
+
+	printf("poweroff 5v\n");
+	printf("0x%x\n", REG32(AO_GPIO_TEST_N));
+
+	REG32(AO_GPIO_TEST_N) = (REG32(AO_GPIO_TEST_N) << 1) >> 1;
+
+	if (shutdown_flag) {
+		/***power off VDDQ/VDDCPU***/
+		ret = xGpioSetDir(GPIOD_4,GPIO_DIR_OUT);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio dir fail\n");
+			return;
+		}
+
+		ret = xGpioSetValue(GPIOD_4,GPIO_LEVEL_LOW);
+		if (ret < 0) {
+			printf("VDDCPU/VDDQ set gpio val fail\n");
+			return;
+		}
+	}
+
+	/***power off vcc3.3***/
+	ret = xGpioSetDir(GPIOD_10,GPIO_DIR_OUT);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio dir fail\n");
+		return;
+	}
+
+#ifndef CONFIG_ETH_WAKEUP
+	ret= xGpioSetValue(GPIOD_10,GPIO_LEVEL_LOW);
+	if (ret < 0) {
+		printf("vcc3.3 set gpio val fail\n");
+		return;
+	}
+#endif
+
+	/***set vdd_cpu val***/
+	vdd_cpu = vPwmMesongetvoltage(VDDCPU_VOLT);
+	if (vdd_cpu < 0) {
+		printf("vdd_CPU pwm get fail\n");
+		return;
+	}
+
+	ret = vPwmMesonsetvoltage(VDDCPU_VOLT,700);
+	if (ret < 0) {
+		printf("vdd_CPU pwm set fail\n");
+		return;
+	}
+
+	/***set vdd_ee val***/
+	vdd_ee = vPwmMesongetvoltage(VDDEE_VOLT);
+	if (vdd_ee < 0) {
+		printf("vdd_EE pwm get fail\n");
+		return;
+	}
+
+	ret = vPwmMesonsetvoltage(VDDEE_VOLT,770);
+	if (ret < 0) {
+		printf("vdd_EE pwm set fail\n");
+		return;
+	}
+
+	//REG32( ((0x0000 << 2) + 0xff638c00)) = 0;
+}
+
diff --git a/util.c b/at309_t962d4/util.c
similarity index 100%
copy from util.c
copy to at309_t962d4/util.c
diff --git a/include/lscript.h b/include/lscript.h
deleted file mode 100644
index d01eb2a..0000000
--- a/include/lscript.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _LSCRIPT_H_
-#define _LSCRIPT_H_
-
-#define configMEM_START		0x10000000
-#define configMEM_LEN		(64 * 1024)
-
-#endif
diff --git a/include/util.h b/include/util.h
deleted file mode 100644
index c5faa2e..0000000
--- a/include/util.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Various utility functions and macros */
-
-#ifndef __CROS_EC_UTIL_H
-#define __CROS_EC_UTIL_H
-
-#include "common.h"
-
-#include <stddef.h>
-
-/**
- * Trigger a debug exception if the condition
- * is not verified at runtime.
- */
-
-
-/* Standard macros / definitions */
-#ifndef MAX
-#define MAX(a, b)					\
-	({						\
-		__typeof__(a) temp_a = (a);		\
-		__typeof__(b) temp_b = (b);		\
-							\
-		temp_a > temp_b ? temp_a : temp_b;	\
-	})
-#endif
-#ifndef MIN
-#define MIN(a, b)					\
-	({						\
-		__typeof__(a) temp_a = (a);		\
-		__typeof__(b) temp_b = (b);		\
-							\
-		temp_a < temp_b ? temp_a : temp_b;	\
-	})
-#endif
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
-/*
- * Convert a pointer to a base struct into a pointer to the struct that
- * contains the base struct.  This requires knowing where in the contained
- * struct the base struct resides, this is the member parameter to downcast.
- */
-#define DOWNCAST(pointer, type, member)					\
-	((type *)(((uint8_t *) pointer) - offsetof(type, member)))
-
-/* True of x is a power of two */
-#define POWER_OF_TWO(x) (x && !(x & (x - 1)))
-
-/**
- * macros for integer division with various rounding variants
- * default integer division rounds down.
- */
-#define DIV_ROUND_UP(x, y) (((x) + ((y) - 1)) / (y))
-#define DIV_ROUND_NEAREST(x, y) (((x) + ((y) / 2)) / (y))
-#define DIV_ROUND_CLOSEST(x, divisor)(                  \
-{                                                       \
-        typeof(x) __x = x;                              \
-        typeof(divisor) __d = divisor;                  \
-        (((typeof(x))-1) > 0 ||                         \
-         ((typeof(divisor))-1) > 0 || (__x) > 0) ?      \
-                (((__x) + ((__d) / 2)) / (__d)) :       \
-                (((__x) - ((__d) / 2)) / (__d));        \
-}                                                       \
-)
-
-/**
- * Parses a boolean option from a string.
- *
- * Strings that set *dest=0 and return 1 (all case-insensitive):
- *   "off"
- *   "dis*"
- *   "n*"
- *   "f*"
- *
- * Strings that set *dest=1 and return 1 (all case-insensitive):
- *   "on"
- *   "ena*"
- *   "y*"
- *   "t*"
- *
- * Other strings return 0 and leave *dest unchanged.
- */
-int parse_bool(const char *s, int *dest);
-
-/* 64-bit divide-and-modulo.  Does the equivalent of:
- *
- *   r = *n % d;
- *   *n /= d;
- *   return r;
- */
-int uint64divmod(uint64_t *v, int by);
-
-/**
- * Get-and-clear next bit from mask.
- *
- * Starts with most significant bit.
- *
- * @param mask Bitmask to extract next bit from. Must NOT be zero.
- * @return bit position (0..31)
- */
-int get_next_bit(uint32_t *mask);
-
-
-/****************************************************************************/
-/* Conditional stuff.
- *
- * We often need to watch for transitions between one state and another, so
- * that we can issue warnings or take action ONCE. This abstracts that "have I
- * already reacted to this" stuff into a single set of functions.
- *
- * For example:
- *
- *     cond_t c;
- *
- *     cond_init_false(&c);
- *
- *     while(1) {
- *         int val = read_some_gpio();
- *         cond_set(&c, val);
- *
- *         if (cond_went_true(&c))
- *             host_event(SOMETHING_HAPPENED);
- *     }
- *
- */
-typedef uint8_t cond_t;
-
-/* Initialize a conditional to a specific state. Do this first. */
-void cond_init(cond_t *c, int boolean);
-static inline void cond_init_false(cond_t *c) { cond_init(c, 0); }
-static inline void cond_init_true(cond_t *c) { cond_init(c, 1); }
-
-/* Set the current state. Do this as often as you like. */
-void cond_set(cond_t *c, int boolean);
-static inline void cond_set_false(cond_t *c) { cond_set(c, 0); }
-static inline void cond_set_true(cond_t *c) { cond_set(c, 1); }
-
-/* Get the current state. Do this as often as you like. */
-int cond_is(cond_t *c, int boolean);
-static inline int cond_is_false(cond_t *c) { return cond_is(c, 0); }
-static inline int cond_is_true(cond_t *c) { return cond_is(c, 1); }
-
-/* See if the state has transitioned. If it has, the corresponding function
- * will return true ONCE only, until it's changed back.
- */
-int cond_went(cond_t *c, int boolean);
-static inline int cond_went_false(cond_t *c) { return cond_went(c, 0); }
-static inline int cond_went_true(cond_t *c) { return cond_went(c, 1); }
-
-/****************************************************************************/
-/* Console command parsing */
-
-/* Parse command-line arguments given integer shift value to obtain
- * offset and size.
- */
-
-int __clzsi2(int x);
-
-#endif  /* __CROS_EC_UTIL_H */