Changes between Version 11 and Version 12 of SPI


Ignore:
Timestamp:
10/09/2018 06:56:44 PM (6 years ago)
Author:
Tim Harvey
Comment:

added a general spidev table at top of page and refactored family sections a bit

Legend:

Unmodified
Added
Removed
Modified
  • SPI

    v11 v12  
    1414
    1515
    16 == On-Board SPI controllers ==
     16[=#spitable]
     17== On-Board SPI controllers
    1718
    18 [=#spitable]
    19 === Newport / Ventana ===
    20 Various Gateworks boards support 3.3V TTL SPI to an off-board expansion connector with a single CS#:
    21 ||= Family =||= Board   =||= Device Tree Node =||= Connector =||= Notes =||
    22 || Newport  || GW630x    || spi_7_0            || J8          || ^^^1^^^ ||
    23 ||          || GW640x    || spi_7_0            || J8          || ^^^1^^^ ||
     19The following Gateworks boards support on-board SPI controllers:
     20||= Family =||= Board =||= Connector =||= Notes =||
     21|| Newport  || GW640x  || J8          || single CS^^^2^^^; spi_7_0 dts node; half-duplex^^^1^^^; modes 1^^^3^^^ ||
     22||          || GW630x  || J8          || single CS^^^2^^^; spi_7_0 dts node; half-duplex^^^1^^^; modes 1^^^3^^^ ||
     23||          || GW620x  || J5          || single CS^^^2^^^; spi_7_0 dts node; half-duplex^^^1^^^; modes 1^^^3^^^ ||
     24||          || GW610x  || J10         || single CS^^^2^^^; spi_7_0 dts node; half-duplex^^^1^^^; modes 1^^^3^^^ ||
    2425|| ||
    25 || Ventana  || GW522x    || ecspi3             || J24         || ||
    26 ||          || GW54xx-E+ || ecspi2             || J32         || ||
     26|| Ventana  || GW54xx-E+ || J24       || single CS^^^2^^^; ecspi2 dts node ||
     27||          || GW522x    || J32       || single CS^^^2^^^; ecspi3 dts node ||
     28|| ||
     29|| Laguna   || GW2388    || J9        || ||
    2730 1. Note that the Cavium ThunderX SPI controller in the CN80XX on the Newport Product family only supports half-duplex SPI transfers. Drivers that use full-duplex transactions can be modified to support half-duplex (see [https://github.com/Gateworks/linux-newport/commit/cb270339619ccf2b50dfd3604a03626f85830453 'can:mcp251x: convert driver to half-duplex SPI'] as en example.
     31 2. While only a single Chip Select (CS) is brought out to an external connector and of the DIO pins routed to ARM GPIO's can be used as additional chip-selects. For Ventana this is done via device-tree pinctrl and for Newport this must be done via a PINSEL GPIO (contact support@gateworks.com)
     32 3. Note that the Cavium ThunderX SPI controller in the CN80XX only supports SPI mode 1 (which clock polarity (CPOL/CKP) is low, clock phase (CPHA) is high, and Clock edge (CKE/NCPHA) is low.
    2833
    29 Pinout (all signals are 3.3V TTL):
     34See the below product family specific sections for pinout details.
     35
     36
     37=== Newport
     38Gateworks Newport boards support 3.3V TTL SPI to an off-board expansion connector with the following pinout:
    3039 * 1 - MOSI
    3140 * 2 - MISO
     
    3544 * GND
    3645
    37 === Laguna ===
    38 While SPI is used for on-board FLASH storage for many Laguna boards, it also is brought out to the J9 expansion connector available on the Laguna GW2388:
     46Notes:
     47 1. While only a single Chip Select (CS) is brought out to an external connector and of the DIO pins routed to ARM GPIO's can be used as additional chip-selects (contact support@gateworks.com for details)
     48 2. Note that the Cavium ThunderX SPI controller in the CN80XX on the Newport Product family only supports half-duplex SPI transfers. Drivers that use full-duplex transactions can be modified to support half-duplex (see [https://github.com/Gateworks/linux-newport/commit/cb270339619ccf2b50dfd3604a03626f85830453 'can:mcp251x: convert driver to half-duplex SPI'] as en example.
     49 3. Note that the Cavium ThunderX SPI controller in the CN80XX only supports SPI mode 1 (which clock polarity (CPOL/CKP) is low, clock phase (CPHA) is high, and Clock edge (CKE/NCPHA) is low.
     50
     51
     52You need to add a device-tree node to the SPI controller to use a kernel driver. Note that you can also access SPI from userspace using {{{spidev}}} (see [#spidev below])
     53
     54An example device-tree child node for a Spansion m25p128 compatible device (S25FL128) 128Mbit (16MB) SPI NOR FLASH device would be:
     55{{{#!c
     56&spi_7_0 {
     57       flash: m25p80@0 {
     58               compatible = "spansion,m25p128", "jedec,spi-nor";
     59               spi-max-frequency = <30000000>;
     60               reg = <0>;
     61               #address-cells = <1>;
     62               #size-cells = <1>;
     63               m25p,fast-read;
     64
     65               partition@0 {
     66                       label = "data";
     67                       reg = <0x0 0x1000000>;
     68               };
     69       };
     70};
     71}}}
     72 - Note that this node must appear within the SPI host controller node (&spi_7_0) along with any other devices on the SPI bus.
     73 - Note that the values shown in the above node are specific to the m25p128, and can vary greatly from the actual device you are using. Replace attribute values as necessary.
     74 - When searching for your device ID string or its controlling driver, searching via a Linux LXR site like the one at [https://lxr.missinglinkelectronics.com/linux missing link electronics] for your device name can be helpful.
     75
     76
     77=== Ventana
     78Gateworks Ventana boards support 3.3V TTL SPI to an off-board expansion connector with the following pinout:
     79 * 1 - MOSI
     80 * 2 - MISO
     81 * 3 - SCLK
     82 * 4 - SS0# (This is chip select 0)
     83 * 5 - 3.3V
     84 * GND
     85
     86Notes:
     87 1. While only a single Chip Select (CS) is brought out to an external connector and of the DIO pins routed to ARM GPIO's can be used as additional chip-selects. For Ventana this is done via device-tree pinctrl.
     88
     89You need to add add a device-tree node to the SPI controller to use a kernel driver. Note that you can also access SPI from userspace using {{{spidev}}} (see [#spidev below])
     90
     91An example device-tree child node for a Spansion m25p128 compatible device (S25FL128) 128Mbit (16MB) SPI NOR FLASH device would be:
     92{{{#!c
     93&ecspi2 {
     94       flash: m25p80@0 {
     95               compatible = "spansion,m25p128", "jedec,spi-nor";
     96               spi-max-frequency = <30000000>;
     97               reg = <0>;
     98               #address-cells = <1>;
     99               #size-cells = <1>;
     100               m25p,fast-read;
     101
     102               partition@0 {
     103                       label = "data";
     104                       reg = <0x0 0x1000000>;
     105               };
     106       };
     107};
     108}}}
     109 - Note that this node must appear within the SPI host controller. For a list of device-tree nodes [#spitable see above].
     110 - Note that the values shown in the above node are specific to the m25p128, and can vary greatly from the actual device you are using. Replace attribute values as necessary.
     111 - When searching for your device ID string or its controlling driver, searching via a Linux LXR site like the one at [https://lxr.missinglinkelectronics.com/linux missing link electronics] for your device name can be helpful.
     112
     113
     114=== Laguna
     115Gateworks Laguna boards support 3.3V TTL SPI to an off-board expansion connector with the following pinout:
    39116 * J9.2 - CS#
    40117 * J9.4 - SCLK
     
    43120 * J9.10 - GND
    44121
     122Notes:
     123 1. The SPI bus is shared with the alternate flash device
     124 2. For details on adding kernel devices to the Laguna kernel see [#laguna below]
     125
    45126[[Image(spi2388.png,800px)]]
    46127
    47 For details on adding kernel devices to the Laguna kernel see [#laguna below]
     128
     129The Laguna Linux kernels which does not use device-tree needs to register a {{{spi_board_info}}} struct with the kernel via {{{spi_register_board_info()}}}. To add a SPI device to Laguna you would add it to the spi_board_info array in {{{laguna.c}}}. Be sure to specify chip_select=1 to use CS1 as CS0 is used for the on-board SPI FLASH device:
     130 * [https://github.com/Gateworks/openwrt/blob/16.02/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c#L188 spi_board_info struct]
     131 * [https://github.com/Gateworks/openwrt/blob/16.02/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c#L1097 call to spi_register_board_info()]
     132
    48133
    49134[=#usb]
     
    52137 * [http://trac.gateworks.com/wiki/expansion/gw16113 GW16113 firmware-flexible USB 2.0 FS expansion]
    53138 * [http://www.commell.com.tw/product/Peripheral/PCI%20Express%20mini%20card/MPX-24794S.HTM Commell MPX-24794S USB 2.0 FS SPI/I2C/GPIO expansion]
    54 
    55 
    56 [=#linux]
    57 == Using a Linux SPI kernel driver ==
    58 
    59 [=#devicetree]
    60 === device-tree: Newport / Ventana ===
    61 Linux kernels that utilize the device-tree need to add a device-tree node to the SPI controller to use a kernel driver. Note that you can also access SPI from userspace using {{{spidev}}} (see [#spidev below])
    62 
    63 An example device-tree child node for a Spansion m25p128 compatible device (S25FL128) 128Mbit (16MB) SPI NOR FLASH device would be:
    64 {{{#!c
    65 flash: m25p80@0 {
    66         /* "m25p128" must match a supported driver compatible string */
    67         compatible = "spansion,m25p128", "jedec,spi-nor";
    68         /* device frequency (in MHz) */
    69         spi-max-frequency = <30000000>;
    70         /* Chip Select */
    71         reg = <0>;
    72         /* see dts documentation for your device */
    73         #address-cells = <1>;
    74         #size-cells = <1>;
    75 
    76         partition@0 {
    77            /* The name of this partition  */
    78            label = "data";
    79             /* starting address and length */
    80            reg = <0x0 0x1000000>;
    81         };
    82 };
    83 }}}
    84 
    85 Note that this node must appear within the SPI host controller. For a list of device-tree nodes [#spitable see above].
    86 
    87 Note that the values shown in the above node are specific to the m25p128, and can vary greatly from the actual device you are using. Replace attribute values as necessary.
    88 
    89 When searching for your device ID string or its controlling driver, searching via a Linux LXR site like the one at [https://lxr.missinglinkelectronics.com/linux missing link electronics] for your device name can be helpful.
    90 
    91 
    92 [=#laguna]
    93 === non-device-tree: Laguna ===
    94 Linux kernels that do not utilize device-tree need to register a {{{spi_board_info}}} struct with the kernel via {{{spi_register_board_info()}}}.
    95 
    96 To add a SPI device to Laguna you would add it to the spi_board_info array in {{{laguna.c}}}. Be sure to specify chip_select=1 to use CS1 as CS0 is used for the on-board SPI FLASH device.
    97 
    98 References:
    99  * [https://github.com/Gateworks/openwrt/blob/16.02/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c#L188 spi_board_info struct]
    100  * [https://github.com/Gateworks/openwrt/blob/16.02/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c#L1097 call to spi_register_board_info()]
    101 
    102139
    103140