Lines Matching full:arb
265 static u32 pmif_readl(struct pmif *arb, enum pmif_regs reg) in pmif_readl() argument
267 return readl(arb->base + arb->data->regs[reg]); in pmif_readl()
270 static void pmif_writel(struct pmif *arb, u32 val, enum pmif_regs reg) in pmif_writel() argument
272 writel(val, arb->base + arb->data->regs[reg]); in pmif_writel()
275 static void mtk_spmi_writel(struct pmif *arb, u32 val, enum spmi_regs reg) in mtk_spmi_writel() argument
277 writel(val, arb->spmimst_base + arb->data->spmimst_regs[reg]); in mtk_spmi_writel()
280 static bool pmif_is_fsm_vldclr(struct pmif *arb) in pmif_is_fsm_vldclr() argument
284 reg_rdata = pmif_readl(arb, arb->chan.ch_sta); in pmif_is_fsm_vldclr()
291 struct pmif *arb = spmi_controller_get_drvdata(ctrl); in pmif_arb_cmd() local
301 mtk_spmi_writel(arb, (cmd << 0x4) | sid, SPMI_OP_ST_CTRL); in pmif_arb_cmd()
302 ret = readl_poll_timeout_atomic(arb->spmimst_base + arb->data->spmimst_regs[SPMI_OP_ST_STA], in pmif_arb_cmd()
314 struct pmif *arb = spmi_controller_get_drvdata(ctrl); in pmif_spmi_read_cmd() local
339 raw_spin_lock_irqsave(&arb->lock, flags); in pmif_spmi_read_cmd()
341 inf_reg = &arb->chan; in pmif_spmi_read_cmd()
342 ret = readl_poll_timeout_atomic(arb->base + arb->data->regs[inf_reg->ch_sta], in pmif_spmi_read_cmd()
347 if (pmif_is_fsm_vldclr(arb)) in pmif_spmi_read_cmd()
348 pmif_writel(arb, 1, inf_reg->ch_rdy); in pmif_spmi_read_cmd()
349 raw_spin_unlock_irqrestore(&arb->lock, flags); in pmif_spmi_read_cmd()
356 pmif_writel(arb, cmd, inf_reg->ch_send); in pmif_spmi_read_cmd()
357 raw_spin_unlock_irqrestore(&arb->lock, flags); in pmif_spmi_read_cmd()
363 ret = readl_poll_timeout_atomic(arb->base + arb->data->regs[inf_reg->ch_sta], in pmif_spmi_read_cmd()
371 data = pmif_readl(arb, inf_reg->rdata); in pmif_spmi_read_cmd()
373 pmif_writel(arb, 1, inf_reg->ch_rdy); in pmif_spmi_read_cmd()
381 struct pmif *arb = spmi_controller_get_drvdata(ctrl); in pmif_spmi_write_cmd() local
412 raw_spin_lock_irqsave(&arb->lock, flags); in pmif_spmi_write_cmd()
414 inf_reg = &arb->chan; in pmif_spmi_write_cmd()
415 ret = readl_poll_timeout_atomic(arb->base + arb->data->regs[inf_reg->ch_sta], in pmif_spmi_write_cmd()
420 if (pmif_is_fsm_vldclr(arb)) in pmif_spmi_write_cmd()
421 pmif_writel(arb, 1, inf_reg->ch_rdy); in pmif_spmi_write_cmd()
422 raw_spin_unlock_irqrestore(&arb->lock, flags); in pmif_spmi_write_cmd()
427 pmif_writel(arb, wdata, inf_reg->wdata); in pmif_spmi_write_cmd()
431 pmif_writel(arb, cmd, inf_reg->ch_send); in pmif_spmi_write_cmd()
432 raw_spin_unlock_irqrestore(&arb->lock, flags); in pmif_spmi_write_cmd()
451 struct pmif *arb; in mtk_spmi_probe() local
456 ctrl = devm_spmi_controller_alloc(&pdev->dev, sizeof(*arb)); in mtk_spmi_probe()
460 arb = spmi_controller_get_drvdata(ctrl); in mtk_spmi_probe()
461 arb->data = device_get_match_data(&pdev->dev); in mtk_spmi_probe()
462 if (!arb->data) { in mtk_spmi_probe()
467 arb->base = devm_platform_ioremap_resource_byname(pdev, "pmif"); in mtk_spmi_probe()
468 if (IS_ERR(arb->base)) in mtk_spmi_probe()
469 return PTR_ERR(arb->base); in mtk_spmi_probe()
471 arb->spmimst_base = devm_platform_ioremap_resource_byname(pdev, "spmimst"); in mtk_spmi_probe()
472 if (IS_ERR(arb->spmimst_base)) in mtk_spmi_probe()
473 return PTR_ERR(arb->spmimst_base); in mtk_spmi_probe()
475 arb->nclks = ARRAY_SIZE(pmif_clock_names); in mtk_spmi_probe()
476 for (i = 0; i < arb->nclks; i++) in mtk_spmi_probe()
477 arb->clks[i].id = pmif_clock_names[i]; in mtk_spmi_probe()
479 err = clk_bulk_get(&pdev->dev, arb->nclks, arb->clks); in mtk_spmi_probe()
485 err = clk_bulk_prepare_enable(arb->nclks, arb->clks); in mtk_spmi_probe()
495 chan_offset = PMIF_CHAN_OFFSET * arb->data->soc_chan; in mtk_spmi_probe()
496 arb->chan.ch_sta = PMIF_SWINF_0_STA + chan_offset; in mtk_spmi_probe()
497 arb->chan.wdata = PMIF_SWINF_0_WDATA_31_0 + chan_offset; in mtk_spmi_probe()
498 arb->chan.rdata = PMIF_SWINF_0_RDATA_31_0 + chan_offset; in mtk_spmi_probe()
499 arb->chan.ch_send = PMIF_SWINF_0_ACC + chan_offset; in mtk_spmi_probe()
500 arb->chan.ch_rdy = PMIF_SWINF_0_VLD_CLR + chan_offset; in mtk_spmi_probe()
502 raw_spin_lock_init(&arb->lock); in mtk_spmi_probe()
513 clk_bulk_disable_unprepare(arb->nclks, arb->clks); in mtk_spmi_probe()
515 clk_bulk_put(arb->nclks, arb->clks); in mtk_spmi_probe()
522 struct pmif *arb = spmi_controller_get_drvdata(ctrl); in mtk_spmi_remove() local
525 clk_bulk_disable_unprepare(arb->nclks, arb->clks); in mtk_spmi_remove()
526 clk_bulk_put(arb->nclks, arb->clks); in mtk_spmi_remove()