aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-10-31 12:10:28 -0400
committerBen Dooks <ben-linux@fluff.org>2008-12-16 15:26:46 -0500
commit692acbd3a866a9f84e18a5980b3a97ca52e501b2 (patch)
treeef30c2cd2978826c652033e21c02c1ca06a86e28 /drivers/i2c
parent6a039cabba3ddd556643156ce0a7cd07da456b20 (diff)
i2c-s3c2410: Allow more than one i2c-s3c2410 adapter
Newer SoCs such as the S3C6410 have 2 instances of this i2c controller block in and thus require the ability to create two seperate busses from this. Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index d6343e2c5889..f14007ff2531 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -559,19 +559,6 @@ static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
559 .functionality = s3c24xx_i2c_func, 559 .functionality = s3c24xx_i2c_func,
560}; 560};
561 561
562static struct s3c24xx_i2c s3c24xx_i2c = {
563 .lock = __SPIN_LOCK_UNLOCKED(s3c24xx_i2c.lock),
564 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
565 .tx_setup = 50,
566 .adap = {
567 .name = "s3c2410-i2c",
568 .owner = THIS_MODULE,
569 .algo = &s3c24xx_i2c_algorithm,
570 .retries = 2,
571 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
572 },
573};
574
575/* s3c24xx_i2c_calcdivisor 562/* s3c24xx_i2c_calcdivisor
576 * 563 *
577 * return the divisor settings for a given frequency 564 * return the divisor settings for a given frequency
@@ -797,7 +784,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
797 784
798static int s3c24xx_i2c_probe(struct platform_device *pdev) 785static int s3c24xx_i2c_probe(struct platform_device *pdev)
799{ 786{
800 struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 787 struct s3c24xx_i2c *i2c;
801 struct s3c2410_platform_i2c *pdata; 788 struct s3c2410_platform_i2c *pdata;
802 struct resource *res; 789 struct resource *res;
803 int ret; 790 int ret;
@@ -808,6 +795,22 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
808 return -EINVAL; 795 return -EINVAL;
809 } 796 }
810 797
798 i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
799 if (!i2c) {
800 dev_err(&pdev->dev, "no memory for state\n");
801 return -ENOMEM;
802 }
803
804 strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name));
805 i2c->adap.owner = THIS_MODULE;
806 i2c->adap.algo = &s3c24xx_i2c_algorithm;
807 i2c->adap.retries = 2;
808 i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
809 i2c->tx_setup = 50;
810
811 spin_lock_init(&i2c->lock);
812 init_waitqueue_head(&i2c->wait);
813
811 /* find the clock and enable it */ 814 /* find the clock and enable it */
812 815
813 i2c->dev = &pdev->dev; 816 i2c->dev = &pdev->dev;
@@ -929,6 +932,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
929 clk_put(i2c->clk); 932 clk_put(i2c->clk);
930 933
931 err_noclk: 934 err_noclk:
935 kfree(i2c);
932 return ret; 936 return ret;
933} 937}
934 938
@@ -953,6 +957,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
953 957
954 release_resource(i2c->ioarea); 958 release_resource(i2c->ioarea);
955 kfree(i2c->ioarea); 959 kfree(i2c->ioarea);
960 kfree(i2c);
956 961
957 return 0; 962 return 0;
958} 963}