.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Oxford Semiconductor OXNAS NAND driver |
---|
3 | 4 | |
---|
.. | .. |
---|
6 | 7 | * Author: Vitaly Wool <vitalywool@gmail.com> |
---|
7 | 8 | * Copyright (C) 2013 Ma Haijun <mahaijuns@gmail.com> |
---|
8 | 9 | * Copyright (C) 2012 John Crispin <blogic@openwrt.org> |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License version 2 as |
---|
12 | | - * published by the Free Software Foundation. |
---|
13 | | - * |
---|
14 | 10 | */ |
---|
15 | 11 | |
---|
16 | 12 | #include <linux/err.h> |
---|
.. | .. |
---|
39 | 35 | unsigned int nchips; |
---|
40 | 36 | }; |
---|
41 | 37 | |
---|
42 | | -static uint8_t oxnas_nand_read_byte(struct mtd_info *mtd) |
---|
| 38 | +static uint8_t oxnas_nand_read_byte(struct nand_chip *chip) |
---|
43 | 39 | { |
---|
44 | | - struct nand_chip *chip = mtd_to_nand(mtd); |
---|
45 | 40 | struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); |
---|
46 | 41 | |
---|
47 | 42 | return readb(oxnas->io_base); |
---|
48 | 43 | } |
---|
49 | 44 | |
---|
50 | | -static void oxnas_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len) |
---|
| 45 | +static void oxnas_nand_read_buf(struct nand_chip *chip, u8 *buf, int len) |
---|
51 | 46 | { |
---|
52 | | - struct nand_chip *chip = mtd_to_nand(mtd); |
---|
53 | 47 | struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); |
---|
54 | 48 | |
---|
55 | 49 | ioread8_rep(oxnas->io_base, buf, len); |
---|
56 | 50 | } |
---|
57 | 51 | |
---|
58 | | -static void oxnas_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len) |
---|
| 52 | +static void oxnas_nand_write_buf(struct nand_chip *chip, const u8 *buf, |
---|
| 53 | + int len) |
---|
59 | 54 | { |
---|
60 | | - struct nand_chip *chip = mtd_to_nand(mtd); |
---|
61 | 55 | struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); |
---|
62 | 56 | |
---|
63 | 57 | iowrite8_rep(oxnas->io_base, buf, len); |
---|
64 | 58 | } |
---|
65 | 59 | |
---|
66 | 60 | /* Single CS command control */ |
---|
67 | | -static void oxnas_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, |
---|
| 61 | +static void oxnas_nand_cmd_ctrl(struct nand_chip *chip, int cmd, |
---|
68 | 62 | unsigned int ctrl) |
---|
69 | 63 | { |
---|
70 | | - struct nand_chip *chip = mtd_to_nand(mtd); |
---|
71 | 64 | struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); |
---|
72 | 65 | |
---|
73 | 66 | if (ctrl & NAND_CLE) |
---|
.. | .. |
---|
136 | 129 | mtd->dev.parent = &pdev->dev; |
---|
137 | 130 | mtd->priv = chip; |
---|
138 | 131 | |
---|
139 | | - chip->cmd_ctrl = oxnas_nand_cmd_ctrl; |
---|
140 | | - chip->read_buf = oxnas_nand_read_buf; |
---|
141 | | - chip->read_byte = oxnas_nand_read_byte; |
---|
142 | | - chip->write_buf = oxnas_nand_write_buf; |
---|
143 | | - chip->chip_delay = 30; |
---|
| 132 | + chip->legacy.cmd_ctrl = oxnas_nand_cmd_ctrl; |
---|
| 133 | + chip->legacy.read_buf = oxnas_nand_read_buf; |
---|
| 134 | + chip->legacy.read_byte = oxnas_nand_read_byte; |
---|
| 135 | + chip->legacy.write_buf = oxnas_nand_write_buf; |
---|
| 136 | + chip->legacy.chip_delay = 30; |
---|
144 | 137 | |
---|
145 | 138 | /* Scan to find existence of the device */ |
---|
146 | 139 | err = nand_scan(chip, 1); |
---|
.. | .. |
---|
151 | 144 | if (err) |
---|
152 | 145 | goto err_cleanup_nand; |
---|
153 | 146 | |
---|
154 | | - oxnas->chips[oxnas->nchips] = chip; |
---|
155 | | - ++oxnas->nchips; |
---|
| 147 | + oxnas->chips[oxnas->nchips++] = chip; |
---|
156 | 148 | } |
---|
157 | 149 | |
---|
158 | 150 | /* Exit if no chips found */ |
---|
.. | .. |
---|
189 | 181 | |
---|
190 | 182 | for (i = 0; i < oxnas->nchips; i++) { |
---|
191 | 183 | chip = oxnas->chips[i]; |
---|
192 | | - nand_release(chip); |
---|
| 184 | + WARN_ON(mtd_device_unregister(nand_to_mtd(chip))); |
---|
| 185 | + nand_cleanup(chip); |
---|
193 | 186 | } |
---|
194 | 187 | |
---|
195 | 188 | clk_disable_unprepare(oxnas->clk); |
---|