hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/fsi/fsi-master-hub.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * FSI hub master driver
34 *
45 * Copyright (C) IBM Corporation 2016
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
146 */
157
168 #include <linux/delay.h>
....@@ -21,53 +13,7 @@
2113
2214 #include "fsi-master.h"
2315
24
-/* Control Registers */
25
-#define FSI_MMODE 0x0 /* R/W: mode */
26
-#define FSI_MDLYR 0x4 /* R/W: delay */
27
-#define FSI_MCRSP 0x8 /* R/W: clock rate */
28
-#define FSI_MENP0 0x10 /* R/W: enable */
29
-#define FSI_MLEVP0 0x18 /* R: plug detect */
30
-#define FSI_MSENP0 0x18 /* S: Set enable */
31
-#define FSI_MCENP0 0x20 /* C: Clear enable */
32
-#define FSI_MAEB 0x70 /* R: Error address */
33
-#define FSI_MVER 0x74 /* R: master version/type */
34
-#define FSI_MRESP0 0xd0 /* W: Port reset */
35
-#define FSI_MESRB0 0x1d0 /* R: Master error status */
36
-#define FSI_MRESB0 0x1d0 /* W: Reset bridge */
37
-#define FSI_MECTRL 0x2e0 /* W: Error control */
38
-
39
-/* MMODE: Mode control */
40
-#define FSI_MMODE_EIP 0x80000000 /* Enable interrupt polling */
41
-#define FSI_MMODE_ECRC 0x40000000 /* Enable error recovery */
42
-#define FSI_MMODE_EPC 0x10000000 /* Enable parity checking */
43
-#define FSI_MMODE_P8_TO_LSB 0x00000010 /* Timeout value LSB */
44
- /* MSB=1, LSB=0 is 0.8 ms */
45
- /* MSB=0, LSB=1 is 0.9 ms */
46
-#define FSI_MMODE_CRS0SHFT 18 /* Clk rate selection 0 shift */
47
-#define FSI_MMODE_CRS0MASK 0x3ff /* Clk rate selection 0 mask */
48
-#define FSI_MMODE_CRS1SHFT 8 /* Clk rate selection 1 shift */
49
-#define FSI_MMODE_CRS1MASK 0x3ff /* Clk rate selection 1 mask */
50
-
51
-/* MRESB: Reset brindge */
52
-#define FSI_MRESB_RST_GEN 0x80000000 /* General reset */
53
-#define FSI_MRESB_RST_ERR 0x40000000 /* Error Reset */
54
-
55
-/* MRESB: Reset port */
56
-#define FSI_MRESP_RST_ALL_MASTER 0x20000000 /* Reset all FSI masters */
57
-#define FSI_MRESP_RST_ALL_LINK 0x10000000 /* Reset all FSI port contr. */
58
-#define FSI_MRESP_RST_MCR 0x08000000 /* Reset FSI master reg. */
59
-#define FSI_MRESP_RST_PYE 0x04000000 /* Reset FSI parity error */
60
-#define FSI_MRESP_RST_ALL 0xfc000000 /* Reset any error */
61
-
62
-/* MECTRL: Error control */
63
-#define FSI_MECTRL_EOAE 0x8000 /* Enable machine check when */
64
- /* master 0 in error */
65
-#define FSI_MECTRL_P8_AUTO_TERM 0x4000 /* Auto terminate */
66
-
6716 #define FSI_ENGID_HUB_MASTER 0x1c
68
-#define FSI_HUB_LINK_OFFSET 0x80000
69
-#define FSI_HUB_LINK_SIZE 0x80000
70
-#define FSI_HUB_MASTER_MAX_LINKS 8
7117
7218 #define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */
7319
....@@ -131,7 +77,8 @@
13177 return hub_master_write(master, link, 0, addr, &cmd, sizeof(cmd));
13278 }
13379
134
-static int hub_master_link_enable(struct fsi_master *master, int link)
80
+static int hub_master_link_enable(struct fsi_master *master, int link,
81
+ bool enable)
13582 {
13683 struct fsi_master_hub *hub = to_fsi_master_hub(master);
13784 int idx, bit;
....@@ -143,13 +90,17 @@
14390
14491 reg = cpu_to_be32(0x80000000 >> bit);
14592
93
+ if (!enable)
94
+ return fsi_device_write(hub->upstream, FSI_MCENP0 + (4 * idx),
95
+ &reg, 4);
96
+
14697 rc = fsi_device_write(hub->upstream, FSI_MSENP0 + (4 * idx), &reg, 4);
98
+ if (rc)
99
+ return rc;
147100
148101 mdelay(FSI_LINK_ENABLE_SETUP_TIME);
149102
150
- fsi_device_read(hub->upstream, FSI_MENP0 + (4 * idx), &reg, 4);
151
-
152
- return rc;
103
+ return 0;
153104 }
154105
155106 static void hub_master_release(struct device *dev)
....@@ -325,7 +276,7 @@
325276 return 0;
326277 }
327278
328
-static struct fsi_device_id hub_master_ids[] = {
279
+static const struct fsi_device_id hub_master_ids[] = {
329280 {
330281 .engine_type = FSI_ENGID_HUB_MASTER,
331282 .version = FSI_VERSION_ANY,