From: "Måns Rullgård" <mans@mansr.com>
To: Mason <slash.tmp@free.fr>
Cc: Javier Martinez Canillas <javier@dowhile0.org>,
Andrew Lunn <andrew@lunn.ch>, LKML <linux-kernel@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Marc Zyngier <marc.zyngier@arm.com>,
Jason Cooper <jason@lakedaemon.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: Grafting old platform drivers onto a new DT kernel
Date: Mon, 09 Nov 2015 15:40:10 +0000 [thread overview]
Message-ID: <yw1xtwov5gh1.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <5640B877.4020108@free.fr> (Mason's message of "Mon, 9 Nov 2015 16:15:03 +0100")
Mason <slash.tmp@free.fr> writes:
> On 05/11/2015 16:42, Javier Martinez Canillas wrote:
>> Hello,
>>
>> On Thu, Nov 5, 2015 at 12:15 PM, Andrew Lunn <andrew@lunn.ch> wrote:
>>>> Since I don't have time to rewrite the drivers at the moment, I'm wondering
>>>> if it's possible to "graft" old drivers (they're using the platform API, no
>>>> trace of DT support) onto my small base?
>>>
>>> Platform drivers are still usable with DT systems. We used that fact
>>> when converting platform based machines over to DT, one driver at a
>>> time. Look in the git history for kirkwood devices. e.g. somewhere
>>> around v3.7, arch/arm/mach-kirkwood. board-dt.c, and the various
>>> board-*.c files, and the DT files in the usual place.
>>>
>>
>> OMAP did the same and still some boards use platform data and manually
>> register platform devices from board code. Take a look to
>> arch/arm/mach-omap2/pdata-quirks.c to see how that is being done.
>
> Hello,
>
> I tried compiling an ancient SDHCI driver on a v4.2 system. It crashes
> all over init because several host->ops functions are required, but the
> old driver does not define them:
> .reset
> .set_clock
> .set_bus_width
> .set_uhs_signaling
>
> So I downgraded to an older v3.14 kernel, and that problem vanished.
> But I am having a problem with the IRQ setup.
>
> # cat /proc/interrupts
> CPU0 CPU1
> 18: 93 0 irq0 1 Level serial
> 55: 2832 0 irq0 38 Level 26000.ethernet
> 60: 0 0 irq0 43 Edge mmc0
> 211: 319 2603 GIC 29 Edge twd
>
> Ethernet is using IRQ 38, as specified in the DT.
> mmc0 is supposed to use IRQ 60.
>
> I see that the mmc0 has the index 60, so I must have messed up between
> the real irq (hwirq?) and the index Linux uses internally (virq?)
>
> static struct resource sdhci_resources[] = {
> {
> .start = TANGOX_SDIO0_BASE_ADDR,
> .end = TANGOX_SDIO0_BASE_ADDR + 0x1ff,
> .flags = IORESOURCE_MEM,
> },
> {
> .start = 60, /* SDHCI0 IRQ */
> .flags = IORESOURCE_IRQ,
> },
> };
>
> Both ethernet and sdhci driver call platform_get_irq(pdev, 0);
> but the eth driver is DT, so calls of_irq_get() while sdhci is
> legacy, so calls platform_get_resource() -- IIUC.
>
> How do I specify a "hwirq" instead of a "Linux index"? and where?
The simplest solution for you is probably to add a quick and dirty DT
binding to the old driver. If it doesn't use any driver-specific
platform data struct, you only need to set .of_match_table in the
struct platform_driver. If there is a platform data struct, you'll also
need to write some code to populate it from DT properties. It shouldn't
take more than a few minutes per driver in most cases.
To get those drivers accepted upstream will obviously take a bit more
work.
--
Måns Rullgård
mans@mansr.com
next prev parent reply other threads:[~2015-11-09 15:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 11:02 Mason
2015-11-05 15:15 ` Andrew Lunn
2015-11-05 15:42 ` Javier Martinez Canillas
2015-11-09 15:15 ` Mason
2015-11-09 15:36 ` Marc Zyngier
2016-02-03 15:33 ` Sebastian Frias
2015-11-09 15:40 ` Måns Rullgård [this message]
2015-11-09 16:07 ` Mason
2015-11-09 16:12 ` Måns Rullgård
2015-11-09 17:03 ` Mason
2015-11-09 17:13 ` Måns Rullgård
2015-11-10 12:44 ` Mason
2015-11-10 12:56 ` Arnd Bergmann
2015-11-09 16:26 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yw1xtwov5gh1.fsf@unicorn.mansr.com \
--to=mans@mansr.com \
--cc=andrew@lunn.ch \
--cc=jason@lakedaemon.net \
--cc=javier@dowhile0.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=slash.tmp@free.fr \
--cc=tglx@linutronix.de \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®