18c2ecf20Sopenharmony_ciFSI bus & engine generic device tree bindings
28c2ecf20Sopenharmony_ci=============================================
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciThe FSI bus is probe-able, so the OS is able to enumerate FSI slaves, and
58c2ecf20Sopenharmony_ciengines within those slaves. However, we have a facility to match devicetree
68c2ecf20Sopenharmony_cinodes to probed engines. This allows for fsi engines to expose non-probeable
78c2ecf20Sopenharmony_cibusses, which are then exposed by the device tree. For example, an FSI engine
88c2ecf20Sopenharmony_cithat is an I2C master - the I2C bus can be described by the device tree under
98c2ecf20Sopenharmony_cithe engine's device tree node.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciFSI masters may require their own DT nodes (to describe the master HW itself);
128c2ecf20Sopenharmony_cithat requirement is defined by the master's implementation, and is described by
138c2ecf20Sopenharmony_cithe fsi-master-* binding specifications.
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciUnder the masters' nodes, we can describe the bus topology using nodes to
168c2ecf20Sopenharmony_cirepresent the FSI slaves and their slave engines. As a basic outline:
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci  fsi-master {
198c2ecf20Sopenharmony_ci      /* top-level of FSI bus topology, bound to an FSI master driver and
208c2ecf20Sopenharmony_ci       * exposes an FSI bus */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci      fsi-slave@<link,id> {
238c2ecf20Sopenharmony_ci          /* this node defines the FSI slave device, and is handled
248c2ecf20Sopenharmony_ci           * entirely with FSI core code */
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci          fsi-slave-engine@<addr> {
278c2ecf20Sopenharmony_ci              /* this node defines the engine endpoint & address range, which
288c2ecf20Sopenharmony_ci               * is bound to the relevant fsi device driver */
298c2ecf20Sopenharmony_ci               ...
308c2ecf20Sopenharmony_ci          };
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci          fsi-slave-engine@<addr> {
338c2ecf20Sopenharmony_ci              ...
348c2ecf20Sopenharmony_ci          };
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci      };
378c2ecf20Sopenharmony_ci  };
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciNote that since the bus is probe-able, some (or all) of the topology may
408c2ecf20Sopenharmony_cinot be described; this binding only provides an optional facility for
418c2ecf20Sopenharmony_ciadding subordinate device tree nodes as children of FSI engines.
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciFSI masters
448c2ecf20Sopenharmony_ci-----------
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciFSI master nodes declare themselves as such with the "fsi-master" compatible
478c2ecf20Sopenharmony_civalue. It's likely that an implementation-specific compatible value will
488c2ecf20Sopenharmony_cibe needed as well, for example:
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci    compatible = "fsi-master-gpio", "fsi-master";
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciSince the master nodes describe the top-level of the FSI topology, they also
538c2ecf20Sopenharmony_cineed to declare the FSI-standard addressing scheme. This requires two cells for
548c2ecf20Sopenharmony_ciaddresses (link index and slave ID), and no size:
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci    #address-cells = <2>;
578c2ecf20Sopenharmony_ci    #size-cells = <0>;
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciAn optional boolean property can be added to indicate that a particular master
608c2ecf20Sopenharmony_cishould not scan for connected devices at initialization time.  This is
618c2ecf20Sopenharmony_cinecessary in cases where a scan could cause arbitration issues with other
628c2ecf20Sopenharmony_cimasters that may be present on the bus.
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci    no-scan-on-init;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciFSI slaves
678c2ecf20Sopenharmony_ci----------
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciSlaves are identified by a (link-index, slave-id) pair, so require two cells
708c2ecf20Sopenharmony_cifor an address identifier. Since these are not a range, no size cells are
718c2ecf20Sopenharmony_cirequired. For an example, a slave on link 1, with ID 2, could be represented
728c2ecf20Sopenharmony_cias:
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci    cfam@1,2 {
758c2ecf20Sopenharmony_ci        reg = <1 2>;
768c2ecf20Sopenharmony_ci	[...];
778c2ecf20Sopenharmony_ci    }
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciEach slave provides an address-space, under which the engines are accessible.
808c2ecf20Sopenharmony_ciThat address space has a maximum of 23 bits, so we use one cell to represent
818c2ecf20Sopenharmony_ciaddresses and sizes in the slave address space:
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci    #address-cells = <1>;
848c2ecf20Sopenharmony_ci    #size-cells = <1>;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciOptionally, a slave can provide a global unique chip ID which is used to
878c2ecf20Sopenharmony_ciidentify the physical location of the chip in a system specific way
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci    chip-id = <0>;
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciFSI engines (devices)
928c2ecf20Sopenharmony_ci---------------------
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciEngines are identified by their address under the slaves' address spaces. We
958c2ecf20Sopenharmony_ciuse a single cell for address and size. Engine nodes represent the endpoint
968c2ecf20Sopenharmony_ciFSI device, and are passed to those FSI device drivers' ->probe() functions.
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ciFor example, for a slave using a single 0x400-byte page starting at address
998c2ecf20Sopenharmony_ci0xc00:
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci    engine@c00 {
1028c2ecf20Sopenharmony_ci        reg = <0xc00 0x400>;
1038c2ecf20Sopenharmony_ci    };
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciFull example
1078c2ecf20Sopenharmony_ci------------
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciHere's an example that illustrates:
1108c2ecf20Sopenharmony_ci - an FSI master
1118c2ecf20Sopenharmony_ci   - connected to an FSI slave
1128c2ecf20Sopenharmony_ci     - that contains an engine that is an I2C master
1138c2ecf20Sopenharmony_ci       - connected to an I2C EEPROM
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciThe FSI master may be connected to additional slaves, and slaves may have
1168c2ecf20Sopenharmony_ciadditional engines, but they don't necessarily need to be describe in the
1178c2ecf20Sopenharmony_cidevice tree if no extra platform information is required.
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci    /* The GPIO-based FSI master node, describing the top level of the
1208c2ecf20Sopenharmony_ci     * FSI bus
1218c2ecf20Sopenharmony_ci     */
1228c2ecf20Sopenharmony_ci    gpio-fsi {
1238c2ecf20Sopenharmony_ci        compatible = "fsi-master-gpio", "fsi-master";
1248c2ecf20Sopenharmony_ci        #address-cells = <2>;
1258c2ecf20Sopenharmony_ci        #size-cells = <0>;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci        /* A FSI slave (aka. CFAM) at link 0, ID 0. */
1288c2ecf20Sopenharmony_ci        cfam@0,0 {
1298c2ecf20Sopenharmony_ci            reg = <0 0>;
1308c2ecf20Sopenharmony_ci            #address-cells = <1>;
1318c2ecf20Sopenharmony_ci            #size-cells = <1>;
1328c2ecf20Sopenharmony_ci	    chip-id = <0>;
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci            /* FSI engine at 0xc00, using a single page. In this example,
1358c2ecf20Sopenharmony_ci             * it's an I2C master controller, so subnodes describe the
1368c2ecf20Sopenharmony_ci             * I2C bus.
1378c2ecf20Sopenharmony_ci             */
1388c2ecf20Sopenharmony_ci            i2c-controller@c00 {
1398c2ecf20Sopenharmony_ci                reg = <0xc00 0x400>;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci                /* Engine-specific data. In this case, we're describing an
1428c2ecf20Sopenharmony_ci                 * I2C bus, so we're conforming to the generic I2C binding
1438c2ecf20Sopenharmony_ci                 */
1448c2ecf20Sopenharmony_ci                compatible = "some-vendor,fsi-i2c-controller";
1458c2ecf20Sopenharmony_ci                #address-cells = <1>;
1468c2ecf20Sopenharmony_ci                #size-cells = <1>;
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci                /* I2C endpoint device: an Atmel EEPROM */
1498c2ecf20Sopenharmony_ci                eeprom@50 {
1508c2ecf20Sopenharmony_ci                    compatible = "atmel,24c256";
1518c2ecf20Sopenharmony_ci                    reg = <0x50>;
1528c2ecf20Sopenharmony_ci                    pagesize = <64>;
1538c2ecf20Sopenharmony_ci                };
1548c2ecf20Sopenharmony_ci            };
1558c2ecf20Sopenharmony_ci        };
1568c2ecf20Sopenharmony_ci    };
157