Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 339697
b: refs/heads/master
c: c34f7c6
h: refs/heads/master
i:
  339695: fcaeecd
v: v3
  • Loading branch information
Tony Lindgren committed Oct 31, 2012
1 parent 470f4ae commit efeda8b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bb77209432873214a796a70a4539e4ebdf3feb54
refs/heads/master: c34f7c696211e3d45ff94a34824b65aa52576bc6
3 changes: 3 additions & 0 deletions trunk/arch/arm/mach-omap1/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata,
struct platform_device *pdev;
struct resource *res;

if (bus_id > 1)
return -EINVAL;

omap1_i2c_mux_pins(bus_id);

pdev = &omap_i2c_devices[bus_id - 1];
Expand Down
16 changes: 16 additions & 0 deletions trunk/arch/arm/mach-omap2/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ int omap_i2c_reset(struct omap_hwmod *oh)
return 0;
}

static int __init omap_i2c_nr_ports(void)
{
int ports = 0;

if (cpu_is_omap24xx())
ports = 2;
else if (cpu_is_omap34xx())
ports = 3;
else if (cpu_is_omap44xx())
ports = 4;
return ports;
}

static const char name[] = "omap_i2c";

int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
Expand All @@ -121,6 +134,9 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
struct omap_i2c_bus_platform_data *pdata;
struct omap_i2c_dev_attr *dev_attr;

if (bus_id > omap_i2c_nr_ports())
return -EINVAL;

omap2_i2c_mux_pins(bus_id);

l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);
Expand Down
26 changes: 3 additions & 23 deletions trunk/arch/arm/plat-omap/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,13 @@

#include <mach/irqs.h>

#include "../mach-omap1/soc.h"
#include "../mach-omap2/soc.h"

#include "i2c.h"

#define OMAP_I2C_MAX_CONTROLLERS 4
static struct omap_i2c_bus_platform_data i2c_pdata[OMAP_I2C_MAX_CONTROLLERS];

#define OMAP_I2C_CMDLINE_SETUP (BIT(31))

static int __init omap_i2c_nr_ports(void)
{
int ports = 0;

if (cpu_class_is_omap1())
ports = 1;
else if (cpu_is_omap24xx())
ports = 2;
else if (cpu_is_omap34xx())
ports = 3;
else if (cpu_is_omap44xx())
ports = 4;

return ports;
}

/**
* omap_i2c_bus_setup - Process command line options for the I2C bus speed
* @str: String of options
Expand All @@ -72,12 +53,11 @@ static int __init omap_i2c_nr_ports(void)
*/
static int __init omap_i2c_bus_setup(char *str)
{
int ports;
int ints[3];

ports = omap_i2c_nr_ports();
get_options(str, 3, ints);
if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports)
if (ints[0] < 2 || ints[1] < 1 ||
ints[1] > OMAP_I2C_MAX_CONTROLLERS)
return 0;
i2c_pdata[ints[1] - 1].clkrate = ints[2];
i2c_pdata[ints[1] - 1].clkrate |= OMAP_I2C_CMDLINE_SETUP;
Expand Down Expand Up @@ -122,7 +102,7 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
{
int err;

BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports());
BUG_ON(bus_id < 1 || bus_id > OMAP_I2C_MAX_CONTROLLERS);

if (info) {
err = i2c_register_board_info(bus_id, info, len);
Expand Down

0 comments on commit efeda8b

Please sign in to comment.