[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAErSpo5My6+ypp9zsxR8vh8k1px0otOWfAcacWaLNs2xjsc7UA@mail.gmail.com>
Date: Thu, 8 Nov 2012 12:32:25 -0700
From: Bjorn Helgaas <bhelgaas@...gle.com>
To: Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc: "Rafael J. Wysocki" <rjw@...k.pl>, linux-kernel@...r.kernel.org,
lenb@...nel.org, rafael.j.wysocki@...el.com,
broonie@...nsource.wolfsonmicro.com, grant.likely@...retlab.ca,
linus.walleij@...aro.org, khali@...ux-fr.org, ben-linux@...ff.org,
w.sang@...gutronix.de, mathias.nyman@...ux.intel.com,
linux-acpi@...r.kernel.org
Subject: Re: [PATCH 2/3] spi / ACPI: add ACPI enumeration support
On Wed, Nov 7, 2012 at 2:56 AM, Mika Westerberg
<mika.westerberg@...ux.intel.com> wrote:
> On Tue, Nov 06, 2012 at 11:18:11PM +0100, Rafael J. Wysocki wrote:
>> > How is the SPI controller different than this? Is there some logical
>> > difference that requires a different framework? Or are you proposing
>> > that we get rid of acpi_bus_register_driver() and migrate everything
>> > to this new framework?
>>
>> Yes, I do, but let's just do it gradually.
>
> Bjorn, here is a concrete example how this is supposed to be used.
>
> Lets say we have an existing SPI slave driver that we want to extend to
> support enumeration from ACPI. Instead of writing acpi_driver glue for that
> (and registering it using acpi_bus_register_driver()) what we do is simple
> add these to the existing SPI driver:
>
> #ifdef CONFIG_ACPI
> static struct acpi_device_id my_spidrv_match[] = {
> /* ACPI IDs here */
> { }
> };
> MODULE_DEVICE_TABLE(acpi, my_spidrv_match);
> #endif
>
> static struct spi_driver my_spidrv = {
> ...
> .driver = {
> .acpi_match_table = ACPI_PTR(my_spidrv_match),
> },
> };
>
> The same thing works with platform, I2c and SPI drivers and can be extented
> to others as well. If the driver needs to do some ACPI specific
> configuration it can get the ACPI handle using its dev->acpi_handle.
>
> The above example now supports both, normal SPI (where the devices are
> enumerated by populating spi_board_info()) and ACPI. Adding support for
> Device Tree is similar than ACPI so a single driver can support all three
> easily at the same time.
Thanks for the concrete example; that helps me a lot.
Struct device_driver is a generic structure, so it seems strange to
have to include non-generic things like of_device_id and now
acpi_match_table there.
I'm actually interested in the details you didn't include above, too.
For example, I don't know of a generic way to get resource information
from a "struct device *", so I assume you need to figure out what sort
of device it is and then do the appropriate PCI/ACPI/OF/DT/etc
operations to learn the resources?
I think it would be cool if there *were* a generic way to get "struct
device" resources. Then you could imagine a mechanism where a driver
supplied a list of identifiers it could claim, e.g.,
PCI_VEN_DEV(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CE4100_UART),
ACPI_ID("PNP0501"), etc., and it might not need to know anything more
than what the identifier is.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists