From: Michael Riesch <michael.riesch@wolfvision.net>
To: barebox@lists.infradead.org
Cc: Michael Riesch <michael.riesch@wolfvision.net>
Subject: [RFC PATCH 1/2] arm: rockchip-rk3568-evb: add hardware id detection
Date: Tue, 29 Jun 2021 14:31:03 +0200 [thread overview]
Message-ID: <20210629123104.13818-2-michael.riesch@wolfvision.net> (raw)
In-Reply-To: <20210629123104.13818-1-michael.riesch@wolfvision.net>
Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-06-29 12:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-29 12:31 [RFC PATCH 0/2] Proof of concept device tree overlays Michael Riesch
2021-06-29 12:31 ` Michael Riesch [this message]
2021-06-30 10:17 ` [RFC PATCH 1/2] arm: rockchip-rk3568-evb: add hardware id detection Ahmad Fatoum
2021-07-01 7:19 ` Michael Riesch
2021-07-03 20:49 ` Sascha Hauer
2021-06-29 12:31 ` [RFC PATCH 2/2] arm: rockchip-rk3568-evb: apply dt overlay for evb7 Michael Riesch
2021-06-29 21:58 ` Trent Piepho
2021-06-30 9:18 ` Michael Riesch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210629123104.13818-2-michael.riesch@wolfvision.net \
--to=michael.riesch@wolfvision.net \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox