aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-30 12:23:30 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-30 12:23:30 -0500
commitc43e0e46adf79c321ed3fbf0351e1005fb8a2413 (patch)
tree35b9ab361651f649d3c9aa69f159812eba50d154 /drivers
parentdba3d36b2f0842ed7f25c33cd3a2ccdb3d0df9db (diff)
parentf2257b70b0f9b2fe8f2afd83fc6798dca75930b8 (diff)
Merge branch 'linus' into core/percpu
Conflicts: kernel/irq/handle.c
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/Kconfig6
-rw-r--r--drivers/ata/ahci.c32
-rw-r--r--drivers/ata/ata_piix.c34
-rw-r--r--drivers/ata/libata-scsi.c20
-rw-r--r--drivers/ata/libata-sff.c12
-rw-r--r--drivers/ata/pata_rb532_cf.c2
-rw-r--r--drivers/ata/pata_via.c22
-rw-r--r--drivers/ata/sata_mv.c56
-rw-r--r--drivers/ata/sata_nv.c70
-rw-r--r--drivers/ata/sata_sil.c37
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/char/tty_io.c4
-rw-r--r--drivers/edac/cell_edac.c8
-rw-r--r--drivers/firewire/fw-card.c4
-rw-r--r--drivers/firewire/fw-device.c123
-rw-r--r--drivers/firewire/fw-device.h1
-rw-r--r--drivers/firewire/fw-ohci.c6
-rw-r--r--drivers/firewire/fw-sbp2.c89
-rw-r--r--drivers/firewire/fw-topology.c12
-rw-r--r--drivers/firewire/fw-transaction.h9
-rw-r--r--drivers/firmware/dmi_scan.c74
-rw-r--r--drivers/gpio/gpiolib.c1
-rw-r--r--drivers/gpu/drm/drm_irq.c161
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c2
-rw-r--r--drivers/hid/hid-core.c4
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-microsoft.c13
-rw-r--r--drivers/hid/usbhid/hiddev.c2
-rw-r--r--drivers/hwmon/applesmc.c30
-rw-r--r--drivers/ieee1394/ieee1394.h4
-rw-r--r--drivers/ieee1394/ieee1394_core.c16
-rw-r--r--drivers/ieee1394/ohci1394.h2
-rw-r--r--drivers/ieee1394/sbp2.c54
-rw-r--r--drivers/lguest/core.c2
-rw-r--r--drivers/lguest/lguest_user.c5
-rw-r--r--drivers/misc/hpilo.c2
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c3
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c34
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c2
-rw-r--r--drivers/mtd/nand/fsl_elbc_nand.c8
-rw-r--r--drivers/mtd/nand/pasemi_nand.c4
-rw-r--r--drivers/mtd/ubi/Kconfig.debug10
-rw-r--r--drivers/mtd/ubi/build.c21
-rw-r--r--drivers/mtd/ubi/cdev.c184
-rw-r--r--drivers/mtd/ubi/gluebi.c11
-rw-r--r--drivers/mtd/ubi/scan.c8
-rw-r--r--drivers/mtd/ubi/ubi.h11
-rw-r--r--drivers/mtd/ubi/upd.c21
-rw-r--r--drivers/mtd/ubi/vmt.c17
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/fec.c2
-rw-r--r--drivers/parisc/sba_iommu.c18
-rw-r--r--drivers/platform/x86/hp-wmi.c6
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c4
-rw-r--r--drivers/scsi/libiscsi.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c53
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c16
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c22
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c23
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_def.h1
-rw-r--r--drivers/scsi/qla4xxx/ql4_init.c10
-rw-r--r--drivers/serial/8250_pci.c6
-rw-r--r--drivers/serial/Kconfig2
-rw-r--r--drivers/serial/jsm/jsm_driver.c2
-rw-r--r--drivers/serial/mcf.c11
-rw-r--r--drivers/staging/agnx/agnx.h2
-rw-r--r--drivers/staging/altpciechdma/altpciechdma.c4
-rw-r--r--drivers/staging/android/binder.c16
-rw-r--r--drivers/staging/android/lowmemorykiller.txt16
-rw-r--r--drivers/staging/android/timed_gpio.c5
-rw-r--r--drivers/staging/comedi/Kconfig1
-rw-r--r--drivers/staging/meilhaus/Kconfig21
-rw-r--r--drivers/staging/poch/poch.c2
-rw-r--r--drivers/staging/usbip/usbip_common.c16
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/class/cdc-acm.c9
-rw-r--r--drivers/usb/class/usblp.c1
-rw-r--r--drivers/usb/core/devio.c20
-rw-r--r--drivers/usb/core/driver.c2
-rw-r--r--drivers/usb/core/hcd-pci.c117
-rw-r--r--drivers/usb/core/hcd.h1
-rw-r--r--drivers/usb/core/hub.c4
-rw-r--r--drivers/usb/core/inode.c1
-rw-r--r--drivers/usb/core/message.c40
-rw-r--r--drivers/usb/core/usb.h6
-rw-r--r--drivers/usb/gadget/composite.c9
-rw-r--r--drivers/usb/gadget/imx_udc.c2
-rw-r--r--drivers/usb/host/Kconfig18
-rw-r--r--drivers/usb/host/Makefile6
-rw-r--r--drivers/usb/host/ehci-pci.c3
-rw-r--r--drivers/usb/host/fhci-dbg.c139
-rw-r--r--drivers/usb/host/fhci-hcd.c836
-rw-r--r--drivers/usb/host/fhci-hub.c345
-rw-r--r--drivers/usb/host/fhci-mem.c113
-rw-r--r--drivers/usb/host/fhci-q.c284
-rw-r--r--drivers/usb/host/fhci-sched.c888
-rw-r--r--drivers/usb/host/fhci-tds.c626
-rw-r--r--drivers/usb/host/fhci.h607
-rw-r--r--drivers/usb/host/ohci-hcd.c8
-rw-r--r--drivers/usb/host/ohci-pci.c1
-rw-r--r--drivers/usb/host/uhci-hcd.c1
-rw-r--r--drivers/usb/misc/ldusb.c2
-rw-r--r--drivers/usb/mon/mon_bin.c105
-rw-r--r--drivers/usb/musb/Kconfig3
-rw-r--r--drivers/usb/musb/cppi_dma.c10
-rw-r--r--drivers/usb/musb/davinci.c13
-rw-r--r--drivers/usb/musb/musb_core.c5
-rw-r--r--drivers/usb/musb/musb_gadget.c6
-rw-r--r--drivers/usb/musb/musb_host.c4
-rw-r--r--drivers/usb/musb/tusb6010_omap.c4
-rw-r--r--drivers/usb/otg/Kconfig4
-rw-r--r--drivers/usb/serial/cp2101.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.h9
-rw-r--r--drivers/usb/serial/option.c14
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h2
-rw-r--r--drivers/usb/storage/unusual_devs.h36
-rw-r--r--drivers/video/Kconfig2
123 files changed, 5073 insertions, 774 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 503a908afc80..0bcf26464670 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -112,11 +112,11 @@ config ATA_PIIX
112 If unsure, say N. 112 If unsure, say N.
113 113
114config SATA_MV 114config SATA_MV
115 tristate "Marvell SATA support (HIGHLY EXPERIMENTAL)" 115 tristate "Marvell SATA support"
116 depends on EXPERIMENTAL
117 help 116 help
118 This option enables support for the Marvell Serial ATA family. 117 This option enables support for the Marvell Serial ATA family.
119 Currently supports 88SX[56]0[48][01] chips. 118 Currently supports 88SX[56]0[48][01] PCI(-X) chips,
119 as well as the newer [67]042 PCI-X/PCIe and SOC devices.
120 120
121 If unsure, say N. 121 If unsure, say N.
122 122
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 96039671e3b9..77bba4c083cb 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -2548,6 +2548,32 @@ static void ahci_p5wdh_workaround(struct ata_host *host)
2548 } 2548 }
2549} 2549}
2550 2550
2551static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
2552{
2553 static const struct dmi_system_id broken_systems[] = {
2554 {
2555 .ident = "HP Compaq nx6310",
2556 .matches = {
2557 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
2558 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6310"),
2559 },
2560 /* PCI slot number of the controller */
2561 .driver_data = (void *)0x1FUL,
2562 },
2563
2564 { } /* terminate list */
2565 };
2566 const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
2567
2568 if (dmi) {
2569 unsigned long slot = (unsigned long)dmi->driver_data;
2570 /* apply the quirk only to on-board controllers */
2571 return slot == PCI_SLOT(pdev->devfn);
2572 }
2573
2574 return false;
2575}
2576
2551static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 2577static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2552{ 2578{
2553 static int printed_version; 2579 static int printed_version;
@@ -2647,6 +2673,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2647 } 2673 }
2648 } 2674 }
2649 2675
2676 if (ahci_broken_system_poweroff(pdev)) {
2677 pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN;
2678 dev_info(&pdev->dev,
2679 "quirky BIOS, skipping spindown on poweroff\n");
2680 }
2681
2650 /* CAP.NP sometimes indicate the index of the last enabled 2682 /* CAP.NP sometimes indicate the index of the last enabled
2651 * port, at other times, that of the last possible port, so 2683 * port, at other times, that of the last possible port, so
2652 * determining the maximum port number requires looking at 2684 * determining the maximum port number requires looking at
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 887d8f46a287..54961c0b2c73 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1387,6 +1387,32 @@ static void piix_iocfg_bit18_quirk(struct ata_host *host)
1387 } 1387 }
1388} 1388}
1389 1389
1390static bool piix_broken_system_poweroff(struct pci_dev *pdev)
1391{
1392 static const struct dmi_system_id broken_systems[] = {
1393 {
1394 .ident = "HP Compaq 2510p",
1395 .matches = {
1396 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1397 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 2510p"),
1398 },
1399 /* PCI slot number of the controller */
1400 .driver_data = (void *)0x1FUL,
1401 },
1402
1403 { } /* terminate list */
1404 };
1405 const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
1406
1407 if (dmi) {
1408 unsigned long slot = (unsigned long)dmi->driver_data;
1409 /* apply the quirk only to on-board controllers */
1410 return slot == PCI_SLOT(pdev->devfn);
1411 }
1412
1413 return false;
1414}
1415
1390/** 1416/**
1391 * piix_init_one - Register PIIX ATA PCI device with kernel services 1417 * piix_init_one - Register PIIX ATA PCI device with kernel services
1392 * @pdev: PCI device to register 1418 * @pdev: PCI device to register
@@ -1422,6 +1448,14 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1422 if (!in_module_init) 1448 if (!in_module_init)
1423 return -ENODEV; 1449 return -ENODEV;
1424 1450
1451 if (piix_broken_system_poweroff(pdev)) {
1452 piix_port_info[ent->driver_data].flags |=
1453 ATA_FLAG_NO_POWEROFF_SPINDOWN |
1454 ATA_FLAG_NO_HIBERNATE_SPINDOWN;
1455 dev_info(&pdev->dev, "quirky BIOS, skipping spindown "
1456 "on poweroff and hibernation\n");
1457 }
1458
1425 port_info[0] = piix_port_info[ent->driver_data]; 1459 port_info[0] = piix_port_info[ent->driver_data];
1426 port_info[1] = piix_port_info[ent->driver_data]; 1460 port_info[1] = piix_port_info[ent->driver_data];
1427 1461
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index a1a6e6298c33..3c4c5ae277ba 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -46,6 +46,7 @@
46#include <linux/libata.h> 46#include <linux/libata.h>
47#include <linux/hdreg.h> 47#include <linux/hdreg.h>
48#include <linux/uaccess.h> 48#include <linux/uaccess.h>
49#include <linux/suspend.h>
49 50
50#include "libata.h" 51#include "libata.h"
51 52
@@ -1303,6 +1304,17 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
1303 1304
1304 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ 1305 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */
1305 } else { 1306 } else {
1307 /* Some odd clown BIOSen issue spindown on power off (ACPI S4
1308 * or S5) causing some drives to spin up and down again.
1309 */
1310 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) &&
1311 system_state == SYSTEM_POWER_OFF)
1312 goto skip;
1313
1314 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) &&
1315 system_entering_hibernation())
1316 goto skip;
1317
1306 /* XXX: This is for backward compatibility, will be 1318 /* XXX: This is for backward compatibility, will be
1307 * removed. Read Documentation/feature-removal-schedule.txt 1319 * removed. Read Documentation/feature-removal-schedule.txt
1308 * for more info. 1320 * for more info.
@@ -1326,8 +1338,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
1326 scmd->scsi_done = qc->scsidone; 1338 scmd->scsi_done = qc->scsidone;
1327 qc->scsidone = ata_delayed_done; 1339 qc->scsidone = ata_delayed_done;
1328 } 1340 }
1329 scmd->result = SAM_STAT_GOOD; 1341 goto skip;
1330 return 1;
1331 } 1342 }
1332 1343
1333 /* Issue ATA STANDBY IMMEDIATE command */ 1344 /* Issue ATA STANDBY IMMEDIATE command */
@@ -1343,10 +1354,13 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
1343 1354
1344 return 0; 1355 return 0;
1345 1356
1346invalid_fld: 1357 invalid_fld:
1347 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0); 1358 ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0);
1348 /* "Invalid field in cbd" */ 1359 /* "Invalid field in cbd" */
1349 return 1; 1360 return 1;
1361 skip:
1362 scmd->result = SAM_STAT_GOOD;
1363 return 1;
1350} 1364}
1351 1365
1352 1366
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 5a4aad123c42..0b299b0f8172 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1322,7 +1322,7 @@ fsm_start:
1322 * condition. Mark hint. 1322 * condition. Mark hint.
1323 */ 1323 */
1324 ata_ehi_push_desc(ehi, "ST-ATA: " 1324 ata_ehi_push_desc(ehi, "ST-ATA: "
1325 "DRQ=1 with device error, " 1325 "DRQ=0 without device error, "
1326 "dev_stat 0x%X", status); 1326 "dev_stat 0x%X", status);
1327 qc->err_mask |= AC_ERR_HSM | 1327 qc->err_mask |= AC_ERR_HSM |
1328 AC_ERR_NODEV_HINT; 1328 AC_ERR_NODEV_HINT;
@@ -1358,6 +1358,16 @@ fsm_start:
1358 qc->err_mask |= AC_ERR_HSM; 1358 qc->err_mask |= AC_ERR_HSM;
1359 } 1359 }
1360 1360
1361 /* There are oddball controllers with
1362 * status register stuck at 0x7f and
1363 * lbal/m/h at zero which makes it
1364 * pass all other presence detection
1365 * mechanisms we have. Set NODEV_HINT
1366 * for it. Kernel bz#7241.
1367 */
1368 if (status == 0x7f)
1369 qc->err_mask |= AC_ERR_NODEV_HINT;
1370
1361 /* ata_pio_sectors() might change the 1371 /* ata_pio_sectors() might change the
1362 * state to HSM_ST_LAST. so, the state 1372 * state to HSM_ST_LAST. so, the state
1363 * is changed after ata_pio_sectors(). 1373 * is changed after ata_pio_sectors().
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index c2e6fb9f2ef9..ebfcda26d639 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -63,8 +63,6 @@ static inline void rb532_pata_finish_io(struct ata_port *ap)
63 ata_sff_sync might be sufficient. */ 63 ata_sff_sync might be sufficient. */
64 ata_sff_dma_pause(ap); 64 ata_sff_dma_pause(ap);
65 ndelay(RB500_CF_IO_DELAY); 65 ndelay(RB500_CF_IO_DELAY);
66
67 set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
68} 66}
69 67
70static void rb532_pata_exec_command(struct ata_port *ap, 68static void rb532_pata_exec_command(struct ata_port *ap,
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 681169c9c640..79a6c9a0b721 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -86,6 +86,10 @@ enum {
86 VIA_SATA_PATA = 0x800, /* SATA/PATA combined configuration */ 86 VIA_SATA_PATA = 0x800, /* SATA/PATA combined configuration */
87}; 87};
88 88
89enum {
90 VIA_IDFLAG_SINGLE = (1 << 0), /* single channel controller) */
91};
92
89/* 93/*
90 * VIA SouthBridge chips. 94 * VIA SouthBridge chips.
91 */ 95 */
@@ -97,8 +101,12 @@ static const struct via_isa_bridge {
97 u8 rev_max; 101 u8 rev_max;
98 u16 flags; 102 u16 flags;
99} via_isa_bridges[] = { 103} via_isa_bridges[] = {
104 { "vx855", PCI_DEVICE_ID_VIA_VX855, 0x00, 0x2f,
105 VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA },
100 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 | 106 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 |
101 VIA_BAD_AST | VIA_SATA_PATA }, 107 VIA_BAD_AST | VIA_SATA_PATA },
108 { "vt8261", PCI_DEVICE_ID_VIA_8261, 0x00, 0x2f,
109 VIA_UDMA_133 | VIA_BAD_AST },
102 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 110 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
103 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 111 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
104 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA }, 112 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA },
@@ -122,6 +130,8 @@ static const struct via_isa_bridge {
122 { "vt82c586", PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, VIA_UDMA_NONE | VIA_SET_FIFO }, 130 { "vt82c586", PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, VIA_UDMA_NONE | VIA_SET_FIFO },
123 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK }, 131 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK },
124 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK | VIA_BAD_ID }, 132 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK | VIA_BAD_ID },
133 { "vtxxxx", PCI_DEVICE_ID_VIA_ANON, 0x00, 0x2f,
134 VIA_UDMA_133 | VIA_BAD_AST },
125 { NULL } 135 { NULL }
126}; 136};
127 137
@@ -460,6 +470,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
460 static int printed_version; 470 static int printed_version;
461 u8 enable; 471 u8 enable;
462 u32 timing; 472 u32 timing;
473 unsigned long flags = id->driver_data;
463 int rc; 474 int rc;
464 475
465 if (!printed_version++) 476 if (!printed_version++)
@@ -469,9 +480,13 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
469 if (rc) 480 if (rc)
470 return rc; 481 return rc;
471 482
483 if (flags & VIA_IDFLAG_SINGLE)
484 ppi[1] = &ata_dummy_port_info;
485
472 /* To find out how the IDE will behave and what features we 486 /* To find out how the IDE will behave and what features we
473 actually have to look at the bridge not the IDE controller */ 487 actually have to look at the bridge not the IDE controller */
474 for (config = via_isa_bridges; config->id; config++) 488 for (config = via_isa_bridges; config->id != PCI_DEVICE_ID_VIA_ANON;
489 config++)
475 if ((isa = pci_get_device(PCI_VENDOR_ID_VIA + 490 if ((isa = pci_get_device(PCI_VENDOR_ID_VIA +
476 !!(config->flags & VIA_BAD_ID), 491 !!(config->flags & VIA_BAD_ID),
477 config->id, NULL))) { 492 config->id, NULL))) {
@@ -482,10 +497,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
482 pci_dev_put(isa); 497 pci_dev_put(isa);
483 } 498 }
484 499
485 if (!config->id) {
486 printk(KERN_WARNING "via: Unknown VIA SouthBridge, disabling.\n");
487 return -ENODEV;
488 }
489 pci_dev_put(isa); 500 pci_dev_put(isa);
490 501
491 if (!(config->flags & VIA_NO_ENABLES)) { 502 if (!(config->flags & VIA_NO_ENABLES)) {
@@ -587,6 +598,7 @@ static const struct pci_device_id via[] = {
587 { PCI_VDEVICE(VIA, 0x1571), }, 598 { PCI_VDEVICE(VIA, 0x1571), },
588 { PCI_VDEVICE(VIA, 0x3164), }, 599 { PCI_VDEVICE(VIA, 0x3164), },
589 { PCI_VDEVICE(VIA, 0x5324), }, 600 { PCI_VDEVICE(VIA, 0x5324), },
601 { PCI_VDEVICE(VIA, 0xC409), VIA_IDFLAG_SINGLE },
590 602
591 { }, 603 { },
592}; 604};
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 86918634a4c5..f2d8a020ea53 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -33,10 +33,6 @@
33 * 33 *
34 * --> ATAPI support (Marvell claims the 60xx/70xx chips can do it). 34 * --> ATAPI support (Marvell claims the 60xx/70xx chips can do it).
35 * 35 *
36 * --> Investigate problems with PCI Message Signalled Interrupts (MSI).
37 *
38 * --> Cache frequently-accessed registers in mv_port_priv to reduce overhead.
39 *
40 * --> Develop a low-power-consumption strategy, and implement it. 36 * --> Develop a low-power-consumption strategy, and implement it.
41 * 37 *
42 * --> [Experiment, low priority] Investigate interrupt coalescing. 38 * --> [Experiment, low priority] Investigate interrupt coalescing.
@@ -72,7 +68,7 @@
72#include <linux/libata.h> 68#include <linux/libata.h>
73 69
74#define DRV_NAME "sata_mv" 70#define DRV_NAME "sata_mv"
75#define DRV_VERSION "1.24" 71#define DRV_VERSION "1.25"
76 72
77enum { 73enum {
78 /* BAR's are enumerated in terms of pci_resource_start() terms */ 74 /* BAR's are enumerated in terms of pci_resource_start() terms */
@@ -351,8 +347,6 @@ enum {
351 347
352 EDMA_HALTCOND_OFS = 0x60, /* GenIIe halt conditions */ 348 EDMA_HALTCOND_OFS = 0x60, /* GenIIe halt conditions */
353 349
354 GEN_II_NCQ_MAX_SECTORS = 256, /* max sects/io on Gen2 w/NCQ */
355
356 /* Host private flags (hp_flags) */ 350 /* Host private flags (hp_flags) */
357 MV_HP_FLAG_MSI = (1 << 0), 351 MV_HP_FLAG_MSI = (1 << 0),
358 MV_HP_ERRATA_50XXB0 = (1 << 1), 352 MV_HP_ERRATA_50XXB0 = (1 << 1),
@@ -883,19 +877,15 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio,
883 struct mv_host_priv *hpriv = ap->host->private_data; 877 struct mv_host_priv *hpriv = ap->host->private_data;
884 int hardport = mv_hardport_from_port(ap->port_no); 878 int hardport = mv_hardport_from_port(ap->port_no);
885 void __iomem *hc_mmio = mv_hc_base_from_port( 879 void __iomem *hc_mmio = mv_hc_base_from_port(
886 mv_host_base(ap->host), hardport); 880 mv_host_base(ap->host), ap->port_no);
887 u32 hc_irq_cause, ipending; 881 u32 hc_irq_cause;
888 882
889 /* clear EDMA event indicators, if any */ 883 /* clear EDMA event indicators, if any */
890 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 884 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
891 885
892 /* clear EDMA interrupt indicator, if any */ 886 /* clear pending irq events */
893 hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); 887 hc_irq_cause = ~((DEV_IRQ | DMA_IRQ) << hardport);
894 ipending = (DEV_IRQ | DMA_IRQ) << hardport; 888 writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS);
895 if (hc_irq_cause & ipending) {
896 writelfl(hc_irq_cause & ~ipending,
897 hc_mmio + HC_IRQ_CAUSE_OFS);
898 }
899 889
900 mv_edma_cfg(ap, want_ncq); 890 mv_edma_cfg(ap, want_ncq);
901 891
@@ -1099,20 +1089,12 @@ static void mv6_dev_config(struct ata_device *adev)
1099 * 1089 *
1100 * Gen-II does not support NCQ over a port multiplier 1090 * Gen-II does not support NCQ over a port multiplier
1101 * (no FIS-based switching). 1091 * (no FIS-based switching).
1102 *
1103 * We don't have hob_nsect when doing NCQ commands on Gen-II.
1104 * See mv_qc_prep() for more info.
1105 */ 1092 */
1106 if (adev->flags & ATA_DFLAG_NCQ) { 1093 if (adev->flags & ATA_DFLAG_NCQ) {
1107 if (sata_pmp_attached(adev->link->ap)) { 1094 if (sata_pmp_attached(adev->link->ap)) {
1108 adev->flags &= ~ATA_DFLAG_NCQ; 1095 adev->flags &= ~ATA_DFLAG_NCQ;
1109 ata_dev_printk(adev, KERN_INFO, 1096 ata_dev_printk(adev, KERN_INFO,
1110 "NCQ disabled for command-based switching\n"); 1097 "NCQ disabled for command-based switching\n");
1111 } else if (adev->max_sectors > GEN_II_NCQ_MAX_SECTORS) {
1112 adev->max_sectors = GEN_II_NCQ_MAX_SECTORS;
1113 ata_dev_printk(adev, KERN_INFO,
1114 "max_sectors limited to %u for NCQ\n",
1115 adev->max_sectors);
1116 } 1098 }
1117 } 1099 }
1118} 1100}
@@ -1450,7 +1432,8 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
1450 * only 11 bytes...so we must pick and choose required 1432 * only 11 bytes...so we must pick and choose required
1451 * registers based on the command. So, we drop feature and 1433 * registers based on the command. So, we drop feature and
1452 * hob_feature for [RW] DMA commands, but they are needed for 1434 * hob_feature for [RW] DMA commands, but they are needed for
1453 * NCQ. NCQ will drop hob_nsect. 1435 * NCQ. NCQ will drop hob_nsect, which is not needed there
1436 * (nsect is used only for the tag; feat/hob_feat hold true nsect).
1454 */ 1437 */
1455 switch (tf->command) { 1438 switch (tf->command) {
1456 case ATA_CMD_READ: 1439 case ATA_CMD_READ:
@@ -2214,9 +2197,15 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance)
2214 struct ata_host *host = dev_instance; 2197 struct ata_host *host = dev_instance;
2215 struct mv_host_priv *hpriv = host->private_data; 2198 struct mv_host_priv *hpriv = host->private_data;
2216 unsigned int handled = 0; 2199 unsigned int handled = 0;
2200 int using_msi = hpriv->hp_flags & MV_HP_FLAG_MSI;
2217 u32 main_irq_cause, pending_irqs; 2201 u32 main_irq_cause, pending_irqs;
2218 2202
2219 spin_lock(&host->lock); 2203 spin_lock(&host->lock);
2204
2205 /* for MSI: block new interrupts while in here */
2206 if (using_msi)
2207 writel(0, hpriv->main_irq_mask_addr);
2208
2220 main_irq_cause = readl(hpriv->main_irq_cause_addr); 2209 main_irq_cause = readl(hpriv->main_irq_cause_addr);
2221 pending_irqs = main_irq_cause & hpriv->main_irq_mask; 2210 pending_irqs = main_irq_cause & hpriv->main_irq_mask;
2222 /* 2211 /*
@@ -2230,6 +2219,11 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance)
2230 handled = mv_host_intr(host, pending_irqs); 2219 handled = mv_host_intr(host, pending_irqs);
2231 } 2220 }
2232 spin_unlock(&host->lock); 2221 spin_unlock(&host->lock);
2222
2223 /* for MSI: unmask; interrupt cause bits will retrigger now */
2224 if (using_msi)
2225 writel(hpriv->main_irq_mask, hpriv->main_irq_mask_addr);
2226
2233 return IRQ_RETVAL(handled); 2227 return IRQ_RETVAL(handled);
2234} 2228}
2235 2229
@@ -2821,8 +2815,7 @@ static void mv_eh_thaw(struct ata_port *ap)
2821 writel(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 2815 writel(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
2822 2816
2823 /* clear pending irq events */ 2817 /* clear pending irq events */
2824 hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); 2818 hc_irq_cause = ~((DEV_IRQ | DMA_IRQ) << hardport);
2825 hc_irq_cause &= ~((DEV_IRQ | DMA_IRQ) << hardport);
2826 writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); 2819 writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS);
2827 2820
2828 mv_enable_port_irqs(ap, ERR_IRQ); 2821 mv_enable_port_irqs(ap, ERR_IRQ);
@@ -3075,6 +3068,9 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx)
3075 hpriv->main_irq_mask_addr = mmio + PCI_HC_MAIN_IRQ_MASK_OFS; 3068 hpriv->main_irq_mask_addr = mmio + PCI_HC_MAIN_IRQ_MASK_OFS;
3076 } 3069 }
3077 3070
3071 /* initialize shadow irq mask with register's value */
3072 hpriv->main_irq_mask = readl(hpriv->main_irq_mask_addr);
3073
3078 /* global interrupt mask: 0 == mask everything */ 3074 /* global interrupt mask: 0 == mask everything */
3079 mv_set_main_irq_mask(host, ~0, 0); 3075 mv_set_main_irq_mask(host, ~0, 0);
3080 3076
@@ -3430,9 +3426,9 @@ static int mv_pci_init_one(struct pci_dev *pdev,
3430 if (rc) 3426 if (rc)
3431 return rc; 3427 return rc;
3432 3428
3433 /* Enable interrupts */ 3429 /* Enable message-switched interrupts, if requested */
3434 if (msi && pci_enable_msi(pdev)) 3430 if (msi && pci_enable_msi(pdev) == 0)
3435 pci_intx(pdev, 1); 3431 hpriv->hp_flags |= MV_HP_FLAG_MSI;
3436 3432
3437 mv_dump_pci_cfg(pdev, 0x68); 3433 mv_dump_pci_cfg(pdev, 0x68);
3438 mv_print_info(host); 3434 mv_print_info(host);
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 6f1460614325..c49ad0e61b6f 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -305,10 +305,10 @@ static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance);
305static int nv_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); 305static int nv_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
306static int nv_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); 306static int nv_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
307 307
308static int nv_noclassify_hardreset(struct ata_link *link, unsigned int *class,
309 unsigned long deadline);
308static void nv_nf2_freeze(struct ata_port *ap); 310static void nv_nf2_freeze(struct ata_port *ap);
309static void nv_nf2_thaw(struct ata_port *ap); 311static void nv_nf2_thaw(struct ata_port *ap);
310static int nv_nf2_hardreset(struct ata_link *link, unsigned int *class,
311 unsigned long deadline);
312static void nv_ck804_freeze(struct ata_port *ap); 312static void nv_ck804_freeze(struct ata_port *ap);
313static void nv_ck804_thaw(struct ata_port *ap); 313static void nv_ck804_thaw(struct ata_port *ap);
314static int nv_adma_slave_config(struct scsi_device *sdev); 314static int nv_adma_slave_config(struct scsi_device *sdev);
@@ -352,6 +352,7 @@ enum nv_host_type
352 NFORCE3 = NFORCE2, /* NF2 == NF3 as far as sata_nv is concerned */ 352 NFORCE3 = NFORCE2, /* NF2 == NF3 as far as sata_nv is concerned */
353 CK804, 353 CK804,
354 ADMA, 354 ADMA,
355 MCP5x,
355 SWNCQ, 356 SWNCQ,
356}; 357};
357 358
@@ -363,10 +364,10 @@ static const struct pci_device_id nv_pci_tbl[] = {
363 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2), CK804 }, 364 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2), CK804 },
364 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA), CK804 }, 365 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA), CK804 },
365 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2), CK804 }, 366 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2), CK804 },
366 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA), SWNCQ }, 367 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA), MCP5x },
367 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2), SWNCQ }, 368 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2), MCP5x },
368 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA), SWNCQ }, 369 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA), MCP5x },
369 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2), SWNCQ }, 370 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2), MCP5x },
370 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, 371 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC },
371 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, 372 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC },
372 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, 373 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC },
@@ -432,7 +433,7 @@ static struct ata_port_operations nv_nf2_ops = {
432 .inherits = &nv_common_ops, 433 .inherits = &nv_common_ops,
433 .freeze = nv_nf2_freeze, 434 .freeze = nv_nf2_freeze,
434 .thaw = nv_nf2_thaw, 435 .thaw = nv_nf2_thaw,
435 .hardreset = nv_nf2_hardreset, 436 .hardreset = nv_noclassify_hardreset,
436}; 437};
437 438
438/* CK804 finally gets hardreset right */ 439/* CK804 finally gets hardreset right */
@@ -467,8 +468,19 @@ static struct ata_port_operations nv_adma_ops = {
467 .host_stop = nv_adma_host_stop, 468 .host_stop = nv_adma_host_stop,
468}; 469};
469 470
471/* Kernel bz#12351 reports that when SWNCQ is enabled, for hotplug to
472 * work, hardreset should be used and hardreset can't report proper
473 * signature, which suggests that mcp5x is closer to nf2 as long as
474 * reset quirkiness is concerned. Define separate ops for mcp5x with
475 * nv_noclassify_hardreset().
476 */
477static struct ata_port_operations nv_mcp5x_ops = {
478 .inherits = &nv_common_ops,
479 .hardreset = nv_noclassify_hardreset,
480};
481
470static struct ata_port_operations nv_swncq_ops = { 482static struct ata_port_operations nv_swncq_ops = {
471 .inherits = &nv_generic_ops, 483 .inherits = &nv_mcp5x_ops,
472 484
473 .qc_defer = ata_std_qc_defer, 485 .qc_defer = ata_std_qc_defer,
474 .qc_prep = nv_swncq_qc_prep, 486 .qc_prep = nv_swncq_qc_prep,
@@ -531,6 +543,15 @@ static const struct ata_port_info nv_port_info[] = {
531 .port_ops = &nv_adma_ops, 543 .port_ops = &nv_adma_ops,
532 .private_data = NV_PI_PRIV(nv_adma_interrupt, &nv_adma_sht), 544 .private_data = NV_PI_PRIV(nv_adma_interrupt, &nv_adma_sht),
533 }, 545 },
546 /* MCP5x */
547 {
548 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
549 .pio_mask = NV_PIO_MASK,
550 .mwdma_mask = NV_MWDMA_MASK,
551 .udma_mask = NV_UDMA_MASK,
552 .port_ops = &nv_mcp5x_ops,
553 .private_data = NV_PI_PRIV(nv_generic_interrupt, &nv_sht),
554 },
534 /* SWNCQ */ 555 /* SWNCQ */
535 { 556 {
536 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 557 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
@@ -1530,6 +1551,17 @@ static int nv_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
1530 return 0; 1551 return 0;
1531} 1552}
1532 1553
1554static int nv_noclassify_hardreset(struct ata_link *link, unsigned int *class,
1555 unsigned long deadline)
1556{
1557 bool online;
1558 int rc;
1559
1560 rc = sata_link_hardreset(link, sata_deb_timing_hotplug, deadline,
1561 &online, NULL);
1562 return online ? -EAGAIN : rc;
1563}
1564
1533static void nv_nf2_freeze(struct ata_port *ap) 1565static void nv_nf2_freeze(struct ata_port *ap)
1534{ 1566{
1535 void __iomem *scr_addr = ap->host->ports[0]->ioaddr.scr_addr; 1567 void __iomem *scr_addr = ap->host->ports[0]->ioaddr.scr_addr;
@@ -1554,17 +1586,6 @@ static void nv_nf2_thaw(struct ata_port *ap)
1554 iowrite8(mask, scr_addr + NV_INT_ENABLE); 1586 iowrite8(mask, scr_addr + NV_INT_ENABLE);
1555} 1587}
1556 1588
1557static int nv_nf2_hardreset(struct ata_link *link, unsigned int *class,
1558 unsigned long deadline)
1559{
1560 bool online;
1561 int rc;
1562
1563 rc = sata_link_hardreset(link, sata_deb_timing_hotplug, deadline,
1564 &online, NULL);
1565 return online ? -EAGAIN : rc;
1566}
1567
1568static void nv_ck804_freeze(struct ata_port *ap) 1589static void nv_ck804_freeze(struct ata_port *ap)
1569{ 1590{
1570 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; 1591 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR];
@@ -2355,14 +2376,9 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2355 if (type == CK804 && adma_enabled) { 2376 if (type == CK804 && adma_enabled) {
2356 dev_printk(KERN_NOTICE, &pdev->dev, "Using ADMA mode\n"); 2377 dev_printk(KERN_NOTICE, &pdev->dev, "Using ADMA mode\n");
2357 type = ADMA; 2378 type = ADMA;
2358 } 2379 } else if (type == MCP5x && swncq_enabled) {
2359 2380 dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ mode\n");
2360 if (type == SWNCQ) { 2381 type = SWNCQ;
2361 if (swncq_enabled)
2362 dev_printk(KERN_NOTICE, &pdev->dev,
2363 "Using SWNCQ mode\n");
2364 else
2365 type = GENERIC;
2366 } 2382 }
2367 2383
2368 ppi[0] = &nv_port_info[type]; 2384 ppi[0] = &nv_port_info[type];
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 564c142b03b0..9f029595f454 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -44,6 +44,7 @@
44#include <linux/device.h> 44#include <linux/device.h>
45#include <scsi/scsi_host.h> 45#include <scsi/scsi_host.h>
46#include <linux/libata.h> 46#include <linux/libata.h>
47#include <linux/dmi.h>
47 48
48#define DRV_NAME "sata_sil" 49#define DRV_NAME "sata_sil"
49#define DRV_VERSION "2.4" 50#define DRV_VERSION "2.4"
@@ -695,11 +696,38 @@ static void sil_init_controller(struct ata_host *host)
695 } 696 }
696} 697}
697 698
699static bool sil_broken_system_poweroff(struct pci_dev *pdev)
700{
701 static const struct dmi_system_id broken_systems[] = {
702 {
703 .ident = "HP Compaq nx6325",
704 .matches = {
705 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
706 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
707 },
708 /* PCI slot number of the controller */
709 .driver_data = (void *)0x12UL,
710 },
711
712 { } /* terminate list */
713 };
714 const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
715
716 if (dmi) {
717 unsigned long slot = (unsigned long)dmi->driver_data;
718 /* apply the quirk only to on-board controllers */
719 return slot == PCI_SLOT(pdev->devfn);
720 }
721
722 return false;
723}
724
698static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 725static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
699{ 726{
700 static int printed_version; 727 static int printed_version;
701 int board_id = ent->driver_data; 728 int board_id = ent->driver_data;
702 const struct ata_port_info *ppi[] = { &sil_port_info[board_id], NULL }; 729 struct ata_port_info pi = sil_port_info[board_id];
730 const struct ata_port_info *ppi[] = { &pi, NULL };
703 struct ata_host *host; 731 struct ata_host *host;
704 void __iomem *mmio_base; 732 void __iomem *mmio_base;
705 int n_ports, rc; 733 int n_ports, rc;
@@ -713,6 +741,13 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
713 if (board_id == sil_3114) 741 if (board_id == sil_3114)
714 n_ports = 4; 742 n_ports = 4;
715 743
744 if (sil_broken_system_poweroff(pdev)) {
745 pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN |
746 ATA_FLAG_NO_HIBERNATE_SPINDOWN;
747 dev_info(&pdev->dev, "quirky BIOS, skipping spindown "
748 "on poweroff and hibernation\n");
749 }
750
716 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); 751 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
717 if (!host) 752 if (!host)
718 return -ENOMEM; 753 return -ENOMEM;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 55e530942ab0..f3eae630e589 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1280,7 +1280,7 @@ EXPORT_SYMBOL_GPL(__root_device_register);
1280 1280
1281/** 1281/**
1282 * root_device_unregister - unregister and free a root device 1282 * root_device_unregister - unregister and free a root device
1283 * @root: device going away. 1283 * @dev: device going away
1284 * 1284 *
1285 * This function unregisters and cleans up a device that was created by 1285 * This function unregisters and cleans up a device that was created by
1286 * root_device_register(). 1286 * root_device_register().
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index d33e5ab06177..bc84e125c6bc 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1817,8 +1817,10 @@ got_driver:
1817 /* check whether we're reopening an existing tty */ 1817 /* check whether we're reopening an existing tty */
1818 tty = tty_driver_lookup_tty(driver, inode, index); 1818 tty = tty_driver_lookup_tty(driver, inode, index);
1819 1819
1820 if (IS_ERR(tty)) 1820 if (IS_ERR(tty)) {
1821 mutex_unlock(&tty_mutex);
1821 return PTR_ERR(tty); 1822 return PTR_ERR(tty);
1823 }
1822 } 1824 }
1823 1825
1824 if (tty) { 1826 if (tty) {
diff --git a/drivers/edac/cell_edac.c b/drivers/edac/cell_edac.c
index cd2e3b8087e7..24f3ca851523 100644
--- a/drivers/edac/cell_edac.c
+++ b/drivers/edac/cell_edac.c
@@ -36,7 +36,7 @@ static void cell_edac_count_ce(struct mem_ctl_info *mci, int chan, u64 ar)
36 struct csrow_info *csrow = &mci->csrows[0]; 36 struct csrow_info *csrow = &mci->csrows[0];
37 unsigned long address, pfn, offset, syndrome; 37 unsigned long address, pfn, offset, syndrome;
38 38
39 dev_dbg(mci->dev, "ECC CE err on node %d, channel %d, ar = 0x%016lx\n", 39 dev_dbg(mci->dev, "ECC CE err on node %d, channel %d, ar = 0x%016llx\n",
40 priv->node, chan, ar); 40 priv->node, chan, ar);
41 41
42 /* Address decoding is likely a bit bogus, to dbl check */ 42 /* Address decoding is likely a bit bogus, to dbl check */
@@ -58,7 +58,7 @@ static void cell_edac_count_ue(struct mem_ctl_info *mci, int chan, u64 ar)
58 struct csrow_info *csrow = &mci->csrows[0]; 58 struct csrow_info *csrow = &mci->csrows[0];
59 unsigned long address, pfn, offset; 59 unsigned long address, pfn, offset;
60 60
61 dev_dbg(mci->dev, "ECC UE err on node %d, channel %d, ar = 0x%016lx\n", 61 dev_dbg(mci->dev, "ECC UE err on node %d, channel %d, ar = 0x%016llx\n",
62 priv->node, chan, ar); 62 priv->node, chan, ar);
63 63
64 /* Address decoding is likely a bit bogus, to dbl check */ 64 /* Address decoding is likely a bit bogus, to dbl check */
@@ -169,7 +169,7 @@ static int __devinit cell_edac_probe(struct platform_device *pdev)
169 169
170 /* Get channel population */ 170 /* Get channel population */
171 reg = in_be64(&regs->mic_mnt_cfg); 171 reg = in_be64(&regs->mic_mnt_cfg);
172 dev_dbg(&pdev->dev, "MIC_MNT_CFG = 0x%016lx\n", reg); 172 dev_dbg(&pdev->dev, "MIC_MNT_CFG = 0x%016llx\n", reg);
173 chanmask = 0; 173 chanmask = 0;
174 if (reg & CBE_MIC_MNT_CFG_CHAN_0_POP) 174 if (reg & CBE_MIC_MNT_CFG_CHAN_0_POP)
175 chanmask |= 0x1; 175 chanmask |= 0x1;
@@ -180,7 +180,7 @@ static int __devinit cell_edac_probe(struct platform_device *pdev)
180 "Yuck ! No channel populated ? Aborting !\n"); 180 "Yuck ! No channel populated ? Aborting !\n");
181 return -ENODEV; 181 return -ENODEV;
182 } 182 }
183 dev_dbg(&pdev->dev, "Initial FIR = 0x%016lx\n", 183 dev_dbg(&pdev->dev, "Initial FIR = 0x%016llx\n",
184 in_be64(&regs->mic_fir)); 184 in_be64(&regs->mic_fir));
185 185
186 /* Allocate & init EDAC MC data structure */ 186 /* Allocate & init EDAC MC data structure */
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 6bd91a15d5e6..7be2cf3514e7 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -232,7 +232,7 @@ fw_card_bm_work(struct work_struct *work)
232 root_id = root_node->node_id; 232 root_id = root_node->node_id;
233 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); 233 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10));
234 234
235 if (card->bm_generation + 1 == generation || 235 if (is_next_generation(generation, card->bm_generation) ||
236 (card->bm_generation != generation && grace)) { 236 (card->bm_generation != generation && grace)) {
237 /* 237 /*
238 * This first step is to figure out who is IRM and 238 * This first step is to figure out who is IRM and
@@ -512,7 +512,7 @@ fw_core_remove_card(struct fw_card *card)
512 fw_core_initiate_bus_reset(card, 1); 512 fw_core_initiate_bus_reset(card, 1);
513 513
514 mutex_lock(&card_mutex); 514 mutex_lock(&card_mutex);
515 list_del(&card->link); 515 list_del_init(&card->link);
516 mutex_unlock(&card_mutex); 516 mutex_unlock(&card_mutex);
517 517
518 /* Set up the dummy driver. */ 518 /* Set up the dummy driver. */
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 2af5a8d1e012..bf53acb45652 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -25,6 +25,7 @@
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/jiffies.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/rwsem.h> 30#include <linux/rwsem.h>
30#include <linux/semaphore.h> 31#include <linux/semaphore.h>
@@ -634,12 +635,39 @@ struct fw_device *fw_device_get_by_devt(dev_t devt)
634 return device; 635 return device;
635} 636}
636 637
638/*
639 * These defines control the retry behavior for reading the config
640 * rom. It shouldn't be necessary to tweak these; if the device
641 * doesn't respond to a config rom read within 10 seconds, it's not
642 * going to respond at all. As for the initial delay, a lot of
643 * devices will be able to respond within half a second after bus
644 * reset. On the other hand, it's not really worth being more
645 * aggressive than that, since it scales pretty well; if 10 devices
646 * are plugged in, they're all getting read within one second.
647 */
648
649#define MAX_RETRIES 10
650#define RETRY_DELAY (3 * HZ)
651#define INITIAL_DELAY (HZ / 2)
652#define SHUTDOWN_DELAY (2 * HZ)
653
637static void fw_device_shutdown(struct work_struct *work) 654static void fw_device_shutdown(struct work_struct *work)
638{ 655{
639 struct fw_device *device = 656 struct fw_device *device =
640 container_of(work, struct fw_device, work.work); 657 container_of(work, struct fw_device, work.work);
641 int minor = MINOR(device->device.devt); 658 int minor = MINOR(device->device.devt);
642 659
660 if (time_is_after_jiffies(device->card->reset_jiffies + SHUTDOWN_DELAY)
661 && !list_empty(&device->card->link)) {
662 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
663 return;
664 }
665
666 if (atomic_cmpxchg(&device->state,
667 FW_DEVICE_GONE,
668 FW_DEVICE_SHUTDOWN) != FW_DEVICE_GONE)
669 return;
670
643 fw_device_cdev_remove(device); 671 fw_device_cdev_remove(device);
644 device_for_each_child(&device->device, NULL, shutdown_unit); 672 device_for_each_child(&device->device, NULL, shutdown_unit);
645 device_unregister(&device->device); 673 device_unregister(&device->device);
@@ -647,6 +675,7 @@ static void fw_device_shutdown(struct work_struct *work)
647 down_write(&fw_device_rwsem); 675 down_write(&fw_device_rwsem);
648 idr_remove(&fw_device_idr, minor); 676 idr_remove(&fw_device_idr, minor);
649 up_write(&fw_device_rwsem); 677 up_write(&fw_device_rwsem);
678
650 fw_device_put(device); 679 fw_device_put(device);
651} 680}
652 681
@@ -654,25 +683,63 @@ static struct device_type fw_device_type = {
654 .release = fw_device_release, 683 .release = fw_device_release,
655}; 684};
656 685
686static void fw_device_update(struct work_struct *work);
687
657/* 688/*
658 * These defines control the retry behavior for reading the config 689 * If a device was pending for deletion because its node went away but its
659 * rom. It shouldn't be necessary to tweak these; if the device 690 * bus info block and root directory header matches that of a newly discovered
660 * doesn't respond to a config rom read within 10 seconds, it's not 691 * device, revive the existing fw_device.
661 * going to respond at all. As for the initial delay, a lot of 692 * The newly allocated fw_device becomes obsolete instead.
662 * devices will be able to respond within half a second after bus
663 * reset. On the other hand, it's not really worth being more
664 * aggressive than that, since it scales pretty well; if 10 devices
665 * are plugged in, they're all getting read within one second.
666 */ 693 */
694static int lookup_existing_device(struct device *dev, void *data)
695{
696 struct fw_device *old = fw_device(dev);
697 struct fw_device *new = data;
698 struct fw_card *card = new->card;
699 int match = 0;
700
701 down_read(&fw_device_rwsem); /* serialize config_rom access */
702 spin_lock_irq(&card->lock); /* serialize node access */
703
704 if (memcmp(old->config_rom, new->config_rom, 6 * 4) == 0 &&
705 atomic_cmpxchg(&old->state,
706 FW_DEVICE_GONE,
707 FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
708 struct fw_node *current_node = new->node;
709 struct fw_node *obsolete_node = old->node;
710
711 new->node = obsolete_node;
712 new->node->data = new;
713 old->node = current_node;
714 old->node->data = old;
715
716 old->max_speed = new->max_speed;
717 old->node_id = current_node->node_id;
718 smp_wmb(); /* update node_id before generation */
719 old->generation = card->generation;
720 old->config_rom_retries = 0;
721 fw_notify("rediscovered device %s\n", dev_name(dev));
667 722
668#define MAX_RETRIES 10 723 PREPARE_DELAYED_WORK(&old->work, fw_device_update);
669#define RETRY_DELAY (3 * HZ) 724 schedule_delayed_work(&old->work, 0);
670#define INITIAL_DELAY (HZ / 2) 725
726 if (current_node == card->root_node)
727 fw_schedule_bm_work(card, 0);
728
729 match = 1;
730 }
731
732 spin_unlock_irq(&card->lock);
733 up_read(&fw_device_rwsem);
734
735 return match;
736}
671 737
672static void fw_device_init(struct work_struct *work) 738static void fw_device_init(struct work_struct *work)
673{ 739{
674 struct fw_device *device = 740 struct fw_device *device =
675 container_of(work, struct fw_device, work.work); 741 container_of(work, struct fw_device, work.work);
742 struct device *revived_dev;
676 int minor, err; 743 int minor, err;
677 744
678 /* 745 /*
@@ -696,6 +763,15 @@ static void fw_device_init(struct work_struct *work)
696 return; 763 return;
697 } 764 }
698 765
766 revived_dev = device_find_child(device->card->device,
767 device, lookup_existing_device);
768 if (revived_dev) {
769 put_device(revived_dev);
770 fw_device_release(&device->device);
771
772 return;
773 }
774
699 device_initialize(&device->device); 775 device_initialize(&device->device);
700 776
701 fw_device_get(device); 777 fw_device_get(device);
@@ -734,9 +810,10 @@ static void fw_device_init(struct work_struct *work)
734 * fw_node_event(). 810 * fw_node_event().
735 */ 811 */
736 if (atomic_cmpxchg(&device->state, 812 if (atomic_cmpxchg(&device->state,
737 FW_DEVICE_INITIALIZING, 813 FW_DEVICE_INITIALIZING,
738 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) { 814 FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
739 fw_device_shutdown(work); 815 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
816 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
740 } else { 817 } else {
741 if (device->config_rom_retries) 818 if (device->config_rom_retries)
742 fw_notify("created device %s: GUID %08x%08x, S%d00, " 819 fw_notify("created device %s: GUID %08x%08x, S%d00, "
@@ -847,8 +924,8 @@ static void fw_device_refresh(struct work_struct *work)
847 924
848 case REREAD_BIB_UNCHANGED: 925 case REREAD_BIB_UNCHANGED:
849 if (atomic_cmpxchg(&device->state, 926 if (atomic_cmpxchg(&device->state,
850 FW_DEVICE_INITIALIZING, 927 FW_DEVICE_INITIALIZING,
851 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) 928 FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
852 goto gone; 929 goto gone;
853 930
854 fw_device_update(work); 931 fw_device_update(work);
@@ -879,8 +956,8 @@ static void fw_device_refresh(struct work_struct *work)
879 create_units(device); 956 create_units(device);
880 957
881 if (atomic_cmpxchg(&device->state, 958 if (atomic_cmpxchg(&device->state,
882 FW_DEVICE_INITIALIZING, 959 FW_DEVICE_INITIALIZING,
883 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) 960 FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
884 goto gone; 961 goto gone;
885 962
886 fw_notify("refreshed device %s\n", dev_name(&device->device)); 963 fw_notify("refreshed device %s\n", dev_name(&device->device));
@@ -890,8 +967,9 @@ static void fw_device_refresh(struct work_struct *work)
890 give_up: 967 give_up:
891 fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); 968 fw_notify("giving up on refresh of device %s\n", dev_name(&device->device));
892 gone: 969 gone:
893 atomic_set(&device->state, FW_DEVICE_SHUTDOWN); 970 atomic_set(&device->state, FW_DEVICE_GONE);
894 fw_device_shutdown(work); 971 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
972 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
895 out: 973 out:
896 if (node_id == card->root_node->node_id) 974 if (node_id == card->root_node->node_id)
897 fw_schedule_bm_work(card, 0); 975 fw_schedule_bm_work(card, 0);
@@ -995,9 +1073,10 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
995 */ 1073 */
996 device = node->data; 1074 device = node->data;
997 if (atomic_xchg(&device->state, 1075 if (atomic_xchg(&device->state,
998 FW_DEVICE_SHUTDOWN) == FW_DEVICE_RUNNING) { 1076 FW_DEVICE_GONE) == FW_DEVICE_RUNNING) {
999 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); 1077 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
1000 schedule_delayed_work(&device->work, 0); 1078 schedule_delayed_work(&device->work,
1079 list_empty(&card->link) ? 0 : SHUTDOWN_DELAY);
1001 } 1080 }
1002 break; 1081 break;
1003 } 1082 }
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index df51732608d9..8ef6ec2ca21c 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -28,6 +28,7 @@
28enum fw_device_state { 28enum fw_device_state {
29 FW_DEVICE_INITIALIZING, 29 FW_DEVICE_INITIALIZING,
30 FW_DEVICE_RUNNING, 30 FW_DEVICE_RUNNING,
31 FW_DEVICE_GONE,
31 FW_DEVICE_SHUTDOWN, 32 FW_DEVICE_SHUTDOWN,
32}; 33};
33 34
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index ab9c01e462ef..6d19828a93a5 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -226,7 +226,7 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
226#define CONTEXT_DEAD 0x0800 226#define CONTEXT_DEAD 0x0800
227#define CONTEXT_ACTIVE 0x0400 227#define CONTEXT_ACTIVE 0x0400
228 228
229#define OHCI1394_MAX_AT_REQ_RETRIES 0x2 229#define OHCI1394_MAX_AT_REQ_RETRIES 0xf
230#define OHCI1394_MAX_AT_RESP_RETRIES 0x2 230#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
231#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 231#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
232 232
@@ -896,11 +896,11 @@ static void context_stop(struct context *ctx)
896 for (i = 0; i < 10; i++) { 896 for (i = 0; i < 10; i++) {
897 reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); 897 reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs));
898 if ((reg & CONTEXT_ACTIVE) == 0) 898 if ((reg & CONTEXT_ACTIVE) == 0)
899 break; 899 return;
900 900
901 fw_notify("context_stop: still active (0x%08x)\n", reg);
902 mdelay(1); 901 mdelay(1);
903 } 902 }
903 fw_error("Error: DMA context still active (0x%08x)\n", reg);
904} 904}
905 905
906struct driver_data { 906struct driver_data {
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index e88d5067448c..c71c4419d9e8 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -168,6 +168,7 @@ struct sbp2_target {
168 int address_high; 168 int address_high;
169 unsigned int workarounds; 169 unsigned int workarounds;
170 unsigned int mgt_orb_timeout; 170 unsigned int mgt_orb_timeout;
171 unsigned int max_payload;
171 172
172 int dont_block; /* counter for each logical unit */ 173 int dont_block; /* counter for each logical unit */
173 int blocked; /* ditto */ 174 int blocked; /* ditto */
@@ -310,14 +311,16 @@ struct sbp2_command_orb {
310 dma_addr_t page_table_bus; 311 dma_addr_t page_table_bus;
311}; 312};
312 313
314#define SBP2_ROM_VALUE_WILDCARD ~0 /* match all */
315#define SBP2_ROM_VALUE_MISSING 0xff000000 /* not present in the unit dir. */
316
313/* 317/*
314 * List of devices with known bugs. 318 * List of devices with known bugs.
315 * 319 *
316 * The firmware_revision field, masked with 0xffff00, is the best 320 * The firmware_revision field, masked with 0xffff00, is the best
317 * indicator for the type of bridge chip of a device. It yields a few 321 * indicator for the type of bridge chip of a device. It yields a few
318 * false positives but this did not break correctly behaving devices 322 * false positives but this did not break correctly behaving devices
319 * so far. We use ~0 as a wildcard, since the 24 bit values we get 323 * so far.
320 * from the config rom can never match that.
321 */ 324 */
322static const struct { 325static const struct {
323 u32 firmware_revision; 326 u32 firmware_revision;
@@ -339,33 +342,35 @@ static const struct {
339 }, 342 },
340 /* Initio bridges, actually only needed for some older ones */ { 343 /* Initio bridges, actually only needed for some older ones */ {
341 .firmware_revision = 0x000200, 344 .firmware_revision = 0x000200,
342 .model = ~0, 345 .model = SBP2_ROM_VALUE_WILDCARD,
343 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 346 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
344 }, 347 },
345 /* PL-3507 bridge with Prolific firmware */ { 348 /* PL-3507 bridge with Prolific firmware */ {
346 .firmware_revision = 0x012800, 349 .firmware_revision = 0x012800,
347 .model = ~0, 350 .model = SBP2_ROM_VALUE_WILDCARD,
348 .workarounds = SBP2_WORKAROUND_POWER_CONDITION, 351 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
349 }, 352 },
350 /* Symbios bridge */ { 353 /* Symbios bridge */ {
351 .firmware_revision = 0xa0b800, 354 .firmware_revision = 0xa0b800,
352 .model = ~0, 355 .model = SBP2_ROM_VALUE_WILDCARD,
353 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 356 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
354 }, 357 },
355 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 358 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
356 .firmware_revision = 0x002600, 359 .firmware_revision = 0x002600,
357 .model = ~0, 360 .model = SBP2_ROM_VALUE_WILDCARD,
358 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 361 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
359 }, 362 },
360
361 /* 363 /*
362 * There are iPods (2nd gen, 3rd gen) with model_id == 0, but 364 * iPod 2nd generation: needs 128k max transfer size workaround
363 * these iPods do not feature the read_capacity bug according 365 * iPod 3rd generation: needs fix capacity workaround
364 * to one report. Read_capacity behaviour as well as model_id
365 * could change due to Apple-supplied firmware updates though.
366 */ 366 */
367 367 {
368 /* iPod 4th generation. */ { 368 .firmware_revision = 0x0a2700,
369 .model = 0x000000,
370 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS |
371 SBP2_WORKAROUND_FIX_CAPACITY,
372 },
373 /* iPod 4th generation */ {
369 .firmware_revision = 0x0a2700, 374 .firmware_revision = 0x0a2700,
370 .model = 0x000021, 375 .model = 0x000021,
371 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 376 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
@@ -1092,7 +1097,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
1092 continue; 1097 continue;
1093 1098
1094 if (sbp2_workarounds_table[i].model != model && 1099 if (sbp2_workarounds_table[i].model != model &&
1095 sbp2_workarounds_table[i].model != ~0) 1100 sbp2_workarounds_table[i].model != SBP2_ROM_VALUE_WILDCARD)
1096 continue; 1101 continue;
1097 1102
1098 w |= sbp2_workarounds_table[i].workarounds; 1103 w |= sbp2_workarounds_table[i].workarounds;
@@ -1142,20 +1147,28 @@ static int sbp2_probe(struct device *dev)
1142 fw_device_get(device); 1147 fw_device_get(device);
1143 fw_unit_get(unit); 1148 fw_unit_get(unit);
1144 1149
1145 /* Initialize to values that won't match anything in our table. */
1146 firmware_revision = 0xff000000;
1147 model = 0xff000000;
1148
1149 /* implicit directory ID */ 1150 /* implicit directory ID */
1150 tgt->directory_id = ((unit->directory - device->config_rom) * 4 1151 tgt->directory_id = ((unit->directory - device->config_rom) * 4
1151 + CSR_CONFIG_ROM) & 0xffffff; 1152 + CSR_CONFIG_ROM) & 0xffffff;
1152 1153
1154 firmware_revision = SBP2_ROM_VALUE_MISSING;
1155 model = SBP2_ROM_VALUE_MISSING;
1156
1153 if (sbp2_scan_unit_dir(tgt, unit->directory, &model, 1157 if (sbp2_scan_unit_dir(tgt, unit->directory, &model,
1154 &firmware_revision) < 0) 1158 &firmware_revision) < 0)
1155 goto fail_tgt_put; 1159 goto fail_tgt_put;
1156 1160
1157 sbp2_init_workarounds(tgt, model, firmware_revision); 1161 sbp2_init_workarounds(tgt, model, firmware_revision);
1158 1162
1163 /*
1164 * At S100 we can do 512 bytes per packet, at S200 1024 bytes,
1165 * and so on up to 4096 bytes. The SBP-2 max_payload field
1166 * specifies the max payload size as 2 ^ (max_payload + 2), so
1167 * if we set this to max_speed + 7, we get the right value.
1168 */
1169 tgt->max_payload = min(device->max_speed + 7, 10U);
1170 tgt->max_payload = min(tgt->max_payload, device->card->max_receive - 1);
1171
1159 /* Do the login in a workqueue so we can easily reschedule retries. */ 1172 /* Do the login in a workqueue so we can easily reschedule retries. */
1160 list_for_each_entry(lu, &tgt->lu_list, link) 1173 list_for_each_entry(lu, &tgt->lu_list, link)
1161 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); 1174 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
@@ -1273,6 +1286,19 @@ static struct fw_driver sbp2_driver = {
1273 .id_table = sbp2_id_table, 1286 .id_table = sbp2_id_table,
1274}; 1287};
1275 1288
1289static void sbp2_unmap_scatterlist(struct device *card_device,
1290 struct sbp2_command_orb *orb)
1291{
1292 if (scsi_sg_count(orb->cmd))
1293 dma_unmap_sg(card_device, scsi_sglist(orb->cmd),
1294 scsi_sg_count(orb->cmd),
1295 orb->cmd->sc_data_direction);
1296
1297 if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT))
1298 dma_unmap_single(card_device, orb->page_table_bus,
1299 sizeof(orb->page_table), DMA_TO_DEVICE);
1300}
1301
1276static unsigned int 1302static unsigned int
1277sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) 1303sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
1278{ 1304{
@@ -1352,15 +1378,7 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
1352 1378
1353 dma_unmap_single(device->card->device, orb->base.request_bus, 1379 dma_unmap_single(device->card->device, orb->base.request_bus,
1354 sizeof(orb->request), DMA_TO_DEVICE); 1380 sizeof(orb->request), DMA_TO_DEVICE);
1355 1381 sbp2_unmap_scatterlist(device->card->device, orb);
1356 if (scsi_sg_count(orb->cmd) > 0)
1357 dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd),
1358 scsi_sg_count(orb->cmd),
1359 orb->cmd->sc_data_direction);
1360
1361 if (orb->page_table_bus != 0)
1362 dma_unmap_single(device->card->device, orb->page_table_bus,
1363 sizeof(orb->page_table), DMA_TO_DEVICE);
1364 1382
1365 orb->cmd->result = result; 1383 orb->cmd->result = result;
1366 orb->done(orb->cmd); 1384 orb->done(orb->cmd);
@@ -1434,7 +1452,6 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1434 struct sbp2_logical_unit *lu = cmd->device->hostdata; 1452 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1435 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 1453 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
1436 struct sbp2_command_orb *orb; 1454 struct sbp2_command_orb *orb;
1437 unsigned int max_payload;
1438 int generation, retval = SCSI_MLQUEUE_HOST_BUSY; 1455 int generation, retval = SCSI_MLQUEUE_HOST_BUSY;
1439 1456
1440 /* 1457 /*
@@ -1462,17 +1479,9 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1462 orb->done = done; 1479 orb->done = done;
1463 orb->cmd = cmd; 1480 orb->cmd = cmd;
1464 1481
1465 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL); 1482 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL);
1466 /*
1467 * At speed 100 we can do 512 bytes per packet, at speed 200,
1468 * 1024 bytes per packet etc. The SBP-2 max_payload field
1469 * specifies the max payload size as 2 ^ (max_payload + 2), so
1470 * if we set this to max_speed + 7, we get the right value.
1471 */
1472 max_payload = min(device->max_speed + 7,
1473 device->card->max_receive - 1);
1474 orb->request.misc = cpu_to_be32( 1483 orb->request.misc = cpu_to_be32(
1475 COMMAND_ORB_MAX_PAYLOAD(max_payload) | 1484 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
1476 COMMAND_ORB_SPEED(device->max_speed) | 1485 COMMAND_ORB_SPEED(device->max_speed) |
1477 COMMAND_ORB_NOTIFY); 1486 COMMAND_ORB_NOTIFY);
1478 1487
@@ -1491,8 +1500,10 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1491 orb->base.request_bus = 1500 orb->base.request_bus =
1492 dma_map_single(device->card->device, &orb->request, 1501 dma_map_single(device->card->device, &orb->request,
1493 sizeof(orb->request), DMA_TO_DEVICE); 1502 sizeof(orb->request), DMA_TO_DEVICE);
1494 if (dma_mapping_error(device->card->device, orb->base.request_bus)) 1503 if (dma_mapping_error(device->card->device, orb->base.request_bus)) {
1504 sbp2_unmap_scatterlist(device->card->device, orb);
1495 goto out; 1505 goto out;
1506 }
1496 1507
1497 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, 1508 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1498 lu->command_block_agent_address + SBP2_ORB_POINTER); 1509 lu->command_block_agent_address + SBP2_ORB_POINTER);
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index c9be6e6948c4..8dd6703b55cd 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -518,6 +518,18 @@ fw_core_handle_bus_reset(struct fw_card *card,
518 struct fw_node *local_node; 518 struct fw_node *local_node;
519 unsigned long flags; 519 unsigned long flags;
520 520
521 /*
522 * If the selfID buffer is not the immediate successor of the
523 * previously processed one, we cannot reliably compare the
524 * old and new topologies.
525 */
526 if (!is_next_generation(generation, card->generation) &&
527 card->local_node != NULL) {
528 fw_notify("skipped bus generations, destroying all nodes\n");
529 fw_destroy_nodes(card);
530 card->bm_retries = 0;
531 }
532
521 spin_lock_irqsave(&card->lock, flags); 533 spin_lock_irqsave(&card->lock, flags);
522 534
523 card->node_id = node_id; 535 card->node_id = node_id;
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index c9ab12a15f6e..1d78e9cc5940 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -276,6 +276,15 @@ static inline void fw_card_put(struct fw_card *card)
276extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); 276extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
277 277
278/* 278/*
279 * Check whether new_generation is the immediate successor of old_generation.
280 * Take counter roll-over at 255 (as per to OHCI) into account.
281 */
282static inline bool is_next_generation(int new_generation, int old_generation)
283{
284 return (new_generation & 0xff) == ((old_generation + 1) & 0xff);
285}
286
287/*
279 * The iso packet format allows for an immediate header/payload part 288 * The iso packet format allows for an immediate header/payload part
280 * stored in 'header' immediately after the packet info plus an 289 * stored in 'header' immediately after the packet info plus an
281 * indirect payload part that is pointer to by the 'payload' field. 290 * indirect payload part that is pointer to by the 'payload' field.
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index d76adfea5df7..8f0f7c449305 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -415,6 +415,29 @@ void __init dmi_scan_machine(void)
415} 415}
416 416
417/** 417/**
418 * dmi_matches - check if dmi_system_id structure matches system DMI data
419 * @dmi: pointer to the dmi_system_id structure to check
420 */
421static bool dmi_matches(const struct dmi_system_id *dmi)
422{
423 int i;
424
425 WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
426
427 for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) {
428 int s = dmi->matches[i].slot;
429 if (s == DMI_NONE)
430 continue;
431 if (dmi_ident[s]
432 && strstr(dmi_ident[s], dmi->matches[i].substr))
433 continue;
434 /* No match */
435 return false;
436 }
437 return true;
438}
439
440/**
418 * dmi_check_system - check system DMI data 441 * dmi_check_system - check system DMI data
419 * @list: array of dmi_system_id structures to match against 442 * @list: array of dmi_system_id structures to match against
420 * All non-null elements of the list must match 443 * All non-null elements of the list must match
@@ -429,32 +452,45 @@ void __init dmi_scan_machine(void)
429 */ 452 */
430int dmi_check_system(const struct dmi_system_id *list) 453int dmi_check_system(const struct dmi_system_id *list)
431{ 454{
432 int i, count = 0; 455 int count = 0;
433 const struct dmi_system_id *d = list; 456 const struct dmi_system_id *d;
434 457
435 WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n"); 458 for (d = list; d->ident; d++)
436 459 if (dmi_matches(d)) {
437 while (d->ident) { 460 count++;
438 for (i = 0; i < ARRAY_SIZE(d->matches); i++) { 461 if (d->callback && d->callback(d))
439 int s = d->matches[i].slot; 462 break;
440 if (s == DMI_NONE)
441 continue;
442 if (dmi_ident[s] && strstr(dmi_ident[s], d->matches[i].substr))
443 continue;
444 /* No match */
445 goto fail;
446 } 463 }
447 count++;
448 if (d->callback && d->callback(d))
449 break;
450fail: d++;
451 }
452 464
453 return count; 465 return count;
454} 466}
455EXPORT_SYMBOL(dmi_check_system); 467EXPORT_SYMBOL(dmi_check_system);
456 468
457/** 469/**
470 * dmi_first_match - find dmi_system_id structure matching system DMI data
471 * @list: array of dmi_system_id structures to match against
472 * All non-null elements of the list must match
473 * their slot's (field index's) data (i.e., each
474 * list string must be a substring of the specified
475 * DMI slot's string data) to be considered a
476 * successful match.
477 *
478 * Walk the blacklist table until the first match is found. Return the
479 * pointer to the matching entry or NULL if there's no match.
480 */
481const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list)
482{
483 const struct dmi_system_id *d;
484
485 for (d = list; d->ident; d++)
486 if (dmi_matches(d))
487 return d;
488
489 return NULL;
490}
491EXPORT_SYMBOL(dmi_first_match);
492
493/**
458 * dmi_get_system_info - return DMI data value 494 * dmi_get_system_info - return DMI data value
459 * @field: data index (see enum dmi_field) 495 * @field: data index (see enum dmi_field)
460 * 496 *
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 35e7aea4222c..42fb2fd24c0c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -789,6 +789,7 @@ int gpio_request(unsigned gpio, const char *label)
789 } else { 789 } else {
790 status = -EBUSY; 790 status = -EBUSY;
791 module_put(chip->owner); 791 module_put(chip->owner);
792 goto done;
792 } 793 }
793 794
794 if (chip->request) { 795 if (chip->request) {
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 477caa1b1e4b..69aa0ab28403 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -106,8 +106,6 @@ void drm_vblank_cleanup(struct drm_device *dev)
106 106
107 drm_free(dev->vbl_queue, sizeof(*dev->vbl_queue) * dev->num_crtcs, 107 drm_free(dev->vbl_queue, sizeof(*dev->vbl_queue) * dev->num_crtcs,
108 DRM_MEM_DRIVER); 108 DRM_MEM_DRIVER);
109 drm_free(dev->vbl_sigs, sizeof(*dev->vbl_sigs) * dev->num_crtcs,
110 DRM_MEM_DRIVER);
111 drm_free(dev->_vblank_count, sizeof(*dev->_vblank_count) * 109 drm_free(dev->_vblank_count, sizeof(*dev->_vblank_count) *
112 dev->num_crtcs, DRM_MEM_DRIVER); 110 dev->num_crtcs, DRM_MEM_DRIVER);
113 drm_free(dev->vblank_refcount, sizeof(*dev->vblank_refcount) * 111 drm_free(dev->vblank_refcount, sizeof(*dev->vblank_refcount) *
@@ -132,7 +130,6 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
132 setup_timer(&dev->vblank_disable_timer, vblank_disable_fn, 130 setup_timer(&dev->vblank_disable_timer, vblank_disable_fn,
133 (unsigned long)dev); 131 (unsigned long)dev);
134 spin_lock_init(&dev->vbl_lock); 132 spin_lock_init(&dev->vbl_lock);
135 atomic_set(&dev->vbl_signal_pending, 0);
136 dev->num_crtcs = num_crtcs; 133 dev->num_crtcs = num_crtcs;
137 134
138 dev->vbl_queue = drm_alloc(sizeof(wait_queue_head_t) * num_crtcs, 135 dev->vbl_queue = drm_alloc(sizeof(wait_queue_head_t) * num_crtcs,
@@ -140,11 +137,6 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
140 if (!dev->vbl_queue) 137 if (!dev->vbl_queue)
141 goto err; 138 goto err;
142 139
143 dev->vbl_sigs = drm_alloc(sizeof(struct list_head) * num_crtcs,
144 DRM_MEM_DRIVER);
145 if (!dev->vbl_sigs)
146 goto err;
147
148 dev->_vblank_count = drm_alloc(sizeof(atomic_t) * num_crtcs, 140 dev->_vblank_count = drm_alloc(sizeof(atomic_t) * num_crtcs,
149 DRM_MEM_DRIVER); 141 DRM_MEM_DRIVER);
150 if (!dev->_vblank_count) 142 if (!dev->_vblank_count)
@@ -177,7 +169,6 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
177 /* Zero per-crtc vblank stuff */ 169 /* Zero per-crtc vblank stuff */
178 for (i = 0; i < num_crtcs; i++) { 170 for (i = 0; i < num_crtcs; i++) {
179 init_waitqueue_head(&dev->vbl_queue[i]); 171 init_waitqueue_head(&dev->vbl_queue[i]);
180 INIT_LIST_HEAD(&dev->vbl_sigs[i]);
181 atomic_set(&dev->_vblank_count[i], 0); 172 atomic_set(&dev->_vblank_count[i], 0);
182 atomic_set(&dev->vblank_refcount[i], 0); 173 atomic_set(&dev->vblank_refcount[i], 0);
183 } 174 }
@@ -540,15 +531,10 @@ out:
540 * \param data user argument, pointing to a drm_wait_vblank structure. 531 * \param data user argument, pointing to a drm_wait_vblank structure.
541 * \return zero on success or a negative number on failure. 532 * \return zero on success or a negative number on failure.
542 * 533 *
543 * Verifies the IRQ is installed. 534 * This function enables the vblank interrupt on the pipe requested, then
544 * 535 * sleeps waiting for the requested sequence number to occur, and drops
545 * If a signal is requested checks if this task has already scheduled the same signal 536 * the vblank interrupt refcount afterwards. (vblank irq disable follows that
546 * for the same vblank sequence number - nothing to be done in 537 * after a timeout with no further vblank waits scheduled).
547 * that case. If the number of tasks waiting for the interrupt exceeds 100 the
548 * function fails. Otherwise adds a new entry to drm_device::vbl_sigs for this
549 * task.
550 *
551 * If a signal is not requested, then calls vblank_wait().
552 */ 538 */
553int drm_wait_vblank(struct drm_device *dev, void *data, 539int drm_wait_vblank(struct drm_device *dev, void *data,
554 struct drm_file *file_priv) 540 struct drm_file *file_priv)
@@ -560,6 +546,9 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
560 if ((!dev->pdev->irq) || (!dev->irq_enabled)) 546 if ((!dev->pdev->irq) || (!dev->irq_enabled))
561 return -EINVAL; 547 return -EINVAL;
562 548
549 if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
550 return -EINVAL;
551
563 if (vblwait->request.type & 552 if (vblwait->request.type &
564 ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) { 553 ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) {
565 DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n", 554 DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n",
@@ -597,89 +586,26 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
597 vblwait->request.sequence = seq + 1; 586 vblwait->request.sequence = seq + 1;
598 } 587 }
599 588
600 if (flags & _DRM_VBLANK_SIGNAL) { 589 DRM_DEBUG("waiting on vblank count %d, crtc %d\n",
601 unsigned long irqflags; 590 vblwait->request.sequence, crtc);
602 struct list_head *vbl_sigs = &dev->vbl_sigs[crtc]; 591 dev->last_vblank_wait[crtc] = vblwait->request.sequence;
603 struct drm_vbl_sig *vbl_sig; 592 DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ,
604 593 (((drm_vblank_count(dev, crtc) -
605 spin_lock_irqsave(&dev->vbl_lock, irqflags); 594 vblwait->request.sequence) <= (1 << 23)) ||
606 595 !dev->irq_enabled));
607 /* Check if this task has already scheduled the same signal
608 * for the same vblank sequence number; nothing to be done in
609 * that case
610 */
611 list_for_each_entry(vbl_sig, vbl_sigs, head) {
612 if (vbl_sig->sequence == vblwait->request.sequence
613 && vbl_sig->info.si_signo ==
614 vblwait->request.signal
615 && vbl_sig->task == current) {
616 spin_unlock_irqrestore(&dev->vbl_lock,
617 irqflags);
618 vblwait->reply.sequence = seq;
619 goto done;
620 }
621 }
622
623 if (atomic_read(&dev->vbl_signal_pending) >= 100) {
624 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
625 ret = -EBUSY;
626 goto done;
627 }
628
629 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
630
631 vbl_sig = drm_calloc(1, sizeof(struct drm_vbl_sig),
632 DRM_MEM_DRIVER);
633 if (!vbl_sig) {
634 ret = -ENOMEM;
635 goto done;
636 }
637
638 /* Get a refcount on the vblank, which will be released by
639 * drm_vbl_send_signals().
640 */
641 ret = drm_vblank_get(dev, crtc);
642 if (ret) {
643 drm_free(vbl_sig, sizeof(struct drm_vbl_sig),
644 DRM_MEM_DRIVER);
645 goto done;
646 }
647
648 atomic_inc(&dev->vbl_signal_pending);
649
650 vbl_sig->sequence = vblwait->request.sequence;
651 vbl_sig->info.si_signo = vblwait->request.signal;
652 vbl_sig->task = current;
653 596
654 spin_lock_irqsave(&dev->vbl_lock, irqflags); 597 if (ret != -EINTR) {
655 598 struct timeval now;
656 list_add_tail(&vbl_sig->head, vbl_sigs);
657 599
658 spin_unlock_irqrestore(&dev->vbl_lock, irqflags); 600 do_gettimeofday(&now);
659 601
660 vblwait->reply.sequence = seq; 602 vblwait->reply.tval_sec = now.tv_sec;
603 vblwait->reply.tval_usec = now.tv_usec;
604 vblwait->reply.sequence = drm_vblank_count(dev, crtc);
605 DRM_DEBUG("returning %d to client\n",
606 vblwait->reply.sequence);
661 } else { 607 } else {
662 DRM_DEBUG("waiting on vblank count %d, crtc %d\n", 608 DRM_DEBUG("vblank wait interrupted by signal\n");
663 vblwait->request.sequence, crtc);
664 dev->last_vblank_wait[crtc] = vblwait->request.sequence;
665 DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ,
666 (((drm_vblank_count(dev, crtc) -
667 vblwait->request.sequence) <= (1 << 23)) ||
668 !dev->irq_enabled));
669
670 if (ret != -EINTR) {
671 struct timeval now;
672
673 do_gettimeofday(&now);
674
675 vblwait->reply.tval_sec = now.tv_sec;
676 vblwait->reply.tval_usec = now.tv_usec;
677 vblwait->reply.sequence = drm_vblank_count(dev, crtc);
678 DRM_DEBUG("returning %d to client\n",
679 vblwait->reply.sequence);
680 } else {
681 DRM_DEBUG("vblank wait interrupted by signal\n");
682 }
683 } 609 }
684 610
685done: 611done:
@@ -688,46 +614,6 @@ done:
688} 614}
689 615
690/** 616/**
691 * Send the VBLANK signals.
692 *
693 * \param dev DRM device.
694 * \param crtc CRTC where the vblank event occurred
695 *
696 * Sends a signal for each task in drm_device::vbl_sigs and empties the list.
697 *
698 * If a signal is not requested, then calls vblank_wait().
699 */
700static void drm_vbl_send_signals(struct drm_device *dev, int crtc)
701{
702 struct drm_vbl_sig *vbl_sig, *tmp;
703 struct list_head *vbl_sigs;
704 unsigned int vbl_seq;
705 unsigned long flags;
706
707 spin_lock_irqsave(&dev->vbl_lock, flags);
708
709 vbl_sigs = &dev->vbl_sigs[crtc];
710 vbl_seq = drm_vblank_count(dev, crtc);
711
712 list_for_each_entry_safe(vbl_sig, tmp, vbl_sigs, head) {
713 if ((vbl_seq - vbl_sig->sequence) <= (1 << 23)) {
714 vbl_sig->info.si_code = vbl_seq;
715 send_sig_info(vbl_sig->info.si_signo,
716 &vbl_sig->info, vbl_sig->task);
717
718 list_del(&vbl_sig->head);
719
720 drm_free(vbl_sig, sizeof(*vbl_sig),
721 DRM_MEM_DRIVER);
722 atomic_dec(&dev->vbl_signal_pending);
723 drm_vblank_put(dev, crtc);
724 }
725 }
726
727 spin_unlock_irqrestore(&dev->vbl_lock, flags);
728}
729
730/**
731 * drm_handle_vblank - handle a vblank event 617 * drm_handle_vblank - handle a vblank event
732 * @dev: DRM device 618 * @dev: DRM device
733 * @crtc: where this event occurred 619 * @crtc: where this event occurred
@@ -739,6 +625,5 @@ void drm_handle_vblank(struct drm_device *dev, int crtc)
739{ 625{
740 atomic_inc(&dev->_vblank_count[crtc]); 626 atomic_inc(&dev->_vblank_count[crtc]);
741 DRM_WAKEUP(&dev->vbl_queue[crtc]); 627 DRM_WAKEUP(&dev->vbl_queue[crtc]);
742 drm_vbl_send_signals(dev, crtc);
743} 628}
744EXPORT_SYMBOL(drm_handle_vblank); 629EXPORT_SYMBOL(drm_handle_vblank);
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 6b1148fc2cbe..b36a5214d8df 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -311,7 +311,7 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
311 if (dev_priv->panel_fixed_mode != NULL) { 311 if (dev_priv->panel_fixed_mode != NULL) {
312 struct drm_display_mode *mode; 312 struct drm_display_mode *mode;
313 313
314 mutex_unlock(&dev->mode_config.mutex); 314 mutex_lock(&dev->mode_config.mutex);
315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); 315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
316 drm_mode_probed_add(connector, mode); 316 drm_mode_probed_add(connector, mode);
317 mutex_unlock(&dev->mode_config.mutex); 317 mutex_unlock(&dev->mode_config.mutex);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 5d7640e49dc5..6cad69ed21c5 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1218,6 +1218,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1218} 1218}
1219EXPORT_SYMBOL_GPL(hid_connect); 1219EXPORT_SYMBOL_GPL(hid_connect);
1220 1220
1221/* a list of devices for which there is a specialized driver on HID bus */
1221static const struct hid_device_id hid_blacklist[] = { 1222static const struct hid_device_id hid_blacklist[] = {
1222 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1223 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1223 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1224 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
@@ -1476,6 +1477,7 @@ static struct bus_type hid_bus_type = {
1476 .uevent = hid_uevent, 1477 .uevent = hid_uevent,
1477}; 1478};
1478 1479
1480/* a list of devices that shouldn't be handled by HID core at all */
1479static const struct hid_device_id hid_ignore_list[] = { 1481static const struct hid_device_id hid_ignore_list[] = {
1480 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1482 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
1481 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1483 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
@@ -1606,6 +1608,8 @@ static const struct hid_device_id hid_ignore_list[] = {
1606 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, 1608 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1607 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) }, 1609 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) },
1608 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) }, 1610 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) },
1611 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD4) },
1612 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5) },
1609 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) }, 1613 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1610 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) }, 1614 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1611 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1615 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index acc1abc834a4..e899f510ebeb 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -362,6 +362,8 @@
362#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038 362#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038
363#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2 0x0036 363#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2 0x0036
364#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3 0x0034 364#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3 0x0034
365#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD4 0x0044
366#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5 0x0045
365 367
366#define USB_VENDOR_ID_SUN 0x0430 368#define USB_VENDOR_ID_SUN 0x0430
367#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 369#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index d718b1607d0f..25b10dcad90d 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -30,7 +30,7 @@
30#define MS_NOGET 0x10 30#define MS_NOGET 0x10
31 31
32/* 32/*
33 * Microsoft Wireless Desktop Receiver (Model 1028) has several 33 * Microsoft Wireless Desktop Receiver (Model 1028) has
34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max' 34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
35 */ 35 */
36static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, 36static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -38,17 +38,12 @@ static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
38{ 38{
39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev); 39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
40 40
41 if ((quirks & MS_RDESC) && rsize == 571 && rdesc[284] == 0x19 && 41 if ((quirks & MS_RDESC) && rsize == 571 && rdesc[557] == 0x19 &&
42 rdesc[286] == 0x2a && rdesc[304] == 0x19 &&
43 rdesc[306] == 0x29 && rdesc[352] == 0x1a &&
44 rdesc[355] == 0x2a && rdesc[557] == 0x19 &&
45 rdesc[559] == 0x29) { 42 rdesc[559] == 0x29) {
46 dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver " 43 dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver "
47 "Model 1028 report descriptor\n"); 44 "Model 1028 report descriptor\n");
48 rdesc[284] = rdesc[304] = rdesc[557] = 0x35; 45 rdesc[557] = 0x35;
49 rdesc[352] = 0x36; 46 rdesc[559] = 0x45;
50 rdesc[286] = rdesc[355] = 0x46;
51 rdesc[306] = rdesc[559] = 0x45;
52 } 47 }
53} 48}
54 49
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index d73eea382ab3..4940e4d70c2d 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -656,7 +656,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
656 656
657 case HIDIOCGSTRING: 657 case HIDIOCGSTRING:
658 mutex_lock(&hiddev->existancelock); 658 mutex_lock(&hiddev->existancelock);
659 if (!hiddev->exist) 659 if (hiddev->exist)
660 r = hiddev_ioctl_string(hiddev, cmd, user_arg); 660 r = hiddev_ioctl_string(hiddev, cmd, user_arg);
661 else 661 else
662 r = -ENODEV; 662 r = -ENODEV;
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index e30186236588..678e34b01e52 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -83,7 +83,7 @@
83/* 83/*
84 * Temperature sensors keys (sp78 - 2 bytes). 84 * Temperature sensors keys (sp78 - 2 bytes).
85 */ 85 */
86static const char* temperature_sensors_sets[][36] = { 86static const char *temperature_sensors_sets[][41] = {
87/* Set 0: Macbook Pro */ 87/* Set 0: Macbook Pro */
88 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", 88 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
89 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, 89 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
@@ -135,6 +135,13 @@ static const char* temperature_sensors_sets[][36] = {
135 { "TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TC0D", "TN0D", "TTF0", 135 { "TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TC0D", "TN0D", "TTF0",
136 "TV0P", "TVFP", "TW0P", "Th0P", "Tp0P", "Tp1P", "TpFP", "Ts0P", 136 "TV0P", "TVFP", "TW0P", "Th0P", "Tp0P", "Tp1P", "TpFP", "Ts0P",
137 "Ts0S", NULL }, 137 "Ts0S", NULL },
138/* Set 16: Mac Pro 3,1 (2 x Quad-Core) */
139 { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", "TC0C", "TC0D", "TC0P",
140 "TC1C", "TC1D", "TC2C", "TC2D", "TC3C", "TC3D", "TH0P", "TH1P",
141 "TH2P", "TH3P", "TMAP", "TMAS", "TMBS", "TM0P", "TM0S", "TM1P",
142 "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S",
143 "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S",
144 NULL },
138}; 145};
139 146
140/* List of keys used to read/write fan speeds */ 147/* List of keys used to read/write fan speeds */
@@ -1153,6 +1160,16 @@ static SENSOR_DEVICE_ATTR(temp34_input, S_IRUGO,
1153 applesmc_show_temperature, NULL, 33); 1160 applesmc_show_temperature, NULL, 33);
1154static SENSOR_DEVICE_ATTR(temp35_input, S_IRUGO, 1161static SENSOR_DEVICE_ATTR(temp35_input, S_IRUGO,
1155 applesmc_show_temperature, NULL, 34); 1162 applesmc_show_temperature, NULL, 34);
1163static SENSOR_DEVICE_ATTR(temp36_input, S_IRUGO,
1164 applesmc_show_temperature, NULL, 35);
1165static SENSOR_DEVICE_ATTR(temp37_input, S_IRUGO,
1166 applesmc_show_temperature, NULL, 36);
1167static SENSOR_DEVICE_ATTR(temp38_input, S_IRUGO,
1168 applesmc_show_temperature, NULL, 37);
1169static SENSOR_DEVICE_ATTR(temp39_input, S_IRUGO,
1170 applesmc_show_temperature, NULL, 38);
1171static SENSOR_DEVICE_ATTR(temp40_input, S_IRUGO,
1172 applesmc_show_temperature, NULL, 39);
1156 1173
1157static struct attribute *temperature_attributes[] = { 1174static struct attribute *temperature_attributes[] = {
1158 &sensor_dev_attr_temp1_input.dev_attr.attr, 1175 &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -1190,6 +1207,11 @@ static struct attribute *temperature_attributes[] = {
1190 &sensor_dev_attr_temp33_input.dev_attr.attr, 1207 &sensor_dev_attr_temp33_input.dev_attr.attr,
1191 &sensor_dev_attr_temp34_input.dev_attr.attr, 1208 &sensor_dev_attr_temp34_input.dev_attr.attr,
1192 &sensor_dev_attr_temp35_input.dev_attr.attr, 1209 &sensor_dev_attr_temp35_input.dev_attr.attr,
1210 &sensor_dev_attr_temp36_input.dev_attr.attr,
1211 &sensor_dev_attr_temp37_input.dev_attr.attr,
1212 &sensor_dev_attr_temp38_input.dev_attr.attr,
1213 &sensor_dev_attr_temp39_input.dev_attr.attr,
1214 &sensor_dev_attr_temp40_input.dev_attr.attr,
1193 NULL 1215 NULL
1194}; 1216};
1195 1217
@@ -1312,6 +1334,8 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1312 { .accelerometer = 0, .light = 0, .temperature_set = 14 }, 1334 { .accelerometer = 0, .light = 0, .temperature_set = 14 },
1313/* MacBook Air 2,1: accelerometer, backlight and temperature set 15 */ 1335/* MacBook Air 2,1: accelerometer, backlight and temperature set 15 */
1314 { .accelerometer = 1, .light = 1, .temperature_set = 15 }, 1336 { .accelerometer = 1, .light = 1, .temperature_set = 15 },
1337/* MacPro3,1: temperature set 16 */
1338 { .accelerometer = 0, .light = 0, .temperature_set = 16 },
1315}; 1339};
1316 1340
1317/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1341/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
@@ -1369,6 +1393,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1369 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), 1393 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1370 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") }, 1394 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
1371 &applesmc_dmi_data[4]}, 1395 &applesmc_dmi_data[4]},
1396 { applesmc_dmi_match, "Apple MacPro3", {
1397 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1398 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro3") },
1399 &applesmc_dmi_data[16]},
1372 { applesmc_dmi_match, "Apple MacPro", { 1400 { applesmc_dmi_match, "Apple MacPro", {
1373 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1401 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1374 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, 1402 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
diff --git a/drivers/ieee1394/ieee1394.h b/drivers/ieee1394/ieee1394.h
index e0ae0d3d747f..af320e2c5079 100644
--- a/drivers/ieee1394/ieee1394.h
+++ b/drivers/ieee1394/ieee1394.h
@@ -54,9 +54,7 @@
54#define IEEE1394_SPEED_800 0x03 54#define IEEE1394_SPEED_800 0x03
55#define IEEE1394_SPEED_1600 0x04 55#define IEEE1394_SPEED_1600 0x04
56#define IEEE1394_SPEED_3200 0x05 56#define IEEE1394_SPEED_3200 0x05
57 57#define IEEE1394_SPEED_MAX IEEE1394_SPEED_3200
58/* The current highest tested speed supported by the subsystem */
59#define IEEE1394_SPEED_MAX IEEE1394_SPEED_800
60 58
61/* Maps speed values above to a string representation */ 59/* Maps speed values above to a string representation */
62extern const char *hpsb_speedto_str[]; 60extern const char *hpsb_speedto_str[];
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index dcdb71a7718d..2beb8d94f7bd 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -338,6 +338,7 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
338 u8 cldcnt[nodecount]; 338 u8 cldcnt[nodecount];
339 u8 *map = host->speed_map; 339 u8 *map = host->speed_map;
340 u8 *speedcap = host->speed; 340 u8 *speedcap = host->speed;
341 u8 local_link_speed = host->csr.lnk_spd;
341 struct selfid *sid; 342 struct selfid *sid;
342 struct ext_selfid *esid; 343 struct ext_selfid *esid;
343 int i, j, n; 344 int i, j, n;
@@ -373,8 +374,8 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
373 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++; 374 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
374 375
375 speedcap[n] = sid->speed; 376 speedcap[n] = sid->speed;
376 if (speedcap[n] > host->csr.lnk_spd) 377 if (speedcap[n] > local_link_speed)
377 speedcap[n] = host->csr.lnk_spd; 378 speedcap[n] = local_link_speed;
378 n--; 379 n--;
379 } 380 }
380 } 381 }
@@ -407,12 +408,11 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
407 } 408 }
408 } 409 }
409 410
410#if SELFID_SPEED_UNKNOWN != IEEE1394_SPEED_MAX 411 /* assume a maximum speed for 1394b PHYs, nodemgr will correct it */
411 /* assume maximum speed for 1394b PHYs, nodemgr will correct it */ 412 if (local_link_speed > SELFID_SPEED_UNKNOWN)
412 for (n = 0; n < nodecount; n++) 413 for (i = 0; i < nodecount; i++)
413 if (speedcap[n] == SELFID_SPEED_UNKNOWN) 414 if (speedcap[i] == SELFID_SPEED_UNKNOWN)
414 speedcap[n] = IEEE1394_SPEED_MAX; 415 speedcap[i] = local_link_speed;
415#endif
416} 416}
417 417
418 418
diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h
index 4320bf010495..7fb8ab9780ae 100644
--- a/drivers/ieee1394/ohci1394.h
+++ b/drivers/ieee1394/ohci1394.h
@@ -26,7 +26,7 @@
26 26
27#define OHCI1394_DRIVER_NAME "ohci1394" 27#define OHCI1394_DRIVER_NAME "ohci1394"
28 28
29#define OHCI1394_MAX_AT_REQ_RETRIES 0x2 29#define OHCI1394_MAX_AT_REQ_RETRIES 0xf
30#define OHCI1394_MAX_AT_RESP_RETRIES 0x2 30#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
31#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 31#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
32#define OHCI1394_MAX_SELF_ID_ERRORS 16 32#define OHCI1394_MAX_SELF_ID_ERRORS 16
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index ab1034ccb7fb..f3fd8657ce4b 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -115,8 +115,8 @@
115 */ 115 */
116static int sbp2_max_speed = IEEE1394_SPEED_MAX; 116static int sbp2_max_speed = IEEE1394_SPEED_MAX;
117module_param_named(max_speed, sbp2_max_speed, int, 0644); 117module_param_named(max_speed, sbp2_max_speed, int, 0644);
118MODULE_PARM_DESC(max_speed, "Force max speed " 118MODULE_PARM_DESC(max_speed, "Limit data transfer speed (5 <= 3200, "
119 "(3 = 800Mb/s, 2 = 400Mb/s, 1 = 200Mb/s, 0 = 100Mb/s)"); 119 "4 <= 1600, 3 <= 800, 2 <= 400, 1 <= 200, 0 = 100 Mb/s)");
120 120
121/* 121/*
122 * Set serialize_io to 0 or N to use dynamically appended lists of command ORBs. 122 * Set serialize_io to 0 or N to use dynamically appended lists of command ORBs.
@@ -256,7 +256,7 @@ static int sbp2_set_busy_timeout(struct sbp2_lu *);
256static int sbp2_max_speed_and_size(struct sbp2_lu *); 256static int sbp2_max_speed_and_size(struct sbp2_lu *);
257 257
258 258
259static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC }; 259static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xa, 0xa, 0xa };
260 260
261static DEFINE_RWLOCK(sbp2_hi_logical_units_lock); 261static DEFINE_RWLOCK(sbp2_hi_logical_units_lock);
262 262
@@ -347,8 +347,8 @@ static struct scsi_host_template sbp2_shost_template = {
347 .sdev_attrs = sbp2_sysfs_sdev_attrs, 347 .sdev_attrs = sbp2_sysfs_sdev_attrs,
348}; 348};
349 349
350/* for match-all entries in sbp2_workarounds_table */ 350#define SBP2_ROM_VALUE_WILDCARD ~0 /* match all */
351#define SBP2_ROM_VALUE_WILDCARD 0x1000000 351#define SBP2_ROM_VALUE_MISSING 0xff000000 /* not present in the unit dir. */
352 352
353/* 353/*
354 * List of devices with known bugs. 354 * List of devices with known bugs.
@@ -359,60 +359,70 @@ static struct scsi_host_template sbp2_shost_template = {
359 */ 359 */
360static const struct { 360static const struct {
361 u32 firmware_revision; 361 u32 firmware_revision;
362 u32 model_id; 362 u32 model;
363 unsigned workarounds; 363 unsigned workarounds;
364} sbp2_workarounds_table[] = { 364} sbp2_workarounds_table[] = {
365 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ { 365 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
366 .firmware_revision = 0x002800, 366 .firmware_revision = 0x002800,
367 .model_id = 0x001010, 367 .model = 0x001010,
368 .workarounds = SBP2_WORKAROUND_INQUIRY_36 | 368 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
369 SBP2_WORKAROUND_MODE_SENSE_8 | 369 SBP2_WORKAROUND_MODE_SENSE_8 |
370 SBP2_WORKAROUND_POWER_CONDITION, 370 SBP2_WORKAROUND_POWER_CONDITION,
371 }, 371 },
372 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ { 372 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
373 .firmware_revision = 0x002800, 373 .firmware_revision = 0x002800,
374 .model_id = 0x000000, 374 .model = 0x000000,
375 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY | 375 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY |
376 SBP2_WORKAROUND_POWER_CONDITION, 376 SBP2_WORKAROUND_POWER_CONDITION,
377 }, 377 },
378 /* Initio bridges, actually only needed for some older ones */ { 378 /* Initio bridges, actually only needed for some older ones */ {
379 .firmware_revision = 0x000200, 379 .firmware_revision = 0x000200,
380 .model_id = SBP2_ROM_VALUE_WILDCARD, 380 .model = SBP2_ROM_VALUE_WILDCARD,
381 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 381 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
382 }, 382 },
383 /* PL-3507 bridge with Prolific firmware */ { 383 /* PL-3507 bridge with Prolific firmware */ {
384 .firmware_revision = 0x012800, 384 .firmware_revision = 0x012800,
385 .model_id = SBP2_ROM_VALUE_WILDCARD, 385 .model = SBP2_ROM_VALUE_WILDCARD,
386 .workarounds = SBP2_WORKAROUND_POWER_CONDITION, 386 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
387 }, 387 },
388 /* Symbios bridge */ { 388 /* Symbios bridge */ {
389 .firmware_revision = 0xa0b800, 389 .firmware_revision = 0xa0b800,
390 .model_id = SBP2_ROM_VALUE_WILDCARD, 390 .model = SBP2_ROM_VALUE_WILDCARD,
391 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 391 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
392 }, 392 },
393 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 393 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
394 .firmware_revision = 0x002600, 394 .firmware_revision = 0x002600,
395 .model_id = SBP2_ROM_VALUE_WILDCARD, 395 .model = SBP2_ROM_VALUE_WILDCARD,
396 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 396 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
397 }, 397 },
398 /*
399 * iPod 2nd generation: needs 128k max transfer size workaround
400 * iPod 3rd generation: needs fix capacity workaround
401 */
402 {
403 .firmware_revision = 0x0a2700,
404 .model = 0x000000,
405 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS |
406 SBP2_WORKAROUND_FIX_CAPACITY,
407 },
398 /* iPod 4th generation */ { 408 /* iPod 4th generation */ {
399 .firmware_revision = 0x0a2700, 409 .firmware_revision = 0x0a2700,
400 .model_id = 0x000021, 410 .model = 0x000021,
401 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 411 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
402 }, 412 },
403 /* iPod mini */ { 413 /* iPod mini */ {
404 .firmware_revision = 0x0a2700, 414 .firmware_revision = 0x0a2700,
405 .model_id = 0x000022, 415 .model = 0x000022,
406 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 416 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
407 }, 417 },
408 /* iPod mini */ { 418 /* iPod mini */ {
409 .firmware_revision = 0x0a2700, 419 .firmware_revision = 0x0a2700,
410 .model_id = 0x000023, 420 .model = 0x000023,
411 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 421 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
412 }, 422 },
413 /* iPod Photo */ { 423 /* iPod Photo */ {
414 .firmware_revision = 0x0a2700, 424 .firmware_revision = 0x0a2700,
415 .model_id = 0x00007e, 425 .model = 0x00007e,
416 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 426 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
417 } 427 }
418}; 428};
@@ -1341,13 +1351,15 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1341 struct csr1212_keyval *kv; 1351 struct csr1212_keyval *kv;
1342 struct csr1212_dentry *dentry; 1352 struct csr1212_dentry *dentry;
1343 u64 management_agent_addr; 1353 u64 management_agent_addr;
1344 u32 unit_characteristics, firmware_revision; 1354 u32 unit_characteristics, firmware_revision, model;
1345 unsigned workarounds; 1355 unsigned workarounds;
1346 int i; 1356 int i;
1347 1357
1348 management_agent_addr = 0; 1358 management_agent_addr = 0;
1349 unit_characteristics = 0; 1359 unit_characteristics = 0;
1350 firmware_revision = 0; 1360 firmware_revision = SBP2_ROM_VALUE_MISSING;
1361 model = ud->flags & UNIT_DIRECTORY_MODEL_ID ?
1362 ud->model_id : SBP2_ROM_VALUE_MISSING;
1351 1363
1352 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) { 1364 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) {
1353 switch (kv->key.id) { 1365 switch (kv->key.id) {
@@ -1388,9 +1400,9 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1388 sbp2_workarounds_table[i].firmware_revision != 1400 sbp2_workarounds_table[i].firmware_revision !=
1389 (firmware_revision & 0xffff00)) 1401 (firmware_revision & 0xffff00))
1390 continue; 1402 continue;
1391 if (sbp2_workarounds_table[i].model_id != 1403 if (sbp2_workarounds_table[i].model !=
1392 SBP2_ROM_VALUE_WILDCARD && 1404 SBP2_ROM_VALUE_WILDCARD &&
1393 sbp2_workarounds_table[i].model_id != ud->model_id) 1405 sbp2_workarounds_table[i].model != model)
1394 continue; 1406 continue;
1395 workarounds |= sbp2_workarounds_table[i].workarounds; 1407 workarounds |= sbp2_workarounds_table[i].workarounds;
1396 break; 1408 break;
@@ -1403,7 +1415,7 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1403 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid), 1415 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
1404 workarounds, firmware_revision, 1416 workarounds, firmware_revision,
1405 ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id, 1417 ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id,
1406 ud->model_id); 1418 model);
1407 1419
1408 /* We would need one SCSI host template for each target to adjust 1420 /* We would need one SCSI host template for each target to adjust
1409 * max_sectors on the fly, therefore warn only. */ 1421 * max_sectors on the fly, therefore warn only. */
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 90663e01a56e..60156dfdc608 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -224,7 +224,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
224 break; 224 break;
225 225
226 /* If the Guest asked to be stopped, we sleep. The Guest's 226 /* If the Guest asked to be stopped, we sleep. The Guest's
227 * clock timer or LHCALL_BREAK from the Waker will wake us. */ 227 * clock timer or LHREQ_BREAK from the Waker will wake us. */
228 if (cpu->halted) { 228 if (cpu->halted) {
229 set_current_state(TASK_INTERRUPTIBLE); 229 set_current_state(TASK_INTERRUPTIBLE);
230 schedule(); 230 schedule();
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 34bc017b8b3c..b8ee103eed5f 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -307,9 +307,8 @@ static int close(struct inode *inode, struct file *file)
307 * kmalloc()ed string, either of which is ok to hand to kfree(). */ 307 * kmalloc()ed string, either of which is ok to hand to kfree(). */
308 if (!IS_ERR(lg->dead)) 308 if (!IS_ERR(lg->dead))
309 kfree(lg->dead); 309 kfree(lg->dead);
310 /* We clear the entire structure, which also marks it as free for the 310 /* Free the memory allocated to the lguest_struct */
311 * next user. */ 311 kfree(lg);
312 memset(lg, 0, sizeof(*lg));
313 /* Release lock and exit. */ 312 /* Release lock and exit. */
314 mutex_unlock(&lguest_lock); 313 mutex_unlock(&lguest_lock);
315 314
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 05e298289238..10c421b73eaf 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -758,7 +758,7 @@ static void __exit ilo_exit(void)
758 class_destroy(ilo_class); 758 class_destroy(ilo_class);
759} 759}
760 760
761MODULE_VERSION("0.05"); 761MODULE_VERSION("0.06");
762MODULE_ALIAS(ILO_NAME); 762MODULE_ALIAS(ILO_NAME);
763MODULE_DESCRIPTION(ILO_NAME); 763MODULE_DESCRIPTION(ILO_NAME);
764MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>"); 764MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index 9cd2ebe2a3b6..45fd653dbe31 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -49,9 +49,6 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
49 49
50 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) 50 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING))
51 return; 51 return;
52
53 DBUG_ON(ch->local_msgqueue == NULL);
54 DBUG_ON(ch->remote_msgqueue == NULL);
55 } 52 }
56 53
57 if (!(ch->flags & XPC_C_OPENREPLY)) { 54 if (!(ch->flags & XPC_C_OPENREPLY)) {
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index 82fb9958f22f..2e975762c32b 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -1106,8 +1106,6 @@ xpc_process_activate_IRQ_rcvd_sn2(void)
1106 int n_IRQs_expected; 1106 int n_IRQs_expected;
1107 int n_IRQs_detected; 1107 int n_IRQs_detected;
1108 1108
1109 DBUG_ON(xpc_activate_IRQ_rcvd == 0);
1110
1111 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags); 1109 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
1112 n_IRQs_expected = xpc_activate_IRQ_rcvd; 1110 n_IRQs_expected = xpc_activate_IRQ_rcvd;
1113 xpc_activate_IRQ_rcvd = 0; 1111 xpc_activate_IRQ_rcvd = 0;
@@ -1726,6 +1724,7 @@ xpc_clear_local_msgqueue_flags_sn2(struct xpc_channel *ch)
1726 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->local_msgqueue + 1724 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->local_msgqueue +
1727 (get % ch->local_nentries) * 1725 (get % ch->local_nentries) *
1728 ch->entry_size); 1726 ch->entry_size);
1727 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1729 msg->flags = 0; 1728 msg->flags = 0;
1730 } while (++get < ch_sn2->remote_GP.get); 1729 } while (++get < ch_sn2->remote_GP.get);
1731} 1730}
@@ -1740,11 +1739,18 @@ xpc_clear_remote_msgqueue_flags_sn2(struct xpc_channel *ch)
1740 struct xpc_msg_sn2 *msg; 1739 struct xpc_msg_sn2 *msg;
1741 s64 put; 1740 s64 put;
1742 1741
1743 put = ch_sn2->w_remote_GP.put; 1742 /* flags are zeroed when the buffer is allocated */
1743 if (ch_sn2->remote_GP.put < ch->remote_nentries)
1744 return;
1745
1746 put = max(ch_sn2->w_remote_GP.put, ch->remote_nentries);
1744 do { 1747 do {
1745 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->remote_msgqueue + 1748 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->remote_msgqueue +
1746 (put % ch->remote_nentries) * 1749 (put % ch->remote_nentries) *
1747 ch->entry_size); 1750 ch->entry_size);
1751 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1752 DBUG_ON(!(msg->flags & XPC_M_SN2_DONE));
1753 DBUG_ON(msg->number != put - ch->remote_nentries);
1748 msg->flags = 0; 1754 msg->flags = 0;
1749 } while (++put < ch_sn2->remote_GP.put); 1755 } while (++put < ch_sn2->remote_GP.put);
1750} 1756}
@@ -1836,6 +1842,7 @@ xpc_process_msg_chctl_flags_sn2(struct xpc_partition *part, int ch_number)
1836 */ 1842 */
1837 xpc_clear_remote_msgqueue_flags_sn2(ch); 1843 xpc_clear_remote_msgqueue_flags_sn2(ch);
1838 1844
1845 smp_wmb(); /* ensure flags have been cleared before bte_copy */
1839 ch_sn2->w_remote_GP.put = ch_sn2->remote_GP.put; 1846 ch_sn2->w_remote_GP.put = ch_sn2->remote_GP.put;
1840 1847
1841 dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, " 1848 dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, "
@@ -1934,7 +1941,7 @@ xpc_get_deliverable_payload_sn2(struct xpc_channel *ch)
1934 break; 1941 break;
1935 1942
1936 get = ch_sn2->w_local_GP.get; 1943 get = ch_sn2->w_local_GP.get;
1937 rmb(); /* guarantee that .get loads before .put */ 1944 smp_rmb(); /* guarantee that .get loads before .put */
1938 if (get == ch_sn2->w_remote_GP.put) 1945 if (get == ch_sn2->w_remote_GP.put)
1939 break; 1946 break;
1940 1947
@@ -1956,11 +1963,13 @@ xpc_get_deliverable_payload_sn2(struct xpc_channel *ch)
1956 1963
1957 msg = xpc_pull_remote_msg_sn2(ch, get); 1964 msg = xpc_pull_remote_msg_sn2(ch, get);
1958 1965
1959 DBUG_ON(msg != NULL && msg->number != get); 1966 if (msg != NULL) {
1960 DBUG_ON(msg != NULL && (msg->flags & XPC_M_SN2_DONE)); 1967 DBUG_ON(msg->number != get);
1961 DBUG_ON(msg != NULL && !(msg->flags & XPC_M_SN2_READY)); 1968 DBUG_ON(msg->flags & XPC_M_SN2_DONE);
1969 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1962 1970
1963 payload = &msg->payload; 1971 payload = &msg->payload;
1972 }
1964 break; 1973 break;
1965 } 1974 }
1966 1975
@@ -2053,7 +2062,7 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
2053 while (1) { 2062 while (1) {
2054 2063
2055 put = ch_sn2->w_local_GP.put; 2064 put = ch_sn2->w_local_GP.put;
2056 rmb(); /* guarantee that .put loads before .get */ 2065 smp_rmb(); /* guarantee that .put loads before .get */
2057 if (put - ch_sn2->w_remote_GP.get < ch->local_nentries) { 2066 if (put - ch_sn2->w_remote_GP.get < ch->local_nentries) {
2058 2067
2059 /* There are available message entries. We need to try 2068 /* There are available message entries. We need to try
@@ -2186,7 +2195,7 @@ xpc_send_payload_sn2(struct xpc_channel *ch, u32 flags, void *payload,
2186 * The preceding store of msg->flags must occur before the following 2195 * The preceding store of msg->flags must occur before the following
2187 * load of local_GP->put. 2196 * load of local_GP->put.
2188 */ 2197 */
2189 mb(); 2198 smp_mb();
2190 2199
2191 /* see if the message is next in line to be sent, if so send it */ 2200 /* see if the message is next in line to be sent, if so send it */
2192 2201
@@ -2277,8 +2286,9 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
2277 dev_dbg(xpc_chan, "msg=0x%p, msg_number=%ld, partid=%d, channel=%d\n", 2286 dev_dbg(xpc_chan, "msg=0x%p, msg_number=%ld, partid=%d, channel=%d\n",
2278 (void *)msg, msg_number, ch->partid, ch->number); 2287 (void *)msg, msg_number, ch->partid, ch->number);
2279 2288
2280 DBUG_ON((((u64)msg - (u64)ch->remote_msgqueue) / ch->entry_size) != 2289 DBUG_ON((((u64)msg - (u64)ch->sn.sn2.remote_msgqueue) / ch->entry_size) !=
2281 msg_number % ch->remote_nentries); 2290 msg_number % ch->remote_nentries);
2291 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
2282 DBUG_ON(msg->flags & XPC_M_SN2_DONE); 2292 DBUG_ON(msg->flags & XPC_M_SN2_DONE);
2283 2293
2284 msg->flags |= XPC_M_SN2_DONE; 2294 msg->flags |= XPC_M_SN2_DONE;
@@ -2287,7 +2297,7 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
2287 * The preceding store of msg->flags must occur before the following 2297 * The preceding store of msg->flags must occur before the following
2288 * load of local_GP->get. 2298 * load of local_GP->get.
2289 */ 2299 */
2290 mb(); 2300 smp_mb();
2291 2301
2292 /* 2302 /*
2293 * See if this message is next in line to be acknowledged as having 2303 * See if this message is next in line to be acknowledged as having
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index 91a55b1b1037..f17f7d40ea2c 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -1423,7 +1423,7 @@ xpc_send_payload_uv(struct xpc_channel *ch, u32 flags, void *payload,
1423 atomic_inc(&ch->n_to_notify); 1423 atomic_inc(&ch->n_to_notify);
1424 1424
1425 msg_slot->key = key; 1425 msg_slot->key = key;
1426 wmb(); /* a non-NULL func must hit memory after the key */ 1426 smp_wmb(); /* a non-NULL func must hit memory after the key */
1427 msg_slot->func = func; 1427 msg_slot->func = func;
1428 1428
1429 if (ch->flags & XPC_C_DISCONNECTING) { 1429 if (ch->flags & XPC_C_DISCONNECTING) {
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 65929db29446..1f6eb2578717 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -676,7 +676,7 @@ static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
676 676
677 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->numchips = %d\n", 677 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->numchips = %d\n",
678 chip->numchips); 678 chip->numchips);
679 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->chipsize = %ld\n", 679 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->chipsize = %lld\n",
680 chip->chipsize); 680 chip->chipsize);
681 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->pagemask = %8x\n", 681 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->pagemask = %8x\n",
682 chip->pagemask); 682 chip->pagemask);
@@ -703,7 +703,7 @@ static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
703 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->ecc.layout = %p\n", 703 dev_dbg(ctrl->dev, "fsl_elbc_init: nand->ecc.layout = %p\n",
704 chip->ecc.layout); 704 chip->ecc.layout);
705 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->flags = %08x\n", mtd->flags); 705 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->flags = %08x\n", mtd->flags);
706 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->size = %d\n", mtd->size); 706 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->size = %lld\n", mtd->size);
707 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->erasesize = %d\n", 707 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->erasesize = %d\n",
708 mtd->erasesize); 708 mtd->erasesize);
709 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->writesize = %d\n", 709 dev_dbg(ctrl->dev, "fsl_elbc_init: mtd->writesize = %d\n",
@@ -932,8 +932,8 @@ static int __devinit fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
932#endif 932#endif
933 add_mtd_device(&priv->mtd); 933 add_mtd_device(&priv->mtd);
934 934
935 printk(KERN_INFO "eLBC NAND device at 0x%zx, bank %d\n", 935 printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
936 res.start, priv->bank); 936 (unsigned long long)res.start, priv->bank);
937 return 0; 937 return 0;
938 938
939err: 939err:
diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
index 9bd6c9ac8443..a8b9376cf324 100644
--- a/drivers/mtd/nand/pasemi_nand.c
+++ b/drivers/mtd/nand/pasemi_nand.c
@@ -107,7 +107,7 @@ static int __devinit pasemi_nand_probe(struct of_device *ofdev,
107 if (pasemi_nand_mtd) 107 if (pasemi_nand_mtd)
108 return -ENODEV; 108 return -ENODEV;
109 109
110 pr_debug("pasemi_nand at %lx-%lx\n", res.start, res.end); 110 pr_debug("pasemi_nand at %llx-%llx\n", res.start, res.end);
111 111
112 /* Allocate memory for MTD device structure and private data */ 112 /* Allocate memory for MTD device structure and private data */
113 pasemi_nand_mtd = kzalloc(sizeof(struct mtd_info) + 113 pasemi_nand_mtd = kzalloc(sizeof(struct mtd_info) +
@@ -170,7 +170,7 @@ static int __devinit pasemi_nand_probe(struct of_device *ofdev,
170 goto out_lpc; 170 goto out_lpc;
171 } 171 }
172 172
173 printk(KERN_INFO "PA Semi NAND flash at %08lx, control at I/O %x\n", 173 printk(KERN_INFO "PA Semi NAND flash at %08llx, control at I/O %x\n",
174 res.start, lpcctl); 174 res.start, lpcctl);
175 175
176 return 0; 176 return 0;
diff --git a/drivers/mtd/ubi/Kconfig.debug b/drivers/mtd/ubi/Kconfig.debug
index 1e2ee22edeff..2246f154e2f7 100644
--- a/drivers/mtd/ubi/Kconfig.debug
+++ b/drivers/mtd/ubi/Kconfig.debug
@@ -33,16 +33,6 @@ config MTD_UBI_DEBUG_DISABLE_BGT
33 This option switches the background thread off by default. The thread 33 This option switches the background thread off by default. The thread
34 may be also be enabled/disabled via UBI sysfs. 34 may be also be enabled/disabled via UBI sysfs.
35 35
36config MTD_UBI_DEBUG_USERSPACE_IO
37 bool "Direct user-space write/erase support"
38 default n
39 depends on MTD_UBI_DEBUG
40 help
41 By default, users cannot directly write and erase individual
42 eraseblocks of dynamic volumes, and have to use update operation
43 instead. This option enables this capability - it is very useful for
44 debugging and testing.
45
46config MTD_UBI_DEBUG_EMULATE_BITFLIPS 36config MTD_UBI_DEBUG_EMULATE_BITFLIPS
47 bool "Emulate flash bit-flips" 37 bool "Emulate flash bit-flips"
48 depends on MTD_UBI_DEBUG 38 depends on MTD_UBI_DEBUG
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 9082768cc6c3..4048db83aef6 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -263,8 +263,12 @@ static ssize_t dev_attribute_show(struct device *dev,
263 return ret; 263 return ret;
264} 264}
265 265
266/* Fake "release" method for UBI devices */ 266static void dev_release(struct device *dev)
267static void dev_release(struct device *dev) { } 267{
268 struct ubi_device *ubi = container_of(dev, struct ubi_device, dev);
269
270 kfree(ubi);
271}
268 272
269/** 273/**
270 * ubi_sysfs_init - initialize sysfs for an UBI device. 274 * ubi_sysfs_init - initialize sysfs for an UBI device.
@@ -380,7 +384,7 @@ static void free_user_volumes(struct ubi_device *ubi)
380 */ 384 */
381static int uif_init(struct ubi_device *ubi) 385static int uif_init(struct ubi_device *ubi)
382{ 386{
383 int i, err, do_free = 0; 387 int i, err;
384 dev_t dev; 388 dev_t dev;
385 389
386 sprintf(ubi->ubi_name, UBI_NAME_STR "%d", ubi->ubi_num); 390 sprintf(ubi->ubi_name, UBI_NAME_STR "%d", ubi->ubi_num);
@@ -427,13 +431,10 @@ static int uif_init(struct ubi_device *ubi)
427 431
428out_volumes: 432out_volumes:
429 kill_volumes(ubi); 433 kill_volumes(ubi);
430 do_free = 0;
431out_sysfs: 434out_sysfs:
432 ubi_sysfs_close(ubi); 435 ubi_sysfs_close(ubi);
433 cdev_del(&ubi->cdev); 436 cdev_del(&ubi->cdev);
434out_unreg: 437out_unreg:
435 if (do_free)
436 free_user_volumes(ubi);
437 unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1); 438 unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1);
438 ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err); 439 ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err);
439 return err; 440 return err;
@@ -947,6 +948,12 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
947 if (ubi->bgt_thread) 948 if (ubi->bgt_thread)
948 kthread_stop(ubi->bgt_thread); 949 kthread_stop(ubi->bgt_thread);
949 950
951 /*
952 * Get a reference to the device in order to prevent 'dev_release()'
953 * from freeing @ubi object.
954 */
955 get_device(&ubi->dev);
956
950 uif_close(ubi); 957 uif_close(ubi);
951 ubi_wl_close(ubi); 958 ubi_wl_close(ubi);
952 free_internal_volumes(ubi); 959 free_internal_volumes(ubi);
@@ -958,7 +965,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
958 vfree(ubi->dbg_peb_buf); 965 vfree(ubi->dbg_peb_buf);
959#endif 966#endif
960 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); 967 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num);
961 kfree(ubi); 968 put_device(&ubi->dev);
962 return 0; 969 return 0;
963} 970}
964 971
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 98cf31ed0814..e63c8fc3df3a 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -40,9 +40,9 @@
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41#include <linux/capability.h> 41#include <linux/capability.h>
42#include <linux/uaccess.h> 42#include <linux/uaccess.h>
43#include <linux/smp_lock.h> 43#include <linux/compat.h>
44#include <linux/math64.h>
44#include <mtd/ubi-user.h> 45#include <mtd/ubi-user.h>
45#include <asm/div64.h>
46#include "ubi.h" 46#include "ubi.h"
47 47
48/** 48/**
@@ -195,7 +195,6 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
195 int err, lnum, off, len, tbuf_size; 195 int err, lnum, off, len, tbuf_size;
196 size_t count_save = count; 196 size_t count_save = count;
197 void *tbuf; 197 void *tbuf;
198 uint64_t tmp;
199 198
200 dbg_gen("read %zd bytes from offset %lld of volume %d", 199 dbg_gen("read %zd bytes from offset %lld of volume %d",
201 count, *offp, vol->vol_id); 200 count, *offp, vol->vol_id);
@@ -225,10 +224,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
225 return -ENOMEM; 224 return -ENOMEM;
226 225
227 len = count > tbuf_size ? tbuf_size : count; 226 len = count > tbuf_size ? tbuf_size : count;
228 227 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
229 tmp = *offp;
230 off = do_div(tmp, vol->usable_leb_size);
231 lnum = tmp;
232 228
233 do { 229 do {
234 cond_resched(); 230 cond_resched();
@@ -263,12 +259,9 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
263 return err ? err : count_save - count; 259 return err ? err : count_save - count;
264} 260}
265 261
266#ifdef CONFIG_MTD_UBI_DEBUG_USERSPACE_IO
267
268/* 262/*
269 * This function allows to directly write to dynamic UBI volumes, without 263 * This function allows to directly write to dynamic UBI volumes, without
270 * issuing the volume update operation. Available only as a debugging feature. 264 * issuing the volume update operation.
271 * Very useful for testing UBI.
272 */ 265 */
273static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, 266static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
274 size_t count, loff_t *offp) 267 size_t count, loff_t *offp)
@@ -279,7 +272,9 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
279 int lnum, off, len, tbuf_size, err = 0; 272 int lnum, off, len, tbuf_size, err = 0;
280 size_t count_save = count; 273 size_t count_save = count;
281 char *tbuf; 274 char *tbuf;
282 uint64_t tmp; 275
276 if (!vol->direct_writes)
277 return -EPERM;
283 278
284 dbg_gen("requested: write %zd bytes to offset %lld of volume %u", 279 dbg_gen("requested: write %zd bytes to offset %lld of volume %u",
285 count, *offp, vol->vol_id); 280 count, *offp, vol->vol_id);
@@ -287,10 +282,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
287 if (vol->vol_type == UBI_STATIC_VOLUME) 282 if (vol->vol_type == UBI_STATIC_VOLUME)
288 return -EROFS; 283 return -EROFS;
289 284
290 tmp = *offp; 285 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
291 off = do_div(tmp, vol->usable_leb_size);
292 lnum = tmp;
293
294 if (off & (ubi->min_io_size - 1)) { 286 if (off & (ubi->min_io_size - 1)) {
295 dbg_err("unaligned position"); 287 dbg_err("unaligned position");
296 return -EINVAL; 288 return -EINVAL;
@@ -347,10 +339,6 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
347 return err ? err : count_save - count; 339 return err ? err : count_save - count;
348} 340}
349 341
350#else
351#define vol_cdev_direct_write(file, buf, count, offp) (-EPERM)
352#endif /* CONFIG_MTD_UBI_DEBUG_USERSPACE_IO */
353
354static ssize_t vol_cdev_write(struct file *file, const char __user *buf, 342static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
355 size_t count, loff_t *offp) 343 size_t count, loff_t *offp)
356{ 344{
@@ -402,8 +390,8 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
402 return count; 390 return count;
403} 391}
404 392
405static int vol_cdev_ioctl(struct inode *inode, struct file *file, 393static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
406 unsigned int cmd, unsigned long arg) 394 unsigned long arg)
407{ 395{
408 int err = 0; 396 int err = 0;
409 struct ubi_volume_desc *desc = file->private_data; 397 struct ubi_volume_desc *desc = file->private_data;
@@ -487,7 +475,6 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
487 break; 475 break;
488 } 476 }
489 477
490#ifdef CONFIG_MTD_UBI_DEBUG_USERSPACE_IO
491 /* Logical eraseblock erasure command */ 478 /* Logical eraseblock erasure command */
492 case UBI_IOCEBER: 479 case UBI_IOCEBER:
493 { 480 {
@@ -518,13 +505,77 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
518 err = ubi_wl_flush(ubi); 505 err = ubi_wl_flush(ubi);
519 break; 506 break;
520 } 507 }
521#endif 508
509 /* Logical eraseblock map command */
510 case UBI_IOCEBMAP:
511 {
512 struct ubi_map_req req;
513
514 err = copy_from_user(&req, argp, sizeof(struct ubi_map_req));
515 if (err) {
516 err = -EFAULT;
517 break;
518 }
519 err = ubi_leb_map(desc, req.lnum, req.dtype);
520 break;
521 }
522
523 /* Logical eraseblock un-map command */
524 case UBI_IOCEBUNMAP:
525 {
526 int32_t lnum;
527
528 err = get_user(lnum, (__user int32_t *)argp);
529 if (err) {
530 err = -EFAULT;
531 break;
532 }
533 err = ubi_leb_unmap(desc, lnum);
534 break;
535 }
536
537 /* Check if logical eraseblock is mapped command */
538 case UBI_IOCEBISMAP:
539 {
540 int32_t lnum;
541
542 err = get_user(lnum, (__user int32_t *)argp);
543 if (err) {
544 err = -EFAULT;
545 break;
546 }
547 err = ubi_is_mapped(desc, lnum);
548 break;
549 }
550
551 /* Set volume property command*/
552 case UBI_IOCSETPROP:
553 {
554 struct ubi_set_prop_req req;
555
556 err = copy_from_user(&req, argp,
557 sizeof(struct ubi_set_prop_req));
558 if (err) {
559 err = -EFAULT;
560 break;
561 }
562 switch (req.property) {
563 case UBI_PROP_DIRECT_WRITE:
564 mutex_lock(&ubi->volumes_mutex);
565 desc->vol->direct_writes = !!req.value;
566 mutex_unlock(&ubi->volumes_mutex);
567 break;
568 default:
569 err = -EINVAL;
570 break;
571 }
572 break;
573 }
522 574
523 default: 575 default:
524 err = -ENOTTY; 576 err = -ENOTTY;
525 break; 577 break;
526 } 578 }
527
528 return err; 579 return err;
529} 580}
530 581
@@ -762,8 +813,8 @@ out_free:
762 return err; 813 return err;
763} 814}
764 815
765static int ubi_cdev_ioctl(struct inode *inode, struct file *file, 816static long ubi_cdev_ioctl(struct file *file, unsigned int cmd,
766 unsigned int cmd, unsigned long arg) 817 unsigned long arg)
767{ 818{
768 int err = 0; 819 int err = 0;
769 struct ubi_device *ubi; 820 struct ubi_device *ubi;
@@ -773,7 +824,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
773 if (!capable(CAP_SYS_RESOURCE)) 824 if (!capable(CAP_SYS_RESOURCE))
774 return -EPERM; 825 return -EPERM;
775 826
776 ubi = ubi_get_by_major(imajor(inode)); 827 ubi = ubi_get_by_major(imajor(file->f_mapping->host));
777 if (!ubi) 828 if (!ubi)
778 return -ENODEV; 829 return -ENODEV;
779 830
@@ -843,7 +894,6 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
843 case UBI_IOCRSVOL: 894 case UBI_IOCRSVOL:
844 { 895 {
845 int pebs; 896 int pebs;
846 uint64_t tmp;
847 struct ubi_rsvol_req req; 897 struct ubi_rsvol_req req;
848 898
849 dbg_gen("re-size volume"); 899 dbg_gen("re-size volume");
@@ -863,9 +913,8 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
863 break; 913 break;
864 } 914 }
865 915
866 tmp = req.bytes; 916 pebs = div_u64(req.bytes + desc->vol->usable_leb_size - 1,
867 pebs = !!do_div(tmp, desc->vol->usable_leb_size); 917 desc->vol->usable_leb_size);
868 pebs += tmp;
869 918
870 mutex_lock(&ubi->volumes_mutex); 919 mutex_lock(&ubi->volumes_mutex);
871 err = ubi_resize_volume(desc, pebs); 920 err = ubi_resize_volume(desc, pebs);
@@ -909,8 +958,8 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
909 return err; 958 return err;
910} 959}
911 960
912static int ctrl_cdev_ioctl(struct inode *inode, struct file *file, 961static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,
913 unsigned int cmd, unsigned long arg) 962 unsigned long arg)
914{ 963{
915 int err = 0; 964 int err = 0;
916 void __user *argp = (void __user *)arg; 965 void __user *argp = (void __user *)arg;
@@ -986,26 +1035,59 @@ static int ctrl_cdev_ioctl(struct inode *inode, struct file *file,
986 return err; 1035 return err;
987} 1036}
988 1037
989/* UBI control character device operations */ 1038#ifdef CONFIG_COMPAT
990struct file_operations ubi_ctrl_cdev_operations = { 1039static long vol_cdev_compat_ioctl(struct file *file, unsigned int cmd,
991 .ioctl = ctrl_cdev_ioctl, 1040 unsigned long arg)
992 .owner = THIS_MODULE, 1041{
1042 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1043
1044 return vol_cdev_ioctl(file, cmd, translated_arg);
1045}
1046
1047static long ubi_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1048 unsigned long arg)
1049{
1050 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1051
1052 return ubi_cdev_ioctl(file, cmd, translated_arg);
1053}
1054
1055static long ctrl_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1056 unsigned long arg)
1057{
1058 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1059
1060 return ctrl_cdev_ioctl(file, cmd, translated_arg);
1061}
1062#else
1063#define vol_cdev_compat_ioctl NULL
1064#define ubi_cdev_compat_ioctl NULL
1065#define ctrl_cdev_compat_ioctl NULL
1066#endif
1067
1068/* UBI volume character device operations */
1069const struct file_operations ubi_vol_cdev_operations = {
1070 .owner = THIS_MODULE,
1071 .open = vol_cdev_open,
1072 .release = vol_cdev_release,
1073 .llseek = vol_cdev_llseek,
1074 .read = vol_cdev_read,
1075 .write = vol_cdev_write,
1076 .unlocked_ioctl = vol_cdev_ioctl,
1077 .compat_ioctl = vol_cdev_compat_ioctl,
993}; 1078};
994 1079
995/* UBI character device operations */ 1080/* UBI character device operations */
996struct file_operations ubi_cdev_operations = { 1081const struct file_operations ubi_cdev_operations = {
997 .owner = THIS_MODULE, 1082 .owner = THIS_MODULE,
998 .ioctl = ubi_cdev_ioctl, 1083 .llseek = no_llseek,
999 .llseek = no_llseek, 1084 .unlocked_ioctl = ubi_cdev_ioctl,
1085 .compat_ioctl = ubi_cdev_compat_ioctl,
1000}; 1086};
1001 1087
1002/* UBI volume character device operations */ 1088/* UBI control character device operations */
1003struct file_operations ubi_vol_cdev_operations = { 1089const struct file_operations ubi_ctrl_cdev_operations = {
1004 .owner = THIS_MODULE, 1090 .owner = THIS_MODULE,
1005 .open = vol_cdev_open, 1091 .unlocked_ioctl = ctrl_cdev_ioctl,
1006 .release = vol_cdev_release, 1092 .compat_ioctl = ctrl_cdev_compat_ioctl,
1007 .llseek = vol_cdev_llseek,
1008 .read = vol_cdev_read,
1009 .write = vol_cdev_write,
1010 .ioctl = vol_cdev_ioctl,
1011}; 1093};
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 6dd4f5e77f82..49cd55ade9c8 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -28,7 +28,7 @@
28 * eraseblock size is equivalent to the logical eraseblock size of the volume. 28 * eraseblock size is equivalent to the logical eraseblock size of the volume.
29 */ 29 */
30 30
31#include <asm/div64.h> 31#include <linux/math64.h>
32#include "ubi.h" 32#include "ubi.h"
33 33
34/** 34/**
@@ -109,7 +109,6 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
109 int err = 0, lnum, offs, total_read; 109 int err = 0, lnum, offs, total_read;
110 struct ubi_volume *vol; 110 struct ubi_volume *vol;
111 struct ubi_device *ubi; 111 struct ubi_device *ubi;
112 uint64_t tmp = from;
113 112
114 dbg_gen("read %zd bytes from offset %lld", len, from); 113 dbg_gen("read %zd bytes from offset %lld", len, from);
115 114
@@ -119,9 +118,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
119 vol = container_of(mtd, struct ubi_volume, gluebi_mtd); 118 vol = container_of(mtd, struct ubi_volume, gluebi_mtd);
120 ubi = vol->ubi; 119 ubi = vol->ubi;
121 120
122 offs = do_div(tmp, mtd->erasesize); 121 lnum = div_u64_rem(from, mtd->erasesize, &offs);
123 lnum = tmp;
124
125 total_read = len; 122 total_read = len;
126 while (total_read) { 123 while (total_read) {
127 size_t to_read = mtd->erasesize - offs; 124 size_t to_read = mtd->erasesize - offs;
@@ -160,7 +157,6 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
160 int err = 0, lnum, offs, total_written; 157 int err = 0, lnum, offs, total_written;
161 struct ubi_volume *vol; 158 struct ubi_volume *vol;
162 struct ubi_device *ubi; 159 struct ubi_device *ubi;
163 uint64_t tmp = to;
164 160
165 dbg_gen("write %zd bytes to offset %lld", len, to); 161 dbg_gen("write %zd bytes to offset %lld", len, to);
166 162
@@ -173,8 +169,7 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
173 if (ubi->ro_mode) 169 if (ubi->ro_mode)
174 return -EROFS; 170 return -EROFS;
175 171
176 offs = do_div(tmp, mtd->erasesize); 172 lnum = div_u64_rem(to, mtd->erasesize, &offs);
177 lnum = tmp;
178 173
179 if (len % mtd->writesize || offs % mtd->writesize) 174 if (len % mtd->writesize || offs % mtd->writesize)
180 return -EINVAL; 175 return -EINVAL;
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index ecde202a5a12..c3d653ba5ca0 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -42,7 +42,7 @@
42 42
43#include <linux/err.h> 43#include <linux/err.h>
44#include <linux/crc32.h> 44#include <linux/crc32.h>
45#include <asm/div64.h> 45#include <linux/math64.h>
46#include "ubi.h" 46#include "ubi.h"
47 47
48#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 48#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -904,10 +904,8 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
904 dbg_msg("scanning is finished"); 904 dbg_msg("scanning is finished");
905 905
906 /* Calculate mean erase counter */ 906 /* Calculate mean erase counter */
907 if (si->ec_count) { 907 if (si->ec_count)
908 do_div(si->ec_sum, si->ec_count); 908 si->mean_ec = div_u64(si->ec_sum, si->ec_count);
909 si->mean_ec = si->ec_sum;
910 }
911 909
912 if (si->is_empty) 910 if (si->is_empty)
913 ubi_msg("empty MTD device detected"); 911 ubi_msg("empty MTD device detected");
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 4a8ec485c91d..c055511bb1b2 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -206,6 +206,7 @@ struct ubi_volume_desc;
206 * @upd_marker: %1 if the update marker is set for this volume 206 * @upd_marker: %1 if the update marker is set for this volume
207 * @updating: %1 if the volume is being updated 207 * @updating: %1 if the volume is being updated
208 * @changing_leb: %1 if the atomic LEB change ioctl command is in progress 208 * @changing_leb: %1 if the atomic LEB change ioctl command is in progress
209 * @direct_writes: %1 if direct writes are enabled for this volume
209 * 210 *
210 * @gluebi_desc: gluebi UBI volume descriptor 211 * @gluebi_desc: gluebi UBI volume descriptor
211 * @gluebi_refcount: reference count of the gluebi MTD device 212 * @gluebi_refcount: reference count of the gluebi MTD device
@@ -253,6 +254,7 @@ struct ubi_volume {
253 unsigned int upd_marker:1; 254 unsigned int upd_marker:1;
254 unsigned int updating:1; 255 unsigned int updating:1;
255 unsigned int changing_leb:1; 256 unsigned int changing_leb:1;
257 unsigned int direct_writes:1;
256 258
257#ifdef CONFIG_MTD_UBI_GLUEBI 259#ifdef CONFIG_MTD_UBI_GLUEBI
258 /* 260 /*
@@ -304,7 +306,8 @@ struct ubi_wl_entry;
304 * @vtbl_size: size of the volume table in bytes 306 * @vtbl_size: size of the volume table in bytes
305 * @vtbl: in-RAM volume table copy 307 * @vtbl: in-RAM volume table copy
306 * @volumes_mutex: protects on-flash volume table and serializes volume 308 * @volumes_mutex: protects on-flash volume table and serializes volume
307 * changes, like creation, deletion, update, re-size and re-name 309 * changes, like creation, deletion, update, re-size,
310 * re-name and set property
308 * 311 *
309 * @max_ec: current highest erase counter value 312 * @max_ec: current highest erase counter value
310 * @mean_ec: current mean erase counter value 313 * @mean_ec: current mean erase counter value
@@ -449,9 +452,9 @@ struct ubi_device {
449}; 452};
450 453
451extern struct kmem_cache *ubi_wl_entry_slab; 454extern struct kmem_cache *ubi_wl_entry_slab;
452extern struct file_operations ubi_ctrl_cdev_operations; 455extern const struct file_operations ubi_ctrl_cdev_operations;
453extern struct file_operations ubi_cdev_operations; 456extern const struct file_operations ubi_cdev_operations;
454extern struct file_operations ubi_vol_cdev_operations; 457extern const struct file_operations ubi_vol_cdev_operations;
455extern struct class *ubi_class; 458extern struct class *ubi_class;
456extern struct mutex ubi_devices_mutex; 459extern struct mutex ubi_devices_mutex;
457 460
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 8b89cc18ff0b..6b4d1ae891ae 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -40,7 +40,7 @@
40 40
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/uaccess.h> 42#include <linux/uaccess.h>
43#include <asm/div64.h> 43#include <linux/math64.h>
44#include "ubi.h" 44#include "ubi.h"
45 45
46/** 46/**
@@ -89,7 +89,6 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
89 long long bytes) 89 long long bytes)
90{ 90{
91 int err; 91 int err;
92 uint64_t tmp;
93 struct ubi_vtbl_record vtbl_rec; 92 struct ubi_vtbl_record vtbl_rec;
94 93
95 dbg_gen("clear update marker for volume %d", vol->vol_id); 94 dbg_gen("clear update marker for volume %d", vol->vol_id);
@@ -101,9 +100,9 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
101 100
102 if (vol->vol_type == UBI_STATIC_VOLUME) { 101 if (vol->vol_type == UBI_STATIC_VOLUME) {
103 vol->corrupted = 0; 102 vol->corrupted = 0;
104 vol->used_bytes = tmp = bytes; 103 vol->used_bytes = bytes;
105 vol->last_eb_bytes = do_div(tmp, vol->usable_leb_size); 104 vol->used_ebs = div_u64_rem(bytes, vol->usable_leb_size,
106 vol->used_ebs = tmp; 105 &vol->last_eb_bytes);
107 if (vol->last_eb_bytes) 106 if (vol->last_eb_bytes)
108 vol->used_ebs += 1; 107 vol->used_ebs += 1;
109 else 108 else
@@ -131,7 +130,6 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
131 long long bytes) 130 long long bytes)
132{ 131{
133 int i, err; 132 int i, err;
134 uint64_t tmp;
135 133
136 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes); 134 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes);
137 ubi_assert(!vol->updating && !vol->changing_leb); 135 ubi_assert(!vol->updating && !vol->changing_leb);
@@ -161,9 +159,8 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
161 if (!vol->upd_buf) 159 if (!vol->upd_buf)
162 return -ENOMEM; 160 return -ENOMEM;
163 161
164 tmp = bytes; 162 vol->upd_ebs = div_u64(bytes + vol->usable_leb_size - 1,
165 vol->upd_ebs = !!do_div(tmp, vol->usable_leb_size); 163 vol->usable_leb_size);
166 vol->upd_ebs += tmp;
167 vol->upd_bytes = bytes; 164 vol->upd_bytes = bytes;
168 vol->upd_received = 0; 165 vol->upd_received = 0;
169 return 0; 166 return 0;
@@ -282,7 +279,6 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
282int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol, 279int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
283 const void __user *buf, int count) 280 const void __user *buf, int count)
284{ 281{
285 uint64_t tmp;
286 int lnum, offs, err = 0, len, to_write = count; 282 int lnum, offs, err = 0, len, to_write = count;
287 283
288 dbg_gen("write %d of %lld bytes, %lld already passed", 284 dbg_gen("write %d of %lld bytes, %lld already passed",
@@ -291,10 +287,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
291 if (ubi->ro_mode) 287 if (ubi->ro_mode)
292 return -EROFS; 288 return -EROFS;
293 289
294 tmp = vol->upd_received; 290 lnum = div_u64_rem(vol->upd_received, vol->usable_leb_size, &offs);
295 offs = do_div(tmp, vol->usable_leb_size);
296 lnum = tmp;
297
298 if (vol->upd_received + count > vol->upd_bytes) 291 if (vol->upd_received + count > vol->upd_bytes)
299 to_write = count = vol->upd_bytes - vol->upd_received; 292 to_write = count = vol->upd_bytes - vol->upd_received;
300 293
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 22e1d7398fce..df5483562b7a 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include <linux/err.h> 26#include <linux/err.h>
27#include <asm/div64.h> 27#include <linux/math64.h>
28#include "ubi.h" 28#include "ubi.h"
29 29
30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -205,7 +205,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
205 int i, err, vol_id = req->vol_id, do_free = 1; 205 int i, err, vol_id = req->vol_id, do_free = 1;
206 struct ubi_volume *vol; 206 struct ubi_volume *vol;
207 struct ubi_vtbl_record vtbl_rec; 207 struct ubi_vtbl_record vtbl_rec;
208 uint64_t bytes;
209 dev_t dev; 208 dev_t dev;
210 209
211 if (ubi->ro_mode) 210 if (ubi->ro_mode)
@@ -255,10 +254,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
255 254
256 /* Calculate how many eraseblocks are requested */ 255 /* Calculate how many eraseblocks are requested */
257 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment; 256 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment;
258 bytes = req->bytes; 257 vol->reserved_pebs += div_u64(req->bytes + vol->usable_leb_size - 1,
259 if (do_div(bytes, vol->usable_leb_size)) 258 vol->usable_leb_size);
260 vol->reserved_pebs = 1;
261 vol->reserved_pebs += bytes;
262 259
263 /* Reserve physical eraseblocks */ 260 /* Reserve physical eraseblocks */
264 if (vol->reserved_pebs > ubi->avail_pebs) { 261 if (vol->reserved_pebs > ubi->avail_pebs) {
@@ -301,10 +298,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
301 vol->used_bytes = 298 vol->used_bytes =
302 (long long)vol->used_ebs * vol->usable_leb_size; 299 (long long)vol->used_ebs * vol->usable_leb_size;
303 } else { 300 } else {
304 bytes = vol->used_bytes; 301 vol->used_ebs = div_u64_rem(vol->used_bytes,
305 vol->last_eb_bytes = do_div(bytes, vol->usable_leb_size); 302 vol->usable_leb_size,
306 vol->used_ebs = bytes; 303 &vol->last_eb_bytes);
307 if (vol->last_eb_bytes) 304 if (vol->last_eb_bytes != 0)
308 vol->used_ebs += 1; 305 vol->used_ebs += 1;
309 else 306 else
310 vol->last_eb_bytes = vol->usable_leb_size; 307 vol->last_eb_bytes = vol->usable_leb_size;
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9fe8cb7d43ac..6bdfd47d679d 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1829,7 +1829,7 @@ config 68360_ENET
1829 1829
1830config FEC 1830config FEC
1831 bool "FEC ethernet controller (of ColdFire CPUs)" 1831 bool "FEC ethernet controller (of ColdFire CPUs)"
1832 depends on M523x || M527x || M5272 || M528x || M520x 1832 depends on M523x || M527x || M5272 || M528x || M520x || M532x
1833 help 1833 help
1834 Say Y here if you want to use the built-in 10/100 Fast ethernet 1834 Say Y here if you want to use the built-in 10/100 Fast ethernet
1835 controller on some Motorola ColdFire processors. 1835 controller on some Motorola ColdFire processors.
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 7e33c129d51c..2769083bfe83 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1698,7 +1698,7 @@ static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_priva
1698 /* 1698 /*
1699 * Set MII speed to 2.5 MHz 1699 * Set MII speed to 2.5 MHz
1700 */ 1700 */
1701 fep->phy_speed = ((((MCF_CLK / 2) / (2500000 / 10)) + 5) / 10) * 2; 1701 fep->phy_speed = (MCF_CLK / 3) / (2500000 * 2 ) * 2;
1702 fecp->fec_mii_speed = fep->phy_speed; 1702 fecp->fec_mii_speed = fep->phy_speed;
1703 1703
1704 fec_restart(dev, 0); 1704 fec_restart(dev, 0);
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 3fac8f81d59d..a70cf16ee1ad 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -668,7 +668,7 @@ sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt)
668 * @dev: instance of PCI owned by the driver that's asking 668 * @dev: instance of PCI owned by the driver that's asking
669 * @mask: number of address bits this PCI device can handle 669 * @mask: number of address bits this PCI device can handle
670 * 670 *
671 * See Documentation/DMA-mapping.txt 671 * See Documentation/PCI/PCI-DMA-mapping.txt
672 */ 672 */
673static int sba_dma_supported( struct device *dev, u64 mask) 673static int sba_dma_supported( struct device *dev, u64 mask)
674{ 674{
@@ -680,8 +680,8 @@ static int sba_dma_supported( struct device *dev, u64 mask)
680 return(0); 680 return(0);
681 } 681 }
682 682
683 /* Documentation/DMA-mapping.txt tells drivers to try 64-bit first, 683 /* Documentation/PCI/PCI-DMA-mapping.txt tells drivers to try 64-bit
684 * then fall back to 32-bit if that fails. 684 * first, then fall back to 32-bit if that fails.
685 * We are just "encouraging" 32-bit DMA masks here since we can 685 * We are just "encouraging" 32-bit DMA masks here since we can
686 * never allow IOMMU bypass unless we add special support for ZX1. 686 * never allow IOMMU bypass unless we add special support for ZX1.
687 */ 687 */
@@ -706,7 +706,7 @@ static int sba_dma_supported( struct device *dev, u64 mask)
706 * @size: number of bytes to map in driver buffer. 706 * @size: number of bytes to map in driver buffer.
707 * @direction: R/W or both. 707 * @direction: R/W or both.
708 * 708 *
709 * See Documentation/DMA-mapping.txt 709 * See Documentation/PCI/PCI-DMA-mapping.txt
710 */ 710 */
711static dma_addr_t 711static dma_addr_t
712sba_map_single(struct device *dev, void *addr, size_t size, 712sba_map_single(struct device *dev, void *addr, size_t size,
@@ -785,7 +785,7 @@ sba_map_single(struct device *dev, void *addr, size_t size,
785 * @size: number of bytes mapped in driver buffer. 785 * @size: number of bytes mapped in driver buffer.
786 * @direction: R/W or both. 786 * @direction: R/W or both.
787 * 787 *
788 * See Documentation/DMA-mapping.txt 788 * See Documentation/PCI/PCI-DMA-mapping.txt
789 */ 789 */
790static void 790static void
791sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, 791sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
@@ -861,7 +861,7 @@ sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
861 * @size: number of bytes mapped in driver buffer. 861 * @size: number of bytes mapped in driver buffer.
862 * @dma_handle: IOVA of new buffer. 862 * @dma_handle: IOVA of new buffer.
863 * 863 *
864 * See Documentation/DMA-mapping.txt 864 * See Documentation/PCI/PCI-DMA-mapping.txt
865 */ 865 */
866static void *sba_alloc_consistent(struct device *hwdev, size_t size, 866static void *sba_alloc_consistent(struct device *hwdev, size_t size,
867 dma_addr_t *dma_handle, gfp_t gfp) 867 dma_addr_t *dma_handle, gfp_t gfp)
@@ -892,7 +892,7 @@ static void *sba_alloc_consistent(struct device *hwdev, size_t size,
892 * @vaddr: virtual address IOVA of "consistent" buffer. 892 * @vaddr: virtual address IOVA of "consistent" buffer.
893 * @dma_handler: IO virtual address of "consistent" buffer. 893 * @dma_handler: IO virtual address of "consistent" buffer.
894 * 894 *
895 * See Documentation/DMA-mapping.txt 895 * See Documentation/PCI/PCI-DMA-mapping.txt
896 */ 896 */
897static void 897static void
898sba_free_consistent(struct device *hwdev, size_t size, void *vaddr, 898sba_free_consistent(struct device *hwdev, size_t size, void *vaddr,
@@ -927,7 +927,7 @@ int dump_run_sg = 0;
927 * @nents: number of entries in list 927 * @nents: number of entries in list
928 * @direction: R/W or both. 928 * @direction: R/W or both.
929 * 929 *
930 * See Documentation/DMA-mapping.txt 930 * See Documentation/PCI/PCI-DMA-mapping.txt
931 */ 931 */
932static int 932static int
933sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents, 933sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
@@ -1011,7 +1011,7 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
1011 * @nents: number of entries in list 1011 * @nents: number of entries in list
1012 * @direction: R/W or both. 1012 * @direction: R/W or both.
1013 * 1013 *
1014 * See Documentation/DMA-mapping.txt 1014 * See Documentation/PCI/PCI-DMA-mapping.txt
1015 */ 1015 */
1016static void 1016static void
1017sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, 1017sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 7c789f0a94d7..de91ddab0a86 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -382,6 +382,11 @@ static int __init hp_wmi_input_setup(void)
382 case KE_SW: 382 case KE_SW:
383 set_bit(EV_SW, hp_wmi_input_dev->evbit); 383 set_bit(EV_SW, hp_wmi_input_dev->evbit);
384 set_bit(key->keycode, hp_wmi_input_dev->swbit); 384 set_bit(key->keycode, hp_wmi_input_dev->swbit);
385
386 /* Set initial dock state */
387 input_report_switch(hp_wmi_input_dev, key->keycode,
388 hp_wmi_dock_state());
389 input_sync(hp_wmi_input_dev);
385 break; 390 break;
386 } 391 }
387 } 392 }
@@ -441,6 +446,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
441 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; 446 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
442 bluetooth_rfkill->user_claim_unsupported = 1; 447 bluetooth_rfkill->user_claim_unsupported = 1;
443 err = rfkill_register(bluetooth_rfkill); 448 err = rfkill_register(bluetooth_rfkill);
449 if (err)
444 goto register_bluetooth_error; 450 goto register_bluetooth_error;
445 } 451 }
446 452
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 91ef669d98f6..a1a511bdec8c 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1322,7 +1322,9 @@ static int ibmvfc_map_sg_data(struct scsi_cmnd *scmd,
1322 &evt->ext_list_token); 1322 &evt->ext_list_token);
1323 1323
1324 if (!evt->ext_list) { 1324 if (!evt->ext_list) {
1325 scmd_printk(KERN_ERR, scmd, "Can't allocate memory for scatterlist\n"); 1325 scsi_dma_unmap(scmd);
1326 if (vhost->log_level > IBMVFC_DEFAULT_LOG_LEVEL)
1327 scmd_printk(KERN_ERR, scmd, "Can't allocate memory for scatterlist\n");
1326 return -ENOMEM; 1328 return -ENOMEM;
1327 } 1329 }
1328 } 1330 }
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 7225b6e2029e..257c24115de9 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1981,6 +1981,7 @@ void iscsi_pool_free(struct iscsi_pool *q)
1981 kfree(q->pool[i]); 1981 kfree(q->pool[i]);
1982 if (q->pool) 1982 if (q->pool)
1983 kfree(q->pool); 1983 kfree(q->pool);
1984 kfree(q->queue);
1984} 1985}
1985EXPORT_SYMBOL_GPL(iscsi_pool_free); 1986EXPORT_SYMBOL_GPL(iscsi_pool_free);
1986 1987
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index c7acef50d5da..33a3c13fd893 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1016,6 +1016,9 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
1016 struct Scsi_Host *host = rport_to_shost(rport); 1016 struct Scsi_Host *host = rport_to_shost(rport);
1017 fc_port_t *fcport = *(fc_port_t **)rport->dd_data; 1017 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
1018 1018
1019 if (!fcport)
1020 return;
1021
1019 qla2x00_abort_fcport_cmds(fcport); 1022 qla2x00_abort_fcport_cmds(fcport);
1020 1023
1021 /* 1024 /*
@@ -1033,6 +1036,9 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
1033{ 1036{
1034 fc_port_t *fcport = *(fc_port_t **)rport->dd_data; 1037 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
1035 1038
1039 if (!fcport)
1040 return;
1041
1036 /* 1042 /*
1037 * At this point all fcport's software-states are cleared. Perform any 1043 * At this point all fcport's software-states are cleared. Perform any
1038 * final cleanup of firmware resources (PCBs and XCBs). 1044 * final cleanup of firmware resources (PCBs and XCBs).
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index ba4913353752..a336b4bc81a7 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -34,6 +34,7 @@ extern void qla24xx_update_fw_options(scsi_qla_host_t *);
34extern void qla81xx_update_fw_options(scsi_qla_host_t *); 34extern void qla81xx_update_fw_options(scsi_qla_host_t *);
35extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *); 35extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *);
36extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *); 36extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *);
37extern int qla81xx_load_risc(scsi_qla_host_t *, uint32_t *);
37 38
38extern int qla2x00_loop_resync(scsi_qla_host_t *); 39extern int qla2x00_loop_resync(scsi_qla_host_t *);
39 40
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 9ad4d0968e5c..f6368a1d3021 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -3562,6 +3562,9 @@ qla24xx_reset_adapter(scsi_qla_host_t *vha)
3562 WRT_REG_DWORD(&reg->hccr, HCCRX_REL_RISC_PAUSE); 3562 WRT_REG_DWORD(&reg->hccr, HCCRX_REL_RISC_PAUSE);
3563 RD_REG_DWORD(&reg->hccr); 3563 RD_REG_DWORD(&reg->hccr);
3564 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3564 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3565
3566 if (IS_NOPOLLING_TYPE(ha))
3567 ha->isp_ops->enable_intrs(ha);
3565} 3568}
3566 3569
3567/* On sparc systems, obtain port and node WWN from firmware 3570/* On sparc systems, obtain port and node WWN from firmware
@@ -3847,6 +3850,10 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr)
3847 uint32_t i; 3850 uint32_t i;
3848 struct qla_hw_data *ha = vha->hw; 3851 struct qla_hw_data *ha = vha->hw;
3849 struct req_que *req = ha->req_q_map[0]; 3852 struct req_que *req = ha->req_q_map[0];
3853
3854 qla_printk(KERN_INFO, ha,
3855 "FW: Loading from flash (%x)...\n", ha->flt_region_fw);
3856
3850 rval = QLA_SUCCESS; 3857 rval = QLA_SUCCESS;
3851 3858
3852 segments = FA_RISC_CODE_SEGMENTS; 3859 segments = FA_RISC_CODE_SEGMENTS;
@@ -4022,8 +4029,8 @@ fail_fw_integrity:
4022 return QLA_FUNCTION_FAILED; 4029 return QLA_FUNCTION_FAILED;
4023} 4030}
4024 4031
4025int 4032static int
4026qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) 4033qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
4027{ 4034{
4028 int rval; 4035 int rval;
4029 int segments, fragment; 4036 int segments, fragment;
@@ -4043,12 +4050,12 @@ qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
4043 qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " 4050 qla_printk(KERN_ERR, ha, "Firmware images can be retrieved "
4044 "from: " QLA_FW_URL ".\n"); 4051 "from: " QLA_FW_URL ".\n");
4045 4052
4046 /* Try to load RISC code from flash. */ 4053 return QLA_FUNCTION_FAILED;
4047 qla_printk(KERN_ERR, ha, "Attempting to load (potentially "
4048 "outdated) firmware from flash.\n");
4049 return qla24xx_load_risc_flash(vha, srisc_addr);
4050 } 4054 }
4051 4055
4056 qla_printk(KERN_INFO, ha,
4057 "FW: Loading via request-firmware...\n");
4058
4052 rval = QLA_SUCCESS; 4059 rval = QLA_SUCCESS;
4053 4060
4054 segments = FA_RISC_CODE_SEGMENTS; 4061 segments = FA_RISC_CODE_SEGMENTS;
@@ -4133,6 +4140,40 @@ fail_fw_integrity:
4133 return QLA_FUNCTION_FAILED; 4140 return QLA_FUNCTION_FAILED;
4134} 4141}
4135 4142
4143int
4144qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
4145{
4146 int rval;
4147
4148 /*
4149 * FW Load priority:
4150 * 1) Firmware via request-firmware interface (.bin file).
4151 * 2) Firmware residing in flash.
4152 */
4153 rval = qla24xx_load_risc_blob(vha, srisc_addr);
4154 if (rval == QLA_SUCCESS)
4155 return rval;
4156
4157 return qla24xx_load_risc_flash(vha, srisc_addr);
4158}
4159
4160int
4161qla81xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
4162{
4163 int rval;
4164
4165 /*
4166 * FW Load priority:
4167 * 1) Firmware residing in flash.
4168 * 2) Firmware via request-firmware interface (.bin file).
4169 */
4170 rval = qla24xx_load_risc_flash(vha, srisc_addr);
4171 if (rval == QLA_SUCCESS)
4172 return rval;
4173
4174 return qla24xx_load_risc_blob(vha, srisc_addr);
4175}
4176
4136void 4177void
4137qla2x00_try_to_stop_firmware(scsi_qla_host_t *vha) 4178qla2x00_try_to_stop_firmware(scsi_qla_host_t *vha)
4138{ 4179{
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 789fc576f222..e28ad81baf1e 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1868,6 +1868,7 @@ qla24xx_disable_msix(struct qla_hw_data *ha)
1868static int 1868static int
1869qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) 1869qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
1870{ 1870{
1871#define MIN_MSIX_COUNT 2
1871 int i, ret; 1872 int i, ret;
1872 struct msix_entry *entries; 1873 struct msix_entry *entries;
1873 struct qla_msix_entry *qentry; 1874 struct qla_msix_entry *qentry;
@@ -1883,12 +1884,16 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
1883 1884
1884 ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); 1885 ret = pci_enable_msix(ha->pdev, entries, ha->msix_count);
1885 if (ret) { 1886 if (ret) {
1887 if (ret < MIN_MSIX_COUNT)
1888 goto msix_failed;
1889
1886 qla_printk(KERN_WARNING, ha, 1890 qla_printk(KERN_WARNING, ha,
1887 "MSI-X: Failed to enable support -- %d/%d\n" 1891 "MSI-X: Failed to enable support -- %d/%d\n"
1888 " Retry with %d vectors\n", ha->msix_count, ret, ret); 1892 " Retry with %d vectors\n", ha->msix_count, ret, ret);
1889 ha->msix_count = ret; 1893 ha->msix_count = ret;
1890 ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); 1894 ret = pci_enable_msix(ha->pdev, entries, ha->msix_count);
1891 if (ret) { 1895 if (ret) {
1896msix_failed:
1892 qla_printk(KERN_WARNING, ha, "MSI-X: Failed to enable" 1897 qla_printk(KERN_WARNING, ha, "MSI-X: Failed to enable"
1893 " support, giving up -- %d/%d\n", 1898 " support, giving up -- %d/%d\n",
1894 ha->msix_count, ret); 1899 ha->msix_count, ret);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index db4df45234a5..f94ffbb98e95 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -58,14 +58,11 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
58 * seconds. This is to serialize actual issuing of mailbox cmds during 58 * seconds. This is to serialize actual issuing of mailbox cmds during
59 * non ISP abort time. 59 * non ISP abort time.
60 */ 60 */
61 if (!abort_active) { 61 if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) {
62 if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, 62 /* Timeout occurred. Return error. */
63 mcp->tov * HZ)) { 63 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
64 /* Timeout occurred. Return error. */ 64 "Exiting.\n", __func__, base_vha->host_no));
65 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 65 return QLA_FUNCTION_TIMEOUT;
66 "Exiting.\n", __func__, base_vha->host_no));
67 return QLA_FUNCTION_TIMEOUT;
68 }
69 } 66 }
70 67
71 ha->flags.mbox_busy = 1; 68 ha->flags.mbox_busy = 1;
@@ -265,8 +262,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
265 } 262 }
266 263
267 /* Allow next mbx cmd to come in. */ 264 /* Allow next mbx cmd to come in. */
268 if (!abort_active) 265 complete(&ha->mbx_cmd_comp);
269 complete(&ha->mbx_cmd_comp);
270 266
271 if (rval) { 267 if (rval) {
272 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, " 268 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index cf32653fe01a..c11f872d3e10 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -65,8 +65,6 @@ MODULE_PARM_DESC(ql2xextended_error_logging,
65 65
66static void qla2x00_free_device(scsi_qla_host_t *); 66static void qla2x00_free_device(scsi_qla_host_t *);
67 67
68static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha);
69
70int ql2xfdmienable=1; 68int ql2xfdmienable=1;
71module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR); 69module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR);
72MODULE_PARM_DESC(ql2xfdmienable, 70MODULE_PARM_DESC(ql2xfdmienable,
@@ -800,6 +798,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
800 if (ha->isp_ops->abort_command(vha, sp, req)) { 798 if (ha->isp_ops->abort_command(vha, sp, req)) {
801 DEBUG2(printk("%s(%ld): abort_command " 799 DEBUG2(printk("%s(%ld): abort_command "
802 "mbx failed.\n", __func__, vha->host_no)); 800 "mbx failed.\n", __func__, vha->host_no));
801 ret = FAILED;
803 } else { 802 } else {
804 DEBUG3(printk("%s(%ld): abort_command " 803 DEBUG3(printk("%s(%ld): abort_command "
805 "mbx success.\n", __func__, vha->host_no)); 804 "mbx success.\n", __func__, vha->host_no));
@@ -1241,9 +1240,8 @@ qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type)
1241 * supported addressing method. 1240 * supported addressing method.
1242 */ 1241 */
1243static void 1242static void
1244qla2x00_config_dma_addressing(scsi_qla_host_t *vha) 1243qla2x00_config_dma_addressing(struct qla_hw_data *ha)
1245{ 1244{
1246 struct qla_hw_data *ha = vha->hw;
1247 /* Assume a 32bit DMA mask. */ 1245 /* Assume a 32bit DMA mask. */
1248 ha->flags.enable_64bit_addressing = 0; 1246 ha->flags.enable_64bit_addressing = 0;
1249 1247
@@ -1480,7 +1478,7 @@ static struct isp_operations qla81xx_isp_ops = {
1480 .reset_adapter = qla24xx_reset_adapter, 1478 .reset_adapter = qla24xx_reset_adapter,
1481 .nvram_config = qla81xx_nvram_config, 1479 .nvram_config = qla81xx_nvram_config,
1482 .update_fw_options = qla81xx_update_fw_options, 1480 .update_fw_options = qla81xx_update_fw_options,
1483 .load_risc = qla24xx_load_risc, 1481 .load_risc = qla81xx_load_risc,
1484 .pci_info_str = qla24xx_pci_info_str, 1482 .pci_info_str = qla24xx_pci_info_str,
1485 .fw_version_str = qla24xx_fw_version_str, 1483 .fw_version_str = qla24xx_fw_version_str,
1486 .intr_handler = qla24xx_intr_handler, 1484 .intr_handler = qla24xx_intr_handler,
@@ -1869,6 +1867,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1869 1867
1870 set_bit(0, (unsigned long *) ha->vp_idx_map); 1868 set_bit(0, (unsigned long *) ha->vp_idx_map);
1871 1869
1870 qla2x00_config_dma_addressing(ha);
1872 ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); 1871 ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
1873 if (!ret) { 1872 if (!ret) {
1874 qla_printk(KERN_WARNING, ha, 1873 qla_printk(KERN_WARNING, ha,
@@ -1888,13 +1887,13 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1888 "[ERROR] Failed to allocate memory for scsi_host\n"); 1887 "[ERROR] Failed to allocate memory for scsi_host\n");
1889 1888
1890 ret = -ENOMEM; 1889 ret = -ENOMEM;
1890 qla2x00_mem_free(ha);
1891 qla2x00_free_que(ha, req, rsp);
1891 goto probe_hw_failed; 1892 goto probe_hw_failed;
1892 } 1893 }
1893 1894
1894 pci_set_drvdata(pdev, base_vha); 1895 pci_set_drvdata(pdev, base_vha);
1895 1896
1896 qla2x00_config_dma_addressing(base_vha);
1897
1898 host = base_vha->host; 1897 host = base_vha->host;
1899 base_vha->req_ques[0] = req->id; 1898 base_vha->req_ques[0] = req->id;
1900 host->can_queue = req->length + 128; 1899 host->can_queue = req->length + 128;
@@ -1917,14 +1916,13 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1917 /* Set up the irqs */ 1916 /* Set up the irqs */
1918 ret = qla2x00_request_irqs(ha, rsp); 1917 ret = qla2x00_request_irqs(ha, rsp);
1919 if (ret) 1918 if (ret)
1920 goto probe_failed; 1919 goto probe_init_failed;
1921
1922 /* Alloc arrays of request and response ring ptrs */ 1920 /* Alloc arrays of request and response ring ptrs */
1923 if (!qla2x00_alloc_queues(ha)) { 1921 if (!qla2x00_alloc_queues(ha)) {
1924 qla_printk(KERN_WARNING, ha, 1922 qla_printk(KERN_WARNING, ha,
1925 "[ERROR] Failed to allocate memory for queue" 1923 "[ERROR] Failed to allocate memory for queue"
1926 " pointers\n"); 1924 " pointers\n");
1927 goto probe_failed; 1925 goto probe_init_failed;
1928 } 1926 }
1929 ha->rsp_q_map[0] = rsp; 1927 ha->rsp_q_map[0] = rsp;
1930 ha->req_q_map[0] = req; 1928 ha->req_q_map[0] = req;
@@ -1997,6 +1995,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1997 1995
1998 return 0; 1996 return 0;
1999 1997
1998probe_init_failed:
1999 qla2x00_free_que(ha, req, rsp);
2000 ha->max_queues = 0;
2001
2000probe_failed: 2002probe_failed:
2001 qla2x00_free_device(base_vha); 2003 qla2x00_free_device(base_vha);
2002 2004
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 303f8ee11f25..9c3b694c049d 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -944,9 +944,9 @@ qla24xx_unprotect_flash(struct qla_hw_data *ha)
944 if (!ha->fdt_wrt_disable) 944 if (!ha->fdt_wrt_disable)
945 return; 945 return;
946 946
947 /* Disable flash write-protection. */ 947 /* Disable flash write-protection, first clear SR protection bit */
948 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); 948 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0);
949 /* Some flash parts need an additional zero-write to clear bits.*/ 949 /* Then write zero again to clear remaining SR bits.*/
950 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); 950 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0);
951} 951}
952 952
@@ -980,12 +980,11 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
980 uint32_t dwords) 980 uint32_t dwords)
981{ 981{
982 int ret; 982 int ret;
983 uint32_t liter, miter; 983 uint32_t liter;
984 uint32_t sec_mask, rest_addr; 984 uint32_t sec_mask, rest_addr;
985 uint32_t fdata, findex; 985 uint32_t fdata;
986 dma_addr_t optrom_dma; 986 dma_addr_t optrom_dma;
987 void *optrom = NULL; 987 void *optrom = NULL;
988 uint32_t *s, *d;
989 struct qla_hw_data *ha = vha->hw; 988 struct qla_hw_data *ha = vha->hw;
990 989
991 ret = QLA_SUCCESS; 990 ret = QLA_SUCCESS;
@@ -1003,17 +1002,15 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
1003 } 1002 }
1004 1003
1005 rest_addr = (ha->fdt_block_size >> 2) - 1; 1004 rest_addr = (ha->fdt_block_size >> 2) - 1;
1006 sec_mask = (ha->optrom_size >> 2) - (ha->fdt_block_size >> 2); 1005 sec_mask = ~rest_addr;
1007 1006
1008 qla24xx_unprotect_flash(ha); 1007 qla24xx_unprotect_flash(ha);
1009 1008
1010 for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { 1009 for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) {
1011 1010 fdata = (faddr & sec_mask) << 2;
1012 findex = faddr;
1013 fdata = (findex & sec_mask) << 2;
1014 1011
1015 /* Are we at the beginning of a sector? */ 1012 /* Are we at the beginning of a sector? */
1016 if ((findex & rest_addr) == 0) { 1013 if ((faddr & rest_addr) == 0) {
1017 /* Do sector unprotect. */ 1014 /* Do sector unprotect. */
1018 if (ha->fdt_unprotect_sec_cmd) 1015 if (ha->fdt_unprotect_sec_cmd)
1019 qla24xx_write_flash_dword(ha, 1016 qla24xx_write_flash_dword(ha,
@@ -1024,7 +1021,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
1024 (fdata & 0xff00) |((fdata << 16) & 1021 (fdata & 0xff00) |((fdata << 16) &
1025 0xff0000) | ((fdata >> 16) & 0xff)); 1022 0xff0000) | ((fdata >> 16) & 0xff));
1026 if (ret != QLA_SUCCESS) { 1023 if (ret != QLA_SUCCESS) {
1027 DEBUG9(qla_printk("Unable to flash sector: " 1024 DEBUG9(qla_printk("Unable to erase sector: "
1028 "address=%x.\n", faddr)); 1025 "address=%x.\n", faddr));
1029 break; 1026 break;
1030 } 1027 }
@@ -1033,9 +1030,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
1033 /* Go with burst-write. */ 1030 /* Go with burst-write. */
1034 if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { 1031 if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) {
1035 /* Copy data to DMA'ble buffer. */ 1032 /* Copy data to DMA'ble buffer. */
1036 for (miter = 0, s = optrom, d = dwptr; 1033 memcpy(optrom, dwptr, OPTROM_BURST_SIZE);
1037 miter < OPTROM_BURST_DWORDS; miter++, s++, d++)
1038 *s = cpu_to_le32(*d);
1039 1034
1040 ret = qla2x00_load_ram(vha, optrom_dma, 1035 ret = qla2x00_load_ram(vha, optrom_dma,
1041 flash_data_addr(ha, faddr), 1036 flash_data_addr(ha, faddr),
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 808bab6ef06b..cfa4c11a4797 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.03.00-k1" 10#define QLA2XXX_VERSION "8.03.00-k2"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 3 13#define QLA_DRIVER_MINOR_VER 3
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index d6be0762eb91..b586f27c3bd4 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -244,6 +244,7 @@ struct ddb_entry {
244 uint8_t ip_addr[ISCSI_IPADDR_SIZE]; 244 uint8_t ip_addr[ISCSI_IPADDR_SIZE];
245 uint8_t iscsi_name[ISCSI_NAME_SIZE]; /* 72 x48 */ 245 uint8_t iscsi_name[ISCSI_NAME_SIZE]; /* 72 x48 */
246 uint8_t iscsi_alias[0x20]; 246 uint8_t iscsi_alias[0x20];
247 uint8_t isid[6];
247}; 248};
248 249
249/* 250/*
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index 109c5f5985ec..af8c3233e8ae 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -342,8 +342,12 @@ static struct ddb_entry* qla4xxx_get_ddb_entry(struct scsi_qla_host *ha,
342 DEBUG2(printk("scsi%ld: %s: Looking for ddb[%d]\n", ha->host_no, 342 DEBUG2(printk("scsi%ld: %s: Looking for ddb[%d]\n", ha->host_no,
343 __func__, fw_ddb_index)); 343 __func__, fw_ddb_index));
344 list_for_each_entry(ddb_entry, &ha->ddb_list, list) { 344 list_for_each_entry(ddb_entry, &ha->ddb_list, list) {
345 if (memcmp(ddb_entry->iscsi_name, fw_ddb_entry->iscsi_name, 345 if ((memcmp(ddb_entry->iscsi_name, fw_ddb_entry->iscsi_name,
346 ISCSI_NAME_SIZE) == 0) { 346 ISCSI_NAME_SIZE) == 0) &&
347 (ddb_entry->tpgt ==
348 le32_to_cpu(fw_ddb_entry->tgt_portal_grp)) &&
349 (memcmp(ddb_entry->isid, fw_ddb_entry->isid,
350 sizeof(ddb_entry->isid)) == 0)) {
347 found++; 351 found++;
348 break; 352 break;
349 } 353 }
@@ -430,6 +434,8 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha,
430 434
431 ddb_entry->port = le16_to_cpu(fw_ddb_entry->port); 435 ddb_entry->port = le16_to_cpu(fw_ddb_entry->port);
432 ddb_entry->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp); 436 ddb_entry->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp);
437 memcpy(ddb_entry->isid, fw_ddb_entry->isid, sizeof(ddb_entry->isid));
438
433 memcpy(&ddb_entry->iscsi_name[0], &fw_ddb_entry->iscsi_name[0], 439 memcpy(&ddb_entry->iscsi_name[0], &fw_ddb_entry->iscsi_name[0],
434 min(sizeof(ddb_entry->iscsi_name), 440 min(sizeof(ddb_entry->iscsi_name),
435 sizeof(fw_ddb_entry->iscsi_name))); 441 sizeof(fw_ddb_entry->iscsi_name)));
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 2a3671233b15..536d8e510f66 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -806,6 +806,8 @@ pci_default_setup(struct serial_private *priv,
806#define PCI_SUBDEVICE_ID_OCTPRO422 0x0208 806#define PCI_SUBDEVICE_ID_OCTPRO422 0x0208
807#define PCI_SUBDEVICE_ID_POCTAL232 0x0308 807#define PCI_SUBDEVICE_ID_POCTAL232 0x0308
808#define PCI_SUBDEVICE_ID_POCTAL422 0x0408 808#define PCI_SUBDEVICE_ID_POCTAL422 0x0408
809#define PCI_VENDOR_ID_ADVANTECH 0x13fe
810#define PCI_DEVICE_ID_ADVANTECH_PCI3620 0x3620
809 811
810/* Unknown vendors/cards - this should not be in linux/pci_ids.h */ 812/* Unknown vendors/cards - this should not be in linux/pci_ids.h */
811#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 813#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584
@@ -2152,6 +2154,10 @@ static int pciserial_resume_one(struct pci_dev *dev)
2152#endif 2154#endif
2153 2155
2154static struct pci_device_id serial_pci_tbl[] = { 2156static struct pci_device_id serial_pci_tbl[] = {
2157 /* Advantech use PCI_DEVICE_ID_ADVANTECH_PCI3620 (0x3620) as 'PCI_SUBVENDOR_ID' */
2158 { PCI_VENDOR_ID_ADVANTECH, PCI_DEVICE_ID_ADVANTECH_PCI3620,
2159 PCI_DEVICE_ID_ADVANTECH_PCI3620, 0x0001, 0, 0,
2160 pbn_b2_8_921600 },
2155 { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V960, 2161 { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V960,
2156 PCI_SUBVENDOR_ID_CONNECT_TECH, 2162 PCI_SUBVENDOR_ID_CONNECT_TECH,
2157 PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232, 0, 0, 2163 PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232, 0, 0,
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 3e525e38a5d9..7d7f576da202 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -982,7 +982,7 @@ config SERIAL_SH_SCI_CONSOLE
982 982
983config SERIAL_PNX8XXX 983config SERIAL_PNX8XXX
984 bool "Enable PNX8XXX SoCs' UART Support" 984 bool "Enable PNX8XXX SoCs' UART Support"
985 depends on MIPS && SOC_PNX8550 985 depends on MIPS && (SOC_PNX8550 || SOC_PNX833X)
986 select SERIAL_CORE 986 select SERIAL_CORE
987 help 987 help
988 If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330 988 If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index 338cf8a08b43..92187e28608a 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -180,7 +180,7 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
180 return rc; 180 return rc;
181} 181}
182 182
183static void jsm_remove_one(struct pci_dev *pdev) 183static void __devexit jsm_remove_one(struct pci_dev *pdev)
184{ 184{
185 struct jsm_board *brd = pci_get_drvdata(pdev); 185 struct jsm_board *brd = pci_get_drvdata(pdev);
186 int i = 0; 186 int i = 0;
diff --git a/drivers/serial/mcf.c b/drivers/serial/mcf.c
index b2001c5b145c..56841fe5f483 100644
--- a/drivers/serial/mcf.c
+++ b/drivers/serial/mcf.c
@@ -212,10 +212,18 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
212{ 212{
213 unsigned long flags; 213 unsigned long flags;
214 unsigned int baud, baudclk; 214 unsigned int baud, baudclk;
215#if defined(CONFIG_M5272)
216 unsigned int baudfr;
217#endif
215 unsigned char mr1, mr2; 218 unsigned char mr1, mr2;
216 219
217 baud = uart_get_baud_rate(port, termios, old, 0, 230400); 220 baud = uart_get_baud_rate(port, termios, old, 0, 230400);
221#if defined(CONFIG_M5272)
222 baudclk = (MCF_BUSCLK / baud) / 32;
223 baudfr = (((MCF_BUSCLK / baud) + 1) / 2) % 16;
224#else
218 baudclk = ((MCF_BUSCLK / baud) + 16) / 32; 225 baudclk = ((MCF_BUSCLK / baud) + 16) / 32;
226#endif
219 227
220 mr1 = MCFUART_MR1_RXIRQRDY | MCFUART_MR1_RXERRCHAR; 228 mr1 = MCFUART_MR1_RXIRQRDY | MCFUART_MR1_RXERRCHAR;
221 mr2 = 0; 229 mr2 = 0;
@@ -262,6 +270,9 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
262 writeb(mr2, port->membase + MCFUART_UMR); 270 writeb(mr2, port->membase + MCFUART_UMR);
263 writeb((baudclk & 0xff00) >> 8, port->membase + MCFUART_UBG1); 271 writeb((baudclk & 0xff00) >> 8, port->membase + MCFUART_UBG1);
264 writeb((baudclk & 0xff), port->membase + MCFUART_UBG2); 272 writeb((baudclk & 0xff), port->membase + MCFUART_UBG2);
273#if defined(CONFIG_M5272)
274 writeb((baudfr & 0x0f), port->membase + MCFUART_UFPD);
275#endif
265 writeb(MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER, 276 writeb(MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER,
266 port->membase + MCFUART_UCSR); 277 port->membase + MCFUART_UCSR);
267 writeb(MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE, 278 writeb(MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE,
diff --git a/drivers/staging/agnx/agnx.h b/drivers/staging/agnx/agnx.h
index a75b0db3726c..20f36da62475 100644
--- a/drivers/staging/agnx/agnx.h
+++ b/drivers/staging/agnx/agnx.h
@@ -1,6 +1,8 @@
1#ifndef AGNX_H_ 1#ifndef AGNX_H_
2#define AGNX_H_ 2#define AGNX_H_
3 3
4#include <linux/io.h>
5
4#include "xmit.h" 6#include "xmit.h"
5 7
6#define PFX KBUILD_MODNAME ": " 8#define PFX KBUILD_MODNAME ": "
diff --git a/drivers/staging/altpciechdma/altpciechdma.c b/drivers/staging/altpciechdma/altpciechdma.c
index 8e2b4ca0651d..f516140ca976 100644
--- a/drivers/staging/altpciechdma/altpciechdma.c
+++ b/drivers/staging/altpciechdma/altpciechdma.c
@@ -531,7 +531,7 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev)
531 goto fail; 531 goto fail;
532 532
533 /* allocate and map coherently-cached memory for a DMA-able buffer */ 533 /* allocate and map coherently-cached memory for a DMA-able buffer */
534 /* @see 2.6.26.2/Documentation/DMA-mapping.txt line 318 */ 534 /* @see Documentation/PCI/PCI-DMA-mapping.txt, near line 318 */
535 buffer_virt = (u8 *)pci_alloc_consistent(dev, PAGE_SIZE * 4, &buffer_bus); 535 buffer_virt = (u8 *)pci_alloc_consistent(dev, PAGE_SIZE * 4, &buffer_bus);
536 if (!buffer_virt) { 536 if (!buffer_virt) {
537 printk(KERN_DEBUG "Could not allocate coherent DMA buffer.\n"); 537 printk(KERN_DEBUG "Could not allocate coherent DMA buffer.\n");
@@ -846,7 +846,7 @@ static int __devinit probe(struct pci_dev *dev, const struct pci_device_id *id)
846 846
847#if 1 // @todo For now, disable 64-bit, because I do not understand the implications (DAC!) 847#if 1 // @todo For now, disable 64-bit, because I do not understand the implications (DAC!)
848 /* query for DMA transfer */ 848 /* query for DMA transfer */
849 /* @see Documentation/DMA-mapping.txt */ 849 /* @see Documentation/PCI/PCI-DMA-mapping.txt */
850 if (!pci_set_dma_mask(dev, DMA_64BIT_MASK)) { 850 if (!pci_set_dma_mask(dev, DMA_64BIT_MASK)) {
851 pci_set_consistent_dma_mask(dev, DMA_64BIT_MASK); 851 pci_set_consistent_dma_mask(dev, DMA_64BIT_MASK);
852 /* use 64-bit DMA */ 852 /* use 64-bit DMA */
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index 6a4ceacb33f5..758131cad08a 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -319,6 +319,7 @@ int task_get_unused_fd_flags(struct task_struct *tsk, int flags)
319 int fd, error; 319 int fd, error;
320 struct fdtable *fdt; 320 struct fdtable *fdt;
321 unsigned long rlim_cur; 321 unsigned long rlim_cur;
322 unsigned long irqs;
322 323
323 if (files == NULL) 324 if (files == NULL)
324 return -ESRCH; 325 return -ESRCH;
@@ -335,12 +336,11 @@ repeat:
335 * N.B. For clone tasks sharing a files structure, this test 336 * N.B. For clone tasks sharing a files structure, this test
336 * will limit the total number of files that can be opened. 337 * will limit the total number of files that can be opened.
337 */ 338 */
338 rcu_read_lock(); 339 rlim_cur = 0;
339 if (tsk->signal) 340 if (lock_task_sighand(tsk, &irqs)) {
340 rlim_cur = tsk->signal->rlim[RLIMIT_NOFILE].rlim_cur; 341 rlim_cur = tsk->signal->rlim[RLIMIT_NOFILE].rlim_cur;
341 else 342 unlock_task_sighand(tsk, &irqs);
342 rlim_cur = 0; 343 }
343 rcu_read_unlock();
344 if (fd >= rlim_cur) 344 if (fd >= rlim_cur)
345 goto out; 345 goto out;
346 346
@@ -2649,14 +2649,14 @@ static void binder_vma_open(struct vm_area_struct *vma)
2649{ 2649{
2650 struct binder_proc *proc = vma->vm_private_data; 2650 struct binder_proc *proc = vma->vm_private_data;
2651 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) 2651 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
2652 printk(KERN_INFO "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, vma->vm_page_prot.pgprot); 2652 printk(KERN_INFO "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, pgprot_val(vma->vm_page_prot));
2653 dump_stack(); 2653 dump_stack();
2654} 2654}
2655static void binder_vma_close(struct vm_area_struct *vma) 2655static void binder_vma_close(struct vm_area_struct *vma)
2656{ 2656{
2657 struct binder_proc *proc = vma->vm_private_data; 2657 struct binder_proc *proc = vma->vm_private_data;
2658 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) 2658 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
2659 printk(KERN_INFO "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, vma->vm_page_prot.pgprot); 2659 printk(KERN_INFO "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, pgprot_val(vma->vm_page_prot));
2660 proc->vma = NULL; 2660 proc->vma = NULL;
2661} 2661}
2662 2662
@@ -2677,7 +2677,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
2677 vma->vm_end = vma->vm_start + SZ_4M; 2677 vma->vm_end = vma->vm_start + SZ_4M;
2678 2678
2679 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) 2679 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
2680 printk(KERN_INFO "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, vma->vm_page_prot.pgprot); 2680 printk(KERN_INFO "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, pgprot_val(vma->vm_page_prot));
2681 2681
2682 if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) { 2682 if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
2683 ret = -EPERM; 2683 ret = -EPERM;
diff --git a/drivers/staging/android/lowmemorykiller.txt b/drivers/staging/android/lowmemorykiller.txt
new file mode 100644
index 000000000000..bd5c0c028968
--- /dev/null
+++ b/drivers/staging/android/lowmemorykiller.txt
@@ -0,0 +1,16 @@
1The lowmemorykiller driver lets user-space specify a set of memory thresholds
2where processes with a range of oom_adj values will get killed. Specify the
3minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the
4number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both
5files take a comma separated list of numbers in ascending order.
6
7For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
8"1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes
9with a oom_adj value of 8 or higher when the free memory drops below 4096 pages
10and kill processes with a oom_adj value of 0 or higher when the free memory
11drops below 1024 pages.
12
13The driver considers memory used for caches to be free, but if a large
14percentage of the cached memory is locked this can be very inaccurate
15and processes may not get killed until the normal oom killer is triggered.
16
diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index bea68c9fc942..903270cbbe02 100644
--- a/drivers/staging/android/timed_gpio.c
+++ b/drivers/staging/android/timed_gpio.c
@@ -18,7 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/hrtimer.h> 19#include <linux/hrtimer.h>
20#include <linux/err.h> 20#include <linux/err.h>
21#include <asm/arch/gpio.h> 21#include <linux/gpio.h>
22 22
23#include "timed_gpio.h" 23#include "timed_gpio.h"
24 24
@@ -49,7 +49,8 @@ static ssize_t gpio_enable_show(struct device *dev, struct device_attribute *att
49 49
50 if (hrtimer_active(&gpio_data->timer)) { 50 if (hrtimer_active(&gpio_data->timer)) {
51 ktime_t r = hrtimer_get_remaining(&gpio_data->timer); 51 ktime_t r = hrtimer_get_remaining(&gpio_data->timer);
52 remaining = r.tv.sec * 1000 + r.tv.nsec / 1000000; 52 struct timeval t = ktime_to_timeval(r);
53 remaining = t.tv_sec * 1000 + t.tv_usec;
53 } else 54 } else
54 remaining = 0; 55 remaining = 0;
55 56
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index b501bfb9c754..b47ca1e7e383 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -1,6 +1,7 @@
1config COMEDI 1config COMEDI
2 tristate "Data Acquision support (comedi)" 2 tristate "Data Acquision support (comedi)"
3 default N 3 default N
4 depends on m
4 ---help--- 5 ---help---
5 Enable support a wide range of data acquision devices 6 Enable support a wide range of data acquision devices
6 for Linux. 7 for Linux.
diff --git a/drivers/staging/meilhaus/Kconfig b/drivers/staging/meilhaus/Kconfig
index 6def83fa2c96..923af22a4686 100644
--- a/drivers/staging/meilhaus/Kconfig
+++ b/drivers/staging/meilhaus/Kconfig
@@ -4,6 +4,7 @@
4 4
5menuconfig MEILHAUS 5menuconfig MEILHAUS
6 tristate "Meilhaus support" 6 tristate "Meilhaus support"
7 depends on m
7 ---help--- 8 ---help---
8 If you have a Meilhaus card, say Y (or M) here. 9 If you have a Meilhaus card, say Y (or M) here.
9 10
@@ -18,7 +19,7 @@ if MEILHAUS
18config ME0600 19config ME0600
19 tristate "Meilhaus ME-600 support" 20 tristate "Meilhaus ME-600 support"
20 default n 21 default n
21 depends on PCI 22 depends on PCI && m
22 help 23 help
23 This driver supports the Meilhaus ME-600 family of boards 24 This driver supports the Meilhaus ME-600 family of boards
24 that do data collection and multipurpose I/O. 25 that do data collection and multipurpose I/O.
@@ -29,7 +30,7 @@ config ME0600
29config ME0900 30config ME0900
30 tristate "Meilhaus ME-900 support" 31 tristate "Meilhaus ME-900 support"
31 default n 32 default n
32 depends on PCI 33 depends on PCI && m
33 help 34 help
34 This driver supports the Meilhaus ME-900 family of boards 35 This driver supports the Meilhaus ME-900 family of boards
35 that do data collection and multipurpose I/O. 36 that do data collection and multipurpose I/O.
@@ -40,7 +41,7 @@ config ME0900
40config ME1000 41config ME1000
41 tristate "Meilhaus ME-1000 support" 42 tristate "Meilhaus ME-1000 support"
42 default n 43 default n
43 depends on PCI 44 depends on PCI && m
44 help 45 help
45 This driver supports the Meilhaus ME-1000 family of boards 46 This driver supports the Meilhaus ME-1000 family of boards
46 that do data collection and multipurpose I/O. 47 that do data collection and multipurpose I/O.
@@ -51,7 +52,7 @@ config ME1000
51config ME1400 52config ME1400
52 tristate "Meilhaus ME-1400 support" 53 tristate "Meilhaus ME-1400 support"
53 default n 54 default n
54 depends on PCI 55 depends on PCI && m
55 help 56 help
56 This driver supports the Meilhaus ME-1400 family of boards 57 This driver supports the Meilhaus ME-1400 family of boards
57 that do data collection and multipurpose I/O. 58 that do data collection and multipurpose I/O.
@@ -62,7 +63,7 @@ config ME1400
62config ME1600 63config ME1600
63 tristate "Meilhaus ME-1600 support" 64 tristate "Meilhaus ME-1600 support"
64 default n 65 default n
65 depends on PCI 66 depends on PCI && m
66 help 67 help
67 This driver supports the Meilhaus ME-1600 family of boards 68 This driver supports the Meilhaus ME-1600 family of boards
68 that do data collection and multipurpose I/O. 69 that do data collection and multipurpose I/O.
@@ -73,7 +74,7 @@ config ME1600
73config ME4600 74config ME4600
74 tristate "Meilhaus ME-4600 support" 75 tristate "Meilhaus ME-4600 support"
75 default n 76 default n
76 depends on PCI 77 depends on PCI && m
77 help 78 help
78 This driver supports the Meilhaus ME-4600 family of boards 79 This driver supports the Meilhaus ME-4600 family of boards
79 that do data collection and multipurpose I/O. 80 that do data collection and multipurpose I/O.
@@ -84,7 +85,7 @@ config ME4600
84config ME6000 85config ME6000
85 tristate "Meilhaus ME-6000 support" 86 tristate "Meilhaus ME-6000 support"
86 default n 87 default n
87 depends on PCI 88 depends on PCI && m
88 help 89 help
89 This driver supports the Meilhaus ME-6000 family of boards 90 This driver supports the Meilhaus ME-6000 family of boards
90 that do data collection and multipurpose I/O. 91 that do data collection and multipurpose I/O.
@@ -95,7 +96,7 @@ config ME6000
95config ME8100 96config ME8100
96 tristate "Meilhaus ME-8100 support" 97 tristate "Meilhaus ME-8100 support"
97 default n 98 default n
98 depends on PCI 99 depends on PCI && m
99 help 100 help
100 This driver supports the Meilhaus ME-8100 family of boards 101 This driver supports the Meilhaus ME-8100 family of boards
101 that do data collection and multipurpose I/O. 102 that do data collection and multipurpose I/O.
@@ -106,7 +107,7 @@ config ME8100
106config ME8200 107config ME8200
107 tristate "Meilhaus ME-8200 support" 108 tristate "Meilhaus ME-8200 support"
108 default n 109 default n
109 depends on PCI 110 depends on PCI && m
110 help 111 help
111 This driver supports the Meilhaus ME-8200 family of boards 112 This driver supports the Meilhaus ME-8200 family of boards
112 that do data collection and multipurpose I/O. 113 that do data collection and multipurpose I/O.
@@ -117,7 +118,7 @@ config ME8200
117config MEDUMMY 118config MEDUMMY
118 tristate "Meilhaus dummy driver" 119 tristate "Meilhaus dummy driver"
119 default n 120 default n
120 depends on PCI 121 depends on PCI && m
121 help 122 help
122 This provides a dummy driver for the Meilhaus driver package 123 This provides a dummy driver for the Meilhaus driver package
123 124
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index ec343ef53a85..0d111ddfabb2 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -1026,7 +1026,7 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
1026 } 1026 }
1027 break; 1027 break;
1028 case POCH_IOC_GET_COUNTERS: 1028 case POCH_IOC_GET_COUNTERS:
1029 if (access_ok(VERIFY_WRITE, argp, sizeof(struct poch_counters))) 1029 if (!access_ok(VERIFY_WRITE, argp, sizeof(struct poch_counters)))
1030 return -EFAULT; 1030 return -EFAULT;
1031 1031
1032 spin_lock_irq(&channel->counters_lock); 1032 spin_lock_irq(&channel->counters_lock);
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
index 72e209276ea7..22f93dd0ba03 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -406,8 +406,20 @@ void usbip_start_threads(struct usbip_device *ud)
406 /* 406 /*
407 * threads are invoked per one device (per one connection). 407 * threads are invoked per one device (per one connection).
408 */ 408 */
409 kernel_thread(usbip_thread, (void *)&ud->tcp_rx, 0); 409 int retval;
410 kernel_thread(usbip_thread, (void *)&ud->tcp_tx, 0); 410
411 retval = kernel_thread(usbip_thread, (void *)&ud->tcp_rx, 0);
412 if (retval < 0) {
413 printk(KERN_ERR "Creating tcp_rx thread for ud %p failed.\n",
414 ud);
415 return;
416 }
417 retval = kernel_thread(usbip_thread, (void *)&ud->tcp_tx, 0);
418 if (retval < 0) {
419 printk(KERN_ERR "Creating tcp_tx thread for ud %p failed.\n",
420 ud);
421 return;
422 }
411 423
412 /* confirm threads are starting */ 424 /* confirm threads are starting */
413 wait_for_completion(&ud->tcp_rx.thread_done); 425 wait_for_completion(&ud->tcp_rx.thread_done);
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 8b7c419b876e..8bcde8cde554 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_USB_EHCI_HCD) += host/
13obj-$(CONFIG_USB_ISP116X_HCD) += host/ 13obj-$(CONFIG_USB_ISP116X_HCD) += host/
14obj-$(CONFIG_USB_OHCI_HCD) += host/ 14obj-$(CONFIG_USB_OHCI_HCD) += host/
15obj-$(CONFIG_USB_UHCI_HCD) += host/ 15obj-$(CONFIG_USB_UHCI_HCD) += host/
16obj-$(CONFIG_USB_FHCI_HCD) += host/
16obj-$(CONFIG_USB_SL811_HCD) += host/ 17obj-$(CONFIG_USB_SL811_HCD) += host/
17obj-$(CONFIG_USB_U132_HCD) += host/ 18obj-$(CONFIG_USB_U132_HCD) += host/
18obj-$(CONFIG_USB_R8A66597_HCD) += host/ 19obj-$(CONFIG_USB_R8A66597_HCD) += host/
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 00b47ea24f86..97ba4a985edc 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1349,6 +1349,12 @@ static struct usb_device_id acm_ids[] = {
1349 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */ 1349 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */
1350 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1350 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1351 }, 1351 },
1352 { USB_DEVICE(0x0e8d, 0x3329), /* i-blue 747, Qstarz BT-Q1000, Holux M-241 */
1353 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1354 },
1355 { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */
1356 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1357 },
1352 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */ 1358 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */
1353 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1359 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1354 }, 1360 },
@@ -1370,6 +1376,9 @@ static struct usb_device_id acm_ids[] = {
1370 { USB_DEVICE(0x0572, 0x1321), /* Conexant USB MODEM CX93010 */ 1376 { USB_DEVICE(0x0572, 0x1321), /* Conexant USB MODEM CX93010 */
1371 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1377 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1372 }, 1378 },
1379 { USB_DEVICE(0x0572, 0x1324), /* Conexant USB MODEM RD02-D400 */
1380 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1381 },
1373 1382
1374 /* control interfaces with various AT-command sets */ 1383 /* control interfaces with various AT-command sets */
1375 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1384 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index b5775af3ba26..3f3ee1351930 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -226,6 +226,7 @@ static const struct quirk_printer_struct quirk_printers[] = {
226 { 0x0409, 0xf0be, USBLP_QUIRK_BIDIR }, /* NEC Picty920 (HP OEM) */ 226 { 0x0409, 0xf0be, USBLP_QUIRK_BIDIR }, /* NEC Picty920 (HP OEM) */
227 { 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */ 227 { 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */
228 { 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut <kernel@zut.de> */ 228 { 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut <kernel@zut.de> */
229 { 0x04f9, 0x000d, USBLP_QUIRK_BIDIR }, /* Brother Industries, Ltd HL-1440 Laser Printer */
229 { 0x04b8, 0x0202, USBLP_QUIRK_BAD_CLASS }, /* Seiko Epson Receipt Printer M129C */ 230 { 0x04b8, 0x0202, USBLP_QUIRK_BAD_CLASS }, /* Seiko Epson Receipt Printer M129C */
230 { 0, 0 } 231 { 0, 0 }
231}; 232};
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 26fece124e0e..7513bb083c15 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1700,7 +1700,7 @@ const struct file_operations usbdev_file_operations = {
1700 .release = usbdev_release, 1700 .release = usbdev_release,
1701}; 1701};
1702 1702
1703void usb_fs_classdev_common_remove(struct usb_device *udev) 1703static void usbdev_remove(struct usb_device *udev)
1704{ 1704{
1705 struct dev_state *ps; 1705 struct dev_state *ps;
1706 struct siginfo sinfo; 1706 struct siginfo sinfo;
@@ -1742,10 +1742,15 @@ static void usb_classdev_remove(struct usb_device *dev)
1742{ 1742{
1743 if (dev->usb_classdev) 1743 if (dev->usb_classdev)
1744 device_unregister(dev->usb_classdev); 1744 device_unregister(dev->usb_classdev);
1745 usb_fs_classdev_common_remove(dev);
1746} 1745}
1747 1746
1748static int usb_classdev_notify(struct notifier_block *self, 1747#else
1748#define usb_classdev_add(dev) 0
1749#define usb_classdev_remove(dev) do {} while (0)
1750
1751#endif
1752
1753static int usbdev_notify(struct notifier_block *self,
1749 unsigned long action, void *dev) 1754 unsigned long action, void *dev)
1750{ 1755{
1751 switch (action) { 1756 switch (action) {
@@ -1755,15 +1760,15 @@ static int usb_classdev_notify(struct notifier_block *self,
1755 break; 1760 break;
1756 case USB_DEVICE_REMOVE: 1761 case USB_DEVICE_REMOVE:
1757 usb_classdev_remove(dev); 1762 usb_classdev_remove(dev);
1763 usbdev_remove(dev);
1758 break; 1764 break;
1759 } 1765 }
1760 return NOTIFY_OK; 1766 return NOTIFY_OK;
1761} 1767}
1762 1768
1763static struct notifier_block usbdev_nb = { 1769static struct notifier_block usbdev_nb = {
1764 .notifier_call = usb_classdev_notify, 1770 .notifier_call = usbdev_notify,
1765}; 1771};
1766#endif
1767 1772
1768static struct cdev usb_device_cdev; 1773static struct cdev usb_device_cdev;
1769 1774
@@ -1798,9 +1803,8 @@ int __init usb_devio_init(void)
1798 * to /sys/dev 1803 * to /sys/dev
1799 */ 1804 */
1800 usb_classdev_class->dev_kobj = NULL; 1805 usb_classdev_class->dev_kobj = NULL;
1801
1802 usb_register_notify(&usbdev_nb);
1803#endif 1806#endif
1807 usb_register_notify(&usbdev_nb);
1804out: 1808out:
1805 return retval; 1809 return retval;
1806 1810
@@ -1811,8 +1815,8 @@ error_cdev:
1811 1815
1812void usb_devio_cleanup(void) 1816void usb_devio_cleanup(void)
1813{ 1817{
1814#ifdef CONFIG_USB_DEVICE_CLASS
1815 usb_unregister_notify(&usbdev_nb); 1818 usb_unregister_notify(&usbdev_nb);
1819#ifdef CONFIG_USB_DEVICE_CLASS
1816 class_destroy(usb_classdev_class); 1820 class_destroy(usb_classdev_class);
1817#endif 1821#endif
1818 cdev_del(&usb_device_cdev); 1822 cdev_del(&usb_device_cdev);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 98760553bc95..d0a21a5f8201 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -284,7 +284,7 @@ static int usb_unbind_interface(struct device *dev)
284 * supports "soft" unbinding. 284 * supports "soft" unbinding.
285 */ 285 */
286 if (!driver->soft_unbind) 286 if (!driver->soft_unbind)
287 usb_disable_interface(udev, intf); 287 usb_disable_interface(udev, intf, false);
288 288
289 driver->disconnect(intf); 289 driver->disconnect(intf);
290 usb_cancel_queued_reset(intf); 290 usb_cancel_queued_reset(intf);
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 507741ed4482..c54fc40458b1 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -128,7 +128,6 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
128 } 128 }
129 129
130 pci_set_master(dev); 130 pci_set_master(dev);
131 device_set_wakeup_enable(&dev->dev, 1);
132 131
133 retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); 132 retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED);
134 if (retval != 0) 133 if (retval != 0)
@@ -201,6 +200,7 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
201 struct usb_hcd *hcd = pci_get_drvdata(dev); 200 struct usb_hcd *hcd = pci_get_drvdata(dev);
202 int retval = 0; 201 int retval = 0;
203 int wake, w; 202 int wake, w;
203 int has_pci_pm;
204 204
205 /* Root hub suspend should have stopped all downstream traffic, 205 /* Root hub suspend should have stopped all downstream traffic,
206 * and all bus master traffic. And done so for both the interface 206 * and all bus master traffic. And done so for both the interface
@@ -230,6 +230,15 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
230 230
231 synchronize_irq(dev->irq); 231 synchronize_irq(dev->irq);
232 232
233 /* Downstream ports from this root hub should already be quiesced, so
234 * there will be no DMA activity. Now we can shut down the upstream
235 * link (except maybe for PME# resume signaling) and enter some PCI
236 * low power state, if the hardware allows.
237 */
238 pci_disable_device(dev);
239
240 pci_save_state(dev);
241
233 /* Don't fail on error to enable wakeup. We rely on pci code 242 /* Don't fail on error to enable wakeup. We rely on pci code
234 * to reject requests the hardware can't implement, rather 243 * to reject requests the hardware can't implement, rather
235 * than coding the same thing. 244 * than coding the same thing.
@@ -241,35 +250,6 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
241 wake = w; 250 wake = w;
242 dev_dbg(&dev->dev, "wakeup: %d\n", wake); 251 dev_dbg(&dev->dev, "wakeup: %d\n", wake);
243 252
244 /* Downstream ports from this root hub should already be quiesced, so
245 * there will be no DMA activity. Now we can shut down the upstream
246 * link (except maybe for PME# resume signaling) and enter some PCI
247 * low power state, if the hardware allows.
248 */
249 pci_disable_device(dev);
250 done:
251 return retval;
252}
253EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend);
254
255/**
256 * usb_hcd_pci_suspend_late - suspend a PCI-based HCD after IRQs are disabled
257 * @dev: USB Host Controller being suspended
258 * @message: Power Management message describing this state transition
259 *
260 * Store this function in the HCD's struct pci_driver as .suspend_late.
261 */
262int usb_hcd_pci_suspend_late(struct pci_dev *dev, pm_message_t message)
263{
264 int retval = 0;
265 int has_pci_pm;
266
267 /* We might already be suspended (runtime PM -- not yet written) */
268 if (dev->current_state != PCI_D0)
269 goto done;
270
271 pci_save_state(dev);
272
273 /* Don't change state if we don't need to */ 253 /* Don't change state if we don't need to */
274 if (message.event == PM_EVENT_FREEZE || 254 if (message.event == PM_EVENT_FREEZE ||
275 message.event == PM_EVENT_PRETHAW) { 255 message.event == PM_EVENT_PRETHAW) {
@@ -315,7 +295,7 @@ int usb_hcd_pci_suspend_late(struct pci_dev *dev, pm_message_t message)
315 done: 295 done:
316 return retval; 296 return retval;
317} 297}
318EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend_late); 298EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend);
319 299
320/** 300/**
321 * usb_hcd_pci_resume_early - resume a PCI-based HCD before IRQs are enabled 301 * usb_hcd_pci_resume_early - resume a PCI-based HCD before IRQs are enabled
@@ -325,65 +305,8 @@ EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend_late);
325 */ 305 */
326int usb_hcd_pci_resume_early(struct pci_dev *dev) 306int usb_hcd_pci_resume_early(struct pci_dev *dev)
327{ 307{
328 int retval = 0; 308 pci_restore_state(dev);
329 pci_power_t state = dev->current_state; 309 return 0;
330
331#ifdef CONFIG_PPC_PMAC
332 /* Reenable ASIC clocks for USB */
333 if (machine_is(powermac)) {
334 struct device_node *of_node;
335
336 of_node = pci_device_to_OF_node(dev);
337 if (of_node)
338 pmac_call_feature(PMAC_FTR_USB_ENABLE,
339 of_node, 0, 1);
340 }
341#endif
342
343 /* NOTE: chip docs cover clean "real suspend" cases (what Linux
344 * calls "standby", "suspend to RAM", and so on). There are also
345 * dirty cases when swsusp fakes a suspend in "shutdown" mode.
346 */
347 if (state != PCI_D0) {
348#ifdef DEBUG
349 int pci_pm;
350 u16 pmcr;
351
352 pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
353 pci_read_config_word(dev, pci_pm + PCI_PM_CTRL, &pmcr);
354 pmcr &= PCI_PM_CTRL_STATE_MASK;
355 if (pmcr) {
356 /* Clean case: power to USB and to HC registers was
357 * maintained; remote wakeup is easy.
358 */
359 dev_dbg(&dev->dev, "resume from PCI D%d\n", pmcr);
360 } else {
361 /* Clean: HC lost Vcc power, D0 uninitialized
362 * + Vaux may have preserved port and transceiver
363 * state ... for remote wakeup from D3cold
364 * + or not; HCD must reinit + re-enumerate
365 *
366 * Dirty: D0 semi-initialized cases with swsusp
367 * + after BIOS init
368 * + after Linux init (HCD statically linked)
369 */
370 dev_dbg(&dev->dev, "resume from previous PCI D%d\n",
371 state);
372 }
373#endif
374
375 retval = pci_set_power_state(dev, PCI_D0);
376 } else {
377 /* Same basic cases: clean (powered/not), dirty */
378 dev_dbg(&dev->dev, "PCI legacy resume\n");
379 }
380
381 if (retval < 0)
382 dev_err(&dev->dev, "can't resume: %d\n", retval);
383 else
384 pci_restore_state(dev);
385
386 return retval;
387} 310}
388EXPORT_SYMBOL_GPL(usb_hcd_pci_resume_early); 311EXPORT_SYMBOL_GPL(usb_hcd_pci_resume_early);
389 312
@@ -398,6 +321,18 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
398 struct usb_hcd *hcd; 321 struct usb_hcd *hcd;
399 int retval; 322 int retval;
400 323
324#ifdef CONFIG_PPC_PMAC
325 /* Reenable ASIC clocks for USB */
326 if (machine_is(powermac)) {
327 struct device_node *of_node;
328
329 of_node = pci_device_to_OF_node(dev);
330 if (of_node)
331 pmac_call_feature(PMAC_FTR_USB_ENABLE,
332 of_node, 0, 1);
333 }
334#endif
335
401 hcd = pci_get_drvdata(dev); 336 hcd = pci_get_drvdata(dev);
402 if (hcd->state != HC_STATE_SUSPENDED) { 337 if (hcd->state != HC_STATE_SUSPENDED) {
403 dev_dbg(hcd->self.controller, 338 dev_dbg(hcd->self.controller,
@@ -405,6 +340,8 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
405 return 0; 340 return 0;
406 } 341 }
407 342
343 pci_enable_wake(dev, PCI_D0, false);
344
408 retval = pci_enable_device(dev); 345 retval = pci_enable_device(dev);
409 if (retval < 0) { 346 if (retval < 0) {
410 dev_err(&dev->dev, "can't re-enable after resume, %d!\n", 347 dev_err(&dev->dev, "can't re-enable after resume, %d!\n",
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 572d2cf46e8d..5b94a56bec23 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -257,7 +257,6 @@ extern void usb_hcd_pci_remove(struct pci_dev *dev);
257 257
258#ifdef CONFIG_PM 258#ifdef CONFIG_PM
259extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t msg); 259extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t msg);
260extern int usb_hcd_pci_suspend_late(struct pci_dev *dev, pm_message_t msg);
261extern int usb_hcd_pci_resume_early(struct pci_dev *dev); 260extern int usb_hcd_pci_resume_early(struct pci_dev *dev);
262extern int usb_hcd_pci_resume(struct pci_dev *dev); 261extern int usb_hcd_pci_resume(struct pci_dev *dev);
263#endif /* CONFIG_PM */ 262#endif /* CONFIG_PM */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 94d5ee263c20..cd50d86029e7 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2382,8 +2382,8 @@ static int hub_port_debounce(struct usb_hub *hub, int port1)
2382 2382
2383void usb_ep0_reinit(struct usb_device *udev) 2383void usb_ep0_reinit(struct usb_device *udev)
2384{ 2384{
2385 usb_disable_endpoint(udev, 0 + USB_DIR_IN); 2385 usb_disable_endpoint(udev, 0 + USB_DIR_IN, true);
2386 usb_disable_endpoint(udev, 0 + USB_DIR_OUT); 2386 usb_disable_endpoint(udev, 0 + USB_DIR_OUT, true);
2387 usb_enable_endpoint(udev, &udev->ep0, true); 2387 usb_enable_endpoint(udev, &udev->ep0, true);
2388} 2388}
2389EXPORT_SYMBOL_GPL(usb_ep0_reinit); 2389EXPORT_SYMBOL_GPL(usb_ep0_reinit);
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 2a129cb7bb56..dff5760a37f6 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -717,7 +717,6 @@ static void usbfs_remove_device(struct usb_device *dev)
717 fs_remove_file (dev->usbfs_dentry); 717 fs_remove_file (dev->usbfs_dentry);
718 dev->usbfs_dentry = NULL; 718 dev->usbfs_dentry = NULL;
719 } 719 }
720 usb_fs_classdev_common_remove(dev);
721} 720}
722 721
723static int usbfs_notify(struct notifier_block *self, unsigned long action, void *dev) 722static int usbfs_notify(struct notifier_block *self, unsigned long action, void *dev)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index de51667dd64d..31fb204f44c6 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1039,14 +1039,15 @@ static void remove_intf_ep_devs(struct usb_interface *intf)
1039 * @dev: the device whose endpoint is being disabled 1039 * @dev: the device whose endpoint is being disabled
1040 * @epaddr: the endpoint's address. Endpoint number for output, 1040 * @epaddr: the endpoint's address. Endpoint number for output,
1041 * endpoint number + USB_DIR_IN for input 1041 * endpoint number + USB_DIR_IN for input
1042 * @reset_hardware: flag to erase any endpoint state stored in the
1043 * controller hardware
1042 * 1044 *
1043 * Deallocates hcd/hardware state for this endpoint ... and nukes all 1045 * Disables the endpoint for URB submission and nukes all pending URBs.
1044 * pending urbs. 1046 * If @reset_hardware is set then also deallocates hcd/hardware state
1045 * 1047 * for the endpoint.
1046 * If the HCD hasn't registered a disable() function, this sets the
1047 * endpoint's maxpacket size to 0 to prevent further submissions.
1048 */ 1048 */
1049void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr) 1049void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr,
1050 bool reset_hardware)
1050{ 1051{
1051 unsigned int epnum = epaddr & USB_ENDPOINT_NUMBER_MASK; 1052 unsigned int epnum = epaddr & USB_ENDPOINT_NUMBER_MASK;
1052 struct usb_host_endpoint *ep; 1053 struct usb_host_endpoint *ep;
@@ -1056,15 +1057,18 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr)
1056 1057
1057 if (usb_endpoint_out(epaddr)) { 1058 if (usb_endpoint_out(epaddr)) {
1058 ep = dev->ep_out[epnum]; 1059 ep = dev->ep_out[epnum];
1059 dev->ep_out[epnum] = NULL; 1060 if (reset_hardware)
1061 dev->ep_out[epnum] = NULL;
1060 } else { 1062 } else {
1061 ep = dev->ep_in[epnum]; 1063 ep = dev->ep_in[epnum];
1062 dev->ep_in[epnum] = NULL; 1064 if (reset_hardware)
1065 dev->ep_in[epnum] = NULL;
1063 } 1066 }
1064 if (ep) { 1067 if (ep) {
1065 ep->enabled = 0; 1068 ep->enabled = 0;
1066 usb_hcd_flush_endpoint(dev, ep); 1069 usb_hcd_flush_endpoint(dev, ep);
1067 usb_hcd_disable_endpoint(dev, ep); 1070 if (reset_hardware)
1071 usb_hcd_disable_endpoint(dev, ep);
1068 } 1072 }
1069} 1073}
1070 1074
@@ -1072,17 +1076,21 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr)
1072 * usb_disable_interface -- Disable all endpoints for an interface 1076 * usb_disable_interface -- Disable all endpoints for an interface
1073 * @dev: the device whose interface is being disabled 1077 * @dev: the device whose interface is being disabled
1074 * @intf: pointer to the interface descriptor 1078 * @intf: pointer to the interface descriptor
1079 * @reset_hardware: flag to erase any endpoint state stored in the
1080 * controller hardware
1075 * 1081 *
1076 * Disables all the endpoints for the interface's current altsetting. 1082 * Disables all the endpoints for the interface's current altsetting.
1077 */ 1083 */
1078void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf) 1084void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
1085 bool reset_hardware)
1079{ 1086{
1080 struct usb_host_interface *alt = intf->cur_altsetting; 1087 struct usb_host_interface *alt = intf->cur_altsetting;
1081 int i; 1088 int i;
1082 1089
1083 for (i = 0; i < alt->desc.bNumEndpoints; ++i) { 1090 for (i = 0; i < alt->desc.bNumEndpoints; ++i) {
1084 usb_disable_endpoint(dev, 1091 usb_disable_endpoint(dev,
1085 alt->endpoint[i].desc.bEndpointAddress); 1092 alt->endpoint[i].desc.bEndpointAddress,
1093 reset_hardware);
1086 } 1094 }
1087} 1095}
1088 1096
@@ -1103,8 +1111,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1103 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__, 1111 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
1104 skip_ep0 ? "non-ep0" : "all"); 1112 skip_ep0 ? "non-ep0" : "all");
1105 for (i = skip_ep0; i < 16; ++i) { 1113 for (i = skip_ep0; i < 16; ++i) {
1106 usb_disable_endpoint(dev, i); 1114 usb_disable_endpoint(dev, i, true);
1107 usb_disable_endpoint(dev, i + USB_DIR_IN); 1115 usb_disable_endpoint(dev, i + USB_DIR_IN, true);
1108 } 1116 }
1109 dev->toggle[0] = dev->toggle[1] = 0; 1117 dev->toggle[0] = dev->toggle[1] = 0;
1110 1118
@@ -1274,7 +1282,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1274 remove_intf_ep_devs(iface); 1282 remove_intf_ep_devs(iface);
1275 usb_remove_sysfs_intf_files(iface); 1283 usb_remove_sysfs_intf_files(iface);
1276 } 1284 }
1277 usb_disable_interface(dev, iface); 1285 usb_disable_interface(dev, iface, true);
1278 1286
1279 iface->cur_altsetting = alt; 1287 iface->cur_altsetting = alt;
1280 1288
@@ -1353,8 +1361,8 @@ int usb_reset_configuration(struct usb_device *dev)
1353 */ 1361 */
1354 1362
1355 for (i = 1; i < 16; ++i) { 1363 for (i = 1; i < 16; ++i) {
1356 usb_disable_endpoint(dev, i); 1364 usb_disable_endpoint(dev, i, true);
1357 usb_disable_endpoint(dev, i + USB_DIR_IN); 1365 usb_disable_endpoint(dev, i + USB_DIR_IN, true);
1358 } 1366 }
1359 1367
1360 config = dev->actconfig; 1368 config = dev->actconfig;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 386177867a8a..79d8a9ea559b 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -15,9 +15,10 @@ extern void usb_enable_endpoint(struct usb_device *dev,
15 struct usb_host_endpoint *ep, bool reset_toggle); 15 struct usb_host_endpoint *ep, bool reset_toggle);
16extern void usb_enable_interface(struct usb_device *dev, 16extern void usb_enable_interface(struct usb_device *dev,
17 struct usb_interface *intf, bool reset_toggles); 17 struct usb_interface *intf, bool reset_toggles);
18extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr); 18extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr,
19 bool reset_hardware);
19extern void usb_disable_interface(struct usb_device *dev, 20extern void usb_disable_interface(struct usb_device *dev,
20 struct usb_interface *intf); 21 struct usb_interface *intf, bool reset_hardware);
21extern void usb_release_interface_cache(struct kref *ref); 22extern void usb_release_interface_cache(struct kref *ref);
22extern void usb_disable_device(struct usb_device *dev, int skip_ep0); 23extern void usb_disable_device(struct usb_device *dev, int skip_ep0);
23extern int usb_deauthorize_device(struct usb_device *); 24extern int usb_deauthorize_device(struct usb_device *);
@@ -151,7 +152,6 @@ extern struct usb_driver usbfs_driver;
151extern const struct file_operations usbfs_devices_fops; 152extern const struct file_operations usbfs_devices_fops;
152extern const struct file_operations usbdev_file_operations; 153extern const struct file_operations usbdev_file_operations;
153extern void usbfs_conn_disc_event(void); 154extern void usbfs_conn_disc_event(void);
154extern void usb_fs_classdev_common_remove(struct usb_device *udev);
155 155
156extern int usb_devio_init(void); 156extern int usb_devio_init(void);
157extern void usb_devio_cleanup(void); 157extern void usb_devio_cleanup(void);
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f2da0269e1b1..5d11c291f1ad 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -683,6 +683,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
683 struct usb_request *req = cdev->req; 683 struct usb_request *req = cdev->req;
684 int value = -EOPNOTSUPP; 684 int value = -EOPNOTSUPP;
685 u16 w_index = le16_to_cpu(ctrl->wIndex); 685 u16 w_index = le16_to_cpu(ctrl->wIndex);
686 u8 intf = w_index & 0xFF;
686 u16 w_value = le16_to_cpu(ctrl->wValue); 687 u16 w_value = le16_to_cpu(ctrl->wValue);
687 u16 w_length = le16_to_cpu(ctrl->wLength); 688 u16 w_length = le16_to_cpu(ctrl->wLength);
688 struct usb_function *f = NULL; 689 struct usb_function *f = NULL;
@@ -769,10 +770,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
769 goto unknown; 770 goto unknown;
770 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) 771 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
771 break; 772 break;
772 f = cdev->config->interface[w_index]; 773 f = cdev->config->interface[intf];
773 if (!f) 774 if (!f)
774 break; 775 break;
775 if (w_value && !f->get_alt) 776 if (w_value && !f->set_alt)
776 break; 777 break;
777 value = f->set_alt(f, w_index, w_value); 778 value = f->set_alt(f, w_index, w_value);
778 break; 779 break;
@@ -781,7 +782,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
781 goto unknown; 782 goto unknown;
782 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) 783 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
783 break; 784 break;
784 f = cdev->config->interface[w_index]; 785 f = cdev->config->interface[intf];
785 if (!f) 786 if (!f)
786 break; 787 break;
787 /* lots of interfaces only need altsetting zero... */ 788 /* lots of interfaces only need altsetting zero... */
@@ -808,7 +809,7 @@ unknown:
808 */ 809 */
809 if ((ctrl->bRequestType & USB_RECIP_MASK) 810 if ((ctrl->bRequestType & USB_RECIP_MASK)
810 == USB_RECIP_INTERFACE) { 811 == USB_RECIP_INTERFACE) {
811 f = cdev->config->interface[w_index]; 812 f = cdev->config->interface[intf];
812 if (f && f->setup) 813 if (f && f->setup)
813 value = f->setup(f, ctrl); 814 value = f->setup(f, ctrl);
814 else 815 else
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
index cde8fdf15d5b..77c5d0a8a06e 100644
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -297,7 +297,7 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep)
297 297
298 for (i = 0; i < 100; i ++) { 298 for (i = 0; i < 100; i ++) {
299 temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); 299 temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
300 if (!temp & EPSTAT_STALL) 300 if (!(temp & EPSTAT_STALL))
301 break; 301 break;
302 udelay(20); 302 udelay(20);
303 } 303 }
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2b476b6b3d4d..2c63bfb1f8d9 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -140,6 +140,7 @@ config USB_OHCI_HCD
140 tristate "OHCI HCD support" 140 tristate "OHCI HCD support"
141 depends on USB && USB_ARCH_HAS_OHCI 141 depends on USB && USB_ARCH_HAS_OHCI
142 select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 142 select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
143 select USB_OTG_UTILS if ARCH_OMAP
143 ---help--- 144 ---help---
144 The Open Host Controller Interface (OHCI) is a standard for accessing 145 The Open Host Controller Interface (OHCI) is a standard for accessing
145 USB 1.1 host controller hardware. It does more in hardware than Intel's 146 USB 1.1 host controller hardware. It does more in hardware than Intel's
@@ -238,6 +239,23 @@ config USB_UHCI_HCD
238 To compile this driver as a module, choose M here: the 239 To compile this driver as a module, choose M here: the
239 module will be called uhci-hcd. 240 module will be called uhci-hcd.
240 241
242config USB_FHCI_HCD
243 tristate "Freescale QE USB Host Controller support"
244 depends on USB && OF_GPIO && QE_GPIO && QUICC_ENGINE
245 select FSL_GTM
246 select QE_USB
247 help
248 This driver enables support for Freescale QE USB Host Controller
249 (as found on MPC8360 and MPC8323 processors), the driver supports
250 Full and Low Speed USB.
251
252config FHCI_DEBUG
253 bool "Freescale QE USB Host Controller debug support"
254 depends on USB_FHCI_HCD && DEBUG_FS
255 help
256 Say "y" to see some FHCI debug information and statistics
257 throught debugfs.
258
241config USB_U132_HCD 259config USB_U132_HCD
242 tristate "Elan U132 Adapter Host Controller" 260 tristate "Elan U132 Adapter Host Controller"
243 depends on USB && USB_FTDI_ELAN 261 depends on USB && USB_FTDI_ELAN
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e5f3f20787e4..f163571e33d8 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -7,6 +7,11 @@ ifeq ($(CONFIG_USB_DEBUG),y)
7endif 7endif
8 8
9isp1760-objs := isp1760-hcd.o isp1760-if.o 9isp1760-objs := isp1760-hcd.o isp1760-if.o
10fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \
11 fhci-tds.o fhci-sched.o
12ifeq ($(CONFIG_FHCI_DEBUG),y)
13fhci-objs += fhci-dbg.o
14endif
10 15
11obj-$(CONFIG_USB_WHCI_HCD) += whci/ 16obj-$(CONFIG_USB_WHCI_HCD) += whci/
12 17
@@ -17,6 +22,7 @@ obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
17obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o 22obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
18obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o 23obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
19obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o 24obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
25obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
20obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o 26obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o
21obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o 27obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
22obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o 28obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index bdc6e86e1f8b..bb21fb0a4969 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -230,7 +230,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
230 pci_read_config_word(pdev, 0x62, &port_wake); 230 pci_read_config_word(pdev, 0x62, &port_wake);
231 if (port_wake & 0x0001) { 231 if (port_wake & 0x0001) {
232 dev_warn(&pdev->dev, "Enabling legacy PCI PM\n"); 232 dev_warn(&pdev->dev, "Enabling legacy PCI PM\n");
233 device_init_wakeup(&pdev->dev, 1); 233 device_set_wakeup_capable(&pdev->dev, 1);
234 } 234 }
235 } 235 }
236 236
@@ -432,7 +432,6 @@ static struct pci_driver ehci_pci_driver = {
432 432
433#ifdef CONFIG_PM 433#ifdef CONFIG_PM
434 .suspend = usb_hcd_pci_suspend, 434 .suspend = usb_hcd_pci_suspend,
435 .suspend_late = usb_hcd_pci_suspend_late,
436 .resume_early = usb_hcd_pci_resume_early, 435 .resume_early = usb_hcd_pci_resume_early,
437 .resume = usb_hcd_pci_resume, 436 .resume = usb_hcd_pci_resume,
438#endif 437#endif
diff --git a/drivers/usb/host/fhci-dbg.c b/drivers/usb/host/fhci-dbg.c
new file mode 100644
index 000000000000..34e14edf390b
--- /dev/null
+++ b/drivers/usb/host/fhci-dbg.c
@@ -0,0 +1,139 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/errno.h>
20#include <linux/debugfs.h>
21#include <linux/seq_file.h>
22#include <linux/usb.h>
23#include "../core/hcd.h"
24#include "fhci.h"
25
26void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er)
27{
28 int i;
29
30 if (usb_er == -1) {
31 fhci->usb_irq_stat[12]++;
32 return;
33 }
34
35 for (i = 0; i < 12; ++i) {
36 if (usb_er & (1 << i))
37 fhci->usb_irq_stat[i]++;
38 }
39}
40
41static int fhci_dfs_regs_show(struct seq_file *s, void *v)
42{
43 struct fhci_hcd *fhci = s->private;
44 struct fhci_regs __iomem *regs = fhci->regs;
45
46 seq_printf(s,
47 "mode: 0x%x\n" "addr: 0x%x\n"
48 "command: 0x%x\n" "ep0: 0x%x\n"
49 "event: 0x%x\n" "mask: 0x%x\n"
50 "status: 0x%x\n" "SOF timer: %d\n"
51 "frame number: %d\n"
52 "lines status: 0x%x\n",
53 in_8(&regs->usb_mod), in_8(&regs->usb_addr),
54 in_8(&regs->usb_comm), in_be16(&regs->usb_ep[0]),
55 in_be16(&regs->usb_event), in_be16(&regs->usb_mask),
56 in_8(&regs->usb_status), in_be16(&regs->usb_sof_tmr),
57 in_be16(&regs->usb_frame_num),
58 fhci_ioports_check_bus_state(fhci));
59
60 return 0;
61}
62
63static int fhci_dfs_irq_stat_show(struct seq_file *s, void *v)
64{
65 struct fhci_hcd *fhci = s->private;
66 int *usb_irq_stat = fhci->usb_irq_stat;
67
68 seq_printf(s,
69 "RXB: %d\n" "TXB: %d\n" "BSY: %d\n"
70 "SOF: %d\n" "TXE0: %d\n" "TXE1: %d\n"
71 "TXE2: %d\n" "TXE3: %d\n" "IDLE: %d\n"
72 "RESET: %d\n" "SFT: %d\n" "MSF: %d\n"
73 "IDLE_ONLY: %d\n",
74 usb_irq_stat[0], usb_irq_stat[1], usb_irq_stat[2],
75 usb_irq_stat[3], usb_irq_stat[4], usb_irq_stat[5],
76 usb_irq_stat[6], usb_irq_stat[7], usb_irq_stat[8],
77 usb_irq_stat[9], usb_irq_stat[10], usb_irq_stat[11],
78 usb_irq_stat[12]);
79
80 return 0;
81}
82
83static int fhci_dfs_regs_open(struct inode *inode, struct file *file)
84{
85 return single_open(file, fhci_dfs_regs_show, inode->i_private);
86}
87
88static int fhci_dfs_irq_stat_open(struct inode *inode, struct file *file)
89{
90 return single_open(file, fhci_dfs_irq_stat_show, inode->i_private);
91}
92
93static const struct file_operations fhci_dfs_regs_fops = {
94 .open = fhci_dfs_regs_open,
95 .read = seq_read,
96 .llseek = seq_lseek,
97 .release = single_release,
98};
99
100static const struct file_operations fhci_dfs_irq_stat_fops = {
101 .open = fhci_dfs_irq_stat_open,
102 .read = seq_read,
103 .llseek = seq_lseek,
104 .release = single_release,
105};
106
107void fhci_dfs_create(struct fhci_hcd *fhci)
108{
109 struct device *dev = fhci_to_hcd(fhci)->self.controller;
110
111 fhci->dfs_root = debugfs_create_dir(dev->bus_id, NULL);
112 if (!fhci->dfs_root) {
113 WARN_ON(1);
114 return;
115 }
116
117 fhci->dfs_regs = debugfs_create_file("regs", S_IFREG | S_IRUGO,
118 fhci->dfs_root, fhci, &fhci_dfs_regs_fops);
119
120 fhci->dfs_irq_stat = debugfs_create_file("irq_stat",
121 S_IFREG | S_IRUGO, fhci->dfs_root, fhci,
122 &fhci_dfs_irq_stat_fops);
123
124 WARN_ON(!fhci->dfs_regs || !fhci->dfs_irq_stat);
125}
126
127void fhci_dfs_destroy(struct fhci_hcd *fhci)
128{
129 if (!fhci->dfs_root)
130 return;
131
132 if (fhci->dfs_irq_stat)
133 debugfs_remove(fhci->dfs_irq_stat);
134
135 if (fhci->dfs_regs)
136 debugfs_remove(fhci->dfs_regs);
137
138 debugfs_remove(fhci->dfs_root);
139}
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
new file mode 100644
index 000000000000..ba622cc8a9ba
--- /dev/null
+++ b/drivers/usb/host/fhci-hcd.c
@@ -0,0 +1,836 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/module.h>
19#include <linux/types.h>
20#include <linux/spinlock.h>
21#include <linux/kernel.h>
22#include <linux/delay.h>
23#include <linux/errno.h>
24#include <linux/list.h>
25#include <linux/interrupt.h>
26#include <linux/io.h>
27#include <linux/usb.h>
28#include <linux/of_platform.h>
29#include <linux/of_gpio.h>
30#include <asm/qe.h>
31#include <asm/fsl_gtm.h>
32#include "../core/hcd.h"
33#include "fhci.h"
34
35void fhci_start_sof_timer(struct fhci_hcd *fhci)
36{
37 fhci_dbg(fhci, "-> %s\n", __func__);
38
39 /* clear frame_n */
40 out_be16(&fhci->pram->frame_num, 0);
41
42 out_be16(&fhci->regs->usb_sof_tmr, 0);
43 setbits8(&fhci->regs->usb_mod, USB_MODE_SFTE);
44
45 fhci_dbg(fhci, "<- %s\n", __func__);
46}
47
48void fhci_stop_sof_timer(struct fhci_hcd *fhci)
49{
50 fhci_dbg(fhci, "-> %s\n", __func__);
51
52 clrbits8(&fhci->regs->usb_mod, USB_MODE_SFTE);
53 gtm_stop_timer16(fhci->timer);
54
55 fhci_dbg(fhci, "<- %s\n", __func__);
56}
57
58u16 fhci_get_sof_timer_count(struct fhci_usb *usb)
59{
60 return be16_to_cpu(in_be16(&usb->fhci->regs->usb_sof_tmr) / 12);
61}
62
63/* initialize the endpoint zero */
64static u32 endpoint_zero_init(struct fhci_usb *usb,
65 enum fhci_mem_alloc data_mem,
66 u32 ring_len)
67{
68 u32 rc;
69
70 rc = fhci_create_ep(usb, data_mem, ring_len);
71 if (rc)
72 return rc;
73
74 /* inilialize endpoint registers */
75 fhci_init_ep_registers(usb, usb->ep0, data_mem);
76
77 return 0;
78}
79
80/* enable the USB interrupts */
81void fhci_usb_enable_interrupt(struct fhci_usb *usb)
82{
83 struct fhci_hcd *fhci = usb->fhci;
84
85 if (usb->intr_nesting_cnt == 1) {
86 /* initialize the USB interrupt */
87 enable_irq(fhci_to_hcd(fhci)->irq);
88
89 /* initialize the event register and mask register */
90 out_be16(&usb->fhci->regs->usb_event, 0xffff);
91 out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
92
93 /* enable the timer interrupts */
94 enable_irq(fhci->timer->irq);
95 } else if (usb->intr_nesting_cnt > 1)
96 fhci_info(fhci, "unbalanced USB interrupts nesting\n");
97 usb->intr_nesting_cnt--;
98}
99
100/* diable the usb interrupt */
101void fhci_usb_disable_interrupt(struct fhci_usb *usb)
102{
103 struct fhci_hcd *fhci = usb->fhci;
104
105 if (usb->intr_nesting_cnt == 0) {
106 /* diable the timer interrupt */
107 disable_irq_nosync(fhci->timer->irq);
108
109 /* disable the usb interrupt */
110 disable_irq_nosync(fhci_to_hcd(fhci)->irq);
111 out_be16(&usb->fhci->regs->usb_mask, 0);
112 }
113 usb->intr_nesting_cnt++;
114}
115
116/* enable the USB controller */
117static u32 fhci_usb_enable(struct fhci_hcd *fhci)
118{
119 struct fhci_usb *usb = fhci->usb_lld;
120
121 out_be16(&usb->fhci->regs->usb_event, 0xffff);
122 out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
123 setbits8(&usb->fhci->regs->usb_mod, USB_MODE_EN);
124
125 mdelay(100);
126
127 return 0;
128}
129
130/* disable the USB controller */
131static u32 fhci_usb_disable(struct fhci_hcd *fhci)
132{
133 struct fhci_usb *usb = fhci->usb_lld;
134
135 fhci_usb_disable_interrupt(usb);
136 fhci_port_disable(fhci);
137
138 /* disable the usb controller */
139 if (usb->port_status == FHCI_PORT_FULL ||
140 usb->port_status == FHCI_PORT_LOW)
141 fhci_device_disconnected_interrupt(fhci);
142
143 clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_EN);
144
145 return 0;
146}
147
148/* check the bus state by polling the QE bit on the IO ports */
149int fhci_ioports_check_bus_state(struct fhci_hcd *fhci)
150{
151 u8 bits = 0;
152
153 /* check USBOE,if transmitting,exit */
154 if (!gpio_get_value(fhci->gpios[GPIO_USBOE]))
155 return -1;
156
157 /* check USBRP */
158 if (gpio_get_value(fhci->gpios[GPIO_USBRP]))
159 bits |= 0x2;
160
161 /* check USBRN */
162 if (gpio_get_value(fhci->gpios[GPIO_USBRN]))
163 bits |= 0x1;
164
165 return bits;
166}
167
168static void fhci_mem_free(struct fhci_hcd *fhci)
169{
170 struct ed *ed;
171 struct ed *next_ed;
172 struct td *td;
173 struct td *next_td;
174
175 list_for_each_entry_safe(ed, next_ed, &fhci->empty_eds, node) {
176 list_del(&ed->node);
177 kfree(ed);
178 }
179
180 list_for_each_entry_safe(td, next_td, &fhci->empty_tds, node) {
181 list_del(&td->node);
182 kfree(td);
183 }
184
185 kfree(fhci->vroot_hub);
186 fhci->vroot_hub = NULL;
187
188 kfree(fhci->hc_list);
189 fhci->hc_list = NULL;
190}
191
192static int fhci_mem_init(struct fhci_hcd *fhci)
193{
194 int i;
195
196 fhci->hc_list = kzalloc(sizeof(*fhci->hc_list), GFP_KERNEL);
197 if (!fhci->hc_list)
198 goto err;
199
200 INIT_LIST_HEAD(&fhci->hc_list->ctrl_list);
201 INIT_LIST_HEAD(&fhci->hc_list->bulk_list);
202 INIT_LIST_HEAD(&fhci->hc_list->iso_list);
203 INIT_LIST_HEAD(&fhci->hc_list->intr_list);
204 INIT_LIST_HEAD(&fhci->hc_list->done_list);
205
206 fhci->vroot_hub = kzalloc(sizeof(*fhci->vroot_hub), GFP_KERNEL);
207 if (!fhci->vroot_hub)
208 goto err;
209
210 INIT_LIST_HEAD(&fhci->empty_eds);
211 INIT_LIST_HEAD(&fhci->empty_tds);
212
213 /* initialize work queue to handle done list */
214 fhci_tasklet.data = (unsigned long)fhci;
215 fhci->process_done_task = &fhci_tasklet;
216
217 for (i = 0; i < MAX_TDS; i++) {
218 struct td *td;
219
220 td = kmalloc(sizeof(*td), GFP_KERNEL);
221 if (!td)
222 goto err;
223 fhci_recycle_empty_td(fhci, td);
224 }
225 for (i = 0; i < MAX_EDS; i++) {
226 struct ed *ed;
227
228 ed = kmalloc(sizeof(*ed), GFP_KERNEL);
229 if (!ed)
230 goto err;
231 fhci_recycle_empty_ed(fhci, ed);
232 }
233
234 fhci->active_urbs = 0;
235 return 0;
236err:
237 fhci_mem_free(fhci);
238 return -ENOMEM;
239}
240
241/* destroy the fhci_usb structure */
242static void fhci_usb_free(void *lld)
243{
244 struct fhci_usb *usb = lld;
245 struct fhci_hcd *fhci = usb->fhci;
246
247 if (usb) {
248 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF);
249 fhci_ep0_free(usb);
250 kfree(usb->actual_frame);
251 kfree(usb);
252 }
253}
254
255/* initialize the USB */
256static int fhci_usb_init(struct fhci_hcd *fhci)
257{
258 struct fhci_usb *usb = fhci->usb_lld;
259
260 memset_io(usb->fhci->pram, 0, FHCI_PRAM_SIZE);
261
262 usb->port_status = FHCI_PORT_DISABLED;
263 usb->max_frame_usage = FRAME_TIME_USAGE;
264 usb->sw_transaction_time = SW_FIX_TIME_BETWEEN_TRANSACTION;
265
266 usb->actual_frame = kzalloc(sizeof(*usb->actual_frame), GFP_KERNEL);
267 if (!usb->actual_frame) {
268 fhci_usb_free(usb);
269 return -ENOMEM;
270 }
271
272 INIT_LIST_HEAD(&usb->actual_frame->tds_list);
273
274 /* initializing registers on chip, clear frame number */
275 out_be16(&fhci->pram->frame_num, 0);
276
277 /* clear rx state */
278 out_be32(&fhci->pram->rx_state, 0);
279
280 /* set mask register */
281 usb->saved_msk = (USB_E_TXB_MASK |
282 USB_E_TXE1_MASK |
283 USB_E_IDLE_MASK |
284 USB_E_RESET_MASK | USB_E_SFT_MASK | USB_E_MSF_MASK);
285
286 out_8(&usb->fhci->regs->usb_mod, USB_MODE_HOST | USB_MODE_EN);
287
288 /* clearing the mask register */
289 out_be16(&usb->fhci->regs->usb_mask, 0);
290
291 /* initialing the event register */
292 out_be16(&usb->fhci->regs->usb_event, 0xffff);
293
294 if (endpoint_zero_init(usb, DEFAULT_DATA_MEM, DEFAULT_RING_LEN) != 0) {
295 fhci_usb_free(usb);
296 return -EINVAL;
297 }
298
299 return 0;
300}
301
302/* initialize the fhci_usb struct and the corresponding data staruct */
303static struct fhci_usb *fhci_create_lld(struct fhci_hcd *fhci)
304{
305 struct fhci_usb *usb;
306
307 /* allocate memory for SCC data structure */
308 usb = kzalloc(sizeof(*usb), GFP_KERNEL);
309 if (!usb) {
310 fhci_err(fhci, "no memory for SCC data struct\n");
311 return NULL;
312 }
313
314 usb->fhci = fhci;
315 usb->hc_list = fhci->hc_list;
316 usb->vroot_hub = fhci->vroot_hub;
317
318 usb->transfer_confirm = fhci_transfer_confirm_callback;
319
320 return usb;
321}
322
323static int fhci_start(struct usb_hcd *hcd)
324{
325 int ret;
326 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
327
328 ret = fhci_mem_init(fhci);
329 if (ret) {
330 fhci_err(fhci, "failed to allocate memory\n");
331 goto err;
332 }
333
334 fhci->usb_lld = fhci_create_lld(fhci);
335 if (!fhci->usb_lld) {
336 fhci_err(fhci, "low level driver config failed\n");
337 ret = -ENOMEM;
338 goto err;
339 }
340
341 ret = fhci_usb_init(fhci);
342 if (ret) {
343 fhci_err(fhci, "low level driver initialize failed\n");
344 goto err;
345 }
346
347 spin_lock_init(&fhci->lock);
348
349 /* connect the virtual root hub */
350 fhci->vroot_hub->dev_num = 1; /* this field may be needed to fix */
351 fhci->vroot_hub->hub.wHubStatus = 0;
352 fhci->vroot_hub->hub.wHubChange = 0;
353 fhci->vroot_hub->port.wPortStatus = 0;
354 fhci->vroot_hub->port.wPortChange = 0;
355
356 hcd->state = HC_STATE_RUNNING;
357
358 /*
359 * From here on, khubd concurrently accesses the root
360 * hub; drivers will be talking to enumerated devices.
361 * (On restart paths, khubd already knows about the root
362 * hub and could find work as soon as we wrote FLAG_CF.)
363 *
364 * Before this point the HC was idle/ready. After, khubd
365 * and device drivers may start it running.
366 */
367 fhci_usb_enable(fhci);
368 return 0;
369err:
370 fhci_mem_free(fhci);
371 return ret;
372}
373
374static void fhci_stop(struct usb_hcd *hcd)
375{
376 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
377
378 fhci_usb_disable_interrupt(fhci->usb_lld);
379 fhci_usb_disable(fhci);
380
381 fhci_usb_free(fhci->usb_lld);
382 fhci->usb_lld = NULL;
383 fhci_mem_free(fhci);
384}
385
386static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
387 gfp_t mem_flags)
388{
389 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
390 u32 pipe = urb->pipe;
391 int ret;
392 int i;
393 int size = 0;
394 struct urb_priv *urb_priv;
395 unsigned long flags;
396
397 switch (usb_pipetype(pipe)) {
398 case PIPE_CONTROL:
399 /* 1 td fro setup,1 for ack */
400 size = 2;
401 case PIPE_BULK:
402 /* one td for every 4096 bytes(can be upto 8k) */
403 size += urb->transfer_buffer_length / 4096;
404 /* ...add for any remaining bytes... */
405 if ((urb->transfer_buffer_length % 4096) != 0)
406 size++;
407 /* ..and maybe a zero length packet to wrap it up */
408 if (size == 0)
409 size++;
410 else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0
411 && (urb->transfer_buffer_length
412 % usb_maxpacket(urb->dev, pipe,
413 usb_pipeout(pipe))) != 0)
414 size++;
415 break;
416 case PIPE_ISOCHRONOUS:
417 size = urb->number_of_packets;
418 if (size <= 0)
419 return -EINVAL;
420 for (i = 0; i < urb->number_of_packets; i++) {
421 urb->iso_frame_desc[i].actual_length = 0;
422 urb->iso_frame_desc[i].status = (u32) (-EXDEV);
423 }
424 break;
425 case PIPE_INTERRUPT:
426 size = 1;
427 }
428
429 /* allocate the private part of the URB */
430 urb_priv = kzalloc(sizeof(*urb_priv), mem_flags);
431 if (!urb_priv)
432 return -ENOMEM;
433
434 /* allocate the private part of the URB */
435 urb_priv->tds = kzalloc(size * sizeof(struct td), mem_flags);
436 if (!urb_priv->tds) {
437 kfree(urb_priv);
438 return -ENOMEM;
439 }
440
441 spin_lock_irqsave(&fhci->lock, flags);
442
443 ret = usb_hcd_link_urb_to_ep(hcd, urb);
444 if (ret)
445 goto err;
446
447 /* fill the private part of the URB */
448 urb_priv->num_of_tds = size;
449
450 urb->status = -EINPROGRESS;
451 urb->actual_length = 0;
452 urb->error_count = 0;
453 urb->hcpriv = urb_priv;
454
455 fhci_queue_urb(fhci, urb);
456err:
457 if (ret) {
458 kfree(urb_priv->tds);
459 kfree(urb_priv);
460 }
461 spin_unlock_irqrestore(&fhci->lock, flags);
462 return ret;
463}
464
465/* dequeue FHCI URB */
466static int fhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
467{
468 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
469 struct fhci_usb *usb = fhci->usb_lld;
470 int ret = -EINVAL;
471 unsigned long flags;
472
473 if (!urb || !urb->dev || !urb->dev->bus)
474 goto out;
475
476 spin_lock_irqsave(&fhci->lock, flags);
477
478 ret = usb_hcd_check_unlink_urb(hcd, urb, status);
479 if (ret)
480 goto out2;
481
482 if (usb->port_status != FHCI_PORT_DISABLED) {
483 struct urb_priv *urb_priv;
484
485 /*
486 * flag the urb's data for deletion in some upcoming
487 * SF interrupt's delete list processing
488 */
489 urb_priv = urb->hcpriv;
490
491 if (!urb_priv || (urb_priv->state == URB_DEL))
492 goto out2;
493
494 urb_priv->state = URB_DEL;
495
496 /* already pending? */
497 urb_priv->ed->state = FHCI_ED_URB_DEL;
498 } else {
499 fhci_urb_complete_free(fhci, urb);
500 }
501
502out2:
503 spin_unlock_irqrestore(&fhci->lock, flags);
504out:
505 return ret;
506}
507
508static void fhci_endpoint_disable(struct usb_hcd *hcd,
509 struct usb_host_endpoint *ep)
510{
511 struct fhci_hcd *fhci;
512 struct ed *ed;
513 unsigned long flags;
514
515 fhci = hcd_to_fhci(hcd);
516 spin_lock_irqsave(&fhci->lock, flags);
517 ed = ep->hcpriv;
518 if (ed) {
519 while (ed->td_head != NULL) {
520 struct td *td = fhci_remove_td_from_ed(ed);
521 fhci_urb_complete_free(fhci, td->urb);
522 }
523 fhci_recycle_empty_ed(fhci, ed);
524 ep->hcpriv = NULL;
525 }
526 spin_unlock_irqrestore(&fhci->lock, flags);
527}
528
529static int fhci_get_frame_number(struct usb_hcd *hcd)
530{
531 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
532
533 return get_frame_num(fhci);
534}
535
536static const struct hc_driver fhci_driver = {
537 .description = "fsl,usb-fhci",
538 .product_desc = "FHCI HOST Controller",
539 .hcd_priv_size = sizeof(struct fhci_hcd),
540
541 /* generic hardware linkage */
542 .irq = fhci_irq,
543 .flags = HCD_USB11 | HCD_MEMORY,
544
545 /* basic lifecycle operation */
546 .start = fhci_start,
547 .stop = fhci_stop,
548
549 /* managing i/o requests and associated device resources */
550 .urb_enqueue = fhci_urb_enqueue,
551 .urb_dequeue = fhci_urb_dequeue,
552 .endpoint_disable = fhci_endpoint_disable,
553
554 /* scheduling support */
555 .get_frame_number = fhci_get_frame_number,
556
557 /* root hub support */
558 .hub_status_data = fhci_hub_status_data,
559 .hub_control = fhci_hub_control,
560};
561
562static int __devinit of_fhci_probe(struct of_device *ofdev,
563 const struct of_device_id *ofid)
564{
565 struct device *dev = &ofdev->dev;
566 struct device_node *node = ofdev->node;
567 struct usb_hcd *hcd;
568 struct fhci_hcd *fhci;
569 struct resource usb_regs;
570 unsigned long pram_addr;
571 unsigned int usb_irq;
572 const char *sprop;
573 const u32 *iprop;
574 int size;
575 int ret;
576 int i;
577 int j;
578
579 if (usb_disabled())
580 return -ENODEV;
581
582 sprop = of_get_property(node, "mode", NULL);
583 if (sprop && strcmp(sprop, "host"))
584 return -ENODEV;
585
586 hcd = usb_create_hcd(&fhci_driver, dev, dev->bus_id);
587 if (!hcd) {
588 dev_err(dev, "could not create hcd\n");
589 return -ENOMEM;
590 }
591
592 fhci = hcd_to_fhci(hcd);
593 hcd->self.controller = dev;
594 dev_set_drvdata(dev, hcd);
595
596 iprop = of_get_property(node, "hub-power-budget", &size);
597 if (iprop && size == sizeof(*iprop))
598 hcd->power_budget = *iprop;
599
600 /* FHCI registers. */
601 ret = of_address_to_resource(node, 0, &usb_regs);
602 if (ret) {
603 dev_err(dev, "could not get regs\n");
604 goto err_regs;
605 }
606
607 hcd->regs = ioremap(usb_regs.start, usb_regs.end - usb_regs.start + 1);
608 if (!hcd->regs) {
609 dev_err(dev, "could not ioremap regs\n");
610 ret = -ENOMEM;
611 goto err_regs;
612 }
613 fhci->regs = hcd->regs;
614
615 /* Parameter RAM. */
616 iprop = of_get_property(node, "reg", &size);
617 if (!iprop || size < sizeof(*iprop) * 4) {
618 dev_err(dev, "can't get pram offset\n");
619 ret = -EINVAL;
620 goto err_pram;
621 }
622
623 pram_addr = cpm_muram_alloc_fixed(iprop[2], FHCI_PRAM_SIZE);
624 if (IS_ERR_VALUE(pram_addr)) {
625 dev_err(dev, "failed to allocate usb pram\n");
626 ret = -ENOMEM;
627 goto err_pram;
628 }
629 fhci->pram = cpm_muram_addr(pram_addr);
630
631 /* GPIOs and pins */
632 for (i = 0; i < NUM_GPIOS; i++) {
633 int gpio;
634 enum of_gpio_flags flags;
635
636 gpio = of_get_gpio_flags(node, i, &flags);
637 fhci->gpios[i] = gpio;
638 fhci->alow_gpios[i] = flags & OF_GPIO_ACTIVE_LOW;
639
640 if (!gpio_is_valid(gpio)) {
641 if (i < GPIO_SPEED) {
642 dev_err(dev, "incorrect GPIO%d: %d\n",
643 i, gpio);
644 goto err_gpios;
645 } else {
646 dev_info(dev, "assuming board doesn't have "
647 "%s gpio\n", i == GPIO_SPEED ?
648 "speed" : "power");
649 continue;
650 }
651 }
652
653 ret = gpio_request(gpio, dev->bus_id);
654 if (ret) {
655 dev_err(dev, "failed to request gpio %d", i);
656 goto err_gpios;
657 }
658
659 if (i >= GPIO_SPEED) {
660 ret = gpio_direction_output(gpio, 0);
661 if (ret) {
662 dev_err(dev, "failed to set gpio %d as "
663 "an output\n", i);
664 i++;
665 goto err_gpios;
666 }
667 }
668 }
669
670 for (j = 0; j < NUM_PINS; j++) {
671 fhci->pins[j] = qe_pin_request(ofdev->node, j);
672 if (IS_ERR(fhci->pins[j])) {
673 ret = PTR_ERR(fhci->pins[j]);
674 dev_err(dev, "can't get pin %d: %d\n", j, ret);
675 goto err_pins;
676 }
677 }
678
679 /* Frame limit timer and its interrupt. */
680 fhci->timer = gtm_get_timer16();
681 if (IS_ERR(fhci->timer)) {
682 ret = PTR_ERR(fhci->timer);
683 dev_err(dev, "failed to request qe timer: %i", ret);
684 goto err_get_timer;
685 }
686
687 ret = request_irq(fhci->timer->irq, fhci_frame_limit_timer_irq,
688 IRQF_DISABLED, "qe timer (usb)", hcd);
689 if (ret) {
690 dev_err(dev, "failed to request timer irq");
691 goto err_timer_irq;
692 }
693
694 /* USB Host interrupt. */
695 usb_irq = irq_of_parse_and_map(node, 0);
696 if (usb_irq == NO_IRQ) {
697 dev_err(dev, "could not get usb irq\n");
698 ret = -EINVAL;
699 goto err_usb_irq;
700 }
701
702 /* Clocks. */
703 sprop = of_get_property(node, "fsl,fullspeed-clock", NULL);
704 if (sprop) {
705 fhci->fullspeed_clk = qe_clock_source(sprop);
706 if (fhci->fullspeed_clk == QE_CLK_DUMMY) {
707 dev_err(dev, "wrong fullspeed-clock\n");
708 ret = -EINVAL;
709 goto err_clocks;
710 }
711 }
712
713 sprop = of_get_property(node, "fsl,lowspeed-clock", NULL);
714 if (sprop) {
715 fhci->lowspeed_clk = qe_clock_source(sprop);
716 if (fhci->lowspeed_clk == QE_CLK_DUMMY) {
717 dev_err(dev, "wrong lowspeed-clock\n");
718 ret = -EINVAL;
719 goto err_clocks;
720 }
721 }
722
723 if (fhci->fullspeed_clk == QE_CLK_NONE &&
724 fhci->lowspeed_clk == QE_CLK_NONE) {
725 dev_err(dev, "no clocks specified\n");
726 ret = -EINVAL;
727 goto err_clocks;
728 }
729
730 dev_info(dev, "at 0x%p, irq %d\n", hcd->regs, usb_irq);
731
732 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF);
733
734 /* Start with full-speed, if possible. */
735 if (fhci->fullspeed_clk != QE_CLK_NONE) {
736 fhci_config_transceiver(fhci, FHCI_PORT_FULL);
737 qe_usb_clock_set(fhci->fullspeed_clk, USB_CLOCK);
738 } else {
739 fhci_config_transceiver(fhci, FHCI_PORT_LOW);
740 qe_usb_clock_set(fhci->lowspeed_clk, USB_CLOCK >> 3);
741 }
742
743 /* Clear and disable any pending interrupts. */
744 out_be16(&fhci->regs->usb_event, 0xffff);
745 out_be16(&fhci->regs->usb_mask, 0);
746
747 ret = usb_add_hcd(hcd, usb_irq, IRQF_DISABLED);
748 if (ret < 0)
749 goto err_add_hcd;
750
751 fhci_dfs_create(fhci);
752
753 return 0;
754
755err_add_hcd:
756err_clocks:
757 irq_dispose_mapping(usb_irq);
758err_usb_irq:
759 free_irq(fhci->timer->irq, hcd);
760err_timer_irq:
761 gtm_put_timer16(fhci->timer);
762err_get_timer:
763err_pins:
764 while (--j >= 0)
765 qe_pin_free(fhci->pins[j]);
766err_gpios:
767 while (--i >= 0) {
768 if (gpio_is_valid(fhci->gpios[i]))
769 gpio_free(fhci->gpios[i]);
770 }
771 cpm_muram_free(pram_addr);
772err_pram:
773 iounmap(hcd->regs);
774err_regs:
775 usb_put_hcd(hcd);
776 return ret;
777}
778
779static int __devexit fhci_remove(struct device *dev)
780{
781 struct usb_hcd *hcd = dev_get_drvdata(dev);
782 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
783 int i;
784 int j;
785
786 usb_remove_hcd(hcd);
787 free_irq(fhci->timer->irq, hcd);
788 gtm_put_timer16(fhci->timer);
789 cpm_muram_free(cpm_muram_offset(fhci->pram));
790 for (i = 0; i < NUM_GPIOS; i++) {
791 if (!gpio_is_valid(fhci->gpios[i]))
792 continue;
793 gpio_free(fhci->gpios[i]);
794 }
795 for (j = 0; j < NUM_PINS; j++)
796 qe_pin_free(fhci->pins[j]);
797 fhci_dfs_destroy(fhci);
798 usb_put_hcd(hcd);
799 return 0;
800}
801
802static int __devexit of_fhci_remove(struct of_device *ofdev)
803{
804 return fhci_remove(&ofdev->dev);
805}
806
807static struct of_device_id of_fhci_match[] = {
808 { .compatible = "fsl,mpc8323-qe-usb", },
809 {},
810};
811MODULE_DEVICE_TABLE(of, of_fhci_match);
812
813static struct of_platform_driver of_fhci_driver = {
814 .name = "fsl,usb-fhci",
815 .match_table = of_fhci_match,
816 .probe = of_fhci_probe,
817 .remove = __devexit_p(of_fhci_remove),
818};
819
820static int __init fhci_module_init(void)
821{
822 return of_register_platform_driver(&of_fhci_driver);
823}
824module_init(fhci_module_init);
825
826static void __exit fhci_module_exit(void)
827{
828 of_unregister_platform_driver(&of_fhci_driver);
829}
830module_exit(fhci_module_exit);
831
832MODULE_DESCRIPTION("USB Freescale Host Controller Interface Driver");
833MODULE_AUTHOR("Shlomi Gridish <gridish@freescale.com>, "
834 "Jerry Huang <Chang-Ming.Huang@freescale.com>, "
835 "Anton Vorontsov <avorontsov@ru.mvista.com>");
836MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/fhci-hub.c b/drivers/usb/host/fhci-hub.c
new file mode 100644
index 000000000000..0cfaedc3e124
--- /dev/null
+++ b/drivers/usb/host/fhci-hub.c
@@ -0,0 +1,345 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/types.h>
20#include <linux/spinlock.h>
21#include <linux/delay.h>
22#include <linux/errno.h>
23#include <linux/io.h>
24#include <linux/usb.h>
25#include <linux/gpio.h>
26#include <asm/qe.h>
27#include "../core/hcd.h"
28#include "fhci.h"
29
30/* virtual root hub specific descriptor */
31static u8 root_hub_des[] = {
32 0x09, /* blength */
33 0x29, /* bDescriptorType;hub-descriptor */
34 0x01, /* bNbrPorts */
35 0x00, /* wHubCharacteristics */
36 0x00,
37 0x01, /* bPwrOn2pwrGood;2ms */
38 0x00, /* bHubContrCurrent;0mA */
39 0x00, /* DeviceRemoveable */
40 0xff, /* PortPwrCtrlMask */
41};
42
43static void fhci_gpio_set_value(struct fhci_hcd *fhci, int gpio_nr, bool on)
44{
45 int gpio = fhci->gpios[gpio_nr];
46 bool alow = fhci->alow_gpios[gpio_nr];
47
48 if (!gpio_is_valid(gpio))
49 return;
50
51 gpio_set_value(gpio, on ^ alow);
52 mdelay(5);
53}
54
55void fhci_config_transceiver(struct fhci_hcd *fhci,
56 enum fhci_port_status status)
57{
58 fhci_dbg(fhci, "-> %s: %d\n", __func__, status);
59
60 switch (status) {
61 case FHCI_PORT_POWER_OFF:
62 fhci_gpio_set_value(fhci, GPIO_POWER, false);
63 break;
64 case FHCI_PORT_DISABLED:
65 case FHCI_PORT_WAITING:
66 fhci_gpio_set_value(fhci, GPIO_POWER, true);
67 break;
68 case FHCI_PORT_LOW:
69 fhci_gpio_set_value(fhci, GPIO_SPEED, false);
70 break;
71 case FHCI_PORT_FULL:
72 fhci_gpio_set_value(fhci, GPIO_SPEED, true);
73 break;
74 default:
75 WARN_ON(1);
76 break;
77 }
78
79 fhci_dbg(fhci, "<- %s: %d\n", __func__, status);
80}
81
82/* disable the USB port by clearing the EN bit in the USBMOD register */
83void fhci_port_disable(struct fhci_hcd *fhci)
84{
85 struct fhci_usb *usb = (struct fhci_usb *)fhci->usb_lld;
86 enum fhci_port_status port_status;
87
88 fhci_dbg(fhci, "-> %s\n", __func__);
89
90 fhci_stop_sof_timer(fhci);
91
92 fhci_flush_all_transmissions(usb);
93
94 fhci_usb_disable_interrupt((struct fhci_usb *)fhci->usb_lld);
95 port_status = usb->port_status;
96 usb->port_status = FHCI_PORT_DISABLED;
97
98 /* Enable IDLE since we want to know if something comes along */
99 usb->saved_msk |= USB_E_IDLE_MASK;
100 out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
101
102 /* check if during the disconnection process attached new device */
103 if (port_status == FHCI_PORT_WAITING)
104 fhci_device_connected_interrupt(fhci);
105 usb->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_ENABLE;
106 usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_ENABLE;
107 fhci_usb_enable_interrupt((struct fhci_usb *)fhci->usb_lld);
108
109 fhci_dbg(fhci, "<- %s\n", __func__);
110}
111
112/* enable the USB port by setting the EN bit in the USBMOD register */
113void fhci_port_enable(void *lld)
114{
115 struct fhci_usb *usb = (struct fhci_usb *)lld;
116 struct fhci_hcd *fhci = usb->fhci;
117
118 fhci_dbg(fhci, "-> %s\n", __func__);
119
120 fhci_config_transceiver(fhci, usb->port_status);
121
122 if ((usb->port_status != FHCI_PORT_FULL) &&
123 (usb->port_status != FHCI_PORT_LOW))
124 fhci_start_sof_timer(fhci);
125
126 usb->vroot_hub->port.wPortStatus |= USB_PORT_STAT_ENABLE;
127 usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_ENABLE;
128
129 fhci_dbg(fhci, "<- %s\n", __func__);
130}
131
132void fhci_io_port_generate_reset(struct fhci_hcd *fhci)
133{
134 fhci_dbg(fhci, "-> %s\n", __func__);
135
136 gpio_direction_output(fhci->gpios[GPIO_USBOE], 0);
137 gpio_direction_output(fhci->gpios[GPIO_USBTP], 0);
138 gpio_direction_output(fhci->gpios[GPIO_USBTN], 0);
139
140 mdelay(5);
141
142 qe_pin_set_dedicated(fhci->pins[PIN_USBOE]);
143 qe_pin_set_dedicated(fhci->pins[PIN_USBTP]);
144 qe_pin_set_dedicated(fhci->pins[PIN_USBTN]);
145
146 fhci_dbg(fhci, "<- %s\n", __func__);
147}
148
149/* generate the RESET condition on the bus */
150void fhci_port_reset(void *lld)
151{
152 struct fhci_usb *usb = (struct fhci_usb *)lld;
153 struct fhci_hcd *fhci = usb->fhci;
154 u8 mode;
155 u16 mask;
156
157 fhci_dbg(fhci, "-> %s\n", __func__);
158
159 fhci_stop_sof_timer(fhci);
160 /* disable the USB controller */
161 mode = in_8(&fhci->regs->usb_mod);
162 out_8(&fhci->regs->usb_mod, mode & (~USB_MODE_EN));
163
164 /* disable idle interrupts */
165 mask = in_be16(&fhci->regs->usb_mask);
166 out_be16(&fhci->regs->usb_mask, mask & (~USB_E_IDLE_MASK));
167
168 fhci_io_port_generate_reset(fhci);
169
170 /* enable interrupt on this endpoint */
171 out_be16(&fhci->regs->usb_mask, mask);
172
173 /* enable the USB controller */
174 mode = in_8(&fhci->regs->usb_mod);
175 out_8(&fhci->regs->usb_mod, mode | USB_MODE_EN);
176 fhci_start_sof_timer(fhci);
177
178 fhci_dbg(fhci, "<- %s\n", __func__);
179}
180
181int fhci_hub_status_data(struct usb_hcd *hcd, char *buf)
182{
183 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
184 int ret = 0;
185 unsigned long flags;
186
187 fhci_dbg(fhci, "-> %s\n", __func__);
188
189 spin_lock_irqsave(&fhci->lock, flags);
190
191 if (fhci->vroot_hub->port.wPortChange & (USB_PORT_STAT_C_CONNECTION |
192 USB_PORT_STAT_C_ENABLE | USB_PORT_STAT_C_SUSPEND |
193 USB_PORT_STAT_C_RESET | USB_PORT_STAT_C_OVERCURRENT)) {
194 *buf = 1 << 1;
195 ret = 1;
196 fhci_dbg(fhci, "-- %s\n", __func__);
197 }
198
199 spin_unlock_irqrestore(&fhci->lock, flags);
200
201 fhci_dbg(fhci, "<- %s\n", __func__);
202
203 return ret;
204}
205
206int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
207 u16 wIndex, char *buf, u16 wLength)
208{
209 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
210 int retval = 0;
211 int len = 0;
212 struct usb_hub_status *hub_status;
213 struct usb_port_status *port_status;
214 unsigned long flags;
215
216 spin_lock_irqsave(&fhci->lock, flags);
217
218 fhci_dbg(fhci, "-> %s\n", __func__);
219
220 switch (typeReq) {
221 case ClearHubFeature:
222 switch (wValue) {
223 case C_HUB_LOCAL_POWER:
224 case C_HUB_OVER_CURRENT:
225 break;
226 default:
227 goto error;
228 }
229 break;
230 case ClearPortFeature:
231 fhci->vroot_hub->feature &= (1 << wValue);
232
233 switch (wValue) {
234 case USB_PORT_FEAT_ENABLE:
235 fhci->vroot_hub->port.wPortStatus &=
236 ~USB_PORT_STAT_ENABLE;
237 fhci_port_disable(fhci);
238 break;
239 case USB_PORT_FEAT_C_ENABLE:
240 fhci->vroot_hub->port.wPortChange &=
241 ~USB_PORT_STAT_C_ENABLE;
242 break;
243 case USB_PORT_FEAT_SUSPEND:
244 fhci->vroot_hub->port.wPortStatus &=
245 ~USB_PORT_STAT_SUSPEND;
246 fhci_stop_sof_timer(fhci);
247 break;
248 case USB_PORT_FEAT_C_SUSPEND:
249 fhci->vroot_hub->port.wPortChange &=
250 ~USB_PORT_STAT_C_SUSPEND;
251 break;
252 case USB_PORT_FEAT_POWER:
253 fhci->vroot_hub->port.wPortStatus &=
254 ~USB_PORT_STAT_POWER;
255 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF);
256 break;
257 case USB_PORT_FEAT_C_CONNECTION:
258 fhci->vroot_hub->port.wPortChange &=
259 ~USB_PORT_STAT_C_CONNECTION;
260 break;
261 case USB_PORT_FEAT_C_OVER_CURRENT:
262 fhci->vroot_hub->port.wPortChange &=
263 ~USB_PORT_STAT_C_OVERCURRENT;
264 break;
265 case USB_PORT_FEAT_C_RESET:
266 fhci->vroot_hub->port.wPortChange &=
267 ~USB_PORT_STAT_C_RESET;
268 break;
269 default:
270 goto error;
271 }
272 break;
273 case GetHubDescriptor:
274 memcpy(buf, root_hub_des, sizeof(root_hub_des));
275 buf[3] = 0x11; /* per-port power, no ovrcrnt */
276 len = (buf[0] < wLength) ? buf[0] : wLength;
277 break;
278 case GetHubStatus:
279 hub_status = (struct usb_hub_status *)buf;
280 hub_status->wHubStatus =
281 cpu_to_le16(fhci->vroot_hub->hub.wHubStatus);
282 hub_status->wHubChange =
283 cpu_to_le16(fhci->vroot_hub->hub.wHubChange);
284 len = 4;
285 break;
286 case GetPortStatus:
287 port_status = (struct usb_port_status *)buf;
288 port_status->wPortStatus =
289 cpu_to_le16(fhci->vroot_hub->port.wPortStatus);
290 port_status->wPortChange =
291 cpu_to_le16(fhci->vroot_hub->port.wPortChange);
292 len = 4;
293 break;
294 case SetHubFeature:
295 switch (wValue) {
296 case C_HUB_OVER_CURRENT:
297 case C_HUB_LOCAL_POWER:
298 break;
299 default:
300 goto error;
301 }
302 break;
303 case SetPortFeature:
304 fhci->vroot_hub->feature |= (1 << wValue);
305
306 switch (wValue) {
307 case USB_PORT_FEAT_ENABLE:
308 fhci->vroot_hub->port.wPortStatus |=
309 USB_PORT_STAT_ENABLE;
310 fhci_port_enable(fhci->usb_lld);
311 break;
312 case USB_PORT_FEAT_SUSPEND:
313 fhci->vroot_hub->port.wPortStatus |=
314 USB_PORT_STAT_SUSPEND;
315 fhci_stop_sof_timer(fhci);
316 break;
317 case USB_PORT_FEAT_RESET:
318 fhci->vroot_hub->port.wPortStatus |=
319 USB_PORT_STAT_RESET;
320 fhci_port_reset(fhci->usb_lld);
321 fhci->vroot_hub->port.wPortStatus |=
322 USB_PORT_STAT_ENABLE;
323 fhci->vroot_hub->port.wPortStatus &=
324 ~USB_PORT_STAT_RESET;
325 break;
326 case USB_PORT_FEAT_POWER:
327 fhci->vroot_hub->port.wPortStatus |=
328 USB_PORT_STAT_POWER;
329 fhci_config_transceiver(fhci, FHCI_PORT_WAITING);
330 break;
331 default:
332 goto error;
333 }
334 break;
335 default:
336error:
337 retval = -EPIPE;
338 }
339
340 fhci_dbg(fhci, "<- %s\n", __func__);
341
342 spin_unlock_irqrestore(&fhci->lock, flags);
343
344 return retval;
345}
diff --git a/drivers/usb/host/fhci-mem.c b/drivers/usb/host/fhci-mem.c
new file mode 100644
index 000000000000..2c0736c99712
--- /dev/null
+++ b/drivers/usb/host/fhci-mem.c
@@ -0,0 +1,113 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/types.h>
20#include <linux/delay.h>
21#include <linux/list.h>
22#include <linux/usb.h>
23#include "../core/hcd.h"
24#include "fhci.h"
25
26static void init_td(struct td *td)
27{
28 memset(td, 0, sizeof(*td));
29 INIT_LIST_HEAD(&td->node);
30 INIT_LIST_HEAD(&td->frame_lh);
31}
32
33static void init_ed(struct ed *ed)
34{
35 memset(ed, 0, sizeof(*ed));
36 INIT_LIST_HEAD(&ed->td_list);
37 INIT_LIST_HEAD(&ed->node);
38}
39
40static struct td *get_empty_td(struct fhci_hcd *fhci)
41{
42 struct td *td;
43
44 if (!list_empty(&fhci->empty_tds)) {
45 td = list_entry(fhci->empty_tds.next, struct td, node);
46 list_del(fhci->empty_tds.next);
47 } else {
48 td = kmalloc(sizeof(*td), GFP_ATOMIC);
49 if (!td)
50 fhci_err(fhci, "No memory to allocate to TD\n");
51 else
52 init_td(td);
53 }
54
55 return td;
56}
57
58void fhci_recycle_empty_td(struct fhci_hcd *fhci, struct td *td)
59{
60 init_td(td);
61 list_add(&td->node, &fhci->empty_tds);
62}
63
64struct ed *fhci_get_empty_ed(struct fhci_hcd *fhci)
65{
66 struct ed *ed;
67
68 if (!list_empty(&fhci->empty_eds)) {
69 ed = list_entry(fhci->empty_eds.next, struct ed, node);
70 list_del(fhci->empty_eds.next);
71 } else {
72 ed = kmalloc(sizeof(*ed), GFP_ATOMIC);
73 if (!ed)
74 fhci_err(fhci, "No memory to allocate to ED\n");
75 else
76 init_ed(ed);
77 }
78
79 return ed;
80}
81
82void fhci_recycle_empty_ed(struct fhci_hcd *fhci, struct ed *ed)
83{
84 init_ed(ed);
85 list_add(&ed->node, &fhci->empty_eds);
86}
87
88struct td *fhci_td_fill(struct fhci_hcd *fhci, struct urb *urb,
89 struct urb_priv *urb_priv, struct ed *ed, u16 index,
90 enum fhci_ta_type type, int toggle, u8 *data, u32 len,
91 u16 interval, u16 start_frame, bool ioc)
92{
93 struct td *td = get_empty_td(fhci);
94
95 if (!td)
96 return NULL;
97
98 td->urb = urb;
99 td->ed = ed;
100 td->type = type;
101 td->toggle = toggle;
102 td->data = data;
103 td->len = len;
104 td->iso_index = index;
105 td->interval = interval;
106 td->start_frame = start_frame;
107 td->ioc = ioc;
108 td->status = USB_TD_OK;
109
110 urb_priv->tds[index] = td;
111
112 return td;
113}
diff --git a/drivers/usb/host/fhci-q.c b/drivers/usb/host/fhci-q.c
new file mode 100644
index 000000000000..b0a1446ba292
--- /dev/null
+++ b/drivers/usb/host/fhci-q.c
@@ -0,0 +1,284 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/types.h>
20#include <linux/spinlock.h>
21#include <linux/errno.h>
22#include <linux/list.h>
23#include <linux/usb.h>
24#include "../core/hcd.h"
25#include "fhci.h"
26
27/* maps the hardware error code to the USB error code */
28static int status_to_error(u32 status)
29{
30 if (status == USB_TD_OK)
31 return 0;
32 else if (status & USB_TD_RX_ER_CRC)
33 return -EILSEQ;
34 else if (status & USB_TD_RX_ER_NONOCT)
35 return -EPROTO;
36 else if (status & USB_TD_RX_ER_OVERUN)
37 return -ECOMM;
38 else if (status & USB_TD_RX_ER_BITSTUFF)
39 return -EPROTO;
40 else if (status & USB_TD_RX_ER_PID)
41 return -EILSEQ;
42 else if (status & (USB_TD_TX_ER_NAK | USB_TD_TX_ER_TIMEOUT))
43 return -ETIMEDOUT;
44 else if (status & USB_TD_TX_ER_STALL)
45 return -EPIPE;
46 else if (status & USB_TD_TX_ER_UNDERUN)
47 return -ENOSR;
48 else if (status & USB_TD_RX_DATA_UNDERUN)
49 return -EREMOTEIO;
50 else if (status & USB_TD_RX_DATA_OVERUN)
51 return -EOVERFLOW;
52 else
53 return -EINVAL;
54}
55
56void fhci_add_td_to_frame(struct fhci_time_frame *frame, struct td *td)
57{
58 list_add_tail(&td->frame_lh, &frame->tds_list);
59}
60
61void fhci_add_tds_to_ed(struct ed *ed, struct td **td_list, int number)
62{
63 int i;
64
65 for (i = 0; i < number; i++) {
66 struct td *td = td_list[i];
67 list_add_tail(&td->node, &ed->td_list);
68 }
69 if (ed->td_head == NULL)
70 ed->td_head = td_list[0];
71}
72
73static struct td *peek_td_from_ed(struct ed *ed)
74{
75 struct td *td;
76
77 if (!list_empty(&ed->td_list))
78 td = list_entry(ed->td_list.next, struct td, node);
79 else
80 td = NULL;
81
82 return td;
83}
84
85struct td *fhci_remove_td_from_frame(struct fhci_time_frame *frame)
86{
87 struct td *td;
88
89 if (!list_empty(&frame->tds_list)) {
90 td = list_entry(frame->tds_list.next, struct td, frame_lh);
91 list_del_init(frame->tds_list.next);
92 } else
93 td = NULL;
94
95 return td;
96}
97
98struct td *fhci_peek_td_from_frame(struct fhci_time_frame *frame)
99{
100 struct td *td;
101
102 if (!list_empty(&frame->tds_list))
103 td = list_entry(frame->tds_list.next, struct td, frame_lh);
104 else
105 td = NULL;
106
107 return td;
108}
109
110struct td *fhci_remove_td_from_ed(struct ed *ed)
111{
112 struct td *td;
113
114 if (!list_empty(&ed->td_list)) {
115 td = list_entry(ed->td_list.next, struct td, node);
116 list_del_init(ed->td_list.next);
117
118 /* if this TD was the ED's head, find next TD */
119 if (!list_empty(&ed->td_list))
120 ed->td_head = list_entry(ed->td_list.next, struct td,
121 node);
122 else
123 ed->td_head = NULL;
124 } else
125 td = NULL;
126
127 return td;
128}
129
130struct td *fhci_remove_td_from_done_list(struct fhci_controller_list *p_list)
131{
132 struct td *td;
133
134 if (!list_empty(&p_list->done_list)) {
135 td = list_entry(p_list->done_list.next, struct td, node);
136 list_del_init(p_list->done_list.next);
137 } else
138 td = NULL;
139
140 return td;
141}
142
143void fhci_move_td_from_ed_to_done_list(struct fhci_usb *usb, struct ed *ed)
144{
145 struct td *td;
146
147 td = ed->td_head;
148 list_del_init(&td->node);
149
150 /* If this TD was the ED's head,find next TD */
151 if (!list_empty(&ed->td_list))
152 ed->td_head = list_entry(ed->td_list.next, struct td, node);
153 else {
154 ed->td_head = NULL;
155 ed->state = FHCI_ED_SKIP;
156 }
157 ed->toggle_carry = td->toggle;
158 list_add_tail(&td->node, &usb->hc_list->done_list);
159 if (td->ioc)
160 usb->transfer_confirm(usb->fhci);
161}
162
163/* free done FHCI URB resource such as ED and TD */
164static void free_urb_priv(struct fhci_hcd *fhci, struct urb *urb)
165{
166 int i;
167 struct urb_priv *urb_priv = urb->hcpriv;
168 struct ed *ed = urb_priv->ed;
169
170 for (i = 0; i < urb_priv->num_of_tds; i++) {
171 list_del_init(&urb_priv->tds[i]->node);
172 fhci_recycle_empty_td(fhci, urb_priv->tds[i]);
173 }
174
175 /* if this TD was the ED's head,find the next TD */
176 if (!list_empty(&ed->td_list))
177 ed->td_head = list_entry(ed->td_list.next, struct td, node);
178 else
179 ed->td_head = NULL;
180
181 kfree(urb_priv->tds);
182 kfree(urb_priv);
183 urb->hcpriv = NULL;
184
185 /* if this TD was the ED's head,find next TD */
186 if (ed->td_head == NULL)
187 list_del_init(&ed->node);
188 fhci->active_urbs--;
189}
190
191/* this routine called to complete and free done URB */
192void fhci_urb_complete_free(struct fhci_hcd *fhci, struct urb *urb)
193{
194 free_urb_priv(fhci, urb);
195
196 if (urb->status == -EINPROGRESS) {
197 if (urb->actual_length != urb->transfer_buffer_length &&
198 urb->transfer_flags & URB_SHORT_NOT_OK)
199 urb->status = -EREMOTEIO;
200 else
201 urb->status = 0;
202 }
203
204 usb_hcd_unlink_urb_from_ep(fhci_to_hcd(fhci), urb);
205
206 spin_unlock(&fhci->lock);
207
208 usb_hcd_giveback_urb(fhci_to_hcd(fhci), urb, urb->status);
209
210 spin_lock(&fhci->lock);
211}
212
213/*
214 * caculate transfer length/stats and update the urb
215 * Precondition: irqsafe(only for urb-?status locking)
216 */
217void fhci_done_td(struct urb *urb, struct td *td)
218{
219 struct ed *ed = td->ed;
220 u32 cc = td->status;
221
222 /* ISO...drivers see per-TD length/status */
223 if (ed->mode == FHCI_TF_ISO) {
224 u32 len;
225 if (!(urb->transfer_flags & URB_SHORT_NOT_OK &&
226 cc == USB_TD_RX_DATA_UNDERUN))
227 cc = USB_TD_OK;
228
229 if (usb_pipeout(urb->pipe))
230 len = urb->iso_frame_desc[td->iso_index].length;
231 else
232 len = td->actual_len;
233
234 urb->actual_length += len;
235 urb->iso_frame_desc[td->iso_index].actual_length = len;
236 urb->iso_frame_desc[td->iso_index].status =
237 status_to_error(cc);
238 }
239
240 /* BULK,INT,CONTROL... drivers see aggregate length/status,
241 * except that "setup" bytes aren't counted and "short" transfers
242 * might not be reported as errors.
243 */
244 else {
245 if (td->error_cnt >= 3)
246 urb->error_count = 3;
247
248 /* control endpoint only have soft stalls */
249
250 /* update packet status if needed(short may be ok) */
251 if (!(urb->transfer_flags & URB_SHORT_NOT_OK) &&
252 cc == USB_TD_RX_DATA_UNDERUN) {
253 ed->state = FHCI_ED_OPER;
254 cc = USB_TD_OK;
255 }
256 if (cc != USB_TD_OK) {
257 if (urb->status == -EINPROGRESS)
258 urb->status = status_to_error(cc);
259 }
260
261 /* count all non-empty packets except control SETUP packet */
262 if (td->type != FHCI_TA_SETUP || td->iso_index != 0)
263 urb->actual_length += td->actual_len;
264 }
265}
266
267/* there are some pedning request to unlink */
268void fhci_del_ed_list(struct fhci_hcd *fhci, struct ed *ed)
269{
270 struct td *td = peek_td_from_ed(ed);
271 struct urb *urb = td->urb;
272 struct urb_priv *urb_priv = urb->hcpriv;
273
274 if (urb_priv->state == URB_DEL) {
275 td = fhci_remove_td_from_ed(ed);
276 /* HC may have partly processed this TD */
277 if (td->status != USB_TD_INPROGRESS)
278 fhci_done_td(urb, td);
279
280 /* URB is done;clean up */
281 if (++(urb_priv->tds_cnt) == urb_priv->num_of_tds)
282 fhci_urb_complete_free(fhci, urb);
283 }
284}
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
new file mode 100644
index 000000000000..bb63b68ddb77
--- /dev/null
+++ b/drivers/usb/host/fhci-sched.c
@@ -0,0 +1,888 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/types.h>
20#include <linux/spinlock.h>
21#include <linux/delay.h>
22#include <linux/errno.h>
23#include <linux/list.h>
24#include <linux/interrupt.h>
25#include <linux/io.h>
26#include <linux/usb.h>
27#include <asm/qe.h>
28#include <asm/fsl_gtm.h>
29#include "../core/hcd.h"
30#include "fhci.h"
31
32static void recycle_frame(struct fhci_usb *usb, struct packet *pkt)
33{
34 pkt->data = NULL;
35 pkt->len = 0;
36 pkt->status = USB_TD_OK;
37 pkt->info = 0;
38 pkt->priv_data = NULL;
39
40 cq_put(usb->ep0->empty_frame_Q, pkt);
41}
42
43/* confirm submitted packet */
44void fhci_transaction_confirm(struct fhci_usb *usb, struct packet *pkt)
45{
46 struct td *td;
47 struct packet *td_pkt;
48 struct ed *ed;
49 u32 trans_len;
50 bool td_done = false;
51
52 td = fhci_remove_td_from_frame(usb->actual_frame);
53 td_pkt = td->pkt;
54 trans_len = pkt->len;
55 td->status = pkt->status;
56 if (td->type == FHCI_TA_IN && td_pkt->info & PKT_DUMMY_PACKET) {
57 if ((td->data + td->actual_len) && trans_len)
58 memcpy(td->data + td->actual_len, pkt->data,
59 trans_len);
60 cq_put(usb->ep0->dummy_packets_Q, pkt->data);
61 }
62
63 recycle_frame(usb, pkt);
64
65 ed = td->ed;
66 if (ed->mode == FHCI_TF_ISO) {
67 if (ed->td_list.next->next != &ed->td_list) {
68 struct td *td_next =
69 list_entry(ed->td_list.next->next, struct td,
70 node);
71
72 td_next->start_frame = usb->actual_frame->frame_num;
73 }
74 td->actual_len = trans_len;
75 td_done = true;
76 } else if ((td->status & USB_TD_ERROR) &&
77 !(td->status & USB_TD_TX_ER_NAK)) {
78 /*
79 * There was an error on the transaction (but not NAK).
80 * If it is fatal error (data underrun, stall, bad pid or 3
81 * errors exceeded), mark this TD as done.
82 */
83 if ((td->status & USB_TD_RX_DATA_UNDERUN) ||
84 (td->status & USB_TD_TX_ER_STALL) ||
85 (td->status & USB_TD_RX_ER_PID) ||
86 (++td->error_cnt >= 3)) {
87 ed->state = FHCI_ED_HALTED;
88 td_done = true;
89
90 if (td->status & USB_TD_RX_DATA_UNDERUN) {
91 fhci_dbg(usb->fhci, "td err fu\n");
92 td->toggle = !td->toggle;
93 td->actual_len += trans_len;
94 } else {
95 fhci_dbg(usb->fhci, "td err f!u\n");
96 }
97 } else {
98 fhci_dbg(usb->fhci, "td err !f\n");
99 /* it is not a fatal error -retry this transaction */
100 td->nak_cnt = 0;
101 td->error_cnt++;
102 td->status = USB_TD_OK;
103 }
104 } else if (td->status & USB_TD_TX_ER_NAK) {
105 /* there was a NAK response */
106 fhci_vdbg(usb->fhci, "td nack\n");
107 td->nak_cnt++;
108 td->error_cnt = 0;
109 td->status = USB_TD_OK;
110 } else {
111 /* there was no error on transaction */
112 td->error_cnt = 0;
113 td->nak_cnt = 0;
114 td->toggle = !td->toggle;
115 td->actual_len += trans_len;
116
117 if (td->len == td->actual_len)
118 td_done = true;
119 }
120
121 if (td_done)
122 fhci_move_td_from_ed_to_done_list(usb, ed);
123}
124
125/*
126 * Flush all transmitted packets from BDs
127 * This routine is called when disabling the USB port to flush all
128 * transmissions that are allready scheduled in the BDs
129 */
130void fhci_flush_all_transmissions(struct fhci_usb *usb)
131{
132 u8 mode;
133 struct td *td;
134
135 mode = in_8(&usb->fhci->regs->usb_mod);
136 clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_EN);
137
138 fhci_flush_bds(usb);
139
140 while ((td = fhci_peek_td_from_frame(usb->actual_frame)) != NULL) {
141 struct packet *pkt = td->pkt;
142
143 pkt->status = USB_TD_TX_ER_TIMEOUT;
144 fhci_transaction_confirm(usb, pkt);
145 }
146
147 usb->actual_frame->frame_status = FRAME_END_TRANSMISSION;
148
149 /* reset the event register */
150 out_be16(&usb->fhci->regs->usb_event, 0xffff);
151 /* enable the USB controller */
152 out_8(&usb->fhci->regs->usb_mod, mode | USB_MODE_EN);
153}
154
155/*
156 * This function forms the packet and transmit the packet. This function
157 * will handle all endpoint type:ISO,interrupt,control and bulk
158 */
159static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td)
160{
161 u32 fw_transaction_time, len = 0;
162 struct packet *pkt;
163 u8 *data = NULL;
164
165 /* calcalate data address,len and toggle and then add the transaction */
166 if (td->toggle == USB_TD_TOGGLE_CARRY)
167 td->toggle = ed->toggle_carry;
168
169 switch (ed->mode) {
170 case FHCI_TF_ISO:
171 len = td->len;
172 if (td->type != FHCI_TA_IN)
173 data = td->data;
174 break;
175 case FHCI_TF_CTRL:
176 case FHCI_TF_BULK:
177 len = min(td->len - td->actual_len, ed->max_pkt_size);
178 if (!((td->type == FHCI_TA_IN) &&
179 ((len + td->actual_len) == td->len)))
180 data = td->data + td->actual_len;
181 break;
182 case FHCI_TF_INTR:
183 len = min(td->len, ed->max_pkt_size);
184 if (!((td->type == FHCI_TA_IN) &&
185 ((td->len + CRC_SIZE) >= ed->max_pkt_size)))
186 data = td->data;
187 break;
188 default:
189 break;
190 }
191
192 if (usb->port_status == FHCI_PORT_FULL)
193 fw_transaction_time = (((len + PROTOCOL_OVERHEAD) * 11) >> 4);
194 else
195 fw_transaction_time = ((len + PROTOCOL_OVERHEAD) * 6);
196
197 /* check if there's enough space in this frame to submit this TD */
198 if (usb->actual_frame->total_bytes + len + PROTOCOL_OVERHEAD >=
199 usb->max_bytes_per_frame) {
200 fhci_vdbg(usb->fhci, "not enough space in this frame: "
201 "%d %d %d\n", usb->actual_frame->total_bytes, len,
202 usb->max_bytes_per_frame);
203 return -1;
204 }
205
206 /* check if there's enough time in this frame to submit this TD */
207 if (usb->actual_frame->frame_status != FRAME_IS_PREPARED &&
208 (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION ||
209 (fw_transaction_time + usb->sw_transaction_time >=
210 1000 - fhci_get_sof_timer_count(usb)))) {
211 fhci_dbg(usb->fhci, "not enough time in this frame\n");
212 return -1;
213 }
214
215 /* update frame object fields before transmitting */
216 pkt = cq_get(usb->ep0->empty_frame_Q);
217 if (!pkt) {
218 fhci_dbg(usb->fhci, "there is no empty frame\n");
219 return -1;
220 }
221 td->pkt = pkt;
222
223 pkt->info = 0;
224 if (data == NULL) {
225 data = cq_get(usb->ep0->dummy_packets_Q);
226 BUG_ON(!data);
227 pkt->info = PKT_DUMMY_PACKET;
228 }
229 pkt->data = data;
230 pkt->len = len;
231 pkt->status = USB_TD_OK;
232 /* update TD status field before transmitting */
233 td->status = USB_TD_INPROGRESS;
234 /* update actual frame time object with the actual transmission */
235 usb->actual_frame->total_bytes += (len + PROTOCOL_OVERHEAD);
236 fhci_add_td_to_frame(usb->actual_frame, td);
237
238 if (usb->port_status != FHCI_PORT_FULL &&
239 usb->port_status != FHCI_PORT_LOW) {
240 pkt->status = USB_TD_TX_ER_TIMEOUT;
241 pkt->len = 0;
242 fhci_transaction_confirm(usb, pkt);
243 } else if (fhci_host_transaction(usb, pkt, td->type, ed->dev_addr,
244 ed->ep_addr, ed->mode, ed->speed, td->toggle)) {
245 /* remove TD from actual frame */
246 list_del_init(&td->frame_lh);
247 td->status = USB_TD_OK;
248 if (pkt->info & PKT_DUMMY_PACKET)
249 cq_put(usb->ep0->dummy_packets_Q, pkt->data);
250 recycle_frame(usb, pkt);
251 usb->actual_frame->total_bytes -= (len + PROTOCOL_OVERHEAD);
252 fhci_err(usb->fhci, "host transaction failed\n");
253 return -1;
254 }
255
256 return len;
257}
258
259static void move_head_to_tail(struct list_head *list)
260{
261 struct list_head *node = list->next;
262
263 if (!list_empty(list)) {
264 list_del(node);
265 list_add_tail(node, list);
266 }
267}
268
269/*
270 * This function goes through the endpoint list and schedules the
271 * transactions within this list
272 */
273static int scan_ed_list(struct fhci_usb *usb,
274 struct list_head *list, enum fhci_tf_mode list_type)
275{
276 static const int frame_part[4] = {
277 [FHCI_TF_CTRL] = MAX_BYTES_PER_FRAME,
278 [FHCI_TF_ISO] = (MAX_BYTES_PER_FRAME *
279 MAX_PERIODIC_FRAME_USAGE) / 100,
280 [FHCI_TF_BULK] = MAX_BYTES_PER_FRAME,
281 [FHCI_TF_INTR] = (MAX_BYTES_PER_FRAME *
282 MAX_PERIODIC_FRAME_USAGE) / 100
283 };
284 struct ed *ed;
285 struct td *td;
286 int ans = 1;
287 u32 save_transaction_time = usb->sw_transaction_time;
288
289 list_for_each_entry(ed, list, node) {
290 td = ed->td_head;
291
292 if (!td || (td && td->status == USB_TD_INPROGRESS))
293 continue;
294
295 if (ed->state != FHCI_ED_OPER) {
296 if (ed->state == FHCI_ED_URB_DEL) {
297 td->status = USB_TD_OK;
298 fhci_move_td_from_ed_to_done_list(usb, ed);
299 ed->state = FHCI_ED_SKIP;
300 }
301 continue;
302 }
303
304 /*
305 * if it isn't interrupt pipe or it is not iso pipe and the
306 * interval time passed
307 */
308 if ((list_type == FHCI_TF_INTR || list_type == FHCI_TF_ISO) &&
309 (((usb->actual_frame->frame_num -
310 td->start_frame) & 0x7ff) < td->interval))
311 continue;
312
313 if (add_packet(usb, ed, td) < 0)
314 continue;
315
316 /* update time stamps in the TD */
317 td->start_frame = usb->actual_frame->frame_num;
318 usb->sw_transaction_time += save_transaction_time;
319
320 if (usb->actual_frame->total_bytes >=
321 usb->max_bytes_per_frame) {
322 usb->actual_frame->frame_status =
323 FRAME_DATA_END_TRANSMISSION;
324 fhci_push_dummy_bd(usb->ep0);
325 ans = 0;
326 break;
327 }
328
329 if (usb->actual_frame->total_bytes >= frame_part[list_type])
330 break;
331 }
332
333 /* be fair to each ED(move list head around) */
334 move_head_to_tail(list);
335 usb->sw_transaction_time = save_transaction_time;
336
337 return ans;
338}
339
340static u32 rotate_frames(struct fhci_usb *usb)
341{
342 struct fhci_hcd *fhci = usb->fhci;
343
344 if (!list_empty(&usb->actual_frame->tds_list)) {
345 if ((((in_be16(&fhci->pram->frame_num) & 0x07ff) -
346 usb->actual_frame->frame_num) & 0x7ff) > 5)
347 fhci_flush_actual_frame(usb);
348 else
349 return -EINVAL;
350 }
351
352 usb->actual_frame->frame_status = FRAME_IS_PREPARED;
353 usb->actual_frame->frame_num = in_be16(&fhci->pram->frame_num) & 0x7ff;
354 usb->actual_frame->total_bytes = 0;
355
356 return 0;
357}
358
359/*
360 * This function schedule the USB transaction and will process the
361 * endpoint in the following order: iso, interrupt, control and bulk.
362 */
363void fhci_schedule_transactions(struct fhci_usb *usb)
364{
365 int left = 1;
366
367 if (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION)
368 if (rotate_frames(usb) != 0)
369 return;
370
371 if (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION)
372 return;
373
374 if (usb->actual_frame->total_bytes == 0) {
375 /*
376 * schedule the next available ISO transfer
377 *or next stage of the ISO transfer
378 */
379 scan_ed_list(usb, &usb->hc_list->iso_list, FHCI_TF_ISO);
380
381 /*
382 * schedule the next available interrupt transfer or
383 * the next stage of the interrupt transfer
384 */
385 scan_ed_list(usb, &usb->hc_list->intr_list, FHCI_TF_INTR);
386
387 /*
388 * schedule the next available control transfer
389 * or the next stage of the control transfer
390 */
391 left = scan_ed_list(usb, &usb->hc_list->ctrl_list,
392 FHCI_TF_CTRL);
393 }
394
395 /*
396 * schedule the next available bulk transfer or the next stage of the
397 * bulk transfer
398 */
399 if (left > 0)
400 scan_ed_list(usb, &usb->hc_list->bulk_list, FHCI_TF_BULK);
401}
402
403/* Handles SOF interrupt */
404static void sof_interrupt(struct fhci_hcd *fhci)
405{
406 struct fhci_usb *usb = fhci->usb_lld;
407
408 if ((usb->port_status == FHCI_PORT_DISABLED) &&
409 (usb->vroot_hub->port.wPortStatus & USB_PORT_STAT_CONNECTION) &&
410 !(usb->vroot_hub->port.wPortChange & USB_PORT_STAT_C_CONNECTION)) {
411 if (usb->vroot_hub->port.wPortStatus & USB_PORT_STAT_LOW_SPEED)
412 usb->port_status = FHCI_PORT_LOW;
413 else
414 usb->port_status = FHCI_PORT_FULL;
415 /* Disable IDLE */
416 usb->saved_msk &= ~USB_E_IDLE_MASK;
417 out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
418 }
419
420 gtm_set_exact_timer16(fhci->timer, usb->max_frame_usage, false);
421
422 fhci_host_transmit_actual_frame(usb);
423 usb->actual_frame->frame_status = FRAME_IS_TRANSMITTED;
424
425 fhci_schedule_transactions(usb);
426}
427
428/* Handles device disconnected interrupt on port */
429void fhci_device_disconnected_interrupt(struct fhci_hcd *fhci)
430{
431 struct fhci_usb *usb = fhci->usb_lld;
432
433 fhci_dbg(fhci, "-> %s\n", __func__);
434
435 fhci_usb_disable_interrupt(usb);
436 clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_LSS);
437 usb->port_status = FHCI_PORT_DISABLED;
438
439 fhci_stop_sof_timer(fhci);
440
441 /* Enable IDLE since we want to know if something comes along */
442 usb->saved_msk |= USB_E_IDLE_MASK;
443 out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
444
445 usb->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_CONNECTION;
446 usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_CONNECTION;
447 usb->max_bytes_per_frame = 0;
448 fhci_usb_enable_interrupt(usb);
449
450 fhci_dbg(fhci, "<- %s\n", __func__);
451}
452
453/* detect a new device connected on the USB port */
454void fhci_device_connected_interrupt(struct fhci_hcd *fhci)
455{
456
457 struct fhci_usb *usb = fhci->usb_lld;
458 int state;
459 int ret;
460
461 fhci_dbg(fhci, "-> %s\n", __func__);
462
463 fhci_usb_disable_interrupt(usb);
464 state = fhci_ioports_check_bus_state(fhci);
465
466 /* low-speed device was connected to the USB port */
467 if (state == 1) {
468 ret = qe_usb_clock_set(fhci->lowspeed_clk, USB_CLOCK >> 3);
469 if (ret) {
470 fhci_warn(fhci, "Low-Speed device is not supported, "
471 "try use BRGx\n");
472 goto out;
473 }
474
475 usb->port_status = FHCI_PORT_LOW;
476 setbits8(&usb->fhci->regs->usb_mod, USB_MODE_LSS);
477 usb->vroot_hub->port.wPortStatus |=
478 (USB_PORT_STAT_LOW_SPEED |
479 USB_PORT_STAT_CONNECTION);
480 usb->vroot_hub->port.wPortChange |=
481 USB_PORT_STAT_C_CONNECTION;
482 usb->max_bytes_per_frame =
483 (MAX_BYTES_PER_FRAME >> 3) - 7;
484 fhci_port_enable(usb);
485 } else if (state == 2) {
486 ret = qe_usb_clock_set(fhci->fullspeed_clk, USB_CLOCK);
487 if (ret) {
488 fhci_warn(fhci, "Full-Speed device is not supported, "
489 "try use CLKx\n");
490 goto out;
491 }
492
493 usb->port_status = FHCI_PORT_FULL;
494 clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_LSS);
495 usb->vroot_hub->port.wPortStatus &=
496 ~USB_PORT_STAT_LOW_SPEED;
497 usb->vroot_hub->port.wPortStatus |=
498 USB_PORT_STAT_CONNECTION;
499 usb->vroot_hub->port.wPortChange |=
500 USB_PORT_STAT_C_CONNECTION;
501 usb->max_bytes_per_frame = (MAX_BYTES_PER_FRAME - 15);
502 fhci_port_enable(usb);
503 }
504out:
505 fhci_usb_enable_interrupt(usb);
506 fhci_dbg(fhci, "<- %s\n", __func__);
507}
508
509irqreturn_t fhci_frame_limit_timer_irq(int irq, void *_hcd)
510{
511 struct usb_hcd *hcd = _hcd;
512 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
513 struct fhci_usb *usb = fhci->usb_lld;
514
515 spin_lock(&fhci->lock);
516
517 gtm_set_exact_timer16(fhci->timer, 1000, false);
518
519 if (usb->actual_frame->frame_status == FRAME_IS_TRANSMITTED) {
520 usb->actual_frame->frame_status = FRAME_TIMER_END_TRANSMISSION;
521 fhci_push_dummy_bd(usb->ep0);
522 }
523
524 fhci_schedule_transactions(usb);
525
526 spin_unlock(&fhci->lock);
527
528 return IRQ_HANDLED;
529}
530
531/* Cancel transmission on the USB endpoint */
532static void abort_transmission(struct fhci_usb *usb)
533{
534 fhci_dbg(usb->fhci, "-> %s\n", __func__);
535 /* issue stop Tx command */
536 qe_issue_cmd(QE_USB_STOP_TX, QE_CR_SUBBLOCK_USB, EP_ZERO, 0);
537 /* flush Tx FIFOs */
538 out_8(&usb->fhci->regs->usb_comm, USB_CMD_FLUSH_FIFO | EP_ZERO);
539 udelay(1000);
540 /* reset Tx BDs */
541 fhci_flush_bds(usb);
542 /* issue restart Tx command */
543 qe_issue_cmd(QE_USB_RESTART_TX, QE_CR_SUBBLOCK_USB, EP_ZERO, 0);
544 fhci_dbg(usb->fhci, "<- %s\n", __func__);
545}
546
547irqreturn_t fhci_irq(struct usb_hcd *hcd)
548{
549 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
550 struct fhci_usb *usb;
551 u16 usb_er = 0;
552 unsigned long flags;
553
554 spin_lock_irqsave(&fhci->lock, flags);
555
556 usb = fhci->usb_lld;
557
558 usb_er |= in_be16(&usb->fhci->regs->usb_event) &
559 in_be16(&usb->fhci->regs->usb_mask);
560
561 /* clear event bits for next time */
562 out_be16(&usb->fhci->regs->usb_event, usb_er);
563
564 fhci_dbg_isr(fhci, usb_er);
565
566 if (usb_er & USB_E_RESET_MASK) {
567 if ((usb->port_status == FHCI_PORT_FULL) ||
568 (usb->port_status == FHCI_PORT_LOW)) {
569 fhci_device_disconnected_interrupt(fhci);
570 usb_er &= ~USB_E_IDLE_MASK;
571 } else if (usb->port_status == FHCI_PORT_WAITING) {
572 usb->port_status = FHCI_PORT_DISCONNECTING;
573
574 /* Turn on IDLE since we want to disconnect */
575 usb->saved_msk |= USB_E_IDLE_MASK;
576 out_be16(&usb->fhci->regs->usb_event,
577 usb->saved_msk);
578 } else if (usb->port_status == FHCI_PORT_DISABLED) {
579 if (fhci_ioports_check_bus_state(fhci) == 1 &&
580 usb->port_status != FHCI_PORT_LOW &&
581 usb->port_status != FHCI_PORT_FULL)
582 fhci_device_connected_interrupt(fhci);
583 }
584 usb_er &= ~USB_E_RESET_MASK;
585 }
586
587 if (usb_er & USB_E_MSF_MASK) {
588 abort_transmission(fhci->usb_lld);
589 usb_er &= ~USB_E_MSF_MASK;
590 }
591
592 if (usb_er & (USB_E_SOF_MASK | USB_E_SFT_MASK)) {
593 sof_interrupt(fhci);
594 usb_er &= ~(USB_E_SOF_MASK | USB_E_SFT_MASK);
595 }
596
597 if (usb_er & USB_E_TXB_MASK) {
598 fhci_tx_conf_interrupt(fhci->usb_lld);
599 usb_er &= ~USB_E_TXB_MASK;
600 }
601
602 if (usb_er & USB_E_TXE1_MASK) {
603 fhci_tx_conf_interrupt(fhci->usb_lld);
604 usb_er &= ~USB_E_TXE1_MASK;
605 }
606
607 if (usb_er & USB_E_IDLE_MASK) {
608 if (usb->port_status == FHCI_PORT_DISABLED &&
609 usb->port_status != FHCI_PORT_LOW &&
610 usb->port_status != FHCI_PORT_FULL) {
611 usb_er &= ~USB_E_RESET_MASK;
612 fhci_device_connected_interrupt(fhci);
613 } else if (usb->port_status ==
614 FHCI_PORT_DISCONNECTING) {
615 /* XXX usb->port_status = FHCI_PORT_WAITING; */
616 /* Disable IDLE */
617 usb->saved_msk &= ~USB_E_IDLE_MASK;
618 out_be16(&usb->fhci->regs->usb_mask,
619 usb->saved_msk);
620 } else {
621 fhci_dbg_isr(fhci, -1);
622 }
623
624 usb_er &= ~USB_E_IDLE_MASK;
625 }
626
627 spin_unlock_irqrestore(&fhci->lock, flags);
628
629 return IRQ_HANDLED;
630}
631
632
633/*
634 * Process normal completions(error or sucess) and clean the schedule.
635 *
636 * This is the main path for handing urbs back to drivers. The only other patth
637 * is process_del_list(),which unlinks URBs by scanning EDs,instead of scanning
638 * the (re-reversed) done list as this does.
639 */
640static void process_done_list(unsigned long data)
641{
642 struct urb *urb;
643 struct ed *ed;
644 struct td *td;
645 struct urb_priv *urb_priv;
646 struct fhci_hcd *fhci = (struct fhci_hcd *)data;
647
648 disable_irq(fhci->timer->irq);
649 disable_irq(fhci_to_hcd(fhci)->irq);
650 spin_lock(&fhci->lock);
651
652 td = fhci_remove_td_from_done_list(fhci->hc_list);
653 while (td != NULL) {
654 urb = td->urb;
655 urb_priv = urb->hcpriv;
656 ed = td->ed;
657
658 /* update URB's length and status from TD */
659 fhci_done_td(urb, td);
660 urb_priv->tds_cnt++;
661
662 /*
663 * if all this urb's TDs are done, call complete()
664 * Interrupt transfers are the onley special case:
665 * they are reissued,until "deleted" by usb_unlink_urb
666 * (real work done in a SOF intr, by process_del_list)
667 */
668 if (urb_priv->tds_cnt == urb_priv->num_of_tds) {
669 fhci_urb_complete_free(fhci, urb);
670 } else if (urb_priv->state == URB_DEL &&
671 ed->state == FHCI_ED_SKIP) {
672 fhci_del_ed_list(fhci, ed);
673 ed->state = FHCI_ED_OPER;
674 } else if (ed->state == FHCI_ED_HALTED) {
675 urb_priv->state = URB_DEL;
676 ed->state = FHCI_ED_URB_DEL;
677 fhci_del_ed_list(fhci, ed);
678 ed->state = FHCI_ED_OPER;
679 }
680
681 td = fhci_remove_td_from_done_list(fhci->hc_list);
682 }
683
684 spin_unlock(&fhci->lock);
685 enable_irq(fhci->timer->irq);
686 enable_irq(fhci_to_hcd(fhci)->irq);
687}
688
689DECLARE_TASKLET(fhci_tasklet, process_done_list, 0);
690
691/* transfer complted callback */
692u32 fhci_transfer_confirm_callback(struct fhci_hcd *fhci)
693{
694 if (!fhci->process_done_task->state)
695 tasklet_schedule(fhci->process_done_task);
696 return 0;
697}
698
699/*
700 * adds urb to the endpoint descriptor list
701 * arguments:
702 * fhci data structure for the Low level host controller
703 * ep USB Host endpoint data structure
704 * urb USB request block data structure
705 */
706void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb)
707{
708 struct ed *ed = urb->ep->hcpriv;
709 struct urb_priv *urb_priv = urb->hcpriv;
710 u32 data_len = urb->transfer_buffer_length;
711 int urb_state = 0;
712 int toggle = 0;
713 struct td *td;
714 u8 *data;
715 u16 cnt = 0;
716
717 if (ed == NULL) {
718 ed = fhci_get_empty_ed(fhci);
719 ed->dev_addr = usb_pipedevice(urb->pipe);
720 ed->ep_addr = usb_pipeendpoint(urb->pipe);
721 switch (usb_pipetype(urb->pipe)) {
722 case PIPE_CONTROL:
723 ed->mode = FHCI_TF_CTRL;
724 break;
725 case PIPE_BULK:
726 ed->mode = FHCI_TF_BULK;
727 break;
728 case PIPE_INTERRUPT:
729 ed->mode = FHCI_TF_INTR;
730 break;
731 case PIPE_ISOCHRONOUS:
732 ed->mode = FHCI_TF_ISO;
733 break;
734 default:
735 break;
736 }
737 ed->speed = (urb->dev->speed == USB_SPEED_LOW) ?
738 FHCI_LOW_SPEED : FHCI_FULL_SPEED;
739 ed->max_pkt_size = usb_maxpacket(urb->dev,
740 urb->pipe, usb_pipeout(urb->pipe));
741 urb->ep->hcpriv = ed;
742 fhci_dbg(fhci, "new ep speed=%d max_pkt_size=%d\n",
743 ed->speed, ed->max_pkt_size);
744 }
745
746 /* for ISO transfer calculate start frame index */
747 if (ed->mode == FHCI_TF_ISO && urb->transfer_flags & URB_ISO_ASAP)
748 urb->start_frame = ed->td_head ? ed->last_iso + 1 :
749 get_frame_num(fhci);
750
751 /*
752 * OHCI handles the DATA toggle itself,we just use the USB
753 * toggle bits
754 */
755 if (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe),
756 usb_pipeout(urb->pipe)))
757 toggle = USB_TD_TOGGLE_CARRY;
758 else {
759 toggle = USB_TD_TOGGLE_DATA0;
760 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
761 usb_pipeout(urb->pipe), 1);
762 }
763
764 urb_priv->tds_cnt = 0;
765 urb_priv->ed = ed;
766 if (data_len > 0)
767 data = urb->transfer_buffer;
768 else
769 data = NULL;
770
771 switch (ed->mode) {
772 case FHCI_TF_BULK:
773 if (urb->transfer_flags & URB_ZERO_PACKET &&
774 urb->transfer_buffer_length > 0 &&
775 ((urb->transfer_buffer_length %
776 usb_maxpacket(urb->dev, urb->pipe,
777 usb_pipeout(urb->pipe))) == 0))
778 urb_state = US_BULK0;
779 while (data_len > 4096) {
780 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt,
781 usb_pipeout(urb->pipe) ? FHCI_TA_OUT :
782 FHCI_TA_IN,
783 cnt ? USB_TD_TOGGLE_CARRY :
784 toggle,
785 data, 4096, 0, 0, true);
786 data += 4096;
787 data_len -= 4096;
788 cnt++;
789 }
790
791 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt,
792 usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN,
793 cnt ? USB_TD_TOGGLE_CARRY : toggle,
794 data, data_len, 0, 0, true);
795 cnt++;
796
797 if (urb->transfer_flags & URB_ZERO_PACKET &&
798 cnt < urb_priv->num_of_tds) {
799 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt,
800 usb_pipeout(urb->pipe) ? FHCI_TA_OUT :
801 FHCI_TA_IN,
802 USB_TD_TOGGLE_CARRY, NULL, 0, 0, 0, true);
803 cnt++;
804 }
805 break;
806 case FHCI_TF_INTR:
807 urb->start_frame = get_frame_num(fhci) + 1;
808 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++,
809 usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN,
810 USB_TD_TOGGLE_DATA0, data, data_len,
811 urb->interval, urb->start_frame, true);
812 break;
813 case FHCI_TF_CTRL:
814 ed->dev_addr = usb_pipedevice(urb->pipe);
815 ed->max_pkt_size = usb_maxpacket(urb->dev, urb->pipe,
816 usb_pipeout(urb->pipe));
817 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, FHCI_TA_SETUP,
818 USB_TD_TOGGLE_DATA0, urb->setup_packet, 8, 0, 0, true);
819
820 if (data_len > 0) {
821 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++,
822 usb_pipeout(urb->pipe) ? FHCI_TA_OUT :
823 FHCI_TA_IN,
824 USB_TD_TOGGLE_DATA1, data, data_len, 0, 0,
825 true);
826 }
827 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++,
828 usb_pipeout(urb->pipe) ? FHCI_TA_IN : FHCI_TA_OUT,
829 USB_TD_TOGGLE_DATA1, data, 0, 0, 0, true);
830 urb_state = US_CTRL_SETUP;
831 break;
832 case FHCI_TF_ISO:
833 for (cnt = 0; cnt < urb->number_of_packets; cnt++) {
834 u16 frame = urb->start_frame;
835
836 /*
837 * FIXME scheduling should handle frame counter
838 * roll-around ... exotic case (and OHCI has
839 * a 2^16 iso range, vs other HCs max of 2^10)
840 */
841 frame += cnt * urb->interval;
842 frame &= 0x07ff;
843 td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt,
844 usb_pipeout(urb->pipe) ? FHCI_TA_OUT :
845 FHCI_TA_IN,
846 USB_TD_TOGGLE_DATA0,
847 data + urb->iso_frame_desc[cnt].offset,
848 urb->iso_frame_desc[cnt].length,
849 urb->interval, frame, true);
850 }
851 break;
852 default:
853 break;
854 }
855
856 /*
857 * set the state of URB
858 * control pipe:3 states -- setup,data,status
859 * interrupt and bulk pipe:1 state -- data
860 */
861 urb->pipe &= ~0x1f;
862 urb->pipe |= urb_state & 0x1f;
863
864 urb_priv->state = URB_INPROGRESS;
865
866 if (!ed->td_head) {
867 ed->state = FHCI_ED_OPER;
868 switch (ed->mode) {
869 case FHCI_TF_CTRL:
870 list_add(&ed->node, &fhci->hc_list->ctrl_list);
871 break;
872 case FHCI_TF_BULK:
873 list_add(&ed->node, &fhci->hc_list->bulk_list);
874 break;
875 case FHCI_TF_INTR:
876 list_add(&ed->node, &fhci->hc_list->intr_list);
877 break;
878 case FHCI_TF_ISO:
879 list_add(&ed->node, &fhci->hc_list->iso_list);
880 break;
881 default:
882 break;
883 }
884 }
885
886 fhci_add_tds_to_ed(ed, urb_priv->tds, urb_priv->num_of_tds);
887 fhci->active_urbs++;
888}
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
new file mode 100644
index 000000000000..b40332290319
--- /dev/null
+++ b/drivers/usb/host/fhci-tds.c
@@ -0,0 +1,626 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/types.h>
20#include <linux/errno.h>
21#include <linux/list.h>
22#include <linux/io.h>
23#include <linux/usb.h>
24#include "../core/hcd.h"
25#include "fhci.h"
26
27#define DUMMY_BD_BUFFER 0xdeadbeef
28#define DUMMY2_BD_BUFFER 0xbaadf00d
29
30/* Transaction Descriptors bits */
31#define TD_R 0x8000 /* ready bit */
32#define TD_W 0x2000 /* wrap bit */
33#define TD_I 0x1000 /* interrupt on completion */
34#define TD_L 0x0800 /* last */
35#define TD_TC 0x0400 /* transmit CRC */
36#define TD_CNF 0x0200 /* CNF - Must be always 1 */
37#define TD_LSP 0x0100 /* Low-speed transaction */
38#define TD_PID 0x00c0 /* packet id */
39#define TD_RXER 0x0020 /* Rx error or not */
40
41#define TD_NAK 0x0010 /* No ack. */
42#define TD_STAL 0x0008 /* Stall recieved */
43#define TD_TO 0x0004 /* time out */
44#define TD_UN 0x0002 /* underrun */
45#define TD_NO 0x0010 /* Rx Non Octet Aligned Packet */
46#define TD_AB 0x0008 /* Frame Aborted */
47#define TD_CR 0x0004 /* CRC Error */
48#define TD_OV 0x0002 /* Overrun */
49#define TD_BOV 0x0001 /* Buffer Overrun */
50
51#define TD_ERRORS (TD_NAK | TD_STAL | TD_TO | TD_UN | \
52 TD_NO | TD_AB | TD_CR | TD_OV | TD_BOV)
53
54#define TD_PID_DATA0 0x0080 /* Data 0 toggle */
55#define TD_PID_DATA1 0x00c0 /* Data 1 toggle */
56#define TD_PID_TOGGLE 0x00c0 /* Data 0/1 toggle mask */
57
58#define TD_TOK_SETUP 0x0000
59#define TD_TOK_OUT 0x4000
60#define TD_TOK_IN 0x8000
61#define TD_ISO 0x1000
62#define TD_ENDP 0x0780
63#define TD_ADDR 0x007f
64
65#define TD_ENDP_SHIFT 7
66
67struct usb_td {
68 __be16 status;
69 __be16 length;
70 __be32 buf_ptr;
71 __be16 extra;
72 __be16 reserved;
73};
74
75static struct usb_td __iomem *next_bd(struct usb_td __iomem *base,
76 struct usb_td __iomem *td,
77 u16 status)
78{
79 if (status & TD_W)
80 return base;
81 else
82 return ++td;
83}
84
85void fhci_push_dummy_bd(struct endpoint *ep)
86{
87 if (ep->already_pushed_dummy_bd == false) {
88 u16 td_status = in_be16(&ep->empty_td->status);
89
90 out_be32(&ep->empty_td->buf_ptr, DUMMY_BD_BUFFER);
91 /* get the next TD in the ring */
92 ep->empty_td = next_bd(ep->td_base, ep->empty_td, td_status);
93 ep->already_pushed_dummy_bd = true;
94 }
95}
96
97/* destroy an USB endpoint */
98void fhci_ep0_free(struct fhci_usb *usb)
99{
100 struct endpoint *ep;
101 int size;
102
103 ep = usb->ep0;
104 if (ep) {
105 if (ep->td_base)
106 cpm_muram_free(cpm_muram_offset(ep->td_base));
107
108 if (ep->conf_frame_Q) {
109 size = cq_howmany(ep->conf_frame_Q);
110 for (; size; size--) {
111 struct packet *pkt = cq_get(ep->conf_frame_Q);
112
113 kfree(pkt);
114 }
115 cq_delete(ep->conf_frame_Q);
116 }
117
118 if (ep->empty_frame_Q) {
119 size = cq_howmany(ep->empty_frame_Q);
120 for (; size; size--) {
121 struct packet *pkt = cq_get(ep->empty_frame_Q);
122
123 kfree(pkt);
124 }
125 cq_delete(ep->empty_frame_Q);
126 }
127
128 if (ep->dummy_packets_Q) {
129 size = cq_howmany(ep->dummy_packets_Q);
130 for (; size; size--) {
131 u8 *buff = cq_get(ep->dummy_packets_Q);
132
133 kfree(buff);
134 }
135 cq_delete(ep->dummy_packets_Q);
136 }
137
138 kfree(ep);
139 usb->ep0 = NULL;
140 }
141}
142
143/*
144 * create the endpoint structure
145 *
146 * arguments:
147 * usb A pointer to the data structure of the USB
148 * data_mem The data memory partition(BUS)
149 * ring_len TD ring length
150 */
151u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
152 u32 ring_len)
153{
154 struct endpoint *ep;
155 struct usb_td __iomem *td;
156 unsigned long ep_offset;
157 char *err_for = "enpoint PRAM";
158 int ep_mem_size;
159 u32 i;
160
161 /* we need at least 3 TDs in the ring */
162 if (!(ring_len > 2)) {
163 fhci_err(usb->fhci, "illegal TD ring length parameters\n");
164 return -EINVAL;
165 }
166
167 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
168 if (!ep)
169 return -ENOMEM;
170
171 ep_mem_size = ring_len * sizeof(*td) + sizeof(struct fhci_ep_pram);
172 ep_offset = cpm_muram_alloc(ep_mem_size, 32);
173 if (IS_ERR_VALUE(ep_offset))
174 goto err;
175 ep->td_base = cpm_muram_addr(ep_offset);
176
177 /* zero all queue pointers */
178 ep->conf_frame_Q = cq_new(ring_len + 2);
179 ep->empty_frame_Q = cq_new(ring_len + 2);
180 ep->dummy_packets_Q = cq_new(ring_len + 2);
181 if (!ep->conf_frame_Q || !ep->empty_frame_Q || !ep->dummy_packets_Q) {
182 err_for = "frame_queues";
183 goto err;
184 }
185
186 for (i = 0; i < (ring_len + 1); i++) {
187 struct packet *pkt;
188 u8 *buff;
189
190 pkt = kmalloc(sizeof(*pkt), GFP_KERNEL);
191 if (!pkt) {
192 err_for = "frame";
193 goto err;
194 }
195
196 buff = kmalloc(1028 * sizeof(*buff), GFP_KERNEL);
197 if (!buff) {
198 kfree(pkt);
199 err_for = "buffer";
200 goto err;
201 }
202 cq_put(ep->empty_frame_Q, pkt);
203 cq_put(ep->dummy_packets_Q, buff);
204 }
205
206 /* we put the endpoint parameter RAM right behind the TD ring */
207 ep->ep_pram_ptr = (void __iomem *)ep->td_base + sizeof(*td) * ring_len;
208
209 ep->conf_td = ep->td_base;
210 ep->empty_td = ep->td_base;
211
212 ep->already_pushed_dummy_bd = false;
213
214 /* initialize tds */
215 td = ep->td_base;
216 for (i = 0; i < ring_len; i++) {
217 out_be32(&td->buf_ptr, 0);
218 out_be16(&td->status, 0);
219 out_be16(&td->length, 0);
220 out_be16(&td->extra, 0);
221 td++;
222 }
223 td--;
224 out_be16(&td->status, TD_W); /* for last TD set Wrap bit */
225 out_be16(&td->length, 0);
226
227 /* endpoint structure has been created */
228 usb->ep0 = ep;
229
230 return 0;
231err:
232 fhci_ep0_free(usb);
233 kfree(ep);
234 fhci_err(usb->fhci, "no memory for the %s\n", err_for);
235 return -ENOMEM;
236}
237
238/*
239 * initialize the endpoint register according to the given parameters
240 *
241 * artuments:
242 * usb A pointer to the data strucutre of the USB
243 * ep A pointer to the endpoint structre
244 * data_mem The data memory partition(BUS)
245 */
246void fhci_init_ep_registers(struct fhci_usb *usb, struct endpoint *ep,
247 enum fhci_mem_alloc data_mem)
248{
249 u8 rt;
250
251 /* set the endpoint registers according to the endpoint */
252 out_be16(&usb->fhci->regs->usb_ep[0],
253 USB_TRANS_CTR | USB_EP_MF | USB_EP_RTE);
254 out_be16(&usb->fhci->pram->ep_ptr[0],
255 cpm_muram_offset(ep->ep_pram_ptr));
256
257 rt = (BUS_MODE_BO_BE | BUS_MODE_GBL);
258#ifdef MULTI_DATA_BUS
259 if (data_mem == MEM_SECONDARY)
260 rt |= BUS_MODE_DTB;
261#endif
262 out_8(&ep->ep_pram_ptr->rx_func_code, rt);
263 out_8(&ep->ep_pram_ptr->tx_func_code, rt);
264 out_be16(&ep->ep_pram_ptr->rx_buff_len, 1028);
265 out_be16(&ep->ep_pram_ptr->rx_base, 0);
266 out_be16(&ep->ep_pram_ptr->tx_base, cpm_muram_offset(ep->td_base));
267 out_be16(&ep->ep_pram_ptr->rx_bd_ptr, 0);
268 out_be16(&ep->ep_pram_ptr->tx_bd_ptr, cpm_muram_offset(ep->td_base));
269 out_be32(&ep->ep_pram_ptr->tx_state, 0);
270}
271
272/*
273 * Collect the submitted frames and inform the application about them
274 * It is also prepearing the TDs for new frames. If the Tx interrupts
275 * are diabled, the application should call that routine to get
276 * confirmation about the submitted frames. Otherwise, the routine is
277 * called frome the interrupt service routine during the Tx interrupt.
278 * In that case the application is informed by calling the application
279 * specific 'fhci_transaction_confirm' routine
280 */
281static void fhci_td_transaction_confirm(struct fhci_usb *usb)
282{
283 struct endpoint *ep = usb->ep0;
284 struct packet *pkt;
285 struct usb_td __iomem *td;
286 u16 extra_data;
287 u16 td_status;
288 u16 td_length;
289 u32 buf;
290
291 /*
292 * collect transmitted BDs from the chip. The routine clears all BDs
293 * with R bit = 0 and the pointer to data buffer is not NULL, that is
294 * BDs which point to the transmitted data buffer
295 */
296 while (1) {
297 td = ep->conf_td;
298 td_status = in_be16(&td->status);
299 td_length = in_be16(&td->length);
300 buf = in_be32(&td->buf_ptr);
301 extra_data = in_be16(&td->extra);
302
303 /* check if the TD is empty */
304 if (!(!(td_status & TD_R) && ((td_status & ~TD_W) || buf)))
305 break;
306 /* check if it is a dummy buffer */
307 else if ((buf == DUMMY_BD_BUFFER) && !(td_status & ~TD_W))
308 break;
309
310 /* mark TD as empty */
311 clrbits16(&td->status, ~TD_W);
312 out_be16(&td->length, 0);
313 out_be32(&td->buf_ptr, 0);
314 out_be16(&td->extra, 0);
315 /* advance the TD pointer */
316 ep->conf_td = next_bd(ep->td_base, ep->conf_td, td_status);
317
318 /* check if it is a dummy buffer(type2) */
319 if ((buf == DUMMY2_BD_BUFFER) && !(td_status & ~TD_W))
320 continue;
321
322 pkt = cq_get(ep->conf_frame_Q);
323 if (!pkt)
324 fhci_err(usb->fhci, "no frame to confirm\n");
325
326 if (td_status & TD_ERRORS) {
327 if (td_status & TD_RXER) {
328 if (td_status & TD_CR)
329 pkt->status = USB_TD_RX_ER_CRC;
330 else if (td_status & TD_AB)
331 pkt->status = USB_TD_RX_ER_BITSTUFF;
332 else if (td_status & TD_OV)
333 pkt->status = USB_TD_RX_ER_OVERUN;
334 else if (td_status & TD_BOV)
335 pkt->status = USB_TD_RX_DATA_OVERUN;
336 else if (td_status & TD_NO)
337 pkt->status = USB_TD_RX_ER_NONOCT;
338 else
339 fhci_err(usb->fhci, "illegal error "
340 "occured\n");
341 } else if (td_status & TD_NAK)
342 pkt->status = USB_TD_TX_ER_NAK;
343 else if (td_status & TD_TO)
344 pkt->status = USB_TD_TX_ER_TIMEOUT;
345 else if (td_status & TD_UN)
346 pkt->status = USB_TD_TX_ER_UNDERUN;
347 else if (td_status & TD_STAL)
348 pkt->status = USB_TD_TX_ER_STALL;
349 else
350 fhci_err(usb->fhci, "illegal error occured\n");
351 } else if ((extra_data & TD_TOK_IN) &&
352 pkt->len > td_length - CRC_SIZE) {
353 pkt->status = USB_TD_RX_DATA_UNDERUN;
354 }
355
356 if (extra_data & TD_TOK_IN)
357 pkt->len = td_length - CRC_SIZE;
358 else if (pkt->info & PKT_ZLP)
359 pkt->len = 0;
360 else
361 pkt->len = td_length;
362
363 fhci_transaction_confirm(usb, pkt);
364 }
365}
366
367/*
368 * Submitting a data frame to a specified endpoint of a USB device
369 * The frame is put in the driver's transmit queue for this endpoint
370 *
371 * Arguments:
372 * usb A pointer to the USB structure
373 * pkt A pointer to the user frame structure
374 * trans_type Transaction tyep - IN,OUT or SETUP
375 * dest_addr Device address - 0~127
376 * dest_ep Endpoint number of the device - 0~16
377 * trans_mode Pipe type - ISO,Interrupt,bulk or control
378 * dest_speed USB speed - Low speed or FULL speed
379 * data_toggle Data sequence toggle - 0 or 1
380 */
381u32 fhci_host_transaction(struct fhci_usb *usb,
382 struct packet *pkt,
383 enum fhci_ta_type trans_type,
384 u8 dest_addr,
385 u8 dest_ep,
386 enum fhci_tf_mode trans_mode,
387 enum fhci_speed dest_speed, u8 data_toggle)
388{
389 struct endpoint *ep = usb->ep0;
390 struct usb_td __iomem *td;
391 u16 extra_data;
392 u16 td_status;
393
394 fhci_usb_disable_interrupt(usb);
395 /* start from the next BD that should be filled */
396 td = ep->empty_td;
397 td_status = in_be16(&td->status);
398
399 if (td_status & TD_R && in_be16(&td->length)) {
400 /* if the TD is not free */
401 fhci_usb_enable_interrupt(usb);
402 return -1;
403 }
404
405 /* get the next TD in the ring */
406 ep->empty_td = next_bd(ep->td_base, ep->empty_td, td_status);
407 fhci_usb_enable_interrupt(usb);
408 pkt->priv_data = td;
409 out_be32(&td->buf_ptr, virt_to_phys(pkt->data));
410 /* sets up transaction parameters - addr,endp,dir,and type */
411 extra_data = (dest_ep << TD_ENDP_SHIFT) | dest_addr;
412 switch (trans_type) {
413 case FHCI_TA_IN:
414 extra_data |= TD_TOK_IN;
415 break;
416 case FHCI_TA_OUT:
417 extra_data |= TD_TOK_OUT;
418 break;
419 case FHCI_TA_SETUP:
420 extra_data |= TD_TOK_SETUP;
421 break;
422 }
423 if (trans_mode == FHCI_TF_ISO)
424 extra_data |= TD_ISO;
425 out_be16(&td->extra, extra_data);
426
427 /* sets up the buffer descriptor */
428 td_status = ((td_status & TD_W) | TD_R | TD_L | TD_I | TD_CNF);
429 if (!(pkt->info & PKT_NO_CRC))
430 td_status |= TD_TC;
431
432 switch (trans_type) {
433 case FHCI_TA_IN:
434 if (data_toggle)
435 pkt->info |= PKT_PID_DATA1;
436 else
437 pkt->info |= PKT_PID_DATA0;
438 break;
439 default:
440 if (data_toggle) {
441 td_status |= TD_PID_DATA1;
442 pkt->info |= PKT_PID_DATA1;
443 } else {
444 td_status |= TD_PID_DATA0;
445 pkt->info |= PKT_PID_DATA0;
446 }
447 break;
448 }
449
450 if ((dest_speed == FHCI_LOW_SPEED) &&
451 (usb->port_status == FHCI_PORT_FULL))
452 td_status |= TD_LSP;
453
454 out_be16(&td->status, td_status);
455
456 /* set up buffer length */
457 if (trans_type == FHCI_TA_IN)
458 out_be16(&td->length, pkt->len + CRC_SIZE);
459 else
460 out_be16(&td->length, pkt->len);
461
462 /* put the frame to the confirmation queue */
463 cq_put(ep->conf_frame_Q, pkt);
464
465 if (cq_howmany(ep->conf_frame_Q) == 1)
466 out_8(&usb->fhci->regs->usb_comm, USB_CMD_STR_FIFO);
467
468 return 0;
469}
470
471/* Reset the Tx BD ring */
472void fhci_flush_bds(struct fhci_usb *usb)
473{
474 u16 extra_data;
475 u16 td_status;
476 u32 buf;
477 struct usb_td __iomem *td;
478 struct endpoint *ep = usb->ep0;
479
480 td = ep->td_base;
481 while (1) {
482 td_status = in_be16(&td->status);
483 buf = in_be32(&td->buf_ptr);
484 extra_data = in_be16(&td->extra);
485
486 /* if the TD is not empty - we'll confirm it as Timeout */
487 if (td_status & TD_R)
488 out_be16(&td->status, (td_status & ~TD_R) | TD_TO);
489 /* if this TD is dummy - let's skip this TD */
490 else if (in_be32(&td->buf_ptr) == DUMMY_BD_BUFFER)
491 out_be32(&td->buf_ptr, DUMMY2_BD_BUFFER);
492 /* if this is the last TD - break */
493 if (td_status & TD_W)
494 break;
495
496 td++;
497 }
498
499 fhci_td_transaction_confirm(usb);
500
501 td = ep->td_base;
502 do {
503 out_be16(&td->status, 0);
504 out_be16(&td->length, 0);
505 out_be32(&td->buf_ptr, 0);
506 out_be16(&td->extra, 0);
507 td++;
508 } while (!(in_be16(&td->status) & TD_W));
509 out_be16(&td->status, TD_W); /* for last TD set Wrap bit */
510 out_be16(&td->length, 0);
511 out_be32(&td->buf_ptr, 0);
512 out_be16(&td->extra, 0);
513
514 out_be16(&ep->ep_pram_ptr->tx_bd_ptr,
515 in_be16(&ep->ep_pram_ptr->tx_base));
516 out_be32(&ep->ep_pram_ptr->tx_state, 0);
517 out_be16(&ep->ep_pram_ptr->tx_cnt, 0);
518 ep->empty_td = ep->td_base;
519 ep->conf_td = ep->td_base;
520}
521
522/*
523 * Flush all transmitted packets from TDs in the actual frame.
524 * This routine is called when something wrong with the controller and
525 * we want to get rid of the actual frame and start again next frame
526 */
527void fhci_flush_actual_frame(struct fhci_usb *usb)
528{
529 u8 mode;
530 u16 tb_ptr;
531 u16 extra_data;
532 u16 td_status;
533 u32 buf_ptr;
534 struct usb_td __iomem *td;
535 struct endpoint *ep = usb->ep0;
536
537 /* disable the USB controller */
538 mode = in_8(&usb->fhci->regs->usb_mod);
539 out_8(&usb->fhci->regs->usb_mod, mode & ~USB_MODE_EN);
540
541 tb_ptr = in_be16(&ep->ep_pram_ptr->tx_bd_ptr);
542 td = cpm_muram_addr(tb_ptr);
543 td_status = in_be16(&td->status);
544 buf_ptr = in_be32(&td->buf_ptr);
545 extra_data = in_be16(&td->extra);
546 do {
547 if (td_status & TD_R) {
548 out_be16(&td->status, (td_status & ~TD_R) | TD_TO);
549 } else {
550 out_be32(&td->buf_ptr, 0);
551 ep->already_pushed_dummy_bd = false;
552 break;
553 }
554
555 /* advance the TD pointer */
556 td = next_bd(ep->td_base, td, td_status);
557 td_status = in_be16(&td->status);
558 buf_ptr = in_be32(&td->buf_ptr);
559 extra_data = in_be16(&td->extra);
560 } while ((td_status & TD_R) || buf_ptr);
561
562 fhci_td_transaction_confirm(usb);
563
564 out_be16(&ep->ep_pram_ptr->tx_bd_ptr,
565 in_be16(&ep->ep_pram_ptr->tx_base));
566 out_be32(&ep->ep_pram_ptr->tx_state, 0);
567 out_be16(&ep->ep_pram_ptr->tx_cnt, 0);
568 ep->empty_td = ep->td_base;
569 ep->conf_td = ep->td_base;
570
571 usb->actual_frame->frame_status = FRAME_TIMER_END_TRANSMISSION;
572
573 /* reset the event register */
574 out_be16(&usb->fhci->regs->usb_event, 0xffff);
575 /* enable the USB controller */
576 out_8(&usb->fhci->regs->usb_mod, mode | USB_MODE_EN);
577}
578
579/* handles Tx confirm and Tx error interrupt */
580void fhci_tx_conf_interrupt(struct fhci_usb *usb)
581{
582 fhci_td_transaction_confirm(usb);
583
584 /*
585 * Schedule another transaction to this frame only if we have
586 * already confirmed all transaction in the frame.
587 */
588 if (((fhci_get_sof_timer_count(usb) < usb->max_frame_usage) ||
589 (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION)) &&
590 (list_empty(&usb->actual_frame->tds_list)))
591 fhci_schedule_transactions(usb);
592}
593
594void fhci_host_transmit_actual_frame(struct fhci_usb *usb)
595{
596 u16 tb_ptr;
597 u16 td_status;
598 struct usb_td __iomem *td;
599 struct endpoint *ep = usb->ep0;
600
601 tb_ptr = in_be16(&ep->ep_pram_ptr->tx_bd_ptr);
602 td = cpm_muram_addr(tb_ptr);
603
604 if (in_be32(&td->buf_ptr) == DUMMY_BD_BUFFER) {
605 struct usb_td __iomem *old_td = td;
606
607 ep->already_pushed_dummy_bd = false;
608 td_status = in_be16(&td->status);
609 /* gets the next TD in the ring */
610 td = next_bd(ep->td_base, td, td_status);
611 tb_ptr = cpm_muram_offset(td);
612 out_be16(&ep->ep_pram_ptr->tx_bd_ptr, tb_ptr);
613
614 /* start transmit only if we have something in the TDs */
615 if (in_be16(&td->status) & TD_R)
616 out_8(&usb->fhci->regs->usb_comm, USB_CMD_STR_FIFO);
617
618 if (in_be32(&ep->conf_td->buf_ptr) == DUMMY_BD_BUFFER) {
619 out_be32(&old_td->buf_ptr, 0);
620 ep->conf_td = next_bd(ep->td_base, ep->conf_td,
621 td_status);
622 } else {
623 out_be32(&old_td->buf_ptr, DUMMY2_BD_BUFFER);
624 }
625 }
626}
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
new file mode 100644
index 000000000000..7116284ed21a
--- /dev/null
+++ b/drivers/usb/host/fhci.h
@@ -0,0 +1,607 @@
1/*
2 * Freescale QUICC Engine USB Host Controller Driver
3 *
4 * Copyright (c) Freescale Semicondutor, Inc. 2006.
5 * Shlomi Gridish <gridish@freescale.com>
6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
7 * Copyright (c) Logic Product Development, Inc. 2007
8 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#ifndef __FHCI_H
19#define __FHCI_H
20
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/spinlock.h>
24#include <linux/interrupt.h>
25#include <linux/kfifo.h>
26#include <linux/io.h>
27#include <linux/usb.h>
28#include <asm/qe.h>
29#include "../core/hcd.h"
30
31#define USB_CLOCK 48000000
32
33#define FHCI_PRAM_SIZE 0x100
34
35#define MAX_EDS 32
36#define MAX_TDS 32
37
38
39/* CRC16 field size */
40#define CRC_SIZE 2
41
42/* USB protocol overhead for each frame transmitted from the host */
43#define PROTOCOL_OVERHEAD 7
44
45/* Packet structure, info field */
46#define PKT_PID_DATA0 0x80000000 /* PID - Data toggle zero */
47#define PKT_PID_DATA1 0x40000000 /* PID - Data toggle one */
48#define PKT_PID_SETUP 0x20000000 /* PID - Setup bit */
49#define PKT_SETUP_STATUS 0x10000000 /* Setup status bit */
50#define PKT_SETADDR_STATUS 0x08000000 /* Set address status bit */
51#define PKT_SET_HOST_LAST 0x04000000 /* Last data packet */
52#define PKT_HOST_DATA 0x02000000 /* Data packet */
53#define PKT_FIRST_IN_FRAME 0x01000000 /* First packet in the frame */
54#define PKT_TOKEN_FRAME 0x00800000 /* Token packet */
55#define PKT_ZLP 0x00400000 /* Zero length packet */
56#define PKT_IN_TOKEN_FRAME 0x00200000 /* IN token packet */
57#define PKT_OUT_TOKEN_FRAME 0x00100000 /* OUT token packet */
58#define PKT_SETUP_TOKEN_FRAME 0x00080000 /* SETUP token packet */
59#define PKT_STALL_FRAME 0x00040000 /* STALL packet */
60#define PKT_NACK_FRAME 0x00020000 /* NACK packet */
61#define PKT_NO_PID 0x00010000 /* No PID */
62#define PKT_NO_CRC 0x00008000 /* don't append CRC */
63#define PKT_HOST_COMMAND 0x00004000 /* Host command packet */
64#define PKT_DUMMY_PACKET 0x00002000 /* Dummy packet, used for mmm */
65#define PKT_LOW_SPEED_PACKET 0x00001000 /* Low-Speed packet */
66
67#define TRANS_OK (0)
68#define TRANS_INPROGRESS (-1)
69#define TRANS_DISCARD (-2)
70#define TRANS_FAIL (-3)
71
72#define PS_INT 0
73#define PS_DISCONNECTED 1
74#define PS_CONNECTED 2
75#define PS_READY 3
76#define PS_MISSING 4
77
78/* Transfer Descriptor status field */
79#define USB_TD_OK 0x00000000 /* TD transmited or received ok */
80#define USB_TD_INPROGRESS 0x80000000 /* TD is being transmitted */
81#define USB_TD_RX_ER_NONOCT 0x40000000 /* Tx Non Octet Aligned Packet */
82#define USB_TD_RX_ER_BITSTUFF 0x20000000 /* Frame Aborted-Received pkt */
83#define USB_TD_RX_ER_CRC 0x10000000 /* CRC error */
84#define USB_TD_RX_ER_OVERUN 0x08000000 /* Over - run occured */
85#define USB_TD_RX_ER_PID 0x04000000 /* wrong PID received */
86#define USB_TD_RX_DATA_UNDERUN 0x02000000 /* shorter than expected */
87#define USB_TD_RX_DATA_OVERUN 0x01000000 /* longer than expected */
88#define USB_TD_TX_ER_NAK 0x00800000 /* NAK handshake */
89#define USB_TD_TX_ER_STALL 0x00400000 /* STALL handshake */
90#define USB_TD_TX_ER_TIMEOUT 0x00200000 /* transmit time out */
91#define USB_TD_TX_ER_UNDERUN 0x00100000 /* transmit underrun */
92
93#define USB_TD_ERROR (USB_TD_RX_ER_NONOCT | USB_TD_RX_ER_BITSTUFF | \
94 USB_TD_RX_ER_CRC | USB_TD_RX_ER_OVERUN | USB_TD_RX_ER_PID | \
95 USB_TD_RX_DATA_UNDERUN | USB_TD_RX_DATA_OVERUN | \
96 USB_TD_TX_ER_NAK | USB_TD_TX_ER_STALL | \
97 USB_TD_TX_ER_TIMEOUT | USB_TD_TX_ER_UNDERUN)
98
99/* Transfer Descriptor toggle field */
100#define USB_TD_TOGGLE_DATA0 0
101#define USB_TD_TOGGLE_DATA1 1
102#define USB_TD_TOGGLE_CARRY 2
103
104/* #define MULTI_DATA_BUS */
105
106/* Bus mode register RBMR/TBMR */
107#define BUS_MODE_GBL 0x20 /* Global snooping */
108#define BUS_MODE_BO 0x18 /* Byte ordering */
109#define BUS_MODE_BO_BE 0x10 /* Byte ordering - Big-endian */
110#define BUS_MODE_DTB 0x02 /* Data bus */
111
112/* FHCI QE USB Register Description */
113
114/* USB Mode Register bit define */
115#define USB_MODE_EN 0x01
116#define USB_MODE_HOST 0x02
117#define USB_MODE_TEST 0x04
118#define USB_MODE_SFTE 0x08
119#define USB_MODE_RESUME 0x40
120#define USB_MODE_LSS 0x80
121
122/* USB Slave Address Register Mask */
123#define USB_SLVADDR_MASK 0x7F
124
125/* USB Endpoint register define */
126#define USB_EPNUM_MASK 0xF000
127#define USB_EPNUM_SHIFT 12
128
129#define USB_TRANS_MODE_SHIFT 8
130#define USB_TRANS_CTR 0x0000
131#define USB_TRANS_INT 0x0100
132#define USB_TRANS_BULK 0x0200
133#define USB_TRANS_ISO 0x0300
134
135#define USB_EP_MF 0x0020
136#define USB_EP_RTE 0x0010
137
138#define USB_THS_SHIFT 2
139#define USB_THS_MASK 0x000c
140#define USB_THS_NORMAL 0x0
141#define USB_THS_IGNORE_IN 0x0004
142#define USB_THS_NACK 0x0008
143#define USB_THS_STALL 0x000c
144
145#define USB_RHS_SHIFT 0
146#define USB_RHS_MASK 0x0003
147#define USB_RHS_NORMAL 0x0
148#define USB_RHS_IGNORE_OUT 0x0001
149#define USB_RHS_NACK 0x0002
150#define USB_RHS_STALL 0x0003
151
152#define USB_RTHS_MASK 0x000f
153
154/* USB Command Register define */
155#define USB_CMD_STR_FIFO 0x80
156#define USB_CMD_FLUSH_FIFO 0x40
157#define USB_CMD_ISFT 0x20
158#define USB_CMD_DSFT 0x10
159#define USB_CMD_EP_MASK 0x03
160
161/* USB Event and Mask Register define */
162#define USB_E_MSF_MASK 0x0800
163#define USB_E_SFT_MASK 0x0400
164#define USB_E_RESET_MASK 0x0200
165#define USB_E_IDLE_MASK 0x0100
166#define USB_E_TXE4_MASK 0x0080
167#define USB_E_TXE3_MASK 0x0040
168#define USB_E_TXE2_MASK 0x0020
169#define USB_E_TXE1_MASK 0x0010
170#define USB_E_SOF_MASK 0x0008
171#define USB_E_BSY_MASK 0x0004
172#define USB_E_TXB_MASK 0x0002
173#define USB_E_RXB_MASK 0x0001
174
175/* Freescale USB Host controller registers */
176struct fhci_regs {
177 u8 usb_mod; /* mode register */
178 u8 usb_addr; /* address register */
179 u8 usb_comm; /* command register */
180 u8 reserved1[1];
181 __be16 usb_ep[4]; /* endpoint register */
182 u8 reserved2[4];
183 __be16 usb_event; /* event register */
184 u8 reserved3[2];
185 __be16 usb_mask; /* mask register */
186 u8 reserved4[1];
187 u8 usb_status; /* status register */
188 __be16 usb_sof_tmr; /* Start Of Frame timer */
189 u8 reserved5[2];
190 __be16 usb_frame_num; /* frame number register */
191 u8 reserved6[1];
192};
193
194/* Freescale USB HOST */
195struct fhci_pram {
196 __be16 ep_ptr[4]; /* Endpoint porter reg */
197 __be32 rx_state; /* Rx internal state */
198 __be32 rx_ptr; /* Rx internal data pointer */
199 __be16 frame_num; /* Frame number */
200 __be16 rx_cnt; /* Rx byte count */
201 __be32 rx_temp; /* Rx temp */
202 __be32 rx_data_temp; /* Rx data temp */
203 __be16 rx_u_ptr; /* Rx microcode return address temp */
204 u8 reserved1[2]; /* reserved area */
205 __be32 sof_tbl; /* SOF lookup table pointer */
206 u8 sof_u_crc_temp; /* SOF micorcode CRC5 temp reg */
207 u8 reserved2[0xdb];
208};
209
210/* Freescale USB Endpoint*/
211struct fhci_ep_pram {
212 __be16 rx_base; /* Rx BD base address */
213 __be16 tx_base; /* Tx BD base address */
214 u8 rx_func_code; /* Rx function code */
215 u8 tx_func_code; /* Tx function code */
216 __be16 rx_buff_len; /* Rx buffer length */
217 __be16 rx_bd_ptr; /* Rx BD pointer */
218 __be16 tx_bd_ptr; /* Tx BD pointer */
219 __be32 tx_state; /* Tx internal state */
220 __be32 tx_ptr; /* Tx internal data pointer */
221 __be16 tx_crc; /* temp transmit CRC */
222 __be16 tx_cnt; /* Tx byte count */
223 __be32 tx_temp; /* Tx temp */
224 __be16 tx_u_ptr; /* Tx microcode return address temp */
225 __be16 reserved;
226};
227
228struct fhci_controller_list {
229 struct list_head ctrl_list; /* control endpoints */
230 struct list_head bulk_list; /* bulk endpoints */
231 struct list_head iso_list; /* isochronous endpoints */
232 struct list_head intr_list; /* interruput endpoints */
233 struct list_head done_list; /* done transfers */
234};
235
236struct virtual_root_hub {
237 int dev_num; /* USB address of the root hub */
238 u32 feature; /* indicates what feature has been set */
239 struct usb_hub_status hub;
240 struct usb_port_status port;
241};
242
243enum fhci_gpios {
244 GPIO_USBOE = 0,
245 GPIO_USBTP,
246 GPIO_USBTN,
247 GPIO_USBRP,
248 GPIO_USBRN,
249 /* these are optional */
250 GPIO_SPEED,
251 GPIO_POWER,
252 NUM_GPIOS,
253};
254
255enum fhci_pins {
256 PIN_USBOE = 0,
257 PIN_USBTP,
258 PIN_USBTN,
259 NUM_PINS,
260};
261
262struct fhci_hcd {
263 enum qe_clock fullspeed_clk;
264 enum qe_clock lowspeed_clk;
265 struct qe_pin *pins[NUM_PINS];
266 int gpios[NUM_GPIOS];
267 bool alow_gpios[NUM_GPIOS];
268
269 struct fhci_regs __iomem *regs; /* I/O memory used to communicate */
270 struct fhci_pram __iomem *pram; /* Parameter RAM */
271 struct gtm_timer *timer;
272
273 spinlock_t lock;
274 struct fhci_usb *usb_lld; /* Low-level driver */
275 struct virtual_root_hub *vroot_hub; /* the virtual root hub */
276 int active_urbs;
277 struct fhci_controller_list *hc_list;
278 struct tasklet_struct *process_done_task; /* tasklet for done list */
279
280 struct list_head empty_eds;
281 struct list_head empty_tds;
282
283#ifdef CONFIG_FHCI_DEBUG
284 int usb_irq_stat[13];
285 struct dentry *dfs_root;
286 struct dentry *dfs_regs;
287 struct dentry *dfs_irq_stat;
288#endif
289};
290
291#define USB_FRAME_USAGE 90
292#define FRAME_TIME_USAGE (USB_FRAME_USAGE*10) /* frame time usage */
293#define SW_FIX_TIME_BETWEEN_TRANSACTION 150 /* SW */
294#define MAX_BYTES_PER_FRAME (USB_FRAME_USAGE*15)
295#define MAX_PERIODIC_FRAME_USAGE 90
296
297/* transaction type */
298enum fhci_ta_type {
299 FHCI_TA_IN = 0, /* input transaction */
300 FHCI_TA_OUT, /* output transaction */
301 FHCI_TA_SETUP, /* setup transaction */
302};
303
304/* transfer mode */
305enum fhci_tf_mode {
306 FHCI_TF_CTRL = 0,
307 FHCI_TF_ISO,
308 FHCI_TF_BULK,
309 FHCI_TF_INTR,
310};
311
312enum fhci_speed {
313 FHCI_FULL_SPEED,
314 FHCI_LOW_SPEED,
315};
316
317/* endpoint state */
318enum fhci_ed_state {
319 FHCI_ED_NEW = 0, /* pipe is new */
320 FHCI_ED_OPER, /* pipe is operating */
321 FHCI_ED_URB_DEL, /* pipe is in hold because urb is being deleted */
322 FHCI_ED_SKIP, /* skip this pipe */
323 FHCI_ED_HALTED, /* pipe is halted */
324};
325
326enum fhci_port_status {
327 FHCI_PORT_POWER_OFF = 0,
328 FHCI_PORT_DISABLED,
329 FHCI_PORT_DISCONNECTING,
330 FHCI_PORT_WAITING, /* waiting for connection */
331 FHCI_PORT_FULL, /* full speed connected */
332 FHCI_PORT_LOW, /* low speed connected */
333};
334
335enum fhci_mem_alloc {
336 MEM_CACHABLE_SYS = 0x00000001, /* primary DDR,cachable */
337 MEM_NOCACHE_SYS = 0x00000004, /* primary DDR,non-cachable */
338 MEM_SECONDARY = 0x00000002, /* either secondary DDR or SDRAM */
339 MEM_PRAM = 0x00000008, /* multi-user RAM identifier */
340};
341
342/* USB default parameters*/
343#define DEFAULT_RING_LEN 8
344#define DEFAULT_DATA_MEM MEM_CACHABLE_SYS
345
346struct ed {
347 u8 dev_addr; /* device address */
348 u8 ep_addr; /* endpoint address */
349 enum fhci_tf_mode mode; /* USB transfer mode */
350 enum fhci_speed speed;
351 unsigned int max_pkt_size;
352 enum fhci_ed_state state;
353 struct list_head td_list; /* a list of all queued TD to this pipe */
354 struct list_head node;
355
356 /* read only parameters, should be cleared upon initialization */
357 u8 toggle_carry; /* toggle carry from the last TD submitted */
358 u32 last_iso; /* time stamp of last queued ISO transfer */
359 struct td *td_head; /* a pointer to the current TD handled */
360};
361
362struct td {
363 void *data; /* a pointer to the data buffer */
364 unsigned int len; /* length of the data to be submitted */
365 unsigned int actual_len; /* actual bytes transfered on this td */
366 enum fhci_ta_type type; /* transaction type */
367 u8 toggle; /* toggle for next trans. within this TD */
368 u16 iso_index; /* ISO transaction index */
369 u16 start_frame; /* start frame time stamp */
370 u16 interval; /* interval between trans. (for ISO/Intr) */
371 u32 status; /* status of the TD */
372 struct ed *ed; /* a handle to the corresponding ED */
373 struct urb *urb; /* a handle to the corresponding URB */
374 bool ioc; /* Inform On Completion */
375 struct list_head node;
376
377 /* read only parameters should be cleared upon initialization */
378 struct packet *pkt;
379 int nak_cnt;
380 int error_cnt;
381 struct list_head frame_lh;
382};
383
384struct packet {
385 u8 *data; /* packet data */
386 u32 len; /* packet length */
387 u32 status; /* status of the packet - equivalent to the status
388 * field for the corresponding structure td */
389 u32 info; /* packet information */
390 void __iomem *priv_data; /* private data of the driver (TDs or BDs) */
391};
392
393/* struct for each URB */
394#define URB_INPROGRESS 0
395#define URB_DEL 1
396
397/* URB states (state field) */
398#define US_BULK 0
399#define US_BULK0 1
400
401/* three setup states */
402#define US_CTRL_SETUP 2
403#define US_CTRL_DATA 1
404#define US_CTRL_ACK 0
405
406#define EP_ZERO 0
407
408struct urb_priv {
409 int num_of_tds;
410 int tds_cnt;
411 int state;
412
413 struct td **tds;
414 struct ed *ed;
415 struct timer_list time_out;
416};
417
418struct endpoint {
419 /* Pointer to ep parameter RAM */
420 struct fhci_ep_pram __iomem *ep_pram_ptr;
421
422 /* Host transactions */
423 struct usb_td __iomem *td_base; /* first TD in the ring */
424 struct usb_td __iomem *conf_td; /* next TD for confirm after transac */
425 struct usb_td __iomem *empty_td;/* next TD for new transaction req. */
426 struct kfifo *empty_frame_Q; /* Empty frames list to use */
427 struct kfifo *conf_frame_Q; /* frames passed to TDs,waiting for tx */
428 struct kfifo *dummy_packets_Q;/* dummy packets for the CRC overun */
429
430 bool already_pushed_dummy_bd;
431};
432
433/* struct for each 1mSec frame time */
434#define FRAME_IS_TRANSMITTED 0x00
435#define FRAME_TIMER_END_TRANSMISSION 0x01
436#define FRAME_DATA_END_TRANSMISSION 0x02
437#define FRAME_END_TRANSMISSION 0x03
438#define FRAME_IS_PREPARED 0x04
439
440struct fhci_time_frame {
441 u16 frame_num; /* frame number */
442 u16 total_bytes; /* total bytes submitted within this frame */
443 u8 frame_status; /* flag that indicates to stop fill this frame */
444 struct list_head tds_list; /* all tds of this frame */
445};
446
447/* internal driver structure*/
448struct fhci_usb {
449 u16 saved_msk; /* saving of the USB mask register */
450 struct endpoint *ep0; /* pointer for endpoint0 structure */
451 int intr_nesting_cnt; /* interrupt nesting counter */
452 u16 max_frame_usage; /* max frame time usage,in micro-sec */
453 u16 max_bytes_per_frame; /* max byte can be tx in one time frame */
454 u32 sw_transaction_time; /* sw complete trans time,in micro-sec */
455 struct fhci_time_frame *actual_frame;
456 struct fhci_controller_list *hc_list; /* main structure for hc */
457 struct virtual_root_hub *vroot_hub;
458 enum fhci_port_status port_status; /* v_rh port status */
459
460 u32 (*transfer_confirm)(struct fhci_hcd *fhci);
461
462 struct fhci_hcd *fhci;
463};
464
465/*
466 * Various helpers and prototypes below.
467 */
468
469static inline u16 get_frame_num(struct fhci_hcd *fhci)
470{
471 return in_be16(&fhci->pram->frame_num) & 0x07ff;
472}
473
474#define fhci_dbg(fhci, fmt, args...) \
475 dev_dbg(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
476#define fhci_vdbg(fhci, fmt, args...) \
477 dev_vdbg(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
478#define fhci_err(fhci, fmt, args...) \
479 dev_err(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
480#define fhci_info(fhci, fmt, args...) \
481 dev_info(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
482#define fhci_warn(fhci, fmt, args...) \
483 dev_warn(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
484
485static inline struct fhci_hcd *hcd_to_fhci(struct usb_hcd *hcd)
486{
487 return (struct fhci_hcd *)hcd->hcd_priv;
488}
489
490static inline struct usb_hcd *fhci_to_hcd(struct fhci_hcd *fhci)
491{
492 return container_of((void *)fhci, struct usb_hcd, hcd_priv);
493}
494
495/* fifo of pointers */
496static inline struct kfifo *cq_new(int size)
497{
498 return kfifo_alloc(size * sizeof(void *), GFP_KERNEL, NULL);
499}
500
501static inline void cq_delete(struct kfifo *kfifo)
502{
503 kfifo_free(kfifo);
504}
505
506static inline unsigned int cq_howmany(struct kfifo *kfifo)
507{
508 return __kfifo_len(kfifo) / sizeof(void *);
509}
510
511static inline int cq_put(struct kfifo *kfifo, void *p)
512{
513 return __kfifo_put(kfifo, (void *)&p, sizeof(p));
514}
515
516static inline void *cq_get(struct kfifo *kfifo)
517{
518 void *p = NULL;
519
520 __kfifo_get(kfifo, (void *)&p, sizeof(p));
521 return p;
522}
523
524/* fhci-hcd.c */
525void fhci_start_sof_timer(struct fhci_hcd *fhci);
526void fhci_stop_sof_timer(struct fhci_hcd *fhci);
527u16 fhci_get_sof_timer_count(struct fhci_usb *usb);
528void fhci_usb_enable_interrupt(struct fhci_usb *usb);
529void fhci_usb_disable_interrupt(struct fhci_usb *usb);
530int fhci_ioports_check_bus_state(struct fhci_hcd *fhci);
531
532/* fhci-mem.c */
533void fhci_recycle_empty_td(struct fhci_hcd *fhci, struct td *td);
534void fhci_recycle_empty_ed(struct fhci_hcd *fhci, struct ed *ed);
535struct ed *fhci_get_empty_ed(struct fhci_hcd *fhci);
536struct td *fhci_td_fill(struct fhci_hcd *fhci, struct urb *urb,
537 struct urb_priv *urb_priv, struct ed *ed, u16 index,
538 enum fhci_ta_type type, int toggle, u8 *data, u32 len,
539 u16 interval, u16 start_frame, bool ioc);
540void fhci_add_tds_to_ed(struct ed *ed, struct td **td_list, int number);
541
542/* fhci-hub.c */
543void fhci_config_transceiver(struct fhci_hcd *fhci,
544 enum fhci_port_status status);
545void fhci_port_disable(struct fhci_hcd *fhci);
546void fhci_port_enable(void *lld);
547void fhci_io_port_generate_reset(struct fhci_hcd *fhci);
548void fhci_port_reset(void *lld);
549int fhci_hub_status_data(struct usb_hcd *hcd, char *buf);
550int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
551 u16 wIndex, char *buf, u16 wLength);
552
553/* fhci-tds.c */
554void fhci_flush_bds(struct fhci_usb *usb);
555void fhci_flush_actual_frame(struct fhci_usb *usb);
556u32 fhci_host_transaction(struct fhci_usb *usb, struct packet *pkt,
557 enum fhci_ta_type trans_type, u8 dest_addr,
558 u8 dest_ep, enum fhci_tf_mode trans_mode,
559 enum fhci_speed dest_speed, u8 data_toggle);
560void fhci_host_transmit_actual_frame(struct fhci_usb *usb);
561void fhci_tx_conf_interrupt(struct fhci_usb *usb);
562void fhci_push_dummy_bd(struct endpoint *ep);
563u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
564 u32 ring_len);
565void fhci_init_ep_registers(struct fhci_usb *usb,
566 struct endpoint *ep,
567 enum fhci_mem_alloc data_mem);
568void fhci_ep0_free(struct fhci_usb *usb);
569
570/* fhci-sched.c */
571extern struct tasklet_struct fhci_tasklet;
572void fhci_transaction_confirm(struct fhci_usb *usb, struct packet *pkt);
573void fhci_flush_all_transmissions(struct fhci_usb *usb);
574void fhci_schedule_transactions(struct fhci_usb *usb);
575void fhci_device_connected_interrupt(struct fhci_hcd *fhci);
576void fhci_device_disconnected_interrupt(struct fhci_hcd *fhci);
577void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb);
578u32 fhci_transfer_confirm_callback(struct fhci_hcd *fhci);
579irqreturn_t fhci_irq(struct usb_hcd *hcd);
580irqreturn_t fhci_frame_limit_timer_irq(int irq, void *_hcd);
581
582/* fhci-q.h */
583void fhci_urb_complete_free(struct fhci_hcd *fhci, struct urb *urb);
584struct td *fhci_remove_td_from_ed(struct ed *ed);
585struct td *fhci_remove_td_from_frame(struct fhci_time_frame *frame);
586void fhci_move_td_from_ed_to_done_list(struct fhci_usb *usb, struct ed *ed);
587struct td *fhci_peek_td_from_frame(struct fhci_time_frame *frame);
588void fhci_add_td_to_frame(struct fhci_time_frame *frame, struct td *td);
589struct td *fhci_remove_td_from_done_list(struct fhci_controller_list *p_list);
590void fhci_done_td(struct urb *urb, struct td *td);
591void fhci_del_ed_list(struct fhci_hcd *fhci, struct ed *ed);
592
593#ifdef CONFIG_FHCI_DEBUG
594
595void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er);
596void fhci_dfs_destroy(struct fhci_hcd *fhci);
597void fhci_dfs_create(struct fhci_hcd *fhci);
598
599#else
600
601static inline void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er) {}
602static inline void fhci_dfs_destroy(struct fhci_hcd *fhci) {}
603static inline void fhci_dfs_create(struct fhci_hcd *fhci) {}
604
605#endif /* CONFIG_FHCI_DEBUG */
606
607#endif /* __FHCI_H */
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 65a9609f4ad6..5cf5f1eca4f4 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -593,12 +593,10 @@ static int ohci_run (struct ohci_hcd *ohci)
593 * to be checked in case boot firmware (BIOS/SMM/...) has set up 593 * to be checked in case boot firmware (BIOS/SMM/...) has set up
594 * wakeup in a way the bus isn't aware of (e.g., legacy PCI PM). 594 * wakeup in a way the bus isn't aware of (e.g., legacy PCI PM).
595 * If the bus glue detected wakeup capability then it should 595 * If the bus glue detected wakeup capability then it should
596 * already be enabled. Either way, if wakeup should be enabled 596 * already be enabled; if so we'll just enable it again.
597 * but isn't, we'll enable it now.
598 */ 597 */
599 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0 598 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0)
600 && !device_can_wakeup(hcd->self.controller)) 599 device_set_wakeup_capable(hcd->self.controller, 1);
601 device_init_wakeup(hcd->self.controller, 1);
602 600
603 switch (ohci->hc_control & OHCI_CTRL_HCFS) { 601 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
604 case OHCI_USB_OPER: 602 case OHCI_USB_OPER:
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 8b28ae7865ba..5d625c3fd423 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -487,7 +487,6 @@ static struct pci_driver ohci_pci_driver = {
487 487
488#ifdef CONFIG_PM 488#ifdef CONFIG_PM
489 .suspend = usb_hcd_pci_suspend, 489 .suspend = usb_hcd_pci_suspend,
490 .suspend_late = usb_hcd_pci_suspend_late,
491 .resume_early = usb_hcd_pci_resume_early, 490 .resume_early = usb_hcd_pci_resume_early,
492 .resume = usb_hcd_pci_resume, 491 .resume = usb_hcd_pci_resume,
493#endif 492#endif
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 4e221060f58c..944f7e0ca4df 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -942,7 +942,6 @@ static struct pci_driver uhci_pci_driver = {
942 942
943#ifdef CONFIG_PM 943#ifdef CONFIG_PM
944 .suspend = usb_hcd_pci_suspend, 944 .suspend = usb_hcd_pci_suspend,
945 .suspend_late = usb_hcd_pci_suspend_late,
946 .resume_early = usb_hcd_pci_resume_early, 945 .resume_early = usb_hcd_pci_resume_early,
947 .resume = usb_hcd_pci_resume, 946 .resume = usb_hcd_pci_resume,
948#endif /* PM */ 947#endif /* PM */
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 189a9db03509..ad4fb15b5dcb 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -57,7 +57,6 @@
57#define USB_DEVICE_ID_LD_MACHINETEST 0x2040 /* USB Product ID of Machine Test System */ 57#define USB_DEVICE_ID_LD_MACHINETEST 0x2040 /* USB Product ID of Machine Test System */
58 58
59#define USB_VENDOR_ID_VERNIER 0x08f7 59#define USB_VENDOR_ID_VERNIER 0x08f7
60#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
61#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 60#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
62#define USB_DEVICE_ID_VERNIER_SKIP 0x0003 61#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
63#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 62#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
@@ -85,7 +84,6 @@ static struct usb_device_id ld_usb_table [] = {
85 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 84 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
86 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 85 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
87 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 86 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
88 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
89 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 87 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
90 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 88 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
91 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 89 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index e06810aef2df..4cf27c72423e 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -37,6 +37,7 @@
37#define MON_IOCX_GET _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get) 37#define MON_IOCX_GET _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get)
38#define MON_IOCX_MFETCH _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch) 38#define MON_IOCX_MFETCH _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch)
39#define MON_IOCH_MFLUSH _IO(MON_IOC_MAGIC, 8) 39#define MON_IOCH_MFLUSH _IO(MON_IOC_MAGIC, 8)
40
40#ifdef CONFIG_COMPAT 41#ifdef CONFIG_COMPAT
41#define MON_IOCX_GET32 _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get32) 42#define MON_IOCX_GET32 _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get32)
42#define MON_IOCX_MFETCH32 _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch32) 43#define MON_IOCX_MFETCH32 _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch32)
@@ -921,21 +922,6 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
921 } 922 }
922 break; 923 break;
923 924
924#ifdef CONFIG_COMPAT
925 case MON_IOCX_GET32: {
926 struct mon_bin_get32 getb;
927
928 if (copy_from_user(&getb, (void __user *)arg,
929 sizeof(struct mon_bin_get32)))
930 return -EFAULT;
931
932 ret = mon_bin_get_event(file, rp,
933 compat_ptr(getb.hdr32), compat_ptr(getb.data32),
934 getb.alloc32);
935 }
936 break;
937#endif
938
939 case MON_IOCX_MFETCH: 925 case MON_IOCX_MFETCH:
940 { 926 {
941 struct mon_bin_mfetch mfetch; 927 struct mon_bin_mfetch mfetch;
@@ -962,7 +948,57 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
962 } 948 }
963 break; 949 break;
964 950
951 case MON_IOCG_STATS: {
952 struct mon_bin_stats __user *sp;
953 unsigned int nevents;
954 unsigned int ndropped;
955
956 spin_lock_irqsave(&rp->b_lock, flags);
957 ndropped = rp->cnt_lost;
958 rp->cnt_lost = 0;
959 spin_unlock_irqrestore(&rp->b_lock, flags);
960 nevents = mon_bin_queued(rp);
961
962 sp = (struct mon_bin_stats __user *)arg;
963 if (put_user(rp->cnt_lost, &sp->dropped))
964 return -EFAULT;
965 if (put_user(nevents, &sp->queued))
966 return -EFAULT;
967
968 }
969 break;
970
971 default:
972 return -ENOTTY;
973 }
974
975 return ret;
976}
977
965#ifdef CONFIG_COMPAT 978#ifdef CONFIG_COMPAT
979static long mon_bin_compat_ioctl(struct file *file,
980 unsigned int cmd, unsigned long arg)
981{
982 struct mon_reader_bin *rp = file->private_data;
983 int ret;
984
985 switch (cmd) {
986
987 case MON_IOCX_GET32: {
988 struct mon_bin_get32 getb;
989
990 if (copy_from_user(&getb, (void __user *)arg,
991 sizeof(struct mon_bin_get32)))
992 return -EFAULT;
993
994 ret = mon_bin_get_event(file, rp,
995 compat_ptr(getb.hdr32), compat_ptr(getb.data32),
996 getb.alloc32);
997 if (ret < 0)
998 return ret;
999 }
1000 return 0;
1001
966 case MON_IOCX_MFETCH32: 1002 case MON_IOCX_MFETCH32:
967 { 1003 {
968 struct mon_bin_mfetch32 mfetch; 1004 struct mon_bin_mfetch32 mfetch;
@@ -986,37 +1022,25 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
986 return ret; 1022 return ret;
987 if (put_user(ret, &uptr->nfetch32)) 1023 if (put_user(ret, &uptr->nfetch32))
988 return -EFAULT; 1024 return -EFAULT;
989 ret = 0;
990 } 1025 }
991 break; 1026 return 0;
992#endif
993
994 case MON_IOCG_STATS: {
995 struct mon_bin_stats __user *sp;
996 unsigned int nevents;
997 unsigned int ndropped;
998
999 spin_lock_irqsave(&rp->b_lock, flags);
1000 ndropped = rp->cnt_lost;
1001 rp->cnt_lost = 0;
1002 spin_unlock_irqrestore(&rp->b_lock, flags);
1003 nevents = mon_bin_queued(rp);
1004 1027
1005 sp = (struct mon_bin_stats __user *)arg; 1028 case MON_IOCG_STATS:
1006 if (put_user(rp->cnt_lost, &sp->dropped)) 1029 return mon_bin_ioctl(NULL, file, cmd,
1007 return -EFAULT; 1030 (unsigned long) compat_ptr(arg));
1008 if (put_user(nevents, &sp->queued))
1009 return -EFAULT;
1010 1031
1011 } 1032 case MON_IOCQ_URB_LEN:
1012 break; 1033 case MON_IOCQ_RING_SIZE:
1034 case MON_IOCT_RING_SIZE:
1035 case MON_IOCH_MFLUSH:
1036 return mon_bin_ioctl(NULL, file, cmd, arg);
1013 1037
1014 default: 1038 default:
1015 return -ENOTTY; 1039 ;
1016 } 1040 }
1017 1041 return -ENOTTY;
1018 return ret;
1019} 1042}
1043#endif /* CONFIG_COMPAT */
1020 1044
1021static unsigned int 1045static unsigned int
1022mon_bin_poll(struct file *file, struct poll_table_struct *wait) 1046mon_bin_poll(struct file *file, struct poll_table_struct *wait)
@@ -1094,6 +1118,9 @@ static const struct file_operations mon_fops_binary = {
1094 /* .write = mon_text_write, */ 1118 /* .write = mon_text_write, */
1095 .poll = mon_bin_poll, 1119 .poll = mon_bin_poll,
1096 .ioctl = mon_bin_ioctl, 1120 .ioctl = mon_bin_ioctl,
1121#ifdef CONFIG_COMPAT
1122 .compat_ioctl = mon_bin_compat_ioctl,
1123#endif
1097 .release = mon_bin_release, 1124 .release = mon_bin_release,
1098 .mmap = mon_bin_mmap, 1125 .mmap = mon_bin_mmap,
1099}; 1126};
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 5af7379cd9a3..9985db08e7db 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -11,6 +11,7 @@ config USB_MUSB_HDRC
11 depends on (USB || USB_GADGET) && HAVE_CLK 11 depends on (USB || USB_GADGET) && HAVE_CLK
12 depends on !SUPERH 12 depends on !SUPERH
13 select TWL4030_USB if MACH_OMAP_3430SDP 13 select TWL4030_USB if MACH_OMAP_3430SDP
14 select USB_OTG_UTILS
14 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)' 15 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
15 help 16 help
16 Say Y here if your system has a dual role high speed USB 17 Say Y here if your system has a dual role high speed USB
@@ -49,7 +50,7 @@ comment "OMAP 343x high speed USB support"
49 depends on USB_MUSB_HDRC && ARCH_OMAP34XX 50 depends on USB_MUSB_HDRC && ARCH_OMAP34XX
50 51
51comment "Blackfin high speed USB Support" 52comment "Blackfin high speed USB Support"
52 depends on USB_MUSB_HDRC && (BF54x && !BF544) || (BF52x && !BF522 && !BF523) 53 depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523))
53 54
54config USB_TUSB6010 55config USB_TUSB6010
55 boolean "TUSB 6010 support" 56 boolean "TUSB 6010 support"
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index 5ad6d0893cbe..569ef0fed0f6 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -9,6 +9,7 @@
9#include <linux/usb.h> 9#include <linux/usb.h>
10 10
11#include "musb_core.h" 11#include "musb_core.h"
12#include "musb_debug.h"
12#include "cppi_dma.h" 13#include "cppi_dma.h"
13 14
14 15
@@ -423,6 +424,7 @@ cppi_rndis_update(struct cppi_channel *c, int is_rx,
423 } 424 }
424} 425}
425 426
427#ifdef CONFIG_USB_MUSB_DEBUG
426static void cppi_dump_rxbd(const char *tag, struct cppi_descriptor *bd) 428static void cppi_dump_rxbd(const char *tag, struct cppi_descriptor *bd)
427{ 429{
428 pr_debug("RXBD/%s %08x: " 430 pr_debug("RXBD/%s %08x: "
@@ -431,10 +433,11 @@ static void cppi_dump_rxbd(const char *tag, struct cppi_descriptor *bd)
431 bd->hw_next, bd->hw_bufp, bd->hw_off_len, 433 bd->hw_next, bd->hw_bufp, bd->hw_off_len,
432 bd->hw_options); 434 bd->hw_options);
433} 435}
436#endif
434 437
435static void cppi_dump_rxq(int level, const char *tag, struct cppi_channel *rx) 438static void cppi_dump_rxq(int level, const char *tag, struct cppi_channel *rx)
436{ 439{
437#if MUSB_DEBUG > 0 440#ifdef CONFIG_USB_MUSB_DEBUG
438 struct cppi_descriptor *bd; 441 struct cppi_descriptor *bd;
439 442
440 if (!_dbg_level(level)) 443 if (!_dbg_level(level))
@@ -881,12 +884,14 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
881 bd->hw_options |= CPPI_SOP_SET; 884 bd->hw_options |= CPPI_SOP_SET;
882 tail->hw_options |= CPPI_EOP_SET; 885 tail->hw_options |= CPPI_EOP_SET;
883 886
884 if (debug >= 5) { 887#ifdef CONFIG_USB_MUSB_DEBUG
888 if (_dbg_level(5)) {
885 struct cppi_descriptor *d; 889 struct cppi_descriptor *d;
886 890
887 for (d = rx->head; d; d = d->next) 891 for (d = rx->head; d; d = d->next)
888 cppi_dump_rxbd("S", d); 892 cppi_dump_rxbd("S", d);
889 } 893 }
894#endif
890 895
891 /* in case the preceding transfer left some state... */ 896 /* in case the preceding transfer left some state... */
892 tail = rx->last_processed; 897 tail = rx->last_processed;
@@ -990,6 +995,7 @@ static int cppi_channel_program(struct dma_channel *ch,
990 cppi_ch->offset = 0; 995 cppi_ch->offset = 0;
991 cppi_ch->maxpacket = maxpacket; 996 cppi_ch->maxpacket = maxpacket;
992 cppi_ch->buf_len = len; 997 cppi_ch->buf_len = len;
998 cppi_ch->channel.actual_len = 0;
993 999
994 /* TX channel? or RX? */ 1000 /* TX channel? or RX? */
995 if (cppi_ch->transmit) 1001 if (cppi_ch->transmit)
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 0d566dc5ce06..5a8fd5d57a11 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -32,9 +32,10 @@
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/gpio.h> 33#include <linux/gpio.h>
34 34
35#include <mach/arch/hardware.h> 35#include <mach/hardware.h>
36#include <mach/arch/memory.h> 36#include <mach/memory.h>
37#include <mach/arch/gpio.h> 37#include <mach/gpio.h>
38
38#include <asm/mach-types.h> 39#include <asm/mach-types.h>
39 40
40#include "musb_core.h" 41#include "musb_core.h"
@@ -370,12 +371,6 @@ int musb_platform_set_mode(struct musb *musb, u8 mode)
370 return -EIO; 371 return -EIO;
371} 372}
372 373
373int musb_platform_set_mode(struct musb *musb, u8 mode)
374{
375 /* EVM can't do this (right?) */
376 return -EIO;
377}
378
379int __init musb_platform_init(struct musb *musb) 374int __init musb_platform_init(struct musb *musb)
380{ 375{
381 void __iomem *tibase = musb->ctrl_base; 376 void __iomem *tibase = musb->ctrl_base;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 6c7faacfb535..2cc34fa05b73 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1824,8 +1824,9 @@ static void musb_free(struct musb *musb)
1824 musb_gadget_cleanup(musb); 1824 musb_gadget_cleanup(musb);
1825#endif 1825#endif
1826 1826
1827 if (musb->nIrq >= 0 && musb->irq_wake) { 1827 if (musb->nIrq >= 0) {
1828 disable_irq_wake(musb->nIrq); 1828 if (musb->irq_wake)
1829 disable_irq_wake(musb->nIrq);
1829 free_irq(musb->nIrq, musb); 1830 free_irq(musb->nIrq, musb);
1830 } 1831 }
1831 if (is_dma_capable() && musb->dma_controller) { 1832 if (is_dma_capable() && musb->dma_controller) {
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 6197daeab8f9..4ea305387981 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -874,10 +874,10 @@ static int musb_gadget_enable(struct usb_ep *ep,
874 status = -EBUSY; 874 status = -EBUSY;
875 goto fail; 875 goto fail;
876 } 876 }
877 musb_ep->type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 877 musb_ep->type = usb_endpoint_type(desc);
878 878
879 /* check direction and (later) maxpacket size against endpoint */ 879 /* check direction and (later) maxpacket size against endpoint */
880 if ((desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) != epnum) 880 if (usb_endpoint_num(desc) != epnum)
881 goto fail; 881 goto fail;
882 882
883 /* REVISIT this rules out high bandwidth periodic transfers */ 883 /* REVISIT this rules out high bandwidth periodic transfers */
@@ -890,7 +890,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
890 * packet size (or fail), set the mode, clear the fifo 890 * packet size (or fail), set the mode, clear the fifo
891 */ 891 */
892 musb_ep_select(mbase, epnum); 892 musb_ep_select(mbase, epnum);
893 if (desc->bEndpointAddress & USB_DIR_IN) { 893 if (usb_endpoint_dir_in(desc)) {
894 u16 int_txe = musb_readw(mbase, MUSB_INTRTXE); 894 u16 int_txe = musb_readw(mbase, MUSB_INTRTXE);
895 895
896 if (hw_ep->is_shared_fifo) 896 if (hw_ep->is_shared_fifo)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 99fa61234876..a035ceccf950 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1847,8 +1847,8 @@ static int musb_urb_enqueue(
1847 goto done; 1847 goto done;
1848 } 1848 }
1849 1849
1850 qh->epnum = epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1850 qh->epnum = usb_endpoint_num(epd);
1851 qh->type = epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 1851 qh->type = usb_endpoint_type(epd);
1852 1852
1853 /* NOTE: urb->dev->devnum is wrong during SET_ADDRESS */ 1853 /* NOTE: urb->dev->devnum is wrong during SET_ADDRESS */
1854 qh->addr_reg = (u8) usb_pipedevice(urb->pipe); 1854 qh->addr_reg = (u8) usb_pipedevice(urb->pipe);
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 52f7f29cebda..7e073a0d7ac9 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -15,8 +15,8 @@
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <asm/arch/dma.h> 18#include <mach/dma.h>
19#include <asm/arch/mux.h> 19#include <mach/mux.h>
20 20
21#include "musb_core.h" 21#include "musb_core.h"
22 22
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 8e8dbdb9b39b..ee55b449ffde 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -6,14 +6,14 @@
6 6
7comment "OTG and related infrastructure" 7comment "OTG and related infrastructure"
8 8
9if USB || USB_GADGET
10
11config USB_OTG_UTILS 9config USB_OTG_UTILS
12 bool 10 bool
13 help 11 help
14 Select this to make sure the build includes objects from 12 Select this to make sure the build includes objects from
15 the OTG infrastructure directory. 13 the OTG infrastructure directory.
16 14
15if USB || USB_GADGET
16
17# 17#
18# USB Transceiver Drivers 18# USB Transceiver Drivers
19# 19#
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index cfaf1f085535..027f4b7dde86 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -85,6 +85,8 @@ static struct usb_device_id id_table [] = {
85 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 85 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
86 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 86 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
87 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 87 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
88 { USB_DEVICE(0x10C4, 0x822B) }, /* Modem EDGE(GSM) Comander 2 */
89 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demostration module */
88 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ 90 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
89 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 91 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
90 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */ 92 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index c70a8f667d85..75597337583e 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -660,6 +660,8 @@ static struct usb_device_id id_table_combined [] = {
660 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, 660 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
661 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) }, 661 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
662 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, 662 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
663 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
664 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) },
663 { }, /* Optional parameter entry */ 665 { }, /* Optional parameter entry */
664 { } /* Terminating entry */ 666 { } /* Terminating entry */
665}; 667};
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 373ee09975bb..1b62eff475d2 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -854,6 +854,10 @@
854#define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */ 854#define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */
855#define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */ 855#define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */
856 856
857/* Alti-2 products http://www.alti-2.com */
858#define ALTI2_VID 0x1BC9
859#define ALTI2_N3_PID 0x6001 /* Neptune 3 */
860
857/* Commands */ 861/* Commands */
858#define FTDI_SIO_RESET 0 /* Reset the port */ 862#define FTDI_SIO_RESET 0 /* Reset the port */
859#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 863#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
@@ -881,6 +885,11 @@
881#define RATOC_PRODUCT_ID_USB60F 0xb020 885#define RATOC_PRODUCT_ID_USB60F 0xb020
882 886
883/* 887/*
888 * DIEBOLD BCS SE923
889 */
890#define DIEBOLD_BCS_SE923_PID 0xfb99
891
892/*
884 * BmRequestType: 1100 0000b 893 * BmRequestType: 1100 0000b
885 * bRequest: FTDI_E2_READ 894 * bRequest: FTDI_E2_READ
886 * wValue: 0 895 * wValue: 0
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 5ed183477aaf..6c89da9c6fea 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -158,6 +158,13 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
158#define HUAWEI_PRODUCT_E143E 0x143E 158#define HUAWEI_PRODUCT_E143E 0x143E
159#define HUAWEI_PRODUCT_E143F 0x143F 159#define HUAWEI_PRODUCT_E143F 0x143F
160 160
161#define QUANTA_VENDOR_ID 0x0408
162#define QUANTA_PRODUCT_Q101 0xEA02
163#define QUANTA_PRODUCT_Q111 0xEA03
164#define QUANTA_PRODUCT_GLX 0xEA04
165#define QUANTA_PRODUCT_GKE 0xEA05
166#define QUANTA_PRODUCT_GLE 0xEA06
167
161#define NOVATELWIRELESS_VENDOR_ID 0x1410 168#define NOVATELWIRELESS_VENDOR_ID 0x1410
162 169
163/* YISO PRODUCTS */ 170/* YISO PRODUCTS */
@@ -224,7 +231,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
224#define ONDA_VENDOR_ID 0x19d2 231#define ONDA_VENDOR_ID 0x19d2
225#define ONDA_PRODUCT_MSA501HS 0x0001 232#define ONDA_PRODUCT_MSA501HS 0x0001
226#define ONDA_PRODUCT_ET502HS 0x0002 233#define ONDA_PRODUCT_ET502HS 0x0002
227#define ONDA_PRODUCT_MT503HS 0x0200 234#define ONDA_PRODUCT_MT503HS 0x2000
228 235
229#define BANDRICH_VENDOR_ID 0x1A8D 236#define BANDRICH_VENDOR_ID 0x1A8D
230#define BANDRICH_PRODUCT_C100_1 0x1002 237#define BANDRICH_PRODUCT_C100_1 0x1002
@@ -298,6 +305,11 @@ static struct usb_device_id option_ids[] = {
298 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, 305 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) },
299 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, 306 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) },
300 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, 307 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) },
308 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q101) },
309 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q111) },
310 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) },
311 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GKE) },
312 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) },
301 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) }, 313 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) },
302 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, 314 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) },
303 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, 315 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) },
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 3cf41df302d7..baf591137b80 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -184,6 +184,7 @@ static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = {
184 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) }, 184 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) }, 185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) }, 186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
187 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
187}; 188};
188 189
189static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 190static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -191,6 +192,7 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
191 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 192 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
192 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 194 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
195 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
194}; 196};
195 197
196static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] = { 198static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] = {
@@ -205,6 +207,7 @@ static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] =
205 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 207 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
206 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 208 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
207 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 209 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
210 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
208 { } 211 { }
209}; 212};
210 213
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index 7e4752fbf232..b7ea5dbadee5 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -27,7 +27,9 @@
27 27
28/* Vendor and product ids */ 28/* Vendor and product ids */
29#define TI_VENDOR_ID 0x0451 29#define TI_VENDOR_ID 0x0451
30#define IBM_VENDOR_ID 0x04b3
30#define TI_3410_PRODUCT_ID 0x3410 31#define TI_3410_PRODUCT_ID 0x3410
32#define IBM_4543_PRODUCT_ID 0x4543
31#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */ 33#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */
32#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */ 34#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */
33#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */ 35#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index a7f9513fa19d..69269f739563 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -995,6 +995,16 @@ UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
995 US_SC_DEVICE, US_PR_DEVICE, NULL, 995 US_SC_DEVICE, US_PR_DEVICE, NULL,
996 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64), 996 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64),
997 997
998/* Reported by Jean-Baptiste Onofre <jb@nanthrax.net>
999 * Support the following product :
1000 * "Dane-Elec MediaTouch"
1001 */
1002UNUSUAL_DEV( 0x071b, 0x32bb, 0x0000, 0x0000,
1003 "RockChip",
1004 "MTP",
1005 US_SC_DEVICE, US_PR_DEVICE, NULL,
1006 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64),
1007
998/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> 1008/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com>
999 * This USB MP3/AVI player device fails and disconnects if more than 128 1009 * This USB MP3/AVI player device fails and disconnects if more than 128
1000 * sectors (64kB) are read/written in a single command, and may be present 1010 * sectors (64kB) are read/written in a single command, and may be present
@@ -1251,6 +1261,13 @@ UNUSUAL_DEV( 0x0840, 0x0084, 0x0001, 0x0001,
1251 US_SC_DEVICE, US_PR_DEVICE, NULL, 1261 US_SC_DEVICE, US_PR_DEVICE, NULL,
1252 US_FL_FIX_CAPACITY), 1262 US_FL_FIX_CAPACITY),
1253 1263
1264/* Reported by Martijn Hijdra <martijn.hijdra@gmail.com> */
1265UNUSUAL_DEV( 0x0840, 0x0085, 0x0001, 0x0001,
1266 "Argosy",
1267 "Storage",
1268 US_SC_DEVICE, US_PR_DEVICE, NULL,
1269 US_FL_FIX_CAPACITY),
1270
1254/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 1271/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
1255 * Flag will support Bulk devices which use a standards-violating 32-byte 1272 * Flag will support Bulk devices which use a standards-violating 32-byte
1256 * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with 1273 * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with
@@ -1589,6 +1606,13 @@ UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
1589 US_SC_DEVICE, US_PR_DEVICE, NULL, 1606 US_SC_DEVICE, US_PR_DEVICE, NULL,
1590 US_FL_NO_WP_DETECT ), 1607 US_FL_NO_WP_DETECT ),
1591 1608
1609/* Reported by The Solutor <thesolutor@gmail.com> */
1610UNUSUAL_DEV( 0x0fce, 0xd0e1, 0x0000, 0x0000,
1611 "Sony Ericsson",
1612 "MD400",
1613 US_SC_DEVICE, US_PR_DEVICE, NULL,
1614 US_FL_IGNORE_DEVICE),
1615
1592/* Reported by Jan Mate <mate@fiit.stuba.sk> 1616/* Reported by Jan Mate <mate@fiit.stuba.sk>
1593 * and by Soeren Sonnenburg <kernel@nn7.de> */ 1617 * and by Soeren Sonnenburg <kernel@nn7.de> */
1594UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000, 1618UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
@@ -2031,15 +2055,11 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
2031 US_SC_DEVICE, US_PR_DEVICE, NULL, 2055 US_SC_DEVICE, US_PR_DEVICE, NULL,
2032 US_FL_IGNORE_RESIDUE ), 2056 US_FL_IGNORE_RESIDUE ),
2033 2057
2034/* Reported by Mauro Andreolini <andreoli@weblab.ing.unimo.it> 2058UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
2035 * This entry is needed to bypass the ZeroCD mechanism 2059 "ST",
2036 * and to properly load as a modem device. 2060 "2A",
2037 */
2038UNUSUAL_DEV( 0x19d2, 0x2000, 0x0000, 0x0000,
2039 "Onda ET502HS",
2040 "USB MMC Storage",
2041 US_SC_DEVICE, US_PR_DEVICE, NULL, 2061 US_SC_DEVICE, US_PR_DEVICE, NULL,
2042 US_FL_IGNORE_DEVICE), 2062 US_FL_FIX_CAPACITY),
2043 2063
2044/* patch submitted by Davide Perini <perini.davide@dpsoftware.org> 2064/* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
2045 * and Renato Perini <rperini@email.it> 2065 * and Renato Perini <rperini@email.it>
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c94f71980c1b..f0267706cb45 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -41,7 +41,7 @@ menuconfig FB
41 You need an utility program called fbset to make full use of frame 41 You need an utility program called fbset to make full use of frame
42 buffer devices. Please read <file:Documentation/fb/framebuffer.txt> 42 buffer devices. Please read <file:Documentation/fb/framebuffer.txt>
43 and the Framebuffer-HOWTO at 43 and the Framebuffer-HOWTO at
44 <http://www.tahallah.demon.co.uk/programming/prog.html> for more 44 <http://www.munted.org.uk/programming/Framebuffer-HOWTO-1.2.html> for more
45 information. 45 information.
46 46
47 Say Y here and to the driver for your graphics board below if you 47 Say Y here and to the driver for your graphics board below if you