From patchwork Tue Oct 4 21:44:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 117703 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 BD0FB1007D1 for ; Wed, 5 Oct 2011 08:46:19 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E9D3C2926C; Tue, 4 Oct 2011 23:46:07 +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 s-KN-Q77eok8; Tue, 4 Oct 2011 23:46:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C64A32928F; Tue, 4 Oct 2011 23:46:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B8F42928F for ; Tue, 4 Oct 2011 23:45:42 +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 sM6hgfN5BwwW for ; Tue, 4 Oct 2011 23:45:19 +0200 (CEST) X-policyd-weight: passed - too many local DNS-errors in dnsbl.njabl.org lookups Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe006.messaging.microsoft.com [216.32.181.186]) by theia.denx.de (Postfix) with ESMTPS id 5BCBC2926C for ; Tue, 4 Oct 2011 23:45:01 +0200 (CEST) Received: from mail138-ch1-R.bigfish.com (10.43.68.250) by CH1EHSOBE016.bigfish.com (10.43.70.66) with Microsoft SMTP Server id 14.1.225.22; Tue, 4 Oct 2011 21:44:49 +0000 Received: from mail138-ch1 (localhost.localdomain [127.0.0.1]) by mail138-ch1-R.bigfish.com (Postfix) with ESMTP id B7413D783BF for ; Tue, 4 Oct 2011 21:44:49 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail138-ch1 (localhost.localdomain [127.0.0.1]) by mail138-ch1 (MessageSwitch) id 1317764687569648_27433; Tue, 4 Oct 2011 21:44:47 +0000 (UTC) Received: from CH1EHSMHS018.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.251]) by mail138-ch1.bigfish.com (Postfix) with ESMTP id 85D9F3C004C for ; Tue, 4 Oct 2011 21:44:47 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS018.bigfish.com (10.43.70.18) with Microsoft SMTP Server (TLS) id 14.1.225.22; Tue, 4 Oct 2011 21:44:45 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.323.7; Tue, 4 Oct 2011 16:44:45 -0500 Received: from efes.am.freescale.net (efes.am.freescale.net [10.82.123.3]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p94Lihef000039; Tue, 4 Oct 2011 16:44:44 -0500 (CDT) From: Timur Tabi To: , , , , Date: Tue, 4 Oct 2011 16:44:43 -0500 Message-ID: <1317764683-29426-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.3.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH] powerpc/85xx: fix null pointer dereference when initializing the SGMII TBI PHY 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 Function dtsec_configure_serdes() needs to know where the TBI PHY registers are in order to configure SGMII for proper SerDes operation. During SGMII initialzation, fm_eth_init_mac() passing NULL for 'phyregs' when it called init_dtsec(), because it was believed that phyregs was not used. In fact, it is used by dtsec_configure_serdes() to configure the TBI PHY registers. We also need to define the PHY registers in struct fm_mdio. Signed-off-by: Timur Tabi --- Note: I'm not sure of my change to struct fm_mdio. It works, but it doesn't smell right. arch/powerpc/include/asm/fsl_fman.h | 9 ++++++++- drivers/net/fm/dtsec.c | 2 +- drivers/net/fm/eth.c | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/fsl_fman.h b/arch/powerpc/include/asm/fsl_fman.h index fddc0cc..2c0c9bc 100644 --- a/arch/powerpc/include/asm/fsl_fman.h +++ b/arch/powerpc/include/asm/fsl_fman.h @@ -405,7 +405,14 @@ typedef struct fm_dtesc { } fm_dtsec_t; typedef struct fm_mdio { - u8 res[4*1024]; + u8 res0[0x120]; + u32 miimcfg; /* MII management configuration reg */ + u32 miimcom; /* MII management command reg */ + u32 miimadd; /* MII management address reg */ + u32 miimcon; /* MII management control reg */ + u32 miimstat; /* MII management status reg */ + u32 miimind; /* MII management indication reg */ + u8 res1[0x1000 - 0x138]; } fm_mdio_t; typedef struct fm_10gec { diff --git a/drivers/net/fm/dtsec.c b/drivers/net/fm/dtsec.c index a77ee20..7dd78f2 100644 --- a/drivers/net/fm/dtsec.c +++ b/drivers/net/fm/dtsec.c @@ -171,7 +171,7 @@ void init_dtsec(struct fsl_enet_mac *mac, void *base, void *phyregs, int max_rx_len) { mac->base = base; - mac->phyregs = NULL; + mac->phyregs = phyregs; mac->max_rx_len = max_rx_len; mac->init_mac = dtsec_init_mac; mac->enable_mac = dtsec_enable_mac; diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index 308d610..f7ed850 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -537,6 +537,7 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg) /* Get the mac registers base address */ if (fm_eth->type == FM_ETH_1G_E) { base = ®->mac_1g[num].fm_dtesc; + phyregs = ®->mac_1g[num].fm_mdio.miimcfg; } else { base = ®->mac_10g[num].fm_10gec; phyregs = ®->mac_10g[num].fm_10gec_mdio; @@ -552,7 +553,7 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg) fm_eth->mac = mac; if (fm_eth->type == FM_ETH_1G_E) - init_dtsec(mac, base, NULL, MAX_RXBUF_LEN); + init_dtsec(mac, base, phyregs, MAX_RXBUF_LEN); else init_tgec(mac, base, phyregs, MAX_RXBUF_LEN);