diff options
Diffstat (limited to 'drivers')
205 files changed, 6243 insertions, 8600 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index f031b8732330..ad1f59c1b3fc 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -2,11 +2,9 @@ | |||
2 | # SATA/PATA driver configuration | 2 | # SATA/PATA driver configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Serial ATA (prod) and Parallel ATA (experimental) drivers" | 5 | menuconfig ATA |
6 | tristate "Serial ATA (prod) and Parallel ATA (experimental) drivers" | ||
6 | depends on HAS_IOMEM | 7 | depends on HAS_IOMEM |
7 | |||
8 | config ATA | ||
9 | tristate "ATA device support" | ||
10 | depends on BLOCK | 8 | depends on BLOCK |
11 | depends on !(M32R || M68K) || BROKEN | 9 | depends on !(M32R || M68K) || BROKEN |
12 | depends on !SUN4 || BROKEN | 10 | depends on !SUN4 || BROKEN |
@@ -24,6 +22,19 @@ config ATA_NONSTANDARD | |||
24 | bool | 22 | bool |
25 | default n | 23 | default n |
26 | 24 | ||
25 | config ATA_ACPI | ||
26 | bool | ||
27 | depends on ACPI && PCI | ||
28 | default y | ||
29 | help | ||
30 | This option adds support for ATA-related ACPI objects. | ||
31 | These ACPI objects add the ability to retrieve taskfiles | ||
32 | from the ACPI BIOS and write them to the disk controller. | ||
33 | These objects may be related to performance, security, | ||
34 | power management, or other areas. | ||
35 | You can disable this at kernel boot time by using the | ||
36 | option libata.noacpi=1 | ||
37 | |||
27 | config SATA_AHCI | 38 | config SATA_AHCI |
28 | tristate "AHCI SATA support" | 39 | tristate "AHCI SATA support" |
29 | depends on PCI | 40 | depends on PCI |
@@ -157,19 +168,6 @@ config SATA_INIC162X | |||
157 | help | 168 | help |
158 | This option enables support for Initio 162x Serial ATA. | 169 | This option enables support for Initio 162x Serial ATA. |
159 | 170 | ||
160 | config SATA_ACPI | ||
161 | bool | ||
162 | depends on ACPI && PCI | ||
163 | default y | ||
164 | help | ||
165 | This option adds support for SATA-related ACPI objects. | ||
166 | These ACPI objects add the ability to retrieve taskfiles | ||
167 | from the ACPI BIOS and write them to the disk controller. | ||
168 | These objects may be related to performance, security, | ||
169 | power management, or other areas. | ||
170 | You can disable this at kernel boot time by using the | ||
171 | option libata.noacpi=1 | ||
172 | |||
173 | config PATA_ALI | 171 | config PATA_ALI |
174 | tristate "ALi PATA support (Experimental)" | 172 | tristate "ALi PATA support (Experimental)" |
175 | depends on PCI && EXPERIMENTAL | 173 | depends on PCI && EXPERIMENTAL |
@@ -585,6 +583,4 @@ config PATA_SCC | |||
585 | 583 | ||
586 | If unsure, say N. | 584 | If unsure, say N. |
587 | 585 | ||
588 | endif | 586 | endif # ATA |
589 | endmenu | ||
590 | |||
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 6f42a0e2812d..8149c68ac2c7 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -69,4 +69,4 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o | |||
69 | obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o | 69 | obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o |
70 | 70 | ||
71 | libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o | 71 | libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o |
72 | libata-$(CONFIG_SATA_ACPI) += libata-acpi.o | 72 | libata-$(CONFIG_ATA_ACPI) += libata-acpi.o |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index d9617892fc23..1ae443d7ab92 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -250,10 +250,6 @@ static struct scsi_host_template ahci_sht = { | |||
250 | .slave_configure = ata_scsi_slave_config, | 250 | .slave_configure = ata_scsi_slave_config, |
251 | .slave_destroy = ata_scsi_slave_destroy, | 251 | .slave_destroy = ata_scsi_slave_destroy, |
252 | .bios_param = ata_std_bios_param, | 252 | .bios_param = ata_std_bios_param, |
253 | #ifdef CONFIG_PM | ||
254 | .suspend = ata_scsi_device_suspend, | ||
255 | .resume = ata_scsi_device_resume, | ||
256 | #endif | ||
257 | }; | 253 | }; |
258 | 254 | ||
259 | static const struct ata_port_operations ahci_ops = { | 255 | static const struct ata_port_operations ahci_ops = { |
@@ -400,6 +396,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
400 | 396 | ||
401 | /* ATI */ | 397 | /* ATI */ |
402 | { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ | 398 | { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ |
399 | { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 */ | ||
403 | 400 | ||
404 | /* VIA */ | 401 | /* VIA */ |
405 | { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ | 402 | { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ |
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c index 92a491ddd030..c3d753296bc6 100644 --- a/drivers/ata/ata_generic.c +++ b/drivers/ata/ata_generic.c | |||
@@ -54,7 +54,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
54 | 54 | ||
55 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 55 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
56 | struct ata_device *dev = &ap->device[i]; | 56 | struct ata_device *dev = &ap->device[i]; |
57 | if (ata_dev_ready(dev)) { | 57 | if (ata_dev_enabled(dev)) { |
58 | /* We don't really care */ | 58 | /* We don't really care */ |
59 | dev->pio_mode = XFER_PIO_0; | 59 | dev->pio_mode = XFER_PIO_0; |
60 | dev->dma_mode = XFER_MW_DMA_0; | 60 | dev->dma_mode = XFER_MW_DMA_0; |
@@ -90,10 +90,6 @@ static struct scsi_host_template generic_sht = { | |||
90 | .slave_configure = ata_scsi_slave_config, | 90 | .slave_configure = ata_scsi_slave_config, |
91 | .slave_destroy = ata_scsi_slave_destroy, | 91 | .slave_destroy = ata_scsi_slave_destroy, |
92 | .bios_param = ata_std_bios_param, | 92 | .bios_param = ata_std_bios_param, |
93 | #ifdef CONFIG_PM | ||
94 | .resume = ata_scsi_device_resume, | ||
95 | .suspend = ata_scsi_device_suspend, | ||
96 | #endif | ||
97 | }; | 93 | }; |
98 | 94 | ||
99 | static struct ata_port_operations generic_port_ops = { | 95 | static struct ata_port_operations generic_port_ops = { |
@@ -145,7 +141,7 @@ static int all_generic_ide; /* Set to claim all devices */ | |||
145 | static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 141 | static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
146 | { | 142 | { |
147 | u16 command; | 143 | u16 command; |
148 | static struct ata_port_info info = { | 144 | static const struct ata_port_info info = { |
149 | .sht = &generic_sht, | 145 | .sht = &generic_sht, |
150 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 146 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
151 | .pio_mask = 0x1f, | 147 | .pio_mask = 0x1f, |
@@ -153,7 +149,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id | |||
153 | .udma_mask = 0x3f, | 149 | .udma_mask = 0x3f, |
154 | .port_ops = &generic_port_ops | 150 | .port_ops = &generic_port_ops |
155 | }; | 151 | }; |
156 | static struct ata_port_info *port_info[2] = { &info, &info }; | 152 | const struct ata_port_info *ppi[] = { &info, NULL }; |
157 | 153 | ||
158 | /* Don't use the generic entry unless instructed to do so */ | 154 | /* Don't use the generic entry unless instructed to do so */ |
159 | if (id->driver_data == 1 && all_generic_ide == 0) | 155 | if (id->driver_data == 1 && all_generic_ide == 0) |
@@ -179,7 +175,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id | |||
179 | if (dev->vendor == PCI_VENDOR_ID_AL) | 175 | if (dev->vendor == PCI_VENDOR_ID_AL) |
180 | ata_pci_clear_simplex(dev); | 176 | ata_pci_clear_simplex(dev); |
181 | 177 | ||
182 | return ata_pci_init_one(dev, port_info, 2); | 178 | return ata_pci_init_one(dev, ppi); |
183 | } | 179 | } |
184 | 180 | ||
185 | static struct pci_device_id ata_generic[] = { | 181 | static struct pci_device_id ata_generic[] = { |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 4a795fdb6a02..13b6b1df2ac4 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -275,10 +275,6 @@ static struct scsi_host_template piix_sht = { | |||
275 | .slave_configure = ata_scsi_slave_config, | 275 | .slave_configure = ata_scsi_slave_config, |
276 | .slave_destroy = ata_scsi_slave_destroy, | 276 | .slave_destroy = ata_scsi_slave_destroy, |
277 | .bios_param = ata_std_bios_param, | 277 | .bios_param = ata_std_bios_param, |
278 | #ifdef CONFIG_PM | ||
279 | .resume = ata_scsi_device_resume, | ||
280 | .suspend = ata_scsi_device_suspend, | ||
281 | #endif | ||
282 | }; | 278 | }; |
283 | 279 | ||
284 | static const struct ata_port_operations piix_pata_ops = { | 280 | static const struct ata_port_operations piix_pata_ops = { |
@@ -1034,7 +1030,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1034 | static int printed_version; | 1030 | static int printed_version; |
1035 | struct device *dev = &pdev->dev; | 1031 | struct device *dev = &pdev->dev; |
1036 | struct ata_port_info port_info[2]; | 1032 | struct ata_port_info port_info[2]; |
1037 | struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; | 1033 | const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; |
1038 | struct piix_host_priv *hpriv; | 1034 | struct piix_host_priv *hpriv; |
1039 | unsigned long port_flags; | 1035 | unsigned long port_flags; |
1040 | 1036 | ||
@@ -1093,7 +1089,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1093 | port_info[1].mwdma_mask = 0; | 1089 | port_info[1].mwdma_mask = 0; |
1094 | port_info[1].udma_mask = 0; | 1090 | port_info[1].udma_mask = 0; |
1095 | } | 1091 | } |
1096 | return ata_pci_init_one(pdev, ppinfo, 2); | 1092 | return ata_pci_init_one(pdev, ppi); |
1097 | } | 1093 | } |
1098 | 1094 | ||
1099 | static int __init piix_init(void) | 1095 | static int __init piix_init(void) |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index cb3eab6e379d..ed4138e24b0c 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -270,8 +270,7 @@ out: | |||
270 | 270 | ||
271 | /** | 271 | /** |
272 | * do_drive_get_GTF - get the drive bootup default taskfile settings | 272 | * do_drive_get_GTF - get the drive bootup default taskfile settings |
273 | * @ap: the ata_port for the drive | 273 | * @dev: target ATA device |
274 | * @ix: target ata_device (drive) index | ||
275 | * @gtf_length: number of bytes of _GTF data returned at @gtf_address | 274 | * @gtf_length: number of bytes of _GTF data returned at @gtf_address |
276 | * @gtf_address: buffer containing _GTF taskfile arrays | 275 | * @gtf_address: buffer containing _GTF taskfile arrays |
277 | * | 276 | * |
@@ -286,20 +285,19 @@ out: | |||
286 | * The returned @gtf_length and @gtf_address are only valid if the | 285 | * The returned @gtf_length and @gtf_address are only valid if the |
287 | * function return value is 0. | 286 | * function return value is 0. |
288 | */ | 287 | */ |
289 | static int do_drive_get_GTF(struct ata_port *ap, int ix, | 288 | static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, |
290 | unsigned int *gtf_length, unsigned long *gtf_address, | 289 | unsigned long *gtf_address, unsigned long *obj_loc) |
291 | unsigned long *obj_loc) | ||
292 | { | 290 | { |
293 | acpi_status status; | 291 | struct ata_port *ap = dev->ap; |
294 | acpi_handle dev_handle = NULL; | 292 | acpi_status status; |
295 | acpi_handle chan_handle, drive_handle; | 293 | acpi_handle dev_handle = NULL; |
296 | acpi_integer pcidevfn = 0; | 294 | acpi_handle chan_handle, drive_handle; |
297 | u32 dev_adr; | 295 | acpi_integer pcidevfn = 0; |
298 | struct acpi_buffer output; | 296 | u32 dev_adr; |
299 | union acpi_object *out_obj; | 297 | struct acpi_buffer output; |
300 | struct device *dev = ap->host->dev; | 298 | union acpi_object *out_obj; |
301 | struct ata_device *atadev = &ap->device[ix]; | 299 | struct device *gdev = ap->host->dev; |
302 | int err = -ENODEV; | 300 | int err = -ENODEV; |
303 | 301 | ||
304 | *gtf_length = 0; | 302 | *gtf_length = 0; |
305 | *gtf_address = 0UL; | 303 | *gtf_address = 0UL; |
@@ -309,14 +307,14 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
309 | return 0; | 307 | return 0; |
310 | 308 | ||
311 | if (ata_msg_probe(ap)) | 309 | if (ata_msg_probe(ap)) |
312 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", | 310 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", |
313 | __FUNCTION__, ap->port_no); | 311 | __FUNCTION__, ap->port_no); |
314 | 312 | ||
315 | if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { | 313 | if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) { |
316 | if (ata_msg_probe(ap)) | 314 | if (ata_msg_probe(ap)) |
317 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ERR: " | 315 | ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: " |
318 | "ata_dev_present: %d, PORT_DISABLED: %lu\n", | 316 | "ata_dev_present: %d, PORT_DISABLED: %lu\n", |
319 | __FUNCTION__, ata_dev_enabled(atadev), | 317 | __FUNCTION__, ata_dev_enabled(dev), |
320 | ap->flags & ATA_FLAG_DISABLED); | 318 | ap->flags & ATA_FLAG_DISABLED); |
321 | goto out; | 319 | goto out; |
322 | } | 320 | } |
@@ -324,19 +322,19 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
324 | /* Don't continue if device has no _ADR method. | 322 | /* Don't continue if device has no _ADR method. |
325 | * _GTF is intended for known motherboard devices. */ | 323 | * _GTF is intended for known motherboard devices. */ |
326 | if (!(ap->cbl == ATA_CBL_SATA)) { | 324 | if (!(ap->cbl == ATA_CBL_SATA)) { |
327 | err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); | 325 | err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn); |
328 | if (err < 0) { | 326 | if (err < 0) { |
329 | if (ata_msg_probe(ap)) | 327 | if (ata_msg_probe(ap)) |
330 | ata_dev_printk(atadev, KERN_DEBUG, | 328 | ata_dev_printk(dev, KERN_DEBUG, |
331 | "%s: pata_get_dev_handle failed (%d)\n", | 329 | "%s: pata_get_dev_handle failed (%d)\n", |
332 | __FUNCTION__, err); | 330 | __FUNCTION__, err); |
333 | goto out; | 331 | goto out; |
334 | } | 332 | } |
335 | } else { | 333 | } else { |
336 | err = sata_get_dev_handle(dev, &dev_handle, &pcidevfn); | 334 | err = sata_get_dev_handle(gdev, &dev_handle, &pcidevfn); |
337 | if (err < 0) { | 335 | if (err < 0) { |
338 | if (ata_msg_probe(ap)) | 336 | if (ata_msg_probe(ap)) |
339 | ata_dev_printk(atadev, KERN_DEBUG, | 337 | ata_dev_printk(dev, KERN_DEBUG, |
340 | "%s: sata_get_dev_handle failed (%d\n", | 338 | "%s: sata_get_dev_handle failed (%d\n", |
341 | __FUNCTION__, err); | 339 | __FUNCTION__, err); |
342 | goto out; | 340 | goto out; |
@@ -344,7 +342,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
344 | } | 342 | } |
345 | 343 | ||
346 | /* Get this drive's _ADR info. if not already known. */ | 344 | /* Get this drive's _ADR info. if not already known. */ |
347 | if (!atadev->obj_handle) { | 345 | if (!dev->obj_handle) { |
348 | if (!(ap->cbl == ATA_CBL_SATA)) { | 346 | if (!(ap->cbl == ATA_CBL_SATA)) { |
349 | /* get child objects of dev_handle == channel objects, | 347 | /* get child objects of dev_handle == channel objects, |
350 | * + _their_ children == drive objects */ | 348 | * + _their_ children == drive objects */ |
@@ -352,7 +350,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
352 | chan_handle = acpi_get_child(dev_handle, | 350 | chan_handle = acpi_get_child(dev_handle, |
353 | ap->port_no); | 351 | ap->port_no); |
354 | if (ata_msg_probe(ap)) | 352 | if (ata_msg_probe(ap)) |
355 | ata_dev_printk(atadev, KERN_DEBUG, | 353 | ata_dev_printk(dev, KERN_DEBUG, |
356 | "%s: chan adr=%d: chan_handle=0x%p\n", | 354 | "%s: chan adr=%d: chan_handle=0x%p\n", |
357 | __FUNCTION__, ap->port_no, | 355 | __FUNCTION__, ap->port_no, |
358 | chan_handle); | 356 | chan_handle); |
@@ -361,26 +359,26 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
361 | goto out; | 359 | goto out; |
362 | } | 360 | } |
363 | /* TBD: could also check ACPI object VALID bits */ | 361 | /* TBD: could also check ACPI object VALID bits */ |
364 | drive_handle = acpi_get_child(chan_handle, ix); | 362 | drive_handle = acpi_get_child(chan_handle, dev->devno); |
365 | if (!drive_handle) { | 363 | if (!drive_handle) { |
366 | err = -ENODEV; | 364 | err = -ENODEV; |
367 | goto out; | 365 | goto out; |
368 | } | 366 | } |
369 | dev_adr = ix; | 367 | dev_adr = dev->devno; |
370 | atadev->obj_handle = drive_handle; | 368 | dev->obj_handle = drive_handle; |
371 | } else { /* for SATA mode */ | 369 | } else { /* for SATA mode */ |
372 | dev_adr = SATA_ADR_RSVD; | 370 | dev_adr = SATA_ADR_RSVD; |
373 | err = get_sata_adr(dev, dev_handle, pcidevfn, 0, | 371 | err = get_sata_adr(gdev, dev_handle, pcidevfn, 0, |
374 | ap, atadev, &dev_adr); | 372 | ap, dev, &dev_adr); |
375 | } | 373 | } |
376 | if (err < 0 || dev_adr == SATA_ADR_RSVD || | 374 | if (err < 0 || dev_adr == SATA_ADR_RSVD || |
377 | !atadev->obj_handle) { | 375 | !dev->obj_handle) { |
378 | if (ata_msg_probe(ap)) | 376 | if (ata_msg_probe(ap)) |
379 | ata_dev_printk(atadev, KERN_DEBUG, | 377 | ata_dev_printk(dev, KERN_DEBUG, |
380 | "%s: get_sata/pata_adr failed: " | 378 | "%s: get_sata/pata_adr failed: " |
381 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", | 379 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", |
382 | __FUNCTION__, err, dev_adr, | 380 | __FUNCTION__, err, dev_adr, |
383 | atadev->obj_handle); | 381 | dev->obj_handle); |
384 | goto out; | 382 | goto out; |
385 | } | 383 | } |
386 | } | 384 | } |
@@ -391,11 +389,11 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
391 | 389 | ||
392 | /* _GTF has no input parameters */ | 390 | /* _GTF has no input parameters */ |
393 | err = -EIO; | 391 | err = -EIO; |
394 | status = acpi_evaluate_object(atadev->obj_handle, "_GTF", | 392 | status = acpi_evaluate_object(dev->obj_handle, "_GTF", |
395 | NULL, &output); | 393 | NULL, &output); |
396 | if (ACPI_FAILURE(status)) { | 394 | if (ACPI_FAILURE(status)) { |
397 | if (ata_msg_probe(ap)) | 395 | if (ata_msg_probe(ap)) |
398 | ata_dev_printk(atadev, KERN_DEBUG, | 396 | ata_dev_printk(dev, KERN_DEBUG, |
399 | "%s: Run _GTF error: status = 0x%x\n", | 397 | "%s: Run _GTF error: status = 0x%x\n", |
400 | __FUNCTION__, status); | 398 | __FUNCTION__, status); |
401 | goto out; | 399 | goto out; |
@@ -403,7 +401,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
403 | 401 | ||
404 | if (!output.length || !output.pointer) { | 402 | if (!output.length || !output.pointer) { |
405 | if (ata_msg_probe(ap)) | 403 | if (ata_msg_probe(ap)) |
406 | ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " | 404 | ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " |
407 | "length or ptr is NULL (0x%llx, 0x%p)\n", | 405 | "length or ptr is NULL (0x%llx, 0x%p)\n", |
408 | __FUNCTION__, | 406 | __FUNCTION__, |
409 | (unsigned long long)output.length, | 407 | (unsigned long long)output.length, |
@@ -416,7 +414,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
416 | if (out_obj->type != ACPI_TYPE_BUFFER) { | 414 | if (out_obj->type != ACPI_TYPE_BUFFER) { |
417 | kfree(output.pointer); | 415 | kfree(output.pointer); |
418 | if (ata_msg_probe(ap)) | 416 | if (ata_msg_probe(ap)) |
419 | ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " | 417 | ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " |
420 | "error: expected object type of " | 418 | "error: expected object type of " |
421 | " ACPI_TYPE_BUFFER, got 0x%x\n", | 419 | " ACPI_TYPE_BUFFER, got 0x%x\n", |
422 | __FUNCTION__, out_obj->type); | 420 | __FUNCTION__, out_obj->type); |
@@ -427,7 +425,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
427 | if (!out_obj->buffer.length || !out_obj->buffer.pointer || | 425 | if (!out_obj->buffer.length || !out_obj->buffer.pointer || |
428 | out_obj->buffer.length % REGS_PER_GTF) { | 426 | out_obj->buffer.length % REGS_PER_GTF) { |
429 | if (ata_msg_drv(ap)) | 427 | if (ata_msg_drv(ap)) |
430 | ata_dev_printk(atadev, KERN_ERR, | 428 | ata_dev_printk(dev, KERN_ERR, |
431 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", | 429 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", |
432 | __FUNCTION__, out_obj->buffer.length, | 430 | __FUNCTION__, out_obj->buffer.length, |
433 | out_obj->buffer.pointer); | 431 | out_obj->buffer.pointer); |
@@ -439,7 +437,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
439 | *gtf_address = (unsigned long)out_obj->buffer.pointer; | 437 | *gtf_address = (unsigned long)out_obj->buffer.pointer; |
440 | *obj_loc = (unsigned long)out_obj; | 438 | *obj_loc = (unsigned long)out_obj; |
441 | if (ata_msg_probe(ap)) | 439 | if (ata_msg_probe(ap)) |
442 | ata_dev_printk(atadev, KERN_DEBUG, "%s: returning " | 440 | ata_dev_printk(dev, KERN_DEBUG, "%s: returning " |
443 | "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", | 441 | "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", |
444 | __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); | 442 | __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); |
445 | err = 0; | 443 | err = 0; |
@@ -449,7 +447,7 @@ out: | |||
449 | 447 | ||
450 | /** | 448 | /** |
451 | * taskfile_load_raw - send taskfile registers to host controller | 449 | * taskfile_load_raw - send taskfile registers to host controller |
452 | * @ap: Port to which output is sent | 450 | * @dev: target ATA device |
453 | * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) | 451 | * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) |
454 | * | 452 | * |
455 | * Outputs ATA taskfile to standard ATA host controller using MMIO | 453 | * Outputs ATA taskfile to standard ATA host controller using MMIO |
@@ -466,15 +464,15 @@ out: | |||
466 | * LOCKING: TBD: | 464 | * LOCKING: TBD: |
467 | * Inherited from caller. | 465 | * Inherited from caller. |
468 | */ | 466 | */ |
469 | static void taskfile_load_raw(struct ata_port *ap, | 467 | static void taskfile_load_raw(struct ata_device *dev, |
470 | struct ata_device *atadev, | 468 | const struct taskfile_array *gtf) |
471 | const struct taskfile_array *gtf) | ||
472 | { | 469 | { |
470 | struct ata_port *ap = dev->ap; | ||
473 | struct ata_taskfile tf; | 471 | struct ata_taskfile tf; |
474 | unsigned int err; | 472 | unsigned int err; |
475 | 473 | ||
476 | if (ata_msg_probe(ap)) | 474 | if (ata_msg_probe(ap)) |
477 | ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " | 475 | ata_dev_printk(dev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " |
478 | "%02x %02x %02x %02x %02x %02x %02x\n", | 476 | "%02x %02x %02x %02x %02x %02x %02x\n", |
479 | __FUNCTION__, | 477 | __FUNCTION__, |
480 | gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], | 478 | gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], |
@@ -485,7 +483,7 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
485 | && (gtf->tfa[6] == 0)) | 483 | && (gtf->tfa[6] == 0)) |
486 | return; | 484 | return; |
487 | 485 | ||
488 | ata_tf_init(atadev, &tf); | 486 | ata_tf_init(dev, &tf); |
489 | 487 | ||
490 | /* convert gtf to tf */ | 488 | /* convert gtf to tf */ |
491 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ | 489 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ |
@@ -498,17 +496,16 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
498 | tf.device = gtf->tfa[5]; /* 0x1f6 */ | 496 | tf.device = gtf->tfa[5]; /* 0x1f6 */ |
499 | tf.command = gtf->tfa[6]; /* 0x1f7 */ | 497 | tf.command = gtf->tfa[6]; /* 0x1f7 */ |
500 | 498 | ||
501 | err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); | 499 | err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); |
502 | if (err && ata_msg_probe(ap)) | 500 | if (err && ata_msg_probe(ap)) |
503 | ata_dev_printk(atadev, KERN_ERR, | 501 | ata_dev_printk(dev, KERN_ERR, |
504 | "%s: ata_exec_internal failed: %u\n", | 502 | "%s: ata_exec_internal failed: %u\n", |
505 | __FUNCTION__, err); | 503 | __FUNCTION__, err); |
506 | } | 504 | } |
507 | 505 | ||
508 | /** | 506 | /** |
509 | * do_drive_set_taskfiles - write the drive taskfile settings from _GTF | 507 | * do_drive_set_taskfiles - write the drive taskfile settings from _GTF |
510 | * @ap: the ata_port for the drive | 508 | * @dev: target ATA device |
511 | * @atadev: target ata_device | ||
512 | * @gtf_length: total number of bytes of _GTF taskfiles | 509 | * @gtf_length: total number of bytes of _GTF taskfiles |
513 | * @gtf_address: location of _GTF taskfile arrays | 510 | * @gtf_address: location of _GTF taskfile arrays |
514 | * | 511 | * |
@@ -517,30 +514,31 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
517 | * Write {gtf_address, length gtf_length} in groups of | 514 | * Write {gtf_address, length gtf_length} in groups of |
518 | * REGS_PER_GTF bytes. | 515 | * REGS_PER_GTF bytes. |
519 | */ | 516 | */ |
520 | static int do_drive_set_taskfiles(struct ata_port *ap, | 517 | static int do_drive_set_taskfiles(struct ata_device *dev, |
521 | struct ata_device *atadev, unsigned int gtf_length, | 518 | unsigned int gtf_length, |
522 | unsigned long gtf_address) | 519 | unsigned long gtf_address) |
523 | { | 520 | { |
524 | int err = -ENODEV; | 521 | struct ata_port *ap = dev->ap; |
525 | int gtf_count = gtf_length / REGS_PER_GTF; | 522 | int err = -ENODEV; |
526 | int ix; | 523 | int gtf_count = gtf_length / REGS_PER_GTF; |
524 | int ix; | ||
527 | struct taskfile_array *gtf; | 525 | struct taskfile_array *gtf; |
528 | 526 | ||
529 | if (ata_msg_probe(ap)) | 527 | if (ata_msg_probe(ap)) |
530 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", | 528 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", |
531 | __FUNCTION__, ap->port_no); | 529 | __FUNCTION__, ap->port_no); |
532 | 530 | ||
533 | if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) | 531 | if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) |
534 | return 0; | 532 | return 0; |
535 | 533 | ||
536 | if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) | 534 | if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) |
537 | goto out; | 535 | goto out; |
538 | if (!gtf_count) /* shouldn't be here */ | 536 | if (!gtf_count) /* shouldn't be here */ |
539 | goto out; | 537 | goto out; |
540 | 538 | ||
541 | if (gtf_length % REGS_PER_GTF) { | 539 | if (gtf_length % REGS_PER_GTF) { |
542 | if (ata_msg_drv(ap)) | 540 | if (ata_msg_drv(ap)) |
543 | ata_dev_printk(atadev, KERN_ERR, | 541 | ata_dev_printk(dev, KERN_ERR, |
544 | "%s: unexpected GTF length (%d)\n", | 542 | "%s: unexpected GTF length (%d)\n", |
545 | __FUNCTION__, gtf_length); | 543 | __FUNCTION__, gtf_length); |
546 | goto out; | 544 | goto out; |
@@ -551,7 +549,7 @@ static int do_drive_set_taskfiles(struct ata_port *ap, | |||
551 | (gtf_address + ix * REGS_PER_GTF); | 549 | (gtf_address + ix * REGS_PER_GTF); |
552 | 550 | ||
553 | /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ | 551 | /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ |
554 | taskfile_load_raw(ap, atadev, gtf); | 552 | taskfile_load_raw(dev, gtf); |
555 | } | 553 | } |
556 | 554 | ||
557 | err = 0; | 555 | err = 0; |
@@ -567,11 +565,11 @@ out: | |||
567 | */ | 565 | */ |
568 | int ata_acpi_exec_tfs(struct ata_port *ap) | 566 | int ata_acpi_exec_tfs(struct ata_port *ap) |
569 | { | 567 | { |
570 | int ix; | 568 | int ix; |
571 | int ret =0; | 569 | int ret = 0; |
572 | unsigned int gtf_length; | 570 | unsigned int gtf_length; |
573 | unsigned long gtf_address; | 571 | unsigned long gtf_address; |
574 | unsigned long obj_loc; | 572 | unsigned long obj_loc; |
575 | 573 | ||
576 | if (libata_noacpi) | 574 | if (libata_noacpi) |
577 | return 0; | 575 | return 0; |
@@ -584,11 +582,13 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
584 | return 0; | 582 | return 0; |
585 | 583 | ||
586 | for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { | 584 | for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { |
587 | if (!ata_dev_enabled(&ap->device[ix])) | 585 | struct ata_device *dev = &ap->device[ix]; |
586 | |||
587 | if (!ata_dev_enabled(dev)) | ||
588 | continue; | 588 | continue; |
589 | 589 | ||
590 | ret = do_drive_get_GTF(ap, ix, | 590 | ret = do_drive_get_GTF(dev, >f_length, >f_address, |
591 | >f_length, >f_address, &obj_loc); | 591 | &obj_loc); |
592 | if (ret < 0) { | 592 | if (ret < 0) { |
593 | if (ata_msg_probe(ap)) | 593 | if (ata_msg_probe(ap)) |
594 | ata_port_printk(ap, KERN_DEBUG, | 594 | ata_port_printk(ap, KERN_DEBUG, |
@@ -597,8 +597,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
597 | break; | 597 | break; |
598 | } | 598 | } |
599 | 599 | ||
600 | ret = do_drive_set_taskfiles(ap, &ap->device[ix], | 600 | ret = do_drive_set_taskfiles(dev, gtf_length, gtf_address); |
601 | gtf_length, gtf_address); | ||
602 | kfree((void *)obj_loc); | 601 | kfree((void *)obj_loc); |
603 | if (ret < 0) { | 602 | if (ret < 0) { |
604 | if (ata_msg_probe(ap)) | 603 | if (ata_msg_probe(ap)) |
@@ -614,8 +613,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
614 | 613 | ||
615 | /** | 614 | /** |
616 | * ata_acpi_push_id - send Identify data to drive | 615 | * ata_acpi_push_id - send Identify data to drive |
617 | * @ap: the ata_port for the drive | 616 | * @dev: target ATA device |
618 | * @ix: drive index | ||
619 | * | 617 | * |
620 | * _SDD ACPI object: for SATA mode only | 618 | * _SDD ACPI object: for SATA mode only |
621 | * Must be after Identify (Packet) Device -- uses its data | 619 | * Must be after Identify (Packet) Device -- uses its data |
@@ -623,57 +621,57 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
623 | * method and if it fails for whatever reason, we should still | 621 | * method and if it fails for whatever reason, we should still |
624 | * just keep going. | 622 | * just keep going. |
625 | */ | 623 | */ |
626 | int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | 624 | int ata_acpi_push_id(struct ata_device *dev) |
627 | { | 625 | { |
628 | acpi_handle handle; | 626 | struct ata_port *ap = dev->ap; |
629 | acpi_integer pcidevfn; | 627 | acpi_handle handle; |
630 | int err; | 628 | acpi_integer pcidevfn; |
631 | struct device *dev = ap->host->dev; | 629 | int err; |
632 | struct ata_device *atadev = &ap->device[ix]; | 630 | struct device *gdev = ap->host->dev; |
633 | u32 dev_adr; | 631 | u32 dev_adr; |
634 | acpi_status status; | 632 | acpi_status status; |
635 | struct acpi_object_list input; | 633 | struct acpi_object_list input; |
636 | union acpi_object in_params[1]; | 634 | union acpi_object in_params[1]; |
637 | 635 | ||
638 | if (libata_noacpi) | 636 | if (libata_noacpi) |
639 | return 0; | 637 | return 0; |
640 | 638 | ||
641 | if (ata_msg_probe(ap)) | 639 | if (ata_msg_probe(ap)) |
642 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", | 640 | ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", |
643 | __FUNCTION__, ix, ap->port_no); | 641 | __FUNCTION__, dev->devno, ap->port_no); |
644 | 642 | ||
645 | /* Don't continue if not a SATA device. */ | 643 | /* Don't continue if not a SATA device. */ |
646 | if (!(ap->cbl == ATA_CBL_SATA)) { | 644 | if (!(ap->cbl == ATA_CBL_SATA)) { |
647 | if (ata_msg_probe(ap)) | 645 | if (ata_msg_probe(ap)) |
648 | ata_dev_printk(atadev, KERN_DEBUG, | 646 | ata_dev_printk(dev, KERN_DEBUG, |
649 | "%s: Not a SATA device\n", __FUNCTION__); | 647 | "%s: Not a SATA device\n", __FUNCTION__); |
650 | goto out; | 648 | goto out; |
651 | } | 649 | } |
652 | 650 | ||
653 | /* Don't continue if device has no _ADR method. | 651 | /* Don't continue if device has no _ADR method. |
654 | * _SDD is intended for known motherboard devices. */ | 652 | * _SDD is intended for known motherboard devices. */ |
655 | err = sata_get_dev_handle(dev, &handle, &pcidevfn); | 653 | err = sata_get_dev_handle(gdev, &handle, &pcidevfn); |
656 | if (err < 0) { | 654 | if (err < 0) { |
657 | if (ata_msg_probe(ap)) | 655 | if (ata_msg_probe(ap)) |
658 | ata_dev_printk(atadev, KERN_DEBUG, | 656 | ata_dev_printk(dev, KERN_DEBUG, |
659 | "%s: sata_get_dev_handle failed (%d\n", | 657 | "%s: sata_get_dev_handle failed (%d\n", |
660 | __FUNCTION__, err); | 658 | __FUNCTION__, err); |
661 | goto out; | 659 | goto out; |
662 | } | 660 | } |
663 | 661 | ||
664 | /* Get this drive's _ADR info, if not already known */ | 662 | /* Get this drive's _ADR info, if not already known */ |
665 | if (!atadev->obj_handle) { | 663 | if (!dev->obj_handle) { |
666 | dev_adr = SATA_ADR_RSVD; | 664 | dev_adr = SATA_ADR_RSVD; |
667 | err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev, | 665 | err = get_sata_adr(gdev, handle, pcidevfn, dev->devno, ap, dev, |
668 | &dev_adr); | 666 | &dev_adr); |
669 | if (err < 0 || dev_adr == SATA_ADR_RSVD || | 667 | if (err < 0 || dev_adr == SATA_ADR_RSVD || |
670 | !atadev->obj_handle) { | 668 | !dev->obj_handle) { |
671 | if (ata_msg_probe(ap)) | 669 | if (ata_msg_probe(ap)) |
672 | ata_dev_printk(atadev, KERN_DEBUG, | 670 | ata_dev_printk(dev, KERN_DEBUG, |
673 | "%s: get_sata_adr failed: " | 671 | "%s: get_sata_adr failed: " |
674 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", | 672 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", |
675 | __FUNCTION__, err, dev_adr, | 673 | __FUNCTION__, err, dev_adr, |
676 | atadev->obj_handle); | 674 | dev->obj_handle); |
677 | goto out; | 675 | goto out; |
678 | } | 676 | } |
679 | } | 677 | } |
@@ -683,19 +681,19 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | |||
683 | input.count = 1; | 681 | input.count = 1; |
684 | input.pointer = in_params; | 682 | input.pointer = in_params; |
685 | in_params[0].type = ACPI_TYPE_BUFFER; | 683 | in_params[0].type = ACPI_TYPE_BUFFER; |
686 | in_params[0].buffer.length = sizeof(atadev->id[0]) * ATA_ID_WORDS; | 684 | in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS; |
687 | in_params[0].buffer.pointer = (u8 *)atadev->id; | 685 | in_params[0].buffer.pointer = (u8 *)dev->id; |
688 | /* Output buffer: _SDD has no output */ | 686 | /* Output buffer: _SDD has no output */ |
689 | 687 | ||
690 | /* It's OK for _SDD to be missing too. */ | 688 | /* It's OK for _SDD to be missing too. */ |
691 | swap_buf_le16(atadev->id, ATA_ID_WORDS); | 689 | swap_buf_le16(dev->id, ATA_ID_WORDS); |
692 | status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL); | 690 | status = acpi_evaluate_object(dev->obj_handle, "_SDD", &input, NULL); |
693 | swap_buf_le16(atadev->id, ATA_ID_WORDS); | 691 | swap_buf_le16(dev->id, ATA_ID_WORDS); |
694 | 692 | ||
695 | err = ACPI_FAILURE(status) ? -EIO : 0; | 693 | err = ACPI_FAILURE(status) ? -EIO : 0; |
696 | if (err < 0) { | 694 | if (err < 0) { |
697 | if (ata_msg_probe(ap)) | 695 | if (ata_msg_probe(ap)) |
698 | ata_dev_printk(atadev, KERN_DEBUG, | 696 | ata_dev_printk(dev, KERN_DEBUG, |
699 | "%s _SDD error: status = 0x%x\n", | 697 | "%s _SDD error: status = 0x%x\n", |
700 | __FUNCTION__, status); | 698 | __FUNCTION__, status); |
701 | } | 699 | } |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4595d1f8cf60..4166407eb47c 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -101,6 +101,12 @@ int libata_noacpi = 1; | |||
101 | module_param_named(noacpi, libata_noacpi, int, 0444); | 101 | module_param_named(noacpi, libata_noacpi, int, 0444); |
102 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); | 102 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); |
103 | 103 | ||
104 | int ata_spindown_compat = 1; | ||
105 | module_param_named(spindown_compat, ata_spindown_compat, int, 0644); | ||
106 | MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown " | ||
107 | "behavior. Will be removed. More info can be found in " | ||
108 | "Documentation/feature-removal-schedule.txt\n"); | ||
109 | |||
104 | MODULE_AUTHOR("Jeff Garzik"); | 110 | MODULE_AUTHOR("Jeff Garzik"); |
105 | MODULE_DESCRIPTION("Library module for ATA devices"); | 111 | MODULE_DESCRIPTION("Library module for ATA devices"); |
106 | MODULE_LICENSE("GPL"); | 112 | MODULE_LICENSE("GPL"); |
@@ -1654,7 +1660,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1654 | struct ata_taskfile tf; | 1660 | struct ata_taskfile tf; |
1655 | unsigned int err_mask = 0; | 1661 | unsigned int err_mask = 0; |
1656 | const char *reason; | 1662 | const char *reason; |
1657 | int tried_spinup = 0; | 1663 | int may_fallback = 1, tried_spinup = 0; |
1658 | int rc; | 1664 | int rc; |
1659 | 1665 | ||
1660 | if (ata_msg_ctl(ap)) | 1666 | if (ata_msg_ctl(ap)) |
@@ -1698,11 +1704,31 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1698 | return -ENOENT; | 1704 | return -ENOENT; |
1699 | } | 1705 | } |
1700 | 1706 | ||
1707 | /* Device or controller might have reported the wrong | ||
1708 | * device class. Give a shot at the other IDENTIFY if | ||
1709 | * the current one is aborted by the device. | ||
1710 | */ | ||
1711 | if (may_fallback && | ||
1712 | (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { | ||
1713 | may_fallback = 0; | ||
1714 | |||
1715 | if (class == ATA_DEV_ATA) | ||
1716 | class = ATA_DEV_ATAPI; | ||
1717 | else | ||
1718 | class = ATA_DEV_ATA; | ||
1719 | goto retry; | ||
1720 | } | ||
1721 | |||
1701 | rc = -EIO; | 1722 | rc = -EIO; |
1702 | reason = "I/O error"; | 1723 | reason = "I/O error"; |
1703 | goto err_out; | 1724 | goto err_out; |
1704 | } | 1725 | } |
1705 | 1726 | ||
1727 | /* Falling back doesn't make sense if ID data was read | ||
1728 | * successfully at least once. | ||
1729 | */ | ||
1730 | may_fallback = 0; | ||
1731 | |||
1706 | swap_buf_le16(id, ATA_ID_WORDS); | 1732 | swap_buf_le16(id, ATA_ID_WORDS); |
1707 | 1733 | ||
1708 | /* sanity check */ | 1734 | /* sanity check */ |
@@ -1843,7 +1869,7 @@ int ata_dev_configure(struct ata_device *dev) | |||
1843 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); | 1869 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); |
1844 | 1870 | ||
1845 | /* set _SDD */ | 1871 | /* set _SDD */ |
1846 | rc = ata_acpi_push_id(ap, dev->devno); | 1872 | rc = ata_acpi_push_id(dev); |
1847 | if (rc) { | 1873 | if (rc) { |
1848 | ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", | 1874 | ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", |
1849 | rc); | 1875 | rc); |
@@ -2860,7 +2886,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2860 | dev = &ap->device[i]; | 2886 | dev = &ap->device[i]; |
2861 | 2887 | ||
2862 | /* don't update suspended devices' xfer mode */ | 2888 | /* don't update suspended devices' xfer mode */ |
2863 | if (!ata_dev_ready(dev)) | 2889 | if (!ata_dev_enabled(dev)) |
2864 | continue; | 2890 | continue; |
2865 | 2891 | ||
2866 | rc = ata_dev_set_mode(dev); | 2892 | rc = ata_dev_set_mode(dev); |
@@ -5845,37 +5871,11 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg, | |||
5845 | */ | 5871 | */ |
5846 | int ata_host_suspend(struct ata_host *host, pm_message_t mesg) | 5872 | int ata_host_suspend(struct ata_host *host, pm_message_t mesg) |
5847 | { | 5873 | { |
5848 | int i, j, rc; | 5874 | int rc; |
5849 | 5875 | ||
5850 | rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); | 5876 | rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); |
5851 | if (rc) | 5877 | if (rc == 0) |
5852 | goto fail; | 5878 | host->dev->power.power_state = mesg; |
5853 | |||
5854 | /* EH is quiescent now. Fail if we have any ready device. | ||
5855 | * This happens if hotplug occurs between completion of device | ||
5856 | * suspension and here. | ||
5857 | */ | ||
5858 | for (i = 0; i < host->n_ports; i++) { | ||
5859 | struct ata_port *ap = host->ports[i]; | ||
5860 | |||
5861 | for (j = 0; j < ATA_MAX_DEVICES; j++) { | ||
5862 | struct ata_device *dev = &ap->device[j]; | ||
5863 | |||
5864 | if (ata_dev_ready(dev)) { | ||
5865 | ata_port_printk(ap, KERN_WARNING, | ||
5866 | "suspend failed, device %d " | ||
5867 | "still active\n", dev->devno); | ||
5868 | rc = -EBUSY; | ||
5869 | goto fail; | ||
5870 | } | ||
5871 | } | ||
5872 | } | ||
5873 | |||
5874 | host->dev->power.power_state = mesg; | ||
5875 | return 0; | ||
5876 | |||
5877 | fail: | ||
5878 | ata_host_resume(host); | ||
5879 | return rc; | 5879 | return rc; |
5880 | } | 5880 | } |
5881 | 5881 | ||
@@ -5984,6 +5984,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
5984 | if (!ap) | 5984 | if (!ap) |
5985 | return NULL; | 5985 | return NULL; |
5986 | 5986 | ||
5987 | ap->pflags |= ATA_PFLAG_INITIALIZING; | ||
5987 | ap->lock = &host->lock; | 5988 | ap->lock = &host->lock; |
5988 | ap->flags = ATA_FLAG_DISABLED; | 5989 | ap->flags = ATA_FLAG_DISABLED; |
5989 | ap->print_id = -1; | 5990 | ap->print_id = -1; |
@@ -6352,6 +6353,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6352 | ehi->action |= ATA_EH_SOFTRESET; | 6353 | ehi->action |= ATA_EH_SOFTRESET; |
6353 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; | 6354 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; |
6354 | 6355 | ||
6356 | ap->pflags &= ~ATA_PFLAG_INITIALIZING; | ||
6355 | ap->pflags |= ATA_PFLAG_LOADING; | 6357 | ap->pflags |= ATA_PFLAG_LOADING; |
6356 | ata_port_schedule_eh(ap); | 6358 | ata_port_schedule_eh(ap); |
6357 | 6359 | ||
@@ -6876,6 +6878,7 @@ EXPORT_SYMBOL_GPL(ata_timing_merge); | |||
6876 | #ifdef CONFIG_PCI | 6878 | #ifdef CONFIG_PCI |
6877 | EXPORT_SYMBOL_GPL(pci_test_config_bits); | 6879 | EXPORT_SYMBOL_GPL(pci_test_config_bits); |
6878 | EXPORT_SYMBOL_GPL(ata_pci_init_native_host); | 6880 | EXPORT_SYMBOL_GPL(ata_pci_init_native_host); |
6881 | EXPORT_SYMBOL_GPL(ata_pci_init_bmdma); | ||
6879 | EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); | 6882 | EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); |
6880 | EXPORT_SYMBOL_GPL(ata_pci_init_one); | 6883 | EXPORT_SYMBOL_GPL(ata_pci_init_one); |
6881 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); | 6884 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
@@ -6889,11 +6892,6 @@ EXPORT_SYMBOL_GPL(ata_pci_default_filter); | |||
6889 | EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); | 6892 | EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); |
6890 | #endif /* CONFIG_PCI */ | 6893 | #endif /* CONFIG_PCI */ |
6891 | 6894 | ||
6892 | #ifdef CONFIG_PM | ||
6893 | EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); | ||
6894 | EXPORT_SYMBOL_GPL(ata_scsi_device_resume); | ||
6895 | #endif /* CONFIG_PM */ | ||
6896 | |||
6897 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | 6895 | EXPORT_SYMBOL_GPL(ata_eng_timeout); |
6898 | EXPORT_SYMBOL_GPL(ata_port_schedule_eh); | 6896 | EXPORT_SYMBOL_GPL(ata_port_schedule_eh); |
6899 | EXPORT_SYMBOL_GPL(ata_port_abort); | 6897 | EXPORT_SYMBOL_GPL(ata_port_abort); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 8256655ce7d9..5309c312f517 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -77,29 +77,12 @@ static void ata_eh_finish(struct ata_port *ap); | |||
77 | #ifdef CONFIG_PM | 77 | #ifdef CONFIG_PM |
78 | static void ata_eh_handle_port_suspend(struct ata_port *ap); | 78 | static void ata_eh_handle_port_suspend(struct ata_port *ap); |
79 | static void ata_eh_handle_port_resume(struct ata_port *ap); | 79 | static void ata_eh_handle_port_resume(struct ata_port *ap); |
80 | static int ata_eh_suspend(struct ata_port *ap, | ||
81 | struct ata_device **r_failed_dev); | ||
82 | static void ata_eh_prep_resume(struct ata_port *ap); | ||
83 | static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev); | ||
84 | #else /* CONFIG_PM */ | 80 | #else /* CONFIG_PM */ |
85 | static void ata_eh_handle_port_suspend(struct ata_port *ap) | 81 | static void ata_eh_handle_port_suspend(struct ata_port *ap) |
86 | { } | 82 | { } |
87 | 83 | ||
88 | static void ata_eh_handle_port_resume(struct ata_port *ap) | 84 | static void ata_eh_handle_port_resume(struct ata_port *ap) |
89 | { } | 85 | { } |
90 | |||
91 | static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
92 | { | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static void ata_eh_prep_resume(struct ata_port *ap) | ||
97 | { } | ||
98 | |||
99 | static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
100 | { | ||
101 | return 0; | ||
102 | } | ||
103 | #endif /* CONFIG_PM */ | 86 | #endif /* CONFIG_PM */ |
104 | 87 | ||
105 | static void ata_ering_record(struct ata_ering *ering, int is_io, | 88 | static void ata_ering_record(struct ata_ering *ering, int is_io, |
@@ -568,6 +551,9 @@ void ata_port_schedule_eh(struct ata_port *ap) | |||
568 | { | 551 | { |
569 | WARN_ON(!ap->ops->error_handler); | 552 | WARN_ON(!ap->ops->error_handler); |
570 | 553 | ||
554 | if (ap->pflags & ATA_PFLAG_INITIALIZING) | ||
555 | return; | ||
556 | |||
571 | ap->pflags |= ATA_PFLAG_EH_PENDING; | 557 | ap->pflags |= ATA_PFLAG_EH_PENDING; |
572 | scsi_schedule_eh(ap->scsi_host); | 558 | scsi_schedule_eh(ap->scsi_host); |
573 | 559 | ||
@@ -1791,7 +1777,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, | |||
1791 | if (ehc->i.flags & ATA_EHI_DID_RESET) | 1777 | if (ehc->i.flags & ATA_EHI_DID_RESET) |
1792 | readid_flags |= ATA_READID_POSTRESET; | 1778 | readid_flags |= ATA_READID_POSTRESET; |
1793 | 1779 | ||
1794 | if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { | 1780 | if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { |
1795 | if (ata_port_offline(ap)) { | 1781 | if (ata_port_offline(ap)) { |
1796 | rc = -EIO; | 1782 | rc = -EIO; |
1797 | goto err; | 1783 | goto err; |
@@ -1872,166 +1858,6 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, | |||
1872 | return rc; | 1858 | return rc; |
1873 | } | 1859 | } |
1874 | 1860 | ||
1875 | #ifdef CONFIG_PM | ||
1876 | /** | ||
1877 | * ata_eh_suspend - handle suspend EH action | ||
1878 | * @ap: target host port | ||
1879 | * @r_failed_dev: result parameter to indicate failing device | ||
1880 | * | ||
1881 | * Handle suspend EH action. Disk devices are spinned down and | ||
1882 | * other types of devices are just marked suspended. Once | ||
1883 | * suspended, no EH action to the device is allowed until it is | ||
1884 | * resumed. | ||
1885 | * | ||
1886 | * LOCKING: | ||
1887 | * Kernel thread context (may sleep). | ||
1888 | * | ||
1889 | * RETURNS: | ||
1890 | * 0 on success, -errno otherwise | ||
1891 | */ | ||
1892 | static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
1893 | { | ||
1894 | struct ata_device *dev; | ||
1895 | int i, rc = 0; | ||
1896 | |||
1897 | DPRINTK("ENTER\n"); | ||
1898 | |||
1899 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
1900 | unsigned long flags; | ||
1901 | unsigned int action, err_mask; | ||
1902 | |||
1903 | dev = &ap->device[i]; | ||
1904 | action = ata_eh_dev_action(dev); | ||
1905 | |||
1906 | if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND)) | ||
1907 | continue; | ||
1908 | |||
1909 | WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED); | ||
1910 | |||
1911 | ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND); | ||
1912 | |||
1913 | if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { | ||
1914 | /* flush cache */ | ||
1915 | rc = ata_flush_cache(dev); | ||
1916 | if (rc) | ||
1917 | break; | ||
1918 | |||
1919 | /* spin down */ | ||
1920 | err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); | ||
1921 | if (err_mask) { | ||
1922 | ata_dev_printk(dev, KERN_ERR, "failed to " | ||
1923 | "spin down (err_mask=0x%x)\n", | ||
1924 | err_mask); | ||
1925 | rc = -EIO; | ||
1926 | break; | ||
1927 | } | ||
1928 | } | ||
1929 | |||
1930 | spin_lock_irqsave(ap->lock, flags); | ||
1931 | dev->flags |= ATA_DFLAG_SUSPENDED; | ||
1932 | spin_unlock_irqrestore(ap->lock, flags); | ||
1933 | |||
1934 | ata_eh_done(ap, dev, ATA_EH_SUSPEND); | ||
1935 | } | ||
1936 | |||
1937 | if (rc) | ||
1938 | *r_failed_dev = dev; | ||
1939 | |||
1940 | DPRINTK("EXIT\n"); | ||
1941 | return rc; | ||
1942 | } | ||
1943 | |||
1944 | /** | ||
1945 | * ata_eh_prep_resume - prep for resume EH action | ||
1946 | * @ap: target host port | ||
1947 | * | ||
1948 | * Clear SUSPENDED in preparation for scheduled resume actions. | ||
1949 | * This allows other parts of EH to access the devices being | ||
1950 | * resumed. | ||
1951 | * | ||
1952 | * LOCKING: | ||
1953 | * Kernel thread context (may sleep). | ||
1954 | */ | ||
1955 | static void ata_eh_prep_resume(struct ata_port *ap) | ||
1956 | { | ||
1957 | struct ata_device *dev; | ||
1958 | unsigned long flags; | ||
1959 | int i; | ||
1960 | |||
1961 | DPRINTK("ENTER\n"); | ||
1962 | |||
1963 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
1964 | unsigned int action; | ||
1965 | |||
1966 | dev = &ap->device[i]; | ||
1967 | action = ata_eh_dev_action(dev); | ||
1968 | |||
1969 | if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) | ||
1970 | continue; | ||
1971 | |||
1972 | spin_lock_irqsave(ap->lock, flags); | ||
1973 | dev->flags &= ~ATA_DFLAG_SUSPENDED; | ||
1974 | spin_unlock_irqrestore(ap->lock, flags); | ||
1975 | } | ||
1976 | |||
1977 | DPRINTK("EXIT\n"); | ||
1978 | } | ||
1979 | |||
1980 | /** | ||
1981 | * ata_eh_resume - handle resume EH action | ||
1982 | * @ap: target host port | ||
1983 | * @r_failed_dev: result parameter to indicate failing device | ||
1984 | * | ||
1985 | * Handle resume EH action. Target devices are already reset and | ||
1986 | * revalidated. Spinning up is the only operation left. | ||
1987 | * | ||
1988 | * LOCKING: | ||
1989 | * Kernel thread context (may sleep). | ||
1990 | * | ||
1991 | * RETURNS: | ||
1992 | * 0 on success, -errno otherwise | ||
1993 | */ | ||
1994 | static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
1995 | { | ||
1996 | struct ata_device *dev; | ||
1997 | int i, rc = 0; | ||
1998 | |||
1999 | DPRINTK("ENTER\n"); | ||
2000 | |||
2001 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
2002 | unsigned int action, err_mask; | ||
2003 | |||
2004 | dev = &ap->device[i]; | ||
2005 | action = ata_eh_dev_action(dev); | ||
2006 | |||
2007 | if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) | ||
2008 | continue; | ||
2009 | |||
2010 | ata_eh_about_to_do(ap, dev, ATA_EH_RESUME); | ||
2011 | |||
2012 | if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { | ||
2013 | err_mask = ata_do_simple_cmd(dev, | ||
2014 | ATA_CMD_IDLEIMMEDIATE); | ||
2015 | if (err_mask) { | ||
2016 | ata_dev_printk(dev, KERN_ERR, "failed to " | ||
2017 | "spin up (err_mask=0x%x)\n", | ||
2018 | err_mask); | ||
2019 | rc = -EIO; | ||
2020 | break; | ||
2021 | } | ||
2022 | } | ||
2023 | |||
2024 | ata_eh_done(ap, dev, ATA_EH_RESUME); | ||
2025 | } | ||
2026 | |||
2027 | if (rc) | ||
2028 | *r_failed_dev = dev; | ||
2029 | |||
2030 | DPRINTK("EXIT\n"); | ||
2031 | return 0; | ||
2032 | } | ||
2033 | #endif /* CONFIG_PM */ | ||
2034 | |||
2035 | static int ata_port_nr_enabled(struct ata_port *ap) | 1861 | static int ata_port_nr_enabled(struct ata_port *ap) |
2036 | { | 1862 | { |
2037 | int i, cnt = 0; | 1863 | int i, cnt = 0; |
@@ -2057,17 +1883,6 @@ static int ata_eh_skip_recovery(struct ata_port *ap) | |||
2057 | struct ata_eh_context *ehc = &ap->eh_context; | 1883 | struct ata_eh_context *ehc = &ap->eh_context; |
2058 | int i; | 1884 | int i; |
2059 | 1885 | ||
2060 | /* skip if all possible devices are suspended */ | ||
2061 | for (i = 0; i < ata_port_max_devices(ap); i++) { | ||
2062 | struct ata_device *dev = &ap->device[i]; | ||
2063 | |||
2064 | if (!(dev->flags & ATA_DFLAG_SUSPENDED)) | ||
2065 | break; | ||
2066 | } | ||
2067 | |||
2068 | if (i == ata_port_max_devices(ap)) | ||
2069 | return 1; | ||
2070 | |||
2071 | /* thaw frozen port, resume link and recover failed devices */ | 1886 | /* thaw frozen port, resume link and recover failed devices */ |
2072 | if ((ap->pflags & ATA_PFLAG_FROZEN) || | 1887 | if ((ap->pflags & ATA_PFLAG_FROZEN) || |
2073 | (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) | 1888 | (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) |
@@ -2147,9 +1962,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2147 | if (ap->pflags & ATA_PFLAG_UNLOADING) | 1962 | if (ap->pflags & ATA_PFLAG_UNLOADING) |
2148 | goto out; | 1963 | goto out; |
2149 | 1964 | ||
2150 | /* prep for resume */ | ||
2151 | ata_eh_prep_resume(ap); | ||
2152 | |||
2153 | /* skip EH if possible. */ | 1965 | /* skip EH if possible. */ |
2154 | if (ata_eh_skip_recovery(ap)) | 1966 | if (ata_eh_skip_recovery(ap)) |
2155 | ehc->i.action = 0; | 1967 | ehc->i.action = 0; |
@@ -2177,11 +1989,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2177 | if (rc) | 1989 | if (rc) |
2178 | goto dev_fail; | 1990 | goto dev_fail; |
2179 | 1991 | ||
2180 | /* resume devices */ | ||
2181 | rc = ata_eh_resume(ap, &dev); | ||
2182 | if (rc) | ||
2183 | goto dev_fail; | ||
2184 | |||
2185 | /* configure transfer mode if necessary */ | 1992 | /* configure transfer mode if necessary */ |
2186 | if (ehc->i.flags & ATA_EHI_SETMODE) { | 1993 | if (ehc->i.flags & ATA_EHI_SETMODE) { |
2187 | rc = ata_set_mode(ap, &dev); | 1994 | rc = ata_set_mode(ap, &dev); |
@@ -2190,25 +1997,16 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2190 | ehc->i.flags &= ~ATA_EHI_SETMODE; | 1997 | ehc->i.flags &= ~ATA_EHI_SETMODE; |
2191 | } | 1998 | } |
2192 | 1999 | ||
2193 | /* suspend devices */ | ||
2194 | rc = ata_eh_suspend(ap, &dev); | ||
2195 | if (rc) | ||
2196 | goto dev_fail; | ||
2197 | |||
2198 | goto out; | 2000 | goto out; |
2199 | 2001 | ||
2200 | dev_fail: | 2002 | dev_fail: |
2201 | ehc->tries[dev->devno]--; | 2003 | ehc->tries[dev->devno]--; |
2202 | 2004 | ||
2203 | switch (rc) { | 2005 | switch (rc) { |
2204 | case -EINVAL: | ||
2205 | /* eeek, something went very wrong, give up */ | ||
2206 | ehc->tries[dev->devno] = 0; | ||
2207 | break; | ||
2208 | |||
2209 | case -ENODEV: | 2006 | case -ENODEV: |
2210 | /* device missing or wrong IDENTIFY data, schedule probing */ | 2007 | /* device missing or wrong IDENTIFY data, schedule probing */ |
2211 | ehc->i.probe_mask |= (1 << dev->devno); | 2008 | ehc->i.probe_mask |= (1 << dev->devno); |
2009 | case -EINVAL: | ||
2212 | /* give it just one more chance */ | 2010 | /* give it just one more chance */ |
2213 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); | 2011 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); |
2214 | case -EIO: | 2012 | case -EIO: |
@@ -2390,22 +2188,13 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap) | |||
2390 | * | 2188 | * |
2391 | * Resume @ap. | 2189 | * Resume @ap. |
2392 | * | 2190 | * |
2393 | * This function also waits upto one second until all devices | ||
2394 | * hanging off this port requests resume EH action. This is to | ||
2395 | * prevent invoking EH and thus reset multiple times on resume. | ||
2396 | * | ||
2397 | * On DPM resume, where some of devices might not be resumed | ||
2398 | * together, this may delay port resume upto one second, but such | ||
2399 | * DPM resumes are rare and 1 sec delay isn't too bad. | ||
2400 | * | ||
2401 | * LOCKING: | 2191 | * LOCKING: |
2402 | * Kernel thread context (may sleep). | 2192 | * Kernel thread context (may sleep). |
2403 | */ | 2193 | */ |
2404 | static void ata_eh_handle_port_resume(struct ata_port *ap) | 2194 | static void ata_eh_handle_port_resume(struct ata_port *ap) |
2405 | { | 2195 | { |
2406 | unsigned long timeout; | ||
2407 | unsigned long flags; | 2196 | unsigned long flags; |
2408 | int i, rc = 0; | 2197 | int rc = 0; |
2409 | 2198 | ||
2410 | /* are we resuming? */ | 2199 | /* are we resuming? */ |
2411 | spin_lock_irqsave(ap->lock, flags); | 2200 | spin_lock_irqsave(ap->lock, flags); |
@@ -2416,31 +2205,12 @@ static void ata_eh_handle_port_resume(struct ata_port *ap) | |||
2416 | } | 2205 | } |
2417 | spin_unlock_irqrestore(ap->lock, flags); | 2206 | spin_unlock_irqrestore(ap->lock, flags); |
2418 | 2207 | ||
2419 | /* spurious? */ | 2208 | WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); |
2420 | if (!(ap->pflags & ATA_PFLAG_SUSPENDED)) | ||
2421 | goto done; | ||
2422 | 2209 | ||
2423 | if (ap->ops->port_resume) | 2210 | if (ap->ops->port_resume) |
2424 | rc = ap->ops->port_resume(ap); | 2211 | rc = ap->ops->port_resume(ap); |
2425 | 2212 | ||
2426 | /* give devices time to request EH */ | 2213 | /* report result */ |
2427 | timeout = jiffies + HZ; /* 1s max */ | ||
2428 | while (1) { | ||
2429 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
2430 | struct ata_device *dev = &ap->device[i]; | ||
2431 | unsigned int action = ata_eh_dev_action(dev); | ||
2432 | |||
2433 | if ((dev->flags & ATA_DFLAG_SUSPENDED) && | ||
2434 | !(action & ATA_EH_RESUME)) | ||
2435 | break; | ||
2436 | } | ||
2437 | |||
2438 | if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout)) | ||
2439 | break; | ||
2440 | msleep(10); | ||
2441 | } | ||
2442 | |||
2443 | done: | ||
2444 | spin_lock_irqsave(ap->lock, flags); | 2214 | spin_lock_irqsave(ap->lock, flags); |
2445 | ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); | 2215 | ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); |
2446 | if (ap->pm_result) { | 2216 | if (ap->pm_result) { |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 9afba2ba489e..dd81fa78cdcf 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -510,133 +510,6 @@ static void ata_dump_status(unsigned id, struct ata_taskfile *tf) | |||
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
513 | #ifdef CONFIG_PM | ||
514 | /** | ||
515 | * ata_scsi_device_suspend - suspend ATA device associated with sdev | ||
516 | * @sdev: the SCSI device to suspend | ||
517 | * @mesg: target power management message | ||
518 | * | ||
519 | * Request suspend EH action on the ATA device associated with | ||
520 | * @sdev and wait for the operation to complete. | ||
521 | * | ||
522 | * LOCKING: | ||
523 | * Kernel thread context (may sleep). | ||
524 | * | ||
525 | * RETURNS: | ||
526 | * 0 on success, -errno otherwise. | ||
527 | */ | ||
528 | int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg) | ||
529 | { | ||
530 | struct ata_port *ap = ata_shost_to_port(sdev->host); | ||
531 | struct ata_device *dev = ata_scsi_find_dev(ap, sdev); | ||
532 | unsigned long flags; | ||
533 | unsigned int action; | ||
534 | int rc = 0; | ||
535 | |||
536 | if (!dev) | ||
537 | goto out; | ||
538 | |||
539 | spin_lock_irqsave(ap->lock, flags); | ||
540 | |||
541 | /* wait for the previous resume to complete */ | ||
542 | while (dev->flags & ATA_DFLAG_SUSPENDED) { | ||
543 | spin_unlock_irqrestore(ap->lock, flags); | ||
544 | ata_port_wait_eh(ap); | ||
545 | spin_lock_irqsave(ap->lock, flags); | ||
546 | } | ||
547 | |||
548 | /* if @sdev is already detached, nothing to do */ | ||
549 | if (sdev->sdev_state == SDEV_OFFLINE || | ||
550 | sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) | ||
551 | goto out_unlock; | ||
552 | |||
553 | /* request suspend */ | ||
554 | action = ATA_EH_SUSPEND; | ||
555 | if (mesg.event != PM_EVENT_SUSPEND) | ||
556 | action |= ATA_EH_PM_FREEZE; | ||
557 | ap->eh_info.dev_action[dev->devno] |= action; | ||
558 | ap->eh_info.flags |= ATA_EHI_QUIET; | ||
559 | ata_port_schedule_eh(ap); | ||
560 | |||
561 | spin_unlock_irqrestore(ap->lock, flags); | ||
562 | |||
563 | /* wait for EH to do the job */ | ||
564 | ata_port_wait_eh(ap); | ||
565 | |||
566 | spin_lock_irqsave(ap->lock, flags); | ||
567 | |||
568 | /* If @sdev is still attached but the associated ATA device | ||
569 | * isn't suspended, the operation failed. | ||
570 | */ | ||
571 | if (sdev->sdev_state != SDEV_OFFLINE && | ||
572 | sdev->sdev_state != SDEV_CANCEL && sdev->sdev_state != SDEV_DEL && | ||
573 | !(dev->flags & ATA_DFLAG_SUSPENDED)) | ||
574 | rc = -EIO; | ||
575 | |||
576 | out_unlock: | ||
577 | spin_unlock_irqrestore(ap->lock, flags); | ||
578 | out: | ||
579 | if (rc == 0) | ||
580 | sdev->sdev_gendev.power.power_state = mesg; | ||
581 | return rc; | ||
582 | } | ||
583 | |||
584 | /** | ||
585 | * ata_scsi_device_resume - resume ATA device associated with sdev | ||
586 | * @sdev: the SCSI device to resume | ||
587 | * | ||
588 | * Request resume EH action on the ATA device associated with | ||
589 | * @sdev and return immediately. This enables parallel | ||
590 | * wakeup/spinup of devices. | ||
591 | * | ||
592 | * LOCKING: | ||
593 | * Kernel thread context (may sleep). | ||
594 | * | ||
595 | * RETURNS: | ||
596 | * 0. | ||
597 | */ | ||
598 | int ata_scsi_device_resume(struct scsi_device *sdev) | ||
599 | { | ||
600 | struct ata_port *ap = ata_shost_to_port(sdev->host); | ||
601 | struct ata_device *dev = ata_scsi_find_dev(ap, sdev); | ||
602 | struct ata_eh_info *ehi = &ap->eh_info; | ||
603 | unsigned long flags; | ||
604 | unsigned int action; | ||
605 | |||
606 | if (!dev) | ||
607 | goto out; | ||
608 | |||
609 | spin_lock_irqsave(ap->lock, flags); | ||
610 | |||
611 | /* if @sdev is already detached, nothing to do */ | ||
612 | if (sdev->sdev_state == SDEV_OFFLINE || | ||
613 | sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) | ||
614 | goto out_unlock; | ||
615 | |||
616 | /* request resume */ | ||
617 | action = ATA_EH_RESUME; | ||
618 | if (sdev->sdev_gendev.power.power_state.event == PM_EVENT_SUSPEND) | ||
619 | __ata_ehi_hotplugged(ehi); | ||
620 | else | ||
621 | action |= ATA_EH_PM_FREEZE | ATA_EH_SOFTRESET; | ||
622 | ehi->dev_action[dev->devno] |= action; | ||
623 | |||
624 | /* We don't want autopsy and verbose EH messages. Disable | ||
625 | * those if we're the only device on this link. | ||
626 | */ | ||
627 | if (ata_port_max_devices(ap) == 1) | ||
628 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; | ||
629 | |||
630 | ata_port_schedule_eh(ap); | ||
631 | |||
632 | out_unlock: | ||
633 | spin_unlock_irqrestore(ap->lock, flags); | ||
634 | out: | ||
635 | sdev->sdev_gendev.power.power_state = PMSG_ON; | ||
636 | return 0; | ||
637 | } | ||
638 | #endif /* CONFIG_PM */ | ||
639 | |||
640 | /** | 513 | /** |
641 | * ata_to_sense_error - convert ATA error to SCSI error | 514 | * ata_to_sense_error - convert ATA error to SCSI error |
642 | * @id: ATA device number | 515 | * @id: ATA device number |
@@ -929,6 +802,8 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
929 | 802 | ||
930 | blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); | 803 | blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); |
931 | 804 | ||
805 | sdev->manage_start_stop = 1; | ||
806 | |||
932 | if (dev) | 807 | if (dev) |
933 | ata_scsi_dev_config(sdev, dev); | 808 | ata_scsi_dev_config(sdev, dev); |
934 | 809 | ||
@@ -1069,9 +944,35 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) | |||
1069 | } | 944 | } |
1070 | 945 | ||
1071 | tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ | 946 | tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ |
1072 | } else | 947 | } else { |
948 | /* XXX: This is for backward compatibility, will be | ||
949 | * removed. Read Documentation/feature-removal-schedule.txt | ||
950 | * for more info. | ||
951 | */ | ||
952 | if (ata_spindown_compat && | ||
953 | (system_state == SYSTEM_HALT || | ||
954 | system_state == SYSTEM_POWER_OFF)) { | ||
955 | static int warned = 0; | ||
956 | |||
957 | if (!warned) { | ||
958 | spin_unlock_irq(qc->ap->lock); | ||
959 | ata_dev_printk(qc->dev, KERN_WARNING, | ||
960 | "DISK MIGHT NOT BE SPUN DOWN PROPERLY. " | ||
961 | "UPDATE SHUTDOWN UTILITY\n"); | ||
962 | ata_dev_printk(qc->dev, KERN_WARNING, | ||
963 | "For more info, visit " | ||
964 | "http://linux-ata.org/shutdown.html\n"); | ||
965 | warned = 1; | ||
966 | ssleep(5); | ||
967 | spin_lock_irq(qc->ap->lock); | ||
968 | } | ||
969 | scmd->result = SAM_STAT_GOOD; | ||
970 | return 1; | ||
971 | } | ||
972 | |||
1073 | /* Issue ATA STANDBY IMMEDIATE command */ | 973 | /* Issue ATA STANDBY IMMEDIATE command */ |
1074 | tf->command = ATA_CMD_STANDBYNOW1; | 974 | tf->command = ATA_CMD_STANDBYNOW1; |
975 | } | ||
1075 | 976 | ||
1076 | /* | 977 | /* |
1077 | * Standby and Idle condition timers could be implemented but that | 978 | * Standby and Idle condition timers could be implemented but that |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index d211db6b35a2..e35d13466c69 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -544,7 +544,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port) | |||
544 | * RETURNS: | 544 | * RETURNS: |
545 | * 0 on success, -errno otherwise. | 545 | * 0 on success, -errno otherwise. |
546 | */ | 546 | */ |
547 | static int ata_pci_init_bmdma(struct ata_host *host) | 547 | int ata_pci_init_bmdma(struct ata_host *host) |
548 | { | 548 | { |
549 | struct device *gdev = host->dev; | 549 | struct device *gdev = host->dev; |
550 | struct pci_dev *pdev = to_pci_dev(gdev); | 550 | struct pci_dev *pdev = to_pci_dev(gdev); |
@@ -566,7 +566,7 @@ static int ata_pci_init_bmdma(struct ata_host *host) | |||
566 | } | 566 | } |
567 | host->iomap = pcim_iomap_table(pdev); | 567 | host->iomap = pcim_iomap_table(pdev); |
568 | 568 | ||
569 | for (i = 0; i < host->n_ports; i++) { | 569 | for (i = 0; i < 2; i++) { |
570 | struct ata_port *ap = host->ports[i]; | 570 | struct ata_port *ap = host->ports[i]; |
571 | void __iomem *bmdma = host->iomap[4] + 8 * i; | 571 | void __iomem *bmdma = host->iomap[4] + 8 * i; |
572 | 572 | ||
@@ -585,54 +585,52 @@ static int ata_pci_init_bmdma(struct ata_host *host) | |||
585 | /** | 585 | /** |
586 | * ata_pci_init_native_host - acquire native ATA resources and init host | 586 | * ata_pci_init_native_host - acquire native ATA resources and init host |
587 | * @host: target ATA host | 587 | * @host: target ATA host |
588 | * @port_mask: ports to consider | ||
589 | * | 588 | * |
590 | * Acquire native PCI ATA resources for @host and initialize | 589 | * Acquire native PCI ATA resources for @host and initialize the |
591 | * @host accordoingly. | 590 | * first two ports of @host accordingly. Ports marked dummy are |
591 | * skipped and allocation failure makes the port dummy. | ||
592 | * | 592 | * |
593 | * LOCKING: | 593 | * LOCKING: |
594 | * Inherited from calling layer (may sleep). | 594 | * Inherited from calling layer (may sleep). |
595 | * | 595 | * |
596 | * RETURNS: | 596 | * RETURNS: |
597 | * 0 on success, -errno otherwise. | 597 | * 0 if at least one port is initialized, -ENODEV if no port is |
598 | * available. | ||
598 | */ | 599 | */ |
599 | int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | 600 | int ata_pci_init_native_host(struct ata_host *host) |
600 | { | 601 | { |
601 | struct device *gdev = host->dev; | 602 | struct device *gdev = host->dev; |
602 | struct pci_dev *pdev = to_pci_dev(gdev); | 603 | struct pci_dev *pdev = to_pci_dev(gdev); |
604 | unsigned int mask = 0; | ||
603 | int i, rc; | 605 | int i, rc; |
604 | 606 | ||
605 | /* Discard disabled ports. Some controllers show their unused | ||
606 | * channels this way. Disabled ports are made dummy. | ||
607 | */ | ||
608 | for (i = 0; i < 2; i++) { | ||
609 | if ((port_mask & (1 << i)) && !ata_resources_present(pdev, i)) { | ||
610 | host->ports[i]->ops = &ata_dummy_port_ops; | ||
611 | port_mask &= ~(1 << i); | ||
612 | } | ||
613 | } | ||
614 | |||
615 | if (!port_mask) { | ||
616 | dev_printk(KERN_ERR, gdev, "no available port\n"); | ||
617 | return -ENODEV; | ||
618 | } | ||
619 | |||
620 | /* request, iomap BARs and init port addresses accordingly */ | 607 | /* request, iomap BARs and init port addresses accordingly */ |
621 | for (i = 0; i < 2; i++) { | 608 | for (i = 0; i < 2; i++) { |
622 | struct ata_port *ap = host->ports[i]; | 609 | struct ata_port *ap = host->ports[i]; |
623 | int base = i * 2; | 610 | int base = i * 2; |
624 | void __iomem * const *iomap; | 611 | void __iomem * const *iomap; |
625 | 612 | ||
626 | if (!(port_mask & (1 << i))) | 613 | if (ata_port_is_dummy(ap)) |
614 | continue; | ||
615 | |||
616 | /* Discard disabled ports. Some controllers show | ||
617 | * their unused channels this way. Disabled ports are | ||
618 | * made dummy. | ||
619 | */ | ||
620 | if (!ata_resources_present(pdev, i)) { | ||
621 | ap->ops = &ata_dummy_port_ops; | ||
627 | continue; | 622 | continue; |
623 | } | ||
628 | 624 | ||
629 | rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); | 625 | rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); |
630 | if (rc) { | 626 | if (rc) { |
631 | dev_printk(KERN_ERR, gdev, "failed to request/iomap " | 627 | dev_printk(KERN_WARNING, gdev, |
632 | "BARs for port %d (errno=%d)\n", i, rc); | 628 | "failed to request/iomap BARs for port %d " |
629 | "(errno=%d)\n", i, rc); | ||
633 | if (rc == -EBUSY) | 630 | if (rc == -EBUSY) |
634 | pcim_pin_device(pdev); | 631 | pcim_pin_device(pdev); |
635 | return rc; | 632 | ap->ops = &ata_dummy_port_ops; |
633 | continue; | ||
636 | } | 634 | } |
637 | host->iomap = iomap = pcim_iomap_table(pdev); | 635 | host->iomap = iomap = pcim_iomap_table(pdev); |
638 | 636 | ||
@@ -641,6 +639,13 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | |||
641 | ap->ioaddr.ctl_addr = (void __iomem *) | 639 | ap->ioaddr.ctl_addr = (void __iomem *) |
642 | ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); | 640 | ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); |
643 | ata_std_ports(&ap->ioaddr); | 641 | ata_std_ports(&ap->ioaddr); |
642 | |||
643 | mask |= 1 << i; | ||
644 | } | ||
645 | |||
646 | if (!mask) { | ||
647 | dev_printk(KERN_ERR, gdev, "no available native port\n"); | ||
648 | return -ENODEV; | ||
644 | } | 649 | } |
645 | 650 | ||
646 | return 0; | 651 | return 0; |
@@ -649,8 +654,7 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | |||
649 | /** | 654 | /** |
650 | * ata_pci_prepare_native_host - helper to prepare native PCI ATA host | 655 | * ata_pci_prepare_native_host - helper to prepare native PCI ATA host |
651 | * @pdev: target PCI device | 656 | * @pdev: target PCI device |
652 | * @ppi: array of port_info | 657 | * @ppi: array of port_info, must be enough for two ports |
653 | * @n_ports: number of ports to allocate | ||
654 | * @r_host: out argument for the initialized ATA host | 658 | * @r_host: out argument for the initialized ATA host |
655 | * | 659 | * |
656 | * Helper to allocate ATA host for @pdev, acquire all native PCI | 660 | * Helper to allocate ATA host for @pdev, acquire all native PCI |
@@ -664,10 +668,9 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | |||
664 | */ | 668 | */ |
665 | int ata_pci_prepare_native_host(struct pci_dev *pdev, | 669 | int ata_pci_prepare_native_host(struct pci_dev *pdev, |
666 | const struct ata_port_info * const * ppi, | 670 | const struct ata_port_info * const * ppi, |
667 | int n_ports, struct ata_host **r_host) | 671 | struct ata_host **r_host) |
668 | { | 672 | { |
669 | struct ata_host *host; | 673 | struct ata_host *host; |
670 | unsigned int port_mask; | ||
671 | int rc; | 674 | int rc; |
672 | 675 | ||
673 | if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) | 676 | if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) |
@@ -681,11 +684,7 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev, | |||
681 | goto err_out; | 684 | goto err_out; |
682 | } | 685 | } |
683 | 686 | ||
684 | port_mask = ATA_PORT_PRIMARY; | 687 | rc = ata_pci_init_native_host(host); |
685 | if (n_ports > 1) | ||
686 | port_mask |= ATA_PORT_SECONDARY; | ||
687 | |||
688 | rc = ata_pci_init_native_host(host, port_mask); | ||
689 | if (rc) | 688 | if (rc) |
690 | goto err_out; | 689 | goto err_out; |
691 | 690 | ||
@@ -777,8 +776,11 @@ static int ata_init_legacy_port(struct ata_port *ap, | |||
777 | /* iomap cmd and ctl ports */ | 776 | /* iomap cmd and ctl ports */ |
778 | legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); | 777 | legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); |
779 | legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); | 778 | legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); |
780 | if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) | 779 | if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) { |
780 | dev_printk(KERN_WARNING, host->dev, | ||
781 | "failed to map cmd/ctl ports\n"); | ||
781 | return -ENOMEM; | 782 | return -ENOMEM; |
783 | } | ||
782 | 784 | ||
783 | /* init IO addresses */ | 785 | /* init IO addresses */ |
784 | ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; | 786 | ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; |
@@ -792,19 +794,20 @@ static int ata_init_legacy_port(struct ata_port *ap, | |||
792 | /** | 794 | /** |
793 | * ata_init_legacy_host - acquire legacy ATA resources and init ATA host | 795 | * ata_init_legacy_host - acquire legacy ATA resources and init ATA host |
794 | * @host: target ATA host | 796 | * @host: target ATA host |
795 | * @legacy_mask: out parameter, mask indicating ports is in legacy mode | ||
796 | * @was_busy: out parameter, indicates whether any port was busy | 797 | * @was_busy: out parameter, indicates whether any port was busy |
797 | * | 798 | * |
798 | * Acquire legacy ATA resources for ports. | 799 | * Acquire legacy ATA resources for the first two ports of @host |
800 | * and initialize it accordingly. Ports marked dummy are skipped | ||
801 | * and resource acquistion failure makes the port dummy. | ||
799 | * | 802 | * |
800 | * LOCKING: | 803 | * LOCKING: |
801 | * Inherited from calling layer (may sleep). | 804 | * Inherited from calling layer (may sleep). |
802 | * | 805 | * |
803 | * RETURNS: | 806 | * RETURNS: |
804 | * 0 on success, -errno otherwise. | 807 | * 0 if at least one port is initialized, -ENODEV if no port is |
808 | * available. | ||
805 | */ | 809 | */ |
806 | static int ata_init_legacy_host(struct ata_host *host, | 810 | static int ata_init_legacy_host(struct ata_host *host, int *was_busy) |
807 | unsigned int *legacy_mask, int *was_busy) | ||
808 | { | 811 | { |
809 | struct device *gdev = host->dev; | 812 | struct device *gdev = host->dev; |
810 | struct ata_legacy_devres *legacy_dr; | 813 | struct ata_legacy_devres *legacy_dr; |
@@ -821,22 +824,23 @@ static int ata_init_legacy_host(struct ata_host *host, | |||
821 | devres_add(gdev, legacy_dr); | 824 | devres_add(gdev, legacy_dr); |
822 | 825 | ||
823 | for (i = 0; i < 2; i++) { | 826 | for (i = 0; i < 2; i++) { |
824 | *legacy_mask &= ~(1 << i); | 827 | if (ata_port_is_dummy(host->ports[i])) |
828 | continue; | ||
829 | |||
825 | rc = ata_init_legacy_port(host->ports[i], legacy_dr); | 830 | rc = ata_init_legacy_port(host->ports[i], legacy_dr); |
826 | if (rc == 0) | 831 | if (rc == 0) |
827 | legacy_dr->mask |= 1 << i; | 832 | legacy_dr->mask |= 1 << i; |
828 | else if (rc == -EBUSY) | 833 | else { |
829 | (*was_busy)++; | 834 | if (rc == -EBUSY) |
830 | } | 835 | (*was_busy)++; |
831 | |||
832 | if (!legacy_dr->mask) | ||
833 | return -EBUSY; | ||
834 | |||
835 | for (i = 0; i < 2; i++) | ||
836 | if (!(legacy_dr->mask & (1 << i))) | ||
837 | host->ports[i]->ops = &ata_dummy_port_ops; | 836 | host->ports[i]->ops = &ata_dummy_port_ops; |
837 | } | ||
838 | } | ||
838 | 839 | ||
839 | *legacy_mask |= legacy_dr->mask; | 840 | if (!legacy_dr->mask) { |
841 | dev_printk(KERN_ERR, gdev, "no available legacy port\n"); | ||
842 | return -ENODEV; | ||
843 | } | ||
840 | 844 | ||
841 | devres_remove_group(gdev, NULL); | 845 | devres_remove_group(gdev, NULL); |
842 | return 0; | 846 | return 0; |
@@ -875,7 +879,7 @@ static int ata_request_legacy_irqs(struct ata_host *host, | |||
875 | legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); | 879 | legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); |
876 | BUG_ON(!legacy_dr); | 880 | BUG_ON(!legacy_dr); |
877 | 881 | ||
878 | for (i = 0; i < host->n_ports; i++) { | 882 | for (i = 0; i < 2; i++) { |
879 | unsigned int irq; | 883 | unsigned int irq; |
880 | 884 | ||
881 | /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ | 885 | /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ |
@@ -923,8 +927,7 @@ static int ata_request_legacy_irqs(struct ata_host *host, | |||
923 | /** | 927 | /** |
924 | * ata_pci_init_one - Initialize/register PCI IDE host controller | 928 | * ata_pci_init_one - Initialize/register PCI IDE host controller |
925 | * @pdev: Controller to be initialized | 929 | * @pdev: Controller to be initialized |
926 | * @port_info: Information from low-level host driver | 930 | * @ppi: array of port_info, must be enough for two ports |
927 | * @n_ports: Number of ports attached to host controller | ||
928 | * | 931 | * |
929 | * This is a helper function which can be called from a driver's | 932 | * This is a helper function which can be called from a driver's |
930 | * xxx_init_one() probe function if the hardware uses traditional | 933 | * xxx_init_one() probe function if the hardware uses traditional |
@@ -944,26 +947,34 @@ static int ata_request_legacy_irqs(struct ata_host *host, | |||
944 | * RETURNS: | 947 | * RETURNS: |
945 | * Zero on success, negative on errno-based value on error. | 948 | * Zero on success, negative on errno-based value on error. |
946 | */ | 949 | */ |
947 | 950 | int ata_pci_init_one(struct pci_dev *pdev, | |
948 | int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | 951 | const struct ata_port_info * const * ppi) |
949 | unsigned int n_ports) | ||
950 | { | 952 | { |
951 | struct device *dev = &pdev->dev; | 953 | struct device *dev = &pdev->dev; |
954 | const struct ata_port_info *pi = NULL; | ||
952 | struct ata_host *host = NULL; | 955 | struct ata_host *host = NULL; |
953 | const struct ata_port_info *port[2]; | ||
954 | u8 mask; | 956 | u8 mask; |
955 | unsigned int legacy_mode = 0; | 957 | int legacy_mode = 0; |
956 | int rc; | 958 | int i, rc; |
957 | 959 | ||
958 | DPRINTK("ENTER\n"); | 960 | DPRINTK("ENTER\n"); |
959 | 961 | ||
960 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) | 962 | /* look up the first valid port_info */ |
961 | return -ENOMEM; | 963 | for (i = 0; i < 2 && ppi[i]; i++) { |
964 | if (ppi[i]->port_ops != &ata_dummy_port_ops) { | ||
965 | pi = ppi[i]; | ||
966 | break; | ||
967 | } | ||
968 | } | ||
962 | 969 | ||
963 | BUG_ON(n_ports < 1 || n_ports > 2); | 970 | if (!pi) { |
971 | dev_printk(KERN_ERR, &pdev->dev, | ||
972 | "no valid port_info specified\n"); | ||
973 | return -EINVAL; | ||
974 | } | ||
964 | 975 | ||
965 | port[0] = port_info[0]; | 976 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) |
966 | port[1] = (n_ports > 1) ? port_info[1] : NULL; | 977 | return -ENOMEM; |
967 | 978 | ||
968 | /* FIXME: Really for ATA it isn't safe because the device may be | 979 | /* FIXME: Really for ATA it isn't safe because the device may be |
969 | multi-purpose and we want to leave it alone if it was already | 980 | multi-purpose and we want to leave it alone if it was already |
@@ -984,7 +995,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
984 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); | 995 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); |
985 | mask = (1 << 2) | (1 << 0); | 996 | mask = (1 << 2) | (1 << 0); |
986 | if ((tmp8 & mask) != mask) | 997 | if ((tmp8 & mask) != mask) |
987 | legacy_mode = (1 << 3); | 998 | legacy_mode = 1; |
988 | #if defined(CONFIG_NO_ATA_LEGACY) | 999 | #if defined(CONFIG_NO_ATA_LEGACY) |
989 | /* Some platforms with PCI limits cannot address compat | 1000 | /* Some platforms with PCI limits cannot address compat |
990 | port space. In that case we punt if their firmware has | 1001 | port space. In that case we punt if their firmware has |
@@ -998,7 +1009,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
998 | } | 1009 | } |
999 | 1010 | ||
1000 | /* alloc and init host */ | 1011 | /* alloc and init host */ |
1001 | host = ata_host_alloc_pinfo(dev, port, n_ports); | 1012 | host = ata_host_alloc_pinfo(dev, ppi, 2); |
1002 | if (!host) { | 1013 | if (!host) { |
1003 | dev_printk(KERN_ERR, &pdev->dev, | 1014 | dev_printk(KERN_ERR, &pdev->dev, |
1004 | "failed to allocate ATA host\n"); | 1015 | "failed to allocate ATA host\n"); |
@@ -1007,19 +1018,13 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1007 | } | 1018 | } |
1008 | 1019 | ||
1009 | if (!legacy_mode) { | 1020 | if (!legacy_mode) { |
1010 | unsigned int port_mask; | 1021 | rc = ata_pci_init_native_host(host); |
1011 | |||
1012 | port_mask = ATA_PORT_PRIMARY; | ||
1013 | if (n_ports > 1) | ||
1014 | port_mask |= ATA_PORT_SECONDARY; | ||
1015 | |||
1016 | rc = ata_pci_init_native_host(host, port_mask); | ||
1017 | if (rc) | 1022 | if (rc) |
1018 | goto err_out; | 1023 | goto err_out; |
1019 | } else { | 1024 | } else { |
1020 | int was_busy = 0; | 1025 | int was_busy = 0; |
1021 | 1026 | ||
1022 | rc = ata_init_legacy_host(host, &legacy_mode, &was_busy); | 1027 | rc = ata_init_legacy_host(host, &was_busy); |
1023 | if (was_busy) | 1028 | if (was_busy) |
1024 | pcim_pin_device(pdev); | 1029 | pcim_pin_device(pdev); |
1025 | if (rc) | 1030 | if (rc) |
@@ -1040,8 +1045,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1040 | goto err_out; | 1045 | goto err_out; |
1041 | 1046 | ||
1042 | if (!legacy_mode) | 1047 | if (!legacy_mode) |
1043 | rc = devm_request_irq(dev, pdev->irq, | 1048 | rc = devm_request_irq(dev, pdev->irq, pi->port_ops->irq_handler, |
1044 | port_info[0]->port_ops->irq_handler, | ||
1045 | IRQF_SHARED, DRV_NAME, host); | 1049 | IRQF_SHARED, DRV_NAME, host); |
1046 | else { | 1050 | else { |
1047 | irq_handler_t handler[2] = { host->ops->irq_handler, | 1051 | irq_handler_t handler[2] = { host->ops->irq_handler, |
@@ -1055,7 +1059,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1055 | goto err_out; | 1059 | goto err_out; |
1056 | 1060 | ||
1057 | /* register */ | 1061 | /* register */ |
1058 | rc = ata_host_register(host, port_info[0]->sht); | 1062 | rc = ata_host_register(host, pi->sht); |
1059 | if (rc) | 1063 | if (rc) |
1060 | goto err_out; | 1064 | goto err_out; |
1061 | 1065 | ||
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 5f4d40cd3288..8b71b73a199c 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -58,6 +58,7 @@ extern int atapi_enabled; | |||
58 | extern int atapi_dmadir; | 58 | extern int atapi_dmadir; |
59 | extern int libata_fua; | 59 | extern int libata_fua; |
60 | extern int libata_noacpi; | 60 | extern int libata_noacpi; |
61 | extern int ata_spindown_compat; | ||
61 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); | 62 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); |
62 | extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, | 63 | extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, |
63 | u64 block, u32 n_block, unsigned int tf_flags, | 64 | u64 block, u32 n_block, unsigned int tf_flags, |
@@ -96,15 +97,15 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | |||
96 | extern struct ata_port *ata_port_alloc(struct ata_host *host); | 97 | extern struct ata_port *ata_port_alloc(struct ata_host *host); |
97 | 98 | ||
98 | /* libata-acpi.c */ | 99 | /* libata-acpi.c */ |
99 | #ifdef CONFIG_SATA_ACPI | 100 | #ifdef CONFIG_ATA_ACPI |
100 | extern int ata_acpi_exec_tfs(struct ata_port *ap); | 101 | extern int ata_acpi_exec_tfs(struct ata_port *ap); |
101 | extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix); | 102 | extern int ata_acpi_push_id(struct ata_device *dev); |
102 | #else | 103 | #else |
103 | static inline int ata_acpi_exec_tfs(struct ata_port *ap) | 104 | static inline int ata_acpi_exec_tfs(struct ata_port *ap) |
104 | { | 105 | { |
105 | return 0; | 106 | return 0; |
106 | } | 107 | } |
107 | static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | 108 | static inline int ata_acpi_push_id(struct ata_device *dev) |
108 | { | 109 | { |
109 | return 0; | 110 | return 0; |
110 | } | 111 | } |
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index d40edebb510a..3c55a5ff74c7 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c | |||
@@ -291,10 +291,6 @@ static struct scsi_host_template ali_sht = { | |||
291 | .slave_configure = ata_scsi_slave_config, | 291 | .slave_configure = ata_scsi_slave_config, |
292 | .slave_destroy = ata_scsi_slave_destroy, | 292 | .slave_destroy = ata_scsi_slave_destroy, |
293 | .bios_param = ata_std_bios_param, | 293 | .bios_param = ata_std_bios_param, |
294 | #ifdef CONFIG_PM | ||
295 | .resume = ata_scsi_device_resume, | ||
296 | .suspend = ata_scsi_device_suspend, | ||
297 | #endif | ||
298 | }; | 294 | }; |
299 | 295 | ||
300 | /* | 296 | /* |
@@ -522,14 +518,14 @@ static void ali_init_chipset(struct pci_dev *pdev) | |||
522 | 518 | ||
523 | static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 519 | static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
524 | { | 520 | { |
525 | static struct ata_port_info info_early = { | 521 | static const struct ata_port_info info_early = { |
526 | .sht = &ali_sht, | 522 | .sht = &ali_sht, |
527 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 523 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
528 | .pio_mask = 0x1f, | 524 | .pio_mask = 0x1f, |
529 | .port_ops = &ali_early_port_ops | 525 | .port_ops = &ali_early_port_ops |
530 | }; | 526 | }; |
531 | /* Revision 0x20 added DMA */ | 527 | /* Revision 0x20 added DMA */ |
532 | static struct ata_port_info info_20 = { | 528 | static const struct ata_port_info info_20 = { |
533 | .sht = &ali_sht, | 529 | .sht = &ali_sht, |
534 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 530 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
535 | .pio_mask = 0x1f, | 531 | .pio_mask = 0x1f, |
@@ -537,7 +533,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
537 | .port_ops = &ali_20_port_ops | 533 | .port_ops = &ali_20_port_ops |
538 | }; | 534 | }; |
539 | /* Revision 0x20 with support logic added UDMA */ | 535 | /* Revision 0x20 with support logic added UDMA */ |
540 | static struct ata_port_info info_20_udma = { | 536 | static const struct ata_port_info info_20_udma = { |
541 | .sht = &ali_sht, | 537 | .sht = &ali_sht, |
542 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 538 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
543 | .pio_mask = 0x1f, | 539 | .pio_mask = 0x1f, |
@@ -546,7 +542,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
546 | .port_ops = &ali_20_port_ops | 542 | .port_ops = &ali_20_port_ops |
547 | }; | 543 | }; |
548 | /* Revision 0xC2 adds UDMA66 */ | 544 | /* Revision 0xC2 adds UDMA66 */ |
549 | static struct ata_port_info info_c2 = { | 545 | static const struct ata_port_info info_c2 = { |
550 | .sht = &ali_sht, | 546 | .sht = &ali_sht, |
551 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 547 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
552 | .pio_mask = 0x1f, | 548 | .pio_mask = 0x1f, |
@@ -555,7 +551,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
555 | .port_ops = &ali_c2_port_ops | 551 | .port_ops = &ali_c2_port_ops |
556 | }; | 552 | }; |
557 | /* Revision 0xC3 is UDMA100 */ | 553 | /* Revision 0xC3 is UDMA100 */ |
558 | static struct ata_port_info info_c3 = { | 554 | static const struct ata_port_info info_c3 = { |
559 | .sht = &ali_sht, | 555 | .sht = &ali_sht, |
560 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 556 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
561 | .pio_mask = 0x1f, | 557 | .pio_mask = 0x1f, |
@@ -564,7 +560,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
564 | .port_ops = &ali_c2_port_ops | 560 | .port_ops = &ali_c2_port_ops |
565 | }; | 561 | }; |
566 | /* Revision 0xC4 is UDMA133 */ | 562 | /* Revision 0xC4 is UDMA133 */ |
567 | static struct ata_port_info info_c4 = { | 563 | static const struct ata_port_info info_c4 = { |
568 | .sht = &ali_sht, | 564 | .sht = &ali_sht, |
569 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 565 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
570 | .pio_mask = 0x1f, | 566 | .pio_mask = 0x1f, |
@@ -573,7 +569,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
573 | .port_ops = &ali_c2_port_ops | 569 | .port_ops = &ali_c2_port_ops |
574 | }; | 570 | }; |
575 | /* Revision 0xC5 is UDMA133 with LBA48 DMA */ | 571 | /* Revision 0xC5 is UDMA133 with LBA48 DMA */ |
576 | static struct ata_port_info info_c5 = { | 572 | static const struct ata_port_info info_c5 = { |
577 | .sht = &ali_sht, | 573 | .sht = &ali_sht, |
578 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 574 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
579 | .pio_mask = 0x1f, | 575 | .pio_mask = 0x1f, |
@@ -582,7 +578,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
582 | .port_ops = &ali_c5_port_ops | 578 | .port_ops = &ali_c5_port_ops |
583 | }; | 579 | }; |
584 | 580 | ||
585 | static struct ata_port_info *port_info[2]; | 581 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
586 | u8 rev, tmp; | 582 | u8 rev, tmp; |
587 | struct pci_dev *isa_bridge; | 583 | struct pci_dev *isa_bridge; |
588 | 584 | ||
@@ -594,17 +590,17 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
594 | */ | 590 | */ |
595 | 591 | ||
596 | if (rev < 0x20) { | 592 | if (rev < 0x20) { |
597 | port_info[0] = port_info[1] = &info_early; | 593 | ppi[0] = &info_early; |
598 | } else if (rev < 0xC2) { | 594 | } else if (rev < 0xC2) { |
599 | port_info[0] = port_info[1] = &info_20; | 595 | ppi[0] = &info_20; |
600 | } else if (rev == 0xC2) { | 596 | } else if (rev == 0xC2) { |
601 | port_info[0] = port_info[1] = &info_c2; | 597 | ppi[0] = &info_c2; |
602 | } else if (rev == 0xC3) { | 598 | } else if (rev == 0xC3) { |
603 | port_info[0] = port_info[1] = &info_c3; | 599 | ppi[0] = &info_c3; |
604 | } else if (rev == 0xC4) { | 600 | } else if (rev == 0xC4) { |
605 | port_info[0] = port_info[1] = &info_c4; | 601 | ppi[0] = &info_c4; |
606 | } else | 602 | } else |
607 | port_info[0] = port_info[1] = &info_c5; | 603 | ppi[0] = &info_c5; |
608 | 604 | ||
609 | ali_init_chipset(pdev); | 605 | ali_init_chipset(pdev); |
610 | 606 | ||
@@ -613,10 +609,10 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
613 | /* Are we paired with a UDMA capable chip */ | 609 | /* Are we paired with a UDMA capable chip */ |
614 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); | 610 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); |
615 | if ((tmp & 0x1E) == 0x12) | 611 | if ((tmp & 0x1E) == 0x12) |
616 | port_info[0] = port_info[1] = &info_20_udma; | 612 | ppi[0] = &info_20_udma; |
617 | pci_dev_put(isa_bridge); | 613 | pci_dev_put(isa_bridge); |
618 | } | 614 | } |
619 | return ata_pci_init_one(pdev, port_info, 2); | 615 | return ata_pci_init_one(pdev, ppi); |
620 | } | 616 | } |
621 | 617 | ||
622 | #ifdef CONFIG_PM | 618 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index 67c7e87dec04..b439351f1fd3 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c | |||
@@ -324,10 +324,6 @@ static struct scsi_host_template amd_sht = { | |||
324 | .slave_configure = ata_scsi_slave_config, | 324 | .slave_configure = ata_scsi_slave_config, |
325 | .slave_destroy = ata_scsi_slave_destroy, | 325 | .slave_destroy = ata_scsi_slave_destroy, |
326 | .bios_param = ata_std_bios_param, | 326 | .bios_param = ata_std_bios_param, |
327 | #ifdef CONFIG_PM | ||
328 | .resume = ata_scsi_device_resume, | ||
329 | .suspend = ata_scsi_device_suspend, | ||
330 | #endif | ||
331 | }; | 327 | }; |
332 | 328 | ||
333 | static struct ata_port_operations amd33_port_ops = { | 329 | static struct ata_port_operations amd33_port_ops = { |
@@ -542,7 +538,7 @@ static struct ata_port_operations nv133_port_ops = { | |||
542 | 538 | ||
543 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 539 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
544 | { | 540 | { |
545 | static struct ata_port_info info[10] = { | 541 | static const struct ata_port_info info[10] = { |
546 | { /* 0: AMD 7401 */ | 542 | { /* 0: AMD 7401 */ |
547 | .sht = &amd_sht, | 543 | .sht = &amd_sht, |
548 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 544 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -624,7 +620,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
624 | .port_ops = &amd100_port_ops | 620 | .port_ops = &amd100_port_ops |
625 | } | 621 | } |
626 | }; | 622 | }; |
627 | static struct ata_port_info *port_info[2]; | 623 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
628 | static int printed_version; | 624 | static int printed_version; |
629 | int type = id->driver_data; | 625 | int type = id->driver_data; |
630 | u8 rev; | 626 | u8 rev; |
@@ -656,9 +652,8 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
656 | ata_pci_clear_simplex(pdev); | 652 | ata_pci_clear_simplex(pdev); |
657 | 653 | ||
658 | /* And fire it up */ | 654 | /* And fire it up */ |
659 | 655 | ppi[0] = &info[type]; | |
660 | port_info[0] = port_info[1] = &info[type]; | 656 | return ata_pci_init_one(pdev, ppi); |
661 | return ata_pci_init_one(pdev, port_info, 2); | ||
662 | } | 657 | } |
663 | 658 | ||
664 | #ifdef CONFIG_PM | 659 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c index ef51940c3adb..9861059dd673 100644 --- a/drivers/ata/pata_artop.c +++ b/drivers/ata/pata_artop.c | |||
@@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = { | |||
414 | static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | 414 | static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) |
415 | { | 415 | { |
416 | static int printed_version; | 416 | static int printed_version; |
417 | static struct ata_port_info info_6210 = { | 417 | static const struct ata_port_info info_6210 = { |
418 | .sht = &artop_sht, | 418 | .sht = &artop_sht, |
419 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 419 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
420 | .pio_mask = 0x1f, /* pio0-4 */ | 420 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
422 | .udma_mask = ATA_UDMA2, | 422 | .udma_mask = ATA_UDMA2, |
423 | .port_ops = &artop6210_ops, | 423 | .port_ops = &artop6210_ops, |
424 | }; | 424 | }; |
425 | static struct ata_port_info info_626x = { | 425 | static const struct ata_port_info info_626x = { |
426 | .sht = &artop_sht, | 426 | .sht = &artop_sht, |
427 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 427 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
428 | .pio_mask = 0x1f, /* pio0-4 */ | 428 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
430 | .udma_mask = ATA_UDMA4, | 430 | .udma_mask = ATA_UDMA4, |
431 | .port_ops = &artop6260_ops, | 431 | .port_ops = &artop6260_ops, |
432 | }; | 432 | }; |
433 | static struct ata_port_info info_626x_fast = { | 433 | static const struct ata_port_info info_626x_fast = { |
434 | .sht = &artop_sht, | 434 | .sht = &artop_sht, |
435 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 435 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
436 | .pio_mask = 0x1f, /* pio0-4 */ | 436 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -438,32 +438,30 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
438 | .udma_mask = ATA_UDMA5, | 438 | .udma_mask = ATA_UDMA5, |
439 | .port_ops = &artop6260_ops, | 439 | .port_ops = &artop6260_ops, |
440 | }; | 440 | }; |
441 | struct ata_port_info *port_info[2]; | 441 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
442 | struct ata_port_info *info = NULL; | ||
443 | int ports = 2; | ||
444 | 442 | ||
445 | if (!printed_version++) | 443 | if (!printed_version++) |
446 | dev_printk(KERN_DEBUG, &pdev->dev, | 444 | dev_printk(KERN_DEBUG, &pdev->dev, |
447 | "version " DRV_VERSION "\n"); | 445 | "version " DRV_VERSION "\n"); |
448 | 446 | ||
449 | if (id->driver_data == 0) { /* 6210 variant */ | 447 | if (id->driver_data == 0) { /* 6210 variant */ |
450 | info = &info_6210; | 448 | ppi[0] = &info_6210; |
449 | ppi[1] = &ata_dummy_port_info; | ||
451 | /* BIOS may have left us in UDMA, clear it before libata probe */ | 450 | /* BIOS may have left us in UDMA, clear it before libata probe */ |
452 | pci_write_config_byte(pdev, 0x54, 0); | 451 | pci_write_config_byte(pdev, 0x54, 0); |
453 | /* For the moment (also lacks dsc) */ | 452 | /* For the moment (also lacks dsc) */ |
454 | printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); | 453 | printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); |
455 | printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); | 454 | printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); |
456 | ports = 1; | ||
457 | } | 455 | } |
458 | else if (id->driver_data == 1) /* 6260 */ | 456 | else if (id->driver_data == 1) /* 6260 */ |
459 | info = &info_626x; | 457 | ppi[0] = &info_626x; |
460 | else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ | 458 | else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ |
461 | unsigned long io = pci_resource_start(pdev, 4); | 459 | unsigned long io = pci_resource_start(pdev, 4); |
462 | u8 reg; | 460 | u8 reg; |
463 | 461 | ||
464 | info = &info_626x; | 462 | ppi[0] = &info_626x; |
465 | if (inb(io) & 0x10) | 463 | if (inb(io) & 0x10) |
466 | info = &info_626x_fast; | 464 | ppi[0] = &info_626x_fast; |
467 | /* Mac systems come up with some registers not set as we | 465 | /* Mac systems come up with some registers not set as we |
468 | will need them */ | 466 | will need them */ |
469 | 467 | ||
@@ -484,10 +482,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
484 | 482 | ||
485 | } | 483 | } |
486 | 484 | ||
487 | BUG_ON(info == NULL); | 485 | BUG_ON(ppi[0] == NULL); |
488 | 486 | ||
489 | port_info[0] = port_info[1] = info; | 487 | return ata_pci_init_one(pdev, ppi); |
490 | return ata_pci_init_one(pdev, port_info, ports); | ||
491 | } | 488 | } |
492 | 489 | ||
493 | static const struct pci_device_id artop_pci_tbl[] = { | 490 | static const struct pci_device_id artop_pci_tbl[] = { |
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c index 21515381b5b3..844914681a2a 100644 --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c | |||
@@ -229,10 +229,6 @@ static struct scsi_host_template atiixp_sht = { | |||
229 | .slave_configure = ata_scsi_slave_config, | 229 | .slave_configure = ata_scsi_slave_config, |
230 | .slave_destroy = ata_scsi_slave_destroy, | 230 | .slave_destroy = ata_scsi_slave_destroy, |
231 | .bios_param = ata_std_bios_param, | 231 | .bios_param = ata_std_bios_param, |
232 | #ifdef CONFIG_PM | ||
233 | .resume = ata_scsi_device_resume, | ||
234 | .suspend = ata_scsi_device_suspend, | ||
235 | #endif | ||
236 | }; | 232 | }; |
237 | 233 | ||
238 | static struct ata_port_operations atiixp_port_ops = { | 234 | static struct ata_port_operations atiixp_port_ops = { |
@@ -272,7 +268,7 @@ static struct ata_port_operations atiixp_port_ops = { | |||
272 | 268 | ||
273 | static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 269 | static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
274 | { | 270 | { |
275 | static struct ata_port_info info = { | 271 | static const struct ata_port_info info = { |
276 | .sht = &atiixp_sht, | 272 | .sht = &atiixp_sht, |
277 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 273 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
278 | .pio_mask = 0x1f, | 274 | .pio_mask = 0x1f, |
@@ -280,8 +276,8 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
280 | .udma_mask = 0x3F, | 276 | .udma_mask = 0x3F, |
281 | .port_ops = &atiixp_port_ops | 277 | .port_ops = &atiixp_port_ops |
282 | }; | 278 | }; |
283 | static struct ata_port_info *port_info[2] = { &info, &info }; | 279 | const struct ata_port_info *ppi[] = { &info, NULL }; |
284 | return ata_pci_init_one(dev, port_info, 2); | 280 | return ata_pci_init_one(dev, ppi); |
285 | } | 281 | } |
286 | 282 | ||
287 | static const struct pci_device_id atiixp[] = { | 283 | static const struct pci_device_id atiixp[] = { |
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c index 2105985a8013..ed00fa9d53be 100644 --- a/drivers/ata/pata_cmd640.c +++ b/drivers/ata/pata_cmd640.c | |||
@@ -181,10 +181,6 @@ static struct scsi_host_template cmd640_sht = { | |||
181 | .slave_configure = ata_scsi_slave_config, | 181 | .slave_configure = ata_scsi_slave_config, |
182 | .slave_destroy = ata_scsi_slave_destroy, | 182 | .slave_destroy = ata_scsi_slave_destroy, |
183 | .bios_param = ata_std_bios_param, | 183 | .bios_param = ata_std_bios_param, |
184 | #ifdef CONFIG_PM | ||
185 | .resume = ata_scsi_device_resume, | ||
186 | .suspend = ata_scsi_device_suspend, | ||
187 | #endif | ||
188 | }; | 184 | }; |
189 | 185 | ||
190 | static struct ata_port_operations cmd640_port_ops = { | 186 | static struct ata_port_operations cmd640_port_ops = { |
@@ -253,17 +249,16 @@ static void cmd640_hardware_init(struct pci_dev *pdev) | |||
253 | 249 | ||
254 | static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 250 | static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
255 | { | 251 | { |
256 | static struct ata_port_info info = { | 252 | static const struct ata_port_info info = { |
257 | .sht = &cmd640_sht, | 253 | .sht = &cmd640_sht, |
258 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 254 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
259 | .pio_mask = 0x1f, | 255 | .pio_mask = 0x1f, |
260 | .port_ops = &cmd640_port_ops | 256 | .port_ops = &cmd640_port_ops |
261 | }; | 257 | }; |
262 | 258 | const struct ata_port_info *ppi[] = { &info, NULL }; | |
263 | static struct ata_port_info *port_info[2] = { &info, &info }; | ||
264 | 259 | ||
265 | cmd640_hardware_init(pdev); | 260 | cmd640_hardware_init(pdev); |
266 | return ata_pci_init_one(pdev, port_info, 2); | 261 | return ata_pci_init_one(pdev, ppi); |
267 | } | 262 | } |
268 | 263 | ||
269 | static int cmd640_reinit_one(struct pci_dev *pdev) | 264 | static int cmd640_reinit_one(struct pci_dev *pdev) |
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c index 3989cc577fcd..2a79b335cfcc 100644 --- a/drivers/ata/pata_cmd64x.c +++ b/drivers/ata/pata_cmd64x.c | |||
@@ -266,10 +266,6 @@ static struct scsi_host_template cmd64x_sht = { | |||
266 | .slave_configure = ata_scsi_slave_config, | 266 | .slave_configure = ata_scsi_slave_config, |
267 | .slave_destroy = ata_scsi_slave_destroy, | 267 | .slave_destroy = ata_scsi_slave_destroy, |
268 | .bios_param = ata_std_bios_param, | 268 | .bios_param = ata_std_bios_param, |
269 | #ifdef CONFIG_PM | ||
270 | .resume = ata_scsi_device_resume, | ||
271 | .suspend = ata_scsi_device_suspend, | ||
272 | #endif | ||
273 | }; | 269 | }; |
274 | 270 | ||
275 | static struct ata_port_operations cmd64x_port_ops = { | 271 | static struct ata_port_operations cmd64x_port_ops = { |
@@ -381,7 +377,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
381 | { | 377 | { |
382 | u32 class_rev; | 378 | u32 class_rev; |
383 | 379 | ||
384 | static struct ata_port_info cmd_info[6] = { | 380 | static const struct ata_port_info cmd_info[6] = { |
385 | { /* CMD 643 - no UDMA */ | 381 | { /* CMD 643 - no UDMA */ |
386 | .sht = &cmd64x_sht, | 382 | .sht = &cmd64x_sht, |
387 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 383 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -428,11 +424,9 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
428 | .port_ops = &cmd648_port_ops | 424 | .port_ops = &cmd648_port_ops |
429 | } | 425 | } |
430 | }; | 426 | }; |
431 | static struct ata_port_info *port_info[2], *info; | 427 | const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL }; |
432 | u8 mrdmode; | 428 | u8 mrdmode; |
433 | 429 | ||
434 | info = &cmd_info[id->driver_data]; | ||
435 | |||
436 | pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); | 430 | pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); |
437 | class_rev &= 0xFF; | 431 | class_rev &= 0xFF; |
438 | 432 | ||
@@ -442,10 +436,10 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
442 | if (pdev->device == PCI_DEVICE_ID_CMD_646) { | 436 | if (pdev->device == PCI_DEVICE_ID_CMD_646) { |
443 | /* Does UDMA work ? */ | 437 | /* Does UDMA work ? */ |
444 | if (class_rev > 4) | 438 | if (class_rev > 4) |
445 | info = &cmd_info[2]; | 439 | ppi[0] = &cmd_info[2]; |
446 | /* Early rev with other problems ? */ | 440 | /* Early rev with other problems ? */ |
447 | else if (class_rev == 1) | 441 | else if (class_rev == 1) |
448 | info = &cmd_info[3]; | 442 | ppi[0] = &cmd_info[3]; |
449 | } | 443 | } |
450 | 444 | ||
451 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); | 445 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); |
@@ -461,8 +455,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
461 | pci_write_config_byte(pdev, UDIDETCR0, 0xF0); | 455 | pci_write_config_byte(pdev, UDIDETCR0, 0xF0); |
462 | #endif | 456 | #endif |
463 | 457 | ||
464 | port_info[0] = port_info[1] = info; | 458 | return ata_pci_init_one(pdev, ppi); |
465 | return ata_pci_init_one(pdev, port_info, 2); | ||
466 | } | 459 | } |
467 | 460 | ||
468 | #ifdef CONFIG_PM | 461 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c index 79bef0d1fad3..83bcc5b32597 100644 --- a/drivers/ata/pata_cs5520.c +++ b/drivers/ata/pata_cs5520.c | |||
@@ -155,10 +155,6 @@ static struct scsi_host_template cs5520_sht = { | |||
155 | .slave_configure = ata_scsi_slave_config, | 155 | .slave_configure = ata_scsi_slave_config, |
156 | .slave_destroy = ata_scsi_slave_destroy, | 156 | .slave_destroy = ata_scsi_slave_destroy, |
157 | .bios_param = ata_std_bios_param, | 157 | .bios_param = ata_std_bios_param, |
158 | #ifdef CONFIG_PM | ||
159 | .resume = ata_scsi_device_resume, | ||
160 | .suspend = ata_scsi_device_suspend, | ||
161 | #endif | ||
162 | }; | 158 | }; |
163 | 159 | ||
164 | static struct ata_port_operations cs5520_port_ops = { | 160 | static struct ata_port_operations cs5520_port_ops = { |
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 29642d5ee189..1b67923d7a4e 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c | |||
@@ -176,10 +176,6 @@ static struct scsi_host_template cs5530_sht = { | |||
176 | .slave_configure = ata_scsi_slave_config, | 176 | .slave_configure = ata_scsi_slave_config, |
177 | .slave_destroy = ata_scsi_slave_destroy, | 177 | .slave_destroy = ata_scsi_slave_destroy, |
178 | .bios_param = ata_std_bios_param, | 178 | .bios_param = ata_std_bios_param, |
179 | #ifdef CONFIG_PM | ||
180 | .resume = ata_scsi_device_resume, | ||
181 | .suspend = ata_scsi_device_suspend, | ||
182 | #endif | ||
183 | }; | 179 | }; |
184 | 180 | ||
185 | static struct ata_port_operations cs5530_port_ops = { | 181 | static struct ata_port_operations cs5530_port_ops = { |
@@ -339,7 +335,7 @@ fail_put: | |||
339 | 335 | ||
340 | static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 336 | static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
341 | { | 337 | { |
342 | static struct ata_port_info info = { | 338 | static const struct ata_port_info info = { |
343 | .sht = &cs5530_sht, | 339 | .sht = &cs5530_sht, |
344 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 340 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
345 | .pio_mask = 0x1f, | 341 | .pio_mask = 0x1f, |
@@ -348,23 +344,23 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
348 | .port_ops = &cs5530_port_ops | 344 | .port_ops = &cs5530_port_ops |
349 | }; | 345 | }; |
350 | /* The docking connector doesn't do UDMA, and it seems not MWDMA */ | 346 | /* The docking connector doesn't do UDMA, and it seems not MWDMA */ |
351 | static struct ata_port_info info_palmax_secondary = { | 347 | static const struct ata_port_info info_palmax_secondary = { |
352 | .sht = &cs5530_sht, | 348 | .sht = &cs5530_sht, |
353 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 349 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
354 | .pio_mask = 0x1f, | 350 | .pio_mask = 0x1f, |
355 | .port_ops = &cs5530_port_ops | 351 | .port_ops = &cs5530_port_ops |
356 | }; | 352 | }; |
357 | static struct ata_port_info *port_info[2] = { &info, &info }; | 353 | const struct ata_port_info *ppi[] = { &info, NULL }; |
358 | 354 | ||
359 | /* Chip initialisation */ | 355 | /* Chip initialisation */ |
360 | if (cs5530_init_chip()) | 356 | if (cs5530_init_chip()) |
361 | return -ENODEV; | 357 | return -ENODEV; |
362 | 358 | ||
363 | if (cs5530_is_palmax()) | 359 | if (cs5530_is_palmax()) |
364 | port_info[1] = &info_palmax_secondary; | 360 | ppi[1] = &info_palmax_secondary; |
365 | 361 | ||
366 | /* Now kick off ATA set up */ | 362 | /* Now kick off ATA set up */ |
367 | return ata_pci_init_one(pdev, port_info, 2); | 363 | return ata_pci_init_one(pdev, ppi); |
368 | } | 364 | } |
369 | 365 | ||
370 | #ifdef CONFIG_PM | 366 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c index 22006ae71941..f37d4cd812a1 100644 --- a/drivers/ata/pata_cs5535.c +++ b/drivers/ata/pata_cs5535.c | |||
@@ -173,10 +173,6 @@ static struct scsi_host_template cs5535_sht = { | |||
173 | .slave_configure = ata_scsi_slave_config, | 173 | .slave_configure = ata_scsi_slave_config, |
174 | .slave_destroy = ata_scsi_slave_destroy, | 174 | .slave_destroy = ata_scsi_slave_destroy, |
175 | .bios_param = ata_std_bios_param, | 175 | .bios_param = ata_std_bios_param, |
176 | #ifdef CONFIG_PM | ||
177 | .resume = ata_scsi_device_resume, | ||
178 | .suspend = ata_scsi_device_suspend, | ||
179 | #endif | ||
180 | }; | 176 | }; |
181 | 177 | ||
182 | static struct ata_port_operations cs5535_port_ops = { | 178 | static struct ata_port_operations cs5535_port_ops = { |
@@ -227,7 +223,7 @@ static struct ata_port_operations cs5535_port_ops = { | |||
227 | 223 | ||
228 | static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 224 | static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
229 | { | 225 | { |
230 | static struct ata_port_info info = { | 226 | static const struct ata_port_info info = { |
231 | .sht = &cs5535_sht, | 227 | .sht = &cs5535_sht, |
232 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 228 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
233 | .pio_mask = 0x1f, | 229 | .pio_mask = 0x1f, |
@@ -235,7 +231,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
235 | .udma_mask = 0x1f, | 231 | .udma_mask = 0x1f, |
236 | .port_ops = &cs5535_port_ops | 232 | .port_ops = &cs5535_port_ops |
237 | }; | 233 | }; |
238 | struct ata_port_info *ports[1] = { &info }; | 234 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; |
239 | 235 | ||
240 | u32 timings, dummy; | 236 | u32 timings, dummy; |
241 | 237 | ||
@@ -247,7 +243,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
247 | rdmsr(ATAC_CH0D1_PIO, timings, dummy); | 243 | rdmsr(ATAC_CH0D1_PIO, timings, dummy); |
248 | if (CS5535_BAD_PIO(timings)) | 244 | if (CS5535_BAD_PIO(timings)) |
249 | wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); | 245 | wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); |
250 | return ata_pci_init_one(dev, ports, 1); | 246 | return ata_pci_init_one(dev, ppi); |
251 | } | 247 | } |
252 | 248 | ||
253 | static const struct pci_device_id cs5535[] = { | 249 | static const struct pci_device_id cs5535[] = { |
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c index 6ec049c3b1dc..27b9f29c01e3 100644 --- a/drivers/ata/pata_cypress.c +++ b/drivers/ata/pata_cypress.c | |||
@@ -125,10 +125,6 @@ static struct scsi_host_template cy82c693_sht = { | |||
125 | .slave_configure = ata_scsi_slave_config, | 125 | .slave_configure = ata_scsi_slave_config, |
126 | .slave_destroy = ata_scsi_slave_destroy, | 126 | .slave_destroy = ata_scsi_slave_destroy, |
127 | .bios_param = ata_std_bios_param, | 127 | .bios_param = ata_std_bios_param, |
128 | #ifdef CONFIG_PM | ||
129 | .resume = ata_scsi_device_resume, | ||
130 | .suspend = ata_scsi_device_suspend, | ||
131 | #endif | ||
132 | }; | 128 | }; |
133 | 129 | ||
134 | static struct ata_port_operations cy82c693_port_ops = { | 130 | static struct ata_port_operations cy82c693_port_ops = { |
@@ -169,14 +165,14 @@ static struct ata_port_operations cy82c693_port_ops = { | |||
169 | 165 | ||
170 | static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 166 | static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
171 | { | 167 | { |
172 | static struct ata_port_info info = { | 168 | static const struct ata_port_info info = { |
173 | .sht = &cy82c693_sht, | 169 | .sht = &cy82c693_sht, |
174 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 170 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
175 | .pio_mask = 0x1f, | 171 | .pio_mask = 0x1f, |
176 | .mwdma_mask = 0x07, | 172 | .mwdma_mask = 0x07, |
177 | .port_ops = &cy82c693_port_ops | 173 | .port_ops = &cy82c693_port_ops |
178 | }; | 174 | }; |
179 | static struct ata_port_info *port_info[1] = { &info }; | 175 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; |
180 | 176 | ||
181 | /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. | 177 | /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. |
182 | For the moment we don't handle the secondary. FIXME */ | 178 | For the moment we don't handle the secondary. FIXME */ |
@@ -184,7 +180,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i | |||
184 | if (PCI_FUNC(pdev->devfn) != 1) | 180 | if (PCI_FUNC(pdev->devfn) != 1) |
185 | return -ENODEV; | 181 | return -ENODEV; |
186 | 182 | ||
187 | return ata_pci_init_one(pdev, port_info, 1); | 183 | return ata_pci_init_one(pdev, ppi); |
188 | } | 184 | } |
189 | 185 | ||
190 | static const struct pci_device_id cy82c693[] = { | 186 | static const struct pci_device_id cy82c693[] = { |
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c index d0f52e034906..079248a9b460 100644 --- a/drivers/ata/pata_efar.c +++ b/drivers/ata/pata_efar.c | |||
@@ -247,10 +247,6 @@ static struct scsi_host_template efar_sht = { | |||
247 | .slave_configure = ata_scsi_slave_config, | 247 | .slave_configure = ata_scsi_slave_config, |
248 | .slave_destroy = ata_scsi_slave_destroy, | 248 | .slave_destroy = ata_scsi_slave_destroy, |
249 | .bios_param = ata_std_bios_param, | 249 | .bios_param = ata_std_bios_param, |
250 | #ifdef CONFIG_PM | ||
251 | .resume = ata_scsi_device_resume, | ||
252 | .suspend = ata_scsi_device_suspend, | ||
253 | #endif | ||
254 | }; | 250 | }; |
255 | 251 | ||
256 | static const struct ata_port_operations efar_ops = { | 252 | static const struct ata_port_operations efar_ops = { |
@@ -305,7 +301,7 @@ static const struct ata_port_operations efar_ops = { | |||
305 | static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 301 | static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
306 | { | 302 | { |
307 | static int printed_version; | 303 | static int printed_version; |
308 | static struct ata_port_info info = { | 304 | static const struct ata_port_info info = { |
309 | .sht = &efar_sht, | 305 | .sht = &efar_sht, |
310 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 306 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
311 | .pio_mask = 0x1f, /* pio0-4 */ | 307 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -313,13 +309,13 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
313 | .udma_mask = 0x0f, /* UDMA 66 */ | 309 | .udma_mask = 0x0f, /* UDMA 66 */ |
314 | .port_ops = &efar_ops, | 310 | .port_ops = &efar_ops, |
315 | }; | 311 | }; |
316 | static struct ata_port_info *port_info[2] = { &info, &info }; | 312 | const struct ata_port_info *ppi[] = { &info, NULL }; |
317 | 313 | ||
318 | if (!printed_version++) | 314 | if (!printed_version++) |
319 | dev_printk(KERN_DEBUG, &pdev->dev, | 315 | dev_printk(KERN_DEBUG, &pdev->dev, |
320 | "version " DRV_VERSION "\n"); | 316 | "version " DRV_VERSION "\n"); |
321 | 317 | ||
322 | return ata_pci_init_one(pdev, port_info, 2); | 318 | return ata_pci_init_one(pdev, ppi); |
323 | } | 319 | } |
324 | 320 | ||
325 | static const struct pci_device_id efar_pci_tbl[] = { | 321 | static const struct pci_device_id efar_pci_tbl[] = { |
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index e64e05e5c7fe..c6c8a8bb06d0 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c | |||
@@ -331,10 +331,6 @@ static struct scsi_host_template hpt36x_sht = { | |||
331 | .slave_configure = ata_scsi_slave_config, | 331 | .slave_configure = ata_scsi_slave_config, |
332 | .slave_destroy = ata_scsi_slave_destroy, | 332 | .slave_destroy = ata_scsi_slave_destroy, |
333 | .bios_param = ata_std_bios_param, | 333 | .bios_param = ata_std_bios_param, |
334 | #ifdef CONFIG_PM | ||
335 | .resume = ata_scsi_device_resume, | ||
336 | .suspend = ata_scsi_device_suspend, | ||
337 | #endif | ||
338 | }; | 334 | }; |
339 | 335 | ||
340 | /* | 336 | /* |
@@ -421,7 +417,7 @@ static void hpt36x_init_chipset(struct pci_dev *dev) | |||
421 | 417 | ||
422 | static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 418 | static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
423 | { | 419 | { |
424 | static struct ata_port_info info_hpt366 = { | 420 | static const struct ata_port_info info_hpt366 = { |
425 | .sht = &hpt36x_sht, | 421 | .sht = &hpt36x_sht, |
426 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 422 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
427 | .pio_mask = 0x1f, | 423 | .pio_mask = 0x1f, |
@@ -429,7 +425,8 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
429 | .udma_mask = 0x1f, | 425 | .udma_mask = 0x1f, |
430 | .port_ops = &hpt366_port_ops | 426 | .port_ops = &hpt366_port_ops |
431 | }; | 427 | }; |
432 | struct ata_port_info *port_info[2] = {&info_hpt366, &info_hpt366}; | 428 | struct ata_port_info info = info_hpt366; |
429 | const struct ata_port_info *ppi[] = { &info, NULL }; | ||
433 | 430 | ||
434 | u32 class_rev; | 431 | u32 class_rev; |
435 | u32 reg1; | 432 | u32 reg1; |
@@ -450,17 +447,17 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
450 | /* info_hpt366 is safe against re-entry so we can scribble on it */ | 447 | /* info_hpt366 is safe against re-entry so we can scribble on it */ |
451 | switch((reg1 & 0x700) >> 8) { | 448 | switch((reg1 & 0x700) >> 8) { |
452 | case 5: | 449 | case 5: |
453 | info_hpt366.private_data = &hpt366_40; | 450 | info.private_data = &hpt366_40; |
454 | break; | 451 | break; |
455 | case 9: | 452 | case 9: |
456 | info_hpt366.private_data = &hpt366_25; | 453 | info.private_data = &hpt366_25; |
457 | break; | 454 | break; |
458 | default: | 455 | default: |
459 | info_hpt366.private_data = &hpt366_33; | 456 | info.private_data = &hpt366_33; |
460 | break; | 457 | break; |
461 | } | 458 | } |
462 | /* Now kick off ATA set up */ | 459 | /* Now kick off ATA set up */ |
463 | return ata_pci_init_one(dev, port_info, 2); | 460 | return ata_pci_init_one(dev, ppi); |
464 | } | 461 | } |
465 | 462 | ||
466 | #ifdef CONFIG_PM | 463 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 1614e8c822a4..5a0a410654e2 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -887,7 +887,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev) | |||
887 | static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 887 | static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
888 | { | 888 | { |
889 | /* HPT370 - UDMA100 */ | 889 | /* HPT370 - UDMA100 */ |
890 | static struct ata_port_info info_hpt370 = { | 890 | static const struct ata_port_info info_hpt370 = { |
891 | .sht = &hpt37x_sht, | 891 | .sht = &hpt37x_sht, |
892 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 892 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
893 | .pio_mask = 0x1f, | 893 | .pio_mask = 0x1f, |
@@ -896,7 +896,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
896 | .port_ops = &hpt370_port_ops | 896 | .port_ops = &hpt370_port_ops |
897 | }; | 897 | }; |
898 | /* HPT370A - UDMA100 */ | 898 | /* HPT370A - UDMA100 */ |
899 | static struct ata_port_info info_hpt370a = { | 899 | static const struct ata_port_info info_hpt370a = { |
900 | .sht = &hpt37x_sht, | 900 | .sht = &hpt37x_sht, |
901 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 901 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
902 | .pio_mask = 0x1f, | 902 | .pio_mask = 0x1f, |
@@ -905,7 +905,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
905 | .port_ops = &hpt370a_port_ops | 905 | .port_ops = &hpt370a_port_ops |
906 | }; | 906 | }; |
907 | /* HPT370 - UDMA100 */ | 907 | /* HPT370 - UDMA100 */ |
908 | static struct ata_port_info info_hpt370_33 = { | 908 | static const struct ata_port_info info_hpt370_33 = { |
909 | .sht = &hpt37x_sht, | 909 | .sht = &hpt37x_sht, |
910 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 910 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
911 | .pio_mask = 0x1f, | 911 | .pio_mask = 0x1f, |
@@ -914,7 +914,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
914 | .port_ops = &hpt370_port_ops | 914 | .port_ops = &hpt370_port_ops |
915 | }; | 915 | }; |
916 | /* HPT370A - UDMA100 */ | 916 | /* HPT370A - UDMA100 */ |
917 | static struct ata_port_info info_hpt370a_33 = { | 917 | static const struct ata_port_info info_hpt370a_33 = { |
918 | .sht = &hpt37x_sht, | 918 | .sht = &hpt37x_sht, |
919 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 919 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
920 | .pio_mask = 0x1f, | 920 | .pio_mask = 0x1f, |
@@ -923,7 +923,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
923 | .port_ops = &hpt370a_port_ops | 923 | .port_ops = &hpt370a_port_ops |
924 | }; | 924 | }; |
925 | /* HPT371, 372 and friends - UDMA133 */ | 925 | /* HPT371, 372 and friends - UDMA133 */ |
926 | static struct ata_port_info info_hpt372 = { | 926 | static const struct ata_port_info info_hpt372 = { |
927 | .sht = &hpt37x_sht, | 927 | .sht = &hpt37x_sht, |
928 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 928 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
929 | .pio_mask = 0x1f, | 929 | .pio_mask = 0x1f, |
@@ -932,7 +932,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
932 | .port_ops = &hpt372_port_ops | 932 | .port_ops = &hpt372_port_ops |
933 | }; | 933 | }; |
934 | /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ | 934 | /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ |
935 | static struct ata_port_info info_hpt372_50 = { | 935 | static const struct ata_port_info info_hpt372_50 = { |
936 | .sht = &hpt37x_sht, | 936 | .sht = &hpt37x_sht, |
937 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 937 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
938 | .pio_mask = 0x1f, | 938 | .pio_mask = 0x1f, |
@@ -941,7 +941,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
941 | .port_ops = &hpt372_port_ops | 941 | .port_ops = &hpt372_port_ops |
942 | }; | 942 | }; |
943 | /* HPT374 - UDMA133 */ | 943 | /* HPT374 - UDMA133 */ |
944 | static struct ata_port_info info_hpt374 = { | 944 | static const struct ata_port_info info_hpt374 = { |
945 | .sht = &hpt37x_sht, | 945 | .sht = &hpt37x_sht, |
946 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 946 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
947 | .pio_mask = 0x1f, | 947 | .pio_mask = 0x1f, |
@@ -951,9 +951,10 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
951 | }; | 951 | }; |
952 | 952 | ||
953 | static const int MHz[4] = { 33, 40, 50, 66 }; | 953 | static const int MHz[4] = { 33, 40, 50, 66 }; |
954 | 954 | const struct ata_port_info *port; | |
955 | struct ata_port_info *port_info[2]; | 955 | void *private_data = NULL; |
956 | struct ata_port_info *port; | 956 | struct ata_port_info port_info; |
957 | const struct ata_port_info *ppi[] = { &port_info, NULL }; | ||
957 | 958 | ||
958 | u8 irqmask; | 959 | u8 irqmask; |
959 | u32 class_rev; | 960 | u32 class_rev; |
@@ -1124,13 +1125,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1124 | return -ENODEV; | 1125 | return -ENODEV; |
1125 | } | 1126 | } |
1126 | if (clock_slot == 3) | 1127 | if (clock_slot == 3) |
1127 | port->private_data = (void *)hpt37x_timings_66; | 1128 | private_data = (void *)hpt37x_timings_66; |
1128 | else | 1129 | else |
1129 | port->private_data = (void *)hpt37x_timings_50; | 1130 | private_data = (void *)hpt37x_timings_50; |
1130 | 1131 | ||
1131 | printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); | 1132 | printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); |
1132 | } else { | 1133 | } else { |
1133 | port->private_data = (void *)chip_table->clocks[clock_slot]; | 1134 | private_data = (void *)chip_table->clocks[clock_slot]; |
1134 | /* | 1135 | /* |
1135 | * Perform a final fixup. Note that we will have used the | 1136 | * Perform a final fixup. Note that we will have used the |
1136 | * DPLL on the HPT372 which means we don't have to worry | 1137 | * DPLL on the HPT372 which means we don't have to worry |
@@ -1144,9 +1145,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1144 | printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); | 1145 | printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); |
1145 | } | 1146 | } |
1146 | 1147 | ||
1147 | port_info[0] = port_info[1] = port; | ||
1148 | /* Now kick off ATA set up */ | 1148 | /* Now kick off ATA set up */ |
1149 | return ata_pci_init_one(dev, port_info, 2); | 1149 | port_info = *port; |
1150 | port_info.private_data = private_data; | ||
1151 | |||
1152 | return ata_pci_init_one(dev, ppi); | ||
1150 | } | 1153 | } |
1151 | 1154 | ||
1152 | static const struct pci_device_id hpt37x[] = { | 1155 | static const struct pci_device_id hpt37x[] = { |
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c index ea1037d67860..f25154aed75d 100644 --- a/drivers/ata/pata_hpt3x2n.c +++ b/drivers/ata/pata_hpt3x2n.c | |||
@@ -488,7 +488,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev) | |||
488 | static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 488 | static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
489 | { | 489 | { |
490 | /* HPT372N and friends - UDMA133 */ | 490 | /* HPT372N and friends - UDMA133 */ |
491 | static struct ata_port_info info = { | 491 | static const struct ata_port_info info = { |
492 | .sht = &hpt3x2n_sht, | 492 | .sht = &hpt3x2n_sht, |
493 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 493 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
494 | .pio_mask = 0x1f, | 494 | .pio_mask = 0x1f, |
@@ -496,8 +496,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
496 | .udma_mask = 0x7f, | 496 | .udma_mask = 0x7f, |
497 | .port_ops = &hpt3x2n_port_ops | 497 | .port_ops = &hpt3x2n_port_ops |
498 | }; | 498 | }; |
499 | struct ata_port_info *port_info[2]; | 499 | struct ata_port_info port = info; |
500 | struct ata_port_info *port = &info; | 500 | const struct ata_port_info *ppi[] = { &port, NULL }; |
501 | 501 | ||
502 | u8 irqmask; | 502 | u8 irqmask; |
503 | u32 class_rev; | 503 | u32 class_rev; |
@@ -585,9 +585,9 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
585 | 585 | ||
586 | /* Set our private data up. We only need a few flags so we use | 586 | /* Set our private data up. We only need a few flags so we use |
587 | it directly */ | 587 | it directly */ |
588 | port->private_data = NULL; | 588 | port.private_data = NULL; |
589 | if (pci_mhz > 60) { | 589 | if (pci_mhz > 60) { |
590 | port->private_data = (void *)PCI66; | 590 | port.private_data = (void *)PCI66; |
591 | /* | 591 | /* |
592 | * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in | 592 | * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in |
593 | * the MISC. register to stretch the UltraDMA Tss timing. | 593 | * the MISC. register to stretch the UltraDMA Tss timing. |
@@ -598,8 +598,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
598 | } | 598 | } |
599 | 599 | ||
600 | /* Now kick off ATA set up */ | 600 | /* Now kick off ATA set up */ |
601 | port_info[0] = port_info[1] = port; | 601 | return ata_pci_init_one(dev, ppi); |
602 | return ata_pci_init_one(dev, port_info, 2); | ||
603 | } | 602 | } |
604 | 603 | ||
605 | static const struct pci_device_id hpt3x2n[] = { | 604 | static const struct pci_device_id hpt3x2n[] = { |
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c index ac28ec8c50aa..bbabe7902fbb 100644 --- a/drivers/ata/pata_hpt3x3.c +++ b/drivers/ata/pata_hpt3x3.c | |||
@@ -100,10 +100,6 @@ static struct scsi_host_template hpt3x3_sht = { | |||
100 | .slave_configure = ata_scsi_slave_config, | 100 | .slave_configure = ata_scsi_slave_config, |
101 | .slave_destroy = ata_scsi_slave_destroy, | 101 | .slave_destroy = ata_scsi_slave_destroy, |
102 | .bios_param = ata_std_bios_param, | 102 | .bios_param = ata_std_bios_param, |
103 | #ifdef CONFIG_PM | ||
104 | .resume = ata_scsi_device_resume, | ||
105 | .suspend = ata_scsi_device_suspend, | ||
106 | #endif | ||
107 | }; | 103 | }; |
108 | 104 | ||
109 | static struct ata_port_operations hpt3x3_port_ops = { | 105 | static struct ata_port_operations hpt3x3_port_ops = { |
@@ -175,7 +171,7 @@ static void hpt3x3_init_chipset(struct pci_dev *dev) | |||
175 | 171 | ||
176 | static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 172 | static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
177 | { | 173 | { |
178 | static struct ata_port_info info = { | 174 | static const struct ata_port_info info = { |
179 | .sht = &hpt3x3_sht, | 175 | .sht = &hpt3x3_sht, |
180 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 176 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
181 | .pio_mask = 0x1f, | 177 | .pio_mask = 0x1f, |
@@ -183,11 +179,11 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
183 | .udma_mask = 0x07, | 179 | .udma_mask = 0x07, |
184 | .port_ops = &hpt3x3_port_ops | 180 | .port_ops = &hpt3x3_port_ops |
185 | }; | 181 | }; |
186 | static struct ata_port_info *port_info[2] = { &info, &info }; | 182 | const struct ata_port_info *ppi[] = { &info, NULL }; |
187 | 183 | ||
188 | hpt3x3_init_chipset(dev); | 184 | hpt3x3_init_chipset(dev); |
189 | /* Now kick off ATA set up */ | 185 | /* Now kick off ATA set up */ |
190 | return ata_pci_init_one(dev, port_info, 2); | 186 | return ata_pci_init_one(dev, ppi); |
191 | } | 187 | } |
192 | 188 | ||
193 | #ifdef CONFIG_PM | 189 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c index 17bf9f3ed013..a769952646e1 100644 --- a/drivers/ata/pata_it8213.c +++ b/drivers/ata/pata_it8213.c | |||
@@ -257,10 +257,6 @@ static struct scsi_host_template it8213_sht = { | |||
257 | .dma_boundary = ATA_DMA_BOUNDARY, | 257 | .dma_boundary = ATA_DMA_BOUNDARY, |
258 | .slave_configure = ata_scsi_slave_config, | 258 | .slave_configure = ata_scsi_slave_config, |
259 | .bios_param = ata_std_bios_param, | 259 | .bios_param = ata_std_bios_param, |
260 | #ifdef CONFIG_PM | ||
261 | .resume = ata_scsi_device_resume, | ||
262 | .suspend = ata_scsi_device_suspend, | ||
263 | #endif | ||
264 | }; | 260 | }; |
265 | 261 | ||
266 | static const struct ata_port_operations it8213_ops = { | 262 | static const struct ata_port_operations it8213_ops = { |
@@ -315,7 +311,7 @@ static const struct ata_port_operations it8213_ops = { | |||
315 | static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 311 | static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
316 | { | 312 | { |
317 | static int printed_version; | 313 | static int printed_version; |
318 | static struct ata_port_info info = { | 314 | static const struct ata_port_info info = { |
319 | .sht = &it8213_sht, | 315 | .sht = &it8213_sht, |
320 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 316 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
321 | .pio_mask = 0x1f, /* pio0-4 */ | 317 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -323,14 +319,14 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en | |||
323 | .udma_mask = 0x1f, /* UDMA 100 */ | 319 | .udma_mask = 0x1f, /* UDMA 100 */ |
324 | .port_ops = &it8213_ops, | 320 | .port_ops = &it8213_ops, |
325 | }; | 321 | }; |
326 | static struct ata_port_info *port_info[2] = { &info, &info }; | 322 | /* Current IT8213 stuff is single port */ |
323 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; | ||
327 | 324 | ||
328 | if (!printed_version++) | 325 | if (!printed_version++) |
329 | dev_printk(KERN_DEBUG, &pdev->dev, | 326 | dev_printk(KERN_DEBUG, &pdev->dev, |
330 | "version " DRV_VERSION "\n"); | 327 | "version " DRV_VERSION "\n"); |
331 | 328 | ||
332 | /* Current IT8213 stuff is single port */ | 329 | return ata_pci_init_one(pdev, ppi); |
333 | return ata_pci_init_one(pdev, port_info, 1); | ||
334 | } | 330 | } |
335 | 331 | ||
336 | static const struct pci_device_id it8213_pci_tbl[] = { | 332 | static const struct pci_device_id it8213_pci_tbl[] = { |
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index f1f8cec8c224..ff9a6fd36657 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c | |||
@@ -620,10 +620,6 @@ static struct scsi_host_template it821x_sht = { | |||
620 | .slave_configure = ata_scsi_slave_config, | 620 | .slave_configure = ata_scsi_slave_config, |
621 | .slave_destroy = ata_scsi_slave_destroy, | 621 | .slave_destroy = ata_scsi_slave_destroy, |
622 | .bios_param = ata_std_bios_param, | 622 | .bios_param = ata_std_bios_param, |
623 | #ifdef CONFIG_PM | ||
624 | .resume = ata_scsi_device_resume, | ||
625 | .suspend = ata_scsi_device_suspend, | ||
626 | #endif | ||
627 | }; | 623 | }; |
628 | 624 | ||
629 | static struct ata_port_operations it821x_smart_port_ops = { | 625 | static struct ata_port_operations it821x_smart_port_ops = { |
@@ -722,14 +718,14 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
722 | { | 718 | { |
723 | u8 conf; | 719 | u8 conf; |
724 | 720 | ||
725 | static struct ata_port_info info_smart = { | 721 | static const struct ata_port_info info_smart = { |
726 | .sht = &it821x_sht, | 722 | .sht = &it821x_sht, |
727 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 723 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
728 | .pio_mask = 0x1f, | 724 | .pio_mask = 0x1f, |
729 | .mwdma_mask = 0x07, | 725 | .mwdma_mask = 0x07, |
730 | .port_ops = &it821x_smart_port_ops | 726 | .port_ops = &it821x_smart_port_ops |
731 | }; | 727 | }; |
732 | static struct ata_port_info info_passthru = { | 728 | static const struct ata_port_info info_passthru = { |
733 | .sht = &it821x_sht, | 729 | .sht = &it821x_sht, |
734 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 730 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
735 | .pio_mask = 0x1f, | 731 | .pio_mask = 0x1f, |
@@ -737,8 +733,8 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
737 | .udma_mask = 0x7f, | 733 | .udma_mask = 0x7f, |
738 | .port_ops = &it821x_passthru_port_ops | 734 | .port_ops = &it821x_passthru_port_ops |
739 | }; | 735 | }; |
740 | static struct ata_port_info *port_info[2]; | ||
741 | 736 | ||
737 | const struct ata_port_info *ppi[] = { NULL, NULL }; | ||
742 | static char *mode[2] = { "pass through", "smart" }; | 738 | static char *mode[2] = { "pass through", "smart" }; |
743 | 739 | ||
744 | /* Force the card into bypass mode if so requested */ | 740 | /* Force the card into bypass mode if so requested */ |
@@ -751,11 +747,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
751 | 747 | ||
752 | printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); | 748 | printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); |
753 | if (conf == 0) | 749 | if (conf == 0) |
754 | port_info[0] = port_info[1] = &info_passthru; | 750 | ppi[0] = &info_passthru; |
755 | else | 751 | else |
756 | port_info[0] = port_info[1] = &info_smart; | 752 | ppi[0] = &info_smart; |
757 | 753 | ||
758 | return ata_pci_init_one(pdev, port_info, 2); | 754 | return ata_pci_init_one(pdev, ppi); |
759 | } | 755 | } |
760 | 756 | ||
761 | #ifdef CONFIG_PM | 757 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index 420c343e5711..b994351fbcd0 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c | |||
@@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) | |||
31 | 31 | ||
32 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 32 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
33 | struct ata_device *dev = &ap->device[i]; | 33 | struct ata_device *dev = &ap->device[i]; |
34 | if (ata_dev_ready(dev)) { | 34 | if (ata_dev_enabled(dev)) { |
35 | ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); | 35 | ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); |
36 | dev->pio_mode = XFER_PIO_0; | 36 | dev->pio_mode = XFER_PIO_0; |
37 | dev->xfer_mode = XFER_PIO_0; | 37 | dev->xfer_mode = XFER_PIO_0; |
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 1daf78ac6efb..8d799e87f752 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c | |||
@@ -138,10 +138,6 @@ static struct scsi_host_template jmicron_sht = { | |||
138 | .slave_destroy = ata_scsi_slave_destroy, | 138 | .slave_destroy = ata_scsi_slave_destroy, |
139 | /* Use standard CHS mapping rules */ | 139 | /* Use standard CHS mapping rules */ |
140 | .bios_param = ata_std_bios_param, | 140 | .bios_param = ata_std_bios_param, |
141 | #ifdef CONFIG_PM | ||
142 | .suspend = ata_scsi_device_suspend, | ||
143 | .resume = ata_scsi_device_resume, | ||
144 | #endif | ||
145 | }; | 141 | }; |
146 | 142 | ||
147 | static const struct ata_port_operations jmicron_ops = { | 143 | static const struct ata_port_operations jmicron_ops = { |
@@ -195,7 +191,7 @@ static const struct ata_port_operations jmicron_ops = { | |||
195 | 191 | ||
196 | static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | 192 | static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) |
197 | { | 193 | { |
198 | static struct ata_port_info info = { | 194 | static const struct ata_port_info info = { |
199 | .sht = &jmicron_sht, | 195 | .sht = &jmicron_sht, |
200 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 196 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
201 | 197 | ||
@@ -205,9 +201,9 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i | |||
205 | 201 | ||
206 | .port_ops = &jmicron_ops, | 202 | .port_ops = &jmicron_ops, |
207 | }; | 203 | }; |
208 | struct ata_port_info *port_info[2] = { &info, &info }; | 204 | const struct ata_port_info *ppi[] = { &info, NULL }; |
209 | 205 | ||
210 | return ata_pci_init_one(pdev, port_info, 2); | 206 | return ata_pci_init_one(pdev, ppi); |
211 | } | 207 | } |
212 | 208 | ||
213 | static const struct pci_device_id jmicron_pci_tbl[] = { | 209 | static const struct pci_device_id jmicron_pci_tbl[] = { |
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c index 837b7fe77dc7..edbfe0dbbf78 100644 --- a/drivers/ata/pata_marvell.c +++ b/drivers/ata/pata_marvell.c | |||
@@ -107,10 +107,6 @@ static struct scsi_host_template marvell_sht = { | |||
107 | .slave_destroy = ata_scsi_slave_destroy, | 107 | .slave_destroy = ata_scsi_slave_destroy, |
108 | /* Use standard CHS mapping rules */ | 108 | /* Use standard CHS mapping rules */ |
109 | .bios_param = ata_std_bios_param, | 109 | .bios_param = ata_std_bios_param, |
110 | #ifdef CONFIG_PM | ||
111 | .resume = ata_scsi_device_resume, | ||
112 | .suspend = ata_scsi_device_suspend, | ||
113 | #endif | ||
114 | }; | 110 | }; |
115 | 111 | ||
116 | static const struct ata_port_operations marvell_ops = { | 112 | static const struct ata_port_operations marvell_ops = { |
@@ -165,7 +161,7 @@ static const struct ata_port_operations marvell_ops = { | |||
165 | 161 | ||
166 | static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | 162 | static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) |
167 | { | 163 | { |
168 | static struct ata_port_info info = { | 164 | static const struct ata_port_info info = { |
169 | .sht = &marvell_sht, | 165 | .sht = &marvell_sht, |
170 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 166 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
171 | 167 | ||
@@ -175,7 +171,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i | |||
175 | 171 | ||
176 | .port_ops = &marvell_ops, | 172 | .port_ops = &marvell_ops, |
177 | }; | 173 | }; |
178 | static struct ata_port_info info_sata = { | 174 | static const struct ata_port_info info_sata = { |
179 | .sht = &marvell_sht, | 175 | .sht = &marvell_sht, |
180 | /* Slave possible as its magically mapped not real */ | 176 | /* Slave possible as its magically mapped not real */ |
181 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 177 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -186,13 +182,12 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i | |||
186 | 182 | ||
187 | .port_ops = &marvell_ops, | 183 | .port_ops = &marvell_ops, |
188 | }; | 184 | }; |
189 | struct ata_port_info *port_info[2] = { &info, &info_sata }; | 185 | const struct ata_port_info *ppi[] = { &info, &info_sata }; |
190 | int n_port = 2; | ||
191 | 186 | ||
192 | if (pdev->device == 0x6101) | 187 | if (pdev->device == 0x6101) |
193 | n_port = 1; | 188 | ppi[1] = &ata_dummy_port_info; |
194 | 189 | ||
195 | return ata_pci_init_one(pdev, port_info, n_port); | 190 | return ata_pci_init_one(pdev, ppi); |
196 | } | 191 | } |
197 | 192 | ||
198 | static const struct pci_device_id marvell_pci_tbl[] = { | 193 | static const struct pci_device_id marvell_pci_tbl[] = { |
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c index 9587a89f9683..368fac7d168b 100644 --- a/drivers/ata/pata_mpc52xx.c +++ b/drivers/ata/pata_mpc52xx.c | |||
@@ -280,10 +280,6 @@ static struct scsi_host_template mpc52xx_ata_sht = { | |||
280 | .dma_boundary = ATA_DMA_BOUNDARY, | 280 | .dma_boundary = ATA_DMA_BOUNDARY, |
281 | .slave_configure = ata_scsi_slave_config, | 281 | .slave_configure = ata_scsi_slave_config, |
282 | .bios_param = ata_std_bios_param, | 282 | .bios_param = ata_std_bios_param, |
283 | #ifdef CONFIG_PM | ||
284 | .suspend = ata_scsi_device_suspend, | ||
285 | .resume = ata_scsi_device_resume, | ||
286 | #endif | ||
287 | }; | 283 | }; |
288 | 284 | ||
289 | static struct ata_port_operations mpc52xx_ata_port_ops = { | 285 | static struct ata_port_operations mpc52xx_ata_port_ops = { |
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c index 3bfbd495f643..4ea42838297e 100644 --- a/drivers/ata/pata_mpiix.c +++ b/drivers/ata/pata_mpiix.c | |||
@@ -165,10 +165,6 @@ static struct scsi_host_template mpiix_sht = { | |||
165 | .slave_configure = ata_scsi_slave_config, | 165 | .slave_configure = ata_scsi_slave_config, |
166 | .slave_destroy = ata_scsi_slave_destroy, | 166 | .slave_destroy = ata_scsi_slave_destroy, |
167 | .bios_param = ata_std_bios_param, | 167 | .bios_param = ata_std_bios_param, |
168 | #ifdef CONFIG_PM | ||
169 | .resume = ata_scsi_device_resume, | ||
170 | .suspend = ata_scsi_device_suspend, | ||
171 | #endif | ||
172 | }; | 168 | }; |
173 | 169 | ||
174 | static struct ata_port_operations mpiix_port_ops = { | 170 | static struct ata_port_operations mpiix_port_ops = { |
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c index dbba5b77d79c..81f563458666 100644 --- a/drivers/ata/pata_netcell.c +++ b/drivers/ata/pata_netcell.c | |||
@@ -37,10 +37,6 @@ static struct scsi_host_template netcell_sht = { | |||
37 | .slave_destroy = ata_scsi_slave_destroy, | 37 | .slave_destroy = ata_scsi_slave_destroy, |
38 | /* Use standard CHS mapping rules */ | 38 | /* Use standard CHS mapping rules */ |
39 | .bios_param = ata_std_bios_param, | 39 | .bios_param = ata_std_bios_param, |
40 | #ifdef CONFIG_PM | ||
41 | .resume = ata_scsi_device_resume, | ||
42 | .suspend = ata_scsi_device_suspend, | ||
43 | #endif | ||
44 | }; | 40 | }; |
45 | 41 | ||
46 | static const struct ata_port_operations netcell_ops = { | 42 | static const struct ata_port_operations netcell_ops = { |
@@ -96,7 +92,7 @@ static const struct ata_port_operations netcell_ops = { | |||
96 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 92 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
97 | { | 93 | { |
98 | static int printed_version; | 94 | static int printed_version; |
99 | static struct ata_port_info info = { | 95 | static const struct ata_port_info info = { |
100 | .sht = &netcell_sht, | 96 | .sht = &netcell_sht, |
101 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 97 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
102 | /* Actually we don't really care about these as the | 98 | /* Actually we don't really care about these as the |
@@ -106,7 +102,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
106 | .udma_mask = 0x3f, /* UDMA 133 */ | 102 | .udma_mask = 0x3f, /* UDMA 133 */ |
107 | .port_ops = &netcell_ops, | 103 | .port_ops = &netcell_ops, |
108 | }; | 104 | }; |
109 | static struct ata_port_info *port_info[2] = { &info, &info }; | 105 | const struct ata_port_info *port_info[] = { &info, NULL }; |
110 | 106 | ||
111 | if (!printed_version++) | 107 | if (!printed_version++) |
112 | dev_printk(KERN_DEBUG, &pdev->dev, | 108 | dev_printk(KERN_DEBUG, &pdev->dev, |
@@ -116,7 +112,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
116 | ata_pci_clear_simplex(pdev); | 112 | ata_pci_clear_simplex(pdev); |
117 | 113 | ||
118 | /* And let the library code do the work */ | 114 | /* And let the library code do the work */ |
119 | return ata_pci_init_one(pdev, port_info, 2); | 115 | return ata_pci_init_one(pdev, port_info); |
120 | } | 116 | } |
121 | 117 | ||
122 | static const struct pci_device_id netcell_pci_tbl[] = { | 118 | static const struct pci_device_id netcell_pci_tbl[] = { |
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c index ebc58a907d26..ea70ec744879 100644 --- a/drivers/ata/pata_ns87410.c +++ b/drivers/ata/pata_ns87410.c | |||
@@ -158,10 +158,6 @@ static struct scsi_host_template ns87410_sht = { | |||
158 | .slave_configure = ata_scsi_slave_config, | 158 | .slave_configure = ata_scsi_slave_config, |
159 | .slave_destroy = ata_scsi_slave_destroy, | 159 | .slave_destroy = ata_scsi_slave_destroy, |
160 | .bios_param = ata_std_bios_param, | 160 | .bios_param = ata_std_bios_param, |
161 | #ifdef CONFIG_PM | ||
162 | .resume = ata_scsi_device_resume, | ||
163 | .suspend = ata_scsi_device_suspend, | ||
164 | #endif | ||
165 | }; | 161 | }; |
166 | 162 | ||
167 | static struct ata_port_operations ns87410_port_ops = { | 163 | static struct ata_port_operations ns87410_port_ops = { |
@@ -195,14 +191,14 @@ static struct ata_port_operations ns87410_port_ops = { | |||
195 | 191 | ||
196 | static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 192 | static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
197 | { | 193 | { |
198 | static struct ata_port_info info = { | 194 | static const struct ata_port_info info = { |
199 | .sht = &ns87410_sht, | 195 | .sht = &ns87410_sht, |
200 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 196 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
201 | .pio_mask = 0x0F, | 197 | .pio_mask = 0x0F, |
202 | .port_ops = &ns87410_port_ops | 198 | .port_ops = &ns87410_port_ops |
203 | }; | 199 | }; |
204 | static struct ata_port_info *port_info[2] = {&info, &info}; | 200 | const struct ata_port_info *ppi[] = { &info, NULL }; |
205 | return ata_pci_init_one(dev, port_info, 2); | 201 | return ata_pci_init_one(dev, ppi); |
206 | } | 202 | } |
207 | 203 | ||
208 | static const struct pci_device_id ns87410[] = { | 204 | static const struct pci_device_id ns87410[] = { |
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c index 4d75d32e5826..29c23ddd6550 100644 --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c | |||
@@ -234,10 +234,6 @@ static struct scsi_host_template oldpiix_sht = { | |||
234 | .slave_configure = ata_scsi_slave_config, | 234 | .slave_configure = ata_scsi_slave_config, |
235 | .slave_destroy = ata_scsi_slave_destroy, | 235 | .slave_destroy = ata_scsi_slave_destroy, |
236 | .bios_param = ata_std_bios_param, | 236 | .bios_param = ata_std_bios_param, |
237 | #ifdef CONFIG_PM | ||
238 | .resume = ata_scsi_device_resume, | ||
239 | .suspend = ata_scsi_device_suspend, | ||
240 | #endif | ||
241 | }; | 237 | }; |
242 | 238 | ||
243 | static const struct ata_port_operations oldpiix_pata_ops = { | 239 | static const struct ata_port_operations oldpiix_pata_ops = { |
@@ -293,20 +289,20 @@ static const struct ata_port_operations oldpiix_pata_ops = { | |||
293 | static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 289 | static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
294 | { | 290 | { |
295 | static int printed_version; | 291 | static int printed_version; |
296 | static struct ata_port_info info = { | 292 | static const struct ata_port_info info = { |
297 | .sht = &oldpiix_sht, | 293 | .sht = &oldpiix_sht, |
298 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 294 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
299 | .pio_mask = 0x1f, /* pio0-4 */ | 295 | .pio_mask = 0x1f, /* pio0-4 */ |
300 | .mwdma_mask = 0x07, /* mwdma1-2 */ | 296 | .mwdma_mask = 0x07, /* mwdma1-2 */ |
301 | .port_ops = &oldpiix_pata_ops, | 297 | .port_ops = &oldpiix_pata_ops, |
302 | }; | 298 | }; |
303 | static struct ata_port_info *port_info[2] = { &info, &info }; | 299 | const struct ata_port_info *ppi[] = { &info, NULL }; |
304 | 300 | ||
305 | if (!printed_version++) | 301 | if (!printed_version++) |
306 | dev_printk(KERN_DEBUG, &pdev->dev, | 302 | dev_printk(KERN_DEBUG, &pdev->dev, |
307 | "version " DRV_VERSION "\n"); | 303 | "version " DRV_VERSION "\n"); |
308 | 304 | ||
309 | return ata_pci_init_one(pdev, port_info, 2); | 305 | return ata_pci_init_one(pdev, ppi); |
310 | } | 306 | } |
311 | 307 | ||
312 | static const struct pci_device_id oldpiix_pci_tbl[] = { | 308 | static const struct pci_device_id oldpiix_pci_tbl[] = { |
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c index 0af8a2c77cc9..1c44653e1e06 100644 --- a/drivers/ata/pata_opti.c +++ b/drivers/ata/pata_opti.c | |||
@@ -179,10 +179,6 @@ static struct scsi_host_template opti_sht = { | |||
179 | .slave_configure = ata_scsi_slave_config, | 179 | .slave_configure = ata_scsi_slave_config, |
180 | .slave_destroy = ata_scsi_slave_destroy, | 180 | .slave_destroy = ata_scsi_slave_destroy, |
181 | .bios_param = ata_std_bios_param, | 181 | .bios_param = ata_std_bios_param, |
182 | #ifdef CONFIG_PM | ||
183 | .resume = ata_scsi_device_resume, | ||
184 | .suspend = ata_scsi_device_suspend, | ||
185 | #endif | ||
186 | }; | 182 | }; |
187 | 183 | ||
188 | static struct ata_port_operations opti_port_ops = { | 184 | static struct ata_port_operations opti_port_ops = { |
@@ -220,19 +216,19 @@ static struct ata_port_operations opti_port_ops = { | |||
220 | 216 | ||
221 | static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 217 | static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
222 | { | 218 | { |
223 | static struct ata_port_info info = { | 219 | static const struct ata_port_info info = { |
224 | .sht = &opti_sht, | 220 | .sht = &opti_sht, |
225 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 221 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
226 | .pio_mask = 0x1f, | 222 | .pio_mask = 0x1f, |
227 | .port_ops = &opti_port_ops | 223 | .port_ops = &opti_port_ops |
228 | }; | 224 | }; |
229 | static struct ata_port_info *port_info[2] = { &info, &info }; | 225 | const struct ata_port_info *ppi[] = { &info, NULL }; |
230 | static int printed_version; | 226 | static int printed_version; |
231 | 227 | ||
232 | if (!printed_version++) | 228 | if (!printed_version++) |
233 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); | 229 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); |
234 | 230 | ||
235 | return ata_pci_init_one(dev, port_info, 2); | 231 | return ata_pci_init_one(dev, ppi); |
236 | } | 232 | } |
237 | 233 | ||
238 | static const struct pci_device_id opti[] = { | 234 | static const struct pci_device_id opti[] = { |
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c index 2843e480f216..3093b02286ce 100644 --- a/drivers/ata/pata_optidma.c +++ b/drivers/ata/pata_optidma.c | |||
@@ -363,10 +363,6 @@ static struct scsi_host_template optidma_sht = { | |||
363 | .slave_configure = ata_scsi_slave_config, | 363 | .slave_configure = ata_scsi_slave_config, |
364 | .slave_destroy = ata_scsi_slave_destroy, | 364 | .slave_destroy = ata_scsi_slave_destroy, |
365 | .bios_param = ata_std_bios_param, | 365 | .bios_param = ata_std_bios_param, |
366 | #ifdef CONFIG_PM | ||
367 | .resume = ata_scsi_device_resume, | ||
368 | .suspend = ata_scsi_device_suspend, | ||
369 | #endif | ||
370 | }; | 366 | }; |
371 | 367 | ||
372 | static struct ata_port_operations optidma_port_ops = { | 368 | static struct ata_port_operations optidma_port_ops = { |
@@ -486,14 +482,14 @@ done_nomsg: /* Wrong chip revision */ | |||
486 | 482 | ||
487 | static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 483 | static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
488 | { | 484 | { |
489 | static struct ata_port_info info_82c700 = { | 485 | static const struct ata_port_info info_82c700 = { |
490 | .sht = &optidma_sht, | 486 | .sht = &optidma_sht, |
491 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 487 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
492 | .pio_mask = 0x1f, | 488 | .pio_mask = 0x1f, |
493 | .mwdma_mask = 0x07, | 489 | .mwdma_mask = 0x07, |
494 | .port_ops = &optidma_port_ops | 490 | .port_ops = &optidma_port_ops |
495 | }; | 491 | }; |
496 | static struct ata_port_info info_82c700_udma = { | 492 | static const struct ata_port_info info_82c700_udma = { |
497 | .sht = &optidma_sht, | 493 | .sht = &optidma_sht, |
498 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 494 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
499 | .pio_mask = 0x1f, | 495 | .pio_mask = 0x1f, |
@@ -501,8 +497,7 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
501 | .udma_mask = 0x07, | 497 | .udma_mask = 0x07, |
502 | .port_ops = &optiplus_port_ops | 498 | .port_ops = &optiplus_port_ops |
503 | }; | 499 | }; |
504 | static struct ata_port_info *port_info[2]; | 500 | const struct ata_port_info *ppi[] = { &info_82c700, NULL }; |
505 | struct ata_port_info *info = &info_82c700; | ||
506 | static int printed_version; | 501 | static int printed_version; |
507 | 502 | ||
508 | if (!printed_version++) | 503 | if (!printed_version++) |
@@ -514,10 +509,9 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
514 | pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ | 509 | pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ |
515 | 510 | ||
516 | if (optiplus_with_udma(dev)) | 511 | if (optiplus_with_udma(dev)) |
517 | info = &info_82c700_udma; | 512 | ppi[0] = &info_82c700_udma; |
518 | 513 | ||
519 | port_info[0] = port_info[1] = info; | 514 | return ata_pci_init_one(dev, ppi); |
520 | return ata_pci_init_one(dev, port_info, 2); | ||
521 | } | 515 | } |
522 | 516 | ||
523 | static const struct pci_device_id optidma[] = { | 517 | static const struct pci_device_id optidma[] = { |
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 11245e331f77..4d44c7555db1 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -397,6 +397,7 @@ static struct pcmcia_device_id pcmcia_devices[] = { | |||
397 | PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), | 397 | PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), |
398 | PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), | 398 | PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), |
399 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), | 399 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), |
400 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), | ||
400 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), | 401 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), |
401 | PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), | 402 | PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), |
402 | PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), | 403 | PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), |
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index ee636beb05e1..edbaf9d653b8 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c | |||
@@ -244,10 +244,6 @@ static struct scsi_host_template pdc202xx_sht = { | |||
244 | .slave_configure = ata_scsi_slave_config, | 244 | .slave_configure = ata_scsi_slave_config, |
245 | .slave_destroy = ata_scsi_slave_destroy, | 245 | .slave_destroy = ata_scsi_slave_destroy, |
246 | .bios_param = ata_std_bios_param, | 246 | .bios_param = ata_std_bios_param, |
247 | #ifdef CONFIG_PM | ||
248 | .resume = ata_scsi_device_resume, | ||
249 | .suspend = ata_scsi_device_suspend, | ||
250 | #endif | ||
251 | }; | 247 | }; |
252 | 248 | ||
253 | static struct ata_port_operations pdc2024x_port_ops = { | 249 | static struct ata_port_operations pdc2024x_port_ops = { |
@@ -321,7 +317,7 @@ static struct ata_port_operations pdc2026x_port_ops = { | |||
321 | 317 | ||
322 | static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 318 | static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
323 | { | 319 | { |
324 | static struct ata_port_info info[3] = { | 320 | static const struct ata_port_info info[3] = { |
325 | { | 321 | { |
326 | .sht = &pdc202xx_sht, | 322 | .sht = &pdc202xx_sht, |
327 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 323 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -348,9 +344,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
348 | } | 344 | } |
349 | 345 | ||
350 | }; | 346 | }; |
351 | static struct ata_port_info *port_info[2]; | 347 | const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; |
352 | |||
353 | port_info[0] = port_info[1] = &info[id->driver_data]; | ||
354 | 348 | ||
355 | if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { | 349 | if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { |
356 | struct pci_dev *bridge = dev->bus->self; | 350 | struct pci_dev *bridge = dev->bus->self; |
@@ -362,7 +356,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
362 | return -ENODEV; | 356 | return -ENODEV; |
363 | } | 357 | } |
364 | } | 358 | } |
365 | return ata_pci_init_one(dev, port_info, 2); | 359 | return ata_pci_init_one(dev, ppi); |
366 | } | 360 | } |
367 | 361 | ||
368 | static const struct pci_device_id pdc202xx[] = { | 362 | static const struct pci_device_id pdc202xx[] = { |
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index a0a650c7f272..1f6384895a4f 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c | |||
@@ -48,6 +48,8 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse | |||
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | static int ata_dummy_ret0(struct ata_port *ap) { return 0; } | ||
52 | |||
51 | static struct scsi_host_template pata_platform_sht = { | 53 | static struct scsi_host_template pata_platform_sht = { |
52 | .module = THIS_MODULE, | 54 | .module = THIS_MODULE, |
53 | .name = DRV_NAME, | 55 | .name = DRV_NAME, |
@@ -91,7 +93,7 @@ static struct ata_port_operations pata_platform_port_ops = { | |||
91 | .irq_on = ata_irq_on, | 93 | .irq_on = ata_irq_on, |
92 | .irq_ack = ata_irq_ack, | 94 | .irq_ack = ata_irq_ack, |
93 | 95 | ||
94 | .port_start = ata_port_start, | 96 | .port_start = ata_dummy_ret0, |
95 | }; | 97 | }; |
96 | 98 | ||
97 | static void pata_platform_setup_port(struct ata_ioports *ioaddr, | 99 | static void pata_platform_setup_port(struct ata_ioports *ioaddr, |
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c index 1c54673e008d..ba96b54f5b87 100644 --- a/drivers/ata/pata_radisys.c +++ b/drivers/ata/pata_radisys.c | |||
@@ -200,10 +200,6 @@ static struct scsi_host_template radisys_sht = { | |||
200 | .slave_configure = ata_scsi_slave_config, | 200 | .slave_configure = ata_scsi_slave_config, |
201 | .slave_destroy = ata_scsi_slave_destroy, | 201 | .slave_destroy = ata_scsi_slave_destroy, |
202 | .bios_param = ata_std_bios_param, | 202 | .bios_param = ata_std_bios_param, |
203 | #ifdef CONFIG_PM | ||
204 | .resume = ata_scsi_device_resume, | ||
205 | .suspend = ata_scsi_device_suspend, | ||
206 | #endif | ||
207 | }; | 203 | }; |
208 | 204 | ||
209 | static const struct ata_port_operations radisys_pata_ops = { | 205 | static const struct ata_port_operations radisys_pata_ops = { |
@@ -259,7 +255,7 @@ static const struct ata_port_operations radisys_pata_ops = { | |||
259 | static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 255 | static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
260 | { | 256 | { |
261 | static int printed_version; | 257 | static int printed_version; |
262 | static struct ata_port_info info = { | 258 | static const struct ata_port_info info = { |
263 | .sht = &radisys_sht, | 259 | .sht = &radisys_sht, |
264 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 260 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
265 | .pio_mask = 0x1f, /* pio0-4 */ | 261 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -267,13 +263,13 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
267 | .udma_mask = 0x14, /* UDMA33/66 only */ | 263 | .udma_mask = 0x14, /* UDMA33/66 only */ |
268 | .port_ops = &radisys_pata_ops, | 264 | .port_ops = &radisys_pata_ops, |
269 | }; | 265 | }; |
270 | static struct ata_port_info *port_info[2] = { &info, &info }; | 266 | const struct ata_port_info *ppi[] = { &info, NULL }; |
271 | 267 | ||
272 | if (!printed_version++) | 268 | if (!printed_version++) |
273 | dev_printk(KERN_DEBUG, &pdev->dev, | 269 | dev_printk(KERN_DEBUG, &pdev->dev, |
274 | "version " DRV_VERSION "\n"); | 270 | "version " DRV_VERSION "\n"); |
275 | 271 | ||
276 | return ata_pci_init_one(pdev, port_info, 2); | 272 | return ata_pci_init_one(pdev, ppi); |
277 | } | 273 | } |
278 | 274 | ||
279 | static const struct pci_device_id radisys_pci_tbl[] = { | 275 | static const struct pci_device_id radisys_pci_tbl[] = { |
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index 85c45290eeee..2bfd7ef42af5 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c | |||
@@ -40,7 +40,7 @@ static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
40 | 40 | ||
41 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 41 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
42 | struct ata_device *dev = &ap->device[i]; | 42 | struct ata_device *dev = &ap->device[i]; |
43 | if (ata_dev_ready(dev)) { | 43 | if (ata_dev_enabled(dev)) { |
44 | /* We don't really care */ | 44 | /* We don't really care */ |
45 | dev->pio_mode = XFER_PIO_0; | 45 | dev->pio_mode = XFER_PIO_0; |
46 | dev->xfer_mode = XFER_PIO_0; | 46 | dev->xfer_mode = XFER_PIO_0; |
@@ -69,10 +69,6 @@ static struct scsi_host_template rz1000_sht = { | |||
69 | .slave_configure = ata_scsi_slave_config, | 69 | .slave_configure = ata_scsi_slave_config, |
70 | .slave_destroy = ata_scsi_slave_destroy, | 70 | .slave_destroy = ata_scsi_slave_destroy, |
71 | .bios_param = ata_std_bios_param, | 71 | .bios_param = ata_std_bios_param, |
72 | #ifdef CONFIG_PM | ||
73 | .resume = ata_scsi_device_resume, | ||
74 | .suspend = ata_scsi_device_suspend, | ||
75 | #endif | ||
76 | }; | 72 | }; |
77 | 73 | ||
78 | static struct ata_port_operations rz1000_port_ops = { | 74 | static struct ata_port_operations rz1000_port_ops = { |
@@ -135,22 +131,20 @@ static int rz1000_fifo_disable(struct pci_dev *pdev) | |||
135 | static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 131 | static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
136 | { | 132 | { |
137 | static int printed_version; | 133 | static int printed_version; |
138 | struct ata_port_info *port_info[2]; | 134 | static const struct ata_port_info info = { |
139 | static struct ata_port_info info = { | ||
140 | .sht = &rz1000_sht, | 135 | .sht = &rz1000_sht, |
141 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 136 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
142 | .pio_mask = 0x1f, | 137 | .pio_mask = 0x1f, |
143 | .port_ops = &rz1000_port_ops | 138 | .port_ops = &rz1000_port_ops |
144 | }; | 139 | }; |
140 | const struct ata_port_info *ppi[] = { &info, NULL }; | ||
145 | 141 | ||
146 | if (!printed_version++) | 142 | if (!printed_version++) |
147 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 143 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); |
148 | 144 | ||
149 | if (rz1000_fifo_disable(pdev) == 0) { | 145 | if (rz1000_fifo_disable(pdev) == 0) |
150 | port_info[0] = &info; | 146 | return ata_pci_init_one(pdev, ppi); |
151 | port_info[1] = &info; | 147 | |
152 | return ata_pci_init_one(pdev, port_info, 2); | ||
153 | } | ||
154 | printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); | 148 | printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); |
155 | /* Not safe to use so skip */ | 149 | /* Not safe to use so skip */ |
156 | return -ENODEV; | 150 | return -ENODEV; |
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c index 66e8ff467c8d..225013ecf4b6 100644 --- a/drivers/ata/pata_sc1200.c +++ b/drivers/ata/pata_sc1200.c | |||
@@ -194,10 +194,6 @@ static struct scsi_host_template sc1200_sht = { | |||
194 | .slave_configure = ata_scsi_slave_config, | 194 | .slave_configure = ata_scsi_slave_config, |
195 | .slave_destroy = ata_scsi_slave_destroy, | 195 | .slave_destroy = ata_scsi_slave_destroy, |
196 | .bios_param = ata_std_bios_param, | 196 | .bios_param = ata_std_bios_param, |
197 | #ifdef CONFIG_PM | ||
198 | .resume = ata_scsi_device_resume, | ||
199 | .suspend = ata_scsi_device_suspend, | ||
200 | #endif | ||
201 | }; | 197 | }; |
202 | 198 | ||
203 | static struct ata_port_operations sc1200_port_ops = { | 199 | static struct ata_port_operations sc1200_port_ops = { |
@@ -247,7 +243,7 @@ static struct ata_port_operations sc1200_port_ops = { | |||
247 | 243 | ||
248 | static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 244 | static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
249 | { | 245 | { |
250 | static struct ata_port_info info = { | 246 | static const struct ata_port_info info = { |
251 | .sht = &sc1200_sht, | 247 | .sht = &sc1200_sht, |
252 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 248 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
253 | .pio_mask = 0x1f, | 249 | .pio_mask = 0x1f, |
@@ -255,10 +251,10 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
255 | .udma_mask = 0x07, | 251 | .udma_mask = 0x07, |
256 | .port_ops = &sc1200_port_ops | 252 | .port_ops = &sc1200_port_ops |
257 | }; | 253 | }; |
258 | static struct ata_port_info *port_info[2] = { &info, &info }; | ||
259 | |||
260 | /* Can't enable port 2 yet, see top comments */ | 254 | /* Can't enable port 2 yet, see top comments */ |
261 | return ata_pci_init_one(dev, port_info, 1); | 255 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; |
256 | |||
257 | return ata_pci_init_one(dev, ppi); | ||
262 | } | 258 | } |
263 | 259 | ||
264 | static const struct pci_device_id sc1200[] = { | 260 | static const struct pci_device_id sc1200[] = { |
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c index 203f463ac39f..cca3aa225efe 100644 --- a/drivers/ata/pata_scc.c +++ b/drivers/ata/pata_scc.c | |||
@@ -984,10 +984,6 @@ static struct scsi_host_template scc_sht = { | |||
984 | .slave_configure = ata_scsi_slave_config, | 984 | .slave_configure = ata_scsi_slave_config, |
985 | .slave_destroy = ata_scsi_slave_destroy, | 985 | .slave_destroy = ata_scsi_slave_destroy, |
986 | .bios_param = ata_std_bios_param, | 986 | .bios_param = ata_std_bios_param, |
987 | #ifdef CONFIG_PM | ||
988 | .resume = ata_scsi_device_resume, | ||
989 | .suspend = ata_scsi_device_suspend, | ||
990 | #endif | ||
991 | }; | 987 | }; |
992 | 988 | ||
993 | static const struct ata_port_operations scc_pata_ops = { | 989 | static const struct ata_port_operations scc_pata_ops = { |
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c index b6e020383dd9..dee6e211949d 100644 --- a/drivers/ata/pata_serverworks.c +++ b/drivers/ata/pata_serverworks.c | |||
@@ -315,10 +315,6 @@ static struct scsi_host_template serverworks_sht = { | |||
315 | .slave_configure = ata_scsi_slave_config, | 315 | .slave_configure = ata_scsi_slave_config, |
316 | .slave_destroy = ata_scsi_slave_destroy, | 316 | .slave_destroy = ata_scsi_slave_destroy, |
317 | .bios_param = ata_std_bios_param, | 317 | .bios_param = ata_std_bios_param, |
318 | #ifdef CONFIG_PM | ||
319 | .resume = ata_scsi_device_resume, | ||
320 | .suspend = ata_scsi_device_suspend, | ||
321 | #endif | ||
322 | }; | 318 | }; |
323 | 319 | ||
324 | static struct ata_port_operations serverworks_osb4_port_ops = { | 320 | static struct ata_port_operations serverworks_osb4_port_ops = { |
@@ -479,8 +475,7 @@ static void serverworks_fixup_ht1000(struct pci_dev *pdev) | |||
479 | 475 | ||
480 | static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 476 | static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
481 | { | 477 | { |
482 | int ports = 2; | 478 | static const struct ata_port_info info[4] = { |
483 | static struct ata_port_info info[4] = { | ||
484 | { /* OSB4 */ | 479 | { /* OSB4 */ |
485 | .sht = &serverworks_sht, | 480 | .sht = &serverworks_sht, |
486 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 481 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -511,8 +506,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
511 | .port_ops = &serverworks_csb_port_ops | 506 | .port_ops = &serverworks_csb_port_ops |
512 | } | 507 | } |
513 | }; | 508 | }; |
514 | static struct ata_port_info *port_info[2]; | 509 | const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; |
515 | struct ata_port_info *devinfo = &info[id->driver_data]; | ||
516 | 510 | ||
517 | /* Force master latency timer to 64 PCI clocks */ | 511 | /* Force master latency timer to 64 PCI clocks */ |
518 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); | 512 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); |
@@ -521,7 +515,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
521 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { | 515 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { |
522 | /* Select non UDMA capable OSB4 if we can't do fixups */ | 516 | /* Select non UDMA capable OSB4 if we can't do fixups */ |
523 | if ( serverworks_fixup_osb4(pdev) < 0) | 517 | if ( serverworks_fixup_osb4(pdev) < 0) |
524 | devinfo = &info[1]; | 518 | ppi[0] = &info[1]; |
525 | } | 519 | } |
526 | /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ | 520 | /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ |
527 | else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || | 521 | else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || |
@@ -531,11 +525,11 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
531 | /* If the returned btr is the newer revision then | 525 | /* If the returned btr is the newer revision then |
532 | select the right info block */ | 526 | select the right info block */ |
533 | if (serverworks_fixup_csb(pdev) == 3) | 527 | if (serverworks_fixup_csb(pdev) == 3) |
534 | devinfo = &info[3]; | 528 | ppi[0] = &info[3]; |
535 | 529 | ||
536 | /* Is this the 3rd channel CSB6 IDE ? */ | 530 | /* Is this the 3rd channel CSB6 IDE ? */ |
537 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) | 531 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) |
538 | ports = 1; | 532 | ppi[1] = &ata_dummy_port_info; |
539 | } | 533 | } |
540 | /* setup HT1000E */ | 534 | /* setup HT1000E */ |
541 | else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) | 535 | else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) |
@@ -544,8 +538,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
544 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) | 538 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) |
545 | ata_pci_clear_simplex(pdev); | 539 | ata_pci_clear_simplex(pdev); |
546 | 540 | ||
547 | port_info[0] = port_info[1] = devinfo; | 541 | return ata_pci_init_one(pdev, ppi); |
548 | return ata_pci_init_one(pdev, port_info, ports); | ||
549 | } | 542 | } |
550 | 543 | ||
551 | #ifdef CONFIG_PM | 544 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index a5886f061c0b..440e2cb6ee75 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c | |||
@@ -232,10 +232,6 @@ static struct scsi_host_template sil680_sht = { | |||
232 | .slave_configure = ata_scsi_slave_config, | 232 | .slave_configure = ata_scsi_slave_config, |
233 | .slave_destroy = ata_scsi_slave_destroy, | 233 | .slave_destroy = ata_scsi_slave_destroy, |
234 | .bios_param = ata_std_bios_param, | 234 | .bios_param = ata_std_bios_param, |
235 | #ifdef CONFIG_PM | ||
236 | .suspend = ata_scsi_device_suspend, | ||
237 | .resume = ata_scsi_device_resume, | ||
238 | #endif | ||
239 | }; | 235 | }; |
240 | 236 | ||
241 | static struct ata_port_operations sil680_port_ops = { | 237 | static struct ata_port_operations sil680_port_ops = { |
@@ -345,7 +341,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev) | |||
345 | 341 | ||
346 | static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 342 | static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
347 | { | 343 | { |
348 | static struct ata_port_info info = { | 344 | static const struct ata_port_info info = { |
349 | .sht = &sil680_sht, | 345 | .sht = &sil680_sht, |
350 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 346 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
351 | .pio_mask = 0x1f, | 347 | .pio_mask = 0x1f, |
@@ -353,7 +349,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
353 | .udma_mask = 0x7f, | 349 | .udma_mask = 0x7f, |
354 | .port_ops = &sil680_port_ops | 350 | .port_ops = &sil680_port_ops |
355 | }; | 351 | }; |
356 | static struct ata_port_info info_slow = { | 352 | static const struct ata_port_info info_slow = { |
357 | .sht = &sil680_sht, | 353 | .sht = &sil680_sht, |
358 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 354 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
359 | .pio_mask = 0x1f, | 355 | .pio_mask = 0x1f, |
@@ -361,7 +357,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
361 | .udma_mask = 0x3f, | 357 | .udma_mask = 0x3f, |
362 | .port_ops = &sil680_port_ops | 358 | .port_ops = &sil680_port_ops |
363 | }; | 359 | }; |
364 | static struct ata_port_info *port_info[2] = {&info, &info}; | 360 | const struct ata_port_info *ppi[] = { &info, NULL }; |
365 | static int printed_version; | 361 | static int printed_version; |
366 | 362 | ||
367 | if (!printed_version++) | 363 | if (!printed_version++) |
@@ -370,12 +366,12 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
370 | switch(sil680_init_chip(pdev)) | 366 | switch(sil680_init_chip(pdev)) |
371 | { | 367 | { |
372 | case 0: | 368 | case 0: |
373 | port_info[0] = port_info[1] = &info_slow; | 369 | ppi[0] = &info_slow; |
374 | break; | 370 | break; |
375 | case 0x30: | 371 | case 0x30: |
376 | return -ENODEV; | 372 | return -ENODEV; |
377 | } | 373 | } |
378 | return ata_pci_init_one(pdev, port_info, 2); | 374 | return ata_pci_init_one(pdev, ppi); |
379 | } | 375 | } |
380 | 376 | ||
381 | #ifdef CONFIG_PM | 377 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index f5838cc11728..f2231267e011 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c | |||
@@ -38,8 +38,8 @@ | |||
38 | #define DRV_VERSION "0.5.1" | 38 | #define DRV_VERSION "0.5.1" |
39 | 39 | ||
40 | struct sis_chipset { | 40 | struct sis_chipset { |
41 | u16 device; /* PCI host ID */ | 41 | u16 device; /* PCI host ID */ |
42 | struct ata_port_info *info; /* Info block */ | 42 | const struct ata_port_info *info; /* Info block */ |
43 | /* Probably add family, cable detect type etc here to clean | 43 | /* Probably add family, cable detect type etc here to clean |
44 | up code later */ | 44 | up code later */ |
45 | }; | 45 | }; |
@@ -524,10 +524,6 @@ static struct scsi_host_template sis_sht = { | |||
524 | .slave_configure = ata_scsi_slave_config, | 524 | .slave_configure = ata_scsi_slave_config, |
525 | .slave_destroy = ata_scsi_slave_destroy, | 525 | .slave_destroy = ata_scsi_slave_destroy, |
526 | .bios_param = ata_std_bios_param, | 526 | .bios_param = ata_std_bios_param, |
527 | #ifdef CONFIG_PM | ||
528 | .resume = ata_scsi_device_resume, | ||
529 | .suspend = ata_scsi_device_suspend, | ||
530 | #endif | ||
531 | }; | 527 | }; |
532 | 528 | ||
533 | static const struct ata_port_operations sis_133_ops = { | 529 | static const struct ata_port_operations sis_133_ops = { |
@@ -700,7 +696,7 @@ static const struct ata_port_operations sis_old_ops = { | |||
700 | .port_start = ata_port_start, | 696 | .port_start = ata_port_start, |
701 | }; | 697 | }; |
702 | 698 | ||
703 | static struct ata_port_info sis_info = { | 699 | static const struct ata_port_info sis_info = { |
704 | .sht = &sis_sht, | 700 | .sht = &sis_sht, |
705 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 701 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
706 | .pio_mask = 0x1f, /* pio0-4 */ | 702 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -708,7 +704,7 @@ static struct ata_port_info sis_info = { | |||
708 | .udma_mask = 0, | 704 | .udma_mask = 0, |
709 | .port_ops = &sis_old_ops, | 705 | .port_ops = &sis_old_ops, |
710 | }; | 706 | }; |
711 | static struct ata_port_info sis_info33 = { | 707 | static const struct ata_port_info sis_info33 = { |
712 | .sht = &sis_sht, | 708 | .sht = &sis_sht, |
713 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 709 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
714 | .pio_mask = 0x1f, /* pio0-4 */ | 710 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -716,35 +712,35 @@ static struct ata_port_info sis_info33 = { | |||
716 | .udma_mask = ATA_UDMA2, /* UDMA 33 */ | 712 | .udma_mask = ATA_UDMA2, /* UDMA 33 */ |
717 | .port_ops = &sis_old_ops, | 713 | .port_ops = &sis_old_ops, |
718 | }; | 714 | }; |
719 | static struct ata_port_info sis_info66 = { | 715 | static const struct ata_port_info sis_info66 = { |
720 | .sht = &sis_sht, | 716 | .sht = &sis_sht, |
721 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 717 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
722 | .pio_mask = 0x1f, /* pio0-4 */ | 718 | .pio_mask = 0x1f, /* pio0-4 */ |
723 | .udma_mask = ATA_UDMA4, /* UDMA 66 */ | 719 | .udma_mask = ATA_UDMA4, /* UDMA 66 */ |
724 | .port_ops = &sis_66_ops, | 720 | .port_ops = &sis_66_ops, |
725 | }; | 721 | }; |
726 | static struct ata_port_info sis_info100 = { | 722 | static const struct ata_port_info sis_info100 = { |
727 | .sht = &sis_sht, | 723 | .sht = &sis_sht, |
728 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 724 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
729 | .pio_mask = 0x1f, /* pio0-4 */ | 725 | .pio_mask = 0x1f, /* pio0-4 */ |
730 | .udma_mask = ATA_UDMA5, | 726 | .udma_mask = ATA_UDMA5, |
731 | .port_ops = &sis_100_ops, | 727 | .port_ops = &sis_100_ops, |
732 | }; | 728 | }; |
733 | static struct ata_port_info sis_info100_early = { | 729 | static const struct ata_port_info sis_info100_early = { |
734 | .sht = &sis_sht, | 730 | .sht = &sis_sht, |
735 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 731 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
736 | .udma_mask = ATA_UDMA5, | 732 | .udma_mask = ATA_UDMA5, |
737 | .pio_mask = 0x1f, /* pio0-4 */ | 733 | .pio_mask = 0x1f, /* pio0-4 */ |
738 | .port_ops = &sis_66_ops, | 734 | .port_ops = &sis_66_ops, |
739 | }; | 735 | }; |
740 | struct ata_port_info sis_info133 = { | 736 | const struct ata_port_info sis_info133 = { |
741 | .sht = &sis_sht, | 737 | .sht = &sis_sht, |
742 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 738 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
743 | .pio_mask = 0x1f, /* pio0-4 */ | 739 | .pio_mask = 0x1f, /* pio0-4 */ |
744 | .udma_mask = ATA_UDMA6, | 740 | .udma_mask = ATA_UDMA6, |
745 | .port_ops = &sis_133_ops, | 741 | .port_ops = &sis_133_ops, |
746 | }; | 742 | }; |
747 | static struct ata_port_info sis_info133_early = { | 743 | static const struct ata_port_info sis_info133_early = { |
748 | .sht = &sis_sht, | 744 | .sht = &sis_sht, |
749 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 745 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
750 | .pio_mask = 0x1f, /* pio0-4 */ | 746 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -827,8 +823,8 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis) | |||
827 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 823 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
828 | { | 824 | { |
829 | static int printed_version; | 825 | static int printed_version; |
830 | static struct ata_port_info *port_info[2]; | 826 | struct ata_port_info port; |
831 | struct ata_port_info *port; | 827 | const struct ata_port_info *ppi[] = { &port, NULL }; |
832 | struct pci_dev *host = NULL; | 828 | struct pci_dev *host = NULL; |
833 | struct sis_chipset *chipset = NULL; | 829 | struct sis_chipset *chipset = NULL; |
834 | struct sis_chipset *sets; | 830 | struct sis_chipset *sets; |
@@ -968,13 +964,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
968 | if (chipset == NULL) | 964 | if (chipset == NULL) |
969 | return -ENODEV; | 965 | return -ENODEV; |
970 | 966 | ||
971 | port = chipset->info; | 967 | port = *chipset->info; |
972 | port->private_data = chipset; | 968 | port.private_data = chipset; |
973 | 969 | ||
974 | sis_fixup(pdev, chipset); | 970 | sis_fixup(pdev, chipset); |
975 | 971 | ||
976 | port_info[0] = port_info[1] = port; | 972 | return ata_pci_init_one(pdev, ppi); |
977 | return ata_pci_init_one(pdev, port_info, 2); | ||
978 | } | 973 | } |
979 | 974 | ||
980 | static const struct pci_device_id sis_pci_tbl[] = { | 975 | static const struct pci_device_id sis_pci_tbl[] = { |
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index 9aeffdbe2829..f48491ad5f3a 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c | |||
@@ -301,20 +301,22 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev) | |||
301 | 301 | ||
302 | static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 302 | static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
303 | { | 303 | { |
304 | static struct ata_port_info info_dma = { | 304 | static const struct ata_port_info info_dma = { |
305 | .sht = &sl82c105_sht, | 305 | .sht = &sl82c105_sht, |
306 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 306 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
307 | .pio_mask = 0x1f, | 307 | .pio_mask = 0x1f, |
308 | .mwdma_mask = 0x07, | 308 | .mwdma_mask = 0x07, |
309 | .port_ops = &sl82c105_port_ops | 309 | .port_ops = &sl82c105_port_ops |
310 | }; | 310 | }; |
311 | static struct ata_port_info info_early = { | 311 | static const struct ata_port_info info_early = { |
312 | .sht = &sl82c105_sht, | 312 | .sht = &sl82c105_sht, |
313 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 313 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
314 | .pio_mask = 0x1f, | 314 | .pio_mask = 0x1f, |
315 | .port_ops = &sl82c105_port_ops | 315 | .port_ops = &sl82c105_port_ops |
316 | }; | 316 | }; |
317 | static struct ata_port_info *port_info[2] = { &info_early, &info_early }; | 317 | /* for now use only the first port */ |
318 | const struct ata_port_info *ppi[] = { &info_early, | ||
319 | &ata_dummy_port_info }; | ||
318 | u32 val; | 320 | u32 val; |
319 | int rev; | 321 | int rev; |
320 | 322 | ||
@@ -324,17 +326,14 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
324 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); | 326 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); |
325 | else if (rev <= 5) | 327 | else if (rev <= 5) |
326 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); | 328 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); |
327 | else { | 329 | else |
328 | port_info[0] = &info_dma; | 330 | ppi[0] = &info_dma; |
329 | port_info[1] = &info_dma; | ||
330 | } | ||
331 | 331 | ||
332 | pci_read_config_dword(dev, 0x40, &val); | 332 | pci_read_config_dword(dev, 0x40, &val); |
333 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; | 333 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; |
334 | pci_write_config_dword(dev, 0x40, val); | 334 | pci_write_config_dword(dev, 0x40, val); |
335 | 335 | ||
336 | 336 | return ata_pci_init_one(dev, ppi); | |
337 | return ata_pci_init_one(dev, port_info, 1); /* For now */ | ||
338 | } | 337 | } |
339 | 338 | ||
340 | static const struct pci_device_id sl82c105[] = { | 339 | static const struct pci_device_id sl82c105[] = { |
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c index 349887bf5b93..b1d3076dfe51 100644 --- a/drivers/ata/pata_triflex.c +++ b/drivers/ata/pata_triflex.c | |||
@@ -194,10 +194,6 @@ static struct scsi_host_template triflex_sht = { | |||
194 | .slave_configure = ata_scsi_slave_config, | 194 | .slave_configure = ata_scsi_slave_config, |
195 | .slave_destroy = ata_scsi_slave_destroy, | 195 | .slave_destroy = ata_scsi_slave_destroy, |
196 | .bios_param = ata_std_bios_param, | 196 | .bios_param = ata_std_bios_param, |
197 | #ifdef CONFIG_PM | ||
198 | .resume = ata_scsi_device_resume, | ||
199 | .suspend = ata_scsi_device_suspend, | ||
200 | #endif | ||
201 | }; | 197 | }; |
202 | 198 | ||
203 | static struct ata_port_operations triflex_port_ops = { | 199 | static struct ata_port_operations triflex_port_ops = { |
@@ -237,20 +233,20 @@ static struct ata_port_operations triflex_port_ops = { | |||
237 | 233 | ||
238 | static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 234 | static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
239 | { | 235 | { |
240 | static struct ata_port_info info = { | 236 | static const struct ata_port_info info = { |
241 | .sht = &triflex_sht, | 237 | .sht = &triflex_sht, |
242 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 238 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
243 | .pio_mask = 0x1f, | 239 | .pio_mask = 0x1f, |
244 | .mwdma_mask = 0x07, | 240 | .mwdma_mask = 0x07, |
245 | .port_ops = &triflex_port_ops | 241 | .port_ops = &triflex_port_ops |
246 | }; | 242 | }; |
247 | static struct ata_port_info *port_info[2] = { &info, &info }; | 243 | const struct ata_port_info *ppi[] = { &info, NULL }; |
248 | static int printed_version; | 244 | static int printed_version; |
249 | 245 | ||
250 | if (!printed_version++) | 246 | if (!printed_version++) |
251 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); | 247 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); |
252 | 248 | ||
253 | return ata_pci_init_one(dev, port_info, 2); | 249 | return ata_pci_init_one(dev, ppi); |
254 | } | 250 | } |
255 | 251 | ||
256 | static const struct pci_device_id triflex[] = { | 252 | static const struct pci_device_id triflex[] = { |
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 362beb2f489c..e4c71f76bd55 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -301,10 +301,6 @@ static struct scsi_host_template via_sht = { | |||
301 | .slave_configure = ata_scsi_slave_config, | 301 | .slave_configure = ata_scsi_slave_config, |
302 | .slave_destroy = ata_scsi_slave_destroy, | 302 | .slave_destroy = ata_scsi_slave_destroy, |
303 | .bios_param = ata_std_bios_param, | 303 | .bios_param = ata_std_bios_param, |
304 | #ifdef CONFIG_PM | ||
305 | .resume = ata_scsi_device_resume, | ||
306 | .suspend = ata_scsi_device_suspend, | ||
307 | #endif | ||
308 | }; | 304 | }; |
309 | 305 | ||
310 | static struct ata_port_operations via_port_ops = { | 306 | static struct ata_port_operations via_port_ops = { |
@@ -425,7 +421,7 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags) | |||
425 | static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 421 | static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
426 | { | 422 | { |
427 | /* Early VIA without UDMA support */ | 423 | /* Early VIA without UDMA support */ |
428 | static struct ata_port_info via_mwdma_info = { | 424 | static const struct ata_port_info via_mwdma_info = { |
429 | .sht = &via_sht, | 425 | .sht = &via_sht, |
430 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 426 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
431 | .pio_mask = 0x1f, | 427 | .pio_mask = 0x1f, |
@@ -433,7 +429,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
433 | .port_ops = &via_port_ops | 429 | .port_ops = &via_port_ops |
434 | }; | 430 | }; |
435 | /* Ditto with IRQ masking required */ | 431 | /* Ditto with IRQ masking required */ |
436 | static struct ata_port_info via_mwdma_info_borked = { | 432 | static const struct ata_port_info via_mwdma_info_borked = { |
437 | .sht = &via_sht, | 433 | .sht = &via_sht, |
438 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 434 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
439 | .pio_mask = 0x1f, | 435 | .pio_mask = 0x1f, |
@@ -441,7 +437,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
441 | .port_ops = &via_port_ops_noirq, | 437 | .port_ops = &via_port_ops_noirq, |
442 | }; | 438 | }; |
443 | /* VIA UDMA 33 devices (and borked 66) */ | 439 | /* VIA UDMA 33 devices (and borked 66) */ |
444 | static struct ata_port_info via_udma33_info = { | 440 | static const struct ata_port_info via_udma33_info = { |
445 | .sht = &via_sht, | 441 | .sht = &via_sht, |
446 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 442 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
447 | .pio_mask = 0x1f, | 443 | .pio_mask = 0x1f, |
@@ -450,7 +446,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
450 | .port_ops = &via_port_ops | 446 | .port_ops = &via_port_ops |
451 | }; | 447 | }; |
452 | /* VIA UDMA 66 devices */ | 448 | /* VIA UDMA 66 devices */ |
453 | static struct ata_port_info via_udma66_info = { | 449 | static const struct ata_port_info via_udma66_info = { |
454 | .sht = &via_sht, | 450 | .sht = &via_sht, |
455 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 451 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
456 | .pio_mask = 0x1f, | 452 | .pio_mask = 0x1f, |
@@ -459,7 +455,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
459 | .port_ops = &via_port_ops | 455 | .port_ops = &via_port_ops |
460 | }; | 456 | }; |
461 | /* VIA UDMA 100 devices */ | 457 | /* VIA UDMA 100 devices */ |
462 | static struct ata_port_info via_udma100_info = { | 458 | static const struct ata_port_info via_udma100_info = { |
463 | .sht = &via_sht, | 459 | .sht = &via_sht, |
464 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 460 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
465 | .pio_mask = 0x1f, | 461 | .pio_mask = 0x1f, |
@@ -468,7 +464,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
468 | .port_ops = &via_port_ops | 464 | .port_ops = &via_port_ops |
469 | }; | 465 | }; |
470 | /* UDMA133 with bad AST (All current 133) */ | 466 | /* UDMA133 with bad AST (All current 133) */ |
471 | static struct ata_port_info via_udma133_info = { | 467 | static const struct ata_port_info via_udma133_info = { |
472 | .sht = &via_sht, | 468 | .sht = &via_sht, |
473 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 469 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
474 | .pio_mask = 0x1f, | 470 | .pio_mask = 0x1f, |
@@ -476,7 +472,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
476 | .udma_mask = 0x7f, /* FIXME: should check north bridge */ | 472 | .udma_mask = 0x7f, /* FIXME: should check north bridge */ |
477 | .port_ops = &via_port_ops | 473 | .port_ops = &via_port_ops |
478 | }; | 474 | }; |
479 | struct ata_port_info *port_info[2], *type; | 475 | struct ata_port_info type; |
476 | const struct ata_port_info *ppi[] = { &type, NULL }; | ||
480 | struct pci_dev *isa = NULL; | 477 | struct pci_dev *isa = NULL; |
481 | const struct via_isa_bridge *config; | 478 | const struct via_isa_bridge *config; |
482 | static int printed_version; | 479 | static int printed_version; |
@@ -521,25 +518,25 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
521 | switch(config->flags & VIA_UDMA) { | 518 | switch(config->flags & VIA_UDMA) { |
522 | case VIA_UDMA_NONE: | 519 | case VIA_UDMA_NONE: |
523 | if (config->flags & VIA_NO_UNMASK) | 520 | if (config->flags & VIA_NO_UNMASK) |
524 | type = &via_mwdma_info_borked; | 521 | type = via_mwdma_info_borked; |
525 | else | 522 | else |
526 | type = &via_mwdma_info; | 523 | type = via_mwdma_info; |
527 | break; | 524 | break; |
528 | case VIA_UDMA_33: | 525 | case VIA_UDMA_33: |
529 | type = &via_udma33_info; | 526 | type = via_udma33_info; |
530 | break; | 527 | break; |
531 | case VIA_UDMA_66: | 528 | case VIA_UDMA_66: |
532 | type = &via_udma66_info; | 529 | type = via_udma66_info; |
533 | /* The 66 MHz devices require we enable the clock */ | 530 | /* The 66 MHz devices require we enable the clock */ |
534 | pci_read_config_dword(pdev, 0x50, &timing); | 531 | pci_read_config_dword(pdev, 0x50, &timing); |
535 | timing |= 0x80008; | 532 | timing |= 0x80008; |
536 | pci_write_config_dword(pdev, 0x50, timing); | 533 | pci_write_config_dword(pdev, 0x50, timing); |
537 | break; | 534 | break; |
538 | case VIA_UDMA_100: | 535 | case VIA_UDMA_100: |
539 | type = &via_udma100_info; | 536 | type = via_udma100_info; |
540 | break; | 537 | break; |
541 | case VIA_UDMA_133: | 538 | case VIA_UDMA_133: |
542 | type = &via_udma133_info; | 539 | type = via_udma133_info; |
543 | break; | 540 | break; |
544 | default: | 541 | default: |
545 | WARN_ON(1); | 542 | WARN_ON(1); |
@@ -554,10 +551,9 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
554 | } | 551 | } |
555 | 552 | ||
556 | /* We have established the device type, now fire it up */ | 553 | /* We have established the device type, now fire it up */ |
557 | type->private_data = (void *)config; | 554 | type.private_data = (void *)config; |
558 | 555 | ||
559 | port_info[0] = port_info[1] = type; | 556 | return ata_pci_init_one(pdev, ppi); |
560 | return ata_pci_init_one(pdev, port_info, 2); | ||
561 | } | 557 | } |
562 | 558 | ||
563 | #ifdef CONFIG_PM | 559 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index b3b62e985f19..bda5e7747c21 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c | |||
@@ -135,10 +135,6 @@ static struct scsi_host_template inic_sht = { | |||
135 | .slave_configure = inic_slave_config, | 135 | .slave_configure = inic_slave_config, |
136 | .slave_destroy = ata_scsi_slave_destroy, | 136 | .slave_destroy = ata_scsi_slave_destroy, |
137 | .bios_param = ata_std_bios_param, | 137 | .bios_param = ata_std_bios_param, |
138 | #ifdef CONFIG_PM | ||
139 | .suspend = ata_scsi_device_suspend, | ||
140 | .resume = ata_scsi_device_resume, | ||
141 | #endif | ||
142 | }; | 138 | }; |
143 | 139 | ||
144 | static const int scr_map[] = { | 140 | static const int scr_map[] = { |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index a097595d4dc7..4cea3ef75226 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -325,10 +325,6 @@ static struct scsi_host_template nv_sht = { | |||
325 | .slave_configure = ata_scsi_slave_config, | 325 | .slave_configure = ata_scsi_slave_config, |
326 | .slave_destroy = ata_scsi_slave_destroy, | 326 | .slave_destroy = ata_scsi_slave_destroy, |
327 | .bios_param = ata_std_bios_param, | 327 | .bios_param = ata_std_bios_param, |
328 | #ifdef CONFIG_PM | ||
329 | .suspend = ata_scsi_device_suspend, | ||
330 | .resume = ata_scsi_device_resume, | ||
331 | #endif | ||
332 | }; | 328 | }; |
333 | 329 | ||
334 | static struct scsi_host_template nv_adma_sht = { | 330 | static struct scsi_host_template nv_adma_sht = { |
@@ -347,10 +343,6 @@ static struct scsi_host_template nv_adma_sht = { | |||
347 | .slave_configure = nv_adma_slave_config, | 343 | .slave_configure = nv_adma_slave_config, |
348 | .slave_destroy = ata_scsi_slave_destroy, | 344 | .slave_destroy = ata_scsi_slave_destroy, |
349 | .bios_param = ata_std_bios_param, | 345 | .bios_param = ata_std_bios_param, |
350 | #ifdef CONFIG_PM | ||
351 | .suspend = ata_scsi_device_suspend, | ||
352 | .resume = ata_scsi_device_resume, | ||
353 | #endif | ||
354 | }; | 346 | }; |
355 | 347 | ||
356 | static const struct ata_port_operations nv_generic_ops = { | 348 | static const struct ata_port_operations nv_generic_ops = { |
@@ -465,7 +457,7 @@ static const struct ata_port_operations nv_adma_ops = { | |||
465 | .host_stop = nv_adma_host_stop, | 457 | .host_stop = nv_adma_host_stop, |
466 | }; | 458 | }; |
467 | 459 | ||
468 | static struct ata_port_info nv_port_info[] = { | 460 | static const struct ata_port_info nv_port_info[] = { |
469 | /* generic */ | 461 | /* generic */ |
470 | { | 462 | { |
471 | .sht = &nv_sht, | 463 | .sht = &nv_sht, |
@@ -1545,7 +1537,7 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1545 | static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1537 | static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
1546 | { | 1538 | { |
1547 | static int printed_version = 0; | 1539 | static int printed_version = 0; |
1548 | const struct ata_port_info *ppi[2]; | 1540 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
1549 | struct ata_host *host; | 1541 | struct ata_host *host; |
1550 | struct nv_host_priv *hpriv; | 1542 | struct nv_host_priv *hpriv; |
1551 | int rc; | 1543 | int rc; |
@@ -1573,8 +1565,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1573 | type = ADMA; | 1565 | type = ADMA; |
1574 | } | 1566 | } |
1575 | 1567 | ||
1576 | ppi[0] = ppi[1] = &nv_port_info[type]; | 1568 | ppi[0] = &nv_port_info[type]; |
1577 | rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); | 1569 | rc = ata_pci_prepare_native_host(pdev, ppi, &host); |
1578 | if (rc) | 1570 | if (rc) |
1579 | return rc; | 1571 | return rc; |
1580 | 1572 | ||
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 0a1e417f309c..e8483aadd11b 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -182,10 +182,6 @@ static struct scsi_host_template sil_sht = { | |||
182 | .slave_configure = ata_scsi_slave_config, | 182 | .slave_configure = ata_scsi_slave_config, |
183 | .slave_destroy = ata_scsi_slave_destroy, | 183 | .slave_destroy = ata_scsi_slave_destroy, |
184 | .bios_param = ata_std_bios_param, | 184 | .bios_param = ata_std_bios_param, |
185 | #ifdef CONFIG_PM | ||
186 | .suspend = ata_scsi_device_suspend, | ||
187 | .resume = ata_scsi_device_resume, | ||
188 | #endif | ||
189 | }; | 185 | }; |
190 | 186 | ||
191 | static const struct ata_port_operations sil_ops = { | 187 | static const struct ata_port_operations sil_ops = { |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index b97ee9f31aec..a69d78cd8e9b 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -380,10 +380,6 @@ static struct scsi_host_template sil24_sht = { | |||
380 | .slave_configure = ata_scsi_slave_config, | 380 | .slave_configure = ata_scsi_slave_config, |
381 | .slave_destroy = ata_scsi_slave_destroy, | 381 | .slave_destroy = ata_scsi_slave_destroy, |
382 | .bios_param = ata_std_bios_param, | 382 | .bios_param = ata_std_bios_param, |
383 | #ifdef CONFIG_PM | ||
384 | .suspend = ata_scsi_device_suspend, | ||
385 | .resume = ata_scsi_device_resume, | ||
386 | #endif | ||
387 | }; | 383 | }; |
388 | 384 | ||
389 | static const struct ata_port_operations sil24_ops = { | 385 | static const struct ata_port_operations sil24_ops = { |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index d8ee062e82fc..ee66c5fa7ac8 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -129,7 +129,7 @@ static const struct ata_port_operations sis_ops = { | |||
129 | .port_start = ata_port_start, | 129 | .port_start = ata_port_start, |
130 | }; | 130 | }; |
131 | 131 | ||
132 | static struct ata_port_info sis_port_info = { | 132 | static const struct ata_port_info sis_port_info = { |
133 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, | 133 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, |
134 | .pio_mask = 0x1f, | 134 | .pio_mask = 0x1f, |
135 | .mwdma_mask = 0x7, | 135 | .mwdma_mask = 0x7, |
@@ -255,7 +255,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
255 | { | 255 | { |
256 | static int printed_version; | 256 | static int printed_version; |
257 | struct ata_port_info pi = sis_port_info; | 257 | struct ata_port_info pi = sis_port_info; |
258 | const struct ata_port_info *ppi[2] = { &pi, &pi }; | 258 | const struct ata_port_info *ppi[] = { &pi, NULL }; |
259 | struct ata_host *host; | 259 | struct ata_host *host; |
260 | u32 genctl, val; | 260 | u32 genctl, val; |
261 | u8 pmr; | 261 | u8 pmr; |
@@ -335,7 +335,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
335 | break; | 335 | break; |
336 | } | 336 | } |
337 | 337 | ||
338 | rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); | 338 | rc = ata_pci_prepare_native_host(pdev, ppi, &host); |
339 | if (rc) | 339 | if (rc) |
340 | return rc; | 340 | return rc; |
341 | 341 | ||
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index f74e383de083..006f5e352658 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -125,7 +125,7 @@ static const struct ata_port_operations uli_ops = { | |||
125 | .port_start = ata_port_start, | 125 | .port_start = ata_port_start, |
126 | }; | 126 | }; |
127 | 127 | ||
128 | static struct ata_port_info uli_port_info = { | 128 | static const struct ata_port_info uli_port_info = { |
129 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 129 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
130 | ATA_FLAG_IGN_SIMPLEX, | 130 | ATA_FLAG_IGN_SIMPLEX, |
131 | .pio_mask = 0x1f, /* pio0-4 */ | 131 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -201,19 +201,33 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
201 | n_ports = 2; | 201 | n_ports = 2; |
202 | if (board_idx == uli_5287) | 202 | if (board_idx == uli_5287) |
203 | n_ports = 4; | 203 | n_ports = 4; |
204 | rc = ata_pci_prepare_native_host(pdev, ppi, n_ports, &host); | 204 | |
205 | if (rc) | 205 | /* allocate the host */ |
206 | return rc; | 206 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); |
207 | if (!host) | ||
208 | return -ENOMEM; | ||
207 | 209 | ||
208 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); | 210 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
209 | if (!hpriv) | 211 | if (!hpriv) |
210 | return -ENOMEM; | 212 | return -ENOMEM; |
211 | host->private_data = hpriv; | 213 | host->private_data = hpriv; |
212 | 214 | ||
215 | /* the first two ports are standard SFF */ | ||
216 | rc = ata_pci_init_native_host(host); | ||
217 | if (rc) | ||
218 | return rc; | ||
219 | |||
220 | rc = ata_pci_init_bmdma(host); | ||
221 | if (rc) | ||
222 | return rc; | ||
223 | |||
213 | iomap = host->iomap; | 224 | iomap = host->iomap; |
214 | 225 | ||
215 | switch (board_idx) { | 226 | switch (board_idx) { |
216 | case uli_5287: | 227 | case uli_5287: |
228 | /* If there are four, the last two live right after | ||
229 | * the standard SFF ports. | ||
230 | */ | ||
217 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; | 231 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; |
218 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; | 232 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; |
219 | 233 | ||
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 939c9246fdd1..d105d2c189d2 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -116,10 +116,6 @@ static struct scsi_host_template svia_sht = { | |||
116 | .slave_configure = ata_scsi_slave_config, | 116 | .slave_configure = ata_scsi_slave_config, |
117 | .slave_destroy = ata_scsi_slave_destroy, | 117 | .slave_destroy = ata_scsi_slave_destroy, |
118 | .bios_param = ata_std_bios_param, | 118 | .bios_param = ata_std_bios_param, |
119 | #ifdef CONFIG_PM | ||
120 | .suspend = ata_scsi_device_suspend, | ||
121 | .resume = ata_scsi_device_resume, | ||
122 | #endif | ||
123 | }; | 119 | }; |
124 | 120 | ||
125 | static const struct ata_port_operations vt6420_sata_ops = { | 121 | static const struct ata_port_operations vt6420_sata_ops = { |
@@ -415,7 +411,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) | |||
415 | struct ata_host *host; | 411 | struct ata_host *host; |
416 | int rc; | 412 | int rc; |
417 | 413 | ||
418 | rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); | 414 | rc = ata_pci_prepare_native_host(pdev, ppi, &host); |
419 | if (rc) | 415 | if (rc) |
420 | return rc; | 416 | return rc; |
421 | *r_host = host; | 417 | *r_host = host; |
diff --git a/drivers/ata/sis.h b/drivers/ata/sis.h index 231da8fc2200..0f2208d8d5ef 100644 --- a/drivers/ata/sis.h +++ b/drivers/ata/sis.h | |||
@@ -2,4 +2,4 @@ | |||
2 | struct ata_port_info; | 2 | struct ata_port_info; |
3 | 3 | ||
4 | /* pata_sis.c */ | 4 | /* pata_sis.c */ |
5 | extern struct ata_port_info sis_info133; | 5 | extern const struct ata_port_info sis_info133; |
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig index 33687454eb32..f5a47a48c3b4 100644 --- a/drivers/atm/Kconfig +++ b/drivers/atm/Kconfig | |||
@@ -2,19 +2,22 @@ | |||
2 | # ATM device configuration | 2 | # ATM device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "ATM drivers" | 5 | menuconfig ATM_DRIVERS |
6 | bool "ATM drivers" | ||
6 | depends on NETDEVICES && ATM | 7 | depends on NETDEVICES && ATM |
8 | default y | ||
9 | |||
10 | if ATM_DRIVERS | ||
7 | 11 | ||
8 | config ATM_DUMMY | 12 | config ATM_DUMMY |
9 | tristate "Dummy ATM driver" | 13 | tristate "Dummy ATM driver" |
10 | depends on ATM | ||
11 | help | 14 | help |
12 | Dummy ATM driver. Useful for proxy signalling, testing, | 15 | Dummy ATM driver. Useful for proxy signalling, testing, |
13 | and development. If unsure, say N. | 16 | and development. If unsure, say N. |
14 | 17 | ||
15 | config ATM_TCP | 18 | config ATM_TCP |
16 | tristate "ATM over TCP" | 19 | tristate "ATM over TCP" |
17 | depends on INET && ATM | 20 | depends on INET |
18 | help | 21 | help |
19 | ATM over TCP driver. Useful mainly for development and for | 22 | ATM over TCP driver. Useful mainly for development and for |
20 | experiments. If unsure, say N. | 23 | experiments. If unsure, say N. |
@@ -30,7 +33,7 @@ config ATM_LANAI | |||
30 | 33 | ||
31 | config ATM_ENI | 34 | config ATM_ENI |
32 | tristate "Efficient Networks ENI155P" | 35 | tristate "Efficient Networks ENI155P" |
33 | depends on PCI && ATM | 36 | depends on PCI |
34 | ---help--- | 37 | ---help--- |
35 | Driver for the Efficient Networks ENI155p series and SMC ATM | 38 | Driver for the Efficient Networks ENI155p series and SMC ATM |
36 | Power155 155 Mbps ATM adapters. Both, the versions with 512KB and | 39 | Power155 155 Mbps ATM adapters. Both, the versions with 512KB and |
@@ -139,7 +142,7 @@ config ATM_ENI_BURST_RX_2W | |||
139 | 142 | ||
140 | config ATM_FIRESTREAM | 143 | config ATM_FIRESTREAM |
141 | tristate "Fujitsu FireStream (FS50/FS155) " | 144 | tristate "Fujitsu FireStream (FS50/FS155) " |
142 | depends on PCI && ATM | 145 | depends on PCI |
143 | help | 146 | help |
144 | Driver for the Fujitsu FireStream 155 (MB86697) and | 147 | Driver for the Fujitsu FireStream 155 (MB86697) and |
145 | FireStream 50 (MB86695) ATM PCI chips. | 148 | FireStream 50 (MB86695) ATM PCI chips. |
@@ -149,7 +152,7 @@ config ATM_FIRESTREAM | |||
149 | 152 | ||
150 | config ATM_ZATM | 153 | config ATM_ZATM |
151 | tristate "ZeitNet ZN1221/ZN1225" | 154 | tristate "ZeitNet ZN1221/ZN1225" |
152 | depends on PCI && ATM | 155 | depends on PCI |
153 | help | 156 | help |
154 | Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM | 157 | Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM |
155 | adapters. | 158 | adapters. |
@@ -169,7 +172,7 @@ config ATM_ZATM_DEBUG | |||
169 | 172 | ||
170 | config ATM_NICSTAR | 173 | config ATM_NICSTAR |
171 | tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" | 174 | tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" |
172 | depends on PCI && ATM && !64BIT | 175 | depends on PCI && !64BIT |
173 | help | 176 | help |
174 | The NICStAR chipset family is used in a large number of ATM NICs for | 177 | The NICStAR chipset family is used in a large number of ATM NICs for |
175 | 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE | 178 | 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE |
@@ -202,7 +205,7 @@ config ATM_NICSTAR_USE_IDT77105 | |||
202 | 205 | ||
203 | config ATM_IDT77252 | 206 | config ATM_IDT77252 |
204 | tristate "IDT 77252 (NICStAR II)" | 207 | tristate "IDT 77252 (NICStAR II)" |
205 | depends on PCI && ATM | 208 | depends on PCI |
206 | help | 209 | help |
207 | Driver for the IDT 77252 ATM PCI chips. | 210 | Driver for the IDT 77252 ATM PCI chips. |
208 | 211 | ||
@@ -237,7 +240,7 @@ config ATM_IDT77252_USE_SUNI | |||
237 | 240 | ||
238 | config ATM_AMBASSADOR | 241 | config ATM_AMBASSADOR |
239 | tristate "Madge Ambassador (Collage PCI 155 Server)" | 242 | tristate "Madge Ambassador (Collage PCI 155 Server)" |
240 | depends on PCI && ATM | 243 | depends on PCI |
241 | select BITREVERSE | 244 | select BITREVERSE |
242 | help | 245 | help |
243 | This is a driver for ATMizer based ATM card produced by Madge | 246 | This is a driver for ATMizer based ATM card produced by Madge |
@@ -262,7 +265,7 @@ config ATM_AMBASSADOR_DEBUG | |||
262 | 265 | ||
263 | config ATM_HORIZON | 266 | config ATM_HORIZON |
264 | tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)" | 267 | tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)" |
265 | depends on PCI && ATM | 268 | depends on PCI |
266 | help | 269 | help |
267 | This is a driver for the Horizon chipset ATM adapter cards once | 270 | This is a driver for the Horizon chipset ATM adapter cards once |
268 | produced by Madge Networks Ltd. Say Y (or M to compile as a module | 271 | produced by Madge Networks Ltd. Say Y (or M to compile as a module |
@@ -286,7 +289,7 @@ config ATM_HORIZON_DEBUG | |||
286 | 289 | ||
287 | config ATM_IA | 290 | config ATM_IA |
288 | tristate "Interphase ATM PCI x575/x525/x531" | 291 | tristate "Interphase ATM PCI x575/x525/x531" |
289 | depends on PCI && ATM && !64BIT | 292 | depends on PCI && !64BIT |
290 | ---help--- | 293 | ---help--- |
291 | This is a driver for the Interphase (i)ChipSAR adapter cards | 294 | This is a driver for the Interphase (i)ChipSAR adapter cards |
292 | which include a variety of variants in term of the size of the | 295 | which include a variety of variants in term of the size of the |
@@ -319,7 +322,7 @@ config ATM_IA_DEBUG | |||
319 | 322 | ||
320 | config ATM_FORE200E_MAYBE | 323 | config ATM_FORE200E_MAYBE |
321 | tristate "FORE Systems 200E-series" | 324 | tristate "FORE Systems 200E-series" |
322 | depends on (PCI || SBUS) && ATM | 325 | depends on PCI || SBUS |
323 | ---help--- | 326 | ---help--- |
324 | This is a driver for the FORE Systems 200E-series ATM adapter | 327 | This is a driver for the FORE Systems 200E-series ATM adapter |
325 | cards. It simultaneously supports PCA-200E and SBA-200E models | 328 | cards. It simultaneously supports PCA-200E and SBA-200E models |
@@ -436,7 +439,7 @@ config ATM_FORE200E | |||
436 | 439 | ||
437 | config ATM_HE | 440 | config ATM_HE |
438 | tristate "ForeRunner HE Series" | 441 | tristate "ForeRunner HE Series" |
439 | depends on PCI && ATM | 442 | depends on PCI |
440 | help | 443 | help |
441 | This is a driver for the Marconi ForeRunner HE-series ATM adapter | 444 | This is a driver for the Marconi ForeRunner HE-series ATM adapter |
442 | cards. It simultaneously supports the 155 and 622 versions. | 445 | cards. It simultaneously supports the 155 and 622 versions. |
@@ -448,5 +451,4 @@ config ATM_HE_USE_SUNI | |||
448 | Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner | 451 | Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner |
449 | HE cards. This driver provides carrier detection some statistics. | 452 | HE cards. This driver provides carrier detection some statistics. |
450 | 453 | ||
451 | endmenu | 454 | endif # ATM |
452 | |||
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 18cdd8c77626..e2fc4b6734cf 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1317,18 +1317,6 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a | |||
1317 | } | 1317 | } |
1318 | #endif | 1318 | #endif |
1319 | 1319 | ||
1320 | static struct loop_device *loop_find_dev(int number) | ||
1321 | { | ||
1322 | struct loop_device *lo; | ||
1323 | |||
1324 | list_for_each_entry(lo, &loop_devices, lo_list) { | ||
1325 | if (lo->lo_number == number) | ||
1326 | return lo; | ||
1327 | } | ||
1328 | return NULL; | ||
1329 | } | ||
1330 | |||
1331 | static struct loop_device *loop_init_one(int i); | ||
1332 | static int lo_open(struct inode *inode, struct file *file) | 1320 | static int lo_open(struct inode *inode, struct file *file) |
1333 | { | 1321 | { |
1334 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1322 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
@@ -1337,11 +1325,6 @@ static int lo_open(struct inode *inode, struct file *file) | |||
1337 | lo->lo_refcnt++; | 1325 | lo->lo_refcnt++; |
1338 | mutex_unlock(&lo->lo_ctl_mutex); | 1326 | mutex_unlock(&lo->lo_ctl_mutex); |
1339 | 1327 | ||
1340 | mutex_lock(&loop_devices_mutex); | ||
1341 | if (!loop_find_dev(lo->lo_number + 1)) | ||
1342 | loop_init_one(lo->lo_number + 1); | ||
1343 | mutex_unlock(&loop_devices_mutex); | ||
1344 | |||
1345 | return 0; | 1328 | return 0; |
1346 | } | 1329 | } |
1347 | 1330 | ||
@@ -1448,7 +1431,7 @@ out_free_queue: | |||
1448 | out_free_dev: | 1431 | out_free_dev: |
1449 | kfree(lo); | 1432 | kfree(lo); |
1450 | out: | 1433 | out: |
1451 | return ERR_PTR(-ENOMEM); | 1434 | return NULL; |
1452 | } | 1435 | } |
1453 | 1436 | ||
1454 | static void loop_del_one(struct loop_device *lo) | 1437 | static void loop_del_one(struct loop_device *lo) |
@@ -1460,36 +1443,30 @@ static void loop_del_one(struct loop_device *lo) | |||
1460 | kfree(lo); | 1443 | kfree(lo); |
1461 | } | 1444 | } |
1462 | 1445 | ||
1446 | static int loop_lock(dev_t dev, void *data) | ||
1447 | { | ||
1448 | mutex_lock(&loop_devices_mutex); | ||
1449 | return 0; | ||
1450 | } | ||
1451 | |||
1463 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) | 1452 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) |
1464 | { | 1453 | { |
1465 | unsigned int number = dev & MINORMASK; | 1454 | struct loop_device *lo = loop_init_one(dev & MINORMASK); |
1466 | struct loop_device *lo; | 1455 | struct kobject *kobj; |
1467 | 1456 | ||
1468 | mutex_lock(&loop_devices_mutex); | 1457 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); |
1469 | lo = loop_find_dev(number); | ||
1470 | if (lo == NULL) | ||
1471 | lo = loop_init_one(number); | ||
1472 | mutex_unlock(&loop_devices_mutex); | 1458 | mutex_unlock(&loop_devices_mutex); |
1473 | 1459 | ||
1474 | *part = 0; | 1460 | *part = 0; |
1475 | if (IS_ERR(lo)) | 1461 | return kobj; |
1476 | return (void *)lo; | ||
1477 | else | ||
1478 | return &lo->lo_disk->kobj; | ||
1479 | } | 1462 | } |
1480 | 1463 | ||
1481 | static int __init loop_init(void) | 1464 | static int __init loop_init(void) |
1482 | { | 1465 | { |
1483 | struct loop_device *lo; | ||
1484 | |||
1485 | if (register_blkdev(LOOP_MAJOR, "loop")) | 1466 | if (register_blkdev(LOOP_MAJOR, "loop")) |
1486 | return -EIO; | 1467 | return -EIO; |
1487 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, | 1468 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, |
1488 | THIS_MODULE, loop_probe, NULL, NULL); | 1469 | THIS_MODULE, loop_probe, loop_lock, NULL); |
1489 | |||
1490 | lo = loop_init_one(0); | ||
1491 | if (IS_ERR(lo)) | ||
1492 | goto out; | ||
1493 | 1470 | ||
1494 | if (max_loop) { | 1471 | if (max_loop) { |
1495 | printk(KERN_INFO "loop: the max_loop option is obsolete " | 1472 | printk(KERN_INFO "loop: the max_loop option is obsolete " |
@@ -1498,11 +1475,6 @@ static int __init loop_init(void) | |||
1498 | } | 1475 | } |
1499 | printk(KERN_INFO "loop: module loaded\n"); | 1476 | printk(KERN_INFO "loop: module loaded\n"); |
1500 | return 0; | 1477 | return 0; |
1501 | |||
1502 | out: | ||
1503 | unregister_blkdev(LOOP_MAJOR, "loop"); | ||
1504 | printk(KERN_ERR "loop: ran out of memory\n"); | ||
1505 | return -ENOMEM; | ||
1506 | } | 1478 | } |
1507 | 1479 | ||
1508 | static void __exit loop_exit(void) | 1480 | static void __exit loop_exit(void) |
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 0f4203b499af..6055b9c0ac0f 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -307,7 +307,9 @@ static void hci_uart_tty_close(struct tty_struct *tty) | |||
307 | 307 | ||
308 | if (hu) { | 308 | if (hu) { |
309 | struct hci_dev *hdev = hu->hdev; | 309 | struct hci_dev *hdev = hu->hdev; |
310 | hci_uart_close(hdev); | 310 | |
311 | if (hdev) | ||
312 | hci_uart_close(hdev); | ||
311 | 313 | ||
312 | if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { | 314 | if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { |
313 | hu->proto->close(hu); | 315 | hu->proto->close(hu); |
@@ -473,12 +475,18 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, | |||
473 | tty->low_latency = 1; | 475 | tty->low_latency = 1; |
474 | } else | 476 | } else |
475 | return -EBUSY; | 477 | return -EBUSY; |
478 | break; | ||
476 | 479 | ||
477 | case HCIUARTGETPROTO: | 480 | case HCIUARTGETPROTO: |
478 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | 481 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) |
479 | return hu->proto->id; | 482 | return hu->proto->id; |
480 | return -EUNATCH; | 483 | return -EUNATCH; |
481 | 484 | ||
485 | case HCIUARTGETDEVICE: | ||
486 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | ||
487 | return hu->hdev->id; | ||
488 | return -EUNATCH; | ||
489 | |||
482 | default: | 490 | default: |
483 | err = n_tty_ioctl(tty, file, cmd, arg); | 491 | err = n_tty_ioctl(tty, file, cmd, arg); |
484 | break; | 492 | break; |
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index b250e6789dee..1097ce72393f 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h | |||
@@ -28,8 +28,9 @@ | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | /* Ioctls */ | 30 | /* Ioctls */ |
31 | #define HCIUARTSETPROTO _IOW('U', 200, int) | 31 | #define HCIUARTSETPROTO _IOW('U', 200, int) |
32 | #define HCIUARTGETPROTO _IOR('U', 201, int) | 32 | #define HCIUARTGETPROTO _IOR('U', 201, int) |
33 | #define HCIUARTGETDEVICE _IOR('U', 202, int) | ||
33 | 34 | ||
34 | /* UART protocols */ | 35 | /* UART protocols */ |
35 | #define HCI_UART_MAX_PROTO 4 | 36 | #define HCI_UART_MAX_PROTO 4 |
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index c9f0f250d78f..801abdd29066 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -268,7 +268,7 @@ static int __devinit aperture_valid(u64 aper, u32 size) | |||
268 | printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20); | 268 | printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20); |
269 | return 0; | 269 | return 0; |
270 | } | 270 | } |
271 | if (aper + size > 0xffffffff) { | 271 | if ((u64)aper + size > 0x100000000ULL) { |
272 | printk(KERN_ERR PFX "Aperture out of bounds\n"); | 272 | printk(KERN_ERR PFX "Aperture out of bounds\n"); |
273 | return 0; | 273 | return 0; |
274 | } | 274 | } |
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 6c5d15de3317..78e1b962fe35 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -1915,10 +1915,10 @@ static __devinit int try_init_acpi(struct SPMITable *spmi) | |||
1915 | 1915 | ||
1916 | if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { | 1916 | if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { |
1917 | info->io_setup = mem_setup; | 1917 | info->io_setup = mem_setup; |
1918 | info->io.addr_type = IPMI_IO_ADDR_SPACE; | 1918 | info->io.addr_type = IPMI_MEM_ADDR_SPACE; |
1919 | } else if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_IO) { | 1919 | } else if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_IO) { |
1920 | info->io_setup = port_setup; | 1920 | info->io_setup = port_setup; |
1921 | info->io.addr_type = IPMI_MEM_ADDR_SPACE; | 1921 | info->io.addr_type = IPMI_IO_ADDR_SPACE; |
1922 | } else { | 1922 | } else { |
1923 | kfree(info); | 1923 | kfree(info); |
1924 | printk("ipmi_si: Unknown ACPI I/O Address type\n"); | 1924 | printk("ipmi_si: Unknown ACPI I/O Address type\n"); |
@@ -2974,6 +2974,10 @@ static __devinit int init_ipmi_si(void) | |||
2974 | #ifdef CONFIG_PCI | 2974 | #ifdef CONFIG_PCI |
2975 | pci_unregister_driver(&ipmi_pci_driver); | 2975 | pci_unregister_driver(&ipmi_pci_driver); |
2976 | #endif | 2976 | #endif |
2977 | |||
2978 | #ifdef CONFIG_PPC_OF | ||
2979 | of_unregister_platform_driver(&ipmi_of_platform_driver); | ||
2980 | #endif | ||
2977 | driver_unregister(&ipmi_driver); | 2981 | driver_unregister(&ipmi_driver); |
2978 | printk("ipmi_si: Unable to find any System Interface(s)\n"); | 2982 | printk("ipmi_si: Unable to find any System Interface(s)\n"); |
2979 | return -ENODEV; | 2983 | return -ENODEV; |
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 6ac3ca4c723c..b3d4ccc33a47 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -1544,21 +1544,18 @@ static unsigned int normal_poll(struct tty_struct * tty, struct file * file, pol | |||
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | struct tty_ldisc tty_ldisc_N_TTY = { | 1546 | struct tty_ldisc tty_ldisc_N_TTY = { |
1547 | TTY_LDISC_MAGIC, /* magic */ | 1547 | .magic = TTY_LDISC_MAGIC, |
1548 | "n_tty", /* name */ | 1548 | .name = "n_tty", |
1549 | 0, /* num */ | 1549 | .open = n_tty_open, |
1550 | 0, /* flags */ | 1550 | .close = n_tty_close, |
1551 | n_tty_open, /* open */ | 1551 | .flush_buffer = n_tty_flush_buffer, |
1552 | n_tty_close, /* close */ | 1552 | .chars_in_buffer = n_tty_chars_in_buffer, |
1553 | n_tty_flush_buffer, /* flush_buffer */ | 1553 | .read = read_chan, |
1554 | n_tty_chars_in_buffer, /* chars_in_buffer */ | 1554 | .write = write_chan, |
1555 | read_chan, /* read */ | 1555 | .ioctl = n_tty_ioctl, |
1556 | write_chan, /* write */ | 1556 | .set_termios = n_tty_set_termios, |
1557 | n_tty_ioctl, /* ioctl */ | 1557 | .poll = normal_poll, |
1558 | n_tty_set_termios, /* set_termios */ | 1558 | .receive_buf = n_tty_receive_buf, |
1559 | normal_poll, /* poll */ | 1559 | .write_wakeup = n_tty_write_wakeup |
1560 | NULL, /* hangup */ | ||
1561 | n_tty_receive_buf, /* receive_buf */ | ||
1562 | n_tty_write_wakeup /* write_wakeup */ | ||
1563 | }; | 1560 | }; |
1564 | 1561 | ||
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c index 245f03195b7c..8cc60b693460 100644 --- a/drivers/char/rio/riocmd.c +++ b/drivers/char/rio/riocmd.c | |||
@@ -402,7 +402,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc | |||
402 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); | 402 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); |
403 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); | 403 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); |
404 | 404 | ||
405 | if (Rup >= (unsigned short) MAX_RUP) { | 405 | if (Rup < (unsigned short) MAX_RUP) { |
406 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); | 406 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); |
407 | } else | 407 | } else |
408 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); | 408 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); |
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 61a63da420c2..a3fd7e7ba5a9 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c | |||
@@ -1014,9 +1014,6 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
1014 | /* | 1014 | /* |
1015 | * Info->count is now 1; so it's safe to sleep now. | 1015 | * Info->count is now 1; so it's safe to sleep now. |
1016 | */ | 1016 | */ |
1017 | info->session = process_session(current); | ||
1018 | info->pgrp = process_group(current); | ||
1019 | |||
1020 | if ((info->flags & ROCKET_INITIALIZED) == 0) { | 1017 | if ((info->flags & ROCKET_INITIALIZED) == 0) { |
1021 | cp = &info->channel; | 1018 | cp = &info->channel; |
1022 | sSetRxTrigger(cp, TRIG_1); | 1019 | sSetRxTrigger(cp, TRIG_1); |
diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h index 89b4d7b10d12..b4c53dfa7951 100644 --- a/drivers/char/rocket_int.h +++ b/drivers/char/rocket_int.h | |||
@@ -1158,8 +1158,6 @@ struct r_port { | |||
1158 | int xmit_head; | 1158 | int xmit_head; |
1159 | int xmit_tail; | 1159 | int xmit_tail; |
1160 | int xmit_cnt; | 1160 | int xmit_cnt; |
1161 | int session; | ||
1162 | int pgrp; | ||
1163 | int cd_status; | 1161 | int cd_status; |
1164 | int ignore_status_mask; | 1162 | int ignore_status_mask; |
1165 | int read_status_mask; | 1163 | int read_status_mask; |
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c index 2f56e8c54897..1b75b0b7d542 100644 --- a/drivers/char/snsc_event.c +++ b/drivers/char/snsc_event.c | |||
@@ -203,8 +203,6 @@ scdrv_dispatch_event(char *event, int len) | |||
203 | class = (code & EV_CLASS_MASK); | 203 | class = (code & EV_CLASS_MASK); |
204 | 204 | ||
205 | if (class == EV_CLASS_PWRD_NOTIFY || code == ENV_PWRDN_PEND) { | 205 | if (class == EV_CLASS_PWRD_NOTIFY || code == ENV_PWRDN_PEND) { |
206 | struct task_struct *p; | ||
207 | |||
208 | if (snsc_shutting_down) | 206 | if (snsc_shutting_down) |
209 | return; | 207 | return; |
210 | 208 | ||
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 2a7736b5f2f7..02b49bc00028 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -1171,6 +1171,112 @@ static int ioctl(struct tty_struct *tty, struct file *file, | |||
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | /* | 1173 | /* |
1174 | * support for 32 bit ioctl calls on 64 bit systems | ||
1175 | */ | ||
1176 | #ifdef CONFIG_COMPAT | ||
1177 | static long get_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *user_params) | ||
1178 | { | ||
1179 | struct MGSL_PARAMS32 tmp_params; | ||
1180 | |||
1181 | DBGINFO(("%s get_params32\n", info->device_name)); | ||
1182 | tmp_params.mode = (compat_ulong_t)info->params.mode; | ||
1183 | tmp_params.loopback = info->params.loopback; | ||
1184 | tmp_params.flags = info->params.flags; | ||
1185 | tmp_params.encoding = info->params.encoding; | ||
1186 | tmp_params.clock_speed = (compat_ulong_t)info->params.clock_speed; | ||
1187 | tmp_params.addr_filter = info->params.addr_filter; | ||
1188 | tmp_params.crc_type = info->params.crc_type; | ||
1189 | tmp_params.preamble_length = info->params.preamble_length; | ||
1190 | tmp_params.preamble = info->params.preamble; | ||
1191 | tmp_params.data_rate = (compat_ulong_t)info->params.data_rate; | ||
1192 | tmp_params.data_bits = info->params.data_bits; | ||
1193 | tmp_params.stop_bits = info->params.stop_bits; | ||
1194 | tmp_params.parity = info->params.parity; | ||
1195 | if (copy_to_user(user_params, &tmp_params, sizeof(struct MGSL_PARAMS32))) | ||
1196 | return -EFAULT; | ||
1197 | return 0; | ||
1198 | } | ||
1199 | |||
1200 | static long set_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *new_params) | ||
1201 | { | ||
1202 | struct MGSL_PARAMS32 tmp_params; | ||
1203 | |||
1204 | DBGINFO(("%s set_params32\n", info->device_name)); | ||
1205 | if (copy_from_user(&tmp_params, new_params, sizeof(struct MGSL_PARAMS32))) | ||
1206 | return -EFAULT; | ||
1207 | |||
1208 | spin_lock(&info->lock); | ||
1209 | info->params.mode = tmp_params.mode; | ||
1210 | info->params.loopback = tmp_params.loopback; | ||
1211 | info->params.flags = tmp_params.flags; | ||
1212 | info->params.encoding = tmp_params.encoding; | ||
1213 | info->params.clock_speed = tmp_params.clock_speed; | ||
1214 | info->params.addr_filter = tmp_params.addr_filter; | ||
1215 | info->params.crc_type = tmp_params.crc_type; | ||
1216 | info->params.preamble_length = tmp_params.preamble_length; | ||
1217 | info->params.preamble = tmp_params.preamble; | ||
1218 | info->params.data_rate = tmp_params.data_rate; | ||
1219 | info->params.data_bits = tmp_params.data_bits; | ||
1220 | info->params.stop_bits = tmp_params.stop_bits; | ||
1221 | info->params.parity = tmp_params.parity; | ||
1222 | spin_unlock(&info->lock); | ||
1223 | |||
1224 | change_params(info); | ||
1225 | |||
1226 | return 0; | ||
1227 | } | ||
1228 | |||
1229 | static long slgt_compat_ioctl(struct tty_struct *tty, struct file *file, | ||
1230 | unsigned int cmd, unsigned long arg) | ||
1231 | { | ||
1232 | struct slgt_info *info = tty->driver_data; | ||
1233 | int rc = -ENOIOCTLCMD; | ||
1234 | |||
1235 | if (sanity_check(info, tty->name, "compat_ioctl")) | ||
1236 | return -ENODEV; | ||
1237 | DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd)); | ||
1238 | |||
1239 | switch (cmd) { | ||
1240 | |||
1241 | case MGSL_IOCSPARAMS32: | ||
1242 | rc = set_params32(info, compat_ptr(arg)); | ||
1243 | break; | ||
1244 | |||
1245 | case MGSL_IOCGPARAMS32: | ||
1246 | rc = get_params32(info, compat_ptr(arg)); | ||
1247 | break; | ||
1248 | |||
1249 | case MGSL_IOCGPARAMS: | ||
1250 | case MGSL_IOCSPARAMS: | ||
1251 | case MGSL_IOCGTXIDLE: | ||
1252 | case MGSL_IOCGSTATS: | ||
1253 | case MGSL_IOCWAITEVENT: | ||
1254 | case MGSL_IOCGIF: | ||
1255 | case MGSL_IOCSGPIO: | ||
1256 | case MGSL_IOCGGPIO: | ||
1257 | case MGSL_IOCWAITGPIO: | ||
1258 | case TIOCGICOUNT: | ||
1259 | rc = ioctl(tty, file, cmd, (unsigned long)(compat_ptr(arg))); | ||
1260 | break; | ||
1261 | |||
1262 | case MGSL_IOCSTXIDLE: | ||
1263 | case MGSL_IOCTXENABLE: | ||
1264 | case MGSL_IOCRXENABLE: | ||
1265 | case MGSL_IOCTXABORT: | ||
1266 | case TIOCMIWAIT: | ||
1267 | case MGSL_IOCSIF: | ||
1268 | rc = ioctl(tty, file, cmd, arg); | ||
1269 | break; | ||
1270 | } | ||
1271 | |||
1272 | DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc)); | ||
1273 | return rc; | ||
1274 | } | ||
1275 | #else | ||
1276 | #define slgt_compat_ioctl NULL | ||
1277 | #endif /* ifdef CONFIG_COMPAT */ | ||
1278 | |||
1279 | /* | ||
1174 | * proc fs support | 1280 | * proc fs support |
1175 | */ | 1281 | */ |
1176 | static inline int line_info(char *buf, struct slgt_info *info) | 1282 | static inline int line_info(char *buf, struct slgt_info *info) |
@@ -3446,6 +3552,7 @@ static const struct tty_operations ops = { | |||
3446 | .chars_in_buffer = chars_in_buffer, | 3552 | .chars_in_buffer = chars_in_buffer, |
3447 | .flush_buffer = flush_buffer, | 3553 | .flush_buffer = flush_buffer, |
3448 | .ioctl = ioctl, | 3554 | .ioctl = ioctl, |
3555 | .compat_ioctl = slgt_compat_ioctl, | ||
3449 | .throttle = throttle, | 3556 | .throttle = throttle, |
3450 | .unthrottle = unthrottle, | 3557 | .unthrottle = unthrottle, |
3451 | .send_xchar = send_xchar, | 3558 | .send_xchar = send_xchar, |
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h index c912d8691cbd..9363bcf0a402 100644 --- a/drivers/char/tpm/tpm_atmel.h +++ b/drivers/char/tpm/tpm_atmel.h | |||
@@ -23,6 +23,9 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifdef CONFIG_PPC64 | 25 | #ifdef CONFIG_PPC64 |
26 | |||
27 | #include <asm/prom.h> | ||
28 | |||
26 | #define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset); | 29 | #define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset); |
27 | #define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) | 30 | #define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) |
28 | #define atmel_request_region request_mem_region | 31 | #define atmel_request_region request_mem_region |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index fc662e4ce58a..75d2a46e106f 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -151,6 +151,12 @@ static int tty_open(struct inode *, struct file *); | |||
151 | static int tty_release(struct inode *, struct file *); | 151 | static int tty_release(struct inode *, struct file *); |
152 | int tty_ioctl(struct inode * inode, struct file * file, | 152 | int tty_ioctl(struct inode * inode, struct file * file, |
153 | unsigned int cmd, unsigned long arg); | 153 | unsigned int cmd, unsigned long arg); |
154 | #ifdef CONFIG_COMPAT | ||
155 | static long tty_compat_ioctl(struct file * file, unsigned int cmd, | ||
156 | unsigned long arg); | ||
157 | #else | ||
158 | #define tty_compat_ioctl NULL | ||
159 | #endif | ||
154 | static int tty_fasync(int fd, struct file * filp, int on); | 160 | static int tty_fasync(int fd, struct file * filp, int on); |
155 | static void release_tty(struct tty_struct *tty, int idx); | 161 | static void release_tty(struct tty_struct *tty, int idx); |
156 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); | 162 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); |
@@ -363,6 +369,29 @@ static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b) | |||
363 | } | 369 | } |
364 | 370 | ||
365 | /** | 371 | /** |
372 | * tty_buffer_flush - flush full tty buffers | ||
373 | * @tty: tty to flush | ||
374 | * | ||
375 | * flush all the buffers containing receive data | ||
376 | * | ||
377 | * Locking: none | ||
378 | */ | ||
379 | |||
380 | static void tty_buffer_flush(struct tty_struct *tty) | ||
381 | { | ||
382 | struct tty_buffer *thead; | ||
383 | unsigned long flags; | ||
384 | |||
385 | spin_lock_irqsave(&tty->buf.lock, flags); | ||
386 | while((thead = tty->buf.head) != NULL) { | ||
387 | tty->buf.head = thead->next; | ||
388 | tty_buffer_free(tty, thead); | ||
389 | } | ||
390 | tty->buf.tail = NULL; | ||
391 | spin_unlock_irqrestore(&tty->buf.lock, flags); | ||
392 | } | ||
393 | |||
394 | /** | ||
366 | * tty_buffer_find - find a free tty buffer | 395 | * tty_buffer_find - find a free tty buffer |
367 | * @tty: tty owning the buffer | 396 | * @tty: tty owning the buffer |
368 | * @size: characters wanted | 397 | * @size: characters wanted |
@@ -1143,8 +1172,8 @@ static unsigned int hung_up_tty_poll(struct file * filp, poll_table * wait) | |||
1143 | return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; | 1172 | return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; |
1144 | } | 1173 | } |
1145 | 1174 | ||
1146 | static int hung_up_tty_ioctl(struct inode * inode, struct file * file, | 1175 | static long hung_up_tty_ioctl(struct file * file, |
1147 | unsigned int cmd, unsigned long arg) | 1176 | unsigned int cmd, unsigned long arg) |
1148 | { | 1177 | { |
1149 | return cmd == TIOCSPGRP ? -ENOTTY : -EIO; | 1178 | return cmd == TIOCSPGRP ? -ENOTTY : -EIO; |
1150 | } | 1179 | } |
@@ -1155,6 +1184,7 @@ static const struct file_operations tty_fops = { | |||
1155 | .write = tty_write, | 1184 | .write = tty_write, |
1156 | .poll = tty_poll, | 1185 | .poll = tty_poll, |
1157 | .ioctl = tty_ioctl, | 1186 | .ioctl = tty_ioctl, |
1187 | .compat_ioctl = tty_compat_ioctl, | ||
1158 | .open = tty_open, | 1188 | .open = tty_open, |
1159 | .release = tty_release, | 1189 | .release = tty_release, |
1160 | .fasync = tty_fasync, | 1190 | .fasync = tty_fasync, |
@@ -1167,6 +1197,7 @@ static const struct file_operations ptmx_fops = { | |||
1167 | .write = tty_write, | 1197 | .write = tty_write, |
1168 | .poll = tty_poll, | 1198 | .poll = tty_poll, |
1169 | .ioctl = tty_ioctl, | 1199 | .ioctl = tty_ioctl, |
1200 | .compat_ioctl = tty_compat_ioctl, | ||
1170 | .open = ptmx_open, | 1201 | .open = ptmx_open, |
1171 | .release = tty_release, | 1202 | .release = tty_release, |
1172 | .fasync = tty_fasync, | 1203 | .fasync = tty_fasync, |
@@ -1179,6 +1210,7 @@ static const struct file_operations console_fops = { | |||
1179 | .write = redirected_tty_write, | 1210 | .write = redirected_tty_write, |
1180 | .poll = tty_poll, | 1211 | .poll = tty_poll, |
1181 | .ioctl = tty_ioctl, | 1212 | .ioctl = tty_ioctl, |
1213 | .compat_ioctl = tty_compat_ioctl, | ||
1182 | .open = tty_open, | 1214 | .open = tty_open, |
1183 | .release = tty_release, | 1215 | .release = tty_release, |
1184 | .fasync = tty_fasync, | 1216 | .fasync = tty_fasync, |
@@ -1189,7 +1221,8 @@ static const struct file_operations hung_up_tty_fops = { | |||
1189 | .read = hung_up_tty_read, | 1221 | .read = hung_up_tty_read, |
1190 | .write = hung_up_tty_write, | 1222 | .write = hung_up_tty_write, |
1191 | .poll = hung_up_tty_poll, | 1223 | .poll = hung_up_tty_poll, |
1192 | .ioctl = hung_up_tty_ioctl, | 1224 | .unlocked_ioctl = hung_up_tty_ioctl, |
1225 | .compat_ioctl = hung_up_tty_ioctl, | ||
1193 | .release = tty_release, | 1226 | .release = tty_release, |
1194 | }; | 1227 | }; |
1195 | 1228 | ||
@@ -1238,6 +1271,7 @@ void tty_ldisc_flush(struct tty_struct *tty) | |||
1238 | ld->flush_buffer(tty); | 1271 | ld->flush_buffer(tty); |
1239 | tty_ldisc_deref(ld); | 1272 | tty_ldisc_deref(ld); |
1240 | } | 1273 | } |
1274 | tty_buffer_flush(tty); | ||
1241 | } | 1275 | } |
1242 | 1276 | ||
1243 | EXPORT_SYMBOL_GPL(tty_ldisc_flush); | 1277 | EXPORT_SYMBOL_GPL(tty_ldisc_flush); |
@@ -3340,6 +3374,15 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
3340 | case TIOCMBIC: | 3374 | case TIOCMBIC: |
3341 | case TIOCMBIS: | 3375 | case TIOCMBIS: |
3342 | return tty_tiocmset(tty, file, cmd, p); | 3376 | return tty_tiocmset(tty, file, cmd, p); |
3377 | case TCFLSH: | ||
3378 | switch (arg) { | ||
3379 | case TCIFLUSH: | ||
3380 | case TCIOFLUSH: | ||
3381 | /* flush tty buffer and allow ldisc to process ioctl */ | ||
3382 | tty_buffer_flush(tty); | ||
3383 | break; | ||
3384 | } | ||
3385 | break; | ||
3343 | } | 3386 | } |
3344 | if (tty->driver->ioctl) { | 3387 | if (tty->driver->ioctl) { |
3345 | retval = (tty->driver->ioctl)(tty, file, cmd, arg); | 3388 | retval = (tty->driver->ioctl)(tty, file, cmd, arg); |
@@ -3357,6 +3400,32 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
3357 | return retval; | 3400 | return retval; |
3358 | } | 3401 | } |
3359 | 3402 | ||
3403 | #ifdef CONFIG_COMPAT | ||
3404 | static long tty_compat_ioctl(struct file * file, unsigned int cmd, | ||
3405 | unsigned long arg) | ||
3406 | { | ||
3407 | struct inode *inode = file->f_dentry->d_inode; | ||
3408 | struct tty_struct *tty = file->private_data; | ||
3409 | struct tty_ldisc *ld; | ||
3410 | int retval = -ENOIOCTLCMD; | ||
3411 | |||
3412 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | ||
3413 | return -EINVAL; | ||
3414 | |||
3415 | if (tty->driver->compat_ioctl) { | ||
3416 | retval = (tty->driver->compat_ioctl)(tty, file, cmd, arg); | ||
3417 | if (retval != -ENOIOCTLCMD) | ||
3418 | return retval; | ||
3419 | } | ||
3420 | |||
3421 | ld = tty_ldisc_ref_wait(tty); | ||
3422 | if (ld->compat_ioctl) | ||
3423 | retval = ld->compat_ioctl(tty, file, cmd, arg); | ||
3424 | tty_ldisc_deref(ld); | ||
3425 | |||
3426 | return retval; | ||
3427 | } | ||
3428 | #endif | ||
3360 | 3429 | ||
3361 | /* | 3430 | /* |
3362 | * This implements the "Secure Attention Key" --- the idea is to | 3431 | * This implements the "Secure Attention Key" --- the idea is to |
@@ -3689,6 +3758,7 @@ void tty_set_operations(struct tty_driver *driver, | |||
3689 | driver->write_room = op->write_room; | 3758 | driver->write_room = op->write_room; |
3690 | driver->chars_in_buffer = op->chars_in_buffer; | 3759 | driver->chars_in_buffer = op->chars_in_buffer; |
3691 | driver->ioctl = op->ioctl; | 3760 | driver->ioctl = op->ioctl; |
3761 | driver->compat_ioctl = op->compat_ioctl; | ||
3692 | driver->set_termios = op->set_termios; | 3762 | driver->set_termios = op->set_termios; |
3693 | driver->throttle = op->throttle; | 3763 | driver->throttle = op->throttle; |
3694 | driver->unthrottle = op->unthrottle; | 3764 | driver->unthrottle = op->unthrottle; |
@@ -3843,6 +3913,7 @@ void proc_clear_tty(struct task_struct *p) | |||
3843 | p->signal->tty = NULL; | 3913 | p->signal->tty = NULL; |
3844 | spin_unlock_irq(&p->sighand->siglock); | 3914 | spin_unlock_irq(&p->sighand->siglock); |
3845 | } | 3915 | } |
3916 | EXPORT_SYMBOL(proc_clear_tty); | ||
3846 | 3917 | ||
3847 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) | 3918 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) |
3848 | { | 3919 | { |
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c index 3c9684ccd2f9..eac4f9b9f007 100644 --- a/drivers/char/watchdog/iTCO_wdt.c +++ b/drivers/char/watchdog/iTCO_wdt.c | |||
@@ -571,7 +571,7 @@ static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent, | |||
571 | * ACPIBASE is bits [15:7] from 0x40-0x43 | 571 | * ACPIBASE is bits [15:7] from 0x40-0x43 |
572 | */ | 572 | */ |
573 | pci_read_config_dword(pdev, 0x40, &base_address); | 573 | pci_read_config_dword(pdev, 0x40, &base_address); |
574 | base_address &= 0x00007f80; | 574 | base_address &= 0x0000ff80; |
575 | if (base_address == 0x00000000) { | 575 | if (base_address == 0x00000000) { |
576 | /* Something's wrong here, ACPIBASE has to be set */ | 576 | /* Something's wrong here, ACPIBASE has to be set */ |
577 | printk(KERN_ERR PFX "failed to get TCOBASE address\n"); | 577 | printk(KERN_ERR PFX "failed to get TCOBASE address\n"); |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index a19b65ed3119..7f817897b178 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -240,11 +240,94 @@ static inline void hidinput_pb_setup(struct input_dev *input) | |||
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | 242 | ||
243 | static inline int match_scancode(int code, int scancode) | ||
244 | { | ||
245 | if (scancode == 0) | ||
246 | return 1; | ||
247 | return ((code & (HID_USAGE_PAGE | HID_USAGE)) == scancode); | ||
248 | } | ||
249 | |||
250 | static inline int match_keycode(int code, int keycode) | ||
251 | { | ||
252 | if (keycode == 0) | ||
253 | return 1; | ||
254 | return (code == keycode); | ||
255 | } | ||
256 | |||
257 | static struct hid_usage *hidinput_find_key(struct hid_device *hid, | ||
258 | int scancode, int keycode) | ||
259 | { | ||
260 | int i, j, k; | ||
261 | struct hid_report *report; | ||
262 | struct hid_usage *usage; | ||
263 | |||
264 | for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) { | ||
265 | list_for_each_entry(report, &hid->report_enum[k].report_list, list) { | ||
266 | for (i = 0; i < report->maxfield; i++) { | ||
267 | for ( j = 0; j < report->field[i]->maxusage; j++) { | ||
268 | usage = report->field[i]->usage + j; | ||
269 | if (usage->type == EV_KEY && | ||
270 | match_scancode(usage->hid, scancode) && | ||
271 | match_keycode(usage->code, keycode)) | ||
272 | return usage; | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | return NULL; | ||
278 | } | ||
279 | |||
280 | static int hidinput_getkeycode(struct input_dev *dev, int scancode, | ||
281 | int *keycode) | ||
282 | { | ||
283 | struct hid_device *hid = dev->private; | ||
284 | struct hid_usage *usage; | ||
285 | |||
286 | usage = hidinput_find_key(hid, scancode, 0); | ||
287 | if (usage) { | ||
288 | *keycode = usage->code; | ||
289 | return 0; | ||
290 | } | ||
291 | return -EINVAL; | ||
292 | } | ||
293 | |||
294 | static int hidinput_setkeycode(struct input_dev *dev, int scancode, | ||
295 | int keycode) | ||
296 | { | ||
297 | struct hid_device *hid = dev->private; | ||
298 | struct hid_usage *usage; | ||
299 | int old_keycode; | ||
300 | |||
301 | if (keycode < 0 || keycode > KEY_MAX) | ||
302 | return -EINVAL; | ||
303 | |||
304 | usage = hidinput_find_key(hid, scancode, 0); | ||
305 | if (usage) { | ||
306 | old_keycode = usage->code; | ||
307 | usage->code = keycode; | ||
308 | |||
309 | clear_bit(old_keycode, dev->keybit); | ||
310 | set_bit(usage->code, dev->keybit); | ||
311 | #ifdef CONFIG_HID_DEBUG | ||
312 | printk (KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode); | ||
313 | #endif | ||
314 | /* Set the keybit for the old keycode if the old keycode is used | ||
315 | * by another key */ | ||
316 | if (hidinput_find_key (hid, 0, old_keycode)) | ||
317 | set_bit(old_keycode, dev->keybit); | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | return -EINVAL; | ||
323 | } | ||
324 | |||
325 | |||
243 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 326 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
244 | struct hid_usage *usage) | 327 | struct hid_usage *usage) |
245 | { | 328 | { |
246 | struct input_dev *input = hidinput->input; | 329 | struct input_dev *input = hidinput->input; |
247 | struct hid_device *device = input->private; | 330 | struct hid_device *device = input_get_drvdata(input); |
248 | int max = 0, code; | 331 | int max = 0, code; |
249 | unsigned long *bit = NULL; | 332 | unsigned long *bit = NULL; |
250 | 333 | ||
@@ -553,6 +636,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
553 | case 0x1015: map_key_clear(KEY_RECORD); break; | 636 | case 0x1015: map_key_clear(KEY_RECORD); break; |
554 | case 0x1016: map_key_clear(KEY_PLAYER); break; | 637 | case 0x1016: map_key_clear(KEY_PLAYER); break; |
555 | case 0x1017: map_key_clear(KEY_EJECTCD); break; | 638 | case 0x1017: map_key_clear(KEY_EJECTCD); break; |
639 | case 0x1018: map_key_clear(KEY_MEDIA); break; | ||
556 | case 0x1019: map_key_clear(KEY_PROG1); break; | 640 | case 0x1019: map_key_clear(KEY_PROG1); break; |
557 | case 0x101a: map_key_clear(KEY_PROG2); break; | 641 | case 0x101a: map_key_clear(KEY_PROG2); break; |
558 | case 0x101b: map_key_clear(KEY_PROG3); break; | 642 | case 0x101b: map_key_clear(KEY_PROG3); break; |
@@ -560,9 +644,12 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
560 | case 0x1020: map_key_clear(KEY_ZOOMOUT); break; | 644 | case 0x1020: map_key_clear(KEY_ZOOMOUT); break; |
561 | case 0x1021: map_key_clear(KEY_ZOOMRESET); break; | 645 | case 0x1021: map_key_clear(KEY_ZOOMRESET); break; |
562 | case 0x1023: map_key_clear(KEY_CLOSE); break; | 646 | case 0x1023: map_key_clear(KEY_CLOSE); break; |
647 | case 0x1027: map_key_clear(KEY_MENU); break; | ||
563 | /* this one is marked as 'Rotate' */ | 648 | /* this one is marked as 'Rotate' */ |
564 | case 0x1028: map_key_clear(KEY_ANGLE); break; | 649 | case 0x1028: map_key_clear(KEY_ANGLE); break; |
565 | case 0x1029: map_key_clear(KEY_SHUFFLE); break; | 650 | case 0x1029: map_key_clear(KEY_SHUFFLE); break; |
651 | case 0x102a: map_key_clear(KEY_BACK); break; | ||
652 | case 0x102b: map_key_clear(KEY_CYCLEWINDOWS); break; | ||
566 | case 0x1041: map_key_clear(KEY_BATTERY); break; | 653 | case 0x1041: map_key_clear(KEY_BATTERY); break; |
567 | case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break; | 654 | case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break; |
568 | case 0x1043: map_key_clear(KEY_SPREADSHEET); break; | 655 | case 0x1043: map_key_clear(KEY_SPREADSHEET); break; |
@@ -855,13 +942,15 @@ EXPORT_SYMBOL_GPL(hidinput_find_field); | |||
855 | 942 | ||
856 | static int hidinput_open(struct input_dev *dev) | 943 | static int hidinput_open(struct input_dev *dev) |
857 | { | 944 | { |
858 | struct hid_device *hid = dev->private; | 945 | struct hid_device *hid = input_get_drvdata(dev); |
946 | |||
859 | return hid->hid_open(hid); | 947 | return hid->hid_open(hid); |
860 | } | 948 | } |
861 | 949 | ||
862 | static void hidinput_close(struct input_dev *dev) | 950 | static void hidinput_close(struct input_dev *dev) |
863 | { | 951 | { |
864 | struct hid_device *hid = dev->private; | 952 | struct hid_device *hid = input_get_drvdata(dev); |
953 | |||
865 | hid->hid_close(hid); | 954 | hid->hid_close(hid); |
866 | } | 955 | } |
867 | 956 | ||
@@ -909,10 +998,12 @@ int hidinput_connect(struct hid_device *hid) | |||
909 | return -1; | 998 | return -1; |
910 | } | 999 | } |
911 | 1000 | ||
912 | input_dev->private = hid; | 1001 | input_set_drvdata(input_dev, hid); |
913 | input_dev->event = hid->hidinput_input_event; | 1002 | input_dev->event = hid->hidinput_input_event; |
914 | input_dev->open = hidinput_open; | 1003 | input_dev->open = hidinput_open; |
915 | input_dev->close = hidinput_close; | 1004 | input_dev->close = hidinput_close; |
1005 | input_dev->setkeycode = hidinput_setkeycode; | ||
1006 | input_dev->getkeycode = hidinput_getkeycode; | ||
916 | 1007 | ||
917 | input_dev->name = hid->name; | 1008 | input_dev->name = hid->name; |
918 | input_dev->phys = hid->phys; | 1009 | input_dev->phys = hid->phys; |
@@ -921,7 +1012,7 @@ int hidinput_connect(struct hid_device *hid) | |||
921 | input_dev->id.vendor = hid->vendor; | 1012 | input_dev->id.vendor = hid->vendor; |
922 | input_dev->id.product = hid->product; | 1013 | input_dev->id.product = hid->product; |
923 | input_dev->id.version = hid->version; | 1014 | input_dev->id.version = hid->version; |
924 | input_dev->cdev.dev = hid->dev; | 1015 | input_dev->dev.parent = hid->dev; |
925 | hidinput->input = input_dev; | 1016 | hidinput->input = input_dev; |
926 | list_add_tail(&hidinput->list, &hid->inputs); | 1017 | list_add_tail(&hidinput->list, &hid->inputs); |
927 | } | 1018 | } |
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig index 7c87bdc538bc..1b4b572f899b 100644 --- a/drivers/hid/usbhid/Kconfig +++ b/drivers/hid/usbhid/Kconfig | |||
@@ -25,12 +25,12 @@ comment "Input core support is needed for USB HID input layer or HIDBP support" | |||
25 | depends on USB_HID && INPUT=n | 25 | depends on USB_HID && INPUT=n |
26 | 26 | ||
27 | config USB_HIDINPUT_POWERBOOK | 27 | config USB_HIDINPUT_POWERBOOK |
28 | bool "Enable support for iBook/PowerBook special keys" | 28 | bool "Enable support for iBook/PowerBook/MacBook/MacBookPro special keys" |
29 | default n | 29 | default n |
30 | depends on USB_HID | 30 | depends on USB_HID |
31 | help | 31 | help |
32 | Say Y here if you want support for the special keys (Fn, Numlock) on | 32 | Say Y here if you want support for the special keys (Fn, Numlock) on |
33 | Apple iBooks and PowerBooks. | 33 | Apple iBooks, PowerBooks, MacBooks and MacBook Pros. |
34 | 34 | ||
35 | If unsure, say N. | 35 | If unsure, say N. |
36 | 36 | ||
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 91d610358d57..d91b9dac6dff 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -446,7 +446,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns | |||
446 | 446 | ||
447 | static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 447 | static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
448 | { | 448 | { |
449 | struct hid_device *hid = dev->private; | 449 | struct hid_device *hid = input_get_drvdata(dev); |
450 | struct hid_field *field; | 450 | struct hid_field *field; |
451 | int offset; | 451 | int offset; |
452 | 452 | ||
@@ -626,14 +626,10 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) | |||
626 | { | 626 | { |
627 | struct usbhid_device *usbhid = hid->driver_data; | 627 | struct usbhid_device *usbhid = hid->driver_data; |
628 | 628 | ||
629 | if (usbhid->inbuf) | 629 | usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); |
630 | usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); | 630 | usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); |
631 | if (usbhid->outbuf) | 631 | usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma); |
632 | usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); | 632 | usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); |
633 | if (usbhid->cr) | ||
634 | usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma); | ||
635 | if (usbhid->ctrlbuf) | ||
636 | usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); | ||
637 | } | 633 | } |
638 | 634 | ||
639 | /* | 635 | /* |
@@ -692,6 +688,30 @@ static void hid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize) | |||
692 | } | 688 | } |
693 | } | 689 | } |
694 | 690 | ||
691 | /* | ||
692 | * Some USB barcode readers from cypress have usage min and usage max in | ||
693 | * the wrong order | ||
694 | */ | ||
695 | static void hid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize) | ||
696 | { | ||
697 | short fixed = 0; | ||
698 | int i; | ||
699 | |||
700 | for (i = 0; i < rsize - 4; i++) { | ||
701 | if (rdesc[i] == 0x29 && rdesc [i+2] == 0x19) { | ||
702 | unsigned char tmp; | ||
703 | |||
704 | rdesc[i] = 0x19; rdesc[i+2] = 0x29; | ||
705 | tmp = rdesc[i+3]; | ||
706 | rdesc[i+3] = rdesc[i+1]; | ||
707 | rdesc[i+1] = tmp; | ||
708 | } | ||
709 | } | ||
710 | |||
711 | if (fixed) | ||
712 | info("Fixing up Cypress report descriptor"); | ||
713 | } | ||
714 | |||
695 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) | 715 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) |
696 | { | 716 | { |
697 | struct usb_host_interface *interface = intf->cur_altsetting; | 717 | struct usb_host_interface *interface = intf->cur_altsetting; |
@@ -758,6 +778,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
758 | if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) | 778 | if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) |
759 | hid_fixup_logitech_descriptor(rdesc, rsize); | 779 | hid_fixup_logitech_descriptor(rdesc, rsize); |
760 | 780 | ||
781 | if (quirks & HID_QUIRK_SWAPPED_MIN_MAX) | ||
782 | hid_fixup_cypress_descriptor(rdesc, rsize); | ||
783 | |||
761 | #ifdef CONFIG_HID_DEBUG | 784 | #ifdef CONFIG_HID_DEBUG |
762 | printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n); | 785 | printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n); |
763 | for (n = 0; n < rsize; n++) | 786 | for (n = 0; n < rsize; n++) |
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/usbhid/hid-lgff.c index 92d2553f17b6..c5cd4107d6af 100644 --- a/drivers/hid/usbhid/hid-lgff.c +++ b/drivers/hid/usbhid/hid-lgff.c | |||
@@ -60,7 +60,7 @@ static const struct dev_type devices[] = { | |||
60 | 60 | ||
61 | static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect) | 61 | static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect) |
62 | { | 62 | { |
63 | struct hid_device *hid = dev->private; | 63 | struct hid_device *hid = input_get_drvdata(dev); |
64 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | 64 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
65 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); | 65 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); |
66 | int x, y; | 66 | int x, y; |
diff --git a/drivers/hid/usbhid/hid-plff.c b/drivers/hid/usbhid/hid-plff.c index 76d2e6e14db4..d6a8f2b49bd2 100644 --- a/drivers/hid/usbhid/hid-plff.c +++ b/drivers/hid/usbhid/hid-plff.c | |||
@@ -37,7 +37,7 @@ struct plff_device { | |||
37 | static int hid_plff_play(struct input_dev *dev, void *data, | 37 | static int hid_plff_play(struct input_dev *dev, void *data, |
38 | struct ff_effect *effect) | 38 | struct ff_effect *effect) |
39 | { | 39 | { |
40 | struct hid_device *hid = dev->private; | 40 | struct hid_device *hid = input_get_drvdata(dev); |
41 | struct plff_device *plff = data; | 41 | struct plff_device *plff = data; |
42 | int left, right; | 42 | int left, right; |
43 | 43 | ||
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 17a87555e32f..f6c4145dc202 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -92,6 +92,8 @@ | |||
92 | #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 | 92 | #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 |
93 | #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 | 93 | #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 |
94 | #define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 | 94 | #define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 |
95 | #define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61 | ||
96 | #define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64 | ||
95 | 97 | ||
96 | #define USB_VENDOR_ID_DELL 0x413c | 98 | #define USB_VENDOR_ID_DELL 0x413c |
97 | #define USB_DEVICE_ID_DELL_W7658 0x2005 | 99 | #define USB_DEVICE_ID_DELL_W7658 0x2005 |
@@ -193,6 +195,7 @@ | |||
193 | 195 | ||
194 | #define USB_VENDOR_ID_LOGITECH 0x046d | 196 | #define USB_VENDOR_ID_LOGITECH 0x046d |
195 | #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 | 197 | #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 |
198 | #define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 | ||
196 | #define USB_DEVICE_ID_S510_RECEIVER 0xc50c | 199 | #define USB_DEVICE_ID_S510_RECEIVER 0xc50c |
197 | #define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 | 200 | #define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 |
198 | #define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 | 201 | #define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 |
@@ -422,6 +425,7 @@ static const struct hid_blacklist { | |||
422 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, | 425 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, |
423 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, | 426 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, |
424 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, | 427 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, |
428 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET }, | ||
425 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, | 429 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, |
426 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, | 430 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, |
427 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, | 431 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
@@ -445,6 +449,9 @@ static const struct hid_blacklist { | |||
445 | 449 | ||
446 | { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, | 450 | { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, |
447 | 451 | ||
452 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_SWAPPED_MIN_MAX }, | ||
453 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2, HID_QUIRK_SWAPPED_MIN_MAX }, | ||
454 | |||
448 | { 0, 0 } | 455 | { 0, 0 } |
449 | }; | 456 | }; |
450 | 457 | ||
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/usbhid/hid-tmff.c index ab67331620d0..ab5ba6ef891c 100644 --- a/drivers/hid/usbhid/hid-tmff.c +++ b/drivers/hid/usbhid/hid-tmff.c | |||
@@ -59,7 +59,7 @@ static inline int hid_tmff_scale(unsigned int in, int minimum, int maximum) | |||
59 | 59 | ||
60 | static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) | 60 | static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) |
61 | { | 61 | { |
62 | struct hid_device *hid = dev->private; | 62 | struct hid_device *hid = input_get_drvdata(dev); |
63 | struct tmff_device *tmff = data; | 63 | struct tmff_device *tmff = data; |
64 | int left, right; /* Rumbling */ | 64 | int left, right; /* Rumbling */ |
65 | 65 | ||
diff --git a/drivers/hid/usbhid/hid-zpff.c b/drivers/hid/usbhid/hid-zpff.c index 7bd8238ca212..a7fbffcdaf36 100644 --- a/drivers/hid/usbhid/hid-zpff.c +++ b/drivers/hid/usbhid/hid-zpff.c | |||
@@ -37,7 +37,7 @@ struct zpff_device { | |||
37 | static int hid_zpff_play(struct input_dev *dev, void *data, | 37 | static int hid_zpff_play(struct input_dev *dev, void *data, |
38 | struct ff_effect *effect) | 38 | struct ff_effect *effect) |
39 | { | 39 | { |
40 | struct hid_device *hid = dev->private; | 40 | struct hid_device *hid = input_get_drvdata(dev); |
41 | struct zpff_device *zpff = data; | 41 | struct zpff_device *zpff = data; |
42 | int left, right; | 42 | int left, right; |
43 | 43 | ||
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index a8b3d66cd498..488d61bdbf2c 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c | |||
@@ -51,6 +51,7 @@ struct hiddev { | |||
51 | wait_queue_head_t wait; | 51 | wait_queue_head_t wait; |
52 | struct hid_device *hid; | 52 | struct hid_device *hid; |
53 | struct list_head list; | 53 | struct list_head list; |
54 | spinlock_t list_lock; | ||
54 | }; | 55 | }; |
55 | 56 | ||
56 | struct hiddev_list { | 57 | struct hiddev_list { |
@@ -161,7 +162,9 @@ static void hiddev_send_event(struct hid_device *hid, | |||
161 | { | 162 | { |
162 | struct hiddev *hiddev = hid->hiddev; | 163 | struct hiddev *hiddev = hid->hiddev; |
163 | struct hiddev_list *list; | 164 | struct hiddev_list *list; |
165 | unsigned long flags; | ||
164 | 166 | ||
167 | spin_lock_irqsave(&hiddev->list_lock, flags); | ||
165 | list_for_each_entry(list, &hiddev->list, node) { | 168 | list_for_each_entry(list, &hiddev->list, node) { |
166 | if (uref->field_index != HID_FIELD_INDEX_NONE || | 169 | if (uref->field_index != HID_FIELD_INDEX_NONE || |
167 | (list->flags & HIDDEV_FLAG_REPORT) != 0) { | 170 | (list->flags & HIDDEV_FLAG_REPORT) != 0) { |
@@ -171,6 +174,7 @@ static void hiddev_send_event(struct hid_device *hid, | |||
171 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 174 | kill_fasync(&list->fasync, SIGIO, POLL_IN); |
172 | } | 175 | } |
173 | } | 176 | } |
177 | spin_unlock_irqrestore(&hiddev->list_lock, flags); | ||
174 | 178 | ||
175 | wake_up_interruptible(&hiddev->wait); | 179 | wake_up_interruptible(&hiddev->wait); |
176 | } | 180 | } |
@@ -235,9 +239,13 @@ static int hiddev_fasync(int fd, struct file *file, int on) | |||
235 | static int hiddev_release(struct inode * inode, struct file * file) | 239 | static int hiddev_release(struct inode * inode, struct file * file) |
236 | { | 240 | { |
237 | struct hiddev_list *list = file->private_data; | 241 | struct hiddev_list *list = file->private_data; |
242 | unsigned long flags; | ||
238 | 243 | ||
239 | hiddev_fasync(-1, file, 0); | 244 | hiddev_fasync(-1, file, 0); |
245 | |||
246 | spin_lock_irqsave(&list->hiddev->list_lock, flags); | ||
240 | list_del(&list->node); | 247 | list_del(&list->node); |
248 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); | ||
241 | 249 | ||
242 | if (!--list->hiddev->open) { | 250 | if (!--list->hiddev->open) { |
243 | if (list->hiddev->exist) | 251 | if (list->hiddev->exist) |
@@ -257,6 +265,7 @@ static int hiddev_release(struct inode * inode, struct file * file) | |||
257 | static int hiddev_open(struct inode *inode, struct file *file) | 265 | static int hiddev_open(struct inode *inode, struct file *file) |
258 | { | 266 | { |
259 | struct hiddev_list *list; | 267 | struct hiddev_list *list; |
268 | unsigned long flags; | ||
260 | 269 | ||
261 | int i = iminor(inode) - HIDDEV_MINOR_BASE; | 270 | int i = iminor(inode) - HIDDEV_MINOR_BASE; |
262 | 271 | ||
@@ -267,7 +276,11 @@ static int hiddev_open(struct inode *inode, struct file *file) | |||
267 | return -ENOMEM; | 276 | return -ENOMEM; |
268 | 277 | ||
269 | list->hiddev = hiddev_table[i]; | 278 | list->hiddev = hiddev_table[i]; |
279 | |||
280 | spin_lock_irqsave(&list->hiddev->list_lock, flags); | ||
270 | list_add_tail(&list->node, &hiddev_table[i]->list); | 281 | list_add_tail(&list->node, &hiddev_table[i]->list); |
282 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); | ||
283 | |||
271 | file->private_data = list; | 284 | file->private_data = list; |
272 | 285 | ||
273 | if (!list->hiddev->open++) | 286 | if (!list->hiddev->open++) |
@@ -773,6 +786,7 @@ int hiddev_connect(struct hid_device *hid) | |||
773 | 786 | ||
774 | init_waitqueue_head(&hiddev->wait); | 787 | init_waitqueue_head(&hiddev->wait); |
775 | INIT_LIST_HEAD(&hiddev->list); | 788 | INIT_LIST_HEAD(&hiddev->list); |
789 | spin_lock_init(&hiddev->list_lock); | ||
776 | hiddev->hid = hid; | 790 | hiddev->hid = hid; |
777 | hiddev->exist = 1; | 791 | hiddev->exist = 1; |
778 | 792 | ||
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index 65aa12e8d7b3..130978780713 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c | |||
@@ -133,12 +133,11 @@ resubmit: | |||
133 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, | 133 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, |
134 | unsigned int code, int value) | 134 | unsigned int code, int value) |
135 | { | 135 | { |
136 | struct usb_kbd *kbd = dev->private; | 136 | struct usb_kbd *kbd = input_get_drvdata(dev); |
137 | 137 | ||
138 | if (type != EV_LED) | 138 | if (type != EV_LED) |
139 | return -1; | 139 | return -1; |
140 | 140 | ||
141 | |||
142 | kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | | 141 | kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | |
143 | (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | | 142 | (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | |
144 | (!!test_bit(LED_NUML, dev->led)); | 143 | (!!test_bit(LED_NUML, dev->led)); |
@@ -175,7 +174,7 @@ static void usb_kbd_led(struct urb *urb) | |||
175 | 174 | ||
176 | static int usb_kbd_open(struct input_dev *dev) | 175 | static int usb_kbd_open(struct input_dev *dev) |
177 | { | 176 | { |
178 | struct usb_kbd *kbd = dev->private; | 177 | struct usb_kbd *kbd = input_get_drvdata(dev); |
179 | 178 | ||
180 | kbd->irq->dev = kbd->usbdev; | 179 | kbd->irq->dev = kbd->usbdev; |
181 | if (usb_submit_urb(kbd->irq, GFP_KERNEL)) | 180 | if (usb_submit_urb(kbd->irq, GFP_KERNEL)) |
@@ -186,7 +185,7 @@ static int usb_kbd_open(struct input_dev *dev) | |||
186 | 185 | ||
187 | static void usb_kbd_close(struct input_dev *dev) | 186 | static void usb_kbd_close(struct input_dev *dev) |
188 | { | 187 | { |
189 | struct usb_kbd *kbd = dev->private; | 188 | struct usb_kbd *kbd = input_get_drvdata(dev); |
190 | 189 | ||
191 | usb_kill_urb(kbd->irq); | 190 | usb_kill_urb(kbd->irq); |
192 | } | 191 | } |
@@ -211,12 +210,9 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) | |||
211 | { | 210 | { |
212 | usb_free_urb(kbd->irq); | 211 | usb_free_urb(kbd->irq); |
213 | usb_free_urb(kbd->led); | 212 | usb_free_urb(kbd->led); |
214 | if (kbd->new) | 213 | usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); |
215 | usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); | 214 | usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma); |
216 | if (kbd->cr) | 215 | usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); |
217 | usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma); | ||
218 | if (kbd->leds) | ||
219 | usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); | ||
220 | } | 216 | } |
221 | 217 | ||
222 | static int usb_kbd_probe(struct usb_interface *iface, | 218 | static int usb_kbd_probe(struct usb_interface *iface, |
@@ -274,8 +270,9 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
274 | input_dev->name = kbd->name; | 270 | input_dev->name = kbd->name; |
275 | input_dev->phys = kbd->phys; | 271 | input_dev->phys = kbd->phys; |
276 | usb_to_input_id(dev, &input_dev->id); | 272 | usb_to_input_id(dev, &input_dev->id); |
277 | input_dev->cdev.dev = &iface->dev; | 273 | input_dev->dev.parent = &iface->dev; |
278 | input_dev->private = kbd; | 274 | |
275 | input_set_drvdata(input_dev, kbd); | ||
279 | 276 | ||
280 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 277 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); |
281 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | 278 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); |
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index 573776d865e1..5345c73bcf62 100644 --- a/drivers/hid/usbhid/usbmouse.c +++ b/drivers/hid/usbhid/usbmouse.c | |||
@@ -96,7 +96,7 @@ resubmit: | |||
96 | 96 | ||
97 | static int usb_mouse_open(struct input_dev *dev) | 97 | static int usb_mouse_open(struct input_dev *dev) |
98 | { | 98 | { |
99 | struct usb_mouse *mouse = dev->private; | 99 | struct usb_mouse *mouse = input_get_drvdata(dev); |
100 | 100 | ||
101 | mouse->irq->dev = mouse->usbdev; | 101 | mouse->irq->dev = mouse->usbdev; |
102 | if (usb_submit_urb(mouse->irq, GFP_KERNEL)) | 102 | if (usb_submit_urb(mouse->irq, GFP_KERNEL)) |
@@ -107,7 +107,7 @@ static int usb_mouse_open(struct input_dev *dev) | |||
107 | 107 | ||
108 | static void usb_mouse_close(struct input_dev *dev) | 108 | static void usb_mouse_close(struct input_dev *dev) |
109 | { | 109 | { |
110 | struct usb_mouse *mouse = dev->private; | 110 | struct usb_mouse *mouse = input_get_drvdata(dev); |
111 | 111 | ||
112 | usb_kill_urb(mouse->irq); | 112 | usb_kill_urb(mouse->irq); |
113 | } | 113 | } |
@@ -171,7 +171,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i | |||
171 | input_dev->name = mouse->name; | 171 | input_dev->name = mouse->name; |
172 | input_dev->phys = mouse->phys; | 172 | input_dev->phys = mouse->phys; |
173 | usb_to_input_id(dev, &input_dev->id); | 173 | usb_to_input_id(dev, &input_dev->id); |
174 | input_dev->cdev.dev = &intf->dev; | 174 | input_dev->dev.parent = &intf->dev; |
175 | 175 | ||
176 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 176 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
177 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 177 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
@@ -179,7 +179,8 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i | |||
179 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 179 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
180 | input_dev->relbit[0] |= BIT(REL_WHEEL); | 180 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
181 | 181 | ||
182 | input_dev->private = mouse; | 182 | input_set_drvdata(input_dev, mouse); |
183 | |||
183 | input_dev->open = usb_mouse_open; | 184 | input_dev->open = usb_mouse_open; |
184 | input_dev->close = usb_mouse_close; | 185 | input_dev->close = usb_mouse_close; |
185 | 186 | ||
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 55a72592704c..b234729706be 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -336,7 +336,7 @@ static int bits_to_user(unsigned long *bits, unsigned int maxbit, | |||
336 | 336 | ||
337 | if (compat) { | 337 | if (compat) { |
338 | len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t); | 338 | len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t); |
339 | if (len < maxlen) | 339 | if (len > maxlen) |
340 | len = maxlen; | 340 | len = maxlen; |
341 | 341 | ||
342 | for (i = 0; i < len / sizeof(compat_long_t); i++) | 342 | for (i = 0; i < len / sizeof(compat_long_t); i++) |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 65814b0340cb..c10ce91b64e9 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -5103,7 +5103,7 @@ static int is_mddev_idle(mddev_t *mddev) | |||
5103 | * | 5103 | * |
5104 | * Note: the following is an unsigned comparison. | 5104 | * Note: the following is an unsigned comparison. |
5105 | */ | 5105 | */ |
5106 | if ((curr_events - rdev->last_events + 4096) > 8192) { | 5106 | if ((long)curr_events - (long)rdev->last_events > 4096) { |
5107 | rdev->last_events = curr_events; | 5107 | rdev->last_events = curr_events; |
5108 | idle = 0; | 5108 | idle = 0; |
5109 | } | 5109 | } |
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 3a80e0cc7369..624b21cef5b3 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig | |||
@@ -87,6 +87,14 @@ config VIDEO_TVEEPROM | |||
87 | tristate | 87 | tristate |
88 | depends on I2C | 88 | depends on I2C |
89 | 89 | ||
90 | config DAB | ||
91 | boolean "DAB adapters" | ||
92 | default y | ||
93 | ---help--- | ||
94 | Allow selecting support for for Digital Audio Broadcasting (DAB) | ||
95 | Receiver adapters. | ||
96 | |||
97 | if DAB | ||
90 | config USB_DABUSB | 98 | config USB_DABUSB |
91 | tristate "DABUSB driver" | 99 | tristate "DABUSB driver" |
92 | depends on USB | 100 | depends on USB |
@@ -100,5 +108,6 @@ config USB_DABUSB | |||
100 | 108 | ||
101 | To compile this driver as a module, choose M here: the | 109 | To compile this driver as a module, choose M here: the |
102 | module will be called dabusb. | 110 | module will be called dabusb. |
111 | endif # DAB | ||
103 | 112 | ||
104 | endmenu | 113 | endmenu |
diff --git a/drivers/media/Makefile b/drivers/media/Makefile index c578a529e7a8..8fa19939c2b6 100644 --- a/drivers/media/Makefile +++ b/drivers/media/Makefile | |||
@@ -5,4 +5,4 @@ | |||
5 | obj-y := common/ | 5 | obj-y := common/ |
6 | obj-$(CONFIG_VIDEO_DEV) += video/ | 6 | obj-$(CONFIG_VIDEO_DEV) += video/ |
7 | obj-$(CONFIG_VIDEO_DEV) += radio/ | 7 | obj-$(CONFIG_VIDEO_DEV) += radio/ |
8 | obj-$(CONFIG_DVB) += dvb/ | 8 | obj-$(CONFIG_DVB_CORE) += dvb/ |
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index 86cbdbcf9d7d..ef3e54cd9407 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
@@ -136,28 +136,45 @@ char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa | |||
136 | char *mem = vmalloc_32(length); | 136 | char *mem = vmalloc_32(length); |
137 | int slen = 0; | 137 | int slen = 0; |
138 | 138 | ||
139 | if (NULL == mem) { | 139 | if (NULL == mem) |
140 | return NULL; | 140 | goto err_null; |
141 | } | ||
142 | 141 | ||
143 | if (!(pt->slist = vmalloc_to_sg(mem, pages))) { | 142 | if (!(pt->slist = vmalloc_to_sg(mem, pages))) |
144 | vfree(mem); | 143 | goto err_free_mem; |
145 | return NULL; | ||
146 | } | ||
147 | 144 | ||
148 | if (saa7146_pgtable_alloc(pci, pt)) { | 145 | if (saa7146_pgtable_alloc(pci, pt)) |
149 | kfree(pt->slist); | 146 | goto err_free_slist; |
150 | pt->slist = NULL; | ||
151 | vfree(mem); | ||
152 | return NULL; | ||
153 | } | ||
154 | 147 | ||
155 | slen = pci_map_sg(pci,pt->slist,pages,PCI_DMA_FROMDEVICE); | 148 | pt->nents = pages; |
156 | if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen)) { | 149 | slen = pci_map_sg(pci,pt->slist,pt->nents,PCI_DMA_FROMDEVICE); |
157 | return NULL; | 150 | if (0 == slen) |
158 | } | 151 | goto err_free_pgtable; |
152 | |||
153 | if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen)) | ||
154 | goto err_unmap_sg; | ||
159 | 155 | ||
160 | return mem; | 156 | return mem; |
157 | |||
158 | err_unmap_sg: | ||
159 | pci_unmap_sg(pci, pt->slist, pt->nents, PCI_DMA_FROMDEVICE); | ||
160 | err_free_pgtable: | ||
161 | saa7146_pgtable_free(pci, pt); | ||
162 | err_free_slist: | ||
163 | kfree(pt->slist); | ||
164 | pt->slist = NULL; | ||
165 | err_free_mem: | ||
166 | vfree(mem); | ||
167 | err_null: | ||
168 | return NULL; | ||
169 | } | ||
170 | |||
171 | void saa7146_vfree_destroy_pgtable(struct pci_dev *pci, char *mem, struct saa7146_pgtable *pt) | ||
172 | { | ||
173 | pci_unmap_sg(pci, pt->slist, pt->nents, PCI_DMA_FROMDEVICE); | ||
174 | saa7146_pgtable_free(pci, pt); | ||
175 | kfree(pt->slist); | ||
176 | pt->slist = NULL; | ||
177 | vfree(mem); | ||
161 | } | 178 | } |
162 | 179 | ||
163 | void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) | 180 | void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) |
@@ -166,8 +183,6 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) | |||
166 | return; | 183 | return; |
167 | pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); | 184 | pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); |
168 | pt->cpu = NULL; | 185 | pt->cpu = NULL; |
169 | kfree(pt->slist); | ||
170 | pt->slist = NULL; | ||
171 | } | 186 | } |
172 | 187 | ||
173 | int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) | 188 | int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) |
@@ -528,6 +543,7 @@ EXPORT_SYMBOL_GPL(saa7146_pgtable_alloc); | |||
528 | EXPORT_SYMBOL_GPL(saa7146_pgtable_free); | 543 | EXPORT_SYMBOL_GPL(saa7146_pgtable_free); |
529 | EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single); | 544 | EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single); |
530 | EXPORT_SYMBOL_GPL(saa7146_vmalloc_build_pgtable); | 545 | EXPORT_SYMBOL_GPL(saa7146_vmalloc_build_pgtable); |
546 | EXPORT_SYMBOL_GPL(saa7146_vfree_destroy_pgtable); | ||
531 | EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done); | 547 | EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done); |
532 | 548 | ||
533 | EXPORT_SYMBOL_GPL(saa7146_setgpio); | 549 | EXPORT_SYMBOL_GPL(saa7146_setgpio); |
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index c18a5da64934..b4770aecc01d 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c | |||
@@ -307,7 +307,6 @@ static int fops_release(struct inode *inode, struct file *file) | |||
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | 309 | ||
310 | int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg); | ||
311 | static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 310 | static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
312 | { | 311 | { |
313 | /* | 312 | /* |
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig index a97c8f5e9a5d..efd2b7468158 100644 --- a/drivers/media/dvb/Kconfig +++ b/drivers/media/dvb/Kconfig | |||
@@ -2,24 +2,16 @@ | |||
2 | # Multimedia device configuration | 2 | # Multimedia device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Digital Video Broadcasting Devices" | 5 | source "drivers/media/dvb/dvb-core/Kconfig" |
6 | 6 | ||
7 | config DVB | 7 | menuconfig DVB_CAPTURE_DRIVERS |
8 | bool "DVB For Linux" | 8 | bool "DVB/ATSC adapters" |
9 | depends on NET && INET | 9 | depends on DVB_CORE |
10 | default y | ||
10 | ---help--- | 11 | ---help--- |
11 | Support Digital Video Broadcasting hardware. Enable this if you | 12 | Say Y to select Digital TV adapters |
12 | own a DVB adapter and want to use it or if you compile Linux for | ||
13 | a digital SetTopBox. | ||
14 | |||
15 | API specs and user tools are available from <http://www.linuxtv.org/>. | ||
16 | 13 | ||
17 | Please report problems regarding this driver to the LinuxDVB | 14 | if DVB_CAPTURE_DRIVERS |
18 | mailing list. | ||
19 | |||
20 | If unsure say N. | ||
21 | |||
22 | source "drivers/media/dvb/dvb-core/Kconfig" | ||
23 | 15 | ||
24 | comment "Supported SAA7146 based PCI Adapters" | 16 | comment "Supported SAA7146 based PCI Adapters" |
25 | depends on DVB_CORE && PCI && I2C | 17 | depends on DVB_CORE && PCI && I2C |
@@ -48,4 +40,4 @@ comment "Supported DVB Frontends" | |||
48 | depends on DVB_CORE | 40 | depends on DVB_CORE |
49 | source "drivers/media/dvb/frontends/Kconfig" | 41 | source "drivers/media/dvb/frontends/Kconfig" |
50 | 42 | ||
51 | endmenu | 43 | endif # DVB_CAPTURE_DRIVERS |
diff --git a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig index 1990eda10c46..e3e6839f8073 100644 --- a/drivers/media/dvb/dvb-core/Kconfig +++ b/drivers/media/dvb/dvb-core/Kconfig | |||
@@ -1,12 +1,22 @@ | |||
1 | config DVB_CORE | 1 | config DVB_CORE |
2 | tristate "DVB Core Support" | 2 | tristate "DVB for Linux" |
3 | depends on DVB | 3 | depends on NET && INET |
4 | select CRC32 | 4 | select CRC32 |
5 | help | 5 | help |
6 | Support Digital Video Broadcasting hardware. Enable this if you | ||
7 | own a DVB adapter and want to use it or if you compile Linux for | ||
8 | a digital SetTopBox. | ||
9 | |||
6 | DVB core utility functions for device handling, software fallbacks etc. | 10 | DVB core utility functions for device handling, software fallbacks etc. |
7 | Say Y when you have a DVB card and want to use it. Say Y if your want | 11 | Say Y when you have a DVB card and want to use it. Say Y if your want |
8 | to build your drivers outside the kernel, but need the DVB core. All | 12 | to build your drivers outside the kernel, but need the DVB core. All |
9 | in-kernel drivers will select this automatically if needed. | 13 | in-kernel drivers will select this automatically if needed. |
14 | |||
15 | API specs and user tools are available from <http://www.linuxtv.org/>. | ||
16 | |||
17 | Please report problems regarding this driver to the LinuxDVB | ||
18 | mailing list. | ||
19 | |||
10 | If unsure say N. | 20 | If unsure say N. |
11 | 21 | ||
12 | config DVB_CORE_ATTACH | 22 | config DVB_CORE_ATTACH |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 97715f7514d6..403081689de1 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #define USB_VID_COMPRO_UNK 0x145f | 19 | #define USB_VID_COMPRO_UNK 0x145f |
20 | #define USB_VID_CYPRESS 0x04b4 | 20 | #define USB_VID_CYPRESS 0x04b4 |
21 | #define USB_VID_DIBCOM 0x10b8 | 21 | #define USB_VID_DIBCOM 0x10b8 |
22 | #define USB_VID_DPOSH 0x1498 | ||
22 | #define USB_VID_DVICO 0x0fe9 | 23 | #define USB_VID_DVICO 0x0fe9 |
23 | #define USB_VID_EMPIA 0xeb1a | 24 | #define USB_VID_EMPIA 0xeb1a |
24 | #define USB_VID_GENPIX 0x09c0 | 25 | #define USB_VID_GENPIX 0x09c0 |
@@ -61,6 +62,8 @@ | |||
61 | #define USB_PID_DIBCOM_STK7700P 0x1e14 | 62 | #define USB_PID_DIBCOM_STK7700P 0x1e14 |
62 | #define USB_PID_DIBCOM_STK7700P_PC 0x1e78 | 63 | #define USB_PID_DIBCOM_STK7700P_PC 0x1e78 |
63 | #define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 | 64 | #define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 |
65 | #define USB_PID_DPOSH_M9206_COLD 0x9206 | ||
66 | #define USB_PID_DPOSH_M9206_WARM 0xa090 | ||
64 | #define USB_PID_UNIWILL_STK7700P 0x6003 | 67 | #define USB_PID_UNIWILL_STK7700P 0x6003 |
65 | #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 | 68 | #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 |
66 | #define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 | 69 | #define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 |
@@ -145,6 +148,8 @@ | |||
145 | #define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 | 148 | #define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 |
146 | #define USB_PID_OPERA1_COLD 0x2830 | 149 | #define USB_PID_OPERA1_COLD 0x2830 |
147 | #define USB_PID_OPERA1_WARM 0x3829 | 150 | #define USB_PID_OPERA1_WARM 0x3829 |
151 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD 0x0514 | ||
152 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM 0x0513 | ||
148 | 153 | ||
149 | 154 | ||
150 | #endif | 155 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 0d721731a524..6f824a569e14 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h | |||
@@ -119,7 +119,7 @@ struct usb_data_stream_properties { | |||
119 | * @caps: capabilities of the DVB USB device. | 119 | * @caps: capabilities of the DVB USB device. |
120 | * @pid_filter_count: number of PID filter position in the optional hardware | 120 | * @pid_filter_count: number of PID filter position in the optional hardware |
121 | * PID-filter. | 121 | * PID-filter. |
122 | * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the | 122 | * @streaming_ctrl: called to start and stop the MPEG2-TS streaming of the |
123 | * device (not URB submitting/killing). | 123 | * device (not URB submitting/killing). |
124 | * @pid_filter_ctrl: called to en/disable the PID filter, if any. | 124 | * @pid_filter_ctrl: called to en/disable the PID filter, if any. |
125 | * @pid_filter: called to set/unset a PID for filtering. | 125 | * @pid_filter: called to set/unset a PID for filtering. |
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c index 45d7bc214c18..c546ddeda5d4 100644 --- a/drivers/media/dvb/dvb-usb/m920x.c +++ b/drivers/media/dvb/dvb-usb/m920x.c | |||
@@ -3,8 +3,8 @@ | |||
3 | * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org) | 3 | * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org) |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the Free | 6 | * under the terms of the GNU General Public License as published by the |
7 | * Software Foundation, version 2. | 7 | * Free Software Foundation, version 2. |
8 | * | 8 | * |
9 | * see Documentation/dvb/README.dvb-usb for more information | 9 | * see Documentation/dvb/README.dvb-usb for more information |
10 | */ | 10 | */ |
@@ -22,26 +22,7 @@ static int dvb_usb_m920x_debug; | |||
22 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); | 22 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); |
23 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 23 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
24 | 24 | ||
25 | static struct dvb_usb_rc_key megasky_rc_keys [] = { | 25 | static inline int m920x_read(struct usb_device *udev, u8 request, u16 value, |
26 | { 0x0, 0x12, KEY_POWER }, | ||
27 | { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */ | ||
28 | { 0x0, 0x02, KEY_CHANNELUP }, | ||
29 | { 0x0, 0x05, KEY_CHANNELDOWN }, | ||
30 | { 0x0, 0x03, KEY_VOLUMEUP }, | ||
31 | { 0x0, 0x06, KEY_VOLUMEDOWN }, | ||
32 | { 0x0, 0x04, KEY_MUTE }, | ||
33 | { 0x0, 0x07, KEY_OK }, /* TS */ | ||
34 | { 0x0, 0x08, KEY_STOP }, | ||
35 | { 0x0, 0x09, KEY_MENU }, /* swap */ | ||
36 | { 0x0, 0x0a, KEY_REWIND }, | ||
37 | { 0x0, 0x1b, KEY_PAUSE }, | ||
38 | { 0x0, 0x1f, KEY_FASTFORWARD }, | ||
39 | { 0x0, 0x0c, KEY_RECORD }, | ||
40 | { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */ | ||
41 | { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */ | ||
42 | }; | ||
43 | |||
44 | static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\ | ||
45 | u16 index, void *data, int size) | 26 | u16 index, void *data, int size) |
46 | { | 27 | { |
47 | int ret; | 28 | int ret; |
@@ -55,14 +36,14 @@ static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\ | |||
55 | } | 36 | } |
56 | 37 | ||
57 | if (ret != size) { | 38 | if (ret != size) { |
58 | deb_rc("m920x_read = no data\n"); | 39 | deb("m920x_read = no data\n"); |
59 | return -EIO; | 40 | return -EIO; |
60 | } | 41 | } |
61 | 42 | ||
62 | return 0; | 43 | return 0; |
63 | } | 44 | } |
64 | 45 | ||
65 | static inline int m9206_write(struct usb_device *udev, u8 request, | 46 | static inline int m920x_write(struct usb_device *udev, u8 request, |
66 | u16 value, u16 index) | 47 | u16 value, u16 index) |
67 | { | 48 | { |
68 | int ret; | 49 | int ret; |
@@ -74,32 +55,40 @@ static inline int m9206_write(struct usb_device *udev, u8 request, | |||
74 | return ret; | 55 | return ret; |
75 | } | 56 | } |
76 | 57 | ||
77 | static int m9206_init(struct dvb_usb_device *d) | 58 | static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq) |
78 | { | 59 | { |
79 | int ret = 0; | 60 | int ret = 0; |
80 | 61 | ||
81 | /* Remote controller init. */ | 62 | /* Remote controller init. */ |
82 | if (d->props.rc_query) { | 63 | if (d->props.rc_query) { |
83 | if ((ret = m9206_write(d->udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0) | 64 | deb("Initialising remote control\n"); |
84 | return ret; | 65 | while (rc_seq->address) { |
66 | if ((ret = m920x_write(d->udev, M9206_CORE, | ||
67 | rc_seq->data, | ||
68 | rc_seq->address)) != 0) { | ||
69 | deb("Initialising remote control failed\n"); | ||
70 | return ret; | ||
71 | } | ||
85 | 72 | ||
86 | if ((ret = m9206_write(d->udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0) | 73 | rc_seq++; |
87 | return ret; | 74 | } |
75 | |||
76 | deb("Initialising remote control success\n"); | ||
88 | } | 77 | } |
89 | 78 | ||
90 | return ret; | 79 | return ret; |
91 | } | 80 | } |
92 | 81 | ||
93 | static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | 82 | static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
94 | { | 83 | { |
95 | struct m9206_state *m = d->priv; | 84 | struct m920x_state *m = d->priv; |
96 | int i, ret = 0; | 85 | int i, ret = 0; |
97 | u8 rc_state[2]; | 86 | u8 rc_state[2]; |
98 | 87 | ||
99 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) | 88 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) |
100 | goto unlock; | 89 | goto unlock; |
101 | 90 | ||
102 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) | 91 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) |
103 | goto unlock; | 92 | goto unlock; |
104 | 93 | ||
105 | for (i = 0; i < d->props.rc_key_map_size; i++) | 94 | for (i = 0; i < d->props.rc_key_map_size; i++) |
@@ -111,6 +100,14 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
111 | *state = REMOTE_NO_KEY_PRESSED; | 100 | *state = REMOTE_NO_KEY_PRESSED; |
112 | goto unlock; | 101 | goto unlock; |
113 | 102 | ||
103 | case 0x88: /* framing error or "invalid code" */ | ||
104 | case 0x99: | ||
105 | case 0xc0: | ||
106 | case 0xd8: | ||
107 | *state = REMOTE_NO_KEY_PRESSED; | ||
108 | m->rep_count = 0; | ||
109 | goto unlock; | ||
110 | |||
114 | case 0x93: | 111 | case 0x93: |
115 | case 0x92: | 112 | case 0x92: |
116 | m->rep_count = 0; | 113 | m->rep_count = 0; |
@@ -118,31 +115,32 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
118 | goto unlock; | 115 | goto unlock; |
119 | 116 | ||
120 | case 0x91: | 117 | case 0x91: |
121 | /* For comfort. */ | 118 | /* prevent immediate auto-repeat */ |
122 | if (++m->rep_count > 2) | 119 | if (++m->rep_count > 2) |
123 | *state = REMOTE_KEY_REPEAT; | 120 | *state = REMOTE_KEY_REPEAT; |
121 | else | ||
122 | *state = REMOTE_NO_KEY_PRESSED; | ||
124 | goto unlock; | 123 | goto unlock; |
125 | 124 | ||
126 | default: | 125 | default: |
127 | deb_rc("Unexpected rc response %x\n", rc_state[0]); | 126 | deb("Unexpected rc state %02x\n", rc_state[0]); |
128 | *state = REMOTE_NO_KEY_PRESSED; | 127 | *state = REMOTE_NO_KEY_PRESSED; |
129 | goto unlock; | 128 | goto unlock; |
130 | } | 129 | } |
131 | } | 130 | } |
132 | 131 | ||
133 | if (rc_state[1] != 0) | 132 | if (rc_state[1] != 0) |
134 | deb_rc("Unknown rc key %x\n", rc_state[1]); | 133 | deb("Unknown rc key %02x\n", rc_state[1]); |
135 | 134 | ||
136 | *state = REMOTE_NO_KEY_PRESSED; | 135 | *state = REMOTE_NO_KEY_PRESSED; |
137 | 136 | ||
138 | unlock: | 137 | unlock: |
139 | 138 | ||
140 | return ret; | 139 | return ret; |
141 | } | 140 | } |
142 | 141 | ||
143 | /* I2C */ | 142 | /* I2C */ |
144 | static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | 143 | static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
145 | int num) | ||
146 | { | 144 | { |
147 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | 145 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
148 | int i, j; | 146 | int i, j; |
@@ -155,33 +153,40 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
155 | return -EAGAIN; | 153 | return -EAGAIN; |
156 | 154 | ||
157 | for (i = 0; i < num; i++) { | 155 | for (i = 0; i < num; i++) { |
158 | if (msg[i].flags & (I2C_M_NO_RD_ACK|I2C_M_IGNORE_NAK|I2C_M_TEN) || | 156 | if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK | I2C_M_TEN) || msg[i].len == 0) { |
159 | msg[i].len == 0) { | 157 | /* For a 0 byte message, I think sending the address |
160 | /* For a 0 byte message, I think sending the address to index 0x80|0x40 | 158 | * to index 0x80|0x40 would be the correct thing to |
161 | * would be the correct thing to do. However, zero byte messages are | 159 | * do. However, zero byte messages are only used for |
162 | * only used for probing, and since we don't know how to get the slave's | 160 | * probing, and since we don't know how to get the |
163 | * ack, we can't probe. */ | 161 | * slave's ack, we can't probe. */ |
164 | ret = -ENOTSUPP; | 162 | ret = -ENOTSUPP; |
165 | goto unlock; | 163 | goto unlock; |
166 | } | 164 | } |
167 | /* Send START & address/RW bit */ | 165 | /* Send START & address/RW bit */ |
168 | if (!(msg[i].flags & I2C_M_NOSTART)) { | 166 | if (!(msg[i].flags & I2C_M_NOSTART)) { |
169 | if ((ret = m9206_write(d->udev, M9206_I2C, (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0), 0x80)) != 0) | 167 | if ((ret = m920x_write(d->udev, M9206_I2C, |
168 | (msg[i].addr << 1) | | ||
169 | (msg[i].flags & I2C_M_RD ? 0x01 : 0), 0x80)) != 0) | ||
170 | goto unlock; | 170 | goto unlock; |
171 | /* Should check for ack here, if we knew how. */ | 171 | /* Should check for ack here, if we knew how. */ |
172 | } | 172 | } |
173 | if (msg[i].flags & I2C_M_RD) { | 173 | if (msg[i].flags & I2C_M_RD) { |
174 | for (j = 0; j < msg[i].len; j++) { | 174 | for (j = 0; j < msg[i].len; j++) { |
175 | /* Last byte of transaction? Send STOP, otherwise send ACK. */ | 175 | /* Last byte of transaction? |
176 | int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x01; | 176 | * Send STOP, otherwise send ACK. */ |
177 | if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x20|stop, &msg[i].buf[j], 1)) != 0) | 177 | int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x01; |
178 | |||
179 | if ((ret = m920x_read(d->udev, M9206_I2C, 0x0, | ||
180 | 0x20 | stop, | ||
181 | &msg[i].buf[j], 1)) != 0) | ||
178 | goto unlock; | 182 | goto unlock; |
179 | } | 183 | } |
180 | } else { | 184 | } else { |
181 | for (j = 0; j < msg[i].len; j++) { | 185 | for (j = 0; j < msg[i].len; j++) { |
182 | /* Last byte of transaction? Then send STOP. */ | 186 | /* Last byte of transaction? Then send STOP. */ |
183 | int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x00; | 187 | int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x00; |
184 | if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) | 188 | |
189 | if ((ret = m920x_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) | ||
185 | goto unlock; | 190 | goto unlock; |
186 | /* Should check for ack here too. */ | 191 | /* Should check for ack here too. */ |
187 | } | 192 | } |
@@ -189,25 +194,25 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
189 | } | 194 | } |
190 | ret = num; | 195 | ret = num; |
191 | 196 | ||
192 | unlock: | 197 | unlock: |
193 | mutex_unlock(&d->i2c_mutex); | 198 | mutex_unlock(&d->i2c_mutex); |
194 | 199 | ||
195 | return ret; | 200 | return ret; |
196 | } | 201 | } |
197 | 202 | ||
198 | static u32 m9206_i2c_func(struct i2c_adapter *adapter) | 203 | static u32 m920x_i2c_func(struct i2c_adapter *adapter) |
199 | { | 204 | { |
200 | return I2C_FUNC_I2C; | 205 | return I2C_FUNC_I2C; |
201 | } | 206 | } |
202 | 207 | ||
203 | static struct i2c_algorithm m9206_i2c_algo = { | 208 | static struct i2c_algorithm m920x_i2c_algo = { |
204 | .master_xfer = m9206_i2c_xfer, | 209 | .master_xfer = m920x_i2c_xfer, |
205 | .functionality = m9206_i2c_func, | 210 | .functionality = m920x_i2c_func, |
206 | }; | 211 | }; |
207 | 212 | ||
208 | 213 | /* pid filter */ | |
209 | static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, | 214 | static int m920x_set_filter(struct dvb_usb_adapter *adap, |
210 | int pid) | 215 | int type, int idx, int pid) |
211 | { | 216 | { |
212 | int ret = 0; | 217 | int ret = 0; |
213 | 218 | ||
@@ -216,18 +221,18 @@ static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, | |||
216 | 221 | ||
217 | pid |= 0x8000; | 222 | pid |= 0x8000; |
218 | 223 | ||
219 | if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0) | 224 | if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0) |
220 | return ret; | 225 | return ret; |
221 | 226 | ||
222 | if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0) | 227 | if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0) |
223 | return ret; | 228 | return ret; |
224 | 229 | ||
225 | return ret; | 230 | return ret; |
226 | } | 231 | } |
227 | 232 | ||
228 | static int m9206_update_filters(struct dvb_usb_adapter *adap) | 233 | static int m920x_update_filters(struct dvb_usb_adapter *adap) |
229 | { | 234 | { |
230 | struct m9206_state *m = adap->dev->priv; | 235 | struct m920x_state *m = adap->dev->priv; |
231 | int enabled = m->filtering_enabled; | 236 | int enabled = m->filtering_enabled; |
232 | int i, ret = 0, filter = 0; | 237 | int i, ret = 0, filter = 0; |
233 | 238 | ||
@@ -236,14 +241,14 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap) | |||
236 | enabled = 0; | 241 | enabled = 0; |
237 | 242 | ||
238 | /* Disable all filters */ | 243 | /* Disable all filters */ |
239 | if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0) | 244 | if ((ret = m920x_set_filter(adap, 0x81, 1, enabled)) != 0) |
240 | return ret; | 245 | return ret; |
241 | 246 | ||
242 | for (i = 0; i < M9206_MAX_FILTERS; i++) | 247 | for (i = 0; i < M9206_MAX_FILTERS; i++) |
243 | if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0) | 248 | if ((ret = m920x_set_filter(adap, 0x81, i + 2, 0)) != 0) |
244 | return ret; | 249 | return ret; |
245 | 250 | ||
246 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0) | 251 | if ((ret = m920x_set_filter(adap, 0x82, 0, 0x0)) != 0) |
247 | return ret; | 252 | return ret; |
248 | 253 | ||
249 | /* Set */ | 254 | /* Set */ |
@@ -252,40 +257,38 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap) | |||
252 | if (m->filters[i] == 0) | 257 | if (m->filters[i] == 0) |
253 | continue; | 258 | continue; |
254 | 259 | ||
255 | if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) | 260 | if ((ret = m920x_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) |
256 | return ret; | 261 | return ret; |
257 | 262 | ||
258 | filter++; | 263 | filter++; |
259 | } | 264 | } |
260 | } | 265 | } |
261 | 266 | ||
262 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0) | 267 | if ((ret = m920x_set_filter(adap, 0x82, 0, 0x02f5)) != 0) |
263 | return ret; | 268 | return ret; |
264 | 269 | ||
265 | return ret; | 270 | return ret; |
266 | } | 271 | } |
267 | 272 | ||
268 | static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) | 273 | static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) |
269 | { | 274 | { |
270 | struct m9206_state *m = adap->dev->priv; | 275 | struct m920x_state *m = adap->dev->priv; |
271 | 276 | ||
272 | m->filtering_enabled = onoff ? 1 : 0; | 277 | m->filtering_enabled = onoff ? 1 : 0; |
273 | 278 | ||
274 | return m9206_update_filters(adap); | 279 | return m920x_update_filters(adap); |
275 | } | 280 | } |
276 | 281 | ||
277 | static int m9206_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, | 282 | static int m920x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff) |
278 | int onoff) | ||
279 | { | 283 | { |
280 | struct m9206_state *m = adap->dev->priv; | 284 | struct m920x_state *m = adap->dev->priv; |
281 | 285 | ||
282 | m->filters[index] = onoff ? pid : 0; | 286 | m->filters[index] = onoff ? pid : 0; |
283 | 287 | ||
284 | return m9206_update_filters(adap); | 288 | return m920x_update_filters(adap); |
285 | } | 289 | } |
286 | 290 | ||
287 | static int m9206_firmware_download(struct usb_device *udev, | 291 | static int m920x_firmware_download(struct usb_device *udev, const struct firmware *fw) |
288 | const struct firmware *fw) | ||
289 | { | 292 | { |
290 | u16 value, index, size; | 293 | u16 value, index, size; |
291 | u8 read[4], *buff; | 294 | u8 read[4], *buff; |
@@ -293,13 +296,13 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
293 | 296 | ||
294 | buff = kmalloc(65536, GFP_KERNEL); | 297 | buff = kmalloc(65536, GFP_KERNEL); |
295 | 298 | ||
296 | if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0) | 299 | if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0) |
297 | goto done; | 300 | goto done; |
298 | deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]); | 301 | deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]); |
299 | 302 | ||
300 | if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0) | 303 | if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0) |
301 | goto done; | 304 | goto done; |
302 | deb_rc("%x\n", read[0]); | 305 | deb("%x\n", read[0]); |
303 | 306 | ||
304 | for (pass = 0; pass < 2; pass++) { | 307 | for (pass = 0; pass < 2; pass++) { |
305 | for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { | 308 | for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { |
@@ -317,11 +320,11 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
317 | memcpy(buff, fw->data + i, size); | 320 | memcpy(buff, fw->data + i, size); |
318 | 321 | ||
319 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0), | 322 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0), |
320 | M9206_FW, | 323 | M9206_FW, |
321 | USB_TYPE_VENDOR | USB_DIR_OUT, | 324 | USB_TYPE_VENDOR | USB_DIR_OUT, |
322 | value, index, buff, size, 20); | 325 | value, index, buff, size, 20); |
323 | if (ret != size) { | 326 | if (ret != size) { |
324 | deb_rc("error while uploading fw!\n"); | 327 | deb("error while uploading fw!\n"); |
325 | ret = -EIO; | 328 | ret = -EIO; |
326 | goto done; | 329 | goto done; |
327 | } | 330 | } |
@@ -330,7 +333,7 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
330 | i += size; | 333 | i += size; |
331 | } | 334 | } |
332 | if (i != fw->size) { | 335 | if (i != fw->size) { |
333 | deb_rc("bad firmware file!\n"); | 336 | deb("bad firmware file!\n"); |
334 | ret = -EINVAL; | 337 | ret = -EINVAL; |
335 | goto done; | 338 | goto done; |
336 | } | 339 | } |
@@ -338,11 +341,11 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
338 | 341 | ||
339 | msleep(36); | 342 | msleep(36); |
340 | 343 | ||
341 | /* m9206 will disconnect itself from the bus after this. */ | 344 | /* m920x will disconnect itself from the bus after this. */ |
342 | (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO); | 345 | (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO); |
343 | deb_rc("firmware uploaded!\n"); | 346 | deb("firmware uploaded!\n"); |
344 | 347 | ||
345 | done: | 348 | done: |
346 | kfree(buff); | 349 | kfree(buff); |
347 | 350 | ||
348 | return ret; | 351 | return ret; |
@@ -362,7 +365,8 @@ static int m920x_identify_state(struct usb_device *udev, | |||
362 | return 0; | 365 | return 0; |
363 | } | 366 | } |
364 | 367 | ||
365 | static int megasky_mt352_demod_init(struct dvb_frontend *fe) | 368 | /* demod configurations */ |
369 | static int m920x_mt352_demod_init(struct dvb_frontend *fe) | ||
366 | { | 370 | { |
367 | u8 config[] = { CONFIG, 0x3d }; | 371 | u8 config[] = { CONFIG, 0x3d }; |
368 | u8 clock[] = { CLOCK_CTL, 0x30 }; | 372 | u8 clock[] = { CLOCK_CTL, 0x30 }; |
@@ -382,74 +386,174 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe) | |||
382 | mt352_write(fe, unk1, ARRAY_SIZE(unk1)); | 386 | mt352_write(fe, unk1, ARRAY_SIZE(unk1)); |
383 | mt352_write(fe, unk2, ARRAY_SIZE(unk2)); | 387 | mt352_write(fe, unk2, ARRAY_SIZE(unk2)); |
384 | 388 | ||
385 | deb_rc("Demod init!\n"); | 389 | deb("Demod init!\n"); |
386 | 390 | ||
387 | return 0; | 391 | return 0; |
388 | } | 392 | } |
389 | 393 | ||
390 | static struct mt352_config megasky_mt352_config = { | 394 | static struct mt352_config m920x_mt352_config = { |
391 | .demod_address = 0x0f, | 395 | .demod_address = 0x0f, |
392 | .no_tuner = 1, | 396 | .no_tuner = 1, |
393 | .demod_init = megasky_mt352_demod_init, | 397 | .demod_init = m920x_mt352_demod_init, |
398 | }; | ||
399 | |||
400 | static struct tda1004x_config m920x_tda10046_08_config = { | ||
401 | .demod_address = 0x08, | ||
402 | .invert = 0, | ||
403 | .invert_oclk = 0, | ||
404 | .ts_mode = TDA10046_TS_SERIAL, | ||
405 | .xtal_freq = TDA10046_XTAL_16M, | ||
406 | .if_freq = TDA10046_FREQ_045, | ||
407 | .agc_config = TDA10046_AGC_TDA827X, | ||
408 | .gpio_config = TDA10046_GPTRI, | ||
409 | .request_firmware = NULL, | ||
410 | }; | ||
411 | |||
412 | static struct tda1004x_config m920x_tda10046_0b_config = { | ||
413 | .demod_address = 0x0b, | ||
414 | .invert = 0, | ||
415 | .invert_oclk = 0, | ||
416 | .ts_mode = TDA10046_TS_SERIAL, | ||
417 | .xtal_freq = TDA10046_XTAL_16M, | ||
418 | .if_freq = TDA10046_FREQ_045, | ||
419 | .agc_config = TDA10046_AGC_TDA827X, | ||
420 | .gpio_config = TDA10046_GPTRI, | ||
421 | .request_firmware = NULL, /* uses firmware EEPROM */ | ||
422 | }; | ||
423 | |||
424 | /* tuner configurations */ | ||
425 | static struct qt1010_config m920x_qt1010_config = { | ||
426 | .i2c_address = 0x62 | ||
394 | }; | 427 | }; |
395 | 428 | ||
396 | static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) | 429 | /* Callbacks for DVB USB */ |
430 | static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) | ||
397 | { | 431 | { |
398 | deb_rc("megasky_frontend_attach!\n"); | 432 | deb("%s\n",__FUNCTION__); |
399 | 433 | ||
400 | if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL) | 434 | if ((adap->fe = dvb_attach(mt352_attach, |
435 | &m920x_mt352_config, | ||
436 | &adap->dev->i2c_adap)) == NULL) | ||
401 | return -EIO; | 437 | return -EIO; |
402 | 438 | ||
403 | return 0; | 439 | return 0; |
404 | } | 440 | } |
405 | 441 | ||
406 | static struct qt1010_config megasky_qt1010_config = { | 442 | static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) |
407 | .i2c_address = 0x62 | ||
408 | }; | ||
409 | |||
410 | static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap) | ||
411 | { | 443 | { |
412 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, | 444 | deb("%s\n",__FUNCTION__); |
413 | &megasky_qt1010_config) == NULL) | 445 | |
414 | return -ENODEV; | 446 | if ((adap->fe = dvb_attach(tda10046_attach, |
447 | &m920x_tda10046_08_config, | ||
448 | &adap->dev->i2c_adap)) == NULL) | ||
449 | return -EIO; | ||
415 | 450 | ||
416 | return 0; | 451 | return 0; |
417 | } | 452 | } |
418 | 453 | ||
419 | static struct tda1004x_config digivox_tda10046_config = { | 454 | static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap) |
420 | .demod_address = 0x08, | ||
421 | .invert = 0, | ||
422 | .invert_oclk = 0, | ||
423 | .ts_mode = TDA10046_TS_SERIAL, | ||
424 | .xtal_freq = TDA10046_XTAL_16M, | ||
425 | .if_freq = TDA10046_FREQ_045, | ||
426 | .agc_config = TDA10046_AGC_TDA827X, | ||
427 | .gpio_config = TDA10046_GPTRI, | ||
428 | .request_firmware = NULL, | ||
429 | }; | ||
430 | |||
431 | static int digivox_tda10046_frontend_attach(struct dvb_usb_adapter *adap) | ||
432 | { | 455 | { |
433 | deb_rc("digivox_tda10046_frontend_attach!\n"); | 456 | deb("%s\n",__FUNCTION__); |
434 | 457 | ||
435 | if ((adap->fe = dvb_attach(tda10046_attach, &digivox_tda10046_config, | 458 | if ((adap->fe = dvb_attach(tda10046_attach, |
459 | &m920x_tda10046_0b_config, | ||
436 | &adap->dev->i2c_adap)) == NULL) | 460 | &adap->dev->i2c_adap)) == NULL) |
437 | return -EIO; | 461 | return -EIO; |
438 | 462 | ||
439 | return 0; | 463 | return 0; |
440 | } | 464 | } |
441 | 465 | ||
442 | static int digivox_tda8275_tuner_attach(struct dvb_usb_adapter *adap) | 466 | static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap) |
443 | { | 467 | { |
444 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, | 468 | deb("%s\n",__FUNCTION__); |
445 | NULL) == NULL) | 469 | |
470 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL) | ||
446 | return -ENODEV; | 471 | return -ENODEV; |
472 | |||
447 | return 0; | 473 | return 0; |
448 | } | 474 | } |
449 | 475 | ||
476 | static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap) | ||
477 | { | ||
478 | deb("%s\n",__FUNCTION__); | ||
479 | |||
480 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL) | ||
481 | return -ENODEV; | ||
482 | |||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap) | ||
487 | { | ||
488 | deb("%s\n",__FUNCTION__); | ||
489 | |||
490 | if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL) | ||
491 | return -ENODEV; | ||
492 | |||
493 | return 0; | ||
494 | } | ||
495 | |||
496 | /* device-specific initialization */ | ||
497 | static struct m920x_inits megasky_rc_init [] = { | ||
498 | { M9206_RC_INIT2, 0xa8 }, | ||
499 | { M9206_RC_INIT1, 0x51 }, | ||
500 | { } /* terminating entry */ | ||
501 | }; | ||
502 | |||
503 | static struct m920x_inits tvwalkertwin_rc_init [] = { | ||
504 | { M9206_RC_INIT2, 0x00 }, | ||
505 | { M9206_RC_INIT1, 0xef }, | ||
506 | { 0xff28, 0x00 }, | ||
507 | { 0xff23, 0x00 }, | ||
508 | { 0xff21, 0x30 }, | ||
509 | { } /* terminating entry */ | ||
510 | }; | ||
511 | |||
512 | /* ir keymaps */ | ||
513 | static struct dvb_usb_rc_key megasky_rc_keys [] = { | ||
514 | { 0x0, 0x12, KEY_POWER }, | ||
515 | { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */ | ||
516 | { 0x0, 0x02, KEY_CHANNELUP }, | ||
517 | { 0x0, 0x05, KEY_CHANNELDOWN }, | ||
518 | { 0x0, 0x03, KEY_VOLUMEUP }, | ||
519 | { 0x0, 0x06, KEY_VOLUMEDOWN }, | ||
520 | { 0x0, 0x04, KEY_MUTE }, | ||
521 | { 0x0, 0x07, KEY_OK }, /* TS */ | ||
522 | { 0x0, 0x08, KEY_STOP }, | ||
523 | { 0x0, 0x09, KEY_MENU }, /* swap */ | ||
524 | { 0x0, 0x0a, KEY_REWIND }, | ||
525 | { 0x0, 0x1b, KEY_PAUSE }, | ||
526 | { 0x0, 0x1f, KEY_FASTFORWARD }, | ||
527 | { 0x0, 0x0c, KEY_RECORD }, | ||
528 | { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */ | ||
529 | { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */ | ||
530 | }; | ||
531 | |||
532 | static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = { | ||
533 | { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */ | ||
534 | { 0x0, 0x02, KEY_CAMERA }, /* snapshot */ | ||
535 | { 0x0, 0x03, KEY_MUTE }, | ||
536 | { 0x0, 0x04, KEY_REWIND }, | ||
537 | { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */ | ||
538 | { 0x0, 0x06, KEY_FASTFORWARD }, | ||
539 | { 0x0, 0x07, KEY_RECORD }, | ||
540 | { 0x0, 0x08, KEY_STOP }, | ||
541 | { 0x0, 0x09, KEY_TIME }, /* Timeshift */ | ||
542 | { 0x0, 0x0c, KEY_COFFEE }, /* Recall */ | ||
543 | { 0x0, 0x0e, KEY_CHANNELUP }, | ||
544 | { 0x0, 0x12, KEY_POWER }, | ||
545 | { 0x0, 0x15, KEY_MENU }, /* source */ | ||
546 | { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */ | ||
547 | { 0x0, 0x1a, KEY_CHANNELDOWN }, | ||
548 | { 0x0, 0x1b, KEY_VOLUMEDOWN }, | ||
549 | { 0x0, 0x1e, KEY_VOLUMEUP }, | ||
550 | }; | ||
551 | |||
450 | /* DVB USB Driver stuff */ | 552 | /* DVB USB Driver stuff */ |
451 | static struct dvb_usb_device_properties megasky_properties; | 553 | static struct dvb_usb_device_properties megasky_properties; |
452 | static struct dvb_usb_device_properties digivox_mini_ii_properties; | 554 | static struct dvb_usb_device_properties digivox_mini_ii_properties; |
555 | static struct dvb_usb_device_properties tvwalkertwin_properties; | ||
556 | static struct dvb_usb_device_properties dposh_properties; | ||
453 | 557 | ||
454 | static int m920x_probe(struct usb_interface *intf, | 558 | static int m920x_probe(struct usb_interface *intf, |
455 | const struct usb_device_id *id) | 559 | const struct usb_device_id *id) |
@@ -457,19 +561,57 @@ static int m920x_probe(struct usb_interface *intf, | |||
457 | struct dvb_usb_device *d; | 561 | struct dvb_usb_device *d; |
458 | struct usb_host_interface *alt; | 562 | struct usb_host_interface *alt; |
459 | int ret; | 563 | int ret; |
564 | struct m920x_inits *rc_init_seq = NULL; | ||
565 | int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber; | ||
460 | 566 | ||
461 | deb_rc("Probed!\n"); | 567 | deb("Probing for m920x device at interface %d\n", bInterfaceNumber); |
462 | 568 | ||
463 | if (((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) || | 569 | if (bInterfaceNumber == 0) { |
464 | ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, THIS_MODULE, &d)) == 0)) | 570 | /* Single-tuner device, or first interface on |
465 | goto found; | 571 | * multi-tuner device |
572 | */ | ||
466 | 573 | ||
467 | return ret; | 574 | if ((ret = dvb_usb_device_init(intf, &megasky_properties, |
575 | THIS_MODULE, &d)) == 0) { | ||
576 | rc_init_seq = megasky_rc_init; | ||
577 | goto found; | ||
578 | } | ||
579 | |||
580 | if ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, | ||
581 | THIS_MODULE, &d)) == 0) { | ||
582 | /* No remote control, so no rc_init_seq */ | ||
583 | goto found; | ||
584 | } | ||
585 | |||
586 | /* This configures both tuners on the TV Walker Twin */ | ||
587 | if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties, | ||
588 | THIS_MODULE, &d)) == 0) { | ||
589 | rc_init_seq = tvwalkertwin_rc_init; | ||
590 | goto found; | ||
591 | } | ||
592 | |||
593 | if ((ret = dvb_usb_device_init(intf, &dposh_properties, | ||
594 | THIS_MODULE, &d)) == 0) { | ||
595 | /* Remote controller not supported yet. */ | ||
596 | goto found; | ||
597 | } | ||
598 | |||
599 | return ret; | ||
600 | } else { | ||
601 | /* Another interface on a multi-tuner device */ | ||
468 | 602 | ||
469 | found: | 603 | /* The LifeView TV Walker Twin gets here, but struct |
604 | * tvwalkertwin_properties already configured both | ||
605 | * tuners, so there is nothing for us to do here | ||
606 | */ | ||
607 | |||
608 | return -ENODEV; | ||
609 | } | ||
610 | |||
611 | found: | ||
470 | alt = usb_altnum_to_altsetting(intf, 1); | 612 | alt = usb_altnum_to_altsetting(intf, 1); |
471 | if (alt == NULL) { | 613 | if (alt == NULL) { |
472 | deb_rc("No alt found!\n"); | 614 | deb("No alt found!\n"); |
473 | return -ENODEV; | 615 | return -ENODEV; |
474 | } | 616 | } |
475 | 617 | ||
@@ -478,7 +620,7 @@ found: | |||
478 | if (ret < 0) | 620 | if (ret < 0) |
479 | return ret; | 621 | return ret; |
480 | 622 | ||
481 | if ((ret = m9206_init(d)) != 0) | 623 | if ((ret = m920x_init(d, rc_init_seq)) != 0) |
482 | return ret; | 624 | return ret; |
483 | 625 | ||
484 | return ret; | 626 | return ret; |
@@ -488,6 +630,12 @@ static struct usb_device_id m920x_table [] = { | |||
488 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, | 630 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, |
489 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, | 631 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
490 | USB_PID_MSI_DIGI_VOX_MINI_II) }, | 632 | USB_PID_MSI_DIGI_VOX_MINI_II) }, |
633 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, | ||
634 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) }, | ||
635 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, | ||
636 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) }, | ||
637 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) }, | ||
638 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) }, | ||
491 | { } /* Terminating entry */ | 639 | { } /* Terminating entry */ |
492 | }; | 640 | }; |
493 | MODULE_DEVICE_TABLE (usb, m920x_table); | 641 | MODULE_DEVICE_TABLE (usb, m920x_table); |
@@ -497,14 +645,14 @@ static struct dvb_usb_device_properties megasky_properties = { | |||
497 | 645 | ||
498 | .usb_ctrl = DEVICE_SPECIFIC, | 646 | .usb_ctrl = DEVICE_SPECIFIC, |
499 | .firmware = "dvb-usb-megasky-02.fw", | 647 | .firmware = "dvb-usb-megasky-02.fw", |
500 | .download_firmware = m9206_firmware_download, | 648 | .download_firmware = m920x_firmware_download, |
501 | 649 | ||
502 | .rc_interval = 100, | 650 | .rc_interval = 100, |
503 | .rc_key_map = megasky_rc_keys, | 651 | .rc_key_map = megasky_rc_keys, |
504 | .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys), | 652 | .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys), |
505 | .rc_query = m9206_rc_query, | 653 | .rc_query = m920x_rc_query, |
506 | 654 | ||
507 | .size_of_priv = sizeof(struct m9206_state), | 655 | .size_of_priv = sizeof(struct m920x_state), |
508 | 656 | ||
509 | .identify_state = m920x_identify_state, | 657 | .identify_state = m920x_identify_state, |
510 | .num_adapters = 1, | 658 | .num_adapters = 1, |
@@ -513,11 +661,11 @@ static struct dvb_usb_device_properties megasky_properties = { | |||
513 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | 661 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
514 | 662 | ||
515 | .pid_filter_count = 8, | 663 | .pid_filter_count = 8, |
516 | .pid_filter = m9206_pid_filter, | 664 | .pid_filter = m920x_pid_filter, |
517 | .pid_filter_ctrl = m9206_pid_filter_ctrl, | 665 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
518 | 666 | ||
519 | .frontend_attach = megasky_mt352_frontend_attach, | 667 | .frontend_attach = m920x_mt352_frontend_attach, |
520 | .tuner_attach = megasky_qt1010_tuner_attach, | 668 | .tuner_attach = m920x_qt1010_tuner_attach, |
521 | 669 | ||
522 | .stream = { | 670 | .stream = { |
523 | .type = USB_BULK, | 671 | .type = USB_BULK, |
@@ -530,7 +678,7 @@ static struct dvb_usb_device_properties megasky_properties = { | |||
530 | } | 678 | } |
531 | }, | 679 | }, |
532 | }}, | 680 | }}, |
533 | .i2c_algo = &m9206_i2c_algo, | 681 | .i2c_algo = &m920x_i2c_algo, |
534 | 682 | ||
535 | .num_device_descs = 1, | 683 | .num_device_descs = 1, |
536 | .devices = { | 684 | .devices = { |
@@ -546,22 +694,22 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = { | |||
546 | 694 | ||
547 | .usb_ctrl = DEVICE_SPECIFIC, | 695 | .usb_ctrl = DEVICE_SPECIFIC, |
548 | .firmware = "dvb-usb-digivox-02.fw", | 696 | .firmware = "dvb-usb-digivox-02.fw", |
549 | .download_firmware = m9206_firmware_download, | 697 | .download_firmware = m920x_firmware_download, |
550 | 698 | ||
551 | .size_of_priv = sizeof(struct m9206_state), | 699 | .size_of_priv = sizeof(struct m920x_state), |
552 | 700 | ||
553 | .identify_state = m920x_identify_state, | 701 | .identify_state = m920x_identify_state, |
554 | .num_adapters = 1, | 702 | .num_adapters = 1, |
555 | .adapter = {{ | 703 | .adapter = {{ |
556 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | 704 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
557 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | 705 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
558 | 706 | ||
559 | .pid_filter_count = 8, | 707 | .pid_filter_count = 8, |
560 | .pid_filter = m9206_pid_filter, | 708 | .pid_filter = m920x_pid_filter, |
561 | .pid_filter_ctrl = m9206_pid_filter_ctrl, | 709 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
562 | 710 | ||
563 | .frontend_attach = digivox_tda10046_frontend_attach, | 711 | .frontend_attach = m920x_tda10046_08_frontend_attach, |
564 | .tuner_attach = digivox_tda8275_tuner_attach, | 712 | .tuner_attach = m920x_tda8275_60_tuner_attach, |
565 | 713 | ||
566 | .stream = { | 714 | .stream = { |
567 | .type = USB_BULK, | 715 | .type = USB_BULK, |
@@ -574,7 +722,7 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = { | |||
574 | } | 722 | } |
575 | }, | 723 | }, |
576 | }}, | 724 | }}, |
577 | .i2c_algo = &m9206_i2c_algo, | 725 | .i2c_algo = &m920x_i2c_algo, |
578 | 726 | ||
579 | .num_device_descs = 1, | 727 | .num_device_descs = 1, |
580 | .devices = { | 728 | .devices = { |
@@ -585,6 +733,122 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = { | |||
585 | } | 733 | } |
586 | }; | 734 | }; |
587 | 735 | ||
736 | /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net> | ||
737 | * | ||
738 | * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A | ||
739 | * TDA10046 #0 is located at i2c address 0x08 | ||
740 | * TDA10046 #1 is located at i2c address 0x0b (presently disabled - not yet working) | ||
741 | * TDA8275A #0 is located at i2c address 0x60 | ||
742 | * TDA8275A #1 is located at i2c address 0x61 (presently disabled - not yet working) | ||
743 | */ | ||
744 | static struct dvb_usb_device_properties tvwalkertwin_properties = { | ||
745 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
746 | |||
747 | .usb_ctrl = DEVICE_SPECIFIC, | ||
748 | .firmware = "dvb-usb-tvwalkert.fw", | ||
749 | .download_firmware = m920x_firmware_download, | ||
750 | |||
751 | .rc_interval = 100, | ||
752 | .rc_key_map = tvwalkertwin_rc_keys, | ||
753 | .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys), | ||
754 | .rc_query = m920x_rc_query, | ||
755 | |||
756 | .size_of_priv = sizeof(struct m920x_state), | ||
757 | |||
758 | .identify_state = m920x_identify_state, | ||
759 | .num_adapters = 1, | ||
760 | .adapter = {{ | ||
761 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
762 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
763 | |||
764 | .pid_filter_count = 8, | ||
765 | .pid_filter = m920x_pid_filter, | ||
766 | .pid_filter_ctrl = m920x_pid_filter_ctrl, | ||
767 | |||
768 | .frontend_attach = m920x_tda10046_08_frontend_attach, | ||
769 | .tuner_attach = m920x_tda8275_60_tuner_attach, | ||
770 | |||
771 | .stream = { | ||
772 | .type = USB_BULK, | ||
773 | .count = 8, | ||
774 | .endpoint = 0x81, | ||
775 | .u = { | ||
776 | .bulk = { | ||
777 | .buffersize = 512, | ||
778 | } | ||
779 | } | ||
780 | }},{ | ||
781 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
782 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
783 | |||
784 | .pid_filter_count = 8, | ||
785 | .pid_filter = m920x_pid_filter, | ||
786 | .pid_filter_ctrl = m920x_pid_filter_ctrl, | ||
787 | |||
788 | .frontend_attach = m920x_tda10046_0b_frontend_attach, | ||
789 | .tuner_attach = m920x_tda8275_61_tuner_attach, | ||
790 | |||
791 | .stream = { | ||
792 | .type = USB_BULK, | ||
793 | .count = 8, | ||
794 | .endpoint = 0x82, | ||
795 | .u = { | ||
796 | .bulk = { | ||
797 | .buffersize = 512, | ||
798 | } | ||
799 | } | ||
800 | }, | ||
801 | }}, | ||
802 | .i2c_algo = &m920x_i2c_algo, | ||
803 | |||
804 | .num_device_descs = 1, | ||
805 | .devices = { | ||
806 | { .name = "LifeView TV Walker Twin DVB-T USB2.0", | ||
807 | .cold_ids = { &m920x_table[2], NULL }, | ||
808 | .warm_ids = { &m920x_table[3], NULL }, | ||
809 | }, | ||
810 | } | ||
811 | }; | ||
812 | |||
813 | static struct dvb_usb_device_properties dposh_properties = { | ||
814 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
815 | |||
816 | .usb_ctrl = DEVICE_SPECIFIC, | ||
817 | .firmware = "dvb-usb-dposh-01.fw", | ||
818 | .download_firmware = m920x_firmware_download, | ||
819 | |||
820 | .size_of_priv = sizeof(struct m920x_state), | ||
821 | |||
822 | .identify_state = m920x_identify_state, | ||
823 | .num_adapters = 1, | ||
824 | .adapter = {{ | ||
825 | /* Hardware pid filters don't work with this device/firmware */ | ||
826 | |||
827 | .frontend_attach = m920x_mt352_frontend_attach, | ||
828 | .tuner_attach = m920x_qt1010_tuner_attach, | ||
829 | |||
830 | .stream = { | ||
831 | .type = USB_BULK, | ||
832 | .count = 8, | ||
833 | .endpoint = 0x81, | ||
834 | .u = { | ||
835 | .bulk = { | ||
836 | .buffersize = 512, | ||
837 | } | ||
838 | } | ||
839 | }, | ||
840 | }}, | ||
841 | .i2c_algo = &m920x_i2c_algo, | ||
842 | |||
843 | .num_device_descs = 1, | ||
844 | .devices = { | ||
845 | { .name = "Dposh DVB-T USB2.0", | ||
846 | .cold_ids = { &m920x_table[4], NULL }, | ||
847 | .warm_ids = { &m920x_table[5], NULL }, | ||
848 | }, | ||
849 | } | ||
850 | }; | ||
851 | |||
588 | static struct usb_driver m920x_driver = { | 852 | static struct usb_driver m920x_driver = { |
589 | .name = "dvb_usb_m920x", | 853 | .name = "dvb_usb_m920x", |
590 | .probe = m920x_probe, | 854 | .probe = m920x_probe, |
@@ -615,6 +879,11 @@ module_init (m920x_module_init); | |||
615 | module_exit (m920x_module_exit); | 879 | module_exit (m920x_module_exit); |
616 | 880 | ||
617 | MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>"); | 881 | MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>"); |
618 | MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / Uli m920x"); | 882 | MODULE_DESCRIPTION("DVB Driver for ULI M920x"); |
619 | MODULE_VERSION("0.1"); | 883 | MODULE_VERSION("0.1"); |
620 | MODULE_LICENSE("GPL"); | 884 | MODULE_LICENSE("GPL"); |
885 | |||
886 | /* | ||
887 | * Local variables: | ||
888 | * c-basic-offset: 8 | ||
889 | */ | ||
diff --git a/drivers/media/dvb/dvb-usb/m920x.h b/drivers/media/dvb/dvb-usb/m920x.h index 7dd3db65c80e..2c8942d04222 100644 --- a/drivers/media/dvb/dvb-usb/m920x.h +++ b/drivers/media/dvb/dvb-usb/m920x.h | |||
@@ -4,7 +4,7 @@ | |||
4 | #define DVB_USB_LOG_PREFIX "m920x" | 4 | #define DVB_USB_LOG_PREFIX "m920x" |
5 | #include "dvb-usb.h" | 5 | #include "dvb-usb.h" |
6 | 6 | ||
7 | #define deb_rc(args...) dprintk(dvb_usb_m920x_debug,0x01,args) | 7 | #define deb(args...) dprintk(dvb_usb_m920x_debug,0x01,args) |
8 | 8 | ||
9 | #define M9206_CORE 0x22 | 9 | #define M9206_CORE 0x22 |
10 | #define M9206_RC_STATE 0xff51 | 10 | #define M9206_RC_STATE 0xff51 |
@@ -59,9 +59,18 @@ What any other bits might mean, or how to get the slave's ACK/NACK | |||
59 | response to a write, is unknown. | 59 | response to a write, is unknown. |
60 | */ | 60 | */ |
61 | 61 | ||
62 | struct m9206_state { | 62 | struct m920x_state { |
63 | u16 filters[M9206_MAX_FILTERS]; | 63 | u16 filters[M9206_MAX_FILTERS]; |
64 | int filtering_enabled; | 64 | int filtering_enabled; |
65 | int rep_count; | 65 | int rep_count; |
66 | }; | 66 | }; |
67 | |||
68 | /* Initialisation data for the m920x | ||
69 | */ | ||
70 | |||
71 | struct m920x_inits { | ||
72 | u16 address; | ||
73 | u8 data; | ||
74 | }; | ||
75 | |||
67 | #endif | 76 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c index 3ecb2e0ce80f..c3fdc7cd094e 100644 --- a/drivers/media/dvb/dvb-usb/vp702x-fe.c +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c | |||
@@ -204,8 +204,8 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe, | |||
204 | static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | 204 | static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, |
205 | struct dvb_diseqc_master_cmd *m) | 205 | struct dvb_diseqc_master_cmd *m) |
206 | { | 206 | { |
207 | //struct vp702x_fe_state *st = fe->demodulator_priv; | 207 | struct vp702x_fe_state *st = fe->demodulator_priv; |
208 | u8 cmd[8];//,ibuf[10]; | 208 | u8 cmd[8],ibuf[10]; |
209 | memset(cmd,0,8); | 209 | memset(cmd,0,8); |
210 | 210 | ||
211 | deb_fe("%s\n",__FUNCTION__); | 211 | deb_fe("%s\n",__FUNCTION__); |
@@ -218,12 +218,12 @@ static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | |||
218 | memcpy(&cmd[3], m->msg, m->msg_len); | 218 | memcpy(&cmd[3], m->msg, m->msg_len); |
219 | cmd[7] = vp702x_chksum(cmd,0,7); | 219 | cmd[7] = vp702x_chksum(cmd,0,7); |
220 | 220 | ||
221 | // vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); | 221 | vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); |
222 | 222 | ||
223 | // if (ibuf[2] == 0 && ibuf[3] == 0) | 223 | if (ibuf[2] == 0 && ibuf[3] == 0) |
224 | // deb_fe("diseqc cmd failed.\n"); | 224 | deb_fe("diseqc cmd failed.\n"); |
225 | // else | 225 | else |
226 | // deb_fe("diseqc cmd succeeded.\n"); | 226 | deb_fe("diseqc cmd succeeded.\n"); |
227 | 227 | ||
228 | return 0; | 228 | return 0; |
229 | } | 229 | } |
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c index 058df5c10034..08a2599ed74a 100644 --- a/drivers/media/dvb/pluto2/pluto2.c +++ b/drivers/media/dvb/pluto2/pluto2.c | |||
@@ -293,12 +293,20 @@ static void pluto_dma_end(struct pluto *pluto, unsigned int nbpackets) | |||
293 | * but no packets have been transfered. | 293 | * but no packets have been transfered. |
294 | * [2] Sometimes (actually very often) NBPACKETS stays at zero | 294 | * [2] Sometimes (actually very often) NBPACKETS stays at zero |
295 | * although one packet has been transfered. | 295 | * although one packet has been transfered. |
296 | * [3] Sometimes (actually rarely), the card gets into an erroneous | ||
297 | * mode where it continuously generates interrupts, claiming it | ||
298 | * has recieved nbpackets>TS_DMA_PACKETS packets, but no packet | ||
299 | * has been transfered. Only a reset seems to solve this | ||
296 | */ | 300 | */ |
297 | if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) { | 301 | if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) { |
298 | unsigned int i = 0; | 302 | unsigned int i = 0; |
299 | while (pluto->dma_buf[i] == 0x47) | 303 | while (pluto->dma_buf[i] == 0x47) |
300 | i += 188; | 304 | i += 188; |
301 | nbpackets = i / 188; | 305 | nbpackets = i / 188; |
306 | if (i == 0) { | ||
307 | pluto_reset_ts(pluto, 1); | ||
308 | dev_printk(KERN_DEBUG, &pluto->pdev->dev, "resetting TS because of invalid packet counter\n"); | ||
309 | } | ||
302 | } | 310 | } |
303 | 311 | ||
304 | dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets); | 312 | dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets); |
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index 67becdd4db60..ef1108c0bf11 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c | |||
@@ -1246,6 +1246,9 @@ static void vpeirq(unsigned long data) | |||
1246 | if (!budget->feeding1 || (newdma == olddma)) | 1246 | if (!budget->feeding1 || (newdma == olddma)) |
1247 | return; | 1247 | return; |
1248 | 1248 | ||
1249 | /* Ensure streamed PCI data is synced to CPU */ | ||
1250 | pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE); | ||
1251 | |||
1249 | #if 0 | 1252 | #if 0 |
1250 | /* track rps1 activity */ | 1253 | /* track rps1 activity */ |
1251 | printk("vpeirq: %02x Event Counter 1 0x%04x\n", | 1254 | printk("vpeirq: %02x Event Counter 1 0x%04x\n", |
@@ -2679,8 +2682,8 @@ err_iobuf_vfree_6: | |||
2679 | err_pci_free_5: | 2682 | err_pci_free_5: |
2680 | pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus); | 2683 | pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus); |
2681 | err_saa71466_vfree_4: | 2684 | err_saa71466_vfree_4: |
2682 | if (!av7110->grabbing) | 2685 | if (av7110->grabbing) |
2683 | saa7146_pgtable_free(pdev, &av7110->pt); | 2686 | saa7146_vfree_destroy_pgtable(pdev, av7110->grabbing, &av7110->pt); |
2684 | err_i2c_del_3: | 2687 | err_i2c_del_3: |
2685 | i2c_del_adapter(&av7110->i2c_adap); | 2688 | i2c_del_adapter(&av7110->i2c_adap); |
2686 | err_dvb_unregister_adapter_2: | 2689 | err_dvb_unregister_adapter_2: |
@@ -2710,7 +2713,7 @@ static int __devexit av7110_detach(struct saa7146_dev* saa) | |||
2710 | SAA7146_ISR_CLEAR(saa, MASK_10); | 2713 | SAA7146_ISR_CLEAR(saa, MASK_10); |
2711 | msleep(50); | 2714 | msleep(50); |
2712 | tasklet_kill(&av7110->vpe_tasklet); | 2715 | tasklet_kill(&av7110->vpe_tasklet); |
2713 | saa7146_pgtable_free(saa->pci, &av7110->pt); | 2716 | saa7146_vfree_destroy_pgtable(saa->pci, av7110->grabbing, &av7110->pt); |
2714 | } | 2717 | } |
2715 | av7110_exit_v4l(av7110); | 2718 | av7110_exit_v4l(av7110); |
2716 | 2719 | ||
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 4ed4599ce816..9d42f88ebb0e 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
@@ -904,7 +904,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc | |||
904 | band = 1; | 904 | band = 1; |
905 | } else if (tuner_frequency < 200000000) { | 905 | } else if (tuner_frequency < 200000000) { |
906 | cp = 6; | 906 | cp = 6; |
907 | band = 2; | 907 | band = 1; |
908 | } else if (tuner_frequency < 290000000) { | 908 | } else if (tuner_frequency < 290000000) { |
909 | cp = 3; | 909 | cp = 3; |
910 | band = 2; | 910 | band = 2; |
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c index 6b97dc1e6b65..2557ac9620d0 100644 --- a/drivers/media/dvb/ttpci/budget-core.c +++ b/drivers/media/dvb/ttpci/budget-core.c | |||
@@ -195,6 +195,9 @@ static void vpeirq(unsigned long data) | |||
195 | u32 newdma = saa7146_read(budget->dev, PCI_VDP3); | 195 | u32 newdma = saa7146_read(budget->dev, PCI_VDP3); |
196 | u32 count; | 196 | u32 count; |
197 | 197 | ||
198 | /* Ensure streamed PCI data is synced to CPU */ | ||
199 | pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE); | ||
200 | |||
198 | /* nearest lower position divisible by 188 */ | 201 | /* nearest lower position divisible by 188 */ |
199 | newdma -= newdma % 188; | 202 | newdma -= newdma % 188; |
200 | 203 | ||
@@ -504,16 +507,16 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, | |||
504 | strcpy(budget->i2c_adap.name, budget->card->name); | 507 | strcpy(budget->i2c_adap.name, budget->card->name); |
505 | 508 | ||
506 | if (i2c_add_adapter(&budget->i2c_adap) < 0) { | 509 | if (i2c_add_adapter(&budget->i2c_adap) < 0) { |
507 | dvb_unregister_adapter(&budget->dvb_adapter); | 510 | ret = -ENOMEM; |
508 | return -ENOMEM; | 511 | goto err_dvb_unregister; |
509 | } | 512 | } |
510 | 513 | ||
511 | ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac); | 514 | ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac); |
512 | 515 | ||
513 | if (NULL == | 516 | budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt); |
514 | (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt))) { | 517 | if (NULL == budget->grabbing) { |
515 | ret = -ENOMEM; | 518 | ret = -ENOMEM; |
516 | goto err; | 519 | goto err_del_i2c; |
517 | } | 520 | } |
518 | 521 | ||
519 | saa7146_write(dev, PCI_BT_V1, 0x001c0000); | 522 | saa7146_write(dev, PCI_BT_V1, 0x001c0000); |
@@ -526,14 +529,16 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, | |||
526 | if (bi->type != BUDGET_FS_ACTIVY) | 529 | if (bi->type != BUDGET_FS_ACTIVY) |
527 | saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); | 530 | saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); |
528 | 531 | ||
529 | if (budget_register(budget) == 0) { | 532 | if (budget_register(budget) == 0) |
530 | return 0; | 533 | return 0; /* Everything OK */ |
531 | } | 534 | |
532 | err: | 535 | /* An error occurred, cleanup resources */ |
533 | i2c_del_adapter(&budget->i2c_adap); | 536 | saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt); |
534 | 537 | ||
535 | vfree(budget->grabbing); | 538 | err_del_i2c: |
539 | i2c_del_adapter(&budget->i2c_adap); | ||
536 | 540 | ||
541 | err_dvb_unregister: | ||
537 | dvb_unregister_adapter(&budget->dvb_adapter); | 542 | dvb_unregister_adapter(&budget->dvb_adapter); |
538 | 543 | ||
539 | return ret; | 544 | return ret; |
@@ -555,15 +560,13 @@ int ttpci_budget_deinit(struct budget *budget) | |||
555 | 560 | ||
556 | budget_unregister(budget); | 561 | budget_unregister(budget); |
557 | 562 | ||
558 | i2c_del_adapter(&budget->i2c_adap); | ||
559 | |||
560 | dvb_unregister_adapter(&budget->dvb_adapter); | ||
561 | |||
562 | tasklet_kill(&budget->vpe_tasklet); | 563 | tasklet_kill(&budget->vpe_tasklet); |
563 | 564 | ||
564 | saa7146_pgtable_free(dev->pci, &budget->pt); | 565 | saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt); |
565 | 566 | ||
566 | vfree(budget->grabbing); | 567 | i2c_del_adapter(&budget->i2c_adap); |
568 | |||
569 | dvb_unregister_adapter(&budget->dvb_adapter); | ||
567 | 570 | ||
568 | return 0; | 571 | return 0; |
569 | } | 572 | } |
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index af66a5d5ecd8..a6ac82a609d4 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -2,8 +2,14 @@ | |||
2 | # Multimedia Video device configuration | 2 | # Multimedia Video device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Radio Adapters" | 5 | menuconfig RADIO_ADAPTERS |
6 | bool "Radio Adapters" | ||
6 | depends on VIDEO_DEV | 7 | depends on VIDEO_DEV |
8 | default y | ||
9 | ---help--- | ||
10 | Say Y here to enable selecting AM/FM radio adapters. | ||
11 | |||
12 | if RADIO_ADAPTERS | ||
7 | 13 | ||
8 | config RADIO_CADET | 14 | config RADIO_CADET |
9 | tristate "ADS Cadet AM/FM Tuner" | 15 | tristate "ADS Cadet AM/FM Tuner" |
@@ -328,4 +334,5 @@ config USB_DSBR | |||
328 | 334 | ||
329 | To compile this driver as a module, choose M here: the | 335 | To compile this driver as a module, choose M here: the |
330 | module will be called dsbr100. | 336 | module will be called dsbr100. |
331 | endmenu | 337 | |
338 | endif # RADIO_ADAPTERS | ||
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 449df1bb00d3..3bd07f7e3774 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -33,6 +33,10 @@ | |||
33 | 33 | ||
34 | History: | 34 | History: |
35 | 35 | ||
36 | Version 0.42: | ||
37 | Converted dsbr100 to use video_ioctl2 | ||
38 | by Douglas Landgraf <dougsland@gmail.com> | ||
39 | |||
36 | Version 0.41-ac1: | 40 | Version 0.41-ac1: |
37 | Alan Cox: Some cleanups and fixes | 41 | Alan Cox: Some cleanups and fixes |
38 | 42 | ||
@@ -121,8 +125,6 @@ devices, that would be 76 and 91. */ | |||
121 | static int usb_dsbr100_probe(struct usb_interface *intf, | 125 | static int usb_dsbr100_probe(struct usb_interface *intf, |
122 | const struct usb_device_id *id); | 126 | const struct usb_device_id *id); |
123 | static void usb_dsbr100_disconnect(struct usb_interface *intf); | 127 | static void usb_dsbr100_disconnect(struct usb_interface *intf); |
124 | static int usb_dsbr100_ioctl(struct inode *inode, struct file *file, | ||
125 | unsigned int cmd, unsigned long arg); | ||
126 | static int usb_dsbr100_open(struct inode *inode, struct file *file); | 128 | static int usb_dsbr100_open(struct inode *inode, struct file *file); |
127 | static int usb_dsbr100_close(struct inode *inode, struct file *file); | 129 | static int usb_dsbr100_close(struct inode *inode, struct file *file); |
128 | 130 | ||
@@ -142,26 +144,6 @@ struct dsbr100_device { | |||
142 | }; | 144 | }; |
143 | 145 | ||
144 | 146 | ||
145 | /* File system interface */ | ||
146 | static const struct file_operations usb_dsbr100_fops = { | ||
147 | .owner = THIS_MODULE, | ||
148 | .open = usb_dsbr100_open, | ||
149 | .release = usb_dsbr100_close, | ||
150 | .ioctl = usb_dsbr100_ioctl, | ||
151 | .compat_ioctl = v4l_compat_ioctl32, | ||
152 | .llseek = no_llseek, | ||
153 | }; | ||
154 | |||
155 | /* V4L interface */ | ||
156 | static struct video_device dsbr100_videodev_template= | ||
157 | { | ||
158 | .owner = THIS_MODULE, | ||
159 | .name = "D-Link DSB-R 100", | ||
160 | .type = VID_TYPE_TUNER, | ||
161 | .fops = &usb_dsbr100_fops, | ||
162 | .release = video_device_release, | ||
163 | }; | ||
164 | |||
165 | static struct usb_device_id usb_dsbr100_device_table [] = { | 147 | static struct usb_device_id usb_dsbr100_device_table [] = { |
166 | { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, | 148 | { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, |
167 | { } /* Terminating entry */ | 149 | { } /* Terminating entry */ |
@@ -252,37 +234,6 @@ static void dsbr100_getstat(struct dsbr100_device *radio) | |||
252 | 234 | ||
253 | /* USB subsystem interface begins here */ | 235 | /* USB subsystem interface begins here */ |
254 | 236 | ||
255 | /* check if the device is present and register with v4l and | ||
256 | usb if it is */ | ||
257 | static int usb_dsbr100_probe(struct usb_interface *intf, | ||
258 | const struct usb_device_id *id) | ||
259 | { | ||
260 | struct dsbr100_device *radio; | ||
261 | |||
262 | if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL))) | ||
263 | return -ENOMEM; | ||
264 | if (!(radio->videodev = video_device_alloc())) { | ||
265 | kfree(radio); | ||
266 | return -ENOMEM; | ||
267 | } | ||
268 | memcpy(radio->videodev, &dsbr100_videodev_template, | ||
269 | sizeof(dsbr100_videodev_template)); | ||
270 | radio->removed = 0; | ||
271 | radio->users = 0; | ||
272 | radio->usbdev = interface_to_usbdev(intf); | ||
273 | radio->curfreq = FREQ_MIN*FREQ_MUL; | ||
274 | video_set_drvdata(radio->videodev, radio); | ||
275 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, | ||
276 | radio_nr)) { | ||
277 | warn("Could not register video device"); | ||
278 | video_device_release(radio->videodev); | ||
279 | kfree(radio); | ||
280 | return -EIO; | ||
281 | } | ||
282 | usb_set_intfdata(intf, radio); | ||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | /* handle unplugging of the device, release data structures | 237 | /* handle unplugging of the device, release data structures |
287 | if nothing keeps us from doing it. If something is still | 238 | if nothing keeps us from doing it. If something is still |
288 | keeping us busy, the release callback of v4l will take care | 239 | keeping us busy, the release callback of v4l will take care |
@@ -307,133 +258,147 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf) | |||
307 | } | 258 | } |
308 | 259 | ||
309 | 260 | ||
310 | /* Video for Linux interface */ | 261 | static int vidioc_querycap(struct file *file, void *priv, |
262 | struct v4l2_capability *v) | ||
263 | { | ||
264 | strlcpy(v->driver, "dsbr100", sizeof(v->driver)); | ||
265 | strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof(v->card)); | ||
266 | sprintf(v->bus_info, "ISA"); | ||
267 | v->version = RADIO_VERSION; | ||
268 | v->capabilities = V4L2_CAP_TUNER; | ||
269 | return 0; | ||
270 | } | ||
311 | 271 | ||
312 | static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file, | 272 | static int vidioc_g_tuner(struct file *file, void *priv, |
313 | unsigned int cmd, void *arg) | 273 | struct v4l2_tuner *v) |
314 | { | 274 | { |
315 | struct dsbr100_device *radio=video_get_drvdata(video_devdata(file)); | 275 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); |
276 | |||
277 | if (v->index > 0) | ||
278 | return -EINVAL; | ||
279 | |||
280 | dsbr100_getstat(radio); | ||
281 | strcpy(v->name, "FM"); | ||
282 | v->type = V4L2_TUNER_RADIO; | ||
283 | v->rangelow = FREQ_MIN*FREQ_MUL; | ||
284 | v->rangehigh = FREQ_MAX*FREQ_MUL; | ||
285 | v->rxsubchans = V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; | ||
286 | v->capability = V4L2_TUNER_CAP_LOW; | ||
287 | if(radio->stereo) | ||
288 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
289 | else | ||
290 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
291 | v->signal = 0xffff; /* We can't get the signal strength */ | ||
292 | return 0; | ||
293 | } | ||
316 | 294 | ||
317 | if (!radio) | 295 | static int vidioc_s_tuner(struct file *file, void *priv, |
318 | return -EIO; | 296 | struct v4l2_tuner *v) |
297 | { | ||
298 | if (v->index > 0) | ||
299 | return -EINVAL; | ||
319 | 300 | ||
320 | switch(cmd) { | 301 | return 0; |
321 | case VIDIOC_QUERYCAP: | 302 | } |
322 | { | ||
323 | struct v4l2_capability *v = arg; | ||
324 | memset(v,0,sizeof(*v)); | ||
325 | strlcpy(v->driver, "dsbr100", sizeof (v->driver)); | ||
326 | strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof (v->card)); | ||
327 | sprintf(v->bus_info,"ISA"); | ||
328 | v->version = RADIO_VERSION; | ||
329 | v->capabilities = V4L2_CAP_TUNER; | ||
330 | 303 | ||
331 | return 0; | 304 | static int vidioc_s_frequency(struct file *file, void *priv, |
332 | } | 305 | struct v4l2_frequency *f) |
333 | case VIDIOC_G_TUNER: | 306 | { |
334 | { | 307 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); |
335 | struct v4l2_tuner *v = arg; | ||
336 | 308 | ||
337 | if (v->index > 0) | 309 | radio->curfreq = f->frequency; |
338 | return -EINVAL; | 310 | if (dsbr100_setfreq(radio, radio->curfreq)==-1) |
311 | warn("Set frequency failed"); | ||
312 | return 0; | ||
313 | } | ||
339 | 314 | ||
340 | dsbr100_getstat(radio); | 315 | static int vidioc_g_frequency(struct file *file, void *priv, |
316 | struct v4l2_frequency *f) | ||
317 | { | ||
318 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); | ||
341 | 319 | ||
342 | memset(v,0,sizeof(*v)); | 320 | f->type = V4L2_TUNER_RADIO; |
343 | strcpy(v->name, "FM"); | 321 | f->frequency = radio->curfreq; |
344 | v->type = V4L2_TUNER_RADIO; | 322 | return 0; |
323 | } | ||
345 | 324 | ||
346 | v->rangelow = FREQ_MIN*FREQ_MUL; | 325 | static int vidioc_queryctrl(struct file *file, void *priv, |
347 | v->rangehigh = FREQ_MAX*FREQ_MUL; | 326 | struct v4l2_queryctrl *qc) |
348 | v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; | 327 | { |
349 | v->capability=V4L2_TUNER_CAP_LOW; | 328 | int i; |
350 | if(radio->stereo) | ||
351 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
352 | else | ||
353 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
354 | v->signal = 0xFFFF; /* We can't get the signal strength */ | ||
355 | 329 | ||
330 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | ||
331 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
332 | memcpy(qc, &(radio_qctrl[i]), | ||
333 | sizeof(*qc)); | ||
356 | return 0; | 334 | return 0; |
357 | } | 335 | } |
358 | case VIDIOC_S_TUNER: | 336 | } |
359 | { | 337 | return -EINVAL; |
360 | struct v4l2_tuner *v = arg; | 338 | } |
361 | |||
362 | if (v->index > 0) | ||
363 | return -EINVAL; | ||
364 | 339 | ||
365 | return 0; | 340 | static int vidioc_g_ctrl(struct file *file, void *priv, |
366 | } | 341 | struct v4l2_control *ctrl) |
367 | case VIDIOC_S_FREQUENCY: | 342 | { |
368 | { | 343 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); |
369 | struct v4l2_frequency *f = arg; | ||
370 | 344 | ||
371 | radio->curfreq = f->frequency; | 345 | switch (ctrl->id) { |
372 | if (dsbr100_setfreq(radio, radio->curfreq)==-1) | 346 | case V4L2_CID_AUDIO_MUTE: |
373 | warn("Set frequency failed"); | 347 | ctrl->value = radio->muted; |
374 | return 0; | 348 | return 0; |
375 | } | 349 | } |
376 | case VIDIOC_G_FREQUENCY: | 350 | return -EINVAL; |
377 | { | 351 | } |
378 | struct v4l2_frequency *f = arg; | ||
379 | 352 | ||
380 | f->type = V4L2_TUNER_RADIO; | 353 | static int vidioc_s_ctrl(struct file *file, void *priv, |
381 | f->frequency = radio->curfreq; | 354 | struct v4l2_control *ctrl) |
355 | { | ||
356 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); | ||
382 | 357 | ||
383 | return 0; | 358 | switch (ctrl->id) { |
384 | } | 359 | case V4L2_CID_AUDIO_MUTE: |
385 | case VIDIOC_QUERYCTRL: | 360 | if (ctrl->value) { |
386 | { | 361 | if (dsbr100_stop(radio)==-1) |
387 | struct v4l2_queryctrl *qc = arg; | 362 | warn("Radio did not respond properly"); |
388 | int i; | 363 | } else { |
389 | 364 | if (dsbr100_start(radio)==-1) | |
390 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | 365 | warn("Radio did not respond properly"); |
391 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
392 | memcpy(qc, &(radio_qctrl[i]), | ||
393 | sizeof(*qc)); | ||
394 | return 0; | ||
395 | } | ||
396 | } | ||
397 | return -EINVAL; | ||
398 | } | ||
399 | case VIDIOC_G_CTRL: | ||
400 | { | ||
401 | struct v4l2_control *ctrl= arg; | ||
402 | |||
403 | switch (ctrl->id) { | ||
404 | case V4L2_CID_AUDIO_MUTE: | ||
405 | ctrl->value=radio->muted; | ||
406 | return 0; | ||
407 | } | ||
408 | return -EINVAL; | ||
409 | } | ||
410 | case VIDIOC_S_CTRL: | ||
411 | { | ||
412 | struct v4l2_control *ctrl= arg; | ||
413 | |||
414 | switch (ctrl->id) { | ||
415 | case V4L2_CID_AUDIO_MUTE: | ||
416 | if (ctrl->value) { | ||
417 | if (dsbr100_stop(radio)==-1) | ||
418 | warn("Radio did not respond properly"); | ||
419 | } else { | ||
420 | if (dsbr100_start(radio)==-1) | ||
421 | warn("Radio did not respond properly"); | ||
422 | } | ||
423 | return 0; | ||
424 | } | ||
425 | return -EINVAL; | ||
426 | } | 366 | } |
427 | default: | 367 | return 0; |
428 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, | ||
429 | usb_dsbr100_do_ioctl); | ||
430 | } | 368 | } |
369 | return -EINVAL; | ||
431 | } | 370 | } |
432 | 371 | ||
433 | static int usb_dsbr100_ioctl(struct inode *inode, struct file *file, | 372 | static int vidioc_g_audio(struct file *file, void *priv, |
434 | unsigned int cmd, unsigned long arg) | 373 | struct v4l2_audio *a) |
435 | { | 374 | { |
436 | return video_usercopy(inode, file, cmd, arg, usb_dsbr100_do_ioctl); | 375 | if (a->index > 1) |
376 | return -EINVAL; | ||
377 | |||
378 | strcpy(a->name, "Radio"); | ||
379 | a->capability = V4L2_AUDCAP_STEREO; | ||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) | ||
384 | { | ||
385 | *i = 0; | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | ||
390 | { | ||
391 | if (i != 0) | ||
392 | return -EINVAL; | ||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | static int vidioc_s_audio(struct file *file, void *priv, | ||
397 | struct v4l2_audio *a) | ||
398 | { | ||
399 | if (a->index != 0) | ||
400 | return -EINVAL; | ||
401 | return 0; | ||
437 | } | 402 | } |
438 | 403 | ||
439 | static int usb_dsbr100_open(struct inode *inode, struct file *file) | 404 | static int usb_dsbr100_open(struct inode *inode, struct file *file) |
@@ -465,6 +430,68 @@ static int usb_dsbr100_close(struct inode *inode, struct file *file) | |||
465 | return 0; | 430 | return 0; |
466 | } | 431 | } |
467 | 432 | ||
433 | /* File system interface */ | ||
434 | static const struct file_operations usb_dsbr100_fops = { | ||
435 | .owner = THIS_MODULE, | ||
436 | .open = usb_dsbr100_open, | ||
437 | .release = usb_dsbr100_close, | ||
438 | .ioctl = video_ioctl2, | ||
439 | .compat_ioctl = v4l_compat_ioctl32, | ||
440 | .llseek = no_llseek, | ||
441 | }; | ||
442 | |||
443 | /* V4L2 interface */ | ||
444 | static struct video_device dsbr100_videodev_template = | ||
445 | { | ||
446 | .owner = THIS_MODULE, | ||
447 | .name = "D-Link DSB-R 100", | ||
448 | .type = VID_TYPE_TUNER, | ||
449 | .fops = &usb_dsbr100_fops, | ||
450 | .release = video_device_release, | ||
451 | .vidioc_querycap = vidioc_querycap, | ||
452 | .vidioc_g_tuner = vidioc_g_tuner, | ||
453 | .vidioc_s_tuner = vidioc_s_tuner, | ||
454 | .vidioc_g_frequency = vidioc_g_frequency, | ||
455 | .vidioc_s_frequency = vidioc_s_frequency, | ||
456 | .vidioc_queryctrl = vidioc_queryctrl, | ||
457 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
458 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
459 | .vidioc_g_audio = vidioc_g_audio, | ||
460 | .vidioc_s_audio = vidioc_s_audio, | ||
461 | .vidioc_g_input = vidioc_g_input, | ||
462 | .vidioc_s_input = vidioc_s_input, | ||
463 | }; | ||
464 | |||
465 | /* check if the device is present and register with v4l and | ||
466 | usb if it is */ | ||
467 | static int usb_dsbr100_probe(struct usb_interface *intf, | ||
468 | const struct usb_device_id *id) | ||
469 | { | ||
470 | struct dsbr100_device *radio; | ||
471 | |||
472 | if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL))) | ||
473 | return -ENOMEM; | ||
474 | if (!(radio->videodev = video_device_alloc())) { | ||
475 | kfree(radio); | ||
476 | return -ENOMEM; | ||
477 | } | ||
478 | memcpy(radio->videodev, &dsbr100_videodev_template, | ||
479 | sizeof(dsbr100_videodev_template)); | ||
480 | radio->removed = 0; | ||
481 | radio->users = 0; | ||
482 | radio->usbdev = interface_to_usbdev(intf); | ||
483 | radio->curfreq = FREQ_MIN*FREQ_MUL; | ||
484 | video_set_drvdata(radio->videodev, radio); | ||
485 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO,radio_nr)) { | ||
486 | warn("Could not register video device"); | ||
487 | video_device_release(radio->videodev); | ||
488 | kfree(radio); | ||
489 | return -EIO; | ||
490 | } | ||
491 | usb_set_intfdata(intf, radio); | ||
492 | return 0; | ||
493 | } | ||
494 | |||
468 | static int __init dsbr100_init(void) | 495 | static int __init dsbr100_init(void) |
469 | { | 496 | { |
470 | int retval = usb_register(&usb_dsbr100_driver); | 497 | int retval = usb_register(&usb_dsbr100_driver); |
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 8fbf0d8bd278..8cf2e9df5c8a 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c | |||
@@ -48,6 +48,25 @@ | |||
48 | 48 | ||
49 | #define CADET_VERSION KERNEL_VERSION(0,3,3) | 49 | #define CADET_VERSION KERNEL_VERSION(0,3,3) |
50 | 50 | ||
51 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
52 | { | ||
53 | .id = V4L2_CID_AUDIO_MUTE, | ||
54 | .name = "Mute", | ||
55 | .minimum = 0, | ||
56 | .maximum = 1, | ||
57 | .default_value = 1, | ||
58 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
59 | },{ | ||
60 | .id = V4L2_CID_AUDIO_VOLUME, | ||
61 | .name = "Volume", | ||
62 | .minimum = 0, | ||
63 | .maximum = 0xff, | ||
64 | .step = 1, | ||
65 | .default_value = 0xff, | ||
66 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
67 | } | ||
68 | }; | ||
69 | |||
51 | static int io=-1; /* default to isapnp activation */ | 70 | static int io=-1; /* default to isapnp activation */ |
52 | static int radio_nr = -1; | 71 | static int radio_nr = -1; |
53 | static int users=0; | 72 | static int users=0; |
@@ -347,135 +366,165 @@ cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | |||
347 | } | 366 | } |
348 | 367 | ||
349 | 368 | ||
369 | static int vidioc_querycap(struct file *file, void *priv, | ||
370 | struct v4l2_capability *v) | ||
371 | { | ||
372 | v->capabilities = | ||
373 | V4L2_CAP_TUNER | | ||
374 | V4L2_CAP_READWRITE; | ||
375 | v->version = CADET_VERSION; | ||
376 | strcpy(v->driver, "ADS Cadet"); | ||
377 | strcpy(v->card, "ADS Cadet"); | ||
378 | return 0; | ||
379 | } | ||
350 | 380 | ||
351 | static int cadet_do_ioctl(struct inode *inode, struct file *file, | 381 | static int vidioc_g_tuner(struct file *file, void *priv, |
352 | unsigned int cmd, void *arg) | 382 | struct v4l2_tuner *v) |
353 | { | 383 | { |
354 | switch(cmd) | 384 | v->type = V4L2_TUNER_RADIO; |
355 | { | 385 | switch (v->index) { |
356 | case VIDIOC_QUERYCAP: | 386 | case 0: |
357 | { | 387 | strcpy(v->name, "FM"); |
358 | struct v4l2_capability *cap = arg; | 388 | v->capability = V4L2_TUNER_CAP_STEREO; |
359 | memset(cap,0,sizeof(*cap)); | 389 | v->rangelow = 1400; /* 87.5 MHz */ |
360 | cap->capabilities = | 390 | v->rangehigh = 1728; /* 108.0 MHz */ |
361 | V4L2_CAP_TUNER | | 391 | v->rxsubchans=cadet_getstereo(); |
362 | V4L2_CAP_READWRITE; | 392 | switch (v->rxsubchans){ |
363 | cap->version = CADET_VERSION; | 393 | case V4L2_TUNER_SUB_MONO: |
364 | strcpy(cap->driver, "ADS Cadet"); | 394 | v->audmode = V4L2_TUNER_MODE_MONO; |
365 | strcpy(cap->card, "ADS Cadet"); | 395 | break; |
366 | return 0; | 396 | case V4L2_TUNER_SUB_STEREO: |
397 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
398 | break; | ||
399 | default: ; | ||
367 | } | 400 | } |
368 | case VIDIOC_G_TUNER: | 401 | break; |
369 | { | 402 | case 1: |
370 | struct v4l2_tuner *t = arg; | 403 | strcpy(v->name, "AM"); |
371 | memset(t,0,sizeof(*t)); | 404 | v->capability = V4L2_TUNER_CAP_LOW; |
372 | t->type = V4L2_TUNER_RADIO; | 405 | v->rangelow = 8320; /* 520 kHz */ |
373 | switch (t->index) | 406 | v->rangehigh = 26400; /* 1650 kHz */ |
374 | { | 407 | v->rxsubchans = V4L2_TUNER_SUB_MONO; |
375 | case 0: strcpy(t->name, "FM"); | 408 | v->audmode = V4L2_TUNER_MODE_MONO; |
376 | t->capability = V4L2_TUNER_CAP_STEREO; | 409 | break; |
377 | t->rangelow = 1400; /* 87.5 MHz */ | 410 | default: |
378 | t->rangehigh = 1728; /* 108.0 MHz */ | 411 | return -EINVAL; |
379 | t->rxsubchans=cadet_getstereo(); | 412 | } |
380 | switch (t->rxsubchans){ | 413 | v->signal = sigstrength; /* We might need to modify scaling of this */ |
381 | case V4L2_TUNER_SUB_MONO: | 414 | return 0; |
382 | t->audmode = V4L2_TUNER_MODE_MONO; | 415 | } |
383 | break; | ||
384 | case V4L2_TUNER_SUB_STEREO: | ||
385 | t->audmode = V4L2_TUNER_MODE_STEREO; | ||
386 | break; | ||
387 | default: ; | ||
388 | } | ||
389 | break; | ||
390 | case 1: strcpy(t->name, "AM"); | ||
391 | t->capability = V4L2_TUNER_CAP_LOW; | ||
392 | t->rangelow = 8320; /* 520 kHz */ | ||
393 | t->rangehigh = 26400; /* 1650 kHz */ | ||
394 | t->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
395 | t->audmode = V4L2_TUNER_MODE_MONO; | ||
396 | break; | ||
397 | default: | ||
398 | return -EINVAL; | ||
399 | } | ||
400 | 416 | ||
401 | t->signal = sigstrength; /* We might need to modify scaling of this */ | 417 | static int vidioc_s_tuner(struct file *file, void *priv, |
402 | return 0; | 418 | struct v4l2_tuner *v) |
403 | } | 419 | { |
404 | case VIDIOC_S_TUNER: | 420 | if((v->index != 0)&&(v->index != 1)) |
405 | { | 421 | return -EINVAL; |
406 | struct v4l2_tuner *t = arg; | 422 | curtuner = v->index; |
407 | if((t->index != 0)&&(t->index != 1)) | 423 | return 0; |
408 | return -EINVAL; | 424 | } |
409 | 425 | ||
410 | curtuner = t->index; | 426 | static int vidioc_g_frequency(struct file *file, void *priv, |
411 | return 0; | 427 | struct v4l2_frequency *f) |
412 | } | 428 | { |
413 | case VIDIOC_G_FREQUENCY: | 429 | f->tuner = curtuner; |
414 | { | 430 | f->type = V4L2_TUNER_RADIO; |
415 | struct v4l2_frequency *f = arg; | 431 | f->frequency = cadet_getfreq(); |
416 | memset(f,0,sizeof(*f)); | 432 | return 0; |
417 | f->tuner = curtuner; | 433 | } |
418 | f->type = V4L2_TUNER_RADIO; | 434 | |
419 | f->frequency = cadet_getfreq(); | 435 | |
420 | return 0; | 436 | static int vidioc_s_frequency(struct file *file, void *priv, |
421 | } | 437 | struct v4l2_frequency *f) |
422 | case VIDIOC_S_FREQUENCY: | 438 | { |
423 | { | 439 | if (f->type != V4L2_TUNER_RADIO) |
424 | struct v4l2_frequency *f = arg; | 440 | return -EINVAL; |
425 | if (f->type != V4L2_TUNER_RADIO){ | 441 | if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) |
426 | return -EINVAL; | 442 | return -EINVAL; |
427 | } | 443 | if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) |
428 | if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) { | 444 | return -EINVAL; |
429 | return -EINVAL; | 445 | cadet_setfreq(f->frequency); |
430 | } | 446 | return 0; |
431 | if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) { | 447 | } |
432 | return -EINVAL; | 448 | |
433 | } | 449 | static int vidioc_queryctrl(struct file *file, void *priv, |
434 | cadet_setfreq(f->frequency); | 450 | struct v4l2_queryctrl *qc) |
435 | return 0; | 451 | { |
436 | } | 452 | int i; |
437 | case VIDIOC_G_CTRL: | 453 | |
438 | { | 454 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
439 | struct v4l2_control *c = arg; | 455 | if (qc->id && qc->id == radio_qctrl[i].id) { |
440 | switch (c->id){ | 456 | memcpy(qc, &(radio_qctrl[i]), |
441 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | 457 | sizeof(*qc)); |
442 | c->value = (cadet_getvol() == 0); | ||
443 | break; | ||
444 | case V4L2_CID_AUDIO_VOLUME: | ||
445 | c->value = cadet_getvol(); | ||
446 | break; | ||
447 | default: | ||
448 | return -EINVAL; | ||
449 | } | ||
450 | return 0; | ||
451 | } | ||
452 | case VIDIOC_S_CTRL: | ||
453 | { | ||
454 | struct v4l2_control *c = arg; | ||
455 | switch (c->id){ | ||
456 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | ||
457 | if (c->value) cadet_setvol(0); | ||
458 | else cadet_setvol(0xffff); | ||
459 | break; | ||
460 | case V4L2_CID_AUDIO_VOLUME: | ||
461 | cadet_setvol(c->value); | ||
462 | break; | ||
463 | default: | ||
464 | return -EINVAL; | ||
465 | } | ||
466 | return 0; | 458 | return 0; |
467 | } | 459 | } |
460 | } | ||
461 | return -EINVAL; | ||
462 | } | ||
468 | 463 | ||
469 | default: | 464 | static int vidioc_g_ctrl(struct file *file, void *priv, |
470 | return -ENOIOCTLCMD; | 465 | struct v4l2_control *ctrl) |
466 | { | ||
467 | switch (ctrl->id){ | ||
468 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | ||
469 | ctrl->value = (cadet_getvol() == 0); | ||
470 | break; | ||
471 | case V4L2_CID_AUDIO_VOLUME: | ||
472 | ctrl->value = cadet_getvol(); | ||
473 | break; | ||
474 | default: | ||
475 | return -EINVAL; | ||
471 | } | 476 | } |
477 | return 0; | ||
472 | } | 478 | } |
473 | 479 | ||
474 | static int | 480 | static int vidioc_s_ctrl(struct file *file, void *priv, |
475 | cadet_ioctl(struct inode *inode, struct file *file, | 481 | struct v4l2_control *ctrl) |
476 | unsigned int cmd, unsigned long arg) | ||
477 | { | 482 | { |
478 | return video_usercopy(inode, file, cmd, arg, cadet_do_ioctl); | 483 | switch (ctrl->id){ |
484 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | ||
485 | if (ctrl->value) | ||
486 | cadet_setvol(0); | ||
487 | else | ||
488 | cadet_setvol(0xffff); | ||
489 | break; | ||
490 | case V4L2_CID_AUDIO_VOLUME: | ||
491 | cadet_setvol(ctrl->value); | ||
492 | break; | ||
493 | default: | ||
494 | return -EINVAL; | ||
495 | } | ||
496 | return 0; | ||
497 | } | ||
498 | |||
499 | static int vidioc_g_audio(struct file *file, void *priv, | ||
500 | struct v4l2_audio *a) | ||
501 | { | ||
502 | if (a->index > 1) | ||
503 | return -EINVAL; | ||
504 | strcpy(a->name, "Radio"); | ||
505 | a->capability = V4L2_AUDCAP_STEREO; | ||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) | ||
510 | { | ||
511 | *i = 0; | ||
512 | return 0; | ||
513 | } | ||
514 | |||
515 | static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | ||
516 | { | ||
517 | if (i != 0) | ||
518 | return -EINVAL; | ||
519 | return 0; | ||
520 | } | ||
521 | |||
522 | static int vidioc_s_audio(struct file *file, void *priv, | ||
523 | struct v4l2_audio *a) | ||
524 | { | ||
525 | if (a->index != 0) | ||
526 | return -EINVAL; | ||
527 | return 0; | ||
479 | } | 528 | } |
480 | 529 | ||
481 | static int | 530 | static int |
@@ -512,7 +561,7 @@ static const struct file_operations cadet_fops = { | |||
512 | .open = cadet_open, | 561 | .open = cadet_open, |
513 | .release = cadet_release, | 562 | .release = cadet_release, |
514 | .read = cadet_read, | 563 | .read = cadet_read, |
515 | .ioctl = cadet_ioctl, | 564 | .ioctl = video_ioctl2, |
516 | .poll = cadet_poll, | 565 | .poll = cadet_poll, |
517 | .compat_ioctl = v4l_compat_ioctl32, | 566 | .compat_ioctl = v4l_compat_ioctl32, |
518 | .llseek = no_llseek, | 567 | .llseek = no_llseek, |
@@ -524,6 +573,18 @@ static struct video_device cadet_radio= | |||
524 | .name = "Cadet radio", | 573 | .name = "Cadet radio", |
525 | .type = VID_TYPE_TUNER, | 574 | .type = VID_TYPE_TUNER, |
526 | .fops = &cadet_fops, | 575 | .fops = &cadet_fops, |
576 | .vidioc_querycap = vidioc_querycap, | ||
577 | .vidioc_g_tuner = vidioc_g_tuner, | ||
578 | .vidioc_s_tuner = vidioc_s_tuner, | ||
579 | .vidioc_g_frequency = vidioc_g_frequency, | ||
580 | .vidioc_s_frequency = vidioc_s_frequency, | ||
581 | .vidioc_queryctrl = vidioc_queryctrl, | ||
582 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
583 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
584 | .vidioc_g_audio = vidioc_g_audio, | ||
585 | .vidioc_s_audio = vidioc_s_audio, | ||
586 | .vidioc_g_input = vidioc_g_input, | ||
587 | .vidioc_s_input = vidioc_s_input, | ||
527 | }; | 588 | }; |
528 | 589 | ||
529 | static struct pnp_device_id cadet_pnp_devices[] = { | 590 | static struct pnp_device_id cadet_pnp_devices[] = { |
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c index 11f80cacd6ed..8e33a19a22a3 100644 --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <asm/io.h> | 25 | #include <asm/io.h> |
26 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
27 | #include <linux/mutex.h> | ||
28 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
29 | #include <linux/videodev2.h> | 28 | #include <linux/videodev2.h> |
30 | #include <media/v4l2-common.h> | 29 | #include <media/v4l2-common.h> |
@@ -110,7 +109,6 @@ struct radio_device { | |||
110 | muted, /* VIDEO_AUDIO_MUTE */ | 109 | muted, /* VIDEO_AUDIO_MUTE */ |
111 | stereo, /* VIDEO_TUNER_STEREO_ON */ | 110 | stereo, /* VIDEO_TUNER_STEREO_ON */ |
112 | tuned; /* signal strength (0 or 0xffff) */ | 111 | tuned; /* signal strength (0 or 0xffff) */ |
113 | struct mutex lock; | ||
114 | }; | 112 | }; |
115 | 113 | ||
116 | static u32 radio_bits_get(struct radio_device *dev) | 114 | static u32 radio_bits_get(struct radio_device *dev) |
@@ -394,7 +392,6 @@ static int __devinit maestro_probe(struct pci_dev *pdev, | |||
394 | } | 392 | } |
395 | 393 | ||
396 | radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA; | 394 | radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA; |
397 | mutex_init(&radio_unit->lock); | ||
398 | 395 | ||
399 | maestro_radio_inst = video_device_alloc(); | 396 | maestro_radio_inst = video_device_alloc(); |
400 | if (maestro_radio_inst == NULL) { | 397 | if (maestro_radio_inst == NULL) { |
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index a4715901512d..203f4373eeb8 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c | |||
@@ -410,7 +410,6 @@ static struct video_device zoltrix_radio = | |||
410 | .owner = THIS_MODULE, | 410 | .owner = THIS_MODULE, |
411 | .name = "Zoltrix Radio Plus", | 411 | .name = "Zoltrix Radio Plus", |
412 | .type = VID_TYPE_TUNER, | 412 | .type = VID_TYPE_TUNER, |
413 | .hardware = 0, | ||
414 | .fops = &zoltrix_fops, | 413 | .fops = &zoltrix_fops, |
415 | .vidioc_querycap = vidioc_querycap, | 414 | .vidioc_querycap = vidioc_querycap, |
416 | .vidioc_g_tuner = vidioc_g_tuner, | 415 | .vidioc_g_tuner = vidioc_g_tuner, |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index bc773781993a..5cb3f54b548b 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -2,14 +2,19 @@ | |||
2 | # Multimedia Video device configuration | 2 | # Multimedia Video device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Video Capture Adapters" | 5 | menuconfig VIDEO_CAPTURE_DRIVERS |
6 | bool "Video capture adapters" | ||
6 | depends on VIDEO_DEV | 7 | depends on VIDEO_DEV |
8 | default y | ||
9 | ---help--- | ||
10 | Say Y here to enable selecting the video adapters for | ||
11 | webcams, analog TV, and hybrid analog/digital TV. | ||
12 | Some of those devices also supports FM radio. | ||
7 | 13 | ||
8 | comment "Video Capture Adapters" | 14 | if VIDEO_CAPTURE_DRIVERS |
9 | 15 | ||
10 | config VIDEO_ADV_DEBUG | 16 | config VIDEO_ADV_DEBUG |
11 | bool "Enable advanced debug functionality" | 17 | bool "Enable advanced debug functionality" |
12 | depends on VIDEO_DEV | ||
13 | default n | 18 | default n |
14 | ---help--- | 19 | ---help--- |
15 | Say Y here to enable advanced debugging functionality on some | 20 | Say Y here to enable advanced debugging functionality on some |
@@ -34,7 +39,7 @@ config VIDEO_HELPER_CHIPS_AUTO | |||
34 | # | 39 | # |
35 | 40 | ||
36 | menu "Encoders/decoders and other helper chips" | 41 | menu "Encoders/decoders and other helper chips" |
37 | depends on VIDEO_DEV && !VIDEO_HELPER_CHIPS_AUTO | 42 | depends on !VIDEO_HELPER_CHIPS_AUTO |
38 | 43 | ||
39 | comment "Audio decoders" | 44 | comment "Audio decoders" |
40 | 45 | ||
@@ -61,7 +66,7 @@ config VIDEO_TDA7432 | |||
61 | 66 | ||
62 | config VIDEO_TDA9840 | 67 | config VIDEO_TDA9840 |
63 | tristate "Philips TDA9840 audio processor" | 68 | tristate "Philips TDA9840 audio processor" |
64 | depends on VIDEO_DEV && I2C | 69 | depends on I2C |
65 | ---help--- | 70 | ---help--- |
66 | Support for tda9840 audio decoder chip found on some Zoran boards. | 71 | Support for tda9840 audio decoder chip found on some Zoran boards. |
67 | 72 | ||
@@ -79,7 +84,7 @@ config VIDEO_TDA9875 | |||
79 | 84 | ||
80 | config VIDEO_TEA6415C | 85 | config VIDEO_TEA6415C |
81 | tristate "Philips TEA6415C audio processor" | 86 | tristate "Philips TEA6415C audio processor" |
82 | depends on VIDEO_DEV && I2C | 87 | depends on I2C |
83 | ---help--- | 88 | ---help--- |
84 | Support for tea6415c audio decoder chip found on some bt8xx boards. | 89 | Support for tea6415c audio decoder chip found on some bt8xx boards. |
85 | 90 | ||
@@ -88,7 +93,7 @@ config VIDEO_TEA6415C | |||
88 | 93 | ||
89 | config VIDEO_TEA6420 | 94 | config VIDEO_TEA6420 |
90 | tristate "Philips TEA6420 audio processor" | 95 | tristate "Philips TEA6420 audio processor" |
91 | depends on VIDEO_DEV && I2C | 96 | depends on I2C |
92 | ---help--- | 97 | ---help--- |
93 | Support for tea6420 audio decoder chip found on some bt8xx boards. | 98 | Support for tea6420 audio decoder chip found on some bt8xx boards. |
94 | 99 | ||
@@ -469,7 +474,7 @@ config VIDEO_SAA5246A | |||
469 | 474 | ||
470 | config VIDEO_SAA5249 | 475 | config VIDEO_SAA5249 |
471 | tristate "SAA5249 Teletext processor" | 476 | tristate "SAA5249 Teletext processor" |
472 | depends on VIDEO_DEV && I2C && VIDEO_V4L2 | 477 | depends on I2C && VIDEO_V4L2 |
473 | help | 478 | help |
474 | Support for I2C bus based teletext using the SAA5249 chip. At the | 479 | Support for I2C bus based teletext using the SAA5249 chip. At the |
475 | moment this is only useful on some European WinTV cards. | 480 | moment this is only useful on some European WinTV cards. |
@@ -479,7 +484,7 @@ config VIDEO_SAA5249 | |||
479 | 484 | ||
480 | config TUNER_3036 | 485 | config TUNER_3036 |
481 | tristate "SAB3036 tuner" | 486 | tristate "SAB3036 tuner" |
482 | depends on VIDEO_DEV && I2C && VIDEO_V4L1 | 487 | depends on I2C && VIDEO_V4L1 |
483 | help | 488 | help |
484 | Say Y here to include support for Philips SAB3036 compatible tuners. | 489 | Say Y here to include support for Philips SAB3036 compatible tuners. |
485 | If in doubt, say N. | 490 | If in doubt, say N. |
@@ -681,8 +686,12 @@ config VIDEO_CAFE_CCIC | |||
681 | # USB Multimedia device configuration | 686 | # USB Multimedia device configuration |
682 | # | 687 | # |
683 | 688 | ||
684 | menu "V4L USB devices" | 689 | menuconfig V4L_USB_DRIVERS |
685 | depends on USB && VIDEO_DEV | 690 | bool "V4L USB devices" |
691 | depends on USB | ||
692 | default y | ||
693 | |||
694 | if V4L_USB_DRIVERS | ||
686 | 695 | ||
687 | source "drivers/media/video/pvrusb2/Kconfig" | 696 | source "drivers/media/video/pvrusb2/Kconfig" |
688 | 697 | ||
@@ -707,7 +716,7 @@ config VIDEO_OVCAMCHIP | |||
707 | 716 | ||
708 | config USB_W9968CF | 717 | config USB_W9968CF |
709 | tristate "USB W996[87]CF JPEG Dual Mode Camera support" | 718 | tristate "USB W996[87]CF JPEG Dual Mode Camera support" |
710 | depends on USB && VIDEO_V4L1 && I2C | 719 | depends on VIDEO_V4L1 && I2C |
711 | select VIDEO_OVCAMCHIP | 720 | select VIDEO_OVCAMCHIP |
712 | ---help--- | 721 | ---help--- |
713 | Say Y here if you want support for cameras based on OV681 or | 722 | Say Y here if you want support for cameras based on OV681 or |
@@ -725,7 +734,7 @@ config USB_W9968CF | |||
725 | 734 | ||
726 | config USB_OV511 | 735 | config USB_OV511 |
727 | tristate "USB OV511 Camera support" | 736 | tristate "USB OV511 Camera support" |
728 | depends on USB && VIDEO_V4L1 | 737 | depends on VIDEO_V4L1 |
729 | ---help--- | 738 | ---help--- |
730 | Say Y here if you want to connect this type of camera to your | 739 | Say Y here if you want to connect this type of camera to your |
731 | computer's USB port. See <file:Documentation/video4linux/ov511.txt> | 740 | computer's USB port. See <file:Documentation/video4linux/ov511.txt> |
@@ -736,7 +745,7 @@ config USB_OV511 | |||
736 | 745 | ||
737 | config USB_SE401 | 746 | config USB_SE401 |
738 | tristate "USB SE401 Camera support" | 747 | tristate "USB SE401 Camera support" |
739 | depends on USB && VIDEO_V4L1 | 748 | depends on VIDEO_V4L1 |
740 | ---help--- | 749 | ---help--- |
741 | Say Y here if you want to connect this type of camera to your | 750 | Say Y here if you want to connect this type of camera to your |
742 | computer's USB port. See <file:Documentation/video4linux/se401.txt> | 751 | computer's USB port. See <file:Documentation/video4linux/se401.txt> |
@@ -749,7 +758,7 @@ source "drivers/media/video/sn9c102/Kconfig" | |||
749 | 758 | ||
750 | config USB_STV680 | 759 | config USB_STV680 |
751 | tristate "USB STV680 (Pencam) Camera support" | 760 | tristate "USB STV680 (Pencam) Camera support" |
752 | depends on USB && VIDEO_V4L1 | 761 | depends on VIDEO_V4L1 |
753 | ---help--- | 762 | ---help--- |
754 | Say Y here if you want to connect this type of camera to your | 763 | Say Y here if you want to connect this type of camera to your |
755 | computer's USB port. This includes the Pencam line of cameras. | 764 | computer's USB port. This includes the Pencam line of cameras. |
@@ -765,7 +774,7 @@ source "drivers/media/video/pwc/Kconfig" | |||
765 | 774 | ||
766 | config USB_ZR364XX | 775 | config USB_ZR364XX |
767 | tristate "USB ZR364XX Camera support" | 776 | tristate "USB ZR364XX Camera support" |
768 | depends on USB && VIDEO_V4L2 | 777 | depends on VIDEO_V4L2 |
769 | ---help--- | 778 | ---help--- |
770 | Say Y here if you want to connect this type of camera to your | 779 | Say Y here if you want to connect this type of camera to your |
771 | computer's USB port. | 780 | computer's USB port. |
@@ -775,6 +784,6 @@ config USB_ZR364XX | |||
775 | To compile this driver as a module, choose M here: the | 784 | To compile this driver as a module, choose M here: the |
776 | module will be called zr364xx. | 785 | module will be called zr364xx. |
777 | 786 | ||
778 | endmenu # V4L USB devices | 787 | endif # V4L_USB_DRIVERS |
779 | 788 | ||
780 | endmenu | 789 | endif # VIDEO_CAPTURE_DRIVERS |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 1757a588970f..67bda9f9a44b 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -555,7 +555,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) | |||
555 | { | 555 | { |
556 | struct v4l2_pix_format *pix; | 556 | struct v4l2_pix_format *pix; |
557 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; | 557 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; |
558 | int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC); | 558 | int is_50Hz = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60); |
559 | 559 | ||
560 | switch (fmt->type) { | 560 | switch (fmt->type) { |
561 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 561 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
@@ -567,7 +567,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) | |||
567 | Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; | 567 | Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; |
568 | Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; | 568 | Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; |
569 | 569 | ||
570 | Vlines = pix->height + (is_pal ? 4 : 7); | 570 | Vlines = pix->height + (is_50Hz ? 4 : 7); |
571 | 571 | ||
572 | if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || | 572 | if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || |
573 | (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { | 573 | (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { |
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index 2ebde2fdbcbe..543b05ebc0e7 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/dma-mapping.h> | 29 | #include <linux/dma-mapping.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/dma-mapping.h> | ||
31 | #include <asm/delay.h> | 32 | #include <asm/delay.h> |
32 | 33 | ||
33 | #include "cx88.h" | 34 | #include "cx88.h" |
@@ -612,7 +613,7 @@ struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board | |||
612 | } | 613 | } |
613 | 614 | ||
614 | /* Driver asked for hardware access. */ | 615 | /* Driver asked for hardware access. */ |
615 | int cx8802_request_acquire(struct cx8802_driver *drv) | 616 | static int cx8802_request_acquire(struct cx8802_driver *drv) |
616 | { | 617 | { |
617 | struct cx88_core *core = drv->core; | 618 | struct cx88_core *core = drv->core; |
618 | 619 | ||
@@ -632,7 +633,7 @@ int cx8802_request_acquire(struct cx8802_driver *drv) | |||
632 | } | 633 | } |
633 | 634 | ||
634 | /* Driver asked to release hardware. */ | 635 | /* Driver asked to release hardware. */ |
635 | int cx8802_request_release(struct cx8802_driver *drv) | 636 | static int cx8802_request_release(struct cx8802_driver *drv) |
636 | { | 637 | { |
637 | struct cx88_core *core = drv->core; | 638 | struct cx88_core *core = drv->core; |
638 | 639 | ||
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index b94ef8ab28c1..98fa35421bdd 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
37 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
38 | #include <linux/kthread.h> | 38 | #include <linux/kthread.h> |
39 | #include <linux/dma-mapping.h> | ||
39 | #include <asm/div64.h> | 40 | #include <asm/div64.h> |
40 | 41 | ||
41 | #include "cx88.h" | 42 | #include "cx88.h" |
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c index 6068c9bf82cd..82bc3a28aa22 100644 --- a/drivers/media/video/cx88/cx88-vp3054-i2c.c +++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c | |||
@@ -111,10 +111,6 @@ static struct i2c_adapter vp3054_i2c_adap_template = { | |||
111 | .id = I2C_HW_B_CX2388x, | 111 | .id = I2C_HW_B_CX2388x, |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static struct i2c_client vp3054_i2c_client_template = { | ||
115 | .name = "VP-3054", | ||
116 | }; | ||
117 | |||
118 | int vp3054_i2c_probe(struct cx8802_dev *dev) | 114 | int vp3054_i2c_probe(struct cx8802_dev *dev) |
119 | { | 115 | { |
120 | struct cx88_core *core = dev->core; | 116 | struct cx88_core *core = dev->core; |
@@ -133,8 +129,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
133 | sizeof(vp3054_i2c->adap)); | 129 | sizeof(vp3054_i2c->adap)); |
134 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, | 130 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, |
135 | sizeof(vp3054_i2c->algo)); | 131 | sizeof(vp3054_i2c->algo)); |
136 | memcpy(&vp3054_i2c->client, &vp3054_i2c_client_template, | ||
137 | sizeof(vp3054_i2c->client)); | ||
138 | 132 | ||
139 | vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL; | 133 | vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL; |
140 | 134 | ||
@@ -144,7 +138,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
144 | vp3054_i2c->algo.data = dev; | 138 | vp3054_i2c->algo.data = dev; |
145 | i2c_set_adapdata(&vp3054_i2c->adap, dev); | 139 | i2c_set_adapdata(&vp3054_i2c->adap, dev); |
146 | vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; | 140 | vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; |
147 | vp3054_i2c->client.adapter = &vp3054_i2c->adap; | ||
148 | 141 | ||
149 | vp3054_bit_setscl(dev,1); | 142 | vp3054_bit_setscl(dev,1); |
150 | vp3054_bit_setsda(dev,1); | 143 | vp3054_bit_setsda(dev,1); |
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.h b/drivers/media/video/cx88/cx88-vp3054-i2c.h index b7a0a04d2423..637a7d232238 100644 --- a/drivers/media/video/cx88/cx88-vp3054-i2c.h +++ b/drivers/media/video/cx88/cx88-vp3054-i2c.h | |||
@@ -26,7 +26,6 @@ | |||
26 | struct vp3054_i2c_state { | 26 | struct vp3054_i2c_state { |
27 | struct i2c_adapter adap; | 27 | struct i2c_adapter adap; |
28 | struct i2c_algo_bit_data algo; | 28 | struct i2c_algo_bit_data algo; |
29 | struct i2c_client client; | ||
30 | u32 state; | 29 | u32 state; |
31 | }; | 30 | }; |
32 | 31 | ||
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig index 9285a58e47aa..3823b62da4a4 100644 --- a/drivers/media/video/em28xx/Kconfig +++ b/drivers/media/video/em28xx/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config VIDEO_EM28XX | 1 | config VIDEO_EM28XX |
2 | tristate "Empia EM2800/2820/2840 USB video capture support" | 2 | tristate "Empia EM2800/2820/2840 USB video capture support" |
3 | depends on VIDEO_V4L1 && USB && I2C | 3 | depends on VIDEO_V4L1 && I2C |
4 | select VIDEO_BUF | 4 | select VIDEO_BUF |
5 | select VIDEO_TUNER | 5 | select VIDEO_TUNER |
6 | select VIDEO_TVEEPROM | 6 | select VIDEO_TVEEPROM |
diff --git a/drivers/media/video/et61x251/Kconfig b/drivers/media/video/et61x251/Kconfig index c6bff705688d..664676f44068 100644 --- a/drivers/media/video/et61x251/Kconfig +++ b/drivers/media/video/et61x251/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_ET61X251 | 1 | config USB_ET61X251 |
2 | tristate "USB ET61X[12]51 PC Camera Controller support" | 2 | tristate "USB ET61X[12]51 PC Camera Controller support" |
3 | depends on USB && VIDEO_V4L1 | 3 | depends on VIDEO_V4L1 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y here if you want support for cameras based on Etoms ET61X151 | 5 | Say Y here if you want support for cameras based on Etoms ET61X151 |
6 | or ET61X251 PC Camera Controllers. | 6 | or ET61X251 PC Camera Controllers. |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index 45b9328a538f..e29f949adf57 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -74,7 +74,7 @@ int ivtv_first_minor = 0; | |||
74 | struct ivtv *ivtv_cards[IVTV_MAX_CARDS]; | 74 | struct ivtv *ivtv_cards[IVTV_MAX_CARDS]; |
75 | 75 | ||
76 | /* Protects ivtv_cards_active */ | 76 | /* Protects ivtv_cards_active */ |
77 | spinlock_t ivtv_cards_lock = SPIN_LOCK_UNLOCKED; | 77 | DEFINE_SPINLOCK(ivtv_cards_lock); |
78 | 78 | ||
79 | /* add your revision and whatnot here */ | 79 | /* add your revision and whatnot here */ |
80 | static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { | 80 | static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 1637097ddec7..8976487a65f3 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -804,7 +804,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp) | |||
804 | struct ivtv_open_id *item; | 804 | struct ivtv_open_id *item; |
805 | struct ivtv *itv = NULL; | 805 | struct ivtv *itv = NULL; |
806 | struct ivtv_stream *s = NULL; | 806 | struct ivtv_stream *s = NULL; |
807 | int minor = MINOR(inode->i_rdev); | 807 | int minor = iminor(inode); |
808 | 808 | ||
809 | /* Find which card this open was on */ | 809 | /* Find which card this open was on */ |
810 | spin_lock(&ivtv_cards_lock); | 810 | spin_lock(&ivtv_cards_lock); |
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig index 5645c9318890..d0c2cd785430 100644 --- a/drivers/media/video/pvrusb2/Kconfig +++ b/drivers/media/video/pvrusb2/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config VIDEO_PVRUSB2 | 1 | config VIDEO_PVRUSB2 |
2 | tristate "Hauppauge WinTV-PVR USB2 support" | 2 | tristate "Hauppauge WinTV-PVR USB2 support" |
3 | depends on VIDEO_V4L2 && USB && I2C && EXPERIMENTAL | 3 | depends on VIDEO_V4L2 && I2C && EXPERIMENTAL |
4 | select FW_LOADER | 4 | select FW_LOADER |
5 | select VIDEO_TUNER | 5 | select VIDEO_TUNER |
6 | select VIDEO_TVEEPROM | 6 | select VIDEO_TVEEPROM |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c index 5669c8ca9ca3..20b614436d2c 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c +++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c | |||
@@ -391,22 +391,29 @@ static int pvr2_encoder_prep_config(struct pvr2_hdw *hdw) | |||
391 | int pvr2_encoder_configure(struct pvr2_hdw *hdw) | 391 | int pvr2_encoder_configure(struct pvr2_hdw *hdw) |
392 | { | 392 | { |
393 | int ret; | 393 | int ret; |
394 | int val; | ||
394 | pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure" | 395 | pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure" |
395 | " (cx2341x module)"); | 396 | " (cx2341x module)"); |
396 | hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING; | 397 | hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING; |
397 | hdw->enc_ctl_state.width = hdw->res_hor_val; | 398 | hdw->enc_ctl_state.width = hdw->res_hor_val; |
398 | hdw->enc_ctl_state.height = hdw->res_ver_val; | 399 | hdw->enc_ctl_state.height = hdw->res_ver_val; |
399 | hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & | 400 | hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & V4L2_STD_525_60) ? |
400 | (V4L2_STD_NTSC|V4L2_STD_PAL_M)) ? | ||
401 | 0 : 1); | 401 | 0 : 1); |
402 | 402 | ||
403 | ret = 0; | 403 | ret = 0; |
404 | 404 | ||
405 | ret |= pvr2_encoder_prep_config(hdw); | 405 | ret |= pvr2_encoder_prep_config(hdw); |
406 | 406 | ||
407 | /* saa7115: 0xf0 */ | ||
408 | val = 0xf0; | ||
409 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { | ||
410 | /* ivtv cx25840: 0x140 */ | ||
411 | val = 0x140; | ||
412 | } | ||
413 | |||
407 | if (!ret) ret = pvr2_encoder_vcmd( | 414 | if (!ret) ret = pvr2_encoder_vcmd( |
408 | hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, | 415 | hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, |
409 | 0xf0, 0xf0); | 416 | val, val); |
410 | 417 | ||
411 | /* setup firmware to notify us about some events (don't know why...) */ | 418 | /* setup firmware to notify us about some events (don't know why...) */ |
412 | if (!ret) ret = pvr2_encoder_vcmd( | 419 | if (!ret) ret = pvr2_encoder_vcmd( |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index acf651e01f94..1311891e7ee3 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -83,7 +83,7 @@ static struct pvr2_string_table pvr2_client_lists[] = { | |||
83 | }; | 83 | }; |
84 | 84 | ||
85 | static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; | 85 | static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; |
86 | static DECLARE_MUTEX(pvr2_unit_sem); | 86 | static DEFINE_MUTEX(pvr2_unit_mtx); |
87 | 87 | ||
88 | static int ctlchg = 0; | 88 | static int ctlchg = 0; |
89 | static int initusbreset = 1; | 89 | static int initusbreset = 1; |
@@ -2076,14 +2076,14 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2076 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); | 2076 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); |
2077 | if (!hdw->ctl_read_urb) goto fail; | 2077 | if (!hdw->ctl_read_urb) goto fail; |
2078 | 2078 | ||
2079 | down(&pvr2_unit_sem); do { | 2079 | mutex_lock(&pvr2_unit_mtx); do { |
2080 | for (idx = 0; idx < PVR_NUM; idx++) { | 2080 | for (idx = 0; idx < PVR_NUM; idx++) { |
2081 | if (unit_pointers[idx]) continue; | 2081 | if (unit_pointers[idx]) continue; |
2082 | hdw->unit_number = idx; | 2082 | hdw->unit_number = idx; |
2083 | unit_pointers[idx] = hdw; | 2083 | unit_pointers[idx] = hdw; |
2084 | break; | 2084 | break; |
2085 | } | 2085 | } |
2086 | } while (0); up(&pvr2_unit_sem); | 2086 | } while (0); mutex_unlock(&pvr2_unit_mtx); |
2087 | 2087 | ||
2088 | cnt1 = 0; | 2088 | cnt1 = 0; |
2089 | cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); | 2089 | cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); |
@@ -2186,13 +2186,13 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) | |||
2186 | } | 2186 | } |
2187 | pvr2_i2c_core_done(hdw); | 2187 | pvr2_i2c_core_done(hdw); |
2188 | pvr2_hdw_remove_usb_stuff(hdw); | 2188 | pvr2_hdw_remove_usb_stuff(hdw); |
2189 | down(&pvr2_unit_sem); do { | 2189 | mutex_lock(&pvr2_unit_mtx); do { |
2190 | if ((hdw->unit_number >= 0) && | 2190 | if ((hdw->unit_number >= 0) && |
2191 | (hdw->unit_number < PVR_NUM) && | 2191 | (hdw->unit_number < PVR_NUM) && |
2192 | (unit_pointers[hdw->unit_number] == hdw)) { | 2192 | (unit_pointers[hdw->unit_number] == hdw)) { |
2193 | unit_pointers[hdw->unit_number] = NULL; | 2193 | unit_pointers[hdw->unit_number] = NULL; |
2194 | } | 2194 | } |
2195 | } while (0); up(&pvr2_unit_sem); | 2195 | } while (0); mutex_unlock(&pvr2_unit_mtx); |
2196 | kfree(hdw->controls); | 2196 | kfree(hdw->controls); |
2197 | kfree(hdw->mpeg_ctrl_info); | 2197 | kfree(hdw->mpeg_ctrl_info); |
2198 | kfree(hdw->std_defs); | 2198 | kfree(hdw->std_defs); |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c index 58fc3c730fe1..6786d3c0c98b 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "pvrusb2-hdw-internal.h" | 23 | #include "pvrusb2-hdw-internal.h" |
24 | #include "pvrusb2-debug.h" | 24 | #include "pvrusb2-debug.h" |
25 | #include "pvrusb2-fx2-cmd.h" | 25 | #include "pvrusb2-fx2-cmd.h" |
26 | #include "pvrusb2.h" | ||
26 | 27 | ||
27 | #define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) | 28 | #define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) |
28 | 29 | ||
@@ -38,6 +39,10 @@ static unsigned int i2c_scan = 0; | |||
38 | module_param(i2c_scan, int, S_IRUGO|S_IWUSR); | 39 | module_param(i2c_scan, int, S_IRUGO|S_IWUSR); |
39 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); | 40 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); |
40 | 41 | ||
42 | static int ir_mode[PVR_NUM] = { [0 ... PVR_NUM-1] = 1 }; | ||
43 | module_param_array(ir_mode, int, NULL, 0444); | ||
44 | MODULE_PARM_DESC(ir_mode,"specify: 0=disable IR reception, 1=normal IR"); | ||
45 | |||
41 | static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, | 46 | static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, |
42 | unsigned int detail, | 47 | unsigned int detail, |
43 | char *buf,unsigned int maxlen); | 48 | char *buf,unsigned int maxlen); |
@@ -273,6 +278,15 @@ static int i2c_hack_wm8775(struct pvr2_hdw *hdw, | |||
273 | return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); | 278 | return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); |
274 | } | 279 | } |
275 | 280 | ||
281 | /* This is an entry point designed to always fail any attempt to perform a | ||
282 | transfer. We use this to cause certain I2C addresses to not be | ||
283 | probed. */ | ||
284 | static int i2c_black_hole(struct pvr2_hdw *hdw, | ||
285 | u8 i2c_addr,u8 *wdata,u16 wlen,u8 *rdata,u16 rlen) | ||
286 | { | ||
287 | return -EIO; | ||
288 | } | ||
289 | |||
276 | /* This is a special entry point that is entered if an I2C operation is | 290 | /* This is a special entry point that is entered if an I2C operation is |
277 | attempted to a cx25840 chip on model 24xxx hardware. This chip can | 291 | attempted to a cx25840 chip on model 24xxx hardware. This chip can |
278 | sometimes wedge itself. Worse still, when this happens msp3400 can | 292 | sometimes wedge itself. Worse still, when this happens msp3400 can |
@@ -994,10 +1008,17 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw) | |||
994 | } | 1008 | } |
995 | 1009 | ||
996 | /* However, deal with various special cases for 24xxx hardware. */ | 1010 | /* However, deal with various special cases for 24xxx hardware. */ |
1011 | if (ir_mode[hdw->unit_number] == 0) { | ||
1012 | printk(KERN_INFO "%s: IR disabled\n",hdw->name); | ||
1013 | hdw->i2c_func[0x18] = i2c_black_hole; | ||
1014 | } else if (ir_mode[hdw->unit_number] == 1) { | ||
1015 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { | ||
1016 | hdw->i2c_func[0x18] = i2c_24xxx_ir; | ||
1017 | } | ||
1018 | } | ||
997 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { | 1019 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { |
998 | hdw->i2c_func[0x1b] = i2c_hack_wm8775; | 1020 | hdw->i2c_func[0x1b] = i2c_hack_wm8775; |
999 | hdw->i2c_func[0x44] = i2c_hack_cx25840; | 1021 | hdw->i2c_func[0x44] = i2c_hack_cx25840; |
1000 | hdw->i2c_func[0x18] = i2c_24xxx_ir; | ||
1001 | } | 1022 | } |
1002 | 1023 | ||
1003 | // Configure the adapter and set up everything else related to it. | 1024 | // Configure the adapter and set up everything else related to it. |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c index a741c556a39a..7ab79baa1c8c 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c +++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c | |||
@@ -518,40 +518,32 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id) | |||
518 | } | 518 | } |
519 | sfp->item_last = cip; | 519 | sfp->item_last = cip; |
520 | 520 | ||
521 | cip->attr_name.attr.owner = THIS_MODULE; | ||
522 | cip->attr_name.attr.name = "name"; | 521 | cip->attr_name.attr.name = "name"; |
523 | cip->attr_name.attr.mode = S_IRUGO; | 522 | cip->attr_name.attr.mode = S_IRUGO; |
524 | cip->attr_name.show = fp->show_name; | 523 | cip->attr_name.show = fp->show_name; |
525 | 524 | ||
526 | cip->attr_type.attr.owner = THIS_MODULE; | ||
527 | cip->attr_type.attr.name = "type"; | 525 | cip->attr_type.attr.name = "type"; |
528 | cip->attr_type.attr.mode = S_IRUGO; | 526 | cip->attr_type.attr.mode = S_IRUGO; |
529 | cip->attr_type.show = fp->show_type; | 527 | cip->attr_type.show = fp->show_type; |
530 | 528 | ||
531 | cip->attr_min.attr.owner = THIS_MODULE; | ||
532 | cip->attr_min.attr.name = "min_val"; | 529 | cip->attr_min.attr.name = "min_val"; |
533 | cip->attr_min.attr.mode = S_IRUGO; | 530 | cip->attr_min.attr.mode = S_IRUGO; |
534 | cip->attr_min.show = fp->show_min; | 531 | cip->attr_min.show = fp->show_min; |
535 | 532 | ||
536 | cip->attr_max.attr.owner = THIS_MODULE; | ||
537 | cip->attr_max.attr.name = "max_val"; | 533 | cip->attr_max.attr.name = "max_val"; |
538 | cip->attr_max.attr.mode = S_IRUGO; | 534 | cip->attr_max.attr.mode = S_IRUGO; |
539 | cip->attr_max.show = fp->show_max; | 535 | cip->attr_max.show = fp->show_max; |
540 | 536 | ||
541 | cip->attr_val.attr.owner = THIS_MODULE; | ||
542 | cip->attr_val.attr.name = "cur_val"; | 537 | cip->attr_val.attr.name = "cur_val"; |
543 | cip->attr_val.attr.mode = S_IRUGO; | 538 | cip->attr_val.attr.mode = S_IRUGO; |
544 | 539 | ||
545 | cip->attr_custom.attr.owner = THIS_MODULE; | ||
546 | cip->attr_custom.attr.name = "custom_val"; | 540 | cip->attr_custom.attr.name = "custom_val"; |
547 | cip->attr_custom.attr.mode = S_IRUGO; | 541 | cip->attr_custom.attr.mode = S_IRUGO; |
548 | 542 | ||
549 | cip->attr_enum.attr.owner = THIS_MODULE; | ||
550 | cip->attr_enum.attr.name = "enum_val"; | 543 | cip->attr_enum.attr.name = "enum_val"; |
551 | cip->attr_enum.attr.mode = S_IRUGO; | 544 | cip->attr_enum.attr.mode = S_IRUGO; |
552 | cip->attr_enum.show = fp->show_enum; | 545 | cip->attr_enum.show = fp->show_enum; |
553 | 546 | ||
554 | cip->attr_bits.attr.owner = THIS_MODULE; | ||
555 | cip->attr_bits.attr.name = "bit_val"; | 547 | cip->attr_bits.attr.name = "bit_val"; |
556 | cip->attr_bits.attr.mode = S_IRUGO; | 548 | cip->attr_bits.attr.mode = S_IRUGO; |
557 | cip->attr_bits.show = fp->show_bits; | 549 | cip->attr_bits.show = fp->show_bits; |
@@ -616,12 +608,10 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp) | |||
616 | 608 | ||
617 | dip = kzalloc(sizeof(*dip),GFP_KERNEL); | 609 | dip = kzalloc(sizeof(*dip),GFP_KERNEL); |
618 | if (!dip) return; | 610 | if (!dip) return; |
619 | dip->attr_debugcmd.attr.owner = THIS_MODULE; | ||
620 | dip->attr_debugcmd.attr.name = "debugcmd"; | 611 | dip->attr_debugcmd.attr.name = "debugcmd"; |
621 | dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP; | 612 | dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP; |
622 | dip->attr_debugcmd.show = debugcmd_show; | 613 | dip->attr_debugcmd.show = debugcmd_show; |
623 | dip->attr_debugcmd.store = debugcmd_store; | 614 | dip->attr_debugcmd.store = debugcmd_store; |
624 | dip->attr_debuginfo.attr.owner = THIS_MODULE; | ||
625 | dip->attr_debuginfo.attr.name = "debuginfo"; | 615 | dip->attr_debuginfo.attr.name = "debuginfo"; |
626 | dip->attr_debuginfo.attr.mode = S_IRUGO; | 616 | dip->attr_debuginfo.attr.mode = S_IRUGO; |
627 | dip->attr_debuginfo.show = debuginfo_show; | 617 | dip->attr_debuginfo.show = debuginfo_show; |
@@ -811,7 +801,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
811 | return; | 801 | return; |
812 | } | 802 | } |
813 | 803 | ||
814 | sfp->attr_v4l_minor_number.attr.owner = THIS_MODULE; | ||
815 | sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; | 804 | sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; |
816 | sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; | 805 | sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; |
817 | sfp->attr_v4l_minor_number.show = v4l_minor_number_show; | 806 | sfp->attr_v4l_minor_number.show = v4l_minor_number_show; |
@@ -825,7 +814,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
825 | sfp->v4l_minor_number_created_ok = !0; | 814 | sfp->v4l_minor_number_created_ok = !0; |
826 | } | 815 | } |
827 | 816 | ||
828 | sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE; | ||
829 | sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number"; | 817 | sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number"; |
830 | sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO; | 818 | sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO; |
831 | sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show; | 819 | sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show; |
@@ -839,7 +827,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
839 | sfp->v4l_radio_minor_number_created_ok = !0; | 827 | sfp->v4l_radio_minor_number_created_ok = !0; |
840 | } | 828 | } |
841 | 829 | ||
842 | sfp->attr_unit_number.attr.owner = THIS_MODULE; | ||
843 | sfp->attr_unit_number.attr.name = "unit_number"; | 830 | sfp->attr_unit_number.attr.name = "unit_number"; |
844 | sfp->attr_unit_number.attr.mode = S_IRUGO; | 831 | sfp->attr_unit_number.attr.mode = S_IRUGO; |
845 | sfp->attr_unit_number.show = unit_number_show; | 832 | sfp->attr_unit_number.show = unit_number_show; |
@@ -852,7 +839,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
852 | sfp->unit_number_created_ok = !0; | 839 | sfp->unit_number_created_ok = !0; |
853 | } | 840 | } |
854 | 841 | ||
855 | sfp->attr_bus_info.attr.owner = THIS_MODULE; | ||
856 | sfp->attr_bus_info.attr.name = "bus_info_str"; | 842 | sfp->attr_bus_info.attr.name = "bus_info_str"; |
857 | sfp->attr_bus_info.attr.mode = S_IRUGO; | 843 | sfp->attr_bus_info.attr.mode = S_IRUGO; |
858 | sfp->attr_bus_info.show = bus_info_show; | 844 | sfp->attr_bus_info.show = bus_info_show; |
diff --git a/drivers/media/video/pwc/Kconfig b/drivers/media/video/pwc/Kconfig index 8fdf7101d3bf..7298cf2e1650 100644 --- a/drivers/media/video/pwc/Kconfig +++ b/drivers/media/video/pwc/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_PWC | 1 | config USB_PWC |
2 | tristate "USB Philips Cameras" | 2 | tristate "USB Philips Cameras" |
3 | depends on USB && VIDEO_V4L1 | 3 | depends on VIDEO_V4L1 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y or M here if you want to use one of these Philips & OEM | 5 | Say Y or M here if you want to use one of these Philips & OEM |
6 | webcams: | 6 | webcams: |
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 4ea479baee74..50f15adfa7c8 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -1170,6 +1170,42 @@ struct saa7134_board saa7134_boards[] = { | |||
1170 | .amux = LINE2, | 1170 | .amux = LINE2, |
1171 | }, | 1171 | }, |
1172 | }, | 1172 | }, |
1173 | [SAA7134_BOARD_ECS_TVP3XP_4CB6] = { | ||
1174 | /* Barry Scott <barry.scott@onelan.co.uk> */ | ||
1175 | .name = "Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM)", | ||
1176 | .audio_clock = 0x187de7, | ||
1177 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
1178 | .radio_type = UNSET, | ||
1179 | .tuner_addr = ADDR_UNSET, | ||
1180 | .radio_addr = ADDR_UNSET, | ||
1181 | .inputs = {{ | ||
1182 | .name = name_tv, | ||
1183 | .vmux = 1, | ||
1184 | .amux = TV, | ||
1185 | .tv = 1, | ||
1186 | },{ | ||
1187 | .name = name_tv_mono, | ||
1188 | .vmux = 1, | ||
1189 | .amux = LINE2, | ||
1190 | .tv = 1, | ||
1191 | },{ | ||
1192 | .name = name_comp1, | ||
1193 | .vmux = 3, | ||
1194 | .amux = LINE1, | ||
1195 | },{ | ||
1196 | .name = name_svideo, | ||
1197 | .vmux = 8, | ||
1198 | .amux = LINE1, | ||
1199 | },{ | ||
1200 | .name = "CVid over SVid", | ||
1201 | .vmux = 0, | ||
1202 | .amux = LINE1, | ||
1203 | }}, | ||
1204 | .radio = { | ||
1205 | .name = name_radio, | ||
1206 | .amux = LINE2, | ||
1207 | }, | ||
1208 | }, | ||
1173 | [SAA7134_BOARD_AVACSSMARTTV] = { | 1209 | [SAA7134_BOARD_AVACSSMARTTV] = { |
1174 | /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */ | 1210 | /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */ |
1175 | .name = "AVACS SmartTV", | 1211 | .name = "AVACS SmartTV", |
@@ -2754,6 +2790,35 @@ struct saa7134_board saa7134_boards[] = { | |||
2754 | .amux = LINE1, | 2790 | .amux = LINE1, |
2755 | }, | 2791 | }, |
2756 | }, | 2792 | }, |
2793 | [SAA7134_BOARD_KWORLD_DVBT_210] = { | ||
2794 | .name = "KWorld DVB-T 210", | ||
2795 | .audio_clock = 0x00187de7, | ||
2796 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
2797 | .radio_type = UNSET, | ||
2798 | .tuner_addr = ADDR_UNSET, | ||
2799 | .radio_addr = ADDR_UNSET, | ||
2800 | .mpeg = SAA7134_MPEG_DVB, | ||
2801 | .gpiomask = 1 << 21, | ||
2802 | .inputs = {{ | ||
2803 | .name = name_tv, | ||
2804 | .vmux = 1, | ||
2805 | .amux = TV, | ||
2806 | .tv = 1, | ||
2807 | },{ | ||
2808 | .name = name_comp1, | ||
2809 | .vmux = 3, | ||
2810 | .amux = LINE1, | ||
2811 | },{ | ||
2812 | .name = name_svideo, | ||
2813 | .vmux = 8, | ||
2814 | .amux = LINE1, | ||
2815 | }}, | ||
2816 | .radio = { | ||
2817 | .name = name_radio, | ||
2818 | .amux = TV, | ||
2819 | .gpio = 0x0200000, | ||
2820 | }, | ||
2821 | }, | ||
2757 | [SAA7134_BOARD_KWORLD_ATSC110] = { | 2822 | [SAA7134_BOARD_KWORLD_ATSC110] = { |
2758 | .name = "Kworld ATSC110", | 2823 | .name = "Kworld ATSC110", |
2759 | .audio_clock = 0x00187de7, | 2824 | .audio_clock = 0x00187de7, |
@@ -3407,6 +3472,36 @@ struct saa7134_board saa7134_boards[] = { | |||
3407 | .gpio = 0x0200000, | 3472 | .gpio = 0x0200000, |
3408 | }, | 3473 | }, |
3409 | }, | 3474 | }, |
3475 | [SAA7134_BOARD_SABRENT_TV_PCB05] = { | ||
3476 | .name = "Sabrent PCMCIA TV-PCB05", | ||
3477 | .audio_clock = 0x00187de7, | ||
3478 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
3479 | .radio_type = UNSET, | ||
3480 | .tuner_addr = ADDR_UNSET, | ||
3481 | .radio_addr = ADDR_UNSET, | ||
3482 | .inputs = {{ | ||
3483 | .name = name_tv, | ||
3484 | .vmux = 1, | ||
3485 | .amux = TV, | ||
3486 | .tv = 1, | ||
3487 | },{ | ||
3488 | .name = name_comp1, | ||
3489 | .vmux = 3, | ||
3490 | .amux = LINE1, | ||
3491 | },{ | ||
3492 | .name = name_comp2, | ||
3493 | .vmux = 0, | ||
3494 | .amux = LINE1, | ||
3495 | },{ | ||
3496 | .name = name_svideo, | ||
3497 | .vmux = 8, | ||
3498 | .amux = LINE1, | ||
3499 | }}, | ||
3500 | .mute = { | ||
3501 | .name = name_mute, | ||
3502 | .amux = TV, | ||
3503 | }, | ||
3504 | }, | ||
3410 | }; | 3505 | }; |
3411 | 3506 | ||
3412 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); | 3507 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); |
@@ -3515,7 +3610,13 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
3515 | .vendor = PCI_VENDOR_ID_PHILIPS, | 3610 | .vendor = PCI_VENDOR_ID_PHILIPS, |
3516 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | 3611 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, |
3517 | .subvendor = 0x5168, /* Animation Technologies (LifeView) */ | 3612 | .subvendor = 0x5168, /* Animation Technologies (LifeView) */ |
3518 | .subdevice = 0x0214, /* Standard PCI, LR214WF */ | 3613 | .subdevice = 0x0214, /* Standard PCI, LR214 Rev E and earlier (SAA7135) */ |
3614 | .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, | ||
3615 | },{ | ||
3616 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
3617 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
3618 | .subvendor = 0x5168, /* Animation Technologies (LifeView) */ | ||
3619 | .subdevice = 0x5214, /* Standard PCI, LR214 Rev F onwards (SAA7131) */ | ||
3519 | .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, | 3620 | .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, |
3520 | },{ | 3621 | },{ |
3521 | .vendor = PCI_VENDOR_ID_PHILIPS, | 3622 | .vendor = PCI_VENDOR_ID_PHILIPS, |
@@ -3689,6 +3790,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
3689 | .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5, | 3790 | .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5, |
3690 | },{ | 3791 | },{ |
3691 | .vendor = PCI_VENDOR_ID_PHILIPS, | 3792 | .vendor = PCI_VENDOR_ID_PHILIPS, |
3793 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | ||
3794 | .subvendor = 0x1019, | ||
3795 | .subdevice = 0x4cb6, | ||
3796 | .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB6, | ||
3797 | },{ | ||
3798 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
3692 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | 3799 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, |
3693 | .subvendor = 0x12ab, | 3800 | .subvendor = 0x12ab, |
3694 | .subdevice = 0x0800, | 3801 | .subdevice = 0x0800, |
@@ -3915,6 +4022,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
3915 | .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF, | 4022 | .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF, |
3916 | },{ | 4023 | },{ |
3917 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4024 | .vendor = PCI_VENDOR_ID_PHILIPS, |
4025 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
4026 | .subvendor = 0x17de, | ||
4027 | .subdevice = 0x7250, | ||
4028 | .driver_data = SAA7134_BOARD_KWORLD_DVBT_210, | ||
4029 | },{ | ||
4030 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
3918 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */ | 4031 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */ |
3919 | .subvendor = 0x17de, | 4032 | .subvendor = 0x17de, |
3920 | .subdevice = 0x7350, | 4033 | .subdevice = 0x7350, |
@@ -4100,6 +4213,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
4100 | .subdevice = 0x4857, | 4213 | .subdevice = 0x4857, |
4101 | .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL, | 4214 | .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL, |
4102 | },{ | 4215 | },{ |
4216 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
4217 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | ||
4218 | .subvendor = 0x0919, /* SinoVideo PCI 2309 Proteus (7134) */ | ||
4219 | .subdevice = 0x2003, /* OEM cardbus */ | ||
4220 | .driver_data = SAA7134_BOARD_SABRENT_TV_PCB05, | ||
4221 | },{ | ||
4103 | /* --- boards without eeprom + subsystem ID --- */ | 4222 | /* --- boards without eeprom + subsystem ID --- */ |
4104 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4223 | .vendor = PCI_VENDOR_ID_PHILIPS, |
4105 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | 4224 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, |
@@ -4178,6 +4297,7 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
4178 | case SAA7134_BOARD_CINERGY600_MK3: | 4297 | case SAA7134_BOARD_CINERGY600_MK3: |
4179 | case SAA7134_BOARD_ECS_TVP3XP: | 4298 | case SAA7134_BOARD_ECS_TVP3XP: |
4180 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: | 4299 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: |
4300 | case SAA7134_BOARD_ECS_TVP3XP_4CB6: | ||
4181 | case SAA7134_BOARD_MD2819: | 4301 | case SAA7134_BOARD_MD2819: |
4182 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: | 4302 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: |
4183 | case SAA7134_BOARD_KWORLD_XPERT: | 4303 | case SAA7134_BOARD_KWORLD_XPERT: |
@@ -4426,6 +4546,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4426 | } | 4546 | } |
4427 | break; | 4547 | break; |
4428 | case SAA7134_BOARD_PINNACLE_PCTV_310i: | 4548 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
4549 | case SAA7134_BOARD_KWORLD_DVBT_210: | ||
4429 | case SAA7134_BOARD_TEVION_DVBT_220RF: | 4550 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
4430 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: | 4551 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
4431 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: | 4552 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 65aec881bbde..e0eec80088c7 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -887,6 +887,20 @@ static struct tda1004x_config asus_p7131_hybrid_lna_config = { | |||
887 | .antenna_switch= 2, | 887 | .antenna_switch= 2, |
888 | .request_firmware = philips_tda1004x_request_firmware | 888 | .request_firmware = philips_tda1004x_request_firmware |
889 | }; | 889 | }; |
890 | static struct tda1004x_config kworld_dvb_t_210_config = { | ||
891 | .demod_address = 0x08, | ||
892 | .invert = 1, | ||
893 | .invert_oclk = 0, | ||
894 | .xtal_freq = TDA10046_XTAL_16M, | ||
895 | .agc_config = TDA10046_AGC_TDA827X, | ||
896 | .gpio_config = TDA10046_GP11_I, | ||
897 | .if_freq = TDA10046_FREQ_045, | ||
898 | .i2c_gate = 0x4b, | ||
899 | .tuner_address = 0x61, | ||
900 | .tuner_config = 2, | ||
901 | .antenna_switch= 1, | ||
902 | .request_firmware = philips_tda1004x_request_firmware | ||
903 | }; | ||
890 | /* ------------------------------------------------------------------ | 904 | /* ------------------------------------------------------------------ |
891 | * special case: this card uses saa713x GPIO22 for the mode switch | 905 | * special case: this card uses saa713x GPIO22 for the mode switch |
892 | */ | 906 | */ |
@@ -1039,6 +1053,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1039 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; | 1053 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; |
1040 | } | 1054 | } |
1041 | break; | 1055 | break; |
1056 | case SAA7134_BOARD_KWORLD_DVBT_210: | ||
1057 | configure_tda827x_fe(dev, &kworld_dvb_t_210_config); | ||
1058 | break; | ||
1042 | case SAA7134_BOARD_PHILIPS_TIGER: | 1059 | case SAA7134_BOARD_PHILIPS_TIGER: |
1043 | configure_tda827x_fe(dev, &philips_tiger_config); | 1060 | configure_tda827x_fe(dev, &philips_tiger_config); |
1044 | break; | 1061 | break; |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 62224cc958f1..15623b27ad2e 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -235,6 +235,9 @@ struct saa7134_format { | |||
235 | #define SAA7134_BOARD_AVERMEDIA_M102 110 | 235 | #define SAA7134_BOARD_AVERMEDIA_M102 110 |
236 | #define SAA7134_BOARD_ASUS_P7131_4871 111 | 236 | #define SAA7134_BOARD_ASUS_P7131_4871 111 |
237 | #define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112 | 237 | #define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112 |
238 | #define SAA7134_BOARD_ECS_TVP3XP_4CB6 113 | ||
239 | #define SAA7134_BOARD_KWORLD_DVBT_210 114 | ||
240 | #define SAA7134_BOARD_SABRENT_TV_PCB05 115 | ||
238 | 241 | ||
239 | #define SAA7134_MAXBOARDS 8 | 242 | #define SAA7134_MAXBOARDS 8 |
240 | #define SAA7134_INPUT_MAX 8 | 243 | #define SAA7134_INPUT_MAX 8 |
diff --git a/drivers/media/video/sn9c102/Kconfig b/drivers/media/video/sn9c102/Kconfig index 19204f5686e1..f71f272776de 100644 --- a/drivers/media/video/sn9c102/Kconfig +++ b/drivers/media/video/sn9c102/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_SN9C102 | 1 | config USB_SN9C102 |
2 | tristate "USB SN9C1xx PC Camera Controller support" | 2 | tristate "USB SN9C1xx PC Camera Controller support" |
3 | depends on USB && VIDEO_V4L2 | 3 | depends on VIDEO_V4L2 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y here if you want support for cameras based on SONiX SN9C101, | 5 | Say Y here if you want support for cameras based on SONiX SN9C101, |
6 | SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers. | 6 | SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers. |
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h index 680e74634527..11fcb49f5b99 100644 --- a/drivers/media/video/sn9c102/sn9c102.h +++ b/drivers/media/video/sn9c102/sn9c102.h | |||
@@ -141,7 +141,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id) | |||
141 | 141 | ||
142 | void | 142 | void |
143 | sn9c102_attach_sensor(struct sn9c102_device* cam, | 143 | sn9c102_attach_sensor(struct sn9c102_device* cam, |
144 | struct sn9c102_sensor* sensor) | 144 | const struct sn9c102_sensor* sensor) |
145 | { | 145 | { |
146 | memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); | 146 | memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); |
147 | } | 147 | } |
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index 89f83354de3b..74a204f8ebc8 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c | |||
@@ -48,8 +48,8 @@ | |||
48 | #define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia" | 48 | #define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia" |
49 | #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" | 49 | #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" |
50 | #define SN9C102_MODULE_LICENSE "GPL" | 50 | #define SN9C102_MODULE_LICENSE "GPL" |
51 | #define SN9C102_MODULE_VERSION "1:1.39" | 51 | #define SN9C102_MODULE_VERSION "1:1.44" |
52 | #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 39) | 52 | #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 44) |
53 | 53 | ||
54 | /*****************************************************************************/ | 54 | /*****************************************************************************/ |
55 | 55 | ||
@@ -209,38 +209,41 @@ static void sn9c102_queue_unusedframes(struct sn9c102_device* cam) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | /*****************************************************************************/ | 211 | /*****************************************************************************/ |
212 | |||
212 | /* | 213 | /* |
213 | * Write a sequence of count value/register pairs. Returns -1 after the | 214 | Write a sequence of count value/register pairs. Returns -1 after the first |
214 | * first failed write, or 0 for no errors. | 215 | failed write, or 0 for no errors. |
215 | */ | 216 | */ |
216 | int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2], | 217 | int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2], |
217 | int count) | 218 | int count) |
218 | { | 219 | { |
219 | struct usb_device* udev = cam->usbdev; | 220 | struct usb_device* udev = cam->usbdev; |
220 | u8* value = cam->control_buffer; /* Needed for DMA'able memory */ | 221 | u8* buff = cam->control_buffer; |
221 | int i, res; | 222 | int i, res; |
222 | 223 | ||
223 | for (i = 0; i < count; i++) { | 224 | for (i = 0; i < count; i++) { |
224 | u8 index = valreg[i][1]; | 225 | u8 index = valreg[i][1]; |
225 | 226 | ||
226 | /* | 227 | /* |
227 | * index is a u8, so it must be <256 and can't be out of range. | 228 | index is a u8, so it must be <256 and can't be out of range. |
228 | * If we put in a check anyway, gcc annoys us with a warning | 229 | If we put in a check anyway, gcc annoys us with a warning |
229 | * that our check is useless. People get all uppity when they | 230 | hat our check is useless. People get all uppity when they |
230 | * see warnings in the kernel compile. | 231 | see warnings in the kernel compile. |
231 | */ | 232 | */ |
232 | 233 | ||
233 | *value = valreg[i][0]; | 234 | *buff = valreg[i][0]; |
234 | res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 235 | |
235 | 0x08, 0x41, index, 0, | 236 | res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, |
236 | value, 1, SN9C102_CTRL_TIMEOUT); | 237 | 0x41, index, 0, buff, 1, |
238 | SN9C102_CTRL_TIMEOUT); | ||
239 | |||
237 | if (res < 0) { | 240 | if (res < 0) { |
238 | DBG(3, "Failed to write a register (value 0x%02X, " | 241 | DBG(3, "Failed to write a register (value 0x%02X, " |
239 | "index 0x%02X, error %d)", *value, index, res); | 242 | "index 0x%02X, error %d)", *buff, index, res); |
240 | return -1; | 243 | return -1; |
241 | } | 244 | } |
242 | 245 | ||
243 | cam->reg[index] = *value; | 246 | cam->reg[index] = *buff; |
244 | } | 247 | } |
245 | 248 | ||
246 | return 0; | 249 | return 0; |
@@ -272,8 +275,8 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index) | |||
272 | } | 275 | } |
273 | 276 | ||
274 | 277 | ||
275 | /* NOTE: reading some registers always returns 0 */ | 278 | /* NOTE: with the SN9C10[123] reading some registers always returns 0 */ |
276 | static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) | 279 | int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) |
277 | { | 280 | { |
278 | struct usb_device* udev = cam->usbdev; | 281 | struct usb_device* udev = cam->usbdev; |
279 | u8* buff = cam->control_buffer; | 282 | u8* buff = cam->control_buffer; |
@@ -299,7 +302,8 @@ int sn9c102_pread_reg(struct sn9c102_device* cam, u16 index) | |||
299 | 302 | ||
300 | 303 | ||
301 | static int | 304 | static int |
302 | sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor) | 305 | sn9c102_i2c_wait(struct sn9c102_device* cam, |
306 | const struct sn9c102_sensor* sensor) | ||
303 | { | 307 | { |
304 | int i, r; | 308 | int i, r; |
305 | 309 | ||
@@ -320,7 +324,7 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor) | |||
320 | 324 | ||
321 | static int | 325 | static int |
322 | sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, | 326 | sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, |
323 | struct sn9c102_sensor* sensor) | 327 | const struct sn9c102_sensor* sensor) |
324 | { | 328 | { |
325 | int r , err = 0; | 329 | int r , err = 0; |
326 | 330 | ||
@@ -342,7 +346,7 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, | |||
342 | 346 | ||
343 | static int | 347 | static int |
344 | sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, | 348 | sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, |
345 | struct sn9c102_sensor* sensor) | 349 | const struct sn9c102_sensor* sensor) |
346 | { | 350 | { |
347 | int r; | 351 | int r; |
348 | r = sn9c102_read_reg(cam, 0x08); | 352 | r = sn9c102_read_reg(cam, 0x08); |
@@ -352,12 +356,12 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, | |||
352 | 356 | ||
353 | int | 357 | int |
354 | sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | 358 | sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, |
355 | struct sn9c102_sensor* sensor, u8 data0, u8 data1, | 359 | const struct sn9c102_sensor* sensor, u8 data0, |
356 | u8 n, u8 buffer[]) | 360 | u8 data1, u8 n, u8 buffer[]) |
357 | { | 361 | { |
358 | struct usb_device* udev = cam->usbdev; | 362 | struct usb_device* udev = cam->usbdev; |
359 | u8* data = cam->control_buffer; | 363 | u8* data = cam->control_buffer; |
360 | int err = 0, res; | 364 | int i = 0, err = 0, res; |
361 | 365 | ||
362 | /* Write cycle */ | 366 | /* Write cycle */ |
363 | data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | | 367 | data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | |
@@ -402,7 +406,8 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | |||
402 | } | 406 | } |
403 | 407 | ||
404 | if (buffer) | 408 | if (buffer) |
405 | memcpy(buffer, data, sizeof(buffer)); | 409 | for (i = 0; i < n && i < 5; i++) |
410 | buffer[n-i-1] = data[4-i]; | ||
406 | 411 | ||
407 | return (int)data[4]; | 412 | return (int)data[4]; |
408 | } | 413 | } |
@@ -410,7 +415,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | |||
410 | 415 | ||
411 | int | 416 | int |
412 | sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, | 417 | sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, |
413 | struct sn9c102_sensor* sensor, u8 n, u8 data0, | 418 | const struct sn9c102_sensor* sensor, u8 n, u8 data0, |
414 | u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) | 419 | u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) |
415 | { | 420 | { |
416 | struct usb_device* udev = cam->usbdev; | 421 | struct usb_device* udev = cam->usbdev; |
@@ -449,7 +454,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, | |||
449 | 454 | ||
450 | int | 455 | int |
451 | sn9c102_i2c_try_read(struct sn9c102_device* cam, | 456 | sn9c102_i2c_try_read(struct sn9c102_device* cam, |
452 | struct sn9c102_sensor* sensor, u8 address) | 457 | const struct sn9c102_sensor* sensor, u8 address) |
453 | { | 458 | { |
454 | return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, | 459 | return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, |
455 | address, 1, NULL); | 460 | address, 1, NULL); |
@@ -458,7 +463,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam, | |||
458 | 463 | ||
459 | int | 464 | int |
460 | sn9c102_i2c_try_write(struct sn9c102_device* cam, | 465 | sn9c102_i2c_try_write(struct sn9c102_device* cam, |
461 | struct sn9c102_sensor* sensor, u8 address, u8 value) | 466 | const struct sn9c102_sensor* sensor, u8 address, u8 value) |
462 | { | 467 | { |
463 | return sn9c102_i2c_try_raw_write(cam, sensor, 3, | 468 | return sn9c102_i2c_try_raw_write(cam, sensor, 3, |
464 | sensor->i2c_slave_id, address, | 469 | sensor->i2c_slave_id, address, |
@@ -657,16 +662,6 @@ sn9c102_write_jpegheader(struct sn9c102_device* cam, struct sn9c102_frame_t* f) | |||
657 | } | 662 | } |
658 | 663 | ||
659 | 664 | ||
660 | static void | ||
661 | sn9c102_write_eoimarker(struct sn9c102_device* cam, struct sn9c102_frame_t* f) | ||
662 | { | ||
663 | static const u8 eoi_marker[2] = {0xff, 0xd9}; | ||
664 | |||
665 | memcpy(f->bufmem + f->buf.bytesused, eoi_marker, sizeof(eoi_marker)); | ||
666 | f->buf.bytesused += sizeof(eoi_marker); | ||
667 | } | ||
668 | |||
669 | |||
670 | static void sn9c102_urb_complete(struct urb *urb) | 665 | static void sn9c102_urb_complete(struct urb *urb) |
671 | { | 666 | { |
672 | struct sn9c102_device* cam = urb->context; | 667 | struct sn9c102_device* cam = urb->context; |
@@ -3181,14 +3176,14 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, | |||
3181 | 3176 | ||
3182 | static const struct file_operations sn9c102_fops = { | 3177 | static const struct file_operations sn9c102_fops = { |
3183 | .owner = THIS_MODULE, | 3178 | .owner = THIS_MODULE, |
3184 | .open = sn9c102_open, | 3179 | .open = sn9c102_open, |
3185 | .release = sn9c102_release, | 3180 | .release = sn9c102_release, |
3186 | .ioctl = sn9c102_ioctl, | 3181 | .ioctl = sn9c102_ioctl, |
3187 | .compat_ioctl = v4l_compat_ioctl32, | 3182 | .compat_ioctl = v4l_compat_ioctl32, |
3188 | .read = sn9c102_read, | 3183 | .read = sn9c102_read, |
3189 | .poll = sn9c102_poll, | 3184 | .poll = sn9c102_poll, |
3190 | .mmap = sn9c102_mmap, | 3185 | .mmap = sn9c102_mmap, |
3191 | .llseek = no_llseek, | 3186 | .llseek = no_llseek, |
3192 | }; | 3187 | }; |
3193 | 3188 | ||
3194 | /*****************************************************************************/ | 3189 | /*****************************************************************************/ |
@@ -3251,7 +3246,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3251 | break; | 3246 | break; |
3252 | } | 3247 | } |
3253 | 3248 | ||
3254 | for (i = 0; sn9c102_sensor_table[i]; i++) { | 3249 | for (i = 0; i < ARRAY_SIZE(sn9c102_sensor_table); i++) { |
3255 | err = sn9c102_sensor_table[i](cam); | 3250 | err = sn9c102_sensor_table[i](cam); |
3256 | if (!err) | 3251 | if (!err) |
3257 | break; | 3252 | break; |
@@ -3262,7 +3257,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3262 | DBG(3, "Support for %s maintained by %s", | 3257 | DBG(3, "Support for %s maintained by %s", |
3263 | cam->sensor.name, cam->sensor.maintainer); | 3258 | cam->sensor.name, cam->sensor.maintainer); |
3264 | } else { | 3259 | } else { |
3265 | DBG(1, "No supported image sensor detected"); | 3260 | DBG(1, "No supported image sensor detected for this bridge"); |
3266 | err = -ENODEV; | 3261 | err = -ENODEV; |
3267 | goto fail; | 3262 | goto fail; |
3268 | } | 3263 | } |
diff --git a/drivers/media/video/sn9c102/sn9c102_devtable.h b/drivers/media/video/sn9c102/sn9c102_devtable.h index f49bd8c5b86e..916054faf9be 100644 --- a/drivers/media/video/sn9c102/sn9c102_devtable.h +++ b/drivers/media/video/sn9c102/sn9c102_devtable.h | |||
@@ -86,6 +86,8 @@ static const struct usb_device_id sn9c102_id_table[] = { | |||
86 | { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, | 86 | { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, |
87 | { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, | 87 | { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, |
88 | /* SN9C105 */ | 88 | /* SN9C105 */ |
89 | { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), }, | ||
90 | { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), }, | ||
89 | { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, | 91 | { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, |
90 | { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, | 92 | { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, |
91 | { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, | 93 | { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, |
@@ -100,6 +102,7 @@ static const struct usb_device_id sn9c102_id_table[] = { | |||
100 | { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, | 102 | { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, |
101 | { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, | 103 | { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, |
102 | /* SN9C120 */ | 104 | /* SN9C120 */ |
105 | { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), }, | ||
103 | { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, | 106 | { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, |
104 | { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, | 107 | { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, |
105 | { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, | 108 | { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, |
@@ -148,7 +151,6 @@ static int (*sn9c102_sensor_table[])(struct sn9c102_device*) = { | |||
148 | &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ | 151 | &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ |
149 | &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */ | 152 | &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */ |
150 | &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ | 153 | &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ |
151 | NULL, | ||
152 | }; | 154 | }; |
153 | 155 | ||
154 | #endif /* _SN9C102_DEVTABLE_H_ */ | 156 | #endif /* _SN9C102_DEVTABLE_H_ */ |
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131d.c b/drivers/media/video/sn9c102/sn9c102_hv7131d.c index 28a861aed044..eaf9ad0dc8a6 100644 --- a/drivers/media/video/sn9c102/sn9c102_hv7131d.c +++ b/drivers/media/video/sn9c102/sn9c102_hv7131d.c | |||
@@ -144,7 +144,7 @@ static int hv7131d_set_pix_format(struct sn9c102_device* cam, | |||
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | static struct sn9c102_sensor hv7131d = { | 147 | static const struct sn9c102_sensor hv7131d = { |
148 | .name = "HV7131D", | 148 | .name = "HV7131D", |
149 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 149 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
150 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 150 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
@@ -248,12 +248,10 @@ int sn9c102_probe_hv7131d(struct sn9c102_device* cam) | |||
248 | 248 | ||
249 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | 249 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, |
250 | {0x28, 0x17}); | 250 | {0x28, 0x17}); |
251 | if (err) | ||
252 | return -EIO; | ||
253 | 251 | ||
254 | r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00); | 252 | r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00); |
255 | r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01); | 253 | r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01); |
256 | if (r0 < 0 || r1 < 0) | 254 | if (err || r0 < 0 || r1 < 0) |
257 | return -EIO; | 255 | return -EIO; |
258 | 256 | ||
259 | if (r0 != 0x00 || r1 != 0x04) | 257 | if (r0 != 0x00 || r1 != 0x04) |
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131r.c b/drivers/media/video/sn9c102/sn9c102_hv7131r.c index 5a495baa5f95..0fc401223cfc 100644 --- a/drivers/media/video/sn9c102/sn9c102_hv7131r.c +++ b/drivers/media/video/sn9c102/sn9c102_hv7131r.c | |||
@@ -44,7 +44,6 @@ static int hv7131r_init(struct sn9c102_device* cam) | |||
44 | {0xb0, 0x2b}, {0xc0, 0x2c}, | 44 | {0xb0, 0x2b}, {0xc0, 0x2c}, |
45 | {0xd0, 0x2d}, {0xe0, 0x2e}, | 45 | {0xd0, 0x2d}, {0xe0, 0x2e}, |
46 | {0xf0, 0x2f}, {0xff, 0x30}); | 46 | {0xf0, 0x2f}, {0xff, 0x30}); |
47 | |||
48 | break; | 47 | break; |
49 | case BRIDGE_SN9C105: | 48 | case BRIDGE_SN9C105: |
50 | case BRIDGE_SN9C120: | 49 | case BRIDGE_SN9C120: |
@@ -254,7 +253,7 @@ static int hv7131r_set_pix_format(struct sn9c102_device* cam, | |||
254 | } | 253 | } |
255 | 254 | ||
256 | 255 | ||
257 | static struct sn9c102_sensor hv7131r = { | 256 | static const struct sn9c102_sensor hv7131r = { |
258 | .name = "HV7131R", | 257 | .name = "HV7131R", |
259 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 258 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
260 | .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, | 259 | .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, |
@@ -350,11 +349,8 @@ int sn9c102_probe_hv7131r(struct sn9c102_device* cam) | |||
350 | {0x34, 0x01}, {0x20, 0x17}, | 349 | {0x34, 0x01}, {0x20, 0x17}, |
351 | {0x34, 0x01}, {0x46, 0x01}); | 350 | {0x34, 0x01}, {0x46, 0x01}); |
352 | 351 | ||
353 | if (err) | ||
354 | return -EIO; | ||
355 | |||
356 | devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00); | 352 | devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00); |
357 | if (devid < 0) | 353 | if (err || devid < 0) |
358 | return -EIO; | 354 | return -EIO; |
359 | 355 | ||
360 | if (devid != 0x02) | 356 | if (devid != 0x02) |
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c index 9200845d011b..00b134ca0a3d 100644 --- a/drivers/media/video/sn9c102/sn9c102_mi0343.c +++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c | |||
@@ -55,45 +55,45 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam, | |||
55 | struct v4l2_control* ctrl) | 55 | struct v4l2_control* ctrl) |
56 | { | 56 | { |
57 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 57 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
58 | u8 data[5+1]; | 58 | u8 data[2]; |
59 | 59 | ||
60 | switch (ctrl->id) { | 60 | switch (ctrl->id) { |
61 | case V4L2_CID_EXPOSURE: | 61 | case V4L2_CID_EXPOSURE: |
62 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, | 62 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2, |
63 | 2+1, data) < 0) | 63 | data) < 0) |
64 | return -EIO; | 64 | return -EIO; |
65 | ctrl->value = data[2]; | 65 | ctrl->value = data[0]; |
66 | return 0; | 66 | return 0; |
67 | case V4L2_CID_GAIN: | 67 | case V4L2_CID_GAIN: |
68 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, | 68 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2, |
69 | 2+1, data) < 0) | 69 | data) < 0) |
70 | return -EIO; | 70 | return -EIO; |
71 | break; | 71 | break; |
72 | case V4L2_CID_HFLIP: | 72 | case V4L2_CID_HFLIP: |
73 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 73 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
74 | 2+1, data) < 0) | 74 | data) < 0) |
75 | return -EIO; | 75 | return -EIO; |
76 | ctrl->value = data[3] & 0x20 ? 1 : 0; | 76 | ctrl->value = data[1] & 0x20 ? 1 : 0; |
77 | return 0; | 77 | return 0; |
78 | case V4L2_CID_VFLIP: | 78 | case V4L2_CID_VFLIP: |
79 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 79 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
80 | 2+1, data) < 0) | 80 | data) < 0) |
81 | return -EIO; | 81 | return -EIO; |
82 | ctrl->value = data[3] & 0x80 ? 1 : 0; | 82 | ctrl->value = data[1] & 0x80 ? 1 : 0; |
83 | return 0; | 83 | return 0; |
84 | case V4L2_CID_RED_BALANCE: | 84 | case V4L2_CID_RED_BALANCE: |
85 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, | 85 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2, |
86 | 2+1, data) < 0) | 86 | data) < 0) |
87 | return -EIO; | 87 | return -EIO; |
88 | break; | 88 | break; |
89 | case V4L2_CID_BLUE_BALANCE: | 89 | case V4L2_CID_BLUE_BALANCE: |
90 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, | 90 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2, |
91 | 2+1, data) < 0) | 91 | data) < 0) |
92 | return -EIO; | 92 | return -EIO; |
93 | break; | 93 | break; |
94 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 94 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
95 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, | 95 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2, |
96 | 2+1, data) < 0) | 96 | data) < 0) |
97 | return -EIO; | 97 | return -EIO; |
98 | break; | 98 | break; |
99 | default: | 99 | default: |
@@ -105,7 +105,7 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam, | |||
105 | case V4L2_CID_RED_BALANCE: | 105 | case V4L2_CID_RED_BALANCE: |
106 | case V4L2_CID_BLUE_BALANCE: | 106 | case V4L2_CID_BLUE_BALANCE: |
107 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 107 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
108 | ctrl->value = data[3] | (data[2] << 8); | 108 | ctrl->value = data[1] | (data[0] << 8); |
109 | if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) | 109 | if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) |
110 | ctrl->value -= 0x10; | 110 | ctrl->value -= 0x10; |
111 | else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) | 111 | else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) |
@@ -223,7 +223,7 @@ static int mi0343_set_pix_format(struct sn9c102_device* cam, | |||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | static struct sn9c102_sensor mi0343 = { | 226 | static const struct sn9c102_sensor mi0343 = { |
227 | .name = "MI-0343", | 227 | .name = "MI-0343", |
228 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 228 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
229 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 229 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
@@ -332,20 +332,17 @@ static struct sn9c102_sensor mi0343 = { | |||
332 | 332 | ||
333 | int sn9c102_probe_mi0343(struct sn9c102_device* cam) | 333 | int sn9c102_probe_mi0343(struct sn9c102_device* cam) |
334 | { | 334 | { |
335 | u8 data[5+1]; | 335 | u8 data[2]; |
336 | int err = 0; | ||
337 | |||
338 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | ||
339 | {0x28, 0x17}); | ||
340 | 336 | ||
341 | if (err) | 337 | if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, |
338 | {0x28, 0x17})) | ||
342 | return -EIO; | 339 | return -EIO; |
343 | 340 | ||
344 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, | 341 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, |
345 | 2, data) < 0) | 342 | 2, data) < 0) |
346 | return -EIO; | 343 | return -EIO; |
347 | 344 | ||
348 | if (data[4] != 0x32 || data[3] != 0xe3) | 345 | if (data[1] != 0x42 || data[0] != 0xe3) |
349 | return -ENODEV; | 346 | return -ENODEV; |
350 | 347 | ||
351 | sn9c102_attach_sensor(cam, &mi0343); | 348 | sn9c102_attach_sensor(cam, &mi0343); |
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0360.c b/drivers/media/video/sn9c102/sn9c102_mi0360.c index 64698acb0b15..f8d81d82e8d5 100644 --- a/drivers/media/video/sn9c102/sn9c102_mi0360.c +++ b/drivers/media/video/sn9c102/sn9c102_mi0360.c | |||
@@ -27,20 +27,105 @@ static int mi0360_init(struct sn9c102_device* cam) | |||
27 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 27 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
28 | int err = 0; | 28 | int err = 0; |
29 | 29 | ||
30 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, | 30 | switch (sn9c102_get_bridge(cam)) { |
31 | {0x0a, 0x14}, {0x40, 0x01}, | 31 | case BRIDGE_SN9C103: |
32 | {0x20, 0x17}, {0x07, 0x18}, | 32 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, |
33 | {0xa0, 0x19}, {0x02, 0x1c}, | 33 | {0x0a, 0x14}, {0x40, 0x01}, |
34 | {0x03, 0x1d}, {0x0f, 0x1e}, | 34 | {0x20, 0x17}, {0x07, 0x18}, |
35 | {0x0c, 0x1f}, {0x00, 0x20}, | 35 | {0xa0, 0x19}, {0x02, 0x1c}, |
36 | {0x10, 0x21}, {0x20, 0x22}, | 36 | {0x03, 0x1d}, {0x0f, 0x1e}, |
37 | {0x30, 0x23}, {0x40, 0x24}, | 37 | {0x0c, 0x1f}, {0x00, 0x20}, |
38 | {0x50, 0x25}, {0x60, 0x26}, | 38 | {0x10, 0x21}, {0x20, 0x22}, |
39 | {0x70, 0x27}, {0x80, 0x28}, | 39 | {0x30, 0x23}, {0x40, 0x24}, |
40 | {0x90, 0x29}, {0xa0, 0x2a}, | 40 | {0x50, 0x25}, {0x60, 0x26}, |
41 | {0xb0, 0x2b}, {0xc0, 0x2c}, | 41 | {0x70, 0x27}, {0x80, 0x28}, |
42 | {0xd0, 0x2d}, {0xe0, 0x2e}, | 42 | {0x90, 0x29}, {0xa0, 0x2a}, |
43 | {0xf0, 0x2f}, {0xff, 0x30}); | 43 | {0xb0, 0x2b}, {0xc0, 0x2c}, |
44 | {0xd0, 0x2d}, {0xe0, 0x2e}, | ||
45 | {0xf0, 0x2f}, {0xff, 0x30}); | ||
46 | break; | ||
47 | case BRIDGE_SN9C105: | ||
48 | case BRIDGE_SN9C120: | ||
49 | err = sn9c102_write_const_regs(cam, {0x44, 0x01}, {0x40, 0x02}, | ||
50 | {0x00, 0x03}, {0x1a, 0x04}, | ||
51 | {0x50, 0x05}, {0x20, 0x06}, | ||
52 | {0x10, 0x07}, {0x03, 0x10}, | ||
53 | {0x08, 0x14}, {0xa2, 0x17}, | ||
54 | {0x47, 0x18}, {0x00, 0x19}, | ||
55 | {0x1d, 0x1a}, {0x10, 0x1b}, | ||
56 | {0x02, 0x1c}, {0x03, 0x1d}, | ||
57 | {0x0f, 0x1e}, {0x0c, 0x1f}, | ||
58 | {0x00, 0x20}, {0x29, 0x21}, | ||
59 | {0x40, 0x22}, {0x54, 0x23}, | ||
60 | {0x66, 0x24}, {0x76, 0x25}, | ||
61 | {0x85, 0x26}, {0x94, 0x27}, | ||
62 | {0xa1, 0x28}, {0xae, 0x29}, | ||
63 | {0xbb, 0x2a}, {0xc7, 0x2b}, | ||
64 | {0xd3, 0x2c}, {0xde, 0x2d}, | ||
65 | {0xea, 0x2e}, {0xf4, 0x2f}, | ||
66 | {0xff, 0x30}, {0x00, 0x3F}, | ||
67 | {0xC7, 0x40}, {0x01, 0x41}, | ||
68 | {0x44, 0x42}, {0x00, 0x43}, | ||
69 | {0x44, 0x44}, {0x00, 0x45}, | ||
70 | {0x44, 0x46}, {0x00, 0x47}, | ||
71 | {0xC7, 0x48}, {0x01, 0x49}, | ||
72 | {0xC7, 0x4A}, {0x01, 0x4B}, | ||
73 | {0xC7, 0x4C}, {0x01, 0x4D}, | ||
74 | {0x44, 0x4E}, {0x00, 0x4F}, | ||
75 | {0x44, 0x50}, {0x00, 0x51}, | ||
76 | {0x44, 0x52}, {0x00, 0x53}, | ||
77 | {0xC7, 0x54}, {0x01, 0x55}, | ||
78 | {0xC7, 0x56}, {0x01, 0x57}, | ||
79 | {0xC7, 0x58}, {0x01, 0x59}, | ||
80 | {0x44, 0x5A}, {0x00, 0x5B}, | ||
81 | {0x44, 0x5C}, {0x00, 0x5D}, | ||
82 | {0x44, 0x5E}, {0x00, 0x5F}, | ||
83 | {0xC7, 0x60}, {0x01, 0x61}, | ||
84 | {0xC7, 0x62}, {0x01, 0x63}, | ||
85 | {0xC7, 0x64}, {0x01, 0x65}, | ||
86 | {0x44, 0x66}, {0x00, 0x67}, | ||
87 | {0x44, 0x68}, {0x00, 0x69}, | ||
88 | {0x44, 0x6A}, {0x00, 0x6B}, | ||
89 | {0xC7, 0x6C}, {0x01, 0x6D}, | ||
90 | {0xC7, 0x6E}, {0x01, 0x6F}, | ||
91 | {0xC7, 0x70}, {0x01, 0x71}, | ||
92 | {0x44, 0x72}, {0x00, 0x73}, | ||
93 | {0x44, 0x74}, {0x00, 0x75}, | ||
94 | {0x44, 0x76}, {0x00, 0x77}, | ||
95 | {0xC7, 0x78}, {0x01, 0x79}, | ||
96 | {0xC7, 0x7A}, {0x01, 0x7B}, | ||
97 | {0xC7, 0x7C}, {0x01, 0x7D}, | ||
98 | {0x44, 0x7E}, {0x00, 0x7F}, | ||
99 | {0x14, 0x84}, {0x00, 0x85}, | ||
100 | {0x27, 0x86}, {0x00, 0x87}, | ||
101 | {0x07, 0x88}, {0x00, 0x89}, | ||
102 | {0xEC, 0x8A}, {0x0f, 0x8B}, | ||
103 | {0xD8, 0x8C}, {0x0f, 0x8D}, | ||
104 | {0x3D, 0x8E}, {0x00, 0x8F}, | ||
105 | {0x3D, 0x90}, {0x00, 0x91}, | ||
106 | {0xCD, 0x92}, {0x0f, 0x93}, | ||
107 | {0xf7, 0x94}, {0x0f, 0x95}, | ||
108 | {0x0C, 0x96}, {0x00, 0x97}, | ||
109 | {0x00, 0x98}, {0x66, 0x99}, | ||
110 | {0x05, 0x9A}, {0x00, 0x9B}, | ||
111 | {0x04, 0x9C}, {0x00, 0x9D}, | ||
112 | {0x08, 0x9E}, {0x00, 0x9F}, | ||
113 | {0x2D, 0xC0}, {0x2D, 0xC1}, | ||
114 | {0x3A, 0xC2}, {0x05, 0xC3}, | ||
115 | {0x04, 0xC4}, {0x3F, 0xC5}, | ||
116 | {0x00, 0xC6}, {0x00, 0xC7}, | ||
117 | {0x50, 0xC8}, {0x3C, 0xC9}, | ||
118 | {0x28, 0xCA}, {0xD8, 0xCB}, | ||
119 | {0x14, 0xCC}, {0xEC, 0xCD}, | ||
120 | {0x32, 0xCE}, {0xDD, 0xCF}, | ||
121 | {0x32, 0xD0}, {0xDD, 0xD1}, | ||
122 | {0x6A, 0xD2}, {0x50, 0xD3}, | ||
123 | {0x00, 0xD4}, {0x00, 0xD5}, | ||
124 | {0x00, 0xD6}); | ||
125 | break; | ||
126 | default: | ||
127 | break; | ||
128 | } | ||
44 | 129 | ||
45 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, | 130 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, |
46 | 0x00, 0x01, 0, 0); | 131 | 0x00, 0x01, 0, 0); |
@@ -65,50 +150,50 @@ static int mi0360_get_ctrl(struct sn9c102_device* cam, | |||
65 | struct v4l2_control* ctrl) | 150 | struct v4l2_control* ctrl) |
66 | { | 151 | { |
67 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 152 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
68 | u8 data[5+1]; | 153 | u8 data[2]; |
69 | 154 | ||
70 | switch (ctrl->id) { | 155 | switch (ctrl->id) { |
71 | case V4L2_CID_EXPOSURE: | 156 | case V4L2_CID_EXPOSURE: |
72 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, | 157 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2, |
73 | 2+1, data) < 0) | 158 | data) < 0) |
74 | return -EIO; | 159 | return -EIO; |
75 | ctrl->value = data[2]; | 160 | ctrl->value = data[0]; |
76 | return 0; | 161 | return 0; |
77 | case V4L2_CID_GAIN: | 162 | case V4L2_CID_GAIN: |
78 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, | 163 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2, |
79 | 2+1, data) < 0) | 164 | data) < 0) |
80 | return -EIO; | 165 | return -EIO; |
81 | ctrl->value = data[3]; | 166 | ctrl->value = data[1]; |
82 | return 0; | 167 | return 0; |
83 | case V4L2_CID_RED_BALANCE: | 168 | case V4L2_CID_RED_BALANCE: |
84 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, | 169 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2, |
85 | 2+1, data) < 0) | 170 | data) < 0) |
86 | return -EIO; | 171 | return -EIO; |
87 | ctrl->value = data[3]; | 172 | ctrl->value = data[1]; |
88 | return 0; | 173 | return 0; |
89 | case V4L2_CID_BLUE_BALANCE: | 174 | case V4L2_CID_BLUE_BALANCE: |
90 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, | 175 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2, |
91 | 2+1, data) < 0) | 176 | data) < 0) |
92 | return -EIO; | 177 | return -EIO; |
93 | ctrl->value = data[3]; | 178 | ctrl->value = data[1]; |
94 | return 0; | 179 | return 0; |
95 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 180 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
96 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, | 181 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2, |
97 | 2+1, data) < 0) | 182 | data) < 0) |
98 | return -EIO; | 183 | return -EIO; |
99 | ctrl->value = data[3]; | 184 | ctrl->value = data[1]; |
100 | return 0; | 185 | return 0; |
101 | case V4L2_CID_HFLIP: | 186 | case V4L2_CID_HFLIP: |
102 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 187 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
103 | 2+1, data) < 0) | 188 | data) < 0) |
104 | return -EIO; | 189 | return -EIO; |
105 | ctrl->value = data[3] & 0x20 ? 1 : 0; | 190 | ctrl->value = data[1] & 0x20 ? 1 : 0; |
106 | return 0; | 191 | return 0; |
107 | case V4L2_CID_VFLIP: | 192 | case V4L2_CID_VFLIP: |
108 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 193 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
109 | 2+1, data) < 0) | 194 | data) < 0) |
110 | return -EIO; | 195 | return -EIO; |
111 | ctrl->value = data[3] & 0x80 ? 1 : 0; | 196 | ctrl->value = data[1] & 0x80 ? 1 : 0; |
112 | return 0; | 197 | return 0; |
113 | default: | 198 | default: |
114 | return -EINVAL; | 199 | return -EINVAL; |
@@ -178,8 +263,19 @@ static int mi0360_set_crop(struct sn9c102_device* cam, | |||
178 | { | 263 | { |
179 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 264 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
180 | int err = 0; | 265 | int err = 0; |
181 | u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0, | 266 | u8 h_start = 0, v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; |
182 | v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; | 267 | |
268 | switch (sn9c102_get_bridge(cam)) { | ||
269 | case BRIDGE_SN9C103: | ||
270 | h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0; | ||
271 | break; | ||
272 | case BRIDGE_SN9C105: | ||
273 | case BRIDGE_SN9C120: | ||
274 | h_start = (u8)(rect->left - s->cropcap.bounds.left) + 1; | ||
275 | break; | ||
276 | default: | ||
277 | break; | ||
278 | } | ||
183 | 279 | ||
184 | err += sn9c102_write_reg(cam, h_start, 0x12); | 280 | err += sn9c102_write_reg(cam, h_start, 0x12); |
185 | err += sn9c102_write_reg(cam, v_start, 0x13); | 281 | err += sn9c102_write_reg(cam, v_start, 0x13); |
@@ -194,24 +290,30 @@ static int mi0360_set_pix_format(struct sn9c102_device* cam, | |||
194 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 290 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
195 | int err = 0; | 291 | int err = 0; |
196 | 292 | ||
197 | if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { | 293 | if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8) { |
198 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, | ||
199 | 0x0a, 0x00, 0x02, 0, 0); | ||
200 | err += sn9c102_write_reg(cam, 0x20, 0x19); | ||
201 | } else { | ||
202 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, | 294 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
203 | 0x0a, 0x00, 0x05, 0, 0); | 295 | 0x0a, 0x00, 0x05, 0, 0); |
204 | err += sn9c102_write_reg(cam, 0x60, 0x19); | 296 | err += sn9c102_write_reg(cam, 0x60, 0x19); |
297 | if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 || | ||
298 | sn9c102_get_bridge(cam) == BRIDGE_SN9C120) | ||
299 | err += sn9c102_write_reg(cam, 0xa6, 0x17); | ||
300 | } else { | ||
301 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, | ||
302 | 0x0a, 0x00, 0x02, 0, 0); | ||
303 | err += sn9c102_write_reg(cam, 0x20, 0x19); | ||
304 | if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 || | ||
305 | sn9c102_get_bridge(cam) == BRIDGE_SN9C120) | ||
306 | err += sn9c102_write_reg(cam, 0xa2, 0x17); | ||
205 | } | 307 | } |
206 | 308 | ||
207 | return err; | 309 | return err; |
208 | } | 310 | } |
209 | 311 | ||
210 | 312 | ||
211 | static struct sn9c102_sensor mi0360 = { | 313 | static const struct sn9c102_sensor mi0360 = { |
212 | .name = "MI-0360", | 314 | .name = "MI-0360", |
213 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 315 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
214 | .supported_bridge = BRIDGE_SN9C103, | 316 | .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, |
215 | .frequency = SN9C102_I2C_100KHZ, | 317 | .frequency = SN9C102_I2C_100KHZ, |
216 | .interface = SN9C102_I2C_2WIRES, | 318 | .interface = SN9C102_I2C_2WIRES, |
217 | .i2c_slave_id = 0x5d, | 319 | .i2c_slave_id = 0x5d, |
@@ -317,19 +419,31 @@ static struct sn9c102_sensor mi0360 = { | |||
317 | 419 | ||
318 | int sn9c102_probe_mi0360(struct sn9c102_device* cam) | 420 | int sn9c102_probe_mi0360(struct sn9c102_device* cam) |
319 | { | 421 | { |
320 | u8 data[5+1]; | ||
321 | int err; | ||
322 | 422 | ||
323 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | 423 | u8 data[2]; |
324 | {0x28, 0x17}); | 424 | |
325 | if (err) | 425 | switch (sn9c102_get_bridge(cam)) { |
326 | return -EIO; | 426 | case BRIDGE_SN9C103: |
427 | if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | ||
428 | {0x28, 0x17})) | ||
429 | return -EIO; | ||
430 | break; | ||
431 | case BRIDGE_SN9C105: | ||
432 | case BRIDGE_SN9C120: | ||
433 | if (sn9c102_write_const_regs(cam, {0x01, 0xf1}, {0x00, 0xf1}, | ||
434 | {0x01, 0x01}, {0x00, 0x01}, | ||
435 | {0x28, 0x17})) | ||
436 | return -EIO; | ||
437 | break; | ||
438 | default: | ||
439 | break; | ||
440 | } | ||
327 | 441 | ||
328 | if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00, | 442 | if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00, |
329 | 2+1, data) < 0) | 443 | 2, data) < 0) |
330 | return -EIO; | 444 | return -EIO; |
331 | 445 | ||
332 | if (data[2] != 0x82 || data[3] != 0x43) | 446 | if (data[0] != 0x82 || data[1] != 0x43) |
333 | return -ENODEV; | 447 | return -ENODEV; |
334 | 448 | ||
335 | sn9c102_attach_sensor(cam, &mi0360); | 449 | sn9c102_attach_sensor(cam, &mi0360); |
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c index 31b6080b0615..e6832347894f 100644 --- a/drivers/media/video/sn9c102/sn9c102_ov7630.c +++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c | |||
@@ -29,9 +29,8 @@ static int ov7630_init(struct sn9c102_device* cam) | |||
29 | switch (sn9c102_get_bridge(cam)) { | 29 | switch (sn9c102_get_bridge(cam)) { |
30 | case BRIDGE_SN9C101: | 30 | case BRIDGE_SN9C101: |
31 | case BRIDGE_SN9C102: | 31 | case BRIDGE_SN9C102: |
32 | err = sn9c102_write_const_regs(cam, {0x00, 0x14}, | 32 | err = sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, |
33 | {0x60, 0x17}, {0x0f, 0x18}, | 33 | {0x0f, 0x18}, {0x50, 0x19}); |
34 | {0x50, 0x19}); | ||
35 | 34 | ||
36 | err += sn9c102_i2c_write(cam, 0x12, 0x8d); | 35 | err += sn9c102_i2c_write(cam, 0x12, 0x8d); |
37 | err += sn9c102_i2c_write(cam, 0x12, 0x0d); | 36 | err += sn9c102_i2c_write(cam, 0x12, 0x0d); |
@@ -61,7 +60,6 @@ static int ov7630_init(struct sn9c102_device* cam) | |||
61 | err += sn9c102_i2c_write(cam, 0x71, 0x00); | 60 | err += sn9c102_i2c_write(cam, 0x71, 0x00); |
62 | err += sn9c102_i2c_write(cam, 0x74, 0x21); | 61 | err += sn9c102_i2c_write(cam, 0x74, 0x21); |
63 | err += sn9c102_i2c_write(cam, 0x7d, 0xf7); | 62 | err += sn9c102_i2c_write(cam, 0x7d, 0xf7); |
64 | |||
65 | break; | 63 | break; |
66 | case BRIDGE_SN9C103: | 64 | case BRIDGE_SN9C103: |
67 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, | 65 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, |
@@ -253,7 +251,7 @@ static int ov7630_set_pix_format(struct sn9c102_device* cam, | |||
253 | } | 251 | } |
254 | 252 | ||
255 | 253 | ||
256 | static struct sn9c102_sensor ov7630 = { | 254 | static const struct sn9c102_sensor ov7630 = { |
257 | .name = "OV7630", | 255 | .name = "OV7630", |
258 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 256 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
259 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, | 257 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, |
@@ -408,19 +406,16 @@ int sn9c102_probe_ov7630(struct sn9c102_device* cam) | |||
408 | switch (sn9c102_get_bridge(cam)) { | 406 | switch (sn9c102_get_bridge(cam)) { |
409 | case BRIDGE_SN9C101: | 407 | case BRIDGE_SN9C101: |
410 | case BRIDGE_SN9C102: | 408 | case BRIDGE_SN9C102: |
411 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, | 409 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, |
412 | {0x00, 0x01}, {0x28, 0x17}); | 410 | {0x28, 0x17}); |
413 | |||
414 | break; | 411 | break; |
415 | case BRIDGE_SN9C103: /* do _not_ change anything! */ | 412 | case BRIDGE_SN9C103: /* do _not_ change anything! */ |
416 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, | 413 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x42, 0x01}, |
417 | {0x42, 0x01}, {0x28, 0x17}, | 414 | {0x28, 0x17}, {0x44, 0x02}); |
418 | {0x44, 0x02}); | ||
419 | pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); | 415 | pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); |
420 | if (err || pid < 0) { /* try a different initialization */ | 416 | if (err || pid < 0) /* try a different initialization */ |
421 | err = sn9c102_write_reg(cam, 0x01, 0x01); | 417 | err += sn9c102_write_const_regs(cam, {0x01, 0x01}, |
422 | err += sn9c102_write_reg(cam, 0x00, 0x01); | 418 | {0x00, 0x01}); |
423 | } | ||
424 | break; | 419 | break; |
425 | default: | 420 | default: |
426 | break; | 421 | break; |
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7660.c b/drivers/media/video/sn9c102/sn9c102_ov7660.c index c898e948fe8d..4b6474048a72 100644 --- a/drivers/media/video/sn9c102/sn9c102_ov7660.c +++ b/drivers/media/video/sn9c102/sn9c102_ov7660.c | |||
@@ -104,8 +104,8 @@ static int ov7660_init(struct sn9c102_device* cam) | |||
104 | err += sn9c102_i2c_write(cam, 0x12, 0x80); | 104 | err += sn9c102_i2c_write(cam, 0x12, 0x80); |
105 | err += sn9c102_i2c_write(cam, 0x11, 0x09); | 105 | err += sn9c102_i2c_write(cam, 0x11, 0x09); |
106 | err += sn9c102_i2c_write(cam, 0x00, 0x0A); | 106 | err += sn9c102_i2c_write(cam, 0x00, 0x0A); |
107 | err += sn9c102_i2c_write(cam, 0x01, 0x78); | 107 | err += sn9c102_i2c_write(cam, 0x01, 0x80); |
108 | err += sn9c102_i2c_write(cam, 0x02, 0x90); | 108 | err += sn9c102_i2c_write(cam, 0x02, 0x80); |
109 | err += sn9c102_i2c_write(cam, 0x03, 0x00); | 109 | err += sn9c102_i2c_write(cam, 0x03, 0x00); |
110 | err += sn9c102_i2c_write(cam, 0x04, 0x00); | 110 | err += sn9c102_i2c_write(cam, 0x04, 0x00); |
111 | err += sn9c102_i2c_write(cam, 0x05, 0x08); | 111 | err += sn9c102_i2c_write(cam, 0x05, 0x08); |
@@ -122,7 +122,7 @@ static int ov7660_init(struct sn9c102_device* cam) | |||
122 | err += sn9c102_i2c_write(cam, 0x10, 0x20); | 122 | err += sn9c102_i2c_write(cam, 0x10, 0x20); |
123 | err += sn9c102_i2c_write(cam, 0x11, 0x03); | 123 | err += sn9c102_i2c_write(cam, 0x11, 0x03); |
124 | err += sn9c102_i2c_write(cam, 0x12, 0x05); | 124 | err += sn9c102_i2c_write(cam, 0x12, 0x05); |
125 | err += sn9c102_i2c_write(cam, 0x13, 0xF8); | 125 | err += sn9c102_i2c_write(cam, 0x13, 0xC7); |
126 | err += sn9c102_i2c_write(cam, 0x14, 0x2C); | 126 | err += sn9c102_i2c_write(cam, 0x14, 0x2C); |
127 | err += sn9c102_i2c_write(cam, 0x15, 0x00); | 127 | err += sn9c102_i2c_write(cam, 0x15, 0x00); |
128 | err += sn9c102_i2c_write(cam, 0x16, 0x02); | 128 | err += sn9c102_i2c_write(cam, 0x16, 0x02); |
@@ -162,7 +162,7 @@ static int ov7660_init(struct sn9c102_device* cam) | |||
162 | err += sn9c102_i2c_write(cam, 0x38, 0x02); | 162 | err += sn9c102_i2c_write(cam, 0x38, 0x02); |
163 | err += sn9c102_i2c_write(cam, 0x39, 0x43); | 163 | err += sn9c102_i2c_write(cam, 0x39, 0x43); |
164 | err += sn9c102_i2c_write(cam, 0x3A, 0x00); | 164 | err += sn9c102_i2c_write(cam, 0x3A, 0x00); |
165 | err += sn9c102_i2c_write(cam, 0x3B, 0x02); | 165 | err += sn9c102_i2c_write(cam, 0x3B, 0x0A); |
166 | err += sn9c102_i2c_write(cam, 0x3C, 0x6C); | 166 | err += sn9c102_i2c_write(cam, 0x3C, 0x6C); |
167 | err += sn9c102_i2c_write(cam, 0x3D, 0x99); | 167 | err += sn9c102_i2c_write(cam, 0x3D, 0x99); |
168 | err += sn9c102_i2c_write(cam, 0x3E, 0x0E); | 168 | err += sn9c102_i2c_write(cam, 0x3E, 0x0E); |
@@ -281,25 +281,34 @@ static int ov7660_get_ctrl(struct sn9c102_device* cam, | |||
281 | return -EIO; | 281 | return -EIO; |
282 | break; | 282 | break; |
283 | case V4L2_CID_DO_WHITE_BALANCE: | 283 | case V4L2_CID_DO_WHITE_BALANCE: |
284 | ctrl->value = sn9c102_pread_reg(cam, 0x02); | 284 | if ((ctrl->value = sn9c102_read_reg(cam, 0x02)) < 0) |
285 | return -EIO; | ||
285 | ctrl->value = (ctrl->value & 0x04) ? 1 : 0; | 286 | ctrl->value = (ctrl->value & 0x04) ? 1 : 0; |
286 | break; | 287 | break; |
287 | case V4L2_CID_RED_BALANCE: | 288 | case V4L2_CID_RED_BALANCE: |
288 | ctrl->value = sn9c102_pread_reg(cam, 0x05); | 289 | if ((ctrl->value = sn9c102_read_reg(cam, 0x05)) < 0) |
290 | return -EIO; | ||
289 | ctrl->value &= 0x7f; | 291 | ctrl->value &= 0x7f; |
290 | break; | 292 | break; |
291 | case V4L2_CID_BLUE_BALANCE: | 293 | case V4L2_CID_BLUE_BALANCE: |
292 | ctrl->value = sn9c102_pread_reg(cam, 0x06); | 294 | if ((ctrl->value = sn9c102_read_reg(cam, 0x06)) < 0) |
295 | return -EIO; | ||
293 | ctrl->value &= 0x7f; | 296 | ctrl->value &= 0x7f; |
294 | break; | 297 | break; |
295 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 298 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
296 | ctrl->value = sn9c102_pread_reg(cam, 0x07); | 299 | if ((ctrl->value = sn9c102_read_reg(cam, 0x07)) < 0) |
300 | return -EIO; | ||
297 | ctrl->value &= 0x7f; | 301 | ctrl->value &= 0x7f; |
298 | break; | 302 | break; |
303 | case SN9C102_V4L2_CID_BAND_FILTER: | ||
304 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x3b)) < 0) | ||
305 | return -EIO; | ||
306 | ctrl->value &= 0x08; | ||
307 | break; | ||
299 | case V4L2_CID_GAIN: | 308 | case V4L2_CID_GAIN: |
300 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0) | 309 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0) |
301 | return -EIO; | 310 | return -EIO; |
302 | ctrl->value &= 0x7f; | 311 | ctrl->value &= 0x1f; |
303 | break; | 312 | break; |
304 | case V4L2_CID_AUTOGAIN: | 313 | case V4L2_CID_AUTOGAIN: |
305 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0) | 314 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0) |
@@ -335,12 +344,15 @@ static int ov7660_set_ctrl(struct sn9c102_device* cam, | |||
335 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 344 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
336 | err += sn9c102_write_reg(cam, ctrl->value, 0x07); | 345 | err += sn9c102_write_reg(cam, ctrl->value, 0x07); |
337 | break; | 346 | break; |
347 | case SN9C102_V4L2_CID_BAND_FILTER: | ||
348 | err += sn9c102_i2c_write(cam, ctrl->value << 3, 0x3b); | ||
349 | break; | ||
338 | case V4L2_CID_GAIN: | 350 | case V4L2_CID_GAIN: |
339 | err += sn9c102_i2c_write(cam, 0x00, ctrl->value); | 351 | err += sn9c102_i2c_write(cam, 0x00, 0x60 + ctrl->value); |
340 | break; | 352 | break; |
341 | case V4L2_CID_AUTOGAIN: | 353 | case V4L2_CID_AUTOGAIN: |
342 | err += sn9c102_i2c_write(cam, 0x13, 0xf0 | ctrl->value | | 354 | err += sn9c102_i2c_write(cam, 0x13, 0xc0 | |
343 | (ctrl->value << 1)); | 355 | (ctrl->value * 0x07)); |
344 | break; | 356 | break; |
345 | default: | 357 | default: |
346 | return -EINVAL; | 358 | return -EINVAL; |
@@ -386,7 +398,7 @@ static int ov7660_set_pix_format(struct sn9c102_device* cam, | |||
386 | } | 398 | } |
387 | 399 | ||
388 | 400 | ||
389 | static struct sn9c102_sensor ov7660 = { | 401 | static const struct sn9c102_sensor ov7660 = { |
390 | .name = "OV7660", | 402 | .name = "OV7660", |
391 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 403 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
392 | .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120, | 404 | .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120, |
@@ -401,9 +413,9 @@ static struct sn9c102_sensor ov7660 = { | |||
401 | .type = V4L2_CTRL_TYPE_INTEGER, | 413 | .type = V4L2_CTRL_TYPE_INTEGER, |
402 | .name = "global gain", | 414 | .name = "global gain", |
403 | .minimum = 0x00, | 415 | .minimum = 0x00, |
404 | .maximum = 0x7f, | 416 | .maximum = 0x1f, |
405 | .step = 0x01, | 417 | .step = 0x01, |
406 | .default_value = 0x0a, | 418 | .default_value = 0x09, |
407 | .flags = 0, | 419 | .flags = 0, |
408 | }, | 420 | }, |
409 | { | 421 | { |
@@ -413,7 +425,7 @@ static struct sn9c102_sensor ov7660 = { | |||
413 | .minimum = 0x00, | 425 | .minimum = 0x00, |
414 | .maximum = 0xff, | 426 | .maximum = 0xff, |
415 | .step = 0x01, | 427 | .step = 0x01, |
416 | .default_value = 0x50, | 428 | .default_value = 0x27, |
417 | .flags = 0, | 429 | .flags = 0, |
418 | }, | 430 | }, |
419 | { | 431 | { |
@@ -433,7 +445,7 @@ static struct sn9c102_sensor ov7660 = { | |||
433 | .minimum = 0x00, | 445 | .minimum = 0x00, |
434 | .maximum = 0x7f, | 446 | .maximum = 0x7f, |
435 | .step = 0x01, | 447 | .step = 0x01, |
436 | .default_value = 0x1f, | 448 | .default_value = 0x14, |
437 | .flags = 0, | 449 | .flags = 0, |
438 | }, | 450 | }, |
439 | { | 451 | { |
@@ -443,7 +455,7 @@ static struct sn9c102_sensor ov7660 = { | |||
443 | .minimum = 0x00, | 455 | .minimum = 0x00, |
444 | .maximum = 0x7f, | 456 | .maximum = 0x7f, |
445 | .step = 0x01, | 457 | .step = 0x01, |
446 | .default_value = 0x1e, | 458 | .default_value = 0x14, |
447 | .flags = 0, | 459 | .flags = 0, |
448 | }, | 460 | }, |
449 | { | 461 | { |
@@ -453,7 +465,7 @@ static struct sn9c102_sensor ov7660 = { | |||
453 | .minimum = 0x00, | 465 | .minimum = 0x00, |
454 | .maximum = 0x01, | 466 | .maximum = 0x01, |
455 | .step = 0x01, | 467 | .step = 0x01, |
456 | .default_value = 0x00, | 468 | .default_value = 0x01, |
457 | .flags = 0, | 469 | .flags = 0, |
458 | }, | 470 | }, |
459 | { | 471 | { |
@@ -463,7 +475,17 @@ static struct sn9c102_sensor ov7660 = { | |||
463 | .minimum = 0x00, | 475 | .minimum = 0x00, |
464 | .maximum = 0x7f, | 476 | .maximum = 0x7f, |
465 | .step = 0x01, | 477 | .step = 0x01, |
466 | .default_value = 0x20, | 478 | .default_value = 0x14, |
479 | .flags = 0, | ||
480 | }, | ||
481 | { | ||
482 | .id = SN9C102_V4L2_CID_BAND_FILTER, | ||
483 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
484 | .name = "band filter", | ||
485 | .minimum = 0x00, | ||
486 | .maximum = 0x01, | ||
487 | .step = 0x01, | ||
488 | .default_value = 0x00, | ||
467 | .flags = 0, | 489 | .flags = 0, |
468 | }, | 490 | }, |
469 | }, | 491 | }, |
@@ -508,6 +530,7 @@ int sn9c102_probe_ov7660(struct sn9c102_device* cam) | |||
508 | return -EIO; | 530 | return -EIO; |
509 | if (pid != 0x76 || ver != 0x60) | 531 | if (pid != 0x76 || ver != 0x60) |
510 | return -ENODEV; | 532 | return -ENODEV; |
533 | |||
511 | sn9c102_attach_sensor(cam, &ov7660); | 534 | sn9c102_attach_sensor(cam, &ov7660); |
512 | 535 | ||
513 | return 0; | 536 | return 0; |
diff --git a/drivers/media/video/sn9c102/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c index 67151964801f..360f2a848bc0 100644 --- a/drivers/media/video/sn9c102/sn9c102_pas106b.c +++ b/drivers/media/video/sn9c102/sn9c102_pas106b.c | |||
@@ -163,7 +163,7 @@ static int pas106b_set_pix_format(struct sn9c102_device* cam, | |||
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | static struct sn9c102_sensor pas106b = { | 166 | static const struct sn9c102_sensor pas106b = { |
167 | .name = "PAS106B", | 167 | .name = "PAS106B", |
168 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 168 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
169 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 169 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
@@ -273,23 +273,21 @@ static struct sn9c102_sensor pas106b = { | |||
273 | 273 | ||
274 | int sn9c102_probe_pas106b(struct sn9c102_device* cam) | 274 | int sn9c102_probe_pas106b(struct sn9c102_device* cam) |
275 | { | 275 | { |
276 | int r0 = 0, r1 = 0, err; | 276 | int r0 = 0, r1 = 0; |
277 | unsigned int pid = 0; | 277 | unsigned int pid = 0; |
278 | 278 | ||
279 | /* | 279 | /* |
280 | Minimal initialization to enable the I2C communication | 280 | Minimal initialization to enable the I2C communication |
281 | NOTE: do NOT change the values! | 281 | NOTE: do NOT change the values! |
282 | */ | 282 | */ |
283 | err = sn9c102_write_const_regs(cam, | 283 | if (sn9c102_write_const_regs(cam, |
284 | {0x01, 0x01}, /* sensor power down */ | 284 | {0x01, 0x01}, /* sensor power down */ |
285 | {0x00, 0x01}, /* sensor power on */ | 285 | {0x00, 0x01}, /* sensor power on */ |
286 | {0x28, 0x17});/* sensor clock 24 MHz */ | 286 | {0x28, 0x17})) /* sensor clock at 24 MHz */ |
287 | if (err) | ||
288 | return -EIO; | 287 | return -EIO; |
289 | 288 | ||
290 | r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00); | 289 | r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00); |
291 | r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01); | 290 | r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01); |
292 | |||
293 | if (r0 < 0 || r1 < 0) | 291 | if (r0 < 0 || r1 < 0) |
294 | return -EIO; | 292 | return -EIO; |
295 | 293 | ||
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c index c1b8d6b63b47..ca4a1506ed3d 100644 --- a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c +++ b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c | |||
@@ -35,29 +35,28 @@ static int pas202bcb_init(struct sn9c102_device* cam) | |||
35 | switch (sn9c102_get_bridge(cam)) { | 35 | switch (sn9c102_get_bridge(cam)) { |
36 | case BRIDGE_SN9C101: | 36 | case BRIDGE_SN9C101: |
37 | case BRIDGE_SN9C102: | 37 | case BRIDGE_SN9C102: |
38 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, | 38 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, |
39 | {0x00, 0x11}, {0x00, 0x14}, | 39 | {0x00, 0x14}, {0x20, 0x17}, |
40 | {0x20, 0x17}, {0x30, 0x19}, | 40 | {0x30, 0x19}, {0x09, 0x18}); |
41 | {0x09, 0x18}); | ||
42 | break; | 41 | break; |
43 | case BRIDGE_SN9C103: | 42 | case BRIDGE_SN9C103: |
44 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, | 43 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, |
45 | {0x00, 0x03}, {0x1a, 0x04}, | 44 | {0x1a, 0x04}, {0x20, 0x05}, |
46 | {0x20, 0x05}, {0x20, 0x06}, | 45 | {0x20, 0x06}, {0x20, 0x07}, |
47 | {0x20, 0x07}, {0x00, 0x10}, | 46 | {0x00, 0x10}, {0x00, 0x11}, |
48 | {0x00, 0x11}, {0x00, 0x14}, | 47 | {0x00, 0x14}, {0x20, 0x17}, |
49 | {0x20, 0x17}, {0x30, 0x19}, | 48 | {0x30, 0x19}, {0x09, 0x18}, |
50 | {0x09, 0x18}, {0x02, 0x1c}, | 49 | {0x02, 0x1c}, {0x03, 0x1d}, |
51 | {0x03, 0x1d}, {0x0f, 0x1e}, | 50 | {0x0f, 0x1e}, {0x0c, 0x1f}, |
52 | {0x0c, 0x1f}, {0x00, 0x20}, | 51 | {0x00, 0x20}, {0x10, 0x21}, |
53 | {0x10, 0x21}, {0x20, 0x22}, | 52 | {0x20, 0x22}, {0x30, 0x23}, |
54 | {0x30, 0x23}, {0x40, 0x24}, | 53 | {0x40, 0x24}, {0x50, 0x25}, |
55 | {0x50, 0x25}, {0x60, 0x26}, | 54 | {0x60, 0x26}, {0x70, 0x27}, |
56 | {0x70, 0x27}, {0x80, 0x28}, | 55 | {0x80, 0x28}, {0x90, 0x29}, |
57 | {0x90, 0x29}, {0xa0, 0x2a}, | 56 | {0xa0, 0x2a}, {0xb0, 0x2b}, |
58 | {0xb0, 0x2b}, {0xc0, 0x2c}, | 57 | {0xc0, 0x2c}, {0xd0, 0x2d}, |
59 | {0xd0, 0x2d}, {0xe0, 0x2e}, | 58 | {0xe0, 0x2e}, {0xf0, 0x2f}, |
60 | {0xf0, 0x2f}, {0xff, 0x30}); | 59 | {0xff, 0x30}); |
61 | break; | 60 | break; |
62 | default: | 61 | default: |
63 | break; | 62 | break; |
@@ -197,7 +196,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam, | |||
197 | } | 196 | } |
198 | 197 | ||
199 | 198 | ||
200 | static struct sn9c102_sensor pas202bcb = { | 199 | static const struct sn9c102_sensor pas202bcb = { |
201 | .name = "PAS202BCB", | 200 | .name = "PAS202BCB", |
202 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 201 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
203 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, | 202 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, |
@@ -313,9 +312,8 @@ int sn9c102_probe_pas202bcb(struct sn9c102_device* cam) | |||
313 | {0x28, 0x17});/* clock 24 MHz */ | 312 | {0x28, 0x17});/* clock 24 MHz */ |
314 | break; | 313 | break; |
315 | case BRIDGE_SN9C103: /* do _not_ change anything! */ | 314 | case BRIDGE_SN9C103: /* do _not_ change anything! */ |
316 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, | 315 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x44, 0x01}, |
317 | {0x44, 0x01}, {0x44, 0x02}, | 316 | {0x44, 0x02}, {0x29, 0x17}); |
318 | {0x29, 0x17}); | ||
319 | break; | 317 | break; |
320 | default: | 318 | default: |
321 | break; | 319 | break; |
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h index 1bbf64c897a2..2d7d786b8430 100644 --- a/drivers/media/video/sn9c102/sn9c102_sensor.h +++ b/drivers/media/video/sn9c102/sn9c102_sensor.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #define _SN9C102_SENSOR_H_ | 22 | #define _SN9C102_SENSOR_H_ |
23 | 23 | ||
24 | #include <linux/usb.h> | 24 | #include <linux/usb.h> |
25 | #include <linux/videodev.h> | 25 | #include <linux/videodev2.h> |
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/stddef.h> | 27 | #include <linux/stddef.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
@@ -74,7 +74,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id); | |||
74 | /* Attach a probed sensor to the camera. */ | 74 | /* Attach a probed sensor to the camera. */ |
75 | extern void | 75 | extern void |
76 | sn9c102_attach_sensor(struct sn9c102_device* cam, | 76 | sn9c102_attach_sensor(struct sn9c102_device* cam, |
77 | struct sn9c102_sensor* sensor); | 77 | const struct sn9c102_sensor* sensor); |
78 | 78 | ||
79 | /* | 79 | /* |
80 | Read/write routines: they always return -1 on error, 0 or the read value | 80 | Read/write routines: they always return -1 on error, 0 or the read value |
@@ -85,10 +85,11 @@ sn9c102_attach_sensor(struct sn9c102_device* cam, | |||
85 | */ | 85 | */ |
86 | 86 | ||
87 | /* The "try" I2C I/O versions are used when probing the sensor */ | 87 | /* The "try" I2C I/O versions are used when probing the sensor */ |
88 | extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, | 88 | extern int sn9c102_i2c_try_write(struct sn9c102_device*, |
89 | u8 address, u8 value); | 89 | const struct sn9c102_sensor*, u8 address, |
90 | extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, | 90 | u8 value); |
91 | u8 address); | 91 | extern int sn9c102_i2c_try_read(struct sn9c102_device*, |
92 | const struct sn9c102_sensor*, u8 address); | ||
92 | 93 | ||
93 | /* | 94 | /* |
94 | These must be used if and only if the sensor doesn't implement the standard | 95 | These must be used if and only if the sensor doesn't implement the standard |
@@ -102,29 +103,31 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, | |||
102 | byte. | 103 | byte. |
103 | */ | 104 | */ |
104 | extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, | 105 | extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, |
105 | struct sn9c102_sensor* sensor, u8 n, | 106 | const struct sn9c102_sensor* sensor, u8 n, |
106 | u8 data0, u8 data1, u8 data2, u8 data3, | 107 | u8 data0, u8 data1, u8 data2, u8 data3, |
107 | u8 data4, u8 data5); | 108 | u8 data4, u8 data5); |
108 | extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | 109 | extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, |
109 | struct sn9c102_sensor* sensor, u8 data0, | 110 | const struct sn9c102_sensor* sensor, |
110 | u8 data1, u8 n, u8 buffer[]); | 111 | u8 data0, u8 data1, u8 n, u8 buffer[]); |
111 | 112 | ||
112 | /* To be used after the sensor struct has been attached to the camera struct */ | 113 | /* To be used after the sensor struct has been attached to the camera struct */ |
113 | extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); | 114 | extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); |
114 | extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); | 115 | extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); |
115 | 116 | ||
116 | /* I/O on registers in the bridge. Could be used by the sensor methods too */ | 117 | /* I/O on registers in the bridge. Could be used by the sensor methods too */ |
118 | extern int sn9c102_read_reg(struct sn9c102_device*, u16 index); | ||
117 | extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); | 119 | extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); |
118 | extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); | 120 | extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); |
119 | extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], | 121 | extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], |
120 | int count); | 122 | int count); |
121 | /* | 123 | /* |
122 | * Write multiple registers with constant values. For example: | 124 | Write multiple registers with constant values. For example: |
123 | * sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); | 125 | sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); |
124 | */ | 126 | Register adresses must be < 256. |
125 | #define sn9c102_write_const_regs(device, data...) \ | 127 | */ |
126 | ({ const static u8 _data[][2] = {data}; \ | 128 | #define sn9c102_write_const_regs(sn9c102_device, data...) \ |
127 | sn9c102_write_regs(device, _data, ARRAY_SIZE(_data)); }) | 129 | ({ const static u8 _valreg[][2] = {data}; \ |
130 | sn9c102_write_regs(sn9c102_device, _valreg, ARRAY_SIZE(_valreg)); }) | ||
128 | 131 | ||
129 | /*****************************************************************************/ | 132 | /*****************************************************************************/ |
130 | 133 | ||
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c index 0e7ec8662c70..e7d2de2bace1 100644 --- a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c +++ b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c | |||
@@ -88,7 +88,7 @@ static int tas5110c1b_set_pix_format(struct sn9c102_device* cam, | |||
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | static struct sn9c102_sensor tas5110c1b = { | 91 | static const struct sn9c102_sensor tas5110c1b = { |
92 | .name = "TAS5110C1B", | 92 | .name = "TAS5110C1B", |
93 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 93 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
94 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 94 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110d.c b/drivers/media/video/sn9c102/sn9c102_tas5110d.c index 83a39e8b5e71..d32fdbccdc5e 100644 --- a/drivers/media/video/sn9c102/sn9c102_tas5110d.c +++ b/drivers/media/video/sn9c102/sn9c102_tas5110d.c | |||
@@ -68,7 +68,7 @@ static int tas5110d_set_pix_format(struct sn9c102_device* cam, | |||
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | static struct sn9c102_sensor tas5110d = { | 71 | static const struct sn9c102_sensor tas5110d = { |
72 | .name = "TAS5110D", | 72 | .name = "TAS5110D", |
73 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 73 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
74 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 74 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c index 50406503fc40..56fb1d575a8a 100644 --- a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c +++ b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c | |||
@@ -89,7 +89,7 @@ static int tas5130d1b_set_pix_format(struct sn9c102_device* cam, | |||
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | static struct sn9c102_sensor tas5130d1b = { | 92 | static const struct sn9c102_sensor tas5130d1b = { |
93 | .name = "TAS5130D1B", | 93 | .name = "TAS5130D1B", |
94 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 94 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
95 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 95 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
diff --git a/drivers/media/video/usbvideo/Kconfig b/drivers/media/video/usbvideo/Kconfig index a0fd82b924f2..e4cb99c1f94b 100644 --- a/drivers/media/video/usbvideo/Kconfig +++ b/drivers/media/video/usbvideo/Kconfig | |||
@@ -3,7 +3,7 @@ config VIDEO_USBVIDEO | |||
3 | 3 | ||
4 | config USB_VICAM | 4 | config USB_VICAM |
5 | tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)" | 5 | tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)" |
6 | depends on USB && VIDEO_DEV && VIDEO_V4L1 && EXPERIMENTAL | 6 | depends on VIDEO_V4L1 && EXPERIMENTAL |
7 | select VIDEO_USBVIDEO | 7 | select VIDEO_USBVIDEO |
8 | ---help--- | 8 | ---help--- |
9 | Say Y here if you have 3com homeconnect camera (vicam). | 9 | Say Y here if you have 3com homeconnect camera (vicam). |
@@ -13,7 +13,7 @@ config USB_VICAM | |||
13 | 13 | ||
14 | config USB_IBMCAM | 14 | config USB_IBMCAM |
15 | tristate "USB IBM (Xirlink) C-it Camera support" | 15 | tristate "USB IBM (Xirlink) C-it Camera support" |
16 | depends on USB && VIDEO_DEV && VIDEO_V4L1 | 16 | depends on VIDEO_V4L1 |
17 | select VIDEO_USBVIDEO | 17 | select VIDEO_USBVIDEO |
18 | ---help--- | 18 | ---help--- |
19 | Say Y here if you want to connect a IBM "C-It" camera, also known as | 19 | Say Y here if you want to connect a IBM "C-It" camera, also known as |
@@ -28,7 +28,7 @@ config USB_IBMCAM | |||
28 | 28 | ||
29 | config USB_KONICAWC | 29 | config USB_KONICAWC |
30 | tristate "USB Konica Webcam support" | 30 | tristate "USB Konica Webcam support" |
31 | depends on USB && VIDEO_DEV && VIDEO_V4L1 | 31 | depends on VIDEO_V4L1 |
32 | select VIDEO_USBVIDEO | 32 | select VIDEO_USBVIDEO |
33 | ---help--- | 33 | ---help--- |
34 | Say Y here if you want support for webcams based on a Konica | 34 | Say Y here if you want support for webcams based on a Konica |
@@ -39,7 +39,7 @@ config USB_KONICAWC | |||
39 | 39 | ||
40 | config USB_QUICKCAM_MESSENGER | 40 | config USB_QUICKCAM_MESSENGER |
41 | tristate "USB Logitech Quickcam Messenger" | 41 | tristate "USB Logitech Quickcam Messenger" |
42 | depends on USB && VIDEO_DEV && VIDEO_V4L1 | 42 | depends on VIDEO_V4L1 |
43 | select VIDEO_USBVIDEO | 43 | select VIDEO_USBVIDEO |
44 | ---help--- | 44 | ---help--- |
45 | Say Y or M here to enable support for the USB Logitech Quickcam | 45 | Say Y or M here to enable support for the USB Logitech Quickcam |
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig index c43a5d899091..fc24ef05b3f3 100644 --- a/drivers/media/video/usbvision/Kconfig +++ b/drivers/media/video/usbvision/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config VIDEO_USBVISION | 1 | config VIDEO_USBVISION |
2 | tristate "USB video devices based on Nogatech NT1003/1004/1005" | 2 | tristate "USB video devices based on Nogatech NT1003/1004/1005" |
3 | depends on I2C && VIDEO_V4L2 && USB | 3 | depends on I2C && VIDEO_V4L2 |
4 | select VIDEO_TUNER | 4 | select VIDEO_TUNER |
5 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO | 5 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO |
6 | ---help--- | 6 | ---help--- |
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index a861e150865e..ede8543818bf 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c | |||
@@ -127,7 +127,7 @@ set_v4l_control(struct inode *inode, | |||
127 | 127 | ||
128 | /* ----------------------------------------------------------------- */ | 128 | /* ----------------------------------------------------------------- */ |
129 | 129 | ||
130 | static int palette2pixelformat[] = { | 130 | const static unsigned int palette2pixelformat[] = { |
131 | [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, | 131 | [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, |
132 | [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, | 132 | [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, |
133 | [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, | 133 | [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, |
@@ -145,7 +145,7 @@ static int palette2pixelformat[] = { | |||
145 | [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, | 145 | [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, |
146 | }; | 146 | }; |
147 | 147 | ||
148 | static unsigned int | 148 | static unsigned int __attribute_pure__ |
149 | palette_to_pixelformat(unsigned int palette) | 149 | palette_to_pixelformat(unsigned int palette) |
150 | { | 150 | { |
151 | if (palette < ARRAY_SIZE(palette2pixelformat)) | 151 | if (palette < ARRAY_SIZE(palette2pixelformat)) |
@@ -154,8 +154,8 @@ palette_to_pixelformat(unsigned int palette) | |||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | static unsigned int | 157 | static unsigned int __attribute_const__ |
158 | pixelformat_to_palette(int pixelformat) | 158 | pixelformat_to_palette(unsigned int pixelformat) |
159 | { | 159 | { |
160 | int palette = 0; | 160 | int palette = 0; |
161 | switch (pixelformat) | 161 | switch (pixelformat) |
@@ -616,6 +616,8 @@ v4l_compat_translate_ioctl(struct inode *inode, | |||
616 | case VIDIOCSPICT: /* set tone controls & partial capture format */ | 616 | case VIDIOCSPICT: /* set tone controls & partial capture format */ |
617 | { | 617 | { |
618 | struct video_picture *pict = arg; | 618 | struct video_picture *pict = arg; |
619 | int mem_err = 0, ovl_err = 0; | ||
620 | |||
619 | memset(&fbuf2, 0, sizeof(fbuf2)); | 621 | memset(&fbuf2, 0, sizeof(fbuf2)); |
620 | 622 | ||
621 | set_v4l_control(inode, file, | 623 | set_v4l_control(inode, file, |
@@ -628,33 +630,59 @@ v4l_compat_translate_ioctl(struct inode *inode, | |||
628 | V4L2_CID_SATURATION, pict->colour, drv); | 630 | V4L2_CID_SATURATION, pict->colour, drv); |
629 | set_v4l_control(inode, file, | 631 | set_v4l_control(inode, file, |
630 | V4L2_CID_WHITENESS, pict->whiteness, drv); | 632 | V4L2_CID_WHITENESS, pict->whiteness, drv); |
633 | /* | ||
634 | * V4L1 uses this ioctl to set both memory capture and overlay | ||
635 | * pixel format, while V4L2 has two different ioctls for this. | ||
636 | * Some cards may not support one or the other, and may support | ||
637 | * different pixel formats for memory vs overlay. | ||
638 | */ | ||
631 | 639 | ||
632 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); | 640 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
633 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 641 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
634 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | 642 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); |
635 | if (err < 0) | 643 | /* If VIDIOC_G_FMT failed, then the driver likely doesn't |
644 | support memory capture. Trying to set the memory capture | ||
645 | parameters would be pointless. */ | ||
646 | if (err < 0) { | ||
636 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); | 647 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); |
637 | if (fmt2->fmt.pix.pixelformat != | 648 | mem_err = -1000; /* didn't even try */ |
638 | palette_to_pixelformat(pict->palette)) { | 649 | } else if (fmt2->fmt.pix.pixelformat != |
650 | palette_to_pixelformat(pict->palette)) { | ||
639 | fmt2->fmt.pix.pixelformat = palette_to_pixelformat( | 651 | fmt2->fmt.pix.pixelformat = palette_to_pixelformat( |
640 | pict->palette); | 652 | pict->palette); |
641 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | 653 | mem_err = drv(inode, file, VIDIOC_S_FMT, fmt2); |
642 | if (err < 0) | 654 | if (mem_err < 0) |
643 | dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",err); | 655 | dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n", |
656 | mem_err); | ||
644 | } | 657 | } |
645 | 658 | ||
646 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | 659 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); |
647 | if (err < 0) | 660 | /* If VIDIOC_G_FBUF failed, then the driver likely doesn't |
661 | support overlay. Trying to set the overlay parameters | ||
662 | would be quite pointless. */ | ||
663 | if (err < 0) { | ||
648 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); | 664 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); |
649 | if (fbuf2.fmt.pixelformat != | 665 | ovl_err = -1000; /* didn't even try */ |
650 | palette_to_pixelformat(pict->palette)) { | 666 | } else if (fbuf2.fmt.pixelformat != |
667 | palette_to_pixelformat(pict->palette)) { | ||
651 | fbuf2.fmt.pixelformat = palette_to_pixelformat( | 668 | fbuf2.fmt.pixelformat = palette_to_pixelformat( |
652 | pict->palette); | 669 | pict->palette); |
653 | err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); | 670 | ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); |
654 | if (err < 0) | 671 | if (ovl_err < 0) |
655 | dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",err); | 672 | dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n", |
656 | err = 0; /* likely fails for non-root */ | 673 | ovl_err); |
657 | } | 674 | } |
675 | if (ovl_err < 0 && mem_err < 0) | ||
676 | /* ioctl failed, couldn't set either parameter */ | ||
677 | if (mem_err != -1000) { | ||
678 | err = mem_err; | ||
679 | } else if (ovl_err == -EPERM) { | ||
680 | err = 0; | ||
681 | } else { | ||
682 | err = ovl_err; | ||
683 | } | ||
684 | else | ||
685 | err = 0; | ||
658 | break; | 686 | break; |
659 | } | 687 | } |
660 | case VIDIOCGTUNER: /* get tuner information */ | 688 | case VIDIOCGTUNER: /* get tuner information */ |
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 459786ff459a..a32dfbe0585a 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c | |||
@@ -702,9 +702,7 @@ videobuf_qbuf(struct videobuf_queue *q, | |||
702 | dprintk(1,"qbuf: memory type is wrong.\n"); | 702 | dprintk(1,"qbuf: memory type is wrong.\n"); |
703 | goto done; | 703 | goto done; |
704 | } | 704 | } |
705 | if (buf->state == STATE_QUEUED || | 705 | if (buf->state != STATE_NEEDS_INIT && buf->state != STATE_IDLE) { |
706 | buf->state == STATE_PREPARED || | ||
707 | buf->state == STATE_ACTIVE) { | ||
708 | dprintk(1,"qbuf: buffer is already queued or active.\n"); | 706 | dprintk(1,"qbuf: buffer is already queued or active.\n"); |
709 | goto done; | 707 | goto done; |
710 | } | 708 | } |
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 5263b50463e1..b876aca69c73 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -433,13 +433,43 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
433 | int ret = -EINVAL; | 433 | int ret = -EINVAL; |
434 | 434 | ||
435 | if ( (vfd->debug & V4L2_DEBUG_IOCTL) && | 435 | if ( (vfd->debug & V4L2_DEBUG_IOCTL) && |
436 | !(vfd->debug | V4L2_DEBUG_IOCTL_ARG)) { | 436 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { |
437 | v4l_print_ioctl(vfd->name, cmd); | 437 | v4l_print_ioctl(vfd->name, cmd); |
438 | } | 438 | } |
439 | 439 | ||
440 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
441 | /*********************************************************** | ||
442 | Handles calls to the obsoleted V4L1 API | ||
443 | Due to the nature of VIDIOCGMBUF, each driver that supports | ||
444 | V4L1 should implement its own handler for this ioctl. | ||
445 | ***********************************************************/ | ||
446 | |||
447 | /* --- streaming capture ------------------------------------- */ | ||
448 | if (cmd == VIDIOCGMBUF) { | ||
449 | struct video_mbuf *p=arg; | ||
450 | |||
451 | memset(p,0,sizeof(p)); | ||
452 | |||
453 | if (!vfd->vidiocgmbuf) | ||
454 | return ret; | ||
455 | ret=vfd->vidiocgmbuf(file, fh, p); | ||
456 | if (!ret) | ||
457 | dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n", | ||
458 | p->size, p->frames, | ||
459 | (unsigned long)p->offsets); | ||
460 | return ret; | ||
461 | } | ||
462 | |||
463 | /******************************************************** | ||
464 | All other V4L1 calls are handled by v4l1_compat module. | ||
465 | Those calls will be translated into V4L2 calls, and | ||
466 | __video_do_ioctl will be called again, with one or more | ||
467 | V4L2 ioctls. | ||
468 | ********************************************************/ | ||
440 | if (_IOC_TYPE(cmd)=='v') | 469 | if (_IOC_TYPE(cmd)=='v') |
441 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, | 470 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, |
442 | __video_do_ioctl); | 471 | __video_do_ioctl); |
472 | #endif | ||
443 | 473 | ||
444 | switch(cmd) { | 474 | switch(cmd) { |
445 | /* --- capabilities ------------------------------------------ */ | 475 | /* --- capabilities ------------------------------------------ */ |
@@ -791,24 +821,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
791 | ret=vfd->vidioc_overlay(file, fh, *i); | 821 | ret=vfd->vidioc_overlay(file, fh, *i); |
792 | break; | 822 | break; |
793 | } | 823 | } |
794 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
795 | /* --- streaming capture ------------------------------------- */ | ||
796 | case VIDIOCGMBUF: | ||
797 | { | ||
798 | struct video_mbuf *p=arg; | ||
799 | |||
800 | memset(p,0,sizeof(p)); | ||
801 | |||
802 | if (!vfd->vidiocgmbuf) | ||
803 | break; | ||
804 | ret=vfd->vidiocgmbuf(file, fh, p); | ||
805 | if (!ret) | ||
806 | dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n", | ||
807 | p->size, p->frames, | ||
808 | (unsigned long)p->offsets); | ||
809 | break; | ||
810 | } | ||
811 | #endif | ||
812 | case VIDIOC_G_FBUF: | 824 | case VIDIOC_G_FBUF: |
813 | { | 825 | { |
814 | struct v4l2_framebuffer *p=arg; | 826 | struct v4l2_framebuffer *p=arg; |
diff --git a/drivers/media/video/zc0301/Kconfig b/drivers/media/video/zc0301/Kconfig index a859a6920189..47cd93f9c7de 100644 --- a/drivers/media/video/zc0301/Kconfig +++ b/drivers/media/video/zc0301/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_ZC0301 | 1 | config USB_ZC0301 |
2 | tristate "USB ZC0301[P] Image Processor and Control Chip support" | 2 | tristate "USB ZC0301[P] Image Processor and Control Chip support" |
3 | depends on USB && VIDEO_V4L1 | 3 | depends on VIDEO_V4L1 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y here if you want support for cameras based on the ZC0301 or | 5 | Say Y here if you want support for cameras based on the ZC0301 or |
6 | ZC0301P Image Processors and Control Chips. | 6 | ZC0301P Image Processors and Control Chips. |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index fa489b10c38c..fb99cd445504 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -1898,8 +1898,12 @@ endmenu | |||
1898 | # Gigabit Ethernet | 1898 | # Gigabit Ethernet |
1899 | # | 1899 | # |
1900 | 1900 | ||
1901 | menu "Ethernet (1000 Mbit)" | 1901 | menuconfig NETDEV_1000 |
1902 | bool "Ethernet (1000 Mbit)" | ||
1902 | depends on !UML | 1903 | depends on !UML |
1904 | default y | ||
1905 | |||
1906 | if NETDEV_1000 | ||
1903 | 1907 | ||
1904 | config ACENIC | 1908 | config ACENIC |
1905 | tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" | 1909 | tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" |
@@ -2299,7 +2303,7 @@ config UGETH_TX_ON_DEMAND | |||
2299 | 2303 | ||
2300 | config MV643XX_ETH | 2304 | config MV643XX_ETH |
2301 | tristate "MV-643XX Ethernet support" | 2305 | tristate "MV-643XX Ethernet support" |
2302 | depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MOMENCO_OCELOT_3 || (PPC_MULTIPLATFORM && PPC32) | 2306 | depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MV64X60 || MOMENCO_OCELOT_3 || (PPC_MULTIPLATFORM && PPC32) |
2303 | select MII | 2307 | select MII |
2304 | help | 2308 | help |
2305 | This driver supports the gigabit Ethernet on the Marvell MV643XX | 2309 | This driver supports the gigabit Ethernet on the Marvell MV643XX |
@@ -2326,14 +2330,18 @@ config ATL1 | |||
2326 | To compile this driver as a module, choose M here. The module | 2330 | To compile this driver as a module, choose M here. The module |
2327 | will be called atl1. | 2331 | will be called atl1. |
2328 | 2332 | ||
2329 | endmenu | 2333 | endif # NETDEV_1000 |
2330 | 2334 | ||
2331 | # | 2335 | # |
2332 | # 10 Gigabit Ethernet | 2336 | # 10 Gigabit Ethernet |
2333 | # | 2337 | # |
2334 | 2338 | ||
2335 | menu "Ethernet (10000 Mbit)" | 2339 | menuconfig NETDEV_10000 |
2340 | bool "Ethernet (10000 Mbit)" | ||
2336 | depends on !UML | 2341 | depends on !UML |
2342 | default y | ||
2343 | |||
2344 | if NETDEV_10000 | ||
2337 | 2345 | ||
2338 | config CHELSIO_T1 | 2346 | config CHELSIO_T1 |
2339 | tristate "Chelsio 10Gb Ethernet support" | 2347 | tristate "Chelsio 10Gb Ethernet support" |
@@ -2507,7 +2515,7 @@ config MLX4_DEBUG | |||
2507 | debug_level module parameter (which can also be set after | 2515 | debug_level module parameter (which can also be set after |
2508 | the driver is loaded through sysfs). | 2516 | the driver is loaded through sysfs). |
2509 | 2517 | ||
2510 | endmenu | 2518 | endif # NETDEV_10000 |
2511 | 2519 | ||
2512 | source "drivers/net/tokenring/Kconfig" | 2520 | source "drivers/net/tokenring/Kconfig" |
2513 | 2521 | ||
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig index 7c8ccc09b601..829da9a1d113 100644 --- a/drivers/net/irda/Kconfig +++ b/drivers/net/irda/Kconfig | |||
@@ -141,6 +141,20 @@ config ACT200L_DONGLE | |||
141 | To activate support for ACTiSYS IR-200L dongle you will have to | 141 | To activate support for ACTiSYS IR-200L dongle you will have to |
142 | start irattach like this: "irattach -d act200l". | 142 | start irattach like this: "irattach -d act200l". |
143 | 143 | ||
144 | config KINGSUN_DONGLE | ||
145 | tristate "KingSun/DonShine DS-620 IrDA-USB dongle" | ||
146 | depends on IRDA && USB && EXPERIMENTAL | ||
147 | help | ||
148 | Say Y or M here if you want to build support for the KingSun/DonShine | ||
149 | DS-620 IrDA-USB bridge device driver. | ||
150 | |||
151 | This USB bridge does not conform to the IrDA-USB device class | ||
152 | specification, and therefore needs its own specific driver. This | ||
153 | dongle supports SIR speed only (9600 bps). | ||
154 | |||
155 | To compile it as a module, choose M here: the module will be called | ||
156 | kingsun-sir. | ||
157 | |||
144 | comment "Old SIR device drivers" | 158 | comment "Old SIR device drivers" |
145 | 159 | ||
146 | config IRPORT_SIR | 160 | config IRPORT_SIR |
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile index 5be09f1b9ee2..233a2f923730 100644 --- a/drivers/net/irda/Makefile +++ b/drivers/net/irda/Makefile | |||
@@ -45,6 +45,7 @@ obj-$(CONFIG_MCP2120_DONGLE) += mcp2120-sir.o | |||
45 | obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o | 45 | obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o |
46 | obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o | 46 | obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o |
47 | obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o | 47 | obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o |
48 | obj-$(CONFIG_KINGSUN_DONGLE) += kingsun-sir.o | ||
48 | 49 | ||
49 | # The SIR helper module | 50 | # The SIR helper module |
50 | sir-dev-objs := sir_dev.o sir_dongle.o | 51 | sir-dev-objs := sir_dev.o sir_dongle.o |
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c new file mode 100644 index 000000000000..217429122e79 --- /dev/null +++ b/drivers/net/irda/kingsun-sir.c | |||
@@ -0,0 +1,657 @@ | |||
1 | /***************************************************************************** | ||
2 | * | ||
3 | * Filename: kingsun-sir.c | ||
4 | * Version: 0.1.1 | ||
5 | * Description: Irda KingSun/DonShine USB Dongle | ||
6 | * Status: Experimental | ||
7 | * Author: Alex Villac�s Lasso <a_villacis@palosanto.com> | ||
8 | * | ||
9 | * Based on stir4200 and mcs7780 drivers, with (strange?) differences | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | *****************************************************************************/ | ||
25 | |||
26 | /* | ||
27 | * This is my current (2007-04-25) understanding of how this dongle is supposed | ||
28 | * to work. This is based on reverse-engineering and examination of the packet | ||
29 | * data sent and received by the WinXP driver using USBSnoopy. Feel free to | ||
30 | * update here as more of this dongle is known: | ||
31 | * | ||
32 | * General: Unlike the other USB IrDA dongles, this particular dongle exposes, | ||
33 | * not two bulk (in and out) endpoints, but two *interrupt* ones. This dongle, | ||
34 | * like the bulk based ones (stir4200.c and mcs7780.c), requires polling in | ||
35 | * order to receive data. | ||
36 | * Transmission: Just like stir4200, this dongle uses a raw stream of data, | ||
37 | * which needs to be wrapped and escaped in a similar way as in stir4200.c. | ||
38 | * Reception: Poll-based, as in stir4200. Each read returns the contents of a | ||
39 | * 8-byte buffer, of which the first byte (LSB) indicates the number of bytes | ||
40 | * (1-7) of valid data contained within the remaining 7 bytes. For example, if | ||
41 | * the buffer had the following contents: | ||
42 | * 06 ff ff ff c0 01 04 aa | ||
43 | * This means that (06) there are 6 bytes of valid data. The byte 0xaa at the | ||
44 | * end is garbage (left over from a previous reception) and is discarded. | ||
45 | * If a read returns an "impossible" value as the length of valid data (such as | ||
46 | * 0x36) in the first byte, then the buffer is uninitialized (as is the case of | ||
47 | * first plug-in) and its contents should be discarded. There is currently no | ||
48 | * evidence that the top 5 bits of the 1st byte of the buffer can have values | ||
49 | * other than 0 once reception begins. | ||
50 | * Once valid bytes are collected, the assembled stream is a sequence of | ||
51 | * wrapped IrDA frames that is unwrapped and unescaped as in stir4200.c. | ||
52 | * BIG FAT WARNING: the dongle does *not* reset the RX buffer in any way after | ||
53 | * a successful read from the host, which means that in absence of further | ||
54 | * reception, repeated reads from the dongle will return the exact same | ||
55 | * contents repeatedly. Attempts to be smart and cache a previous read seem | ||
56 | * to result in corrupted packets, so this driver depends on the unwrap logic | ||
57 | * to sort out any repeated reads. | ||
58 | * Speed change: no commands observed so far to change speed, assumed fixed | ||
59 | * 9600bps (SIR). | ||
60 | */ | ||
61 | |||
62 | #include <linux/module.h> | ||
63 | #include <linux/moduleparam.h> | ||
64 | #include <linux/kernel.h> | ||
65 | #include <linux/types.h> | ||
66 | #include <linux/errno.h> | ||
67 | #include <linux/init.h> | ||
68 | #include <linux/slab.h> | ||
69 | #include <linux/module.h> | ||
70 | #include <linux/kref.h> | ||
71 | #include <linux/usb.h> | ||
72 | #include <linux/device.h> | ||
73 | #include <linux/crc32.h> | ||
74 | |||
75 | #include <asm/unaligned.h> | ||
76 | #include <asm/byteorder.h> | ||
77 | #include <asm/uaccess.h> | ||
78 | |||
79 | #include <net/irda/irda.h> | ||
80 | #include <net/irda/wrapper.h> | ||
81 | #include <net/irda/crc.h> | ||
82 | |||
83 | /* | ||
84 | * According to lsusb, 0x07c0 is assigned to | ||
85 | * "Code Mercenaries Hard- und Software GmbH" | ||
86 | */ | ||
87 | #define KING_VENDOR_ID 0x07c0 | ||
88 | #define KING_PRODUCT_ID 0x4200 | ||
89 | |||
90 | /* These are the currently known USB ids */ | ||
91 | static struct usb_device_id dongles[] = { | ||
92 | /* KingSun Co,Ltd IrDA/USB Bridge */ | ||
93 | { USB_DEVICE(KING_VENDOR_ID, KING_PRODUCT_ID) }, | ||
94 | { } | ||
95 | }; | ||
96 | |||
97 | MODULE_DEVICE_TABLE(usb, dongles); | ||
98 | |||
99 | #define KINGSUN_MTT 0x07 | ||
100 | |||
101 | #define KINGSUN_FIFO_SIZE 4096 | ||
102 | #define KINGSUN_EP_IN 0 | ||
103 | #define KINGSUN_EP_OUT 1 | ||
104 | |||
105 | struct kingsun_cb { | ||
106 | struct usb_device *usbdev; /* init: probe_irda */ | ||
107 | struct net_device *netdev; /* network layer */ | ||
108 | struct irlap_cb *irlap; /* The link layer we are binded to */ | ||
109 | struct net_device_stats stats; /* network statistics */ | ||
110 | struct qos_info qos; | ||
111 | |||
112 | __u8 *in_buf; /* receive buffer */ | ||
113 | __u8 *out_buf; /* transmit buffer */ | ||
114 | __u8 max_rx; /* max. atomic read from dongle | ||
115 | (usually 8), also size of in_buf */ | ||
116 | __u8 max_tx; /* max. atomic write to dongle | ||
117 | (usually 8) */ | ||
118 | |||
119 | iobuff_t rx_buff; /* receive unwrap state machine */ | ||
120 | struct timeval rx_time; | ||
121 | spinlock_t lock; | ||
122 | int receiving; | ||
123 | |||
124 | __u8 ep_in; | ||
125 | __u8 ep_out; | ||
126 | |||
127 | struct urb *tx_urb; | ||
128 | struct urb *rx_urb; | ||
129 | }; | ||
130 | |||
131 | /* Callback transmission routine */ | ||
132 | static void kingsun_send_irq(struct urb *urb) | ||
133 | { | ||
134 | struct kingsun_cb *kingsun = urb->context; | ||
135 | struct net_device *netdev = kingsun->netdev; | ||
136 | |||
137 | /* in process of stopping, just drop data */ | ||
138 | if (!netif_running(kingsun->netdev)) { | ||
139 | err("kingsun_send_irq: Network not running!"); | ||
140 | return; | ||
141 | } | ||
142 | |||
143 | /* unlink, shutdown, unplug, other nasties */ | ||
144 | if (urb->status != 0) { | ||
145 | err("kingsun_send_irq: urb asynchronously failed - %d", | ||
146 | urb->status); | ||
147 | } | ||
148 | netif_wake_queue(netdev); | ||
149 | } | ||
150 | |||
151 | /* | ||
152 | * Called from net/core when new frame is available. | ||
153 | */ | ||
154 | static int kingsun_hard_xmit(struct sk_buff *skb, struct net_device *netdev) | ||
155 | { | ||
156 | struct kingsun_cb *kingsun; | ||
157 | int wraplen; | ||
158 | int ret = 0; | ||
159 | |||
160 | if (skb == NULL || netdev == NULL) | ||
161 | return -EINVAL; | ||
162 | |||
163 | netif_stop_queue(netdev); | ||
164 | |||
165 | /* the IRDA wrapping routines don't deal with non linear skb */ | ||
166 | SKB_LINEAR_ASSERT(skb); | ||
167 | |||
168 | kingsun = netdev_priv(netdev); | ||
169 | |||
170 | spin_lock(&kingsun->lock); | ||
171 | |||
172 | /* Append data to the end of whatever data remains to be transmitted */ | ||
173 | wraplen = async_wrap_skb(skb, | ||
174 | kingsun->out_buf, | ||
175 | KINGSUN_FIFO_SIZE); | ||
176 | |||
177 | /* Calculate how much data can be transmitted in this urb */ | ||
178 | usb_fill_int_urb(kingsun->tx_urb, kingsun->usbdev, | ||
179 | usb_sndintpipe(kingsun->usbdev, kingsun->ep_out), | ||
180 | kingsun->out_buf, wraplen, kingsun_send_irq, | ||
181 | kingsun, 1); | ||
182 | |||
183 | if ((ret = usb_submit_urb(kingsun->tx_urb, GFP_ATOMIC))) { | ||
184 | err("kingsun_hard_xmit: failed tx_urb submit: %d", ret); | ||
185 | switch (ret) { | ||
186 | case -ENODEV: | ||
187 | case -EPIPE: | ||
188 | break; | ||
189 | default: | ||
190 | kingsun->stats.tx_errors++; | ||
191 | netif_start_queue(netdev); | ||
192 | } | ||
193 | } else { | ||
194 | kingsun->stats.tx_packets++; | ||
195 | kingsun->stats.tx_bytes += skb->len; | ||
196 | } | ||
197 | |||
198 | dev_kfree_skb(skb); | ||
199 | spin_unlock(&kingsun->lock); | ||
200 | |||
201 | return ret; | ||
202 | } | ||
203 | |||
204 | /* Receive callback function */ | ||
205 | static void kingsun_rcv_irq(struct urb *urb) | ||
206 | { | ||
207 | struct kingsun_cb *kingsun = urb->context; | ||
208 | int ret; | ||
209 | |||
210 | /* in process of stopping, just drop data */ | ||
211 | if (!netif_running(kingsun->netdev)) { | ||
212 | kingsun->receiving = 0; | ||
213 | return; | ||
214 | } | ||
215 | |||
216 | /* unlink, shutdown, unplug, other nasties */ | ||
217 | if (urb->status != 0) { | ||
218 | err("kingsun_rcv_irq: urb asynchronously failed - %d", | ||
219 | urb->status); | ||
220 | kingsun->receiving = 0; | ||
221 | return; | ||
222 | } | ||
223 | |||
224 | if (urb->actual_length == kingsun->max_rx) { | ||
225 | __u8 *bytes = urb->transfer_buffer; | ||
226 | int i; | ||
227 | |||
228 | /* The very first byte in the buffer indicates the length of | ||
229 | valid data in the read. This byte must be in the range | ||
230 | 1..kingsun->max_rx -1 . Values outside this range indicate | ||
231 | an uninitialized Rx buffer when the dongle has just been | ||
232 | plugged in. */ | ||
233 | if (bytes[0] >= 1 && bytes[0] < kingsun->max_rx) { | ||
234 | for (i = 1; i <= bytes[0]; i++) { | ||
235 | async_unwrap_char(kingsun->netdev, | ||
236 | &kingsun->stats, | ||
237 | &kingsun->rx_buff, bytes[i]); | ||
238 | } | ||
239 | kingsun->netdev->last_rx = jiffies; | ||
240 | do_gettimeofday(&kingsun->rx_time); | ||
241 | kingsun->receiving = | ||
242 | (kingsun->rx_buff.state != OUTSIDE_FRAME) | ||
243 | ? 1 : 0; | ||
244 | } | ||
245 | } else if (urb->actual_length > 0) { | ||
246 | err("%s(): Unexpected response length, expected %d got %d", | ||
247 | __FUNCTION__, kingsun->max_rx, urb->actual_length); | ||
248 | } | ||
249 | /* This urb has already been filled in kingsun_net_open */ | ||
250 | ret = usb_submit_urb(urb, GFP_ATOMIC); | ||
251 | } | ||
252 | |||
253 | /* | ||
254 | * Function kingsun_net_open (dev) | ||
255 | * | ||
256 | * Network device is taken up. Usually this is done by "ifconfig irda0 up" | ||
257 | */ | ||
258 | static int kingsun_net_open(struct net_device *netdev) | ||
259 | { | ||
260 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
261 | int err = -ENOMEM; | ||
262 | char hwname[16]; | ||
263 | |||
264 | /* At this point, urbs are NULL, and skb is NULL (see kingsun_probe) */ | ||
265 | kingsun->receiving = 0; | ||
266 | |||
267 | /* Initialize for SIR to copy data directly into skb. */ | ||
268 | kingsun->rx_buff.in_frame = FALSE; | ||
269 | kingsun->rx_buff.state = OUTSIDE_FRAME; | ||
270 | kingsun->rx_buff.truesize = IRDA_SKB_MAX_MTU; | ||
271 | kingsun->rx_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU); | ||
272 | if (!kingsun->rx_buff.skb) | ||
273 | goto free_mem; | ||
274 | |||
275 | skb_reserve(kingsun->rx_buff.skb, 1); | ||
276 | kingsun->rx_buff.head = kingsun->rx_buff.skb->data; | ||
277 | do_gettimeofday(&kingsun->rx_time); | ||
278 | |||
279 | kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
280 | if (!kingsun->rx_urb) | ||
281 | goto free_mem; | ||
282 | |||
283 | kingsun->tx_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
284 | if (!kingsun->tx_urb) | ||
285 | goto free_mem; | ||
286 | |||
287 | /* | ||
288 | * Now that everything should be initialized properly, | ||
289 | * Open new IrLAP layer instance to take care of us... | ||
290 | */ | ||
291 | sprintf(hwname, "usb#%d", kingsun->usbdev->devnum); | ||
292 | kingsun->irlap = irlap_open(netdev, &kingsun->qos, hwname); | ||
293 | if (!kingsun->irlap) { | ||
294 | err("kingsun-sir: irlap_open failed"); | ||
295 | goto free_mem; | ||
296 | } | ||
297 | |||
298 | /* Start first reception */ | ||
299 | usb_fill_int_urb(kingsun->rx_urb, kingsun->usbdev, | ||
300 | usb_rcvintpipe(kingsun->usbdev, kingsun->ep_in), | ||
301 | kingsun->in_buf, kingsun->max_rx, | ||
302 | kingsun_rcv_irq, kingsun, 1); | ||
303 | kingsun->rx_urb->status = 0; | ||
304 | err = usb_submit_urb(kingsun->rx_urb, GFP_KERNEL); | ||
305 | if (err) { | ||
306 | err("kingsun-sir: first urb-submit failed: %d", err); | ||
307 | goto close_irlap; | ||
308 | } | ||
309 | |||
310 | netif_start_queue(netdev); | ||
311 | |||
312 | /* Situation at this point: | ||
313 | - all work buffers allocated | ||
314 | - urbs allocated and ready to fill | ||
315 | - max rx packet known (in max_rx) | ||
316 | - unwrap state machine initialized, in state outside of any frame | ||
317 | - receive request in progress | ||
318 | - IrLAP layer started, about to hand over packets to send | ||
319 | */ | ||
320 | |||
321 | return 0; | ||
322 | |||
323 | close_irlap: | ||
324 | irlap_close(kingsun->irlap); | ||
325 | free_mem: | ||
326 | if (kingsun->tx_urb) { | ||
327 | usb_free_urb(kingsun->tx_urb); | ||
328 | kingsun->tx_urb = NULL; | ||
329 | } | ||
330 | if (kingsun->rx_urb) { | ||
331 | usb_free_urb(kingsun->rx_urb); | ||
332 | kingsun->rx_urb = NULL; | ||
333 | } | ||
334 | if (kingsun->rx_buff.skb) { | ||
335 | kfree_skb(kingsun->rx_buff.skb); | ||
336 | kingsun->rx_buff.skb = NULL; | ||
337 | kingsun->rx_buff.head = NULL; | ||
338 | } | ||
339 | return err; | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * Function kingsun_net_close (kingsun) | ||
344 | * | ||
345 | * Network device is taken down. Usually this is done by | ||
346 | * "ifconfig irda0 down" | ||
347 | */ | ||
348 | static int kingsun_net_close(struct net_device *netdev) | ||
349 | { | ||
350 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
351 | |||
352 | /* Stop transmit processing */ | ||
353 | netif_stop_queue(netdev); | ||
354 | |||
355 | /* Mop up receive && transmit urb's */ | ||
356 | usb_kill_urb(kingsun->tx_urb); | ||
357 | usb_kill_urb(kingsun->rx_urb); | ||
358 | |||
359 | usb_free_urb(kingsun->tx_urb); | ||
360 | usb_free_urb(kingsun->rx_urb); | ||
361 | |||
362 | kingsun->tx_urb = NULL; | ||
363 | kingsun->rx_urb = NULL; | ||
364 | |||
365 | kfree_skb(kingsun->rx_buff.skb); | ||
366 | kingsun->rx_buff.skb = NULL; | ||
367 | kingsun->rx_buff.head = NULL; | ||
368 | kingsun->rx_buff.in_frame = FALSE; | ||
369 | kingsun->rx_buff.state = OUTSIDE_FRAME; | ||
370 | kingsun->receiving = 0; | ||
371 | |||
372 | /* Stop and remove instance of IrLAP */ | ||
373 | if (kingsun->irlap) | ||
374 | irlap_close(kingsun->irlap); | ||
375 | |||
376 | kingsun->irlap = NULL; | ||
377 | |||
378 | return 0; | ||
379 | } | ||
380 | |||
381 | /* | ||
382 | * IOCTLs : Extra out-of-band network commands... | ||
383 | */ | ||
384 | static int kingsun_net_ioctl(struct net_device *netdev, struct ifreq *rq, | ||
385 | int cmd) | ||
386 | { | ||
387 | struct if_irda_req *irq = (struct if_irda_req *) rq; | ||
388 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
389 | int ret = 0; | ||
390 | |||
391 | switch (cmd) { | ||
392 | case SIOCSBANDWIDTH: /* Set bandwidth */ | ||
393 | if (!capable(CAP_NET_ADMIN)) | ||
394 | return -EPERM; | ||
395 | |||
396 | /* Check if the device is still there */ | ||
397 | if (netif_device_present(kingsun->netdev)) | ||
398 | /* No observed commands for speed change */ | ||
399 | ret = -EOPNOTSUPP; | ||
400 | break; | ||
401 | |||
402 | case SIOCSMEDIABUSY: /* Set media busy */ | ||
403 | if (!capable(CAP_NET_ADMIN)) | ||
404 | return -EPERM; | ||
405 | |||
406 | /* Check if the IrDA stack is still there */ | ||
407 | if (netif_running(kingsun->netdev)) | ||
408 | irda_device_set_media_busy(kingsun->netdev, TRUE); | ||
409 | break; | ||
410 | |||
411 | case SIOCGRECEIVING: | ||
412 | /* Only approximately true */ | ||
413 | irq->ifr_receiving = kingsun->receiving; | ||
414 | break; | ||
415 | |||
416 | default: | ||
417 | ret = -EOPNOTSUPP; | ||
418 | } | ||
419 | |||
420 | return ret; | ||
421 | } | ||
422 | |||
423 | /* | ||
424 | * Get device stats (for /proc/net/dev and ifconfig) | ||
425 | */ | ||
426 | static struct net_device_stats * | ||
427 | kingsun_net_get_stats(struct net_device *netdev) | ||
428 | { | ||
429 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
430 | return &kingsun->stats; | ||
431 | } | ||
432 | |||
433 | /* | ||
434 | * This routine is called by the USB subsystem for each new device | ||
435 | * in the system. We need to check if the device is ours, and in | ||
436 | * this case start handling it. | ||
437 | */ | ||
438 | static int kingsun_probe(struct usb_interface *intf, | ||
439 | const struct usb_device_id *id) | ||
440 | { | ||
441 | struct usb_host_interface *interface; | ||
442 | struct usb_endpoint_descriptor *endpoint; | ||
443 | |||
444 | struct usb_device *dev = interface_to_usbdev(intf); | ||
445 | struct kingsun_cb *kingsun = NULL; | ||
446 | struct net_device *net = NULL; | ||
447 | int ret = -ENOMEM; | ||
448 | int pipe, maxp_in, maxp_out; | ||
449 | __u8 ep_in; | ||
450 | __u8 ep_out; | ||
451 | |||
452 | /* Check that there really are two interrupt endpoints. | ||
453 | Check based on the one in drivers/usb/input/usbmouse.c | ||
454 | */ | ||
455 | interface = intf->cur_altsetting; | ||
456 | if (interface->desc.bNumEndpoints != 2) { | ||
457 | err("kingsun-sir: expected 2 endpoints, found %d", | ||
458 | interface->desc.bNumEndpoints); | ||
459 | return -ENODEV; | ||
460 | } | ||
461 | endpoint = &interface->endpoint[KINGSUN_EP_IN].desc; | ||
462 | if (!usb_endpoint_is_int_in(endpoint)) { | ||
463 | err("kingsun-sir: endpoint 0 is not interrupt IN"); | ||
464 | return -ENODEV; | ||
465 | } | ||
466 | |||
467 | ep_in = endpoint->bEndpointAddress; | ||
468 | pipe = usb_rcvintpipe(dev, ep_in); | ||
469 | maxp_in = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | ||
470 | if (maxp_in > 255 || maxp_in <= 1) { | ||
471 | err("%s: endpoint 0 has max packet size %d not in range", | ||
472 | __FILE__, maxp_in); | ||
473 | return -ENODEV; | ||
474 | } | ||
475 | |||
476 | endpoint = &interface->endpoint[KINGSUN_EP_OUT].desc; | ||
477 | if (!usb_endpoint_is_int_out(endpoint)) { | ||
478 | err("kingsun-sir: endpoint 1 is not interrupt OUT"); | ||
479 | return -ENODEV; | ||
480 | } | ||
481 | |||
482 | ep_out = endpoint->bEndpointAddress; | ||
483 | pipe = usb_sndintpipe(dev, ep_out); | ||
484 | maxp_out = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | ||
485 | |||
486 | /* Allocate network device container. */ | ||
487 | net = alloc_irdadev(sizeof(*kingsun)); | ||
488 | if(!net) | ||
489 | goto err_out1; | ||
490 | |||
491 | SET_MODULE_OWNER(net); | ||
492 | SET_NETDEV_DEV(net, &intf->dev); | ||
493 | kingsun = netdev_priv(net); | ||
494 | kingsun->irlap = NULL; | ||
495 | kingsun->tx_urb = NULL; | ||
496 | kingsun->rx_urb = NULL; | ||
497 | kingsun->ep_in = ep_in; | ||
498 | kingsun->ep_out = ep_out; | ||
499 | kingsun->in_buf = NULL; | ||
500 | kingsun->out_buf = NULL; | ||
501 | kingsun->max_rx = (__u8)maxp_in; | ||
502 | kingsun->max_tx = (__u8)maxp_out; | ||
503 | kingsun->netdev = net; | ||
504 | kingsun->usbdev = dev; | ||
505 | kingsun->rx_buff.in_frame = FALSE; | ||
506 | kingsun->rx_buff.state = OUTSIDE_FRAME; | ||
507 | kingsun->rx_buff.skb = NULL; | ||
508 | kingsun->receiving = 0; | ||
509 | spin_lock_init(&kingsun->lock); | ||
510 | |||
511 | /* Allocate input buffer */ | ||
512 | kingsun->in_buf = (__u8 *)kmalloc(kingsun->max_rx, GFP_KERNEL); | ||
513 | if (!kingsun->in_buf) | ||
514 | goto free_mem; | ||
515 | |||
516 | /* Allocate output buffer */ | ||
517 | kingsun->out_buf = (__u8 *)kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL); | ||
518 | if (!kingsun->out_buf) | ||
519 | goto free_mem; | ||
520 | |||
521 | printk(KERN_INFO "KingSun/DonShine IRDA/USB found at address %d, " | ||
522 | "Vendor: %x, Product: %x\n", | ||
523 | dev->devnum, le16_to_cpu(dev->descriptor.idVendor), | ||
524 | le16_to_cpu(dev->descriptor.idProduct)); | ||
525 | |||
526 | /* Initialize QoS for this device */ | ||
527 | irda_init_max_qos_capabilies(&kingsun->qos); | ||
528 | |||
529 | /* That's the Rx capability. */ | ||
530 | kingsun->qos.baud_rate.bits &= IR_9600; | ||
531 | kingsun->qos.min_turn_time.bits &= KINGSUN_MTT; | ||
532 | irda_qos_bits_to_value(&kingsun->qos); | ||
533 | |||
534 | /* Override the network functions we need to use */ | ||
535 | net->hard_start_xmit = kingsun_hard_xmit; | ||
536 | net->open = kingsun_net_open; | ||
537 | net->stop = kingsun_net_close; | ||
538 | net->get_stats = kingsun_net_get_stats; | ||
539 | net->do_ioctl = kingsun_net_ioctl; | ||
540 | |||
541 | ret = register_netdev(net); | ||
542 | if (ret != 0) | ||
543 | goto free_mem; | ||
544 | |||
545 | info("IrDA: Registered KingSun/DonShine device %s", net->name); | ||
546 | |||
547 | usb_set_intfdata(intf, kingsun); | ||
548 | |||
549 | /* Situation at this point: | ||
550 | - all work buffers allocated | ||
551 | - urbs not allocated, set to NULL | ||
552 | - max rx packet known (in max_rx) | ||
553 | - unwrap state machine (partially) initialized, but skb == NULL | ||
554 | */ | ||
555 | |||
556 | return 0; | ||
557 | |||
558 | free_mem: | ||
559 | if (kingsun->out_buf) kfree(kingsun->out_buf); | ||
560 | if (kingsun->in_buf) kfree(kingsun->in_buf); | ||
561 | free_netdev(net); | ||
562 | err_out1: | ||
563 | return ret; | ||
564 | } | ||
565 | |||
566 | /* | ||
567 | * The current device is removed, the USB layer tell us to shut it down... | ||
568 | */ | ||
569 | static void kingsun_disconnect(struct usb_interface *intf) | ||
570 | { | ||
571 | struct kingsun_cb *kingsun = usb_get_intfdata(intf); | ||
572 | |||
573 | if (!kingsun) | ||
574 | return; | ||
575 | |||
576 | unregister_netdev(kingsun->netdev); | ||
577 | |||
578 | /* Mop up receive && transmit urb's */ | ||
579 | if (kingsun->tx_urb != NULL) { | ||
580 | usb_kill_urb(kingsun->tx_urb); | ||
581 | usb_free_urb(kingsun->tx_urb); | ||
582 | kingsun->tx_urb = NULL; | ||
583 | } | ||
584 | if (kingsun->rx_urb != NULL) { | ||
585 | usb_kill_urb(kingsun->rx_urb); | ||
586 | usb_free_urb(kingsun->rx_urb); | ||
587 | kingsun->rx_urb = NULL; | ||
588 | } | ||
589 | |||
590 | kfree(kingsun->out_buf); | ||
591 | kfree(kingsun->in_buf); | ||
592 | free_netdev(kingsun->netdev); | ||
593 | |||
594 | usb_set_intfdata(intf, NULL); | ||
595 | } | ||
596 | |||
597 | #ifdef CONFIG_PM | ||
598 | /* USB suspend, so power off the transmitter/receiver */ | ||
599 | static int kingsun_suspend(struct usb_interface *intf, pm_message_t message) | ||
600 | { | ||
601 | struct kingsun_cb *kingsun = usb_get_intfdata(intf); | ||
602 | |||
603 | netif_device_detach(kingsun->netdev); | ||
604 | if (kingsun->tx_urb != NULL) usb_kill_urb(kingsun->tx_urb); | ||
605 | if (kingsun->rx_urb != NULL) usb_kill_urb(kingsun->rx_urb); | ||
606 | return 0; | ||
607 | } | ||
608 | |||
609 | /* Coming out of suspend, so reset hardware */ | ||
610 | static int kingsun_resume(struct usb_interface *intf) | ||
611 | { | ||
612 | struct kingsun_cb *kingsun = usb_get_intfdata(intf); | ||
613 | |||
614 | if (kingsun->rx_urb != NULL) | ||
615 | usb_submit_urb(kingsun->rx_urb, GFP_KERNEL); | ||
616 | netif_device_attach(kingsun->netdev); | ||
617 | |||
618 | return 0; | ||
619 | } | ||
620 | #endif | ||
621 | |||
622 | /* | ||
623 | * USB device callbacks | ||
624 | */ | ||
625 | static struct usb_driver irda_driver = { | ||
626 | .name = "kingsun-sir", | ||
627 | .probe = kingsun_probe, | ||
628 | .disconnect = kingsun_disconnect, | ||
629 | .id_table = dongles, | ||
630 | #ifdef CONFIG_PM | ||
631 | .suspend = kingsun_suspend, | ||
632 | .resume = kingsun_resume, | ||
633 | #endif | ||
634 | }; | ||
635 | |||
636 | /* | ||
637 | * Module insertion | ||
638 | */ | ||
639 | static int __init kingsun_init(void) | ||
640 | { | ||
641 | return usb_register(&irda_driver); | ||
642 | } | ||
643 | module_init(kingsun_init); | ||
644 | |||
645 | /* | ||
646 | * Module removal | ||
647 | */ | ||
648 | static void __exit kingsun_cleanup(void) | ||
649 | { | ||
650 | /* Deregister the driver and remove all pending instances */ | ||
651 | usb_deregister(&irda_driver); | ||
652 | } | ||
653 | module_exit(kingsun_cleanup); | ||
654 | |||
655 | MODULE_AUTHOR("Alex Villac�s Lasso <a_villacis@palosanto.com>"); | ||
656 | MODULE_DESCRIPTION("IrDA-USB Dongle Driver for KingSun/DonShine"); | ||
657 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c index acf1c801a1b8..af016d0ea1c6 100644 --- a/drivers/net/mlx4/eq.c +++ b/drivers/net/mlx4/eq.c | |||
@@ -623,7 +623,7 @@ int __devinit mlx4_init_eq_table(struct mlx4_dev *dev) | |||
623 | priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1; | 623 | priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1; |
624 | } else { | 624 | } else { |
625 | err = request_irq(dev->pdev->irq, mlx4_interrupt, | 625 | err = request_irq(dev->pdev->irq, mlx4_interrupt, |
626 | SA_SHIRQ, DRV_NAME, dev); | 626 | IRQF_SHARED, DRV_NAME, dev); |
627 | if (err) | 627 | if (err) |
628 | goto err_out_async; | 628 | goto err_out_async; |
629 | 629 | ||
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 4e32bb678ea9..2c5c6d20e6e9 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -735,7 +735,7 @@ static int netxen_nic_open(struct net_device *netdev) | |||
735 | } | 735 | } |
736 | adapter->irq = adapter->ahw.pdev->irq; | 736 | adapter->irq = adapter->ahw.pdev->irq; |
737 | err = request_irq(adapter->ahw.pdev->irq, netxen_intr, | 737 | err = request_irq(adapter->ahw.pdev->irq, netxen_intr, |
738 | SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, | 738 | IRQF_SHARED|IRQF_SAMPLE_RANDOM, netdev->name, |
739 | adapter); | 739 | adapter); |
740 | if (err) { | 740 | if (err) { |
741 | printk(KERN_ERR "request_irq failed with: %d\n", err); | 741 | printk(KERN_ERR "request_irq failed with: %d\n", err); |
diff --git a/drivers/net/pcmcia/Kconfig b/drivers/net/pcmcia/Kconfig index 74f862001247..5d658bc9791c 100644 --- a/drivers/net/pcmcia/Kconfig +++ b/drivers/net/pcmcia/Kconfig | |||
@@ -2,11 +2,9 @@ | |||
2 | # PCMCIA Network device configuration | 2 | # PCMCIA Network device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "PCMCIA network device support" | 5 | menuconfig NET_PCMCIA |
6 | depends on NETDEVICES && PCMCIA!=n | ||
7 | |||
8 | config NET_PCMCIA | ||
9 | bool "PCMCIA network device support" | 6 | bool "PCMCIA network device support" |
7 | depends on PCMCIA | ||
10 | ---help--- | 8 | ---help--- |
11 | Say Y if you would like to include support for any PCMCIA or CardBus | 9 | Say Y if you would like to include support for any PCMCIA or CardBus |
12 | network adapters, then say Y to the driver for your particular card | 10 | network adapters, then say Y to the driver for your particular card |
@@ -21,9 +19,10 @@ config NET_PCMCIA | |||
21 | 19 | ||
22 | If unsure, say N. | 20 | If unsure, say N. |
23 | 21 | ||
22 | if NET_PCMCIA | ||
23 | |||
24 | config PCMCIA_3C589 | 24 | config PCMCIA_3C589 |
25 | tristate "3Com 3c589 PCMCIA support" | 25 | tristate "3Com 3c589 PCMCIA support" |
26 | depends on NET_PCMCIA && PCMCIA | ||
27 | help | 26 | help |
28 | Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA | 27 | Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA |
29 | (PC-card) Ethernet card to your computer. | 28 | (PC-card) Ethernet card to your computer. |
@@ -33,7 +32,6 @@ config PCMCIA_3C589 | |||
33 | 32 | ||
34 | config PCMCIA_3C574 | 33 | config PCMCIA_3C574 |
35 | tristate "3Com 3c574 PCMCIA support" | 34 | tristate "3Com 3c574 PCMCIA support" |
36 | depends on NET_PCMCIA && PCMCIA | ||
37 | help | 35 | help |
38 | Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA | 36 | Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA |
39 | (PC-card) Fast Ethernet card to your computer. | 37 | (PC-card) Fast Ethernet card to your computer. |
@@ -43,7 +41,6 @@ config PCMCIA_3C574 | |||
43 | 41 | ||
44 | config PCMCIA_FMVJ18X | 42 | config PCMCIA_FMVJ18X |
45 | tristate "Fujitsu FMV-J18x PCMCIA support" | 43 | tristate "Fujitsu FMV-J18x PCMCIA support" |
46 | depends on NET_PCMCIA && PCMCIA | ||
47 | select CRC32 | 44 | select CRC32 |
48 | help | 45 | help |
49 | Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible | 46 | Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible |
@@ -54,7 +51,6 @@ config PCMCIA_FMVJ18X | |||
54 | 51 | ||
55 | config PCMCIA_PCNET | 52 | config PCMCIA_PCNET |
56 | tristate "NE2000 compatible PCMCIA support" | 53 | tristate "NE2000 compatible PCMCIA support" |
57 | depends on NET_PCMCIA && PCMCIA | ||
58 | select CRC32 | 54 | select CRC32 |
59 | help | 55 | help |
60 | Say Y here if you intend to attach an NE2000 compatible PCMCIA | 56 | Say Y here if you intend to attach an NE2000 compatible PCMCIA |
@@ -65,7 +61,6 @@ config PCMCIA_PCNET | |||
65 | 61 | ||
66 | config PCMCIA_NMCLAN | 62 | config PCMCIA_NMCLAN |
67 | tristate "New Media PCMCIA support" | 63 | tristate "New Media PCMCIA support" |
68 | depends on NET_PCMCIA && PCMCIA | ||
69 | help | 64 | help |
70 | Say Y here if you intend to attach a New Media Ethernet or LiveWire | 65 | Say Y here if you intend to attach a New Media Ethernet or LiveWire |
71 | PCMCIA (PC-card) Ethernet card to your computer. | 66 | PCMCIA (PC-card) Ethernet card to your computer. |
@@ -75,7 +70,6 @@ config PCMCIA_NMCLAN | |||
75 | 70 | ||
76 | config PCMCIA_SMC91C92 | 71 | config PCMCIA_SMC91C92 |
77 | tristate "SMC 91Cxx PCMCIA support" | 72 | tristate "SMC 91Cxx PCMCIA support" |
78 | depends on NET_PCMCIA && PCMCIA | ||
79 | select CRC32 | 73 | select CRC32 |
80 | select MII | 74 | select MII |
81 | help | 75 | help |
@@ -87,7 +81,6 @@ config PCMCIA_SMC91C92 | |||
87 | 81 | ||
88 | config PCMCIA_XIRC2PS | 82 | config PCMCIA_XIRC2PS |
89 | tristate "Xircom 16-bit PCMCIA support" | 83 | tristate "Xircom 16-bit PCMCIA support" |
90 | depends on NET_PCMCIA && PCMCIA | ||
91 | help | 84 | help |
92 | Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card) | 85 | Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card) |
93 | Ethernet or Fast Ethernet card to your computer. | 86 | Ethernet or Fast Ethernet card to your computer. |
@@ -97,7 +90,6 @@ config PCMCIA_XIRC2PS | |||
97 | 90 | ||
98 | config PCMCIA_AXNET | 91 | config PCMCIA_AXNET |
99 | tristate "Asix AX88190 PCMCIA support" | 92 | tristate "Asix AX88190 PCMCIA support" |
100 | depends on NET_PCMCIA && PCMCIA | ||
101 | ---help--- | 93 | ---help--- |
102 | Say Y here if you intend to attach an Asix AX88190-based PCMCIA | 94 | Say Y here if you intend to attach an Asix AX88190-based PCMCIA |
103 | (PC-card) Fast Ethernet card to your computer. These cards are | 95 | (PC-card) Fast Ethernet card to your computer. These cards are |
@@ -109,7 +101,7 @@ config PCMCIA_AXNET | |||
109 | 101 | ||
110 | config ARCNET_COM20020_CS | 102 | config ARCNET_COM20020_CS |
111 | tristate "COM20020 ARCnet PCMCIA support" | 103 | tristate "COM20020 ARCnet PCMCIA support" |
112 | depends on NET_PCMCIA && ARCNET_COM20020 && PCMCIA | 104 | depends on ARCNET_COM20020 |
113 | help | 105 | help |
114 | Say Y here if you intend to attach this type of ARCnet PCMCIA card | 106 | Say Y here if you intend to attach this type of ARCnet PCMCIA card |
115 | to your computer. | 107 | to your computer. |
@@ -119,7 +111,7 @@ config ARCNET_COM20020_CS | |||
119 | 111 | ||
120 | config PCMCIA_IBMTR | 112 | config PCMCIA_IBMTR |
121 | tristate "IBM PCMCIA tokenring adapter support" | 113 | tristate "IBM PCMCIA tokenring adapter support" |
122 | depends on NET_PCMCIA && IBMTR!=y && TR && PCMCIA && !64BIT | 114 | depends on IBMTR!=y && TR && !64BIT |
123 | help | 115 | help |
124 | Say Y here if you intend to attach this type of Token Ring PCMCIA | 116 | Say Y here if you intend to attach this type of Token Ring PCMCIA |
125 | card to your computer. You then also need to say Y to "Token Ring | 117 | card to your computer. You then also need to say Y to "Token Ring |
@@ -128,5 +120,4 @@ config PCMCIA_IBMTR | |||
128 | To compile this driver as a module, choose M here: the module will be | 120 | To compile this driver as a module, choose M here: the module will be |
129 | called ibmtr_cs. | 121 | called ibmtr_cs. |
130 | 122 | ||
131 | endmenu | 123 | endif # NET_PCMCIA |
132 | |||
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index c0d3101eb6a0..09b6f259eb92 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
@@ -2,70 +2,61 @@ | |||
2 | # PHY Layer Configuration | 2 | # PHY Layer Configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "PHY device support" | 5 | menuconfig PHYLIB |
6 | depends on !S390 | ||
7 | |||
8 | config PHYLIB | ||
9 | tristate "PHY Device support and infrastructure" | 6 | tristate "PHY Device support and infrastructure" |
7 | depends on !S390 | ||
10 | depends on NET_ETHERNET && (BROKEN || !S390) | 8 | depends on NET_ETHERNET && (BROKEN || !S390) |
11 | help | 9 | help |
12 | Ethernet controllers are usually attached to PHY | 10 | Ethernet controllers are usually attached to PHY |
13 | devices. This option provides infrastructure for | 11 | devices. This option provides infrastructure for |
14 | managing PHY devices. | 12 | managing PHY devices. |
15 | 13 | ||
14 | if PHYLIB | ||
15 | |||
16 | comment "MII PHY device drivers" | 16 | comment "MII PHY device drivers" |
17 | depends on PHYLIB | ||
18 | 17 | ||
19 | config MARVELL_PHY | 18 | config MARVELL_PHY |
20 | tristate "Drivers for Marvell PHYs" | 19 | tristate "Drivers for Marvell PHYs" |
21 | depends on PHYLIB | ||
22 | ---help--- | 20 | ---help--- |
23 | Currently has a driver for the 88E1011S | 21 | Currently has a driver for the 88E1011S |
24 | 22 | ||
25 | config DAVICOM_PHY | 23 | config DAVICOM_PHY |
26 | tristate "Drivers for Davicom PHYs" | 24 | tristate "Drivers for Davicom PHYs" |
27 | depends on PHYLIB | ||
28 | ---help--- | 25 | ---help--- |
29 | Currently supports dm9161e and dm9131 | 26 | Currently supports dm9161e and dm9131 |
30 | 27 | ||
31 | config QSEMI_PHY | 28 | config QSEMI_PHY |
32 | tristate "Drivers for Quality Semiconductor PHYs" | 29 | tristate "Drivers for Quality Semiconductor PHYs" |
33 | depends on PHYLIB | ||
34 | ---help--- | 30 | ---help--- |
35 | Currently supports the qs6612 | 31 | Currently supports the qs6612 |
36 | 32 | ||
37 | config LXT_PHY | 33 | config LXT_PHY |
38 | tristate "Drivers for the Intel LXT PHYs" | 34 | tristate "Drivers for the Intel LXT PHYs" |
39 | depends on PHYLIB | ||
40 | ---help--- | 35 | ---help--- |
41 | Currently supports the lxt970, lxt971 | 36 | Currently supports the lxt970, lxt971 |
42 | 37 | ||
43 | config CICADA_PHY | 38 | config CICADA_PHY |
44 | tristate "Drivers for the Cicada PHYs" | 39 | tristate "Drivers for the Cicada PHYs" |
45 | depends on PHYLIB | ||
46 | ---help--- | 40 | ---help--- |
47 | Currently supports the cis8204 | 41 | Currently supports the cis8204 |
42 | |||
48 | config VITESSE_PHY | 43 | config VITESSE_PHY |
49 | tristate "Drivers for the Vitesse PHYs" | 44 | tristate "Drivers for the Vitesse PHYs" |
50 | depends on PHYLIB | ||
51 | ---help--- | 45 | ---help--- |
52 | Currently supports the vsc8244 | 46 | Currently supports the vsc8244 |
53 | 47 | ||
54 | config SMSC_PHY | 48 | config SMSC_PHY |
55 | tristate "Drivers for SMSC PHYs" | 49 | tristate "Drivers for SMSC PHYs" |
56 | depends on PHYLIB | ||
57 | ---help--- | 50 | ---help--- |
58 | Currently supports the LAN83C185 PHY | 51 | Currently supports the LAN83C185 PHY |
59 | 52 | ||
60 | config BROADCOM_PHY | 53 | config BROADCOM_PHY |
61 | tristate "Drivers for Broadcom PHYs" | 54 | tristate "Drivers for Broadcom PHYs" |
62 | depends on PHYLIB | ||
63 | ---help--- | 55 | ---help--- |
64 | Currently supports the BCM5411, BCM5421 and BCM5461 PHYs. | 56 | Currently supports the BCM5411, BCM5421 and BCM5461 PHYs. |
65 | 57 | ||
66 | config FIXED_PHY | 58 | config FIXED_PHY |
67 | tristate "Drivers for PHY emulation on fixed speed/link" | 59 | tristate "Drivers for PHY emulation on fixed speed/link" |
68 | depends on PHYLIB | ||
69 | ---help--- | 60 | ---help--- |
70 | Adds the driver to PHY layer to cover the boards that do not have any PHY bound, | 61 | Adds the driver to PHY layer to cover the boards that do not have any PHY bound, |
71 | but with the ability to manipulate the speed/link in software. The relevant MII | 62 | but with the ability to manipulate the speed/link in software. The relevant MII |
@@ -80,5 +71,4 @@ config FIXED_MII_100_FDX | |||
80 | bool "Emulation for 100M Fdx fixed PHY behavior" | 71 | bool "Emulation for 100M Fdx fixed PHY behavior" |
81 | depends on FIXED_PHY | 72 | depends on FIXED_PHY |
82 | 73 | ||
83 | endmenu | 74 | endif # PHYLIB |
84 | |||
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c index 519baa38be8d..7ed632db00d7 100644 --- a/drivers/net/phy/davicom.c +++ b/drivers/net/phy/davicom.c | |||
@@ -139,7 +139,7 @@ static int dm9161_ack_interrupt(struct phy_device *phydev) | |||
139 | return (err < 0) ? err : 0; | 139 | return (err < 0) ? err : 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | static struct phy_driver dm9161_driver = { | 142 | static struct phy_driver dm9161e_driver = { |
143 | .phy_id = 0x0181b880, | 143 | .phy_id = 0x0181b880, |
144 | .name = "Davicom DM9161E", | 144 | .name = "Davicom DM9161E", |
145 | .phy_id_mask = 0x0ffffff0, | 145 | .phy_id_mask = 0x0ffffff0, |
@@ -147,7 +147,18 @@ static struct phy_driver dm9161_driver = { | |||
147 | .config_init = dm9161_config_init, | 147 | .config_init = dm9161_config_init, |
148 | .config_aneg = dm9161_config_aneg, | 148 | .config_aneg = dm9161_config_aneg, |
149 | .read_status = genphy_read_status, | 149 | .read_status = genphy_read_status, |
150 | .driver = { .owner = THIS_MODULE,}, | 150 | .driver = { .owner = THIS_MODULE,}, |
151 | }; | ||
152 | |||
153 | static struct phy_driver dm9161a_driver = { | ||
154 | .phy_id = 0x0181b8a0, | ||
155 | .name = "Davicom DM9161A", | ||
156 | .phy_id_mask = 0x0ffffff0, | ||
157 | .features = PHY_BASIC_FEATURES, | ||
158 | .config_init = dm9161_config_init, | ||
159 | .config_aneg = dm9161_config_aneg, | ||
160 | .read_status = genphy_read_status, | ||
161 | .driver = { .owner = THIS_MODULE,}, | ||
151 | }; | 162 | }; |
152 | 163 | ||
153 | static struct phy_driver dm9131_driver = { | 164 | static struct phy_driver dm9131_driver = { |
@@ -160,31 +171,38 @@ static struct phy_driver dm9131_driver = { | |||
160 | .read_status = genphy_read_status, | 171 | .read_status = genphy_read_status, |
161 | .ack_interrupt = dm9161_ack_interrupt, | 172 | .ack_interrupt = dm9161_ack_interrupt, |
162 | .config_intr = dm9161_config_intr, | 173 | .config_intr = dm9161_config_intr, |
163 | .driver = { .owner = THIS_MODULE,}, | 174 | .driver = { .owner = THIS_MODULE,}, |
164 | }; | 175 | }; |
165 | 176 | ||
166 | static int __init davicom_init(void) | 177 | static int __init davicom_init(void) |
167 | { | 178 | { |
168 | int ret; | 179 | int ret; |
169 | 180 | ||
170 | ret = phy_driver_register(&dm9161_driver); | 181 | ret = phy_driver_register(&dm9161e_driver); |
171 | if (ret) | 182 | if (ret) |
172 | goto err1; | 183 | goto err1; |
173 | 184 | ||
174 | ret = phy_driver_register(&dm9131_driver); | 185 | ret = phy_driver_register(&dm9161a_driver); |
175 | if (ret) | 186 | if (ret) |
176 | goto err2; | 187 | goto err2; |
188 | |||
189 | ret = phy_driver_register(&dm9131_driver); | ||
190 | if (ret) | ||
191 | goto err3; | ||
177 | return 0; | 192 | return 0; |
178 | 193 | ||
179 | err2: | 194 | err3: |
180 | phy_driver_unregister(&dm9161_driver); | 195 | phy_driver_unregister(&dm9161a_driver); |
196 | err2: | ||
197 | phy_driver_unregister(&dm9161e_driver); | ||
181 | err1: | 198 | err1: |
182 | return ret; | 199 | return ret; |
183 | } | 200 | } |
184 | 201 | ||
185 | static void __exit davicom_exit(void) | 202 | static void __exit davicom_exit(void) |
186 | { | 203 | { |
187 | phy_driver_unregister(&dm9161_driver); | 204 | phy_driver_unregister(&dm9161e_driver); |
205 | phy_driver_unregister(&dm9161a_driver); | ||
188 | phy_driver_unregister(&dm9131_driver); | 206 | phy_driver_unregister(&dm9131_driver); |
189 | } | 207 | } |
190 | 208 | ||
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 290e1c1f30c6..e3e6d410d72c 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -84,7 +84,7 @@ | |||
84 | #include "s2io.h" | 84 | #include "s2io.h" |
85 | #include "s2io-regs.h" | 85 | #include "s2io-regs.h" |
86 | 86 | ||
87 | #define DRV_VERSION "2.0.22.1" | 87 | #define DRV_VERSION "2.0.23.1" |
88 | 88 | ||
89 | /* S2io Driver name & version. */ | 89 | /* S2io Driver name & version. */ |
90 | static char s2io_driver_name[] = "Neterion"; | 90 | static char s2io_driver_name[] = "Neterion"; |
@@ -281,6 +281,28 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = { | |||
281 | ("lro_out_of_sequence_pkts"), | 281 | ("lro_out_of_sequence_pkts"), |
282 | ("lro_flush_due_to_max_pkts"), | 282 | ("lro_flush_due_to_max_pkts"), |
283 | ("lro_avg_aggr_pkts"), | 283 | ("lro_avg_aggr_pkts"), |
284 | ("mem_alloc_fail_cnt"), | ||
285 | ("watchdog_timer_cnt"), | ||
286 | ("mem_allocated"), | ||
287 | ("mem_freed"), | ||
288 | ("link_up_cnt"), | ||
289 | ("link_down_cnt"), | ||
290 | ("link_up_time"), | ||
291 | ("link_down_time"), | ||
292 | ("tx_tcode_buf_abort_cnt"), | ||
293 | ("tx_tcode_desc_abort_cnt"), | ||
294 | ("tx_tcode_parity_err_cnt"), | ||
295 | ("tx_tcode_link_loss_cnt"), | ||
296 | ("tx_tcode_list_proc_err_cnt"), | ||
297 | ("rx_tcode_parity_err_cnt"), | ||
298 | ("rx_tcode_abort_cnt"), | ||
299 | ("rx_tcode_parity_abort_cnt"), | ||
300 | ("rx_tcode_rda_fail_cnt"), | ||
301 | ("rx_tcode_unkn_prot_cnt"), | ||
302 | ("rx_tcode_fcs_err_cnt"), | ||
303 | ("rx_tcode_buf_size_err_cnt"), | ||
304 | ("rx_tcode_rxd_corrupt_cnt"), | ||
305 | ("rx_tcode_unkn_err_cnt") | ||
284 | }; | 306 | }; |
285 | 307 | ||
286 | #define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN | 308 | #define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN |
@@ -490,6 +512,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
490 | 512 | ||
491 | struct mac_info *mac_control; | 513 | struct mac_info *mac_control; |
492 | struct config_param *config; | 514 | struct config_param *config; |
515 | unsigned long long mem_allocated = 0; | ||
493 | 516 | ||
494 | mac_control = &nic->mac_control; | 517 | mac_control = &nic->mac_control; |
495 | config = &nic->config; | 518 | config = &nic->config; |
@@ -519,6 +542,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
519 | "Malloc failed for list_info\n"); | 542 | "Malloc failed for list_info\n"); |
520 | return -ENOMEM; | 543 | return -ENOMEM; |
521 | } | 544 | } |
545 | mem_allocated += list_holder_size; | ||
522 | memset(mac_control->fifos[i].list_info, 0, list_holder_size); | 546 | memset(mac_control->fifos[i].list_info, 0, list_holder_size); |
523 | } | 547 | } |
524 | for (i = 0; i < config->tx_fifo_num; i++) { | 548 | for (i = 0; i < config->tx_fifo_num; i++) { |
@@ -565,6 +589,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
565 | DBG_PRINT(INFO_DBG, "failed for TxDL\n"); | 589 | DBG_PRINT(INFO_DBG, "failed for TxDL\n"); |
566 | return -ENOMEM; | 590 | return -ENOMEM; |
567 | } | 591 | } |
592 | mem_allocated += PAGE_SIZE; | ||
568 | } | 593 | } |
569 | while (k < lst_per_page) { | 594 | while (k < lst_per_page) { |
570 | int l = (j * lst_per_page) + k; | 595 | int l = (j * lst_per_page) + k; |
@@ -582,6 +607,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
582 | nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); | 607 | nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); |
583 | if (!nic->ufo_in_band_v) | 608 | if (!nic->ufo_in_band_v) |
584 | return -ENOMEM; | 609 | return -ENOMEM; |
610 | mem_allocated += (size * sizeof(u64)); | ||
585 | 611 | ||
586 | /* Allocation and initialization of RXDs in Rings */ | 612 | /* Allocation and initialization of RXDs in Rings */ |
587 | size = 0; | 613 | size = 0; |
@@ -639,6 +665,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
639 | rx_blocks->block_virt_addr = tmp_v_addr; | 665 | rx_blocks->block_virt_addr = tmp_v_addr; |
640 | return -ENOMEM; | 666 | return -ENOMEM; |
641 | } | 667 | } |
668 | mem_allocated += size; | ||
642 | memset(tmp_v_addr, 0, size); | 669 | memset(tmp_v_addr, 0, size); |
643 | rx_blocks->block_virt_addr = tmp_v_addr; | 670 | rx_blocks->block_virt_addr = tmp_v_addr; |
644 | rx_blocks->block_dma_addr = tmp_p_addr; | 671 | rx_blocks->block_dma_addr = tmp_p_addr; |
@@ -647,6 +674,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
647 | GFP_KERNEL); | 674 | GFP_KERNEL); |
648 | if (!rx_blocks->rxds) | 675 | if (!rx_blocks->rxds) |
649 | return -ENOMEM; | 676 | return -ENOMEM; |
677 | mem_allocated += | ||
678 | (sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]); | ||
650 | for (l=0; l<rxd_count[nic->rxd_mode];l++) { | 679 | for (l=0; l<rxd_count[nic->rxd_mode];l++) { |
651 | rx_blocks->rxds[l].virt_addr = | 680 | rx_blocks->rxds[l].virt_addr = |
652 | rx_blocks->block_virt_addr + | 681 | rx_blocks->block_virt_addr + |
@@ -689,6 +718,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
689 | GFP_KERNEL); | 718 | GFP_KERNEL); |
690 | if (!mac_control->rings[i].ba) | 719 | if (!mac_control->rings[i].ba) |
691 | return -ENOMEM; | 720 | return -ENOMEM; |
721 | mem_allocated +=(sizeof(struct buffAdd *) * blk_cnt); | ||
692 | for (j = 0; j < blk_cnt; j++) { | 722 | for (j = 0; j < blk_cnt; j++) { |
693 | int k = 0; | 723 | int k = 0; |
694 | mac_control->rings[i].ba[j] = | 724 | mac_control->rings[i].ba[j] = |
@@ -697,6 +727,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
697 | GFP_KERNEL); | 727 | GFP_KERNEL); |
698 | if (!mac_control->rings[i].ba[j]) | 728 | if (!mac_control->rings[i].ba[j]) |
699 | return -ENOMEM; | 729 | return -ENOMEM; |
730 | mem_allocated += (sizeof(struct buffAdd) * \ | ||
731 | (rxd_count[nic->rxd_mode] + 1)); | ||
700 | while (k != rxd_count[nic->rxd_mode]) { | 732 | while (k != rxd_count[nic->rxd_mode]) { |
701 | ba = &mac_control->rings[i].ba[j][k]; | 733 | ba = &mac_control->rings[i].ba[j][k]; |
702 | 734 | ||
@@ -704,6 +736,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
704 | (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); | 736 | (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); |
705 | if (!ba->ba_0_org) | 737 | if (!ba->ba_0_org) |
706 | return -ENOMEM; | 738 | return -ENOMEM; |
739 | mem_allocated += | ||
740 | (BUF0_LEN + ALIGN_SIZE); | ||
707 | tmp = (unsigned long)ba->ba_0_org; | 741 | tmp = (unsigned long)ba->ba_0_org; |
708 | tmp += ALIGN_SIZE; | 742 | tmp += ALIGN_SIZE; |
709 | tmp &= ~((unsigned long) ALIGN_SIZE); | 743 | tmp &= ~((unsigned long) ALIGN_SIZE); |
@@ -713,6 +747,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
713 | (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); | 747 | (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); |
714 | if (!ba->ba_1_org) | 748 | if (!ba->ba_1_org) |
715 | return -ENOMEM; | 749 | return -ENOMEM; |
750 | mem_allocated | ||
751 | += (BUF1_LEN + ALIGN_SIZE); | ||
716 | tmp = (unsigned long) ba->ba_1_org; | 752 | tmp = (unsigned long) ba->ba_1_org; |
717 | tmp += ALIGN_SIZE; | 753 | tmp += ALIGN_SIZE; |
718 | tmp &= ~((unsigned long) ALIGN_SIZE); | 754 | tmp &= ~((unsigned long) ALIGN_SIZE); |
@@ -736,6 +772,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
736 | */ | 772 | */ |
737 | return -ENOMEM; | 773 | return -ENOMEM; |
738 | } | 774 | } |
775 | mem_allocated += size; | ||
739 | mac_control->stats_mem_sz = size; | 776 | mac_control->stats_mem_sz = size; |
740 | 777 | ||
741 | tmp_v_addr = mac_control->stats_mem; | 778 | tmp_v_addr = mac_control->stats_mem; |
@@ -743,7 +780,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
743 | memset(tmp_v_addr, 0, size); | 780 | memset(tmp_v_addr, 0, size); |
744 | DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, | 781 | DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, |
745 | (unsigned long long) tmp_p_addr); | 782 | (unsigned long long) tmp_p_addr); |
746 | 783 | mac_control->stats_info->sw_stat.mem_allocated += mem_allocated; | |
747 | return SUCCESS; | 784 | return SUCCESS; |
748 | } | 785 | } |
749 | 786 | ||
@@ -757,12 +794,14 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
757 | static void free_shared_mem(struct s2io_nic *nic) | 794 | static void free_shared_mem(struct s2io_nic *nic) |
758 | { | 795 | { |
759 | int i, j, blk_cnt, size; | 796 | int i, j, blk_cnt, size; |
797 | u32 ufo_size = 0; | ||
760 | void *tmp_v_addr; | 798 | void *tmp_v_addr; |
761 | dma_addr_t tmp_p_addr; | 799 | dma_addr_t tmp_p_addr; |
762 | struct mac_info *mac_control; | 800 | struct mac_info *mac_control; |
763 | struct config_param *config; | 801 | struct config_param *config; |
764 | int lst_size, lst_per_page; | 802 | int lst_size, lst_per_page; |
765 | struct net_device *dev = nic->dev; | 803 | struct net_device *dev = nic->dev; |
804 | int page_num = 0; | ||
766 | 805 | ||
767 | if (!nic) | 806 | if (!nic) |
768 | return; | 807 | return; |
@@ -774,8 +813,9 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
774 | lst_per_page = PAGE_SIZE / lst_size; | 813 | lst_per_page = PAGE_SIZE / lst_size; |
775 | 814 | ||
776 | for (i = 0; i < config->tx_fifo_num; i++) { | 815 | for (i = 0; i < config->tx_fifo_num; i++) { |
777 | int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, | 816 | ufo_size += config->tx_cfg[i].fifo_len; |
778 | lst_per_page); | 817 | page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, |
818 | lst_per_page); | ||
779 | for (j = 0; j < page_num; j++) { | 819 | for (j = 0; j < page_num; j++) { |
780 | int mem_blks = (j * lst_per_page); | 820 | int mem_blks = (j * lst_per_page); |
781 | if (!mac_control->fifos[i].list_info) | 821 | if (!mac_control->fifos[i].list_info) |
@@ -790,6 +830,8 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
790 | mac_control->fifos[i]. | 830 | mac_control->fifos[i]. |
791 | list_info[mem_blks]. | 831 | list_info[mem_blks]. |
792 | list_phy_addr); | 832 | list_phy_addr); |
833 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
834 | += PAGE_SIZE; | ||
793 | } | 835 | } |
794 | /* If we got a zero DMA address during allocation, | 836 | /* If we got a zero DMA address during allocation, |
795 | * free the page now | 837 | * free the page now |
@@ -803,8 +845,12 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
803 | dev->name); | 845 | dev->name); |
804 | DBG_PRINT(INIT_DBG, "Virtual address %p\n", | 846 | DBG_PRINT(INIT_DBG, "Virtual address %p\n", |
805 | mac_control->zerodma_virt_addr); | 847 | mac_control->zerodma_virt_addr); |
848 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
849 | += PAGE_SIZE; | ||
806 | } | 850 | } |
807 | kfree(mac_control->fifos[i].list_info); | 851 | kfree(mac_control->fifos[i].list_info); |
852 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
853 | (nic->config.tx_cfg[i].fifo_len *sizeof(struct list_info_hold)); | ||
808 | } | 854 | } |
809 | 855 | ||
810 | size = SIZE_OF_BLOCK; | 856 | size = SIZE_OF_BLOCK; |
@@ -819,7 +865,10 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
819 | break; | 865 | break; |
820 | pci_free_consistent(nic->pdev, size, | 866 | pci_free_consistent(nic->pdev, size, |
821 | tmp_v_addr, tmp_p_addr); | 867 | tmp_v_addr, tmp_p_addr); |
868 | nic->mac_control.stats_info->sw_stat.mem_freed += size; | ||
822 | kfree(mac_control->rings[i].rx_blocks[j].rxds); | 869 | kfree(mac_control->rings[i].rx_blocks[j].rxds); |
870 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
871 | ( sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]); | ||
823 | } | 872 | } |
824 | } | 873 | } |
825 | 874 | ||
@@ -836,12 +885,20 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
836 | struct buffAdd *ba = | 885 | struct buffAdd *ba = |
837 | &mac_control->rings[i].ba[j][k]; | 886 | &mac_control->rings[i].ba[j][k]; |
838 | kfree(ba->ba_0_org); | 887 | kfree(ba->ba_0_org); |
888 | nic->mac_control.stats_info->sw_stat.\ | ||
889 | mem_freed += (BUF0_LEN + ALIGN_SIZE); | ||
839 | kfree(ba->ba_1_org); | 890 | kfree(ba->ba_1_org); |
891 | nic->mac_control.stats_info->sw_stat.\ | ||
892 | mem_freed += (BUF1_LEN + ALIGN_SIZE); | ||
840 | k++; | 893 | k++; |
841 | } | 894 | } |
842 | kfree(mac_control->rings[i].ba[j]); | 895 | kfree(mac_control->rings[i].ba[j]); |
896 | nic->mac_control.stats_info->sw_stat.mem_freed += (sizeof(struct buffAdd) * | ||
897 | (rxd_count[nic->rxd_mode] + 1)); | ||
843 | } | 898 | } |
844 | kfree(mac_control->rings[i].ba); | 899 | kfree(mac_control->rings[i].ba); |
900 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
901 | (sizeof(struct buffAdd *) * blk_cnt); | ||
845 | } | 902 | } |
846 | } | 903 | } |
847 | 904 | ||
@@ -850,9 +907,14 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
850 | mac_control->stats_mem_sz, | 907 | mac_control->stats_mem_sz, |
851 | mac_control->stats_mem, | 908 | mac_control->stats_mem, |
852 | mac_control->stats_mem_phy); | 909 | mac_control->stats_mem_phy); |
910 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
911 | mac_control->stats_mem_sz; | ||
853 | } | 912 | } |
854 | if (nic->ufo_in_band_v) | 913 | if (nic->ufo_in_band_v) { |
855 | kfree(nic->ufo_in_band_v); | 914 | kfree(nic->ufo_in_band_v); |
915 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
916 | += (ufo_size * sizeof(u64)); | ||
917 | } | ||
856 | } | 918 | } |
857 | 919 | ||
858 | /** | 920 | /** |
@@ -2122,10 +2184,12 @@ static void free_tx_buffers(struct s2io_nic *nic) | |||
2122 | 2184 | ||
2123 | for (i = 0; i < config->tx_fifo_num; i++) { | 2185 | for (i = 0; i < config->tx_fifo_num; i++) { |
2124 | for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { | 2186 | for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { |
2125 | txdp = (struct TxD *) mac_control->fifos[i].list_info[j]. | 2187 | txdp = (struct TxD *) \ |
2126 | list_virt_addr; | 2188 | mac_control->fifos[i].list_info[j].list_virt_addr; |
2127 | skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); | 2189 | skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); |
2128 | if (skb) { | 2190 | if (skb) { |
2191 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
2192 | += skb->truesize; | ||
2129 | dev_kfree_skb(skb); | 2193 | dev_kfree_skb(skb); |
2130 | cnt++; | 2194 | cnt++; |
2131 | } | 2195 | } |
@@ -2186,11 +2250,14 @@ static int fill_rxd_3buf(struct s2io_nic *nic, struct RxD_t *rxdp, struct \ | |||
2186 | /* skb_shinfo(skb)->frag_list will have L4 data payload */ | 2250 | /* skb_shinfo(skb)->frag_list will have L4 data payload */ |
2187 | skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE); | 2251 | skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE); |
2188 | if (skb_shinfo(skb)->frag_list == NULL) { | 2252 | if (skb_shinfo(skb)->frag_list == NULL) { |
2253 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
2189 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name); | 2254 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name); |
2190 | return -ENOMEM ; | 2255 | return -ENOMEM ; |
2191 | } | 2256 | } |
2192 | frag_list = skb_shinfo(skb)->frag_list; | 2257 | frag_list = skb_shinfo(skb)->frag_list; |
2193 | skb->truesize += frag_list->truesize; | 2258 | skb->truesize += frag_list->truesize; |
2259 | nic->mac_control.stats_info->sw_stat.mem_allocated | ||
2260 | += frag_list->truesize; | ||
2194 | frag_list->next = NULL; | 2261 | frag_list->next = NULL; |
2195 | tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1); | 2262 | tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1); |
2196 | frag_list->data = tmp; | 2263 | frag_list->data = tmp; |
@@ -2319,8 +2386,12 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2319 | wmb(); | 2386 | wmb(); |
2320 | first_rxdp->Control_1 |= RXD_OWN_XENA; | 2387 | first_rxdp->Control_1 |= RXD_OWN_XENA; |
2321 | } | 2388 | } |
2389 | nic->mac_control.stats_info->sw_stat. \ | ||
2390 | mem_alloc_fail_cnt++; | ||
2322 | return -ENOMEM ; | 2391 | return -ENOMEM ; |
2323 | } | 2392 | } |
2393 | nic->mac_control.stats_info->sw_stat.mem_allocated | ||
2394 | += skb->truesize; | ||
2324 | if (nic->rxd_mode == RXD_MODE_1) { | 2395 | if (nic->rxd_mode == RXD_MODE_1) { |
2325 | /* 1 buffer mode - normal operation mode */ | 2396 | /* 1 buffer mode - normal operation mode */ |
2326 | memset(rxdp, 0, sizeof(struct RxD1)); | 2397 | memset(rxdp, 0, sizeof(struct RxD1)); |
@@ -2328,7 +2399,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2328 | ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single | 2399 | ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single |
2329 | (nic->pdev, skb->data, size - NET_IP_ALIGN, | 2400 | (nic->pdev, skb->data, size - NET_IP_ALIGN, |
2330 | PCI_DMA_FROMDEVICE); | 2401 | PCI_DMA_FROMDEVICE); |
2331 | rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); | 2402 | rxdp->Control_2 = |
2403 | SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); | ||
2332 | 2404 | ||
2333 | } else if (nic->rxd_mode >= RXD_MODE_3A) { | 2405 | } else if (nic->rxd_mode >= RXD_MODE_3A) { |
2334 | /* | 2406 | /* |
@@ -2342,7 +2414,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2342 | * payload | 2414 | * payload |
2343 | */ | 2415 | */ |
2344 | 2416 | ||
2345 | /* save the buffer pointers to avoid frequent dma mapping */ | 2417 | /* save buffer pointers to avoid frequent dma mapping */ |
2346 | Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; | 2418 | Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; |
2347 | Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; | 2419 | Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; |
2348 | memset(rxdp, 0, sizeof(struct RxD3)); | 2420 | memset(rxdp, 0, sizeof(struct RxD3)); |
@@ -2364,7 +2436,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2364 | PCI_DMA_FROMDEVICE); | 2436 | PCI_DMA_FROMDEVICE); |
2365 | else | 2437 | else |
2366 | pci_dma_sync_single_for_device(nic->pdev, | 2438 | pci_dma_sync_single_for_device(nic->pdev, |
2367 | (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, | 2439 | (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, |
2368 | BUF0_LEN, PCI_DMA_FROMDEVICE); | 2440 | BUF0_LEN, PCI_DMA_FROMDEVICE); |
2369 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); | 2441 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); |
2370 | if (nic->rxd_mode == RXD_MODE_3B) { | 2442 | if (nic->rxd_mode == RXD_MODE_3B) { |
@@ -2391,6 +2463,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2391 | } else { | 2463 | } else { |
2392 | /* 3 buffer mode */ | 2464 | /* 3 buffer mode */ |
2393 | if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) { | 2465 | if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) { |
2466 | nic->mac_control.stats_info->sw_stat.\ | ||
2467 | mem_freed += skb->truesize; | ||
2394 | dev_kfree_skb_irq(skb); | 2468 | dev_kfree_skb_irq(skb); |
2395 | if (first_rxdp) { | 2469 | if (first_rxdp) { |
2396 | wmb(); | 2470 | wmb(); |
@@ -2491,6 +2565,7 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk) | |||
2491 | PCI_DMA_FROMDEVICE); | 2565 | PCI_DMA_FROMDEVICE); |
2492 | memset(rxdp, 0, sizeof(struct RxD3)); | 2566 | memset(rxdp, 0, sizeof(struct RxD3)); |
2493 | } | 2567 | } |
2568 | sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; | ||
2494 | dev_kfree_skb(skb); | 2569 | dev_kfree_skb(skb); |
2495 | atomic_dec(&sp->rx_bufs_left[ring_no]); | 2570 | atomic_dec(&sp->rx_bufs_left[ring_no]); |
2496 | } | 2571 | } |
@@ -2820,13 +2895,35 @@ static void tx_intr_handler(struct fifo_info *fifo_data) | |||
2820 | nic->mac_control.stats_info->sw_stat. | 2895 | nic->mac_control.stats_info->sw_stat. |
2821 | parity_err_cnt++; | 2896 | parity_err_cnt++; |
2822 | } | 2897 | } |
2823 | if ((err >> 48) == 0xA) { | 2898 | |
2824 | DBG_PRINT(TX_DBG, "TxD returned due \ | 2899 | /* update t_code statistics */ |
2825 | to loss of link\n"); | 2900 | err >>= 48; |
2826 | } | 2901 | switch(err) { |
2827 | else { | 2902 | case 2: |
2828 | DBG_PRINT(ERR_DBG, "***TxD error %llx\n", err); | 2903 | nic->mac_control.stats_info->sw_stat. |
2829 | } | 2904 | tx_buf_abort_cnt++; |
2905 | break; | ||
2906 | |||
2907 | case 3: | ||
2908 | nic->mac_control.stats_info->sw_stat. | ||
2909 | tx_desc_abort_cnt++; | ||
2910 | break; | ||
2911 | |||
2912 | case 7: | ||
2913 | nic->mac_control.stats_info->sw_stat. | ||
2914 | tx_parity_err_cnt++; | ||
2915 | break; | ||
2916 | |||
2917 | case 10: | ||
2918 | nic->mac_control.stats_info->sw_stat. | ||
2919 | tx_link_loss_cnt++; | ||
2920 | break; | ||
2921 | |||
2922 | case 15: | ||
2923 | nic->mac_control.stats_info->sw_stat. | ||
2924 | tx_list_proc_err_cnt++; | ||
2925 | break; | ||
2926 | } | ||
2830 | } | 2927 | } |
2831 | 2928 | ||
2832 | skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); | 2929 | skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); |
@@ -2839,6 +2936,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data) | |||
2839 | 2936 | ||
2840 | /* Updating the statistics block */ | 2937 | /* Updating the statistics block */ |
2841 | nic->stats.tx_bytes += skb->len; | 2938 | nic->stats.tx_bytes += skb->len; |
2939 | nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; | ||
2842 | dev_kfree_skb_irq(skb); | 2940 | dev_kfree_skb_irq(skb); |
2843 | 2941 | ||
2844 | get_info.offset++; | 2942 | get_info.offset++; |
@@ -3314,7 +3412,9 @@ static void s2io_reset(struct s2io_nic * sp) | |||
3314 | u16 subid, pci_cmd; | 3412 | u16 subid, pci_cmd; |
3315 | int i; | 3413 | int i; |
3316 | u16 val16; | 3414 | u16 val16; |
3317 | unsigned long long reset_cnt = 0; | 3415 | unsigned long long up_cnt, down_cnt, up_time, down_time, reset_cnt; |
3416 | unsigned long long mem_alloc_cnt, mem_free_cnt, watchdog_cnt; | ||
3417 | |||
3318 | DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n", | 3418 | DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n", |
3319 | __FUNCTION__, sp->dev->name); | 3419 | __FUNCTION__, sp->dev->name); |
3320 | 3420 | ||
@@ -3380,11 +3480,26 @@ new_way: | |||
3380 | 3480 | ||
3381 | /* Reset device statistics maintained by OS */ | 3481 | /* Reset device statistics maintained by OS */ |
3382 | memset(&sp->stats, 0, sizeof (struct net_device_stats)); | 3482 | memset(&sp->stats, 0, sizeof (struct net_device_stats)); |
3383 | /* save reset count */ | 3483 | |
3484 | up_cnt = sp->mac_control.stats_info->sw_stat.link_up_cnt; | ||
3485 | down_cnt = sp->mac_control.stats_info->sw_stat.link_down_cnt; | ||
3486 | up_time = sp->mac_control.stats_info->sw_stat.link_up_time; | ||
3487 | down_time = sp->mac_control.stats_info->sw_stat.link_down_time; | ||
3384 | reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt; | 3488 | reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt; |
3489 | mem_alloc_cnt = sp->mac_control.stats_info->sw_stat.mem_allocated; | ||
3490 | mem_free_cnt = sp->mac_control.stats_info->sw_stat.mem_freed; | ||
3491 | watchdog_cnt = sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt; | ||
3492 | /* save link up/down time/cnt, reset/memory/watchdog cnt */ | ||
3385 | memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block)); | 3493 | memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block)); |
3386 | /* restore reset count */ | 3494 | /* restore link up/down time/cnt, reset/memory/watchdog cnt */ |
3495 | sp->mac_control.stats_info->sw_stat.link_up_cnt = up_cnt; | ||
3496 | sp->mac_control.stats_info->sw_stat.link_down_cnt = down_cnt; | ||
3497 | sp->mac_control.stats_info->sw_stat.link_up_time = up_time; | ||
3498 | sp->mac_control.stats_info->sw_stat.link_down_time = down_time; | ||
3387 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt; | 3499 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt; |
3500 | sp->mac_control.stats_info->sw_stat.mem_allocated = mem_alloc_cnt; | ||
3501 | sp->mac_control.stats_info->sw_stat.mem_freed = mem_free_cnt; | ||
3502 | sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt = watchdog_cnt; | ||
3388 | 3503 | ||
3389 | /* SXE-002: Configure link and activity LED to turn it off */ | 3504 | /* SXE-002: Configure link and activity LED to turn it off */ |
3390 | subid = sp->pdev->subsystem_device; | 3505 | subid = sp->pdev->subsystem_device; |
@@ -3672,19 +3787,29 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3672 | nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), | 3787 | nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), |
3673 | GFP_KERNEL); | 3788 | GFP_KERNEL); |
3674 | if (nic->entries == NULL) { | 3789 | if (nic->entries == NULL) { |
3675 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); | 3790 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \ |
3791 | __FUNCTION__); | ||
3792 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
3676 | return -ENOMEM; | 3793 | return -ENOMEM; |
3677 | } | 3794 | } |
3678 | memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | 3795 | nic->mac_control.stats_info->sw_stat.mem_allocated |
3796 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3797 | memset(nic->entries, 0,MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3679 | 3798 | ||
3680 | nic->s2io_entries = | 3799 | nic->s2io_entries = |
3681 | kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), | 3800 | kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), |
3682 | GFP_KERNEL); | 3801 | GFP_KERNEL); |
3683 | if (nic->s2io_entries == NULL) { | 3802 | if (nic->s2io_entries == NULL) { |
3684 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); | 3803 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", |
3804 | __FUNCTION__); | ||
3805 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
3685 | kfree(nic->entries); | 3806 | kfree(nic->entries); |
3807 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
3808 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3686 | return -ENOMEM; | 3809 | return -ENOMEM; |
3687 | } | 3810 | } |
3811 | nic->mac_control.stats_info->sw_stat.mem_allocated | ||
3812 | += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | ||
3688 | memset(nic->s2io_entries, 0, | 3813 | memset(nic->s2io_entries, 0, |
3689 | MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | 3814 | MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); |
3690 | 3815 | ||
@@ -3708,7 +3833,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3708 | rx_mat = readq(&bar0->rx_mat); | 3833 | rx_mat = readq(&bar0->rx_mat); |
3709 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { | 3834 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { |
3710 | rx_mat |= RX_MAT_SET(j, msix_indx); | 3835 | rx_mat |= RX_MAT_SET(j, msix_indx); |
3711 | nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; | 3836 | nic->s2io_entries[msix_indx].arg |
3837 | = &nic->mac_control.rings[j]; | ||
3712 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; | 3838 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; |
3713 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; | 3839 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; |
3714 | } | 3840 | } |
@@ -3717,7 +3843,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3717 | tx_mat = readq(&bar0->tx_mat0_n[7]); | 3843 | tx_mat = readq(&bar0->tx_mat0_n[7]); |
3718 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { | 3844 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { |
3719 | tx_mat |= TX_MAT_SET(i, msix_indx); | 3845 | tx_mat |= TX_MAT_SET(i, msix_indx); |
3720 | nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; | 3846 | nic->s2io_entries[msix_indx].arg |
3847 | = &nic->mac_control.rings[j]; | ||
3721 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; | 3848 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; |
3722 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; | 3849 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; |
3723 | } | 3850 | } |
@@ -3734,7 +3861,11 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3734 | if (ret) { | 3861 | if (ret) { |
3735 | DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); | 3862 | DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); |
3736 | kfree(nic->entries); | 3863 | kfree(nic->entries); |
3864 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
3865 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3737 | kfree(nic->s2io_entries); | 3866 | kfree(nic->s2io_entries); |
3867 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
3868 | += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | ||
3738 | nic->entries = NULL; | 3869 | nic->entries = NULL; |
3739 | nic->s2io_entries = NULL; | 3870 | nic->s2io_entries = NULL; |
3740 | nic->avail_msix_vectors = 0; | 3871 | nic->avail_msix_vectors = 0; |
@@ -3802,10 +3933,16 @@ static int s2io_open(struct net_device *dev) | |||
3802 | 3933 | ||
3803 | hw_init_failed: | 3934 | hw_init_failed: |
3804 | if (sp->intr_type == MSI_X) { | 3935 | if (sp->intr_type == MSI_X) { |
3805 | if (sp->entries) | 3936 | if (sp->entries) { |
3806 | kfree(sp->entries); | 3937 | kfree(sp->entries); |
3807 | if (sp->s2io_entries) | 3938 | sp->mac_control.stats_info->sw_stat.mem_freed |
3939 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3940 | } | ||
3941 | if (sp->s2io_entries) { | ||
3808 | kfree(sp->s2io_entries); | 3942 | kfree(sp->s2io_entries); |
3943 | sp->mac_control.stats_info->sw_stat.mem_freed | ||
3944 | += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | ||
3945 | } | ||
3809 | } | 3946 | } |
3810 | return err; | 3947 | return err; |
3811 | } | 3948 | } |
@@ -3866,6 +4003,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3866 | config = &sp->config; | 4003 | config = &sp->config; |
3867 | 4004 | ||
3868 | DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); | 4005 | DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); |
4006 | |||
4007 | if (unlikely(skb->len <= 0)) { | ||
4008 | DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); | ||
4009 | dev_kfree_skb_any(skb); | ||
4010 | return 0; | ||
4011 | } | ||
4012 | |||
3869 | spin_lock_irqsave(&sp->tx_lock, flags); | 4013 | spin_lock_irqsave(&sp->tx_lock, flags); |
3870 | if (atomic_read(&sp->card_state) == CARD_DOWN) { | 4014 | if (atomic_read(&sp->card_state) == CARD_DOWN) { |
3871 | DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", | 4015 | DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", |
@@ -3876,7 +4020,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3876 | } | 4020 | } |
3877 | 4021 | ||
3878 | queue = 0; | 4022 | queue = 0; |
3879 | |||
3880 | /* Get Fifo number to Transmit based on vlan priority */ | 4023 | /* Get Fifo number to Transmit based on vlan priority */ |
3881 | if (sp->vlgrp && vlan_tx_tag_present(skb)) { | 4024 | if (sp->vlgrp && vlan_tx_tag_present(skb)) { |
3882 | vlan_tag = vlan_tx_tag_get(skb); | 4025 | vlan_tag = vlan_tx_tag_get(skb); |
@@ -3900,14 +4043,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3900 | return 0; | 4043 | return 0; |
3901 | } | 4044 | } |
3902 | 4045 | ||
3903 | /* A buffer with no data will be dropped */ | ||
3904 | if (!skb->len) { | ||
3905 | DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); | ||
3906 | dev_kfree_skb(skb); | ||
3907 | spin_unlock_irqrestore(&sp->tx_lock, flags); | ||
3908 | return 0; | ||
3909 | } | ||
3910 | |||
3911 | offload_type = s2io_offload_type(skb); | 4046 | offload_type = s2io_offload_type(skb); |
3912 | if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { | 4047 | if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { |
3913 | txdp->Control_1 |= TXD_TCP_LSO_EN; | 4048 | txdp->Control_1 |= TXD_TCP_LSO_EN; |
@@ -4003,7 +4138,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4003 | put_off, get_off); | 4138 | put_off, get_off); |
4004 | netif_stop_queue(dev); | 4139 | netif_stop_queue(dev); |
4005 | } | 4140 | } |
4006 | 4141 | mac_control->stats_info->sw_stat.mem_allocated += skb->truesize; | |
4007 | dev->trans_start = jiffies; | 4142 | dev->trans_start = jiffies; |
4008 | spin_unlock_irqrestore(&sp->tx_lock, flags); | 4143 | spin_unlock_irqrestore(&sp->tx_lock, flags); |
4009 | 4144 | ||
@@ -4775,6 +4910,40 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data) | |||
4775 | return 0; | 4910 | return 0; |
4776 | } | 4911 | } |
4777 | 4912 | ||
4913 | static void s2io_ethtool_gringparam(struct net_device *dev, | ||
4914 | struct ethtool_ringparam *ering) | ||
4915 | { | ||
4916 | struct s2io_nic *sp = dev->priv; | ||
4917 | int i,tx_desc_count=0,rx_desc_count=0; | ||
4918 | |||
4919 | if (sp->rxd_mode == RXD_MODE_1) | ||
4920 | ering->rx_max_pending = MAX_RX_DESC_1; | ||
4921 | else if (sp->rxd_mode == RXD_MODE_3B) | ||
4922 | ering->rx_max_pending = MAX_RX_DESC_2; | ||
4923 | else if (sp->rxd_mode == RXD_MODE_3A) | ||
4924 | ering->rx_max_pending = MAX_RX_DESC_3; | ||
4925 | |||
4926 | ering->tx_max_pending = MAX_TX_DESC; | ||
4927 | for (i = 0 ; i < sp->config.tx_fifo_num ; i++) { | ||
4928 | tx_desc_count += sp->config.tx_cfg[i].fifo_len; | ||
4929 | } | ||
4930 | DBG_PRINT(INFO_DBG,"\nmax txds : %d\n",sp->config.max_txds); | ||
4931 | ering->tx_pending = tx_desc_count; | ||
4932 | rx_desc_count = 0; | ||
4933 | for (i = 0 ; i < sp->config.rx_ring_num ; i++) { | ||
4934 | rx_desc_count += sp->config.rx_cfg[i].num_rxd; | ||
4935 | } | ||
4936 | ering->rx_pending = rx_desc_count; | ||
4937 | |||
4938 | ering->rx_mini_max_pending = 0; | ||
4939 | ering->rx_mini_pending = 0; | ||
4940 | if(sp->rxd_mode == RXD_MODE_1) | ||
4941 | ering->rx_jumbo_max_pending = MAX_RX_DESC_1; | ||
4942 | else if (sp->rxd_mode == RXD_MODE_3B) | ||
4943 | ering->rx_jumbo_max_pending = MAX_RX_DESC_2; | ||
4944 | ering->rx_jumbo_pending = rx_desc_count; | ||
4945 | } | ||
4946 | |||
4778 | /** | 4947 | /** |
4779 | * s2io_ethtool_getpause_data -Pause frame frame generation and reception. | 4948 | * s2io_ethtool_getpause_data -Pause frame frame generation and reception. |
4780 | * @sp : private member of the device structure, which is a pointer to the | 4949 | * @sp : private member of the device structure, which is a pointer to the |
@@ -4981,8 +5150,11 @@ static void s2io_vpd_read(struct s2io_nic *nic) | |||
4981 | strcpy(nic->serial_num, "NOT AVAILABLE"); | 5150 | strcpy(nic->serial_num, "NOT AVAILABLE"); |
4982 | 5151 | ||
4983 | vpd_data = kmalloc(256, GFP_KERNEL); | 5152 | vpd_data = kmalloc(256, GFP_KERNEL); |
4984 | if (!vpd_data) | 5153 | if (!vpd_data) { |
5154 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
4985 | return; | 5155 | return; |
5156 | } | ||
5157 | nic->mac_control.stats_info->sw_stat.mem_allocated += 256; | ||
4986 | 5158 | ||
4987 | for (i = 0; i < 256; i +=4 ) { | 5159 | for (i = 0; i < 256; i +=4 ) { |
4988 | pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); | 5160 | pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); |
@@ -5022,6 +5194,7 @@ static void s2io_vpd_read(struct s2io_nic *nic) | |||
5022 | memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); | 5194 | memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); |
5023 | } | 5195 | } |
5024 | kfree(vpd_data); | 5196 | kfree(vpd_data); |
5197 | nic->mac_control.stats_info->sw_stat.mem_freed += 256; | ||
5025 | } | 5198 | } |
5026 | 5199 | ||
5027 | /** | 5200 | /** |
@@ -5742,6 +5915,30 @@ static void s2io_get_ethtool_stats(struct net_device *dev, | |||
5742 | } | 5915 | } |
5743 | else | 5916 | else |
5744 | tmp_stats[i++] = 0; | 5917 | tmp_stats[i++] = 0; |
5918 | tmp_stats[i++] = stat_info->sw_stat.mem_alloc_fail_cnt; | ||
5919 | tmp_stats[i++] = stat_info->sw_stat.watchdog_timer_cnt; | ||
5920 | tmp_stats[i++] = stat_info->sw_stat.mem_allocated; | ||
5921 | tmp_stats[i++] = stat_info->sw_stat.mem_freed; | ||
5922 | tmp_stats[i++] = stat_info->sw_stat.link_up_cnt; | ||
5923 | tmp_stats[i++] = stat_info->sw_stat.link_down_cnt; | ||
5924 | tmp_stats[i++] = stat_info->sw_stat.link_up_time; | ||
5925 | tmp_stats[i++] = stat_info->sw_stat.link_down_time; | ||
5926 | |||
5927 | tmp_stats[i++] = stat_info->sw_stat.tx_buf_abort_cnt; | ||
5928 | tmp_stats[i++] = stat_info->sw_stat.tx_desc_abort_cnt; | ||
5929 | tmp_stats[i++] = stat_info->sw_stat.tx_parity_err_cnt; | ||
5930 | tmp_stats[i++] = stat_info->sw_stat.tx_link_loss_cnt; | ||
5931 | tmp_stats[i++] = stat_info->sw_stat.tx_list_proc_err_cnt; | ||
5932 | |||
5933 | tmp_stats[i++] = stat_info->sw_stat.rx_parity_err_cnt; | ||
5934 | tmp_stats[i++] = stat_info->sw_stat.rx_abort_cnt; | ||
5935 | tmp_stats[i++] = stat_info->sw_stat.rx_parity_abort_cnt; | ||
5936 | tmp_stats[i++] = stat_info->sw_stat.rx_rda_fail_cnt; | ||
5937 | tmp_stats[i++] = stat_info->sw_stat.rx_unkn_prot_cnt; | ||
5938 | tmp_stats[i++] = stat_info->sw_stat.rx_fcs_err_cnt; | ||
5939 | tmp_stats[i++] = stat_info->sw_stat.rx_buf_size_err_cnt; | ||
5940 | tmp_stats[i++] = stat_info->sw_stat.rx_rxd_corrupt_cnt; | ||
5941 | tmp_stats[i++] = stat_info->sw_stat.rx_unkn_err_cnt; | ||
5745 | } | 5942 | } |
5746 | 5943 | ||
5747 | static int s2io_ethtool_get_regs_len(struct net_device *dev) | 5944 | static int s2io_ethtool_get_regs_len(struct net_device *dev) |
@@ -5854,6 +6051,7 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
5854 | .get_eeprom_len = s2io_get_eeprom_len, | 6051 | .get_eeprom_len = s2io_get_eeprom_len, |
5855 | .get_eeprom = s2io_ethtool_geeprom, | 6052 | .get_eeprom = s2io_ethtool_geeprom, |
5856 | .set_eeprom = s2io_ethtool_seeprom, | 6053 | .set_eeprom = s2io_ethtool_seeprom, |
6054 | .get_ringparam = s2io_ethtool_gringparam, | ||
5857 | .get_pauseparam = s2io_ethtool_getpause_data, | 6055 | .get_pauseparam = s2io_ethtool_getpause_data, |
5858 | .set_pauseparam = s2io_ethtool_setpause_data, | 6056 | .set_pauseparam = s2io_ethtool_setpause_data, |
5859 | .get_rx_csum = s2io_ethtool_get_rx_csum, | 6057 | .get_rx_csum = s2io_ethtool_get_rx_csum, |
@@ -5962,7 +6160,7 @@ static void s2io_tasklet(unsigned long dev_addr) | |||
5962 | if (ret == -ENOMEM) { | 6160 | if (ret == -ENOMEM) { |
5963 | DBG_PRINT(INFO_DBG, "%s: Out of ", | 6161 | DBG_PRINT(INFO_DBG, "%s: Out of ", |
5964 | dev->name); | 6162 | dev->name); |
5965 | DBG_PRINT(ERR_DBG, "memory in tasklet\n"); | 6163 | DBG_PRINT(INFO_DBG, "memory in tasklet\n"); |
5966 | break; | 6164 | break; |
5967 | } else if (ret == -EFILL) { | 6165 | } else if (ret == -EFILL) { |
5968 | DBG_PRINT(INFO_DBG, | 6166 | DBG_PRINT(INFO_DBG, |
@@ -6077,9 +6275,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6077 | *skb = dev_alloc_skb(size); | 6275 | *skb = dev_alloc_skb(size); |
6078 | if (!(*skb)) { | 6276 | if (!(*skb)) { |
6079 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); | 6277 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); |
6080 | DBG_PRINT(INFO_DBG, "memory to allocate SKBs\n"); | 6278 | DBG_PRINT(INFO_DBG, "memory to allocate "); |
6279 | DBG_PRINT(INFO_DBG, "1 buf mode SKBs\n"); | ||
6280 | sp->mac_control.stats_info->sw_stat. \ | ||
6281 | mem_alloc_fail_cnt++; | ||
6081 | return -ENOMEM ; | 6282 | return -ENOMEM ; |
6082 | } | 6283 | } |
6284 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6285 | += (*skb)->truesize; | ||
6083 | /* storing the mapped addr in a temp variable | 6286 | /* storing the mapped addr in a temp variable |
6084 | * such it will be used for next rxd whose | 6287 | * such it will be used for next rxd whose |
6085 | * Host Control is NULL | 6288 | * Host Control is NULL |
@@ -6099,10 +6302,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6099 | } else { | 6302 | } else { |
6100 | *skb = dev_alloc_skb(size); | 6303 | *skb = dev_alloc_skb(size); |
6101 | if (!(*skb)) { | 6304 | if (!(*skb)) { |
6102 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", | 6305 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); |
6103 | dev->name); | 6306 | DBG_PRINT(INFO_DBG, "memory to allocate "); |
6307 | DBG_PRINT(INFO_DBG, "2 buf mode SKBs\n"); | ||
6308 | sp->mac_control.stats_info->sw_stat. \ | ||
6309 | mem_alloc_fail_cnt++; | ||
6104 | return -ENOMEM; | 6310 | return -ENOMEM; |
6105 | } | 6311 | } |
6312 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6313 | += (*skb)->truesize; | ||
6106 | ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = | 6314 | ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = |
6107 | pci_map_single(sp->pdev, (*skb)->data, | 6315 | pci_map_single(sp->pdev, (*skb)->data, |
6108 | dev->mtu + 4, | 6316 | dev->mtu + 4, |
@@ -6126,10 +6334,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6126 | } else { | 6334 | } else { |
6127 | *skb = dev_alloc_skb(size); | 6335 | *skb = dev_alloc_skb(size); |
6128 | if (!(*skb)) { | 6336 | if (!(*skb)) { |
6129 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", | 6337 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); |
6130 | dev->name); | 6338 | DBG_PRINT(INFO_DBG, "memory to allocate "); |
6339 | DBG_PRINT(INFO_DBG, "3 buf mode SKBs\n"); | ||
6340 | sp->mac_control.stats_info->sw_stat. \ | ||
6341 | mem_alloc_fail_cnt++; | ||
6131 | return -ENOMEM; | 6342 | return -ENOMEM; |
6132 | } | 6343 | } |
6344 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6345 | += (*skb)->truesize; | ||
6133 | ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = | 6346 | ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = |
6134 | pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, | 6347 | pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, |
6135 | PCI_DMA_FROMDEVICE); | 6348 | PCI_DMA_FROMDEVICE); |
@@ -6147,10 +6360,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6147 | if (skb_shinfo(*skb)->frag_list == NULL) { | 6360 | if (skb_shinfo(*skb)->frag_list == NULL) { |
6148 | DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \ | 6361 | DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \ |
6149 | failed\n ", dev->name); | 6362 | failed\n ", dev->name); |
6363 | sp->mac_control.stats_info->sw_stat. \ | ||
6364 | mem_alloc_fail_cnt++; | ||
6150 | return -ENOMEM ; | 6365 | return -ENOMEM ; |
6151 | } | 6366 | } |
6152 | frag_list = skb_shinfo(*skb)->frag_list; | 6367 | frag_list = skb_shinfo(*skb)->frag_list; |
6153 | frag_list->next = NULL; | 6368 | frag_list->next = NULL; |
6369 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6370 | += frag_list->truesize; | ||
6154 | /* | 6371 | /* |
6155 | * Buffer-2 receives L4 data payload | 6372 | * Buffer-2 receives L4 data payload |
6156 | */ | 6373 | */ |
@@ -6566,6 +6783,7 @@ static void s2io_tx_watchdog(struct net_device *dev) | |||
6566 | struct s2io_nic *sp = dev->priv; | 6783 | struct s2io_nic *sp = dev->priv; |
6567 | 6784 | ||
6568 | if (netif_carrier_ok(dev)) { | 6785 | if (netif_carrier_ok(dev)) { |
6786 | sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt++; | ||
6569 | schedule_work(&sp->rst_timer_task); | 6787 | schedule_work(&sp->rst_timer_task); |
6570 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt++; | 6788 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt++; |
6571 | } | 6789 | } |
@@ -6606,7 +6824,53 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6606 | if (err & 0x1) { | 6824 | if (err & 0x1) { |
6607 | sp->mac_control.stats_info->sw_stat.parity_err_cnt++; | 6825 | sp->mac_control.stats_info->sw_stat.parity_err_cnt++; |
6608 | } | 6826 | } |
6827 | err >>= 48; | ||
6828 | switch(err) { | ||
6829 | case 1: | ||
6830 | sp->mac_control.stats_info->sw_stat. | ||
6831 | rx_parity_err_cnt++; | ||
6832 | break; | ||
6609 | 6833 | ||
6834 | case 2: | ||
6835 | sp->mac_control.stats_info->sw_stat. | ||
6836 | rx_abort_cnt++; | ||
6837 | break; | ||
6838 | |||
6839 | case 3: | ||
6840 | sp->mac_control.stats_info->sw_stat. | ||
6841 | rx_parity_abort_cnt++; | ||
6842 | break; | ||
6843 | |||
6844 | case 4: | ||
6845 | sp->mac_control.stats_info->sw_stat. | ||
6846 | rx_rda_fail_cnt++; | ||
6847 | break; | ||
6848 | |||
6849 | case 5: | ||
6850 | sp->mac_control.stats_info->sw_stat. | ||
6851 | rx_unkn_prot_cnt++; | ||
6852 | break; | ||
6853 | |||
6854 | case 6: | ||
6855 | sp->mac_control.stats_info->sw_stat. | ||
6856 | rx_fcs_err_cnt++; | ||
6857 | break; | ||
6858 | |||
6859 | case 7: | ||
6860 | sp->mac_control.stats_info->sw_stat. | ||
6861 | rx_buf_size_err_cnt++; | ||
6862 | break; | ||
6863 | |||
6864 | case 8: | ||
6865 | sp->mac_control.stats_info->sw_stat. | ||
6866 | rx_rxd_corrupt_cnt++; | ||
6867 | break; | ||
6868 | |||
6869 | case 15: | ||
6870 | sp->mac_control.stats_info->sw_stat. | ||
6871 | rx_unkn_err_cnt++; | ||
6872 | break; | ||
6873 | } | ||
6610 | /* | 6874 | /* |
6611 | * Drop the packet if bad transfer code. Exception being | 6875 | * Drop the packet if bad transfer code. Exception being |
6612 | * 0x5, which could be due to unsupported IPv6 extension header. | 6876 | * 0x5, which could be due to unsupported IPv6 extension header. |
@@ -6614,10 +6878,12 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6614 | * Note that in this case, since checksum will be incorrect, | 6878 | * Note that in this case, since checksum will be incorrect, |
6615 | * stack will validate the same. | 6879 | * stack will validate the same. |
6616 | */ | 6880 | */ |
6617 | if (err && ((err >> 48) != 0x5)) { | 6881 | if (err != 0x5) { |
6618 | DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", | 6882 | DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", |
6619 | dev->name, err); | 6883 | dev->name, err); |
6620 | sp->stats.rx_crc_errors++; | 6884 | sp->stats.rx_crc_errors++; |
6885 | sp->mac_control.stats_info->sw_stat.mem_freed | ||
6886 | += skb->truesize; | ||
6621 | dev_kfree_skb(skb); | 6887 | dev_kfree_skb(skb); |
6622 | atomic_dec(&sp->rx_bufs_left[ring_no]); | 6888 | atomic_dec(&sp->rx_bufs_left[ring_no]); |
6623 | rxdp->Host_Control = 0; | 6889 | rxdp->Host_Control = 0; |
@@ -6627,7 +6893,6 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6627 | 6893 | ||
6628 | /* Updating statistics */ | 6894 | /* Updating statistics */ |
6629 | rxdp->Host_Control = 0; | 6895 | rxdp->Host_Control = 0; |
6630 | sp->stats.rx_packets++; | ||
6631 | if (sp->rxd_mode == RXD_MODE_1) { | 6896 | if (sp->rxd_mode == RXD_MODE_1) { |
6632 | int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); | 6897 | int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); |
6633 | 6898 | ||
@@ -6731,7 +6996,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6731 | } else { | 6996 | } else { |
6732 | skb->ip_summed = CHECKSUM_NONE; | 6997 | skb->ip_summed = CHECKSUM_NONE; |
6733 | } | 6998 | } |
6734 | 6999 | sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; | |
6735 | if (!sp->lro) { | 7000 | if (!sp->lro) { |
6736 | skb->protocol = eth_type_trans(skb, dev); | 7001 | skb->protocol = eth_type_trans(skb, dev); |
6737 | if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) && | 7002 | if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) && |
@@ -6780,12 +7045,21 @@ static void s2io_link(struct s2io_nic * sp, int link) | |||
6780 | if (link == LINK_DOWN) { | 7045 | if (link == LINK_DOWN) { |
6781 | DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); | 7046 | DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); |
6782 | netif_carrier_off(dev); | 7047 | netif_carrier_off(dev); |
7048 | if(sp->mac_control.stats_info->sw_stat.link_up_cnt) | ||
7049 | sp->mac_control.stats_info->sw_stat.link_up_time = | ||
7050 | jiffies - sp->start_time; | ||
7051 | sp->mac_control.stats_info->sw_stat.link_down_cnt++; | ||
6783 | } else { | 7052 | } else { |
6784 | DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); | 7053 | DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); |
7054 | if (sp->mac_control.stats_info->sw_stat.link_down_cnt) | ||
7055 | sp->mac_control.stats_info->sw_stat.link_down_time = | ||
7056 | jiffies - sp->start_time; | ||
7057 | sp->mac_control.stats_info->sw_stat.link_up_cnt++; | ||
6785 | netif_carrier_on(dev); | 7058 | netif_carrier_on(dev); |
6786 | } | 7059 | } |
6787 | } | 7060 | } |
6788 | sp->last_link_state = link; | 7061 | sp->last_link_state = link; |
7062 | sp->start_time = jiffies; | ||
6789 | } | 7063 | } |
6790 | 7064 | ||
6791 | /** | 7065 | /** |
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h index a656d18b33df..54baa0b8ec7c 100644 --- a/drivers/net/s2io.h +++ b/drivers/net/s2io.h | |||
@@ -95,6 +95,32 @@ struct swStat { | |||
95 | unsigned long long flush_max_pkts; | 95 | unsigned long long flush_max_pkts; |
96 | unsigned long long sum_avg_pkts_aggregated; | 96 | unsigned long long sum_avg_pkts_aggregated; |
97 | unsigned long long num_aggregations; | 97 | unsigned long long num_aggregations; |
98 | /* Other statistics */ | ||
99 | unsigned long long mem_alloc_fail_cnt; | ||
100 | unsigned long long watchdog_timer_cnt; | ||
101 | unsigned long long mem_allocated; | ||
102 | unsigned long long mem_freed; | ||
103 | unsigned long long link_up_cnt; | ||
104 | unsigned long long link_down_cnt; | ||
105 | unsigned long long link_up_time; | ||
106 | unsigned long long link_down_time; | ||
107 | |||
108 | /* Transfer Code statistics */ | ||
109 | unsigned long long tx_buf_abort_cnt; | ||
110 | unsigned long long tx_desc_abort_cnt; | ||
111 | unsigned long long tx_parity_err_cnt; | ||
112 | unsigned long long tx_link_loss_cnt; | ||
113 | unsigned long long tx_list_proc_err_cnt; | ||
114 | |||
115 | unsigned long long rx_parity_err_cnt; | ||
116 | unsigned long long rx_abort_cnt; | ||
117 | unsigned long long rx_parity_abort_cnt; | ||
118 | unsigned long long rx_rda_fail_cnt; | ||
119 | unsigned long long rx_unkn_prot_cnt; | ||
120 | unsigned long long rx_fcs_err_cnt; | ||
121 | unsigned long long rx_buf_size_err_cnt; | ||
122 | unsigned long long rx_rxd_corrupt_cnt; | ||
123 | unsigned long long rx_unkn_err_cnt; | ||
98 | }; | 124 | }; |
99 | 125 | ||
100 | /* Xpak releated alarm and warnings */ | 126 | /* Xpak releated alarm and warnings */ |
@@ -308,6 +334,11 @@ struct stat_block { | |||
308 | #define MAX_TX_FIFOS 8 | 334 | #define MAX_TX_FIFOS 8 |
309 | #define MAX_RX_RINGS 8 | 335 | #define MAX_RX_RINGS 8 |
310 | 336 | ||
337 | #define MAX_RX_DESC_1 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 127 ) | ||
338 | #define MAX_RX_DESC_2 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 ) | ||
339 | #define MAX_RX_DESC_3 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 ) | ||
340 | #define MAX_TX_DESC (MAX_AVAILABLE_TXDS) | ||
341 | |||
311 | /* FIFO mappings for all possible number of fifos configured */ | 342 | /* FIFO mappings for all possible number of fifos configured */ |
312 | static int fifo_map[][MAX_TX_FIFOS] = { | 343 | static int fifo_map[][MAX_TX_FIFOS] = { |
313 | {0, 0, 0, 0, 0, 0, 0, 0}, | 344 | {0, 0, 0, 0, 0, 0, 0, 0}, |
@@ -819,6 +850,7 @@ struct s2io_nic { | |||
819 | #define LINK_UP 2 | 850 | #define LINK_UP 2 |
820 | 851 | ||
821 | int task_flag; | 852 | int task_flag; |
853 | unsigned long long start_time; | ||
822 | #define CARD_DOWN 1 | 854 | #define CARD_DOWN 1 |
823 | #define CARD_UP 2 | 855 | #define CARD_UP 2 |
824 | atomic_t card_state; | 856 | atomic_t card_state; |
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c index 1fc77300b055..2106becf6990 100644 --- a/drivers/net/sgiseeq.c +++ b/drivers/net/sgiseeq.c | |||
@@ -16,11 +16,13 @@ | |||
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/netdevice.h> | 18 | #include <linux/netdevice.h> |
19 | #include <linux/platform_device.h> | ||
19 | #include <linux/etherdevice.h> | 20 | #include <linux/etherdevice.h> |
20 | #include <linux/skbuff.h> | 21 | #include <linux/skbuff.h> |
21 | 22 | ||
22 | #include <asm/sgi/hpc3.h> | 23 | #include <asm/sgi/hpc3.h> |
23 | #include <asm/sgi/ip22.h> | 24 | #include <asm/sgi/ip22.h> |
25 | #include <asm/sgi/seeq.h> | ||
24 | 26 | ||
25 | #include "sgiseeq.h" | 27 | #include "sgiseeq.h" |
26 | 28 | ||
@@ -92,13 +94,9 @@ struct sgiseeq_private { | |||
92 | 94 | ||
93 | struct net_device_stats stats; | 95 | struct net_device_stats stats; |
94 | 96 | ||
95 | struct net_device *next_module; | ||
96 | spinlock_t tx_lock; | 97 | spinlock_t tx_lock; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | /* A list of all installed seeq devices, for removing the driver module. */ | ||
100 | static struct net_device *root_sgiseeq_dev; | ||
101 | |||
102 | static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) | 100 | static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) |
103 | { | 101 | { |
104 | hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ; | 102 | hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ; |
@@ -624,9 +622,12 @@ static inline void setup_rx_ring(struct sgiseeq_rx_desc *buf, int nbufs) | |||
624 | 622 | ||
625 | #define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) | 623 | #define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) |
626 | 624 | ||
627 | static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | 625 | static int __init sgiseeq_probe(struct platform_device *pdev) |
628 | { | 626 | { |
627 | struct sgiseeq_platform_data *pd = pdev->dev.platform_data; | ||
628 | struct hpc3_regs *hpcregs = pd->hpc; | ||
629 | struct sgiseeq_init_block *sr; | 629 | struct sgiseeq_init_block *sr; |
630 | unsigned int irq = pd->irq; | ||
630 | struct sgiseeq_private *sp; | 631 | struct sgiseeq_private *sp; |
631 | struct net_device *dev; | 632 | struct net_device *dev; |
632 | int err, i; | 633 | int err, i; |
@@ -637,6 +638,8 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | |||
637 | err = -ENOMEM; | 638 | err = -ENOMEM; |
638 | goto err_out; | 639 | goto err_out; |
639 | } | 640 | } |
641 | |||
642 | platform_set_drvdata(pdev, dev); | ||
640 | sp = netdev_priv(dev); | 643 | sp = netdev_priv(dev); |
641 | 644 | ||
642 | /* Make private data page aligned */ | 645 | /* Make private data page aligned */ |
@@ -648,15 +651,7 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | |||
648 | } | 651 | } |
649 | sp->srings = sr; | 652 | sp->srings = sr; |
650 | 653 | ||
651 | #define EADDR_NVOFS 250 | 654 | memcpy(dev->dev_addr, pd->mac, ETH_ALEN); |
652 | for (i = 0; i < 3; i++) { | ||
653 | unsigned short tmp = has_eeprom ? | ||
654 | ip22_eeprom_read(&hpcregs->eeprom, EADDR_NVOFS / 2+i) : | ||
655 | ip22_nvram_read(EADDR_NVOFS / 2+i); | ||
656 | |||
657 | dev->dev_addr[2 * i] = tmp >> 8; | ||
658 | dev->dev_addr[2 * i + 1] = tmp & 0xff; | ||
659 | } | ||
660 | 655 | ||
661 | #ifdef DEBUG | 656 | #ifdef DEBUG |
662 | gpriv = sp; | 657 | gpriv = sp; |
@@ -720,9 +715,6 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | |||
720 | for (i = 0; i < 6; i++) | 715 | for (i = 0; i < 6; i++) |
721 | printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); | 716 | printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); |
722 | 717 | ||
723 | sp->next_module = root_sgiseeq_dev; | ||
724 | root_sgiseeq_dev = dev; | ||
725 | |||
726 | return 0; | 718 | return 0; |
727 | 719 | ||
728 | err_out_free_page: | 720 | err_out_free_page: |
@@ -734,43 +726,42 @@ err_out: | |||
734 | return err; | 726 | return err; |
735 | } | 727 | } |
736 | 728 | ||
737 | static int __init sgiseeq_probe(void) | 729 | static void __exit sgiseeq_remove(struct platform_device *pdev) |
738 | { | 730 | { |
739 | unsigned int tmp, ret1, ret2 = 0; | 731 | struct net_device *dev = platform_get_drvdata(pdev); |
740 | 732 | struct sgiseeq_private *sp = netdev_priv(dev); | |
741 | /* On board adapter on 1st HPC is always present */ | ||
742 | ret1 = sgiseeq_init(hpc3c0, SGI_ENET_IRQ, 0); | ||
743 | /* Let's see if second HPC is there */ | ||
744 | if (!(ip22_is_fullhouse()) && | ||
745 | get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1]) == 0) { | ||
746 | sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | | ||
747 | SGIMC_GIOPAR_EXP164 | | ||
748 | SGIMC_GIOPAR_HPC264; | ||
749 | hpc3c1->pbus_piocfg[0][0] = 0x3ffff; | ||
750 | /* interrupt/config register on Challenge S Mezz board */ | ||
751 | hpc3c1->pbus_extregs[0][0] = 0x30; | ||
752 | ret2 = sgiseeq_init(hpc3c1, SGI_GIO_0_IRQ, 1); | ||
753 | } | ||
754 | 733 | ||
755 | return (ret1 & ret2) ? ret1 : 0; | 734 | unregister_netdev(dev); |
735 | free_page((unsigned long) sp->srings); | ||
736 | free_netdev(dev); | ||
737 | platform_set_drvdata(pdev, NULL); | ||
756 | } | 738 | } |
757 | 739 | ||
758 | static void __exit sgiseeq_exit(void) | 740 | static struct platform_driver sgiseeq_driver = { |
759 | { | 741 | .probe = sgiseeq_probe, |
760 | struct net_device *next, *dev; | 742 | .remove = __devexit_p(sgiseeq_remove), |
761 | struct sgiseeq_private *sp; | 743 | .driver = { |
744 | .name = "sgiseeq" | ||
745 | } | ||
746 | }; | ||
762 | 747 | ||
763 | for (dev = root_sgiseeq_dev; dev; dev = next) { | 748 | static int __init sgiseeq_module_init(void) |
764 | sp = (struct sgiseeq_private *) netdev_priv(dev); | 749 | { |
765 | next = sp->next_module; | 750 | if (platform_driver_register(&sgiseeq_driver)) { |
766 | unregister_netdev(dev); | 751 | printk(KERN_ERR "Driver registration failed\n"); |
767 | free_page((unsigned long) sp->srings); | 752 | return -ENODEV; |
768 | free_netdev(dev); | ||
769 | } | 753 | } |
754 | |||
755 | return 0; | ||
756 | } | ||
757 | |||
758 | static void __exit sgiseeq_module_exit(void) | ||
759 | { | ||
760 | platform_driver_unregister(&sgiseeq_driver); | ||
770 | } | 761 | } |
771 | 762 | ||
772 | module_init(sgiseeq_probe); | 763 | module_init(sgiseeq_module_init); |
773 | module_exit(sgiseeq_exit); | 764 | module_exit(sgiseeq_module_exit); |
774 | 765 | ||
775 | MODULE_DESCRIPTION("SGI Seeq 8003 driver"); | 766 | MODULE_DESCRIPTION("SGI Seeq 8003 driver"); |
776 | MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>"); | 767 | MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>"); |
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index e0489578945d..776692946562 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -3802,6 +3802,9 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3802 | struct skge_hw *hw = pci_get_drvdata(pdev); | 3802 | struct skge_hw *hw = pci_get_drvdata(pdev); |
3803 | int i, err, wol = 0; | 3803 | int i, err, wol = 0; |
3804 | 3804 | ||
3805 | if (!hw) | ||
3806 | return 0; | ||
3807 | |||
3805 | err = pci_save_state(pdev); | 3808 | err = pci_save_state(pdev); |
3806 | if (err) | 3809 | if (err) |
3807 | return err; | 3810 | return err; |
@@ -3830,6 +3833,9 @@ static int skge_resume(struct pci_dev *pdev) | |||
3830 | struct skge_hw *hw = pci_get_drvdata(pdev); | 3833 | struct skge_hw *hw = pci_get_drvdata(pdev); |
3831 | int i, err; | 3834 | int i, err; |
3832 | 3835 | ||
3836 | if (!hw) | ||
3837 | return 0; | ||
3838 | |||
3833 | err = pci_set_power_state(pdev, PCI_D0); | 3839 | err = pci_set_power_state(pdev, PCI_D0); |
3834 | if (err) | 3840 | if (err) |
3835 | goto out; | 3841 | goto out; |
@@ -3868,6 +3874,9 @@ static void skge_shutdown(struct pci_dev *pdev) | |||
3868 | struct skge_hw *hw = pci_get_drvdata(pdev); | 3874 | struct skge_hw *hw = pci_get_drvdata(pdev); |
3869 | int i, wol = 0; | 3875 | int i, wol = 0; |
3870 | 3876 | ||
3877 | if (!hw) | ||
3878 | return; | ||
3879 | |||
3871 | for (i = 0; i < hw->ports; i++) { | 3880 | for (i = 0; i < hw->ports; i++) { |
3872 | struct net_device *dev = hw->dev[i]; | 3881 | struct net_device *dev = hw->dev[i]; |
3873 | struct skge_port *skge = netdev_priv(dev); | 3882 | struct skge_port *skge = netdev_priv(dev); |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index a307310f13f5..104e20456e6f 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/if_vlan.h> | 40 | #include <linux/if_vlan.h> |
41 | #include <linux/prefetch.h> | 41 | #include <linux/prefetch.h> |
42 | #include <linux/mii.h> | 42 | #include <linux/mii.h> |
43 | #include <linux/dmi.h> | ||
43 | 44 | ||
44 | #include <asm/irq.h> | 45 | #include <asm/irq.h> |
45 | 46 | ||
@@ -130,7 +131,7 @@ static const struct pci_device_id sky2_id_table[] = { | |||
130 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ | 131 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ |
131 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ | 132 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ |
132 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ | 133 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ |
133 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ | 134 | // { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ |
134 | { 0 } | 135 | { 0 } |
135 | }; | 136 | }; |
136 | 137 | ||
@@ -150,6 +151,8 @@ static const char *yukon2_name[] = { | |||
150 | "FE", /* 0xb7 */ | 151 | "FE", /* 0xb7 */ |
151 | }; | 152 | }; |
152 | 153 | ||
154 | static int dmi_blacklisted; | ||
155 | |||
153 | /* Access to external PHY */ | 156 | /* Access to external PHY */ |
154 | static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) | 157 | static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) |
155 | { | 158 | { |
@@ -2531,6 +2534,17 @@ static int __devinit sky2_init(struct sky2_hw *hw) | |||
2531 | return -EOPNOTSUPP; | 2534 | return -EOPNOTSUPP; |
2532 | } | 2535 | } |
2533 | 2536 | ||
2537 | |||
2538 | /* Some Gigabyte motherboards have 88e8056 but cause problems | ||
2539 | * There is some unresolved hardware related problem that causes | ||
2540 | * descriptor errors and receive data corruption. | ||
2541 | */ | ||
2542 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && dmi_blacklisted) { | ||
2543 | dev_err(&hw->pdev->dev, | ||
2544 | "88E8056 on this motherboard not supported\n"); | ||
2545 | return -EOPNOTSUPP; | ||
2546 | } | ||
2547 | |||
2534 | hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); | 2548 | hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); |
2535 | hw->ports = 1; | 2549 | hw->ports = 1; |
2536 | t8 = sky2_read8(hw, B2_Y2_HW_RES); | 2550 | t8 = sky2_read8(hw, B2_Y2_HW_RES); |
@@ -3578,17 +3592,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3578 | goto err_out; | 3592 | goto err_out; |
3579 | } | 3593 | } |
3580 | 3594 | ||
3581 | /* Some Gigabyte motherboards have 88e8056 but cause problems | ||
3582 | * There is some unresolved hardware related problem that causes | ||
3583 | * descriptor errors and receive data corruption. | ||
3584 | */ | ||
3585 | if (pdev->vendor == PCI_VENDOR_ID_MARVELL && | ||
3586 | pdev->device == 0x4364 && pdev->subsystem_vendor == 0x1458) { | ||
3587 | dev_err(&pdev->dev, | ||
3588 | "88E8056 on Gigabyte motherboards not supported\n"); | ||
3589 | goto err_out_disable; | ||
3590 | } | ||
3591 | |||
3592 | err = pci_request_regions(pdev, DRV_NAME); | 3595 | err = pci_request_regions(pdev, DRV_NAME); |
3593 | if (err) { | 3596 | if (err) { |
3594 | dev_err(&pdev->dev, "cannot obtain PCI resources\n"); | 3597 | dev_err(&pdev->dev, "cannot obtain PCI resources\n"); |
@@ -3732,6 +3735,7 @@ err_out_free_regions: | |||
3732 | err_out_disable: | 3735 | err_out_disable: |
3733 | pci_disable_device(pdev); | 3736 | pci_disable_device(pdev); |
3734 | err_out: | 3737 | err_out: |
3738 | pci_set_drvdata(pdev, NULL); | ||
3735 | return err; | 3739 | return err; |
3736 | } | 3740 | } |
3737 | 3741 | ||
@@ -3784,6 +3788,9 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3784 | struct sky2_hw *hw = pci_get_drvdata(pdev); | 3788 | struct sky2_hw *hw = pci_get_drvdata(pdev); |
3785 | int i, wol = 0; | 3789 | int i, wol = 0; |
3786 | 3790 | ||
3791 | if (!hw) | ||
3792 | return 0; | ||
3793 | |||
3787 | del_timer_sync(&hw->idle_timer); | 3794 | del_timer_sync(&hw->idle_timer); |
3788 | netif_poll_disable(hw->dev[0]); | 3795 | netif_poll_disable(hw->dev[0]); |
3789 | 3796 | ||
@@ -3815,6 +3822,9 @@ static int sky2_resume(struct pci_dev *pdev) | |||
3815 | struct sky2_hw *hw = pci_get_drvdata(pdev); | 3822 | struct sky2_hw *hw = pci_get_drvdata(pdev); |
3816 | int i, err; | 3823 | int i, err; |
3817 | 3824 | ||
3825 | if (!hw) | ||
3826 | return 0; | ||
3827 | |||
3818 | err = pci_set_power_state(pdev, PCI_D0); | 3828 | err = pci_set_power_state(pdev, PCI_D0); |
3819 | if (err) | 3829 | if (err) |
3820 | goto out; | 3830 | goto out; |
@@ -3861,6 +3871,9 @@ static void sky2_shutdown(struct pci_dev *pdev) | |||
3861 | struct sky2_hw *hw = pci_get_drvdata(pdev); | 3871 | struct sky2_hw *hw = pci_get_drvdata(pdev); |
3862 | int i, wol = 0; | 3872 | int i, wol = 0; |
3863 | 3873 | ||
3874 | if (!hw) | ||
3875 | return; | ||
3876 | |||
3864 | del_timer_sync(&hw->idle_timer); | 3877 | del_timer_sync(&hw->idle_timer); |
3865 | netif_poll_disable(hw->dev[0]); | 3878 | netif_poll_disable(hw->dev[0]); |
3866 | 3879 | ||
@@ -3897,8 +3910,24 @@ static struct pci_driver sky2_driver = { | |||
3897 | .shutdown = sky2_shutdown, | 3910 | .shutdown = sky2_shutdown, |
3898 | }; | 3911 | }; |
3899 | 3912 | ||
3913 | static struct dmi_system_id __initdata broken_dmi_table[] = { | ||
3914 | { | ||
3915 | .ident = "Gigabyte 965P-S3", | ||
3916 | .matches = { | ||
3917 | DMI_MATCH(DMI_SYS_VENDOR, "Gigabyte Technology Co., Ltd."), | ||
3918 | DMI_MATCH(DMI_PRODUCT_NAME, "965P-S3"), | ||
3919 | |||
3920 | }, | ||
3921 | }, | ||
3922 | { } | ||
3923 | }; | ||
3924 | |||
3900 | static int __init sky2_init_module(void) | 3925 | static int __init sky2_init_module(void) |
3901 | { | 3926 | { |
3927 | /* Look for sick motherboards */ | ||
3928 | if (dmi_check_system(broken_dmi_table)) | ||
3929 | dmi_blacklisted = 1; | ||
3930 | |||
3902 | return pci_register_driver(&sky2_driver); | 3931 | return pci_register_driver(&sky2_driver); |
3903 | } | 3932 | } |
3904 | 3933 | ||
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index c15e97253ede..108adbf5b5eb 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -175,12 +175,10 @@ spider_net_setup_aneg(struct spider_net_card *card) | |||
175 | { | 175 | { |
176 | struct mii_phy *phy = &card->phy; | 176 | struct mii_phy *phy = &card->phy; |
177 | u32 advertise = 0; | 177 | u32 advertise = 0; |
178 | u16 bmcr, bmsr, stat1000, estat; | 178 | u16 bmsr, estat; |
179 | 179 | ||
180 | bmcr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMCR); | 180 | bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); |
181 | bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); | 181 | estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); |
182 | stat1000 = spider_net_read_phy(card->netdev, phy->mii_id, MII_STAT1000); | ||
183 | estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); | ||
184 | 182 | ||
185 | if (bmsr & BMSR_10HALF) | 183 | if (bmsr & BMSR_10HALF) |
186 | advertise |= ADVERTISED_10baseT_Half; | 184 | advertise |= ADVERTISED_10baseT_Half; |
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index 8897f538a7c7..4fc8681bc110 100644 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig | |||
@@ -2,10 +2,7 @@ | |||
2 | # wan devices configuration | 2 | # wan devices configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Wan interfaces" | 5 | menuconfig WAN |
6 | depends on NETDEVICES | ||
7 | |||
8 | config WAN | ||
9 | bool "Wan interfaces support" | 6 | bool "Wan interfaces support" |
10 | ---help--- | 7 | ---help--- |
11 | Wide Area Networks (WANs), such as X.25, Frame Relay and leased | 8 | Wide Area Networks (WANs), such as X.25, Frame Relay and leased |
@@ -23,10 +20,12 @@ config WAN | |||
23 | 20 | ||
24 | If unsure, say N. | 21 | If unsure, say N. |
25 | 22 | ||
23 | if WAN | ||
24 | |||
26 | # There is no way to detect a comtrol sv11 - force it modular for now. | 25 | # There is no way to detect a comtrol sv11 - force it modular for now. |
27 | config HOSTESS_SV11 | 26 | config HOSTESS_SV11 |
28 | tristate "Comtrol Hostess SV-11 support" | 27 | tristate "Comtrol Hostess SV-11 support" |
29 | depends on WAN && ISA && m && ISA_DMA_API && INET | 28 | depends on ISA && m && ISA_DMA_API && INET |
30 | help | 29 | help |
31 | Driver for Comtrol Hostess SV-11 network card which | 30 | Driver for Comtrol Hostess SV-11 network card which |
32 | operates on low speed synchronous serial links at up to | 31 | operates on low speed synchronous serial links at up to |
@@ -38,7 +37,7 @@ config HOSTESS_SV11 | |||
38 | # The COSA/SRP driver has not been tested as non-modular yet. | 37 | # The COSA/SRP driver has not been tested as non-modular yet. |
39 | config COSA | 38 | config COSA |
40 | tristate "COSA/SRP sync serial boards support" | 39 | tristate "COSA/SRP sync serial boards support" |
41 | depends on WAN && ISA && m && ISA_DMA_API | 40 | depends on ISA && m && ISA_DMA_API |
42 | ---help--- | 41 | ---help--- |
43 | Driver for COSA and SRP synchronous serial boards. | 42 | Driver for COSA and SRP synchronous serial boards. |
44 | 43 | ||
@@ -62,7 +61,7 @@ config COSA | |||
62 | # | 61 | # |
63 | config LANMEDIA | 62 | config LANMEDIA |
64 | tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" | 63 | tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" |
65 | depends on WAN && PCI | 64 | depends on PCI |
66 | ---help--- | 65 | ---help--- |
67 | Driver for the following Lan Media family of serial boards: | 66 | Driver for the following Lan Media family of serial boards: |
68 | 67 | ||
@@ -89,7 +88,7 @@ config LANMEDIA | |||
89 | # There is no way to detect a Sealevel board. Force it modular | 88 | # There is no way to detect a Sealevel board. Force it modular |
90 | config SEALEVEL_4021 | 89 | config SEALEVEL_4021 |
91 | tristate "Sealevel Systems 4021 support" | 90 | tristate "Sealevel Systems 4021 support" |
92 | depends on WAN && ISA && m && ISA_DMA_API && INET | 91 | depends on ISA && m && ISA_DMA_API && INET |
93 | help | 92 | help |
94 | This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. | 93 | This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. |
95 | 94 | ||
@@ -99,7 +98,6 @@ config SEALEVEL_4021 | |||
99 | # Generic HDLC | 98 | # Generic HDLC |
100 | config HDLC | 99 | config HDLC |
101 | tristate "Generic HDLC layer" | 100 | tristate "Generic HDLC layer" |
102 | depends on WAN | ||
103 | help | 101 | help |
104 | Say Y to this option if your Linux box contains a WAN (Wide Area | 102 | Say Y to this option if your Linux box contains a WAN (Wide Area |
105 | Network) card supported by this driver and you are planning to | 103 | Network) card supported by this driver and you are planning to |
@@ -167,7 +165,7 @@ config HDLC_X25 | |||
167 | If unsure, say N. | 165 | If unsure, say N. |
168 | 166 | ||
169 | comment "X.25/LAPB support is disabled" | 167 | comment "X.25/LAPB support is disabled" |
170 | depends on WAN && HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y | 168 | depends on HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y |
171 | 169 | ||
172 | config PCI200SYN | 170 | config PCI200SYN |
173 | tristate "Goramo PCI200SYN support" | 171 | tristate "Goramo PCI200SYN support" |
@@ -230,10 +228,10 @@ config PC300_MLPPP | |||
230 | Multilink PPP over the PC300 synchronous communication boards. | 228 | Multilink PPP over the PC300 synchronous communication boards. |
231 | 229 | ||
232 | comment "Cyclades-PC300 MLPPP support is disabled." | 230 | comment "Cyclades-PC300 MLPPP support is disabled." |
233 | depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) | 231 | depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) |
234 | 232 | ||
235 | comment "Refer to the file README.mlppp, provided by PC300 package." | 233 | comment "Refer to the file README.mlppp, provided by PC300 package." |
236 | depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) | 234 | depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) |
237 | 235 | ||
238 | config PC300TOO | 236 | config PC300TOO |
239 | tristate "Cyclades PC300 RSV/X21 alternative support" | 237 | tristate "Cyclades PC300 RSV/X21 alternative support" |
@@ -338,7 +336,6 @@ config DSCC4_PCI_RST | |||
338 | 336 | ||
339 | config DLCI | 337 | config DLCI |
340 | tristate "Frame Relay DLCI support" | 338 | tristate "Frame Relay DLCI support" |
341 | depends on WAN | ||
342 | ---help--- | 339 | ---help--- |
343 | Support for the Frame Relay protocol. | 340 | Support for the Frame Relay protocol. |
344 | 341 | ||
@@ -385,7 +382,7 @@ config SDLA | |||
385 | # Wan router core. | 382 | # Wan router core. |
386 | config WAN_ROUTER_DRIVERS | 383 | config WAN_ROUTER_DRIVERS |
387 | tristate "WAN router drivers" | 384 | tristate "WAN router drivers" |
388 | depends on WAN && WAN_ROUTER | 385 | depends on WAN_ROUTER |
389 | ---help--- | 386 | ---help--- |
390 | Connect LAN to WAN via Linux box. | 387 | Connect LAN to WAN via Linux box. |
391 | 388 | ||
@@ -440,7 +437,7 @@ config CYCLOMX_X25 | |||
440 | # X.25 network drivers | 437 | # X.25 network drivers |
441 | config LAPBETHER | 438 | config LAPBETHER |
442 | tristate "LAPB over Ethernet driver (EXPERIMENTAL)" | 439 | tristate "LAPB over Ethernet driver (EXPERIMENTAL)" |
443 | depends on WAN && LAPB && X25 | 440 | depends on LAPB && X25 |
444 | ---help--- | 441 | ---help--- |
445 | Driver for a pseudo device (typically called /dev/lapb0) which allows | 442 | Driver for a pseudo device (typically called /dev/lapb0) which allows |
446 | you to open an LAPB point-to-point connection to some other computer | 443 | you to open an LAPB point-to-point connection to some other computer |
@@ -456,7 +453,7 @@ config LAPBETHER | |||
456 | 453 | ||
457 | config X25_ASY | 454 | config X25_ASY |
458 | tristate "X.25 async driver (EXPERIMENTAL)" | 455 | tristate "X.25 async driver (EXPERIMENTAL)" |
459 | depends on WAN && LAPB && X25 | 456 | depends on LAPB && X25 |
460 | ---help--- | 457 | ---help--- |
461 | Send and receive X.25 frames over regular asynchronous serial | 458 | Send and receive X.25 frames over regular asynchronous serial |
462 | lines such as telephone lines equipped with ordinary modems. | 459 | lines such as telephone lines equipped with ordinary modems. |
@@ -471,7 +468,7 @@ config X25_ASY | |||
471 | 468 | ||
472 | config SBNI | 469 | config SBNI |
473 | tristate "Granch SBNI12 Leased Line adapter support" | 470 | tristate "Granch SBNI12 Leased Line adapter support" |
474 | depends on WAN && X86 | 471 | depends on X86 |
475 | ---help--- | 472 | ---help--- |
476 | Driver for ISA SBNI12-xx cards which are low cost alternatives to | 473 | Driver for ISA SBNI12-xx cards which are low cost alternatives to |
477 | leased line modems. | 474 | leased line modems. |
@@ -497,5 +494,4 @@ config SBNI_MULTILINE | |||
497 | 494 | ||
498 | If unsure, say N. | 495 | If unsure, say N. |
499 | 496 | ||
500 | endmenu | 497 | endif # WAN |
501 | |||
diff --git a/drivers/net/wireless/libertas/Makefile b/drivers/net/wireless/libertas/Makefile index 19c935071d8e..56a8ea1fbf04 100644 --- a/drivers/net/wireless/libertas/Makefile +++ b/drivers/net/wireless/libertas/Makefile | |||
@@ -1,5 +1,3 @@ | |||
1 | # EXTRA_CFLAGS += -Wpacked | ||
2 | |||
3 | usb8xxx-objs := main.o fw.o wext.o \ | 1 | usb8xxx-objs := main.o fw.o wext.o \ |
4 | rx.o tx.o cmd.o \ | 2 | rx.o tx.o cmd.o \ |
5 | cmdresp.o scan.o \ | 3 | cmdresp.o scan.o \ |
@@ -7,13 +5,6 @@ usb8xxx-objs := main.o fw.o wext.o \ | |||
7 | ioctl.o debugfs.o \ | 5 | ioctl.o debugfs.o \ |
8 | ethtool.o assoc.o | 6 | ethtool.o assoc.o |
9 | 7 | ||
10 | ifeq ($(CONFIG_LIBERTAS_USB_DEBUG), y) | ||
11 | EXTRA_CFLAGS += -DDEBUG -DPROC_DEBUG | ||
12 | endif | ||
13 | |||
14 | |||
15 | # This is needed to support the newer boot2 bootloader (v >= 3104) | ||
16 | EXTRA_CFLAGS += -DSUPPORT_BOOT_COMMAND | ||
17 | usb8xxx-objs += if_bootcmd.o | 8 | usb8xxx-objs += if_bootcmd.o |
18 | usb8xxx-objs += if_usb.o | 9 | usb8xxx-objs += if_usb.o |
19 | 10 | ||
diff --git a/drivers/net/wireless/libertas/README b/drivers/net/wireless/libertas/README index 688da4c784b1..378577200b56 100644 --- a/drivers/net/wireless/libertas/README +++ b/drivers/net/wireless/libertas/README | |||
@@ -40,64 +40,11 @@ NAME | |||
40 | SYNOPSIS | 40 | SYNOPSIS |
41 | iwpriv <ethX> <command> [sub-command] ... | 41 | iwpriv <ethX> <command> [sub-command] ... |
42 | 42 | ||
43 | iwpriv ethX version | ||
44 | iwpriv ethX scantype [sub-command] | ||
45 | iwpriv ethX getSNR <n> | ||
46 | iwpriv ethX getNF <n> | ||
47 | iwpriv ethX getRSSI <n> | ||
48 | iwpriv ethX setrxant <n> | ||
49 | iwpriv ethX getrxant | ||
50 | iwpriv ethX settxant <n> | ||
51 | iwpriv ethX gettxant | ||
52 | iwpriv ethX authalgs <n> | ||
53 | iwpriv ethX pre-TBTT <n> | ||
54 | iwpriv ethX 8021xauthalgs <n> | ||
55 | iwpriv ethX encryptionmode <n> | ||
56 | iwpriv ethX setregioncode <n> | 43 | iwpriv ethX setregioncode <n> |
57 | iwpriv ethX getregioncode | 44 | iwpriv ethX getregioncode |
58 | iwpriv ethX setbcnavg <n> | ||
59 | iwpriv ethX getbcnavg | ||
60 | iwpriv ethX setdataavg <n> | ||
61 | iwpriv ethX setlisteninter <n> | ||
62 | iwpriv ethX getlisteninter | ||
63 | iwpriv ethX setmultipledtim <n> | ||
64 | iwpriv ethX getmultipledtim | ||
65 | iwpriv ethX atimwindow <n> | ||
66 | iwpriv ethX deauth | ||
67 | iwpriv ethX adhocstop | ||
68 | iwpriv ethX radioon | ||
69 | iwpriv ethX radiooff | ||
70 | iwpriv ethX reasso-on | ||
71 | iwpriv ethX reasso-off | ||
72 | iwpriv ethX scanmode [sub-command] | ||
73 | iwpriv ethX setwpaie <n> | ||
74 | iwpriv ethX wlanidle-off | ||
75 | iwpriv ethX wlanidle-on | ||
76 | iwpriv ethX getcis | ||
77 | iwpriv ethX getlog | ||
78 | iwpriv ethX getadhocstatus | ||
79 | iwpriv ethX adhocgrate <n> | ||
80 | |||
81 | Version 4 Command: | ||
82 | iwpriv ethX inactvityto <n> | ||
83 | iwpriv ethX sleeppd <n> | ||
84 | iwpriv ethX enable11d <n> | ||
85 | iwpriv ethX tpccfg <n> | ||
86 | iwpriv ethX powercfg <n> | ||
87 | iwpriv ethX setafc <n> | ||
88 | iwpriv ethX getafc | ||
89 | 45 | ||
90 | Version 5 Command: | 46 | Version 5 Command: |
91 | iwpriv ethX ledgpio <n> | 47 | iwpriv ethX ledgpio <n> |
92 | iwpriv ethX scanprobes <n> | ||
93 | iwpriv ethX lolisteninter <n> | ||
94 | iwpriv ethX rateadapt <n> <m> | ||
95 | iwpriv ethX txcontrol <n> | ||
96 | iwpriv ethX psnullinterval <n> | ||
97 | iwpriv ethX prescan <n> | ||
98 | iwpriv ethX getrxinfo | ||
99 | iwpriv ethX gettxrate | ||
100 | iwpriv ethX beaconinterval | ||
101 | 48 | ||
102 | BT Commands: | 49 | BT Commands: |
103 | The blinding table (BT) contains a list of mac addresses that should be | 50 | The blinding table (BT) contains a list of mac addresses that should be |
@@ -150,114 +97,6 @@ DESCRIPTION | |||
150 | The ethX parameter specifies the network device that is to be used to | 97 | The ethX parameter specifies the network device that is to be used to |
151 | perform this command on. it could be eth0, eth1 etc. | 98 | perform this command on. it could be eth0, eth1 etc. |
152 | 99 | ||
153 | version | ||
154 | This is used to get the current version of the driver and the firmware. | ||
155 | |||
156 | scantype | ||
157 | This command is used to set the scan type to be used by the driver in | ||
158 | the scan command. This setting will not be used while performing a scan | ||
159 | for a specific SSID, as it is always done with scan type being active. | ||
160 | |||
161 | where the sub-commands are: - | ||
162 | active -- to set the scan type to active | ||
163 | passive -- to set the scan type to passive | ||
164 | get -- to get the scan type set in the driver | ||
165 | |||
166 | getSNR | ||
167 | This command gets the average and non average value of Signal to Noise | ||
168 | Ratio of Beacon and Data. | ||
169 | |||
170 | where value is:- | ||
171 | 0 -- Beacon non-average. | ||
172 | 1 -- Beacon average. | ||
173 | 2 -- Data non-average. | ||
174 | 3 -- Data average. | ||
175 | |||
176 | If no value is given, all four values are returned in the order mentioned | ||
177 | above. | ||
178 | |||
179 | Note: This command is available only when STA is connected. | ||
180 | |||
181 | getRSSI | ||
182 | This command gets the average and non average value os Receive Signal | ||
183 | Strength of Beacon and Data. | ||
184 | |||
185 | where value is:- | ||
186 | 0 -- Beacon non-average. | ||
187 | 1 -- Beacon average. | ||
188 | 2 -- Data non-average. | ||
189 | 3 -- Data average. | ||
190 | |||
191 | Note: This command is available only when STA is connected. | ||
192 | |||
193 | getNF | ||
194 | This command gets the average and non average value of Noise Floor of | ||
195 | Beacon and Data. | ||
196 | |||
197 | where value is:- | ||
198 | 0 -- Beacon non-average. | ||
199 | 1 -- Beacon average. | ||
200 | 2 -- Data non-average. | ||
201 | 3 -- Data average. | ||
202 | |||
203 | Note: This command is available only when STA is connected. | ||
204 | |||
205 | setrxant | ||
206 | This command is used to set the mode for Rx antenna. | ||
207 | |||
208 | The options that can be sent are:- | ||
209 | 1 -- Antenna 1. | ||
210 | 2 -- Antenna 2. | ||
211 | 0xFFFF -- Diversity. | ||
212 | |||
213 | Usage: | ||
214 | iwpriv ethX setrxant 0x01: select Antenna 1. | ||
215 | |||
216 | getrxant | ||
217 | This command is used to get the mode for Rx antenna. | ||
218 | |||
219 | |||
220 | settxant | ||
221 | This command is used to set the mode for Tx antenna. | ||
222 | The options that can be sent are:- | ||
223 | 1 -- Antenna 1. | ||
224 | 2 -- Antenna 2. | ||
225 | 0xFFFF -- Diversity. | ||
226 | Usage: | ||
227 | iwpriv ethX settxant 0x01: select Antenna 1. | ||
228 | |||
229 | gettxant | ||
230 | This command is used to get the mode for Tx antenna. | ||
231 | |||
232 | authalgs | ||
233 | This command is used by the WPA supplicant to set the authentication | ||
234 | algorithms in the station. | ||
235 | |||
236 | 8021xauthalgs | ||
237 | This command is used by the WPA supplicant to set the 8021.x authentication algorithm type | ||
238 | station. | ||
239 | |||
240 | where values can be:- | ||
241 | 1 -- None | ||
242 | 2 -- LEAP | ||
243 | 4 -- TLS | ||
244 | 8 -- TTLs | ||
245 | 16 -- MD5 | ||
246 | |||
247 | |||
248 | encryptionmode | ||
249 | This command is used by the WPA supplicant to set the encryption algorithm. | ||
250 | |||
251 | where values can be:- | ||
252 | 0 -- NONE | ||
253 | 1 -- WEP40 | ||
254 | 2 -- TKIP | ||
255 | 3 -- CCMP | ||
256 | 4 -- WEP104 | ||
257 | |||
258 | pre-TBTT | ||
259 | This command is used to set pre-TBTT time period where value is in microseconds. | ||
260 | |||
261 | setregioncode | 100 | setregioncode |
262 | This command is used to set the region code in the station. | 101 | This command is used to set the region code in the station. |
263 | where value is 'region code' for various regions like | 102 | where value is 'region code' for various regions like |
@@ -270,114 +109,6 @@ getregioncode | |||
270 | This command is used to get the region code information set in the | 109 | This command is used to get the region code information set in the |
271 | station. | 110 | station. |
272 | 111 | ||
273 | setbcnavg | ||
274 | Set the weighting factor for calculating RSSI. | ||
275 | |||
276 | getbcnavg | ||
277 | Get weighting factor for calculating RSSI. | ||
278 | |||
279 | setdataavg | ||
280 | Set the weighting factor for calculating SNR. | ||
281 | |||
282 | setlisteninter | ||
283 | This command is used to set the listen interval in the | ||
284 | station. | ||
285 | |||
286 | where the value ranges between 1 - 255 | ||
287 | |||
288 | getlisteninter | ||
289 | This command is used to get the listen interval value set in the | ||
290 | station. | ||
291 | |||
292 | setmultipledtim | ||
293 | This command is used to set the multiple dtim value in the | ||
294 | station. | ||
295 | where the value is 1,2,3,4,5,0xfffe | ||
296 | 0xfffe means the firmware will use listen interval in association | ||
297 | command for waking up | ||
298 | |||
299 | getmultipledtim | ||
300 | This command is used to get the multiple dtim value set in the station. | ||
301 | |||
302 | atimwindow | ||
303 | This command is used to set the atim value in the | ||
304 | station. | ||
305 | |||
306 | where the value ranges between 0 - 50 | ||
307 | |||
308 | deauth | ||
309 | This command is used to send the de-authentication to the AP with which | ||
310 | the station is associated. This command is valid only when | ||
311 | station is in Infrastructure mode. | ||
312 | |||
313 | Note: This command is available only when STA is connected. | ||
314 | |||
315 | adhocstop | ||
316 | This command is used to stop beacon transmission from the station and | ||
317 | go into idle state in ad-hoc mode. | ||
318 | |||
319 | Note: This command is available only when STA is connected. | ||
320 | |||
321 | radioon | ||
322 | This command is used to turn on the RF antenna. | ||
323 | |||
324 | radiooff | ||
325 | This command is sued to turn off the RF antenna. | ||
326 | |||
327 | scanmode | ||
328 | This command is used to set the station to scan for either IBSS | ||
329 | networks or BSS networks or both BSS and IBSS networks. This | ||
330 | command can be used with sub commands, | ||
331 | |||
332 | where the value for | ||
333 | bss -- Scan All the BSS networks. | ||
334 | ibss -- Scan All the IBSS networks. | ||
335 | any -- Scan both BSS and IBSS networks. | ||
336 | |||
337 | |||
338 | |||
339 | setwpaie | ||
340 | This command is used by WPA supplicant to send the WPA-IE to the driver. | ||
341 | |||
342 | wlanidle-off | ||
343 | This command is used to get into idle state. | ||
344 | |||
345 | Note: This command is available only when STA is connected. | ||
346 | |||
347 | wlanidle-on | ||
348 | This command is used to get off the idle state. | ||
349 | |||
350 | Note: This command is available only when STA is connected. | ||
351 | |||
352 | |||
353 | getlog | ||
354 | This command is used to get the 802.11 statistics available in the | ||
355 | station. | ||
356 | |||
357 | Note: This command is available only when STA is connected. | ||
358 | |||
359 | getadhocstatus | ||
360 | This command is used to get the ad-hoc Network Status. | ||
361 | |||
362 | The various status codes are: | ||
363 | AdhocStarted | ||
364 | AdhocJoined | ||
365 | AdhocIdle | ||
366 | InfraMode | ||
367 | AutoUnknownMode | ||
368 | |||
369 | Note: This command is available only when STA is connected. | ||
370 | |||
371 | adhocgrate | ||
372 | This command is used to enable(1) g_rate, Disable(0) g_rate | ||
373 | and request(2) the status which g_rate is disabled/enabled, | ||
374 | for Ad-hoc creator. | ||
375 | |||
376 | where value is:- | ||
377 | 0 -- Disabled | ||
378 | 1 -- Enabled | ||
379 | 2 -- Get | ||
380 | |||
381 | ledgpio | 112 | ledgpio |
382 | This command is used to set/get LEDs. | 113 | This command is used to set/get LEDs. |
383 | 114 | ||
@@ -400,253 +131,6 @@ ledgpio | |||
400 | Note: LED0 is invalid | 131 | Note: LED0 is invalid |
401 | Note: Maximum Number of LEDs are 16. | 132 | Note: Maximum Number of LEDs are 16. |
402 | 133 | ||
403 | inactivityto | ||
404 | This command is used by the host to set/get the inactivity timeout value, | ||
405 | which specifies when WLAN device is put to sleep. | ||
406 | |||
407 | Usage: | ||
408 | iwpriv ethX inactivityto [<timeout>] | ||
409 | |||
410 | where the parameter are: | ||
411 | timeout: timeout value in milliseconds. | ||
412 | |||
413 | Example: | ||
414 | iwpriv eth1 inactivityto | ||
415 | "get the timeout value" | ||
416 | |||
417 | iwpriv eth1 inactivityto X | ||
418 | "set timeout value to X ms" | ||
419 | |||
420 | |||
421 | sleeppd | ||
422 | This command is used to configure the sleep period of the WLAN device. | ||
423 | |||
424 | Usage: | ||
425 | iwpriv ethX sleeppd [<sleep period>] | ||
426 | |||
427 | where the parameter are: | ||
428 | Period: sleep period in milliseconds. Range 10~60. | ||
429 | |||
430 | Example: | ||
431 | iwpriv eth1 sleeppd 10 | ||
432 | "set period as 10 ms" | ||
433 | iwpriv eth1 sleeppd | ||
434 | "get the sleep period configuration" | ||
435 | |||
436 | enable11d | ||
437 | This command is used to control 11d | ||
438 | where value is:- | ||
439 | 1 -- Enabled | ||
440 | 0 -- Disabled | ||
441 | 2 -- Get | ||
442 | |||
443 | |||
444 | |||
445 | |||
446 | tpccfg | ||
447 | Enables or disables automatic transmit power control. | ||
448 | |||
449 | The first parameter turns this feature on (1) or off (0). When turning | ||
450 | on, the user must also supply four more parameters in the following | ||
451 | order: | ||
452 | -UseSNR (Use SNR (in addition to PER) for TPC algorithm), | ||
453 | -P0 (P0 power level for TPC), | ||
454 | -P1 (P1 power level for TPC), | ||
455 | -P2 (P2 power level for TPC). | ||
456 | |||
457 | Usage: | ||
458 | iwpriv ethX tpccfg: Get current configuration | ||
459 | iwpriv ethX tpccfg 0: disable auto TPC | ||
460 | iwpriv ethX tpccfg 0x01 0x00 0x05 0x0a 0x0d: enable auto TPC; do not use SNR; | ||
461 | P0=0x05; P1=0x0a; P2=0x0d; | ||
462 | iwpriv ethX tpccfg 0x01 0x01 0x05 0x0a 0x0d: enable auto TPC; use SNR; | ||
463 | P0=0x05; P1=0x0a; P2=0x0d. | ||
464 | |||
465 | powercfg | ||
466 | Enables or disables power adaptation. | ||
467 | |||
468 | The first parameter turns this feature on (1) or off (0). When turning | ||
469 | on, the user must also supply three more parameters in the following | ||
470 | order: | ||
471 | -P0 (P0 power level for Power Adaptation), | ||
472 | -P1 (P1 power level for Power Adaptation), | ||
473 | -P2 (P2 power level for Power Adaptation). | ||
474 | |||
475 | Usage: | ||
476 | iwpriv ethX powercfg: Get current configuration | ||
477 | iwpriv ethX powercfg 0: disable power adaptation | ||
478 | iwpriv ethX powercfg 1 0x0d 0x0f 0x12: enable power adaptation; | ||
479 | P0=0x0d; P1=0x0f; P2=0x12. | ||
480 | |||
481 | getafc | ||
482 | This command returns automatic frequency control parameters. It returns | ||
483 | three integers: | ||
484 | -P0: automatic is on (1), or off (0), | ||
485 | -P1: current timing offset in PPM (part per million), and | ||
486 | -P2: current frequency offset in PPM. | ||
487 | |||
488 | setafc | ||
489 | Set automatic frequency control options. | ||
490 | |||
491 | The first parameter turns automatic on (1) or off (0). | ||
492 | The user must supply two more parameters in either case, in the following | ||
493 | order: | ||
494 | |||
495 | When auto is on: | ||
496 | |||
497 | -P0 (automatic adjustment frequency threshold in PPM), | ||
498 | -P1 (automatic adjustment period in beacon period), | ||
499 | |||
500 | When auto is off: | ||
501 | |||
502 | -P0 (manual adjustment timing offset in PPM), and | ||
503 | -P1 (manual adjustment frequency offset in PPM). | ||
504 | |||
505 | Usage: | ||
506 | iwpriv ethX setafc 0 10 10: manual adjustment, both timing and frequcncy | ||
507 | offset are 10 PPM. | ||
508 | |||
509 | iwpriv ethX setafc 1 10 10 enable afc, automatic adjustment, | ||
510 | frequency threshold 10 PPM, for every 10 beacon periods. | ||
511 | |||
512 | |||
513 | |||
514 | scanprobes | ||
515 | This command sets number of probe requests per channel. | ||
516 | |||
517 | Usage: | ||
518 | iwpriv ethX scanprobes 3 (set scan probes to 3) | ||
519 | iwpriv ethX scanprobes (get scan probes) | ||
520 | |||
521 | lolisteninter | ||
522 | This command sets the value of listen interval. | ||
523 | |||
524 | Usage: | ||
525 | iwpriv ethX lolisteninter 234 (set the lolisteninter to 234) | ||
526 | iwpriv ethX lolisteninter (get the lolisteninter value) | ||
527 | |||
528 | rateadapt | ||
529 | This command sets the data rates bitmap. | ||
530 | Where <n> | ||
531 | 0: Disable auto rate adapt | ||
532 | 1: Enable auto rate adapt | ||
533 | |||
534 | <m> | ||
535 | data rate bitmap | ||
536 | Bit Data rate | ||
537 | 0 1 Mbps | ||
538 | 1 2 Mbps | ||
539 | 2 5.5 Mbps | ||
540 | 3 11 Mbps | ||
541 | 4 Reserved | ||
542 | 5 6 Mbps | ||
543 | 6 9 Mbps | ||
544 | 7 12 Mbps | ||
545 | 8 18 Mbps | ||
546 | 9 24 Mbps | ||
547 | 10 36 Mbps | ||
548 | 11 48 Mbps | ||
549 | 12 54 Mbps | ||
550 | 12-15 Reserved | ||
551 | |||
552 | Usage: | ||
553 | iwpriv ethX rateadapt | ||
554 | read the currect data rate setting | ||
555 | iwpriv ethX rateadapt 1 0x07 | ||
556 | enable auto data rate adapt and | ||
557 | data rates are 1Mbps, 2Mbsp and 5.5Mbps | ||
558 | |||
559 | |||
560 | txcontrol | ||
561 | This command is used to set the Tx rate, ack policy, and retry limit on a per packet basis. | ||
562 | |||
563 | Where value <n> is: | ||
564 | if bit[4] == 1: | ||
565 | bit[3:0] -- 0 1 2 3 4 5 6 7 8 9 10 11 12 13-16 | ||
566 | Data Rate(Mbps) -- 1 2 5.5 11 Rsv 6 9 12 18 24 36 48 54 Rsv | ||
567 | |||
568 | bit[12:8] | ||
569 | if bit[12] == 1, bit[11:8] specifies the Tx retry limit. | ||
570 | |||
571 | bit[14:13] specifies per packet ack policy: | ||
572 | bit[14:13] | ||
573 | 1 0 use immediate ack policy for this packet | ||
574 | 1 1 use no ack policy for this packet | ||
575 | 0 x use the per-packet ack policy setting | ||
576 | |||
577 | Usage: | ||
578 | iwpriv ethX txcontrol 0x7513 | ||
579 | Use no-ack policy, 5 retires for Tx, 11Mbps rate | ||
580 | |||
581 | |||
582 | |||
583 | psnullinterval | ||
584 | This command is used to set/request NULL package interval for Power Save | ||
585 | under infrastructure mode. | ||
586 | |||
587 | where value is:- | ||
588 | -1 -- Disabled | ||
589 | n>0 -- Set interval as n (seconds) | ||
590 | |||
591 | prescan | ||
592 | This command is used to enable (1)/disable(0) auto prescan before assoicate to the ap | ||
593 | |||
594 | where value is:- | ||
595 | 0 -- Disabled | ||
596 | 1 -- Enabled | ||
597 | 2 -- Get | ||
598 | |||
599 | getrxinfo | ||
600 | This command gets non average value of Signal to Noise Ratio of Data and rate index. | ||
601 | |||
602 | The following table shows RateIndex and Rate | ||
603 | |||
604 | RateIndex Data rate | ||
605 | 0 1 Mbps | ||
606 | 1 2 Mbps | ||
607 | 2 5.5 Mbps | ||
608 | 3 11 Mbps | ||
609 | 4 Reserved | ||
610 | 5 6 Mbps | ||
611 | 6 9 Mbps | ||
612 | 7 12 Mbps | ||
613 | 8 18 Mbps | ||
614 | 9 24 Mbps | ||
615 | 10 36 Mbps | ||
616 | 11 48 Mbps | ||
617 | 12 54 Mbps | ||
618 | 13-15 Reserved | ||
619 | |||
620 | gettxrate | ||
621 | This command gets current Tx rate index of the first packet associated with Rate Adaptation. | ||
622 | |||
623 | The following table shows RateIndex and Rate | ||
624 | |||
625 | RateIndex Data rate | ||
626 | 0 1 Mbps | ||
627 | 1 2 Mbps | ||
628 | 2 5.5 Mbps | ||
629 | 3 11 Mbps | ||
630 | 4 Reserved | ||
631 | 5 6 Mbps | ||
632 | 6 9 Mbps | ||
633 | 7 12 Mbps | ||
634 | 8 18 Mbps | ||
635 | 9 24 Mbps | ||
636 | 10 36 Mbps | ||
637 | 11 48 Mbps | ||
638 | 12 54 Mbps | ||
639 | 13-15 Reserved | ||
640 | |||
641 | bcninterval | ||
642 | This command is used to sets beacon interval in adhoc mode when an argument is given, and gets current adhoc | ||
643 | beacon interval when no argument is given. The valid beacon interval is between 20 - 1000, | ||
644 | default beacon interval is 100. | ||
645 | |||
646 | Usage: | ||
647 | iwpriv ethX bcninterval 100 (set adhoc beacon interval to 100) | ||
648 | iwpriv ethX bcninterval (get adhoc beacon interval) | ||
649 | |||
650 | fwt_add | 134 | fwt_add |
651 | This command is used to insert an entry into the FWT table. The list of | 135 | This command is used to insert an entry into the FWT table. The list of |
652 | parameters must follow the following structure: | 136 | parameters must follow the following structure: |
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c index b55c7f57aca8..c260bd1b3d46 100644 --- a/drivers/net/wireless/libertas/assoc.c +++ b/drivers/net/wireless/libertas/assoc.c | |||
@@ -23,13 +23,13 @@ static int assoc_helper_essid(wlan_private *priv, | |||
23 | ENTER(); | 23 | ENTER(); |
24 | 24 | ||
25 | lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); | 25 | lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); |
26 | if (assoc_req->mode == wlan802_11infrastructure) { | 26 | if (assoc_req->mode == IW_MODE_INFRA) { |
27 | if (adapter->prescan) { | 27 | if (adapter->prescan) { |
28 | libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); | 28 | libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); |
29 | } | 29 | } |
30 | 30 | ||
31 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, | 31 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, |
32 | NULL, wlan802_11infrastructure); | 32 | NULL, IW_MODE_INFRA); |
33 | if (i >= 0) { | 33 | if (i >= 0) { |
34 | lbs_pr_debug(1, | 34 | lbs_pr_debug(1, |
35 | "SSID found in scan list ... associating...\n"); | 35 | "SSID found in scan list ... associating...\n"); |
@@ -44,7 +44,7 @@ static int assoc_helper_essid(wlan_private *priv, | |||
44 | lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", | 44 | lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", |
45 | assoc_req->ssid.ssid); | 45 | assoc_req->ssid.ssid); |
46 | } | 46 | } |
47 | } else if (assoc_req->mode == wlan802_11ibss) { | 47 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
48 | /* Scan for the network, do not save previous results. Stale | 48 | /* Scan for the network, do not save previous results. Stale |
49 | * scan data will cause us to join a non-existant adhoc network | 49 | * scan data will cause us to join a non-existant adhoc network |
50 | */ | 50 | */ |
@@ -52,7 +52,7 @@ static int assoc_helper_essid(wlan_private *priv, | |||
52 | 52 | ||
53 | /* Search for the requested SSID in the scan table */ | 53 | /* Search for the requested SSID in the scan table */ |
54 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, | 54 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, |
55 | wlan802_11ibss); | 55 | IW_MODE_ADHOC); |
56 | if (i >= 0) { | 56 | if (i >= 0) { |
57 | lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); | 57 | lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); |
58 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); | 58 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); |
@@ -90,10 +90,10 @@ static int assoc_helper_bssid(wlan_private *priv, | |||
90 | goto out; | 90 | goto out; |
91 | } | 91 | } |
92 | 92 | ||
93 | if (assoc_req->mode == wlan802_11infrastructure) { | 93 | if (assoc_req->mode == IW_MODE_INFRA) { |
94 | ret = wlan_associate(priv, &adapter->scantable[i]); | 94 | ret = wlan_associate(priv, &adapter->scantable[i]); |
95 | lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); | 95 | lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); |
96 | } else if (assoc_req->mode == wlan802_11ibss) { | 96 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
97 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); | 97 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); |
98 | } | 98 | } |
99 | memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, | 99 | memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, |
@@ -142,23 +142,23 @@ static int assoc_helper_mode(wlan_private *priv, | |||
142 | 142 | ||
143 | ENTER(); | 143 | ENTER(); |
144 | 144 | ||
145 | if (assoc_req->mode == adapter->inframode) { | 145 | if (assoc_req->mode == adapter->mode) { |
146 | LEAVE(); | 146 | LEAVE(); |
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | 149 | ||
150 | if (assoc_req->mode == wlan802_11infrastructure) { | 150 | if (assoc_req->mode == IW_MODE_INFRA) { |
151 | if (adapter->psstate != PS_STATE_FULL_POWER) | 151 | if (adapter->psstate != PS_STATE_FULL_POWER) |
152 | libertas_ps_wakeup(priv, cmd_option_waitforrsp); | 152 | libertas_ps_wakeup(priv, cmd_option_waitforrsp); |
153 | adapter->psmode = wlan802_11powermodecam; | 153 | adapter->psmode = wlan802_11powermodecam; |
154 | } | 154 | } |
155 | 155 | ||
156 | adapter->inframode = assoc_req->mode; | 156 | adapter->mode = assoc_req->mode; |
157 | ret = libertas_prepare_and_send_command(priv, | 157 | ret = libertas_prepare_and_send_command(priv, |
158 | cmd_802_11_snmp_mib, | 158 | cmd_802_11_snmp_mib, |
159 | 0, cmd_option_waitforrsp, | 159 | 0, cmd_option_waitforrsp, |
160 | OID_802_11_INFRASTRUCTURE_MODE, | 160 | OID_802_11_INFRASTRUCTURE_MODE, |
161 | (void *) assoc_req->mode); | 161 | (void *) (size_t) assoc_req->mode); |
162 | 162 | ||
163 | LEAVE(); | 163 | LEAVE(); |
164 | return ret; | 164 | return ret; |
@@ -196,7 +196,7 @@ static int assoc_helper_wep_keys(wlan_private *priv, | |||
196 | goto out; | 196 | goto out; |
197 | 197 | ||
198 | /* enable/disable the MAC's WEP packet filter */ | 198 | /* enable/disable the MAC's WEP packet filter */ |
199 | if (assoc_req->secinfo.WEPstatus == wlan802_11WEPenabled) | 199 | if (assoc_req->secinfo.wep_enabled) |
200 | adapter->currentpacketfilter |= cmd_act_mac_wep_enable; | 200 | adapter->currentpacketfilter |= cmd_act_mac_wep_enable; |
201 | else | 201 | else |
202 | adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable; | 202 | adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable; |
@@ -300,8 +300,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter, | |||
300 | } | 300 | } |
301 | 301 | ||
302 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { | 302 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
303 | if (adapter->secinfo.authmode != | 303 | if (adapter->secinfo.auth_mode != assoc_req->secinfo.auth_mode) { |
304 | assoc_req->secinfo.authmode) { | ||
305 | lbs_pr_debug(1, "Deauthenticating due to updated security " | 304 | lbs_pr_debug(1, "Deauthenticating due to updated security " |
306 | "info in configuration request.\n"); | 305 | "info in configuration request.\n"); |
307 | return 1; | 306 | return 1; |
@@ -316,7 +315,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter, | |||
316 | 315 | ||
317 | /* FIXME: deal with 'auto' mode somehow */ | 316 | /* FIXME: deal with 'auto' mode somehow */ |
318 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { | 317 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
319 | if (assoc_req->mode != wlan802_11infrastructure) | 318 | if (assoc_req->mode != IW_MODE_INFRA) |
320 | return 1; | 319 | return 1; |
321 | } | 320 | } |
322 | 321 | ||
@@ -333,12 +332,12 @@ static int should_stop_adhoc(wlan_adapter *adapter, | |||
333 | if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) | 332 | if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) |
334 | return 1; | 333 | return 1; |
335 | if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, | 334 | if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, |
336 | sizeof(struct WLAN_802_11_SSID))) | 335 | adapter->curbssparams.ssid.ssidlength)) |
337 | return 1; | 336 | return 1; |
338 | 337 | ||
339 | /* FIXME: deal with 'auto' mode somehow */ | 338 | /* FIXME: deal with 'auto' mode somehow */ |
340 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { | 339 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
341 | if (assoc_req->mode != wlan802_11ibss) | 340 | if (assoc_req->mode != IW_MODE_ADHOC) |
342 | return 1; | 341 | return 1; |
343 | } | 342 | } |
344 | 343 | ||
@@ -382,7 +381,7 @@ void wlan_association_worker(struct work_struct *work) | |||
382 | } | 381 | } |
383 | 382 | ||
384 | if (find_any_ssid) { | 383 | if (find_any_ssid) { |
385 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; | 384 | u8 new_mode; |
386 | 385 | ||
387 | ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, | 386 | ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, |
388 | assoc_req->mode, &new_mode); | 387 | assoc_req->mode, &new_mode); |
@@ -393,7 +392,7 @@ void wlan_association_worker(struct work_struct *work) | |||
393 | } | 392 | } |
394 | 393 | ||
395 | /* Ensure we switch to the mode of the AP */ | 394 | /* Ensure we switch to the mode of the AP */ |
396 | if (assoc_req->mode == wlan802_11autounknown) { | 395 | if (assoc_req->mode == IW_MODE_AUTO) { |
397 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); | 396 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
398 | assoc_req->mode = new_mode; | 397 | assoc_req->mode = new_mode; |
399 | } | 398 | } |
@@ -403,7 +402,7 @@ void wlan_association_worker(struct work_struct *work) | |||
403 | * Check if the attributes being changing require deauthentication | 402 | * Check if the attributes being changing require deauthentication |
404 | * from the currently associated infrastructure access point. | 403 | * from the currently associated infrastructure access point. |
405 | */ | 404 | */ |
406 | if (adapter->inframode == wlan802_11infrastructure) { | 405 | if (adapter->mode == IW_MODE_INFRA) { |
407 | if (should_deauth_infrastructure(adapter, assoc_req)) { | 406 | if (should_deauth_infrastructure(adapter, assoc_req)) { |
408 | ret = libertas_send_deauthentication(priv); | 407 | ret = libertas_send_deauthentication(priv); |
409 | if (ret) { | 408 | if (ret) { |
@@ -412,7 +411,7 @@ void wlan_association_worker(struct work_struct *work) | |||
412 | ret); | 411 | ret); |
413 | } | 412 | } |
414 | } | 413 | } |
415 | } else if (adapter->inframode == wlan802_11ibss) { | 414 | } else if (adapter->mode == IW_MODE_ADHOC) { |
416 | if (should_stop_adhoc(adapter, assoc_req)) { | 415 | if (should_stop_adhoc(adapter, assoc_req)) { |
417 | ret = libertas_stop_adhoc_network(priv); | 416 | ret = libertas_stop_adhoc_network(priv); |
418 | if (ret) { | 417 | if (ret) { |
@@ -543,7 +542,7 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter) | |||
543 | assoc_req->channel = adapter->curbssparams.channel; | 542 | assoc_req->channel = adapter->curbssparams.channel; |
544 | 543 | ||
545 | if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) | 544 | if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) |
546 | assoc_req->mode = adapter->inframode; | 545 | assoc_req->mode = adapter->mode; |
547 | 546 | ||
548 | if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { | 547 | if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
549 | memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, | 548 | memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, |
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index bfdac58b5c06..de9cb46a70ff 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -381,15 +381,16 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv, | |||
381 | switch (cmd_oid) { | 381 | switch (cmd_oid) { |
382 | case OID_802_11_INFRASTRUCTURE_MODE: | 382 | case OID_802_11_INFRASTRUCTURE_MODE: |
383 | { | 383 | { |
384 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode = | 384 | u8 mode = (u8) (size_t) pdata_buf; |
385 | (enum WLAN_802_11_NETWORK_INFRASTRUCTURE) pdata_buf; | ||
386 | pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); | 385 | pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); |
387 | pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i); | 386 | pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i); |
388 | pSNMPMIB->bufsize = sizeof(u8); | 387 | pSNMPMIB->bufsize = sizeof(u8); |
389 | if (mode == wlan802_11infrastructure) | 388 | if (mode == IW_MODE_ADHOC) { |
390 | ucTemp = SNMP_MIB_VALUE_INFRA; | ||
391 | else | ||
392 | ucTemp = SNMP_MIB_VALUE_ADHOC; | 389 | ucTemp = SNMP_MIB_VALUE_ADHOC; |
390 | } else { | ||
391 | /* Infra and Auto modes */ | ||
392 | ucTemp = SNMP_MIB_VALUE_INFRA; | ||
393 | } | ||
393 | 394 | ||
394 | memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); | 395 | memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); |
395 | 396 | ||
@@ -947,8 +948,8 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u | |||
947 | 948 | ||
948 | spin_unlock_irqrestore(&adapter->driver_lock, flags); | 949 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
949 | 950 | ||
950 | lbs_pr_debug(1, "QUEUE_CMD: Inserted node=0x%x, cmd=0x%x in cmdpendingq\n", | 951 | lbs_pr_debug(1, "QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n", |
951 | (u32) cmdnode, | 952 | cmdnode, |
952 | ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); | 953 | ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); |
953 | 954 | ||
954 | done: | 955 | done: |
@@ -976,8 +977,8 @@ static int DownloadcommandToStation(wlan_private * priv, | |||
976 | ENTER(); | 977 | ENTER(); |
977 | 978 | ||
978 | if (!adapter || !cmdnode) { | 979 | if (!adapter || !cmdnode) { |
979 | lbs_pr_debug(1, "DNLD_CMD: adapter = %#x, cmdnode = %#x\n", | 980 | lbs_pr_debug(1, "DNLD_CMD: adapter = %p, cmdnode = %p\n", |
980 | (int)adapter, (int)cmdnode); | 981 | adapter, cmdnode); |
981 | if (cmdnode) { | 982 | if (cmdnode) { |
982 | spin_lock_irqsave(&adapter->driver_lock, flags); | 983 | spin_lock_irqsave(&adapter->driver_lock, flags); |
983 | __libertas_cleanup_and_insert_cmd(priv, cmdnode); | 984 | __libertas_cleanup_and_insert_cmd(priv, cmdnode); |
@@ -1174,8 +1175,8 @@ int libertas_prepare_and_send_command(wlan_private * priv, | |||
1174 | 1175 | ||
1175 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; | 1176 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; |
1176 | 1177 | ||
1177 | lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr =0x%x, command=0x%X\n", | 1178 | lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr=%p, command=0x%X\n", |
1178 | (u32) cmdptr, cmd_no); | 1179 | cmdptr, cmd_no); |
1179 | 1180 | ||
1180 | if (!cmdptr) { | 1181 | if (!cmdptr) { |
1181 | lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); | 1182 | lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index cdb012c7e9cf..c86454034b58 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -72,8 +72,6 @@ void libertas_mac_event_disconnected(wlan_private * priv) | |||
72 | adapter->secinfo.WPAenabled = 0; | 72 | adapter->secinfo.WPAenabled = 0; |
73 | adapter->secinfo.WPA2enabled = 0; | 73 | adapter->secinfo.WPA2enabled = 0; |
74 | adapter->wpa_ie_len = 0; | 74 | adapter->wpa_ie_len = 0; |
75 | adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE; | ||
76 | adapter->secinfo.Encryptionmode = CIPHER_NONE; | ||
77 | 75 | ||
78 | adapter->connect_status = libertas_disconnected; | 76 | adapter->connect_status = libertas_disconnected; |
79 | 77 | ||
@@ -811,7 +809,7 @@ int libertas_process_rx_command(wlan_private * priv) | |||
811 | if (result) { | 809 | if (result) { |
812 | lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", | 810 | lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", |
813 | resp->result); | 811 | resp->result); |
814 | if (adapter->inframode == wlan802_11ibss) { | 812 | if (adapter->mode == IW_MODE_ADHOC) { |
815 | /* | 813 | /* |
816 | * We should not re-try enter-ps command in | 814 | * We should not re-try enter-ps command in |
817 | * ad-hoc mode. It takes place in | 815 | * ad-hoc mode. It takes place in |
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c index 51dfd202f558..7d7bc5e86a56 100644 --- a/drivers/net/wireless/libertas/debugfs.c +++ b/drivers/net/wireless/libertas/debugfs.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "dev.h" | 7 | #include "dev.h" |
8 | #include "decl.h" | 8 | #include "decl.h" |
9 | #include "host.h" | 9 | #include "host.h" |
10 | #include "debugfs.h" | ||
10 | 11 | ||
11 | static struct dentry *libertas_dir = NULL; | 12 | static struct dentry *libertas_dir = NULL; |
12 | static char *szStates[] = { | 13 | static char *szStates[] = { |
@@ -276,7 +277,7 @@ static void libertas_parse_ssid(char *buf, size_t count, | |||
276 | if (!end) | 277 | if (!end) |
277 | end = buf + count - 1; | 278 | end = buf + count - 1; |
278 | 279 | ||
279 | size = min(IW_ESSID_MAX_SIZE, end - hold); | 280 | size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold)); |
280 | strncpy(scan_cfg->specificSSID, hold, size); | 281 | strncpy(scan_cfg->specificSSID, hold, size); |
281 | 282 | ||
282 | return; | 283 | return; |
@@ -1648,7 +1649,7 @@ struct libertas_debugfs_files { | |||
1648 | struct file_operations fops; | 1649 | struct file_operations fops; |
1649 | }; | 1650 | }; |
1650 | 1651 | ||
1651 | struct libertas_debugfs_files debugfs_files[] = { | 1652 | static struct libertas_debugfs_files debugfs_files[] = { |
1652 | { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), }, | 1653 | { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), }, |
1653 | { "getscantable", 0444, FOPS(libertas_getscantable, | 1654 | { "getscantable", 0444, FOPS(libertas_getscantable, |
1654 | write_file_dummy), }, | 1655 | write_file_dummy), }, |
@@ -1658,7 +1659,7 @@ struct libertas_debugfs_files debugfs_files[] = { | |||
1658 | { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), }, | 1659 | { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), }, |
1659 | }; | 1660 | }; |
1660 | 1661 | ||
1661 | struct libertas_debugfs_files debugfs_events_files[] = { | 1662 | static struct libertas_debugfs_files debugfs_events_files[] = { |
1662 | {"low_rssi", 0644, FOPS(libertas_lowrssi_read, | 1663 | {"low_rssi", 0644, FOPS(libertas_lowrssi_read, |
1663 | libertas_lowrssi_write), }, | 1664 | libertas_lowrssi_write), }, |
1664 | {"low_snr", 0644, FOPS(libertas_lowsnr_read, | 1665 | {"low_snr", 0644, FOPS(libertas_lowsnr_read, |
@@ -1673,7 +1674,7 @@ struct libertas_debugfs_files debugfs_events_files[] = { | |||
1673 | libertas_highsnr_write), }, | 1674 | libertas_highsnr_write), }, |
1674 | }; | 1675 | }; |
1675 | 1676 | ||
1676 | struct libertas_debugfs_files debugfs_regs_files[] = { | 1677 | static struct libertas_debugfs_files debugfs_regs_files[] = { |
1677 | {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), }, | 1678 | {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), }, |
1678 | {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), }, | 1679 | {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), }, |
1679 | {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), }, | 1680 | {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), }, |
@@ -1778,7 +1779,7 @@ void libertas_debugfs_remove_one(wlan_private *priv) | |||
1778 | struct debug_data { | 1779 | struct debug_data { |
1779 | char name[32]; | 1780 | char name[32]; |
1780 | u32 size; | 1781 | u32 size; |
1781 | u32 addr; | 1782 | size_t addr; |
1782 | }; | 1783 | }; |
1783 | 1784 | ||
1784 | /* To debug any member of wlan_adapter, simply add one line here. | 1785 | /* To debug any member of wlan_adapter, simply add one line here. |
@@ -1825,6 +1826,8 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf, | |||
1825 | val = *((u16 *) d[i].addr); | 1826 | val = *((u16 *) d[i].addr); |
1826 | else if (d[i].size == 4) | 1827 | else if (d[i].size == 4) |
1827 | val = *((u32 *) d[i].addr); | 1828 | val = *((u32 *) d[i].addr); |
1829 | else if (d[i].size == 8) | ||
1830 | val = *((u64 *) d[i].addr); | ||
1828 | 1831 | ||
1829 | pos += sprintf(p + pos, "%s=%d\n", d[i].name, val); | 1832 | pos += sprintf(p + pos, "%s=%d\n", d[i].name, val); |
1830 | } | 1833 | } |
@@ -1844,7 +1847,7 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf, | |||
1844 | * @param data data to write | 1847 | * @param data data to write |
1845 | * @return number of data | 1848 | * @return number of data |
1846 | */ | 1849 | */ |
1847 | static int wlan_debugfs_write(struct file *f, const char __user *buf, | 1850 | static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf, |
1848 | size_t cnt, loff_t *ppos) | 1851 | size_t cnt, loff_t *ppos) |
1849 | { | 1852 | { |
1850 | int r, i; | 1853 | int r, i; |
@@ -1886,12 +1889,14 @@ static int wlan_debugfs_write(struct file *f, const char __user *buf, | |||
1886 | *((u16 *) d[i].addr) = (u16) r; | 1889 | *((u16 *) d[i].addr) = (u16) r; |
1887 | else if (d[i].size == 4) | 1890 | else if (d[i].size == 4) |
1888 | *((u32 *) d[i].addr) = (u32) r; | 1891 | *((u32 *) d[i].addr) = (u32) r; |
1892 | else if (d[i].size == 8) | ||
1893 | *((u64 *) d[i].addr) = (u64) r; | ||
1889 | break; | 1894 | break; |
1890 | } while (1); | 1895 | } while (1); |
1891 | } | 1896 | } |
1892 | kfree(pdata); | 1897 | kfree(pdata); |
1893 | 1898 | ||
1894 | return cnt; | 1899 | return (ssize_t)cnt; |
1895 | } | 1900 | } |
1896 | 1901 | ||
1897 | static struct file_operations libertas_debug_fops = { | 1902 | static struct file_operations libertas_debug_fops = { |
@@ -1916,20 +1921,10 @@ void libertas_debug_init(wlan_private * priv, struct net_device *dev) | |||
1916 | return; | 1921 | return; |
1917 | 1922 | ||
1918 | for (i = 0; i < num_of_items; i++) | 1923 | for (i = 0; i < num_of_items; i++) |
1919 | items[i].addr += (u32) priv->adapter; | 1924 | items[i].addr += (size_t) priv->adapter; |
1920 | 1925 | ||
1921 | priv->debugfs_debug = debugfs_create_file("debug", 0644, | 1926 | priv->debugfs_debug = debugfs_create_file("debug", 0644, |
1922 | priv->debugfs_dir, &items[0], | 1927 | priv->debugfs_dir, &items[0], |
1923 | &libertas_debug_fops); | 1928 | &libertas_debug_fops); |
1924 | } | 1929 | } |
1925 | 1930 | ||
1926 | /** | ||
1927 | * @brief remove proc file | ||
1928 | * | ||
1929 | * @param priv pointer wlan_private | ||
1930 | * @return N/A | ||
1931 | */ | ||
1932 | void libertas_debug_remove(wlan_private * priv) | ||
1933 | { | ||
1934 | debugfs_remove(priv->debugfs_debug); | ||
1935 | } | ||
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h index fb1478c1b87d..80dd9ea19c8e 100644 --- a/drivers/net/wireless/libertas/defs.h +++ b/drivers/net/wireless/libertas/defs.h | |||
@@ -9,6 +9,11 @@ | |||
9 | 9 | ||
10 | extern unsigned int libertas_debug; | 10 | extern unsigned int libertas_debug; |
11 | 11 | ||
12 | #ifdef CONFIG_LIBERTAS_DEBUG | ||
13 | #define DEBUG | ||
14 | #define PROC_DEBUG | ||
15 | #endif | ||
16 | |||
12 | #define DRV_NAME "usb8xxx" | 17 | #define DRV_NAME "usb8xxx" |
13 | 18 | ||
14 | #define lbs_pr_info(format, args...) \ | 19 | #define lbs_pr_info(format, args...) \ |
@@ -223,31 +228,6 @@ enum SNRNF_DATA { | |||
223 | MAX_TYPE_AVG | 228 | MAX_TYPE_AVG |
224 | }; | 229 | }; |
225 | 230 | ||
226 | /** WLAN_802_11_AUTH_ALG*/ | ||
227 | enum WLAN_802_11_AUTH_ALG { | ||
228 | AUTH_ALG_OPEN_SYSTEM = 1, | ||
229 | AUTH_ALG_SHARED_KEY = 2, | ||
230 | AUTH_ALG_NETWORK_EAP = 8, | ||
231 | }; | ||
232 | |||
233 | /** WLAN_802_1X_AUTH_ALG */ | ||
234 | enum WLAN_802_1X_AUTH_ALG { | ||
235 | WLAN_1X_AUTH_ALG_NONE = 1, | ||
236 | WLAN_1X_AUTH_ALG_LEAP = 2, | ||
237 | WLAN_1X_AUTH_ALG_TLS = 4, | ||
238 | WLAN_1X_AUTH_ALG_TTLS = 8, | ||
239 | WLAN_1X_AUTH_ALG_MD5 = 16, | ||
240 | }; | ||
241 | |||
242 | /** WLAN_802_11_ENCRYPTION_MODE */ | ||
243 | enum WLAN_802_11_ENCRYPTION_MODE { | ||
244 | CIPHER_NONE, | ||
245 | CIPHER_WEP40, | ||
246 | CIPHER_TKIP, | ||
247 | CIPHER_CCMP, | ||
248 | CIPHER_WEP104, | ||
249 | }; | ||
250 | |||
251 | /** WLAN_802_11_POWER_MODE */ | 231 | /** WLAN_802_11_POWER_MODE */ |
252 | enum WLAN_802_11_POWER_MODE { | 232 | enum WLAN_802_11_POWER_MODE { |
253 | wlan802_11powermodecam, | 233 | wlan802_11powermodecam, |
@@ -292,28 +272,6 @@ enum mv_ms_type { | |||
292 | MVMS_EVENT | 272 | MVMS_EVENT |
293 | }; | 273 | }; |
294 | 274 | ||
295 | /** WLAN_802_11_NETWORK_INFRASTRUCTURE */ | ||
296 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE { | ||
297 | wlan802_11ibss, | ||
298 | wlan802_11infrastructure, | ||
299 | wlan802_11autounknown, | ||
300 | /*defined as upper bound */ | ||
301 | wlan802_11infrastructuremax | ||
302 | }; | ||
303 | |||
304 | /** WLAN_802_11_AUTHENTICATION_MODE */ | ||
305 | enum WLAN_802_11_AUTHENTICATION_MODE { | ||
306 | wlan802_11authmodeopen = 0x00, | ||
307 | wlan802_11authmodeshared = 0x01, | ||
308 | wlan802_11authmodenetworkEAP = 0x80, | ||
309 | }; | ||
310 | |||
311 | /** WLAN_802_11_WEP_STATUS */ | ||
312 | enum WLAN_802_11_WEP_STATUS { | ||
313 | wlan802_11WEPenabled, | ||
314 | wlan802_11WEPdisabled, | ||
315 | }; | ||
316 | |||
317 | /** SNMP_MIB_INDEX_e */ | 275 | /** SNMP_MIB_INDEX_e */ |
318 | enum SNMP_MIB_INDEX_e { | 276 | enum SNMP_MIB_INDEX_e { |
319 | desired_bsstype_i = 0, | 277 | desired_bsstype_i = 0, |
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h index b1f876f9693b..e8b9020f9bd6 100644 --- a/drivers/net/wireless/libertas/dev.h +++ b/drivers/net/wireless/libertas/dev.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/wireless.h> | 10 | #include <linux/wireless.h> |
11 | #include <linux/ethtool.h> | 11 | #include <linux/ethtool.h> |
12 | #include <linux/debugfs.h> | 12 | #include <linux/debugfs.h> |
13 | #include <net/ieee80211.h> | ||
13 | 14 | ||
14 | #include "defs.h" | 15 | #include "defs.h" |
15 | #include "scan.h" | 16 | #include "scan.h" |
@@ -56,10 +57,8 @@ struct region_channel { | |||
56 | struct wlan_802_11_security { | 57 | struct wlan_802_11_security { |
57 | u8 WPAenabled; | 58 | u8 WPAenabled; |
58 | u8 WPA2enabled; | 59 | u8 WPA2enabled; |
59 | enum WLAN_802_11_WEP_STATUS WEPstatus; | 60 | u8 wep_enabled; |
60 | enum WLAN_802_11_AUTHENTICATION_MODE authmode; | 61 | u8 auth_mode; |
61 | enum WLAN_802_1X_AUTH_ALG auth1xalg; | ||
62 | enum WLAN_802_11_ENCRYPTION_MODE Encryptionmode; | ||
63 | }; | 62 | }; |
64 | 63 | ||
65 | /** Current Basic Service Set State Structure */ | 64 | /** Current Basic Service Set State Structure */ |
@@ -184,7 +183,7 @@ struct assoc_request { | |||
184 | 183 | ||
185 | struct WLAN_802_11_SSID ssid; | 184 | struct WLAN_802_11_SSID ssid; |
186 | u8 channel; | 185 | u8 channel; |
187 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode; | 186 | u8 mode; |
188 | u8 bssid[ETH_ALEN]; | 187 | u8 bssid[ETH_ALEN]; |
189 | 188 | ||
190 | /** WEP keys */ | 189 | /** WEP keys */ |
@@ -198,7 +197,6 @@ struct assoc_request { | |||
198 | struct wlan_802_11_security secinfo; | 197 | struct wlan_802_11_security secinfo; |
199 | 198 | ||
200 | /** WPA Information Elements*/ | 199 | /** WPA Information Elements*/ |
201 | #define MAX_WPA_IE_LEN 64 | ||
202 | u8 wpa_ie[MAX_WPA_IE_LEN]; | 200 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
203 | u8 wpa_ie_len; | 201 | u8 wpa_ie_len; |
204 | }; | 202 | }; |
@@ -254,7 +252,8 @@ struct _wlan_adapter { | |||
254 | /** current ssid/bssid related parameters*/ | 252 | /** current ssid/bssid related parameters*/ |
255 | struct current_bss_params curbssparams; | 253 | struct current_bss_params curbssparams; |
256 | 254 | ||
257 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; | 255 | /* IW_MODE_* */ |
256 | u8 mode; | ||
258 | 257 | ||
259 | struct bss_descriptor *pattemptedbssdesc; | 258 | struct bss_descriptor *pattemptedbssdesc; |
260 | 259 | ||
@@ -339,7 +338,6 @@ struct _wlan_adapter { | |||
339 | struct WLAN_802_11_KEY wpa_unicast_key; | 338 | struct WLAN_802_11_KEY wpa_unicast_key; |
340 | 339 | ||
341 | /** WPA Information Elements*/ | 340 | /** WPA Information Elements*/ |
342 | #define MAX_WPA_IE_LEN 64 | ||
343 | u8 wpa_ie[MAX_WPA_IE_LEN]; | 341 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
344 | u8 wpa_ie_len; | 342 | u8 wpa_ie_len; |
345 | 343 | ||
diff --git a/drivers/net/wireless/libertas/fw.c b/drivers/net/wireless/libertas/fw.c index b194a4570791..441123c85e62 100644 --- a/drivers/net/wireless/libertas/fw.c +++ b/drivers/net/wireless/libertas/fw.c | |||
@@ -194,16 +194,13 @@ static void wlan_init_adapter(wlan_private * priv) | |||
194 | adapter->scanmode = cmd_bss_type_any; | 194 | adapter->scanmode = cmd_bss_type_any; |
195 | 195 | ||
196 | /* 802.11 specific */ | 196 | /* 802.11 specific */ |
197 | adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; | 197 | adapter->secinfo.wep_enabled = 0; |
198 | for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); | 198 | for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); |
199 | i++) | 199 | i++) |
200 | memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); | 200 | memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); |
201 | adapter->wep_tx_keyidx = 0; | 201 | adapter->wep_tx_keyidx = 0; |
202 | adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; | 202 | adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
203 | adapter->secinfo.authmode = wlan802_11authmodeopen; | 203 | adapter->mode = IW_MODE_INFRA; |
204 | adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE; | ||
205 | adapter->secinfo.Encryptionmode = CIPHER_NONE; | ||
206 | adapter->inframode = wlan802_11infrastructure; | ||
207 | 204 | ||
208 | adapter->assoc_req = NULL; | 205 | adapter->assoc_req = NULL; |
209 | 206 | ||
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 695fb6a66ffe..ae6f72a6cdf3 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -388,7 +388,7 @@ static int __if_usb_submit_rx_urb(wlan_private * priv, | |||
388 | usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, | 388 | usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, |
389 | usb_rcvbulkpipe(cardp->udev, | 389 | usb_rcvbulkpipe(cardp->udev, |
390 | cardp->bulk_in_endpointAddr), | 390 | cardp->bulk_in_endpointAddr), |
391 | skb->tail + IPFIELD_ALIGN_OFFSET, | 391 | (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET), |
392 | MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, | 392 | MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, |
393 | rinfo); | 393 | rinfo); |
394 | 394 | ||
@@ -626,6 +626,7 @@ static void if_usb_receive(struct urb *urb) | |||
626 | cardp->usb_event_cause); | 626 | cardp->usb_event_cause); |
627 | if (cardp->usb_event_cause & 0xffff0000) { | 627 | if (cardp->usb_event_cause & 0xffff0000) { |
628 | libertas_send_tx_feedback(priv); | 628 | libertas_send_tx_feedback(priv); |
629 | spin_unlock(&priv->adapter->driver_lock); | ||
629 | break; | 630 | break; |
630 | } | 631 | } |
631 | cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; | 632 | cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; |
@@ -775,7 +776,6 @@ restart: | |||
775 | return -1; | 776 | return -1; |
776 | } | 777 | } |
777 | 778 | ||
778 | #ifdef SUPPORT_BOOT_COMMAND | ||
779 | cardp->bootcmdresp = 0; | 779 | cardp->bootcmdresp = 0; |
780 | do { | 780 | do { |
781 | int j = 0; | 781 | int j = 0; |
@@ -796,7 +796,6 @@ restart: | |||
796 | } | 796 | } |
797 | return -1; | 797 | return -1; |
798 | } | 798 | } |
799 | #endif | ||
800 | 799 | ||
801 | i = 0; | 800 | i = 0; |
802 | priv->adapter->fw_ready = 0; | 801 | priv->adapter->fw_ready = 0; |
diff --git a/drivers/net/wireless/libertas/if_usb.h b/drivers/net/wireless/libertas/if_usb.h index 785116720bc6..170dfe6809f5 100644 --- a/drivers/net/wireless/libertas/if_usb.h +++ b/drivers/net/wireless/libertas/if_usb.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #define USB8388_VID_2 0x05a3 | 12 | #define USB8388_VID_2 0x05a3 |
13 | #define USB8388_PID_2 0x8388 | 13 | #define USB8388_PID_2 0x8388 |
14 | 14 | ||
15 | #ifdef SUPPORT_BOOT_COMMAND | ||
16 | #define BOOT_CMD_FW_BY_USB 0x01 | 15 | #define BOOT_CMD_FW_BY_USB 0x01 |
17 | #define BOOT_CMD_FW_IN_EEPROM 0x02 | 16 | #define BOOT_CMD_FW_IN_EEPROM 0x02 |
18 | #define BOOT_CMD_UPDATE_BOOT2 0x03 | 17 | #define BOOT_CMD_UPDATE_BOOT2 0x03 |
@@ -36,7 +35,6 @@ struct bootcmdrespStr | |||
36 | u8 u8result; | 35 | u8 u8result; |
37 | u8 au8dumy[2]; | 36 | u8 au8dumy[2]; |
38 | }; | 37 | }; |
39 | #endif /* SUPPORT_BOOT_COMMAND */ | ||
40 | 38 | ||
41 | /* read callback private data */ | 39 | /* read callback private data */ |
42 | struct read_cb_info { | 40 | struct read_cb_info { |
diff --git a/drivers/net/wireless/libertas/ioctl.c b/drivers/net/wireless/libertas/ioctl.c index 82b39642423a..a8f76c358992 100644 --- a/drivers/net/wireless/libertas/ioctl.c +++ b/drivers/net/wireless/libertas/ioctl.c | |||
@@ -27,95 +27,6 @@ | |||
27 | 27 | ||
28 | #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) | 28 | #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) |
29 | 29 | ||
30 | static int setrxantenna(wlan_private * priv, int mode) | ||
31 | { | ||
32 | int ret = 0; | ||
33 | wlan_adapter *adapter = priv->adapter; | ||
34 | |||
35 | if (mode != RF_ANTENNA_1 && mode != RF_ANTENNA_2 | ||
36 | && mode != RF_ANTENNA_AUTO) { | ||
37 | return -EINVAL; | ||
38 | } | ||
39 | |||
40 | adapter->rxantennamode = mode; | ||
41 | |||
42 | lbs_pr_debug(1, "SET RX Antenna mode to 0x%04x\n", adapter->rxantennamode); | ||
43 | |||
44 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
45 | cmd_act_set_rx, | ||
46 | cmd_option_waitforrsp, 0, | ||
47 | &adapter->rxantennamode); | ||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | static int settxantenna(wlan_private * priv, int mode) | ||
52 | { | ||
53 | int ret = 0; | ||
54 | wlan_adapter *adapter = priv->adapter; | ||
55 | |||
56 | if ((mode != RF_ANTENNA_1) && (mode != RF_ANTENNA_2) | ||
57 | && (mode != RF_ANTENNA_AUTO)) { | ||
58 | return -EINVAL; | ||
59 | } | ||
60 | |||
61 | adapter->txantennamode = mode; | ||
62 | |||
63 | lbs_pr_debug(1, "SET TX Antenna mode to 0x%04x\n", adapter->txantennamode); | ||
64 | |||
65 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
66 | cmd_act_set_tx, | ||
67 | cmd_option_waitforrsp, 0, | ||
68 | &adapter->txantennamode); | ||
69 | |||
70 | return ret; | ||
71 | } | ||
72 | |||
73 | static int getrxantenna(wlan_private * priv, char *buf) | ||
74 | { | ||
75 | int ret = 0; | ||
76 | wlan_adapter *adapter = priv->adapter; | ||
77 | |||
78 | // clear it, so we will know if the value | ||
79 | // returned below is correct or not. | ||
80 | adapter->rxantennamode = 0; | ||
81 | |||
82 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
83 | cmd_act_get_rx, | ||
84 | cmd_option_waitforrsp, 0, NULL); | ||
85 | |||
86 | if (ret) { | ||
87 | LEAVE(); | ||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | lbs_pr_debug(1, "Get Rx Antenna mode:0x%04x\n", adapter->rxantennamode); | ||
92 | |||
93 | return sprintf(buf, "0x%04x", adapter->rxantennamode) + 1; | ||
94 | } | ||
95 | |||
96 | static int gettxantenna(wlan_private * priv, char *buf) | ||
97 | { | ||
98 | int ret = 0; | ||
99 | wlan_adapter *adapter = priv->adapter; | ||
100 | |||
101 | // clear it, so we will know if the value | ||
102 | // returned below is correct or not. | ||
103 | adapter->txantennamode = 0; | ||
104 | |||
105 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
106 | cmd_act_get_tx, | ||
107 | cmd_option_waitforrsp, 0, NULL); | ||
108 | |||
109 | if (ret) { | ||
110 | LEAVE(); | ||
111 | return ret; | ||
112 | } | ||
113 | |||
114 | lbs_pr_debug(1, "Get Tx Antenna mode:0x%04x\n", adapter->txantennamode); | ||
115 | |||
116 | return sprintf(buf, "0x%04x", adapter->txantennamode) + 1; | ||
117 | } | ||
118 | |||
119 | static int wlan_set_region(wlan_private * priv, u16 region_code) | 30 | static int wlan_set_region(wlan_private * priv, u16 region_code) |
120 | { | 31 | { |
121 | int i; | 32 | int i; |
@@ -144,998 +55,6 @@ static int wlan_set_region(wlan_private * priv, u16 region_code) | |||
144 | return 0; | 55 | return 0; |
145 | } | 56 | } |
146 | 57 | ||
147 | /** | ||
148 | * @brief Get/Set Firmware wakeup method | ||
149 | * | ||
150 | * @param priv A pointer to wlan_private structure | ||
151 | * @param wrq A pointer to user data | ||
152 | * @return 0--success, otherwise fail | ||
153 | */ | ||
154 | static int wlan_txcontrol(wlan_private * priv, struct iwreq *wrq) | ||
155 | { | ||
156 | wlan_adapter *adapter = priv->adapter; | ||
157 | int data; | ||
158 | ENTER(); | ||
159 | |||
160 | if ((int)wrq->u.data.length == 0) { | ||
161 | if (copy_to_user | ||
162 | (wrq->u.data.pointer, &adapter->pkttxctrl, sizeof(u32))) { | ||
163 | lbs_pr_alert("copy_to_user failed!\n"); | ||
164 | return -EFAULT; | ||
165 | } | ||
166 | } else { | ||
167 | if ((int)wrq->u.data.length > 1) { | ||
168 | lbs_pr_alert("ioctl too many args!\n"); | ||
169 | return -EFAULT; | ||
170 | } | ||
171 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
172 | lbs_pr_alert("Copy from user failed\n"); | ||
173 | return -EFAULT; | ||
174 | } | ||
175 | |||
176 | adapter->pkttxctrl = (u32) data; | ||
177 | } | ||
178 | |||
179 | wrq->u.data.length = 1; | ||
180 | |||
181 | LEAVE(); | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * @brief Get/Set NULL Package generation interval | ||
187 | * | ||
188 | * @param priv A pointer to wlan_private structure | ||
189 | * @param wrq A pointer to user data | ||
190 | * @return 0--success, otherwise fail | ||
191 | */ | ||
192 | static int wlan_null_pkt_interval(wlan_private * priv, struct iwreq *wrq) | ||
193 | { | ||
194 | wlan_adapter *adapter = priv->adapter; | ||
195 | int data; | ||
196 | ENTER(); | ||
197 | |||
198 | if ((int)wrq->u.data.length == 0) { | ||
199 | data = adapter->nullpktinterval; | ||
200 | |||
201 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { | ||
202 | lbs_pr_alert( "copy_to_user failed!\n"); | ||
203 | return -EFAULT; | ||
204 | } | ||
205 | } else { | ||
206 | if ((int)wrq->u.data.length > 1) { | ||
207 | lbs_pr_alert( "ioctl too many args!\n"); | ||
208 | return -EFAULT; | ||
209 | } | ||
210 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
211 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
212 | return -EFAULT; | ||
213 | } | ||
214 | |||
215 | adapter->nullpktinterval = data; | ||
216 | } | ||
217 | |||
218 | wrq->u.data.length = 1; | ||
219 | |||
220 | LEAVE(); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int wlan_get_rxinfo(wlan_private * priv, struct iwreq *wrq) | ||
225 | { | ||
226 | wlan_adapter *adapter = priv->adapter; | ||
227 | int data[2]; | ||
228 | ENTER(); | ||
229 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
230 | data[1] = adapter->rxpd_rate; | ||
231 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { | ||
232 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
233 | return -EFAULT; | ||
234 | } | ||
235 | wrq->u.data.length = 2; | ||
236 | LEAVE(); | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int wlan_get_snr(wlan_private * priv, struct iwreq *wrq) | ||
241 | { | ||
242 | int ret = 0; | ||
243 | wlan_adapter *adapter = priv->adapter; | ||
244 | int data[4]; | ||
245 | |||
246 | ENTER(); | ||
247 | memset(data, 0, sizeof(data)); | ||
248 | if (wrq->u.data.length) { | ||
249 | if (copy_from_user(data, wrq->u.data.pointer, | ||
250 | min_t(size_t, wrq->u.data.length, 4) * sizeof(int))) | ||
251 | return -EFAULT; | ||
252 | } | ||
253 | if ((wrq->u.data.length == 0) || (data[0] == 0) || (data[0] == 1)) { | ||
254 | if (adapter->connect_status == libertas_connected) { | ||
255 | ret = libertas_prepare_and_send_command(priv, | ||
256 | cmd_802_11_rssi, | ||
257 | 0, | ||
258 | cmd_option_waitforrsp, | ||
259 | 0, NULL); | ||
260 | |||
261 | if (ret) { | ||
262 | LEAVE(); | ||
263 | return ret; | ||
264 | } | ||
265 | } | ||
266 | } | ||
267 | |||
268 | if (wrq->u.data.length == 0) { | ||
269 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; | ||
270 | data[1] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; | ||
271 | data[2] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
272 | data[3] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
273 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 4)) | ||
274 | return -EFAULT; | ||
275 | wrq->u.data.length = 4; | ||
276 | } else if (data[0] == 0) { | ||
277 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; | ||
278 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
279 | return -EFAULT; | ||
280 | wrq->u.data.length = 1; | ||
281 | } else if (data[0] == 1) { | ||
282 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; | ||
283 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
284 | return -EFAULT; | ||
285 | wrq->u.data.length = 1; | ||
286 | } else if (data[0] == 2) { | ||
287 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
288 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
289 | return -EFAULT; | ||
290 | wrq->u.data.length = 1; | ||
291 | } else if (data[0] == 3) { | ||
292 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
293 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
294 | return -EFAULT; | ||
295 | wrq->u.data.length = 1; | ||
296 | } else | ||
297 | return -ENOTSUPP; | ||
298 | |||
299 | LEAVE(); | ||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static int wlan_beacon_interval(wlan_private * priv, struct iwreq *wrq) | ||
304 | { | ||
305 | int data; | ||
306 | wlan_adapter *adapter = priv->adapter; | ||
307 | |||
308 | if (wrq->u.data.length > 0) { | ||
309 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) | ||
310 | return -EFAULT; | ||
311 | |||
312 | lbs_pr_debug(1, "WLAN SET BEACON INTERVAL: %d\n", data); | ||
313 | if ((data > MRVDRV_MAX_BEACON_INTERVAL) | ||
314 | || (data < MRVDRV_MIN_BEACON_INTERVAL)) | ||
315 | return -ENOTSUPP; | ||
316 | adapter->beaconperiod = data; | ||
317 | } | ||
318 | data = adapter->beaconperiod; | ||
319 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) | ||
320 | return -EFAULT; | ||
321 | |||
322 | wrq->u.data.length = 1; | ||
323 | |||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static int wlan_get_rssi(wlan_private * priv, struct iwreq *wrq) | ||
328 | { | ||
329 | int ret = 0; | ||
330 | wlan_adapter *adapter = priv->adapter; | ||
331 | int temp; | ||
332 | int data = 0; | ||
333 | int *val; | ||
334 | |||
335 | ENTER(); | ||
336 | data = SUBCMD_DATA(wrq); | ||
337 | if ((data == 0) || (data == 1)) { | ||
338 | ret = libertas_prepare_and_send_command(priv, | ||
339 | cmd_802_11_rssi, | ||
340 | 0, cmd_option_waitforrsp, | ||
341 | 0, NULL); | ||
342 | if (ret) { | ||
343 | LEAVE(); | ||
344 | return ret; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | switch (data) { | ||
349 | case 0: | ||
350 | |||
351 | temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], | ||
352 | adapter->NF[TYPE_BEACON][TYPE_NOAVG]); | ||
353 | break; | ||
354 | case 1: | ||
355 | temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG], | ||
356 | adapter->NF[TYPE_BEACON][TYPE_AVG]); | ||
357 | break; | ||
358 | case 2: | ||
359 | temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_NOAVG], | ||
360 | adapter->NF[TYPE_RXPD][TYPE_NOAVG]); | ||
361 | break; | ||
362 | case 3: | ||
363 | temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, | ||
364 | adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); | ||
365 | break; | ||
366 | default: | ||
367 | return -ENOTSUPP; | ||
368 | } | ||
369 | val = (int *)wrq->u.name; | ||
370 | *val = temp; | ||
371 | |||
372 | LEAVE(); | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static int wlan_get_nf(wlan_private * priv, struct iwreq *wrq) | ||
377 | { | ||
378 | int ret = 0; | ||
379 | wlan_adapter *adapter = priv->adapter; | ||
380 | int temp; | ||
381 | int data = 0; | ||
382 | int *val; | ||
383 | |||
384 | data = SUBCMD_DATA(wrq); | ||
385 | if ((data == 0) || (data == 1)) { | ||
386 | ret = libertas_prepare_and_send_command(priv, | ||
387 | cmd_802_11_rssi, | ||
388 | 0, cmd_option_waitforrsp, | ||
389 | 0, NULL); | ||
390 | |||
391 | if (ret) { | ||
392 | LEAVE(); | ||
393 | return ret; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | switch (data) { | ||
398 | case 0: | ||
399 | temp = adapter->NF[TYPE_BEACON][TYPE_NOAVG]; | ||
400 | break; | ||
401 | case 1: | ||
402 | temp = adapter->NF[TYPE_BEACON][TYPE_AVG]; | ||
403 | break; | ||
404 | case 2: | ||
405 | temp = adapter->NF[TYPE_RXPD][TYPE_NOAVG]; | ||
406 | break; | ||
407 | case 3: | ||
408 | temp = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
409 | break; | ||
410 | default: | ||
411 | return -ENOTSUPP; | ||
412 | } | ||
413 | |||
414 | temp = CAL_NF(temp); | ||
415 | |||
416 | lbs_pr_debug(1, "%s: temp = %d\n", __FUNCTION__, temp); | ||
417 | val = (int *)wrq->u.name; | ||
418 | *val = temp; | ||
419 | return 0; | ||
420 | } | ||
421 | |||
422 | static int wlan_get_txrate_ioctl(wlan_private * priv, struct ifreq *req) | ||
423 | { | ||
424 | wlan_adapter *adapter = priv->adapter; | ||
425 | int *pdata; | ||
426 | struct iwreq *wrq = (struct iwreq *)req; | ||
427 | int ret = 0; | ||
428 | adapter->txrate = 0; | ||
429 | lbs_pr_debug(1, "wlan_get_txrate_ioctl\n"); | ||
430 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_tx_rate_query, | ||
431 | cmd_act_get, cmd_option_waitforrsp, | ||
432 | 0, NULL); | ||
433 | if (ret) | ||
434 | return ret; | ||
435 | |||
436 | pdata = (int *)wrq->u.name; | ||
437 | *pdata = (int)adapter->txrate; | ||
438 | return 0; | ||
439 | } | ||
440 | |||
441 | static int wlan_get_adhoc_status_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
442 | { | ||
443 | char status[64]; | ||
444 | wlan_adapter *adapter = priv->adapter; | ||
445 | |||
446 | memset(status, 0, sizeof(status)); | ||
447 | |||
448 | switch (adapter->inframode) { | ||
449 | case wlan802_11ibss: | ||
450 | if (adapter->connect_status == libertas_connected) { | ||
451 | if (adapter->adhoccreate) | ||
452 | memcpy(&status, "AdhocStarted", sizeof(status)); | ||
453 | else | ||
454 | memcpy(&status, "AdhocJoined", sizeof(status)); | ||
455 | } else { | ||
456 | memcpy(&status, "AdhocIdle", sizeof(status)); | ||
457 | } | ||
458 | break; | ||
459 | case wlan802_11infrastructure: | ||
460 | memcpy(&status, "Inframode", sizeof(status)); | ||
461 | break; | ||
462 | default: | ||
463 | memcpy(&status, "AutoUnknownmode", sizeof(status)); | ||
464 | break; | ||
465 | } | ||
466 | |||
467 | lbs_pr_debug(1, "status = %s\n", status); | ||
468 | wrq->u.data.length = strlen(status) + 1; | ||
469 | |||
470 | if (wrq->u.data.pointer) { | ||
471 | if (copy_to_user(wrq->u.data.pointer, | ||
472 | &status, wrq->u.data.length)) | ||
473 | return -EFAULT; | ||
474 | } | ||
475 | |||
476 | LEAVE(); | ||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * @brief Set/Get WPA IE | ||
482 | * @param priv A pointer to wlan_private structure | ||
483 | * @param req A pointer to ifreq structure | ||
484 | * @return 0 --success, otherwise fail | ||
485 | */ | ||
486 | static int wlan_setwpaie_ioctl(wlan_private * priv, struct ifreq *req) | ||
487 | { | ||
488 | struct iwreq *wrq = (struct iwreq *)req; | ||
489 | wlan_adapter *adapter = priv->adapter; | ||
490 | int ret = 0; | ||
491 | |||
492 | ENTER(); | ||
493 | |||
494 | if (wrq->u.data.length) { | ||
495 | if (wrq->u.data.length > sizeof(adapter->wpa_ie)) { | ||
496 | lbs_pr_debug(1, "failed to copy WPA IE, too big \n"); | ||
497 | return -EFAULT; | ||
498 | } | ||
499 | if (copy_from_user(adapter->wpa_ie, wrq->u.data.pointer, | ||
500 | wrq->u.data.length)) { | ||
501 | lbs_pr_debug(1, "failed to copy WPA IE \n"); | ||
502 | return -EFAULT; | ||
503 | } | ||
504 | adapter->wpa_ie_len = wrq->u.data.length; | ||
505 | lbs_pr_debug(1, "Set wpa_ie_len=%d IE=%#x\n", adapter->wpa_ie_len, | ||
506 | adapter->wpa_ie[0]); | ||
507 | lbs_dbg_hex("wpa_ie", adapter->wpa_ie, adapter->wpa_ie_len); | ||
508 | if (adapter->wpa_ie[0] == WPA_IE) | ||
509 | adapter->secinfo.WPAenabled = 1; | ||
510 | else if (adapter->wpa_ie[0] == WPA2_IE) | ||
511 | adapter->secinfo.WPA2enabled = 1; | ||
512 | else { | ||
513 | adapter->secinfo.WPAenabled = 0; | ||
514 | adapter->secinfo.WPA2enabled = 0; | ||
515 | } | ||
516 | } else { | ||
517 | memset(adapter->wpa_ie, 0, sizeof(adapter->wpa_ie)); | ||
518 | adapter->wpa_ie_len = wrq->u.data.length; | ||
519 | lbs_pr_debug(1, "Reset wpa_ie_len=%d IE=%#x\n", | ||
520 | adapter->wpa_ie_len, adapter->wpa_ie[0]); | ||
521 | adapter->secinfo.WPAenabled = 0; | ||
522 | adapter->secinfo.WPA2enabled = 0; | ||
523 | } | ||
524 | |||
525 | // enable/disable RSN in firmware if WPA is enabled/disabled | ||
526 | // depending on variable adapter->secinfo.WPAenabled is set or not | ||
527 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_enable_rsn, | ||
528 | cmd_act_set, cmd_option_waitforrsp, | ||
529 | 0, NULL); | ||
530 | |||
531 | LEAVE(); | ||
532 | return ret; | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * @brief Set Auto prescan | ||
537 | * @param priv A pointer to wlan_private structure | ||
538 | * @param wrq A pointer to iwreq structure | ||
539 | * @return 0 --success, otherwise fail | ||
540 | */ | ||
541 | static int wlan_subcmd_setprescan_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
542 | { | ||
543 | int data; | ||
544 | wlan_adapter *adapter = priv->adapter; | ||
545 | int *val; | ||
546 | |||
547 | data = SUBCMD_DATA(wrq); | ||
548 | lbs_pr_debug(1, "WLAN_SUBCMD_SET_PRESCAN %d\n", data); | ||
549 | adapter->prescan = data; | ||
550 | |||
551 | val = (int *)wrq->u.name; | ||
552 | *val = data; | ||
553 | return 0; | ||
554 | } | ||
555 | |||
556 | static int wlan_set_multiple_dtim_ioctl(wlan_private * priv, struct ifreq *req) | ||
557 | { | ||
558 | struct iwreq *wrq = (struct iwreq *)req; | ||
559 | u32 mdtim; | ||
560 | int idata; | ||
561 | int ret = -EINVAL; | ||
562 | |||
563 | ENTER(); | ||
564 | |||
565 | idata = SUBCMD_DATA(wrq); | ||
566 | mdtim = (u32) idata; | ||
567 | if (((mdtim >= MRVDRV_MIN_MULTIPLE_DTIM) | ||
568 | && (mdtim <= MRVDRV_MAX_MULTIPLE_DTIM)) | ||
569 | || (mdtim == MRVDRV_IGNORE_MULTIPLE_DTIM)) { | ||
570 | priv->adapter->multipledtim = mdtim; | ||
571 | ret = 0; | ||
572 | } | ||
573 | if (ret) | ||
574 | lbs_pr_debug(1, "Invalid parameter, multipledtim not changed.\n"); | ||
575 | |||
576 | LEAVE(); | ||
577 | return ret; | ||
578 | } | ||
579 | |||
580 | /** | ||
581 | * @brief Set authentication mode | ||
582 | * @param priv A pointer to wlan_private structure | ||
583 | * @param req A pointer to ifreq structure | ||
584 | * @return 0 --success, otherwise fail | ||
585 | */ | ||
586 | static int wlan_setauthalg_ioctl(wlan_private * priv, struct ifreq *req) | ||
587 | { | ||
588 | int alg; | ||
589 | struct iwreq *wrq = (struct iwreq *)req; | ||
590 | wlan_adapter *adapter = priv->adapter; | ||
591 | |||
592 | if (wrq->u.data.flags == 0) { | ||
593 | //from iwpriv subcmd | ||
594 | alg = SUBCMD_DATA(wrq); | ||
595 | } else { | ||
596 | //from wpa_supplicant subcmd | ||
597 | if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(alg))) { | ||
598 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
599 | return -EFAULT; | ||
600 | } | ||
601 | } | ||
602 | |||
603 | lbs_pr_debug(1, "auth alg is %#x\n", alg); | ||
604 | |||
605 | switch (alg) { | ||
606 | case AUTH_ALG_SHARED_KEY: | ||
607 | adapter->secinfo.authmode = wlan802_11authmodeshared; | ||
608 | break; | ||
609 | case AUTH_ALG_NETWORK_EAP: | ||
610 | adapter->secinfo.authmode = | ||
611 | wlan802_11authmodenetworkEAP; | ||
612 | break; | ||
613 | case AUTH_ALG_OPEN_SYSTEM: | ||
614 | default: | ||
615 | adapter->secinfo.authmode = wlan802_11authmodeopen; | ||
616 | break; | ||
617 | } | ||
618 | return 0; | ||
619 | } | ||
620 | |||
621 | /** | ||
622 | * @brief Set 802.1x authentication mode | ||
623 | * @param priv A pointer to wlan_private structure | ||
624 | * @param req A pointer to ifreq structure | ||
625 | * @return 0 --success, otherwise fail | ||
626 | */ | ||
627 | static int wlan_set8021xauthalg_ioctl(wlan_private * priv, struct ifreq *req) | ||
628 | { | ||
629 | int alg; | ||
630 | struct iwreq *wrq = (struct iwreq *)req; | ||
631 | |||
632 | if (wrq->u.data.flags == 0) { | ||
633 | //from iwpriv subcmd | ||
634 | alg = SUBCMD_DATA(wrq); | ||
635 | } else { | ||
636 | //from wpa_supplicant subcmd | ||
637 | if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(int))) { | ||
638 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
639 | return -EFAULT; | ||
640 | } | ||
641 | } | ||
642 | lbs_pr_debug(1, "802.1x auth alg is %#x\n", alg); | ||
643 | priv->adapter->secinfo.auth1xalg = alg; | ||
644 | return 0; | ||
645 | } | ||
646 | |||
647 | static int wlan_setencryptionmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
648 | { | ||
649 | int mode; | ||
650 | struct iwreq *wrq = (struct iwreq *)req; | ||
651 | |||
652 | ENTER(); | ||
653 | |||
654 | if (wrq->u.data.flags == 0) { | ||
655 | //from iwpriv subcmd | ||
656 | mode = SUBCMD_DATA(wrq); | ||
657 | } else { | ||
658 | //from wpa_supplicant subcmd | ||
659 | if (copy_from_user(&mode, wrq->u.data.pointer, sizeof(int))) { | ||
660 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
661 | return -EFAULT; | ||
662 | } | ||
663 | } | ||
664 | lbs_pr_debug(1, "encryption mode is %#x\n", mode); | ||
665 | priv->adapter->secinfo.Encryptionmode = mode; | ||
666 | |||
667 | LEAVE(); | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | static void adjust_mtu(wlan_private * priv) | ||
672 | { | ||
673 | int mtu_increment = 0; | ||
674 | |||
675 | if (priv->adapter->linkmode == WLAN_LINKMODE_802_11) | ||
676 | mtu_increment += sizeof(struct ieee80211_hdr_4addr); | ||
677 | |||
678 | if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP) | ||
679 | mtu_increment += max(sizeof(struct tx_radiotap_hdr), | ||
680 | sizeof(struct rx_radiotap_hdr)); | ||
681 | priv->wlan_dev.netdev->mtu = ETH_FRAME_LEN | ||
682 | - sizeof(struct ethhdr) | ||
683 | + mtu_increment; | ||
684 | } | ||
685 | |||
686 | /** | ||
687 | * @brief Set Link-Layer Layer mode | ||
688 | * @param priv A pointer to wlan_private structure | ||
689 | * @param req A pointer to ifreq structure | ||
690 | * @return 0 --success, otherwise fail | ||
691 | */ | ||
692 | static int wlan_set_linkmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
693 | { | ||
694 | int mode; | ||
695 | |||
696 | mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; | ||
697 | |||
698 | switch (mode) { | ||
699 | case WLAN_LINKMODE_802_3: | ||
700 | priv->adapter->linkmode = mode; | ||
701 | break; | ||
702 | case WLAN_LINKMODE_802_11: | ||
703 | priv->adapter->linkmode = mode; | ||
704 | break; | ||
705 | default: | ||
706 | lbs_pr_info("usb8388-5: invalid link-layer mode (%#x)\n", | ||
707 | mode); | ||
708 | return -EINVAL; | ||
709 | break; | ||
710 | } | ||
711 | lbs_pr_debug(1, "usb8388-5: link-layer mode is %#x\n", mode); | ||
712 | |||
713 | adjust_mtu(priv); | ||
714 | |||
715 | return 0; | ||
716 | } | ||
717 | |||
718 | /** | ||
719 | * @brief Set Radio header mode | ||
720 | * @param priv A pointer to wlan_private structure | ||
721 | * @param req A pointer to ifreq structure | ||
722 | * @return 0 --success, otherwise fail | ||
723 | */ | ||
724 | static int wlan_set_radiomode_ioctl(wlan_private * priv, struct ifreq *req) | ||
725 | { | ||
726 | int mode; | ||
727 | |||
728 | mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; | ||
729 | |||
730 | switch (mode) { | ||
731 | case WLAN_RADIOMODE_NONE: | ||
732 | priv->adapter->radiomode = mode; | ||
733 | break; | ||
734 | case WLAN_RADIOMODE_RADIOTAP: | ||
735 | priv->adapter->radiomode = mode; | ||
736 | break; | ||
737 | default: | ||
738 | lbs_pr_debug(1, "usb8388-5: invalid radio header mode (%#x)\n", | ||
739 | mode); | ||
740 | return -EINVAL; | ||
741 | } | ||
742 | lbs_pr_debug(1, "usb8388-5: radio-header mode is %#x\n", mode); | ||
743 | |||
744 | adjust_mtu(priv); | ||
745 | return 0; | ||
746 | } | ||
747 | |||
748 | /** | ||
749 | * @brief Set Debug header mode | ||
750 | * @param priv A pointer to wlan_private structure | ||
751 | * @param req A pointer to ifreq structure | ||
752 | * @return 0 --success, otherwise fail | ||
753 | */ | ||
754 | static int wlan_set_debugmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
755 | { | ||
756 | priv->adapter->debugmode = (int)((struct ifreq *) | ||
757 | ((u8 *) req + 4))->ifr_data; | ||
758 | return 0; | ||
759 | } | ||
760 | |||
761 | static int wlan_subcmd_getrxantenna_ioctl(wlan_private * priv, | ||
762 | struct ifreq *req) | ||
763 | { | ||
764 | int len; | ||
765 | char buf[8]; | ||
766 | struct iwreq *wrq = (struct iwreq *)req; | ||
767 | |||
768 | lbs_pr_debug(1, "WLAN_SUBCMD_GETRXANTENNA\n"); | ||
769 | len = getrxantenna(priv, buf); | ||
770 | |||
771 | wrq->u.data.length = len; | ||
772 | if (wrq->u.data.pointer) { | ||
773 | if (copy_to_user(wrq->u.data.pointer, &buf, len)) { | ||
774 | lbs_pr_debug(1, "CopyToUser failed\n"); | ||
775 | return -EFAULT; | ||
776 | } | ||
777 | } | ||
778 | |||
779 | return 0; | ||
780 | } | ||
781 | |||
782 | static int wlan_subcmd_gettxantenna_ioctl(wlan_private * priv, | ||
783 | struct ifreq *req) | ||
784 | { | ||
785 | int len; | ||
786 | char buf[8]; | ||
787 | struct iwreq *wrq = (struct iwreq *)req; | ||
788 | |||
789 | lbs_pr_debug(1, "WLAN_SUBCMD_GETTXANTENNA\n"); | ||
790 | len = gettxantenna(priv, buf); | ||
791 | |||
792 | wrq->u.data.length = len; | ||
793 | if (wrq->u.data.pointer) { | ||
794 | if (copy_to_user(wrq->u.data.pointer, &buf, len)) { | ||
795 | lbs_pr_debug(1, "CopyToUser failed\n"); | ||
796 | return -EFAULT; | ||
797 | } | ||
798 | } | ||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | /** | ||
803 | * @brief Get the MAC TSF value from the firmware | ||
804 | * | ||
805 | * @param priv A pointer to wlan_private structure | ||
806 | * @param wrq A pointer to iwreq structure containing buffer | ||
807 | * space to store a TSF value retrieved from the firmware | ||
808 | * | ||
809 | * @return 0 if successful; IOCTL error code otherwise | ||
810 | */ | ||
811 | static int wlan_get_tsf_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
812 | { | ||
813 | u64 tsfval; | ||
814 | int ret; | ||
815 | |||
816 | ret = libertas_prepare_and_send_command(priv, | ||
817 | cmd_get_tsf, | ||
818 | 0, cmd_option_waitforrsp, 0, &tsfval); | ||
819 | |||
820 | lbs_pr_debug(1, "IOCTL: Get TSF = 0x%016llx\n", tsfval); | ||
821 | |||
822 | if (ret != 0) { | ||
823 | lbs_pr_debug(1, "IOCTL: Get TSF; command exec failed\n"); | ||
824 | ret = -EFAULT; | ||
825 | } else { | ||
826 | if (copy_to_user(wrq->u.data.pointer, | ||
827 | &tsfval, | ||
828 | min_t(size_t, wrq->u.data.length, | ||
829 | sizeof(tsfval))) != 0) { | ||
830 | |||
831 | lbs_pr_debug(1, "IOCTL: Get TSF; Copy to user failed\n"); | ||
832 | ret = -EFAULT; | ||
833 | } else { | ||
834 | ret = 0; | ||
835 | } | ||
836 | } | ||
837 | return ret; | ||
838 | } | ||
839 | |||
840 | /** | ||
841 | * @brief Get/Set adapt rate | ||
842 | * @param priv A pointer to wlan_private structure | ||
843 | * @param wrq A pointer to iwreq structure | ||
844 | * @return 0 --success, otherwise fail | ||
845 | */ | ||
846 | static int wlan_adapt_rateset(wlan_private * priv, struct iwreq *wrq) | ||
847 | { | ||
848 | int ret; | ||
849 | wlan_adapter *adapter = priv->adapter; | ||
850 | int data[2]; | ||
851 | |||
852 | memset(data, 0, sizeof(data)); | ||
853 | if (!wrq->u.data.length) { | ||
854 | lbs_pr_debug(1, "Get ADAPT RATE SET\n"); | ||
855 | ret = libertas_prepare_and_send_command(priv, | ||
856 | cmd_802_11_rate_adapt_rateset, | ||
857 | cmd_act_get, | ||
858 | cmd_option_waitforrsp, 0, NULL); | ||
859 | data[0] = adapter->enablehwauto; | ||
860 | data[1] = adapter->ratebitmap; | ||
861 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { | ||
862 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
863 | return -EFAULT; | ||
864 | } | ||
865 | #define GET_TWO_INT 2 | ||
866 | wrq->u.data.length = GET_TWO_INT; | ||
867 | } else { | ||
868 | lbs_pr_debug(1, "Set ADAPT RATE SET\n"); | ||
869 | if (wrq->u.data.length > 2) | ||
870 | return -EINVAL; | ||
871 | if (copy_from_user | ||
872 | (data, wrq->u.data.pointer, | ||
873 | sizeof(int) * wrq->u.data.length)) { | ||
874 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
875 | return -EFAULT; | ||
876 | } | ||
877 | |||
878 | adapter->enablehwauto = data[0]; | ||
879 | adapter->ratebitmap = data[1]; | ||
880 | ret = libertas_prepare_and_send_command(priv, | ||
881 | cmd_802_11_rate_adapt_rateset, | ||
882 | cmd_act_set, | ||
883 | cmd_option_waitforrsp, 0, NULL); | ||
884 | } | ||
885 | return ret; | ||
886 | } | ||
887 | |||
888 | /** | ||
889 | * @brief Get/Set inactivity timeout | ||
890 | * @param priv A pointer to wlan_private structure | ||
891 | * @param wrq A pointer to iwreq structure | ||
892 | * @return 0 --success, otherwise fail | ||
893 | */ | ||
894 | static int wlan_inactivity_timeout(wlan_private * priv, struct iwreq *wrq) | ||
895 | { | ||
896 | int ret; | ||
897 | int data = 0; | ||
898 | u16 timeout = 0; | ||
899 | |||
900 | ENTER(); | ||
901 | if (wrq->u.data.length > 1) | ||
902 | return -ENOTSUPP; | ||
903 | |||
904 | if (wrq->u.data.length == 0) { | ||
905 | /* Get */ | ||
906 | ret = libertas_prepare_and_send_command(priv, | ||
907 | cmd_802_11_inactivity_timeout, | ||
908 | cmd_act_get, | ||
909 | cmd_option_waitforrsp, 0, | ||
910 | &timeout); | ||
911 | data = timeout; | ||
912 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { | ||
913 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
914 | return -EFAULT; | ||
915 | } | ||
916 | } else { | ||
917 | /* Set */ | ||
918 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
919 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
920 | return -EFAULT; | ||
921 | } | ||
922 | |||
923 | timeout = data; | ||
924 | ret = libertas_prepare_and_send_command(priv, | ||
925 | cmd_802_11_inactivity_timeout, | ||
926 | cmd_act_set, | ||
927 | cmd_option_waitforrsp, 0, | ||
928 | &timeout); | ||
929 | } | ||
930 | |||
931 | wrq->u.data.length = 1; | ||
932 | |||
933 | LEAVE(); | ||
934 | return ret; | ||
935 | } | ||
936 | |||
937 | static int wlan_do_getlog_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
938 | { | ||
939 | int ret; | ||
940 | char buf[GETLOG_BUFSIZE - 1]; | ||
941 | wlan_adapter *adapter = priv->adapter; | ||
942 | |||
943 | lbs_pr_debug(1, " GET STATS\n"); | ||
944 | |||
945 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_get_log, | ||
946 | 0, cmd_option_waitforrsp, 0, NULL); | ||
947 | |||
948 | if (ret) { | ||
949 | return ret; | ||
950 | } | ||
951 | |||
952 | if (wrq->u.data.pointer) { | ||
953 | sprintf(buf, "\n mcasttxframe %u failed %u retry %u " | ||
954 | "multiretry %u framedup %u " | ||
955 | "rtssuccess %u rtsfailure %u ackfailure %u\n" | ||
956 | "rxfrag %u mcastrxframe %u fcserror %u " | ||
957 | "txframe %u wepundecryptable %u ", | ||
958 | adapter->logmsg.mcasttxframe, | ||
959 | adapter->logmsg.failed, | ||
960 | adapter->logmsg.retry, | ||
961 | adapter->logmsg.multiretry, | ||
962 | adapter->logmsg.framedup, | ||
963 | adapter->logmsg.rtssuccess, | ||
964 | adapter->logmsg.rtsfailure, | ||
965 | adapter->logmsg.ackfailure, | ||
966 | adapter->logmsg.rxfrag, | ||
967 | adapter->logmsg.mcastrxframe, | ||
968 | adapter->logmsg.fcserror, | ||
969 | adapter->logmsg.txframe, | ||
970 | adapter->logmsg.wepundecryptable); | ||
971 | wrq->u.data.length = strlen(buf) + 1; | ||
972 | if (copy_to_user(wrq->u.data.pointer, buf, wrq->u.data.length)) { | ||
973 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
974 | return -EFAULT; | ||
975 | } | ||
976 | } | ||
977 | |||
978 | return 0; | ||
979 | } | ||
980 | |||
981 | static int wlan_scan_type_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
982 | { | ||
983 | u8 buf[12]; | ||
984 | u8 *option[] = { "active", "passive", "get", }; | ||
985 | int i, max_options = (sizeof(option) / sizeof(option[0])); | ||
986 | int ret = 0; | ||
987 | wlan_adapter *adapter = priv->adapter; | ||
988 | |||
989 | if (priv->adapter->enable11d) { | ||
990 | lbs_pr_debug(1, "11D: Cannot set scantype when 11D enabled\n"); | ||
991 | return -EFAULT; | ||
992 | } | ||
993 | |||
994 | memset(buf, 0, sizeof(buf)); | ||
995 | |||
996 | if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), | ||
997 | wrq->u.data.length))) | ||
998 | return -EFAULT; | ||
999 | |||
1000 | lbs_pr_debug(1, "Scan type Option = %s\n", buf); | ||
1001 | |||
1002 | buf[sizeof(buf) - 1] = '\0'; | ||
1003 | |||
1004 | for (i = 0; i < max_options; i++) { | ||
1005 | if (!strcmp(buf, option[i])) | ||
1006 | break; | ||
1007 | } | ||
1008 | |||
1009 | switch (i) { | ||
1010 | case 0: | ||
1011 | adapter->scantype = cmd_scan_type_active; | ||
1012 | break; | ||
1013 | case 1: | ||
1014 | adapter->scantype = cmd_scan_type_passive; | ||
1015 | break; | ||
1016 | case 2: | ||
1017 | wrq->u.data.length = strlen(option[adapter->scantype]) + 1; | ||
1018 | |||
1019 | if (copy_to_user(wrq->u.data.pointer, | ||
1020 | option[adapter->scantype], | ||
1021 | wrq->u.data.length)) { | ||
1022 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
1023 | ret = -EFAULT; | ||
1024 | } | ||
1025 | |||
1026 | break; | ||
1027 | default: | ||
1028 | lbs_pr_debug(1, "Invalid Scan type Ioctl Option\n"); | ||
1029 | ret = -EINVAL; | ||
1030 | break; | ||
1031 | } | ||
1032 | |||
1033 | return ret; | ||
1034 | } | ||
1035 | |||
1036 | static int wlan_scan_mode_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
1037 | { | ||
1038 | wlan_adapter *adapter = priv->adapter; | ||
1039 | u8 buf[12]; | ||
1040 | u8 *option[] = { "bss", "ibss", "any", "get" }; | ||
1041 | int i, max_options = (sizeof(option) / sizeof(option[0])); | ||
1042 | int ret = 0; | ||
1043 | |||
1044 | ENTER(); | ||
1045 | |||
1046 | memset(buf, 0, sizeof(buf)); | ||
1047 | |||
1048 | if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), | ||
1049 | wrq->u.data.length))) { | ||
1050 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
1051 | return -EFAULT; | ||
1052 | } | ||
1053 | |||
1054 | lbs_pr_debug(1, "Scan mode Option = %s\n", buf); | ||
1055 | |||
1056 | buf[sizeof(buf) - 1] = '\0'; | ||
1057 | |||
1058 | for (i = 0; i < max_options; i++) { | ||
1059 | if (!strcmp(buf, option[i])) | ||
1060 | break; | ||
1061 | } | ||
1062 | |||
1063 | switch (i) { | ||
1064 | |||
1065 | case 0: | ||
1066 | adapter->scanmode = cmd_bss_type_bss; | ||
1067 | break; | ||
1068 | case 1: | ||
1069 | adapter->scanmode = cmd_bss_type_ibss; | ||
1070 | break; | ||
1071 | case 2: | ||
1072 | adapter->scanmode = cmd_bss_type_any; | ||
1073 | break; | ||
1074 | case 3: | ||
1075 | |||
1076 | wrq->u.data.length = strlen(option[adapter->scanmode - 1]) + 1; | ||
1077 | |||
1078 | lbs_pr_debug(1, "Get Scan mode Option = %s\n", | ||
1079 | option[adapter->scanmode - 1]); | ||
1080 | |||
1081 | lbs_pr_debug(1, "Scan mode length %d\n", wrq->u.data.length); | ||
1082 | |||
1083 | if (copy_to_user(wrq->u.data.pointer, | ||
1084 | option[adapter->scanmode - 1], | ||
1085 | wrq->u.data.length)) { | ||
1086 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
1087 | ret = -EFAULT; | ||
1088 | } | ||
1089 | lbs_pr_debug(1, "GET Scan type Option after copy = %s\n", | ||
1090 | (char *)wrq->u.data.pointer); | ||
1091 | |||
1092 | break; | ||
1093 | |||
1094 | default: | ||
1095 | lbs_pr_debug(1, "Invalid Scan mode Ioctl Option\n"); | ||
1096 | ret = -EINVAL; | ||
1097 | break; | ||
1098 | } | ||
1099 | |||
1100 | LEAVE(); | ||
1101 | return ret; | ||
1102 | } | ||
1103 | |||
1104 | /** | ||
1105 | * @brief Get/Set Adhoc G Rate | ||
1106 | * | ||
1107 | * @param priv A pointer to wlan_private structure | ||
1108 | * @param wrq A pointer to user data | ||
1109 | * @return 0--success, otherwise fail | ||
1110 | */ | ||
1111 | static int wlan_do_set_grate_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
1112 | { | ||
1113 | wlan_adapter *adapter = priv->adapter; | ||
1114 | int data, data1; | ||
1115 | int *val; | ||
1116 | |||
1117 | ENTER(); | ||
1118 | |||
1119 | data1 = SUBCMD_DATA(wrq); | ||
1120 | switch (data1) { | ||
1121 | case 0: | ||
1122 | adapter->adhoc_grate_enabled = 0; | ||
1123 | break; | ||
1124 | case 1: | ||
1125 | adapter->adhoc_grate_enabled = 1; | ||
1126 | break; | ||
1127 | case 2: | ||
1128 | break; | ||
1129 | default: | ||
1130 | return -EINVAL; | ||
1131 | } | ||
1132 | data = adapter->adhoc_grate_enabled; | ||
1133 | val = (int *)wrq->u.name; | ||
1134 | *val = data; | ||
1135 | LEAVE(); | ||
1136 | return 0; | ||
1137 | } | ||
1138 | |||
1139 | static inline int hex2int(char c) | 58 | static inline int hex2int(char c) |
1140 | { | 59 | { |
1141 | if (c >= '0' && c <= '9') | 60 | if (c >= '0' && c <= '9') |
@@ -1761,6 +680,7 @@ static int wlan_fwt_list_neighbor_ioctl(wlan_private * priv, struct ifreq *req) | |||
1761 | */ | 680 | */ |
1762 | static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) | 681 | static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) |
1763 | { | 682 | { |
683 | struct iwreq *wrq = (struct iwreq *)req; | ||
1764 | static struct cmd_ds_fwt_access fwt_access; | 684 | static struct cmd_ds_fwt_access fwt_access; |
1765 | int ret; | 685 | int ret; |
1766 | 686 | ||
@@ -1776,7 +696,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) | |||
1776 | (void *)&fwt_access); | 696 | (void *)&fwt_access); |
1777 | 697 | ||
1778 | if (ret == 0) | 698 | if (ret == 0) |
1779 | req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); | 699 | wrq->u.param.value = le32_to_cpu(fwt_access.references); |
1780 | else | 700 | else |
1781 | return -EFAULT; | 701 | return -EFAULT; |
1782 | 702 | ||
@@ -1792,6 +712,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) | |||
1792 | */ | 712 | */ |
1793 | static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) | 713 | static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) |
1794 | { | 714 | { |
715 | struct iwreq *wrq = (struct iwreq *)req; | ||
1795 | static struct cmd_ds_fwt_access fwt_access; | 716 | static struct cmd_ds_fwt_access fwt_access; |
1796 | int ret; | 717 | int ret; |
1797 | 718 | ||
@@ -1807,7 +728,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) | |||
1807 | (void *)&fwt_access); | 728 | (void *)&fwt_access); |
1808 | 729 | ||
1809 | if (ret == 0) | 730 | if (ret == 0) |
1810 | req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); | 731 | wrq->u.param.value = le32_to_cpu(fwt_access.references); |
1811 | else | 732 | else |
1812 | return -EFAULT; | 733 | return -EFAULT; |
1813 | 734 | ||
@@ -1823,6 +744,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) | |||
1823 | */ | 744 | */ |
1824 | static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) | 745 | static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) |
1825 | { | 746 | { |
747 | struct iwreq *wrq = (struct iwreq *)req; | ||
1826 | struct cmd_ds_mesh_access mesh_access; | 748 | struct cmd_ds_mesh_access mesh_access; |
1827 | int ret; | 749 | int ret; |
1828 | 750 | ||
@@ -1835,9 +757,8 @@ static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) | |||
1835 | cmd_option_waitforrsp, 0, | 757 | cmd_option_waitforrsp, 0, |
1836 | (void *)&mesh_access); | 758 | (void *)&mesh_access); |
1837 | 759 | ||
1838 | if (ret == 0) { | 760 | if (ret == 0) |
1839 | req->ifr_data = (char *)(le32_to_cpu(mesh_access.data[0])); | 761 | wrq->u.param.value = le32_to_cpu(mesh_access.data[0]); |
1840 | } | ||
1841 | else | 762 | else |
1842 | return -EFAULT; | 763 | return -EFAULT; |
1843 | 764 | ||
@@ -1898,36 +819,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1898 | 819 | ||
1899 | lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); | 820 | lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); |
1900 | switch (cmd) { | 821 | switch (cmd) { |
1901 | case WLANSCAN_TYPE: | ||
1902 | lbs_pr_debug(1, "Scan type Ioctl\n"); | ||
1903 | ret = wlan_scan_type_ioctl(priv, wrq); | ||
1904 | break; | ||
1905 | |||
1906 | case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ | 822 | case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ |
1907 | switch (wrq->u.data.flags) { | 823 | switch (wrq->u.data.flags) { |
1908 | case WLANDEAUTH: | ||
1909 | lbs_pr_debug(1, "Deauth\n"); | ||
1910 | libertas_send_deauth(priv); | ||
1911 | break; | ||
1912 | |||
1913 | case WLANADHOCSTOP: | ||
1914 | lbs_pr_debug(1, "Adhoc stop\n"); | ||
1915 | ret = libertas_do_adhocstop_ioctl(priv); | ||
1916 | break; | ||
1917 | |||
1918 | case WLANRADIOON: | ||
1919 | wlan_radio_ioctl(priv, 1); | ||
1920 | break; | ||
1921 | |||
1922 | case WLANRADIOOFF: | ||
1923 | wlan_radio_ioctl(priv, 0); | ||
1924 | break; | ||
1925 | case WLANWLANIDLEON: | ||
1926 | libertas_idle_on(priv); | ||
1927 | break; | ||
1928 | case WLANWLANIDLEOFF: | ||
1929 | libertas_idle_off(priv); | ||
1930 | break; | ||
1931 | case WLAN_SUBCMD_BT_RESET: /* bt_reset */ | 824 | case WLAN_SUBCMD_BT_RESET: /* bt_reset */ |
1932 | wlan_bt_reset_ioctl(priv); | 825 | wlan_bt_reset_ioctl(priv); |
1933 | break; | 826 | break; |
@@ -1937,162 +830,19 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1937 | } /* End of switch */ | 830 | } /* End of switch */ |
1938 | break; | 831 | break; |
1939 | 832 | ||
1940 | case WLANSETWPAIE: | ||
1941 | ret = wlan_setwpaie_ioctl(priv, req); | ||
1942 | break; | ||
1943 | case WLAN_SETINT_GETINT: | ||
1944 | /* The first 4 bytes of req->ifr_data is sub-ioctl number | ||
1945 | * after 4 bytes sits the payload. | ||
1946 | */ | ||
1947 | subcmd = (int)req->ifr_data; //from iwpriv subcmd | ||
1948 | switch (subcmd) { | ||
1949 | case WLANNF: | ||
1950 | ret = wlan_get_nf(priv, wrq); | ||
1951 | break; | ||
1952 | case WLANRSSI: | ||
1953 | ret = wlan_get_rssi(priv, wrq); | ||
1954 | break; | ||
1955 | case WLANENABLE11D: | ||
1956 | ret = libertas_cmd_enable_11d(priv, wrq); | ||
1957 | break; | ||
1958 | case WLANADHOCGRATE: | ||
1959 | ret = wlan_do_set_grate_ioctl(priv, wrq); | ||
1960 | break; | ||
1961 | case WLAN_SUBCMD_SET_PRESCAN: | ||
1962 | ret = wlan_subcmd_setprescan_ioctl(priv, wrq); | ||
1963 | break; | ||
1964 | } | ||
1965 | break; | ||
1966 | |||
1967 | case WLAN_SETONEINT_GETONEINT: | ||
1968 | switch (wrq->u.data.flags) { | ||
1969 | case WLAN_BEACON_INTERVAL: | ||
1970 | ret = wlan_beacon_interval(priv, wrq); | ||
1971 | break; | ||
1972 | |||
1973 | case WLAN_LISTENINTRVL: | ||
1974 | if (!wrq->u.data.length) { | ||
1975 | int data; | ||
1976 | lbs_pr_debug(1, "Get locallisteninterval value\n"); | ||
1977 | #define GET_ONE_INT 1 | ||
1978 | data = adapter->locallisteninterval; | ||
1979 | if (copy_to_user(wrq->u.data.pointer, | ||
1980 | &data, sizeof(int))) { | ||
1981 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
1982 | return -EFAULT; | ||
1983 | } | ||
1984 | |||
1985 | wrq->u.data.length = GET_ONE_INT; | ||
1986 | } else { | ||
1987 | int data; | ||
1988 | if (copy_from_user | ||
1989 | (&data, wrq->u.data.pointer, sizeof(int))) { | ||
1990 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
1991 | return -EFAULT; | ||
1992 | } | ||
1993 | |||
1994 | lbs_pr_debug(1, "Set locallisteninterval = %d\n", | ||
1995 | data); | ||
1996 | #define MAX_U16_VAL 65535 | ||
1997 | if (data > MAX_U16_VAL) { | ||
1998 | lbs_pr_debug(1, "Exceeds U16 value\n"); | ||
1999 | return -EINVAL; | ||
2000 | } | ||
2001 | adapter->locallisteninterval = data; | ||
2002 | } | ||
2003 | break; | ||
2004 | case WLAN_TXCONTROL: | ||
2005 | ret = wlan_txcontrol(priv, wrq); //adds for txcontrol ioctl | ||
2006 | break; | ||
2007 | |||
2008 | case WLAN_NULLPKTINTERVAL: | ||
2009 | ret = wlan_null_pkt_interval(priv, wrq); | ||
2010 | break; | ||
2011 | |||
2012 | default: | ||
2013 | ret = -EOPNOTSUPP; | ||
2014 | break; | ||
2015 | } | ||
2016 | break; | ||
2017 | |||
2018 | case WLAN_SETONEINT_GETNONE: | 833 | case WLAN_SETONEINT_GETNONE: |
2019 | /* The first 4 bytes of req->ifr_data is sub-ioctl number | 834 | /* The first 4 bytes of req->ifr_data is sub-ioctl number |
2020 | * after 4 bytes sits the payload. | 835 | * after 4 bytes sits the payload. |
2021 | */ | 836 | */ |
2022 | subcmd = wrq->u.data.flags; //from wpa_supplicant subcmd | 837 | subcmd = wrq->u.data.flags; |
2023 | |||
2024 | if (!subcmd) | 838 | if (!subcmd) |
2025 | subcmd = (int)req->ifr_data; //from iwpriv subcmd | 839 | subcmd = (int)wrq->u.param.value; |
2026 | 840 | ||
2027 | switch (subcmd) { | 841 | switch (subcmd) { |
2028 | case WLAN_SUBCMD_SETRXANTENNA: /* SETRXANTENNA */ | ||
2029 | idata = SUBCMD_DATA(wrq); | ||
2030 | ret = setrxantenna(priv, idata); | ||
2031 | break; | ||
2032 | case WLAN_SUBCMD_SETTXANTENNA: /* SETTXANTENNA */ | ||
2033 | idata = SUBCMD_DATA(wrq); | ||
2034 | ret = settxantenna(priv, idata); | ||
2035 | break; | ||
2036 | case WLAN_SET_ATIM_WINDOW: | ||
2037 | adapter->atimwindow = SUBCMD_DATA(wrq); | ||
2038 | adapter->atimwindow = min_t(__u16, adapter->atimwindow, 50); | ||
2039 | break; | ||
2040 | case WLANSETBCNAVG: | ||
2041 | adapter->bcn_avg_factor = SUBCMD_DATA(wrq); | ||
2042 | if (adapter->bcn_avg_factor == 0) | ||
2043 | adapter->bcn_avg_factor = | ||
2044 | DEFAULT_BCN_AVG_FACTOR; | ||
2045 | if (adapter->bcn_avg_factor > DEFAULT_BCN_AVG_FACTOR) | ||
2046 | adapter->bcn_avg_factor = | ||
2047 | DEFAULT_BCN_AVG_FACTOR; | ||
2048 | break; | ||
2049 | case WLANSETDATAAVG: | ||
2050 | adapter->data_avg_factor = SUBCMD_DATA(wrq); | ||
2051 | if (adapter->data_avg_factor == 0) | ||
2052 | adapter->data_avg_factor = | ||
2053 | DEFAULT_DATA_AVG_FACTOR; | ||
2054 | if (adapter->data_avg_factor > DEFAULT_DATA_AVG_FACTOR) | ||
2055 | adapter->data_avg_factor = | ||
2056 | DEFAULT_DATA_AVG_FACTOR; | ||
2057 | break; | ||
2058 | case WLANSETREGION: | 842 | case WLANSETREGION: |
2059 | idata = SUBCMD_DATA(wrq); | 843 | idata = SUBCMD_DATA(wrq); |
2060 | ret = wlan_set_region(priv, (u16) idata); | 844 | ret = wlan_set_region(priv, (u16) idata); |
2061 | break; | 845 | break; |
2062 | |||
2063 | case WLAN_SET_LISTEN_INTERVAL: | ||
2064 | idata = SUBCMD_DATA(wrq); | ||
2065 | adapter->listeninterval = (u16) idata; | ||
2066 | break; | ||
2067 | |||
2068 | case WLAN_SET_MULTIPLE_DTIM: | ||
2069 | ret = wlan_set_multiple_dtim_ioctl(priv, req); | ||
2070 | break; | ||
2071 | |||
2072 | case WLANSETAUTHALG: | ||
2073 | ret = wlan_setauthalg_ioctl(priv, req); | ||
2074 | break; | ||
2075 | |||
2076 | case WLANSET8021XAUTHALG: | ||
2077 | ret = wlan_set8021xauthalg_ioctl(priv, req); | ||
2078 | break; | ||
2079 | |||
2080 | case WLANSETENCRYPTIONMODE: | ||
2081 | ret = wlan_setencryptionmode_ioctl(priv, req); | ||
2082 | break; | ||
2083 | |||
2084 | case WLAN_SET_LINKMODE: | ||
2085 | ret = wlan_set_linkmode_ioctl(priv, req); | ||
2086 | break; | ||
2087 | |||
2088 | case WLAN_SET_RADIOMODE: | ||
2089 | ret = wlan_set_radiomode_ioctl(priv, req); | ||
2090 | break; | ||
2091 | |||
2092 | case WLAN_SET_DEBUGMODE: | ||
2093 | ret = wlan_set_debugmode_ioctl(priv, req); | ||
2094 | break; | ||
2095 | |||
2096 | case WLAN_SUBCMD_MESH_SET_TTL: | 846 | case WLAN_SUBCMD_MESH_SET_TTL: |
2097 | idata = SUBCMD_DATA(wrq); | 847 | idata = SUBCMD_DATA(wrq); |
2098 | ret = wlan_mesh_set_ttl_ioctl(priv, idata); | 848 | ret = wlan_mesh_set_ttl_ioctl(priv, idata); |
@@ -2105,38 +855,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2105 | 855 | ||
2106 | break; | 856 | break; |
2107 | 857 | ||
2108 | case WLAN_SETNONE_GETTWELVE_CHAR: /* Get Antenna settings */ | ||
2109 | /* | ||
2110 | * We've not used IW_PRIV_TYPE_FIXED so sub-ioctl number is | ||
2111 | * in flags of iwreq structure, otherwise it will be in | ||
2112 | * mode member of iwreq structure. | ||
2113 | */ | ||
2114 | switch ((int)wrq->u.data.flags) { | ||
2115 | case WLAN_SUBCMD_GETRXANTENNA: /* Get Rx Antenna */ | ||
2116 | ret = wlan_subcmd_getrxantenna_ioctl(priv, req); | ||
2117 | break; | ||
2118 | |||
2119 | case WLAN_SUBCMD_GETTXANTENNA: /* Get Tx Antenna */ | ||
2120 | ret = wlan_subcmd_gettxantenna_ioctl(priv, req); | ||
2121 | break; | ||
2122 | |||
2123 | case WLAN_GET_TSF: | ||
2124 | ret = wlan_get_tsf_ioctl(priv, wrq); | ||
2125 | break; | ||
2126 | } | ||
2127 | break; | ||
2128 | |||
2129 | case WLAN_SET128CHAR_GET128CHAR: | 858 | case WLAN_SET128CHAR_GET128CHAR: |
2130 | switch ((int)wrq->u.data.flags) { | 859 | switch ((int)wrq->u.data.flags) { |
2131 | |||
2132 | case WLANSCAN_MODE: | ||
2133 | lbs_pr_debug(1, "Scan mode Ioctl\n"); | ||
2134 | ret = wlan_scan_mode_ioctl(priv, wrq); | ||
2135 | break; | ||
2136 | |||
2137 | case WLAN_GET_ADHOC_STATUS: | ||
2138 | ret = wlan_get_adhoc_status_ioctl(priv, wrq); | ||
2139 | break; | ||
2140 | case WLAN_SUBCMD_BT_ADD: | 860 | case WLAN_SUBCMD_BT_ADD: |
2141 | ret = wlan_bt_add_ioctl(priv, req); | 861 | ret = wlan_bt_add_ioctl(priv, req); |
2142 | break; | 862 | break; |
@@ -2168,41 +888,11 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2168 | break; | 888 | break; |
2169 | 889 | ||
2170 | case WLAN_SETNONE_GETONEINT: | 890 | case WLAN_SETNONE_GETONEINT: |
2171 | switch ((int)req->ifr_data) { | 891 | switch (wrq->u.param.value) { |
2172 | case WLANGETBCNAVG: | ||
2173 | pdata = (int *)wrq->u.name; | ||
2174 | *pdata = (int)adapter->bcn_avg_factor; | ||
2175 | break; | ||
2176 | |||
2177 | case WLANGETREGION: | 892 | case WLANGETREGION: |
2178 | pdata = (int *)wrq->u.name; | 893 | pdata = (int *)wrq->u.name; |
2179 | *pdata = (int)adapter->regioncode; | 894 | *pdata = (int)adapter->regioncode; |
2180 | break; | 895 | break; |
2181 | |||
2182 | case WLAN_GET_LISTEN_INTERVAL: | ||
2183 | pdata = (int *)wrq->u.name; | ||
2184 | *pdata = (int)adapter->listeninterval; | ||
2185 | break; | ||
2186 | |||
2187 | case WLAN_GET_LINKMODE: | ||
2188 | req->ifr_data = (char *)((u32) adapter->linkmode); | ||
2189 | break; | ||
2190 | |||
2191 | case WLAN_GET_RADIOMODE: | ||
2192 | req->ifr_data = (char *)((u32) adapter->radiomode); | ||
2193 | break; | ||
2194 | |||
2195 | case WLAN_GET_DEBUGMODE: | ||
2196 | req->ifr_data = (char *)((u32) adapter->debugmode); | ||
2197 | break; | ||
2198 | |||
2199 | case WLAN_GET_MULTIPLE_DTIM: | ||
2200 | pdata = (int *)wrq->u.name; | ||
2201 | *pdata = (int)adapter->multipledtim; | ||
2202 | break; | ||
2203 | case WLAN_GET_TX_RATE: | ||
2204 | ret = wlan_get_txrate_ioctl(priv, req); | ||
2205 | break; | ||
2206 | case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ | 896 | case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ |
2207 | ret = wlan_fwt_cleanup_ioctl(priv, req); | 897 | ret = wlan_fwt_cleanup_ioctl(priv, req); |
2208 | break; | 898 | break; |
@@ -2222,196 +912,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2222 | 912 | ||
2223 | break; | 913 | break; |
2224 | 914 | ||
2225 | case WLANGETLOG: | ||
2226 | ret = wlan_do_getlog_ioctl(priv, wrq); | ||
2227 | break; | ||
2228 | |||
2229 | case WLAN_SET_GET_SIXTEEN_INT: | 915 | case WLAN_SET_GET_SIXTEEN_INT: |
2230 | switch ((int)wrq->u.data.flags) { | 916 | switch ((int)wrq->u.data.flags) { |
2231 | case WLAN_TPCCFG: | ||
2232 | { | ||
2233 | int data[5]; | ||
2234 | struct cmd_ds_802_11_tpc_cfg cfg; | ||
2235 | memset(&cfg, 0, sizeof(cfg)); | ||
2236 | if ((wrq->u.data.length > 1) | ||
2237 | && (wrq->u.data.length != 5)) | ||
2238 | return -1; | ||
2239 | |||
2240 | if (wrq->u.data.length == 0) { | ||
2241 | cfg.action = | ||
2242 | cpu_to_le16 | ||
2243 | (cmd_act_get); | ||
2244 | } else { | ||
2245 | if (copy_from_user | ||
2246 | (data, wrq->u.data.pointer, | ||
2247 | sizeof(int) * 5)) { | ||
2248 | lbs_pr_debug(1, | ||
2249 | "Copy from user failed\n"); | ||
2250 | return -EFAULT; | ||
2251 | } | ||
2252 | |||
2253 | cfg.action = | ||
2254 | cpu_to_le16 | ||
2255 | (cmd_act_set); | ||
2256 | cfg.enable = data[0]; | ||
2257 | cfg.usesnr = data[1]; | ||
2258 | cfg.P0 = data[2]; | ||
2259 | cfg.P1 = data[3]; | ||
2260 | cfg.P2 = data[4]; | ||
2261 | } | ||
2262 | |||
2263 | ret = | ||
2264 | libertas_prepare_and_send_command(priv, | ||
2265 | cmd_802_11_tpc_cfg, | ||
2266 | 0, | ||
2267 | cmd_option_waitforrsp, | ||
2268 | 0, (void *)&cfg); | ||
2269 | |||
2270 | data[0] = cfg.enable; | ||
2271 | data[1] = cfg.usesnr; | ||
2272 | data[2] = cfg.P0; | ||
2273 | data[3] = cfg.P1; | ||
2274 | data[4] = cfg.P2; | ||
2275 | if (copy_to_user | ||
2276 | (wrq->u.data.pointer, data, | ||
2277 | sizeof(int) * 5)) { | ||
2278 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2279 | return -EFAULT; | ||
2280 | } | ||
2281 | |||
2282 | wrq->u.data.length = 5; | ||
2283 | } | ||
2284 | break; | ||
2285 | |||
2286 | case WLAN_POWERCFG: | ||
2287 | { | ||
2288 | int data[4]; | ||
2289 | struct cmd_ds_802_11_pwr_cfg cfg; | ||
2290 | memset(&cfg, 0, sizeof(cfg)); | ||
2291 | if ((wrq->u.data.length > 1) | ||
2292 | && (wrq->u.data.length != 4)) | ||
2293 | return -1; | ||
2294 | if (wrq->u.data.length == 0) { | ||
2295 | cfg.action = | ||
2296 | cpu_to_le16 | ||
2297 | (cmd_act_get); | ||
2298 | } else { | ||
2299 | if (copy_from_user | ||
2300 | (data, wrq->u.data.pointer, | ||
2301 | sizeof(int) * 4)) { | ||
2302 | lbs_pr_debug(1, | ||
2303 | "Copy from user failed\n"); | ||
2304 | return -EFAULT; | ||
2305 | } | ||
2306 | |||
2307 | cfg.action = | ||
2308 | cpu_to_le16 | ||
2309 | (cmd_act_set); | ||
2310 | cfg.enable = data[0]; | ||
2311 | cfg.PA_P0 = data[1]; | ||
2312 | cfg.PA_P1 = data[2]; | ||
2313 | cfg.PA_P2 = data[3]; | ||
2314 | } | ||
2315 | ret = | ||
2316 | libertas_prepare_and_send_command(priv, | ||
2317 | cmd_802_11_pwr_cfg, | ||
2318 | 0, | ||
2319 | cmd_option_waitforrsp, | ||
2320 | 0, (void *)&cfg); | ||
2321 | data[0] = cfg.enable; | ||
2322 | data[1] = cfg.PA_P0; | ||
2323 | data[2] = cfg.PA_P1; | ||
2324 | data[3] = cfg.PA_P2; | ||
2325 | if (copy_to_user | ||
2326 | (wrq->u.data.pointer, data, | ||
2327 | sizeof(int) * 4)) { | ||
2328 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2329 | return -EFAULT; | ||
2330 | } | ||
2331 | |||
2332 | wrq->u.data.length = 4; | ||
2333 | } | ||
2334 | break; | ||
2335 | case WLAN_AUTO_FREQ_SET: | ||
2336 | { | ||
2337 | int data[3]; | ||
2338 | struct cmd_ds_802_11_afc afc; | ||
2339 | memset(&afc, 0, sizeof(afc)); | ||
2340 | if (wrq->u.data.length != 3) | ||
2341 | return -1; | ||
2342 | if (copy_from_user | ||
2343 | (data, wrq->u.data.pointer, | ||
2344 | sizeof(int) * 3)) { | ||
2345 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
2346 | return -EFAULT; | ||
2347 | } | ||
2348 | afc.afc_auto = data[0]; | ||
2349 | |||
2350 | if (afc.afc_auto != 0) { | ||
2351 | afc.threshold = data[1]; | ||
2352 | afc.period = data[2]; | ||
2353 | } else { | ||
2354 | afc.timing_offset = data[1]; | ||
2355 | afc.carrier_offset = data[2]; | ||
2356 | } | ||
2357 | ret = | ||
2358 | libertas_prepare_and_send_command(priv, | ||
2359 | cmd_802_11_set_afc, | ||
2360 | 0, | ||
2361 | cmd_option_waitforrsp, | ||
2362 | 0, (void *)&afc); | ||
2363 | } | ||
2364 | break; | ||
2365 | case WLAN_AUTO_FREQ_GET: | ||
2366 | { | ||
2367 | int data[3]; | ||
2368 | struct cmd_ds_802_11_afc afc; | ||
2369 | memset(&afc, 0, sizeof(afc)); | ||
2370 | ret = | ||
2371 | libertas_prepare_and_send_command(priv, | ||
2372 | cmd_802_11_get_afc, | ||
2373 | 0, | ||
2374 | cmd_option_waitforrsp, | ||
2375 | 0, (void *)&afc); | ||
2376 | data[0] = afc.afc_auto; | ||
2377 | data[1] = afc.timing_offset; | ||
2378 | data[2] = afc.carrier_offset; | ||
2379 | if (copy_to_user | ||
2380 | (wrq->u.data.pointer, data, | ||
2381 | sizeof(int) * 3)) { | ||
2382 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2383 | return -EFAULT; | ||
2384 | } | ||
2385 | |||
2386 | wrq->u.data.length = 3; | ||
2387 | } | ||
2388 | break; | ||
2389 | case WLAN_SCANPROBES: | ||
2390 | { | ||
2391 | int data; | ||
2392 | if (wrq->u.data.length > 0) { | ||
2393 | if (copy_from_user | ||
2394 | (&data, wrq->u.data.pointer, | ||
2395 | sizeof(int))) { | ||
2396 | lbs_pr_debug(1, | ||
2397 | "Copy from user failed\n"); | ||
2398 | return -EFAULT; | ||
2399 | } | ||
2400 | |||
2401 | adapter->scanprobes = data; | ||
2402 | } else { | ||
2403 | data = adapter->scanprobes; | ||
2404 | if (copy_to_user | ||
2405 | (wrq->u.data.pointer, &data, | ||
2406 | sizeof(int))) { | ||
2407 | lbs_pr_debug(1, | ||
2408 | "Copy to user failed\n"); | ||
2409 | return -EFAULT; | ||
2410 | } | ||
2411 | } | ||
2412 | wrq->u.data.length = 1; | ||
2413 | } | ||
2414 | break; | ||
2415 | case WLAN_LED_GPIO_CTRL: | 917 | case WLAN_LED_GPIO_CTRL: |
2416 | { | 918 | { |
2417 | int i; | 919 | int i; |
@@ -2475,17 +977,6 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2475 | wrq->u.data.length = gpio->header.len; | 977 | wrq->u.data.length = gpio->header.len; |
2476 | } | 978 | } |
2477 | break; | 979 | break; |
2478 | case WLAN_ADAPT_RATESET: | ||
2479 | ret = wlan_adapt_rateset(priv, wrq); | ||
2480 | break; | ||
2481 | case WLAN_INACTIVITY_TIMEOUT: | ||
2482 | ret = wlan_inactivity_timeout(priv, wrq); | ||
2483 | break; | ||
2484 | case WLANSNR: | ||
2485 | ret = wlan_get_snr(priv, wrq); | ||
2486 | break; | ||
2487 | case WLAN_GET_RXINFO: | ||
2488 | ret = wlan_get_rxinfo(priv, wrq); | ||
2489 | } | 980 | } |
2490 | break; | 981 | break; |
2491 | 982 | ||
diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c index 11682cbe752b..d4926b83e145 100644 --- a/drivers/net/wireless/libertas/join.c +++ b/drivers/net/wireless/libertas/join.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include "join.h" | 15 | #include "join.h" |
16 | #include "dev.h" | 16 | #include "dev.h" |
17 | 17 | ||
18 | #define AD_HOC_CAP_PRIVACY_ON 1 | ||
19 | |||
18 | /** | 20 | /** |
19 | * @brief This function finds out the common rates between rate1 and rate2. | 21 | * @brief This function finds out the common rates between rate1 and rate2. |
20 | * | 22 | * |
@@ -85,7 +87,7 @@ int libertas_send_deauth(wlan_private * priv) | |||
85 | wlan_adapter *adapter = priv->adapter; | 87 | wlan_adapter *adapter = priv->adapter; |
86 | int ret = 0; | 88 | int ret = 0; |
87 | 89 | ||
88 | if (adapter->inframode == wlan802_11infrastructure && | 90 | if (adapter->mode == IW_MODE_INFRA && |
89 | adapter->connect_status == libertas_connected) | 91 | adapter->connect_status == libertas_connected) |
90 | ret = libertas_send_deauthentication(priv); | 92 | ret = libertas_send_deauthentication(priv); |
91 | else | 93 | else |
@@ -94,20 +96,6 @@ int libertas_send_deauth(wlan_private * priv) | |||
94 | return ret; | 96 | return ret; |
95 | } | 97 | } |
96 | 98 | ||
97 | int libertas_do_adhocstop_ioctl(wlan_private * priv) | ||
98 | { | ||
99 | wlan_adapter *adapter = priv->adapter; | ||
100 | int ret = 0; | ||
101 | |||
102 | if (adapter->inframode == wlan802_11ibss && | ||
103 | adapter->connect_status == libertas_connected) | ||
104 | ret = libertas_stop_adhoc_network(priv); | ||
105 | else | ||
106 | ret = -ENOTSUPP; | ||
107 | |||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | /** | 99 | /** |
112 | * @brief Associate to a specific BSS discovered in a scan | 100 | * @brief Associate to a specific BSS discovered in a scan |
113 | * | 101 | * |
@@ -207,8 +195,7 @@ int libertas_join_adhoc_network(wlan_private * priv, struct bss_descriptor * pbs | |||
207 | /* check if the requested SSID is already joined */ | 195 | /* check if the requested SSID is already joined */ |
208 | if (adapter->curbssparams.ssid.ssidlength | 196 | if (adapter->curbssparams.ssid.ssidlength |
209 | && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) | 197 | && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) |
210 | && (adapter->curbssparams.bssdescriptor.inframode == | 198 | && (adapter->mode == IW_MODE_ADHOC)) { |
211 | wlan802_11ibss)) { | ||
212 | 199 | ||
213 | lbs_pr_debug(1, | 200 | lbs_pr_debug(1, |
214 | "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " | 201 | "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " |
@@ -261,130 +248,6 @@ int libertas_send_deauthentication(wlan_private * priv) | |||
261 | } | 248 | } |
262 | 249 | ||
263 | /** | 250 | /** |
264 | * @brief Set Idle Off | ||
265 | * | ||
266 | * @param priv A pointer to wlan_private structure | ||
267 | * @return 0 --success, otherwise fail | ||
268 | */ | ||
269 | int libertas_idle_off(wlan_private * priv) | ||
270 | { | ||
271 | wlan_adapter *adapter = priv->adapter; | ||
272 | int ret = 0; | ||
273 | const u8 zeromac[] = { 0, 0, 0, 0, 0, 0 }; | ||
274 | int i; | ||
275 | |||
276 | ENTER(); | ||
277 | |||
278 | if (adapter->connect_status == libertas_disconnected) { | ||
279 | if (adapter->inframode == wlan802_11infrastructure) { | ||
280 | if (memcmp(adapter->previousbssid, zeromac, | ||
281 | sizeof(zeromac)) != 0) { | ||
282 | |||
283 | lbs_pr_debug(1, "Previous SSID = %s\n", | ||
284 | adapter->previousssid.ssid); | ||
285 | lbs_pr_debug(1, "Previous BSSID = " | ||
286 | "%02x:%02x:%02x:%02x:%02x:%02x:\n", | ||
287 | adapter->previousbssid[0], | ||
288 | adapter->previousbssid[1], | ||
289 | adapter->previousbssid[2], | ||
290 | adapter->previousbssid[3], | ||
291 | adapter->previousbssid[4], | ||
292 | adapter->previousbssid[5]); | ||
293 | |||
294 | i = libertas_find_SSID_in_list(adapter, | ||
295 | &adapter->previousssid, | ||
296 | adapter->previousbssid, | ||
297 | adapter->inframode); | ||
298 | |||
299 | if (i < 0) { | ||
300 | libertas_send_specific_BSSID_scan(priv, | ||
301 | adapter-> | ||
302 | previousbssid, | ||
303 | 1); | ||
304 | i = libertas_find_SSID_in_list(adapter, | ||
305 | &adapter-> | ||
306 | previousssid, | ||
307 | adapter-> | ||
308 | previousbssid, | ||
309 | adapter-> | ||
310 | inframode); | ||
311 | } | ||
312 | |||
313 | if (i < 0) { | ||
314 | /* If the BSSID could not be found, try just the SSID */ | ||
315 | i = libertas_find_SSID_in_list(adapter, | ||
316 | &adapter-> | ||
317 | previousssid, NULL, | ||
318 | adapter-> | ||
319 | inframode); | ||
320 | } | ||
321 | |||
322 | if (i < 0) { | ||
323 | libertas_send_specific_SSID_scan(priv, | ||
324 | &adapter-> | ||
325 | previousssid, | ||
326 | 1); | ||
327 | i = libertas_find_SSID_in_list(adapter, | ||
328 | &adapter-> | ||
329 | previousssid, NULL, | ||
330 | adapter-> | ||
331 | inframode); | ||
332 | } | ||
333 | |||
334 | if (i >= 0) { | ||
335 | ret = | ||
336 | wlan_associate(priv, | ||
337 | &adapter-> | ||
338 | scantable[i]); | ||
339 | } | ||
340 | } | ||
341 | } else if (adapter->inframode == wlan802_11ibss) { | ||
342 | ret = libertas_prepare_and_send_command(priv, | ||
343 | cmd_802_11_ad_hoc_start, | ||
344 | 0, | ||
345 | cmd_option_waitforrsp, | ||
346 | 0, &adapter->previousssid); | ||
347 | } | ||
348 | } | ||
349 | /* else it is connected */ | ||
350 | |||
351 | lbs_pr_debug(1, "\nwlanidle is off"); | ||
352 | LEAVE(); | ||
353 | return ret; | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * @brief Set Idle On | ||
358 | * | ||
359 | * @param priv A pointer to wlan_private structure | ||
360 | * @return 0 --success, otherwise fail | ||
361 | */ | ||
362 | int libertas_idle_on(wlan_private * priv) | ||
363 | { | ||
364 | wlan_adapter *adapter = priv->adapter; | ||
365 | int ret = 0; | ||
366 | |||
367 | if (adapter->connect_status == libertas_connected) { | ||
368 | if (adapter->inframode == wlan802_11infrastructure) { | ||
369 | lbs_pr_debug(1, "Previous SSID = %s\n", | ||
370 | adapter->previousssid.ssid); | ||
371 | memmove(&adapter->previousssid, | ||
372 | &adapter->curbssparams.ssid, | ||
373 | sizeof(struct WLAN_802_11_SSID)); | ||
374 | libertas_send_deauth(priv); | ||
375 | |||
376 | } else if (adapter->inframode == wlan802_11ibss) { | ||
377 | ret = libertas_stop_adhoc_network(priv); | ||
378 | } | ||
379 | |||
380 | } | ||
381 | |||
382 | lbs_pr_debug(1, "\nwlanidle is on"); | ||
383 | |||
384 | return ret; | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * @brief This function prepares command of authenticate. | 251 | * @brief This function prepares command of authenticate. |
389 | * | 252 | * |
390 | * @param priv A pointer to wlan_private structure | 253 | * @param priv A pointer to wlan_private structure |
@@ -398,22 +261,39 @@ int libertas_cmd_80211_authenticate(wlan_private * priv, | |||
398 | void *pdata_buf) | 261 | void *pdata_buf) |
399 | { | 262 | { |
400 | wlan_adapter *adapter = priv->adapter; | 263 | wlan_adapter *adapter = priv->adapter; |
401 | struct cmd_ds_802_11_authenticate *pauthenticate = | 264 | struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth; |
402 | &cmd->params.auth; | 265 | int ret = -1; |
403 | u8 *bssid = pdata_buf; | 266 | u8 *bssid = pdata_buf; |
404 | 267 | ||
405 | cmd->command = cpu_to_le16(cmd_802_11_authenticate); | 268 | cmd->command = cpu_to_le16(cmd_802_11_authenticate); |
406 | cmd->size = | 269 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) |
407 | cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) | 270 | + S_DS_GEN); |
408 | + S_DS_GEN); | 271 | |
272 | /* translate auth mode to 802.11 defined wire value */ | ||
273 | switch (adapter->secinfo.auth_mode) { | ||
274 | case IW_AUTH_ALG_OPEN_SYSTEM: | ||
275 | pauthenticate->authtype = 0x00; | ||
276 | break; | ||
277 | case IW_AUTH_ALG_SHARED_KEY: | ||
278 | pauthenticate->authtype = 0x01; | ||
279 | break; | ||
280 | case IW_AUTH_ALG_LEAP: | ||
281 | pauthenticate->authtype = 0x80; | ||
282 | break; | ||
283 | default: | ||
284 | lbs_pr_debug(1, "AUTH_CMD: invalid auth alg 0x%X\n", | ||
285 | adapter->secinfo.auth_mode); | ||
286 | goto out; | ||
287 | } | ||
409 | 288 | ||
410 | pauthenticate->authtype = adapter->secinfo.authmode; | ||
411 | memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); | 289 | memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); |
412 | 290 | ||
413 | lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", | 291 | lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", |
414 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); | 292 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); |
293 | ret = 0; | ||
415 | 294 | ||
416 | return 0; | 295 | out: |
296 | return ret; | ||
417 | } | 297 | } |
418 | 298 | ||
419 | int libertas_cmd_80211_deauthenticate(wlan_private * priv, | 299 | int libertas_cmd_80211_deauthenticate(wlan_private * priv, |
@@ -550,7 +430,7 @@ int libertas_cmd_80211_associate(wlan_private * priv, | |||
550 | lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); | 430 | lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); |
551 | 431 | ||
552 | /* set IBSS field */ | 432 | /* set IBSS field */ |
553 | if (pbssdesc->inframode == wlan802_11infrastructure) { | 433 | if (pbssdesc->mode == IW_MODE_INFRA) { |
554 | #define CAPINFO_ESS_MODE 1 | 434 | #define CAPINFO_ESS_MODE 1 |
555 | passo->capinfo.ess = CAPINFO_ESS_MODE; | 435 | passo->capinfo.ess = CAPINFO_ESS_MODE; |
556 | } | 436 | } |
@@ -624,7 +504,7 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, | |||
624 | 504 | ||
625 | /* set the BSS type */ | 505 | /* set the BSS type */ |
626 | adhs->bsstype = cmd_bss_type_ibss; | 506 | adhs->bsstype = cmd_bss_type_ibss; |
627 | pbssdesc->inframode = wlan802_11ibss; | 507 | pbssdesc->mode = IW_MODE_ADHOC; |
628 | adhs->beaconperiod = adapter->beaconperiod; | 508 | adhs->beaconperiod = adapter->beaconperiod; |
629 | 509 | ||
630 | /* set Physical param set */ | 510 | /* set Physical param set */ |
@@ -666,15 +546,12 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, | |||
666 | adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); | 546 | adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); |
667 | 547 | ||
668 | /* set up privacy in adapter->scantable[i] */ | 548 | /* set up privacy in adapter->scantable[i] */ |
669 | if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { | 549 | if (adapter->secinfo.wep_enabled) { |
670 | 550 | lbs_pr_debug(1, "ADHOC_S_CMD: WEP enabled, setting privacy on\n"); | |
671 | #define AD_HOC_CAP_PRIVACY_ON 1 | ||
672 | lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus set, privacy to WEP\n"); | ||
673 | pbssdesc->privacy = wlan802_11privfilter8021xWEP; | 551 | pbssdesc->privacy = wlan802_11privfilter8021xWEP; |
674 | adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; | 552 | adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; |
675 | } else { | 553 | } else { |
676 | lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus NOT set, Setting " | 554 | lbs_pr_debug(1, "ADHOC_S_CMD: WEP disabled, setting privacy off\n"); |
677 | "privacy to ACCEPT ALL\n"); | ||
678 | pbssdesc->privacy = wlan802_11privfilteracceptall; | 555 | pbssdesc->privacy = wlan802_11privfilteracceptall; |
679 | } | 556 | } |
680 | 557 | ||
@@ -786,9 +663,6 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv, | |||
786 | padhocjoin->bssdescriptor.BSSID[5], | 663 | padhocjoin->bssdescriptor.BSSID[5], |
787 | padhocjoin->bssdescriptor.SSID); | 664 | padhocjoin->bssdescriptor.SSID); |
788 | 665 | ||
789 | lbs_pr_debug(1, "ADHOC_J_CMD: Data Rate = %x\n", | ||
790 | (u32) padhocjoin->bssdescriptor.datarates); | ||
791 | |||
792 | /* failtimeout */ | 666 | /* failtimeout */ |
793 | padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); | 667 | padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); |
794 | 668 | ||
@@ -832,7 +706,7 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv, | |||
832 | padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = | 706 | padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = |
833 | cpu_to_le16(pbssdesc->atimwindow); | 707 | cpu_to_le16(pbssdesc->atimwindow); |
834 | 708 | ||
835 | if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { | 709 | if (adapter->secinfo.wep_enabled) { |
836 | padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; | 710 | padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; |
837 | } | 711 | } |
838 | 712 | ||
diff --git a/drivers/net/wireless/libertas/join.h b/drivers/net/wireless/libertas/join.h index 8efa2455af9a..115f5a8ba346 100644 --- a/drivers/net/wireless/libertas/join.h +++ b/drivers/net/wireless/libertas/join.h | |||
@@ -1,6 +1,3 @@ | |||
1 | /* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ | ||
2 | /* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ | ||
3 | |||
4 | /** | 1 | /** |
5 | * Interface for the wlan infrastructure and adhoc join routines | 2 | * Interface for the wlan infrastructure and adhoc join routines |
6 | * | 3 | * |
@@ -40,10 +37,6 @@ extern int libertas_ret_80211_disassociate(wlan_private * priv, | |||
40 | extern int libertas_ret_80211_associate(wlan_private * priv, | 37 | extern int libertas_ret_80211_associate(wlan_private * priv, |
41 | struct cmd_ds_command *resp); | 38 | struct cmd_ds_command *resp); |
42 | 39 | ||
43 | extern int libertas_idle_on(wlan_private * priv); | ||
44 | extern int libertas_idle_off(wlan_private * priv); | ||
45 | |||
46 | extern int libertas_do_adhocstop_ioctl(wlan_private * priv); | ||
47 | extern int libertas_reassociation_thread(void *data); | 40 | extern int libertas_reassociation_thread(void *data); |
48 | 41 | ||
49 | struct WLAN_802_11_SSID; | 42 | struct WLAN_802_11_SSID; |
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index dcbf102a057e..b9b25ce65919 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -21,6 +21,13 @@ | |||
21 | #include "debugfs.h" | 21 | #include "debugfs.h" |
22 | #include "assoc.h" | 22 | #include "assoc.h" |
23 | 23 | ||
24 | #define DRIVER_RELEASE_VERSION "320.p0" | ||
25 | const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION | ||
26 | #ifdef DEBUG | ||
27 | "-dbg" | ||
28 | #endif | ||
29 | ""; | ||
30 | |||
24 | #ifdef ENABLE_PM | 31 | #ifdef ENABLE_PM |
25 | static struct pm_dev *wlan_pm_dev = NULL; | 32 | static struct pm_dev *wlan_pm_dev = NULL; |
26 | #endif | 33 | #endif |
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c index 7e3f78f092dc..d17924f764e5 100644 --- a/drivers/net/wireless/libertas/rx.c +++ b/drivers/net/wireless/libertas/rx.c | |||
@@ -210,7 +210,7 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb) | |||
210 | goto done; | 210 | goto done; |
211 | } | 211 | } |
212 | 212 | ||
213 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", | 213 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", |
214 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); | 214 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); |
215 | 215 | ||
216 | lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, | 216 | lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, |
@@ -364,7 +364,7 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb) | |||
364 | priv->stats.rx_errors++; | 364 | priv->stats.rx_errors++; |
365 | } | 365 | } |
366 | 366 | ||
367 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", | 367 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", |
368 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); | 368 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); |
369 | 369 | ||
370 | /* create the exported radio header */ | 370 | /* create the exported radio header */ |
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c index e18706238951..3c0b1a2a1727 100644 --- a/drivers/net/wireless/libertas/scan.c +++ b/drivers/net/wireless/libertas/scan.c | |||
@@ -1,6 +1,3 @@ | |||
1 | /* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ | ||
2 | /* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ | ||
3 | |||
4 | /** | 1 | /** |
5 | * Functions implementing wlan scan IOCTL and firmware command APIs | 2 | * Functions implementing wlan scan IOCTL and firmware command APIs |
6 | * | 3 | * |
@@ -87,118 +84,95 @@ | |||
87 | * | 84 | * |
88 | * @return Index in scantable, or error code if negative | 85 | * @return Index in scantable, or error code if negative |
89 | */ | 86 | */ |
90 | static int is_network_compatible(wlan_adapter * adapter, int index, int mode) | 87 | static int is_network_compatible(wlan_adapter * adapter, int index, u8 mode) |
91 | { | 88 | { |
92 | ENTER(); | 89 | ENTER(); |
93 | 90 | ||
94 | if (adapter->scantable[index].inframode == mode) { | 91 | if (adapter->scantable[index].mode == mode) { |
95 | if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 92 | if ( !adapter->secinfo.wep_enabled |
96 | && !adapter->secinfo.WPAenabled | 93 | && !adapter->secinfo.WPAenabled |
97 | && !adapter->secinfo.WPA2enabled | 94 | && !adapter->secinfo.WPA2enabled |
98 | && adapter->scantable[index].wpa_supplicant.wpa_ie[0] != | 95 | && adapter->scantable[index].wpa_ie[0] != WPA_IE |
99 | WPA_IE | 96 | && adapter->scantable[index].rsn_ie[0] != WPA2_IE |
100 | && adapter->scantable[index].wpa2_supplicant.wpa_ie[0] != | ||
101 | WPA2_IE && adapter->secinfo.Encryptionmode == CIPHER_NONE | ||
102 | && !adapter->scantable[index].privacy) { | 97 | && !adapter->scantable[index].privacy) { |
103 | /* no security */ | 98 | /* no security */ |
104 | LEAVE(); | 99 | LEAVE(); |
105 | return index; | 100 | return index; |
106 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled | 101 | } else if ( adapter->secinfo.wep_enabled |
107 | && !adapter->secinfo.WPAenabled | 102 | && !adapter->secinfo.WPAenabled |
108 | && !adapter->secinfo.WPA2enabled | 103 | && !adapter->secinfo.WPA2enabled |
109 | && adapter->scantable[index].privacy) { | 104 | && adapter->scantable[index].privacy) { |
110 | /* static WEP enabled */ | 105 | /* static WEP enabled */ |
111 | LEAVE(); | 106 | LEAVE(); |
112 | return index; | 107 | return index; |
113 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 108 | } else if ( !adapter->secinfo.wep_enabled |
114 | && adapter->secinfo.WPAenabled | 109 | && adapter->secinfo.WPAenabled |
115 | && !adapter->secinfo.WPA2enabled | 110 | && !adapter->secinfo.WPA2enabled |
116 | && (adapter->scantable[index].wpa_supplicant. | 111 | && (adapter->scantable[index].wpa_ie[0] == WPA_IE) |
117 | wpa_ie[0] | ||
118 | == WPA_IE) | ||
119 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G | 112 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
120 | && adapter->scantable[index].privacy */ | 113 | && adapter->scantable[index].privacy */ |
121 | ) { | 114 | ) { |
122 | /* WPA enabled */ | 115 | /* WPA enabled */ |
123 | lbs_pr_debug(1, | 116 | lbs_pr_debug(1, |
124 | "is_network_compatible() WPA: index=%d wpa_ie=%#x " | 117 | "is_network_compatible() WPA: index=%d wpa_ie=%#x " |
125 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " | 118 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " |
126 | "privacy=%#x\n", index, | 119 | "privacy=%#x\n", index, |
127 | adapter->scantable[index].wpa_supplicant. | 120 | adapter->scantable[index].wpa_ie[0], |
128 | wpa_ie[0], | 121 | adapter->scantable[index].rsn_ie[0], |
129 | adapter->scantable[index].wpa2_supplicant. | 122 | adapter->secinfo.wep_enabled ? "e" : "d", |
130 | wpa_ie[0], | 123 | adapter->secinfo.WPAenabled ? "e" : "d", |
131 | (adapter->secinfo.WEPstatus == | 124 | adapter->secinfo.WPA2enabled ? "e" : "d", |
132 | wlan802_11WEPenabled) ? "e" : "d", | ||
133 | (adapter->secinfo.WPAenabled) ? "e" : "d", | ||
134 | (adapter->secinfo.WPA2enabled) ? "e" : "d", | ||
135 | adapter->secinfo.Encryptionmode, | ||
136 | adapter->scantable[index].privacy); | 125 | adapter->scantable[index].privacy); |
137 | LEAVE(); | 126 | LEAVE(); |
138 | return index; | 127 | return index; |
139 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 128 | } else if ( !adapter->secinfo.wep_enabled |
140 | && !adapter->secinfo.WPAenabled | 129 | && !adapter->secinfo.WPAenabled |
141 | && adapter->secinfo.WPA2enabled | 130 | && adapter->secinfo.WPA2enabled |
142 | && (adapter->scantable[index].wpa2_supplicant. | 131 | && (adapter->scantable[index].rsn_ie[0] == WPA2_IE) |
143 | wpa_ie[0] | ||
144 | == WPA2_IE) | ||
145 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G | 132 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
146 | && adapter->scantable[index].privacy */ | 133 | && adapter->scantable[index].privacy */ |
147 | ) { | 134 | ) { |
148 | /* WPA2 enabled */ | 135 | /* WPA2 enabled */ |
149 | lbs_pr_debug(1, | 136 | lbs_pr_debug(1, |
150 | "is_network_compatible() WPA2: index=%d wpa_ie=%#x " | 137 | "is_network_compatible() WPA2: index=%d wpa_ie=%#x " |
151 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " | 138 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " |
152 | "privacy=%#x\n", index, | 139 | "privacy=%#x\n", index, |
153 | adapter->scantable[index].wpa_supplicant. | 140 | adapter->scantable[index].wpa_ie[0], |
154 | wpa_ie[0], | 141 | adapter->scantable[index].rsn_ie[0], |
155 | adapter->scantable[index].wpa2_supplicant. | 142 | adapter->secinfo.wep_enabled ? "e" : "d", |
156 | wpa_ie[0], | 143 | adapter->secinfo.WPAenabled ? "e" : "d", |
157 | (adapter->secinfo.WEPstatus == | 144 | adapter->secinfo.WPA2enabled ? "e" : "d", |
158 | wlan802_11WEPenabled) ? "e" : "d", | ||
159 | (adapter->secinfo.WPAenabled) ? "e" : "d", | ||
160 | (adapter->secinfo.WPA2enabled) ? "e" : "d", | ||
161 | adapter->secinfo.Encryptionmode, | ||
162 | adapter->scantable[index].privacy); | 145 | adapter->scantable[index].privacy); |
163 | LEAVE(); | 146 | LEAVE(); |
164 | return index; | 147 | return index; |
165 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 148 | } else if ( !adapter->secinfo.wep_enabled |
166 | && !adapter->secinfo.WPAenabled | 149 | && !adapter->secinfo.WPAenabled |
167 | && !adapter->secinfo.WPA2enabled | 150 | && !adapter->secinfo.WPA2enabled |
168 | && (adapter->scantable[index].wpa_supplicant. | 151 | && (adapter->scantable[index].wpa_ie[0] != WPA_IE) |
169 | wpa_ie[0] | 152 | && (adapter->scantable[index].rsn_ie[0] != WPA2_IE) |
170 | != WPA_IE) | ||
171 | && (adapter->scantable[index].wpa2_supplicant. | ||
172 | wpa_ie[0] | ||
173 | != WPA2_IE) | ||
174 | && adapter->secinfo.Encryptionmode != CIPHER_NONE | ||
175 | && adapter->scantable[index].privacy) { | 153 | && adapter->scantable[index].privacy) { |
176 | /* dynamic WEP enabled */ | 154 | /* dynamic WEP enabled */ |
177 | lbs_pr_debug(1, | 155 | lbs_pr_debug(1, |
178 | "is_network_compatible() dynamic WEP: index=%d " | 156 | "is_network_compatible() dynamic WEP: index=%d " |
179 | "wpa_ie=%#x wpa2_ie=%#x Encmode=%#x privacy=%#x\n", | 157 | "wpa_ie=%#x wpa2_ie=%#x privacy=%#x\n", |
180 | index, | 158 | index, |
181 | adapter->scantable[index].wpa_supplicant. | 159 | adapter->scantable[index].wpa_ie[0], |
182 | wpa_ie[0], | 160 | adapter->scantable[index].rsn_ie[0], |
183 | adapter->scantable[index].wpa2_supplicant. | ||
184 | wpa_ie[0], adapter->secinfo.Encryptionmode, | ||
185 | adapter->scantable[index].privacy); | 161 | adapter->scantable[index].privacy); |
186 | LEAVE(); | 162 | LEAVE(); |
187 | return index; | 163 | return index; |
188 | } | 164 | } |
189 | 165 | ||
190 | /* security doesn't match */ | 166 | /* security doesn't match */ |
191 | lbs_pr_debug(1, | 167 | lbs_pr_debug(1, |
192 | "is_network_compatible() FAILED: index=%d wpa_ie=%#x " | 168 | "is_network_compatible() FAILED: index=%d wpa_ie=%#x " |
193 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x privacy=%#x\n", | 169 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s privacy=%#x\n", |
194 | index, | 170 | index, |
195 | adapter->scantable[index].wpa_supplicant.wpa_ie[0], | 171 | adapter->scantable[index].wpa_ie[0], |
196 | adapter->scantable[index].wpa2_supplicant.wpa_ie[0], | 172 | adapter->scantable[index].rsn_ie[0], |
197 | (adapter->secinfo.WEPstatus == | 173 | adapter->secinfo.wep_enabled ? "e" : "d", |
198 | wlan802_11WEPenabled) ? "e" : "d", | 174 | adapter->secinfo.WPAenabled ? "e" : "d", |
199 | (adapter->secinfo.WPAenabled) ? "e" : "d", | 175 | adapter->secinfo.WPA2enabled ? "e" : "d", |
200 | (adapter->secinfo.WPA2enabled) ? "e" : "d", | ||
201 | adapter->secinfo.Encryptionmode, | ||
202 | adapter->scantable[index].privacy); | 176 | adapter->scantable[index].privacy); |
203 | LEAVE(); | 177 | LEAVE(); |
204 | return -ECONNREFUSED; | 178 | return -ECONNREFUSED; |
@@ -924,8 +898,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
924 | u8 founddatarateie; | 898 | u8 founddatarateie; |
925 | int bytesleftforcurrentbeacon; | 899 | int bytesleftforcurrentbeacon; |
926 | 900 | ||
927 | struct WPA_SUPPLICANT *pwpa_supplicant; | ||
928 | struct WPA_SUPPLICANT *pwpa2_supplicant; | ||
929 | struct IE_WPA *pIe; | 901 | struct IE_WPA *pIe; |
930 | const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; | 902 | const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; |
931 | 903 | ||
@@ -962,9 +934,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
962 | 934 | ||
963 | bytesleftforcurrentbeacon = beaconsize; | 935 | bytesleftforcurrentbeacon = beaconsize; |
964 | 936 | ||
965 | pwpa_supplicant = &pBSSEntry->wpa_supplicant; | ||
966 | pwpa2_supplicant = &pBSSEntry->wpa2_supplicant; | ||
967 | |||
968 | memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); | 937 | memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); |
969 | lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", | 938 | lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", |
970 | pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], | 939 | pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], |
@@ -1027,9 +996,9 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
1027 | } | 996 | } |
1028 | 997 | ||
1029 | if (pcap->ibss == 1) { | 998 | if (pcap->ibss == 1) { |
1030 | pBSSEntry->inframode = wlan802_11ibss; | 999 | pBSSEntry->mode = IW_MODE_ADHOC; |
1031 | } else { | 1000 | } else { |
1032 | pBSSEntry->inframode = wlan802_11infrastructure; | 1001 | pBSSEntry->mode = IW_MODE_INFRA; |
1033 | } | 1002 | } |
1034 | 1003 | ||
1035 | /* process variable IE */ | 1004 | /* process variable IE */ |
@@ -1116,7 +1085,7 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
1116 | sizeof(pcountryinfo->countrycode) | 1085 | sizeof(pcountryinfo->countrycode) |
1117 | || pcountryinfo->len > 254) { | 1086 | || pcountryinfo->len > 254) { |
1118 | lbs_pr_debug(1, "InterpretIE: 11D- Err " | 1087 | lbs_pr_debug(1, "InterpretIE: 11D- Err " |
1119 | "CountryInfo len =%d min=%d max=254\n", | 1088 | "CountryInfo len =%d min=%zd max=254\n", |
1120 | pcountryinfo->len, | 1089 | pcountryinfo->len, |
1121 | sizeof(pcountryinfo->countrycode)); | 1090 | sizeof(pcountryinfo->countrycode)); |
1122 | LEAVE(); | 1091 | LEAVE(); |
@@ -1160,27 +1129,27 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
1160 | #define IE_ID_LEN_FIELDS_BYTES 2 | 1129 | #define IE_ID_LEN_FIELDS_BYTES 2 |
1161 | pIe = (struct IE_WPA *)pcurrentptr; | 1130 | pIe = (struct IE_WPA *)pcurrentptr; |
1162 | 1131 | ||
1163 | if (!memcmp(pIe->oui, oui01, sizeof(oui01))) { | 1132 | if (memcmp(pIe->oui, oui01, sizeof(oui01))) |
1164 | pwpa_supplicant->wpa_ie_len | 1133 | break; |
1165 | = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, | 1134 | |
1166 | sizeof(pwpa_supplicant->wpa_ie)); | 1135 | pBSSEntry->wpa_ie_len = min_t(size_t, |
1167 | memcpy(pwpa_supplicant->wpa_ie, | 1136 | elemlen + IE_ID_LEN_FIELDS_BYTES, |
1168 | pcurrentptr, | 1137 | sizeof(pBSSEntry->wpa_ie)); |
1169 | pwpa_supplicant->wpa_ie_len); | 1138 | memcpy(pBSSEntry->wpa_ie, pcurrentptr, |
1170 | lbs_dbg_hex("InterpretIE: Resp WPA_IE", | 1139 | pBSSEntry->wpa_ie_len); |
1171 | pwpa_supplicant->wpa_ie, elemlen); | 1140 | lbs_dbg_hex("InterpretIE: Resp WPA_IE", |
1172 | } | 1141 | pBSSEntry->wpa_ie, elemlen); |
1173 | break; | 1142 | break; |
1174 | case WPA2_IE: | 1143 | case WPA2_IE: |
1175 | pIe = (struct IE_WPA *)pcurrentptr; | 1144 | pIe = (struct IE_WPA *)pcurrentptr; |
1176 | pwpa2_supplicant->wpa_ie_len | ||
1177 | = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, | ||
1178 | sizeof(pwpa2_supplicant->wpa_ie)); | ||
1179 | memcpy(pwpa2_supplicant->wpa_ie, | ||
1180 | pcurrentptr, pwpa2_supplicant->wpa_ie_len); | ||
1181 | 1145 | ||
1146 | pBSSEntry->rsn_ie_len = min_t(size_t, | ||
1147 | elemlen + IE_ID_LEN_FIELDS_BYTES, | ||
1148 | sizeof(pBSSEntry->rsn_ie)); | ||
1149 | memcpy(pBSSEntry->rsn_ie, pcurrentptr, | ||
1150 | pBSSEntry->rsn_ie_len); | ||
1182 | lbs_dbg_hex("InterpretIE: Resp WPA2_IE", | 1151 | lbs_dbg_hex("InterpretIE: Resp WPA2_IE", |
1183 | pwpa2_supplicant->wpa_ie, elemlen); | 1152 | pBSSEntry->rsn_ie, elemlen); |
1184 | break; | 1153 | break; |
1185 | case TIM: | 1154 | case TIM: |
1186 | break; | 1155 | break; |
@@ -1227,7 +1196,7 @@ int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *s | |||
1227 | * | 1196 | * |
1228 | * @return index in BSSID list, or error return code (< 0) | 1197 | * @return index in BSSID list, or error return code (< 0) |
1229 | */ | 1198 | */ |
1230 | int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) | 1199 | int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode) |
1231 | { | 1200 | { |
1232 | int ret = -ENETUNREACH; | 1201 | int ret = -ENETUNREACH; |
1233 | int i; | 1202 | int i; |
@@ -1247,8 +1216,8 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) | |||
1247 | for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { | 1216 | for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { |
1248 | if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { | 1217 | if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { |
1249 | switch (mode) { | 1218 | switch (mode) { |
1250 | case wlan802_11infrastructure: | 1219 | case IW_MODE_INFRA: |
1251 | case wlan802_11ibss: | 1220 | case IW_MODE_ADHOC: |
1252 | ret = is_network_compatible(adapter, i, mode); | 1221 | ret = is_network_compatible(adapter, i, mode); |
1253 | break; | 1222 | break; |
1254 | default: | 1223 | default: |
@@ -1272,7 +1241,7 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) | |||
1272 | * @return index in BSSID list | 1241 | * @return index in BSSID list |
1273 | */ | 1242 | */ |
1274 | int libertas_find_SSID_in_list(wlan_adapter * adapter, | 1243 | int libertas_find_SSID_in_list(wlan_adapter * adapter, |
1275 | struct WLAN_802_11_SSID *ssid, u8 * bssid, int mode) | 1244 | struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode) |
1276 | { | 1245 | { |
1277 | int net = -ENETUNREACH; | 1246 | int net = -ENETUNREACH; |
1278 | u8 bestrssi = 0; | 1247 | u8 bestrssi = 0; |
@@ -1287,8 +1256,8 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, | |||
1287 | !memcmp(adapter->scantable[i]. | 1256 | !memcmp(adapter->scantable[i]. |
1288 | macaddress, bssid, ETH_ALEN))) { | 1257 | macaddress, bssid, ETH_ALEN))) { |
1289 | switch (mode) { | 1258 | switch (mode) { |
1290 | case wlan802_11infrastructure: | 1259 | case IW_MODE_INFRA: |
1291 | case wlan802_11ibss: | 1260 | case IW_MODE_ADHOC: |
1292 | j = is_network_compatible(adapter, i, mode); | 1261 | j = is_network_compatible(adapter, i, mode); |
1293 | 1262 | ||
1294 | if (j >= 0) { | 1263 | if (j >= 0) { |
@@ -1311,7 +1280,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, | |||
1311 | } | 1280 | } |
1312 | } | 1281 | } |
1313 | break; | 1282 | break; |
1314 | case wlan802_11autounknown: | 1283 | case IW_MODE_AUTO: |
1315 | default: | 1284 | default: |
1316 | if (SCAN_RSSI(adapter->scantable[i].rssi) | 1285 | if (SCAN_RSSI(adapter->scantable[i].rssi) |
1317 | > bestrssi) { | 1286 | > bestrssi) { |
@@ -1338,8 +1307,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, | |||
1338 | * | 1307 | * |
1339 | * @return index in BSSID list | 1308 | * @return index in BSSID list |
1340 | */ | 1309 | */ |
1341 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | 1310 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode) |
1342 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode) | ||
1343 | { | 1311 | { |
1344 | int bestnet = -ENETUNREACH; | 1312 | int bestnet = -ENETUNREACH; |
1345 | u8 bestrssi = 0; | 1313 | u8 bestrssi = 0; |
@@ -1351,8 +1319,8 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | |||
1351 | 1319 | ||
1352 | for (i = 0; i < adapter->numinscantable; i++) { | 1320 | for (i = 0; i < adapter->numinscantable; i++) { |
1353 | switch (mode) { | 1321 | switch (mode) { |
1354 | case wlan802_11infrastructure: | 1322 | case IW_MODE_INFRA: |
1355 | case wlan802_11ibss: | 1323 | case IW_MODE_ADHOC: |
1356 | if (is_network_compatible(adapter, i, mode) >= 0) { | 1324 | if (is_network_compatible(adapter, i, mode) >= 0) { |
1357 | if (SCAN_RSSI(adapter->scantable[i].rssi) > | 1325 | if (SCAN_RSSI(adapter->scantable[i].rssi) > |
1358 | bestrssi) { | 1326 | bestrssi) { |
@@ -1363,7 +1331,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | |||
1363 | } | 1331 | } |
1364 | } | 1332 | } |
1365 | break; | 1333 | break; |
1366 | case wlan802_11autounknown: | 1334 | case IW_MODE_AUTO: |
1367 | default: | 1335 | default: |
1368 | if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { | 1336 | if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { |
1369 | bestrssi = | 1337 | bestrssi = |
@@ -1388,8 +1356,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | |||
1388 | */ | 1356 | */ |
1389 | int libertas_find_best_network_SSID(wlan_private * priv, | 1357 | int libertas_find_best_network_SSID(wlan_private * priv, |
1390 | struct WLAN_802_11_SSID *pSSID, | 1358 | struct WLAN_802_11_SSID *pSSID, |
1391 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, | 1359 | u8 preferred_mode, u8 *out_mode) |
1392 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode) | ||
1393 | { | 1360 | { |
1394 | wlan_adapter *adapter = priv->adapter; | 1361 | wlan_adapter *adapter = priv->adapter; |
1395 | int ret = 0; | 1362 | int ret = 0; |
@@ -1414,7 +1381,7 @@ int libertas_find_best_network_SSID(wlan_private * priv, | |||
1414 | preqbssid = &adapter->scantable[i]; | 1381 | preqbssid = &adapter->scantable[i]; |
1415 | memcpy(pSSID, &preqbssid->ssid, | 1382 | memcpy(pSSID, &preqbssid->ssid, |
1416 | sizeof(struct WLAN_802_11_SSID)); | 1383 | sizeof(struct WLAN_802_11_SSID)); |
1417 | *out_mode = preqbssid->inframode; | 1384 | *out_mode = preqbssid->mode; |
1418 | 1385 | ||
1419 | if (!pSSID->ssidlength) { | 1386 | if (!pSSID->ssidlength) { |
1420 | ret = -1; | 1387 | ret = -1; |
@@ -1584,7 +1551,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1584 | for (i = 0; i < adapter->numinscantable; i++) { | 1551 | for (i = 0; i < adapter->numinscantable; i++) { |
1585 | if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { | 1552 | if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { |
1586 | lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " | 1553 | lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " |
1587 | "MAX_SCAN_CELL_SIZE=%d\n", | 1554 | "MAX_SCAN_CELL_SIZE=%zd\n", |
1588 | i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); | 1555 | i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); |
1589 | break; | 1556 | break; |
1590 | } | 1557 | } |
@@ -1632,7 +1599,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1632 | 1599 | ||
1633 | //Add mode | 1600 | //Add mode |
1634 | iwe.cmd = SIOCGIWMODE; | 1601 | iwe.cmd = SIOCGIWMODE; |
1635 | iwe.u.mode = adapter->scantable[i].inframode + 1; | 1602 | iwe.u.mode = adapter->scantable[i].mode; |
1636 | iwe.len = IW_EV_UINT_LEN; | 1603 | iwe.len = IW_EV_UINT_LEN; |
1637 | current_ev = | 1604 | current_ev = |
1638 | iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); | 1605 | iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); |
@@ -1666,7 +1633,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1666 | iwe.u.qual.noise = | 1633 | iwe.u.qual.noise = |
1667 | CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); | 1634 | CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); |
1668 | } | 1635 | } |
1669 | if ((adapter->inframode == wlan802_11ibss) && | 1636 | if ((adapter->mode == IW_MODE_ADHOC) && |
1670 | !libertas_SSID_cmp(&adapter->curbssparams.ssid, | 1637 | !libertas_SSID_cmp(&adapter->curbssparams.ssid, |
1671 | &adapter->scantable[i].ssid) | 1638 | &adapter->scantable[i].ssid) |
1672 | && adapter->adhoccreate) { | 1639 | && adapter->adhoccreate) { |
@@ -1731,7 +1698,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1731 | end_buf, &iwe, iwe.len); | 1698 | end_buf, &iwe, iwe.len); |
1732 | 1699 | ||
1733 | } | 1700 | } |
1734 | if ((adapter->scantable[i].inframode == wlan802_11ibss) | 1701 | if ((adapter->scantable[i].mode == IW_MODE_ADHOC) |
1735 | && !libertas_SSID_cmp(&adapter->curbssparams.ssid, | 1702 | && !libertas_SSID_cmp(&adapter->curbssparams.ssid, |
1736 | &adapter->scantable[i].ssid) | 1703 | &adapter->scantable[i].ssid) |
1737 | && adapter->adhoccreate) { | 1704 | && adapter->adhoccreate) { |
@@ -1745,30 +1712,24 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1745 | /* Add new value to event */ | 1712 | /* Add new value to event */ |
1746 | current_val = current_ev + IW_EV_LCP_LEN; | 1713 | current_val = current_ev + IW_EV_LCP_LEN; |
1747 | 1714 | ||
1748 | if (adapter->scantable[i].wpa2_supplicant.wpa_ie[0] == WPA2_IE) { | 1715 | if (adapter->scantable[i].rsn_ie[0] == WPA2_IE) { |
1749 | memset(&iwe, 0, sizeof(iwe)); | 1716 | memset(&iwe, 0, sizeof(iwe)); |
1750 | memset(buf, 0, sizeof(buf)); | 1717 | memset(buf, 0, sizeof(buf)); |
1751 | memcpy(buf, adapter->scantable[i]. | 1718 | memcpy(buf, adapter->scantable[i].rsn_ie, |
1752 | wpa2_supplicant.wpa_ie, | 1719 | adapter->scantable[i].rsn_ie_len); |
1753 | adapter->scantable[i].wpa2_supplicant. | ||
1754 | wpa_ie_len); | ||
1755 | iwe.cmd = IWEVGENIE; | 1720 | iwe.cmd = IWEVGENIE; |
1756 | iwe.u.data.length = adapter->scantable[i]. | 1721 | iwe.u.data.length = adapter->scantable[i].rsn_ie_len; |
1757 | wpa2_supplicant.wpa_ie_len; | ||
1758 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; | 1722 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; |
1759 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 1723 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
1760 | &iwe, buf); | 1724 | &iwe, buf); |
1761 | } | 1725 | } |
1762 | if (adapter->scantable[i].wpa_supplicant.wpa_ie[0] == WPA_IE) { | 1726 | if (adapter->scantable[i].wpa_ie[0] == WPA_IE) { |
1763 | memset(&iwe, 0, sizeof(iwe)); | 1727 | memset(&iwe, 0, sizeof(iwe)); |
1764 | memset(buf, 0, sizeof(buf)); | 1728 | memset(buf, 0, sizeof(buf)); |
1765 | memcpy(buf, adapter->scantable[i]. | 1729 | memcpy(buf, adapter->scantable[i].wpa_ie, |
1766 | wpa_supplicant.wpa_ie, | 1730 | adapter->scantable[i].wpa_ie_len); |
1767 | adapter->scantable[i].wpa_supplicant. | ||
1768 | wpa_ie_len); | ||
1769 | iwe.cmd = IWEVGENIE; | 1731 | iwe.cmd = IWEVGENIE; |
1770 | iwe.u.data.length = adapter->scantable[i]. | 1732 | iwe.u.data.length = adapter->scantable[i].wpa_ie_len; |
1771 | wpa_supplicant.wpa_ie_len; | ||
1772 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; | 1733 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; |
1773 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 1734 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
1774 | &iwe, buf); | 1735 | &iwe, buf); |
diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h index d93aa7fa44fd..405f4f0fe575 100644 --- a/drivers/net/wireless/libertas/scan.h +++ b/drivers/net/wireless/libertas/scan.h | |||
@@ -1,6 +1,3 @@ | |||
1 | /* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ | ||
2 | /* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ | ||
3 | |||
4 | /** | 1 | /** |
5 | * Interface for the wlan network scan routines | 2 | * Interface for the wlan network scan routines |
6 | * | 3 | * |
@@ -10,6 +7,7 @@ | |||
10 | #ifndef _WLAN_SCAN_H | 7 | #ifndef _WLAN_SCAN_H |
11 | #define _WLAN_SCAN_H | 8 | #define _WLAN_SCAN_H |
12 | 9 | ||
10 | #include <net/ieee80211.h> | ||
13 | #include "hostcmd.h" | 11 | #include "hostcmd.h" |
14 | 12 | ||
15 | /** | 13 | /** |
@@ -155,7 +153,7 @@ struct bss_descriptor { | |||
155 | 153 | ||
156 | u32 atimwindow; | 154 | u32 atimwindow; |
157 | 155 | ||
158 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; | 156 | u8 mode; |
159 | u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; | 157 | u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; |
160 | 158 | ||
161 | int extra_ie; | 159 | int extra_ie; |
@@ -170,22 +168,22 @@ struct bss_descriptor { | |||
170 | 168 | ||
171 | struct ieeetypes_countryinfofullset countryinfo; | 169 | struct ieeetypes_countryinfofullset countryinfo; |
172 | 170 | ||
173 | struct WPA_SUPPLICANT wpa_supplicant; | 171 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
174 | struct WPA_SUPPLICANT wpa2_supplicant; | 172 | size_t wpa_ie_len; |
175 | 173 | u8 rsn_ie[MAX_WPA_IE_LEN]; | |
174 | size_t rsn_ie_len; | ||
176 | }; | 175 | }; |
177 | 176 | ||
178 | extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, | 177 | extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, |
179 | struct WLAN_802_11_SSID *ssid2); | 178 | struct WLAN_802_11_SSID *ssid2); |
180 | extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, | 179 | extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, |
181 | u8 * bssid, int mode); | 180 | u8 * bssid, u8 mode); |
182 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode); | 181 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode); |
183 | extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode); | 182 | extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode); |
184 | 183 | ||
185 | int libertas_find_best_network_SSID(wlan_private * priv, | 184 | int libertas_find_best_network_SSID(wlan_private * priv, |
186 | struct WLAN_802_11_SSID *pSSID, | 185 | struct WLAN_802_11_SSID *pSSID, |
187 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, | 186 | u8 preferred_mode, u8 *out_mode); |
188 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode); | ||
189 | 187 | ||
190 | extern int libertas_send_specific_SSID_scan(wlan_private * priv, | 188 | extern int libertas_send_specific_SSID_scan(wlan_private * priv, |
191 | struct WLAN_802_11_SSID *prequestedssid, | 189 | struct WLAN_802_11_SSID *prequestedssid, |
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c index 82d06223043e..d4b13478c9a7 100644 --- a/drivers/net/wireless/libertas/tx.c +++ b/drivers/net/wireless/libertas/tx.c | |||
@@ -78,7 +78,7 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb) | |||
78 | min_t(unsigned int, skb->len, 100)); | 78 | min_t(unsigned int, skb->len, 100)); |
79 | 79 | ||
80 | if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { | 80 | if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { |
81 | lbs_pr_debug(1, "Tx error: Bad skb length %d : %d\n", | 81 | lbs_pr_debug(1, "Tx error: Bad skb length %d : %zd\n", |
82 | skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); | 82 | skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); |
83 | ret = -1; | 83 | ret = -1; |
84 | goto done; | 84 | goto done; |
diff --git a/drivers/net/wireless/libertas/version.h b/drivers/net/wireless/libertas/version.h index e86f65ae79b8..8b137891791f 100644 --- a/drivers/net/wireless/libertas/version.h +++ b/drivers/net/wireless/libertas/version.h | |||
@@ -1,8 +1 @@ | |||
1 | #define DRIVER_RELEASE_VERSION "320.p0" | ||
2 | const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION | ||
3 | #ifdef DEBUG | ||
4 | "-dbg" | ||
5 | #endif | ||
6 | ""; | ||
7 | |||
8 | |||
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index 4a52336bc0f6..69f52b6e59c8 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include "defs.h" | 17 | #include "defs.h" |
18 | #include "dev.h" | 18 | #include "dev.h" |
19 | #include "join.h" | 19 | #include "join.h" |
20 | #include "version.h" | ||
21 | #include "wext.h" | 20 | #include "wext.h" |
22 | #include "assoc.h" | 21 | #include "assoc.h" |
23 | 22 | ||
@@ -233,7 +232,7 @@ static int changeadhocchannel(wlan_private * priv, int channel) | |||
233 | 232 | ||
234 | // find out the BSSID that matches the current SSID | 233 | // find out the BSSID that matches the current SSID |
235 | i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, | 234 | i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, |
236 | wlan802_11ibss); | 235 | IW_MODE_ADHOC); |
237 | 236 | ||
238 | if (i >= 0) { | 237 | if (i >= 0) { |
239 | lbs_pr_debug(1, "SSID found at %d in List," | 238 | lbs_pr_debug(1, "SSID found at %d in List," |
@@ -316,13 +315,11 @@ static int get_active_data_rates(wlan_adapter * adapter, | |||
316 | ENTER(); | 315 | ENTER(); |
317 | 316 | ||
318 | if (adapter->connect_status != libertas_connected) { | 317 | if (adapter->connect_status != libertas_connected) { |
319 | if (adapter->inframode == wlan802_11infrastructure) { | 318 | if (adapter->mode == IW_MODE_INFRA) { |
320 | //Infra. mode | ||
321 | lbs_pr_debug(1, "Infra\n"); | 319 | lbs_pr_debug(1, "Infra\n"); |
322 | k = copyrates(rates, k, libertas_supported_rates, | 320 | k = copyrates(rates, k, libertas_supported_rates, |
323 | sizeof(libertas_supported_rates)); | 321 | sizeof(libertas_supported_rates)); |
324 | } else { | 322 | } else { |
325 | //ad-hoc mode | ||
326 | lbs_pr_debug(1, "Adhoc G\n"); | 323 | lbs_pr_debug(1, "Adhoc G\n"); |
327 | k = copyrates(rates, k, libertas_adhoc_rates_g, | 324 | k = copyrates(rates, k, libertas_adhoc_rates_g, |
328 | sizeof(libertas_adhoc_rates_g)); | 325 | sizeof(libertas_adhoc_rates_g)); |
@@ -586,20 +583,7 @@ static int wlan_get_mode(struct net_device *dev, | |||
586 | 583 | ||
587 | ENTER(); | 584 | ENTER(); |
588 | 585 | ||
589 | switch (adapter->inframode) { | 586 | *uwrq = adapter->mode; |
590 | case wlan802_11ibss: | ||
591 | *uwrq = IW_MODE_ADHOC; | ||
592 | break; | ||
593 | |||
594 | case wlan802_11infrastructure: | ||
595 | *uwrq = IW_MODE_INFRA; | ||
596 | break; | ||
597 | |||
598 | default: | ||
599 | case wlan802_11autounknown: | ||
600 | *uwrq = IW_MODE_AUTO; | ||
601 | break; | ||
602 | } | ||
603 | 587 | ||
604 | LEAVE(); | 588 | LEAVE(); |
605 | return 0; | 589 | return 0; |
@@ -1002,149 +986,18 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1002 | /* | 986 | /* |
1003 | * { cmd, set_args, get_args, name } | 987 | * { cmd, set_args, get_args, name } |
1004 | */ | 988 | */ |
1005 | { | ||
1006 | WLANSCAN_TYPE, | ||
1007 | IW_PRIV_TYPE_CHAR | 8, | ||
1008 | IW_PRIV_TYPE_CHAR | 8, | ||
1009 | "scantype"}, | ||
1010 | |||
1011 | { | ||
1012 | WLAN_SETINT_GETINT, | ||
1013 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1014 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1015 | ""}, | ||
1016 | { | ||
1017 | WLANNF, | ||
1018 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1019 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1020 | "getNF"}, | ||
1021 | { | ||
1022 | WLANRSSI, | ||
1023 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1024 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1025 | "getRSSI"}, | ||
1026 | { | ||
1027 | WLANENABLE11D, | ||
1028 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1029 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1030 | "enable11d"}, | ||
1031 | { | ||
1032 | WLANADHOCGRATE, | ||
1033 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1034 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1035 | "adhocgrate"}, | ||
1036 | |||
1037 | { | ||
1038 | WLAN_SUBCMD_SET_PRESCAN, | ||
1039 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1040 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1041 | "prescan"}, | ||
1042 | { | ||
1043 | WLAN_SETONEINT_GETONEINT, | ||
1044 | IW_PRIV_TYPE_INT | 1, | ||
1045 | IW_PRIV_TYPE_INT | 1, | ||
1046 | ""}, | ||
1047 | { | ||
1048 | WLAN_BEACON_INTERVAL, | ||
1049 | IW_PRIV_TYPE_INT | 1, | ||
1050 | IW_PRIV_TYPE_INT | 1, | ||
1051 | "bcninterval"}, | ||
1052 | { | ||
1053 | WLAN_LISTENINTRVL, | ||
1054 | IW_PRIV_TYPE_INT | 1, | ||
1055 | IW_PRIV_TYPE_INT | 1, | ||
1056 | "lolisteninter"}, | ||
1057 | { | ||
1058 | WLAN_TXCONTROL, | ||
1059 | IW_PRIV_TYPE_INT | 1, | ||
1060 | IW_PRIV_TYPE_INT | 1, | ||
1061 | "txcontrol"}, | ||
1062 | { | ||
1063 | WLAN_NULLPKTINTERVAL, | ||
1064 | IW_PRIV_TYPE_INT | 1, | ||
1065 | IW_PRIV_TYPE_INT | 1, | ||
1066 | "psnullinterval"}, | ||
1067 | /* Using iwpriv sub-command feature */ | 989 | /* Using iwpriv sub-command feature */ |
1068 | { | 990 | { |
1069 | WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */ | 991 | WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */ |
1070 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 992 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1071 | IW_PRIV_TYPE_NONE, | 993 | IW_PRIV_TYPE_NONE, |
1072 | ""}, | 994 | ""}, |
1073 | |||
1074 | { | ||
1075 | WLAN_SUBCMD_SETRXANTENNA, | ||
1076 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1077 | IW_PRIV_TYPE_NONE, | ||
1078 | "setrxant"}, | ||
1079 | { | ||
1080 | WLAN_SUBCMD_SETTXANTENNA, | ||
1081 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1082 | IW_PRIV_TYPE_NONE, | ||
1083 | "settxant"}, | ||
1084 | { | ||
1085 | WLANSETAUTHALG, | ||
1086 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1087 | IW_PRIV_TYPE_NONE, | ||
1088 | "authalgs", | ||
1089 | }, | ||
1090 | { | ||
1091 | WLANSET8021XAUTHALG, | ||
1092 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1093 | IW_PRIV_TYPE_NONE, | ||
1094 | "8021xauthalgs", | ||
1095 | }, | ||
1096 | { | ||
1097 | WLANSETENCRYPTIONMODE, | ||
1098 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1099 | IW_PRIV_TYPE_NONE, | ||
1100 | "encryptionmode", | ||
1101 | }, | ||
1102 | { | 995 | { |
1103 | WLANSETREGION, | 996 | WLANSETREGION, |
1104 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 997 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1105 | IW_PRIV_TYPE_NONE, | 998 | IW_PRIV_TYPE_NONE, |
1106 | "setregioncode"}, | 999 | "setregioncode"}, |
1107 | { | 1000 | { |
1108 | WLAN_SET_LISTEN_INTERVAL, | ||
1109 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1110 | IW_PRIV_TYPE_NONE, | ||
1111 | "setlisteninter"}, | ||
1112 | { | ||
1113 | WLAN_SET_MULTIPLE_DTIM, | ||
1114 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1115 | IW_PRIV_TYPE_NONE, | ||
1116 | "setmultipledtim"}, | ||
1117 | { | ||
1118 | WLAN_SET_ATIM_WINDOW, | ||
1119 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1120 | IW_PRIV_TYPE_NONE, | ||
1121 | "atimwindow"}, | ||
1122 | { | ||
1123 | WLANSETBCNAVG, | ||
1124 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1125 | IW_PRIV_TYPE_NONE, | ||
1126 | "setbcnavg"}, | ||
1127 | { | ||
1128 | WLANSETDATAAVG, | ||
1129 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1130 | IW_PRIV_TYPE_NONE, | ||
1131 | "setdataavg"}, | ||
1132 | { | ||
1133 | WLAN_SET_LINKMODE, | ||
1134 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1135 | IW_PRIV_TYPE_NONE, | ||
1136 | "linkmode"}, | ||
1137 | { | ||
1138 | WLAN_SET_RADIOMODE, | ||
1139 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1140 | IW_PRIV_TYPE_NONE, | ||
1141 | "radiomode"}, | ||
1142 | { | ||
1143 | WLAN_SET_DEBUGMODE, | ||
1144 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1145 | IW_PRIV_TYPE_NONE, | ||
1146 | "debugmode"}, | ||
1147 | { | ||
1148 | WLAN_SUBCMD_MESH_SET_TTL, | 1001 | WLAN_SUBCMD_MESH_SET_TTL, |
1149 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1002 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1150 | IW_PRIV_TYPE_NONE, | 1003 | IW_PRIV_TYPE_NONE, |
@@ -1160,41 +1013,6 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1160 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1013 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1161 | "getregioncode"}, | 1014 | "getregioncode"}, |
1162 | { | 1015 | { |
1163 | WLAN_GET_LISTEN_INTERVAL, | ||
1164 | IW_PRIV_TYPE_NONE, | ||
1165 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1166 | "getlisteninter"}, | ||
1167 | { | ||
1168 | WLAN_GET_MULTIPLE_DTIM, | ||
1169 | IW_PRIV_TYPE_NONE, | ||
1170 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1171 | "getmultipledtim"}, | ||
1172 | { | ||
1173 | WLAN_GET_TX_RATE, | ||
1174 | IW_PRIV_TYPE_NONE, | ||
1175 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1176 | "gettxrate"}, | ||
1177 | { | ||
1178 | WLANGETBCNAVG, | ||
1179 | IW_PRIV_TYPE_NONE, | ||
1180 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1181 | "getbcnavg"}, | ||
1182 | { | ||
1183 | WLAN_GET_LINKMODE, | ||
1184 | IW_PRIV_TYPE_NONE, | ||
1185 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1186 | "get_linkmode"}, | ||
1187 | { | ||
1188 | WLAN_GET_RADIOMODE, | ||
1189 | IW_PRIV_TYPE_NONE, | ||
1190 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1191 | "get_radiomode"}, | ||
1192 | { | ||
1193 | WLAN_GET_DEBUGMODE, | ||
1194 | IW_PRIV_TYPE_NONE, | ||
1195 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1196 | "get_debugmode"}, | ||
1197 | { | ||
1198 | WLAN_SUBCMD_FWT_CLEANUP, | 1016 | WLAN_SUBCMD_FWT_CLEANUP, |
1199 | IW_PRIV_TYPE_NONE, | 1017 | IW_PRIV_TYPE_NONE, |
1200 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1018 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
@@ -1210,61 +1028,11 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1210 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1028 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1211 | "mesh_get_ttl"}, | 1029 | "mesh_get_ttl"}, |
1212 | { | 1030 | { |
1213 | WLAN_SETNONE_GETTWELVE_CHAR, | ||
1214 | IW_PRIV_TYPE_NONE, | ||
1215 | IW_PRIV_TYPE_CHAR | 12, | ||
1216 | ""}, | ||
1217 | { | ||
1218 | WLAN_SUBCMD_GETRXANTENNA, | ||
1219 | IW_PRIV_TYPE_NONE, | ||
1220 | IW_PRIV_TYPE_CHAR | 12, | ||
1221 | "getrxant"}, | ||
1222 | { | ||
1223 | WLAN_SUBCMD_GETTXANTENNA, | ||
1224 | IW_PRIV_TYPE_NONE, | ||
1225 | IW_PRIV_TYPE_CHAR | 12, | ||
1226 | "gettxant"}, | ||
1227 | { | ||
1228 | WLAN_GET_TSF, | ||
1229 | IW_PRIV_TYPE_NONE, | ||
1230 | IW_PRIV_TYPE_CHAR | 12, | ||
1231 | "gettsf"}, | ||
1232 | { | ||
1233 | WLAN_SETNONE_GETNONE, | 1031 | WLAN_SETNONE_GETNONE, |
1234 | IW_PRIV_TYPE_NONE, | 1032 | IW_PRIV_TYPE_NONE, |
1235 | IW_PRIV_TYPE_NONE, | 1033 | IW_PRIV_TYPE_NONE, |
1236 | ""}, | 1034 | ""}, |
1237 | { | 1035 | { |
1238 | WLANDEAUTH, | ||
1239 | IW_PRIV_TYPE_NONE, | ||
1240 | IW_PRIV_TYPE_NONE, | ||
1241 | "deauth"}, | ||
1242 | { | ||
1243 | WLANADHOCSTOP, | ||
1244 | IW_PRIV_TYPE_NONE, | ||
1245 | IW_PRIV_TYPE_NONE, | ||
1246 | "adhocstop"}, | ||
1247 | { | ||
1248 | WLANRADIOON, | ||
1249 | IW_PRIV_TYPE_NONE, | ||
1250 | IW_PRIV_TYPE_NONE, | ||
1251 | "radioon"}, | ||
1252 | { | ||
1253 | WLANRADIOOFF, | ||
1254 | IW_PRIV_TYPE_NONE, | ||
1255 | IW_PRIV_TYPE_NONE, | ||
1256 | "radiooff"}, | ||
1257 | { | ||
1258 | WLANWLANIDLEON, | ||
1259 | IW_PRIV_TYPE_NONE, | ||
1260 | IW_PRIV_TYPE_NONE, | ||
1261 | "wlanidle-on"}, | ||
1262 | { | ||
1263 | WLANWLANIDLEOFF, | ||
1264 | IW_PRIV_TYPE_NONE, | ||
1265 | IW_PRIV_TYPE_NONE, | ||
1266 | "wlanidle-off"}, | ||
1267 | { | ||
1268 | WLAN_SUBCMD_FWT_RESET, | 1036 | WLAN_SUBCMD_FWT_RESET, |
1269 | IW_PRIV_TYPE_NONE, | 1037 | IW_PRIV_TYPE_NONE, |
1270 | IW_PRIV_TYPE_NONE, | 1038 | IW_PRIV_TYPE_NONE, |
@@ -1327,90 +1095,15 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1327 | IW_PRIV_TYPE_CHAR | 128, | 1095 | IW_PRIV_TYPE_CHAR | 128, |
1328 | "fwt_list_route"}, | 1096 | "fwt_list_route"}, |
1329 | { | 1097 | { |
1330 | WLANSCAN_MODE, | ||
1331 | IW_PRIV_TYPE_CHAR | 128, | ||
1332 | IW_PRIV_TYPE_CHAR | 128, | ||
1333 | "scanmode"}, | ||
1334 | { | ||
1335 | WLAN_GET_ADHOC_STATUS, | ||
1336 | IW_PRIV_TYPE_CHAR | 128, | ||
1337 | IW_PRIV_TYPE_CHAR | 128, | ||
1338 | "getadhocstatus"}, | ||
1339 | { | ||
1340 | WLAN_SETNONE_GETWORDCHAR, | ||
1341 | IW_PRIV_TYPE_NONE, | ||
1342 | IW_PRIV_TYPE_CHAR | 128, | ||
1343 | ""}, | ||
1344 | { | ||
1345 | WLANSETWPAIE, | ||
1346 | IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 24, | ||
1347 | IW_PRIV_TYPE_NONE, | ||
1348 | "setwpaie"}, | ||
1349 | { | ||
1350 | WLANGETLOG, | ||
1351 | IW_PRIV_TYPE_NONE, | ||
1352 | IW_PRIV_TYPE_CHAR | GETLOG_BUFSIZE, | ||
1353 | "getlog"}, | ||
1354 | { | ||
1355 | WLAN_SET_GET_SIXTEEN_INT, | 1098 | WLAN_SET_GET_SIXTEEN_INT, |
1356 | IW_PRIV_TYPE_INT | 16, | 1099 | IW_PRIV_TYPE_INT | 16, |
1357 | IW_PRIV_TYPE_INT | 16, | 1100 | IW_PRIV_TYPE_INT | 16, |
1358 | ""}, | 1101 | ""}, |
1359 | { | 1102 | { |
1360 | WLAN_TPCCFG, | ||
1361 | IW_PRIV_TYPE_INT | 16, | ||
1362 | IW_PRIV_TYPE_INT | 16, | ||
1363 | "tpccfg"}, | ||
1364 | { | ||
1365 | WLAN_POWERCFG, | ||
1366 | IW_PRIV_TYPE_INT | 16, | ||
1367 | IW_PRIV_TYPE_INT | 16, | ||
1368 | "powercfg"}, | ||
1369 | { | ||
1370 | WLAN_AUTO_FREQ_SET, | ||
1371 | IW_PRIV_TYPE_INT | 16, | ||
1372 | IW_PRIV_TYPE_INT | 16, | ||
1373 | "setafc"}, | ||
1374 | { | ||
1375 | WLAN_AUTO_FREQ_GET, | ||
1376 | IW_PRIV_TYPE_INT | 16, | ||
1377 | IW_PRIV_TYPE_INT | 16, | ||
1378 | "getafc"}, | ||
1379 | { | ||
1380 | WLAN_SCANPROBES, | ||
1381 | IW_PRIV_TYPE_INT | 16, | ||
1382 | IW_PRIV_TYPE_INT | 16, | ||
1383 | "scanprobes"}, | ||
1384 | { | ||
1385 | WLAN_LED_GPIO_CTRL, | 1103 | WLAN_LED_GPIO_CTRL, |
1386 | IW_PRIV_TYPE_INT | 16, | 1104 | IW_PRIV_TYPE_INT | 16, |
1387 | IW_PRIV_TYPE_INT | 16, | 1105 | IW_PRIV_TYPE_INT | 16, |
1388 | "ledgpio"}, | 1106 | "ledgpio"}, |
1389 | { | ||
1390 | WLAN_ADAPT_RATESET, | ||
1391 | IW_PRIV_TYPE_INT | 16, | ||
1392 | IW_PRIV_TYPE_INT | 16, | ||
1393 | "rateadapt"}, | ||
1394 | { | ||
1395 | WLAN_INACTIVITY_TIMEOUT, | ||
1396 | IW_PRIV_TYPE_INT | 16, | ||
1397 | IW_PRIV_TYPE_INT | 16, | ||
1398 | "inactivityto"}, | ||
1399 | { | ||
1400 | WLANSNR, | ||
1401 | IW_PRIV_TYPE_INT | 16, | ||
1402 | IW_PRIV_TYPE_INT | 16, | ||
1403 | "getSNR"}, | ||
1404 | { | ||
1405 | WLAN_GET_RATE, | ||
1406 | IW_PRIV_TYPE_INT | 16, | ||
1407 | IW_PRIV_TYPE_INT | 16, | ||
1408 | "getrate"}, | ||
1409 | { | ||
1410 | WLAN_GET_RXINFO, | ||
1411 | IW_PRIV_TYPE_INT | 16, | ||
1412 | IW_PRIV_TYPE_INT | 16, | ||
1413 | "getrxinfo"}, | ||
1414 | }; | 1107 | }; |
1415 | 1108 | ||
1416 | static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) | 1109 | static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) |
@@ -1434,7 +1127,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) | |||
1434 | 1127 | ||
1435 | ENTER(); | 1128 | ENTER(); |
1436 | 1129 | ||
1437 | priv->wstats.status = adapter->inframode; | 1130 | priv->wstats.status = adapter->mode; |
1438 | 1131 | ||
1439 | /* If we're not associated, all quality values are meaningless */ | 1132 | /* If we're not associated, all quality values are meaningless */ |
1440 | if (adapter->connect_status != libertas_connected) | 1133 | if (adapter->connect_status != libertas_connected) |
@@ -1568,13 +1261,12 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info, | |||
1568 | if (!cfp) { | 1261 | if (!cfp) { |
1569 | rc = -EINVAL; | 1262 | rc = -EINVAL; |
1570 | } else { | 1263 | } else { |
1571 | if (adapter->inframode == wlan802_11ibss) { | 1264 | if (adapter->mode == IW_MODE_ADHOC) { |
1572 | rc = changeadhocchannel(priv, channel); | 1265 | rc = changeadhocchannel(priv, channel); |
1573 | /* If station is WEP enabled, send the | 1266 | /* If station is WEP enabled, send the |
1574 | * command to set WEP in firmware | 1267 | * command to set WEP in firmware |
1575 | */ | 1268 | */ |
1576 | if (adapter->secinfo.WEPstatus == | 1269 | if (adapter->secinfo.wep_enabled) { |
1577 | wlan802_11WEPenabled) { | ||
1578 | lbs_pr_debug(1, "set_freq: WEP enabled\n"); | 1270 | lbs_pr_debug(1, "set_freq: WEP enabled\n"); |
1579 | ret = libertas_prepare_and_send_command(priv, | 1271 | ret = libertas_prepare_and_send_command(priv, |
1580 | cmd_802_11_set_wep, | 1272 | cmd_802_11_set_wep, |
@@ -1716,49 +1408,31 @@ static int wlan_set_mode(struct net_device *dev, | |||
1716 | wlan_private *priv = dev->priv; | 1408 | wlan_private *priv = dev->priv; |
1717 | wlan_adapter *adapter = priv->adapter; | 1409 | wlan_adapter *adapter = priv->adapter; |
1718 | struct assoc_request * assoc_req; | 1410 | struct assoc_request * assoc_req; |
1719 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; | ||
1720 | 1411 | ||
1721 | ENTER(); | 1412 | ENTER(); |
1722 | 1413 | ||
1723 | switch (*uwrq) { | 1414 | if ( (*uwrq != IW_MODE_ADHOC) |
1724 | case IW_MODE_ADHOC: | 1415 | && (*uwrq != IW_MODE_INFRA) |
1725 | lbs_pr_debug(1, "Wanted mode is ad-hoc: current datarate=%#x\n", | 1416 | && (*uwrq != IW_MODE_AUTO)) { |
1726 | adapter->datarate); | 1417 | lbs_pr_debug(1, "Invalid mode: 0x%x\n", *uwrq); |
1727 | new_mode = wlan802_11ibss; | 1418 | ret = -EINVAL; |
1728 | adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL; | 1419 | goto out; |
1729 | break; | ||
1730 | |||
1731 | case IW_MODE_INFRA: | ||
1732 | lbs_pr_debug(1, "Wanted mode is Infrastructure\n"); | ||
1733 | new_mode = wlan802_11infrastructure; | ||
1734 | break; | ||
1735 | |||
1736 | case IW_MODE_AUTO: | ||
1737 | lbs_pr_debug(1, "Wanted mode is Auto\n"); | ||
1738 | new_mode = wlan802_11autounknown; | ||
1739 | break; | ||
1740 | |||
1741 | default: | ||
1742 | lbs_pr_debug(1, "Wanted mode is Unknown: 0x%x\n", *uwrq); | ||
1743 | return -EINVAL; | ||
1744 | } | 1420 | } |
1745 | 1421 | ||
1746 | mutex_lock(&adapter->lock); | 1422 | mutex_lock(&adapter->lock); |
1747 | assoc_req = wlan_get_association_request(adapter); | 1423 | assoc_req = wlan_get_association_request(adapter); |
1748 | if (!assoc_req) { | 1424 | if (!assoc_req) { |
1749 | ret = -ENOMEM; | 1425 | ret = -ENOMEM; |
1426 | wlan_cancel_association_work(priv); | ||
1750 | } else { | 1427 | } else { |
1751 | assoc_req->mode = new_mode; | 1428 | assoc_req->mode = *uwrq; |
1752 | } | ||
1753 | |||
1754 | if (ret == 0) { | ||
1755 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); | 1429 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
1756 | wlan_postpone_association_work(priv); | 1430 | wlan_postpone_association_work(priv); |
1757 | } else { | 1431 | lbs_pr_debug(1, "Switching to mode: 0x%x\n", *uwrq); |
1758 | wlan_cancel_association_work(priv); | ||
1759 | } | 1432 | } |
1760 | mutex_unlock(&adapter->lock); | 1433 | mutex_unlock(&adapter->lock); |
1761 | 1434 | ||
1435 | out: | ||
1762 | LEAVE(); | 1436 | LEAVE(); |
1763 | return ret; | 1437 | return ret; |
1764 | } | 1438 | } |
@@ -1789,13 +1463,13 @@ static int wlan_get_encode(struct net_device *dev, | |||
1789 | dwrq->flags = 0; | 1463 | dwrq->flags = 0; |
1790 | 1464 | ||
1791 | /* Authentication method */ | 1465 | /* Authentication method */ |
1792 | switch (adapter->secinfo.authmode) { | 1466 | switch (adapter->secinfo.auth_mode) { |
1793 | case wlan802_11authmodeopen: | 1467 | case IW_AUTH_ALG_OPEN_SYSTEM: |
1794 | dwrq->flags = IW_ENCODE_OPEN; | 1468 | dwrq->flags = IW_ENCODE_OPEN; |
1795 | break; | 1469 | break; |
1796 | 1470 | ||
1797 | case wlan802_11authmodeshared: | 1471 | case IW_AUTH_ALG_SHARED_KEY: |
1798 | case wlan802_11authmodenetworkEAP: | 1472 | case IW_AUTH_ALG_LEAP: |
1799 | dwrq->flags = IW_ENCODE_RESTRICTED; | 1473 | dwrq->flags = IW_ENCODE_RESTRICTED; |
1800 | break; | 1474 | break; |
1801 | default: | 1475 | default: |
@@ -1803,8 +1477,9 @@ static int wlan_get_encode(struct net_device *dev, | |||
1803 | break; | 1477 | break; |
1804 | } | 1478 | } |
1805 | 1479 | ||
1806 | if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) | 1480 | if ( adapter->secinfo.wep_enabled |
1807 | || adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) { | 1481 | || adapter->secinfo.WPAenabled |
1482 | || adapter->secinfo.WPA2enabled) { | ||
1808 | dwrq->flags &= ~IW_ENCODE_DISABLED; | 1483 | dwrq->flags &= ~IW_ENCODE_DISABLED; |
1809 | } else { | 1484 | } else { |
1810 | dwrq->flags |= IW_ENCODE_DISABLED; | 1485 | dwrq->flags |= IW_ENCODE_DISABLED; |
@@ -1818,8 +1493,7 @@ static int wlan_get_encode(struct net_device *dev, | |||
1818 | if (index < 0) | 1493 | if (index < 0) |
1819 | index = adapter->wep_tx_keyidx; | 1494 | index = adapter->wep_tx_keyidx; |
1820 | 1495 | ||
1821 | if ((adapter->wep_keys[index].len) && | 1496 | if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) { |
1822 | (adapter->secinfo.WEPstatus == wlan802_11WEPenabled)) { | ||
1823 | memcpy(extra, adapter->wep_keys[index].key, | 1497 | memcpy(extra, adapter->wep_keys[index].key, |
1824 | adapter->wep_keys[index].len); | 1498 | adapter->wep_keys[index].len); |
1825 | dwrq->length = adapter->wep_keys[index].len; | 1499 | dwrq->length = adapter->wep_keys[index].len; |
@@ -1903,7 +1577,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req, | |||
1903 | assoc_req->wep_tx_keyidx = index; | 1577 | assoc_req->wep_tx_keyidx = index; |
1904 | } | 1578 | } |
1905 | 1579 | ||
1906 | assoc_req->secinfo.WEPstatus = wlan802_11WEPenabled; | 1580 | assoc_req->secinfo.wep_enabled = 1; |
1907 | 1581 | ||
1908 | LEAVE(); | 1582 | LEAVE(); |
1909 | return 0; | 1583 | return 0; |
@@ -1932,10 +1606,10 @@ static void disable_wep(struct assoc_request *assoc_req) | |||
1932 | int i; | 1606 | int i; |
1933 | 1607 | ||
1934 | /* Set Open System auth mode */ | 1608 | /* Set Open System auth mode */ |
1935 | assoc_req->secinfo.authmode = wlan802_11authmodeopen; | 1609 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
1936 | 1610 | ||
1937 | /* Clear WEP keys and mark WEP as disabled */ | 1611 | /* Clear WEP keys and mark WEP as disabled */ |
1938 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 1612 | assoc_req->secinfo.wep_enabled = 0; |
1939 | for (i = 0; i < 4; i++) | 1613 | for (i = 0; i < 4; i++) |
1940 | assoc_req->wep_keys[i].len = 0; | 1614 | assoc_req->wep_keys[i].len = 0; |
1941 | 1615 | ||
@@ -1987,8 +1661,7 @@ static int wlan_set_encode(struct net_device *dev, | |||
1987 | /* If WEP isn't enabled, or if there is no key data but a valid | 1661 | /* If WEP isn't enabled, or if there is no key data but a valid |
1988 | * index, set the TX key. | 1662 | * index, set the TX key. |
1989 | */ | 1663 | */ |
1990 | if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) | 1664 | if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default)) |
1991 | || (dwrq->length == 0 && !is_default)) | ||
1992 | set_tx_key = 1; | 1665 | set_tx_key = 1; |
1993 | 1666 | ||
1994 | ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); | 1667 | ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); |
@@ -2001,9 +1674,9 @@ static int wlan_set_encode(struct net_device *dev, | |||
2001 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); | 1674 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); |
2002 | 1675 | ||
2003 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { | 1676 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
2004 | assoc_req->secinfo.authmode = wlan802_11authmodeshared; | 1677 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
2005 | } else if (dwrq->flags & IW_ENCODE_OPEN) { | 1678 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
2006 | assoc_req->secinfo.authmode = wlan802_11authmodeopen; | 1679 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2007 | } | 1680 | } |
2008 | 1681 | ||
2009 | out: | 1682 | out: |
@@ -2056,30 +1729,31 @@ static int wlan_get_encodeext(struct net_device *dev, | |||
2056 | 1729 | ||
2057 | if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && | 1730 | if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && |
2058 | ext->alg != IW_ENCODE_ALG_WEP) { | 1731 | ext->alg != IW_ENCODE_ALG_WEP) { |
2059 | if (index != 0 || adapter->inframode != wlan802_11infrastructure) | 1732 | if (index != 0 || adapter->mode != IW_MODE_INFRA) |
2060 | goto out; | 1733 | goto out; |
2061 | } | 1734 | } |
2062 | 1735 | ||
2063 | dwrq->flags = index + 1; | 1736 | dwrq->flags = index + 1; |
2064 | memset(ext, 0, sizeof(*ext)); | 1737 | memset(ext, 0, sizeof(*ext)); |
2065 | 1738 | ||
2066 | if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) | 1739 | if ( !adapter->secinfo.wep_enabled |
2067 | && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) { | 1740 | && !adapter->secinfo.WPAenabled |
1741 | && !adapter->secinfo.WPA2enabled) { | ||
2068 | ext->alg = IW_ENCODE_ALG_NONE; | 1742 | ext->alg = IW_ENCODE_ALG_NONE; |
2069 | ext->key_len = 0; | 1743 | ext->key_len = 0; |
2070 | dwrq->flags |= IW_ENCODE_DISABLED; | 1744 | dwrq->flags |= IW_ENCODE_DISABLED; |
2071 | } else { | 1745 | } else { |
2072 | u8 *key = NULL; | 1746 | u8 *key = NULL; |
2073 | 1747 | ||
2074 | if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) | 1748 | if ( adapter->secinfo.wep_enabled |
2075 | && !adapter->secinfo.WPAenabled | 1749 | && !adapter->secinfo.WPAenabled |
2076 | && !adapter->secinfo.WPA2enabled) { | 1750 | && !adapter->secinfo.WPA2enabled) { |
2077 | ext->alg = IW_ENCODE_ALG_WEP; | 1751 | ext->alg = IW_ENCODE_ALG_WEP; |
2078 | ext->key_len = adapter->wep_keys[index].len; | 1752 | ext->key_len = adapter->wep_keys[index].len; |
2079 | key = &adapter->wep_keys[index].key[0]; | 1753 | key = &adapter->wep_keys[index].key[0]; |
2080 | } else if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) && | 1754 | } else if ( !adapter->secinfo.wep_enabled |
2081 | (adapter->secinfo.WPAenabled || | 1755 | && (adapter->secinfo.WPAenabled || |
2082 | adapter->secinfo.WPA2enabled)) { | 1756 | adapter->secinfo.WPA2enabled)) { |
2083 | /* WPA */ | 1757 | /* WPA */ |
2084 | ext->alg = IW_ENCODE_ALG_TKIP; | 1758 | ext->alg = IW_ENCODE_ALG_TKIP; |
2085 | ext->key_len = 0; | 1759 | ext->key_len = 0; |
@@ -2149,7 +1823,7 @@ static int wlan_set_encodeext(struct net_device *dev, | |||
2149 | /* If WEP isn't enabled, or if there is no key data but a valid | 1823 | /* If WEP isn't enabled, or if there is no key data but a valid |
2150 | * index, or if the set-TX-key flag was passed, set the TX key. | 1824 | * index, or if the set-TX-key flag was passed, set the TX key. |
2151 | */ | 1825 | */ |
2152 | if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) | 1826 | if ( !assoc_req->secinfo.wep_enabled |
2153 | || (dwrq->length == 0 && !is_default) | 1827 | || (dwrq->length == 0 && !is_default) |
2154 | || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) | 1828 | || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) |
2155 | set_tx_key = 1; | 1829 | set_tx_key = 1; |
@@ -2161,11 +1835,9 @@ static int wlan_set_encodeext(struct net_device *dev, | |||
2161 | goto out; | 1835 | goto out; |
2162 | 1836 | ||
2163 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { | 1837 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
2164 | assoc_req->secinfo.authmode = | 1838 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
2165 | wlan802_11authmodeshared; | ||
2166 | } else if (dwrq->flags & IW_ENCODE_OPEN) { | 1839 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
2167 | assoc_req->secinfo.authmode = | 1840 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2168 | wlan802_11authmodeopen; | ||
2169 | } | 1841 | } |
2170 | 1842 | ||
2171 | /* Mark the various WEP bits as modified */ | 1843 | /* Mark the various WEP bits as modified */ |
@@ -2350,15 +2022,13 @@ static int wlan_set_auth(struct net_device *dev, | |||
2350 | } | 2022 | } |
2351 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { | 2023 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { |
2352 | assoc_req->secinfo.WPAenabled = 1; | 2024 | assoc_req->secinfo.WPAenabled = 1; |
2353 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 2025 | assoc_req->secinfo.wep_enabled = 0; |
2354 | assoc_req->secinfo.authmode = | 2026 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2355 | wlan802_11authmodeopen; | ||
2356 | } | 2027 | } |
2357 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { | 2028 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { |
2358 | assoc_req->secinfo.WPA2enabled = 1; | 2029 | assoc_req->secinfo.WPA2enabled = 1; |
2359 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 2030 | assoc_req->secinfo.wep_enabled = 0; |
2360 | assoc_req->secinfo.authmode = | 2031 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2361 | wlan802_11authmodeopen; | ||
2362 | } | 2032 | } |
2363 | updated = 1; | 2033 | updated = 1; |
2364 | break; | 2034 | break; |
@@ -2376,14 +2046,11 @@ static int wlan_set_auth(struct net_device *dev, | |||
2376 | 2046 | ||
2377 | case IW_AUTH_80211_AUTH_ALG: | 2047 | case IW_AUTH_80211_AUTH_ALG: |
2378 | if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { | 2048 | if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { |
2379 | assoc_req->secinfo.authmode = | 2049 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
2380 | wlan802_11authmodeshared; | ||
2381 | } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { | 2050 | } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { |
2382 | assoc_req->secinfo.authmode = | 2051 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2383 | wlan802_11authmodeopen; | ||
2384 | } else if (dwrq->value & IW_AUTH_ALG_LEAP) { | 2052 | } else if (dwrq->value & IW_AUTH_ALG_LEAP) { |
2385 | assoc_req->secinfo.authmode = | 2053 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP; |
2386 | wlan802_11authmodenetworkEAP; | ||
2387 | } else { | 2054 | } else { |
2388 | ret = -EINVAL; | 2055 | ret = -EINVAL; |
2389 | } | 2056 | } |
@@ -2396,9 +2063,8 @@ static int wlan_set_auth(struct net_device *dev, | |||
2396 | !assoc_req->secinfo.WPA2enabled) { | 2063 | !assoc_req->secinfo.WPA2enabled) { |
2397 | assoc_req->secinfo.WPAenabled = 1; | 2064 | assoc_req->secinfo.WPAenabled = 1; |
2398 | assoc_req->secinfo.WPA2enabled = 1; | 2065 | assoc_req->secinfo.WPA2enabled = 1; |
2399 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 2066 | assoc_req->secinfo.wep_enabled = 0; |
2400 | assoc_req->secinfo.authmode = | 2067 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2401 | wlan802_11authmodeopen; | ||
2402 | } | 2068 | } |
2403 | } else { | 2069 | } else { |
2404 | assoc_req->secinfo.WPAenabled = 0; | 2070 | assoc_req->secinfo.WPAenabled = 0; |
@@ -2455,19 +2121,7 @@ static int wlan_get_auth(struct net_device *dev, | |||
2455 | break; | 2121 | break; |
2456 | 2122 | ||
2457 | case IW_AUTH_80211_AUTH_ALG: | 2123 | case IW_AUTH_80211_AUTH_ALG: |
2458 | switch (adapter->secinfo.authmode) { | 2124 | dwrq->value = adapter->secinfo.auth_mode; |
2459 | case wlan802_11authmodeshared: | ||
2460 | dwrq->value = IW_AUTH_ALG_SHARED_KEY; | ||
2461 | break; | ||
2462 | case wlan802_11authmodeopen: | ||
2463 | dwrq->value = IW_AUTH_ALG_OPEN_SYSTEM; | ||
2464 | break; | ||
2465 | case wlan802_11authmodenetworkEAP: | ||
2466 | dwrq->value = IW_AUTH_ALG_LEAP; | ||
2467 | break; | ||
2468 | default: | ||
2469 | break; | ||
2470 | } | ||
2471 | break; | 2125 | break; |
2472 | 2126 | ||
2473 | case IW_AUTH_WPA_ENABLED: | 2127 | case IW_AUTH_WPA_ENABLED: |
diff --git a/drivers/net/wireless/libertas/wext.h b/drivers/net/wireless/libertas/wext.h index 39f367c38d90..15cfaaf0797f 100644 --- a/drivers/net/wireless/libertas/wext.h +++ b/drivers/net/wireless/libertas/wext.h | |||
@@ -10,88 +10,22 @@ | |||
10 | /** PRIVATE CMD ID */ | 10 | /** PRIVATE CMD ID */ |
11 | #define WLANIOCTL SIOCIWFIRSTPRIV | 11 | #define WLANIOCTL SIOCIWFIRSTPRIV |
12 | 12 | ||
13 | #define WLANSETWPAIE (WLANIOCTL + 0) | ||
14 | |||
15 | #define WLAN_SETINT_GETINT (WLANIOCTL + 7) | ||
16 | #define WLANNF 1 | ||
17 | #define WLANRSSI 2 | ||
18 | #define WLANENABLE11D 5 | ||
19 | #define WLANADHOCGRATE 6 | ||
20 | #define WLAN_SUBCMD_SET_PRESCAN 11 | ||
21 | |||
22 | #define WLAN_SETNONE_GETNONE (WLANIOCTL + 8) | 13 | #define WLAN_SETNONE_GETNONE (WLANIOCTL + 8) |
23 | #define WLANDEAUTH 1 | ||
24 | #define WLANRADIOON 2 | ||
25 | #define WLANRADIOOFF 3 | ||
26 | #define WLANREMOVEADHOCAES 4 | ||
27 | #define WLANADHOCSTOP 5 | ||
28 | #define WLANCIPHERTEST 6 | ||
29 | #define WLANCRYPTOTEST 7 | ||
30 | |||
31 | #define WLANWLANIDLEON 10 | ||
32 | #define WLANWLANIDLEOFF 11 | ||
33 | #define WLAN_SUBCMD_BT_RESET 13 | 14 | #define WLAN_SUBCMD_BT_RESET 13 |
34 | #define WLAN_SUBCMD_FWT_RESET 14 | 15 | #define WLAN_SUBCMD_FWT_RESET 14 |
35 | 16 | ||
36 | #define WLANGETLOG (WLANIOCTL + 9) | ||
37 | #define GETLOG_BUFSIZE 300 | ||
38 | |||
39 | #define WLANSCAN_TYPE (WLANIOCTL + 11) | ||
40 | |||
41 | #define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15) | 17 | #define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15) |
42 | #define WLANGETREGION 1 | 18 | #define WLANGETREGION 1 |
43 | #define WLAN_GET_LISTEN_INTERVAL 2 | ||
44 | #define WLAN_GET_MULTIPLE_DTIM 3 | ||
45 | #define WLAN_GET_TX_RATE 4 | ||
46 | #define WLANGETBCNAVG 5 | ||
47 | 19 | ||
48 | #define WLAN_GET_LINKMODE 6 | ||
49 | #define WLAN_GET_RADIOMODE 7 | ||
50 | #define WLAN_GET_DEBUGMODE 8 | ||
51 | #define WLAN_SUBCMD_FWT_CLEANUP 15 | 20 | #define WLAN_SUBCMD_FWT_CLEANUP 15 |
52 | #define WLAN_SUBCMD_FWT_TIME 16 | 21 | #define WLAN_SUBCMD_FWT_TIME 16 |
53 | #define WLAN_SUBCMD_MESH_GET_TTL 17 | 22 | #define WLAN_SUBCMD_MESH_GET_TTL 17 |
54 | 23 | ||
55 | #define WLANREGCFRDWR (WLANIOCTL + 18) | ||
56 | |||
57 | #define WLAN_SETNONE_GETTWELVE_CHAR (WLANIOCTL + 19) | ||
58 | #define WLAN_SUBCMD_GETRXANTENNA 1 | ||
59 | #define WLAN_SUBCMD_GETTXANTENNA 2 | ||
60 | #define WLAN_GET_TSF 3 | ||
61 | |||
62 | #define WLAN_SETNONE_GETWORDCHAR (WLANIOCTL + 21) | ||
63 | #define WLANGETADHOCAES 1 | ||
64 | |||
65 | #define WLAN_SETONEINT_GETONEINT (WLANIOCTL + 23) | ||
66 | #define WLAN_BEACON_INTERVAL 1 | ||
67 | #define WLAN_LISTENINTRVL 4 | ||
68 | |||
69 | #define WLAN_TXCONTROL 6 | ||
70 | #define WLAN_NULLPKTINTERVAL 7 | ||
71 | |||
72 | #define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) | 24 | #define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) |
73 | #define WLAN_SUBCMD_SETRXANTENNA 1 | ||
74 | #define WLAN_SUBCMD_SETTXANTENNA 2 | ||
75 | #define WLANSETAUTHALG 5 | ||
76 | #define WLANSET8021XAUTHALG 6 | ||
77 | #define WLANSETENCRYPTIONMODE 7 | ||
78 | #define WLANSETREGION 8 | 25 | #define WLANSETREGION 8 |
79 | #define WLAN_SET_LISTEN_INTERVAL 9 | ||
80 | |||
81 | #define WLAN_SET_MULTIPLE_DTIM 10 | ||
82 | #define WLAN_SET_ATIM_WINDOW 11 | ||
83 | #define WLANSETBCNAVG 13 | ||
84 | #define WLANSETDATAAVG 14 | ||
85 | #define WLAN_SET_LINKMODE 15 | ||
86 | #define WLAN_SET_RADIOMODE 16 | ||
87 | #define WLAN_SET_DEBUGMODE 17 | ||
88 | #define WLAN_SUBCMD_MESH_SET_TTL 18 | 26 | #define WLAN_SUBCMD_MESH_SET_TTL 18 |
89 | 27 | ||
90 | #define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) | 28 | #define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) |
91 | #define WLANSCAN_MODE 6 | ||
92 | |||
93 | #define WLAN_GET_ADHOC_STATUS 9 | ||
94 | |||
95 | #define WLAN_SUBCMD_BT_ADD 18 | 29 | #define WLAN_SUBCMD_BT_ADD 18 |
96 | #define WLAN_SUBCMD_BT_DEL 19 | 30 | #define WLAN_SUBCMD_BT_DEL 19 |
97 | #define WLAN_SUBCMD_BT_LIST 20 | 31 | #define WLAN_SUBCMD_BT_LIST 20 |
@@ -103,27 +37,8 @@ | |||
103 | #define WLAN_SUBCMD_FWT_LIST_ROUTE 26 | 37 | #define WLAN_SUBCMD_FWT_LIST_ROUTE 26 |
104 | 38 | ||
105 | #define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) | 39 | #define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) |
106 | #define WLAN_TPCCFG 1 | ||
107 | #define WLAN_POWERCFG 2 | ||
108 | |||
109 | #define WLAN_AUTO_FREQ_SET 3 | ||
110 | #define WLAN_AUTO_FREQ_GET 4 | ||
111 | #define WLAN_LED_GPIO_CTRL 5 | 40 | #define WLAN_LED_GPIO_CTRL 5 |
112 | #define WLAN_SCANPROBES 6 | ||
113 | #define WLAN_ADAPT_RATESET 8 | ||
114 | #define WLAN_INACTIVITY_TIMEOUT 9 | ||
115 | #define WLANSNR 10 | ||
116 | #define WLAN_GET_RATE 11 | ||
117 | #define WLAN_GET_RXINFO 12 | ||
118 | |||
119 | #define WLANCMD52RDWR (WLANIOCTL + 30) | ||
120 | #define WLANCMD53RDWR (WLANIOCTL + 31) | ||
121 | #define CMD53BUFLEN 32 | ||
122 | 41 | ||
123 | #define REG_MAC 0x19 | ||
124 | #define REG_BBP 0x1a | ||
125 | #define REG_RF 0x1b | ||
126 | #define REG_EEPROM 0x59 | ||
127 | #define WLAN_LINKMODE_802_3 0 | 42 | #define WLAN_LINKMODE_802_3 0 |
128 | #define WLAN_LINKMODE_802_11 2 | 43 | #define WLAN_LINKMODE_802_11 2 |
129 | #define WLAN_RADIOMODE_NONE 0 | 44 | #define WLAN_RADIOMODE_NONE 0 |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index 78cf0711d1fa..ef07c36bccf7 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -249,19 +249,19 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, | |||
249 | 249 | ||
250 | 250 | ||
251 | if (rc == PCI_SLOT_ALREADY_UP) { | 251 | if (rc == PCI_SLOT_ALREADY_UP) { |
252 | dev_dbg(slot->pci_bus->self, "is already active\n"); | 252 | dev_dbg(&slot->pci_bus->self->dev, "is already active\n"); |
253 | return 1; /* return 1 to user */ | 253 | return 1; /* return 1 to user */ |
254 | } | 254 | } |
255 | 255 | ||
256 | if (rc == PCI_L1_ERR) { | 256 | if (rc == PCI_L1_ERR) { |
257 | dev_dbg(slot->pci_bus->self, | 257 | dev_dbg(&slot->pci_bus->self->dev, |
258 | "L1 failure %d with message: %s", | 258 | "L1 failure %d with message: %s", |
259 | resp.resp_sub_errno, resp.resp_l1_msg); | 259 | resp.resp_sub_errno, resp.resp_l1_msg); |
260 | return -EPERM; | 260 | return -EPERM; |
261 | } | 261 | } |
262 | 262 | ||
263 | if (rc) { | 263 | if (rc) { |
264 | dev_dbg(slot->pci_bus->self, | 264 | dev_dbg(&slot->pci_bus->self->dev, |
265 | "insert failed with error %d sub-error %d\n", | 265 | "insert failed with error %d sub-error %d\n", |
266 | rc, resp.resp_sub_errno); | 266 | rc, resp.resp_sub_errno); |
267 | return -EIO; | 267 | return -EIO; |
@@ -287,25 +287,25 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, | |||
287 | 287 | ||
288 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && | 288 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && |
289 | (rc == PCI_SLOT_ALREADY_DOWN)) { | 289 | (rc == PCI_SLOT_ALREADY_DOWN)) { |
290 | dev_dbg(slot->pci_bus->self, "Slot %s already inactive\n"); | 290 | dev_dbg(&slot->pci_bus->self->dev, "Slot %s already inactive\n", slot->physical_path); |
291 | return 1; /* return 1 to user */ | 291 | return 1; /* return 1 to user */ |
292 | } | 292 | } |
293 | 293 | ||
294 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { | 294 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { |
295 | dev_dbg(slot->pci_bus->self, | 295 | dev_dbg(&slot->pci_bus->self->dev, |
296 | "Cannot remove last 33MHz card\n"); | 296 | "Cannot remove last 33MHz card\n"); |
297 | return -EPERM; | 297 | return -EPERM; |
298 | } | 298 | } |
299 | 299 | ||
300 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { | 300 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { |
301 | dev_dbg(slot->pci_bus->self, | 301 | dev_dbg(&slot->pci_bus->self->dev, |
302 | "L1 failure %d with message \n%s\n", | 302 | "L1 failure %d with message \n%s\n", |
303 | resp.resp_sub_errno, resp.resp_l1_msg); | 303 | resp.resp_sub_errno, resp.resp_l1_msg); |
304 | return -EPERM; | 304 | return -EPERM; |
305 | } | 305 | } |
306 | 306 | ||
307 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { | 307 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { |
308 | dev_dbg(slot->pci_bus->self, | 308 | dev_dbg(&slot->pci_bus->self->dev, |
309 | "remove failed with error %d sub-error %d\n", | 309 | "remove failed with error %d sub-error %d\n", |
310 | rc, resp.resp_sub_errno); | 310 | rc, resp.resp_sub_errno); |
311 | return -EIO; | 311 | return -EIO; |
@@ -317,12 +317,12 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, | |||
317 | if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { | 317 | if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { |
318 | pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); | 318 | pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); |
319 | pcibus_info->pbi_enabled_devices &= ~(1 << device_num); | 319 | pcibus_info->pbi_enabled_devices &= ~(1 << device_num); |
320 | dev_dbg(slot->pci_bus->self, "remove successful\n"); | 320 | dev_dbg(&slot->pci_bus->self->dev, "remove successful\n"); |
321 | return 0; | 321 | return 0; |
322 | } | 322 | } |
323 | 323 | ||
324 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { | 324 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { |
325 | dev_dbg(slot->pci_bus->self,"remove failed rc = %d\n", rc); | 325 | dev_dbg(&slot->pci_bus->self->dev,"remove failed rc = %d\n", rc); |
326 | } | 326 | } |
327 | 327 | ||
328 | return rc; | 328 | return rc; |
@@ -375,7 +375,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
375 | num_funcs = pci_scan_slot(slot->pci_bus, | 375 | num_funcs = pci_scan_slot(slot->pci_bus, |
376 | PCI_DEVFN(slot->device_num + 1, 0)); | 376 | PCI_DEVFN(slot->device_num + 1, 0)); |
377 | if (!num_funcs) { | 377 | if (!num_funcs) { |
378 | dev_dbg(slot->pci_bus->self, "no device in slot\n"); | 378 | dev_dbg(&slot->pci_bus->self->dev, "no device in slot\n"); |
379 | mutex_unlock(&sn_hotplug_mutex); | 379 | mutex_unlock(&sn_hotplug_mutex); |
380 | return -ENODEV; | 380 | return -ENODEV; |
381 | } | 381 | } |
@@ -427,7 +427,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
427 | phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; | 427 | phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; |
428 | 428 | ||
429 | if (acpi_bus_get_device(phandle, &pdevice)) { | 429 | if (acpi_bus_get_device(phandle, &pdevice)) { |
430 | dev_dbg(slot->pci_bus->self, | 430 | dev_dbg(&slot->pci_bus->self->dev, |
431 | "no parent device, assuming NULL\n"); | 431 | "no parent device, assuming NULL\n"); |
432 | pdevice = NULL; | 432 | pdevice = NULL; |
433 | } | 433 | } |
@@ -479,10 +479,10 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
479 | mutex_unlock(&sn_hotplug_mutex); | 479 | mutex_unlock(&sn_hotplug_mutex); |
480 | 480 | ||
481 | if (rc == 0) | 481 | if (rc == 0) |
482 | dev_dbg(slot->pci_bus->self, | 482 | dev_dbg(&slot->pci_bus->self->dev, |
483 | "insert operation successful\n"); | 483 | "insert operation successful\n"); |
484 | else | 484 | else |
485 | dev_dbg(slot->pci_bus->self, | 485 | dev_dbg(&slot->pci_bus->self->dev, |
486 | "insert operation failed rc = %d\n", rc); | 486 | "insert operation failed rc = %d\n", rc); |
487 | 487 | ||
488 | return rc; | 488 | return rc; |
@@ -659,16 +659,16 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | |||
659 | if (rc) | 659 | if (rc) |
660 | goto register_err; | 660 | goto register_err; |
661 | } | 661 | } |
662 | dev_dbg(pci_bus->self, "Registered bus with hotplug\n"); | 662 | dev_dbg(&pci_bus->self->dev, "Registered bus with hotplug\n"); |
663 | return rc; | 663 | return rc; |
664 | 664 | ||
665 | register_err: | 665 | register_err: |
666 | dev_dbg(pci_bus->self, "bus failed to register with err = %d\n", | 666 | dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n", |
667 | rc); | 667 | rc); |
668 | 668 | ||
669 | alloc_err: | 669 | alloc_err: |
670 | if (rc == -ENOMEM) | 670 | if (rc == -ENOMEM) |
671 | dev_dbg(pci_bus->self, "Memory allocation error\n"); | 671 | dev_dbg(&pci_bus->self->dev, "Memory allocation error\n"); |
672 | 672 | ||
673 | /* destroy THIS element */ | 673 | /* destroy THIS element */ |
674 | if (bss_hotplug_slot) | 674 | if (bss_hotplug_slot) |
@@ -701,10 +701,10 @@ static int sn_pci_hotplug_init(void) | |||
701 | 701 | ||
702 | rc = sn_pci_bus_valid(pci_bus); | 702 | rc = sn_pci_bus_valid(pci_bus); |
703 | if (rc != 1) { | 703 | if (rc != 1) { |
704 | dev_dbg(pci_bus->self, "not a valid hotplug bus\n"); | 704 | dev_dbg(&pci_bus->self->dev, "not a valid hotplug bus\n"); |
705 | continue; | 705 | continue; |
706 | } | 706 | } |
707 | dev_dbg(pci_bus->self, "valid hotplug bus\n"); | 707 | dev_dbg(&pci_bus->self->dev, "valid hotplug bus\n"); |
708 | 708 | ||
709 | rc = sn_hotplug_slot_register(pci_bus); | 709 | rc = sn_hotplug_slot_register(pci_bus); |
710 | if (!rc) { | 710 | if (!rc) { |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index e6740d1a0824..d9cbd586ae4b 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -549,8 +549,10 @@ static int msi_free_irqs(struct pci_dev* dev) | |||
549 | { | 549 | { |
550 | struct msi_desc *entry, *tmp; | 550 | struct msi_desc *entry, *tmp; |
551 | 551 | ||
552 | list_for_each_entry(entry, &dev->msi_list, list) | 552 | list_for_each_entry(entry, &dev->msi_list, list) { |
553 | BUG_ON(irq_has_action(entry->irq)); | 553 | if (entry->irq) |
554 | BUG_ON(irq_has_action(entry->irq)); | ||
555 | } | ||
554 | 556 | ||
555 | arch_teardown_msi_irqs(dev); | 557 | arch_teardown_msi_irqs(dev); |
556 | 558 | ||
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 147d86f8edbf..6ccc2e95930a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -875,6 +875,7 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev) | |||
875 | } | 875 | } |
876 | } | 876 | } |
877 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); | 877 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); |
878 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_sb600_sata); | ||
878 | 879 | ||
879 | /* | 880 | /* |
880 | * Serverworks CSB5 IDE does not fully support native mode | 881 | * Serverworks CSB5 IDE does not fully support native mode |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 1759baad439c..95ce8f49e382 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -246,7 +246,7 @@ comment "Platform RTC drivers" | |||
246 | config RTC_DRV_CMOS | 246 | config RTC_DRV_CMOS |
247 | tristate "PC-style 'CMOS'" | 247 | tristate "PC-style 'CMOS'" |
248 | depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ | 248 | depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ |
249 | || M32R || ATARI || POWERPC) | 249 | || M32R || ATARI || POWERPC || MIPS) |
250 | help | 250 | help |
251 | Say "yes" here to get direct support for the real time clock | 251 | Say "yes" here to get direct support for the real time clock |
252 | found in every PC or ACPI-based system, and some other boards. | 252 | found in every PC or ACPI-based system, and some other boards. |
@@ -397,7 +397,7 @@ config RTC_DRV_BFIN | |||
397 | 397 | ||
398 | config RTC_DRV_RS5C313 | 398 | config RTC_DRV_RS5C313 |
399 | tristate "Ricoh RS5C313" | 399 | tristate "Ricoh RS5C313" |
400 | depends on RTC_CLASS && BROKEN | 400 | depends on RTC_CLASS && SH_LANDISK |
401 | help | 401 | help |
402 | If you say yes here you get support for the Ricoh RS5C313 RTC chips. | 402 | If you say yes here you get support for the Ricoh RS5C313 RTC chips. |
403 | 403 | ||
diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 9d6de371495b..66eb133bf5fd 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c | |||
@@ -126,7 +126,7 @@ static void rs5c313_write_data(unsigned char data) | |||
126 | static unsigned char rs5c313_read_data(void) | 126 | static unsigned char rs5c313_read_data(void) |
127 | { | 127 | { |
128 | int i; | 128 | int i; |
129 | unsigned char data; | 129 | unsigned char data = 0; |
130 | 130 | ||
131 | for (i = 0; i < 8; i++) { | 131 | for (i = 0; i < 8; i++) { |
132 | ndelay(700); | 132 | ndelay(700); |
@@ -194,7 +194,7 @@ static void rs5c313_write_reg(unsigned char addr, unsigned char data) | |||
194 | return; | 194 | return; |
195 | } | 195 | } |
196 | 196 | ||
197 | static inline unsigned char rs5c313_read_cntreg(unsigned char addr) | 197 | static inline unsigned char rs5c313_read_cntreg(void) |
198 | { | 198 | { |
199 | return rs5c313_read_reg(RS5C313_ADDR_CNTREG); | 199 | return rs5c313_read_reg(RS5C313_ADDR_CNTREG); |
200 | } | 200 | } |
@@ -212,7 +212,9 @@ static inline void rs5c313_write_intintvreg(unsigned char data) | |||
212 | static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) | 212 | static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) |
213 | { | 213 | { |
214 | int data; | 214 | int data; |
215 | int cnt; | ||
215 | 216 | ||
217 | cnt = 0; | ||
216 | while (1) { | 218 | while (1) { |
217 | RS5C313_CEENABLE; /* CE:H */ | 219 | RS5C313_CEENABLE; /* CE:H */ |
218 | 220 | ||
@@ -225,6 +227,10 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
225 | RS5C313_CEDISABLE; | 227 | RS5C313_CEDISABLE; |
226 | ndelay(700); /* CE:L */ | 228 | ndelay(700); /* CE:L */ |
227 | 229 | ||
230 | if (cnt++ > 100) { | ||
231 | dev_err(dev, "%s: timeout error\n", __FUNCTION__); | ||
232 | return -EIO; | ||
233 | } | ||
228 | } | 234 | } |
229 | 235 | ||
230 | data = rs5c313_read_reg(RS5C313_ADDR_SEC); | 236 | data = rs5c313_read_reg(RS5C313_ADDR_SEC); |
@@ -266,7 +272,9 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
266 | static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | 272 | static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) |
267 | { | 273 | { |
268 | int data; | 274 | int data; |
275 | int cnt; | ||
269 | 276 | ||
277 | cnt = 0; | ||
270 | /* busy check. */ | 278 | /* busy check. */ |
271 | while (1) { | 279 | while (1) { |
272 | RS5C313_CEENABLE; /* CE:H */ | 280 | RS5C313_CEENABLE; /* CE:H */ |
@@ -279,6 +287,11 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
279 | RS5C313_MISCOP; | 287 | RS5C313_MISCOP; |
280 | RS5C313_CEDISABLE; | 288 | RS5C313_CEDISABLE; |
281 | ndelay(700); /* CE:L */ | 289 | ndelay(700); /* CE:L */ |
290 | |||
291 | if (cnt++ > 100) { | ||
292 | dev_err(dev, "%s: timeout error\n", __FUNCTION__); | ||
293 | return -EIO; | ||
294 | } | ||
282 | } | 295 | } |
283 | 296 | ||
284 | data = BIN2BCD(tm->tm_sec); | 297 | data = BIN2BCD(tm->tm_sec); |
@@ -317,6 +330,7 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
317 | static void rs5c313_check_xstp_bit(void) | 330 | static void rs5c313_check_xstp_bit(void) |
318 | { | 331 | { |
319 | struct rtc_time tm; | 332 | struct rtc_time tm; |
333 | int cnt; | ||
320 | 334 | ||
321 | RS5C313_CEENABLE; /* CE:H */ | 335 | RS5C313_CEENABLE; /* CE:H */ |
322 | if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) { | 336 | if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) { |
@@ -326,12 +340,16 @@ static void rs5c313_check_xstp_bit(void) | |||
326 | rs5c313_write_cntreg(0x07); | 340 | rs5c313_write_cntreg(0x07); |
327 | 341 | ||
328 | /* busy check. */ | 342 | /* busy check. */ |
329 | while (rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY) | 343 | for (cnt = 0; cnt < 100; cnt++) { |
344 | if (!(rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY)) | ||
345 | break; | ||
330 | RS5C313_MISCOP; | 346 | RS5C313_MISCOP; |
347 | } | ||
331 | 348 | ||
332 | memset(&tm, 0, sizeof(struct rtc_time)); | 349 | memset(&tm, 0, sizeof(struct rtc_time)); |
333 | tm.tm_mday = 1; | 350 | tm.tm_mday = 1; |
334 | tm.tm_mon = 1; | 351 | tm.tm_mon = 1 - 1; |
352 | tm.tm_year = 2000 - 1900; | ||
335 | 353 | ||
336 | rs5c313_rtc_set_time(NULL, &tm); | 354 | rs5c313_rtc_set_time(NULL, &tm); |
337 | printk(KERN_ERR "RICHO RS5C313: invalid value, resetting to " | 355 | printk(KERN_ERR "RICHO RS5C313: invalid value, resetting to " |
@@ -356,7 +374,7 @@ static int rs5c313_rtc_probe(struct platform_device *pdev) | |||
356 | 374 | ||
357 | platform_set_drvdata(pdev, rtc); | 375 | platform_set_drvdata(pdev, rtc); |
358 | 376 | ||
359 | return err; | 377 | return 0; |
360 | } | 378 | } |
361 | 379 | ||
362 | static int __devexit rs5c313_rtc_remove(struct platform_device *pdev) | 380 | static int __devexit rs5c313_rtc_remove(struct platform_device *pdev) |
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index f2be2ead8742..8328acab47fd 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <asm/ebus.h> | 30 | #include <asm/ebus.h> |
31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
32 | #include <asm/envctrl.h> | 32 | #include <asm/envctrl.h> |
33 | #include <asm/io.h> | ||
33 | 34 | ||
34 | #define ENVCTRL_MINOR 162 | 35 | #define ENVCTRL_MINOR 162 |
35 | 36 | ||
diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c index a15752b37990..eef82758d047 100644 --- a/drivers/scsi/sgiwd93.c +++ b/drivers/scsi/sgiwd93.c | |||
@@ -6,87 +6,49 @@ | |||
6 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | 6 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) |
7 | * Copyright (C) 1999 Andrew R. Baker (andrewb@uab.edu) | 7 | * Copyright (C) 1999 Andrew R. Baker (andrewb@uab.edu) |
8 | * Copyright (C) 2001 Florian Lohoff (flo@rfc822.org) | 8 | * Copyright (C) 2001 Florian Lohoff (flo@rfc822.org) |
9 | * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) | 9 | * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org) |
10 | * | 10 | * |
11 | * (In all truth, Jed Schimmel wrote all this code.) | 11 | * (In all truth, Jed Schimmel wrote all this code.) |
12 | */ | 12 | */ |
13 | #include <linux/init.h> | 13 | |
14 | #include <linux/interrupt.h> | 14 | #undef DEBUG |
15 | #include <linux/types.h> | 15 | |
16 | #include <linux/mm.h> | ||
17 | #include <linux/blkdev.h> | ||
18 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
19 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
18 | #include <linux/gfp.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/types.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/platform_device.h> | ||
20 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
21 | 26 | ||
22 | #include <asm/page.h> | ||
23 | #include <asm/pgtable.h> | ||
24 | #include <asm/sgialib.h> | ||
25 | #include <asm/sgi/sgi.h> | ||
26 | #include <asm/sgi/mc.h> | ||
27 | #include <asm/sgi/hpc3.h> | 27 | #include <asm/sgi/hpc3.h> |
28 | #include <asm/sgi/ip22.h> | 28 | #include <asm/sgi/ip22.h> |
29 | #include <asm/irq.h> | 29 | #include <asm/sgi/wd.h> |
30 | #include <asm/io.h> | ||
31 | 30 | ||
32 | #include "scsi.h" | 31 | #include "scsi.h" |
33 | #include <scsi/scsi_host.h> | ||
34 | #include "wd33c93.h" | 32 | #include "wd33c93.h" |
35 | 33 | ||
36 | #include <linux/stat.h> | ||
37 | |||
38 | #if 0 | ||
39 | #define DPRINTK(args...) printk(args) | ||
40 | #else | ||
41 | #define DPRINTK(args...) | ||
42 | #endif | ||
43 | |||
44 | #define HDATA(ptr) ((struct ip22_hostdata *)((ptr)->hostdata)) | ||
45 | |||
46 | struct ip22_hostdata { | 34 | struct ip22_hostdata { |
47 | struct WD33C93_hostdata wh; | 35 | struct WD33C93_hostdata wh; |
48 | struct hpc_data { | 36 | struct hpc_data { |
49 | dma_addr_t dma; | 37 | dma_addr_t dma; |
50 | void * cpu; | 38 | void *cpu; |
51 | } hd; | 39 | } hd; |
52 | }; | 40 | }; |
53 | 41 | ||
42 | #define host_to_hostdata(host) ((struct ip22_hostdata *)((host)->hostdata)) | ||
43 | |||
54 | struct hpc_chunk { | 44 | struct hpc_chunk { |
55 | struct hpc_dma_desc desc; | 45 | struct hpc_dma_desc desc; |
56 | u32 _padding; /* align to quadword boundary */ | 46 | u32 _padding; /* align to quadword boundary */ |
57 | }; | 47 | }; |
58 | 48 | ||
59 | struct Scsi_Host *sgiwd93_host; | ||
60 | struct Scsi_Host *sgiwd93_host1; | ||
61 | |||
62 | /* Wuff wuff, wuff, wd33c93.c, wuff wuff, object oriented, bow wow. */ | ||
63 | static inline void write_wd33c93_count(const wd33c93_regs regs, | ||
64 | unsigned long value) | ||
65 | { | ||
66 | *regs.SASR = WD_TRANSFER_COUNT_MSB; | ||
67 | mb(); | ||
68 | *regs.SCMD = ((value >> 16) & 0xff); | ||
69 | *regs.SCMD = ((value >> 8) & 0xff); | ||
70 | *regs.SCMD = ((value >> 0) & 0xff); | ||
71 | mb(); | ||
72 | } | ||
73 | |||
74 | static inline unsigned long read_wd33c93_count(const wd33c93_regs regs) | ||
75 | { | ||
76 | unsigned long value; | ||
77 | |||
78 | *regs.SASR = WD_TRANSFER_COUNT_MSB; | ||
79 | mb(); | ||
80 | value = ((*regs.SCMD & 0xff) << 16); | ||
81 | value |= ((*regs.SCMD & 0xff) << 8); | ||
82 | value |= ((*regs.SCMD & 0xff) << 0); | ||
83 | mb(); | ||
84 | return value; | ||
85 | } | ||
86 | |||
87 | static irqreturn_t sgiwd93_intr(int irq, void *dev_id) | 49 | static irqreturn_t sgiwd93_intr(int irq, void *dev_id) |
88 | { | 50 | { |
89 | struct Scsi_Host * host = (struct Scsi_Host *) dev_id; | 51 | struct Scsi_Host * host = dev_id; |
90 | unsigned long flags; | 52 | unsigned long flags; |
91 | 53 | ||
92 | spin_lock_irqsave(host->host_lock, flags); | 54 | spin_lock_irqsave(host->host_lock, flags); |
@@ -131,12 +93,12 @@ void fill_hpc_entries(struct hpc_chunk *hcp, struct scsi_cmnd *cmd, int datainp) | |||
131 | 93 | ||
132 | static int dma_setup(struct scsi_cmnd *cmd, int datainp) | 94 | static int dma_setup(struct scsi_cmnd *cmd, int datainp) |
133 | { | 95 | { |
134 | struct ip22_hostdata *hdata = HDATA(cmd->device->host); | 96 | struct ip22_hostdata *hdata = host_to_hostdata(cmd->device->host); |
135 | struct hpc3_scsiregs *hregs = | 97 | struct hpc3_scsiregs *hregs = |
136 | (struct hpc3_scsiregs *) cmd->device->host->base; | 98 | (struct hpc3_scsiregs *) cmd->device->host->base; |
137 | struct hpc_chunk *hcp = (struct hpc_chunk *) hdata->hd.cpu; | 99 | struct hpc_chunk *hcp = (struct hpc_chunk *) hdata->hd.cpu; |
138 | 100 | ||
139 | DPRINTK("dma_setup: datainp<%d> hcp<%p> ", datainp, hcp); | 101 | pr_debug("dma_setup: datainp<%d> hcp<%p> ", datainp, hcp); |
140 | 102 | ||
141 | hdata->wh.dma_dir = datainp; | 103 | hdata->wh.dma_dir = datainp; |
142 | 104 | ||
@@ -151,7 +113,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp) | |||
151 | 113 | ||
152 | fill_hpc_entries(hcp, cmd, datainp); | 114 | fill_hpc_entries(hcp, cmd, datainp); |
153 | 115 | ||
154 | DPRINTK(" HPCGO\n"); | 116 | pr_debug(" HPCGO\n"); |
155 | 117 | ||
156 | /* Start up the HPC. */ | 118 | /* Start up the HPC. */ |
157 | hregs->ndptr = hdata->hd.dma; | 119 | hregs->ndptr = hdata->hd.dma; |
@@ -166,7 +128,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp) | |||
166 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | 128 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, |
167 | int status) | 129 | int status) |
168 | { | 130 | { |
169 | struct ip22_hostdata *hdata = HDATA(instance); | 131 | struct ip22_hostdata *hdata = host_to_hostdata(instance); |
170 | struct hpc3_scsiregs *hregs; | 132 | struct hpc3_scsiregs *hregs; |
171 | 133 | ||
172 | if (!SCpnt) | 134 | if (!SCpnt) |
@@ -174,7 +136,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | |||
174 | 136 | ||
175 | hregs = (struct hpc3_scsiregs *) SCpnt->device->host->base; | 137 | hregs = (struct hpc3_scsiregs *) SCpnt->device->host->base; |
176 | 138 | ||
177 | DPRINTK("dma_stop: status<%d> ", status); | 139 | pr_debug("dma_stop: status<%d> ", status); |
178 | 140 | ||
179 | /* First stop the HPC and flush it's FIFO. */ | 141 | /* First stop the HPC and flush it's FIFO. */ |
180 | if (hdata->wh.dma_dir) { | 142 | if (hdata->wh.dma_dir) { |
@@ -186,7 +148,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | |||
186 | dma_unmap_single(NULL, SCpnt->SCp.dma_handle, SCpnt->SCp.this_residual, | 148 | dma_unmap_single(NULL, SCpnt->SCp.dma_handle, SCpnt->SCp.this_residual, |
187 | SCpnt->sc_data_direction); | 149 | SCpnt->sc_data_direction); |
188 | 150 | ||
189 | DPRINTK("\n"); | 151 | pr_debug("\n"); |
190 | } | 152 | } |
191 | 153 | ||
192 | void sgiwd93_reset(unsigned long base) | 154 | void sgiwd93_reset(unsigned long base) |
@@ -216,29 +178,71 @@ static inline void init_hpc_chain(struct hpc_data *hd) | |||
216 | hcp->desc.pnext = hd->dma; | 178 | hcp->desc.pnext = hd->dma; |
217 | } | 179 | } |
218 | 180 | ||
219 | static struct Scsi_Host * __init sgiwd93_setup_scsi( | 181 | static int sgiwd93_bus_reset(struct scsi_cmnd *cmd) |
220 | struct scsi_host_template *SGIblows, int unit, int irq, | 182 | { |
221 | struct hpc3_scsiregs *hregs, unsigned char *wdregs) | 183 | /* FIXME perform bus-specific reset */ |
184 | |||
185 | /* FIXME 2: kill this function, and let midlayer fallback | ||
186 | to the same result, calling wd33c93_host_reset() */ | ||
187 | |||
188 | spin_lock_irq(cmd->device->host->host_lock); | ||
189 | wd33c93_host_reset(cmd); | ||
190 | spin_unlock_irq(cmd->device->host->host_lock); | ||
191 | |||
192 | return SUCCESS; | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Kludge alert - the SCSI code calls the abort and reset method with int | ||
197 | * arguments not with pointers. So this is going to blow up beautyfully | ||
198 | * on 64-bit systems with memory outside the compat address spaces. | ||
199 | */ | ||
200 | static struct scsi_host_template sgiwd93_template = { | ||
201 | .module = THIS_MODULE, | ||
202 | .proc_name = "SGIWD93", | ||
203 | .name = "SGI WD93", | ||
204 | .queuecommand = wd33c93_queuecommand, | ||
205 | .eh_abort_handler = wd33c93_abort, | ||
206 | .eh_bus_reset_handler = sgiwd93_bus_reset, | ||
207 | .eh_host_reset_handler = wd33c93_host_reset, | ||
208 | .can_queue = 16, | ||
209 | .this_id = 7, | ||
210 | .sg_tablesize = SG_ALL, | ||
211 | .cmd_per_lun = 8, | ||
212 | .use_clustering = DISABLE_CLUSTERING, | ||
213 | }; | ||
214 | |||
215 | static int __init sgiwd93_probe(struct platform_device *pdev) | ||
222 | { | 216 | { |
217 | struct sgiwd93_platform_data *pd = pdev->dev.platform_data; | ||
218 | unsigned char *wdregs = pd->wdregs; | ||
219 | struct hpc3_scsiregs *hregs = pd->hregs; | ||
223 | struct ip22_hostdata *hdata; | 220 | struct ip22_hostdata *hdata; |
224 | struct Scsi_Host *host; | 221 | struct Scsi_Host *host; |
225 | wd33c93_regs regs; | 222 | wd33c93_regs regs; |
226 | 223 | unsigned int unit = pd->unit; | |
227 | host = scsi_register(SGIblows, sizeof(struct ip22_hostdata)); | 224 | unsigned int irq = pd->irq; |
228 | if (!host) | 225 | int err; |
229 | return NULL; | 226 | |
227 | host = scsi_host_alloc(&sgiwd93_template, sizeof(struct ip22_hostdata)); | ||
228 | if (!host) { | ||
229 | err = -ENOMEM; | ||
230 | goto out; | ||
231 | } | ||
230 | 232 | ||
231 | host->base = (unsigned long) hregs; | 233 | host->base = (unsigned long) hregs; |
232 | host->irq = irq; | 234 | host->irq = irq; |
233 | 235 | ||
234 | hdata = HDATA(host); | 236 | hdata = host_to_hostdata(host); |
235 | hdata->hd.cpu = dma_alloc_coherent(NULL, PAGE_SIZE, &hdata->hd.dma, | 237 | hdata->hd.cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, |
236 | GFP_KERNEL); | 238 | &hdata->hd.dma, GFP_KERNEL); |
237 | if (!hdata->hd.cpu) { | 239 | if (!hdata->hd.cpu) { |
238 | printk(KERN_WARNING "sgiwd93: Could not allocate memory for " | 240 | printk(KERN_WARNING "sgiwd93: Could not allocate memory for " |
239 | "host %d buffer.\n", unit); | 241 | "host %d buffer.\n", unit); |
240 | goto out_unregister; | 242 | err = -ENOMEM; |
243 | goto out_put; | ||
241 | } | 244 | } |
245 | |||
242 | init_hpc_chain(&hdata->hd); | 246 | init_hpc_chain(&hdata->hd); |
243 | 247 | ||
244 | regs.SASR = wdregs + 3; | 248 | regs.SASR = wdregs + 3; |
@@ -249,95 +253,67 @@ static struct Scsi_Host * __init sgiwd93_setup_scsi( | |||
249 | if (hdata->wh.no_sync == 0xff) | 253 | if (hdata->wh.no_sync == 0xff) |
250 | hdata->wh.no_sync = 0; | 254 | hdata->wh.no_sync = 0; |
251 | 255 | ||
252 | if (request_irq(irq, sgiwd93_intr, 0, "SGI WD93", (void *) host)) { | 256 | err = request_irq(irq, sgiwd93_intr, 0, "SGI WD93", host); |
257 | if (err) { | ||
253 | printk(KERN_WARNING "sgiwd93: Could not register irq %d " | 258 | printk(KERN_WARNING "sgiwd93: Could not register irq %d " |
254 | "for host %d.\n", irq, unit); | 259 | "for host %d.\n", irq, unit); |
255 | goto out_free; | 260 | goto out_free; |
256 | } | 261 | } |
257 | return host; | ||
258 | 262 | ||
259 | out_free: | 263 | platform_set_drvdata(pdev, host); |
260 | dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); | ||
261 | wd33c93_release(); | ||
262 | 264 | ||
263 | out_unregister: | 265 | err = scsi_add_host(host, NULL); |
264 | scsi_unregister(host); | 266 | if (err) |
267 | goto out_irq; | ||
265 | 268 | ||
266 | return NULL; | 269 | scsi_scan_host(host); |
267 | } | ||
268 | |||
269 | static int __init sgiwd93_detect(struct scsi_host_template *SGIblows) | ||
270 | { | ||
271 | int found = 0; | ||
272 | |||
273 | SGIblows->proc_name = "SGIWD93"; | ||
274 | sgiwd93_host = sgiwd93_setup_scsi(SGIblows, 0, SGI_WD93_0_IRQ, | ||
275 | &hpc3c0->scsi_chan0, | ||
276 | (unsigned char *)hpc3c0->scsi0_ext); | ||
277 | if (sgiwd93_host) | ||
278 | found++; | ||
279 | |||
280 | /* Set up second controller on the Indigo2 */ | ||
281 | if (ip22_is_fullhouse()) { | ||
282 | sgiwd93_host1 = sgiwd93_setup_scsi(SGIblows, 1, SGI_WD93_1_IRQ, | ||
283 | &hpc3c0->scsi_chan1, | ||
284 | (unsigned char *)hpc3c0->scsi1_ext); | ||
285 | if (sgiwd93_host1) | ||
286 | found++; | ||
287 | } | ||
288 | |||
289 | return found; | ||
290 | } | ||
291 | 270 | ||
292 | static int sgiwd93_release(struct Scsi_Host *instance) | 271 | return 0; |
293 | { | ||
294 | struct ip22_hostdata *hdata = HDATA(instance); | ||
295 | int irq = 0; | ||
296 | |||
297 | if (sgiwd93_host && sgiwd93_host == instance) | ||
298 | irq = SGI_WD93_0_IRQ; | ||
299 | else if (sgiwd93_host1 && sgiwd93_host1 == instance) | ||
300 | irq = SGI_WD93_1_IRQ; | ||
301 | 272 | ||
302 | free_irq(irq, sgiwd93_intr); | 273 | out_irq: |
274 | free_irq(irq, host); | ||
275 | out_free: | ||
303 | dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); | 276 | dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); |
304 | wd33c93_release(); | 277 | out_put: |
278 | scsi_host_put(host); | ||
279 | out: | ||
305 | 280 | ||
306 | return 1; | 281 | return err; |
307 | } | 282 | } |
308 | 283 | ||
309 | static int sgiwd93_bus_reset(struct scsi_cmnd *cmd) | 284 | static void __exit sgiwd93_remove(struct platform_device *pdev) |
310 | { | 285 | { |
311 | /* FIXME perform bus-specific reset */ | 286 | struct Scsi_Host *host = platform_get_drvdata(pdev); |
287 | struct ip22_hostdata *hdata = (struct ip22_hostdata *) host->hostdata; | ||
288 | struct sgiwd93_platform_data *pd = pdev->dev.platform_data; | ||
289 | |||
290 | scsi_remove_host(host); | ||
291 | free_irq(pd->irq, host); | ||
292 | dma_free_coherent(&pdev->dev, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); | ||
293 | scsi_host_put(host); | ||
294 | } | ||
312 | 295 | ||
313 | /* FIXME 2: kill this function, and let midlayer fallback | 296 | static struct platform_driver sgiwd93_driver = { |
314 | to the same result, calling wd33c93_host_reset() */ | 297 | .probe = sgiwd93_probe, |
298 | .remove = __devexit_p(sgiwd93_remove), | ||
299 | .driver = { | ||
300 | .name = "sgiwd93" | ||
301 | } | ||
302 | }; | ||
315 | 303 | ||
316 | spin_lock_irq(cmd->device->host->host_lock); | 304 | static int __init sgiwd93_module_init(void) |
317 | wd33c93_host_reset(cmd); | 305 | { |
318 | spin_unlock_irq(cmd->device->host->host_lock); | 306 | return platform_driver_register(&sgiwd93_driver); |
307 | } | ||
319 | 308 | ||
320 | return SUCCESS; | 309 | static void __exit sgiwd93_module_exit(void) |
310 | { | ||
311 | return platform_driver_unregister(&sgiwd93_driver); | ||
321 | } | 312 | } |
322 | 313 | ||
323 | /* | 314 | module_init(sgiwd93_module_init); |
324 | * Kludge alert - the SCSI code calls the abort and reset method with int | 315 | module_exit(sgiwd93_module_exit); |
325 | * arguments not with pointers. So this is going to blow up beautyfully | 316 | |
326 | * on 64-bit systems with memory outside the compat address spaces. | 317 | MODULE_DESCRIPTION("SGI WD33C93 driver"); |
327 | */ | 318 | MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>"); |
328 | static struct scsi_host_template driver_template = { | 319 | MODULE_LICENSE("GPL"); |
329 | .proc_name = "SGIWD93", | ||
330 | .name = "SGI WD93", | ||
331 | .detect = sgiwd93_detect, | ||
332 | .release = sgiwd93_release, | ||
333 | .queuecommand = wd33c93_queuecommand, | ||
334 | .eh_abort_handler = wd33c93_abort, | ||
335 | .eh_bus_reset_handler = sgiwd93_bus_reset, | ||
336 | .eh_host_reset_handler = wd33c93_host_reset, | ||
337 | .can_queue = 16, | ||
338 | .this_id = 7, | ||
339 | .sg_tablesize = SG_ALL, | ||
340 | .cmd_per_lun = 8, | ||
341 | .use_clustering = DISABLE_CLUSTERING, | ||
342 | }; | ||
343 | #include "scsi_module.c" | ||
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 7c9d37f651e3..5e3f748f2693 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -107,6 +107,13 @@ config SPI_IMX | |||
107 | This enables using the Freescale iMX SPI controller in master | 107 | This enables using the Freescale iMX SPI controller in master |
108 | mode. | 108 | mode. |
109 | 109 | ||
110 | config SPI_MPC52xx_PSC | ||
111 | tristate "Freescale MPC52xx PSC SPI controller" | ||
112 | depends on SPI_MASTER && PPC_MPC52xx && EXPERIMENTAL | ||
113 | help | ||
114 | This enables using the Freescale MPC52xx Programmable Serial | ||
115 | Controller in master SPI mode. | ||
116 | |||
110 | config SPI_MPC83xx | 117 | config SPI_MPC83xx |
111 | tristate "Freescale MPC83xx SPI controller" | 118 | tristate "Freescale MPC83xx SPI controller" |
112 | depends on SPI_MASTER && PPC_83xx && EXPERIMENTAL | 119 | depends on SPI_MASTER && PPC_83xx && EXPERIMENTAL |
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 624b6363f490..5788d867de84 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile | |||
@@ -19,6 +19,7 @@ obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o | |||
19 | obj-$(CONFIG_SPI_IMX) += spi_imx.o | 19 | obj-$(CONFIG_SPI_IMX) += spi_imx.o |
20 | obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o | 20 | obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o |
21 | obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o | 21 | obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o |
22 | obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o | ||
22 | obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o | 23 | obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o |
23 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o | 24 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o |
24 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o | 25 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o |
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c new file mode 100644 index 000000000000..052359fc41ee --- /dev/null +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -0,0 +1,654 @@ | |||
1 | /* | ||
2 | * MPC52xx SPC in SPI mode driver. | ||
3 | * | ||
4 | * Maintainer: Dragos Carp | ||
5 | * | ||
6 | * Copyright (C) 2006 TOPTICA Photonics AG. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | |||
19 | #if defined(CONFIG_PPC_MERGE) | ||
20 | #include <asm/of_platform.h> | ||
21 | #else | ||
22 | #include <linux/platform_device.h> | ||
23 | #endif | ||
24 | |||
25 | #include <linux/workqueue.h> | ||
26 | #include <linux/completion.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <linux/delay.h> | ||
29 | #include <linux/spi/spi.h> | ||
30 | #include <linux/fsl_devices.h> | ||
31 | |||
32 | #include <asm/mpc52xx.h> | ||
33 | #include <asm/mpc52xx_psc.h> | ||
34 | |||
35 | #define MCLK 20000000 /* PSC port MClk in hz */ | ||
36 | |||
37 | struct mpc52xx_psc_spi { | ||
38 | /* fsl_spi_platform data */ | ||
39 | void (*activate_cs)(u8, u8); | ||
40 | void (*deactivate_cs)(u8, u8); | ||
41 | u32 sysclk; | ||
42 | |||
43 | /* driver internal data */ | ||
44 | struct mpc52xx_psc __iomem *psc; | ||
45 | unsigned int irq; | ||
46 | u8 bits_per_word; | ||
47 | u8 busy; | ||
48 | |||
49 | struct workqueue_struct *workqueue; | ||
50 | struct work_struct work; | ||
51 | |||
52 | struct list_head queue; | ||
53 | spinlock_t lock; | ||
54 | |||
55 | struct completion done; | ||
56 | }; | ||
57 | |||
58 | /* controller state */ | ||
59 | struct mpc52xx_psc_spi_cs { | ||
60 | int bits_per_word; | ||
61 | int speed_hz; | ||
62 | }; | ||
63 | |||
64 | /* set clock freq, clock ramp, bits per work | ||
65 | * if t is NULL then reset the values to the default values | ||
66 | */ | ||
67 | static int mpc52xx_psc_spi_transfer_setup(struct spi_device *spi, | ||
68 | struct spi_transfer *t) | ||
69 | { | ||
70 | struct mpc52xx_psc_spi_cs *cs = spi->controller_state; | ||
71 | |||
72 | cs->speed_hz = (t && t->speed_hz) | ||
73 | ? t->speed_hz : spi->max_speed_hz; | ||
74 | cs->bits_per_word = (t && t->bits_per_word) | ||
75 | ? t->bits_per_word : spi->bits_per_word; | ||
76 | cs->bits_per_word = ((cs->bits_per_word + 7) / 8) * 8; | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi) | ||
81 | { | ||
82 | struct mpc52xx_psc_spi_cs *cs = spi->controller_state; | ||
83 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
84 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
85 | u32 sicr; | ||
86 | u16 ccr; | ||
87 | |||
88 | sicr = in_be32(&psc->sicr); | ||
89 | |||
90 | /* Set clock phase and polarity */ | ||
91 | if (spi->mode & SPI_CPHA) | ||
92 | sicr |= 0x00001000; | ||
93 | else | ||
94 | sicr &= ~0x00001000; | ||
95 | if (spi->mode & SPI_CPOL) | ||
96 | sicr |= 0x00002000; | ||
97 | else | ||
98 | sicr &= ~0x00002000; | ||
99 | |||
100 | if (spi->mode & SPI_LSB_FIRST) | ||
101 | sicr |= 0x10000000; | ||
102 | else | ||
103 | sicr &= ~0x10000000; | ||
104 | out_be32(&psc->sicr, sicr); | ||
105 | |||
106 | /* Set clock frequency and bits per word | ||
107 | * Because psc->ccr is defined as 16bit register instead of 32bit | ||
108 | * just set the lower byte of BitClkDiv | ||
109 | */ | ||
110 | ccr = in_be16(&psc->ccr); | ||
111 | ccr &= 0xFF00; | ||
112 | if (cs->speed_hz) | ||
113 | ccr |= (MCLK / cs->speed_hz - 1) & 0xFF; | ||
114 | else /* by default SPI Clk 1MHz */ | ||
115 | ccr |= (MCLK / 1000000 - 1) & 0xFF; | ||
116 | out_be16(&psc->ccr, ccr); | ||
117 | mps->bits_per_word = cs->bits_per_word; | ||
118 | |||
119 | if (mps->activate_cs) | ||
120 | mps->activate_cs(spi->chip_select, | ||
121 | (spi->mode & SPI_CS_HIGH) ? 1 : 0); | ||
122 | } | ||
123 | |||
124 | static void mpc52xx_psc_spi_deactivate_cs(struct spi_device *spi) | ||
125 | { | ||
126 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
127 | |||
128 | if (mps->deactivate_cs) | ||
129 | mps->deactivate_cs(spi->chip_select, | ||
130 | (spi->mode & SPI_CS_HIGH) ? 1 : 0); | ||
131 | } | ||
132 | |||
133 | #define MPC52xx_PSC_BUFSIZE (MPC52xx_PSC_RFNUM_MASK + 1) | ||
134 | /* wake up when 80% fifo full */ | ||
135 | #define MPC52xx_PSC_RFALARM (MPC52xx_PSC_BUFSIZE * 20 / 100) | ||
136 | |||
137 | static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi, | ||
138 | struct spi_transfer *t) | ||
139 | { | ||
140 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
141 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
142 | unsigned rb = 0; /* number of bytes receieved */ | ||
143 | unsigned sb = 0; /* number of bytes sent */ | ||
144 | unsigned char *rx_buf = (unsigned char *)t->rx_buf; | ||
145 | unsigned char *tx_buf = (unsigned char *)t->tx_buf; | ||
146 | unsigned rfalarm; | ||
147 | unsigned send_at_once = MPC52xx_PSC_BUFSIZE; | ||
148 | unsigned recv_at_once; | ||
149 | unsigned bpw = mps->bits_per_word / 8; | ||
150 | |||
151 | if (!t->tx_buf && !t->rx_buf && t->len) | ||
152 | return -EINVAL; | ||
153 | |||
154 | /* enable transmiter/receiver */ | ||
155 | out_8(&psc->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); | ||
156 | while (rb < t->len) { | ||
157 | if (t->len - rb > MPC52xx_PSC_BUFSIZE) { | ||
158 | rfalarm = MPC52xx_PSC_RFALARM; | ||
159 | } else { | ||
160 | send_at_once = t->len - sb; | ||
161 | rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); | ||
162 | } | ||
163 | |||
164 | dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); | ||
165 | if (tx_buf) { | ||
166 | for (; send_at_once; sb++, send_at_once--) { | ||
167 | /* set EOF flag */ | ||
168 | if (mps->bits_per_word | ||
169 | && (sb + 1) % bpw == 0) | ||
170 | out_8(&psc->ircr2, 0x01); | ||
171 | out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]); | ||
172 | } | ||
173 | } else { | ||
174 | for (; send_at_once; sb++, send_at_once--) { | ||
175 | /* set EOF flag */ | ||
176 | if (mps->bits_per_word | ||
177 | && ((sb + 1) % bpw) == 0) | ||
178 | out_8(&psc->ircr2, 0x01); | ||
179 | out_8(&psc->mpc52xx_psc_buffer_8, 0); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | |||
184 | /* enable interupts and wait for wake up | ||
185 | * if just one byte is expected the Rx FIFO genererates no | ||
186 | * FFULL interrupt, so activate the RxRDY interrupt | ||
187 | */ | ||
188 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); | ||
189 | if (t->len - rb == 1) { | ||
190 | out_8(&psc->mode, 0); | ||
191 | } else { | ||
192 | out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL); | ||
193 | out_be16(&psc->rfalarm, rfalarm); | ||
194 | } | ||
195 | out_be16(&psc->mpc52xx_psc_imr, MPC52xx_PSC_IMR_RXRDY); | ||
196 | wait_for_completion(&mps->done); | ||
197 | recv_at_once = in_be16(&psc->rfnum); | ||
198 | dev_dbg(&spi->dev, "%d bytes received\n", recv_at_once); | ||
199 | |||
200 | send_at_once = recv_at_once; | ||
201 | if (rx_buf) { | ||
202 | for (; recv_at_once; rb++, recv_at_once--) | ||
203 | rx_buf[rb] = in_8(&psc->mpc52xx_psc_buffer_8); | ||
204 | } else { | ||
205 | for (; recv_at_once; rb++, recv_at_once--) | ||
206 | in_8(&psc->mpc52xx_psc_buffer_8); | ||
207 | } | ||
208 | } | ||
209 | /* disable transmiter/receiver */ | ||
210 | out_8(&psc->command, MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE); | ||
211 | |||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | static void mpc52xx_psc_spi_work(struct work_struct *work) | ||
216 | { | ||
217 | struct mpc52xx_psc_spi *mps = | ||
218 | container_of(work, struct mpc52xx_psc_spi, work); | ||
219 | |||
220 | spin_lock_irq(&mps->lock); | ||
221 | mps->busy = 1; | ||
222 | while (!list_empty(&mps->queue)) { | ||
223 | struct spi_message *m; | ||
224 | struct spi_device *spi; | ||
225 | struct spi_transfer *t = NULL; | ||
226 | unsigned cs_change; | ||
227 | int status; | ||
228 | |||
229 | m = container_of(mps->queue.next, struct spi_message, queue); | ||
230 | list_del_init(&m->queue); | ||
231 | spin_unlock_irq(&mps->lock); | ||
232 | |||
233 | spi = m->spi; | ||
234 | cs_change = 1; | ||
235 | status = 0; | ||
236 | list_for_each_entry (t, &m->transfers, transfer_list) { | ||
237 | if (t->bits_per_word || t->speed_hz) { | ||
238 | status = mpc52xx_psc_spi_transfer_setup(spi, t); | ||
239 | if (status < 0) | ||
240 | break; | ||
241 | } | ||
242 | |||
243 | if (cs_change) | ||
244 | mpc52xx_psc_spi_activate_cs(spi); | ||
245 | cs_change = t->cs_change; | ||
246 | |||
247 | status = mpc52xx_psc_spi_transfer_rxtx(spi, t); | ||
248 | if (status) | ||
249 | break; | ||
250 | m->actual_length += t->len; | ||
251 | |||
252 | if (t->delay_usecs) | ||
253 | udelay(t->delay_usecs); | ||
254 | |||
255 | if (cs_change) | ||
256 | mpc52xx_psc_spi_deactivate_cs(spi); | ||
257 | } | ||
258 | |||
259 | m->status = status; | ||
260 | m->complete(m->context); | ||
261 | |||
262 | if (status || !cs_change) | ||
263 | mpc52xx_psc_spi_deactivate_cs(spi); | ||
264 | |||
265 | mpc52xx_psc_spi_transfer_setup(spi, NULL); | ||
266 | |||
267 | spin_lock_irq(&mps->lock); | ||
268 | } | ||
269 | mps->busy = 0; | ||
270 | spin_unlock_irq(&mps->lock); | ||
271 | } | ||
272 | |||
273 | static int mpc52xx_psc_spi_setup(struct spi_device *spi) | ||
274 | { | ||
275 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
276 | struct mpc52xx_psc_spi_cs *cs = spi->controller_state; | ||
277 | unsigned long flags; | ||
278 | |||
279 | if (spi->bits_per_word%8) | ||
280 | return -EINVAL; | ||
281 | |||
282 | if (!cs) { | ||
283 | cs = kzalloc(sizeof *cs, GFP_KERNEL); | ||
284 | if (!cs) | ||
285 | return -ENOMEM; | ||
286 | spi->controller_state = cs; | ||
287 | } | ||
288 | |||
289 | cs->bits_per_word = spi->bits_per_word; | ||
290 | cs->speed_hz = spi->max_speed_hz; | ||
291 | |||
292 | spin_lock_irqsave(&mps->lock, flags); | ||
293 | if (!mps->busy) | ||
294 | mpc52xx_psc_spi_deactivate_cs(spi); | ||
295 | spin_unlock_irqrestore(&mps->lock, flags); | ||
296 | |||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static int mpc52xx_psc_spi_transfer(struct spi_device *spi, | ||
301 | struct spi_message *m) | ||
302 | { | ||
303 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
304 | unsigned long flags; | ||
305 | |||
306 | m->actual_length = 0; | ||
307 | m->status = -EINPROGRESS; | ||
308 | |||
309 | spin_lock_irqsave(&mps->lock, flags); | ||
310 | list_add_tail(&m->queue, &mps->queue); | ||
311 | queue_work(mps->workqueue, &mps->work); | ||
312 | spin_unlock_irqrestore(&mps->lock, flags); | ||
313 | |||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | static void mpc52xx_psc_spi_cleanup(struct spi_device *spi) | ||
318 | { | ||
319 | kfree(spi->controller_state); | ||
320 | } | ||
321 | |||
322 | static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) | ||
323 | { | ||
324 | struct mpc52xx_cdm __iomem *cdm; | ||
325 | struct mpc52xx_gpio __iomem *gpio; | ||
326 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
327 | u32 ul; | ||
328 | u32 mclken_div; | ||
329 | int ret = 0; | ||
330 | |||
331 | #if defined(CONFIG_PPC_MERGE) | ||
332 | cdm = mpc52xx_find_and_map("mpc52xx-cdm"); | ||
333 | gpio = mpc52xx_find_and_map("mpc52xx-gpio"); | ||
334 | #else | ||
335 | cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE); | ||
336 | gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE); | ||
337 | #endif | ||
338 | if (!cdm || !gpio) { | ||
339 | printk(KERN_ERR "Error mapping CDM/GPIO\n"); | ||
340 | ret = -EFAULT; | ||
341 | goto unmap_regs; | ||
342 | } | ||
343 | |||
344 | /* default sysclk is 512MHz */ | ||
345 | mclken_div = 0x8000 | | ||
346 | (((mps->sysclk ? mps->sysclk : 512000000) / MCLK) & 0x1FF); | ||
347 | |||
348 | switch (psc_id) { | ||
349 | case 1: | ||
350 | ul = in_be32(&gpio->port_config); | ||
351 | ul &= 0xFFFFFFF8; | ||
352 | ul |= 0x00000006; | ||
353 | out_be32(&gpio->port_config, ul); | ||
354 | out_be16(&cdm->mclken_div_psc1, mclken_div); | ||
355 | ul = in_be32(&cdm->clk_enables); | ||
356 | ul |= 0x00000020; | ||
357 | out_be32(&cdm->clk_enables, ul); | ||
358 | break; | ||
359 | case 2: | ||
360 | ul = in_be32(&gpio->port_config); | ||
361 | ul &= 0xFFFFFF8F; | ||
362 | ul |= 0x00000060; | ||
363 | out_be32(&gpio->port_config, ul); | ||
364 | out_be16(&cdm->mclken_div_psc2, mclken_div); | ||
365 | ul = in_be32(&cdm->clk_enables); | ||
366 | ul |= 0x00000040; | ||
367 | out_be32(&cdm->clk_enables, ul); | ||
368 | break; | ||
369 | case 3: | ||
370 | ul = in_be32(&gpio->port_config); | ||
371 | ul &= 0xFFFFF0FF; | ||
372 | ul |= 0x00000600; | ||
373 | out_be32(&gpio->port_config, ul); | ||
374 | out_be16(&cdm->mclken_div_psc3, mclken_div); | ||
375 | ul = in_be32(&cdm->clk_enables); | ||
376 | ul |= 0x00000080; | ||
377 | out_be32(&cdm->clk_enables, ul); | ||
378 | break; | ||
379 | case 6: | ||
380 | ul = in_be32(&gpio->port_config); | ||
381 | ul &= 0xFF8FFFFF; | ||
382 | ul |= 0x00700000; | ||
383 | out_be32(&gpio->port_config, ul); | ||
384 | out_be16(&cdm->mclken_div_psc6, mclken_div); | ||
385 | ul = in_be32(&cdm->clk_enables); | ||
386 | ul |= 0x00000010; | ||
387 | out_be32(&cdm->clk_enables, ul); | ||
388 | break; | ||
389 | default: | ||
390 | ret = -EINVAL; | ||
391 | goto unmap_regs; | ||
392 | } | ||
393 | |||
394 | /* Reset the PSC into a known state */ | ||
395 | out_8(&psc->command, MPC52xx_PSC_RST_RX); | ||
396 | out_8(&psc->command, MPC52xx_PSC_RST_TX); | ||
397 | out_8(&psc->command, MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE); | ||
398 | |||
399 | /* Disable interrupts, interrupts are based on alarm level */ | ||
400 | out_be16(&psc->mpc52xx_psc_imr, 0); | ||
401 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); | ||
402 | out_8(&psc->rfcntl, 0); | ||
403 | out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL); | ||
404 | |||
405 | /* Configure 8bit codec mode as a SPI master and use EOF flags */ | ||
406 | /* SICR_SIM_CODEC8|SICR_GENCLK|SICR_SPI|SICR_MSTR|SICR_USEEOF */ | ||
407 | out_be32(&psc->sicr, 0x0180C800); | ||
408 | out_be16(&psc->ccr, 0x070F); /* by default SPI Clk 1MHz */ | ||
409 | |||
410 | /* Set 2ms DTL delay */ | ||
411 | out_8(&psc->ctur, 0x00); | ||
412 | out_8(&psc->ctlr, 0x84); | ||
413 | |||
414 | mps->bits_per_word = 8; | ||
415 | |||
416 | unmap_regs: | ||
417 | if (cdm) | ||
418 | iounmap(cdm); | ||
419 | if (gpio) | ||
420 | iounmap(gpio); | ||
421 | |||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) | ||
426 | { | ||
427 | struct mpc52xx_psc_spi *mps = (struct mpc52xx_psc_spi *)dev_id; | ||
428 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
429 | |||
430 | /* disable interrupt and wake up the work queue */ | ||
431 | if (in_be16(&psc->mpc52xx_psc_isr) & MPC52xx_PSC_IMR_RXRDY) { | ||
432 | out_be16(&psc->mpc52xx_psc_imr, 0); | ||
433 | complete(&mps->done); | ||
434 | return IRQ_HANDLED; | ||
435 | } | ||
436 | return IRQ_NONE; | ||
437 | } | ||
438 | |||
439 | /* bus_num is used only for the case dev->platform_data == NULL */ | ||
440 | static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | ||
441 | u32 size, unsigned int irq, s16 bus_num) | ||
442 | { | ||
443 | struct fsl_spi_platform_data *pdata = dev->platform_data; | ||
444 | struct mpc52xx_psc_spi *mps; | ||
445 | struct spi_master *master; | ||
446 | int ret; | ||
447 | |||
448 | if (pdata == NULL) | ||
449 | return -ENODEV; | ||
450 | |||
451 | master = spi_alloc_master(dev, sizeof *mps); | ||
452 | if (master == NULL) | ||
453 | return -ENOMEM; | ||
454 | |||
455 | dev_set_drvdata(dev, master); | ||
456 | mps = spi_master_get_devdata(master); | ||
457 | |||
458 | mps->irq = irq; | ||
459 | if (pdata == NULL) { | ||
460 | dev_warn(dev, "probe called without platform data, no " | ||
461 | "(de)activate_cs function will be called\n"); | ||
462 | mps->activate_cs = NULL; | ||
463 | mps->deactivate_cs = NULL; | ||
464 | mps->sysclk = 0; | ||
465 | master->bus_num = bus_num; | ||
466 | master->num_chipselect = 255; | ||
467 | } else { | ||
468 | mps->activate_cs = pdata->activate_cs; | ||
469 | mps->deactivate_cs = pdata->deactivate_cs; | ||
470 | mps->sysclk = pdata->sysclk; | ||
471 | master->bus_num = pdata->bus_num; | ||
472 | master->num_chipselect = pdata->max_chipselect; | ||
473 | } | ||
474 | master->setup = mpc52xx_psc_spi_setup; | ||
475 | master->transfer = mpc52xx_psc_spi_transfer; | ||
476 | master->cleanup = mpc52xx_psc_spi_cleanup; | ||
477 | |||
478 | mps->psc = ioremap(regaddr, size); | ||
479 | if (!mps->psc) { | ||
480 | dev_err(dev, "could not ioremap I/O port range\n"); | ||
481 | ret = -EFAULT; | ||
482 | goto free_master; | ||
483 | } | ||
484 | |||
485 | ret = request_irq(mps->irq, mpc52xx_psc_spi_isr, 0, "mpc52xx-psc-spi", | ||
486 | mps); | ||
487 | if (ret) | ||
488 | goto free_master; | ||
489 | |||
490 | ret = mpc52xx_psc_spi_port_config(master->bus_num, mps); | ||
491 | if (ret < 0) | ||
492 | goto free_irq; | ||
493 | |||
494 | spin_lock_init(&mps->lock); | ||
495 | init_completion(&mps->done); | ||
496 | INIT_WORK(&mps->work, mpc52xx_psc_spi_work); | ||
497 | INIT_LIST_HEAD(&mps->queue); | ||
498 | |||
499 | mps->workqueue = create_singlethread_workqueue( | ||
500 | master->cdev.dev->bus_id); | ||
501 | if (mps->workqueue == NULL) { | ||
502 | ret = -EBUSY; | ||
503 | goto free_irq; | ||
504 | } | ||
505 | |||
506 | ret = spi_register_master(master); | ||
507 | if (ret < 0) | ||
508 | goto unreg_master; | ||
509 | |||
510 | return ret; | ||
511 | |||
512 | unreg_master: | ||
513 | destroy_workqueue(mps->workqueue); | ||
514 | free_irq: | ||
515 | free_irq(mps->irq, mps); | ||
516 | free_master: | ||
517 | if (mps->psc) | ||
518 | iounmap(mps->psc); | ||
519 | spi_master_put(master); | ||
520 | |||
521 | return ret; | ||
522 | } | ||
523 | |||
524 | static int __exit mpc52xx_psc_spi_do_remove(struct device *dev) | ||
525 | { | ||
526 | struct spi_master *master = dev_get_drvdata(dev); | ||
527 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master); | ||
528 | |||
529 | flush_workqueue(mps->workqueue); | ||
530 | destroy_workqueue(mps->workqueue); | ||
531 | spi_unregister_master(master); | ||
532 | free_irq(mps->irq, mps); | ||
533 | if (mps->psc) | ||
534 | iounmap(mps->psc); | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
539 | #if !defined(CONFIG_PPC_MERGE) | ||
540 | static int __init mpc52xx_psc_spi_probe(struct platform_device *dev) | ||
541 | { | ||
542 | switch(dev->id) { | ||
543 | case 1: | ||
544 | case 2: | ||
545 | case 3: | ||
546 | case 6: | ||
547 | return mpc52xx_psc_spi_do_probe(&dev->dev, | ||
548 | MPC52xx_PA(MPC52xx_PSCx_OFFSET(dev->id)), | ||
549 | MPC52xx_PSC_SIZE, platform_get_irq(dev, 0), dev->id); | ||
550 | default: | ||
551 | return -EINVAL; | ||
552 | } | ||
553 | } | ||
554 | |||
555 | static int __exit mpc52xx_psc_spi_remove(struct platform_device *dev) | ||
556 | { | ||
557 | return mpc52xx_psc_spi_do_remove(&dev->dev); | ||
558 | } | ||
559 | |||
560 | static struct platform_driver mpc52xx_psc_spi_platform_driver = { | ||
561 | .remove = __exit_p(mpc52xx_psc_spi_remove), | ||
562 | .driver = { | ||
563 | .name = "mpc52xx-psc-spi", | ||
564 | .owner = THIS_MODULE, | ||
565 | }, | ||
566 | }; | ||
567 | |||
568 | static int __init mpc52xx_psc_spi_init(void) | ||
569 | { | ||
570 | return platform_driver_probe(&mpc52xx_psc_spi_platform_driver, | ||
571 | mpc52xx_psc_spi_probe); | ||
572 | } | ||
573 | module_init(mpc52xx_psc_spi_init); | ||
574 | |||
575 | static void __exit mpc52xx_psc_spi_exit(void) | ||
576 | { | ||
577 | platform_driver_unregister(&mpc52xx_psc_spi_platform_driver); | ||
578 | } | ||
579 | module_exit(mpc52xx_psc_spi_exit); | ||
580 | |||
581 | #else /* defined(CONFIG_PPC_MERGE) */ | ||
582 | |||
583 | static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | ||
584 | const struct of_device_id *match) | ||
585 | { | ||
586 | const u32 *regaddr_p; | ||
587 | u64 regaddr64, size64; | ||
588 | s16 id = -1; | ||
589 | |||
590 | regaddr_p = of_get_address(op->node, 0, &size64, NULL); | ||
591 | if (!regaddr_p) { | ||
592 | printk(KERN_ERR "Invalid PSC address\n"); | ||
593 | return -EINVAL; | ||
594 | } | ||
595 | regaddr64 = of_translate_address(op->node, regaddr_p); | ||
596 | |||
597 | if (op->dev.platform_data == NULL) { | ||
598 | struct device_node *np; | ||
599 | int i = 0; | ||
600 | |||
601 | for_each_node_by_type(np, "spi") { | ||
602 | if (of_find_device_by_node(np) == op) { | ||
603 | id = i; | ||
604 | break; | ||
605 | } | ||
606 | i++; | ||
607 | } | ||
608 | } | ||
609 | |||
610 | return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, | ||
611 | irq_of_parse_and_map(op->node, 0), id); | ||
612 | } | ||
613 | |||
614 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) | ||
615 | { | ||
616 | return mpc52xx_psc_spi_do_remove(&op->dev); | ||
617 | } | ||
618 | |||
619 | static struct of_device_id mpc52xx_psc_spi_of_match[] = { | ||
620 | { .type = "spi", .compatible = "mpc52xx-psc-spi", }, | ||
621 | {}, | ||
622 | }; | ||
623 | |||
624 | MODULE_DEVICE_TABLE(of, mpc52xx_psc_spi_of_match); | ||
625 | |||
626 | static struct of_platform_driver mpc52xx_psc_spi_of_driver = { | ||
627 | .owner = THIS_MODULE, | ||
628 | .name = "mpc52xx-psc-spi", | ||
629 | .match_table = mpc52xx_psc_spi_of_match, | ||
630 | .probe = mpc52xx_psc_spi_of_probe, | ||
631 | .remove = __exit_p(mpc52xx_psc_spi_of_remove), | ||
632 | .driver = { | ||
633 | .name = "mpc52xx-psc-spi", | ||
634 | .owner = THIS_MODULE, | ||
635 | }, | ||
636 | }; | ||
637 | |||
638 | static int __init mpc52xx_psc_spi_init(void) | ||
639 | { | ||
640 | return of_register_platform_driver(&mpc52xx_psc_spi_of_driver); | ||
641 | } | ||
642 | module_init(mpc52xx_psc_spi_init); | ||
643 | |||
644 | static void __exit mpc52xx_psc_spi_exit(void) | ||
645 | { | ||
646 | of_unregister_platform_driver(&mpc52xx_psc_spi_of_driver); | ||
647 | } | ||
648 | module_exit(mpc52xx_psc_spi_exit); | ||
649 | |||
650 | #endif /* defined(CONFIG_PPC_MERGE) */ | ||
651 | |||
652 | MODULE_AUTHOR("Dragos Carp"); | ||
653 | MODULE_DESCRIPTION("MPC52xx PSC SPI Driver"); | ||
654 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index f54438828cb9..eebcb708cff1 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -748,6 +748,22 @@ config FB_S1D13XXX | |||
748 | working with S1D13806). Product specs at | 748 | working with S1D13806). Product specs at |
749 | <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> | 749 | <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> |
750 | 750 | ||
751 | config FB_ATMEL | ||
752 | tristate "AT91/AT32 LCD Controller support" | ||
753 | depends on FB && (ARCH_AT91SAM9261 || ARCH_AT91SAM9263 || AVR32) | ||
754 | select FB_CFB_FILLRECT | ||
755 | select FB_CFB_COPYAREA | ||
756 | select FB_CFB_IMAGEBLIT | ||
757 | help | ||
758 | This enables support for the AT91/AT32 LCD Controller. | ||
759 | |||
760 | config FB_INTSRAM | ||
761 | bool "Frame Buffer in internal SRAM" | ||
762 | depends on FB_ATMEL && ARCH_AT91SAM9261 | ||
763 | help | ||
764 | Say Y if you want to map Frame Buffer in internal SRAM. Say N if you want | ||
765 | to let frame buffer in external SDRAM. | ||
766 | |||
751 | config FB_NVIDIA | 767 | config FB_NVIDIA |
752 | tristate "nVidia Framebuffer Support" | 768 | tristate "nVidia Framebuffer Support" |
753 | depends on FB && PCI | 769 | depends on FB && PCI |
@@ -780,6 +796,15 @@ config FB_NVIDIA_I2C | |||
780 | independently validate video mode parameters, you should say Y | 796 | independently validate video mode parameters, you should say Y |
781 | here. | 797 | here. |
782 | 798 | ||
799 | config FB_NVIDIA_DEBUG | ||
800 | bool "Lots of debug output" | ||
801 | depends on FB_NVIDIA | ||
802 | default n | ||
803 | help | ||
804 | Say Y here if you want the nVidia driver to output all sorts | ||
805 | of debugging information to provide to the maintainer when | ||
806 | something goes wrong. | ||
807 | |||
783 | config FB_NVIDIA_BACKLIGHT | 808 | config FB_NVIDIA_BACKLIGHT |
784 | bool "Support for backlight control" | 809 | bool "Support for backlight control" |
785 | depends on FB_NVIDIA | 810 | depends on FB_NVIDIA |
@@ -819,7 +844,7 @@ config FB_RIVA_I2C | |||
819 | here. | 844 | here. |
820 | 845 | ||
821 | config FB_RIVA_DEBUG | 846 | config FB_RIVA_DEBUG |
822 | bool "Lots of debug output from Riva(nVidia) driver" | 847 | bool "Lots of debug output" |
823 | depends on FB_RIVA | 848 | depends on FB_RIVA |
824 | default n | 849 | default n |
825 | help | 850 | help |
@@ -1431,8 +1456,11 @@ config FB_ARK | |||
1431 | and ICS 5342 RAMDAC. | 1456 | and ICS 5342 RAMDAC. |
1432 | 1457 | ||
1433 | config FB_PM3 | 1458 | config FB_PM3 |
1434 | tristate "Permedia3 support" | 1459 | tristate "Permedia3 support (EXPERIMENTAL)" |
1435 | depends on FB && PCI && BROKEN | 1460 | depends on FB && PCI && EXPERIMENTAL |
1461 | select FB_CFB_FILLRECT | ||
1462 | select FB_CFB_COPYAREA | ||
1463 | select FB_CFB_IMAGEBLIT | ||
1436 | help | 1464 | help |
1437 | This is the frame buffer device driver for the 3DLabs Permedia3 | 1465 | This is the frame buffer device driver for the 3DLabs Permedia3 |
1438 | chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 & | 1466 | chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 & |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 0b70567458fb..bd8b05229500 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -87,6 +87,7 @@ obj-$(CONFIG_FB_G364) += g364fb.o | |||
87 | obj-$(CONFIG_FB_SA1100) += sa1100fb.o | 87 | obj-$(CONFIG_FB_SA1100) += sa1100fb.o |
88 | obj-$(CONFIG_FB_HIT) += hitfb.o | 88 | obj-$(CONFIG_FB_HIT) += hitfb.o |
89 | obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o | 89 | obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o |
90 | obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o | ||
90 | obj-$(CONFIG_FB_PVR2) += pvr2fb.o | 91 | obj-$(CONFIG_FB_PVR2) += pvr2fb.o |
91 | obj-$(CONFIG_FB_VOODOO1) += sstfb.o | 92 | obj-$(CONFIG_FB_VOODOO1) += sstfb.o |
92 | obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o | 93 | obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o |
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c new file mode 100644 index 000000000000..e1d5bd0c98c4 --- /dev/null +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -0,0 +1,752 @@ | |||
1 | /* | ||
2 | * Driver for AT91/AT32 LCD Controller | ||
3 | * | ||
4 | * Copyright (C) 2007 Atmel Corporation | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/dma-mapping.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/delay.h> | ||
19 | |||
20 | #include <asm/arch/board.h> | ||
21 | #include <asm/arch/cpu.h> | ||
22 | #include <asm/arch/gpio.h> | ||
23 | |||
24 | #include <video/atmel_lcdc.h> | ||
25 | |||
26 | #define lcdc_readl(sinfo, reg) __raw_readl((sinfo)->mmio+(reg)) | ||
27 | #define lcdc_writel(sinfo, reg, val) __raw_writel((val), (sinfo)->mmio+(reg)) | ||
28 | |||
29 | /* configurable parameters */ | ||
30 | #define ATMEL_LCDC_CVAL_DEFAULT 0xc8 | ||
31 | #define ATMEL_LCDC_DMA_BURST_LEN 8 | ||
32 | |||
33 | #if defined(CONFIG_ARCH_AT91SAM9263) | ||
34 | #define ATMEL_LCDC_FIFO_SIZE 2048 | ||
35 | #else | ||
36 | #define ATMEL_LCDC_FIFO_SIZE 512 | ||
37 | #endif | ||
38 | |||
39 | #if defined(CONFIG_ARCH_AT91) | ||
40 | #define ATMEL_LCDFB_FBINFO_DEFAULT FBINFO_DEFAULT | ||
41 | |||
42 | static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo, | ||
43 | struct fb_var_screeninfo *var) | ||
44 | { | ||
45 | |||
46 | } | ||
47 | #elif defined(CONFIG_AVR32) | ||
48 | #define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \ | ||
49 | | FBINFO_PARTIAL_PAN_OK \ | ||
50 | | FBINFO_HWACCEL_XPAN \ | ||
51 | | FBINFO_HWACCEL_YPAN) | ||
52 | |||
53 | static void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo, | ||
54 | struct fb_var_screeninfo *var) | ||
55 | { | ||
56 | u32 dma2dcfg; | ||
57 | u32 pixeloff; | ||
58 | |||
59 | pixeloff = (var->xoffset * var->bits_per_pixel) & 0x1f; | ||
60 | |||
61 | dma2dcfg = ((var->xres_virtual - var->xres) * var->bits_per_pixel) / 8; | ||
62 | dma2dcfg |= pixeloff << ATMEL_LCDC_PIXELOFF_OFFSET; | ||
63 | lcdc_writel(sinfo, ATMEL_LCDC_DMA2DCFG, dma2dcfg); | ||
64 | |||
65 | /* Update configuration */ | ||
66 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, | ||
67 | lcdc_readl(sinfo, ATMEL_LCDC_DMACON) | ||
68 | | ATMEL_LCDC_DMAUPDT); | ||
69 | } | ||
70 | #endif | ||
71 | |||
72 | |||
73 | static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = { | ||
74 | .type = FB_TYPE_PACKED_PIXELS, | ||
75 | .visual = FB_VISUAL_TRUECOLOR, | ||
76 | .xpanstep = 0, | ||
77 | .ypanstep = 0, | ||
78 | .ywrapstep = 0, | ||
79 | .accel = FB_ACCEL_NONE, | ||
80 | }; | ||
81 | |||
82 | |||
83 | static void atmel_lcdfb_update_dma(struct fb_info *info, | ||
84 | struct fb_var_screeninfo *var) | ||
85 | { | ||
86 | struct atmel_lcdfb_info *sinfo = info->par; | ||
87 | struct fb_fix_screeninfo *fix = &info->fix; | ||
88 | unsigned long dma_addr; | ||
89 | |||
90 | dma_addr = (fix->smem_start + var->yoffset * fix->line_length | ||
91 | + var->xoffset * var->bits_per_pixel / 8); | ||
92 | |||
93 | dma_addr &= ~3UL; | ||
94 | |||
95 | /* Set framebuffer DMA base address and pixel offset */ | ||
96 | lcdc_writel(sinfo, ATMEL_LCDC_DMABADDR1, dma_addr); | ||
97 | |||
98 | atmel_lcdfb_update_dma2d(sinfo, var); | ||
99 | } | ||
100 | |||
101 | static inline void atmel_lcdfb_free_video_memory(struct atmel_lcdfb_info *sinfo) | ||
102 | { | ||
103 | struct fb_info *info = sinfo->info; | ||
104 | |||
105 | dma_free_writecombine(info->device, info->fix.smem_len, | ||
106 | info->screen_base, info->fix.smem_start); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * atmel_lcdfb_alloc_video_memory - Allocate framebuffer memory | ||
111 | * @sinfo: the frame buffer to allocate memory for | ||
112 | */ | ||
113 | static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo) | ||
114 | { | ||
115 | struct fb_info *info = sinfo->info; | ||
116 | struct fb_var_screeninfo *var = &info->var; | ||
117 | |||
118 | info->fix.smem_len = (var->xres_virtual * var->yres_virtual | ||
119 | * ((var->bits_per_pixel + 7) / 8)); | ||
120 | |||
121 | info->screen_base = dma_alloc_writecombine(info->device, info->fix.smem_len, | ||
122 | (dma_addr_t *)&info->fix.smem_start, GFP_KERNEL); | ||
123 | |||
124 | if (!info->screen_base) { | ||
125 | return -ENOMEM; | ||
126 | } | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * atmel_lcdfb_check_var - Validates a var passed in. | ||
133 | * @var: frame buffer variable screen structure | ||
134 | * @info: frame buffer structure that represents a single frame buffer | ||
135 | * | ||
136 | * Checks to see if the hardware supports the state requested by | ||
137 | * var passed in. This function does not alter the hardware | ||
138 | * state!!! This means the data stored in struct fb_info and | ||
139 | * struct atmel_lcdfb_info do not change. This includes the var | ||
140 | * inside of struct fb_info. Do NOT change these. This function | ||
141 | * can be called on its own if we intent to only test a mode and | ||
142 | * not actually set it. The stuff in modedb.c is a example of | ||
143 | * this. If the var passed in is slightly off by what the | ||
144 | * hardware can support then we alter the var PASSED in to what | ||
145 | * we can do. If the hardware doesn't support mode change a | ||
146 | * -EINVAL will be returned by the upper layers. You don't need | ||
147 | * to implement this function then. If you hardware doesn't | ||
148 | * support changing the resolution then this function is not | ||
149 | * needed. In this case the driver would just provide a var that | ||
150 | * represents the static state the screen is in. | ||
151 | * | ||
152 | * Returns negative errno on error, or zero on success. | ||
153 | */ | ||
154 | static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, | ||
155 | struct fb_info *info) | ||
156 | { | ||
157 | struct device *dev = info->device; | ||
158 | struct atmel_lcdfb_info *sinfo = info->par; | ||
159 | unsigned long clk_value_khz; | ||
160 | |||
161 | clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000; | ||
162 | |||
163 | dev_dbg(dev, "%s:\n", __func__); | ||
164 | dev_dbg(dev, " resolution: %ux%u\n", var->xres, var->yres); | ||
165 | dev_dbg(dev, " pixclk: %lu KHz\n", PICOS2KHZ(var->pixclock)); | ||
166 | dev_dbg(dev, " bpp: %u\n", var->bits_per_pixel); | ||
167 | dev_dbg(dev, " clk: %lu KHz\n", clk_value_khz); | ||
168 | |||
169 | if ((PICOS2KHZ(var->pixclock) * var->bits_per_pixel / 8) > clk_value_khz) { | ||
170 | dev_err(dev, "%lu KHz pixel clock is too fast\n", PICOS2KHZ(var->pixclock)); | ||
171 | return -EINVAL; | ||
172 | } | ||
173 | |||
174 | /* Force same alignment for each line */ | ||
175 | var->xres = (var->xres + 3) & ~3UL; | ||
176 | var->xres_virtual = (var->xres_virtual + 3) & ~3UL; | ||
177 | |||
178 | var->red.msb_right = var->green.msb_right = var->blue.msb_right = 0; | ||
179 | var->transp.msb_right = 0; | ||
180 | var->transp.offset = var->transp.length = 0; | ||
181 | var->xoffset = var->yoffset = 0; | ||
182 | |||
183 | switch (var->bits_per_pixel) { | ||
184 | case 2: | ||
185 | case 4: | ||
186 | case 8: | ||
187 | var->red.offset = var->green.offset = var->blue.offset = 0; | ||
188 | var->red.length = var->green.length = var->blue.length | ||
189 | = var->bits_per_pixel; | ||
190 | break; | ||
191 | case 15: | ||
192 | case 16: | ||
193 | var->red.offset = 0; | ||
194 | var->green.offset = 5; | ||
195 | var->blue.offset = 10; | ||
196 | var->red.length = var->green.length = var->blue.length = 5; | ||
197 | break; | ||
198 | case 24: | ||
199 | case 32: | ||
200 | var->red.offset = 0; | ||
201 | var->green.offset = 8; | ||
202 | var->blue.offset = 16; | ||
203 | var->red.length = var->green.length = var->blue.length = 8; | ||
204 | break; | ||
205 | default: | ||
206 | dev_err(dev, "color depth %d not supported\n", | ||
207 | var->bits_per_pixel); | ||
208 | return -EINVAL; | ||
209 | } | ||
210 | |||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * atmel_lcdfb_set_par - Alters the hardware state. | ||
216 | * @info: frame buffer structure that represents a single frame buffer | ||
217 | * | ||
218 | * Using the fb_var_screeninfo in fb_info we set the resolution | ||
219 | * of the this particular framebuffer. This function alters the | ||
220 | * par AND the fb_fix_screeninfo stored in fb_info. It doesn't | ||
221 | * not alter var in fb_info since we are using that data. This | ||
222 | * means we depend on the data in var inside fb_info to be | ||
223 | * supported by the hardware. atmel_lcdfb_check_var is always called | ||
224 | * before atmel_lcdfb_set_par to ensure this. Again if you can't | ||
225 | * change the resolution you don't need this function. | ||
226 | * | ||
227 | */ | ||
228 | static int atmel_lcdfb_set_par(struct fb_info *info) | ||
229 | { | ||
230 | struct atmel_lcdfb_info *sinfo = info->par; | ||
231 | unsigned long value; | ||
232 | unsigned long clk_value_khz; | ||
233 | |||
234 | dev_dbg(info->device, "%s:\n", __func__); | ||
235 | dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n", | ||
236 | info->var.xres, info->var.yres, | ||
237 | info->var.xres_virtual, info->var.yres_virtual); | ||
238 | |||
239 | /* Turn off the LCD controller and the DMA controller */ | ||
240 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); | ||
241 | |||
242 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); | ||
243 | |||
244 | if (info->var.bits_per_pixel <= 8) | ||
245 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
246 | else | ||
247 | info->fix.visual = FB_VISUAL_TRUECOLOR; | ||
248 | |||
249 | info->fix.line_length = info->var.xres_virtual * (info->var.bits_per_pixel / 8); | ||
250 | |||
251 | /* Re-initialize the DMA engine... */ | ||
252 | dev_dbg(info->device, " * update DMA engine\n"); | ||
253 | atmel_lcdfb_update_dma(info, &info->var); | ||
254 | |||
255 | /* ...set frame size and burst length = 8 words (?) */ | ||
256 | value = (info->var.yres * info->var.xres * info->var.bits_per_pixel) / 32; | ||
257 | value |= ((ATMEL_LCDC_DMA_BURST_LEN - 1) << ATMEL_LCDC_BLENGTH_OFFSET); | ||
258 | lcdc_writel(sinfo, ATMEL_LCDC_DMAFRMCFG, value); | ||
259 | |||
260 | /* Now, the LCDC core... */ | ||
261 | |||
262 | /* Set pixel clock */ | ||
263 | clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000; | ||
264 | |||
265 | value = clk_value_khz / PICOS2KHZ(info->var.pixclock); | ||
266 | |||
267 | if (clk_value_khz % PICOS2KHZ(info->var.pixclock)) | ||
268 | value++; | ||
269 | |||
270 | value = (value / 2) - 1; | ||
271 | |||
272 | if (value <= 0) { | ||
273 | dev_notice(info->device, "Bypassing pixel clock divider\n"); | ||
274 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS); | ||
275 | } else | ||
276 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET); | ||
277 | |||
278 | /* Initialize control register 2 */ | ||
279 | value = sinfo->default_lcdcon2; | ||
280 | |||
281 | if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) | ||
282 | value |= ATMEL_LCDC_INVLINE_INVERTED; | ||
283 | if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) | ||
284 | value |= ATMEL_LCDC_INVFRAME_INVERTED; | ||
285 | |||
286 | switch (info->var.bits_per_pixel) { | ||
287 | case 1: value |= ATMEL_LCDC_PIXELSIZE_1; break; | ||
288 | case 2: value |= ATMEL_LCDC_PIXELSIZE_2; break; | ||
289 | case 4: value |= ATMEL_LCDC_PIXELSIZE_4; break; | ||
290 | case 8: value |= ATMEL_LCDC_PIXELSIZE_8; break; | ||
291 | case 15: /* fall through */ | ||
292 | case 16: value |= ATMEL_LCDC_PIXELSIZE_16; break; | ||
293 | case 24: value |= ATMEL_LCDC_PIXELSIZE_24; break; | ||
294 | case 32: value |= ATMEL_LCDC_PIXELSIZE_32; break; | ||
295 | default: BUG(); break; | ||
296 | } | ||
297 | dev_dbg(info->device, " * LCDCON2 = %08lx\n", value); | ||
298 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON2, value); | ||
299 | |||
300 | /* Vertical timing */ | ||
301 | value = (info->var.vsync_len - 1) << ATMEL_LCDC_VPW_OFFSET; | ||
302 | value |= info->var.upper_margin << ATMEL_LCDC_VBP_OFFSET; | ||
303 | value |= info->var.lower_margin; | ||
304 | dev_dbg(info->device, " * LCDTIM1 = %08lx\n", value); | ||
305 | lcdc_writel(sinfo, ATMEL_LCDC_TIM1, value); | ||
306 | |||
307 | /* Horizontal timing */ | ||
308 | value = (info->var.right_margin - 1) << ATMEL_LCDC_HFP_OFFSET; | ||
309 | value |= (info->var.hsync_len - 1) << ATMEL_LCDC_HPW_OFFSET; | ||
310 | value |= (info->var.left_margin - 1); | ||
311 | dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value); | ||
312 | lcdc_writel(sinfo, ATMEL_LCDC_TIM2, value); | ||
313 | |||
314 | /* Display size */ | ||
315 | value = (info->var.xres - 1) << ATMEL_LCDC_HOZVAL_OFFSET; | ||
316 | value |= info->var.yres - 1; | ||
317 | lcdc_writel(sinfo, ATMEL_LCDC_LCDFRMCFG, value); | ||
318 | |||
319 | /* FIFO Threshold: Use formula from data sheet */ | ||
320 | value = ATMEL_LCDC_FIFO_SIZE - (2 * ATMEL_LCDC_DMA_BURST_LEN + 3); | ||
321 | lcdc_writel(sinfo, ATMEL_LCDC_FIFO, value); | ||
322 | |||
323 | /* Toggle LCD_MODE every frame */ | ||
324 | lcdc_writel(sinfo, ATMEL_LCDC_MVAL, 0); | ||
325 | |||
326 | /* Disable all interrupts */ | ||
327 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL); | ||
328 | |||
329 | /* Set contrast */ | ||
330 | value = ATMEL_LCDC_PS_DIV8 | ATMEL_LCDC_POL_POSITIVE | ATMEL_LCDC_ENA_PWMENABLE; | ||
331 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, value); | ||
332 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, ATMEL_LCDC_CVAL_DEFAULT); | ||
333 | /* ...wait for DMA engine to become idle... */ | ||
334 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) | ||
335 | msleep(10); | ||
336 | |||
337 | dev_dbg(info->device, " * re-enable DMA engine\n"); | ||
338 | /* ...and enable it with updated configuration */ | ||
339 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon); | ||
340 | |||
341 | dev_dbg(info->device, " * re-enable LCDC core\n"); | ||
342 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, | ||
343 | (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET) | ATMEL_LCDC_PWR); | ||
344 | |||
345 | dev_dbg(info->device, " * DONE\n"); | ||
346 | |||
347 | return 0; | ||
348 | } | ||
349 | |||
350 | static inline unsigned int chan_to_field(unsigned int chan, const struct fb_bitfield *bf) | ||
351 | { | ||
352 | chan &= 0xffff; | ||
353 | chan >>= 16 - bf->length; | ||
354 | return chan << bf->offset; | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * atmel_lcdfb_setcolreg - Optional function. Sets a color register. | ||
359 | * @regno: Which register in the CLUT we are programming | ||
360 | * @red: The red value which can be up to 16 bits wide | ||
361 | * @green: The green value which can be up to 16 bits wide | ||
362 | * @blue: The blue value which can be up to 16 bits wide. | ||
363 | * @transp: If supported the alpha value which can be up to 16 bits wide. | ||
364 | * @info: frame buffer info structure | ||
365 | * | ||
366 | * Set a single color register. The values supplied have a 16 bit | ||
367 | * magnitude which needs to be scaled in this function for the hardware. | ||
368 | * Things to take into consideration are how many color registers, if | ||
369 | * any, are supported with the current color visual. With truecolor mode | ||
370 | * no color palettes are supported. Here a psuedo palette is created | ||
371 | * which we store the value in pseudo_palette in struct fb_info. For | ||
372 | * pseudocolor mode we have a limited color palette. To deal with this | ||
373 | * we can program what color is displayed for a particular pixel value. | ||
374 | * DirectColor is similar in that we can program each color field. If | ||
375 | * we have a static colormap we don't need to implement this function. | ||
376 | * | ||
377 | * Returns negative errno on error, or zero on success. In an | ||
378 | * ideal world, this would have been the case, but as it turns | ||
379 | * out, the other drivers return 1 on failure, so that's what | ||
380 | * we're going to do. | ||
381 | */ | ||
382 | static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red, | ||
383 | unsigned int green, unsigned int blue, | ||
384 | unsigned int transp, struct fb_info *info) | ||
385 | { | ||
386 | struct atmel_lcdfb_info *sinfo = info->par; | ||
387 | unsigned int val; | ||
388 | u32 *pal; | ||
389 | int ret = 1; | ||
390 | |||
391 | if (info->var.grayscale) | ||
392 | red = green = blue = (19595 * red + 38470 * green | ||
393 | + 7471 * blue) >> 16; | ||
394 | |||
395 | switch (info->fix.visual) { | ||
396 | case FB_VISUAL_TRUECOLOR: | ||
397 | if (regno < 16) { | ||
398 | pal = info->pseudo_palette; | ||
399 | |||
400 | val = chan_to_field(red, &info->var.red); | ||
401 | val |= chan_to_field(green, &info->var.green); | ||
402 | val |= chan_to_field(blue, &info->var.blue); | ||
403 | |||
404 | pal[regno] = val; | ||
405 | ret = 0; | ||
406 | } | ||
407 | break; | ||
408 | |||
409 | case FB_VISUAL_PSEUDOCOLOR: | ||
410 | if (regno < 256) { | ||
411 | val = ((red >> 11) & 0x001f); | ||
412 | val |= ((green >> 6) & 0x03e0); | ||
413 | val |= ((blue >> 1) & 0x7c00); | ||
414 | |||
415 | /* | ||
416 | * TODO: intensity bit. Maybe something like | ||
417 | * ~(red[10] ^ green[10] ^ blue[10]) & 1 | ||
418 | */ | ||
419 | |||
420 | lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val); | ||
421 | ret = 0; | ||
422 | } | ||
423 | break; | ||
424 | } | ||
425 | |||
426 | return ret; | ||
427 | } | ||
428 | |||
429 | static int atmel_lcdfb_pan_display(struct fb_var_screeninfo *var, | ||
430 | struct fb_info *info) | ||
431 | { | ||
432 | dev_dbg(info->device, "%s\n", __func__); | ||
433 | |||
434 | atmel_lcdfb_update_dma(info, var); | ||
435 | |||
436 | return 0; | ||
437 | } | ||
438 | |||
439 | static struct fb_ops atmel_lcdfb_ops = { | ||
440 | .owner = THIS_MODULE, | ||
441 | .fb_check_var = atmel_lcdfb_check_var, | ||
442 | .fb_set_par = atmel_lcdfb_set_par, | ||
443 | .fb_setcolreg = atmel_lcdfb_setcolreg, | ||
444 | .fb_pan_display = atmel_lcdfb_pan_display, | ||
445 | .fb_fillrect = cfb_fillrect, | ||
446 | .fb_copyarea = cfb_copyarea, | ||
447 | .fb_imageblit = cfb_imageblit, | ||
448 | }; | ||
449 | |||
450 | static irqreturn_t atmel_lcdfb_interrupt(int irq, void *dev_id) | ||
451 | { | ||
452 | struct fb_info *info = dev_id; | ||
453 | struct atmel_lcdfb_info *sinfo = info->par; | ||
454 | u32 status; | ||
455 | |||
456 | status = lcdc_readl(sinfo, ATMEL_LCDC_ISR); | ||
457 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, status); | ||
458 | return IRQ_HANDLED; | ||
459 | } | ||
460 | |||
461 | static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo) | ||
462 | { | ||
463 | struct fb_info *info = sinfo->info; | ||
464 | int ret = 0; | ||
465 | |||
466 | memset_io(info->screen_base, 0, info->fix.smem_len); | ||
467 | info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW; | ||
468 | |||
469 | dev_info(info->device, | ||
470 | "%luKiB frame buffer at %08lx (mapped at %p)\n", | ||
471 | (unsigned long)info->fix.smem_len / 1024, | ||
472 | (unsigned long)info->fix.smem_start, | ||
473 | info->screen_base); | ||
474 | |||
475 | /* Allocate colormap */ | ||
476 | ret = fb_alloc_cmap(&info->cmap, 256, 0); | ||
477 | if (ret < 0) | ||
478 | dev_err(info->device, "Alloc color map failed\n"); | ||
479 | |||
480 | return ret; | ||
481 | } | ||
482 | |||
483 | static void atmel_lcdfb_start_clock(struct atmel_lcdfb_info *sinfo) | ||
484 | { | ||
485 | if (sinfo->bus_clk) | ||
486 | clk_enable(sinfo->bus_clk); | ||
487 | clk_enable(sinfo->lcdc_clk); | ||
488 | } | ||
489 | |||
490 | static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo) | ||
491 | { | ||
492 | if (sinfo->bus_clk) | ||
493 | clk_disable(sinfo->bus_clk); | ||
494 | clk_disable(sinfo->lcdc_clk); | ||
495 | } | ||
496 | |||
497 | |||
498 | static int __init atmel_lcdfb_probe(struct platform_device *pdev) | ||
499 | { | ||
500 | struct device *dev = &pdev->dev; | ||
501 | struct fb_info *info; | ||
502 | struct atmel_lcdfb_info *sinfo; | ||
503 | struct atmel_lcdfb_info *pdata_sinfo; | ||
504 | struct resource *regs = NULL; | ||
505 | struct resource *map = NULL; | ||
506 | int ret; | ||
507 | |||
508 | dev_dbg(dev, "%s BEGIN\n", __func__); | ||
509 | |||
510 | ret = -ENOMEM; | ||
511 | info = framebuffer_alloc(sizeof(struct atmel_lcdfb_info), dev); | ||
512 | if (!info) { | ||
513 | dev_err(dev, "cannot allocate memory\n"); | ||
514 | goto out; | ||
515 | } | ||
516 | |||
517 | sinfo = info->par; | ||
518 | |||
519 | if (dev->platform_data) { | ||
520 | pdata_sinfo = (struct atmel_lcdfb_info *)dev->platform_data; | ||
521 | sinfo->default_bpp = pdata_sinfo->default_bpp; | ||
522 | sinfo->default_dmacon = pdata_sinfo->default_dmacon; | ||
523 | sinfo->default_lcdcon2 = pdata_sinfo->default_lcdcon2; | ||
524 | sinfo->default_monspecs = pdata_sinfo->default_monspecs; | ||
525 | sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control; | ||
526 | sinfo->guard_time = pdata_sinfo->guard_time; | ||
527 | } else { | ||
528 | dev_err(dev, "cannot get default configuration\n"); | ||
529 | goto free_info; | ||
530 | } | ||
531 | sinfo->info = info; | ||
532 | sinfo->pdev = pdev; | ||
533 | |||
534 | strcpy(info->fix.id, sinfo->pdev->name); | ||
535 | info->flags = ATMEL_LCDFB_FBINFO_DEFAULT; | ||
536 | info->pseudo_palette = sinfo->pseudo_palette; | ||
537 | info->fbops = &atmel_lcdfb_ops; | ||
538 | |||
539 | memcpy(&info->monspecs, sinfo->default_monspecs, sizeof(info->monspecs)); | ||
540 | info->fix = atmel_lcdfb_fix; | ||
541 | |||
542 | /* Enable LCDC Clocks */ | ||
543 | if (cpu_is_at91sam9261() || cpu_is_at32ap7000()) { | ||
544 | sinfo->bus_clk = clk_get(dev, "hck1"); | ||
545 | if (IS_ERR(sinfo->bus_clk)) { | ||
546 | ret = PTR_ERR(sinfo->bus_clk); | ||
547 | goto free_info; | ||
548 | } | ||
549 | } | ||
550 | sinfo->lcdc_clk = clk_get(dev, "lcdc_clk"); | ||
551 | if (IS_ERR(sinfo->lcdc_clk)) { | ||
552 | ret = PTR_ERR(sinfo->lcdc_clk); | ||
553 | goto put_bus_clk; | ||
554 | } | ||
555 | atmel_lcdfb_start_clock(sinfo); | ||
556 | |||
557 | ret = fb_find_mode(&info->var, info, NULL, info->monspecs.modedb, | ||
558 | info->monspecs.modedb_len, info->monspecs.modedb, | ||
559 | sinfo->default_bpp); | ||
560 | if (!ret) { | ||
561 | dev_err(dev, "no suitable video mode found\n"); | ||
562 | goto stop_clk; | ||
563 | } | ||
564 | |||
565 | |||
566 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
567 | if (!regs) { | ||
568 | dev_err(dev, "resources unusable\n"); | ||
569 | ret = -ENXIO; | ||
570 | goto stop_clk; | ||
571 | } | ||
572 | |||
573 | sinfo->irq_base = platform_get_irq(pdev, 0); | ||
574 | if (sinfo->irq_base < 0) { | ||
575 | dev_err(dev, "unable to get irq\n"); | ||
576 | ret = sinfo->irq_base; | ||
577 | goto stop_clk; | ||
578 | } | ||
579 | |||
580 | /* Initialize video memory */ | ||
581 | map = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
582 | if (map) { | ||
583 | /* use a pre-allocated memory buffer */ | ||
584 | info->fix.smem_start = map->start; | ||
585 | info->fix.smem_len = map->end - map->start + 1; | ||
586 | if (!request_mem_region(info->fix.smem_start, | ||
587 | info->fix.smem_len, pdev->name)) { | ||
588 | ret = -EBUSY; | ||
589 | goto stop_clk; | ||
590 | } | ||
591 | |||
592 | info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); | ||
593 | if (!info->screen_base) | ||
594 | goto release_intmem; | ||
595 | } else { | ||
596 | /* alocate memory buffer */ | ||
597 | ret = atmel_lcdfb_alloc_video_memory(sinfo); | ||
598 | if (ret < 0) { | ||
599 | dev_err(dev, "cannot allocate framebuffer: %d\n", ret); | ||
600 | goto stop_clk; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | /* LCDC registers */ | ||
605 | info->fix.mmio_start = regs->start; | ||
606 | info->fix.mmio_len = regs->end - regs->start + 1; | ||
607 | |||
608 | if (!request_mem_region(info->fix.mmio_start, | ||
609 | info->fix.mmio_len, pdev->name)) { | ||
610 | ret = -EBUSY; | ||
611 | goto free_fb; | ||
612 | } | ||
613 | |||
614 | sinfo->mmio = ioremap(info->fix.mmio_start, info->fix.mmio_len); | ||
615 | if (!sinfo->mmio) { | ||
616 | dev_err(dev, "cannot map LCDC registers\n"); | ||
617 | goto release_mem; | ||
618 | } | ||
619 | |||
620 | /* interrupt */ | ||
621 | ret = request_irq(sinfo->irq_base, atmel_lcdfb_interrupt, 0, pdev->name, info); | ||
622 | if (ret) { | ||
623 | dev_err(dev, "request_irq failed: %d\n", ret); | ||
624 | goto unmap_mmio; | ||
625 | } | ||
626 | |||
627 | ret = atmel_lcdfb_init_fbinfo(sinfo); | ||
628 | if (ret < 0) { | ||
629 | dev_err(dev, "init fbinfo failed: %d\n", ret); | ||
630 | goto unregister_irqs; | ||
631 | } | ||
632 | |||
633 | /* | ||
634 | * This makes sure that our colour bitfield | ||
635 | * descriptors are correctly initialised. | ||
636 | */ | ||
637 | atmel_lcdfb_check_var(&info->var, info); | ||
638 | |||
639 | ret = fb_set_var(info, &info->var); | ||
640 | if (ret) { | ||
641 | dev_warn(dev, "unable to set display parameters\n"); | ||
642 | goto free_cmap; | ||
643 | } | ||
644 | |||
645 | dev_set_drvdata(dev, info); | ||
646 | |||
647 | /* | ||
648 | * Tell the world that we're ready to go | ||
649 | */ | ||
650 | ret = register_framebuffer(info); | ||
651 | if (ret < 0) { | ||
652 | dev_err(dev, "failed to register framebuffer device: %d\n", ret); | ||
653 | goto free_cmap; | ||
654 | } | ||
655 | |||
656 | /* Power up the LCDC screen */ | ||
657 | if (sinfo->atmel_lcdfb_power_control) | ||
658 | sinfo->atmel_lcdfb_power_control(1); | ||
659 | |||
660 | dev_info(dev, "fb%d: Atmel LCDC at 0x%08lx (mapped at %p), irq %lu\n", | ||
661 | info->node, info->fix.mmio_start, sinfo->mmio, sinfo->irq_base); | ||
662 | |||
663 | return 0; | ||
664 | |||
665 | |||
666 | free_cmap: | ||
667 | fb_dealloc_cmap(&info->cmap); | ||
668 | unregister_irqs: | ||
669 | free_irq(sinfo->irq_base, info); | ||
670 | unmap_mmio: | ||
671 | iounmap(sinfo->mmio); | ||
672 | release_mem: | ||
673 | release_mem_region(info->fix.mmio_start, info->fix.mmio_len); | ||
674 | free_fb: | ||
675 | if (map) | ||
676 | iounmap(info->screen_base); | ||
677 | else | ||
678 | atmel_lcdfb_free_video_memory(sinfo); | ||
679 | |||
680 | release_intmem: | ||
681 | if (map) | ||
682 | release_mem_region(info->fix.smem_start, info->fix.smem_len); | ||
683 | stop_clk: | ||
684 | atmel_lcdfb_stop_clock(sinfo); | ||
685 | clk_put(sinfo->lcdc_clk); | ||
686 | put_bus_clk: | ||
687 | if (sinfo->bus_clk) | ||
688 | clk_put(sinfo->bus_clk); | ||
689 | free_info: | ||
690 | framebuffer_release(info); | ||
691 | out: | ||
692 | dev_dbg(dev, "%s FAILED\n", __func__); | ||
693 | return ret; | ||
694 | } | ||
695 | |||
696 | static int __exit atmel_lcdfb_remove(struct platform_device *pdev) | ||
697 | { | ||
698 | struct device *dev = &pdev->dev; | ||
699 | struct fb_info *info = dev_get_drvdata(dev); | ||
700 | struct atmel_lcdfb_info *sinfo = info->par; | ||
701 | |||
702 | if (!sinfo) | ||
703 | return 0; | ||
704 | |||
705 | if (sinfo->atmel_lcdfb_power_control) | ||
706 | sinfo->atmel_lcdfb_power_control(0); | ||
707 | unregister_framebuffer(info); | ||
708 | atmel_lcdfb_stop_clock(sinfo); | ||
709 | clk_put(sinfo->lcdc_clk); | ||
710 | if (sinfo->bus_clk) | ||
711 | clk_put(sinfo->bus_clk); | ||
712 | fb_dealloc_cmap(&info->cmap); | ||
713 | free_irq(sinfo->irq_base, info); | ||
714 | iounmap(sinfo->mmio); | ||
715 | release_mem_region(info->fix.mmio_start, info->fix.mmio_len); | ||
716 | if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) { | ||
717 | iounmap(info->screen_base); | ||
718 | release_mem_region(info->fix.smem_start, info->fix.smem_len); | ||
719 | } else { | ||
720 | atmel_lcdfb_free_video_memory(sinfo); | ||
721 | } | ||
722 | |||
723 | dev_set_drvdata(dev, NULL); | ||
724 | framebuffer_release(info); | ||
725 | |||
726 | return 0; | ||
727 | } | ||
728 | |||
729 | static struct platform_driver atmel_lcdfb_driver = { | ||
730 | .remove = __exit_p(atmel_lcdfb_remove), | ||
731 | .driver = { | ||
732 | .name = "atmel_lcdfb", | ||
733 | .owner = THIS_MODULE, | ||
734 | }, | ||
735 | }; | ||
736 | |||
737 | static int __init atmel_lcdfb_init(void) | ||
738 | { | ||
739 | return platform_driver_probe(&atmel_lcdfb_driver, atmel_lcdfb_probe); | ||
740 | } | ||
741 | |||
742 | static void __exit atmel_lcdfb_exit(void) | ||
743 | { | ||
744 | platform_driver_unregister(&atmel_lcdfb_driver); | ||
745 | } | ||
746 | |||
747 | module_init(atmel_lcdfb_init); | ||
748 | module_exit(atmel_lcdfb_exit); | ||
749 | |||
750 | MODULE_DESCRIPTION("AT91/AT32 LCD Controller framebuffer driver"); | ||
751 | MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@rfo.atmel.com>"); | ||
752 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index aa3935df852a..63b85bf81a65 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig | |||
@@ -19,13 +19,6 @@ config VGA_CONSOLE | |||
19 | 19 | ||
20 | Say Y. | 20 | Say Y. |
21 | 21 | ||
22 | # if [ "$CONFIG_PCI" = "y" -a "$CONFIG_VGA_CONSOLE" = "y" ]; then | ||
23 | # bool ' Allow VGA on any bus?' CONFIG_VGA_HOSE | ||
24 | # if [ "$CONFIG_VGA_HOSE" = "y" ]; then | ||
25 | # define_bool CONFIG_DUMMY_CONSOLE y | ||
26 | # fi | ||
27 | # fi | ||
28 | |||
29 | config VGACON_SOFT_SCROLLBACK | 22 | config VGACON_SOFT_SCROLLBACK |
30 | bool "Enable Scrollback Buffer in System RAM" | 23 | bool "Enable Scrollback Buffer in System RAM" |
31 | depends on VGA_CONSOLE | 24 | depends on VGA_CONSOLE |
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c index c627955aa124..aff11bbf59a7 100644 --- a/drivers/video/nvidia/nv_hw.c +++ b/drivers/video/nvidia/nv_hw.c | |||
@@ -149,7 +149,9 @@ static void nvGetClocks(struct nvidia_par *par, unsigned int *MClk, | |||
149 | pll = NV_RD32(par->PMC, 0x4024); | 149 | pll = NV_RD32(par->PMC, 0x4024); |
150 | M = pll & 0xFF; | 150 | M = pll & 0xFF; |
151 | N = (pll >> 8) & 0xFF; | 151 | N = (pll >> 8) & 0xFF; |
152 | if (((par->Chipset & 0xfff0) == 0x0290) || ((par->Chipset & 0xfff0) == 0x0390) || ((par->Chipset & 0xfff0) == 0x02E0)) { | 152 | if (((par->Chipset & 0xfff0) == 0x0290) || |
153 | ((par->Chipset & 0xfff0) == 0x0390) || | ||
154 | ((par->Chipset & 0xfff0) == 0x02E0)) { | ||
153 | MB = 1; | 155 | MB = 1; |
154 | NB = 1; | 156 | NB = 1; |
155 | } else { | 157 | } else { |
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c index f85edf084da3..41f63658572f 100644 --- a/drivers/video/nvidia/nvidia.c +++ b/drivers/video/nvidia/nvidia.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include "nv_proto.h" | 37 | #include "nv_proto.h" |
38 | #include "nv_dma.h" | 38 | #include "nv_dma.h" |
39 | 39 | ||
40 | #undef CONFIG_FB_NVIDIA_DEBUG | ||
41 | #ifdef CONFIG_FB_NVIDIA_DEBUG | 40 | #ifdef CONFIG_FB_NVIDIA_DEBUG |
42 | #define NVTRACE printk | 41 | #define NVTRACE printk |
43 | #else | 42 | #else |
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c index 1ac5264bb2c1..ab5e66890e4e 100644 --- a/drivers/video/pm2fb.c +++ b/drivers/video/pm2fb.c | |||
@@ -204,17 +204,6 @@ static inline void WAIT_FIFO(struct pm2fb_par* p, u32 a) | |||
204 | } | 204 | } |
205 | #endif | 205 | #endif |
206 | 206 | ||
207 | static void wait_pm2(struct pm2fb_par* par) { | ||
208 | |||
209 | WAIT_FIFO(par, 1); | ||
210 | pm2_WR(par, PM2R_SYNC, 0); | ||
211 | mb(); | ||
212 | do { | ||
213 | while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0); | ||
214 | rmb(); | ||
215 | } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC)); | ||
216 | } | ||
217 | |||
218 | /* | 207 | /* |
219 | * partial products for the supported horizontal resolutions. | 208 | * partial products for the supported horizontal resolutions. |
220 | */ | 209 | */ |
@@ -1050,13 +1039,30 @@ static int pm2fb_blank(int blank_mode, struct fb_info *info) | |||
1050 | return 0; | 1039 | return 0; |
1051 | } | 1040 | } |
1052 | 1041 | ||
1042 | static int pm2fb_sync(struct fb_info *info) | ||
1043 | { | ||
1044 | struct pm2fb_par *par = info->par; | ||
1045 | |||
1046 | WAIT_FIFO(par, 1); | ||
1047 | pm2_WR(par, PM2R_SYNC, 0); | ||
1048 | mb(); | ||
1049 | do { | ||
1050 | while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0) | ||
1051 | udelay(10); | ||
1052 | rmb(); | ||
1053 | } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC)); | ||
1054 | |||
1055 | return 0; | ||
1056 | } | ||
1057 | |||
1053 | /* | 1058 | /* |
1054 | * block operation. copy=0: rectangle fill, copy=1: rectangle copy. | 1059 | * block operation. copy=0: rectangle fill, copy=1: rectangle copy. |
1055 | */ | 1060 | */ |
1056 | static void pm2fb_block_op(struct pm2fb_par* par, int copy, | 1061 | static void pm2fb_block_op(struct fb_info* info, int copy, |
1057 | s32 xsrc, s32 ysrc, | 1062 | s32 xsrc, s32 ysrc, |
1058 | s32 x, s32 y, s32 w, s32 h, | 1063 | s32 x, s32 y, s32 w, s32 h, |
1059 | u32 color) { | 1064 | u32 color) { |
1065 | struct pm2fb_par *par = info->par; | ||
1060 | 1066 | ||
1061 | if (!w || !h) | 1067 | if (!w || !h) |
1062 | return; | 1068 | return; |
@@ -1076,13 +1082,11 @@ static void pm2fb_block_op(struct pm2fb_par* par, int copy, | |||
1076 | (x<xsrc ? PM2F_INCREASE_X : 0) | | 1082 | (x<xsrc ? PM2F_INCREASE_X : 0) | |
1077 | (y<ysrc ? PM2F_INCREASE_Y : 0) | | 1083 | (y<ysrc ? PM2F_INCREASE_Y : 0) | |
1078 | (copy ? 0 : PM2F_RENDER_FASTFILL)); | 1084 | (copy ? 0 : PM2F_RENDER_FASTFILL)); |
1079 | wait_pm2(par); | ||
1080 | } | 1085 | } |
1081 | 1086 | ||
1082 | static void pm2fb_fillrect (struct fb_info *info, | 1087 | static void pm2fb_fillrect (struct fb_info *info, |
1083 | const struct fb_fillrect *region) | 1088 | const struct fb_fillrect *region) |
1084 | { | 1089 | { |
1085 | struct pm2fb_par *par = info->par; | ||
1086 | struct fb_fillrect modded; | 1090 | struct fb_fillrect modded; |
1087 | int vxres, vyres; | 1091 | int vxres, vyres; |
1088 | u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? | 1092 | u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? |
@@ -1116,7 +1120,7 @@ static void pm2fb_fillrect (struct fb_info *info, | |||
1116 | color |= color << 16; | 1120 | color |= color << 16; |
1117 | 1121 | ||
1118 | if(info->var.bits_per_pixel != 24) | 1122 | if(info->var.bits_per_pixel != 24) |
1119 | pm2fb_block_op(par, 0, 0, 0, | 1123 | pm2fb_block_op(info, 0, 0, 0, |
1120 | modded.dx, modded.dy, | 1124 | modded.dx, modded.dy, |
1121 | modded.width, modded.height, color); | 1125 | modded.width, modded.height, color); |
1122 | else | 1126 | else |
@@ -1126,7 +1130,6 @@ static void pm2fb_fillrect (struct fb_info *info, | |||
1126 | static void pm2fb_copyarea(struct fb_info *info, | 1130 | static void pm2fb_copyarea(struct fb_info *info, |
1127 | const struct fb_copyarea *area) | 1131 | const struct fb_copyarea *area) |
1128 | { | 1132 | { |
1129 | struct pm2fb_par *par = info->par; | ||
1130 | struct fb_copyarea modded; | 1133 | struct fb_copyarea modded; |
1131 | u32 vxres, vyres; | 1134 | u32 vxres, vyres; |
1132 | 1135 | ||
@@ -1156,7 +1159,7 @@ static void pm2fb_copyarea(struct fb_info *info, | |||
1156 | if(modded.dy + modded.height > vyres) | 1159 | if(modded.dy + modded.height > vyres) |
1157 | modded.height = vyres - modded.dy; | 1160 | modded.height = vyres - modded.dy; |
1158 | 1161 | ||
1159 | pm2fb_block_op(par, 1, modded.sx, modded.sy, | 1162 | pm2fb_block_op(info, 1, modded.sx, modded.sy, |
1160 | modded.dx, modded.dy, | 1163 | modded.dx, modded.dy, |
1161 | modded.width, modded.height, 0); | 1164 | modded.width, modded.height, 0); |
1162 | } | 1165 | } |
@@ -1177,6 +1180,7 @@ static struct fb_ops pm2fb_ops = { | |||
1177 | .fb_fillrect = pm2fb_fillrect, | 1180 | .fb_fillrect = pm2fb_fillrect, |
1178 | .fb_copyarea = pm2fb_copyarea, | 1181 | .fb_copyarea = pm2fb_copyarea, |
1179 | .fb_imageblit = cfb_imageblit, | 1182 | .fb_imageblit = cfb_imageblit, |
1183 | .fb_sync = pm2fb_sync, | ||
1180 | }; | 1184 | }; |
1181 | 1185 | ||
1182 | /* | 1186 | /* |
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c index bd787e80177d..c77a1a1fd46b 100644 --- a/drivers/video/pm3fb.c +++ b/drivers/video/pm3fb.c | |||
@@ -1,55 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device | 2 | * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device |
3 | * | 3 | * |
4 | * Copyright (C) 2001 Romain Dolbeau <dolbeau@irisa.fr> | 4 | * Copyright (C) 2001 Romain Dolbeau <romain@dolbeau.org>. |
5 | * | ||
6 | * Ported to 2.6 kernel on 1 May 2007 by Krzysztof Helt <krzysztof.h1@wp.pl> | ||
7 | * based on pm2fb.c | ||
8 | * | ||
5 | * Based on code written by: | 9 | * Based on code written by: |
6 | * Sven Luther, <luther@dpt-info.u-strasbg.fr> | 10 | * Sven Luther, <luther@dpt-info.u-strasbg.fr> |
7 | * Alan Hourihane, <alanh@fairlite.demon.co.uk> | 11 | * Alan Hourihane, <alanh@fairlite.demon.co.uk> |
8 | * Russell King, <rmk@arm.linux.org.uk> | 12 | * Russell King, <rmk@arm.linux.org.uk> |
9 | * Based on linux/drivers/video/skeletonfb.c: | 13 | * Based on linux/drivers/video/skeletonfb.c: |
10 | * Copyright (C) 1997 Geert Uytterhoeven | 14 | * Copyright (C) 1997 Geert Uytterhoeven |
11 | * Based on linux/driver/video/pm2fb.c: | 15 | * Based on linux/driver/video/pm2fb.c: |
12 | * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT) | 16 | * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT) |
13 | * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com) | 17 | * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com) |
14 | * | 18 | * |
15 | * This file is subject to the terms and conditions of the GNU General Public | 19 | * This file is subject to the terms and conditions of the GNU General Public |
16 | * License. See the file COPYING in the main directory of this archive for | 20 | * License. See the file COPYING in the main directory of this archive for |
17 | * more details. | 21 | * more details. |
18 | * | 22 | * |
19 | * $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $ | ||
20 | * | ||
21 | * CHANGELOG: | ||
22 | * Mon Feb 11 10:35:48 MET 2002, v 1.4.11B: Cosmetic update. | ||
23 | * Wed Jan 23 14:16:59 MET 2002, v 1.4.11: Preliminary 2.5.x support, patch for 2.5.2. | ||
24 | * Wed Nov 28 11:08:29 MET 2001, v 1.4.10: potential bug fix for SDRAM-based board, patch for 2.4.16. | ||
25 | * Thu Sep 20 10:24:42 MET DST 2001, v 1.4.9: sync bug fix, preliminary flatpanel support, better timings. | ||
26 | * Tue Aug 28 10:13:01 MET DST 2001, v 1.4.8: memory timings check, minor bug fixes. | ||
27 | * Wed Jul 18 19:06:14 CEST 2001, v 1.4.7: Mode fix (800x600-100, 1024x768-100 changed), using HW panning + accel bug fix. | ||
28 | * Mon Jun 25 10:33:56 MET DST 2001, v 1.4.6: Depth 12 fix, chip reset ioctl, moved memory erase ioctl to DEBUG. | ||
29 | * Wed Jun 20 11:13:08 MET DST 2001, v 1.4.5: Fixed missing blinking cursor in 8bpp, code cleaning, memory erase IOCTL. | ||
30 | * Mon Jun 18 16:00:27 CEST 2001, v 1.4.4: Depth 12 (RGBA 4444) support, code cleaning. | ||
31 | * Fri Jun 15 13:53:01 CEST 2001, v 1.4.3: Removed warnings, depth 15 support, add 'depth' option. | ||
32 | * Thu Jun 14 10:13:52 MET DST 2001, v 1.4.2: Fixed depth switching bug, preliminary 15bpp (RGB5551) support. | ||
33 | * Thu Apr 12 11:16:45 MET DST 2001, v 1.4.1B: Doc updates. | ||
34 | * Fri Apr 6 11:12:53 MET DST 2001, v 1.4.1: Configure.help, minor cleanup | ||
35 | * Thu Mar 29 10:56:50 MET DST 2001, v 1.4.0: Module & module options support (note: linux patch changed, 2.2.19 added). | ||
36 | * Thu Mar 15 15:30:31 MET 2001, v 1.3.2: Fixed mirroring bug on little-endian. | ||
37 | * Wed Mar 14 21:25:54 CET 2001, v 1.3.1: Fixed bug in BlockMove (_bmov). | ||
38 | * Tue Mar 13 10:53:19 MET 2001, v 1.3.0: Character drawing hardware support (in all width between 1 and 16), fixes. | ||
39 | * Thu Mar 8 10:20:16 MET 2001, v 1.2.2: Better J2000 support, "font:" option. | ||
40 | * Tue Mar 6 21:25:04 CET 2001, v 1.2.1: Better acceleration support. | ||
41 | * Mon Mar 5 21:54:17 CET 2001, v 1.2.0: Partial acceleration support (clear & bmove) | ||
42 | * Mon Mar 5 12:52:15 CET 2001, v 1.1.3: Big pan_display fix. | ||
43 | * Sun Mar 4 22:21:50 CET 2001, v 1.1.2: (numerous) bug fixes. | ||
44 | * Fri Mar 2 15:54:07 CET 2001, v 1.1.1: Might have Appian J2000 support, resource mangement in 2.4 | ||
45 | * Wed Feb 28 18:21:35 CET 2001, v 1.1.0: Might have multiple boards support (added, but not yest tested) | ||
46 | * Tue Feb 27 17:31:12 CET 2001, v 1.0.6: fixes boot-time mode select, add more default mode | ||
47 | * Tue Feb 27 14:01:36 CET 2001, v 1.0.5: fixes (1.0.4 was broken for 2.2), cleaning up | ||
48 | * Mon Feb 26 23:17:36 CET 2001, v 1.0.4: preliminary 2.4.x support, dropped (useless on pm3) partial product, more OF fix | ||
49 | * Mon Feb 26 20:59:05 CET 2001, v 1.0.3: No more shadow register (and wasted memory), endianess fix, use OF-preset resolution by default | ||
50 | * Wed Feb 21 22:09:30 CET 2001, v 1.0.2: Code cleaning for future multiboard support, better OF support, bugs fix | ||
51 | * Wed Feb 21 19:58:56 CET 2001, v 1.0.1: OpenFirmware support, fixed memory detection, better debug support, code cleaning | ||
52 | * Wed Feb 21 14:47:06 CET 2001, v 1.0.0: First working version | ||
53 | */ | 23 | */ |
54 | 24 | ||
55 | #include <linux/module.h> | 25 | #include <linux/module.h> |
@@ -58,856 +28,155 @@ | |||
58 | #include <linux/string.h> | 28 | #include <linux/string.h> |
59 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
60 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
61 | #include <linux/vmalloc.h> | ||
62 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
63 | #include <linux/interrupt.h> | ||
64 | #include <linux/fb.h> | 32 | #include <linux/fb.h> |
65 | #include <linux/init.h> | 33 | #include <linux/init.h> |
66 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
67 | #include <linux/ioport.h> | ||
68 | #include <linux/ctype.h> | ||
69 | |||
70 | #include <video/fbcon.h> | ||
71 | #include <video/fbcon-mfb.h> | ||
72 | #include <video/fbcon-cfb2.h> | ||
73 | #include <video/fbcon-cfb4.h> | ||
74 | #include <video/fbcon-cfb8.h> | ||
75 | #include <video/fbcon-cfb16.h> | ||
76 | #include <video/fbcon-cfb24.h> | ||
77 | #include <video/fbcon-cfb32.h> | ||
78 | #include <video/pm3fb.h> | ||
79 | 35 | ||
80 | #include <asm/io.h> | 36 | #include <video/pm3fb.h> |
81 | #include <asm/uaccess.h> | ||
82 | 37 | ||
83 | #ifdef CONFIG_FB_OF | 38 | #if !defined(CONFIG_PCI) |
84 | #include <asm/prom.h> | 39 | #error "Only generic PCI cards supported." |
85 | #endif | 40 | #endif |
86 | 41 | ||
87 | /* ************************************* */ | 42 | #undef PM3FB_MASTER_DEBUG |
88 | /* ***** The various "global" data ***** */ | 43 | #ifdef PM3FB_MASTER_DEBUG |
89 | /* ************************************* */ | 44 | #define DPRINTK(a,b...) printk(KERN_DEBUG "pm3fb: %s: " a, __FUNCTION__ , ## b) |
90 | 45 | #else | |
91 | /* those will need a rework for multiple board support */ | 46 | #define DPRINTK(a,b...) |
92 | /* Driver name */ | ||
93 | static const char permedia3_name[16] = "Permedia3"; | ||
94 | |||
95 | /* the fb_par struct, mandatory */ | ||
96 | struct pm3fb_par { | ||
97 | u32 pixclock; /* pixclock in KHz */ | ||
98 | |||
99 | u32 width; /* width of virtual screen */ | ||
100 | u32 height; /* height of virtual screen */ | ||
101 | |||
102 | u32 hsstart; /* horiz. sync start */ | ||
103 | u32 hsend; /* horiz. sync end */ | ||
104 | u32 hbend; /* horiz. blank end (also gate end) */ | ||
105 | u32 htotal; /* total width (w/ sync & blank) */ | ||
106 | |||
107 | u32 vsstart; /* vert. sync start */ | ||
108 | u32 vsend; /* vert. sync end */ | ||
109 | u32 vbend; /* vert. blank end */ | ||
110 | u32 vtotal; /* total height (w/ sync & blank) */ | ||
111 | |||
112 | u32 stride; /* screen stride */ | ||
113 | u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */ | ||
114 | /* NOTE : unlike other pm3 stuff above, stored *after* shiftbpp. don't ask */ | ||
115 | u32 depth; /* screen depth (8, 12, 15, 16 or 32) */ | ||
116 | u32 video; /* video control (hsync,vsync) */ | ||
117 | }; | ||
118 | |||
119 | /* memory timings */ | ||
120 | struct pm3fb_timings | ||
121 | { | ||
122 | unsigned long caps; | ||
123 | unsigned long timings; | ||
124 | unsigned long control; | ||
125 | unsigned long refresh; | ||
126 | unsigned long powerdown; | ||
127 | }; | ||
128 | typedef enum pm3fb_timing_result { pm3fb_timing_ok, pm3fb_timing_problem, pm3fb_timing_retry } pm3fb_timing_result; | ||
129 | #define PM3FB_UNKNOWN_TIMING_VALUE ((unsigned long)-1) | ||
130 | #define PM3FB_UNKNOWN_TIMINGS { PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE } | ||
131 | |||
132 | /* the fb_info struct, mandatory */ | ||
133 | struct pm3fb_info { | ||
134 | struct fb_info_gen gen; | ||
135 | unsigned long board_num; /* internal board number */ | ||
136 | unsigned long use_current; | ||
137 | struct pm3fb_par *current_par; | ||
138 | struct pci_dev *dev; /* PCI device */ | ||
139 | unsigned long board_type; /* index in the cardbase */ | ||
140 | unsigned char *fb_base; /* framebuffer memory base */ | ||
141 | u32 fb_size; /* framebuffer memory size */ | ||
142 | unsigned char *p_fb; /* physical address of frame buffer */ | ||
143 | unsigned char *v_fb; /* virtual address of frame buffer */ | ||
144 | unsigned char *pIOBase; /* physical address of registers region, must be rg_base or rg_base+PM2_REGS_SIZE depending on the host endianness */ | ||
145 | unsigned char *vIOBase; /* address of registers after ioremap() */ | ||
146 | struct { | ||
147 | u8 transp; | ||
148 | u8 red; | ||
149 | u8 green; | ||
150 | u8 blue; | ||
151 | } palette[256]; | ||
152 | union { | ||
153 | #ifdef FBCON_HAS_CFB16 | ||
154 | u16 cmap12[16]; /* RGBA 4444 */ | ||
155 | u16 cmap15[16]; /* RGBA 5551 */ | ||
156 | u16 cmap16[16]; /* RGBA 5650 */ | ||
157 | #endif | ||
158 | #ifdef FBCON_HAS_CFB32 | ||
159 | u32 cmap32[16]; | ||
160 | #endif | 47 | #endif |
161 | } cmap; | ||
162 | struct pm3fb_timings memt; | ||
163 | }; | ||
164 | 48 | ||
165 | /* regular resolution database*/ | 49 | /* |
166 | static struct { | 50 | * Driver data |
167 | char name[16]; | 51 | */ |
168 | struct pm3fb_par user_mode; | 52 | static char *mode_option __devinitdata; |
169 | } mode_base[] __initdata = { | ||
170 | { | ||
171 | "default-800x600", { | ||
172 | 49500, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625, | ||
173 | 800, 0, 8, | ||
174 | PM3VideoControl_ENABLE | | ||
175 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
176 | | | ||
177 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
178 | | PM3VideoControl_PIXELSIZE_8BIT}}, { | ||
179 | "1024x768-74", { | ||
180 | 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38, | ||
181 | 806, 1024, 0, 8, | ||
182 | PM3VideoControl_ENABLE | | ||
183 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
184 | | | ||
185 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
186 | | PM3VideoControl_PIXELSIZE_8BIT}}, { | ||
187 | "1024x768-74-32", { | ||
188 | 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38, | ||
189 | 806, 1024, 0, 32, | ||
190 | PM3VideoControl_ENABLE | | ||
191 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
192 | | | ||
193 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
194 | | PM3VideoControl_PIXELSIZE_32BIT}}, | ||
195 | /* Generated mode : "1600x1024", for the SGI 1600SW flat panel*/ | ||
196 | { | ||
197 | "SGI1600SW", { | ||
198 | 108000, 1600, 1024, 16, 56, 104, 1704, 3, 6, 32, | ||
199 | 1056, 1600, 0, 8, | ||
200 | PM3VideoControl_ENABLE| | ||
201 | PM3VideoControl_HSYNC_ACTIVE_LOW|PM3VideoControl_VSYNC_ACTIVE_LOW| | ||
202 | PM3VideoControl_PIXELSIZE_32BIT}}, | ||
203 | /* ##### auto-generated mode, by fbtimings2pm3 */ | ||
204 | /* Generated mode : "640x480-60" */ | ||
205 | { | ||
206 | "640x480-60", { | ||
207 | 25174, 640, 480, 16, 112, 160, 800, 10, 12, 45, | ||
208 | 525, 640, 0, 8, | ||
209 | PM3VideoControl_ENABLE | | ||
210 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
211 | | | ||
212 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
213 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
214 | /* Generated mode : "640x480-72" */ | ||
215 | { | ||
216 | "640x480-72", { | ||
217 | 31199, 640, 480, 24, 64, 192, 832, 9, 12, 40, 520, | ||
218 | 640, 0, 8, | ||
219 | PM3VideoControl_ENABLE | | ||
220 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
221 | | | ||
222 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
223 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
224 | /* Generated mode : "640x480-75" */ | ||
225 | { | ||
226 | "640x480-75", { | ||
227 | 31499, 640, 480, 16, 80, 200, 840, 1, 4, 20, 500, | ||
228 | 640, 0, 8, | ||
229 | PM3VideoControl_ENABLE | | ||
230 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
231 | | | ||
232 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
233 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
234 | /* Generated mode : "640x480-90" */ | ||
235 | { | ||
236 | "640x480-90", { | ||
237 | 39909, 640, 480, 32, 72, 192, 832, 25, 39, 53, 533, | ||
238 | 640, 0, 8, | ||
239 | PM3VideoControl_ENABLE | | ||
240 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
241 | | | ||
242 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
243 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
244 | /* Generated mode : "640x480-100" */ | ||
245 | { | ||
246 | "640x480-100", { | ||
247 | 44899, 640, 480, 32, 160, 208, 848, 22, 34, 51, | ||
248 | 531, 640, 0, 8, | ||
249 | PM3VideoControl_ENABLE | | ||
250 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
251 | | | ||
252 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
253 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
254 | /* Generated mode : "800x600-48-lace" */ | ||
255 | /* INTERLACED NOT SUPPORTED | ||
256 | {"800x600-48-lace", {35999, 800, 600, 80, 208, 264, 1064, 11, 23, 102, 702, 800, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
257 | INTERLACED NOT SUPPORTED */ | ||
258 | /* Generated mode : "800x600-56" */ | ||
259 | { | ||
260 | "800x600-56", { | ||
261 | 35999, 800, 600, 24, 96, 224, 1024, 1, 3, 25, 625, | ||
262 | 800, 0, 8, | ||
263 | PM3VideoControl_ENABLE | | ||
264 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
265 | | | ||
266 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
267 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
268 | /* Generated mode : "800x600-60" */ | ||
269 | { | ||
270 | "800x600-60", { | ||
271 | 40000, 800, 600, 40, 168, 256, 1056, 1, 5, 28, 628, | ||
272 | 800, 0, 8, | ||
273 | PM3VideoControl_ENABLE | | ||
274 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
275 | | | ||
276 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
277 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
278 | /* Generated mode : "800x600-70" */ | ||
279 | { | ||
280 | "800x600-70", { | ||
281 | 44899, 800, 600, 24, 168, 208, 1008, 9, 21, 36, | ||
282 | 636, 800, 0, 8, | ||
283 | PM3VideoControl_ENABLE | | ||
284 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
285 | | | ||
286 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
287 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
288 | /* Generated mode : "800x600-72" */ | ||
289 | { | ||
290 | "800x600-72", { | ||
291 | 50000, 800, 600, 56, 176, 240, 1040, 37, 43, 66, | ||
292 | 666, 800, 0, 8, | ||
293 | PM3VideoControl_ENABLE | | ||
294 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
295 | | | ||
296 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
297 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
298 | /* Generated mode : "800x600-75" */ | ||
299 | { | ||
300 | "800x600-75", { | ||
301 | 49497, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625, | ||
302 | 800, 0, 8, | ||
303 | PM3VideoControl_ENABLE | | ||
304 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
305 | | | ||
306 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
307 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
308 | /* Generated mode : "800x600-90" */ | ||
309 | { | ||
310 | "800x600-90", { | ||
311 | 56637, 800, 600, 8, 72, 192, 992, 8, 19, 35, 635, | ||
312 | 800, 0, 8, | ||
313 | PM3VideoControl_ENABLE | | ||
314 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
315 | | | ||
316 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
317 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
318 | /* Generated mode : "800x600-100", from /etc/fb.modes */ | ||
319 | /* DISABLED, hsstart == 0 | ||
320 | { | ||
321 | "800x600-100", { | ||
322 | 67499, 800, 600, 0, 64, 280, 1080, 7, 11, 25, 625, | ||
323 | 800, 0, 8, | ||
324 | PM3VideoControl_ENABLE | | ||
325 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
326 | | | ||
327 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
328 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
329 | */ | ||
330 | /* Generated mode : "800x600-100", from ??? */ | ||
331 | { | ||
332 | "800x600-100", { | ||
333 | 69650, 800, 600, 64, 128, 288, 1088, 4, 10, 40, 640, 800, 0, 8, | ||
334 | PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW| | ||
335 | PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
336 | /* Generated mode : "1024x768-43-lace" */ | ||
337 | /* INTERLACED NOT SUPPORTED | ||
338 | {"1024x768-43-lace", {44899, 1024, 768, 8, 184, 240, 1264, 1, 9, 49, 817, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
339 | INTERLACED NOT SUPPORTED */ | ||
340 | /* Generated mode : "1024x768-60" */ | ||
341 | { | ||
342 | "1024x768-60", { | ||
343 | 64998, 1024, 768, 24, 160, 320, 1344, 3, 9, 38, | ||
344 | 806, 1024, 0, 8, | ||
345 | PM3VideoControl_ENABLE | | ||
346 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
347 | | | ||
348 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
349 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
350 | /* Generated mode : "1024x768-70" */ | ||
351 | { | ||
352 | "1024x768-70", { | ||
353 | 74996, 1024, 768, 24, 160, 304, 1328, 3, 9, 38, | ||
354 | 806, 1024, 0, 8, | ||
355 | PM3VideoControl_ENABLE | | ||
356 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
357 | | | ||
358 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
359 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
360 | /* Generated mode : "1024x768-72" */ | ||
361 | { | ||
362 | "1024x768-72", { | ||
363 | 74996, 10224, 768, 24, 160, 264, 10488, 3, 9, 38, | ||
364 | 806, 10224, 0, 8, | ||
365 | PM3VideoControl_ENABLE | | ||
366 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
367 | | | ||
368 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
369 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
370 | /* Generated mode : "1024x768-75" */ | ||
371 | { | ||
372 | "1024x768-75", { | ||
373 | 78746, 1024, 768, 16, 112, 288, 1312, 1, 4, 32, | ||
374 | 800, 1024, 0, 8, | ||
375 | PM3VideoControl_ENABLE | | ||
376 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
377 | | | ||
378 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
379 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
380 | /* Generated mode : "1024x768-90" */ | ||
381 | { | ||
382 | "1024x768-90", { | ||
383 | 100000, 1024, 768, 0, 96, 288, 1312, 21, 36, 77, | ||
384 | 845, 1024, 0, 8, | ||
385 | PM3VideoControl_ENABLE | | ||
386 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
387 | | | ||
388 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
389 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
390 | /* Generated mode : "1024x768-100", from /etc/fb.modes */ | ||
391 | /* DISABLED, vsstart == 0 | ||
392 | { | ||
393 | "1024x768-100", { | ||
394 | 109998, 1024, 768, 0, 88, 368, 1392, 0, 8, 24, 792, | ||
395 | 1024, 0, 8, | ||
396 | PM3VideoControl_ENABLE | | ||
397 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
398 | | | ||
399 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
400 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
401 | */ | ||
402 | /* Generated mode : "1024x768-100", from ??? */ | ||
403 | { | ||
404 | "1024x768-100", { | ||
405 | 115500, 1024, 768, 32, 224, 416, 1440, 3, 13, 34, 802, 1024, 0, 8, | ||
406 | PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW| | ||
407 | PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
408 | /* Generated mode : "1152x864-43-lace" */ | ||
409 | /* INTERLACED NOT SUPPORTED | ||
410 | {"1152x864-43-lace", {64998, 1152, 864, 72, 200, 264, 1416, 78, 87, 191, 1055, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
411 | INTERLACED NOT SUPPORTED */ | ||
412 | /* Generated mode : "1152x864-47-lace" */ | ||
413 | /* INTERLACED NOT SUPPORTED | ||
414 | {"1152x864-47-lace", {64998, 1152, 864, 88, 216, 296, 1448, 30, 39, 83, 947, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
415 | INTERLACED NOT SUPPORTED */ | ||
416 | /* Generated mode : "1152x864-60" */ | ||
417 | { | ||
418 | "1152x864-60", { | ||
419 | 80000, 1152, 864, 64, 176, 304, 1456, 6, 11, 52, | ||
420 | 916, 1152, 0, 8, | ||
421 | PM3VideoControl_ENABLE | | ||
422 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
423 | | | ||
424 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
425 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
426 | /* Generated mode : "1152x864-70" */ | ||
427 | { | ||
428 | "1152x864-70", { | ||
429 | 100000, 1152, 864, 40, 192, 360, 1512, 13, 24, 81, | ||
430 | 945, 1152, 0, 8, | ||
431 | PM3VideoControl_ENABLE | | ||
432 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
433 | | | ||
434 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
435 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
436 | /* Generated mode : "1152x864-75" */ | ||
437 | { | ||
438 | "1152x864-75", { | ||
439 | 109998, 1152, 864, 24, 168, 312, 1464, 45, 53, 138, | ||
440 | 1002, 1152, 0, 8, | ||
441 | PM3VideoControl_ENABLE | | ||
442 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
443 | | | ||
444 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
445 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
446 | /* Generated mode : "1152x864-80" */ | ||
447 | { | ||
448 | "1152x864-80", { | ||
449 | 109998, 1152, 864, 16, 128, 288, 1440, 30, 37, 94, | ||
450 | 958, 1152, 0, 8, | ||
451 | PM3VideoControl_ENABLE | | ||
452 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
453 | | | ||
454 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
455 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
456 | /* Generated mode : "1280x1024-43-lace" */ | ||
457 | /* INTERLACED NOT SUPPORTED | ||
458 | {"1280x1024-43-lace", {80000, 1024, 1024, 80, 160, 320, 1344, 50, 60, 125, 1149, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
459 | INTERLACED NOT SUPPORTED */ | ||
460 | /* Generated mode : "1280x1024-47-lace" */ | ||
461 | /* INTERLACED NOT SUPPORTED | ||
462 | {"1280x1024-47-lace", {80000, 1280, 1024, 80, 160, 320, 1600, 1, 11, 29, 1053, 1280, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
463 | INTERLACED NOT SUPPORTED */ | ||
464 | /* Generated mode : "1280x1024-60" */ | ||
465 | { | ||
466 | "1280x1024-60", { | ||
467 | 107991, 1280, 1024, 48, 160, 408, 1688, 1, 4, 42, | ||
468 | 1066, 1280, 0, 8, | ||
469 | PM3VideoControl_ENABLE | | ||
470 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
471 | | | ||
472 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
473 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
474 | /* Generated mode : "1280x1024-70" */ | ||
475 | { | ||
476 | "1280x1024-70", { | ||
477 | 125992, 1280, 1024, 80, 192, 408, 1688, 1, 6, 42, | ||
478 | 1066, 1280, 0, 8, | ||
479 | PM3VideoControl_ENABLE | | ||
480 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
481 | | | ||
482 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
483 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
484 | /* Generated mode : "1280x1024-74" */ | ||
485 | { | ||
486 | "1280x1024-74", { | ||
487 | 134989, 1280, 1024, 32, 176, 432, 1712, 0, 30, 40, | ||
488 | 1064, 1280, 0, 8, | ||
489 | PM3VideoControl_ENABLE | | ||
490 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
491 | | | ||
492 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
493 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
494 | /* Generated mode : "1280x1024-75" */ | ||
495 | { | ||
496 | "1280x1024-75", { | ||
497 | 134989, 1280, 1024, 16, 160, 408, 1688, 1, 4, 42, | ||
498 | 1066, 1280, 0, 8, | ||
499 | PM3VideoControl_ENABLE | | ||
500 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
501 | | | ||
502 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
503 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
504 | /* Generated mode : "1600x1200-60" */ | ||
505 | { | ||
506 | "1600x1200-60", { | ||
507 | 155981, 1600, 1200, 32, 192, 448, 2048, 10, 18, 70, | ||
508 | 1270, 1600, 0, 8, | ||
509 | PM3VideoControl_ENABLE | | ||
510 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
511 | | | ||
512 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
513 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
514 | /* Generated mode : "1600x1200-66" */ | ||
515 | { | ||
516 | "1600x1200-66", { | ||
517 | 171998, 1600, 1200, 40, 176, 480, 2080, 3, 6, 53, | ||
518 | 1253, 1600, 0, 8, | ||
519 | PM3VideoControl_ENABLE | | ||
520 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
521 | | | ||
522 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
523 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
524 | /* Generated mode : "1600x1200-76" */ | ||
525 | { | ||
526 | "1600x1200-76", { | ||
527 | 197980, 1600, 1200, 40, 176, 480, 2080, 3, 8, 50, | ||
528 | 1250, 1600, 0, 8, | ||
529 | PM3VideoControl_ENABLE | | ||
530 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
531 | | | ||
532 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
533 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
534 | /* ##### end of auto-generated mode */ | ||
535 | { | ||
536 | "\0",} | ||
537 | }; | ||
538 | |||
539 | /* more mandatory stuff (see skeletonfb.c + framebuffer driver HOWTO */ | ||
540 | static struct pm3fb_info fb_info[PM3_MAX_BOARD]; | ||
541 | static struct pm3fb_par current_par[PM3_MAX_BOARD]; | ||
542 | static int current_par_valid[PM3_MAX_BOARD]; | ||
543 | /* to allow explicit filtering of board */ | ||
544 | short bus[PM3_MAX_BOARD]; | ||
545 | short slot[PM3_MAX_BOARD]; | ||
546 | short func[PM3_MAX_BOARD]; | ||
547 | short disable[PM3_MAX_BOARD]; | ||
548 | short noaccel[PM3_MAX_BOARD]; | ||
549 | char fontn[PM3_MAX_BOARD][PM3_FONTNAME_SIZE]; | ||
550 | short depth[PM3_MAX_BOARD]; | ||
551 | short flatpanel[PM3_MAX_BOARD]; | ||
552 | static struct display disp[PM3_MAX_BOARD]; | ||
553 | static char g_options[PM3_OPTIONS_SIZE] __initdata = "pm3fb,dummy"; | ||
554 | short printtimings = 0; | ||
555 | short forcesize[PM3_MAX_BOARD]; | ||
556 | |||
557 | /* ********************* */ | ||
558 | /* ***** prototype ***** */ | ||
559 | /* ********************* */ | ||
560 | /* card-specific */ | ||
561 | static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info); | ||
562 | /* permedia3-specific */ | ||
563 | static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info); | ||
564 | static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info); | ||
565 | static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info); | ||
566 | static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info, | ||
567 | unsigned long r); | ||
568 | static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */ | ||
569 | unsigned long refclock, /* In kHz units */ | ||
570 | unsigned char *prescale, /* ClkPreScale */ | ||
571 | unsigned char *feedback, /* ClkFeedBackScale */ | ||
572 | unsigned char *postscale | ||
573 | /* ClkPostScale */ ); | ||
574 | static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc); | ||
575 | static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b); | ||
576 | static void pm3fb_common_init(struct pm3fb_info *l_fb_info); | ||
577 | static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info, | ||
578 | unsigned long depth, int v); | ||
579 | static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info, | ||
580 | unsigned long depth, int v); | ||
581 | static void pm3fb_mapIO(struct pm3fb_info *l_fb_info); | ||
582 | static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info); | ||
583 | #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) | ||
584 | static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info); | ||
585 | #endif | ||
586 | static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info); | ||
587 | static void pm3fb_write_mode(struct pm3fb_info *l_fb_info); | ||
588 | static void pm3fb_read_mode(struct pm3fb_info *l_fb_info, | ||
589 | struct pm3fb_par *curpar); | ||
590 | static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info); | ||
591 | /* accelerated permedia3-specific */ | ||
592 | #ifdef PM3FB_USE_ACCEL | ||
593 | static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info); | ||
594 | static void pm3fb_init_engine(struct pm3fb_info *l_fb_info); | ||
595 | #ifdef FBCON_HAS_CFB32 | ||
596 | static void pm3fb_cfb32_clear(struct vc_data *conp, | ||
597 | struct display *p, | ||
598 | int sy, int sx, int height, int width); | ||
599 | static void pm3fb_cfb32_clear_margins(struct vc_data *conp, | ||
600 | struct display *p, int bottom_only); | ||
601 | #endif /* FBCON_HAS_CFB32 */ | ||
602 | #ifdef FBCON_HAS_CFB16 | ||
603 | static void pm3fb_cfb16_clear(struct vc_data *conp, | ||
604 | struct display *p, | ||
605 | int sy, int sx, int height, int width); | ||
606 | static void pm3fb_cfb16_clear_margins(struct vc_data *conp, | ||
607 | struct display *p, int bottom_only); | ||
608 | #endif /* FBCON_HAS_CFB16 */ | ||
609 | #ifdef FBCON_HAS_CFB8 | ||
610 | static void pm3fb_cfb8_clear(struct vc_data *conp, | ||
611 | struct display *p, | ||
612 | int sy, int sx, int height, int width); | ||
613 | static void pm3fb_cfb8_clear_margins(struct vc_data *conp, | ||
614 | struct display *p, int bottom_only); | ||
615 | #endif /* FBCON_HAS_CFB8 */ | ||
616 | #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32) | ||
617 | static void pm3fb_cfbX_bmove(struct display *p, | ||
618 | int sy, int sx, | ||
619 | int dy, int dx, int height, int width); | ||
620 | static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p, | ||
621 | int c, int yy, int xx); | ||
622 | static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p, | ||
623 | const unsigned short *s, int count, int yy, | ||
624 | int xx); | ||
625 | static void pm3fb_cfbX_revc(struct display *p, int xx, int yy); | ||
626 | #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */ | ||
627 | #endif /* PM3FB_USE_ACCEL */ | ||
628 | /* pre-init */ | ||
629 | static void pm3fb_mode_setup(char *mode, unsigned long board_num); | ||
630 | static void pm3fb_pciid_setup(char *pciid, unsigned long board_num); | ||
631 | static char *pm3fb_boardnum_setup(char *options, unsigned long *bn); | ||
632 | static void pm3fb_real_setup(char *options); | ||
633 | /* fbdev */ | ||
634 | static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix, | ||
635 | const void *par, struct fb_info_gen *info); | ||
636 | static int pm3fb_decode_var(const struct fb_var_screeninfo *var, | ||
637 | void *par, struct fb_info_gen *info); | ||
638 | static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d); | ||
639 | static int pm3fb_encode_var(struct fb_var_screeninfo *var, | ||
640 | const void *par, struct fb_info_gen *info); | ||
641 | static void pm3fb_get_par(void *par, struct fb_info_gen *info); | ||
642 | static void pm3fb_set_par(const void *par, struct fb_info_gen *info); | ||
643 | static void pm3fb_set_color(struct pm3fb_info *l_fb_info, | ||
644 | unsigned char regno, unsigned char r, | ||
645 | unsigned char g, unsigned char b); | ||
646 | static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green, | ||
647 | unsigned *blue, unsigned *transp, | ||
648 | struct fb_info *info); | ||
649 | static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, | ||
650 | unsigned blue, unsigned transp, | ||
651 | struct fb_info *info); | ||
652 | static int pm3fb_blank(int blank_mode, struct fb_info_gen *info); | ||
653 | static void pm3fb_set_disp(const void *par, struct display *disp, | ||
654 | struct fb_info_gen *info); | ||
655 | static void pm3fb_detect(void); | ||
656 | static int pm3fb_pan_display(const struct fb_var_screeninfo *var, | ||
657 | struct fb_info_gen *info); | ||
658 | static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg); | ||
659 | |||
660 | |||
661 | /* the struct that hold them together */ | ||
662 | struct fbgen_hwswitch pm3fb_switch = { | ||
663 | pm3fb_detect, pm3fb_encode_fix, pm3fb_decode_var, pm3fb_encode_var, | ||
664 | pm3fb_get_par, pm3fb_set_par, pm3fb_getcolreg, | ||
665 | pm3fb_pan_display, pm3fb_blank, pm3fb_set_disp | ||
666 | }; | ||
667 | 53 | ||
668 | static struct fb_ops pm3fb_ops = { | 54 | /* |
669 | .owner = THIS_MODULE, | 55 | * If your driver supports multiple boards, you should make the |
670 | .fb_get_fix = fbgen_get_fix, | 56 | * below data types arrays, or allocate them dynamically (using kmalloc()). |
671 | .fb_get_var = fbgen_get_var, | 57 | */ |
672 | .fb_set_var = fbgen_set_var, | ||
673 | .fb_get_cmap = fbgen_get_cmap, | ||
674 | .fb_set_cmap = fbgen_set_cmap, | ||
675 | .fb_setcolreg = pm3fb_setcolreg, | ||
676 | .fb_pan_display =fbgen_pan_display, | ||
677 | .fb_blank = fbgen_blank, | ||
678 | .fb_ioctl = pm3fb_ioctl, | ||
679 | }; | ||
680 | 58 | ||
681 | #ifdef PM3FB_USE_ACCEL | 59 | /* |
682 | #ifdef FBCON_HAS_CFB32 | 60 | * This structure defines the hardware state of the graphics card. Normally |
683 | static struct display_switch pm3fb_cfb32 = { | 61 | * you place this in a header file in linux/include/video. This file usually |
684 | fbcon_cfb32_setup, pm3fb_cfbX_bmove, pm3fb_cfb32_clear, | 62 | * also includes register information. That allows other driver subsystems |
685 | pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc, | 63 | * and userland applications the ability to use the same header file to |
686 | NULL /* cursor() */ , NULL /* set_font() */ , | 64 | * avoid duplicate work and easy porting of software. |
687 | pm3fb_cfb32_clear_margins, | 65 | */ |
688 | FONTWIDTHRANGE(1, 16) /* true only if accelerated... */ | 66 | struct pm3_par { |
689 | }; | 67 | unsigned char __iomem *v_regs;/* virtual address of p_regs */ |
690 | #endif /* FBCON_HAS_CFB32 */ | 68 | u32 video; /* video flags before blanking */ |
691 | #ifdef FBCON_HAS_CFB16 | 69 | u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */ |
692 | static struct display_switch pm3fb_cfb16 = { | 70 | u32 palette[16]; |
693 | fbcon_cfb16_setup, pm3fb_cfbX_bmove, pm3fb_cfb16_clear, | ||
694 | pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc, | ||
695 | NULL /* cursor() */ , NULL /* set_font() */ , | ||
696 | pm3fb_cfb16_clear_margins, | ||
697 | FONTWIDTHRANGE(1, 16) /* true only if accelerated... */ | ||
698 | }; | ||
699 | #endif /* FBCON_HAS_CFB16 */ | ||
700 | #ifdef FBCON_HAS_CFB8 | ||
701 | static struct display_switch pm3fb_cfb8 = { | ||
702 | fbcon_cfb8_setup, pm3fb_cfbX_bmove, pm3fb_cfb8_clear, | ||
703 | pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc, | ||
704 | NULL /* cursor() */ , NULL /* set_font() */ , | ||
705 | pm3fb_cfb8_clear_margins, | ||
706 | FONTWIDTHRANGE(1, 16) /* true only if accelerated... */ | ||
707 | }; | ||
708 | #endif /* FBCON_HAS_CFB8 */ | ||
709 | #endif /* PM3FB_USE_ACCEL */ | ||
710 | |||
711 | /* ****************************** */ | ||
712 | /* ***** card-specific data ***** */ | ||
713 | /* ****************************** */ | ||
714 | struct pm3fb_card_timings { | ||
715 | unsigned long memsize; /* 0 for last value (i.e. default) */ | ||
716 | struct pm3fb_timings memt; | ||
717 | }; | 71 | }; |
718 | 72 | ||
719 | static struct pm3fb_card_timings t_FormacProFormance3[] = { | 73 | /* |
720 | { 16, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} }, | 74 | * Here we define the default structs fb_fix_screeninfo and fb_var_screeninfo |
721 | { 0, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} } /* from 16 MB PF3 */ | 75 | * if we don't use modedb. If we do use modedb see pm3fb_init how to use it |
76 | * to get a fb_var_screeninfo. Otherwise define a default var as well. | ||
77 | */ | ||
78 | static struct fb_fix_screeninfo pm3fb_fix __devinitdata = { | ||
79 | .id = "Permedia3", | ||
80 | .type = FB_TYPE_PACKED_PIXELS, | ||
81 | .visual = FB_VISUAL_PSEUDOCOLOR, | ||
82 | .xpanstep = 1, | ||
83 | .ypanstep = 1, | ||
84 | .ywrapstep = 0, | ||
85 | .accel = FB_ACCEL_NONE, | ||
722 | }; | 86 | }; |
723 | 87 | ||
724 | static struct pm3fb_card_timings t_AppianJeronimo2000[] = { | 88 | /* |
725 | { 32, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} }, | 89 | * Utility functions |
726 | { 0, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} } /* from 32MB J2000 */ | 90 | */ |
727 | }; | ||
728 | 91 | ||
729 | static struct pm3fb_card_timings t_3DLabsOxygenVX1[] = { | 92 | static inline u32 PM3_READ_REG(struct pm3_par *par, s32 off) |
730 | { 32, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} }, | 93 | { |
731 | { 0, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} } /* from 32MB VX1 */ | 94 | return fb_readl(par->v_regs + off); |
732 | }; | 95 | } |
733 | 96 | ||
734 | static struct { | 97 | static inline void PM3_WRITE_REG(struct pm3_par *par, s32 off, u32 v) |
735 | char cardname[32]; /* recognized card name */ | 98 | { |
736 | u16 subvendor; /* subvendor of the card */ | 99 | fb_writel(v, par->v_regs + off); |
737 | u16 subdevice; /* subdevice of the card */ | 100 | } |
738 | u8 func; /* function of the card to which the extra init apply */ | ||
739 | void (*specific_setup)(struct pm3fb_info *l_fb_info); /* card/func specific setup, done before _any_ FB access */ | ||
740 | struct pm3fb_card_timings *c_memt; /* defauls timings for the boards */ | ||
741 | } cardbase[] = { | ||
742 | { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL, NULL }, | ||
743 | { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL, | ||
744 | t_AppianJeronimo2000 | ||
745 | }, | ||
746 | { "Appian Jeronimo 2000 head 2", 0x1097, 0x3d32, 2, pm3fb_j2000_setup, | ||
747 | t_AppianJeronimo2000 | ||
748 | }, | ||
749 | { "Formac ProFormance 3", PCI_VENDOR_ID_3DLABS, 0x000a, 0, NULL, /* Formac use 3DLabs ID ?!? */ | ||
750 | t_FormacProFormance3 | ||
751 | }, | ||
752 | { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS, 0x0127, 0, NULL, NULL }, | ||
753 | { "3DLabs Oxygen VX1 PCI", PCI_VENDOR_ID_3DLABS, 0x0121, 0, NULL, | ||
754 | t_3DLabsOxygenVX1 | ||
755 | }, | ||
756 | { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS, 0x0125, 0, NULL, NULL }, | ||
757 | { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS, 0x0140, 0, NULL, NULL }, | ||
758 | { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS, 0x0800, 0, NULL, NULL }, | ||
759 | { "\0", 0x0, 0x0, 0, NULL, NULL } | ||
760 | }; | ||
761 | 101 | ||
762 | /* ********************************** */ | 102 | static inline void PM3_WAIT(struct pm3_par *par, u32 n) |
763 | /* ***** card-specific function ***** */ | 103 | { |
764 | /* ********************************** */ | 104 | while (PM3_READ_REG(par, PM3InFIFOSpace) < n); |
765 | static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info) | ||
766 | { /* the appian j2000 require more initialization of the second head */ | ||
767 | /* l_fb_info must point to the _second_ head of the J2000 */ | ||
768 | |||
769 | DTRACE; | ||
770 | |||
771 | l_fb_info->memt = t_AppianJeronimo2000[0].memt; /* 32 MB, first and only j2000 ? */ | ||
772 | |||
773 | pm3fb_write_memory_timings(l_fb_info); | ||
774 | } | 105 | } |
775 | 106 | ||
776 | /* *************************************** */ | 107 | static inline void PM3_SLOW_WRITE_REG(struct pm3_par *par, s32 off, u32 v) |
777 | /* ***** permedia3-specific function ***** */ | ||
778 | /* *************************************** */ | ||
779 | static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info) | ||
780 | { | 108 | { |
781 | l_fb_info->memt.caps = PM3_READ_REG(PM3LocalMemCaps); | 109 | if (par->v_regs) { |
782 | l_fb_info->memt.timings = PM3_READ_REG(PM3LocalMemTimings); | 110 | mb(); |
783 | l_fb_info->memt.control = PM3_READ_REG(PM3LocalMemControl); | 111 | PM3_WAIT(par, 1); |
784 | l_fb_info->memt.refresh = PM3_READ_REG(PM3LocalMemRefresh); | 112 | wmb(); |
785 | l_fb_info->memt.powerdown = PM3_READ_REG(PM3LocalMemPowerDown); | 113 | PM3_WRITE_REG(par, off, v); |
786 | |||
787 | if ((l_fb_info->memt.caps == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
788 | (l_fb_info->memt.timings == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
789 | (l_fb_info->memt.control == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
790 | (l_fb_info->memt.refresh == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
791 | (l_fb_info->memt.powerdown == PM3FB_UNKNOWN_TIMING_VALUE)) | ||
792 | { | ||
793 | printk(KERN_ERR "pm3fb: invalid memory timings in permedia3 board #%ld\n", l_fb_info->board_num); | ||
794 | return(pm3fb_try_memory_timings(l_fb_info)); | ||
795 | } | 114 | } |
796 | return(pm3fb_timing_ok); | ||
797 | } | 115 | } |
798 | 116 | ||
799 | static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info) | 117 | static inline void PM3_SET_INDEX(struct pm3_par *par, unsigned index) |
800 | { | 118 | { |
801 | if (cardbase[l_fb_info->board_type].c_memt) | 119 | PM3_SLOW_WRITE_REG(par, PM3RD_IndexHigh, (index >> 8) & 0xff); |
802 | { | 120 | PM3_SLOW_WRITE_REG(par, PM3RD_IndexLow, index & 0xff); |
803 | int i = 0, done = 0; | 121 | } |
804 | while (!done) | 122 | |
805 | { | 123 | static inline void PM3_WRITE_DAC_REG(struct pm3_par *par, unsigned r, u8 v) |
806 | if ((cardbase[l_fb_info->board_type].c_memt[i].memsize == l_fb_info->fb_size) | 124 | { |
807 | || !(cardbase[l_fb_info->board_type].c_memt[i].memsize)) | 125 | PM3_SET_INDEX(par, r); |
808 | { /* will use the 0-sized timings by default */ | 126 | wmb(); |
809 | done = 1; | 127 | PM3_WRITE_REG(par, PM3RD_IndexedData, v); |
810 | l_fb_info->memt = cardbase[l_fb_info->board_type].c_memt[i].memt; | ||
811 | printk(KERN_WARNING "pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s, %ld MB)\n", | ||
812 | l_fb_info->board_num, | ||
813 | cardbase[l_fb_info->board_type].cardname, | ||
814 | cardbase[l_fb_info->board_type].c_memt[i].memsize); | ||
815 | pm3fb_write_memory_timings(l_fb_info); | ||
816 | return(pm3fb_timing_retry); | ||
817 | } | ||
818 | i++; | ||
819 | } | ||
820 | } else | ||
821 | return(pm3fb_timing_problem); | ||
822 | return(pm3fb_timing_ok); | ||
823 | } | 128 | } |
824 | 129 | ||
825 | static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info) | 130 | static inline void pm3fb_set_color(struct pm3_par *par, unsigned char regno, |
131 | unsigned char r, unsigned char g, unsigned char b) | ||
826 | { | 132 | { |
827 | unsigned char m, n, p; | 133 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteWriteAddress, regno); |
828 | unsigned long clockused; | 134 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, r); |
829 | 135 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, g); | |
830 | PM3_SLOW_WRITE_REG(PM3LocalMemCaps, l_fb_info->memt.caps); | 136 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, b); |
831 | PM3_SLOW_WRITE_REG(PM3LocalMemTimings, l_fb_info->memt.timings); | ||
832 | PM3_SLOW_WRITE_REG(PM3LocalMemControl, l_fb_info->memt.control); | ||
833 | PM3_SLOW_WRITE_REG(PM3LocalMemRefresh, l_fb_info->memt.refresh); | ||
834 | PM3_SLOW_WRITE_REG(PM3LocalMemPowerDown, l_fb_info->memt.powerdown); | ||
835 | |||
836 | clockused = | ||
837 | pm3fb_CalculateClock(l_fb_info, 2 * 105000, PM3_REF_CLOCK, &m, | ||
838 | &n, &p); | ||
839 | |||
840 | PM3_WRITE_DAC_REG(PM3RD_KClkPreScale, m); | ||
841 | PM3_WRITE_DAC_REG(PM3RD_KClkFeedbackScale, n); | ||
842 | PM3_WRITE_DAC_REG(PM3RD_KClkPostScale, p); | ||
843 | PM3_WRITE_DAC_REG(PM3RD_KClkControl, | ||
844 | PM3RD_KClkControl_STATE_RUN | | ||
845 | PM3RD_KClkControl_SOURCE_PLL | | ||
846 | PM3RD_KClkControl_ENABLE); | ||
847 | PM3_WRITE_DAC_REG(PM3RD_MClkControl, | ||
848 | PM3RD_MClkControl_STATE_RUN | | ||
849 | PM3RD_MClkControl_SOURCE_KCLK | | ||
850 | PM3RD_MClkControl_ENABLE); | ||
851 | PM3_WRITE_DAC_REG(PM3RD_SClkControl, | ||
852 | PM3RD_SClkControl_STATE_RUN | | ||
853 | PM3RD_SClkControl_SOURCE_PCLK | | ||
854 | PM3RD_SClkControl_ENABLE); | ||
855 | } | 137 | } |
856 | 138 | ||
857 | static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info, | 139 | static void pm3fb_clear_colormap(struct pm3_par *par, |
858 | unsigned long r) | 140 | unsigned char r, unsigned char g, unsigned char b) |
859 | { | 141 | { |
860 | DASSERT((l_fb_info->vIOBase != (unsigned char *) (-1)), | 142 | int i; |
861 | "l_fb_info->vIOBase mapped in read dac reg\n"); | 143 | |
862 | PM3_SET_INDEX(r); | 144 | for (i = 0; i < 256 ; i++) /* fill color map with white */ |
863 | mb(); | 145 | pm3fb_set_color(par, i, r, g, b); |
864 | return (PM3_READ_REG(PM3RD_IndexedData)); | 146 | |
865 | } | 147 | } |
866 | 148 | ||
867 | /* Calculating various clock parameter */ | 149 | /* Calculating various clock parameter */ |
868 | static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */ | 150 | static void pm3fb_calculate_clock(unsigned long reqclock, |
869 | unsigned long refclock, /* In kHz units */ | 151 | unsigned char *prescale, |
870 | unsigned char *prescale, /* ClkPreScale */ | 152 | unsigned char *feedback, |
871 | unsigned char *feedback, /* ClkFeedBackScale */ | 153 | unsigned char *postscale) |
872 | unsigned char *postscale | ||
873 | /* ClkPostScale */ ) | ||
874 | { | 154 | { |
875 | int f, pre, post; | 155 | int f, pre, post; |
876 | unsigned long freq; | 156 | unsigned long freq; |
877 | long freqerr = 1000; | 157 | long freqerr = 1000; |
878 | unsigned long actualclock = 0; | 158 | long currerr; |
879 | |||
880 | DTRACE; | ||
881 | 159 | ||
882 | for (f = 1; f < 256; f++) { | 160 | for (f = 1; f < 256; f++) { |
883 | for (pre = 1; pre < 256; pre++) { | 161 | for (pre = 1; pre < 256; pre++) { |
884 | for (post = 0; post < 5; post++) { | 162 | for (post = 0; post < 5; post++) { |
885 | freq = | 163 | freq = ((2*PM3_REF_CLOCK * f) >> post) / pre; |
886 | ((2 * refclock * f) / | 164 | currerr = (reqclock > freq) |
887 | (pre * (1 << post))); | 165 | ? reqclock - freq |
888 | if ((reqclock > freq - freqerr) | 166 | : freq - reqclock; |
889 | && (reqclock < freq + freqerr)) { | 167 | if (currerr < freqerr) { |
890 | freqerr = | 168 | freqerr = currerr; |
891 | (reqclock > | ||
892 | freq) ? reqclock - | ||
893 | freq : freq - reqclock; | ||
894 | *feedback = f; | 169 | *feedback = f; |
895 | *prescale = pre; | 170 | *prescale = pre; |
896 | *postscale = post; | 171 | *postscale = post; |
897 | actualclock = freq; | ||
898 | } | 172 | } |
899 | } | 173 | } |
900 | } | 174 | } |
901 | } | 175 | } |
902 | |||
903 | return (actualclock); | ||
904 | } | 176 | } |
905 | 177 | ||
906 | static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info, | 178 | static inline int pm3fb_shift_bpp(unsigned long depth, int v) |
907 | unsigned long depth, int v) | ||
908 | { | 179 | { |
909 | DTRACE; | ||
910 | |||
911 | switch (depth) { | 180 | switch (depth) { |
912 | case 8: | 181 | case 8: |
913 | return (v >> 4); | 182 | return (v >> 4); |
@@ -918,181 +187,59 @@ static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info, | |||
918 | case 32: | 187 | case 32: |
919 | return (v >> 2); | 188 | return (v >> 2); |
920 | } | 189 | } |
921 | DPRINTK(1, "Unsupported depth %ld\n", depth); | 190 | DPRINTK("Unsupported depth %ld\n", depth); |
922 | return (0); | 191 | return 0; |
923 | } | ||
924 | |||
925 | static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info, | ||
926 | unsigned long depth, int v) | ||
927 | { | ||
928 | DTRACE; | ||
929 | |||
930 | switch (depth) { | ||
931 | case 8: | ||
932 | return (v << 4); | ||
933 | case 12: | ||
934 | case 15: | ||
935 | case 16: | ||
936 | return (v << 3); | ||
937 | case 32: | ||
938 | return (v << 2); | ||
939 | } | ||
940 | DPRINTK(1, "Unsupported depth %ld\n", depth); | ||
941 | return (0); | ||
942 | } | ||
943 | |||
944 | static void pm3fb_mapIO(struct pm3fb_info *l_fb_info) | ||
945 | { | ||
946 | DTRACE; | ||
947 | |||
948 | l_fb_info->vIOBase = | ||
949 | ioremap((unsigned long) l_fb_info->pIOBase, PM3_REGS_SIZE); | ||
950 | l_fb_info->v_fb = | ||
951 | ioremap((unsigned long) l_fb_info->p_fb, l_fb_info->fb_size); | ||
952 | DPRINTK(2, "IO mapping : IOBase %lx / %lx, fb %lx / %lx\n", | ||
953 | (unsigned long) l_fb_info->pIOBase, | ||
954 | (unsigned long) l_fb_info->vIOBase, | ||
955 | (unsigned long) l_fb_info->p_fb, | ||
956 | (unsigned long) l_fb_info->v_fb); | ||
957 | } | ||
958 | |||
959 | static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info) | ||
960 | { | ||
961 | DTRACE; | ||
962 | |||
963 | iounmap(l_fb_info->vIOBase); | ||
964 | iounmap(l_fb_info->v_fb); | ||
965 | l_fb_info->vIOBase = (unsigned char *) -1; | ||
966 | l_fb_info->v_fb = (unsigned char *) -1; | ||
967 | } | ||
968 | |||
969 | #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) | ||
970 | static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info) | ||
971 | { | ||
972 | DPRINTK(2, "PM3Aperture0: 0x%08x\n", PM3_READ_REG(PM3Aperture0)); | ||
973 | DPRINTK(2, "PM3Aperture1: 0x%08x\n", PM3_READ_REG(PM3Aperture1)); | ||
974 | DPRINTK(2, "PM3ByAperture1Mode: 0x%08x\n", | ||
975 | PM3_READ_REG(PM3ByAperture1Mode)); | ||
976 | DPRINTK(2, "PM3ByAperture2Mode: 0x%08x\n", | ||
977 | PM3_READ_REG(PM3ByAperture2Mode)); | ||
978 | DPRINTK(2, "PM3ChipConfig: 0x%08x\n", PM3_READ_REG(PM3ChipConfig)); | ||
979 | DPRINTK(2, "PM3FIFODis: 0x%08x\n", PM3_READ_REG(PM3FIFODis)); | ||
980 | DPRINTK(2, "PM3HTotal: 0x%08x\n", PM3_READ_REG(PM3HTotal)); | ||
981 | DPRINTK(2, "PM3HbEnd: 0x%08x\n", PM3_READ_REG(PM3HbEnd)); | ||
982 | DPRINTK(2, "PM3HgEnd: 0x%08x\n", PM3_READ_REG(PM3HgEnd)); | ||
983 | DPRINTK(2, "PM3HsEnd: 0x%08x\n", PM3_READ_REG(PM3HsEnd)); | ||
984 | DPRINTK(2, "PM3HsStart: 0x%08x\n", PM3_READ_REG(PM3HsStart)); | ||
985 | DPRINTK(2, "PM3MemBypassWriteMask: 0x%08x\n", | ||
986 | PM3_READ_REG(PM3MemBypassWriteMask)); | ||
987 | DPRINTK(2, "PM3RD_IndexControl: 0x%08x\n", | ||
988 | PM3_READ_REG(PM3RD_IndexControl)); | ||
989 | DPRINTK(2, "PM3ScreenBase: 0x%08x\n", PM3_READ_REG(PM3ScreenBase)); | ||
990 | DPRINTK(2, "PM3ScreenStride: 0x%08x\n", | ||
991 | PM3_READ_REG(PM3ScreenStride)); | ||
992 | DPRINTK(2, "PM3VClkCtl: 0x%08x\n", PM3_READ_REG(PM3VClkCtl)); | ||
993 | DPRINTK(2, "PM3VTotal: 0x%08x\n", PM3_READ_REG(PM3VTotal)); | ||
994 | DPRINTK(2, "PM3VbEnd: 0x%08x\n", PM3_READ_REG(PM3VbEnd)); | ||
995 | DPRINTK(2, "PM3VideoControl: 0x%08x\n", | ||
996 | PM3_READ_REG(PM3VideoControl)); | ||
997 | DPRINTK(2, "PM3VsEnd: 0x%08x\n", PM3_READ_REG(PM3VsEnd)); | ||
998 | DPRINTK(2, "PM3VsStart: 0x%08x\n", PM3_READ_REG(PM3VsStart)); | ||
999 | |||
1000 | DPRINTK(2, "PM3RD_ColorFormat: %ld\n", | ||
1001 | PM3_READ_DAC_REG(PM3RD_ColorFormat)); | ||
1002 | DPRINTK(2, "PM3RD_DACControl: %ld\n", | ||
1003 | PM3_READ_DAC_REG(PM3RD_DACControl)); | ||
1004 | DPRINTK(2, "PM3RD_DClk0FeedbackScale: %ld\n", | ||
1005 | PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale)); | ||
1006 | DPRINTK(2, "PM3RD_DClk0PostScale: %ld\n", | ||
1007 | PM3_READ_DAC_REG(PM3RD_DClk0PostScale)); | ||
1008 | DPRINTK(2, "PM3RD_DClk0PreScale: %ld\n", | ||
1009 | PM3_READ_DAC_REG(PM3RD_DClk0PreScale)); | ||
1010 | DPRINTK(2, "[not set] PM3RD_IndexControl: %ld\n", | ||
1011 | PM3_READ_DAC_REG(PM3RD_IndexControl)); | ||
1012 | DPRINTK(2, "PM3RD_MiscControl: %ld\n", | ||
1013 | PM3_READ_DAC_REG(PM3RD_MiscControl)); | ||
1014 | DPRINTK(2, "PM3RD_PixelSize: %ld\n", | ||
1015 | PM3_READ_DAC_REG(PM3RD_PixelSize)); | ||
1016 | DPRINTK(2, "PM3RD_SyncControl: %ld\n", | ||
1017 | PM3_READ_DAC_REG(PM3RD_SyncControl)); | ||
1018 | } | ||
1019 | |||
1020 | #endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) */ | ||
1021 | static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info) | ||
1022 | { | ||
1023 | u16 subvendor, subdevice; | ||
1024 | |||
1025 | if ((!pci_read_config_word | ||
1026 | (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor)) | ||
1027 | && | ||
1028 | (!pci_read_config_word | ||
1029 | (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) { | ||
1030 | /* well, nothing... */ | ||
1031 | } else { | ||
1032 | subvendor = subdevice = (u16)-1; | ||
1033 | } | ||
1034 | |||
1035 | printk(KERN_INFO "pm3fb: memory timings for board #%ld (subvendor: 0x%hx, subdevice: 0x%hx)\n", l_fb_info->board_num, subvendor, subdevice); | ||
1036 | printk(KERN_INFO " PM3LocalMemCaps: 0x%08x\n", | ||
1037 | PM3_READ_REG(PM3LocalMemCaps)); | ||
1038 | printk(KERN_INFO " PM3LocalMemTimings: 0x%08x\n", | ||
1039 | PM3_READ_REG(PM3LocalMemTimings)); | ||
1040 | printk(KERN_INFO " PM3LocalMemControl: 0x%08x\n", | ||
1041 | PM3_READ_REG(PM3LocalMemControl)); | ||
1042 | printk(KERN_INFO " PM3LocalMemRefresh: 0x%08x\n", | ||
1043 | PM3_READ_REG(PM3LocalMemRefresh)); | ||
1044 | printk(KERN_INFO " PM3LocalMemPowerDown: 0x%08x\n", | ||
1045 | PM3_READ_REG(PM3LocalMemPowerDown)); | ||
1046 | } | 192 | } |
1047 | 193 | ||
1048 | /* write the mode to registers */ | 194 | /* write the mode to registers */ |
1049 | static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | 195 | static void pm3fb_write_mode(struct fb_info *info) |
1050 | { | 196 | { |
197 | struct pm3_par *par = info->par; | ||
1051 | char tempsync = 0x00, tempmisc = 0x00; | 198 | char tempsync = 0x00, tempmisc = 0x00; |
1052 | DTRACE; | 199 | const u32 hsstart = info->var.right_margin; |
1053 | 200 | const u32 hsend = hsstart + info->var.hsync_len; | |
1054 | PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xffffffff); | 201 | const u32 hbend = hsend + info->var.left_margin; |
1055 | PM3_SLOW_WRITE_REG(PM3Aperture0, 0x00000000); | 202 | const u32 xres = (info->var.xres + 31) & ~31; |
1056 | PM3_SLOW_WRITE_REG(PM3Aperture1, 0x00000000); | 203 | const u32 htotal = xres + hbend; |
1057 | PM3_SLOW_WRITE_REG(PM3FIFODis, 0x00000007); | 204 | const u32 vsstart = info->var.lower_margin; |
1058 | 205 | const u32 vsend = vsstart + info->var.vsync_len; | |
1059 | PM3_SLOW_WRITE_REG(PM3HTotal, | 206 | const u32 vbend = vsend + info->var.upper_margin; |
1060 | pm3fb_Shiftbpp(l_fb_info, | 207 | const u32 vtotal = info->var.yres + vbend; |
1061 | l_fb_info->current_par->depth, | 208 | const u32 width = (info->var.xres_virtual + 7) & ~7; |
1062 | l_fb_info->current_par->htotal - | 209 | |
1063 | 1)); | 210 | PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xffffffff); |
1064 | PM3_SLOW_WRITE_REG(PM3HsEnd, | 211 | PM3_SLOW_WRITE_REG(par, PM3Aperture0, 0x00000000); |
1065 | pm3fb_Shiftbpp(l_fb_info, | 212 | PM3_SLOW_WRITE_REG(par, PM3Aperture1, 0x00000000); |
1066 | l_fb_info->current_par->depth, | 213 | PM3_SLOW_WRITE_REG(par, PM3FIFODis, 0x00000007); |
1067 | l_fb_info->current_par->hsend)); | 214 | |
1068 | PM3_SLOW_WRITE_REG(PM3HsStart, | 215 | PM3_SLOW_WRITE_REG(par, PM3HTotal, |
1069 | pm3fb_Shiftbpp(l_fb_info, | 216 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1070 | l_fb_info->current_par->depth, | 217 | htotal - 1)); |
1071 | l_fb_info->current_par-> | 218 | PM3_SLOW_WRITE_REG(par, PM3HsEnd, |
219 | pm3fb_shift_bpp(info->var.bits_per_pixel, | ||
220 | hsend)); | ||
221 | PM3_SLOW_WRITE_REG(par, PM3HsStart, | ||
222 | pm3fb_shift_bpp(info->var.bits_per_pixel, | ||
1072 | hsstart)); | 223 | hsstart)); |
1073 | PM3_SLOW_WRITE_REG(PM3HbEnd, | 224 | PM3_SLOW_WRITE_REG(par, PM3HbEnd, |
1074 | pm3fb_Shiftbpp(l_fb_info, | 225 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1075 | l_fb_info->current_par->depth, | 226 | hbend)); |
1076 | l_fb_info->current_par->hbend)); | 227 | PM3_SLOW_WRITE_REG(par, PM3HgEnd, |
1077 | PM3_SLOW_WRITE_REG(PM3HgEnd, | 228 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1078 | pm3fb_Shiftbpp(l_fb_info, | 229 | hbend)); |
1079 | l_fb_info->current_par->depth, | 230 | PM3_SLOW_WRITE_REG(par, PM3ScreenStride, |
1080 | l_fb_info->current_par->hbend)); | 231 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1081 | PM3_SLOW_WRITE_REG(PM3ScreenStride, | 232 | width)); |
1082 | pm3fb_Shiftbpp(l_fb_info, | 233 | PM3_SLOW_WRITE_REG(par, PM3VTotal, vtotal - 1); |
1083 | l_fb_info->current_par->depth, | 234 | PM3_SLOW_WRITE_REG(par, PM3VsEnd, vsend - 1); |
1084 | l_fb_info->current_par->stride)); | 235 | PM3_SLOW_WRITE_REG(par, PM3VsStart, vsstart - 1); |
1085 | PM3_SLOW_WRITE_REG(PM3VTotal, l_fb_info->current_par->vtotal - 1); | 236 | PM3_SLOW_WRITE_REG(par, PM3VbEnd, vbend); |
1086 | PM3_SLOW_WRITE_REG(PM3VsEnd, l_fb_info->current_par->vsend - 1); | 237 | |
1087 | PM3_SLOW_WRITE_REG(PM3VsStart, | 238 | switch (info->var.bits_per_pixel) { |
1088 | l_fb_info->current_par->vsstart - 1); | ||
1089 | PM3_SLOW_WRITE_REG(PM3VbEnd, l_fb_info->current_par->vbend); | ||
1090 | |||
1091 | switch (l_fb_info->current_par->depth) { | ||
1092 | case 8: | 239 | case 8: |
1093 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 240 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1094 | PM3ByApertureMode_PIXELSIZE_8BIT); | 241 | PM3ByApertureMode_PIXELSIZE_8BIT); |
1095 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 242 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1096 | PM3ByApertureMode_PIXELSIZE_8BIT); | 243 | PM3ByApertureMode_PIXELSIZE_8BIT); |
1097 | break; | 244 | break; |
1098 | 245 | ||
@@ -1100,15 +247,15 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1100 | case 15: | 247 | case 15: |
1101 | case 16: | 248 | case 16: |
1102 | #ifndef __BIG_ENDIAN | 249 | #ifndef __BIG_ENDIAN |
1103 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 250 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1104 | PM3ByApertureMode_PIXELSIZE_16BIT); | 251 | PM3ByApertureMode_PIXELSIZE_16BIT); |
1105 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 252 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1106 | PM3ByApertureMode_PIXELSIZE_16BIT); | 253 | PM3ByApertureMode_PIXELSIZE_16BIT); |
1107 | #else | 254 | #else |
1108 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 255 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1109 | PM3ByApertureMode_PIXELSIZE_16BIT | | 256 | PM3ByApertureMode_PIXELSIZE_16BIT | |
1110 | PM3ByApertureMode_BYTESWAP_BADC); | 257 | PM3ByApertureMode_BYTESWAP_BADC); |
1111 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 258 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1112 | PM3ByApertureMode_PIXELSIZE_16BIT | | 259 | PM3ByApertureMode_PIXELSIZE_16BIT | |
1113 | PM3ByApertureMode_BYTESWAP_BADC); | 260 | PM3ByApertureMode_BYTESWAP_BADC); |
1114 | #endif /* ! __BIG_ENDIAN */ | 261 | #endif /* ! __BIG_ENDIAN */ |
@@ -1116,23 +263,23 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1116 | 263 | ||
1117 | case 32: | 264 | case 32: |
1118 | #ifndef __BIG_ENDIAN | 265 | #ifndef __BIG_ENDIAN |
1119 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 266 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1120 | PM3ByApertureMode_PIXELSIZE_32BIT); | 267 | PM3ByApertureMode_PIXELSIZE_32BIT); |
1121 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 268 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1122 | PM3ByApertureMode_PIXELSIZE_32BIT); | 269 | PM3ByApertureMode_PIXELSIZE_32BIT); |
1123 | #else | 270 | #else |
1124 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 271 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1125 | PM3ByApertureMode_PIXELSIZE_32BIT | | 272 | PM3ByApertureMode_PIXELSIZE_32BIT | |
1126 | PM3ByApertureMode_BYTESWAP_DCBA); | 273 | PM3ByApertureMode_BYTESWAP_DCBA); |
1127 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 274 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1128 | PM3ByApertureMode_PIXELSIZE_32BIT | | 275 | PM3ByApertureMode_PIXELSIZE_32BIT | |
1129 | PM3ByApertureMode_BYTESWAP_DCBA); | 276 | PM3ByApertureMode_BYTESWAP_DCBA); |
1130 | #endif /* ! __BIG_ENDIAN */ | 277 | #endif /* ! __BIG_ENDIAN */ |
1131 | break; | 278 | break; |
1132 | 279 | ||
1133 | default: | 280 | default: |
1134 | DPRINTK(1, "Unsupported depth %d\n", | 281 | DPRINTK("Unsupported depth %d\n", |
1135 | l_fb_info->current_par->depth); | 282 | info->var.bits_per_pixel); |
1136 | break; | 283 | break; |
1137 | } | 284 | } |
1138 | 285 | ||
@@ -1143,95 +290,86 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1143 | * sync options in PM3RD_SyncControl. --rmk | 290 | * sync options in PM3RD_SyncControl. --rmk |
1144 | */ | 291 | */ |
1145 | { | 292 | { |
1146 | unsigned int video = l_fb_info->current_par->video; | 293 | unsigned int video = par->video; |
1147 | 294 | ||
1148 | video &= ~(PM3VideoControl_HSYNC_MASK | | 295 | video &= ~(PM3VideoControl_HSYNC_MASK | |
1149 | PM3VideoControl_VSYNC_MASK); | 296 | PM3VideoControl_VSYNC_MASK); |
1150 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | | 297 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | |
1151 | PM3VideoControl_VSYNC_ACTIVE_HIGH; | 298 | PM3VideoControl_VSYNC_ACTIVE_HIGH; |
1152 | PM3_SLOW_WRITE_REG(PM3VideoControl, video); | 299 | PM3_SLOW_WRITE_REG(par, PM3VideoControl, video); |
1153 | } | 300 | } |
1154 | PM3_SLOW_WRITE_REG(PM3VClkCtl, | 301 | PM3_SLOW_WRITE_REG(par, PM3VClkCtl, |
1155 | (PM3_READ_REG(PM3VClkCtl) & 0xFFFFFFFC)); | 302 | (PM3_READ_REG(par, PM3VClkCtl) & 0xFFFFFFFC)); |
1156 | PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base); | 303 | PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base); |
1157 | PM3_SLOW_WRITE_REG(PM3ChipConfig, | 304 | PM3_SLOW_WRITE_REG(par, PM3ChipConfig, |
1158 | (PM3_READ_REG(PM3ChipConfig) & 0xFFFFFFFD)); | 305 | (PM3_READ_REG(par, PM3ChipConfig) & 0xFFFFFFFD)); |
1159 | 306 | ||
1160 | { | 307 | { |
1161 | unsigned char m; /* ClkPreScale */ | 308 | unsigned char uninitialized_var(m); /* ClkPreScale */ |
1162 | unsigned char n; /* ClkFeedBackScale */ | 309 | unsigned char uninitialized_var(n); /* ClkFeedBackScale */ |
1163 | unsigned char p; /* ClkPostScale */ | 310 | unsigned char uninitialized_var(p); /* ClkPostScale */ |
1164 | (void)pm3fb_CalculateClock(l_fb_info, l_fb_info->current_par->pixclock, PM3_REF_CLOCK, &m, &n, &p); | 311 | unsigned long pixclock = PICOS2KHZ(info->var.pixclock); |
1165 | 312 | ||
1166 | DPRINTK(2, | 313 | (void)pm3fb_calculate_clock(pixclock, &m, &n, &p); |
1167 | "Pixclock: %d, Pre: %d, Feedback: %d, Post: %d\n", | 314 | |
1168 | l_fb_info->current_par->pixclock, (int) m, (int) n, | 315 | DPRINTK("Pixclock: %ld, Pre: %d, Feedback: %d, Post: %d\n", |
1169 | (int) p); | 316 | pixclock, (int) m, (int) n, (int) p); |
1170 | 317 | ||
1171 | PM3_WRITE_DAC_REG(PM3RD_DClk0PreScale, m); | 318 | PM3_WRITE_DAC_REG(par, PM3RD_DClk0PreScale, m); |
1172 | PM3_WRITE_DAC_REG(PM3RD_DClk0FeedbackScale, n); | 319 | PM3_WRITE_DAC_REG(par, PM3RD_DClk0FeedbackScale, n); |
1173 | PM3_WRITE_DAC_REG(PM3RD_DClk0PostScale, p); | 320 | PM3_WRITE_DAC_REG(par, PM3RD_DClk0PostScale, p); |
1174 | } | 321 | } |
1175 | /* | 322 | /* |
1176 | PM3_WRITE_DAC_REG(PM3RD_IndexControl, 0x00); | 323 | PM3_WRITE_DAC_REG(par, PM3RD_IndexControl, 0x00); |
1177 | */ | 324 | */ |
1178 | /* | 325 | /* |
1179 | PM3_SLOW_WRITE_REG(PM3RD_IndexControl, 0x00); | 326 | PM3_SLOW_WRITE_REG(par, PM3RD_IndexControl, 0x00); |
1180 | */ | 327 | */ |
1181 | if ((l_fb_info->current_par->video & PM3VideoControl_HSYNC_MASK) == | 328 | if ((par->video & PM3VideoControl_HSYNC_MASK) == |
1182 | PM3VideoControl_HSYNC_ACTIVE_HIGH) | 329 | PM3VideoControl_HSYNC_ACTIVE_HIGH) |
1183 | tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH; | 330 | tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH; |
1184 | if ((l_fb_info->current_par->video & PM3VideoControl_VSYNC_MASK) == | 331 | if ((par->video & PM3VideoControl_VSYNC_MASK) == |
1185 | PM3VideoControl_VSYNC_ACTIVE_HIGH) | 332 | PM3VideoControl_VSYNC_ACTIVE_HIGH) |
1186 | tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH; | 333 | tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH; |
1187 | |||
1188 | PM3_WRITE_DAC_REG(PM3RD_SyncControl, tempsync); | ||
1189 | DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync); | ||
1190 | |||
1191 | if (flatpanel[l_fb_info->board_num]) | ||
1192 | { | ||
1193 | PM3_WRITE_DAC_REG(PM3RD_DACControl, PM3RD_DACControl_BLANK_PEDESTAL_ENABLE); | ||
1194 | PM3_WAIT(2); | ||
1195 | PM3_WRITE_REG(PM3VSConfiguration, 0x06); | ||
1196 | PM3_WRITE_REG(0x5a00, 1 << 14); /* black magic... */ | ||
1197 | tempmisc = PM3RD_MiscControl_VSB_OUTPUT_ENABLE; | ||
1198 | } | ||
1199 | else | ||
1200 | PM3_WRITE_DAC_REG(PM3RD_DACControl, 0x00); | ||
1201 | 334 | ||
1202 | switch (l_fb_info->current_par->depth) { | 335 | PM3_WRITE_DAC_REG(par, PM3RD_SyncControl, tempsync); |
336 | DPRINTK("PM3RD_SyncControl: %d\n", tempsync); | ||
337 | |||
338 | PM3_WRITE_DAC_REG(par, PM3RD_DACControl, 0x00); | ||
339 | |||
340 | switch (info->var.bits_per_pixel) { | ||
1203 | case 8: | 341 | case 8: |
1204 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 342 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1205 | PM3RD_PixelSize_8_BIT_PIXELS); | 343 | PM3RD_PixelSize_8_BIT_PIXELS); |
1206 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 344 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1207 | PM3RD_ColorFormat_CI8_COLOR | | 345 | PM3RD_ColorFormat_CI8_COLOR | |
1208 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); | 346 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); |
1209 | tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 347 | tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1210 | break; | 348 | break; |
1211 | case 12: | 349 | case 12: |
1212 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 350 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1213 | PM3RD_PixelSize_16_BIT_PIXELS); | 351 | PM3RD_PixelSize_16_BIT_PIXELS); |
1214 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 352 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1215 | PM3RD_ColorFormat_4444_COLOR | | 353 | PM3RD_ColorFormat_4444_COLOR | |
1216 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | | 354 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | |
1217 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); | 355 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); |
1218 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | | 356 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | |
1219 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 357 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1220 | break; | 358 | break; |
1221 | case 15: | 359 | case 15: |
1222 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 360 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1223 | PM3RD_PixelSize_16_BIT_PIXELS); | 361 | PM3RD_PixelSize_16_BIT_PIXELS); |
1224 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 362 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1225 | PM3RD_ColorFormat_5551_FRONT_COLOR | | 363 | PM3RD_ColorFormat_5551_FRONT_COLOR | |
1226 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | | 364 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | |
1227 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); | 365 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); |
1228 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | | 366 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | |
1229 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 367 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1230 | break; | 368 | break; |
1231 | case 16: | 369 | case 16: |
1232 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 370 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1233 | PM3RD_PixelSize_16_BIT_PIXELS); | 371 | PM3RD_PixelSize_16_BIT_PIXELS); |
1234 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 372 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1235 | PM3RD_ColorFormat_565_FRONT_COLOR | | 373 | PM3RD_ColorFormat_565_FRONT_COLOR | |
1236 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | | 374 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | |
1237 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); | 375 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); |
@@ -1239,1936 +377,280 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1239 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 377 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1240 | break; | 378 | break; |
1241 | case 32: | 379 | case 32: |
1242 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 380 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1243 | PM3RD_PixelSize_32_BIT_PIXELS); | 381 | PM3RD_PixelSize_32_BIT_PIXELS); |
1244 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 382 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1245 | PM3RD_ColorFormat_8888_COLOR | | 383 | PM3RD_ColorFormat_8888_COLOR | |
1246 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); | 384 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); |
1247 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | | 385 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | |
1248 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 386 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1249 | break; | 387 | break; |
1250 | } | 388 | } |
1251 | PM3_WRITE_DAC_REG(PM3RD_MiscControl, tempmisc); | 389 | PM3_WRITE_DAC_REG(par, PM3RD_MiscControl, tempmisc); |
1252 | |||
1253 | PM3_SHOW_CUR_MODE; | ||
1254 | } | 390 | } |
1255 | 391 | ||
1256 | static void pm3fb_read_mode(struct pm3fb_info *l_fb_info, | 392 | /* |
1257 | struct pm3fb_par *curpar) | 393 | * hardware independent functions |
1258 | { | 394 | */ |
1259 | unsigned long pixsize1, pixsize2, clockused; | 395 | int pm3fb_init(void); |
1260 | unsigned long pre, feedback, post; | 396 | int pm3fb_setup(char*); |
1261 | |||
1262 | DTRACE; | ||
1263 | |||
1264 | clockused = PM3_READ_REG(PM3VClkCtl); | ||
1265 | 397 | ||
1266 | switch (clockused) { | 398 | static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
1267 | case 3: | 399 | { |
1268 | pre = PM3_READ_DAC_REG(PM3RD_DClk3PreScale); | 400 | u32 lpitch; |
1269 | feedback = PM3_READ_DAC_REG(PM3RD_DClk3FeedbackScale); | ||
1270 | post = PM3_READ_DAC_REG(PM3RD_DClk3PostScale); | ||
1271 | 401 | ||
1272 | DPRINTK(2, | 402 | var->transp.offset = 0; |
1273 | "DClk3 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 403 | var->transp.length = 0; |
1274 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | 404 | switch(var->bits_per_pixel) { |
1275 | feedback, | 405 | case 8: |
1276 | post)); | 406 | var->red.length = var->green.length = var->blue.length = 8; |
407 | var->red.offset = var->green.offset = var->blue.offset = 0; | ||
1277 | break; | 408 | break; |
1278 | case 2: | 409 | case 12: |
1279 | pre = PM3_READ_DAC_REG(PM3RD_DClk2PreScale); | 410 | var->red.offset = 8; |
1280 | feedback = PM3_READ_DAC_REG(PM3RD_DClk2FeedbackScale); | 411 | var->red.length = 4; |
1281 | post = PM3_READ_DAC_REG(PM3RD_DClk2PostScale); | 412 | var->green.offset = 4; |
1282 | 413 | var->green.length = 4; | |
1283 | DPRINTK(2, | 414 | var->blue.offset = 0; |
1284 | "DClk2 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 415 | var->blue.length = 4; |
1285 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | 416 | var->transp.offset = 12; |
1286 | feedback, | 417 | var->transp.length = 4; |
1287 | post)); | 418 | case 15: |
419 | var->red.offset = 10; | ||
420 | var->red.length = 5; | ||
421 | var->green.offset = 5; | ||
422 | var->green.length = 5; | ||
423 | var->blue.offset = 0; | ||
424 | var->blue.length = 5; | ||
425 | var->transp.offset = 15; | ||
426 | var->transp.length = 1; | ||
1288 | break; | 427 | break; |
1289 | case 1: | 428 | case 16: |
1290 | pre = PM3_READ_DAC_REG(PM3RD_DClk1PreScale); | 429 | var->red.offset = 11; |
1291 | feedback = PM3_READ_DAC_REG(PM3RD_DClk1FeedbackScale); | 430 | var->red.length = 5; |
1292 | post = PM3_READ_DAC_REG(PM3RD_DClk1PostScale); | 431 | var->green.offset = 5; |
1293 | 432 | var->green.length = 6; | |
1294 | DPRINTK(2, | 433 | var->blue.offset = 0; |
1295 | "DClk1 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 434 | var->blue.length = 5; |
1296 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | ||
1297 | feedback, | ||
1298 | post)); | ||
1299 | break; | 435 | break; |
1300 | case 0: | 436 | case 32: |
1301 | pre = PM3_READ_DAC_REG(PM3RD_DClk0PreScale); | 437 | var->transp.offset = 24; |
1302 | feedback = PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale); | 438 | var->transp.length = 8; |
1303 | post = PM3_READ_DAC_REG(PM3RD_DClk0PostScale); | 439 | var->red.offset = 16; |
1304 | 440 | var->green.offset = 8; | |
1305 | DPRINTK(2, | 441 | var->blue.offset = 0; |
1306 | "DClk0 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 442 | var->red.length = var->green.length = var->blue.length = 8; |
1307 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | ||
1308 | feedback, | ||
1309 | post)); | ||
1310 | break; | 443 | break; |
1311 | default: | 444 | default: |
1312 | pre = feedback = post = 0; | 445 | DPRINTK("depth not supported: %u\n", var->bits_per_pixel); |
1313 | DPRINTK(1, "Unknowk D clock used : %ld\n", clockused); | 446 | return -EINVAL; |
1314 | break; | ||
1315 | } | ||
1316 | |||
1317 | curpar->pixclock = PM3_SCALE_TO_CLOCK(pre, feedback, post); | ||
1318 | |||
1319 | pixsize1 = | ||
1320 | PM3ByApertureMode_PIXELSIZE_MASK & | ||
1321 | (PM3_READ_REG(PM3ByAperture1Mode)); | ||
1322 | pixsize2 = | ||
1323 | PM3ByApertureMode_PIXELSIZE_MASK & | ||
1324 | (PM3_READ_REG(PM3ByAperture2Mode)); | ||
1325 | |||
1326 | DASSERT((pixsize1 == pixsize2), | ||
1327 | "pixsize the same in both aperture\n"); | ||
1328 | |||
1329 | if (pixsize1 & PM3ByApertureMode_PIXELSIZE_32BIT) | ||
1330 | curpar->depth = 32; | ||
1331 | else if (pixsize1 & PM3ByApertureMode_PIXELSIZE_16BIT) | ||
1332 | { | ||
1333 | curpar->depth = 16; | ||
1334 | } | ||
1335 | else | ||
1336 | curpar->depth = 8; | ||
1337 | |||
1338 | /* not sure if I need to add one on the next ; it give better result with */ | ||
1339 | curpar->htotal = | ||
1340 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1341 | 1 + PM3_READ_REG(PM3HTotal)); | ||
1342 | curpar->hsend = | ||
1343 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1344 | PM3_READ_REG(PM3HsEnd)); | ||
1345 | curpar->hsstart = | ||
1346 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1347 | PM3_READ_REG(PM3HsStart)); | ||
1348 | curpar->hbend = | ||
1349 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1350 | PM3_READ_REG(PM3HbEnd)); | ||
1351 | |||
1352 | curpar->stride = | ||
1353 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1354 | PM3_READ_REG(PM3ScreenStride)); | ||
1355 | |||
1356 | curpar->vtotal = 1 + PM3_READ_REG(PM3VTotal); | ||
1357 | curpar->vsend = 1 + PM3_READ_REG(PM3VsEnd); | ||
1358 | curpar->vsstart = 1 + PM3_READ_REG(PM3VsStart); | ||
1359 | curpar->vbend = PM3_READ_REG(PM3VbEnd); | ||
1360 | |||
1361 | curpar->video = PM3_READ_REG(PM3VideoControl); | ||
1362 | |||
1363 | curpar->base = PM3_READ_REG(PM3ScreenBase); | ||
1364 | curpar->width = curpar->htotal - curpar->hbend; /* make virtual == displayed resolution */ | ||
1365 | curpar->height = curpar->vtotal - curpar->vbend; | ||
1366 | |||
1367 | DPRINTK(2, "Found : %d * %d, %d Khz, stride is %08x\n", | ||
1368 | curpar->width, curpar->height, curpar->pixclock, | ||
1369 | curpar->stride); | ||
1370 | } | ||
1371 | |||
1372 | static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info) | ||
1373 | { | ||
1374 | unsigned long memsize = 0, tempBypass, i, temp1, temp2; | ||
1375 | u16 subvendor, subdevice; | ||
1376 | pm3fb_timing_result ptr; | ||
1377 | |||
1378 | DTRACE; | ||
1379 | |||
1380 | l_fb_info->fb_size = 64 * 1024 * 1024; /* pm3 aperture always 64 MB */ | ||
1381 | pm3fb_mapIO(l_fb_info); /* temporary map IO */ | ||
1382 | |||
1383 | DASSERT((l_fb_info->vIOBase != NULL), | ||
1384 | "IO successfully mapped before mem detect\n"); | ||
1385 | DASSERT((l_fb_info->v_fb != NULL), | ||
1386 | "FB successfully mapped before mem detect\n"); | ||
1387 | |||
1388 | /* card-specific stuff, *before* accessing *any* FB memory */ | ||
1389 | if ((!pci_read_config_word | ||
1390 | (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor)) | ||
1391 | && | ||
1392 | (!pci_read_config_word | ||
1393 | (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) { | ||
1394 | i = 0; l_fb_info->board_type = 0; | ||
1395 | while ((cardbase[i].cardname[0]) && !(l_fb_info->board_type)) { | ||
1396 | if ((cardbase[i].subvendor == subvendor) && | ||
1397 | (cardbase[i].subdevice == subdevice) && | ||
1398 | (cardbase[i].func == PCI_FUNC(l_fb_info->dev->devfn))) { | ||
1399 | DPRINTK(2, "Card #%ld is an %s\n", | ||
1400 | l_fb_info->board_num, | ||
1401 | cardbase[i].cardname); | ||
1402 | if (cardbase[i].specific_setup) | ||
1403 | cardbase[i].specific_setup(l_fb_info); | ||
1404 | l_fb_info->board_type = i; | ||
1405 | } | ||
1406 | i++; | ||
1407 | } | ||
1408 | if (!l_fb_info->board_type) { | ||
1409 | DPRINTK(1, "Card #%ld is an unknown 0x%04x / 0x%04x\n", | ||
1410 | l_fb_info->board_num, subvendor, subdevice); | ||
1411 | } | ||
1412 | } else { | ||
1413 | printk(KERN_ERR "pm3fb: Error: pci_read_config_word failed, board #%ld\n", | ||
1414 | l_fb_info->board_num); | ||
1415 | } | ||
1416 | |||
1417 | if (printtimings) | ||
1418 | pm3fb_show_cur_timing(l_fb_info); | ||
1419 | |||
1420 | /* card-specific setup is done, we preserve the final | ||
1421 | memory timing for future reference */ | ||
1422 | if ((ptr = pm3fb_preserve_memory_timings(l_fb_info)) == pm3fb_timing_problem) { /* memory timings were wrong ! oops.... */ | ||
1423 | return(0); | ||
1424 | } | ||
1425 | |||
1426 | tempBypass = PM3_READ_REG(PM3MemBypassWriteMask); | ||
1427 | |||
1428 | DPRINTK(2, "PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass); | ||
1429 | |||
1430 | PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xFFFFFFFF); | ||
1431 | |||
1432 | /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */ | ||
1433 | for (i = 0; i < 32; i++) { | ||
1434 | fb_writel(i * 0x00345678, | ||
1435 | (l_fb_info->v_fb + (i * 1048576))); | ||
1436 | mb(); | ||
1437 | temp1 = fb_readl((l_fb_info->v_fb + (i * 1048576))); | ||
1438 | |||
1439 | /* Let's check for wrapover, write will fail at 16MB boundary */ | ||
1440 | if (temp1 == (i * 0x00345678)) | ||
1441 | memsize = i; | ||
1442 | else | ||
1443 | break; | ||
1444 | } | ||
1445 | |||
1446 | DPRINTK(2, "First detect pass already got %ld MB\n", memsize + 1); | ||
1447 | |||
1448 | if (memsize == i) { | ||
1449 | for (i = 0; i < 32; i++) { | ||
1450 | /* Clear first 32MB ; 0 is 0, no need to byteswap */ | ||
1451 | writel(0x0000000, | ||
1452 | (l_fb_info->v_fb + (i * 1048576))); | ||
1453 | mb(); | ||
1454 | } | ||
1455 | |||
1456 | for (i = 32; i < 64; i++) { | ||
1457 | fb_writel(i * 0x00345678, | ||
1458 | (l_fb_info->v_fb + (i * 1048576))); | ||
1459 | mb(); | ||
1460 | temp1 = | ||
1461 | fb_readl((l_fb_info->v_fb + (i * 1048576))); | ||
1462 | temp2 = | ||
1463 | fb_readl((l_fb_info->v_fb + | ||
1464 | ((i - 32) * 1048576))); | ||
1465 | if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) /* different value, different RAM... */ | ||
1466 | memsize = i; | ||
1467 | else | ||
1468 | break; | ||
1469 | } | ||
1470 | } | ||
1471 | |||
1472 | DPRINTK(2, "Second detect pass got %ld MB\n", memsize + 1); | ||
1473 | |||
1474 | PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, tempBypass); | ||
1475 | |||
1476 | pm3fb_unmapIO(l_fb_info); | ||
1477 | memsize = 1048576 * (memsize + 1); | ||
1478 | |||
1479 | DPRINTK(2, "Returning 0x%08lx bytes\n", memsize); | ||
1480 | |||
1481 | if (forcesize[l_fb_info->board_num] && ((forcesize[l_fb_info->board_num] * 1048576) != memsize)) | ||
1482 | { | ||
1483 | printk(KERN_WARNING "pm3fb: mismatch between probed (%ld MB) and specified (%hd MB) memory size, using SPECIFIED !\n", memsize, forcesize[l_fb_info->board_num]); | ||
1484 | memsize = 1048576 * forcesize[l_fb_info->board_num]; | ||
1485 | } | ||
1486 | |||
1487 | l_fb_info->fb_size = memsize; | ||
1488 | |||
1489 | if (ptr == pm3fb_timing_retry) | ||
1490 | { | ||
1491 | printk(KERN_WARNING "pm3fb: retrying memory timings check"); | ||
1492 | if (pm3fb_try_memory_timings(l_fb_info) == pm3fb_timing_problem) | ||
1493 | return(0); | ||
1494 | } | ||
1495 | |||
1496 | return (memsize); | ||
1497 | } | ||
1498 | |||
1499 | static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc) | ||
1500 | { | ||
1501 | int i; | ||
1502 | |||
1503 | DTRACE; | ||
1504 | |||
1505 | for (i = 0; i < (l_fb_info->fb_size / sizeof(u32)) ; i++) /* clear entire FB memory to black */ | ||
1506 | { | ||
1507 | fb_writel(cc, (l_fb_info->v_fb + (i * sizeof(u32)))); | ||
1508 | } | 447 | } |
1509 | } | 448 | var->height = var->width = -1; |
1510 | |||
1511 | static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b) | ||
1512 | { | ||
1513 | int i; | ||
1514 | |||
1515 | DTRACE; | ||
1516 | |||
1517 | for (i = 0; i < 256 ; i++) /* fill color map with white */ | ||
1518 | pm3fb_set_color(l_fb_info, i, r, g, b); | ||
1519 | |||
1520 | } | ||
1521 | |||
1522 | /* common initialisation */ | ||
1523 | static void pm3fb_common_init(struct pm3fb_info *l_fb_info) | ||
1524 | { | ||
1525 | DTRACE; | ||
1526 | |||
1527 | DPRINTK(2, "Initializing board #%ld @ %lx\n", l_fb_info->board_num, | ||
1528 | (unsigned long) l_fb_info); | ||
1529 | |||
1530 | strcpy(l_fb_info->gen.info.modename, permedia3_name); | ||
1531 | disp[l_fb_info->board_num].scrollmode = 0; /* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */ | ||
1532 | l_fb_info->gen.parsize = sizeof(struct pm3fb_par); | ||
1533 | l_fb_info->gen.info.changevar = NULL; | ||
1534 | l_fb_info->gen.info.fbops = &pm3fb_ops; | ||
1535 | l_fb_info->gen.info.disp = &(disp[l_fb_info->board_num]); | ||
1536 | if (fontn[l_fb_info->board_num][0]) | ||
1537 | strcpy(l_fb_info->gen.info.fontname, | ||
1538 | fontn[l_fb_info->board_num]); | ||
1539 | l_fb_info->gen.info.switch_con = &fbgen_switch; | ||
1540 | l_fb_info->gen.info.updatevar = &fbgen_update_var; /* */ | ||
1541 | l_fb_info->gen.info.flags = FBINFO_FLAG_DEFAULT; | ||
1542 | |||
1543 | pm3fb_mapIO(l_fb_info); | ||
1544 | |||
1545 | pm3fb_clear_memory(l_fb_info, 0); | ||
1546 | pm3fb_clear_colormap(l_fb_info, 0, 0, 0); | ||
1547 | |||
1548 | (void) fbgen_get_var(&(disp[l_fb_info->board_num]).var, -1, | ||
1549 | &l_fb_info->gen.info); | ||
1550 | 449 | ||
1551 | if (depth[l_fb_info->board_num]) /* override mode-defined depth */ | 450 | if (var->xres != var->xres_virtual) { |
1552 | { | 451 | DPRINTK("virtual x resolution != physical x resolution not supported\n"); |
1553 | pm3fb_encode_depth(&(disp[l_fb_info->board_num]).var, depth[l_fb_info->board_num]); | 452 | return -EINVAL; |
1554 | (disp[l_fb_info->board_num]).var.bits_per_pixel = depth2bpp(depth[l_fb_info->board_num]); | ||
1555 | } | 453 | } |
1556 | 454 | ||
1557 | (void) fbgen_do_set_var(&(disp[l_fb_info->board_num]).var, 1, | 455 | if (var->yres > var->yres_virtual) { |
1558 | &l_fb_info->gen); | 456 | DPRINTK("virtual y resolution < physical y resolution not possible\n"); |
1559 | 457 | return -EINVAL; | |
1560 | fbgen_set_disp(-1, &l_fb_info->gen); | ||
1561 | |||
1562 | do_install_cmap(0, &l_fb_info->gen.info); | ||
1563 | |||
1564 | if (register_framebuffer(&l_fb_info->gen.info) < 0) { | ||
1565 | DPRINTK(1, "Couldn't register framebuffer\n"); | ||
1566 | return; | ||
1567 | } | 458 | } |
1568 | 459 | ||
1569 | PM3_WRITE_DAC_REG(PM3RD_CursorMode, | 460 | if (var->xoffset) { |
1570 | PM3RD_CursorMode_CURSOR_DISABLE); | 461 | DPRINTK("xoffset not supported\n"); |
1571 | 462 | return -EINVAL; | |
1572 | PM3_SHOW_CUR_MODE; | ||
1573 | |||
1574 | pm3fb_write_mode(l_fb_info); | ||
1575 | |||
1576 | printk("fb%d: %s, using %uK of video memory (%s)\n", | ||
1577 | l_fb_info->gen.info.node, | ||
1578 | permedia3_name, (u32) (l_fb_info->fb_size >> 10), | ||
1579 | cardbase[l_fb_info->board_type].cardname); | ||
1580 | } | ||
1581 | |||
1582 | /* **************************************************** */ | ||
1583 | /* ***** accelerated permedia3-specific functions ***** */ | ||
1584 | /* **************************************************** */ | ||
1585 | #ifdef PM3FB_USE_ACCEL | ||
1586 | static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info) | ||
1587 | { | ||
1588 | DTRACE; | ||
1589 | |||
1590 | PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync); | ||
1591 | PM3_SLOW_WRITE_REG(PM3Sync, 0); | ||
1592 | mb(); | ||
1593 | do { | ||
1594 | while ((PM3_READ_REG(PM3OutFIFOWords)) == 0); | ||
1595 | rmb(); | ||
1596 | } while ((PM3_READ_REG(PM3OutputFifo)) != PM3Sync_Tag); | ||
1597 | } | ||
1598 | |||
1599 | static void pm3fb_init_engine(struct pm3fb_info *l_fb_info) | ||
1600 | { | ||
1601 | PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync); | ||
1602 | PM3_SLOW_WRITE_REG(PM3StatisticMode, 0x0); | ||
1603 | PM3_SLOW_WRITE_REG(PM3DeltaMode, 0x0); | ||
1604 | PM3_SLOW_WRITE_REG(PM3RasterizerMode, 0x0); | ||
1605 | PM3_SLOW_WRITE_REG(PM3ScissorMode, 0x0); | ||
1606 | PM3_SLOW_WRITE_REG(PM3LineStippleMode, 0x0); | ||
1607 | PM3_SLOW_WRITE_REG(PM3AreaStippleMode, 0x0); | ||
1608 | PM3_SLOW_WRITE_REG(PM3GIDMode, 0x0); | ||
1609 | PM3_SLOW_WRITE_REG(PM3DepthMode, 0x0); | ||
1610 | PM3_SLOW_WRITE_REG(PM3StencilMode, 0x0); | ||
1611 | PM3_SLOW_WRITE_REG(PM3StencilData, 0x0); | ||
1612 | PM3_SLOW_WRITE_REG(PM3ColorDDAMode, 0x0); | ||
1613 | PM3_SLOW_WRITE_REG(PM3TextureCoordMode, 0x0); | ||
1614 | PM3_SLOW_WRITE_REG(PM3TextureIndexMode0, 0x0); | ||
1615 | PM3_SLOW_WRITE_REG(PM3TextureIndexMode1, 0x0); | ||
1616 | PM3_SLOW_WRITE_REG(PM3TextureReadMode, 0x0); | ||
1617 | PM3_SLOW_WRITE_REG(PM3LUTMode, 0x0); | ||
1618 | PM3_SLOW_WRITE_REG(PM3TextureFilterMode, 0x0); | ||
1619 | PM3_SLOW_WRITE_REG(PM3TextureCompositeMode, 0x0); | ||
1620 | PM3_SLOW_WRITE_REG(PM3TextureApplicationMode, 0x0); | ||
1621 | PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode1, 0x0); | ||
1622 | PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode1, 0x0); | ||
1623 | PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode0, 0x0); | ||
1624 | PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode0, 0x0); | ||
1625 | PM3_SLOW_WRITE_REG(PM3FogMode, 0x0); | ||
1626 | PM3_SLOW_WRITE_REG(PM3ChromaTestMode, 0x0); | ||
1627 | PM3_SLOW_WRITE_REG(PM3AlphaTestMode, 0x0); | ||
1628 | PM3_SLOW_WRITE_REG(PM3AntialiasMode, 0x0); | ||
1629 | PM3_SLOW_WRITE_REG(PM3YUVMode, 0x0); | ||
1630 | PM3_SLOW_WRITE_REG(PM3AlphaBlendColorMode, 0x0); | ||
1631 | PM3_SLOW_WRITE_REG(PM3AlphaBlendAlphaMode, 0x0); | ||
1632 | PM3_SLOW_WRITE_REG(PM3DitherMode, 0x0); | ||
1633 | PM3_SLOW_WRITE_REG(PM3LogicalOpMode, 0x0); | ||
1634 | PM3_SLOW_WRITE_REG(PM3RouterMode, 0x0); | ||
1635 | PM3_SLOW_WRITE_REG(PM3Window, 0x0); | ||
1636 | |||
1637 | PM3_SLOW_WRITE_REG(PM3Config2D, 0x0); | ||
1638 | |||
1639 | PM3_SLOW_WRITE_REG(PM3SpanColorMask, 0xffffffff); | ||
1640 | |||
1641 | PM3_SLOW_WRITE_REG(PM3XBias, 0x0); | ||
1642 | PM3_SLOW_WRITE_REG(PM3YBias, 0x0); | ||
1643 | PM3_SLOW_WRITE_REG(PM3DeltaControl, 0x0); | ||
1644 | |||
1645 | PM3_SLOW_WRITE_REG(PM3BitMaskPattern, 0xffffffff); | ||
1646 | |||
1647 | PM3_SLOW_WRITE_REG(PM3FBDestReadEnables, | ||
1648 | PM3FBDestReadEnables_E(0xff) | | ||
1649 | PM3FBDestReadEnables_R(0xff) | | ||
1650 | PM3FBDestReadEnables_ReferenceAlpha(0xff)); | ||
1651 | PM3_SLOW_WRITE_REG(PM3FBDestReadBufferAddr0, 0x0); | ||
1652 | PM3_SLOW_WRITE_REG(PM3FBDestReadBufferOffset0, 0x0); | ||
1653 | PM3_SLOW_WRITE_REG(PM3FBDestReadBufferWidth0, | ||
1654 | PM3FBDestReadBufferWidth_Width(l_fb_info-> | ||
1655 | current_par-> | ||
1656 | width)); | ||
1657 | |||
1658 | PM3_SLOW_WRITE_REG(PM3FBDestReadMode, | ||
1659 | PM3FBDestReadMode_ReadEnable | | ||
1660 | PM3FBDestReadMode_Enable0); | ||
1661 | PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferAddr, 0x0); | ||
1662 | PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferOffset, 0x0); | ||
1663 | PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferWidth, | ||
1664 | PM3FBSourceReadBufferWidth_Width(l_fb_info-> | ||
1665 | current_par-> | ||
1666 | width)); | ||
1667 | PM3_SLOW_WRITE_REG(PM3FBSourceReadMode, | ||
1668 | PM3FBSourceReadMode_Blocking | | ||
1669 | PM3FBSourceReadMode_ReadEnable); | ||
1670 | |||
1671 | { | ||
1672 | unsigned long rm = 1; | ||
1673 | switch (l_fb_info->current_par->depth) { | ||
1674 | case 8: | ||
1675 | PM3_SLOW_WRITE_REG(PM3PixelSize, | ||
1676 | PM3PixelSize_GLOBAL_8BIT); | ||
1677 | break; | ||
1678 | case 12: | ||
1679 | case 15: | ||
1680 | case 16: | ||
1681 | PM3_SLOW_WRITE_REG(PM3PixelSize, | ||
1682 | PM3PixelSize_GLOBAL_16BIT); | ||
1683 | break; | ||
1684 | case 32: | ||
1685 | PM3_SLOW_WRITE_REG(PM3PixelSize, | ||
1686 | PM3PixelSize_GLOBAL_32BIT); | ||
1687 | break; | ||
1688 | default: | ||
1689 | DPRINTK(1, "Unsupported depth %d\n", | ||
1690 | l_fb_info->current_par->depth); | ||
1691 | break; | ||
1692 | } | ||
1693 | PM3_SLOW_WRITE_REG(PM3RasterizerMode, rm); | ||
1694 | } | 463 | } |
1695 | 464 | ||
1696 | PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xffffffff); | 465 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { |
1697 | PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xffffffff); | 466 | DPRINTK("interlace not supported\n"); |
1698 | PM3_SLOW_WRITE_REG(PM3FBWriteMode, | 467 | return -EINVAL; |
1699 | PM3FBWriteMode_WriteEnable | | ||
1700 | PM3FBWriteMode_OpaqueSpan | | ||
1701 | PM3FBWriteMode_Enable0); | ||
1702 | PM3_SLOW_WRITE_REG(PM3FBWriteBufferAddr0, 0x0); | ||
1703 | PM3_SLOW_WRITE_REG(PM3FBWriteBufferOffset0, 0x0); | ||
1704 | PM3_SLOW_WRITE_REG(PM3FBWriteBufferWidth0, | ||
1705 | PM3FBWriteBufferWidth_Width(l_fb_info-> | ||
1706 | current_par-> | ||
1707 | width)); | ||
1708 | |||
1709 | PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 0x0); | ||
1710 | { | ||
1711 | unsigned long sofb = (8UL * l_fb_info->fb_size) / | ||
1712 | ((depth2bpp(l_fb_info->current_par->depth)) | ||
1713 | * l_fb_info->current_par->width); /* size in lines of FB */ | ||
1714 | if (sofb > 4095) | ||
1715 | PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 4095); | ||
1716 | else | ||
1717 | PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, sofb); | ||
1718 | |||
1719 | switch (l_fb_info->current_par->depth) { | ||
1720 | case 8: | ||
1721 | PM3_SLOW_WRITE_REG(PM3DitherMode, | ||
1722 | (1 << 10) | (2 << 3)); | ||
1723 | break; | ||
1724 | case 12: | ||
1725 | case 15: | ||
1726 | case 16: | ||
1727 | PM3_SLOW_WRITE_REG(PM3DitherMode, | ||
1728 | (1 << 10) | (1 << 3)); | ||
1729 | break; | ||
1730 | case 32: | ||
1731 | PM3_SLOW_WRITE_REG(PM3DitherMode, | ||
1732 | (1 << 10) | (0 << 3)); | ||
1733 | break; | ||
1734 | default: | ||
1735 | DPRINTK(1, "Unsupported depth %d\n", | ||
1736 | l_fb_info->current_par->depth); | ||
1737 | break; | ||
1738 | } | ||
1739 | } | 468 | } |
1740 | 469 | ||
1741 | PM3_SLOW_WRITE_REG(PM3dXDom, 0x0); | 470 | var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */ |
1742 | PM3_SLOW_WRITE_REG(PM3dXSub, 0x0); | 471 | lpitch = var->xres * ((var->bits_per_pixel + 7)>>3); |
1743 | PM3_SLOW_WRITE_REG(PM3dY, (1 << 16)); | ||
1744 | PM3_SLOW_WRITE_REG(PM3StartXDom, 0x0); | ||
1745 | PM3_SLOW_WRITE_REG(PM3StartXSub, 0x0); | ||
1746 | PM3_SLOW_WRITE_REG(PM3StartY, 0x0); | ||
1747 | PM3_SLOW_WRITE_REG(PM3Count, 0x0); | ||
1748 | |||
1749 | /* Disable LocalBuffer. better safe than sorry */ | ||
1750 | PM3_SLOW_WRITE_REG(PM3LBDestReadMode, 0x0); | ||
1751 | PM3_SLOW_WRITE_REG(PM3LBDestReadEnables, 0x0); | ||
1752 | PM3_SLOW_WRITE_REG(PM3LBSourceReadMode, 0x0); | ||
1753 | PM3_SLOW_WRITE_REG(PM3LBWriteMode, 0x0); | ||
1754 | |||
1755 | pm3fb_wait_pm3(l_fb_info); | ||
1756 | } | ||
1757 | 472 | ||
1758 | #ifdef FBCON_HAS_CFB32 | 473 | if (var->xres < 200 || var->xres > 2048) { |
1759 | static void pm3fb_cfb32_clear(struct vc_data *conp, | 474 | DPRINTK("width not supported: %u\n", var->xres); |
1760 | struct display *p, | 475 | return -EINVAL; |
1761 | int sy, int sx, int height, int width) | ||
1762 | { | ||
1763 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1764 | u32 c; | ||
1765 | |||
1766 | DTRACE; | ||
1767 | |||
1768 | sx = sx * fontwidth(p); | ||
1769 | width = width * fontwidth(p); | ||
1770 | sy = sy * fontheight(p); | ||
1771 | height = height * fontheight(p); | ||
1772 | c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1773 | |||
1774 | /* block fills in 32bpp are hard, but in low res (width <= 1600 :-) | ||
1775 | we can use 16bpp operations, but not if NoWriteMask is on (SDRAM) */ | ||
1776 | if ((l_fb_info->current_par->width > 1600) || | ||
1777 | (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)) { | ||
1778 | PM3_WAIT(4); | ||
1779 | |||
1780 | PM3_WRITE_REG(PM3Config2D, | ||
1781 | PM3Config2D_UseConstantSource | | ||
1782 | PM3Config2D_ForegroundROPEnable | | ||
1783 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1784 | PM3Config2D_FBWriteEnable); | ||
1785 | |||
1786 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1787 | |||
1788 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1789 | (PM3RectanglePosition_XOffset(sx)) | | ||
1790 | (PM3RectanglePosition_YOffset(sy))); | ||
1791 | |||
1792 | PM3_WRITE_REG(PM3Render2D, | ||
1793 | PM3Render2D_XPositive | | ||
1794 | PM3Render2D_YPositive | | ||
1795 | PM3Render2D_Operation_Normal | | ||
1796 | PM3Render2D_SpanOperation | | ||
1797 | (PM3Render2D_Width(width)) | | ||
1798 | (PM3Render2D_Height(height))); | ||
1799 | } else { | ||
1800 | PM3_WAIT(8); | ||
1801 | |||
1802 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
1803 | |||
1804 | PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_16BIT); | ||
1805 | |||
1806 | PM3_WRITE_REG(PM3FBWriteBufferWidth0, | ||
1807 | PM3FBWriteBufferWidth_Width(l_fb_info-> | ||
1808 | current_par-> | ||
1809 | width << 1)); | ||
1810 | |||
1811 | PM3_WRITE_REG(PM3Config2D, | ||
1812 | PM3Config2D_UseConstantSource | | ||
1813 | PM3Config2D_ForegroundROPEnable | | ||
1814 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1815 | PM3Config2D_FBWriteEnable); | ||
1816 | |||
1817 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1818 | (PM3RectanglePosition_XOffset(sx << 1)) | | ||
1819 | (PM3RectanglePosition_YOffset(sy))); | ||
1820 | |||
1821 | PM3_WRITE_REG(PM3Render2D, | ||
1822 | PM3Render2D_XPositive | | ||
1823 | PM3Render2D_YPositive | | ||
1824 | PM3Render2D_Operation_Normal | | ||
1825 | (PM3Render2D_Width(width << 1)) | | ||
1826 | (PM3Render2D_Height(height))); | ||
1827 | |||
1828 | PM3_WRITE_REG(PM3FBWriteBufferWidth0, | ||
1829 | PM3FBWriteBufferWidth_Width(l_fb_info-> | ||
1830 | current_par-> | ||
1831 | width)); | ||
1832 | |||
1833 | PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_32BIT); | ||
1834 | } | 476 | } |
1835 | 477 | ||
1836 | pm3fb_wait_pm3(l_fb_info); | 478 | if (var->yres < 200 || var->yres > 4095) { |
1837 | } | 479 | DPRINTK("height not supported: %u\n", var->yres); |
1838 | 480 | return -EINVAL; | |
1839 | static void pm3fb_cfb32_clear_margins(struct vc_data *conp, | ||
1840 | struct display *p, int bottom_only) | ||
1841 | { | ||
1842 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1843 | int sx, sy; | ||
1844 | u32 c; | ||
1845 | |||
1846 | DTRACE; | ||
1847 | |||
1848 | sx = conp->vc_cols * fontwidth(p); /* right margin */ | ||
1849 | sy = conp->vc_rows * fontheight(p); /* bottom margin */ | ||
1850 | c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1851 | |||
1852 | if (!bottom_only) { /* right margin top->bottom */ | ||
1853 | PM3_WAIT(4); | ||
1854 | |||
1855 | PM3_WRITE_REG(PM3Config2D, | ||
1856 | PM3Config2D_UseConstantSource | | ||
1857 | PM3Config2D_ForegroundROPEnable | | ||
1858 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1859 | PM3Config2D_FBWriteEnable); | ||
1860 | |||
1861 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1862 | |||
1863 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1864 | (PM3RectanglePosition_XOffset | ||
1865 | (p->var.xoffset + | ||
1866 | sx)) | (PM3RectanglePosition_YOffset(p-> | ||
1867 | var. | ||
1868 | yoffset))); | ||
1869 | |||
1870 | PM3_WRITE_REG(PM3Render2D, | ||
1871 | PM3Render2D_XPositive | | ||
1872 | PM3Render2D_YPositive | | ||
1873 | PM3Render2D_Operation_Normal | | ||
1874 | PM3Render2D_SpanOperation | | ||
1875 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
1876 | (PM3Render2D_Height(p->var.yres))); | ||
1877 | } | 481 | } |
1878 | 482 | ||
1879 | /* bottom margin left -> right */ | 483 | if (lpitch * var->yres_virtual > info->fix.smem_len) { |
1880 | PM3_WAIT(4); | 484 | DPRINTK("no memory for screen (%ux%ux%u)\n", |
1881 | 485 | var->xres, var->yres_virtual, var->bits_per_pixel); | |
1882 | PM3_WRITE_REG(PM3Config2D, | 486 | return -EINVAL; |
1883 | PM3Config2D_UseConstantSource | | ||
1884 | PM3Config2D_ForegroundROPEnable | | ||
1885 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1886 | PM3Config2D_FBWriteEnable); | ||
1887 | |||
1888 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1889 | |||
1890 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1891 | (PM3RectanglePosition_XOffset(p->var.xoffset)) | | ||
1892 | (PM3RectanglePosition_YOffset(p->var.yoffset + sy))); | ||
1893 | |||
1894 | PM3_WRITE_REG(PM3Render2D, | ||
1895 | PM3Render2D_XPositive | | ||
1896 | PM3Render2D_YPositive | | ||
1897 | PM3Render2D_Operation_Normal | | ||
1898 | PM3Render2D_SpanOperation | | ||
1899 | (PM3Render2D_Width(p->var.xres)) | | ||
1900 | (PM3Render2D_Height(p->var.yres - sy))); | ||
1901 | |||
1902 | pm3fb_wait_pm3(l_fb_info); | ||
1903 | } | ||
1904 | #endif /* FBCON_HAS_CFB32 */ | ||
1905 | #ifdef FBCON_HAS_CFB16 | ||
1906 | static void pm3fb_cfb16_clear(struct vc_data *conp, | ||
1907 | struct display *p, | ||
1908 | int sy, int sx, int height, int width) | ||
1909 | { | ||
1910 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1911 | u32 c; | ||
1912 | |||
1913 | DTRACE; | ||
1914 | |||
1915 | sx = sx * fontwidth(p); | ||
1916 | width = width * fontwidth(p); | ||
1917 | sy = sy * fontheight(p); | ||
1918 | height = height * fontheight(p); | ||
1919 | c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1920 | c = c | (c << 16); | ||
1921 | |||
1922 | PM3_WAIT(4); | ||
1923 | |||
1924 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1925 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1926 | else | ||
1927 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
1928 | |||
1929 | PM3_WRITE_REG(PM3Config2D, | ||
1930 | PM3Config2D_UseConstantSource | | ||
1931 | PM3Config2D_ForegroundROPEnable | | ||
1932 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1933 | PM3Config2D_FBWriteEnable); | ||
1934 | |||
1935 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1936 | (PM3RectanglePosition_XOffset(sx)) | | ||
1937 | (PM3RectanglePosition_YOffset(sy))); | ||
1938 | |||
1939 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1940 | PM3_WRITE_REG(PM3Render2D, | ||
1941 | PM3Render2D_XPositive | | ||
1942 | PM3Render2D_YPositive | | ||
1943 | PM3Render2D_Operation_Normal | | ||
1944 | PM3Render2D_SpanOperation | | ||
1945 | (PM3Render2D_Width(width)) | | ||
1946 | (PM3Render2D_Height(height))); | ||
1947 | else | ||
1948 | PM3_WRITE_REG(PM3Render2D, | ||
1949 | PM3Render2D_XPositive | | ||
1950 | PM3Render2D_YPositive | | ||
1951 | PM3Render2D_Operation_Normal | | ||
1952 | (PM3Render2D_Width(width)) | | ||
1953 | (PM3Render2D_Height(height))); | ||
1954 | |||
1955 | pm3fb_wait_pm3(l_fb_info); | ||
1956 | } | ||
1957 | |||
1958 | static void pm3fb_cfb16_clear_margins(struct vc_data *conp, | ||
1959 | struct display *p, int bottom_only) | ||
1960 | { | ||
1961 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1962 | int sx, sy; | ||
1963 | u32 c; | ||
1964 | |||
1965 | DTRACE; | ||
1966 | |||
1967 | sx = conp->vc_cols * fontwidth(p); /* right margin */ | ||
1968 | sy = conp->vc_rows * fontheight(p); /* bottom margin */ | ||
1969 | c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1970 | c = c | (c << 16); | ||
1971 | |||
1972 | if (!bottom_only) { /* right margin top->bottom */ | ||
1973 | PM3_WAIT(4); | ||
1974 | |||
1975 | PM3_WRITE_REG(PM3Config2D, | ||
1976 | PM3Config2D_UseConstantSource | | ||
1977 | PM3Config2D_ForegroundROPEnable | | ||
1978 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1979 | PM3Config2D_FBWriteEnable); | ||
1980 | |||
1981 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1982 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1983 | else | ||
1984 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
1985 | |||
1986 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1987 | (PM3RectanglePosition_XOffset | ||
1988 | (p->var.xoffset + | ||
1989 | sx)) | (PM3RectanglePosition_YOffset(p-> | ||
1990 | var. | ||
1991 | yoffset))); | ||
1992 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1993 | PM3_WRITE_REG(PM3Render2D, | ||
1994 | PM3Render2D_XPositive | | ||
1995 | PM3Render2D_YPositive | | ||
1996 | PM3Render2D_Operation_Normal | | ||
1997 | PM3Render2D_SpanOperation | | ||
1998 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
1999 | (PM3Render2D_Height(p->var.yres))); | ||
2000 | else | ||
2001 | PM3_WRITE_REG(PM3Render2D, | ||
2002 | PM3Render2D_XPositive | | ||
2003 | PM3Render2D_YPositive | | ||
2004 | PM3Render2D_Operation_Normal | | ||
2005 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
2006 | (PM3Render2D_Height(p->var.yres))); | ||
2007 | } | 487 | } |
2008 | |||
2009 | /* bottom margin left -> right */ | ||
2010 | PM3_WAIT(4); | ||
2011 | |||
2012 | PM3_WRITE_REG(PM3Config2D, | ||
2013 | PM3Config2D_UseConstantSource | | ||
2014 | PM3Config2D_ForegroundROPEnable | | ||
2015 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2016 | PM3Config2D_FBWriteEnable); | ||
2017 | |||
2018 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2019 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2020 | else | ||
2021 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
2022 | |||
2023 | |||
2024 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2025 | (PM3RectanglePosition_XOffset(p->var.xoffset)) | | ||
2026 | (PM3RectanglePosition_YOffset(p->var.yoffset + sy))); | ||
2027 | |||
2028 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2029 | PM3_WRITE_REG(PM3Render2D, | ||
2030 | PM3Render2D_XPositive | | ||
2031 | PM3Render2D_YPositive | | ||
2032 | PM3Render2D_Operation_Normal | | ||
2033 | PM3Render2D_SpanOperation | | ||
2034 | (PM3Render2D_Width(p->var.xres)) | | ||
2035 | (PM3Render2D_Height(p->var.yres - sy))); | ||
2036 | else | ||
2037 | PM3_WRITE_REG(PM3Render2D, | ||
2038 | PM3Render2D_XPositive | | ||
2039 | PM3Render2D_YPositive | | ||
2040 | PM3Render2D_Operation_Normal | | ||
2041 | (PM3Render2D_Width(p->var.xres)) | | ||
2042 | (PM3Render2D_Height(p->var.yres - sy))); | ||
2043 | |||
2044 | pm3fb_wait_pm3(l_fb_info); | ||
2045 | } | ||
2046 | #endif /* FBCON_HAS_CFB16 */ | ||
2047 | #ifdef FBCON_HAS_CFB8 | ||
2048 | static void pm3fb_cfb8_clear(struct vc_data *conp, | ||
2049 | struct display *p, | ||
2050 | int sy, int sx, int height, int width) | ||
2051 | { | ||
2052 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2053 | u32 c; | ||
2054 | |||
2055 | DTRACE; | ||
2056 | |||
2057 | sx = sx * fontwidth(p); | ||
2058 | width = width * fontwidth(p); | ||
2059 | sy = sy * fontheight(p); | ||
2060 | height = height * fontheight(p); | ||
2061 | |||
2062 | c = attr_bgcol_ec(p, conp); | ||
2063 | c |= c << 8; | ||
2064 | c |= c << 16; | ||
2065 | 488 | ||
2066 | PM3_WAIT(4); | 489 | if (PICOS2KHZ(var->pixclock) > PM3_MAX_PIXCLOCK) { |
2067 | 490 | DPRINTK("pixclock too high (%ldKHz)\n", PICOS2KHZ(var->pixclock)); | |
2068 | PM3_WRITE_REG(PM3Config2D, | 491 | return -EINVAL; |
2069 | PM3Config2D_UseConstantSource | | ||
2070 | PM3Config2D_ForegroundROPEnable | | ||
2071 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2072 | PM3Config2D_FBWriteEnable); | ||
2073 | |||
2074 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2075 | |||
2076 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2077 | (PM3RectanglePosition_XOffset(sx)) | | ||
2078 | (PM3RectanglePosition_YOffset(sy))); | ||
2079 | |||
2080 | PM3_WRITE_REG(PM3Render2D, | ||
2081 | PM3Render2D_XPositive | | ||
2082 | PM3Render2D_YPositive | | ||
2083 | PM3Render2D_Operation_Normal | | ||
2084 | PM3Render2D_SpanOperation | | ||
2085 | (PM3Render2D_Width(width)) | | ||
2086 | (PM3Render2D_Height(height))); | ||
2087 | |||
2088 | pm3fb_wait_pm3(l_fb_info); | ||
2089 | } | ||
2090 | |||
2091 | static void pm3fb_cfb8_clear_margins(struct vc_data *conp, | ||
2092 | struct display *p, int bottom_only) | ||
2093 | { | ||
2094 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2095 | int sx, sy; | ||
2096 | u32 c; | ||
2097 | |||
2098 | DTRACE; | ||
2099 | |||
2100 | sx = conp->vc_cols * fontwidth(p); /* right margin */ | ||
2101 | sy = conp->vc_rows * fontheight(p); /* bottom margin */ | ||
2102 | c = attr_bgcol_ec(p, conp); | ||
2103 | c |= c << 8; | ||
2104 | c |= c << 16; | ||
2105 | |||
2106 | if (!bottom_only) { /* right margin top->bottom */ | ||
2107 | PM3_WAIT(4); | ||
2108 | |||
2109 | PM3_WRITE_REG(PM3Config2D, | ||
2110 | PM3Config2D_UseConstantSource | | ||
2111 | PM3Config2D_ForegroundROPEnable | | ||
2112 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2113 | PM3Config2D_FBWriteEnable); | ||
2114 | |||
2115 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2116 | |||
2117 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2118 | (PM3RectanglePosition_XOffset | ||
2119 | (p->var.xoffset + | ||
2120 | sx)) | (PM3RectanglePosition_YOffset(p-> | ||
2121 | var. | ||
2122 | yoffset))); | ||
2123 | |||
2124 | PM3_WRITE_REG(PM3Render2D, | ||
2125 | PM3Render2D_XPositive | | ||
2126 | PM3Render2D_YPositive | | ||
2127 | PM3Render2D_Operation_Normal | | ||
2128 | PM3Render2D_SpanOperation | | ||
2129 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
2130 | (PM3Render2D_Height(p->var.yres))); | ||
2131 | } | 492 | } |
2132 | 493 | ||
2133 | /* bottom margin left -> right */ | 494 | var->accel_flags = 0; /* Can't mmap if this is on */ |
2134 | PM3_WAIT(4); | ||
2135 | |||
2136 | PM3_WRITE_REG(PM3Config2D, | ||
2137 | PM3Config2D_UseConstantSource | | ||
2138 | PM3Config2D_ForegroundROPEnable | | ||
2139 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2140 | PM3Config2D_FBWriteEnable); | ||
2141 | |||
2142 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2143 | 495 | ||
2144 | PM3_WRITE_REG(PM3RectanglePosition, | 496 | DPRINTK("Checking graphics mode at %dx%d depth %d\n", |
2145 | (PM3RectanglePosition_XOffset(p->var.xoffset)) | | 497 | var->xres, var->yres, var->bits_per_pixel); |
2146 | (PM3RectanglePosition_YOffset(p->var.yoffset + sy))); | 498 | return 0; |
2147 | |||
2148 | PM3_WRITE_REG(PM3Render2D, | ||
2149 | PM3Render2D_XPositive | | ||
2150 | PM3Render2D_YPositive | | ||
2151 | PM3Render2D_Operation_Normal | | ||
2152 | PM3Render2D_SpanOperation | | ||
2153 | (PM3Render2D_Width(p->var.xres)) | | ||
2154 | (PM3Render2D_Height(p->var.yres - sy))); | ||
2155 | |||
2156 | pm3fb_wait_pm3(l_fb_info); | ||
2157 | } | ||
2158 | #endif /* FBCON_HAS_CFB8 */ | ||
2159 | #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32) | ||
2160 | static void pm3fb_cfbX_bmove(struct display *p, | ||
2161 | int sy, int sx, | ||
2162 | int dy, int dx, int height, int width) | ||
2163 | { | ||
2164 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2165 | int x_align, o_x, o_y; | ||
2166 | |||
2167 | DTRACE; | ||
2168 | |||
2169 | sx = sx * fontwidth(p); | ||
2170 | dx = dx * fontwidth(p); | ||
2171 | width = width * fontwidth(p); | ||
2172 | sy = sy * fontheight(p); | ||
2173 | dy = dy * fontheight(p); | ||
2174 | height = height * fontheight(p); | ||
2175 | |||
2176 | o_x = sx - dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */ | ||
2177 | o_y = sy - dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */ | ||
2178 | |||
2179 | x_align = (sx & 0x1f); | ||
2180 | |||
2181 | PM3_WAIT(6); | ||
2182 | |||
2183 | PM3_WRITE_REG(PM3Config2D, | ||
2184 | PM3Config2D_UserScissorEnable | | ||
2185 | PM3Config2D_ForegroundROPEnable | | ||
2186 | PM3Config2D_Blocking | | ||
2187 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2188 | PM3Config2D_FBWriteEnable); | ||
2189 | |||
2190 | PM3_WRITE_REG(PM3ScissorMinXY, | ||
2191 | ((dy & 0x0fff) << 16) | (dx & 0x0fff)); | ||
2192 | PM3_WRITE_REG(PM3ScissorMaxXY, | ||
2193 | (((dy + height) & 0x0fff) << 16) | | ||
2194 | ((dx + width) & 0x0fff)); | ||
2195 | |||
2196 | PM3_WRITE_REG(PM3FBSourceReadBufferOffset, | ||
2197 | PM3FBSourceReadBufferOffset_XOffset(o_x) | | ||
2198 | PM3FBSourceReadBufferOffset_YOffset(o_y)); | ||
2199 | |||
2200 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2201 | (PM3RectanglePosition_XOffset(dx - x_align)) | | ||
2202 | (PM3RectanglePosition_YOffset(dy))); | ||
2203 | |||
2204 | PM3_WRITE_REG(PM3Render2D, | ||
2205 | ((sx > dx) ? PM3Render2D_XPositive : 0) | | ||
2206 | ((sy > dy) ? PM3Render2D_YPositive : 0) | | ||
2207 | PM3Render2D_Operation_Normal | | ||
2208 | PM3Render2D_SpanOperation | | ||
2209 | PM3Render2D_FBSourceReadEnable | | ||
2210 | (PM3Render2D_Width(width + x_align)) | | ||
2211 | (PM3Render2D_Height(height))); | ||
2212 | |||
2213 | pm3fb_wait_pm3(l_fb_info); | ||
2214 | } | 499 | } |
2215 | 500 | ||
2216 | static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p, | 501 | static int pm3fb_set_par(struct fb_info *info) |
2217 | int c, int yy, int xx) | ||
2218 | { | 502 | { |
2219 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | 503 | struct pm3_par *par = info->par; |
2220 | u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0; | 504 | const u32 xres = (info->var.xres + 31) & ~31; |
2221 | u32 fgx, bgx, ldat; | 505 | const int depth = (info->var.bits_per_pixel + 7) & ~7; |
2222 | int sx, sy, i; | ||
2223 | |||
2224 | DTRACE; | ||
2225 | |||
2226 | if (l_fb_info->current_par->depth == 8) | ||
2227 | fgx = attr_fgcol(p, c); | ||
2228 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2229 | fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, c)]; | ||
2230 | else | ||
2231 | fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, c)]; | ||
2232 | |||
2233 | PM3_COLOR(fgx); | ||
2234 | |||
2235 | if (l_fb_info->current_par->depth == 8) | ||
2236 | bgx = attr_bgcol(p, c); | ||
2237 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2238 | bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, c)]; | ||
2239 | else | ||
2240 | bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, c)]; | ||
2241 | |||
2242 | PM3_COLOR(bgx); | ||
2243 | |||
2244 | PM3_WAIT(4); | ||
2245 | |||
2246 | PM3_WRITE_REG(PM3Config2D, | ||
2247 | PM3Config2D_UseConstantSource | | ||
2248 | PM3Config2D_ForegroundROPEnable | | ||
2249 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2250 | PM3Config2D_FBWriteEnable | PM3Config2D_OpaqueSpan); | ||
2251 | |||
2252 | PM3_WRITE_REG(PM3ForegroundColor, fgx); | ||
2253 | PM3_WRITE_REG(PM3FillBackgroundColor, bgx); | ||
2254 | |||
2255 | /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */ | ||
2256 | /* and 16 bits for fontwidth <= 16 */ | ||
2257 | /* same in _putcs, same for Y and fontheight */ | ||
2258 | if (fontwidth(p) <= 8) | ||
2259 | asx = 2; | ||
2260 | else if (fontwidth(p) <= 16) | ||
2261 | asx = 3; /* look OK */ | ||
2262 | if (fontheight(p) <= 8) | ||
2263 | asy = 2; | ||
2264 | else if (fontheight(p) <= 16) | ||
2265 | asy = 3; /* look OK */ | ||
2266 | else if (fontheight(p) <= 32) | ||
2267 | asy = 4; /* look OK */ | ||
2268 | |||
2269 | sx = xx * fontwidth(p); | ||
2270 | sy = yy * fontheight(p); | ||
2271 | |||
2272 | if (fontwidth(p) <= 8) | ||
2273 | o_x = (8 - (sx & 0x7)) & 0x7; | ||
2274 | else if (fontwidth(p) <= 16) | ||
2275 | o_x = (16 - (sx & 0xF)) & 0xF; | ||
2276 | if (fontheight(p) <= 8) | ||
2277 | o_y = (8 - (sy & 0x7)) & 0x7; | ||
2278 | else if (fontheight(p) <= 16) | ||
2279 | o_y = (16 - (sy & 0xF)) & 0xF; | ||
2280 | else if (fontheight(p) <= 32) | ||
2281 | o_y = (32 - (sy & 0x1F)) & 0x1F; | ||
2282 | |||
2283 | PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */ | ||
2284 | (1 << 18) | /* BE */ | ||
2285 | 1 | (asx << 1) | (asy << 4) | /* address select x/y */ | ||
2286 | (1 << 20)); /* OpaqueSpan */ | ||
2287 | |||
2288 | if (fontwidth(p) <= 8) { | ||
2289 | cdat = p->fontdata + (c & p->charmask) * fontheight(p); | ||
2290 | } else { | ||
2291 | cdat = | ||
2292 | p->fontdata + | ||
2293 | ((c & p->charmask) * (fontheight(p) << 1)); | ||
2294 | } | ||
2295 | |||
2296 | PM3_WAIT(2 + fontheight(p)); | ||
2297 | |||
2298 | for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */ | ||
2299 | if (fontwidth(p) <= 8) { | ||
2300 | ldat = *cdat++; | ||
2301 | } else { /* assume fontwidth <= 16 ATM */ | ||
2302 | |||
2303 | ldat = ((*cdat++) << 8); | ||
2304 | ldat |= *cdat++; | ||
2305 | } | ||
2306 | PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat); | ||
2307 | } | ||
2308 | 506 | ||
2309 | PM3_WRITE_REG(PM3RectanglePosition, | 507 | par->base = pm3fb_shift_bpp(info->var.bits_per_pixel, |
2310 | (PM3RectanglePosition_XOffset(sx)) | | 508 | (info->var.yoffset * xres) |
2311 | (PM3RectanglePosition_YOffset(sy))); | 509 | + info->var.xoffset); |
510 | par->video = 0; | ||
2312 | 511 | ||
2313 | PM3_WRITE_REG(PM3Render2D, | 512 | if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) |
2314 | PM3Render2D_AreaStippleEnable | | 513 | par->video |= PM3VideoControl_HSYNC_ACTIVE_HIGH; |
2315 | PM3Render2D_XPositive | | ||
2316 | PM3Render2D_YPositive | | ||
2317 | PM3Render2D_Operation_Normal | | ||
2318 | PM3Render2D_SpanOperation | | ||
2319 | (PM3Render2D_Width(fontwidth(p))) | | ||
2320 | (PM3Render2D_Height(fontheight(p)))); | ||
2321 | |||
2322 | pm3fb_wait_pm3(l_fb_info); | ||
2323 | } | ||
2324 | |||
2325 | static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p, | ||
2326 | const unsigned short *s, int count, int yy, | ||
2327 | int xx) | ||
2328 | { | ||
2329 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2330 | u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0; | ||
2331 | u32 fgx, bgx, ldat; | ||
2332 | int sx, sy, i, j; | ||
2333 | u16 sc; | ||
2334 | |||
2335 | DTRACE; | ||
2336 | |||
2337 | sc = scr_readw(s); | ||
2338 | if (l_fb_info->current_par->depth == 8) | ||
2339 | fgx = attr_fgcol(p, sc); | ||
2340 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2341 | fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, sc)]; | ||
2342 | else | ||
2343 | fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, sc)]; | ||
2344 | |||
2345 | PM3_COLOR(fgx); | ||
2346 | |||
2347 | if (l_fb_info->current_par->depth == 8) | ||
2348 | bgx = attr_bgcol(p, sc); | ||
2349 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2350 | bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, sc)]; | ||
2351 | else | 514 | else |
2352 | bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, sc)]; | 515 | par->video |= PM3VideoControl_HSYNC_ACTIVE_LOW; |
2353 | |||
2354 | PM3_COLOR(bgx); | ||
2355 | |||
2356 | PM3_WAIT(4); | ||
2357 | |||
2358 | PM3_WRITE_REG(PM3Config2D, | ||
2359 | PM3Config2D_UseConstantSource | | ||
2360 | PM3Config2D_ForegroundROPEnable | | ||
2361 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2362 | PM3Config2D_FBWriteEnable | | ||
2363 | PM3Config2D_OpaqueSpan); | ||
2364 | |||
2365 | PM3_WRITE_REG(PM3ForegroundColor, fgx); | ||
2366 | PM3_WRITE_REG(PM3FillBackgroundColor, bgx); | ||
2367 | |||
2368 | /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */ | ||
2369 | /* and 16 bits for fontwidth <= 16 */ | ||
2370 | /* same in _putc, same for Y and fontheight */ | ||
2371 | if (fontwidth(p) <= 8) | ||
2372 | asx = 2; | ||
2373 | else if (fontwidth(p) <= 16) | ||
2374 | asx = 3; /* look OK */ | ||
2375 | if (fontheight(p) <= 8) | ||
2376 | asy = 2; | ||
2377 | else if (fontheight(p) <= 16) | ||
2378 | asy = 3; /* look OK */ | ||
2379 | else if (fontheight(p) <= 32) | ||
2380 | asy = 4; /* look OK */ | ||
2381 | |||
2382 | sy = yy * fontheight(p); | ||
2383 | |||
2384 | if (fontheight(p) <= 8) | ||
2385 | o_y = (8 - (sy & 0x7)) & 0x7; | ||
2386 | else if (fontheight(p) <= 16) | ||
2387 | o_y = (16 - (sy & 0xF)) & 0xF; | ||
2388 | else if (fontheight(p) <= 32) | ||
2389 | o_y = (32 - (sy & 0x1F)) & 0x1F; | ||
2390 | |||
2391 | for (j = 0; j < count; j++) { | ||
2392 | sc = scr_readw(s + j); | ||
2393 | if (fontwidth(p) <= 8) | ||
2394 | cdat = p->fontdata + | ||
2395 | (sc & p->charmask) * fontheight(p); | ||
2396 | else | ||
2397 | cdat = p->fontdata + | ||
2398 | ((sc & p->charmask) * fontheight(p) << 1); | ||
2399 | |||
2400 | sx = (xx + j) * fontwidth(p); | ||
2401 | |||
2402 | if (fontwidth(p) <= 8) | ||
2403 | o_x = (8 - (sx & 0x7)) & 0x7; | ||
2404 | else if (fontwidth(p) <= 16) | ||
2405 | o_x = (16 - (sx & 0xF)) & 0xF; | ||
2406 | |||
2407 | PM3_WAIT(3 + fontheight(p)); | ||
2408 | |||
2409 | PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */ | ||
2410 | (1 << 18) | /* BE */ | ||
2411 | 1 | (asx << 1) | (asy << 4) | /* address select x/y */ | ||
2412 | (1 << 20)); /* OpaqueSpan */ | ||
2413 | |||
2414 | for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */ | ||
2415 | if (fontwidth(p) <= 8) { | ||
2416 | ldat = *cdat++; | ||
2417 | } else { /* assume fontwidth <= 16 ATM */ | ||
2418 | ldat = ((*cdat++) << 8); | ||
2419 | ldat |= *cdat++; | ||
2420 | } | ||
2421 | PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat); | ||
2422 | } | ||
2423 | |||
2424 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2425 | (PM3RectanglePosition_XOffset(sx)) | | ||
2426 | (PM3RectanglePosition_YOffset(sy))); | ||
2427 | |||
2428 | PM3_WRITE_REG(PM3Render2D, | ||
2429 | PM3Render2D_AreaStippleEnable | | ||
2430 | PM3Render2D_XPositive | | ||
2431 | PM3Render2D_YPositive | | ||
2432 | PM3Render2D_Operation_Normal | | ||
2433 | PM3Render2D_SpanOperation | | ||
2434 | (PM3Render2D_Width(fontwidth(p))) | | ||
2435 | (PM3Render2D_Height(fontheight(p)))); | ||
2436 | } | ||
2437 | pm3fb_wait_pm3(l_fb_info); | ||
2438 | } | ||
2439 | |||
2440 | static void pm3fb_cfbX_revc(struct display *p, int xx, int yy) | ||
2441 | { | ||
2442 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2443 | |||
2444 | xx = xx * fontwidth(p); | ||
2445 | yy = yy * fontheight(p); | ||
2446 | |||
2447 | if (l_fb_info->current_par->depth == 8) | ||
2448 | { | ||
2449 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2450 | PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0x0F0F0F0F); | ||
2451 | else | ||
2452 | PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0x0F0F0F0F); | ||
2453 | } | ||
2454 | |||
2455 | PM3_WAIT(3); | ||
2456 | |||
2457 | PM3_WRITE_REG(PM3Config2D, | ||
2458 | PM3Config2D_UseConstantSource | | ||
2459 | PM3Config2D_ForegroundROPEnable | | ||
2460 | (PM3Config2D_ForegroundROP(0xa)) | /* Oxa is GXinvert */ | ||
2461 | PM3Config2D_FBDestReadEnable | | ||
2462 | PM3Config2D_FBWriteEnable); | ||
2463 | |||
2464 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2465 | (PM3RectanglePosition_XOffset(xx)) | | ||
2466 | (PM3RectanglePosition_YOffset(yy))); | ||
2467 | |||
2468 | PM3_WRITE_REG(PM3Render2D, | ||
2469 | PM3Render2D_XPositive | | ||
2470 | PM3Render2D_YPositive | | ||
2471 | PM3Render2D_Operation_Normal | | ||
2472 | PM3Render2D_SpanOperation | | ||
2473 | (PM3Render2D_Width(fontwidth(p))) | | ||
2474 | (PM3Render2D_Height(fontheight(p)))); | ||
2475 | |||
2476 | pm3fb_wait_pm3(l_fb_info); | ||
2477 | |||
2478 | if (l_fb_info->current_par->depth == 8) | ||
2479 | { | ||
2480 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2481 | PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xFFFFFFFF); | ||
2482 | else | ||
2483 | PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xFFFFFFFF); | ||
2484 | } | ||
2485 | } | ||
2486 | |||
2487 | #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */ | ||
2488 | #endif /* PM3FB_USE_ACCEL */ | ||
2489 | /* *********************************** */ | ||
2490 | /* ***** pre-init board(s) setup ***** */ | ||
2491 | /* *********************************** */ | ||
2492 | |||
2493 | static void pm3fb_mode_setup(char *mode, unsigned long board_num) | ||
2494 | { | ||
2495 | struct pm3fb_info *l_fb_info = &(fb_info[board_num]); | ||
2496 | struct pm3fb_par *l_fb_par = &(current_par[board_num]); | ||
2497 | unsigned long i = 0; | ||
2498 | |||
2499 | current_par_valid[board_num] = 0; | ||
2500 | |||
2501 | if (!strncmp(mode, "current", 7)) { | ||
2502 | l_fb_info->use_current = 1; /* default w/ OpenFirmware */ | ||
2503 | } else { | ||
2504 | while ((mode_base[i].name[0]) | ||
2505 | && (!current_par_valid[board_num])) { | ||
2506 | if (! | ||
2507 | (strncmp | ||
2508 | (mode, mode_base[i].name, | ||
2509 | strlen(mode_base[i].name)))) { | ||
2510 | memcpy(l_fb_par, &(mode_base[i].user_mode), | ||
2511 | sizeof(struct pm3fb_par)); | ||
2512 | current_par_valid[board_num] = 1; | ||
2513 | DPRINTK(2, "Mode set to %s\n", | ||
2514 | mode_base[i].name); | ||
2515 | } | ||
2516 | i++; | ||
2517 | } | ||
2518 | DASSERT(current_par_valid[board_num], | ||
2519 | "Valid mode on command line\n"); | ||
2520 | } | ||
2521 | } | ||
2522 | |||
2523 | static void pm3fb_pciid_setup(char *pciid, unsigned long board_num) | ||
2524 | { | ||
2525 | short l_bus = -1, l_slot = -1, l_func = -1; | ||
2526 | char *next; | ||
2527 | |||
2528 | if (pciid) { | ||
2529 | l_bus = simple_strtoul(pciid, &next, 10); | ||
2530 | if (next && (next[0] == ':')) { | ||
2531 | pciid = next + 1; | ||
2532 | l_slot = simple_strtoul(pciid, &next, 10); | ||
2533 | if (next && (next[0] == ':')) { | ||
2534 | pciid = next + 1; | ||
2535 | l_func = | ||
2536 | simple_strtoul(pciid, (char **) NULL, | ||
2537 | 10); | ||
2538 | } | ||
2539 | } | ||
2540 | } else | ||
2541 | return; | ||
2542 | |||
2543 | if ((l_bus >= 0) && (l_slot >= 0) && (l_func >= 0)) { | ||
2544 | bus[board_num] = l_bus; | ||
2545 | slot[board_num] = l_slot; | ||
2546 | func[board_num] = l_func; | ||
2547 | DPRINTK(2, "Board #%ld will be PciId: %hd:%hd:%hd\n", | ||
2548 | board_num, l_bus, l_slot, l_func); | ||
2549 | } else { | ||
2550 | DPRINTK(1, "Invalid PciId: %hd:%hd:%hd for board #%ld\n", | ||
2551 | l_bus, l_slot, l_func, board_num); | ||
2552 | } | ||
2553 | } | ||
2554 | |||
2555 | static void pm3fb_font_setup(char *lf, unsigned long board_num) | ||
2556 | { | ||
2557 | unsigned long lfs = strlen(lf); | ||
2558 | |||
2559 | if (lfs > (PM3_FONTNAME_SIZE - 1)) { | ||
2560 | DPRINTK(1, "Fontname %s too long\n", lf); | ||
2561 | return; | ||
2562 | } | ||
2563 | strlcpy(fontn[board_num], lf, lfs + 1); | ||
2564 | } | ||
2565 | |||
2566 | static void pm3fb_bootdepth_setup(char *bds, unsigned long board_num) | ||
2567 | { | ||
2568 | unsigned long bd = simple_strtoul(bds, (char **) NULL, 10); | ||
2569 | |||
2570 | if (!(depth_supported(bd))) { | ||
2571 | printk(KERN_WARNING "pm3fb: ignoring invalid depth %s for board #%ld\n", | ||
2572 | bds, board_num); | ||
2573 | return; | ||
2574 | } | ||
2575 | depth[board_num] = bd; | ||
2576 | } | ||
2577 | |||
2578 | static void pm3fb_forcesize_setup(char *bds, unsigned long board_num) | ||
2579 | { | ||
2580 | unsigned long bd = simple_strtoul(bds, (char **) NULL, 10); | ||
2581 | |||
2582 | if (bd > 64) { | ||
2583 | printk(KERN_WARNING "pm3fb: ignoring invalid memory size %s for board #%ld\n", | ||
2584 | bds, board_num); | ||
2585 | return; | ||
2586 | } | ||
2587 | forcesize[board_num] = bd; | ||
2588 | } | ||
2589 | |||
2590 | static char *pm3fb_boardnum_setup(char *options, unsigned long *bn) | ||
2591 | { | ||
2592 | char *next; | ||
2593 | |||
2594 | if (!(isdigit(options[0]))) { | ||
2595 | (*bn) = 0; | ||
2596 | return (options); | ||
2597 | } | ||
2598 | |||
2599 | (*bn) = simple_strtoul(options, &next, 10); | ||
2600 | 516 | ||
2601 | if (next && (next[0] == ':') && ((*bn) >= 0) | 517 | if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) |
2602 | && ((*bn) <= PM3_MAX_BOARD)) { | 518 | par->video |= PM3VideoControl_VSYNC_ACTIVE_HIGH; |
2603 | DPRINTK(2, "Board_num seen as %ld\n", (*bn)); | ||
2604 | return (next + 1); | ||
2605 | } else { | ||
2606 | (*bn) = 0; | ||
2607 | DPRINTK(2, "Board_num default to %ld\n", (*bn)); | ||
2608 | return (options); | ||
2609 | } | ||
2610 | } | ||
2611 | |||
2612 | static void pm3fb_real_setup(char *options) | ||
2613 | { | ||
2614 | char *next; | ||
2615 | unsigned long i, bn; | ||
2616 | struct pm3fb_info *l_fb_info; | ||
2617 | |||
2618 | DTRACE; | ||
2619 | |||
2620 | DPRINTK(2, "Options : %s\n", options); | ||
2621 | |||
2622 | for (i = 0; i < PM3_MAX_BOARD; i++) { | ||
2623 | l_fb_info = &(fb_info[i]); | ||
2624 | memset(l_fb_info, 0, sizeof(struct pm3fb_info)); | ||
2625 | l_fb_info->gen.fbhw = &pm3fb_switch; | ||
2626 | l_fb_info->board_num = i; | ||
2627 | current_par_valid[i] = 0; | ||
2628 | slot[i] = -1; | ||
2629 | func[i] = -1; | ||
2630 | bus[i] = -1; | ||
2631 | disable[i] = 0; | ||
2632 | noaccel[i] = 0; | ||
2633 | fontn[i][0] = '\0'; | ||
2634 | depth[i] = 0; | ||
2635 | l_fb_info->current_par = &(current_par[i]); | ||
2636 | } | ||
2637 | |||
2638 | /* eat up prefix pm3fb and whatever is used as separator i.e. :,= */ | ||
2639 | if (!strncmp(options, "pm3fb", 5)) { | ||
2640 | options += 5; | ||
2641 | while (((*options) == ',') || ((*options) == ':') | ||
2642 | || ((*options) == '=')) | ||
2643 | options++; | ||
2644 | } | ||
2645 | |||
2646 | while (options) { | ||
2647 | bn = 0; | ||
2648 | if ((next = strchr(options, ','))) { | ||
2649 | (*next) = '\0'; | ||
2650 | next++; | ||
2651 | } | ||
2652 | |||
2653 | if (!strncmp(options, "mode:", 5)) { | ||
2654 | options = pm3fb_boardnum_setup(options + 5, &bn); | ||
2655 | DPRINTK(2, "Setting mode for board #%ld\n", bn); | ||
2656 | pm3fb_mode_setup(options, bn); | ||
2657 | } else if (!strncmp(options, "off:", 4)) { | ||
2658 | options = pm3fb_boardnum_setup(options + 4, &bn); | ||
2659 | DPRINTK(2, "Disabling board #%ld\n", bn); | ||
2660 | disable[bn] = 1; | ||
2661 | } else if (!strncmp(options, "off", 3)) { /* disable everything */ | ||
2662 | for (i = 0; i < PM3_MAX_BOARD; i++) | ||
2663 | disable[i] = 1; | ||
2664 | } else if (!strncmp(options, "disable:", 8)) { | ||
2665 | options = pm3fb_boardnum_setup(options + 8, &bn); | ||
2666 | DPRINTK(2, "Disabling board #%ld\n", bn); | ||
2667 | disable[bn] = 1; | ||
2668 | } else if (!strncmp(options, "pciid:", 6)) { | ||
2669 | options = pm3fb_boardnum_setup(options + 6, &bn); | ||
2670 | DPRINTK(2, "Setting PciID for board #%ld\n", bn); | ||
2671 | pm3fb_pciid_setup(options, bn); | ||
2672 | } else if (!strncmp(options, "noaccel:", 8)) { | ||
2673 | options = pm3fb_boardnum_setup(options + 8, &bn); | ||
2674 | noaccel[bn] = 1; | ||
2675 | } else if (!strncmp(options, "font:", 5)) { | ||
2676 | options = pm3fb_boardnum_setup(options + 5, &bn); | ||
2677 | pm3fb_font_setup(options, bn); | ||
2678 | } else if (!strncmp(options, "depth:", 6)) { | ||
2679 | options = pm3fb_boardnum_setup(options + 6, &bn); | ||
2680 | pm3fb_bootdepth_setup(options, bn); | ||
2681 | } else if (!strncmp(options, "printtimings", 12)) { | ||
2682 | printtimings = 1; | ||
2683 | } else if (!strncmp(options, "flatpanel:", 10)) { | ||
2684 | options = pm3fb_boardnum_setup(options + 10, &bn); | ||
2685 | flatpanel[bn] = 1; | ||
2686 | } else if (!strncmp(options, "forcesize:", 10)) { | ||
2687 | options = pm3fb_boardnum_setup(options + 10, &bn); | ||
2688 | pm3fb_forcesize_setup(options, bn); | ||
2689 | } | ||
2690 | options = next; | ||
2691 | } | ||
2692 | } | ||
2693 | |||
2694 | /* ********************************************** */ | ||
2695 | /* ***** framebuffer API standard functions ***** */ | ||
2696 | /* ********************************************** */ | ||
2697 | |||
2698 | static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix, | ||
2699 | const void *par, struct fb_info_gen *info) | ||
2700 | { | ||
2701 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
2702 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
2703 | |||
2704 | DTRACE; | ||
2705 | |||
2706 | strcpy(fix->id, permedia3_name); | ||
2707 | fix->smem_start = (unsigned long)l_fb_info->p_fb; | ||
2708 | fix->smem_len = l_fb_info->fb_size; | ||
2709 | fix->mmio_start = (unsigned long)l_fb_info->pIOBase; | ||
2710 | fix->mmio_len = PM3_REGS_SIZE; | ||
2711 | #ifdef PM3FB_USE_ACCEL | ||
2712 | if (!(noaccel[l_fb_info->board_num])) | ||
2713 | fix->accel = FB_ACCEL_3DLABS_PERMEDIA3; | ||
2714 | else | ||
2715 | #endif /* PM3FB_USE_ACCEL */ | ||
2716 | fix->accel = FB_ACCEL_NONE; | ||
2717 | fix->type = FB_TYPE_PACKED_PIXELS; | ||
2718 | fix->visual = | ||
2719 | (p->depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; | ||
2720 | if (current_par_valid[l_fb_info->board_num]) | ||
2721 | fix->line_length = | ||
2722 | l_fb_info->current_par->width * | ||
2723 | depth2ByPP(l_fb_info->current_par->depth); | ||
2724 | else | 519 | else |
2725 | fix->line_length = 0; | 520 | par->video |= PM3VideoControl_VSYNC_ACTIVE_LOW; |
2726 | fix->xpanstep = 64 / depth2bpp(p->depth); | ||
2727 | fix->ypanstep = 1; | ||
2728 | fix->ywrapstep = 0; | ||
2729 | return (0); | ||
2730 | } | ||
2731 | |||
2732 | static int pm3fb_decode_var(const struct fb_var_screeninfo *var, | ||
2733 | void *par, struct fb_info_gen *info) | ||
2734 | { | ||
2735 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
2736 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
2737 | struct pm3fb_par temp_p; | ||
2738 | u32 xres; | ||
2739 | |||
2740 | DTRACE; | ||
2741 | |||
2742 | DASSERT((var != NULL), "fb_var_screeninfo* not NULL"); | ||
2743 | DASSERT((p != NULL), "pm3fb_par* not NULL"); | ||
2744 | DASSERT((l_fb_info != NULL), "pm3fb_info* not NULL"); | ||
2745 | 521 | ||
2746 | memset(&temp_p, 0, sizeof(struct pm3fb_par)); | 522 | if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) |
2747 | temp_p.width = (var->xres_virtual + 7) & ~7; | 523 | par->video |= PM3VideoControl_LINE_DOUBLE_ON; |
2748 | temp_p.height = var->yres_virtual; | ||
2749 | |||
2750 | if (!(depth_supported(var->bits_per_pixel))) /* round unsupported up to a multiple of 8 */ | ||
2751 | temp_p.depth = depth2bpp(var->bits_per_pixel); | ||
2752 | else | 524 | else |
2753 | temp_p.depth = var->bits_per_pixel; | 525 | par->video |= PM3VideoControl_LINE_DOUBLE_OFF; |
2754 | |||
2755 | temp_p.depth = (temp_p.depth > 32) ? 32 : temp_p.depth; /* max 32 */ | ||
2756 | temp_p.depth = (temp_p.depth == 24) ? 32 : temp_p.depth; /* 24 unsupported, round-up to 32 */ | ||
2757 | |||
2758 | if ((temp_p.depth == 16) && (var->red.length == 5) && (var->green.length == 5) && (var->blue.length == 5)) | ||
2759 | temp_p.depth = 15; /* RGBA 5551 is stored as depth 15 */ | ||
2760 | |||
2761 | if ((temp_p.depth == 16) && (var->red.length == 4) && (var->green.length == 4) && (var->blue.length == 4)) | ||
2762 | temp_p.depth = 12; /* RGBA 4444 is stored as depth 12 */ | ||
2763 | |||
2764 | |||
2765 | DPRINTK(2, | ||
2766 | "xres: %d, yres: %d, vxres: %d, vyres: %d ; xoffset:%d, yoffset: %d\n", | ||
2767 | var->xres, var->yres, var->xres_virtual, var->yres_virtual, | ||
2768 | var->xoffset, var->yoffset); | ||
2769 | |||
2770 | xres = (var->xres + 31) & ~31; | ||
2771 | if (temp_p.width < xres + var->xoffset) | ||
2772 | temp_p.width = xres + var->xoffset; | ||
2773 | if (temp_p.height < var->yres + var->yoffset) | ||
2774 | temp_p.height = var->yres + var->yoffset; | ||
2775 | |||
2776 | if (temp_p.width > 2048) { | ||
2777 | DPRINTK(1, "virtual width not supported: %u\n", | ||
2778 | temp_p.width); | ||
2779 | return (-EINVAL); | ||
2780 | } | ||
2781 | if (var->yres < 200) { | ||
2782 | DPRINTK(1, "height not supported: %u\n", (u32) var->yres); | ||
2783 | return (-EINVAL); | ||
2784 | } | ||
2785 | if (temp_p.height < 200 || temp_p.height > 4095) { | ||
2786 | DPRINTK(1, "virtual height not supported: %u\n", | ||
2787 | temp_p.height); | ||
2788 | return (-EINVAL); | ||
2789 | } | ||
2790 | if (!(depth_supported(temp_p.depth))) { | ||
2791 | DPRINTK(1, "depth not supported: %u\n", temp_p.depth); | ||
2792 | return (-EINVAL); | ||
2793 | } | ||
2794 | if ((temp_p.width * temp_p.height * depth2ByPP(temp_p.depth)) > | ||
2795 | l_fb_info->fb_size) { | ||
2796 | DPRINTK(1, "no memory for screen (%ux%ux%u)\n", | ||
2797 | temp_p.width, temp_p.height, temp_p.depth); | ||
2798 | return (-EINVAL); | ||
2799 | } | ||
2800 | |||
2801 | if ((!var->pixclock) || | ||
2802 | (!var->right_margin) || | ||
2803 | (!var->hsync_len) || | ||
2804 | (!var->left_margin) || | ||
2805 | (!var->lower_margin) || | ||
2806 | (!var->vsync_len) || (!var->upper_margin) | ||
2807 | ) { | ||
2808 | unsigned long i = 0, done = 0; | ||
2809 | printk(KERN_WARNING "pm3fb: refusing to use a likely wrong timing\n"); | ||
2810 | |||
2811 | while ((mode_base[i].user_mode.width) && !done) { | ||
2812 | if ((mode_base[i].user_mode.width == temp_p.width) | ||
2813 | && (mode_base[i].user_mode.height == | ||
2814 | temp_p.height)) { | ||
2815 | printk(KERN_NOTICE "pm3fb: using close match %s\n", | ||
2816 | mode_base[i].name); | ||
2817 | temp_p = mode_base[i].user_mode; | ||
2818 | done = 1; | ||
2819 | } | ||
2820 | i++; | ||
2821 | } | ||
2822 | if (!done) | ||
2823 | return (-EINVAL); | ||
2824 | } else { | ||
2825 | temp_p.pixclock = PICOS2KHZ(var->pixclock); | ||
2826 | if (temp_p.pixclock > PM3_MAX_PIXCLOCK) { | ||
2827 | DPRINTK(1, "pixclock too high (%uKHz)\n", | ||
2828 | temp_p.pixclock); | ||
2829 | return (-EINVAL); | ||
2830 | } | ||
2831 | |||
2832 | temp_p.hsstart = var->right_margin; | ||
2833 | temp_p.hsend = var->right_margin + var->hsync_len; | ||
2834 | temp_p.hbend = | ||
2835 | var->right_margin + var->hsync_len + var->left_margin; | ||
2836 | temp_p.htotal = xres + temp_p.hbend; | ||
2837 | |||
2838 | temp_p.vsstart = var->lower_margin; | ||
2839 | temp_p.vsend = var->lower_margin + var->vsync_len; | ||
2840 | temp_p.vbend = | ||
2841 | var->lower_margin + var->vsync_len + var->upper_margin; | ||
2842 | temp_p.vtotal = var->yres + temp_p.vbend; | ||
2843 | |||
2844 | temp_p.stride = temp_p.width; | ||
2845 | |||
2846 | DPRINTK(2, "Using %d * %d, %d Khz, stride is %08x\n", | ||
2847 | temp_p.width, temp_p.height, temp_p.pixclock, | ||
2848 | temp_p.stride); | ||
2849 | |||
2850 | temp_p.base = | ||
2851 | pm3fb_Shiftbpp(l_fb_info, temp_p.depth, | ||
2852 | (var->yoffset * xres) + var->xoffset); | ||
2853 | 526 | ||
2854 | temp_p.video = 0; | 527 | if (info->var.activate == FB_ACTIVATE_NOW) |
2855 | 528 | par->video |= PM3VideoControl_ENABLE; | |
2856 | if (var->sync & FB_SYNC_HOR_HIGH_ACT) | 529 | else { |
2857 | temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_HIGH; | 530 | par->video |= PM3VideoControl_DISABLE; |
2858 | else | 531 | DPRINTK("PM3Video disabled\n"); |
2859 | temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_LOW; | ||
2860 | |||
2861 | if (var->sync & FB_SYNC_VERT_HIGH_ACT) | ||
2862 | temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_HIGH; | ||
2863 | else | ||
2864 | temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_LOW; | ||
2865 | |||
2866 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { | ||
2867 | DPRINTK(1, "Interlaced mode not supported\n\n"); | ||
2868 | return (-EINVAL); | ||
2869 | } | ||
2870 | |||
2871 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) | ||
2872 | temp_p.video |= PM3VideoControl_LINE_DOUBLE_ON; | ||
2873 | else | ||
2874 | temp_p.video |= PM3VideoControl_LINE_DOUBLE_OFF; | ||
2875 | |||
2876 | if (var->activate == FB_ACTIVATE_NOW) | ||
2877 | temp_p.video |= PM3VideoControl_ENABLE; | ||
2878 | else { | ||
2879 | temp_p.video |= PM3VideoControl_DISABLE; | ||
2880 | DPRINTK(2, "PM3Video disabled\n"); | ||
2881 | } | ||
2882 | |||
2883 | switch (temp_p.depth) { | ||
2884 | case 8: | ||
2885 | temp_p.video |= PM3VideoControl_PIXELSIZE_8BIT; | ||
2886 | break; | ||
2887 | case 12: | ||
2888 | case 15: | ||
2889 | case 16: | ||
2890 | temp_p.video |= PM3VideoControl_PIXELSIZE_16BIT; | ||
2891 | break; | ||
2892 | case 32: | ||
2893 | temp_p.video |= PM3VideoControl_PIXELSIZE_32BIT; | ||
2894 | break; | ||
2895 | default: | ||
2896 | DPRINTK(1, "Unsupported depth\n"); | ||
2897 | break; | ||
2898 | } | ||
2899 | } | 532 | } |
2900 | (*p) = temp_p; | 533 | switch (depth) { |
2901 | |||
2902 | #ifdef PM3FB_USE_ACCEL | ||
2903 | if (var->accel_flags & FB_ACCELF_TEXT) | ||
2904 | noaccel[l_fb_info->board_num] = 0; | ||
2905 | else | ||
2906 | noaccel[l_fb_info->board_num] = 1; | ||
2907 | #endif /* PM3FB_USE_ACCEL */ | ||
2908 | |||
2909 | return (0); | ||
2910 | } | ||
2911 | |||
2912 | static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d) | ||
2913 | { | ||
2914 | switch (d) { | ||
2915 | case 8: | 534 | case 8: |
2916 | var->red.length = var->green.length = var->blue.length = 8; | 535 | par->video |= PM3VideoControl_PIXELSIZE_8BIT; |
2917 | var->red.offset = var->green.offset = var->blue.offset = 0; | ||
2918 | var->transp.offset = var->transp.length = 0; | ||
2919 | break; | 536 | break; |
2920 | |||
2921 | case 12: | 537 | case 12: |
2922 | var->red.offset = 8; | ||
2923 | var->red.length = 4; | ||
2924 | var->green.offset = 4; | ||
2925 | var->green.length = 4; | ||
2926 | var->blue.offset = 0; | ||
2927 | var->blue.length = 4; | ||
2928 | var->transp.offset = 12; | ||
2929 | var->transp.length = 4; | ||
2930 | break; | ||
2931 | |||
2932 | case 15: | 538 | case 15: |
2933 | var->red.offset = 10; | ||
2934 | var->red.length = 5; | ||
2935 | var->green.offset = 5; | ||
2936 | var->green.length = 5; | ||
2937 | var->blue.offset = 0; | ||
2938 | var->blue.length = 5; | ||
2939 | var->transp.offset = 15; | ||
2940 | var->transp.length = 1; | ||
2941 | break; | ||
2942 | |||
2943 | case 16: | 539 | case 16: |
2944 | var->red.offset = 11; | 540 | par->video |= PM3VideoControl_PIXELSIZE_16BIT; |
2945 | var->red.length = 5; | ||
2946 | var->green.offset = 5; | ||
2947 | var->green.length = 6; | ||
2948 | var->blue.offset = 0; | ||
2949 | var->blue.length = 5; | ||
2950 | var->transp.offset = var->transp.length = 0; | ||
2951 | break; | 541 | break; |
2952 | |||
2953 | case 32: | 542 | case 32: |
2954 | var->transp.offset = 24; | 543 | par->video |= PM3VideoControl_PIXELSIZE_32BIT; |
2955 | var->red.offset = 16; | ||
2956 | var->green.offset = 8; | ||
2957 | var->blue.offset = 0; | ||
2958 | var->red.length = var->green.length = | ||
2959 | var->blue.length = var->transp.length = 8; | ||
2960 | break; | 544 | break; |
2961 | |||
2962 | default: | 545 | default: |
2963 | DPRINTK(1, "Unsupported depth %ld\n", d); | 546 | DPRINTK("Unsupported depth\n"); |
2964 | break; | 547 | break; |
2965 | } | 548 | } |
2966 | } | ||
2967 | |||
2968 | static int pm3fb_encode_var(struct fb_var_screeninfo *var, | ||
2969 | const void *par, struct fb_info_gen *info) | ||
2970 | { | ||
2971 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
2972 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
2973 | |||
2974 | u32 base; | ||
2975 | |||
2976 | DTRACE; | ||
2977 | |||
2978 | DASSERT((var != NULL), "fb_var_screeninfo* not NULL"); | ||
2979 | DASSERT((p != NULL), "pm3fb_par* not NULL"); | ||
2980 | DASSERT((info != NULL), "fb_info_gen* not NULL"); | ||
2981 | |||
2982 | memset(var, 0, sizeof(struct fb_var_screeninfo)); | ||
2983 | |||
2984 | #ifdef PM3FB_USE_ACCEL | ||
2985 | if (!(noaccel[l_fb_info->board_num])) | ||
2986 | var->accel_flags |= FB_ACCELF_TEXT; | ||
2987 | #endif /* PM3FB_USE_ACCEL */ | ||
2988 | |||
2989 | var->xres_virtual = p->width; | ||
2990 | var->yres_virtual = p->height; | ||
2991 | var->xres = p->htotal - p->hbend; | ||
2992 | var->yres = p->vtotal - p->vbend; | ||
2993 | |||
2994 | DPRINTK(2, "xres = %d, yres : %d\n", var->xres, var->yres); | ||
2995 | |||
2996 | var->right_margin = p->hsstart; | ||
2997 | var->hsync_len = p->hsend - p->hsstart; | ||
2998 | var->left_margin = p->hbend - p->hsend; | ||
2999 | var->lower_margin = p->vsstart; | ||
3000 | var->vsync_len = p->vsend - p->vsstart; | ||
3001 | var->upper_margin = p->vbend - p->vsend; | ||
3002 | var->bits_per_pixel = depth2bpp(p->depth); | ||
3003 | |||
3004 | pm3fb_encode_depth(var, p->depth); | ||
3005 | |||
3006 | base = pm3fb_Unshiftbpp(l_fb_info, p->depth, p->base); | ||
3007 | |||
3008 | var->xoffset = base % var->xres; | ||
3009 | var->yoffset = base / var->xres; | ||
3010 | |||
3011 | var->height = var->width = -1; | ||
3012 | |||
3013 | var->pixclock = KHZ2PICOS(p->pixclock); | ||
3014 | |||
3015 | if ((p->video & PM3VideoControl_HSYNC_MASK) == | ||
3016 | PM3VideoControl_HSYNC_ACTIVE_HIGH) | ||
3017 | var->sync |= FB_SYNC_HOR_HIGH_ACT; | ||
3018 | if ((p->video & PM3VideoControl_VSYNC_MASK) == | ||
3019 | PM3VideoControl_VSYNC_ACTIVE_HIGH) | ||
3020 | var->sync |= FB_SYNC_VERT_HIGH_ACT; | ||
3021 | if (p->video & PM3VideoControl_LINE_DOUBLE_ON) | ||
3022 | var->vmode = FB_VMODE_DOUBLE; | ||
3023 | |||
3024 | return (0); | ||
3025 | } | ||
3026 | |||
3027 | static void pm3fb_get_par(void *par, struct fb_info_gen *info) | ||
3028 | { | ||
3029 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3030 | |||
3031 | DTRACE; | ||
3032 | |||
3033 | if (!current_par_valid[l_fb_info->board_num]) { | ||
3034 | if (l_fb_info->use_current) | ||
3035 | pm3fb_read_mode(l_fb_info, l_fb_info->current_par); | ||
3036 | else | ||
3037 | memcpy(l_fb_info->current_par, | ||
3038 | &(mode_base[0].user_mode), | ||
3039 | sizeof(struct pm3fb_par)); | ||
3040 | current_par_valid[l_fb_info->board_num] = 1; | ||
3041 | } | ||
3042 | *((struct pm3fb_par *) par) = *(l_fb_info->current_par); | ||
3043 | } | ||
3044 | |||
3045 | static void pm3fb_set_par(const void *par, struct fb_info_gen *info) | ||
3046 | { | ||
3047 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3048 | |||
3049 | DTRACE; | ||
3050 | 549 | ||
3051 | *(l_fb_info->current_par) = *((struct pm3fb_par *) par); | 550 | info->fix.visual = |
3052 | current_par_valid[l_fb_info->board_num] = 1; | 551 | (depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
552 | info->fix.line_length = ((info->var.xres_virtual + 7) & ~7) | ||
553 | * depth / 8; | ||
3053 | 554 | ||
3054 | pm3fb_write_mode(l_fb_info); | 555 | /* pm3fb_clear_memory(info, 0);*/ |
3055 | 556 | pm3fb_clear_colormap(par, 0, 0, 0); | |
3056 | #ifdef PM3FB_USE_ACCEL | 557 | PM3_WRITE_DAC_REG(par, PM3RD_CursorMode, |
3057 | pm3fb_init_engine(l_fb_info); | 558 | PM3RD_CursorMode_CURSOR_DISABLE); |
3058 | #endif /* PM3FB_USE_ACCEL */ | 559 | pm3fb_write_mode(info); |
3059 | } | 560 | return 0; |
3060 | |||
3061 | static void pm3fb_set_color(struct pm3fb_info *l_fb_info, | ||
3062 | unsigned char regno, unsigned char r, | ||
3063 | unsigned char g, unsigned char b) | ||
3064 | { | ||
3065 | DTRACE; | ||
3066 | |||
3067 | PM3_SLOW_WRITE_REG(PM3RD_PaletteWriteAddress, regno); | ||
3068 | PM3_SLOW_WRITE_REG(PM3RD_PaletteData, r); | ||
3069 | PM3_SLOW_WRITE_REG(PM3RD_PaletteData, g); | ||
3070 | PM3_SLOW_WRITE_REG(PM3RD_PaletteData, b); | ||
3071 | } | ||
3072 | |||
3073 | static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green, | ||
3074 | unsigned *blue, unsigned *transp, | ||
3075 | struct fb_info *info) | ||
3076 | { | ||
3077 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3078 | |||
3079 | DTRACE; | ||
3080 | |||
3081 | if (regno < 256) { | ||
3082 | *red = | ||
3083 | l_fb_info->palette[regno].red << 8 | l_fb_info-> | ||
3084 | palette[regno].red; | ||
3085 | *green = | ||
3086 | l_fb_info->palette[regno].green << 8 | l_fb_info-> | ||
3087 | palette[regno].green; | ||
3088 | *blue = | ||
3089 | l_fb_info->palette[regno].blue << 8 | l_fb_info-> | ||
3090 | palette[regno].blue; | ||
3091 | *transp = | ||
3092 | l_fb_info->palette[regno].transp << 8 | l_fb_info-> | ||
3093 | palette[regno].transp; | ||
3094 | } | ||
3095 | return (regno > 255); | ||
3096 | } | 561 | } |
3097 | 562 | ||
3098 | static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, | 563 | static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, |
3099 | unsigned blue, unsigned transp, | 564 | unsigned blue, unsigned transp, |
3100 | struct fb_info *info) | 565 | struct fb_info *info) |
3101 | { | 566 | { |
3102 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | 567 | struct pm3_par *par = info->par; |
3103 | 568 | ||
3104 | DTRACE; | 569 | if (regno >= 256) /* no. of hw registers */ |
570 | return -EINVAL; | ||
571 | |||
572 | /* grayscale works only partially under directcolor */ | ||
573 | if (info->var.grayscale) { | ||
574 | /* grayscale = 0.30*R + 0.59*G + 0.11*B */ | ||
575 | red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; | ||
576 | } | ||
577 | |||
578 | /* Directcolor: | ||
579 | * var->{color}.offset contains start of bitfield | ||
580 | * var->{color}.length contains length of bitfield | ||
581 | * {hardwarespecific} contains width of DAC | ||
582 | * pseudo_palette[X] is programmed to (X << red.offset) | | ||
583 | * (X << green.offset) | | ||
584 | * (X << blue.offset) | ||
585 | * RAMDAC[X] is programmed to (red, green, blue) | ||
586 | * color depth = SUM(var->{color}.length) | ||
587 | * | ||
588 | * Pseudocolor: | ||
589 | * var->{color}.offset is 0 | ||
590 | * var->{color}.length contains width of DAC or the number of unique | ||
591 | * colors available (color depth) | ||
592 | * pseudo_palette is not used | ||
593 | * RAMDAC[X] is programmed to (red, green, blue) | ||
594 | * color depth = var->{color}.length | ||
595 | */ | ||
3105 | 596 | ||
3106 | if (regno < 16) { | 597 | /* |
3107 | switch (l_fb_info->current_par->depth) { | 598 | * This is the point where the color is converted to something that |
3108 | #ifdef FBCON_HAS_CFB8 | 599 | * is acceptable by the hardware. |
600 | */ | ||
601 | #define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16) | ||
602 | red = CNVT_TOHW(red, info->var.red.length); | ||
603 | green = CNVT_TOHW(green, info->var.green.length); | ||
604 | blue = CNVT_TOHW(blue, info->var.blue.length); | ||
605 | transp = CNVT_TOHW(transp, info->var.transp.length); | ||
606 | #undef CNVT_TOHW | ||
607 | |||
608 | if (info->fix.visual == FB_VISUAL_TRUECOLOR || | ||
609 | info->fix.visual == FB_VISUAL_DIRECTCOLOR) { | ||
610 | u32 v; | ||
611 | |||
612 | if (regno >= 16) | ||
613 | return -EINVAL; | ||
614 | |||
615 | v = (red << info->var.red.offset) | | ||
616 | (green << info->var.green.offset) | | ||
617 | (blue << info->var.blue.offset) | | ||
618 | (transp << info->var.transp.offset); | ||
619 | |||
620 | switch (info->var.bits_per_pixel) { | ||
3109 | case 8: | 621 | case 8: |
3110 | break; | 622 | break; |
3111 | #endif | ||
3112 | #ifdef FBCON_HAS_CFB16 | ||
3113 | case 12: | ||
3114 | l_fb_info->cmap.cmap12[regno] = | ||
3115 | (((u32) red & 0xf000) >> 4) | | ||
3116 | (((u32) green & 0xf000) >> 8) | | ||
3117 | (((u32) blue & 0xf000) >> 12); | ||
3118 | break; | ||
3119 | |||
3120 | case 15: | ||
3121 | l_fb_info->cmap.cmap15[regno] = | ||
3122 | (((u32) red & 0xf800) >> 1) | | ||
3123 | (((u32) green & 0xf800) >> 6) | | ||
3124 | (((u32) blue & 0xf800) >> 11); | ||
3125 | break; | ||
3126 | |||
3127 | case 16: | 623 | case 16: |
3128 | l_fb_info->cmap.cmap16[regno] = | 624 | case 24: |
3129 | ((u32) red & 0xf800) | | ||
3130 | (((u32) green & 0xfc00) >> 5) | | ||
3131 | (((u32) blue & 0xf800) >> 11); | ||
3132 | break; | ||
3133 | #endif | ||
3134 | #ifdef FBCON_HAS_CFB32 | ||
3135 | case 32: | 625 | case 32: |
3136 | l_fb_info->cmap.cmap32[regno] = | 626 | ((u32*)(info->pseudo_palette))[regno] = v; |
3137 | (((u32) transp & 0xff00) << 16) | | ||
3138 | (((u32) red & 0xff00) << 8) | | ||
3139 | (((u32) green & 0xff00)) | | ||
3140 | (((u32) blue & 0xff00) >> 8); | ||
3141 | break; | ||
3142 | #endif | ||
3143 | default: | ||
3144 | DPRINTK(1, "bad depth %u\n", | ||
3145 | l_fb_info->current_par->depth); | ||
3146 | break; | 627 | break; |
3147 | } | 628 | } |
629 | return 0; | ||
3148 | } | 630 | } |
3149 | if (regno < 256) { | 631 | else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) |
3150 | l_fb_info->palette[regno].red = red >> 8; | 632 | pm3fb_set_color(par, regno, red, green, blue); |
3151 | l_fb_info->palette[regno].green = green >> 8; | 633 | |
3152 | l_fb_info->palette[regno].blue = blue >> 8; | 634 | return 0; |
3153 | l_fb_info->palette[regno].transp = transp >> 8; | ||
3154 | if (l_fb_info->current_par->depth == 8) | ||
3155 | pm3fb_set_color(l_fb_info, regno, red >> 8, | ||
3156 | green >> 8, blue >> 8); | ||
3157 | } | ||
3158 | return (regno > 255); | ||
3159 | } | 635 | } |
3160 | 636 | ||
3161 | static int pm3fb_blank(int blank_mode, struct fb_info_gen *info) | 637 | static int pm3fb_pan_display(struct fb_var_screeninfo *var, |
638 | struct fb_info *info) | ||
3162 | { | 639 | { |
3163 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | 640 | struct pm3_par *par = info->par; |
3164 | u32 video; | 641 | const u32 xres = (var->xres + 31) & ~31; |
3165 | |||
3166 | DTRACE; | ||
3167 | 642 | ||
3168 | if (!current_par_valid[l_fb_info->board_num]) | 643 | par->base = pm3fb_shift_bpp(var->bits_per_pixel, |
3169 | return (1); | 644 | (var->yoffset * xres) |
645 | + var->xoffset); | ||
646 | PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base); | ||
647 | return 0; | ||
648 | } | ||
3170 | 649 | ||
3171 | video = l_fb_info->current_par->video; | 650 | static int pm3fb_blank(int blank_mode, struct fb_info *info) |
651 | { | ||
652 | struct pm3_par *par = info->par; | ||
653 | u32 video = par->video; | ||
3172 | 654 | ||
3173 | /* | 655 | /* |
3174 | * Oxygen VX1 - it appears that setting PM3VideoControl and | 656 | * Oxygen VX1 - it appears that setting PM3VideoControl and |
@@ -3181,454 +663,345 @@ static int pm3fb_blank(int blank_mode, struct fb_info_gen *info) | |||
3181 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | | 663 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | |
3182 | PM3VideoControl_VSYNC_ACTIVE_HIGH; | 664 | PM3VideoControl_VSYNC_ACTIVE_HIGH; |
3183 | 665 | ||
3184 | if (blank_mode > 0) { | 666 | switch (blank_mode) { |
3185 | switch (blank_mode - 1) { | 667 | case FB_BLANK_UNBLANK: |
3186 | 668 | video = video | PM3VideoControl_ENABLE; | |
3187 | case VESA_NO_BLANKING: /* FIXME */ | ||
3188 | video = video & ~(PM3VideoControl_ENABLE); | ||
3189 | break; | ||
3190 | |||
3191 | case VESA_HSYNC_SUSPEND: | ||
3192 | video = video & ~(PM3VideoControl_HSYNC_MASK | | ||
3193 | PM3VideoControl_BLANK_ACTIVE_LOW); | ||
3194 | break; | ||
3195 | case VESA_VSYNC_SUSPEND: | ||
3196 | video = video & ~(PM3VideoControl_VSYNC_MASK | | ||
3197 | PM3VideoControl_BLANK_ACTIVE_LOW); | ||
3198 | break; | ||
3199 | case VESA_POWERDOWN: | ||
3200 | video = video & ~(PM3VideoControl_HSYNC_MASK | | ||
3201 | PM3VideoControl_VSYNC_MASK | | ||
3202 | PM3VideoControl_BLANK_ACTIVE_LOW); | ||
3203 | break; | ||
3204 | default: | ||
3205 | DPRINTK(1, "Unsupported blanking %d\n", | ||
3206 | blank_mode); | ||
3207 | return (1); | ||
3208 | break; | ||
3209 | } | ||
3210 | } | ||
3211 | |||
3212 | PM3_SLOW_WRITE_REG(PM3VideoControl, video); | ||
3213 | |||
3214 | return (0); | ||
3215 | } | ||
3216 | |||
3217 | static void pm3fb_set_disp(const void *par, struct display *disp, | ||
3218 | struct fb_info_gen *info) | ||
3219 | { | ||
3220 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3221 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
3222 | u32 flags; | ||
3223 | |||
3224 | DTRACE; | ||
3225 | |||
3226 | local_irq_save(flags); | ||
3227 | info->info.screen_base = l_fb_info->v_fb; | ||
3228 | switch (p->depth) { | ||
3229 | #ifdef FBCON_HAS_CFB8 | ||
3230 | case 8: | ||
3231 | #ifdef PM3FB_USE_ACCEL | ||
3232 | if (!(noaccel[l_fb_info->board_num])) | ||
3233 | disp->dispsw = &pm3fb_cfb8; | ||
3234 | else | ||
3235 | #endif /* PM3FB_USE_ACCEL */ | ||
3236 | disp->dispsw = &fbcon_cfb8; | ||
3237 | break; | 669 | break; |
3238 | #endif | 670 | case FB_BLANK_NORMAL: /* FIXME */ |
3239 | #ifdef FBCON_HAS_CFB16 | 671 | video = video & ~(PM3VideoControl_ENABLE); |
3240 | case 12: | ||
3241 | #ifdef PM3FB_USE_ACCEL | ||
3242 | if (!(noaccel[l_fb_info->board_num])) | ||
3243 | disp->dispsw = &pm3fb_cfb16; | ||
3244 | else | ||
3245 | #endif /* PM3FB_USE_ACCEL */ | ||
3246 | disp->dispsw = &fbcon_cfb16; | ||
3247 | disp->dispsw_data = l_fb_info->cmap.cmap12; | ||
3248 | break; | 672 | break; |
3249 | case 15: | 673 | case FB_BLANK_HSYNC_SUSPEND: |
3250 | #ifdef PM3FB_USE_ACCEL | 674 | video = video & ~(PM3VideoControl_HSYNC_MASK | |
3251 | if (!(noaccel[l_fb_info->board_num])) | 675 | PM3VideoControl_BLANK_ACTIVE_LOW); |
3252 | disp->dispsw = &pm3fb_cfb16; | ||
3253 | else | ||
3254 | #endif /* PM3FB_USE_ACCEL */ | ||
3255 | disp->dispsw = &fbcon_cfb16; | ||
3256 | disp->dispsw_data = l_fb_info->cmap.cmap15; | ||
3257 | break; | 676 | break; |
3258 | case 16: | 677 | case FB_BLANK_VSYNC_SUSPEND: |
3259 | #ifdef PM3FB_USE_ACCEL | 678 | video = video & ~(PM3VideoControl_VSYNC_MASK | |
3260 | if (!(noaccel[l_fb_info->board_num])) | 679 | PM3VideoControl_BLANK_ACTIVE_LOW); |
3261 | disp->dispsw = &pm3fb_cfb16; | ||
3262 | else | ||
3263 | #endif /* PM3FB_USE_ACCEL */ | ||
3264 | disp->dispsw = &fbcon_cfb16; | ||
3265 | disp->dispsw_data = l_fb_info->cmap.cmap16; | ||
3266 | break; | 680 | break; |
3267 | #endif | 681 | case FB_BLANK_POWERDOWN: |
3268 | #ifdef FBCON_HAS_CFB32 | 682 | video = video & ~(PM3VideoControl_HSYNC_MASK | |
3269 | case 32: | 683 | PM3VideoControl_VSYNC_MASK | |
3270 | #ifdef PM3FB_USE_ACCEL | 684 | PM3VideoControl_BLANK_ACTIVE_LOW); |
3271 | if (!(noaccel[l_fb_info->board_num])) | ||
3272 | disp->dispsw = &pm3fb_cfb32; | ||
3273 | else | ||
3274 | #endif /* PM3FB_USE_ACCEL */ | ||
3275 | disp->dispsw = &fbcon_cfb32; | ||
3276 | disp->dispsw_data = l_fb_info->cmap.cmap32; | ||
3277 | break; | 685 | break; |
3278 | #endif /* FBCON_HAS_CFB32 */ | ||
3279 | default: | 686 | default: |
3280 | disp->dispsw = &fbcon_dummy; | 687 | DPRINTK("Unsupported blanking %d\n", blank_mode); |
3281 | DPRINTK(1, "Invalid depth, using fbcon_dummy\n"); | 688 | return 1; |
3282 | break; | ||
3283 | } | 689 | } |
3284 | local_irq_restore(flags); | 690 | |
691 | PM3_SLOW_WRITE_REG(par,PM3VideoControl, video); | ||
692 | |||
693 | return 0; | ||
3285 | } | 694 | } |
3286 | 695 | ||
3287 | /* */ | 696 | /* |
3288 | static void pm3fb_detect(void) | 697 | * Frame buffer operations |
3289 | { | 698 | */ |
3290 | struct pci_dev *dev_array[PM3_MAX_BOARD]; | ||
3291 | struct pci_dev *dev = NULL; | ||
3292 | struct pm3fb_info *l_fb_info = &(fb_info[0]); | ||
3293 | unsigned long i, j, done; | ||
3294 | 699 | ||
3295 | DTRACE; | 700 | static struct fb_ops pm3fb_ops = { |
701 | .owner = THIS_MODULE, | ||
702 | .fb_check_var = pm3fb_check_var, | ||
703 | .fb_set_par = pm3fb_set_par, | ||
704 | .fb_setcolreg = pm3fb_setcolreg, | ||
705 | .fb_pan_display = pm3fb_pan_display, | ||
706 | .fb_fillrect = cfb_fillrect, /* Needed !!! */ | ||
707 | .fb_copyarea = cfb_copyarea, /* Needed !!! */ | ||
708 | .fb_imageblit = cfb_imageblit, /* Needed !!! */ | ||
709 | .fb_blank = pm3fb_blank, | ||
710 | }; | ||
3296 | 711 | ||
3297 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 712 | /* ------------------------------------------------------------------------- */ |
3298 | dev_array[i] = NULL; | ||
3299 | fb_info[i].dev = NULL; | ||
3300 | } | ||
3301 | 713 | ||
3302 | dev = pci_get_device(PCI_VENDOR_ID_3DLABS, | 714 | /* |
3303 | PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); | 715 | * Initialization |
716 | */ | ||
3304 | 717 | ||
3305 | for (i = 0; ((i < PM3_MAX_BOARD) && dev); i++) { | 718 | /* mmio register are already mapped when this function is called */ |
3306 | dev_array[i] = dev; | 719 | /* the pm3fb_fix.smem_start is also set */ |
3307 | dev = pci_get_device(PCI_VENDOR_ID_3DLABS, | 720 | static unsigned long pm3fb_size_memory(struct pm3_par *par) |
3308 | PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); | 721 | { |
3309 | } | 722 | unsigned long memsize = 0, tempBypass, i, temp1, temp2; |
723 | unsigned char __iomem *screen_mem; | ||
3310 | 724 | ||
3311 | if (dev) { /* more than PM3_MAX_BOARD */ | 725 | pm3fb_fix.smem_len = 64 * 1024 * 1024; /* request full aperture size */ |
3312 | printk(KERN_WARNING "pm3fb: Warning: more than %d boards found\n", | 726 | /* Linear frame buffer - request region and map it. */ |
3313 | PM3_MAX_BOARD); | 727 | if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len, |
728 | "pm3fb smem")) { | ||
729 | printk(KERN_WARNING "pm3fb: Can't reserve smem.\n"); | ||
730 | return 0; | ||
3314 | } | 731 | } |
3315 | 732 | screen_mem = | |
3316 | if (!dev_array[0]) { /* not a single board, abort */ | 733 | ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len); |
3317 | return; | 734 | if (!screen_mem) { |
735 | printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n"); | ||
736 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
737 | return 0; | ||
3318 | } | 738 | } |
3319 | 739 | ||
3320 | /* allocate user-defined boards */ | 740 | /* TODO: card-specific stuff, *before* accessing *any* FB memory */ |
3321 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 741 | /* For Appian Jeronimo 2000 board second head */ |
3322 | if ((bus[i] >= 0) && (slot[i] >= 0) && (func[i] >= 0)) { | 742 | |
3323 | for (j = 0; j < PM3_MAX_BOARD; j++) { | 743 | tempBypass = PM3_READ_REG(par, PM3MemBypassWriteMask); |
3324 | if ((dev_array[j] != NULL) && | 744 | |
3325 | (dev_array[j]->bus->number == bus[i]) | 745 | DPRINTK("PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass); |
3326 | && (PCI_SLOT(dev_array[j]->devfn) == | 746 | |
3327 | slot[i]) | 747 | PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xFFFFFFFF); |
3328 | && (PCI_FUNC(dev_array[j]->devfn) == | 748 | |
3329 | func[i])) { | 749 | /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */ |
3330 | fb_info[i].dev = dev_array[j]; | 750 | for (i = 0; i < 32; i++) { |
3331 | dev_array[j] = NULL; | 751 | fb_writel(i * 0x00345678, |
3332 | } | 752 | (screen_mem + (i * 1048576))); |
3333 | } | 753 | mb(); |
3334 | } | 754 | temp1 = fb_readl((screen_mem + (i * 1048576))); |
755 | |||
756 | /* Let's check for wrapover, write will fail at 16MB boundary */ | ||
757 | if (temp1 == (i * 0x00345678)) | ||
758 | memsize = i; | ||
759 | else | ||
760 | break; | ||
3335 | } | 761 | } |
3336 | /* allocate remaining boards */ | 762 | |
3337 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 763 | DPRINTK("First detect pass already got %ld MB\n", memsize + 1); |
3338 | if (fb_info[i].dev == NULL) { | 764 | |
3339 | done = 0; | 765 | if (memsize + 1 == i) { |
3340 | for (j = 0; ((j < PM3_MAX_BOARD) && (!done)); j++) { | 766 | for (i = 0; i < 32; i++) { |
3341 | if (dev_array[j] != NULL) { | 767 | /* Clear first 32MB ; 0 is 0, no need to byteswap */ |
3342 | fb_info[i].dev = dev_array[j]; | 768 | writel(0x0000000, |
3343 | dev_array[j] = NULL; | 769 | (screen_mem + (i * 1048576))); |
3344 | done = 1; | 770 | mb(); |
3345 | } | ||
3346 | } | ||
3347 | } | 771 | } |
3348 | } | ||
3349 | 772 | ||
3350 | /* at that point, all PCI Permedia3 are detected and allocated */ | 773 | for (i = 32; i < 64; i++) { |
3351 | /* now, initialize... or not */ | 774 | fb_writel(i * 0x00345678, |
3352 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 775 | (screen_mem + (i * 1048576))); |
3353 | l_fb_info = &(fb_info[i]); | 776 | mb(); |
3354 | if (l_fb_info->dev && !disable[i]) { /* PCI device was found and not disabled by user */ | 777 | temp1 = |
3355 | DPRINTK(2, | 778 | fb_readl((screen_mem + (i * 1048576))); |
3356 | "found @%lx Vendor %lx Device %lx ; base @ : %lx - %lx - %lx - %lx - %lx - %lx, irq %ld\n", | 779 | temp2 = |
3357 | (unsigned long) l_fb_info->dev, | 780 | fb_readl((screen_mem + ((i - 32) * 1048576))); |
3358 | (unsigned long) l_fb_info->dev->vendor, | 781 | /* different value, different RAM... */ |
3359 | (unsigned long) l_fb_info->dev->device, | 782 | if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) |
3360 | (unsigned long) | 783 | memsize = i; |
3361 | pci_resource_start(l_fb_info->dev, 0), | 784 | else |
3362 | (unsigned long) | 785 | break; |
3363 | pci_resource_start(l_fb_info->dev, 1), | ||
3364 | (unsigned long) | ||
3365 | pci_resource_start(l_fb_info->dev, 2), | ||
3366 | (unsigned long) | ||
3367 | pci_resource_start(l_fb_info->dev, 3), | ||
3368 | (unsigned long) | ||
3369 | pci_resource_start(l_fb_info->dev, 4), | ||
3370 | (unsigned long) | ||
3371 | pci_resource_start(l_fb_info->dev, 5), | ||
3372 | (unsigned long) l_fb_info->dev->irq); | ||
3373 | |||
3374 | l_fb_info->pIOBase = | ||
3375 | (unsigned char *) | ||
3376 | pci_resource_start(l_fb_info->dev, 0); | ||
3377 | #ifdef __BIG_ENDIAN | ||
3378 | l_fb_info->pIOBase += PM3_REGS_SIZE; | ||
3379 | #endif | ||
3380 | l_fb_info->vIOBase = (unsigned char *) -1; | ||
3381 | l_fb_info->p_fb = | ||
3382 | (unsigned char *) | ||
3383 | pci_resource_start(l_fb_info->dev, 1); | ||
3384 | l_fb_info->v_fb = (unsigned char *) -1; | ||
3385 | |||
3386 | if (!request_mem_region | ||
3387 | ((unsigned long)l_fb_info->p_fb, 64 * 1024 * 1024, /* request full aperture size */ | ||
3388 | "pm3fb")) { | ||
3389 | printk | ||
3390 | (KERN_ERR "pm3fb: Error: couldn't request framebuffer memory, board #%ld\n", | ||
3391 | l_fb_info->board_num); | ||
3392 | continue; | ||
3393 | } | ||
3394 | if (!request_mem_region | ||
3395 | ((unsigned long)l_fb_info->pIOBase, PM3_REGS_SIZE, | ||
3396 | "pm3fb I/O regs")) { | ||
3397 | printk | ||
3398 | (KERN_ERR "pm3fb: Error: couldn't request IObase memory, board #%ld\n", | ||
3399 | l_fb_info->board_num); | ||
3400 | continue; | ||
3401 | } | ||
3402 | if (forcesize[l_fb_info->board_num]) | ||
3403 | l_fb_info->fb_size = forcesize[l_fb_info->board_num]; | ||
3404 | |||
3405 | l_fb_info->fb_size = | ||
3406 | pm3fb_size_memory(l_fb_info); | ||
3407 | if (l_fb_info->fb_size) { | ||
3408 | (void) pci_enable_device(l_fb_info->dev); | ||
3409 | pm3fb_common_init(l_fb_info); | ||
3410 | } else | ||
3411 | printk(KERN_ERR "pm3fb: memory problem, not enabling board #%ld\n", l_fb_info->board_num); | ||
3412 | } | 786 | } |
3413 | } | 787 | } |
3414 | } | 788 | DPRINTK("Second detect pass got %ld MB\n", memsize + 1); |
3415 | 789 | ||
3416 | static int pm3fb_pan_display(const struct fb_var_screeninfo *var, | 790 | PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, tempBypass); |
3417 | struct fb_info_gen *info) | ||
3418 | { | ||
3419 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3420 | 791 | ||
3421 | DTRACE; | 792 | iounmap(screen_mem); |
793 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
794 | memsize = 1048576 * (memsize + 1); | ||
3422 | 795 | ||
3423 | if (!current_par_valid[l_fb_info->board_num]) | 796 | DPRINTK("Returning 0x%08lx bytes\n", memsize); |
3424 | return -EINVAL; | ||
3425 | 797 | ||
3426 | l_fb_info->current_par->base = /* in 128 bits chunk - i.e. AFTER Shiftbpp */ | 798 | return memsize; |
3427 | pm3fb_Shiftbpp(l_fb_info, | ||
3428 | l_fb_info->current_par->depth, | ||
3429 | (var->yoffset * l_fb_info->current_par->width) + | ||
3430 | var->xoffset); | ||
3431 | PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base); | ||
3432 | return 0; | ||
3433 | } | 799 | } |
3434 | 800 | ||
3435 | static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg) | 801 | static int __devinit pm3fb_probe(struct pci_dev *dev, |
802 | const struct pci_device_id *ent) | ||
3436 | { | 803 | { |
3437 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | 804 | struct fb_info *info; |
3438 | u32 cm, i; | 805 | struct pm3_par *par; |
3439 | #ifdef PM3FB_MASTER_DEBUG | 806 | struct device* device = &dev->dev; /* for pci drivers */ |
3440 | char cc[3]; | 807 | int err, retval = -ENXIO; |
3441 | #endif /* PM3FB_MASTER_DEBUG */ | ||
3442 | 808 | ||
3443 | switch(cmd) | 809 | err = pci_enable_device(dev); |
3444 | { | 810 | if (err) { |
3445 | #ifdef PM3FB_MASTER_DEBUG | 811 | printk(KERN_WARNING "pm3fb: Can't enable PCI dev: %d\n", err); |
3446 | case PM3FBIO_CLEARMEMORY: | 812 | return err; |
3447 | if (copy_from_user(&cm, (void *)arg, sizeof(u32))) | 813 | } |
3448 | return(-EFAULT); | 814 | /* |
3449 | pm3fb_clear_memory(l_fb_info, cm); | 815 | * Dynamically allocate info and par |
3450 | return(0); | 816 | */ |
3451 | break; | 817 | info = framebuffer_alloc(sizeof(struct pm3_par), device); |
3452 | 818 | ||
3453 | case PM3FBIO_CLEARCMAP: | 819 | if (!info) |
3454 | if (copy_from_user(cc, (void*)arg, 3 * sizeof(char))) | 820 | return -ENOMEM; |
3455 | return(-EFAULT); | 821 | par = info->par; |
3456 | pm3fb_clear_colormap(l_fb_info, cc[0], cc[1], cc[2]); | ||
3457 | return(0); | ||
3458 | break; | ||
3459 | #endif /* PM3FB_MASTER_DEBUG */ | ||
3460 | |||
3461 | case PM3FBIO_RESETCHIP: | ||
3462 | cm = 1; | ||
3463 | PM3_SLOW_WRITE_REG(PM3ResetStatus, 1); | ||
3464 | for (i = 0 ; (i < 10000) && cm ; i++) | ||
3465 | { | ||
3466 | PM3_DELAY(10); | ||
3467 | cm = PM3_READ_REG(PM3ResetStatus); | ||
3468 | } | ||
3469 | if (cm) | ||
3470 | { | ||
3471 | printk(KERN_ERR "pm3fb: chip reset failed with status 0x%x\n", cm); | ||
3472 | return(-EIO); | ||
3473 | } | ||
3474 | /* first thing first, reload memory timings */ | ||
3475 | pm3fb_write_memory_timings(l_fb_info); | ||
3476 | #ifdef PM3FB_USE_ACCEL | ||
3477 | pm3fb_init_engine(l_fb_info); | ||
3478 | #endif /* PM3FB_USE_ACCEL */ | ||
3479 | pm3fb_write_mode(l_fb_info); | ||
3480 | return(0); | ||
3481 | break; | ||
3482 | 822 | ||
3483 | default: | 823 | /* |
3484 | DPRINTK(2, "unknown ioctl: %d (%x)\n", cmd, cmd); | 824 | * Here we set the screen_base to the virtual memory address |
3485 | return(-EINVAL); | 825 | * for the framebuffer. |
826 | */ | ||
827 | pm3fb_fix.mmio_start = pci_resource_start(dev, 0); | ||
828 | pm3fb_fix.mmio_len = PM3_REGS_SIZE; | ||
829 | |||
830 | /* Registers - request region and map it. */ | ||
831 | if (!request_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len, | ||
832 | "pm3fb regbase")) { | ||
833 | printk(KERN_WARNING "pm3fb: Can't reserve regbase.\n"); | ||
834 | goto err_exit_neither; | ||
835 | } | ||
836 | par->v_regs = | ||
837 | ioremap_nocache(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len); | ||
838 | if (!par->v_regs) { | ||
839 | printk(KERN_WARNING "pm3fb: Can't remap %s register area.\n", | ||
840 | pm3fb_fix.id); | ||
841 | release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len); | ||
842 | goto err_exit_neither; | ||
843 | } | ||
844 | |||
845 | #if defined(__BIG_ENDIAN) | ||
846 | pm3fb_fix.mmio_start += PM3_REGS_SIZE; | ||
847 | DPRINTK("Adjusting register base for big-endian.\n"); | ||
848 | #endif | ||
849 | /* Linear frame buffer - request region and map it. */ | ||
850 | pm3fb_fix.smem_start = pci_resource_start(dev, 1); | ||
851 | pm3fb_fix.smem_len = pm3fb_size_memory(par); | ||
852 | if (!pm3fb_fix.smem_len) | ||
853 | { | ||
854 | printk(KERN_WARNING "pm3fb: Can't find memory on board.\n"); | ||
855 | goto err_exit_mmio; | ||
3486 | } | 856 | } |
3487 | } | 857 | if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len, |
858 | "pm3fb smem")) { | ||
859 | printk(KERN_WARNING "pm3fb: Can't reserve smem.\n"); | ||
860 | goto err_exit_mmio; | ||
861 | } | ||
862 | info->screen_base = | ||
863 | ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
864 | if (!info->screen_base) { | ||
865 | printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n"); | ||
866 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
867 | goto err_exit_mmio; | ||
868 | } | ||
869 | info->screen_size = pm3fb_fix.smem_len; | ||
3488 | 870 | ||
3489 | /* ****************************************** */ | 871 | info->fbops = &pm3fb_ops; |
3490 | /* ***** standard FB API init functions ***** */ | ||
3491 | /* ****************************************** */ | ||
3492 | 872 | ||
3493 | int __init pm3fb_setup(char *options) | 873 | par->video = PM3_READ_REG(par, PM3VideoControl); |
3494 | { | ||
3495 | long opsi = strlen(options); | ||
3496 | 874 | ||
3497 | DTRACE; | 875 | info->fix = pm3fb_fix; |
876 | info->pseudo_palette = par->palette; | ||
877 | info->flags = FBINFO_DEFAULT;/* | FBINFO_HWACCEL_YPAN;*/ | ||
3498 | 878 | ||
3499 | memcpy(g_options, options, | 879 | /* |
3500 | ((opsi + 1) > | 880 | * This should give a reasonable default video mode. The following is |
3501 | PM3_OPTIONS_SIZE) ? PM3_OPTIONS_SIZE : (opsi + 1)); | 881 | * done when we can set a video mode. |
3502 | g_options[PM3_OPTIONS_SIZE - 1] = 0; | 882 | */ |
883 | if (!mode_option) | ||
884 | mode_option = "640x480@60"; | ||
885 | |||
886 | retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8); | ||
887 | |||
888 | if (!retval || retval == 4) { | ||
889 | retval = -EINVAL; | ||
890 | goto err_exit_both; | ||
891 | } | ||
892 | |||
893 | /* This has to been done !!! */ | ||
894 | if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { | ||
895 | retval = -ENOMEM; | ||
896 | goto err_exit_both; | ||
897 | } | ||
3503 | 898 | ||
3504 | return (0); | 899 | /* |
900 | * For drivers that can... | ||
901 | */ | ||
902 | pm3fb_check_var(&info->var, info); | ||
903 | |||
904 | if (register_framebuffer(info) < 0) { | ||
905 | retval = -EINVAL; | ||
906 | goto err_exit_all; | ||
907 | } | ||
908 | printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, | ||
909 | info->fix.id); | ||
910 | pci_set_drvdata(dev, info); /* or dev_set_drvdata(device, info) */ | ||
911 | return 0; | ||
912 | |||
913 | err_exit_all: | ||
914 | fb_dealloc_cmap(&info->cmap); | ||
915 | err_exit_both: | ||
916 | iounmap(info->screen_base); | ||
917 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
918 | err_exit_mmio: | ||
919 | iounmap(par->v_regs); | ||
920 | release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len); | ||
921 | err_exit_neither: | ||
922 | framebuffer_release(info); | ||
923 | return retval; | ||
3505 | } | 924 | } |
3506 | 925 | ||
3507 | int __init pm3fb_init(void) | 926 | /* |
927 | * Cleanup | ||
928 | */ | ||
929 | static void __devexit pm3fb_remove(struct pci_dev *dev) | ||
3508 | { | 930 | { |
3509 | DTRACE; | 931 | struct fb_info *info = pci_get_drvdata(dev); |
3510 | 932 | ||
3511 | DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $"); | 933 | if (info) { |
934 | struct fb_fix_screeninfo *fix = &info->fix; | ||
935 | struct pm3_par *par = info->par; | ||
3512 | 936 | ||
3513 | pm3fb_real_setup(g_options); | 937 | unregister_framebuffer(info); |
938 | fb_dealloc_cmap(&info->cmap); | ||
3514 | 939 | ||
3515 | pm3fb_detect(); | 940 | iounmap(info->screen_base); |
941 | release_mem_region(fix->smem_start, fix->smem_len); | ||
942 | iounmap(par->v_regs); | ||
943 | release_mem_region(fix->mmio_start, fix->mmio_len); | ||
3516 | 944 | ||
3517 | if (!fb_info[0].dev) { /* not even one board ??? */ | 945 | pci_set_drvdata(dev, NULL); |
3518 | DPRINTK(1, "No PCI Permedia3 board detected\n"); | 946 | framebuffer_release(info); |
3519 | } | 947 | } |
3520 | return (0); | ||
3521 | } | 948 | } |
3522 | 949 | ||
3523 | /* ************************* */ | 950 | static struct pci_device_id pm3fb_id_table[] = { |
3524 | /* **** Module support ***** */ | 951 | { PCI_VENDOR_ID_3DLABS, 0x0a, |
3525 | /* ************************* */ | 952 | PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, |
3526 | 953 | 0xff0000, 0 }, | |
3527 | #ifdef MODULE | 954 | { 0, } |
3528 | MODULE_AUTHOR("Romain Dolbeau"); | 955 | }; |
3529 | MODULE_DESCRIPTION("Permedia3 framebuffer device driver"); | ||
3530 | static char *mode[PM3_MAX_BOARD]; | ||
3531 | module_param_array(mode, charp, NULL, 0); | ||
3532 | MODULE_PARM_DESC(mode,"video mode"); | ||
3533 | module_param_array(disable, short, NULL, 0); | ||
3534 | MODULE_PARM_DESC(disable,"disable board"); | ||
3535 | static short off[PM3_MAX_BOARD]; | ||
3536 | module_param_array(off, short, NULL, 0); | ||
3537 | MODULE_PARM_DESC(off,"disable board"); | ||
3538 | static char *pciid[PM3_MAX_BOARD]; | ||
3539 | module_param_array(pciid, charp, NULL, 0); | ||
3540 | MODULE_PARM_DESC(pciid,"board PCI Id"); | ||
3541 | module_param_array(noaccel, short, NULL, 0); | ||
3542 | MODULE_PARM_DESC(noaccel,"disable accel"); | ||
3543 | static char *font[PM3_MAX_BOARD]; | ||
3544 | module_param_array(font, charp, NULL, 0); | ||
3545 | MODULE_PARM_DESC(font,"choose font"); | ||
3546 | module_param(depth, short, NULL, 0); | ||
3547 | MODULE_PARM_DESC(depth,"boot-time depth"); | ||
3548 | module_param(printtimings, short, NULL, 0); | ||
3549 | MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)"); | ||
3550 | module_param(forcesize, short, NULL, 0); | ||
3551 | MODULE_PARM_DESC(forcesize, "force specified memory size"); | ||
3552 | /* | ||
3553 | MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards") | ||
3554 | MODULE_GENERIC_TABLE(gtype,name) | ||
3555 | MODULE_DEVICE_TABLE(type,name) | ||
3556 | */ | ||
3557 | 956 | ||
3558 | void pm3fb_build_options(void) | 957 | /* For PCI drivers */ |
3559 | { | 958 | static struct pci_driver pm3fb_driver = { |
3560 | int i; | 959 | .name = "pm3fb", |
3561 | char ts[128]; | 960 | .id_table = pm3fb_id_table, |
961 | .probe = pm3fb_probe, | ||
962 | .remove = __devexit_p(pm3fb_remove), | ||
963 | }; | ||
3562 | 964 | ||
3563 | strcpy(g_options, "pm3fb"); | 965 | MODULE_DEVICE_TABLE(pci, pm3fb_id_table); |
3564 | for (i = 0; i < PM3_MAX_BOARD ; i++) | ||
3565 | { | ||
3566 | if (mode[i]) | ||
3567 | { | ||
3568 | sprintf(ts, ",mode:%d:%s", i, mode[i]); | ||
3569 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3570 | } | ||
3571 | if (disable[i] || off[i]) | ||
3572 | { | ||
3573 | sprintf(ts, ",disable:%d:", i); | ||
3574 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3575 | } | ||
3576 | if (pciid[i]) | ||
3577 | { | ||
3578 | sprintf(ts, ",pciid:%d:%s", i, pciid[i]); | ||
3579 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3580 | } | ||
3581 | if (noaccel[i]) | ||
3582 | { | ||
3583 | sprintf(ts, ",noaccel:%d:", i); | ||
3584 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3585 | } | ||
3586 | if (font[i]) | ||
3587 | { | ||
3588 | sprintf(ts, ",font:%d:%s", i, font[i]); | ||
3589 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3590 | } | ||
3591 | if (depth[i]) | ||
3592 | { | ||
3593 | sprintf(ts, ",depth:%d:%d", i, depth[i]); | ||
3594 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3595 | } | ||
3596 | } | ||
3597 | g_options[PM3_OPTIONS_SIZE - 1] = '\0'; | ||
3598 | DPRINTK(1, "pm3fb use options: %s\n", g_options); | ||
3599 | } | ||
3600 | 966 | ||
3601 | int init_module(void) | 967 | int __init pm3fb_init(void) |
3602 | { | 968 | { |
3603 | DTRACE; | 969 | /* |
970 | * For kernel boot options (in 'video=pm3fb:<options>' format) | ||
971 | */ | ||
972 | #ifndef MODULE | ||
973 | char *option = NULL; | ||
3604 | 974 | ||
3605 | pm3fb_build_options(); | 975 | if (fb_get_options("pm3fb", &option)) |
976 | return -ENODEV; | ||
977 | pm3fb_setup(option); | ||
978 | #endif | ||
3606 | 979 | ||
3607 | pm3fb_init(); | 980 | return pci_register_driver(&pm3fb_driver); |
981 | } | ||
3608 | 982 | ||
3609 | return 0; | 983 | static void __exit pm3fb_exit(void) |
984 | { | ||
985 | pci_unregister_driver(&pm3fb_driver); | ||
3610 | } | 986 | } |
3611 | 987 | ||
3612 | void cleanup_module(void) | 988 | #ifndef MODULE |
989 | /* | ||
990 | * Setup | ||
991 | */ | ||
992 | |||
993 | /* | ||
994 | * Only necessary if your driver takes special options, | ||
995 | * otherwise we fall back on the generic fb_setup(). | ||
996 | */ | ||
997 | int __init pm3fb_setup(char *options) | ||
3613 | { | 998 | { |
3614 | DTRACE; | 999 | /* Parse user speficied options (`video=pm3fb:') */ |
3615 | { | 1000 | return 0; |
3616 | unsigned long i; | ||
3617 | struct pm3fb_info *l_fb_info; | ||
3618 | for (i = 0; i < PM3_MAX_BOARD; i++) { | ||
3619 | l_fb_info = &(fb_info[i]); | ||
3620 | pci_dev_put(l_fb_info->dev); | ||
3621 | if (l_fb_info->dev != NULL && !(disable[l_fb_info->board_num])) { | ||
3622 | if (l_fb_info->vIOBase != (unsigned char *) -1) { | ||
3623 | pm3fb_unmapIO(l_fb_info); | ||
3624 | release_mem_region(l_fb_info->p_fb, | ||
3625 | l_fb_info->fb_size); | ||
3626 | release_mem_region(l_fb_info->pIOBase, | ||
3627 | PM3_REGS_SIZE); | ||
3628 | } | ||
3629 | unregister_framebuffer(&l_fb_info->gen.info); | ||
3630 | } | ||
3631 | } | ||
3632 | } | ||
3633 | } | 1001 | } |
3634 | #endif /* MODULE */ | 1002 | #endif /* MODULE */ |
1003 | |||
1004 | module_init(pm3fb_init); | ||
1005 | module_exit(pm3fb_exit); | ||
1006 | |||
1007 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c index 76e6ce353c8e..a0e22ac483a3 100644 --- a/drivers/video/riva/rivafb-i2c.c +++ b/drivers/video/riva/rivafb-i2c.c | |||
@@ -70,8 +70,6 @@ static int riva_gpio_getscl(void* data) | |||
70 | if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x04) | 70 | if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x04) |
71 | val = 1; | 71 | val = 1; |
72 | 72 | ||
73 | val = VGA_RD08(par->riva.PCIO, 0x3d5); | ||
74 | |||
75 | return val; | 73 | return val; |
76 | } | 74 | } |
77 | 75 | ||