Re: [PATCH] lis3lv02d: add axes knowledge of HP Pavilion dv5 models

Éric Piel
2009-02-10T23:17:38Z

Giuseppe Bilotta schreef:
> On Tue, Feb 10, 2009 at 10:39 PM, Giuseppe Bilotta
> <giuseppe.bilotta@gmail.com> wrote:
>> On Tue, Feb 10, 2009 at 11:10 AM, Pavel Machek <pavel@suse.cz> wrote:
>>> Yeah, that patch. Not sure what to do next... you could grab lis3
>>> manual and see if you can setup chip by hand to get better results...
>> As Eric pointed out, it looks definitely like an endianness problem,
>> although there are a few strange things which are happening at the
>> same time. Is the lis3 manual available online somewhere, or can I
>> request it to the mfgr?
>
> 'k, found it on the STMicroelectronics website. Reading the doc about
> LIS3LV02DL I see that WHO_AM_I should return 3Ah, but my sensor
> returns 3Bh. I'll see if I find the correct datasheet for this one
> instead, it might have info about the differences.
Yeah, we accept also 3Bh for the who_am_i (see in hp_accel.c). The
reporter who had a laptop with such chip never reported any problem and
I didn't pay attention enough to notice those chips have only 8bits
precision.

> One thing that I noticed is that (modulo axis inversion) I'm able to
> use the sensor correctly if I set the thing to only use the high byte,
> totally discarding the lower byte:
> return *((s8*)(&hi));
> Maybe this sensor needs a different setup to return 12 instead of 8
> bits of information.
So you probably have a lis202dl (which has only two axes of 8bits each)
or a LIS302DL (3 axes of 8 bits):
http://www.st.com/stonline/products/literature/ds/13624/lis202dl.htm
http://www.st.com/stonline/products/literature/ds/12726/lis302dl.htm

Unfortunately, the WHO_AM_I register returns 3Bh in both cases. I'd tend
to imagine it's a three axes chip, but you can confirm that by just
checking if Z has any meaningful value. You can then modify
lis3lv02d_read_16() to only return the byte as low byte and the high
byte as FFh if the high bit of the value is set (because I guess they
are signed integers). You also have to change MDPS_MAX_VAL to 128, to
get things completely right.

Once we have this sorted, we should add a flag to know if the current
device is 8 bits or 12 bits, depending on the value of who_am_i. This
would allow the driver to work fine with both type of chip.

Eric