ring: ring: add osc ring efuse info get cmd for g12 [3/3]
authorHuan Biao <huan.biao@amlogic.com>
Thu, 7 Jun 2018 11:27:44 +0000 (19:27 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Fri, 22 Jun 2018 02:02:41 +0000 (19:02 -0700)
PD#165091:

Problem:
no osc ring efuse info

Solution:
add g12 osc ring efuse info get cmd

Verify:
g12 skt

Change-Id: I5adf6efd9787a6afeea38e959105f4a273a82bad
Signed-off-by: Huan Biao <huan.biao@amlogic.com>
arch/arm64/boot/dts/amlogic/mesong12a.dtsi
arch/arm64/configs/meson64_defconfig
drivers/amlogic/clk/Kconfig
drivers/amlogic/clk/clk_measure.c
drivers/amlogic/mailbox/scpi_protocol.c
include/linux/amlogic/scpi_protocol.h

index 34faeb4..aeddf60 100644 (file)
                        meson_clk_msr {
                                compatible = "amlogic, gxl_measure";
                                reg = <0x0 0x18004 0x0 0x4
-                      0x0 0x1800c 0x0 0x4>;
+                                       0x0 0x1800c 0x0 0x4>;
+                               ringctrl = <0xff6345fc>;
                        };
 
                        pwm_ab: pwm@1b000 {
index 7ce567a..06e604b 100644 (file)
@@ -225,7 +225,6 @@ CONFIG_AMLOGIC_SEC=y
 CONFIG_AMLOGIC_CPU_VERSION=y
 CONFIG_AMLOGIC_MESON64_VERSION=y
 CONFIG_AMLOGIC_CPU_INFO=y
-CONFIG_AMLOGIC_MHU_MBOX=y
 CONFIG_AMLOGIC_REG_ACCESS=y
 CONFIG_AMLOGIC_TIMER=y
 CONFIG_AMLOGIC_BC_TIMER=y
index a38da71..90f9637 100644 (file)
@@ -2,6 +2,7 @@ config AMLOGIC_CLK
        bool "Amlogic clock driver  support"
        depends on OF
        select COMMON_CLK
+       select AMLOGIC_MHU_MBOX
        help
                This is the Amlogic Clock  driver
                Say Y if you want peripherals
@@ -37,4 +38,4 @@ config AMLOGIC_GX_CLK
        depends on AMLOGIC_CLK
        help
          Support for the clock controller on AmLogic S905 devices, aka gxbb.
-         Say Y if you want peripherals and CPU frequency scaling to work.
\ No newline at end of file
+         Say Y if you want peripherals and CPU frequency scaling to work.
index db34c19..9054f1b 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/amlogic/cpu_version.h>
 #include <linux/amlogic/iomap.h>
 #include <linux/amlogic/clk_measure.h>
+#include <linux/amlogic/scpi_protocol.h>
 
 #undef pr_fmt
 #define pr_fmt(fmt) "clkmsr: " fmt
@@ -118,7 +119,7 @@ static unsigned int gxbb_clk_util_clk_msr(unsigned int clk_mux)
 
 }
 
-static unsigned int gxbb_clk_util_ring_msr(unsigned int clk_mux)
+static unsigned int meson_clk_util_ring_msr(unsigned int clk_mux)
 {
        unsigned int  msr;
        unsigned int regval = 0;
@@ -872,7 +873,7 @@ int g12a_clk_measure(struct seq_file *s, void *what, unsigned int index)
        return 0;
 }
 
-int g12a_ring_measure(struct seq_file *s, void *what, unsigned int index)
+int g12_ring_measure(struct seq_file *s, void *what, unsigned int index)
 {
        static const char * const clk_table[] = {
                        [11] = "sys_cpu_ring_osc_clk[1] ",
@@ -890,22 +891,44 @@ int g12a_ring_measure(struct seq_file *s, void *what, unsigned int index)
                };
        const int tb[] = {0, 1, 2, 99, 100, 101, 102, 103, 104, 105, 3, 33};
        unsigned long i;
+       unsigned char ringinfo[8] = {0, 0, 0, 0, 0, 0, 0, 0};
 
-       msr_ring_reg0 = ioremap(0xff6345fc, 1);
        /*RING_OSCILLATOR       0x7f: set slow ring*/
-       writel_relaxed(0x555555, msr_ring_reg0);
-       for (i = 0; i < 12; i++) {
-               seq_printf(s, "[%10d]: %s\n",
-                                          gxbb_clk_util_ring_msr(tb[i]),
-                                               clk_table[i]);
+       if (msr_ring_reg0 != NULL) {
+               writel_relaxed(0x555555, msr_ring_reg0);
+               for (i = 0; i < 12; i++)
+                       seq_printf(s, "%s       :%10d   KHz\n",
+                         clk_table[i], meson_clk_util_ring_msr(tb[i]));
+       } else {
+               seq_puts(s, "fail test osc ring info\n");
+       }
 
+       if (scpi_get_ring_value(ringinfo) != 0) {
+               seq_puts(s, "fail get osc ring efuse info\n");
+               return 0;
        }
-       iounmap(msr_ring_reg0);
+
+       seq_puts(s, "osc ring efuse info:\n");
+
+       for (i = 0; i < 8; i++)
+               seq_printf(s, "0x%x ", ringinfo[i]);
+       seq_puts(s, "\n");
+
+       /*efuse to test value*/
+       seq_puts(s, "ee[9], ee[1], ee[0], cpu[1], cpu[0], iddee, iddcpu\n");
+
+       for (i = 1; i <= 5; i++)
+               seq_printf(s, "%d KHz ", (ringinfo[i] * 20));
+
+       for (i = 6; i <= 7; i++)
+               seq_printf(s, "%d uA ", (ringinfo[i] * 200));
+
+       seq_puts(s, "\n");
+
        return 0;
 }
 
-
-int  meson_clk_measure(unsigned int clk_mux)
+int meson_clk_measure(unsigned int clk_mux)
 {
        int clk_val;
 
@@ -952,7 +975,7 @@ static int dump_clk(struct seq_file *s, void *what)
 static int dump_ring(struct seq_file *s, void *what)
 {
        if (get_cpu_type() == MESON_CPU_MAJOR_ID_G12A)
-               g12a_ring_measure(s, what, clk_msr_index);
+               g12_ring_measure(s, what, clk_msr_index);
        return 0;
 }
 
@@ -1019,6 +1042,7 @@ static int aml_clkmsr_probe(struct platform_device *pdev)
 {
        static struct dentry *debugfs_root;
        struct device_node *np;
+       u32 ringctrl;
 
        np = pdev->dev.of_node;
        debugfs_root = debugfs_create_dir("aml_clkmsr", NULL);
@@ -1037,6 +1061,17 @@ static int aml_clkmsr_probe(struct platform_device *pdev)
        msr_clk_reg2 = of_iomap(np, 1);
        pr_info("msr_clk_reg0=%p,msr_clk_reg2=%p\n",
                msr_clk_reg0, msr_clk_reg2);
+
+       if (of_property_read_u32(pdev->dev.of_node,
+                               "ringctrl", &ringctrl)) {
+               dev_err(&pdev->dev,
+                       "failed to get msr ring reg0\n");
+               msr_ring_reg0 = NULL;
+       } else {
+               msr_ring_reg0 = ioremap(ringctrl, 1);
+               pr_info("msr_ring_reg0=%p\n", msr_ring_reg0);
+       }
+
        return 0;
 }
 
index 7444620..8ed94a3 100644 (file)
@@ -461,3 +461,23 @@ int scpi_set_vrtc(u32 vrtc_val)
        return 0;
 }
 EXPORT_SYMBOL_GPL(scpi_set_vrtc);
+
+int scpi_get_ring_value(unsigned char *val)
+{
+       struct scpi_data_buf sdata;
+       struct mhu_data_buf mdata;
+       struct __packed {
+               unsigned int status;
+               unsigned char ringinfo[8];
+       } buf;
+       int ret;
+       u32 temp = 0;
+
+       SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_NONE, SCPI_CMD_OSCRING_VALUE,
+                       temp, buf);
+       ret = scpi_execute_cmd(&sdata);
+       if (ret == 0)
+               memcpy(val, &buf.ringinfo, sizeof(buf.ringinfo));
+       return ret;
+}
+EXPORT_SYMBOL_GPL(scpi_get_ring_value);
index 7395c26..806689d 100644 (file)
@@ -64,6 +64,7 @@ enum scpi_std_cmd {
        SCPI_CMD_SENSOR_CFG_BOUNDS      = 0x1e,
        SCPI_CMD_SENSOR_ASYNC_VALUE     = 0x1f,
        SCPI_CMD_SET_USR_DATA = 0x20,
+       SCPI_CMD_OSCRING_VALUE = 0x43,
        SCPI_CMD_COUNT
 };
 
@@ -89,4 +90,5 @@ int scpi_get_sensor_value(u16 sensor, u32 *val);
 int scpi_send_usr_data(u32 client_id, u32 *val, u32 size);
 int scpi_get_vrtc(u32 *p_vrtc);
 int scpi_set_vrtc(u32 vrtc_val);
+int scpi_get_ring_value(unsigned char *val);
 #endif /*_SCPI_PROTOCOL_H_*/