Patchworkβ [1/1] Sort flashchips defines alphabetically

login
register
about
Submitter Peter Lemenkov
Date 2010-06-17 14:41:41
Message ID <1276785701-23097-1-git-send-email-lemenkov@gmail.com>
Download mbox | patch
Permalink /patch/1525/
State New
Headers show

Comments

Peter Lemenkov - 2010-06-17 14:41:41
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
 flashchips.h |  200 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 100 insertions(+), 100 deletions(-)
Carl-Daniel Hailfinger - 2010-06-17 15:23:26
Hi Peter,

On 17.06.2010 16:41, Peter Lemenkov wrote:
> Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
>   

Thanks for your patch.
Review follows.


> --- a/flashchips.h
> +++ b/flashchips.h
> @@ -253,17 +253,17 @@
>  #define IM_29F004T		0xAF
>  
>  #define INTEL_ID		0x89	/* Intel */
> -#define I_82802AB		0xAD
> -#define I_82802AC		0xAC
>  #define E_28F004S5		0xA7
>  #define E_28F008S5		0xA6
>  #define E_28F016S5		0xAA
> -#define P28F001BXT		0x94	/* 28F001BX-T */
> +#define I_82802AB		0xAD
> +#define I_82802AC		0xAC
>  #define P28F001BXB		0x95	/* 28F001BX-B */
> -#define P28F004BT		0x78	/* 28F004BV/BE-T */
> +#define P28F001BXT		0x94	/* 28F001BX-T */
>  #define P28F004BB		0x79	/* 28F004BV/BE-B */
> -#define P28F400BT		0x70	/* 28F400BV/CV/CE-T */
> +#define P28F004BT		0x78	/* 28F004BV/BE-T */
>  #define P28F400BB		0x71	/* 28F400BV/CV/CE-B */
> +#define P28F400BT		0x70	/* 28F400BV/CV/CE-T */
>  #define SHARP_LH28F008SA	0xA2	/* Sharp chip, Intel Vendor ID */
>  #define SHARP_LH28F008SC	0xA6	/* Sharp chip, Intel Vendor ID */
>  
>   

The Intel IDs have inconsistent naming even if you ignore the Sharp IDs.
Why are some called I_foo and others E_foo and others Pfoo? That makes
no sense at all. This is not your fault, but since you're touching these
definitions anyway, could you convert them to a common INTEL_ prefix?

The rest of the patch makes sense, but there are a few problems I'm not
sure how to fix:

Quite a few vendors have multiple chips with the same ID. Right now we
simply have only one #define for such an ID, and use it for all chips
with that ID. A comment on the right side of that ID says something like
"Same as ...". The problem is that the flash ID list grew organically,
so sometimes the IDs for one chip family have names picked randomly from
the different subfamilies.

Sorting. You propose alphabetical sorting in this example:
>  #define EN_25F05		0x3110
>  #define EN_25F10		0x3111
> +#define EN_25F16		0x3115
>  #define EN_25F20		0x3112
> +#define EN_25F32		0x3116
>  #define EN_25F40		0x3113
>  #define EN_25F80		0x3114
> -#define EN_25F16		0x3115
> -#define EN_25F32		0x3116
>   

Right now the IDs are ordered by chip size which has a few advantages:
You can spot holes in the numeric IDs easily (10,11,12,13,14,15,16), and
you can spot holes in the symbolic names easily (05,10,20,40,80,16,32).
An alphabetical ordering gives us a different numeric ID order
(10,11,15,12,16,13,14) and a different symbolic name order
(05,10,16,20,32,40,80). While those orders follow alphanumeric sort
rules, we should also check if they are convenient for humans. Please
note that the ordering difference gets more complicated once we add the
EN_25F64 and EN_25F128.

Comments?

Regards,
Carl-Daniel

Patch

diff --git a/flashchips.h b/flashchips.h
index a04edef..2e1b0d7 100644
--- a/flashchips.h
+++ b/flashchips.h
@@ -40,16 +40,16 @@ 
 #define ALLIANCE_ID		0x52	/* Alliance Semiconductor */
 
 #define AMD_ID			0x01	/* AMD */
-#define AM_29DL400BT		0x0C
 #define AM_29DL400BB		0x0F
-#define AM_29DL800BT		0x4A
+#define AM_29DL400BT		0x0C
 #define AM_29DL800BB		0xCB
+#define AM_29DL800BT		0x4A
 #define AM_29F002BB		0x34	/* Same as Am29F002NBB */
 #define AM_29F002BT		0xB0	/* Same as Am29F002NBT */
 #define AM_29F004BB		0x7B
 #define AM_29F004BT		0x77
-#define AM_29F016D		0xAD
 #define AM_29F010B		0x20	/* Same as Am29F010A */
+#define AM_29F016D		0xAD
 #define AM_29F040B		0xA4
 #define AM_29F080B		0xD5
 #define AM_29F200BB		0x57
@@ -68,9 +68,9 @@ 
 #define AM_29LV080B		0x38	/* Same as Am29LV081B */
 #define AM_29LV200BB		0xBF
 #define AM_29LV200BT		0x3B
-#define AM_29LV800BB		0x5B	/* Same as Am29LV800DB */
-#define AM_29LV400BT		0xB9
 #define AM_29LV400BB		0xBA
+#define AM_29LV400BT		0xB9
+#define AM_29LV800BB		0x5B	/* Same as Am29LV800DB */
 #define AM_29LV800BT		0xDA	/* Same as Am29LV800DT */
 
 #define AMIC_ID			0x7F37	/* AMIC */
@@ -113,9 +113,9 @@ 
 #define AT_26DF161A		0x4601
 #define AT_26DF321		0x4700	/* Same as 25DF321 */
 #define AT_26F004		0x0400
-#define AT_29C040A		0xA4
 #define AT_29C010A		0xD5	
 #define AT_29C020		0xDA
+#define AT_29C040A		0xA4
 #define AT_29C512		0x5D	
 #define AT_45BR3214B		/* No ID available */
 #define AT_45CS1282		0x2920
@@ -144,9 +144,9 @@ 
 #define AT_45DB642		/* No ID available */
 #define AT_45DB642D		0x2800
 #define AT_49BV512		0x03
-#define AT_49F020		0x0B
 #define AT_49F002N		0x07	/* for AT49F002(N)  */
 #define AT_49F002NT		0x08	/* for AT49F002(N)T */
+#define AT_49F020		0x0B
 
 #define CATALYST_ID		0x31	/* Catalyst */
 
@@ -165,44 +165,44 @@ 
 #define EON_ID			0x7F1C	/* EON Silicon Devices */
 #define EON_ID_NOPREFIX		0x1C	/* EON, missing 0x7F prefix */
 #define EN_25B05		0x2010	/* Same as P05, 2^19 kbit or 2^16 kByte */
-#define EN_25B05T		0x25
 #define EN_25B05B		0x95
+#define EN_25B05T		0x25
 #define EN_25B10		0x2011	/* Same as P10 */
-#define EN_25B10T		0x40
 #define EN_25B10B		0x30
-#define EN_25B20		0x2012	/* Same as P20 */
-#define EN_25B20T		0x41
-#define EN_25B20B		0x31
-#define EN_25B40		0x2013	/* Same as P40 */
-#define EN_25B40T		0x42
-#define EN_25B40B		0x32
-#define EN_25B80		0x2014	/* Same as P80 */
-#define EN_25B80T		0x43
-#define EN_25B80B		0x33
+#define EN_25B10T		0x40
 #define EN_25B16		0x2015	/* Same as P16 */
-#define EN_25B16T		0x44
 #define EN_25B16B		0x34
+#define EN_25B16T		0x44
+#define EN_25B20		0x2012	/* Same as P20 */
+#define EN_25B20B		0x31
+#define EN_25B20T		0x41
 #define EN_25B32		0x2016	/* Same as P32 */
-#define EN_25B32T		0x45
 #define EN_25B32B		0x35
+#define EN_25B32T		0x45
+#define EN_25B40		0x2013	/* Same as P40 */
+#define EN_25B40B		0x32
+#define EN_25B40T		0x42
 #define EN_25B64		0x2017	/* Same as P64 */
-#define EN_25B64T		0x46
 #define EN_25B64B		0x36
+#define EN_25B64T		0x46
+#define EN_25B80		0x2014	/* Same as P80 */
+#define EN_25B80B		0x33
+#define EN_25B80T		0x43
 #define EN_25D16		0x3015
 #define EN_25F05		0x3110
 #define EN_25F10		0x3111
+#define EN_25F16		0x3115
 #define EN_25F20		0x3112
+#define EN_25F32		0x3116
 #define EN_25F40		0x3113
 #define EN_25F80		0x3114
-#define EN_25F16		0x3115
-#define EN_25F32		0x3116
-#define EN_29F512		0x7F21
+#define EN_29F002B		0x7F97	/* Same as EN29F002AN */
+#define EN_29F002T		0x7F92	/* Same as EN29F002A */
 #define EN_29F010		0x20
 #define EN_29F040A		0x7F04
+#define EN_29F512		0x7F21
 #define EN_29LV010		0x7F6E
 #define EN_29LV040A		0x7F4F	/* EN_29LV040(A) */
-#define EN_29F002T		0x7F92	/* Same as EN29F002A */
-#define EN_29F002B		0x7F97	/* Same as EN29F002AN */
 
 #define FUJITSU_ID		0x04	/* Fujitsu */
 #define MBM29DL400BC		0x0F
@@ -236,16 +236,16 @@ 
 #define MBM29LV800TA		0xDA	/* Same as MBM29LV800TE */
 
 #define HYUNDAI_ID		0xAD	/* Hyundai */
-#define HY_29F400T		0x23	/* Same as HY_29F400AT */
-#define HY_29F800B		0x58	/* Same as HY_29F800AB */
-#define HY_29LV800B		0x5B
-#define HY_29F040A		0xA4
-#define HY_29F400B		0xAB	/* Same as HY_29F400AB */
 #define HY_29F002		0xB0
-#define HY_29LV400T		0xB9
-#define HY_29LV400B		0xBA
+#define HY_29F040A		0xA4
 #define HY_29F080		0xD5
+#define HY_29F400B		0xAB	/* Same as HY_29F400AB */
+#define HY_29F400T		0x23	/* Same as HY_29F400AT */
+#define HY_29F800B		0x58	/* Same as HY_29F800AB */
 #define HY_29F800T		0xD6	/* Same as HY_29F800AT */
+#define HY_29LV400B		0xBA
+#define HY_29LV400T		0xB9
+#define HY_29LV800B		0x5B
 #define HY_29LV800T		0xDA
 
 #define IMT_ID			0x7F1F	/* Integrated Memory Technologies */
@@ -253,17 +253,17 @@ 
 #define IM_29F004T		0xAF
 
 #define INTEL_ID		0x89	/* Intel */
-#define I_82802AB		0xAD
-#define I_82802AC		0xAC
 #define E_28F004S5		0xA7
 #define E_28F008S5		0xA6
 #define E_28F016S5		0xAA
-#define P28F001BXT		0x94	/* 28F001BX-T */
+#define I_82802AB		0xAD
+#define I_82802AC		0xAC
 #define P28F001BXB		0x95	/* 28F001BX-B */
-#define P28F004BT		0x78	/* 28F004BV/BE-T */
+#define P28F001BXT		0x94	/* 28F001BX-T */
 #define P28F004BB		0x79	/* 28F004BV/BE-B */
-#define P28F400BT		0x70	/* 28F400BV/CV/CE-T */
+#define P28F004BT		0x78	/* 28F004BV/BE-T */
 #define P28F400BB		0x71	/* 28F400BV/CV/CE-B */
+#define P28F400BT		0x70	/* 28F400BV/CV/CE-T */
 #define SHARP_LH28F008SA	0xA2	/* Sharp chip, Intel Vendor ID */
 #define SHARP_LH28F008SC	0xA6	/* Sharp chip, Intel Vendor ID */
 
@@ -276,17 +276,17 @@ 
  * and use the same set of IDs.
  */
 #define MX_ID			0xC2	/* Macronix (MX) */
-#define MX_25L512		0x2010	/* Same as MX25V512 */
 #define MX_25L1005		0x2011
-#define MX_25L2005		0x2012
-#define MX_25L4005		0x2013	/* MX25L4005{,A} */
-#define MX_25L8005		0x2014	/* Same as MX25V8005 */
-#define MX_25L1605		0x2015	/* MX25L1605{,A,D} */
-#define MX_25L3205		0x2016	/* MX25L3205{,A} */
-#define MX_25L6405		0x2017	/* MX25L3205{,D} */
 #define MX_25L12805		0x2018	/* MX25L12805 */
+#define MX_25L1605		0x2015	/* MX25L1605{,A,D} */
 #define MX_25L1635D		0x2415
+#define MX_25L2005		0x2012
+#define MX_25L3205		0x2016	/* MX25L3205{,A} */
 #define MX_25L3235D		0x5E16	/* MX25L3225D/MX25L3235D/MX25L3237D */
+#define MX_25L4005		0x2013	/* MX25L4005{,A} */
+#define MX_25L512		0x2010	/* Same as MX25V512 */
+#define MX_25L6405		0x2017	/* MX25L3205{,D} */
+#define MX_25L8005		0x2014	/* Same as MX25V8005 */
 #define MX_29F001B		0x19
 #define MX_29F001T		0x18
 #define MX_29F002B		0x34	/* Same as MX29F002NB */
@@ -333,20 +333,20 @@ 
  */
 #define PMC_ID			0x7F9D	/* PMC */
 #define PMC_ID_NOPREFIX		0x9D	/* PMC, missing 0x7F prefix */
-#define PMC_25LV512		0x7B
 #define PMC_25LV010		0x7C
+#define PMC_25LV016B		0x14
 #define PMC_25LV020		0x7D
 #define PMC_25LV040		0x7E
 #define PMC_25LV080B		0x13
-#define PMC_25LV016B		0x14
-#define PMC_29F002T		0x1D
+#define PMC_25LV512		0x7B
 #define PMC_29F002B		0x2D
-#define PMC_39LV512		0x1B
+#define PMC_29F002T		0x1D
 #define PMC_39F010		0x1C	/* Same as Pm39LV010 */
-#define PMC_39LV020		0x3D
-#define PMC_39LV040		0x3E
 #define PMC_39F020		0x4D
 #define PMC_39F040		0x4E
+#define PMC_39LV020		0x3D
+#define PMC_39LV040		0x3E
+#define PMC_39LV512		0x1B
 #define PMC_49FL002		0x6D
 #define PMC_49FL004		0x6E
 
@@ -359,8 +359,8 @@ 
 #define SANYO_LE25FW203A	0x1600
 
 #define SHARP_ID		0xB0	/* Sharp */
-#define SHARP_LH28F008BJxxPT	0xEC
 #define SHARP_LH28F008BJxxPB	0xED
+#define SHARP_LH28F008BJxxPT	0xEC
 #define SHARP_LH28F800BVxxBTL	0x4B
 #define SHARP_LH28F800BVxxBV	0x4D
 #define SHARP_LH28F800BVxxTV	0x4C
@@ -381,61 +381,61 @@ 
  * byte of device ID is related to log(bitsize) at least for some chips.
  */
 #define SST_ID			0xBF	/* SST */
-#define SST_25WF512		0x2501
-#define SST_25WF010		0x2502
-#define SST_25WF020		0x2503
-#define SST_25WF040		0x2504
-#define SST_25VF512A_REMS	0x48	/* REMS or RES opcode */
 #define SST_25VF010_REMS	0x49	/* REMS or RES opcode */
+#define SST_25VF016B		0x2541
 #define SST_25VF020_REMS	0x43	/* REMS or RES opcode */
-#define SST_25VF040_REMS	0x44	/* REMS or RES opcode, same as SST25LF040A */
+#define SST_25VF032B		0x254A
+#define SST_25VF032B_REMS	0x4A	/* REMS or RES opcode */
 #define SST_25VF040B		0x258D
 #define SST_25VF040B_REMS	0x8D	/* REMS or RES opcode */
-#define SST_25VF080_REMS	0x80	/* REMS or RES opcode */
+#define SST_25VF040_REMS	0x44	/* REMS or RES opcode, same as SST25LF040A */
 #define SST_25VF080B		0x258E
 #define SST_25VF080B_REMS	0x8E	/* REMS or RES opcode */
-#define SST_25VF016B		0x2541
-#define SST_25VF032B		0x254A
-#define SST_25VF032B_REMS	0x4A	/* REMS or RES opcode */
+#define SST_25VF080_REMS	0x80	/* REMS or RES opcode */
+#define SST_25VF512A_REMS	0x48	/* REMS or RES opcode */
+#define SST_25WF010		0x2502
+#define SST_25WF020		0x2503
+#define SST_25WF040		0x2504
+#define SST_25WF512		0x2501
 #define SST_26VF016		0x2601
 #define SST_26VF032		0x2602
-#define SST_27SF512		0xA4
 #define SST_27SF010		0xA5
 #define SST_27SF020		0xA6
+#define SST_27SF512		0xA4
 #define SST_27VF010		0xA9
 #define SST_27VF020		0xAA
 #define SST_28SF040		0x04
-#define SST_29EE512		0x5D
 #define SST_29EE010		0x07
-#define SST_29LE010		0x08	/* Same as SST29VE010 */
 #define SST_29EE020A		0x10	/* Same as SST29EE020 */
+#define SST_29EE512		0x5D
+#define SST_29LE010		0x08	/* Same as SST29VE010 */
 #define SST_29LE020		0x12	/* Same as SST29VE020 */
 #define SST_29SF020		0x24
-#define SST_29VF020		0x25
 #define SST_29SF040		0x13
+#define SST_29VF020		0x25
 #define SST_29VF040		0x14
-#define SST_39SF512		0xB4
 #define SST_39SF010		0xB5
 #define SST_39SF020		0xB6	/* Same as 39SF020A */
 #define SST_39SF040		0xB7
-#define SST_39VF512		0xD4
+#define SST_39SF512		0xB4
 #define SST_39VF010		0xD5
 #define SST_39VF020		0xD6	/* Same as 39LF020 */
 #define SST_39VF040		0xD7	/* Same as 39LF040 */
 #define SST_39VF080		0xD8	/* Same as 39LF080/39VF080/39VF088 */
-#define SST_49LF040B		0x50
-#define SST_49LF040		0x51
-#define SST_49LF020		0x61
-#define SST_49LF020A		0x52
-#define SST_49LF030A		0x1C
-#define SST_49LF080A		0x5B
+#define SST_39VF512		0xD4
 #define SST_49LF002A		0x57
 #define SST_49LF003A		0x1B
 #define SST_49LF004A		0x60	/* Same as 49LF004B */
-#define SST_49LF008A		0x5A
 #define SST_49LF004C		0x54
+#define SST_49LF008A		0x5A
 #define SST_49LF008C		0x59
 #define SST_49LF016C		0x5C
+#define SST_49LF020		0x61
+#define SST_49LF020A		0x52
+#define SST_49LF030A		0x1C
+#define SST_49LF040		0x51
+#define SST_49LF040B		0x50
+#define SST_49LF080A		0x5B
 #define SST_49LF160C		0x4C
 
 /*
@@ -447,52 +447,52 @@ 
 #define ST_M25P05_RES		0x10	/* Same code as M25P10. */
 #define ST_M25P10A		0x2011
 #define ST_M25P10_RES		0x10	/* Same code as M25P05. */
+#define ST_M25P128		0x2018
+#define ST_M25P16		0x2015
 #define ST_M25P20		0x2012
+#define ST_M25P32		0x2016
 #define ST_M25P40		0x2013
 #define ST_M25P40_RES		0x12
-#define ST_M25P80		0x2014
-#define ST_M25P16		0x2015
-#define ST_M25P32		0x2016
 #define ST_M25P64		0x2017
-#define ST_M25P128		0x2018
+#define ST_M25P80		0x2014
 #define ST_M25PE10		0x8011
+#define ST_M25PE16		0x8015
 #define ST_M25PE20		0x8012
 #define ST_M25PE40		0x8013
 #define ST_M25PE80		0x8014
-#define ST_M25PE16		0x8015
-#define ST_M50FLW040A		0x08
-#define ST_M50FLW040B		0x28
-#define ST_M50FLW080A		0x80
-#define ST_M50FLW080B		0x81
-#define ST_M50FW002		0x29
-#define ST_M50FW040		0x2C
-#define ST_M50FW080		0x2D
-#define ST_M50FW016		0x2E
-#define ST_M50LPW116		0x30
 #define ST_M29F002B		0x34	/* Same as M29F002BB */
 #define ST_M29F002T		0xB0	/* Same as M29F002BT/M29F002NT/M29F002BNT */
 #define ST_M29F040B		0xE2	/* Same as M29F040 */
 #define ST_M29F080		0xF1
-#define ST_M29F200BT		0xD3
 #define ST_M29F200BB		0xD4
-#define ST_M29F400BT		0xD5	/* Same as M29F400T */
+#define ST_M29F200BT		0xD3
 #define ST_M29F400BB		0xD6	/* Same as M29F400B */
+#define ST_M29F400BT		0xD5	/* Same as M29F400T */
 #define ST_M29F800DB		0x58
 #define ST_M29F800DT		0xEC
 #define ST_M29W010B		0x23
 #define ST_M29W040B		0xE3
 #define ST_M29W512B		0x27
+#define ST_M50FLW040A		0x08
+#define ST_M50FLW040B		0x28
+#define ST_M50FLW080A		0x80
+#define ST_M50FLW080B		0x81
+#define ST_M50FW002		0x29
+#define ST_M50FW016		0x2E
+#define ST_M50FW040		0x2C
+#define ST_M50FW080		0x2D
+#define ST_M50LPW116		0x30
 
 #define SYNCMOS_ID		0x40	/* SyncMOS and Mosel Vitelic */
+#define S29C31004T		0x63
 #define S29C51001T		0x01
 #define S29C51002T		0x02
 #define S29C51004T		0x03
-#define S29C31004T		0x63
 
 #define TI_ID			0x97	/* Texas Instruments */
 #define TI_OLD_ID		0x01	/* TI chips from last century */
-#define TI_TMS29F002RT		0xB0
 #define TI_TMS29F002RB		0x34
+#define TI_TMS29F002RT		0xB0
 
 /*
  * W25X chips are SPI, first byte of device ID is memory type, second
@@ -500,26 +500,26 @@ 
  */
 #define WINBOND_ID		0xDA	/* Winbond */
 #define WINBOND_NEX_ID		0xEF	/* Winbond (ex Nexcom) serial flashes */
+#define W_25Q16			0x4015
+#define W_25Q32			0x4016
+#define W_25Q80			0x4014
 #define W_25X10			0x3011
-#define W_25X20			0x3012
-#define W_25X40			0x3013
-#define W_25X80			0x3014
 #define W_25X16			0x3015
+#define W_25X20			0x3012
 #define W_25X32			0x3016
+#define W_25X40			0x3013
 #define W_25X64			0x3017
-#define W_25Q80			0x4014
-#define W_25Q16			0x4015
-#define W_25Q32			0x4016
+#define W_25X80			0x3014
 #define W_29C011		0xC1
 #define W_29C020C		0x45	/* Same as W29C020 and ASD AE29F2008 */
 #define W_29C040P		0x46	/* Same as W29C040 */
 #define W_29EE011		0xC1
 #define W_39L020		0xB5
 #define W_39L040		0xB6
-#define W_39V040FA		0x34
 #define W_39V040A		0x3D
 #define W_39V040B		0x54
 #define W_39V040C		0x50
+#define W_39V040FA		0x34
 #define W_39V080A		0xD0
 #define W_39V080FA		0xD3
 #define W_39V080FA_DM		0x93