Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/wan/fsl_ucc_hdlc: add hdlc-bus support

This adds support for hdlc-bus mode to the fsl_ucc_hdlc driver. This can
be enabled with the "fsl,hdlc-bus" property in the DTS node of the
corresponding ucc.

This aligns the configuration of the UPSMR and GUMR registers to what is
done in our ucc_hdlc driver (that only support hdlc-bus mode) and with
the QuickEngine's documentation for hdlc-bus mode.

GUMR/SYNL is set to AUTO for the busmode as in this case the CD signal
is ignored. The brkpt_support is enabled to set the HBM1 bit in the
CMXUCR register to configure an open-drain connected HDLC bus.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Zhao Qiang <qiang.zhao@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Holger Brunck and committed by
David S. Miller
067bb938 c7f235a7

+38
+32
drivers/net/wan/fsl_ucc_hdlc.c
··· 98 98 uf_info->tsa = 1; 99 99 uf_info->ctsp = 1; 100 100 } 101 + 102 + /* This sets HPM register in CMXUCR register which configures a 103 + * open drain connected HDLC bus 104 + */ 105 + if (priv->hdlc_bus) 106 + uf_info->brkpt_support = 1; 107 + 101 108 uf_info->uccm_mask = ((UCC_HDLC_UCCE_RXB | UCC_HDLC_UCCE_RXF | 102 109 UCC_HDLC_UCCE_TXB) << 16); 103 110 ··· 141 134 142 135 /* Set UPSMR normal mode (need fixed)*/ 143 136 iowrite32be(0, &priv->uf_regs->upsmr); 137 + 138 + /* hdlc_bus mode */ 139 + if (priv->hdlc_bus) { 140 + u32 upsmr; 141 + 142 + dev_info(priv->dev, "HDLC bus Mode\n"); 143 + upsmr = ioread32be(&priv->uf_regs->upsmr); 144 + 145 + /* bus mode and retransmit enable, with collision window 146 + * set to 8 bytes 147 + */ 148 + upsmr |= UCC_HDLC_UPSMR_RTE | UCC_HDLC_UPSMR_BUS | 149 + UCC_HDLC_UPSMR_CW8; 150 + iowrite32be(upsmr, &priv->uf_regs->upsmr); 151 + 152 + /* explicitly disable CDS & CTSP */ 153 + gumr = ioread32be(&priv->uf_regs->gumr); 154 + gumr &= ~(UCC_FAST_GUMR_CDS | UCC_FAST_GUMR_CTSP); 155 + /* set automatic sync to explicitly ignore CD signal */ 156 + gumr |= UCC_FAST_GUMR_SYNL_AUTO; 157 + iowrite32be(gumr, &priv->uf_regs->gumr); 158 + } 144 159 145 160 priv->rx_ring_size = RX_BD_RING_LEN; 146 161 priv->tx_ring_size = TX_BD_RING_LEN; ··· 1074 1045 1075 1046 if (of_get_property(np, "fsl,ucc-internal-loopback", NULL)) 1076 1047 uhdlc_priv->loopback = 1; 1048 + 1049 + if (of_get_property(np, "fsl,hdlc-bus", NULL)) 1050 + uhdlc_priv->hdlc_bus = 1; 1077 1051 1078 1052 if (uhdlc_priv->tsa == 1) { 1079 1053 utdm = kzalloc(sizeof(*utdm), GFP_KERNEL);
+1
drivers/net/wan/fsl_ucc_hdlc.h
··· 78 78 u16 tsa; 79 79 bool hdlc_busy; 80 80 bool loopback; 81 + bool hdlc_bus; 81 82 82 83 u8 *tx_buffer; 83 84 u8 *rx_buffer;
+5
include/soc/fsl/qe/qe.h
··· 789 789 #define UCC_GETH_UPSMR_SMM 0x00000080 790 790 #define UCC_GETH_UPSMR_SGMM 0x00000020 791 791 792 + /* UCC Protocol Specific Mode Register (UPSMR), when used for HDLC */ 793 + #define UCC_HDLC_UPSMR_RTE 0x02000000 794 + #define UCC_HDLC_UPSMR_BUS 0x00200000 795 + #define UCC_HDLC_UPSMR_CW8 0x00007000 796 + 792 797 /* UCC Transmit On Demand Register (UTODR) */ 793 798 #define UCC_SLOW_TOD 0x8000 794 799 #define UCC_FAST_TOD 0x8000