.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * FSI hub master driver |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
14 | 6 | */ |
---|
15 | 7 | |
---|
16 | 8 | #include <linux/delay.h> |
---|
.. | .. |
---|
21 | 13 | |
---|
22 | 14 | #include "fsi-master.h" |
---|
23 | 15 | |
---|
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 | | - |
---|
67 | 16 | #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 |
---|
71 | 17 | |
---|
72 | 18 | #define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ |
---|
73 | 19 | |
---|
.. | .. |
---|
131 | 77 | return hub_master_write(master, link, 0, addr, &cmd, sizeof(cmd)); |
---|
132 | 78 | } |
---|
133 | 79 | |
---|
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) |
---|
135 | 82 | { |
---|
136 | 83 | struct fsi_master_hub *hub = to_fsi_master_hub(master); |
---|
137 | 84 | int idx, bit; |
---|
.. | .. |
---|
143 | 90 | |
---|
144 | 91 | reg = cpu_to_be32(0x80000000 >> bit); |
---|
145 | 92 | |
---|
| 93 | + if (!enable) |
---|
| 94 | + return fsi_device_write(hub->upstream, FSI_MCENP0 + (4 * idx), |
---|
| 95 | + ®, 4); |
---|
| 96 | + |
---|
146 | 97 | rc = fsi_device_write(hub->upstream, FSI_MSENP0 + (4 * idx), ®, 4); |
---|
| 98 | + if (rc) |
---|
| 99 | + return rc; |
---|
147 | 100 | |
---|
148 | 101 | mdelay(FSI_LINK_ENABLE_SETUP_TIME); |
---|
149 | 102 | |
---|
150 | | - fsi_device_read(hub->upstream, FSI_MENP0 + (4 * idx), ®, 4); |
---|
151 | | - |
---|
152 | | - return rc; |
---|
| 103 | + return 0; |
---|
153 | 104 | } |
---|
154 | 105 | |
---|
155 | 106 | static void hub_master_release(struct device *dev) |
---|
.. | .. |
---|
325 | 276 | return 0; |
---|
326 | 277 | } |
---|
327 | 278 | |
---|
328 | | -static struct fsi_device_id hub_master_ids[] = { |
---|
| 279 | +static const struct fsi_device_id hub_master_ids[] = { |
---|
329 | 280 | { |
---|
330 | 281 | .engine_type = FSI_ENGID_HUB_MASTER, |
---|
331 | 282 | .version = FSI_VERSION_ANY, |
---|