aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c39
1 files changed, 8 insertions, 31 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 0aa0142de14f..d6343e2c5889 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -77,16 +77,7 @@ struct s3c24xx_i2c {
77#endif 77#endif
78}; 78};
79 79
80/* default platform data to use if not supplied in the platform_device 80/* default platform data removed, dev should always carry data. */
81*/
82
83static struct s3c2410_platform_i2c s3c24xx_i2c_default_platform = {
84 .flags = 0,
85 .slave_addr = 0x10,
86 .bus_freq = 100*1000,
87 .max_freq = 400*1000,
88 .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
89};
90 81
91/* s3c24xx_i2c_is2440() 82/* s3c24xx_i2c_is2440()
92 * 83 *
@@ -100,22 +91,6 @@ static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
100 return !strcmp(pdev->name, "s3c2440-i2c"); 91 return !strcmp(pdev->name, "s3c2440-i2c");
101} 92}
102 93
103
104/* s3c24xx_i2c_get_platformdata
105 *
106 * get the platform data associated with the given device, or return
107 * the default if there is none
108*/
109
110static inline struct s3c2410_platform_i2c *
111s3c24xx_i2c_get_platformdata(struct device *dev)
112{
113 if (dev->platform_data != NULL)
114 return (struct s3c2410_platform_i2c *)dev->platform_data;
115
116 return &s3c24xx_i2c_default_platform;
117}
118
119/* s3c24xx_i2c_master_complete 94/* s3c24xx_i2c_master_complete
120 * 95 *
121 * complete the message and wake up the caller, using the given return code, 96 * complete the message and wake up the caller, using the given return code,
@@ -648,7 +623,7 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
648 623
649static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) 624static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
650{ 625{
651 struct s3c2410_platform_i2c *pdata; 626 struct s3c2410_platform_i2c *pdata = i2c->dev->platform_data;
652 unsigned long clkin = clk_get_rate(i2c->clk); 627 unsigned long clkin = clk_get_rate(i2c->clk);
653 unsigned int divs, div1; 628 unsigned int divs, div1;
654 u32 iiccon; 629 u32 iiccon;
@@ -656,8 +631,6 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
656 int start, end; 631 int start, end;
657 632
658 i2c->clkrate = clkin; 633 i2c->clkrate = clkin;
659
660 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
661 clkin /= 1000; /* clkin now in KHz */ 634 clkin /= 1000; /* clkin now in KHz */
662 635
663 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n", 636 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",
@@ -778,7 +751,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
778 751
779 /* get the plafrom data */ 752 /* get the plafrom data */
780 753
781 pdata = s3c24xx_i2c_get_platformdata(i2c->dev); 754 pdata = i2c->dev->platform_data;
782 755
783 /* inititalise the gpio */ 756 /* inititalise the gpio */
784 757
@@ -829,7 +802,11 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
829 struct resource *res; 802 struct resource *res;
830 int ret; 803 int ret;
831 804
832 pdata = s3c24xx_i2c_get_platformdata(&pdev->dev); 805 pdata = pdev->dev.platform_data;
806 if (!pdata) {
807 dev_err(&pdev->dev, "no platform data\n");
808 return -EINVAL;
809 }
833 810
834 /* find the clock and enable it */ 811 /* find the clock and enable it */
835 812