Permalink
Browse files

board: samsung: i9300: set serial number and board rev

The board rev is GPM1[5:2], and the serial number
is the bottom two words of the MMC CID.
  • Loading branch information...
fourkbomb committed May 20, 2018
1 parent 0f2899c commit 5e87c7025639a7fe5fa4a320b42976d57bb0eaa5
Showing with 53 additions and 3 deletions.
  1. +1 −0 arch/arm/mach-exynos/Kconfig
  2. +52 −3 board/samsung/i9300/i9300.c
@@ -76,6 +76,7 @@ config TARGET_I9300
bool "Exynos4412 i9300 board"
select SUPPORT_SPL
select EXYNOS4412
select BOARD_LATE_INIT
imply OF_BOARD_SETUP

endchoice
@@ -9,6 +9,7 @@
#include <asm/arch/gpio.h>
#include <extcon.h>
#include <linux/libfdt.h>
#include <mmc.h>
#include <power/max77686_pmic.h>
#include <power/max77693_muic.h>
#include <power/pmic.h>
@@ -18,10 +19,51 @@

DECLARE_GLOBAL_DATA_PTR;

int get_board_rev(void)
static uint64_t board_serial = 0;
static char board_rev = 0xff;
static char board_serial_str[17];

void board_load_info(void)
{
// TODO: GPM1[5:2]
return 0;
struct mmc *emmc = find_mmc_device(2);
static const int rev_gpios[] = {
EXYNOS4X12_GPIO_M15,
EXYNOS4X12_GPIO_M14,
EXYNOS4X12_GPIO_M13,
EXYNOS4X12_GPIO_M12,
};

board_rev = 0;

for (int i = 0; i < ARRAY_SIZE(rev_gpios); i++) {
gpio_request(rev_gpios[i], "HW_REV[0..3]");
gpio_cfg_pin(rev_gpios[i], S5P_GPIO_INPUT);
gpio_set_pull(rev_gpios[i], S5P_GPIO_PULL_DOWN);

board_rev <<= 1;
board_rev |= gpio_get_value(rev_gpios[i]);
}

if (!emmc) {
pr_err("%s: couldn't get serial number - no eMMC device found!\n", __func__);
sprintf(board_serial_str, "%16x", 0);
return;
}

if (mmc_init(emmc)) {
pr_err("%s: eMMC init failed!\n", __func__);
} else {
board_serial = ((uint64_t)emmc->cid[2] << 32) | emmc->cid[3];
}
sprintf(board_serial_str, "%16llx", board_serial);
env_set("serial#", board_serial_str);
}

int get_board_rev(void) {
if (board_rev == 0xff)
board_load_info();

return board_rev;
}

static void board_gpio_init(void)
@@ -169,3 +211,10 @@ int exynos_init(void)

return 0;
}

int exynos_late_init(void)
{
board_load_info();

return 0;
}

0 comments on commit 5e87c70

Please sign in to comment.