@@ -19,16 +19,17 @@ possible we decided to do following:
1919 platform devices.
2020
2121 - Devices behind real busses where there is a connector resource
22- are represented as struct spi_device or struct i2c_device
23- (standard UARTs are not busses so there is no struct uart_device).
22+ are represented as struct spi_device or struct i2c_device. Note
23+ that standard UARTs are not busses so there is no struct uart_device,
24+ although some of them may be represented by sturct serdev_device.
2425
2526As both ACPI and Device Tree represent a tree of devices (and their
2627resources) this implementation follows the Device Tree way as much as
2728possible.
2829
29- The ACPI implementation enumerates devices behind busses (platform, SPI and
30- I2C), creates the physical devices and binds them to their ACPI handle in
31- the ACPI namespace.
30+ The ACPI implementation enumerates devices behind busses (platform, SPI,
31+ I2C, and in some cases UART ), creates the physical devices and binds them
32+ to their ACPI handle in the ACPI namespace.
3233
3334This means that when ACPI_HANDLE(dev) returns non-NULL the device was
3435enumerated from ACPI namespace. This handle can be used to extract other
@@ -46,18 +47,16 @@ some minor changes.
4647Adding ACPI support for an existing driver should be pretty
4748straightforward. Here is the simplest example::
4849
49- #ifdef CONFIG_ACPI
5050 static const struct acpi_device_id mydrv_acpi_match[] = {
5151 /* ACPI IDs here */
5252 { }
5353 };
5454 MODULE_DEVICE_TABLE(acpi, mydrv_acpi_match);
55- #endif
5655
5756 static struct platform_driver my_driver = {
5857 ...
5958 .driver = {
60- .acpi_match_table = ACPI_PTR( mydrv_acpi_match) ,
59+ .acpi_match_table = mydrv_acpi_match,
6160 },
6261 };
6362
@@ -155,7 +154,7 @@ Here is what the ACPI namespace for a SPI slave might look like::
155154 Device (EEP0)
156155 {
157156 Name (_ADR, 1)
158- Name (_CID, Package() {
157+ Name (_CID, Package () {
159158 "ATML0025",
160159 "AT25",
161160 })
@@ -172,59 +171,51 @@ The SPI device drivers only need to add ACPI IDs in a similar way than with
172171the platform device drivers. Below is an example where we add ACPI support
173172to at25 SPI eeprom driver (this is meant for the above ACPI snippet)::
174173
175- #ifdef CONFIG_ACPI
176174 static const struct acpi_device_id at25_acpi_match[] = {
177175 { "AT25", 0 },
178- { },
176+ { }
179177 };
180178 MODULE_DEVICE_TABLE(acpi, at25_acpi_match);
181- #endif
182179
183180 static struct spi_driver at25_driver = {
184181 .driver = {
185182 ...
186- .acpi_match_table = ACPI_PTR( at25_acpi_match) ,
183+ .acpi_match_table = at25_acpi_match,
187184 },
188185 };
189186
190187Note that this driver actually needs more information like page size of the
191- eeprom etc. but at the time writing this there is no standard way of
192- passing those. One idea is to return this in _DSM method like::
188+ eeprom, etc. This information can be passed via _DSD method like::
193189
194190 Device (EEP0)
195191 {
196192 ...
197- Method (_DSM, 4, NotSerialized )
193+ Name (_DSD, Package ( )
198194 {
199- Store (Package (6)
195+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
196+ Package ()
200197 {
201- "byte-len", 1024,
202- "addr-mode", 2,
203- "page-size, 32
204- }, Local0)
205-
206- // Check UUIDs etc.
207-
208- Return (Local0)
209- }
210-
211- Then the at25 SPI driver can get this configuration by calling _DSM on its
212- ACPI handle like::
213-
214- struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
215- struct acpi_object_list input;
216- acpi_status status;
198+ Package () { "size", 1024 },
199+ Package () { "pagesize", 32 },
200+ Package () { "address-width", 16 },
201+ }
202+ })
203+ }
217204
218- /* Fill in the input buffer */
205+ Then the at25 SPI driver can get this configuration by calling device property
206+ APIs during ->probe() phase like::
219207
220- status = acpi_evaluate_object(ACPI_HANDLE(&spi->dev), "_DSM",
221- &input, &output);
222- if (ACPI_FAILURE(status))
223- /* Handle the error */
208+ err = device_property_read_u32(dev, "size", &size);
209+ if (err)
210+ ...error handling...
224211
225- /* Extract the data here */
212+ err = device_property_read_u32(dev, "pagesize", &page_size);
213+ if (err)
214+ ...error handling...
226215
227- kfree(output.pointer);
216+ err = device_property_read_u32(dev, "address-width", &addr_width);
217+ if (err)
218+ ...error handling...
228219
229220I2C serial bus support
230221======================
@@ -237,26 +228,24 @@ registered.
237228Below is an example of how to add ACPI support to the existing mpu3050
238229input driver::
239230
240- #ifdef CONFIG_ACPI
241231 static const struct acpi_device_id mpu3050_acpi_match[] = {
242232 { "MPU3050", 0 },
243- { },
233+ { }
244234 };
245235 MODULE_DEVICE_TABLE(acpi, mpu3050_acpi_match);
246- #endif
247236
248237 static struct i2c_driver mpu3050_i2c_driver = {
249238 .driver = {
250239 .name = "mpu3050",
251- .owner = THIS_MODULE,
252240 .pm = &mpu3050_pm,
253241 .of_match_table = mpu3050_of_match,
254- .acpi_match_table = ACPI_PTR( mpu3050_acpi_match) ,
242+ .acpi_match_table = mpu3050_acpi_match,
255243 },
256244 .probe = mpu3050_probe,
257245 .remove = mpu3050_remove,
258246 .id_table = mpu3050_ids,
259247 };
248+ module_i2c_driver(mpu3050_i2c_driver);
260249
261250Reference to PWM device
262251=======================
@@ -282,9 +271,9 @@ introduced, i.e.::
282271 }
283272 }
284273 }
285-
286274 })
287275 ...
276+ }
288277
289278In the above example the PWM-based LED driver references to the PWM channel 0
290279of \_ SB.PCI0.PWM device with initial period setting equal to 600 ms (note that
@@ -306,26 +295,13 @@ For example::
306295 {
307296 Name (SBUF, ResourceTemplate()
308297 {
309- ...
310298 // Used to power on/off the device
311- GpioIo (Exclusive, PullDefault, 0x0000, 0x0000,
312- IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0",
313- 0x00, ResourceConsumer,,)
314- {
315- // Pin List
316- 0x0055
317- }
299+ GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionOutputOnly,
300+ "\\_SB.PCI0.GPI0", 0, ResourceConsumer) { 85 }
318301
319302 // Interrupt for the device
320- GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone,
321- 0x0000, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer,,)
322- {
323- // Pin list
324- 0x0058
325- }
326-
327- ...
328-
303+ GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0,
304+ "\\_SB.PCI0.GPI0", 0, ResourceConsumer) { 88 }
329305 }
330306
331307 Return (SBUF)
@@ -337,11 +313,12 @@ For example::
337313 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
338314 Package ()
339315 {
340- Package () {"power-gpios", Package() {^DEV, 0, 0, 0 }},
341- Package () {"irq-gpios", Package() {^DEV, 1, 0, 0 }},
316+ Package () { "power-gpios", Package () { ^DEV, 0, 0, 0 } },
317+ Package () { "irq-gpios", Package () { ^DEV, 1, 0, 0 } },
342318 }
343319 })
344320 ...
321+ }
345322
346323These GPIO numbers are controller relative and path "\\ _SB.PCI0.GPI0"
347324specifies the path to the controller. In order to use these GPIOs in Linux
@@ -460,10 +437,10 @@ namespace link::
460437 Device (TMP0)
461438 {
462439 Name (_HID, "PRP0001")
463- Name (_DSD, Package() {
440+ Name (_DSD, Package () {
464441 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
465442 Package () {
466- Package (2 ) { "compatible", "ti,tmp75" },
443+ Package () { "compatible", "ti,tmp75" },
467444 }
468445 })
469446 Method (_CRS, 0, Serialized)
0 commit comments