History

soc: qcom: geni: Support for ICC voting

Add necessary macros and structure variables to support ICC BW voting from individual SE drivers.

Akash Asthana committed 6 years ago

Commit 58ffbba1 parent be24c6a2 files · +120 −0Browse files

Unified · Split

2 files
  1. drivers/soc/qcom/qcom-geni-se.c +82 −0
  2. include/linux/qcom-geni-se.h +38 −0
drivers/soc/qcom/qcom-geni-se.c+82−0
@@ -92,6 +92,9 @@ struct geni_wrapper { · 91 unmodified lines
9292 struct clk_bulk_data ahb_clks[NUM_AHB_CLKS];
9393 };
9494
95+static const char * const icc_path_names[] = {"qup-core", "qup-config",
96+ "qup-memory"};
97+
9598 #define QUP_HW_VER_REG 0x4
9699
97100 /* 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
720723 }
721724 EXPORT_SYMBOL(geni_se_rx_dma_unprep);
722725
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+
723805 static int geni_se_probe(struct platform_device *pdev)
724806 {
725807 struct device *dev = &pdev->dev;
include/linux/qcom-geni-se.h+38−0
@@ -6,6 +6,8 @@ · 5 unmodified lines
66 #ifndef _LINUX_QCOM_GENI_SE
77 #define _LINUX_QCOM_GENI_SE
88
9+#include <linux/interconnect.h>
10+
911 /* Transfer mode supported by GENI Serial Engines */
1012 enum geni_se_xfer_mode {
1113 GENI_SE_INVALID,
@@ -25,6 +27,17 @@ enum geni_se_protocol_type { · 13 unmodified lines
2527 struct geni_wrapper;
2628 struct clk;
2729
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+
2841 /**
2942 * struct geni_se - GENI Serial Engine
3043 * @base: Base Address of the Serial Engine's register block
@@ -33,6 +46,7 @@ struct clk; · 2 unmodified lines
3346 * @clk: Handle to the core serial engine clock
3447 * @num_clk_levels: Number of valid clock levels in clk_perf_tbl
3548 * @clk_perf_tbl: Table of clock frequency input to serial engine clock
49+ * @icc_paths: Array of ICC paths for SE
3650 */
3751 struct geni_se {
3852 void __iomem *base;
@@ -41,6 +55,7 @@ struct geni_se { · 2 unmodified lines
4155 struct clk *clk;
4256 unsigned int num_clk_levels;
4357 unsigned long *clk_perf_tbl;
58+ struct geni_icc_path icc_paths[3];
4459 };
4560
4661 /* Common SE registers */
@@ -229,6 +244,21 @@ struct geni_se { · 182 unmodified lines
229244 #define GENI_SE_VERSION_MINOR(ver) ((ver & HW_VER_MINOR_MASK) >> HW_VER_MINOR_SHFT)
230245 #define GENI_SE_VERSION_STEP(ver) (ver & HW_VER_STEP_MASK)
231246
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+
232262 #if IS_ENABLED(CONFIG_QCOM_GENI_SE)
233263
234264 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
416446 void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len);
417447
418448 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);
419457 #endif
420458 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t