Lines Matching refs:aq
225 static u32 atmel_qspi_read(struct atmel_qspi *aq, u32 offset) in atmel_qspi_read() argument
227 u32 value = readl_relaxed(aq->regs + offset); in atmel_qspi_read()
232 dev_vdbg(&aq->pdev->dev, "read 0x%08x from %s\n", value, in atmel_qspi_read()
239 static void atmel_qspi_write(u32 value, struct atmel_qspi *aq, u32 offset) in atmel_qspi_write() argument
244 dev_vdbg(&aq->pdev->dev, "write 0x%08x into %s\n", value, in atmel_qspi_write()
248 writel_relaxed(value, aq->regs + offset); in atmel_qspi_write()
300 static int atmel_qspi_set_cfg(struct atmel_qspi *aq, in atmel_qspi_set_cfg() argument
383 if (aq->mr != QSPI_MR_SMM) { in atmel_qspi_set_cfg()
384 atmel_qspi_write(QSPI_MR_SMM, aq, QSPI_MR); in atmel_qspi_set_cfg()
385 aq->mr = QSPI_MR_SMM; in atmel_qspi_set_cfg()
389 (void)atmel_qspi_read(aq, QSPI_SR); in atmel_qspi_set_cfg()
391 if (aq->caps->has_ricr) { in atmel_qspi_set_cfg()
396 atmel_qspi_write(iar, aq, QSPI_IAR); in atmel_qspi_set_cfg()
398 atmel_qspi_write(icr, aq, QSPI_RICR); in atmel_qspi_set_cfg()
400 atmel_qspi_write(icr, aq, QSPI_WICR); in atmel_qspi_set_cfg()
401 atmel_qspi_write(ifr, aq, QSPI_IFR); in atmel_qspi_set_cfg()
407 atmel_qspi_write(iar, aq, QSPI_IAR); in atmel_qspi_set_cfg()
408 atmel_qspi_write(icr, aq, QSPI_ICR); in atmel_qspi_set_cfg()
409 atmel_qspi_write(ifr, aq, QSPI_IFR); in atmel_qspi_set_cfg()
417 struct atmel_qspi *aq = spi_controller_get_devdata(mem->spi->master); in atmel_qspi_exec_op() local
426 if (op->addr.val + op->data.nbytes > aq->mmap_size) in atmel_qspi_exec_op()
429 err = atmel_qspi_set_cfg(aq, op, &offset); in atmel_qspi_exec_op()
436 (void)atmel_qspi_read(aq, QSPI_IFR); in atmel_qspi_exec_op()
440 memcpy_fromio(op->data.buf.in, aq->mem + offset, in atmel_qspi_exec_op()
443 memcpy_toio(aq->mem + offset, op->data.buf.out, in atmel_qspi_exec_op()
447 atmel_qspi_write(QSPI_CR_LASTXFER, aq, QSPI_CR); in atmel_qspi_exec_op()
451 sr = atmel_qspi_read(aq, QSPI_SR); in atmel_qspi_exec_op()
456 reinit_completion(&aq->cmd_completion); in atmel_qspi_exec_op()
457 aq->pending = sr & QSPI_SR_CMD_COMPLETED; in atmel_qspi_exec_op()
458 atmel_qspi_write(QSPI_SR_CMD_COMPLETED, aq, QSPI_IER); in atmel_qspi_exec_op()
459 if (!wait_for_completion_timeout(&aq->cmd_completion, in atmel_qspi_exec_op()
462 atmel_qspi_write(QSPI_SR_CMD_COMPLETED, aq, QSPI_IDR); in atmel_qspi_exec_op()
481 struct atmel_qspi *aq = spi_controller_get_devdata(ctrl); in atmel_qspi_setup() local
491 src_rate = clk_get_rate(aq->pclk); in atmel_qspi_setup()
500 aq->scr = QSPI_SCR_SCBR(scbr); in atmel_qspi_setup()
501 atmel_qspi_write(aq->scr, aq, QSPI_SCR); in atmel_qspi_setup()
506 static void atmel_qspi_init(struct atmel_qspi *aq) in atmel_qspi_init() argument
509 atmel_qspi_write(QSPI_CR_SWRST, aq, QSPI_CR); in atmel_qspi_init()
512 atmel_qspi_write(QSPI_MR_SMM, aq, QSPI_MR); in atmel_qspi_init()
513 aq->mr = QSPI_MR_SMM; in atmel_qspi_init()
516 atmel_qspi_write(QSPI_CR_QSPIEN, aq, QSPI_CR); in atmel_qspi_init()
521 struct atmel_qspi *aq = dev_id; in atmel_qspi_interrupt() local
524 status = atmel_qspi_read(aq, QSPI_SR); in atmel_qspi_interrupt()
525 mask = atmel_qspi_read(aq, QSPI_IMR); in atmel_qspi_interrupt()
531 aq->pending |= pending; in atmel_qspi_interrupt()
532 if ((aq->pending & QSPI_SR_CMD_COMPLETED) == QSPI_SR_CMD_COMPLETED) in atmel_qspi_interrupt()
533 complete(&aq->cmd_completion); in atmel_qspi_interrupt()
541 struct atmel_qspi *aq; in atmel_qspi_probe() local
545 ctrl = devm_spi_alloc_master(&pdev->dev, sizeof(*aq)); in atmel_qspi_probe()
557 aq = spi_controller_get_devdata(ctrl); in atmel_qspi_probe()
559 init_completion(&aq->cmd_completion); in atmel_qspi_probe()
560 aq->pdev = pdev; in atmel_qspi_probe()
564 aq->regs = devm_ioremap_resource(&pdev->dev, res); in atmel_qspi_probe()
565 if (IS_ERR(aq->regs)) { in atmel_qspi_probe()
567 return PTR_ERR(aq->regs); in atmel_qspi_probe()
572 aq->mem = devm_ioremap_resource(&pdev->dev, res); in atmel_qspi_probe()
573 if (IS_ERR(aq->mem)) { in atmel_qspi_probe()
575 return PTR_ERR(aq->mem); in atmel_qspi_probe()
578 aq->mmap_size = resource_size(res); in atmel_qspi_probe()
581 aq->pclk = devm_clk_get(&pdev->dev, "pclk"); in atmel_qspi_probe()
582 if (IS_ERR(aq->pclk)) in atmel_qspi_probe()
583 aq->pclk = devm_clk_get(&pdev->dev, NULL); in atmel_qspi_probe()
585 if (IS_ERR(aq->pclk)) { in atmel_qspi_probe()
587 return PTR_ERR(aq->pclk); in atmel_qspi_probe()
591 err = clk_prepare_enable(aq->pclk); in atmel_qspi_probe()
597 aq->caps = of_device_get_match_data(&pdev->dev); in atmel_qspi_probe()
598 if (!aq->caps) { in atmel_qspi_probe()
604 if (aq->caps->has_qspick) { in atmel_qspi_probe()
606 aq->qspick = devm_clk_get(&pdev->dev, "qspick"); in atmel_qspi_probe()
607 if (IS_ERR(aq->qspick)) { in atmel_qspi_probe()
609 err = PTR_ERR(aq->qspick); in atmel_qspi_probe()
614 err = clk_prepare_enable(aq->qspick); in atmel_qspi_probe()
629 0, dev_name(&pdev->dev), aq); in atmel_qspi_probe()
633 atmel_qspi_init(aq); in atmel_qspi_probe()
642 clk_disable_unprepare(aq->qspick); in atmel_qspi_probe()
644 clk_disable_unprepare(aq->pclk); in atmel_qspi_probe()
652 struct atmel_qspi *aq = spi_controller_get_devdata(ctrl); in atmel_qspi_remove() local
655 atmel_qspi_write(QSPI_CR_QSPIDIS, aq, QSPI_CR); in atmel_qspi_remove()
656 clk_disable_unprepare(aq->qspick); in atmel_qspi_remove()
657 clk_disable_unprepare(aq->pclk); in atmel_qspi_remove()
664 struct atmel_qspi *aq = spi_controller_get_devdata(ctrl); in atmel_qspi_suspend() local
666 clk_disable_unprepare(aq->qspick); in atmel_qspi_suspend()
667 clk_disable_unprepare(aq->pclk); in atmel_qspi_suspend()
675 struct atmel_qspi *aq = spi_controller_get_devdata(ctrl); in atmel_qspi_resume() local
677 clk_prepare_enable(aq->pclk); in atmel_qspi_resume()
678 clk_prepare_enable(aq->qspick); in atmel_qspi_resume()
680 atmel_qspi_init(aq); in atmel_qspi_resume()
682 atmel_qspi_write(aq->scr, aq, QSPI_SCR); in atmel_qspi_resume()