Skip to content

Commit

Permalink
i2c: S3C2410: Pass the I2C bus number via drivers platform data
Browse files Browse the repository at this point in the history
Allow the platform data to specify the bus bumber that the
new I2C bus will be given. This is to allow the use of the
board registration mechanism to specify the new style of
I2C device registration which allows boards to provide a
list of attached devices.

Note, as discussed on the mailing list, we have dropped
backwards compatibility of adding an dynamic bus number
as it should not affect most boards to have the bus pinned
to 0 if they have either not specified platform data for
driver. Any board supplying platform data will automatically
have the bus_num field set to 0, and anyone who needs the
driver on a different bus number can supply platform data
to set bus_num.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Ben Dooks committed Jul 28, 2008
1 parent c9272c4 commit 399dee2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/i2c/busses/i2c-s3c2410.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,12 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
static int s3c24xx_i2c_probe(struct platform_device *pdev)
{
struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
struct s3c2410_platform_i2c *pdata;
struct resource *res;
int ret;

pdata = s3c24xx_i2c_get_platformdata(&pdev->dev);

/* find the clock and enable it */

i2c->dev = &pdev->dev;
Expand Down Expand Up @@ -832,7 +835,15 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,
(unsigned long)res->start);

ret = i2c_add_adapter(&i2c->adap);
/* Note, previous versions of the driver used i2c_add_adapter()
* to add the bus at any number. We now pass the bus number via
* the platform data, so if unset it will now default to always
* being bus 0.
*/

i2c->adap.nr = pdata->bus_num;

ret = i2c_add_numbered_adapter(&i2c->adap);
if (ret < 0) {
dev_err(&pdev->dev, "failed to add bus to i2c core\n");
goto err_irq;
Expand Down
1 change: 1 addition & 0 deletions include/asm-arm/plat-s3c/iic.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

struct s3c2410_platform_i2c {
int bus_num; /* bus number to use */
unsigned int flags;
unsigned int slave_addr; /* slave address for controller */
unsigned long bus_freq; /* standard bus frequency */
Expand Down

0 comments on commit 399dee2

Please sign in to comment.