platform.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. Platform Devices and Drivers
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. Platform devices
  4. ~~~~~~~~~~~~~~~~
  5. Platform devices are devices that typically appear as autonomous
  6. entities in the system. This includes legacy port-based devices and
  7. host bridges to peripheral buses.
  8. Platform drivers
  9. ~~~~~~~~~~~~~~~~
  10. Drivers for platform devices are typically very simple and
  11. unstructured. Either the device was present at a particular I/O port
  12. and the driver was loaded, or it was not. There was no possibility
  13. of hotplugging or alternative discovery besides probing at a specific
  14. I/O address and expecting a specific response.
  15. Other Architectures, Modern Firmware, and new Platforms
  16. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  17. These devices are not always at the legacy I/O ports. This is true on
  18. other architectures and on some modern architectures. In most cases,
  19. the drivers are modified to discover the devices at other well-known
  20. ports for the given platform. However, the firmware in these systems
  21. does usually know where exactly these devices reside, and in some
  22. cases, it's the only way of discovering them.
  23. The Platform Bus
  24. ~~~~~~~~~~~~~~~~
  25. A platform bus has been created to deal with these issues. First and
  26. foremost, it groups all the legacy devices under a common bus, and
  27. gives them a common parent if they don't already have one.
  28. But, besides the organizational benefits, the platform bus can also
  29. accommodate firmware-based enumeration.
  30. Device Discovery
  31. ~~~~~~~~~~~~~~~~
  32. The platform bus has no concept of probing for devices. Devices
  33. discovery is left up to either the legacy drivers or the
  34. firmware. These entities are expected to notify the platform of
  35. devices that it discovers via the bus's add() callback:
  36. platform_bus.add(parent,bus_id).
  37. Bus IDs
  38. ~~~~~~~
  39. Bus IDs are the canonical names for the devices. There is no globally
  40. standard addressing mechanism for legacy devices. In the IA-32 world,
  41. we have Pnp IDs to use, as well as the legacy I/O ports. However,
  42. neither tell what the device really is or have any meaning on other
  43. platforms.
  44. Since both PnP IDs and the legacy I/O ports (and other standard I/O
  45. ports for specific devices) have a 1:1 mapping, we map the
  46. platform-specific name or identifier to a generic name (at least
  47. within the scope of the kernel).
  48. For example, a serial driver might find a device at I/O 0x3f8. The
  49. ACPI firmware might also discover a device with PnP ID (_HID)
  50. PNP0501. Both correspond to the same device and should be mapped to the
  51. canonical name 'serial'.
  52. The bus_id field should be a concatenation of the canonical name and
  53. the instance of that type of device. For example, the device at I/O
  54. port 0x3f8 should have a bus_id of "serial0". This places the
  55. responsibility of enumerating devices of a particular type up to the
  56. discovery mechanism. But, they are the entity that should know best
  57. (as opposed to the platform bus driver).
  58. Drivers
  59. ~~~~~~~
  60. Drivers for platform devices should have a name that is the same as
  61. the canonical name of the devices they support. This allows the
  62. platform bus driver to do simple matching with the basic data
  63. structures to determine if a driver supports a certain device.
  64. For example, a legacy serial driver should have a name of 'serial' and
  65. register itself with the platform bus.
  66. Driver Binding
  67. ~~~~~~~~~~~~~~
  68. Legacy drivers assume they are bound to the device once they start up
  69. and probe an I/O port. Divorcing them from this will be a difficult
  70. process. However, that shouldn't prevent us from implementing
  71. firmware-based enumeration.
  72. The firmware should notify the platform bus about devices before the
  73. legacy drivers have had a chance to load. Once the drivers are loaded,
  74. they driver model core will attempt to bind the driver to any
  75. previously-discovered devices. Once that has happened, it will be free
  76. to discover any other devices it pleases.