Merge tag 'r8169-20060920-00' of git://electric-eye.fr.zoreil.com/home/romieu/linux...
[pandora-kernel.git] / drivers / mtd / chips / jedec_probe.c
index 30da428..1154dac 100644 (file)
@@ -1,14 +1,13 @@
-/* 
+/*
    Common Flash Interface probe code.
    (C) 2000 Red Hat. GPL'd.
-   $Id: jedec_probe.c,v 1.63 2005/02/14 16:30:32 bjd Exp $
+   $Id: jedec_probe.c,v 1.66 2005/11/07 11:14:23 gleixner Exp $
    See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5)
    for the standard this probe goes back to.
 
    Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com
 */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -34,6 +33,7 @@
 #define MANUFACTURER_MACRONIX  0x00C2
 #define MANUFACTURER_NEC       0x0010
 #define MANUFACTURER_PMC       0x009D
+#define MANUFACTURER_SHARP     0x00b0
 #define MANUFACTURER_SST       0x00BF
 #define MANUFACTURER_ST                0x0020
 #define MANUFACTURER_TOSHIBA   0x0098
 #define MX29LV040C     0x004F
 #define MX29LV160T     0x22C4
 #define MX29LV160B     0x2249
+#define MX29F040       0x00A4
 #define MX29F016       0x00AD
 #define MX29F002T      0x00B0
 #define MX29F004T      0x0045
 #define PM49FL004      0x006E
 #define PM49FL008      0x006A
 
+/* Sharp */
+#define LH28F640BF     0x00b0
+
 /* ST - www.st.com */
 #define M29W800DT      0x00D7
 #define M29W800DB      0x005B
@@ -1168,6 +1172,19 @@ static const struct amd_flash_info jedec_table[] = {
                        ERASEINFO(0x10000,31)
                }
        }, {
+               .mfr_id         = MANUFACTURER_MACRONIX,
+               .dev_id         = MX29F040,
+               .name           = "Macronix MX29F040",
+               .uaddr          = {
+                       [0] = MTD_UADDR_0x0555_0x02AA /* x8 */
+               },
+               .DevSize        = SIZE_512KiB,
+               .CmdSet         = P_ID_AMD_STD,
+               .NumEraseRegions= 1,
+               .regions        = {
+                       ERASEINFO(0x10000,8),
+               }
+        }, {
                .mfr_id         = MANUFACTURER_MACRONIX,
                .dev_id         = MX29F016,
                .name           = "Macronix MX29F016",
@@ -1267,6 +1284,19 @@ static const struct amd_flash_info jedec_table[] = {
                .regions        = {
                        ERASEINFO( 0x01000, 256 )
                }
+       }, {
+               .mfr_id         = MANUFACTURER_SHARP,
+               .dev_id         = LH28F640BF,
+               .name           = "LH28F640BF",
+               .uaddr          = {
+                       [0] = MTD_UADDR_UNNECESSARY,    /* x8 */
+               },
+               .DevSize        = SIZE_4MiB,
+               .CmdSet         = P_ID_INTEL_STD,
+               .NumEraseRegions= 1,
+               .regions        = {
+                       ERASEINFO(0x40000,16),
+               }
         }, {
                .mfr_id         = MANUFACTURER_SST,
                .dev_id         = SST39LF512,
@@ -1719,7 +1749,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
 
 static struct mtd_info *jedec_probe(struct map_info *map);
 
-static inline u32 jedec_read_mfr(struct map_info *map, __u32 base, 
+static inline u32 jedec_read_mfr(struct map_info *map, __u32 base,
        struct cfi_private *cfi)
 {
        map_word result;
@@ -1730,7 +1760,7 @@ static inline u32 jedec_read_mfr(struct map_info *map, __u32 base,
        return result.x[0] & mask;
 }
 
-static inline u32 jedec_read_id(struct map_info *map, __u32 base, 
+static inline u32 jedec_read_id(struct map_info *map, __u32 base,
        struct cfi_private *cfi)
 {
        map_word result;
@@ -1741,7 +1771,7 @@ static inline u32 jedec_read_id(struct map_info *map, __u32 base,
        return result.x[0] & mask;
 }
 
-static inline void jedec_reset(u32 base, struct map_info *map, 
+static inline void jedec_reset(u32 base, struct map_info *map,
        struct cfi_private *cfi)
 {
        /* Reset */
@@ -1765,7 +1795,7 @@ static inline void jedec_reset(u32 base, struct map_info *map,
         * so ensure we're in read mode.  Send both the Intel and the AMD command
         * for this.  Intel uses 0xff for this, AMD uses 0xff for NOP, so
         * this should be safe.
-        */ 
+        */
        cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
        /* FIXME - should have reset delay before continuing */
 }
@@ -1807,14 +1837,14 @@ static int cfi_jedec_setup(struct cfi_private *p_cfi, int index)
        printk("Found: %s\n",jedec_table[index].name);
 
        num_erase_regions = jedec_table[index].NumEraseRegions;
-       
+
        p_cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL);
        if (!p_cfi->cfiq) {
                //xx printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name);
                return 0;
        }
 
-       memset(p_cfi->cfiq,0,sizeof(struct cfi_ident)); 
+       memset(p_cfi->cfiq,0,sizeof(struct cfi_ident));
 
        p_cfi->cfiq->P_ID = jedec_table[index].CmdSet;
        p_cfi->cfiq->NumEraseRegions = jedec_table[index].NumEraseRegions;
@@ -1969,7 +1999,7 @@ static inline int jedec_match( __u32 base,
        cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
        /* FIXME - should have a delay before continuing */
 
- match_done:   
+ match_done:
        return rc;
 }
 
@@ -1998,23 +2028,23 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
                        "Probe at base(0x%08x) past the end of the map(0x%08lx)\n",
                        base, map->size -1);
                return 0;
-               
+
        }
        /* Ensure the unlock addresses we try stay inside the map */
        probe_offset1 = cfi_build_cmd_addr(
-               cfi->addr_unlock1, 
-               cfi_interleave(cfi), 
+               cfi->addr_unlock1,
+               cfi_interleave(cfi),
                cfi->device_type);
        probe_offset2 = cfi_build_cmd_addr(
-               cfi->addr_unlock1, 
-               cfi_interleave(cfi), 
+               cfi->addr_unlock1,
+               cfi_interleave(cfi),
                cfi->device_type);
        if (    ((base + probe_offset1 + map_bankwidth(map)) >= map->size) ||
                ((base + probe_offset2 + map_bankwidth(map)) >= map->size))
        {
                goto retry;
        }
-               
+
        /* Reset */
        jedec_reset(base, map, cfi);
 
@@ -2027,15 +2057,15 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
        /* FIXME - should have a delay before continuing */
 
        if (!cfi->numchips) {
-               /* This is the first time we're called. Set up the CFI 
+               /* This is the first time we're called. Set up the CFI
                   stuff accordingly and return */
-               
+
                cfi->mfr = jedec_read_mfr(map, base, cfi);
                cfi->id = jedec_read_id(map, base, cfi);
                DEBUG(MTD_DEBUG_LEVEL3,
-                     "Search for id:(%02x %02x) interleave(%d) type(%d)\n", 
+                     "Search for id:(%02x %02x) interleave(%d) type(%d)\n",
                        cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type);
-               for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) {
+               for (i = 0; i < ARRAY_SIZE(jedec_table); i++) {
                        if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) {
                                DEBUG( MTD_DEBUG_LEVEL3,
                                       "MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n",
@@ -2062,7 +2092,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
                        return 0;
                }
        }
-       
+
        /* Check each previous chip locations to see if it's an alias */
        for (i=0; i < (base >> cfi->chipshift); i++) {
                unsigned long start;
@@ -2083,7 +2113,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
                                       map->name, base, start);
                                return 0;
                        }
-                       
+
                        /* Yes, it's actually got the device IDs as data. Most
                         * unfortunate. Stick the new chip in read mode
                         * too and if it's the same, assume it's an alias. */
@@ -2097,20 +2127,20 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
                        }
                }
        }
-               
+
        /* OK, if we got to here, then none of the previous chips appear to
           be aliases for the current one. */
        set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */
        cfi->numchips++;
-               
+
 ok_out:
        /* Put it back into Read Mode */
        jedec_reset(base, map, cfi);
 
        printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n",
-              map->name, cfi_interleave(cfi), cfi->device_type*8, base, 
+              map->name, cfi_interleave(cfi), cfi->device_type*8, base,
               map->bankwidth*8);
-       
+
        return 1;
 }