Skip to content

Commit 5e87c70

Browse files
committed
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.
1 parent 0f2899c commit 5e87c70

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

arch/arm/mach-exynos/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ config TARGET_I9300
7676
bool "Exynos4412 i9300 board"
7777
select SUPPORT_SPL
7878
select EXYNOS4412
79+
select BOARD_LATE_INIT
7980
imply OF_BOARD_SETUP
8081

8182
endchoice

board/samsung/i9300/i9300.c

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/arch/gpio.h>
1010
#include <extcon.h>
1111
#include <linux/libfdt.h>
12+
#include <mmc.h>
1213
#include <power/max77686_pmic.h>
1314
#include <power/max77693_muic.h>
1415
#include <power/pmic.h>
@@ -18,10 +19,51 @@
1819

1920
DECLARE_GLOBAL_DATA_PTR;
2021

21-
int get_board_rev(void)
22+
static uint64_t board_serial = 0;
23+
static char board_rev = 0xff;
24+
static char board_serial_str[17];
25+
26+
void board_load_info(void)
2227
{
23-
// TODO: GPM1[5:2]
24-
return 0;
28+
struct mmc *emmc = find_mmc_device(2);
29+
static const int rev_gpios[] = {
30+
EXYNOS4X12_GPIO_M15,
31+
EXYNOS4X12_GPIO_M14,
32+
EXYNOS4X12_GPIO_M13,
33+
EXYNOS4X12_GPIO_M12,
34+
};
35+
36+
board_rev = 0;
37+
38+
for (int i = 0; i < ARRAY_SIZE(rev_gpios); i++) {
39+
gpio_request(rev_gpios[i], "HW_REV[0..3]");
40+
gpio_cfg_pin(rev_gpios[i], S5P_GPIO_INPUT);
41+
gpio_set_pull(rev_gpios[i], S5P_GPIO_PULL_DOWN);
42+
43+
board_rev <<= 1;
44+
board_rev |= gpio_get_value(rev_gpios[i]);
45+
}
46+
47+
if (!emmc) {
48+
pr_err("%s: couldn't get serial number - no eMMC device found!\n", __func__);
49+
sprintf(board_serial_str, "%16x", 0);
50+
return;
51+
}
52+
53+
if (mmc_init(emmc)) {
54+
pr_err("%s: eMMC init failed!\n", __func__);
55+
} else {
56+
board_serial = ((uint64_t)emmc->cid[2] << 32) | emmc->cid[3];
57+
}
58+
sprintf(board_serial_str, "%16llx", board_serial);
59+
env_set("serial#", board_serial_str);
60+
}
61+
62+
int get_board_rev(void) {
63+
if (board_rev == 0xff)
64+
board_load_info();
65+
66+
return board_rev;
2567
}
2668

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

170212
return 0;
171213
}
214+
215+
int exynos_late_init(void)
216+
{
217+
board_load_info();
218+
219+
return 0;
220+
}

0 commit comments

Comments
 (0)