Lines Matching refs:mxic

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()
308 ret = readl_poll_timeout(mxic->regs + INT_STS, sts, in mxic_spi_data_xfer()
314 ret = readl_poll_timeout(mxic->regs + INT_STS, sts, in mxic_spi_data_xfer()
320 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()
325 readl(mxic->regs + RXD); in mxic_spi_data_xfer()
327 WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY); in mxic_spi_data_xfer()
355 struct mxic_spi *mxic = spi_master_get_devdata(mem->spi->master); in mxic_spi_mem_exec_op() local
360 ret = mxic_spi_set_freq(mxic, mem->spi->max_speed_hz); in mxic_spi_mem_exec_op()
373 mxic->regs + HC_CFG); in mxic_spi_mem_exec_op()
374 writel(HC_EN_BIT, mxic->regs + HC_EN); in mxic_spi_mem_exec_op()
391 writel(ss_ctrl, mxic->regs + SS_CTRL(mem->spi->chip_select)); in mxic_spi_mem_exec_op()
393 writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_ASSERT, in mxic_spi_mem_exec_op()
394 mxic->regs + HC_CFG); in mxic_spi_mem_exec_op()
396 ret = mxic_spi_data_xfer(mxic, &op->cmd.opcode, NULL, 1); in mxic_spi_mem_exec_op()
403 ret = mxic_spi_data_xfer(mxic, addr, NULL, op->addr.nbytes); in mxic_spi_mem_exec_op()
407 ret = mxic_spi_data_xfer(mxic, NULL, NULL, op->dummy.nbytes); in mxic_spi_mem_exec_op()
411 ret = mxic_spi_data_xfer(mxic, in mxic_spi_mem_exec_op()
419 writel(readl(mxic->regs + HC_CFG) & ~HC_CFG_MAN_CS_ASSERT, in mxic_spi_mem_exec_op()
420 mxic->regs + HC_CFG); in mxic_spi_mem_exec_op()
421 writel(0, mxic->regs + HC_EN); in mxic_spi_mem_exec_op()
433 struct mxic_spi *mxic = spi_master_get_devdata(spi->master); in mxic_spi_set_cs() local
436 writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_EN, in mxic_spi_set_cs()
437 mxic->regs + HC_CFG); in mxic_spi_set_cs()
438 writel(HC_EN_BIT, mxic->regs + HC_EN); 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()
442 writel(readl(mxic->regs + HC_CFG) & ~HC_CFG_MAN_CS_ASSERT, in mxic_spi_set_cs()
443 mxic->regs + HC_CFG); in mxic_spi_set_cs()
444 writel(0, mxic->regs + HC_EN); in mxic_spi_set_cs()
452 struct mxic_spi *mxic = spi_master_get_devdata(master); in mxic_spi_transfer_one() local
464 ret = mxic_spi_set_freq(mxic, t->speed_hz); in mxic_spi_transfer_one()
482 mxic->regs + SS_CTRL(0)); in mxic_spi_transfer_one()
484 ret = mxic_spi_data_xfer(mxic, t->tx_buf, t->rx_buf, t->len); in mxic_spi_transfer_one()
496 struct mxic_spi *mxic = spi_master_get_devdata(master); in mxic_spi_runtime_suspend() local
498 mxic_spi_clk_disable(mxic); in mxic_spi_runtime_suspend()
499 clk_disable_unprepare(mxic->ps_clk); in mxic_spi_runtime_suspend()
507 struct mxic_spi *mxic = spi_master_get_devdata(master); in mxic_spi_runtime_resume() local
510 ret = clk_prepare_enable(mxic->ps_clk); in mxic_spi_runtime_resume()
516 return mxic_spi_clk_enable(mxic); in mxic_spi_runtime_resume()
528 struct mxic_spi *mxic; in mxic_spi_probe() local
537 mxic = spi_master_get_devdata(master); in mxic_spi_probe()
541 mxic->ps_clk = devm_clk_get(&pdev->dev, "ps_clk"); in mxic_spi_probe()
542 if (IS_ERR(mxic->ps_clk)) in mxic_spi_probe()
543 return PTR_ERR(mxic->ps_clk); in mxic_spi_probe()
545 mxic->send_clk = devm_clk_get(&pdev->dev, "send_clk"); in mxic_spi_probe()
546 if (IS_ERR(mxic->send_clk)) in mxic_spi_probe()
547 return PTR_ERR(mxic->send_clk); in mxic_spi_probe()
549 mxic->send_dly_clk = devm_clk_get(&pdev->dev, "send_dly_clk"); in mxic_spi_probe()
550 if (IS_ERR(mxic->send_dly_clk)) in mxic_spi_probe()
551 return PTR_ERR(mxic->send_dly_clk); in mxic_spi_probe()
554 mxic->regs = devm_ioremap_resource(&pdev->dev, res); in mxic_spi_probe()
555 if (IS_ERR(mxic->regs)) in mxic_spi_probe()
556 return PTR_ERR(mxic->regs); in mxic_spi_probe()
571 mxic_spi_hw_init(mxic); in mxic_spi_probe()