#include #include #include #include struct _avm_hw_config *avm_current_hw_config = NULL; EXPORT_SYMBOL(avm_current_hw_config); struct _avm_hw_config *avm_get_hw_config_table(void) { static struct _avm_hw_config *current_config_table = NULL; unsigned int hwrev, hwsubrev, i; char *s; if (current_config_table) return current_config_table; s = prom_getenv("HWRevision"); hwrev = s ? simple_strtoul(s, NULL, 10) : 0; s = prom_getenv("HWSubRevision"); hwsubrev = s ? simple_strtoul(s, NULL, 10) : 1; if (unlikely(hwrev == 0)) { pr_alert("avm-hw-config: no HWRevision detected in environment variables\n"); BUG_ON(1); return NULL; } for (i = 0; avm_hw_config_tables[i].hwrev; i++) { if (avm_hw_config_tables[i].hwrev != hwrev) continue; if ((avm_hw_config_tables[i].hwsubrev == 0) || (avm_hw_config_tables[i].hwsubrev == hwsubrev)) { current_config_table = avm_hw_config_tables[i].table; return current_config_table; } } pr_alert("avm-hw-config: No hardware configuration found for HWRevision %d\n", hwrev); BUG_ON(1); return NULL; } EXPORT_SYMBOL(avm_get_hw_config_table);