sysmobts: detect the eeprom variant at runtime
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
This commit is contained in:
parent
be17e14d38
commit
8b61a7b135
|
@ -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);
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
status = "okay";
|
||||
|
||||
eeprom: eeprom@50 {
|
||||
compatible = "24c02";
|
||||
status = "disabled";
|
||||
reg = <0x50>;
|
||||
|
||||
#address-cells = <1>;
|
||||
|
|
Loading…
Reference in New Issue