Commit a36cf686 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'mtd/for-4.20' of git://git.infradead.org/linux-mtd

Pull mtd updates from Boris Brezillon:
 "SPI NOR core changes:
   - Support non-uniform erase size
   - Support controllers with limited TX fifo size

 Driver changes:
   - m25p80: Re-issue a WREN command after each write access
   - cadence: Pass a proper dir value to dma_[un]map_single()
   - fsl-qspi: Check fsl_qspi_get_seqid() return val make sure 4B
     addressing opcodes are properly handled
   - intel-spi: Add a new PCI entry for Ice Lake

 Raw NAND core changes:
   - Two batchs of cleanups of the NAND API, including:
      * Deprecating a lot of interfaces (now replaced by ->exec_op()).
      * Moving code in separate drivers (JEDEC, ONFI), in private files
        (internals), in platform drivers, etc.
      * Functions/structures reordering.
      * Exclusive use of the nand_chip structure instead of the MTD one
        all across the subsystem.
   - Addition of the nand_wait_readrdy/rdy_op() helpers.

 Raw NAND controllers drivers changes:
   - Various coccinelle patches.
   - Marvell:
      * Use regmap_update_bits() for syscon access.
      * More documentation.
      * BCH failure path rework.
      * More layouts to be supported.
      * IRQ handler complete() condition fixed.
   - Fsl_ifc:
      * SRAM initialization fixed for newer controller versions.
   - Denali:
      * Fix licenses mismatch and use a SPDX tag.
      * Set SPARE_AREA_SKIP_BYTES register to 8 if unset.
   - Qualcomm:
      * Do not include dma-direct.h.
   - Docg4:
      * Removed.
   - Ams-delta:
      * Use of a GPIO lookup table
      * Internal machinery changes.

 Raw NAND chip drivers changes:
   - Toshiba:
      * Add support for Toshiba memory BENAND
      * Pass a single nand_chip object to the status helper.
   - ESMT:
      * New driver to retrieve the ECC requirements from the 5th ID
        byte.

  MTD changes:
   - physmap cleanups/fixe
   - gpio-addr-flash cleanups/fixes"

* tag 'mtd/for-4.20' of git://git.infradead.org/linux-mtd: (93 commits)
  jffs2: free jffs2_sb_info through jffs2_kill_sb()
  mtd: spi-nor: fsl-quadspi: fix read error for flash size larger than 16MB
  mtd: spi-nor: intel-spi: Add support for Intel Ice Lake SPI serial flash
  mtd: maps: gpio-addr-flash: Convert to gpiod
  mtd: maps: gpio-addr-flash: Replace array with an integer
  mtd: maps: gpio-addr-flash: Use order instead of size
  mtd: spi-nor: fsl-quadspi: Don't let -EINVAL on the bus
  mtd: devices: m25p80: Make sure WRITE_EN is issued before each write
  mtd: spi-nor: Support controllers with limited TX FIFO size
  mtd: spi-nor: cadence-quadspi: Use proper enum for dma_[un]map_single
  mtd: spi-nor: parse SFDP Sector Map Parameter Table
  mtd: spi-nor: add support to non-uniform SFDP SPI NOR flash memories
  mtd: rawnand: marvell: fix the IRQ handler complete() condition
  mtd: rawnand: denali: set SPARE_AREA_SKIP_BYTES register to 8 if unset
  mtd: rawnand: r852: fix spelling mistake "card_registred" -> "card_registered"
  mtd: rawnand: toshiba: Pass a single nand_chip object to the status helper
  mtd: maps: gpio-addr-flash: Use devm_* functions
  mtd: maps: gpio-addr-flash: Fix ioremapped size
  mtd: maps: gpio-addr-flash: Replace custom printk
  mtd: physmap_of: Release resources on error
  ...
parents b8e445b6 042c1a5a
...@@ -180,10 +180,10 @@ by a chip select decoder. ...@@ -180,10 +180,10 @@ by a chip select decoder.
{ {
struct nand_chip *this = mtd_to_nand(mtd); struct nand_chip *this = mtd_to_nand(mtd);
switch(cmd){ switch(cmd){
case NAND_CTL_SETCLE: this->IO_ADDR_W |= CLE_ADRR_BIT; break; case NAND_CTL_SETCLE: this->legacy.IO_ADDR_W |= CLE_ADRR_BIT; break;
case NAND_CTL_CLRCLE: this->IO_ADDR_W &= ~CLE_ADRR_BIT; break; case NAND_CTL_CLRCLE: this->legacy.IO_ADDR_W &= ~CLE_ADRR_BIT; break;
case NAND_CTL_SETALE: this->IO_ADDR_W |= ALE_ADRR_BIT; break; case NAND_CTL_SETALE: this->legacy.IO_ADDR_W |= ALE_ADRR_BIT; break;
case NAND_CTL_CLRALE: this->IO_ADDR_W &= ~ALE_ADRR_BIT; break; case NAND_CTL_CLRALE: this->legacy.IO_ADDR_W &= ~ALE_ADRR_BIT; break;
} }
} }
...@@ -197,7 +197,7 @@ to read back the state of the pin. The function has no arguments and ...@@ -197,7 +197,7 @@ to read back the state of the pin. The function has no arguments and
should return 0, if the device is busy (R/B pin is low) and 1, if the should return 0, if the device is busy (R/B pin is low) and 1, if the
device is ready (R/B pin is high). If the hardware interface does not device is ready (R/B pin is high). If the hardware interface does not
give access to the ready busy pin, then the function must not be defined give access to the ready busy pin, then the function must not be defined
and the function pointer this->dev_ready is set to NULL. and the function pointer this->legacy.dev_ready is set to NULL.
Init function Init function
------------- -------------
...@@ -235,18 +235,18 @@ necessary information about the device. ...@@ -235,18 +235,18 @@ necessary information about the device.
} }
/* Set address of NAND IO lines */ /* Set address of NAND IO lines */
this->IO_ADDR_R = baseaddr; this->legacy.IO_ADDR_R = baseaddr;
this->IO_ADDR_W = baseaddr; this->legacy.IO_ADDR_W = baseaddr;
/* Reference hardware control function */ /* Reference hardware control function */
this->hwcontrol = board_hwcontrol; this->hwcontrol = board_hwcontrol;
/* Set command delay time, see datasheet for correct value */ /* Set command delay time, see datasheet for correct value */
this->chip_delay = CHIP_DEPENDEND_COMMAND_DELAY; this->legacy.chip_delay = CHIP_DEPENDEND_COMMAND_DELAY;
/* Assign the device ready function, if available */ /* Assign the device ready function, if available */
this->dev_ready = board_dev_ready; this->legacy.dev_ready = board_dev_ready;
this->eccmode = NAND_ECC_SOFT; this->eccmode = NAND_ECC_SOFT;
/* Scan to find existence of the device */ /* Scan to find existence of the device */
if (nand_scan (board_mtd, 1)) { if (nand_scan (this, 1)) {
err = -ENXIO; err = -ENXIO;
goto out_ior; goto out_ior;
} }
...@@ -277,7 +277,7 @@ unregisters the partitions in the MTD layer. ...@@ -277,7 +277,7 @@ unregisters the partitions in the MTD layer.
static void __exit board_cleanup (void) static void __exit board_cleanup (void)
{ {
/* Release resources, unregister device */ /* Release resources, unregister device */
nand_release (board_mtd); nand_release (mtd_to_nand(board_mtd));
/* unmap physical address */ /* unmap physical address */
iounmap(baseaddr); iounmap(baseaddr);
...@@ -336,17 +336,17 @@ connected to an address decoder. ...@@ -336,17 +336,17 @@ connected to an address decoder.
struct nand_chip *this = mtd_to_nand(mtd); struct nand_chip *this = mtd_to_nand(mtd);
/* Deselect all chips */ /* Deselect all chips */
this->IO_ADDR_R &= ~BOARD_NAND_ADDR_MASK; this->legacy.IO_ADDR_R &= ~BOARD_NAND_ADDR_MASK;
this->IO_ADDR_W &= ~BOARD_NAND_ADDR_MASK; this->legacy.IO_ADDR_W &= ~BOARD_NAND_ADDR_MASK;
switch (chip) { switch (chip) {
case 0: case 0:
this->IO_ADDR_R |= BOARD_NAND_ADDR_CHIP0; this->legacy.IO_ADDR_R |= BOARD_NAND_ADDR_CHIP0;
this->IO_ADDR_W |= BOARD_NAND_ADDR_CHIP0; this->legacy.IO_ADDR_W |= BOARD_NAND_ADDR_CHIP0;
break; break;
.... ....
case n: case n:
this->IO_ADDR_R |= BOARD_NAND_ADDR_CHIPn; this->legacy.IO_ADDR_R |= BOARD_NAND_ADDR_CHIPn;
this->IO_ADDR_W |= BOARD_NAND_ADDR_CHIPn; this->legacy.IO_ADDR_W |= BOARD_NAND_ADDR_CHIPn;
break; break;
} }
} }
......
About this document
===================
Some notes about Marvell's NAND controller available in PXA and Armada 370/XP
SoC (aka NFCv1 and NFCv2), with an emphasis on the latter.
NFCv2 controller background
===========================
The controller has a 2176 bytes FIFO buffer. Therefore, in order to support
larger pages, I/O operations on 4 KiB and 8 KiB pages is done with a set of
chunked transfers.
For instance, if we choose a 2048 data chunk and set "BCH" ECC (see below)
we'll have this layout in the pages:
------------------------------------------------------------------------------
| 2048B data | 32B spare | 30B ECC || 2048B data | 32B spare | 30B ECC | ... |
------------------------------------------------------------------------------
The driver reads the data and spare portions independently and builds an internal
buffer with this layout (in the 4 KiB page case):
------------------------------------------
| 4096B data | 64B spare |
------------------------------------------
Also, for the READOOB command the driver disables the ECC and reads a 'spare + ECC'
OOB, one per chunk read.
-------------------------------------------------------------------
| 4096B data | 32B spare | 30B ECC | 32B spare | 30B ECC |
-------------------------------------------------------------------
So, in order to achieve reading (for instance), we issue several READ0 commands
(with some additional controller-specific magic) and read two chunks of 2080B
(2048 data + 32 spare) each.
The driver accommodates this data to expose the NAND core a contiguous buffer
(4096 data + spare) or (4096 + spare + ECC + spare + ECC).
ECC
===
The controller has built-in hardware ECC capabilities. In addition it is
configurable between two modes: 1) Hamming, 2) BCH.
Note that the actual BCH mode: BCH-4 or BCH-8 will depend on the way
the controller is configured to transfer the data.
In the BCH mode the ECC code will be calculated for each transferred chunk
and expected to be located (when reading/programming) right after the spare
bytes as the figure above shows.
So, repeating the above scheme, a 2048B data chunk will be followed by 32B
spare, and then the ECC controller will read/write the ECC code (30B in
this case):
------------------------------------
| 2048B data | 32B spare | 30B ECC |
------------------------------------
If the ECC mode is 'BCH' then the ECC is *always* 30 bytes long.
If the ECC mode is 'Hamming' the ECC is 6 bytes long, for each 512B block.
So in Hamming mode, a 2048B page will have a 24B ECC.
Despite all of the above, the controller requires the driver to only read or
write in multiples of 8-bytes, because the data buffer is 64-bits.
OOB
===
Because of the above scheme, and because the "spare" OOB is really located in
the middle of a page, spare OOB cannot be read or write independently of the
data area. In other words, in order to read the OOB (aka READOOB), the entire
page (aka READ0) has to be read.
In the same sense, in order to write to the spare OOB the driver has to write
an *entire* page.
Factory bad blocks handling
===========================
Given the ECC BCH requires to layout the device's pages in a split
data/OOB/data/OOB way, the controller has a view of the flash page that's
different from the specified (aka the manufacturer's) view. In other words,
Factory view:
-----------------------------------------------
| Data |x OOB |
-----------------------------------------------
Driver's view:
-----------------------------------------------
| Data | OOB | Data x | OOB |
-----------------------------------------------
It can be seen from the above, that the factory bad block marker must be
searched within the 'data' region, and not in the usual OOB region.
In addition, this means under regular usage the driver will write such
position (since it belongs to the data region) and every used block is
likely to be marked as bad.
For this reason, marking the block as bad in the OOB is explicitly
disabled by using the NAND_BBT_NO_OOB_BBM option in the driver. The rationale
for this is that there's no point in marking a block as bad, because good
blocks are also 'marked as bad' (in the OOB BBM sense) under normal usage.
Instead, the driver relies on the bad block table alone, and should only perform
the bad block scan on the very first time (when the device hasn't been used).
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/rawnand.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <linux/platform_data/video-ep93xx.h> #include <linux/platform_data/video-ep93xx.h>
...@@ -43,12 +42,11 @@ ...@@ -43,12 +42,11 @@
#define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */ #define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */
#define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */ #define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */
#define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40) #define NAND_CTRL_ADDR(chip) (chip->legacy.IO_ADDR_W + 0x40)
static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, static void snappercl15_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
static u16 nand_state = SNAPPERCL15_NAND_WPN; static u16 nand_state = SNAPPERCL15_NAND_WPN;
u16 set; u16 set;
...@@ -70,13 +68,12 @@ static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, ...@@ -70,13 +68,12 @@ static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
__raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W); __raw_writew((cmd & 0xff) | nand_state,
chip->legacy.IO_ADDR_W);
} }
static int snappercl15_nand_dev_ready(struct mtd_info *mtd) static int snappercl15_nand_dev_ready(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY); return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY);
} }
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/spi/mmc_spi.h> #include <linux/spi/mmc_spi.h>
...@@ -76,13 +75,11 @@ static void __init ts72xx_map_io(void) ...@@ -76,13 +75,11 @@ static void __init ts72xx_map_io(void)
#define TS72XX_NAND_CONTROL_ADDR_LINE 22 /* 0xN0400000 */ #define TS72XX_NAND_CONTROL_ADDR_LINE 22 /* 0xN0400000 */
#define TS72XX_NAND_BUSY_ADDR_LINE 23 /* 0xN0800000 */ #define TS72XX_NAND_BUSY_ADDR_LINE 23 /* 0xN0800000 */
static void ts72xx_nand_hwcontrol(struct mtd_info *mtd, static void ts72xx_nand_hwcontrol(struct nand_chip *chip,
int cmd, unsigned int ctrl) int cmd, unsigned int ctrl)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_CTRL_CHANGE) {
void __iomem *addr = chip->IO_ADDR_R; void __iomem *addr = chip->legacy.IO_ADDR_R;
unsigned char bits; unsigned char bits;
addr += (1 << TS72XX_NAND_CONTROL_ADDR_LINE); addr += (1 << TS72XX_NAND_CONTROL_ADDR_LINE);
...@@ -96,13 +93,12 @@ static void ts72xx_nand_hwcontrol(struct mtd_info *mtd, ...@@ -96,13 +93,12 @@ static void ts72xx_nand_hwcontrol(struct mtd_info *mtd,
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
__raw_writeb(cmd, chip->IO_ADDR_W); __raw_writeb(cmd, chip->legacy.IO_ADDR_W);
} }
static int ts72xx_nand_device_ready(struct mtd_info *mtd) static int ts72xx_nand_device_ready(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); void __iomem *addr = chip->legacy.IO_ADDR_R;
void __iomem *addr = chip->IO_ADDR_R;
addr += (1 << TS72XX_NAND_BUSY_ADDR_LINE); addr += (1 << TS72XX_NAND_BUSY_ADDR_LINE);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/memory.h> #include <linux/memory.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
...@@ -129,30 +129,29 @@ static void qong_init_nor_mtd(void) ...@@ -129,30 +129,29 @@ static void qong_init_nor_mtd(void)
/* /*
* Hardware specific access to control-lines * Hardware specific access to control-lines
*/ */
static void qong_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) static void qong_nand_cmd_ctrl(struct nand_chip *nand_chip, int cmd,
unsigned int ctrl)
{ {
struct nand_chip *nand_chip = mtd_to_nand(mtd);
if (cmd == NAND_CMD_NONE) if (cmd == NAND_CMD_NONE)
return; return;
if (ctrl & NAND_CLE) if (ctrl & NAND_CLE)
writeb(cmd, nand_chip->IO_ADDR_W + (1 << 24)); writeb(cmd, nand_chip->legacy.IO_ADDR_W + (1 << 24));
else else
writeb(cmd, nand_chip->IO_ADDR_W + (1 << 23)); writeb(cmd, nand_chip->legacy.IO_ADDR_W + (1 << 23));
} }
/* /*
* Read the Device Ready pin. * Read the Device Ready pin.
*/ */
static int qong_nand_device_ready(struct mtd_info *mtd) static int qong_nand_device_ready(struct nand_chip *chip)
{ {
return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_NFRB)); return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_NFRB));
} }
static void qong_nand_select_chip(struct mtd_info *mtd, int chip) static void qong_nand_select_chip(struct nand_chip *chip, int cs)
{ {
if (chip >= 0) if (cs >= 0)
gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 0); gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 0);
else else
gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 1); gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 1);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/platnand.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <asm/types.h> #include <asm/types.h>
...@@ -75,9 +76,8 @@ static struct mtd_partition ixdp425_partitions[] = { ...@@ -75,9 +76,8 @@ static struct mtd_partition ixdp425_partitions[] = {
}; };
static void static void
ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) ixdp425_flash_nand_cmd_ctrl(struct nand_chip *this, int cmd, unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
int offset = (int)nand_get_controller_data(this); int offset = (int)nand_get_controller_data(this);
if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_CTRL_CHANGE) {
...@@ -93,7 +93,7 @@ ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) ...@@ -93,7 +93,7 @@ ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
writeb(cmd, this->IO_ADDR_W + offset); writeb(cmd, this->legacy.IO_ADDR_W + offset);
} }
static struct platform_nand_data ixdp425_flash_nand_data = { static struct platform_nand_data ixdp425_flash_nand_data = {
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/smc91x.h> #include <linux/smc91x.h>
...@@ -186,7 +185,7 @@ static struct platform_device nor_device = { ...@@ -186,7 +185,7 @@ static struct platform_device nor_device = {
#define FSAMPLE_NAND_RB_GPIO_PIN 62 #define FSAMPLE_NAND_RB_GPIO_PIN 62
static int nand_dev_ready(struct mtd_info *mtd) static int nand_dev_ready(struct nand_chip *chip)
{ {
return gpio_get_value(FSAMPLE_NAND_RB_GPIO_PIN); return gpio_get_value(FSAMPLE_NAND_RB_GPIO_PIN);
} }
......
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/mfd/tps65010.h> #include <linux/mfd/tps65010.h>
...@@ -182,7 +181,7 @@ static struct mtd_partition h2_nand_partitions[] = { ...@@ -182,7 +181,7 @@ static struct mtd_partition h2_nand_partitions[] = {
#define H2_NAND_RB_GPIO_PIN 62 #define H2_NAND_RB_GPIO_PIN 62
static int h2_nand_dev_ready(struct mtd_info *mtd) static int h2_nand_dev_ready(struct nand_chip *chip)
{ {
return gpio_get_value(H2_NAND_RB_GPIO_PIN); return gpio_get_value(H2_NAND_RB_GPIO_PIN);
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/input.h> #include <linux/input.h>
...@@ -185,7 +185,7 @@ static struct mtd_partition nand_partitions[] = { ...@@ -185,7 +185,7 @@ static struct mtd_partition nand_partitions[] = {
#define H3_NAND_RB_GPIO_PIN 10 #define H3_NAND_RB_GPIO_PIN 10
static int nand_dev_ready(struct mtd_info *mtd) static int nand_dev_ready(struct nand_chip *chip)
{ {
return gpio_get_value(H3_NAND_RB_GPIO_PIN); return gpio_get_value(H3_NAND_RB_GPIO_PIN);
} }
......
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
#include "common.h" #include "common.h"
void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) void omap1_nand_cmd_ctl(struct nand_chip *this, int cmd, unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
unsigned long mask; unsigned long mask;
if (cmd == NAND_CMD_NONE) if (cmd == NAND_CMD_NONE)
...@@ -32,6 +31,6 @@ void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) ...@@ -32,6 +31,6 @@ void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
if (ctrl & NAND_ALE) if (ctrl & NAND_ALE)
mask |= 0x04; mask |= 0x04;
writeb(cmd, this->IO_ADDR_W + mask); writeb(cmd, this->legacy.IO_ADDR_W + mask);
} }
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/smc91x.h> #include <linux/smc91x.h>
...@@ -144,7 +143,7 @@ static struct platform_device nor_device = { ...@@ -144,7 +143,7 @@ static struct platform_device nor_device = {
#define P2_NAND_RB_GPIO_PIN 62 #define P2_NAND_RB_GPIO_PIN 62
static int nand_dev_ready(struct mtd_info *mtd) static int nand_dev_ready(struct nand_chip *chip)
{ {
return gpio_get_value(P2_NAND_RB_GPIO_PIN); return gpio_get_value(P2_NAND_RB_GPIO_PIN);
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#ifndef __ARCH_ARM_MACH_OMAP1_COMMON_H #ifndef __ARCH_ARM_MACH_OMAP1_COMMON_H
#define __ARCH_ARM_MACH_OMAP1_COMMON_H #define __ARCH_ARM_MACH_OMAP1_COMMON_H
#include <linux/mtd/mtd.h>
#include <linux/platform_data/i2c-omap.h> #include <linux/platform_data/i2c-omap.h>
#include <linux/reboot.h> #include <linux/reboot.h>
...@@ -82,7 +81,8 @@ void omap1_restart(enum reboot_mode, const char *); ...@@ -82,7 +81,8 @@ void omap1_restart(enum reboot_mode, const char *);
extern void __init omap_check_revision(void); extern void __init omap_check_revision(void);
extern void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd, struct nand_chip;
extern void omap1_nand_cmd_ctl(struct nand_chip *this, int cmd,
unsigned int ctrl); unsigned int ctrl);
extern void omap1_timer_init(void); extern void omap1_timer_init(void);
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mv643xx_eth.h> #include <linux/mv643xx_eth.h>
#include <linux/ata_platform.h> #include <linux/ata_platform.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/timeriomem-rng.h> #include <linux/timeriomem-rng.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
...@@ -131,11 +130,9 @@ static void ts78xx_ts_rtc_unload(void) ...@@ -131,11 +130,9 @@ static void ts78xx_ts_rtc_unload(void)
* NAND_CLE: bit 1 -> bit 1 * NAND_CLE: bit 1 -> bit 1
* NAND_ALE: bit 2 -> bit 0 * NAND_ALE: bit 2 -> bit 0
*/ */
static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, static void ts78xx_ts_nand_cmd_ctrl(struct nand_chip *this, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_CTRL_CHANGE) {
unsigned char bits; unsigned char bits;
...@@ -147,19 +144,18 @@ static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, ...@@ -147,19 +144,18 @@ static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
writeb(cmd, this->IO_ADDR_W); writeb(cmd, this->legacy.IO_ADDR_W);
} }
static int ts78xx_ts_nand_dev_ready(struct mtd_info *mtd) static int ts78xx_ts_nand_dev_ready(struct nand_chip *chip)
{ {
return readb(TS_NAND_CTRL) & 0x20; return readb(TS_NAND_CTRL) & 0x20;
} }
static void ts78xx_ts_nand_write_buf(struct mtd_info *mtd, static void ts78xx_ts_nand_write_buf(struct nand_chip *chip,
const uint8_t *buf, int len) const uint8_t *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); void __iomem *io_base = chip->legacy.IO_ADDR_W;
void __iomem *io_base = chip->IO_ADDR_W;
unsigned long off = ((unsigned long)buf & 3); unsigned long off = ((unsigned long)buf & 3);
int sz; int sz;
...@@ -182,11 +178,10 @@ static void ts78xx_ts_nand_write_buf(struct mtd_info *mtd, ...@@ -182,11 +178,10 @@ static void ts78xx_ts_nand_write_buf(struct mtd_info *mtd,
writesb(io_base, buf, len); writesb(io_base, buf, len);
} }
static void ts78xx_ts_nand_read_buf(struct mtd_info *mtd, static void ts78xx_ts_nand_read_buf(struct nand_chip *chip,
uint8_t *buf, int len) uint8_t *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); void __iomem *io_base = chip->legacy.IO_ADDR_R;
void __iomem *io_base = chip->IO_ADDR_R;
unsigned long off = ((unsigned long)buf & 3); unsigned long off = ((unsigned long)buf & 3);
int sz; int sz;
......
...@@ -25,11 +25,10 @@ ...@@ -25,11 +25,10 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/ucb1400.h> #include <linux/ucb1400.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/platform_data/pcf857x.h> #include <linux/platform_data/pcf857x.h>
#include <linux/platform_data/i2c-pxa.h> #include <linux/platform_data/i2c-pxa.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/regulator/max1586.h> #include <linux/regulator/max1586.h>
...@@ -571,9 +570,9 @@ static inline void balloon3_i2c_init(void) {} ...@@ -571,9 +570,9 @@ static inline void balloon3_i2c_init(void) {}
* NAND * NAND
******************************************************************************/ ******************************************************************************/
#if defined(CONFIG_MTD_NAND_PLATFORM)||defined(CONFIG_MTD_NAND_PLATFORM_MODULE) #if defined(CONFIG_MTD_NAND_PLATFORM)||defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) static void balloon3_nand_cmd_ctl(struct nand_chip *this, int cmd,
unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
uint8_t balloon3_ctl_set = 0, balloon3_ctl_clr = 0; uint8_t balloon3_ctl_set = 0, balloon3_ctl_clr = 0;
if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_CTRL_CHANGE) {
...@@ -597,10 +596,10 @@ static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ct ...@@ -597,10 +596,10 @@ static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ct
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
writeb(cmd, this->IO_ADDR_W); writeb(cmd, this->legacy.IO_ADDR_W);
} }
static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip) static void balloon3_nand_select_chip(struct nand_chip *this, int chip)
{ {
if (chip < 0 || chip > 3) if (chip < 0 || chip > 3)
return; return;
...@@ -616,7 +615,7 @@ static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip) ...@@ -616,7 +615,7 @@ static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip)
BALLOON3_NAND_CONTROL_REG); BALLOON3_NAND_CONTROL_REG);
} }
static int balloon3_nand_dev_ready(struct mtd_info *mtd) static int balloon3_nand_dev_ready(struct nand_chip *this)
{ {
return __raw_readl(BALLOON3_NAND_STAT_REG) & BALLOON3_NAND_STAT_RNB; return __raw_readl(BALLOON3_NAND_STAT_REG) & BALLOON3_NAND_STAT_RNB;
} }
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
#include <linux/dm9000.h> #include <linux/dm9000.h>
#include <linux/platform_data/rtc-v3020.h> #include <linux/platform_data/rtc-v3020.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
...@@ -285,11 +284,10 @@ static void nand_cs_off(void) ...@@ -285,11 +284,10 @@ static void nand_cs_off(void)
} }
/* hardware specific access to control-lines */ /* hardware specific access to control-lines */
static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat, static void em_x270_nand_cmd_ctl(struct nand_chip *this, int dat,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); unsigned long nandaddr = (unsigned long)this->legacy.IO_ADDR_W;
unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
dsb(); dsb();
...@@ -309,15 +307,15 @@ static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat, ...@@ -309,15 +307,15 @@ static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
} }
dsb(); dsb();
this->IO_ADDR_W = (void __iomem *)nandaddr; this->legacy.IO_ADDR_W = (void __iomem *)nandaddr;
if (dat != NAND_CMD_NONE) if (dat != NAND_CMD_NONE)
writel(dat, this->IO_ADDR_W); writel(dat, this->legacy.IO_ADDR_W);
dsb(); dsb();
} }
/* read device ready pin */ /* read device ready pin */
static int em_x270_nand_device_ready(struct mtd_info *mtd) static int em_x270_nand_device_ready(struct nand_chip *this)
{ {
dsb(); dsb();
......
...@@ -403,36 +403,6 @@ static void __init palmtreo_leds_init(void) ...@@ -403,36 +403,6 @@ static void __init palmtreo_leds_init(void)
platform_device_register(&palmtreo_leds); platform_device_register(&palmtreo_leds);
} }
/******************************************************************************
* diskonchip docg4 flash
******************************************************************************/
#if defined(CONFIG_MACH_TREO680)
/* REVISIT: does the centro have this device also? */
#if IS_ENABLED(CONFIG_MTD_NAND_DOCG4)
static struct resource docg4_resources[] = {
{
.start = 0x00000000,
.end = 0x00001FFF,
.flags = IORESOURCE_MEM,
},
};
static struct platform_device treo680_docg4_flash = {
.name = "docg4",
.id = -1,
.resource = docg4_resources,
.num_resources = ARRAY_SIZE(docg4_resources),
};
static void __init treo680_docg4_flash_init(void)
{
platform_device_register(&treo680_docg4_flash);
}
#else
static inline void treo680_docg4_flash_init(void) {}
#endif
#endif
/****************************************************************************** /******************************************************************************
* Machine init * Machine init
******************************************************************************/ ******************************************************************************/
...@@ -517,7 +487,6 @@ static void __init treo680_init(void) ...@@ -517,7 +487,6 @@ static void __init treo680_init(void)
treo680_gpio_init(); treo680_gpio_init();
palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY, palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY,
GPIO_NR_TREO680_SD_POWER, 0); GPIO_NR_TREO680_SD_POWER, 0);
treo680_docg4_flash_init();
} }
#endif #endif
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
#include <linux/wm97xx.h> #include <linux/wm97xx.h>
#include <linux/power_supply.h> #include <linux/power_supply.h>
#include <linux/usb/gpio_vbus.h> #include <linux/usb/gpio_vbus.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
...@@ -247,11 +246,10 @@ static inline void palmtx_keys_init(void) {} ...@@ -247,11 +246,10 @@ static inline void palmtx_keys_init(void) {}
******************************************************************************/ ******************************************************************************/
#if defined(CONFIG_MTD_NAND_PLATFORM) || \ #if defined(CONFIG_MTD_NAND_PLATFORM) || \
defined(CONFIG_MTD_NAND_PLATFORM_MODULE) defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd, static void palmtx_nand_cmd_ctl(struct nand_chip *this, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); char __iomem *nandaddr = this->legacy.IO_ADDR_W;
char __iomem *nandaddr = this->IO_ADDR_W;
if (cmd == NAND_CMD_NONE) if (cmd == NAND_CMD_NONE)
return; return;
......
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -197,11 +196,10 @@ static struct i2c_board_info db1200_i2c_devs[] __initdata = { ...@@ -197,11 +196,10 @@ static struct i2c_board_info db1200_i2c_devs[] __initdata = {
/**********************************************************************/ /**********************************************************************/
static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, static void au1200_nand_cmd_ctrl(struct nand_chip *this, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); unsigned long ioaddr = (unsigned long)this->legacy.IO_ADDR_W;
unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
ioaddr &= 0xffffff00; ioaddr &= 0xffffff00;
...@@ -213,14 +211,14 @@ static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, ...@@ -213,14 +211,14 @@ static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
/* assume we want to r/w real data by default */ /* assume we want to r/w real data by default */
ioaddr += MEM_STNAND_DATA; ioaddr += MEM_STNAND_DATA;
} }
this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr; this->legacy.IO_ADDR_R = this->legacy.IO_ADDR_W = (void __iomem *)ioaddr;
if (cmd != NAND_CMD_NONE) { if (cmd != NAND_CMD_NONE) {
__raw_writeb(cmd, this->IO_ADDR_W); __raw_writeb(cmd, this->legacy.IO_ADDR_W);
wmb(); wmb();
} }
} }
static int au1200_nand_device_ready(struct mtd_info *mtd) static int au1200_nand_device_ready(struct nand_chip *this)
{ {
return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1;
} }
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/smsc911x.h> #include <linux/smsc911x.h>
#include <linux/wm97xx.h> #include <linux/wm97xx.h>
...@@ -149,11 +148,10 @@ static void __init db1300_gpio_config(void) ...@@ -149,11 +148,10 @@ static void __init db1300_gpio_config(void)
/**********************************************************************/ /**********************************************************************/
static void au1300_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, static void au1300_nand_cmd_ctrl(struct nand_chip *this, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); unsigned long ioaddr = (unsigned long)this->legacy.IO_ADDR_W;
unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
ioaddr &= 0xffffff00; ioaddr &= 0xffffff00;
...@@ -165,14 +163,14 @@ static void au1300_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, ...@@ -165,14 +163,14 @@ static void au1300_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
/* assume we want to r/w real data by default */ /* assume we want to r/w real data by default */
ioaddr += MEM_STNAND_DATA; ioaddr += MEM_STNAND_DATA;
} }
this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr; this->legacy.IO_ADDR_R = this->legacy.IO_ADDR_W = (void __iomem *)ioaddr;
if (cmd != NAND_CMD_NONE) { if (cmd != NAND_CMD_NONE) {
__raw_writeb(cmd, this->IO_ADDR_W); __raw_writeb(cmd, this->legacy.IO_ADDR_W);
wmb(); wmb();
} }
} }
static int au1300_nand_device_ready(struct mtd_info *mtd) static int au1300_nand_device_ready(struct nand_chip *this)
{ {
return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1;
} }
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -126,11 +125,10 @@ static struct i2c_board_info db1550_i2c_devs[] __initdata = { ...@@ -126,11 +125,10 @@ static struct i2c_board_info db1550_i2c_devs[] __initdata = {
/**********************************************************************/ /**********************************************************************/
static void au1550_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, static void au1550_nand_cmd_ctrl(struct nand_chip *this, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); unsigned long ioaddr = (unsigned long)this->legacy.IO_ADDR_W;
unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
ioaddr &= 0xffffff00; ioaddr &= 0xffffff00;
...@@ -142,14 +140,14 @@ static void au1550_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, ...@@ -142,14 +140,14 @@ static void au1550_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
/* assume we want to r/w real data by default */ /* assume we want to r/w real data by default */
ioaddr += MEM_STNAND_DATA; ioaddr += MEM_STNAND_DATA;
} }
this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr; this->legacy.IO_ADDR_R = this->legacy.IO_ADDR_W = (void __iomem *)ioaddr;
if (cmd != NAND_CMD_NONE) { if (cmd != NAND_CMD_NONE) {
__raw_writeb(cmd, this->IO_ADDR_W); __raw_writeb(cmd, this->legacy.IO_ADDR_W);
wmb(); wmb();
} }
} }
static int au1550_nand_device_ready(struct mtd_info *mtd) static int au1550_nand_device_ready(struct nand_chip *this)
{ {
return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1;
} }
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <asm/netlogic/haldefs.h> #include <asm/netlogic/haldefs.h>
#include <asm/netlogic/xlr/iomap.h> #include <asm/netlogic/xlr/iomap.h>
...@@ -92,8 +91,8 @@ struct xlr_nand_flash_priv { ...@@ -92,8 +91,8 @@ struct xlr_nand_flash_priv {
static struct xlr_nand_flash_priv nand_priv; static struct xlr_nand_flash_priv nand_priv;
static void xlr_nand_ctrl(struct mtd_info *mtd, int cmd, static void xlr_nand_ctrl(struct nand_chip *chip, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
if (ctrl & NAND_CLE) if (ctrl & NAND_CLE)
nlm_write_reg(nand_priv.flash_mmio, nlm_write_reg(nand_priv.flash_mmio,
......
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
#include <linux/resource.h> #include <linux/resource.h>
#include <linux/serial.h> #include <linux/serial.h>
#include <linux/serial_pnx8xxx.h> #include <linux/serial_pnx8xxx.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/partitions.h>
#include <irq.h> #include <irq.h>
#include <irq-mapping.h> #include <irq-mapping.h>
...@@ -178,10 +177,9 @@ static struct platform_device pnx833x_sata_device = { ...@@ -178,10 +177,9 @@ static struct platform_device pnx833x_sata_device = {
}; };
static void static void
pnx833x_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) pnx833x_flash_nand_cmd_ctrl(struct nand_chip *this, int cmd, unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); unsigned long nandaddr = (unsigned long)this->legacy.IO_ADDR_W;
unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
if (cmd == NAND_CMD_NONE) if (cmd == NAND_CMD_NONE)
return; return;
......
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
#include <linux/input.h> #include <linux/input.h>
...@@ -141,14 +140,13 @@ static struct platform_device cf_slot0 = { ...@@ -141,14 +140,13 @@ static struct platform_device cf_slot0 = {
}; };
/* Resources and device for NAND */ /* Resources and device for NAND */
static int rb532_dev_ready(struct mtd_info *mtd) static int rb532_dev_ready(struct nand_chip *chip)
{ {
return gpio_get_value(GPIO_RDY); return gpio_get_value(GPIO_RDY);
} }
static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) static void rb532_cmd_ctrl(struct nand_chip *chip, int cmd, unsigned int ctrl)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
unsigned char orbits, nandbits; unsigned char orbits, nandbits;
if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_CTRL_CHANGE) {
...@@ -161,7 +159,7 @@ static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) ...@@ -161,7 +159,7 @@ static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
set_latch_u5(orbits, nandbits); set_latch_u5(orbits, nandbits);
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
writeb(cmd, chip->IO_ADDR_W); writeb(cmd, chip->legacy.IO_ADDR_W);
} }
static struct resource nand_slot0_res[] = { static struct resource nand_slot0_res[] = {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/mfd/tmio.h> #include <linux/mfd/tmio.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/platnand.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/regulator/fixed.h> #include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
...@@ -165,23 +165,21 @@ static struct mtd_partition migor_nand_flash_partitions[] = { ...@@ -165,23 +165,21 @@ static struct mtd_partition migor_nand_flash_partitions[] = {
}, },
}; };
static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd, static void migor_nand_flash_cmd_ctl(struct nand_chip *chip, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
if (cmd == NAND_CMD_NONE) if (cmd == NAND_CMD_NONE)
return; return;
if (ctrl & NAND_CLE) if (ctrl & NAND_CLE)
writeb(cmd, chip->IO_ADDR_W + 0x00400000); writeb(cmd, chip->legacy.IO_ADDR_W + 0x00400000);
else if (ctrl & NAND_ALE) else if (ctrl & NAND_ALE)
writeb(cmd, chip->IO_ADDR_W + 0x00800000); writeb(cmd, chip->legacy.IO_ADDR_W + 0x00800000);
else else
writeb(cmd, chip->IO_ADDR_W); writeb(cmd, chip->legacy.IO_ADDR_W);
} }
static int migor_nand_flash_ready(struct mtd_info *mtd) static int migor_nand_flash_ready(struct nand_chip *chip)
{ {
return gpio_get_value(GPIO_PTA1); /* NAND_RBn */ return gpio_get_value(GPIO_PTA1); /* NAND_RBn */
} }
......
...@@ -90,7 +90,6 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len, ...@@ -90,7 +90,6 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
SPI_MEM_OP_ADDR(nor->addr_width, to, 1), SPI_MEM_OP_ADDR(nor->addr_width, to, 1),
SPI_MEM_OP_NO_DUMMY, SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_OUT(len, buf, 1)); SPI_MEM_OP_DATA_OUT(len, buf, 1));
size_t remaining = len;
int ret; int ret;
/* get transfer protocols. */ /* get transfer protocols. */
...@@ -101,22 +100,16 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len, ...@@ -101,22 +100,16 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second) if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second)
op.addr.nbytes = 0; op.addr.nbytes = 0;
while (remaining) { ret = spi_mem_adjust_op_size(flash->spimem, &op);
op.data.nbytes = remaining < UINT_MAX ? remaining : UINT_MAX; if (ret)
ret = spi_mem_adjust_op_size(flash->spimem, &op); return ret;
if (ret) op.data.nbytes = len < op.data.nbytes ? len : op.data.nbytes;
return ret;
ret = spi_mem_exec_op(flash->spimem, &op);
if (ret)
return ret;
op.addr.val += op.data.nbytes; ret = spi_mem_exec_op(flash->spimem, &op);
remaining -= op.data.nbytes; if (ret)
op.data.buf.out += op.data.nbytes; return ret;
}
return len; return op.data.nbytes;
} }
/* /*
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -25,28 +26,24 @@ ...@@ -25,28 +26,24 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#define pr_devinit(fmt, args...) \ #define win_mask(x) ((BIT(x)) - 1)
({ static const char __fmt[] = fmt; printk(__fmt, ## args); })
#define DRIVER_NAME "gpio-addr-flash" #define DRIVER_NAME "gpio-addr-flash"
#define PFX DRIVER_NAME ": "
/** /**
* struct async_state - keep GPIO flash state * struct async_state - keep GPIO flash state
* @mtd: MTD state for this mapping * @mtd: MTD state for this mapping
* @map: MTD map state for this flash * @map: MTD map state for this flash
* @gpio_count: number of GPIOs used to address * @gpios: Struct containing the array of GPIO descriptors
* @gpio_addrs: array of GPIOs to twiddle
* @gpio_values: cached GPIO values * @gpio_values: cached GPIO values
* @win_size: dedicated memory size (if no GPIOs) * @win_order: dedicated memory size (if no GPIOs)
*/ */
struct async_state { struct async_state {
struct mtd_info *mtd; struct mtd_info *mtd;
struct map_info map; struct map_info map;
size_t gpio_count; struct gpio_descs *gpios;
unsigned *gpio_addrs; unsigned int gpio_values;
int *gpio_values; unsigned int win_order;
unsigned long win_size;
}; };
#define gf_map_info_to_state(mi) ((struct async_state *)(mi)->map_priv_1) #define gf_map_info_to_state(mi) ((struct async_state *)(mi)->map_priv_1)
...@@ -57,21 +54,25 @@ struct async_state { ...@@ -57,21 +54,25 @@ struct async_state {
* *
* Rather than call the GPIO framework every time, cache the last-programmed * Rather than call the GPIO framework every time, cache the last-programmed
* value. This speeds up sequential accesses (which are by far the most common * value. This speeds up sequential accesses (which are by far the most common
* type). We rely on the GPIO framework to treat non-zero value as high so * type).
* that we don't have to normalize the bits.
*/ */
static void gf_set_gpios(struct async_state *state, unsigned long ofs) static void gf_set_gpios(struct async_state *state, unsigned long ofs)
{ {
size_t i = 0; int i;
int value;
ofs /= state->win_size; ofs >>= state->win_order;
do {
value = ofs & (1 << i); if (ofs == state->gpio_values)
if (state->gpio_values[i] != value) { return;
gpio_set_value(state->gpio_addrs[i], value);
state->gpio_values[i] = value; for (i = 0; i < state->gpios->ndescs; i++) {
} if ((ofs & BIT(i)) == (state->gpio_values & BIT(i)))
} while (++i < state->gpio_count); continue;
gpiod_set_value(state->gpios->desc[i], !!(ofs & BIT(i)));
}
state->gpio_values = ofs;
} }
/** /**
...@@ -87,7 +88,7 @@ static map_word gf_read(struct map_info *map, unsigned long ofs) ...@@ -87,7 +88,7 @@ static map_word gf_read(struct map_info *map, unsigned long ofs)
gf_set_gpios(state, ofs); gf_set_gpios(state, ofs);
word = readw(map->virt + (ofs % state->win_size)); word = readw(map->virt + (ofs & win_mask(state->win_order)));
test.x[0] = word; test.x[0] = word;
return test; return test;
} }
...@@ -109,14 +110,14 @@ static void gf_copy_from(struct map_info *map, void *to, unsigned long from, ssi ...@@ -109,14 +110,14 @@ static void gf_copy_from(struct map_info *map, void *to, unsigned long from, ssi
int this_len; int this_len;
while (len) { while (len) {
if ((from % state->win_size) + len > state->win_size) this_len = from & win_mask(state->win_order);
this_len = state->win_size - (from % state->win_size); this_len = BIT(state->win_order) - this_len;
else this_len = min_t(int, len, this_len);
this_len = len;
gf_set_gpios(state, from); gf_set_gpios(state, from);
memcpy_fromio(to, map->virt + (from % state->win_size), memcpy_fromio(to,
this_len); map->virt + (from & win_mask(state->win_order)),
this_len);
len -= this_len; len -= this_len;
from += this_len; from += this_len;
to += this_len; to += this_len;
...@@ -136,7 +137,7 @@ static void gf_write(struct map_info *map, map_word d1, unsigned long ofs) ...@@ -136,7 +137,7 @@ static void gf_write(struct map_info *map, map_word d1, unsigned long ofs)
gf_set_gpios(state, ofs); gf_set_gpios(state, ofs);
d = d1.x[0]; d = d1.x[0];
writew(d, map->virt + (ofs % state->win_size)); writew(d, map->virt + (ofs & win_mask(state->win_order)));
} }
/** /**
...@@ -156,13 +157,13 @@ static void gf_copy_to(struct map_info *map, unsigned long to, ...@@ -156,13 +157,13 @@ static void gf_copy_to(struct map_info *map, unsigned long to,
int this_len; int this_len;
while (len) { while (len) {
if ((to % state->win_size) + len > state->win_size) this_len = to & win_mask(state->win_order);
this_len = state->win_size - (to % state->win_size); this_len = BIT(state->win_order) - this_len;
else this_len = min_t(int, len, this_len);
this_len = len;
gf_set_gpios(state, to); gf_set_gpios(state, to);
memcpy_toio(map->virt + (to % state->win_size), from, len); memcpy_toio(map->virt + (to & win_mask(state->win_order)),
from, len);
len -= this_len; len -= this_len;
to += this_len; to += this_len;
...@@ -180,18 +181,22 @@ static const char * const part_probe_types[] = { ...@@ -180,18 +181,22 @@ static const char * const part_probe_types[] = {
* The platform resource layout expected looks something like: * The platform resource layout expected looks something like:
* struct mtd_partition partitions[] = { ... }; * struct mtd_partition partitions[] = { ... };
* struct physmap_flash_data flash_data = { ... }; * struct physmap_flash_data flash_data = { ... };
* unsigned flash_gpios[] = { GPIO_XX, GPIO_XX, ... }; * static struct gpiod_lookup_table addr_flash_gpios = {
* .dev_id = "gpio-addr-flash.0",
* .table = {
* GPIO_LOOKUP_IDX("gpio.0", 15, "addr", 0, GPIO_ACTIVE_HIGH),
* GPIO_LOOKUP_IDX("gpio.0", 16, "addr", 1, GPIO_ACTIVE_HIGH),
* );
* };
* gpiod_add_lookup_table(&addr_flash_gpios);
*
* struct resource flash_resource[] = { * struct resource flash_resource[] = {
* { * {
* .name = "cfi_probe", * .name = "cfi_probe",
* .start = 0x20000000, * .start = 0x20000000,
* .end = 0x201fffff, * .end = 0x201fffff,
* .flags = IORESOURCE_MEM, * .flags = IORESOURCE_MEM,
* }, { * },
* .start = (unsigned long)flash_gpios,
* .end = ARRAY_SIZE(flash_gpios),
* .flags = IORESOURCE_IRQ,
* }
* }; * };
* struct platform_device flash_device = { * struct platform_device flash_device = {
* .name = "gpio-addr-flash", * .name = "gpio-addr-flash",
...@@ -203,33 +208,25 @@ static const char * const part_probe_types[] = { ...@@ -203,33 +208,25 @@ static const char * const part_probe_types[] = {
*/ */
static int gpio_flash_probe(struct platform_device *pdev) static int gpio_flash_probe(struct platform_device *pdev)
{ {
size_t i, arr_size;
struct physmap_flash_data *pdata; struct physmap_flash_data *pdata;
struct resource *memory; struct resource *memory;
struct resource *gpios;
struct async_state *state; struct async_state *state;
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
memory = platform_get_resource(pdev, IORESOURCE_MEM, 0); memory = platform_get_resource(pdev, IORESOURCE_MEM, 0);
gpios = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!memory || !gpios || !gpios->end) if (!memory)
return -EINVAL; return -EINVAL;
arr_size = sizeof(int) * gpios->end; state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL);
state = kzalloc(sizeof(*state) + arr_size, GFP_KERNEL);
if (!state) if (!state)
return -ENOMEM; return -ENOMEM;
/* state->gpios = devm_gpiod_get_array(&pdev->dev, "addr", GPIOD_OUT_LOW);
* We cast start/end to known types in the boards file, so cast if (IS_ERR(state->gpios))
* away their pointer types here to the known types (gpios->xxx). return PTR_ERR(state->gpios);
*/
state->gpio_count = gpios->end; state->win_order = get_bitmask_order(resource_size(memory)) - 1;
state->gpio_addrs = (void *)(unsigned long)gpios->start;
state->gpio_values = (void *)(state + 1);
state->win_size = resource_size(memory);
memset(state->gpio_values, 0xff, arr_size);
state->map.name = DRIVER_NAME; state->map.name = DRIVER_NAME;
state->map.read = gf_read; state->map.read = gf_read;
...@@ -237,38 +234,21 @@ static int gpio_flash_probe(struct platform_device *pdev) ...@@ -237,38 +234,21 @@ static int gpio_flash_probe(struct platform_device *pdev)
state->map.write = gf_write; state->map.write = gf_write;
state->map.copy_to = gf_copy_to; state->map.copy_to = gf_copy_to;
state->map.bankwidth = pdata->width; state->map.bankwidth = pdata->width;
state->map.size = state->win_size * (1 << state->gpio_count); state->map.size = BIT(state->win_order + state->gpios->ndescs);
state->map.virt = ioremap_nocache(memory->start, state->map.size); state->map.virt = devm_ioremap_resource(&pdev->dev, memory);
if (!state->map.virt) if (IS_ERR(state->map.virt))
return -ENOMEM; return PTR_ERR(state->map.virt);
state->map.phys = NO_XIP; state->map.phys = NO_XIP;
state->map.map_priv_1 = (unsigned long)state; state->map.map_priv_1 = (unsigned long)state;
platform_set_drvdata(pdev, state); platform_set_drvdata(pdev, state);
i = 0; dev_notice(&pdev->dev, "probing %d-bit flash bus\n",
do { state->map.bankwidth * 8);
if (gpio_request(state->gpio_addrs[i], DRIVER_NAME)) {
pr_devinit(KERN_ERR PFX "failed to request gpio %d\n",
state->gpio_addrs[i]);
while (i--)
gpio_free(state->gpio_addrs[i]);
kfree(state);
return -EBUSY;
}
gpio_direction_output(state->gpio_addrs[i], 0);
} while (++i < state->gpio_count);
pr_devinit(KERN_NOTICE PFX "probing %d-bit flash bus\n",
state->map.bankwidth * 8);
state->mtd = do_map_probe(memory->name, &state->map); state->mtd = do_map_probe(memory->name, &state->map);
if (!state->mtd) { if (!state->mtd)
for (i = 0; i < state->gpio_count; ++i)
gpio_free(state->gpio_addrs[i]);
kfree(state);
return -ENXIO; return -ENXIO;
}
state->mtd->dev.parent = &pdev->dev; state->mtd->dev.parent = &pdev->dev;
mtd_device_parse_register(state->mtd, part_probe_types, NULL, mtd_device_parse_register(state->mtd, part_probe_types, NULL,
...@@ -280,13 +260,9 @@ static int gpio_flash_probe(struct platform_device *pdev) ...@@ -280,13 +260,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
static int gpio_flash_remove(struct platform_device *pdev) static int gpio_flash_remove(struct platform_device *pdev)
{ {
struct async_state *state = platform_get_drvdata(pdev); struct async_state *state = platform_get_drvdata(pdev);
size_t i = 0;
do {
gpio_free(state->gpio_addrs[i]);
} while (++i < state->gpio_count);
mtd_device_unregister(state->mtd); mtd_device_unregister(state->mtd);
map_destroy(state->mtd); map_destroy(state->mtd);
kfree(state);
return 0; return 0;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
struct of_flash_list { struct of_flash_list {
struct mtd_info *mtd; struct mtd_info *mtd;
struct map_info map; struct map_info map;
struct resource *res;
}; };
struct of_flash { struct of_flash {
...@@ -56,18 +55,10 @@ static int of_flash_remove(struct platform_device *dev) ...@@ -56,18 +55,10 @@ static int of_flash_remove(struct platform_device *dev)
mtd_concat_destroy(info->cmtd); mtd_concat_destroy(info->cmtd);
} }
for (i = 0; i < info->list_size; i++) { for (i = 0; i < info->list_size; i++)
if (info->list[i].mtd) if (info->list[i].mtd)
map_destroy(info->list[i].mtd); map_destroy(info->list[i].mtd);
if (info->list[i].map.virt)
iounmap(info->list[i].map.virt);
if (info->list[i].res) {
release_resource(info->list[i].res);
kfree(info->list[i].res);
}
}
return 0; return 0;
} }
...@@ -215,10 +206,11 @@ static int of_flash_probe(struct platform_device *dev) ...@@ -215,10 +206,11 @@ static int of_flash_probe(struct platform_device *dev)
err = -EBUSY; err = -EBUSY;
res_size = resource_size(&res); res_size = resource_size(&res);
info->list[i].res = request_mem_region(res.start, res_size, info->list[i].map.virt = devm_ioremap_resource(&dev->dev, &res);
dev_name(&dev->dev)); if (IS_ERR(info->list[i].map.virt)) {
if (!info->list[i].res) err = PTR_ERR(info->list[i].map.virt);
goto err_out; goto err_out;
}
err = -ENXIO; err = -ENXIO;
width = of_get_property(dp, "bank-width", NULL); width = of_get_property(dp, "bank-width", NULL);
...@@ -246,15 +238,6 @@ static int of_flash_probe(struct platform_device *dev) ...@@ -246,15 +238,6 @@ static int of_flash_probe(struct platform_device *dev)
if (err) if (err)
goto err_out; goto err_out;
err = -ENOMEM;
info->list[i].map.virt = ioremap(info->list[i].map.phys,
info->list[i].map.size);
if (!info->list[i].map.virt) {
dev_err(&dev->dev, "Failed to ioremap() flash"
" region\n");
goto err_out;
}
simple_map_init(&info->list[i].map); simple_map_init(&info->list[i].map);
/* /*
......
...@@ -44,11 +44,6 @@ ...@@ -44,11 +44,6 @@
#define FLASH_PARALLEL_HIGH_PIN_CNT (1 << 20) /* else low pin cnt */ #define FLASH_PARALLEL_HIGH_PIN_CNT (1 << 20) /* else low pin cnt */
static const struct of_device_id syscon_match[] = {
{ .compatible = "cortina,gemini-syscon" },
{ },
};
int of_flash_probe_gemini(struct platform_device *pdev, int of_flash_probe_gemini(struct platform_device *pdev,
struct device_node *np, struct device_node *np,
struct map_info *map) struct map_info *map)
......
...@@ -227,26 +227,6 @@ config MTD_NAND_DISKONCHIP_BBTWRITE ...@@ -227,26 +227,6 @@ config MTD_NAND_DISKONCHIP_BBTWRITE
load time (assuming you build diskonchip as a module) with the module load time (assuming you build diskonchip as a module) with the module
parameter "inftl_bbt_write=1". parameter "inftl_bbt_write=1".
config MTD_NAND_DOCG4
tristate "Support for DiskOnChip G4"
depends on HAS_IOMEM
select BCH
select BITREVERSE
help
Support for diskonchip G4 nand flash, found in various smartphones and
PDAs, among them the Palm Treo680, HTC Prophet and Wizard, Toshiba
Portege G900, Asus P526, and O2 XDA Zinc.
With this driver you will be able to use UBI and create a ubifs on the
device, so you may wish to consider enabling UBI and UBIFS as well.
These devices ship with the Mys/Sandisk SAFTL formatting, for which
there is currently no mtd parser, so you may want to use command line
partitioning to segregate write-protected blocks. On the Treo680, the
first five erase blocks (256KiB each) are write-protected, followed
by the block containing the saftl partition table. This is probably
typical.
config MTD_NAND_SHARPSL config MTD_NAND_SHARPSL
tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)" tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)"
depends on ARCH_PXA || COMPILE_TEST depends on ARCH_PXA || COMPILE_TEST
......
...@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o ...@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
obj-$(CONFIG_MTD_NAND_TANGO) += tango_nand.o obj-$(CONFIG_MTD_NAND_TANGO) += tango_nand.o
obj-$(CONFIG_MTD_NAND_DAVINCI) += davinci_nand.o obj-$(CONFIG_MTD_NAND_DAVINCI) += davinci_nand.o
obj-$(CONFIG_MTD_NAND_DISKONCHIP) += diskonchip.o obj-$(CONFIG_MTD_NAND_DISKONCHIP) += diskonchip.o
obj-$(CONFIG_MTD_NAND_DOCG4) += docg4.o
obj-$(CONFIG_MTD_NAND_FSMC) += fsmc_nand.o obj-$(CONFIG_MTD_NAND_FSMC) += fsmc_nand.o
obj-$(CONFIG_MTD_NAND_SHARPSL) += sharpsl.o obj-$(CONFIG_MTD_NAND_SHARPSL) += sharpsl.o
obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o
...@@ -58,8 +57,11 @@ obj-$(CONFIG_MTD_NAND_QCOM) += qcom_nandc.o ...@@ -58,8 +57,11 @@ obj-$(CONFIG_MTD_NAND_QCOM) += qcom_nandc.o
obj-$(CONFIG_MTD_NAND_MTK) += mtk_ecc.o mtk_nand.o obj-$(CONFIG_MTD_NAND_MTK) += mtk_ecc.o mtk_nand.o
obj-$(CONFIG_MTD_NAND_TEGRA) += tegra_nand.o obj-$(CONFIG_MTD_NAND_TEGRA) += tegra_nand.o
nand-objs := nand_base.o nand_bbt.o nand_timings.o nand_ids.o nand-objs := nand_base.o nand_legacy.o nand_bbt.o nand_timings.o nand_ids.o
nand-objs += nand_onfi.o
nand-objs += nand_jedec.o
nand-objs += nand_amd.o nand-objs += nand_amd.o
nand-objs += nand_esmt.o
nand-objs += nand_hynix.o nand-objs += nand_hynix.o
nand-objs += nand_macronix.o nand-objs += nand_macronix.o
nand-objs += nand_micron.o nand-objs += nand_micron.o
......
This diff is collapsed.
This diff is collapsed.
...@@ -65,7 +65,7 @@ static int bcm47xxnflash_remove(struct platform_device *pdev) ...@@ -65,7 +65,7 @@ static int bcm47xxnflash_remove(struct platform_device *pdev)
{ {
struct bcm47xxnflash *nflash = platform_get_drvdata(pdev); struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
nand_release(nand_to_mtd(&nflash->nand_chip)); nand_release(&nflash->nand_chip);
return 0; return 0;
} }
......
...@@ -170,10 +170,9 @@ static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd, ...@@ -170,10 +170,9 @@ static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd,
* NAND chip ops * NAND chip ops
**************************************************/ **************************************************/
static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd, static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct nand_chip *nand_chip,
unsigned int ctrl) int cmd, unsigned int ctrl)
{ {
struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
u32 code = 0; u32 code = 0;
...@@ -191,15 +190,14 @@ static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd, ...@@ -191,15 +190,14 @@ static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd,
} }
/* Default nand_select_chip calls cmd_ctrl, which is not used in BCM4706 */ /* Default nand_select_chip calls cmd_ctrl, which is not used in BCM4706 */
static void bcm47xxnflash_ops_bcm4706_select_chip(struct mtd_info *mtd, static void bcm47xxnflash_ops_bcm4706_select_chip(struct nand_chip *chip,
int chip) int cs)
{ {
return; return;
} }
static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd) static int bcm47xxnflash_ops_bcm4706_dev_ready(struct nand_chip *nand_chip)
{ {
struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
return !!(bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_CTL) & NCTL_READY); return !!(bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_CTL) & NCTL_READY);
...@@ -212,11 +210,11 @@ static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd) ...@@ -212,11 +210,11 @@ static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd)
* registers of ChipCommon core. Hacking cmd_ctrl to understand and convert * registers of ChipCommon core. Hacking cmd_ctrl to understand and convert
* standard commands would be much more complicated. * standard commands would be much more complicated.
*/ */
static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct nand_chip *nand_chip,
unsigned command, int column, unsigned command, int column,
int page_addr) int page_addr)
{ {
struct nand_chip *nand_chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(nand_chip);
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
struct bcma_drv_cc *cc = b47n->cc; struct bcma_drv_cc *cc = b47n->cc;
u32 ctlcode; u32 ctlcode;
...@@ -229,10 +227,10 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, ...@@ -229,10 +227,10 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd,
switch (command) { switch (command) {
case NAND_CMD_RESET: case NAND_CMD_RESET:
nand_chip->cmd_ctrl(mtd, command, NAND_CTRL_CLE); nand_chip->legacy.cmd_ctrl(nand_chip, command, NAND_CTRL_CLE);
ndelay(100); ndelay(100);
nand_wait_ready(mtd); nand_wait_ready(nand_chip);
break; break;
case NAND_CMD_READID: case NAND_CMD_READID:
ctlcode = NCTL_CSA | 0x01000000 | NCTL_CMD1W | NCTL_CMD0; ctlcode = NCTL_CSA | 0x01000000 | NCTL_CMD1W | NCTL_CMD0;
...@@ -310,9 +308,9 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, ...@@ -310,9 +308,9 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd,
b47n->curr_command = command; b47n->curr_command = command;
} }
static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd) static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct nand_chip *nand_chip)
{ {
struct nand_chip *nand_chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(nand_chip);
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
struct bcma_drv_cc *cc = b47n->cc; struct bcma_drv_cc *cc = b47n->cc;
u32 tmp = 0; u32 tmp = 0;
...@@ -338,31 +336,31 @@ static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd) ...@@ -338,31 +336,31 @@ static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd)
return 0; return 0;
} }
static void bcm47xxnflash_ops_bcm4706_read_buf(struct mtd_info *mtd, static void bcm47xxnflash_ops_bcm4706_read_buf(struct nand_chip *nand_chip,
uint8_t *buf, int len) uint8_t *buf, int len)
{ {
struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
switch (b47n->curr_command) { switch (b47n->curr_command) {
case NAND_CMD_READ0: case NAND_CMD_READ0:
case NAND_CMD_READOOB: case NAND_CMD_READOOB:
bcm47xxnflash_ops_bcm4706_read(mtd, buf, len); bcm47xxnflash_ops_bcm4706_read(nand_to_mtd(nand_chip), buf,
len);
return; return;
} }
pr_err("Invalid command for buf read: 0x%X\n", b47n->curr_command); pr_err("Invalid command for buf read: 0x%X\n", b47n->curr_command);
} }
static void bcm47xxnflash_ops_bcm4706_write_buf(struct mtd_info *mtd, static void bcm47xxnflash_ops_bcm4706_write_buf(struct nand_chip *nand_chip,
const uint8_t *buf, int len) const uint8_t *buf, int len)
{ {
struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
switch (b47n->curr_command) { switch (b47n->curr_command) {
case NAND_CMD_SEQIN: case NAND_CMD_SEQIN:
bcm47xxnflash_ops_bcm4706_write(mtd, buf, len); bcm47xxnflash_ops_bcm4706_write(nand_to_mtd(nand_chip), buf,
len);
return; return;
} }
...@@ -386,16 +384,16 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n) ...@@ -386,16 +384,16 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
u32 val; u32 val;
b47n->nand_chip.select_chip = bcm47xxnflash_ops_bcm4706_select_chip; b47n->nand_chip.select_chip = bcm47xxnflash_ops_bcm4706_select_chip;
nand_chip->cmd_ctrl = bcm47xxnflash_ops_bcm4706_cmd_ctrl; nand_chip->legacy.cmd_ctrl = bcm47xxnflash_ops_bcm4706_cmd_ctrl;
nand_chip->dev_ready = bcm47xxnflash_ops_bcm4706_dev_ready; nand_chip->legacy.dev_ready = bcm47xxnflash_ops_bcm4706_dev_ready;
b47n->nand_chip.cmdfunc = bcm47xxnflash_ops_bcm4706_cmdfunc; b47n->nand_chip.legacy.cmdfunc = bcm47xxnflash_ops_bcm4706_cmdfunc;
b47n->nand_chip.read_byte = bcm47xxnflash_ops_bcm4706_read_byte; b47n->nand_chip.legacy.read_byte = bcm47xxnflash_ops_bcm4706_read_byte;
b47n->nand_chip.read_buf = bcm47xxnflash_ops_bcm4706_read_buf; b47n->nand_chip.legacy.read_buf = bcm47xxnflash_ops_bcm4706_read_buf;
b47n->nand_chip.write_buf = bcm47xxnflash_ops_bcm4706_write_buf; b47n->nand_chip.legacy.write_buf = bcm47xxnflash_ops_bcm4706_write_buf;
b47n->nand_chip.set_features = nand_get_set_features_notsupp; b47n->nand_chip.legacy.set_features = nand_get_set_features_notsupp;
b47n->nand_chip.get_features = nand_get_set_features_notsupp; b47n->nand_chip.legacy.get_features = nand_get_set_features_notsupp;
nand_chip->chip_delay = 50; nand_chip->legacy.chip_delay = 50;
b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH; b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH;
b47n->nand_chip.ecc.mode = NAND_ECC_NONE; /* TODO: implement ECC */ b47n->nand_chip.ecc.mode = NAND_ECC_NONE; /* TODO: implement ECC */
...@@ -423,7 +421,7 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n) ...@@ -423,7 +421,7 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
(w4 << 24 | w3 << 18 | w2 << 12 | w1 << 6 | w0)); (w4 << 24 | w3 << 18 | w2 << 12 | w1 << 6 | w0));
/* Scan NAND */ /* Scan NAND */
err = nand_scan(nand_to_mtd(&b47n->nand_chip), 1); err = nand_scan(&b47n->nand_chip, 1);
if (err) { if (err) {
pr_err("Could not scan NAND flash: %d\n", err); pr_err("Could not scan NAND flash: %d\n", err);
goto exit; goto exit;
......
...@@ -1231,15 +1231,14 @@ static void brcmnand_send_cmd(struct brcmnand_host *host, int cmd) ...@@ -1231,15 +1231,14 @@ static void brcmnand_send_cmd(struct brcmnand_host *host, int cmd)
* NAND MTD API: read/program/erase * NAND MTD API: read/program/erase
***********************************************************************/ ***********************************************************************/
static void brcmnand_cmd_ctrl(struct mtd_info *mtd, int dat, static void brcmnand_cmd_ctrl(struct nand_chip *chip, int dat,
unsigned int ctrl) unsigned int ctrl)
{ {
/* intentionally left blank */ /* intentionally left blank */
} }
static int brcmnand_waitfunc(struct mtd_info *mtd, struct nand_chip *this) static int brcmnand_waitfunc(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
struct brcmnand_controller *ctrl = host->ctrl; struct brcmnand_controller *ctrl = host->ctrl;
unsigned long timeo = msecs_to_jiffies(100); unsigned long timeo = msecs_to_jiffies(100);
...@@ -1274,7 +1273,6 @@ static int brcmnand_low_level_op(struct brcmnand_host *host, ...@@ -1274,7 +1273,6 @@ static int brcmnand_low_level_op(struct brcmnand_host *host,
enum brcmnand_llop_type type, u32 data, enum brcmnand_llop_type type, u32 data,
bool last_op) bool last_op)
{ {
struct mtd_info *mtd = nand_to_mtd(&host->chip);
struct nand_chip *chip = &host->chip; struct nand_chip *chip = &host->chip;
struct brcmnand_controller *ctrl = host->ctrl; struct brcmnand_controller *ctrl = host->ctrl;
u32 tmp; u32 tmp;
...@@ -1307,13 +1305,13 @@ static int brcmnand_low_level_op(struct brcmnand_host *host, ...@@ -1307,13 +1305,13 @@ static int brcmnand_low_level_op(struct brcmnand_host *host,
(void)brcmnand_read_reg(ctrl, BRCMNAND_LL_OP); (void)brcmnand_read_reg(ctrl, BRCMNAND_LL_OP);
brcmnand_send_cmd(host, CMD_LOW_LEVEL_OP); brcmnand_send_cmd(host, CMD_LOW_LEVEL_OP);
return brcmnand_waitfunc(mtd, chip); return brcmnand_waitfunc(chip);
} }
static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command, static void brcmnand_cmdfunc(struct nand_chip *chip, unsigned command,
int column, int page_addr) int column, int page_addr)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(chip);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
struct brcmnand_controller *ctrl = host->ctrl; struct brcmnand_controller *ctrl = host->ctrl;
u64 addr = (u64)page_addr << chip->page_shift; u64 addr = (u64)page_addr << chip->page_shift;
...@@ -1383,7 +1381,7 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command, ...@@ -1383,7 +1381,7 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
(void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS); (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS);
brcmnand_send_cmd(host, native_cmd); brcmnand_send_cmd(host, native_cmd);
brcmnand_waitfunc(mtd, chip); brcmnand_waitfunc(chip);
if (native_cmd == CMD_PARAMETER_READ || if (native_cmd == CMD_PARAMETER_READ ||
native_cmd == CMD_PARAMETER_CHANGE_COL) { native_cmd == CMD_PARAMETER_CHANGE_COL) {
...@@ -1417,9 +1415,8 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command, ...@@ -1417,9 +1415,8 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
brcmnand_wp(mtd, 1); brcmnand_wp(mtd, 1);
} }
static uint8_t brcmnand_read_byte(struct mtd_info *mtd) static uint8_t brcmnand_read_byte(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
struct brcmnand_controller *ctrl = host->ctrl; struct brcmnand_controller *ctrl = host->ctrl;
uint8_t ret = 0; uint8_t ret = 0;
...@@ -1474,19 +1471,18 @@ static uint8_t brcmnand_read_byte(struct mtd_info *mtd) ...@@ -1474,19 +1471,18 @@ static uint8_t brcmnand_read_byte(struct mtd_info *mtd)
return ret; return ret;
} }
static void brcmnand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static void brcmnand_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
{ {
int i; int i;
for (i = 0; i < len; i++, buf++) for (i = 0; i < len; i++, buf++)
*buf = brcmnand_read_byte(mtd); *buf = brcmnand_read_byte(chip);
} }
static void brcmnand_write_buf(struct mtd_info *mtd, const uint8_t *buf, static void brcmnand_write_buf(struct nand_chip *chip, const uint8_t *buf,
int len) int len)
{ {
int i; int i;
struct nand_chip *chip = mtd_to_nand(mtd);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
switch (host->last_cmd) { switch (host->last_cmd) {
...@@ -1617,7 +1613,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1617,7 +1613,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,
(void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS); (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS);
/* SPARE_AREA_READ does not use ECC, so just use PAGE_READ */ /* SPARE_AREA_READ does not use ECC, so just use PAGE_READ */
brcmnand_send_cmd(host, CMD_PAGE_READ); brcmnand_send_cmd(host, CMD_PAGE_READ);
brcmnand_waitfunc(mtd, chip); brcmnand_waitfunc(chip);
if (likely(buf)) { if (likely(buf)) {
brcmnand_soc_data_bus_prepare(ctrl->soc, false); brcmnand_soc_data_bus_prepare(ctrl->soc, false);
...@@ -1689,7 +1685,7 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd, ...@@ -1689,7 +1685,7 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
sas = mtd->oobsize / chip->ecc.steps; sas = mtd->oobsize / chip->ecc.steps;
/* read without ecc for verification */ /* read without ecc for verification */
ret = chip->ecc.read_page_raw(mtd, chip, buf, true, page); ret = chip->ecc.read_page_raw(chip, buf, true, page);
if (ret) if (ret)
return ret; return ret;
...@@ -1786,9 +1782,10 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1786,9 +1782,10 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,
return 0; return 0;
} }
static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read_page(struct nand_chip *chip, uint8_t *buf,
uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL; u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL;
...@@ -1798,10 +1795,11 @@ static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1798,10 +1795,11 @@ static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
mtd->writesize >> FC_SHIFT, (u32 *)buf, oob); mtd->writesize >> FC_SHIFT, (u32 *)buf, oob);
} }
static int brcmnand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read_page_raw(struct nand_chip *chip, uint8_t *buf,
uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
struct mtd_info *mtd = nand_to_mtd(chip);
u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL; u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL;
int ret; int ret;
...@@ -1814,17 +1812,18 @@ static int brcmnand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1814,17 +1812,18 @@ static int brcmnand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
return ret; return ret;
} }
static int brcmnand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read_oob(struct nand_chip *chip, int page)
int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
return brcmnand_read(mtd, chip, (u64)page << chip->page_shift, return brcmnand_read(mtd, chip, (u64)page << chip->page_shift,
mtd->writesize >> FC_SHIFT, mtd->writesize >> FC_SHIFT,
NULL, (u8 *)chip->oob_poi); NULL, (u8 *)chip->oob_poi);
} }
static int brcmnand_read_oob_raw(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read_oob_raw(struct nand_chip *chip, int page)
int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
brcmnand_set_ecc_enabled(host, 0); brcmnand_set_ecc_enabled(host, 0);
...@@ -1892,7 +1891,7 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1892,7 +1891,7 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,
/* we cannot use SPARE_AREA_PROGRAM when PARTIAL_PAGE_EN=0 */ /* we cannot use SPARE_AREA_PROGRAM when PARTIAL_PAGE_EN=0 */
brcmnand_send_cmd(host, CMD_PROGRAM_PAGE); brcmnand_send_cmd(host, CMD_PROGRAM_PAGE);
status = brcmnand_waitfunc(mtd, chip); status = brcmnand_waitfunc(chip);
if (status & NAND_STATUS_FAIL) { if (status & NAND_STATUS_FAIL) {
dev_info(ctrl->dev, "program failed at %llx\n", dev_info(ctrl->dev, "program failed at %llx\n",
...@@ -1906,9 +1905,10 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1906,9 +1905,10 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,
return ret; return ret;
} }
static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_write_page(struct nand_chip *chip, const uint8_t *buf,
const uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
void *oob = oob_required ? chip->oob_poi : NULL; void *oob = oob_required ? chip->oob_poi : NULL;
...@@ -1918,10 +1918,10 @@ static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1918,10 +1918,10 @@ static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
return nand_prog_page_end_op(chip); return nand_prog_page_end_op(chip);
} }
static int brcmnand_write_page_raw(struct mtd_info *mtd, static int brcmnand_write_page_raw(struct nand_chip *chip, const uint8_t *buf,
struct nand_chip *chip, const uint8_t *buf,
int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
void *oob = oob_required ? chip->oob_poi : NULL; void *oob = oob_required ? chip->oob_poi : NULL;
...@@ -1933,16 +1933,16 @@ static int brcmnand_write_page_raw(struct mtd_info *mtd, ...@@ -1933,16 +1933,16 @@ static int brcmnand_write_page_raw(struct mtd_info *mtd,
return nand_prog_page_end_op(chip); return nand_prog_page_end_op(chip);
} }
static int brcmnand_write_oob(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_write_oob(struct nand_chip *chip, int page)
int page)
{ {
return brcmnand_write(mtd, chip, (u64)page << chip->page_shift, return brcmnand_write(nand_to_mtd(chip), chip,
NULL, chip->oob_poi); (u64)page << chip->page_shift, NULL,
chip->oob_poi);
} }
static int brcmnand_write_oob_raw(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_write_oob_raw(struct nand_chip *chip, int page)
int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_host *host = nand_get_controller_data(chip);
int ret; int ret;
...@@ -2270,15 +2270,12 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) ...@@ -2270,15 +2270,12 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
mtd->owner = THIS_MODULE; mtd->owner = THIS_MODULE;
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
chip->IO_ADDR_R = (void __iomem *)0xdeadbeef; chip->legacy.cmd_ctrl = brcmnand_cmd_ctrl;
chip->IO_ADDR_W = (void __iomem *)0xdeadbeef; chip->legacy.cmdfunc = brcmnand_cmdfunc;
chip->legacy.waitfunc = brcmnand_waitfunc;
chip->cmd_ctrl = brcmnand_cmd_ctrl; chip->legacy.read_byte = brcmnand_read_byte;
chip->cmdfunc = brcmnand_cmdfunc; chip->legacy.read_buf = brcmnand_read_buf;
chip->waitfunc = brcmnand_waitfunc; chip->legacy.write_buf = brcmnand_write_buf;
chip->read_byte = brcmnand_read_byte;
chip->read_buf = brcmnand_read_buf;
chip->write_buf = brcmnand_write_buf;
chip->ecc.mode = NAND_ECC_HW; chip->ecc.mode = NAND_ECC_HW;
chip->ecc.read_page = brcmnand_read_page; chip->ecc.read_page = brcmnand_read_page;
...@@ -2301,7 +2298,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) ...@@ -2301,7 +2298,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
nand_writereg(ctrl, cfg_offs, nand_writereg(ctrl, cfg_offs,
nand_readreg(ctrl, cfg_offs) & ~CFG_BUS_WIDTH); nand_readreg(ctrl, cfg_offs) & ~CFG_BUS_WIDTH);
ret = nand_scan(mtd, 1); ret = nand_scan(chip, 1);
if (ret) if (ret)
return ret; return ret;
...@@ -2616,7 +2613,7 @@ int brcmnand_remove(struct platform_device *pdev) ...@@ -2616,7 +2613,7 @@ int brcmnand_remove(struct platform_device *pdev)
struct brcmnand_host *host; struct brcmnand_host *host;
list_for_each_entry(host, &ctrl->host_list, node) list_for_each_entry(host, &ctrl->host_list, node)
nand_release(nand_to_mtd(&host->chip)); nand_release(&host->chip);
clk_disable_unprepare(ctrl->clk); clk_disable_unprepare(ctrl->clk);
......
...@@ -100,9 +100,8 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; ...@@ -100,9 +100,8 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
#define cafe_readl(cafe, addr) readl((cafe)->mmio + CAFE_##addr) #define cafe_readl(cafe, addr) readl((cafe)->mmio + CAFE_##addr)
#define cafe_writel(cafe, datum, addr) writel(datum, (cafe)->mmio + CAFE_##addr) #define cafe_writel(cafe, datum, addr) writel(datum, (cafe)->mmio + CAFE_##addr)
static int cafe_device_ready(struct mtd_info *mtd) static int cafe_device_ready(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000); int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000);
uint32_t irqs = cafe_readl(cafe, NAND_IRQ); uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
...@@ -117,9 +116,8 @@ static int cafe_device_ready(struct mtd_info *mtd) ...@@ -117,9 +116,8 @@ static int cafe_device_ready(struct mtd_info *mtd)
} }
static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) static void cafe_write_buf(struct nand_chip *chip, const uint8_t *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
if (cafe->usedma) if (cafe->usedma)
...@@ -133,9 +131,8 @@ static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) ...@@ -133,9 +131,8 @@ static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
len, cafe->datalen); len, cafe->datalen);
} }
static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static void cafe_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
if (cafe->usedma) if (cafe->usedma)
...@@ -148,22 +145,21 @@ static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) ...@@ -148,22 +145,21 @@ static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
cafe->datalen += len; cafe->datalen += len;
} }
static uint8_t cafe_read_byte(struct mtd_info *mtd) static uint8_t cafe_read_byte(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
uint8_t d; uint8_t d;
cafe_read_buf(mtd, &d, 1); cafe_read_buf(chip, &d, 1);
cafe_dev_dbg(&cafe->pdev->dev, "Read %02x\n", d); cafe_dev_dbg(&cafe->pdev->dev, "Read %02x\n", d);
return d; return d;
} }
static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, static void cafe_nand_cmdfunc(struct nand_chip *chip, unsigned command,
int column, int page_addr) int column, int page_addr)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(chip);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
int adrbytes = 0; int adrbytes = 0;
uint32_t ctl1; uint32_t ctl1;
...@@ -313,13 +309,12 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, ...@@ -313,13 +309,12 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
cafe_writel(cafe, cafe->ctl2, NAND_CTRL2); cafe_writel(cafe, cafe->ctl2, NAND_CTRL2);
return; return;
} }
nand_wait_ready(mtd); nand_wait_ready(chip);
cafe_writel(cafe, cafe->ctl2, NAND_CTRL2); cafe_writel(cafe, cafe->ctl2, NAND_CTRL2);
} }
static void cafe_select_chip(struct mtd_info *mtd, int chipnr) static void cafe_select_chip(struct nand_chip *chip, int chipnr)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr); cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr);
...@@ -346,17 +341,19 @@ static irqreturn_t cafe_nand_interrupt(int irq, void *id) ...@@ -346,17 +341,19 @@ static irqreturn_t cafe_nand_interrupt(int irq, void *id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int cafe_nand_write_oob(struct mtd_info *mtd, static int cafe_nand_write_oob(struct nand_chip *chip, int page)
struct nand_chip *chip, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi, return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi,
mtd->oobsize); mtd->oobsize);
} }
/* Don't use -- use nand_read_oob_std for now */ /* Don't use -- use nand_read_oob_std for now */
static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, static int cafe_nand_read_oob(struct nand_chip *chip, int page)
int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
return nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize); return nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize);
} }
/** /**
...@@ -369,9 +366,10 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -369,9 +366,10 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
* The hw generator calculates the error syndrome automatically. Therefore * The hw generator calculates the error syndrome automatically. Therefore
* we need a special oob layout and handling. * we need a special oob layout and handling.
*/ */
static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, static int cafe_nand_read_page(struct nand_chip *chip, uint8_t *buf,
uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
unsigned int max_bitflips = 0; unsigned int max_bitflips = 0;
...@@ -380,7 +378,7 @@ static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -380,7 +378,7 @@ static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
cafe_readl(cafe, NAND_ECC_SYN01)); cafe_readl(cafe, NAND_ECC_SYN01));
nand_read_page_op(chip, page, 0, buf, mtd->writesize); nand_read_page_op(chip, page, 0, buf, mtd->writesize);
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); chip->legacy.read_buf(chip, chip->oob_poi, mtd->oobsize);
if (checkecc && cafe_readl(cafe, NAND_ECC_RESULT) & (1<<18)) { if (checkecc && cafe_readl(cafe, NAND_ECC_RESULT) & (1<<18)) {
unsigned short syn[8], pat[4]; unsigned short syn[8], pat[4];
...@@ -531,15 +529,15 @@ static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = { ...@@ -531,15 +529,15 @@ static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = {
}; };
static int cafe_nand_write_page_lowlevel(struct mtd_info *mtd, static int cafe_nand_write_page_lowlevel(struct nand_chip *chip,
struct nand_chip *chip, const uint8_t *buf, int oob_required,
const uint8_t *buf, int oob_required, int page)
int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct cafe_priv *cafe = nand_get_controller_data(chip); struct cafe_priv *cafe = nand_get_controller_data(chip);
nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize); nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize);
chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); chip->legacy.write_buf(chip, chip->oob_poi, mtd->oobsize);
/* Set up ECC autogeneration */ /* Set up ECC autogeneration */
cafe->ctl2 |= (1<<30); cafe->ctl2 |= (1<<30);
...@@ -547,7 +545,7 @@ static int cafe_nand_write_page_lowlevel(struct mtd_info *mtd, ...@@ -547,7 +545,7 @@ static int cafe_nand_write_page_lowlevel(struct mtd_info *mtd,
return nand_prog_page_end_op(chip); return nand_prog_page_end_op(chip);
} }
static int cafe_nand_block_bad(struct mtd_info *mtd, loff_t ofs) static int cafe_nand_block_bad(struct nand_chip *chip, loff_t ofs)
{ {
return 0; return 0;
} }
...@@ -705,23 +703,23 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -705,23 +703,23 @@ static int cafe_nand_probe(struct pci_dev *pdev,
goto out_ior; goto out_ior;
} }
cafe->nand.cmdfunc = cafe_nand_cmdfunc; cafe->nand.legacy.cmdfunc = cafe_nand_cmdfunc;
cafe->nand.dev_ready = cafe_device_ready; cafe->nand.legacy.dev_ready = cafe_device_ready;
cafe->nand.read_byte = cafe_read_byte; cafe->nand.legacy.read_byte = cafe_read_byte;
cafe->nand.read_buf = cafe_read_buf; cafe->nand.legacy.read_buf = cafe_read_buf;
cafe->nand.write_buf = cafe_write_buf; cafe->nand.legacy.write_buf = cafe_write_buf;
cafe->nand.select_chip = cafe_select_chip; cafe->nand.select_chip = cafe_select_chip;
cafe->nand.set_features = nand_get_set_features_notsupp; cafe->nand.legacy.set_features = nand_get_set_features_notsupp;
cafe->nand.get_features = nand_get_set_features_notsupp; cafe->nand.legacy.get_features = nand_get_set_features_notsupp;
cafe->nand.chip_delay = 0; cafe->nand.legacy.chip_delay = 0;
/* Enable the following for a flash based bad block table */ /* Enable the following for a flash based bad block table */
cafe->nand.bbt_options = NAND_BBT_USE_FLASH; cafe->nand.bbt_options = NAND_BBT_USE_FLASH;
if (skipbbt) { if (skipbbt) {
cafe->nand.options |= NAND_SKIP_BBTSCAN; cafe->nand.options |= NAND_SKIP_BBTSCAN;
cafe->nand.block_bad = cafe_nand_block_bad; cafe->nand.legacy.block_bad = cafe_nand_block_bad;
} }
if (numtimings && numtimings != 3) { if (numtimings && numtimings != 3) {
...@@ -783,7 +781,7 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -783,7 +781,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
/* Scan to find existence of the device */ /* Scan to find existence of the device */
cafe->nand.dummy_controller.ops = &cafe_nand_controller_ops; cafe->nand.dummy_controller.ops = &cafe_nand_controller_ops;
err = nand_scan(mtd, 2); err = nand_scan(&cafe->nand, 2);
if (err) if (err)
goto out_irq; goto out_irq;
...@@ -819,7 +817,7 @@ static void cafe_nand_remove(struct pci_dev *pdev) ...@@ -819,7 +817,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
/* Disable NAND IRQ in global IRQ mask register */ /* Disable NAND IRQ in global IRQ mask register */
cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK);
free_irq(pdev->irq, mtd); free_irq(pdev->irq, mtd);
nand_release(mtd); nand_release(chip);
free_rs(cafe->rs); free_rs(cafe->rs);
pci_iounmap(pdev, cafe->mmio); pci_iounmap(pdev, cafe->mmio);
dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
......
...@@ -49,29 +49,26 @@ static const struct mtd_partition partition_info[] = { ...@@ -49,29 +49,26 @@ static const struct mtd_partition partition_info[] = {
}; };
#define NUM_PARTITIONS (ARRAY_SIZE(partition_info)) #define NUM_PARTITIONS (ARRAY_SIZE(partition_info))
static u_char cmx270_read_byte(struct mtd_info *mtd) static u_char cmx270_read_byte(struct nand_chip *this)
{ {
struct nand_chip *this = mtd_to_nand(mtd); return (readl(this->legacy.IO_ADDR_R) >> 16);
return (readl(this->IO_ADDR_R) >> 16);
} }
static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len) static void cmx270_write_buf(struct nand_chip *this, const u_char *buf,
int len)
{ {
int i; int i;
struct nand_chip *this = mtd_to_nand(mtd);
for (i=0; i<len; i++) for (i=0; i<len; i++)
writel((*buf++ << 16), this->IO_ADDR_W); writel((*buf++ << 16), this->legacy.IO_ADDR_W);
} }
static void cmx270_read_buf(struct mtd_info *mtd, u_char *buf, int len) static void cmx270_read_buf(struct nand_chip *this, u_char *buf, int len)
{ {
int i; int i;
struct nand_chip *this = mtd_to_nand(mtd);
for (i=0; i<len; i++) for (i=0; i<len; i++)
*buf++ = readl(this->IO_ADDR_R) >> 16; *buf++ = readl(this->legacy.IO_ADDR_R) >> 16;
} }
static inline void nand_cs_on(void) static inline void nand_cs_on(void)
...@@ -89,11 +86,10 @@ static void nand_cs_off(void) ...@@ -89,11 +86,10 @@ static void nand_cs_off(void)
/* /*
* hardware specific access to control-lines * hardware specific access to control-lines
*/ */
static void cmx270_hwcontrol(struct mtd_info *mtd, int dat, static void cmx270_hwcontrol(struct nand_chip *this, int dat,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); unsigned int nandaddr = (unsigned int)this->legacy.IO_ADDR_W;
unsigned int nandaddr = (unsigned int)this->IO_ADDR_W;
dsb(); dsb();
...@@ -113,9 +109,9 @@ static void cmx270_hwcontrol(struct mtd_info *mtd, int dat, ...@@ -113,9 +109,9 @@ static void cmx270_hwcontrol(struct mtd_info *mtd, int dat,
} }
dsb(); dsb();
this->IO_ADDR_W = (void __iomem*)nandaddr; this->legacy.IO_ADDR_W = (void __iomem*)nandaddr;
if (dat != NAND_CMD_NONE) if (dat != NAND_CMD_NONE)
writel((dat << 16), this->IO_ADDR_W); writel((dat << 16), this->legacy.IO_ADDR_W);
dsb(); dsb();
} }
...@@ -123,7 +119,7 @@ static void cmx270_hwcontrol(struct mtd_info *mtd, int dat, ...@@ -123,7 +119,7 @@ static void cmx270_hwcontrol(struct mtd_info *mtd, int dat,
/* /*
* read device ready pin * read device ready pin
*/ */
static int cmx270_device_ready(struct mtd_info *mtd) static int cmx270_device_ready(struct nand_chip *this)
{ {
dsb(); dsb();
...@@ -177,23 +173,23 @@ static int __init cmx270_init(void) ...@@ -177,23 +173,23 @@ static int __init cmx270_init(void)
cmx270_nand_mtd->owner = THIS_MODULE; cmx270_nand_mtd->owner = THIS_MODULE;
/* insert callbacks */ /* insert callbacks */
this->IO_ADDR_R = cmx270_nand_io; this->legacy.IO_ADDR_R = cmx270_nand_io;
this->IO_ADDR_W = cmx270_nand_io; this->legacy.IO_ADDR_W = cmx270_nand_io;
this->cmd_ctrl = cmx270_hwcontrol; this->legacy.cmd_ctrl = cmx270_hwcontrol;
this->dev_ready = cmx270_device_ready; this->legacy.dev_ready = cmx270_device_ready;
/* 15 us command delay time */ /* 15 us command delay time */
this->chip_delay = 20; this->legacy.chip_delay = 20;
this->ecc.mode = NAND_ECC_SOFT; this->ecc.mode = NAND_ECC_SOFT;
this->ecc.algo = NAND_ECC_HAMMING; this->ecc.algo = NAND_ECC_HAMMING;
/* read/write functions */ /* read/write functions */
this->read_byte = cmx270_read_byte; this->legacy.read_byte = cmx270_read_byte;
this->read_buf = cmx270_read_buf; this->legacy.read_buf = cmx270_read_buf;
this->write_buf = cmx270_write_buf; this->legacy.write_buf = cmx270_write_buf;
/* Scan to find existence of the device */ /* Scan to find existence of the device */
ret = nand_scan(cmx270_nand_mtd, 1); ret = nand_scan(this, 1);
if (ret) { if (ret) {
pr_notice("No NAND device\n"); pr_notice("No NAND device\n");
goto err_scan; goto err_scan;
...@@ -228,7 +224,7 @@ module_init(cmx270_init); ...@@ -228,7 +224,7 @@ module_init(cmx270_init);
static void __exit cmx270_cleanup(void) static void __exit cmx270_cleanup(void)
{ {
/* Release resources, unregister device */ /* Release resources, unregister device */
nand_release(cmx270_nand_mtd); nand_release(mtd_to_nand(cmx270_nand_mtd));
gpio_free(GPIO_NAND_RB); gpio_free(GPIO_NAND_RB);
gpio_free(GPIO_NAND_CS); gpio_free(GPIO_NAND_CS);
......
...@@ -93,83 +93,74 @@ ...@@ -93,83 +93,74 @@
#define CS_NAND_ECC_CLRECC (1<<1) #define CS_NAND_ECC_CLRECC (1<<1)
#define CS_NAND_ECC_ENECC (1<<0) #define CS_NAND_ECC_ENECC (1<<0)
static void cs553x_read_buf(struct mtd_info *mtd, u_char *buf, int len) static void cs553x_read_buf(struct nand_chip *this, u_char *buf, int len)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
while (unlikely(len > 0x800)) { while (unlikely(len > 0x800)) {
memcpy_fromio(buf, this->IO_ADDR_R, 0x800); memcpy_fromio(buf, this->legacy.IO_ADDR_R, 0x800);
buf += 0x800; buf += 0x800;
len -= 0x800; len -= 0x800;
} }
memcpy_fromio(buf, this->IO_ADDR_R, len); memcpy_fromio(buf, this->legacy.IO_ADDR_R, len);
} }
static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len) static void cs553x_write_buf(struct nand_chip *this, const u_char *buf, int len)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
while (unlikely(len > 0x800)) { while (unlikely(len > 0x800)) {
memcpy_toio(this->IO_ADDR_R, buf, 0x800); memcpy_toio(this->legacy.IO_ADDR_R, buf, 0x800);
buf += 0x800; buf += 0x800;
len -= 0x800; len -= 0x800;
} }
memcpy_toio(this->IO_ADDR_R, buf, len); memcpy_toio(this->legacy.IO_ADDR_R, buf, len);
} }
static unsigned char cs553x_read_byte(struct mtd_info *mtd) static unsigned char cs553x_read_byte(struct nand_chip *this)
{ {
struct nand_chip *this = mtd_to_nand(mtd); return readb(this->legacy.IO_ADDR_R);
return readb(this->IO_ADDR_R);
} }
static void cs553x_write_byte(struct mtd_info *mtd, u_char byte) static void cs553x_write_byte(struct nand_chip *this, u_char byte)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
int i = 100000; int i = 100000;
while (i && readb(this->IO_ADDR_R + MM_NAND_STS) & CS_NAND_CTLR_BUSY) { while (i && readb(this->legacy.IO_ADDR_R + MM_NAND_STS) & CS_NAND_CTLR_BUSY) {
udelay(1); udelay(1);
i--; i--;
} }
writeb(byte, this->IO_ADDR_W + 0x801); writeb(byte, this->legacy.IO_ADDR_W + 0x801);
} }
static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd, static void cs553x_hwcontrol(struct nand_chip *this, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct nand_chip *this = mtd_to_nand(mtd); void __iomem *mmio_base = this->legacy.IO_ADDR_R;
void __iomem *mmio_base = this->IO_ADDR_R;
if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_CTRL_CHANGE) {
unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^ 0x01; unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^ 0x01;
writeb(ctl, mmio_base + MM_NAND_CTL); writeb(ctl, mmio_base + MM_NAND_CTL);
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
cs553x_write_byte(mtd, cmd); cs553x_write_byte(this, cmd);
} }
static int cs553x_device_ready(struct mtd_info *mtd) static int cs553x_device_ready(struct nand_chip *this)
{ {
struct nand_chip *this = mtd_to_nand(mtd); void __iomem *mmio_base = this->legacy.IO_ADDR_R;
void __iomem *mmio_base = this->IO_ADDR_R;
unsigned char foo = readb(mmio_base + MM_NAND_STS); unsigned char foo = readb(mmio_base + MM_NAND_STS);
return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY); return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY);
} }
static void cs_enable_hwecc(struct mtd_info *mtd, int mode) static void cs_enable_hwecc(struct nand_chip *this, int mode)
{ {
struct nand_chip *this = mtd_to_nand(mtd); void __iomem *mmio_base = this->legacy.IO_ADDR_R;
void __iomem *mmio_base = this->IO_ADDR_R;
writeb(0x07, mmio_base + MM_NAND_ECC_CTL); writeb(0x07, mmio_base + MM_NAND_ECC_CTL);
} }
static int cs_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,
u_char *ecc_code)
{ {
uint32_t ecc; uint32_t ecc;
struct nand_chip *this = mtd_to_nand(mtd); void __iomem *mmio_base = this->legacy.IO_ADDR_R;
void __iomem *mmio_base = this->IO_ADDR_R;
ecc = readl(mmio_base + MM_NAND_STS); ecc = readl(mmio_base + MM_NAND_STS);
...@@ -208,20 +199,20 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) ...@@ -208,20 +199,20 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
new_mtd->owner = THIS_MODULE; new_mtd->owner = THIS_MODULE;
/* map physical address */ /* map physical address */
this->IO_ADDR_R = this->IO_ADDR_W = ioremap(adr, 4096); this->legacy.IO_ADDR_R = this->legacy.IO_ADDR_W = ioremap(adr, 4096);
if (!this->IO_ADDR_R) { if (!this->legacy.IO_ADDR_R) {
pr_warn("ioremap cs553x NAND @0x%08lx failed\n", adr); pr_warn("ioremap cs553x NAND @0x%08lx failed\n", adr);
err = -EIO; err = -EIO;
goto out_mtd; goto out_mtd;
} }
this->cmd_ctrl = cs553x_hwcontrol; this->legacy.cmd_ctrl = cs553x_hwcontrol;
this->dev_ready = cs553x_device_ready; this->legacy.dev_ready = cs553x_device_ready;
this->read_byte = cs553x_read_byte; this->legacy.read_byte = cs553x_read_byte;
this->read_buf = cs553x_read_buf; this->legacy.read_buf = cs553x_read_buf;
this->write_buf = cs553x_write_buf; this->legacy.write_buf = cs553x_write_buf;
this->chip_delay = 0; this->legacy.chip_delay = 0;
this->ecc.mode = NAND_ECC_HW; this->ecc.mode = NAND_ECC_HW;
this->ecc.size = 256; this->ecc.size = 256;
...@@ -241,7 +232,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) ...@@ -241,7 +232,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
} }
/* Scan to find existence of the device */ /* Scan to find existence of the device */
err = nand_scan(new_mtd, 1); err = nand_scan(this, 1);
if (err) if (err)
goto out_free; goto out_free;
...@@ -251,7 +242,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) ...@@ -251,7 +242,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
out_free: out_free:
kfree(new_mtd->name); kfree(new_mtd->name);
out_ior: out_ior:
iounmap(this->IO_ADDR_R); iounmap(this->legacy.IO_ADDR_R);
out_mtd: out_mtd:
kfree(this); kfree(this);
out: out:
...@@ -333,10 +324,10 @@ static void __exit cs553x_cleanup(void) ...@@ -333,10 +324,10 @@ static void __exit cs553x_cleanup(void)
continue; continue;
this = mtd_to_nand(mtd); this = mtd_to_nand(mtd);
mmio_base = this->IO_ADDR_R; mmio_base = this->legacy.IO_ADDR_R;
/* Release resources, unregister device */ /* Release resources, unregister device */
nand_release(mtd); nand_release(this);
kfree(mtd->name); kfree(mtd->name);
cs553x_mtd[i] = NULL; cs553x_mtd[i] = NULL;
......
...@@ -97,12 +97,11 @@ static inline void davinci_nand_writel(struct davinci_nand_info *info, ...@@ -97,12 +97,11 @@ static inline void davinci_nand_writel(struct davinci_nand_info *info,
* Access to hardware control lines: ALE, CLE, secondary chipselect. * Access to hardware control lines: ALE, CLE, secondary chipselect.
*/ */
static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd, static void nand_davinci_hwcontrol(struct nand_chip *nand, int cmd,
unsigned int ctrl) unsigned int ctrl)
{ {
struct davinci_nand_info *info = to_davinci_nand(mtd); struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(nand));
void __iomem *addr = info->current_cs; void __iomem *addr = info->current_cs;
struct nand_chip *nand = mtd_to_nand(mtd);
/* Did the control lines change? */ /* Did the control lines change? */
if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_CTRL_CHANGE) {
...@@ -111,16 +110,16 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd, ...@@ -111,16 +110,16 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd,
else if ((ctrl & NAND_CTRL_ALE) == NAND_CTRL_ALE) else if ((ctrl & NAND_CTRL_ALE) == NAND_CTRL_ALE)
addr += info->mask_ale; addr += info->mask_ale;
nand->IO_ADDR_W = addr; nand->legacy.IO_ADDR_W = addr;
} }
if (cmd != NAND_CMD_NONE) if (cmd != NAND_CMD_NONE)
iowrite8(cmd, nand->IO_ADDR_W); iowrite8(cmd, nand->legacy.IO_ADDR_W);
} }
static void nand_davinci_select_chip(struct mtd_info *mtd, int chip) static void nand_davinci_select_chip(struct nand_chip *nand, int chip)
{ {
struct davinci_nand_info *info = to_davinci_nand(mtd); struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(nand));
info->current_cs = info->vaddr; info->current_cs = info->vaddr;
...@@ -128,8 +127,8 @@ static void nand_davinci_select_chip(struct mtd_info *mtd, int chip) ...@@ -128,8 +127,8 @@ static void nand_davinci_select_chip(struct mtd_info *mtd, int chip)
if (chip > 0) if (chip > 0)
info->current_cs += info->mask_chipsel; info->current_cs += info->mask_chipsel;
info->chip.IO_ADDR_W = info->current_cs; info->chip.legacy.IO_ADDR_W = info->current_cs;
info->chip.IO_ADDR_R = info->chip.IO_ADDR_W; info->chip.legacy.IO_ADDR_R = info->chip.legacy.IO_ADDR_W;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
...@@ -146,16 +145,16 @@ static inline uint32_t nand_davinci_readecc_1bit(struct mtd_info *mtd) ...@@ -146,16 +145,16 @@ static inline uint32_t nand_davinci_readecc_1bit(struct mtd_info *mtd)
+ 4 * info->core_chipsel); + 4 * info->core_chipsel);
} }
static void nand_davinci_hwctl_1bit(struct mtd_info *mtd, int mode) static void nand_davinci_hwctl_1bit(struct nand_chip *chip, int mode)
{ {
struct davinci_nand_info *info; struct davinci_nand_info *info;
uint32_t nandcfr; uint32_t nandcfr;
unsigned long flags; unsigned long flags;
info = to_davinci_nand(mtd); info = to_davinci_nand(nand_to_mtd(chip));
/* Reset ECC hardware */ /* Reset ECC hardware */
nand_davinci_readecc_1bit(mtd); nand_davinci_readecc_1bit(nand_to_mtd(chip));
spin_lock_irqsave(&davinci_nand_lock, flags); spin_lock_irqsave(&davinci_nand_lock, flags);
...@@ -170,10 +169,10 @@ static void nand_davinci_hwctl_1bit(struct mtd_info *mtd, int mode) ...@@ -170,10 +169,10 @@ static void nand_davinci_hwctl_1bit(struct mtd_info *mtd, int mode)
/* /*
* Read hardware ECC value and pack into three bytes * Read hardware ECC value and pack into three bytes
*/ */
static int nand_davinci_calculate_1bit(struct mtd_info *mtd, static int nand_davinci_calculate_1bit(struct nand_chip *chip,
const u_char *dat, u_char *ecc_code) const u_char *dat, u_char *ecc_code)
{ {
unsigned int ecc_val = nand_davinci_readecc_1bit(mtd); unsigned int ecc_val = nand_davinci_readecc_1bit(nand_to_mtd(chip));
unsigned int ecc24 = (ecc_val & 0x0fff) | ((ecc_val & 0x0fff0000) >> 4); unsigned int ecc24 = (ecc_val & 0x0fff) | ((ecc_val & 0x0fff0000) >> 4);
/* invert so that erased block ecc is correct */ /* invert so that erased block ecc is correct */
...@@ -185,10 +184,9 @@ static int nand_davinci_calculate_1bit(struct mtd_info *mtd, ...@@ -185,10 +184,9 @@ static int nand_davinci_calculate_1bit(struct mtd_info *mtd,
return 0; return 0;
} }
static int nand_davinci_correct_1bit(struct mtd_info *mtd, u_char *dat, static int nand_davinci_correct_1bit(struct nand_chip *chip, u_char *dat,
u_char *read_ecc, u_char *calc_ecc) u_char *read_ecc, u_char *calc_ecc)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
uint32_t eccNand = read_ecc[0] | (read_ecc[1] << 8) | uint32_t eccNand = read_ecc[0] | (read_ecc[1] << 8) |
(read_ecc[2] << 16); (read_ecc[2] << 16);
uint32_t eccCalc = calc_ecc[0] | (calc_ecc[1] << 8) | uint32_t eccCalc = calc_ecc[0] | (calc_ecc[1] << 8) |
...@@ -231,9 +229,9 @@ static int nand_davinci_correct_1bit(struct mtd_info *mtd, u_char *dat, ...@@ -231,9 +229,9 @@ static int nand_davinci_correct_1bit(struct mtd_info *mtd, u_char *dat,
* OOB without recomputing ECC. * OOB without recomputing ECC.
*/ */
static void nand_davinci_hwctl_4bit(struct mtd_info *mtd, int mode) static void nand_davinci_hwctl_4bit(struct nand_chip *chip, int mode)
{ {
struct davinci_nand_info *info = to_davinci_nand(mtd); struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(chip));
unsigned long flags; unsigned long flags;
u32 val; u32 val;
...@@ -266,10 +264,10 @@ nand_davinci_readecc_4bit(struct davinci_nand_info *info, u32 code[4]) ...@@ -266,10 +264,10 @@ nand_davinci_readecc_4bit(struct davinci_nand_info *info, u32 code[4])
} }
/* Terminate read ECC; or return ECC (as bytes) of data written to NAND. */ /* Terminate read ECC; or return ECC (as bytes) of data written to NAND. */
static int nand_davinci_calculate_4bit(struct mtd_info *mtd, static int nand_davinci_calculate_4bit(struct nand_chip *chip,
const u_char *dat, u_char *ecc_code) const u_char *dat, u_char *ecc_code)
{ {
struct davinci_nand_info *info = to_davinci_nand(mtd); struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(chip));
u32 raw_ecc[4], *p; u32 raw_ecc[4], *p;
unsigned i; unsigned i;
...@@ -303,11 +301,11 @@ static int nand_davinci_calculate_4bit(struct mtd_info *mtd, ...@@ -303,11 +301,11 @@ static int nand_davinci_calculate_4bit(struct mtd_info *mtd,
/* Correct up to 4 bits in data we just read, using state left in the /* Correct up to 4 bits in data we just read, using state left in the
* hardware plus the ecc_code computed when it was first written. * hardware plus the ecc_code computed when it was first written.
*/ */
static int nand_davinci_correct_4bit(struct mtd_info *mtd, static int nand_davinci_correct_4bit(struct nand_chip *chip, u_char *data,
u_char *data, u_char *ecc_code, u_char *null) u_char *ecc_code, u_char *null)
{ {
int i; int i;
struct davinci_nand_info *info = to_davinci_nand(mtd); struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(chip));
unsigned short ecc10[8]; unsigned short ecc10[8];
unsigned short *ecc16; unsigned short *ecc16;
u32 syndrome[4]; u32 syndrome[4];
...@@ -436,38 +434,35 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd, ...@@ -436,38 +434,35 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd,
* the two LSBs for NAND access ... so we can issue 32-bit reads/writes * the two LSBs for NAND access ... so we can issue 32-bit reads/writes
* and have that transparently morphed into multiple NAND operations. * and have that transparently morphed into multiple NAND operations.
*/ */
static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static void nand_davinci_read_buf(struct nand_chip *chip, uint8_t *buf,
int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0) if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0)
ioread32_rep(chip->IO_ADDR_R, buf, len >> 2); ioread32_rep(chip->legacy.IO_ADDR_R, buf, len >> 2);
else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0) else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0)
ioread16_rep(chip->IO_ADDR_R, buf, len >> 1); ioread16_rep(chip->legacy.IO_ADDR_R, buf, len >> 1);
else else
ioread8_rep(chip->IO_ADDR_R, buf, len); ioread8_rep(chip->legacy.IO_ADDR_R, buf, len);
} }
static void nand_davinci_write_buf(struct mtd_info *mtd, static void nand_davinci_write_buf(struct nand_chip *chip, const uint8_t *buf,
const uint8_t *buf, int len) int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0) if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0)
iowrite32_rep(chip->IO_ADDR_R, buf, len >> 2); iowrite32_rep(chip->legacy.IO_ADDR_R, buf, len >> 2);
else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0) else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0)
iowrite16_rep(chip->IO_ADDR_R, buf, len >> 1); iowrite16_rep(chip->legacy.IO_ADDR_R, buf, len >> 1);
else else
iowrite8_rep(chip->IO_ADDR_R, buf, len); iowrite8_rep(chip->legacy.IO_ADDR_R, buf, len);
} }
/* /*
* Check hardware register for wait status. Returns 1 if device is ready, * Check hardware register for wait status. Returns 1 if device is ready,
* 0 if it is still busy. * 0 if it is still busy.
*/ */
static int nand_davinci_dev_ready(struct mtd_info *mtd) static int nand_davinci_dev_ready(struct nand_chip *chip)
{ {
struct davinci_nand_info *info = to_davinci_nand(mtd); struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(chip));
return davinci_nand_readl(info, NANDFSR_OFFSET) & BIT(0); return davinci_nand_readl(info, NANDFSR_OFFSET) & BIT(0);
} }
...@@ -764,9 +759,9 @@ static int nand_davinci_probe(struct platform_device *pdev) ...@@ -764,9 +759,9 @@ static int nand_davinci_probe(struct platform_device *pdev)
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
nand_set_flash_node(&info->chip, pdev->dev.of_node); nand_set_flash_node(&info->chip, pdev->dev.of_node);
info->chip.IO_ADDR_R = vaddr; info->chip.legacy.IO_ADDR_R = vaddr;
info->chip.IO_ADDR_W = vaddr; info->chip.legacy.IO_ADDR_W = vaddr;
info->chip.chip_delay = 0; info->chip.legacy.chip_delay = 0;
info->chip.select_chip = nand_davinci_select_chip; info->chip.select_chip = nand_davinci_select_chip;
/* options such as NAND_BBT_USE_FLASH */ /* options such as NAND_BBT_USE_FLASH */
...@@ -786,12 +781,12 @@ static int nand_davinci_probe(struct platform_device *pdev) ...@@ -786,12 +781,12 @@ static int nand_davinci_probe(struct platform_device *pdev)
info->mask_cle = pdata->mask_cle ? : MASK_CLE; info->mask_cle = pdata->mask_cle ? : MASK_CLE;
/* Set address of hardware control function */ /* Set address of hardware control function */
info->chip.cmd_ctrl = nand_davinci_hwcontrol; info->chip.legacy.cmd_ctrl = nand_davinci_hwcontrol;
info->chip.dev_ready = nand_davinci_dev_ready; info->chip.legacy.dev_ready = nand_davinci_dev_ready;
/* Speed up buffer I/O */ /* Speed up buffer I/O */
info->chip.read_buf = nand_davinci_read_buf; info->chip.legacy.read_buf = nand_davinci_read_buf;
info->chip.write_buf = nand_davinci_write_buf; info->chip.legacy.write_buf = nand_davinci_write_buf;
/* Use board-specific ECC config */ /* Use board-specific ECC config */
info->chip.ecc.mode = pdata->ecc_mode; info->chip.ecc.mode = pdata->ecc_mode;
...@@ -807,7 +802,7 @@ static int nand_davinci_probe(struct platform_device *pdev) ...@@ -807,7 +802,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
/* Scan to find existence of the device(s) */ /* Scan to find existence of the device(s) */
info->chip.dummy_controller.ops = &davinci_nand_controller_ops; info->chip.dummy_controller.ops = &davinci_nand_controller_ops;
ret = nand_scan(mtd, pdata->mask_chipsel ? 2 : 1); ret = nand_scan(&info->chip, pdata->mask_chipsel ? 2 : 1);
if (ret < 0) { if (ret < 0) {
dev_dbg(&pdev->dev, "no NAND chip(s) found\n"); dev_dbg(&pdev->dev, "no NAND chip(s) found\n");
return ret; return ret;
...@@ -841,7 +836,7 @@ static int nand_davinci_remove(struct platform_device *pdev) ...@@ -841,7 +836,7 @@ static int nand_davinci_remove(struct platform_device *pdev)
ecc4_busy = false; ecc4_busy = false;
spin_unlock_irq(&davinci_nand_lock); spin_unlock_irq(&davinci_nand_lock);
nand_release(nand_to_mtd(&info->chip)); nand_release(&info->chip);
return 0; return 0;
} }
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* NAND Flash Controller Device Driver * NAND Flash Controller Device Driver
* Copyright (c) 2009 - 2010, Intel Corporation and its suppliers. * Copyright (c) 2009 - 2010, Intel Corporation and its suppliers.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*/ */
#ifndef __DENALI_H__ #ifndef __DENALI_H__
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* NAND Flash Controller Device Driver for DT * NAND Flash Controller Device Driver for DT
* *
* Copyright © 2011, Picochip. * Copyright © 2011, Picochip.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/clk.h> #include <linux/clk.h>
...@@ -202,6 +194,6 @@ static struct platform_driver denali_dt_driver = { ...@@ -202,6 +194,6 @@ static struct platform_driver denali_dt_driver = {
}; };
module_platform_driver(denali_dt_driver); module_platform_driver(denali_dt_driver);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Jamie Iles"); MODULE_AUTHOR("Jamie Iles");
MODULE_DESCRIPTION("DT driver for Denali NAND controller"); MODULE_DESCRIPTION("DT driver for Denali NAND controller");
// SPDX-License-Identifier: GPL-2.0
/* /*
* NAND Flash Controller Device Driver * NAND Flash Controller Device Driver
* Copyright © 2009-2010, Intel Corporation and its suppliers. * Copyright © 2009-2010, Intel Corporation and its suppliers.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/errno.h> #include <linux/errno.h>
......
This diff is collapsed.
This diff is collapsed.
...@@ -317,10 +317,10 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob) ...@@ -317,10 +317,10 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob)
} }
/* cmdfunc send commands to the FCM */ /* cmdfunc send commands to the FCM */
static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command, static void fsl_elbc_cmdfunc(struct nand_chip *chip, unsigned int command,
int column, int page_addr) int column, int page_addr)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(chip);
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip); struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
struct fsl_lbc_ctrl *ctrl = priv->ctrl; struct fsl_lbc_ctrl *ctrl = priv->ctrl;
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand; struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand;
...@@ -533,7 +533,7 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command, ...@@ -533,7 +533,7 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
} }
} }
static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip) static void fsl_elbc_select_chip(struct nand_chip *chip, int cs)
{ {
/* The hardware does not seem to support multiple /* The hardware does not seem to support multiple
* chips per bank. * chips per bank.
...@@ -543,9 +543,9 @@ static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip) ...@@ -543,9 +543,9 @@ static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip)
/* /*
* Write buf to the FCM Controller Data Buffer * Write buf to the FCM Controller Data Buffer
*/ */
static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) static void fsl_elbc_write_buf(struct nand_chip *chip, const u8 *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(chip);
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip); struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand; struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
unsigned int bufsize = mtd->writesize + mtd->oobsize; unsigned int bufsize = mtd->writesize + mtd->oobsize;
...@@ -581,9 +581,8 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) ...@@ -581,9 +581,8 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
* read a byte from either the FCM hardware buffer if it has any data left * read a byte from either the FCM hardware buffer if it has any data left
* otherwise issue a command to read a single byte. * otherwise issue a command to read a single byte.
*/ */
static u8 fsl_elbc_read_byte(struct mtd_info *mtd) static u8 fsl_elbc_read_byte(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip); struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand; struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
...@@ -598,9 +597,8 @@ static u8 fsl_elbc_read_byte(struct mtd_info *mtd) ...@@ -598,9 +597,8 @@ static u8 fsl_elbc_read_byte(struct mtd_info *mtd)
/* /*
* Read from the FCM Controller Data Buffer * Read from the FCM Controller Data Buffer
*/ */
static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len) static void fsl_elbc_read_buf(struct nand_chip *chip, u8 *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip); struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand; struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
int avail; int avail;
...@@ -623,7 +621,7 @@ static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len) ...@@ -623,7 +621,7 @@ static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
/* This function is called after Program and Erase Operations to /* This function is called after Program and Erase Operations to
* check for success or failure. * check for success or failure.
*/ */
static int fsl_elbc_wait(struct mtd_info *mtd, struct nand_chip *chip) static int fsl_elbc_wait(struct nand_chip *chip)
{ {
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip); struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand; struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
...@@ -660,8 +658,8 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip) ...@@ -660,8 +658,8 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip)
chip->chipsize); chip->chipsize);
dev_dbg(priv->dev, "fsl_elbc_init: nand->pagemask = %8x\n", dev_dbg(priv->dev, "fsl_elbc_init: nand->pagemask = %8x\n",
chip->pagemask); chip->pagemask);
dev_dbg(priv->dev, "fsl_elbc_init: nand->chip_delay = %d\n", dev_dbg(priv->dev, "fsl_elbc_init: nand->legacy.chip_delay = %d\n",
chip->chip_delay); chip->legacy.chip_delay);
dev_dbg(priv->dev, "fsl_elbc_init: nand->badblockpos = %d\n", dev_dbg(priv->dev, "fsl_elbc_init: nand->badblockpos = %d\n",
chip->badblockpos); chip->badblockpos);
dev_dbg(priv->dev, "fsl_elbc_init: nand->chip_shift = %d\n", dev_dbg(priv->dev, "fsl_elbc_init: nand->chip_shift = %d\n",
...@@ -710,18 +708,19 @@ static const struct nand_controller_ops fsl_elbc_controller_ops = { ...@@ -710,18 +708,19 @@ static const struct nand_controller_ops fsl_elbc_controller_ops = {
.attach_chip = fsl_elbc_attach_chip, .attach_chip = fsl_elbc_attach_chip,
}; };
static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip, static int fsl_elbc_read_page(struct nand_chip *chip, uint8_t *buf,
uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip); struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
struct fsl_lbc_ctrl *ctrl = priv->ctrl; struct fsl_lbc_ctrl *ctrl = priv->ctrl;
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand; struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand;
nand_read_page_op(chip, page, 0, buf, mtd->writesize); nand_read_page_op(chip, page, 0, buf, mtd->writesize);
if (oob_required) if (oob_required)
fsl_elbc_read_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_elbc_read_buf(chip, chip->oob_poi, mtd->oobsize);
if (fsl_elbc_wait(mtd, chip) & NAND_STATUS_FAIL) if (fsl_elbc_wait(chip) & NAND_STATUS_FAIL)
mtd->ecc_stats.failed++; mtd->ecc_stats.failed++;
return elbc_fcm_ctrl->max_bitflips; return elbc_fcm_ctrl->max_bitflips;
...@@ -730,11 +729,13 @@ static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -730,11 +729,13 @@ static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
/* ECC will be calculated automatically, and errors will be detected in /* ECC will be calculated automatically, and errors will be detected in
* waitfunc. * waitfunc.
*/ */
static int fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip, static int fsl_elbc_write_page(struct nand_chip *chip, const uint8_t *buf,
const uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize); nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize);
fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_elbc_write_buf(chip, chip->oob_poi, mtd->oobsize);
return nand_prog_page_end_op(chip); return nand_prog_page_end_op(chip);
} }
...@@ -742,13 +743,15 @@ static int fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -742,13 +743,15 @@ static int fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
/* ECC will be calculated automatically, and errors will be detected in /* ECC will be calculated automatically, and errors will be detected in
* waitfunc. * waitfunc.
*/ */
static int fsl_elbc_write_subpage(struct mtd_info *mtd, struct nand_chip *chip, static int fsl_elbc_write_subpage(struct nand_chip *chip, uint32_t offset,
uint32_t offset, uint32_t data_len, uint32_t data_len, const uint8_t *buf,
const uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
nand_prog_page_begin_op(chip, page, 0, NULL, 0); nand_prog_page_begin_op(chip, page, 0, NULL, 0);
fsl_elbc_write_buf(mtd, buf, mtd->writesize); fsl_elbc_write_buf(chip, buf, mtd->writesize);
fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_elbc_write_buf(chip, chip->oob_poi, mtd->oobsize);
return nand_prog_page_end_op(chip); return nand_prog_page_end_op(chip);
} }
...@@ -773,14 +776,14 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv) ...@@ -773,14 +776,14 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
/* fill in nand_chip structure */ /* fill in nand_chip structure */
/* set up function call table */ /* set up function call table */
chip->read_byte = fsl_elbc_read_byte; chip->legacy.read_byte = fsl_elbc_read_byte;
chip->write_buf = fsl_elbc_write_buf; chip->legacy.write_buf = fsl_elbc_write_buf;
chip->read_buf = fsl_elbc_read_buf; chip->legacy.read_buf = fsl_elbc_read_buf;
chip->select_chip = fsl_elbc_select_chip; chip->select_chip = fsl_elbc_select_chip;
chip->cmdfunc = fsl_elbc_cmdfunc; chip->legacy.cmdfunc = fsl_elbc_cmdfunc;
chip->waitfunc = fsl_elbc_wait; chip->legacy.waitfunc = fsl_elbc_wait;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
chip->bbt_td = &bbt_main_descr; chip->bbt_td = &bbt_main_descr;
chip->bbt_md = &bbt_mirror_descr; chip->bbt_md = &bbt_mirror_descr;
...@@ -915,7 +918,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev) ...@@ -915,7 +918,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev)
goto err; goto err;
priv->chip.controller->ops = &fsl_elbc_controller_ops; priv->chip.controller->ops = &fsl_elbc_controller_ops;
ret = nand_scan(mtd, 1); ret = nand_scan(&priv->chip, 1);
if (ret) if (ret)
goto err; goto err;
...@@ -942,9 +945,8 @@ static int fsl_elbc_nand_remove(struct platform_device *pdev) ...@@ -942,9 +945,8 @@ static int fsl_elbc_nand_remove(struct platform_device *pdev)
{ {
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = fsl_lbc_ctrl_dev->nand; struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = fsl_lbc_ctrl_dev->nand;
struct fsl_elbc_mtd *priv = dev_get_drvdata(&pdev->dev); struct fsl_elbc_mtd *priv = dev_get_drvdata(&pdev->dev);
struct mtd_info *mtd = nand_to_mtd(&priv->chip);
nand_release(mtd); nand_release(&priv->chip);
fsl_elbc_chip_remove(priv); fsl_elbc_chip_remove(priv);
mutex_lock(&fsl_elbc_nand_mutex); mutex_lock(&fsl_elbc_nand_mutex);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand_ecc.h>
#include <linux/fsl_ifc.h> #include <linux/fsl_ifc.h>
#include <linux/iopoll.h>
#define ERR_BYTE 0xFF /* Value returned for read #define ERR_BYTE 0xFF /* Value returned for read
bytes when read failed */ bytes when read failed */
...@@ -300,9 +301,9 @@ static void fsl_ifc_do_read(struct nand_chip *chip, ...@@ -300,9 +301,9 @@ static void fsl_ifc_do_read(struct nand_chip *chip,
} }
/* cmdfunc send commands to the IFC NAND Machine */ /* cmdfunc send commands to the IFC NAND Machine */
static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, static void fsl_ifc_cmdfunc(struct nand_chip *chip, unsigned int command,
int column, int page_addr) { int column, int page_addr) {
struct nand_chip *chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(chip);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_ctrl *ctrl = priv->ctrl;
struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs; struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
...@@ -508,7 +509,7 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, ...@@ -508,7 +509,7 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
} }
} }
static void fsl_ifc_select_chip(struct mtd_info *mtd, int chip) static void fsl_ifc_select_chip(struct nand_chip *chip, int cs)
{ {
/* The hardware does not seem to support multiple /* The hardware does not seem to support multiple
* chips per bank. * chips per bank.
...@@ -518,9 +519,9 @@ static void fsl_ifc_select_chip(struct mtd_info *mtd, int chip) ...@@ -518,9 +519,9 @@ static void fsl_ifc_select_chip(struct mtd_info *mtd, int chip)
/* /*
* Write buf to the IFC NAND Controller Data Buffer * Write buf to the IFC NAND Controller Data Buffer
*/ */
static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) static void fsl_ifc_write_buf(struct nand_chip *chip, const u8 *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(chip);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
unsigned int bufsize = mtd->writesize + mtd->oobsize; unsigned int bufsize = mtd->writesize + mtd->oobsize;
...@@ -544,9 +545,8 @@ static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) ...@@ -544,9 +545,8 @@ static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
* Read a byte from either the IFC hardware buffer * Read a byte from either the IFC hardware buffer
* read function for 8-bit buswidth * read function for 8-bit buswidth
*/ */
static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd) static uint8_t fsl_ifc_read_byte(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
unsigned int offset; unsigned int offset;
...@@ -567,9 +567,8 @@ static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd) ...@@ -567,9 +567,8 @@ static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd)
* Read two bytes from the IFC hardware buffer * Read two bytes from the IFC hardware buffer
* read function for 16-bit buswith * read function for 16-bit buswith
*/ */
static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd) static uint8_t fsl_ifc_read_byte16(struct nand_chip *chip)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
uint16_t data; uint16_t data;
...@@ -590,9 +589,8 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd) ...@@ -590,9 +589,8 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
/* /*
* Read from the IFC Controller Data Buffer * Read from the IFC Controller Data Buffer
*/ */
static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len) static void fsl_ifc_read_buf(struct nand_chip *chip, u8 *buf, int len)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
int avail; int avail;
...@@ -616,8 +614,9 @@ static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len) ...@@ -616,8 +614,9 @@ static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
* This function is called after Program and Erase Operations to * This function is called after Program and Erase Operations to
* check for success or failure. * check for success or failure.
*/ */
static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip) static int fsl_ifc_wait(struct nand_chip *chip)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_ctrl *ctrl = priv->ctrl;
struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs; struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
...@@ -678,20 +677,21 @@ static int check_erased_page(struct nand_chip *chip, u8 *buf) ...@@ -678,20 +677,21 @@ static int check_erased_page(struct nand_chip *chip, u8 *buf)
return bitflips; return bitflips;
} }
static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip, static int fsl_ifc_read_page(struct nand_chip *chip, uint8_t *buf,
uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_ctrl *ctrl = priv->ctrl;
struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl; struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
nand_read_page_op(chip, page, 0, buf, mtd->writesize); nand_read_page_op(chip, page, 0, buf, mtd->writesize);
if (oob_required) if (oob_required)
fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_ifc_read_buf(chip, chip->oob_poi, mtd->oobsize);
if (ctrl->nand_stat & IFC_NAND_EVTER_STAT_ECCER) { if (ctrl->nand_stat & IFC_NAND_EVTER_STAT_ECCER) {
if (!oob_required) if (!oob_required)
fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_ifc_read_buf(chip, chip->oob_poi, mtd->oobsize);
return check_erased_page(chip, buf); return check_erased_page(chip, buf);
} }
...@@ -705,11 +705,13 @@ static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -705,11 +705,13 @@ static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
/* ECC will be calculated automatically, and errors will be detected in /* ECC will be calculated automatically, and errors will be detected in
* waitfunc. * waitfunc.
*/ */
static int fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip, static int fsl_ifc_write_page(struct nand_chip *chip, const uint8_t *buf,
const uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize); nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize);
fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_ifc_write_buf(chip, chip->oob_poi, mtd->oobsize);
return nand_prog_page_end_op(chip); return nand_prog_page_end_op(chip);
} }
...@@ -725,8 +727,8 @@ static int fsl_ifc_attach_chip(struct nand_chip *chip) ...@@ -725,8 +727,8 @@ static int fsl_ifc_attach_chip(struct nand_chip *chip)
chip->chipsize); chip->chipsize);
dev_dbg(priv->dev, "%s: nand->pagemask = %8x\n", __func__, dev_dbg(priv->dev, "%s: nand->pagemask = %8x\n", __func__,
chip->pagemask); chip->pagemask);
dev_dbg(priv->dev, "%s: nand->chip_delay = %d\n", __func__, dev_dbg(priv->dev, "%s: nand->legacy.chip_delay = %d\n", __func__,
chip->chip_delay); chip->legacy.chip_delay);
dev_dbg(priv->dev, "%s: nand->badblockpos = %d\n", __func__, dev_dbg(priv->dev, "%s: nand->badblockpos = %d\n", __func__,
chip->badblockpos); chip->badblockpos);
dev_dbg(priv->dev, "%s: nand->chip_shift = %d\n", __func__, dev_dbg(priv->dev, "%s: nand->chip_shift = %d\n", __func__,
...@@ -761,7 +763,7 @@ static const struct nand_controller_ops fsl_ifc_controller_ops = { ...@@ -761,7 +763,7 @@ static const struct nand_controller_ops fsl_ifc_controller_ops = {
.attach_chip = fsl_ifc_attach_chip, .attach_chip = fsl_ifc_attach_chip,
}; };
static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) static int fsl_ifc_sram_init(struct fsl_ifc_mtd *priv)
{ {
struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_ctrl *ctrl = priv->ctrl;
struct fsl_ifc_runtime __iomem *ifc_runtime = ctrl->rregs; struct fsl_ifc_runtime __iomem *ifc_runtime = ctrl->rregs;
...@@ -769,6 +771,27 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) ...@@ -769,6 +771,27 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv)
uint32_t csor = 0, csor_8k = 0, csor_ext = 0; uint32_t csor = 0, csor_8k = 0, csor_ext = 0;
uint32_t cs = priv->bank; uint32_t cs = priv->bank;
if (ctrl->version < FSL_IFC_VERSION_1_1_0)
return 0;
if (ctrl->version > FSL_IFC_VERSION_1_1_0) {
u32 ncfgr, status;
int ret;
/* Trigger auto initialization */
ncfgr = ifc_in32(&ifc_runtime->ifc_nand.ncfgr);
ifc_out32(ncfgr | IFC_NAND_NCFGR_SRAM_INIT_EN, &ifc_runtime->ifc_nand.ncfgr);
/* Wait until done */
ret = readx_poll_timeout(ifc_in32, &ifc_runtime->ifc_nand.ncfgr,
status, !(status & IFC_NAND_NCFGR_SRAM_INIT_EN),
10, IFC_TIMEOUT_MSECS * 1000);
if (ret)
dev_err(priv->dev, "Failed to initialize SRAM!\n");
return ret;
}
/* Save CSOR and CSOR_ext */ /* Save CSOR and CSOR_ext */
csor = ifc_in32(&ifc_global->csor_cs[cs].csor); csor = ifc_in32(&ifc_global->csor_cs[cs].csor);
csor_ext = ifc_in32(&ifc_global->csor_cs[cs].csor_ext); csor_ext = ifc_in32(&ifc_global->csor_cs[cs].csor_ext);
...@@ -805,12 +828,16 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) ...@@ -805,12 +828,16 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv)
wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat,
msecs_to_jiffies(IFC_TIMEOUT_MSECS)); msecs_to_jiffies(IFC_TIMEOUT_MSECS));
if (ctrl->nand_stat != IFC_NAND_EVTER_STAT_OPC) if (ctrl->nand_stat != IFC_NAND_EVTER_STAT_OPC) {
pr_err("fsl-ifc: Failed to Initialise SRAM\n"); pr_err("fsl-ifc: Failed to Initialise SRAM\n");
return -ETIMEDOUT;
}
/* Restore CSOR and CSOR_ext */ /* Restore CSOR and CSOR_ext */
ifc_out32(csor, &ifc_global->csor_cs[cs].csor); ifc_out32(csor, &ifc_global->csor_cs[cs].csor);
ifc_out32(csor_ext, &ifc_global->csor_cs[cs].csor_ext); ifc_out32(csor_ext, &ifc_global->csor_cs[cs].csor_ext);
return 0;
} }
static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
...@@ -821,6 +848,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) ...@@ -821,6 +848,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
struct nand_chip *chip = &priv->chip; struct nand_chip *chip = &priv->chip;
struct mtd_info *mtd = nand_to_mtd(&priv->chip); struct mtd_info *mtd = nand_to_mtd(&priv->chip);
u32 csor; u32 csor;
int ret;
/* Fill in fsl_ifc_mtd structure */ /* Fill in fsl_ifc_mtd structure */
mtd->dev.parent = priv->dev; mtd->dev.parent = priv->dev;
...@@ -830,17 +858,17 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) ...@@ -830,17 +858,17 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
/* set up function call table */ /* set up function call table */
if ((ifc_in32(&ifc_global->cspr_cs[priv->bank].cspr)) if ((ifc_in32(&ifc_global->cspr_cs[priv->bank].cspr))
& CSPR_PORT_SIZE_16) & CSPR_PORT_SIZE_16)
chip->read_byte = fsl_ifc_read_byte16; chip->legacy.read_byte = fsl_ifc_read_byte16;
else else
chip->read_byte = fsl_ifc_read_byte; chip->legacy.read_byte = fsl_ifc_read_byte;
chip->write_buf = fsl_ifc_write_buf; chip->legacy.write_buf = fsl_ifc_write_buf;
chip->read_buf = fsl_ifc_read_buf; chip->legacy.read_buf = fsl_ifc_read_buf;
chip->select_chip = fsl_ifc_select_chip; chip->select_chip = fsl_ifc_select_chip;
chip->cmdfunc = fsl_ifc_cmdfunc; chip->legacy.cmdfunc = fsl_ifc_cmdfunc;
chip->waitfunc = fsl_ifc_wait; chip->legacy.waitfunc = fsl_ifc_wait;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
chip->bbt_td = &bbt_main_descr; chip->bbt_td = &bbt_main_descr;
chip->bbt_md = &bbt_mirror_descr; chip->bbt_md = &bbt_mirror_descr;
...@@ -853,10 +881,10 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) ...@@ -853,10 +881,10 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
if (ifc_in32(&ifc_global->cspr_cs[priv->bank].cspr) if (ifc_in32(&ifc_global->cspr_cs[priv->bank].cspr)
& CSPR_PORT_SIZE_16) { & CSPR_PORT_SIZE_16) {
chip->read_byte = fsl_ifc_read_byte16; chip->legacy.read_byte = fsl_ifc_read_byte16;
chip->options |= NAND_BUSWIDTH_16; chip->options |= NAND_BUSWIDTH_16;
} else { } else {
chip->read_byte = fsl_ifc_read_byte; chip->legacy.read_byte = fsl_ifc_read_byte;
} }
chip->controller = &ifc_nand_ctrl->controller; chip->controller = &ifc_nand_ctrl->controller;
...@@ -914,8 +942,9 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) ...@@ -914,8 +942,9 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
chip->ecc.algo = NAND_ECC_HAMMING; chip->ecc.algo = NAND_ECC_HAMMING;
} }
if (ctrl->version >= FSL_IFC_VERSION_1_1_0) ret = fsl_ifc_sram_init(priv);
fsl_ifc_sram_init(priv); if (ret)
return ret;
/* /*
* As IFC version 2.0.0 has 16KB of internal SRAM as compared to older * As IFC version 2.0.0 has 16KB of internal SRAM as compared to older
...@@ -1051,7 +1080,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) ...@@ -1051,7 +1080,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
goto err; goto err;
priv->chip.controller->ops = &fsl_ifc_controller_ops; priv->chip.controller->ops = &fsl_ifc_controller_ops;
ret = nand_scan(mtd, 1); ret = nand_scan(&priv->chip, 1);
if (ret) if (ret)
goto err; goto err;
...@@ -1077,9 +1106,8 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) ...@@ -1077,9 +1106,8 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
static int fsl_ifc_nand_remove(struct platform_device *dev) static int fsl_ifc_nand_remove(struct platform_device *dev)
{ {
struct fsl_ifc_mtd *priv = dev_get_drvdata(&dev->dev); struct fsl_ifc_mtd *priv = dev_get_drvdata(&dev->dev);
struct mtd_info *mtd = nand_to_mtd(&priv->chip);
nand_release(mtd); nand_release(&priv->chip);
fsl_ifc_chip_remove(priv); fsl_ifc_chip_remove(priv);
mutex_lock(&fsl_ifc_nand_mutex); mutex_lock(&fsl_ifc_nand_mutex);
......
...@@ -52,9 +52,9 @@ static inline struct fsl_upm_nand *to_fsl_upm_nand(struct mtd_info *mtdinfo) ...@@ -52,9 +52,9 @@ static inline struct fsl_upm_nand *to_fsl_upm_nand(struct mtd_info *mtdinfo)
chip); chip);
} }
static int fun_chip_ready(struct mtd_info *mtd) static int fun_chip_ready(struct nand_chip *chip)
{ {
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
if (gpio_get_value(fun->rnb_gpio[fun->mchip_number])) if (gpio_get_value(fun->rnb_gpio[fun->mchip_number]))
return 1; return 1;
...@@ -69,7 +69,7 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun) ...@@ -69,7 +69,7 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun)
struct mtd_info *mtd = nand_to_mtd(&fun->chip); struct mtd_info *mtd = nand_to_mtd(&fun->chip);
int cnt = 1000000; int cnt = 1000000;
while (--cnt && !fun_chip_ready(mtd)) while (--cnt && !fun_chip_ready(&fun->chip))
cpu_relax(); cpu_relax();
if (!cnt) if (!cnt)
dev_err(fun->dev, "tired waiting for RNB\n"); dev_err(fun->dev, "tired waiting for RNB\n");
...@@ -78,10 +78,9 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun) ...@@ -78,10 +78,9 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun)
} }
} }
static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) static void fun_cmd_ctrl(struct nand_chip *chip, int cmd, unsigned int ctrl)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
u32 mar; u32 mar;
if (!(ctrl & fun->last_ctrl)) { if (!(ctrl & fun->last_ctrl)) {
...@@ -102,51 +101,50 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) ...@@ -102,51 +101,50 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
mar = (cmd << (32 - fun->upm.width)) | mar = (cmd << (32 - fun->upm.width)) |
fun->mchip_offsets[fun->mchip_number]; fun->mchip_offsets[fun->mchip_number];
fsl_upm_run_pattern(&fun->upm, chip->IO_ADDR_R, mar); fsl_upm_run_pattern(&fun->upm, chip->legacy.IO_ADDR_R, mar);
if (fun->wait_flags & FSL_UPM_WAIT_RUN_PATTERN) if (fun->wait_flags & FSL_UPM_WAIT_RUN_PATTERN)
fun_wait_rnb(fun); fun_wait_rnb(fun);
} }
static void fun_select_chip(struct mtd_info *mtd, int mchip_nr) static void fun_select_chip(struct nand_chip *chip, int mchip_nr)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
if (mchip_nr == -1) { if (mchip_nr == -1) {
chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE);
} else if (mchip_nr >= 0 && mchip_nr < NAND_MAX_CHIPS) { } else if (mchip_nr >= 0 && mchip_nr < NAND_MAX_CHIPS) {
fun->mchip_number = mchip_nr; fun->mchip_number = mchip_nr;
chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr]; chip->legacy.IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
chip->IO_ADDR_W = chip->IO_ADDR_R; chip->legacy.IO_ADDR_W = chip->legacy.IO_ADDR_R;
} else { } else {
BUG(); BUG();
} }
} }
static uint8_t fun_read_byte(struct mtd_info *mtd) static uint8_t fun_read_byte(struct nand_chip *chip)
{ {
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
return in_8(fun->chip.IO_ADDR_R); return in_8(fun->chip.legacy.IO_ADDR_R);
} }
static void fun_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static void fun_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
{ {
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
int i; int i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
buf[i] = in_8(fun->chip.IO_ADDR_R); buf[i] = in_8(fun->chip.legacy.IO_ADDR_R);
} }
static void fun_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) static void fun_write_buf(struct nand_chip *chip, const uint8_t *buf, int len)
{ {
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
int i; int i;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
out_8(fun->chip.IO_ADDR_W, buf[i]); out_8(fun->chip.legacy.IO_ADDR_W, buf[i]);
if (fun->wait_flags & FSL_UPM_WAIT_WRITE_BYTE) if (fun->wait_flags & FSL_UPM_WAIT_WRITE_BYTE)
fun_wait_rnb(fun); fun_wait_rnb(fun);
} }
...@@ -162,20 +160,20 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -162,20 +160,20 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
int ret; int ret;
struct device_node *flash_np; struct device_node *flash_np;
fun->chip.IO_ADDR_R = fun->io_base; fun->chip.legacy.IO_ADDR_R = fun->io_base;
fun->chip.IO_ADDR_W = fun->io_base; fun->chip.legacy.IO_ADDR_W = fun->io_base;
fun->chip.cmd_ctrl = fun_cmd_ctrl; fun->chip.legacy.cmd_ctrl = fun_cmd_ctrl;
fun->chip.chip_delay = fun->chip_delay; fun->chip.legacy.chip_delay = fun->chip_delay;
fun->chip.read_byte = fun_read_byte; fun->chip.legacy.read_byte = fun_read_byte;
fun->chip.read_buf = fun_read_buf; fun->chip.legacy.read_buf = fun_read_buf;
fun->chip.write_buf = fun_write_buf; fun->chip.legacy.write_buf = fun_write_buf;
fun->chip.ecc.mode = NAND_ECC_SOFT; fun->chip.ecc.mode = NAND_ECC_SOFT;
fun->chip.ecc.algo = NAND_ECC_HAMMING; fun->chip.ecc.algo = NAND_ECC_HAMMING;
if (fun->mchip_count > 1) if (fun->mchip_count > 1)
fun->chip.select_chip = fun_select_chip; fun->chip.select_chip = fun_select_chip;
if (fun->rnb_gpio[0] >= 0) if (fun->rnb_gpio[0] >= 0)
fun->chip.dev_ready = fun_chip_ready; fun->chip.legacy.dev_ready = fun_chip_ready;
mtd->dev.parent = fun->dev; mtd->dev.parent = fun->dev;
...@@ -184,14 +182,14 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -184,14 +182,14 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
return -ENODEV; return -ENODEV;
nand_set_flash_node(&fun->chip, flash_np); nand_set_flash_node(&fun->chip, flash_np);
mtd->name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, mtd->name = kasprintf(GFP_KERNEL, "0x%llx.%pOFn", (u64)io_res->start,
flash_np->name); flash_np);
if (!mtd->name) { if (!mtd->name) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
ret = nand_scan(mtd, fun->mchip_count); ret = nand_scan(&fun->chip, fun->mchip_count);
if (ret) if (ret)
goto err; goto err;
...@@ -326,7 +324,7 @@ static int fun_remove(struct platform_device *ofdev) ...@@ -326,7 +324,7 @@ static int fun_remove(struct platform_device *ofdev)
struct mtd_info *mtd = nand_to_mtd(&fun->chip); struct mtd_info *mtd = nand_to_mtd(&fun->chip);
int i; int i;
nand_release(mtd); nand_release(&fun->chip);
kfree(mtd->name); kfree(mtd->name);
for (i = 0; i < fun->mchip_count; i++) { for (i = 0; i < fun->mchip_count; i++) {
......
...@@ -340,10 +340,9 @@ static int fsmc_calc_timings(struct fsmc_nand_data *host, ...@@ -340,10 +340,9 @@ static int fsmc_calc_timings(struct fsmc_nand_data *host,
return 0; return 0;
} }
static int fsmc_setup_data_interface(struct mtd_info *mtd, int csline, static int fsmc_setup_data_interface(struct nand_chip *nand, int csline,
const struct nand_data_interface *conf) const struct nand_data_interface *conf)
{ {
struct nand_chip *nand = mtd_to_nand(mtd);
struct fsmc_nand_data *host = nand_get_controller_data(nand); struct fsmc_nand_data *host = nand_get_controller_data(nand);
struct fsmc_nand_timings tims; struct fsmc_nand_timings tims;
const struct nand_sdr_timings *sdrt; const struct nand_sdr_timings *sdrt;
...@@ -368,9 +367,9 @@ static int fsmc_setup_data_interface(struct mtd_info *mtd, int csline, ...@@ -368,9 +367,9 @@ static int fsmc_setup_data_interface(struct mtd_info *mtd, int csline,
/* /*
* fsmc_enable_hwecc - Enables Hardware ECC through FSMC registers * fsmc_enable_hwecc - Enables Hardware ECC through FSMC registers
*/ */
static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode) static void fsmc_enable_hwecc(struct nand_chip *chip, int mode)
{ {
struct fsmc_nand_data *host = mtd_to_fsmc(mtd); struct fsmc_nand_data *host = mtd_to_fsmc(nand_to_mtd(chip));
writel_relaxed(readl(host->regs_va + FSMC_PC) & ~FSMC_ECCPLEN_256, writel_relaxed(readl(host->regs_va + FSMC_PC) & ~FSMC_ECCPLEN_256,
host->regs_va + FSMC_PC); host->regs_va + FSMC_PC);
...@@ -385,10 +384,10 @@ static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode) ...@@ -385,10 +384,10 @@ static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode)
* FSMC. ECC is 13 bytes for 512 bytes of data (supports error correction up to * FSMC. ECC is 13 bytes for 512 bytes of data (supports error correction up to
* max of 8-bits) * max of 8-bits)
*/ */
static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data, static int fsmc_read_hwecc_ecc4(struct nand_chip *chip, const uint8_t *data,
uint8_t *ecc) uint8_t *ecc)
{ {
struct fsmc_nand_data *host = mtd_to_fsmc(mtd); struct fsmc_nand_data *host = mtd_to_fsmc(nand_to_mtd(chip));
uint32_t ecc_tmp; uint32_t ecc_tmp;
unsigned long deadline = jiffies + FSMC_BUSY_WAIT_TIMEOUT; unsigned long deadline = jiffies + FSMC_BUSY_WAIT_TIMEOUT;
...@@ -433,10 +432,10 @@ static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data, ...@@ -433,10 +432,10 @@ static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data,
* FSMC. ECC is 3 bytes for 512 bytes of data (supports error correction up to * FSMC. ECC is 3 bytes for 512 bytes of data (supports error correction up to
* max of 1-bit) * max of 1-bit)
*/ */
static int fsmc_read_hwecc_ecc1(struct mtd_info *mtd, const uint8_t *data, static int fsmc_read_hwecc_ecc1(struct nand_chip *chip, const uint8_t *data,
uint8_t *ecc) uint8_t *ecc)
{ {
struct fsmc_nand_data *host = mtd_to_fsmc(mtd); struct fsmc_nand_data *host = mtd_to_fsmc(nand_to_mtd(chip));
uint32_t ecc_tmp; uint32_t ecc_tmp;
ecc_tmp = readl_relaxed(host->regs_va + ECC1); ecc_tmp = readl_relaxed(host->regs_va + ECC1);
...@@ -610,9 +609,9 @@ static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf, ...@@ -610,9 +609,9 @@ static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf,
} }
/* fsmc_select_chip - assert or deassert nCE */ /* fsmc_select_chip - assert or deassert nCE */
static void fsmc_select_chip(struct mtd_info *mtd, int chipnr) static void fsmc_select_chip(struct nand_chip *chip, int chipnr)
{ {
struct fsmc_nand_data *host = mtd_to_fsmc(mtd); struct fsmc_nand_data *host = mtd_to_fsmc(nand_to_mtd(chip));
u32 pc; u32 pc;
/* Support only one CS */ /* Support only one CS */
...@@ -707,7 +706,6 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op, ...@@ -707,7 +706,6 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,
/* /*
* fsmc_read_page_hwecc * fsmc_read_page_hwecc
* @mtd: mtd info structure
* @chip: nand chip info structure * @chip: nand chip info structure
* @buf: buffer to store read data * @buf: buffer to store read data
* @oob_required: caller expects OOB data read to chip->oob_poi * @oob_required: caller expects OOB data read to chip->oob_poi
...@@ -719,9 +717,10 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op, ...@@ -719,9 +717,10 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,
* After this read, fsmc hardware generates and reports error data bits(up to a * After this read, fsmc hardware generates and reports error data bits(up to a
* max of 8 bits) * max of 8 bits)
*/ */
static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, static int fsmc_read_page_hwecc(struct nand_chip *chip, uint8_t *buf,
uint8_t *buf, int oob_required, int page) int oob_required, int page)
{ {
struct mtd_info *mtd = nand_to_mtd(chip);
int i, j, s, stat, eccsize = chip->ecc.size; int i, j, s, stat, eccsize = chip->ecc.size;
int eccbytes = chip->ecc.bytes; int eccbytes = chip->ecc.bytes;
int eccsteps = chip->ecc.steps; int eccsteps = chip->ecc.steps;
...@@ -740,7 +739,7 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -740,7 +739,7 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
for (i = 0, s = 0; s < eccsteps; s++, i += eccbytes, p += eccsize) { for (i = 0, s = 0; s < eccsteps; s++, i += eccbytes, p += eccsize) {
nand_read_page_op(chip, page, s * eccsize, NULL, 0); nand_read_page_op(chip, page, s * eccsize, NULL, 0);
chip->ecc.hwctl(mtd, NAND_ECC_READ); chip->ecc.hwctl(chip, NAND_ECC_READ);
nand_read_data_op(chip, p, eccsize, false); nand_read_data_op(chip, p, eccsize, false);
for (j = 0; j < eccbytes;) { for (j = 0; j < eccbytes;) {
...@@ -767,9 +766,9 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -767,9 +766,9 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
} }
memcpy(&ecc_code[i], oob, chip->ecc.bytes); memcpy(&ecc_code[i], oob, chip->ecc.bytes);
chip->ecc.calculate(mtd, p, &ecc_calc[i]); chip->ecc.calculate(chip, p, &ecc_calc[i]);
stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); stat = chip->ecc.correct(chip, p, &ecc_code[i], &ecc_calc[i]);
if (stat < 0) { if (stat < 0) {
mtd->ecc_stats.failed++; mtd->ecc_stats.failed++;
} else { } else {
...@@ -791,11 +790,10 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -791,11 +790,10 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
* calc_ecc is a 104 bit information containing maximum of 8 error * calc_ecc is a 104 bit information containing maximum of 8 error
* offset informations of 13 bits each in 512 bytes of read data. * offset informations of 13 bits each in 512 bytes of read data.
*/ */
static int fsmc_bch8_correct_data(struct mtd_info *mtd, uint8_t *dat, static int fsmc_bch8_correct_data(struct nand_chip *chip, uint8_t *dat,
uint8_t *read_ecc, uint8_t *calc_ecc) uint8_t *read_ecc, uint8_t *calc_ecc)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct fsmc_nand_data *host = mtd_to_fsmc(nand_to_mtd(chip));
struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
uint32_t err_idx[8]; uint32_t err_idx[8];
uint32_t num_err, i; uint32_t num_err, i;
uint32_t ecc1, ecc2, ecc3, ecc4; uint32_t ecc1, ecc2, ecc3, ecc4;
...@@ -951,6 +949,7 @@ static int fsmc_nand_attach_chip(struct nand_chip *nand) ...@@ -951,6 +949,7 @@ static int fsmc_nand_attach_chip(struct nand_chip *nand)
nand->ecc.correct = nand_correct_data; nand->ecc.correct = nand_correct_data;
nand->ecc.bytes = 3; nand->ecc.bytes = 3;
nand->ecc.strength = 1; nand->ecc.strength = 1;
nand->ecc.options |= NAND_ECC_SOFT_HAMMING_SM_ORDER;
break; break;
case NAND_ECC_SOFT: case NAND_ECC_SOFT:
...@@ -1082,7 +1081,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) ...@@ -1082,7 +1081,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
nand->exec_op = fsmc_exec_op; nand->exec_op = fsmc_exec_op;
nand->select_chip = fsmc_select_chip; nand->select_chip = fsmc_select_chip;
nand->chip_delay = 30;
/* /*
* Setup default ECC mode. nand_dt_init() called from nand_scan_ident() * Setup default ECC mode. nand_dt_init() called from nand_scan_ident()
...@@ -1125,7 +1123,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) ...@@ -1125,7 +1123,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
* Scan to find existence of the device * Scan to find existence of the device
*/ */
nand->dummy_controller.ops = &fsmc_nand_controller_ops; nand->dummy_controller.ops = &fsmc_nand_controller_ops;
ret = nand_scan(mtd, 1); ret = nand_scan(nand, 1);
if (ret) if (ret)
goto release_dma_write_chan; goto release_dma_write_chan;
...@@ -1161,7 +1159,7 @@ static int fsmc_nand_remove(struct platform_device *pdev) ...@@ -1161,7 +1159,7 @@ static int fsmc_nand_remove(struct platform_device *pdev)
struct fsmc_nand_data *host = platform_get_drvdata(pdev); struct fsmc_nand_data *host = platform_get_drvdata(pdev);
if (host) { if (host) {
nand_release(nand_to_mtd(&host->nand)); nand_release(&host->nand);
if (host->mode == USE_DMA_ACCESS) { if (host->mode == USE_DMA_ACCESS) {
dma_release_channel(host->write_dma_chan); dma_release_channel(host->write_dma_chan);
......
...@@ -73,9 +73,10 @@ static void gpio_nand_dosync(struct gpiomtd *gpiomtd) ...@@ -73,9 +73,10 @@ static void gpio_nand_dosync(struct gpiomtd *gpiomtd)
static inline void gpio_nand_dosync(struct gpiomtd *gpiomtd) {} static inline void gpio_nand_dosync(struct gpiomtd *gpiomtd) {}
#endif #endif
static void gpio_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) static void gpio_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
unsigned int ctrl)
{ {
struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd); struct gpiomtd *gpiomtd = gpio_nand_getpriv(nand_to_mtd(chip));
gpio_nand_dosync(gpiomtd); gpio_nand_dosync(gpiomtd);
...@@ -89,13 +90,13 @@ static void gpio_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) ...@@ -89,13 +90,13 @@ static void gpio_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
if (cmd == NAND_CMD_NONE) if (cmd == NAND_CMD_NONE)
return; return;
writeb(cmd, gpiomtd->nand_chip.IO_ADDR_W); writeb(cmd, gpiomtd->nand_chip.legacy.IO_ADDR_W);
gpio_nand_dosync(gpiomtd); gpio_nand_dosync(gpiomtd);
} }
static int gpio_nand_devready(struct mtd_info *mtd) static int gpio_nand_devready(struct nand_chip *chip)
{ {
struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd); struct gpiomtd *gpiomtd = gpio_nand_getpriv(nand_to_mtd(chip));
return gpiod_get_value(gpiomtd->rdy); return gpiod_get_value(gpiomtd->rdy);
} }
...@@ -194,7 +195,7 @@ static int gpio_nand_remove(struct platform_device *pdev) ...@@ -194,7 +195,7 @@ static int gpio_nand_remove(struct platform_device *pdev)
{ {
struct gpiomtd *gpiomtd = platform_get_drvdata(pdev); struct gpiomtd *gpiomtd = platform_get_drvdata(pdev);
nand_release(nand_to_mtd(&gpiomtd->nand_chip)); nand_release(&gpiomtd->nand_chip);
/* Enable write protection and disable the chip */ /* Enable write protection and disable the chip */
if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
...@@ -224,9 +225,9 @@ static int gpio_nand_probe(struct platform_device *pdev) ...@@ -224,9 +225,9 @@ static int gpio_nand_probe(struct platform_device *pdev)
chip = &gpiomtd->nand_chip; chip = &gpiomtd->nand_chip;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
chip->IO_ADDR_R = devm_ioremap_resource(dev, res); chip->legacy.IO_ADDR_R = devm_ioremap_resource(dev, res);
if (IS_ERR(chip->IO_ADDR_R)) if (IS_ERR(chip->legacy.IO_ADDR_R))
return PTR_ERR(chip->IO_ADDR_R); return PTR_ERR(chip->legacy.IO_ADDR_R);
res = gpio_nand_get_io_sync(pdev); res = gpio_nand_get_io_sync(pdev);
if (res) { if (res) {
...@@ -270,15 +271,15 @@ static int gpio_nand_probe(struct platform_device *pdev) ...@@ -270,15 +271,15 @@ static int gpio_nand_probe(struct platform_device *pdev)
} }
/* Using RDY pin */ /* Using RDY pin */
if (gpiomtd->rdy) if (gpiomtd->rdy)
chip->dev_ready = gpio_nand_devready; chip->legacy.dev_ready = gpio_nand_devready;
nand_set_flash_node(chip, pdev->dev.of_node); nand_set_flash_node(chip, pdev->dev.of_node);
chip->IO_ADDR_W = chip->IO_ADDR_R; chip->legacy.IO_ADDR_W = chip->legacy.IO_ADDR_R;
chip->ecc.mode = NAND_ECC_SOFT; chip->ecc.mode = NAND_ECC_SOFT;
chip->ecc.algo = NAND_ECC_HAMMING; chip->ecc.algo = NAND_ECC_HAMMING;
chip->options = gpiomtd->plat.options; chip->options = gpiomtd->plat.options;
chip->chip_delay = gpiomtd->plat.chip_delay; chip->legacy.chip_delay = gpiomtd->plat.chip_delay;
chip->cmd_ctrl = gpio_nand_cmd_ctrl; chip->legacy.cmd_ctrl = gpio_nand_cmd_ctrl;
mtd = nand_to_mtd(chip); mtd = nand_to_mtd(chip);
mtd->dev.parent = dev; mtd->dev.parent = dev;
...@@ -289,7 +290,7 @@ static int gpio_nand_probe(struct platform_device *pdev) ...@@ -289,7 +290,7 @@ static int gpio_nand_probe(struct platform_device *pdev)
if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
gpiod_direction_output(gpiomtd->nwp, 1); gpiod_direction_output(gpiomtd->nwp, 1);
ret = nand_scan(mtd, 1); ret = nand_scan(chip, 1);
if (ret) if (ret)
goto err_wp; goto err_wp;
......
...@@ -471,10 +471,9 @@ void gpmi_nfc_apply_timings(struct gpmi_nand_data *this) ...@@ -471,10 +471,9 @@ void gpmi_nfc_apply_timings(struct gpmi_nand_data *this)
udelay(dll_wait_time_us); udelay(dll_wait_time_us);
} }
int gpmi_setup_data_interface(struct mtd_info *mtd, int chipnr, int gpmi_setup_data_interface(struct nand_chip *chip, int chipnr,
const struct nand_data_interface *conf) const struct nand_data_interface *conf)
{ {
struct nand_chip *chip = mtd_to_nand(mtd);
struct gpmi_nand_data *this = nand_get_controller_data(chip); struct gpmi_nand_data *this = nand_get_controller_data(chip);
const struct nand_sdr_timings *sdr; const struct nand_sdr_timings *sdr;
......
This diff is collapsed.
...@@ -178,7 +178,7 @@ int gpmi_is_ready(struct gpmi_nand_data *, unsigned chip); ...@@ -178,7 +178,7 @@ int gpmi_is_ready(struct gpmi_nand_data *, unsigned chip);
int gpmi_send_command(struct gpmi_nand_data *); int gpmi_send_command(struct gpmi_nand_data *);
int gpmi_enable_clk(struct gpmi_nand_data *this); int gpmi_enable_clk(struct gpmi_nand_data *this);
int gpmi_disable_clk(struct gpmi_nand_data *this); int gpmi_disable_clk(struct gpmi_nand_data *this);
int gpmi_setup_data_interface(struct mtd_info *mtd, int chipnr, int gpmi_setup_data_interface(struct nand_chip *chip, int chipnr,
const struct nand_data_interface *conf); const struct nand_data_interface *conf);
void gpmi_nfc_apply_timings(struct gpmi_nand_data *this); void gpmi_nfc_apply_timings(struct gpmi_nand_data *this);
int gpmi_read_data(struct gpmi_nand_data *, void *buf, int len); int gpmi_read_data(struct gpmi_nand_data *, void *buf, int len);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/mtd/rawnand.h> #include "internals.h"
static void amd_nand_decode_id(struct nand_chip *chip) static void amd_nand_decode_id(struct nand_chip *chip)
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/mtd/rawnand.h> #include "internals.h"
/* /*
* Macronix AC series does not support using SET/GET_FEATURES to change * Macronix AC series does not support using SET/GET_FEATURES to change
......
This diff is collapsed.
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/mtd/rawnand.h> #include "internals.h"
static void samsung_nand_decode_id(struct nand_chip *chip) static void samsung_nand_decode_id(struct nand_chip *chip)
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment