Add Wondermedia Serial Flash controller support
v3 cover Add Wondermedia Serial Flash controller support
v3 Changes:
As requested by Artem Bityutskiy, I have seperated out the flash chip data into a seperate file (flash_jedec.(h/c)) which should be expandable by other drivers as needed.
I have also cleared up some of the sparse warnings that were being generated,
but need some help with the last one:+drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] which relates to this line:
+ u32 addr_to = (u32)info->sf_base_virt + to;
What is the correct way to get the value of ->sf_base_virt without generating a sparse warning? sf_base_virt is void __iomem *.
Tony Prisk (2):
mtd: Add a common JEDEC flash device table
mtd: vt8500: Add support for Wondermedia Serial Flash Controller
drivers/mtd/devices/Kconfig | 10 + drivers/mtd/devices/Makefile | 3 +- drivers/mtd/devices/flash_jedec.c | 96 ++++++ drivers/mtd/devices/flash_jedec.h | 30 ++ drivers/mtd/devices/wmt_sflash.c | 585 +++++++++++++++++++++++++++++++++++++ 5 files changed, 723 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/flash_jedec.c create mode 100644 drivers/mtd/devices/flash_jedec.h create mode 100644 drivers/mtd/devices/wmt_sflash.c
Signature · 1 line
1.7.9.5
PATCH v3 1/2 mtd: Add a common JEDEC flash device table
This patch adds a common JEDEC flash device table which can be expanded on as more features are required.
A simple match function is also included to query the table for a match based on the JEDEC id.
--- drivers/mtd/devices/flash_jedec.c | 96 +++++++++++++++++++++++++++++++++++++ drivers/mtd/devices/flash_jedec.h | 30 ++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 drivers/mtd/devices/flash_jedec.c create mode 100644 drivers/mtd/devices/flash_jedec.h
drivers/mtd/devices/flash_jedec.c new file +96 -0
@@ -0,0 +1,96 @@ +/* +* Copyright Tony Prisk <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <linux/bug.h> +#include <linux/err.h> +#include <linux/kernel.h> +#include <linux/types.h> + +#include "flash_jedec.h" + +/* +* Device Manufacturer IDs +* Please keep sorted by manufacturer ID +*/ +#define MFR_SPANSION 0X01 +#define MFR_EON 0X1C +#define MFR_ATMEL 0X1F +#define MFR_MICRON 0X20/* Also Numonyx & STM */ +#define MFR_INTEL 0x89 +#define MFR_FUDAN 0XA1 +#define MFR_SST 0XBF +#define MFR_MXIC 0XC2 +#define MFR_WINBOND 0XEF + +#define _ID (m, d) ((m << 16) | d) + +/* +* Flash device information +* Please keep sorted by manufacturer id, then device id +*/ +static struct flash_device_info flash_devices[] = { +/* Spansion */ + {"s25fl016" ,_ID (MFR_SPANSION ,0x0214 ),2048 }, + {"s25fl064" ,_ID (MFR_SPANSION ,0x0216 ),8192 }, +/* EON */ + {"en25p16" ,_ID (MFR_EON ,0x2015 ),2048 }, + {"en25p64" ,_ID (MFR_EON ,0x2017 ),8192 }, + {"en25f40" ,_ID (MFR_EON ,0x3113 ),512 }, + {"en25f16" ,_ID (MFR_EON ,0x3115 ),2048 }, +/* ATMEL */ + {"at25df041a" ,_ID (MFR_ATMEL ,0x4401 ),512 }, +/* Micron, STM & Numonyx */ + {"stm25p16" ,_ID (MFR_MICRON ,0x2015 ),2048 }, + {"stm25p64" ,_ID (MFR_MICRON ,0x2017 ),8192 }, +/* Fudan */ + {"fm25f04" ,_ID (MFR_FUDAN ,0x3113 ),512 }, +/* SST */ + {"sst25vf016b" ,_ID (MFR_SST ,0x2541 ),2048 }, +/* Macronix - MXIC */ + {"mx25l512" ,_ID (MFR_MXIC ,0x2010 ),64 }, + {"mx25l4005" ,_ID (MFR_MXIC ,0x2013 ),512 }, + {"mx25l1605" ,_ID (MFR_MXIC ,0x2015 ),2048 }, + {"mx25l3205" ,_ID (MFR_MXIC ,0x2016 ),4096 }, + {"mx25l6405" ,_ID (MFR_MXIC ,0x2017 ),8192 }, + {"mx25l12805" ,_ID (MFR_MXIC ,0x2018 ),16384 }, + {"mx25l1635" ,_ID (MFR_MXIC ,0x2415 ),2048 }, + {"mx25l3235" ,_ID (MFR_MXIC ,0x5E16 ),4096 }, +/* Winbond */ + {"w25x40" ,_ID (MFR_WINBOND ,0x3013 ),512 }, + {"w25x16" ,_ID (MFR_WINBOND ,0x3015 ),2048 }, + {"w25x32" ,_ID (MFR_WINBOND ,0x3016 ),4096 }, + {"w25x64" ,_ID (MFR_WINBOND ,0x3017 ),8192 }, +}; + +/* +* jedec_match_device - match a jedec id against the flash_devices table +* @jedecid: JEDEC formatted id to match +* bits 16..24: manufacturer id +* bits 0..15: device id +* Returns a valid flash_device_info* or ERR_PTR(-ENODEV) if an entry is +* not found +*/ +struct flash_device_info *jedec_match_device (u32 jedec_id) +{ +int i; +for (i =0 ; i <ARRAY_SIZE (flash_devices); i++) +if (flash_devices[i].jedec_id == jedec_id) +return &flash_devices[i]; + +return ERR_PTR (-ENODEV ); +}
drivers/mtd/devices/flash_jedec.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright Tony Prisk <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __MTD_FLASH_JEDEC +#define __MTD_FLASH_JEDEC + +struct flash_device_info { +const char *name; +u32 jedec_id; +u32 size_kb; +}; + +extern struct flash_device_info *jedec_match_device (u32 jedec_id); + +#endif
Signature · 1 line
1.7.9.5
Re: [PATCH v3 1/2] mtd: Add a common JEDEC flash device table
Tony Prisk a ?crit :
Quoted 5 lines
This patch adds a common JEDEC flash device table which can be expanded on as more features are required.
A simple match function is also included to query the table for a match based on the JEDEC id.
Why don't you use id from include/linux/mtd/cfi.h that is used by flash driver like drivers/mtd/devices/m25p80.c ?
#define CFI_MFR_AMD 0x0001
#define CFI_MFR_AMIC 0x0037
#define CFI_MFR_ATMEL 0x001F
#define CFI_MFR_EON 0x001C
#define CFI_MFR_FUJITSU 0x0004 #define CFI_MFR_HYUNDAI 0x00AD #define CFI_MFR_INTEL 0x0089 #define CFI_MFR_MACRONIX 0x00C2
#define CFI_MFR_NEC 0x0010
#define CFI_MFR_PMC 0x009D
#define CFI_MFR_SAMSUNG 0x00EC
#define CFI_MFR_SHARP 0x00B0
#define CFI_MFR_SST 0x00BF
#define CFI_MFR_ST 0x0020 /* STMicroelectronics */
#define CFI_MFR_TOSHIBA 0x0098
#define CFI_MFR_WINBOND 0x00DA
Quoted 147 lines
Signed-off-by Tony Prisk <[email protected]>--- drivers/mtd/devices/flash_jedec.c | 96 +++++++++++++++++++++++++++++++++++++ drivers/mtd/devices/flash_jedec.h | 30 ++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 drivers/mtd/devices/flash_jedec.c create mode 100644 drivers/mtd/devices/flash_jedec.hdrivers/mtd/devices/flash_jedec.c new file +96
-0@@ -0,0 +1,96 @@ +/* +* Copyright Tony Prisk <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <linux/bug.h> +#include <linux/err.h> +#include <linux/kernel.h> +#include <linux/types.h> + +#include "flash_jedec.h" + +/* +* Device Manufacturer IDs +* Please keep sorted by manufacturer ID +*/ +#define MFR_SPANSION 0X01 +#define MFR_EON 0X1C +#define MFR_ATMEL 0X1F +#define MFR_MICRON 0X20/* Also Numonyx & STM */ +#define MFR_INTEL 0x89 +#define MFR_FUDAN 0XA1 +#define MFR_SST 0XBF +#define MFR_MXIC 0XC2 +#define MFR_WINBOND 0XEF + +#define _ID (m, d) ((m << 16) | d) + +/* +* Flash device information +* Please keep sorted by manufacturer id, then device id +*/ +static struct flash_device_info flash_devices[] = { +/* Spansion */ + {"s25fl016" ,_ID (MFR_SPANSION ,0x0214 ),2048 }, + {"s25fl064" ,_ID (MFR_SPANSION ,0x0216 ),8192 }, +/* EON */ + {"en25p16" ,_ID (MFR_EON ,0x2015 ),2048 }, + {"en25p64" ,_ID (MFR_EON ,0x2017 ),8192 }, + {"en25f40" ,_ID (MFR_EON ,0x3113 ),512 }, + {"en25f16" ,_ID (MFR_EON ,0x3115 ),2048 }, +/* ATMEL */ + {"at25df041a" ,_ID (MFR_ATMEL ,0x4401 ),512 }, +/* Micron, STM & Numonyx */ + {"stm25p16" ,_ID (MFR_MICRON ,0x2015 ),2048 }, + {"stm25p64" ,_ID (MFR_MICRON ,0x2017 ),8192 }, +/* Fudan */ + {"fm25f04" ,_ID (MFR_FUDAN ,0x3113 ),512 }, +/* SST */ + {"sst25vf016b" ,_ID (MFR_SST ,0x2541 ),2048 }, +/* Macronix - MXIC */ + {"mx25l512" ,_ID (MFR_MXIC ,0x2010 ),64 }, + {"mx25l4005" ,_ID (MFR_MXIC ,0x2013 ),512 }, + {"mx25l1605" ,_ID (MFR_MXIC ,0x2015 ),2048 }, + {"mx25l3205" ,_ID (MFR_MXIC ,0x2016 ),4096 }, + {"mx25l6405" ,_ID (MFR_MXIC ,0x2017 ),8192 }, + {"mx25l12805" ,_ID (MFR_MXIC ,0x2018 ),16384 }, + {"mx25l1635" ,_ID (MFR_MXIC ,0x2415 ),2048 }, + {"mx25l3235" ,_ID (MFR_MXIC ,0x5E16 ),4096 }, +/* Winbond */ + {"w25x40" ,_ID (MFR_WINBOND ,0x3013 ),512 }, + {"w25x16" ,_ID (MFR_WINBOND ,0x3015 ),2048 }, + {"w25x32" ,_ID (MFR_WINBOND ,0x3016 ),4096 }, + {"w25x64" ,_ID (MFR_WINBOND ,0x3017 ),8192 }, +}; + +/* +* jedec_match_device - match a jedec id against the flash_devices table +* @jedecid: JEDEC formatted id to match +* bits 16..24: manufacturer id +* bits 0..15: device id +* Returns a valid flash_device_info* or ERR_PTR(-ENODEV) if an entry is +* not found +*/ +struct flash_device_info *jedec_match_device (u32 jedec_id) +{ +int i; +for (i =0 ; i <ARRAY_SIZE (flash_devices); i++) +if (flash_devices[i].jedec_id == jedec_id) +return &flash_devices[i]; + +return ERR_PTR (-ENODEV ); +}drivers/mtd/devices/flash_jedec.h new file +30
-0@@ -0,0 +1,30 @@ +/* +* Copyright Tony Prisk <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __MTD_FLASH_JEDEC +#define __MTD_FLASH_JEDEC + +struct flash_device_info { +const char *name; +u32 jedec_id; +u32 size_kb; +}; + +extern struct flash_device_info *jedec_match_device (u32 jedec_id); + +#endif
Signature · 10 lines
Matthieu Castet Ing?nieur D?veloppement Logiciel Parrot SA 174 Quai de Jemmapes 75010 Paris, France T?l: +33 (0) 1 48 03 74 78 Fax: +33 (0) 1 48 03 06 66 Email: matthieu.castet at parrot.fr http://www.parrot.biz
Re: [PATCH v3 1/2] mtd: Add a common JEDEC flash device table
Quoted 10 lines · Matthieu CASTET
Quoted 5 lines · Tony Prisk
This patch adds a common JEDEC flash device table which can be expanded on as more features are required.
A simple match function is also included to query the table for a match based on the JEDEC id.
Why don't you use id from
include/linux/mtd/cfi.hthat is used by flash driver likedrivers/mtd/devices/m25p80.c?
Thanks - have changed for v4.
Regards
Tony P
PATCH v3 2/2 mtd: vt8500: Add support for Wondermedia Serial Flash Controller
In reply to Tony PriskThis patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs.
--- drivers/mtd/devices/Kconfig | 10 + drivers/mtd/devices/Makefile | 3 +- drivers/mtd/devices/wmt_sflash.c | 585 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 597 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/wmt_sflash.c
drivers/mtd/devices/Kconfig +10 -0
@@ -128,6 +128,16 @@ config MTD_BCM47XXSFLASH registered by bcma as platform devices. This enables driver for serial flash memories (only read-only mode is implemented). +config MTD_WMT_SFLASH + tristate "WonderMedia Serial Flash Support" + depends on ARCH_VT8500 + help + Enable this option to provide support for the Wondermedia SoC serial + flash controller. + + Select M to build this driver as a module. The module will be called + 'wmt_sflash'. + config MTD_SLRAM tristate "Uncached system RAM" help
drivers/mtd/devices/Makefile +2 -1
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o obj-$(CONFIG_MTD_M25P80) += m25p80.o obj-$(CONFIG_MTD_SPEAR_SMI) += spear_smi.o obj-$(CONFIG_MTD_SST25L) += sst25l.o +obj-$(CONFIG_MTD_WMT_SFLASH) += wmt_sflash.o flash_jedec.o obj-$(CONFIG_MTD_BCM47XXSFLASH) += bcm47xxsflash.o -CFLAGS_docg3.o += -I$(src) +CFLAGS_docg3.o += -I$(src)
drivers/mtd/devices/wmt_sflash.c new file +585 -0
585 lines not on this page · raw message
Signature · 1 line
1.7.9.5