9
0
Fork 0

sysmobts: detect the eeprom variant at runtime

Signed-off-by: Jan Luebbe <jluebbe@debian.org>
This commit is contained in:
Jan Luebbe 2015-06-14 12:08:16 +02:00 committed by Holger Hans Peter Freyther
parent be17e14d38
commit 8b61a7b135
2 changed files with 22 additions and 3 deletions

View File

@ -76,6 +76,18 @@ static struct device_d dm644x_emac_device = {
.platform_data = &dm644x_emac_pdata,
};
static void sysmobts_config_eeprom(const char *compatible) {
struct device_node *node;
node = of_find_node_by_path("/i2c/eeprom@50");
if (!node) {
pr_err("can't find eeprom node to configure\n");
return;
}
of_set_property(node, "compatible", compatible, strlen(compatible)+1, 1);
of_device_enable(node);
}
static void sysmobts_board_detect(void)
{
int board_ver, board_cfg;
@ -99,6 +111,13 @@ static void sysmobts_board_detect(void)
globalvar_add_simple("board.variant", variant);
printf("detected 'sysmobts_v2 %s'\n", variant);
/* enable the correct eeprom */
if (board_ver <= 2) {
sysmobts_config_eeprom("24c02");
} else {
sysmobts_config_eeprom("24c64");
}
}
static int sysmobts_set_ethaddr(void)
@ -146,14 +165,14 @@ static int sysmobts_coredevices_init(void)
writel(readl(PINMUX1) & ~PINMUX1_I2C, PINMUX1);
sysmobts_board_detect();
return 0;
}
coredevice_initcall(sysmobts_coredevices_init);
static int sysmobts_devices_init(void)
{
sysmobts_board_detect();
sysmobts_set_ethaddr();
platform_device_register(&dm644x_emac_device);

View File

@ -72,7 +72,7 @@
status = "okay";
eeprom: eeprom@50 {
compatible = "24c02";
status = "disabled";
reg = <0x50>;
#address-cells = <1>;