android - Writing a driver i2c for MPC6050 -


i'm new in c, , try write driver mpc6050 accelerometer. (kernel 3.4 android 4.2.2). following of question.

this page , one helped me, can't use driver yet:

arch/arm/mach-sun7i/core.c:77:44: warning: ‘sun7i_i2c_platform_data’ defined not used [-wunused-variable] arch/arm/mach-sun7i/core.c:136:41: warning: ‘sun7i_i2c_platform_device’ defined not used [-wunused-variable] 

i'm working on /android/lichee/linux-3.4/arch/arm/mach-sun7i/core.c file. (the equivalent of board-machine.c)

i have pasted struct of each structure base. init functions are, hope ok, this:

/* 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   /*  *  /////////// 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 };  /*  *  /////////// 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 };  /*  *  /////////// 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 readme page // static struct i2c_board_info __initdata single_chip_board_info[] = {     {         i2c_board_info("mpu6050", 0x68),  // can 0x34         .irq = (ih_gpio_base + mpuirq_gpio),         .platform_data = &gyro_platform_data,     }, }; */ 

now, problem use , make active theses functions. don't understand means this:

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

i can't find register_i2c_bus equivalent in folders.

and @ end of file, call this:

    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");     } 

so, question is: how make active init functions, because omap different system comparate sun7i ?

any should appeciate! lot.

edit: documentation compilation don't fail. new dmesg is:

<3>[   11.963914] inv-mpu-iio 1-0068: unable 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 error -5 <7>[   11.975436] i2c-core: driver [inv-mpu-iio] registered 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -