Lines Matching refs:mp2

72 static int amd_mp2_wait_response(struct amd_mp2_dev *mp2, u8 cmd_id, u32 command_sts)  in amd_mp2_wait_response()  argument
76 if (!readl_poll_timeout(mp2->mmio + AMD_P2C_MSG0, cmd_resp.resp, in amd_mp2_wait_response()
86 static void amd_mp2_stb_send_cmd(struct amd_mp2_dev *mp2, u8 cmd_id, bool is_dma_used) in amd_mp2_stb_send_cmd() argument
95 writeq(mp2->dma_addr, mp2->mmio + AMD_C2P_MSG1); in amd_mp2_stb_send_cmd()
96 writel(cmd_base.ul, mp2->mmio + AMD_C2P_MSG0); in amd_mp2_stb_send_cmd()
99 static int amd_mp2_stb_region(struct amd_mp2_dev *mp2) in amd_mp2_stb_region() argument
101 struct device *dev = &mp2->pdev->dev; in amd_mp2_stb_region()
102 unsigned int len = mp2->stb_len; in amd_mp2_stb_region()
104 if (!mp2->stbdata) { in amd_mp2_stb_region()
105 mp2->vslbase = dmam_alloc_coherent(dev, len, &mp2->dma_addr, GFP_KERNEL); in amd_mp2_stb_region()
106 if (!mp2->vslbase) in amd_mp2_stb_region()
109 mp2->stbdata = devm_kzalloc(dev, len, GFP_KERNEL); in amd_mp2_stb_region()
110 if (!mp2->stbdata) in amd_mp2_stb_region()
117 static int amd_mp2_process_cmd(struct amd_mp2_dev *mp2, struct file *filp) in amd_mp2_process_cmd() argument
119 struct device *dev = &mp2->pdev->dev; in amd_mp2_process_cmd()
123 stb_dv.data_valid = readl(mp2->mmio + AMD_P2C_MSG1); in amd_mp2_process_cmd()
136 mp2->stb_len = BIT(stb_dv.val.length) * SZ_1K; in amd_mp2_process_cmd()
138 status = amd_mp2_stb_region(mp2); in amd_mp2_process_cmd()
144 amd_mp2_stb_send_cmd(mp2, VALID_MSG, true); in amd_mp2_process_cmd()
145 status = amd_mp2_wait_response(mp2, VALID_MSG, VALID_RESPONSE); in amd_mp2_process_cmd()
147 memcpy_fromio(mp2->stbdata, mp2->vslbase, mp2->stb_len); in amd_mp2_process_cmd()
148 filp->private_data = mp2->stbdata; in amd_mp2_process_cmd()
149 mp2->is_stb_data = true; in amd_mp2_process_cmd()
161 struct amd_mp2_dev *mp2 = dev->mp2; in amd_mp2_stb_debugfs_open() local
163 if (mp2) { in amd_mp2_stb_debugfs_open()
164 if (!mp2->is_stb_data) in amd_mp2_stb_debugfs_open()
165 return amd_mp2_process_cmd(mp2, filp); in amd_mp2_stb_debugfs_open()
167 filp->private_data = mp2->stbdata; in amd_mp2_stb_debugfs_open()
179 struct amd_mp2_dev *mp2 = dev->mp2; in amd_mp2_stb_debugfs_read() local
181 if (!mp2) in amd_mp2_stb_debugfs_read()
187 return simple_read_from_buffer(buf, size, pos, filp->private_data, mp2->stb_len); in amd_mp2_stb_debugfs_read()
207 struct amd_mp2_dev *mp2 = dev->mp2; in amd_mp2_stb_deinit() local
210 if (mp2 && mp2->pdev) { in amd_mp2_stb_deinit()
211 pdev = mp2->pdev; in amd_mp2_stb_deinit()
213 if (mp2->mmio) in amd_mp2_stb_deinit()
218 if (mp2->devres_gid) in amd_mp2_stb_deinit()
219 devres_release_group(&pdev->dev, mp2->devres_gid); in amd_mp2_stb_deinit()
221 dev->mp2 = NULL; in amd_mp2_stb_deinit()
227 struct amd_mp2_dev *mp2 = NULL; in amd_mp2_stb_init() local
231 mp2 = devm_kzalloc(dev->dev, sizeof(*mp2), GFP_KERNEL); in amd_mp2_stb_init()
232 if (!mp2) in amd_mp2_stb_init()
239 dev->mp2 = mp2; in amd_mp2_stb_init()
240 mp2->pdev = pdev; in amd_mp2_stb_init()
242 mp2->devres_gid = devres_open_group(&pdev->dev, NULL, GFP_KERNEL); in amd_mp2_stb_init()
243 if (!mp2->devres_gid) { in amd_mp2_stb_init()
260 mp2->mmio = pcim_iomap_table(pdev)[MP2_MMIO_BAR]; in amd_mp2_stb_init()
261 if (!mp2->mmio) { in amd_mp2_stb_init()