Add Spreadtrum Sharkl64 Platform support
Subsystems (9)
A message that is not in the archive (sent off-list or not yet received): Sharkl64-v3
v3 cover Add Spreadtrum Sharkl64 Platform support
Spreadtrum is a rapid growing chip vendor providing smart phone total solutions.
Sharkl64 Platform is nominated as a SoC infrastructure that supports 4G/3G/2G standards based on ARMv8 multiple core architecture.Now we have only one SoC(SC9836) based on this Platform in developing.
This patchset adds Sharkl64 support in arm64 device tree and the serial driver of SC9836-UART.
This patchset also has patches which address "sprd" prefix and DT compatible strings for nodes which appear un-documented.
This version code was tesed on Fast Mode.
We use boot-wrapper-aarch64 as the bootloader.
Changes from v2:
* Addressed review comments:
- Added a specific compitible string 'sc9836-uart' for the serial
- Added a full serial driver
- Added the property 'clock-frequency' for timer node in dtsi.
- Replaceed the old macro prefix 'UART_' with 'SPRD_' in the Spreadtrum serial driver code.
* Revised the name of SoC and board from 'sharkl3' to 'sc9836'
* Used dual-license for DTS files
* Added a menuconfig 'ARCH_SPRD' in arch/arm64/Kconfig
Changes from v1:
* Addressed review comments:
- Added "sprd" prefix to vendor-prefixes.txt
- Created serial/sprd-serial.txt and remove the properties for serial-sprd from of-serial.txt to it.
- Renamed of-serial.txt to 8250.txt according to Arnd's review comments
- Splited and revised .dts for Sharkl64 Platform
- Changed to PSCI method for cpu power management
- Revised Kconfig Makefile to match the alphabetical ordering
- Renamed serial-sprd-earlycon.c to serial-sprd.c
Chunyan Zhang (3):
Documentation: DT: Renamed of-serial.txt to 8250.txt
Documentation: DT: Add bindings for Spreadtrum SoC Platform tty/serial: Add Spreadtrum sc9836-uart driver support
Zhizhou Zhang (2):
arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
arm64: Add support for Spreadtrum's Sharkl64 Platform in Kconfig and
defconfig
Documentation/devices.txt | 3 +
Documentation/devicetree/bindings/arm/sprd.txt | 11 +
.../bindings/serial/{of-serial.txt => 8250.txt} | 0
.../devicetree/bindings/serial/sprd-uart.txt | 6 +
.../devicetree/bindings/vendor-prefixes.txt | 1 +
arch/arm64/Kconfig | 17 +
arch/arm64/boot/dts/Makefile | 1 +
arch/arm64/boot/dts/sprd-sc9836-openphone.dts | 85 +++
arch/arm64/boot/dts/sprd-sc9836.dtsi | 103 +++
arch/arm64/boot/dts/sprd-sharkl64.dtsi | 105 +++
arch/arm64/configs/defconfig | 2 +
drivers/tty/serial/Kconfig | 23 +
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/sprd_serial.c | 752 ++++++++++++++++++++
include/uapi/linux/serial_core.h | 3 +
15 files changed, 1113 insertions(+)
create mode 100644 Documentation/devicetree/bindings/arm/sprd.txt
rename Documentation/devicetree/bindings/serial/{of-serial.txt => 8250.txt} (100%)
create mode 100644 Documentation/devicetree/bindings/serial/sprd-uart.txt
create mode 100644 arch/arm64/boot/dts/sprd-sc9836-openphone.dts
create mode 100644 arch/arm64/boot/dts/sprd-sc9836.dtsi
create mode 100644 arch/arm64/boot/dts/sprd-sharkl64.dtsi
create mode 100644 drivers/tty/serial/sprd_serial.cSignature · 1 line
1.7.9.5
PATCH v3 1/5 Documentation: DT: Renamed of-serial.txt to 8250.txt
The file of-serial.txt was only for 8250 compatible UART implementations, so renamed it to 8250.txt to avoid confusing other persons. This is recommended by Arnd, see:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/291455.html
---
.../bindings/serial/{of-serial.txt => 8250.txt} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Documentation/devicetree/bindings/serial/{of-serial.txt => 8250.txt} (100%)Documentation/devicetree/bindings/serial/8250.txt renamed from Documentation/devicetree/bindings/serial/of-serial.txt +0 -0
Signature · 1 line
1.7.9.5
Mark Rutland
maintainerRe: [PATCH v3 1/5] Documentation: DT: Renamed of-serial.txt to 8250.txt
Quoted 6 lines · Chunyan Zhang
The file of-serial.txt was only for 8250 compatible UART implementations, so renamed it to 8250.txt to avoid confusing other persons. This is recommended by Arnd, see:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/291455.htmlSigned-off-by Chunyan Zhang <[email protected]>
My prior Ack [1] still applies (given you've just changed the way the patch was generated, as Arnd and I suggested).
Mark.
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/295152.html
Quoted 13 lines
--- .../bindings/serial/{of-serial.txt => 8250.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Documentation/devicetree/bindings/serial/{of-serial.txt => 8250.txt} (100%)Documentation/devicetree/bindings/serial/8250.txt renamed from Documentation/devicetree/bindings/serial/of-serial.txt +0
-0Signature · 1 line
1.7.9.5
Lyra Zhang
reviewerRe: [PATCH v3 1/5] Documentation: DT: Renamed of-serial.txt to 8250.txt
2014-11-27 19:38 GMT+08:00 Mark Rutland <[email protected]>:
Quoted 11 lines · Chunyan Zhang
Quoted 6 lines
The file of-serial.txt was only for 8250 compatible UART implementations, so renamed it to 8250.txt to avoid confusing other persons. This is recommended by Arnd, see:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/291455.htmlSigned-off-by Chunyan Zhang <[email protected]>My prior Ack [1] still applies (given you've just changed the way the patch was generated, as Arnd and I suggested).
OK, I'll add in v4.
Quoted 22 lines
Mark.
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/295152.html
Quoted 10 lines
--- .../bindings/serial/{of-serial.txt => 8250.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Documentation/devicetree/bindings/serial/{of-serial.txt => 8250.txt} (100%)Documentation/devicetree/bindings/serial/8250.txt renamed from Documentation/devicetree/bindings/serial/of-serial.txt +0
-1--Quoted 3 lines
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH v3 2/5 Documentation: DT: Add bindings for Spreadtrum SoC Platform
In reply to Chunyan ZhangAdds Spreadtrum's prefix "sprd" to vendor-prefixes file. Adds the devicetree binding documentations for Spreadtrum's sc9836-uart and SC9836 SoC based on the Sharkl64 Platform which is a 64-bit SoC Platform of Spreadtrum.
--- Documentation/devicetree/bindings/arm/sprd.txt | 11 +++++++++++ .../devicetree/bindings/serial/sprd-uart.txt | 6 ++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 3 files changed, 18 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/sprd.txt create mode 100644 Documentation/devicetree/bindings/serial/sprd-uart.txt
Documentation/devicetree/bindings/arm/sprd.txt new file +11 -0
@@ -0,0 +1,11 @@ +Spreadtrum SoC Platforms Device Tree Bindings +---------------------------------------------------- + +Sharkl64 is a Spreadtrum's SoC Platform which is based +on ARM 64-bit processor. + +SC9836 openphone board with SC9836 SoC based on the +Sharkl64 Platform shall have the following properties. + +Required root node properties: + - compatible = "sprd,sc9836-openphone", "sprd,sc9836";
Documentation/devicetree/bindings/serial/sprd-uart.txt new file +6 -0
@@ -0,0 +1,6 @@ +* Spreadtrum serial UART + +Required properties: +- compatible: must be "sprd,sc9836-uart" +- reg: offset and length of the register set for the device +- interrupts: exactly one interrupt specifier
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -142,6 +142,7 @@ snps Synopsys, Inc. solidrun SolidRun sony Sony Corporation spansion Spansion Inc. +sprd Spreadtrum Communications Inc. st STMicroelectronics ste ST-Ericsson stericsson ST-Ericsson
Signature · 1 line
1.7.9.5
Arnd Bergmann
maintainerRe: [PATCH v3 2/5] Documentation: DT: Add bindings for Spreadtrum SoC Platform
Documentation/devicetree/bindings/serial/sprd-uart.txt line 6
Quoted 13 lines · On Tuesday 25 November 2014 20:16:55 Chunyan Zhang wrote:
Documentation/devicetree/bindings/serial/sprd-uart.txt new file +6
-0@@ -0,0 +1,6 @@ +* Spreadtrum serial UART + +Required properties: +- compatible: must be "sprd,sc9836-uart" +- reg: offset and length of the register set for the device +- interrupts: exactly one interrupt specifier
The driver uses a clock, and the dts file lists a clock property, so it should be documented here, either as optional or mandatory, and with a description what this clock refers to.
Arnd
PATCH v3 3/5 arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
In reply to Chunyan ZhangFrom: Zhizhou Zhang <[email protected]>
Adds the device tree support for Spreadtrum SC9836 SoC which is based on Sharkl64 platform.
Sharkl64 platform contains the common nodes of Spreadtrum's arm64-based SoCs.
--- arch/arm64/boot/dts/Makefile | 1 + arch/arm64/boot/dts/sprd-sc9836-openphone.dts | 85 ++++++++++++++++++++ arch/arm64/boot/dts/sprd-sc9836.dtsi | 103 ++++++++++++++++++++++++ arch/arm64/boot/dts/sprd-sharkl64.dtsi | 105 +++++++++++++++++++++++++ 4 files changed, 294 insertions(+) create mode 100644 arch/arm64/boot/dts/sprd-sc9836-openphone.dts create mode 100644 arch/arm64/boot/dts/sprd-sc9836.dtsi create mode 100644 arch/arm64/boot/dts/sprd-sharkl64.dtsi
arch/arm64/boot/dts/Makefile +1 -0
@@ -1,4 +1,5 @@ dtb-$(CONFIG_ARCH_THUNDER) += thunder-88xx.dtb +dtb-$(CONFIG_ARCH_SHARKL64) += sprd-sc9836-openphone.dtb dtb-$(CONFIG_ARCH_VEXPRESS) += rtsm_ve-aemv8a.dtb foundation-v8.dtb dtb-$(CONFIG_ARCH_XGENE) += apm-mustang.dtb
arch/arm64/boot/dts/sprd-sc9836-openphone.dts new file +85 -0
85 lines not on this page · raw message
arch/arm64/boot/dts/sprd-sc9836.dtsi new file +103 -0
103 lines not on this page · raw message
arch/arm64/boot/dts/sprd-sharkl64.dtsi new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Mark Rutland
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 29 lines · Chunyan Zhang
From: Zhizhou Zhang <[email protected]>
Adds the device tree support for Spreadtrum SC9836 SoC which is based on Sharkl64 platform.
Sharkl64 platform contains the common nodes of Spreadtrum's arm64-based SoCs.
Signed-off-by Zhizhou Zhang <[email protected]>Signed-off-by Chunyan Zhang <[email protected]>Signed-off-by Orson Zhai <[email protected]>--- arch/arm64/boot/dts/Makefile | 1 + arch/arm64/boot/dts/sprd-sc9836-openphone.dts | 85 ++++++++++++++++++++ arch/arm64/boot/dts/sprd-sc9836.dtsi | 103 ++++++++++++++++++++++++ arch/arm64/boot/dts/sprd-sharkl64.dtsi | 105 +++++++++++++++++++++++++ 4 files changed, 294 insertions(+) create mode 100644 arch/arm64/boot/dts/sprd-sc9836-openphone.dts create mode 100644 arch/arm64/boot/dts/sprd-sc9836.dtsi create mode 100644 arch/arm64/boot/dts/sprd-sharkl64.dtsiarch/arm64/boot/dts/Makefile +1
-0@@ -1,4 +1,5 @@ dtb-$(CONFIG_ARCH_THUNDER) += thunder-88xx.dtb +dtb-$(CONFIG_ARCH_SHARKL64) += sprd-sc9836-openphone.dtb dtb-$(CONFIG_ARCH_VEXPRESS) += rtsm_ve-aemv8a.dtb foundation-v8.dtb dtb-$(CONFIG_ARCH_XGENE) += apm-mustang.dtb
[...]
arch/arm64/boot/dts/Makefile
Quoted 9 lines
arch/arm64/boot/dts/Makefile +9
-0+ gic: interrupt-controller@12001000 { + compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic"; + #interrupt-cells = <3>; + interrupt-controller; + reg = <0 0x12001000 0 0x1000>, + <0 0x12002000 0 0x1000>, + <0 0x12004000 0 0x2000>, + <0 0x12006000 0 0x2000>; + };
I believe GICC should be 8KiB here.
arch/arm64/boot/dts/Makefile
Quoted 5 lines
arch/arm64/boot/dts/Makefile +5
-0+ + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + };
Do you have a complete PSCI 0.2 implementation (e.g. are all the mandatory functions implemented)?
I take it CPUs enter the kernel at EL2?
How have you tested this?
arch/arm64/boot/dts/Makefile
Quoted 8 lines
arch/arm64/boot/dts/Makefile +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;
Please remove the clock-frequency property. Your FW should initialise CNTFRQ_EL0 on all CPUs (certainly PSCI 0.2 requires that you do this).
[...]
arch/arm64/boot/dts/Makefile
Quoted 7 lines
arch/arm64/boot/dts/Makefile +7
-0+ clocks { + clk26mhz: clk26mhz { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <26000000>; + }; + };
Get rid of the "clocks" container node. There's no need for it.
Thanks,
Mark.
Catalin Marinas
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 10 lines · Mark Rutland
arch/arm64/boot/dts/sprd-sc9836.dtsi line 101
Quoted 8 lines · Chunyan Zhang
arch/arm64/boot/dts/sprd-sc9836.dtsi new file +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).
Since this comes up regularly, I think we need a dev_warn() in the arch timer driver when CONFIG_ARM64.
Signature · 1 line
Catalin
Mark Rutland
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
arch/arm64/boot/dts/sprd-sc9836.dtsi new file +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.
I'll ack such a patch ;)
Mark.
Catalin Marinas
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
(quoted diff) +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.I'll ack such a patch ;)
How rude would this be?
drivers/clocksource/arm_arch_timer.c +0 -0
@@ -371,7 +371,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)
return;
/* Try to determine the frequency from the device tree or CNTFRQ */
- if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
+ if (IS_ENABLED(CONFIG_ARM64) ||
+ of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
if (cntbase)
arch_timer_rate = readl_relaxed(cntbase + CNTFRQ);
elseMark Rutland
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 29 lines · Catalin Marinas
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
(quoted diff) +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.I'll ack such a patch ;)
How rude would this be?
drivers/clocksource/arm_arch_timer.c +0
-0
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 378
Quoted 9 lines
drivers/clocksource/arm_arch_timer.c +2
-1@@ -371,7 +371,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)return ;/* Try to determine the frequency from the device tree or CNTFRQ */ -if (of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) { +if (IS_ENABLED (CONFIG_ARM64 ) || +of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) {if (cntbase) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ );else
Probably too rude, given it doesn't WARN() the user.
We should be extremely loud if we see the clock-frequency property on an arm64 system. Whether or not we should ignore the property is another matter.
Mark.
Re: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 31 lines · Mark Rutland
Quoted 30 lines · Catalin Marinas
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
(quoted diff) +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.I'll ack such a patch ;)
How rude would this be?
drivers/clocksource/arm_arch_timer.c +0
-0@@ -371,7 +371,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)return ;
Quoted 10 lines
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 378
Quoted 8 lines
drivers/clocksource/arm_arch_timer.c +2
-1/* Try to determine the frequency from the device tree or CNTFRQ */ -if (of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) { +if (IS_ENABLED (CONFIG_ARM64 ) || +of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) {if (cntbase) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ );else Probably too rude, given it doesn't
WARN()the user.
We override broken hardware ID registers all the time in device-tree without dumping stack. Why is this any different?
Quoted 3 lines
We should be extremely loud if we see the clock-frequency property on an arm64 system. Whether or not we should ignore the property is another matter.
I don't really see the point in ignoring it. We will see broken hardware
[1] and this is just preventing ourselves from working around it. I'd much rather have arch-timers with a "clock-frequence" property than have some other timer instead because the kernel driver is being stubborn.
Will
[1] A previous version of the Juno firmware, for example.
Mark Rutland
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 43 lines · Will Deacon
Quoted 31 lines · Mark Rutland
Quoted 30 lines · Catalin Marinas
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
(quoted diff) +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.I'll ack such a patch ;)
How rude would this be?
drivers/clocksource/arm_arch_timer.c +0
-0@@ -371,7 +371,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)return ;Quoted 10 lines
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 378
Quoted 8 lines
drivers/clocksource/arm_arch_timer.c +2
-1/* Try to determine the frequency from the device tree or CNTFRQ */ -if (of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) { +if (IS_ENABLED (CONFIG_ARM64 ) || +of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) {if (cntbase) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ );else Probably too rude, given it doesn't
WARN()the user.
Quoted 2 lines
We override broken hardware ID registers all the time in device-tree without dumping stack. Why is this any different?
Exposure to guests via KVM, and the fact that it's possible to write to the register from EL3. This isn't so much broken HW (which cannot be fixed) as broken FW (which can be fixed).
Printing the warning gives people the chance to realise and fix the issue during bringup.
Mark.
Re: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 44 lines · Mark Rutland
Quoted 43 lines · Will Deacon
Quoted 41 lines · Mark Rutland
Quoted 29 lines · Catalin Marinas
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
(quoted diff) +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.I'll ack such a patch ;)
How rude would this be?
drivers/clocksource/arm_arch_timer.c +0
-0drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 378
Quoted 9 lines
drivers/clocksource/arm_arch_timer.c +2
-1@@ -371,7 +371,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)return ;/* Try to determine the frequency from the device tree or CNTFRQ */ -if (of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) { +if (IS_ENABLED (CONFIG_ARM64 ) || +of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) {if (cntbase) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ );else Probably too rude, given it doesn't
WARN()the user.
Quoted 6 lines
Quoted 2 lines
We override broken hardware ID registers all the time in device-tree without dumping stack. Why is this any different?
Exposure to guests via KVM, and the fact that it's possible to write to the register from EL3. This isn't so much broken HW (which cannot be fixed) as broken FW (which can be fixed).
I think we'll see plenty of systems where vendors are reluctant to offer over-the-air firmware upgrades for issues that can be solved simply by adding a property to the device-tree.
Quoted 2 lines
Printing the warning gives people the chance to realise and fix the issue during bringup.
Print a warning, but don't dump the stack. A simple pr_warn is fine.
Will
Re: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
In reply to Will DeaconQuoted 6 lines · Will Deacon
Quoted 1 line · Mark Rutland
Probably too rude, given it doesn't
WARN()the user.We override broken hardware ID registers all the time in device-tree without dumping stack. Why is this any different?
I do tend to agree that a WARN() is excessive but given the amount of pushback on using this property on ARMv8 systems saying something would be nice, though...
Quoted 8 lines
Quoted 3 lines
We should be extremely loud if we see the clock-frequency property on an arm64 system. Whether or not we should ignore the property is another matter.
I don't really see the point in ignoring it. We will see broken hardware
[1] and this is just preventing ourselves from working around it. I'd much rather have arch-timers with a "clock-frequence" property than have some other timer instead because the kernel driver is being stubborn.
...it is likely that even if there is a warning we'll end up in this situation. If the kernel doesn't complain at all it seems totally reasonable for people to use the feature, but just refusing to allow it to be used at all doesn't seem like it's actually helping things.
Catalin Marinas
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
In reply to Will DeaconQuoted 43 lines · Will Deacon
Quoted 31 lines · Mark Rutland
Quoted 30 lines · Catalin Marinas
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
(quoted diff) +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.I'll ack such a patch ;)
How rude would this be?
drivers/clocksource/arm_arch_timer.c +0
-0@@ -371,7 +371,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)return ;Quoted 10 lines
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 378
Quoted 8 lines
drivers/clocksource/arm_arch_timer.c +2
-1/* Try to determine the frequency from the device tree or CNTFRQ */ -if (of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) { +if (IS_ENABLED (CONFIG_ARM64 ) || +of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) {if (cntbase) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ );else Probably too rude, given it doesn't
WARN()the user.
Quoted 2 lines
We override broken hardware ID registers all the time in device-tree without dumping stack. Why is this any different?
I'm not for dumping the stack, it's not relevant (just more noise).
Quoted 8 lines
Quoted 3 lines
We should be extremely loud if we see the clock-frequency property on an arm64 system. Whether or not we should ignore the property is another matter.
I don't really see the point in ignoring it. We will see broken hardware
[1] and this is just preventing ourselves from working around it. I'd much rather have arch-timers with a "clock-frequence" property than have some other timer instead because the kernel driver is being stubborn.
I agree that sooner or later we'll need a workaround (we already did for Juno). My point is that many consider such overriding behaviour to be the default - i.e. don't bother writing any sane value in CNTFRQ in firmware at boot because Linux can cope without. It gets worse when companies develop their firmware long before starting to upstream kernel patches, so too late to fix it.
Quoted 1 line
[1] A previous version of the Juno firmware, for example.
What about CONFIG_BROKEN_FIRMWARE, default off?
In the meantime I think we can be more tolerant:
drivers/clocksource/arm_arch_timer.c +2 -0
@@ -376,6 +376,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ ); else arch_timer_rate =arch_timer_get_cntfrq (); + }else if (IS_ENABLED (CONFIG_ARM64 )) { +pr_warn ("Architected timer frequency overridden by DT (broken firmware?)\n" ); }/* Check the timer frequency. */
Re: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 65 lines · Catalin Marinas
Quoted 43 lines · Will Deacon
Quoted 31 lines · Mark Rutland
Quoted 30 lines · Catalin Marinas
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Mark Rutland
Quoted 8 lines · Chunyan Zhang
(quoted diff) +8
-0+ + timer { + compatible = "arm,armv8-timer"; + interrupts = <1 13 0xff01>, + <1 14 0xff01>, + <1 11 0xff01>, + <1 10 0xff01>; + clock-frequency = <26000000>;Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Please remove the clock-frequency property. Your FW should initialise
CNTFRQ_EL0on all CPUs (certainly PSCI 0.2 requires that you do this).Since this comes up regularly, I think we need a
dev_warn()in the arch timer driver whenCONFIG_ARM64.I'll ack such a patch ;)
How rude would this be?
drivers/clocksource/arm_arch_timer.c +0
-0@@ -371,7 +371,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)return ;Quoted 10 lines
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 378
Quoted 8 lines
drivers/clocksource/arm_arch_timer.c +2
-1/* Try to determine the frequency from the device tree or CNTFRQ */ -if (of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) { +if (IS_ENABLED (CONFIG_ARM64 ) || +of_property_read_u32 (np,"clock-frequency" , &arch_timer_rate)) {if (cntbase) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ );else Probably too rude, given it doesn't
WARN()the user.Quoted 2 lines
We override broken hardware ID registers all the time in device-tree without dumping stack. Why is this any different?
I'm not for dumping the stack, it's not relevant (just more noise).
Quoted 8 lines
Quoted 3 lines
We should be extremely loud if we see the clock-frequency property on an arm64 system. Whether or not we should ignore the property is another matter.
I don't really see the point in ignoring it. We will see broken hardware
[1] and this is just preventing ourselves from working around it. I'd much rather have arch-timers with a "clock-frequence" property than have some other timer instead because the kernel driver is being stubborn.I agree that sooner or later we'll need a workaround (we already did for Juno). My point is that many consider such overriding behaviour to be the default - i.e. don't bother writing any sane value in CNTFRQ in firmware at boot because Linux can cope without. It gets worse when companies develop their firmware long before starting to upstream kernel patches, so too late to fix it.
Quoted 3 lines
Quoted 1 line
[1] A previous version of the Juno firmware, for example.
What about
CONFIG_BROKEN_FIRMWARE, default off?
I'd rather have a `firmware test' module, which could be as noisy as it likes when it finds issues like this. It could also do things like fuzz the PSCI interface.
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 381
Quoted 13 lines
In the meantime I think we can be more tolerant:
drivers/clocksource/arm_arch_timer.c +2
-0@@ -376,6 +376,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ ); else arch_timer_rate =arch_timer_get_cntfrq (); + }else if (IS_ENABLED (CONFIG_ARM64 )) { +pr_warn ("Architected timer frequency overridden by DT (broken firmware?)\n" ); }
That looks sensible. It would be interesting to print the value of CNTFRQ too.
Will
Mark Rutland
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
In reply to Catalin Marinas[...]
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 381
Quoted 13 lines
In the meantime I think we can be more tolerant:
drivers/clocksource/arm_arch_timer.c +2
-0@@ -376,6 +376,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ ); else arch_timer_rate =arch_timer_get_cntfrq (); + }else if (IS_ENABLED (CONFIG_ARM64 )) { +pr_warn ("Architected timer frequency overridden by DT (broken firmware?)\n" ); }
That looks good to me. On a related note, it looks like my documentation patch [1] from a while back fell by the wayside. Does anyone fancy picking that up to go with this?
Mark.
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-August/282830.html
Catalin Marinas
maintainerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
Quoted 4 lines · Mark Rutland
[...]
Quoted 2 lines
In the meantime I think we can be more tolerant:
Quoted 15 lines
drivers/clocksource/arm_arch_timer.c arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) · line 381
Quoted 11 lines
drivers/clocksource/arm_arch_timer.c +2
-0@@ -376,6 +376,8 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) arch_timer_rate =readl_relaxed (cntbase +CNTFRQ ); else arch_timer_rate =arch_timer_get_cntfrq (); + }else if (IS_ENABLED (CONFIG_ARM64 )) { +pr_warn ("Architected timer frequency overridden by DT (broken firmware?)\n" ); }That looks good to me. On a related note, it looks like my documentation patch [1] from a while back fell by the wayside. Does anyone fancy picking that up to go with this?
I can put the two together (keeping you as author). Do we still need the IS_ENABLED(CONFIG_ARM64) part here or we extend the warning to to arm32 as well?
Signature · 5 lines
Catalin -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Orson Zhai
maintainerPATCH v3 3/5 arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
In reply to Mark RutlandHi, Mark,
Quoted 8 lines · Mark Rutland
Quoted 7 lines
arch/arm64/boot/dts/sprd-sharkl64.dtsi line 104
Quoted 7 lines
arch/arm64/boot/dts/sprd-sharkl64.dtsi new file +7
-0+ clocks { + clk26mhz: clk26mhz { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <26000000>; + }; + };Get rid of the "clocks" container node. There's no need for it.
We are going to add more clk nodes when relative device drivers being committed.
Could we reserve clocks{} here for future use?
Or we remove it now and add it back when needed?
Thanks,
Orson
Quoted 2 lines
Thanks,
Mark.
Lyra Zhang
reviewerRe: [PATCH v3 3/5] arm64: dts: Add support for Spreadtrum SC9836 SoC in dts and Makefile
In reply to Mark RutlandQuoted 11 lines
arch/arm64/boot/dts/sprd-sc9836.dtsi line 88
Quoted 10 lines
arch/arm64/boot/dts/sprd-sc9836.dtsi new file +9
-0+ gic: interrupt-controller@12001000 { + compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic"; + #interrupt-cells = <3>; + interrupt-controller; + reg = <0 0x12001000 0 0x1000>, + <0 0x12002000 0 0x1000>, + <0 0x12004000 0 0x2000>, + <0 0x12006000 0 0x2000>; + };
Quoted 2 lines
I believe GICC should be 8KiB here.
Yes, I'll correct it in next patch.
Quoted 9 lines
arch/arm64/boot/dts/sprd-sc9836.dtsi line 93
Quoted 5 lines
arch/arm64/boot/dts/sprd-sc9836.dtsi new file +5
-0+ + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + };Do you have a complete PSCI 0.2 implementation (e.g. are all the mandatory functions implemented)?
I was using the latest boot-wrapper as the bootloader for test, I'll add a compatible string "arm,psci" in v4.
We'll use u-boot on real hardware, the support for PSCI in our u-boot is in progress.
We're intending to implement psci-0.1 at first, and psci-0.2 for the next step.
Quoted 2 lines
I take it CPUs enter the kernel at EL2?
yes, we've just do like this.
Quoted 1 line
How have you tested this?
I'll test it on the SC9836 FPGA board before next submitting.
Thanks for your patient review.
Chunyan
PATCH v3 4/5 arm64: Add support for Spreadtrum's Sharkl64 Platform in Kconfig and defconfig
In reply to Chunyan ZhangFrom: Zhizhou Zhang <[email protected]>
Adds support for Spreadtrum's SoC Platform and its subset Sharkl64 in the arm64 Kconfig and defconfig files.
--- arch/arm64/Kconfig | 17 +++++++++++++++++ arch/arm64/configs/defconfig | 2 ++ 2 files changed, 19 insertions(+)
arch/arm64/Kconfig +17 -0
@@ -147,6 +147,23 @@ config ARCH_THUNDER help This enables support for Cavium's Thunder Family of SoCs. +menuconfig ARCH_SPRD + bool "Spreadtrum SoC platform" + depends on ARM64 + help + Support for Spreadtrum ARM based SoCs + +if ARCH_SPRD + +config ARCH_SHARKL64 + bool "Sharkl64 SoC Platform" + help + Sharkl64 is a Spreadtrum's SoC Platform which is based + on ARM 64-bit processor core including + sc9836 + +endif #ARCH_SPRD + config ARCH_VEXPRESS bool "ARMv8 software model (Versatile Express)" select ARCH_REQUIRE_GPIOLIB
arch/arm64/configs/defconfig +2 -0
@@ -33,6 +33,8 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set # CONFIG_IOSCHED_DEADLINE is not set CONFIG_ARCH_THUNDER=y +CONFIG_ARCH_SPRD=y +CONFIG_ARCH_SHARKL64=y CONFIG_ARCH_VEXPRESS=y CONFIG_ARCH_XGENE=y CONFIG_PCI=y
Signature · 1 line
1.7.9.5
Arnd Bergmann
maintainerRe: [PATCH v3 4/5] arm64: Add support for Spreadtrum's Sharkl64 Platform in Kconfig and defconfig
Quoted 8 lines · On Tuesday 25 November 2014 20:16:57 Chunyan Zhang wrote:
arch/arm64/Kconfig +7
-0+menuconfig ARCH_SPRD + bool "Spreadtrum SoC platform" + depends on ARM64 + help + Support for Spreadtrum ARM based SoCs + +if ARCH_SPRD
arch/arm64/Kconfig config ARCH_THUNDER · line 166
Quoted 10 lines
arch/arm64/Kconfig +10
-0+ +config ARCH_SHARKL64 + bool "Sharkl64 SoC Platform" + help + Sharkl64 is a Spreadtrum's SoC Platform which is based + on ARM 64-bit processor core including + sc9836 + +endif #ARCH_SPRD +
I don't think we need multiple levels here, it should be enough to have either ARCH_SPRD or ARCH_SHARKL64, because all device drivers are going to be optional anyway. Typically a Kconfig symbol covers all SoCs that are related, so if you Spreadtrum are doing both phone and server chips and these are designed independently, you would have two symbols, but if you only expect to see phone chips here that are all derived from the same product line, using ARCH_SPRD to refer to all of them should be enough.
Arnd
Lyra Zhang
reviewerRe: [PATCH v3 4/5] arm64: Add support for Spreadtrum's Sharkl64 Platform in Kconfig and defconfig
2014-11-25 20:57 GMT+08:00 Arnd Bergmann <[email protected]>:
Quoted 29 lines · On Tuesday 25 November 2014 20:16:57 Chunyan Zhang wrote:
Quoted 8 lines
arch/arm64/Kconfig +7
-0+menuconfig ARCH_SPRD + bool "Spreadtrum SoC platform" + depends on ARM64 + help + Support for Spreadtrum ARM based SoCs + +if ARCH_SPRDarch/arm64/Kconfig config ARCH_THUNDER · line 166
Quoted 10 lines
arch/arm64/Kconfig +10
-0+ +config ARCH_SHARKL64 + bool "Sharkl64 SoC Platform" + help + Sharkl64 is a Spreadtrum's SoC Platform which is based + on ARM 64-bit processor core including + sc9836 + +endif #ARCH_SPRD +I don't think we need multiple levels here, it should be enough to have either
ARCH_SPRDorARCH_SHARKL64, because all device drivers are going to be optional anyway. Typically aKconfigsymbol covers all SoCs that are related, so if you Spreadtrum are doing both phone and server chips and these are designed independently, you would have two symbols, but if you only expect to see phone chips here that are all derived from the same product line, usingARCH_SPRDto refer to all of them should be enough.
Quoted 2 lines
Arnd
For now, we have only one platform(Sharkl64) based on ARM64 been submitted, but we're intending to add support for more our platforms based on ARM64 or ARM32 in the future. There are many common devices on these platforms, such as serial. Our idea would be that if we had a 'menuconfig ARCH_SPRD' in the Kconfig, these common devices only need to depend on ARCH_SPRD in the respective Kconfig, otherwise they may depend on a few Kconfig symbols for every platforms which include these common devices.
So, do you think whether we should define a menuconfig(ARCH_SPRD) in the Kconfig for this case ?
Thanks!
Best regards,
Chunyan
Arnd Bergmann
maintainerRe: [PATCH v3 4/5] arm64: Add support for Spreadtrum's Sharkl64 Platform in Kconfig and defconfig
Quoted 11 lines · On Wednesday 26 November 2014 10:32:35 Lyra Zhang wrote:
For now, we have only one platform(Sharkl64) based on ARM64 been submitted, but we're intending to add support for more our platforms based on ARM64 or ARM32 in the future. There are many common devices on these platforms, such as serial. Our idea would be that if we had a 'menuconfig
ARCH_SPRD' in theKconfig, these common devices only need to depend onARCH_SPRDin the respectiveKconfig, otherwise they may depend on a fewKconfigsymbols for every platforms which include these common devices.So, do you think whether we should define a
menuconfig(ARCH_SPRD)in theKconfigfor this case ?
It sounds like your other platforms are all related, so one ARCH_SPRD should be enough. If someone wants to build a kernel that is only going to run on a particular machine, they can just turn off all the other drivers they don't want.
Arnd
Lyra Zhang
reviewerRe: [PATCH v3 4/5] arm64: Add support for Spreadtrum's Sharkl64 Platform in Kconfig and defconfig
In reply to Arnd Bergmann2014-11-25 20:57 GMT+08:00 Arnd Bergmann <[email protected]>:
Quoted 30 lines · On Tuesday 25 November 2014 20:16:57 Chunyan Zhang wrote:
Quoted 8 lines
arch/arm64/Kconfig +7
-0+menuconfig ARCH_SPRD + bool "Spreadtrum SoC platform" + depends on ARM64 + help + Support for Spreadtrum ARM based SoCs + +if ARCH_SPRDarch/arm64/Kconfig config ARCH_THUNDER · line 166
Quoted 10 lines
arch/arm64/Kconfig +10
-0+ +config ARCH_SHARKL64 + bool "Sharkl64 SoC Platform" + help + Sharkl64 is a Spreadtrum's SoC Platform which is based + on ARM 64-bit processor core including + sc9836 + +endif #ARCH_SPRD +I don't think we need multiple levels here, it should be enough to have either
ARCH_SPRDorARCH_SHARKL64, because all device drivers are going to be optional anyway. Typically aKconfigsymbol covers all SoCs that are related, so if you Spreadtrum are doing both phone and server chips and these are designed independently, you would have two symbols, but if you only expect to see phone chips here that are all derived from the same product line, usingARCH_SPRDto refer to all of them should be enough.
Quoted 1 line
Arnd
For now, we have only one platform(Sharkl64) based on ARM64 been submitted, but we're intending to add support for more our platforms based on ARM64 or ARM32 in the future. There are many common devices on these platforms, such as serial. Our idea would be that if we had a 'menuconfig ARCH_SPRD' in the Kconfig, these common devices only need to depend on ARCH_SPRD in the respective Kconfig, otherwise they may depend on a few Kconfig symbols for every platforms which include these common devices.
So, do you think whether we should define a menuconfig(ARCH_SPRD) in the Kconfig for this case ?
Thanks!
Best regards,
Chunyan
PATCH v3 5/5 tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Chunyan ZhangAdd a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.
--- Documentation/devices.txt | 3 + drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sprd_serial.c | 752 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 5 files changed, 782 insertions(+) create mode 100644 drivers/tty/serial/sprd_serial.c
Documentation/devices.txt +3 -0
@@ -2816,6 +2816,9 @@ Your cooperation is appreciated. 210 = /dev/ttyMAX1 MAX3100 serial port 1 211 = /dev/ttyMAX2 MAX3100 serial port 2 212 = /dev/ttyMAX3 MAX3100 serial port 3 + 213 = /dev/ttySPX0 SPRD serial port 0 + ... + 216 = /dev/ttySPX3 SPRD serial port 3 205 char Low-density serial ports (alternate device) 0 = /dev/culu0 Callout device for ttyLU0
drivers/tty/serial/Kconfig +23 -0
@@ -1573,6 +1573,29 @@ config SERIAL_MEN_Z135 This driver can also be build as a module. If so, the module will be called men_z135_uart.ko +config SERIAL_SPRD + tristate "Support for SPRD serial" + depends on ARCH_SPRD + select SERIAL_CORE + help + This enables the driver for the Spreadtrum's serial. + +config SERIAL_SPRD_NR + int "Maximum number of sprd serial ports" + depends on SERIAL_SPRD + default "4" + +config SERIAL_SPRD_CONSOLE + bool "SPRD UART console support" + depends on SERIAL_SPRD=y + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Support for early debug console using Spreadtrum's serial. This enables + the console before standard serial driver is probed. This is enabled + with "earlycon" on the kernel command line. The console is + enabled when early_param is processed. + endmenu config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_SERIAL_ARC) += arc_uart.o obj-$(CONFIG_SERIAL_RP2) += rp2.o obj-$(CONFIG_SERIAL_FSL_LPUART) += fsl_lpuart.o obj-$(CONFIG_SERIAL_MEN_Z135) += men_z135_uart.o +obj-$(CONFIG_SERIAL_SPRD) += sprd_serial.o # GPIOLIB helpers for modem control lines obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o
drivers/tty/serial/sprd_serial.c new file +752 -0
752 lines not on this page · raw message
include/uapi/linux/serial_core.h +3 -0
@@ -247,4 +247,7 @@/* MESON */ #define PORT_MESON 109 +/* SPRD SERIAL */ +#define PORT_SPRD 110 +#endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 1 line
1.7.9.5
Greg KH
maintainerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 7 lines · Chunyan Zhang
Add a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.Signed-off-by Chunyan Zhang <[email protected]>Signed-off-by Orson Zhai <[email protected]>Originally-by Lanqing Liu <[email protected]>
Some objections:
drivers/tty/serial/sprd_serial.c line 722
Quoted 8 lines
drivers/tty/serial/sprd_serial.c new file +8
-0+static struct platform_driver sprd_platform_driver = { + .probe = sprd_probe, + .remove = sprd_remove, + .suspend = sprd_suspend, + .resume = sprd_resume, + .driver = { + .name ="sprd_serial" , + .owner =THIS_MODULE ,
platform drivers don't need .owner in them anymore, it's handled by the driver core automatically.
drivers/tty/serial/sprd_serial.c line 733
Quoted 11 lines
drivers/tty/serial/sprd_serial.c new file +11
-0+ .of_match_table = of_match_ptr(serial_ids), + }, +}; + +static int __init sprd_serial_init (void ) +{ +int ret =0 ; + + ret =uart_register_driver (&sprd_uart_driver); +if (unlikely (ret !=0 )) +return ret;
NEVER use unlikely unless you can measure the difference without it. And even then, you better be able to justify it. For something as dumb as this type of check, youare working against the complier and cpu which already knows that 0 is the usual response.
So please remove all usages of likely/unlikely in this patch series.
Quoted 24 lines
drivers/tty/serial/sprd_serial.c new file +19
-0+ + ret =platform_driver_register (&sprd_platform_driver); +if (unlikely (ret !=0 )) +uart_unregister_driver (&sprd_uart_driver); + +return ret; +} + +static void __exit sprd_serial_exit(void) +{ +platform_driver_unregister (&sprd_platform_driver); +uart_unregister_driver (&sprd_uart_driver); +} + +module_init (sprd_serial_init); +module_exit (sprd_serial_exit); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Spreadtrum SoC serial driver series" );include/uapi/linux/serial_core.h +0
-0
include/uapi/linux/serial_core.h line 251
Quoted 5 lines
include/uapi/linux/serial_core.h +2
-0@@ -247,4 +247,7 @@/* MESON */ #define PORT_MESON 109 +/* SPRD SERIAL */ +#define PORT_SPRD 110
Please use a tab character here.
Lyra Zhang
reviewerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
2014-11-26 4:03 GMT+08:00 Greg KH <[email protected]>:
Quoted 20 lines · Chunyan Zhang
Quoted 7 lines
Add a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.Signed-off-by Chunyan Zhang <[email protected]>Signed-off-by Orson Zhai <[email protected]>Originally-by Lanqing Liu <[email protected]>Some objections:
drivers/tty/serial/sprd_serial.c line 722
Quoted 8 lines
drivers/tty/serial/sprd_serial.c new file +8
-0+static struct platform_driver sprd_platform_driver = { + .probe = sprd_probe, + .remove = sprd_remove, + .suspend = sprd_suspend, + .resume = sprd_resume, + .driver = { + .name ="sprd_serial" , + .owner =THIS_MODULE ,
Quoted 3 lines
platform drivers don't need .owner in them anymore, it's handled by the driver core automatically.
OK, will remove it in v4.
Quoted 18 lines
drivers/tty/serial/sprd_serial.c line 733
Quoted 12 lines
drivers/tty/serial/sprd_serial.c new file +11
-0+ .of_match_table = of_match_ptr(serial_ids), + }, +}; + +static int __init sprd_serial_init (void ) +{ +int ret =0 ; + + ret =uart_register_driver (&sprd_uart_driver); +if (unlikely (ret !=0 )) +return ret;NEVER use unlikely unless you can measure the difference without it. And even then, you better be able to justify it. For something as dumb as this type of check, youare working against the complier and cpu which already knows that 0 is the usual response.
Quoted 2 lines
So please remove all usages of likely/unlikely in this patch series.
OK, will remove it.
Quoted 27 lines
Quoted 27 lines
drivers/tty/serial/sprd_serial.c new file +19
-0+ + ret =platform_driver_register (&sprd_platform_driver); +if (unlikely (ret !=0 )) +uart_unregister_driver (&sprd_uart_driver); + +return ret; +} + +static void __exit sprd_serial_exit(void) +{ +platform_driver_unregister (&sprd_platform_driver); +uart_unregister_driver (&sprd_uart_driver); +} + +module_init (sprd_serial_init); +module_exit (sprd_serial_exit); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Spreadtrum SoC serial driver series" );include/uapi/linux/serial_core.h +0
-0@@ -247,4 +247,7 @@/* MESON */ #define PORT_MESON 109
Quoted 4 lines
include/uapi/linux/serial_core.h line 251
Quoted 2 lines
include/uapi/linux/serial_core.h +2
-0+/* SPRD SERIAL */ +#define PORT_SPRD 110Please use a tab character here.
OK.
Thanks for your comments!
Chunyan
Re: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Chunyan ZhangQuoted 16 lines · Chunyan Zhang
Add a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.Signed-off-by Chunyan Zhang <[email protected]>Signed-off-by Orson Zhai <[email protected]>Originally-by Lanqing Liu <[email protected]>--- Documentation/devices.txt | 3 + drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sprd_serial.c | 752 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 5 files changed, 782 insertions(+) create mode 100644 drivers/tty/serial/sprd_serial.c
[...]
Quoted 20 lines
drivers/tty/serial/Kconfig +14
-0@@ -1573,6 +1573,29 @@ config SERIAL_MEN_Z135 This driver can also be build as a module. If so, the module will be called men_z135_uart.ko +config SERIAL_SPRD + tristate "Support for SPRD serial" + depends on ARCH_SPRD + select SERIAL_CORE + help + This enables the driver for the Spreadtrum's serial. + +config SERIAL_SPRD_NR + int "Maximum number of sprd serial ports" + depends on SERIAL_SPRD + default "4" + +config SERIAL_SPRD_CONSOLE + bool "SPRD UART console support"
drivers/tty/serial/Kconfig config SERIAL_MEN_Z135 · line 1599
Quoted 10 lines
drivers/tty/serial/Kconfig +9
-0+ depends on SERIAL_SPRD=y + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Support for early debug console using Spreadtrum's serial. This enables + the console before standard serial driver is probed. This is enabled + with "earlycon" on the kernel command line. The console is + enabled when early_param is processed. + endmenu
Please consistently use tabs instead of spaces for indentation. The help text should be indented by one tabe + 2 spaces.
[...]
Quoted 5 lines
drivers/tty/serial/sprd_serial.c new file +0
-0
[...]
drivers/tty/serial/sprd_serial.c line 191
Quoted 2 lines
drivers/tty/serial/sprd_serial.c new file +2
-0+static inline int handle_lsr_errors (struct uart_port *port, +unsigned int *flag,unsigned int *lsr)
This line should be aligned with the opening ( above.
Quoted 22 lines
drivers/tty/serial/sprd_serial.c new file +22
-0+{ +int ret =0 ; + +/* stastics */ +if (*lsr &SPRD_LSR_BI ) { + *lsr &= ~(SPRD_LSR_FE |SPRD_LSR_PE ); + port->icount.brk++; + ret =uart_handle_break (port); +if (ret) +return ret; + }else if (*lsr &SPRD_LSR_PE ) + port->icount.parity++; +else if (*lsr &SPRD_LSR_FE ) + port->icount.frame++; +if (*lsr &SPRD_LSR_OE ) + port->icount.overrun++; + +/* mask off conditions which should be ignored */ + *lsr &= port->read_status_mask; +if (*lsr &SPRD_LSR_BI ) + *flag =TTY_BREAK ; +else if (*lsr &SPRD_LSR_PE )
drivers/tty/serial/sprd_serial.c line 223
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+ *flag =TTY_PARITY ; + else if (*lsr & SPRD_LSR_FE) + *flag = TTY_FRAME; + +return ret; +} + +static inline void sprd_rx (int irq,void *dev_id) +{ +struct uart_port *port = (struct uart_port *)dev_id;
No need to cast a void pointer.
Quoted 21 lines
drivers/tty/serial/sprd_serial.c new file +21
-0+struct tty_port *tty = &port->state->port; +unsigned int ch, flag, lsr, max_count =2048 ; + +while ((serial_in (port,SPRD_STS1 ) &0x00ff ) && max_count--) { + lsr =serial_in (port,SPRD_LSR ); + ch =serial_in (port,SPRD_RXD ); + flag =TTY_NORMAL ; + port->icount.rx++; + +if (unlikely (lsr & (SPRD_LSR_BI |SPRD_LSR_PE + |SPRD_LSR_FE |SPRD_LSR_OE ))) +if (handle_lsr_errors (port, &lsr, &flag)) +continue ; +if (uart_handle_sysrq_char (port, ch)) +continue ; + +uart_insert_char (port, lsr,SPRD_LSR_OE , ch, flag); + } + +tty_flip_buffer_push (tty); +}
[...]
drivers/tty/serial/sprd_serial.c line 514
Quoted 4 lines
drivers/tty/serial/sprd_serial.c new file +4
-0+static void sprd_console_write (struct console *co,const char *s, +unsigned int count) +{ +struct uart_port *port = (struct uart_port *)sprd_port[co->index];
Better explicitly access the .port member of sprd_port[co->index] here instead of casting.
Quoted 22 lines
drivers/tty/serial/sprd_serial.c new file +22
-0+int ien; +int locked =1 ; + +if (oops_in_progress) + locked =spin_trylock (&port->lock); +else +spin_lock (&port->lock); +/* save the IEN then disable the interrupts */ + ien =serial_in (port,SPRD_IEN ); +serial_out (port,SPRD_IEN ,0x0 ); + +uart_console_write (port, s, count, sprd_console_putchar); + +/* wait for transmitter to become empty and restore the IEN */ +wait_for_xmitr (port); +serial_out (port,SPRD_IEN , ien); +if (locked) +spin_unlock (&port->lock); +} + +static int __init sprd_console_setup (struct console *co,char *options) +{
drivers/tty/serial/sprd_serial.c line 546
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+struct uart_port *port; +int baud =115200 ; +int bits =8 ; +int parity ='n' ; +int flow ='n' ; + +if (unlikely (co->index >=UART_NR_MAX || co->index <0 )) + co->index =0 ; + + port = (struct uart_port *)sprd_port[co->index];
Same here, use the .port member of struct sprd_port[co->index].
drivers/tty/serial/sprd_serial.c line 548
Quoted 2 lines
drivers/tty/serial/sprd_serial.c new file +2
-0+if (port ==NULL ) { +pr_info ("srial port %d not yet initialized\n" , co->index);
Typo: should be serial instead of srial.
Quoted 7 lines
drivers/tty/serial/sprd_serial.c new file +7
-0+return -ENODEV ; + } +if (options) +uart_parse_options (options, &baud, &parity, &bits, &flow); + +return uart_set_options (port, co, baud, parity, bits, flow); +}
[...]
Quoted 33 lines
drivers/tty/serial/sprd_serial.c new file +33
-0+static int sprd_probe (struct platform_device *pdev) +{ +struct resource *mem; +struct device_node *np = pdev->dev.of_node; +struct uart_port *up; +struct clk *clk; +int irq; + + +if (np) + pdev->id =of_alias_get_id (np,"serial" ); + +if (unlikely (pdev->id <0 || pdev->id >=UART_NR_MAX )) { +dev_err (&pdev->dev,"does not support id %d\n" , pdev->id); +return -ENXIO ; + } + + sprd_port[pdev->id] =devm_kzalloc (&pdev->dev, +sizeof (*sprd_port[pdev->id]),GFP_KERNEL ); +if (!sprd_port[pdev->id]) +return -ENOMEM ; + + up = (struct uart_port *)sprd_port[pdev->id]; + up->dev = &pdev->dev; + up->line = pdev->id; + up->type =PORT_SPRD ; + up->iotype =SERIAL_IO_PORT ; + up->uartclk =SPRD_DEF_RATE ; + up->fifosize =SPRD_FIFO_SIZE ; + up->ops = &serial_sprd_ops; + up->flags =ASYNC_BOOT_AUTOCONF ; + + clk =devm_clk_get (&pdev->dev,NULL );
drivers/tty/serial/sprd_serial.c line 657
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+if (!IS_ERR (clk)) + up->uartclk =clk_get_rate (clk); + + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (unlikely (!mem)) { +dev_err (&pdev->dev,"not provide mem resource\n" ); +return -ENODEV ; + } + up->mapbase = mem->start; + up->membase =ioremap (mem->start,resource_size (mem));
Return value of ioremap() should be checked for NULL.
Quoted 30 lines
drivers/tty/serial/sprd_serial.c new file +30
-0+ + irq =platform_get_irq (pdev,0 ); +if (unlikely (irq <0 )) { +dev_err (&pdev->dev,"not provide irq resource\n" ); +return -ENODEV ; + } + up->irq = irq; + +platform_set_drvdata (pdev, up); + +return uart_add_one_port (&sprd_uart_driver, up); +} + +static int sprd_remove (struct platform_device *dev) +{ +struct uart_port *up =platform_get_drvdata (dev); + +return uart_remove_one_port (&sprd_uart_driver, up); +} + +static int sprd_suspend (struct platform_device *dev,pm_message_t state) +{ +int id = dev->id; +struct uart_port *port = (struct uart_port *)sprd_port[id]; +struct reg_backup *reg_bak = &(sprd_port[id]->reg_bak); + + reg_bak->ien =serial_in (port,SPRD_IEN ); + reg_bak->ctrl0 =serial_in (port,SPRD_LCR ); + reg_bak->ctrl1 =serial_in (port,SPRD_CTL1 ); + reg_bak->ctrl2 =serial_in (port,SPRD_CTL2 );
drivers/tty/serial/sprd_serial.c line 697
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+ reg_bak->clkd0 =serial_in (port,SPRD_CLKD0 ); + reg_bak->clkd1 =serial_in (port,SPRD_CLKD1 ); + +return 0 ; +} + +static int sprd_resume (struct platform_device *dev) +{ +int id = dev->id; +struct uart_port *port = (struct uart_port *)sprd_port[id];
Access the .port member instead of the cast.
Quoted 11 lines
drivers/tty/serial/sprd_serial.c new file +11
-0+struct reg_backup *reg_bak = &(sprd_port[id]->reg_bak); + +serial_out (port,SPRD_LCR , reg_bak->ctrl0); +serial_out (port,SPRD_CTL1 , reg_bak->ctrl1); +serial_out (port,SPRD_CTL2 , reg_bak->ctrl2); +serial_out (port,SPRD_CLKD0 , reg_bak->clkd0); +serial_out (port,SPRD_CLKD1 , reg_bak->clkd1); +serial_out (port,SPRD_IEN , reg_bak->ien); + +return 0 ; +}
Lyra Zhang
reviewerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
2014-11-26 17:48 GMT+08:00 Tobias Klauser <[email protected]>:
Quoted 3 lines · Chunyan Zhang
Quoted 2 lines
---
[...]
Quoted 8 lines
Quoted 8 lines
drivers/tty/serial/Kconfig +8
-0+ +config SERIAL_SPRD_CONSOLE + bool "SPRD UART console support" + depends on SERIAL_SPRD=y + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Support for early debug console using Spreadtrum's serial. This enables
Quoted 9 lines
drivers/tty/serial/Kconfig config SERIAL_MEN_Z135 · line 1599
Quoted 5 lines
drivers/tty/serial/Kconfig +4
-0+ the console before standard serial driver is probed. This is enabled + with "earlycon" on the kernel command line. The console is + enabled when early_param is processed. + endmenuPlease consistently use tabs instead of spaces for indentation. The help text should be indented by one tabe + 2 spaces.
OK, I will note it later.
[...]
Quoted 5 lines
drivers/tty/serial/sprd_serial.c line 191
Quoted 2 lines
drivers/tty/serial/sprd_serial.c new file +2
-0+static inline int handle_lsr_errors (struct uart_port *port, +unsigned int *flag,unsigned int *lsr)This line should be aligned with the opening ( above.
OK, will change.
Quoted 29 lines
drivers/tty/serial/sprd_serial.c line 223
Quoted 3 lines
drivers/tty/serial/sprd_serial.c new file +3
-0+static inline void sprd_rx (int irq,void *dev_id) +{ +struct uart_port *port = (struct uart_port *)dev_id;No need to cast a void pointer.
drivers/tty/serial/sprd_serial.c line 514
Quoted 4 lines
drivers/tty/serial/sprd_serial.c new file +4
-0+static void sprd_console_write (struct console *co,const char *s, +unsigned int count) +{ +struct uart_port *port = (struct uart_port *)sprd_port[co->index];Better explicitly access the .port member of sprd_port[co->index] here instead of casting.
Quoted 1 line
+ port = (struct
uart_port*)sprd_port[co->index];Same here, use the .port member of struct sprd_port[co->index].
drivers/tty/serial/sprd_serial.c line 548
Quoted 2 lines
drivers/tty/serial/sprd_serial.c new file +2
-0+if (port ==NULL ) { +pr_info ("srial port %d not yet initialized\n" , co->index);Typo: should be serial instead of srial.
drivers/tty/serial/sprd_serial.c line 657
Quoted 2 lines
drivers/tty/serial/sprd_serial.c new file +2
-0+ up->mapbase = mem->start; + up->membase =ioremap (mem->start,resource_size (mem));
Quoted 9 lines
Return value of
ioremap()should be checked for NULL.drivers/tty/serial/sprd_serial.c line 697
Quoted 4 lines
drivers/tty/serial/sprd_serial.c new file +4
-0+static int sprd_resume (struct platform_device *dev) +{ +int id = dev->id; +struct uart_port *port = (struct uart_port *)sprd_port[id];Access the .port member instead of the cast.
OK, will change all of the problems you pointed out in v4. Thanks for your review.
Chunyan
Re: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Chunyan ZhangDocumentation/devices.txt Your cooperation is appreciated. · line 2821
Quoted 3 lines
Documentation/devices.txt +3
-0+ 213 = /dev/ttySPX0 SPRD serial port 0 + ... + 216 = /dev/ttySPX3 SPRD serial port 3
Please use dynamic allocation or give a very very good reason why you can't
drivers/tty/serial/Kconfig config SERIAL_MEN_Z135 · line 1586
Quoted 4 lines
drivers/tty/serial/Kconfig +4
-0+config SERIAL_SPRD_NR + int "Maximum number of sprd serial ports" + depends on SERIAL_SPRD + default "4"
If you are doing dynamic allocation this should pretty much go away
Quoted 5 lines
drivers/tty/serial/sprd_serial.c new file +5
-0+static int sprd_startup (struct uart_port *port) +{ +int ret =0 ; +unsigned int ien, ctrl1; +struct sprd_uart_port *sp;
drivers/tty/serial/sprd_serial.c line 314
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+ +serial_out (port,SPRD_CTL2 , ((THLD_TX_EMPTY <<8 ) |THLD_RX_FULL )); + +/* clear rx fifo */ +while (serial_in (port,SPRD_STS1 ) &0x00ff ) +serial_in (port,SPRD_RXD ); + +/* clear tx fifo */ +while (serial_in (port,SPRD_STS1 ) &0xff00 ) + ;
Missing a cpu_relax and I would have thought a timeout on both of these.
Quoted 5 lines
drivers/tty/serial/sprd_serial.c new file +5
-0+static void sprd_set_termios (struct uart_port *port, +struct ktermios *termios, +struct ktermios *old) +{ +unsigned int baud, quot;
drivers/tty/serial/sprd_serial.c line 397
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +9
-0+/* calculate parity */ + lcr &= ~SPRD_LCR_PARITY ; +if (termios->c_cflag &PARENB ) { + lcr |=SPRD_LCR_PARITY_EN ; +if (termios->c_cflag &PARODD ) + lcr |=SPRD_LCR_ODD_PAR ; +else + lcr |=SPRD_LCR_EVEN_PAR ; + }
If you don't support mark/space parity then also clear CMSPAR in termios->c_cflag. If you do then it ought to be handled above.
drivers/tty/serial/sprd_serial.c line 439
Quoted 6 lines
drivers/tty/serial/sprd_serial.c new file +6
-0+ +/* clock divider bit16~bit20 */ +serial_out (port,SPRD_CLKD1 , (quot &0x1f0000 ) >>16 ); +serial_out (port,SPRD_LCR , lcr); + fc |=0x3e00 |THLD_RX_FULL ; +serial_out (port,SPRD_CTL1 , fc);
Also set the resulting baud back into the termios (see the 8250 termios for an example)
Quoted 4 lines
drivers/tty/serial/sprd_serial.c new file +4
-0+static int __init sprd_console_setup (struct console *co,char *options) +{ +struct uart_port *port; +int baud =115200 ;
drivers/tty/serial/sprd_serial.c line 548
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+int bits =8 ; +int parity ='n' ; +int flow ='n' ; + +if (unlikely (co->index >=UART_NR_MAX || co->index <0 )) + co->index =0 ; + + port = (struct uart_port *)sprd_port[co->index]; +if (port ==NULL ) { +pr_info ("srial port %d not yet initialized\n" , co->index);
Typo
Looks basically sound to me
Alan
Orson Zhai
maintainerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
Hi, Alan,
Thanks for your comments!
Some question for them below,
Quoted 5 lines · One Thousand Gnomes
Documentation/devices.txt Your cooperation is appreciated. · line 2821
Quoted 3 lines
Documentation/devices.txt +3
-0+ 213 = /dev/ttySPX0 SPRD serial port 0 + ... + 216 = /dev/ttySPX3 SPRD serial port 3Please use dynamic allocation or give a very very good reason why you can't
do we just leave the .major & .minor as NULL in struct uart_driver for dynamic allocation?
Quoted 5 lines
drivers/tty/serial/Kconfig config SERIAL_MEN_Z135 · line 1586
Quoted 4 lines
drivers/tty/serial/Kconfig +4
-0+config SERIAL_SPRD_NR + int "Maximum number of sprd serial ports" + depends on SERIAL_SPRD + default "4"If you are doing dynamic allocation this should pretty much go away
I think you mean getting the number of uarts from dt and dynamically allocate their port structure?
Quoted 17 lines
Quoted 6 lines
drivers/tty/serial/sprd_serial.c new file +5
-0+static int sprd_startup (struct uart_port *port) +{ +int ret =0 ; +unsigned int ien, ctrl1; +struct sprd_uart_port *sp;drivers/tty/serial/sprd_serial.c line 314
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+ +serial_out (port,SPRD_CTL2 , ((THLD_TX_EMPTY <<8 ) |THLD_RX_FULL )); + +/* clear rx fifo */ +while (serial_in (port,SPRD_STS1 ) &0x00ff ) +serial_in (port,SPRD_RXD ); + +/* clear tx fifo */ +while (serial_in (port,SPRD_STS1 ) &0xff00 ) + ;Missing a
cpu_relaxand I would have thought a timeout on both of these.
We will add in V4
Quoted 18 lines
Quoted 6 lines
drivers/tty/serial/sprd_serial.c new file +4
-0+static void sprd_set_termios (struct uart_port *port, +struct ktermios *termios, +struct ktermios *old) +{drivers/tty/serial/sprd_serial.c line 397
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+unsigned int baud, quot; +/* calculate parity */ + lcr &= ~SPRD_LCR_PARITY ; +if (termios->c_cflag &PARENB ) { + lcr |=SPRD_LCR_PARITY_EN ; +if (termios->c_cflag &PARODD ) + lcr |=SPRD_LCR_ODD_PAR ; +else + lcr |=SPRD_LCR_EVEN_PAR ; + }If you don't support mark/space parity then also clear CMSPAR in
termios->c_cflag.
just simply use code like "termios->c_cflag &= ~CMSPAR" ?
Quoted 10 lines
If you do then it ought to be handled above.
drivers/tty/serial/sprd_serial.c line 439
Quoted 6 lines
drivers/tty/serial/sprd_serial.c new file +6
-0+ +/* clock divider bit16~bit20 */ +serial_out (port,SPRD_CLKD1 , (quot &0x1f0000 ) >>16 ); +serial_out (port,SPRD_LCR , lcr); + fc |=0x3e00 |THLD_RX_FULL ; +serial_out (port,SPRD_CTL1 , fc);Also set the resulting baud back into the termios (see the 8250 termios for an example)
you mean something like this part ?
/* Don't rewrite B0 */
if (tty_termios_baud_rate(termios)) tty_termios_encode_baud_rate(termios, baud, baud);
Quoted 17 lines
Quoted 6 lines
drivers/tty/serial/sprd_serial.c new file +4
-0+static int __init sprd_console_setup (struct console *co,char *options) +{ +struct uart_port *port; +int baud =115200 ;drivers/tty/serial/sprd_serial.c line 548
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+int bits =8 ; +int parity ='n' ; +int flow ='n' ; + +if (unlikely (co->index >=UART_NR_MAX || co->index <0 )) + co->index =0 ; + + port = (struct uart_port *)sprd_port[co->index]; +if (port ==NULL ) { +pr_info ("srial port %d not yet initialized\n" , co->index);Typo
it will be fixed :)
Thanks,
Orson
Quoted 3 lines
Looks basically sound to me
Alan
Re: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 2 lines
do we just leave the .major & .minor as NULL in struct
uart_driverfor dynamic allocation?
Yes
Quoted 7 lines
Quoted 5 lines
drivers/tty/serial/Kconfig config SERIAL_MEN_Z135 · line 1586
Quoted 4 lines
drivers/tty/serial/Kconfig +4
-0+config SERIAL_SPRD_NR + int "Maximum number of sprd serial ports" + depends on SERIAL_SPRD + default "4"If you are doing dynamic allocation this should pretty much go away
I think you mean getting the number of uarts from dt and dynamically allocate their port structure?
Yes
Quoted 7 lines
Quoted 2 lines
Also set the resulting baud back into the termios (see the 8250 termios for an example)
you mean something like this part ?
/* Don't rewrite B0 */
if (tty_termios_baud_rate(termios))tty_termios_encode_baud_rate(termios, baud, baud);
Exactly.
Alan
Re: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Chunyan ZhangQuoted 101 lines · Chunyan Zhang
Add a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.Signed-off-by Chunyan Zhang<[email protected]>Signed-off-by Orson Zhai<[email protected]>Originally-by Lanqing Liu<[email protected]>--- Documentation/devices.txt | 3 + drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sprd_serial.c | 752 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 5 files changed, 782 insertions(+)create mode 100644
drivers/tty/serial/sprd_serial.cDocumentation/devices.txt +3
-0@@ -2816,6 +2816,9 @@ Your cooperation is appreciated. 210 = /dev/ttyMAX1 MAX3100 serial port 1 211 = /dev/ttyMAX2 MAX3100 serial port 2 212 = /dev/ttyMAX3 MAX3100 serial port 3 + 213 = /dev/ttySPX0 SPRD serial port 0 + ... + 216 = /dev/ttySPX3 SPRD serial port 3 205 char Low-density serial ports (alternate device) 0 = /dev/culu0 Callout device for ttyLU0drivers/tty/serial/Kconfig +23
-0@@ -1573,6 +1573,29 @@ config SERIAL_MEN_Z135 This driver can also be build as a module. If so, the module will be called men_z135_uart.ko +config SERIAL_SPRD + tristate "Support for SPRD serial" + depends on ARCH_SPRD + select SERIAL_CORE + help + This enables the driver for the Spreadtrum's serial. + +config SERIAL_SPRD_NR + int "Maximum number of sprd serial ports" + depends on SERIAL_SPRD + default "4" + +config SERIAL_SPRD_CONSOLE + bool "SPRD UART console support" + depends on SERIAL_SPRD=y + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Support for early debug console using Spreadtrum's serial. This enables + the console before standard serial driver is probed. This is enabled + with "earlycon" on the kernel command line. The console is + enabled when early_param is processed. + endmenu config SERIAL_MCTRL_GPIOdrivers/tty/serial/Makefile +1
-0@@ -93,6 +93,7 @@ obj-$(CONFIG_SERIAL_ARC) += arc_uart.o obj-$(CONFIG_SERIAL_RP2) += rp2.o obj-$(CONFIG_SERIAL_FSL_LPUART) += fsl_lpuart.o obj-$(CONFIG_SERIAL_MEN_Z135) += men_z135_uart.o +obj-$(CONFIG_SERIAL_SPRD) += sprd_serial.o # GPIOLIB helpers for modem control lines obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.odrivers/tty/serial/sprd_serial.c new file +19
-0@@ -0,0 +1,752 @@ +/* +* Copyright (C) 2012 Spreadtrum Communications Inc. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/module.h> +#include <linux/tty.h> +#include <linux/ioport.h> +#include <linux/console.h> +#include <linux/platform_device.h> +#include <linux/tty_flip.h>
drivers/tty/serial/sprd_serial.c line 29
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+#include <linux/serial_core.h> +#include <linux/serial.h> +#include <linux/delay.h> +#include <linux/io.h> +#include <asm/irq.h> +#include <linux/slab.h> +#include <linux/of.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/clk.h>
How about sorting this includes? asm/irq.h go first followed linux/ in alphabatical order?
Quoted 258 lines
drivers/tty/serial/sprd_serial.c new file +258
-0+ +/* device name */ +#define UART_NR_MAX CONFIG_SERIAL_SPRD_NR +#define SPRD_TTY_NAME "ttySPX" +#define SPRD_TTY_MAJOR 204 +#define SPRD_TTY_MINOR_START 213 +#define SPRD_FIFO_SIZE 128 +#define SPRD_DEF_RATE 26000000 + +/* the offset of serial registers and BITs for them */ +/* data registers */ +#define SPRD_TXD 0x0000 +#define SPRD_RXD 0x0004 + +/* line status register and its BITs */ +#define SPRD_LSR 0x0008 +#define SPRD_LSR_OE BIT(4) +#define SPRD_LSR_FE BIT(3) +#define SPRD_LSR_PE BIT(2) +#define SPRD_LSR_BI BIT(7) +#define SPRD_LSR_TX_OVER BIT(15) + +/* data number in TX and RX fifo */ +#define SPRD_STS1 0x000C + +/* interrupt enable register and its BITs */ +#define SPRD_IEN 0x0010 +#define SPRD_IEN_RX_FULL BIT(0) +#define SPRD_IEN_TX_EMPTY BIT(1) +#define SPRD_IEN_BREAK_DETECT BIT(7) +#define SPRD_IEN_TIMEOUT BIT(13) + +/* interrupt clear register */ +#define SPRD_ICLR 0x0014 + +/* line control register */ +#define SPRD_LCR 0x0018 +#define SPRD_LCR_STOP_1BIT 0x10 +#define SPRD_LCR_STOP_2BIT 0x30 +#define SPRD_LCR_DATA_LEN (BIT(2) | BIT(3)) +#define SPRD_LCR_DATA_LEN5 0x0 +#define SPRD_LCR_DATA_LEN6 0x4 +#define SPRD_LCR_DATA_LEN7 0x8 +#define SPRD_LCR_DATA_LEN8 0xc +#define SPRD_LCR_PARITY (BIT(0) | BIT(1)) +#define SPRD_LCR_PARITY_EN 0x2 +#define SPRD_LCR_EVEN_PAR 0x0 +#define SPRD_LCR_ODD_PAR 0x1 + +/* control register 1 */ +#define SPRD_CTL1 0x001C +#define RX_HW_FLOW_CTL_THLD BIT(6) +#define RX_HW_FLOW_CTL_EN BIT(7) +#define TX_HW_FLOW_CTL_EN BIT(8) + +/* fifo threshold register */ +#define SPRD_CTL2 0x0020 +#define THLD_TX_EMPTY 0x40 +#define THLD_RX_FULL 0x40 + +/* config baud rate register */ +#define SPRD_CLKD0 0x0024 +#define SPRD_CLKD1 0x0028 + +/* interrupt mask status register */ +#define SPRD_IMSR 0x002C +#define SPRD_IMSR_RX_FIFO_FULL BIT(0) +#define SPRD_IMSR_TX_FIFO_EMPTY BIT(1) +#define SPRD_IMSR_BREAK_DETECT BIT(7) +#define SPRD_IMSR_TIMEOUT BIT(13) + +struct reg_backup { +uint32_t ien; +uint32_t ctrl0; +uint32_t ctrl1; +uint32_t ctrl2; +uint32_t clkd0; +uint32_t clkd1; +uint32_t dspwait; +}; +struct sprd_uart_port { +struct uart_port port; +struct reg_backup reg_bak; +char name[16 ]; +}; +static struct sprd_uart_port *sprd_port[UART_NR_MAX ] = {NULL }; + +static inline unsigned int serial_in (struct uart_port *port,int offset) +{ +return readl_relaxed (port->membase + offset); +} + +static inline void serial_out (struct uart_port *port,int offset,int value) +{ +writel_relaxed (value, port->membase + offset); +} + +static unsigned int sprd_tx_empty (struct uart_port *port) +{ +if (serial_in (port,SPRD_STS1 )&0xff00 ) +return 0 ; +else +return TIOCSER_TEMT ; +} + +static unsigned int sprd_get_mctrl (struct uart_port *port) +{ +return TIOCM_DSR |TIOCM_CTS ; +} + +static void sprd_set_mctrl (struct uart_port *port,unsigned int mctrl) +{ +/* nothing to do */ +} + +static void sprd_stop_tx (struct uart_port *port) +{ +unsigned int ien, iclr; + + iclr =serial_in (port,SPRD_ICLR ); + ien =serial_in (port,SPRD_IEN ); + + iclr |=SPRD_IEN_TX_EMPTY ; + ien&= ~SPRD_IEN_TX_EMPTY ; + +serial_out (port,SPRD_ICLR , iclr); +serial_out (port,SPRD_IEN , ien); +} + +static void sprd_start_tx (struct uart_port *port) +{ +unsigned int ien; + + ien =serial_in (port,SPRD_IEN ); +if (!(ien&SPRD_IEN_TX_EMPTY )) { + ien |=SPRD_IEN_TX_EMPTY ; +serial_out (port,SPRD_IEN , ien); + } +} + +static void sprd_stop_rx (struct uart_port *port) +{ +unsigned int ien, iclr; + + iclr =serial_in (port,SPRD_ICLR ); + ien =serial_in (port,SPRD_IEN ); + + ien&= ~(SPRD_IEN_RX_FULL |SPRD_IEN_BREAK_DETECT ); + iclr |=SPRD_IEN_RX_FULL |SPRD_IEN_BREAK_DETECT ; + +serial_out (port,SPRD_IEN , ien); +serial_out (port,SPRD_ICLR , iclr); +} + +/* The Sprd serial does not support this function. */ +static void sprd_break_ctl (struct uart_port *port,int break_state) +{ +/* nothing to do */ +} + +static inline int handle_lsr_errors (struct uart_port *port, +unsigned int *flag,unsigned int *lsr) +{ +int ret =0 ; + +/* stastics */ +if (*lsr&SPRD_LSR_BI ) { + *lsr&= ~(SPRD_LSR_FE |SPRD_LSR_PE ); + port->icount.brk++; + ret =uart_handle_break (port); +if (ret) +return ret; + }else if (*lsr&SPRD_LSR_PE ) + port->icount.parity++; +else if (*lsr&SPRD_LSR_FE ) + port->icount.frame++; +if (*lsr&SPRD_LSR_OE ) + port->icount.overrun++; + +/* mask off conditions which should be ignored */ + *lsr&= port->read_status_mask; +if (*lsr&SPRD_LSR_BI ) + *flag =TTY_BREAK ; +else if (*lsr&SPRD_LSR_PE ) + *flag =TTY_PARITY ; +else if (*lsr&SPRD_LSR_FE ) + *flag =TTY_FRAME ; + +return ret; +} + +static inline void sprd_rx (int irq,void *dev_id) +{ +struct uart_port *port = (struct uart_port *)dev_id; +struct tty_port *tty =&port->state->port; +unsigned int ch, flag, lsr, max_count =2048 ; + +while ((serial_in (port,SPRD_STS1 )&0x00ff )&& max_count--) { + lsr =serial_in (port,SPRD_LSR ); + ch =serial_in (port,SPRD_RXD ); + flag =TTY_NORMAL ; + port->icount.rx++; + +if (unlikely (lsr& (SPRD_LSR_BI |SPRD_LSR_PE + |SPRD_LSR_FE |SPRD_LSR_OE ))) +if (handle_lsr_errors (port,&lsr,&flag)) +continue ; +if (uart_handle_sysrq_char (port, ch)) +continue ; + +uart_insert_char (port, lsr,SPRD_LSR_OE , ch, flag); + } + +tty_flip_buffer_push (tty); +} + +static inline void sprd_tx (int irq,void *dev_id) +{ +struct uart_port *port = dev_id; +struct circ_buf *xmit =&port->state->xmit; +int count; + +if (port->x_char) { +serial_out (port,SPRD_TXD , port->x_char); + port->icount.tx++; + port->x_char =0 ; +return ; + } +if (uart_circ_empty (xmit) ||uart_tx_stopped (port)) { +sprd_stop_tx (port); +return ; + } + count =THLD_TX_EMPTY ; +do { +serial_out (port,SPRD_TXD , xmit->buf[xmit->tail]); + xmit->tail = (xmit->tail +1 )& (UART_XMIT_SIZE -1 ); + port->icount.tx++; +if (uart_circ_empty (xmit)) +break ; + }while (--count>0 ); + +if (uart_circ_chars_pending (xmit)<WAKEUP_CHARS ) +uart_write_wakeup (port); + +if (uart_circ_empty (xmit)) +sprd_stop_tx (port); +} + +/* +*this handles the interrupt from one port +*/ +static irqreturn_t sprd_handle_irq (int irq,void *dev_id) +{ +struct uart_port *port = (struct uart_port *)dev_id; +u32 ims; + + ims =serial_in (port,SPRD_IMSR ); +
drivers/tty/serial/sprd_serial.c line 297
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+serial_out (port,SPRD_ICLR , ~0 ); + +if (ims& (SPRD_IMSR_RX_FIFO_FULL | +SPRD_IMSR_BREAK_DETECT |SPRD_IMSR_TIMEOUT )) { +sprd_rx (irq, port); + } +if (ims&SPRD_IMSR_TX_FIFO_EMPTY ) +sprd_tx (irq, port); + +return IRQ_HANDLED ;
You are always returning IRQ_HANDLED and this is registered as a SHARED irq. Is there a chance this handler is called and the irq event doesn't belong to this device?
Murali
Quoted 467 lines
drivers/tty/serial/sprd_serial.c new file +455
-0+} + +static int sprd_startup (struct uart_port *port) +{ +int ret =0 ; +unsigned int ien, ctrl1; +struct sprd_uart_port *sp; + +serial_out (port,SPRD_CTL2 , ((THLD_TX_EMPTY <<8 ) |THLD_RX_FULL )); + +/* clear rx fifo */ +while (serial_in (port,SPRD_STS1 )&0x00ff ) +serial_in (port,SPRD_RXD ); + +/* clear tx fifo */ +while (serial_in (port,SPRD_STS1 )&0xff00 ) + ; + +/* clear interrupt */ +serial_out (port,SPRD_IEN ,0x0 ); +serial_out (port,SPRD_ICLR , ~0 ); + +/* allocate irq */ + sp = container_of(port, struct sprd_uart_port, port); +snprintf (sp->name,sizeof (sp->name),"sprd_serial%d" , port->line); + ret =devm_request_irq (port->dev, port->irq, sprd_handle_irq, +IRQF_SHARED , sp->name, port); +if (ret) { +dev_err (port->dev,"fail to request serial irq %d\n" , + port->irq); +return ret; + } + ctrl1 =serial_in (port,SPRD_CTL1 ); + ctrl1 |=0x3e00 |THLD_RX_FULL ; +serial_out (port,SPRD_CTL1 , ctrl1); + +/* enable interrupt */ +spin_lock (&port->lock); + ien =serial_in (port,SPRD_IEN ); + ien |=SPRD_IEN_RX_FULL |SPRD_IEN_BREAK_DETECT |SPRD_IEN_TIMEOUT ; +serial_out (port,SPRD_IEN , ien); +spin_unlock (&port->lock); + +return 0 ; +} + +static void sprd_shutdown (struct uart_port *port) +{ +serial_out (port,SPRD_IEN ,0x0 ); +serial_out (port,SPRD_ICLR , ~0 ); +devm_free_irq (port->dev, port->irq, port); +} + +static void sprd_set_termios (struct uart_port *port, +struct ktermios *termios, +struct ktermios *old) +{ +unsigned int baud, quot; +unsigned int lcr, fc; + +/* ask the core to calculate the divisor for us */ + baud =uart_get_baud_rate (port, termios, old,1200 ,3000000 ); + + quot = (unsigned int )((port->uartclk + baud /2 ) / baud); + +/* set data length */ + lcr =serial_in (port,SPRD_LCR ); + lcr&= ~SPRD_LCR_DATA_LEN ; +switch (termios->c_cflag&CSIZE ) { +case CS5 : + lcr |=SPRD_LCR_DATA_LEN5 ; +break ; +case CS6 : + lcr |=SPRD_LCR_DATA_LEN6 ; +break ; +case CS7 : + lcr |=SPRD_LCR_DATA_LEN7 ; +break ; +case CS8 : +default : + lcr |=SPRD_LCR_DATA_LEN8 ; +break ; + } + +/* calculate stop bits */ + lcr&= ~(SPRD_LCR_STOP_1BIT |SPRD_LCR_STOP_2BIT ); +if (termios->c_cflag&CSTOPB ) + lcr |=SPRD_LCR_STOP_2BIT ; +else + lcr |=SPRD_LCR_STOP_1BIT ; + +/* calculate parity */ + lcr&= ~SPRD_LCR_PARITY ; +if (termios->c_cflag&PARENB ) { + lcr |=SPRD_LCR_PARITY_EN ; +if (termios->c_cflag&PARODD ) + lcr |=SPRD_LCR_ODD_PAR ; +else + lcr |=SPRD_LCR_EVEN_PAR ; + } + +/* change the port state. */ +/* update the per-port timeout */ +uart_update_timeout (port, termios->c_cflag, baud); + + port->read_status_mask =SPRD_LSR_OE ; +if (termios->c_iflag&INPCK ) + port->read_status_mask |=SPRD_LSR_FE |SPRD_LSR_PE ; +if (termios->c_iflag& (BRKINT |PARMRK )) + port->read_status_mask |=SPRD_LSR_BI ; + +/* characters to ignore */ + port->ignore_status_mask =0 ; +if (termios->c_iflag&IGNPAR ) + port->ignore_status_mask |=SPRD_LSR_PE |SPRD_LSR_FE ; +if (termios->c_iflag&IGNBRK ) { + port->ignore_status_mask |=SPRD_LSR_BI ; +/* +* If we're ignoring parity and break indicators, +* ignore overruns too (for real raw support). +*/ +if (termios->c_iflag&IGNPAR ) + port->ignore_status_mask |=SPRD_LSR_OE ; + } + +/* flow control */ + fc =serial_in (port,SPRD_CTL1 ); + fc&= ~(RX_HW_FLOW_CTL_THLD |RX_HW_FLOW_CTL_EN |TX_HW_FLOW_CTL_EN ); +if (termios->c_cflag&CRTSCTS ) { + fc |=RX_HW_FLOW_CTL_THLD ; + fc |=RX_HW_FLOW_CTL_EN ; + fc |=TX_HW_FLOW_CTL_EN ; + } + +/* clock divider bit0~bit15 */ +serial_out (port,SPRD_CLKD0 , quot&0xffff ); + +/* clock divider bit16~bit20 */ +serial_out (port,SPRD_CLKD1 , (quot&0x1f0000 )>>16 ); +serial_out (port,SPRD_LCR , lcr); + fc |=0x3e00 |THLD_RX_FULL ; +serial_out (port,SPRD_CTL1 , fc); +} + +static const char *sprd_type (struct uart_port *port) +{ +return "SPX" ; +} + +static void sprd_release_port (struct uart_port *port) +{ +/* nothing to do */ +} + +static int sprd_request_port (struct uart_port *port) +{ +return 0 ; +} + +static void sprd_config_port (struct uart_port *port,int flags) +{ +if (flags&UART_CONFIG_TYPE ) + port->type =PORT_SPRD ; +} + +static int sprd_verify_port (struct uart_port *port, +struct serial_struct *ser) +{ +if (unlikely (ser->type !=PORT_SPRD )) +return -EINVAL ; +if (unlikely (port->irq != ser->irq)) +return -EINVAL ; +return 0 ; +} + +static struct uart_ops serial_sprd_ops = { + .tx_empty = sprd_tx_empty, + .get_mctrl = sprd_get_mctrl, + .set_mctrl = sprd_set_mctrl, + .stop_tx = sprd_stop_tx, + .start_tx = sprd_start_tx, + .stop_rx = sprd_stop_rx, + .break_ctl = sprd_break_ctl, + .startup = sprd_startup, + .shutdown = sprd_shutdown, + .set_termios = sprd_set_termios, + .type = sprd_type, + .release_port = sprd_release_port, + .request_port = sprd_request_port, + .config_port = sprd_config_port, + .verify_port = sprd_verify_port, +}; + +#ifdef CONFIG_SERIAL_SPRD_CONSOLE +static inline void wait_for_xmitr (struct uart_port *port) +{ +unsigned int status, tmout =10000 ; + +/* wait up to 10ms for the character(s) to be sent */ +do { + status =serial_in (port,SPRD_STS1 ); +if (--tmout ==0 ) +break ; +udelay (1 ); + }while (status&0xff00 ); +} + +static void sprd_console_putchar (struct uart_port *port,int ch) +{ +wait_for_xmitr (port); +serial_out (port,SPRD_TXD , ch); +} + +static void sprd_console_write (struct console *co,const char *s, +unsigned int count) +{ +struct uart_port *port = (struct uart_port *)sprd_port[co->index]; +int ien; +int locked =1 ; + +if (oops_in_progress) + locked =spin_trylock (&port->lock); +else +spin_lock (&port->lock); +/* save the IEN then disable the interrupts */ + ien =serial_in (port,SPRD_IEN ); +serial_out (port,SPRD_IEN ,0x0 ); + +uart_console_write (port, s, count, sprd_console_putchar); + +/* wait for transmitter to become empty and restore the IEN */ +wait_for_xmitr (port); +serial_out (port,SPRD_IEN , ien); +if (locked) +spin_unlock (&port->lock); +} + +static int __init sprd_console_setup (struct console *co,char *options) +{ +struct uart_port *port; +int baud =115200 ; +int bits =8 ; +int parity ='n' ; +int flow ='n' ; + +if (unlikely (co->index>=UART_NR_MAX || co->index<0 )) + co->index =0 ; + + port = (struct uart_port *)sprd_port[co->index]; +if (port ==NULL ) { +pr_info ("srial port %d not yet initialized\n" , co->index); +return -ENODEV ; + } +if (options) +uart_parse_options (options,&baud,&parity,&bits,&flow); + +return uart_set_options (port, co, baud, parity, bits, flow); +} + +static struct uart_driver sprd_uart_driver; +static struct console sprd_console = { + .name =SPRD_TTY_NAME , + .write = sprd_console_write, + .device = uart_console_device, + .setup = sprd_console_setup, + .flags =CON_PRINTBUFFER , + .index =-1 , + .data =&sprd_uart_driver, +}; + +#define SPRD_CONSOLE (&sprd_console) + +/* Support for earlycon */ +static void sprd_putc (struct uart_port *port,int c) +{ +while (!(readl (port->membase +SPRD_LSR )&SPRD_LSR_TX_OVER )) + ; +writeb (c, port->membase +SPRD_TXD ); +} + +static void sprd_early_write (struct console *con,const char *s, +unsigned n) +{ +struct earlycon_device *dev = con->data; + +uart_console_write (&dev->port, s, n, sprd_putc); +} + +static int __init sprd_early_console_setup ( +struct earlycon_device *device, +const char *opt) +{ +if (!device->port.membase) +return -ENODEV ; + + device->con->write = sprd_early_write; +return 0 ; +} + +EARLYCON_DECLARE (sprd_serial, sprd_early_console_setup); +OF_EARLYCON_DECLARE (sprd_serial,"sprd,sc9836-uart" , + sprd_early_console_setup); + +#else /* !CONFIG_SERIAL_SPRD_CONSOLE */ +#define SPRD_CONSOLE NULL +#endif + +static struct uart_driver sprd_uart_driver = { + .owner =THIS_MODULE , + .driver_name ="sprd_serial" , + .dev_name =SPRD_TTY_NAME , + .major =SPRD_TTY_MAJOR , + .minor =SPRD_TTY_MINOR_START , + .nr =UART_NR_MAX , + .cons =SPRD_CONSOLE , +}; + +static int sprd_probe (struct platform_device *pdev) +{ +struct resource *mem; +struct device_node *np = pdev->dev.of_node; +struct uart_port *up; +struct clk *clk; +int irq; + + +if (np) + pdev->id =of_alias_get_id (np,"serial" ); + +if (unlikely (pdev->id<0 || pdev->id>=UART_NR_MAX )) { +dev_err (&pdev->dev,"does not support id %d\n" , pdev->id); +return -ENXIO ; + } + + sprd_port[pdev->id] =devm_kzalloc (&pdev->dev, +sizeof (*sprd_port[pdev->id]),GFP_KERNEL ); +if (!sprd_port[pdev->id]) +return -ENOMEM ; + + up = (struct uart_port *)sprd_port[pdev->id]; + up->dev =&pdev->dev; + up->line = pdev->id; + up->type =PORT_SPRD ; + up->iotype =SERIAL_IO_PORT ; + up->uartclk =SPRD_DEF_RATE ; + up->fifosize =SPRD_FIFO_SIZE ; + up->ops =&serial_sprd_ops; + up->flags =ASYNC_BOOT_AUTOCONF ; + + clk =devm_clk_get (&pdev->dev,NULL ); +if (!IS_ERR (clk)) + up->uartclk =clk_get_rate (clk); + + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (unlikely (!mem)) { +dev_err (&pdev->dev,"not provide mem resource\n" ); +return -ENODEV ; + } + up->mapbase = mem->start; + up->membase =ioremap (mem->start,resource_size (mem)); + + irq =platform_get_irq (pdev,0 ); +if (unlikely (irq<0 )) { +dev_err (&pdev->dev,"not provide irq resource\n" ); +return -ENODEV ; + } + up->irq = irq; + +platform_set_drvdata (pdev, up); + +return uart_add_one_port (&sprd_uart_driver, up); +} + +static int sprd_remove (struct platform_device *dev) +{ +struct uart_port *up =platform_get_drvdata (dev); + +return uart_remove_one_port (&sprd_uart_driver, up); +} + +static int sprd_suspend (struct platform_device *dev,pm_message_t state) +{ +int id = dev->id; +struct uart_port *port = (struct uart_port *)sprd_port[id]; +struct reg_backup *reg_bak =&(sprd_port[id]->reg_bak); + + reg_bak->ien =serial_in (port,SPRD_IEN ); + reg_bak->ctrl0 =serial_in (port,SPRD_LCR ); + reg_bak->ctrl1 =serial_in (port,SPRD_CTL1 ); + reg_bak->ctrl2 =serial_in (port,SPRD_CTL2 ); + reg_bak->clkd0 =serial_in (port,SPRD_CLKD0 ); + reg_bak->clkd1 =serial_in (port,SPRD_CLKD1 ); + +return 0 ; +} + +static int sprd_resume (struct platform_device *dev) +{ +int id = dev->id; +struct uart_port *port = (struct uart_port *)sprd_port[id]; +struct reg_backup *reg_bak =&(sprd_port[id]->reg_bak); + +serial_out (port,SPRD_LCR , reg_bak->ctrl0); +serial_out (port,SPRD_CTL1 , reg_bak->ctrl1); +serial_out (port,SPRD_CTL2 , reg_bak->ctrl2); +serial_out (port,SPRD_CLKD0 , reg_bak->clkd0); +serial_out (port,SPRD_CLKD1 , reg_bak->clkd1); +serial_out (port,SPRD_IEN , reg_bak->ien); + +return 0 ; +} + +static const struct of_device_id serial_ids[] = { + {.compatible ="sprd,sc9836-uart" ,}, + {} +}; + +static struct platform_driver sprd_platform_driver = { + .probe = sprd_probe, + .remove = sprd_remove, + .suspend = sprd_suspend, + .resume = sprd_resume, + .driver = { + .name ="sprd_serial" , + .owner =THIS_MODULE , + .of_match_table =of_match_ptr (serial_ids), + }, +}; + +static int __init sprd_serial_init (void ) +{ +int ret =0 ; + + ret =uart_register_driver (&sprd_uart_driver); +if (unlikely (ret !=0 )) +return ret; + + ret =platform_driver_register (&sprd_platform_driver); +if (unlikely (ret !=0 )) +uart_unregister_driver (&sprd_uart_driver); + +return ret; +} + +static void __exit sprd_serial_exit(void) +{ +platform_driver_unregister (&sprd_platform_driver); +uart_unregister_driver (&sprd_uart_driver); +} + +module_init (sprd_serial_init); +module_exit (sprd_serial_exit); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Spreadtrum SoC serial driver series" );include/uapi/linux/serial_core.h +3
-0@@ -247,4 +247,7 @@/* MESON */ #define PORT_MESON 109 +/* SPRD SERIAL */ +#define PORT_SPRD 110 +#endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 2 lines
Murali Karicheri Linux Kernel, Texas Instruments
Lyra Zhang
reviewerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 31 lines · Chunyan Zhang
Quoted 4 lines
Add a full sc9836-uart driver for SC9836 SoC which is based on the
+#include<linux/clk.h>
How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?Quoted 7 lines
drivers/tty/serial/sprd_serial.c new file +7
-0+static irqreturn_t sprd_handle_irq (int irq,void *dev_id) +{ +struct uart_port *port = (struct uart_port *)dev_id; +u32 ims; + + ims =serial_in (port,SPRD_IMSR ); +drivers/tty/serial/sprd_serial.c line 297
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+serial_out (port,SPRD_ICLR , ~0 ); + +if (ims& (SPRD_IMSR_RX_FIFO_FULL | +SPRD_IMSR_BREAK_DETECT |SPRD_IMSR_TIMEOUT )) { +sprd_rx (irq, port); + } +if (ims&SPRD_IMSR_TX_FIFO_EMPTY ) +sprd_tx (irq, port); + +return IRQ_HANDLED ;You are always returning
IRQ_HANDLEDand this is registered as a SHARED irq. Is there a chance this handler is called and the irq event doesn't belong to this device?
Quoted 1 line
Murali
You are right, this is not a SHARED irq. I'll pass 0 for irqflags when called 'devm_request_irq' in the next version patch.
Thank you,
Chunyan
Arnd Bergmann
maintainerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 32 lines · On Thursday 27 November 2014 19:59:46 Lyra Zhang wrote:
2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 31 lines · Chunyan Zhang
Quoted 4 lines
Add a full sc9836-uart driver for SC9836 SoC which is based on the
+#include<linux/clk.h>
How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?Quoted 7 lines
drivers/tty/serial/sprd_serial.c new file +7
-0+static irqreturn_t sprd_handle_irq (int irq,void *dev_id) +{ +struct uart_port *port = (struct uart_port *)dev_id; +u32 ims; + + ims =serial_in (port,SPRD_IMSR ); +drivers/tty/serial/sprd_serial.c line 297
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+serial_out (port,SPRD_ICLR , ~0 ); + +if (ims& (SPRD_IMSR_RX_FIFO_FULL | +SPRD_IMSR_BREAK_DETECT |SPRD_IMSR_TIMEOUT )) { +sprd_rx (irq, port); + } +if (ims&SPRD_IMSR_TX_FIFO_EMPTY ) +sprd_tx (irq, port); + +return IRQ_HANDLED ;You are always returning
IRQ_HANDLEDand this is registered as a SHARED irq. Is there a chance this handler is called and the irq event doesn't belong to this device?
Quoted 4 lines
Quoted 1 line
Murali
You are right, this is not a SHARED irq. I'll pass 0 for irqflags when called '
devm_request_irq' in the next version patch.
I think you could also add
if (!ims) return IRQ_NONE;
which would make it work on shared interrupt lines.
Arnd
Lyra Zhang
reviewerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
2014-11-27 20:57 GMT+08:00 Arnd Bergmann <[email protected]>:
Quoted 38 lines · On Thursday 27 November 2014 19:59:46 Lyra Zhang wrote:
Quoted 32 lines
2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 31 lines · Chunyan Zhang
Quoted 4 lines
Add a full sc9836-uart driver for SC9836 SoC which is based on the
+#include<linux/clk.h>
How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?Quoted 7 lines
drivers/tty/serial/sprd_serial.c new file +7
-0+static irqreturn_t sprd_handle_irq (int irq,void *dev_id) +{ +struct uart_port *port = (struct uart_port *)dev_id; +u32 ims; + + ims =serial_in (port,SPRD_IMSR ); +drivers/tty/serial/sprd_serial.c line 297
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+serial_out (port,SPRD_ICLR , ~0 ); + +if (ims& (SPRD_IMSR_RX_FIFO_FULL | +SPRD_IMSR_BREAK_DETECT |SPRD_IMSR_TIMEOUT )) { +sprd_rx (irq, port); + } +if (ims&SPRD_IMSR_TX_FIFO_EMPTY ) +sprd_tx (irq, port); + +return IRQ_HANDLED ;You are always returning
IRQ_HANDLEDand this is registered as a SHARED irq. Is there a chance this handler is called and the irq event doesn't belong to this device?Quoted 4 lines
Quoted 1 line
Murali
You are right, this is not a SHARED irq. I'll pass 0 for irqflags when called '
devm_request_irq' in the next version patch.
Quoted 8 lines
I think you could also add
if (!ims) return IRQ_NONE;which would make it work on shared interrupt lines.
Arnd
Yes, I saw this way in other serial drivers. But, if then, there are two questions for me:
1. Why did some serial drivers need an UN_SHARED irq?
2. How can we choose a right way?
Thank you!
Best regards,
Chunyan
Re: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 4 lines
Yes, I saw this way in other serial drivers. But, if then, there are two questions for me:
1. Why did some serial drivers need anUN_SHAREDirq?
2. How can we choose a right way?
If your hardware can support sharing an IRQ then shared is the right way
- along with the test Arnd suggested. Some hardware lacks the needed facilities to handle shared interrupt.
Alan
Arnd Bergmann
maintainerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Lyra ZhangQuoted 4 lines · On Thursday 27 November 2014 23:23:17 Lyra Zhang wrote:
Yes, I saw this way in other serial drivers. But, if then, there are two questions for me:
1. Why did some serial drivers need anUN_SHAREDirq?
A lot of drivers were written before we had shared IRQs, or were copied from old drivers, or are for hardware that uses edge-triggered interrupts instead of level-triggered interrupts.
Only level-triggered interrupts can be shared.
Quoted 1 line
2. How can we choose a right way?
It never hurts to implement a shared interrupt handler. Only if you have no way to find out whether the device triggered the interrupt or not you have to leave out IRQF_SHARED, and then you won't be able to return IRQ_NONE.
Arnd
Lyra Zhang
reviewerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Murali Karicheri2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 36 lines · Chunyan Zhang
Quoted 34 lines
Add a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.[...]
+++
b/drivers/tty/serial/sprd_serial.cdrivers/tty/serial/sprd_serial.c new file +23
-0@@ -0,0 +1,752 @@ +/* +* Copyright (C) 2012 Spreadtrum Communications Inc. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/module.h> +#include <linux/tty.h> +#include <linux/ioport.h> +#include <linux/console.h> +#include <linux/platform_device.h> +#include <linux/tty_flip.h> +#include <linux/serial_core.h> +#include <linux/serial.h> +#include <linux/delay.h> +#include <linux/io.h>
Quoted 8 lines
Review line 29
Quoted 6 lines
(quoted diff) +6
-0+#include<asm/irq.h> +#include<linux/slab.h> +#include<linux/of.h> +#include<linux/kernel.h> +#include<linux/slab.h> +#include<linux/clk.h>How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?
There are a few compile warnings if I moved asm/irq.h to the top of all included files.
Warning details are below:
In file included from drivers/tty/serial/sprd_serial.c:14:0:./arch/arm64/include/asm/irq.h:6:39: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]
extern void (*handle_arch_irq)(struct pt_regs *);
^./arch/arm64/include/asm/irq.h:6:39: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]./arch/arm64/include/asm/irq.h:8:54: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]
extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
Thanks,
Chunyan
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnd Bergmann
maintainerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 5 lines · On Wednesday 03 December 2014 17:17:13 Lyra Zhang wrote:
2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 1 line
How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?There are a few compile warnings if I moved
asm/irq.hto the top of all included files.
The order that Murali meant is
- first all linux/*.h headers, sorted alphabetically
- then all asm/*.h headers, again sorted alphabetically
This is the recommended style in general.
Quoted 5 lines
Warning details are below:
In file included from
drivers/tty/serial/sprd_serial.c:14:0:./arch/arm64/include/asm/irq.h:6:39: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]
Quoted 9 lines
extern void (*handle_arch_irq)(struct pt_regs *); ^
./arch/arm64/include/asm/irq.h:6:39: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]./arch/arm64/include/asm/irq.h:8:54: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]
extern voidset_handle_irq(void (*handle_irq)(struct pt_regs *));
I would consider this a (minor) bug in asm/irq.h. If you don't mind, please submit a patch to add a line with 'struct pt_regs;' to asm/irq.h.
Arnd
Re: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 30 lines · Arnd Bergmann
Quoted 5 lines · On Wednesday 03 December 2014 17:17:13 Lyra Zhang wrote:
2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 1 line
How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?There are a few compile warnings if I moved
asm/irq.hto the top of all included files.The order that Murali meant is
- first all linux/*.h headers, sorted alphabetically
- then all asm/*.h headers, again sorted alphabeticallyThis is the recommended style in general.
Quoted 5 lines
Warning details are below:
In file included from
drivers/tty/serial/sprd_serial.c:14:0:./arch/arm64/include/asm/irq.h:6:39: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]Quoted 9 lines
extern void (*handle_arch_irq)(struct pt_regs *); ^
./arch/arm64/include/asm/irq.h:6:39: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]./arch/arm64/include/asm/irq.h:8:54: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]
extern voidset_handle_irq(void (*handle_irq)(struct pt_regs *));
Quoted 3 lines
I would consider this a (minor) bug in
asm/irq.h. If you don't mind, please submit a patch to add a line with 'structpt_regs;' toasm/irq.h.
A better question is: why is a modern driver using asm/irq.h in the first place.
We used to include that file when platforms defined IRQ numbers statically, but modern platforms don't do that, so it shouldn't be required anymore.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.
Lyra Zhang
reviewerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
2014-12-03 18:11 GMT+08:00 Russell King - ARM Linux <linux-lFZ/[email protected]>:
Quoted 35 lines · Arnd Bergmann
Quoted 30 lines · On Wednesday 03 December 2014 17:17:13 Lyra Zhang wrote:
Quoted 6 lines
2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 1 line
How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?There are a few compile warnings if I moved
asm/irq.hto the top of all included files.The order that Murali meant is
- first all linux/*.h headers, sorted alphabetically
- then all asm/*.h headers, again sorted alphabeticallyThis is the recommended style in general.
Quoted 5 lines
Warning details are below:
In file included from
drivers/tty/serial/sprd_serial.c:14:0:./arch/arm64/include/asm/irq.h:6:39: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]Quoted 9 lines
extern void (*handle_arch_irq)(struct pt_regs *); ^
./arch/arm64/include/asm/irq.h:6:39: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]./arch/arm64/include/asm/irq.h:8:54: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]
extern voidset_handle_irq(void (*handle_irq)(struct pt_regs *));Quoted 3 lines
I would consider this a (minor) bug in
asm/irq.h. If you don't mind, please submit a patch to add a line with 'structpt_regs;' toasm/irq.h.
Quoted 7 lines
A better question is: why is a modern driver using
asm/irq.hin the first place.We used to include that file when platforms defined IRQ numbers statically, but modern platforms don't do that, so it shouldn't be required anymore.
OK, I see. I'll remove it in v4.
I'm very sorry that I didn't check it carefully enough and troubled many people for this problem.
This file included the asm/irq.h before I revised it for upstreaming, I also could not find this file was no longer needed to include. Thank you for your reminder, I'll avoid making the same mistake, and I'll also share my experience with my colleagues to keep them from having this mistake in the future.
Best regards,
Chunyan
Lyra Zhang
reviewerRe: [PATCH v3 5/5] tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Arnd Bergmann2014-12-03 17:50 GMT+08:00 Arnd Bergmann <[email protected]>:
Quoted 30 lines · On Wednesday 03 December 2014 17:17:13 Lyra Zhang wrote:
Quoted 6 lines
2014-11-27 2:29 GMT+08:00 Murali Karicheri <[email protected]>:
Quoted 1 line
How about sorting this includes?
asm/irq.hgo first followed linux/ in alphabatical order?There are a few compile warnings if I moved
asm/irq.hto the top of all included files.The order that Murali meant is
- first all linux/*.h headers, sorted alphabetically
- then all asm/*.h headers, again sorted alphabeticallyThis is the recommended style in general.
Quoted 5 lines
Warning details are below:
In file included from
drivers/tty/serial/sprd_serial.c:14:0:./arch/arm64/include/asm/irq.h:6:39: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]Quoted 9 lines
extern void (*handle_arch_irq)(struct pt_regs *); ^
./arch/arm64/include/asm/irq.h:6:39: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]./arch/arm64/include/asm/irq.h:8:54: warning: ‘struct pt_regs’ declared inside parameter list [enabled by default]
extern voidset_handle_irq(void (*handle_irq)(struct pt_regs *));
Quoted 3 lines
I would consider this a (minor) bug in
asm/irq.h. If you don't mind, please submit a patch to add a line with 'structpt_regs;' toasm/irq.h.
OK, I would like to send another separate patch for this.
Best regards,
Chunyan
Quoted 7 lines
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 5 lines · Chunyan Zhang
Spreadtrum is a rapid growing chip vendor providing smart phone total solutions.
Sharkl64 Platform is nominated as a SoC infrastructure that supports 4G/3G/2G standards based on ARMv8 multiple core architecture.Now we have only one SoC(SC9836) based on this Platform in developing.
This series is being sent to both my work and upstream addresses - please don't do that, send it to just one (normally my upstream one for upstream work).
Arnd Bergmann
maintainerQuoted 6 lines · On Tuesday 25 November 2014 20:16:53 Chunyan Zhang wrote:
Spreadtrum is a rapid growing chip vendor providing smart phone total solutions.
Sharkl64 Platform is nominated as a SoC infrastructure that supports 4G/3G/2G standards based on ARMv8 multiple core architecture.Now we have only one SoC(SC9836) based on this Platform in developing.
Quoted 8 lines
This patchset adds Sharkl64 support in arm64 device tree and the serial driver of SC9836-UART.
This patchset also has patches which address "sprd" prefix and DT compatible strings for nodes which appear un-documented.
This version code was tesed on Fast Mode.
We use boot-wrapper-aarch64 as the bootloader.
Looks very good overall. I have two small comments to individual patches, but I think we can still merge them for 3.19. Please send the serial driver to Greg for inclusion, unless you get further comments, and send the updated version of the other patches to [email protected] and ask for including them in the cover letter.
Arnd
Mark Rutland
maintainerHi,
Quoted 6 lines · Chunyan Zhang
Spreadtrum is a rapid growing chip vendor providing smart phone total solutions.
Sharkl64 Platform is nominated as a SoC infrastructure that supports 4G/3G/2G standards based on ARMv8 multiple core architecture.Now we have only one SoC(SC9836) based on this Platform in developing.
Quoted 7 lines
This patchset adds Sharkl64 support in arm64 device tree and the serial driver of SC9836-UART.
This patchset also has patches which address "sprd" prefix and DT compatible strings for nodes which appear un-documented.
This version code was tesed on Fast Mode.
This concerns me a bit because fast models are extremely lenient w.r.t. the management of clocks and regulators. Are you sure you have everything you need for your UART described?
Quoted 1 line
We use boot-wrapper-aarch64 as the bootloader.
Which version of boot-wrapper-aarch64 are you using?
Upstream does not implement PSCI 0.2, but its --enable-psci option will inject PSCI 0.1 compatible properties, which leads me to suspect that your DT is misleading. The boot wrapper should also program CNTFRQ_EL0 correctly regardless.
What do you intend to use on real hardware?
Thanks,
Mark.
Quoted 61 lines
Changes from v2:
* Addressed review comments:
- Added a specific compitible string 'sc9836-uart' for the serial
- Added a full serial driver
- Added the property 'clock-frequency' for timer node in dtsi.
- Replaceed the old macro prefix 'UART_' with 'SPRD_' in the Spreadtrum serial driver code.
* Revised the name of SoC and board from 'sharkl3' to 'sc9836'
* Used dual-license for DTS files
* Added a menuconfig 'ARCH_SPRD' inarch/arm64/KconfigChanges from v1:
* Addressed review comments:
- Added "sprd" prefix to vendor-prefixes.txt
- Createdserial/sprd-serial.txtand remove the properties for serial-sprd from of-serial.txt to it.
- Renamed of-serial.txt to 8250.txt according to Arnd's review comments
- Splited and revised .dts for Sharkl64 Platform
- Changed to PSCI method for cpu power management
- RevisedKconfigMakefileto match the alphabetical ordering
- Renamedserial-sprd-earlycon.ctoserial-sprd.cChunyan Zhang (3):
Documentation: DT: Renamed of-serial.txt to 8250.txt
Documentation: DT: Add bindings for Spreadtrum SoC Platform tty/serial: Add Spreadtrum sc9836-uart driver supportZhizhou Zhang (2):
arm64: dts: Add support for Spreadtrum SC9836 SoC in dts andMakefile
arm64: Add support for Spreadtrum's Sharkl64 Platform inKconfigand
defconfigDocumentation/devices.txt | 3 + Documentation/devicetree/bindings/arm/sprd.txt | 11 + .../bindings/serial/{of-serial.txt => 8250.txt} | 0 .../devicetree/bindings/serial/sprd-uart.txt | 6 + .../devicetree/bindings/vendor-prefixes.txt | 1 + arch/arm64/Kconfig | 17 + arch/arm64/boot/dts/Makefile | 1 + arch/arm64/boot/dts/sprd-sc9836-openphone.dts | 85 +++ arch/arm64/boot/dts/sprd-sc9836.dtsi | 103 +++ arch/arm64/boot/dts/sprd-sharkl64.dtsi | 105 +++ arch/arm64/configs/defconfig | 2 + drivers/tty/serial/Kconfig | 23 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sprd_serial.c | 752 ++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 15 files changed, 1113 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/sprd.txt rename Documentation/devicetree/bindings/serial/{of-serial.txt => 8250.txt} (100%) create mode 100644 Documentation/devicetree/bindings/serial/sprd-uart.txt create mode 100644 arch/arm64/boot/dts/sprd-sc9836-openphone.dts create mode 100644 arch/arm64/boot/dts/sprd-sc9836.dtsi create mode 100644 arch/arm64/boot/dts/sprd-sharkl64.dtsi create mode 100644 drivers/tty/serial/sprd_serial.cSignature · 1 line
1.7.9.5