@@ -108,6 +108,7 @@ struct sa1111 {
108108 spinlock_t lock ;
109109 void __iomem * base ;
110110 struct sa1111_platform_data * pdata ;
111+ struct irq_domain * irqdomain ;
111112 struct gpio_chip gc ;
112113#ifdef CONFIG_PM
113114 void * saved_state ;
@@ -193,6 +194,14 @@ static struct sa1111_dev_info sa1111_devices[] = {
193194 },
194195};
195196
197+ static void sa1111_handle_irqdomain (struct irq_domain * irqdomain , int irq )
198+ {
199+ struct irq_desc * d = irq_to_desc (irq_linear_revmap (irqdomain , irq ));
200+
201+ if (d )
202+ generic_handle_irq_desc (d );
203+ }
204+
196205/*
197206 * SA1111 interrupt support. Since clearing an IRQ while there are
198207 * active IRQs causes the interrupt output to pulse, the upper levels
@@ -202,6 +211,7 @@ static void sa1111_irq_handler(struct irq_desc *desc)
202211{
203212 unsigned int stat0 , stat1 , i ;
204213 struct sa1111 * sachip = irq_desc_get_handler_data (desc );
214+ struct irq_domain * irqdomain ;
205215 void __iomem * mapbase = sachip -> base + SA1111_INTC ;
206216
207217 stat0 = readl_relaxed (mapbase + SA1111_INTSTATCLR0 );
@@ -218,33 +228,28 @@ static void sa1111_irq_handler(struct irq_desc *desc)
218228 return ;
219229 }
220230
231+ irqdomain = sachip -> irqdomain ;
232+
221233 for (i = 0 ; stat0 ; i ++ , stat0 >>= 1 )
222234 if (stat0 & 1 )
223- generic_handle_irq ( i + sachip -> irq_base );
235+ sa1111_handle_irqdomain ( irqdomain , i );
224236
225237 for (i = 32 ; stat1 ; i ++ , stat1 >>= 1 )
226238 if (stat1 & 1 )
227- generic_handle_irq ( i + sachip -> irq_base );
239+ sa1111_handle_irqdomain ( irqdomain , i );
228240
229241 /* For level-based interrupts */
230242 desc -> irq_data .chip -> irq_unmask (& desc -> irq_data );
231243}
232244
233- #define SA1111_IRQMASK_LO (x ) (1 << (x - sachip->irq_base))
234- #define SA1111_IRQMASK_HI (x ) (1 << (x - sachip->irq_base - 32))
235-
236245static u32 sa1111_irqmask (struct irq_data * d )
237246{
238- struct sa1111 * sachip = irq_data_get_irq_chip_data (d );
239-
240- return BIT ((d -> irq - sachip -> irq_base ) & 31 );
247+ return BIT (irqd_to_hwirq (d ) & 31 );
241248}
242249
243250static int sa1111_irqbank (struct irq_data * d )
244251{
245- struct sa1111 * sachip = irq_data_get_irq_chip_data (d );
246-
247- return ((d -> irq - sachip -> irq_base ) / 32 ) * 4 ;
252+ return (irqd_to_hwirq (d ) / 32 ) * 4 ;
248253}
249254
250255static void sa1111_ack_irq (struct irq_data * d )
@@ -350,10 +355,26 @@ static struct irq_chip sa1111_irq_chip = {
350355 .irq_set_wake = sa1111_wake_irq ,
351356};
352357
358+ static int sa1111_irqdomain_map (struct irq_domain * d , unsigned int irq ,
359+ irq_hw_number_t hwirq )
360+ {
361+ struct sa1111 * sachip = d -> host_data ;
362+
363+ irq_set_chip_data (irq , sachip );
364+ irq_set_chip_and_handler (irq , & sa1111_irq_chip , handle_edge_irq );
365+ irq_clear_status_flags (irq , IRQ_NOREQUEST | IRQ_NOPROBE );
366+
367+ return 0 ;
368+ }
369+
370+ static const struct irq_domain_ops sa1111_irqdomain_ops = {
371+ .map = sa1111_irqdomain_map ,
372+ .xlate = irq_domain_xlate_twocell ,
373+ };
374+
353375static int sa1111_setup_irq (struct sa1111 * sachip , unsigned irq_base )
354376{
355377 void __iomem * irqbase = sachip -> base + SA1111_INTC ;
356- unsigned i , irq ;
357378 int ret ;
358379
359380 /*
@@ -391,19 +412,21 @@ static int sa1111_setup_irq(struct sa1111 *sachip, unsigned irq_base)
391412 writel_relaxed (~0 , irqbase + SA1111_INTSTATCLR0 );
392413 writel_relaxed (~0 , irqbase + SA1111_INTSTATCLR1 );
393414
394- for (i = IRQ_GPAIN0 ; i <= SSPROR ; i ++ ) {
395- irq = sachip -> irq_base + i ;
396- irq_set_chip_and_handler (irq , & sa1111_irq_chip , handle_edge_irq );
397- irq_set_chip_data (irq , sachip );
398- irq_clear_status_flags (irq , IRQ_NOREQUEST | IRQ_NOPROBE );
415+ sachip -> irqdomain = irq_domain_add_linear (NULL , SA1111_IRQ_NR ,
416+ & sa1111_irqdomain_ops ,
417+ sachip );
418+ if (!sachip -> irqdomain ) {
419+ irq_free_descs (sachip -> irq_base , SA1111_IRQ_NR );
420+ return - ENOMEM ;
399421 }
400422
401- for (i = AUDXMTDMADONEA ; i <= IRQ_S1_BVD1_STSCHG ; i ++ ) {
402- irq = sachip -> irq_base + i ;
403- irq_set_chip_and_handler (irq , & sa1111_irq_chip , handle_edge_irq );
404- irq_set_chip_data (irq , sachip );
405- irq_clear_status_flags (irq , IRQ_NOREQUEST | IRQ_NOPROBE );
406- }
423+ irq_domain_associate_many (sachip -> irqdomain ,
424+ sachip -> irq_base + IRQ_GPAIN0 ,
425+ IRQ_GPAIN0 , SSPROR + 1 - IRQ_GPAIN0 );
426+ irq_domain_associate_many (sachip -> irqdomain ,
427+ sachip -> irq_base + AUDXMTDMADONEA ,
428+ AUDXMTDMADONEA ,
429+ IRQ_S1_BVD1_STSCHG + 1 - AUDXMTDMADONEA );
407430
408431 /*
409432 * Register SA1111 interrupt
@@ -428,12 +451,12 @@ static void sa1111_remove_irq(struct sa1111 *sachip)
428451 writel_relaxed (0 , irqbase + SA1111_WAKEEN0 );
429452 writel_relaxed (0 , irqbase + SA1111_WAKEEN1 );
430453
431- if (sachip -> irq != NO_IRQ ) {
432- irq_set_chained_handler_and_data (sachip -> irq , NULL , NULL );
433- irq_free_descs (sachip -> irq_base , SA1111_IRQ_NR );
454+ irq_domain_remove (sachip -> irqdomain );
434455
435- release_mem_region (sachip -> phys + SA1111_INTC , 512 );
436- }
456+ irq_set_chained_handler_and_data (sachip -> irq , NULL , NULL );
457+ irq_free_descs (sachip -> irq_base , SA1111_IRQ_NR );
458+
459+ release_mem_region (sachip -> phys + SA1111_INTC , 512 );
437460}
438461
439462enum {
0 commit comments