Skip to content

Commit 2b37c3e

Browse files
cbosticgregkh
authored andcommitted
drivers/fsi: Set slave SMODE to init communication
Set CFAM to appropriate ID so that the controlling master can manage link memory ranges. Add slave engine register definitions. Includes changes from Jeremy Kerr <jk@ozlabs.org>. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2b545cd commit 2b37c3e

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

‎drivers/fsi/fsi-core.c‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@
2222

2323
#include "fsi-master.h"
2424

25+
#define FSI_SLAVE_BASE 0x800
26+
27+
/*
28+
* FSI slave engine control register offsets
29+
*/
30+
#define FSI_SMODE 0x0 /* R/W: Mode register */
31+
32+
/*
33+
* SMODE fields
34+
*/
35+
#define FSI_SMODE_WSC 0x80000000 /* Warm start done */
36+
#define FSI_SMODE_ECRC 0x20000000 /* Hw CRC check */
37+
#define FSI_SMODE_SID_SHIFT 24 /* ID shift */
38+
#define FSI_SMODE_SID_MASK 3 /* ID Mask */
39+
#define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */
40+
#define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */
41+
#define FSI_SMODE_SD_SHIFT 16 /* Send delay shift */
42+
#define FSI_SMODE_SD_MASK 0xf /* Send delay mask */
43+
#define FSI_SMODE_LBCRR_SHIFT 8 /* Clk ratio shift */
44+
#define FSI_SMODE_LBCRR_MASK 0xf /* Clk ratio mask */
45+
2546
#define FSI_SLAVE_SIZE_23b 0x800000
2647

2748
static DEFINE_IDA(master_ida);
@@ -94,6 +115,52 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
94115
addr, val, size);
95116
}
96117

118+
/* Encode slave local bus echo delay */
119+
static inline uint32_t fsi_smode_echodly(int x)
120+
{
121+
return (x & FSI_SMODE_ED_MASK) << FSI_SMODE_ED_SHIFT;
122+
}
123+
124+
/* Encode slave local bus send delay */
125+
static inline uint32_t fsi_smode_senddly(int x)
126+
{
127+
return (x & FSI_SMODE_SD_MASK) << FSI_SMODE_SD_SHIFT;
128+
}
129+
130+
/* Encode slave local bus clock rate ratio */
131+
static inline uint32_t fsi_smode_lbcrr(int x)
132+
{
133+
return (x & FSI_SMODE_LBCRR_MASK) << FSI_SMODE_LBCRR_SHIFT;
134+
}
135+
136+
/* Encode slave ID */
137+
static inline uint32_t fsi_smode_sid(int x)
138+
{
139+
return (x & FSI_SMODE_SID_MASK) << FSI_SMODE_SID_SHIFT;
140+
}
141+
142+
static const uint32_t fsi_slave_smode(int id)
143+
{
144+
return FSI_SMODE_WSC | FSI_SMODE_ECRC
145+
| fsi_smode_sid(id)
146+
| fsi_smode_echodly(0xf) | fsi_smode_senddly(0xf)
147+
| fsi_smode_lbcrr(0x8);
148+
}
149+
150+
static int fsi_slave_set_smode(struct fsi_master *master, int link, int id)
151+
{
152+
uint32_t smode;
153+
154+
/* set our smode register with the slave ID field to 0; this enables
155+
* extended slave addressing
156+
*/
157+
smode = fsi_slave_smode(id);
158+
smode = cpu_to_be32(smode);
159+
160+
return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SMODE,
161+
&smode, sizeof(smode));
162+
}
163+
97164
static void fsi_slave_release(struct device *dev)
98165
{
99166
struct fsi_slave *slave = to_fsi_slave(dev);
@@ -132,6 +199,14 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
132199
dev_info(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n",
133200
chip_id, master->idx, link, id);
134201

202+
rc = fsi_slave_set_smode(master, link, id);
203+
if (rc) {
204+
dev_warn(&master->dev,
205+
"can't set smode on slave:%02x:%02x %d\n",
206+
link, id, rc);
207+
return -ENODEV;
208+
}
209+
135210
/* We can communicate with a slave; create the slave device and
136211
* register.
137212
*/

0 commit comments

Comments
 (0)