aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/gpmi-nand/gpmi-nand.c')
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index d79696b2f19b..5cd141f7bfc2 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -25,7 +25,6 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/mtd/gpmi-nand.h>
29#include <linux/mtd/partitions.h> 28#include <linux/mtd/partitions.h>
30#include <linux/pinctrl/consumer.h> 29#include <linux/pinctrl/consumer.h>
31#include <linux/of.h> 30#include <linux/of.h>
@@ -33,6 +32,12 @@
33#include <linux/of_mtd.h> 32#include <linux/of_mtd.h>
34#include "gpmi-nand.h" 33#include "gpmi-nand.h"
35 34
35/* Resource names for the GPMI NAND driver. */
36#define GPMI_NAND_GPMI_REGS_ADDR_RES_NAME "gpmi-nand"
37#define GPMI_NAND_BCH_REGS_ADDR_RES_NAME "bch"
38#define GPMI_NAND_BCH_INTERRUPT_RES_NAME "bch"
39#define GPMI_NAND_DMA_INTERRUPT_RES_NAME "gpmi-dma"
40
36/* add our owner bbt descriptor */ 41/* add our owner bbt descriptor */
37static uint8_t scan_ff_pattern[] = { 0xff }; 42static uint8_t scan_ff_pattern[] = { 0xff };
38static struct nand_bbt_descr gpmi_bbt_descr = { 43static struct nand_bbt_descr gpmi_bbt_descr = {
@@ -222,7 +227,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr)
222 227
223 ret = dma_map_sg(this->dev, sgl, 1, dr); 228 ret = dma_map_sg(this->dev, sgl, 1, dr);
224 if (ret == 0) 229 if (ret == 0)
225 pr_err("map failed.\n"); 230 pr_err("DMA mapping failed.\n");
226 231
227 this->direct_dma_map_ok = false; 232 this->direct_dma_map_ok = false;
228 } 233 }
@@ -314,7 +319,7 @@ int start_dma_with_bch_irq(struct gpmi_nand_data *this,
314 return 0; 319 return 0;
315} 320}
316 321
317static int __devinit 322static int
318acquire_register_block(struct gpmi_nand_data *this, const char *res_name) 323acquire_register_block(struct gpmi_nand_data *this, const char *res_name)
319{ 324{
320 struct platform_device *pdev = this->pdev; 325 struct platform_device *pdev = this->pdev;
@@ -355,7 +360,7 @@ static void release_register_block(struct gpmi_nand_data *this)
355 res->bch_regs = NULL; 360 res->bch_regs = NULL;
356} 361}
357 362
358static int __devinit 363static int
359acquire_bch_irq(struct gpmi_nand_data *this, irq_handler_t irq_h) 364acquire_bch_irq(struct gpmi_nand_data *this, irq_handler_t irq_h)
360{ 365{
361 struct platform_device *pdev = this->pdev; 366 struct platform_device *pdev = this->pdev;
@@ -422,7 +427,7 @@ static void release_dma_channels(struct gpmi_nand_data *this)
422 } 427 }
423} 428}
424 429
425static int __devinit acquire_dma_channels(struct gpmi_nand_data *this) 430static int acquire_dma_channels(struct gpmi_nand_data *this)
426{ 431{
427 struct platform_device *pdev = this->pdev; 432 struct platform_device *pdev = this->pdev;
428 struct resource *r_dma; 433 struct resource *r_dma;
@@ -456,7 +461,7 @@ static int __devinit acquire_dma_channels(struct gpmi_nand_data *this)
456 461
457 dma_chan = dma_request_channel(mask, gpmi_dma_filter, this); 462 dma_chan = dma_request_channel(mask, gpmi_dma_filter, this);
458 if (!dma_chan) { 463 if (!dma_chan) {
459 pr_err("dma_request_channel failed.\n"); 464 pr_err("Failed to request DMA channel.\n");
460 goto acquire_err; 465 goto acquire_err;
461 } 466 }
462 467
@@ -487,7 +492,7 @@ static char *extra_clks_for_mx6q[GPMI_CLK_MAX] = {
487 "gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch", 492 "gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch",
488}; 493};
489 494
490static int __devinit gpmi_get_clks(struct gpmi_nand_data *this) 495static int gpmi_get_clks(struct gpmi_nand_data *this)
491{ 496{
492 struct resources *r = &this->resources; 497 struct resources *r = &this->resources;
493 char **extra_clks = NULL; 498 char **extra_clks = NULL;
@@ -533,7 +538,7 @@ err_clock:
533 return -ENOMEM; 538 return -ENOMEM;
534} 539}
535 540
536static int __devinit acquire_resources(struct gpmi_nand_data *this) 541static int acquire_resources(struct gpmi_nand_data *this)
537{ 542{
538 struct pinctrl *pinctrl; 543 struct pinctrl *pinctrl;
539 int ret; 544 int ret;
@@ -583,7 +588,7 @@ static void release_resources(struct gpmi_nand_data *this)
583 release_dma_channels(this); 588 release_dma_channels(this);
584} 589}
585 590
586static int __devinit init_hardware(struct gpmi_nand_data *this) 591static int init_hardware(struct gpmi_nand_data *this)
587{ 592{
588 int ret; 593 int ret;
589 594
@@ -625,7 +630,8 @@ static int read_page_prepare(struct gpmi_nand_data *this,
625 length, DMA_FROM_DEVICE); 630 length, DMA_FROM_DEVICE);
626 if (dma_mapping_error(dev, dest_phys)) { 631 if (dma_mapping_error(dev, dest_phys)) {
627 if (alt_size < length) { 632 if (alt_size < length) {
628 pr_err("Alternate buffer is too small\n"); 633 pr_err("%s, Alternate buffer is too small\n",
634 __func__);
629 return -ENOMEM; 635 return -ENOMEM;
630 } 636 }
631 goto map_failed; 637 goto map_failed;
@@ -675,7 +681,8 @@ static int send_page_prepare(struct gpmi_nand_data *this,
675 DMA_TO_DEVICE); 681 DMA_TO_DEVICE);
676 if (dma_mapping_error(dev, source_phys)) { 682 if (dma_mapping_error(dev, source_phys)) {
677 if (alt_size < length) { 683 if (alt_size < length) {
678 pr_err("Alternate buffer is too small\n"); 684 pr_err("%s, Alternate buffer is too small\n",
685 __func__);
679 return -ENOMEM; 686 return -ENOMEM;
680 } 687 }
681 goto map_failed; 688 goto map_failed;
@@ -763,7 +770,7 @@ static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this)
763 770
764error_alloc: 771error_alloc:
765 gpmi_free_dma_buffer(this); 772 gpmi_free_dma_buffer(this);
766 pr_err("allocate DMA buffer ret!!\n"); 773 pr_err("Error allocating DMA buffers!\n");
767 return -ENOMEM; 774 return -ENOMEM;
768} 775}
769 776
@@ -1474,7 +1481,7 @@ static int gpmi_set_geometry(struct gpmi_nand_data *this)
1474 /* Set up the NFC geometry which is used by BCH. */ 1481 /* Set up the NFC geometry which is used by BCH. */
1475 ret = bch_set_geometry(this); 1482 ret = bch_set_geometry(this);
1476 if (ret) { 1483 if (ret) {
1477 pr_err("set geometry ret : %d\n", ret); 1484 pr_err("Error setting BCH geometry : %d\n", ret);
1478 return ret; 1485 return ret;
1479 } 1486 }
1480 1487
@@ -1535,7 +1542,7 @@ static void gpmi_nfc_exit(struct gpmi_nand_data *this)
1535 gpmi_free_dma_buffer(this); 1542 gpmi_free_dma_buffer(this);
1536} 1543}
1537 1544
1538static int __devinit gpmi_nfc_init(struct gpmi_nand_data *this) 1545static int gpmi_nfc_init(struct gpmi_nand_data *this)
1539{ 1546{
1540 struct mtd_info *mtd = &this->mtd; 1547 struct mtd_info *mtd = &this->mtd;
1541 struct nand_chip *chip = &this->nand; 1548 struct nand_chip *chip = &this->nand;
@@ -1618,7 +1625,7 @@ static const struct of_device_id gpmi_nand_id_table[] = {
1618}; 1625};
1619MODULE_DEVICE_TABLE(of, gpmi_nand_id_table); 1626MODULE_DEVICE_TABLE(of, gpmi_nand_id_table);
1620 1627
1621static int __devinit gpmi_nand_probe(struct platform_device *pdev) 1628static int gpmi_nand_probe(struct platform_device *pdev)
1622{ 1629{
1623 struct gpmi_nand_data *this; 1630 struct gpmi_nand_data *this;
1624 const struct of_device_id *of_id; 1631 const struct of_device_id *of_id;
@@ -1668,7 +1675,7 @@ exit_acquire_resources:
1668 return ret; 1675 return ret;
1669} 1676}
1670 1677
1671static int __devexit gpmi_nand_remove(struct platform_device *pdev) 1678static int gpmi_nand_remove(struct platform_device *pdev)
1672{ 1679{
1673 struct gpmi_nand_data *this = platform_get_drvdata(pdev); 1680 struct gpmi_nand_data *this = platform_get_drvdata(pdev);
1674 1681
@@ -1685,7 +1692,7 @@ static struct platform_driver gpmi_nand_driver = {
1685 .of_match_table = gpmi_nand_id_table, 1692 .of_match_table = gpmi_nand_id_table,
1686 }, 1693 },
1687 .probe = gpmi_nand_probe, 1694 .probe = gpmi_nand_probe,
1688 .remove = __devexit_p(gpmi_nand_remove), 1695 .remove = gpmi_nand_remove,
1689 .id_table = gpmi_ids, 1696 .id_table = gpmi_ids,
1690}; 1697};
1691module_platform_driver(gpmi_nand_driver); 1698module_platform_driver(gpmi_nand_driver);