From patchwork Mon Aug 6 07:52:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 175285 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 F3A232C0095 for ; Mon, 6 Aug 2012 17:52:21 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 20A7928122; Mon, 6 Aug 2012 09:52:20 +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 t0GbX2pq94Z0; Mon, 6 Aug 2012 09:52:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AD66D2812B; Mon, 6 Aug 2012 09:52:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 665192812B for ; Mon, 6 Aug 2012 09:52:15 +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 1Hg0boHh9lai for ; Mon, 6 Aug 2012 09:52:15 +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-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by theia.denx.de (Postfix) with ESMTPS id 07AD028122 for ; Mon, 6 Aug 2012 09:52:13 +0200 (CEST) Received: by wibhr14 with SMTP id hr14so1170412wib.9 for ; Mon, 06 Aug 2012 00:52:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:x-gm-message-state; bh=XcUcEINUSV8EmQHfI3iygMiLpHfbIjmXZv2ZMtvhOYY=; b=MdSKXaEv3nDXtn67tK2l2BeWSaJO8cf3jfIR9NCeLmUne+RHI/QJMtzzF0kxnSxaw3 oJwxFlrhB1h7CEaQWEFWJBi6E7rg9pMSY95f7dBlylEipmCPXRoM410vhdCaDJ8OJCh+ YGKx6kW/4p4SNSI1b3HTTj0S1ERYP3X6lX61He1FEpnQuZLjzdRMk/leHv1Qh69x4ryV NHbFIQGdF2uJgAz+h0N08im7UX58qmKmTncD+75SsZIePxKxDzz4czL4JWTR34BDdkRM y2VWIIQFTkhVySJthBJT7PS9sWIEG0jEPzfye61zw0WlLzNLStqxl9E7ZHgmYClcix9r YqKQ== Received: by 10.180.99.196 with SMTP id es4mr16154691wib.18.1344239533590; Mon, 06 Aug 2012 00:52:13 -0700 (PDT) Received: from localhost (nat-2.starnet.cz. [92.62.224.2]) by mx.google.com with ESMTPS id t7sm21060970wix.6.2012.08.06.00.52.12 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 00:52:13 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de Date: Mon, 6 Aug 2012 09:52:11 +0200 Message-Id: <1344239531-12557-1-git-send-email-monstr@monstr.eu> X-Mailer: git-send-email 1.7.0.4 X-Gm-Message-State: ALoCoQk+v0R15aL09SffD2dYk0FfwjOOuwDVygE5ZDkx10J7Mh8C9QNHKwpHj5UkbbXzky1YNZ7e Subject: [U-Boot] [PATCH] block: systemace: Simplify base and width initialization 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 Use CONFIG parameters only at one location to simplify the code. Also create ace_readw/writew functions. Signed-off-by: Michal Simek --- drivers/block/systemace.c | 38 +++++++++++++++++++++++++------------- 1 files changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/block/systemace.c b/drivers/block/systemace.c index 58402b9..247cf06 100644 --- a/drivers/block/systemace.c +++ b/drivers/block/systemace.c @@ -51,24 +51,36 @@ * to be the base address for the chip, usually in the local * peripheral bus. */ -#if (CONFIG_SYS_SYSTEMACE_WIDTH == 8) + +static u32 base = CONFIG_SYS_SYSTEMACE_BASE; +static u32 width = CONFIG_SYS_SYSTEMACE_WIDTH; + +static void ace_writew(u16 val, unsigned off) +{ + if (width == 8) { #if !defined(__BIG_ENDIAN) -#define ace_readw(off) ((readb(CONFIG_SYS_SYSTEMACE_BASE+off)<<8) | \ - (readb(CONFIG_SYS_SYSTEMACE_BASE+off+1))) -#define ace_writew(val, off) {writeb(val>>8, CONFIG_SYS_SYSTEMACE_BASE+off); \ - writeb(val, CONFIG_SYS_SYSTEMACE_BASE+off+1);} + writeb(val >> 8, base + off); + writeb(val, base + off + 1); #else -#define ace_readw(off) ((readb(CONFIG_SYS_SYSTEMACE_BASE+off)) | \ - (readb(CONFIG_SYS_SYSTEMACE_BASE+off+1)<<8)) -#define ace_writew(val, off) {writeb(val, CONFIG_SYS_SYSTEMACE_BASE+off); \ - writeb(val>>8, CONFIG_SYS_SYSTEMACE_BASE+off+1);} + writeb(val, base + off); + writeb(val >> 8, base + off + 1); #endif + } + out16(base + off, val); +} + +static u16 ace_readw(unsigned off) +{ + if (width == 8) { +#if !defined(__BIG_ENDIAN) + return (readb(base + off) << 8) | readb(base + off + 1); #else -#define ace_readw(off) (in16(CONFIG_SYS_SYSTEMACE_BASE+off)) -#define ace_writew(val, off) (out16(CONFIG_SYS_SYSTEMACE_BASE+off,val)) + return readb(base + off) | (readb(base + off + 1) << 8); #endif + } -/* */ + return in16(base + off); +} static unsigned long systemace_read(int dev, unsigned long start, unsigned long blkcnt, void *buffer); @@ -121,7 +133,7 @@ block_dev_desc_t *systemace_get_dev(int dev) /* * Ensure the correct bus mode (8/16 bits) gets enabled */ - ace_writew(CONFIG_SYS_SYSTEMACE_WIDTH == 8 ? 0 : 0x0001, 0); + ace_writew(width == 8 ? 0 : 0x0001, 0); init_part(&systemace_dev);