Lines Matching full:se

15 #include <linux/qcom-geni-se.h>
20 * Generic Interface (GENI) Serial Engine (SE) Wrapper driver is introduced
34 * determined by the firmware loaded to the serial engine. Each SE consists
42 * --QUP & SE Clocks--> | Serial Engine N | +-IO------>
52 * <------SE IRQ------+ +----------------------------+ |
68 * GENI SE Wrapper driver is structured into 2 parts:
104 /* Common SE registers */
181 * @se: Pointer to the corresponding serial engine.
185 u32 geni_se_get_qup_hw_version(struct geni_se *se) in geni_se_get_qup_hw_version() argument
187 struct geni_wrapper *wrapper = se->wrapper; in geni_se_get_qup_hw_version()
226 static void geni_se_irq_clear(struct geni_se *se) in geni_se_irq_clear() argument
228 writel_relaxed(0, se->base + SE_GSI_EVENT_EN); in geni_se_irq_clear()
229 writel_relaxed(0xffffffff, se->base + SE_GENI_M_IRQ_CLEAR); in geni_se_irq_clear()
230 writel_relaxed(0xffffffff, se->base + SE_GENI_S_IRQ_CLEAR); in geni_se_irq_clear()
231 writel_relaxed(0xffffffff, se->base + SE_DMA_TX_IRQ_CLR); in geni_se_irq_clear()
232 writel_relaxed(0xffffffff, se->base + SE_DMA_RX_IRQ_CLR); in geni_se_irq_clear()
233 writel_relaxed(0xffffffff, se->base + SE_IRQ_EN); in geni_se_irq_clear()
238 * @se: Pointer to the concerned serial engine.
245 void geni_se_init(struct geni_se *se, u32 rx_wm, u32 rx_rfr) in geni_se_init() argument
249 geni_se_irq_clear(se); in geni_se_init()
250 geni_se_io_init(se->base); in geni_se_init()
251 geni_se_io_set_mode(se->base); in geni_se_init()
253 writel_relaxed(rx_wm, se->base + SE_GENI_RX_WATERMARK_REG); in geni_se_init()
254 writel_relaxed(rx_rfr, se->base + SE_GENI_RX_RFR_WATERMARK_REG); in geni_se_init()
256 val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_init()
258 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_init()
260 val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); in geni_se_init()
262 writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); in geni_se_init()
266 static void geni_se_select_fifo_mode(struct geni_se *se) in geni_se_select_fifo_mode() argument
268 u32 proto = geni_se_read_proto(se); in geni_se_select_fifo_mode()
271 geni_se_irq_clear(se); in geni_se_select_fifo_mode()
273 val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); in geni_se_select_fifo_mode()
278 writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); in geni_se_select_fifo_mode()
280 val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); in geni_se_select_fifo_mode()
283 writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); in geni_se_select_fifo_mode()
285 val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_fifo_mode()
287 writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_fifo_mode()
290 static void geni_se_select_dma_mode(struct geni_se *se) in geni_se_select_dma_mode() argument
294 geni_se_irq_clear(se); in geni_se_select_dma_mode()
296 val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_dma_mode()
298 writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); in geni_se_select_dma_mode()
303 * @se: Pointer to the concerned serial engine.
306 void geni_se_select_mode(struct geni_se *se, enum geni_se_xfer_mode mode) in geni_se_select_mode() argument
312 geni_se_select_fifo_mode(se); in geni_se_select_mode()
315 geni_se_select_dma_mode(se); in geni_se_select_mode()
376 * @se: Pointer to the concerned serial engine
386 void geni_se_config_packing(struct geni_se *se, int bpw, int pack_words, in geni_se_config_packing() argument
421 writel_relaxed(cfg0, se->base + SE_GENI_TX_PACKING_CFG0); in geni_se_config_packing()
422 writel_relaxed(cfg1, se->base + SE_GENI_TX_PACKING_CFG1); in geni_se_config_packing()
425 writel_relaxed(cfg0, se->base + SE_GENI_RX_PACKING_CFG0); in geni_se_config_packing()
426 writel_relaxed(cfg1, se->base + SE_GENI_RX_PACKING_CFG1); in geni_se_config_packing()
437 writel_relaxed(bpw / 16, se->base + SE_GENI_BYTE_GRAN); in geni_se_config_packing()
441 static void geni_se_clks_off(struct geni_se *se) in geni_se_clks_off() argument
443 struct geni_wrapper *wrapper = se->wrapper; in geni_se_clks_off()
445 clk_disable_unprepare(se->clk); in geni_se_clks_off()
453 * @se: Pointer to the concerned serial engine.
457 int geni_se_resources_off(struct geni_se *se) in geni_se_resources_off() argument
461 if (has_acpi_companion(se->dev)) in geni_se_resources_off()
464 ret = pinctrl_pm_select_sleep_state(se->dev); in geni_se_resources_off()
468 geni_se_clks_off(se); in geni_se_resources_off()
473 static int geni_se_clks_on(struct geni_se *se) in geni_se_clks_on() argument
476 struct geni_wrapper *wrapper = se->wrapper; in geni_se_clks_on()
483 ret = clk_prepare_enable(se->clk); in geni_se_clks_on()
493 * @se: Pointer to the concerned serial engine.
497 int geni_se_resources_on(struct geni_se *se) in geni_se_resources_on() argument
501 if (has_acpi_companion(se->dev)) in geni_se_resources_on()
504 ret = geni_se_clks_on(se); in geni_se_resources_on()
508 ret = pinctrl_pm_select_default_state(se->dev); in geni_se_resources_on()
510 geni_se_clks_off(se); in geni_se_resources_on()
518 * @se: Pointer to the concerned serial engine.
529 int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl) in geni_se_clk_tbl_get() argument
534 if (se->clk_perf_tbl) { in geni_se_clk_tbl_get()
535 *tbl = se->clk_perf_tbl; in geni_se_clk_tbl_get()
536 return se->num_clk_levels; in geni_se_clk_tbl_get()
539 se->clk_perf_tbl = devm_kcalloc(se->dev, MAX_CLK_PERF_LEVEL, in geni_se_clk_tbl_get()
540 sizeof(*se->clk_perf_tbl), in geni_se_clk_tbl_get()
542 if (!se->clk_perf_tbl) in geni_se_clk_tbl_get()
546 freq = clk_round_rate(se->clk, freq + 1); in geni_se_clk_tbl_get()
547 if (freq <= 0 || freq == se->clk_perf_tbl[i - 1]) in geni_se_clk_tbl_get()
549 se->clk_perf_tbl[i] = freq; in geni_se_clk_tbl_get()
551 se->num_clk_levels = i; in geni_se_clk_tbl_get()
552 *tbl = se->clk_perf_tbl; in geni_se_clk_tbl_get()
553 return se->num_clk_levels; in geni_se_clk_tbl_get()
558 * geni_se_clk_freq_match() - Get the matching or closest SE clock frequency
559 * @se: Pointer to the concerned serial engine.
576 int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq, in geni_se_clk_freq_match() argument
587 num_clk_levels = geni_se_clk_tbl_get(se, &tbl); in geni_se_clk_freq_match()
625 * @se: Pointer to the concerned serial engine.
634 int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len, in geni_se_tx_dma_prep() argument
637 struct geni_wrapper *wrapper = se->wrapper; in geni_se_tx_dma_prep()
650 writel_relaxed(val, se->base + SE_DMA_TX_IRQ_EN_SET); in geni_se_tx_dma_prep()
651 writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_TX_PTR_L); in geni_se_tx_dma_prep()
652 writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_TX_PTR_H); in geni_se_tx_dma_prep()
653 writel_relaxed(GENI_SE_DMA_EOT_BUF, se->base + SE_DMA_TX_ATTR); in geni_se_tx_dma_prep()
654 writel_relaxed(len, se->base + SE_DMA_TX_LEN); in geni_se_tx_dma_prep()
661 * @se: Pointer to the concerned serial engine.
670 int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len, in geni_se_rx_dma_prep() argument
673 struct geni_wrapper *wrapper = se->wrapper; in geni_se_rx_dma_prep()
686 writel_relaxed(val, se->base + SE_DMA_RX_IRQ_EN_SET); in geni_se_rx_dma_prep()
687 writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_RX_PTR_L); in geni_se_rx_dma_prep()
688 writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_RX_PTR_H); in geni_se_rx_dma_prep()
690 writel_relaxed(0, se->base + SE_DMA_RX_ATTR); in geni_se_rx_dma_prep()
691 writel_relaxed(len, se->base + SE_DMA_RX_LEN); in geni_se_rx_dma_prep()
698 * @se: Pointer to the concerned serial engine.
704 void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_tx_dma_unprep() argument
706 struct geni_wrapper *wrapper = se->wrapper; in geni_se_tx_dma_unprep()
715 * @se: Pointer to the concerned serial engine.
721 void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len) in geni_se_rx_dma_unprep() argument
723 struct geni_wrapper *wrapper = se->wrapper; in geni_se_rx_dma_unprep()
730 int geni_icc_get(struct geni_se *se, const char *icc_ddr) in geni_icc_get() argument
735 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_get()
739 se->icc_paths[i].path = devm_of_icc_get(se->dev, icc_names[i]); in geni_icc_get()
740 if (IS_ERR(se->icc_paths[i].path)) in geni_icc_get()
747 err = PTR_ERR(se->icc_paths[i].path); in geni_icc_get()
749 dev_err_ratelimited(se->dev, "Failed to get ICC path '%s': %d\n", in geni_icc_get()
756 int geni_icc_set_bw(struct geni_se *se) in geni_icc_set_bw() argument
760 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_set_bw()
761 ret = icc_set_bw(se->icc_paths[i].path, in geni_icc_set_bw()
762 se->icc_paths[i].avg_bw, se->icc_paths[i].avg_bw); in geni_icc_set_bw()
764 dev_err_ratelimited(se->dev, "ICC BW voting failed on path '%s': %d\n", in geni_icc_set_bw()
774 void geni_icc_set_tag(struct geni_se *se, u32 tag) in geni_icc_set_tag() argument
778 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) in geni_icc_set_tag()
779 icc_set_tag(se->icc_paths[i].path, tag); in geni_icc_set_tag()
784 int geni_icc_enable(struct geni_se *se) in geni_icc_enable() argument
788 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_enable()
789 ret = icc_enable(se->icc_paths[i].path); in geni_icc_enable()
791 dev_err_ratelimited(se->dev, "ICC enable failed on path '%s': %d\n", in geni_icc_enable()
801 int geni_icc_disable(struct geni_se *se) in geni_icc_disable() argument
805 for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { in geni_icc_disable()
806 ret = icc_disable(se->icc_paths[i].path); in geni_icc_disable()
808 dev_err_ratelimited(se->dev, "ICC disable failed on path '%s': %d\n", in geni_icc_disable()
831 if (!of_device_is_compatible(child, "qcom,geni-se-qup")) in geni_remove_earlycon_icc_vote()
916 dev_dbg(dev, "GENI SE Driver probed\n"); in geni_se_probe()
921 { .compatible = "qcom,geni-se-qup", },