Skip to contentSkip to conversation

Add cpuidle driver for Sunplus SP7021

PATCH Superseded Edwin Chiu 3 participants 5 messages Jan 6, 2022 – Jan 12, 2022

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Edwin Chiu

author
#0 lore raw

v3 cover Add cpuidle driver for Sunplus SP7021

This is a patch series for cpuidle driver for Sunplus SP7021 SoC.

Sunplus SP7021 is an ARM Cortex A7 (4 cores) based SoC. It integrates many peripherals (ex: UART, I2C, SPI, SDIO, eMMC, USB, SD card and etc.) into a single chip. It is designed for industrial control.

Refer to:
https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
https://tibbo.com/store/plus1.html

Edwin Chiu (2):
dt-bingings:arm:sunplus:add sp7021 compatible string to
sunplus,idle-state.yaml
cpuidle:sunplus:create cpuidle driver for sunplus sp7021

 .../bindings/arm/sunplus/sunplus,idle-state.yaml   |  59 ++++++++
 MAINTAINERS                                        |   9 ++
 drivers/cpuidle/Kconfig.arm                        |   7 +
 drivers/cpuidle/Makefile                           |   1 +
 drivers/cpuidle/cpuidle-sunplus.c                  | 167 +++++++++++++++++++++
 include/linux/platform_data/cpuidle-sunplus.h      |  19 +++
 6 files changed, 262 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml
 create mode 100644 drivers/cpuidle/cpuidle-sunplus.c
 create mode 100644 include/linux/platform_data/cpuidle-sunplus.h
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v3 1/2 dt-bingings:arm:sunplus:add sp7021 compatible string to sunplus,idle-state.yaml

Add the compatible string for cpuidle state on sp7021

---
Changes in v3
- Align email address of sob and sender
- Added sp7021 compatible string

 .../bindings/arm/sunplus/sunplus,idle-state.yaml   | 59 ++++++++++++++++++++++
 MAINTAINERS                                        |  5 ++
 2 files changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml
Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml new file +59 -0
new file mode 100644
index 0000000..64281ba
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) Sunplus Co., Ltd. 2021
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/sunplus/sunplus,idle-state.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SOC cpuidle state
+
+maintainers:
+  - Edwin Chiu<[email protected]>
+
+description: |
+  Sunplus SOC cpuidle state
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - sunplus,sp7021-idle-state
+
+  entry-latency-us:
+    description:
+      Worst case latency in microseconds required to enter the idle state.
+
+  exit-latency-us:
+    description:
+      Worst case latency in microseconds required to exit the idle state.
+      The exit-latency-us duration may be guaranteed only after
+      entry-latency-us has passed.
+
+  min-residency-us:
+    description:
+      Minimum residency duration in microseconds, inclusive of preparation
+      and entry, for this idle state to be considered worthwhile energy wise
+      (refer to section 2 of this document for a complete description).
+
+required:
+  - compatible
+  - entry-latency-us
+  - exit-latency-us
+  - min-residency-us
+
+additionalProperties: true
+
+examples:
+  - |
+
+    idle-state {
+      CPU_IDLE: cpu_idle {
+        compatible = "sunplus,sp7021-idle-state";
+        entry-latency-us = <8000>;
+        exit-latency-us = <700>;
+        min-residency-us = <9000>;
+      };
+    };
+
+...
MAINTAINERS +5 -0
index e0dca8f..22cfafe 100644
@@ -18252,6 +18252,11 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/dlink/sundance.c
 
+SUNPLUS CPUIDLE DRIVER
+M:	Edwin Chiu <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml
+
 SUPERH
 M:	Yoshinori Sato <[email protected]>
 M:	Rich Felker <[email protected]>
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v3 1/2] dt-bingings:arm:sunplus:add sp7021 compatible string to sunplus,idle-state.yaml

Quoted 66 lines · Edwin Chiu

Add the compatible string for cpuidle state on sp7021

---
Changes in v3
- Align email address of sob and sender
- Added sp7021 compatible string

 .../bindings/arm/sunplus/sunplus,idle-state.yaml   | 59 ++++++++++++++++++++++
 MAINTAINERS                                        |  5 ++
 2 files changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml
Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml new file +47 -0
new file mode 100644
index 0000000..64281ba
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) Sunplus Co., Ltd. 2021
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/sunplus/sunplus,idle-state.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SOC cpuidle state
+
+maintainers:
+  - Edwin Chiu<[email protected]>
+
+description: |
+  Sunplus SOC cpuidle state
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - sunplus,sp7021-idle-state
+
+  entry-latency-us:
+    description:
+      Worst case latency in microseconds required to enter the idle state.
+
+  exit-latency-us:
+    description:
+      Worst case latency in microseconds required to exit the idle state.
+      The exit-latency-us duration may be guaranteed only after
+      entry-latency-us has passed.
+
+  min-residency-us:
+    description:
+      Minimum residency duration in microseconds, inclusive of preparation
+      and entry, for this idle state to be considered worthwhile energy wise
+      (refer to section 2 of this document for a complete description).
+
+required:
+  - compatible
+  - entry-latency-us
+  - exit-latency-us
+  - min-residency-us
+
+additionalProperties: true
+
+examples:

Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml line 57

Quoted 10 lines
Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml new file +10 -0
+  - |
+
+    idle-state {
+      CPU_IDLE: cpu_idle {
+        compatible = "sunplus,sp7021-idle-state";
+        entry-latency-us = <8000>;
+        exit-latency-us = <700>;
+        min-residency-us = <9000>;
+      };
+    };

Again, this is no different than the generic binding. There is no need for this binding. Just wanting a different driver is not a reason for a duplicate schema.

Rob

author
#3 lore raw

PATCH v3 2/2 cpuidle:sunplus:create cpuidle driver for sunplus sp7021

In reply to Edwin Chiu

Create cpuidle driver for sunplus sp7021 chip

---
Changes in v3
- Rearrangement #include sequence
- Change remark style to /*~*/
- Align author email address to same as sob
- Optimal code

 MAINTAINERS                                   |   4 +
 drivers/cpuidle/Kconfig.arm                   |   7 ++
 drivers/cpuidle/Makefile                      |   1 +
 drivers/cpuidle/cpuidle-sunplus.c             | 167 ++++++++++++++++++++++++++
 include/linux/platform_data/cpuidle-sunplus.h |  19 +++
 5 files changed, 198 insertions(+)
 create mode 100644 drivers/cpuidle/cpuidle-sunplus.c
 create mode 100644 include/linux/platform_data/cpuidle-sunplus.h
MAINTAINERS +4 -0
index 22cfafe..4fb5e5c 100644
@@ -18256,6 +18256,10 @@ SUNPLUS CPUIDLE DRIVER
 M:	Edwin Chiu <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/arm/sunplus/sunplus,idle-state.yaml
+F:	drivers/cpuidle/Kconfig.arm
+F:	drivers/cpuidle/Makefile
+F:	drivers/cpuidle/cpuidle-sunplus.c
+F:	include/linux/platform_data/cpuidle-sunplus.h
 
 SUPERH
 M:	Yoshinori Sato <[email protected]>
drivers/cpuidle/Kconfig.arm +7 -0
index 15d6c46..fd921c5 100644
@@ -118,3 +118,10 @@ config ARM_QCOM_SPM_CPUIDLE
 	  The Subsystem Power Manager (SPM) controls low power modes for the
 	  CPU and L2 cores. It interface with various system drivers to put
 	  the cores in low power modes.
+
+config ARM_SUNPLUS_CPUIDLE
+	bool "CPU Idle Driver For SUNPLUS SoCs"
+	depends on !ARM64
+	select DT_IDLE_STATES
+	help
+	  Select this to enable cpuidle on SP7021 processors.
drivers/cpuidle/Makefile +1 -0
index 26bbc5e..0a020d1 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_ARM_PSCI_CPUIDLE)		+= cpuidle-psci.o
 obj-$(CONFIG_ARM_PSCI_CPUIDLE_DOMAIN)	+= cpuidle-psci-domain.o
 obj-$(CONFIG_ARM_TEGRA_CPUIDLE)		+= cpuidle-tegra.o
 obj-$(CONFIG_ARM_QCOM_SPM_CPUIDLE)	+= cpuidle-qcom-spm.o
+obj-$(CONFIG_ARM_SUNPLUS_CPUIDLE)		+= cpuidle-sunplus.o
 
 ###############################################################################
 # MIPS drivers
drivers/cpuidle/cpuidle-sunplus.c new file +167 -0

167 lines not on this page · raw message

include/linux/platform_data/cpuidle-sunplus.h new file +19 -0
new file mode 100644
index 0000000..bf87682
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __CPUIDLE_SP7021_H
+#define __CPUIDLE_SP7021_H
+
+struct cpuidle_sp7021_data {
+	int (*cpu23_powerdown)(void);
+	void (*pre_enter_aftr)(void);
+	void (*post_enter_aftr)(void);
+};
+
+extern int cpu_v7_do_idle(void);
+
+#endif
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v3 2/2] cpuidle:sunplus:create cpuidle driver for sunplus sp7021

I love your patch! Yet something to improve:

Hi Edwin,

I love your patch! Yet something to improve:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on robh/for-next linux/master linus/master v5.16-rc8] [cannot apply to next-20220106]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Edwin-Chiu/Add-cpuidle-driver-for-Sunplus-SP7021/20220106-100119
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: arm-randconfig-r002-20220106 (https://download.01.org/0day-ci/archive/20220107/202201070605.hejuN38H-lkp(a)intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7757275d128603b3d14e37735ba6f88396fd139c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Edwin-Chiu/Add-cpuidle-driver-for-Sunplus-SP7021/20220106-100119 git checkout 7757275d128603b3d14e37735ba6f88396fd139c
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

arm-linux-gnueabi-ld: drivers/cpuidle/cpuidle-sunplus.o: in function `sp7021_wfi_finisher':

>> cpuidle-sunplus.c:(.text+0x6): undefined reference to `cpu_v7_do_idle'
   arm-linux-gnueabi-ld: drivers/cpuidle/cpuidle-sunplus.o: in function `sp7021_enter_idle_state':
>> cpuidle-sunplus.c:(.text+0x4c): undefined reference to `cpu_suspend'
>> arm-linux-gnueabi-ld: cpuidle-sunplus.c:(.text+0x72): undefined reference to `cpu_v7_do_idle'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org