/** * omap2_i2c_pullup - setup pull-up resistors for I2C bus * @bus_id: bus id counting from number 1 * @sda_pullup: Pull-up resistor for SDA and SCL pins * */ void omap2_i2c_pullup(int bus_id, enum omap_i2c_pullup_values pullup) { u32 val = 0; if (bus_id < 1 || bus_id > omap_i2c_nr_ports() || pullup > I2C_PULLUP_STD_NA_FAST_300_OM) { pr_err("%s:Wrong pullup (%d) or use wrong I2C port (%d)\n", __func__, pullup, bus_id); return; } val = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_I2C_0); switch (bus_id) { case 1: /* Setup PULL-UP resistor for I2C-1 */ val &= ~(OMAP4_I2C1_SDA_LOAD_BITS_MASK | OMAP4_I2C1_SCL_LOAD_BITS_MASK | OMAP4_I2C1_SDA_PULLUPRESX_MASK | OMAP4_I2C1_SCL_PULLUPRESX_MASK); val |= ((pullup << OMAP4_I2C1_SDA_LOAD_BITS_SHIFT) | (pullup << OMAP4_I2C1_SCL_LOAD_BITS_SHIFT)); break; case 2: /* Setup PULL-UP resistor for I2C-2 */ val &= ~(OMAP4_I2C2_SDA_LOAD_BITS_MASK | OMAP4_I2C2_SCL_LOAD_BITS_MASK | OMAP4_I2C2_SDA_PULLUPRESX_MASK | OMAP4_I2C2_SCL_PULLUPRESX_MASK); val |= ((pullup << OMAP4_I2C2_SDA_LOAD_BITS_SHIFT) | (pullup << OMAP4_I2C2_SCL_LOAD_BITS_SHIFT)); break; case 3: /* Setup PULL-UP resistor for I2C-3 */ val &= ~(OMAP4_I2C3_SDA_LOAD_BITS_MASK | OMAP4_I2C3_SCL_LOAD_BITS_MASK | OMAP4_I2C3_SDA_PULLUPRESX_MASK | OMAP4_I2C3_SCL_PULLUPRESX_MASK); val |= ((pullup << OMAP4_I2C3_SDA_LOAD_BITS_SHIFT) | (pullup << OMAP4_I2C3_SCL_LOAD_BITS_SHIFT)); break; case 4: /* Setup PULL-UP resistor for I2C-4 */ val &= ~(OMAP4_I2C4_SDA_LOAD_BITS_MASK | OMAP4_I2C4_SCL_LOAD_BITS_MASK | OMAP4_I2C4_SDA_PULLUPRESX_MASK | OMAP4_I2C4_SCL_PULLUPRESX_MASK); val |= ((pullup << OMAP4_I2C4_SDA_LOAD_BITS_SHIFT) | (pullup << OMAP4_I2C4_SCL_LOAD_BITS_SHIFT)); break; default: return; } omap4_ctrl_pad_writel(val, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_I2C_0); }
/** * omap_register_i2c_bus_board_data - register hwspinlock data * @bus_id: bus id counting from number 1 * @pdata: pointer to the I2C bus board data */ void omap_register_i2c_bus_board_data(int bus_id, struct omap_i2c_bus_board_data *pdata) { BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports()); if ((pdata != NULL) && (pdata->handle != NULL)) { i2c_pdata[bus_id - 1].handle = pdata->handle; i2c_pdata[bus_id - 1].hwspin_lock_timeout = pdata->hwspin_lock_timeout; i2c_pdata[bus_id - 1].hwspin_unlock = pdata->hwspin_unlock; } }
/** * omap_i2c_bus_setup - Process command line options for the I2C bus speed * @str: String of options * * This function allow to override the default I2C bus speed for given I2C * bus with a command line option. * * Format: i2c_bus=bus_id,clkrate (in kHz) * * Returns 1 on success, 0 otherwise. */ 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) return 0; i2c_pdata[ints[1] - 1].clkrate = ints[2]; i2c_pdata[ints[1] - 1].clkrate |= OMAP_I2C_CMDLINE_SETUP; return 1; }
/** * omap_register_i2c_bus - register I2C bus with device descriptors * @bus_id: bus id counting from number 1 * @clkrate: clock rate of the bus in kHz * @info: pointer into I2C device descriptor table or NULL * @len: number of descriptors in the table * * Returns 0 on success or an error code. */ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, struct i2c_board_info const *info, unsigned len) { int err; BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports()); if (info) { err = i2c_register_board_info(bus_id, info, len); if (err) return err; } if (!i2c_rate[bus_id - 1]) i2c_rate[bus_id - 1] = clkrate; i2c_rate[bus_id - 1] &= ~OMAP_I2C_CMDLINE_SETUP; return omap_i2c_add_bus(bus_id); }