为MPC6050编写驱动程序i2c

我是C新手,我尝试写一个MPC6050加速计的驱动程序。 (Android 4.2.2的内核3.4)。 这是这个问题的下列。

这个页面和这个帮助我,但我不能使用驱动程序呢:

arch/arm/mach-sun7i/core.c:77:44: warning: 'sun7i_i2c_platform_data' defined but not used [-Wunused-variable] arch/arm/mach-sun7i/core.c:136:41: warning: 'sun7i_i2c_platform_device' defined but not used [-Wunused-variable] 

我正在处理/ANDROID/lichee/linux-3.4/arch/arm/mach-sun7i/core.c文件。 (相当于board-machine.c)

我粘贴了每个结构基础的结构。 初始化函数是,我希望确定,像这样:

 /* ACCELEROMETER*/ #include <linux/i2c-gpio.h> #include <linux/mpu.h> #include <linux/i2c.h> #include <mach/i2c.h> #include <mach/gpio.h> #define I2C_SDA TWI_LCR_SDA_EN #define I2C_SCL TWI_LCR_SCL_EN /* * /////////// from linux/i2c-gpio.h ////////// * struct i2c_gpio_platform_data { unsigned int sda_pin; unsigned int scl_pin; int udelay; int timeout; unsigned int sda_is_open_drain:1; unsigned int scl_is_open_drain:1; unsigned int scl_is_output_only:1; }; */ static struct i2c_gpio_platform_data sun7i_i2c_platform_data = { .sda_pin = I2C_SDA, // gpio number .scl_pin = I2C_SCL, .udelay = 5, // 100KHz .sda_is_open_drain = 0, .scl_is_open_drain = 0, .scl_is_output_only = 0 }; /* * /////////// from linux/mpu.h ////////// * struct mpu_platform_data { __u8 int_config; __u8 level_shifter; __s8 orientation[9]; enum secondary_slave_type sec_slave_type; enum ext_slave_id sec_slave_id; __u16 secondary_i2c_addr; __s8 secondary_orientation[9]; __u8 key[16]; enum secondary_slave_type aux_slave_type; enum ext_slave_id aux_slave_id; __u16 aux_i2c_addr; int (*power_on)(struct mpu_platform_data *); int (*power_off)(struct mpu_platform_data *); struct regulator *vdd_ana; struct regulator *vdd_i2c; }; */ static struct mpu_platform_data gyro_platform_data = { .int_config = 0x00, .level_shifter = 0, .orientation = { -1, 0, 0, 0, 1, 0, 0, 0, -1 }, .sec_slave_type = SECONDARY_SLAVE_TYPE_COMPASS, .sec_slave_id = COMPASS_ID_AK8972, .secondary_i2c_addr = 0x0E }; /* * /////////// from i2c.h ////////// * * struct i2c_board_info { char type[I2C_NAME_SIZE]; unsigned short flags; unsigned short addr; void *platform_data; struct dev_archdata *archdata; struct device_node *of_node; int irq; };*/ //for MPU6050 #define IRQ_GPIO SUN7I_IRQ_TWI0 #define TWI_STAT_REG (0x10) /* 28 interrupt types + 0xF8 normal type = 29 */ static struct i2c_board_info __initdata sun7i_i2c_platform_device[] = { { I2C_BOARD_INFO("mpu6050", 0x68), .irq = (IRQ_GPIO + TWI_STAT_REG), .platform_data = &gyro_platform_data, }, }; /* // ORIGINAL FROM THE README PAGE // static struct i2c_board_info __initdata single_chip_board_info[] = { { I2C_BOARD_INFO("mpu6050", 0x68), // can be 0x34 .irq = (IH_GPIO_BASE + MPUIRQ_GPIO), .platform_data = &gyro_platform_data, }, }; */ 

现在,我的问题是使用和激活这些function。 我不明白这是什么意思:

 static int __init omap4_panda_i2c_init(void) { omap_register_i2c_bus(4, 400, single_chip_board_info, ARRAY_SIZE(single_chip_board_info)); } 

我无法在我的文件夹中find相当于register_i2c_bus

在文件末尾,我会这样称呼它:

  static void __init sun7i_init(void) { pr_info("%s: enter\n", __func__); sw_pdev_init(); /* Register platform devices here!! */ + &sun7i_i2c_init(); + pr_info("sun7i_i2c_init\n"); } 

所以,我的问题是:如何使活动我的init函数,因为omap是一个非常不同的系统比较sun7i?

任何帮助应该是非常appeciate! 非常感谢。

编辑:有了这个文档编译不会失败。 新的dmesg是:

 <3>[ 11.963914] inv-mpu-iio 1-0068: Unable to read axis_map_x <3>[ 11.969998] i2c i2c-1: inv_mpu_probe failed -38 <4>[ 11.975080] inv-mpu-iio: probe of 1-0068 failed with error -5 <7>[ 11.975436] i2c-core: driver [inv-mpu-iio] registered 

Solutions Collecting From Web of "为MPC6050编写驱动程序i2c"