#include "i2c-rk30.h"
#define TX_SETUP 1
+static int i2c_max_adap = 0;
void i2c_adap_sel(struct rk30_i2c *i2c, int nr, int adap_type)
{
i2c_writel((1 << I2C_ADAP_SEL_BIT(nr)) | (1 << I2C_ADAP_SEL_MASK(nr)) ,
i2c->is_div_from_arm[i2c->adap.nr] = pdata->is_div_from_arm;
i2c->i2c_init_hw(i2c, 100 * 1000);
+ i2c_max_adap++;
dev_info(&pdev->dev, "%s: RK30 I2C adapter\n", dev_name(&i2c->adap.dev));
return 0;
//err_none:
module_init(i2c_detect_init);
module_exit(i2c_detect_exit);
+static int __init i2c_detect_rk610(void)
+{
+ int i;
+ for(i = 0; i < i2c_max_adap; i++){
+ i2c_check_rk610_ex(i);
+ }
+ return 0;
+}
+late_initcall(i2c_detect_rk610);
}
EXPORT_SYMBOL_GPL(i2c_new_device);
#ifdef CONFIG_PLAT_RK
+#define RK610_KEY "rk610"
+static int __i2c_client_print(struct device *dev, void *param)
+{
+ struct i2c_client *client = i2c_verify_client(dev);
+
+ if(client)
+ printk(KERN_WARNING "client: %s, addr: 0x%x\n", client->name, client->addr);
+ return 0;
+}
+static int __i2c_check_rk610_ex(struct device *dev, void *ex)
+{
+ struct i2c_client *client = i2c_verify_client(dev);
+
+ if(!client)
+ return 0;
+
+ if(strstr(client->name, RK610_KEY) != NULL)
+ *(int *)ex += 1 << 8;
+ else
+ *(int *)ex += 1;
+ return 0;
+}
+int i2c_check_rk610_ex(int nr)
+{
+ int ex = 0, rk610_ex = 0, oth_ex = 0;
+ struct i2c_adapter *adap = i2c_get_adapter(nr);
+
+ if(!adap){
+ printk(KERN_ERR "%s: adap(%d) is not exist\n", __func__, nr);
+ return -EINVAL;
+ }
+ device_for_each_child(&adap->dev, &ex, __i2c_check_rk610_ex);
+
+ if(ex & (1 << 8))
+ rk610_ex = 1;
+
+ oth_ex = ex & 0xff;
+
+ if(rk610_ex && oth_ex){
+ ex = 1;
+ printk(KERN_WARNING "******************* WARNING ********************\n");
+ dev_warn(&adap->dev, "%s is exist, clients:\n", RK610_KEY);
+ device_for_each_child(&adap->dev, NULL, __i2c_client_print);
+ printk(KERN_WARNING "************************************************\n");
+ }
+ else
+ ex = 0;
+ return ex;
+}
#ifdef CONFIG_I2C_RK30
int i2c_add_device(int nr, struct i2c_board_info const *info)
{
return status;
}
#else
+int i2c_check_rk610_ex(int nr)
+{
+ return 0;
+}
int i2c_add_device(int nr, struct i2c_board_info const *info)
{
return 0;
}
#endif
+EXPORT_SYMBOL_GPL(i2c_check_rk610_ex);
EXPORT_SYMBOL_GPL(i2c_add_device);
#endif
extern int i2c_master_reg16_recv(const struct i2c_client *client, const short regs, short *buf, int count, int scl_rate);
extern int i2c_suspended(struct i2c_adapter *adap);
extern int i2c_add_device(int nr, struct i2c_board_info const *info);
+extern int i2c_check_rk610_ex(int nr);
#endif
/* Transfer num messages.