From: Al Stone <al.stone@linaro.org>
To: Grant Likely <grant.likely@linaro.org>,
Brandon Anderson <brandon.anderson@amd.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
ACPI Devel Mailing List <linux-acpi@vger.kernel.org>,
linaro-acpi <linaro-acpi@lists.linaro.org>
Subject: Re: [Linaro-acpi] [PATCH V2 3/4] ACPI/ARM: Add ACPI to AMBA SPI driver
Date: Fri, 22 Nov 2013 13:12:36 -0700 [thread overview]
Message-ID: <528FBAB4.20107@linaro.org> (raw)
In-Reply-To: <CACxGe6sfaWgZ59E5n_5Ozv6CQ8Z76dyy346Uz0Lf2E0GdKYrZw@mail.gmail.com>
On 11/22/2013 12:52 PM, Grant Likely wrote:
> On Fri, Nov 22, 2013 at 6:12 PM, Brandon Anderson
> <brandon.anderson@amd.com> wrote:
>> Neither Foundation nor RTSM have a SPI device, but here are the necessary driver
>> changes as an example of how to use acpi_amba_dsm_lookup() to get non-standard
>> parameters from ACPI.
>>
>> This was tested by wiring up a SPI device into an RTSM Fast Model.
>>
>>
>> Signed-off-by: Brandon Anderson <brandon.anderson@amd.com>
>> ---
>> drivers/spi/spi-pl022.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 53 insertions(+)
>>
>> diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
>> index 9c511a9..1d0a8ec 100644
>> --- a/drivers/spi/spi-pl022.c
>> +++ b/drivers/spi/spi-pl022.c
>> @@ -43,6 +43,7 @@
>> #include <linux/gpio.h>
>> #include <linux/of_gpio.h>
>> #include <linux/pinctrl/consumer.h>
>> +#include <linux/amba/acpi.h>
>>
>> /*
>> * This macro is used to define some register default values.
>> @@ -2069,6 +2070,55 @@ pl022_platform_data_dt_get(struct device *dev)
>> return pd;
>> }
>>
>> +#ifdef CONFIG_ACPI
>> +static struct pl022_ssp_controller *
>> +acpi_pl022_get_platform_data(struct device *dev)
>> +{
>> + struct pl022_ssp_controller *pd, *ret;
>> + struct acpi_amba_dsm_entry entry;
>> +
>> + pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL);
>> + if (!pd) {
>> + dev_err(dev, "cannot allocate platform data memory\n");
>> + return NULL;
>> + }
>> + ret = pd;
>> +
>> + pd->bus_id = -1;
>> + pd->enable_dma = 1;
>> + if (acpi_amba_dsm_lookup(ACPI_HANDLE(dev), "num-cs", 0, &entry) == 0) {
>> + if (kstrtou8(entry.value, 0, &pd->num_chipselect) != 0) {
>> + dev_err(dev, "invalid 'num-cs' in ACPI definition\n");
>> + ret = NULL;
>> + }
>> + kfree(entry.key);
>> + kfree(entry.value);
>> + }
>> + if (acpi_amba_dsm_lookup(ACPI_HANDLE(dev),
>> + "autosuspend-delay", 0, &entry) == 0) {
>> + if (kstrtoint(entry.value, 0, &pd->autosuspend_delay) != 0) {
>> + dev_err(dev, "invalid 'autosuspend-delay' in ACPI definition\n");
>> + ret = NULL;
>> + }
>> + kfree(entry.key);
>> + kfree(entry.value);
>> + }
>> + if (acpi_amba_dsm_lookup(ACPI_HANDLE(dev), "rt", 0, &entry) == 0) {
>> + pd->rt = (entry.value && strcmp(entry.value, "1") == 0);
>> + kfree(entry.key);
>> + kfree(entry.value);
>> + }
>> +
>> + return ret;
>> +}
>
> As discussed in the ACPI vs DT thread. The kinds of lookups here are
> identical to the DT property lookups except that the function name is
> different and the property name is needlessly different. That's
> madness. In all of the trivial cases the DT and ACPI lookup code
> should be identical. We need a property value lookup function that
> both DT and ACPI can use.
>
> g.
Agreed. I'm in the process of prototyping this code and my plan
is to have something available for comment the week after next
(unless I get _really_ bored Thanksgiving weekend...).
--
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Linaro Enterprise Group
al.stone@linaro.org
-----------------------------------
next prev parent reply other threads:[~2013-11-22 20:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 18:12 [PATCH V2 0/4] ACPI/ARM: AMBA bus ACPI module Brandon Anderson
2013-11-22 18:12 ` [PATCH V2 1/4] ACPI/ARM: Load fixed-clk module early Brandon Anderson
2013-11-22 18:56 ` Olof Johansson
2013-11-22 18:12 ` [PATCH V2 2/4] ACPI/ARM: Add AMBA bus ACPI module Brandon Anderson
2013-11-22 21:02 ` Matthew Garrett
2013-11-22 18:12 ` [PATCH V2 3/4] ACPI/ARM: Add ACPI to AMBA SPI driver Brandon Anderson
2013-11-22 19:52 ` [Linaro-acpi] " Grant Likely
2013-11-22 20:12 ` Al Stone [this message]
2013-11-22 20:17 ` Anderson, Brandon
2013-11-22 22:16 ` Russell King - ARM Linux
2013-11-22 18:12 ` [PATCH V2 4/4] ACPI/ARM: Remove sections of DTS definition Brandon Anderson
2013-11-22 19:48 ` [Linaro-acpi] " Grant Likely
2013-11-22 20:08 ` Anderson, Brandon
2013-11-22 19:03 ` [PATCH V2 0/4] ACPI/ARM: AMBA bus ACPI module Olof Johansson
2013-11-22 19:44 ` Anderson, Brandon
2013-11-22 22:17 ` Rafael J. Wysocki
2013-11-23 0:10 ` Olof Johansson
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=528FBAB4.20107@linaro.org \
--to=al.stone@linaro.org \
--cc=brandon.anderson@amd.com \
--cc=grant.likely@linaro.org \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=rjw@rjwysocki.net \
/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