xref: /OK3568_Linux_fs/kernel/Documentation/arm/interrupts.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun==========
2*4882a593SmuzhiyunInterrupts
3*4882a593Smuzhiyun==========
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun2.5.2-rmk5:
6*4882a593Smuzhiyun  This is the first kernel that contains a major shake up of some of the
7*4882a593Smuzhiyun  major architecture-specific subsystems.
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunFirstly, it contains some pretty major changes to the way we handle the
10*4882a593SmuzhiyunMMU TLB.  Each MMU TLB variant is now handled completely separately -
11*4882a593Smuzhiyunwe have TLB v3, TLB v4 (without write buffer), TLB v4 (with write buffer),
12*4882a593Smuzhiyunand finally TLB v4 (with write buffer, with I TLB invalidate entry).
13*4882a593SmuzhiyunThere is more assembly code inside each of these functions, mainly to
14*4882a593Smuzhiyunallow more flexible TLB handling for the future.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunSecondly, the IRQ subsystem.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunThe 2.5 kernels will be having major changes to the way IRQs are handled.
19*4882a593SmuzhiyunUnfortunately, this means that machine types that touch the irq_desc[]
20*4882a593Smuzhiyunarray (basically all machine types) will break, and this means every
21*4882a593Smuzhiyunmachine type that we currently have.
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunLets take an example.  On the Assabet with Neponset, we have::
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun                  GPIO25                 IRR:2
26*4882a593Smuzhiyun        SA1100 ------------> Neponset -----------> SA1111
27*4882a593Smuzhiyun                                         IIR:1
28*4882a593Smuzhiyun                                      -----------> USAR
29*4882a593Smuzhiyun                                         IIR:0
30*4882a593Smuzhiyun                                      -----------> SMC9196
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunThe way stuff currently works, all SA1111 interrupts are mutually
33*4882a593Smuzhiyunexclusive of each other - if you're processing one interrupt from the
34*4882a593SmuzhiyunSA1111 and another comes in, you have to wait for that interrupt to
35*4882a593Smuzhiyunfinish processing before you can service the new interrupt.  Eg, an
36*4882a593SmuzhiyunIDE PIO-based interrupt on the SA1111 excludes all other SA1111 and
37*4882a593SmuzhiyunSMC9196 interrupts until it has finished transferring its multi-sector
38*4882a593Smuzhiyundata, which can be a long time.  Note also that since we loop in the
39*4882a593SmuzhiyunSA1111 IRQ handler, SA1111 IRQs can hold off SMC9196 IRQs indefinitely.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunThe new approach brings several new ideas...
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunWe introduce the concept of a "parent" and a "child".  For example,
45*4882a593Smuzhiyunto the Neponset handler, the "parent" is GPIO25, and the "children"d
46*4882a593Smuzhiyunare SA1111, SMC9196 and USAR.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunWe also bring the idea of an IRQ "chip" (mainly to reduce the size of
49*4882a593Smuzhiyunthe irqdesc array).  This doesn't have to be a real "IC"; indeed the
50*4882a593SmuzhiyunSA11x0 IRQs are handled by two separate "chip" structures, one for
51*4882a593SmuzhiyunGPIO0-10, and another for all the rest.  It is just a container for
52*4882a593Smuzhiyunthe various operations (maybe this'll change to a better name).
53*4882a593SmuzhiyunThis structure has the following operations::
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun  struct irqchip {
56*4882a593Smuzhiyun          /*
57*4882a593Smuzhiyun           * Acknowledge the IRQ.
58*4882a593Smuzhiyun           * If this is a level-based IRQ, then it is expected to mask the IRQ
59*4882a593Smuzhiyun           * as well.
60*4882a593Smuzhiyun           */
61*4882a593Smuzhiyun          void (*ack)(unsigned int irq);
62*4882a593Smuzhiyun          /*
63*4882a593Smuzhiyun           * Mask the IRQ in hardware.
64*4882a593Smuzhiyun           */
65*4882a593Smuzhiyun          void (*mask)(unsigned int irq);
66*4882a593Smuzhiyun          /*
67*4882a593Smuzhiyun           * Unmask the IRQ in hardware.
68*4882a593Smuzhiyun           */
69*4882a593Smuzhiyun          void (*unmask)(unsigned int irq);
70*4882a593Smuzhiyun          /*
71*4882a593Smuzhiyun           * Re-run the IRQ
72*4882a593Smuzhiyun           */
73*4882a593Smuzhiyun          void (*rerun)(unsigned int irq);
74*4882a593Smuzhiyun          /*
75*4882a593Smuzhiyun           * Set the type of the IRQ.
76*4882a593Smuzhiyun           */
77*4882a593Smuzhiyun          int (*type)(unsigned int irq, unsigned int, type);
78*4882a593Smuzhiyun  };
79*4882a593Smuzhiyun
80*4882a593Smuzhiyunack
81*4882a593Smuzhiyun       - required.  May be the same function as mask for IRQs
82*4882a593Smuzhiyun         handled by do_level_IRQ.
83*4882a593Smuzhiyunmask
84*4882a593Smuzhiyun       - required.
85*4882a593Smuzhiyununmask
86*4882a593Smuzhiyun       - required.
87*4882a593Smuzhiyunrerun
88*4882a593Smuzhiyun       - optional.  Not required if you're using do_level_IRQ for all
89*4882a593Smuzhiyun         IRQs that use this 'irqchip'.  Generally expected to re-trigger
90*4882a593Smuzhiyun         the hardware IRQ if possible.  If not, may call the handler
91*4882a593Smuzhiyun	 directly.
92*4882a593Smuzhiyuntype
93*4882a593Smuzhiyun       - optional.  If you don't support changing the type of an IRQ,
94*4882a593Smuzhiyun         it should be null so people can detect if they are unable to
95*4882a593Smuzhiyun         set the IRQ type.
96*4882a593Smuzhiyun
97*4882a593SmuzhiyunFor each IRQ, we keep the following information:
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun        - "disable" depth (number of disable_irq()s without enable_irq()s)
100*4882a593Smuzhiyun        - flags indicating what we can do with this IRQ (valid, probe,
101*4882a593Smuzhiyun          noautounmask) as before
102*4882a593Smuzhiyun        - status of the IRQ (probing, enable, etc)
103*4882a593Smuzhiyun        - chip
104*4882a593Smuzhiyun        - per-IRQ handler
105*4882a593Smuzhiyun        - irqaction structure list
106*4882a593Smuzhiyun
107*4882a593SmuzhiyunThe handler can be one of the 3 standard handlers - "level", "edge" and
108*4882a593Smuzhiyun"simple", or your own specific handler if you need to do something special.
109*4882a593Smuzhiyun
110*4882a593SmuzhiyunThe "level" handler is what we currently have - its pretty simple.
111*4882a593Smuzhiyun"edge" knows about the brokenness of such IRQ implementations - that you
112*4882a593Smuzhiyunneed to leave the hardware IRQ enabled while processing it, and queueing
113*4882a593Smuzhiyunfurther IRQ events should the IRQ happen again while processing.  The
114*4882a593Smuzhiyun"simple" handler is very basic, and does not perform any hardware
115*4882a593Smuzhiyunmanipulation, nor state tracking.  This is useful for things like the
116*4882a593SmuzhiyunSMC9196 and USAR above.
117*4882a593Smuzhiyun
118*4882a593SmuzhiyunSo, what's changed?
119*4882a593Smuzhiyun===================
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun1. Machine implementations must not write to the irqdesc array.
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun2. New functions to manipulate the irqdesc array.  The first 4 are expected
124*4882a593Smuzhiyun   to be useful only to machine specific code.  The last is recommended to
125*4882a593Smuzhiyun   only be used by machine specific code, but may be used in drivers if
126*4882a593Smuzhiyun   absolutely necessary.
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun        set_irq_chip(irq,chip)
129*4882a593Smuzhiyun                Set the mask/unmask methods for handling this IRQ
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun        set_irq_handler(irq,handler)
132*4882a593Smuzhiyun                Set the handler for this IRQ (level, edge, simple)
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun        set_irq_chained_handler(irq,handler)
135*4882a593Smuzhiyun                Set a "chained" handler for this IRQ - automatically
136*4882a593Smuzhiyun                enables this IRQ (eg, Neponset and SA1111 handlers).
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun        set_irq_flags(irq,flags)
139*4882a593Smuzhiyun                Set the valid/probe/noautoenable flags.
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun        set_irq_type(irq,type)
142*4882a593Smuzhiyun                Set active the IRQ edge(s)/level.  This replaces the
143*4882a593Smuzhiyun                SA1111 INTPOL manipulation, and the set_GPIO_IRQ_edge()
144*4882a593Smuzhiyun                function.  Type should be one of IRQ_TYPE_xxx defined in
145*4882a593Smuzhiyun		<linux/irq.h>
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun3. set_GPIO_IRQ_edge() is obsolete, and should be replaced by set_irq_type.
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun4. Direct access to SA1111 INTPOL is deprecated.  Use set_irq_type instead.
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun5. A handler is expected to perform any necessary acknowledgement of the
152*4882a593Smuzhiyun   parent IRQ via the correct chip specific function.  For instance, if
153*4882a593Smuzhiyun   the SA1111 is directly connected to a SA1110 GPIO, then you should
154*4882a593Smuzhiyun   acknowledge the SA1110 IRQ each time you re-read the SA1111 IRQ status.
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun6. For any child which doesn't have its own IRQ enable/disable controls
157*4882a593Smuzhiyun   (eg, SMC9196), the handler must mask or acknowledge the parent IRQ
158*4882a593Smuzhiyun   while the child handler is called, and the child handler should be the
159*4882a593Smuzhiyun   "simple" handler (not "edge" nor "level").  After the handler completes,
160*4882a593Smuzhiyun   the parent IRQ should be unmasked, and the status of all children must
161*4882a593Smuzhiyun   be re-checked for pending events.  (see the Neponset IRQ handler for
162*4882a593Smuzhiyun   details).
163*4882a593Smuzhiyun
164*4882a593Smuzhiyun7. fixup_irq() is gone, as is `arch/arm/mach-*/include/mach/irq.h`
165*4882a593Smuzhiyun
166*4882a593SmuzhiyunPlease note that this will not solve all problems - some of them are
167*4882a593Smuzhiyunhardware based.  Mixing level-based and edge-based IRQs on the same
168*4882a593Smuzhiyunparent signal (eg neponset) is one such area where a software based
169*4882a593Smuzhiyunsolution can't provide the full answer to low IRQ latency.
170