2 * linux/drivers/mtd/onenand/omap2.c
4 * OneNAND driver for OMAP2 / OMAP3
6 * Copyright © 2005-2006 Nokia Corporation
8 * Author: Jarkko Lavinen <jarkko.lavinen@nokia.com> and Juha Yrjölä
9 * IRQ and DMA support written by Timo Teras
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published by
13 * the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 * You should have received a copy of the GNU General Public License along with
21 * this program; see the file COPYING. If not, write to the Free Software
22 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include <linux/device.h>
27 #include <linux/module.h>
28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/onenand.h>
30 #include <linux/mtd/partitions.h>
31 #include <linux/platform_device.h>
32 #include <linux/interrupt.h>
33 #include <linux/delay.h>
34 #include <linux/dma-mapping.h>
36 #include <linux/slab.h>
37 #include <linux/regulator/consumer.h>
39 #include <asm/mach/flash.h>
40 #include <linux/platform_data/mtd-onenand-omap2.h>
43 #include <linux/omap-dma.h>
45 #define DRIVER_NAME "omap2-onenand"
47 #define ONENAND_BUFRAM_SIZE (1024 * 5)
49 struct omap2_onenand
{
50 struct platform_device
*pdev
;
52 unsigned long phys_base
;
53 unsigned int mem_size
;
56 struct onenand_chip onenand
;
57 struct completion irq_done
;
58 struct completion dma_done
;
61 int (*setup
)(void __iomem
*base
, int *freq_ptr
);
62 struct regulator
*regulator
;
66 static void omap2_onenand_dma_cb(int lch
, u16 ch_status
, void *data
)
68 struct omap2_onenand
*c
= data
;
70 complete(&c
->dma_done
);
73 static irqreturn_t
omap2_onenand_interrupt(int irq
, void *dev_id
)
75 struct omap2_onenand
*c
= dev_id
;
77 complete(&c
->irq_done
);
82 static inline unsigned short read_reg(struct omap2_onenand
*c
, int reg
)
84 return readw(c
->onenand
.base
+ reg
);
87 static inline void write_reg(struct omap2_onenand
*c
, unsigned short value
,
90 writew(value
, c
->onenand
.base
+ reg
);
93 static void wait_err(char *msg
, int state
, unsigned int ctrl
, unsigned int intr
)
95 printk(KERN_ERR
"onenand_wait: %s! state %d ctrl 0x%04x intr 0x%04x\n",
96 msg
, state
, ctrl
, intr
);
99 static void wait_warn(char *msg
, int state
, unsigned int ctrl
,
102 printk(KERN_WARNING
"onenand_wait: %s! state %d ctrl 0x%04x "
103 "intr 0x%04x\n", msg
, state
, ctrl
, intr
);
106 static int omap2_onenand_wait(struct mtd_info
*mtd
, int state
)
108 struct omap2_onenand
*c
= container_of(mtd
, struct omap2_onenand
, mtd
);
109 struct onenand_chip
*this = mtd
->priv
;
110 unsigned int intr
= 0;
111 unsigned int ctrl
, ctrl_mask
;
112 unsigned long timeout
;
115 if (state
== FL_RESETING
|| state
== FL_PREPARING_ERASE
||
116 state
== FL_VERIFYING_ERASE
) {
118 unsigned int intr_flags
= ONENAND_INT_MASTER
;
122 intr_flags
|= ONENAND_INT_RESET
;
124 case FL_PREPARING_ERASE
:
125 intr_flags
|= ONENAND_INT_ERASE
;
127 case FL_VERIFYING_ERASE
:
134 intr
= read_reg(c
, ONENAND_REG_INTERRUPT
);
135 if (intr
& ONENAND_INT_MASTER
)
138 ctrl
= read_reg(c
, ONENAND_REG_CTRL_STATUS
);
139 if (ctrl
& ONENAND_CTRL_ERROR
) {
140 wait_err("controller error", state
, ctrl
, intr
);
143 if ((intr
& intr_flags
) == intr_flags
)
145 /* Continue in wait for interrupt branch */
148 if (state
!= FL_READING
) {
151 /* Turn interrupts on */
152 syscfg
= read_reg(c
, ONENAND_REG_SYS_CFG1
);
153 if (!(syscfg
& ONENAND_SYS_CFG1_IOBE
)) {
154 syscfg
|= ONENAND_SYS_CFG1_IOBE
;
155 write_reg(c
, syscfg
, ONENAND_REG_SYS_CFG1
);
156 if (c
->flags
& ONENAND_IN_OMAP34XX
)
157 /* Add a delay to let GPIO settle */
158 syscfg
= read_reg(c
, ONENAND_REG_SYS_CFG1
);
161 reinit_completion(&c
->irq_done
);
163 result
= gpio_get_value(c
->gpio_irq
);
165 ctrl
= read_reg(c
, ONENAND_REG_CTRL_STATUS
);
166 intr
= read_reg(c
, ONENAND_REG_INTERRUPT
);
167 wait_err("gpio error", state
, ctrl
, intr
);
175 result
= wait_for_completion_timeout(&c
->irq_done
,
176 msecs_to_jiffies(20));
178 /* Timeout after 20ms */
179 ctrl
= read_reg(c
, ONENAND_REG_CTRL_STATUS
);
180 if (ctrl
& ONENAND_CTRL_ONGO
&&
183 * The operation seems to be still going
184 * so give it some more time.
190 ONENAND_REG_INTERRUPT
);
191 wait_err("timeout", state
, ctrl
, intr
);
194 intr
= read_reg(c
, ONENAND_REG_INTERRUPT
);
195 if ((intr
& ONENAND_INT_MASTER
) == 0)
196 wait_warn("timeout", state
, ctrl
, intr
);
202 /* Turn interrupts off */
203 syscfg
= read_reg(c
, ONENAND_REG_SYS_CFG1
);
204 syscfg
&= ~ONENAND_SYS_CFG1_IOBE
;
205 write_reg(c
, syscfg
, ONENAND_REG_SYS_CFG1
);
207 timeout
= jiffies
+ msecs_to_jiffies(20);
209 if (time_before(jiffies
, timeout
)) {
210 intr
= read_reg(c
, ONENAND_REG_INTERRUPT
);
211 if (intr
& ONENAND_INT_MASTER
)
214 /* Timeout after 20ms */
215 ctrl
= read_reg(c
, ONENAND_REG_CTRL_STATUS
);
216 if (ctrl
& ONENAND_CTRL_ONGO
) {
218 * The operation seems to be still going
219 * so give it some more time.
224 msecs_to_jiffies(20);
233 intr
= read_reg(c
, ONENAND_REG_INTERRUPT
);
234 ctrl
= read_reg(c
, ONENAND_REG_CTRL_STATUS
);
236 if (intr
& ONENAND_INT_READ
) {
237 int ecc
= read_reg(c
, ONENAND_REG_ECC_STATUS
);
240 unsigned int addr1
, addr8
;
242 addr1
= read_reg(c
, ONENAND_REG_START_ADDRESS1
);
243 addr8
= read_reg(c
, ONENAND_REG_START_ADDRESS8
);
244 if (ecc
& ONENAND_ECC_2BIT_ALL
) {
245 printk(KERN_ERR
"onenand_wait: ECC error = "
246 "0x%04x, addr1 %#x, addr8 %#x\n",
248 mtd
->ecc_stats
.failed
++;
250 } else if (ecc
& ONENAND_ECC_1BIT_ALL
) {
251 printk(KERN_NOTICE
"onenand_wait: correctable "
252 "ECC error = 0x%04x, addr1 %#x, "
253 "addr8 %#x\n", ecc
, addr1
, addr8
);
254 mtd
->ecc_stats
.corrected
++;
257 } else if (state
== FL_READING
) {
258 wait_err("timeout", state
, ctrl
, intr
);
262 if (ctrl
& ONENAND_CTRL_ERROR
) {
263 wait_err("controller error", state
, ctrl
, intr
);
264 if (ctrl
& ONENAND_CTRL_LOCK
)
265 printk(KERN_ERR
"onenand_wait: "
266 "Device is write protected!!!\n");
272 ctrl_mask
&= ~0x8000;
274 if (ctrl
& ctrl_mask
)
275 wait_warn("unexpected controller status", state
, ctrl
, intr
);
280 static inline int omap2_onenand_bufferram_offset(struct mtd_info
*mtd
, int area
)
282 struct onenand_chip
*this = mtd
->priv
;
284 if (ONENAND_CURRENT_BUFFERRAM(this)) {
285 if (area
== ONENAND_DATARAM
)
286 return this->writesize
;
287 if (area
== ONENAND_SPARERAM
)
294 #if defined(CONFIG_ARCH_OMAP3) || defined(MULTI_OMAP2)
296 static int omap3_onenand_read_bufferram(struct mtd_info
*mtd
, int area
,
297 unsigned char *buffer
, int offset
,
300 struct omap2_onenand
*c
= container_of(mtd
, struct omap2_onenand
, mtd
);
301 struct onenand_chip
*this = mtd
->priv
;
302 dma_addr_t dma_src
, dma_dst
;
304 unsigned long timeout
;
305 void *buf
= (void *)buffer
;
307 volatile unsigned *done
;
309 bram_offset
= omap2_onenand_bufferram_offset(mtd
, area
) + area
+ offset
;
310 if (bram_offset
& 3 || (size_t)buf
& 3 || count
< 384)
313 /* panic_write() may be in an interrupt context */
314 if (in_interrupt() || oops_in_progress
)
317 if (buf
>= high_memory
) {
320 if (((size_t)buf
& PAGE_MASK
) !=
321 ((size_t)(buf
+ count
- 1) & PAGE_MASK
))
323 p1
= vmalloc_to_page(buf
);
326 buf
= page_address(p1
) + ((size_t)buf
& ~PAGE_MASK
);
332 memcpy(buf
+ count
, this->base
+ bram_offset
+ count
, xtra
);
335 dma_src
= c
->phys_base
+ bram_offset
;
336 dma_dst
= dma_map_single(&c
->pdev
->dev
, buf
, count
, DMA_FROM_DEVICE
);
337 if (dma_mapping_error(&c
->pdev
->dev
, dma_dst
)) {
338 dev_err(&c
->pdev
->dev
,
339 "Couldn't DMA map a %d byte buffer\n",
344 omap_set_dma_transfer_params(c
->dma_channel
, OMAP_DMA_DATA_TYPE_S32
,
345 count
>> 2, 1, 0, 0, 0);
346 omap_set_dma_src_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
348 omap_set_dma_dest_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
351 reinit_completion(&c
->dma_done
);
352 omap_start_dma(c
->dma_channel
);
354 timeout
= jiffies
+ msecs_to_jiffies(20);
355 done
= &c
->dma_done
.done
;
356 while (time_before(jiffies
, timeout
))
360 dma_unmap_single(&c
->pdev
->dev
, dma_dst
, count
, DMA_FROM_DEVICE
);
363 dev_err(&c
->pdev
->dev
, "timeout waiting for DMA\n");
370 memcpy(buf
, this->base
+ bram_offset
, count
);
374 static int omap3_onenand_write_bufferram(struct mtd_info
*mtd
, int area
,
375 const unsigned char *buffer
,
376 int offset
, size_t count
)
378 struct omap2_onenand
*c
= container_of(mtd
, struct omap2_onenand
, mtd
);
379 struct onenand_chip
*this = mtd
->priv
;
380 dma_addr_t dma_src
, dma_dst
;
382 unsigned long timeout
;
383 void *buf
= (void *)buffer
;
384 volatile unsigned *done
;
386 bram_offset
= omap2_onenand_bufferram_offset(mtd
, area
) + area
+ offset
;
387 if (bram_offset
& 3 || (size_t)buf
& 3 || count
< 384)
390 /* panic_write() may be in an interrupt context */
391 if (in_interrupt() || oops_in_progress
)
394 if (buf
>= high_memory
) {
397 if (((size_t)buf
& PAGE_MASK
) !=
398 ((size_t)(buf
+ count
- 1) & PAGE_MASK
))
400 p1
= vmalloc_to_page(buf
);
403 buf
= page_address(p1
) + ((size_t)buf
& ~PAGE_MASK
);
406 dma_src
= dma_map_single(&c
->pdev
->dev
, buf
, count
, DMA_TO_DEVICE
);
407 dma_dst
= c
->phys_base
+ bram_offset
;
408 if (dma_mapping_error(&c
->pdev
->dev
, dma_src
)) {
409 dev_err(&c
->pdev
->dev
,
410 "Couldn't DMA map a %d byte buffer\n",
415 omap_set_dma_transfer_params(c
->dma_channel
, OMAP_DMA_DATA_TYPE_S32
,
416 count
>> 2, 1, 0, 0, 0);
417 omap_set_dma_src_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
419 omap_set_dma_dest_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
422 reinit_completion(&c
->dma_done
);
423 omap_start_dma(c
->dma_channel
);
425 timeout
= jiffies
+ msecs_to_jiffies(20);
426 done
= &c
->dma_done
.done
;
427 while (time_before(jiffies
, timeout
))
431 dma_unmap_single(&c
->pdev
->dev
, dma_src
, count
, DMA_TO_DEVICE
);
434 dev_err(&c
->pdev
->dev
, "timeout waiting for DMA\n");
441 memcpy(this->base
+ bram_offset
, buf
, count
);
447 static int omap3_onenand_read_bufferram(struct mtd_info
*mtd
, int area
,
448 unsigned char *buffer
, int offset
,
454 static int omap3_onenand_write_bufferram(struct mtd_info
*mtd
, int area
,
455 const unsigned char *buffer
,
456 int offset
, size_t count
)
463 #if defined(CONFIG_ARCH_OMAP2) || defined(MULTI_OMAP2)
465 static int omap2_onenand_read_bufferram(struct mtd_info
*mtd
, int area
,
466 unsigned char *buffer
, int offset
,
469 struct omap2_onenand
*c
= container_of(mtd
, struct omap2_onenand
, mtd
);
470 struct onenand_chip
*this = mtd
->priv
;
471 dma_addr_t dma_src
, dma_dst
;
474 bram_offset
= omap2_onenand_bufferram_offset(mtd
, area
) + area
+ offset
;
475 /* DMA is not used. Revisit PM requirements before enabling it. */
476 if (1 || (c
->dma_channel
< 0) ||
477 ((void *) buffer
>= (void *) high_memory
) || (bram_offset
& 3) ||
478 (((unsigned int) buffer
) & 3) || (count
< 1024) || (count
& 3)) {
479 memcpy(buffer
, (__force
void *)(this->base
+ bram_offset
),
484 dma_src
= c
->phys_base
+ bram_offset
;
485 dma_dst
= dma_map_single(&c
->pdev
->dev
, buffer
, count
,
487 if (dma_mapping_error(&c
->pdev
->dev
, dma_dst
)) {
488 dev_err(&c
->pdev
->dev
,
489 "Couldn't DMA map a %d byte buffer\n",
494 omap_set_dma_transfer_params(c
->dma_channel
, OMAP_DMA_DATA_TYPE_S32
,
495 count
/ 4, 1, 0, 0, 0);
496 omap_set_dma_src_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
498 omap_set_dma_dest_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
501 reinit_completion(&c
->dma_done
);
502 omap_start_dma(c
->dma_channel
);
503 wait_for_completion(&c
->dma_done
);
505 dma_unmap_single(&c
->pdev
->dev
, dma_dst
, count
, DMA_FROM_DEVICE
);
510 static int omap2_onenand_write_bufferram(struct mtd_info
*mtd
, int area
,
511 const unsigned char *buffer
,
512 int offset
, size_t count
)
514 struct omap2_onenand
*c
= container_of(mtd
, struct omap2_onenand
, mtd
);
515 struct onenand_chip
*this = mtd
->priv
;
516 dma_addr_t dma_src
, dma_dst
;
519 bram_offset
= omap2_onenand_bufferram_offset(mtd
, area
) + area
+ offset
;
520 /* DMA is not used. Revisit PM requirements before enabling it. */
521 if (1 || (c
->dma_channel
< 0) ||
522 ((void *) buffer
>= (void *) high_memory
) || (bram_offset
& 3) ||
523 (((unsigned int) buffer
) & 3) || (count
< 1024) || (count
& 3)) {
524 memcpy((__force
void *)(this->base
+ bram_offset
), buffer
,
529 dma_src
= dma_map_single(&c
->pdev
->dev
, (void *) buffer
, count
,
531 dma_dst
= c
->phys_base
+ bram_offset
;
532 if (dma_mapping_error(&c
->pdev
->dev
, dma_src
)) {
533 dev_err(&c
->pdev
->dev
,
534 "Couldn't DMA map a %d byte buffer\n",
539 omap_set_dma_transfer_params(c
->dma_channel
, OMAP_DMA_DATA_TYPE_S16
,
540 count
/ 2, 1, 0, 0, 0);
541 omap_set_dma_src_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
543 omap_set_dma_dest_params(c
->dma_channel
, 0, OMAP_DMA_AMODE_POST_INC
,
546 reinit_completion(&c
->dma_done
);
547 omap_start_dma(c
->dma_channel
);
548 wait_for_completion(&c
->dma_done
);
550 dma_unmap_single(&c
->pdev
->dev
, dma_src
, count
, DMA_TO_DEVICE
);
557 static int omap2_onenand_read_bufferram(struct mtd_info
*mtd
, int area
,
558 unsigned char *buffer
, int offset
,
564 static int omap2_onenand_write_bufferram(struct mtd_info
*mtd
, int area
,
565 const unsigned char *buffer
,
566 int offset
, size_t count
)
573 static struct platform_driver omap2_onenand_driver
;
575 static void omap2_onenand_shutdown(struct platform_device
*pdev
)
577 struct omap2_onenand
*c
= dev_get_drvdata(&pdev
->dev
);
579 /* With certain content in the buffer RAM, the OMAP boot ROM code
580 * can recognize the flash chip incorrectly. Zero it out before
583 memset((__force
void *)c
->onenand
.base
, 0, ONENAND_BUFRAM_SIZE
);
586 static int omap2_onenand_enable(struct mtd_info
*mtd
)
589 struct omap2_onenand
*c
= container_of(mtd
, struct omap2_onenand
, mtd
);
591 ret
= regulator_enable(c
->regulator
);
593 dev_err(&c
->pdev
->dev
, "can't enable regulator\n");
598 static int omap2_onenand_disable(struct mtd_info
*mtd
)
601 struct omap2_onenand
*c
= container_of(mtd
, struct omap2_onenand
, mtd
);
603 ret
= regulator_disable(c
->regulator
);
605 dev_err(&c
->pdev
->dev
, "can't disable regulator\n");
610 static int omap2_onenand_probe(struct platform_device
*pdev
)
612 struct omap_onenand_platform_data
*pdata
;
613 struct omap2_onenand
*c
;
614 struct onenand_chip
*this;
616 struct resource
*res
;
617 struct mtd_part_parser_data ppdata
= {};
619 pdata
= dev_get_platdata(&pdev
->dev
);
621 dev_err(&pdev
->dev
, "platform data missing\n");
625 c
= kzalloc(sizeof(struct omap2_onenand
), GFP_KERNEL
);
629 init_completion(&c
->irq_done
);
630 init_completion(&c
->dma_done
);
631 c
->flags
= pdata
->flags
;
632 c
->gpmc_cs
= pdata
->cs
;
633 c
->gpio_irq
= pdata
->gpio_irq
;
634 c
->dma_channel
= pdata
->dma_channel
;
635 if (c
->dma_channel
< 0) {
636 /* if -1, don't use DMA */
640 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
643 dev_err(&pdev
->dev
, "error getting memory resource\n");
647 c
->phys_base
= res
->start
;
648 c
->mem_size
= resource_size(res
);
650 if (request_mem_region(c
->phys_base
, c
->mem_size
,
651 pdev
->dev
.driver
->name
) == NULL
) {
652 dev_err(&pdev
->dev
, "Cannot reserve memory region at 0x%08lx, size: 0x%x\n",
653 c
->phys_base
, c
->mem_size
);
657 c
->onenand
.base
= ioremap(c
->phys_base
, c
->mem_size
);
658 if (c
->onenand
.base
== NULL
) {
660 goto err_release_mem_region
;
663 if (pdata
->onenand_setup
!= NULL
) {
664 r
= pdata
->onenand_setup(c
->onenand
.base
, &c
->freq
);
666 dev_err(&pdev
->dev
, "Onenand platform setup failed: "
670 c
->setup
= pdata
->onenand_setup
;
674 if ((r
= gpio_request(c
->gpio_irq
, "OneNAND irq")) < 0) {
675 dev_err(&pdev
->dev
, "Failed to request GPIO%d for "
676 "OneNAND\n", c
->gpio_irq
);
679 gpio_direction_input(c
->gpio_irq
);
681 if ((r
= request_irq(gpio_to_irq(c
->gpio_irq
),
682 omap2_onenand_interrupt
, IRQF_TRIGGER_RISING
,
683 pdev
->dev
.driver
->name
, c
)) < 0)
684 goto err_release_gpio
;
687 if (c
->dma_channel
>= 0) {
688 r
= omap_request_dma(0, pdev
->dev
.driver
->name
,
689 omap2_onenand_dma_cb
, (void *) c
,
692 omap_set_dma_write_mode(c
->dma_channel
,
693 OMAP_DMA_WRITE_NON_POSTED
);
694 omap_set_dma_src_data_pack(c
->dma_channel
, 1);
695 omap_set_dma_src_burst_mode(c
->dma_channel
,
696 OMAP_DMA_DATA_BURST_8
);
697 omap_set_dma_dest_data_pack(c
->dma_channel
, 1);
698 omap_set_dma_dest_burst_mode(c
->dma_channel
,
699 OMAP_DMA_DATA_BURST_8
);
702 "failed to allocate DMA for OneNAND, "
703 "using PIO instead\n");
708 dev_info(&pdev
->dev
, "initializing on CS%d, phys base 0x%08lx, virtual "
709 "base %p, freq %d MHz\n", c
->gpmc_cs
, c
->phys_base
,
710 c
->onenand
.base
, c
->freq
);
713 c
->mtd
.priv
= &c
->onenand
;
715 c
->mtd
.dev
.parent
= &pdev
->dev
;
718 if (c
->dma_channel
>= 0) {
719 this->wait
= omap2_onenand_wait
;
720 if (c
->flags
& ONENAND_IN_OMAP34XX
) {
721 this->read_bufferram
= omap3_onenand_read_bufferram
;
722 this->write_bufferram
= omap3_onenand_write_bufferram
;
724 this->read_bufferram
= omap2_onenand_read_bufferram
;
725 this->write_bufferram
= omap2_onenand_write_bufferram
;
729 if (pdata
->regulator_can_sleep
) {
730 c
->regulator
= regulator_get(&pdev
->dev
, "vonenand");
731 if (IS_ERR(c
->regulator
)) {
732 dev_err(&pdev
->dev
, "Failed to get regulator\n");
733 r
= PTR_ERR(c
->regulator
);
734 goto err_release_dma
;
736 c
->onenand
.enable
= omap2_onenand_enable
;
737 c
->onenand
.disable
= omap2_onenand_disable
;
740 if (pdata
->skip_initial_unlocking
)
741 this->options
|= ONENAND_SKIP_INITIAL_UNLOCKING
;
743 if ((r
= onenand_scan(&c
->mtd
, 1)) < 0)
744 goto err_release_regulator
;
746 ppdata
.of_node
= pdata
->of_node
;
747 r
= mtd_device_parse_register(&c
->mtd
, NULL
, &ppdata
,
748 pdata
? pdata
->parts
: NULL
,
749 pdata
? pdata
->nr_parts
: 0);
751 goto err_release_onenand
;
753 platform_set_drvdata(pdev
, c
);
758 onenand_release(&c
->mtd
);
759 err_release_regulator
:
760 regulator_put(c
->regulator
);
762 if (c
->dma_channel
!= -1)
763 omap_free_dma(c
->dma_channel
);
765 free_irq(gpio_to_irq(c
->gpio_irq
), c
);
768 gpio_free(c
->gpio_irq
);
770 iounmap(c
->onenand
.base
);
771 err_release_mem_region
:
772 release_mem_region(c
->phys_base
, c
->mem_size
);
779 static int omap2_onenand_remove(struct platform_device
*pdev
)
781 struct omap2_onenand
*c
= dev_get_drvdata(&pdev
->dev
);
783 onenand_release(&c
->mtd
);
784 regulator_put(c
->regulator
);
785 if (c
->dma_channel
!= -1)
786 omap_free_dma(c
->dma_channel
);
787 omap2_onenand_shutdown(pdev
);
789 free_irq(gpio_to_irq(c
->gpio_irq
), c
);
790 gpio_free(c
->gpio_irq
);
792 iounmap(c
->onenand
.base
);
793 release_mem_region(c
->phys_base
, c
->mem_size
);
799 static struct platform_driver omap2_onenand_driver
= {
800 .probe
= omap2_onenand_probe
,
801 .remove
= omap2_onenand_remove
,
802 .shutdown
= omap2_onenand_shutdown
,
808 module_platform_driver(omap2_onenand_driver
);
810 MODULE_ALIAS("platform:" DRIVER_NAME
);
811 MODULE_LICENSE("GPL");
812 MODULE_AUTHOR("Jarkko Lavinen <jarkko.lavinen@nokia.com>");
813 MODULE_DESCRIPTION("Glue layer for OneNAND flash on OMAP2 / OMAP3");