Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1440043 > unrolled thread
| Started by | Wan Zongshun <vw@iommu.org> |
|---|---|
| First post | 2016-07-10 09:30 +0200 |
| Last post | 2016-07-12 00:20 +0200 |
| Articles | 20 on this page of 31 — 7 participants |
Back to article view | Back to linux.kernel
[PATCH v2 00/10] ARM: NUC900: Add NUC970 SoC support Wan Zongshun <vw@iommu.org> - 2016-07-10 09:30 +0200
[PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support Wan Zongshun <vw@iommu.org> - 2016-07-10 09:30 +0200
Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support Arnd Bergmann <arnd@arndb.de> - 2016-07-11 00:10 +0200
Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support Arnd Bergmann <arnd@arndb.de> - 2016-07-11 18:10 +0200
Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support Wan Zongshun <vw@iommu.org> - 2016-07-12 06:40 +0200
Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support Wan Zongshun <vw@iommu.org> - 2016-07-12 09:20 +0200
Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support Arnd Bergmann <arnd@arndb.de> - 2016-07-12 10:30 +0200
[PATCH v2 03/10] Clocksource: add nuc970 clocksource driver Wan Zongshun <vw@iommu.org> - 2016-07-10 09:30 +0200
Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver Arnd Bergmann <arnd@arndb.de> - 2016-07-11 17:40 +0200
Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver Wan Zongshun <vw@iommu.org> - 2016-07-12 09:40 +0200
Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver Arnd Bergmann <arnd@arndb.de> - 2016-07-12 10:30 +0200
Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver Arnd Bergmann <arnd@arndb.de> - 2016-07-21 15:00 +0200
Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-07-21 15:00 +0200
[PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Wan Zongshun <vw@iommu.org> - 2016-07-10 09:30 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Paul Gortmaker <paul.gortmaker@windriver.com> - 2016-07-11 00:00 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Wan Zongshun <vw@iommu.org> - 2016-07-11 04:20 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Arnd Bergmann <arnd@arndb.de> - 2016-07-11 17:50 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Wan Zongshun <vw@iommu.org> - 2016-07-12 09:10 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Arnd Bergmann <arnd@arndb.de> - 2016-07-12 10:30 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Wan Zongshun <vw@iommu.org> - 2016-07-14 11:00 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Arnd Bergmann <arnd@arndb.de> - 2016-07-14 13:20 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Jason Cooper <jason@lakedaemon.net> - 2016-07-13 22:10 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Wan Zongshun <vw@iommu.org> - 2016-07-14 05:40 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Jason Cooper <jason@lakedaemon.net> - 2016-07-14 16:00 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Wan Zongshun <vw@iommu.org> - 2016-07-15 07:20 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Arnd Bergmann <arnd@arndb.de> - 2016-07-15 09:10 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Wan ZongShun <mcuos.com@gmail.com> - 2016-07-15 11:50 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Jason Cooper <jason@lakedaemon.net> - 2016-07-15 17:50 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Arnd Bergmann <arnd@arndb.de> - 2016-07-21 13:00 +0200
Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 Jason Cooper <jason@lakedaemon.net> - 2016-07-21 20:50 +0200
Re: [PATCH v2 04/10] clk: add Clock driver for nuc970 Michael Turquette <mturquette@baylibre.com> - 2016-07-12 00:20 +0200
Page 1 of 2 [1] 2 Next page →
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-10 09:30 +0200 |
| Subject | [PATCH v2 00/10] ARM: NUC900: Add NUC970 SoC support |
| Message-ID | <rThlD-5X6-3@gated-at.bofh.it> |
Hi, This patch series added Nuvoton new SoC NUC970 development board support, this nuc970 belongs to nuc900 series, but many features are not compatible with old nuc900 SoCs like nuc910, nuc920. Those patches are basing on old w90x900 codes, and are using standard linux subsystem interface, such as dts, driver/clk, driver/clocksource , driver/irqchip drivers. The old w90x900 plat such as nuc910,nuc960 codes will also be changed to new style according to nuc970 codes after those patches was accepted. PATCH V2: The V2 patches change some code style, re-archtect some drivers and add reset and soc drivers, split some dts patches according to maillist's comments. Wan Zongshun (10): ARM: NUC900: Add nuc970 machine support irqchip: add irqchip driver for nuc900 Clocksource: add nuc970 clocksource driver clk: add Clock driver for nuc970 power/reset: Add reset driver support for nuc900 soc: Add SoC specific driver support for nuc900 ARM: dts: Add clock header file into dt-bindings ARM: dts: nuc900: Add nuc970 dts files Documentation: devicetree: Add dts description for nuc900 nuc900: add nuc970 platform defconfig file .../devicetree/bindings/arm/nuvoton/nuc970.txt | 12 + .../bindings/clock/nuvoton,nuc970-clk.txt | 13 + .../interrupt-controller/nuvoton,nuc900-aic.txt | 15 + .../bindings/reset/nuvoton,nuc900-reset.txt | 12 + .../devicetree/bindings/serial/nuc970-uart.txt | 22 + .../bindings/soc/nuvoton/nuvoton,nuc900-soc.txt | 12 + .../bindings/timer/nuvoton,nuc970-tmr.txt | 20 + arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/nuc970-evb.dts | 34 + arch/arm/boot/dts/nuc970.dtsi | 88 ++ arch/arm/configs/nuc970_defconfig | 76 ++ arch/arm/mach-w90x900/Kconfig | 20 + arch/arm/mach-w90x900/Makefile | 3 + arch/arm/mach-w90x900/include/mach/irqs.h | 5 + arch/arm/mach-w90x900/nuc900.c | 41 + drivers/clk/Makefile | 1 + drivers/clk/nuc900/Makefile | 6 + drivers/clk/nuc900/clk-apll.c | 168 ++++ drivers/clk/nuc900/clk-ccf.h | 53 ++ drivers/clk/nuc900/clk-nuc970.c | 925 +++++++++++++++++++++ drivers/clk/nuc900/clk-upll.c | 83 ++ drivers/clocksource/Kconfig | 8 + drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-nuc900.c | 305 +++++++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-nuc900.c | 150 ++++ drivers/power/reset/Kconfig | 7 + drivers/power/reset/Makefile | 1 + drivers/power/reset/nuc900-reset.c | 93 +++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/nuvoton/Kconfig | 10 + drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/soc-nuc900.c | 100 +++ include/dt-bindings/clock/nuc970-clock.h | 233 ++++++ 35 files changed, 2522 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/nuvoton/nuc970.txt create mode 100644 Documentation/devicetree/bindings/clock/nuvoton,nuc970-clk.txt create mode 100644 Documentation/devicetree/bindings/interrupt-controller/nuvoton,nuc900-aic.txt create mode 100644 Documentation/devicetree/bindings/reset/nuvoton,nuc900-reset.txt create mode 100644 Documentation/devicetree/bindings/serial/nuc970-uart.txt create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,nuc900-soc.txt create mode 100644 Documentation/devicetree/bindings/timer/nuvoton,nuc970-tmr.txt create mode 100644 arch/arm/boot/dts/nuc970-evb.dts create mode 100644 arch/arm/boot/dts/nuc970.dtsi create mode 100644 arch/arm/configs/nuc970_defconfig create mode 100644 arch/arm/mach-w90x900/nuc900.c create mode 100644 drivers/clk/nuc900/Makefile create mode 100644 drivers/clk/nuc900/clk-apll.c create mode 100644 drivers/clk/nuc900/clk-ccf.h create mode 100644 drivers/clk/nuc900/clk-nuc970.c create mode 100644 drivers/clk/nuc900/clk-upll.c create mode 100644 drivers/clocksource/timer-nuc900.c create mode 100644 drivers/irqchip/irq-nuc900.c create mode 100644 drivers/power/reset/nuc900-reset.c create mode 100644 drivers/soc/nuvoton/Kconfig create mode 100644 drivers/soc/nuvoton/Makefile create mode 100644 drivers/soc/nuvoton/soc-nuc900.c create mode 100644 include/dt-bindings/clock/nuc970-clock.h -- 2.7.4
[toc] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-10 09:30 +0200 |
| Subject | [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support |
| Message-ID | <rThlD-5X6-17@gated-at.bofh.it> |
| In reply to | #1440043 |
NUC970 is a new SoC of Nuvoton nuc900 series, this patch is
to add machine file support for it.
Signed-off-by: Wan Zongshun <mcuos.com@gmail.com>
---
arch/arm/mach-w90x900/Kconfig | 20 ++++++++++++++++++++
arch/arm/mach-w90x900/Makefile | 3 +++
arch/arm/mach-w90x900/nuc900.c | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 arch/arm/mach-w90x900/nuc900.c
diff --git a/arch/arm/mach-w90x900/Kconfig b/arch/arm/mach-w90x900/Kconfig
index 69bab32..80ab00c 100644
--- a/arch/arm/mach-w90x900/Kconfig
+++ b/arch/arm/mach-w90x900/Kconfig
@@ -15,6 +15,26 @@ config CPU_NUC960
help
Support for NUCP960 of Nuvoton NUC900 CPUs.
+config SOC_NUC970
+ bool "Nuvoton NUC970 SoC support"
+ select COMMON_CLK
+ select GENERIC_IRQ_CHIP
+ select HAVE_CLK_PREPARE
+ select IRQ_DOMAIN
+ select MULTI_IRQ_HANDLER
+ select MFD_SYSCON
+ select NUC900_TIMER
+ select SOC_NUC900
+ select USE_OF
+ help
+ Support for NUC970 of Nuvoton NUC900 SoCs.
+ The NUC970 series runs up to 300 MHz, with 16 KB I-cache,
+ 16 KB D-cache and MMU, 56KB embedded SRAM and 16 KB Internal
+ Boot ROM for booting from USB, NAND and SPI FLASH.
+ Detailed information please check the following link:
+ https://github.com/zswan/nuc900-document/blob/master/
+ NUC970_TechnicalReferenceManual_EN_Rev1.30.pdf
+
menu "W90P910 Machines"
config MACH_W90P910EVB
diff --git a/arch/arm/mach-w90x900/Makefile b/arch/arm/mach-w90x900/Makefile
index 828c032..d13ba5a 100644
--- a/arch/arm/mach-w90x900/Makefile
+++ b/arch/arm/mach-w90x900/Makefile
@@ -4,8 +4,10 @@
# Object file lists.
+ifeq ($(CONFIG_SOC_NUC970),)
obj-y := irq.o time.o mfp.o gpio.o clock.o
obj-y += clksel.o dev.o cpu.o
+endif
# W90X900 CPU support files
obj-$(CONFIG_CPU_W90P910) += nuc910.o
@@ -17,3 +19,4 @@ obj-$(CONFIG_CPU_NUC960) += nuc960.o
obj-$(CONFIG_MACH_W90P910EVB) += mach-nuc910evb.o
obj-$(CONFIG_MACH_W90P950EVB) += mach-nuc950evb.o
obj-$(CONFIG_MACH_W90N960EVB) += mach-nuc960evb.o
+obj-$(CONFIG_SOC_NUC970) += nuc900.o
diff --git a/arch/arm/mach-w90x900/nuc900.c b/arch/arm/mach-w90x900/nuc900.c
new file mode 100644
index 0000000..309c332
--- /dev/null
+++ b/arch/arm/mach-w90x900/nuc900.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 Wan Zongshun <mcuos.com@gmail.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/reboot.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/sys_soc.h>
+#include <linux/semaphore.h>
+
+#include <asm/system_misc.h>
+#include <asm/mach/arch.h>
+
+static void __init nuc900_machine_init(void)
+{
+ of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+}
+
+static const char *nuc900_dt_compat[] __initconst = {
+ "nuvoton,nuc970",
+ NULL,
+};
+
+DT_MACHINE_START(nuc900_dt, "Nuvoton NUC900 (Device Tree Support)")
+ .init_machine = nuc900_machine_init,
+ .dt_compat = nuc900_dt_compat,
+MACHINE_END
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-11 00:10 +0200 |
| Subject | Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support |
| Message-ID | <rTv5f-6Jl-3@gated-at.bofh.it> |
| In reply to | #1440044 |
On Sunday, July 10, 2016 3:27:21 PM CEST Wan Zongshun wrote:
> +
> +#include <linux/platform_device.h>
> +#include <linux/clk.h>
> +#include <linux/clkdev.h>
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/gpio.h>
> +#include <linux/init.h>
> +#include <linux/reboot.h>
> +#include <linux/of_address.h>
> +#include <linux/of_platform.h>
> +#include <linux/sys_soc.h>
> +#include <linux/semaphore.h>
> +
> +#include <asm/system_misc.h>
> +#include <asm/mach/arch.h>
> +
> +static void __init nuc900_machine_init(void)
> +{
> + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}
This is the default for .init_machine, so you can leave the function
undefined.
> +static const char *nuc900_dt_compat[] __initconst = {
> + "nuvoton,nuc970",
> + NULL,
> +};
> +
> +DT_MACHINE_START(nuc900_dt, "Nuvoton NUC900 (Device Tree Support)")
> + .init_machine = nuc900_machine_init,
> + .dt_compat = nuc900_dt_compat,
> +MACHINE_END
>
After that, you can probably remove most of the #include statements.
The file is still needed for now, until you move to ARCH_MULTIPLATFORM,
at which point the entire machine descriptor is redundant.
Arnd
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-11 18:10 +0200 |
| Subject | Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support |
| Message-ID | <rTLWq-WD-29@gated-at.bofh.it> |
| In reply to | #1440044 |
On Sunday, July 10, 2016 3:27:21 PM CEST Wan Zongshun wrote: > +ifeq ($(CONFIG_SOC_NUC970),) > obj-y := irq.o time.o mfp.o gpio.o clock.o > obj-y += clksel.o dev.o cpu.o > +endif > # W90X900 CPU support files When mfp.o is disabled like this, I get a link error in two drivers using the exported interface: ERROR: "mfp_set_groupg" [drivers/spi/spi-nuc900.ko] undefined! ERROR: "mfp_set_groupi" [drivers/input/keyboard/w90p910_keypad.ko] undefined! Any idea for a better migration strategy? Arnd
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-12 06:40 +0200 |
| Subject | Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support |
| Message-ID | <rTXEe-8re-3@gated-at.bofh.it> |
| In reply to | #1440736 |
On 2016年07月12日 00:04, Arnd Bergmann wrote: > On Sunday, July 10, 2016 3:27:21 PM CEST Wan Zongshun wrote: >> +ifeq ($(CONFIG_SOC_NUC970),) >> obj-y := irq.o time.o mfp.o gpio.o clock.o >> obj-y += clksel.o dev.o cpu.o >> +endif >> # W90X900 CPU support files > > When mfp.o is disabled like this, I get a link error in two drivers > using the exported interface: > > ERROR: "mfp_set_groupg" [drivers/spi/spi-nuc900.ko] undefined! > ERROR: "mfp_set_groupi" [drivers/input/keyboard/w90p910_keypad.ko] undefined! Why remove mfp modules? this multifunction pin driver should be used for those two drivers, if no mfp_set_groupX, I don't think driver can work. Now mfp has standard driver subsystem? > > Any idea for a better migration strategy? > > Arnd > >
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-12 09:20 +0200 |
| Subject | Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support |
| Message-ID | <rU093-1KR-3@gated-at.bofh.it> |
| In reply to | #1441063 |
On 2016年07月12日 12:30, Wan Zongshun wrote: > > > On 2016年07月12日 00:04, Arnd Bergmann wrote: >> On Sunday, July 10, 2016 3:27:21 PM CEST Wan Zongshun wrote: >>> +ifeq ($(CONFIG_SOC_NUC970),) >>> obj-y := irq.o time.o mfp.o gpio.o clock.o >>> obj-y += clksel.o dev.o cpu.o >>> +endif >>> # W90X900 CPU support files >> >> When mfp.o is disabled like this, I get a link error in two drivers >> using the exported interface: >> >> ERROR: "mfp_set_groupg" [drivers/spi/spi-nuc900.ko] undefined! >> ERROR: "mfp_set_groupi" [drivers/input/keyboard/w90p910_keypad.ko] >> undefined! > > Why remove mfp modules? this multifunction pin driver should be used for > those two drivers, if no mfp_set_groupX, I don't think driver can work. > > Now mfp has standard driver subsystem? > >> >> Any idea for a better migration strategy? Arnd, If you still think the mfp should be removed, we can send a series patches to instead of using mfp interface quickly, and do mfp set in local driver. Do you think it is ok? >> >> Arnd >> >> > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-12 10:30 +0200 |
| Subject | Re: [PATCH v2 01/10] ARM: NUC900: Add nuc970 machine support |
| Message-ID | <rU1eO-2pJ-17@gated-at.bofh.it> |
| In reply to | #1441105 |
On Tuesday, July 12, 2016 3:14:47 PM CEST Wan Zongshun wrote: > On 2016年07月12日 12:30, Wan Zongshun wrote: > > > > > > On 2016年07月12日 00:04, Arnd Bergmann wrote: > >> On Sunday, July 10, 2016 3:27:21 PM CEST Wan Zongshun wrote: > >>> +ifeq ($(CONFIG_SOC_NUC970),) > >>> obj-y := irq.o time.o mfp.o gpio.o clock.o > >>> obj-y += clksel.o dev.o cpu.o > >>> +endif > >>> # W90X900 CPU support files > >> > >> When mfp.o is disabled like this, I get a link error in two drivers > >> using the exported interface: > >> > >> ERROR: "mfp_set_groupg" [drivers/spi/spi-nuc900.ko] undefined! > >> ERROR: "mfp_set_groupi" [drivers/input/keyboard/w90p910_keypad.ko] > >> undefined! > > > > Why remove mfp modules? this multifunction pin driver should be used for > > those two drivers, if no mfp_set_groupX, I don't think driver can work. > > > > Now mfp has standard driver subsystem? > > > >> > >> Any idea for a better migration strategy? > > Arnd, If you still think the mfp should be removed, we can send a series > patches to instead of using mfp interface quickly, and do mfp set in > local driver. Do you think it is ok? I don't think setting it locally in the driver is a good idea. In the long run, this should go through the pinctrl framework, but there is no need to implement that right away. Until then, I think using the existing mfp.o code is fine, it will just need to be adapted slightly to understand the DT based device names. Arnd
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-10 09:30 +0200 |
| Subject | [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver |
| Message-ID | <rThlD-5X6-11@gated-at.bofh.it> |
| In reply to | #1440043 |
This patch is to add nuc970 clocksource driver support.
NUC970 general timer controller includes five channels, TIMER0, TIMER1,
TIMER2, TIMER3, and TIMER4, which allow user to easily implement a
counting scheme or timing control for applications.The timer possesses
features such as adjustable resolution, and programmable counting period.
The timer can generate an interrupt signal upon timeout, or provide the
current value of count during operation.
Currently, we are using TIMER0 and TIMER1 for clocksource and clockevent
device driver support.
Signed-off-by: Wan Zongshun <mcuos.com@gmail.com>
---
drivers/clocksource/Kconfig | 8 +
drivers/clocksource/Makefile | 1 +
drivers/clocksource/timer-nuc900.c | 305 +++++++++++++++++++++++++++++++++++++
3 files changed, 314 insertions(+)
create mode 100644 drivers/clocksource/timer-nuc900.c
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 47352d2..441c5ee 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -427,4 +427,12 @@ config CLKSRC_ST_LPC
Enable this option to use the Low Power controller timer
as clocksource.
+config NUC900_TIMER
+ bool "Clocksource timer for nuc900 platform" if COMPILE_TEST
+ depends on ARM
+ select CLKSRC_OF if OF
+ select CLKSRC_MMIO
+ help
+ Enables the clocksource for the NUC900 platform.
+
endmenu
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 473974f..c74e252 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -67,3 +67,4 @@ obj-$(CONFIG_H8300_TMR16) += h8300_timer16.o
obj-$(CONFIG_H8300_TPU) += h8300_tpu.o
obj-$(CONFIG_CLKSRC_ST_LPC) += clksrc_st_lpc.o
obj-$(CONFIG_X86_NUMACHIP) += numachip.o
+obj-$(CONFIG_NUC900_TIMER) += timer-nuc900.o
diff --git a/drivers/clocksource/timer-nuc900.c b/drivers/clocksource/timer-nuc900.c
new file mode 100644
index 0000000..28ccbcf
--- /dev/null
+++ b/drivers/clocksource/timer-nuc900.c
@@ -0,0 +1,305 @@
+/*
+ * Copyright 2016 Wan Zongshun <mcuos.com@gmail.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
+#include <linux/clockchips.h>
+#include <linux/types.h>
+#include <linux/clk.h>
+#include <linux/slab.h>
+
+#include <linux/io.h>
+#include <asm/mach/time.h>
+
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+
+#define TMR_TCSR0 0x00
+#define TMR_TICR0 0x04
+#define TMR_TDR0 0x08
+#define TMR_TCSR1 0x10
+#define TMR_TICR1 0x14
+#define TMR_TDR1 0x18
+#define TMR_TISR 0x60
+
+#define RESETINT 0x1f
+#define PERIODIC (0x01 << 27)
+#define ONESHOT (0x00 << 27)
+#define COUNTEN (0x01 << 30)
+#define INTEN (0x01 << 29)
+
+#define TICKS_PER_SEC 100
+/* Divider = prescale + 1 */
+#define PRESCALE 0x63
+
+#define TDR_SHIFT 24
+#define TDR_MASK ((1 << TDR_SHIFT) - 1)
+#define OPMODE_MASK ~(0x03 << 27)
+
+struct nuc970_clockevents {
+ struct clock_event_device clkevt;
+ unsigned int timer0_load;
+ void __iomem *base;
+};
+
+struct nuc970_clockevents *clkevt_to_nuc970(struct clock_event_device *clk)
+{
+ return container_of(clk, struct nuc970_clockevents, clkevt);
+}
+
+static int nuc970_clockevent_set(bool periodic, struct clock_event_device *clk)
+{
+ struct nuc970_clockevents *evt = clkevt_to_nuc970(clk);
+ unsigned int val;
+
+ val = readl(evt->base + TMR_TCSR0);
+ val &= OPMODE_MASK;
+
+ writel(evt->timer0_load, evt->base + TMR_TICR0);
+
+ val |= periodic ? PERIODIC:ONESHOT;
+ val |= (COUNTEN | INTEN | PRESCALE);
+
+ writel(val, evt->base + TMR_TCSR0);
+
+ return 0;
+}
+
+
+static int nuc970_clockevent_set_oneshot(struct clock_event_device *clk)
+{
+ nuc970_clockevent_set(0, clk);
+ return 0;
+}
+
+static int nuc970_clockevent_set_periodic(struct clock_event_device *clk)
+{
+ nuc970_clockevent_set(1, clk);
+ return 0;
+}
+
+static int nuc970_clockevent_setnextevent(unsigned long evtval,
+ struct clock_event_device *clk)
+{
+ struct nuc970_clockevents *evt = clkevt_to_nuc970(clk);
+ unsigned int tcsr, tdelta;
+
+ tcsr = readl(evt->base + TMR_TCSR0);
+ tdelta = readl(evt->base + TMR_TICR0) - readl(evt->base + TMR_TDR0);
+
+ writel(evtval, evt->base + TMR_TICR0);
+
+ if (!(tcsr & COUNTEN) && ((tdelta > 2) || (tdelta == 0)))
+ writel(readl(evt->base + TMR_TCSR0) | COUNTEN,
+ evt->base + TMR_TCSR0);
+
+ return 0;
+}
+
+static int nuc970_clockevent_shutdown(struct clock_event_device *clk)
+{
+ struct nuc970_clockevents *evt = clkevt_to_nuc970(clk);
+ unsigned int val = readl(evt->base + TMR_TCSR0) & ~(0x03 << 27);
+
+ writel(val, evt->base + TMR_TCSR0);
+
+ return 0;
+}
+
+/*IRQ handler for the timer*/
+static irqreturn_t nuc970_timer0_interrupt(int irq, void *dev_id)
+{
+ struct nuc970_clockevents *evt = dev_id;
+ struct clock_event_device *clk = &(evt->clkevt);
+
+ writel(0x01, evt->base + TMR_TISR);
+
+ clk->event_handler(clk);
+
+ return IRQ_HANDLED;
+}
+
+static int clock_event_device_init(struct clock_event_device *clk,
+ unsigned int rate)
+{
+ clk->name = "nuc970-timer0";
+ clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
+ clk->set_state_shutdown = nuc970_clockevent_shutdown;
+ clk->set_state_periodic = nuc970_clockevent_set_periodic;
+ clk->set_state_oneshot = nuc970_clockevent_set_oneshot;
+ clk->set_state_oneshot_stopped = nuc970_clockevent_shutdown;
+ clk->set_next_event = nuc970_clockevent_setnextevent;
+ clk->cpumask = cpumask_of(0);
+ clk->rating = 300;
+
+ clockevents_config_and_register(clk, rate, 0xf, 0xffffffff);
+ return 0;
+}
+
+static int __init nuc970_clkevt_init(struct nuc970_clockevents *evt,
+ int irq, struct clk *clk_timer0)
+{
+ unsigned int rate = 0;
+ int ret;
+
+ /*Clockevents init*/
+ ret = clk_prepare_enable(clk_timer0);
+ if (ret) {
+ pr_err("Failed to enable clk_timer0 clock :%d.\n", ret);
+ goto err_clk_prepare_enable;
+ }
+
+ writel(0x00, evt->base + TMR_TCSR0);
+
+ rate = clk_get_rate(clk_timer0);
+ if (!rate) {
+ pr_err("Failed to get clk_timer0 rate :%d.\n", rate);
+ ret = -EINVAL;
+ goto err_clk_get_rate;
+ }
+
+ rate /= (PRESCALE + 1);
+
+ evt->timer0_load = (rate / TICKS_PER_SEC);
+
+ writel(RESETINT, evt->base + TMR_TISR);
+
+ clock_event_device_init(&(evt->clkevt), rate);
+
+ ret = request_irq(irq, nuc970_timer0_interrupt,
+ IRQF_TIMER | IRQF_IRQPOLL, "nuc970-timer0", evt);
+ if (ret) {
+ pr_err("Failed to request irq :%d, return: %d.\n", irq, ret);
+ goto err_clk_get_rate;
+ }
+
+ return 0;
+
+err_clk_get_rate:
+ clk_disable_unprepare(clk_timer0);
+err_clk_prepare_enable:
+ return ret;
+}
+
+static int __init nuc970_clksrc_init(struct nuc970_clockevents *evt,
+ struct clk *clk_timer1)
+{
+ unsigned int val, rate = 0;
+ int ret;
+
+ /*Clocksource init*/
+ ret = clk_prepare_enable(clk_timer1);
+ if (ret) {
+ pr_err("Failed to enable clk_timer1 clock :%d.\n", ret);
+ goto err_clk_prepare_enable;
+ }
+
+ writel(0x00, evt->base + TMR_TCSR1);
+
+ rate = clk_get_rate(clk_timer1);
+ if (!rate) {
+ pr_err("Failed to get clk_timer1 rate :%d.\n", rate);
+ ret = -EINVAL;
+ goto err_clk_get_rate;
+ }
+
+ rate /= (PRESCALE + 1);
+
+ writel(0xffffffff, evt->base + TMR_TICR1);
+
+ val = readl(evt->base + TMR_TCSR1);
+ val |= (COUNTEN | PERIODIC | PRESCALE);
+ writel(val, evt->base + TMR_TCSR1);
+
+ ret = clocksource_mmio_init(evt->base + TMR_TDR1, "nuc970-timer1",
+ rate, 200, TDR_SHIFT,
+ clocksource_mmio_readl_down);
+ if (ret) {
+ pr_err("nuc970-timer1: can't register clocksource\n");
+ goto err_clk_get_rate;
+ }
+
+ return 0;
+
+err_clk_get_rate:
+ clk_disable_unprepare(clk_timer1);
+err_clk_prepare_enable:
+ return ret;
+
+}
+
+static void __init nuc970_timer_of_init(struct device_node *node)
+{
+ struct nuc970_clockevents *nuc970_evt;
+ struct clk *clk_timer0, *clk_timer1;
+ int irq, ret;
+
+ nuc970_evt = kzalloc(sizeof(struct nuc970_clockevents), GFP_KERNEL);
+ if (!nuc970_evt) {
+ ret = -ENOMEM;
+ pr_err("%s: Failed to kzalloc memory\n", node->full_name);
+ goto err_alloc_mem;
+ }
+
+ nuc970_evt->base = of_iomap(node, 0);
+ if (!nuc970_evt->base) {
+ ret = -ENOMEM;
+ pr_err("%s: Unable to map timer base\n", node->full_name);
+ goto err_iomap;
+ }
+
+ clk_timer0 = of_clk_get_by_name(node, "timer0");
+ if (IS_ERR(clk_timer0)) {
+ ret = PTR_ERR(clk_timer0);
+ pr_err("%s: Unable to get clk_timer0\n", node->full_name);
+ goto err_get_clk;
+ }
+
+ clk_timer1 = of_clk_get_by_name(node, "timer1");
+ if (IS_ERR(clk_timer1)) {
+ ret = PTR_ERR(clk_timer1);
+ pr_err("%s: Unable to get clk_timer1\n", node->full_name);
+ goto err_get_clk;
+ }
+
+ irq = irq_of_parse_and_map(node, 0);
+ if (irq <= 0) {
+ ret = irq;
+ pr_err("%s: Unable to get irq\n", node->full_name);
+ goto err_get_clk;
+ }
+
+ ret = nuc970_clksrc_init(nuc970_evt, clk_timer1);
+ if (ret) {
+ pr_err("Failed to init clock source :%d.\n", ret);
+ goto err_get_clk;
+ }
+
+ nuc970_clkevt_init(nuc970_evt, irq, clk_timer0);
+ if (ret) {
+ pr_err("Failed to init clock event device :%d.\n", ret);
+ goto err_get_clk;
+ }
+
+ return;
+
+err_get_clk:
+ iounmap(nuc970_evt->base);
+err_iomap:
+ kfree(nuc970_evt);
+err_alloc_mem:
+ return;
+}
+
+CLOCKSOURCE_OF_DECLARE(nuc970, "nuvoton,nuc970-tmr", nuc970_timer_of_init);
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-11 17:40 +0200 |
| Subject | Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver |
| Message-ID | <rTLtn-rG-11@gated-at.bofh.it> |
| In reply to | #1440045 |
On Sunday, July 10, 2016 3:27:23 PM CEST Wan Zongshun wrote:
>
> +config NUC900_TIMER
> + bool "Clocksource timer for nuc900 platform" if COMPILE_TEST
> + depends on ARM
> + select CLKSRC_OF if OF
> + select CLKSRC_MMIO
> + help
> + Enables the clocksource for the NUC900 platform.
>
I have put this patch into my randconfig build system and found that
it lacks a dependency:
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index e18ef32776a3..59b9251eef37 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -523,7 +523,7 @@ config CLKSRC_ST_LPC
config NUC900_TIMER
bool "Clocksource timer for nuc900 platform" if COMPILE_TEST
- depends on ARM
+ depends on ARM && GENERIC_CLOCKEVENTS
select CLKSRC_OF if OF
select CLKSRC_MMIO
help
Also the init function has changed its return type in linux-next:
> +static void __init nuc970_timer_of_init(struct device_node *node)
This now needs to return an error code or we get:
../include/linux/of.h:1004:20: error: comparison of distinct pointer types lacks a cast [-Werror]
.data = (fn == (fn_type)NULL) ? fn : fn }
Daniel Lezcano seems to have implemented a migration strategy, but I
can't see what you are supposed to do here, since the
CLOCKSOURCE_OF_DECLARE_RET macro is no longer part of linux-next.
Arnd
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-12 09:40 +0200 |
| Subject | Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver |
| Message-ID | <rU0sp-1Rq-3@gated-at.bofh.it> |
| In reply to | #1440719 |
On 2016年07月11日 23:36, Arnd Bergmann wrote: > On Sunday, July 10, 2016 3:27:23 PM CEST Wan Zongshun wrote: >> >> +config NUC900_TIMER >> + bool "Clocksource timer for nuc900 platform" if COMPILE_TEST >> + depends on ARM >> + select CLKSRC_OF if OF >> + select CLKSRC_MMIO >> + help >> + Enables the clocksource for the NUC900 platform. >> > > I have put this patch into my randconfig build system and found that > it lacks a dependency: > > > > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig > index e18ef32776a3..59b9251eef37 100644 > --- a/drivers/clocksource/Kconfig > +++ b/drivers/clocksource/Kconfig > @@ -523,7 +523,7 @@ config CLKSRC_ST_LPC > > config NUC900_TIMER > bool "Clocksource timer for nuc900 platform" if COMPILE_TEST > - depends on ARM > + depends on ARM && GENERIC_CLOCKEVENTS > select CLKSRC_OF if OF > select CLKSRC_MMIO > help > So this patch, I still need submit or you have merged it? > > Also the init function has changed its return type in linux-next: > >> +static void __init nuc970_timer_of_init(struct device_node *node) > > This now needs to return an error code or we get: > > ../include/linux/of.h:1004:20: error: comparison of distinct pointer types lacks a cast [-Werror] > .data = (fn == (fn_type)NULL) ? fn : fn } > > Daniel Lezcano seems to have implemented a migration strategy, but I > can't see what you are supposed to do here, since the > CLOCKSOURCE_OF_DECLARE_RET macro is no longer part of linux-next. Wait for Daniel's comments? or what should I do now? > > Arnd > >
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-12 10:30 +0200 |
| Subject | Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver |
| Message-ID | <rU1eO-2pJ-21@gated-at.bofh.it> |
| In reply to | #1441121 |
On Tuesday, July 12, 2016 3:32:59 PM CEST Wan Zongshun wrote: > > On 2016年07月11日 23:36, Arnd Bergmann wrote: > > On Sunday, July 10, 2016 3:27:23 PM CEST Wan Zongshun wrote: > >> > >> +config NUC900_TIMER > >> + bool "Clocksource timer for nuc900 platform" if COMPILE_TEST > >> + depends on ARM > >> + select CLKSRC_OF if OF > >> + select CLKSRC_MMIO > >> + help > >> + Enables the clocksource for the NUC900 platform. > >> > > > > I have put this patch into my randconfig build system and found that > > it lacks a dependency: > > > > > > > > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig > > index e18ef32776a3..59b9251eef37 100644 > > --- a/drivers/clocksource/Kconfig > > +++ b/drivers/clocksource/Kconfig > > @@ -523,7 +523,7 @@ config CLKSRC_ST_LPC > > > > config NUC900_TIMER > > bool "Clocksource timer for nuc900 platform" if COMPILE_TEST > > - depends on ARM > > + depends on ARM && GENERIC_CLOCKEVENTS > > select CLKSRC_OF if OF > > select CLKSRC_MMIO > > help > > > > So this patch, I still need submit or you have merged it? Ideally the driver should get submitted through the clocksource maintainer tree. I have not applied it to any git tree that I plan to send anywhere. > > > > Also the init function has changed its return type in linux-next: > > > >> +static void __init nuc970_timer_of_init(struct device_node *node) > > > > This now needs to return an error code or we get: > > > > ../include/linux/of.h:1004:20: error: comparison of distinct pointer types lacks a cast [-Werror] > > .data = (fn == (fn_type)NULL) ? fn : fn } > > > > Daniel Lezcano seems to have implemented a migration strategy, but I > > can't see what you are supposed to do here, since the > > CLOCKSOURCE_OF_DECLARE_RET macro is no longer part of linux-next. > > Wait for Daniel's comments? or what should I do now? Yes, let's see what he says. I guess from the timing, this will probably have to wait for linux-4.9 anyway, and then we have no problem because the API change will make it into 4.8. Arnd
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-21 15:00 +0200 |
| Subject | Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver |
| Message-ID | <rXlK1-7xV-5@gated-at.bofh.it> |
| In reply to | #1441137 |
On Thursday, July 21, 2016 2:52:24 PM CEST Daniel Lezcano wrote: > On Tue, Jul 12, 2016 at 10:28:35AM +0200, Arnd Bergmann wrote: > > [ ... ] > > > > > Also the init function has changed its return type in linux-next: > > > > > > > >> +static void __init nuc970_timer_of_init(struct device_node *node) > > > > > > > > This now needs to return an error code or we get: > > > > > > > > ../include/linux/of.h:1004:20: error: comparison of distinct pointer types lacks a cast [-Werror] > > > > .data = (fn == (fn_type)NULL) ? fn : fn } > > > > > > > > Daniel Lezcano seems to have implemented a migration strategy, but I > > > > can't see what you are supposed to do here, since the > > > > CLOCKSOURCE_OF_DECLARE_RET macro is no longer part of linux-next. > > > > > > Wait for Daniel's comments? or what should I do now? > > > > Yes, let's see what he says. I guess from the timing, this will probably > > have to wait for linux-4.9 anyway, and then we have no problem because the > > API change will make it into 4.8. > > CLOCKSOURCE_OF_DECLARE_RET was renamed back to CLOCKSOURCE_OF_DECLARE but it > expects now an init function returning an 'int'. > > These changes are now in tip/timers/core, so in linux-next. Ok, so the driver could be merged on top of that, but it's really late for 4.8 now, so we'd just wait until after the merge window anyway. Arnd
[toc] | [prev] | [next] | [standalone]
| From | Daniel Lezcano <daniel.lezcano@linaro.org> |
|---|---|
| Date | 2016-07-21 15:00 +0200 |
| Subject | Re: [PATCH v2 03/10] Clocksource: add nuc970 clocksource driver |
| Message-ID | <rXlK1-7xV-7@gated-at.bofh.it> |
| In reply to | #1441137 |
On Tue, Jul 12, 2016 at 10:28:35AM +0200, Arnd Bergmann wrote: [ ... ] > > > Also the init function has changed its return type in linux-next: > > > > > >> +static void __init nuc970_timer_of_init(struct device_node *node) > > > > > > This now needs to return an error code or we get: > > > > > > ../include/linux/of.h:1004:20: error: comparison of distinct pointer types lacks a cast [-Werror] > > > .data = (fn == (fn_type)NULL) ? fn : fn } > > > > > > Daniel Lezcano seems to have implemented a migration strategy, but I > > > can't see what you are supposed to do here, since the > > > CLOCKSOURCE_OF_DECLARE_RET macro is no longer part of linux-next. > > > > Wait for Daniel's comments? or what should I do now? > > Yes, let's see what he says. I guess from the timing, this will probably > have to wait for linux-4.9 anyway, and then we have no problem because the > API change will make it into 4.8. CLOCKSOURCE_OF_DECLARE_RET was renamed back to CLOCKSOURCE_OF_DECLARE but it expects now an init function returning an 'int'. These changes are now in tip/timers/core, so in linux-next.
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-10 09:30 +0200 |
| Subject | [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 |
| Message-ID | <rThlD-5X6-13@gated-at.bofh.it> |
| In reply to | #1440043 |
This patch is to add irqchip driver support for nuc900 plat,
current this driver only supports nuc970 SoC.
Signed-off-by: Wan Zongshun <mcuos.com@gmail.com>
---
arch/arm/mach-w90x900/include/mach/irqs.h | 5 +
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-nuc900.c | 150 ++++++++++++++++++++++++++++++
3 files changed, 156 insertions(+)
create mode 100644 drivers/irqchip/irq-nuc900.c
diff --git a/arch/arm/mach-w90x900/include/mach/irqs.h b/arch/arm/mach-w90x900/include/mach/irqs.h
index 9d5cba3..3b035c6 100644
--- a/arch/arm/mach-w90x900/include/mach/irqs.h
+++ b/arch/arm/mach-w90x900/include/mach/irqs.h
@@ -59,7 +59,12 @@
#define IRQ_KPI W90X900_IRQ(29)
#define IRQ_P2SGROUP W90X900_IRQ(30)
#define IRQ_ADC W90X900_IRQ(31)
+
+#if !defined(CONFIG_SOC_NUC900)
#define NR_IRQS (IRQ_ADC+1)
+#else
+#define NR_IRQS 62
+#endif
/*for irq group*/
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 38853a1..9ccd5af8a 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -69,3 +69,4 @@ obj-$(CONFIG_PIC32_EVIC) += irq-pic32-evic.o
obj-$(CONFIG_MVEBU_ODMI) += irq-mvebu-odmi.o
obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o
obj-$(CONFIG_EZNPS_GIC) += irq-eznps.o
+obj-$(CONFIG_SOC_NUC970) += irq-nuc900.o
diff --git a/drivers/irqchip/irq-nuc900.c b/drivers/irqchip/irq-nuc900.c
new file mode 100644
index 0000000..c4b2e39
--- /dev/null
+++ b/drivers/irqchip/irq-nuc900.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2016 Wan Zongshun <mcuos.com@gmail.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/irqchip.h>
+#include <linux/irqdomain.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+
+#include <asm/exception.h>
+#include <asm/hardirq.h>
+
+#define REG_AIC_SCR1 0x00
+#define REG_AIC_SCR2 0x04
+#define REG_AIC_SCR3 0x08
+#define REG_AIC_SCR4 0x0C
+#define REG_AIC_SCR5 0x10
+#define REG_AIC_SCR6 0x14
+#define REG_AIC_SCR7 0x18
+#define REG_AIC_SCR8 0x1C
+#define REG_AIC_SCR9 0x20
+#define REG_AIC_SCR10 0x24
+#define REG_AIC_SCR11 0x28
+#define REG_AIC_SCR12 0x2C
+#define REG_AIC_SCR13 0x30
+#define REG_AIC_SCR14 0x34
+#define REG_AIC_SCR15 0x38
+#define REG_AIC_IRSR 0x100
+#define REG_AIC_IRSRH 0x104
+#define REG_AIC_IASR 0x108
+#define REG_AIC_IASRH 0x10C
+#define REG_AIC_ISR 0x110
+#define REG_AIC_ISRH 0x114
+#define REG_AIC_IPER 0x118
+#define REG_AIC_ISNR 0x120
+#define REG_AIC_OISR 0x124
+#define REG_AIC_IMR 0x128
+#define REG_AIC_IMRH 0x12C
+#define REG_AIC_MECR 0x130
+#define REG_AIC_MECRH 0x134
+#define REG_AIC_MDCR 0x138
+#define REG_AIC_MDCRH 0x13C
+#define REG_AIC_SSCR 0x140
+#define REG_AIC_SSCRH 0x144
+#define REG_AIC_SCCR 0x148
+#define REG_AIC_SCCRH 0x14C
+#define REG_AIC_EOSCR 0x150
+
+static void __iomem *aic_base;
+static struct irq_domain *aic_domain;
+
+static void nuc900_irq_mask(struct irq_data *d)
+{
+ if (d->irq < 32)
+ writel(1 << (d->irq), aic_base + REG_AIC_MDCR);
+ else
+ writel(1 << (d->irq - 32), aic_base + REG_AIC_MDCRH);
+}
+
+static void nuc900_irq_ack(struct irq_data *d)
+{
+ writel(0x01, aic_base + REG_AIC_EOSCR);
+}
+
+static void nuc900_irq_unmask(struct irq_data *d)
+{
+ if (d->irq < 32)
+ writel(1 << (d->irq), aic_base + REG_AIC_MECR);
+ else
+ writel(1 << (d->irq - 32), aic_base + REG_AIC_MECRH);
+}
+
+static struct irq_chip nuc900_irq_chip = {
+ .irq_ack = nuc900_irq_ack,
+ .irq_mask = nuc900_irq_mask,
+ .irq_unmask = nuc900_irq_unmask,
+};
+
+void __exception_irq_entry aic_handle_irq(struct pt_regs *regs)
+{
+ u32 hwirq;
+
+ hwirq = readl(aic_base + REG_AIC_IPER);
+ hwirq = readl(aic_base + REG_AIC_ISNR);
+ if (!hwirq)
+ writel(0x01, aic_base + REG_AIC_EOSCR);
+
+ handle_IRQ((irq_find_mapping(aic_domain, hwirq)), regs);
+}
+
+static int aic_irq_domain_map(struct irq_domain *d, unsigned int virq,
+ irq_hw_number_t hw)
+{
+ irq_set_chip_and_handler(virq, &nuc900_irq_chip, handle_level_irq);
+ irq_clear_status_flags(virq, IRQ_NOREQUEST);
+
+ return 0;
+}
+
+static struct irq_domain_ops aic_irq_domain_ops = {
+ .map = aic_irq_domain_map,
+ .xlate = irq_domain_xlate_onecell,
+};
+
+static int __init aic_of_init(struct device_node *node,
+ struct device_node *parent)
+{
+ int ret;
+
+ aic_base = of_iomap(node, 0);
+ if (!aic_base) {
+ ret = -ENOMEM;
+ pr_err("%s: unable to map registers\n", node->full_name);
+ goto err_iomap;
+ }
+
+ writel(0xFFFFFFFC, aic_base + REG_AIC_MDCR);
+ writel(0xFFFFFFFF, aic_base + REG_AIC_MDCRH);
+
+ aic_domain = irq_domain_add_linear(node, NR_IRQS,
+ &aic_irq_domain_ops, NULL);
+
+ if (!aic_domain) {
+ ret = -ENOMEM;
+ pr_err("%s: unable to create IRQ domain\n", node->full_name);
+ goto err_aic_domain;
+ }
+
+ set_handle_irq(aic_handle_irq);
+ return 0;
+
+err_aic_domain:
+ iounmap(aic_base);
+err_iomap:
+ return ret;
+}
+
+IRQCHIP_DECLARE(nuc900, "nuvoton,nuc900-aic", aic_of_init);
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Paul Gortmaker <paul.gortmaker@windriver.com> |
|---|---|
| Date | 2016-07-11 00:00 +0200 |
| Subject | Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 |
| Message-ID | <rTuVB-6qQ-47@gated-at.bofh.it> |
| In reply to | #1440046 |
On Sun, Jul 10, 2016 at 3:27 AM, Wan Zongshun <vw@iommu.org> wrote: > This patch is to add irqchip driver support for nuc900 plat, > current this driver only supports nuc970 SoC. > > Signed-off-by: Wan Zongshun <mcuos.com@gmail.com> > --- > arch/arm/mach-w90x900/include/mach/irqs.h | 5 + > drivers/irqchip/Makefile | 1 + > drivers/irqchip/irq-nuc900.c | 150 ++++++++++++++++++++++++++++++ > 3 files changed, 156 insertions(+) > create mode 100644 drivers/irqchip/irq-nuc900.c > > diff --git a/arch/arm/mach-w90x900/include/mach/irqs.h b/arch/arm/mach-w90x900/include/mach/irqs.h > index 9d5cba3..3b035c6 100644 > --- a/arch/arm/mach-w90x900/include/mach/irqs.h > +++ b/arch/arm/mach-w90x900/include/mach/irqs.h > @@ -59,7 +59,12 @@ > #define IRQ_KPI W90X900_IRQ(29) > #define IRQ_P2SGROUP W90X900_IRQ(30) > #define IRQ_ADC W90X900_IRQ(31) > + > +#if !defined(CONFIG_SOC_NUC900) > #define NR_IRQS (IRQ_ADC+1) > +#else > +#define NR_IRQS 62 > +#endif > > /*for irq group*/ > > diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile > index 38853a1..9ccd5af8a 100644 > --- a/drivers/irqchip/Makefile > +++ b/drivers/irqchip/Makefile > @@ -69,3 +69,4 @@ obj-$(CONFIG_PIC32_EVIC) += irq-pic32-evic.o > obj-$(CONFIG_MVEBU_ODMI) += irq-mvebu-odmi.o > obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o > obj-$(CONFIG_EZNPS_GIC) += irq-eznps.o > +obj-$(CONFIG_SOC_NUC970) += irq-nuc900.o > diff --git a/drivers/irqchip/irq-nuc900.c b/drivers/irqchip/irq-nuc900.c > new file mode 100644 > index 0000000..c4b2e39 > --- /dev/null > +++ b/drivers/irqchip/irq-nuc900.c > @@ -0,0 +1,150 @@ > +/* > + * Copyright 2016 Wan Zongshun <mcuos.com@gmail.com> > + * > + * The code contained herein is licensed under the GNU General Public > + * License. You may obtain a copy of the GNU General Public License > + * Version 2 or later at the following locations: > + * > + * http://www.opensource.org/licenses/gpl-license.html > + * http://www.gnu.org/copyleft/gpl.html > + */ > + > +#include <linux/module.h> Why do you include module.h when I don't see anything modular in this driver? Paul. -- > +#include <linux/init.h> > +#include <linux/irq.h> > +#include <linux/irqchip.h> > +#include <linux/irqdomain.h> > +#include <linux/io.h> > +#include <linux/ioport.h> > +#include <linux/of_address.h> > +#include <linux/of_irq.h> > + > +#include <asm/exception.h> > +#include <asm/hardirq.h> > + [...]
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-11 04:20 +0200 |
| Subject | Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 |
| Message-ID | <rTyZb-Pn-3@gated-at.bofh.it> |
| In reply to | #1440175 |
On 2016年07月11日 05:51, Paul Gortmaker wrote: > On Sun, Jul 10, 2016 at 3:27 AM, Wan Zongshun <vw@iommu.org> wrote: >> This patch is to add irqchip driver support for nuc900 plat, >> current this driver only supports nuc970 SoC. >> >> Signed-off-by: Wan Zongshun <mcuos.com@gmail.com> >> --- >> arch/arm/mach-w90x900/include/mach/irqs.h | 5 + >> drivers/irqchip/Makefile | 1 + >> drivers/irqchip/irq-nuc900.c | 150 ++++++++++++++++++++++++++++++ >> 3 files changed, 156 insertions(+) >> create mode 100644 drivers/irqchip/irq-nuc900.c >> >> diff --git a/arch/arm/mach-w90x900/include/mach/irqs.h b/arch/arm/mach-w90x900/include/mach/irqs.h >> index 9d5cba3..3b035c6 100644 >> --- a/arch/arm/mach-w90x900/include/mach/irqs.h >> +++ b/arch/arm/mach-w90x900/include/mach/irqs.h >> @@ -59,7 +59,12 @@ >> #define IRQ_KPI W90X900_IRQ(29) >> #define IRQ_P2SGROUP W90X900_IRQ(30) >> #define IRQ_ADC W90X900_IRQ(31) >> + >> +#if !defined(CONFIG_SOC_NUC900) >> #define NR_IRQS (IRQ_ADC+1) >> +#else >> +#define NR_IRQS 62 >> +#endif >> >> /*for irq group*/ >> >> diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile >> index 38853a1..9ccd5af8a 100644 >> --- a/drivers/irqchip/Makefile >> +++ b/drivers/irqchip/Makefile >> @@ -69,3 +69,4 @@ obj-$(CONFIG_PIC32_EVIC) += irq-pic32-evic.o >> obj-$(CONFIG_MVEBU_ODMI) += irq-mvebu-odmi.o >> obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o >> obj-$(CONFIG_EZNPS_GIC) += irq-eznps.o >> +obj-$(CONFIG_SOC_NUC970) += irq-nuc900.o >> diff --git a/drivers/irqchip/irq-nuc900.c b/drivers/irqchip/irq-nuc900.c >> new file mode 100644 >> index 0000000..c4b2e39 >> --- /dev/null >> +++ b/drivers/irqchip/irq-nuc900.c >> @@ -0,0 +1,150 @@ >> +/* >> + * Copyright 2016 Wan Zongshun <mcuos.com@gmail.com> >> + * >> + * The code contained herein is licensed under the GNU General Public >> + * License. You may obtain a copy of the GNU General Public License >> + * Version 2 or later at the following locations: >> + * >> + * http://www.opensource.org/licenses/gpl-license.html >> + * http://www.gnu.org/copyleft/gpl.html >> + */ >> + >> +#include <linux/module.h> > > Why do you include module.h when I don't see anything modular in > this driver? Okay, I can delete it. > > Paul. > -- > >> +#include <linux/init.h> >> +#include <linux/irq.h> >> +#include <linux/irqchip.h> >> +#include <linux/irqdomain.h> >> +#include <linux/io.h> >> +#include <linux/ioport.h> >> +#include <linux/of_address.h> >> +#include <linux/of_irq.h> >> + >> +#include <asm/exception.h> >> +#include <asm/hardirq.h> >> + > > [...] > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > >
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-11 17:50 +0200 |
| Subject | Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 |
| Message-ID | <rTLD4-xi-19@gated-at.bofh.it> |
| In reply to | #1440046 |
On Sunday, July 10, 2016 3:27:22 PM CEST Wan Zongshun wrote: > + > +#if !defined(CONFIG_SOC_NUC900) > #define NR_IRQS (IRQ_ADC+1) > +#else > +#define NR_IRQS 62 > +#endif > The Kconfig symbols are a bit confusing here: CONFIG_SOC_NUC900 controls the compilation of the soc_device driver, but I guess what you actually mean here is CONFIG_SOC_NUC970, which is the support for the actual chip. Maybe rename the former to something less confusing and change this to CONFIG_SOC_NUC970? Ideally, this should just go away once we use SPARSE_IRQ. Arnd
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-12 09:10 +0200 |
| Subject | Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 |
| Message-ID | <rTZZo-1H8-13@gated-at.bofh.it> |
| In reply to | #1440724 |
On 2016年07月11日 23:46, Arnd Bergmann wrote: > On Sunday, July 10, 2016 3:27:22 PM CEST Wan Zongshun wrote: >> + >> +#if !defined(CONFIG_SOC_NUC900) >> #define NR_IRQS (IRQ_ADC+1) >> +#else >> +#define NR_IRQS 62 >> +#endif >> > > The Kconfig symbols are a bit confusing here: CONFIG_SOC_NUC900 > controls the compilation of the soc_device driver, but I guess > what you actually mean here is CONFIG_SOC_NUC970, which is the > support for the actual chip. > > Maybe rename the former to something less confusing and change > this to CONFIG_SOC_NUC970? You are right, it should _NUC970. Many thanks! > > Ideally, this should just go away once we use SPARSE_IRQ. This platform also can use SPARSE_IRQ? this just a simple irq map and no more irq number in this Soc. > > Arnd > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > >
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-07-12 10:30 +0200 |
| Subject | Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 |
| Message-ID | <rU1eO-2pJ-9@gated-at.bofh.it> |
| In reply to | #1441099 |
On Tuesday, July 12, 2016 3:04:42 PM CEST Wan Zongshun wrote: > > > > Ideally, this should just go away once we use SPARSE_IRQ. > > This platform also can use SPARSE_IRQ? this just a simple irq map and no > more irq number in this Soc. > SPARSE_IRQ is implied by ARCH_MULTIPLATFORM, so we will have to use it once that gets enabled. Your new irqchip driver already handles IRQ domains, so it will work out of the box with SPARSE_IRQ, but you have to change the reference to "NR_IRQS" into something else. I've prototyped a patch series to enable ARCH_MULTIPLATFORM, I hope you can start working from what I have and get it to run. Arnd
[toc] | [prev] | [next] | [standalone]
| From | Wan Zongshun <vw@iommu.org> |
|---|---|
| Date | 2016-07-14 11:00 +0200 |
| Subject | Re: [PATCH v2 02/10] irqchip: add irqchip driver for nuc900 |
| Message-ID | <rUKF1-7ra-19@gated-at.bofh.it> |
| In reply to | #1441132 |
On 2016年07月12日 16:26, Arnd Bergmann wrote:
> On Tuesday, July 12, 2016 3:04:42 PM CEST Wan Zongshun wrote:
>>>
>>> Ideally, this should just go away once we use SPARSE_IRQ.
>>
>> This platform also can use SPARSE_IRQ? this just a simple irq map and no
>> more irq number in this Soc.
>>
>
> SPARSE_IRQ is implied by ARCH_MULTIPLATFORM, so we will have to
> use it once that gets enabled.
>
> Your new irqchip driver already handles IRQ domains, so it will
> work out of the box with SPARSE_IRQ, but you have to change the
> reference to "NR_IRQS" into something else.
>
> I've prototyped a patch series to enable ARCH_MULTIPLATFORM,
> I hope you can start working from what I have and get it to run.
I go through the ARCH_MULTIPLATFORM and SPARSE_IRQ related codes, but I
find I also have to define the NUC900_NR_IRQS firstly like below, so
that I can init the .nr_irq.
+#if !defined(CONFIG_SOC_NUC970)
#define NUC900_NR_IRQS (IRQ_ADC+1)
+#else
+#define NUC900_NR_IRQS 62
+#endif
DT_MACHINE_START(nuc900_dt, "Nuvoton NUC900 (Device Tree Support)")
.dt_compat = nuc900_dt_compat,
+ .nr_irqs = NUC900_NR_IRQS,
MACHINE_END
and then in my irqchip driver, I will use the NUC900_NR_IRQS:
+aic_domain = irq_domain_add_linear(node, NUC900_NR_IRQS,
+ &aic_irq_domain_ops, NULL);
Is that a right usage?
>
> Arnd
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
>
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web