diff options
author | Andrew Gabbasov <andrew_gabbasov@mentor.com> | 2013-05-14 12:27:52 -0500 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2013-05-23 09:47:59 +0200 |
commit | aedadf10f0eac3084105511062520b0b361dd9bf (patch) | |
tree | 3401bdcd36c707b0969d068cca3d0a990eee31f7 /include/mtd | |
parent | 8bcb6f43e98ffc76e998349e0ec32a0e359160d4 (diff) | |
download | u-boot-imx-aedadf10f0eac3084105511062520b0b361dd9bf.zip u-boot-imx-aedadf10f0eac3084105511062520b0b361dd9bf.tar.gz u-boot-imx-aedadf10f0eac3084105511062520b0b361dd9bf.tar.bz2 |
cfi_flash: Fix unaligned accesses to cfi_qry structure
Packed structure cfi_qry contains unaligned 16- and 32-bits members,
accessing which causes problems when cfi_flash driver is compiled with
-munaligned-access option: flash initialization hangs, probably
due to data error.
Since the structure is supposed to replicate the actual data layout
in CFI Flash chips, the alignment issue can't be fixed in the structure.
So, unaligned fields need using of explicit unaligned access macros.
Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Reviewed-By: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'include/mtd')
-rw-r--r-- | include/mtd/cfi_flash.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/include/mtd/cfi_flash.h b/include/mtd/cfi_flash.h index 966b5e0..b644b91 100644 --- a/include/mtd/cfi_flash.h +++ b/include/mtd/cfi_flash.h @@ -129,12 +129,16 @@ typedef union { } cfiword_t; /* CFI standard query structure */ +/* The offsets and sizes of this packed structure members correspond + * to the actual layout in CFI Flash chips. Some 16- and 32-bit members + * are unaligned and must be accessed with explicit unaligned access macros. + */ struct cfi_qry { u8 qry[3]; - u16 p_id; - u16 p_adr; - u16 a_id; - u16 a_adr; + u16 p_id; /* unaligned */ + u16 p_adr; /* unaligned */ + u16 a_id; /* unaligned */ + u16 a_adr; /* unaligned */ u8 vcc_min; u8 vcc_max; u8 vpp_min; @@ -148,10 +152,10 @@ struct cfi_qry { u8 block_erase_timeout_max; u8 chip_erase_timeout_max; u8 dev_size; - u16 interface_desc; - u16 max_buf_write_size; + u16 interface_desc; /* aligned */ + u16 max_buf_write_size; /* aligned */ u8 num_erase_regions; - u32 erase_region_info[NUM_ERASE_REGIONS]; + u32 erase_region_info[NUM_ERASE_REGIONS]; /* unaligned */ } __attribute__((packed)); struct cfi_pri_hdr { |