};
#endif
+#ifdef CONFIG_I2C_GPIO_RK30
+#define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
+#define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
+static int rk30_i2c_io_init(void)
+{
+ //set iomux (gpio) here
+ //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
+ //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
+
+ return 0;
+}
+struct i2c_gpio_platform_data default_i2c_gpio_data = {
+ .sda_pin = I2C_SDA_PIN,
+ .scl_pin = I2C_SCL_PIN,
+ .udelay = 5, // clk = 500/udelay = 100Khz
+ .timeout = 100,//msecs_to_jiffies(100),
+ .bus_num = 5,
+ .io_init = rk30_i2c_io_init,
+};
+static struct i2c_board_info __initdata i2c_gpio_info[] = {
+};
+#endif
+
static void __init rk30_i2c_register_board_info(void)
{
#ifdef CONFIG_I2C0_RK30
#ifdef CONFIG_I2C4_RK30
i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
#endif
+#ifdef CONFIG_I2C_GPIO_RK30
+ i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
+#endif
}
//end of i2c
};
#endif
+#ifdef CONFIG_I2C_GPIO_RK30
+struct platform_device device_i2c_gpio = {
+ .name = "i2c-gpio",
+ .id = 5,
+ .dev = {
+ .platform_data = &default_i2c_gpio_data,
+ },
+};
+#endif
+
static void __init rk30_init_i2c(void)
{
#ifdef CONFIG_I2C0_RK30
#ifdef CONFIG_I2C4_RK30
platform_device_register(&device_i2c4);
#endif
+#ifdef CONFIG_I2C_GPIO_RK30
+ platform_device_register(&device_i2c_gpio);
+#endif
}
//end of i2c
#include <asm/setup.h>
#include <plat/board.h>
#include <mach/sram.h>
+#include <linux/i2c-gpio.h>
struct rk30_i2c_platform_data {
char *name;
extern struct rk29_sdmmc_platform_data default_sdmmc0_data;
extern struct rk29_sdmmc_platform_data default_sdmmc1_data;
+#ifdef CONFIG_I2C_ALGOBIT
+extern struct i2c_gpio_platform_data default_i2c_gpio_data;
+#endif
+
void __init rk30_map_common_io(void);
void __init rk30_init_irq(void);
void __init rk30_map_io(void);
bool "With RK30 I2C Controller"
endchoice
endif
+ config I2C_GPIO_RK30
+ bool "Simulation with GPIO"
+ default n
+ select I2C_GPIO
endif
config I2C_RK29
tristate "RK29 i2c interface (I2C)"
#define TX_SETUP 1 //unit us
void i2c_adap_sel(struct rk30_i2c *i2c, int nr, int adap_type)
{
- unsigned int p = readl(i2c->con_base);
-
- p = rk30_set_bit(p, adap_type, I2C_ADAP_SEL_BIT(nr));
- p = rk30_set_bit(p, adap_type, I2C_ADAP_SEL_MASK(nr));
- writel(p, i2c->con_base);
+ writel((1 << I2C_ADAP_SEL_BIT(nr)) | (1 << I2C_ADAP_SEL_MASK(nr)) ,
+ i2c->con_base);
}
#ifdef CONFIG_CPU_FREQ