• Home
  • Raw
  • Download

Lines Matching full:mxic

6 //	Mason Yang <masonccyang@mxic.com.tw>
7 // zhengxunli <zhengxunli@mxic.com.tw>
177 static int mxic_spi_clk_enable(struct mxic_spi *mxic) in mxic_spi_clk_enable() argument
181 ret = clk_prepare_enable(mxic->send_clk); in mxic_spi_clk_enable()
185 ret = clk_prepare_enable(mxic->send_dly_clk); in mxic_spi_clk_enable()
192 clk_disable_unprepare(mxic->send_clk); in mxic_spi_clk_enable()
197 static void mxic_spi_clk_disable(struct mxic_spi *mxic) in mxic_spi_clk_disable() argument
199 clk_disable_unprepare(mxic->send_clk); in mxic_spi_clk_disable()
200 clk_disable_unprepare(mxic->send_dly_clk); in mxic_spi_clk_disable()
203 static void mxic_spi_set_input_delay_dqs(struct mxic_spi *mxic, u8 idly_code) in mxic_spi_set_input_delay_dqs() argument
209 mxic->regs + IDLY_CODE(0)); in mxic_spi_set_input_delay_dqs()
214 mxic->regs + IDLY_CODE(1)); in mxic_spi_set_input_delay_dqs()
217 static int mxic_spi_clk_setup(struct mxic_spi *mxic, unsigned long freq) in mxic_spi_clk_setup() argument
221 ret = clk_set_rate(mxic->send_clk, freq); in mxic_spi_clk_setup()
225 ret = clk_set_rate(mxic->send_dly_clk, freq); in mxic_spi_clk_setup()
233 mxic_spi_set_input_delay_dqs(mxic, 0xf); in mxic_spi_clk_setup()
243 ret = clk_set_phase(mxic->send_dly_clk, 9 * freq / 25000000); in mxic_spi_clk_setup()
250 static int mxic_spi_set_freq(struct mxic_spi *mxic, unsigned long freq) in mxic_spi_set_freq() argument
254 if (mxic->cur_speed_hz == freq) in mxic_spi_set_freq()
257 mxic_spi_clk_disable(mxic); in mxic_spi_set_freq()
258 ret = mxic_spi_clk_setup(mxic, freq); in mxic_spi_set_freq()
262 ret = mxic_spi_clk_enable(mxic); in mxic_spi_set_freq()
266 mxic->cur_speed_hz = freq; in mxic_spi_set_freq()
271 static void mxic_spi_hw_init(struct mxic_spi *mxic) in mxic_spi_hw_init() argument
273 writel(0, mxic->regs + DATA_STROB); in mxic_spi_hw_init()
274 writel(INT_STS_ALL, mxic->regs + INT_STS_EN); in mxic_spi_hw_init()
275 writel(0, mxic->regs + HC_EN); in mxic_spi_hw_init()
276 writel(0, mxic->regs + LRD_CFG); in mxic_spi_hw_init()
277 writel(0, mxic->regs + LRD_CTRL); in mxic_spi_hw_init()
280 mxic->regs + HC_CFG); in mxic_spi_hw_init()
283 static int mxic_spi_data_xfer(struct mxic_spi *mxic, const void *txbuf, in mxic_spi_data_xfer() argument
300 ret = readl_poll_timeout(mxic->regs + INT_STS, sts, in mxic_spi_data_xfer()
305 writel(data, mxic->regs + TXD(nbytes % 4)); in mxic_spi_data_xfer()
307 ret = readl_poll_timeout(mxic->regs + INT_STS, sts, in mxic_spi_data_xfer()
312 ret = readl_poll_timeout(mxic->regs + INT_STS, sts, in mxic_spi_data_xfer()
318 data = readl(mxic->regs + RXD); in mxic_spi_data_xfer()
323 WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY); in mxic_spi_data_xfer()
351 struct mxic_spi *mxic = spi_master_get_devdata(mem->spi->master); in mxic_spi_mem_exec_op() local
357 ret = mxic_spi_set_freq(mxic, mem->spi->max_speed_hz); in mxic_spi_mem_exec_op()
370 mxic->regs + HC_CFG); in mxic_spi_mem_exec_op()
371 writel(HC_EN_BIT, mxic->regs + HC_EN); in mxic_spi_mem_exec_op()
388 writel(ss_ctrl, mxic->regs + SS_CTRL(mem->spi->chip_select)); in mxic_spi_mem_exec_op()
390 writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_ASSERT, in mxic_spi_mem_exec_op()
391 mxic->regs + HC_CFG); in mxic_spi_mem_exec_op()
393 ret = mxic_spi_data_xfer(mxic, &opcode, NULL, 1); in mxic_spi_mem_exec_op()
400 ret = mxic_spi_data_xfer(mxic, addr, NULL, op->addr.nbytes); in mxic_spi_mem_exec_op()
404 ret = mxic_spi_data_xfer(mxic, NULL, NULL, op->dummy.nbytes); in mxic_spi_mem_exec_op()
408 ret = mxic_spi_data_xfer(mxic, in mxic_spi_mem_exec_op()
416 writel(readl(mxic->regs + HC_CFG) & ~HC_CFG_MAN_CS_ASSERT, in mxic_spi_mem_exec_op()
417 mxic->regs + HC_CFG); in mxic_spi_mem_exec_op()
418 writel(0, mxic->regs + HC_EN); in mxic_spi_mem_exec_op()
430 struct mxic_spi *mxic = spi_master_get_devdata(spi->master); in mxic_spi_set_cs() local
433 writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_EN, in mxic_spi_set_cs()
434 mxic->regs + HC_CFG); in mxic_spi_set_cs()
435 writel(HC_EN_BIT, mxic->regs + HC_EN); in mxic_spi_set_cs()
436 writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_ASSERT, in mxic_spi_set_cs()
437 mxic->regs + HC_CFG); in mxic_spi_set_cs()
439 writel(readl(mxic->regs + HC_CFG) & ~HC_CFG_MAN_CS_ASSERT, in mxic_spi_set_cs()
440 mxic->regs + HC_CFG); in mxic_spi_set_cs()
441 writel(0, mxic->regs + HC_EN); in mxic_spi_set_cs()
449 struct mxic_spi *mxic = spi_master_get_devdata(master); in mxic_spi_transfer_one() local
461 ret = mxic_spi_set_freq(mxic, t->speed_hz); in mxic_spi_transfer_one()
479 mxic->regs + SS_CTRL(0)); in mxic_spi_transfer_one()
481 ret = mxic_spi_data_xfer(mxic, t->tx_buf, t->rx_buf, t->len); in mxic_spi_transfer_one()
493 struct mxic_spi *mxic = spi_master_get_devdata(master); in mxic_spi_runtime_suspend() local
495 mxic_spi_clk_disable(mxic); in mxic_spi_runtime_suspend()
496 clk_disable_unprepare(mxic->ps_clk); in mxic_spi_runtime_suspend()
504 struct mxic_spi *mxic = spi_master_get_devdata(master); in mxic_spi_runtime_resume() local
507 ret = clk_prepare_enable(mxic->ps_clk); in mxic_spi_runtime_resume()
513 return mxic_spi_clk_enable(mxic); in mxic_spi_runtime_resume()
525 struct mxic_spi *mxic; in mxic_spi_probe() local
534 mxic = spi_master_get_devdata(master); in mxic_spi_probe()
538 mxic->ps_clk = devm_clk_get(&pdev->dev, "ps_clk"); in mxic_spi_probe()
539 if (IS_ERR(mxic->ps_clk)) in mxic_spi_probe()
540 return PTR_ERR(mxic->ps_clk); in mxic_spi_probe()
542 mxic->send_clk = devm_clk_get(&pdev->dev, "send_clk"); in mxic_spi_probe()
543 if (IS_ERR(mxic->send_clk)) in mxic_spi_probe()
544 return PTR_ERR(mxic->send_clk); in mxic_spi_probe()
546 mxic->send_dly_clk = devm_clk_get(&pdev->dev, "send_dly_clk"); in mxic_spi_probe()
547 if (IS_ERR(mxic->send_dly_clk)) in mxic_spi_probe()
548 return PTR_ERR(mxic->send_dly_clk); in mxic_spi_probe()
551 mxic->regs = devm_ioremap_resource(&pdev->dev, res); in mxic_spi_probe()
552 if (IS_ERR(mxic->regs)) in mxic_spi_probe()
553 return PTR_ERR(mxic->regs); in mxic_spi_probe()
568 mxic_spi_hw_init(mxic); in mxic_spi_probe()
599 .name = "mxic-spi",
606 MODULE_AUTHOR("Mason Yang <masonccyang@mxic.com.tw>");