From patchwork Mon Jun 10 13:45:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Denk X-Patchwork-Id: 250251 X-Patchwork-Delegate: joe.hershberger@gmail.com 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 8D1372C007C for ; Mon, 10 Jun 2013 23:45:37 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28A204A08E; Mon, 10 Jun 2013 15:45:36 +0200 (CEST) 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 1V9Ht6hJa04S; Mon, 10 Jun 2013 15:45:36 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EE9644A048; Mon, 10 Jun 2013 15:45:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 778844A048 for ; Mon, 10 Jun 2013 15:45:23 +0200 (CEST) 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 cEVPIjpKX5H7 for ; Mon, 10 Jun 2013 15:45:17 +0200 (CEST) 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 mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTPS id 5C30B4A040 for ; Mon, 10 Jun 2013 15:45:10 +0200 (CEST) Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3bTbFK3C7Cz3hhTB; Mon, 10 Jun 2013 15:45:09 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3bTbFK2swLzbbgb; Mon, 10 Jun 2013 15:45:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from smtp-auth.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id AyL0Bp_IqAaJ; Mon, 10 Jun 2013 15:45:07 +0200 (CEST) X-Auth-Info: wc1UeVg1TRX1aqv9RKZh2lEq+kSRRIehv33g1+aHcF4= Received: from diddl.denx.de (host-80-81-18-216.customer.m-online.net [80.81.18.216]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA; Mon, 10 Jun 2013 15:45:07 +0200 (CEST) Received: from gemini.denx.de (unknown [10.0.0.2]) by diddl.denx.de (Postfix) with ESMTP id 0ECD61A777C; Mon, 10 Jun 2013 15:45:05 +0200 (CEST) Received: by gemini.denx.de (Postfix, from userid 500) id 5F96E383192; Mon, 10 Jun 2013 15:45:07 +0200 (MEST) From: Wolfgang Denk To: u-boot@lists.denx.de Date: Mon, 10 Jun 2013 15:45:00 +0200 Message-Id: <1370871900-28027-1-git-send-email-wd@denx.de> X-Mailer: git-send-email 1.8.1.4 Subject: [U-Boot] [PATCH RFC] NET: TSEC: make PHY addresses software configurable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Some systems use a SoM (system on module) in such a way that the PHY addresses depend on the carrier board used, or even on the geographic position of the SoM on the carrier board. This patch adds support for runtime assignment of the PHY addresses for the TSEC ports through environment variables "tsec_1_phy_addr", "tsec_2_phy_addr", ... Signed-off-by: Wolfgang Denk Cc: Joe Hershberger --- This is a RFC patch to have a base for discussing the approach. There are a few things I dislike - all comments welcome: - It would be nice if there was a generic approach that works for all types of network interfaces instead of only TSEC ports, but I could not find a good generic place for such a hook. - I'm not sure if "tsec_1_phy_addr" etc. is a good name ;-) - Maybe there is another way to address this issue? I can't believe we're the first to run into this type of problem? drivers/net/tsec.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index f5e314b..e86e48c 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -567,6 +567,26 @@ static phy_interface_t tsec_get_interface(struct tsec_private *priv) return PHY_INTERFACE_MODE_MII; } +static void update_phy_addr(int phy_nr) +{ + char *str, buf[32]; + + sprintf(buf, "tsec_%d_phy_addr", phy_nr); + + str = getenv(buf); + + if (str) { + ulong val = simple_strtoul(str, NULL, 16); + + debug("FIX TSEC%d_PHY_ADDR : %d => %ld\n", + phy_nr, tsec_info[phy_nr].phyaddr, val); + + tsec_info[phy_nr].phyaddr = val; + } else { + debug("FIX TSEC%d_PHY_ADDR : %s not set\n", + phy_nr, buf); + } +} /* Discover which PHY is attached to the device, and configure it * properly. If the PHY is not recognized, then return 0 @@ -671,7 +691,10 @@ int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num) int i; int ret, count = 0; + debug ("tsec_eth_init()\n"); for (i = 0; i < num; i++) { + update_phy_addr(i); + ret = tsec_initialize(bis, &tsecs[i]); if (ret > 0) count += ret;