* [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver
@ 2016-02-05 7:11 qiujiang
2016-02-05 11:09 ` Mark Brown
2016-02-05 15:55 ` Andy Shevchenko
0 siblings, 2 replies; 10+ messages in thread
From: qiujiang @ 2016-02-05 7:11 UTC (permalink / raw)
To: broonie
Cc: linux-spi, linux-acpi, linux-kernel, linuxarm, haifeng.wei,
charles.chenxin, qiujiang
This patch added ACPI support for DesignWare SPI mmio driver. It
was based the corresponding DT driver and compatible for this two
way. This patch has been tested on Hisilicon D02 board. It relies
on the GPIO patchset.
Signed-off-by: qiujiang <qiujiang@huawei.com>
---
drivers/spi/spi-dw-mmio.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index a6d7029..de542f0 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -8,6 +8,7 @@
* version 2, as published by the Free Software Foundation.
*/
+#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/interrupt.h>
@@ -36,7 +37,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
struct dw_spi *dws;
struct resource *mem;
int ret;
- int num_cs;
+ int num_cs, i;
+ struct gpio_desc *gpiod;
+ char propname[32];
dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio),
GFP_KERNEL);
@@ -84,8 +87,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
dws->num_cs = num_cs;
if (pdev->dev.of_node) {
- int i;
-
for (i = 0; i < dws->num_cs; i++) {
int cs_gpio = of_get_named_gpio(pdev->dev.of_node,
"cs-gpios", i);
@@ -104,6 +105,18 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
}
}
+ if (ACPI_COMPANION(&pdev->dev)) {
+ for (i = 0; i < dws->num_cs; i++) {
+ snprintf(propname, sizeof(propname), "cs%d", i);
+ gpiod = devm_gpiod_get(&pdev->dev,
+ propname, GPIOD_ASIS);
+ if (IS_ERR(gpiod)) {
+ dev_err(&pdev->dev, "Get gpio desc failed!\n");
+ return PTR_ERR(gpiod);
+ }
+ }
+ }
+
ret = dw_spi_add_host(&pdev->dev, dws);
if (ret)
goto out;
@@ -132,12 +145,19 @@ static const struct of_device_id dw_spi_mmio_of_match[] = {
};
MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);
+static const struct acpi_device_id dw_spi_mmio_acpi_match[] = {
+ {"HISI0171", 0},
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, dw_spi_mmio_acpi_match);
+
static struct platform_driver dw_spi_mmio_driver = {
.probe = dw_spi_mmio_probe,
.remove = dw_spi_mmio_remove,
.driver = {
.name = DRIVER_NAME,
.of_match_table = dw_spi_mmio_of_match,
+ .acpi_match_table = ACPI_PTR(dw_spi_mmio_acpi_match),
},
};
module_platform_driver(dw_spi_mmio_driver);
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver
2016-02-05 7:11 [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver qiujiang
@ 2016-02-05 11:09 ` Mark Brown
[not found] ` <20160205110900.GA12311-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-02-05 15:55 ` Andy Shevchenko
1 sibling, 1 reply; 10+ messages in thread
From: Mark Brown @ 2016-02-05 11:09 UTC (permalink / raw)
To: qiujiang
Cc: linux-spi, linux-acpi, linux-kernel, linuxarm, haifeng.wei,
charles.chenxin, Andy Shevchenko, Jarkko Nikula
[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]
On Fri, Feb 05, 2016 at 03:11:20PM +0800, qiujiang wrote:
> This patch added ACPI support for DesignWare SPI mmio driver. It
> was based the corresponding DT driver and compatible for this two
> way. This patch has been tested on Hisilicon D02 board. It relies
> on the GPIO patchset.
Intel are heavy users of this driver on their systems which also use
ACPI. Have you discussed this binding with them? I've copied Andy and
Jarkko who've worked on the driver recently.
Please use subject lines matching the style for the subsystem. This
makes it easier for people to identify relevant patches.
> + char propname[32];
That's a magic number, where did it come from and why is it a magic
nummber?
> + if (ACPI_COMPANION(&pdev->dev)) {
> + for (i = 0; i < dws->num_cs; i++) {
> + snprintf(propname, sizeof(propname), "cs%d", i);
> + gpiod = devm_gpiod_get(&pdev->dev,
> + propname, GPIOD_ASIS);
> + if (IS_ERR(gpiod)) {
> + dev_err(&pdev->dev, "Get gpio desc failed!\n");
> + return PTR_ERR(gpiod);
> + }
> + }
> + }
I'm not seeing anywhere where we store the GPIO in this loop. It is
therefore unclear to me how the chip select is going to work?
> +static const struct acpi_device_id dw_spi_mmio_acpi_match[] = {
> + {"HISI0171", 0},
> + { }
> +};
> +MODULE_DEVICE_TABLE(acpi, dw_spi_mmio_acpi_match);
I really do wish ACPI had some more sensible system for allocating
device IDs so the tables were a little more legible. :(
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver
2016-02-05 7:11 [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver qiujiang
2016-02-05 11:09 ` Mark Brown
@ 2016-02-05 15:55 ` Andy Shevchenko
[not found] ` <CAHp75VeSkUvHSd_JC-qPzwDjBWM8oxJP8jt3UD91uq1=fvEEqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-14 9:47 ` Jiang Qiu
1 sibling, 2 replies; 10+ messages in thread
From: Andy Shevchenko @ 2016-02-05 15:55 UTC (permalink / raw)
To: qiujiang
Cc: Mark Brown, linux-spi, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, linuxarm, haifeng.wei,
charles.chenxin
On Fri, Feb 5, 2016 at 9:11 AM, qiujiang <qiujiang@huawei.com> wrote:
> This patch added ACPI support for DesignWare SPI mmio driver. It
> was based the corresponding DT driver and compatible for this two
> way. This patch has been tested on Hisilicon D02 board. It relies
> on the GPIO patchset.
My comments below.
> @@ -84,8 +87,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
> dws->num_cs = num_cs;
>
> if (pdev->dev.of_node) {
> - int i;
> -
> for (i = 0; i < dws->num_cs; i++) {
> int cs_gpio = of_get_named_gpio(pdev->dev.of_node,
> "cs-gpios", i);
It seems the driver was never validated with more than one chip select.
Perhaps someone has to switch to use of_spi_register_master() here.
> @@ -104,6 +105,18 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
> }
> }
>
> + if (ACPI_COMPANION(&pdev->dev)) {
> + for (i = 0; i < dws->num_cs; i++) {
> + snprintf(propname, sizeof(propname), "cs%d", i);
> + gpiod = devm_gpiod_get(&pdev->dev,
> + propname, GPIOD_ASIS);
> + if (IS_ERR(gpiod)) {
> + dev_err(&pdev->dev, "Get gpio desc failed!\n");
> + return PTR_ERR(gpiod);
> + }
> + }
> + }
Like Mark noticed there is also same issue. Do you indeed check the
configuration with different chip select signals?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <CAHp75VeSkUvHSd_JC-qPzwDjBWM8oxJP8jt3UD91uq1=fvEEqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver
[not found] ` <CAHp75VeSkUvHSd_JC-qPzwDjBWM8oxJP8jt3UD91uq1=fvEEqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-02-05 16:11 ` Mark Brown
0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2016-02-05 16:11 UTC (permalink / raw)
To: Andy Shevchenko
Cc: qiujiang, linux-spi,
linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linuxarm-hv44wF8Li93QT0dZR+AlfA,
haifeng.wei-hv44wF8Li93QT0dZR+AlfA,
charles.chenxin-hv44wF8Li93QT0dZR+AlfA
[-- Attachment #1: Type: text/plain, Size: 329 bytes --]
On Fri, Feb 05, 2016 at 05:55:42PM +0200, Andy Shevchenko wrote:
> Like Mark noticed there is also same issue. Do you indeed check the
> configuration with different chip select signals?
It's not clear to me that *any* chip select signals work, we get a GPIO
descriptor back but I didn't see any code that ever used the value.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver
2016-02-05 15:55 ` Andy Shevchenko
[not found] ` <CAHp75VeSkUvHSd_JC-qPzwDjBWM8oxJP8jt3UD91uq1=fvEEqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-02-14 9:47 ` Jiang Qiu
1 sibling, 0 replies; 10+ messages in thread
From: Jiang Qiu @ 2016-02-14 9:47 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Mark Brown, linux-spi, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, linuxarm, haifeng.wei,
charles.chenxin
Hi Andy,
Sorry for late relpy because Chinese new year holiday. See my replies below.
Best Regards
Jiang
在 2016/2/5 23:55, Andy Shevchenko 写道:
> On Fri, Feb 5, 2016 at 9:11 AM, qiujiang <qiujiang@huawei.com> wrote:
>> This patch added ACPI support for DesignWare SPI mmio driver. It
>> was based the corresponding DT driver and compatible for this two
>> way. This patch has been tested on Hisilicon D02 board. It relies
>> on the GPIO patchset.
> My comments below.
As Mark mentioned, I want to ask you how to use this spi-dw-mmio driver for
ACPI binding? Dose it need any other extra patchset?
>
>> @@ -84,8 +87,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
>> dws->num_cs = num_cs;
>>
>> if (pdev->dev.of_node) {
>> - int i;
>> -
>> for (i = 0; i < dws->num_cs; i++) {
>> int cs_gpio = of_get_named_gpio(pdev->dev.of_node,
>> "cs-gpios", i);
> It seems the driver was never validated with more than one chip select.
> Perhaps someone has to switch to use of_spi_register_master() here.
of_spi_register_master() will be executed in the spi_register_master(),
but it just saved the
cs_gpios to the spi_master and not used it any more.
>> @@ -104,6 +105,18 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
>> }
>> }
>>
>> + if (ACPI_COMPANION(&pdev->dev)) {
>> + for (i = 0; i < dws->num_cs; i++) {
>> + snprintf(propname, sizeof(propname), "cs%d", i);
>> + gpiod = devm_gpiod_get(&pdev->dev,
>> + propname, GPIOD_ASIS);
>> + if (IS_ERR(gpiod)) {
>> + dev_err(&pdev->dev, "Get gpio desc failed!\n");
>> + return PTR_ERR(gpiod);
>> + }
>> + }
>> + }
> Like Mark noticed there is also same issue. Do you indeed check the
> configuration with different chip select signals?
As a spi master driver, it seems that multi-chip select must be
supported, so this check is
necessary, I think.
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-02-15 18:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-05 7:11 [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver qiujiang
2016-02-05 11:09 ` Mark Brown
[not found] ` <20160205110900.GA12311-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-02-14 9:31 ` Jiang Qiu
2016-02-15 17:44 ` Mark Brown
2016-02-15 8:27 ` Hanjun Guo
[not found] ` <56C18C07.2030209-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-02-15 17:45 ` Mark Brown
[not found] ` <20160215174540.GS18988-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-02-15 18:09 ` One Thousand Gnomes
2016-02-05 15:55 ` Andy Shevchenko
[not found] ` <CAHp75VeSkUvHSd_JC-qPzwDjBWM8oxJP8jt3UD91uq1=fvEEqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-05 16:11 ` Mark Brown
2016-02-14 9:47 ` Jiang Qiu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).