docs: networking: convert caif files to ReST
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 27 Apr 2020 22:01:16 +0000 (00:01 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 28 Apr 2020 21:38:38 +0000 (14:38 -0700)
There are two text files for caif, plus one already converted
file.

Convert the two remaining ones to ReST, create a new index.rst
file for CAIF, adding it to the main networking documentation
index.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/networking/caif/Linux-CAIF.txt [deleted file]
Documentation/networking/caif/caif.rst
Documentation/networking/caif/index.rst [new file with mode: 0644]
Documentation/networking/caif/linux_caif.rst [new file with mode: 0644]
Documentation/networking/caif/spi_porting.rst [new file with mode: 0644]
Documentation/networking/caif/spi_porting.txt [deleted file]
Documentation/networking/index.rst
drivers/net/caif/Kconfig

diff --git a/Documentation/networking/caif/Linux-CAIF.txt b/Documentation/networking/caif/Linux-CAIF.txt
deleted file mode 100644 (file)
index 0aa4bd3..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-Linux CAIF
-===========
-copyright (C) ST-Ericsson AB 2010
-Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
-License terms: GNU General Public License (GPL) version 2
-
-
-Introduction
-------------
-CAIF is a MUX protocol used by ST-Ericsson cellular modems for
-communication between Modem and host. The host processes can open virtual AT
-channels, initiate GPRS Data connections, Video channels and Utility Channels.
-The Utility Channels are general purpose pipes between modem and host.
-
-ST-Ericsson modems support a number of transports between modem
-and host. Currently, UART and Loopback are available for Linux.
-
-
-Architecture:
-------------
-The implementation of CAIF is divided into:
-* CAIF Socket Layer and GPRS IP Interface.
-* CAIF Core Protocol Implementation
-* CAIF Link Layer, implemented as NET devices.
-
-
-  RTNL
-   !
-   !         +------+   +------+
-   !        +------+!  +------+!
-   !        !  IP  !!  !Socket!!
-   +-------> !interf!+ ! API  !+       <- CAIF Client APIs
-   !        +------+   +------!
-   !           !           !
-   !           +-----------+
-   !                 !
-   !              +------+             <- CAIF Core Protocol
-   !              ! CAIF !
-   !              ! Core !
-   !              +------+
-   !      +----------!---------+
-   !      !          !         !
-   !   +------+   +-----+   +------+
-   +--> ! HSI  !   ! TTY !   ! USB  !  <- Link Layer (Net Devices)
-       +------+   +-----+   +------+
-
-
-
-I M P L E M E N T A T I O N
-===========================
-
-
-CAIF Core Protocol Layer
-=========================================
-
-CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
-It implements the CAIF protocol stack in a layered approach, where
-each layer described in the specification is implemented as a separate layer.
-The architecture is inspired by the design patterns "Protocol Layer" and
-"Protocol Packet".
-
-== CAIF structure ==
-The Core CAIF implementation contains:
-      -        Simple implementation of CAIF.
-      -        Layered architecture (a la Streams), each layer in the CAIF
-       specification is implemented in a separate c-file.
-      -        Clients must call configuration function to add PHY layer.
-      -        Clients must implement CAIF layer to consume/produce
-       CAIF payload with receive and transmit functions.
-      -        Clients must call configuration function to add and connect the
-       Client layer.
-      - When receiving / transmitting CAIF Packets (cfpkt), ownership is passed
-       to the called function (except for framing layers' receive function)
-
-Layered Architecture
---------------------
-The CAIF protocol can be divided into two parts: Support functions and Protocol
-Implementation. The support functions include:
-
-      - CFPKT CAIF Packet. Implementation of CAIF Protocol Packet. The
-       CAIF Packet has functions for creating, destroying and adding content
-       and for adding/extracting header and trailers to protocol packets.
-
-The CAIF Protocol implementation contains:
-
-      - CFCNFG CAIF Configuration layer. Configures the CAIF Protocol
-       Stack and provides a Client interface for adding Link-Layer and
-       Driver interfaces on top of the CAIF Stack.
-
-      - CFCTRL CAIF Control layer. Encodes and Decodes control messages
-       such as enumeration and channel setup. Also matches request and
-       response messages.
-
-      - CFSERVL General CAIF Service Layer functionality; handles flow
-       control and remote shutdown requests.
-
-      - CFVEI CAIF VEI layer. Handles CAIF AT Channels on VEI (Virtual
-       External Interface). This layer encodes/decodes VEI frames.
-
-      - CFDGML CAIF Datagram layer. Handles CAIF Datagram layer (IP
-       traffic), encodes/decodes Datagram frames.
-
-      - CFMUX CAIF Mux layer. Handles multiplexing between multiple
-       physical bearers and multiple channels such as VEI, Datagram, etc.
-       The MUX keeps track of the existing CAIF Channels and
-       Physical Instances and selects the appropriate instance based
-       on Channel-Id and Physical-ID.
-
-      - CFFRML CAIF Framing layer. Handles Framing i.e. Frame length
-       and frame checksum.
-
-      - CFSERL CAIF Serial layer. Handles concatenation/split of frames
-       into CAIF Frames with correct length.
-
-
-
-                   +---------+
-                   | Config  |
-                   | CFCNFG  |
-                   +---------+
-                        !
-    +---------+            +---------+     +---------+
-    |  AT    |     | Control |     | Datagram|
-    | CFVEIL  |            | CFCTRL  |     | CFDGML  |
-    +---------+            +---------+     +---------+
-          \_____________!______________/
-                        !
-                   +---------+
-                   |   MUX   |
-                   |         |
-                   +---------+
-                   _____!_____
-                  /           \
-           +---------+     +---------+
-           | CFFRML  |     | CFFRML  |
-           | Framing |     | Framing |
-           +---------+     +---------+
-                !              !
-           +---------+     +---------+
-           |         |     | Serial  |
-           |         |     | CFSERL  |
-           +---------+     +---------+
-
-
-In this layered approach the following "rules" apply.
-      - All layers embed the same structure "struct cflayer"
-      - A layer does not depend on any other layer's private data.
-      - Layers are stacked by setting the pointers
-                 layer->up , layer->dn
-      -        In order to send data upwards, each layer should do
-                layer->up->receive(layer->up, packet);
-      - In order to send data downwards, each layer should do
-                layer->dn->transmit(layer->dn, packet);
-
-
-CAIF Socket and IP interface
-===========================
-
-The IP interface and CAIF socket API are implemented on top of the
-CAIF Core protocol. The IP Interface and CAIF socket have an instance of
-'struct cflayer', just like the CAIF Core protocol stack.
-Net device and Socket implement the 'receive()' function defined by
-'struct cflayer', just like the rest of the CAIF stack. In this way, transmit and
-receive of packets is handled as by the rest of the layers: the 'dn->transmit()'
-function is called in order to transmit data.
-
-Configuration of Link Layer
----------------------------
-The Link Layer is implemented as Linux network devices (struct net_device).
-Payload handling and registration is done using standard Linux mechanisms.
-
-The CAIF Protocol relies on a loss-less link layer without implementing
-retransmission. This implies that packet drops must not happen.
-Therefore a flow-control mechanism is implemented where the physical
-interface can initiate flow stop for all CAIF Channels.
index 07afc8063d4d54ec286d4d3273256e082c351aa1..a07213030ccf547d9e11a5269d9fa4af5219581f 100644 (file)
@@ -1,5 +1,3 @@
-:orphan:
-
 .. SPDX-License-Identifier: GPL-2.0
 .. include:: <isonum.txt>
 
diff --git a/Documentation/networking/caif/index.rst b/Documentation/networking/caif/index.rst
new file mode 100644 (file)
index 0000000..86e5b78
--- /dev/null
@@ -0,0 +1,13 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+CAIF
+====
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   linux_caif
+   caif
+   spi_porting
diff --git a/Documentation/networking/caif/linux_caif.rst b/Documentation/networking/caif/linux_caif.rst
new file mode 100644 (file)
index 0000000..a048086
--- /dev/null
@@ -0,0 +1,195 @@
+.. SPDX-License-Identifier: GPL-2.0
+.. include:: <isonum.txt>
+
+==========
+Linux CAIF
+==========
+
+Copyright |copy| ST-Ericsson AB 2010
+
+:Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
+:License terms: GNU General Public License (GPL) version 2
+
+
+Introduction
+============
+
+CAIF is a MUX protocol used by ST-Ericsson cellular modems for
+communication between Modem and host. The host processes can open virtual AT
+channels, initiate GPRS Data connections, Video channels and Utility Channels.
+The Utility Channels are general purpose pipes between modem and host.
+
+ST-Ericsson modems support a number of transports between modem
+and host. Currently, UART and Loopback are available for Linux.
+
+
+Architecture
+============
+
+The implementation of CAIF is divided into:
+
+* CAIF Socket Layer and GPRS IP Interface.
+* CAIF Core Protocol Implementation
+* CAIF Link Layer, implemented as NET devices.
+
+::
+
+  RTNL
+   !
+   !         +------+   +------+
+   !        +------+!  +------+!
+   !        !  IP  !!  !Socket!!
+   +-------> !interf!+ ! API  !+       <- CAIF Client APIs
+   !        +------+   +------!
+   !           !           !
+   !           +-----------+
+   !                 !
+   !              +------+             <- CAIF Core Protocol
+   !              ! CAIF !
+   !              ! Core !
+   !              +------+
+   !      +----------!---------+
+   !      !          !         !
+   !   +------+   +-----+   +------+
+   +--> ! HSI  !   ! TTY !   ! USB  !  <- Link Layer (Net Devices)
+       +------+   +-----+   +------+
+
+
+
+Implementation
+==============
+
+
+CAIF Core Protocol Layer
+------------------------
+
+CAIF Core layer implements the CAIF protocol as defined by ST-Ericsson.
+It implements the CAIF protocol stack in a layered approach, where
+each layer described in the specification is implemented as a separate layer.
+The architecture is inspired by the design patterns "Protocol Layer" and
+"Protocol Packet".
+
+CAIF structure
+^^^^^^^^^^^^^^
+
+The Core CAIF implementation contains:
+
+      -        Simple implementation of CAIF.
+      -        Layered architecture (a la Streams), each layer in the CAIF
+       specification is implemented in a separate c-file.
+      -        Clients must call configuration function to add PHY layer.
+      -        Clients must implement CAIF layer to consume/produce
+       CAIF payload with receive and transmit functions.
+      -        Clients must call configuration function to add and connect the
+       Client layer.
+      - When receiving / transmitting CAIF Packets (cfpkt), ownership is passed
+       to the called function (except for framing layers' receive function)
+
+Layered Architecture
+====================
+
+The CAIF protocol can be divided into two parts: Support functions and Protocol
+Implementation. The support functions include:
+
+      - CFPKT CAIF Packet. Implementation of CAIF Protocol Packet. The
+       CAIF Packet has functions for creating, destroying and adding content
+       and for adding/extracting header and trailers to protocol packets.
+
+The CAIF Protocol implementation contains:
+
+      - CFCNFG CAIF Configuration layer. Configures the CAIF Protocol
+       Stack and provides a Client interface for adding Link-Layer and
+       Driver interfaces on top of the CAIF Stack.
+
+      - CFCTRL CAIF Control layer. Encodes and Decodes control messages
+       such as enumeration and channel setup. Also matches request and
+       response messages.
+
+      - CFSERVL General CAIF Service Layer functionality; handles flow
+       control and remote shutdown requests.
+
+      - CFVEI CAIF VEI layer. Handles CAIF AT Channels on VEI (Virtual
+       External Interface). This layer encodes/decodes VEI frames.
+
+      - CFDGML CAIF Datagram layer. Handles CAIF Datagram layer (IP
+       traffic), encodes/decodes Datagram frames.
+
+      - CFMUX CAIF Mux layer. Handles multiplexing between multiple
+       physical bearers and multiple channels such as VEI, Datagram, etc.
+       The MUX keeps track of the existing CAIF Channels and
+       Physical Instances and selects the appropriate instance based
+       on Channel-Id and Physical-ID.
+
+      - CFFRML CAIF Framing layer. Handles Framing i.e. Frame length
+       and frame checksum.
+
+      - CFSERL CAIF Serial layer. Handles concatenation/split of frames
+       into CAIF Frames with correct length.
+
+::
+
+                   +---------+
+                   | Config  |
+                   | CFCNFG  |
+                   +---------+
+                        !
+    +---------+            +---------+     +---------+
+    |  AT    |     | Control |     | Datagram|
+    | CFVEIL  |            | CFCTRL  |     | CFDGML  |
+    +---------+            +---------+     +---------+
+          \_____________!______________/
+                        !
+                   +---------+
+                   |   MUX   |
+                   |         |
+                   +---------+
+                   _____!_____
+                  /           \
+           +---------+     +---------+
+           | CFFRML  |     | CFFRML  |
+           | Framing |     | Framing |
+           +---------+     +---------+
+                !              !
+           +---------+     +---------+
+           |         |     | Serial  |
+           |         |     | CFSERL  |
+           +---------+     +---------+
+
+
+In this layered approach the following "rules" apply.
+
+      - All layers embed the same structure "struct cflayer"
+      - A layer does not depend on any other layer's private data.
+      - Layers are stacked by setting the pointers::
+
+                 layer->up , layer->dn
+
+      -        In order to send data upwards, each layer should do::
+
+                layer->up->receive(layer->up, packet);
+
+      - In order to send data downwards, each layer should do::
+
+                layer->dn->transmit(layer->dn, packet);
+
+
+CAIF Socket and IP interface
+============================
+
+The IP interface and CAIF socket API are implemented on top of the
+CAIF Core protocol. The IP Interface and CAIF socket have an instance of
+'struct cflayer', just like the CAIF Core protocol stack.
+Net device and Socket implement the 'receive()' function defined by
+'struct cflayer', just like the rest of the CAIF stack. In this way, transmit and
+receive of packets is handled as by the rest of the layers: the 'dn->transmit()'
+function is called in order to transmit data.
+
+Configuration of Link Layer
+---------------------------
+The Link Layer is implemented as Linux network devices (struct net_device).
+Payload handling and registration is done using standard Linux mechanisms.
+
+The CAIF Protocol relies on a loss-less link layer without implementing
+retransmission. This implies that packet drops must not happen.
+Therefore a flow-control mechanism is implemented where the physical
+interface can initiate flow stop for all CAIF Channels.
diff --git a/Documentation/networking/caif/spi_porting.rst b/Documentation/networking/caif/spi_porting.rst
new file mode 100644 (file)
index 0000000..d49f874
--- /dev/null
@@ -0,0 +1,229 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+================
+CAIF SPI porting
+================
+
+CAIF SPI basics
+===============
+
+Running CAIF over SPI needs some extra setup, owing to the nature of SPI.
+Two extra GPIOs have been added in order to negotiate the transfers
+between the master and the slave. The minimum requirement for running
+CAIF over SPI is a SPI slave chip and two GPIOs (more details below).
+Please note that running as a slave implies that you need to keep up
+with the master clock. An overrun or underrun event is fatal.
+
+CAIF SPI framework
+==================
+
+To make porting as easy as possible, the CAIF SPI has been divided in
+two parts. The first part (called the interface part) deals with all
+generic functionality such as length framing, SPI frame negotiation
+and SPI frame delivery and transmission. The other part is the CAIF
+SPI slave device part, which is the module that you have to write if
+you want to run SPI CAIF on a new hardware. This part takes care of
+the physical hardware, both with regard to SPI and to GPIOs.
+
+- Implementing a CAIF SPI device:
+
+       - Functionality provided by the CAIF SPI slave device:
+
+       In order to implement a SPI device you will, as a minimum,
+       need to implement the following
+       functions:
+
+       ::
+
+           int (*init_xfer) (struct cfspi_xfer * xfer, struct cfspi_dev *dev):
+
+       This function is called by the CAIF SPI interface to give
+       you a chance to set up your hardware to be ready to receive
+       a stream of data from the master. The xfer structure contains
+       both physical and logical addresses, as well as the total length
+       of the transfer in both directions.The dev parameter can be used
+       to map to different CAIF SPI slave devices.
+
+       ::
+
+           void (*sig_xfer) (bool xfer, struct cfspi_dev *dev):
+
+       This function is called by the CAIF SPI interface when the output
+       (SPI_INT) GPIO needs to change state. The boolean value of the xfer
+       variable indicates whether the GPIO should be asserted (HIGH) or
+       deasserted (LOW). The dev parameter can be used to map to different CAIF
+       SPI slave devices.
+
+       - Functionality provided by the CAIF SPI interface:
+
+       ::
+
+           void (*ss_cb) (bool assert, struct cfspi_ifc *ifc);
+
+       This function is called by the CAIF SPI slave device in order to
+       signal a change of state of the input GPIO (SS) to the interface.
+       Only active edges are mandatory to be reported.
+       This function can be called from IRQ context (recommended in order
+       not to introduce latency). The ifc parameter should be the pointer
+       returned from the platform probe function in the SPI device structure.
+
+       ::
+
+           void (*xfer_done_cb) (struct cfspi_ifc *ifc);
+
+       This function is called by the CAIF SPI slave device in order to
+       report that a transfer is completed. This function should only be
+       called once both the transmission and the reception are completed.
+       This function can be called from IRQ context (recommended in order
+       not to introduce latency). The ifc parameter should be the pointer
+       returned from the platform probe function in the SPI device structure.
+
+       - Connecting the bits and pieces:
+
+               - Filling in the SPI slave device structure:
+
+                 Connect the necessary callback functions.
+
+                 Indicate clock speed (used to calculate toggle delays).
+
+                 Chose a suitable name (helps debugging if you use several CAIF
+                 SPI slave devices).
+
+                 Assign your private data (can be used to map to your
+                 structure).
+
+               - Filling in the SPI slave platform device structure:
+
+                 Add name of driver to connect to ("cfspi_sspi").
+
+                 Assign the SPI slave device structure as platform data.
+
+Padding
+=======
+
+In order to optimize throughput, a number of SPI padding options are provided.
+Padding can be enabled independently for uplink and downlink transfers.
+Padding can be enabled for the head, the tail and for the total frame size.
+The padding needs to be correctly configured on both sides of the link.
+The padding can be changed via module parameters in cfspi_sspi.c or via
+the sysfs directory of the cfspi_sspi driver (before device registration).
+
+- CAIF SPI device template::
+
+    /*
+    *  Copyright (C) ST-Ericsson AB 2010
+    *  Author: Daniel Martensson / Daniel.Martensson@stericsson.com
+    *  License terms: GNU General Public License (GPL), version 2.
+    *
+    */
+
+    #include <linux/init.h>
+    #include <linux/module.h>
+    #include <linux/device.h>
+    #include <linux/wait.h>
+    #include <linux/interrupt.h>
+    #include <linux/dma-mapping.h>
+    #include <net/caif/caif_spi.h>
+
+    MODULE_LICENSE("GPL");
+
+    struct sspi_struct {
+           struct cfspi_dev sdev;
+           struct cfspi_xfer *xfer;
+    };
+
+    static struct sspi_struct slave;
+    static struct platform_device slave_device;
+
+    static irqreturn_t sspi_irq(int irq, void *arg)
+    {
+           /* You only need to trigger on an edge to the active state of the
+           * SS signal. Once a edge is detected, the ss_cb() function should be
+           * called with the parameter assert set to true. It is OK
+           * (and even advised) to call the ss_cb() function in IRQ context in
+           * order not to add any delay. */
+
+           return IRQ_HANDLED;
+    }
+
+    static void sspi_complete(void *context)
+    {
+           /* Normally the DMA or the SPI framework will call you back
+           * in something similar to this. The only thing you need to
+           * do is to call the xfer_done_cb() function, providing the pointer
+           * to the CAIF SPI interface. It is OK to call this function
+           * from IRQ context. */
+    }
+
+    static int sspi_init_xfer(struct cfspi_xfer *xfer, struct cfspi_dev *dev)
+    {
+           /* Store transfer info. For a normal implementation you should
+           * set up your DMA here and make sure that you are ready to
+           * receive the data from the master SPI. */
+
+           struct sspi_struct *sspi = (struct sspi_struct *)dev->priv;
+
+           sspi->xfer = xfer;
+
+           return 0;
+    }
+
+    void sspi_sig_xfer(bool xfer, struct cfspi_dev *dev)
+    {
+           /* If xfer is true then you should assert the SPI_INT to indicate to
+           * the master that you are ready to receive the data from the master
+           * SPI. If xfer is false then you should de-assert SPI_INT to indicate
+           * that the transfer is done.
+           */
+
+           struct sspi_struct *sspi = (struct sspi_struct *)dev->priv;
+    }
+
+    static void sspi_release(struct device *dev)
+    {
+           /*
+           * Here you should release your SPI device resources.
+           */
+    }
+
+    static int __init sspi_init(void)
+    {
+           /* Here you should initialize your SPI device by providing the
+           * necessary functions, clock speed, name and private data. Once
+           * done, you can register your device with the
+           * platform_device_register() function. This function will return
+           * with the CAIF SPI interface initialized. This is probably also
+           * the place where you should set up your GPIOs, interrupts and SPI
+           * resources. */
+
+           int res = 0;
+
+           /* Initialize slave device. */
+           slave.sdev.init_xfer = sspi_init_xfer;
+           slave.sdev.sig_xfer = sspi_sig_xfer;
+           slave.sdev.clk_mhz = 13;
+           slave.sdev.priv = &slave;
+           slave.sdev.name = "spi_sspi";
+           slave_device.dev.release = sspi_release;
+
+           /* Initialize platform device. */
+           slave_device.name = "cfspi_sspi";
+           slave_device.dev.platform_data = &slave.sdev;
+
+           /* Register platform device. */
+           res = platform_device_register(&slave_device);
+           if (res) {
+                   printk(KERN_WARNING "sspi_init: failed to register dev.\n");
+                   return -ENODEV;
+           }
+
+           return res;
+    }
+
+    static void __exit sspi_exit(void)
+    {
+           platform_device_del(&slave_device);
+    }
+
+    module_init(sspi_init);
+    module_exit(sspi_exit);
diff --git a/Documentation/networking/caif/spi_porting.txt b/Documentation/networking/caif/spi_porting.txt
deleted file mode 100644 (file)
index 9efd068..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-- CAIF SPI porting -
-
-- CAIF SPI basics:
-
-Running CAIF over SPI needs some extra setup, owing to the nature of SPI.
-Two extra GPIOs have been added in order to negotiate the transfers
- between the master and the slave. The minimum requirement for running
-CAIF over SPI is a SPI slave chip and two GPIOs (more details below).
-Please note that running as a slave implies that you need to keep up
-with the master clock. An overrun or underrun event is fatal.
-
-- CAIF SPI framework:
-
-To make porting as easy as possible, the CAIF SPI has been divided in
-two parts. The first part (called the interface part) deals with all
-generic functionality such as length framing, SPI frame negotiation
-and SPI frame delivery and transmission. The other part is the CAIF
-SPI slave device part, which is the module that you have to write if
-you want to run SPI CAIF on a new hardware. This part takes care of
-the physical hardware, both with regard to SPI and to GPIOs.
-
-- Implementing a CAIF SPI device:
-
-       - Functionality provided by the CAIF SPI slave device:
-
-       In order to implement a SPI device you will, as a minimum,
-       need to implement the following
-       functions:
-
-       int (*init_xfer) (struct cfspi_xfer * xfer, struct cfspi_dev *dev):
-
-       This function is called by the CAIF SPI interface to give
-       you a chance to set up your hardware to be ready to receive
-       a stream of data from the master. The xfer structure contains
-       both physical and logical addresses, as well as the total length
-       of the transfer in both directions.The dev parameter can be used
-       to map to different CAIF SPI slave devices.
-
-       void (*sig_xfer) (bool xfer, struct cfspi_dev *dev):
-
-       This function is called by the CAIF SPI interface when the output
-       (SPI_INT) GPIO needs to change state. The boolean value of the xfer
-       variable indicates whether the GPIO should be asserted (HIGH) or
-       deasserted (LOW). The dev parameter can be used to map to different CAIF
-       SPI slave devices.
-
-       - Functionality provided by the CAIF SPI interface:
-
-       void (*ss_cb) (bool assert, struct cfspi_ifc *ifc);
-
-       This function is called by the CAIF SPI slave device in order to
-       signal a change of state of the input GPIO (SS) to the interface.
-       Only active edges are mandatory to be reported.
-       This function can be called from IRQ context (recommended in order
-       not to introduce latency). The ifc parameter should be the pointer
-       returned from the platform probe function in the SPI device structure.
-
-       void (*xfer_done_cb) (struct cfspi_ifc *ifc);
-
-       This function is called by the CAIF SPI slave device in order to
-       report that a transfer is completed. This function should only be
-       called once both the transmission and the reception are completed.
-       This function can be called from IRQ context (recommended in order
-       not to introduce latency). The ifc parameter should be the pointer
-       returned from the platform probe function in the SPI device structure.
-
-       - Connecting the bits and pieces:
-
-               - Filling in the SPI slave device structure:
-
-               Connect the necessary callback functions.
-               Indicate clock speed (used to calculate toggle delays).
-               Chose a suitable name (helps debugging if you use several CAIF
-               SPI slave devices).
-               Assign your private data (can be used to map to your structure).
-
-               - Filling in the SPI slave platform device structure:
-               Add name of driver to connect to ("cfspi_sspi").
-               Assign the SPI slave device structure as platform data.
-
-- Padding:
-
-In order to optimize throughput, a number of SPI padding options are provided.
-Padding can be enabled independently for uplink and downlink transfers.
-Padding can be enabled for the head, the tail and for the total frame size.
-The padding needs to be correctly configured on both sides of the link.
-The padding can be changed via module parameters in cfspi_sspi.c or via
-the sysfs directory of the cfspi_sspi driver (before device registration).
-
-- CAIF SPI device template:
-
-/*
- *     Copyright (C) ST-Ericsson AB 2010
- *     Author: Daniel Martensson / Daniel.Martensson@stericsson.com
- *     License terms: GNU General Public License (GPL), version 2.
- *
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/wait.h>
-#include <linux/interrupt.h>
-#include <linux/dma-mapping.h>
-#include <net/caif/caif_spi.h>
-
-MODULE_LICENSE("GPL");
-
-struct sspi_struct {
-       struct cfspi_dev sdev;
-       struct cfspi_xfer *xfer;
-};
-
-static struct sspi_struct slave;
-static struct platform_device slave_device;
-
-static irqreturn_t sspi_irq(int irq, void *arg)
-{
-       /* You only need to trigger on an edge to the active state of the
-        * SS signal. Once a edge is detected, the ss_cb() function should be
-        * called with the parameter assert set to true. It is OK
-        * (and even advised) to call the ss_cb() function in IRQ context in
-        * order not to add any delay. */
-
-       return IRQ_HANDLED;
-}
-
-static void sspi_complete(void *context)
-{
-       /* Normally the DMA or the SPI framework will call you back
-        * in something similar to this. The only thing you need to
-        * do is to call the xfer_done_cb() function, providing the pointer
-        * to the CAIF SPI interface. It is OK to call this function
-        * from IRQ context. */
-}
-
-static int sspi_init_xfer(struct cfspi_xfer *xfer, struct cfspi_dev *dev)
-{
-       /* Store transfer info. For a normal implementation you should
-        * set up your DMA here and make sure that you are ready to
-        * receive the data from the master SPI. */
-
-       struct sspi_struct *sspi = (struct sspi_struct *)dev->priv;
-
-       sspi->xfer = xfer;
-
-       return 0;
-}
-
-void sspi_sig_xfer(bool xfer, struct cfspi_dev *dev)
-{
-       /* If xfer is true then you should assert the SPI_INT to indicate to
-        * the master that you are ready to receive the data from the master
-        * SPI. If xfer is false then you should de-assert SPI_INT to indicate
-        * that the transfer is done.
-        */
-
-       struct sspi_struct *sspi = (struct sspi_struct *)dev->priv;
-}
-
-static void sspi_release(struct device *dev)
-{
-       /*
-        * Here you should release your SPI device resources.
-        */
-}
-
-static int __init sspi_init(void)
-{
-       /* Here you should initialize your SPI device by providing the
-        * necessary functions, clock speed, name and private data. Once
-        * done, you can register your device with the
-        * platform_device_register() function. This function will return
-        * with the CAIF SPI interface initialized. This is probably also
-        * the place where you should set up your GPIOs, interrupts and SPI
-        * resources. */
-
-       int res = 0;
-
-       /* Initialize slave device. */
-       slave.sdev.init_xfer = sspi_init_xfer;
-       slave.sdev.sig_xfer = sspi_sig_xfer;
-       slave.sdev.clk_mhz = 13;
-       slave.sdev.priv = &slave;
-       slave.sdev.name = "spi_sspi";
-       slave_device.dev.release = sspi_release;
-
-       /* Initialize platform device. */
-       slave_device.name = "cfspi_sspi";
-       slave_device.dev.platform_data = &slave.sdev;
-
-       /* Register platform device. */
-       res = platform_device_register(&slave_device);
-       if (res) {
-               printk(KERN_WARNING "sspi_init: failed to register dev.\n");
-               return -ENODEV;
-       }
-
-       return res;
-}
-
-static void __exit sspi_exit(void)
-{
-       platform_device_del(&slave_device);
-}
-
-module_init(sspi_init);
-module_exit(sspi_exit);
index 6538ede29661e802ac6e826a688ed03e5d41ed70..5b3421ec25ec3287ebe2a8812df3a835eb915e39 100644 (file)
@@ -15,6 +15,7 @@ Contents:
    device_drivers/index
    dsa/index
    devlink/index
+   caif/index
    ethtool-netlink
    ieee802154
    j1939
index 661c25eb1c46f0f436fcd0b525cea9fceb5c899b..1538ad194cf42ef8680d70902fd59f7a52781cb6 100644 (file)
@@ -28,7 +28,7 @@ config CAIF_SPI_SLAVE
          The CAIF Link layer SPI Protocol driver for Slave SPI interface.
          This driver implements a platform driver to accommodate for a
          platform specific SPI device. A sample CAIF SPI Platform device is
-         provided in <file:Documentation/networking/caif/spi_porting.txt>.
+         provided in <file:Documentation/networking/caif/spi_porting.rst>.
 
 config CAIF_SPI_SYNC
        bool "Next command and length in start of frame"