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

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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