Skip to contentSkip to conversation

Driver model, take 1

RFC PATCH New Marek Vasut 5 participants 15 messages Aug 21, 2012 – Sep 14, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Driver model, take 1

I'm submitting hereby the initial code for the driver model. This is a RFC patch, please give it a spin and scream :-)

The GPIO api should now use the new approach on the sandbox target. There's also "dm" command, that allows dumping the driver tree.

Marek Vasut (5):
dm: sandbox: Add necessary linker sections
dm: sandbox: Add necessary GD sections
dm: REMOVE: sandbox binding experiment
dm: gpio: Add draft GPIO core and convert sandbox to use it
dm: Add "dm dump" command

Pavel Herrmann (2):
dm: Add skeleton support for cores and drivers
dm: add dummy demo driver and core

 Makefile                               |    3 +
 arch/sandbox/cpu/u-boot.lds            |   35 ++-
 arch/sandbox/include/asm/global_data.h |    9 +
 arch/sandbox/lib/board.c               |   25 ++
 common/dm/Makefile                     |   40 ++++
 common/dm/core.c                       |  150 ++++++++++++
 common/dm/debug.c                      |  106 +++++++++
 common/dm/driver.c                     |  404 ++++++++++++++++++++++++++++++++
 common/dm/lists.c                      |  138 +++++++++++
 common/dm/root.c                       |  103 ++++++++
 common/dm/tree.c                       |  164 +++++++++++++
 common/dm/tree.h                       |   31 +++
 drivers/demo/Makefile                  |   42 ++++
 drivers/demo/core.c                    |  236 +++++++++++++++++++
 drivers/demo/demo.c                    |   67 ++++++
 drivers/gpio/Makefile                  |    2 +
 drivers/gpio/core.c                    |  365 +++++++++++++++++++++++++++++
 drivers/gpio/sandbox.c                 |   58 ++++-
 include/asm-generic/gpio.h             |   19 ++
 include/configs/sandbox.h              |    2 +
 include/dm/core_numbering.h            |   35 +++
 include/dm/debug.h                     |   33 +++
 include/dm/demo.h                      |   37 +++
 include/dm/manager.h                   |   57 +++++
 include/dm/options.h                   |   46 ++++
 include/dm/structures.h                |  154 ++++++++++++
 26 files changed, 2352 insertions(+), 9 deletions(-)
 create mode 100644 common/dm/Makefile
 create mode 100644 common/dm/core.c
 create mode 100644 common/dm/debug.c
 create mode 100644 common/dm/driver.c
 create mode 100644 common/dm/lists.c
 create mode 100644 common/dm/root.c
 create mode 100644 common/dm/tree.c
 create mode 100644 common/dm/tree.h
 create mode 100644 drivers/demo/Makefile
 create mode 100644 drivers/demo/core.c
 create mode 100644 drivers/demo/demo.c
 create mode 100644 drivers/gpio/core.c
 create mode 100644 include/dm/core_numbering.h
 create mode 100644 include/dm/debug.h
 create mode 100644 include/dm/demo.h
 create mode 100644 include/dm/manager.h
 create mode 100644 include/dm/options.h
 create mode 100644 include/dm/structures.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/7 dm: Add skeleton support for cores and drivers

From: Pavel Herrmann <[email protected]>

---
 Makefile                    |    2 +
 common/dm/Makefile          |   40 +++++
 common/dm/core.c            |  150 ++++++++++++++++
 common/dm/driver.c          |  404 +++++++++++++++++++++++++++++++++++++++++++
 common/dm/lists.c           |  138 +++++++++++++++
 common/dm/root.c            |  103 +++++++++++
 common/dm/tree.c            |  164 ++++++++++++++++++
 common/dm/tree.h            |   31 ++++
 include/dm/core_numbering.h |   33 ++++
 include/dm/manager.h        |   57 ++++++
 include/dm/options.h        |   46 +++++
 include/dm/structures.h     |  154 +++++++++++++++++
 12 files changed, 1322 insertions(+)
 create mode 100644 common/dm/Makefile
 create mode 100644 common/dm/core.c
 create mode 100644 common/dm/driver.c
 create mode 100644 common/dm/lists.c
 create mode 100644 common/dm/root.c
 create mode 100644 common/dm/tree.c
 create mode 100644 common/dm/tree.h
 create mode 100644 include/dm/core_numbering.h
 create mode 100644 include/dm/manager.h
 create mode 100644 include/dm/options.h
 create mode 100644 include/dm/structures.h
Makefile +2 -0
index 67c89ca..0e008b1 100644
@@ -301,6 +301,8 @@ LIBS-y += api/libapi.o
 LIBS-y += post/libpost.o
 LIBS-y += test/libtest.o
 
+LIBS-$(CONFIG_DM) += common/dm/libdm.o
+
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
 endif
common/dm/Makefile new file +40 -0
new file mode 100644
index 0000000..6510021
@@ -0,0 +1,40 @@
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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 program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	:= $(obj)libdm.o
+
+COBJS	:= core.o driver.o lists.o tree.o root.o
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(LIB)
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
common/dm/core.c new file +150 -0

150 lines not on this page · raw message

common/dm/driver.c new file +404 -0

404 lines not on this page · raw message

common/dm/lists.c new file +138 -0

138 lines not on this page · raw message

common/dm/root.c new file +103 -0

103 lines not on this page · raw message

common/dm/tree.c new file +164 -0

164 lines not on this page · raw message

common/dm/tree.h new file +31 -0
new file mode 100644
index 0000000..ed29b83
@@ -0,0 +1,31 @@
+/*
+ * (C) Copyright 2012
+ * Pavel Herrmann <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _COMMON_DM_TREE_H_
+#define _COMMON_DM_TREE_H_ 1
+
+/* we dont want this to be in public headers */
+int init_core_tree(void);
+
+#endif
+
include/dm/core_numbering.h new file +33 -0
new file mode 100644
index 0000000..75a023f
@@ -0,0 +1,33 @@
+/*
+ * (C) Copyright 2012
+ * Pavel Herrmann <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _DM_CORE_NUMBERING_H
+#define _DM_CORE_NUMBERING_H 1
+
+/* TODO: this could be compile-time generated */
+
+enum core_id {
+	CORE_INVALID = 0,
+};
+
+#endif
include/dm/manager.h new file +57 -0

57 lines not on this page · raw message

include/dm/options.h new file +46 -0

46 lines not on this page · raw message

include/dm/structures.h new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 1/7 dm: Add skeleton support for cores and drivers

Quoted 4 lines · Marek Vasut

From: Pavel Herrmann <[email protected]>

More of a commit message please. At least point to the design docs that are now in tree.

common/dm/tree.h line 25

Quoted 2 lines
common/dm/tree.h new file +2 -0
+#ifndef _COMMON_DM_TREE_H_
+#define _COMMON_DM_TREE_H_ 1

#ifndef __COMMON_DM_TREE_H
#define __COMMON_DM_TREE_H

etc, etc. You also pass in 'i' as a variable to one of the functions at least. Please make sure you use real variable names in functions.

Signature · 1 line
Tom
#3 lore raw

PATCH 2/7 dm: sandbox: Add necessary linker sections

In reply to Marek Vasut

Add linker sections necessary for driver model operation.

---
 arch/sandbox/cpu/u-boot.lds |   35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
arch/sandbox/cpu/u-boot.lds +32 -3
index 9960138..d83ee66 100644
@@ -24,9 +24,38 @@
 
 SECTIONS
 {
-	__u_boot_cmd_start = .;
-	_u_boot_cmd : { *(.u_boot_cmd) }
-	__u_boot_cmd_end = .;
+	.u_boot_cmd : {
+		__u_boot_cmd_start = .;
+		*(SORT(.u_boot_cmd.*))
+		__u_boot_cmd_end = .;
+	}
+
+	.u_boot_driver : {
+		__u_boot_driver_start = .;
+		__u_boot_driver_generic_start = .;
+		*(SORT(.u_boot_driver.generic.*))
+		__u_boot_driver_generic_end = .;
+
+		/*
+		 * PCI and USB drivers have special needs,
+		 * hence the separate lists
+		 */
+		__u_boot_driver_pci_start = .;
+		*(SORT(.u_boot_driver.pci.*))
+		__u_boot_driver_pci_end = .;
+
+		__u_boot_driver_usb_start = .;
+		*(SORT(.u_boot_driver.usb.*))
+		__u_boot_driver_usb_end = .;
+
+		__u_boot_driver_end = .;
+	}
+
+	.u_boot_core : {
+		__u_boot_core_start = .;
+		*(SORT(.u_boot_core.*))
+		__u_boot_core_end = .;
+	}
 
 	__u_boot_sandbox_option_start = .;
 	_u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 3/7 dm: sandbox: Add necessary GD sections

In reply to Marek Vasut

Add GD sections necessary for driver model operation.

---
 arch/sandbox/include/asm/global_data.h |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/sandbox/include/asm/global_data.h +9 -0
index 581fd2f..77c7508 100644
@@ -25,6 +25,9 @@
 
 #ifndef	__ASM_GBL_DATA_H
 #define __ASM_GBL_DATA_H
+
+#include <linux/list.h>
+
 /*
  * The following data structure is placed in some memory wich is
  * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
@@ -43,6 +46,12 @@ typedef	struct global_data {
 	unsigned long	fb_base;	/* base address of frame buffer */
 	u8		*ram_buf;	/* emulated RAM buffer */
 	phys_size_t	ram_size;	/* RAM size */
+
+#ifdef CONFIG_DM
+	struct instance	*dm_root;	/* Root instance for Driver Model */
+	struct list_head core_root;	/* Head of core tree */
+#endif
+
 	const void	*fdt_blob;	/* Our device tree, NULL if none */
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 4/7 dm: REMOVE: sandbox binding experiment

In reply to Marek Vasut
---
 arch/sandbox/lib/board.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/sandbox/lib/board.c +19 -0
index c173bf9..b6b3768 100644
@@ -47,6 +47,8 @@
 
 #include <os.h>
 
+#include <dm/manager.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static gd_t gd_mem;
@@ -232,6 +234,23 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	mem_malloc_init((ulong)gd->ram_buf + gd->ram_size - TOTAL_MALLOC_LEN,
 			TOTAL_MALLOC_LEN);
 
+	dm_init();
+	static const struct driver_info info = {
+		.name = "demo_drv",
+		.platform_data = NULL
+	};
+	struct instance *root = get_root_instance();
+	struct instance *demo1, *demo2, *demo3;
+	demo1 =	driver_bind(root, &info);
+		driver_bind(root, &info);
+				driver_bind(demo1, &info);
+				driver_bind(demo1, &info);
+			demo2 = driver_bind(demo1, &info);
+				demo3 = driver_bind(demo2, &info);
+	driver_bind(demo2, &info);
+
+	demo_hello(demo2);
+
 	/* initialize environment */
 	env_relocate();
 
Signature · 1 line
1.7.10.4
#6 lore raw

PATCH 5/7 dm: gpio: Add draft GPIO core and convert sandbox to use it

In reply to Marek Vasut
---
 arch/sandbox/lib/board.c    |    6 +
 drivers/gpio/Makefile       |    2 +
 drivers/gpio/core.c         |  365 +++++++++++++++++++++++++++++++++++++++++++
 drivers/gpio/sandbox.c      |   58 ++++++-
 include/asm-generic/gpio.h  |   19 +++
 include/configs/sandbox.h   |    2 +
 include/dm/core_numbering.h |    1 +
 7 files changed, 447 insertions(+), 6 deletions(-)
 create mode 100644 drivers/gpio/core.c
arch/sandbox/lib/board.c +6 -0
index b6b3768..c79cc62 100644
@@ -239,6 +239,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
 		.name = "demo_drv",
 		.platform_data = NULL
 	};
+	static const struct driver_info gs_info = {
+		.name = "gpio_sandbox",
+		.platform_data = NULL
+	};
+
 	struct instance *root = get_root_instance();
 	struct instance *demo1, *demo2, *demo3;
 	demo1 =	driver_bind(root, &info);
@@ -248,6 +253,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
 			demo2 = driver_bind(demo1, &info);
 				demo3 = driver_bind(demo2, &info);
 	driver_bind(demo2, &info);
+	driver_bind(root, &gs_info);
 
 	demo_hello(demo2);
 
drivers/gpio/Makefile +2 -0
index 4b99b85..1d3aa02 100644
@@ -25,6 +25,8 @@ include $(TOPDIR)/config.mk
 
 LIB 	:= $(obj)libgpio.o
 
+COBJS-$(CONFIG_DM)		+= core.o
+
 COBJS-$(CONFIG_AT91_GPIO)	+= at91_gpio.o
 COBJS-$(CONFIG_KIRKWOOD_GPIO)	+= kw_gpio.o
 COBJS-$(CONFIG_MARVELL_GPIO)	+= mvgpio.o
drivers/gpio/core.c new file +365 -0

365 lines not on this page · raw message

drivers/gpio/sandbox.c +52 -6

103 lines not on this page · raw message

include/asm-generic/gpio.h +19 -0
index c19e16c..fac73ae 100644
@@ -94,4 +94,23 @@ int gpio_get_value(unsigned gpio);
  */
 int gpio_set_value(unsigned gpio, int value);
 
+/**
+ * Driver model GPIO operations, refer to functions above for description.
+ * These function copy the old API.
+ *
+ * This is trying to be close to Linux GPIO API. Once the U-Boot uses the
+ * new DM GPIO API, this should be really easy to flip over to the Linux
+ * GPIO API-alike interface.
+ */
+struct dm_gpio_ops {
+	int	base;
+	u16	ngpio;
+	int	(*gpio_request)(unsigned gpio, const char *label);
+	int	(*gpio_free)(unsigned gpio);
+	int	(*gpio_direction_input)(unsigned gpio);
+	int	(*gpio_direction_output)(unsigned gpio, int value);
+	int	(*gpio_get_value)(unsigned gpio);
+	int	(*gpio_set_value)(unsigned gpio, int value);
+};
+
 #endif	/* _ASM_GENERIC_GPIO_H_ */
include/configs/sandbox.h +2 -0
index 9c431bf..0220386 100644
@@ -22,6 +22,8 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+#define CONFIG_DM
+
 #define CONFIG_NR_DRAM_BANKS	1
 #define CONFIG_DRAM_SIZE	(128 << 20)
 
include/dm/core_numbering.h +1 -0
index 75a023f..b543b48 100644
@@ -28,6 +28,7 @@
 
 enum core_id {
 	CORE_INVALID = 0,
+	CORE_GPIO,
 };
 
 #endif
Signature · 1 line
1.7.10.4
#7 lore raw

PATCH 5/7 dm: gpio: Add draft GPIO core and convert sandbox to use it

Hi

On Tuesday 21 August 2012 18:00:51 Marek Vasut wrote:
...snip...

Quoted 7 lines
drivers/gpio/core.c new file +7 -0
+/**
+ * gpio_request() - [COMPAT] Request GPIO
+ * gpio:	GPIO number
+ * label:	Name for the requested GPIO
+ *
+ * This function implements the API that's compatible with current
+ * GPIO API used in U-Boot. The request is forwarded to particular

drivers/gpio/core.c line 77

Quoted 10 lines
drivers/gpio/core.c new file +10 -0
+ * GPIO driver. Returns 0 on success, negative value on error.
+ */
+int gpio_request(unsigned gpio, const char *label)
+{
+	struct gpio_core_entry *e = gpio_to_entry(gpio);
+	if (!e)
+		return -EINVAL;
+
+	return e->ops->gpio_request(gpio, label);
+}

...snip...

Your core should have a driver API (as described in the core document), which should be in form of gpio_$fname for each $fname in the gpio_ops. on top of those you can have the command API, which accesses the gpio pins in a linear fashion (like what you have now)

the reason for this is if you have a device on gpio (say some LEDs), which knows (from platform data) that pins 3-6 of the parent device are connected to this device. in your API, this has no way of working - even if you put global pin numbering in the platform data, this would stop working if you had a PnP GPIO controllers (say USB).

regards
Pavel Herrmann

#8 lore raw

PATCH 6/7 dm: add dummy demo driver and core

In reply to Marek Vasut

From: Pavel Herrmann <[email protected]>

---
 Makefile                    |    1 +
 drivers/demo/Makefile       |   42 ++++++++
 drivers/demo/core.c         |  236 +++++++++++++++++++++++++++++++++++++++++++
 drivers/demo/demo.c         |   67 ++++++++++++
 include/dm/core_numbering.h |    1 +
 include/dm/demo.h           |   37 +++++++
 6 files changed, 384 insertions(+)
 create mode 100644 drivers/demo/Makefile
 create mode 100644 drivers/demo/core.c
 create mode 100644 drivers/demo/demo.c
 create mode 100644 include/dm/demo.h
Makefile +1 -0
index 0e008b1..ba74696 100644
@@ -302,6 +302,7 @@ LIBS-y += post/libpost.o
 LIBS-y += test/libtest.o
 
 LIBS-$(CONFIG_DM) += common/dm/libdm.o
+LIBS-$(CONFIG_DM) += drivers/demo/libdemo.o
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
drivers/demo/Makefile new file +42 -0

42 lines not on this page · raw message

drivers/demo/core.c new file +236 -0

236 lines not on this page · raw message

drivers/demo/demo.c new file +67 -0

67 lines not on this page · raw message

include/dm/core_numbering.h +1 -0
index b543b48..8dd6067 100644
@@ -29,6 +29,7 @@
 enum core_id {
 	CORE_INVALID = 0,
 	CORE_GPIO,
+	CORE_DEMO,
 };
 
 #endif
include/dm/demo.h new file +37 -0
new file mode 100644
index 0000000..9fca7b8
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2012
+ * Pavel Herrmann <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _DM_DEMO_H_
+#define _DM_DEMO_H_ 1
+
+#include <dm/options.h>
+#include <dm/structures.h>
+
+struct demo_ops {
+	int (*hello)(struct instance *i);
+};
+
+int demo_hello(struct instance *i);
+int demo_list(void);
+
+#endif
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH 7/7 dm: Add "dm dump" command

In reply to Marek Vasut

Dumps the content of system tree

---
 common/dm/Makefile |    2 +-
 common/dm/debug.c  |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/debug.h |   33 ++++++++++++++++
 3 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 common/dm/debug.c
 create mode 100644 include/dm/debug.h
common/dm/Makefile +1 -1
index 6510021..2096c6b 100644
@@ -21,7 +21,7 @@ include $(TOPDIR)/config.mk
 
 LIB	:= $(obj)libdm.o
 
-COBJS	:= core.o driver.o lists.o tree.o root.o
+COBJS	:= core.o debug.o driver.o lists.o tree.o root.o
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
 
common/dm/debug.c new file +106 -0

106 lines not on this page · raw message

include/dm/debug.h new file +33 -0
new file mode 100644
index 0000000..df86113
@@ -0,0 +1,33 @@
+/*
+ * (C) Copyright 2012
+ * Pavel Herrmann <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#ifndef _DM_DEBUG_H_
+#define _DM_DEBUG_H_ 1
+
+#include <dm/structures.h>
+
+int dm_dump_all(void);
+int dm_dump(struct instance *i);
+
+#endif
Signature · 1 line
1.7.10.4
#10 lore raw

cover Driver model, take 1

In reply to Marek Vasut

Dear Marek Vasut,

Quoted 5 lines

I'm submitting hereby the initial code for the driver model. This is a RFC patch, please give it a spin and scream :-)

The GPIO api should now use the new approach on the sandbox target. There's also "dm" command, that allows dumping the driver tree.

Expanding CC ... guys, please start ripping us to shreds :-)

Quoted 50 lines

Marek Vasut (5):
dm: sandbox: Add necessary linker sections
dm: sandbox: Add necessary GD sections
dm: REMOVE: sandbox binding experiment
dm: gpio: Add draft GPIO core and convert sandbox to use it
dm: Add "dm dump" command

Pavel Herrmann (2):
dm: Add skeleton support for cores and drivers
dm: add dummy demo driver and core

 Makefile                               |    3 +
 arch/sandbox/cpu/u-boot.lds            |   35 ++-
 arch/sandbox/include/asm/global_data.h |    9 +
 arch/sandbox/lib/board.c               |   25 ++
 common/dm/Makefile                     |   40 ++++
 common/dm/core.c                       |  150 ++++++++++++
 common/dm/debug.c                      |  106 +++++++++
 common/dm/driver.c                     |  404
++++++++++++++++++++++++++++++++ common/dm/lists.c                      | 
138 +++++++++++
 common/dm/root.c                       |  103 ++++++++
 common/dm/tree.c                       |  164 +++++++++++++
 common/dm/tree.h                       |   31 +++
 drivers/demo/Makefile                  |   42 ++++
 drivers/demo/core.c                    |  236 +++++++++++++++++++
 drivers/demo/demo.c                    |   67 ++++++
 drivers/gpio/Makefile                  |    2 +
 drivers/gpio/core.c                    |  365
+++++++++++++++++++++++++++++ drivers/gpio/sandbox.c                 |  
58 ++++-
 include/asm-generic/gpio.h             |   19 ++
 include/configs/sandbox.h              |    2 +
 include/dm/core_numbering.h            |   35 +++
 include/dm/debug.h                     |   33 +++
 include/dm/demo.h                      |   37 +++
 include/dm/manager.h                   |   57 +++++
 include/dm/options.h                   |   46 ++++
 include/dm/structures.h                |  154 ++++++++++++
 26 files changed, 2352 insertions(+), 9 deletions(-)
 create mode 100644 common/dm/Makefile
 create mode 100644 common/dm/core.c
 create mode 100644 common/dm/debug.c
 create mode 100644 common/dm/driver.c
 create mode 100644 common/dm/lists.c
 create mode 100644 common/dm/root.c
 create mode 100644 common/dm/tree.c
 create mode 100644 common/dm/tree.h
 create mode 100644 drivers/demo/Makefile
 create mode 100644 drivers/demo/core.c
Quoted 8 lines
 create mode 100644 drivers/demo/demo.c
 create mode 100644 drivers/gpio/core.c
 create mode 100644 include/dm/core_numbering.h
 create mode 100644 include/dm/debug.h
 create mode 100644 include/dm/demo.h
 create mode 100644 include/dm/manager.h
 create mode 100644 include/dm/options.h
 create mode 100644 include/dm/structures.h

Best regards,
Marek Vasut

#11 lore raw

cover Driver model, take 1

Hi DM Team,

Quoted 4 lines · Marek Vasut

Dear Marek Vasut,

Quoted 2 lines

I'm submitting hereby the initial code for the driver model. This is a RFC patch, please give it a spin and scream :-)

I haven't had a really deep play with this yet, but a couple of things do come to mind...

I've been thinking of a scenario of a simple LED module with both a Serial (RS-232) and USB interface (or maybe an I2C connection). I can think of two options:
a) Write a separate driver for each interface
b) Write a single driver that can handle all supported interfaces

If going with option b, the LED driver is going to need to know what type of interface it is attached on in order for it to issue the correct commands to the upstream driver. I can't see a way in the current model to determine the type of the upstream driver

Another thought is naming if instances (this was in particular relation to stdio) - If you have two UARTS onboard, it would make sense to name them in U-Boot according to how they are named on the board (UART1 / UART2, Port 1 / Port 2, Console / Diagnostics, etc.) and when directing stdio, using the name of the port.

Regards,

Graeme

#12 lore raw

cover Driver model, take 1

Dear Graeme Russ,

Quoted 8 lines

Hi DM Team,

Quoted 4 lines · Marek Vasut

Dear Marek Vasut,

Quoted 2 lines

I'm submitting hereby the initial code for the driver model. This is a RFC patch, please give it a spin and scream :-)

Quoted 8 lines

I haven't had a really deep play with this yet, but a couple of things do come to mind...

I've been thinking of a scenario of a simple LED module with both a Serial (RS-232) and USB interface (or maybe an I2C connection). I can think of two options:
a) Write a separate driver for each interface
b) Write a single driver that can handle all supported interfaces

c) Write a muxing driver, basically you'd have two drivers -- "led-module-uart" and "led-module-usb" -- which would share common logic. The upcall towards the bus can also be pretty much covered by some local wrappers.

But I'm fairy sleepy now, had a hacknight tonight, so ...

Quoted 4 lines

If going with option b, the LED driver is going to need to know what type of interface it is attached on in order for it to issue the correct commands to the upstream driver. I can't see a way in the current model to determine the type of the upstream driver

You can have a shared part and separate part of the probe() function. Also, the probe function knows the name of the driver, it can decide based on that.

Quoted 5 lines

Another thought is naming if instances (this was in particular relation to stdio) - If you have two UARTS onboard, it would make sense to name them in U-Boot according to how they are named on the board (UART1 / UART2, Port 1 / Port 2, Console / Diagnostics, etc.) and when directing stdio, using the name of the port.

Basically aliases ... I'd postpone this. But it's good it's here, green on white with monospace font. I'll mark this as important.

Quoted 3 lines

Regards,

Graeme

Best regards,
Marek Vasut

#13 lore raw

cover Driver model, take 1

Hi Marek,

Quoted 19 lines · Marek Vasut

Dear Graeme Russ,

Quoted 8 lines

Hi DM Team,

Quoted 4 lines · Marek Vasut

Dear Marek Vasut,

Quoted 2 lines

I'm submitting hereby the initial code for the driver model. This is a RFC patch, please give it a spin and scream :-)

Quoted 8 lines

I haven't had a really deep play with this yet, but a couple of things do come to mind...

I've been thinking of a scenario of a simple LED module with both a Serial (RS-232) and USB interface (or maybe an I2C connection). I can think of two options:
a) Write a separate driver for each interface
b) Write a single driver that can handle all supported interfaces

Quoted 3 lines

c) Write a muxing driver, basically you'd have two drivers -- "led-module-uart" and "led-module-usb" -- which would share common logic. The upcall towards the bus can also be pretty much covered by some local wrappers.

Adds a little overhead, but sounds sound. But also, you should give the downstream driver the ability to check that it is being attached to a valid upstream driver - Attaching a USB ethernet dongle to PCI isn't going to cut it. This will be critical if we allow modularisation of the driver sub-system (i.e. dynamically load a driver module and bind it from the command line)

Regards,

Graeme

#14 lore raw

cover Driver model, take 1

In reply to Marek Vasut
Quoted 13 lines · Marek Vasut

I'm submitting hereby the initial code for the driver model. This is a RFC patch, please give it a spin and scream :-)

The GPIO api should now use the new approach on the sandbox target. There's also "dm" command, that allows dumping the driver tree.

Marek Vasut (5):
dm: sandbox: Add necessary linker sections
dm: sandbox: Add necessary GD sections
dm: REMOVE: sandbox binding experiment
dm: gpio: Add draft GPIO core and convert sandbox to use it
dm: Add "dm dump" command

Quoted 3 lines

Pavel Herrmann (2):
dm: Add skeleton support for cores and drivers
dm: add dummy demo driver and core

So, the design documents are in. And you've got a "simple" example. How have you progressed on migrating some of the more complex drivers that will really put DM through its paces, so to speak? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120914/29869f2c/attachment.pgp>