From patchwork Fri Nov 16 21:20:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 199755 X-Patchwork-Delegate: trini@ti.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 AA2212C0090 for ; Sat, 17 Nov 2012 08:32:42 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 985824A1E7; Fri, 16 Nov 2012 22:32:25 +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 hO6E8knRQy1e; Fri, 16 Nov 2012 22:32:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E41414A1EE; Fri, 16 Nov 2012 22:30:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3F38A4A1EC for ; Fri, 16 Nov 2012 22:29:15 +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 XRjXVg2J8tEm for ; Fri, 16 Nov 2012 22:29:13 +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 mail-vb0-f74.google.com (mail-vb0-f74.google.com [209.85.212.74]) by theia.denx.de (Postfix) with ESMTPS id 58F1A4A19C for ; Fri, 16 Nov 2012 22:28:50 +0100 (CET) Received: by mail-vb0-f74.google.com with SMTP id s24so350094vbi.3 for ; Fri, 16 Nov 2012 13:28:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=SXOEGBJNwHtYT8+Z86pGc3CxyIKvMUTa0usYwb1cOFI=; b=FBqzXaCqN5Xi0BYp2015VFFbomQDsFV4pv7s2iT1P0etPxY82u14keSNCt99z5mHql NIGG7j5cxHziJzoHy3WPgpJ4T2AagOQZ5eScXkym0kLc5cQ1STViU43n/piKxscEErgh rWS/htO38Y+Nry78DTfcBCkbIVujGTDKCKixDVyoVLBxAWAOkAZeid0xNQ5CA1aHu6LG EcAOdyfu1e5x4sDe7YOTGVNTZBCkW/OrDN4wUWJjBarl/EagpQfkUgmV6+GPLqnbpvfI Kg4R7k19EKiUa+NzQO6JGYYWtl0AlIeqPyDVnQovGssoJWLAQFISzq+Ho59kOpJuamDV 1UZg== Received: by 10.236.193.106 with SMTP id j70mr4157807yhn.11.1353101329827; Fri, 16 Nov 2012 13:28:49 -0800 (PST) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id i27si212214yhb.0.2012.11.16.13.28.49 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 16 Nov 2012 13:28:49 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 9808810004A; Fri, 16 Nov 2012 13:28:49 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 77335160847; Fri, 16 Nov 2012 13:28:49 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Fri, 16 Nov 2012 13:20:08 -0800 Message-Id: <1353100842-20126-24-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1353100842-20126-1-git-send-email-sjg@chromium.org> References: <1353100842-20126-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmzOVdlHEoZbgvKCQAitQFO89a0HTkJDeiLZ3neFo/x9YSqSvgOUt4iNVQBHdKL4Lv2AMwylpyeKeunlfaBEtrxXNUGXkpG/NdAFw60ur9fLO0il71DYHtdH9FqHIhKq2z5kxPi8NNCVR5Au1hayGzmSvup8haODxeerAH6Klm3ygCxwDWfrLQ+z9NS9MRN6NNVOYeY Cc: Kim Phillips , Kumar Gala , Andy Fleming , Tom Rini , Stefan Roese Subject: [U-Boot] [PATCH 23/57] ppc: Move mpc5xxx clocks to arch_global_data 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 Move ipb_clk and pci_clk into arch_global_data and tidy up. Signed-off-by: Simon Glass --- arch/powerpc/cpu/mpc5xxx/i2c.c | 2 +- arch/powerpc/cpu/mpc5xxx/ide.c | 2 +- arch/powerpc/cpu/mpc5xxx/serial.c | 4 ++-- arch/powerpc/cpu/mpc5xxx/speed.c | 18 ++++++++++++------ arch/powerpc/cpu/mpc8220/fec.c | 8 +++++--- arch/powerpc/include/asm/global_data.h | 6 +++--- arch/powerpc/lib/board.c | 2 +- board/inka4x0/inkadiag.c | 8 ++++---- drivers/input/ps2ser.c | 2 +- drivers/net/mpc5xxx_fec.c | 9 ++++++--- 10 files changed, 36 insertions(+), 25 deletions(-) diff --git a/arch/powerpc/cpu/mpc5xxx/i2c.c b/arch/powerpc/cpu/mpc5xxx/i2c.c index b423d2f..8d5f47b 100644 --- a/arch/powerpc/cpu/mpc5xxx/i2c.c +++ b/arch/powerpc/cpu/mpc5xxx/i2c.c @@ -310,7 +310,7 @@ static int mpc_get_fdr(int speed) {126, 128} }; - ipb = gd->ipb_clk; + ipb = gd->arch.ipb_clk; for (i = 7; i >= 0; i--) { for (j = 7; j >= 0; j--) { scl = 2 * (scltap[j].scl2tap + diff --git a/arch/powerpc/cpu/mpc5xxx/ide.c b/arch/powerpc/cpu/mpc5xxx/ide.c index d337abb..094f62b 100644 --- a/arch/powerpc/cpu/mpc5xxx/ide.c +++ b/arch/powerpc/cpu/mpc5xxx/ide.c @@ -75,7 +75,7 @@ int ide_preinit (void) psdma->PtdCntrl |= 1; /* Init timings : we use PIO mode 0 timings */ - period = 1000000000 / gd->ipb_clk; /* period in ns */ + period = 1000000000 / gd->arch.ipb_clk; /* period in ns */ t0 = CALC_TIMING (600); t2_8 = CALC_TIMING (290); diff --git a/arch/powerpc/cpu/mpc5xxx/serial.c b/arch/powerpc/cpu/mpc5xxx/serial.c index eb14161..1ccb4e3 100644 --- a/arch/powerpc/cpu/mpc5xxx/serial.c +++ b/arch/powerpc/cpu/mpc5xxx/serial.c @@ -89,7 +89,7 @@ int serial_init_dev (unsigned long dev_base) /* select clock sources */ psc->psc_clock_select = 0; - baseclk = (gd->ipb_clk + 16) / 32; + baseclk = (gd->arch.ipb_clk + 16) / 32; /* switch to UART mode */ psc->sicr = 0; @@ -169,7 +169,7 @@ void serial_setbrg_dev (unsigned long dev_base) volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base; unsigned long baseclk, div; - baseclk = (gd->ipb_clk + 16) / 32; + baseclk = (gd->arch.ipb_clk + 16) / 32; /* set up UART divisor */ div = (baseclk + (gd->baudrate/2)) / gd->baudrate; diff --git a/arch/powerpc/cpu/mpc5xxx/speed.c b/arch/powerpc/cpu/mpc5xxx/speed.c index 8027d3e..5353e3d 100644 --- a/arch/powerpc/cpu/mpc5xxx/speed.c +++ b/arch/powerpc/cpu/mpc5xxx/speed.c @@ -66,14 +66,20 @@ int get_clocks (void) val = *(vu_long *)MPC5XXX_CDM_CFG; if (val & (1 << 8)) { - gd->ipb_clk = gd->bus_clk / 2; + gd->arch.ipb_clk = gd->bus_clk / 2; } else { - gd->ipb_clk = gd->bus_clk; + gd->arch.ipb_clk = gd->bus_clk; } switch (val & 3) { - case 0: gd->pci_clk = gd->ipb_clk; break; - case 1: gd->pci_clk = gd->ipb_clk / 2; break; - default: gd->pci_clk = gd->bus_clk / 4; break; + case 0: + gd->pci_clk = gd->arch.ipb_clk; + break; + case 1: + gd->pci_clk = gd->arch.ipb_clk / 2; + break; + default: + gd->pci_clk = gd->bus_clk / 4; + break; } return (0); @@ -85,7 +91,7 @@ int prt_mpc5xxx_clks (void) printf (" Bus %s MHz, IPB %s MHz, PCI %s MHz\n", strmhz(buf1, gd->bus_clk), - strmhz(buf2, gd->ipb_clk), + strmhz(buf2, gd->arch.ipb_clk), strmhz(buf3, gd->pci_clk) ); return (0); diff --git a/arch/powerpc/cpu/mpc8220/fec.c b/arch/powerpc/cpu/mpc8220/fec.c index aaf9be1..43fa802 100644 --- a/arch/powerpc/cpu/mpc8220/fec.c +++ b/arch/powerpc/cpu/mpc8220/fec.c @@ -288,9 +288,11 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock * and do not drop the Preamble. */ - /* tbd - rtm */ - /*fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); */ - /* No MII for 7-wire mode */ + /* + * tbd - rtm + * fec->eth->mii_speed = (((gd->arch.ipb_clk >> 20) / 5) << 1); + * No MII for 7-wire mode + */ fec->eth->mii_speed = 0x00000030; } diff --git a/arch/powerpc/include/asm/global_data.h b/arch/powerpc/include/asm/global_data.h index ca36ca3..423e792 100644 --- a/arch/powerpc/include/asm/global_data.h +++ b/arch/powerpc/include/asm/global_data.h @@ -94,6 +94,9 @@ struct arch_global_data { #if defined(CONFIG_E500) u32 used_tlb_cams[(CONFIG_SYS_NUM_TLBCAMS+31)/32]; #endif +#if defined(CONFIG_MPC5xxx) + unsigned long ipb_clk; +#endif }; /* @@ -116,9 +119,6 @@ typedef struct global_data { #if defined(CONFIG_FSL_ESDHC) u32 sdhc_clk; #endif -#if defined(CONFIG_MPC5xxx) - unsigned long ipb_clk; -#endif #if defined(CONFIG_MPC512X) u32 ips_clk; u32 csb_clk; diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index 6315991..07b16d5 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -589,7 +589,7 @@ void board_init_f(ulong bootflag) bd->bi_ipsfreq = gd->ips_clk; #endif /* CONFIG_MPC512X */ #if defined(CONFIG_MPC5xxx) - bd->bi_ipbfreq = gd->ipb_clk; + bd->bi_ipbfreq = gd->arch.ipb_clk; bd->bi_pcifreq = gd->pci_clk; #endif /* CONFIG_MPC5xxx */ bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ diff --git a/board/inka4x0/inkadiag.c b/board/inka4x0/inkadiag.c index cf82f61..1c01bb4 100644 --- a/board/inka4x0/inkadiag.c +++ b/board/inka4x0/inkadiag.c @@ -187,7 +187,7 @@ static int ser_init(volatile struct mpc5xxx_psc *psc, int baudrate) /* select clock sources */ out_be16(&psc->psc_clock_select, 0); - baseclk = (gd->ipb_clk + 16) / 32; + baseclk = (gd->arch.ipb_clk + 16) / 32; /* switch to UART mode */ out_be32(&psc->sicr, 0); @@ -369,7 +369,7 @@ static void buzzer_turn_on(unsigned int freq) { volatile struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt *)(BUZZER_GPT); - const u32 prescale = gd->ipb_clk / freq / 128; + const u32 prescale = gd->arch.ipb_clk / freq / 128; const u32 count = 128; const u32 width = 64; @@ -405,9 +405,9 @@ static int do_inkadiag_buzzer(cmd_tbl_t *cmdtp, int flag, int argc, freq = simple_strtol(argv[0], NULL, 0); /* avoid zero prescale in buzzer_turn_on() */ - if (freq > gd->ipb_clk / 128) { + if (freq > gd->arch.ipb_clk / 128) { printf("%dHz exceeds maximum (%ldHz)\n", freq, - gd->ipb_clk / 128); + gd->arch.ipb_clk / 128); } else if (!freq) printf("Zero frequency is senseless\n"); else diff --git a/drivers/input/ps2ser.c b/drivers/input/ps2ser.c index a655a16..bcbe52a 100644 --- a/drivers/input/ps2ser.c +++ b/drivers/input/ps2ser.c @@ -80,7 +80,7 @@ int ps2ser_init(void) /* select clock sources */ psc->psc_clock_select = 0; - baseclk = (gd->ipb_clk + 16) / 32; + baseclk = (gd->arch.ipb_clk + 16) / 32; /* switch to UART mode */ psc->sicr = 0; diff --git a/drivers/net/mpc5xxx_fec.c b/drivers/net/mpc5xxx_fec.c index 3d180db..1093ba5 100644 --- a/drivers/net/mpc5xxx_fec.c +++ b/drivers/net/mpc5xxx_fec.c @@ -440,8 +440,9 @@ static int mpc5xxx_fec_init_phy(struct eth_device *dev, bd_t * bis) /* * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock * and do not drop the Preamble. + * No MII for 7-wire mode */ - fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */ + fec->eth->mii_speed = (((gd->arch.ipb_clk >> 20) / 5) << 1); } if (fec->xcv_type != SEVENWIRE) { @@ -644,8 +645,9 @@ static void mpc5xxx_fec_halt(struct eth_device *dev) /* * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock * and do not drop the Preamble. + * No MII for 7-wire mode */ - fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */ + fec->eth->mii_speed = (((gd->arch.ipb_clk >> 20) / 5) << 1); } #if (DEBUG & 0x3) @@ -909,8 +911,9 @@ int mpc5xxx_fec_initialize(bd_t * bis) /* * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock * and do not drop the Preamble. + * No MII for 7-wire mode */ - fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */ + fec->eth->mii_speed = (((gd->arch.ipb_clk >> 20) / 5) << 1); } dev->priv = (void *)fec;