Skip to content

Commit 6baa9b2

Browse files
sravnborgdavem330
authored andcommitted
sparc32: genirq support
The conversion of sparc32 to genirq is based on original work done by David S. Miller. Daniel Hellstrom has helped in the conversion and implemented the shutdowm functionality. Marcel van Nies <morcles@gmail.com> has tested this on Sparc Station 20 Test status: sun4c - not tested sun4m,pci - not tested sun4m,sbus - tested (Sparc Classic, Sparc Station 5, Sparc Station 20) sun4d - not tested leon - tested on various combinations of leon boards, including SMP variants generic Introduce use of GENERIC_HARDIRQS and GENERIC_IRQ_SHOW Allocate 64 IRQs - which is enough even for SS2000 Use a table of irq_bucket to maintain uses IRQs irq_bucket is also used to chain several irq's that must be called when the same intrrupt is asserted Use irq_link to link a interrupt source to the irq All plafforms must now supply their own build_device_irq method handler_irq rewriten to use generic irq support floppy Read FLOPPY_IRQ from platform device Use generic request_irq to register the floppy interrupt Rewrote sparc_floppy_irq to use the generic irq support pcic: Introduce irq_chip Store mask in chip_data for use in mask/unmask functions Add build_device_irq for pcic Use pcic_build_device_irq in pci_time_init allocate virtual irqs in pcic_fill_irq sun4c: Introduce irq_chip Store mask in chip_data for use in mask/unmask functions Add build_device_irq for sun4c Use sun4c_build_device_irq in sun4c_init_timers sun4m: Introduce irq_chip Introduce dedicated mask/unmask methods Introduce sun4m_handler_data that allow easy access to necessary data in the mask/unmask functions Add a helper method to enable profile_timer (used from smp) Added sun4m_build_device_irq Use sun4m_build_device_irq in sun4m_init_timers TODO: There is no replacement for smp_rotate that always scheduled next CPU as interrupt target upon an interrupt sun4d: Introduce irq_chip Introduce dedicated mask/unmask methods Introduce sun4d_handler_data that allow easy access to necessary data in mask/unmask fuctions Rewrote sun4d_handler_irq to use generic irq support TODO: The original implmentation of enable/disable had: if (irq < NR_IRQS) return; The new implmentation does not distingush between SBUS and cpu interrupts. I am no sure what is right here. I assume we need to do something for the cpu interrupts. I have not succeeded booting my sun4d box (with or without this patch) and my understanding of this platfrom is limited. So I would be a bit suprised if this works. leon: Introduce irq_chip Store mask in chip_data for use in mask/unmask functions Add build_device_irq for leon Use leon_build_device_irq in leon_init_timers Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Acked-by: Daniel Hellstrom <daniel@gaisler.com> Tested-by: Daniel Hellstrom <daniel@gaisler.com> Tested-by: Marcel van Nies <morcles@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 06010fb commit 6baa9b2

14 files changed

Lines changed: 636 additions & 935 deletions

File tree

‎arch/sparc/Kconfig‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ config SPARC
2525
select HAVE_DMA_ATTRS
2626
select HAVE_DMA_API_DEBUG
2727
select HAVE_ARCH_JUMP_LABEL
28+
select HAVE_GENERIC_HARDIRQS
29+
select GENERIC_HARDIRQS_NO_DEPRECATED
30+
select GENERIC_IRQ_SHOW
31+
2832

2933
config SPARC32
3034
def_bool !64BIT
@@ -50,8 +54,6 @@ config SPARC64
5054
select RTC_DRV_STARFIRE
5155
select HAVE_PERF_EVENTS
5256
select PERF_USE_VMALLOC
53-
select HAVE_GENERIC_HARDIRQS
54-
select GENERIC_IRQ_SHOW
5557
select IRQ_PREFLOW_FASTEOI
5658

5759
config ARCH_DEFCONFIG

‎arch/sparc/include/asm/floppy_32.h‎

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,36 +281,34 @@ static inline void sun_fd_enable_dma(void)
281281
pdma_areasize = pdma_size;
282282
}
283283

284-
/* Our low-level entry point in arch/sparc/kernel/entry.S */
285-
extern int sparc_floppy_request_irq(int irq, unsigned long flags,
286-
irq_handler_t irq_handler);
284+
extern int sparc_floppy_request_irq(unsigned int irq,
285+
irq_handler_t irq_handler);
287286

288287
static int sun_fd_request_irq(void)
289288
{
290289
static int once = 0;
291-
int error;
292290

293-
if(!once) {
291+
if (!once) {
294292
once = 1;
295-
error = sparc_floppy_request_irq(FLOPPY_IRQ,
296-
IRQF_DISABLED,
297-
floppy_interrupt);
298-
return ((error == 0) ? 0 : -1);
299-
} else return 0;
293+
return sparc_floppy_request_irq(FLOPPY_IRQ, floppy_interrupt);
294+
} else {
295+
return 0;
296+
}
300297
}
301298

302299
static struct linux_prom_registers fd_regs[2];
303300

304301
static int sun_floppy_init(void)
305302
{
303+
struct platform_device *op;
304+
struct device_node *dp;
306305
char state[128];
307306
phandle tnode, fd_node;
308307
int num_regs;
309308
struct resource r;
310309

311310
use_virtual_dma = 1;
312311

313-
FLOPPY_IRQ = 11;
314312
/* Forget it if we aren't on a machine that could possibly
315313
* ever have a floppy drive.
316314
*/
@@ -349,6 +347,26 @@ static int sun_floppy_init(void)
349347
sun_fdc = (struct sun_flpy_controller *)
350348
of_ioremap(&r, 0, fd_regs[0].reg_size, "floppy");
351349

350+
/* Look up irq in platform_device.
351+
* We try "SUNW,fdtwo" and "fd"
352+
*/
353+
for_each_node_by_name(dp, "SUNW,fdtwo") {
354+
op = of_find_device_by_node(dp);
355+
if (op)
356+
break;
357+
}
358+
if (!op) {
359+
for_each_node_by_name(dp, "fd") {
360+
op = of_find_device_by_node(dp);
361+
if (op)
362+
break;
363+
}
364+
}
365+
if (!op)
366+
goto no_sun_fdc;
367+
368+
FLOPPY_IRQ = op->archdata.irqs[0];
369+
352370
/* Last minute sanity check... */
353371
if(sun_fdc->status_82072 == 0xff) {
354372
sun_fdc = NULL;

‎arch/sparc/include/asm/irq_32.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
#ifndef _SPARC_IRQ_H
77
#define _SPARC_IRQ_H
88

9-
#define NR_IRQS 16
9+
/* Allocated number of logical irq numbers.
10+
* sun4d boxes (ss2000e) should be OK with ~32.
11+
* Be on the safe side and make room for 64
12+
*/
13+
#define NR_IRQS 64
1014

1115
#include <linux/interrupt.h>
1216

‎arch/sparc/include/asm/system_32.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515

1616
#include <linux/irqflags.h>
1717

18-
static inline unsigned int probe_irq_mask(unsigned long val)
19-
{
20-
return 0;
21-
}
22-
2318
/*
2419
* Sparc (general) CPU types
2520
*/

‎arch/sparc/kernel/Makefile‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ obj-$(CONFIG_SPARC64) += pcr.o
7171
obj-$(CONFIG_SPARC64) += nmi.o
7272
obj-$(CONFIG_SPARC64_SMP) += cpumap.o
7373

74-
# sparc32 do not use GENERIC_HARDIRQS but uses the generic devres implementation
75-
obj-$(CONFIG_SPARC32) += devres.o
76-
devres-y := ../../../kernel/irq/devres.o
77-
7874
obj-y += dma.o
7975

8076
obj-$(CONFIG_SPARC32_PCI) += pcic.o

‎arch/sparc/kernel/irq.h‎

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
#include <asm/btfixup.h>
44

5+
struct irq_bucket {
6+
struct irq_bucket *next;
7+
unsigned int real_irq;
8+
unsigned int irq;
9+
unsigned int pil;
10+
};
11+
12+
#define SUN4D_MAX_BOARD 10
13+
#define SUN4D_MAX_IRQ ((SUN4D_MAX_BOARD + 2) << 5)
14+
15+
/* Map between the irq identifier used in hw to the
16+
* irq_bucket. The map is sufficient large to hold
17+
* the sun4d hw identifiers.
18+
*/
19+
extern struct irq_bucket *irq_map[SUN4D_MAX_IRQ];
20+
21+
522
/* sun4m specific type definitions */
623

724
/* This maps direct to CPU specific interrupt registers */
@@ -35,6 +52,10 @@ struct sparc_irq_config {
3552
};
3653
extern struct sparc_irq_config sparc_irq_config;
3754

55+
unsigned int irq_alloc(unsigned int real_irq, unsigned int pil);
56+
void irq_link(unsigned int irq);
57+
void irq_unlink(unsigned int irq);
58+
void handler_irq(unsigned int pil, struct pt_regs *regs);
3859

3960
/* Dave Redman (djhr@tadpole.co.uk)
4061
* changed these to function pointers.. it saves cycles and will allow
@@ -44,33 +65,9 @@ extern struct sparc_irq_config sparc_irq_config;
4465
* Changed these to btfixup entities... It saves cycles :)
4566
*/
4667

47-
BTFIXUPDEF_CALL(void, disable_irq, unsigned int)
48-
BTFIXUPDEF_CALL(void, enable_irq, unsigned int)
49-
BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int)
50-
BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int)
5168
BTFIXUPDEF_CALL(void, clear_clock_irq, void)
5269
BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int)
5370

54-
static inline void __disable_irq(unsigned int irq)
55-
{
56-
BTFIXUP_CALL(disable_irq)(irq);
57-
}
58-
59-
static inline void __enable_irq(unsigned int irq)
60-
{
61-
BTFIXUP_CALL(enable_irq)(irq);
62-
}
63-
64-
static inline void disable_pil_irq(unsigned int irq)
65-
{
66-
BTFIXUP_CALL(disable_pil_irq)(irq);
67-
}
68-
69-
static inline void enable_pil_irq(unsigned int irq)
70-
{
71-
BTFIXUP_CALL(enable_pil_irq)(irq);
72-
}
73-
7471
static inline void clear_clock_irq(void)
7572
{
7673
BTFIXUP_CALL(clear_clock_irq)();

0 commit comments

Comments
 (0)