summaryrefslogtreecommitdiff
path: root/board/sunxi/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/sunxi/board.c')
-rw-r--r--board/sunxi/board.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 9c340908a96..c7a2205ed61 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -14,6 +14,7 @@
#include <dm.h>
#include <env.h>
#include <hang.h>
+#include <i2c.h>
#include <image.h>
#include <init.h>
#include <log.h>
@@ -878,6 +879,27 @@ static void bluetooth_dt_fixup(void *blob)
"local-bd-address", bdaddr, ETH_ALEN, 1);
}
+#define PINEPHONE_LIS3MDL_I2C_ADDR 0x1e
+#define PINEPHONE_LIS3MDL_I2C_BUS 1 /* I2C1 */
+
+static void board_dt_fixup(void *blob)
+{
+ struct udevice *bus, *dev;
+
+ if (IS_ENABLED(CONFIG_PINEPHONE_DT_SELECTION) &&
+ !fdt_node_check_compatible(blob, 0, "pine64,pinephone-1.2")) {
+ if (!uclass_get_device_by_seq(UCLASS_I2C,
+ PINEPHONE_LIS3MDL_I2C_BUS,
+ &bus)) {
+ dm_i2c_probe(bus, PINEPHONE_LIS3MDL_I2C_ADDR, 0, &dev);
+ fdt_set_status_by_compatible(blob, "st,lis3mdl-magn",
+ dev ? FDT_STATUS_OKAY : FDT_STATUS_DISABLED);
+ fdt_set_status_by_compatible(blob, "voltafield,af8133j",
+ dev ? FDT_STATUS_DISABLED : FDT_STATUS_OKAY);
+ }
+ }
+}
+
int ft_board_setup(void *blob, struct bd_info *bd)
{
int __maybe_unused r;
@@ -891,6 +913,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
fdt_fixup_ethernet(blob);
bluetooth_dt_fixup(blob);
+ board_dt_fixup(blob);
#ifdef CONFIG_VIDEO_DT_SIMPLEFB
r = sunxi_simplefb_setup(blob);