[RFC PATCH 1/2] arm: rockchip-rk3568-evb: add hardware id detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michael Riesch <michael.riesch@xxxxxxxxxxxxxx>
---
 arch/arm/boards/rockchip-rk3568-evb/board.c | 36 +++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boards/rockchip-rk3568-evb/board.c b/arch/arm/boards/rockchip-rk3568-evb/board.c
index 57c24ed3c..ee8e1b979 100644
--- a/arch/arm/boards/rockchip-rk3568-evb/board.c
+++ b/arch/arm/boards/rockchip-rk3568-evb/board.c
@@ -2,6 +2,7 @@
 #include <common.h>
 #include <init.h>
 #include <mach/bbu.h>
+#include <aiodev.h>
 #include <bootsource.h>
 
 static int rk3568_evb_probe(struct device_d *dev)
@@ -34,3 +35,38 @@ static struct driver_d rk3568_evb_board_driver = {
 	.of_compatible = rk3568_evb_of_match,
 };
 coredevice_platform_driver(rk3568_evb_board_driver);
+
+static int rk3568_evb_detect_version(void)
+{
+	int ret = 0;
+	int evb_hw_id = 0;
+	int evb_hw_id_voltage = 1800;
+	struct aiochannel *evb_hw_id_chan;
+
+	evb_hw_id_chan = aiochannel_by_name("aiodev0.in_value1_mV");
+	if (!IS_ERR(evb_hw_id_chan))
+		ret = aiochannel_get_value(evb_hw_id_chan, &evb_hw_id_voltage);
+	if (ret || IS_ERR(evb_hw_id_chan))
+		pr_warn("couldn't retrieve hardware ID");
+
+	if (evb_hw_id_voltage > 1650) {
+		evb_hw_id = 1;
+	} else if (evb_hw_id_voltage > 1350) {
+		evb_hw_id = 2;
+	} else if (evb_hw_id_voltage > 1050) {
+		evb_hw_id = 3;
+	} else if (evb_hw_id_voltage > 750) {
+		evb_hw_id = 4;
+	} else if (evb_hw_id_voltage > 450) {
+		evb_hw_id = 5;
+	} else if (evb_hw_id_voltage > 150) {
+		evb_hw_id = 6;
+	} else {
+		evb_hw_id = 7;
+	}
+
+	pr_info("Detected RK3568 EVB%d\n", evb_hw_id);
+
+	return 0;
+}
+late_initcall(rk3568_evb_detect_version);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux