Hi

Also been struggling to get Invensense driver to work....not very impressed 
with Invensense to be honest. If you login to their support forum, there is 
no mention of MPU9250 Linux kernel drivers.....I found the tegra stuff, 
emailed Invensense and asked them where they publish their code.....they 
don't.

Rather then release a unified driver for 3.4 (i2c &spi) and 3.10+ (i2c & 
spi) ....they rather efforts and struggle be duplicated by every user of 
their component....this is very advanced and progressive thinking .....the 
head of software development must be an absolute genius, no wonder their 
products are so easy to integrate.

Invense replied to my email with this link:
https://android.googlesource.com/kernel/msm/+/android-msm-hammerhead-3.4-kk-fr2/drivers/staging/iio/imu/inv_mpu/README
 

*So I'm guessing with the endless array of 2012 versions.....this is what 
they suggested....no idea 


I have yet to find an working Invensense driver that natively supports 
MPU9250 for the 3.10+ kernel....and absolutely nothing that supports Linux 
& SPI

Hoping bosch will come to the rescue and offer real linux support for this 
little guy:
http://www.bosch-sensortec.com/en/homepage/products_3/9_axis_sensors_5/ecompass_2/bmx055_1/bmx055

Invensense may have some nice components....but they're worthless without 
quality drivers. 








On Tuesday, 13 May 2014 22:10:59 UTC+1, [email protected] wrote:
>
> Hi,
>
> I have got a small project at home, running the inv-mpu6050 driver. To get 
> it to work I had to add device tree functionality to the driver and then 
> write a cape dtc for the beaglebone. As a result I have got the following 
> outputs:
>
> cat /sys/devices/bone_capemgr.8/slots
>  0: 54:PF---
>  1: 55:PF---
>  2: 56:PF---
>  3: 57:PF---
>  4: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-MPU6050
>
> lsmod
> Module                  Size  Used by
> inv_mpu6050             7868  0
> g_multi                47670  0
> libcomposite           14299  1 g_multi
> mt7601Usta            601404  0
>
> ls /sys/bus/iio/devices/iio:device0/
> buffer         in_accel_scale  in_accel_z_raw    in_anglvel_y_raw  
> in_temp_offset  name         sampling_frequency_available  trigger
> dev         in_accel_x_raw  in_anglvel_scale  in_anglvel_z_raw  
> in_temp_raw     power         scan_elements               uevent
> in_accel_matrix  in_accel_y_raw  in_anglvel_x_raw  in_gyro_matrix    
> in_temp_scale   sampling_frequency  subsystem
>
> cat /sys/bus/iio/devices/iio:device0/*raw
> -8202
> -458
> 11288
> 10
> 51
> 109
> -4967
>
> But now to the downside. It takes about100ms to read one value e.g. 
> /sys/bus/iio/devices/iio:device0/in_accel_x_raw ?!
>
> I am still working on the device tree part of the driver, as the 
> configuration should be able to deal with negative values, but my current 
> dtc does not support the unary operator yet. That is fixed in a later 
> version. I will have a look at that when I find some time. When it is 
> finished I would like to give the driver back to the community.
>
> For now my work has the current state:
> -) MPU6050 cape:
> /*
>  * Copyright (C) 2014 Thomas Graziadei
>  * 
>  * Make use of the Invensens MPU6050
>  *
>  * This program is free software; you can redistribute it and/or modify
>  * it under the terms of the GNU General Public License version 2 as
>  * published by the Free Software Foundation.
>  */
> /dts-v1/;
> /plugin/;
>
> / {
>     compatible = "ti,beaglebone", "ti,beaglebone-black";
>
>     /* identification */
>     part-number = "BB-MPU6050";
>     version = "00A0";
>
>     /* state the resources this cape uses */
>     exclusive-use =
>         /* the pin header uses */
>         "P9.18",    /* i2c1_sda */
>         "P9.17",    /* i2c1_scl */
>         /* the hardware ip uses */
>         "i2c1";
>
>     fragment@0 {
>         target = <&am33xx_pinmux>;
>         __overlay__ {
>             bb_i2c1_pins: pinmux_bb_i2c1_pins {
>                 pinctrl-single,pins = <
>                     0x158 0x72    /* spi0_d1.i2c1_sda, SLEWCTRL_SLOW | 
> INPUT_PULLUP | MODE2 */
>                     0x15c 0x72    /* spi0_cs0.i2c1_scl, SLEWCTRL_SLOW | 
> INPUT_PULLUP | MODE2 */
>                 >;
>             };
>         };
>     };
>
>     fragment@1 {
>         target = <&i2c1>;    /* i2c1 is numbered correctly */
>         __overlay__ {
>             status = "okay";
>             pinctrl-names = "default";
>             pinctrl-0 = <&bb_i2c1_pins>;
>
>             /* this is the configuration part */
>             clock-frequency = <100000>;    
>
>             #address-cells = <1>;
>             #size-cells = <0>;
>
>             /* add any i2c devices on the bus here */
>
>             mpu6050@68 {
>                 compatible = "inv,mpu6050";
>                 reg = <0x68>;
>                 orientation = <1 0 0 0 1 0 0 0 1>;
>             };
>         };
>     };
> };
>
>
> -) driver patch:
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c 
> b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 37ca05b..d101a0c 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -648,6 +648,31 @@ static int inv_check_and_setup_chip(struct 
> inv_mpu6050_state *st,
>      return 0;
>  }
>  
> +static struct inv_mpu6050_platform_data*
> +    mpu6050_parse_dt(struct device* dev)
> +{
> +    struct device_node *np = dev->of_node;
> +    struct inv_mpu6050_platform_data *pdata;
> +
> +    if (!np) {
> +        dev_err(dev, "no device tree or platform data\n");
> +        return ERR_PTR(-EINVAL);
> +    }
> +
> +    pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +    if (!pdata)
> +        return ERR_PTR(-ENOMEM);
> +
> +
> +    if (of_property_read_u8_array(np, "orientation",
> +        pdata->orientation, sizeof(pdata->orientation)) != 0) {
> +        dev_err(dev, "no valid orientation property found\n");
> +        return ERR_PTR(-EINVAL);
> +    }
> +
> +    return pdata;
> +}
> +
>  /**
>   *  inv_mpu_probe() - probe function.
>   *  @client:          i2c client.
> @@ -660,6 +685,7 @@ static int inv_mpu_probe(struct i2c_client *client,
>  {
>      struct inv_mpu6050_state *st;
>      struct iio_dev *indio_dev;
> +    struct inv_mpu6050_platform_data* pdata;
>      int result;
>  
>      if (!i2c_check_functionality(client->adapter,
> @@ -675,8 +701,21 @@ static int inv_mpu_probe(struct i2c_client *client,
>      }
>      st = iio_priv(indio_dev);
>      st->client = client;
> -    st->plat_data = *(struct inv_mpu6050_platform_data
> -                *)dev_get_platdata(&client->dev);
> +    pdata = (struct inv_mpu6050_platform_data*)
> +        dev_get_platdata(&client->dev);
> +
> +    if (pdata == NULL) {
> +        /* check of devicetree */
> +        // printk(KERN_ERR "checking device tree for parameter infos");
> +        pdata = mpu6050_parse_dt(&client->dev);
> +    }
> +
> +    if (IS_ERR(pdata)) {
> +        return PTR_ERR(pdata);
> +    }
> +
> +    st->plat_data = *pdata;
> +
>      /* power is turned on inside check chip type*/
>      result = inv_check_and_setup_chip(st, id);
>      if (result)
> @@ -777,14 +816,22 @@ static const struct i2c_device_id inv_mpu_id[] = {
>  
>  MODULE_DEVICE_TABLE(i2c, inv_mpu_id);
>  
> +static struct of_device_id inv_mpu6050_i2c_of_match[] = {
> +    { .compatible = "inv,mpu6050", },
> +    { }
> +};
> +
> +MODULE_DEVICE_TABLE(of, inv_mpu6050_i2c_of_match);
> +
>  static struct i2c_driver inv_mpu_driver = {
>      .probe        =    inv_mpu_probe,
>      .remove        =    inv_mpu_remove,
>      .id_table    =    inv_mpu_id,
>      .driver = {
> -        .owner    =    THIS_MODULE,
> -        .name    =    "inv-mpu6050",
> -        .pm     =       INV_MPU6050_PMOPS,
> +        .owner        =     THIS_MODULE,
> +        .name        =     "inv-mpu6050",
> +        .pm         =     INV_MPU6050_PMOPS,
> +        .of_match_table =     inv_mpu6050_i2c_of_match,
>      },
>  };
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to