From patchwork Tue Mar 22 10:20:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ramneek mehresh X-Patchwork-Id: 87898 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B2959B6F77 for ; Tue, 22 Mar 2011 22:43:47 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 493B5280B8; Tue, 22 Mar 2011 12:43:46 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sE9ujknGTxuN; Tue, 22 Mar 2011 12:43:46 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9ACFF280C0; Tue, 22 Mar 2011 12:43:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7E247280C0 for ; Tue, 22 Mar 2011 12:43:37 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pwepQSfAt5uV for ; Tue, 22 Mar 2011 12:43:36 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from VA3EHSOBE004.bigfish.com (va3ehsobe004.messaging.microsoft.com [216.32.180.14]) by theia.denx.de (Postfix) with ESMTPS id 0417A280B8 for ; Tue, 22 Mar 2011 12:43:34 +0100 (CET) Received: from mail193-va3-R.bigfish.com (10.7.14.246) by VA3EHSOBE004.bigfish.com (10.7.40.24) with Microsoft SMTP Server id 14.1.225.8; Tue, 22 Mar 2011 11:43:32 +0000 Received: from mail193-va3 (localhost.localdomain [127.0.0.1]) by mail193-va3-R.bigfish.com (Postfix) with ESMTP id 769C5AC8488 for ; Tue, 22 Mar 2011 11:43:32 +0000 (UTC) X-SpamScore: -3 X-BigFish: VS-3(zzbb2cKzz1202hzz8275bh8275chz2dh2a8h668h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail193-va3 (localhost.localdomain [127.0.0.1]) by mail193-va3 (MessageSwitch) id 130079421142812_10112; Tue, 22 Mar 2011 11:43:31 +0000 (UTC) Received: from VA3EHSMHS029.bigfish.com (unknown [10.7.14.239]) by mail193-va3.bigfish.com (Postfix) with ESMTP id 071001B30054 for ; Tue, 22 Mar 2011 11:43:31 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS029.bigfish.com (10.7.99.39) with Microsoft SMTP Server (TLS) id 14.1.225.8; Tue, 22 Mar 2011 11:43:25 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.270.2; Tue, 22 Mar 2011 06:43:23 -0500 Received: from localhost.localdomain (udp153803uds.ap.freescale.net [10.232.134.9]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id p2MBhKs6005601; Tue, 22 Mar 2011 06:43:21 -0500 (CDT) From: Ramneek Mehresh To: Date: Tue, 22 Mar 2011 15:50:56 +0530 Message-ID: <1300789256-14487-1-git-send-email-ramneek.mehresh@freescale.com> X-Mailer: git-send-email 1.6.1 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: Ramneek Mehresh Subject: [U-Boot] [PATCH] powerpc/qoriq: Update USB mode device tree fixup X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Modify support for USB mode fixup: - Add support for fetching USB mode and phy type via hwconfig - Add common support for USB mode and phy type device tree fix-up for all USB controllers mentioned in hwconfig string - Add USB2 controller offset Signed-off-by: Ramneek Mehresh --- Applies on git://git.am.freescale.net/mirrors/u-boot (branch next) arch/powerpc/cpu/mpc8xxx/fdt.c | 84 ++++++++++++++++++++++++++------- arch/powerpc/include/asm/immap_85xx.h | 3 +- include/fdt_support.h | 6 ++- 3 files changed, 74 insertions(+), 19 deletions(-) diff --git a/arch/powerpc/cpu/mpc8xxx/fdt.c b/arch/powerpc/cpu/mpc8xxx/fdt.c index 54e60bb..3744205 100644 --- a/arch/powerpc/cpu/mpc8xxx/fdt.c +++ b/arch/powerpc/cpu/mpc8xxx/fdt.c @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Freescale Semiconductor, Inc. + * Copyright 2009-2011 Freescale Semiconductor, Inc. * * This file is derived from arch/powerpc/cpu/mpc85xx/cpu.c and * arch/powerpc/cpu/mpc86xx/cpu.c. Basically this file contains @@ -28,6 +28,8 @@ #include #include #include +#include +#include #if defined(CONFIG_MP) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)) static int ft_del_cpuhandle(void *blob, int cpuhandle) @@ -83,25 +85,21 @@ void ft_fixup_num_cores(void *blob) { #endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */ #ifdef CONFIG_HAS_FSL_DR_USB -void fdt_fixup_dr_usb(void *blob, bd_t *bd) +static void fdt_fixup_usb_mode_phy_type(void *blob, const char *mode, + const char *phy_type) { - 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; + static int start_offset = -1; + int err, node_offset; - mode = getenv("usb_dr_mode"); - type = getenv("usb_phy_type"); - if (!mode && !type) - return; - - node_offset = fdt_node_offset_by_compatible(blob, 0, compat); + node_offset = fdt_node_offset_by_compatible(blob, + start_offset, compat); if (node_offset < 0) { - printf("WARNING: could not find compatible node %s: %s.\n", - compat, fdt_strerror(node_offset)); + printf("WARNING: could not find compatible" + "node %s: %s.\n", compat, + fdt_strerror(node_offset)); return; } @@ -113,13 +111,65 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) prop_mode, compat, fdt_strerror(err)); } - if (type) { - err = fdt_setprop(blob, node_offset, prop_type, type, - strlen(type) + 1); + if (phy_type) { + err = fdt_setprop(blob, node_offset, prop_type, phy_type, + strlen(phy_type) + 1); if (err < 0) printf("WARNING: could not set %s for %s: %s.\n", prop_type, compat, fdt_strerror(err)); } + + start_offset = node_offset; +} + +void fdt_fixup_dr_usb(void *blob, bd_t *bd) +{ + const char *modes[] = { "host", "peripheral", "otg" }; + const char *phys[] = { "ulpi", "umti" }; + const char *phy_type = NULL; + char usb1_defined = 0; + const char *mode = NULL; + int node_offset; + char str[5]; + int err, i, j; + + for (i = 1; i <= USB_MAX_DEVICE; i++) { + int mode_idx = -1, phy_idx = -1; + sprintf(str, "%s%d", "usb", i); + if (hwconfig(str)) { + for (j = 0; j < sizeof(modes); j++) { + if (hwconfig_subarg_cmp(str, "dr_mode", + modes[j])) { + mode_idx = j; + break; + } + } + for (j = 0; j < sizeof(phys); j++) { + if (hwconfig_subarg_cmp(str, "phy_type", + phys[j])) { + phy_idx = j; + break; + } + } + if ((mode_idx >= 0) || (phy_idx >= 0)) { + fdt_fixup_usb_mode_phy_type(blob, + modes[mode_idx], phys[phy_idx]); + if (!strcmp(str, "usb1")) + usb1_defined = 1; + } else { + printf("WARNING: invalid phy or mode\n"); + } + } else { + break; + } + } + if (!usb1_defined) { + mode = getenv("usb_dr_mode"); + phy_type = getenv("usb_phy_type"); + if (!mode && !phy_type) + return; + fdt_fixup_usb_mode_phy_type(blob, mode, phy_type); + } } #endif /* CONFIG_HAS_FSL_DR_USB */ diff --git a/arch/powerpc/include/asm/immap_85xx.h b/arch/powerpc/include/asm/immap_85xx.h index 30c64eb..1d67471 100644 --- a/arch/powerpc/include/asm/immap_85xx.h +++ b/arch/powerpc/include/asm/immap_85xx.h @@ -1,7 +1,7 @@ /* * MPC85xx Internal Memory Map * - * Copyright 2007-2010 Freescale Semiconductor, Inc. + * Copyright 2007-2011 Freescale Semiconductor, Inc. * * Copyright(c) 2002,2003 Motorola Inc. * Xianghua Xiao (x.xiao@motorola.com) @@ -2245,6 +2245,7 @@ typedef struct ccsr_pme { #define CONFIG_SYS_MPC85xx_L2_OFFSET 0x20000 #define CONFIG_SYS_MPC85xx_DMA_OFFSET 0x21000 #define CONFIG_SYS_MPC85xx_USB_OFFSET 0x22000 +#define CONFIG_SYS_MPC85xx_USB2_OFFSET 0x23000 #ifdef CONFIG_TSECV2 #define CONFIG_SYS_TSEC1_OFFSET 0xB0000 #else diff --git a/include/fdt_support.h b/include/fdt_support.h index ce6817b..9bde6c5 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2007 + * (C) Copyright 2011 * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com * * See file CREDITS for list of people who contributed to this @@ -56,8 +56,12 @@ void fdt_fixup_qe_firmware(void *fdt); #ifdef CONFIG_HAS_FSL_DR_USB void fdt_fixup_dr_usb(void *blob, bd_t *bd); +void fdt_fixup_usb_mode_phy_type(void *blob, int node_offset, + const char *mode, const char *phy_type); #else static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {} +static inline void fdt_fixup_usb_mode_phy_type(void *blob, int node_offset, + const char *mode, const char *phy_type) {} #endif /* CONFIG_HAS_FSL_DR_USB */ #if defined(CONFIG_SYS_FSL_SEC_COMPAT)