Add necessary macros and structure variables to support ICC BW voting from individual SE drivers.
Unified · Split
| @@ -92,6 +92,9 @@ struct geni_wrapper { · 91 unmodified lines | |||
| 92 | struct clk_bulk_data ahb_clks[NUM_AHB_CLKS]; | 92 | struct clk_bulk_data ahb_clks[NUM_AHB_CLKS]; |
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | static const char * const icc_path_names[] = {"qup-core", "qup-config", | ||
| 96 | "qup-memory"}; | ||
| 97 | |||
| 95 | #define QUP_HW_VER_REG 0x4 | 98 | #define QUP_HW_VER_REG 0x4 |
| 96 | 99 | ||
| 97 | /* Common SE registers */ | 100 | /* Common SE registers */ |
| @@ -720,6 +723,85 @@ void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len) · 622 unmodified lines | |||
| 720 | } | 723 | } |
| 721 | EXPORT_SYMBOL(geni_se_rx_dma_unprep); | 724 | EXPORT_SYMBOL(geni_se_rx_dma_unprep); |
| 722 | 725 | ||
| 726 | int geni_icc_get(struct geni_se *se, const char *icc_ddr) | ||
| 727 | { | ||
| 728 | int i, err; | ||
| 729 | const char *icc_names[] = {"qup-core", "qup-config", icc_ddr}; | ||
| 730 | |||
| 731 | for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { | ||
| 732 | if (!icc_names[i]) | ||
| 733 | continue; | ||
| 734 | |||
| 735 | se->icc_paths[i].path = devm_of_icc_get(se->dev, icc_names[i]); | ||
| 736 | if (IS_ERR(se->icc_paths[i].path)) | ||
| 737 | goto err; | ||
| 738 | } | ||
| 739 | |||
| 740 | return 0; | ||
| 741 | |||
| 742 | err: | ||
| 743 | err = PTR_ERR(se->icc_paths[i].path); | ||
| 744 | if (err != -EPROBE_DEFER) | ||
| 745 | dev_err_ratelimited(se->dev, "Failed to get ICC path '%s': %d\n", | ||
| 746 | icc_names[i], err); | ||
| 747 | return err; | ||
| 748 | |||
| 749 | } | ||
| 750 | EXPORT_SYMBOL(geni_icc_get); | ||
| 751 | |||
| 752 | int geni_icc_set_bw(struct geni_se *se) | ||
| 753 | { | ||
| 754 | int i, ret; | ||
| 755 | |||
| 756 | for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { | ||
| 757 | ret = icc_set_bw(se->icc_paths[i].path, | ||
| 758 | se->icc_paths[i].avg_bw, se->icc_paths[i].avg_bw); | ||
| 759 | if (ret) { | ||
| 760 | dev_err_ratelimited(se->dev, "ICC BW voting failed on path '%s': %d\n", | ||
| 761 | icc_path_names[i], ret); | ||
| 762 | return ret; | ||
| 763 | } | ||
| 764 | } | ||
| 765 | |||
| 766 | return 0; | ||
| 767 | } | ||
| 768 | EXPORT_SYMBOL(geni_icc_set_bw); | ||
| 769 | |||
| 770 | /* To do: Replace this by icc_bulk_enable once it's implemented in ICC core */ | ||
| 771 | int geni_icc_enable(struct geni_se *se) | ||
| 772 | { | ||
| 773 | int i, ret; | ||
| 774 | |||
| 775 | for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { | ||
| 776 | ret = icc_enable(se->icc_paths[i].path); | ||
| 777 | if (ret) { | ||
| 778 | dev_err_ratelimited(se->dev, "ICC enable failed on path '%s': %d\n", | ||
| 779 | icc_path_names[i], ret); | ||
| 780 | return ret; | ||
| 781 | } | ||
| 782 | } | ||
| 783 | |||
| 784 | return 0; | ||
| 785 | } | ||
| 786 | EXPORT_SYMBOL(geni_icc_enable); | ||
| 787 | |||
| 788 | int geni_icc_disable(struct geni_se *se) | ||
| 789 | { | ||
| 790 | int i, ret; | ||
| 791 | |||
| 792 | for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) { | ||
| 793 | ret = icc_disable(se->icc_paths[i].path); | ||
| 794 | if (ret) { | ||
| 795 | dev_err_ratelimited(se->dev, "ICC disable failed on path '%s': %d\n", | ||
| 796 | icc_path_names[i], ret); | ||
| 797 | return ret; | ||
| 798 | } | ||
| 799 | } | ||
| 800 | |||
| 801 | return 0; | ||
| 802 | } | ||
| 803 | EXPORT_SYMBOL(geni_icc_disable); | ||
| 804 | |||
| 723 | static int geni_se_probe(struct platform_device *pdev) | 805 | static int geni_se_probe(struct platform_device *pdev) |
| 724 | { | 806 | { |
| 725 | struct device *dev = &pdev->dev; | 807 | struct device *dev = &pdev->dev; |
| @@ -6,6 +6,8 @@ · 5 unmodified lines | |||
| 6 | #ifndef _LINUX_QCOM_GENI_SE | 6 | #ifndef _LINUX_QCOM_GENI_SE |
| 7 | #define _LINUX_QCOM_GENI_SE | 7 | #define _LINUX_QCOM_GENI_SE |
| 8 | 8 | ||
| 9 | #include <linux/interconnect.h> | ||
| 10 | |||
| 9 | /* Transfer mode supported by GENI Serial Engines */ | 11 | /* Transfer mode supported by GENI Serial Engines */ |
| 10 | enum geni_se_xfer_mode { | 12 | enum geni_se_xfer_mode { |
| 11 | GENI_SE_INVALID, | 13 | GENI_SE_INVALID, |
| @@ -25,6 +27,17 @@ enum geni_se_protocol_type { · 13 unmodified lines | |||
| 25 | struct geni_wrapper; | 27 | struct geni_wrapper; |
| 26 | struct clk; | 28 | struct clk; |
| 27 | 29 | ||
| 30 | enum geni_icc_path_index { | ||
| 31 | GENI_TO_CORE, | ||
| 32 | CPU_TO_GENI, | ||
| 33 | GENI_TO_DDR | ||
| 34 | }; | ||
| 35 | |||
| 36 | struct geni_icc_path { | ||
| 37 | struct icc_path *path; | ||
| 38 | unsigned int avg_bw; | ||
| 39 | }; | ||
| 40 | |||
| 28 | /** | 41 | /** |
| 29 | * struct geni_se - GENI Serial Engine | 42 | * struct geni_se - GENI Serial Engine |
| 30 | * @base: Base Address of the Serial Engine's register block | 43 | * @base: Base Address of the Serial Engine's register block |
| @@ -33,6 +46,7 @@ struct clk; · 2 unmodified lines | |||
| 33 | * @clk: Handle to the core serial engine clock | 46 | * @clk: Handle to the core serial engine clock |
| 34 | * @num_clk_levels: Number of valid clock levels in clk_perf_tbl | 47 | * @num_clk_levels: Number of valid clock levels in clk_perf_tbl |
| 35 | * @clk_perf_tbl: Table of clock frequency input to serial engine clock | 48 | * @clk_perf_tbl: Table of clock frequency input to serial engine clock |
| 49 | * @icc_paths: Array of ICC paths for SE | ||
| 36 | */ | 50 | */ |
| 37 | struct geni_se { | 51 | struct geni_se { |
| 38 | void __iomem *base; | 52 | void __iomem *base; |
| @@ -41,6 +55,7 @@ struct geni_se { · 2 unmodified lines | |||
| 41 | struct clk *clk; | 55 | struct clk *clk; |
| 42 | unsigned int num_clk_levels; | 56 | unsigned int num_clk_levels; |
| 43 | unsigned long *clk_perf_tbl; | 57 | unsigned long *clk_perf_tbl; |
| 58 | struct geni_icc_path icc_paths[3]; | ||
| 44 | }; | 59 | }; |
| 45 | 60 | ||
| 46 | /* Common SE registers */ | 61 | /* Common SE registers */ |
| @@ -229,6 +244,21 @@ struct geni_se { · 182 unmodified lines | |||
| 229 | #define GENI_SE_VERSION_MINOR(ver) ((ver & HW_VER_MINOR_MASK) >> HW_VER_MINOR_SHFT) | 244 | #define GENI_SE_VERSION_MINOR(ver) ((ver & HW_VER_MINOR_MASK) >> HW_VER_MINOR_SHFT) |
| 230 | #define GENI_SE_VERSION_STEP(ver) (ver & HW_VER_STEP_MASK) | 245 | #define GENI_SE_VERSION_STEP(ver) (ver & HW_VER_STEP_MASK) |
| 231 | 246 | ||
| 247 | /* | ||
| 248 | * Define bandwidth thresholds that cause the underlying Core 2X interconnect | ||
| 249 | * clock to run at the named frequency. These baseline values are recommended | ||
| 250 | * by the hardware team, and are not dynamically scaled with GENI bandwidth | ||
| 251 | * beyond basic on/off. | ||
| 252 | */ | ||
| 253 | #define CORE_2X_19_2_MHZ 960 | ||
| 254 | #define CORE_2X_50_MHZ 2500 | ||
| 255 | #define CORE_2X_100_MHZ 5000 | ||
| 256 | #define CORE_2X_150_MHZ 7500 | ||
| 257 | #define CORE_2X_200_MHZ 10000 | ||
| 258 | #define CORE_2X_236_MHZ 16383 | ||
| 259 | |||
| 260 | #define GENI_DEFAULT_BW Bps_to_icc(1000) | ||
| 261 | |||
| 232 | #if IS_ENABLED(CONFIG_QCOM_GENI_SE) | 262 | #if IS_ENABLED(CONFIG_QCOM_GENI_SE) |
| 233 | 263 | ||
| 234 | u32 geni_se_get_qup_hw_version(struct geni_se *se); | 264 | u32 geni_se_get_qup_hw_version(struct geni_se *se); |
| @@ -416,5 +446,13 @@ int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len, · 181 unmodified lines | |||
| 416 | void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len); | 446 | void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len); |
| 417 | 447 | ||
| 418 | void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len); | 448 | void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len); |
| 449 | |||
| 450 | int geni_icc_get(struct geni_se *se, const char *icc_ddr); | ||
| 451 | |||
| 452 | int geni_icc_set_bw(struct geni_se *se); | ||
| 453 | |||
| 454 | int geni_icc_enable(struct geni_se *se); | ||
| 455 | |||
| 456 | int geni_icc_disable(struct geni_se *se); | ||
| 419 | #endif | 457 | #endif |
| 420 | #endif | 458 | #endif |