[U-Boot] [PATCH 5/8] fdt_support, usb: Move fdt_fixup_dr_usb routine to drivers/usb/otg

Anton Vorontsov avorontsov at ru.mvista.com
Wed Apr 29 23:50:05 CEST 2009


In subsequent patches we'll use FSL-specific functions in
fdt_fixup_dr_usb(), so let's move the routine to a more appropriate
place.

So far fsl_dr_usb.c isn't actually an USB driver, but eventually it
will turn into one, let's hope. ;-)

Also rename CONFIG_HAS_FSL_DR_USB to CONFIG_USB_FSL_DR to be
consistent with other USB drivers.

Signed-off-by: Anton Vorontsov <avorontsov at ru.mvista.com>
---
 Makefile                                  |    1 +
 board/freescale/mpc8315erdb/mpc8315erdb.c |    1 +
 board/freescale/mpc837xemds/mpc837xemds.c |    1 +
 board/freescale/mpc837xerdb/mpc837xerdb.c |    1 +
 common/fdt_support.c                      |   41 ----------------------
 drivers/usb/otg/Makefile                  |   46 +++++++++++++++++++++++++
 drivers/usb/otg/fsl_dr_usb.c              |   52 +++++++++++++++++++++++++++++
 include/configs/MPC8315ERDB.h             |    2 +-
 include/configs/MPC837XEMDS.h             |    2 +-
 include/configs/MPC837XERDB.h             |    2 +-
 include/fdt_support.h                     |    6 ---
 include/fsl_dr_usb.h                      |   21 +++++++++++
 12 files changed, 126 insertions(+), 50 deletions(-)
 create mode 100644 drivers/usb/otg/Makefile
 create mode 100644 drivers/usb/otg/fsl_dr_usb.c
 create mode 100644 include/fsl_dr_usb.h

diff --git a/Makefile b/Makefile
index c52894c..fe3a323 100644
--- a/Makefile
+++ b/Makefile
@@ -265,6 +265,7 @@ LIBS += drivers/serial/libserial.a
 LIBS += drivers/twserial/libtws.a
 LIBS += drivers/usb/gadget/libusb_gadget.a
 LIBS += drivers/usb/host/libusb_host.a
+LIBS += drivers/usb/otg/libusb_otg.a
 LIBS += drivers/usb/musb/libusb_musb.a
 LIBS += drivers/video/libvideo.a
 LIBS += drivers/watchdog/libwatchdog.a
diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c
index f80b0ba..9d6896d 100644
--- a/board/freescale/mpc8315erdb/mpc8315erdb.c
+++ b/board/freescale/mpc8315erdb/mpc8315erdb.c
@@ -30,6 +30,7 @@
 #include <pci.h>
 #include <mpc83xx.h>
 #include <netdev.h>
+#include <fsl_dr_usb.h>
 #include <asm/io.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/board/freescale/mpc837xemds/mpc837xemds.c b/board/freescale/mpc837xemds/mpc837xemds.c
index 5d3cea1..76b5430 100644
--- a/board/freescale/mpc837xemds/mpc837xemds.c
+++ b/board/freescale/mpc837xemds/mpc837xemds.c
@@ -20,6 +20,7 @@
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <fsl_esdhc.h>
+#include <fsl_dr_usb.h>
 #include "pci.h"
 #include "../common/pq-mds-pib.h"
 
diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c
index 2229657..e8fa6b6 100644
--- a/board/freescale/mpc837xerdb/mpc837xerdb.c
+++ b/board/freescale/mpc837xerdb/mpc837xerdb.c
@@ -21,6 +21,7 @@
 #include <spd_sdram.h>
 #include <vsc7385.h>
 #include <fsl_esdhc.h>
+#include <fsl_dr_usb.h>
 
 #if defined(CONFIG_SYS_DRAM_TEST)
 int
diff --git a/common/fdt_support.c b/common/fdt_support.c
index b54f886..ec6cff1 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -454,47 +454,6 @@ void fdt_fixup_ethernet(void *fdt)
 	}
 }
 
-#ifdef CONFIG_HAS_FSL_DR_USB
-void fdt_fixup_dr_usb(void *blob, bd_t *bd)
-{
-	char *mode;
-	char *type;
-	const char *compat = "fsl-usb2-dr";
-	const char *prop_mode = "dr_mode";
-	const char *prop_type = "phy_type";
-	int node_offset;
-	int err;
-
-	mode = getenv("usb_dr_mode");
-	type = getenv("usb_phy_type");
-	if (!mode && !type)
-		return;
-
-	node_offset = fdt_node_offset_by_compatible(blob, 0, compat);
-	if (node_offset < 0) {
-		printf("WARNING: could not find compatible node %s: %s.\n",
-			compat, fdt_strerror(node_offset));
-		return;
-	}
-
-	if (mode) {
-		err = fdt_setprop(blob, node_offset, prop_mode, mode,
-				  strlen(mode) + 1);
-		if (err < 0)
-			printf("WARNING: could not set %s for %s: %s.\n",
-			       prop_mode, compat, fdt_strerror(err));
-	}
-
-	if (type) {
-		err = fdt_setprop(blob, node_offset, prop_type, type,
-				  strlen(type) + 1);
-		if (err < 0)
-			printf("WARNING: could not set %s for %s: %s.\n",
-			       prop_type, compat, fdt_strerror(err));
-	}
-}
-#endif /* CONFIG_HAS_FSL_DR_USB */
-
 #if defined(CONFIG_MPC83XX) || defined(CONFIG_MPC85xx)
 /*
  * update crypto node properties to a specified revision of the SEC
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
new file mode 100644
index 0000000..34b590f
--- /dev/null
+++ b/drivers/usb/otg/Makefile
@@ -0,0 +1,46 @@
+#
+# (C) Copyright 2000-2007
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# 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)libusb_otg.a
+
+COBJS-$(CONFIG_USB_FSL_DR) += fsl_dr_usb.o
+
+COBJS	:= $(COBJS-y)
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(LIB)
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/drivers/usb/otg/fsl_dr_usb.c b/drivers/usb/otg/fsl_dr_usb.c
new file mode 100644
index 0000000..af9797f
--- /dev/null
+++ b/drivers/usb/otg/fsl_dr_usb.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2008-2009 MontaVista Software, Inc.
+ *
+ * Author: Anton Vorontsov <avorontsov at 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 Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <libfdt.h>
+
+void fdt_fixup_dr_usb(void *blob, bd_t *bd)
+{
+	char *mode;
+	char *type;
+	const char *compat = "fsl-usb2-dr";
+	const char *prop_mode = "dr_mode";
+	const char *prop_type = "phy_type";
+	int node_offset;
+	int err;
+
+	mode = getenv("usb_dr_mode");
+	type = getenv("usb_phy_type");
+	if (!mode && !type)
+		return;
+
+	node_offset = fdt_node_offset_by_compatible(blob, 0, compat);
+	if (node_offset < 0) {
+		printf("WARNING: could not find compatible node %s: %s.\n",
+			compat, fdt_strerror(node_offset));
+		return;
+	}
+
+	if (mode) {
+		err = fdt_setprop(blob, node_offset, prop_mode, mode,
+				  strlen(mode) + 1);
+		if (err < 0)
+			printf("WARNING: could not set %s for %s: %s.\n",
+			       prop_mode, compat, fdt_strerror(err));
+	}
+
+	if (type) {
+		err = fdt_setprop(blob, node_offset, prop_type, type,
+				  strlen(type) + 1);
+		if (err < 0)
+			printf("WARNING: could not set %s for %s: %s.\n",
+			       prop_type, compat, fdt_strerror(err));
+	}
+}
diff --git a/include/configs/MPC8315ERDB.h b/include/configs/MPC8315ERDB.h
index 9fa91f4..e3dcf96 100644
--- a/include/configs/MPC8315ERDB.h
+++ b/include/configs/MPC8315ERDB.h
@@ -344,7 +344,7 @@
 #define CONFIG_NET_MULTI	1
 #endif
 
-#define CONFIG_HAS_FSL_DR_USB
+#define CONFIG_USB_FSL_DR	1
 
 /*
  * TSEC
diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h
index 9413b29..631468f 100644
--- a/include/configs/MPC837XEMDS.h
+++ b/include/configs/MPC837XEMDS.h
@@ -385,7 +385,7 @@ extern int board_pci_host_broken(void);
 #define CONFIG_83XX_GENERIC_PCIE	1
 #define CONFIG_PQ_MDS_PIB	1 /* PQ MDS Platform IO Board */
 
-#define CONFIG_HAS_FSL_DR_USB	1 /* fixup device tree for the DR USB */
+#define CONFIG_USB_FSL_DR	1 /* fixup device tree for the DR USB */
 
 #define CONFIG_NET_MULTI
 #define CONFIG_PCI_PNP		/* do pci plug-and-play */
diff --git a/include/configs/MPC837XERDB.h b/include/configs/MPC837XERDB.h
index d335d76..4f15be5 100644
--- a/include/configs/MPC837XERDB.h
+++ b/include/configs/MPC837XERDB.h
@@ -654,7 +654,7 @@
 #define CONFIG_ETH1ADDR		00:04:9f:ef:04:02
 #endif
 
-#define CONFIG_HAS_FSL_DR_USB
+#define CONFIG_USB_FSL_DR	1
 
 #define CONFIG_IPADDR		10.0.0.2
 #define CONFIG_SERVERIP		10.0.0.1
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 6062df9..7ee29ef 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -53,12 +53,6 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
 			 const void *val, int len, int create);
 void fdt_fixup_qe_firmware(void *fdt);
 
-#ifdef CONFIG_HAS_FSL_DR_USB
-void fdt_fixup_dr_usb(void *blob, bd_t *bd);
-#else
-static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {}
-#endif /* CONFIG_HAS_FSL_DR_USB */
-
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC83XX)
 void fdt_fixup_crypto_node(void *blob, int sec_rev);
 #else
diff --git a/include/fsl_dr_usb.h b/include/fsl_dr_usb.h
new file mode 100644
index 0000000..c14d9ba
--- /dev/null
+++ b/include/fsl_dr_usb.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2008-2009 MontaVista Software, Inc.
+ *
+ * Author: Anton Vorontsov <avorontsov at 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 Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#ifndef __DR_USB_H
+#define __DR_USB_H
+
+#ifdef CONFIG_USB_FSL_DR
+void fdt_fixup_dr_usb(void *blob, bd_t *bd);
+#else
+static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {}
+#endif
+
+#endif /* __DR_USB_H */
-- 
1.6.2.2



More information about the U-Boot mailing list