diff options
Diffstat (limited to 'arch/ppc/syslib')
-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) |