Lines Matching refs:conf
78 void (*write_data)(struct altera_cvp_conf *conf,
88 void (*switch_clk)(struct altera_cvp_conf *conf);
89 int (*clear_state)(struct altera_cvp_conf *conf);
96 static int altera_read_config_byte(struct altera_cvp_conf *conf, in altera_read_config_byte() argument
99 return pci_read_config_byte(conf->pci_dev, conf->vsec_offset + where, in altera_read_config_byte()
103 static int altera_read_config_dword(struct altera_cvp_conf *conf, in altera_read_config_dword() argument
106 return pci_read_config_dword(conf->pci_dev, conf->vsec_offset + where, in altera_read_config_dword()
110 static int altera_write_config_dword(struct altera_cvp_conf *conf, in altera_write_config_dword() argument
113 return pci_write_config_dword(conf->pci_dev, conf->vsec_offset + where, in altera_write_config_dword()
119 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_state() local
122 altera_read_config_dword(conf, VSE_CVP_STATUS, &status); in altera_cvp_state()
133 static void altera_cvp_write_data_iomem(struct altera_cvp_conf *conf, u32 val) in altera_cvp_write_data_iomem() argument
135 writel(val, conf->map); in altera_cvp_write_data_iomem()
138 static void altera_cvp_write_data_config(struct altera_cvp_conf *conf, u32 val) in altera_cvp_write_data_config() argument
140 pci_write_config_dword(conf->pci_dev, conf->vsec_offset + VSE_CVP_DATA, in altera_cvp_write_data_config()
145 static void altera_cvp_dummy_write(struct altera_cvp_conf *conf) in altera_cvp_dummy_write() argument
151 altera_read_config_dword(conf, VSE_CVP_MODE_CTRL, &val); in altera_cvp_dummy_write()
154 altera_write_config_dword(conf, VSE_CVP_MODE_CTRL, val); in altera_cvp_dummy_write()
157 conf->write_data(conf, 0); /* dummy data, could be any value */ in altera_cvp_dummy_write()
160 static int altera_cvp_wait_status(struct altera_cvp_conf *conf, u32 status_mask, in altera_cvp_wait_status() argument
171 altera_read_config_dword(conf, VSE_CVP_STATUS, &val); in altera_cvp_wait_status()
184 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_chk_error() local
189 ret = altera_read_config_dword(conf, VSE_CVP_STATUS, &val); in altera_cvp_chk_error()
204 static int altera_cvp_v2_clear_state(struct altera_cvp_conf *conf) in altera_cvp_v2_clear_state() argument
210 ret = altera_read_config_dword(conf, VSE_CVP_PROG_CTRL, &val); in altera_cvp_v2_clear_state()
212 dev_err(&conf->pci_dev->dev, in altera_cvp_v2_clear_state()
218 ret = altera_write_config_dword(conf, VSE_CVP_PROG_CTRL, val); in altera_cvp_v2_clear_state()
220 dev_err(&conf->pci_dev->dev, in altera_cvp_v2_clear_state()
225 return altera_cvp_wait_status(conf, VSE_CVP_STATUS_CFG_RDY, 0, in altera_cvp_v2_clear_state()
226 conf->priv->poll_time_us); in altera_cvp_v2_clear_state()
233 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_v2_wait_for_credit() local
238 ret = altera_read_config_byte(conf, VSE_CVP_TX_CREDITS, &val); in altera_cvp_v2_wait_for_credit()
240 dev_err(&conf->pci_dev->dev, in altera_cvp_v2_wait_for_credit()
246 if (val - (u8)conf->sent_packets) in altera_cvp_v2_wait_for_credit()
251 dev_err(&conf->pci_dev->dev, in altera_cvp_v2_wait_for_credit()
253 val, conf->sent_packets); in altera_cvp_v2_wait_for_credit()
261 dev_err(&conf->pci_dev->dev, "Timeout waiting for credit\n"); in altera_cvp_v2_wait_for_credit()
265 static int altera_cvp_send_block(struct altera_cvp_conf *conf, in altera_cvp_send_block() argument
272 conf->write_data(conf, *data++); in altera_cvp_send_block()
279 conf->write_data(conf, *data & mask); in altera_cvp_send_block()
288 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_teardown() local
293 altera_read_config_dword(conf, VSE_CVP_PROG_CTRL, &val); in altera_cvp_teardown()
295 altera_write_config_dword(conf, VSE_CVP_PROG_CTRL, val); in altera_cvp_teardown()
299 altera_write_config_dword(conf, VSE_CVP_PROG_CTRL, val); in altera_cvp_teardown()
306 if (conf->priv->switch_clk) in altera_cvp_teardown()
307 conf->priv->switch_clk(conf); in altera_cvp_teardown()
310 ret = altera_cvp_wait_status(conf, VSE_CVP_STATUS_CFG_RDY, 0, in altera_cvp_teardown()
311 conf->priv->poll_time_us); in altera_cvp_teardown()
322 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_write_init() local
335 conf->numclks = 8; /* ratio for all compressed images */ in altera_cvp_write_init()
337 conf->numclks = 4; /* for uncompressed and encrypted images */ in altera_cvp_write_init()
339 conf->numclks = 1; /* for uncompressed and unencrypted images */ in altera_cvp_write_init()
342 altera_read_config_dword(conf, VSE_CVP_STATUS, &val); in altera_cvp_write_init()
360 altera_read_config_dword(conf, VSE_CVP_MODE_CTRL, &val); in altera_cvp_write_init()
362 altera_write_config_dword(conf, VSE_CVP_MODE_CTRL, val); in altera_cvp_write_init()
365 altera_read_config_dword(conf, VSE_CVP_MODE_CTRL, &val); in altera_cvp_write_init()
367 altera_write_config_dword(conf, VSE_CVP_MODE_CTRL, val); in altera_cvp_write_init()
373 if (conf->priv->switch_clk) in altera_cvp_write_init()
374 conf->priv->switch_clk(conf); in altera_cvp_write_init()
376 if (conf->priv->clear_state) { in altera_cvp_write_init()
377 ret = conf->priv->clear_state(conf); in altera_cvp_write_init()
384 conf->sent_packets = 0; in altera_cvp_write_init()
387 altera_read_config_dword(conf, VSE_CVP_PROG_CTRL, &val); in altera_cvp_write_init()
390 altera_write_config_dword(conf, VSE_CVP_PROG_CTRL, val); in altera_cvp_write_init()
393 ret = altera_cvp_wait_status(conf, VSE_CVP_STATUS_CFG_RDY, in altera_cvp_write_init()
395 conf->priv->poll_time_us); in altera_cvp_write_init()
405 if (conf->priv->switch_clk) in altera_cvp_write_init()
406 conf->priv->switch_clk(conf); in altera_cvp_write_init()
417 altera_read_config_dword(conf, VSE_CVP_PROG_CTRL, &val); in altera_cvp_write_init()
419 altera_write_config_dword(conf, VSE_CVP_PROG_CTRL, val); in altera_cvp_write_init()
422 if (conf->priv->switch_clk) { in altera_cvp_write_init()
423 altera_read_config_dword(conf, VSE_CVP_MODE_CTRL, &val); in altera_cvp_write_init()
425 val |= conf->numclks << VSE_CVP_MODE_CTRL_NUMCLKS_OFF; in altera_cvp_write_init()
426 altera_write_config_dword(conf, VSE_CVP_MODE_CTRL, val); in altera_cvp_write_init()
434 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_write() local
446 if (conf->priv->wait_credit) { in altera_cvp_write()
447 status = conf->priv->wait_credit(mgr, done); in altera_cvp_write()
449 dev_err(&conf->pci_dev->dev, in altera_cvp_write()
455 len = min(conf->priv->block_size, remaining); in altera_cvp_write()
456 altera_cvp_send_block(conf, data, len); in altera_cvp_write()
460 conf->sent_packets++; in altera_cvp_write()
487 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_write_complete() local
496 altera_read_config_dword(conf, VSE_UNCOR_ERR_STATUS, &val); in altera_cvp_write_complete()
503 altera_read_config_dword(conf, VSE_CVP_MODE_CTRL, &val); in altera_cvp_write_complete()
506 altera_write_config_dword(conf, VSE_CVP_MODE_CTRL, val); in altera_cvp_write_complete()
510 ret = altera_cvp_wait_status(conf, mask, mask, in altera_cvp_write_complete()
511 conf->priv->user_time_us); in altera_cvp_write_complete()
579 struct altera_cvp_conf *conf; in altera_cvp_probe() local
611 conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL); in altera_cvp_probe()
612 if (!conf) in altera_cvp_probe()
615 conf->vsec_offset = offset; in altera_cvp_probe()
638 conf->pci_dev = pdev; in altera_cvp_probe()
639 conf->write_data = altera_cvp_write_data_iomem; in altera_cvp_probe()
641 if (conf->vsec_offset == V1_VSEC_OFFSET) in altera_cvp_probe()
642 conf->priv = &cvp_priv_v1; in altera_cvp_probe()
644 conf->priv = &cvp_priv_v2; in altera_cvp_probe()
646 conf->map = pci_iomap(pdev, CVP_BAR, 0); in altera_cvp_probe()
647 if (!conf->map) { in altera_cvp_probe()
649 conf->write_data = altera_cvp_write_data_config; in altera_cvp_probe()
652 snprintf(conf->mgr_name, sizeof(conf->mgr_name), "%s @%s", in altera_cvp_probe()
655 mgr = fpga_mgr_register(&pdev->dev, conf->mgr_name, in altera_cvp_probe()
656 &altera_cvp_ops, conf); in altera_cvp_probe()
667 if (conf->map) in altera_cvp_probe()
668 pci_iounmap(pdev, conf->map); in altera_cvp_probe()
679 struct altera_cvp_conf *conf = mgr->priv; in altera_cvp_remove() local
683 if (conf->map) in altera_cvp_remove()
684 pci_iounmap(pdev, conf->map); in altera_cvp_remove()