linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] identify_ppc_sys_by_name_and_id function implementation
@ 2005-08-10 17:15 Vitaly Bordug
  2005-08-10 17:46 ` [PATCH] identify_ppc_sys_by_name_and_id function implementation (braces fixed) Vitaly Bordug
  0 siblings, 1 reply; 12+ messages in thread
From: Vitaly Bordug @ 2005-08-10 17:15 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-embedded list

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Kumar,

This is preliminary version of the identify_ppc_sys_by_name_and_id(...).
Tested with pq2 devices/sys for 8272ADS and fs_enet. This will BUG_ON if 
nothing found or duplicates exist (guess if we call identify_ppc_sys.. 
hit is expected).

Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>

-- 
Sincerely,
Vitaly

[-- Attachment #2: ppc_sys_add.patch --]
[-- Type: text/x-patch, Size: 2183 bytes --]

diff --git a/arch/ppc/syslib/ppc_sys.c b/arch/ppc/syslib/ppc_sys.c
--- 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
@@ -33,10 +34,48 @@ void __init identify_ppc_sys_by_id(u32 i
 	return;
 }
 
-void __init identify_ppc_sys_by_name(char *name)
+static int __init count_sys_specs(void)
 {
-	/* TODO */
-	return;
+	int i = 0;
+	while (strcmp(ppc_sys_specs[i].ppc_sys_name,""))
+		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 int matched[count_sys_specs()];
+	
+	while (strcmp(ppc_sys_specs[i].ppc_sys_name,"")) {
+		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 */
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -51,7 +51,7 @@ extern struct ppc_sys_spec *cur_ppc_sys_
 
 /* 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[];

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-08-16 13:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-10 17:15 [RFC][PATCH] identify_ppc_sys_by_name_and_id function implementation Vitaly Bordug
2005-08-10 17:46 ` [PATCH] identify_ppc_sys_by_name_and_id function implementation (braces fixed) Vitaly Bordug
2005-08-10 18:01   ` [PATCH] identify_ppc_sys_by_name_and_id function implementation final Vitaly Bordug
2005-08-10 19:16     ` Kumar Gala
2005-08-11  5:30       ` Marcelo Tosatti
2005-08-11 15:25         ` Vitaly Bordug
2005-08-11 22:45           ` Marcelo Tosatti
2005-08-12 15:37             ` Vitaly Bordug
2005-08-12 16:18               ` Kumar Gala
2005-08-12 16:30                 ` Vitaly Bordug
2005-08-12 19:48                   ` Kumar Gala
2005-08-16 13:36                     ` Vitaly Bordug

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).