History log of /fuchsia/zircon/system/dev/bus/platform/platform-proxy.h
Revision Date Author Comments
# fd3d6217 25-Aug-2018 Mike Voydanoff <voydanoff@google.com>

[platform-bus][aml-canvas] Add support for proxying SOC-specific protocols

This change adds support to the platform bus driver for proxying
SOC-specific protocols to platform devices without modifying the
platform bus source code. It also removes support for the Amlogic canvas
protocol from the platform bus driver and uses this new proxying support instead.

The Amlogic canvas driver is now split into two drivers:
the canvas implementation driver and the canvas proxy driver.
The implementation driver runs in the platform bus devhost and implements the main
functionality of the driver. The proxy driver runs in the devhosts of the
drivers that are clients of the canvas protocol and is responsible for proxying
the canvas protocol to the implementation driver.

To make this work we add a new protocol ZX_PROTOCOL_PLATFORM_PROXY
and add new support to ZX_PROTOCOL_PLATFORM_BUS.
In ZX_PROTOCOL_PLATFORM_BUS, the pbus_register_protocol() API now adds an
optional callback of type platform_proxy_cb_t. This callback handles
RPCs from a protocol proxy driver.

The new protocol ZX_PROTOCOL_PLATFORM_PROXY is used for protocol proxy drivers
to communicate with the platform bus in the client devhosts.
When the proxy driver loads, it calls platform_proxy_register_protocol()
to register its protocol implementation with the platform bus proxy driver.
When the client driver calls a protocol API implemented by the proxy driver,
the proxy driver calls platform_proxy_proxy() to proxy the protocol
to the implementation driver in the platform device devhost, via the channel
that connects the two devhosts.

Support for proxying the Amlogic canvas protocol is now removed from the
platform bus driver, since we are using this new mechanism instead.

Within the platform bus driver, we add a new class ProxyClient.
This is a subclass of ddk::Device that is used for binding the
protocol proxy drivers. In the case where a platform device relies on
SOC-specific protocols implemented using this new mechanism,
the platform bus proxy driver creates a PlatformProxyClient for each
of the protocols and waits for them all to register their protocols
via the ZX_PROTOCOL_PLATFORM_PROXY protocol before creating the
ProxyDevice object to bind the platform device driver.

Below illustrates the parts of the device tree is changed by this CL:

BEFORE:
[04:02:1] pid=1785 /boot/driver/platform-bus.so
<04:02:1> pid=2881 /boot/driver/platform-bus.proxy.so
[vim2-display] pid=2881 /boot/driver/vim-display.so
[display-controller] pid=2881 /boot/driver/display.so

AFTER:
[04:02:1] pid=1850 /boot/driver/platform-bus.so
<04:02:1> pid=3024 /boot/driver/platform-bus.proxy.so
[ProxyClient[7043414e]] pid=3024 /boot/driver/platform-bus.proxy.so
[aml-canvas-proxy] pid=3024 /boot/driver/aml-canvas.proxy.so
[ProxyDevice] pid=3024 /boot/driver/platform-bus.proxy.so
[vim2-display] pid=3024 /boot/driver/vim-display.so
[display-controller] pid=3024 /boot/driver/display.so

In the AFTER subtree, the platform proxy driver inserts a new root device that has
both the aml-canvas and vim2-display drivers as children.

TEST: manual testing on VIM2 and astro

Change-Id: Ibfa925948491fb3793dd934ee5737ace7903edb9


# 5cfd5b91 07-Aug-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Provide platform bus resources platform device children

Currently the platform bus allows creating a list of platform devices,
each running in a separate devhost.
These devices are provided by the bus with various resources
(MMIO buffers, interrupt handles, GPIOs, I2C channels, etc).
However we have use cases where a platform device may have child devices
that also need resources from the platform bus.

This change allows children of platform devices to access platform bus resources.
To do this, the board driver can pass a list of child devices via the pbus_dev_t
structure passed via pbus_device_add(). These children can also have children,
allowing for a tree of platform devices in the same devhost, rather than just one.
To facilitate this, a platform device must use a new platform device protocol
pdev_device_add() to create the child device rather than calling the DDK
device_add() directly.
The behavior of pdev_device_add() is the same as device_add(), except it inserts
a layer between the parent and child device to allow device_get_protocol()
to return protocols that are implemented by the platform bus
(for example, ZX_PROTOCOL_PLATFORM_DEV, ZX_PROTOCOL_GPIO, etc.)
This allows the children of of platform devices to also be platform devices,
while simultaneously allowing access to the protocol(s) implemented by the
parent device.

This change also adds four drivers to the qemu build to test this new functionality.
The qemu-bus board driver adds a platform device called "parent".
"parent" then creates a child device called "child-1", which in turn has
two children called "child-2" and "child-3".
All of these devices are platform devices and all four of the corresponding drivers
test to make sure that they can access the platform device protocol and map
their own unique MMIO regions.

TEST: manual testing on qemu, vim2 and gauss

Change-Id: Iaa4cd2afb06512dd0a9f9e06ca91c84c348e352f


# 9b1d42b6 13-Aug-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Refactor proxying code into a separate class

The PlatformProxy class handles proxying the various protocols
to the parent devhost. PlatformProxy is reference counted to allow
for the future existence of multiple ProxyDevice instances.

This is a step toward having multiple platform devices in the same devhost
(breaking up a larger CL into more easily reviewable chunks).

TEST: manual testing on vim2 and qemu

Change-Id: Ie14b3dde1cd335010f661a28127ee496fbf36844


# fd05dc6b 08-Aug-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Refactor proxying protocol

Proxy request and response structs are now broken up by protocol,
with common headers.
This is first step in modularizing platform bus support for protocol proxying.

TESTS: manual testing on vim2, gauss and qemu

Change-Id: Ic42ac51a03d608cbd481c00a8bcf6e191690c2e7


# d5267c7c 08-Aug-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add platform device support for board info

pdev_get_board_info() returns board vendor and product IDs, board name,
and a board revision number optionally set by the board driver.

TEST: Added test to VIM2 display driver.

ZX-2452 #done

Change-Id: Ia417acc3afede145a7a256ab3d71415c236d8230


# 195d90d8 06-Aug-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Continue port to C++

The proxy side of the platform bus now uses ddktl for all its protocols,
fbl::Vector for its arrays and libzx to manage its handles.
The other half of the platform bus will be ported in a separate CL.

TEST: booting on VIM2 and qemu

Change-Id: Ie843aecffe1df74aa1d74843d4bdb71eb8d52344


# 207a6d5d 01-Jun-2018 Christopher Anderson <cja@google.com>

[dev][platform-bus] Move MMIO/IRQ allocations to proxy devhosts

This change integrates the new Resource Dispatcher model into the
ARM platform.

- Change bus proxy drivers so that on creation they request resource
handles for their mmios and interruptss from the platform bus.
- Use resources to create vmos and interrupts in the proxy devhost

Test: 'k ut resource' and core-tests

Change-Id: I8ea30c87a94952d0314f62a02ec6343bba37e03e


# 93f14256 30-Jul-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Remove support for proxying the mailbox protocol

This support is not actually being used and the proxying code
wasn't actually working correctly.

TEST: manual testing on VIM2

Change-Id: If6cbd86eb23f92bc381821aeb79790da9d4c1f80


# d184543e 26-Jul-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Compile in C++

Minimal changes to compile in C++ instead of C
Subsequent CLs will actually start using C++ language features.

TEST: Boot on VIM2

Change-Id: I9ea5f93b7c4ff2ecb51056d6d2504a207fdac775


# 47434600 26-Jul-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Clean up proxying for scpi protocol

Having a struct with four unions in it was a bit messy while looking
at converting this code to C++.
This CL eliminates the pdev_scpi_ctx_t struct and moves the contents
to pdev_req_t and pdev_resp_t instead.

TEST: boot on VIM2

Change-Id: Ifc6dfbe6dc566c455225589697016b5517742ef9


# b7025e4b 24-Jul-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Fix GPIO alt function truncation

The function parameter to gpio_set_alt_function() was changed to uint64_t,
but platform bus was still using uint32_t in the proxying code.

TEST: manual on VIM2

Change-Id: Ied490e58840a042ad3c248d924070aa09c1b036d


# 28daa8f5 28-Jun-2018 Mike Voydanoff <voydanoff@google.com>

[dev][usb] Move USB initial mode from USB mode switch protocol to device metadata

A step toward making the USB mode switch protocol optional in the OTG case

Test: manual testing on hikey960 and madrone

Change-Id: If121c793d50767cc61044af8da081946a38be636


# 6bd61ec7 22-Jun-2018 Brijen Raval <braval@google.com>

[amlogic][canvas] Add canvas driver for AMLOGIC

- Added a canvas protocol
- Modified the VIM2 display driver to use the canvas
protocol instead of local canvas driver
- Removed local vim2 canvas driver

ZX-2154 #done

Test: Boot up on VIM2 board with HDMI monitor attached
Change-Id: I9e2328513fafecd1a440985f84ee41fce0c35ab9


# b1ac31ce 25-May-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Pass physical address to io_buffer in pdev_map_mmio_buffer()

Change-Id: Icf8662fd1fcdb81b06c118aeb4f1bfbe7ae773f0


# c9cb6e42 14-May-2018 Brijen Raval <braval@google.com>

[vim2][scpi][dvfs] Add DVFS support

- Added DVFS support in the SCPI driver
- scpi_get_dvfs_info() - gets the DVFS table
- scpi_get_dvfs_idx() - gets the current
operating index for given power domain
- scpi_set_dvfs_idx() - sets the DVFS entry
of a given power domain and index

Change-Id: Ie185762b37a3f921e75cbd06349a9a57081871d4


# dcbb70f0 10-May-2018 Brijen Raval <braval@braval-macbookpro2.roam.corp.google.com>

[scpi][vim2] Use array to store sensor name

ZX-2138 #done
Change-Id: Id1289510cfe9191483c7c863799ac17dbad1c592


# c09e0551 09-May-2018 Brijen Raval <braval@google.com>

[vim2][mailbox][scpi] Introduce Mailbox & SCPI Protocol

Breaking down the fan-control thermal prototype driver
into 3 parts.

1st layer would be the Mailbox driver which would
provide communication between the two on-board
processors.

2nd layer would be the SCPI driver (System Control and
Power Interface) which would use the mailbox protocol
to set/get system configuration such as frequency/voltage
and thermal parameters.

3rd layer would be the Fan-control driver which uses
the SCPI protocol to get the temperature and controls
the fan via the GPIO protocol based on it.

(TODO): Expose the fan-ctl & SCPI interface as IOCTL's in a later CL

Change-Id: Ia0175fdfe76048d7cb789e3898e50d9cffb3cee3


# 3b7433be 17-Apr-2018 Brijen Raval <braval@google.com>

[gpio][interrupts] Add GPIO Interrupt Support

Change-Id: Ib9890ed4170fbb84c4c0bb657d716fb3ae983516


# a1d7836e 20-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][platform-bus] Remove contiguous VMO helpers from platform device protocol

These were originally added to remove dependency on get_root_resource(),
but in the future we will be able to use BTI handles instead.

Change-Id: Ic259063b2ca08e96d5a0dc056d4d3aa8e900ebce


# 466813a0 12-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][serial] Move serial protocol support out of platform bus driver

Instead of implementing UARTs as platform device resources in platform bus,
We now have a generic serial driver that implements ZX_PROTOCOL_SERIAL
on top of the lower level ZX_PROTOCOL_SERIAL_IMPL protocol.
This allows the possibility of using the generic seral protocol support
on x86 as well as SOC based platforms.

In order to make this work, we add some new generic device properties to our binding rules:
BIND_DEVICE_VID, BIND_DEVICE_PID and BIND_DEVICE_CLASS.
In this CL we use BIND_DEVICE_CLASS to specify the serial port type
(for example Bluetooth HCI versus generic serial port)
and BIND_DEVICE_VID and BIND_DEVICE_PID to specify which Bluetooth firmware
to use in the case of HCI.

We also simplify the serial protocols by eliminating port numbers from the APIs.
Now serial drivers support only one serial port each, so we now have separate
driver instances per serial port.
This is necessary to maintain the flexibility of running serial port clients
in separate devhosts after decoupling from the platform bus.

Change-Id: Ife2c611a1340ec99440595e45d79bdcf63979644


# 3d0477f4 11-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][i2c] Phase 2 of i2c protocol clean-up

- Remove i2c_channel_t. Now the i2c protocol ops use a uint32_t index
to specify the i2c channel

- Remove i2c_set_bitrate() from the high level i2c protocol.
None of our drivers actually implement this, and if they did
this would be something set by the platform board driver,
not the client.

- Remove the "actual" parameter from i2c_complete_cb.
i2c read transfers either return the amount requested or fail,
so this parameter is not needed.

Change-Id: I2dc2499ba1218d9bfd3501a43982279a3c534157


# db7c4fd3 11-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][i2c] Phase 1 of i2c protocol clean-up

- Add new protocol ZX_PROTOCOL_I2C_IMPL for i2c drivers to implement
This is a simpler protocol to implement than the existing ZX_PROTOCOL_I2C protocol

- Convert the aml-i2c and dw-i2c drivers to implement ZX_PROTOCOL_I2C_IMPL
instead of the higher level ZX_PROTOCOL_I2C protocol

- Move logic for queueing i2c transactions from the i2c drivers
to the platform bus driver

Change-Id: Ic16d18ec331f73cfccce560c1423a1db78472670


# 7bccd5b1 07-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][platform-device] Add cache policy argument to contig buffer allocation helpers

For now, keep all clients using cached buffers.

Change-Id: Ia1777f1506f8421da7ccb99a39391a4bc7256427


# 57eac337 07-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add IOMMU support

Add a new ZX_PROTOCOL_IOMMU, which platform board drivers can use
to implement platform specific IOMMU functionality.
If no IOMMU protocol is set by the board driver, the platform bus
uses a default implementation based on a dummy IOMMU.

Platform device drivers can now access BTIs via the pdev_get_bti()
API in the platform device protocol.
Similarly, board drivers can assign BTIs to the platform devices they create
via the pbus_dev_t struct passed to pbus_device_add().

Also modified the vim, hikey and gauss board drivers to assign BTIs
to all platform devices where the the driver will need to perform DMA.

ZX-693

Change-Id: Id3decaba2ad5bda2c2dc49280e94e674bee1ae56


# b6fd5830 13-Feb-2018 Gurjant Kalsi <gkalsi@google.com>

[ddk][clk][protocol] Initial Clock Protocol

Initial implementation for a platform clock protocol. Only implements enable/disable for now.

Change-Id: If74b24ca6dd59ad7e7b437b15582b700fa5548ac


# 9003e692 02-Feb-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add support for new serial protocols

The socket based ZX_PROTOCOL_SERIAL is implemented on top of the
lower level ZX_PROTOCOL_SERIAL_DRIVER protocol in platform-serial.c
and is proxied across devhost boundaries to platform devices.

Change-Id: Ib19c4cba16cabbb259600d6af0b0c864105f9551


# b383056f 01-Feb-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][gpio] Remove use of enum typedef in the GPIO protocol

Change-Id: I32b9e068fd83cfdbe22804d8b86926173e1b196c


# 7b1941d3 30-Jan-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add pdev_get_device_info()

This allows drivers to access the SOC VID/PID/DID of the platform device
they bound to, as well as number of MMIOs, IRQs, GPIOs and I2C channels
they have access to.

Change-Id: Id244f63f93c2eae460fc90baab2f1cb5ae0197ca


# dd4006e5 17-Jan-2018 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add support for MMIO ranges that are not page aligned

Change-Id: I34f2f931c678bed146081e14e3cbfd4a043f6661


# 537615c0 18-Jan-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][gpio] Add gpio_set_alt_function() to the GPIO protocol

Added plumbing to platform-bus for proxying this new call,
but have not wired it up to any of the GPIO drivers yet.

Change-Id: If512ae3bbd830e36f4c9a03de82d4c065c8527c3


# 4af3a9a0 08-Nov-2017 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add API for allocating contiguous VMOs

to prepare for get_root_resource() removal

Change-Id: I86fd3b079ff85042e61addec6eaec73cdb671d2a


# 3d6efb68 29-Oct-2017 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add support for proxying the i2c protocol to platform devices

Change-Id: I5d76a551a9ad77481a20d9d8fe4313761347dee8


# 8e4df676 13-Oct-2017 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Add proxying support for the GPIO protocol

Change-Id: I3b0e005fce841a9e21f393be70f235d481f27c8a


# 90b89950 13-Oct-2017 Mike Voydanoff <voydanoff@google.com>

[dev][platform-bus] Run platform devices in separate devhosts

The platform bus driver now proxies the platform device
and USB mode switch protocols.
usb_mode_switch_get_initial_mode() now returns a zx_status_t.

Still to do: proxy the GPIO protocol

Change-Id: If989338bd77299b2797e83e9121a856fe00ace5a