From: Michal Simek <monstr@monstr.eu>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] block: systemace: Simplify base and width initialization
Date: Fri, 10 Aug 2012 08:39:05 +0200 [thread overview]
Message-ID: <5024AC89.3030009@monstr.eu> (raw)
In-Reply-To: <1344239531-12557-1-git-send-email-monstr@monstr.eu>
On 08/06/2012 09:52 AM, Michal Simek wrote:
> Use CONFIG parameters only at one location to simplify
> the code. Also create ace_readw/writew functions.
>
> Signed-off-by: Michal Simek <monstr@monstr.eu>
> ---
> 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);
>
>
Applied to microblaze custodian tree.
Michal
--
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
prev parent reply other threads:[~2012-08-10 6:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 7:52 [U-Boot] [PATCH] block: systemace: Simplify base and width initialization Michal Simek
2012-08-10 6:39 ` Michal Simek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5024AC89.3030009@monstr.eu \
--to=monstr@monstr.eu \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.