
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@ru.mvista.com --- 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/Makefile | 1 + drivers/usb/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 +++++++++++ 11 files changed, 80 insertions(+), 50 deletions(-) create mode 100644 drivers/usb/fsl_dr_usb.c create mode 100644 include/fsl_dr_usb.h
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 062d762..376b7f2 100644 --- a/board/freescale/mpc837xemds/mpc837xemds.c +++ b/board/freescale/mpc837xemds/mpc837xemds.c @@ -18,6 +18,7 @@ #include <tsec.h> #include <libfdt.h> #include <fdt_support.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 318a3dc..8cbac14 100644 --- a/board/freescale/mpc837xerdb/mpc837xerdb.c +++ b/board/freescale/mpc837xerdb/mpc837xerdb.c @@ -19,6 +19,7 @@ #include <fdt_support.h> #include <spd_sdram.h> #include <vsc7385.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/Makefile b/drivers/usb/Makefile index b306a65..bb71a26 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile @@ -40,6 +40,7 @@ COBJS-$(CONFIG_USB_EHCI_IXP4XX) += usb_ehci_ixp.o COBJS-$(CONFIG_MUSB_HCD) += musb_hcd.o musb_core.o COBJS-$(CONFIG_USB_DAVINCI) += davinci_usb.o COBJS-$(CONFIG_USB_EHCI_VCT) += usb_ehci_vct.o +COBJS-$(CONFIG_USB_FSL_DR) += fsl_dr_usb.o
# device ifdef CONFIG_USB_DEVICE diff --git a/drivers/usb/fsl_dr_usb.c b/drivers/usb/fsl_dr_usb.c new file mode 100644 index 0000000..af9797f --- /dev/null +++ b/drivers/usb/fsl_dr_usb.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008-2009 MontaVista Software, Inc. + * + * Author: Anton Vorontsov avorontsov@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 a62d805..68e0239 100644 --- a/include/configs/MPC837XEMDS.h +++ b/include/configs/MPC837XEMDS.h @@ -384,7 +384,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 8d0c93b..df7e746 100644 --- a/include/configs/MPC837XERDB.h +++ b/include/configs/MPC837XERDB.h @@ -638,7 +638,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@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 */