From patchwork Fri May 4 22:21:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 157007 X-Patchwork-Delegate: afleming@freescale.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 60031B6FCA for ; Sat, 5 May 2012 08:37:12 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 25E1B28087; Sat, 5 May 2012 00:37:08 +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 ZuGrk4Sl9lep; Sat, 5 May 2012 00:37:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 570B928088; Sat, 5 May 2012 00:37:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1E3222807F for ; Sat, 5 May 2012 00:36:59 +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 eoGvWlQ6Afox for ; Sat, 5 May 2012 00:36:54 +0200 (CEST) X-Greylist: delayed 906 seconds by postgrey-1.27 at theia; Sat, 05 May 2012 00:36:52 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 am1outboundpool.messaging.microsoft.com (am1ehsobe006.messaging.microsoft.com [213.199.154.209]) by theia.denx.de (Postfix) with ESMTPS id 117DD28083 for ; Sat, 5 May 2012 00:36:52 +0200 (CEST) Received: from mail17-am1-R.bigfish.com (10.3.201.232) by AM1EHSOBE003.bigfish.com (10.3.204.23) with Microsoft SMTP Server id 14.1.225.23; Fri, 4 May 2012 22:21:35 +0000 Received: from mail17-am1 (localhost [127.0.0.1]) by mail17-am1-R.bigfish.com (Postfix) with ESMTP id 4394532062D; Fri, 4 May 2012 22:21:35 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839hd24he5bh) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail17-am1 (localhost.localdomain [127.0.0.1]) by mail17-am1 (MessageSwitch) id 1336170093168203_20188; Fri, 4 May 2012 22:21:33 +0000 (UTC) Received: from AM1EHSMHS009.bigfish.com (unknown [10.3.201.232]) by mail17-am1.bigfish.com (Postfix) with ESMTP id 195182A0045; Fri, 4 May 2012 22:21:33 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS009.bigfish.com (10.3.207.109) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 4 May 2012 22:21:32 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.1.355.3; Fri, 4 May 2012 17:21:41 -0500 Received: from efes.am.freescale.net (efes.am.freescale.net [10.82.123.3]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id q44MLWbO027408; Fri, 4 May 2012 15:21:39 -0700 From: Timur Tabi To: Andy Fleming , Wolfgang Denk , Date: Fri, 4 May 2012 17:21:32 -0500 Message-ID: <1336170092-22538-6-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1336170092-22538-1-git-send-email-timur@freescale.com> References: <1336170092-22538-1-git-send-email-timur@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH 6/6] powerpc/85xx: p1022ds: use the saveenv board preparation functions 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de On the P1022, the DIU video signals are muxed with the localbus, so when the DIU is active, the localbus is unavailable. The saveenv command now supports board-specific functions that allow the DIU/LBC mux to be switched while saving the environment. This is much more efficient than switching the mux for each NOR flash transaction (which is what the current code does), and it also allows us to support any localbus device, not just NOR flash. Signed-off-by: Timur Tabi --- board/freescale/p1022ds/diu.c | 173 +++++++---------------------------------- include/configs/P1022DS.h | 6 -- 2 files changed, 28 insertions(+), 151 deletions(-) diff --git a/board/freescale/p1022ds/diu.c b/board/freescale/p1022ds/diu.c index d5428ea..1dd0e1f 100644 --- a/board/freescale/p1022ds/diu.c +++ b/board/freescale/p1022ds/diu.c @@ -147,10 +147,7 @@ int platform_diu_init(unsigned int xres, unsigned int yres, const char *port) * * On the Freescale P1022, the DIU video signal and the LBC address/data lines * share the same pins, which means that when the DIU is active (e.g. the - * console is on the DVI display), NOR flash cannot be accessed. So we use the - * weak accessor feature of the CFI flash code to temporarily switch the pin - * mux from DIU to LBC whenever we want to read or write flash. This has a - * significant performance penalty, but it's the only way to make it work. + * console is on the DVI display), NOR flash cannot be accessed. * * There are two muxes: one on the chip, and one on the board. The chip mux * controls whether the pins are used for the DIU or the LBC, and it is @@ -213,6 +210,33 @@ static void set_mux_to_diu(void) } /* + * While the DIU is active, the localbus is not available. Therefore, in + * order to support the saveenv command, we need to temporarily disable the + * DIU and enable the localbus. To do this, we provide our own + * implementations of the board_start_saveenv() and board_finish_saveenv() + * weak functions. These functions are called by do_env_save() before and + * after the environment is saved. + */ + +/* Remember if we switched the MUX, so that we know to switch it back */ +static int switched; + +int board_start_saveenv(void) +{ + switched = set_mux_to_lbc(); + + return 0; +} + +void board_finish_saveenv(void) +{ + if (switched) + set_mux_to_diu(); + + switched = 0; +} + +/* * pixis_read - board-specific function to read from the PIXIS * * This function overrides the generic pixis_read() function, so that it can @@ -271,144 +295,3 @@ void pixis_bank_reset(void) while (1); } - -#ifdef CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS - -void flash_write8(u8 value, void *addr) -{ - int sw = set_mux_to_lbc(); - - __raw_writeb(value, addr); - if (sw) { - /* - * To ensure the post-write is completed to eLBC, software must - * perform a dummy read from one valid address from eLBC space - * before changing the eLBC_DIU from NOR mode to DIU mode. - * set_mux_to_diu() includes a sync that will ensure the - * __raw_readb() completes before it switches the mux. - */ - __raw_readb(addr); - set_mux_to_diu(); - } -} - -void flash_write16(u16 value, void *addr) -{ - int sw = set_mux_to_lbc(); - - __raw_writew(value, addr); - if (sw) { - /* - * To ensure the post-write is completed to eLBC, software must - * perform a dummy read from one valid address from eLBC space - * before changing the eLBC_DIU from NOR mode to DIU mode. - * set_mux_to_diu() includes a sync that will ensure the - * __raw_readb() completes before it switches the mux. - */ - __raw_readb(addr); - set_mux_to_diu(); - } -} - -void flash_write32(u32 value, void *addr) -{ - int sw = set_mux_to_lbc(); - - __raw_writel(value, addr); - if (sw) { - /* - * To ensure the post-write is completed to eLBC, software must - * perform a dummy read from one valid address from eLBC space - * before changing the eLBC_DIU from NOR mode to DIU mode. - * set_mux_to_diu() includes a sync that will ensure the - * __raw_readb() completes before it switches the mux. - */ - __raw_readb(addr); - set_mux_to_diu(); - } -} - -void flash_write64(u64 value, void *addr) -{ - int sw = set_mux_to_lbc(); - uint32_t *p = addr; - - /* - * There is no __raw_writeq(), so do the write manually. We don't trust - * the compiler, so we use inline assembly. - */ - __asm__ __volatile__( - "stw%U0%X0 %2,%0;\n" - "stw%U1%X1 %3,%1;\n" - : "=m" (*p), "=m" (*(p + 1)) - : "r" ((uint32_t) (value >> 32)), "r" ((uint32_t) (value))); - - if (sw) { - /* - * To ensure the post-write is completed to eLBC, software must - * perform a dummy read from one valid address from eLBC space - * before changing the eLBC_DIU from NOR mode to DIU mode. We - * read addr+4 because we just wrote to addr+4, so that's how we - * maintain execution order. set_mux_to_diu() includes a sync - * that will ensure the __raw_readb() completes before it - * switches the mux. - */ - __raw_readb(addr + 4); - set_mux_to_diu(); - } -} - -u8 flash_read8(void *addr) -{ - u8 ret; - - int sw = set_mux_to_lbc(); - - ret = __raw_readb(addr); - if (sw) - set_mux_to_diu(); - - return ret; -} - -u16 flash_read16(void *addr) -{ - u16 ret; - - int sw = set_mux_to_lbc(); - - ret = __raw_readw(addr); - if (sw) - set_mux_to_diu(); - - return ret; -} - -u32 flash_read32(void *addr) -{ - u32 ret; - - int sw = set_mux_to_lbc(); - - ret = __raw_readl(addr); - if (sw) - set_mux_to_diu(); - - return ret; -} - -u64 flash_read64(void *addr) -{ - u64 ret; - - int sw = set_mux_to_lbc(); - - /* There is no __raw_readq(), so do the read manually */ - ret = *(volatile u64 *)addr; - if (sw) - set_mux_to_diu(); - - return ret; -} - -#endif diff --git a/include/configs/P1022DS.h b/include/configs/P1022DS.h index 9d2f8ea..89e8663 100644 --- a/include/configs/P1022DS.h +++ b/include/configs/P1022DS.h @@ -206,12 +206,6 @@ #define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_VIDEO_LOGO #define CONFIG_VIDEO_BMP_LOGO -#define CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS -/* - * With CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS, flash I/O is really slow, so - * disable empty flash sector detection, which is I/O-intensive. - */ -#undef CONFIG_SYS_FLASH_EMPTY_INFO #endif #ifndef CONFIG_FSL_DIU_FB