diff options
Diffstat (limited to 'board/kontron/pitx_imx8m/pitx_misc.c')
-rw-r--r-- | board/kontron/pitx_imx8m/pitx_misc.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/board/kontron/pitx_imx8m/pitx_misc.c b/board/kontron/pitx_imx8m/pitx_misc.c new file mode 100644 index 0000000000..48b29c4bd3 --- /dev/null +++ b/board/kontron/pitx_imx8m/pitx_misc.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <asm/arch/imx8mq_pins.h> +#include <asm-generic/gpio.h> +#include <asm/mach-imx/gpio.h> + +/* + * BRD_REV1 BRD_REV0 + * 0 0 n/a + * 0 1 n/a + * 1 0 2GB LPDDR4 + * 1 1 4GB LPDDR4 + */ + +#define BRD_REV0 IMX_GPIO_NR(5, 0) +#define BRD_REV1 IMX_GPIO_NR(5, 1) + +static iomux_v3_cfg_t const brdrev_pads[] = { + IMX8MQ_PAD_SAI3_TXC__GPIO5_IO0 | MUX_PAD_CTRL(PAD_CTL_PUE), + IMX8MQ_PAD_SAI3_TXD__GPIO5_IO1 | MUX_PAD_CTRL(PAD_CTL_PUE), + IMX8MQ_PAD_SAI3_MCLK__GPIO5_IO2 | MUX_PAD_CTRL(PAD_CTL_PUE), +}; + +int get_pitx_board_variant(void) +{ + int variant = 0; + + imx_iomux_v3_setup_multiple_pads(brdrev_pads, ARRAY_SIZE(brdrev_pads)); + + gpio_request(BRD_REV0, "BRD_REV0"); + gpio_direction_input(BRD_REV0); + gpio_request(BRD_REV1, "BRD_REV1"); + gpio_direction_input(BRD_REV1); + + variant |= !!gpio_get_value(BRD_REV0) << 0; + variant |= !!gpio_get_value(BRD_REV1) << 1; + + return variant; +} |