kernel: bump 5.4 to 5.4.109
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 806-dma-0009-MLK-16327-1-dma-fsl-edma-v3-make-exclusive-channel-n.patch
1 From c5a5706b8a86660505ef0dc863a85596437ca49b Mon Sep 17 00:00:00 2001
2 From: Robin Gong <yibin.gong@nxp.com>
3 Date: Wed, 30 Aug 2017 18:51:16 +0800
4 Subject: [PATCH] MLK-16327-1: dma: fsl-edma-v3: make exclusive channel name
5 for all edma channels
6
7 Since there are multi edmav3 instances on i.mx8, every edma channel name
8 is better unique.But so far, all edma channel name is 'edma-channel(id)-
9 tx',thus some edma channels which share the same channel id but different
10 edma instance will show the same channel name in kernel and this is not
11 friendly to debug in kernel.
12 Now the edma channel name(interrupt-names property) is define in dts
13 as below:
14 "edmaX-chanX-Xx"
15 | | |---> receive/transmit, r or t
16 | |---> channel id, the max number is 32
17 |---> edma controller instance, 0, 1, 2,..etc
18 and get below correct name with 'cat /proc/interrupts':
19 43: 0 0 0 0 GICv3 466 Level edma0-chan8-rx
20 44: 0 0 0 0 GICv3 467 Level edma0-chan9-tx
21 45: 79 0 0 0 GICv3 468 Level edma0-chan10-rx
22 46: 311 0 0 0 GICv3 469 Level edma0-chan11-tx
23 47: 0 0 0 0 GICv3 470 Level edma0-chan12-rx
24 48: 0 0 0 0 GICv3 471 Level edma0-chan13-tx
25 49: 0 0 0 0 GICv3 472 Level edma0-chan14-rx
26 50: 0 0 0 0 GICv3 473 Level edma0-chan15-tx
27 51: 0 0 0 0 GICv3 406 Level edma2-chan0-tx
28 52: 0 0 0 0 GICv3 407 Level edma2-chan1-tx
29 53: 0 0 0 0 GICv3 408 Level edma2-chan2-tx
30 54: 0 0 0 0 GICv3 409 Level edma2-chan3-tx
31 55: 0 0 0 0 GICv3 410 Level edma2-chan4-tx
32 56: 0 0 0 0 GICv3 411 Level edma2-chan5-tx
33 57: 0 0 0 0 GICv3 442 Level edma2-chan6-rx, edma2-chan7-tx
34
35 Signed-off-by: Robin Gong <yibin.gong@nxp.com>
36 Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
37 (cherry picked from commit af8e197a92c9c024ec4fbfcf543d744e81748773)
38 ---
39 .../devicetree/bindings/dma/fsl-edma-v3.txt | 12 +++++---
40 drivers/dma/fsl-edma-v3.c | 35 ++++++++++++++++++++--
41 2 files changed, 41 insertions(+), 6 deletions(-)
42
43 --- a/Documentation/devicetree/bindings/dma/fsl-edma-v3.txt
44 +++ b/Documentation/devicetree/bindings/dma/fsl-edma-v3.txt
45 @@ -12,8 +12,12 @@ Required properties:
46 - reg : Specifies base physical address(s) and size of the eDMA channel registers.
47 Each eDMA channel has separated register's address and size.
48 - interrupts : A list of interrupt-specifiers, each channel has one interrupt.
49 -- interrupt-names : Should contain:
50 - "edma-chan12-tx" - the channel12 transmission interrupt
51 +- interrupt-names : Should contain below template:
52 + "edmaX-chanX-Xx"
53 + | | |---> receive/transmit, r or t
54 + | |---> channel id, the max number is 32
55 + |---> edma controller instance, 0, 1, 2,..etc
56 +
57 - #dma-cells : Must be <3>.
58 The 1st cell specifies the channel ID.
59 The 2nd cell specifies the channel priority.
60 @@ -40,8 +44,8 @@ edma0: dma-controller@40018000 {
61 <GIC_SPI 435 IRQ_TYPE_LEVEL_HIGH>,
62 <GIC_SPI 436 IRQ_TYPE_LEVEL_HIGH>,
63 <GIC_SPI 437 IRQ_TYPE_LEVEL_HIGH>;
64 - interrupt-names = "edma-chan12-tx", "edma-chan13-tx",
65 - "edma-chan14-tx", "edma-chan15-tx";
66 + interrupt-names = "edma0-chan12-rx", "edma0-chan13-tx",
67 + "edma0-chan14-rx", "edma0-chan15-tx";
68 status = "okay";
69 };
70
71 --- a/drivers/dma/fsl-edma-v3.c
72 +++ b/drivers/dma/fsl-edma-v3.c
73 @@ -107,6 +107,10 @@
74 #define ARGS_REMOTE BIT(1)
75 #define ARGS_DFIFO BIT(2)
76
77 +/* channel name template define in dts */
78 +#define CHAN_PREFIX "edma0-chan"
79 +#define CHAN_POSFIX "-tx"
80 +
81 struct fsl_edma3_hw_tcd {
82 __le32 saddr;
83 __le16 soff;
84 @@ -806,7 +810,10 @@ static int fsl_edma3_probe(struct platfo
85 INIT_LIST_HEAD(&fsl_edma3->dma_dev.channels);
86 for (i = 0; i < fsl_edma3->n_chans; i++) {
87 struct fsl_edma3_chan *fsl_chan = &fsl_edma3->chans[i];
88 - char *txirq_name = fsl_chan->txirq_name;
89 + const char *txirq_name = fsl_chan->txirq_name;
90 + char chanid[3], id_len = 0;
91 + char *p = chanid;
92 + unsigned long val;
93
94 fsl_chan->edma3 = fsl_edma3;
95 /* Get per channel membase */
96 @@ -819,7 +826,31 @@ static int fsl_edma3_probe(struct platfo
97 * channel0:0x10000, channel1:0x20000... total 32 channels
98 */
99 fsl_chan->hw_chanid = (res->start >> 16) & 0x1f;
100 - sprintf(txirq_name, "edma-chan%d-tx", fsl_chan->hw_chanid);
101 +
102 + ret = of_property_read_string_index(np, "interrupt-names", i,
103 + &txirq_name);
104 + if (ret) {
105 + dev_err(&pdev->dev, "read interrupt-names fail.\n");
106 + return ret;
107 + }
108 + /* Get channel id length from dts, one-digit or double-digit */
109 + id_len = strlen(txirq_name) - strlen(CHAN_PREFIX) -
110 + strlen(CHAN_POSFIX);
111 + if (id_len > 2) {
112 + dev_err(&pdev->dev, "%s is edmaX-chanX-tx in dts?\n",
113 + res->name);
114 + return -EINVAL;
115 + }
116 + /* Grab channel id from txirq_name */
117 + strncpy(p, txirq_name + strlen(CHAN_PREFIX), id_len);
118 + *(p + id_len) = '\0';
119 +
120 + /* check if the channel id match well with hw_chanid */
121 + ret = kstrtoul(chanid, 0, &val);
122 + if (ret || val != fsl_chan->hw_chanid) {
123 + dev_err(&pdev->dev, "%s,wrong id?\n", txirq_name);
124 + return -EINVAL;
125 + }
126
127 /* request channel irq */
128 fsl_chan->txirq = platform_get_irq_byname(pdev, txirq_name);