diff options
Diffstat (limited to 'drivers/mtd/chips/jedec_probe.c')
-rw-r--r-- | drivers/mtd/chips/jedec_probe.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c index 30da428eb7b9..edb306c03c0a 100644 --- a/drivers/mtd/chips/jedec_probe.c +++ b/drivers/mtd/chips/jedec_probe.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Common Flash Interface probe code. | 2 | Common Flash Interface probe code. |
3 | (C) 2000 Red Hat. GPL'd. | 3 | (C) 2000 Red Hat. GPL'd. |
4 | $Id: jedec_probe.c,v 1.63 2005/02/14 16:30:32 bjd Exp $ | 4 | $Id: jedec_probe.c,v 1.66 2005/11/07 11:14:23 gleixner Exp $ |
5 | See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5) | 5 | See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5) |
6 | for the standard this probe goes back to. | 6 | for the standard this probe goes back to. |
7 | 7 | ||
@@ -1719,7 +1719,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base, | |||
1719 | 1719 | ||
1720 | static struct mtd_info *jedec_probe(struct map_info *map); | 1720 | static struct mtd_info *jedec_probe(struct map_info *map); |
1721 | 1721 | ||
1722 | static inline u32 jedec_read_mfr(struct map_info *map, __u32 base, | 1722 | static inline u32 jedec_read_mfr(struct map_info *map, __u32 base, |
1723 | struct cfi_private *cfi) | 1723 | struct cfi_private *cfi) |
1724 | { | 1724 | { |
1725 | map_word result; | 1725 | map_word result; |
@@ -1730,7 +1730,7 @@ static inline u32 jedec_read_mfr(struct map_info *map, __u32 base, | |||
1730 | return result.x[0] & mask; | 1730 | return result.x[0] & mask; |
1731 | } | 1731 | } |
1732 | 1732 | ||
1733 | static inline u32 jedec_read_id(struct map_info *map, __u32 base, | 1733 | static inline u32 jedec_read_id(struct map_info *map, __u32 base, |
1734 | struct cfi_private *cfi) | 1734 | struct cfi_private *cfi) |
1735 | { | 1735 | { |
1736 | map_word result; | 1736 | map_word result; |
@@ -1741,7 +1741,7 @@ static inline u32 jedec_read_id(struct map_info *map, __u32 base, | |||
1741 | return result.x[0] & mask; | 1741 | return result.x[0] & mask; |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | static inline void jedec_reset(u32 base, struct map_info *map, | 1744 | static inline void jedec_reset(u32 base, struct map_info *map, |
1745 | struct cfi_private *cfi) | 1745 | struct cfi_private *cfi) |
1746 | { | 1746 | { |
1747 | /* Reset */ | 1747 | /* Reset */ |
@@ -1765,7 +1765,7 @@ static inline void jedec_reset(u32 base, struct map_info *map, | |||
1765 | * so ensure we're in read mode. Send both the Intel and the AMD command | 1765 | * so ensure we're in read mode. Send both the Intel and the AMD command |
1766 | * for this. Intel uses 0xff for this, AMD uses 0xff for NOP, so | 1766 | * for this. Intel uses 0xff for this, AMD uses 0xff for NOP, so |
1767 | * this should be safe. | 1767 | * this should be safe. |
1768 | */ | 1768 | */ |
1769 | cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); | 1769 | cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); |
1770 | /* FIXME - should have reset delay before continuing */ | 1770 | /* FIXME - should have reset delay before continuing */ |
1771 | } | 1771 | } |
@@ -1807,14 +1807,14 @@ static int cfi_jedec_setup(struct cfi_private *p_cfi, int index) | |||
1807 | printk("Found: %s\n",jedec_table[index].name); | 1807 | printk("Found: %s\n",jedec_table[index].name); |
1808 | 1808 | ||
1809 | num_erase_regions = jedec_table[index].NumEraseRegions; | 1809 | num_erase_regions = jedec_table[index].NumEraseRegions; |
1810 | 1810 | ||
1811 | p_cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL); | 1811 | p_cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL); |
1812 | if (!p_cfi->cfiq) { | 1812 | if (!p_cfi->cfiq) { |
1813 | //xx printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name); | 1813 | //xx printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name); |
1814 | return 0; | 1814 | return 0; |
1815 | } | 1815 | } |
1816 | 1816 | ||
1817 | memset(p_cfi->cfiq,0,sizeof(struct cfi_ident)); | 1817 | memset(p_cfi->cfiq,0,sizeof(struct cfi_ident)); |
1818 | 1818 | ||
1819 | p_cfi->cfiq->P_ID = jedec_table[index].CmdSet; | 1819 | p_cfi->cfiq->P_ID = jedec_table[index].CmdSet; |
1820 | p_cfi->cfiq->NumEraseRegions = jedec_table[index].NumEraseRegions; | 1820 | p_cfi->cfiq->NumEraseRegions = jedec_table[index].NumEraseRegions; |
@@ -1969,7 +1969,7 @@ static inline int jedec_match( __u32 base, | |||
1969 | cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL); | 1969 | cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL); |
1970 | /* FIXME - should have a delay before continuing */ | 1970 | /* FIXME - should have a delay before continuing */ |
1971 | 1971 | ||
1972 | match_done: | 1972 | match_done: |
1973 | return rc; | 1973 | return rc; |
1974 | } | 1974 | } |
1975 | 1975 | ||
@@ -1998,23 +1998,23 @@ static int jedec_probe_chip(struct map_info *map, __u32 base, | |||
1998 | "Probe at base(0x%08x) past the end of the map(0x%08lx)\n", | 1998 | "Probe at base(0x%08x) past the end of the map(0x%08lx)\n", |
1999 | base, map->size -1); | 1999 | base, map->size -1); |
2000 | return 0; | 2000 | return 0; |
2001 | 2001 | ||
2002 | } | 2002 | } |
2003 | /* Ensure the unlock addresses we try stay inside the map */ | 2003 | /* Ensure the unlock addresses we try stay inside the map */ |
2004 | probe_offset1 = cfi_build_cmd_addr( | 2004 | probe_offset1 = cfi_build_cmd_addr( |
2005 | cfi->addr_unlock1, | 2005 | cfi->addr_unlock1, |
2006 | cfi_interleave(cfi), | 2006 | cfi_interleave(cfi), |
2007 | cfi->device_type); | 2007 | cfi->device_type); |
2008 | probe_offset2 = cfi_build_cmd_addr( | 2008 | probe_offset2 = cfi_build_cmd_addr( |
2009 | cfi->addr_unlock1, | 2009 | cfi->addr_unlock1, |
2010 | cfi_interleave(cfi), | 2010 | cfi_interleave(cfi), |
2011 | cfi->device_type); | 2011 | cfi->device_type); |
2012 | if ( ((base + probe_offset1 + map_bankwidth(map)) >= map->size) || | 2012 | if ( ((base + probe_offset1 + map_bankwidth(map)) >= map->size) || |
2013 | ((base + probe_offset2 + map_bankwidth(map)) >= map->size)) | 2013 | ((base + probe_offset2 + map_bankwidth(map)) >= map->size)) |
2014 | { | 2014 | { |
2015 | goto retry; | 2015 | goto retry; |
2016 | } | 2016 | } |
2017 | 2017 | ||
2018 | /* Reset */ | 2018 | /* Reset */ |
2019 | jedec_reset(base, map, cfi); | 2019 | jedec_reset(base, map, cfi); |
2020 | 2020 | ||
@@ -2027,13 +2027,13 @@ static int jedec_probe_chip(struct map_info *map, __u32 base, | |||
2027 | /* FIXME - should have a delay before continuing */ | 2027 | /* FIXME - should have a delay before continuing */ |
2028 | 2028 | ||
2029 | if (!cfi->numchips) { | 2029 | if (!cfi->numchips) { |
2030 | /* This is the first time we're called. Set up the CFI | 2030 | /* This is the first time we're called. Set up the CFI |
2031 | stuff accordingly and return */ | 2031 | stuff accordingly and return */ |
2032 | 2032 | ||
2033 | cfi->mfr = jedec_read_mfr(map, base, cfi); | 2033 | cfi->mfr = jedec_read_mfr(map, base, cfi); |
2034 | cfi->id = jedec_read_id(map, base, cfi); | 2034 | cfi->id = jedec_read_id(map, base, cfi); |
2035 | DEBUG(MTD_DEBUG_LEVEL3, | 2035 | DEBUG(MTD_DEBUG_LEVEL3, |
2036 | "Search for id:(%02x %02x) interleave(%d) type(%d)\n", | 2036 | "Search for id:(%02x %02x) interleave(%d) type(%d)\n", |
2037 | cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type); | 2037 | cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type); |
2038 | for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) { | 2038 | for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) { |
2039 | if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) { | 2039 | if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) { |
@@ -2062,7 +2062,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base, | |||
2062 | return 0; | 2062 | return 0; |
2063 | } | 2063 | } |
2064 | } | 2064 | } |
2065 | 2065 | ||
2066 | /* Check each previous chip locations to see if it's an alias */ | 2066 | /* Check each previous chip locations to see if it's an alias */ |
2067 | for (i=0; i < (base >> cfi->chipshift); i++) { | 2067 | for (i=0; i < (base >> cfi->chipshift); i++) { |
2068 | unsigned long start; | 2068 | unsigned long start; |
@@ -2083,7 +2083,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base, | |||
2083 | map->name, base, start); | 2083 | map->name, base, start); |
2084 | return 0; | 2084 | return 0; |
2085 | } | 2085 | } |
2086 | 2086 | ||
2087 | /* Yes, it's actually got the device IDs as data. Most | 2087 | /* Yes, it's actually got the device IDs as data. Most |
2088 | * unfortunate. Stick the new chip in read mode | 2088 | * unfortunate. Stick the new chip in read mode |
2089 | * too and if it's the same, assume it's an alias. */ | 2089 | * too and if it's the same, assume it's an alias. */ |
@@ -2097,20 +2097,20 @@ static int jedec_probe_chip(struct map_info *map, __u32 base, | |||
2097 | } | 2097 | } |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | 2100 | ||
2101 | /* OK, if we got to here, then none of the previous chips appear to | 2101 | /* OK, if we got to here, then none of the previous chips appear to |
2102 | be aliases for the current one. */ | 2102 | be aliases for the current one. */ |
2103 | set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */ | 2103 | set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */ |
2104 | cfi->numchips++; | 2104 | cfi->numchips++; |
2105 | 2105 | ||
2106 | ok_out: | 2106 | ok_out: |
2107 | /* Put it back into Read Mode */ | 2107 | /* Put it back into Read Mode */ |
2108 | jedec_reset(base, map, cfi); | 2108 | jedec_reset(base, map, cfi); |
2109 | 2109 | ||
2110 | printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", | 2110 | printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", |
2111 | map->name, cfi_interleave(cfi), cfi->device_type*8, base, | 2111 | map->name, cfi_interleave(cfi), cfi->device_type*8, base, |
2112 | map->bankwidth*8); | 2112 | map->bankwidth*8); |
2113 | 2113 | ||
2114 | return 1; | 2114 | return 1; |
2115 | } | 2115 | } |
2116 | 2116 | ||