Add iop driver for Sunplus SP7021
Subsystems (2)
v8 cover Add iop driver for Sunplus SP7021
Add iop driver for Sunplus SP7021 SOC
This is a patch series for iop 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
Tony Huang (2):
dt-binding: misc: Add iop yaml file for Sunplus SP7021
misc: Add iop driver for Sunplus SP7021
Documentation/ABI/testing/sysfs-platform-soc@B | 28 ++ .../devicetree/bindings/misc/sunplus-iop.yaml | 76 ++++ MAINTAINERS | 7 + drivers/misc/Kconfig | 20 + drivers/misc/Makefile | 1 + drivers/misc/sunplus_iop.c | 463 +++++++++++++++++++++ 6 files changed, 595 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-soc@B create mode 100644 Documentation/devicetree/bindings/misc/sunplus-iop.yaml create mode 100644 drivers/misc/sunplus_iop.c
Signature · 1 line
2.7.4
PATCH v8 1/2 dt-binding: misc: Add iop yaml file for Sunplus SP7021
Add iop yaml file for Sunplus SP7021
---
Changes in v8:
-No change
.../devicetree/bindings/misc/sunplus-iop.yaml | 76 ++++++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/sunplus-iop.yaml
Documentation/devicetree/bindings/misc/sunplus-iop.yaml new file +76 -0
@@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) Sunplus Ltd. Co. 2021 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/sunplus-iop.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sunplus IOP(8051) controller + +maintainers: + - Tony Huang <[email protected]> + +description: | + Processor for I/O control, RTC wake-up procedure management, + and cooperation with CPU&PMC in power management. + +properties: + compatible: + enum: + - sunplus,sp7021-iop + + reg: + items: + - description: IOP registers regions + - description: PMC registers regions + - description: MOON0 registers regions + + reg-names: + items: + - const: iop + - const: iop_pmc + - const: moon0 + + interrupts: + items: + - description: IOP_INT0. IOP to system Interrupt 0. + Sent by IOP to system RISC. + - description: IOP_INT1. IOP to System Interrupt 1. + Sent by IOP to system RISC. + + memory-region: + maxItems: 1 + + wakeup-gpios: + description: When the linux kernel system is powered off. + 8051 is always powered. 8051 cand receive external signals + according to this gpio pin. 8051 receives external signal + through gpio pin. 8051 can power on linux kernel system. + +required: + - compatible + - reg + - reg-names + - interrupts + - memory-region + - wakeup-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/gpio/gpio.h> + iop: iop@9c000400 { + compatible = "sunplus,sp7021-iop"; + reg = <0x9c000400 0x80>, <0x9c003100 0x80>, <0x9c000000 0x80>; + reg-names = "iop", "iop_pmc", "moon0"; + interrupt-parent = <&intc>; + interrupts = <41 IRQ_TYPE_LEVEL_HIGH>, <42 IRQ_TYPE_LEVEL_HIGH>; + memory-region = <&iop_reserve>; + pinctrl-names = "default"; + pinctrl-0 = <&iop_pins>; + wakeup-gpios = <&pctl 1 GPIO_ACTIVE_HIGH>; + }; +...
MAINTAINERS +5 -0
@@ -18242,6 +18242,11 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/dlink/sundance.c +SUNPLUS IOP DRIVER +M: Tony Huang <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/misc/sunplu-iop.yaml + SUPERH M: Yoshinori Sato <[email protected]> M: Rich Felker <[email protected]>
Signature · 1 line
2.7.4
PATCH v8 2/2 misc: Add iop driver for Sunplus SP7021
In reply to Tony HuangIOP(8051) embedded inside SP7021 which is used as Processor for I/O control, monitor RTC interrupt and cooperation with CPU & PMC in power management purpose. The IOP core is DQ8051, so also named IOP8051,
it supports dedicated JTAG debug pins which share with SP7021. In standby mode operation, the power spec reach 400uA.
---
Changes in v8:
- Addressed comments from Greg KH.
Documentation/ABI/testing/sysfs-platform-soc@B | 28 ++ MAINTAINERS | 2 + drivers/misc/Kconfig | 20 ++ drivers/misc/Makefile | 1 + drivers/misc/sunplus_iop.c | 463 +++++++++++++++++++++++++ 5 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-soc@B create mode 100644 drivers/misc/sunplus_iop.c
Documentation/ABI/testing/sysfs-platform-soc@B new file +28 -0
@@ -0,0 +1,28 @@ +What: /sys/devices/platform/soc@B/9c000400.iop/sp_iop_mailbox +Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Show IOP's mailbox0 register data. + Format: %x + +What: /sys/devices/platform/soc@B/9c000400.iop/sp_iop_mode +Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Read-Write. + + Write this file. + Operation mode of IOP is switched to standby mode by writing + "1" to sysfs. + Operation mode of IOP is switched to normal mode by writing + "0" to sysfs. + Writing of other values is invalid. + + Read this file. + Show operation mode of IOP. "0" is normal mode. "1" is standby + mode. + Format: %x + +
MAINTAINERS +2 -0
@@ -18245,7 +18245,9 @@ F: drivers/net/ethernet/dlink/sundance.c SUNPLUS IOP DRIVER M: Tony Huang <[email protected]> S: Maintained +F: Documentation/ABI/testing/sysfs-platform-soc@B F: Documentation/devicetree/bindings/misc/sunplu-iop.yaml +F: drivers/misc/sunplus_iop.c SUPERH M: Yoshinori Sato <[email protected]>
drivers/misc/Kconfig +20 -0
@@ -470,6 +470,26 @@ config HISI_HIKEY_USB switching between the dual-role USB-C port and the USB-A host ports using only one USB controller. +config SUNPLUS_IOP + tristate "Sunplus IOP support" + default ARCH_SUNPLUS + help + Sunplus I/O processor (8051) driver. + Processor for I/O control, monitor RTC interrupt + and cooperation with CPU&PMC in power management. + + The IOP core is DQ8051, so also named IOP8051. + Need Install DQ8051, The DQ8051 bin file generated by keil C. + We will provide users with 8051 normal and standby source code. + Path: https://sunplus.atlassian.net/wiki/spaces/doc/pages/610172933/ + How+to+use+I+O+processor+8051+of+SP7021#5.-Write-C-or-assembly-source-files-for-IOP + Users can follow the operation steps to generate normal.bin and standby.bin. + Path: https://sunplus.atlassian.net/wiki/spaces/doc/pages/466190338/26.+IOP8051 + 26.5?How To Create 8051 bin file + + This driver can also be built as a module. If so, the module + will be called sunplus_iop. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_DW_XDATA_PCIE) += dw-xdata-pcie.o obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o obj-$(CONFIG_OCXL) += ocxl/ obj-$(CONFIG_BCM_VK) += bcm-vk/ +obj-$(CONFIG_SUNPLUS_IOP) += sunplus_iop.o obj-y += cardreader/ obj-$(CONFIG_PVPANIC) += pvpanic/ obj-$(CONFIG_HABANA_AI) += habanalabs/
drivers/misc/sunplus_iop.c new file +463 -0
463 lines not on this page · raw message
Signature · 1 line
2.7.4
Arnd Bergmann
maintainerRe: [PATCH v8 2/2] misc: Add iop driver for Sunplus SP7021
Quoted 44 lines · Tony Huang
IOP(8051) embedded inside SP7021 which is used as Processor for I/O control, monitor RTC interrupt and cooperation with CPU & PMC in power management purpose. The IOP core is DQ8051, so also named IOP8051,
it supports dedicated JTAG debug pins which share with SP7021. In standby mode operation, the power spec reach 400uA.Signed-off-by Tony Huang <[email protected]>---
Changes in v8:
- Addressed comments from Greg KH.Documentation/ABI/testing/sysfs-platform-soc@B | 28 ++ MAINTAINERS | 2 + drivers/misc/Kconfig | 20 ++ drivers/misc/Makefile | 1 + drivers/misc/sunplus_iop.c | 463 +++++++++++++++++++++++++ 5 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-soc@B create mode 100644 drivers/misc/sunplus_iop.cDocumentation/ABI/testing/sysfs-platform-soc@B new file +16
-0@@ -0,0 +1,28 @@ +What: /sys/devices/platform/soc@B/9c000400.iop/sp_iop_mailbox +Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Show IOP's mailbox0 register data. + Format: %x + +What: /sys/devices/platform/soc@B/9c000400.iop/sp_iop_mode +Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Read-Write. + + Write this file.
Documentation/ABI/testing/sysfs-platform-soc@B line 26
Quoted 10 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +10
-0+ Operation mode of IOP is switched to standby mode by writing + "1" to sysfs. + Operation mode of IOP is switched to normal mode by writing + "0" to sysfs. + Writing of other values is invalid. + + Read this file. + Show operation mode of IOP. "0" is normal mode. "1" is standby + mode. + Format: %x
As discussed before, I would suggest leaving out all custom attributes for now, and first hooking up the driver to all the in-kernel subsystems.
The mailbox0 register data definitely feels like an implementation detail, not something that should be exposed to user space as an interface.
For standby mode, this would normally be handled by the power management subsystem in the kernel. not a custom interface. From your earlier description, I assume this interface puts the main CPU into standby mode, not the IOP, right?
CPU standby is handled by the cpuidle subsystem, so you need a driver in drivers/cpuidle/ to replace your sysfs attribute. If you plan to hook up the driver to multiple subsystems, keeping a generic driver file is ok, so you'll end up with two driver modules, with one of them calling into the other, using EXPORT_SYMBOL() to link between them.
Arnd
RE: [PATCH v8 2/2] misc: Add iop driver for Sunplus SP7021
Dear Arnd:
Quoted 87 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Monday, February 7, 2022 3:48 PM
To: Tony Huang <[email protected]>
Cc: Rob Herring <[email protected]>; DTML <[email protected]>; Linux Kernel Mailing List <[email protected]>; Derek Kiernan <[email protected]>; Dragan Cvetic <[email protected]>; Arnd Bergmann <[email protected]>; gregkh <[email protected]>; Tony Huang 黃懷厚 <[email protected]>; Wells Lu 呂芳騰 <[email protected]>
Subject: Re: [PATCH v8 2/2] misc: Add iop driver for Sunplus SP7021Quoted 13 lines · Tony Huang
IOP(8051) embedded inside SP7021 which is used as Processor for I/O control, monitor RTC interrupt and cooperation with CPU & PMC in power management purpose.
The IOP core is DQ8051, so also named IOP8051, it supports dedicated JTAG debug pins which share with SP7021.
In standby mode operation, the power spec reach 400uA.Signed-off-by Tony Huang <[email protected]>---
Changes in v8:
- Addressed comments from Greg KH.Quoted 5 lines
Documentation/ABI/testing/sysfs-platform-soc@B | 28 ++ MAINTAINERS | 2 + drivers/misc/Kconfig | 20 ++ drivers/misc/Makefile | 1 + drivers/misc/sunplus_iop.c | 463+++++++++++++++++++++++++
Documentation/ABI/testing/sysfs-platform-soc@B line 1
Quoted 12 lines
5 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-soc@B create mode 100644 drivers/misc/sunplus_iop.cDocumentation/ABI/testing/sysfs-platform-soc@B new file +1
-0@@ -0,0 +1,28 @@ +What:
/sys/devices/platform/soc@B/9c000400.iop/sp_iop_mailboxDocumentation/ABI/testing/sysfs-platform-soc@B
Quoted 8 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +8
-0+Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Show IOP's mailbox0 register data. + Format: %x + +What:
/sys/devices/platform/soc@B/9c000400.iop/sp_iop_modeDocumentation/ABI/testing/sysfs-platform-soc@B
Quoted 8 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +8
-0+Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Read-Write. + + Write this file. + Operation mode of IOP is switched to standby mode bywriting
Documentation/ABI/testing/sysfs-platform-soc@B line 19
Quoted 2 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +2
-0+ "1" to sysfs. + Operation mode of IOP is switched to normal mode bywriting
Documentation/ABI/testing/sysfs-platform-soc@B
Quoted 5 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +5
-0+ "0" to sysfs. + Writing of other values is invalid. + + Read this file. + Show operation mode of IOP. "0" is normal mode. "1" isstandby
Documentation/ABI/testing/sysfs-platform-soc@B line 26
Quoted 2 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +2
-0+ mode. + Format: %xAs discussed before, I would suggest leaving out all custom attributes for now, and first hooking up the driver to all the in-kernel subsystems.
The mailbox0 register data definitely feels like an implementation detail, not something that should be exposed to user space as an interface.
For standby mode, this would normally be handled by the power management subsystem in the kernel. not a custom interface. From your earlier description, I assume this interface puts the main CPU into standby mode, not the IOP, right?
Quoted 7 lines
CPU standby is handled by the cpuidle subsystem, so you need a driver in
drivers/cpuidle/to replace your sysfs attribute.
If you plan to hook up the driver to multiple subsystems, keeping a generic driver file is ok, so you'll end up with two driver modules, with one of them calling into the other, usingEXPORT_SYMBOL()to link between them.
The purpose of adding sysfs is only for users to debug. So this is not needed?
Thanks
gregkh
maintainerRe: [PATCH v8 2/2] misc: Add iop driver for Sunplus SP7021
Quoted 97 lines · Tony Huang 黃懷厚
Dear Arnd:
Quoted 87 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Monday, February 7, 2022 3:48 PM
To: Tony Huang <[email protected]>
Cc: Rob Herring <[email protected]>; DTML <[email protected]>; Linux Kernel Mailing List <[email protected]>; Derek Kiernan <[email protected]>; Dragan Cvetic <[email protected]>; Arnd Bergmann <[email protected]>; gregkh <[email protected]>; Tony Huang 黃懷厚 <[email protected]>; Wells Lu 呂芳騰 <[email protected]>
Subject: Re: [PATCH v8 2/2] misc: Add iop driver for Sunplus SP7021Quoted 13 lines · Tony Huang
IOP(8051) embedded inside SP7021 which is used as Processor for I/O control, monitor RTC interrupt and cooperation with CPU & PMC in power management purpose.
The IOP core is DQ8051, so also named IOP8051, it supports dedicated JTAG debug pins which share with SP7021.
In standby mode operation, the power spec reach 400uA.Signed-off-by Tony Huang <[email protected]>---
Changes in v8:
- Addressed comments from Greg KH.Quoted 5 lines
Documentation/ABI/testing/sysfs-platform-soc@B | 28 ++ MAINTAINERS | 2 + drivers/misc/Kconfig | 20 ++ drivers/misc/Makefile | 1 + drivers/misc/sunplus_iop.c | 463+++++++++++++++++++++++++
Documentation/ABI/testing/sysfs-platform-soc@B line 1
Quoted 12 lines
5 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-soc@B create mode 100644 drivers/misc/sunplus_iop.cDocumentation/ABI/testing/sysfs-platform-soc@B new file +1
-0@@ -0,0 +1,28 @@ +What:
/sys/devices/platform/soc@B/9c000400.iop/sp_iop_mailboxDocumentation/ABI/testing/sysfs-platform-soc@B
Quoted 8 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +8
-0+Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Show IOP's mailbox0 register data. + Format: %x + +What:
/sys/devices/platform/soc@B/9c000400.iop/sp_iop_modeDocumentation/ABI/testing/sysfs-platform-soc@B
Quoted 8 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +8
-0+Date: January 2022 +KernelVersion: 5.16 +Contact: Tony Huang <[email protected]> +Description: + Read-Write. + + Write this file. + Operation mode of IOP is switched to standby mode bywriting
Documentation/ABI/testing/sysfs-platform-soc@B line 19
Quoted 2 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +2
-0+ "1" to sysfs. + Operation mode of IOP is switched to normal mode bywriting
Documentation/ABI/testing/sysfs-platform-soc@B
Quoted 5 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +5
-0+ "0" to sysfs. + Writing of other values is invalid. + + Read this file. + Show operation mode of IOP. "0" is normal mode. "1" isstandby
Documentation/ABI/testing/sysfs-platform-soc@B line 26
Quoted 2 lines
Documentation/ABI/testing/sysfs-platform-soc@B new file +2
-0+ mode. + Format: %xAs discussed before, I would suggest leaving out all custom attributes for now, and first hooking up the driver to all the in-kernel subsystems.
The mailbox0 register data definitely feels like an implementation detail, not something that should be exposed to user space as an interface.
For standby mode, this would normally be handled by the power management subsystem in the kernel. not a custom interface. From your earlier description, I assume this interface puts the main CPU into standby mode, not the IOP, right?
Quoted 7 lines
CPU standby is handled by the cpuidle subsystem, so you need a driver in
drivers/cpuidle/to replace your sysfs attribute.
If you plan to hook up the driver to multiple subsystems, keeping a generic driver file is ok, so you'll end up with two driver modules, with one of them calling into the other, usingEXPORT_SYMBOL()to link between them.
Quoted 2 lines
The purpose of adding sysfs is only for users to debug. So this is not needed?
If this is only for debugging, please put it in debugfs and not sysfs.
thanks,
greg k-h
Arnd Bergmann
maintainerRe: [PATCH v8 2/2] misc: Add iop driver for Sunplus SP7021
Quoted 21 lines · gregkh
Quoted 20 lines · Tony Huang 黃懷厚
Quoted 19 lines
As discussed before, I would suggest leaving out all custom attributes for now, and first hooking up the driver to all the in-kernel subsystems.
The mailbox0 register data definitely feels like an implementation detail, not something that should be exposed to user space as an interface.
For standby mode, this would normally be handled by the power management subsystem in the kernel. not a custom interface. From your earlier description, I assume this interface puts the main CPU into standby mode, not the IOP, right?
CPU standby is handled by the cpuidle subsystem, so you need a driver in
drivers/cpuidle/to replace your sysfs attribute.
If you plan to hook up the driver to multiple subsystems, keeping a generic driver file is ok, so you'll end up with two driver modules, with one of them calling into the other, usingEXPORT_SYMBOL()to link between them.
Quoted 4 lines
Quoted 2 lines
The purpose of adding sysfs is only for users to debug. So this is not needed?
If this is only for debugging, please put it in debugfs and not sysfs.
I don't think that works for the idle mode interface, as this is the only thing the driver really does at the moment.
In a previous review round, I already asked for the driver to implement at least two in-kernel interfaces before any custom user interface is added.
Arnd