aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-s3c2410.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-s3c2410.c')
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1b582262e677..58cfd3111ef6 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -760,24 +760,23 @@ static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c)
760 * called by the bus driver when a suitable device is found 760 * called by the bus driver when a suitable device is found
761*/ 761*/
762 762
763static int s3c24xx_i2c_probe(struct device *dev) 763static int s3c24xx_i2c_probe(struct platform_device *pdev)
764{ 764{
765 struct platform_device *pdev = to_platform_device(dev);
766 struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 765 struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
767 struct resource *res; 766 struct resource *res;
768 int ret; 767 int ret;
769 768
770 /* find the clock and enable it */ 769 /* find the clock and enable it */
771 770
772 i2c->dev = dev; 771 i2c->dev = &pdev->dev;
773 i2c->clk = clk_get(dev, "i2c"); 772 i2c->clk = clk_get(&pdev->dev, "i2c");
774 if (IS_ERR(i2c->clk)) { 773 if (IS_ERR(i2c->clk)) {
775 dev_err(dev, "cannot get clock\n"); 774 dev_err(&pdev->dev, "cannot get clock\n");
776 ret = -ENOENT; 775 ret = -ENOENT;
777 goto out; 776 goto out;
778 } 777 }
779 778
780 dev_dbg(dev, "clock source %p\n", i2c->clk); 779 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
781 780
782 clk_use(i2c->clk); 781 clk_use(i2c->clk);
783 clk_enable(i2c->clk); 782 clk_enable(i2c->clk);
@@ -786,7 +785,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
786 785
787 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 786 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
788 if (res == NULL) { 787 if (res == NULL) {
789 dev_err(dev, "cannot find IO resource\n"); 788 dev_err(&pdev->dev, "cannot find IO resource\n");
790 ret = -ENOENT; 789 ret = -ENOENT;
791 goto out; 790 goto out;
792 } 791 }
@@ -795,7 +794,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
795 pdev->name); 794 pdev->name);
796 795
797 if (i2c->ioarea == NULL) { 796 if (i2c->ioarea == NULL) {
798 dev_err(dev, "cannot request IO\n"); 797 dev_err(&pdev->dev, "cannot request IO\n");
799 ret = -ENXIO; 798 ret = -ENXIO;
800 goto out; 799 goto out;
801 } 800 }
@@ -803,17 +802,17 @@ static int s3c24xx_i2c_probe(struct device *dev)
803 i2c->regs = ioremap(res->start, (res->end-res->start)+1); 802 i2c->regs = ioremap(res->start, (res->end-res->start)+1);
804 803
805 if (i2c->regs == NULL) { 804 if (i2c->regs == NULL) {
806 dev_err(dev, "cannot map IO\n"); 805 dev_err(&pdev->dev, "cannot map IO\n");
807 ret = -ENXIO; 806 ret = -ENXIO;
808 goto out; 807 goto out;
809 } 808 }
810 809
811 dev_dbg(dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res); 810 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);
812 811
813 /* setup info block for the i2c core */ 812 /* setup info block for the i2c core */
814 813
815 i2c->adap.algo_data = i2c; 814 i2c->adap.algo_data = i2c;
816 i2c->adap.dev.parent = dev; 815 i2c->adap.dev.parent = &pdev->dev;
817 816
818 /* initialise the i2c controller */ 817 /* initialise the i2c controller */
819 818
@@ -827,7 +826,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
827 826
828 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 827 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
829 if (res == NULL) { 828 if (res == NULL) {
830 dev_err(dev, "cannot find IRQ\n"); 829 dev_err(&pdev->dev, "cannot find IRQ\n");
831 ret = -ENOENT; 830 ret = -ENOENT;
832 goto out; 831 goto out;
833 } 832 }
@@ -836,23 +835,23 @@ static int s3c24xx_i2c_probe(struct device *dev)
836 pdev->name, i2c); 835 pdev->name, i2c);
837 836
838 if (ret != 0) { 837 if (ret != 0) {
839 dev_err(dev, "cannot claim IRQ\n"); 838 dev_err(&pdev->dev, "cannot claim IRQ\n");
840 goto out; 839 goto out;
841 } 840 }
842 841
843 i2c->irq = res; 842 i2c->irq = res;
844 843
845 dev_dbg(dev, "irq resource %p (%ld)\n", res, res->start); 844 dev_dbg(&pdev->dev, "irq resource %p (%ld)\n", res, res->start);
846 845
847 ret = i2c_add_adapter(&i2c->adap); 846 ret = i2c_add_adapter(&i2c->adap);
848 if (ret < 0) { 847 if (ret < 0) {
849 dev_err(dev, "failed to add bus to i2c core\n"); 848 dev_err(&pdev->dev, "failed to add bus to i2c core\n");
850 goto out; 849 goto out;
851 } 850 }
852 851
853 dev_set_drvdata(dev, i2c); 852 platform_set_drvdata(pdev, i2c);
854 853
855 dev_info(dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); 854 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
856 855
857 out: 856 out:
858 if (ret < 0) 857 if (ret < 0)
@@ -866,22 +865,22 @@ static int s3c24xx_i2c_probe(struct device *dev)
866 * called when device is removed from the bus 865 * called when device is removed from the bus
867*/ 866*/
868 867
869static int s3c24xx_i2c_remove(struct device *dev) 868static int s3c24xx_i2c_remove(struct platform_device *pdev)
870{ 869{
871 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 870 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
872 871
873 if (i2c != NULL) { 872 if (i2c != NULL) {
874 s3c24xx_i2c_free(i2c); 873 s3c24xx_i2c_free(i2c);
875 dev_set_drvdata(dev, NULL); 874 platform_set_drvdata(pdev, NULL);
876 } 875 }
877 876
878 return 0; 877 return 0;
879} 878}
880 879
881#ifdef CONFIG_PM 880#ifdef CONFIG_PM
882static int s3c24xx_i2c_resume(struct device *dev) 881static int s3c24xx_i2c_resume(struct platform_device *dev)
883{ 882{
884 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 883 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
885 884
886 if (i2c != NULL) 885 if (i2c != NULL)
887 s3c24xx_i2c_init(i2c); 886 s3c24xx_i2c_init(i2c);
@@ -895,33 +894,35 @@ static int s3c24xx_i2c_resume(struct device *dev)
895 894
896/* device driver for platform bus bits */ 895/* device driver for platform bus bits */
897 896
898static struct device_driver s3c2410_i2c_driver = { 897static struct platform_driver s3c2410_i2c_driver = {
899 .owner = THIS_MODULE,
900 .name = "s3c2410-i2c",
901 .bus = &platform_bus_type,
902 .probe = s3c24xx_i2c_probe, 898 .probe = s3c24xx_i2c_probe,
903 .remove = s3c24xx_i2c_remove, 899 .remove = s3c24xx_i2c_remove,
904 .resume = s3c24xx_i2c_resume, 900 .resume = s3c24xx_i2c_resume,
901 .driver = {
902 .owner = THIS_MODULE,
903 .name = "s3c2410-i2c",
904 },
905}; 905};
906 906
907static struct device_driver s3c2440_i2c_driver = { 907static struct platform_driver s3c2440_i2c_driver = {
908 .owner = THIS_MODULE,
909 .name = "s3c2440-i2c",
910 .bus = &platform_bus_type,
911 .probe = s3c24xx_i2c_probe, 908 .probe = s3c24xx_i2c_probe,
912 .remove = s3c24xx_i2c_remove, 909 .remove = s3c24xx_i2c_remove,
913 .resume = s3c24xx_i2c_resume, 910 .resume = s3c24xx_i2c_resume,
911 .driver = {
912 .owner = THIS_MODULE,
913 .name = "s3c2440-i2c",
914 },
914}; 915};
915 916
916static int __init i2c_adap_s3c_init(void) 917static int __init i2c_adap_s3c_init(void)
917{ 918{
918 int ret; 919 int ret;
919 920
920 ret = driver_register(&s3c2410_i2c_driver); 921 ret = platform_driver_register(&s3c2410_i2c_driver);
921 if (ret == 0) { 922 if (ret == 0) {
922 ret = driver_register(&s3c2440_i2c_driver); 923 ret = platform_driver_register(&s3c2440_i2c_driver);
923 if (ret) 924 if (ret)
924 driver_unregister(&s3c2410_i2c_driver); 925 platform_driver_unregister(&s3c2410_i2c_driver);
925 } 926 }
926 927
927 return ret; 928 return ret;
@@ -929,8 +930,8 @@ static int __init i2c_adap_s3c_init(void)
929 930
930static void __exit i2c_adap_s3c_exit(void) 931static void __exit i2c_adap_s3c_exit(void)
931{ 932{
932 driver_unregister(&s3c2410_i2c_driver); 933 platform_driver_unregister(&s3c2410_i2c_driver);
933 driver_unregister(&s3c2440_i2c_driver); 934 platform_driver_unregister(&s3c2440_i2c_driver);
934} 935}
935 936
936module_init(i2c_adap_s3c_init); 937module_init(i2c_adap_s3c_init);