SlideShare a Scribd company logo
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_resume
Sasi Kumar
 
Ensoft dvb 1
Ensoft dvb 1Ensoft dvb 1
Ensoft dvb 1
sarge
 
DVB-T/H Solution
DVB-T/H  SolutionDVB-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
grssieee
 
Buildin a small linux kernel
Buildin a small linux kernelBuildin a small linux kernel
Buildin a small linux kernel
trx2001
 
Standard java coding convention
Standard java coding conventionStandard java coding convention
Standard java coding convention
Tam Thanh
 
An Ultra-Low Power Asynchronous-Logic
An Ultra-Low Power Asynchronous-LogicAn Ultra-Low Power Asynchronous-Logic
An Ultra-Low Power Asynchronous-Logic
Hossam Hassan
 
Embedded Linux
Embedded LinuxEmbedded Linux
Embedded Linux
Quotient Technology Inc.
 
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
Chris Simmonds
 
J2ME
J2MEJ2ME
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
Farhad Shahrivar
 
11 ak45b5 5
11 ak45b5 511 ak45b5 5
11 ak45b5 5
crom68
 
Introduction to Raspberry PI
Introduction to Raspberry PIIntroduction to Raspberry PI
Introduction to Raspberry PI
Chandrashekar Babu
 
Embedded Linux Basics
Embedded Linux BasicsEmbedded Linux Basics
Embedded Linux Basics
Marc Leeman
 
The Digital Video Broadcast (DVB) Project
The Digital Video Broadcast (DVB) ProjectThe Digital Video Broadcast (DVB) Project
The Digital Video Broadcast (DVB) Project
Partho Choudhury
 
Read-only rootfs: theory and practice
Read-only rootfs: theory and practiceRead-only rootfs: theory and practice
Read-only rootfs: theory and practice
Chris Simmonds
 
Standard embedded c
Standard embedded cStandard embedded c
Standard embedded c
Tam Thanh
 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016
Chris 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 Gallo
Linaro
 
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
Linaro
 
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
Linaro
 
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
Linaro
 
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
Linaro
 
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
Linaro
 
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 mainline
Linaro
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
Linaro
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
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 mainline
Linaro
 
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
Linaro
 
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
Linaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
Linaro
 
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
Linaro
 
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 boot
Linaro
 

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

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 

Recently uploaded (20)

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 

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