On Wednesday 15 July 2009, Philby John wrote:
> /*
> + * Configure the i2c data pin as a GPIO input and the i2c clock pin as a
> + * high GPIO output.
> + */
> +static void disable_i2c_pins(void)
> +{
> + unsigned long flags;
> +
> + local_irq_save(flags);
> + if (cpu_is_davinci_dm355()) {
> + gpio_direction_input(15);
> + gpio_direction_output(14, 0);
> + gpio_set_value(14, 1);
As noted: gpio_direction_output(14, 1) is better.
> + davinci_cfg_reg(DM355_I2C_SDA);
> + davinci_cfg_reg(DM355_I2C_SCL);
> + }
> + local_irq_restore(flags);
> +}
> +
> +/* Connect the i2c pins to the i2c controller. */
> +static void enable_i2c_pins(void)
> +{
> + unsigned long flags;
> +
> + local_irq_save(flags);
> + if (cpu_is_davinci_dm355()) {
> + davinci_cfg_reg(DM355_I2C_SDA);
> + davinci_cfg_reg(DM355_I2C_SCL);
> + }
> + local_irq_restore(flags);
> +}
> +
> +
> +/* Generate a pulse on the i2c clock pin. */
> +static void pulse_i2c_clock(void)
> +{
> + if (cpu_is_davinci_dm355()) {
> + gpio_set_value(14, 0);
> + udelay(20);
> + gpio_set_value(14, 1);
> + udelay(20);
> + }
> +}
> +
The general problem with how that's done is that the SoC-specific
bits should not be in this file. The mach-davinc/dm355.c file
should hold that configuration; likewise for other SoCs.
> + /* Disable i2c */
> + disable_i2c_pins();
> + for (i = 0; i < 10; i++)
> + pulse_i2c_clock();
> + /* Re-enable i2c */
> + enable_i2c_pins();
A better description of this is that you're trying to follow
the I2Cv3 instructions about how to *reset* the bus, yes?
> + i2c_davinci_init(dev);
>
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source