Lines Matching +full:reg +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0-only
14 #include "fsi-master.h"
29 * device (the hub->upstream device), and provides access to the downstream FSI
30 * bus as through an address range on the slave itself (->addr and ->size).
39 uint32_t addr, size; /* slave-relative addr of */ member
46 uint8_t id, uint32_t addr, void *val, size_t size) in hub_master_read() argument
51 return -EINVAL; in hub_master_read()
53 addr += hub->addr + (link * FSI_HUB_LINK_SIZE); in hub_master_read()
54 return fsi_slave_read(hub->upstream->slave, addr, val, size); in hub_master_read()
58 uint8_t id, uint32_t addr, const void *val, size_t size) in hub_master_write() argument
63 return -EINVAL; in hub_master_write()
65 addr += hub->addr + (link * FSI_HUB_LINK_SIZE); in hub_master_write()
66 return fsi_slave_write(hub->upstream->slave, addr, val, size); in hub_master_write()
71 uint32_t addr; in hub_master_break() local
74 addr = 0x4; in hub_master_break()
77 return hub_master_write(master, link, 0, addr, &cmd, sizeof(cmd)); in hub_master_break()
85 __be32 reg; in hub_master_link_enable() local
91 reg = cpu_to_be32(0x80000000 >> bit); in hub_master_link_enable()
94 return fsi_device_write(hub->upstream, FSI_MCENP0 + (4 * idx), in hub_master_link_enable()
95 ®, 4); in hub_master_link_enable()
97 rc = fsi_device_write(hub->upstream, FSI_MSENP0 + (4 * idx), ®, 4); in hub_master_link_enable()
126 struct fsi_device *dev = hub->upstream; in hub_master_init()
127 __be32 reg; in hub_master_init() local
130 reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK in hub_master_init()
132 rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); in hub_master_init()
137 reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK in hub_master_init()
139 rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); in hub_master_init()
143 reg = cpu_to_be32(FSI_MECTRL_EOAE | FSI_MECTRL_P8_AUTO_TERM); in hub_master_init()
144 rc = fsi_device_write(dev, FSI_MECTRL, ®, sizeof(reg)); in hub_master_init()
148 reg = cpu_to_be32(FSI_MMODE_EIP | FSI_MMODE_ECRC | FSI_MMODE_EPC in hub_master_init()
151 rc = fsi_device_write(dev, FSI_MMODE, ®, sizeof(reg)); in hub_master_init()
155 reg = cpu_to_be32(0xffff0000); in hub_master_init()
156 rc = fsi_device_write(dev, FSI_MDLYR, ®, sizeof(reg)); in hub_master_init()
160 reg = cpu_to_be32(~0); in hub_master_init()
161 rc = fsi_device_write(dev, FSI_MSENP0, ®, sizeof(reg)); in hub_master_init()
168 rc = fsi_device_write(dev, FSI_MCENP0, ®, sizeof(reg)); in hub_master_init()
172 rc = fsi_device_read(dev, FSI_MAEB, ®, sizeof(reg)); in hub_master_init()
176 reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK); in hub_master_init()
177 rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); in hub_master_init()
181 rc = fsi_device_read(dev, FSI_MLEVP0, ®, sizeof(reg)); in hub_master_init()
186 reg = cpu_to_be32(FSI_MRESB_RST_GEN); in hub_master_init()
187 rc = fsi_device_write(dev, FSI_MRESB0, ®, sizeof(reg)); in hub_master_init()
191 reg = cpu_to_be32(FSI_MRESB_RST_ERR); in hub_master_init()
192 return fsi_device_write(dev, FSI_MRESB0, ®, sizeof(reg)); in hub_master_init()
199 uint32_t reg, links; in hub_master_probe() local
207 reg = be32_to_cpu(__reg); in hub_master_probe()
208 links = (reg >> 8) & 0xff; in hub_master_probe()
209 dev_dbg(dev, "hub version %08x (%d links)\n", reg, links); in hub_master_probe()
211 rc = fsi_slave_claim_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET, in hub_master_probe()
220 rc = -ENOMEM; in hub_master_probe()
224 hub->addr = FSI_HUB_LINK_OFFSET; in hub_master_probe()
225 hub->size = FSI_HUB_LINK_SIZE * links; in hub_master_probe()
226 hub->upstream = fsi_dev; in hub_master_probe()
228 hub->master.dev.parent = dev; in hub_master_probe()
229 hub->master.dev.release = hub_master_release; in hub_master_probe()
230 hub->master.dev.of_node = of_node_get(dev_of_node(dev)); in hub_master_probe()
232 hub->master.n_links = links; in hub_master_probe()
233 hub->master.read = hub_master_read; in hub_master_probe()
234 hub->master.write = hub_master_write; in hub_master_probe()
235 hub->master.send_break = hub_master_break; in hub_master_probe()
236 hub->master.link_enable = hub_master_link_enable; in hub_master_probe()
242 rc = fsi_master_register(&hub->master); in hub_master_probe()
248 * will be freed (via ->release) during any subsequent call to in hub_master_probe()
253 get_device(&hub->master.dev); in hub_master_probe()
257 fsi_slave_release_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET, in hub_master_probe()
266 fsi_master_unregister(&hub->master); in hub_master_remove()
267 fsi_slave_release_range(hub->upstream->slave, hub->addr, hub->size); in hub_master_remove()
268 of_node_put(hub->master.dev.of_node); in hub_master_remove()
271 * master.dev will likely be ->release()ed after this, which free()s in hub_master_remove()
274 put_device(&hub->master.dev); in hub_master_remove()
290 .name = "fsi-master-hub",