LAN969x FLEXCOM
1. SoC Resources
LAN969X SoC have 4 FLEXCOMs (Flexible Serial Communication Controller). Each flexcom supports three serial communication protocols that includes
-
USART (Universal Synchronous Asynchronous Receiver Transceiver). See USART documentation
-
SPI (Serial Peripheral Interface). See SPI documentation
-
TWI (Two-wire Interface) or I2C (Inter Integrated Circuit). See TWI documentation
Each flexcom has two optional I/O lines. Namely, CS0 and CS1 in flexcom SPI mode. CTS and RTS in flexcom USART mode. These chip-selects can be mapped to lan969x FLEXCOM_SHARED[0-20] pins and usage depends on functions being configured.
2. Kernel configurations
Following kernel config options should be enabled to use LAN969x Flexcom interface:
-
CONFIG_MFD_ATMEL_FLEXCOM- Flexcom driver config option.
3. Devicetree Configuration
Following configurations are required to define a flexcom in device tree:
-
compatiblestring must be set toatmel,sama5d2-flexcomor set tomicrochip,lan969x-flexcomin case flexcom chip-select configurations are required. -
Flexcom
regproperty must be set with register address and length. Refer table below:
| FLEXCOM ID | Flexcom base registers map |
|---|---|
flx0 |
<0xe0040000 0x100> |
flx1 |
<0xe0044000 0x100> |
flx2 |
<0xe0060000 0x100> |
flx3 |
<0xe0064000 0x100> |
-
clocksproperty must be set to<&clks GCK_ID_FLEXCOMx>wherexis flexcom ID. -
#address-cellsmust be set to1. -
#size-cellsmust be set to1. -
rangesmust be set to one range for the full I/O register region. -
Optional flexcom chip-select configurations: In order to map flexcom USART
cts,rtslines or flexcom SPIcs0,cs1lines to flexcom shared pins, use below properties:-
Append flexcom shared register address and length to
regproperty. Refer table below: -
microchip,flx-shrd-pins- Specify the flexcom shared pins to be mapped to chip-select line. Possible flexcom shared pins are [0-20]. -
microchip,flx-cs- Specify chip-selects to be configured.-
0forctsline in USART mode,cs0in SPI mode. -
1forrtsline in USART mode,cs1in SPI mode.
-
-
| FLEXCOM ID | Flexcom shared registers map |
|---|---|
flx0 |
<0xe2004168 0x8> |
flx1 |
<0xe2004170 0x8> |
flx2 |
<0xe2004178 0x8> |
flx3 |
<0xe2004180 0x8> |
flx4 |
<0xe2004188 0x8> |
3.2. Example
Following example shows how a flexcom should be defined in device tree.
Example to configure flexcom2 in TWI mode:
dtsi file:
flx2: flexcom@e0060000 {
compatible = "atmel,sama5d2-flexcom";
reg = <e0060000 0x100>;
clocks = <&clks GCK_ID_FLEXCOM2>;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0x0 e0060000 0x800>;
status = "disabled";
};
dts file:
&flx2 {
atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_TWI>;
status = "okay";
};
Example to configure flexcom3 in SPI mode and map cs0 to flexcom shared pin 4:
dtsi file:
flx3: flexcom@e0064000 {
compatible = "microchip,lan969x-flexcom";
reg = <0xe0064000 0x100>,
<0xe2004180 0x8>;
clocks = <&clks GCK_ID_FLEXCOM3>;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0x0 0xe0064000 0x800>;
status = "disabled";
};
dts file:
&flx3 {
atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_SPI>;
microchip,flx-shrd-pins = <4>;
microchip,flx-cs = <0>;
status = "okay";
};