Skip to content

Platform Bus

Overview

The Platform Bus is the most commonly used bus type for SoC-integrated peripherals in Embedded Linux systems.

Unlike discoverable buses such as PCIe or USB, platform devices are usually described by firmware information, most commonly through Device Tree.

Typical platform devices include:

  • GPIO Controllers
  • UART Controllers
  • SPI Controllers
  • I2C Controllers
  • Watchdogs
  • RTCs
  • PWMs
  • DMA Controllers
  • PCIe Controllers

The Platform Bus is built on top of the Linux Driver Model.


Relationship with the Linux Driver Model

The Linux Driver Model provides three core objects:

bus_type
device
device_driver

The Platform Bus specializes these objects:

platform_bus_type
bus_type

platform_device
device

platform_driver
device_driver

As a result, Platform Bus behavior follows the same matching and binding mechanisms used throughout the Driver Core.


Platform Bus Architecture

platform_device
platform_match()
platform_driver

The Platform Bus is responsible for matching devices and drivers.

A successful match establishes a device-driver binding and allows probing to proceed.


Device Creation

Platform devices may be created in several ways.

Device Tree

Most modern ARM systems use Device Tree.

Device Tree
OF Subsystem
of_platform_populate()
platform_device

Example:

uart0 {
    compatible = "vendor,uart";
};

The kernel automatically creates a corresponding platform device.


Manual Registration

Platform devices may also be created directly by software.

platform_device_register_simple(
    "demo_platform",
    -1,
    NULL,
    0);

This approach is commonly used for:

  • Testing
  • Legacy platforms
  • Virtual devices

Driver Registration

Platform drivers are registered through:

platform_driver_register()

Internally:

platform_driver_register()
driver_register()

The driver becomes part of the Platform Bus and participates in device matching.


Matching Methods

The Platform Bus supports several matching mechanisms.

Conceptually:

platform_device
platform_match()
platform_driver

The matching order is:

1. Device Tree matching
2. ACPI matching
3. ID table matching
4. Name matching

The exact implementation may vary between kernel versions.


Device Tree Matching

The most common matching method on Embedded Linux systems uses Device Tree.

Driver:

static const struct of_device_id demo_of_match[] = {
    { .compatible = "demo,platform-bus" },
    {}
};
.driver = {
    .of_match_table = demo_of_match,
}

Device Tree:

demo-platform {
    compatible = "demo,platform-bus";
};

Matching flow:

compatible
of_match_table
platform_match()

If the strings match, the driver can be bound to the device.


Name Matching

When Device Tree matching is unavailable, Platform Bus may fall back to name matching.

Device:

platform_device_register_simple(
    "demo_platform",
    ...
);

Driver:

.driver = {
    .name = "demo_platform",
}

Matching flow:

platform_device.name
platform_driver.name

Name matching is commonly used in simple examples and legacy code.


Probe Flow

A successful match allows the probing process to continue.

Conceptually:

platform_driver_register()
driver_register()
driver_attach()
platform_match()
really_probe()
platform_probe()
driver probe()

The exact internal implementation may vary between kernel versions.


Device Tree and Probe

A common misunderstanding is:

Device Tree
probe()

This is incorrect.

The actual flow is:

Device Tree
platform_device
platform_match()
platform_driver
probe()

Device Tree creates platform devices.

The Platform Bus performs device-driver matching.

The driver's probe callback is only invoked after a successful bind.


MODULE_DEVICE_TABLE(of)

Example:

MODULE_DEVICE_TABLE(of, demo_of_match);

This macro generates OF module aliases.

Example:

alias: of:N*T*Cdemo,platform-busC*

Purpose:

Module alias generation
Module auto-loading support

Runtime matching still relies on:

.of_match_table

rather than MODULE_DEVICE_TABLE().


Sysfs Representation

Platform Bus objects are visible through sysfs.

Bus:

/sys/bus/platform

Devices:

/sys/bus/platform/devices

Drivers:

/sys/bus/platform/drivers

Device Tree association:

platform_device
of_node
Device Tree node

Driver association:

platform_device
driver
platform_driver

These relationships can be inspected directly from sysfs.


Key Takeaways

Platform Bus is built on top of the Linux Driver Model.

Device Tree creates platform_device objects.

Platform Bus performs matching.

Successful matching triggers probe().

Device Tree does not call probe() directly.