C-SKY(csky) Linux Kernel Driver
Subsystems (5)
v11 cover C-SKY(csky) Linux Kernel Driver
This is about 11th patchset for C-SKY linux drivers and it should pair with 8th kernel patchset.
Changelog:
- Convert the cpumask to an interrupt-controller specific representation in driver's code, and not the SMP code's, and also modify the related codes in csky kernel patchset.
- Add COMPILE_TEST for csky_mp_timer.
- Fixup smp boot error, cpuhp_setup_state must after timer_of_init() for csky_mp_timer.
Any feedback is welcome, thx for all people review my patchset.
Guo Ren (8):
irqchip: add C-SKY SMP interrupt controller
dt-bindings: interrupt-controller: C-SKY SMP intc
irqchip: add C-SKY APB bus interrupt controller
dt-bindings: interrupt-controller: C-SKY APB intc
clocksource: add C-SKY SMP timer
dt-bindings: timer: C-SKY Multi-processor timer
clocksource: add gx6605s SOC system timer
dt-bindings: timer: gx6605s SOC timer
.../interrupt-controller/csky,apb-intc.txt | 62 +++++ .../bindings/interrupt-controller/csky,mpintc.txt | 40 +++ .../bindings/timer/csky,gx6605s-timer.txt | 42 ++++ .../devicetree/bindings/timer/csky,mptimer.txt | 42 ++++ drivers/clocksource/Kconfig | 18 ++ drivers/clocksource/Makefile | 2 + drivers/clocksource/timer-gx6605s.c | 154 ++++++++++++ drivers/clocksource/timer-mp-csky.c | 173 +++++++++++++ drivers/irqchip/Kconfig | 17 ++ drivers/irqchip/Makefile | 2 + drivers/irqchip/irq-csky-apb-intc.c | 274 +++++++++++++++++++++ drivers/irqchip/irq-csky-mpintc.c | 198 +++++++++++++++ include/linux/cpuhotplug.h | 1 + 13 files changed, 1025 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt create mode 100644 Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt create mode 100644 Documentation/devicetree/bindings/timer/csky,mptimer.txt create mode 100644 drivers/clocksource/timer-gx6605s.c create mode 100644 drivers/clocksource/timer-mp-csky.c create mode 100644 drivers/irqchip/irq-csky-apb-intc.c create mode 100644 drivers/irqchip/irq-csky-mpintc.c
Signature · 1 line
2.7.4
PATCH v11 1/8 irqchip: add C-SKY SMP interrupt controller
- Irq-csky-mpintc is C-SKY smp system interrupt controller and it could support 16 soft irqs, 16 private irqs, and 992 max common irqs.
Changelog:
- Convert the cpumask to an interrupt-controller specific representation in driver's code, and not the SMP code's.
- pass checkpatch.pl
- Move IPI_IRQ into the driver
- Remove irq_set_default_host() and use set_ipi_irq_mapping()
- Change name with upstream feed-back
- Change irq map, reserve soft_irq & private_irq space
- Add License and Copyright
- Support set_affinity for irq balance in SMP
--- drivers/irqchip/Kconfig | 9 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-csky-mpintc.c | 198 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 208 insertions(+) create mode 100644 drivers/irqchip/irq-csky-mpintc.c
drivers/irqchip/Kconfig +9 -0
@@ -371,6 +371,15 @@ config QCOM_PDC Power Domain Controller driver to manage and configure wakeup IRQs for Qualcomm Technologies Inc (QTI) mobile chips. +config CSKY_MPINTC + bool "C-SKY Multi Processor Interrupt Controller" + depends on CSKY + help + Say yes here to enable C-SKY SMP interrupt controller driver used + for C-SKY SMP system. + In fact it's not mmio map in hw and it use ld/st to visit the + controller's register inside CPU. + endmenu config SIFIVE_PLIC
drivers/irqchip/Makefile +1 -0
@@ -87,4 +87,5 @@ obj-$(CONFIG_MESON_IRQ_GPIO) += irq-meson-gpio.o obj-$(CONFIG_GOLDFISH_PIC) += irq-goldfish-pic.o obj-$(CONFIG_NDS32) += irq-ativic32.o obj-$(CONFIG_QCOM_PDC) += qcom-pdc.o +obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o
drivers/irqchip/irq-csky-mpintc.c new file +198 -0
198 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH V11 1/8] irqchip: add C-SKY SMP interrupt controller
Quoted 17 lines · Guo Ren
- Irq-csky-mpintc is C-SKY smp system interrupt controller and it could support 16 soft irqs, 16 private irqs, and 992 max common irqs.
Changelog:
- Convert the cpumask to an interrupt-controller specific representation in driver's code, and not the SMP code's.
- pass checkpatch.pl
- MoveIPI_IRQinto the driver
- Removeirq_set_default_host()and useset_ipi_irq_mapping()
- Change name with upstream feed-back
- Change irq map, reservesoft_irq&private_irqspace
- Add License and Copyright
- Supportset_affinityfor irq balance in SMPSigned-off-by Guo Ren <[email protected]>Cc Marc Zyngier <[email protected]>
[...]
Quoted 32 lines
drivers/irqchip/irq-csky-mpintc.c new file +32
-0+/* C-SKY multi processor interrupt controller */ +static int __init +csky_mpintc_init (struct device_node *node,struct device_node *parent) +{ +unsigned int cpu, nr_irq; +int ret; + +if (parent) +return 0 ; + + ret =of_property_read_u32 (node,"csky,num-irqs" , &nr_irq); +if (ret <0 ) + nr_irq =INTC_IRQS ; + +if (INTCG_base ==NULL ) { + INTCG_base =ioremap (mfcr ("cr<31, 14>" ), +INTCL_SIZE *nr_cpu_ids +INTCG_SIZE ); +if (INTCG_base ==NULL ) +return -EIO ; + + INTCL_base = INTCG_base +INTCG_SIZE ; + +writel_relaxed (BIT (0 ), INTCG_base +INTCG_ICTLR ); + } + + root_domain =irq_domain_add_linear (node, nr_irq, &csky_irqdomain_ops, +NULL ); +if (!root_domain) +return -ENXIO ; + +/* for every cpu */ +for_each_present_cpu (cpu) {
drivers/irqchip/irq-csky-mpintc.c line 193
Quoted 10 lines
drivers/irqchip/irq-csky-mpintc.c new file +10
-0+per_cpu (intcl_reg, cpu) = INTCL_base + (INTCL_SIZE * cpu); +writel_relaxed (BIT (0 ),per_cpu (intcl_reg, cpu) +INTCL_PICTLR ); + } + +set_handle_irq (&csky_mpintc_handler); + +#ifdef CONFIG_SMP +set_send_ipi (&csky_mpintc_send_ipi); + +set_ipi_irq_mapping (&csky_mpintc_ipi_irq_mapping);
Same remark as before.
You do not need this second callback, and you should redefine set_send_ipi to take an irq number:
ipi_irq = irq_create_mapping(root_domain, IPI_IRQ); if (!ipi_irq) [handle error] set_send_ipi(csky_mpintc_send_ipi, ipi_irq);
and you can then delete both set_ipi_irq_mapping and csky_mpintc_handler, none of which serve any purpose.
In your SMP code:
void __init set_send_ipi(void (*func)(const struct cpumask *), int irq)
{
if (send_arch_ipi)
return;
send_arch_ipi = func;
ipi_irq = irq;
}and simplify setup_smp_ipi.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH V11 1/8] irqchip: add C-SKY SMP interrupt controller
Hi Marc,
Quoted 89 lines · Marc Zyngier
Quoted 17 lines · Guo Ren
- Irq-csky-mpintc is C-SKY smp system interrupt controller and it could support 16 soft irqs, 16 private irqs, and 992 max common irqs.
Changelog:
- Convert the cpumask to an interrupt-controller specific representation in driver's code, and not the SMP code's.
- pass checkpatch.pl
- MoveIPI_IRQinto the driver
- Removeirq_set_default_host()and useset_ipi_irq_mapping()
- Change name with upstream feed-back
- Change irq map, reservesoft_irq&private_irqspace
- Add License and Copyright
- Supportset_affinityfor irq balance in SMPSigned-off-by Guo Ren <[email protected]>Cc Marc Zyngier <[email protected]>[...]
Quoted 32 lines
drivers/irqchip/irq-csky-mpintc.c new file +32
-0+/* C-SKY multi processor interrupt controller */ +static int __init +csky_mpintc_init (struct device_node *node,struct device_node *parent) +{ +unsigned int cpu, nr_irq; +int ret; + +if (parent) +return 0 ; + + ret =of_property_read_u32 (node,"csky,num-irqs" , &nr_irq); +if (ret <0 ) + nr_irq =INTC_IRQS ; + +if (INTCG_base ==NULL ) { + INTCG_base =ioremap (mfcr ("cr<31, 14>" ), +INTCL_SIZE *nr_cpu_ids +INTCG_SIZE ); +if (INTCG_base ==NULL ) +return -EIO ; + + INTCL_base = INTCG_base +INTCG_SIZE ; + +writel_relaxed (BIT (0 ), INTCG_base +INTCG_ICTLR ); + } + + root_domain =irq_domain_add_linear (node, nr_irq, &csky_irqdomain_ops, +NULL ); +if (!root_domain) +return -ENXIO ; + +/* for every cpu */ +for_each_present_cpu (cpu) {drivers/irqchip/irq-csky-mpintc.c line 193
Quoted 10 lines
drivers/irqchip/irq-csky-mpintc.c new file +10
-0+per_cpu (intcl_reg, cpu) = INTCL_base + (INTCL_SIZE * cpu); +writel_relaxed (BIT (0 ),per_cpu (intcl_reg, cpu) +INTCL_PICTLR ); + } + +set_handle_irq (&csky_mpintc_handler); + +#ifdef CONFIG_SMP +set_send_ipi (&csky_mpintc_send_ipi); + +set_ipi_irq_mapping (&csky_mpintc_ipi_irq_mapping);Same remark as before.
You do not need this second callback, and you should redefine
set_send_ipito take an irq number:ipi_irq = irq_create_mapping(root_domain, IPI_IRQ); if (!ipi_irq) [handle error] set_send_ipi(csky_mpintc_send_ipi, ipi_irq);and you can then delete both
set_ipi_irq_mappingandcsky_mpintc_handler, none of which serve any purpose.In your SMP code:
void
__initset_send_ipi(void (*func)(const struct cpumask *), int irq){ if (send_arch_ipi) return; send_arch_ipi = func; ipi_irq = irq; }
Quoted 1 line
and simplify
setup_smp_ipi.
Ok, remove the set_ipi_irq_mapping. See my next version patch.
Best Regards
Guo Ren
PATCH v11 2/8 dt-bindings: interrupt-controller: C-SKY SMP intc
In reply to Guo RenDt-bindings doc about C-SKY Multi-processors interrupt controller.
Changelog:
- Should be: '#interrupt-cells' not 'interrupt-cells'
--- .../bindings/interrupt-controller/csky,mpintc.txt | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt new file +40 -0
@@ -0,0 +1,40 @@ +=========================================== +C-SKY Multi-processors Interrupt Controller +=========================================== + +C-SKY Multi-processors Interrupt Controller is designed for ck807/ck810/ck860 +SMP soc, and it also could be used in non-SMP system. + +Interrupt number definition: + + 0-15 : software irq, and we use 15 as our IPI_IRQ. + 16-31 : private irq, and we use 16 as the co-processor timer. + 31-1024: common irq for soc ip. + +============================= +intc node bindings definition +============================= + + Description: Describes SMP interrupt controller + + PROPERTIES + + - compatible + Usage: required + Value type: <string> + Definition: must be "csky,mpintc" + - #interrupt-cells + Usage: required + Value type: <u32> + Definition: must be <1> + - interrupt-controller: + Usage: required + +Examples: +--------- + + intc: interrupt-controller { + compatible = "csky,mpintc"; + #interrupt-cells = <1>; + interrupt-controller; + };
Signature · 1 line
2.7.4
PATCH v11 3/8 irqchip: add C-SKY APB bus interrupt controller
In reply to Guo Ren- irq-csky-apb-intc is a simple SOC interrupt controller which is used in a lot of C-SKY CPU SOC products.
Changelog:
- pass checkpatch.pl.
- use "bool ret" instead of "int ret"
- add support-pulse-signal in irq-csky-apb-intc.c
- change name with upstream feed-back
- add INTC_IFR to clear irq-pending
- remove CSKY_VECIRQ_LEGENCY
- change to generic irq chip framework
- add License and Copyright
- use irq_domain_add_linear instead of leagcy
--- drivers/irqchip/Kconfig | 8 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-csky-apb-intc.c | 274 ++++++++++++++++++++++++++++++++++++ 3 files changed, 283 insertions(+) create mode 100644 drivers/irqchip/irq-csky-apb-intc.c
drivers/irqchip/Kconfig +8 -0
@@ -380,6 +380,14 @@ config CSKY_MPINTC In fact it's not mmio map in hw and it use ld/st to visit the controller's register inside CPU. +config CSKY_APB_INTC + bool "C-SKY APB Interrupt Controller" + depends on CSKY + help + Say yes here to enable C-SKY APB interrupt controller driver used + by C-SKY single core SOC system. It use mmio map apb-bus to visit + the controller's register. + endmenu config SIFIVE_PLIC
drivers/irqchip/Makefile +1 -0
@@ -88,4 +88,5 @@ obj-$(CONFIG_GOLDFISH_PIC) += irq-goldfish-pic.o obj-$(CONFIG_NDS32) += irq-ativic32.o obj-$(CONFIG_QCOM_PDC) += qcom-pdc.o obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o +obj-$(CONFIG_CSKY_APB_INTC) += irq-csky-apb-intc.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o
drivers/irqchip/irq-csky-apb-intc.c new file +274 -0
274 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v11 4/8 dt-bindings: interrupt-controller: C-SKY APB intc
In reply to Guo Ren- Dt-bindings doc about C-SKY apb bus interrupt controller.
--- .../interrupt-controller/csky,apb-intc.txt | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt new file +62 -0
@@ -0,0 +1,62 @@ +============================== +C-SKY APB Interrupt Controller +============================== + +C-SKY APB Interrupt Controller is a simple soc interrupt controller +on the apb bus and we only use it as root irq controller. + + - csky,apb-intc is used in a lot of csky fpgas and socs, it support 64 irq nums. + - csky,dual-apb-intc consists of 2 apb-intc and 128 irq nums supported. + - csky,gx6605s-intc is gx6605s soc internal irq interrupt controller, 64 irq nums. + +============================= +intc node bindings definition +============================= + + Description: Describes APB interrupt controller + + PROPERTIES + + - compatible + Usage: required + Value type: <string> + Definition: must be "csky,apb-intc" + "csky,dual-apb-intc" + "csky,gx6605s-intc" + - #interrupt-cells + Usage: required + Value type: <u32> + Definition: must be <1> + - reg + Usage: required + Value type: <u32 u32> + Definition: <phyaddr size> in soc from cpu view + - interrupt-controller: + Usage: required + - csky,support-pulse-signal: + Usage: select + Description: to support pulse signal flag + +Examples: +--------- + + intc: interrupt-controller@500000 { + compatible = "csky,apb-intc"; + #interrupt-cells = <1>; + reg = <0x00500000 0x400>; + interrupt-controller; + }; + + intc: interrupt-controller@500000 { + compatible = "csky,dual-apb-intc"; + #interrupt-cells = <1>; + reg = <0x00500000 0x400>; + interrupt-controller; + }; + + intc: interrupt-controller@500000 { + compatible = "csky,gx6605s-intc"; + #interrupt-cells = <1>; + reg = <0x00500000 0x400>; + interrupt-controller; + };
Signature · 1 line
2.7.4
PATCH v11 5/8 clocksource: add C-SKY SMP timer
In reply to Guo RenThis timer is used by SMP system and use mfcr/mtcr instruction to access the regs.
Changelog:
- Add COMPILE_TEST
- Fixup smp boot error, cpuhp_setup_state must after timer_of_init()
- Add rollback for timer_of_cleanup.
- Use request_percpu_irq separate from time_of.
- Remove #define CPUHP_AP_CSKY_TIMER_STARTING.
- Add CPUHP_AP_CSKY_TIMER_STARTING in cpuhotplug.h.
- Support csky mp timer alpha version.
- Just use low-counter with 32bit width as clocksource.
- Coding convention with upstream feed-back.
--- drivers/clocksource/Kconfig | 10 +++ drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-mp-csky.c | 173 ++++++++++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 4 files changed, 185 insertions(+) create mode 100644 drivers/clocksource/timer-mp-csky.c
drivers/clocksource/Kconfig +10 -0
@@ -620,4 +620,14 @@ config RISCV_TIMER is accessed via both the SBI and the rdcycle instruction. This is required for all RISC-V systems. +config CSKY_MP_TIMER + bool "SMP Timer for the C-SKY platform" if COMPILE_TEST + depends on CSKY + select TIMER_OF + help + Say yes here to enable C-SKY SMP timer driver used for C-SKY SMP + system. + csky,mptimer is not only used in SMP system, it also could be used + single core system. It's not a mmio reg and it use mtcr/mfcr instruction. + endmenu
drivers/clocksource/Makefile +1 -0
@@ -79,3 +79,4 @@ obj-$(CONFIG_CLKSRC_ST_LPC) += clksrc_st_lpc.o obj-$(CONFIG_X86_NUMACHIP) += numachip.o obj-$(CONFIG_ATCPIT100_TIMER) += timer-atcpit100.o obj-$(CONFIG_RISCV_TIMER) += riscv_timer.o +obj-$(CONFIG_CSKY_MP_TIMER) += timer-mp-csky.o
drivers/clocksource/timer-mp-csky.c new file +173 -0
173 lines not on this page · raw message
include/linux/cpuhotplug.h +1 -0
@@ -126,6 +126,7 @@ enum cpuhp_state {CPUHP_AP_MIPS_GIC_TIMER_STARTING ,CPUHP_AP_ARC_TIMER_STARTING ,CPUHP_AP_RISCV_TIMER_STARTING , +CPUHP_AP_CSKY_TIMER_STARTING ,CPUHP_AP_KVM_STARTING ,CPUHP_AP_KVM_ARM_VGIC_INIT_STARTING , CPUHP_AP_KVM_ARM_VGIC_STARTING,
Signature · 1 line
2.7.4
PATCH v11 6/8 dt-bindings: timer: C-SKY Multi-processor timer
In reply to Guo RenDt-bingdings doc for C-SKY SMP system setting.
Changelog:
- Drop the interrupt-parent.
--- .../devicetree/bindings/timer/csky,mptimer.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/csky,mptimer.txt
Documentation/devicetree/bindings/timer/csky,mptimer.txt new file +42 -0
@@ -0,0 +1,42 @@ +============================ +C-SKY Multi-processors Timer +============================ + +C-SKY multi-processors timer is designed for C-SKY SMP system and the +regs is accessed by cpu co-processor 4 registers with mtcr/mfcr. + + - PTIM_CTLR "cr<0, 14>" Control reg to start reset timer. + - PTIM_TSR "cr<1, 14>" Interrupt cleanup status reg. + - PTIM_CCVR "cr<3, 14>" Current counter value reg. + - PTIM_LVR "cr<6, 14>" Window value reg to triger next event. + +============================== +timer node bindings definition +============================== + + Description: Describes SMP timer + + PROPERTIES + + - compatible + Usage: required + Value type: <string> + Definition: must be "csky,mptimer" + - clocks + Usage: required + Value type: <node> + Definition: must be input clk node + - interrupts + Usage: required + Value type: <u32> + Definition: must be timer irq num defined by soc + +Examples: +--------- + + timer: timer { + compatible = "csky,mptimer"; + clocks = <&dummy_apb_clk>; + interrupts = <16>; + interrupt-parent = <&intc>; + };
Signature · 1 line
2.7.4
PATCH v11 7/8 clocksource: add gx6605s SOC system timer
In reply to Guo RenChangelog:
- pass checkpatch.pl
- Add COMIPLE_TEST in Kconfig
- no cast is needed for "struct clock_event_device *ce = dev"
- remove: extra space after (u64)
- Add License and Copyright
- Use timer-of framework
- Change name with upstream feedback
- Use clksource_mmio framework
--- drivers/clocksource/Kconfig | 8 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-gx6605s.c | 154 ++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 drivers/clocksource/timer-gx6605s.c
drivers/clocksource/Kconfig +8 -0
@@ -630,4 +630,12 @@ config CSKY_MP_TIMER csky,mptimer is not only used in SMP system, it also could be used single core system. It's not a mmio reg and it use mtcr/mfcr instruction. +config GX6605S_TIMER + bool "Gx6605s SOC system timer driver" if COMPILE_TEST + depends on CSKY + select CLKSRC_MMIO + select TIMER_OF + help + This option enables support for gx6605s SOC's timer. + endmenu
drivers/clocksource/Makefile +1 -0
@@ -80,3 +80,4 @@ obj-$(CONFIG_X86_NUMACHIP) += numachip.o obj-$(CONFIG_ATCPIT100_TIMER) += timer-atcpit100.o obj-$(CONFIG_RISCV_TIMER) += riscv_timer.o obj-$(CONFIG_CSKY_MP_TIMER) += timer-mp-csky.o +obj-$(CONFIG_GX6605S_TIMER) += timer-gx6605s.o
drivers/clocksource/timer-gx6605s.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v11 8/8 dt-bindings: timer: gx6605s SOC timer
In reply to Guo RenDt-bindings doc for gx6605s SOC's system timer.
--- .../bindings/timer/csky,gx6605s-timer.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt
Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt new file +42 -0
@@ -0,0 +1,42 @@ +================= +gx6605s SOC Timer +================= + +The timer is used in gx6605s soc as system timer and the driver +contain clk event and clk source. + +============================== +timer node bindings definition +============================== + + Description: Describes gx6605s SOC timer + + PROPERTIES + + - compatible + Usage: required + Value type: <string> + Definition: must be "csky,gx6605s-timer" + - reg + Usage: required + Value type: <u32 u32> + Definition: <phyaddr size> in soc from cpu view + - clocks + Usage: required + Value type: phandle + clock specifier cells + Definition: must be input clk node + - interrupt + Usage: required + Value type: <u32> + Definition: must be timer irq num defined by soc + +Examples: +--------- + + timer0: timer@20a000 { + compatible = "csky,gx6605s-timer"; + reg = <0x0020a000 0x400>; + clocks = <&dummy_apb_clk>; + interrupts = <10>; + interrupt-parent = <&intc>; + };
Signature · 1 line
2.7.4