diff options
author | Kumar Gala <galak@freescale.com> | 2005-09-04 02:55:46 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 11:05:58 +0400 |
commit | 88adfe70c667c9e8fe5ec68eba78af566b539e24 (patch) | |
tree | d5aab7e39596b537bcc202ed9b20e4405eccc57e | |
parent | fa71f0e0f541e65280fdb9d60b142012f1951b7c (diff) | |
download | linux-88adfe70c667c9e8fe5ec68eba78af566b539e24.tar.xz |
[PATCH] ppc32: ppc_sys system on chip identification additions
Add the ability to identify an SOC by a name and id. There are cases in
which the integer identifier is not sufficient to specify a specific SOC.
In these cases we can use a string to further qualify the match.
Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>
Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/ppc/syslib/ppc_sys.c | 52 | ||||
-rw-r--r-- | include/asm-ppc/ppc_sys.h | 1 |
2 files changed, 52 insertions, 1 deletions
diff --git a/arch/ppc/syslib/ppc_sys.c b/arch/ppc/syslib/ppc_sys.c index 879202352560..52ba0c68078d 100644 --- a/arch/ppc/syslib/ppc_sys.c +++ b/arch/ppc/syslib/ppc_sys.c @@ -6,6 +6,7 @@ * Maintainer: Kumar Gala <kumar.gala@freescale.com> * * Copyright 2005 Freescale Semiconductor Inc. + * Copyright 2005 MontaVista, Inc. by Vitaly Bordug <vbordug@ru.mvista.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -35,10 +36,59 @@ void __init identify_ppc_sys_by_id(u32 id) void __init identify_ppc_sys_by_name(char *name) { - /* TODO */ + unsigned int i = 0; + while (ppc_sys_specs[i].ppc_sys_name[0]) + { + if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name)) + break; + i++; + } + cur_ppc_sys_spec = &ppc_sys_specs[i]; return; } +static int __init count_sys_specs(void) +{ + int i = 0; + while (ppc_sys_specs[i].ppc_sys_name[0]) + i++; + return i; +} + +static int __init find_chip_by_name_and_id(char *name, u32 id) +{ + int ret = -1; + unsigned int i = 0; + unsigned int j = 0; + unsigned int dups = 0; + + unsigned char matched[count_sys_specs()]; + + while (ppc_sys_specs[i].ppc_sys_name[0]) { + if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name)) + matched[j++] = i; + i++; + } + if (j != 0) { + for (i = 0; i < j; i++) { + if ((ppc_sys_specs[matched[i]].mask & id) == + ppc_sys_specs[matched[i]].value) { + ret = matched[i]; + dups++; + } + } + ret = (dups == 1) ? ret : (-1 * dups); + } + return ret; +} + +void __init identify_ppc_sys_by_name_and_id(char *name, u32 id) +{ + int i = find_chip_by_name_and_id(name, id); + BUG_ON(i < 0); + cur_ppc_sys_spec = &ppc_sys_specs[i]; +} + /* Update all memory resources by paddr, call before platform_device_register */ void __init ppc_sys_fixup_mem_resource(struct platform_device *pdev, phys_addr_t paddr) diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h index 01acf75735fe..048f7c8596ee 100644 --- a/include/asm-ppc/ppc_sys.h +++ b/include/asm-ppc/ppc_sys.h @@ -52,6 +52,7 @@ extern struct ppc_sys_spec *cur_ppc_sys_spec; /* determine which specific SOC we are */ extern void identify_ppc_sys_by_id(u32 id) __init; extern void identify_ppc_sys_by_name(char *name) __init; +extern void identify_ppc_sys_by_name_and_id(char *name, u32 id) __init; /* describes all devices that may exist in a given family of processors */ extern struct platform_device ppc_sys_platform_devices[]; |