diff options
author | Kumar Gala <galak@freescale.com> | 2005-09-03 18:55:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 03:05:58 -0400 |
commit | 88adfe70c667c9e8fe5ec68eba78af566b539e24 (patch) | |
tree | d5aab7e39596b537bcc202ed9b20e4405eccc57e /arch/ppc | |
parent | fa71f0e0f541e65280fdb9d60b142012f1951b7c (diff) |
[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>
Diffstat (limited to 'arch/ppc')
-rw-r--r-- | arch/ppc/syslib/ppc_sys.c | 52 |
1 files changed, 51 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 @@ | |||
6 | * Maintainer: Kumar Gala <kumar.gala@freescale.com> | 6 | * Maintainer: Kumar Gala <kumar.gala@freescale.com> |
7 | * | 7 | * |
8 | * Copyright 2005 Freescale Semiconductor Inc. | 8 | * Copyright 2005 Freescale Semiconductor Inc. |
9 | * Copyright 2005 MontaVista, Inc. by Vitaly Bordug <vbordug@ru.mvista.com> | ||
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify it | 11 | * This program is free software; you can redistribute it and/or modify it |
11 | * under the terms of the GNU General Public License as published by the | 12 | * 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) | |||
35 | 36 | ||
36 | void __init identify_ppc_sys_by_name(char *name) | 37 | void __init identify_ppc_sys_by_name(char *name) |
37 | { | 38 | { |
38 | /* TODO */ | 39 | unsigned int i = 0; |
40 | while (ppc_sys_specs[i].ppc_sys_name[0]) | ||
41 | { | ||
42 | if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name)) | ||
43 | break; | ||
44 | i++; | ||
45 | } | ||
46 | cur_ppc_sys_spec = &ppc_sys_specs[i]; | ||
39 | return; | 47 | return; |
40 | } | 48 | } |
41 | 49 | ||
50 | static int __init count_sys_specs(void) | ||
51 | { | ||
52 | int i = 0; | ||
53 | while (ppc_sys_specs[i].ppc_sys_name[0]) | ||
54 | i++; | ||
55 | return i; | ||
56 | } | ||
57 | |||
58 | static int __init find_chip_by_name_and_id(char *name, u32 id) | ||
59 | { | ||
60 | int ret = -1; | ||
61 | unsigned int i = 0; | ||
62 | unsigned int j = 0; | ||
63 | unsigned int dups = 0; | ||
64 | |||
65 | unsigned char matched[count_sys_specs()]; | ||
66 | |||
67 | while (ppc_sys_specs[i].ppc_sys_name[0]) { | ||
68 | if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name)) | ||
69 | matched[j++] = i; | ||
70 | i++; | ||
71 | } | ||
72 | if (j != 0) { | ||
73 | for (i = 0; i < j; i++) { | ||
74 | if ((ppc_sys_specs[matched[i]].mask & id) == | ||
75 | ppc_sys_specs[matched[i]].value) { | ||
76 | ret = matched[i]; | ||
77 | dups++; | ||
78 | } | ||
79 | } | ||
80 | ret = (dups == 1) ? ret : (-1 * dups); | ||
81 | } | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | void __init identify_ppc_sys_by_name_and_id(char *name, u32 id) | ||
86 | { | ||
87 | int i = find_chip_by_name_and_id(name, id); | ||
88 | BUG_ON(i < 0); | ||
89 | cur_ppc_sys_spec = &ppc_sys_specs[i]; | ||
90 | } | ||
91 | |||
42 | /* Update all memory resources by paddr, call before platform_device_register */ | 92 | /* Update all memory resources by paddr, call before platform_device_register */ |
43 | void __init | 93 | void __init |
44 | ppc_sys_fixup_mem_resource(struct platform_device *pdev, phys_addr_t paddr) | 94 | ppc_sys_fixup_mem_resource(struct platform_device *pdev, phys_addr_t paddr) |