diff options
author | Steve Lin <steven.lin1@broadcom.com> | 2016-11-14 13:25:56 -0500 |
---|---|---|
committer | Jassi Brar <jaswinder.singh@linaro.org> | 2016-12-19 09:40:18 -0500 |
commit | 9fb0f9ac54b393ddfe49be7da7751f02bb133db6 (patch) | |
tree | 177d10101dea874b39f5b518f022568b09c25df5 /drivers/mailbox/bcm-pdc-mailbox.c | |
parent | 9b1b2b3adb310560a31ea248fa0defc8f09129ff (diff) |
mailbox: bcm-pdc: Changes so mbox client can be removed / re-inserted
Ensure that DMA is disabled, and pointers reset, when changing
DMA base addresses in pdc_ring_init(). This allows a mailbox client
to be re-inserted after being removed. Otherwise, the DMA doesn't
restart so the client hangs while being reinserted.
Signed-off-by: Steve Lin <steven.lin1@broadcom.com>
Signed-off-by: Rob Rice <rob.rice@broadcom.com>
Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Diffstat (limited to 'drivers/mailbox/bcm-pdc-mailbox.c')
-rw-r--r-- | drivers/mailbox/bcm-pdc-mailbox.c | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/drivers/mailbox/bcm-pdc-mailbox.c b/drivers/mailbox/bcm-pdc-mailbox.c index a9c804fa3fbe..3b4ebbe81964 100644 --- a/drivers/mailbox/bcm-pdc-mailbox.c +++ b/drivers/mailbox/bcm-pdc-mailbox.c | |||
@@ -117,15 +117,16 @@ | |||
117 | 117 | ||
118 | /* | 118 | /* |
119 | * Sets the following bits for write to transmit control reg: | 119 | * Sets the following bits for write to transmit control reg: |
120 | * 0 - XmtEn - enable activity on the tx channel | ||
121 | * 11 - PtyChkDisable - parity check is disabled | 120 | * 11 - PtyChkDisable - parity check is disabled |
122 | * 20:18 - BurstLen = 3 -> 2^7 = 128 byte data reads from memory | 121 | * 20:18 - BurstLen = 3 -> 2^7 = 128 byte data reads from memory |
123 | */ | 122 | */ |
124 | #define PDC_TX_CTL 0x000C0801 | 123 | #define PDC_TX_CTL 0x000C0800 |
124 | |||
125 | /* Bit in tx control reg to enable tx channel */ | ||
126 | #define PDC_TX_ENABLE 0x1 | ||
125 | 127 | ||
126 | /* | 128 | /* |
127 | * Sets the following bits for write to receive control reg: | 129 | * Sets the following bits for write to receive control reg: |
128 | * 0 - RcvEn - enable activity on the rx channel | ||
129 | * 7:1 - RcvOffset - size in bytes of status region at start of rx frame buf | 130 | * 7:1 - RcvOffset - size in bytes of status region at start of rx frame buf |
130 | * 9 - SepRxHdrDescEn - place start of new frames only in descriptors | 131 | * 9 - SepRxHdrDescEn - place start of new frames only in descriptors |
131 | * that have StartOfFrame set | 132 | * that have StartOfFrame set |
@@ -135,7 +136,10 @@ | |||
135 | * 11 - PtyChkDisable - parity check is disabled | 136 | * 11 - PtyChkDisable - parity check is disabled |
136 | * 20:18 - BurstLen = 3 -> 2^7 = 128 byte data reads from memory | 137 | * 20:18 - BurstLen = 3 -> 2^7 = 128 byte data reads from memory |
137 | */ | 138 | */ |
138 | #define PDC_RX_CTL 0x000C0E01 | 139 | #define PDC_RX_CTL 0x000C0E00 |
140 | |||
141 | /* Bit in rx control reg to enable rx channel */ | ||
142 | #define PDC_RX_ENABLE 0x1 | ||
139 | 143 | ||
140 | #define CRYPTO_D64_RS0_CD_MASK ((PDC_RING_ENTRIES * RING_ENTRY_SIZE) - 1) | 144 | #define CRYPTO_D64_RS0_CD_MASK ((PDC_RING_ENTRIES * RING_ENTRY_SIZE) - 1) |
141 | 145 | ||
@@ -1054,6 +1058,15 @@ static int pdc_ring_init(struct pdc_state *pdcs, int ringset) | |||
1054 | 1058 | ||
1055 | /* Tell device the base DMA address of each ring */ | 1059 | /* Tell device the base DMA address of each ring */ |
1056 | dma_reg = &pdcs->regs->dmaregs[ringset]; | 1060 | dma_reg = &pdcs->regs->dmaregs[ringset]; |
1061 | |||
1062 | /* But first disable DMA and set curptr to 0 for both TX & RX */ | ||
1063 | iowrite32(PDC_TX_CTL, &dma_reg->dmaxmt.control); | ||
1064 | iowrite32((PDC_RX_CTL + (pdcs->rx_status_len << 1)), | ||
1065 | (void *)&dma_reg->dmarcv.control); | ||
1066 | iowrite32(0, (void *)&dma_reg->dmaxmt.ptr); | ||
1067 | iowrite32(0, (void *)&dma_reg->dmarcv.ptr); | ||
1068 | |||
1069 | /* Set base DMA addresses */ | ||
1057 | iowrite32(lower_32_bits(pdcs->tx_ring_alloc.dmabase), | 1070 | iowrite32(lower_32_bits(pdcs->tx_ring_alloc.dmabase), |
1058 | (void *)&dma_reg->dmaxmt.addrlow); | 1071 | (void *)&dma_reg->dmaxmt.addrlow); |
1059 | iowrite32(upper_32_bits(pdcs->tx_ring_alloc.dmabase), | 1072 | iowrite32(upper_32_bits(pdcs->tx_ring_alloc.dmabase), |
@@ -1064,6 +1077,11 @@ static int pdc_ring_init(struct pdc_state *pdcs, int ringset) | |||
1064 | iowrite32(upper_32_bits(pdcs->rx_ring_alloc.dmabase), | 1077 | iowrite32(upper_32_bits(pdcs->rx_ring_alloc.dmabase), |
1065 | (void *)&dma_reg->dmarcv.addrhigh); | 1078 | (void *)&dma_reg->dmarcv.addrhigh); |
1066 | 1079 | ||
1080 | /* Re-enable DMA */ | ||
1081 | iowrite32(PDC_TX_CTL | PDC_TX_ENABLE, &dma_reg->dmaxmt.control); | ||
1082 | iowrite32((PDC_RX_CTL | PDC_RX_ENABLE | (pdcs->rx_status_len << 1)), | ||
1083 | (void *)&dma_reg->dmarcv.control); | ||
1084 | |||
1067 | /* Initialize descriptors */ | 1085 | /* Initialize descriptors */ |
1068 | for (i = 0; i < PDC_RING_ENTRIES; i++) { | 1086 | for (i = 0; i < PDC_RING_ENTRIES; i++) { |
1069 | /* Every tx descriptor can be used for start of frame. */ | 1087 | /* Every tx descriptor can be used for start of frame. */ |
@@ -1235,23 +1253,41 @@ void pdc_hw_init(struct pdc_state *pdcs) | |||
1235 | pdcs->nrxd = PDC_RING_ENTRIES; | 1253 | pdcs->nrxd = PDC_RING_ENTRIES; |
1236 | pdcs->ntxpost = PDC_RING_ENTRIES - 1; | 1254 | pdcs->ntxpost = PDC_RING_ENTRIES - 1; |
1237 | pdcs->nrxpost = PDC_RING_ENTRIES - 1; | 1255 | pdcs->nrxpost = PDC_RING_ENTRIES - 1; |
1238 | pdcs->regs->intmask = 0; | 1256 | iowrite32(0, &pdcs->regs->intmask); |
1239 | 1257 | ||
1240 | dma_reg = &pdcs->regs->dmaregs[ringset]; | 1258 | dma_reg = &pdcs->regs->dmaregs[ringset]; |
1241 | iowrite32(0, (void *)&dma_reg->dmaxmt.ptr); | ||
1242 | iowrite32(0, (void *)&dma_reg->dmarcv.ptr); | ||
1243 | 1259 | ||
1244 | iowrite32(PDC_TX_CTL, (void *)&dma_reg->dmaxmt.control); | 1260 | /* Configure DMA but will enable later in pdc_ring_init() */ |
1261 | iowrite32(PDC_TX_CTL, &dma_reg->dmaxmt.control); | ||
1245 | 1262 | ||
1246 | iowrite32(PDC_RX_CTL + (pdcs->rx_status_len << 1), | 1263 | iowrite32(PDC_RX_CTL + (pdcs->rx_status_len << 1), |
1247 | (void *)&dma_reg->dmarcv.control); | 1264 | (void *)&dma_reg->dmarcv.control); |
1248 | 1265 | ||
1266 | /* Reset current index pointers after making sure DMA is disabled */ | ||
1267 | iowrite32(0, &dma_reg->dmaxmt.ptr); | ||
1268 | iowrite32(0, &dma_reg->dmarcv.ptr); | ||
1269 | |||
1249 | if (pdcs->pdc_resp_hdr_len == PDC_SPU2_RESP_HDR_LEN) | 1270 | if (pdcs->pdc_resp_hdr_len == PDC_SPU2_RESP_HDR_LEN) |
1250 | iowrite32(PDC_CKSUM_CTRL, | 1271 | iowrite32(PDC_CKSUM_CTRL, |
1251 | pdcs->pdc_reg_vbase + PDC_CKSUM_CTRL_OFFSET); | 1272 | pdcs->pdc_reg_vbase + PDC_CKSUM_CTRL_OFFSET); |
1252 | } | 1273 | } |
1253 | 1274 | ||
1254 | /** | 1275 | /** |
1276 | * pdc_hw_disable() - Disable the tx and rx control in the hw. | ||
1277 | * @pdcs: PDC state structure | ||
1278 | * | ||
1279 | */ | ||
1280 | static void pdc_hw_disable(struct pdc_state *pdcs) | ||
1281 | { | ||
1282 | struct dma64 *dma_reg; | ||
1283 | |||
1284 | dma_reg = &pdcs->regs->dmaregs[PDC_RINGSET]; | ||
1285 | iowrite32(PDC_TX_CTL, &dma_reg->dmaxmt.control); | ||
1286 | iowrite32(PDC_RX_CTL + (pdcs->rx_status_len << 1), | ||
1287 | &dma_reg->dmarcv.control); | ||
1288 | } | ||
1289 | |||
1290 | /** | ||
1255 | * pdc_rx_buf_pool_create() - Pool of receive buffers used to catch the metadata | 1291 | * pdc_rx_buf_pool_create() - Pool of receive buffers used to catch the metadata |
1256 | * header returned with each response message. | 1292 | * header returned with each response message. |
1257 | * @pdcs: PDC state structure | 1293 | * @pdcs: PDC state structure |
@@ -1505,6 +1541,8 @@ static int pdc_remove(struct platform_device *pdev) | |||
1505 | 1541 | ||
1506 | pdc_free_debugfs(); | 1542 | pdc_free_debugfs(); |
1507 | 1543 | ||
1544 | pdc_hw_disable(pdcs); | ||
1545 | |||
1508 | mbox_controller_unregister(&pdcs->mbc); | 1546 | mbox_controller_unregister(&pdcs->mbc); |
1509 | 1547 | ||
1510 | dma_pool_destroy(pdcs->rx_buf_pool); | 1548 | dma_pool_destroy(pdcs->rx_buf_pool); |