Commit 47bd59e5 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal
Browse files

mtd: rawnand: plat_nand: Pass a nand_chip object to all platform_nand_ctrl hooks



Let's make the raw NAND API consistent by patching all helpers and
hooks to take a nand_chip object instead of an mtd_info one or
remove the mtd_info object when both are passed.

In order to do that, we first need to update the platform_nand_ctrl
hooks to take a nand_chip object instead of an mtd_info.

We add temporary plat_nand_xxx() wrappers to the do the mtd -> chip
conversion, but those will be dropped when patching nand_chip hooks to
take a nand_chip object.

Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: default avatarAlexander Sverdlin <alexander.sverdlin@gmail.com>
Acked-by: default avatarAlexander Sverdlin <alexander.sverdlin@gmail.com>
Acked-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Acked-by: default avatarKrzysztof Halasa <khalasa@piap.pl>
Acked-by: default avatarPaul Burton <paul.burton@mips.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 2f91eb69
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -45,10 +45,9 @@

#define NAND_CTRL_ADDR(chip) 	(chip->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)
{
	struct nand_chip *chip = mtd_to_nand(mtd);
	static u16 nand_state = SNAPPERCL15_NAND_WPN;
	u16 set;

@@ -73,10 +72,8 @@ static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
		__raw_writew((cmd & 0xff) | nand_state, chip->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);
}

+2 −5
Original line number Diff line number Diff line
@@ -76,11 +76,9 @@ static void __init ts72xx_map_io(void)
#define TS72XX_NAND_CONTROL_ADDR_LINE	22	/* 0xN0400000 */
#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)
{
	struct nand_chip *chip = mtd_to_nand(mtd);

	if (ctrl & NAND_CTRL_CHANGE) {
		void __iomem *addr = chip->IO_ADDR_R;
		unsigned char bits;
@@ -99,9 +97,8 @@ static void ts72xx_nand_hwcontrol(struct mtd_info *mtd,
		__raw_writeb(cmd, chip->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->IO_ADDR_R;

	addr += (1 << TS72XX_NAND_BUSY_ADDR_LINE);
+5 −6
Original line number Diff line number Diff line
@@ -129,10 +129,9 @@ static void qong_init_nor_mtd(void)
/*
 * 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)
		return;

@@ -145,14 +144,14 @@ static void qong_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
/*
 * 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));
}

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);
	else
		gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_NFCE_B), 1);
+1 −2
Original line number Diff line number Diff line
@@ -75,9 +75,8 @@ static struct mtd_partition ixdp425_partitions[] = {
};

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);

	if (ctrl & NAND_CTRL_CHANGE) {
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ static struct platform_device nor_device = {

#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);
}
Loading