From 76c1ce7870fd9b05431da1bbd47fdafcc029a25b Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:19:07 +1000 Subject: Split out common parts of prom.h This creates linux/of.h and includes asm/prom.h from it. We also include linux/of.h from asm/prom.h while we transition. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/prom.h | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index 9ea105ebe2f..d67af08abb4 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -2,7 +2,6 @@ #define _SPARC_PROM_H #ifdef __KERNEL__ - /* * Definitions for talking to the Open Firmware PROM on * Power Macintosh computers. @@ -17,7 +16,6 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ - #include #include #include @@ -55,53 +53,21 @@ struct device_node { unsigned int unique_id; }; -/* flag descriptions */ -#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ - #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) -#define OF_BAD_ADDR ((u64)-1) - -static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) -{ - dn->pde = de; -} - -extern struct device_node *of_find_node_by_name(struct device_node *from, - const char *name); -#define for_each_node_by_name(dn, name) \ - for (dn = of_find_node_by_name(NULL, name); dn; \ - dn = of_find_node_by_name(dn, name)) -extern struct device_node *of_find_node_by_type(struct device_node *from, - const char *type); -#define for_each_node_by_type(dn, type) \ - for (dn = of_find_node_by_type(NULL, type); dn; \ - dn = of_find_node_by_type(dn, type)) -extern struct device_node *of_find_compatible_node(struct device_node *from, - const char *type, const char *compat); -extern struct device_node *of_find_node_by_path(const char *path); -extern struct device_node *of_find_node_by_phandle(phandle handle); -extern struct device_node *of_get_parent(const struct device_node *node); -extern struct device_node *of_get_next_child(const struct device_node *node, - struct device_node *prev); -extern struct property *of_find_property(const struct device_node *np, - const char *name, - int *lenp); -extern int of_device_is_compatible(const struct device_node *device, - const char *); -extern const void *of_get_property(const struct device_node *node, - const char *name, - int *lenp); -#define get_property(node,name,lenp) of_get_property(node,name,lenp) extern int of_set_property(struct device_node *node, const char *name, void *val, int len); extern int of_getintprop_default(struct device_node *np, const char *name, int def); -extern int of_n_addr_cells(struct device_node *np); -extern int of_n_size_cells(struct device_node *np); extern void prom_build_devicetree(void); +/* + * NB: This is here while we transition from using asm/prom.h + * to linux/of.h + */ +#include + #endif /* __KERNEL__ */ #endif /* _SPARC_PROM_H */ -- cgit v1.2.3 From 97e873e5c8ad8711ce4cca080cff4eb5d21b3aeb Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:26:07 +1000 Subject: Start split out of common open firmware code This creates drivers/of/base.c (depending on CONFIG_OF) and puts the first trivially common bits from the prom.c files into it. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/prom.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index d67af08abb4..a8a121f6332 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -20,6 +20,9 @@ #include #include +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 + typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From 0081cbc3731de8ad4744ba433af51f17bf27eb9c Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:29:19 +1000 Subject: Consolidate of_device_is_compatible The only difference here is that Sparc uses strncmp to match compatibility names while PowerPC uses strncasecmp. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/prom.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index a8a121f6332..c755c69404f 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -23,6 +23,8 @@ #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) + typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From 581b605a83ec241a2aff8ef780e08b9414c8dfd8 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 24 Apr 2007 16:46:53 +1000 Subject: Consolidate of_find_property The only change here is that a readlock is taken while the property list is being traversed on Sparc where it was not taken previously. Also, Sparc uses strcasecmp to compare property names while PowerPC uses strcmp. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/prom.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index c755c69404f..57f86c84293 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -24,6 +24,7 @@ #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) +#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From e679c5f445fe142940e0962de9c5c82f10d9357c Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 24 Apr 2007 17:16:16 +1000 Subject: Consolidate of_get_parent This requires creating dummy of_node_{get,put} routines for sparc and sparc64. It also adds a read_lock around the parent accesses. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/prom.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index 57f86c84293..c7d54958a90 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -69,6 +69,15 @@ extern int of_getintprop_default(struct device_node *np, extern void prom_build_devicetree(void); +/* Dummy ref counting routines - to be implemented later */ +static inline struct device_node *of_node_get(struct device_node *node) +{ + return node; +} +static inline void of_node_put(struct device_node *node) +{ +} + /* * NB: This is here while we transition from using asm/prom.h * to linux/of.h -- cgit v1.2.3 From 1ef4d4242d9c494c49ae1ae66dc938fce0272816 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 24 Apr 2007 17:57:33 +1000 Subject: Consolidate of_find_node_by routines This consolidates the routines of_find_node_by_path, of_find_node_by_name, of_find_node_by_type and of_find_compatible_device. Again, the comparison of strings are done differently by Sparc and PowerPC and also these add read_locks around the iterations. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/prom.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index c7d54958a90..db9feb75bd8 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -25,6 +25,7 @@ #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) +#define of_node_cmp(s1, s2) strcmp((s1), (s2)) typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From f898f8dbcec4848cddb8c5be2d0affd75779ebe2 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:49:51 +1000 Subject: Begin consolidation of of_device.h This just moves the common stuff from the arch of_device.h files to linux/of_device.h. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/of_device.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index 7cb00c1b09c..b625261c9ec 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h @@ -3,9 +3,9 @@ #ifdef __KERNEL__ #include +#include #include #include -#include extern struct bus_type ebus_bus_type; extern struct bus_type sbus_bus_type; @@ -30,19 +30,12 @@ struct of_device int portid; int clock_freq; }; -#define to_of_device(d) container_of(d, struct of_device, dev) extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); extern struct of_device *of_find_device_by_node(struct device_node *); -extern const struct of_device_id *of_match_device( - const struct of_device_id *matches, const struct of_device *dev); - -extern struct of_device *of_dev_get(struct of_device *dev); -extern void of_dev_put(struct of_device *dev); - /* * An of_platform_driver driver is attached to a basic of_device on * the ISA, EBUS, and SBUS busses on sparc64. @@ -67,13 +60,13 @@ struct of_platform_driver extern int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus); extern void of_unregister_driver(struct of_platform_driver *drv); -extern int of_device_register(struct of_device *ofdev); -extern void of_device_unregister(struct of_device *ofdev); extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id, struct device *parent, struct bus_type *bus); -extern void of_release_dev(struct device *dev); + +/* This is just here during the transition */ +#include #endif /* __KERNEL__ */ #endif /* _ASM_SPARC_OF_DEVICE_H */ -- cgit v1.2.3 From 37b7754aab9a6ad7ecbba45c87f8d8a1f81b3bcc Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 30 Apr 2007 17:43:56 +1000 Subject: [SPARC/64] Rename some functions like PowerPC This is to make the of merge easier. Also rename of_bus_type. Signed-off-by: Stephen Rothwell Acked-by: David S. Miller --- include/asm-sparc/of_device.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index b625261c9ec..fd8e9574313 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h @@ -9,7 +9,8 @@ extern struct bus_type ebus_bus_type; extern struct bus_type sbus_bus_type; -extern struct bus_type of_bus_type; +extern struct bus_type of_platform_bus_type; +#define of_bus_type of_platform_bus_type /* for compatibility */ /* * The of_device is a kind of "base class" that is a superset of -- cgit v1.2.3 From b41912ca345e6de8ec8469d57cd585881271e2b9 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:12:57 +1000 Subject: Create linux/of_platorm.h Move common stuff from asm-powerpc/of_platform.h to here and move the common bits from asm-sparc*/of_device.h here as well. Create asm-sparc*/of_platform.h and move appropriate parts of of_device.h to them. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/of_device.h | 39 ++------------------------------------- include/asm-sparc/of_platform.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 37 deletions(-) create mode 100644 include/asm-sparc/of_platform.h (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index fd8e9574313..e5f5aedc229 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h @@ -7,11 +7,6 @@ #include #include -extern struct bus_type ebus_bus_type; -extern struct bus_type sbus_bus_type; -extern struct bus_type of_platform_bus_type; -#define of_bus_type of_platform_bus_type /* for compatibility */ - /* * The of_device is a kind of "base class" that is a superset of * struct device for use by devices attached to an OF node and @@ -35,39 +30,9 @@ struct of_device extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); -extern struct of_device *of_find_device_by_node(struct device_node *); - -/* - * An of_platform_driver driver is attached to a basic of_device on - * the ISA, EBUS, and SBUS busses on sparc64. - */ -struct of_platform_driver -{ - char *name; - struct of_device_id *match_table; - struct module *owner; - - int (*probe)(struct of_device* dev, const struct of_device_id *match); - int (*remove)(struct of_device* dev); - - int (*suspend)(struct of_device* dev, pm_message_t state); - int (*resume)(struct of_device* dev); - int (*shutdown)(struct of_device* dev); - - struct device_driver driver; -}; -#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver) - -extern int of_register_driver(struct of_platform_driver *drv, - struct bus_type *bus); -extern void of_unregister_driver(struct of_platform_driver *drv); -extern struct of_device *of_platform_device_create(struct device_node *np, - const char *bus_id, - struct device *parent, - struct bus_type *bus); - -/* This is just here during the transition */ +/* These are just here during the transition */ #include +#include #endif /* __KERNEL__ */ #endif /* _ASM_SPARC_OF_DEVICE_H */ diff --git a/include/asm-sparc/of_platform.h b/include/asm-sparc/of_platform.h new file mode 100644 index 00000000000..64a230064ef --- /dev/null +++ b/include/asm-sparc/of_platform.h @@ -0,0 +1,32 @@ +#ifndef _ASM_SPARC_OF_PLATFORM_H +#define _ASM_SPARC_OF_PLATFORM_H +/* + * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. + * + * Modified for Sparc by merging parts of asm-sparc/of_device.h + * by Stephen Rothwell + * + * 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 Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +/* This is just here during the transition */ +#include + +extern struct bus_type ebus_bus_type; +extern struct bus_type sbus_bus_type; +extern struct bus_type of_platform_bus_type; +#define of_bus_type of_platform_bus_type /* for compatibility */ + +extern int of_register_driver(struct of_platform_driver *drv, + struct bus_type *bus); +extern void of_unregister_driver(struct of_platform_driver *drv); +extern struct of_device *of_platform_device_create(struct device_node *np, + const char *bus_id, + struct device *parent, + struct bus_type *bus); + +#endif /* _ASM_SPARC_OF_PLATFORM_H */ -- cgit v1.2.3