Skip to contentSkip to conversation

Add Sunplus SP7021 SoC Support

PATCH Superseded Qin Jian 4 participants 29 messages Mar 31, 2022 – Apr 2, 2022

Subsystems (7)

v12 of 20 Superseded Latest is v20 →

lore
Share & tools
lore

Qin Jian

author maintainer
#0 lore raw

v12 cover Add Sunplus SP7021 SoC Support

This patch series add Sunplus SP7021 SoC support.

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.

SP7021 consists of two chips (dies) in a package. One is called C-chip (computing chip). It is a 4-core ARM Cortex A7 CPU. It adopts high-level process (22 nm) for high performance computing. The other is called P- chip (peripheral chip). It has many peripherals and an ARM A926 added especially for real-time control. P-chip is made for customers. It adopts low-level process (ex: 0.11 um) to reduce cost.

Refer to (for documentations):
https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview

Refer to (applications):
https://tibbo.com/store/plus1.html

Refer to (applications):
http://www.sinovoip.com.cn/ecp_view.asp?id=586

Changes in v12:
- sunplus,sp7021-clkc.yaml: Move 'reg' after 'compatible'
- sunplus,sp7021-intc.yaml: Move 'reg' after 'compatible'
- sunplus,reset.yaml: Move 'reg' after 'compatible'
- Remove wrong reviewed-tags

Changes in v11:
- clk-sp7021.c: Remove the dead code

Changes in v10:
- arm/sunplus,sp7021.yaml: Add SoC compatible: "sunplus,sp7021"
- clock/sunplus,sp7021-clkc.yaml: Remove the internal clock parent from DTS
- clk-sp7021.c: Refine the macro DBG_CLK
- clk-sp7021.c: Refine the clock_parent_data

Changes in v9:
- clk/Kconfig: fix the comments form Stephen Boyd
- clk-sp7021.c: fix the comments form Stephen Boyd

Changes in v8:
- clk-sp7021.c: fix the comments form Stephen Boyd

Changes in v7:
- sunplus,sp7021-clkc.yaml: Add clocks & clock-names
- clk-sp7021.c: fix the comments form Stephen Boyd
- irq-sp7021-intc.c: fix the comments from Marc

Changes in v6:
- reset-sunplus.c: fix the comments from Philipp
- irq-sp7021-intc.c: fix the comments from Marc
- mach-sunplus: fix the comments from Arnd

Changes in v5:
- reset-sunplus.c: fix strict checks
- clk/Kconfig: fix spell
- clk-sp7021.c: using bitfield ops, fix strict checks
- irqchip/Kconfig: fix spell
- irq-sp7021-intc.c: cleanup error path in probe, fix strict checks
- arm/Kconfig: fix spell & typo, remove CONFIG_SERIAL_SUNPLUS
- mach-sunplus/Kconfig: fix typo
- sp7021_defconfig: add CONFIG_SERIAL_SUNPLUS

Changes in v4:
- mach-sunplus: add initial support for SP7021
- sp7021_defconfig: add generic SP7021 defconfig
- reset-sunplus: remove Q645 support
- reset-sunplus.c: refine code based on Philipp's review
- clk-sp7021: clock defines add prefix, more clean up

Changes in v3:
- sp7021-intc: remove primary controller mode due to P-chip running Linux not supported any more.
- sp7021-intc.h: removed, not set ext through the DT but sp_intc_set_ext()
- sunplus,sp7021-intc.yaml: update descriptions for above changes
- irq-sp7021-intc.c: more cleanup based on Marc's review
- all driver's Kconfig removed default, it's selected by platform config

Changes in v2:
- sunplus,sp7021-intc.yaml: add descrption for "#interrupt-cells", interrupts
- sunplus,sp7021-intc.yaml: drop "ext0-mask"/"ext1-mask" from DT
- sunplus,sp7021-intc.yaml: fix example.dt too long error
- irq-sp7021-intc.c: major rewrite
- all files with dual license

Qin Jian (9):
dt-bindings: arm: sunplus: Add bindings for Sunplus SP7021 SoC boards
dt-bindings: reset: Add bindings for SP7021 reset driver
reset: Add Sunplus SP7021 reset driver
dt-bindings: clock: Add bindings for SP7021 clock driver
clk: Add Sunplus SP7021 clock driver
dt-bindings: interrupt-controller: Add bindings for SP7021 interrupt
controller
irqchip: Add Sunplus SP7021 interrupt controller driver
ARM: sunplus: Add initial support for Sunplus SP7021 SoC
ARM: sp7021_defconfig: Add Sunplus SP7021 defconfig

 .../bindings/arm/sunplus,sp7021.yaml          |  28 +
 .../bindings/clock/sunplus,sp7021-clkc.yaml   |  39 +
 .../sunplus,sp7021-intc.yaml                  |  62 ++
 .../bindings/reset/sunplus,reset.yaml         |  38 +
 MAINTAINERS                                   |  17 +
 arch/arm/Kconfig                              |   2 +
 arch/arm/Makefile                             |   1 +
 arch/arm/configs/multi_v7_defconfig           |   1 +
 arch/arm/configs/sp7021_defconfig             |  61 ++
 arch/arm/mach-sunplus/Kconfig                 |  26 +
 arch/arm/mach-sunplus/Makefile                |   9 +
 arch/arm/mach-sunplus/sp7021.c                |  16 +
 drivers/clk/Kconfig                           |  10 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/clk-sp7021.c                      | 736 ++++++++++++++++++
 drivers/irqchip/Kconfig                       |   9 +
 drivers/irqchip/Makefile                      |   2 +
 drivers/irqchip/irq-sp7021-intc.c             | 288 +++++++
 drivers/reset/Kconfig                         |   9 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-sunplus.c                 | 130 ++++
 include/dt-bindings/clock/sp-sp7021.h         | 112 +++
 include/dt-bindings/reset/sp-sp7021.h         |  97 +++
 23 files changed, 1695 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
 create mode 100644 Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
 create mode 100644 Documentation/devicetree/bindings/reset/sunplus,reset.yaml
 create mode 100644 arch/arm/configs/sp7021_defconfig
 create mode 100644 arch/arm/mach-sunplus/Kconfig
 create mode 100644 arch/arm/mach-sunplus/Makefile
 create mode 100644 arch/arm/mach-sunplus/sp7021.c
 create mode 100644 drivers/clk/clk-sp7021.c
 create mode 100644 drivers/irqchip/irq-sp7021-intc.c
 create mode 100644 drivers/reset/reset-sunplus.c
 create mode 100644 include/dt-bindings/clock/sp-sp7021.h
 create mode 100644 include/dt-bindings/reset/sp-sp7021.h
Signature · 1 line
2.33.1
author maintainer
#1 lore raw

PATCH v12 1/9 dt-bindings: arm: sunplus: Add bindings for Sunplus SP7021 SoC boards

This introduces bindings for boards based Sunplus SP7021 SoC.

---
 .../bindings/arm/sunplus,sp7021.yaml          | 28 +++++++++++++++++++
 MAINTAINERS                                   |  7 +++++
 2 files changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml new file +28 -0
new file mode 100644
index 000000000..ef48fb270
@@ -0,0 +1,28 @@
+# 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,sp7021.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SP7021 Boards Device Tree Bindings
+
+maintainers:
+  - qinjian <[email protected]>
+
+description: |
+  ARM platforms using Sunplus SP7021, an ARM Cortex A7 (4-cores) based SoC.
+  Wiki: https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
+
+properties:
+  $nodename:
+    const: '/'
+  compatible:
+    items:
+      - enum:
+          - sunplus,sp7021-achip
+      - const: sunplus,sp7021
+
+additionalProperties: true
+
+...
MAINTAINERS +7 -0
index cd0f68d4a..8b5e2e639 100644
@@ -2738,6 +2738,13 @@ F:	drivers/clocksource/armv7m_systick.c
 N:	stm32
 N:	stm
 
+ARM/SUNPLUS SP7021 SOC SUPPORT
+M:	Qin Jian <[email protected]>
+L:	[email protected] (moderated for mon-subscribers)
+S:	Maintained
+W:	https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
+F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
+
 ARM/Synaptics SoC support
 M:	Jisheng Zhang <[email protected]>
 M:	Sebastian Hesselbarth <[email protected]>
Signature · 1 line
2.33.1
author maintainer
#2 lore raw

PATCH v12 2/9 dt-bindings: reset: Add bindings for SP7021 reset driver

In reply to Qin Jian

Add documentation to describe Sunplus SP7021 reset driver bindings.

---
Move "reg' after 'compatible'

---
 .../bindings/reset/sunplus,reset.yaml         | 38 ++++++++
 MAINTAINERS                                   |  2 +
 include/dt-bindings/reset/sp-sp7021.h         | 97 +++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/sunplus,reset.yaml
 create mode 100644 include/dt-bindings/reset/sp-sp7021.h
Documentation/devicetree/bindings/reset/sunplus,reset.yaml new file +38 -0
new file mode 100644
index 000000000..f24646ba9
@@ -0,0 +1,38 @@
+# 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/reset/sunplus,reset.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Sunplus SoC Reset Controller
+
+maintainers:
+  - Qin Jian <[email protected]>
+
+properties:
+  compatible:
+    const: sunplus,sp7021-reset
+
+  reg:
+    maxItems: 1
+
+  "#reset-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    rstc: reset@9c000054 {
+      compatible = "sunplus,sp7021-reset";
+      reg = <0x9c000054 0x28>;
+      #reset-cells = <1>;
+    };
+
+...
MAINTAINERS +2 -0
index 8b5e2e639..a8be86b25 100644
@@ -2744,6 +2744,8 @@ L:	[email protected] (moderated for mon-subscribers)
 S:	Maintained
 W:	https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
 F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
+F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
+F:	include/dt-bindings/reset/sp-sp7021.h
 
 ARM/Synaptics SoC support
 M:	Jisheng Zhang <[email protected]>
include/dt-bindings/reset/sp-sp7021.h new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
2.33.1
#3 lore raw

Re: [PATCH v12 2/9] dt-bindings: reset: Add bindings for SP7021 reset driver

Quoted 12 lines · Qin Jian
include/dt-bindings/reset/sp-sp7021.h new file +12 -0
+/* mo_reset0 ~ mo_reset9 */
+#define RST_SYSTEM             0x00
+#define RST_RTC                        0x02
+#define RST_IOCTL              0x03
+#define RST_IOP                        0x04
+#define RST_OTPRX              0x05
+#define RST_NOC                        0x06
+#define RST_BR                 0x07
+#define RST_RBUS_L00           0x08
+#define RST_SPIFL              0x09
+#define RST_SDCTRL0            0x0a
+#define RST_PERI0              0x0b

include/dt-bindings/reset/sp-sp7021.h line 30

Quoted 10 lines
include/dt-bindings/reset/sp-sp7021.h new file +10 -0
+#define RST_A926               0x0d
+#define RST_UMCTL2             0x0e
+#define RST_PERI1              0x0f
+
+#define RST_DDR_PHY0           0x10
+#define RST_ACHIP              0x12
+#define RST_STC0               0x14
+#define RST_STC_AV0            0x15
+#define RST_STC_AV1            0x16
+#define RST_STC_AV2            0x17

The list looks like these definitions just match the hardware, which means you don't have to define them as a binding at all, just use the hardware numbers directly in the dt, as you do for interrupts or gpio numbers.

If the hardware does not have a sane way of mapping reset lines to a particular hardware number, then you may have to define a binding, but in that case just use consecutive integer numbers, not hexadecimal numbers.

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#4 lore raw

RE: [PATCH v12 2/9] dt-bindings: reset: Add bindings for SP7021 reset driver

Quoted 30 lines · Qin Jian
Quoted 13 lines
include/dt-bindings/reset/sp-sp7021.h new file +12 -0
+/* mo_reset0 ~ mo_reset9 */
+#define RST_SYSTEM             0x00
+#define RST_RTC                        0x02
+#define RST_IOCTL              0x03
+#define RST_IOP                        0x04
+#define RST_OTPRX              0x05
+#define RST_NOC                        0x06
+#define RST_BR                 0x07
+#define RST_RBUS_L00           0x08
+#define RST_SPIFL              0x09
+#define RST_SDCTRL0            0x0a
+#define RST_PERI0              0x0b

include/dt-bindings/reset/sp-sp7021.h line 30

Quoted 10 lines
include/dt-bindings/reset/sp-sp7021.h new file +10 -0
+#define RST_A926               0x0d
+#define RST_UMCTL2             0x0e
+#define RST_PERI1              0x0f
+
+#define RST_DDR_PHY0           0x10
+#define RST_ACHIP              0x12
+#define RST_STC0               0x14
+#define RST_STC_AV0            0x15
+#define RST_STC_AV1            0x16
+#define RST_STC_AV2            0x17

The list looks like these definitions just match the hardware, which means you don't have to define them as a binding at all, just use the hardware numbers directly in the dt, as you do for interrupts or gpio numbers.

Quoted 5 lines

If the hardware does not have a sane way of mapping reset lines to a particular hardware number, then you may have to define a binding, but in that case just use consecutive integer numbers, not hexadecimal numbers.

Arnd

You are right, these definitions does match the hardware, In reset-sunplus.c:
static int sp_reset_status(struct reset_controller_dev *rcdev,
unsigned long id)

{
        struct sp_reset *reset = to_sp_reset(rcdev);
        int index = id / BITS_PER_HWM_REG;
        int shift = id % BITS_PER_HWM_REG;
        u32 reg;

        reg = readl(reset->base + (index * 4));

        return !!(reg & BIT(shift));
}

the 'id' is these value passed from dt.

I'll remove this file & update dt, thanks for your comments.

author maintainer
#5 lore raw

PATCH v12 3/9 reset: Add Sunplus SP7021 reset driver

In reply to Qin Jian

Add reset driver for Sunplus SP7021 SoC.

---
 MAINTAINERS                   |   1 +
 drivers/reset/Kconfig         |   9 +++
 drivers/reset/Makefile        |   1 +
 drivers/reset/reset-sunplus.c | 130 ++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+)
 create mode 100644 drivers/reset/reset-sunplus.c
MAINTAINERS +1 -0
index a8be86b25..26066f199 100644
@@ -2745,6 +2745,7 @@ S:	Maintained
 W:	https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
 F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
+F:	drivers/reset/reset-sunplus.c
 F:	include/dt-bindings/reset/sp-sp7021.h
 
 ARM/Synaptics SoC support
drivers/reset/Kconfig +9 -0
index 6f8ba0ddc..36825787e 100644
@@ -231,6 +231,15 @@ config RESET_STARFIVE_JH7100
 	help
 	  This enables the reset controller driver for the StarFive JH7100 SoC.
 
+config RESET_SUNPLUS
+	bool "Sunplus SoCs Reset Driver" if COMPILE_TEST
+	default ARCH_SUNPLUS
+	help
+	  This enables the reset driver support for Sunplus SoCs.
+	  The reset lines that can be asserted and deasserted by toggling bits
+	  in a contiguous, exclusive register space. The register is HIWORD_MASKED,
+	  which means each register hold 16 reset lines.
+
 config RESET_SUNXI
 	bool "Allwinner SoCs Reset Driver" if COMPILE_TEST && !ARCH_SUNXI
 	default ARCH_SUNXI
drivers/reset/Makefile +1 -0
index bd0a97be1..cadc46d3e 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
 obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o
+obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o
 obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
 obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o
 obj-$(CONFIG_RESET_TI_SYSCON) += reset-ti-syscon.o
drivers/reset/reset-sunplus.c new file +130 -0

130 lines not on this page · raw message

Signature · 1 line
2.33.1
#6 lore raw

Re: [PATCH v12 3/9] reset: Add Sunplus SP7021 reset driver

drivers/reset/reset-sunplus.c line 15

Quoted 8 lines · Qin Jian
drivers/reset/reset-sunplus.c new file +8 -0
+
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+#include <linux/reboot.h>
+

As commented on the binding header -- it looks again like you are not actually relying on the header here, so it's almost certainly not needed.

Arnd

author maintainer
#7 lore raw

PATCH v12 4/9 dt-bindings: clock: Add bindings for SP7021 clock driver

In reply to Qin Jian

Add documentation to describe Sunplus SP7021 clock driver bindings.

---
Move 'reg' after 'compatible'

---
 .../bindings/clock/sunplus,sp7021-clkc.yaml   |  39 ++++++
 MAINTAINERS                                   |   2 +
 include/dt-bindings/clock/sp-sp7021.h         | 112 ++++++++++++++++++
 3 files changed, 153 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 create mode 100644 include/dt-bindings/clock/sp-sp7021.h
Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml new file +39 -0
new file mode 100644
index 000000000..41e73a088
@@ -0,0 +1,39 @@
+# 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/clock/sunplus,sp7021-clkc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SP7021 SoC Clock Controller Binding
+
+maintainers:
+  - Qin Jian <[email protected]>
+
+properties:
+  compatible:
+    const: sunplus,sp7021-clkc
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+
+    clkc: clock-controller@9c000000 {
+      compatible = "sunplus,sp7021-clkc";
+      reg = <0x9c000000 0x280>;
+      #clock-cells = <1>;
+    };
+
+...
MAINTAINERS +2 -0
index 26066f199..5d8b420d0 100644
@@ -2744,8 +2744,10 @@ L:	[email protected] (moderated for mon-subscribers)
 S:	Maintained
 W:	https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
 F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
+F:	Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
 F:	drivers/reset/reset-sunplus.c
+F:	include/dt-bindings/clock/sp-sp7021.h
 F:	include/dt-bindings/reset/sp-sp7021.h
 
 ARM/Synaptics SoC support
include/dt-bindings/clock/sp-sp7021.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
2.33.1
#8 lore raw

Re: [PATCH v12 4/9] dt-bindings: clock: Add bindings for SP7021 clock driver

Quoted 93 lines · Qin Jian

Add documentation to describe Sunplus SP7021 clock driver bindings.

---
Move 'reg' after 'compatible'

---
 .../bindings/clock/sunplus,sp7021-clkc.yaml   |  39 ++++++
 MAINTAINERS                                   |   2 +
 include/dt-bindings/clock/sp-sp7021.h         | 112 ++++++++++++++++++
 3 files changed, 153 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 create mode 100644 include/dt-bindings/clock/sp-sp7021.h
Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml new file +39 -0
new file mode 100644
index 000000000..41e73a088
@@ -0,0 +1,39 @@
+# 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/clock/sunplus,sp7021-clkc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SP7021 SoC Clock Controller Binding
+
+maintainers:
+  - Qin Jian <[email protected]>
+
+properties:
+  compatible:
+    const: sunplus,sp7021-clkc
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+
+    clkc: clock-controller@9c000000 {
+      compatible = "sunplus,sp7021-clkc";
+      reg = <0x9c000000 0x280>;
+      #clock-cells = <1>;
+    };
+
+...
MAINTAINERS +2 -0
index 26066f199..5d8b420d0 100644
@@ -2744,8 +2744,10 @@ L:	[email protected] (moderated for mon-subscribers)
 S:	Maintained
 W:	https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
 F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
+F:	Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
 F:	drivers/reset/reset-sunplus.c
+F:	include/dt-bindings/clock/sp-sp7021.h
 F:	include/dt-bindings/reset/sp-sp7021.h
 
 ARM/Synaptics SoC support
include/dt-bindings/clock/sp-sp7021.h new file +14 -0
new file mode 100644
index 000000000..45dac6de8
@@ -0,0 +1,112 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) Sunplus Technology Co., Ltd.
+ *       All rights reserved.
+ */
+#ifndef _DT_BINDINGS_CLOCK_SUNPLUS_SP7021_H
+#define _DT_BINDINGS_CLOCK_SUNPLUS_SP7021_H
+
+#define XTAL			27000000
+
+/* plls */
+#define PLL_A			0
+#define PLL_E			1
+#define PLL_E_2P5		2

include/dt-bindings/clock/sp-sp7021.h line 24

Quoted 10 lines
include/dt-bindings/clock/sp-sp7021.h new file +10 -0
+#define PLL_E_25		3
+#define PLL_E_112P5		4
+#define PLL_F			5
+#define PLL_TV			6
+#define PLL_TV_A		7
+#define PLL_SYS			8
+
+/* gates: mo_clken0 ~ mo_clken9 */
+#define CLK_SYSTEM		0x10
+#define CLK_RTC			0x12

YAML looks ok, but here comment from Arnd also applies. These should be regular decimal numbers incremented by one.

Best regards,
Krzysztof

author maintainer
#9 lore raw

RE: [PATCH v12 4/9] dt-bindings: clock: Add bindings for SP7021 clock driver

Quoted 34 lines
Quoted 20 lines
include/dt-bindings/clock/sp-sp7021.h new file +14 -0
new file mode 100644
index 000000000..45dac6de8
@@ -0,0 +1,112 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) Sunplus Technology Co., Ltd.
+ *       All rights reserved.
+ */
+#ifndef _DT_BINDINGS_CLOCK_SUNPLUS_SP7021_H
+#define _DT_BINDINGS_CLOCK_SUNPLUS_SP7021_H
+
+#define XTAL			27000000
+
+/* plls */
+#define PLL_A			0
+#define PLL_E			1
+#define PLL_E_2P5		2

include/dt-bindings/clock/sp-sp7021.h line 24

Quoted 10 lines
include/dt-bindings/clock/sp-sp7021.h new file +10 -0
+#define PLL_E_25		3
+#define PLL_E_112P5		4
+#define PLL_F			5
+#define PLL_TV			6
+#define PLL_TV_A		7
+#define PLL_SYS			8
+
+/* gates: mo_clken0 ~ mo_clken9 */
+#define CLK_SYSTEM		0x10
+#define CLK_RTC			0x12

YAML looks ok, but here comment from Arnd also applies. These should be regular decimal numbers incremented by one.

Quoted 2 lines

Best regards,
Krzysztof

Yes, same as reset driver, these defines also mapping the hardware.
But different from reset driver, clk driver also used these defines.
If I removed this defines, I must write the proper hardware number twice in dt & driver. It's meaningless & hard to check.

#10 lore raw

Re: [PATCH v12 4/9] dt-bindings: clock: Add bindings for SP7021 clock driver

Quoted 34 lines · qinjian[覃健]
Quoted 34 lines
Quoted 20 lines
include/dt-bindings/clock/sp-sp7021.h new file +14 -0
new file mode 100644
index 000000000..45dac6de8
@@ -0,0 +1,112 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) Sunplus Technology Co., Ltd.
+ *       All rights reserved.
+ */
+#ifndef _DT_BINDINGS_CLOCK_SUNPLUS_SP7021_H
+#define _DT_BINDINGS_CLOCK_SUNPLUS_SP7021_H
+
+#define XTAL			27000000
+
+/* plls */
+#define PLL_A			0
+#define PLL_E			1
+#define PLL_E_2P5		2

include/dt-bindings/clock/sp-sp7021.h line 24

Quoted 10 lines
include/dt-bindings/clock/sp-sp7021.h new file +10 -0
+#define PLL_E_25		3
+#define PLL_E_112P5		4
+#define PLL_F			5
+#define PLL_TV			6
+#define PLL_TV_A		7
+#define PLL_SYS			8
+
+/* gates: mo_clken0 ~ mo_clken9 */
+#define CLK_SYSTEM		0x10
+#define CLK_RTC			0x12

YAML looks ok, but here comment from Arnd also applies. These should be regular decimal numbers incremented by one.

Quoted 7 lines
Quoted 2 lines

Best regards,
Krzysztof

Yes, same as reset driver, these defines also mapping the hardware.
But different from reset driver, clk driver also used these defines.
If I removed this defines, I must write the proper hardware number twice in dt & driver. It's meaningless & hard to check.

Not really... just follow what most (or all) clock drivers are doing - incremental IDs.

Best regards,
Krzysztof

author maintainer
#11 lore raw

PATCH v12 5/9 clk: Add Sunplus SP7021 clock driver

In reply to Qin Jian

Add clock driver for Sunplus SP7021 SoC.

---
 MAINTAINERS              |   1 +
 drivers/clk/Kconfig      |  10 +
 drivers/clk/Makefile     |   1 +
 drivers/clk/clk-sp7021.c | 736 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 748 insertions(+)
 create mode 100644 drivers/clk/clk-sp7021.c
MAINTAINERS +1 -0
index 5d8b420d0..8b77f7ae4 100644
@@ -2746,6 +2746,7 @@ W:	https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
 F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
 F:	Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
+F:	drivers/clk/clk-sp7021.c
 F:	drivers/reset/reset-sunplus.c
 F:	include/dt-bindings/clock/sp-sp7021.h
 F:	include/dt-bindings/reset/sp-sp7021.h
drivers/clk/Kconfig +10 -0
index d4d67fbae..9eedeea78 100644
@@ -351,6 +351,16 @@ config COMMON_CLK_VC5
 	  This driver supports the IDT VersaClock 5 and VersaClock 6
 	  programmable clock generators.
 
+config COMMON_CLK_SP7021
+	bool "Clock driver for Sunplus SP7021 SoC"
+	depends on SOC_SP7021 || COMPILE_TEST
+	default SOC_SP7021
+	help
+	  This driver supports the Sunplus SP7021 SoC clocks.
+	  It implements SP7021 PLLs/gate.
+	  Not all features of the PLL are currently supported
+	  by the driver.
+
 config COMMON_CLK_STM32MP157
 	def_bool COMMON_CLK && MACH_STM32MP157
 	help
drivers/clk/Makefile +1 -0
index 16e588630..377ea7f7b 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_COMMON_CLK_SI5351)		+= clk-si5351.o
 obj-$(CONFIG_COMMON_CLK_SI514)		+= clk-si514.o
 obj-$(CONFIG_COMMON_CLK_SI544)		+= clk-si544.o
 obj-$(CONFIG_COMMON_CLK_SI570)		+= clk-si570.o
+obj-$(CONFIG_COMMON_CLK_SP7021)		+= clk-sp7021.o
 obj-$(CONFIG_COMMON_CLK_STM32F)		+= clk-stm32f4.o
 obj-$(CONFIG_COMMON_CLK_STM32H7)	+= clk-stm32h7.o
 obj-$(CONFIG_COMMON_CLK_STM32MP157)	+= clk-stm32mp1.o
drivers/clk/clk-sp7021.c new file +736 -0

736 lines not on this page · raw message

Signature · 1 line
2.33.1
#12 lore raw

Re: [PATCH v12 5/9] clk: Add Sunplus SP7021 clock driver

Quoted 11 lines · Qin Jian
drivers/clk/clk-sp7021.c new file +11 -0
+static int sp_pll_enable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       unsigned long flags;
+
+       spin_lock_irqsave(clk->lock, flags);
+       writel(BIT(clk->pd_bit + 16) | BIT(clk->pd_bit), clk->reg); /* power up */
+       spin_unlock_irqrestore(clk->lock, flags);
+
+       return 0;
+}

drivers/clk/clk-sp7021.c line 539

Quoted 10 lines
drivers/clk/clk-sp7021.c new file +10 -0
+
+static void sp_pll_disable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       unsigned long flags;
+
+       spin_lock_irqsave(clk->lock, flags);
+       writel(BIT(clk->pd_bit + 16), clk->reg); /* power down */
+       spin_unlock_irqrestore(clk->lock, flags);
+}

What does the spinlock actually protect here? As writel() is posted, it can already leak of of the lock, and the inputs would appear to be constant.

drivers/clk/clk-sp7021.c line 633

Quoted 8 lines
drivers/clk/clk-sp7021.c new file +8 -0
+       /* This memory region include multi HW regs in discontinuous order.
+        * clk driver used some discontinuous areas in the memory region.
+        * Using devm_platform_ioremap_resource() would conflicted with other drivers.
+        */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       sp_clk_base = devm_ioremap(dev, res->start, resource_size(res));
+       if (!sp_clk_base)
+               return -ENXIO;

Can you explain this comment in more detail? Generally, the 'reg' properties of drivers should not overlap, so it is supposed to be safe to call devm_platform_ioremap_resource() here.

We discussed this in the context of the iop driver that did have overlapping registers with this driver, and that was incorrect. Are there any other drivers that conflict with the clk driver?

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#13 lore raw

RE: [PATCH v12 5/9] clk: Add Sunplus SP7021 clock driver

Quoted 18 lines
Quoted 18 lines
drivers/clk/clk-sp7021.c new file +17 -0
+static int sp_pll_enable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       unsigned long flags;
+
+       spin_lock_irqsave(clk->lock, flags);
+       writel(BIT(clk->pd_bit + 16) | BIT(clk->pd_bit), clk->reg); /* power up */
+       spin_unlock_irqrestore(clk->lock, flags);
+
+       return 0;
+}
+
+static void sp_pll_disable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       unsigned long flags;
+
Quoted 9 lines

drivers/clk/clk-sp7021.c line 539

Quoted 4 lines
drivers/clk/clk-sp7021.c new file +4 -0
+       spin_lock_irqsave(clk->lock, flags);
+       writel(BIT(clk->pd_bit + 16), clk->reg); /* power down */
+       spin_unlock_irqrestore(clk->lock, flags);
+}

What does the spinlock actually protect here? As writel() is posted, it can already leak of of the lock, and the inputs would appear to be constant.

These code is refered from other clk driver.
But, other driver need read then write, so need lock protected.
Our HW is HIWORD_MASKED_REG, means modify bits no need to read, just 1 write only. So, the lock is useless.
Did I right?

Quoted 13 lines

drivers/clk/clk-sp7021.c line 633

Quoted 8 lines
drivers/clk/clk-sp7021.c new file +8 -0
+       /* This memory region include multi HW regs in discontinuous order.
+        * clk driver used some discontinuous areas in the memory region.
+        * Using devm_platform_ioremap_resource() would conflicted with other drivers.
+        */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       sp_clk_base = devm_ioremap(dev, res->start, resource_size(res));
+       if (!sp_clk_base)
+               return -ENXIO;

Can you explain this comment in more detail? Generally, the 'reg' properties of drivers should not overlap, so it is supposed to be safe to call devm_platform_ioremap_resource() here.

Quoted 5 lines

We discussed this in the context of the iop driver that did have overlapping registers with this driver, and that was incorrect. Are there any other drivers that conflict with the clk driver?

Arnd

I means, I must split up the origin reg region into 4 small pieces, and call devm_platform_ioremap_resource() 4 times.
Did I should follow this way?

#14 lore raw

Re: [PATCH v12 5/9] clk: Add Sunplus SP7021 clock driver

Quoted 27 lines · qinjian[覃健]
Quoted 17 lines
Quoted 17 lines
drivers/clk/clk-sp7021.c new file +17 -0
+static int sp_pll_enable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       unsigned long flags;
+
+       spin_lock_irqsave(clk->lock, flags);
+       writel(BIT(clk->pd_bit + 16) | BIT(clk->pd_bit), clk->reg); /* power up */
+       spin_unlock_irqrestore(clk->lock, flags);
+
+       return 0;
+}
+
+static void sp_pll_disable(struct clk_hw *hw)
+{
+       struct sp_pll *clk = to_sp_pll(hw);
+       unsigned long flags;
+
Quoted 9 lines

drivers/clk/clk-sp7021.c line 539

Quoted 4 lines
drivers/clk/clk-sp7021.c new file +4 -0
+       spin_lock_irqsave(clk->lock, flags);
+       writel(BIT(clk->pd_bit + 16), clk->reg); /* power down */
+       spin_unlock_irqrestore(clk->lock, flags);
+}

What does the spinlock actually protect here? As writel() is posted, it can already leak of of the lock, and the inputs would appear to be constant.

Quoted 5 lines

These code is refered from other clk driver.
But, other driver need read then write, so need lock protected.
Our HW is HIWORD_MASKED_REG, means modify bits no need to read, just 1 write only. So, the lock is useless.
Did I right?

If the read-modify-write is done on a different register, then it is fine to remove
the lock. You can also consider having shadow registers to avoid expensive r-m-w cycles and just always write the register directly.

Quoted 13 lines
Quoted 13 lines

drivers/clk/clk-sp7021.c line 633

Quoted 8 lines
drivers/clk/clk-sp7021.c new file +8 -0
+       /* This memory region include multi HW regs in discontinuous order.
+        * clk driver used some discontinuous areas in the memory region.
+        * Using devm_platform_ioremap_resource() would conflicted with other drivers.
+        */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       sp_clk_base = devm_ioremap(dev, res->start, resource_size(res));
+       if (!sp_clk_base)
+               return -ENXIO;

Can you explain this comment in more detail? Generally, the 'reg' properties of drivers should not overlap, so it is supposed to be safe to call devm_platform_ioremap_resource() here.

Quoted 7 lines
Quoted 3 lines

We discussed this in the context of the iop driver that did have overlapping registers with this driver, and that was incorrect. Are there any other drivers that conflict with the clk driver?

I means, I must split up the origin reg region into 4 small pieces, and call devm_platform_ioremap_resource() 4 times.
Did I should follow this way?

It depends. What are those other registers, and what drivers use them?

Arnd

author maintainer
#15 lore raw

RE: [PATCH v12 5/9] clk: Add Sunplus SP7021 clock driver

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines

drivers/clk/clk-sp7021.c line 633

Quoted 9 lines
drivers/clk/clk-sp7021.c new file +8 -0
+       /* This memory region include multi HW regs in discontinuous order.
+        * clk driver used some discontinuous areas in the memory region.
+        * Using devm_platform_ioremap_resource() would conflicted with other drivers.
+        */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       sp_clk_base = devm_ioremap(dev, res->start, resource_size(res));
+       if (!sp_clk_base)
+               return -ENXIO;

Can you explain this comment in more detail? Generally, the 'reg' properties of drivers should not overlap, so it is supposed to be safe to call devm_platform_ioremap_resource() here.

We discussed this in the context of the iop driver that did have overlapping registers with this driver, and that was incorrect. Are there any other drivers that conflict with the clk driver?

Quoted 7 lines
Quoted 3 lines

I means, I must split up the origin reg region into 4 small pieces, and call devm_platform_ioremap_resource() 4 times.
Did I should follow this way?

It depends. What are those other registers, and what drivers use them?

Arnd

Include Reset / PinMux / USBC / UPHY regs, which used by related drivers.

author maintainer
#16 lore raw

PATCH v12 6/9 dt-bindings: interrupt-controller: Add bindings for SP7021 interrupt controller

In reply to Qin Jian

Add documentation to describe Sunplus SP7021 interrupt controller bindings.

---
Move 'reg' after 'compatible'

---
 .../sunplus,sp7021-intc.yaml                  | 62 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml new file +62 -0
new file mode 100644
index 000000000..f26d8b213
@@ -0,0 +1,62 @@
+# 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/interrupt-controller/sunplus,sp7021-intc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SP7021 SoC Interrupt Controller Device Tree Bindings
+
+maintainers:
+  - Qin Jian <[email protected]>
+
+properties:
+  compatible:
+    items:
+      - const: sunplus,sp7021-intc
+
+  reg:
+    maxItems: 2
+    description:
+      Specifies base physical address(s) and size of the controller regs.
+      The 1st region include type/polarity/priority/mask regs.
+      The 2nd region include clear/masked_ext0/masked_ext1/group regs.
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+    description:
+      The first cell is the IRQ number, the second cell is the trigger
+      type as defined in interrupt.txt in this directory.
+
+  interrupts:
+    maxItems: 2
+    description:
+      EXT_INT0 & EXT_INT1, 2 interrupts references to primary interrupt
+      controller.
+
+required:
+  - compatible
+  - reg
+  - interrupt-controller
+  - "#interrupt-cells"
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    intc: interrupt-controller@9c000780 {
+        compatible = "sunplus,sp7021-intc";
+        reg = <0x9c000780 0x80>, <0x9c000a80 0x80>;
+        interrupt-controller;
+        #interrupt-cells = <2>;
+        interrupt-parent = <&gic>;
+        interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>, /* EXT_INT0 */
+                     <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>; /* EXT_INT1 */
+    };
+
+...
MAINTAINERS +1 -0
index 8b77f7ae4..9fba67159 100644
@@ -2745,6 +2745,7 @@ S:	Maintained
 W:	https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
 F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
 F:	Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
+F:	Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
 F:	drivers/clk/clk-sp7021.c
 F:	drivers/reset/reset-sunplus.c
Signature · 1 line
2.33.1
maintainer
#17 lore raw

Re: [PATCH v12 6/9] dt-bindings: interrupt-controller: Add bindings for SP7021 interrupt controller

Quoted 11 lines · Qin Jian

Add documentation to describe Sunplus SP7021 interrupt controller bindings.

---
Move 'reg' after 'compatible'

---
 .../sunplus,sp7021-intc.yaml                  | 62 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

author maintainer
#18 lore raw

RE: [PATCH v12 6/9] dt-bindings: interrupt-controller: Add bindings for SP7021 interrupt controller

Quoted 15 lines · Qin Jian
Quoted 11 lines

Add documentation to describe Sunplus SP7021 interrupt controller bindings.

---
Move 'reg' after 'compatible'

---
 .../sunplus,sp7021-intc.yaml                  | 62 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
Quoted 5 lines

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

Changes: Move 'reg' after 'compatible'
I did a modification based on comments from [email protected] [1]

[1] https://lore.kernel.org/all/[email protected]/

maintainer
#19 lore raw

Re: [PATCH v12 6/9] dt-bindings: interrupt-controller: Add bindings for SP7021 interrupt controller

Quoted 19 lines · qinjian[覃健]
Quoted 19 lines · Qin Jian
Quoted 11 lines

Add documentation to describe Sunplus SP7021 interrupt controller bindings.

---
Move 'reg' after 'compatible'

---
 .../sunplus,sp7021-intc.yaml                  | 62 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

Quoted 6 lines
Quoted 1 line

If a tag was not added on purpose, please state why and what changed.

Changes: Move 'reg' after 'compatible'
I did a modification based on comments from [email protected] [1]

[1] https://lore.kernel.org/all/[email protected]/

A trivial change like that can keep a tag especially if it came after the comment (not sure here).

Rob

author maintainer
#20 lore raw

RE: [PATCH v12 6/9] dt-bindings: interrupt-controller: Add bindings for SP7021 interrupt controller

Quoted 26 lines · qinjian[覃健]
Quoted 24 lines
Quoted 15 lines · Qin Jian
Quoted 11 lines

Add documentation to describe Sunplus SP7021 interrupt controller bindings.

---
Move 'reg' after 'compatible'

---
 .../sunplus,sp7021-intc.yaml                  | 62 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
Quoted 5 lines

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

Changes: Move 'reg' after 'compatible'
I did a modification based on comments from [email protected] [1]

Quoted 6 lines
Quoted 1 line

[1] https://lore.kernel.org/all/[email protected]/

A trivial change like that can keep a tag especially if it came after the comment (not sure here).

Rob

I'll add back the tag next version, thanks.

author maintainer
#21 lore raw

PATCH v12 7/9 irqchip: Add Sunplus SP7021 interrupt controller driver

In reply to Qin Jian

Add interrupt controller driver for Sunplus SP7021 SoC.

This is the interrupt controller in P-chip which collects all interrupt sources in P-chip and routes them to parent interrupt controller in C-chip.

---
 MAINTAINERS                       |   1 +
 drivers/irqchip/Kconfig           |   9 +
 drivers/irqchip/Makefile          |   2 +
 drivers/irqchip/irq-sp7021-intc.c | 288 ++++++++++++++++++++++++++++++
 4 files changed, 300 insertions(+)
 create mode 100644 drivers/irqchip/irq-sp7021-intc.c
MAINTAINERS +1 -0
index 9fba67159..cf6873295 100644
@@ -2748,6 +2748,7 @@ F:	Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 F:	Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
 F:	drivers/clk/clk-sp7021.c
+F:	drivers/irqchip/irq-sp7021-intc.c
 F:	drivers/reset/reset-sunplus.c
 F:	include/dt-bindings/clock/sp-sp7021.h
 F:	include/dt-bindings/reset/sp-sp7021.h
drivers/irqchip/Kconfig +9 -0
index 7038957f4..f5c2596bc 100644
@@ -617,4 +617,13 @@ config MCHP_EIC
 	help
 	  Support for Microchip External Interrupt Controller.
 
+config SUNPLUS_SP7021_INTC
+	bool "Sunplus SP7021 interrupt controller" if COMPILE_TEST
+	default SOC_SP7021
+	help
+	  Support for the Sunplus SP7021 Interrupt Controller IP core.
+	  SP7021 SoC has 2 Chips: C-Chip & P-Chip. This is used as a
+	  chained controller, routing all interrupt source in P-Chip to
+	  the primary controller on C-Chip.
+
 endmenu
drivers/irqchip/Makefile +2 -0
index c1f611cbf..eb0ac83ff 100644
@@ -117,3 +117,5 @@ obj-$(CONFIG_WPCM450_AIC)		+= irq-wpcm450-aic.o
 obj-$(CONFIG_IRQ_IDT3243X)		+= irq-idt3243x.o
 obj-$(CONFIG_APPLE_AIC)			+= irq-apple-aic.o
 obj-$(CONFIG_MCHP_EIC)			+= irq-mchp-eic.o
+obj-$(CONFIG_SUNPLUS_SP7021_INTC)	+= irq-sp7021-intc.o
+
drivers/irqchip/irq-sp7021-intc.c new file +288 -0

288 lines not on this page · raw message

Signature · 1 line
2.33.1
#22 lore raw

Re: [PATCH v12 7/9] irqchip: Add Sunplus SP7021 interrupt controller driver

Quoted 7 lines · Qin Jian
drivers/irqchip/irq-sp7021-intc.c new file +7 -0
+#ifdef CONFIG_SMP
+static int sp_intc_set_affinity(struct irq_data *d, const struct cpumask *mask, bool force)
+{
+       return -EINVAL;
+}
+#endif
+

drivers/irqchip/irq-sp7021-intc.c line 203

Quoted 10 lines
drivers/irqchip/irq-sp7021-intc.c new file +10 -0
+static struct irq_chip sp_intc_chip = {
+       .name = "sp_intc",
+       .irq_ack = sp_intc_ack_irq,
+       .irq_mask = sp_intc_mask_irq,
+       .irq_unmask = sp_intc_unmask_irq,
+       .irq_set_type = sp_intc_set_type,
+#ifdef CONFIG_SMP
+       .irq_set_affinity = sp_intc_set_affinity,
+#endif
+};

I don't think you need to define an irq_set_affinity() callback at all if you just return -EINVAL, all the callers should have a check already. Even if you do need the function, I think you can remove the #ifdef, as long as the function itself can be built that way.

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#23 lore raw

RE: [PATCH v12 7/9] irqchip: Add Sunplus SP7021 interrupt controller driver

Quoted 26 lines · Qin Jian
Quoted 8 lines
drivers/irqchip/irq-sp7021-intc.c new file +7 -0
+#ifdef CONFIG_SMP
+static int sp_intc_set_affinity(struct irq_data *d, const struct cpumask *mask, bool force)
+{
+       return -EINVAL;
+}
+#endif
+

drivers/irqchip/irq-sp7021-intc.c line 203

Quoted 10 lines
drivers/irqchip/irq-sp7021-intc.c new file +10 -0
+static struct irq_chip sp_intc_chip = {
+       .name = "sp_intc",
+       .irq_ack = sp_intc_ack_irq,
+       .irq_mask = sp_intc_mask_irq,
+       .irq_unmask = sp_intc_unmask_irq,
+       .irq_set_type = sp_intc_set_type,
+#ifdef CONFIG_SMP
+       .irq_set_affinity = sp_intc_set_affinity,
+#endif
+};

I don't think you need to define an irq_set_affinity() callback at all if you just return -EINVAL, all the callers should have a check already. Even if you do need the function, I think you can remove the #ifdef, as long as the function itself can be built that way.

Quoted 1 line

Arnd

Thanks for your comments, I'll remove this empty function.

author maintainer
#24 lore raw

PATCH v12 8/9 ARM: sunplus: Add initial support for Sunplus SP7021 SoC

In reply to Qin Jian

This patch aims to add an initial support for Sunplus SP7021 SoC.

---
 MAINTAINERS                    |  1 +
 arch/arm/Kconfig               |  2 ++
 arch/arm/Makefile              |  1 +
 arch/arm/mach-sunplus/Kconfig  | 26 ++++++++++++++++++++++++++
 arch/arm/mach-sunplus/Makefile |  9 +++++++++
 arch/arm/mach-sunplus/sp7021.c | 16 ++++++++++++++++
 6 files changed, 55 insertions(+)
 create mode 100644 arch/arm/mach-sunplus/Kconfig
 create mode 100644 arch/arm/mach-sunplus/Makefile
 create mode 100644 arch/arm/mach-sunplus/sp7021.c
MAINTAINERS +1 -0
index cf6873295..38890c055 100644
@@ -2747,6 +2747,7 @@ F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
 F:	Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 F:	Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
+F:	arch/arm/mach-sunplus/
 F:	drivers/clk/clk-sp7021.c
 F:	drivers/irqchip/irq-sp7021-intc.c
 F:	drivers/reset/reset-sunplus.c
arch/arm/Kconfig +2 -0
index 4c97cb40e..1ee9a27a3 100644
@@ -693,6 +693,8 @@ source "arch/arm/mach-sti/Kconfig"
 
 source "arch/arm/mach-stm32/Kconfig"
 
+source "arch/arm/mach-sunplus/Kconfig"
+
 source "arch/arm/mach-sunxi/Kconfig"
 
 source "arch/arm/mach-tegra/Kconfig"
arch/arm/Makefile +1 -0
index 77172d555..1e19d2f4b 100644
@@ -216,6 +216,7 @@ machine-$(CONFIG_ARCH_RENESAS)	 	+= shmobile
 machine-$(CONFIG_ARCH_INTEL_SOCFPGA)	+= socfpga
 machine-$(CONFIG_ARCH_STI)		+= sti
 machine-$(CONFIG_ARCH_STM32)		+= stm32
+machine-$(CONFIG_ARCH_SUNPLUS)		+= sunplus
 machine-$(CONFIG_ARCH_SUNXI)		+= sunxi
 machine-$(CONFIG_ARCH_TEGRA)		+= tegra
 machine-$(CONFIG_ARCH_U8500)		+= ux500
arch/arm/mach-sunplus/Kconfig new file +26 -0
new file mode 100644
index 000000000..e720606dd
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+
+menuconfig ARCH_SUNPLUS
+	bool "Sunplus SoCs"
+	depends on ARCH_MULTI_V7
+	help
+	  Support for Sunplus SoC family: SP7021 and succeeding SoC-based systems,
+	  such as the Banana Pi BPI-F2S development board (and derivatives).
+	  (<http://www.sinovoip.com.cn/ecp_view.asp?id=586>)
+	  (<https://tibbo.com/store/plus1.html>)
+
+config SOC_SP7021
+	bool "Sunplus SP7021 SoC support"
+	depends on ARCH_SUNPLUS
+	default ARCH_SUNPLUS
+	select ARM_GIC
+	select ARM_PSCI
+	select PINCTRL
+	select PINCTRL_SPPCTL
+	select SERIAL_SUNPLUS
+	select SERIAL_SUNPLUS_CONSOLE
+	help
+	  Support for Sunplus SP7021 SoC. It is based on ARM 4-core
+	  Cortex-A7 with various peripherals (ex: I2C, SPI, SDIO,
+	  Ethernet and etc.), FPGA interface,  chip-to-chip bus.
+	  It is designed for industrial control.
arch/arm/mach-sunplus/Makefile new file +9 -0
new file mode 100644
index 000000000..c902580a7
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the linux kernel.
+#
+
+# Object file lists.
+
+obj-$(CONFIG_SOC_SP7021)	+= sp7021.o
+
arch/arm/mach-sunplus/sp7021.c new file +16 -0
new file mode 100644
index 000000000..774d0a5bd
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+/*
+ * Copyright (C) Sunplus Technology Co., Ltd.
+ *       All rights reserved.
+ */
+#include <linux/kernel.h>
+#include <asm/mach/arch.h>
+
+static const char *sp7021_compat[] __initconst = {
+	"sunplus,sp7021",
+	NULL
+};
+
+DT_MACHINE_START(SP7021_DT, "SP7021")
+	.dt_compat	= sp7021_compat,
+MACHINE_END
Signature · 1 line
2.33.1
author maintainer
#26 lore raw

PATCH v12 9/9 ARM: sp7021_defconfig: Add Sunplus SP7021 defconfig

In reply to Qin Jian

Add generic Sunplus SP7021 based board defconfig

---
 MAINTAINERS                         |  1 +
 arch/arm/configs/multi_v7_defconfig |  1 +
 arch/arm/configs/sp7021_defconfig   | 61 +++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)
 create mode 100644 arch/arm/configs/sp7021_defconfig
MAINTAINERS +1 -0
index 38890c055..93f4de6c1 100644
@@ -2747,6 +2747,7 @@ F:	Documentation/devicetree/bindings/arm/sunplus,sp7021.yaml
 F:	Documentation/devicetree/bindings/clock/sunplus,sp7021-clkc.yaml
 F:	Documentation/devicetree/bindings/interrupt-controller/sunplus,sp7021-intc.yaml
 F:	Documentation/devicetree/bindings/reset/sunplus,reset.yaml
+F:	arch/arm/configs/sp7021_*defconfig
 F:	arch/arm/mach-sunplus/
 F:	drivers/clk/clk-sp7021.c
 F:	drivers/irqchip/irq-sp7021-intc.c
arch/arm/configs/multi_v7_defconfig +1 -0
index 8863fa969..a3bd9dbd8 100644
@@ -86,6 +86,7 @@ CONFIG_MACH_SPEAR1310=y
 CONFIG_MACH_SPEAR1340=y
 CONFIG_ARCH_STI=y
 CONFIG_ARCH_STM32=y
+CONFIG_ARCH_SUNPLUS=y
 CONFIG_ARCH_SUNXI=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_ARCH_UNIPHIER=y
arch/arm/configs/sp7021_defconfig new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.33.1
#27 lore raw

Re: [PATCH v12 9/9] ARM: sp7021_defconfig: Add Sunplus SP7021 defconfig

Quoted 1 line · Qin Jian

Add generic Sunplus SP7021 based board defconfig

Here, you should explain why you need a custom defconfig for this SoC, as most platforms are fine just using the generic one. Are you too memory constrained,
or are there other problems?

arch/arm/configs/multi_v7_defconfig CONFIG_MACH_SPEAR1310=y · line 92

Quoted 12 lines
arch/arm/configs/multi_v7_defconfig +1 -0
index 8863fa969..a3bd9dbd8 100644
@@ -86,6 +86,7 @@ CONFIG_MACH_SPEAR1310=y
 CONFIG_MACH_SPEAR1340=y
 CONFIG_ARCH_STI=y
 CONFIG_ARCH_STM32=y
+CONFIG_ARCH_SUNPLUS=y
 CONFIG_ARCH_SUNXI=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_ARCH_UNIPHIER=y

Don't you need any drivers here?

Quoted 5 lines
arch/arm/configs/sp7021_defconfig new file +0 -0
new file mode 100644
index 000000000..cda16d33a

...

Quoted 1 line

+CONFIG_HAVE_ARM_ARCH_TIMER=y

I checked this one again, as most others don't enable it in the defconfig.

I don't remember if I recommended removing the 'select' from Kconfig in a previous round, but as that is where other platforms have it, I'd add it there as well.

Quoted 1 line

+CONFIG_STAGING=y

Do you actually enable any staging drivers here? If not, I'd drop that bit.

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#28 lore raw

RE: [PATCH v12 9/9] ARM: sp7021_defconfig: Add Sunplus SP7021 defconfig

Quoted 8 lines · Qin Jian
Quoted 1 line

Add generic Sunplus SP7021 based board defconfig

Here, you should explain why you need a custom defconfig for this SoC, as most platforms are fine just using the generic one. Are you too memory constrained,
or are there other problems?

For memory constrained board only.

Quoted 6 lines
Quoted 6 lines
arch/arm/configs/multi_v7_defconfig +0 -0
index 8863fa969..a3bd9dbd8 100644
@@ -86,6 +86,7 @@ CONFIG_MACH_SPEAR1310=y
 CONFIG_MACH_SPEAR1340=y
Quoted 9 lines

arch/arm/configs/multi_v7_defconfig CONFIG_MACH_SPEAR1310=y · line 92

Quoted 6 lines
arch/arm/configs/multi_v7_defconfig +1 -0
 CONFIG_ARCH_STI=y
 CONFIG_ARCH_STM32=y
+CONFIG_ARCH_SUNPLUS=y
 CONFIG_ARCH_SUNXI=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_ARCH_UNIPHIER=y

Don't you need any drivers here?

Currently, all basic drivers auto enabled by mach-sunplus/Kconfig:
...
config SOC_SP7021
bool "Sunplus SP7021 SoC support"
depends on ARCH_SUNPLUS
default ARCH_SUNPLUS
select ARM_GIC
select ARM_PSCI
select PINCTRL
select PINCTRL_SPPCTL
select SERIAL_SUNPLUS
select SERIAL_SUNPLUS_CONSOLE

and driver's Kconfig:
...
config RESET_SUNPLUS
bool "Sunplus SoCs Reset Driver" if COMPILE_TEST default ARCH_SUNPLUS
...

Quoted 6 lines
Quoted 5 lines
arch/arm/configs/sp7021_defconfig new file +0 -0
new file mode 100644
index 000000000..cda16d33a

...

Quoted 8 lines
Quoted 1 line

+CONFIG_HAVE_ARM_ARCH_TIMER=y

I checked this one again, as most others don't enable it in the defconfig.

I don't remember if I recommended removing the 'select' from Kconfig in a previous round, but as that is where other platforms have it, I'd add it there as well.

I'll move this to mach-sunplus/Kconfig.

Quoted 4 lines
Quoted 1 line

+CONFIG_STAGING=y

Do you actually enable any staging drivers here? If not, I'd drop that bit.

I’ll drop it.

Thanks all your comments.