aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/r852.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-09 13:33:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-09 13:33:19 -0400
commitef9a61bef917e38f8e096f6df303329aed6cf467 (patch)
tree31cfe2444d0270e77ff8ef792df11591fed6075c /drivers/mtd/nand/r852.c
parentb5f0998cae3d7ea56d3d8377e46328fe972b9546 (diff)
parent6c3b88970175e18a67eb8e55c4eba10614d0d5dc (diff)
Merge tag 'for-linus-20130909' of git://git.infradead.org/linux-mtd
Pull mtd updates from David Woodhouse: - factor out common code from MTD tests - nand-gpio cleanup and portability to non-ARM - m25p80 support for 4-byte addressing chips, other new chips - pxa3xx cleanup and support for new platforms - remove obsolete alauda, octagon-5066 drivers - erase/write support for bcm47xxsflash - improve detection of ECC requirements for NAND, controller setup - NFC acceleration support for atmel-nand, read/write via SRAM - etc * tag 'for-linus-20130909' of git://git.infradead.org/linux-mtd: (184 commits) mtd: chips: Add support for PMC SPI Flash chips in m25p80.c mtd: ofpart: use for_each_child_of_node() macro mtd: mtdswap: replace strict_strtoul() with kstrtoul() mtd cs553x_nand: use kzalloc() instead of memset mtd: atmel_nand: fix error return code in atmel_nand_probe() mtd: bcm47xxsflash: writing support mtd: bcm47xxsflash: implement erasing support mtd: bcm47xxsflash: convert to module_platform_driver instead of init/exit mtd: bcm47xxsflash: convert kzalloc to avoid invalid access mtd: remove alauda driver mtd: nand: mxc_nand: mark 'const' properly mtd: maps: cfi_flagadm: add missing __iomem annotation mtd: spear_smi: add missing __iomem annotation mtd: r852: Staticize local symbols mtd: nandsim: Staticize local symbols mtd: impa7: add missing __iomem annotation mtd: sm_ftl: Staticize local symbols mtd: m25p80: add support for mr25h10 mtd: m25p80: make CONFIG_M25PXX_USE_FAST_READ safe to enable mtd: m25p80: Pass flags through CAT25_INFO macro ...
Diffstat (limited to 'drivers/mtd/nand/r852.c')
-rw-r--r--drivers/mtd/nand/r852.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
index 4495f8551fa0..9dcf02d22aa8 100644
--- a/drivers/mtd/nand/r852.c
+++ b/drivers/mtd/nand/r852.c
@@ -229,7 +229,7 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read)
229/* 229/*
230 * Program data lines of the nand chip to send data to it 230 * Program data lines of the nand chip to send data to it
231 */ 231 */
232void r852_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 232static void r852_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
233{ 233{
234 struct r852_device *dev = r852_get_dev(mtd); 234 struct r852_device *dev = r852_get_dev(mtd);
235 uint32_t reg; 235 uint32_t reg;
@@ -261,7 +261,7 @@ void r852_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
261/* 261/*
262 * Read data lines of the nand chip to retrieve data 262 * Read data lines of the nand chip to retrieve data
263 */ 263 */
264void r852_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 264static void r852_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
265{ 265{
266 struct r852_device *dev = r852_get_dev(mtd); 266 struct r852_device *dev = r852_get_dev(mtd);
267 uint32_t reg; 267 uint32_t reg;
@@ -312,7 +312,7 @@ static uint8_t r852_read_byte(struct mtd_info *mtd)
312/* 312/*
313 * Control several chip lines & send commands 313 * Control several chip lines & send commands
314 */ 314 */
315void r852_cmdctl(struct mtd_info *mtd, int dat, unsigned int ctrl) 315static void r852_cmdctl(struct mtd_info *mtd, int dat, unsigned int ctrl)
316{ 316{
317 struct r852_device *dev = r852_get_dev(mtd); 317 struct r852_device *dev = r852_get_dev(mtd);
318 318
@@ -357,7 +357,7 @@ void r852_cmdctl(struct mtd_info *mtd, int dat, unsigned int ctrl)
357 * Wait till card is ready. 357 * Wait till card is ready.
358 * based on nand_wait, but returns errors on DMA error 358 * based on nand_wait, but returns errors on DMA error
359 */ 359 */
360int r852_wait(struct mtd_info *mtd, struct nand_chip *chip) 360static int r852_wait(struct mtd_info *mtd, struct nand_chip *chip)
361{ 361{
362 struct r852_device *dev = chip->priv; 362 struct r852_device *dev = chip->priv;
363 363
@@ -386,7 +386,7 @@ int r852_wait(struct mtd_info *mtd, struct nand_chip *chip)
386 * Check if card is ready 386 * Check if card is ready
387 */ 387 */
388 388
389int r852_ready(struct mtd_info *mtd) 389static int r852_ready(struct mtd_info *mtd)
390{ 390{
391 struct r852_device *dev = r852_get_dev(mtd); 391 struct r852_device *dev = r852_get_dev(mtd);
392 return !(r852_read_reg(dev, R852_CARD_STA) & R852_CARD_STA_BUSY); 392 return !(r852_read_reg(dev, R852_CARD_STA) & R852_CARD_STA_BUSY);
@@ -397,7 +397,7 @@ int r852_ready(struct mtd_info *mtd)
397 * Set ECC engine mode 397 * Set ECC engine mode
398*/ 398*/
399 399
400void r852_ecc_hwctl(struct mtd_info *mtd, int mode) 400static void r852_ecc_hwctl(struct mtd_info *mtd, int mode)
401{ 401{
402 struct r852_device *dev = r852_get_dev(mtd); 402 struct r852_device *dev = r852_get_dev(mtd);
403 403
@@ -429,7 +429,7 @@ void r852_ecc_hwctl(struct mtd_info *mtd, int mode)
429 * Calculate ECC, only used for writes 429 * Calculate ECC, only used for writes
430 */ 430 */
431 431
432int r852_ecc_calculate(struct mtd_info *mtd, const uint8_t *dat, 432static int r852_ecc_calculate(struct mtd_info *mtd, const uint8_t *dat,
433 uint8_t *ecc_code) 433 uint8_t *ecc_code)
434{ 434{
435 struct r852_device *dev = r852_get_dev(mtd); 435 struct r852_device *dev = r852_get_dev(mtd);
@@ -461,7 +461,7 @@ int r852_ecc_calculate(struct mtd_info *mtd, const uint8_t *dat,
461 * Correct the data using ECC, hw did almost everything for us 461 * Correct the data using ECC, hw did almost everything for us
462 */ 462 */
463 463
464int r852_ecc_correct(struct mtd_info *mtd, uint8_t *dat, 464static int r852_ecc_correct(struct mtd_info *mtd, uint8_t *dat,
465 uint8_t *read_ecc, uint8_t *calc_ecc) 465 uint8_t *read_ecc, uint8_t *calc_ecc)
466{ 466{
467 uint16_t ecc_reg; 467 uint16_t ecc_reg;
@@ -529,7 +529,7 @@ static int r852_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
529 * Start the nand engine 529 * Start the nand engine
530 */ 530 */
531 531
532void r852_engine_enable(struct r852_device *dev) 532static void r852_engine_enable(struct r852_device *dev)
533{ 533{
534 if (r852_read_reg_dword(dev, R852_HW) & R852_HW_UNKNOWN) { 534 if (r852_read_reg_dword(dev, R852_HW) & R852_HW_UNKNOWN) {
535 r852_write_reg(dev, R852_CTL, R852_CTL_RESET | R852_CTL_ON); 535 r852_write_reg(dev, R852_CTL, R852_CTL_RESET | R852_CTL_ON);
@@ -547,7 +547,7 @@ void r852_engine_enable(struct r852_device *dev)
547 * Stop the nand engine 547 * Stop the nand engine
548 */ 548 */
549 549
550void r852_engine_disable(struct r852_device *dev) 550static void r852_engine_disable(struct r852_device *dev)
551{ 551{
552 r852_write_reg_dword(dev, R852_HW, 0); 552 r852_write_reg_dword(dev, R852_HW, 0);
553 r852_write_reg(dev, R852_CTL, R852_CTL_RESET); 553 r852_write_reg(dev, R852_CTL, R852_CTL_RESET);
@@ -557,7 +557,7 @@ void r852_engine_disable(struct r852_device *dev)
557 * Test if card is present 557 * Test if card is present
558 */ 558 */
559 559
560void r852_card_update_present(struct r852_device *dev) 560static void r852_card_update_present(struct r852_device *dev)
561{ 561{
562 unsigned long flags; 562 unsigned long flags;
563 uint8_t reg; 563 uint8_t reg;
@@ -572,7 +572,7 @@ void r852_card_update_present(struct r852_device *dev)
572 * Update card detection IRQ state according to current card state 572 * Update card detection IRQ state according to current card state
573 * which is read in r852_card_update_present 573 * which is read in r852_card_update_present
574 */ 574 */
575void r852_update_card_detect(struct r852_device *dev) 575static void r852_update_card_detect(struct r852_device *dev)
576{ 576{
577 int card_detect_reg = r852_read_reg(dev, R852_CARD_IRQ_ENABLE); 577 int card_detect_reg = r852_read_reg(dev, R852_CARD_IRQ_ENABLE);
578 dev->card_unstable = 0; 578 dev->card_unstable = 0;
@@ -586,8 +586,8 @@ void r852_update_card_detect(struct r852_device *dev)
586 r852_write_reg(dev, R852_CARD_IRQ_ENABLE, card_detect_reg); 586 r852_write_reg(dev, R852_CARD_IRQ_ENABLE, card_detect_reg);
587} 587}
588 588
589ssize_t r852_media_type_show(struct device *sys_dev, 589static ssize_t r852_media_type_show(struct device *sys_dev,
590 struct device_attribute *attr, char *buf) 590 struct device_attribute *attr, char *buf)
591{ 591{
592 struct mtd_info *mtd = container_of(sys_dev, struct mtd_info, dev); 592 struct mtd_info *mtd = container_of(sys_dev, struct mtd_info, dev);
593 struct r852_device *dev = r852_get_dev(mtd); 593 struct r852_device *dev = r852_get_dev(mtd);
@@ -597,11 +597,11 @@ ssize_t r852_media_type_show(struct device *sys_dev,
597 return strlen(data); 597 return strlen(data);
598} 598}
599 599
600DEVICE_ATTR(media_type, S_IRUGO, r852_media_type_show, NULL); 600static DEVICE_ATTR(media_type, S_IRUGO, r852_media_type_show, NULL);
601 601
602 602
603/* Detect properties of card in slot */ 603/* Detect properties of card in slot */
604void r852_update_media_status(struct r852_device *dev) 604static void r852_update_media_status(struct r852_device *dev)
605{ 605{
606 uint8_t reg; 606 uint8_t reg;
607 unsigned long flags; 607 unsigned long flags;
@@ -630,7 +630,7 @@ void r852_update_media_status(struct r852_device *dev)
630 * Register the nand device 630 * Register the nand device
631 * Called when the card is detected 631 * Called when the card is detected
632 */ 632 */
633int r852_register_nand_device(struct r852_device *dev) 633static int r852_register_nand_device(struct r852_device *dev)
634{ 634{
635 dev->mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); 635 dev->mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
636 636
@@ -668,7 +668,7 @@ error1:
668 * Unregister the card 668 * Unregister the card
669 */ 669 */
670 670
671void r852_unregister_nand_device(struct r852_device *dev) 671static void r852_unregister_nand_device(struct r852_device *dev)
672{ 672{
673 if (!dev->card_registred) 673 if (!dev->card_registred)
674 return; 674 return;
@@ -682,7 +682,7 @@ void r852_unregister_nand_device(struct r852_device *dev)
682} 682}
683 683
684/* Card state updater */ 684/* Card state updater */
685void r852_card_detect_work(struct work_struct *work) 685static void r852_card_detect_work(struct work_struct *work)
686{ 686{
687 struct r852_device *dev = 687 struct r852_device *dev =
688 container_of(work, struct r852_device, card_detect_work.work); 688 container_of(work, struct r852_device, card_detect_work.work);
@@ -821,7 +821,7 @@ out:
821 return ret; 821 return ret;
822} 822}
823 823
824int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) 824static int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
825{ 825{
826 int error; 826 int error;
827 struct nand_chip *chip; 827 struct nand_chip *chip;
@@ -961,7 +961,7 @@ error1:
961 return error; 961 return error;
962} 962}
963 963
964void r852_remove(struct pci_dev *pci_dev) 964static void r852_remove(struct pci_dev *pci_dev)
965{ 965{
966 struct r852_device *dev = pci_get_drvdata(pci_dev); 966 struct r852_device *dev = pci_get_drvdata(pci_dev);
967 967
@@ -992,7 +992,7 @@ void r852_remove(struct pci_dev *pci_dev)
992 pci_disable_device(pci_dev); 992 pci_disable_device(pci_dev);
993} 993}
994 994
995void r852_shutdown(struct pci_dev *pci_dev) 995static void r852_shutdown(struct pci_dev *pci_dev)
996{ 996{
997 struct r852_device *dev = pci_get_drvdata(pci_dev); 997 struct r852_device *dev = pci_get_drvdata(pci_dev);
998 998
@@ -1002,7 +1002,7 @@ void r852_shutdown(struct pci_dev *pci_dev)
1002 pci_disable_device(pci_dev); 1002 pci_disable_device(pci_dev);
1003} 1003}
1004 1004
1005#ifdef CONFIG_PM 1005#ifdef CONFIG_PM_SLEEP
1006static int r852_suspend(struct device *device) 1006static int r852_suspend(struct device *device)
1007{ 1007{
1008 struct r852_device *dev = pci_get_drvdata(to_pci_dev(device)); 1008 struct r852_device *dev = pci_get_drvdata(to_pci_dev(device));
@@ -1055,9 +1055,6 @@ static int r852_resume(struct device *device)
1055 r852_update_card_detect(dev); 1055 r852_update_card_detect(dev);
1056 return 0; 1056 return 0;
1057} 1057}
1058#else
1059#define r852_suspend NULL
1060#define r852_resume NULL
1061#endif 1058#endif
1062 1059
1063static const struct pci_device_id r852_pci_id_tbl[] = { 1060static const struct pci_device_id r852_pci_id_tbl[] = {