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^^^ || |
| 19 | The 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^^^ || |
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: |
| 46 | Notes: |
| 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 | |
| 52 | You 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 | |
| 54 | An 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 |
| 78 | Gateworks 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 | |
| 86 | Notes: |
| 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 | |
| 89 | You 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 | |
| 91 | An 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 |
| 115 | Gateworks Laguna boards support 3.3V TTL SPI to an off-board expansion connector with the following pinout: |
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 | | |