[U-Boot-Users] [PATCH 4/6] cfi_flash: Introduce read and write accessors
Kumar Gala
galak at kernel.crashing.org
Tue Dec 11 16:35:21 CET 2007
On Dec 11, 2007, at 9:28 AM, Haavard Skinnemoen wrote:
> Introduce flash_read{8,16,32,64) and flash_write{8,16,32,64} and use
> them to access the flash memory. This makes it clearer when the flash
> is actually being accessed; merely dereferencing a volatile pointer
> looks just like any other kind of access.
>
> Signed-off-by: Haavard Skinnemoen <hskinnemoen at atmel.com>
> ---
> drivers/mtd/cfi_flash.c | 203 ++++++++++++++++++++++++++++
> +------------------
> 1 files changed, 125 insertions(+), 78 deletions(-)
>
> diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
> index a89fcae..70a626a 100644
> --- a/drivers/mtd/cfi_flash.c
> +++ b/drivers/mtd/cfi_flash.c
> @@ -149,13 +149,6 @@ typedef union {
> unsigned long long ll;
> } cfiword_t;
>
> -typedef union {
> - volatile unsigned char *cp;
> - volatile unsigned short *wp;
> - volatile unsigned long *lp;
> - volatile unsigned long long *llp;
> -} cfiptr_t;
> -
> #define NUM_ERASE_REGIONS 4 /* max. number of erase regions */
>
> static uint flash_offset_cfi[2] = { FLASH_OFFSET_CFI,
> FLASH_OFFSET_CFI_ALT };
> @@ -178,6 +171,46 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /
> * FLASH chips info */
>
> typedef unsigned long flash_sect_t;
>
> +static void flash_write8(u8 value, void *addr)
> +{
> + *(volatile u8 *)addr = value;
> +}
> +
> +static void flash_write16(u16 value, void *addr)
> +{
> + *(volatile u16 *)addr = value;
> +}
> +
> +static void flash_write32(u32 value, void *addr)
> +{
> + *(volatile u32 *)addr = value;
> +}
> +
> +static void flash_write64(u64 value, void *addr)
> +{
> + *(volatile u64 *)addr = value;
> +}
> +
> +static u8 flash_read8(void *addr)
> +{
> + return *(volatile u8 *)addr;
> +}
> +
> +static u16 flash_read16(void *addr)
> +{
> + return *(volatile u16 *)addr;
> +}
> +
> +static u32 flash_read32(void *addr)
> +{
> + return *(volatile u32 *)addr;
> +}
> +
> +static u64 flash_read64(void *addr)
> +{
> + return *(volatile u64 *)addr;
> +}
> +
should these not use in/out macros from asm/io.h?
- k
More information about the U-Boot
mailing list