blob: 2501cfe00f43902ced6f4a7e354bf882ca2491ab [file] [log] [blame]
Boris Brezillon48573932018-11-11 08:55:09 +01001// SPDX-License-Identifier: GPL-2.0
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +01002/*
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +01003 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
4 *
Boris Brezillon187c54482018-02-05 23:02:02 +01005 * Derived from drivers/mtd/nand/toto.c (removed in v2.6.28)
Boris Brezillon7b6afee2018-02-05 23:02:03 +01006 * Copyright (c) 2003 Texas Instruments
7 * Copyright (c) 2002 Thomas Gleixner <tgxl@linutronix.de>
8 *
Janusz Krzysztofik7e95d1f12010-12-14 21:09:40 +01009 * Converted to platform driver by Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Boris Brezillon93cbd6f32018-02-05 23:02:00 +010010 * Partially stolen from plat_nand.c
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010011 *
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010012 * Overview:
13 * This is a device driver for the NAND flash device found on the
14 * Amstrad E3 (Delta).
15 */
16
17#include <linux/slab.h>
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010018#include <linux/module.h>
19#include <linux/delay.h>
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +020020#include <linux/gpio/consumer.h>
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010021#include <linux/mtd/mtd.h>
Boris Brezillond4092d72017-08-04 17:29:10 +020022#include <linux/mtd/rawnand.h>
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010023#include <linux/mtd/partitions.h>
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +010024#include <linux/platform_device.h>
Boris Brezillonfbb080a2018-11-11 08:55:08 +010025#include <linux/sizes.h>
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010026
27/*
28 * MTD structure for E3 (Delta)
29 */
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +020030struct ams_delta_nand {
Boris Brezillon9fd6bcf2018-11-11 08:55:13 +010031 struct nand_controller base;
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +020032 struct nand_chip nand_chip;
33 struct gpio_desc *gpiod_rdy;
34 struct gpio_desc *gpiod_nce;
35 struct gpio_desc *gpiod_nre;
36 struct gpio_desc *gpiod_nwp;
37 struct gpio_desc *gpiod_nwe;
38 struct gpio_desc *gpiod_ale;
39 struct gpio_desc *gpiod_cle;
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +010040 struct gpio_descs *data_gpiods;
Janusz Krzysztofik9c076d72018-09-20 00:52:55 +020041 bool data_in;
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +020042};
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010043
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010044/*
45 * Define partitions for flash devices
46 */
47
Arvind Yadavd4906682017-08-28 13:54:57 +053048static const struct mtd_partition partition_info[] = {
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010049 { .name = "Kernel",
50 .offset = 0,
51 .size = 3 * SZ_1M + SZ_512K },
52 { .name = "u-boot",
53 .offset = 3 * SZ_1M + SZ_512K,
54 .size = SZ_256K },
55 { .name = "u-boot params",
56 .offset = 3 * SZ_1M + SZ_512K + SZ_256K,
57 .size = SZ_256K },
58 { .name = "Amstrad LDR",
59 .offset = 4 * SZ_1M,
60 .size = SZ_256K },
61 { .name = "File system",
62 .offset = 4 * SZ_1M + 1 * SZ_256K,
63 .size = 27 * SZ_1M },
64 { .name = "PBL reserved",
65 .offset = 32 * SZ_1M - 3 * SZ_256K,
66 .size = 3 * SZ_256K },
67};
68
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +010069static void ams_delta_write_commit(struct ams_delta_nand *priv)
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010070{
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +020071 gpiod_set_value(priv->gpiod_nwe, 0);
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010072 ndelay(40);
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +020073 gpiod_set_value(priv->gpiod_nwe, 1);
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +010074}
75
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +010076static void ams_delta_io_write(struct ams_delta_nand *priv, u8 byte)
77{
78 struct gpio_descs *data_gpiods = priv->data_gpiods;
79 DECLARE_BITMAP(values, BITS_PER_TYPE(byte)) = { byte, };
80
81 gpiod_set_raw_array_value(data_gpiods->ndescs, data_gpiods->desc,
82 data_gpiods->info, values);
83
84 ams_delta_write_commit(priv);
85}
86
87static void ams_delta_dir_output(struct ams_delta_nand *priv, u8 byte)
88{
89 struct gpio_descs *data_gpiods = priv->data_gpiods;
90 DECLARE_BITMAP(values, BITS_PER_TYPE(byte)) = { byte, };
91 int i;
92
93 for (i = 0; i < data_gpiods->ndescs; i++)
94 gpiod_direction_output_raw(data_gpiods->desc[i],
95 test_bit(i, values));
96
97 ams_delta_write_commit(priv);
98
99 priv->data_in = false;
100}
101
Boris Brezillond54445d2018-11-11 08:55:10 +0100102static u8 ams_delta_io_read(struct ams_delta_nand *priv)
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100103{
Boris Brezillond54445d2018-11-11 08:55:10 +0100104 u8 res;
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100105 struct gpio_descs *data_gpiods = priv->data_gpiods;
106 DECLARE_BITMAP(values, BITS_PER_TYPE(res)) = { 0, };
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100107
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200108 gpiod_set_value(priv->gpiod_nre, 0);
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100109 ndelay(40);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100110
111 gpiod_get_raw_array_value(data_gpiods->ndescs, data_gpiods->desc,
112 data_gpiods->info, values);
113
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200114 gpiod_set_value(priv->gpiod_nre, 1);
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100115
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100116 res = values[0];
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100117 return res;
118}
119
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100120static void ams_delta_dir_input(struct ams_delta_nand *priv)
Janusz Krzysztofik9c076d72018-09-20 00:52:55 +0200121{
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100122 struct gpio_descs *data_gpiods = priv->data_gpiods;
123 int i;
124
125 for (i = 0; i < data_gpiods->ndescs; i++)
126 gpiod_direction_input(data_gpiods->desc[i]);
127
128 priv->data_in = true;
Janusz Krzysztofik9c076d72018-09-20 00:52:55 +0200129}
130
Boris Brezillond54445d2018-11-11 08:55:10 +0100131static void ams_delta_write_buf(struct ams_delta_nand *priv, const u8 *buf,
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100132 int len)
133{
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100134 int i = 0;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100135
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100136 if (len > 0 && priv->data_in)
137 ams_delta_dir_output(priv, buf[i++]);
Janusz Krzysztofik9c076d72018-09-20 00:52:55 +0200138
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100139 while (i < len)
140 ams_delta_io_write(priv, buf[i++]);
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100141}
142
Boris Brezillond54445d2018-11-11 08:55:10 +0100143static void ams_delta_read_buf(struct ams_delta_nand *priv, u8 *buf, int len)
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100144{
145 int i;
146
Janusz Krzysztofik9c076d72018-09-20 00:52:55 +0200147 if (!priv->data_in)
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100148 ams_delta_dir_input(priv);
Janusz Krzysztofik9c076d72018-09-20 00:52:55 +0200149
150 for (i = 0; i < len; i++)
151 buf[i] = ams_delta_io_read(priv);
152}
153
Boris Brezillon17700222018-11-11 08:55:21 +0100154static void ams_delta_ctrl_cs(struct ams_delta_nand *priv, bool assert)
Thomas Gleixner7abd3ef2006-05-23 23:25:53 +0200155{
Boris Brezillon17700222018-11-11 08:55:21 +0100156 gpiod_set_value(priv->gpiod_nce, assert ? 0 : 1);
Thomas Gleixner7abd3ef2006-05-23 23:25:53 +0200157}
158
Janusz Krzysztofik861fbd62018-10-15 21:41:30 +0200159static int ams_delta_exec_op(struct nand_chip *this,
160 const struct nand_operation *op, bool check_only)
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100161{
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200162 struct ams_delta_nand *priv = nand_get_controller_data(this);
Janusz Krzysztofik861fbd62018-10-15 21:41:30 +0200163 const struct nand_op_instr *instr;
164 int ret = 0;
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200165
Janusz Krzysztofik861fbd62018-10-15 21:41:30 +0200166 if (check_only)
167 return 0;
168
Boris Brezillon17700222018-11-11 08:55:21 +0100169 ams_delta_ctrl_cs(priv, 1);
170
Janusz Krzysztofik861fbd62018-10-15 21:41:30 +0200171 for (instr = op->instrs; instr < op->instrs + op->ninstrs; instr++) {
Janusz Krzysztofik861fbd62018-10-15 21:41:30 +0200172 switch (instr->type) {
173 case NAND_OP_CMD_INSTR:
174 gpiod_set_value(priv->gpiod_cle, 1);
175 ams_delta_write_buf(priv, &instr->ctx.cmd.opcode, 1);
176 gpiod_set_value(priv->gpiod_cle, 0);
177 break;
178
179 case NAND_OP_ADDR_INSTR:
180 gpiod_set_value(priv->gpiod_ale, 1);
181 ams_delta_write_buf(priv, instr->ctx.addr.addrs,
182 instr->ctx.addr.naddrs);
183 gpiod_set_value(priv->gpiod_ale, 0);
184 break;
185
186 case NAND_OP_DATA_IN_INSTR:
187 ams_delta_read_buf(priv, instr->ctx.data.buf.in,
188 instr->ctx.data.len);
189 break;
190
191 case NAND_OP_DATA_OUT_INSTR:
192 ams_delta_write_buf(priv, instr->ctx.data.buf.out,
193 instr->ctx.data.len);
194 break;
195
196 case NAND_OP_WAITRDY_INSTR:
197 ret = priv->gpiod_rdy ?
198 nand_gpio_waitrdy(this, priv->gpiod_rdy,
199 instr->ctx.waitrdy.timeout_ms) :
200 nand_soft_waitrdy(this,
201 instr->ctx.waitrdy.timeout_ms);
202 break;
203 }
204
205 if (ret)
206 break;
207 }
208
Boris Brezillon17700222018-11-11 08:55:21 +0100209 ams_delta_ctrl_cs(priv, 0);
210
Janusz Krzysztofik861fbd62018-10-15 21:41:30 +0200211 return ret;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100212}
213
Boris Brezillonf2abfeb2018-11-11 08:55:23 +0100214static const struct nand_controller_ops ams_delta_ops = {
215 .exec_op = ams_delta_exec_op,
216};
217
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100218/*
219 * Main initialization routine
220 */
Bill Pemberton06f25512012-11-19 13:23:07 -0500221static int ams_delta_init(struct platform_device *pdev)
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100222{
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200223 struct ams_delta_nand *priv;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100224 struct nand_chip *this;
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200225 struct mtd_info *mtd;
Janusz Krzysztofik97738612018-11-21 12:08:04 +0100226 struct gpio_descs *data_gpiods;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100227 int err = 0;
228
229 /* Allocate memory for MTD device structure and private data */
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200230 priv = devm_kzalloc(&pdev->dev, sizeof(struct ams_delta_nand),
231 GFP_KERNEL);
Boris Brezillond54445d2018-11-11 08:55:10 +0100232 if (!priv)
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200233 return -ENOMEM;
Boris Brezillond54445d2018-11-11 08:55:10 +0100234
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200235 this = &priv->nand_chip;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100236
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200237 mtd = nand_to_mtd(this);
238 mtd->dev.parent = &pdev->dev;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100239
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200240 nand_set_controller_data(this, priv);
Janusz Krzysztofikeaca4912010-12-15 15:43:44 +0100241
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200242 priv->gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", GPIOD_IN);
243 if (IS_ERR(priv->gpiod_rdy)) {
244 err = PTR_ERR(priv->gpiod_rdy);
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200245 dev_warn(&pdev->dev, "RDY GPIO request failed (%d)\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100246 return err;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100247 }
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200248
Thomas Gleixner6dfc6d22006-05-23 12:00:46 +0200249 this->ecc.mode = NAND_ECC_SOFT;
Rafał Miłeckie58dd3c2016-04-08 12:23:44 +0200250 this->ecc.algo = NAND_ECC_HAMMING;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100251
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200252 platform_set_drvdata(pdev, priv);
Janusz Krzysztofikeaca4912010-12-15 15:43:44 +0100253
Janusz Krzysztofik91a1abf2020-02-12 01:39:16 +0100254 /* Set chip enabled but write protected */
255 priv->gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_LOW);
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200256 if (IS_ERR(priv->gpiod_nwp)) {
257 err = PTR_ERR(priv->gpiod_nwp);
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200258 dev_err(&pdev->dev, "NWP GPIO request failed (%d)\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100259 return err;
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200260 }
261
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200262 priv->gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_HIGH);
263 if (IS_ERR(priv->gpiod_nce)) {
264 err = PTR_ERR(priv->gpiod_nce);
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200265 dev_err(&pdev->dev, "NCE GPIO request failed (%d)\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100266 return err;
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200267 }
268
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200269 priv->gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_HIGH);
270 if (IS_ERR(priv->gpiod_nre)) {
271 err = PTR_ERR(priv->gpiod_nre);
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200272 dev_err(&pdev->dev, "NRE GPIO request failed (%d)\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100273 return err;
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200274 }
275
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200276 priv->gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_HIGH);
277 if (IS_ERR(priv->gpiod_nwe)) {
278 err = PTR_ERR(priv->gpiod_nwe);
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200279 dev_err(&pdev->dev, "NWE GPIO request failed (%d)\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100280 return err;
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200281 }
282
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200283 priv->gpiod_ale = devm_gpiod_get(&pdev->dev, "ale", GPIOD_OUT_LOW);
284 if (IS_ERR(priv->gpiod_ale)) {
285 err = PTR_ERR(priv->gpiod_ale);
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200286 dev_err(&pdev->dev, "ALE GPIO request failed (%d)\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100287 return err;
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200288 }
289
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200290 priv->gpiod_cle = devm_gpiod_get(&pdev->dev, "cle", GPIOD_OUT_LOW);
291 if (IS_ERR(priv->gpiod_cle)) {
292 err = PTR_ERR(priv->gpiod_cle);
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200293 dev_err(&pdev->dev, "CLE GPIO request failed (%d)\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100294 return err;
Janusz Krzysztofikf1a97e02018-09-20 00:17:29 +0200295 }
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100296
Janusz Krzysztofik97738612018-11-21 12:08:04 +0100297 /* Request array of data pins, initialize them as input */
298 data_gpiods = devm_gpiod_get_array(&pdev->dev, "data", GPIOD_IN);
299 if (IS_ERR(data_gpiods)) {
300 err = PTR_ERR(data_gpiods);
301 dev_err(&pdev->dev, "data GPIO request failed: %d\n", err);
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100302 return err;
Janusz Krzysztofik97738612018-11-21 12:08:04 +0100303 }
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100304 priv->data_gpiods = data_gpiods;
Janusz Krzysztofik97738612018-11-21 12:08:04 +0100305 priv->data_in = true;
Janusz Krzysztofik9c076d72018-09-20 00:52:55 +0200306
Boris Brezillon9fd6bcf2018-11-11 08:55:13 +0100307 /* Initialize the NAND controller object embedded in ams_delta_nand. */
Boris Brezillonf2abfeb2018-11-11 08:55:23 +0100308 priv->base.ops = &ams_delta_ops;
Boris Brezillon9fd6bcf2018-11-11 08:55:13 +0100309 nand_controller_init(&priv->base);
310 this->controller = &priv->base;
311
Janusz Krzysztofik91a1abf2020-02-12 01:39:16 +0100312 /*
313 * FIXME: We should release write protection only after nand_scan() to
314 * be on the safe side but we can't do that until we have a generic way
315 * to assert/deassert WP from the core. Even if the core shouldn't
316 * write things in the nand_scan() path, it should have control on this
317 * pin just in case we ever need to disable write protection during
318 * chip detection/initialization.
319 */
320 /* Release write protection */
321 gpiod_set_value(priv->gpiod_nwp, 1);
322
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300323 /* Scan to find existence of the device */
Boris Brezillon00ad3782018-09-06 14:05:14 +0200324 err = nand_scan(this, 1);
Masahiro Yamada0d0aa862016-11-04 19:42:49 +0900325 if (err)
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100326 return err;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100327
328 /* Register the partitions */
Boris Brezillon876ba602018-11-11 08:55:12 +0100329 err = mtd_device_register(mtd, partition_info,
330 ARRAY_SIZE(partition_info));
331 if (err)
332 goto err_nand_cleanup;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100333
Boris Brezillon8bbc3c02018-11-11 08:55:11 +0100334 return 0;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100335
Boris Brezillon876ba602018-11-11 08:55:12 +0100336err_nand_cleanup:
337 nand_cleanup(this);
338
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100339 return err;
340}
341
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100342/*
343 * Clean up routine
344 */
Bill Pemberton810b7e02012-11-19 13:26:04 -0500345static int ams_delta_cleanup(struct platform_device *pdev)
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100346{
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200347 struct ams_delta_nand *priv = platform_get_drvdata(pdev);
348 struct mtd_info *mtd = nand_to_mtd(&priv->nand_chip);
Janusz Krzysztofikeaca4912010-12-15 15:43:44 +0100349
Janusz Krzysztofik91a1abf2020-02-12 01:39:16 +0100350 /* Apply write protection */
351 gpiod_set_value(priv->gpiod_nwp, 0);
352
Janusz Krzysztofik7416bd32018-11-21 12:08:05 +0100353 /* Unregister device */
Janusz Krzysztofik2b44af32018-09-20 00:52:54 +0200354 nand_release(mtd_to_nand(mtd));
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100355
Janusz Krzysztofik7e95d1f12010-12-14 21:09:40 +0100356 return 0;
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100357}
Janusz Krzysztofik7e95d1f12010-12-14 21:09:40 +0100358
359static struct platform_driver ams_delta_nand_driver = {
360 .probe = ams_delta_init,
Bill Pemberton5153b882012-11-19 13:21:24 -0500361 .remove = ams_delta_cleanup,
Janusz Krzysztofik7e95d1f12010-12-14 21:09:40 +0100362 .driver = {
363 .name = "ams-delta-nand",
Janusz Krzysztofik7e95d1f12010-12-14 21:09:40 +0100364 },
365};
366
Axel Linf99640d2011-11-27 20:45:03 +0800367module_platform_driver(ams_delta_nand_driver);
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100368
Boris Brezillon48573932018-11-11 08:55:09 +0100369MODULE_LICENSE("GPL v2");
Jonathan McDowell3d12c0c2006-05-21 18:11:55 +0100370MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
371MODULE_DESCRIPTION("Glue layer for NAND flash on Amstrad E3 (Delta)");