From 399488158bdc7a48d2c537c9bb6491e59f8813dc Mon Sep 17 00:00:00 2001 From: Ray Thomson Date: Thu, 4 Mar 2021 21:59:50 +1100 Subject: [PATCH 1/2] Add Rock Pi 4c Support Added Rock Pi 4c Support --- adafruit_platformdetect/board.py | 8 ++++++-- adafruit_platformdetect/chip.py | 3 +++ adafruit_platformdetect/constants/boards.py | 4 ++++ adafruit_platformdetect/constants/chips.py | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index c9194591..457c8746 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -135,6 +135,8 @@ def id(self): board_id = self._clockwork_pi_id() elif chip_id == chips.RK3308: board_id = self._rock_pi_id() + elif chip_id == chips.RK3399: + board_id = self._rock_pi_id() elif chip_id == chips.ATOM_X5_Z8350: board_id = self._rock_pi_id() elif chip_id == chips.RK3288: @@ -372,6 +374,8 @@ def _rock_pi_id(self): board = None if board_value and "ROCK Pi S" in board_value: board = boards.ROCK_PI_S + if board_value and "ROCK PI 4" in board_value.upper(): + board = boards.ROCK_PI_4 if self.detector.check_board_name_value() == "ROCK Pi X": board = boards.ROCK_PI_X return board @@ -486,8 +490,8 @@ def any_pine64_board(self): @property def any_rock_pi_board(self): - """Check whether the current board is any Clockwork Pi device.""" - return self.ROCK_PI_S + """Check whether the current board is any Rock Pi device.""" + return self.id in boards._ROCK_PI_IDS @property def any_clockwork_pi_board(self): diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index 0838301b..e91a1794 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -144,6 +144,9 @@ def _linux_id(self): if self.detector.check_dt_compatible_value("rockchip,rk3308"): return chips.RK3308 + if self.detector.check_dt_compatible_value("rockchip,rk3399"): + return chips.RK3399 + if self.detector.check_dt_compatible_value("rockchip,rk3288"): return chips.RK3288 diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 510dc402..383a02ff 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -121,6 +121,7 @@ SOPINE = "SOPINE" ROCK_PI_S = "ROCK_PI_S" +ROCK_PI_4 = "ROCK_PI_4" ROCK_PI_X = "ROCK_PI_X" GREATFET_ONE = "GREATFET_ONE" @@ -454,5 +455,8 @@ # Pine64 boards and devices _PINE64_DEV_IDS = (PINE64, PINEH64, PINEBOOK, PINEPHONE, SOPINE) +# RockPi boards and devices +_ROCK_PI_IDS = (ROCK_PI_S, ROCK_PI_4, ROCK_PI_X) + # UDOO _UDOO_BOARD_IDS = {UDOO_BOLT_V8: ("SC40-2000-0000-C0|C",), UDOO_X86: ("dummy",)} diff --git a/adafruit_platformdetect/constants/chips.py b/adafruit_platformdetect/constants/chips.py index cf8c9fb5..0789fb84 100644 --- a/adafruit_platformdetect/constants/chips.py +++ b/adafruit_platformdetect/constants/chips.py @@ -33,6 +33,7 @@ H5 = "H5" H616 = "H616" RK3308 = "RK3308" +RK3399 = "RK3399" LPC4330 = "LPC4330" RK3288 = "RK3288" PENTIUM_N3710 = "PENTIUM_N3710" # SOC Braswell core From 0bf1431380c8e50a769ff28511bf721f6a3b7aae Mon Sep 17 00:00:00 2001 From: Ray Thomson Date: Sat, 6 Mar 2021 21:50:27 +1100 Subject: [PATCH 2/2] Code reformat --- adafruit_platformdetect/board.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 457c8746..f51b3391 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -136,7 +136,7 @@ def id(self): elif chip_id == chips.RK3308: board_id = self._rock_pi_id() elif chip_id == chips.RK3399: - board_id = self._rock_pi_id() + board_id = self._rock_pi_id() elif chip_id == chips.ATOM_X5_Z8350: board_id = self._rock_pi_id() elif chip_id == chips.RK3288: @@ -375,7 +375,7 @@ def _rock_pi_id(self): if board_value and "ROCK Pi S" in board_value: board = boards.ROCK_PI_S if board_value and "ROCK PI 4" in board_value.upper(): - board = boards.ROCK_PI_4 + board = boards.ROCK_PI_4 if self.detector.check_board_name_value() == "ROCK Pi X": board = boards.ROCK_PI_X return board