ACPI/ARM: AMBA bus ACPI module
Subsystems (6)
v2 cover ACPI/ARM: AMBA bus ACPI module
This patch series requires the fixed-clock patches from Hanjun Guo.
Provides an ACPI module to probe ARM AMBA devices that have a hardware ID, which is used with struct amba_device to match up the appropriate driver. This currently uses the _DSM table for key/value pairs, which may need to be changed to use _PRP depending on the results of separate discussions.
See example of the required DSDT definition format below.
V2:
Minor changes to address comments about #ifdef format and _DSM table tests.
Brandon Anderson (4):
early fixed-clock
AMBA bus ACPI implementation
Add ACPI to AMBA SPI driver
remove unneeded sections of DTS definition
arch/arm64/boot/dts/foundation-v8-acpi.dts | 10 +- arch/arm64/boot/dts/rtsm_ve-aemv8a-acpi.dts | 4 + arch/arm64/boot/dts/rtsm_ve-motherboard-acpi.dtsi | 8 + drivers/acpi/acpi_platform.c | 2 + drivers/amba/Makefile | 2 +- drivers/amba/acpi.c | 338 +++++++++++++++++++++ drivers/clk/clk-fixed-rate.c | 2 +- drivers/spi/spi-pl022.c | 53 ++++ include/linux/amba/acpi.h | 29 ++ 9 files changed, 443 insertions(+), 5 deletions(-) create mode 100644 drivers/amba/acpi.c create mode 100644 include/linux/amba/acpi.h
Signature · 3 lines
1.7.9.5 -----------
platforms/rtsm_ve-aemv8a.acpi/dsdt.asl +251 -0
@@ -252,6 +252,33 @@ DefinitionBlock ( } } + Device (CLK0) { + Name (_HID, "LINA0008") + Name (_UID, 0) + + Method (FREQ, 0x0, NotSerialized) { + Return (24000000) + } + } + + Device (CLK1) { + Name (_HID, "LINA0008") + Name (_UID, 1) + + Method (FREQ, 0x0, NotSerialized) { + Return (1000000) + } + } + + Device (CLK2) { + Name (_HID, "LINA0008") + Name (_UID, 2) + + Method (FREQ, 0x0, NotSerialized) { + Return (32768) + } + } + Device (PMU0) { Name (_HID, "LINA0007") Name (_UID, 0)
@@ -263,5 +290,229 @@ DefinitionBlock ( Return (RBUF) } } + + Method (DTGP, 5, NotSerialized) + { + If (LEqual (Arg0, Buffer (0x10) + { + /* UUID: a706b112-bf0b-48d2-9fa3-95591a3c4c06 */ + /* 0000 */ 0xa7, 0x06, 0xb1, 0x12, 0xbf, 0x0b, 0x48, 0xd2, + /* 0008 */ 0x9f, 0xa3, 0x95, 0x59, 0x1a, 0x3c, 0x4c, 0x06 + })) + { + If (LEqual (Arg1, 0x01)) + { + If (LEqual (Arg2, 0x00)) + { + Store (Buffer (0x01) + { + 0x03 + }, Arg4) + Return (0x01) + } + + If (LEqual (Arg2, 0x01)) + { + Return (0x01) + } + } + } + + Store (Buffer (0x01) + { + 0x00 + }, Arg4) + Return (0x00) + } + + Device (AMBA) { + Name (_HID, "AMBA0000") /* the parallel to "arm,primecell" in DTS */ + Name (_UID, 0) + + /* Define 'apb_pclk' as a default clock source since it is + common with devices below */ + Method(_DSM, 4, NotSerialized) { + Store (Package (2) + { + "clock-name", "apb_pclk \\_SB.CLK0", + }, Local0) + + DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0)) + + Return (Local0) + } + + Device (SCT0) { + Name (_ADR, 0x1c020000) /* SYSCTL */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c020000, 0x00001000) + }) + Return (RBUF) + } + Method(_DSM, 4, Serialized) { + Store (Package (4) + { + "clock-name", "refclk \\_SB.CLK2", + "clock-name", "timclk \\_SB.CLK1", + }, Local0) + + DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0)) + + Return (Local0) + } + } + + Device (KMI0) { + Name (_ADR, 0x1c060000) + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c060000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {44} + }) + Return (RBUF) + } + Method(_DSM, 4, Serialized) { + Store (Package (2) + { + "clock-name", "KMIREFCLK \\_SB.CLK0", + }, Local0) + + DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0)) + + Return (Local0) + } + } + + Device (KMI1) { + Name (_ADR, 0x1c070000) + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c070000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {45} + }) + Return (RBUF) + } + Method(_DSM, 4, NotSerialized) { + Store (Package (2) + { + "clock-name", "KMIREFCLK \\_SB.CLK0", + }, Local0) + + DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0)) + + Return (Local0) + } + } + + Device (SER0) { + Name (_ADR, 0x1c090000) /* UART0 */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c090000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {37} + }) + Return (RBUF) + } + } + + Device (SER1) { + Name (_ADR, 0x1c0a0000) /* UART1 */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c0a0000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {38} + }) + Return (RBUF) + } + } + Device (SER2) { + Name (_ADR, 0x1c0b0000) /* UART2 */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c0b0000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {39} + }) + Return (RBUF) + } + } + + Device (SER3) { + Name (_ADR, 0x1c0c0000) /* UART3 */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c0c0000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {40} + }) + Return (RBUF) + } + } + + Device (AAC0) { + Name (_ADR, 0x1c040000) /* AACI */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c040000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {43} + }) + Return (RBUF) + } + } + + Device (WDT0) { + Name (_ADR, 0x1c0f0000) /* WDT */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c0f0000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {32} + }) + Return (RBUF) + } + } + + Device (TIM0) { + Name (_ADR, 0x1c110000) /* TIMER01 */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c110000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {34} + }) + Return (RBUF) + } + } + + Device (TIM2) { + Name (_ADR, 0x1c120000) /* TIMER23 */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c120000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {35} + }) + Return (RBUF) + } + } + + Device (RTC0) { + Name (_ADR, 0x1c170000) /* RTC */ + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate () { + Memory32Fixed (ReadWrite, 0x1c170000, 0x00001000) + Interrupt (ResourceConsumer, Edge, ActiveBoth, + Exclusive, , , ) {36} + }) + Return (RBUF) + } + } + } } }
PATCH v2 1/4 ACPI/ARM: Load fixed-clk module early
An AMBA device will be probed once two things have occured: 1) ACPI has registered a device, and 2) the driver has registered itself as an AMBA driver. Since several drivers register themselves very early on, the probe will happen as soon as ACPI registers the device. If a device depends on a clock, the clock must be probed before ACPI registers the device. This means that the clock definition must be encountered first in the DSDT file, and the clock driver must already be loaded when this happens.
There are other potential solutions, with this solution registering the clock driver very early in the boot process to avoid changes to other drivers.
--- drivers/clk/clk-fixed-rate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-fixed-rate.c +1 -1
@@ -174,5 +174,5 @@ static int __init fixed_clk_init(void)* fixed clock will used for AMBA bus, UART and etc, so it should be * initialized early enough. */ -subsys_initcall (fixed_clk_init); +postcore_initcall (fixed_clk_init);#endif
Signature · 1 line
1.7.9.5
Re: [PATCH V2 1/4] ACPI/ARM: Load fixed-clk module early
Quoted 8 lines · Brandon Anderson
An AMBA device will be probed once two things have occured: 1) ACPI has registered a device, and 2) the driver has registered itself as an AMBA driver. Since several drivers register themselves very early on, the probe will happen as soon as ACPI registers the device. If a device depends on a clock, the clock must be probed before ACPI registers the device. This means that the clock definition must be encountered first in the DSDT file, and the clock driver must already be loaded when this happens.
Quoted 5 lines
There are other potential solutions, with this solution registering the clock driver very early in the boot process to avoid changes to other drivers.
Signed-off-by Brandon Anderson <[email protected]>
You guys really need to start posting these patches to a wider audience than just linux-acpi. At least cc the clock maintainer on clock patches, and since these are ARM related, the linux-arm-kernel list should be cc:d too.
-Olof
PATCH v2 2/4 ACPI/ARM: Add AMBA bus ACPI module
In reply to Brandon AndersonThis AMBA bus ACPI module provides a generic handler for compatible devices. It depends on a DSDT definition as provided in the related '0/4' email.
It uses the same common code as the device tree method to probe for a hardware ID and match up a driver for each device.
--- drivers/acpi/acpi_platform.c | 2 + drivers/amba/Makefile | 2 +- drivers/amba/acpi.c | 338 ++++++++++++++++++++++++++++++++++++++++++ include/linux/amba/acpi.h | 29 ++++ 4 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 drivers/amba/acpi.c create mode 100644 include/linux/amba/acpi.h
drivers/acpi/acpi_platform.c +2 -0
@@ -36,6 +36,8 @@ static const struct acpi_device_id acpi_platform_device_ids[] = { { "LINA0007" }, /* armv8 pmu */ { "LINA0008" }, /* Fixed clock */ + { "AMBA0000" }, + { } };
drivers/amba/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-$(CONFIG_ARM_AMBA) += bus.o +obj-$(CONFIG_ARM_AMBA) += bus.o acpi.o obj-$(CONFIG_TEGRA_AHB) += tegra-ahb.o
drivers/amba/acpi.c new file +338 -0
338 lines not on this page · raw message
include/linux/amba/acpi.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* AMBA bus ACPI helpers +* +* Copyright (C) 2013 Advanced Micro Devices, Inc. +* +* Author: Brandon Anderson <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef __ARM_AMBA_ACPI_H__ +#define __ARM_AMBA_ACPI_H__ + +#ifdef CONFIG_ACPI +#include <linux/acpi.h> + +struct acpi_amba_dsm_entry { +char *key; +char *value; +}; + +int acpi_amba_dsm_lookup (acpi_handle handle, +const char *tag,int index, +struct acpi_amba_dsm_entry *entry); + +#endif + +#endif
Signature · 1 line
1.7.9.5
Re: [PATCH V2 2/4] ACPI/ARM: Add AMBA bus ACPI module
drivers/amba/acpi.c line 68
Quoted 2 lines · Brandon Anderson
drivers/amba/acpi.c new file +2
-0+ status =acpi_evaluate_object_typed (handle,"_DSM" , + &input, &output,ACPI_TYPE_PACKAGE );
We've got enough uses of _DSM that it'd be nice to have a generic helper function for setting them up. Not that this is a blocker.
drivers/amba/acpi.c line 77
Quoted 1 line
drivers/amba/acpi.c new file +1
-0+/* parse 2 objects per entry */
But if we're expecting anyone to use _DSM for DT properties, this really should be a generic function. Don't make it AMBA specific.
drivers/amba/acpi.c line 174
Quoted 5 lines
drivers/amba/acpi.c new file +5
-0+/* key=value format for clocks is: +* "clock-name"="apb_pclk \\_SB.CLK0" +*/ +if (acpi_amba_dsm_lookup (handle,"clock-name" , index, &entry) !=0 ) +return NULL ;
Why use DT properties for this? If you're just pointing to something else in the ACPI namespace then add a method that returns the object.
Signature · 1 line
Matthew Garrett | [email protected]
PATCH v2 3/4 ACPI/ARM: Add ACPI to AMBA SPI driver
In reply to Brandon AndersonNeither 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.
--- drivers/spi/spi-pl022.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/spi/spi-pl022.c +53 -0
@@ -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; +} +#else +static struct pl022_ssp_controller * +acpi_pl022_get_platform_data (struct device *dev) +{ +return NULL ; +} +#endif +static int pl022_probe (struct amba_device *adev,const struct amba_id *id) {struct device *dev = &adev->dev;
@@ -2081,6 +2131,9 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)dev_info (&adev->dev,"ARM PL022 driver, device ID: 0x%08x\n" , adev->periphid); +if (!platform_info &&ACPI_HANDLE (dev)) + platform_info =acpi_pl022_get_platform_data (dev); +else if (!platform_info &&IS_ENABLED (CONFIG_OF )) platform_info =pl022_platform_data_dt_get (dev);
Signature · 1 line
1.7.9.5
Re: [Linaro-acpi] [PATCH V2 3/4] ACPI/ARM: Add ACPI to AMBA SPI driver
Quoted 59 lines · Brandon Anderson
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 <[email protected]>--- drivers/spi/spi-pl022.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/spi/spi-pl022.c +32
-0@@ -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);
drivers/spi/spi-pl022.c pl022_platform_data_dt_get(struct device *dev) · line 2113
Quoted 10 lines
drivers/spi/spi-pl022.c +10
-0+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.
Re: [Linaro-acpi] [PATCH V2 3/4] ACPI/ARM: Add ACPI to AMBA SPI driver
Quoted 79 lines · Grant Likely
Quoted 59 lines · Brandon Anderson
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 <[email protected]>--- drivers/spi/spi-pl022.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/spi/spi-pl022.c +32
-0@@ -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);drivers/spi/spi-pl022.c pl022_platform_data_dt_get(struct device *dev) · line 2113
Quoted 10 lines
drivers/spi/spi-pl022.c +10
-0+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.
Quoted 1 line
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...).
Signature · 8 lines
ciao, al ----------------------------------- Al Stone Software Engineer Linaro Enterprise Group [email protected] -----------------------------------
RE: [Linaro-acpi] [PATCH V2 3/4] ACPI/ARM: Add ACPI to AMBA SPI driver
-----Original Message-----
From: Al Stone [mailto:[email protected]]
Sent: Friday, November 22, 2013 2:13 PM
To: Grant Likely; Anderson, Brandon
Cc: Rafael J. Wysocki; Russell King - ARM Linux; ACPI Devel Mailing List; linaro-acpi
Subject: Re: [Linaro-acpi] [PATCH V2 3/4] ACPI/ARM: Add ACPI to AMBA SPI driver
Quoted 78 lines · Grant Likely
Quoted 58 lines · Brandon Anderson
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 <[email protected]>--- drivers/spi/spi-pl022.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/spi/spi-pl022.c index renamed from drivers/spi/spi-pl022.c +0
-09c511a9..1d0a8ec 100644
drivers/spi/spi-pl022.c +31
-0@@ -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);drivers/spi/spi-pl022.c pl022_platform_data_dt_get(struct device *dev) · line 2112
Quoted 10 lines
drivers/spi/spi-pl022.c +10
-0+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.
Quoted 1 line
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...).
Great, Al!
I agree, and Russell King has made the same comment. This patch in the series can be dropped with no ill effect, as it is an example only. Or modified to use a common lookup function once it is available.
--
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Linaro Enterprise Group
[email protected]
-----------------------------------
Re: [PATCH V2 3/4] ACPI/ARM: Add ACPI to AMBA SPI driver
In reply to Brandon AndersonQuoted 31 lines · Brandon Anderson
drivers/spi/spi-pl022.c +31
-0+#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);
drivers/spi/spi-pl022.c pl022_platform_data_dt_get(struct device *dev) · line 2113
Quoted 10 lines
drivers/spi/spi-pl022.c +10
-0+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; +}
I thought I'd already commented about this, and said if the properties are the same as the DT stuff, this should be done in a common way rather than modifing every driver.
For stuff like the above, it's really quite simple.
Rename the of_property_read_*() function to firmware_read_*() function and make it take a struct device.
Then you can hide the of_property_read_*() if there's an OF node present inside the firmware_read_*() function. If not, and it has an ACPI handle, then you can read it from ACPI.
That means the only modification that drivers see is a function rename and a _slight_ change of argument, which is a lot saner for driver authors to review rather than having to review an entire set of new parsing code.
PATCH v2 4/4 ACPI/ARM: Remove sections of DTS definition
In reply to Brandon AndersonUse ACPI definition instead of DTS definition for devices that are supported by AMBA bus ACPI module. The replacement ACPI definition was provided in the related '0/4' email.
Note that MMCI is compatible with AMBA bus ACPI module, but is not ported due to complex relations with sysreg and voltage regulator.
--- arch/arm64/boot/dts/foundation-v8-acpi.dts | 10 +++++++--- arch/arm64/boot/dts/rtsm_ve-aemv8a-acpi.dts | 4 ++++ arch/arm64/boot/dts/rtsm_ve-motherboard-acpi.dtsi | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/foundation-v8-acpi.dts +7 -3
@@ -15,12 +15,16 @@ chosen { }; + /* + * Removed for ACPI + * aliases { serial0 = &v2m_serial0; serial1 = &v2m_serial1; serial2 = &v2m_serial2; serial3 = &v2m_serial3; }; + */ cpus { #address-cells = <2>;
@@ -196,6 +200,9 @@ reg = <0x010000 0x1000>; }; + /* + * Removed for ACPI + * v2m_serial0: uart@090000 { compatible = "arm,pl011", "arm,primecell"; reg = <0x090000 0x1000>;
@@ -227,9 +234,6 @@ clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>; clock-names = "uartclk", "apb_pclk"; }; - /* - * Removed for ACPI - * virtio_block@0130000 { compatible = "virtio,mmio"; reg = <0x130000 0x1000>;
arch/arm64/boot/dts/rtsm_ve-aemv8a-acpi.dts +4 -0
@@ -20,12 +20,16 @@ chosen { }; + /* + * Removed for ACPI + * aliases { serial0 = &v2m_serial0; serial1 = &v2m_serial1; serial2 = &v2m_serial2; serial3 = &v2m_serial3; }; + */ cpus { #address-cells = <2>;
arch/arm64/boot/dts/rtsm_ve-motherboard-acpi.dtsi +8 -0
@@ -71,6 +71,9 @@ #gpio-cells = <2>; }; + /* + * Removed for ACPI + * v2m_sysctl: sysctl@020000 { compatible = "arm,sp810", "arm,primecell"; reg = <0x020000 0x1000>;
@@ -87,6 +90,7 @@ clocks = <&v2m_clk24mhz>; clock-names = "apb_pclk"; }; + */ mmci@050000 { compatible = "arm,pl180", "arm,primecell";
@@ -100,6 +104,9 @@ clock-names = "mclk", "apb_pclk"; }; + /* + * Removed for ACPI + * kmi@060000 { compatible = "arm,pl050", "arm,primecell"; reg = <0x060000 0x1000>;
@@ -179,6 +186,7 @@ clocks = <&v2m_clk24mhz>; clock-names = "apb_pclk"; }; + */ clcd@1f0000 { compatible = "arm,pl111", "arm,primecell";
Signature · 1 line
1.7.9.5
Re: [Linaro-acpi] [PATCH V2 4/4] ACPI/ARM: Remove sections of DTS definition
Quoted 23 lines · Brandon Anderson
Use ACPI definition instead of DTS definition for devices that are supported by AMBA bus ACPI module. The replacement ACPI definition was provided in the related '0/4' email.
Note that MMCI is compatible with AMBA bus ACPI module, but is not ported due to complex relations with sysreg and voltage regulator.
Signed-off-by Brandon Anderson <[email protected]>--- arch/arm64/boot/dts/foundation-v8-acpi.dts | 10 +++++++--- arch/arm64/boot/dts/rtsm_ve-aemv8a-acpi.dts | 4 ++++ arch/arm64/boot/dts/rtsm_ve-motherboard-acpi.dtsi | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-)arch/arm64/boot/dts/foundation-v8-acpi.dts +0
-0@@ -15,12 +15,16 @@ chosen { };
arch/arm64/boot/dts/foundation-v8-acpi.dts line 27
Quoted 10 lines
arch/arm64/boot/dts/foundation-v8-acpi.dts +4
-0+ /* + * Removed for ACPI + * aliases { serial0 = &v2m_serial0; serial1 = &v2m_serial1; serial2 = &v2m_serial2; serial3 = &v2m_serial3; }; + */
There's no point in commenting the sections out. If you're removing them, remove the outright.
g.
RE: [Linaro-acpi] [PATCH V2 4/4] ACPI/ARM: Remove sections of DTS definition
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Grant Likely
Sent: Friday, November 22, 2013 1:48 PM
To: Anderson, Brandon
Cc: Russell King - ARM Linux; Rafael J. Wysocki; linaro-acpi; ACPI Devel Mailing List
Subject: Re: [Linaro-acpi] [PATCH V2 4/4] ACPI/ARM: Remove sections of DTS definition
Quoted 24 lines · Brandon Anderson
Use ACPI definition instead of DTS definition for devices that are supported by AMBA bus ACPI module. The replacement ACPI definition was provided in the related '0/4' email.
Note that MMCI is compatible with AMBA bus ACPI module, but is not ported due to complex relations with sysreg and voltage regulator.
Signed-off-by Brandon Anderson <[email protected]>--- arch/arm64/boot/dts/foundation-v8-acpi.dts | 10 +++++++--- arch/arm64/boot/dts/rtsm_ve-aemv8a-acpi.dts | 4 ++++ arch/arm64/boot/dts/rtsm_ve-motherboard-acpi.dtsi | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-)arch/arm64/boot/dts/foundation-v8-acpi.dts +0
-0@@ -15,12 +15,16 @@ chosen { };
arch/arm64/boot/dts/foundation-v8-acpi.dts line 27
Quoted 10 lines
arch/arm64/boot/dts/foundation-v8-acpi.dts +4
-0+ /* + * Removed for ACPI + * aliases { serial0 = &v2m_serial0; serial1 = &v2m_serial1; serial2 = &v2m_serial2; serial3 = &v2m_serial3; }; + */
There's no point in commenting the sections out. If you're removing them, remove the outright.
g.
Acknowledged.
Hi,
Quoted 1 line · Brandon Anderson
This patch series requires the fixed-clock patches from Hanjun Guo.
I don't see them posted anywhere? Please don't post patches that don't apply to mainline (or to publicly posted dependencies).
Quoted 3 lines
arch/arm64/boot/dts/foundation-v8-acpi.dts | 10 +- arch/arm64/boot/dts/rtsm_ve-aemv8a-acpi.dts | 4 + arch/arm64/boot/dts/rtsm_ve-motherboard-acpi.dtsi | 8 +
These files don't exist in mainline, nor in linux-next.
-Olof
Olof,
I apologize for posting confusing patches to the linux-acpi list.
These patches are on top of the Linaro ACPI work, http://git.linaro.org/git-ro/arm/acpi/leg-kernel.git
Brandon
-----Original Message-----
From: Olof Johansson [mailto:[email protected]]
Sent: Friday, November 22, 2013 1:04 PM
To: Anderson, Brandon
Cc: Russell King - ARM Linux; Rafael J. Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH V2 0/4] ACPI/ARM: AMBA bus ACPI module
Hi,
Quoted 1 line · Brandon Anderson
This patch series requires the fixed-clock patches from Hanjun Guo.
I don't see them posted anywhere? Please don't post patches that don't apply to mainline (or to publicly posted dependencies).
Quoted 3 lines
arch/arm64/boot/dts/foundation-v8-acpi.dts | 10 +- arch/arm64/boot/dts/rtsm_ve-aemv8a-acpi.dts | 4 + arch/arm64/boot/dts/rtsm_ve-motherboard-acpi.dtsi | 8 +
These files don't exist in mainline, nor in linux-next.
-Olof
Quoted 4 lines · Brandon
Olof,
I apologize for posting confusing patches to the linux-acpi list.These patches are on top of the Linaro ACPI work, http://git.linaro.org/git-ro/arm/acpi/leg-kernel.git
So here's a rule. I'm not going to look into any Linaro repositories, so please don't expect me to do that. If you want me to look at any code outside of the mainline kernel, please post it here.
Thanks,
Rafael
Quoted 4 lines · Brandon
Olof,
I apologize for posting confusing patches to the linux-acpi list.These patches are on top of the Linaro ACPI work, http://git.linaro.org/git-ro/arm/acpi/leg-kernel.git
Hi Brandon,
First, please don't top-post replies to emails on kernel mailing lists, we usually do in-line replies.
Posting patches that only apply to your forked/private kernel to a community-wide list is not appropriate. Upstream mailing lists should only see code targeted for upstream.
-Olof