Lines Matching full:se

17 #include <linux/qcom-geni-se.h>
22 * Generic Interface (GENI) Serial Engine (SE) Wrapper driver is introduced
36 * determined by the firmware loaded to the serial engine. Each SE consists
44 * --QUP & SE Clocks--> | Serial Engine N | +-IO------>
54 * <------SE IRQ------+ +----------------------------+ |
70 * GENI SE Wrapper driver is structured into 2 parts:
104 /* Common SE registers */
180 * @se: Pointer to the corresponding serial engine.
184 u32 geni_se_get_qup_hw_version(struct geni_se *se) in geni_se_get_qup_hw_version() argument
186 struct geni_wrapper *wrapper = se->wrapper; in geni_se_get_qup_hw_version()
225 static void geni_se_irq_clear(struct geni_se *se) in geni_se_irq_clear() argument
227 writel_relaxed(0, se->base + SE_GSI_EVENT_EN); in geni_se_irq_clear()
228 writel_relaxed(0xffffffff, se->base + SE_GENI_M_IRQ_CLEAR); in geni_se_irq_clear()
229 writel_relaxed(0xffffffff, se->base + SE_GENI_S_IRQ_CLEAR); in geni_se_irq_clear()
230 writel_relaxed(0xffffffff, se->base + SE_DMA_TX_IRQ_CLR); in geni_se_irq_clear()
231 writel_relaxed(0xffffffff, se->base + SE_DMA_RX_IRQ_CLR); in geni_se_irq_clear()
232 writel_relaxed(0xffffffff, se->base + SE_IRQ_EN); in geni_se_irq_clear()
237 * @se: Pointer to the concerned serial engine.
244 void geni_se_init(struct geni_se *se, u32 rx_wm, u32 rx_rfr) in geni_se_init() argument
248 geni_se_irq_clear(se); in geni_se_init()
249 geni_se_io_init(se->base); in geni_se_init()
250 geni_se_io_set_mode(se->base); in geni_se_init()
252 writel_relaxed(rx_wm, se->base + SE_GENI_RX_WATERMARK_REG); in geni_se_init()
253 writel_relaxed(rx_rfr, se->base + SE_GENI_RX_RFR_WATERMARK_REG); in geni_se_init()
255 val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_init()
257 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_init()
259 val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); in geni_se_init()
261 writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); in geni_se_init()
265 static void geni_se_select_fifo_mode(struct geni_se *se) in geni_se_select_fifo_mode() argument
267 u32 proto = geni_se_read_proto(se); in geni_se_select_fifo_mode()
270 geni_se_irq_clear(se); in geni_se_select_fifo_mode()
283 val_old = val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_select_fifo_mode()
287 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_select_fifo_mode()
289 val_old = val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); in geni_se_select_fifo_mode()
292 writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); in geni_se_select_fifo_mode()
295 val_old = val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_fifo_mode()
298 writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_fifo_mode()
301 static void geni_se_select_dma_mode(struct geni_se *se) in geni_se_select_dma_mode() argument
303 u32 proto = geni_se_read_proto(se); in geni_se_select_dma_mode()
306 geni_se_irq_clear(se); in geni_se_select_dma_mode()
309 val_old = val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_select_dma_mode()
313 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_select_dma_mode()
315 val_old = val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); in geni_se_select_dma_mode()
318 writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); in geni_se_select_dma_mode()
321 val_old = val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_dma_mode()
324 writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_dma_mode()
327 static void geni_se_select_gpi_mode(struct geni_se *se) in geni_se_select_gpi_mode() argument
331 geni_se_irq_clear(se); in geni_se_select_gpi_mode()
333 writel(0, se->base + SE_IRQ_EN); in geni_se_select_gpi_mode()
335 val = readl(se->base + SE_GENI_S_IRQ_EN); in geni_se_select_gpi_mode()
337 writel(val, se->base + SE_GENI_S_IRQ_EN); in geni_se_select_gpi_mode()
339 val = readl(se->base + SE_GENI_M_IRQ_EN); in geni_se_select_gpi_mode()
342 writel(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_select_gpi_mode()
344 writel(GENI_DMA_MODE_EN, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_gpi_mode()
346 val = readl(se->base + SE_GSI_EVENT_EN); in geni_se_select_gpi_mode()
348 writel(val, se->base + SE_GSI_EVENT_EN); in geni_se_select_gpi_mode()
353 * @se: Pointer to the concerned serial engine.
356 void geni_se_select_mode(struct geni_se *se, enum geni_se_xfer_mode mode) in geni_se_select_mode() argument
362 geni_se_select_fifo_mode(se); in geni_se_select_mode()
365 geni_se_select_dma_mode(se); in geni_se_select_mode()
368 geni_se_select_gpi_mode(se); in geni_se_select_mode()
429 * @se: Pointer to the concerned serial engine
439 void geni_se_config_packing(struct geni_se *se, int bpw, int pack_words, in geni_se_config_packing() argument
474 writel_relaxed(cfg0, se->base + SE_GENI_TX_PACKING_CFG0); in geni_se_config_packing()
475 writel_relaxed(cfg1, se->base + SE_GENI_TX_PACKING_CFG1); in geni_se_config_packing()
478 writel_relaxed(cfg0, se->base + SE_GENI_RX_PACKING_CFG0); in geni_se_config_packing()
479 writel_relaxed(cfg1, se->base + SE_GENI_RX_PACKING_CFG1); in geni_se_config_packing()
490 writel_relaxed(bpw / 16, se->base + SE_GENI_BYTE_GRAN); in geni_se_config_packing()
494 static void geni_se_clks_off(struct geni_se *se) in geni_se_clks_off() argument
496 struct geni_wrapper *wrapper = se->wrapper; in geni_se_clks_off()
498 clk_disable_unprepare(se->clk); in geni_se_clks_off()
506 * @se: Pointer to the concerned serial engine.
510 int geni_se_resources_off(struct geni_se *se) in geni_se_resources_off() argument
514 if (has_acpi_companion(se->dev)) in geni_se_resources_off()
517 ret = pinctrl_pm_select_sleep_state(se->dev); in geni_se_resources_off()
521 geni_se_clks_off(se); in geni_se_resources_off()
526 static int geni_se_clks_on(struct geni_se *se) in geni_se_clks_on() argument
529 struct geni_wrapper *wrapper = se->wrapper; in geni_se_clks_on()
536 ret = clk_prepare_enable(se->clk); in geni_se_clks_on()
546 * @se: Pointer to the concerned serial engine.
550 int geni_se_resources_on(struct geni_se *se) in geni_se_resources_on() argument
554 if (has_acpi_companion(se->dev)) in geni_se_resources_on()
557 ret = geni_se_clks_on(se); in geni_se_resources_on()
561 ret = pinctrl_pm_select_default_state(se->dev); in geni_se_resources_on()
563 geni_se_clks_off(se); in geni_se_resources_on()
571 * @se: Pointer to the concerned serial engine.
582 int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl) in geni_se_clk_tbl_get() argument
587 if (se->clk_perf_tbl) { in geni_se_clk_tbl_get()
588 *tbl = se->clk_perf_tbl; in geni_se_clk_tbl_get()
589 return se->num_clk_levels; in geni_se_clk_tbl_get()
592 se->clk_perf_tbl = devm_kcalloc(se->dev, MAX_CLK_PERF_LEVEL, in geni_se_clk_tbl_get()
593 sizeof(*se->clk_perf_tbl), in geni_se_clk_tbl_get()
595 if (!se->clk_perf_tbl) in geni_se_clk_tbl_get()
599 freq = clk_round_rate(se->clk, freq + 1); in geni_se_clk_tbl_get()
600 if (freq <= 0 || freq == se->clk_perf_tbl[i - 1]) in geni_se_clk_tbl_get()
602 se->clk_perf_tbl[i] = freq; in geni_se_clk_tbl_get()
604 se->num_clk_levels = i; in geni_se_clk_tbl_get()
605 *tbl = se->clk_perf_tbl; in geni_se_clk_tbl_get()
606 return se->num_clk_levels; in geni_se_clk_tbl_get()
611 * geni_se_clk_freq_match() - Get the matching or closest SE clock frequency
612 * @se: Pointer to the concerned serial engine.
629 int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq, in geni_se_clk_freq_match() argument
640 num_clk_levels = geni_se_clk_tbl_get(se, &tbl); in geni_se_clk_freq_match()
678 * @se: Pointer to the concerned serial engine.
687 int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len, in geni_se_tx_dma_prep() argument
690 struct geni_wrapper *wrapper = se->wrapper; in geni_se_tx_dma_prep()
703 writel_relaxed(val, se->base + SE_DMA_TX_IRQ_EN_SET); in geni_se_tx_dma_prep()
704 writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_TX_PTR_L); in geni_se_tx_dma_prep()
705 writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_TX_PTR_H); in geni_se_tx_dma_prep()
706 writel_relaxed(GENI_SE_DMA_EOT_BUF, se->base + SE_DMA_TX_ATTR); in geni_se_tx_dma_prep()
707 writel(len, se->base + SE_DMA_TX_LEN); in geni_se_tx_dma_prep()
714 * @se: Pointer to the concerned serial engine.
723 int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len, in geni_se_rx_dma_prep() argument
726 struct geni_wrapper *wrapper = se->wrapper; in geni_se_rx_dma_prep()
739 writel_relaxed(val, se->base + SE_DMA_RX_IRQ_EN_SET); in geni_se_rx_dma_prep()
740 writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_RX_PTR_L); in geni_se_rx_dma_prep()
741 writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_RX_PTR_H); in geni_se_rx_dma_prep()
743 writel_relaxed(0, se->base + SE_DMA_RX_ATTR); in geni_se_rx_dma_prep()
744 writel(len, se->base + SE_DMA_RX_LEN); in geni_se_rx_dma_prep()
751 * @se: Pointer to the concerned serial engine.
757 void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_tx_dma_unprep() argument
759 struct geni_wrapper *wrapper = se->wrapper; in geni_se_tx_dma_unprep()
768 * @se: Pointer to the concerned serial engine.
774 void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_rx_dma_unprep() argument
776 struct geni_wrapper *wrapper = se->wrapper; in geni_se_rx_dma_unprep()
783 int geni_icc_get(struct geni_se *se, const char *icc_ddr) in geni_icc_get() argument
788 if (has_acpi_companion(se->dev)) in geni_icc_get()
791 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_get()
795 se->icc_paths[i].path = devm_of_icc_get(se->dev, icc_names[i]); in geni_icc_get()
796 if (IS_ERR(se->icc_paths[i].path)) in geni_icc_get()
803 err = PTR_ERR(se->icc_paths[i].path); in geni_icc_get()
805 dev_err_ratelimited(se->dev, "Failed to get ICC path '%s': %d\n", in geni_icc_get()
812 int geni_icc_set_bw(struct geni_se *se) in geni_icc_set_bw() argument
816 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_set_bw()
817 ret = icc_set_bw(se->icc_paths[i].path, in geni_icc_set_bw()
818 se->icc_paths[i].avg_bw, se->icc_paths[i].avg_bw); in geni_icc_set_bw()
820 dev_err_ratelimited(se->dev, "ICC BW voting failed on path '%s': %d\n", in geni_icc_set_bw()
830 void geni_icc_set_tag(struct geni_se *se, u32 tag) in geni_icc_set_tag() argument
834 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) in geni_icc_set_tag()
835 icc_set_tag(se->icc_paths[i].path, tag); in geni_icc_set_tag()
840 int geni_icc_enable(struct geni_se *se) in geni_icc_enable() argument
844 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_enable()
845 ret = icc_enable(se->icc_paths[i].path); in geni_icc_enable()
847 dev_err_ratelimited(se->dev, "ICC enable failed on path '%s': %d\n", in geni_icc_enable()
857 int geni_icc_disable(struct geni_se *se) in geni_icc_disable() argument
861 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_disable()
862 ret = icc_disable(se->icc_paths[i].path); in geni_icc_disable()
864 dev_err_ratelimited(se->dev, "ICC disable failed on path '%s': %d\n", in geni_icc_disable()
900 dev_dbg(dev, "GENI SE Driver probed\n"); in geni_se_probe()
905 { .compatible = "qcom,geni-se-qup", },