mbox

[V2,3/5] usb: gadget: pxa25x_udc: prepare/unprepare clocks in pxa-ssp

Message ID CALT56yO8tktrXo0rfRd91AtXBE4F5vYfYjm9AL+7dcoam6Oq9Q@mail.gmail.com
State New
Headers show

Pull-request

git://git.infradead.org/users/dbaryshkov/zaurus.git lubbock

Message

Dmitry Baryshkov Nov. 17, 2014, 11:50 p.m. UTC
2014-11-17 23:05 GMT+03:00 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>:
> 2014-11-17 21:44 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>> Guess what, Russell's remark on i2c and serial made me cross-check.  And there
>> is a case where this will be called in irq context too ...
>>
>> See :
>> -> do_IRQ
>>   -> lubbock_vbus_irq()
>>     -> pxa25x_udc_vbus_session()
>>       -> pullup()
>>         -> clk_prepare_enable()
>>           -> CRACK
>>
>> Note that your patch is not really the faulty one, I think a threaded irq
>> instead of the "raw" irq should do the trick. And it is granted on UDC api that
>> vbus function is called in a "sleeping" context (Felipe correct me if I'm
>> wrong), so a patch to fix this before your current code would be fine.
>
> OK, I will take a look. It seems the correct way would be to strip this code
> away to a phy, like gpio-vbus or nop phys. Do you have access to lubbock
> (or maybe Daniel, Haojian or Russell has?)?

I have sketched a compile-tested only PHY for the Lubbock platform. Could you
please take a look and test.
The following changes since commit fc14f9c1272f62c3e8d01300f52467c0d9af50f9:

  Linux 3.18-rc5 (2014-11-16 16:36:20 -0800)

are available in the git repository at:

  git://git.infradead.org/users/dbaryshkov/zaurus.git lubbock

for you to fetch changes up to 67d7e1e57af0a42d86476cd2e73fd154b590d3f8:

  usb: gadget: drop lubbock-specific code from pxa25x_udc (2014-11-18
02:43:03 +0300)

----------------------------------------------------------------
Dmitry Eremin-Solenikov (3):
      ARM: pxa: lubbock: add declaration of vbus tranceiver
      usb: phy: add lubbock phy driver
      usb: gadget: drop lubbock-specific code from pxa25x_udc

 arch/arm/mach-pxa/lubbock.c         |   6 +++
 drivers/usb/gadget/udc/pxa25x_udc.c |  61 -----------------------
 drivers/usb/phy/Kconfig             |  10 ++++
 drivers/usb/phy/Makefile            |   1 +
 drivers/usb/phy/phy-lubbock.c       | 225
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 242 insertions(+), 61 deletions(-)
 create mode 100644 drivers/usb/phy/phy-lubbock.c

Comments

Robert Jarzmik Nov. 19, 2014, 8:29 p.m. UTC | #1
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:

> I have sketched a compile-tested only PHY for the Lubbock platform. Could you
> please take a look and test.
>   git://git.infradead.org/users/dbaryshkov/zaurus.git lubbock

Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
don't care about telephone posts", I'll fetch your changes and make a
test. Let's say I schedule this for saturday.

Cheers.

--
Robert
Dmitry Baryshkov Nov. 19, 2014, 9:11 p.m. UTC | #2
2014-11-19 23:29 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
> Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:
>
>> I have sketched a compile-tested only PHY for the Lubbock platform. Could you
>> please take a look and test.
>>   git://git.infradead.org/users/dbaryshkov/zaurus.git lubbock
>
> Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
> don't care about telephone posts", I'll fetch your changes and make a
> test. Let's say I schedule this for saturday.

Fine with me, thank you.
Robert Jarzmik Nov. 22, 2014, 1:56 p.m. UTC | #3
Robert Jarzmik <robert.jarzmik@free.fr> writes:
> Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
> don't care about telephone posts", I'll fetch your changes and make a
> test. Let's say I schedule this for saturday.

Removed people from the list for the tests aspect.

Well, my lubbock board seem to raise several interrupts in the linux kernel, all
the LUBBOCK_IRQ interrupts multiplexed on GPIO0 actually, amongst which are the
2 interrupts for the UDC.

That will mean delay I'm afraid, as I have to find out what happens. I'm pretty
sure the hardware is OK, because the "blob" loader uses the ethernet card which
is amongst the LUBBOCK_IRQs.

There is probably a regression in the kernel not seen for several revisions, and
I have to fix it before I can test.

Cheers.
Dmitry Baryshkov Nov. 22, 2014, 3:44 p.m. UTC | #4
2014-11-22 16:56 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
> Robert Jarzmik <robert.jarzmik@free.fr> writes:
>> Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
>> don't care about telephone posts", I'll fetch your changes and make a
>> test. Let's say I schedule this for saturday.
>
> Removed people from the list for the tests aspect.
>
> Well, my lubbock board seem to raise several interrupts in the linux kernel, all
> the LUBBOCK_IRQ interrupts multiplexed on GPIO0 actually, amongst which are the
> 2 interrupts for the UDC.

This looks normal - GPIO0 is connected to an interrupt pin of the CPLD.
lubbock_init_irq function should be setting up a chained handler for the GPIO0.
And that chained handler (lubbock_irq_handler) should further decode which
IRQ bit is set. Do you see the handler being called? Can you print the (pending)
variable in the handler?
Robert Jarzmik Nov. 22, 2014, 5:18 p.m. UTC | #5
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:

> 2014-11-22 16:56 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>> Robert Jarzmik <robert.jarzmik@free.fr> writes:
>>> Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
>>> don't care about telephone posts", I'll fetch your changes and make a
>>> test. Let's say I schedule this for saturday.
>>
>> Removed people from the list for the tests aspect.
>>
>> Well, my lubbock board seem to raise several interrupts in the linux kernel, all
>> the LUBBOCK_IRQ interrupts multiplexed on GPIO0 actually, amongst which are the
>> 2 interrupts for the UDC.
Arg, what I meant to write was "seem to *never* raise several interrupts".

> This looks normal - GPIO0 is connected to an interrupt pin of the CPLD.
> lubbock_init_irq function should be setting up a chained handler for the GPIO0.
> And that chained handler (lubbock_irq_handler) should further decode which
> IRQ bit is set. Do you see the handler being called? Can you print the (pending)
> variable in the handler?
lubbock_irq_handler() is never called.
pxa_gpio_demux_handler() is never called.
  => this is the one worrying me most.

And as the lubbock_irq_handler() is never called there is not point in printing
that yet, first should be finding out why on earth the gpio demux is not getting
called.

Cheers.
Dmitry Baryshkov Nov. 22, 2014, 5:48 p.m. UTC | #6
Hello,

2014-11-22 20:18 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
> Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:
>
>> 2014-11-22 16:56 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>>> Robert Jarzmik <robert.jarzmik@free.fr> writes:
>>>> Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
>>>> don't care about telephone posts", I'll fetch your changes and make a
>>>> test. Let's say I schedule this for saturday.
>>>
>>> Removed people from the list for the tests aspect.
>>>
>>> Well, my lubbock board seem to raise several interrupts in the linux kernel, all
>>> the LUBBOCK_IRQ interrupts multiplexed on GPIO0 actually, amongst which are the
>>> 2 interrupts for the UDC.
> Arg, what I meant to write was "seem to *never* raise several interrupts".

Understood. Just to make me sure - does the upstream kernel work?
Robert Jarzmik Nov. 22, 2014, 5:49 p.m. UTC | #7
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:

> Hello,
>
> 2014-11-22 20:18 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>> Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:
>>
>>> 2014-11-22 16:56 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>>>> Robert Jarzmik <robert.jarzmik@free.fr> writes:
>>>>> Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
>>>>> don't care about telephone posts", I'll fetch your changes and make a
>>>>> test. Let's say I schedule this for saturday.
>>>>
>>>> Removed people from the list for the tests aspect.
>>>>
>>>> Well, my lubbock board seem to raise several interrupts in the linux kernel, all
>>>> the LUBBOCK_IRQ interrupts multiplexed on GPIO0 actually, amongst which are the
>>>> 2 interrupts for the UDC.
>> Arg, what I meant to write was "seem to *never* raise several interrupts".
>
> Understood. Just to make me sure - does the upstream kernel work?
Nope, that's the current situation with the upstream kernel.

Cheers.
Dmitry Baryshkov Nov. 22, 2014, 5:51 p.m. UTC | #8
2014-11-22 20:49 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
> Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:
>
>> Hello,
>>
>> 2014-11-22 20:18 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>>> Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:
>>>
>>>> 2014-11-22 16:56 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>>>>> Robert Jarzmik <robert.jarzmik@free.fr> writes:
>>>>>> Okay, now my ADSL line is repaired, thank you Mr farmer "I drive a tractor but I
>>>>>> don't care about telephone posts", I'll fetch your changes and make a
>>>>>> test. Let's say I schedule this for saturday.
>>>>>
>>>>> Removed people from the list for the tests aspect.
>>>>>
>>>>> Well, my lubbock board seem to raise several interrupts in the linux kernel, all
>>>>> the LUBBOCK_IRQ interrupts multiplexed on GPIO0 actually, amongst which are the
>>>>> 2 interrupts for the UDC.
>>> Arg, what I meant to write was "seem to *never* raise several interrupts".
>>
>> Understood. Just to make me sure - does the upstream kernel work?
> Nope, that's the current situation with the upstream kernel.

Next point would be (from my POV) to make sure that
lubbock_unmask_irq() is called
and works as expected.
Robert Jarzmik Nov. 24, 2014, 7:53 a.m. UTC | #9
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:

> 2014-11-22 20:49 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
> Next point would be (from my POV) to make sure that
> lubbock_unmask_irq() is called
> and works as expected.

Actually the problem is probably within the CPLD.
Irrespective of the CPLD register LUB_IRQ_MASK_EN, the GPIO0 is always low,
indicating an interrupt all the time.

The only thing that changes that is the switch SW13, which forces GPIO0 to high,
but prevents interrupts.

Normally, GPIO0 = (SW13 | ! (LUB_IRQ_MASK_EN && LUB_IRQ_SET_CLR))

This is why I don't have any interrupt, next stage will be to verify U46 and U54
on the IO board for GPIO_INT# and USB_INT# signals ...

Cheers.
Robert Jarzmik Nov. 26, 2014, 10:12 p.m. UTC | #10
OK Dmitry, I pulled through, the interrupts are working back.

Actually one of the blockers I have is in pxa25x_udc, and it is also in your
phy-lubbock.c. The bottom of the error is that disable_irq() is called from
within a irq handler, and it deadlocks. A disable_irq_nosync() should be used
...

... but a better approach would be to use a threaded irq for vbus handling. I
think that way disable_irq() can be used, no workqueue is needed anymore in
phy-lubbock.

Would you make that change, I'll test it and review it.

Cheers.

--
Robert
Dmitry Baryshkov Nov. 26, 2014, 10:19 p.m. UTC | #11
2014-11-27 1:12 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
> OK Dmitry, I pulled through, the interrupts are working back.

What was the problem? Hardware issues? Firmware in CPLD being of old
revision?

> Actually one of the blockers I have is in pxa25x_udc, and it is also in your
> phy-lubbock.c. The bottom of the error is that disable_irq() is called from
> within a irq handler, and it deadlocks. A disable_irq_nosync() should be used
> ...
>
> ... but a better approach would be to use a threaded irq for vbus handling. I
> think that way disable_irq() can be used, no workqueue is needed anymore in
> phy-lubbock.
>
> Would you make that change, I'll test it and review it.

OK, I will take a look in a next few days.

BTW: I have also received a pxa270 board (Sophia Sandgate II, the one
without the additional graphics accelerator), so after spending some efforts
on bringup & bsp, I should be able to also test pxa270 code.
Dmitry Baryshkov Nov. 26, 2014, 10:39 p.m. UTC | #12
2014-11-27 1:38 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
> Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:
>
>> 2014-11-27 1:12 GMT+03:00 Robert Jarzmik <robert.jarzmik@free.fr>:
>>> OK Dmitry, I pulled through, the interrupts are working back.
>>
>> What was the problem? Hardware issues? Firmware in CPLD being of old
>> revision?
> There were basically 2 problems :
>  - hardware: switch S13 was in a position that disabled interrupts all the time
>    One other problem which fooled me was the incorrect gate schematics I had,
>    and which make my understanding of linear function foo such as
>    GPIO0 = foo(LUB_IRQ_EN, LUB_SET_CLR) false.
>
>  - software: lubbock.c error
>    Since gpio-pxa was ported to device/gpio, it is probed *after*
>    lubbock_init_irq() is called. As lubbock_init_irq() installs
>    lubbock_irq_handler() and sets the irq to falling edge detect before gpio-pxa
>    is probed, gpio-pxa probe overwrites this by :
>      - clearing any edge detection (probe state reset)
>      - installing generic handle_edge_irq() instead of the lubbock irq handler
>
> So the conclusion is that I have to rework lubbock_init_irq(), remove from it
> the PXA_GPIO_TO_IRQ(0) stuff, and move it to a code in lubbock.c which will
> provide the guarantee of being executed _after_ gpio-pxa is probed. When I'm
> happy with my patch I'll submit it.

Thank you for your explanation.