Skip to content

Commit 0bf0fe4

Browse files
committed
sunxi: pinephone: detect existed magnetometer and fixup dtb
In newer 1.2 PinePhone board revisions LIS3MDL magnetometer was replaced by AF8133J. They use the same PB1 pin in different modes. LIS3MDL uses it as an gpio input to handle interrupt. AF8133J uses it as an gpio output as a reset signal. It wasn't possible at runtime to enable both device tree nodes and detect supported sensor at probe time. AF8133J has reset pin (PB1) connected to the SoC. By default AF8133J is in a reset state and don't respond to probe request on I2C bus. Extra code would be needed to handle reset signal. Therefore this code uses LIS3MDL magnetometer instead of AF8133J. Introducing new dts 1.2b with AF8133J sensor would require probing in SPL. That would lead to pulling in into SPL I2C controller driver, RSB controller driver, introducing new AXP803 driver to power-up sensors for probe. It's working, but SPL is pretty size-constrained on A64 and doesn't have much space. Therefore fdt fixup is done in U-Boot proper without introducing new board revision and new dts. Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
1 parent f1252aa commit 0bf0fe4

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

board/sunxi/board.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <dm.h>
1616
#include <env.h>
1717
#include <hang.h>
18+
#include <i2c.h>
1819
#include <image.h>
1920
#include <init.h>
2021
#include <log.h>
@@ -920,6 +921,28 @@ static void bluetooth_dt_fixup(void *blob)
920921
"local-bd-address", bdaddr, ETH_ALEN, 1);
921922
}
922923

924+
#define PINEPHONE_LIS3MDL_I2C_ADDR 0x1E
925+
#define PINEPHONE_LIS3MDL_I2C_BUS 1 /* I2C1 */
926+
927+
static void board_dt_fixup(void *blob)
928+
{
929+
struct udevice *bus, *dev;
930+
931+
#ifdef CONFIG_PINEPHONE_DT_SELECTION
932+
if (!fdt_node_check_compatible(blob, 0, "pine64,pinephone-1.2")) {
933+
if (!uclass_get_device_by_seq(UCLASS_I2C, PINEPHONE_LIS3MDL_I2C_BUS, &bus)) {
934+
dm_i2c_probe(bus, PINEPHONE_LIS3MDL_I2C_ADDR, 0, &dev);
935+
fdt_set_status_by_compatible(
936+
blob, "st,lis3mdl-magn",
937+
dev ? FDT_STATUS_OKAY : FDT_STATUS_DISABLED);
938+
fdt_set_status_by_compatible(
939+
blob, "voltafield,af8133j",
940+
dev ? FDT_STATUS_DISABLED : FDT_STATUS_OKAY);
941+
}
942+
}
943+
#endif
944+
}
945+
923946
int ft_board_setup(void *blob, struct bd_info *bd)
924947
{
925948
int __maybe_unused r;
@@ -934,6 +957,9 @@ int ft_board_setup(void *blob, struct bd_info *bd)
934957

935958
bluetooth_dt_fixup(blob);
936959

960+
#ifdef CONFIG_PINEPHONE_DT_SELECTION
961+
board_dt_fixup(blob);
962+
#endif
937963
#ifdef CONFIG_VIDEO_DT_SIMPLEFB
938964
r = sunxi_simplefb_setup(blob);
939965
if (r)

configs/pinephone_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CONFIG_MMC_SUNXI_SLOT_EXTRA=2
1212
CONFIG_PINEPHONE_DT_SELECTION=y
1313
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
1414
CONFIG_OF_LIST="sun50i-a64-pinephone-1.1 sun50i-a64-pinephone-1.2"
15+
CONFIG_SYS_I2C_MVTWSI=y
1516
CONFIG_LED_STATUS=y
1617
CONFIG_LED_STATUS_GPIO=y
1718
CONFIG_LED_STATUS0=y

0 commit comments

Comments
 (0)