[PATCH linux dev-4.7 v2 3/7] drivers/fsi: Define hub master callbacks
Christopher Bostic
cbostic at linux.vnet.ibm.com
Wed Feb 22 08:50:28 AEDT 2017
Define hub master read, write, link enable, and break ops.
Signed-off-by: Christopher Bostic <cbostic at linux.vnet.ibm.com>
---
drivers/fsi/fsi-core.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 4199188..360c02a 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -27,6 +27,7 @@
#define DEBUG
#define FSI_N_SLAVES 4
+#define FSI_BREAK 0xc0de0000
#define FSI_SLAVE_CONF_NEXT_MASK 0x80000000
#define FSI_SLAVE_CONF_SLOTS_MASK 0x00ff0000
@@ -47,6 +48,7 @@
#define FSI_ENGID_HUB_MASTER 0x1c
#define FSI_ENGID_HUB_LINK 0x1d
#define FSI_HUB_LINK_OFFSET 0x80000
+#define FSI_MASTER_HUB_LINK_SIZE 0x80000
#define FSI_HUB_MASTER_MAX_LINKS 8
static const int engine_page_size = 0x400;
@@ -72,6 +74,7 @@ struct fsi_master_hub {
/* master address space */
};
+#define to_fsi_master_hub(d) container_of(d, struct fsi_master_hub, master)
#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
@@ -230,23 +233,47 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
int hub_master_read(struct fsi_master *master, int linkno, uint8_t slave,
uint32_t addr, void *val, size_t size)
{
- return 0;
+ struct fsi_master_hub *hub = to_fsi_master_hub(master);
+
+ addr += (linkno * FSI_MASTER_HUB_LINK_SIZE) + hub->base;
+ return fsi_slave_read(hub->slave, addr, val, size);
}
int hub_master_write(struct fsi_master *master, int linkno, uint8_t slave,
uint32_t addr, const void *val, size_t size)
{
- return 0;
+ struct fsi_master_hub *hub = to_fsi_master_hub(master);
+
+ addr += (linkno * FSI_MASTER_HUB_LINK_SIZE) + hub->base;
+ return fsi_slave_write(hub->slave, addr, val, size);
}
int hub_master_break(struct fsi_master *master, int linkno)
{
- return 0;
+ struct fsi_master_hub *hub = to_fsi_master_hub(master);
+ uint32_t command;
+ uint32_t break_offset = 0x4; /* hw workaround */
+ uint32_t addr;
+
+ command = FSI_BREAK;
+ addr = (linkno * FSI_MASTER_HUB_LINK_SIZE) + hub->base;
+ return fsi_slave_write(hub->slave, addr + break_offset, &command,
+ sizeof(command));
}
int hub_master_link_enable(struct fsi_master *master, int linkno)
{
- return 0;
+ struct fsi_master_hub *hub = to_fsi_master_hub(master);
+ uint32_t menp = L_MSB_MASK(linkno);
+ int rc;
+
+ rc = fsi_slave_write(hub->slave, hub->control_regs + FSI_MSENP0, &menp,
+ sizeof(menp));
+
+ /* Wait for hw to finish enable */
+ mdelay(10);
+
+ return rc;
}
static int hub_master_init(struct fsi_master_hub *hub)
@@ -571,6 +598,7 @@ static int fsi_slave_init(struct fsi_master *master,
slave->id = slave_id;
slave->dev.parent = master->dev;
slave->dev.release = fsi_slave_release;
+ slave->link = link;
dev_set_name(&slave->dev, "slave@%02x:%02x", link, slave_id);
rc = device_register(&slave->dev);
--
1.8.2.2
More information about the openbmc
mailing list