genode/repos/os/src/drivers/i2c
2021-12-17 15:04:45 +01:00
..
imx8q_evk os: avoid implicit conversions 2021-12-17 15:04:45 +01:00
component.h i2c: extend API to support transactions 2021-05-28 14:16:45 +02:00
i2c_interface.h i2c: extend API to support transactions 2021-05-28 14:16:45 +02:00
main.cc add I2c driver for imx8q based platform 2021-03-29 13:45:24 +02:00
README add I2c driver for imx8q based platform 2021-03-29 13:45:24 +02:00
target.inc add I2c driver for imx8q based platform 2021-03-29 13:45:24 +02:00

This directory contains the implementation of the I2C driver component.

Brief
=====

The driver supports I2C bus controller for imx8q_evk only for master mode.
A platform connection is used to retrieve device's capabilities.
The platform driver must provide a device with the following configuration:

!<!-- I2C controller bus 2 -->
!<device name="i2c2">
!
!  <!-- I2C bus 2 ctl register -->
!  <io_mem address="0x30a30000" size="0x10000"/>
!
!  <!-- iomux's I2C config register and iomux's pull-up resistor config -->
!  <io_mem address="0x30330000" size="0x1000"/>
!
!  <!-- irq number as the controller is interrupt driven -->
!  <irq number="68"/>
!
!  <!-- I2C bus 2 clock -->
!  <clock  name="i2c2_clk_root"
!          driver_name="i2c2_root_clk"
!          parent="system_pll3_clk"/>
!  <clock  name="i2c2_gate"/>
!
!</device>
!
!<policy label_prefix="imx8q_evk_i2c_drv"> <device name="i2c2"/> </policy>

The io_mem address, irq number and clock might change from one I2C bus
controller to another. The io_mem address for iomux configuration may
remain the same across I2C bus controllers.

The driver can be extended to another platform. An 'I2c::Driver_base'
interface is provided in 'i2c_interface.h'. The specific platform
implementation must expose a 'driver.h' header file that contains a
declaration of 'I2c::Driver' that implements the 'I2c::Driver_base'
interface. An example of a specific platform implementation can be found
in 'os/src/drivers/i2c/imx8q_evk'.

Configuration
=============

The driver acts as a server that must be configured via a policy, that states
which client can access a certain device(s) on the bus:

!<start name="imx8q_evk_i2c_drv">
!  <resource name="RAM" quantum="1M"/>
!  <provides> <service name="I2c"/> </provides>
!
!  <config bus_no="2" verbose="yes">
!    <policy label_prefix="MCP_9808"  bus_address="0x18"/>
!  </config>
!
!  <route>
!    <any-service> <parent/> <any-child/> </any-service>
!  </route>
!</start>

The driver's config must contain the 'bus_no' (bus number) attribute,
'bus_no="2"' for bus 2. And device(s) policy with two attributes
'label_prefix' and 'bus_address' which is an address of a slave
device on the bus. A 'verbose' boolean attribute might be specified
if you want the driver to log error messages.

Example
=======

An example of how to use the I2C driver can be found in the test
script 'os/run/i2c_mcp9808.run'.