Add iop driver for Sunplus SP7021
Subsystems (2)
v3 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
.../devicetree/bindings/misc/sunplus-iop.yaml | 61 ++++ MAINTAINERS | 6 + drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/sunplus_iop.c | 395 +++++++++++++++++++++ 5 files changed, 475 insertions(+) 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 v3 1/2 dt-binding: misc: Add iop yaml file for Sunplus SP7021
Add iop yaml file for Sunplus SP7021
---
Changes in v3:
- No change.
.../devicetree/bindings/misc/sunplus-iop.yaml | 61 ++++++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/sunplus-iop.yaml
Documentation/devicetree/bindings/misc/sunplus-iop.yaml new file +61 -0
@@ -0,0 +1,61 @@ +# 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: + maxItems: 2 + + memory-region: + maxItems: 1 + +required: + - compatible + - reg + - reg-names + - interrupts + - memory-region + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.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>; + }; +...
MAINTAINERS +5 -0
@@ -17945,6 +17945,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
Rob Herring
maintainerRe: [PATCH v3 1/2] dt-binding: misc: Add iop yaml file for Sunplus SP7021
Quoted 43 lines · Tony Huang
Add iop yaml file for Sunplus SP7021
Signed-off-by Tony Huang <[email protected]>---
Changes in v3:
- No change..../devicetree/bindings/misc/sunplus-iop.yaml | 61 ++++++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/sunplus-iop.yamlDocumentation/devicetree/bindings/misc/sunplus-iop.yaml new file +25
-0@@ -0,0 +1,61 @@ +# 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
Documentation/devicetree/bindings/misc/sunplus-iop.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/misc/sunplus-iop.yaml new file +10
-0+ - description: MOON0 registers regions + + reg-names: + items: + - const: iop + - const: iop_pmc + - const: moon0 + + interrupts: + maxItems: 2
Need to define what each interrupt is.
Quoted 46 lines
Documentation/devicetree/bindings/misc/sunplus-iop.yaml new file +26
-0+ + memory-region: + maxItems: 1 + +required: + - compatible + - reg + - reg-names + - interrupts + - memory-region + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.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>; + }; +...MAINTAINERS +5
-0@@ -17945,6 +17945,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 v3 2/2 misc: Add iop driver for Sunplus SP7021
In reply to Tony HuangIOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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 v3:
- Addressed comments from Arnd Bergmann.
- Addressed comments from Greg KH.
- Addressed comments from kernel test robot.
MAINTAINERS | 1 + drivers/misc/Kconfig | 12 ++ drivers/misc/Makefile | 1 + drivers/misc/sunplus_iop.c | 395 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 409 insertions(+) create mode 100644 drivers/misc/sunplus_iop.c
MAINTAINERS +1 -0
@@ -17949,6 +17949,7 @@ SUNPLUS IOP DRIVER M: Tony Huang <[email protected]> S: Maintained F: Documentation/devicetree/bindings/misc/sunplu-iop.yaml +F: drivers/misc/sunplus_iop.c SUPERH M: Yoshinori Sato <[email protected]>
drivers/misc/Kconfig +12 -0
@@ -470,6 +470,18 @@ 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, RTC wake-up proceduce management, + and cooperation with CPU&PMC in power management. + Need Install DQ8051, The DQ8051 bin file generated by keil C. + + This driver can also be built as a module. If so, the module + will be called ad525x_dpot. + 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 +395 -0
395 lines not on this page · raw message
Signature · 1 line
2.7.4
Arnd Bergmann
maintainerRe: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
Quoted 9 lines · Tony Huang
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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]>
Thanks for the improvements, this again looks better than the previous version. I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no file_operations associated
with it, so it still doesn't have any effect.
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power management".
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the abstraction works.
Arnd
RE: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
Dear Arnd:
Quoted 23 lines
Quoted 9 lines · Tony Huang
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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]>Thanks for the improvements, this again looks better than the previous version. I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no
file_operationsassociated with it, so it still doesn't have any effect.
Quoted 9 lines
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power management".
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the abstraction works.
OK, I will modify it.
RE: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
In reply to Arnd BergmannDear Arnd:
Quoted 23 lines
Quoted 9 lines · Tony Huang
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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]>Thanks for the improvements, this again looks better than the previous version. I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no
file_operationsassociated with it, so it still doesn't have any effect.
Quoted 9 lines
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power management".
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the abstraction works.
Q:"with respective kernel subsystems in order to show that the abstraction works." May I ask you about repective kernel subsystem.
If I use the file_operation method
Provide user can read and write IOP(8051)'s register.
Is this a repective kernel subsystem?
if not
There are other driver code can give me reference
gregkh
maintainerRe: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
Quoted 35 lines · Tony Huang 黃懷厚
Dear Arnd:
Quoted 23 lines
Quoted 9 lines · Tony Huang
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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]>Thanks for the improvements, this again looks better than the previous version. I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no
file_operationsassociated with it, so it still doesn't have any effect.Quoted 9 lines
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power management".
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the abstraction works.
Quoted 8 lines
Q:"with respective kernel subsystems in order to show that the abstraction works." May I ask you about repective kernel subsystem.
If I use thefile_operationmethod
Provide user can read and write IOP(8051)'s register.
Is this a repective kernel subsystem?
if not
There are other driver code can give me reference
I still do not understand what the goal of this driver is.
What is the problem that you are needing to solve? What needs to access this hardware, and what exactly was this hardware designed to do?
thanks,
greg k-h
RE: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
Dear gregkh, arnd:
Quoted 46 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines · wrote:
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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.Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Tony Huang <[email protected]>Thanks for the improvements, this again looks better than the previous
version.
Quoted 9 lines
Quoted 9 lines
I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no
file_operationsassociated with it, so it still doesn'thave any effect.
Quoted 5 lines
Quoted 5 lines
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power
management".
Quoted 4 lines
Quoted 4 lines
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the
abstraction works.
Quoted 3 lines
Quoted 1 line
Q:"with respective kernel subsystems in order to show that the abstraction
works."
Quoted 7 lines
May I ask you about repective kernel subsystem. If I use the
file_operationmethod
Provide user can read and write IOP(8051)'s register. Is this a repective kernel subsystem?
if not
There are other driver code can give me reference
Quoted 2 lines
I still do not understand what the goal of this driver is.
When the poweroff command is executed.
1.The 8051 has a register to control the power-on and power-off of the system(Linux kernel).
If you turn off the power through the 8051 register(DEF_PWR_EN_0=0),
The current measured by the circuit board is 0.4mA only. In order to save power.
2.The power is not turned off through the 8051 register.
The current measured on the circuit board is 33mA
3.When the system linux kerenl is powered off. /driver/rtc, /driver/gpio cannot operate.
8051 is still alive and operational
8051 has RTC register. When the time is up, 8051 powers on the system
The 8051 can detect GPIO0~7 pins, and GPIO pin high/low can be used as a power-on judgment mechanism for the system.
Quoted 3 lines
What is the problem that you are needing to solve? What needs to access this hardware, and what exactly was this hardware designed to do?
for example:
SP7021 8051 has three power states:S0, S1 and S3.
S0:Default domain(linux kernel) is on. IOP domain of 8051 is on. AO domain of 8051 is on. S1:Default domain(linux kernel) is off. IOP domain of 8051 is on. AO domain of 8051 is on. S3:Default domain(linux kernel) is off. IOP domain of 8051 is off. AO domain of 8051 is on. The user can use the 12bytes mailbox register to notify 8051.8051 needs to turn off which domain. I need custom miscdevice.
User<--->misc/sunplus_iop<--->Hardware(8051)
gregkh
maintainerRe: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
Quoted 48 lines · Tony Huang 黃懷厚
Dear gregkh, arnd:
Quoted 46 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines · wrote:
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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.Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Tony Huang <[email protected]>Thanks for the improvements, this again looks better than the previous
version.
Quoted 9 lines
Quoted 9 lines
I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no
file_operationsassociated with it, so it still doesn'thave any effect.
Quoted 5 lines
Quoted 5 lines
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power
management".
Quoted 4 lines
Quoted 4 lines
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the
abstraction works.
Quoted 3 lines
Quoted 1 line
Q:"with respective kernel subsystems in order to show that the abstraction
works."
Quoted 7 lines
May I ask you about repective kernel subsystem. If I use the
file_operationmethod
Provide user can read and write IOP(8051)'s register. Is this a repective kernel subsystem?
if not
There are other driver code can give me reference
Quoted 4 lines
Quoted 2 lines
I still do not understand what the goal of this driver is.
When the poweroff command is executed.
What exactly do you mean by this? The power off command that is sent to the kernel from userspace?
Quoted 9 lines
1.The 8051 has a register to control the power-on and power-off of the system(Linux kernel).
If you turn off the power through the 8051register(DEF_PWR_EN_0=0),
The current measured by the circuit board is 0.4mA only. In order to save power.
2.The power is not turned off through the 8051 register.
The current measured on the circuit board is 33mA
3.When the system linux kerenl is powered off. /driver/rtc, /driver/gpio cannot operate.
8051 is still alive and operational
8051 has RTC register. When the time is up, 8051 powers on the system
The 8051 can detect GPIO0~7 pins, and GPIO pin high/low can be used as a power-on judgment mechanism for the system.
So what do you need to do? When the kernel needs to shut down the system, send a message to this hardware device? If so, great, just tie into the normal powerdown sequence, this is nothing new.
If not, I do not understand.
thanks,
greg k-h
RE: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
Dear gregkh, arnd:
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines · wrote:
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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.Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Tony Huang <[email protected]>Thanks for the improvements, this again looks better than the previous
version.
Quoted 10 lines
Quoted 10 lines
I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no
file_operationsassociated with it, so it still doesn'thave any effect.
Quoted 6 lines
Quoted 6 lines
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power
management".
Quoted 5 lines
Quoted 5 lines
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the
abstraction works.
Quoted 4 lines
Quoted 1 line
Q:"with respective kernel subsystems in order to show that the abstraction
works."
Quoted 7 lines
May I ask you about repective kernel subsystem.
If I use thefile_operationmethod Provide user can read and write IOP(8051)'s register.
Is this a repective kernel subsystem?
if not
There are other driver code can give me reference
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I still do not understand what the goal of this driver is.
When the poweroff command is executed.
What exactly do you mean by this? The power off command that is sent to the kernel from userspace?
I type "poweroff" in command line.
Quoted 11 lines
Quoted 1 line
1.The 8051 has a register to control the power-on and power-off of the
system(Linux kernel).
Quoted 2 lines
If you turn off the power through the 8051
register(DEF_PWR_EN_0=0),
The current measured by the circuit board is 0.4mA only. In order to savepower.
Quoted 6 lines
2.The power is not turned off through the 8051 register.
The current measured on the circuit board is 33mA 3.When the system
linux kerenl is powered off. /driver/rtc, /driver/gpio cannot operate.
8051 is still alive and operational
8051 has RTC register. When the time is up, 8051 powers on the system The 8051 can detect GPIO0~7 pins, and GPIO pin high/low can be used as
Quoted 6 lines
a power-on judgment mechanism for the system.
So what do you need to do? When the kernel needs to shut down the system, send a message to this hardware device? If so, great, just tie into the normal powerdown sequence, this is nothing new.
Yes,
poweroff command ---> run misc/sunplus_ioc.c/sp_iop_platform_driver_shutdown()---->switch standby.bin for 8051--->setting 8051 PMC register---> sent a message to 8051 Q:Why need switch standby.bin for 8051?
A: 8051 has two bin files, normal.bin and standby.bin in rootfs.
Normally, 8051 executes normal.bin code. Normal.bin code size can exceed 16K.
When system linux kernel is shutdown, 8051 is to execute standby.bin code.
Standby.bin code cannot exceed 16K bytes. Because 8051 Icache size is 16k
8051 runs with standby.bin code in the Icache before the system(linux kernel) is poweroff.
So I need misc/sunplus_iop.c interface to switch bin code and sends message to 8051.
Thanks
Arnd Bergmann
maintainerRe: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
In reply to Tony Huang 黃懷厚Quoted 33 lines · Tony Huang 黃懷厚
Quoted 23 lines
Quoted 9 lines · Tony Huang
IOP (IO Processor) embedded inside SP7021 which is used as Processor for I/O control, RTC wake-up 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]>Thanks for the improvements, this again looks better than the previous version. I still have some minor comments, and there are a couple of details I have commented on before that would need to be addressed, but let's focus on the one main issue for now:
The driver still doesn't actually /do/ anything: you load the firmware when the driver is loaded, and you shut it down when the driver is removed, but otherwise there is no way to interact with the iop. You had the miscdevice earlier, and you still register that, but there are no
file_operationsassociated with it, so it still doesn't have any effect.Quoted 9 lines
In the original version you had a couple of user-side interfaces, for which Greg and I commented that they were not using the correct abstractions, and you still list them in the changelog text as "I/O control, RTC wake-up and cooperation with CPU & PMC in power management".
If you want to make any progress with adding the driver, I'd say you should implement at least two of those high-level interfaces that interact with the respective kernel subsystems in order to show that the abstraction works.
Quoted 7 lines
Q:"with respective kernel subsystems in order to show that the abstraction works." May I ask you about repective kernel subsystem.
If I use thefile_operationmethod
Provide user can read and write IOP(8051)'s register.
Is this a repective kernel subsystem?
if not
There are other driver code can give me reference
- For gpio, there are lots of drivers in drivers/gpio/
- For RTC, there are drivers in drivers/rtc/
- For suspending the CPU core, there are drivers in drivers/cpuidle/
- For turning off the system, you can find drivers in drivers/power/reset/
Any of these drivers can interface with your kernel driver in various ways that avoid adding a custom miscdevice.
Arnd
Greg KH
maintainerRe: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
In reply to Tony Huangdrivers/misc/sunplus_iop.c line 219
Quoted 4 lines · Tony Huang
drivers/misc/sunplus_iop.c new file +4
-0+while (1 ) { +if (p_iop_reg->iop_data7 ==0xaaaa ) +break ; + }
You can not create a loop that could never exit. Please fix.
Also, what prevents the compiler from optimizing this away into nothing? This code does not look correct at all.
drivers/misc/sunplus_iop.c line 231
Quoted 12 lines
drivers/misc/sunplus_iop.c new file +12
-0+ +writel (0xdd , &p_iop_reg->iop_data1);//8051 bin file call Ultra low function. +mdelay (10 ); +} + +static int sp_iop_get_normal_code (struct device *dev,struct sp_iop *iop) +{ +const struct firmware *fw; +static const char file[] ="normal.bin" ; +unsigned int err, i; + +dev_info (dev,"normal code\n" );
Please always delete your debugging code before submitting a patch.
Also, please run checkpatch.pl on your changes before submitting them.
thanks,
greg k-h
RE: [PATCH v3 2/2] misc: Add iop driver for Sunplus SP7021
Dear Greg:
Quoted 8 lines · Tony Huang
drivers/misc/sunplus_iop.c line 219
Quoted 4 lines
drivers/misc/sunplus_iop.c new file +4
-0+while (1 ) { +if (p_iop_reg->iop_data7 ==0xaaaa ) +break ; + }You can not create a loop that could never exit. Please fix.
OK, I will modify it.
Quoted 6 lines
Also, what prevents the compiler from optimizing this away into nothing? This code does not look correct at all.
Review
Quoted 2 lines
(quoted diff) +2
-0+ + writel(0xdd, &p_iop_reg->iop_data1);//8051 bin file call Ultra lowfunction.
Quoted 13 lines
drivers/misc/sunplus_iop.c line 231
Quoted 10 lines
drivers/misc/sunplus_iop.c new file +10
-0+mdelay (10 ); +} + +static int sp_iop_get_normal_code (struct device *dev,struct sp_iop +*iop) { +const struct firmware *fw; +static const char file[] ="normal.bin" ; +unsigned int err, i; + +dev_info (dev,"normal code\n" );Please always delete your debugging code before submitting a patch.
OK, I will delete it.
Quoted 5 lines
Also, please run checkpatch.pl on your changes before submitting them.
thanks,
greg k-h