SlideShare a Scribd company logo
1 of 19
Download to read offline
ACPI vs FDT
Graeme Gregory
9th July 2013
DTS for I2C
i2c_0: i2c@12C60000 {
compatible = "samsung ,s3c2440 -i2c ";
reg = <0x12C60000 0x100 >;
interrupts = <0 56 0>;
#address -cells = <1>;
#size -cells = <0>;
samsung ,i2c -slave -addr = <0x66 >;
gpios = <&gpb3 0 2 3 0>,
<&gpb3 1 2 3 0>;
};
ASL for I2C
Device (I2C) {
Name (_HID , "LINA0001 ")
Name (_UID , 0)
Method (_CRS , 0x0 , NotSerialized ) {
Name (RBUF , ResourceTemplate ()
{
Memory32Fixed (ReadWrite , 0x12C60000 ,
0x00000100)
Interrupt (ResourceConsumer , Level ,
ActiveLow , Exclusive , , , ) {0 x58}
GpioIo (Exclusive , PullDefault , , , ,
" _SB.GPB3 ") {0x2A , 0x2B}
})
Return (RBUF)
}
Method (DLAY , 0x0 , NotSerialized ) {
Return (100)
}
Method (SADD , 0x0 , NotSerialized ) {
Return (0 x66)
}
Method (FREQ , 0x0 , NotSerialized ) {
Return (20000)
}
}
I2C Device Driver Example
i2c-s3c2410.c driver used as example
Actual system code defined by OEM ASL
ASL binding here is just an example
ACPI Device Table
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id s3c24xx_i2c_acpi_match [] = {
+ { "LINA0001", },
+ { }
+};
+ MODULE_DEVICE_TABLE (acpi , s3c24xx_i2c_acpi_match );
+#endif
+
Similar to FDT table
Allows private data for ”quirks”
Process Quirks
static inline unsigned int s3c24xx_get_device_quirks (struct platform_device *pd
ev)
{
+ struct acpi_handle *dev_handle;
+ struct acpi_device_id const *dev_id;
+
+ dev_handle = ACPI_HANDLE (&pdev ->dev );
+
if (pdev ->dev.of_node) {
const struct of_device_id *match;
match = of_match_node (s3c24xx_i2c_match , pdev ->dev.of_node );
return (unsigned int)match ->data;
}
+ if (dev_handle) {
+ dev_id = acpi_match_device ( s3c24xx_i2c_acpi_match , &pdev ->dev );
+ return (unsigned int)dev_id -> driver_data;
+ }
+
return platform_get_device_id (pdev)-> driver_data ;
}
Process Quirks
Uses the ACPI match table
Types are different but functionally same as
FDT version
Quirks should be rare on ACPI systems
+static acpi_status
+ s3c24xx_i2c_acpi_resource (struct acpi_resource *resource , void *context)
+{
+ u32 i;
+ struct s3c24xx_i2c *i2c = context;
+
+ switch (resource ->type) {
+ case ACPI_RESOURCE_TYPE_EXTENDED_IRQ :
+ /* IRQ resources have already been read */
+ return AE_OK;
+
+ case ACPI_RESOURCE_TYPE_FIXED_MEMORY32 :
+ /* Mem resources have already been read */
+ return AE_OK;
+
+ case ACPI_RESOURCE_TYPE_GPIO :
+ {
+ struct acpi_resource_gpio *p = &resource ->data.gpio;
+
+ if (p-> pin_table_length != 2) {
+ dev_err(i2c ->dev , "2 GPIOS required in resourcen");
+ return AE_OK;
+ }
+
+ for (i = 0; i < p-> pin_table_length ; i++)
+ i2c ->gpios[i] = p->pin_table[i];
+
+ return AE_OK;
+ }
+ default:
+ dev_info(i2c ->dev , "Resource %d isn ’t MMIO , IRQ or GPIOn",
+ resource ->type );
+
+ case ACPI_RESOURCE_TYPE_END_TAG :
+ return AE_OK;
+ }
+ return AE_CTRL_TERMINATE ;
+}
+static int s3c24xx_i2c_parse_acpi_gpio (struct s3c24xx_i2c *i2c)
+{
+ int idx , gpio , ret;
+ struct acpi_handle *dev_handle = ACPI_HANDLE(i2c ->dev);
+
+ if (i2c ->quirks & QUIRK_NO_GPIO )
+ return 0;
+
+ ret = acpi_walk_resources (dev_handle , METHOD_NAME__CRS ,
+ s3c24xx_i2c_acpi_resource , i2c);
+ if ( ACPI_FAILURE (ret)) {
+ pr_warn (" Failure evaluating %sn", METHOD_NAME__CRS );
+ return -EINVAL;
+ }
+
+ for (idx = 0; idx < 2; idx ++) {
+ gpio = i2c ->gpios[idx ];
+ if (! gpio_is_valid (gpio )) {
+ dev_err(i2c ->dev , "invalid gpio [%d]: %dn", idx , gpio );
+ goto free_gpio;
+ }
+ i2c ->gpios[idx] = gpio;
+
+ ret = gpio_request (gpio , "i2c -bus ");
+ if (ret) {
+ dev_err(i2c ->dev , "gpio [%d] request failedn", gpio );
+ goto free_gpio;
+ }
+ }
+ return 0;
+
+free_gpio:
+ while (--idx >= 0)
+ gpio_free(i2c ->gpios[idx ]);
+ return -EINVAL;
+}
Processing the Resources
In this example most resources processed by
acpi-platform.c
GPIO resources not represented by
IO RESOURCE structures so parsed in driver
Resources passed from ASL as structures
Process Misc Data
+static void
+ s3c24xx_i2c_parse_acpi (struct device *device , struct s3c24xx_i2c *i2c)
+{
+ struct s3c2410_platform_i2c *pdata = i2c ->pdata;
+ struct acpi_handle *dev_handle = ACPI_HANDLE(device );
+ acpi_status res;
+ u64 result;
+
+ pdata ->bus_num = -1; /* i2c bus number is dynamically assigned */
+
+ res = acpi_evaluate_integer (dev_handle , "DLAY", NULL , &result );
+ if (! ACPI_FAILURE (res))
+ pdata ->sda_delay = result;
+
+ res = acpi_evaluate_integer (dev_handle , "SADD", NULL , &result );
+ if (! ACPI_FAILURE (res))
+ pdata ->slave_addr = result;
+
+ res = acpi_evaluate_integer (dev_handle , "FREQ", NULL , &result );
+ if (! ACPI_FAILURE (res))
+ pdata ->frequency = result;
+
+ dev_dbg(device , "ACPI delay %d, freq %ld , address %xn",
+ pdata ->sda_delay , pdata ->frequency , pdata ->slave_addr );
+}
Process Misc Data
Misc Data obtained by executing ASL methods
This example just one way, could also have had
one method return a structure of values
Probe
struct s3c24xx_i2c *i2c;
struct s3c2410_platform_i2c *pdata = NULL;
struct resource *res;
+ struct acpi_handle *dev_handle;
int ret;
- if (!pdev ->dev.of_node) {
+ dev_handle = DEVICE_ACPI_HANDLE (&pdev ->dev);
+
+ if (!pdev ->dev.of_node && !dev_handle) {
pdata = pdev ->dev. platform_data ;
if (! pdata) {
dev_err (&pdev ->dev , "no platform datan");
Add checking of ACPI handle
Handle will be set if probed from ACPI
Probe
}
i2c ->quirks = s3c24xx_get_device_quirks (pdev );
- if (pdata)
+ if (pdata) {
memcpy(i2c ->pdata , pdata , sizeof (* pdata ));
- else
- s3c24xx_i2c_parse_dt (pdev ->dev.of_node , i2c);
+ } else {
+ if (pdev ->dev.of_node)
+ s3c24xx_i2c_parse_dt (pdev ->dev.of_node , i2c);
+ if (dev_handle)
+ s3c24xx_i2c_parse_acpi (&pdev ->dev , i2c);
+ }
strlcpy(i2c ->adap.name , "s3c2410 -i2c", sizeof(i2c ->adap.name ));
i2c ->adap.owner = THIS_MODULE;
Add calls to parse data from ASL
Probe
if (i2c ->pdata ->cfg_gpio) {
i2c ->pdata ->cfg_gpio( to_platform_device (i2c ->dev ));
+ } else if (dev_handle) {
+ s3c24xx_i2c_parse_acpi_gpio (i2c);
} else if (IS_ERR(i2c ->pctrl) && s3c24xx_i2c_parse_dt_gpio (i2c)) {
return -EINVAL;
}
Parse GPIO resources from ASL
ACPI Match Table
.name = "s3c -i2c",
.pm = S3C24XX_DEV_PM_OPS ,
. of_match_table = of_match_ptr ( s3c24xx_i2c_match ),
+ . acpi_match_table = ACPI_PTR( s3c24xx_i2c_acpi_match ),
},
};
Add the acpi match table to platform driver
structure
ACPI Platform Whitelist
= {
{ "INT33C6", ACPI_PLATFORM_CLK },
{ "INT33C7", ACPI_PLATFORM_CLK },
+ { "LINA0001", 0 },
+
{ }
};
Platform devices need to be whitelisted before
ACPI will probe them
Conclusion
ACPI similar to work already done for FDT
Actual driver code will depend on ASL from
OEMs
https://wiki.linaro.org/LEG/Engineering/Kernel/ACPI/PrototypeACPI
LCE13: LEG - ACPI reference driver

More Related Content

Viewers also liked

sasikumarj_resume
sasikumarj_resumesasikumarj_resume
sasikumarj_resumeSasi Kumar
 
Ensoft dvb 1
Ensoft dvb 1Ensoft dvb 1
Ensoft dvb 1sarge
 
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
 Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radargrssieee
 
Buildin a small linux kernel
Buildin a small linux kernelBuildin a small linux kernel
Buildin a small linux kerneltrx2001
 
Standard java coding convention
Standard java coding conventionStandard java coding convention
Standard java coding conventionTam Thanh
 
An Ultra-Low Power Asynchronous-Logic
An Ultra-Low Power Asynchronous-LogicAn Ultra-Low Power Asynchronous-Logic
An Ultra-Low Power Asynchronous-LogicHossam Hassan
 
10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easier10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easierChris Simmonds
 
Overview of DVB-T standard to deploy Digital Terrestrial Television
Overview of DVB-T standard to deploy Digital Terrestrial TelevisionOverview of DVB-T standard to deploy Digital Terrestrial Television
Overview of DVB-T standard to deploy Digital Terrestrial TelevisionFarhad Shahrivar
 
11 ak45b5 5
11 ak45b5 511 ak45b5 5
11 ak45b5 5crom68
 
Embedded Linux Basics
Embedded Linux BasicsEmbedded Linux Basics
Embedded Linux BasicsMarc Leeman
 
The Digital Video Broadcast (DVB) Project
The Digital Video Broadcast (DVB) ProjectThe Digital Video Broadcast (DVB) Project
The Digital Video Broadcast (DVB) ProjectPartho Choudhury
 
Read-only rootfs: theory and practice
Read-only rootfs: theory and practiceRead-only rootfs: theory and practice
Read-only rootfs: theory and practiceChris Simmonds
 
Standard embedded c
Standard embedded cStandard embedded c
Standard embedded cTam Thanh
 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016Chris Simmonds
 

Viewers also liked (18)

sasikumarj_resume
sasikumarj_resumesasikumarj_resume
sasikumarj_resume
 
Ensoft dvb 1
Ensoft dvb 1Ensoft dvb 1
Ensoft dvb 1
 
DVB-T/H Solution
DVB-T/H  SolutionDVB-T/H  Solution
DVB-T/H Solution
 
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
 Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
 
Buildin a small linux kernel
Buildin a small linux kernelBuildin a small linux kernel
Buildin a small linux kernel
 
Standard java coding convention
Standard java coding conventionStandard java coding convention
Standard java coding convention
 
An Ultra-Low Power Asynchronous-Logic
An Ultra-Low Power Asynchronous-LogicAn Ultra-Low Power Asynchronous-Logic
An Ultra-Low Power Asynchronous-Logic
 
Embedded Linux
Embedded LinuxEmbedded Linux
Embedded Linux
 
10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easier10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easier
 
J2ME
J2MEJ2ME
J2ME
 
Overview of DVB-T standard to deploy Digital Terrestrial Television
Overview of DVB-T standard to deploy Digital Terrestrial TelevisionOverview of DVB-T standard to deploy Digital Terrestrial Television
Overview of DVB-T standard to deploy Digital Terrestrial Television
 
11 ak45b5 5
11 ak45b5 511 ak45b5 5
11 ak45b5 5
 
Introduction to Raspberry PI
Introduction to Raspberry PIIntroduction to Raspberry PI
Introduction to Raspberry PI
 
Embedded Linux Basics
Embedded Linux BasicsEmbedded Linux Basics
Embedded Linux Basics
 
The Digital Video Broadcast (DVB) Project
The Digital Video Broadcast (DVB) ProjectThe Digital Video Broadcast (DVB) Project
The Digital Video Broadcast (DVB) Project
 
Read-only rootfs: theory and practice
Read-only rootfs: theory and practiceRead-only rootfs: theory and practice
Read-only rootfs: theory and practice
 
Standard embedded c
Standard embedded cStandard embedded c
Standard embedded c
 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016
 

More from Linaro

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloLinaro
 
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta VekariaArm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta VekariaLinaro
 
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua MoraHuawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua MoraLinaro
 
Bud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qaBud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qaLinaro
 
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018Linaro
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018Linaro
 
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...Linaro
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Linaro
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Linaro
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteLinaro
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopLinaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allLinaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorLinaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMULinaro
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MLinaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootLinaro
 

More from Linaro (20)

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
 
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta VekariaArm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
 
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua MoraHuawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
 
Bud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qaBud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qa
 
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
 
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 

Recently uploaded

Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101vincent683379
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 

Recently uploaded (20)

Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 

LCE13: LEG - ACPI reference driver

  • 1. ACPI vs FDT Graeme Gregory 9th July 2013
  • 2. DTS for I2C i2c_0: i2c@12C60000 { compatible = "samsung ,s3c2440 -i2c "; reg = <0x12C60000 0x100 >; interrupts = <0 56 0>; #address -cells = <1>; #size -cells = <0>; samsung ,i2c -slave -addr = <0x66 >; gpios = <&gpb3 0 2 3 0>, <&gpb3 1 2 3 0>; };
  • 3. ASL for I2C Device (I2C) { Name (_HID , "LINA0001 ") Name (_UID , 0) Method (_CRS , 0x0 , NotSerialized ) { Name (RBUF , ResourceTemplate () { Memory32Fixed (ReadWrite , 0x12C60000 , 0x00000100) Interrupt (ResourceConsumer , Level , ActiveLow , Exclusive , , , ) {0 x58} GpioIo (Exclusive , PullDefault , , , , " _SB.GPB3 ") {0x2A , 0x2B} }) Return (RBUF) } Method (DLAY , 0x0 , NotSerialized ) { Return (100) } Method (SADD , 0x0 , NotSerialized ) { Return (0 x66) } Method (FREQ , 0x0 , NotSerialized ) { Return (20000) } }
  • 4. I2C Device Driver Example i2c-s3c2410.c driver used as example Actual system code defined by OEM ASL ASL binding here is just an example
  • 5. ACPI Device Table +#ifdef CONFIG_ACPI +static const struct acpi_device_id s3c24xx_i2c_acpi_match [] = { + { "LINA0001", }, + { } +}; + MODULE_DEVICE_TABLE (acpi , s3c24xx_i2c_acpi_match ); +#endif + Similar to FDT table Allows private data for ”quirks”
  • 6. Process Quirks static inline unsigned int s3c24xx_get_device_quirks (struct platform_device *pd ev) { + struct acpi_handle *dev_handle; + struct acpi_device_id const *dev_id; + + dev_handle = ACPI_HANDLE (&pdev ->dev ); + if (pdev ->dev.of_node) { const struct of_device_id *match; match = of_match_node (s3c24xx_i2c_match , pdev ->dev.of_node ); return (unsigned int)match ->data; } + if (dev_handle) { + dev_id = acpi_match_device ( s3c24xx_i2c_acpi_match , &pdev ->dev ); + return (unsigned int)dev_id -> driver_data; + } + return platform_get_device_id (pdev)-> driver_data ; }
  • 7. Process Quirks Uses the ACPI match table Types are different but functionally same as FDT version Quirks should be rare on ACPI systems
  • 8. +static acpi_status + s3c24xx_i2c_acpi_resource (struct acpi_resource *resource , void *context) +{ + u32 i; + struct s3c24xx_i2c *i2c = context; + + switch (resource ->type) { + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ : + /* IRQ resources have already been read */ + return AE_OK; + + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32 : + /* Mem resources have already been read */ + return AE_OK; + + case ACPI_RESOURCE_TYPE_GPIO : + { + struct acpi_resource_gpio *p = &resource ->data.gpio; + + if (p-> pin_table_length != 2) { + dev_err(i2c ->dev , "2 GPIOS required in resourcen"); + return AE_OK; + } + + for (i = 0; i < p-> pin_table_length ; i++) + i2c ->gpios[i] = p->pin_table[i]; + + return AE_OK; + } + default: + dev_info(i2c ->dev , "Resource %d isn ’t MMIO , IRQ or GPIOn", + resource ->type ); + + case ACPI_RESOURCE_TYPE_END_TAG : + return AE_OK; + } + return AE_CTRL_TERMINATE ; +}
  • 9. +static int s3c24xx_i2c_parse_acpi_gpio (struct s3c24xx_i2c *i2c) +{ + int idx , gpio , ret; + struct acpi_handle *dev_handle = ACPI_HANDLE(i2c ->dev); + + if (i2c ->quirks & QUIRK_NO_GPIO ) + return 0; + + ret = acpi_walk_resources (dev_handle , METHOD_NAME__CRS , + s3c24xx_i2c_acpi_resource , i2c); + if ( ACPI_FAILURE (ret)) { + pr_warn (" Failure evaluating %sn", METHOD_NAME__CRS ); + return -EINVAL; + } + + for (idx = 0; idx < 2; idx ++) { + gpio = i2c ->gpios[idx ]; + if (! gpio_is_valid (gpio )) { + dev_err(i2c ->dev , "invalid gpio [%d]: %dn", idx , gpio ); + goto free_gpio; + } + i2c ->gpios[idx] = gpio; + + ret = gpio_request (gpio , "i2c -bus "); + if (ret) { + dev_err(i2c ->dev , "gpio [%d] request failedn", gpio ); + goto free_gpio; + } + } + return 0; + +free_gpio: + while (--idx >= 0) + gpio_free(i2c ->gpios[idx ]); + return -EINVAL; +}
  • 10. Processing the Resources In this example most resources processed by acpi-platform.c GPIO resources not represented by IO RESOURCE structures so parsed in driver Resources passed from ASL as structures
  • 11. Process Misc Data +static void + s3c24xx_i2c_parse_acpi (struct device *device , struct s3c24xx_i2c *i2c) +{ + struct s3c2410_platform_i2c *pdata = i2c ->pdata; + struct acpi_handle *dev_handle = ACPI_HANDLE(device ); + acpi_status res; + u64 result; + + pdata ->bus_num = -1; /* i2c bus number is dynamically assigned */ + + res = acpi_evaluate_integer (dev_handle , "DLAY", NULL , &result ); + if (! ACPI_FAILURE (res)) + pdata ->sda_delay = result; + + res = acpi_evaluate_integer (dev_handle , "SADD", NULL , &result ); + if (! ACPI_FAILURE (res)) + pdata ->slave_addr = result; + + res = acpi_evaluate_integer (dev_handle , "FREQ", NULL , &result ); + if (! ACPI_FAILURE (res)) + pdata ->frequency = result; + + dev_dbg(device , "ACPI delay %d, freq %ld , address %xn", + pdata ->sda_delay , pdata ->frequency , pdata ->slave_addr ); +}
  • 12. Process Misc Data Misc Data obtained by executing ASL methods This example just one way, could also have had one method return a structure of values
  • 13. Probe struct s3c24xx_i2c *i2c; struct s3c2410_platform_i2c *pdata = NULL; struct resource *res; + struct acpi_handle *dev_handle; int ret; - if (!pdev ->dev.of_node) { + dev_handle = DEVICE_ACPI_HANDLE (&pdev ->dev); + + if (!pdev ->dev.of_node && !dev_handle) { pdata = pdev ->dev. platform_data ; if (! pdata) { dev_err (&pdev ->dev , "no platform datan"); Add checking of ACPI handle Handle will be set if probed from ACPI
  • 14. Probe } i2c ->quirks = s3c24xx_get_device_quirks (pdev ); - if (pdata) + if (pdata) { memcpy(i2c ->pdata , pdata , sizeof (* pdata )); - else - s3c24xx_i2c_parse_dt (pdev ->dev.of_node , i2c); + } else { + if (pdev ->dev.of_node) + s3c24xx_i2c_parse_dt (pdev ->dev.of_node , i2c); + if (dev_handle) + s3c24xx_i2c_parse_acpi (&pdev ->dev , i2c); + } strlcpy(i2c ->adap.name , "s3c2410 -i2c", sizeof(i2c ->adap.name )); i2c ->adap.owner = THIS_MODULE; Add calls to parse data from ASL
  • 15. Probe if (i2c ->pdata ->cfg_gpio) { i2c ->pdata ->cfg_gpio( to_platform_device (i2c ->dev )); + } else if (dev_handle) { + s3c24xx_i2c_parse_acpi_gpio (i2c); } else if (IS_ERR(i2c ->pctrl) && s3c24xx_i2c_parse_dt_gpio (i2c)) { return -EINVAL; } Parse GPIO resources from ASL
  • 16. ACPI Match Table .name = "s3c -i2c", .pm = S3C24XX_DEV_PM_OPS , . of_match_table = of_match_ptr ( s3c24xx_i2c_match ), + . acpi_match_table = ACPI_PTR( s3c24xx_i2c_acpi_match ), }, }; Add the acpi match table to platform driver structure
  • 17. ACPI Platform Whitelist = { { "INT33C6", ACPI_PLATFORM_CLK }, { "INT33C7", ACPI_PLATFORM_CLK }, + { "LINA0001", 0 }, + { } }; Platform devices need to be whitelisted before ACPI will probe them
  • 18. Conclusion ACPI similar to work already done for FDT Actual driver code will depend on ASL from OEMs https://wiki.linaro.org/LEG/Engineering/Kernel/ACPI/PrototypeACPI