Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Thu, 2013-01-17 at 13:21 +0200, Artem Bityutskiy wrote: > Probably this should also be outside of the driver, since it is not > specific to this driver. Take a look at this huge array which constantly gets updated with new chips (see git log): drivers/mtd/devices/m25p80.c static const struct spi_device_id m25p_ids[] I think this should be generalized and shared across the drivers. -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Wed, 2013-01-16 at 06:53 +1300, Tony Prisk wrote: > This patch adds support for the Wondermedia serial flash controller > found on WM8505, WM8650 and WM8850 SoCs. > > Signed-off-by: Tony Prisk > --- > v2: > Change Kconfig depends to ARCH_VT8500 as this driver can't be used on other > platforms. Sparse still complains: @@ @@ +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] +drivers/mtd/devices/wmt_sflash.c:458:17: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:458:17:expected void volatile [noderef] * [sparse] +drivers/mtd/devices/wmt_sflash.c:458:17:got unsigned char [usertype] * [sparse] +drivers/mtd/devices/wmt_sflash.c:465:25: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:465:25:expected void volatile [noderef] * [sparse] +drivers/mtd/devices/wmt_sflash.c:465:25:got unsigned char [usertype] * [sparse] Also, checkpatch.pl has a valid complaint: WARNING:CONFIG_DESCRIPTION: please write a paragraph that describes the config symbol fully #26: FILE: drivers/mtd/devices/Kconfig:131: +config MTD_WMT_SFLASH total: 0 errors, 1 warnings, 636 lines checked ... > +/* WinBond */ > +#define WB_W25X40BV 0x3013 /* 512 KB */ > +#define WB_X16A 0x3015 /* 2 MB */ > +#define WB_X32 0x3016 /* 4 MB */ > +#define WB_X64 0x3017 /* 8 MB */ > + > + > +#define SF_ID(mfr, mdl) ((mfr << 16) | mdl) The flash manufacturer IDs are not specific to this driver, and should be defined in a common header. > + > +#define FLASH_UNKNOWN0x00ff > + > +struct wmt_flash_id { > + u32 id; > + u32 size; /* Size in KB */ > +}; > + > +static struct wmt_flash_id flash_ids[] = { > + { SF_ID(MFR_SPANSION, SPAN_FL016A), 2048 }, > + { SF_ID(MFR_SPANSION, SPAN_FL064A), 8192 }, > + { SF_ID(MFR_EON,EON_25P16), 2048 }, > + { SF_ID(MFR_EON,EON_25P64), 8192 }, > + { SF_ID(MFR_EON,EON_25F40), 512 }, > + { SF_ID(MFR_EON,EON_25F16), 2048 }, > + { SF_ID(MFR_ATMEL, AT_25DF041A), 512 }, > + { SF_ID(MFR_NUMONYX,NX_25P16), 2048 }, > + { SF_ID(MFR_NUMONYX,NX_25P64), 8192 }, > + { SF_ID(MFR_FUDAN, FM_25F04), 512 }, > + { SF_ID(MFR_SST,SST_VF016B),2048 }, > + { SF_ID(MFR_MXIC, MX_L512), 64 }, > + { SF_ID(MFR_MXIC, MX_L4005A), 512 }, > + { SF_ID(MFR_MXIC, MX_L1605D), 2048 }, > + { SF_ID(MFR_MXIC, MX_L3205D), 4192 }, > + { SF_ID(MFR_MXIC, MX_L6405D), 8192 }, > + { SF_ID(MFR_MXIC, MX_L1635D), 2048 }, > + { SF_ID(MFR_MXIC, MX_L3235D), 4192 }, > + { SF_ID(MFR_MXIC, MX_L12805D),16384 }, > + { SF_ID(MFR_WINBOND,WB_W25X40BV), 512 }, > + { SF_ID(MFR_WINBOND,WB_X16A), 2048 }, > + { SF_ID(MFR_WINBOND,WB_X32),4096 }, > + { SF_ID(MFR_WINBOND,WB_X64),8192 }, > + { 0, 0 }, > +}; Probably this should also be outside of the driver, since it is not specific to this driver. > +static u32 sf_get_chip_size(struct device *dev, u32 id) > +{ > + int i; > + for (i = 0; flash_ids[i].id != 0; i++) > + if (flash_ids[i].id == id) > + return flash_ids[i].size * 1024; > + > + dev_err(dev, "Unknown flash id (%08x)\n", id); > + return 0; > +} And this. -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Wed, 2013-01-16 at 06:53 +1300, Tony Prisk wrote: This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz --- v2: Change Kconfig depends to ARCH_VT8500 as this driver can't be used on other platforms. Sparse still complains: @@ @@ +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] +drivers/mtd/devices/wmt_sflash.c:458:17: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:458:17:expected void volatile [noderef] asn:2*noident [sparse] +drivers/mtd/devices/wmt_sflash.c:458:17:got unsigned char [usertype] *noident [sparse] +drivers/mtd/devices/wmt_sflash.c:465:25: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:465:25:expected void volatile [noderef] asn:2*noident [sparse] +drivers/mtd/devices/wmt_sflash.c:465:25:got unsigned char [usertype] *noident [sparse] Also, checkpatch.pl has a valid complaint: WARNING:CONFIG_DESCRIPTION: please write a paragraph that describes the config symbol fully #26: FILE: drivers/mtd/devices/Kconfig:131: +config MTD_WMT_SFLASH total: 0 errors, 1 warnings, 636 lines checked ... +/* WinBond */ +#define WB_W25X40BV 0x3013 /* 512 KB */ +#define WB_X16A 0x3015 /* 2 MB */ +#define WB_X32 0x3016 /* 4 MB */ +#define WB_X64 0x3017 /* 8 MB */ + + +#define SF_ID(mfr, mdl) ((mfr 16) | mdl) The flash manufacturer IDs are not specific to this driver, and should be defined in a common header. + +#define FLASH_UNKNOWN0x00ff + +struct wmt_flash_id { + u32 id; + u32 size; /* Size in KB */ +}; + +static struct wmt_flash_id flash_ids[] = { + { SF_ID(MFR_SPANSION, SPAN_FL016A), 2048 }, + { SF_ID(MFR_SPANSION, SPAN_FL064A), 8192 }, + { SF_ID(MFR_EON,EON_25P16), 2048 }, + { SF_ID(MFR_EON,EON_25P64), 8192 }, + { SF_ID(MFR_EON,EON_25F40), 512 }, + { SF_ID(MFR_EON,EON_25F16), 2048 }, + { SF_ID(MFR_ATMEL, AT_25DF041A), 512 }, + { SF_ID(MFR_NUMONYX,NX_25P16), 2048 }, + { SF_ID(MFR_NUMONYX,NX_25P64), 8192 }, + { SF_ID(MFR_FUDAN, FM_25F04), 512 }, + { SF_ID(MFR_SST,SST_VF016B),2048 }, + { SF_ID(MFR_MXIC, MX_L512), 64 }, + { SF_ID(MFR_MXIC, MX_L4005A), 512 }, + { SF_ID(MFR_MXIC, MX_L1605D), 2048 }, + { SF_ID(MFR_MXIC, MX_L3205D), 4192 }, + { SF_ID(MFR_MXIC, MX_L6405D), 8192 }, + { SF_ID(MFR_MXIC, MX_L1635D), 2048 }, + { SF_ID(MFR_MXIC, MX_L3235D), 4192 }, + { SF_ID(MFR_MXIC, MX_L12805D),16384 }, + { SF_ID(MFR_WINBOND,WB_W25X40BV), 512 }, + { SF_ID(MFR_WINBOND,WB_X16A), 2048 }, + { SF_ID(MFR_WINBOND,WB_X32),4096 }, + { SF_ID(MFR_WINBOND,WB_X64),8192 }, + { 0, 0 }, +}; Probably this should also be outside of the driver, since it is not specific to this driver. +static u32 sf_get_chip_size(struct device *dev, u32 id) +{ + int i; + for (i = 0; flash_ids[i].id != 0; i++) + if (flash_ids[i].id == id) + return flash_ids[i].size * 1024; + + dev_err(dev, Unknown flash id (%08x)\n, id); + return 0; +} And this. -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Thu, 2013-01-17 at 13:21 +0200, Artem Bityutskiy wrote: Probably this should also be outside of the driver, since it is not specific to this driver. Take a look at this huge array which constantly gets updated with new chips (see git log): drivers/mtd/devices/m25p80.c static const struct spi_device_id m25p_ids[] I think this should be generalized and shared across the drivers. -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Tue, 2013-01-15 at 21:36 +0200, Artem Bityutskiy wrote: > On Wed, 2013-01-16 at 06:53 +1300, Tony Prisk wrote: > > This patch adds support for the Wondermedia serial flash controller > > found on WM8505, WM8650 and WM8850 SoCs. > > > > Signed-off-by: Tony Prisk > > Would please you also send a defconfig which I can use to compile-test > this? > This should be sufficient. I haven't done a defconfig for arch-vt8500 yet as multiplatform-only support has gone through in this window and any previous defconfig would now be useless. This defconfig is based on 3.8-rc3 - some features may not be available in earlier revisions. CONFIG_EXPERIMENTAL=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y CONFIG_ARCH_VT8500_SINGLE=y # CONFIG_ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA is not set CONFIG_ARM_ARCH_TIMER=y CONFIG_AEABI=y CONFIG_HIGHMEM=y CONFIG_HIGHPTE=y CONFIG_ARM_APPENDED_DTB=y CONFIG_VFP=y CONFIG_NEON=y CONFIG_NET=y CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y CONFIG_NET_CALXEDA_XGMAC=y CONFIG_SMSC911X=y CONFIG_STMMAC_ETH=y CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y CONFIG_SERIAL_VT8500=y CONFIG_SERIAL_VT8500_CONSOLE=y CONFIG_GPIO_VT8500=y CONFIG_GPIOLIB=y CONFIG_FB=y CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FB_VT8500=y CONFIG_FB_WM8505=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_VT8500=y CONFIG_USB=y CONFIG_MMC=y CONFIG_PWM=y CONFIG_PWM_VT8500=y CONFIG_MTD=y CONFIG_MTD_WMT_SFLASH=y CONFIG_DMADEVICES=y Regards Tony P -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Tue, 2013-01-15 at 21:11 +0200, Artem Bityutskiy wrote: > On Wed, 2013-01-16 at 06:45 +1300, Tony Prisk wrote: > > On Tue, 2013-01-15 at 16:55 +0200, Artem Bityutskiy wrote: > > > On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: > > > > This patch adds support for the Wondermedia serial flash controller > > > > found on WM8505, WM8650 and WM8850 SoCs. > > > > > > > > Signed-off-by: Tony Prisk > > > > --- > > > > v2: Whitespace tidyup > > > > > > Hi, would you please take a look at these warings, identified by aiaiai: > > > > > > Successfully built configuration "x86_64_defconfig,x86_64,", results: > > > > > > --- before_patching.log > > > +++ after_patching.log > > > @@ @@ > > > +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: > > > +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects > > > argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] > > > +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: > > > +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to > > > integer of different size [-Wpointer-to-int-cast] > > > +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address > > > space of expression [sparse] > > > +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from > > > integer of different size [-Wint-to-pointer-cast] > > > +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in > > > argument 1 (different address spaces) [sparse] > > > +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile > > > [noderef] *dst [sparse] > > > +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] > > > * [sparse] > > > +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from > > > integer of different size [-Wint-to-pointer-cast] > > > +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in > > > argument 1 (different address spaces) [sparse] > > > +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile > > > [noderef] *dst [sparse] > > > +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] > > > * [sparse] > > > > > > > Apologies - This driver shouldn't be selectable for x86_64. > > It is an ARM driver for an embedded device. Will fix. > > Note, there are also warnings when it is compiled for other platforms, > not only x86_64. Take a look at them. Also note, than many warnings come > from sparse, you probably just did not run it. > I posted the patch for this problem this morning. It should only be selectable on arch-vt8500 and the new patch fixes this problem. It incorrectly depended on MTD rather than ARCH_VT8500 Regards Tony P -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Wed, 2013-01-16 at 06:53 +1300, Tony Prisk wrote: > This patch adds support for the Wondermedia serial flash controller > found on WM8505, WM8650 and WM8850 SoCs. > > Signed-off-by: Tony Prisk Would please you also send a defconfig which I can use to compile-test this? -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Wed, 2013-01-16 at 06:45 +1300, Tony Prisk wrote: > On Tue, 2013-01-15 at 16:55 +0200, Artem Bityutskiy wrote: > > On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: > > > This patch adds support for the Wondermedia serial flash controller > > > found on WM8505, WM8650 and WM8850 SoCs. > > > > > > Signed-off-by: Tony Prisk > > > --- > > > v2: Whitespace tidyup > > > > Hi, would you please take a look at these warings, identified by aiaiai: > > > > Successfully built configuration "x86_64_defconfig,x86_64,", results: > > > > --- before_patching.log > > +++ after_patching.log > > @@ @@ > > +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: > > +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects > > argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] > > +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: > > +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to > > integer of different size [-Wpointer-to-int-cast] > > +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address > > space of expression [sparse] > > +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from > > integer of different size [-Wint-to-pointer-cast] > > +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in > > argument 1 (different address spaces) [sparse] > > +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile > > [noderef] *dst [sparse] > > +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] > > * [sparse] > > +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from > > integer of different size [-Wint-to-pointer-cast] > > +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in > > argument 1 (different address spaces) [sparse] > > +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile > > [noderef] *dst [sparse] > > +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] > > * [sparse] > > > > Apologies - This driver shouldn't be selectable for x86_64. > It is an ARM driver for an embedded device. Will fix. Note, there are also warnings when it is compiled for other platforms, not only x86_64. Take a look at them. Also note, than many warnings come from sparse, you probably just did not run it. -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
[PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk --- v2: Change Kconfig depends to ARCH_VT8500 as this driver can't be used on other platforms. drivers/mtd/devices/Kconfig |7 + drivers/mtd/devices/Makefile |3 +- drivers/mtd/devices/wmt_sflash.c | 614 ++ 3 files changed, 623 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/wmt_sflash.c diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 27f80cd..0233b37 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -128,6 +128,13 @@ 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. + config MTD_SLRAM tristate "Uncached system RAM" help diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile index 395733a..10b8bec 100644 --- a/drivers/mtd/devices/Makefile +++ b/drivers/mtd/devices/Makefile @@ -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 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o -CFLAGS_docg3.o += -I$(src) \ No newline at end of file +CFLAGS_docg3.o += -I$(src) diff --git a/drivers/mtd/devices/wmt_sflash.c b/drivers/mtd/devices/wmt_sflash.c new file mode 100644 index 000..49359ea --- /dev/null +++ b/drivers/mtd/devices/wmt_sflash.c @@ -0,0 +1,614 @@ +/* + * Copyright (C) 2012 Tony Prisk + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +/* controller only supports erase size of 64KB */ +#define WMT_ERASESIZE 0x1 + +/* Serial Flash controller register offsets */ +#define SF_CHIP_SEL_0_CFG 0x000 +#define SF_CHIP_SEL_1_CFG 0x008 +#define SF_SPI_INTF_CFG0x040 +#define SF_SPI_RD_WR_CTR 0x050 +#define SF_SPI_WR_EN_CTR 0x060 +#define SF_SPI_ER_CTR 0x070 +#define SF_SPI_ER_START_ADDR 0x074 +#define SF_SPI_ERROR_STATUS0x080 +#define SF_SPI_MEM_0_SR_ACC0x100 +#define SF_SPI_MEM_1_SR_ACC0x110 +#define SF_SPI_PDWN_CTR_0 0x180 +#define SF_SPI_PDWN_CTR_1 0x190 +#define SF_SPI_PROG_CMD_CTR0x200 +#define SF_SPI_USER_CMD_VAL0x210 +#define SF_SPI_PROG_CMD_WBF0x300 /* 64 bytes */ +#define SF_SPI_PROG_CMD_RBF0x380 /* 64 bytes */ + +/* SF_SPI_WR_EN_CTR bit fields */ +#define SF_CS0_WR_EN BIT(0) +#define SF_CS1_WR_EN BIT(1) + +/* SF_SPI_ER_CTR bit fields */ +#define SF_SEC_ER_EN BIT(31) + +/* SF_SPI_ERROR_STATUS bit fields */ +#define SF_ERR_TIMEOUT BIT(31) +#define SF_ERR_WR_PROT_ERR BIT(5) +#define SF_ERR_MEM_REGION_ERR BIT(4) +#define SF_ERR_PWR_DWN_ACC_ERR BIT(3) +#define SF_ERR_PCMD_OP_ERR BIT(2) +#define SF_ERR_PCMD_ACC_ERRBIT(1) +#define SF_ERR_MASLOCK_ERR BIT(0) + +/* + * Serial Flash device manufacturers + * Please keep sorted by manufacturers ID + */ +#define MFR_SPANSION 0x01 +#define MFR_EON0x1C +#define MFR_ATMEL 0x1F +#define MFR_NUMONYX0x20 +#define MFR_FUDAN 0xA1 +#define MFR_SST0xBF +#define MFR_MXIC 0xC2 +#define MFR_WINBOND0xEF + +/* + * SF Device Models + * Please keep in the same order as the manufacturers table + */ + +/* Spansion */ +#define SPAN_FL016A0x0214 /* 2 MB */ +#define SPAN_FL064A0x0216 /* 8 MB */ + +/* Eon */ +#define EON_25P16 0x2015 /* 2 MB */ +#define EON_25P64 0x2017 /* 8 MB */ +#define EON_25F40 0x3113 /* 512 KB */ +#define EON_25F16 0x3115 /* 2 MB */ + +/* Atmel */ +#define AT_25DF041A0x4401 /* 512KB */ + +/*
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Tue, 2013-01-15 at 16:55 +0200, Artem Bityutskiy wrote: > On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: > > This patch adds support for the Wondermedia serial flash controller > > found on WM8505, WM8650 and WM8850 SoCs. > > > > Signed-off-by: Tony Prisk > > --- > > v2: Whitespace tidyup > > Hi, would you please take a look at these warings, identified by aiaiai: > > Successfully built configuration "x86_64_defconfig,x86_64,", results: > > --- before_patching.log > +++ after_patching.log > @@ @@ > +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: > +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects > argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] > +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: > +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to > integer of different size [-Wpointer-to-int-cast] > +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space > of expression [sparse] > +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from > integer of different size [-Wint-to-pointer-cast] > +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in argument > 1 (different address spaces) [sparse] > +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile [noderef] > *dst [sparse] > +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] > * [sparse] > +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from > integer of different size [-Wint-to-pointer-cast] > +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in argument > 1 (different address spaces) [sparse] > +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile [noderef] > *dst [sparse] > +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] > * [sparse] > Apologies - This driver shouldn't be selectable for x86_64. It is an ARM driver for an embedded device. Will fix. Regards Tony P -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: > This patch adds support for the Wondermedia serial flash controller > found on WM8505, WM8650 and WM8850 SoCs. > > Signed-off-by: Tony Prisk > --- > v2: Whitespace tidyup Hi, would you please take a look at these warings, identified by aiaiai: Successfully built configuration "x86_64_defconfig,x86_64,", results: --- before_patching.log +++ after_patching.log @@ @@ +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile [noderef] *dst [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] * [sparse] +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile [noderef] *dst [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] * [sparse] -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Tue, 2013-01-15 at 21:11 +0200, Artem Bityutskiy wrote: On Wed, 2013-01-16 at 06:45 +1300, Tony Prisk wrote: On Tue, 2013-01-15 at 16:55 +0200, Artem Bityutskiy wrote: On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz --- v2: Whitespace tidyup Hi, would you please take a look at these warings, identified by aiaiai: Successfully built configuration x86_64_defconfig,x86_64,, results: --- before_patching.log +++ after_patching.log @@ @@ +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] *noident [sparse] +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] *noident [sparse] Apologies - This driver shouldn't be selectable for x86_64. It is an ARM driver for an embedded device. Will fix. Note, there are also warnings when it is compiled for other platforms, not only x86_64. Take a look at them. Also note, than many warnings come from sparse, you probably just did not run it. I posted the patch for this problem this morning. It should only be selectable on arch-vt8500 and the new patch fixes this problem. It incorrectly depended on MTD rather than ARCH_VT8500 Regards Tony P -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Tue, 2013-01-15 at 21:36 +0200, Artem Bityutskiy wrote: On Wed, 2013-01-16 at 06:53 +1300, Tony Prisk wrote: This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz Would please you also send a defconfig which I can use to compile-test this? This should be sufficient. I haven't done a defconfig for arch-vt8500 yet as multiplatform-only support has gone through in this window and any previous defconfig would now be useless. This defconfig is based on 3.8-rc3 - some features may not be available in earlier revisions. CONFIG_EXPERIMENTAL=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y CONFIG_ARCH_VT8500_SINGLE=y # CONFIG_ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA is not set CONFIG_ARM_ARCH_TIMER=y CONFIG_AEABI=y CONFIG_HIGHMEM=y CONFIG_HIGHPTE=y CONFIG_ARM_APPENDED_DTB=y CONFIG_VFP=y CONFIG_NEON=y CONFIG_NET=y CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y CONFIG_NET_CALXEDA_XGMAC=y CONFIG_SMSC911X=y CONFIG_STMMAC_ETH=y CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y CONFIG_SERIAL_VT8500=y CONFIG_SERIAL_VT8500_CONSOLE=y CONFIG_GPIO_VT8500=y CONFIG_GPIOLIB=y CONFIG_FB=y CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FB_VT8500=y CONFIG_FB_WM8505=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_VT8500=y CONFIG_USB=y CONFIG_MMC=y CONFIG_PWM=y CONFIG_PWM_VT8500=y CONFIG_MTD=y CONFIG_MTD_WMT_SFLASH=y CONFIG_DMADEVICES=y Regards Tony P -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz --- v2: Whitespace tidyup Hi, would you please take a look at these warings, identified by aiaiai: Successfully built configuration x86_64_defconfig,x86_64,, results: --- before_patching.log +++ after_patching.log @@ @@ +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] *noident [sparse] +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] *noident [sparse] -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Tue, 2013-01-15 at 16:55 +0200, Artem Bityutskiy wrote: On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz --- v2: Whitespace tidyup Hi, would you please take a look at these warings, identified by aiaiai: Successfully built configuration x86_64_defconfig,x86_64,, results: --- before_patching.log +++ after_patching.log @@ @@ +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] *noident [sparse] +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] *noident [sparse] Apologies - This driver shouldn't be selectable for x86_64. It is an ARM driver for an embedded device. Will fix. Regards Tony P -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz --- v2: Change Kconfig depends to ARCH_VT8500 as this driver can't be used on other platforms. drivers/mtd/devices/Kconfig |7 + drivers/mtd/devices/Makefile |3 +- drivers/mtd/devices/wmt_sflash.c | 614 ++ 3 files changed, 623 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/wmt_sflash.c diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 27f80cd..0233b37 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -128,6 +128,13 @@ 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. + config MTD_SLRAM tristate Uncached system RAM help diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile index 395733a..10b8bec 100644 --- a/drivers/mtd/devices/Makefile +++ b/drivers/mtd/devices/Makefile @@ -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 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o -CFLAGS_docg3.o += -I$(src) \ No newline at end of file +CFLAGS_docg3.o += -I$(src) diff --git a/drivers/mtd/devices/wmt_sflash.c b/drivers/mtd/devices/wmt_sflash.c new file mode 100644 index 000..49359ea --- /dev/null +++ b/drivers/mtd/devices/wmt_sflash.c @@ -0,0 +1,614 @@ +/* + * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#include linux/io.h +#include linux/clk.h +#include linux/errno.h +#include linux/module.h +#include linux/platform_device.h + +#include linux/of.h +#include linux/of_device.h +#include linux/of_address.h + +#include linux/mtd/mtd.h + +/* controller only supports erase size of 64KB */ +#define WMT_ERASESIZE 0x1 + +/* Serial Flash controller register offsets */ +#define SF_CHIP_SEL_0_CFG 0x000 +#define SF_CHIP_SEL_1_CFG 0x008 +#define SF_SPI_INTF_CFG0x040 +#define SF_SPI_RD_WR_CTR 0x050 +#define SF_SPI_WR_EN_CTR 0x060 +#define SF_SPI_ER_CTR 0x070 +#define SF_SPI_ER_START_ADDR 0x074 +#define SF_SPI_ERROR_STATUS0x080 +#define SF_SPI_MEM_0_SR_ACC0x100 +#define SF_SPI_MEM_1_SR_ACC0x110 +#define SF_SPI_PDWN_CTR_0 0x180 +#define SF_SPI_PDWN_CTR_1 0x190 +#define SF_SPI_PROG_CMD_CTR0x200 +#define SF_SPI_USER_CMD_VAL0x210 +#define SF_SPI_PROG_CMD_WBF0x300 /* 64 bytes */ +#define SF_SPI_PROG_CMD_RBF0x380 /* 64 bytes */ + +/* SF_SPI_WR_EN_CTR bit fields */ +#define SF_CS0_WR_EN BIT(0) +#define SF_CS1_WR_EN BIT(1) + +/* SF_SPI_ER_CTR bit fields */ +#define SF_SEC_ER_EN BIT(31) + +/* SF_SPI_ERROR_STATUS bit fields */ +#define SF_ERR_TIMEOUT BIT(31) +#define SF_ERR_WR_PROT_ERR BIT(5) +#define SF_ERR_MEM_REGION_ERR BIT(4) +#define SF_ERR_PWR_DWN_ACC_ERR BIT(3) +#define SF_ERR_PCMD_OP_ERR BIT(2) +#define SF_ERR_PCMD_ACC_ERRBIT(1) +#define SF_ERR_MASLOCK_ERR BIT(0) + +/* + * Serial Flash device manufacturers + * Please keep sorted by manufacturers ID + */ +#define MFR_SPANSION 0x01 +#define MFR_EON0x1C +#define MFR_ATMEL 0x1F +#define MFR_NUMONYX0x20 +#define MFR_FUDAN 0xA1 +#define MFR_SST0xBF +#define MFR_MXIC 0xC2 +#define MFR_WINBOND0xEF + +/* + * SF Device Models + * Please keep in the same order as the manufacturers table + */ + +/* Spansion */ +#define SPAN_FL016A0x0214 /* 2 MB */ +#define SPAN_FL064A0x0216 /* 8 MB */ + +/* Eon */ +#define EON_25P16 0x2015 /* 2 MB */ +#define EON_25P64 0x2017 /* 8 MB */ +#define
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Wed, 2013-01-16 at 06:45 +1300, Tony Prisk wrote: On Tue, 2013-01-15 at 16:55 +0200, Artem Bityutskiy wrote: On Mon, 2012-12-31 at 10:00 +1300, Tony Prisk wrote: This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz --- v2: Whitespace tidyup Hi, would you please take a look at these warings, identified by aiaiai: Successfully built configuration x86_64_defconfig,x86_64,, results: --- before_patching.log +++ after_patching.log @@ @@ +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_read’: +drivers/mtd/devices/wmt_sflash.c:425:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] +drivers/mtd/devices/wmt_sflash.c: In function ‘sf_sector_write’: +drivers/mtd/devices/wmt_sflash.c:442:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] +drivers/mtd/devices/wmt_sflash.c:442:24: warning: cast removes address space of expression [sparse] +drivers/mtd/devices/wmt_sflash.c:458:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:458:31: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:458:31:got unsigned char [usertype] *noident [sparse] +drivers/mtd/devices/wmt_sflash.c:465:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] +drivers/mtd/devices/wmt_sflash.c:465:39: warning: incorrect type in argument 1 (different address spaces) [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:expected void volatile [noderef] asn:2*dst [sparse] +drivers/mtd/devices/wmt_sflash.c:465:39:got unsigned char [usertype] *noident [sparse] Apologies - This driver shouldn't be selectable for x86_64. It is an ARM driver for an embedded device. Will fix. Note, there are also warnings when it is compiled for other platforms, not only x86_64. Take a look at them. Also note, than many warnings come from sparse, you probably just did not run it. -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
Re: [PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
On Wed, 2013-01-16 at 06:53 +1300, Tony Prisk wrote: This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz Would please you also send a defconfig which I can use to compile-test this? -- Best Regards, Artem Bityutskiy signature.asc Description: This is a digitally signed message part
[PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk --- v2: Whitespace tidyup drivers/mtd/devices/Kconfig |7 + drivers/mtd/devices/Makefile |3 +- drivers/mtd/devices/wmt_sflash.c | 614 ++ 3 files changed, 623 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/wmt_sflash.c diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 27f80cd..6c4bbd4 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -128,6 +128,13 @@ 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 MTD + help + Enable this option to provide support for the Wondermedia SoC serial + flash controller. + config MTD_SLRAM tristate "Uncached system RAM" help diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile index 395733a..10b8bec 100644 --- a/drivers/mtd/devices/Makefile +++ b/drivers/mtd/devices/Makefile @@ -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 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o -CFLAGS_docg3.o += -I$(src) \ No newline at end of file +CFLAGS_docg3.o += -I$(src) diff --git a/drivers/mtd/devices/wmt_sflash.c b/drivers/mtd/devices/wmt_sflash.c new file mode 100644 index 000..49359ea --- /dev/null +++ b/drivers/mtd/devices/wmt_sflash.c @@ -0,0 +1,614 @@ +/* + * Copyright (C) 2012 Tony Prisk + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +/* controller only supports erase size of 64KB */ +#define WMT_ERASESIZE 0x1 + +/* Serial Flash controller register offsets */ +#define SF_CHIP_SEL_0_CFG 0x000 +#define SF_CHIP_SEL_1_CFG 0x008 +#define SF_SPI_INTF_CFG0x040 +#define SF_SPI_RD_WR_CTR 0x050 +#define SF_SPI_WR_EN_CTR 0x060 +#define SF_SPI_ER_CTR 0x070 +#define SF_SPI_ER_START_ADDR 0x074 +#define SF_SPI_ERROR_STATUS0x080 +#define SF_SPI_MEM_0_SR_ACC0x100 +#define SF_SPI_MEM_1_SR_ACC0x110 +#define SF_SPI_PDWN_CTR_0 0x180 +#define SF_SPI_PDWN_CTR_1 0x190 +#define SF_SPI_PROG_CMD_CTR0x200 +#define SF_SPI_USER_CMD_VAL0x210 +#define SF_SPI_PROG_CMD_WBF0x300 /* 64 bytes */ +#define SF_SPI_PROG_CMD_RBF0x380 /* 64 bytes */ + +/* SF_SPI_WR_EN_CTR bit fields */ +#define SF_CS0_WR_EN BIT(0) +#define SF_CS1_WR_EN BIT(1) + +/* SF_SPI_ER_CTR bit fields */ +#define SF_SEC_ER_EN BIT(31) + +/* SF_SPI_ERROR_STATUS bit fields */ +#define SF_ERR_TIMEOUT BIT(31) +#define SF_ERR_WR_PROT_ERR BIT(5) +#define SF_ERR_MEM_REGION_ERR BIT(4) +#define SF_ERR_PWR_DWN_ACC_ERR BIT(3) +#define SF_ERR_PCMD_OP_ERR BIT(2) +#define SF_ERR_PCMD_ACC_ERRBIT(1) +#define SF_ERR_MASLOCK_ERR BIT(0) + +/* + * Serial Flash device manufacturers + * Please keep sorted by manufacturers ID + */ +#define MFR_SPANSION 0x01 +#define MFR_EON0x1C +#define MFR_ATMEL 0x1F +#define MFR_NUMONYX0x20 +#define MFR_FUDAN 0xA1 +#define MFR_SST0xBF +#define MFR_MXIC 0xC2 +#define MFR_WINBOND0xEF + +/* + * SF Device Models + * Please keep in the same order as the manufacturers table + */ + +/* Spansion */ +#define SPAN_FL016A0x0214 /* 2 MB */ +#define SPAN_FL064A0x0216 /* 8 MB */ + +/* Eon */ +#define EON_25P16 0x2015 /* 2 MB */ +#define EON_25P64 0x2017 /* 8 MB */ +#define EON_25F40 0x3113 /* 512 KB */ +#define EON_25F16 0x3115 /* 2 MB */ + +/* Atmel */ +#define AT_25DF041A0x4401 /* 512KB */ + +/* Numonyx */ +#defineNX_25P160x2015 /* 2 MB */ +#define
[PATCH v2] mtd: vt8500: Add support for Wondermedia Serial Flash Controller
This patch adds support for the Wondermedia serial flash controller found on WM8505, WM8650 and WM8850 SoCs. Signed-off-by: Tony Prisk li...@prisktech.co.nz --- v2: Whitespace tidyup drivers/mtd/devices/Kconfig |7 + drivers/mtd/devices/Makefile |3 +- drivers/mtd/devices/wmt_sflash.c | 614 ++ 3 files changed, 623 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/wmt_sflash.c diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 27f80cd..6c4bbd4 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -128,6 +128,13 @@ 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 MTD + help + Enable this option to provide support for the Wondermedia SoC serial + flash controller. + config MTD_SLRAM tristate Uncached system RAM help diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile index 395733a..10b8bec 100644 --- a/drivers/mtd/devices/Makefile +++ b/drivers/mtd/devices/Makefile @@ -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 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o -CFLAGS_docg3.o += -I$(src) \ No newline at end of file +CFLAGS_docg3.o += -I$(src) diff --git a/drivers/mtd/devices/wmt_sflash.c b/drivers/mtd/devices/wmt_sflash.c new file mode 100644 index 000..49359ea --- /dev/null +++ b/drivers/mtd/devices/wmt_sflash.c @@ -0,0 +1,614 @@ +/* + * Copyright (C) 2012 Tony Prisk li...@prisktech.co.nz + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#include linux/io.h +#include linux/clk.h +#include linux/errno.h +#include linux/module.h +#include linux/platform_device.h + +#include linux/of.h +#include linux/of_device.h +#include linux/of_address.h + +#include linux/mtd/mtd.h + +/* controller only supports erase size of 64KB */ +#define WMT_ERASESIZE 0x1 + +/* Serial Flash controller register offsets */ +#define SF_CHIP_SEL_0_CFG 0x000 +#define SF_CHIP_SEL_1_CFG 0x008 +#define SF_SPI_INTF_CFG0x040 +#define SF_SPI_RD_WR_CTR 0x050 +#define SF_SPI_WR_EN_CTR 0x060 +#define SF_SPI_ER_CTR 0x070 +#define SF_SPI_ER_START_ADDR 0x074 +#define SF_SPI_ERROR_STATUS0x080 +#define SF_SPI_MEM_0_SR_ACC0x100 +#define SF_SPI_MEM_1_SR_ACC0x110 +#define SF_SPI_PDWN_CTR_0 0x180 +#define SF_SPI_PDWN_CTR_1 0x190 +#define SF_SPI_PROG_CMD_CTR0x200 +#define SF_SPI_USER_CMD_VAL0x210 +#define SF_SPI_PROG_CMD_WBF0x300 /* 64 bytes */ +#define SF_SPI_PROG_CMD_RBF0x380 /* 64 bytes */ + +/* SF_SPI_WR_EN_CTR bit fields */ +#define SF_CS0_WR_EN BIT(0) +#define SF_CS1_WR_EN BIT(1) + +/* SF_SPI_ER_CTR bit fields */ +#define SF_SEC_ER_EN BIT(31) + +/* SF_SPI_ERROR_STATUS bit fields */ +#define SF_ERR_TIMEOUT BIT(31) +#define SF_ERR_WR_PROT_ERR BIT(5) +#define SF_ERR_MEM_REGION_ERR BIT(4) +#define SF_ERR_PWR_DWN_ACC_ERR BIT(3) +#define SF_ERR_PCMD_OP_ERR BIT(2) +#define SF_ERR_PCMD_ACC_ERRBIT(1) +#define SF_ERR_MASLOCK_ERR BIT(0) + +/* + * Serial Flash device manufacturers + * Please keep sorted by manufacturers ID + */ +#define MFR_SPANSION 0x01 +#define MFR_EON0x1C +#define MFR_ATMEL 0x1F +#define MFR_NUMONYX0x20 +#define MFR_FUDAN 0xA1 +#define MFR_SST0xBF +#define MFR_MXIC 0xC2 +#define MFR_WINBOND0xEF + +/* + * SF Device Models + * Please keep in the same order as the manufacturers table + */ + +/* Spansion */ +#define SPAN_FL016A0x0214 /* 2 MB */ +#define SPAN_FL064A0x0216 /* 8 MB */ + +/* Eon */ +#define EON_25P16 0x2015 /* 2 MB */ +#define EON_25P64 0x2017 /* 8 MB */ +#define EON_25F40 0x3113 /* 512 KB */ +#define EON_25F16