blob: 48b29c4bd34c99d863cfd282bce2e4327059623f [file] [log] [blame]
Heiko Thiery05a3d952022-01-31 17:30:45 +01001// SPDX-License-Identifier: GPL-2.0+
2#include <asm/arch/imx8mq_pins.h>
3#include <asm-generic/gpio.h>
4#include <asm/mach-imx/gpio.h>
5
6/*
7 * BRD_REV1 BRD_REV0
8 * 0 0 n/a
9 * 0 1 n/a
10 * 1 0 2GB LPDDR4
11 * 1 1 4GB LPDDR4
12 */
13
14#define BRD_REV0 IMX_GPIO_NR(5, 0)
15#define BRD_REV1 IMX_GPIO_NR(5, 1)
16
17static iomux_v3_cfg_t const brdrev_pads[] = {
18 IMX8MQ_PAD_SAI3_TXC__GPIO5_IO0 | MUX_PAD_CTRL(PAD_CTL_PUE),
19 IMX8MQ_PAD_SAI3_TXD__GPIO5_IO1 | MUX_PAD_CTRL(PAD_CTL_PUE),
20 IMX8MQ_PAD_SAI3_MCLK__GPIO5_IO2 | MUX_PAD_CTRL(PAD_CTL_PUE),
21};
22
23int get_pitx_board_variant(void)
24{
25 int variant = 0;
26
27 imx_iomux_v3_setup_multiple_pads(brdrev_pads, ARRAY_SIZE(brdrev_pads));
28
29 gpio_request(BRD_REV0, "BRD_REV0");
30 gpio_direction_input(BRD_REV0);
31 gpio_request(BRD_REV1, "BRD_REV1");
32 gpio_direction_input(BRD_REV1);
33
34 variant |= !!gpio_get_value(BRD_REV0) << 0;
35 variant |= !!gpio_get_value(BRD_REV1) << 1;
36
37 return variant;
38}