From e45322a926374400125ba1be12558e2480a4e63f Mon Sep 17 00:00:00 2001 From: William Wu Date: Tue, 15 Aug 2023 16:39:09 +0800 Subject: [PATCH 01/10] ARM: dts: rockchip: disable hs park mode for usb dwc3 controller Some high speed devices performance drop drastically on Rockchip platforms when connected with DWC3-xHCI controller. It's because that the DWC3 controller enable high speed park mode by default, it aims to improve performance with pipelining of multiple packet. However, for some devices (such as UVC with bulk transfer VID:04b4, PID:02f9), when an IN request is sent within 900ns of the ACK of the previous packet, these devices NAKs more than 3 times, it could decrease the performance. These slow devices include: 1. idVendor=04b4, idProduct=02f9, Product: IRay UVC 2. idVendor=1921, idProduct=21863, Product: Sandisk 3. idVendor=3744, idProduct=8552, Manufacturer: Flex Drive In order to improve compatibility with high speed devices, this patch disable HS park mode for USB DWC3 controller on all arm64 SoCs. With this patch, we test RK3588 with one slow device (IRay UVC VID:04b4, PID:02f9) and three fast devices (U2 disk VID:058f, PID:6387; U2 disk VID:0781, PID:557c; U3 disk VID:174c, PID:55aa), all of these device have no performance loss. Signed-off-by: William Wu Change-Id: I0ac37e7af429392f65f339cf1448cf2958e03b57 --- arch/arm/boot/dts/rv1106.dtsi | 1 + arch/arm/boot/dts/rv1126.dtsi | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/rv1106.dtsi b/arch/arm/boot/dts/rv1106.dtsi index 1cf580756db0..ff475c11903d 100644 --- a/arch/arm/boot/dts/rv1106.dtsi +++ b/arch/arm/boot/dts/rv1106.dtsi @@ -1423,6 +1423,7 @@ snps,dis-tx-ipgap-linecheck-quirk; snps,usb2-gadget-lpm-disable; snps,usb2-lpm-disable; + snps,parkmode-disable-hs-quirk; status = "disabled"; }; }; diff --git a/arch/arm/boot/dts/rv1126.dtsi b/arch/arm/boot/dts/rv1126.dtsi index 2900694f1d2c..1a464c3e1076 100644 --- a/arch/arm/boot/dts/rv1126.dtsi +++ b/arch/arm/boot/dts/rv1126.dtsi @@ -2556,6 +2556,7 @@ snps,tx-fifo-resize; snps,xhci-trb-ent-quirk; snps,usb2-lpm-disable; + snps,parkmode-disable-hs-quirk; status = "disabled"; }; }; From 613e5c0710d3e4dd4c906221bcbe0b96ea1052b2 Mon Sep 17 00:00:00 2001 From: Guochun Huang Date: Wed, 16 Aug 2023 01:37:54 +0000 Subject: [PATCH 02/10] drm/rockchip: dsi2: havle dsc pps pic_width in dual channel dsi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit two dsc encoder slices which is equal to pic_width / slice_width will also halve whith pic_width <-HxV-> <------------- H/2 x V --------------> <-H x V-> ┌───────┐ ┌───────┐ ┌───────────┐ │ DSC0 ├───►│dsi0 tx├──►│lcd dsi0 rx│\ ┌───────┐ ┌─────┐ /└───────┘ └───────┘ └───────────┘ \│ │ │ │/ /│lcd DSC│ │ VP │\ ┌───────┐ ┌───────┐ ┌───────────┐/ │ │ └─────┘ \│ DSC1 ├───►│dsi1 tx├──►│lcd dsi1 rx│ └───────┘ └───────┘ └───────┘ └───────────┘ Change-Id: I65e65f969f9b1e81bee1a7343b386f577255a2f5 Signed-off-by: Guochun Huang --- drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c index b7a24e102d75..46ace54ebab8 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c @@ -1214,6 +1214,9 @@ static int dw_mipi_dsi2_get_dsc_params_from_sink(struct dw_mipi_dsi2 *dsi2, dsi2->slave->dsc_enable = dsi2->dsc_enable; } + if (!dsi2->dsc_enable) + return 0; + of_property_read_u32(np, "slice-width", &dsi2->slice_width); of_property_read_u32(np, "slice-height", &dsi2->slice_height); of_property_read_u8(np, "version-major", &dsi2->version_major); @@ -1249,8 +1252,21 @@ static int dw_mipi_dsi2_get_dsc_params_from_sink(struct dw_mipi_dsi2 *dsi2, len -= header->payload_length; } + if (!pps) { + dev_err(dsi2->dev, "not found dsc pps definition\n"); + return -EINVAL; + } + dsi2->pps = pps; + if (dsi2->slave) { + u16 pic_width = be16_to_cpu(pps->pic_width) / 2; + + dsi2->pps->pic_width = cpu_to_be16(pic_width); + dev_info(dsi2->dev, "dsc pic_width change from %d to %d\n", + pic_width * 2, pic_width); + } + return 0; } From f109af5ac1cb24af6656008211c0c0868a8d8e82 Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Mon, 14 Aug 2023 15:11:13 +0800 Subject: [PATCH 03/10] arm64: dts: rockchip: rk3588s: Change leakage-voltage-sel for venc In order to improve stability for some chips. Signed-off-by: Finley Xiao Change-Id: Ia09d9e6d455e7dd932c84f4d7815c95dda83a6d6 --- arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi index 8d64adfcdd1d..3719b14d287e 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi @@ -4081,9 +4081,9 @@ nvmem-cells = <&codec_leakage>, <&venc_opp_info>; nvmem-cell-names = "leakage", "opp-info"; rockchip,leakage-voltage-sel = < - 1 8 0 - 9 20 1 - 21 254 2 + 1 15 0 + 16 25 1 + 26 254 2 >; rockchip,grf = <&sys_grf>; From 75476ee430878834756f05253b29ac85dac020a4 Mon Sep 17 00:00:00 2001 From: Algea Cao Date: Wed, 16 Aug 2023 11:58:13 +0800 Subject: [PATCH 04/10] drm/bridge: synopsys: dw-hdmi-qp: Disable access to registers when hdmi is disabled When hdmi is disabled, relevant clocks have been turned off. Accessing hdmi registers may cause crash. Change-Id: Id5370641aac15d317d2e820aeac053a1bcf016a5 Signed-off-by: Algea Cao --- drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c index e8fc40d1e705..96c510111f36 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c @@ -3158,6 +3158,11 @@ static int dw_hdmi_ctrl_show(struct seq_file *s, void *v) struct dw_hdmi_qp *hdmi = s->private; u32 i = 0, j = 0, val = 0; + if (hdmi->disabled) { + dev_err(hdmi->dev, "hdmi is disabled\n"); + return -EACCES; + } + seq_puts(s, "\n---------------------------------------------------"); for (i = 0; i < ARRAY_SIZE(hdmi_reg_table); i++) { @@ -3189,6 +3194,11 @@ dw_hdmi_ctrl_write(struct file *file, const char __user *buf, u32 reg, val; char kbuf[25]; + if (hdmi->disabled) { + dev_err(hdmi->dev, "hdmi is disabled\n"); + return -EACCES; + } + if (count > 24) { dev_err(hdmi->dev, "out of buf range\n"); return count; From 8a5c76ee450471b4365f030a7d5f28f9e7959fe6 Mon Sep 17 00:00:00 2001 From: Jon Lin Date: Thu, 20 Jul 2023 15:30:04 +0800 Subject: [PATCH 05/10] spi: rockchip: Support pm_runtime_use_autosuspend Change-Id: I12103f0d1fbe3c168c5fa304d4bfb181d2a4ab5f Signed-off-by: Jon Lin --- drivers/spi/spi-rockchip.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 4af62691e8e4..b627663667a6 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -979,6 +979,7 @@ static int rockchip_spi_probe(struct platform_device *pdev) bool slave_mode; struct pinctrl *pinctrl = NULL; const struct rockchip_spi_quirks *quirks_cfg; + u32 val; slave_mode = of_property_read_bool(np, "spi-slave"); @@ -1106,6 +1107,13 @@ static int rockchip_spi_probe(struct platform_device *pdev) if (quirks_cfg) rs->max_baud_div_in_cpha = quirks_cfg->max_baud_div_in_cpha; + if (!device_property_read_u32(&pdev->dev, "rockchip,autosuspend-delay-ms", &val)) { + if (val > 0) { + pm_runtime_set_autosuspend_delay(&pdev->dev, val); + pm_runtime_use_autosuspend(&pdev->dev); + } + } + pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); From 939dcaa594e95270bed3da8a0d0d082c1e664965 Mon Sep 17 00:00:00 2001 From: Jon Lin Date: Sun, 6 Aug 2023 15:06:32 +0800 Subject: [PATCH 06/10] dt-bindings: spi: spi-rockchip: Support rockchip,autosuspend-delay-ms Change-Id: Ib5a7344b4732ce525a3ac54c90868e89e82ca819 Signed-off-by: Jon Lin --- Documentation/devicetree/bindings/spi/spi-rockchip.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-rockchip.yaml b/Documentation/devicetree/bindings/spi/spi-rockchip.yaml index fe2f770e42bb..d0fbfa3f2192 100644 --- a/Documentation/devicetree/bindings/spi/spi-rockchip.yaml +++ b/Documentation/devicetree/bindings/spi/spi-rockchip.yaml @@ -103,6 +103,10 @@ properties: description: GPIO spec for the spi slave ready signal. maxItems: 1 + rockchip,autosuspend-delay-ms: + default: 0 + description: Set pm runtime autosuspend value in milliseconds. + required: - compatible - reg From 490787f8b7b714343f962ec2043ea1547940300d Mon Sep 17 00:00:00 2001 From: Jon Lin Date: Wed, 26 Jul 2023 15:05:53 +0800 Subject: [PATCH 07/10] drivers: rkflash: Add sleep for spinand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Program/Erase/Read Speed – Page Program time : 450us typical – BLOCK ERASE time : 4ms typical – PAGE READ time : 120us maximum (without ECC) Change-Id: I0c5bc9827788938df028e525e331c0db8d041676 Signed-off-by: Jon Lin --- drivers/rkflash/sfc.c | 6 +++++- drivers/rkflash/sfc_nand.c | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/rkflash/sfc.c b/drivers/rkflash/sfc.c index 44a14792a90d..19773a8ec0fc 100644 --- a/drivers/rkflash/sfc.c +++ b/drivers/rkflash/sfc.c @@ -12,6 +12,7 @@ #define SFC_MAX_IOSIZE_VER4 (0xFFFFFFFF) static void __iomem *g_sfc_reg; +static u32 sfc_version; static void sfc_reset(void) { @@ -75,6 +76,7 @@ int sfc_init(void __iomem *reg_addr) if (sfc_get_version() >= SFC_VER_4) writel(1, g_sfc_reg + SFC_LEN_CTRL); + sfc_version = sfc_get_version(); return SFC_OK; } @@ -116,7 +118,7 @@ int sfc_request(struct rk_sfc_op *op, u32 addr, void *data, u32 size) op->sfctrl.d32 |= 0x2; cmd.b.datasize = size; - if (sfc_get_version() >= SFC_VER_4) + if (sfc_version >= SFC_VER_4) writel(size, g_sfc_reg + SFC_LEN_EXT); else cmd.b.datasize = size; @@ -238,6 +240,8 @@ int sfc_request(struct rk_sfc_op *op, u32 addr, void *data, u32 size) break; } + if (!bytes) + break; sfc_delay(1); if (timeout++ > 10000) { diff --git a/drivers/rkflash/sfc_nand.c b/drivers/rkflash/sfc_nand.c index f0eeec956fd8..4accf3d791c6 100644 --- a/drivers/rkflash/sfc_nand.c +++ b/drivers/rkflash/sfc_nand.c @@ -311,7 +311,7 @@ static int sfc_nand_write_feature(u32 addr, u8 status) return ret; } -static int sfc_nand_wait_busy(u8 *data, int timeout) +static int sfc_nand_wait_busy_sleep(u8 *data, int timeout, int sleep_us) { int ret; int i; @@ -319,7 +319,9 @@ static int sfc_nand_wait_busy(u8 *data, int timeout) *data = 0; - for (i = 0; i < timeout; i++) { + for (i = 0; i < timeout; i += sleep_us) { + usleep_range(sleep_us, sleep_us + 50); + ret = sfc_nand_read_feature(0xC0, &status); if (ret != SFC_OK) @@ -329,8 +331,6 @@ static int sfc_nand_wait_busy(u8 *data, int timeout) if (!(status & (1 << 0))) return SFC_OK; - - sfc_delay(1); } return SFC_NAND_WAIT_TIME_OUT; @@ -794,7 +794,7 @@ u32 sfc_nand_erase_block(u8 cs, u32 addr) if (ret != SFC_OK) return ret; - ret = sfc_nand_wait_busy(&status, 1000 * 1000); + ret = sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 1000); if (status & (1 << 2)) return SFC_NAND_PROG_ERASE_ERROR; @@ -851,6 +851,7 @@ u32 sfc_nand_prog_page_raw(u8 cs, u32 addr, u32 *p_page_buf) op.sfctrl.d32 = 0; op.sfctrl.b.datalines = sfc_nand_dev.prog_lines; op.sfctrl.b.addrbits = 16; + op.sfctrl.b.enbledma = 0; plane = p_nand_info->plane_per_die == 2 ? ((addr >> 6) & 0x1) << 12 : 0; sfc_request(&op, plane, p_page_buf, page_size); @@ -880,7 +881,8 @@ u32 sfc_nand_prog_page_raw(u8 cs, u32 addr, u32 *p_page_buf) if (ret != SFC_OK) return ret; - ret = sfc_nand_wait_busy(&status, 1000 * 1000); + ret = sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 200); + if (status & (1 << 3)) return SFC_NAND_PROG_ERASE_ERROR; @@ -931,7 +933,10 @@ u32 sfc_nand_read(u32 row, u32 *p_page_buf, u32 column, u32 len) sfc_get_version() < SFC_VER_3) sfc_nand_rw_preset(); - sfc_nand_wait_busy(&status, 1000 * 1000); + sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 50); + if (sfc_nand_dev.manufacturer == 0x01 && status) + sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 50); + ecc_result = p_nand_info->ecc_status(); op.sfcmd.d32 = 0; @@ -942,6 +947,7 @@ u32 sfc_nand_read(u32 row, u32 *p_page_buf, u32 column, u32 len) op.sfctrl.d32 = 0; op.sfctrl.b.datalines = sfc_nand_dev.read_lines; op.sfctrl.b.addrbits = 16; + op.sfctrl.b.enbledma = 0; plane = p_nand_info->plane_per_die == 2 ? ((row >> 6) & 0x1) << 12 : 0; ret = sfc_request(&op, plane | column, p_page_buf, len); From 4b354ca1b7628d9d233bd7454b7051ca96e813a4 Mon Sep 17 00:00:00 2001 From: Shunhua Lan Date: Wed, 16 Aug 2023 23:47:23 +0800 Subject: [PATCH 08/10] arm64: dts: rockchip: rk3399-evb: fix dts build error Fixes: d449b25d6b0e ("arm64: dts: rockchip: rk3399-evb: use multicodecs instead simple card") Signed-off-by: Shunhua Lan Change-Id: I2c13a7834090e8433301125b79e86219db7b805d --- arch/arm64/boot/dts/rockchip/rk3399-excavator-sapphire.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3399-excavator-sapphire.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-excavator-sapphire.dtsi index c12a87057876..59cdade78801 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399-excavator-sapphire.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399-excavator-sapphire.dtsi @@ -32,7 +32,7 @@ "Speaker", "Speaker Power", "IN1P", "Main Mic", "IN2P", "Headset Mic", - "IN2N", "Headset Mic"; + "IN2N", "Headset Mic", "Headset Mic", "micbias1"; play-pause-key { label = "playpause"; From a555b785b3e5d75875e0ca25da5155f61458e050 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Fri, 4 Aug 2023 02:34:57 +0000 Subject: [PATCH 09/10] soc: rockchip: amp: Add 'boot-on' property assignment support boot-on is absent or boot-on = <1>: bring up this cpu when driver probe. Signed-off-by: Joseph Chen Change-Id: I0157e72b53f5c35e5478408804a72bab5fd02837 --- drivers/soc/rockchip/rockchip_amp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/soc/rockchip/rockchip_amp.c b/drivers/soc/rockchip/rockchip_amp.c index 0d1cb29ac207..e7faf3be22c3 100644 --- a/drivers/soc/rockchip/rockchip_amp.c +++ b/drivers/soc/rockchip/rockchip_amp.c @@ -207,7 +207,7 @@ static int rockchip_amp_boot_cpus(struct device *dev, struct device_node *cpu_node, int idx) { u64 cpu_entry, cpu_id; - u32 cpu_mode; + u32 cpu_mode, boot_on; int ret; if (idx >= CONFIG_NR_CPUS) @@ -233,6 +233,9 @@ static int rockchip_amp_boot_cpus(struct device *dev, return -1; } + if (of_property_read_u32_array(cpu_node, "boot-on", &boot_on, 1)) + boot_on = 1; /* compatible old action */ + cpu_boot_info[idx].entry = cpu_entry; cpu_boot_info[idx].mode = cpu_mode; cpu_boot_info[idx].cpu_id = cpu_id; @@ -243,10 +246,12 @@ static int rockchip_amp_boot_cpus(struct device *dev, return ret; } - ret = sip_smc_amp_config(RK_AMP_SUB_FUNC_CPU_ON, cpu_id, cpu_entry, 0); - if (ret) { - dev_warn(dev, "booting up a cpu is error(%d)!\n", ret); - return ret; + if (boot_on) { + ret = sip_smc_amp_config(RK_AMP_SUB_FUNC_CPU_ON, cpu_id, cpu_entry, 0); + if (ret) { + dev_warn(dev, "booting up a cpu is error(%d)!\n", ret); + return ret; + } } cpu_boot_info[idx].en = 1; From f2576488ab0bcb5544f9e9415c116b26a65e4b68 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Wed, 16 Aug 2023 02:36:34 +0000 Subject: [PATCH 10/10] soc: rockchip: amp: Update coding style and message Signed-off-by: Joseph Chen Change-Id: I05b802b7caec5361c5b659926ebd46f31f0b1d44 --- drivers/soc/rockchip/rockchip_amp.c | 87 ++++++++++++++--------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/drivers/soc/rockchip/rockchip_amp.c b/drivers/soc/rockchip/rockchip_amp.c index e7faf3be22c3..3bb0920eab42 100644 --- a/drivers/soc/rockchip/rockchip_amp.c +++ b/drivers/soc/rockchip/rockchip_amp.c @@ -111,29 +111,29 @@ static ssize_t boot_cpu_show(struct device *dev, static void cpu_status_print(unsigned long cpu_id, struct arm_smccc_res *res) { if (res->a0) { - pr_info("get cpu-0x%lx status(%lx) error!\n", cpu_id, res->a0); + pr_info("failed to get cpu[%lx] status, ret=%lx!\n", cpu_id, res->a0); return; } if (res->a1 == AMP_CPU_STATUS_AMP_DIS) - pr_info("cpu-0x%lx amp is disable (%ld)\n", cpu_id, res->a1); + pr_info("cpu[%lx] amp is disabled (%ld)\n", cpu_id, res->a1); else if (res->a1 == AMP_CPU_STATUS_EN) - pr_info("cpu-0x%lx amp is enable (%ld)\n", cpu_id, res->a1); + pr_info("cpu[%lx] amp is enabled (%ld)\n", cpu_id, res->a1); else if (res->a1 == AMP_CPU_STATUS_ON) - pr_info("cpu-0x%lx amp: cpu is on (%ld)\n", cpu_id, res->a1); + pr_info("cpu[%lx] amp: cpu is on (%ld)\n", cpu_id, res->a1); else if (res->a1 == AMP_CPU_STATUS_OFF) - pr_info("cpu-0x%lx amp: cpu is off(%ld)\n", cpu_id, res->a1); + pr_info("cpu[%lx] amp: cpu is off(%ld)\n", cpu_id, res->a1); else - pr_info("cpu-0x%lx status(%ld) is error\n", cpu_id, res->a1); + pr_info("cpu[%lx] amp status(%ld) is error\n", cpu_id, res->a1); if (res->a2 == RK_CPU_STATUS_OFF) - pr_info("cpu-0x%lx status(%ld) is off\n", cpu_id, res->a2); + pr_info("cpu[%lx] status(%ld) is off\n", cpu_id, res->a2); else if (res->a2 == RK_CPU_STATUS_ON) - pr_info("cpu-0x%lx status(%ld) is on\n", cpu_id, res->a2); + pr_info("cpu[%lx] status(%ld) is on\n", cpu_id, res->a2); else if (res->a2 == RK_CPU_STATUS_BUSY) - pr_info("cpu-0x%lx status(%ld) is busy\n", cpu_id, res->a2); + pr_info("cpu[%lx] status(%ld) is busy\n", cpu_id, res->a2); else - pr_info("cpu-0x%lx status(%ld) is error\n", cpu_id, res->a2); + pr_info("cpu[%lx] status(%ld) is error\n", cpu_id, res->a2); } static ssize_t boot_cpu_store(struct device *dev, @@ -141,9 +141,9 @@ static ssize_t boot_cpu_store(struct device *dev, const char *buf, size_t count) { - char cmd[10]; - unsigned long cpu_id; struct arm_smccc_res res = {0}; + unsigned long cpu_id; + char cmd[10]; int ret, idx; ret = sscanf(buf, "%s", cmd); @@ -154,12 +154,10 @@ static ssize_t boot_cpu_store(struct device *dev, if (!strncmp(cmd, "status", strlen("status"))) { ret = sscanf(buf, "%s %lx", cmd, &cpu_id); - if (ret != 2) return -EINVAL; - res = sip_smc_get_amp_info(RK_AMP_SUB_FUNC_GET_CPU_STATUS, - cpu_id); + res = sip_smc_get_amp_info(RK_AMP_SUB_FUNC_GET_CPU_STATUS, cpu_id); cpu_status_print(cpu_id, &res); } else if (!strncmp(cmd, "off", strlen("off"))) { ret = sscanf(buf, "%s %lx", cmd, &cpu_id); @@ -167,17 +165,14 @@ static ssize_t boot_cpu_store(struct device *dev, return -EINVAL; idx = get_cpu_boot_info_idx(cpu_id); - if (idx >= 0 && cpu_boot_info[idx].en) { ret = sip_smc_amp_config(RK_AMP_SUB_FUNC_REQ_CPU_OFF, cpu_id, 0, 0); if (ret) - pr_info("requesting a cpu off is error(%d)!\n", - ret); + dev_warn(dev, "failed to request cpu[%lx] off, ret=%d!\n", cpu_id, ret); } } else if (!strncmp(cmd, "on", strlen("on"))) { ret = sscanf(buf, "%s %lx", cmd, &cpu_id); - if (ret != 2) return -EINVAL; @@ -188,11 +183,14 @@ static ssize_t boot_cpu_store(struct device *dev, cpu_boot_info[idx].entry, 0); if (ret) - pr_info("booting up a cpu is error(%d)!\n", - ret); + dev_warn(dev, "Brought up cpu[%lx] failed, ret=%d\n", cpu_id, ret); + else + pr_info("Brought up cpu[%lx] ok.\n", cpu_id); + } else { + dev_warn(dev, "cpu[%lx] is unavailable\n", cpu_id); } } else { - pr_info("unsupported cmd(%s)\n", cmd); + dev_warn(dev, "unsupported cmd(%s)\n", cmd); } return count; @@ -213,23 +211,23 @@ static int rockchip_amp_boot_cpus(struct device *dev, if (idx >= CONFIG_NR_CPUS) return -1; + if (of_property_read_u64_array(cpu_node, "id", &cpu_id, 1)) { + dev_warn(dev, "failed to get 'id'\n"); + return -1; + } + if (of_property_read_u64_array(cpu_node, "entry", &cpu_entry, 1)) { - dev_warn(dev, "can not get the entry\n"); + dev_warn(dev, "failed to get cpu[%llx] 'entry'\n", cpu_id); return -1; } if (!cpu_entry) { - dev_warn(dev, "cpu-entry is 0\n"); - return -1; - } - - if (of_property_read_u64_array(cpu_node, "id", &cpu_id, 1)) { - dev_warn(dev, "can not get the cpu id\n"); + dev_warn(dev, "invalid cpu[%llx] 'entry': 0\n", cpu_id); return -1; } if (of_property_read_u32_array(cpu_node, "mode", &cpu_mode, 1)) { - dev_warn(dev, "can not get the cpu mode\n"); + dev_warn(dev, "failed to get cpu[%llx] 'mode'\n", cpu_id); return -1; } @@ -242,15 +240,17 @@ static int rockchip_amp_boot_cpus(struct device *dev, ret = sip_smc_amp_config(RK_AMP_SUB_FUNC_CFG_MODE, cpu_id, cpu_mode, 0); if (ret) { - dev_warn(dev, "setting cpu mode is error(%d)!\n", ret); + dev_warn(dev, "failed to set cpu mode, ret=%d\n", ret); return ret; } if (boot_on) { ret = sip_smc_amp_config(RK_AMP_SUB_FUNC_CPU_ON, cpu_id, cpu_entry, 0); if (ret) { - dev_warn(dev, "booting up a cpu is error(%d)!\n", ret); + dev_warn(dev, "Brought up cpu[%llx] failed, ret=%d\n", cpu_id, ret); return ret; + } else { + pr_info("Brought up cpu[%llx] ok.\n", cpu_id); } } @@ -512,9 +512,9 @@ exit: static int rockchip_amp_probe(struct platform_device *pdev) { - struct rkamp_device *rkamp_dev = NULL; - int ret, i, idx = 0; struct device_node *cpus_node, *cpu_node; + struct rkamp_device *rkamp_dev; + int ret, i, idx = 0; rkamp_dev = devm_kzalloc(&pdev->dev, sizeof(*rkamp_dev), GFP_KERNEL); if (!rkamp_dev) @@ -523,18 +523,20 @@ static int rockchip_amp_probe(struct platform_device *pdev) rkamp_dev->num_clks = devm_clk_bulk_get_all(&pdev->dev, &rkamp_dev->clks); if (rkamp_dev->num_clks < 0) return -ENODEV; + ret = clk_bulk_prepare_enable(rkamp_dev->num_clks, rkamp_dev->clks); if (ret) return dev_err_probe(&pdev->dev, ret, "failed to prepare enable clks: %d\n", ret); pm_runtime_enable(&pdev->dev); - rkamp_dev->num_pds = of_count_phandle_with_args(pdev->dev.of_node, "power-domains", - "#power-domain-cells"); - + rkamp_dev->num_pds = + of_count_phandle_with_args(pdev->dev.of_node, "power-domains", + "#power-domain-cells"); if (rkamp_dev->num_pds > 0) { - rkamp_dev->pd_dev = devm_kmalloc_array(&pdev->dev, rkamp_dev->num_pds, - sizeof(*rkamp_dev->pd_dev), GFP_KERNEL); + rkamp_dev->pd_dev = + devm_kmalloc_array(&pdev->dev, rkamp_dev->num_pds, + sizeof(*rkamp_dev->pd_dev), GFP_KERNEL); if (!rkamp_dev->pd_dev) return -ENOMEM; @@ -555,13 +557,10 @@ static int rockchip_amp_probe(struct platform_device *pdev) } cpus_node = of_get_child_by_name(pdev->dev.of_node, "amp-cpus"); - if (cpus_node) { for_each_available_child_of_node(cpus_node, cpu_node) { - if (!rockchip_amp_boot_cpus(&pdev->dev, cpu_node, - idx)) { + if (!rockchip_amp_boot_cpus(&pdev->dev, cpu_node, idx)) idx++; - } } of_node_put(cpus_node); } @@ -581,8 +580,8 @@ static int rockchip_amp_probe(struct platform_device *pdev) static int rockchip_amp_remove(struct platform_device *pdev) { - int i; struct rkamp_device *rkamp_dev = platform_get_drvdata(pdev); + int i; clk_bulk_disable_unprepare(rkamp_dev->num_clks, rkamp_dev->clks);