Fwd: Fwd: [PATCH 1/1] SPI : spi-pxa2xx : fix spi init of WM510205 codec via ACPI (resend)
diff mbox

Message ID CAKor6TfW4reRz3m-xkCr_ZUfHQkfqT3q+S7JCpO-9F+k1QW38g@mail.gmail.com
State New
Headers show

Commit Message

Christian Hartmann Aug. 28, 2015, 9:50 a.m. UTC
Hi,

this is a resend with all recipients in cc now


---------- Forwarded message ----------
From: Christian Hartmann <cornogle@googlemail.com>
Date: 2015-08-28 9:41 GMT+02:00
Subject: Re: [alsa-devel] Fwd: [PATCH 1/1] SPI : spi-pxa2xx : fix spi
init of WM510205 codec via ACPI (resend)
To: Mark Brown <broonie@kernel.org>


hi Mark et al.,



2015-08-27 16:56 GMT+02:00 Mark Brown <broonie@kernel.org>:
> I can't see how that would work, the interrupt output isn't a GPIO.

yes I think also that this is the GPIO pin number.
I am not familiar with the interrupt handling, have again to look (in
other drivers or similar), to understand how things should work, never
done that before.

I have added three dev_info() into spi-pxa2xx pxa2xx_spi_probe() to
found out more whats wrong with the slave/master:

commit 4b6ff73610deef478e53b958a02617f024bbef22
Author: Christian Hartmann <cornogle@googlemail.com>
Date:   Thu Aug 27 14:51:48 2015 +0200

    spi/spi-pxa2xx.c : added three new dev_infos, which prints irq,
bus_num and num_chipselect

    Signed-off-by: Christian Hartmann <cornogle@googlemail.com>



 and thats what I got:

[    6.182903] pxa2xx-spi 80860F0E:00: bus_num = -1
[    6.182909] pxa2xx-spi 80860F0E:00: num_chipselect = 2
[    6.182928] pxa2xx-spi 80860F0E:00: IRQ 194
[    6.183049] pxa2xx-spi 80860F0E:00: no DMA channels available, using PIO
[    6.183111] pxa2xx-spi 80860F0E:00: registered master spi32766 (dynamic)
[    6.192761] spi spi-WM510205:00: 8333333 Hz actual, PIO
.... the rest of the dmesg is currently the same....


Q:  this thread is about the patch for the pxa2xx-spi where the
num_chipselect was raised by one to so that the slave connects here at
all. otherwise the cs1 >= max will be hit.
Do you think the bus_number is ok ?
And shouldn't it be set the cs1=0 and num_chipselect=1  ??

The DSDT has wrongly SPI=1 as chipselect,  either the firmware (DSDT)
must be updated or a correct patch enables the spi master/slave init
here.

I hope or expect that when the spi slave will be init correctly, that
the device would also work.
The ACPI stuff is already done here, and I am running out of time.

In the last resort I have to give up or have to do that at night :)

cheers
chris

Comments

Christian Hartmann Sept. 1, 2015, 9:45 a.m. UTC | #1
hi

2015-08-28 11:50 GMT+02:00 Christian Hartmann <cornogle@googlemail.com>:
>
>  and thats what I got:
>
> [    6.182903] pxa2xx-spi 80860F0E:00: bus_num = -1
> [    6.182909] pxa2xx-spi 80860F0E:00: num_chipselect = 2
> [    6.182928] pxa2xx-spi 80860F0E:00: IRQ 194
> [    6.183049] pxa2xx-spi 80860F0E:00: no DMA channels available, using PIO
> [    6.183111] pxa2xx-spi 80860F0E:00: registered master spi32766 (dynamic)
> [    6.192761] spi spi-WM510205:00: 8333333 Hz actual, PIO
> .... the rest of the dmesg is currently the same....
>
>
> Q:  this thread is about the patch for the pxa2xx-spi where the
> num_chipselect was raised by one to so that the slave connects here at
> all. otherwise the cs1 >= max will be hit.
> Do you think the bus_number is ok ?
> And shouldn't it be set the cs1=0 and num_chipselect=1  ??

What is with the bus_num ? where can I find the correct one ?
I have no working example, is it possible to find the right settings
only via a windows installation??

cheers
chris
Charles Keepax Sept. 2, 2015, 8:13 a.m. UTC | #2
On Tue, Sep 01, 2015 at 11:45:31AM +0200, Christian Hartmann wrote:
> hi
> 
> 2015-08-28 11:50 GMT+02:00 Christian Hartmann <cornogle@googlemail.com>:
> >
> >  and thats what I got:
> >
> > [    6.182903] pxa2xx-spi 80860F0E:00: bus_num = -1
> > [    6.182909] pxa2xx-spi 80860F0E:00: num_chipselect = 2
> > [    6.182928] pxa2xx-spi 80860F0E:00: IRQ 194
> > [    6.183049] pxa2xx-spi 80860F0E:00: no DMA channels available, using PIO
> > [    6.183111] pxa2xx-spi 80860F0E:00: registered master spi32766 (dynamic)
> > [    6.192761] spi spi-WM510205:00: 8333333 Hz actual, PIO
> > .... the rest of the dmesg is currently the same....
> >
> >
> > Q:  this thread is about the patch for the pxa2xx-spi where the
> > num_chipselect was raised by one to so that the slave connects here at
> > all. otherwise the cs1 >= max will be hit.
> > Do you think the bus_number is ok ?
> > And shouldn't it be set the cs1=0 and num_chipselect=1  ??
> 
> What is with the bus_num ? where can I find the correct one ?
> I have no working example, is it possible to find the right settings
> only via a windows installation??

I am not sure the problem would be the bus number it is basically
just a number allocated in the kernel, it should really matter as
long as it represents the right device. Which as far as we can
see here looks likely.

The chip select being wrong could well be the issue, perhaps the
Windows driver supports multiple chipselects where as the Linux
one doesn't? Do you have access to any datasheets for the SPI on
the AP? Alternatively you could try hacking it to use chip select
0 and see if that makes the system work, seems like a long shot
but perhaps worth a quick go.

Thanks,
Charles
Christian Hartmann Sept. 4, 2015, 1:32 p.m. UTC | #3
Hi,


2015-09-02 10:13 GMT+02:00 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>:
> On Tue, Sep 01, 2015 at 11:45:31AM +0200, Christian Hartmann wrote:
>> hi
>>
>> 2015-08-28 11:50 GMT+02:00 Christian Hartmann <cornogle@googlemail.com>:
>> >
>> >  and thats what I got:
>> >
>> > [    6.182903] pxa2xx-spi 80860F0E:00: bus_num = -1
>> > [    6.182909] pxa2xx-spi 80860F0E:00: num_chipselect = 2
>> > [    6.182928] pxa2xx-spi 80860F0E:00: IRQ 194
>> > [    6.183049] pxa2xx-spi 80860F0E:00: no DMA channels available, using PIO
>> > [    6.183111] pxa2xx-spi 80860F0E:00: registered master spi32766 (dynamic)
>> > [    6.192761] spi spi-WM510205:00: 8333333 Hz actual, PIO
>> > .... the rest of the dmesg is currently the same....

> The chip select being wrong could well be the issue, perhaps the
> Windows driver supports multiple chipselects where as the Linux
> one doesn't? Do you have access to any datasheets for the SPI on
> the AP? Alternatively you could try hacking it to use chip select
> 0 and see if that makes the system work, seems like a long shot
> but perhaps worth a quick go.
>
> Thanks,
> Charles

ok, that was a one-shot, in effect nothing changed .
I did set the num_chipsselect = 1 (as in vanilla kernels, so its more
a revert) and
changed the cs value from 1 to 0 (as a testpatch).
as soon as the SPI device WM510205:00 is allocated,
it tries to add the acpi_resource and in the case of the wrong SPI
chip_select with the value 1 from the DSDT ACPI table entry, but here
I set it again to 0.

expected : chip id register can be read, but
nothing changed. the logs are the same in the end.
I saw also that acpi_add_resource tries to add an irq (init with -1), but fails

[    5.966307] acpi INT33FD:00: GPIO: looking up 0 in _CRS
[    5.966806] intel_soc_pmic_i2c i2c-INT33FD:00: using lookup tables
for GPIO lookup
[    5.966814] intel_soc_pmic_i2c i2c-INT33FD:00: lookup for GPIO
intel_soc_pmic failed
[    5.975702] sst-acpi 80860F28:00: No matching ASoC machine driver found
[    5.986039] pxa2xx-spi 80860F0E:00: bus_num = -1
[    5.986047] pxa2xx-spi 80860F0E:00: num_chipselect = 1
[    5.986076] pxa2xx-spi 80860F0E:00: IRQ 194
[    5.986368] pxa2xx-spi 80860F0E:00: no DMA channels available, using PIO
[    5.987011] pxa2xx-spi 80860F0E:00: registered master spi32766 (dynamic)
[    5.987123] spi_master spi32766: allocated SPI device for WM510205:00
[    5.987172] spi (null): acpi_spi_add_resource : chip_select = 1
[    5.987177] spi (null): acpi_spi_add_resource : new chip_select = 0
[    5.987182] spi (null): acpi_spi_add_resource : irq = -1
[    5.987186] spi (null): acpi_spi_add_resource : irq < 0,
acpi_dev_resource_interrupt
[    5.987189] spi (null): acpi_spi_add_resource : irq = -1
[    5.987193] spi (null): acpi_spi_add_resource : irq < 0,
acpi_dev_resource_interrupt
[    5.987197] spi (null): acpi_spi_add_resource : irq = -1
[    5.987201] spi (null): acpi_spi_add_resource : irq < 0,
acpi_dev_resource_interrupt
[    5.987204] spi (null): acpi_spi_add_resource : irq = -1
[    5.987208] spi (null): acpi_spi_add_resource : irq < 0,
acpi_dev_resource_interrupt
[    5.987212] spi (null): acpi_spi_add_resource : irq = -1
[    5.987217] pxa2xx-spi 80860F0E:00: cs0 < max 1
[    5.987243] spi spi-WM510205:00: 8333333 Hz actual, PIO
[    5.987249] spi spi-WM510205:00: setup mode 0, 8 bits/w, 8000000 Hz max --> 0
[    5.991261] spi spi-WM510205:00: checking WM510205 with bmp180
[    5.991271] spi spi-WM510205:00: checking WM510205 with bmp181
[    5.991276] spi spi-WM510205:00: modalias WM510205 in id_table not
found, returns NULL
[    5.991310] arizona spi-WM510205:00: arizona_acpi_get_type(), than
via spi_get_device_id().
[    5.991316] arizona spi-WM510205:00: arizona_acpi_get_type matched
[    5.991323] acpi WM510205:00: GPIO: looking up 0 in _CRS
[    5.991401] arizona spi-WM510205:00: using 1 as type for arizona audio codec
[    5.991406] arizona spi-WM510205:00: regmap set to wm5102_spi
[    5.991980] arizona spi-WM510205:00: acpi_dev_add_driver_gpios
arizona_acpi_gpios added done, 0
[    5.991986] arizona spi-WM510205:00: spi_irq = 146
[    5.991990] arizona spi-WM510205:00: arizona_spi_probe done,
calling arizona_dev_init
[    5.991994] arizona spi-WM510205:00: dev_set_drvdata done for 1
[    5.991999] arizona spi-WM510205:00: arizona_of_get_core_pdata for 1
[    5.992004] arizona spi-WM510205:00: regcache_cache_only for 1 set
[    5.992008] arizona spi-WM510205:00: added wm5102_core_supplies for 1
[    5.994493] arizona spi-WM510205:00: mfd_add_devices done for 1
[    5.994505] spi-WM510205:00 supply AVDD not found, using dummy regulator
[    5.994553] spi-WM510205:00 supply DBVDD1 not found, using dummy regulator
[    6.007337] arizona spi-WM510205:00: devm_regulator_bulk_get done for 1
[    6.007348] LDO1: supplied by regulator-dummy
[    6.007419] arizona spi-WM510205:00: regulator_get done for 1
[    6.007427] acpi WM510205:00: GPIO: looking up 0 in _CRS
[    6.007517] arizona spi-WM510205:00: (ACPI) using irq_gpio GPIO = 146
[    6.007534] arizona spi-WM510205:00: devm_gpio_request_one done for
request reset: 0
[    6.007541] arizona spi-WM510205:00: regulator_bulk_enable done,
enable core supplies: 0
[    6.010032] arizona spi-WM510205:00: regulator_enable done, enable DCVDD: 0
[    6.017864] arizona spi-WM510205:00: arizona_disabe_reset
[    6.017875] arizona spi-WM510205:00: regcache_cache_only
[    6.019067] arizona spi-WM510205:00: regmap_read : read ID
register, return value: 0
[    6.019077] arizona spi-WM510205:00: found device ID: ffff


I asked to get more technical docs / datasheets from lenovo , but I do
not think, that I will get them.

Has anybody directions and hints / some tools known to get started
with win8.1 to get such hardware details extracted? I mean, it must
work under windows, why to not look there and write down / dump whats
needed.

Any hints or suggestions for me ?
Charles Keepax Sept. 4, 2015, 2:34 p.m. UTC | #4
On Fri, Sep 04, 2015 at 03:32:03PM +0200, Christian Hartmann wrote:
> Hi,
> 
> 
> 2015-09-02 10:13 GMT+02:00 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>:
> > On Tue, Sep 01, 2015 at 11:45:31AM +0200, Christian Hartmann wrote:
> >> hi
> >>
> >> 2015-08-28 11:50 GMT+02:00 Christian Hartmann <cornogle@googlemail.com>:
> >> >
> > The chip select being wrong could well be the issue, perhaps the
> > Windows driver supports multiple chipselects where as the Linux
> > one doesn't? Do you have access to any datasheets for the SPI on
> > the AP? Alternatively you could try hacking it to use chip select
> > 0 and see if that makes the system work, seems like a long shot
> > but perhaps worth a quick go.
> >
> > Thanks,
> > Charles
> 
> ok, that was a one-shot, in effect nothing changed .
> I did set the num_chipsselect = 1 (as in vanilla kernels, so its more
> a revert) and
> changed the cs value from 1 to 0 (as a testpatch).
> as soon as the SPI device WM510205:00 is allocated,
> it tries to add the acpi_resource and in the case of the wrong SPI
> chip_select with the value 1 from the DSDT ACPI table entry, but here
> I set it again to 0.
> 
> expected : chip id register can be read, but
> nothing changed. the logs are the same in the end.
> I saw also that acpi_add_resource tries to add an irq (init with -1), but fails

Not entirely unexpected I guess, but certainly my gut feel here
is that this is a problem with the chip selects. I guess really
trying to find any available documentation on the AP/SPI and
tearing apart the SPI driver are the next steps from here. But
afraid I don't really have any great ideas for diving much
deeper. I will try to chase the Windows guys here again and see
if I can gain any clues from them but I don't really know at what
level these things are abstracted in Windows and thus if they can
really help us much.

Thanks,
Charles
Christian Hartmann Sept. 7, 2015, 7:58 a.m. UTC | #5
Hello,

2015-09-04 16:34 GMT+02:00 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>:
> Not entirely unexpected I guess, but certainly my gut feel here
> is that this is a problem with the chip selects. I guess really
> trying to find any available documentation on the AP/SPI and
what do you mean with AP ?

I have googled and found some technical datasheets and
developer documentation about the marvell pxa27 under this link/webpage
http://www.marvell.com/application-processors/pxa-family/

I also asked lenovo about datasheets (not the short brief productsheet) to get
facts about it. But again,  I do not think that lenovo will ever
support me in this case.
if I got some datasheets and if its not against laws etc I will report it here.

> tearing apart the SPI driver are the next steps from here. But
> afraid I don't really have any great ideas for diving much
> deeper. I will try to chase the Windows guys here again and see
That would be nice, hope they got some glues.

> if I can gain any clues from them but I don't really know at what
> level these things are abstracted in Windows and thus if they can
> really help us much.
>
> Thanks,
> Charles

Thanks,
Chris
Charles Keepax Sept. 28, 2015, 9:08 a.m. UTC | #6
On Mon, Sep 07, 2015 at 09:58:22AM +0200, Christian Hartmann wrote:
> Hello,
> 
> 2015-09-04 16:34 GMT+02:00 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>:
> > Not entirely unexpected I guess, but certainly my gut feel here
> > is that this is a problem with the chip selects. I guess really
> > trying to find any available documentation on the AP/SPI and
> what do you mean with AP ?
> 
> I have googled and found some technical datasheets and
> developer documentation about the marvell pxa27 under this link/webpage
> http://www.marvell.com/application-processors/pxa-family/
> 
> I also asked lenovo about datasheets (not the short brief productsheet) to get
> facts about it. But again,  I do not think that lenovo will ever
> support me in this case.
> if I got some datasheets and if its not against laws etc I will report it here.
> 
> > tearing apart the SPI driver are the next steps from here. But
> > afraid I don't really have any great ideas for diving much
> > deeper. I will try to chase the Windows guys here again and see
> That would be nice, hope they got some glues.
> 
> > if I can gain any clues from them but I don't really know at what
> > level these things are abstracted in Windows and thus if they can
> > really help us much.

Ok no major hints from them, they do have a 10 inch version of
the same tablet lying around though so I will get them to post
that up and have a look see if I can figure anything out.

If you had anywhere I can pull in what you have done already that
would be handy.

Thanks,
Charles
Christian Hartmann Sept. 29, 2015, 7:48 a.m. UTC | #7
Hi,


> Ok no major hints from them, they do have a 10 inch version of
> the same tablet lying around though so I will get them to post
> that up and have a look see if I can figure anything out.
>
nice to hear, I am stuck at reading the chip registers ID value
correctly at the moment.

> If you had anywhere I can pull in what you have done already that
> would be handy.
I have no such public or secure repo setup yet, time to do that.
in that case with the wm510205 branched from torvalds/master, what do
you prefer or
is it okay, if I make an repo on github for it ??
Another options are available too, I can also make them as a patch
series (in email format)
and send them to this group or to you.

Let me know whats the best way for all of us
cheers
chris
Charles Keepax Sept. 29, 2015, 7:57 a.m. UTC | #8
On Tue, Sep 29, 2015 at 09:48:45AM +0200, Christian Hartmann wrote:
> Hi,
> 
> 
> > Ok no major hints from them, they do have a 10 inch version of
> > the same tablet lying around though so I will get them to post
> > that up and have a look see if I can figure anything out.
> >
> nice to hear, I am stuck at reading the chip registers ID value
> correctly at the moment.
> 
> > If you had anywhere I can pull in what you have done already that
> > would be handy.
> I have no such public or secure repo setup yet, time to do that.
> in that case with the wm510205 branched from torvalds/master, what do
> you prefer or
> is it okay, if I make an repo on github for it ??

Yeah branched of Linus's tree is probably best and shoving it on
github works for me.

Thanks,
Charles
Christian Hartmann Oct. 5, 2015, 10:54 a.m. UTC | #9
> Yeah branched of Linus's tree is probably best and shoving it on
> github works for me.
>
> Thanks,
> Charles

wow, I had already a github account for some years, but not used it yet.

I just forked torvalds/linux now and I have to re-apply my patches
into the github workflow.

Anyway, I give you the url, where you can find the patches I made.
I will update the repository today.

I actually clone the linux repo. In the next steps I create a yoga851f
branch , will apply the patches
and will push them soon back to github.

The URL will be:
https://github.com/cornbob/linux

Overview under:
https://github.com/cornbob


cheers
chris

Patch
diff mbox

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 6d795a5..cf02094 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1389,6 +1389,9 @@  static int pxa2xx_spi_probe(struct platform_device *pdev)
        master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer;
        master->auto_runtime_pm = true;

+       dev_info(&pdev->dev, "bus_num = %d\n",master->bus_num);
+       dev_info(&pdev->dev, "num_chipselect = %d\n",master->num_chipselect);
+
        drv_data->ssp_type = ssp->type;
        drv_data->null_dma_buf = (u32 *)PTR_ALIGN(&drv_data[1], DMA_ALIGNMENT);

@@ -1423,6 +1426,8 @@  static int pxa2xx_spi_probe(struct platform_device *pdev)

        }

+       dev_info(&pdev->dev, "IRQ %d\n", ssp->irq);
+
        /* Setup DMA if requested */
        drv_data->tx_channel = -1;
        drv_data->rx_channel = -1;