Lines Matching full:se
17 #include <linux/soc/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:
116 /* Common SE registers */
192 * @se: Pointer to the corresponding serial engine.
196 u32 geni_se_get_qup_hw_version(struct geni_se *se) in geni_se_get_qup_hw_version() argument
198 struct geni_wrapper *wrapper = se->wrapper; in geni_se_get_qup_hw_version()
237 static void geni_se_irq_clear(struct geni_se *se) in geni_se_irq_clear() argument
239 writel_relaxed(0, se->base + SE_GSI_EVENT_EN); in geni_se_irq_clear()
240 writel_relaxed(0xffffffff, se->base + SE_GENI_M_IRQ_CLEAR); in geni_se_irq_clear()
241 writel_relaxed(0xffffffff, se->base + SE_GENI_S_IRQ_CLEAR); in geni_se_irq_clear()
242 writel_relaxed(0xffffffff, se->base + SE_DMA_TX_IRQ_CLR); in geni_se_irq_clear()
243 writel_relaxed(0xffffffff, se->base + SE_DMA_RX_IRQ_CLR); in geni_se_irq_clear()
244 writel_relaxed(0xffffffff, se->base + SE_IRQ_EN); in geni_se_irq_clear()
249 * @se: Pointer to the concerned serial engine.
256 void geni_se_init(struct geni_se *se, u32 rx_wm, u32 rx_rfr) in geni_se_init() argument
260 geni_se_irq_clear(se); in geni_se_init()
261 geni_se_io_init(se->base); in geni_se_init()
262 geni_se_io_set_mode(se->base); in geni_se_init()
264 writel_relaxed(rx_wm, se->base + SE_GENI_RX_WATERMARK_REG); in geni_se_init()
265 writel_relaxed(rx_rfr, se->base + SE_GENI_RX_RFR_WATERMARK_REG); in geni_se_init()
267 val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_init()
269 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_init()
271 val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); in geni_se_init()
273 writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); in geni_se_init()
277 static void geni_se_select_fifo_mode(struct geni_se *se) in geni_se_select_fifo_mode() argument
279 u32 proto = geni_se_read_proto(se); in geni_se_select_fifo_mode()
282 geni_se_irq_clear(se); in geni_se_select_fifo_mode()
287 val_old = val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_select_fifo_mode()
291 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_select_fifo_mode()
294 val_old = val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_fifo_mode()
297 writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_fifo_mode()
300 static void geni_se_select_dma_mode(struct geni_se *se) in geni_se_select_dma_mode() argument
302 u32 proto = geni_se_read_proto(se); in geni_se_select_dma_mode()
305 geni_se_irq_clear(se); in geni_se_select_dma_mode()
310 val_old = val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_select_dma_mode()
314 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_select_dma_mode()
317 val_old = val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_dma_mode()
320 writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_dma_mode()
323 static void geni_se_select_gpi_mode(struct geni_se *se) in geni_se_select_gpi_mode() argument
327 geni_se_irq_clear(se); in geni_se_select_gpi_mode()
329 writel(0, se->base + SE_IRQ_EN); in geni_se_select_gpi_mode()
331 val = readl(se->base + SE_GENI_M_IRQ_EN); in geni_se_select_gpi_mode()
334 writel(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_select_gpi_mode()
336 writel(GENI_DMA_MODE_EN, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_gpi_mode()
338 val = readl(se->base + SE_GSI_EVENT_EN); in geni_se_select_gpi_mode()
340 writel(val, se->base + SE_GSI_EVENT_EN); in geni_se_select_gpi_mode()
345 * @se: Pointer to the concerned serial engine.
348 void geni_se_select_mode(struct geni_se *se, enum geni_se_xfer_mode mode) in geni_se_select_mode() argument
354 geni_se_select_fifo_mode(se); in geni_se_select_mode()
357 geni_se_select_dma_mode(se); in geni_se_select_mode()
360 geni_se_select_gpi_mode(se); in geni_se_select_mode()
421 * @se: Pointer to the concerned serial engine
431 void geni_se_config_packing(struct geni_se *se, int bpw, int pack_words, in geni_se_config_packing() argument
466 writel_relaxed(cfg0, se->base + SE_GENI_TX_PACKING_CFG0); in geni_se_config_packing()
467 writel_relaxed(cfg1, se->base + SE_GENI_TX_PACKING_CFG1); in geni_se_config_packing()
470 writel_relaxed(cfg0, se->base + SE_GENI_RX_PACKING_CFG0); in geni_se_config_packing()
471 writel_relaxed(cfg1, se->base + SE_GENI_RX_PACKING_CFG1); in geni_se_config_packing()
482 writel_relaxed(bpw / 16, se->base + SE_GENI_BYTE_GRAN); in geni_se_config_packing()
486 static void geni_se_clks_off(struct geni_se *se) in geni_se_clks_off() argument
488 struct geni_wrapper *wrapper = se->wrapper; in geni_se_clks_off()
490 clk_disable_unprepare(se->clk); in geni_se_clks_off()
497 * @se: Pointer to the concerned serial engine.
501 int geni_se_resources_off(struct geni_se *se) in geni_se_resources_off() argument
505 if (has_acpi_companion(se->dev)) in geni_se_resources_off()
508 ret = pinctrl_pm_select_sleep_state(se->dev); in geni_se_resources_off()
512 geni_se_clks_off(se); in geni_se_resources_off()
517 static int geni_se_clks_on(struct geni_se *se) in geni_se_clks_on() argument
520 struct geni_wrapper *wrapper = se->wrapper; in geni_se_clks_on()
526 ret = clk_prepare_enable(se->clk); in geni_se_clks_on()
535 * @se: Pointer to the concerned serial engine.
539 int geni_se_resources_on(struct geni_se *se) in geni_se_resources_on() argument
543 if (has_acpi_companion(se->dev)) in geni_se_resources_on()
546 ret = geni_se_clks_on(se); in geni_se_resources_on()
550 ret = pinctrl_pm_select_default_state(se->dev); in geni_se_resources_on()
552 geni_se_clks_off(se); in geni_se_resources_on()
560 * @se: Pointer to the concerned serial engine.
571 int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl) in geni_se_clk_tbl_get() argument
576 if (se->clk_perf_tbl) { in geni_se_clk_tbl_get()
577 *tbl = se->clk_perf_tbl; in geni_se_clk_tbl_get()
578 return se->num_clk_levels; in geni_se_clk_tbl_get()
581 se->clk_perf_tbl = devm_kcalloc(se->dev, MAX_CLK_PERF_LEVEL, in geni_se_clk_tbl_get()
582 sizeof(*se->clk_perf_tbl), in geni_se_clk_tbl_get()
584 if (!se->clk_perf_tbl) in geni_se_clk_tbl_get()
588 freq = clk_round_rate(se->clk, freq + 1); in geni_se_clk_tbl_get()
590 (i > 0 && freq == se->clk_perf_tbl[i - 1])) in geni_se_clk_tbl_get()
592 se->clk_perf_tbl[i] = freq; in geni_se_clk_tbl_get()
594 se->num_clk_levels = i; in geni_se_clk_tbl_get()
595 *tbl = se->clk_perf_tbl; in geni_se_clk_tbl_get()
596 return se->num_clk_levels; in geni_se_clk_tbl_get()
601 * geni_se_clk_freq_match() - Get the matching or closest SE clock frequency
602 * @se: Pointer to the concerned serial engine.
619 int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq, in geni_se_clk_freq_match() argument
630 num_clk_levels = geni_se_clk_tbl_get(se, &tbl); in geni_se_clk_freq_match()
669 * @se: Pointer to the concerned serial engine.
675 void geni_se_tx_init_dma(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_tx_init_dma() argument
682 writel_relaxed(val, se->base + SE_DMA_TX_IRQ_EN_SET); in geni_se_tx_init_dma()
683 writel_relaxed(lower_32_bits(iova), se->base + SE_DMA_TX_PTR_L); in geni_se_tx_init_dma()
684 writel_relaxed(upper_32_bits(iova), se->base + SE_DMA_TX_PTR_H); in geni_se_tx_init_dma()
685 writel_relaxed(GENI_SE_DMA_EOT_BUF, se->base + SE_DMA_TX_ATTR); in geni_se_tx_init_dma()
686 writel(len, se->base + SE_DMA_TX_LEN); in geni_se_tx_init_dma()
692 * @se: Pointer to the concerned serial engine.
701 int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len, in geni_se_tx_dma_prep() argument
704 struct geni_wrapper *wrapper = se->wrapper; in geni_se_tx_dma_prep()
713 geni_se_tx_init_dma(se, *iova, len); in geni_se_tx_dma_prep()
720 * @se: Pointer to the concerned serial engine.
726 void geni_se_rx_init_dma(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_rx_init_dma() argument
733 writel_relaxed(val, se->base + SE_DMA_RX_IRQ_EN_SET); in geni_se_rx_init_dma()
734 writel_relaxed(lower_32_bits(iova), se->base + SE_DMA_RX_PTR_L); in geni_se_rx_init_dma()
735 writel_relaxed(upper_32_bits(iova), se->base + SE_DMA_RX_PTR_H); in geni_se_rx_init_dma()
737 writel_relaxed(0, se->base + SE_DMA_RX_ATTR); in geni_se_rx_init_dma()
738 writel(len, se->base + SE_DMA_RX_LEN); in geni_se_rx_init_dma()
744 * @se: Pointer to the concerned serial engine.
753 int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len, in geni_se_rx_dma_prep() argument
756 struct geni_wrapper *wrapper = se->wrapper; in geni_se_rx_dma_prep()
765 geni_se_rx_init_dma(se, *iova, len); in geni_se_rx_dma_prep()
772 * @se: Pointer to the concerned serial engine.
778 void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_tx_dma_unprep() argument
780 struct geni_wrapper *wrapper = se->wrapper; in geni_se_tx_dma_unprep()
789 * @se: Pointer to the concerned serial engine.
795 void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_rx_dma_unprep() argument
797 struct geni_wrapper *wrapper = se->wrapper; in geni_se_rx_dma_unprep()
804 int geni_icc_get(struct geni_se *se, const char *icc_ddr) in geni_icc_get() argument
809 if (has_acpi_companion(se->dev)) in geni_icc_get()
812 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_get()
816 se->icc_paths[i].path = devm_of_icc_get(se->dev, icc_names[i]); in geni_icc_get()
817 if (IS_ERR(se->icc_paths[i].path)) in geni_icc_get()
824 err = PTR_ERR(se->icc_paths[i].path); in geni_icc_get()
826 dev_err_ratelimited(se->dev, "Failed to get ICC path '%s': %d\n", in geni_icc_get()
833 int geni_icc_set_bw(struct geni_se *se) in geni_icc_set_bw() argument
837 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_set_bw()
838 ret = icc_set_bw(se->icc_paths[i].path, in geni_icc_set_bw()
839 se->icc_paths[i].avg_bw, se->icc_paths[i].avg_bw); in geni_icc_set_bw()
841 dev_err_ratelimited(se->dev, "ICC BW voting failed on path '%s': %d\n", in geni_icc_set_bw()
851 void geni_icc_set_tag(struct geni_se *se, u32 tag) in geni_icc_set_tag() argument
855 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) in geni_icc_set_tag()
856 icc_set_tag(se->icc_paths[i].path, tag); in geni_icc_set_tag()
861 int geni_icc_enable(struct geni_se *se) in geni_icc_enable() argument
865 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_enable()
866 ret = icc_enable(se->icc_paths[i].path); in geni_icc_enable()
868 dev_err_ratelimited(se->dev, "ICC enable failed on path '%s': %d\n", in geni_icc_enable()
878 int geni_icc_disable(struct geni_se *se) in geni_icc_disable() argument
882 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_disable()
883 ret = icc_disable(se->icc_paths[i].path); in geni_icc_disable()
885 dev_err_ratelimited(se->dev, "ICC disable failed on path '%s': %d\n", in geni_icc_disable()
943 dev_dbg(dev, "GENI SE Driver probed\n"); in geni_se_probe()
967 { .compatible = "qcom,geni-se-qup", .data = &qup_desc },
968 { .compatible = "qcom,geni-se-i2c-master-hub", .data = &i2c_master_hub_desc },