diff options
Diffstat (limited to 'drivers/mtd/nand/s3c2410.c')
-rw-r--r-- | drivers/mtd/nand/s3c2410.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 97e9b7892d29..d209214b1318 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -125,14 +125,14 @@ static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd) | |||
125 | return s3c2410_nand_mtd_toours(mtd)->info; | 125 | return s3c2410_nand_mtd_toours(mtd)->info; |
126 | } | 126 | } |
127 | 127 | ||
128 | static struct s3c2410_nand_info *to_nand_info(struct device *dev) | 128 | static struct s3c2410_nand_info *to_nand_info(struct platform_device *dev) |
129 | { | 129 | { |
130 | return dev_get_drvdata(dev); | 130 | return platform_get_drvdata(dev); |
131 | } | 131 | } |
132 | 132 | ||
133 | static struct s3c2410_platform_nand *to_nand_plat(struct device *dev) | 133 | static struct s3c2410_platform_nand *to_nand_plat(struct platform_device *dev) |
134 | { | 134 | { |
135 | return dev->platform_data; | 135 | return dev->dev.platform_data; |
136 | } | 136 | } |
137 | 137 | ||
138 | /* timing calculations */ | 138 | /* timing calculations */ |
@@ -165,9 +165,9 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max) | |||
165 | /* controller setup */ | 165 | /* controller setup */ |
166 | 166 | ||
167 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, | 167 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, |
168 | struct device *dev) | 168 | struct platform_device *pdev) |
169 | { | 169 | { |
170 | struct s3c2410_platform_nand *plat = to_nand_plat(dev); | 170 | struct s3c2410_platform_nand *plat = to_nand_plat(pdev); |
171 | unsigned long clkrate = clk_get_rate(info->clk); | 171 | unsigned long clkrate = clk_get_rate(info->clk); |
172 | int tacls, twrph0, twrph1; | 172 | int tacls, twrph0, twrph1; |
173 | unsigned long cfg; | 173 | unsigned long cfg; |
@@ -430,11 +430,11 @@ static void s3c2410_nand_write_buf(struct mtd_info *mtd, | |||
430 | 430 | ||
431 | /* device management functions */ | 431 | /* device management functions */ |
432 | 432 | ||
433 | static int s3c2410_nand_remove(struct device *dev) | 433 | static int s3c2410_nand_remove(struct platform_device *pdev) |
434 | { | 434 | { |
435 | struct s3c2410_nand_info *info = to_nand_info(dev); | 435 | struct s3c2410_nand_info *info = to_nand_info(pdev); |
436 | 436 | ||
437 | dev_set_drvdata(dev, NULL); | 437 | platform_set_drvdata(pdev, NULL); |
438 | 438 | ||
439 | if (info == NULL) | 439 | if (info == NULL) |
440 | return 0; | 440 | return 0; |
@@ -562,10 +562,9 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, | |||
562 | * nand layer to look for devices | 562 | * nand layer to look for devices |
563 | */ | 563 | */ |
564 | 564 | ||
565 | static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) | 565 | static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440) |
566 | { | 566 | { |
567 | struct platform_device *pdev = to_platform_device(dev); | 567 | struct s3c2410_platform_nand *plat = to_nand_plat(pdev); |
568 | struct s3c2410_platform_nand *plat = to_nand_plat(dev); | ||
569 | struct s3c2410_nand_info *info; | 568 | struct s3c2410_nand_info *info; |
570 | struct s3c2410_nand_mtd *nmtd; | 569 | struct s3c2410_nand_mtd *nmtd; |
571 | struct s3c2410_nand_set *sets; | 570 | struct s3c2410_nand_set *sets; |
@@ -575,26 +574,26 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) | |||
575 | int nr_sets; | 574 | int nr_sets; |
576 | int setno; | 575 | int setno; |
577 | 576 | ||
578 | pr_debug("s3c2410_nand_probe(%p)\n", dev); | 577 | pr_debug("s3c2410_nand_probe(%p)\n", pdev); |
579 | 578 | ||
580 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 579 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
581 | if (info == NULL) { | 580 | if (info == NULL) { |
582 | dev_err(dev, "no memory for flash info\n"); | 581 | dev_err(&pdev->dev, "no memory for flash info\n"); |
583 | err = -ENOMEM; | 582 | err = -ENOMEM; |
584 | goto exit_error; | 583 | goto exit_error; |
585 | } | 584 | } |
586 | 585 | ||
587 | memzero(info, sizeof(*info)); | 586 | memzero(info, sizeof(*info)); |
588 | dev_set_drvdata(dev, info); | 587 | platform_set_drvdata(pdev, info); |
589 | 588 | ||
590 | spin_lock_init(&info->controller.lock); | 589 | spin_lock_init(&info->controller.lock); |
591 | init_waitqueue_head(&info->controller.wq); | 590 | init_waitqueue_head(&info->controller.wq); |
592 | 591 | ||
593 | /* get the clock source and enable it */ | 592 | /* get the clock source and enable it */ |
594 | 593 | ||
595 | info->clk = clk_get(dev, "nand"); | 594 | info->clk = clk_get(&pdev->dev, "nand"); |
596 | if (IS_ERR(info->clk)) { | 595 | if (IS_ERR(info->clk)) { |
597 | dev_err(dev, "failed to get clock"); | 596 | dev_err(&pdev->dev, "failed to get clock"); |
598 | err = -ENOENT; | 597 | err = -ENOENT; |
599 | goto exit_error; | 598 | goto exit_error; |
600 | } | 599 | } |
@@ -611,27 +610,27 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) | |||
611 | info->area = request_mem_region(res->start, size, pdev->name); | 610 | info->area = request_mem_region(res->start, size, pdev->name); |
612 | 611 | ||
613 | if (info->area == NULL) { | 612 | if (info->area == NULL) { |
614 | dev_err(dev, "cannot reserve register region\n"); | 613 | dev_err(&pdev->dev, "cannot reserve register region\n"); |
615 | err = -ENOENT; | 614 | err = -ENOENT; |
616 | goto exit_error; | 615 | goto exit_error; |
617 | } | 616 | } |
618 | 617 | ||
619 | info->device = dev; | 618 | info->device = &pdev->dev; |
620 | info->platform = plat; | 619 | info->platform = plat; |
621 | info->regs = ioremap(res->start, size); | 620 | info->regs = ioremap(res->start, size); |
622 | info->is_s3c2440 = is_s3c2440; | 621 | info->is_s3c2440 = is_s3c2440; |
623 | 622 | ||
624 | if (info->regs == NULL) { | 623 | if (info->regs == NULL) { |
625 | dev_err(dev, "cannot reserve register region\n"); | 624 | dev_err(&pdev->dev, "cannot reserve register region\n"); |
626 | err = -EIO; | 625 | err = -EIO; |
627 | goto exit_error; | 626 | goto exit_error; |
628 | } | 627 | } |
629 | 628 | ||
630 | dev_dbg(dev, "mapped registers at %p\n", info->regs); | 629 | dev_dbg(&pdev->dev, "mapped registers at %p\n", info->regs); |
631 | 630 | ||
632 | /* initialise the hardware */ | 631 | /* initialise the hardware */ |
633 | 632 | ||
634 | err = s3c2410_nand_inithw(info, dev); | 633 | err = s3c2410_nand_inithw(info, pdev); |
635 | if (err != 0) | 634 | if (err != 0) |
636 | goto exit_error; | 635 | goto exit_error; |
637 | 636 | ||
@@ -645,7 +644,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) | |||
645 | size = nr_sets * sizeof(*info->mtds); | 644 | size = nr_sets * sizeof(*info->mtds); |
646 | info->mtds = kmalloc(size, GFP_KERNEL); | 645 | info->mtds = kmalloc(size, GFP_KERNEL); |
647 | if (info->mtds == NULL) { | 646 | if (info->mtds == NULL) { |
648 | dev_err(dev, "failed to allocate mtd storage\n"); | 647 | dev_err(&pdev->dev, "failed to allocate mtd storage\n"); |
649 | err = -ENOMEM; | 648 | err = -ENOMEM; |
650 | goto exit_error; | 649 | goto exit_error; |
651 | } | 650 | } |
@@ -677,7 +676,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) | |||
677 | return 0; | 676 | return 0; |
678 | 677 | ||
679 | exit_error: | 678 | exit_error: |
680 | s3c2410_nand_remove(dev); | 679 | s3c2410_nand_remove(pdev); |
681 | 680 | ||
682 | if (err == 0) | 681 | if (err == 0) |
683 | err = -EINVAL; | 682 | err = -EINVAL; |
@@ -686,44 +685,46 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) | |||
686 | 685 | ||
687 | /* driver device registration */ | 686 | /* driver device registration */ |
688 | 687 | ||
689 | static int s3c2410_nand_probe(struct device *dev) | 688 | static int s3c2410_nand_probe(struct platform_device *dev) |
690 | { | 689 | { |
691 | return s3c24xx_nand_probe(dev, 0); | 690 | return s3c24xx_nand_probe(dev, 0); |
692 | } | 691 | } |
693 | 692 | ||
694 | static int s3c2440_nand_probe(struct device *dev) | 693 | static int s3c2440_nand_probe(struct platform_device *dev) |
695 | { | 694 | { |
696 | return s3c24xx_nand_probe(dev, 1); | 695 | return s3c24xx_nand_probe(dev, 1); |
697 | } | 696 | } |
698 | 697 | ||
699 | static struct device_driver s3c2410_nand_driver = { | 698 | static struct platform_driver s3c2410_nand_driver = { |
700 | .name = "s3c2410-nand", | ||
701 | .owner = THIS_MODULE, | ||
702 | .bus = &platform_bus_type, | ||
703 | .probe = s3c2410_nand_probe, | 699 | .probe = s3c2410_nand_probe, |
704 | .remove = s3c2410_nand_remove, | 700 | .remove = s3c2410_nand_remove, |
701 | .driver = { | ||
702 | .name = "s3c2410-nand", | ||
703 | .owner = THIS_MODULE, | ||
704 | }, | ||
705 | }; | 705 | }; |
706 | 706 | ||
707 | static struct device_driver s3c2440_nand_driver = { | 707 | static struct platform_driver s3c2440_nand_driver = { |
708 | .name = "s3c2440-nand", | ||
709 | .owner = THIS_MODULE, | ||
710 | .bus = &platform_bus_type, | ||
711 | .probe = s3c2440_nand_probe, | 708 | .probe = s3c2440_nand_probe, |
712 | .remove = s3c2410_nand_remove, | 709 | .remove = s3c2410_nand_remove, |
710 | .driver = { | ||
711 | .name = "s3c2440-nand", | ||
712 | .owner = THIS_MODULE, | ||
713 | }, | ||
713 | }; | 714 | }; |
714 | 715 | ||
715 | static int __init s3c2410_nand_init(void) | 716 | static int __init s3c2410_nand_init(void) |
716 | { | 717 | { |
717 | printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n"); | 718 | printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n"); |
718 | 719 | ||
719 | driver_register(&s3c2440_nand_driver); | 720 | platform_driver_register(&s3c2440_nand_driver); |
720 | return driver_register(&s3c2410_nand_driver); | 721 | return platform_driver_register(&s3c2410_nand_driver); |
721 | } | 722 | } |
722 | 723 | ||
723 | static void __exit s3c2410_nand_exit(void) | 724 | static void __exit s3c2410_nand_exit(void) |
724 | { | 725 | { |
725 | driver_unregister(&s3c2440_nand_driver); | 726 | platform_driver_unregister(&s3c2440_nand_driver); |
726 | driver_unregister(&s3c2410_nand_driver); | 727 | platform_driver_unregister(&s3c2410_nand_driver); |
727 | } | 728 | } |
728 | 729 | ||
729 | module_init(s3c2410_nand_init); | 730 | module_init(s3c2410_nand_init); |