~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/powerpc/platforms/powermac/pic.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <linux/signal.h>
22
22
#include <linux/pci.h>
23
23
#include <linux/interrupt.h>
24
 
#include <linux/sysdev.h>
 
24
#include <linux/syscore_ops.h>
25
25
#include <linux/adb.h>
26
26
#include <linux/pmu.h>
27
27
#include <linux/module.h>
82
82
        }
83
83
}
84
84
 
85
 
static void pmac_mask_and_ack_irq(unsigned int virq)
 
85
static void pmac_mask_and_ack_irq(struct irq_data *d)
86
86
{
87
 
        unsigned int src = irq_map[virq].hwirq;
 
87
        unsigned int src = irqd_to_hwirq(d);
88
88
        unsigned long bit = 1UL << (src & 0x1f);
89
89
        int i = src >> 5;
90
90
        unsigned long flags;
104
104
        raw_spin_unlock_irqrestore(&pmac_pic_lock, flags);
105
105
}
106
106
 
107
 
static void pmac_ack_irq(unsigned int virq)
 
107
static void pmac_ack_irq(struct irq_data *d)
108
108
{
109
 
        unsigned int src = irq_map[virq].hwirq;
 
109
        unsigned int src = irqd_to_hwirq(d);
110
110
        unsigned long bit = 1UL << (src & 0x1f);
111
111
        int i = src >> 5;
112
112
        unsigned long flags;
149
149
/* When an irq gets requested for the first client, if it's an
150
150
 * edge interrupt, we clear any previous one on the controller
151
151
 */
152
 
static unsigned int pmac_startup_irq(unsigned int virq)
 
152
static unsigned int pmac_startup_irq(struct irq_data *d)
153
153
{
154
154
        unsigned long flags;
155
 
        unsigned int src = irq_map[virq].hwirq;
 
155
        unsigned int src = irqd_to_hwirq(d);
156
156
        unsigned long bit = 1UL << (src & 0x1f);
157
157
        int i = src >> 5;
158
158
 
159
159
        raw_spin_lock_irqsave(&pmac_pic_lock, flags);
160
 
        if ((irq_to_desc(virq)->status & IRQ_LEVEL) == 0)
 
160
        if (!irqd_is_level_type(d))
161
161
                out_le32(&pmac_irq_hw[i]->ack, bit);
162
162
        __set_bit(src, ppc_cached_irq_mask);
163
163
        __pmac_set_irq_mask(src, 0);
166
166
        return 0;
167
167
}
168
168
 
169
 
static void pmac_mask_irq(unsigned int virq)
 
169
static void pmac_mask_irq(struct irq_data *d)
170
170
{
171
171
        unsigned long flags;
172
 
        unsigned int src = irq_map[virq].hwirq;
 
172
        unsigned int src = irqd_to_hwirq(d);
173
173
 
174
174
        raw_spin_lock_irqsave(&pmac_pic_lock, flags);
175
175
        __clear_bit(src, ppc_cached_irq_mask);
177
177
        raw_spin_unlock_irqrestore(&pmac_pic_lock, flags);
178
178
}
179
179
 
180
 
static void pmac_unmask_irq(unsigned int virq)
 
180
static void pmac_unmask_irq(struct irq_data *d)
181
181
{
182
182
        unsigned long flags;
183
 
        unsigned int src = irq_map[virq].hwirq;
 
183
        unsigned int src = irqd_to_hwirq(d);
184
184
 
185
185
        raw_spin_lock_irqsave(&pmac_pic_lock, flags);
186
186
        __set_bit(src, ppc_cached_irq_mask);
188
188
        raw_spin_unlock_irqrestore(&pmac_pic_lock, flags);
189
189
}
190
190
 
191
 
static int pmac_retrigger(unsigned int virq)
 
191
static int pmac_retrigger(struct irq_data *d)
192
192
{
193
193
        unsigned long flags;
194
194
 
195
195
        raw_spin_lock_irqsave(&pmac_pic_lock, flags);
196
 
        __pmac_retrigger(irq_map[virq].hwirq);
 
196
        __pmac_retrigger(irqd_to_hwirq(d));
197
197
        raw_spin_unlock_irqrestore(&pmac_pic_lock, flags);
198
198
        return 1;
199
199
}
200
200
 
201
201
static struct irq_chip pmac_pic = {
202
202
        .name           = "PMAC-PIC",
203
 
        .startup        = pmac_startup_irq,
204
 
        .mask           = pmac_mask_irq,
205
 
        .ack            = pmac_ack_irq,
206
 
        .mask_ack       = pmac_mask_and_ack_irq,
207
 
        .unmask         = pmac_unmask_irq,
208
 
        .retrigger      = pmac_retrigger,
 
203
        .irq_startup    = pmac_startup_irq,
 
204
        .irq_mask       = pmac_mask_irq,
 
205
        .irq_ack        = pmac_ack_irq,
 
206
        .irq_mask_ack   = pmac_mask_and_ack_irq,
 
207
        .irq_unmask     = pmac_unmask_irq,
 
208
        .irq_retrigger  = pmac_retrigger,
209
209
};
210
210
 
211
211
static irqreturn_t gatwick_action(int cpl, void *dev_id)
239
239
        unsigned long bits = 0;
240
240
        unsigned long flags;
241
241
 
242
 
#ifdef CONFIG_SMP
243
 
        void psurge_smp_message_recv(void);
244
 
 
245
 
        /* IPI's are a hack on the powersurge -- Cort */
246
 
        if ( smp_processor_id() != 0 ) {
247
 
                psurge_smp_message_recv();
248
 
                return NO_IRQ_IGNORE;   /* ignore, already handled */
 
242
#ifdef CONFIG_PPC_PMAC32_PSURGE
 
243
        /* IPI's are a hack on the powersurge -- Cort */
 
244
        if (smp_processor_id() != 0) {
 
245
                return  psurge_secondary_virq;
249
246
        }
250
 
#endif /* CONFIG_SMP */
 
247
#endif /* CONFIG_PPC_PMAC32_PSURGE */
251
248
        raw_spin_lock_irqsave(&pmac_pic_lock, flags);
252
249
        for (irq = max_real_irqs; (irq -= 32) >= 0; ) {
253
250
                int i = irq >> 5;
289
286
static int pmac_pic_host_map(struct irq_host *h, unsigned int virq,
290
287
                             irq_hw_number_t hw)
291
288
{
292
 
        struct irq_desc *desc = irq_to_desc(virq);
293
289
        int level;
294
290
 
295
291
        if (hw >= max_irqs)
300
296
         */
301
297
        level = !!(level_mask[hw >> 5] & (1UL << (hw & 0x1f)));
302
298
        if (level)
303
 
                desc->status |= IRQ_LEVEL;
304
 
        set_irq_chip_and_handler(virq, &pmac_pic, level ?
305
 
                                 handle_level_irq : handle_edge_irq);
 
299
                irq_set_status_flags(virq, IRQ_LEVEL);
 
300
        irq_set_chip_and_handler(virq, &pmac_pic,
 
301
                                 level ? handle_level_irq : handle_edge_irq);
306
302
        return 0;
307
303
}
308
304
 
472
468
 
473
469
static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
474
470
{
475
 
        struct mpic *mpic = desc->handler_data;
476
 
 
 
471
        struct irq_chip *chip = irq_desc_get_chip(desc);
 
472
        struct mpic *mpic = irq_desc_get_handler_data(desc);
477
473
        unsigned int cascade_irq = mpic_get_one_irq(mpic);
 
474
 
478
475
        if (cascade_irq != NO_IRQ)
479
476
                generic_handle_irq(cascade_irq);
480
 
        desc->chip->eoi(irq);
 
477
 
 
478
        chip->irq_eoi(&desc->irq_data);
481
479
}
482
480
 
483
481
static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
589
587
                of_node_put(slave);
590
588
                return 0;
591
589
        }
592
 
        set_irq_data(cascade, mpic2);
593
 
        set_irq_chained_handler(cascade, pmac_u3_cascade);
 
590
        irq_set_handler_data(cascade, mpic2);
 
591
        irq_set_chained_handler(cascade, pmac_u3_cascade);
594
592
 
595
593
        of_node_put(slave);
596
594
        return 0;
676
674
        return viaint;
677
675
}
678
676
 
679
 
static int pmacpic_suspend(struct sys_device *sysdev, pm_message_t state)
 
677
static int pmacpic_suspend(void)
680
678
{
681
679
        int viaint = pmacpic_find_viaint();
682
680
 
697
695
        return 0;
698
696
}
699
697
 
700
 
static int pmacpic_resume(struct sys_device *sysdev)
 
698
static void pmacpic_resume(void)
701
699
{
702
700
        int i;
703
701
 
707
705
        mb();
708
706
        for (i = 0; i < max_real_irqs; ++i)
709
707
                if (test_bit(i, sleep_save_mask))
710
 
                        pmac_unmask_irq(i);
711
 
 
712
 
        return 0;
 
708
                        pmac_unmask_irq(irq_get_irq_data(i));
713
709
}
714
710
 
715
 
#endif /* CONFIG_PM && CONFIG_PPC32 */
716
 
 
717
 
static struct sysdev_class pmacpic_sysclass = {
718
 
        .name = "pmac_pic",
719
 
};
720
 
 
721
 
static struct sys_device device_pmacpic = {
722
 
        .id             = 0,
723
 
        .cls            = &pmacpic_sysclass,
724
 
};
725
 
 
726
 
static struct sysdev_driver driver_pmacpic = {
727
 
#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
728
 
        .suspend        = &pmacpic_suspend,
729
 
        .resume         = &pmacpic_resume,
730
 
#endif /* CONFIG_PM && CONFIG_PPC32 */
731
 
};
732
 
 
733
 
static int __init init_pmacpic_sysfs(void)
 
711
static struct syscore_ops pmacpic_syscore_ops = {
 
712
        .suspend        = pmacpic_suspend,
 
713
        .resume         = pmacpic_resume,
 
714
};
 
715
 
 
716
static int __init init_pmacpic_syscore(void)
734
717
{
735
 
#ifdef CONFIG_PPC32
736
 
        if (max_irqs == 0)
737
 
                return -ENODEV;
738
 
#endif
739
 
        printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");
740
 
        sysdev_class_register(&pmacpic_sysclass);
741
 
        sysdev_register(&device_pmacpic);
742
 
        sysdev_driver_register(&pmacpic_sysclass, &driver_pmacpic);
 
718
        if (pmac_irq_hw[0])
 
719
                register_syscore_ops(&pmacpic_syscore_ops);
743
720
        return 0;
744
721
}
745
 
machine_subsys_initcall(powermac, init_pmacpic_sysfs);
746
 
 
 
722
 
 
723
machine_subsys_initcall(powermac, init_pmacpic_syscore);
 
724
 
 
725
#endif /* CONFIG_PM && CONFIG_PPC32 */