~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/scsi/sun_esp.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#include <linux/dma-mapping.h>
13
13
#include <linux/of.h>
14
14
#include <linux/of_device.h>
 
15
#include <linux/gfp.h>
15
16
 
16
17
#include <asm/irq.h>
17
18
#include <asm/io.h>
43
44
};
44
45
 
45
46
static int __devinit esp_sbus_setup_dma(struct esp *esp,
46
 
                                        struct of_device *dma_of)
 
47
                                        struct platform_device *dma_of)
47
48
{
48
49
        esp->dma = dma_of;
49
50
 
80
81
 
81
82
static int __devinit esp_sbus_map_regs(struct esp *esp, int hme)
82
83
{
83
 
        struct of_device *op = esp->dev;
 
84
        struct platform_device *op = esp->dev;
84
85
        struct resource *res;
85
86
 
86
87
        /* On HME, two reg sets exist, first is DVMA,
100
101
 
101
102
static int __devinit esp_sbus_map_command_block(struct esp *esp)
102
103
{
103
 
        struct of_device *op = esp->dev;
 
104
        struct platform_device *op = esp->dev;
104
105
 
105
106
        esp->command_block = dma_alloc_coherent(&op->dev, 16,
106
107
                                                &esp->command_block_dma,
113
114
static int __devinit esp_sbus_register_irq(struct esp *esp)
114
115
{
115
116
        struct Scsi_Host *host = esp->host;
116
 
        struct of_device *op = esp->dev;
 
117
        struct platform_device *op = esp->dev;
117
118
 
118
 
        host->irq = op->irqs[0];
 
119
        host->irq = op->archdata.irqs[0];
119
120
        return request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp);
120
121
}
121
122
 
122
 
static void __devinit esp_get_scsi_id(struct esp *esp, struct of_device *espdma)
 
123
static void __devinit esp_get_scsi_id(struct esp *esp, struct platform_device *espdma)
123
124
{
124
 
        struct of_device *op = esp->dev;
 
125
        struct platform_device *op = esp->dev;
125
126
        struct device_node *dp;
126
127
 
127
 
        dp = op->node;
 
128
        dp = op->dev.of_node;
128
129
        esp->scsi_id = of_getintprop_default(dp, "initiator-id", 0xff);
129
130
        if (esp->scsi_id != 0xff)
130
131
                goto done;
133
134
        if (esp->scsi_id != 0xff)
134
135
                goto done;
135
136
 
136
 
        esp->scsi_id = of_getintprop_default(espdma->node,
 
137
        esp->scsi_id = of_getintprop_default(espdma->dev.of_node,
137
138
                                             "scsi-initiator-id", 7);
138
139
 
139
140
done:
143
144
 
144
145
static void __devinit esp_get_differential(struct esp *esp)
145
146
{
146
 
        struct of_device *op = esp->dev;
 
147
        struct platform_device *op = esp->dev;
147
148
        struct device_node *dp;
148
149
 
149
 
        dp = op->node;
 
150
        dp = op->dev.of_node;
150
151
        if (of_find_property(dp, "differential", NULL))
151
152
                esp->flags |= ESP_FLAG_DIFFERENTIAL;
152
153
        else
155
156
 
156
157
static void __devinit esp_get_clock_params(struct esp *esp)
157
158
{
158
 
        struct of_device *op = esp->dev;
 
159
        struct platform_device *op = esp->dev;
159
160
        struct device_node *bus_dp, *dp;
160
161
        int fmhz;
161
162
 
162
 
        dp = op->node;
 
163
        dp = op->dev.of_node;
163
164
        bus_dp = dp->parent;
164
165
 
165
166
        fmhz = of_getintprop_default(dp, "clock-frequency", 0);
169
170
        esp->cfreq = fmhz;
170
171
}
171
172
 
172
 
static void __devinit esp_get_bursts(struct esp *esp, struct of_device *dma_of)
 
173
static void __devinit esp_get_bursts(struct esp *esp, struct platform_device *dma_of)
173
174
{
174
 
        struct device_node *dma_dp = dma_of->node;
175
 
        struct of_device *op = esp->dev;
 
175
        struct device_node *dma_dp = dma_of->dev.of_node;
 
176
        struct platform_device *op = esp->dev;
176
177
        struct device_node *dp;
177
178
        u8 bursts, val;
178
179
 
179
 
        dp = op->node;
 
180
        dp = op->dev.of_node;
180
181
        bursts = of_getintprop_default(dp, "burst-sizes", 0xff);
181
182
        val = of_getintprop_default(dma_dp, "burst-sizes", 0xff);
182
183
        if (val != 0xff)
194
195
        esp->bursts = bursts;
195
196
}
196
197
 
197
 
static void __devinit esp_sbus_get_props(struct esp *esp, struct of_device *espdma)
 
198
static void __devinit esp_sbus_get_props(struct esp *esp, struct platform_device *espdma)
198
199
{
199
200
        esp_get_scsi_id(esp, espdma);
200
201
        esp_get_differential(esp);
215
216
static dma_addr_t sbus_esp_map_single(struct esp *esp, void *buf,
216
217
                                      size_t sz, int dir)
217
218
{
218
 
        struct of_device *op = esp->dev;
 
219
        struct platform_device *op = esp->dev;
219
220
 
220
221
        return dma_map_single(&op->dev, buf, sz, dir);
221
222
}
223
224
static int sbus_esp_map_sg(struct esp *esp, struct scatterlist *sg,
224
225
                                  int num_sg, int dir)
225
226
{
226
 
        struct of_device *op = esp->dev;
 
227
        struct platform_device *op = esp->dev;
227
228
 
228
229
        return dma_map_sg(&op->dev, sg, num_sg, dir);
229
230
}
231
232
static void sbus_esp_unmap_single(struct esp *esp, dma_addr_t addr,
232
233
                                  size_t sz, int dir)
233
234
{
234
 
        struct of_device *op = esp->dev;
 
235
        struct platform_device *op = esp->dev;
235
236
 
236
237
        dma_unmap_single(&op->dev, addr, sz, dir);
237
238
}
239
240
static void sbus_esp_unmap_sg(struct esp *esp, struct scatterlist *sg,
240
241
                              int num_sg, int dir)
241
242
{
242
 
        struct of_device *op = esp->dev;
 
243
        struct platform_device *op = esp->dev;
243
244
 
244
245
        dma_unmap_sg(&op->dev, sg, num_sg, dir);
245
246
}
255
256
{
256
257
        int can_do_burst16, can_do_burst32, can_do_burst64;
257
258
        int can_do_sbus64, lim;
258
 
        struct of_device *op;
 
259
        struct platform_device *op;
259
260
        u32 val;
260
261
 
261
262
        can_do_burst16 = (esp->bursts & DMA_BURST16) != 0;
486
487
        .dma_error      =       sbus_esp_dma_error,
487
488
};
488
489
 
489
 
static int __devinit esp_sbus_probe_one(struct of_device *op,
490
 
                                        struct of_device *espdma,
 
490
static int __devinit esp_sbus_probe_one(struct platform_device *op,
 
491
                                        struct platform_device *espdma,
491
492
                                        int hme)
492
493
{
493
494
        struct scsi_host_template *tpnt = &scsi_esp_template;
561
562
        return err;
562
563
}
563
564
 
564
 
static int __devinit esp_sbus_probe(struct of_device *op, const struct of_device_id *match)
 
565
static int __devinit esp_sbus_probe(struct platform_device *op, const struct of_device_id *match)
565
566
{
566
567
        struct device_node *dma_node = NULL;
567
 
        struct device_node *dp = op->node;
568
 
        struct of_device *dma_of = NULL;
 
568
        struct device_node *dp = op->dev.of_node;
 
569
        struct platform_device *dma_of = NULL;
569
570
        int hme = 0;
570
571
 
571
572
        if (dp->parent &&
573
574
             !strcmp(dp->parent->name, "dma")))
574
575
                dma_node = dp->parent;
575
576
        else if (!strcmp(dp->name, "SUNW,fas")) {
576
 
                dma_node = op->node;
 
577
                dma_node = op->dev.of_node;
577
578
                hme = 1;
578
579
        }
579
580
        if (dma_node)
584
585
        return esp_sbus_probe_one(op, dma_of, hme);
585
586
}
586
587
 
587
 
static int __devexit esp_sbus_remove(struct of_device *op)
 
588
static int __devexit esp_sbus_remove(struct platform_device *op)
588
589
{
589
590
        struct esp *esp = dev_get_drvdata(&op->dev);
590
 
        struct of_device *dma_of = esp->dma;
 
591
        struct platform_device *dma_of = esp->dma;
591
592
        unsigned int irq = esp->host->irq;
592
593
        bool is_hme;
593
594
        u32 val;
632
633
MODULE_DEVICE_TABLE(of, esp_match);
633
634
 
634
635
static struct of_platform_driver esp_sbus_driver = {
635
 
        .name           = "esp",
636
 
        .match_table    = esp_match,
 
636
        .driver = {
 
637
                .name = "esp",
 
638
                .owner = THIS_MODULE,
 
639
                .of_match_table = esp_match,
 
640
        },
637
641
        .probe          = esp_sbus_probe,
638
642
        .remove         = __devexit_p(esp_sbus_remove),
639
643
};
640
644
 
641
645
static int __init sunesp_init(void)
642
646
{
643
 
        return of_register_driver(&esp_sbus_driver, &of_bus_type);
 
647
        return of_register_platform_driver(&esp_sbus_driver);
644
648
}
645
649
 
646
650
static void __exit sunesp_exit(void)
647
651
{
648
 
        of_unregister_driver(&esp_sbus_driver);
 
652
        of_unregister_platform_driver(&esp_sbus_driver);
649
653
}
650
654
 
651
655
MODULE_DESCRIPTION("Sun ESP SCSI driver");