xref: /openbmc/linux/Documentation/driver-api/slimbus.rst (revision 3eb66e91a25497065c5322b1268cbc3953642227)
1202318d3SSagar Dharia============================
2202318d3SSagar DhariaLinux kernel SLIMbus support
3202318d3SSagar Dharia============================
4202318d3SSagar Dharia
5202318d3SSagar DhariaOverview
6202318d3SSagar Dharia========
7202318d3SSagar Dharia
8202318d3SSagar DhariaWhat is SLIMbus?
9202318d3SSagar Dharia----------------
10202318d3SSagar DhariaSLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by
11202318d3SSagar DhariaMIPI (Mobile Industry Processor Interface) alliance. The bus uses master/slave
12202318d3SSagar Dhariaconfiguration, and is a 2-wire multi-drop implementation (clock, and data).
13202318d3SSagar Dharia
14202318d3SSagar DhariaCurrently, SLIMbus is used to interface between application processors of SoCs
15202318d3SSagar Dharia(System-on-Chip) and peripheral components (typically codec). SLIMbus uses
16202318d3SSagar DhariaTime-Division-Multiplexing to accommodate multiple data channels, and
17202318d3SSagar Dhariaa control channel.
18202318d3SSagar Dharia
19202318d3SSagar DhariaThe control channel is used for various control functions such as bus
20202318d3SSagar Dhariamanagement, configuration and status updates. These messages can be unicast (e.g.
21202318d3SSagar Dhariareading/writing device specific values), or multicast (e.g. data channel
22202318d3SSagar Dhariareconfiguration sequence is a broadcast message announced to all devices)
23202318d3SSagar Dharia
24202318d3SSagar DhariaA data channel is used for data-transfer between 2 SLIMbus devices. Data
25202318d3SSagar Dhariachannel uses dedicated ports on the device.
26202318d3SSagar Dharia
27202318d3SSagar DhariaHardware description:
28202318d3SSagar Dharia---------------------
29202318d3SSagar DhariaSLIMbus specification has different types of device classifications based on
30202318d3SSagar Dhariatheir capabilities.
31202318d3SSagar DhariaA manager device is responsible for enumeration, configuration, and dynamic
32202318d3SSagar Dhariachannel allocation. Every bus has 1 active manager.
33202318d3SSagar Dharia
34202318d3SSagar DhariaA generic device is a device providing application functionality (e.g. codec).
35202318d3SSagar Dharia
36202318d3SSagar DhariaFramer device is responsible for clocking the bus, and transmitting frame-sync
37202318d3SSagar Dhariaand framing information on the bus.
38202318d3SSagar Dharia
39202318d3SSagar DhariaEach SLIMbus component has an interface device for monitoring physical layer.
40202318d3SSagar Dharia
41202318d3SSagar DhariaTypically each SoC contains SLIMbus component having 1 manager, 1 framer device,
42202318d3SSagar Dharia1 generic device (for data channel support), and 1 interface device.
43202318d3SSagar DhariaExternal peripheral SLIMbus component usually has 1 generic device (for
44202318d3SSagar Dhariafunctionality/data channel support), and an associated interface device.
45202318d3SSagar DhariaThe generic device's registers are mapped as 'value elements' so that they can
46202318d3SSagar Dhariabe written/read using SLIMbus control channel exchanging control/status type of
47202318d3SSagar Dhariainformation.
48202318d3SSagar DhariaIn case there are multiple framer devices on the same bus, manager device is
49202318d3SSagar Dhariaresponsible to select the active-framer for clocking the bus.
50202318d3SSagar Dharia
51202318d3SSagar DhariaPer specification, SLIMbus uses "clock gears" to do power management based on
52202318d3SSagar Dhariacurrent frequency and bandwidth requirements. There are 10 clock gears and each
53202318d3SSagar Dhariagear changes the SLIMbus frequency to be twice its previous gear.
54202318d3SSagar Dharia
55202318d3SSagar DhariaEach device has a 6-byte enumeration-address and the manager assigns every
56202318d3SSagar Dhariadevice with a 1-byte logical address after the devices report presence on the
57202318d3SSagar Dhariabus.
58202318d3SSagar Dharia
59202318d3SSagar DhariaSoftware description:
60202318d3SSagar Dharia---------------------
61202318d3SSagar DhariaThere are 2 types of SLIMbus drivers:
62202318d3SSagar Dharia
63202318d3SSagar Dhariaslim_controller represents a 'controller' for SLIMbus. This driver should
64202318d3SSagar Dhariaimplement duties needed by the SoC (manager device, associated
65202318d3SSagar Dhariainterface device for monitoring the layers and reporting errors, default
66202318d3SSagar Dhariaframer device).
67202318d3SSagar Dharia
68202318d3SSagar Dhariaslim_device represents the 'generic device/component' for SLIMbus, and a
69202318d3SSagar Dhariaslim_driver should implement driver for that slim_device.
70202318d3SSagar Dharia
71202318d3SSagar DhariaDevice notifications to the driver:
72202318d3SSagar Dharia-----------------------------------
73202318d3SSagar DhariaSince SLIMbus devices have mechanisms for reporting their presence, the
74202318d3SSagar Dhariaframework allows drivers to bind when corresponding devices report their
75202318d3SSagar Dhariapresence on the bus.
76202318d3SSagar DhariaHowever, it is possible that the driver needs to be probed
77202318d3SSagar Dhariafirst so that it can enable corresponding SLIMbus device (e.g. power it up and/or
78202318d3SSagar Dhariatake it out of reset). To support that behavior, the framework allows drivers
79202318d3SSagar Dhariato probe first as well  (e.g. using standard DeviceTree compatibility field).
80202318d3SSagar DhariaThis creates the necessity for the driver to know when the device is functional
81202318d3SSagar Dharia(i.e. reported present). device_up callback is used for that reason when the
82202318d3SSagar Dhariadevice reports present and is assigned a logical address by the controller.
83202318d3SSagar Dharia
84202318d3SSagar DhariaSimilarly, SLIMbus devices 'report absent' when they go down. A 'device_down'
85202318d3SSagar Dhariacallback notifies the driver when the device reports absent and its logical
86202318d3SSagar Dhariaaddress assignment is invalidated by the controller.
87202318d3SSagar Dharia
88202318d3SSagar DhariaAnother notification "boot_device" is used to notify the slim_driver when
89202318d3SSagar Dhariacontroller resets the bus. This notification allows the driver to take necessary
90202318d3SSagar Dhariasteps to boot the device so that it's functional after the bus has been reset.
91202318d3SSagar Dharia
92202318d3SSagar DhariaDriver and Controller APIs:
93281a7af8SMasanari Iida---------------------------
94202318d3SSagar Dharia.. kernel-doc:: include/linux/slimbus.h
95202318d3SSagar Dharia   :internal:
96202318d3SSagar Dharia
97202318d3SSagar Dharia.. kernel-doc:: drivers/slimbus/slimbus.h
98202318d3SSagar Dharia   :internal:
99202318d3SSagar Dharia
100202318d3SSagar Dharia.. kernel-doc:: drivers/slimbus/core.c
101202318d3SSagar Dharia   :export:
102202318d3SSagar Dharia
103202318d3SSagar DhariaClock-pause:
104202318d3SSagar Dharia------------
105202318d3SSagar DhariaSLIMbus mandates that a reconfiguration sequence (known as clock-pause) be
106202318d3SSagar Dhariabroadcast to all active devices on the bus before the bus can enter low-power
107202318d3SSagar Dhariamode. Controller uses this sequence when it decides to enter low-power mode so
108202318d3SSagar Dhariathat corresponding clocks and/or power-rails can be turned off to save power.
109202318d3SSagar DhariaClock-pause is exited by waking up framer device (if controller driver initiates
110202318d3SSagar Dhariaexiting low power mode), or by toggling the data line (if a slave device wants
111202318d3SSagar Dhariato initiate it).
112202318d3SSagar Dharia
113202318d3SSagar DhariaClock-pause APIs:
114202318d3SSagar Dharia~~~~~~~~~~~~~~~~~
115202318d3SSagar Dharia.. kernel-doc:: drivers/slimbus/sched.c
116202318d3SSagar Dharia   :export:
117202318d3SSagar Dharia
118202318d3SSagar DhariaMessaging:
119202318d3SSagar Dharia----------
120202318d3SSagar DhariaThe framework supports regmap and read/write apis to exchange control-information
121202318d3SSagar Dhariawith a SLIMbus device. APIs can be synchronous or asynchronous.
122202318d3SSagar DhariaThe header file <linux/slimbus.h> has more documentation about messaging APIs.
123202318d3SSagar Dharia
124202318d3SSagar DhariaMessaging APIs:
125202318d3SSagar Dharia~~~~~~~~~~~~~~~
126202318d3SSagar Dharia.. kernel-doc:: drivers/slimbus/messaging.c
127202318d3SSagar Dharia   :export:
128*abb9c9b8SSrinivas Kandagatla
129*abb9c9b8SSrinivas KandagatlaStreaming APIs:
130*abb9c9b8SSrinivas Kandagatla~~~~~~~~~~~~~~~
131*abb9c9b8SSrinivas Kandagatla.. kernel-doc:: drivers/slimbus/stream.c
132*abb9c9b8SSrinivas Kandagatla   :export:
133