aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/apei/apei-base.c35
-rw-r--r--drivers/acpi/apei/einj.c95
-rw-r--r--drivers/acpi/atomicio.c422
-rw-r--r--drivers/acpi/osl.c152
-rw-r--r--drivers/acpi/processor_driver.c154
-rw-r--r--drivers/acpi/sleep.c8
-rw-r--r--drivers/base/Makefile2
-rw-r--r--drivers/base/bus.c9
-rw-r--r--drivers/base/core.c17
-rw-r--r--drivers/base/firmware_class.c3
-rw-r--r--drivers/base/regmap/regmap.c3
-rw-r--r--drivers/base/sys.c383
-rw-r--r--drivers/char/agp/backend.c12
-rw-r--r--drivers/gpu/drm/drm_auth.c6
-rw-r--r--drivers/gpu/drm/drm_fops.c5
-rw-r--r--drivers/gpu/drm/drm_gem.c2
-rw-r--r--drivers/gpu/drm/exynos/Kconfig4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c109
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c8
-rw-r--r--drivers/gpu/drm/gma500/framebuffer.c8
-rw-r--r--drivers/gpu/drm/gma500/gtt.c5
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c17
-rw-r--r--drivers/gpu/drm/i810/i810_drv.c1
-rw-r--r--drivers/gpu/drm/i810/i810_drv.h6
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c31
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c1
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c56
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h10
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c3
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c11
-rw-r--r--drivers/gpu/drm/i915/intel_bios.h6
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c23
-rw-r--r--drivers/gpu/drm/i915/intel_display.c22
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c8
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c41
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c8
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c8
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c138
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c4
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c60
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c22
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c89
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c1
-rw-r--r--drivers/gpu/drm/radeon/evergreend.h1
-rw-r--r--drivers/gpu/drm/radeon/ni.c1
-rw-r--r--drivers/gpu/drm/radeon/nid.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon.h84
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c77
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h8
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c37
-rw-r--r--drivers/gpu/drm/sis/sis_drv.c3
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c17
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c2
-rw-r--r--drivers/hwmon/f71805f.c10
-rw-r--r--drivers/hwmon/sht15.c3
-rw-r--r--drivers/hwmon/w83627ehf.c6
-rw-r--r--drivers/idle/intel_idle.c2
-rw-r--r--drivers/leds/Kconfig7
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-ot200.c171
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c11
-rw-r--r--drivers/media/dvb/dvb-usb/cinergyT2-fe.c7
-rw-r--r--drivers/media/dvb/frontends/cxd2820r.h6
-rw-r--r--drivers/media/dvb/frontends/cxd2820r_core.c20
-rw-r--r--drivers/media/video/atmel-isi.c14
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c3
-rw-r--r--drivers/mfd/mcp-core.c61
-rw-r--r--drivers/mfd/mcp-sa11x0.c169
-rw-r--r--drivers/mfd/ucb1x00-core.c67
-rw-r--r--drivers/mfd/ucb1x00-ts.c34
-rw-r--r--drivers/net/bonding/bond_alb.c27
-rw-r--r--drivers/net/dsa/mv88e6060.c1
-rw-r--r--drivers/net/dsa/mv88e6123_61_65.c22
-rw-r--r--drivers/net/dsa/mv88e6131.c1
-rw-r--r--drivers/net/dsa/mv88e6xxx.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c111
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c11
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c44
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h11
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c9
-rw-r--r--drivers/net/ethernet/cisco/enic/enic.h2
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c38
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c3
-rw-r--r--drivers/net/ethernet/faraday/ftgmac100.c1
-rw-r--r--drivers/net/ethernet/faraday/ftmac100.c1
-rw-r--r--drivers/net/ethernet/intel/igb/Makefile2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.c2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_defines.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_hw.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mac.c4
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mac.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mbx.c2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mbx.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_nvm.c2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_nvm.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_phy.c2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_phy.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_regs.h2
-rw-r--r--drivers/net/ethernet/intel/igb/igb.h2
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ethtool.c2
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c10
-rw-r--r--drivers/net/ethernet/intel/igbvf/ethtool.c3
-rw-r--r--drivers/net/ethernet/intel/igbvf/netdev.c5
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h32
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ethtool.c5
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf.h8
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c41
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/mbx.c3
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/vf.c7
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/vf.h2
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c14
-rw-r--r--drivers/net/ethernet/marvell/skge.c109
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c9
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cq.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c159
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_main.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c38
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c21
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mr.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/pd.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/port.c23
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/profile.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/qp.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c39
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/srq.c2
-rw-r--r--drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c17
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c6
-rw-r--r--drivers/net/hyperv/netvsc_drv.c5
-rw-r--r--drivers/net/macvlan.c1
-rw-r--r--drivers/net/phy/mdio_bus.c5
-rw-r--r--drivers/net/team/team.c136
-rw-r--r--drivers/net/wireless/b43/Kconfig6
-rw-r--r--drivers/net/wireless/b43/main.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/main.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c4
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--drivers/pci/pci.c6
-rw-r--r--drivers/pcmcia/sa1111_generic.c3
-rw-r--r--drivers/pinctrl/core.c50
-rw-r--r--drivers/pinctrl/core.h3
-rw-r--r--drivers/pinctrl/pinconf.c6
-rw-r--r--drivers/pinctrl/pinconf.h4
-rw-r--r--drivers/pinctrl/pinmux.c81
-rw-r--r--drivers/pinctrl/pinmux.h4
-rw-r--r--drivers/regulator/core.c2
-rw-r--r--drivers/regulator/of_regulator.c2
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/rtc-sa1100.c295
-rw-r--r--drivers/s390/block/dasd.c6
-rw-r--r--drivers/s390/block/dasd_alias.c64
-rw-r--r--drivers/s390/block/dasd_eckd.c63
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/scsi/mac_esp.c3
-rw-r--r--drivers/scsi/mac_scsi.c6
-rw-r--r--drivers/thermal/thermal_sys.c4
-rw-r--r--drivers/tty/serial/8250/8250.c (renamed from drivers/tty/serial/8250.c)0
-rw-r--r--drivers/tty/serial/8250/8250.h (renamed from drivers/tty/serial/8250.h)0
-rw-r--r--drivers/tty/serial/8250/8250_accent.c (renamed from drivers/tty/serial/8250_accent.c)0
-rw-r--r--drivers/tty/serial/8250/8250_acorn.c (renamed from drivers/tty/serial/8250_acorn.c)0
-rw-r--r--drivers/tty/serial/8250/8250_boca.c (renamed from drivers/tty/serial/8250_boca.c)0
-rw-r--r--drivers/tty/serial/8250/8250_dw.c (renamed from drivers/tty/serial/8250_dw.c)0
-rw-r--r--drivers/tty/serial/8250/8250_early.c (renamed from drivers/tty/serial/8250_early.c)0
-rw-r--r--drivers/tty/serial/8250/8250_exar_st16c554.c (renamed from drivers/tty/serial/8250_exar_st16c554.c)0
-rw-r--r--drivers/tty/serial/8250/8250_fourport.c (renamed from drivers/tty/serial/8250_fourport.c)0
-rw-r--r--drivers/tty/serial/8250/8250_fsl.c (renamed from drivers/tty/serial/8250_fsl.c)0
-rw-r--r--drivers/tty/serial/8250/8250_gsc.c (renamed from drivers/tty/serial/8250_gsc.c)0
-rw-r--r--drivers/tty/serial/8250/8250_hp300.c (renamed from drivers/tty/serial/8250_hp300.c)0
-rw-r--r--drivers/tty/serial/8250/8250_hub6.c (renamed from drivers/tty/serial/8250_hub6.c)0
-rw-r--r--drivers/tty/serial/8250/8250_mca.c (renamed from drivers/tty/serial/8250_mca.c)0
-rw-r--r--drivers/tty/serial/8250/8250_pci.c (renamed from drivers/tty/serial/8250_pci.c)0
-rw-r--r--drivers/tty/serial/8250/8250_pnp.c (renamed from drivers/tty/serial/8250_pnp.c)0
-rw-r--r--drivers/tty/serial/8250/Kconfig280
-rw-r--r--drivers/tty/serial/8250/Makefile20
-rw-r--r--drivers/tty/serial/8250/m32r_sio.c (renamed from drivers/tty/serial/m32r_sio.c)0
-rw-r--r--drivers/tty/serial/8250/m32r_sio.h (renamed from drivers/tty/serial/m32r_sio.h)0
-rw-r--r--drivers/tty/serial/8250/m32r_sio_reg.h (renamed from drivers/tty/serial/m32r_sio_reg.h)0
-rw-r--r--drivers/tty/serial/8250/serial_cs.c (renamed from drivers/tty/serial/serial_cs.c)0
-rw-r--r--drivers/tty/serial/Kconfig283
-rw-r--r--drivers/tty/serial/Makefile20
-rw-r--r--drivers/tty/serial/amba-pl011.c30
-rw-r--r--drivers/tty/serial/jsm/jsm_driver.c1
-rw-r--r--drivers/tty/serial/max3107-aava.c344
-rw-r--r--drivers/tty/serial/omap-serial.c4
-rw-r--r--drivers/tty/serial/serial_core.c6
-rw-r--r--drivers/tty/tty_port.c12
-rw-r--r--drivers/usb/class/cdc-wdm.c59
-rw-r--r--drivers/usb/dwc3/ep0.c15
-rw-r--r--drivers/usb/dwc3/gadget.c2
-rw-r--r--drivers/usb/gadget/composite.c7
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/f_mass_storage.c10
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c4
-rw-r--r--drivers/usb/gadget/langwell_udc.c107
-rw-r--r--drivers/usb/gadget/langwell_udc.h1
-rw-r--r--drivers/usb/gadget/storage_common.c6
-rw-r--r--drivers/usb/host/ehci-fsl.c2
-rw-r--r--drivers/usb/host/ehci-pci.c6
-rw-r--r--drivers/usb/host/ohci-at91.c24
-rw-r--r--drivers/usb/host/ohci-dbg.c12
-rw-r--r--drivers/usb/host/ohci-pci.c4
-rw-r--r--drivers/usb/host/xhci-ring.c6
-rw-r--r--drivers/usb/misc/emi26.c3
-rw-r--r--drivers/usb/misc/emi62.c3
-rw-r--r--drivers/usb/misc/usbsevseg.c2
-rw-r--r--drivers/usb/musb/davinci.c3
-rw-r--r--drivers/usb/musb/musb_core.c5
-rw-r--r--drivers/usb/musb/omap2430.c4
-rw-r--r--drivers/usb/otg/Kconfig18
-rw-r--r--drivers/usb/otg/Makefile1
-rw-r--r--drivers/usb/otg/langwell_otg.c2347
-rw-r--r--drivers/usb/otg/mv_otg.c2
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c2
-rw-r--r--drivers/usb/serial/cp210x.c105
-rw-r--r--drivers/usb/serial/ftdi_sio.c14
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h19
-rw-r--r--drivers/usb/serial/io_ti.c10
-rw-r--r--drivers/usb/serial/kobil_sct.c2
-rw-r--r--drivers/usb/serial/option.c5
-rw-r--r--drivers/usb/serial/qcaux.c7
-rw-r--r--drivers/usb/storage/realtek_cr.c2
-rw-r--r--drivers/usb/usb-skeleton.c18
-rw-r--r--drivers/usb/wusbcore/Kconfig2
-rw-r--r--drivers/video/backlight/adp8860_bl.c2
-rw-r--r--drivers/video/backlight/adp8870_bl.c2
-rw-r--r--drivers/video/backlight/l4f00242t03.c2
-rw-r--r--drivers/video/macfb.c60
-rw-r--r--drivers/virtio/virtio_ring.c8
-rw-r--r--drivers/watchdog/dw_wdt.c6
-rw-r--r--drivers/watchdog/iTCO_wdt.c35
-rw-r--r--drivers/watchdog/imx2_wdt.c11
-rw-r--r--drivers/watchdog/nuc900_wdt.c5
-rw-r--r--drivers/watchdog/omap_wdt.c2
-rw-r--r--drivers/watchdog/pnx4008_wdt.c2
-rw-r--r--drivers/watchdog/stmp3xxx_wdt.c2
-rw-r--r--drivers/watchdog/via_wdt.c6
-rw-r--r--drivers/watchdog/wafer5823wdt.c4
-rw-r--r--drivers/watchdog/wm8350_wdt.c4
-rw-r--r--drivers/xen/grant-table.c7
254 files changed, 2865 insertions, 5693 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index c07f44f05f9d..1567028d2038 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -19,7 +19,6 @@ obj-y += acpi.o \
19 19
20# All the builtin files are in the "acpi." module_param namespace. 20# All the builtin files are in the "acpi." module_param namespace.
21acpi-y += osl.o utils.o reboot.o 21acpi-y += osl.o utils.o reboot.o
22acpi-y += atomicio.o
23acpi-y += nvs.o 22acpi-y += nvs.o
24 23
25# sleep related files 24# sleep related files
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index e45350cb6ac8..e5d53b7ddc7e 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -596,33 +596,19 @@ int apei_read(u64 *val, struct acpi_generic_address *reg)
596{ 596{
597 int rc; 597 int rc;
598 u64 address; 598 u64 address;
599 u32 tmp, width = reg->bit_width;
600 acpi_status status; 599 acpi_status status;
601 600
602 rc = apei_check_gar(reg, &address); 601 rc = apei_check_gar(reg, &address);
603 if (rc) 602 if (rc)
604 return rc; 603 return rc;
605 604
606 if (width == 64)
607 width = 32; /* Break into two 32-bit transfers */
608
609 *val = 0; 605 *val = 0;
610 switch(reg->space_id) { 606 switch(reg->space_id) {
611 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 607 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
612 status = acpi_os_read_memory((acpi_physical_address) 608 status = acpi_os_read_memory64((acpi_physical_address)
613 address, &tmp, width); 609 address, val, reg->bit_width);
614 if (ACPI_FAILURE(status)) 610 if (ACPI_FAILURE(status))
615 return -EIO; 611 return -EIO;
616 *val = tmp;
617
618 if (reg->bit_width == 64) {
619 /* Read the top 32 bits */
620 status = acpi_os_read_memory((acpi_physical_address)
621 (address + 4), &tmp, 32);
622 if (ACPI_FAILURE(status))
623 return -EIO;
624 *val |= ((u64)tmp << 32);
625 }
626 break; 612 break;
627 case ACPI_ADR_SPACE_SYSTEM_IO: 613 case ACPI_ADR_SPACE_SYSTEM_IO:
628 status = acpi_os_read_port(address, (u32 *)val, reg->bit_width); 614 status = acpi_os_read_port(address, (u32 *)val, reg->bit_width);
@@ -642,31 +628,18 @@ int apei_write(u64 val, struct acpi_generic_address *reg)
642{ 628{
643 int rc; 629 int rc;
644 u64 address; 630 u64 address;
645 u32 width = reg->bit_width;
646 acpi_status status; 631 acpi_status status;
647 632
648 rc = apei_check_gar(reg, &address); 633 rc = apei_check_gar(reg, &address);
649 if (rc) 634 if (rc)
650 return rc; 635 return rc;
651 636
652 if (width == 64)
653 width = 32; /* Break into two 32-bit transfers */
654
655 switch (reg->space_id) { 637 switch (reg->space_id) {
656 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 638 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
657 status = acpi_os_write_memory((acpi_physical_address) 639 status = acpi_os_write_memory64((acpi_physical_address)
658 address, ACPI_LODWORD(val), 640 address, val, reg->bit_width);
659 width);
660 if (ACPI_FAILURE(status)) 641 if (ACPI_FAILURE(status))
661 return -EIO; 642 return -EIO;
662
663 if (reg->bit_width == 64) {
664 status = acpi_os_write_memory((acpi_physical_address)
665 (address + 4),
666 ACPI_HIDWORD(val), 32);
667 if (ACPI_FAILURE(status))
668 return -EIO;
669 }
670 break; 643 break;
671 case ACPI_ADR_SPACE_SYSTEM_IO: 644 case ACPI_ADR_SPACE_SYSTEM_IO:
672 status = acpi_os_write_port(address, val, reg->bit_width); 645 status = acpi_os_write_port(address, val, reg->bit_width);
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 5b898d4dda99..4ca087dd5f4f 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -141,21 +141,6 @@ static DEFINE_MUTEX(einj_mutex);
141 141
142static void *einj_param; 142static void *einj_param;
143 143
144#ifndef readq
145static inline __u64 readq(volatile void __iomem *addr)
146{
147 return ((__u64)readl(addr+4) << 32) + readl(addr);
148}
149#endif
150
151#ifndef writeq
152static inline void writeq(__u64 val, volatile void __iomem *addr)
153{
154 writel(val, addr);
155 writel(val >> 32, addr+4);
156}
157#endif
158
159static void einj_exec_ctx_init(struct apei_exec_context *ctx) 144static void einj_exec_ctx_init(struct apei_exec_context *ctx)
160{ 145{
161 apei_exec_ctx_init(ctx, einj_ins_type, ARRAY_SIZE(einj_ins_type), 146 apei_exec_ctx_init(ctx, einj_ins_type, ARRAY_SIZE(einj_ins_type),
@@ -204,22 +189,21 @@ static int einj_timedout(u64 *t)
204static void check_vendor_extension(u64 paddr, 189static void check_vendor_extension(u64 paddr,
205 struct set_error_type_with_address *v5param) 190 struct set_error_type_with_address *v5param)
206{ 191{
207 int offset = readl(&v5param->vendor_extension); 192 int offset = v5param->vendor_extension;
208 struct vendor_error_type_extension *v; 193 struct vendor_error_type_extension *v;
209 u32 sbdf; 194 u32 sbdf;
210 195
211 if (!offset) 196 if (!offset)
212 return; 197 return;
213 v = ioremap(paddr + offset, sizeof(*v)); 198 v = acpi_os_map_memory(paddr + offset, sizeof(*v));
214 if (!v) 199 if (!v)
215 return; 200 return;
216 sbdf = readl(&v->pcie_sbdf); 201 sbdf = v->pcie_sbdf;
217 sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n", 202 sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
218 sbdf >> 24, (sbdf >> 16) & 0xff, 203 sbdf >> 24, (sbdf >> 16) & 0xff,
219 (sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7, 204 (sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7,
220 readw(&v->vendor_id), readw(&v->device_id), 205 v->vendor_id, v->device_id, v->rev_id);
221 readb(&v->rev_id)); 206 acpi_os_unmap_memory(v, sizeof(*v));
222 iounmap(v);
223} 207}
224 208
225static void *einj_get_parameter_address(void) 209static void *einj_get_parameter_address(void)
@@ -247,7 +231,7 @@ static void *einj_get_parameter_address(void)
247 if (paddrv5) { 231 if (paddrv5) {
248 struct set_error_type_with_address *v5param; 232 struct set_error_type_with_address *v5param;
249 233
250 v5param = ioremap(paddrv5, sizeof(*v5param)); 234 v5param = acpi_os_map_memory(paddrv5, sizeof(*v5param));
251 if (v5param) { 235 if (v5param) {
252 acpi5 = 1; 236 acpi5 = 1;
253 check_vendor_extension(paddrv5, v5param); 237 check_vendor_extension(paddrv5, v5param);
@@ -257,17 +241,17 @@ static void *einj_get_parameter_address(void)
257 if (paddrv4) { 241 if (paddrv4) {
258 struct einj_parameter *v4param; 242 struct einj_parameter *v4param;
259 243
260 v4param = ioremap(paddrv4, sizeof(*v4param)); 244 v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));
261 if (!v4param) 245 if (!v4param)
262 return 0; 246 return NULL;
263 if (readq(&v4param->reserved1) || readq(&v4param->reserved2)) { 247 if (v4param->reserved1 || v4param->reserved2) {
264 iounmap(v4param); 248 acpi_os_unmap_memory(v4param, sizeof(*v4param));
265 return 0; 249 return NULL;
266 } 250 }
267 return v4param; 251 return v4param;
268 } 252 }
269 253
270 return 0; 254 return NULL;
271} 255}
272 256
273/* do sanity check to trigger table */ 257/* do sanity check to trigger table */
@@ -276,7 +260,7 @@ static int einj_check_trigger_header(struct acpi_einj_trigger *trigger_tab)
276 if (trigger_tab->header_size != sizeof(struct acpi_einj_trigger)) 260 if (trigger_tab->header_size != sizeof(struct acpi_einj_trigger))
277 return -EINVAL; 261 return -EINVAL;
278 if (trigger_tab->table_size > PAGE_SIZE || 262 if (trigger_tab->table_size > PAGE_SIZE ||
279 trigger_tab->table_size <= trigger_tab->header_size) 263 trigger_tab->table_size < trigger_tab->header_size)
280 return -EINVAL; 264 return -EINVAL;
281 if (trigger_tab->entry_count != 265 if (trigger_tab->entry_count !=
282 (trigger_tab->table_size - trigger_tab->header_size) / 266 (trigger_tab->table_size - trigger_tab->header_size) /
@@ -340,6 +324,11 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
340 "The trigger error action table is invalid\n"); 324 "The trigger error action table is invalid\n");
341 goto out_rel_header; 325 goto out_rel_header;
342 } 326 }
327
328 /* No action structures in the TRIGGER_ERROR table, nothing to do */
329 if (!trigger_tab->entry_count)
330 goto out_rel_header;
331
343 rc = -EIO; 332 rc = -EIO;
344 table_size = trigger_tab->table_size; 333 table_size = trigger_tab->table_size;
345 r = request_mem_region(trigger_paddr + sizeof(*trigger_tab), 334 r = request_mem_region(trigger_paddr + sizeof(*trigger_tab),
@@ -435,41 +424,41 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
435 if (acpi5) { 424 if (acpi5) {
436 struct set_error_type_with_address *v5param = einj_param; 425 struct set_error_type_with_address *v5param = einj_param;
437 426
438 writel(type, &v5param->type); 427 v5param->type = type;
439 if (type & 0x80000000) { 428 if (type & 0x80000000) {
440 switch (vendor_flags) { 429 switch (vendor_flags) {
441 case SETWA_FLAGS_APICID: 430 case SETWA_FLAGS_APICID:
442 writel(param1, &v5param->apicid); 431 v5param->apicid = param1;
443 break; 432 break;
444 case SETWA_FLAGS_MEM: 433 case SETWA_FLAGS_MEM:
445 writeq(param1, &v5param->memory_address); 434 v5param->memory_address = param1;
446 writeq(param2, &v5param->memory_address_range); 435 v5param->memory_address_range = param2;
447 break; 436 break;
448 case SETWA_FLAGS_PCIE_SBDF: 437 case SETWA_FLAGS_PCIE_SBDF:
449 writel(param1, &v5param->pcie_sbdf); 438 v5param->pcie_sbdf = param1;
450 break; 439 break;
451 } 440 }
452 writel(vendor_flags, &v5param->flags); 441 v5param->flags = vendor_flags;
453 } else { 442 } else {
454 switch (type) { 443 switch (type) {
455 case ACPI_EINJ_PROCESSOR_CORRECTABLE: 444 case ACPI_EINJ_PROCESSOR_CORRECTABLE:
456 case ACPI_EINJ_PROCESSOR_UNCORRECTABLE: 445 case ACPI_EINJ_PROCESSOR_UNCORRECTABLE:
457 case ACPI_EINJ_PROCESSOR_FATAL: 446 case ACPI_EINJ_PROCESSOR_FATAL:
458 writel(param1, &v5param->apicid); 447 v5param->apicid = param1;
459 writel(SETWA_FLAGS_APICID, &v5param->flags); 448 v5param->flags = SETWA_FLAGS_APICID;
460 break; 449 break;
461 case ACPI_EINJ_MEMORY_CORRECTABLE: 450 case ACPI_EINJ_MEMORY_CORRECTABLE:
462 case ACPI_EINJ_MEMORY_UNCORRECTABLE: 451 case ACPI_EINJ_MEMORY_UNCORRECTABLE:
463 case ACPI_EINJ_MEMORY_FATAL: 452 case ACPI_EINJ_MEMORY_FATAL:
464 writeq(param1, &v5param->memory_address); 453 v5param->memory_address = param1;
465 writeq(param2, &v5param->memory_address_range); 454 v5param->memory_address_range = param2;
466 writel(SETWA_FLAGS_MEM, &v5param->flags); 455 v5param->flags = SETWA_FLAGS_MEM;
467 break; 456 break;
468 case ACPI_EINJ_PCIX_CORRECTABLE: 457 case ACPI_EINJ_PCIX_CORRECTABLE:
469 case ACPI_EINJ_PCIX_UNCORRECTABLE: 458 case ACPI_EINJ_PCIX_UNCORRECTABLE:
470 case ACPI_EINJ_PCIX_FATAL: 459 case ACPI_EINJ_PCIX_FATAL:
471 writel(param1, &v5param->pcie_sbdf); 460 v5param->pcie_sbdf = param1;
472 writel(SETWA_FLAGS_PCIE_SBDF, &v5param->flags); 461 v5param->flags = SETWA_FLAGS_PCIE_SBDF;
473 break; 462 break;
474 } 463 }
475 } 464 }
@@ -479,8 +468,8 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
479 return rc; 468 return rc;
480 if (einj_param) { 469 if (einj_param) {
481 struct einj_parameter *v4param = einj_param; 470 struct einj_parameter *v4param = einj_param;
482 writeq(param1, &v4param->param1); 471 v4param->param1 = param1;
483 writeq(param2, &v4param->param2); 472 v4param->param2 = param2;
484 } 473 }
485 } 474 }
486 rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION); 475 rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION);
@@ -731,8 +720,13 @@ static int __init einj_init(void)
731 return 0; 720 return 0;
732 721
733err_unmap: 722err_unmap:
734 if (einj_param) 723 if (einj_param) {
735 iounmap(einj_param); 724 acpi_size size = (acpi5) ?
725 sizeof(struct set_error_type_with_address) :
726 sizeof(struct einj_parameter);
727
728 acpi_os_unmap_memory(einj_param, size);
729 }
736 apei_exec_post_unmap_gars(&ctx); 730 apei_exec_post_unmap_gars(&ctx);
737err_release: 731err_release:
738 apei_resources_release(&einj_resources); 732 apei_resources_release(&einj_resources);
@@ -748,8 +742,13 @@ static void __exit einj_exit(void)
748{ 742{
749 struct apei_exec_context ctx; 743 struct apei_exec_context ctx;
750 744
751 if (einj_param) 745 if (einj_param) {
752 iounmap(einj_param); 746 acpi_size size = (acpi5) ?
747 sizeof(struct set_error_type_with_address) :
748 sizeof(struct einj_parameter);
749
750 acpi_os_unmap_memory(einj_param, size);
751 }
753 einj_exec_ctx_init(&ctx); 752 einj_exec_ctx_init(&ctx);
754 apei_exec_post_unmap_gars(&ctx); 753 apei_exec_post_unmap_gars(&ctx);
755 apei_resources_release(&einj_resources); 754 apei_resources_release(&einj_resources);
diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
deleted file mode 100644
index d4a5b3d3657b..000000000000
--- a/drivers/acpi/atomicio.c
+++ /dev/null
@@ -1,422 +0,0 @@
1/*
2 * atomicio.c - ACPI IO memory pre-mapping/post-unmapping, then
3 * accessing in atomic context.
4 *
5 * This is used for NMI handler to access IO memory area, because
6 * ioremap/iounmap can not be used in NMI handler. The IO memory area
7 * is pre-mapped in process context and accessed in NMI handler.
8 *
9 * Copyright (C) 2009-2010, Intel Corp.
10 * Author: Huang Ying <ying.huang@intel.com>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License version
14 * 2 as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/kernel.h>
27#include <linux/export.h>
28#include <linux/init.h>
29#include <linux/acpi.h>
30#include <linux/io.h>
31#include <linux/kref.h>
32#include <linux/rculist.h>
33#include <linux/interrupt.h>
34#include <linux/slab.h>
35#include <linux/mm.h>
36#include <linux/highmem.h>
37#include <acpi/atomicio.h>
38
39#define ACPI_PFX "ACPI: "
40
41static LIST_HEAD(acpi_iomaps);
42/*
43 * Used for mutual exclusion between writers of acpi_iomaps list, for
44 * synchronization between readers and writer, RCU is used.
45 */
46static DEFINE_SPINLOCK(acpi_iomaps_lock);
47
48struct acpi_iomap {
49 struct list_head list;
50 void __iomem *vaddr;
51 unsigned long size;
52 phys_addr_t paddr;
53 struct kref ref;
54};
55
56/* acpi_iomaps_lock or RCU read lock must be held before calling */
57static struct acpi_iomap *__acpi_find_iomap(phys_addr_t paddr,
58 unsigned long size)
59{
60 struct acpi_iomap *map;
61
62 list_for_each_entry_rcu(map, &acpi_iomaps, list) {
63 if (map->paddr + map->size >= paddr + size &&
64 map->paddr <= paddr)
65 return map;
66 }
67 return NULL;
68}
69
70/*
71 * Atomic "ioremap" used by NMI handler, if the specified IO memory
72 * area is not pre-mapped, NULL will be returned.
73 *
74 * acpi_iomaps_lock or RCU read lock must be held before calling
75 */
76static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
77 unsigned long size)
78{
79 struct acpi_iomap *map;
80
81 map = __acpi_find_iomap(paddr, size/8);
82 if (map)
83 return map->vaddr + (paddr - map->paddr);
84 else
85 return NULL;
86}
87
88/* acpi_iomaps_lock must be held before calling */
89static void __iomem *__acpi_try_ioremap(phys_addr_t paddr,
90 unsigned long size)
91{
92 struct acpi_iomap *map;
93
94 map = __acpi_find_iomap(paddr, size);
95 if (map) {
96 kref_get(&map->ref);
97 return map->vaddr + (paddr - map->paddr);
98 } else
99 return NULL;
100}
101
102#ifndef CONFIG_IA64
103#define should_use_kmap(pfn) page_is_ram(pfn)
104#else
105/* ioremap will take care of cache attributes */
106#define should_use_kmap(pfn) 0
107#endif
108
109static void __iomem *acpi_map(phys_addr_t pg_off, unsigned long pg_sz)
110{
111 unsigned long pfn;
112
113 pfn = pg_off >> PAGE_SHIFT;
114 if (should_use_kmap(pfn)) {
115 if (pg_sz > PAGE_SIZE)
116 return NULL;
117 return (void __iomem __force *)kmap(pfn_to_page(pfn));
118 } else
119 return ioremap(pg_off, pg_sz);
120}
121
122static void acpi_unmap(phys_addr_t pg_off, void __iomem *vaddr)
123{
124 unsigned long pfn;
125
126 pfn = pg_off >> PAGE_SHIFT;
127 if (page_is_ram(pfn))
128 kunmap(pfn_to_page(pfn));
129 else
130 iounmap(vaddr);
131}
132
133/*
134 * Used to pre-map the specified IO memory area. First try to find
135 * whether the area is already pre-mapped, if it is, increase the
136 * reference count (in __acpi_try_ioremap) and return; otherwise, do
137 * the real ioremap, and add the mapping into acpi_iomaps list.
138 */
139static void __iomem *acpi_pre_map(phys_addr_t paddr,
140 unsigned long size)
141{
142 void __iomem *vaddr;
143 struct acpi_iomap *map;
144 unsigned long pg_sz, flags;
145 phys_addr_t pg_off;
146
147 spin_lock_irqsave(&acpi_iomaps_lock, flags);
148 vaddr = __acpi_try_ioremap(paddr, size);
149 spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
150 if (vaddr)
151 return vaddr;
152
153 pg_off = paddr & PAGE_MASK;
154 pg_sz = ((paddr + size + PAGE_SIZE - 1) & PAGE_MASK) - pg_off;
155 vaddr = acpi_map(pg_off, pg_sz);
156 if (!vaddr)
157 return NULL;
158 map = kmalloc(sizeof(*map), GFP_KERNEL);
159 if (!map)
160 goto err_unmap;
161 INIT_LIST_HEAD(&map->list);
162 map->paddr = pg_off;
163 map->size = pg_sz;
164 map->vaddr = vaddr;
165 kref_init(&map->ref);
166
167 spin_lock_irqsave(&acpi_iomaps_lock, flags);
168 vaddr = __acpi_try_ioremap(paddr, size);
169 if (vaddr) {
170 spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
171 acpi_unmap(pg_off, map->vaddr);
172 kfree(map);
173 return vaddr;
174 }
175 list_add_tail_rcu(&map->list, &acpi_iomaps);
176 spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
177
178 return map->vaddr + (paddr - map->paddr);
179err_unmap:
180 acpi_unmap(pg_off, vaddr);
181 return NULL;
182}
183
184/* acpi_iomaps_lock must be held before calling */
185static void __acpi_kref_del_iomap(struct kref *ref)
186{
187 struct acpi_iomap *map;
188
189 map = container_of(ref, struct acpi_iomap, ref);
190 list_del_rcu(&map->list);
191}
192
193/*
194 * Used to post-unmap the specified IO memory area. The iounmap is
195 * done only if the reference count goes zero.
196 */
197static void acpi_post_unmap(phys_addr_t paddr, unsigned long size)
198{
199 struct acpi_iomap *map;
200 unsigned long flags;
201 int del;
202
203 spin_lock_irqsave(&acpi_iomaps_lock, flags);
204 map = __acpi_find_iomap(paddr, size);
205 BUG_ON(!map);
206 del = kref_put(&map->ref, __acpi_kref_del_iomap);
207 spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
208
209 if (!del)
210 return;
211
212 synchronize_rcu();
213 acpi_unmap(map->paddr, map->vaddr);
214 kfree(map);
215}
216
217/* In NMI handler, should set silent = 1 */
218static int acpi_check_gar(struct acpi_generic_address *reg,
219 u64 *paddr, int silent)
220{
221 u32 width, space_id;
222
223 width = reg->bit_width;
224 space_id = reg->space_id;
225 /* Handle possible alignment issues */
226 memcpy(paddr, &reg->address, sizeof(*paddr));
227 if (!*paddr) {
228 if (!silent)
229 pr_warning(FW_BUG ACPI_PFX
230 "Invalid physical address in GAR [0x%llx/%u/%u]\n",
231 *paddr, width, space_id);
232 return -EINVAL;
233 }
234
235 if ((width != 8) && (width != 16) && (width != 32) && (width != 64)) {
236 if (!silent)
237 pr_warning(FW_BUG ACPI_PFX
238 "Invalid bit width in GAR [0x%llx/%u/%u]\n",
239 *paddr, width, space_id);
240 return -EINVAL;
241 }
242
243 if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY &&
244 space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
245 if (!silent)
246 pr_warning(FW_BUG ACPI_PFX
247 "Invalid address space type in GAR [0x%llx/%u/%u]\n",
248 *paddr, width, space_id);
249 return -EINVAL;
250 }
251
252 return 0;
253}
254
255/* Pre-map, working on GAR */
256int acpi_pre_map_gar(struct acpi_generic_address *reg)
257{
258 u64 paddr;
259 void __iomem *vaddr;
260 int rc;
261
262 if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
263 return 0;
264
265 rc = acpi_check_gar(reg, &paddr, 0);
266 if (rc)
267 return rc;
268
269 vaddr = acpi_pre_map(paddr, reg->bit_width / 8);
270 if (!vaddr)
271 return -EIO;
272
273 return 0;
274}
275EXPORT_SYMBOL_GPL(acpi_pre_map_gar);
276
277/* Post-unmap, working on GAR */
278int acpi_post_unmap_gar(struct acpi_generic_address *reg)
279{
280 u64 paddr;
281 int rc;
282
283 if (reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
284 return 0;
285
286 rc = acpi_check_gar(reg, &paddr, 0);
287 if (rc)
288 return rc;
289
290 acpi_post_unmap(paddr, reg->bit_width / 8);
291
292 return 0;
293}
294EXPORT_SYMBOL_GPL(acpi_post_unmap_gar);
295
296#ifdef readq
297static inline u64 read64(const volatile void __iomem *addr)
298{
299 return readq(addr);
300}
301#else
302static inline u64 read64(const volatile void __iomem *addr)
303{
304 u64 l, h;
305 l = readl(addr);
306 h = readl(addr+4);
307 return l | (h << 32);
308}
309#endif
310
311/*
312 * Can be used in atomic (including NMI) or process context. RCU read
313 * lock can only be released after the IO memory area accessing.
314 */
315static int acpi_atomic_read_mem(u64 paddr, u64 *val, u32 width)
316{
317 void __iomem *addr;
318
319 rcu_read_lock();
320 addr = __acpi_ioremap_fast(paddr, width);
321 switch (width) {
322 case 8:
323 *val = readb(addr);
324 break;
325 case 16:
326 *val = readw(addr);
327 break;
328 case 32:
329 *val = readl(addr);
330 break;
331 case 64:
332 *val = read64(addr);
333 break;
334 default:
335 return -EINVAL;
336 }
337 rcu_read_unlock();
338
339 return 0;
340}
341
342#ifdef writeq
343static inline void write64(u64 val, volatile void __iomem *addr)
344{
345 writeq(val, addr);
346}
347#else
348static inline void write64(u64 val, volatile void __iomem *addr)
349{
350 writel(val, addr);
351 writel(val>>32, addr+4);
352}
353#endif
354
355static int acpi_atomic_write_mem(u64 paddr, u64 val, u32 width)
356{
357 void __iomem *addr;
358
359 rcu_read_lock();
360 addr = __acpi_ioremap_fast(paddr, width);
361 switch (width) {
362 case 8:
363 writeb(val, addr);
364 break;
365 case 16:
366 writew(val, addr);
367 break;
368 case 32:
369 writel(val, addr);
370 break;
371 case 64:
372 write64(val, addr);
373 break;
374 default:
375 return -EINVAL;
376 }
377 rcu_read_unlock();
378
379 return 0;
380}
381
382/* GAR accessing in atomic (including NMI) or process context */
383int acpi_atomic_read(u64 *val, struct acpi_generic_address *reg)
384{
385 u64 paddr;
386 int rc;
387
388 rc = acpi_check_gar(reg, &paddr, 1);
389 if (rc)
390 return rc;
391
392 *val = 0;
393 switch (reg->space_id) {
394 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
395 return acpi_atomic_read_mem(paddr, val, reg->bit_width);
396 case ACPI_ADR_SPACE_SYSTEM_IO:
397 return acpi_os_read_port(paddr, (u32 *)val, reg->bit_width);
398 default:
399 return -EINVAL;
400 }
401}
402EXPORT_SYMBOL_GPL(acpi_atomic_read);
403
404int acpi_atomic_write(u64 val, struct acpi_generic_address *reg)
405{
406 u64 paddr;
407 int rc;
408
409 rc = acpi_check_gar(reg, &paddr, 1);
410 if (rc)
411 return rc;
412
413 switch (reg->space_id) {
414 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
415 return acpi_atomic_write_mem(paddr, val, reg->bit_width);
416 case ACPI_ADR_SPACE_SYSTEM_IO:
417 return acpi_os_write_port(paddr, val, reg->bit_width);
418 default:
419 return -EINVAL;
420 }
421}
422EXPORT_SYMBOL_GPL(acpi_atomic_write);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index fcc12d842bcc..412a1e04a922 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -31,6 +31,7 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/highmem.h>
34#include <linux/pci.h> 35#include <linux/pci.h>
35#include <linux/interrupt.h> 36#include <linux/interrupt.h>
36#include <linux/kmod.h> 37#include <linux/kmod.h>
@@ -321,6 +322,37 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
321 return NULL; 322 return NULL;
322} 323}
323 324
325#ifndef CONFIG_IA64
326#define should_use_kmap(pfn) page_is_ram(pfn)
327#else
328/* ioremap will take care of cache attributes */
329#define should_use_kmap(pfn) 0
330#endif
331
332static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
333{
334 unsigned long pfn;
335
336 pfn = pg_off >> PAGE_SHIFT;
337 if (should_use_kmap(pfn)) {
338 if (pg_sz > PAGE_SIZE)
339 return NULL;
340 return (void __iomem __force *)kmap(pfn_to_page(pfn));
341 } else
342 return acpi_os_ioremap(pg_off, pg_sz);
343}
344
345static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
346{
347 unsigned long pfn;
348
349 pfn = pg_off >> PAGE_SHIFT;
350 if (page_is_ram(pfn))
351 kunmap(pfn_to_page(pfn));
352 else
353 iounmap(vaddr);
354}
355
324void __iomem *__init_refok 356void __iomem *__init_refok
325acpi_os_map_memory(acpi_physical_address phys, acpi_size size) 357acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
326{ 358{
@@ -353,7 +385,7 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
353 385
354 pg_off = round_down(phys, PAGE_SIZE); 386 pg_off = round_down(phys, PAGE_SIZE);
355 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; 387 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
356 virt = acpi_os_ioremap(pg_off, pg_sz); 388 virt = acpi_map(pg_off, pg_sz);
357 if (!virt) { 389 if (!virt) {
358 mutex_unlock(&acpi_ioremap_lock); 390 mutex_unlock(&acpi_ioremap_lock);
359 kfree(map); 391 kfree(map);
@@ -384,7 +416,7 @@ static void acpi_os_map_cleanup(struct acpi_ioremap *map)
384{ 416{
385 if (!map->refcount) { 417 if (!map->refcount) {
386 synchronize_rcu(); 418 synchronize_rcu();
387 iounmap(map->virt); 419 acpi_unmap(map->phys, map->virt);
388 kfree(map); 420 kfree(map);
389 } 421 }
390} 422}
@@ -710,6 +742,67 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
710 return AE_OK; 742 return AE_OK;
711} 743}
712 744
745#ifdef readq
746static inline u64 read64(const volatile void __iomem *addr)
747{
748 return readq(addr);
749}
750#else
751static inline u64 read64(const volatile void __iomem *addr)
752{
753 u64 l, h;
754 l = readl(addr);
755 h = readl(addr+4);
756 return l | (h << 32);
757}
758#endif
759
760acpi_status
761acpi_os_read_memory64(acpi_physical_address phys_addr, u64 *value, u32 width)
762{
763 void __iomem *virt_addr;
764 unsigned int size = width / 8;
765 bool unmap = false;
766 u64 dummy;
767
768 rcu_read_lock();
769 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
770 if (!virt_addr) {
771 rcu_read_unlock();
772 virt_addr = acpi_os_ioremap(phys_addr, size);
773 if (!virt_addr)
774 return AE_BAD_ADDRESS;
775 unmap = true;
776 }
777
778 if (!value)
779 value = &dummy;
780
781 switch (width) {
782 case 8:
783 *(u8 *) value = readb(virt_addr);
784 break;
785 case 16:
786 *(u16 *) value = readw(virt_addr);
787 break;
788 case 32:
789 *(u32 *) value = readl(virt_addr);
790 break;
791 case 64:
792 *(u64 *) value = read64(virt_addr);
793 break;
794 default:
795 BUG();
796 }
797
798 if (unmap)
799 iounmap(virt_addr);
800 else
801 rcu_read_unlock();
802
803 return AE_OK;
804}
805
713acpi_status 806acpi_status
714acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) 807acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
715{ 808{
@@ -749,6 +842,61 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
749 return AE_OK; 842 return AE_OK;
750} 843}
751 844
845#ifdef writeq
846static inline void write64(u64 val, volatile void __iomem *addr)
847{
848 writeq(val, addr);
849}
850#else
851static inline void write64(u64 val, volatile void __iomem *addr)
852{
853 writel(val, addr);
854 writel(val>>32, addr+4);
855}
856#endif
857
858acpi_status
859acpi_os_write_memory64(acpi_physical_address phys_addr, u64 value, u32 width)
860{
861 void __iomem *virt_addr;
862 unsigned int size = width / 8;
863 bool unmap = false;
864
865 rcu_read_lock();
866 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
867 if (!virt_addr) {
868 rcu_read_unlock();
869 virt_addr = acpi_os_ioremap(phys_addr, size);
870 if (!virt_addr)
871 return AE_BAD_ADDRESS;
872 unmap = true;
873 }
874
875 switch (width) {
876 case 8:
877 writeb(value, virt_addr);
878 break;
879 case 16:
880 writew(value, virt_addr);
881 break;
882 case 32:
883 writel(value, virt_addr);
884 break;
885 case 64:
886 write64(value, virt_addr);
887 break;
888 default:
889 BUG();
890 }
891
892 if (unmap)
893 iounmap(virt_addr);
894 else
895 rcu_read_unlock();
896
897 return AE_OK;
898}
899
752acpi_status 900acpi_status
753acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, 901acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
754 u64 *value, u32 width) 902 u64 *value, u32 width)
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 0034ede38710..2b805d7ef317 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -84,7 +84,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type);
84static void acpi_processor_notify(struct acpi_device *device, u32 event); 84static void acpi_processor_notify(struct acpi_device *device, u32 event);
85static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr); 85static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr);
86static int acpi_processor_handle_eject(struct acpi_processor *pr); 86static int acpi_processor_handle_eject(struct acpi_processor *pr);
87 87static int acpi_processor_start(struct acpi_processor *pr);
88 88
89static const struct acpi_device_id processor_device_ids[] = { 89static const struct acpi_device_id processor_device_ids[] = {
90 {ACPI_PROCESSOR_OBJECT_HID, 0}, 90 {ACPI_PROCESSOR_OBJECT_HID, 0},
@@ -423,10 +423,29 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
423 struct acpi_processor *pr = per_cpu(processors, cpu); 423 struct acpi_processor *pr = per_cpu(processors, cpu);
424 424
425 if (action == CPU_ONLINE && pr) { 425 if (action == CPU_ONLINE && pr) {
426 acpi_processor_ppc_has_changed(pr, 0); 426 /* CPU got physically hotplugged and onlined the first time:
427 acpi_processor_hotplug(pr); 427 * Initialize missing things
428 acpi_processor_reevaluate_tstate(pr, action); 428 */
429 acpi_processor_tstate_has_changed(pr); 429 if (pr->flags.need_hotplug_init) {
430 struct cpuidle_driver *idle_driver =
431 cpuidle_get_driver();
432
433 printk(KERN_INFO "Will online and init hotplugged "
434 "CPU: %d\n", pr->id);
435 WARN(acpi_processor_start(pr), "Failed to start CPU:"
436 " %d\n", pr->id);
437 pr->flags.need_hotplug_init = 0;
438 if (idle_driver && !strcmp(idle_driver->name,
439 "intel_idle")) {
440 intel_idle_cpu_init(pr->id);
441 }
442 /* Normal CPU soft online event */
443 } else {
444 acpi_processor_ppc_has_changed(pr, 0);
445 acpi_processor_cst_has_changed(pr);
446 acpi_processor_reevaluate_tstate(pr, action);
447 acpi_processor_tstate_has_changed(pr);
448 }
430 } 449 }
431 if (action == CPU_DEAD && pr) { 450 if (action == CPU_DEAD && pr) {
432 /* invalidate the flag.throttling after one CPU is offline */ 451 /* invalidate the flag.throttling after one CPU is offline */
@@ -440,6 +459,71 @@ static struct notifier_block acpi_cpu_notifier =
440 .notifier_call = acpi_cpu_soft_notify, 459 .notifier_call = acpi_cpu_soft_notify,
441}; 460};
442 461
462/*
463 * acpi_processor_start() is called by the cpu_hotplug_notifier func:
464 * acpi_cpu_soft_notify(). Getting it __cpuinit{data} is difficult, the
465 * root cause seem to be that acpi_processor_uninstall_hotplug_notify()
466 * is in the module_exit (__exit) func. Allowing acpi_processor_start()
467 * to not be in __cpuinit section, but being called from __cpuinit funcs
468 * via __ref looks like the right thing to do here.
469 */
470static __ref int acpi_processor_start(struct acpi_processor *pr)
471{
472 struct acpi_device *device = per_cpu(processor_device_array, pr->id);
473 int result = 0;
474
475#ifdef CONFIG_CPU_FREQ
476 acpi_processor_ppc_has_changed(pr, 0);
477#endif
478 acpi_processor_get_throttling_info(pr);
479 acpi_processor_get_limit_info(pr);
480
481 if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
482 acpi_processor_power_init(pr, device);
483
484 pr->cdev = thermal_cooling_device_register("Processor", device,
485 &processor_cooling_ops);
486 if (IS_ERR(pr->cdev)) {
487 result = PTR_ERR(pr->cdev);
488 goto err_power_exit;
489 }
490
491 dev_dbg(&device->dev, "registered as cooling_device%d\n",
492 pr->cdev->id);
493
494 result = sysfs_create_link(&device->dev.kobj,
495 &pr->cdev->device.kobj,
496 "thermal_cooling");
497 if (result) {
498 printk(KERN_ERR PREFIX "Create sysfs link\n");
499 goto err_thermal_unregister;
500 }
501 result = sysfs_create_link(&pr->cdev->device.kobj,
502 &device->dev.kobj,
503 "device");
504 if (result) {
505 printk(KERN_ERR PREFIX "Create sysfs link\n");
506 goto err_remove_sysfs_thermal;
507 }
508
509 return 0;
510
511err_remove_sysfs_thermal:
512 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
513err_thermal_unregister:
514 thermal_cooling_device_unregister(pr->cdev);
515err_power_exit:
516 acpi_processor_power_exit(pr, device);
517
518 return result;
519}
520
521/*
522 * Do not put anything in here which needs the core to be online.
523 * For example MSR access or setting up things which check for cpuinfo_x86
524 * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc.
525 * Such things have to be put in and set up above in acpi_processor_start()
526 */
443static int __cpuinit acpi_processor_add(struct acpi_device *device) 527static int __cpuinit acpi_processor_add(struct acpi_device *device)
444{ 528{
445 struct acpi_processor *pr = NULL; 529 struct acpi_processor *pr = NULL;
@@ -495,48 +579,27 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
495 goto err_free_cpumask; 579 goto err_free_cpumask;
496 } 580 }
497 581
498#ifdef CONFIG_CPU_FREQ 582 /*
499 acpi_processor_ppc_has_changed(pr, 0); 583 * Do not start hotplugged CPUs now, but when they
500#endif 584 * are onlined the first time
501 acpi_processor_get_throttling_info(pr); 585 */
502 acpi_processor_get_limit_info(pr); 586 if (pr->flags.need_hotplug_init)
503 587 return 0;
504 if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
505 acpi_processor_power_init(pr, device);
506
507 pr->cdev = thermal_cooling_device_register("Processor", device,
508 &processor_cooling_ops);
509 if (IS_ERR(pr->cdev)) {
510 result = PTR_ERR(pr->cdev);
511 goto err_power_exit;
512 }
513 588
514 dev_dbg(&device->dev, "registered as cooling_device%d\n", 589 /*
515 pr->cdev->id); 590 * Do not start hotplugged CPUs now, but when they
591 * are onlined the first time
592 */
593 if (pr->flags.need_hotplug_init)
594 return 0;
516 595
517 result = sysfs_create_link(&device->dev.kobj, 596 result = acpi_processor_start(pr);
518 &pr->cdev->device.kobj, 597 if (result)
519 "thermal_cooling");
520 if (result) {
521 printk(KERN_ERR PREFIX "Create sysfs link\n");
522 goto err_thermal_unregister;
523 }
524 result = sysfs_create_link(&pr->cdev->device.kobj,
525 &device->dev.kobj,
526 "device");
527 if (result) {
528 printk(KERN_ERR PREFIX "Create sysfs link\n");
529 goto err_remove_sysfs; 598 goto err_remove_sysfs;
530 }
531 599
532 return 0; 600 return 0;
533 601
534err_remove_sysfs: 602err_remove_sysfs:
535 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
536err_thermal_unregister:
537 thermal_cooling_device_unregister(pr->cdev);
538err_power_exit:
539 acpi_processor_power_exit(pr, device);
540 sysfs_remove_link(&device->dev.kobj, "sysdev"); 603 sysfs_remove_link(&device->dev.kobj, "sysdev");
541err_free_cpumask: 604err_free_cpumask:
542 free_cpumask_var(pr->throttling.shared_cpu_map); 605 free_cpumask_var(pr->throttling.shared_cpu_map);
@@ -735,6 +798,17 @@ static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr)
735 return AE_ERROR; 798 return AE_ERROR;
736 } 799 }
737 800
801 /* CPU got hot-plugged, but cpu_data is not initialized yet
802 * Set flag to delay cpu_idle/throttling initialization
803 * in:
804 * acpi_processor_add()
805 * acpi_processor_get_info()
806 * and do it when the CPU gets online the first time
807 * TBD: Cleanup above functions and try to do this more elegant.
808 */
809 printk(KERN_INFO "CPU %d got hotplugged\n", pr->id);
810 pr->flags.need_hotplug_init = 1;
811
738 return AE_OK; 812 return AE_OK;
739} 813}
740 814
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 0a7ed69546ba..ca191ff97844 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -438,6 +438,14 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
438 }, 438 },
439 { 439 {
440 .callback = init_nvs_nosave, 440 .callback = init_nvs_nosave,
441 .ident = "Sony Vaio VPCCW29FX",
442 .matches = {
443 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
444 DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"),
445 },
446 },
447 {
448 .callback = init_nvs_nosave,
441 .ident = "Averatec AV1020-ED2", 449 .ident = "Averatec AV1020-ED2",
442 .matches = { 450 .matches = {
443 DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"), 451 DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"),
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 2c8272dd93c4..610f9997a403 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -1,6 +1,6 @@
1# Makefile for the Linux device tree 1# Makefile for the Linux device tree
2 2
3obj-y := core.o sys.o bus.o dd.o syscore.o \ 3obj-y := core.o bus.o dd.o syscore.o \
4 driver.o class.o platform.o \ 4 driver.o class.o platform.o \
5 cpu.o firmware.o init.o map.o devres.o \ 5 cpu.o firmware.o init.o map.o devres.o \
6 attribute_container.o transport_class.o \ 6 attribute_container.o transport_class.o \
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 99dc5921e1dd..40fb12288ce2 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -915,9 +915,10 @@ static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
915 915
916/** 916/**
917 * __bus_register - register a driver-core subsystem 917 * __bus_register - register a driver-core subsystem
918 * @bus: bus. 918 * @bus: bus to register
919 * @key: lockdep class key
919 * 920 *
920 * Once we have that, we registered the bus with the kobject 921 * Once we have that, we register the bus with the kobject
921 * infrastructure, then register the children subsystems it has: 922 * infrastructure, then register the children subsystems it has:
922 * the devices and drivers that belong to the subsystem. 923 * the devices and drivers that belong to the subsystem.
923 */ 924 */
@@ -1220,8 +1221,8 @@ static void system_root_device_release(struct device *dev)
1220} 1221}
1221/** 1222/**
1222 * subsys_system_register - register a subsystem at /sys/devices/system/ 1223 * subsys_system_register - register a subsystem at /sys/devices/system/
1223 * @subsys - system subsystem 1224 * @subsys: system subsystem
1224 * @groups - default attributes for the root device 1225 * @groups: default attributes for the root device
1225 * 1226 *
1226 * All 'system' subsystems have a /sys/devices/system/<name> root device 1227 * All 'system' subsystems have a /sys/devices/system/<name> root device
1227 * with the name of the subsystem. The root device can carry subsystem- 1228 * with the name of the subsystem. The root device can carry subsystem-
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4a67cc0c8b37..74dda4f697f9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -632,6 +632,11 @@ static void klist_children_put(struct klist_node *n)
632 * may be used for reference counting of @dev after calling this 632 * may be used for reference counting of @dev after calling this
633 * function. 633 * function.
634 * 634 *
635 * All fields in @dev must be initialized by the caller to 0, except
636 * for those explicitly set to some other value. The simplest
637 * approach is to use kzalloc() to allocate the structure containing
638 * @dev.
639 *
635 * NOTE: Use put_device() to give up your reference instead of freeing 640 * NOTE: Use put_device() to give up your reference instead of freeing
636 * @dev directly once you have called this function. 641 * @dev directly once you have called this function.
637 */ 642 */
@@ -930,6 +935,13 @@ int device_private_init(struct device *dev)
930 * to the global and sibling lists for the device, then 935 * to the global and sibling lists for the device, then
931 * adds it to the other relevant subsystems of the driver model. 936 * adds it to the other relevant subsystems of the driver model.
932 * 937 *
938 * Do not call this routine or device_register() more than once for
939 * any device structure. The driver model core is not designed to work
940 * with devices that get unregistered and then spring back to life.
941 * (Among other things, it's very hard to guarantee that all references
942 * to the previous incarnation of @dev have been dropped.) Allocate
943 * and register a fresh new struct device instead.
944 *
933 * NOTE: _Never_ directly free @dev after calling this function, even 945 * NOTE: _Never_ directly free @dev after calling this function, even
934 * if it returned an error! Always use put_device() to give up your 946 * if it returned an error! Always use put_device() to give up your
935 * reference instead. 947 * reference instead.
@@ -1022,7 +1034,7 @@ int device_add(struct device *dev)
1022 device_pm_add(dev); 1034 device_pm_add(dev);
1023 1035
1024 /* Notify clients of device addition. This call must come 1036 /* Notify clients of device addition. This call must come
1025 * after dpm_sysf_add() and before kobject_uevent(). 1037 * after dpm_sysfs_add() and before kobject_uevent().
1026 */ 1038 */
1027 if (dev->bus) 1039 if (dev->bus)
1028 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 1040 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
@@ -1090,6 +1102,9 @@ name_error:
1090 * have a clearly defined need to use and refcount the device 1102 * have a clearly defined need to use and refcount the device
1091 * before it is added to the hierarchy. 1103 * before it is added to the hierarchy.
1092 * 1104 *
1105 * For more information, see the kerneldoc for device_initialize()
1106 * and device_add().
1107 *
1093 * NOTE: _Never_ directly free @dev after calling this function, even 1108 * NOTE: _Never_ directly free @dev after calling this function, even
1094 * if it returned an error! Always use put_device() to give up the 1109 * if it returned an error! Always use put_device() to give up the
1095 * reference initialized in this function instead. 1110 * reference initialized in this function instead.
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 26ab358dac62..6c9387d646ec 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -525,8 +525,7 @@ static int _request_firmware(const struct firmware **firmware_p,
525 if (!firmware) { 525 if (!firmware) {
526 dev_err(device, "%s: kmalloc(struct firmware) failed\n", 526 dev_err(device, "%s: kmalloc(struct firmware) failed\n",
527 __func__); 527 __func__);
528 retval = -ENOMEM; 528 return -ENOMEM;
529 goto out;
530 } 529 }
531 530
532 if (fw_get_builtin_firmware(firmware, name)) { 531 if (fw_get_builtin_firmware(firmware, name)) {
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index be10a4ff6609..65558034318f 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -284,6 +284,9 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
284 map->precious_reg = config->precious_reg; 284 map->precious_reg = config->precious_reg;
285 map->cache_type = config->cache_type; 285 map->cache_type = config->cache_type;
286 286
287 map->cache_bypass = false;
288 map->cache_only = false;
289
287 ret = regcache_init(map, config); 290 ret = regcache_init(map, config);
288 291
289 mutex_unlock(&map->lock); 292 mutex_unlock(&map->lock);
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
deleted file mode 100644
index 409f5ce78829..000000000000
--- a/drivers/base/sys.c
+++ /dev/null
@@ -1,383 +0,0 @@
1/*
2 * sys.c - pseudo-bus for system 'devices' (cpus, PICs, timers, etc)
3 *
4 * Copyright (c) 2002-3 Patrick Mochel
5 * 2002-3 Open Source Development Lab
6 *
7 * This file is released under the GPLv2
8 *
9 * This exports a 'system' bus type.
10 * By default, a 'sys' bus gets added to the root of the system. There will
11 * always be core system devices. Devices can use sysdev_register() to
12 * add themselves as children of the system bus.
13 */
14
15#include <linux/sysdev.h>
16#include <linux/err.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/string.h>
21#include <linux/pm.h>
22#include <linux/device.h>
23#include <linux/mutex.h>
24#include <linux/interrupt.h>
25
26#include "base.h"
27
28#define to_sysdev(k) container_of(k, struct sys_device, kobj)
29#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)
30
31
32static ssize_t
33sysdev_show(struct kobject *kobj, struct attribute *attr, char *buffer)
34{
35 struct sys_device *sysdev = to_sysdev(kobj);
36 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
37
38 if (sysdev_attr->show)
39 return sysdev_attr->show(sysdev, sysdev_attr, buffer);
40 return -EIO;
41}
42
43
44static ssize_t
45sysdev_store(struct kobject *kobj, struct attribute *attr,
46 const char *buffer, size_t count)
47{
48 struct sys_device *sysdev = to_sysdev(kobj);
49 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
50
51 if (sysdev_attr->store)
52 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
53 return -EIO;
54}
55
56static const struct sysfs_ops sysfs_ops = {
57 .show = sysdev_show,
58 .store = sysdev_store,
59};
60
61static struct kobj_type ktype_sysdev = {
62 .sysfs_ops = &sysfs_ops,
63};
64
65
66int sysdev_create_file(struct sys_device *s, struct sysdev_attribute *a)
67{
68 return sysfs_create_file(&s->kobj, &a->attr);
69}
70
71
72void sysdev_remove_file(struct sys_device *s, struct sysdev_attribute *a)
73{
74 sysfs_remove_file(&s->kobj, &a->attr);
75}
76
77EXPORT_SYMBOL_GPL(sysdev_create_file);
78EXPORT_SYMBOL_GPL(sysdev_remove_file);
79
80#define to_sysdev_class(k) container_of(k, struct sysdev_class, kset.kobj)
81#define to_sysdev_class_attr(a) container_of(a, \
82 struct sysdev_class_attribute, attr)
83
84static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
85 char *buffer)
86{
87 struct sysdev_class *class = to_sysdev_class(kobj);
88 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
89
90 if (class_attr->show)
91 return class_attr->show(class, class_attr, buffer);
92 return -EIO;
93}
94
95static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
96 const char *buffer, size_t count)
97{
98 struct sysdev_class *class = to_sysdev_class(kobj);
99 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
100
101 if (class_attr->store)
102 return class_attr->store(class, class_attr, buffer, count);
103 return -EIO;
104}
105
106static const struct sysfs_ops sysfs_class_ops = {
107 .show = sysdev_class_show,
108 .store = sysdev_class_store,
109};
110
111static struct kobj_type ktype_sysdev_class = {
112 .sysfs_ops = &sysfs_class_ops,
113};
114
115int sysdev_class_create_file(struct sysdev_class *c,
116 struct sysdev_class_attribute *a)
117{
118 return sysfs_create_file(&c->kset.kobj, &a->attr);
119}
120EXPORT_SYMBOL_GPL(sysdev_class_create_file);
121
122void sysdev_class_remove_file(struct sysdev_class *c,
123 struct sysdev_class_attribute *a)
124{
125 sysfs_remove_file(&c->kset.kobj, &a->attr);
126}
127EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
128
129extern struct kset *system_kset;
130
131int sysdev_class_register(struct sysdev_class *cls)
132{
133 int retval;
134
135 pr_debug("Registering sysdev class '%s'\n", cls->name);
136
137 INIT_LIST_HEAD(&cls->drivers);
138 memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
139 cls->kset.kobj.parent = &system_kset->kobj;
140 cls->kset.kobj.ktype = &ktype_sysdev_class;
141 cls->kset.kobj.kset = system_kset;
142
143 retval = kobject_set_name(&cls->kset.kobj, "%s", cls->name);
144 if (retval)
145 return retval;
146
147 retval = kset_register(&cls->kset);
148 if (!retval && cls->attrs)
149 retval = sysfs_create_files(&cls->kset.kobj,
150 (const struct attribute **)cls->attrs);
151 return retval;
152}
153
154void sysdev_class_unregister(struct sysdev_class *cls)
155{
156 pr_debug("Unregistering sysdev class '%s'\n",
157 kobject_name(&cls->kset.kobj));
158 if (cls->attrs)
159 sysfs_remove_files(&cls->kset.kobj,
160 (const struct attribute **)cls->attrs);
161 kset_unregister(&cls->kset);
162}
163
164EXPORT_SYMBOL_GPL(sysdev_class_register);
165EXPORT_SYMBOL_GPL(sysdev_class_unregister);
166
167static DEFINE_MUTEX(sysdev_drivers_lock);
168
169/*
170 * @dev != NULL means that we're unwinding because some drv->add()
171 * failed for some reason. You need to grab sysdev_drivers_lock before
172 * calling this.
173 */
174static void __sysdev_driver_remove(struct sysdev_class *cls,
175 struct sysdev_driver *drv,
176 struct sys_device *from_dev)
177{
178 struct sys_device *dev = from_dev;
179
180 list_del_init(&drv->entry);
181 if (!cls)
182 return;
183
184 if (!drv->remove)
185 goto kset_put;
186
187 if (dev)
188 list_for_each_entry_continue_reverse(dev, &cls->kset.list,
189 kobj.entry)
190 drv->remove(dev);
191 else
192 list_for_each_entry(dev, &cls->kset.list, kobj.entry)
193 drv->remove(dev);
194
195kset_put:
196 kset_put(&cls->kset);
197}
198
199/**
200 * sysdev_driver_register - Register auxiliary driver
201 * @cls: Device class driver belongs to.
202 * @drv: Driver.
203 *
204 * @drv is inserted into @cls->drivers to be
205 * called on each operation on devices of that class. The refcount
206 * of @cls is incremented.
207 */
208int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
209{
210 struct sys_device *dev = NULL;
211 int err = 0;
212
213 if (!cls) {
214 WARN(1, KERN_WARNING "sysdev: invalid class passed to %s!\n",
215 __func__);
216 return -EINVAL;
217 }
218
219 /* Check whether this driver has already been added to a class. */
220 if (drv->entry.next && !list_empty(&drv->entry))
221 WARN(1, KERN_WARNING "sysdev: class %s: driver (%p) has already"
222 " been registered to a class, something is wrong, but "
223 "will forge on!\n", cls->name, drv);
224
225 mutex_lock(&sysdev_drivers_lock);
226 if (cls && kset_get(&cls->kset)) {
227 list_add_tail(&drv->entry, &cls->drivers);
228
229 /* If devices of this class already exist, tell the driver */
230 if (drv->add) {
231 list_for_each_entry(dev, &cls->kset.list, kobj.entry) {
232 err = drv->add(dev);
233 if (err)
234 goto unwind;
235 }
236 }
237 } else {
238 err = -EINVAL;
239 WARN(1, KERN_ERR "%s: invalid device class\n", __func__);
240 }
241
242 goto unlock;
243
244unwind:
245 __sysdev_driver_remove(cls, drv, dev);
246
247unlock:
248 mutex_unlock(&sysdev_drivers_lock);
249 return err;
250}
251
252/**
253 * sysdev_driver_unregister - Remove an auxiliary driver.
254 * @cls: Class driver belongs to.
255 * @drv: Driver.
256 */
257void sysdev_driver_unregister(struct sysdev_class *cls,
258 struct sysdev_driver *drv)
259{
260 mutex_lock(&sysdev_drivers_lock);
261 __sysdev_driver_remove(cls, drv, NULL);
262 mutex_unlock(&sysdev_drivers_lock);
263}
264EXPORT_SYMBOL_GPL(sysdev_driver_register);
265EXPORT_SYMBOL_GPL(sysdev_driver_unregister);
266
267/**
268 * sysdev_register - add a system device to the tree
269 * @sysdev: device in question
270 *
271 */
272int sysdev_register(struct sys_device *sysdev)
273{
274 int error;
275 struct sysdev_class *cls = sysdev->cls;
276
277 if (!cls)
278 return -EINVAL;
279
280 pr_debug("Registering sys device of class '%s'\n",
281 kobject_name(&cls->kset.kobj));
282
283 /* initialize the kobject to 0, in case it had previously been used */
284 memset(&sysdev->kobj, 0x00, sizeof(struct kobject));
285
286 /* Make sure the kset is set */
287 sysdev->kobj.kset = &cls->kset;
288
289 /* Register the object */
290 error = kobject_init_and_add(&sysdev->kobj, &ktype_sysdev, NULL,
291 "%s%d", kobject_name(&cls->kset.kobj),
292 sysdev->id);
293
294 if (!error) {
295 struct sysdev_driver *drv;
296
297 pr_debug("Registering sys device '%s'\n",
298 kobject_name(&sysdev->kobj));
299
300 mutex_lock(&sysdev_drivers_lock);
301 /* Generic notification is implicit, because it's that
302 * code that should have called us.
303 */
304
305 /* Notify class auxiliary drivers */
306 list_for_each_entry(drv, &cls->drivers, entry) {
307 if (drv->add)
308 drv->add(sysdev);
309 }
310 mutex_unlock(&sysdev_drivers_lock);
311 kobject_uevent(&sysdev->kobj, KOBJ_ADD);
312 }
313
314 return error;
315}
316
317void sysdev_unregister(struct sys_device *sysdev)
318{
319 struct sysdev_driver *drv;
320
321 mutex_lock(&sysdev_drivers_lock);
322 list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
323 if (drv->remove)
324 drv->remove(sysdev);
325 }
326 mutex_unlock(&sysdev_drivers_lock);
327
328 kobject_put(&sysdev->kobj);
329}
330
331EXPORT_SYMBOL_GPL(sysdev_register);
332EXPORT_SYMBOL_GPL(sysdev_unregister);
333
334#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr)
335
336ssize_t sysdev_store_ulong(struct sys_device *sysdev,
337 struct sysdev_attribute *attr,
338 const char *buf, size_t size)
339{
340 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
341 char *end;
342 unsigned long new = simple_strtoul(buf, &end, 0);
343 if (end == buf)
344 return -EINVAL;
345 *(unsigned long *)(ea->var) = new;
346 /* Always return full write size even if we didn't consume all */
347 return size;
348}
349EXPORT_SYMBOL_GPL(sysdev_store_ulong);
350
351ssize_t sysdev_show_ulong(struct sys_device *sysdev,
352 struct sysdev_attribute *attr,
353 char *buf)
354{
355 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
356 return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var));
357}
358EXPORT_SYMBOL_GPL(sysdev_show_ulong);
359
360ssize_t sysdev_store_int(struct sys_device *sysdev,
361 struct sysdev_attribute *attr,
362 const char *buf, size_t size)
363{
364 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
365 char *end;
366 long new = simple_strtol(buf, &end, 0);
367 if (end == buf || new > INT_MAX || new < INT_MIN)
368 return -EINVAL;
369 *(int *)(ea->var) = new;
370 /* Always return full write size even if we didn't consume all */
371 return size;
372}
373EXPORT_SYMBOL_GPL(sysdev_store_int);
374
375ssize_t sysdev_show_int(struct sys_device *sysdev,
376 struct sysdev_attribute *attr,
377 char *buf)
378{
379 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
380 return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var));
381}
382EXPORT_SYMBOL_GPL(sysdev_show_int);
383
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 4b71647782d0..317c28ce8328 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -194,10 +194,10 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
194 194
195err_out: 195err_out:
196 if (bridge->driver->needs_scratch_page) { 196 if (bridge->driver->needs_scratch_page) {
197 void *va = page_address(bridge->scratch_page_page); 197 struct page *page = bridge->scratch_page_page;
198 198
199 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP); 199 bridge->driver->agp_destroy_page(page, AGP_PAGE_DESTROY_UNMAP);
200 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE); 200 bridge->driver->agp_destroy_page(page, AGP_PAGE_DESTROY_FREE);
201 } 201 }
202 if (got_gatt) 202 if (got_gatt)
203 bridge->driver->free_gatt_table(bridge); 203 bridge->driver->free_gatt_table(bridge);
@@ -221,10 +221,10 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
221 221
222 if (bridge->driver->agp_destroy_page && 222 if (bridge->driver->agp_destroy_page &&
223 bridge->driver->needs_scratch_page) { 223 bridge->driver->needs_scratch_page) {
224 void *va = page_address(bridge->scratch_page_page); 224 struct page *page = bridge->scratch_page_page;
225 225
226 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP); 226 bridge->driver->agp_destroy_page(page, AGP_PAGE_DESTROY_UNMAP);
227 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE); 227 bridge->driver->agp_destroy_page(page, AGP_PAGE_DESTROY_FREE);
228 } 228 }
229} 229}
230 230
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 3f46772f0cb2..ba23790450e9 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -101,7 +101,7 @@ static int drm_add_magic(struct drm_master *master, struct drm_file *priv,
101 * Searches and unlinks the entry in drm_device::magiclist with the magic 101 * Searches and unlinks the entry in drm_device::magiclist with the magic
102 * number hash key, while holding the drm_device::struct_mutex lock. 102 * number hash key, while holding the drm_device::struct_mutex lock.
103 */ 103 */
104static int drm_remove_magic(struct drm_master *master, drm_magic_t magic) 104int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
105{ 105{
106 struct drm_magic_entry *pt; 106 struct drm_magic_entry *pt;
107 struct drm_hash_item *hash; 107 struct drm_hash_item *hash;
@@ -136,6 +136,8 @@ static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
136 * If there is a magic number in drm_file::magic then use it, otherwise 136 * If there is a magic number in drm_file::magic then use it, otherwise
137 * searches an unique non-zero magic number and add it associating it with \p 137 * searches an unique non-zero magic number and add it associating it with \p
138 * file_priv. 138 * file_priv.
139 * This ioctl needs protection by the drm_global_mutex, which protects
140 * struct drm_file::magic and struct drm_magic_entry::priv.
139 */ 141 */
140int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv) 142int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
141{ 143{
@@ -173,6 +175,8 @@ int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
173 * \return zero if authentication successed, or a negative number otherwise. 175 * \return zero if authentication successed, or a negative number otherwise.
174 * 176 *
175 * Checks if \p file_priv is associated with the magic number passed in \arg. 177 * Checks if \p file_priv is associated with the magic number passed in \arg.
178 * This ioctl needs protection by the drm_global_mutex, which protects
179 * struct drm_file::magic and struct drm_magic_entry::priv.
176 */ 180 */
177int drm_authmagic(struct drm_device *dev, void *data, 181int drm_authmagic(struct drm_device *dev, void *data,
178 struct drm_file *file_priv) 182 struct drm_file *file_priv)
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index c00cf154cc0b..6263b0147598 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -487,6 +487,11 @@ int drm_release(struct inode *inode, struct file *filp)
487 (long)old_encode_dev(file_priv->minor->device), 487 (long)old_encode_dev(file_priv->minor->device),
488 dev->open_count); 488 dev->open_count);
489 489
490 /* Release any auth tokens that might point to this file_priv,
491 (do that under the drm_global_mutex) */
492 if (file_priv->magic)
493 (void) drm_remove_magic(file_priv->master, file_priv->magic);
494
490 /* if the master has gone away we can't do anything with the lock */ 495 /* if the master has gone away we can't do anything with the lock */
491 if (file_priv->minor->master) 496 if (file_priv->minor->master)
492 drm_master_release(dev, filp); 497 drm_master_release(dev, filp);
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 396e60ce8114..f8625e290728 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -140,7 +140,7 @@ int drm_gem_object_init(struct drm_device *dev,
140 obj->dev = dev; 140 obj->dev = dev;
141 obj->filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); 141 obj->filp = shmem_file_setup("drm mm object", size, VM_NORESERVE);
142 if (IS_ERR(obj->filp)) 142 if (IS_ERR(obj->filp))
143 return -ENOMEM; 143 return PTR_ERR(obj->filp);
144 144
145 kref_init(&obj->refcount); 145 kref_init(&obj->refcount);
146 atomic_set(&obj->handle_count, 0); 146 atomic_set(&obj->handle_count, 0);
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index f9aaa56eae07..b9e5266c341b 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -13,7 +13,7 @@ config DRM_EXYNOS
13 13
14config DRM_EXYNOS_FIMD 14config DRM_EXYNOS_FIMD
15 tristate "Exynos DRM FIMD" 15 tristate "Exynos DRM FIMD"
16 depends on DRM_EXYNOS 16 depends on DRM_EXYNOS && !FB_S3C
17 default n 17 default n
18 help 18 help
19 Choose this option if you want to use Exynos FIMD for DRM. 19 Choose this option if you want to use Exynos FIMD for DRM.
@@ -21,7 +21,7 @@ config DRM_EXYNOS_FIMD
21 21
22config DRM_EXYNOS_HDMI 22config DRM_EXYNOS_HDMI
23 tristate "Exynos DRM HDMI" 23 tristate "Exynos DRM HDMI"
24 depends on DRM_EXYNOS 24 depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_TV
25 help 25 help
26 Choose this option if you want to use Exynos HDMI for DRM. 26 Choose this option if you want to use Exynos HDMI for DRM.
27 If M is selected, the module will be called exynos_drm_hdmi 27 If M is selected, the module will be called exynos_drm_hdmi
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index ca83139cd309..b6a737d196ae 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -158,7 +158,8 @@ static void fimd_dpms(struct device *subdrv_dev, int mode)
158 case DRM_MODE_DPMS_STANDBY: 158 case DRM_MODE_DPMS_STANDBY:
159 case DRM_MODE_DPMS_SUSPEND: 159 case DRM_MODE_DPMS_SUSPEND:
160 case DRM_MODE_DPMS_OFF: 160 case DRM_MODE_DPMS_OFF:
161 pm_runtime_put_sync(subdrv_dev); 161 if (!ctx->suspended)
162 pm_runtime_put_sync(subdrv_dev);
162 break; 163 break;
163 default: 164 default:
164 DRM_DEBUG_KMS("unspecified mode %d\n", mode); 165 DRM_DEBUG_KMS("unspecified mode %d\n", mode);
@@ -734,6 +735,46 @@ static void fimd_clear_win(struct fimd_context *ctx, int win)
734 writel(val, ctx->regs + SHADOWCON); 735 writel(val, ctx->regs + SHADOWCON);
735} 736}
736 737
738static int fimd_power_on(struct fimd_context *ctx, bool enable)
739{
740 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
741 struct device *dev = subdrv->manager.dev;
742
743 DRM_DEBUG_KMS("%s\n", __FILE__);
744
745 if (enable != false && enable != true)
746 return -EINVAL;
747
748 if (enable) {
749 int ret;
750
751 ret = clk_enable(ctx->bus_clk);
752 if (ret < 0)
753 return ret;
754
755 ret = clk_enable(ctx->lcd_clk);
756 if (ret < 0) {
757 clk_disable(ctx->bus_clk);
758 return ret;
759 }
760
761 ctx->suspended = false;
762
763 /* if vblank was enabled status, enable it again. */
764 if (test_and_clear_bit(0, &ctx->irq_flags))
765 fimd_enable_vblank(dev);
766
767 fimd_apply(dev);
768 } else {
769 clk_disable(ctx->lcd_clk);
770 clk_disable(ctx->bus_clk);
771
772 ctx->suspended = true;
773 }
774
775 return 0;
776}
777
737static int __devinit fimd_probe(struct platform_device *pdev) 778static int __devinit fimd_probe(struct platform_device *pdev)
738{ 779{
739 struct device *dev = &pdev->dev; 780 struct device *dev = &pdev->dev;
@@ -911,39 +952,30 @@ out:
911#ifdef CONFIG_PM_SLEEP 952#ifdef CONFIG_PM_SLEEP
912static int fimd_suspend(struct device *dev) 953static int fimd_suspend(struct device *dev)
913{ 954{
914 int ret; 955 struct fimd_context *ctx = get_fimd_context(dev);
915 956
916 if (pm_runtime_suspended(dev)) 957 if (pm_runtime_suspended(dev))
917 return 0; 958 return 0;
918 959
919 ret = pm_runtime_suspend(dev); 960 /*
920 if (ret < 0) 961 * do not use pm_runtime_suspend(). if pm_runtime_suspend() is
921 return ret; 962 * called here, an error would be returned by that interface
922 963 * because the usage_count of pm runtime is more than 1.
923 return 0; 964 */
965 return fimd_power_on(ctx, false);
924} 966}
925 967
926static int fimd_resume(struct device *dev) 968static int fimd_resume(struct device *dev)
927{ 969{
928 int ret; 970 struct fimd_context *ctx = get_fimd_context(dev);
929
930 ret = pm_runtime_resume(dev);
931 if (ret < 0) {
932 DRM_ERROR("failed to resume runtime pm.\n");
933 return ret;
934 }
935
936 pm_runtime_disable(dev);
937
938 ret = pm_runtime_set_active(dev);
939 if (ret < 0) {
940 DRM_ERROR("failed to active runtime pm.\n");
941 pm_runtime_enable(dev);
942 pm_runtime_suspend(dev);
943 return ret;
944 }
945 971
946 pm_runtime_enable(dev); 972 /*
973 * if entered to sleep when lcd panel was on, the usage_count
974 * of pm runtime would still be 1 so in this case, fimd driver
975 * should be on directly not drawing on pm runtime interface.
976 */
977 if (!pm_runtime_suspended(dev))
978 return fimd_power_on(ctx, true);
947 979
948 return 0; 980 return 0;
949} 981}
@@ -956,39 +988,16 @@ static int fimd_runtime_suspend(struct device *dev)
956 988
957 DRM_DEBUG_KMS("%s\n", __FILE__); 989 DRM_DEBUG_KMS("%s\n", __FILE__);
958 990
959 clk_disable(ctx->lcd_clk); 991 return fimd_power_on(ctx, false);
960 clk_disable(ctx->bus_clk);
961
962 ctx->suspended = true;
963 return 0;
964} 992}
965 993
966static int fimd_runtime_resume(struct device *dev) 994static int fimd_runtime_resume(struct device *dev)
967{ 995{
968 struct fimd_context *ctx = get_fimd_context(dev); 996 struct fimd_context *ctx = get_fimd_context(dev);
969 int ret;
970 997
971 DRM_DEBUG_KMS("%s\n", __FILE__); 998 DRM_DEBUG_KMS("%s\n", __FILE__);
972 999
973 ret = clk_enable(ctx->bus_clk); 1000 return fimd_power_on(ctx, true);
974 if (ret < 0)
975 return ret;
976
977 ret = clk_enable(ctx->lcd_clk);
978 if (ret < 0) {
979 clk_disable(ctx->bus_clk);
980 return ret;
981 }
982
983 ctx->suspended = false;
984
985 /* if vblank was enabled status, enable it again. */
986 if (test_and_clear_bit(0, &ctx->irq_flags))
987 fimd_enable_vblank(dev);
988
989 fimd_apply(dev);
990
991 return 0;
992} 1001}
993#endif 1002#endif
994 1003
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index f48f7ce92f5f..3429d3fd93f3 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -1116,8 +1116,8 @@ err_ddc:
1116err_iomap: 1116err_iomap:
1117 iounmap(hdata->regs); 1117 iounmap(hdata->regs);
1118err_req_region: 1118err_req_region:
1119 release_resource(hdata->regs_res); 1119 release_mem_region(hdata->regs_res->start,
1120 kfree(hdata->regs_res); 1120 resource_size(hdata->regs_res));
1121err_resource: 1121err_resource:
1122 hdmi_resources_cleanup(hdata); 1122 hdmi_resources_cleanup(hdata);
1123err_data: 1123err_data:
@@ -1145,8 +1145,8 @@ static int __devexit hdmi_remove(struct platform_device *pdev)
1145 1145
1146 iounmap(hdata->regs); 1146 iounmap(hdata->regs);
1147 1147
1148 release_resource(hdata->regs_res); 1148 release_mem_region(hdata->regs_res->start,
1149 kfree(hdata->regs_res); 1149 resource_size(hdata->regs_res));
1150 1150
1151 /* hdmiphy i2c driver */ 1151 /* hdmiphy i2c driver */
1152 i2c_del_driver(&hdmiphy_driver); 1152 i2c_del_driver(&hdmiphy_driver);
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 791c0ef1a65b..830dfdd6bf15 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -113,12 +113,12 @@ static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info)
113 113
114void psbfb_suspend(struct drm_device *dev) 114void psbfb_suspend(struct drm_device *dev)
115{ 115{
116 struct drm_framebuffer *fb = 0; 116 struct drm_framebuffer *fb;
117 struct psb_framebuffer *psbfb = to_psb_fb(fb);
118 117
119 console_lock(); 118 console_lock();
120 mutex_lock(&dev->mode_config.mutex); 119 mutex_lock(&dev->mode_config.mutex);
121 list_for_each_entry(fb, &dev->mode_config.fb_list, head) { 120 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
121 struct psb_framebuffer *psbfb = to_psb_fb(fb);
122 struct fb_info *info = psbfb->fbdev; 122 struct fb_info *info = psbfb->fbdev;
123 fb_set_suspend(info, 1); 123 fb_set_suspend(info, 1);
124 drm_fb_helper_blank(FB_BLANK_POWERDOWN, info); 124 drm_fb_helper_blank(FB_BLANK_POWERDOWN, info);
@@ -129,12 +129,12 @@ void psbfb_suspend(struct drm_device *dev)
129 129
130void psbfb_resume(struct drm_device *dev) 130void psbfb_resume(struct drm_device *dev)
131{ 131{
132 struct drm_framebuffer *fb = 0; 132 struct drm_framebuffer *fb;
133 struct psb_framebuffer *psbfb = to_psb_fb(fb);
134 133
135 console_lock(); 134 console_lock();
136 mutex_lock(&dev->mode_config.mutex); 135 mutex_lock(&dev->mode_config.mutex);
137 list_for_each_entry(fb, &dev->mode_config.fb_list, head) { 136 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
137 struct psb_framebuffer *psbfb = to_psb_fb(fb);
138 struct fb_info *info = psbfb->fbdev; 138 struct fb_info *info = psbfb->fbdev;
139 fb_set_suspend(info, 0); 139 fb_set_suspend(info, 0);
140 drm_fb_helper_blank(FB_BLANK_UNBLANK, info); 140 drm_fb_helper_blank(FB_BLANK_UNBLANK, info);
diff --git a/drivers/gpu/drm/gma500/gtt.c b/drivers/gpu/drm/gma500/gtt.c
index e770bd190a5c..5d5330f667f1 100644
--- a/drivers/gpu/drm/gma500/gtt.c
+++ b/drivers/gpu/drm/gma500/gtt.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <drm/drmP.h> 22#include <drm/drmP.h>
23#include <linux/shmem_fs.h>
23#include "psb_drv.h" 24#include "psb_drv.h"
24 25
25 26
@@ -203,9 +204,7 @@ static int psb_gtt_attach_pages(struct gtt_range *gt)
203 gt->npage = pages; 204 gt->npage = pages;
204 205
205 for (i = 0; i < pages; i++) { 206 for (i = 0; i < pages; i++) {
206 /* FIXME: needs updating as per mail from Hugh Dickins */ 207 p = shmem_read_mapping_page(mapping, i);
207 p = read_cache_page_gfp(mapping, i,
208 __GFP_COLD | GFP_KERNEL);
209 if (IS_ERR(p)) 208 if (IS_ERR(p))
210 goto err; 209 goto err;
211 gt->pages[i] = p; 210 gt->pages[i] = p;
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index f7c17b239833..7f4b4e10246e 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -886,7 +886,7 @@ static int i810_flush_queue(struct drm_device *dev)
886} 886}
887 887
888/* Must be called with the lock held */ 888/* Must be called with the lock held */
889void i810_driver_reclaim_buffers(struct drm_device *dev, 889static void i810_reclaim_buffers(struct drm_device *dev,
890 struct drm_file *file_priv) 890 struct drm_file *file_priv)
891{ 891{
892 struct drm_device_dma *dma = dev->dma; 892 struct drm_device_dma *dma = dev->dma;
@@ -1223,17 +1223,12 @@ void i810_driver_preclose(struct drm_device *dev, struct drm_file *file_priv)
1223 if (dev_priv->page_flipping) 1223 if (dev_priv->page_flipping)
1224 i810_do_cleanup_pageflip(dev); 1224 i810_do_cleanup_pageflip(dev);
1225 } 1225 }
1226}
1226 1227
1227 if (file_priv->master && file_priv->master->lock.hw_lock) { 1228void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
1228 drm_idlelock_take(&file_priv->master->lock); 1229 struct drm_file *file_priv)
1229 i810_driver_reclaim_buffers(dev, file_priv); 1230{
1230 drm_idlelock_release(&file_priv->master->lock); 1231 i810_reclaim_buffers(dev, file_priv);
1231 } else {
1232 /* master disappeared, clean up stuff anyway and hope nothing
1233 * goes wrong */
1234 i810_driver_reclaim_buffers(dev, file_priv);
1235 }
1236
1237} 1232}
1238 1233
1239int i810_driver_dma_quiescent(struct drm_device *dev) 1234int i810_driver_dma_quiescent(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 053f1ee58393..ec12f7dc717a 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -63,6 +63,7 @@ static struct drm_driver driver = {
63 .lastclose = i810_driver_lastclose, 63 .lastclose = i810_driver_lastclose,
64 .preclose = i810_driver_preclose, 64 .preclose = i810_driver_preclose,
65 .device_is_agp = i810_driver_device_is_agp, 65 .device_is_agp = i810_driver_device_is_agp,
66 .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked,
66 .dma_quiescent = i810_driver_dma_quiescent, 67 .dma_quiescent = i810_driver_dma_quiescent,
67 .ioctls = i810_ioctls, 68 .ioctls = i810_ioctls,
68 .fops = &i810_driver_fops, 69 .fops = &i810_driver_fops,
diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
index 6e0acad9e0f5..c9339f481795 100644
--- a/drivers/gpu/drm/i810/i810_drv.h
+++ b/drivers/gpu/drm/i810/i810_drv.h
@@ -116,12 +116,14 @@ typedef struct drm_i810_private {
116 116
117 /* i810_dma.c */ 117 /* i810_dma.c */
118extern int i810_driver_dma_quiescent(struct drm_device *dev); 118extern int i810_driver_dma_quiescent(struct drm_device *dev);
119void i810_driver_reclaim_buffers(struct drm_device *dev, 119extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
120 struct drm_file *file_priv); 120 struct drm_file *file_priv);
121extern int i810_driver_load(struct drm_device *, unsigned long flags); 121extern int i810_driver_load(struct drm_device *, unsigned long flags);
122extern void i810_driver_lastclose(struct drm_device *dev); 122extern void i810_driver_lastclose(struct drm_device *dev);
123extern void i810_driver_preclose(struct drm_device *dev, 123extern void i810_driver_preclose(struct drm_device *dev,
124 struct drm_file *file_priv); 124 struct drm_file *file_priv);
125extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
126 struct drm_file *file_priv);
125extern int i810_driver_device_is_agp(struct drm_device *dev); 127extern int i810_driver_device_is_agp(struct drm_device *dev);
126 128
127extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 129extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 11807989f918..deaa657292b4 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -121,11 +121,11 @@ static const char *cache_level_str(int type)
121static void 121static void
122describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) 122describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
123{ 123{
124 seq_printf(m, "%p: %s%s %8zd %04x %04x %d %d%s%s%s", 124 seq_printf(m, "%p: %s%s %8zdKiB %04x %04x %d %d%s%s%s",
125 &obj->base, 125 &obj->base,
126 get_pin_flag(obj), 126 get_pin_flag(obj),
127 get_tiling_flag(obj), 127 get_tiling_flag(obj),
128 obj->base.size, 128 obj->base.size / 1024,
129 obj->base.read_domains, 129 obj->base.read_domains,
130 obj->base.write_domain, 130 obj->base.write_domain,
131 obj->last_rendering_seqno, 131 obj->last_rendering_seqno,
@@ -653,7 +653,7 @@ static int i915_ringbuffer_info(struct seq_file *m, void *data)
653 seq_printf(m, " Size : %08x\n", ring->size); 653 seq_printf(m, " Size : %08x\n", ring->size);
654 seq_printf(m, " Active : %08x\n", intel_ring_get_active_head(ring)); 654 seq_printf(m, " Active : %08x\n", intel_ring_get_active_head(ring));
655 seq_printf(m, " NOPID : %08x\n", I915_READ_NOPID(ring)); 655 seq_printf(m, " NOPID : %08x\n", I915_READ_NOPID(ring));
656 if (IS_GEN6(dev)) { 656 if (IS_GEN6(dev) || IS_GEN7(dev)) {
657 seq_printf(m, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring)); 657 seq_printf(m, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring));
658 seq_printf(m, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring)); 658 seq_printf(m, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring));
659 } 659 }
@@ -1075,6 +1075,7 @@ static int gen6_drpc_info(struct seq_file *m)
1075 struct drm_device *dev = node->minor->dev; 1075 struct drm_device *dev = node->minor->dev;
1076 struct drm_i915_private *dev_priv = dev->dev_private; 1076 struct drm_i915_private *dev_priv = dev->dev_private;
1077 u32 rpmodectl1, gt_core_status, rcctl1; 1077 u32 rpmodectl1, gt_core_status, rcctl1;
1078 unsigned forcewake_count;
1078 int count=0, ret; 1079 int count=0, ret;
1079 1080
1080 1081
@@ -1082,9 +1083,13 @@ static int gen6_drpc_info(struct seq_file *m)
1082 if (ret) 1083 if (ret)
1083 return ret; 1084 return ret;
1084 1085
1085 if (atomic_read(&dev_priv->forcewake_count)) { 1086 spin_lock_irq(&dev_priv->gt_lock);
1086 seq_printf(m, "RC information inaccurate because userspace " 1087 forcewake_count = dev_priv->forcewake_count;
1087 "holds a reference \n"); 1088 spin_unlock_irq(&dev_priv->gt_lock);
1089
1090 if (forcewake_count) {
1091 seq_printf(m, "RC information inaccurate because somebody "
1092 "holds a forcewake reference \n");
1088 } else { 1093 } else {
1089 /* NB: we cannot use forcewake, else we read the wrong values */ 1094 /* NB: we cannot use forcewake, else we read the wrong values */
1090 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) 1095 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
@@ -1106,7 +1111,7 @@ static int gen6_drpc_info(struct seq_file *m)
1106 seq_printf(m, "SW control enabled: %s\n", 1111 seq_printf(m, "SW control enabled: %s\n",
1107 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == 1112 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1108 GEN6_RP_MEDIA_SW_MODE)); 1113 GEN6_RP_MEDIA_SW_MODE));
1109 seq_printf(m, "RC6 Enabled: %s\n", 1114 seq_printf(m, "RC1e Enabled: %s\n",
1110 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); 1115 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1111 seq_printf(m, "RC6 Enabled: %s\n", 1116 seq_printf(m, "RC6 Enabled: %s\n",
1112 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); 1117 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
@@ -1398,9 +1403,13 @@ static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data)
1398 struct drm_info_node *node = (struct drm_info_node *) m->private; 1403 struct drm_info_node *node = (struct drm_info_node *) m->private;
1399 struct drm_device *dev = node->minor->dev; 1404 struct drm_device *dev = node->minor->dev;
1400 struct drm_i915_private *dev_priv = dev->dev_private; 1405 struct drm_i915_private *dev_priv = dev->dev_private;
1406 unsigned forcewake_count;
1407
1408 spin_lock_irq(&dev_priv->gt_lock);
1409 forcewake_count = dev_priv->forcewake_count;
1410 spin_unlock_irq(&dev_priv->gt_lock);
1401 1411
1402 seq_printf(m, "forcewake count = %d\n", 1412 seq_printf(m, "forcewake count = %u\n", forcewake_count);
1403 atomic_read(&dev_priv->forcewake_count));
1404 1413
1405 return 0; 1414 return 0;
1406} 1415}
@@ -1665,7 +1674,7 @@ static int i915_forcewake_open(struct inode *inode, struct file *file)
1665 struct drm_i915_private *dev_priv = dev->dev_private; 1674 struct drm_i915_private *dev_priv = dev->dev_private;
1666 int ret; 1675 int ret;
1667 1676
1668 if (!IS_GEN6(dev)) 1677 if (INTEL_INFO(dev)->gen < 6)
1669 return 0; 1678 return 0;
1670 1679
1671 ret = mutex_lock_interruptible(&dev->struct_mutex); 1680 ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -1682,7 +1691,7 @@ int i915_forcewake_release(struct inode *inode, struct file *file)
1682 struct drm_device *dev = inode->i_private; 1691 struct drm_device *dev = inode->i_private;
1683 struct drm_i915_private *dev_priv = dev->dev_private; 1692 struct drm_i915_private *dev_priv = dev->dev_private;
1684 1693
1685 if (!IS_GEN6(dev)) 1694 if (INTEL_INFO(dev)->gen < 6)
1686 return 0; 1695 return 0;
1687 1696
1688 /* 1697 /*
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 5f4d5893e983..ddfe3d902b2a 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2045,6 +2045,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
2045 if (!IS_I945G(dev) && !IS_I945GM(dev)) 2045 if (!IS_I945G(dev) && !IS_I945GM(dev))
2046 pci_enable_msi(dev->pdev); 2046 pci_enable_msi(dev->pdev);
2047 2047
2048 spin_lock_init(&dev_priv->gt_lock);
2048 spin_lock_init(&dev_priv->irq_lock); 2049 spin_lock_init(&dev_priv->irq_lock);
2049 spin_lock_init(&dev_priv->error_lock); 2050 spin_lock_init(&dev_priv->error_lock);
2050 spin_lock_init(&dev_priv->rps_lock); 2051 spin_lock_init(&dev_priv->rps_lock);
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 8f7187915b0d..308f81913562 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -368,11 +368,12 @@ void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv)
368 */ 368 */
369void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv) 369void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)
370{ 370{
371 WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex)); 371 unsigned long irqflags;
372 372
373 /* Forcewake is atomic in case we get in here without the lock */ 373 spin_lock_irqsave(&dev_priv->gt_lock, irqflags);
374 if (atomic_add_return(1, &dev_priv->forcewake_count) == 1) 374 if (dev_priv->forcewake_count++ == 0)
375 dev_priv->display.force_wake_get(dev_priv); 375 dev_priv->display.force_wake_get(dev_priv);
376 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags);
376} 377}
377 378
378void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv) 379void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv)
@@ -392,10 +393,12 @@ void __gen6_gt_force_wake_mt_put(struct drm_i915_private *dev_priv)
392 */ 393 */
393void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv) 394void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv)
394{ 395{
395 WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex)); 396 unsigned long irqflags;
396 397
397 if (atomic_dec_and_test(&dev_priv->forcewake_count)) 398 spin_lock_irqsave(&dev_priv->gt_lock, irqflags);
399 if (--dev_priv->forcewake_count == 0)
398 dev_priv->display.force_wake_put(dev_priv); 400 dev_priv->display.force_wake_put(dev_priv);
401 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags);
399} 402}
400 403
401void __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv) 404void __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)
@@ -597,9 +600,36 @@ static int ironlake_do_reset(struct drm_device *dev, u8 flags)
597static int gen6_do_reset(struct drm_device *dev, u8 flags) 600static int gen6_do_reset(struct drm_device *dev, u8 flags)
598{ 601{
599 struct drm_i915_private *dev_priv = dev->dev_private; 602 struct drm_i915_private *dev_priv = dev->dev_private;
603 int ret;
604 unsigned long irqflags;
600 605
601 I915_WRITE(GEN6_GDRST, GEN6_GRDOM_FULL); 606 /* Hold gt_lock across reset to prevent any register access
602 return wait_for((I915_READ(GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500); 607 * with forcewake not set correctly
608 */
609 spin_lock_irqsave(&dev_priv->gt_lock, irqflags);
610
611 /* Reset the chip */
612
613 /* GEN6_GDRST is not in the gt power well, no need to check
614 * for fifo space for the write or forcewake the chip for
615 * the read
616 */
617 I915_WRITE_NOTRACE(GEN6_GDRST, GEN6_GRDOM_FULL);
618
619 /* Spin waiting for the device to ack the reset request */
620 ret = wait_for((I915_READ_NOTRACE(GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500);
621
622 /* If reset with a user forcewake, try to restore, otherwise turn it off */
623 if (dev_priv->forcewake_count)
624 dev_priv->display.force_wake_get(dev_priv);
625 else
626 dev_priv->display.force_wake_put(dev_priv);
627
628 /* Restore fifo count */
629 dev_priv->gt_fifo_count = I915_READ_NOTRACE(GT_FIFO_FREE_ENTRIES);
630
631 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags);
632 return ret;
603} 633}
604 634
605/** 635/**
@@ -643,9 +673,6 @@ int i915_reset(struct drm_device *dev, u8 flags)
643 case 7: 673 case 7:
644 case 6: 674 case 6:
645 ret = gen6_do_reset(dev, flags); 675 ret = gen6_do_reset(dev, flags);
646 /* If reset with a user forcewake, try to restore */
647 if (atomic_read(&dev_priv->forcewake_count))
648 __gen6_gt_force_wake_get(dev_priv);
649 break; 676 break;
650 case 5: 677 case 5:
651 ret = ironlake_do_reset(dev, flags); 678 ret = ironlake_do_reset(dev, flags);
@@ -927,9 +954,14 @@ MODULE_LICENSE("GPL and additional rights");
927u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ 954u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
928 u##x val = 0; \ 955 u##x val = 0; \
929 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 956 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
930 gen6_gt_force_wake_get(dev_priv); \ 957 unsigned long irqflags; \
958 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
959 if (dev_priv->forcewake_count == 0) \
960 dev_priv->display.force_wake_get(dev_priv); \
931 val = read##y(dev_priv->regs + reg); \ 961 val = read##y(dev_priv->regs + reg); \
932 gen6_gt_force_wake_put(dev_priv); \ 962 if (dev_priv->forcewake_count == 0) \
963 dev_priv->display.force_wake_put(dev_priv); \
964 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
933 } else { \ 965 } else { \
934 val = read##y(dev_priv->regs + reg); \ 966 val = read##y(dev_priv->regs + reg); \
935 } \ 967 } \
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 602bc80baabb..9689ca38b2b3 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -288,7 +288,13 @@ typedef struct drm_i915_private {
288 int relative_constants_mode; 288 int relative_constants_mode;
289 289
290 void __iomem *regs; 290 void __iomem *regs;
291 u32 gt_fifo_count; 291 /** gt_fifo_count and the subsequent register write are synchronized
292 * with dev->struct_mutex. */
293 unsigned gt_fifo_count;
294 /** forcewake_count is protected by gt_lock */
295 unsigned forcewake_count;
296 /** gt_lock is also taken in irq contexts. */
297 struct spinlock gt_lock;
292 298
293 struct intel_gmbus { 299 struct intel_gmbus {
294 struct i2c_adapter adapter; 300 struct i2c_adapter adapter;
@@ -741,8 +747,6 @@ typedef struct drm_i915_private {
741 747
742 struct drm_property *broadcast_rgb_property; 748 struct drm_property *broadcast_rgb_property;
743 struct drm_property *force_audio_property; 749 struct drm_property *force_audio_property;
744
745 atomic_t forcewake_count;
746} drm_i915_private_t; 750} drm_i915_private_t;
747 751
748enum i915_cache_level { 752enum i915_cache_level {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 5d433fc11ace..5bd4361ea84d 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1751,7 +1751,8 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
1751 INIT_WORK(&dev_priv->rps_work, gen6_pm_rps_work); 1751 INIT_WORK(&dev_priv->rps_work, gen6_pm_rps_work);
1752 1752
1753 I915_WRITE(HWSTAM, 0xeffe); 1753 I915_WRITE(HWSTAM, 0xeffe);
1754 if (IS_GEN6(dev) || IS_GEN7(dev)) { 1754
1755 if (IS_GEN6(dev)) {
1755 /* Workaround stalls observed on Sandy Bridge GPUs by 1756 /* Workaround stalls observed on Sandy Bridge GPUs by
1756 * making the blitter command streamer generate a 1757 * making the blitter command streamer generate a
1757 * write to the Hardware Status Page for 1758 * write to the Hardware Status Page for
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 7886e4fb60e3..2b5eb229ff2c 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -28,14 +28,19 @@
28#include "drm.h" 28#include "drm.h"
29#include "i915_drm.h" 29#include "i915_drm.h"
30#include "intel_drv.h" 30#include "intel_drv.h"
31#include "i915_reg.h"
31 32
32static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe) 33static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe)
33{ 34{
34 struct drm_i915_private *dev_priv = dev->dev_private; 35 struct drm_i915_private *dev_priv = dev->dev_private;
35 u32 dpll_reg; 36 u32 dpll_reg;
36 37
38 /* On IVB, 3rd pipe shares PLL with another one */
39 if (pipe > 1)
40 return false;
41
37 if (HAS_PCH_SPLIT(dev)) 42 if (HAS_PCH_SPLIT(dev))
38 dpll_reg = (pipe == PIPE_A) ? _PCH_DPLL_A : _PCH_DPLL_B; 43 dpll_reg = PCH_DPLL(pipe);
39 else 44 else
40 dpll_reg = (pipe == PIPE_A) ? _DPLL_A : _DPLL_B; 45 dpll_reg = (pipe == PIPE_A) ? _DPLL_A : _DPLL_B;
41 46
@@ -822,7 +827,7 @@ int i915_save_state(struct drm_device *dev)
822 827
823 if (IS_IRONLAKE_M(dev)) 828 if (IS_IRONLAKE_M(dev))
824 ironlake_disable_drps(dev); 829 ironlake_disable_drps(dev);
825 if (IS_GEN6(dev)) 830 if (INTEL_INFO(dev)->gen >= 6)
826 gen6_disable_rps(dev); 831 gen6_disable_rps(dev);
827 832
828 /* Cache mode state */ 833 /* Cache mode state */
@@ -881,7 +886,7 @@ int i915_restore_state(struct drm_device *dev)
881 intel_init_emon(dev); 886 intel_init_emon(dev);
882 } 887 }
883 888
884 if (IS_GEN6(dev)) { 889 if (INTEL_INFO(dev)->gen >= 6) {
885 gen6_enable_rps(dev_priv); 890 gen6_enable_rps(dev_priv);
886 gen6_update_ring_freq(dev_priv); 891 gen6_update_ring_freq(dev_priv);
887 } 892 }
diff --git a/drivers/gpu/drm/i915/intel_bios.h b/drivers/gpu/drm/i915/intel_bios.h
index 8af3735e27c6..dbda6e3bdf07 100644
--- a/drivers/gpu/drm/i915/intel_bios.h
+++ b/drivers/gpu/drm/i915/intel_bios.h
@@ -467,8 +467,12 @@ struct edp_link_params {
467struct bdb_edp { 467struct bdb_edp {
468 struct edp_power_seq power_seqs[16]; 468 struct edp_power_seq power_seqs[16];
469 u32 color_depth; 469 u32 color_depth;
470 u32 sdrrs_msa_timing_delay;
471 struct edp_link_params link_params[16]; 470 struct edp_link_params link_params[16];
471 u32 sdrrs_msa_timing_delay;
472
473 /* ith bit indicates enabled/disabled for (i+1)th panel */
474 u16 edp_s3d_feature;
475 u16 edp_t3_optimization;
472} __attribute__ ((packed)); 476} __attribute__ ((packed));
473 477
474void intel_setup_bios(struct drm_device *dev); 478void intel_setup_bios(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index fee0ad02c6d0..dd729d46a61f 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -24,6 +24,7 @@
24 * Eric Anholt <eric@anholt.net> 24 * Eric Anholt <eric@anholt.net>
25 */ 25 */
26 26
27#include <linux/dmi.h>
27#include <linux/i2c.h> 28#include <linux/i2c.h>
28#include <linux/slab.h> 29#include <linux/slab.h>
29#include "drmP.h" 30#include "drmP.h"
@@ -540,6 +541,24 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = {
540 .destroy = intel_encoder_destroy, 541 .destroy = intel_encoder_destroy,
541}; 542};
542 543
544static int __init intel_no_crt_dmi_callback(const struct dmi_system_id *id)
545{
546 DRM_DEBUG_KMS("Skipping CRT initialization for %s\n", id->ident);
547 return 1;
548}
549
550static const struct dmi_system_id intel_no_crt[] = {
551 {
552 .callback = intel_no_crt_dmi_callback,
553 .ident = "ACER ZGB",
554 .matches = {
555 DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
556 DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
557 },
558 },
559 { }
560};
561
543void intel_crt_init(struct drm_device *dev) 562void intel_crt_init(struct drm_device *dev)
544{ 563{
545 struct drm_connector *connector; 564 struct drm_connector *connector;
@@ -547,6 +566,10 @@ void intel_crt_init(struct drm_device *dev)
547 struct intel_connector *intel_connector; 566 struct intel_connector *intel_connector;
548 struct drm_i915_private *dev_priv = dev->dev_private; 567 struct drm_i915_private *dev_priv = dev->dev_private;
549 568
569 /* Skip machines without VGA that falsely report hotplug events */
570 if (dmi_check_system(intel_no_crt))
571 return;
572
550 crt = kzalloc(sizeof(struct intel_crt), GFP_KERNEL); 573 crt = kzalloc(sizeof(struct intel_crt), GFP_KERNEL);
551 if (!crt) 574 if (!crt)
552 return; 575 return;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2a3f707caab8..b3b51c43dad0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5808,12 +5808,15 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5808 if (is_lvds) { 5808 if (is_lvds) {
5809 temp = I915_READ(PCH_LVDS); 5809 temp = I915_READ(PCH_LVDS);
5810 temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP; 5810 temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP;
5811 if (HAS_PCH_CPT(dev)) 5811 if (HAS_PCH_CPT(dev)) {
5812 temp &= ~PORT_TRANS_SEL_MASK;
5812 temp |= PORT_TRANS_SEL_CPT(pipe); 5813 temp |= PORT_TRANS_SEL_CPT(pipe);
5813 else if (pipe == 1) 5814 } else {
5814 temp |= LVDS_PIPEB_SELECT; 5815 if (pipe == 1)
5815 else 5816 temp |= LVDS_PIPEB_SELECT;
5816 temp &= ~LVDS_PIPEB_SELECT; 5817 else
5818 temp &= ~LVDS_PIPEB_SELECT;
5819 }
5817 5820
5818 /* set the corresponsding LVDS_BORDER bit */ 5821 /* set the corresponsding LVDS_BORDER bit */
5819 temp |= dev_priv->lvds_border_bits; 5822 temp |= dev_priv->lvds_border_bits;
@@ -9025,12 +9028,9 @@ void intel_modeset_init(struct drm_device *dev)
9025 9028
9026 for (i = 0; i < dev_priv->num_pipe; i++) { 9029 for (i = 0; i < dev_priv->num_pipe; i++) {
9027 intel_crtc_init(dev, i); 9030 intel_crtc_init(dev, i);
9028 if (HAS_PCH_SPLIT(dev)) { 9031 ret = intel_plane_init(dev, i);
9029 ret = intel_plane_init(dev, i); 9032 if (ret)
9030 if (ret) 9033 DRM_DEBUG_KMS("plane %d init failed: %d\n", i, ret);
9031 DRM_ERROR("plane %d init failed: %d\n",
9032 i, ret);
9033 }
9034 } 9034 }
9035 9035
9036 /* Just disable it once at startup */ 9036 /* Just disable it once at startup */
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index e44191132ac4..798f6e1aa544 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -708,6 +708,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
708 }, 708 },
709 }, 709 },
710 { 710 {
711 .callback = intel_no_lvds_dmi_callback,
712 .ident = "Clientron E830",
713 .matches = {
714 DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
715 DMI_MATCH(DMI_PRODUCT_NAME, "E830"),
716 },
717 },
718 {
711 .callback = intel_no_lvds_dmi_callback, 719 .callback = intel_no_lvds_dmi_callback,
712 .ident = "Asus EeeBox PC EB1007", 720 .ident = "Asus EeeBox PC EB1007",
713 .matches = { 721 .matches = {
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 77e729d4e4f0..1ab842c6032e 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -636,6 +636,19 @@ render_ring_add_request(struct intel_ring_buffer *ring,
636} 636}
637 637
638static u32 638static u32
639gen6_ring_get_seqno(struct intel_ring_buffer *ring)
640{
641 struct drm_device *dev = ring->dev;
642
643 /* Workaround to force correct ordering between irq and seqno writes on
644 * ivb (and maybe also on snb) by reading from a CS register (like
645 * ACTHD) before reading the status page. */
646 if (IS_GEN7(dev))
647 intel_ring_get_active_head(ring);
648 return intel_read_status_page(ring, I915_GEM_HWS_INDEX);
649}
650
651static u32
639ring_get_seqno(struct intel_ring_buffer *ring) 652ring_get_seqno(struct intel_ring_buffer *ring)
640{ 653{
641 return intel_read_status_page(ring, I915_GEM_HWS_INDEX); 654 return intel_read_status_page(ring, I915_GEM_HWS_INDEX);
@@ -792,17 +805,6 @@ ring_add_request(struct intel_ring_buffer *ring,
792} 805}
793 806
794static bool 807static bool
795gen7_blt_ring_get_irq(struct intel_ring_buffer *ring)
796{
797 /* The BLT ring on IVB appears to have broken synchronization
798 * between the seqno write and the interrupt, so that the
799 * interrupt appears first. Returning false here makes
800 * i915_wait_request() do a polling loop, instead.
801 */
802 return false;
803}
804
805static bool
806gen6_ring_get_irq(struct intel_ring_buffer *ring, u32 gflag, u32 rflag) 808gen6_ring_get_irq(struct intel_ring_buffer *ring, u32 gflag, u32 rflag)
807{ 809{
808 struct drm_device *dev = ring->dev; 810 struct drm_device *dev = ring->dev;
@@ -811,6 +813,12 @@ gen6_ring_get_irq(struct intel_ring_buffer *ring, u32 gflag, u32 rflag)
811 if (!dev->irq_enabled) 813 if (!dev->irq_enabled)
812 return false; 814 return false;
813 815
816 /* It looks like we need to prevent the gt from suspending while waiting
817 * for an notifiy irq, otherwise irqs seem to get lost on at least the
818 * blt/bsd rings on ivb. */
819 if (IS_GEN7(dev))
820 gen6_gt_force_wake_get(dev_priv);
821
814 spin_lock(&ring->irq_lock); 822 spin_lock(&ring->irq_lock);
815 if (ring->irq_refcount++ == 0) { 823 if (ring->irq_refcount++ == 0) {
816 ring->irq_mask &= ~rflag; 824 ring->irq_mask &= ~rflag;
@@ -835,6 +843,9 @@ gen6_ring_put_irq(struct intel_ring_buffer *ring, u32 gflag, u32 rflag)
835 ironlake_disable_irq(dev_priv, gflag); 843 ironlake_disable_irq(dev_priv, gflag);
836 } 844 }
837 spin_unlock(&ring->irq_lock); 845 spin_unlock(&ring->irq_lock);
846
847 if (IS_GEN7(dev))
848 gen6_gt_force_wake_put(dev_priv);
838} 849}
839 850
840static bool 851static bool
@@ -1341,7 +1352,7 @@ static const struct intel_ring_buffer gen6_bsd_ring = {
1341 .write_tail = gen6_bsd_ring_write_tail, 1352 .write_tail = gen6_bsd_ring_write_tail,
1342 .flush = gen6_ring_flush, 1353 .flush = gen6_ring_flush,
1343 .add_request = gen6_add_request, 1354 .add_request = gen6_add_request,
1344 .get_seqno = ring_get_seqno, 1355 .get_seqno = gen6_ring_get_seqno,
1345 .irq_get = gen6_bsd_ring_get_irq, 1356 .irq_get = gen6_bsd_ring_get_irq,
1346 .irq_put = gen6_bsd_ring_put_irq, 1357 .irq_put = gen6_bsd_ring_put_irq,
1347 .dispatch_execbuffer = gen6_ring_dispatch_execbuffer, 1358 .dispatch_execbuffer = gen6_ring_dispatch_execbuffer,
@@ -1476,7 +1487,7 @@ static const struct intel_ring_buffer gen6_blt_ring = {
1476 .write_tail = ring_write_tail, 1487 .write_tail = ring_write_tail,
1477 .flush = blt_ring_flush, 1488 .flush = blt_ring_flush,
1478 .add_request = gen6_add_request, 1489 .add_request = gen6_add_request,
1479 .get_seqno = ring_get_seqno, 1490 .get_seqno = gen6_ring_get_seqno,
1480 .irq_get = blt_ring_get_irq, 1491 .irq_get = blt_ring_get_irq,
1481 .irq_put = blt_ring_put_irq, 1492 .irq_put = blt_ring_put_irq,
1482 .dispatch_execbuffer = gen6_ring_dispatch_execbuffer, 1493 .dispatch_execbuffer = gen6_ring_dispatch_execbuffer,
@@ -1499,6 +1510,7 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
1499 ring->flush = gen6_render_ring_flush; 1510 ring->flush = gen6_render_ring_flush;
1500 ring->irq_get = gen6_render_ring_get_irq; 1511 ring->irq_get = gen6_render_ring_get_irq;
1501 ring->irq_put = gen6_render_ring_put_irq; 1512 ring->irq_put = gen6_render_ring_put_irq;
1513 ring->get_seqno = gen6_ring_get_seqno;
1502 } else if (IS_GEN5(dev)) { 1514 } else if (IS_GEN5(dev)) {
1503 ring->add_request = pc_render_add_request; 1515 ring->add_request = pc_render_add_request;
1504 ring->get_seqno = pc_render_get_seqno; 1516 ring->get_seqno = pc_render_get_seqno;
@@ -1577,8 +1589,5 @@ int intel_init_blt_ring_buffer(struct drm_device *dev)
1577 1589
1578 *ring = gen6_blt_ring; 1590 *ring = gen6_blt_ring;
1579 1591
1580 if (IS_GEN7(dev))
1581 ring->irq_get = gen7_blt_ring_get_irq;
1582
1583 return intel_init_ring_buffer(dev, ring); 1592 return intel_init_ring_buffer(dev, ring);
1584} 1593}
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index f7b9268df266..e334ec33a47d 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1066,15 +1066,13 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1066 1066
1067 /* Set the SDVO control regs. */ 1067 /* Set the SDVO control regs. */
1068 if (INTEL_INFO(dev)->gen >= 4) { 1068 if (INTEL_INFO(dev)->gen >= 4) {
1069 sdvox = 0; 1069 /* The real mode polarity is set by the SDVO commands, using
1070 * struct intel_sdvo_dtd. */
1071 sdvox = SDVO_VSYNC_ACTIVE_HIGH | SDVO_HSYNC_ACTIVE_HIGH;
1070 if (intel_sdvo->is_hdmi) 1072 if (intel_sdvo->is_hdmi)
1071 sdvox |= intel_sdvo->color_range; 1073 sdvox |= intel_sdvo->color_range;
1072 if (INTEL_INFO(dev)->gen < 5) 1074 if (INTEL_INFO(dev)->gen < 5)
1073 sdvox |= SDVO_BORDER_ENABLE; 1075 sdvox |= SDVO_BORDER_ENABLE;
1074 if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
1075 sdvox |= SDVO_VSYNC_ACTIVE_HIGH;
1076 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
1077 sdvox |= SDVO_HSYNC_ACTIVE_HIGH;
1078 } else { 1076 } else {
1079 sdvox = I915_READ(intel_sdvo->sdvo_reg); 1077 sdvox = I915_READ(intel_sdvo->sdvo_reg);
1080 switch (intel_sdvo->sdvo_reg) { 1078 switch (intel_sdvo->sdvo_reg) {
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index d13989fda501..2288abf88cce 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -466,10 +466,8 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
466 mutex_lock(&dev->struct_mutex); 466 mutex_lock(&dev->struct_mutex);
467 467
468 ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); 468 ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
469 if (ret) { 469 if (ret)
470 DRM_ERROR("failed to pin object\n");
471 goto out_unlock; 470 goto out_unlock;
472 }
473 471
474 intel_plane->obj = obj; 472 intel_plane->obj = obj;
475 473
@@ -632,10 +630,8 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
632 unsigned long possible_crtcs; 630 unsigned long possible_crtcs;
633 int ret; 631 int ret;
634 632
635 if (!(IS_GEN6(dev) || IS_GEN7(dev))) { 633 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
636 DRM_ERROR("new plane code only for SNB+\n");
637 return -ENODEV; 634 return -ENODEV;
638 }
639 635
640 intel_plane = kzalloc(sizeof(struct intel_plane), GFP_KERNEL); 636 intel_plane = kzalloc(sizeof(struct intel_plane), GFP_KERNEL);
641 if (!intel_plane) 637 if (!intel_plane)
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index f3c6a9a8b081..1571be37ce3e 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -417,7 +417,7 @@ static const struct tv_mode tv_modes[] = {
417 { 417 {
418 .name = "NTSC-M", 418 .name = "NTSC-M",
419 .clock = 108000, 419 .clock = 108000,
420 .refresh = 29970, 420 .refresh = 59940,
421 .oversample = TV_OVERSAMPLE_8X, 421 .oversample = TV_OVERSAMPLE_8X,
422 .component_only = 0, 422 .component_only = 0,
423 /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 3.580MHz */ 423 /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 3.580MHz */
@@ -460,7 +460,7 @@ static const struct tv_mode tv_modes[] = {
460 { 460 {
461 .name = "NTSC-443", 461 .name = "NTSC-443",
462 .clock = 108000, 462 .clock = 108000,
463 .refresh = 29970, 463 .refresh = 59940,
464 .oversample = TV_OVERSAMPLE_8X, 464 .oversample = TV_OVERSAMPLE_8X,
465 .component_only = 0, 465 .component_only = 0,
466 /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 4.43MHz */ 466 /* 525 Lines, 60 Fields, 15.734KHz line, Sub-Carrier 4.43MHz */
@@ -502,7 +502,7 @@ static const struct tv_mode tv_modes[] = {
502 { 502 {
503 .name = "NTSC-J", 503 .name = "NTSC-J",
504 .clock = 108000, 504 .clock = 108000,
505 .refresh = 29970, 505 .refresh = 59940,
506 .oversample = TV_OVERSAMPLE_8X, 506 .oversample = TV_OVERSAMPLE_8X,
507 .component_only = 0, 507 .component_only = 0,
508 508
@@ -545,7 +545,7 @@ static const struct tv_mode tv_modes[] = {
545 { 545 {
546 .name = "PAL-M", 546 .name = "PAL-M",
547 .clock = 108000, 547 .clock = 108000,
548 .refresh = 29970, 548 .refresh = 59940,
549 .oversample = TV_OVERSAMPLE_8X, 549 .oversample = TV_OVERSAMPLE_8X,
550 .component_only = 0, 550 .component_only = 0,
551 551
@@ -589,7 +589,7 @@ static const struct tv_mode tv_modes[] = {
589 /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */ 589 /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */
590 .name = "PAL-N", 590 .name = "PAL-N",
591 .clock = 108000, 591 .clock = 108000,
592 .refresh = 25000, 592 .refresh = 50000,
593 .oversample = TV_OVERSAMPLE_8X, 593 .oversample = TV_OVERSAMPLE_8X,
594 .component_only = 0, 594 .component_only = 0,
595 595
@@ -634,7 +634,7 @@ static const struct tv_mode tv_modes[] = {
634 /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */ 634 /* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */
635 .name = "PAL", 635 .name = "PAL",
636 .clock = 108000, 636 .clock = 108000,
637 .refresh = 25000, 637 .refresh = 50000,
638 .oversample = TV_OVERSAMPLE_8X, 638 .oversample = TV_OVERSAMPLE_8X,
639 .component_only = 0, 639 .component_only = 0,
640 640
@@ -674,78 +674,6 @@ static const struct tv_mode tv_modes[] = {
674 .filter_table = filter_table, 674 .filter_table = filter_table,
675 }, 675 },
676 { 676 {
677 .name = "480p@59.94Hz",
678 .clock = 107520,
679 .refresh = 59940,
680 .oversample = TV_OVERSAMPLE_4X,
681 .component_only = 1,
682
683 .hsync_end = 64, .hblank_end = 122,
684 .hblank_start = 842, .htotal = 857,
685
686 .progressive = true, .trilevel_sync = false,
687
688 .vsync_start_f1 = 12, .vsync_start_f2 = 12,
689 .vsync_len = 12,
690
691 .veq_ena = false,
692
693 .vi_end_f1 = 44, .vi_end_f2 = 44,
694 .nbr_end = 479,
695
696 .burst_ena = false,
697
698 .filter_table = filter_table,
699 },
700 {
701 .name = "480p@60Hz",
702 .clock = 107520,
703 .refresh = 60000,
704 .oversample = TV_OVERSAMPLE_4X,
705 .component_only = 1,
706
707 .hsync_end = 64, .hblank_end = 122,
708 .hblank_start = 842, .htotal = 856,
709
710 .progressive = true, .trilevel_sync = false,
711
712 .vsync_start_f1 = 12, .vsync_start_f2 = 12,
713 .vsync_len = 12,
714
715 .veq_ena = false,
716
717 .vi_end_f1 = 44, .vi_end_f2 = 44,
718 .nbr_end = 479,
719
720 .burst_ena = false,
721
722 .filter_table = filter_table,
723 },
724 {
725 .name = "576p",
726 .clock = 107520,
727 .refresh = 50000,
728 .oversample = TV_OVERSAMPLE_4X,
729 .component_only = 1,
730
731 .hsync_end = 64, .hblank_end = 139,
732 .hblank_start = 859, .htotal = 863,
733
734 .progressive = true, .trilevel_sync = false,
735
736 .vsync_start_f1 = 10, .vsync_start_f2 = 10,
737 .vsync_len = 10,
738
739 .veq_ena = false,
740
741 .vi_end_f1 = 48, .vi_end_f2 = 48,
742 .nbr_end = 575,
743
744 .burst_ena = false,
745
746 .filter_table = filter_table,
747 },
748 {
749 .name = "720p@60Hz", 677 .name = "720p@60Hz",
750 .clock = 148800, 678 .clock = 148800,
751 .refresh = 60000, 679 .refresh = 60000,
@@ -770,30 +698,6 @@ static const struct tv_mode tv_modes[] = {
770 .filter_table = filter_table, 698 .filter_table = filter_table,
771 }, 699 },
772 { 700 {
773 .name = "720p@59.94Hz",
774 .clock = 148800,
775 .refresh = 59940,
776 .oversample = TV_OVERSAMPLE_2X,
777 .component_only = 1,
778
779 .hsync_end = 80, .hblank_end = 300,
780 .hblank_start = 1580, .htotal = 1651,
781
782 .progressive = true, .trilevel_sync = true,
783
784 .vsync_start_f1 = 10, .vsync_start_f2 = 10,
785 .vsync_len = 10,
786
787 .veq_ena = false,
788
789 .vi_end_f1 = 29, .vi_end_f2 = 29,
790 .nbr_end = 719,
791
792 .burst_ena = false,
793
794 .filter_table = filter_table,
795 },
796 {
797 .name = "720p@50Hz", 701 .name = "720p@50Hz",
798 .clock = 148800, 702 .clock = 148800,
799 .refresh = 50000, 703 .refresh = 50000,
@@ -821,7 +725,7 @@ static const struct tv_mode tv_modes[] = {
821 { 725 {
822 .name = "1080i@50Hz", 726 .name = "1080i@50Hz",
823 .clock = 148800, 727 .clock = 148800,
824 .refresh = 25000, 728 .refresh = 50000,
825 .oversample = TV_OVERSAMPLE_2X, 729 .oversample = TV_OVERSAMPLE_2X,
826 .component_only = 1, 730 .component_only = 1,
827 731
@@ -847,7 +751,7 @@ static const struct tv_mode tv_modes[] = {
847 { 751 {
848 .name = "1080i@60Hz", 752 .name = "1080i@60Hz",
849 .clock = 148800, 753 .clock = 148800,
850 .refresh = 30000, 754 .refresh = 60000,
851 .oversample = TV_OVERSAMPLE_2X, 755 .oversample = TV_OVERSAMPLE_2X,
852 .component_only = 1, 756 .component_only = 1,
853 757
@@ -870,32 +774,6 @@ static const struct tv_mode tv_modes[] = {
870 774
871 .filter_table = filter_table, 775 .filter_table = filter_table,
872 }, 776 },
873 {
874 .name = "1080i@59.94Hz",
875 .clock = 148800,
876 .refresh = 29970,
877 .oversample = TV_OVERSAMPLE_2X,
878 .component_only = 1,
879
880 .hsync_end = 88, .hblank_end = 235,
881 .hblank_start = 2155, .htotal = 2201,
882
883 .progressive = false, .trilevel_sync = true,
884
885 .vsync_start_f1 = 4, .vsync_start_f2 = 5,
886 .vsync_len = 10,
887
888 .veq_ena = true, .veq_start_f1 = 4,
889 .veq_start_f2 = 4, .veq_len = 10,
890
891
892 .vi_end_f1 = 21, .vi_end_f2 = 22,
893 .nbr_end = 539,
894
895 .burst_ena = false,
896
897 .filter_table = filter_table,
898 },
899}; 777};
900 778
901static struct intel_tv *enc_to_intel_tv(struct drm_encoder *encoder) 779static struct intel_tv *enc_to_intel_tv(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 724b41a2b9e9..ec54364ac828 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -812,6 +812,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
812 struct nouveau_bo *nvbo = nouveau_bo(bo); 812 struct nouveau_bo *nvbo = nouveau_bo(bo);
813 struct nouveau_vma *vma; 813 struct nouveau_vma *vma;
814 814
815 /* ttm can now (stupidly) pass the driver bos it didn't create... */
816 if (bo->destroy != nouveau_bo_del_ttm)
817 return;
818
815 list_for_each_entry(vma, &nvbo->vma_list, head) { 819 list_for_each_entry(vma, &nvbo->vma_list, head) {
816 if (new_mem && new_mem->mem_type == TTM_PL_VRAM) { 820 if (new_mem && new_mem->mem_type == TTM_PL_VRAM) {
817 nouveau_vm_map(vma, new_mem->mm_node); 821 nouveau_vm_map(vma, new_mem->mm_node);
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 0fda830ef806..891935271d34 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -355,15 +355,12 @@ static void atombios_crtc_set_timing(struct drm_crtc *crtc,
355 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 355 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
356} 356}
357 357
358static void atombios_disable_ss(struct drm_crtc *crtc) 358static void atombios_disable_ss(struct radeon_device *rdev, int pll_id)
359{ 359{
360 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
361 struct drm_device *dev = crtc->dev;
362 struct radeon_device *rdev = dev->dev_private;
363 u32 ss_cntl; 360 u32 ss_cntl;
364 361
365 if (ASIC_IS_DCE4(rdev)) { 362 if (ASIC_IS_DCE4(rdev)) {
366 switch (radeon_crtc->pll_id) { 363 switch (pll_id) {
367 case ATOM_PPLL1: 364 case ATOM_PPLL1:
368 ss_cntl = RREG32(EVERGREEN_P1PLL_SS_CNTL); 365 ss_cntl = RREG32(EVERGREEN_P1PLL_SS_CNTL);
369 ss_cntl &= ~EVERGREEN_PxPLL_SS_EN; 366 ss_cntl &= ~EVERGREEN_PxPLL_SS_EN;
@@ -379,7 +376,7 @@ static void atombios_disable_ss(struct drm_crtc *crtc)
379 return; 376 return;
380 } 377 }
381 } else if (ASIC_IS_AVIVO(rdev)) { 378 } else if (ASIC_IS_AVIVO(rdev)) {
382 switch (radeon_crtc->pll_id) { 379 switch (pll_id) {
383 case ATOM_PPLL1: 380 case ATOM_PPLL1:
384 ss_cntl = RREG32(AVIVO_P1PLL_INT_SS_CNTL); 381 ss_cntl = RREG32(AVIVO_P1PLL_INT_SS_CNTL);
385 ss_cntl &= ~1; 382 ss_cntl &= ~1;
@@ -406,13 +403,11 @@ union atom_enable_ss {
406 ENABLE_SPREAD_SPECTRUM_ON_PPLL_V3 v3; 403 ENABLE_SPREAD_SPECTRUM_ON_PPLL_V3 v3;
407}; 404};
408 405
409static void atombios_crtc_program_ss(struct drm_crtc *crtc, 406static void atombios_crtc_program_ss(struct radeon_device *rdev,
410 int enable, 407 int enable,
411 int pll_id, 408 int pll_id,
412 struct radeon_atom_ss *ss) 409 struct radeon_atom_ss *ss)
413{ 410{
414 struct drm_device *dev = crtc->dev;
415 struct radeon_device *rdev = dev->dev_private;
416 int index = GetIndexIntoMasterTable(COMMAND, EnableSpreadSpectrumOnPPLL); 411 int index = GetIndexIntoMasterTable(COMMAND, EnableSpreadSpectrumOnPPLL);
417 union atom_enable_ss args; 412 union atom_enable_ss args;
418 413
@@ -479,7 +474,7 @@ static void atombios_crtc_program_ss(struct drm_crtc *crtc,
479 } else if (ASIC_IS_AVIVO(rdev)) { 474 } else if (ASIC_IS_AVIVO(rdev)) {
480 if ((enable == ATOM_DISABLE) || (ss->percentage == 0) || 475 if ((enable == ATOM_DISABLE) || (ss->percentage == 0) ||
481 (ss->type & ATOM_EXTERNAL_SS_MASK)) { 476 (ss->type & ATOM_EXTERNAL_SS_MASK)) {
482 atombios_disable_ss(crtc); 477 atombios_disable_ss(rdev, pll_id);
483 return; 478 return;
484 } 479 }
485 args.lvds_ss_2.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage); 480 args.lvds_ss_2.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage);
@@ -491,7 +486,7 @@ static void atombios_crtc_program_ss(struct drm_crtc *crtc,
491 } else { 486 } else {
492 if ((enable == ATOM_DISABLE) || (ss->percentage == 0) || 487 if ((enable == ATOM_DISABLE) || (ss->percentage == 0) ||
493 (ss->type & ATOM_EXTERNAL_SS_MASK)) { 488 (ss->type & ATOM_EXTERNAL_SS_MASK)) {
494 atombios_disable_ss(crtc); 489 atombios_disable_ss(rdev, pll_id);
495 return; 490 return;
496 } 491 }
497 args.lvds_ss.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage); 492 args.lvds_ss.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage);
@@ -523,6 +518,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
523 int encoder_mode = 0; 518 int encoder_mode = 0;
524 u32 dp_clock = mode->clock; 519 u32 dp_clock = mode->clock;
525 int bpc = 8; 520 int bpc = 8;
521 bool is_duallink = false;
526 522
527 /* reset the pll flags */ 523 /* reset the pll flags */
528 pll->flags = 0; 524 pll->flags = 0;
@@ -557,6 +553,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
557 if (connector && connector->display_info.bpc) 553 if (connector && connector->display_info.bpc)
558 bpc = connector->display_info.bpc; 554 bpc = connector->display_info.bpc;
559 encoder_mode = atombios_get_encoder_mode(encoder); 555 encoder_mode = atombios_get_encoder_mode(encoder);
556 is_duallink = radeon_dig_monitor_is_duallink(encoder, mode->clock);
560 if ((radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) || 557 if ((radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) ||
561 (radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) { 558 (radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) {
562 if (connector) { 559 if (connector) {
@@ -652,7 +649,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
652 if (dig->coherent_mode) 649 if (dig->coherent_mode)
653 args.v3.sInput.ucDispPllConfig |= 650 args.v3.sInput.ucDispPllConfig |=
654 DISPPLL_CONFIG_COHERENT_MODE; 651 DISPPLL_CONFIG_COHERENT_MODE;
655 if (mode->clock > 165000) 652 if (is_duallink)
656 args.v3.sInput.ucDispPllConfig |= 653 args.v3.sInput.ucDispPllConfig |=
657 DISPPLL_CONFIG_DUAL_LINK; 654 DISPPLL_CONFIG_DUAL_LINK;
658 } 655 }
@@ -702,11 +699,9 @@ union set_pixel_clock {
702/* on DCE5, make sure the voltage is high enough to support the 699/* on DCE5, make sure the voltage is high enough to support the
703 * required disp clk. 700 * required disp clk.
704 */ 701 */
705static void atombios_crtc_set_dcpll(struct drm_crtc *crtc, 702static void atombios_crtc_set_dcpll(struct radeon_device *rdev,
706 u32 dispclk) 703 u32 dispclk)
707{ 704{
708 struct drm_device *dev = crtc->dev;
709 struct radeon_device *rdev = dev->dev_private;
710 u8 frev, crev; 705 u8 frev, crev;
711 int index; 706 int index;
712 union set_pixel_clock args; 707 union set_pixel_clock args;
@@ -996,7 +991,7 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
996 radeon_compute_pll_legacy(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, 991 radeon_compute_pll_legacy(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div,
997 &ref_div, &post_div); 992 &ref_div, &post_div);
998 993
999 atombios_crtc_program_ss(crtc, ATOM_DISABLE, radeon_crtc->pll_id, &ss); 994 atombios_crtc_program_ss(rdev, ATOM_DISABLE, radeon_crtc->pll_id, &ss);
1000 995
1001 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id, 996 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
1002 encoder_mode, radeon_encoder->encoder_id, mode->clock, 997 encoder_mode, radeon_encoder->encoder_id, mode->clock,
@@ -1019,7 +1014,7 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
1019 ss.step = step_size; 1014 ss.step = step_size;
1020 } 1015 }
1021 1016
1022 atombios_crtc_program_ss(crtc, ATOM_ENABLE, radeon_crtc->pll_id, &ss); 1017 atombios_crtc_program_ss(rdev, ATOM_ENABLE, radeon_crtc->pll_id, &ss);
1023 } 1018 }
1024} 1019}
1025 1020
@@ -1494,6 +1489,24 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1494 1489
1495} 1490}
1496 1491
1492void radeon_atom_dcpll_init(struct radeon_device *rdev)
1493{
1494 /* always set DCPLL */
1495 if (ASIC_IS_DCE4(rdev)) {
1496 struct radeon_atom_ss ss;
1497 bool ss_enabled = radeon_atombios_get_asic_ss_info(rdev, &ss,
1498 ASIC_INTERNAL_SS_ON_DCPLL,
1499 rdev->clock.default_dispclk);
1500 if (ss_enabled)
1501 atombios_crtc_program_ss(rdev, ATOM_DISABLE, ATOM_DCPLL, &ss);
1502 /* XXX: DCE5, make sure voltage, dispclk is high enough */
1503 atombios_crtc_set_dcpll(rdev, rdev->clock.default_dispclk);
1504 if (ss_enabled)
1505 atombios_crtc_program_ss(rdev, ATOM_ENABLE, ATOM_DCPLL, &ss);
1506 }
1507
1508}
1509
1497int atombios_crtc_mode_set(struct drm_crtc *crtc, 1510int atombios_crtc_mode_set(struct drm_crtc *crtc,
1498 struct drm_display_mode *mode, 1511 struct drm_display_mode *mode,
1499 struct drm_display_mode *adjusted_mode, 1512 struct drm_display_mode *adjusted_mode,
@@ -1515,19 +1528,6 @@ int atombios_crtc_mode_set(struct drm_crtc *crtc,
1515 } 1528 }
1516 } 1529 }
1517 1530
1518 /* always set DCPLL */
1519 if (ASIC_IS_DCE4(rdev)) {
1520 struct radeon_atom_ss ss;
1521 bool ss_enabled = radeon_atombios_get_asic_ss_info(rdev, &ss,
1522 ASIC_INTERNAL_SS_ON_DCPLL,
1523 rdev->clock.default_dispclk);
1524 if (ss_enabled)
1525 atombios_crtc_program_ss(crtc, ATOM_DISABLE, ATOM_DCPLL, &ss);
1526 /* XXX: DCE5, make sure voltage, dispclk is high enough */
1527 atombios_crtc_set_dcpll(crtc, rdev->clock.default_dispclk);
1528 if (ss_enabled)
1529 atombios_crtc_program_ss(crtc, ATOM_ENABLE, ATOM_DCPLL, &ss);
1530 }
1531 atombios_crtc_set_pll(crtc, adjusted_mode); 1531 atombios_crtc_set_pll(crtc, adjusted_mode);
1532 1532
1533 if (ASIC_IS_DCE4(rdev)) 1533 if (ASIC_IS_DCE4(rdev))
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 6fb335a4fdda..a71557ce01dc 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -549,8 +549,8 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector)
549 return false; 549 return false;
550} 550}
551 551
552static void radeon_dp_set_panel_mode(struct drm_encoder *encoder, 552int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
553 struct drm_connector *connector) 553 struct drm_connector *connector)
554{ 554{
555 struct drm_device *dev = encoder->dev; 555 struct drm_device *dev = encoder->dev;
556 struct radeon_device *rdev = dev->dev_private; 556 struct radeon_device *rdev = dev->dev_private;
@@ -558,7 +558,7 @@ static void radeon_dp_set_panel_mode(struct drm_encoder *encoder,
558 int panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE; 558 int panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
559 559
560 if (!ASIC_IS_DCE4(rdev)) 560 if (!ASIC_IS_DCE4(rdev))
561 return; 561 return panel_mode;
562 562
563 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) == 563 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) ==
564 ENCODER_OBJECT_ID_NUTMEG) 564 ENCODER_OBJECT_ID_NUTMEG)
@@ -572,14 +572,7 @@ static void radeon_dp_set_panel_mode(struct drm_encoder *encoder,
572 panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE; 572 panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
573 } 573 }
574 574
575 atombios_dig_encoder_setup(encoder, 575 return panel_mode;
576 ATOM_ENCODER_CMD_SETUP_PANEL_MODE,
577 panel_mode);
578
579 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) &&
580 (panel_mode == DP_PANEL_MODE_INTERNAL_DP2_MODE)) {
581 radeon_write_dpcd_reg(radeon_connector, DP_EDP_CONFIGURATION_SET, 1);
582 }
583} 576}
584 577
585void radeon_dp_set_link_config(struct drm_connector *connector, 578void radeon_dp_set_link_config(struct drm_connector *connector,
@@ -717,6 +710,8 @@ static void radeon_dp_set_tp(struct radeon_dp_link_train_info *dp_info, int tp)
717 710
718static int radeon_dp_link_train_init(struct radeon_dp_link_train_info *dp_info) 711static int radeon_dp_link_train_init(struct radeon_dp_link_train_info *dp_info)
719{ 712{
713 struct radeon_encoder *radeon_encoder = to_radeon_encoder(dp_info->encoder);
714 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
720 u8 tmp; 715 u8 tmp;
721 716
722 /* power up the sink */ 717 /* power up the sink */
@@ -732,7 +727,10 @@ static int radeon_dp_link_train_init(struct radeon_dp_link_train_info *dp_info)
732 radeon_write_dpcd_reg(dp_info->radeon_connector, 727 radeon_write_dpcd_reg(dp_info->radeon_connector,
733 DP_DOWNSPREAD_CTRL, 0); 728 DP_DOWNSPREAD_CTRL, 0);
734 729
735 radeon_dp_set_panel_mode(dp_info->encoder, dp_info->connector); 730 if ((dp_info->connector->connector_type == DRM_MODE_CONNECTOR_eDP) &&
731 (dig->panel_mode == DP_PANEL_MODE_INTERNAL_DP2_MODE)) {
732 radeon_write_dpcd_reg(dp_info->radeon_connector, DP_EDP_CONFIGURATION_SET, 1);
733 }
736 734
737 /* set the lane count on the sink */ 735 /* set the lane count on the sink */
738 tmp = dp_info->dp_lane_count; 736 tmp = dp_info->dp_lane_count;
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index f1f06ca9f1f5..b88c4608731b 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -57,22 +57,6 @@ static inline bool radeon_encoder_is_digital(struct drm_encoder *encoder)
57 } 57 }
58} 58}
59 59
60static struct drm_connector *
61radeon_get_connector_for_encoder_init(struct drm_encoder *encoder)
62{
63 struct drm_device *dev = encoder->dev;
64 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
65 struct drm_connector *connector;
66 struct radeon_connector *radeon_connector;
67
68 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
69 radeon_connector = to_radeon_connector(connector);
70 if (radeon_encoder->devices & radeon_connector->devices)
71 return connector;
72 }
73 return NULL;
74}
75
76static bool radeon_atom_mode_fixup(struct drm_encoder *encoder, 60static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
77 struct drm_display_mode *mode, 61 struct drm_display_mode *mode,
78 struct drm_display_mode *adjusted_mode) 62 struct drm_display_mode *adjusted_mode)
@@ -253,7 +237,7 @@ atombios_dvo_setup(struct drm_encoder *encoder, int action)
253 /* R4xx, R5xx */ 237 /* R4xx, R5xx */
254 args.ext_tmds.sXTmdsEncoder.ucEnable = action; 238 args.ext_tmds.sXTmdsEncoder.ucEnable = action;
255 239
256 if (radeon_encoder->pixel_clock > 165000) 240 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
257 args.ext_tmds.sXTmdsEncoder.ucMisc |= PANEL_ENCODER_MISC_DUAL; 241 args.ext_tmds.sXTmdsEncoder.ucMisc |= PANEL_ENCODER_MISC_DUAL;
258 242
259 args.ext_tmds.sXTmdsEncoder.ucMisc |= ATOM_PANEL_MISC_888RGB; 243 args.ext_tmds.sXTmdsEncoder.ucMisc |= ATOM_PANEL_MISC_888RGB;
@@ -265,7 +249,7 @@ atombios_dvo_setup(struct drm_encoder *encoder, int action)
265 /* DFP1, CRT1, TV1 depending on the type of port */ 249 /* DFP1, CRT1, TV1 depending on the type of port */
266 args.dvo.sDVOEncoder.ucDeviceType = ATOM_DEVICE_DFP1_INDEX; 250 args.dvo.sDVOEncoder.ucDeviceType = ATOM_DEVICE_DFP1_INDEX;
267 251
268 if (radeon_encoder->pixel_clock > 165000) 252 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
269 args.dvo.sDVOEncoder.usDevAttr.sDigAttrib.ucAttribute |= PANEL_ENCODER_MISC_DUAL; 253 args.dvo.sDVOEncoder.usDevAttr.sDigAttrib.ucAttribute |= PANEL_ENCODER_MISC_DUAL;
270 break; 254 break;
271 case 3: 255 case 3:
@@ -349,7 +333,7 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
349 } else { 333 } else {
350 if (dig->linkb) 334 if (dig->linkb)
351 args.v1.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB; 335 args.v1.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB;
352 if (radeon_encoder->pixel_clock > 165000) 336 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
353 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL; 337 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL;
354 /*if (pScrn->rgbBits == 8) */ 338 /*if (pScrn->rgbBits == 8) */
355 args.v1.ucMisc |= ATOM_PANEL_MISC_888RGB; 339 args.v1.ucMisc |= ATOM_PANEL_MISC_888RGB;
@@ -388,7 +372,7 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
388 } else { 372 } else {
389 if (dig->linkb) 373 if (dig->linkb)
390 args.v2.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB; 374 args.v2.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB;
391 if (radeon_encoder->pixel_clock > 165000) 375 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
392 args.v2.ucMisc |= PANEL_ENCODER_MISC_DUAL; 376 args.v2.ucMisc |= PANEL_ENCODER_MISC_DUAL;
393 } 377 }
394 break; 378 break;
@@ -432,7 +416,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
432 switch (connector->connector_type) { 416 switch (connector->connector_type) {
433 case DRM_MODE_CONNECTOR_DVII: 417 case DRM_MODE_CONNECTOR_DVII:
434 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */ 418 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */
435 if (drm_detect_monitor_audio(radeon_connector->edid) && 419 if (drm_detect_hdmi_monitor(radeon_connector->edid) &&
436 radeon_audio) 420 radeon_audio)
437 return ATOM_ENCODER_MODE_HDMI; 421 return ATOM_ENCODER_MODE_HDMI;
438 else if (radeon_connector->use_digital) 422 else if (radeon_connector->use_digital)
@@ -443,7 +427,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
443 case DRM_MODE_CONNECTOR_DVID: 427 case DRM_MODE_CONNECTOR_DVID:
444 case DRM_MODE_CONNECTOR_HDMIA: 428 case DRM_MODE_CONNECTOR_HDMIA:
445 default: 429 default:
446 if (drm_detect_monitor_audio(radeon_connector->edid) && 430 if (drm_detect_hdmi_monitor(radeon_connector->edid) &&
447 radeon_audio) 431 radeon_audio)
448 return ATOM_ENCODER_MODE_HDMI; 432 return ATOM_ENCODER_MODE_HDMI;
449 else 433 else
@@ -457,7 +441,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
457 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 441 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
458 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) 442 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))
459 return ATOM_ENCODER_MODE_DP; 443 return ATOM_ENCODER_MODE_DP;
460 else if (drm_detect_monitor_audio(radeon_connector->edid) && 444 else if (drm_detect_hdmi_monitor(radeon_connector->edid) &&
461 radeon_audio) 445 radeon_audio)
462 return ATOM_ENCODER_MODE_HDMI; 446 return ATOM_ENCODER_MODE_HDMI;
463 else 447 else
@@ -587,7 +571,7 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mo
587 571
588 if (ENCODER_MODE_IS_DP(args.v1.ucEncoderMode)) 572 if (ENCODER_MODE_IS_DP(args.v1.ucEncoderMode))
589 args.v1.ucLaneNum = dp_lane_count; 573 args.v1.ucLaneNum = dp_lane_count;
590 else if (radeon_encoder->pixel_clock > 165000) 574 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
591 args.v1.ucLaneNum = 8; 575 args.v1.ucLaneNum = 8;
592 else 576 else
593 args.v1.ucLaneNum = 4; 577 args.v1.ucLaneNum = 4;
@@ -622,7 +606,7 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mo
622 606
623 if (ENCODER_MODE_IS_DP(args.v1.ucEncoderMode)) 607 if (ENCODER_MODE_IS_DP(args.v1.ucEncoderMode))
624 args.v3.ucLaneNum = dp_lane_count; 608 args.v3.ucLaneNum = dp_lane_count;
625 else if (radeon_encoder->pixel_clock > 165000) 609 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
626 args.v3.ucLaneNum = 8; 610 args.v3.ucLaneNum = 8;
627 else 611 else
628 args.v3.ucLaneNum = 4; 612 args.v3.ucLaneNum = 4;
@@ -662,7 +646,7 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mo
662 646
663 if (ENCODER_MODE_IS_DP(args.v1.ucEncoderMode)) 647 if (ENCODER_MODE_IS_DP(args.v1.ucEncoderMode))
664 args.v4.ucLaneNum = dp_lane_count; 648 args.v4.ucLaneNum = dp_lane_count;
665 else if (radeon_encoder->pixel_clock > 165000) 649 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
666 args.v4.ucLaneNum = 8; 650 args.v4.ucLaneNum = 8;
667 else 651 else
668 args.v4.ucLaneNum = 4; 652 args.v4.ucLaneNum = 4;
@@ -806,7 +790,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
806 if (is_dp) 790 if (is_dp)
807 args.v1.usPixelClock = 791 args.v1.usPixelClock =
808 cpu_to_le16(dp_clock / 10); 792 cpu_to_le16(dp_clock / 10);
809 else if (radeon_encoder->pixel_clock > 165000) 793 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
810 args.v1.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10); 794 args.v1.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10);
811 else 795 else
812 args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); 796 args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
@@ -821,7 +805,8 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
821 805
822 if ((rdev->flags & RADEON_IS_IGP) && 806 if ((rdev->flags & RADEON_IS_IGP) &&
823 (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_UNIPHY)) { 807 (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_UNIPHY)) {
824 if (is_dp || (radeon_encoder->pixel_clock <= 165000)) { 808 if (is_dp ||
809 !radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock)) {
825 if (igp_lane_info & 0x1) 810 if (igp_lane_info & 0x1)
826 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3; 811 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3;
827 else if (igp_lane_info & 0x2) 812 else if (igp_lane_info & 0x2)
@@ -848,7 +833,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
848 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 833 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
849 if (dig->coherent_mode) 834 if (dig->coherent_mode)
850 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT; 835 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT;
851 if (radeon_encoder->pixel_clock > 165000) 836 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
852 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK; 837 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK;
853 } 838 }
854 break; 839 break;
@@ -863,7 +848,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
863 if (is_dp) 848 if (is_dp)
864 args.v2.usPixelClock = 849 args.v2.usPixelClock =
865 cpu_to_le16(dp_clock / 10); 850 cpu_to_le16(dp_clock / 10);
866 else if (radeon_encoder->pixel_clock > 165000) 851 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
867 args.v2.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10); 852 args.v2.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10);
868 else 853 else
869 args.v2.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); 854 args.v2.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
@@ -891,7 +876,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
891 } else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 876 } else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
892 if (dig->coherent_mode) 877 if (dig->coherent_mode)
893 args.v2.acConfig.fCoherentMode = 1; 878 args.v2.acConfig.fCoherentMode = 1;
894 if (radeon_encoder->pixel_clock > 165000) 879 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
895 args.v2.acConfig.fDualLinkConnector = 1; 880 args.v2.acConfig.fDualLinkConnector = 1;
896 } 881 }
897 break; 882 break;
@@ -906,7 +891,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
906 if (is_dp) 891 if (is_dp)
907 args.v3.usPixelClock = 892 args.v3.usPixelClock =
908 cpu_to_le16(dp_clock / 10); 893 cpu_to_le16(dp_clock / 10);
909 else if (radeon_encoder->pixel_clock > 165000) 894 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
910 args.v3.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10); 895 args.v3.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10);
911 else 896 else
912 args.v3.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); 897 args.v3.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
@@ -914,7 +899,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
914 899
915 if (is_dp) 900 if (is_dp)
916 args.v3.ucLaneNum = dp_lane_count; 901 args.v3.ucLaneNum = dp_lane_count;
917 else if (radeon_encoder->pixel_clock > 165000) 902 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
918 args.v3.ucLaneNum = 8; 903 args.v3.ucLaneNum = 8;
919 else 904 else
920 args.v3.ucLaneNum = 4; 905 args.v3.ucLaneNum = 4;
@@ -951,7 +936,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
951 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 936 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
952 if (dig->coherent_mode) 937 if (dig->coherent_mode)
953 args.v3.acConfig.fCoherentMode = 1; 938 args.v3.acConfig.fCoherentMode = 1;
954 if (radeon_encoder->pixel_clock > 165000) 939 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
955 args.v3.acConfig.fDualLinkConnector = 1; 940 args.v3.acConfig.fDualLinkConnector = 1;
956 } 941 }
957 break; 942 break;
@@ -966,7 +951,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
966 if (is_dp) 951 if (is_dp)
967 args.v4.usPixelClock = 952 args.v4.usPixelClock =
968 cpu_to_le16(dp_clock / 10); 953 cpu_to_le16(dp_clock / 10);
969 else if (radeon_encoder->pixel_clock > 165000) 954 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
970 args.v4.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10); 955 args.v4.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10);
971 else 956 else
972 args.v4.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); 957 args.v4.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
@@ -974,7 +959,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
974 959
975 if (is_dp) 960 if (is_dp)
976 args.v4.ucLaneNum = dp_lane_count; 961 args.v4.ucLaneNum = dp_lane_count;
977 else if (radeon_encoder->pixel_clock > 165000) 962 else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
978 args.v4.ucLaneNum = 8; 963 args.v4.ucLaneNum = 8;
979 else 964 else
980 args.v4.ucLaneNum = 4; 965 args.v4.ucLaneNum = 4;
@@ -1014,7 +999,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
1014 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 999 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
1015 if (dig->coherent_mode) 1000 if (dig->coherent_mode)
1016 args.v4.acConfig.fCoherentMode = 1; 1001 args.v4.acConfig.fCoherentMode = 1;
1017 if (radeon_encoder->pixel_clock > 165000) 1002 if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
1018 args.v4.acConfig.fDualLinkConnector = 1; 1003 args.v4.acConfig.fDualLinkConnector = 1;
1019 } 1004 }
1020 break; 1005 break;
@@ -1137,7 +1122,7 @@ atombios_external_encoder_setup(struct drm_encoder *encoder,
1137 if (dp_clock == 270000) 1122 if (dp_clock == 270000)
1138 args.v1.sDigEncoder.ucConfig |= ATOM_ENCODER_CONFIG_DPLINKRATE_2_70GHZ; 1123 args.v1.sDigEncoder.ucConfig |= ATOM_ENCODER_CONFIG_DPLINKRATE_2_70GHZ;
1139 args.v1.sDigEncoder.ucLaneNum = dp_lane_count; 1124 args.v1.sDigEncoder.ucLaneNum = dp_lane_count;
1140 } else if (radeon_encoder->pixel_clock > 165000) 1125 } else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
1141 args.v1.sDigEncoder.ucLaneNum = 8; 1126 args.v1.sDigEncoder.ucLaneNum = 8;
1142 else 1127 else
1143 args.v1.sDigEncoder.ucLaneNum = 4; 1128 args.v1.sDigEncoder.ucLaneNum = 4;
@@ -1156,7 +1141,7 @@ atombios_external_encoder_setup(struct drm_encoder *encoder,
1156 else if (dp_clock == 540000) 1141 else if (dp_clock == 540000)
1157 args.v3.sExtEncoder.ucConfig |= EXTERNAL_ENCODER_CONFIG_V3_DPLINKRATE_5_40GHZ; 1142 args.v3.sExtEncoder.ucConfig |= EXTERNAL_ENCODER_CONFIG_V3_DPLINKRATE_5_40GHZ;
1158 args.v3.sExtEncoder.ucLaneNum = dp_lane_count; 1143 args.v3.sExtEncoder.ucLaneNum = dp_lane_count;
1159 } else if (radeon_encoder->pixel_clock > 165000) 1144 } else if (radeon_dig_monitor_is_duallink(encoder, radeon_encoder->pixel_clock))
1160 args.v3.sExtEncoder.ucLaneNum = 8; 1145 args.v3.sExtEncoder.ucLaneNum = 8;
1161 else 1146 else
1162 args.v3.sExtEncoder.ucLaneNum = 4; 1147 args.v3.sExtEncoder.ucLaneNum = 4;
@@ -1341,7 +1326,8 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1341 switch (mode) { 1326 switch (mode) {
1342 case DRM_MODE_DPMS_ON: 1327 case DRM_MODE_DPMS_ON:
1343 /* some early dce3.2 boards have a bug in their transmitter control table */ 1328 /* some early dce3.2 boards have a bug in their transmitter control table */
1344 if ((rdev->family == CHIP_RV710) || (rdev->family == CHIP_RV730)) 1329 if ((rdev->family == CHIP_RV710) || (rdev->family == CHIP_RV730) ||
1330 ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev))
1345 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); 1331 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1346 else 1332 else
1347 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); 1333 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
@@ -1351,8 +1337,6 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1351 ATOM_TRANSMITTER_ACTION_POWER_ON); 1337 ATOM_TRANSMITTER_ACTION_POWER_ON);
1352 radeon_dig_connector->edp_on = true; 1338 radeon_dig_connector->edp_on = true;
1353 } 1339 }
1354 if (ASIC_IS_DCE4(rdev))
1355 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF, 0);
1356 radeon_dp_link_train(encoder, connector); 1340 radeon_dp_link_train(encoder, connector);
1357 if (ASIC_IS_DCE4(rdev)) 1341 if (ASIC_IS_DCE4(rdev))
1358 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0); 1342 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
@@ -1363,7 +1347,10 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1363 case DRM_MODE_DPMS_STANDBY: 1347 case DRM_MODE_DPMS_STANDBY:
1364 case DRM_MODE_DPMS_SUSPEND: 1348 case DRM_MODE_DPMS_SUSPEND:
1365 case DRM_MODE_DPMS_OFF: 1349 case DRM_MODE_DPMS_OFF:
1366 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0); 1350 if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev))
1351 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0);
1352 else
1353 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0);
1367 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { 1354 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) {
1368 if (ASIC_IS_DCE4(rdev)) 1355 if (ASIC_IS_DCE4(rdev))
1369 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF, 0); 1356 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF, 0);
@@ -1810,7 +1797,21 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1810 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: 1797 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1811 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: 1798 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1812 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: 1799 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
1813 if (ASIC_IS_DCE4(rdev)) { 1800 if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev)) {
1801 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1802 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
1803
1804 if (!connector)
1805 dig->panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
1806 else
1807 dig->panel_mode = radeon_dp_get_panel_mode(encoder, connector);
1808
1809 /* setup and enable the encoder */
1810 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_SETUP, 0);
1811 atombios_dig_encoder_setup(encoder,
1812 ATOM_ENCODER_CMD_SETUP_PANEL_MODE,
1813 dig->panel_mode);
1814 } else if (ASIC_IS_DCE4(rdev)) {
1814 /* disable the transmitter */ 1815 /* disable the transmitter */
1815 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0); 1816 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0);
1816 /* setup and enable the encoder */ 1817 /* setup and enable the encoder */
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 636660fca8c2..ae09fe82afbc 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1455,6 +1455,7 @@ int evergreen_cp_resume(struct radeon_device *rdev)
1455#endif 1455#endif
1456 WREG32(CP_RB_CNTL, tmp); 1456 WREG32(CP_RB_CNTL, tmp);
1457 WREG32(CP_SEM_WAIT_TIMER, 0x0); 1457 WREG32(CP_SEM_WAIT_TIMER, 0x0);
1458 WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0);
1458 1459
1459 /* Set the write pointer delay */ 1460 /* Set the write pointer delay */
1460 WREG32(CP_RB_WPTR_DELAY, 0); 1461 WREG32(CP_RB_WPTR_DELAY, 0);
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index b502216d42af..74713d42df29 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -108,6 +108,7 @@
108#define CP_RB_WPTR_ADDR_HI 0xC11C 108#define CP_RB_WPTR_ADDR_HI 0xC11C
109#define CP_RB_WPTR_DELAY 0x8704 109#define CP_RB_WPTR_DELAY 0x8704
110#define CP_SEM_WAIT_TIMER 0x85BC 110#define CP_SEM_WAIT_TIMER 0x85BC
111#define CP_SEM_INCOMPLETE_TIMER_CNTL 0x85C8
111#define CP_DEBUG 0xC1FC 112#define CP_DEBUG 0xC1FC
112 113
113 114
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 321137295400..db09065e68fd 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1219,6 +1219,7 @@ int cayman_cp_resume(struct radeon_device *rdev)
1219 RREG32(GRBM_SOFT_RESET); 1219 RREG32(GRBM_SOFT_RESET);
1220 1220
1221 WREG32(CP_SEM_WAIT_TIMER, 0x0); 1221 WREG32(CP_SEM_WAIT_TIMER, 0x0);
1222 WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0);
1222 1223
1223 /* Set the write pointer delay */ 1224 /* Set the write pointer delay */
1224 WREG32(CP_RB_WPTR_DELAY, 0); 1225 WREG32(CP_RB_WPTR_DELAY, 0);
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
index f9df2a645e79..9a7f3b6e02de 100644
--- a/drivers/gpu/drm/radeon/nid.h
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -222,6 +222,7 @@
222#define SCRATCH_UMSK 0x8540 222#define SCRATCH_UMSK 0x8540
223#define SCRATCH_ADDR 0x8544 223#define SCRATCH_ADDR 0x8544
224#define CP_SEM_WAIT_TIMER 0x85BC 224#define CP_SEM_WAIT_TIMER 0x85BC
225#define CP_SEM_INCOMPLETE_TIMER_CNTL 0x85C8
225#define CP_COHER_CNTL2 0x85E8 226#define CP_COHER_CNTL2 0x85E8
226#define CP_ME_CNTL 0x86D8 227#define CP_ME_CNTL 0x86D8
227#define CP_ME_HALT (1 << 28) 228#define CP_ME_HALT (1 << 28)
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 73e05cb85eca..1668ec1ee770 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -157,6 +157,47 @@ bool radeon_get_bios(struct radeon_device *rdev);
157 157
158 158
159/* 159/*
160 * Mutex which allows recursive locking from the same process.
161 */
162struct radeon_mutex {
163 struct mutex mutex;
164 struct task_struct *owner;
165 int level;
166};
167
168static inline void radeon_mutex_init(struct radeon_mutex *mutex)
169{
170 mutex_init(&mutex->mutex);
171 mutex->owner = NULL;
172 mutex->level = 0;
173}
174
175static inline void radeon_mutex_lock(struct radeon_mutex *mutex)
176{
177 if (mutex_trylock(&mutex->mutex)) {
178 /* The mutex was unlocked before, so it's ours now */
179 mutex->owner = current;
180 } else if (mutex->owner != current) {
181 /* Another process locked the mutex, take it */
182 mutex_lock(&mutex->mutex);
183 mutex->owner = current;
184 }
185 /* Otherwise the mutex was already locked by this process */
186
187 mutex->level++;
188}
189
190static inline void radeon_mutex_unlock(struct radeon_mutex *mutex)
191{
192 if (--mutex->level > 0)
193 return;
194
195 mutex->owner = NULL;
196 mutex_unlock(&mutex->mutex);
197}
198
199
200/*
160 * Dummy page 201 * Dummy page
161 */ 202 */
162struct radeon_dummy_page { 203struct radeon_dummy_page {
@@ -598,7 +639,7 @@ struct radeon_ib {
598 * mutex protects scheduled_ibs, ready, alloc_bm 639 * mutex protects scheduled_ibs, ready, alloc_bm
599 */ 640 */
600struct radeon_ib_pool { 641struct radeon_ib_pool {
601 struct mutex mutex; 642 struct radeon_mutex mutex;
602 struct radeon_sa_manager sa_manager; 643 struct radeon_sa_manager sa_manager;
603 struct radeon_ib ibs[RADEON_IB_POOL_SIZE]; 644 struct radeon_ib ibs[RADEON_IB_POOL_SIZE];
604 bool ready; 645 bool ready;
@@ -1355,47 +1396,6 @@ struct r600_vram_scratch {
1355 1396
1356 1397
1357/* 1398/*
1358 * Mutex which allows recursive locking from the same process.
1359 */
1360struct radeon_mutex {
1361 struct mutex mutex;
1362 struct task_struct *owner;
1363 int level;
1364};
1365
1366static inline void radeon_mutex_init(struct radeon_mutex *mutex)
1367{
1368 mutex_init(&mutex->mutex);
1369 mutex->owner = NULL;
1370 mutex->level = 0;
1371}
1372
1373static inline void radeon_mutex_lock(struct radeon_mutex *mutex)
1374{
1375 if (mutex_trylock(&mutex->mutex)) {
1376 /* The mutex was unlocked before, so it's ours now */
1377 mutex->owner = current;
1378 } else if (mutex->owner != current) {
1379 /* Another process locked the mutex, take it */
1380 mutex_lock(&mutex->mutex);
1381 mutex->owner = current;
1382 }
1383 /* Otherwise the mutex was already locked by this process */
1384
1385 mutex->level++;
1386}
1387
1388static inline void radeon_mutex_unlock(struct radeon_mutex *mutex)
1389{
1390 if (--mutex->level > 0)
1391 return;
1392
1393 mutex->owner = NULL;
1394 mutex_unlock(&mutex->mutex);
1395}
1396
1397
1398/*
1399 * Core structure, functions and helpers. 1399 * Core structure, functions and helpers.
1400 */ 1400 */
1401typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t); 1401typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 9d95792bea3e..13ac63ba6075 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -58,9 +58,9 @@ static int radeon_atrm_call(acpi_handle atrm_handle, uint8_t *bios,
58 } 58 }
59 59
60 obj = (union acpi_object *)buffer.pointer; 60 obj = (union acpi_object *)buffer.pointer;
61 memcpy(bios+offset, obj->buffer.pointer, len); 61 memcpy(bios+offset, obj->buffer.pointer, obj->buffer.length);
62 kfree(buffer.pointer); 62 kfree(buffer.pointer);
63 return len; 63 return obj->buffer.length;
64} 64}
65 65
66bool radeon_atrm_supported(struct pci_dev *pdev) 66bool radeon_atrm_supported(struct pci_dev *pdev)
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 229a20f10e2b..501f4881e5aa 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -120,7 +120,7 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev)
120 ret = radeon_atrm_get_bios_chunk(rdev->bios, 120 ret = radeon_atrm_get_bios_chunk(rdev->bios,
121 (i * ATRM_BIOS_PAGE), 121 (i * ATRM_BIOS_PAGE),
122 ATRM_BIOS_PAGE); 122 ATRM_BIOS_PAGE);
123 if (ret <= 0) 123 if (ret < ATRM_BIOS_PAGE)
124 break; 124 break;
125 } 125 }
126 126
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 0afb13bd8dca..cec51a5b69dd 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -720,7 +720,7 @@ int radeon_device_init(struct radeon_device *rdev,
720 /* mutex initialization are all done here so we 720 /* mutex initialization are all done here so we
721 * can recall function without having locking issues */ 721 * can recall function without having locking issues */
722 radeon_mutex_init(&rdev->cs_mutex); 722 radeon_mutex_init(&rdev->cs_mutex);
723 mutex_init(&rdev->ib_pool.mutex); 723 radeon_mutex_init(&rdev->ib_pool.mutex);
724 for (i = 0; i < RADEON_NUM_RINGS; ++i) 724 for (i = 0; i < RADEON_NUM_RINGS; ++i)
725 mutex_init(&rdev->ring[i].mutex); 725 mutex_init(&rdev->ring[i].mutex);
726 mutex_init(&rdev->dc_hw_i2c_mutex); 726 mutex_init(&rdev->dc_hw_i2c_mutex);
@@ -959,9 +959,11 @@ int radeon_resume_kms(struct drm_device *dev)
959 radeon_fbdev_set_suspend(rdev, 0); 959 radeon_fbdev_set_suspend(rdev, 0);
960 console_unlock(); 960 console_unlock();
961 961
962 /* init dig PHYs */ 962 /* init dig PHYs, disp eng pll */
963 if (rdev->is_atom_bios) 963 if (rdev->is_atom_bios) {
964 radeon_atom_encoder_init(rdev); 964 radeon_atom_encoder_init(rdev);
965 radeon_atom_dcpll_init(rdev);
966 }
965 /* reset hpd state */ 967 /* reset hpd state */
966 radeon_hpd_init(rdev); 968 radeon_hpd_init(rdev);
967 /* blat the mode back in */ 969 /* blat the mode back in */
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index d3ffc18774a6..8c49fef1ce78 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1305,9 +1305,11 @@ int radeon_modeset_init(struct radeon_device *rdev)
1305 return ret; 1305 return ret;
1306 } 1306 }
1307 1307
1308 /* init dig PHYs */ 1308 /* init dig PHYs, disp eng pll */
1309 if (rdev->is_atom_bios) 1309 if (rdev->is_atom_bios) {
1310 radeon_atom_encoder_init(rdev); 1310 radeon_atom_encoder_init(rdev);
1311 radeon_atom_dcpll_init(rdev);
1312 }
1311 1313
1312 /* initialize hpd */ 1314 /* initialize hpd */
1313 radeon_hpd_init(rdev); 1315 radeon_hpd_init(rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 4b27efa4405b..9419c51bcf50 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -202,6 +202,22 @@ radeon_get_connector_for_encoder(struct drm_encoder *encoder)
202 return NULL; 202 return NULL;
203} 203}
204 204
205struct drm_connector *
206radeon_get_connector_for_encoder_init(struct drm_encoder *encoder)
207{
208 struct drm_device *dev = encoder->dev;
209 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
210 struct drm_connector *connector;
211 struct radeon_connector *radeon_connector;
212
213 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
214 radeon_connector = to_radeon_connector(connector);
215 if (radeon_encoder->devices & radeon_connector->devices)
216 return connector;
217 }
218 return NULL;
219}
220
205struct drm_encoder *radeon_get_external_encoder(struct drm_encoder *encoder) 221struct drm_encoder *radeon_get_external_encoder(struct drm_encoder *encoder)
206{ 222{
207 struct drm_device *dev = encoder->dev; 223 struct drm_device *dev = encoder->dev;
@@ -288,3 +304,64 @@ void radeon_panel_mode_fixup(struct drm_encoder *encoder,
288 304
289} 305}
290 306
307bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder,
308 u32 pixel_clock)
309{
310 struct drm_device *dev = encoder->dev;
311 struct radeon_device *rdev = dev->dev_private;
312 struct drm_connector *connector;
313 struct radeon_connector *radeon_connector;
314 struct radeon_connector_atom_dig *dig_connector;
315
316 connector = radeon_get_connector_for_encoder(encoder);
317 /* if we don't have an active device yet, just use one of
318 * the connectors tied to the encoder.
319 */
320 if (!connector)
321 connector = radeon_get_connector_for_encoder_init(encoder);
322 radeon_connector = to_radeon_connector(connector);
323
324 switch (connector->connector_type) {
325 case DRM_MODE_CONNECTOR_DVII:
326 case DRM_MODE_CONNECTOR_HDMIB:
327 if (radeon_connector->use_digital) {
328 /* HDMI 1.3 supports up to 340 Mhz over single link */
329 if (ASIC_IS_DCE3(rdev) && drm_detect_hdmi_monitor(radeon_connector->edid)) {
330 if (pixel_clock > 340000)
331 return true;
332 else
333 return false;
334 } else {
335 if (pixel_clock > 165000)
336 return true;
337 else
338 return false;
339 }
340 } else
341 return false;
342 case DRM_MODE_CONNECTOR_DVID:
343 case DRM_MODE_CONNECTOR_HDMIA:
344 case DRM_MODE_CONNECTOR_DisplayPort:
345 dig_connector = radeon_connector->con_priv;
346 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
347 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))
348 return false;
349 else {
350 /* HDMI 1.3 supports up to 340 Mhz over single link */
351 if (ASIC_IS_DCE3(rdev) && drm_detect_hdmi_monitor(radeon_connector->edid)) {
352 if (pixel_clock > 340000)
353 return true;
354 else
355 return false;
356 } else {
357 if (pixel_clock > 165000)
358 return true;
359 else
360 return false;
361 }
362 }
363 default:
364 return false;
365 }
366}
367
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 7bb1b079f480..e2a393ff0c44 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -897,6 +897,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
897 i2c->rec = *rec; 897 i2c->rec = *rec;
898 i2c->adapter.owner = THIS_MODULE; 898 i2c->adapter.owner = THIS_MODULE;
899 i2c->adapter.class = I2C_CLASS_DDC; 899 i2c->adapter.class = I2C_CLASS_DDC;
900 i2c->adapter.dev.parent = &dev->pdev->dev;
900 i2c->dev = dev; 901 i2c->dev = dev;
901 i2c_set_adapdata(&i2c->adapter, i2c); 902 i2c_set_adapdata(&i2c->adapter, i2c);
902 if (rec->mm_i2c || 903 if (rec->mm_i2c ||
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index be38921bf761..66d5fe1c8174 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -138,6 +138,12 @@ static bool radeon_msi_ok(struct radeon_device *rdev)
138 /* Dell RS690 only seems to work with MSIs. */ 138 /* Dell RS690 only seems to work with MSIs. */
139 if ((rdev->pdev->device == 0x791f) && 139 if ((rdev->pdev->device == 0x791f) &&
140 (rdev->pdev->subsystem_vendor == 0x1028) && 140 (rdev->pdev->subsystem_vendor == 0x1028) &&
141 (rdev->pdev->subsystem_device == 0x01fc))
142 return true;
143
144 /* Dell RS690 only seems to work with MSIs. */
145 if ((rdev->pdev->device == 0x791f) &&
146 (rdev->pdev->subsystem_vendor == 0x1028) &&
141 (rdev->pdev->subsystem_device == 0x01fd)) 147 (rdev->pdev->subsystem_device == 0x01fd))
142 return true; 148 return true;
143 149
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 08ff857c8fd6..4330e3253573 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -362,6 +362,7 @@ struct radeon_encoder_atom_dig {
362 struct backlight_device *bl_dev; 362 struct backlight_device *bl_dev;
363 int dpms_mode; 363 int dpms_mode;
364 uint8_t backlight_level; 364 uint8_t backlight_level;
365 int panel_mode;
365}; 366};
366 367
367struct radeon_encoder_atom_dac { 368struct radeon_encoder_atom_dac {
@@ -466,6 +467,10 @@ radeon_atombios_get_tv_info(struct radeon_device *rdev);
466 467
467extern struct drm_connector * 468extern struct drm_connector *
468radeon_get_connector_for_encoder(struct drm_encoder *encoder); 469radeon_get_connector_for_encoder(struct drm_encoder *encoder);
470extern struct drm_connector *
471radeon_get_connector_for_encoder_init(struct drm_encoder *encoder);
472extern bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder,
473 u32 pixel_clock);
469 474
470extern u16 radeon_encoder_get_dp_bridge_encoder_id(struct drm_encoder *encoder); 475extern u16 radeon_encoder_get_dp_bridge_encoder_id(struct drm_encoder *encoder);
471extern u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector); 476extern u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector);
@@ -482,8 +487,11 @@ extern void radeon_dp_link_train(struct drm_encoder *encoder,
482extern bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector); 487extern bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector);
483extern u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector); 488extern u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector);
484extern bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector); 489extern bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector);
490extern int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
491 struct drm_connector *connector);
485extern void atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mode); 492extern void atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mode);
486extern void radeon_atom_encoder_init(struct radeon_device *rdev); 493extern void radeon_atom_encoder_init(struct radeon_device *rdev);
494extern void radeon_atom_dcpll_init(struct radeon_device *rdev);
487extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder, 495extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder,
488 int action, uint8_t lane_num, 496 int action, uint8_t lane_num,
489 uint8_t lane_set); 497 uint8_t lane_set);
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index e8bc70933d1b..30a4c5014c8b 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -109,12 +109,12 @@ int radeon_ib_get(struct radeon_device *rdev, int ring,
109 return r; 109 return r;
110 } 110 }
111 111
112 mutex_lock(&rdev->ib_pool.mutex); 112 radeon_mutex_lock(&rdev->ib_pool.mutex);
113 idx = rdev->ib_pool.head_id; 113 idx = rdev->ib_pool.head_id;
114retry: 114retry:
115 if (cretry > 5) { 115 if (cretry > 5) {
116 dev_err(rdev->dev, "failed to get an ib after 5 retry\n"); 116 dev_err(rdev->dev, "failed to get an ib after 5 retry\n");
117 mutex_unlock(&rdev->ib_pool.mutex); 117 radeon_mutex_unlock(&rdev->ib_pool.mutex);
118 radeon_fence_unref(&fence); 118 radeon_fence_unref(&fence);
119 return -ENOMEM; 119 return -ENOMEM;
120 } 120 }
@@ -139,7 +139,7 @@ retry:
139 */ 139 */
140 rdev->ib_pool.head_id = (1 + idx); 140 rdev->ib_pool.head_id = (1 + idx);
141 rdev->ib_pool.head_id &= (RADEON_IB_POOL_SIZE - 1); 141 rdev->ib_pool.head_id &= (RADEON_IB_POOL_SIZE - 1);
142 mutex_unlock(&rdev->ib_pool.mutex); 142 radeon_mutex_unlock(&rdev->ib_pool.mutex);
143 return 0; 143 return 0;
144 } 144 }
145 } 145 }
@@ -158,7 +158,7 @@ retry:
158 } 158 }
159 idx = (idx + 1) & (RADEON_IB_POOL_SIZE - 1); 159 idx = (idx + 1) & (RADEON_IB_POOL_SIZE - 1);
160 } 160 }
161 mutex_unlock(&rdev->ib_pool.mutex); 161 radeon_mutex_unlock(&rdev->ib_pool.mutex);
162 radeon_fence_unref(&fence); 162 radeon_fence_unref(&fence);
163 return r; 163 return r;
164} 164}
@@ -171,12 +171,12 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib)
171 if (tmp == NULL) { 171 if (tmp == NULL) {
172 return; 172 return;
173 } 173 }
174 mutex_lock(&rdev->ib_pool.mutex); 174 radeon_mutex_lock(&rdev->ib_pool.mutex);
175 if (tmp->fence && !tmp->fence->emitted) { 175 if (tmp->fence && !tmp->fence->emitted) {
176 radeon_sa_bo_free(rdev, &tmp->sa_bo); 176 radeon_sa_bo_free(rdev, &tmp->sa_bo);
177 radeon_fence_unref(&tmp->fence); 177 radeon_fence_unref(&tmp->fence);
178 } 178 }
179 mutex_unlock(&rdev->ib_pool.mutex); 179 radeon_mutex_unlock(&rdev->ib_pool.mutex);
180} 180}
181 181
182int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib) 182int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
@@ -204,22 +204,25 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
204 204
205int radeon_ib_pool_init(struct radeon_device *rdev) 205int radeon_ib_pool_init(struct radeon_device *rdev)
206{ 206{
207 struct radeon_sa_manager tmp;
207 int i, r; 208 int i, r;
208 209
209 mutex_lock(&rdev->ib_pool.mutex); 210 r = radeon_sa_bo_manager_init(rdev, &tmp,
210 if (rdev->ib_pool.ready) {
211 mutex_unlock(&rdev->ib_pool.mutex);
212 return 0;
213 }
214
215 r = radeon_sa_bo_manager_init(rdev, &rdev->ib_pool.sa_manager,
216 RADEON_IB_POOL_SIZE*64*1024, 211 RADEON_IB_POOL_SIZE*64*1024,
217 RADEON_GEM_DOMAIN_GTT); 212 RADEON_GEM_DOMAIN_GTT);
218 if (r) { 213 if (r) {
219 mutex_unlock(&rdev->ib_pool.mutex);
220 return r; 214 return r;
221 } 215 }
222 216
217 radeon_mutex_lock(&rdev->ib_pool.mutex);
218 if (rdev->ib_pool.ready) {
219 radeon_mutex_unlock(&rdev->ib_pool.mutex);
220 radeon_sa_bo_manager_fini(rdev, &tmp);
221 return 0;
222 }
223
224 rdev->ib_pool.sa_manager = tmp;
225 INIT_LIST_HEAD(&rdev->ib_pool.sa_manager.sa_bo);
223 for (i = 0; i < RADEON_IB_POOL_SIZE; i++) { 226 for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
224 rdev->ib_pool.ibs[i].fence = NULL; 227 rdev->ib_pool.ibs[i].fence = NULL;
225 rdev->ib_pool.ibs[i].idx = i; 228 rdev->ib_pool.ibs[i].idx = i;
@@ -236,7 +239,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
236 if (radeon_debugfs_ring_init(rdev)) { 239 if (radeon_debugfs_ring_init(rdev)) {
237 DRM_ERROR("Failed to register debugfs file for rings !\n"); 240 DRM_ERROR("Failed to register debugfs file for rings !\n");
238 } 241 }
239 mutex_unlock(&rdev->ib_pool.mutex); 242 radeon_mutex_unlock(&rdev->ib_pool.mutex);
240 return 0; 243 return 0;
241} 244}
242 245
@@ -244,7 +247,7 @@ void radeon_ib_pool_fini(struct radeon_device *rdev)
244{ 247{
245 unsigned i; 248 unsigned i;
246 249
247 mutex_lock(&rdev->ib_pool.mutex); 250 radeon_mutex_lock(&rdev->ib_pool.mutex);
248 if (rdev->ib_pool.ready) { 251 if (rdev->ib_pool.ready) {
249 for (i = 0; i < RADEON_IB_POOL_SIZE; i++) { 252 for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
250 radeon_sa_bo_free(rdev, &rdev->ib_pool.ibs[i].sa_bo); 253 radeon_sa_bo_free(rdev, &rdev->ib_pool.ibs[i].sa_bo);
@@ -253,7 +256,7 @@ void radeon_ib_pool_fini(struct radeon_device *rdev)
253 radeon_sa_bo_manager_fini(rdev, &rdev->ib_pool.sa_manager); 256 radeon_sa_bo_manager_fini(rdev, &rdev->ib_pool.sa_manager);
254 rdev->ib_pool.ready = false; 257 rdev->ib_pool.ready = false;
255 } 258 }
256 mutex_unlock(&rdev->ib_pool.mutex); 259 radeon_mutex_unlock(&rdev->ib_pool.mutex);
257} 260}
258 261
259int radeon_ib_pool_start(struct radeon_device *rdev) 262int radeon_ib_pool_start(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 06da063ece2e..573220cc5269 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -40,7 +40,6 @@ static struct pci_device_id pciidlist[] = {
40static int sis_driver_load(struct drm_device *dev, unsigned long chipset) 40static int sis_driver_load(struct drm_device *dev, unsigned long chipset)
41{ 41{
42 drm_sis_private_t *dev_priv; 42 drm_sis_private_t *dev_priv;
43 int ret;
44 43
45 dev_priv = kzalloc(sizeof(drm_sis_private_t), GFP_KERNEL); 44 dev_priv = kzalloc(sizeof(drm_sis_private_t), GFP_KERNEL);
46 if (dev_priv == NULL) 45 if (dev_priv == NULL)
@@ -50,7 +49,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset)
50 dev_priv->chipset = chipset; 49 dev_priv->chipset = chipset;
51 idr_init(&dev->object_name_idr); 50 idr_init(&dev->object_name_idr);
52 51
53 return ret; 52 return 0;
54} 53}
55 54
56static int sis_driver_unload(struct drm_device *dev) 55static int sis_driver_unload(struct drm_device *dev)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2f0eab66ece6..7c3a57de8187 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -404,6 +404,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
404 } 404 }
405 } 405 }
406 406
407 if (bdev->driver->move_notify)
408 bdev->driver->move_notify(bo, mem);
409
407 if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) && 410 if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
408 !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) 411 !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED))
409 ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, mem); 412 ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, mem);
@@ -413,11 +416,17 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
413 else 416 else
414 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, mem); 417 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, mem);
415 418
416 if (ret) 419 if (ret) {
417 goto out_err; 420 if (bdev->driver->move_notify) {
421 struct ttm_mem_reg tmp_mem = *mem;
422 *mem = bo->mem;
423 bo->mem = tmp_mem;
424 bdev->driver->move_notify(bo, mem);
425 bo->mem = *mem;
426 }
418 427
419 if (bdev->driver->move_notify) 428 goto out_err;
420 bdev->driver->move_notify(bo, mem); 429 }
421 430
422moved: 431moved:
423 if (bo->evicted) { 432 if (bo->evicted) {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 0af6ebdf205d..b66ef0e3cde1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -378,7 +378,7 @@ int vmw_framebuffer_create_handle(struct drm_framebuffer *fb,
378 unsigned int *handle) 378 unsigned int *handle)
379{ 379{
380 if (handle) 380 if (handle)
381 handle = 0; 381 *handle = 0;
382 382
383 return 0; 383 return 0;
384} 384}
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index 92f949767ece..6dbfd3e516e4 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -283,11 +283,11 @@ static inline long temp_from_reg(u8 reg)
283 283
284static inline u8 temp_to_reg(long val) 284static inline u8 temp_to_reg(long val)
285{ 285{
286 if (val < 0) 286 if (val <= 0)
287 val = 0; 287 return 0;
288 else if (val > 1000 * 0xff) 288 if (val >= 1000 * 0xff)
289 val = 0xff; 289 return 0xff;
290 return ((val + 500) / 1000); 290 return (val + 500) / 1000;
291} 291}
292 292
293/* 293/*
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 6ddeae049058..91fdd1fe18b0 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -883,7 +883,7 @@ static int sht15_invalidate_voltage(struct notifier_block *nb,
883 883
884static int __devinit sht15_probe(struct platform_device *pdev) 884static int __devinit sht15_probe(struct platform_device *pdev)
885{ 885{
886 int ret = 0; 886 int ret;
887 struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL); 887 struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL);
888 u8 status = 0; 888 u8 status = 0;
889 889
@@ -901,6 +901,7 @@ static int __devinit sht15_probe(struct platform_device *pdev)
901 init_waitqueue_head(&data->wait_queue); 901 init_waitqueue_head(&data->wait_queue);
902 902
903 if (pdev->dev.platform_data == NULL) { 903 if (pdev->dev.platform_data == NULL) {
904 ret = -EINVAL;
904 dev_err(&pdev->dev, "no platform data supplied\n"); 905 dev_err(&pdev->dev, "no platform data supplied\n");
905 goto err_free_data; 906 goto err_free_data;
906 } 907 }
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 0e0af0445222..2dfae7d7cc5b 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1319,6 +1319,7 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
1319{ 1319{
1320 struct w83627ehf_data *data = dev_get_drvdata(dev); 1320 struct w83627ehf_data *data = dev_get_drvdata(dev);
1321 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 1321 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1322 struct w83627ehf_sio_data *sio_data = dev->platform_data;
1322 int nr = sensor_attr->index; 1323 int nr = sensor_attr->index;
1323 unsigned long val; 1324 unsigned long val;
1324 int err; 1325 int err;
@@ -1330,6 +1331,11 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
1330 1331
1331 if (val > 1) 1332 if (val > 1)
1332 return -EINVAL; 1333 return -EINVAL;
1334
1335 /* On NCT67766F, DC mode is only supported for pwm1 */
1336 if (sio_data->kind == nct6776 && nr && val != 1)
1337 return -EINVAL;
1338
1333 mutex_lock(&data->update_lock); 1339 mutex_lock(&data->update_lock);
1334 reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]); 1340 reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]);
1335 data->pwm_mode[nr] = val; 1341 data->pwm_mode[nr] = val;
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 20bce51c2e82..54ab97bae042 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -527,7 +527,7 @@ int intel_idle_cpu_init(int cpu)
527 527
528 return 0; 528 return 0;
529} 529}
530 530EXPORT_SYMBOL_GPL(intel_idle_cpu_init);
531 531
532static int __init intel_idle_init(void) 532static int __init intel_idle_init(void)
533{ 533{
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index c957c344233f..9ca28fced2b9 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -403,6 +403,13 @@ config LEDS_MAX8997
403 This option enables support for on-chip LED drivers on 403 This option enables support for on-chip LED drivers on
404 MAXIM MAX8997 PMIC. 404 MAXIM MAX8997 PMIC.
405 405
406config LEDS_OT200
407 tristate "LED support for the Bachmann OT200"
408 depends on LEDS_CLASS && HAS_IOMEM
409 help
410 This option enables support for the LEDs on the Bachmann OT200.
411 Say Y to enable LEDs on the Bachmann OT200.
412
406config LEDS_TRIGGERS 413config LEDS_TRIGGERS
407 bool "LED Trigger support" 414 bool "LED Trigger support"
408 depends on LEDS_CLASS 415 depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index b8a9723477f0..1fc6875a8b20 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_LEDS_LP5523) += leds-lp5523.o
28obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o 28obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o
29obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o 29obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
30obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o 30obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
31obj-$(CONFIG_LEDS_OT200) += leds-ot200.o
31obj-$(CONFIG_LEDS_FSG) += leds-fsg.o 32obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
32obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o 33obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
33obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o 34obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
diff --git a/drivers/leds/leds-ot200.c b/drivers/leds/leds-ot200.c
new file mode 100644
index 000000000000..c4646825a620
--- /dev/null
+++ b/drivers/leds/leds-ot200.c
@@ -0,0 +1,171 @@
1/*
2 * Bachmann ot200 leds driver.
3 *
4 * Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
5 * Christian Gmeiner <christian.gmeiner@gmail.com>
6 *
7 * License: GPL as published by the FSF.
8 */
9
10#include <linux/kernel.h>
11#include <linux/init.h>
12#include <linux/platform_device.h>
13#include <linux/slab.h>
14#include <linux/leds.h>
15#include <linux/io.h>
16#include <linux/module.h>
17
18
19struct ot200_led {
20 struct led_classdev cdev;
21 const char *name;
22 unsigned long port;
23 u8 mask;
24};
25
26/*
27 * The device has three leds on the back panel (led_err, led_init and led_run)
28 * and can handle up to seven leds on the front panel.
29 */
30
31static struct ot200_led leds[] = {
32 {
33 .name = "led_run",
34 .port = 0x5a,
35 .mask = BIT(0),
36 },
37 {
38 .name = "led_init",
39 .port = 0x5a,
40 .mask = BIT(1),
41 },
42 {
43 .name = "led_err",
44 .port = 0x5a,
45 .mask = BIT(2),
46 },
47 {
48 .name = "led_1",
49 .port = 0x49,
50 .mask = BIT(7),
51 },
52 {
53 .name = "led_2",
54 .port = 0x49,
55 .mask = BIT(6),
56 },
57 {
58 .name = "led_3",
59 .port = 0x49,
60 .mask = BIT(5),
61 },
62 {
63 .name = "led_4",
64 .port = 0x49,
65 .mask = BIT(4),
66 },
67 {
68 .name = "led_5",
69 .port = 0x49,
70 .mask = BIT(3),
71 },
72 {
73 .name = "led_6",
74 .port = 0x49,
75 .mask = BIT(2),
76 },
77 {
78 .name = "led_7",
79 .port = 0x49,
80 .mask = BIT(1),
81 }
82};
83
84static DEFINE_SPINLOCK(value_lock);
85
86/*
87 * we need to store the current led states, as it is not
88 * possible to read the current led state via inb().
89 */
90static u8 leds_back;
91static u8 leds_front;
92
93static void ot200_led_brightness_set(struct led_classdev *led_cdev,
94 enum led_brightness value)
95{
96 struct ot200_led *led = container_of(led_cdev, struct ot200_led, cdev);
97 u8 *val;
98 unsigned long flags;
99
100 spin_lock_irqsave(&value_lock, flags);
101
102 if (led->port == 0x49)
103 val = &leds_front;
104 else if (led->port == 0x5a)
105 val = &leds_back;
106 else
107 BUG();
108
109 if (value == LED_OFF)
110 *val &= ~led->mask;
111 else
112 *val |= led->mask;
113
114 outb(*val, led->port);
115 spin_unlock_irqrestore(&value_lock, flags);
116}
117
118static int __devinit ot200_led_probe(struct platform_device *pdev)
119{
120 int i;
121 int ret;
122
123 for (i = 0; i < ARRAY_SIZE(leds); i++) {
124
125 leds[i].cdev.name = leds[i].name;
126 leds[i].cdev.brightness_set = ot200_led_brightness_set;
127
128 ret = led_classdev_register(&pdev->dev, &leds[i].cdev);
129 if (ret < 0)
130 goto err;
131 }
132
133 leds_front = 0; /* turn off all front leds */
134 leds_back = BIT(1); /* turn on init led */
135 outb(leds_front, 0x49);
136 outb(leds_back, 0x5a);
137
138 return 0;
139
140err:
141 for (i = i - 1; i >= 0; i--)
142 led_classdev_unregister(&leds[i].cdev);
143
144 return ret;
145}
146
147static int __devexit ot200_led_remove(struct platform_device *pdev)
148{
149 int i;
150
151 for (i = 0; i < ARRAY_SIZE(leds); i++)
152 led_classdev_unregister(&leds[i].cdev);
153
154 return 0;
155}
156
157static struct platform_driver ot200_led_driver = {
158 .probe = ot200_led_probe,
159 .remove = __devexit_p(ot200_led_remove),
160 .driver = {
161 .name = "leds-ot200",
162 .owner = THIS_MODULE,
163 },
164};
165
166module_platform_driver(ot200_led_driver);
167
168MODULE_AUTHOR("Sebastian A. Siewior <bigeasy@linutronix.de>");
169MODULE_DESCRIPTION("ot200 LED driver");
170MODULE_LICENSE("GPL");
171MODULE_ALIAS("platform:leds-ot200");
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index 1455e2644ab5..cf0c318d6989 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -887,8 +887,7 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
887 887
888 /* attach demod */ 888 /* attach demod */
889 adap->fe_adap[state->fe_id].fe = dvb_attach(cxd2820r_attach, 889 adap->fe_adap[state->fe_id].fe = dvb_attach(cxd2820r_attach,
890 &anysee_cxd2820r_config, &adap->dev->i2c_adap, 890 &anysee_cxd2820r_config, &adap->dev->i2c_adap);
891 NULL);
892 891
893 state->has_ci = true; 892 state->has_ci = true;
894 893
@@ -1189,6 +1188,14 @@ static int anysee_ci_init(struct dvb_usb_device *d)
1189 if (ret) 1188 if (ret)
1190 return ret; 1189 return ret;
1191 1190
1191 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 2)|(0 << 1)|(0 << 0), 0x07);
1192 if (ret)
1193 return ret;
1194
1195 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 2)|(1 << 1)|(1 << 0), 0x07);
1196 if (ret)
1197 return ret;
1198
1192 ret = dvb_ca_en50221_init(&d->adapter[0].dvb_adap, &state->ci, 0, 1); 1199 ret = dvb_ca_en50221_init(&d->adapter[0].dvb_adap, &state->ci, 0, 1);
1193 if (ret) 1200 if (ret)
1194 return ret; 1201 return ret;
diff --git a/drivers/media/dvb/dvb-usb/cinergyT2-fe.c b/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
index 8a57ed8272de..1efc028a76c9 100644
--- a/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
+++ b/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
@@ -276,14 +276,15 @@ static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe)
276 param.flags = 0; 276 param.flags = 0;
277 277
278 switch (fep->bandwidth_hz) { 278 switch (fep->bandwidth_hz) {
279 default:
279 case 8000000: 280 case 8000000:
280 param.bandwidth = 0; 281 param.bandwidth = 8;
281 break; 282 break;
282 case 7000000: 283 case 7000000:
283 param.bandwidth = 1; 284 param.bandwidth = 7;
284 break; 285 break;
285 case 6000000: 286 case 6000000:
286 param.bandwidth = 2; 287 param.bandwidth = 6;
287 break; 288 break;
288 } 289 }
289 290
diff --git a/drivers/media/dvb/frontends/cxd2820r.h b/drivers/media/dvb/frontends/cxd2820r.h
index cf0f546aa1d1..5aa306ebb7ef 100644
--- a/drivers/media/dvb/frontends/cxd2820r.h
+++ b/drivers/media/dvb/frontends/cxd2820r.h
@@ -77,14 +77,12 @@ struct cxd2820r_config {
77 (defined(CONFIG_DVB_CXD2820R_MODULE) && defined(MODULE)) 77 (defined(CONFIG_DVB_CXD2820R_MODULE) && defined(MODULE))
78extern struct dvb_frontend *cxd2820r_attach( 78extern struct dvb_frontend *cxd2820r_attach(
79 const struct cxd2820r_config *config, 79 const struct cxd2820r_config *config,
80 struct i2c_adapter *i2c, 80 struct i2c_adapter *i2c
81 struct dvb_frontend *fe
82); 81);
83#else 82#else
84static inline struct dvb_frontend *cxd2820r_attach( 83static inline struct dvb_frontend *cxd2820r_attach(
85 const struct cxd2820r_config *config, 84 const struct cxd2820r_config *config,
86 struct i2c_adapter *i2c, 85 struct i2c_adapter *i2c
87 struct dvb_frontend *fe
88) 86)
89{ 87{
90 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 88 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
diff --git a/drivers/media/dvb/frontends/cxd2820r_core.c b/drivers/media/dvb/frontends/cxd2820r_core.c
index caae7f79c837..5c7c2aaf9bf5 100644
--- a/drivers/media/dvb/frontends/cxd2820r_core.c
+++ b/drivers/media/dvb/frontends/cxd2820r_core.c
@@ -482,10 +482,19 @@ static enum dvbfe_search cxd2820r_search(struct dvb_frontend *fe)
482 482
483 /* switch between DVB-T and DVB-T2 when tune fails */ 483 /* switch between DVB-T and DVB-T2 when tune fails */
484 if (priv->last_tune_failed) { 484 if (priv->last_tune_failed) {
485 if (priv->delivery_system == SYS_DVBT) 485 if (priv->delivery_system == SYS_DVBT) {
486 ret = cxd2820r_sleep_t(fe);
487 if (ret)
488 goto error;
489
486 c->delivery_system = SYS_DVBT2; 490 c->delivery_system = SYS_DVBT2;
487 else if (priv->delivery_system == SYS_DVBT2) 491 } else if (priv->delivery_system == SYS_DVBT2) {
492 ret = cxd2820r_sleep_t2(fe);
493 if (ret)
494 goto error;
495
488 c->delivery_system = SYS_DVBT; 496 c->delivery_system = SYS_DVBT;
497 }
489 } 498 }
490 499
491 /* set frontend */ 500 /* set frontend */
@@ -562,7 +571,7 @@ static const struct dvb_frontend_ops cxd2820r_ops = {
562 .delsys = { SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A }, 571 .delsys = { SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A },
563 /* default: DVB-T/T2 */ 572 /* default: DVB-T/T2 */
564 .info = { 573 .info = {
565 .name = "Sony CXD2820R (DVB-T/T2)", 574 .name = "Sony CXD2820R",
566 575
567 .caps = FE_CAN_FEC_1_2 | 576 .caps = FE_CAN_FEC_1_2 |
568 FE_CAN_FEC_2_3 | 577 FE_CAN_FEC_2_3 |
@@ -572,7 +581,9 @@ static const struct dvb_frontend_ops cxd2820r_ops = {
572 FE_CAN_FEC_AUTO | 581 FE_CAN_FEC_AUTO |
573 FE_CAN_QPSK | 582 FE_CAN_QPSK |
574 FE_CAN_QAM_16 | 583 FE_CAN_QAM_16 |
584 FE_CAN_QAM_32 |
575 FE_CAN_QAM_64 | 585 FE_CAN_QAM_64 |
586 FE_CAN_QAM_128 |
576 FE_CAN_QAM_256 | 587 FE_CAN_QAM_256 |
577 FE_CAN_QAM_AUTO | 588 FE_CAN_QAM_AUTO |
578 FE_CAN_TRANSMISSION_MODE_AUTO | 589 FE_CAN_TRANSMISSION_MODE_AUTO |
@@ -602,8 +613,7 @@ static const struct dvb_frontend_ops cxd2820r_ops = {
602}; 613};
603 614
604struct dvb_frontend *cxd2820r_attach(const struct cxd2820r_config *cfg, 615struct dvb_frontend *cxd2820r_attach(const struct cxd2820r_config *cfg,
605 struct i2c_adapter *i2c, 616 struct i2c_adapter *i2c)
606 struct dvb_frontend *fe)
607{ 617{
608 struct cxd2820r_priv *priv = NULL; 618 struct cxd2820r_priv *priv = NULL;
609 int ret; 619 int ret;
diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c
index 9fe4519176a4..ec3f6a06f9c3 100644
--- a/drivers/media/video/atmel-isi.c
+++ b/drivers/media/video/atmel-isi.c
@@ -922,7 +922,9 @@ static int __devexit atmel_isi_remove(struct platform_device *pdev)
922 isi->fb_descriptors_phys); 922 isi->fb_descriptors_phys);
923 923
924 iounmap(isi->regs); 924 iounmap(isi->regs);
925 clk_unprepare(isi->mck);
925 clk_put(isi->mck); 926 clk_put(isi->mck);
927 clk_unprepare(isi->pclk);
926 clk_put(isi->pclk); 928 clk_put(isi->pclk);
927 kfree(isi); 929 kfree(isi);
928 930
@@ -955,6 +957,10 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev)
955 if (IS_ERR(pclk)) 957 if (IS_ERR(pclk))
956 return PTR_ERR(pclk); 958 return PTR_ERR(pclk);
957 959
960 ret = clk_prepare(pclk);
961 if (ret)
962 goto err_clk_prepare_pclk;
963
958 isi = kzalloc(sizeof(struct atmel_isi), GFP_KERNEL); 964 isi = kzalloc(sizeof(struct atmel_isi), GFP_KERNEL);
959 if (!isi) { 965 if (!isi) {
960 ret = -ENOMEM; 966 ret = -ENOMEM;
@@ -978,6 +984,10 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev)
978 goto err_clk_get; 984 goto err_clk_get;
979 } 985 }
980 986
987 ret = clk_prepare(isi->mck);
988 if (ret)
989 goto err_clk_prepare_mck;
990
981 /* Set ISI_MCK's frequency, it should be faster than pixel clock */ 991 /* Set ISI_MCK's frequency, it should be faster than pixel clock */
982 ret = clk_set_rate(isi->mck, pdata->mck_hz); 992 ret = clk_set_rate(isi->mck, pdata->mck_hz);
983 if (ret < 0) 993 if (ret < 0)
@@ -1059,10 +1069,14 @@ err_alloc_ctx:
1059 isi->fb_descriptors_phys); 1069 isi->fb_descriptors_phys);
1060err_alloc_descriptors: 1070err_alloc_descriptors:
1061err_set_mck_rate: 1071err_set_mck_rate:
1072 clk_unprepare(isi->mck);
1073err_clk_prepare_mck:
1062 clk_put(isi->mck); 1074 clk_put(isi->mck);
1063err_clk_get: 1075err_clk_get:
1064 kfree(isi); 1076 kfree(isi);
1065err_alloc_isi: 1077err_alloc_isi:
1078 clk_unprepare(pclk);
1079err_clk_prepare_pclk:
1066 clk_put(pclk); 1080 clk_put(pclk);
1067 1081
1068 return ret; 1082 return ret;
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 9449423098e0..aabbf4854f66 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -853,8 +853,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
853 case EM28174_BOARD_PCTV_290E: 853 case EM28174_BOARD_PCTV_290E:
854 dvb->fe[0] = dvb_attach(cxd2820r_attach, 854 dvb->fe[0] = dvb_attach(cxd2820r_attach,
855 &em28xx_cxd2820r_config, 855 &em28xx_cxd2820r_config,
856 &dev->i2c_adap, 856 &dev->i2c_adap);
857 NULL);
858 if (dvb->fe[0]) { 857 if (dvb->fe[0]) {
859 /* FE 0 attach tuner */ 858 /* FE 0 attach tuner */
860 if (!dvb_attach(tda18271_attach, 859 if (!dvb_attach(tda18271_attach,
diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c
index 63be60bc3455..86cc3f7841cd 100644
--- a/drivers/mfd/mcp-core.c
+++ b/drivers/mfd/mcp-core.c
@@ -26,35 +26,9 @@
26#define to_mcp(d) container_of(d, struct mcp, attached_device) 26#define to_mcp(d) container_of(d, struct mcp, attached_device)
27#define to_mcp_driver(d) container_of(d, struct mcp_driver, drv) 27#define to_mcp_driver(d) container_of(d, struct mcp_driver, drv)
28 28
29static const struct mcp_device_id *mcp_match_id(const struct mcp_device_id *id,
30 const char *codec)
31{
32 while (id->name[0]) {
33 if (strcmp(codec, id->name) == 0)
34 return id;
35 id++;
36 }
37 return NULL;
38}
39
40const struct mcp_device_id *mcp_get_device_id(const struct mcp *mcp)
41{
42 const struct mcp_driver *driver =
43 to_mcp_driver(mcp->attached_device.driver);
44
45 return mcp_match_id(driver->id_table, mcp->codec);
46}
47EXPORT_SYMBOL(mcp_get_device_id);
48
49static int mcp_bus_match(struct device *dev, struct device_driver *drv) 29static int mcp_bus_match(struct device *dev, struct device_driver *drv)
50{ 30{
51 const struct mcp *mcp = to_mcp(dev); 31 return 1;
52 const struct mcp_driver *driver = to_mcp_driver(drv);
53
54 if (driver->id_table)
55 return !!mcp_match_id(driver->id_table, mcp->codec);
56
57 return 0;
58} 32}
59 33
60static int mcp_bus_probe(struct device *dev) 34static int mcp_bus_probe(struct device *dev)
@@ -100,18 +74,9 @@ static int mcp_bus_resume(struct device *dev)
100 return ret; 74 return ret;
101} 75}
102 76
103static int mcp_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
104{
105 struct mcp *mcp = to_mcp(dev);
106
107 add_uevent_var(env, "MODALIAS=%s%s", MCP_MODULE_PREFIX, mcp->codec);
108 return 0;
109}
110
111static struct bus_type mcp_bus_type = { 77static struct bus_type mcp_bus_type = {
112 .name = "mcp", 78 .name = "mcp",
113 .match = mcp_bus_match, 79 .match = mcp_bus_match,
114 .uevent = mcp_bus_uevent,
115 .probe = mcp_bus_probe, 80 .probe = mcp_bus_probe,
116 .remove = mcp_bus_remove, 81 .remove = mcp_bus_remove,
117 .suspend = mcp_bus_suspend, 82 .suspend = mcp_bus_suspend,
@@ -128,9 +93,11 @@ static struct bus_type mcp_bus_type = {
128 */ 93 */
129void mcp_set_telecom_divisor(struct mcp *mcp, unsigned int div) 94void mcp_set_telecom_divisor(struct mcp *mcp, unsigned int div)
130{ 95{
131 spin_lock_irq(&mcp->lock); 96 unsigned long flags;
97
98 spin_lock_irqsave(&mcp->lock, flags);
132 mcp->ops->set_telecom_divisor(mcp, div); 99 mcp->ops->set_telecom_divisor(mcp, div);
133 spin_unlock_irq(&mcp->lock); 100 spin_unlock_irqrestore(&mcp->lock, flags);
134} 101}
135EXPORT_SYMBOL(mcp_set_telecom_divisor); 102EXPORT_SYMBOL(mcp_set_telecom_divisor);
136 103
@@ -143,9 +110,11 @@ EXPORT_SYMBOL(mcp_set_telecom_divisor);
143 */ 110 */
144void mcp_set_audio_divisor(struct mcp *mcp, unsigned int div) 111void mcp_set_audio_divisor(struct mcp *mcp, unsigned int div)
145{ 112{
146 spin_lock_irq(&mcp->lock); 113 unsigned long flags;
114
115 spin_lock_irqsave(&mcp->lock, flags);
147 mcp->ops->set_audio_divisor(mcp, div); 116 mcp->ops->set_audio_divisor(mcp, div);
148 spin_unlock_irq(&mcp->lock); 117 spin_unlock_irqrestore(&mcp->lock, flags);
149} 118}
150EXPORT_SYMBOL(mcp_set_audio_divisor); 119EXPORT_SYMBOL(mcp_set_audio_divisor);
151 120
@@ -198,10 +167,11 @@ EXPORT_SYMBOL(mcp_reg_read);
198 */ 167 */
199void mcp_enable(struct mcp *mcp) 168void mcp_enable(struct mcp *mcp)
200{ 169{
201 spin_lock_irq(&mcp->lock); 170 unsigned long flags;
171 spin_lock_irqsave(&mcp->lock, flags);
202 if (mcp->use_count++ == 0) 172 if (mcp->use_count++ == 0)
203 mcp->ops->enable(mcp); 173 mcp->ops->enable(mcp);
204 spin_unlock_irq(&mcp->lock); 174 spin_unlock_irqrestore(&mcp->lock, flags);
205} 175}
206EXPORT_SYMBOL(mcp_enable); 176EXPORT_SYMBOL(mcp_enable);
207 177
@@ -247,14 +217,9 @@ struct mcp *mcp_host_alloc(struct device *parent, size_t size)
247} 217}
248EXPORT_SYMBOL(mcp_host_alloc); 218EXPORT_SYMBOL(mcp_host_alloc);
249 219
250int mcp_host_register(struct mcp *mcp, void *pdata) 220int mcp_host_register(struct mcp *mcp)
251{ 221{
252 if (!mcp->codec)
253 return -EINVAL;
254
255 mcp->attached_device.platform_data = pdata;
256 dev_set_name(&mcp->attached_device, "mcp0"); 222 dev_set_name(&mcp->attached_device, "mcp0");
257 request_module("%s%s", MCP_MODULE_PREFIX, mcp->codec);
258 return device_register(&mcp->attached_device); 223 return device_register(&mcp->attached_device);
259} 224}
260EXPORT_SYMBOL(mcp_host_register); 225EXPORT_SYMBOL(mcp_host_register);
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c
index 9adc2eb69492..02c53a0766c4 100644
--- a/drivers/mfd/mcp-sa11x0.c
+++ b/drivers/mfd/mcp-sa11x0.c
@@ -19,7 +19,6 @@
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/mfd/mcp.h> 21#include <linux/mfd/mcp.h>
22#include <linux/io.h>
23 22
24#include <mach/dma.h> 23#include <mach/dma.h>
25#include <mach/hardware.h> 24#include <mach/hardware.h>
@@ -27,19 +26,12 @@
27#include <asm/system.h> 26#include <asm/system.h>
28#include <mach/mcp.h> 27#include <mach/mcp.h>
29 28
30/* Register offsets */ 29#include <mach/assabet.h>
31#define MCCR0 0x00 30
32#define MCDR0 0x08
33#define MCDR1 0x0C
34#define MCDR2 0x10
35#define MCSR 0x18
36#define MCCR1 0x00
37 31
38struct mcp_sa11x0 { 32struct mcp_sa11x0 {
39 u32 mccr0; 33 u32 mccr0;
40 u32 mccr1; 34 u32 mccr1;
41 unsigned char *mccr0_base;
42 unsigned char *mccr1_base;
43}; 35};
44 36
45#define priv(mcp) ((struct mcp_sa11x0 *)mcp_priv(mcp)) 37#define priv(mcp) ((struct mcp_sa11x0 *)mcp_priv(mcp))
@@ -47,25 +39,25 @@ struct mcp_sa11x0 {
47static void 39static void
48mcp_sa11x0_set_telecom_divisor(struct mcp *mcp, unsigned int divisor) 40mcp_sa11x0_set_telecom_divisor(struct mcp *mcp, unsigned int divisor)
49{ 41{
50 struct mcp_sa11x0 *priv = priv(mcp); 42 unsigned int mccr0;
51 43
52 divisor /= 32; 44 divisor /= 32;
53 45
54 priv->mccr0 &= ~0x00007f00; 46 mccr0 = Ser4MCCR0 & ~0x00007f00;
55 priv->mccr0 |= divisor << 8; 47 mccr0 |= divisor << 8;
56 __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 48 Ser4MCCR0 = mccr0;
57} 49}
58 50
59static void 51static void
60mcp_sa11x0_set_audio_divisor(struct mcp *mcp, unsigned int divisor) 52mcp_sa11x0_set_audio_divisor(struct mcp *mcp, unsigned int divisor)
61{ 53{
62 struct mcp_sa11x0 *priv = priv(mcp); 54 unsigned int mccr0;
63 55
64 divisor /= 32; 56 divisor /= 32;
65 57
66 priv->mccr0 &= ~0x0000007f; 58 mccr0 = Ser4MCCR0 & ~0x0000007f;
67 priv->mccr0 |= divisor; 59 mccr0 |= divisor;
68 __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 60 Ser4MCCR0 = mccr0;
69} 61}
70 62
71/* 63/*
@@ -79,16 +71,12 @@ mcp_sa11x0_write(struct mcp *mcp, unsigned int reg, unsigned int val)
79{ 71{
80 int ret = -ETIME; 72 int ret = -ETIME;
81 int i; 73 int i;
82 u32 mcpreg;
83 struct mcp_sa11x0 *priv = priv(mcp);
84 74
85 mcpreg = reg << 17 | MCDR2_Wr | (val & 0xffff); 75 Ser4MCDR2 = reg << 17 | MCDR2_Wr | (val & 0xffff);
86 __raw_writel(mcpreg, priv->mccr0_base + MCDR2);
87 76
88 for (i = 0; i < 2; i++) { 77 for (i = 0; i < 2; i++) {
89 udelay(mcp->rw_timeout); 78 udelay(mcp->rw_timeout);
90 mcpreg = __raw_readl(priv->mccr0_base + MCSR); 79 if (Ser4MCSR & MCSR_CWC) {
91 if (mcpreg & MCSR_CWC) {
92 ret = 0; 80 ret = 0;
93 break; 81 break;
94 } 82 }
@@ -109,18 +97,13 @@ mcp_sa11x0_read(struct mcp *mcp, unsigned int reg)
109{ 97{
110 int ret = -ETIME; 98 int ret = -ETIME;
111 int i; 99 int i;
112 u32 mcpreg;
113 struct mcp_sa11x0 *priv = priv(mcp);
114 100
115 mcpreg = reg << 17 | MCDR2_Rd; 101 Ser4MCDR2 = reg << 17 | MCDR2_Rd;
116 __raw_writel(mcpreg, priv->mccr0_base + MCDR2);
117 102
118 for (i = 0; i < 2; i++) { 103 for (i = 0; i < 2; i++) {
119 udelay(mcp->rw_timeout); 104 udelay(mcp->rw_timeout);
120 mcpreg = __raw_readl(priv->mccr0_base + MCSR); 105 if (Ser4MCSR & MCSR_CRC) {
121 if (mcpreg & MCSR_CRC) { 106 ret = Ser4MCDR2 & 0xffff;
122 ret = __raw_readl(priv->mccr0_base + MCDR2)
123 & 0xffff;
124 break; 107 break;
125 } 108 }
126 } 109 }
@@ -133,19 +116,13 @@ mcp_sa11x0_read(struct mcp *mcp, unsigned int reg)
133 116
134static void mcp_sa11x0_enable(struct mcp *mcp) 117static void mcp_sa11x0_enable(struct mcp *mcp)
135{ 118{
136 struct mcp_sa11x0 *priv = priv(mcp); 119 Ser4MCSR = -1;
137 120 Ser4MCCR0 |= MCCR0_MCE;
138 __raw_writel(-1, priv->mccr0_base + MCSR);
139 priv->mccr0 |= MCCR0_MCE;
140 __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0);
141} 121}
142 122
143static void mcp_sa11x0_disable(struct mcp *mcp) 123static void mcp_sa11x0_disable(struct mcp *mcp)
144{ 124{
145 struct mcp_sa11x0 *priv = priv(mcp); 125 Ser4MCCR0 &= ~MCCR0_MCE;
146
147 priv->mccr0 &= ~MCCR0_MCE;
148 __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0);
149} 126}
150 127
151/* 128/*
@@ -165,69 +142,50 @@ static int mcp_sa11x0_probe(struct platform_device *pdev)
165 struct mcp_plat_data *data = pdev->dev.platform_data; 142 struct mcp_plat_data *data = pdev->dev.platform_data;
166 struct mcp *mcp; 143 struct mcp *mcp;
167 int ret; 144 int ret;
168 struct mcp_sa11x0 *priv;
169 struct resource *res_mem0, *res_mem1;
170 u32 size0, size1;
171 145
172 if (!data) 146 if (!data)
173 return -ENODEV; 147 return -ENODEV;
174 148
175 if (!data->codec) 149 if (!request_mem_region(0x80060000, 0x60, "sa11x0-mcp"))
176 return -ENODEV;
177
178 res_mem0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
179 if (!res_mem0)
180 return -ENODEV;
181 size0 = res_mem0->end - res_mem0->start + 1;
182
183 res_mem1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
184 if (!res_mem1)
185 return -ENODEV;
186 size1 = res_mem1->end - res_mem1->start + 1;
187
188 if (!request_mem_region(res_mem0->start, size0, "sa11x0-mcp"))
189 return -EBUSY; 150 return -EBUSY;
190 151
191 if (!request_mem_region(res_mem1->start, size1, "sa11x0-mcp")) {
192 ret = -EBUSY;
193 goto release;
194 }
195
196 mcp = mcp_host_alloc(&pdev->dev, sizeof(struct mcp_sa11x0)); 152 mcp = mcp_host_alloc(&pdev->dev, sizeof(struct mcp_sa11x0));
197 if (!mcp) { 153 if (!mcp) {
198 ret = -ENOMEM; 154 ret = -ENOMEM;
199 goto release2; 155 goto release;
200 } 156 }
201 157
202 priv = priv(mcp);
203
204 mcp->owner = THIS_MODULE; 158 mcp->owner = THIS_MODULE;
205 mcp->ops = &mcp_sa11x0; 159 mcp->ops = &mcp_sa11x0;
206 mcp->sclk_rate = data->sclk_rate; 160 mcp->sclk_rate = data->sclk_rate;
207 mcp->dma_audio_rd = DDAR_DevAdd(res_mem0->start + MCDR0) 161 mcp->dma_audio_rd = DMA_Ser4MCP0Rd;
208 + DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev; 162 mcp->dma_audio_wr = DMA_Ser4MCP0Wr;
209 mcp->dma_audio_wr = DDAR_DevAdd(res_mem0->start + MCDR0) 163 mcp->dma_telco_rd = DMA_Ser4MCP1Rd;
210 + DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev; 164 mcp->dma_telco_wr = DMA_Ser4MCP1Wr;
211 mcp->dma_telco_rd = DDAR_DevAdd(res_mem0->start + MCDR1) 165 mcp->gpio_base = data->gpio_base;
212 + DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev;
213 mcp->dma_telco_wr = DDAR_DevAdd(res_mem0->start + MCDR1)
214 + DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev;
215 mcp->codec = data->codec;
216 166
217 platform_set_drvdata(pdev, mcp); 167 platform_set_drvdata(pdev, mcp);
218 168
169 if (machine_is_assabet()) {
170 ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
171 }
172
173 /*
174 * Setup the PPC unit correctly.
175 */
176 PPDR &= ~PPC_RXD4;
177 PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
178 PSDR |= PPC_RXD4;
179 PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
180 PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
181
219 /* 182 /*
220 * Initialise device. Note that we initially 183 * Initialise device. Note that we initially
221 * set the sampling rate to minimum. 184 * set the sampling rate to minimum.
222 */ 185 */
223 priv->mccr0_base = ioremap(res_mem0->start, size0); 186 Ser4MCSR = -1;
224 priv->mccr1_base = ioremap(res_mem1->start, size1); 187 Ser4MCCR1 = data->mccr1;
225 188 Ser4MCCR0 = data->mccr0 | 0x7f7f;
226 __raw_writel(-1, priv->mccr0_base + MCSR);
227 priv->mccr1 = data->mccr1;
228 priv->mccr0 = data->mccr0 | 0x7f7f;
229 __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0);
230 __raw_writel(priv->mccr1, priv->mccr1_base + MCCR1);
231 189
232 /* 190 /*
233 * Calculate the read/write timeout (us) from the bit clock 191 * Calculate the read/write timeout (us) from the bit clock
@@ -237,53 +195,36 @@ static int mcp_sa11x0_probe(struct platform_device *pdev)
237 mcp->rw_timeout = (64 * 3 * 1000000 + mcp->sclk_rate - 1) / 195 mcp->rw_timeout = (64 * 3 * 1000000 + mcp->sclk_rate - 1) /
238 mcp->sclk_rate; 196 mcp->sclk_rate;
239 197
240 ret = mcp_host_register(mcp, data->codec_pdata); 198 ret = mcp_host_register(mcp);
241 if (ret == 0) 199 if (ret == 0)
242 goto out; 200 goto out;
243 201
244 release2:
245 release_mem_region(res_mem1->start, size1);
246 release: 202 release:
247 release_mem_region(res_mem0->start, size0); 203 release_mem_region(0x80060000, 0x60);
248 platform_set_drvdata(pdev, NULL); 204 platform_set_drvdata(pdev, NULL);
249 205
250 out: 206 out:
251 return ret; 207 return ret;
252} 208}
253 209
254static int mcp_sa11x0_remove(struct platform_device *pdev) 210static int mcp_sa11x0_remove(struct platform_device *dev)
255{ 211{
256 struct mcp *mcp = platform_get_drvdata(pdev); 212 struct mcp *mcp = platform_get_drvdata(dev);
257 struct mcp_sa11x0 *priv = priv(mcp);
258 struct resource *res_mem;
259 u32 size;
260 213
261 platform_set_drvdata(pdev, NULL); 214 platform_set_drvdata(dev, NULL);
262 mcp_host_unregister(mcp); 215 mcp_host_unregister(mcp);
216 release_mem_region(0x80060000, 0x60);
263 217
264 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
265 if (res_mem) {
266 size = res_mem->end - res_mem->start + 1;
267 release_mem_region(res_mem->start, size);
268 }
269 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
270 if (res_mem) {
271 size = res_mem->end - res_mem->start + 1;
272 release_mem_region(res_mem->start, size);
273 }
274 iounmap(priv->mccr0_base);
275 iounmap(priv->mccr1_base);
276 return 0; 218 return 0;
277} 219}
278 220
279static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state) 221static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state)
280{ 222{
281 struct mcp *mcp = platform_get_drvdata(dev); 223 struct mcp *mcp = platform_get_drvdata(dev);
282 struct mcp_sa11x0 *priv = priv(mcp);
283 u32 mccr0;
284 224
285 mccr0 = priv->mccr0 & ~MCCR0_MCE; 225 priv(mcp)->mccr0 = Ser4MCCR0;
286 __raw_writel(mccr0, priv->mccr0_base + MCCR0); 226 priv(mcp)->mccr1 = Ser4MCCR1;
227 Ser4MCCR0 &= ~MCCR0_MCE;
287 228
288 return 0; 229 return 0;
289} 230}
@@ -291,10 +232,9 @@ static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state)
291static int mcp_sa11x0_resume(struct platform_device *dev) 232static int mcp_sa11x0_resume(struct platform_device *dev)
292{ 233{
293 struct mcp *mcp = platform_get_drvdata(dev); 234 struct mcp *mcp = platform_get_drvdata(dev);
294 struct mcp_sa11x0 *priv = priv(mcp);
295 235
296 __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 236 Ser4MCCR1 = priv(mcp)->mccr1;
297 __raw_writel(priv->mccr1, priv->mccr1_base + MCCR1); 237 Ser4MCCR0 = priv(mcp)->mccr0;
298 238
299 return 0; 239 return 0;
300} 240}
@@ -311,7 +251,6 @@ static struct platform_driver mcp_sa11x0_driver = {
311 .resume = mcp_sa11x0_resume, 251 .resume = mcp_sa11x0_resume,
312 .driver = { 252 .driver = {
313 .name = "sa11x0-mcp", 253 .name = "sa11x0-mcp",
314 .owner = THIS_MODULE,
315 }, 254 },
316}; 255};
317 256
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index 91c4f25e0e55..febc90cdef7e 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -36,15 +36,6 @@ static DEFINE_MUTEX(ucb1x00_mutex);
36static LIST_HEAD(ucb1x00_drivers); 36static LIST_HEAD(ucb1x00_drivers);
37static LIST_HEAD(ucb1x00_devices); 37static LIST_HEAD(ucb1x00_devices);
38 38
39static struct mcp_device_id ucb1x00_id[] = {
40 { "ucb1x00", 0 }, /* auto-detection */
41 { "ucb1200", UCB_ID_1200 },
42 { "ucb1300", UCB_ID_1300 },
43 { "tc35143", UCB_ID_TC35143 },
44 { }
45};
46MODULE_DEVICE_TABLE(mcp, ucb1x00_id);
47
48/** 39/**
49 * ucb1x00_io_set_dir - set IO direction 40 * ucb1x00_io_set_dir - set IO direction
50 * @ucb: UCB1x00 structure describing chip 41 * @ucb: UCB1x00 structure describing chip
@@ -157,16 +148,22 @@ static int ucb1x00_gpio_direction_output(struct gpio_chip *chip, unsigned offset
157{ 148{
158 struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio); 149 struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
159 unsigned long flags; 150 unsigned long flags;
151 unsigned old, mask = 1 << offset;
160 152
161 spin_lock_irqsave(&ucb->io_lock, flags); 153 spin_lock_irqsave(&ucb->io_lock, flags);
162 ucb->io_dir |= (1 << offset); 154 old = ucb->io_out;
163 ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
164
165 if (value) 155 if (value)
166 ucb->io_out |= 1 << offset; 156 ucb->io_out |= mask;
167 else 157 else
168 ucb->io_out &= ~(1 << offset); 158 ucb->io_out &= ~mask;
169 ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out); 159
160 if (old != ucb->io_out)
161 ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
162
163 if (!(ucb->io_dir & mask)) {
164 ucb->io_dir |= mask;
165 ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
166 }
170 spin_unlock_irqrestore(&ucb->io_lock, flags); 167 spin_unlock_irqrestore(&ucb->io_lock, flags);
171 168
172 return 0; 169 return 0;
@@ -536,33 +533,17 @@ static struct class ucb1x00_class = {
536 533
537static int ucb1x00_probe(struct mcp *mcp) 534static int ucb1x00_probe(struct mcp *mcp)
538{ 535{
539 const struct mcp_device_id *mid;
540 struct ucb1x00 *ucb; 536 struct ucb1x00 *ucb;
541 struct ucb1x00_driver *drv; 537 struct ucb1x00_driver *drv;
542 struct ucb1x00_plat_data *pdata;
543 unsigned int id; 538 unsigned int id;
544 int ret = -ENODEV; 539 int ret = -ENODEV;
545 int temp; 540 int temp;
546 541
547 mcp_enable(mcp); 542 mcp_enable(mcp);
548 id = mcp_reg_read(mcp, UCB_ID); 543 id = mcp_reg_read(mcp, UCB_ID);
549 mid = mcp_get_device_id(mcp);
550 544
551 if (mid && mid->driver_data) { 545 if (id != UCB_ID_1200 && id != UCB_ID_1300 && id != UCB_ID_TC35143) {
552 if (id != mid->driver_data) { 546 printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id);
553 printk(KERN_WARNING "%s wrong ID %04x found: %04x\n",
554 mid->name, (unsigned int) mid->driver_data, id);
555 goto err_disable;
556 }
557 } else {
558 mid = &ucb1x00_id[1];
559 while (mid->driver_data) {
560 if (id == mid->driver_data)
561 break;
562 mid++;
563 }
564 printk(KERN_WARNING "%s ID not found: %04x\n",
565 ucb1x00_id[0].name, id);
566 goto err_disable; 547 goto err_disable;
567 } 548 }
568 549
@@ -571,28 +552,28 @@ static int ucb1x00_probe(struct mcp *mcp)
571 if (!ucb) 552 if (!ucb)
572 goto err_disable; 553 goto err_disable;
573 554
574 pdata = mcp->attached_device.platform_data; 555
575 ucb->dev.class = &ucb1x00_class; 556 ucb->dev.class = &ucb1x00_class;
576 ucb->dev.parent = &mcp->attached_device; 557 ucb->dev.parent = &mcp->attached_device;
577 dev_set_name(&ucb->dev, mid->name); 558 dev_set_name(&ucb->dev, "ucb1x00");
578 559
579 spin_lock_init(&ucb->lock); 560 spin_lock_init(&ucb->lock);
580 spin_lock_init(&ucb->io_lock); 561 spin_lock_init(&ucb->io_lock);
581 sema_init(&ucb->adc_sem, 1); 562 sema_init(&ucb->adc_sem, 1);
582 563
583 ucb->id = mid; 564 ucb->id = id;
584 ucb->mcp = mcp; 565 ucb->mcp = mcp;
585 ucb->irq = ucb1x00_detect_irq(ucb); 566 ucb->irq = ucb1x00_detect_irq(ucb);
586 if (ucb->irq == NO_IRQ) { 567 if (ucb->irq == NO_IRQ) {
587 printk(KERN_ERR "%s: IRQ probe failed\n", mid->name); 568 printk(KERN_ERR "UCB1x00: IRQ probe failed\n");
588 ret = -ENODEV; 569 ret = -ENODEV;
589 goto err_free; 570 goto err_free;
590 } 571 }
591 572
592 ucb->gpio.base = -1; 573 ucb->gpio.base = -1;
593 if (pdata && (pdata->gpio_base >= 0)) { 574 if (mcp->gpio_base != 0) {
594 ucb->gpio.label = dev_name(&ucb->dev); 575 ucb->gpio.label = dev_name(&ucb->dev);
595 ucb->gpio.base = pdata->gpio_base; 576 ucb->gpio.base = mcp->gpio_base;
596 ucb->gpio.ngpio = 10; 577 ucb->gpio.ngpio = 10;
597 ucb->gpio.set = ucb1x00_gpio_set; 578 ucb->gpio.set = ucb1x00_gpio_set;
598 ucb->gpio.get = ucb1x00_gpio_get; 579 ucb->gpio.get = ucb1x00_gpio_get;
@@ -605,10 +586,10 @@ static int ucb1x00_probe(struct mcp *mcp)
605 dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); 586 dev_info(&ucb->dev, "gpio_base not set so no gpiolib support");
606 587
607 ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, 588 ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING,
608 mid->name, ucb); 589 "UCB1x00", ucb);
609 if (ret) { 590 if (ret) {
610 printk(KERN_ERR "%s: unable to grab irq%d: %d\n", 591 printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n",
611 mid->name, ucb->irq, ret); 592 ucb->irq, ret);
612 goto err_gpio; 593 goto err_gpio;
613 } 594 }
614 595
@@ -712,6 +693,7 @@ static int ucb1x00_resume(struct mcp *mcp)
712 struct ucb1x00 *ucb = mcp_get_drvdata(mcp); 693 struct ucb1x00 *ucb = mcp_get_drvdata(mcp);
713 struct ucb1x00_dev *dev; 694 struct ucb1x00_dev *dev;
714 695
696 ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
715 ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir); 697 ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
716 mutex_lock(&ucb1x00_mutex); 698 mutex_lock(&ucb1x00_mutex);
717 list_for_each_entry(dev, &ucb->devs, dev_node) { 699 list_for_each_entry(dev, &ucb->devs, dev_node) {
@@ -730,7 +712,6 @@ static struct mcp_driver ucb1x00_driver = {
730 .remove = ucb1x00_remove, 712 .remove = ucb1x00_remove,
731 .suspend = ucb1x00_suspend, 713 .suspend = ucb1x00_suspend,
732 .resume = ucb1x00_resume, 714 .resume = ucb1x00_resume,
733 .id_table = ucb1x00_id,
734}; 715};
735 716
736static int __init ucb1x00_init(void) 717static int __init ucb1x00_init(void)
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index 40ec3c118868..63a3cbdfa3f3 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -47,7 +47,6 @@ struct ucb1x00_ts {
47 u16 x_res; 47 u16 x_res;
48 u16 y_res; 48 u16 y_res;
49 49
50 unsigned int restart:1;
51 unsigned int adcsync:1; 50 unsigned int adcsync:1;
52}; 51};
53 52
@@ -207,15 +206,17 @@ static int ucb1x00_thread(void *_ts)
207{ 206{
208 struct ucb1x00_ts *ts = _ts; 207 struct ucb1x00_ts *ts = _ts;
209 DECLARE_WAITQUEUE(wait, current); 208 DECLARE_WAITQUEUE(wait, current);
209 bool frozen, ignore = false;
210 int valid = 0; 210 int valid = 0;
211 211
212 set_freezable(); 212 set_freezable();
213 add_wait_queue(&ts->irq_wait, &wait); 213 add_wait_queue(&ts->irq_wait, &wait);
214 while (!kthread_should_stop()) { 214 while (!kthread_freezable_should_stop(&frozen)) {
215 unsigned int x, y, p; 215 unsigned int x, y, p;
216 signed long timeout; 216 signed long timeout;
217 217
218 ts->restart = 0; 218 if (frozen)
219 ignore = true;
219 220
220 ucb1x00_adc_enable(ts->ucb); 221 ucb1x00_adc_enable(ts->ucb);
221 222
@@ -258,7 +259,7 @@ static int ucb1x00_thread(void *_ts)
258 * space. We therefore leave it to user space 259 * space. We therefore leave it to user space
259 * to do any filtering they please. 260 * to do any filtering they please.
260 */ 261 */
261 if (!ts->restart) { 262 if (!ignore) {
262 ucb1x00_ts_evt_add(ts, p, x, y); 263 ucb1x00_ts_evt_add(ts, p, x, y);
263 valid = 1; 264 valid = 1;
264 } 265 }
@@ -267,8 +268,6 @@ static int ucb1x00_thread(void *_ts)
267 timeout = HZ / 100; 268 timeout = HZ / 100;
268 } 269 }
269 270
270 try_to_freeze();
271
272 schedule_timeout(timeout); 271 schedule_timeout(timeout);
273 } 272 }
274 273
@@ -340,26 +339,6 @@ static void ucb1x00_ts_close(struct input_dev *idev)
340 ucb1x00_disable(ts->ucb); 339 ucb1x00_disable(ts->ucb);
341} 340}
342 341
343#ifdef CONFIG_PM
344static int ucb1x00_ts_resume(struct ucb1x00_dev *dev)
345{
346 struct ucb1x00_ts *ts = dev->priv;
347
348 if (ts->rtask != NULL) {
349 /*
350 * Restart the TS thread to ensure the
351 * TS interrupt mode is set up again
352 * after sleep.
353 */
354 ts->restart = 1;
355 wake_up(&ts->irq_wait);
356 }
357 return 0;
358}
359#else
360#define ucb1x00_ts_resume NULL
361#endif
362
363 342
364/* 343/*
365 * Initialisation. 344 * Initialisation.
@@ -382,7 +361,7 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
382 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; 361 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC;
383 362
384 idev->name = "Touchscreen panel"; 363 idev->name = "Touchscreen panel";
385 idev->id.product = ts->ucb->id->driver_data; 364 idev->id.product = ts->ucb->id;
386 idev->open = ucb1x00_ts_open; 365 idev->open = ucb1x00_ts_open;
387 idev->close = ucb1x00_ts_close; 366 idev->close = ucb1x00_ts_close;
388 367
@@ -425,7 +404,6 @@ static void ucb1x00_ts_remove(struct ucb1x00_dev *dev)
425static struct ucb1x00_driver ucb1x00_ts_driver = { 404static struct ucb1x00_driver ucb1x00_ts_driver = {
426 .add = ucb1x00_ts_add, 405 .add = ucb1x00_ts_add,
427 .remove = ucb1x00_ts_remove, 406 .remove = ucb1x00_ts_remove,
428 .resume = ucb1x00_ts_resume,
429}; 407};
430 408
431static int __init ucb1x00_ts_init(void) 409static int __init ucb1x00_ts_init(void)
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 342626f4bc46..f820b26b9db3 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -909,16 +909,12 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
909 } 909 }
910} 910}
911 911
912/* hw is a boolean parameter that determines whether we should try and 912static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
913 * set the hw address of the device as well as the hw address of the
914 * net_device
915 */
916static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
917{ 913{
918 struct net_device *dev = slave->dev; 914 struct net_device *dev = slave->dev;
919 struct sockaddr s_addr; 915 struct sockaddr s_addr;
920 916
921 if (!hw) { 917 if (slave->bond->params.mode == BOND_MODE_TLB) {
922 memcpy(dev->dev_addr, addr, dev->addr_len); 918 memcpy(dev->dev_addr, addr, dev->addr_len);
923 return 0; 919 return 0;
924 } 920 }
@@ -948,8 +944,8 @@ static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct
948 u8 tmp_mac_addr[ETH_ALEN]; 944 u8 tmp_mac_addr[ETH_ALEN];
949 945
950 memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN); 946 memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN);
951 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled); 947 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr);
952 alb_set_slave_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled); 948 alb_set_slave_mac_addr(slave2, tmp_mac_addr);
953 949
954} 950}
955 951
@@ -1096,8 +1092,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
1096 1092
1097 /* Try setting slave mac to bond address and fall-through 1093 /* Try setting slave mac to bond address and fall-through
1098 to code handling that situation below... */ 1094 to code handling that situation below... */
1099 alb_set_slave_mac_addr(slave, bond->dev->dev_addr, 1095 alb_set_slave_mac_addr(slave, bond->dev->dev_addr);
1100 bond->alb_info.rlb_enabled);
1101 } 1096 }
1102 1097
1103 /* The slave's address is equal to the address of the bond. 1098 /* The slave's address is equal to the address of the bond.
@@ -1133,8 +1128,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
1133 } 1128 }
1134 1129
1135 if (free_mac_slave) { 1130 if (free_mac_slave) {
1136 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, 1131 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr);
1137 bond->alb_info.rlb_enabled);
1138 1132
1139 pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n", 1133 pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n",
1140 bond->dev->name, slave->dev->name, 1134 bond->dev->name, slave->dev->name,
@@ -1491,8 +1485,7 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1491{ 1485{
1492 int res; 1486 int res;
1493 1487
1494 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, 1488 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr);
1495 bond->alb_info.rlb_enabled);
1496 if (res) { 1489 if (res) {
1497 return res; 1490 return res;
1498 } 1491 }
@@ -1643,8 +1636,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
1643 alb_swap_mac_addr(bond, swap_slave, new_slave); 1636 alb_swap_mac_addr(bond, swap_slave, new_slave);
1644 } else { 1637 } else {
1645 /* set the new_slave to the bond mac address */ 1638 /* set the new_slave to the bond mac address */
1646 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr, 1639 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr);
1647 bond->alb_info.rlb_enabled);
1648 } 1640 }
1649 1641
1650 if (swap_slave) { 1642 if (swap_slave) {
@@ -1704,8 +1696,7 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1704 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave); 1696 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave);
1705 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave); 1697 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave);
1706 } else { 1698 } else {
1707 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr, 1699 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr);
1708 bond->alb_info.rlb_enabled);
1709 1700
1710 read_lock(&bond->lock); 1701 read_lock(&bond->lock);
1711 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr); 1702 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr);
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 7fc4e81d4d43..325391d19bad 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/module.h>
12#include <linux/netdevice.h> 13#include <linux/netdevice.h>
13#include <linux/phy.h> 14#include <linux/phy.h>
14#include <net/dsa.h> 15#include <net/dsa.h>
diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c
index c0a458fc698f..c17c75b9f531 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/module.h>
12#include <linux/netdevice.h> 13#include <linux/netdevice.h>
13#include <linux/phy.h> 14#include <linux/phy.h>
14#include <net/dsa.h> 15#include <net/dsa.h>
@@ -20,12 +21,25 @@ static char *mv88e6123_61_65_probe(struct mii_bus *bus, int sw_addr)
20 21
21 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); 22 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03);
22 if (ret >= 0) { 23 if (ret >= 0) {
23 ret &= 0xfff0; 24 if (ret == 0x1212)
24 if (ret == 0x1210) 25 return "Marvell 88E6123 (A1)";
26 if (ret == 0x1213)
27 return "Marvell 88E6123 (A2)";
28 if ((ret & 0xfff0) == 0x1210)
25 return "Marvell 88E6123"; 29 return "Marvell 88E6123";
26 if (ret == 0x1610) 30
31 if (ret == 0x1612)
32 return "Marvell 88E6161 (A1)";
33 if (ret == 0x1613)
34 return "Marvell 88E6161 (A2)";
35 if ((ret & 0xfff0) == 0x1610)
27 return "Marvell 88E6161"; 36 return "Marvell 88E6161";
28 if (ret == 0x1650) 37
38 if (ret == 0x1652)
39 return "Marvell 88E6165 (A1)";
40 if (ret == 0x1653)
41 return "Marvell 88e6165 (A2)";
42 if ((ret & 0xfff0) == 0x1650)
29 return "Marvell 88E6165"; 43 return "Marvell 88E6165";
30 } 44 }
31 45
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index e0eb68243834..55888b06d8b4 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/module.h>
12#include <linux/netdevice.h> 13#include <linux/netdevice.h>
13#include <linux/phy.h> 14#include <linux/phy.h>
14#include <net/dsa.h> 15#include <net/dsa.h>
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 5467c040824a..a2c62c2f30ee 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/module.h>
12#include <linux/netdevice.h> 13#include <linux/netdevice.h>
13#include <linux/phy.h> 14#include <linux/phy.h>
14#include <net/dsa.h> 15#include <net/dsa.h>
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 2b731b253598..03f3935fd8c2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -3117,7 +3117,7 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
3117 int rx_ring_size = 0; 3117 int rx_ring_size = 0;
3118 3118
3119#ifdef BCM_CNIC 3119#ifdef BCM_CNIC
3120 if (IS_MF_ISCSI_SD(bp)) { 3120 if (!bp->rx_ring_size && IS_MF_ISCSI_SD(bp)) {
3121 rx_ring_size = MIN_RX_SIZE_NONTPA; 3121 rx_ring_size = MIN_RX_SIZE_NONTPA;
3122 bp->rx_ring_size = rx_ring_size; 3122 bp->rx_ring_size = rx_ring_size;
3123 } else 3123 } else
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index f99c6e312a5d..31a8b38ab15e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -1738,7 +1738,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode)
1738 struct bnx2x_fp_txdata *txdata = &fp_tx->txdata[0]; 1738 struct bnx2x_fp_txdata *txdata = &fp_tx->txdata[0];
1739 u16 tx_start_idx, tx_idx; 1739 u16 tx_start_idx, tx_idx;
1740 u16 rx_start_idx, rx_idx; 1740 u16 rx_start_idx, rx_idx;
1741 u16 pkt_prod, bd_prod, rx_comp_cons; 1741 u16 pkt_prod, bd_prod;
1742 struct sw_tx_bd *tx_buf; 1742 struct sw_tx_bd *tx_buf;
1743 struct eth_tx_start_bd *tx_start_bd; 1743 struct eth_tx_start_bd *tx_start_bd;
1744 struct eth_tx_parse_bd_e1x *pbd_e1x = NULL; 1744 struct eth_tx_parse_bd_e1x *pbd_e1x = NULL;
@@ -1873,8 +1873,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode)
1873 if (rx_idx != rx_start_idx + num_pkts) 1873 if (rx_idx != rx_start_idx + num_pkts)
1874 goto test_loopback_exit; 1874 goto test_loopback_exit;
1875 1875
1876 rx_comp_cons = le16_to_cpu(fp_rx->rx_comp_cons); 1876 cqe = &fp_rx->rx_comp_ring[RCQ_BD(fp_rx->rx_comp_cons)];
1877 cqe = &fp_rx->rx_comp_ring[RCQ_BD(rx_comp_cons)];
1878 cqe_fp_flags = cqe->fast_path_cqe.type_error_flags; 1877 cqe_fp_flags = cqe->fast_path_cqe.type_error_flags;
1879 cqe_fp_type = cqe_fp_flags & ETH_FAST_PATH_RX_CQE_TYPE; 1878 cqe_fp_type = cqe_fp_flags & ETH_FAST_PATH_RX_CQE_TYPE;
1880 if (!CQE_TYPE_FAST(cqe_fp_type) || (cqe_fp_flags & ETH_RX_ERROR_FALGS)) 1879 if (!CQE_TYPE_FAST(cqe_fp_type) || (cqe_fp_flags & ETH_RX_ERROR_FALGS))
@@ -2121,18 +2120,16 @@ static int bnx2x_get_sset_count(struct net_device *dev, int stringset)
2121 case ETH_SS_STATS: 2120 case ETH_SS_STATS:
2122 if (is_multi(bp)) { 2121 if (is_multi(bp)) {
2123 num_stats = bnx2x_num_stat_queues(bp) * 2122 num_stats = bnx2x_num_stat_queues(bp) *
2124 BNX2X_NUM_Q_STATS; 2123 BNX2X_NUM_Q_STATS;
2125 if (!IS_MF_MODE_STAT(bp)) 2124 } else
2126 num_stats += BNX2X_NUM_STATS; 2125 num_stats = 0;
2127 } else { 2126 if (IS_MF_MODE_STAT(bp)) {
2128 if (IS_MF_MODE_STAT(bp)) { 2127 for (i = 0; i < BNX2X_NUM_STATS; i++)
2129 num_stats = 0; 2128 if (IS_FUNC_STAT(i))
2130 for (i = 0; i < BNX2X_NUM_STATS; i++) 2129 num_stats++;
2131 if (IS_FUNC_STAT(i)) 2130 } else
2132 num_stats++; 2131 num_stats += BNX2X_NUM_STATS;
2133 } else 2132
2134 num_stats = BNX2X_NUM_STATS;
2135 }
2136 return num_stats; 2133 return num_stats;
2137 2134
2138 case ETH_SS_TEST: 2135 case ETH_SS_TEST:
@@ -2151,8 +2148,8 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
2151 2148
2152 switch (stringset) { 2149 switch (stringset) {
2153 case ETH_SS_STATS: 2150 case ETH_SS_STATS:
2151 k = 0;
2154 if (is_multi(bp)) { 2152 if (is_multi(bp)) {
2155 k = 0;
2156 for_each_eth_queue(bp, i) { 2153 for_each_eth_queue(bp, i) {
2157 memset(queue_name, 0, sizeof(queue_name)); 2154 memset(queue_name, 0, sizeof(queue_name));
2158 sprintf(queue_name, "%d", i); 2155 sprintf(queue_name, "%d", i);
@@ -2163,20 +2160,17 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
2163 queue_name); 2160 queue_name);
2164 k += BNX2X_NUM_Q_STATS; 2161 k += BNX2X_NUM_Q_STATS;
2165 } 2162 }
2166 if (IS_MF_MODE_STAT(bp))
2167 break;
2168 for (j = 0; j < BNX2X_NUM_STATS; j++)
2169 strcpy(buf + (k + j)*ETH_GSTRING_LEN,
2170 bnx2x_stats_arr[j].string);
2171 } else {
2172 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) {
2173 if (IS_MF_MODE_STAT(bp) && IS_PORT_STAT(i))
2174 continue;
2175 strcpy(buf + j*ETH_GSTRING_LEN,
2176 bnx2x_stats_arr[i].string);
2177 j++;
2178 }
2179 } 2163 }
2164
2165
2166 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) {
2167 if (IS_MF_MODE_STAT(bp) && IS_PORT_STAT(i))
2168 continue;
2169 strcpy(buf + (k + j)*ETH_GSTRING_LEN,
2170 bnx2x_stats_arr[i].string);
2171 j++;
2172 }
2173
2180 break; 2174 break;
2181 2175
2182 case ETH_SS_TEST: 2176 case ETH_SS_TEST:
@@ -2190,10 +2184,9 @@ static void bnx2x_get_ethtool_stats(struct net_device *dev,
2190{ 2184{
2191 struct bnx2x *bp = netdev_priv(dev); 2185 struct bnx2x *bp = netdev_priv(dev);
2192 u32 *hw_stats, *offset; 2186 u32 *hw_stats, *offset;
2193 int i, j, k; 2187 int i, j, k = 0;
2194 2188
2195 if (is_multi(bp)) { 2189 if (is_multi(bp)) {
2196 k = 0;
2197 for_each_eth_queue(bp, i) { 2190 for_each_eth_queue(bp, i) {
2198 hw_stats = (u32 *)&bp->fp[i].eth_q_stats; 2191 hw_stats = (u32 *)&bp->fp[i].eth_q_stats;
2199 for (j = 0; j < BNX2X_NUM_Q_STATS; j++) { 2192 for (j = 0; j < BNX2X_NUM_Q_STATS; j++) {
@@ -2214,46 +2207,28 @@ static void bnx2x_get_ethtool_stats(struct net_device *dev,
2214 } 2207 }
2215 k += BNX2X_NUM_Q_STATS; 2208 k += BNX2X_NUM_Q_STATS;
2216 } 2209 }
2217 if (IS_MF_MODE_STAT(bp)) 2210 }
2218 return; 2211
2219 hw_stats = (u32 *)&bp->eth_stats; 2212 hw_stats = (u32 *)&bp->eth_stats;
2220 for (j = 0; j < BNX2X_NUM_STATS; j++) { 2213 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) {
2221 if (bnx2x_stats_arr[j].size == 0) { 2214 if (IS_MF_MODE_STAT(bp) && IS_PORT_STAT(i))
2222 /* skip this counter */ 2215 continue;
2223 buf[k + j] = 0; 2216 if (bnx2x_stats_arr[i].size == 0) {
2224 continue; 2217 /* skip this counter */
2225 } 2218 buf[k + j] = 0;
2226 offset = (hw_stats + bnx2x_stats_arr[j].offset); 2219 j++;
2227 if (bnx2x_stats_arr[j].size == 4) { 2220 continue;
2228 /* 4-byte counter */
2229 buf[k + j] = (u64) *offset;
2230 continue;
2231 }
2232 /* 8-byte counter */
2233 buf[k + j] = HILO_U64(*offset, *(offset + 1));
2234 } 2221 }
2235 } else { 2222 offset = (hw_stats + bnx2x_stats_arr[i].offset);
2236 hw_stats = (u32 *)&bp->eth_stats; 2223 if (bnx2x_stats_arr[i].size == 4) {
2237 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) { 2224 /* 4-byte counter */
2238 if (IS_MF_MODE_STAT(bp) && IS_PORT_STAT(i)) 2225 buf[k + j] = (u64) *offset;
2239 continue;
2240 if (bnx2x_stats_arr[i].size == 0) {
2241 /* skip this counter */
2242 buf[j] = 0;
2243 j++;
2244 continue;
2245 }
2246 offset = (hw_stats + bnx2x_stats_arr[i].offset);
2247 if (bnx2x_stats_arr[i].size == 4) {
2248 /* 4-byte counter */
2249 buf[j] = (u64) *offset;
2250 j++;
2251 continue;
2252 }
2253 /* 8-byte counter */
2254 buf[j] = HILO_U64(*offset, *(offset + 1));
2255 j++; 2226 j++;
2227 continue;
2256 } 2228 }
2229 /* 8-byte counter */
2230 buf[k + j] = HILO_U64(*offset, *(offset + 1));
2231 j++;
2257 } 2232 }
2258} 2233}
2259 2234
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index ffeaaa95ed96..1e3f978ee6da 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -941,7 +941,7 @@ void bnx2x_panic_dump(struct bnx2x *bp)
941 struct sw_rx_bd *sw_bd = &fp->rx_buf_ring[j]; 941 struct sw_rx_bd *sw_bd = &fp->rx_buf_ring[j];
942 942
943 BNX2X_ERR("fp%d: rx_bd[%x]=[%x:%x] sw_bd=[%p]\n", 943 BNX2X_ERR("fp%d: rx_bd[%x]=[%x:%x] sw_bd=[%p]\n",
944 i, j, rx_bd[1], rx_bd[0], sw_bd->skb); 944 i, j, rx_bd[1], rx_bd[0], sw_bd->data);
945 } 945 }
946 946
947 start = RX_SGE(fp->rx_sge_prod); 947 start = RX_SGE(fp->rx_sge_prod);
@@ -10536,6 +10536,9 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10536{ 10536{
10537 struct bnx2x *bp; 10537 struct bnx2x *bp;
10538 int rc; 10538 int rc;
10539 bool chip_is_e1x = (board_type == BCM57710 ||
10540 board_type == BCM57711 ||
10541 board_type == BCM57711E);
10539 10542
10540 SET_NETDEV_DEV(dev, &pdev->dev); 10543 SET_NETDEV_DEV(dev, &pdev->dev);
10541 bp = netdev_priv(dev); 10544 bp = netdev_priv(dev);
@@ -10624,7 +10627,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10624 REG_WR(bp, PXP2_REG_PGL_ADDR_90_F0, 0); 10627 REG_WR(bp, PXP2_REG_PGL_ADDR_90_F0, 0);
10625 REG_WR(bp, PXP2_REG_PGL_ADDR_94_F0, 0); 10628 REG_WR(bp, PXP2_REG_PGL_ADDR_94_F0, 0);
10626 10629
10627 if (CHIP_IS_E1x(bp)) { 10630 if (chip_is_e1x) {
10628 REG_WR(bp, PXP2_REG_PGL_ADDR_88_F1, 0); 10631 REG_WR(bp, PXP2_REG_PGL_ADDR_88_F1, 0);
10629 REG_WR(bp, PXP2_REG_PGL_ADDR_8C_F1, 0); 10632 REG_WR(bp, PXP2_REG_PGL_ADDR_8C_F1, 0);
10630 REG_WR(bp, PXP2_REG_PGL_ADDR_90_F1, 0); 10633 REG_WR(bp, PXP2_REG_PGL_ADDR_90_F1, 0);
@@ -10635,9 +10638,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10635 * Enable internal target-read (in case we are probed after PF FLR). 10638 * Enable internal target-read (in case we are probed after PF FLR).
10636 * Must be done prior to any BAR read access. Only for 57712 and up 10639 * Must be done prior to any BAR read access. Only for 57712 and up
10637 */ 10640 */
10638 if (board_type != BCM57710 && 10641 if (!chip_is_e1x)
10639 board_type != BCM57711 &&
10640 board_type != BCM57711E)
10641 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); 10642 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1);
10642 10643
10643 /* Reset the load counter */ 10644 /* Reset the load counter */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index 5ac616093f9f..cb6339c35571 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -50,6 +50,7 @@ static inline void bnx2x_exe_queue_init(struct bnx2x *bp,
50 int exe_len, 50 int exe_len,
51 union bnx2x_qable_obj *owner, 51 union bnx2x_qable_obj *owner,
52 exe_q_validate validate, 52 exe_q_validate validate,
53 exe_q_remove remove,
53 exe_q_optimize optimize, 54 exe_q_optimize optimize,
54 exe_q_execute exec, 55 exe_q_execute exec,
55 exe_q_get get) 56 exe_q_get get)
@@ -66,6 +67,7 @@ static inline void bnx2x_exe_queue_init(struct bnx2x *bp,
66 67
67 /* Owner specific callbacks */ 68 /* Owner specific callbacks */
68 o->validate = validate; 69 o->validate = validate;
70 o->remove = remove;
69 o->optimize = optimize; 71 o->optimize = optimize;
70 o->execute = exec; 72 o->execute = exec;
71 o->get = get; 73 o->get = get;
@@ -1340,6 +1342,35 @@ static int bnx2x_validate_vlan_mac(struct bnx2x *bp,
1340 } 1342 }
1341} 1343}
1342 1344
1345static int bnx2x_remove_vlan_mac(struct bnx2x *bp,
1346 union bnx2x_qable_obj *qo,
1347 struct bnx2x_exeq_elem *elem)
1348{
1349 int rc = 0;
1350
1351 /* If consumption wasn't required, nothing to do */
1352 if (test_bit(BNX2X_DONT_CONSUME_CAM_CREDIT,
1353 &elem->cmd_data.vlan_mac.vlan_mac_flags))
1354 return 0;
1355
1356 switch (elem->cmd_data.vlan_mac.cmd) {
1357 case BNX2X_VLAN_MAC_ADD:
1358 case BNX2X_VLAN_MAC_MOVE:
1359 rc = qo->vlan_mac.put_credit(&qo->vlan_mac);
1360 break;
1361 case BNX2X_VLAN_MAC_DEL:
1362 rc = qo->vlan_mac.get_credit(&qo->vlan_mac);
1363 break;
1364 default:
1365 return -EINVAL;
1366 }
1367
1368 if (rc != true)
1369 return -EINVAL;
1370
1371 return 0;
1372}
1373
1343/** 1374/**
1344 * bnx2x_wait_vlan_mac - passivly wait for 5 seconds until all work completes. 1375 * bnx2x_wait_vlan_mac - passivly wait for 5 seconds until all work completes.
1345 * 1376 *
@@ -1801,8 +1832,14 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
1801 1832
1802 list_for_each_entry_safe(exeq_pos, exeq_pos_n, &exeq->exe_queue, link) { 1833 list_for_each_entry_safe(exeq_pos, exeq_pos_n, &exeq->exe_queue, link) {
1803 if (exeq_pos->cmd_data.vlan_mac.vlan_mac_flags == 1834 if (exeq_pos->cmd_data.vlan_mac.vlan_mac_flags ==
1804 *vlan_mac_flags) 1835 *vlan_mac_flags) {
1836 rc = exeq->remove(bp, exeq->owner, exeq_pos);
1837 if (rc) {
1838 BNX2X_ERR("Failed to remove command\n");
1839 return rc;
1840 }
1805 list_del(&exeq_pos->link); 1841 list_del(&exeq_pos->link);
1842 }
1806 } 1843 }
1807 1844
1808 spin_unlock_bh(&exeq->lock); 1845 spin_unlock_bh(&exeq->lock);
@@ -1908,6 +1945,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,
1908 bnx2x_exe_queue_init(bp, 1945 bnx2x_exe_queue_init(bp,
1909 &mac_obj->exe_queue, 1, qable_obj, 1946 &mac_obj->exe_queue, 1, qable_obj,
1910 bnx2x_validate_vlan_mac, 1947 bnx2x_validate_vlan_mac,
1948 bnx2x_remove_vlan_mac,
1911 bnx2x_optimize_vlan_mac, 1949 bnx2x_optimize_vlan_mac,
1912 bnx2x_execute_vlan_mac, 1950 bnx2x_execute_vlan_mac,
1913 bnx2x_exeq_get_mac); 1951 bnx2x_exeq_get_mac);
@@ -1924,6 +1962,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,
1924 bnx2x_exe_queue_init(bp, 1962 bnx2x_exe_queue_init(bp,
1925 &mac_obj->exe_queue, CLASSIFY_RULES_COUNT, 1963 &mac_obj->exe_queue, CLASSIFY_RULES_COUNT,
1926 qable_obj, bnx2x_validate_vlan_mac, 1964 qable_obj, bnx2x_validate_vlan_mac,
1965 bnx2x_remove_vlan_mac,
1927 bnx2x_optimize_vlan_mac, 1966 bnx2x_optimize_vlan_mac,
1928 bnx2x_execute_vlan_mac, 1967 bnx2x_execute_vlan_mac,
1929 bnx2x_exeq_get_mac); 1968 bnx2x_exeq_get_mac);
@@ -1963,6 +2002,7 @@ void bnx2x_init_vlan_obj(struct bnx2x *bp,
1963 bnx2x_exe_queue_init(bp, 2002 bnx2x_exe_queue_init(bp,
1964 &vlan_obj->exe_queue, CLASSIFY_RULES_COUNT, 2003 &vlan_obj->exe_queue, CLASSIFY_RULES_COUNT,
1965 qable_obj, bnx2x_validate_vlan_mac, 2004 qable_obj, bnx2x_validate_vlan_mac,
2005 bnx2x_remove_vlan_mac,
1966 bnx2x_optimize_vlan_mac, 2006 bnx2x_optimize_vlan_mac,
1967 bnx2x_execute_vlan_mac, 2007 bnx2x_execute_vlan_mac,
1968 bnx2x_exeq_get_vlan); 2008 bnx2x_exeq_get_vlan);
@@ -2009,6 +2049,7 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
2009 bnx2x_exe_queue_init(bp, 2049 bnx2x_exe_queue_init(bp,
2010 &vlan_mac_obj->exe_queue, 1, qable_obj, 2050 &vlan_mac_obj->exe_queue, 1, qable_obj,
2011 bnx2x_validate_vlan_mac, 2051 bnx2x_validate_vlan_mac,
2052 bnx2x_remove_vlan_mac,
2012 bnx2x_optimize_vlan_mac, 2053 bnx2x_optimize_vlan_mac,
2013 bnx2x_execute_vlan_mac, 2054 bnx2x_execute_vlan_mac,
2014 bnx2x_exeq_get_vlan_mac); 2055 bnx2x_exeq_get_vlan_mac);
@@ -2025,6 +2066,7 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
2025 &vlan_mac_obj->exe_queue, 2066 &vlan_mac_obj->exe_queue,
2026 CLASSIFY_RULES_COUNT, 2067 CLASSIFY_RULES_COUNT,
2027 qable_obj, bnx2x_validate_vlan_mac, 2068 qable_obj, bnx2x_validate_vlan_mac,
2069 bnx2x_remove_vlan_mac,
2028 bnx2x_optimize_vlan_mac, 2070 bnx2x_optimize_vlan_mac,
2029 bnx2x_execute_vlan_mac, 2071 bnx2x_execute_vlan_mac,
2030 bnx2x_exeq_get_vlan_mac); 2072 bnx2x_exeq_get_vlan_mac);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
index 992308ff82e8..66da39f0c84a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
@@ -161,6 +161,10 @@ typedef int (*exe_q_validate)(struct bnx2x *bp,
161 union bnx2x_qable_obj *o, 161 union bnx2x_qable_obj *o,
162 struct bnx2x_exeq_elem *elem); 162 struct bnx2x_exeq_elem *elem);
163 163
164typedef int (*exe_q_remove)(struct bnx2x *bp,
165 union bnx2x_qable_obj *o,
166 struct bnx2x_exeq_elem *elem);
167
164/** 168/**
165 * @return positive is entry was optimized, 0 - if not, negative 169 * @return positive is entry was optimized, 0 - if not, negative
166 * in case of an error. 170 * in case of an error.
@@ -203,11 +207,18 @@ struct bnx2x_exe_queue_obj {
203 */ 207 */
204 exe_q_validate validate; 208 exe_q_validate validate;
205 209
210 /**
211 * Called before removing pending commands, cleaning allocated
212 * resources (e.g., credits from validate)
213 */
214 exe_q_remove remove;
206 215
207 /** 216 /**
208 * This will try to cancel the current pending commands list 217 * This will try to cancel the current pending commands list
209 * considering the new command. 218 * considering the new command.
210 * 219 *
220 * Returns the number of optimized commands or a negative error code
221 *
211 * Must run under exe_queue->lock 222 * Must run under exe_queue->lock
212 */ 223 */
213 exe_q_optimize optimize; 224 exe_q_optimize optimize;
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index d529af99157d..a1f2e0fed78b 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -6667,14 +6667,9 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
6667 iph = ip_hdr(skb); 6667 iph = ip_hdr(skb);
6668 tcp_opt_len = tcp_optlen(skb); 6668 tcp_opt_len = tcp_optlen(skb);
6669 6669
6670 if (skb_is_gso_v6(skb)) { 6670 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb) - ETH_HLEN;
6671 hdr_len = skb_headlen(skb) - ETH_HLEN;
6672 } else {
6673 u32 ip_tcp_len;
6674
6675 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
6676 hdr_len = ip_tcp_len + tcp_opt_len;
6677 6671
6672 if (!skb_is_gso_v6(skb)) {
6678 iph->check = 0; 6673 iph->check = 0;
6679 iph->tot_len = htons(mss + hdr_len); 6674 iph->tot_len = htons(mss + hdr_len);
6680 } 6675 }
diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
index fe0c29acdbe6..ee93a2087fe6 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -32,7 +32,7 @@
32 32
33#define DRV_NAME "enic" 33#define DRV_NAME "enic"
34#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" 34#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver"
35#define DRV_VERSION "2.1.1.28" 35#define DRV_VERSION "2.1.1.31"
36#define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" 36#define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc"
37 37
38#define ENIC_BARS_MAX 6 38#define ENIC_BARS_MAX 6
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 2fd9db4b1be5..ab3f67f980d8 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -57,11 +57,13 @@
57 57
58#define PCI_DEVICE_ID_CISCO_VIC_ENET 0x0043 /* ethernet vnic */ 58#define PCI_DEVICE_ID_CISCO_VIC_ENET 0x0043 /* ethernet vnic */
59#define PCI_DEVICE_ID_CISCO_VIC_ENET_DYN 0x0044 /* enet dynamic vnic */ 59#define PCI_DEVICE_ID_CISCO_VIC_ENET_DYN 0x0044 /* enet dynamic vnic */
60#define PCI_DEVICE_ID_CISCO_VIC_ENET_VF 0x0071 /* enet SRIOV VF */
60 61
61/* Supported devices */ 62/* Supported devices */
62static DEFINE_PCI_DEVICE_TABLE(enic_id_table) = { 63static DEFINE_PCI_DEVICE_TABLE(enic_id_table) = {
63 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET) }, 64 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET) },
64 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_DYN) }, 65 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_DYN) },
66 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_VF) },
65 { 0, } /* end of table */ 67 { 0, } /* end of table */
66}; 68};
67 69
@@ -132,6 +134,11 @@ int enic_sriov_enabled(struct enic *enic)
132 return (enic->priv_flags & ENIC_SRIOV_ENABLED) ? 1 : 0; 134 return (enic->priv_flags & ENIC_SRIOV_ENABLED) ? 1 : 0;
133} 135}
134 136
137static int enic_is_sriov_vf(struct enic *enic)
138{
139 return enic->pdev->device == PCI_DEVICE_ID_CISCO_VIC_ENET_VF;
140}
141
135int enic_is_valid_vf(struct enic *enic, int vf) 142int enic_is_valid_vf(struct enic *enic, int vf)
136{ 143{
137#ifdef CONFIG_PCI_IOV 144#ifdef CONFIG_PCI_IOV
@@ -437,7 +444,7 @@ static void enic_mtu_check(struct enic *enic)
437 444
438 if (mtu && mtu != enic->port_mtu) { 445 if (mtu && mtu != enic->port_mtu) {
439 enic->port_mtu = mtu; 446 enic->port_mtu = mtu;
440 if (enic_is_dynamic(enic)) { 447 if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic)) {
441 mtu = max_t(int, ENIC_MIN_MTU, 448 mtu = max_t(int, ENIC_MIN_MTU,
442 min_t(int, ENIC_MAX_MTU, mtu)); 449 min_t(int, ENIC_MAX_MTU, mtu));
443 if (mtu != netdev->mtu) 450 if (mtu != netdev->mtu)
@@ -849,7 +856,7 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)
849{ 856{
850 struct enic *enic = netdev_priv(netdev); 857 struct enic *enic = netdev_priv(netdev);
851 858
852 if (enic_is_dynamic(enic)) { 859 if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic)) {
853 if (!is_valid_ether_addr(addr) && !is_zero_ether_addr(addr)) 860 if (!is_valid_ether_addr(addr) && !is_zero_ether_addr(addr))
854 return -EADDRNOTAVAIL; 861 return -EADDRNOTAVAIL;
855 } else { 862 } else {
@@ -1608,7 +1615,7 @@ static int enic_open(struct net_device *netdev)
1608 for (i = 0; i < enic->rq_count; i++) 1615 for (i = 0; i < enic->rq_count; i++)
1609 vnic_rq_enable(&enic->rq[i]); 1616 vnic_rq_enable(&enic->rq[i]);
1610 1617
1611 if (!enic_is_dynamic(enic)) 1618 if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic))
1612 enic_dev_add_station_addr(enic); 1619 enic_dev_add_station_addr(enic);
1613 1620
1614 enic_set_rx_mode(netdev); 1621 enic_set_rx_mode(netdev);
@@ -1659,7 +1666,7 @@ static int enic_stop(struct net_device *netdev)
1659 netif_carrier_off(netdev); 1666 netif_carrier_off(netdev);
1660 netif_tx_disable(netdev); 1667 netif_tx_disable(netdev);
1661 1668
1662 if (!enic_is_dynamic(enic)) 1669 if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic))
1663 enic_dev_del_station_addr(enic); 1670 enic_dev_del_station_addr(enic);
1664 1671
1665 for (i = 0; i < enic->wq_count; i++) { 1672 for (i = 0; i < enic->wq_count; i++) {
@@ -1696,7 +1703,7 @@ static int enic_change_mtu(struct net_device *netdev, int new_mtu)
1696 if (new_mtu < ENIC_MIN_MTU || new_mtu > ENIC_MAX_MTU) 1703 if (new_mtu < ENIC_MIN_MTU || new_mtu > ENIC_MAX_MTU)
1697 return -EINVAL; 1704 return -EINVAL;
1698 1705
1699 if (enic_is_dynamic(enic)) 1706 if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))
1700 return -EOPNOTSUPP; 1707 return -EOPNOTSUPP;
1701 1708
1702 if (running) 1709 if (running)
@@ -2263,10 +2270,10 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2263 int using_dac = 0; 2270 int using_dac = 0;
2264 unsigned int i; 2271 unsigned int i;
2265 int err; 2272 int err;
2266 int num_pps = 1;
2267#ifdef CONFIG_PCI_IOV 2273#ifdef CONFIG_PCI_IOV
2268 int pos = 0; 2274 int pos = 0;
2269#endif 2275#endif
2276 int num_pps = 1;
2270 2277
2271 /* Allocate net device structure and initialize. Private 2278 /* Allocate net device structure and initialize. Private
2272 * instance data is initialized to zero. 2279 * instance data is initialized to zero.
@@ -2376,14 +2383,14 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2376 num_pps = enic->num_vfs; 2383 num_pps = enic->num_vfs;
2377 } 2384 }
2378 } 2385 }
2379
2380#endif 2386#endif
2387
2381 /* Allocate structure for port profiles */ 2388 /* Allocate structure for port profiles */
2382 enic->pp = kcalloc(num_pps, sizeof(*enic->pp), GFP_KERNEL); 2389 enic->pp = kcalloc(num_pps, sizeof(*enic->pp), GFP_KERNEL);
2383 if (!enic->pp) { 2390 if (!enic->pp) {
2384 pr_err("port profile alloc failed, aborting\n"); 2391 pr_err("port profile alloc failed, aborting\n");
2385 err = -ENOMEM; 2392 err = -ENOMEM;
2386 goto err_out_disable_sriov; 2393 goto err_out_disable_sriov_pp;
2387 } 2394 }
2388 2395
2389 /* Issue device open to get device in known state 2396 /* Issue device open to get device in known state
@@ -2392,7 +2399,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2392 err = enic_dev_open(enic); 2399 err = enic_dev_open(enic);
2393 if (err) { 2400 if (err) {
2394 dev_err(dev, "vNIC dev open failed, aborting\n"); 2401 dev_err(dev, "vNIC dev open failed, aborting\n");
2395 goto err_out_free_pp; 2402 goto err_out_disable_sriov;
2396 } 2403 }
2397 2404
2398 /* Setup devcmd lock 2405 /* Setup devcmd lock
@@ -2426,7 +2433,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2426 * called later by an upper layer. 2433 * called later by an upper layer.
2427 */ 2434 */
2428 2435
2429 if (!enic_is_dynamic(enic)) { 2436 if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic)) {
2430 err = vnic_dev_init(enic->vdev, 0); 2437 err = vnic_dev_init(enic->vdev, 0);
2431 if (err) { 2438 if (err) {
2432 dev_err(dev, "vNIC dev init failed, aborting\n"); 2439 dev_err(dev, "vNIC dev init failed, aborting\n");
@@ -2460,8 +2467,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2460 (void)enic_change_mtu(netdev, enic->port_mtu); 2467 (void)enic_change_mtu(netdev, enic->port_mtu);
2461 2468
2462#ifdef CONFIG_PCI_IOV 2469#ifdef CONFIG_PCI_IOV
2463 if (enic_is_dynamic(enic) && pdev->is_virtfn && 2470 if (enic_is_sriov_vf(enic) && is_zero_ether_addr(enic->mac_addr))
2464 is_zero_ether_addr(enic->mac_addr))
2465 random_ether_addr(enic->mac_addr); 2471 random_ether_addr(enic->mac_addr);
2466#endif 2472#endif
2467 2473
@@ -2474,7 +2480,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2474 enic->tx_coalesce_usecs = enic->config.intr_timer_usec; 2480 enic->tx_coalesce_usecs = enic->config.intr_timer_usec;
2475 enic->rx_coalesce_usecs = enic->tx_coalesce_usecs; 2481 enic->rx_coalesce_usecs = enic->tx_coalesce_usecs;
2476 2482
2477 if (enic_is_dynamic(enic)) 2483 if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))
2478 netdev->netdev_ops = &enic_netdev_dynamic_ops; 2484 netdev->netdev_ops = &enic_netdev_dynamic_ops;
2479 else 2485 else
2480 netdev->netdev_ops = &enic_netdev_ops; 2486 netdev->netdev_ops = &enic_netdev_ops;
@@ -2516,17 +2522,17 @@ err_out_dev_deinit:
2516 enic_dev_deinit(enic); 2522 enic_dev_deinit(enic);
2517err_out_dev_close: 2523err_out_dev_close:
2518 vnic_dev_close(enic->vdev); 2524 vnic_dev_close(enic->vdev);
2519err_out_free_pp:
2520 kfree(enic->pp);
2521err_out_disable_sriov: 2525err_out_disable_sriov:
2526 kfree(enic->pp);
2527err_out_disable_sriov_pp:
2522#ifdef CONFIG_PCI_IOV 2528#ifdef CONFIG_PCI_IOV
2523 if (enic_sriov_enabled(enic)) { 2529 if (enic_sriov_enabled(enic)) {
2524 pci_disable_sriov(pdev); 2530 pci_disable_sriov(pdev);
2525 enic->priv_flags &= ~ENIC_SRIOV_ENABLED; 2531 enic->priv_flags &= ~ENIC_SRIOV_ENABLED;
2526 } 2532 }
2527err_out_vnic_unregister: 2533err_out_vnic_unregister:
2528 vnic_dev_unregister(enic->vdev);
2529#endif 2534#endif
2535 vnic_dev_unregister(enic->vdev);
2530err_out_iounmap: 2536err_out_iounmap:
2531 enic_iounmap(enic); 2537 enic_iounmap(enic);
2532err_out_release_regions: 2538err_out_release_regions:
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index a6bcdb5cd2be..e703d64434f8 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1786,8 +1786,7 @@ static void be_rx_queues_destroy(struct be_adapter *adapter)
1786static u32 be_num_rxqs_want(struct be_adapter *adapter) 1786static u32 be_num_rxqs_want(struct be_adapter *adapter)
1787{ 1787{
1788 if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && 1788 if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) &&
1789 !sriov_enabled(adapter) && be_physfn(adapter) && 1789 !sriov_enabled(adapter) && be_physfn(adapter)) {
1790 !be_is_mc(adapter)) {
1791 return 1 + MAX_RSS_QS; /* one default non-RSS queue */ 1790 return 1 + MAX_RSS_QS; /* one default non-RSS queue */
1792 } else { 1791 } else {
1793 dev_warn(&adapter->pdev->dev, 1792 dev_warn(&adapter->pdev->dev,
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index fb5579a3b19d..47f85c337cf7 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -25,6 +25,7 @@
25#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
26#include <linux/ethtool.h> 26#include <linux/ethtool.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/interrupt.h>
28#include <linux/io.h> 29#include <linux/io.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <linux/netdevice.h> 31#include <linux/netdevice.h>
diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index a127cb2476c7..bb336a0959c9 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -25,6 +25,7 @@
25#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
26#include <linux/ethtool.h> 26#include <linux/ethtool.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/interrupt.h>
28#include <linux/io.h> 29#include <linux/io.h>
29#include <linux/mii.h> 30#include <linux/mii.h>
30#include <linux/module.h> 31#include <linux/module.h>
diff --git a/drivers/net/ethernet/intel/igb/Makefile b/drivers/net/ethernet/intel/igb/Makefile
index c6e4621b6262..6565c463185c 100644
--- a/drivers/net/ethernet/intel/igb/Makefile
+++ b/drivers/net/ethernet/intel/igb/Makefile
@@ -1,7 +1,7 @@
1################################################################################ 1################################################################################
2# 2#
3# Intel 82575 PCI-Express Ethernet Linux driver 3# Intel 82575 PCI-Express Ethernet Linux driver
4# Copyright(c) 1999 - 2011 Intel Corporation. 4# Copyright(c) 1999 - 2012 Intel Corporation.
5# 5#
6# This program is free software; you can redistribute it and/or modify it 6# This program is free software; you can redistribute it and/or modify it
7# under the terms and conditions of the GNU General Public License, 7# under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index b8e20f037d0a..08bdc33715ee 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.h b/drivers/net/ethernet/intel/igb/e1000_82575.h
index 08a757eb6608..b927d79ab536 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.h
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
index f5fc5725ea94..aed217449f0d 100644
--- a/drivers/net/ethernet/intel/igb/e1000_defines.h
+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
index 4519a1367170..f67cbd3fa307 100644
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c
index 73aac082c44d..f57338afd71f 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -151,7 +151,7 @@ void igb_clear_vfta_i350(struct e1000_hw *hw)
151 * Writes value at the given offset in the register array which stores 151 * Writes value at the given offset in the register array which stores
152 * the VLAN filter table. 152 * the VLAN filter table.
153 **/ 153 **/
154void igb_write_vfta_i350(struct e1000_hw *hw, u32 offset, u32 value) 154static void igb_write_vfta_i350(struct e1000_hw *hw, u32 offset, u32 value)
155{ 155{
156 int i; 156 int i;
157 157
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.h b/drivers/net/ethernet/intel/igb/e1000_mac.h
index e45996b4ea34..cbddc4e51e30 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.h
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_mbx.c b/drivers/net/ethernet/intel/igb/e1000_mbx.c
index 469d95eaa154..5988b8958baf 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mbx.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mbx.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_mbx.h b/drivers/net/ethernet/intel/igb/e1000_mbx.h
index eddb0f83dcea..dbcfa3d5caec 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mbx.h
+++ b/drivers/net/ethernet/intel/igb/e1000_mbx.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_nvm.c b/drivers/net/ethernet/intel/igb/e1000_nvm.c
index 40407124e722..fa2c6ba62139 100644
--- a/drivers/net/ethernet/intel/igb/e1000_nvm.c
+++ b/drivers/net/ethernet/intel/igb/e1000_nvm.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_nvm.h b/drivers/net/ethernet/intel/igb/e1000_nvm.h
index a2a7ca9fa733..825b0228cac0 100644
--- a/drivers/net/ethernet/intel/igb/e1000_nvm.h
+++ b/drivers/net/ethernet/intel/igb/e1000_nvm.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2011 Intel Corporation. 4 Copyright(c) 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
index b17d7c20f817..789de5b83aad 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.h b/drivers/net/ethernet/intel/igb/e1000_phy.h
index 8510797b9d81..4c32ac66ff39 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.h
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h
index 0a860bc1198e..ccdf36d503fd 100644
--- a/drivers/net/ethernet/intel/igb/e1000_regs.h
+++ b/drivers/net/ethernet/intel/igb/e1000_regs.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index 3d12e67eebb4..8e33bdd33eea 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 7998bf4d5946..aa399a8a8f0d 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 01e5e89ef959..e91d73c8aa4e 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2011 Intel Corporation. 4 Copyright(c) 2007-2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -68,7 +68,7 @@ char igb_driver_name[] = "igb";
68char igb_driver_version[] = DRV_VERSION; 68char igb_driver_version[] = DRV_VERSION;
69static const char igb_driver_string[] = 69static const char igb_driver_string[] =
70 "Intel(R) Gigabit Ethernet Network Driver"; 70 "Intel(R) Gigabit Ethernet Network Driver";
71static const char igb_copyright[] = "Copyright (c) 2007-2011 Intel Corporation."; 71static const char igb_copyright[] = "Copyright (c) 2007-2012 Intel Corporation.";
72 72
73static const struct e1000_info *igb_info_tbl[] = { 73static const struct e1000_info *igb_info_tbl[] = {
74 [board_82575] = &e1000_82575_info, 74 [board_82575] = &e1000_82575_info,
@@ -4003,8 +4003,8 @@ set_itr_now:
4003 } 4003 }
4004} 4004}
4005 4005
4006void igb_tx_ctxtdesc(struct igb_ring *tx_ring, u32 vlan_macip_lens, 4006static void igb_tx_ctxtdesc(struct igb_ring *tx_ring, u32 vlan_macip_lens,
4007 u32 type_tucmd, u32 mss_l4len_idx) 4007 u32 type_tucmd, u32 mss_l4len_idx)
4008{ 4008{
4009 struct e1000_adv_tx_context_desc *context_desc; 4009 struct e1000_adv_tx_context_desc *context_desc;
4010 u16 i = tx_ring->next_to_use; 4010 u16 i = tx_ring->next_to_use;
@@ -5623,7 +5623,7 @@ static irqreturn_t igb_intr(int irq, void *data)
5623 return IRQ_HANDLED; 5623 return IRQ_HANDLED;
5624} 5624}
5625 5625
5626void igb_ring_irq_enable(struct igb_q_vector *q_vector) 5626static void igb_ring_irq_enable(struct igb_q_vector *q_vector)
5627{ 5627{
5628 struct igb_adapter *adapter = q_vector->adapter; 5628 struct igb_adapter *adapter = q_vector->adapter;
5629 struct e1000_hw *hw = &adapter->hw; 5629 struct e1000_hw *hw = &adapter->hw;
diff --git a/drivers/net/ethernet/intel/igbvf/ethtool.c b/drivers/net/ethernet/intel/igbvf/ethtool.c
index 7b600a1f6366..2dba53446064 100644
--- a/drivers/net/ethernet/intel/igbvf/ethtool.c
+++ b/drivers/net/ethernet/intel/igbvf/ethtool.c
@@ -468,6 +468,5 @@ static const struct ethtool_ops igbvf_ethtool_ops = {
468 468
469void igbvf_set_ethtool_ops(struct net_device *netdev) 469void igbvf_set_ethtool_ops(struct net_device *netdev)
470{ 470{
471 /* have to "undeclare" const on this struct to remove warnings */ 471 SET_ETHTOOL_OPS(netdev, &igbvf_ethtool_ops);
472 SET_ETHTOOL_OPS(netdev, (struct ethtool_ops *)&igbvf_ethtool_ops);
473} 472}
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index fd3da3076c2f..a4b20c865759 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -1194,11 +1194,6 @@ static int igbvf_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
1194 struct igbvf_adapter *adapter = netdev_priv(netdev); 1194 struct igbvf_adapter *adapter = netdev_priv(netdev);
1195 struct e1000_hw *hw = &adapter->hw; 1195 struct e1000_hw *hw = &adapter->hw;
1196 1196
1197 igbvf_irq_disable(adapter);
1198
1199 if (!test_bit(__IGBVF_DOWN, &adapter->state))
1200 igbvf_irq_enable(adapter);
1201
1202 if (hw->mac.ops.set_vfta(hw, vid, false)) { 1197 if (hw->mac.ops.set_vfta(hw, vid, false)) {
1203 dev_err(&adapter->pdev->dev, 1198 dev_err(&adapter->pdev->dev,
1204 "Failed to remove vlan id %d\n", vid); 1199 "Failed to remove vlan id %d\n", vid);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 802bfa0f62cc..775602ef90e5 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -161,19 +161,19 @@
161 161
162/* Receive DMA Registers */ 162/* Receive DMA Registers */
163#define IXGBE_RDBAL(_i) (((_i) < 64) ? (0x01000 + ((_i) * 0x40)) : \ 163#define IXGBE_RDBAL(_i) (((_i) < 64) ? (0x01000 + ((_i) * 0x40)) : \
164 (0x0D000 + ((_i - 64) * 0x40))) 164 (0x0D000 + (((_i) - 64) * 0x40)))
165#define IXGBE_RDBAH(_i) (((_i) < 64) ? (0x01004 + ((_i) * 0x40)) : \ 165#define IXGBE_RDBAH(_i) (((_i) < 64) ? (0x01004 + ((_i) * 0x40)) : \
166 (0x0D004 + ((_i - 64) * 0x40))) 166 (0x0D004 + (((_i) - 64) * 0x40)))
167#define IXGBE_RDLEN(_i) (((_i) < 64) ? (0x01008 + ((_i) * 0x40)) : \ 167#define IXGBE_RDLEN(_i) (((_i) < 64) ? (0x01008 + ((_i) * 0x40)) : \
168 (0x0D008 + ((_i - 64) * 0x40))) 168 (0x0D008 + (((_i) - 64) * 0x40)))
169#define IXGBE_RDH(_i) (((_i) < 64) ? (0x01010 + ((_i) * 0x40)) : \ 169#define IXGBE_RDH(_i) (((_i) < 64) ? (0x01010 + ((_i) * 0x40)) : \
170 (0x0D010 + ((_i - 64) * 0x40))) 170 (0x0D010 + (((_i) - 64) * 0x40)))
171#define IXGBE_RDT(_i) (((_i) < 64) ? (0x01018 + ((_i) * 0x40)) : \ 171#define IXGBE_RDT(_i) (((_i) < 64) ? (0x01018 + ((_i) * 0x40)) : \
172 (0x0D018 + ((_i - 64) * 0x40))) 172 (0x0D018 + (((_i) - 64) * 0x40)))
173#define IXGBE_RXDCTL(_i) (((_i) < 64) ? (0x01028 + ((_i) * 0x40)) : \ 173#define IXGBE_RXDCTL(_i) (((_i) < 64) ? (0x01028 + ((_i) * 0x40)) : \
174 (0x0D028 + ((_i - 64) * 0x40))) 174 (0x0D028 + (((_i) - 64) * 0x40)))
175#define IXGBE_RSCCTL(_i) (((_i) < 64) ? (0x0102C + ((_i) * 0x40)) : \ 175#define IXGBE_RSCCTL(_i) (((_i) < 64) ? (0x0102C + ((_i) * 0x40)) : \
176 (0x0D02C + ((_i - 64) * 0x40))) 176 (0x0D02C + (((_i) - 64) * 0x40)))
177#define IXGBE_RSCDBU 0x03028 177#define IXGBE_RSCDBU 0x03028
178#define IXGBE_RDDCC 0x02F20 178#define IXGBE_RDDCC 0x02F20
179#define IXGBE_RXMEMWRAP 0x03190 179#define IXGBE_RXMEMWRAP 0x03190
@@ -186,7 +186,7 @@
186 */ 186 */
187#define IXGBE_SRRCTL(_i) (((_i) <= 15) ? (0x02100 + ((_i) * 4)) : \ 187#define IXGBE_SRRCTL(_i) (((_i) <= 15) ? (0x02100 + ((_i) * 4)) : \
188 (((_i) < 64) ? (0x01014 + ((_i) * 0x40)) : \ 188 (((_i) < 64) ? (0x01014 + ((_i) * 0x40)) : \
189 (0x0D014 + ((_i - 64) * 0x40)))) 189 (0x0D014 + (((_i) - 64) * 0x40))))
190/* 190/*
191 * Rx DCA Control Register: 191 * Rx DCA Control Register:
192 * 00-15 : 0x02200 + n*4 192 * 00-15 : 0x02200 + n*4
@@ -195,7 +195,7 @@
195 */ 195 */
196#define IXGBE_DCA_RXCTRL(_i) (((_i) <= 15) ? (0x02200 + ((_i) * 4)) : \ 196#define IXGBE_DCA_RXCTRL(_i) (((_i) <= 15) ? (0x02200 + ((_i) * 4)) : \
197 (((_i) < 64) ? (0x0100C + ((_i) * 0x40)) : \ 197 (((_i) < 64) ? (0x0100C + ((_i) * 0x40)) : \
198 (0x0D00C + ((_i - 64) * 0x40)))) 198 (0x0D00C + (((_i) - 64) * 0x40))))
199#define IXGBE_RDRXCTL 0x02F00 199#define IXGBE_RDRXCTL 0x02F00
200#define IXGBE_RXPBSIZE(_i) (0x03C00 + ((_i) * 4)) 200#define IXGBE_RXPBSIZE(_i) (0x03C00 + ((_i) * 4))
201 /* 8 of these 0x03C00 - 0x03C1C */ 201 /* 8 of these 0x03C00 - 0x03C1C */
@@ -344,9 +344,9 @@
344 344
345#define IXGBE_WUPL 0x05900 345#define IXGBE_WUPL 0x05900
346#define IXGBE_WUPM 0x05A00 /* wake up pkt memory 0x5A00-0x5A7C */ 346#define IXGBE_WUPM 0x05A00 /* wake up pkt memory 0x5A00-0x5A7C */
347#define IXGBE_FHFT(_n) (0x09000 + (_n * 0x100)) /* Flex host filter table */ 347#define IXGBE_FHFT(_n) (0x09000 + ((_n) * 0x100)) /* Flex host filter table */
348#define IXGBE_FHFT_EXT(_n) (0x09800 + (_n * 0x100)) /* Ext Flexible Host 348#define IXGBE_FHFT_EXT(_n) (0x09800 + ((_n) * 0x100)) /* Ext Flexible Host
349 * Filter Table */ 349 * Filter Table */
350 350
351#define IXGBE_FLEXIBLE_FILTER_COUNT_MAX 4 351#define IXGBE_FLEXIBLE_FILTER_COUNT_MAX 4
352#define IXGBE_EXT_FLEXIBLE_FILTER_COUNT_MAX 2 352#define IXGBE_EXT_FLEXIBLE_FILTER_COUNT_MAX 2
@@ -1485,7 +1485,7 @@ enum {
1485#define IXGBE_LED_BLINK_BASE 0x00000080 1485#define IXGBE_LED_BLINK_BASE 0x00000080
1486#define IXGBE_LED_MODE_MASK_BASE 0x0000000F 1486#define IXGBE_LED_MODE_MASK_BASE 0x0000000F
1487#define IXGBE_LED_OFFSET(_base, _i) (_base << (8 * (_i))) 1487#define IXGBE_LED_OFFSET(_base, _i) (_base << (8 * (_i)))
1488#define IXGBE_LED_MODE_SHIFT(_i) (8*(_i)) 1488#define IXGBE_LED_MODE_SHIFT(_i) (8 * (_i))
1489#define IXGBE_LED_IVRT(_i) IXGBE_LED_OFFSET(IXGBE_LED_IVRT_BASE, _i) 1489#define IXGBE_LED_IVRT(_i) IXGBE_LED_OFFSET(IXGBE_LED_IVRT_BASE, _i)
1490#define IXGBE_LED_BLINK(_i) IXGBE_LED_OFFSET(IXGBE_LED_BLINK_BASE, _i) 1490#define IXGBE_LED_BLINK(_i) IXGBE_LED_OFFSET(IXGBE_LED_BLINK_BASE, _i)
1491#define IXGBE_LED_MODE_MASK(_i) IXGBE_LED_OFFSET(IXGBE_LED_MODE_MASK_BASE, _i) 1491#define IXGBE_LED_MODE_MASK(_i) IXGBE_LED_OFFSET(IXGBE_LED_MODE_MASK_BASE, _i)
@@ -2068,9 +2068,9 @@ enum {
2068 2068
2069/* SR-IOV specific macros */ 2069/* SR-IOV specific macros */
2070#define IXGBE_MBVFICR_INDEX(vf_number) (vf_number >> 4) 2070#define IXGBE_MBVFICR_INDEX(vf_number) (vf_number >> 4)
2071#define IXGBE_MBVFICR(_i) (0x00710 + (_i * 4)) 2071#define IXGBE_MBVFICR(_i) (0x00710 + ((_i) * 4))
2072#define IXGBE_VFLRE(_i) (((_i & 1) ? 0x001C0 : 0x00600)) 2072#define IXGBE_VFLRE(_i) ((((_i) & 1) ? 0x001C0 : 0x00600))
2073#define IXGBE_VFLREC(_i) (0x00700 + (_i * 4)) 2073#define IXGBE_VFLREC(_i) (0x00700 + ((_i) * 4))
2074 2074
2075enum ixgbe_fdir_pballoc_type { 2075enum ixgbe_fdir_pballoc_type {
2076 IXGBE_FDIR_PBALLOC_NONE = 0, 2076 IXGBE_FDIR_PBALLOC_NONE = 0,
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index dc8e6511c640..c85700318147 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -56,7 +56,8 @@ struct ixgbe_stats {
56 offsetof(struct ixgbevf_adapter, m), \ 56 offsetof(struct ixgbevf_adapter, m), \
57 offsetof(struct ixgbevf_adapter, b), \ 57 offsetof(struct ixgbevf_adapter, b), \
58 offsetof(struct ixgbevf_adapter, r) 58 offsetof(struct ixgbevf_adapter, r)
59static struct ixgbe_stats ixgbe_gstrings_stats[] = { 59
60static const struct ixgbe_stats ixgbe_gstrings_stats[] = {
60 {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc, 61 {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc,
61 stats.saved_reset_vfgprc)}, 62 stats.saved_reset_vfgprc)},
62 {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc, 63 {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc,
@@ -671,7 +672,7 @@ static int ixgbevf_nway_reset(struct net_device *netdev)
671 return 0; 672 return 0;
672} 673}
673 674
674static struct ethtool_ops ixgbevf_ethtool_ops = { 675static const struct ethtool_ops ixgbevf_ethtool_ops = {
675 .get_settings = ixgbevf_get_settings, 676 .get_settings = ixgbevf_get_settings,
676 .get_drvinfo = ixgbevf_get_drvinfo, 677 .get_drvinfo = ixgbevf_get_drvinfo,
677 .get_regs_len = ixgbevf_get_regs_len, 678 .get_regs_len = ixgbevf_get_regs_len,
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index e6c9d1a927a9..9075c1d61039 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -279,12 +279,12 @@ enum ixgbevf_boards {
279 board_X540_vf, 279 board_X540_vf,
280}; 280};
281 281
282extern struct ixgbevf_info ixgbevf_82599_vf_info; 282extern const struct ixgbevf_info ixgbevf_82599_vf_info;
283extern struct ixgbevf_info ixgbevf_X540_vf_info; 283extern const struct ixgbevf_info ixgbevf_X540_vf_info;
284extern struct ixgbe_mbx_operations ixgbevf_mbx_ops; 284extern const struct ixgbe_mbx_operations ixgbevf_mbx_ops;
285 285
286/* needed by ethtool.c */ 286/* needed by ethtool.c */
287extern char ixgbevf_driver_name[]; 287extern const char ixgbevf_driver_name[];
288extern const char ixgbevf_driver_version[]; 288extern const char ixgbevf_driver_version[];
289 289
290extern int ixgbevf_up(struct ixgbevf_adapter *adapter); 290extern int ixgbevf_up(struct ixgbevf_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 891162d1610c..bed411bada21 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -53,7 +53,7 @@
53 53
54#include "ixgbevf.h" 54#include "ixgbevf.h"
55 55
56char ixgbevf_driver_name[] = "ixgbevf"; 56const char ixgbevf_driver_name[] = "ixgbevf";
57static const char ixgbevf_driver_string[] = 57static const char ixgbevf_driver_string[] =
58 "Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver"; 58 "Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver";
59 59
@@ -917,31 +917,34 @@ static irqreturn_t ixgbevf_msix_mbx(int irq, void *data)
917 struct ixgbe_hw *hw = &adapter->hw; 917 struct ixgbe_hw *hw = &adapter->hw;
918 u32 eicr; 918 u32 eicr;
919 u32 msg; 919 u32 msg;
920 bool got_ack = false;
920 921
921 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICS); 922 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICS);
922 IXGBE_WRITE_REG(hw, IXGBE_VTEICR, eicr); 923 IXGBE_WRITE_REG(hw, IXGBE_VTEICR, eicr);
923 924
924 if (!hw->mbx.ops.check_for_ack(hw)) { 925 if (!hw->mbx.ops.check_for_ack(hw))
925 /* 926 got_ack = true;
926 * checking for the ack clears the PFACK bit. Place
927 * it back in the v2p_mailbox cache so that anyone
928 * polling for an ack will not miss it. Also
929 * avoid the read below because the code to read
930 * the mailbox will also clear the ack bit. This was
931 * causing lost acks. Just cache the bit and exit
932 * the IRQ handler.
933 */
934 hw->mbx.v2p_mailbox |= IXGBE_VFMAILBOX_PFACK;
935 goto out;
936 }
937 927
938 /* Not an ack interrupt, go ahead and read the message */ 928 if (!hw->mbx.ops.check_for_msg(hw)) {
939 hw->mbx.ops.read(hw, &msg, 1); 929 hw->mbx.ops.read(hw, &msg, 1);
940 930
941 if ((msg & IXGBE_MBVFICR_VFREQ_MASK) == IXGBE_PF_CONTROL_MSG) 931 if ((msg & IXGBE_MBVFICR_VFREQ_MASK) == IXGBE_PF_CONTROL_MSG)
942 mod_timer(&adapter->watchdog_timer, 932 mod_timer(&adapter->watchdog_timer,
943 round_jiffies(jiffies + 1)); 933 round_jiffies(jiffies + 1));
944 934
935 if (msg & IXGBE_VT_MSGTYPE_NACK)
936 pr_warn("Last Request of type %2.2x to PF Nacked\n",
937 msg & 0xFF);
938 goto out;
939 }
940
941 /*
942 * checking for the ack clears the PFACK bit. Place
943 * it back in the v2p_mailbox cache so that anyone
944 * polling for an ack will not miss it
945 */
946 if (got_ack)
947 hw->mbx.v2p_mailbox |= IXGBE_VFMAILBOX_PFACK;
945out: 948out:
946 return IRQ_HANDLED; 949 return IRQ_HANDLED;
947} 950}
diff --git a/drivers/net/ethernet/intel/ixgbevf/mbx.c b/drivers/net/ethernet/intel/ixgbevf/mbx.c
index 930fa83f2568..13532d9ba72d 100644
--- a/drivers/net/ethernet/intel/ixgbevf/mbx.c
+++ b/drivers/net/ethernet/intel/ixgbevf/mbx.c
@@ -26,6 +26,7 @@
26*******************************************************************************/ 26*******************************************************************************/
27 27
28#include "mbx.h" 28#include "mbx.h"
29#include "ixgbevf.h"
29 30
30/** 31/**
31 * ixgbevf_poll_for_msg - Wait for message notification 32 * ixgbevf_poll_for_msg - Wait for message notification
@@ -328,7 +329,7 @@ static s32 ixgbevf_init_mbx_params_vf(struct ixgbe_hw *hw)
328 return 0; 329 return 0;
329} 330}
330 331
331struct ixgbe_mbx_operations ixgbevf_mbx_ops = { 332const struct ixgbe_mbx_operations ixgbevf_mbx_ops = {
332 .init_params = ixgbevf_init_mbx_params_vf, 333 .init_params = ixgbevf_init_mbx_params_vf,
333 .read = ixgbevf_read_mbx_vf, 334 .read = ixgbevf_read_mbx_vf,
334 .write = ixgbevf_write_mbx_vf, 335 .write = ixgbevf_write_mbx_vf,
diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.c b/drivers/net/ethernet/intel/ixgbevf/vf.c
index 21533e300367..d0138d7a31a1 100644
--- a/drivers/net/ethernet/intel/ixgbevf/vf.c
+++ b/drivers/net/ethernet/intel/ixgbevf/vf.c
@@ -26,6 +26,7 @@
26*******************************************************************************/ 26*******************************************************************************/
27 27
28#include "vf.h" 28#include "vf.h"
29#include "ixgbevf.h"
29 30
30/** 31/**
31 * ixgbevf_start_hw_vf - Prepare hardware for Tx/Rx 32 * ixgbevf_start_hw_vf - Prepare hardware for Tx/Rx
@@ -401,7 +402,7 @@ static s32 ixgbevf_check_mac_link_vf(struct ixgbe_hw *hw,
401 return 0; 402 return 0;
402} 403}
403 404
404static struct ixgbe_mac_operations ixgbevf_mac_ops = { 405static const struct ixgbe_mac_operations ixgbevf_mac_ops = {
405 .init_hw = ixgbevf_init_hw_vf, 406 .init_hw = ixgbevf_init_hw_vf,
406 .reset_hw = ixgbevf_reset_hw_vf, 407 .reset_hw = ixgbevf_reset_hw_vf,
407 .start_hw = ixgbevf_start_hw_vf, 408 .start_hw = ixgbevf_start_hw_vf,
@@ -415,12 +416,12 @@ static struct ixgbe_mac_operations ixgbevf_mac_ops = {
415 .set_vfta = ixgbevf_set_vfta_vf, 416 .set_vfta = ixgbevf_set_vfta_vf,
416}; 417};
417 418
418struct ixgbevf_info ixgbevf_82599_vf_info = { 419const struct ixgbevf_info ixgbevf_82599_vf_info = {
419 .mac = ixgbe_mac_82599_vf, 420 .mac = ixgbe_mac_82599_vf,
420 .mac_ops = &ixgbevf_mac_ops, 421 .mac_ops = &ixgbevf_mac_ops,
421}; 422};
422 423
423struct ixgbevf_info ixgbevf_X540_vf_info = { 424const struct ixgbevf_info ixgbevf_X540_vf_info = {
424 .mac = ixgbe_mac_X540_vf, 425 .mac = ixgbe_mac_X540_vf,
425 .mac_ops = &ixgbevf_mac_ops, 426 .mac_ops = &ixgbevf_mac_ops,
426}; 427};
diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.h b/drivers/net/ethernet/intel/ixgbevf/vf.h
index 10306b492ee6..d556619a9212 100644
--- a/drivers/net/ethernet/intel/ixgbevf/vf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/vf.h
@@ -167,7 +167,7 @@ struct ixgbevf_hw_stats {
167 167
168struct ixgbevf_info { 168struct ixgbevf_info {
169 enum ixgbe_mac_type mac; 169 enum ixgbe_mac_type mac;
170 struct ixgbe_mac_operations *mac_ops; 170 const struct ixgbe_mac_operations *mac_ops;
171}; 171};
172 172
173#endif /* __IXGBE_VF_H__ */ 173#endif /* __IXGBE_VF_H__ */
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 9c049d2cb97d..9edecfa1f0f4 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -136,6 +136,8 @@ static char mv643xx_eth_driver_version[] = "1.4";
136#define INT_MASK 0x0068 136#define INT_MASK 0x0068
137#define INT_MASK_EXT 0x006c 137#define INT_MASK_EXT 0x006c
138#define TX_FIFO_URGENT_THRESHOLD 0x0074 138#define TX_FIFO_URGENT_THRESHOLD 0x0074
139#define RX_DISCARD_FRAME_CNT 0x0084
140#define RX_OVERRUN_FRAME_CNT 0x0088
139#define TXQ_FIX_PRIO_CONF_MOVED 0x00dc 141#define TXQ_FIX_PRIO_CONF_MOVED 0x00dc
140#define TX_BW_RATE_MOVED 0x00e0 142#define TX_BW_RATE_MOVED 0x00e0
141#define TX_BW_MTU_MOVED 0x00e8 143#define TX_BW_MTU_MOVED 0x00e8
@@ -334,6 +336,9 @@ struct mib_counters {
334 u32 bad_crc_event; 336 u32 bad_crc_event;
335 u32 collision; 337 u32 collision;
336 u32 late_collision; 338 u32 late_collision;
339 /* Non MIB hardware counters */
340 u32 rx_discard;
341 u32 rx_overrun;
337}; 342};
338 343
339struct lro_counters { 344struct lro_counters {
@@ -1225,6 +1230,10 @@ static void mib_counters_clear(struct mv643xx_eth_private *mp)
1225 1230
1226 for (i = 0; i < 0x80; i += 4) 1231 for (i = 0; i < 0x80; i += 4)
1227 mib_read(mp, i); 1232 mib_read(mp, i);
1233
1234 /* Clear non MIB hw counters also */
1235 rdlp(mp, RX_DISCARD_FRAME_CNT);
1236 rdlp(mp, RX_OVERRUN_FRAME_CNT);
1228} 1237}
1229 1238
1230static void mib_counters_update(struct mv643xx_eth_private *mp) 1239static void mib_counters_update(struct mv643xx_eth_private *mp)
@@ -1262,6 +1271,9 @@ static void mib_counters_update(struct mv643xx_eth_private *mp)
1262 p->bad_crc_event += mib_read(mp, 0x74); 1271 p->bad_crc_event += mib_read(mp, 0x74);
1263 p->collision += mib_read(mp, 0x78); 1272 p->collision += mib_read(mp, 0x78);
1264 p->late_collision += mib_read(mp, 0x7c); 1273 p->late_collision += mib_read(mp, 0x7c);
1274 /* Non MIB hardware counters */
1275 p->rx_discard += rdlp(mp, RX_DISCARD_FRAME_CNT);
1276 p->rx_overrun += rdlp(mp, RX_OVERRUN_FRAME_CNT);
1265 spin_unlock_bh(&mp->mib_counters_lock); 1277 spin_unlock_bh(&mp->mib_counters_lock);
1266 1278
1267 mod_timer(&mp->mib_counters_timer, jiffies + 30 * HZ); 1279 mod_timer(&mp->mib_counters_timer, jiffies + 30 * HZ);
@@ -1413,6 +1425,8 @@ static const struct mv643xx_eth_stats mv643xx_eth_stats[] = {
1413 MIBSTAT(bad_crc_event), 1425 MIBSTAT(bad_crc_event),
1414 MIBSTAT(collision), 1426 MIBSTAT(collision),
1415 MIBSTAT(late_collision), 1427 MIBSTAT(late_collision),
1428 MIBSTAT(rx_discard),
1429 MIBSTAT(rx_overrun),
1416 LROSTAT(lro_aggregated), 1430 LROSTAT(lro_aggregated),
1417 LROSTAT(lro_flushed), 1431 LROSTAT(lro_flushed),
1418 LROSTAT(lro_no_desc), 1432 LROSTAT(lro_no_desc),
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 18a87a57fc0a..edb9bda55d55 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -931,17 +931,20 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
931} 931}
932 932
933/* Allocate and setup a new buffer for receiving */ 933/* Allocate and setup a new buffer for receiving */
934static void skge_rx_setup(struct skge_port *skge, struct skge_element *e, 934static int skge_rx_setup(struct pci_dev *pdev,
935 struct sk_buff *skb, unsigned int bufsize) 935 struct skge_element *e,
936 struct sk_buff *skb, unsigned int bufsize)
936{ 937{
937 struct skge_rx_desc *rd = e->desc; 938 struct skge_rx_desc *rd = e->desc;
938 u64 map; 939 dma_addr_t map;
939 940
940 map = pci_map_single(skge->hw->pdev, skb->data, bufsize, 941 map = pci_map_single(pdev, skb->data, bufsize,
941 PCI_DMA_FROMDEVICE); 942 PCI_DMA_FROMDEVICE);
943 if (pci_dma_mapping_error(pdev, map))
944 goto mapping_error;
942 945
943 rd->dma_lo = map; 946 rd->dma_lo = lower_32_bits(map);
944 rd->dma_hi = map >> 32; 947 rd->dma_hi = upper_32_bits(map);
945 e->skb = skb; 948 e->skb = skb;
946 rd->csum1_start = ETH_HLEN; 949 rd->csum1_start = ETH_HLEN;
947 rd->csum2_start = ETH_HLEN; 950 rd->csum2_start = ETH_HLEN;
@@ -953,6 +956,13 @@ static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
953 rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | bufsize; 956 rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | bufsize;
954 dma_unmap_addr_set(e, mapaddr, map); 957 dma_unmap_addr_set(e, mapaddr, map);
955 dma_unmap_len_set(e, maplen, bufsize); 958 dma_unmap_len_set(e, maplen, bufsize);
959 return 0;
960
961mapping_error:
962 if (net_ratelimit())
963 dev_warn(&pdev->dev, "%s: rx mapping error\n",
964 skb->dev->name);
965 return -EIO;
956} 966}
957 967
958/* Resume receiving using existing skb, 968/* Resume receiving using existing skb,
@@ -1014,7 +1024,11 @@ static int skge_rx_fill(struct net_device *dev)
1014 return -ENOMEM; 1024 return -ENOMEM;
1015 1025
1016 skb_reserve(skb, NET_IP_ALIGN); 1026 skb_reserve(skb, NET_IP_ALIGN);
1017 skge_rx_setup(skge, e, skb, skge->rx_buf_size); 1027 if (skge_rx_setup(skge->hw->pdev, e, skb, skge->rx_buf_size)) {
1028 kfree_skb(skb);
1029 return -ENOMEM;
1030 }
1031
1018 } while ((e = e->next) != ring->start); 1032 } while ((e = e->next) != ring->start);
1019 1033
1020 ring->to_clean = ring->start; 1034 ring->to_clean = ring->start;
@@ -2576,6 +2590,7 @@ static int skge_up(struct net_device *dev)
2576 } 2590 }
2577 2591
2578 /* Initialize MAC */ 2592 /* Initialize MAC */
2593 netif_carrier_off(dev);
2579 spin_lock_bh(&hw->phy_lock); 2594 spin_lock_bh(&hw->phy_lock);
2580 if (is_genesis(hw)) 2595 if (is_genesis(hw))
2581 genesis_mac_init(hw, port); 2596 genesis_mac_init(hw, port);
@@ -2728,7 +2743,7 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2728 struct skge_tx_desc *td; 2743 struct skge_tx_desc *td;
2729 int i; 2744 int i;
2730 u32 control, len; 2745 u32 control, len;
2731 u64 map; 2746 dma_addr_t map;
2732 2747
2733 if (skb_padto(skb, ETH_ZLEN)) 2748 if (skb_padto(skb, ETH_ZLEN))
2734 return NETDEV_TX_OK; 2749 return NETDEV_TX_OK;
@@ -2742,11 +2757,14 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2742 e->skb = skb; 2757 e->skb = skb;
2743 len = skb_headlen(skb); 2758 len = skb_headlen(skb);
2744 map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE); 2759 map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
2760 if (pci_dma_mapping_error(hw->pdev, map))
2761 goto mapping_error;
2762
2745 dma_unmap_addr_set(e, mapaddr, map); 2763 dma_unmap_addr_set(e, mapaddr, map);
2746 dma_unmap_len_set(e, maplen, len); 2764 dma_unmap_len_set(e, maplen, len);
2747 2765
2748 td->dma_lo = map; 2766 td->dma_lo = lower_32_bits(map);
2749 td->dma_hi = map >> 32; 2767 td->dma_hi = upper_32_bits(map);
2750 2768
2751 if (skb->ip_summed == CHECKSUM_PARTIAL) { 2769 if (skb->ip_summed == CHECKSUM_PARTIAL) {
2752 const int offset = skb_checksum_start_offset(skb); 2770 const int offset = skb_checksum_start_offset(skb);
@@ -2777,14 +2795,16 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2777 2795
2778 map = skb_frag_dma_map(&hw->pdev->dev, frag, 0, 2796 map = skb_frag_dma_map(&hw->pdev->dev, frag, 0,
2779 skb_frag_size(frag), DMA_TO_DEVICE); 2797 skb_frag_size(frag), DMA_TO_DEVICE);
2798 if (dma_mapping_error(&hw->pdev->dev, map))
2799 goto mapping_unwind;
2780 2800
2781 e = e->next; 2801 e = e->next;
2782 e->skb = skb; 2802 e->skb = skb;
2783 tf = e->desc; 2803 tf = e->desc;
2784 BUG_ON(tf->control & BMU_OWN); 2804 BUG_ON(tf->control & BMU_OWN);
2785 2805
2786 tf->dma_lo = map; 2806 tf->dma_lo = lower_32_bits(map);
2787 tf->dma_hi = (u64) map >> 32; 2807 tf->dma_hi = upper_32_bits(map);
2788 dma_unmap_addr_set(e, mapaddr, map); 2808 dma_unmap_addr_set(e, mapaddr, map);
2789 dma_unmap_len_set(e, maplen, skb_frag_size(frag)); 2809 dma_unmap_len_set(e, maplen, skb_frag_size(frag));
2790 2810
@@ -2797,6 +2817,8 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2797 td->control = BMU_OWN | BMU_SW | BMU_STF | control | len; 2817 td->control = BMU_OWN | BMU_SW | BMU_STF | control | len;
2798 wmb(); 2818 wmb();
2799 2819
2820 netdev_sent_queue(dev, skb->len);
2821
2800 skge_write8(hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_START); 2822 skge_write8(hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_START);
2801 2823
2802 netif_printk(skge, tx_queued, KERN_DEBUG, skge->netdev, 2824 netif_printk(skge, tx_queued, KERN_DEBUG, skge->netdev,
@@ -2812,15 +2834,35 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2812 } 2834 }
2813 2835
2814 return NETDEV_TX_OK; 2836 return NETDEV_TX_OK;
2837
2838mapping_unwind:
2839 /* unroll any pages that were already mapped. */
2840 if (e != skge->tx_ring.to_use) {
2841 struct skge_element *u;
2842
2843 for (u = skge->tx_ring.to_use->next; u != e; u = u->next)
2844 pci_unmap_page(hw->pdev, dma_unmap_addr(u, mapaddr),
2845 dma_unmap_len(u, maplen),
2846 PCI_DMA_TODEVICE);
2847 e = skge->tx_ring.to_use;
2848 }
2849 /* undo the mapping for the skb header */
2850 pci_unmap_single(hw->pdev, dma_unmap_addr(e, mapaddr),
2851 dma_unmap_len(e, maplen),
2852 PCI_DMA_TODEVICE);
2853mapping_error:
2854 /* mapping error causes error message and packet to be discarded. */
2855 if (net_ratelimit())
2856 dev_warn(&hw->pdev->dev, "%s: tx mapping error\n", dev->name);
2857 dev_kfree_skb(skb);
2858 return NETDEV_TX_OK;
2815} 2859}
2816 2860
2817 2861
2818/* Free resources associated with this reing element */ 2862/* Free resources associated with this reing element */
2819static void skge_tx_free(struct skge_port *skge, struct skge_element *e, 2863static inline void skge_tx_unmap(struct pci_dev *pdev, struct skge_element *e,
2820 u32 control) 2864 u32 control)
2821{ 2865{
2822 struct pci_dev *pdev = skge->hw->pdev;
2823
2824 /* skb header vs. fragment */ 2866 /* skb header vs. fragment */
2825 if (control & BMU_STF) 2867 if (control & BMU_STF)
2826 pci_unmap_single(pdev, dma_unmap_addr(e, mapaddr), 2868 pci_unmap_single(pdev, dma_unmap_addr(e, mapaddr),
@@ -2830,13 +2872,6 @@ static void skge_tx_free(struct skge_port *skge, struct skge_element *e,
2830 pci_unmap_page(pdev, dma_unmap_addr(e, mapaddr), 2872 pci_unmap_page(pdev, dma_unmap_addr(e, mapaddr),
2831 dma_unmap_len(e, maplen), 2873 dma_unmap_len(e, maplen),
2832 PCI_DMA_TODEVICE); 2874 PCI_DMA_TODEVICE);
2833
2834 if (control & BMU_EOF) {
2835 netif_printk(skge, tx_done, KERN_DEBUG, skge->netdev,
2836 "tx done slot %td\n", e - skge->tx_ring.start);
2837
2838 dev_kfree_skb(e->skb);
2839 }
2840} 2875}
2841 2876
2842/* Free all buffers in transmit ring */ 2877/* Free all buffers in transmit ring */
@@ -2847,10 +2882,15 @@ static void skge_tx_clean(struct net_device *dev)
2847 2882
2848 for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) { 2883 for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) {
2849 struct skge_tx_desc *td = e->desc; 2884 struct skge_tx_desc *td = e->desc;
2850 skge_tx_free(skge, e, td->control); 2885
2886 skge_tx_unmap(skge->hw->pdev, e, td->control);
2887
2888 if (td->control & BMU_EOF)
2889 dev_kfree_skb(e->skb);
2851 td->control = 0; 2890 td->control = 0;
2852 } 2891 }
2853 2892
2893 netdev_reset_queue(dev);
2854 skge->tx_ring.to_clean = e; 2894 skge->tx_ring.to_clean = e;
2855} 2895}
2856 2896
@@ -3059,13 +3099,17 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
3059 if (!nskb) 3099 if (!nskb)
3060 goto resubmit; 3100 goto resubmit;
3061 3101
3102 if (unlikely(skge_rx_setup(skge->hw->pdev, e, nskb, skge->rx_buf_size))) {
3103 dev_kfree_skb(nskb);
3104 goto resubmit;
3105 }
3106
3062 pci_unmap_single(skge->hw->pdev, 3107 pci_unmap_single(skge->hw->pdev,
3063 dma_unmap_addr(e, mapaddr), 3108 dma_unmap_addr(e, mapaddr),
3064 dma_unmap_len(e, maplen), 3109 dma_unmap_len(e, maplen),
3065 PCI_DMA_FROMDEVICE); 3110 PCI_DMA_FROMDEVICE);
3066 skb = e->skb; 3111 skb = e->skb;
3067 prefetch(skb->data); 3112 prefetch(skb->data);
3068 skge_rx_setup(skge, e, nskb, skge->rx_buf_size);
3069 } 3113 }
3070 3114
3071 skb_put(skb, len); 3115 skb_put(skb, len);
@@ -3111,6 +3155,7 @@ static void skge_tx_done(struct net_device *dev)
3111 struct skge_port *skge = netdev_priv(dev); 3155 struct skge_port *skge = netdev_priv(dev);
3112 struct skge_ring *ring = &skge->tx_ring; 3156 struct skge_ring *ring = &skge->tx_ring;
3113 struct skge_element *e; 3157 struct skge_element *e;
3158 unsigned int bytes_compl = 0, pkts_compl = 0;
3114 3159
3115 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F); 3160 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
3116 3161
@@ -3120,8 +3165,20 @@ static void skge_tx_done(struct net_device *dev)
3120 if (control & BMU_OWN) 3165 if (control & BMU_OWN)
3121 break; 3166 break;
3122 3167
3123 skge_tx_free(skge, e, control); 3168 skge_tx_unmap(skge->hw->pdev, e, control);
3169
3170 if (control & BMU_EOF) {
3171 netif_printk(skge, tx_done, KERN_DEBUG, skge->netdev,
3172 "tx done slot %td\n",
3173 e - skge->tx_ring.start);
3174
3175 pkts_compl++;
3176 bytes_compl += e->skb->len;
3177
3178 dev_kfree_skb(e->skb);
3179 }
3124 } 3180 }
3181 netdev_completed_queue(dev, pkts_compl, bytes_compl);
3125 skge->tx_ring.to_clean = e; 3182 skge->tx_ring.to_clean = e;
3126 3183
3127 /* Can run lockless until we need to synchronize to restart queue. */ 3184 /* Can run lockless until we need to synchronize to restart queue. */
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 978f593094c0..405e6ac3faf6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -1247,6 +1247,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd,
1247 u32 reply; 1247 u32 reply;
1248 u32 slave_status = 0; 1248 u32 slave_status = 0;
1249 u8 is_going_down = 0; 1249 u8 is_going_down = 0;
1250 int i;
1250 1251
1251 slave_state[slave].comm_toggle ^= 1; 1252 slave_state[slave].comm_toggle ^= 1;
1252 reply = (u32) slave_state[slave].comm_toggle << 31; 1253 reply = (u32) slave_state[slave].comm_toggle << 31;
@@ -1258,6 +1259,10 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd,
1258 if (cmd == MLX4_COMM_CMD_RESET) { 1259 if (cmd == MLX4_COMM_CMD_RESET) {
1259 mlx4_warn(dev, "Received reset from slave:%d\n", slave); 1260 mlx4_warn(dev, "Received reset from slave:%d\n", slave);
1260 slave_state[slave].active = false; 1261 slave_state[slave].active = false;
1262 for (i = 0; i < MLX4_EVENT_TYPES_NUM; ++i) {
1263 slave_state[slave].event_eq[i].eqn = -1;
1264 slave_state[slave].event_eq[i].token = 0;
1265 }
1261 /*check if we are in the middle of FLR process, 1266 /*check if we are in the middle of FLR process,
1262 if so return "retry" status to the slave*/ 1267 if so return "retry" status to the slave*/
1263 if (MLX4_COMM_CMD_FLR == slave_state[slave].last_cmd) { 1268 if (MLX4_COMM_CMD_FLR == slave_state[slave].last_cmd) {
@@ -1452,7 +1457,7 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
1452{ 1457{
1453 struct mlx4_priv *priv = mlx4_priv(dev); 1458 struct mlx4_priv *priv = mlx4_priv(dev);
1454 struct mlx4_slave_state *s_state; 1459 struct mlx4_slave_state *s_state;
1455 int i, err, port; 1460 int i, j, err, port;
1456 1461
1457 priv->mfunc.vhcr = dma_alloc_coherent(&(dev->pdev->dev), PAGE_SIZE, 1462 priv->mfunc.vhcr = dma_alloc_coherent(&(dev->pdev->dev), PAGE_SIZE,
1458 &priv->mfunc.vhcr_dma, 1463 &priv->mfunc.vhcr_dma,
@@ -1485,6 +1490,8 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
1485 for (i = 0; i < dev->num_slaves; ++i) { 1490 for (i = 0; i < dev->num_slaves; ++i) {
1486 s_state = &priv->mfunc.master.slave_state[i]; 1491 s_state = &priv->mfunc.master.slave_state[i];
1487 s_state->last_cmd = MLX4_COMM_CMD_RESET; 1492 s_state->last_cmd = MLX4_COMM_CMD_RESET;
1493 for (j = 0; j < MLX4_EVENT_TYPES_NUM; ++j)
1494 s_state->event_eq[j].eqn = -1;
1488 __raw_writel((__force u32) 0, 1495 __raw_writel((__force u32) 0,
1489 &priv->mfunc.comm[i].slave_write); 1496 &priv->mfunc.comm[i].slave_write);
1490 __raw_writel((__force u32) 0, 1497 __raw_writel((__force u32) 0,
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c
index 475f9d6af955..7e64033d7de3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cq.c
@@ -96,7 +96,7 @@ void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type)
96static int mlx4_SW2HW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 96static int mlx4_SW2HW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
97 int cq_num) 97 int cq_num)
98{ 98{
99 return mlx4_cmd(dev, mailbox->dma | dev->caps.function, cq_num, 0, 99 return mlx4_cmd(dev, mailbox->dma, cq_num, 0,
100 MLX4_CMD_SW2HW_CQ, MLX4_CMD_TIME_CLASS_A, 100 MLX4_CMD_SW2HW_CQ, MLX4_CMD_TIME_CLASS_A,
101 MLX4_CMD_WRAPPED); 101 MLX4_CMD_WRAPPED);
102} 102}
@@ -111,7 +111,7 @@ static int mlx4_MODIFY_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox
111static int mlx4_HW2SW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 111static int mlx4_HW2SW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
112 int cq_num) 112 int cq_num)
113{ 113{
114 return mlx4_cmd_box(dev, dev->caps.function, mailbox ? mailbox->dma : 0, 114 return mlx4_cmd_box(dev, 0, mailbox ? mailbox->dma : 0,
115 cq_num, mailbox ? 0 : 1, MLX4_CMD_HW2SW_CQ, 115 cq_num, mailbox ? 0 : 1, MLX4_CMD_HW2SW_CQ,
116 MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); 116 MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED);
117} 117}
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 7dbc6a230779..70346fd7f9c4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -183,10 +183,11 @@ static int mlx4_en_set_wol(struct net_device *netdev,
183static int mlx4_en_get_sset_count(struct net_device *dev, int sset) 183static int mlx4_en_get_sset_count(struct net_device *dev, int sset)
184{ 184{
185 struct mlx4_en_priv *priv = netdev_priv(dev); 185 struct mlx4_en_priv *priv = netdev_priv(dev);
186 int bit_count = hweight64(priv->stats_bitmap);
186 187
187 switch (sset) { 188 switch (sset) {
188 case ETH_SS_STATS: 189 case ETH_SS_STATS:
189 return NUM_ALL_STATS + 190 return (priv->stats_bitmap ? bit_count : NUM_ALL_STATS) +
190 (priv->tx_ring_num + priv->rx_ring_num) * 2; 191 (priv->tx_ring_num + priv->rx_ring_num) * 2;
191 case ETH_SS_TEST: 192 case ETH_SS_TEST:
192 return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags 193 return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags
@@ -201,14 +202,34 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
201{ 202{
202 struct mlx4_en_priv *priv = netdev_priv(dev); 203 struct mlx4_en_priv *priv = netdev_priv(dev);
203 int index = 0; 204 int index = 0;
204 int i; 205 int i, j = 0;
205 206
206 spin_lock_bh(&priv->stats_lock); 207 spin_lock_bh(&priv->stats_lock);
207 208
208 for (i = 0; i < NUM_MAIN_STATS; i++) 209 if (!(priv->stats_bitmap)) {
209 data[index++] = ((unsigned long *) &priv->stats)[i]; 210 for (i = 0; i < NUM_MAIN_STATS; i++)
210 for (i = 0; i < NUM_PORT_STATS; i++) 211 data[index++] =
211 data[index++] = ((unsigned long *) &priv->port_stats)[i]; 212 ((unsigned long *) &priv->stats)[i];
213 for (i = 0; i < NUM_PORT_STATS; i++)
214 data[index++] =
215 ((unsigned long *) &priv->port_stats)[i];
216 for (i = 0; i < NUM_PKT_STATS; i++)
217 data[index++] =
218 ((unsigned long *) &priv->pkstats)[i];
219 } else {
220 for (i = 0; i < NUM_MAIN_STATS; i++) {
221 if ((priv->stats_bitmap >> j) & 1)
222 data[index++] =
223 ((unsigned long *) &priv->stats)[i];
224 j++;
225 }
226 for (i = 0; i < NUM_PORT_STATS; i++) {
227 if ((priv->stats_bitmap >> j) & 1)
228 data[index++] =
229 ((unsigned long *) &priv->port_stats)[i];
230 j++;
231 }
232 }
212 for (i = 0; i < priv->tx_ring_num; i++) { 233 for (i = 0; i < priv->tx_ring_num; i++) {
213 data[index++] = priv->tx_ring[i].packets; 234 data[index++] = priv->tx_ring[i].packets;
214 data[index++] = priv->tx_ring[i].bytes; 235 data[index++] = priv->tx_ring[i].bytes;
@@ -217,8 +238,6 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
217 data[index++] = priv->rx_ring[i].packets; 238 data[index++] = priv->rx_ring[i].packets;
218 data[index++] = priv->rx_ring[i].bytes; 239 data[index++] = priv->rx_ring[i].bytes;
219 } 240 }
220 for (i = 0; i < NUM_PKT_STATS; i++)
221 data[index++] = ((unsigned long *) &priv->pkstats)[i];
222 spin_unlock_bh(&priv->stats_lock); 241 spin_unlock_bh(&priv->stats_lock);
223 242
224} 243}
@@ -247,11 +266,29 @@ static void mlx4_en_get_strings(struct net_device *dev,
247 266
248 case ETH_SS_STATS: 267 case ETH_SS_STATS:
249 /* Add main counters */ 268 /* Add main counters */
250 for (i = 0; i < NUM_MAIN_STATS; i++) 269 if (!priv->stats_bitmap) {
251 strcpy(data + (index++) * ETH_GSTRING_LEN, main_strings[i]); 270 for (i = 0; i < NUM_MAIN_STATS; i++)
252 for (i = 0; i< NUM_PORT_STATS; i++) 271 strcpy(data + (index++) * ETH_GSTRING_LEN,
253 strcpy(data + (index++) * ETH_GSTRING_LEN, 272 main_strings[i]);
254 main_strings[i + NUM_MAIN_STATS]); 273 for (i = 0; i < NUM_PORT_STATS; i++)
274 strcpy(data + (index++) * ETH_GSTRING_LEN,
275 main_strings[i +
276 NUM_MAIN_STATS]);
277 for (i = 0; i < NUM_PKT_STATS; i++)
278 strcpy(data + (index++) * ETH_GSTRING_LEN,
279 main_strings[i +
280 NUM_MAIN_STATS +
281 NUM_PORT_STATS]);
282 } else
283 for (i = 0; i < NUM_MAIN_STATS + NUM_PORT_STATS; i++) {
284 if ((priv->stats_bitmap >> i) & 1) {
285 strcpy(data +
286 (index++) * ETH_GSTRING_LEN,
287 main_strings[i]);
288 }
289 if (!(priv->stats_bitmap >> i))
290 break;
291 }
255 for (i = 0; i < priv->tx_ring_num; i++) { 292 for (i = 0; i < priv->tx_ring_num; i++) {
256 sprintf(data + (index++) * ETH_GSTRING_LEN, 293 sprintf(data + (index++) * ETH_GSTRING_LEN,
257 "tx%d_packets", i); 294 "tx%d_packets", i);
@@ -264,9 +301,6 @@ static void mlx4_en_get_strings(struct net_device *dev,
264 sprintf(data + (index++) * ETH_GSTRING_LEN, 301 sprintf(data + (index++) * ETH_GSTRING_LEN,
265 "rx%d_bytes", i); 302 "rx%d_bytes", i);
266 } 303 }
267 for (i = 0; i< NUM_PKT_STATS; i++)
268 strcpy(data + (index++) * ETH_GSTRING_LEN,
269 main_strings[i + NUM_MAIN_STATS + NUM_PORT_STATS]);
270 break; 304 break;
271 } 305 }
272} 306}
@@ -479,6 +513,95 @@ static void mlx4_en_get_ringparam(struct net_device *dev,
479 param->tx_pending = priv->tx_ring[0].size; 513 param->tx_pending = priv->tx_ring[0].size;
480} 514}
481 515
516static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev)
517{
518 struct mlx4_en_priv *priv = netdev_priv(dev);
519
520 return priv->rx_ring_num;
521}
522
523static int mlx4_en_get_rxfh_indir(struct net_device *dev, u32 *ring_index)
524{
525 struct mlx4_en_priv *priv = netdev_priv(dev);
526 struct mlx4_en_rss_map *rss_map = &priv->rss_map;
527 int rss_rings;
528 size_t n = priv->rx_ring_num;
529 int err = 0;
530
531 rss_rings = priv->prof->rss_rings ?: priv->rx_ring_num;
532
533 while (n--) {
534 ring_index[n] = rss_map->qps[n % rss_rings].qpn -
535 rss_map->base_qpn;
536 }
537
538 return err;
539}
540
541static int mlx4_en_set_rxfh_indir(struct net_device *dev,
542 const u32 *ring_index)
543{
544 struct mlx4_en_priv *priv = netdev_priv(dev);
545 struct mlx4_en_dev *mdev = priv->mdev;
546 int port_up = 0;
547 int err = 0;
548 int i;
549 int rss_rings = 0;
550
551 /* Calculate RSS table size and make sure flows are spread evenly
552 * between rings
553 */
554 for (i = 0; i < priv->rx_ring_num; i++) {
555 if (i > 0 && !ring_index[i] && !rss_rings)
556 rss_rings = i;
557
558 if (ring_index[i] != (i % (rss_rings ?: priv->rx_ring_num)))
559 return -EINVAL;
560 }
561
562 if (!rss_rings)
563 rss_rings = priv->rx_ring_num;
564
565 /* RSS table size must be an order of 2 */
566 if (!is_power_of_2(rss_rings))
567 return -EINVAL;
568
569 mutex_lock(&mdev->state_lock);
570 if (priv->port_up) {
571 port_up = 1;
572 mlx4_en_stop_port(dev);
573 }
574
575 priv->prof->rss_rings = rss_rings;
576
577 if (port_up) {
578 err = mlx4_en_start_port(dev);
579 if (err)
580 en_err(priv, "Failed starting port\n");
581 }
582
583 mutex_unlock(&mdev->state_lock);
584 return err;
585}
586
587static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
588 u32 *rule_locs)
589{
590 struct mlx4_en_priv *priv = netdev_priv(dev);
591 int err = 0;
592
593 switch (cmd->cmd) {
594 case ETHTOOL_GRXRINGS:
595 cmd->data = priv->rx_ring_num;
596 break;
597 default:
598 err = -EOPNOTSUPP;
599 break;
600 }
601
602 return err;
603}
604
482const struct ethtool_ops mlx4_en_ethtool_ops = { 605const struct ethtool_ops mlx4_en_ethtool_ops = {
483 .get_drvinfo = mlx4_en_get_drvinfo, 606 .get_drvinfo = mlx4_en_get_drvinfo,
484 .get_settings = mlx4_en_get_settings, 607 .get_settings = mlx4_en_get_settings,
@@ -498,6 +621,10 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
498 .set_pauseparam = mlx4_en_set_pauseparam, 621 .set_pauseparam = mlx4_en_set_pauseparam,
499 .get_ringparam = mlx4_en_get_ringparam, 622 .get_ringparam = mlx4_en_get_ringparam,
500 .set_ringparam = mlx4_en_set_ringparam, 623 .set_ringparam = mlx4_en_set_ringparam,
624 .get_rxnfc = mlx4_en_get_rxnfc,
625 .get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size,
626 .get_rxfh_indir = mlx4_en_get_rxfh_indir,
627 .set_rxfh_indir = mlx4_en_set_rxfh_indir,
501}; 628};
502 629
503 630
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_main.c b/drivers/net/ethernet/mellanox/mlx4/en_main.c
index a06096fcc0b8..2097a7d3c5b8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_main.c
@@ -62,10 +62,6 @@ static const char mlx4_en_version[] =
62 * Device scope module parameters 62 * Device scope module parameters
63 */ 63 */
64 64
65
66/* Enable RSS TCP traffic */
67MLX4_EN_PARM_INT(tcp_rss, 1,
68 "Enable RSS for incomming TCP traffic or disabled (0)");
69/* Enable RSS UDP traffic */ 65/* Enable RSS UDP traffic */
70MLX4_EN_PARM_INT(udp_rss, 1, 66MLX4_EN_PARM_INT(udp_rss, 1,
71 "Enable RSS for incomming UDP traffic or disabled (0)"); 67 "Enable RSS for incomming UDP traffic or disabled (0)");
@@ -104,7 +100,6 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
104 struct mlx4_en_profile *params = &mdev->profile; 100 struct mlx4_en_profile *params = &mdev->profile;
105 int i; 101 int i;
106 102
107 params->tcp_rss = tcp_rss;
108 params->udp_rss = udp_rss; 103 params->udp_rss = udp_rss;
109 if (params->udp_rss && !(mdev->dev->caps.flags 104 if (params->udp_rss && !(mdev->dev->caps.flags
110 & MLX4_DEV_CAP_FLAG_UDP_RSS)) { 105 & MLX4_DEV_CAP_FLAG_UDP_RSS)) {
@@ -120,6 +115,7 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
120 params->prof[i].rx_ring_size = MLX4_EN_DEF_RX_RING_SIZE; 115 params->prof[i].rx_ring_size = MLX4_EN_DEF_RX_RING_SIZE;
121 params->prof[i].tx_ring_num = MLX4_EN_NUM_TX_RINGS + 116 params->prof[i].tx_ring_num = MLX4_EN_NUM_TX_RINGS +
122 (!!pfcrx) * MLX4_EN_NUM_PPP_RINGS; 117 (!!pfcrx) * MLX4_EN_NUM_PPP_RINGS;
118 params->prof[i].rss_rings = 0;
123 } 119 }
124 120
125 return 0; 121 return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 72fa807b69ce..467ae5824875 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -702,6 +702,8 @@ int mlx4_en_start_port(struct net_device *dev)
702 /* Schedule multicast task to populate multicast list */ 702 /* Schedule multicast task to populate multicast list */
703 queue_work(mdev->workqueue, &priv->mcast_task); 703 queue_work(mdev->workqueue, &priv->mcast_task);
704 704
705 mlx4_set_stats_bitmap(mdev->dev, &priv->stats_bitmap);
706
705 priv->port_up = true; 707 priv->port_up = true;
706 netif_tx_start_all_queues(dev); 708 netif_tx_start_all_queues(dev);
707 return 0; 709 return 0;
@@ -807,38 +809,50 @@ static void mlx4_en_restart(struct work_struct *work)
807 mutex_unlock(&mdev->state_lock); 809 mutex_unlock(&mdev->state_lock);
808} 810}
809 811
810 812static void mlx4_en_clear_stats(struct net_device *dev)
811static int mlx4_en_open(struct net_device *dev)
812{ 813{
813 struct mlx4_en_priv *priv = netdev_priv(dev); 814 struct mlx4_en_priv *priv = netdev_priv(dev);
814 struct mlx4_en_dev *mdev = priv->mdev; 815 struct mlx4_en_dev *mdev = priv->mdev;
815 int i; 816 int i;
816 int err = 0;
817
818 mutex_lock(&mdev->state_lock);
819
820 if (!mdev->device_up) {
821 en_err(priv, "Cannot open - device down/disabled\n");
822 err = -EBUSY;
823 goto out;
824 }
825 817
826 /* Reset HW statistics and performance counters */
827 if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1)) 818 if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1))
828 en_dbg(HW, priv, "Failed dumping statistics\n"); 819 en_dbg(HW, priv, "Failed dumping statistics\n");
829 820
830 memset(&priv->stats, 0, sizeof(priv->stats)); 821 memset(&priv->stats, 0, sizeof(priv->stats));
831 memset(&priv->pstats, 0, sizeof(priv->pstats)); 822 memset(&priv->pstats, 0, sizeof(priv->pstats));
823 memset(&priv->pkstats, 0, sizeof(priv->pkstats));
824 memset(&priv->port_stats, 0, sizeof(priv->port_stats));
832 825
833 for (i = 0; i < priv->tx_ring_num; i++) { 826 for (i = 0; i < priv->tx_ring_num; i++) {
834 priv->tx_ring[i].bytes = 0; 827 priv->tx_ring[i].bytes = 0;
835 priv->tx_ring[i].packets = 0; 828 priv->tx_ring[i].packets = 0;
829 priv->tx_ring[i].tx_csum = 0;
836 } 830 }
837 for (i = 0; i < priv->rx_ring_num; i++) { 831 for (i = 0; i < priv->rx_ring_num; i++) {
838 priv->rx_ring[i].bytes = 0; 832 priv->rx_ring[i].bytes = 0;
839 priv->rx_ring[i].packets = 0; 833 priv->rx_ring[i].packets = 0;
834 priv->rx_ring[i].csum_ok = 0;
835 priv->rx_ring[i].csum_none = 0;
836 }
837}
838
839static int mlx4_en_open(struct net_device *dev)
840{
841 struct mlx4_en_priv *priv = netdev_priv(dev);
842 struct mlx4_en_dev *mdev = priv->mdev;
843 int err = 0;
844
845 mutex_lock(&mdev->state_lock);
846
847 if (!mdev->device_up) {
848 en_err(priv, "Cannot open - device down/disabled\n");
849 err = -EBUSY;
850 goto out;
840 } 851 }
841 852
853 /* Reset HW statistics and SW counters */
854 mlx4_en_clear_stats(dev);
855
842 err = mlx4_en_start_port(dev); 856 err = mlx4_en_start_port(dev);
843 if (err) 857 if (err)
844 en_err(priv, "Failed starting port:%d\n", priv->port); 858 en_err(priv, "Failed starting port:%d\n", priv->port);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index e8d6ad2dce0a..971d4b6b8dfe 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -853,6 +853,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
853 struct mlx4_en_rss_map *rss_map = &priv->rss_map; 853 struct mlx4_en_rss_map *rss_map = &priv->rss_map;
854 struct mlx4_qp_context context; 854 struct mlx4_qp_context context;
855 struct mlx4_rss_context *rss_context; 855 struct mlx4_rss_context *rss_context;
856 int rss_rings;
856 void *ptr; 857 void *ptr;
857 u8 rss_mask = (MLX4_RSS_IPV4 | MLX4_RSS_TCP_IPV4 | MLX4_RSS_IPV6 | 858 u8 rss_mask = (MLX4_RSS_IPV4 | MLX4_RSS_TCP_IPV4 | MLX4_RSS_IPV6 |
858 MLX4_RSS_TCP_IPV6); 859 MLX4_RSS_TCP_IPV6);
@@ -893,10 +894,15 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
893 mlx4_en_fill_qp_context(priv, 0, 0, 0, 1, priv->base_qpn, 894 mlx4_en_fill_qp_context(priv, 0, 0, 0, 1, priv->base_qpn,
894 priv->rx_ring[0].cqn, &context); 895 priv->rx_ring[0].cqn, &context);
895 896
897 if (!priv->prof->rss_rings || priv->prof->rss_rings > priv->rx_ring_num)
898 rss_rings = priv->rx_ring_num;
899 else
900 rss_rings = priv->prof->rss_rings;
901
896 ptr = ((void *) &context) + offsetof(struct mlx4_qp_context, pri_path) 902 ptr = ((void *) &context) + offsetof(struct mlx4_qp_context, pri_path)
897 + MLX4_RSS_OFFSET_IN_QPC_PRI_PATH; 903 + MLX4_RSS_OFFSET_IN_QPC_PRI_PATH;
898 rss_context = ptr; 904 rss_context = ptr;
899 rss_context->base_qpn = cpu_to_be32(ilog2(priv->rx_ring_num) << 24 | 905 rss_context->base_qpn = cpu_to_be32(ilog2(rss_rings) << 24 |
900 (rss_map->base_qpn)); 906 (rss_map->base_qpn));
901 rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn); 907 rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn);
902 if (priv->mdev->profile.udp_rss) { 908 if (priv->mdev->profile.udp_rss) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 1e9b55eb7217..55d7bd4e210a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -513,25 +513,22 @@ int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
513{ 513{
514 struct mlx4_priv *priv = mlx4_priv(dev); 514 struct mlx4_priv *priv = mlx4_priv(dev);
515 struct mlx4_slave_event_eq_info *event_eq = 515 struct mlx4_slave_event_eq_info *event_eq =
516 &priv->mfunc.master.slave_state[slave].event_eq; 516 priv->mfunc.master.slave_state[slave].event_eq;
517 u32 in_modifier = vhcr->in_modifier; 517 u32 in_modifier = vhcr->in_modifier;
518 u32 eqn = in_modifier & 0x1FF; 518 u32 eqn = in_modifier & 0x1FF;
519 u64 in_param = vhcr->in_param; 519 u64 in_param = vhcr->in_param;
520 int err = 0; 520 int err = 0;
521 int i;
521 522
522 if (slave == dev->caps.function) 523 if (slave == dev->caps.function)
523 err = mlx4_cmd(dev, in_param, (in_modifier & 0x80000000) | eqn, 524 err = mlx4_cmd(dev, in_param, (in_modifier & 0x80000000) | eqn,
524 0, MLX4_CMD_MAP_EQ, MLX4_CMD_TIME_CLASS_B, 525 0, MLX4_CMD_MAP_EQ, MLX4_CMD_TIME_CLASS_B,
525 MLX4_CMD_NATIVE); 526 MLX4_CMD_NATIVE);
526 if (!err) { 527 if (!err)
527 if (in_modifier >> 31) { 528 for (i = 0; i < MLX4_EVENT_TYPES_NUM; ++i)
528 /* unmap */ 529 if (in_param & (1LL << i))
529 event_eq->event_type &= ~in_param; 530 event_eq[i].eqn = in_modifier >> 31 ? -1 : eqn;
530 } else { 531
531 event_eq->eqn = eqn;
532 event_eq->event_type = in_param;
533 }
534 }
535 return err; 532 return err;
536} 533}
537 534
@@ -546,7 +543,7 @@ static int mlx4_MAP_EQ(struct mlx4_dev *dev, u64 event_mask, int unmap,
546static int mlx4_SW2HW_EQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 543static int mlx4_SW2HW_EQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
547 int eq_num) 544 int eq_num)
548{ 545{
549 return mlx4_cmd(dev, mailbox->dma | dev->caps.function, eq_num, 0, 546 return mlx4_cmd(dev, mailbox->dma, eq_num, 0,
550 MLX4_CMD_SW2HW_EQ, MLX4_CMD_TIME_CLASS_A, 547 MLX4_CMD_SW2HW_EQ, MLX4_CMD_TIME_CLASS_A,
551 MLX4_CMD_WRAPPED); 548 MLX4_CMD_WRAPPED);
552} 549}
@@ -554,7 +551,7 @@ static int mlx4_SW2HW_EQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
554static int mlx4_HW2SW_EQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 551static int mlx4_HW2SW_EQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
555 int eq_num) 552 int eq_num)
556{ 553{
557 return mlx4_cmd_box(dev, dev->caps.function, mailbox->dma, eq_num, 554 return mlx4_cmd_box(dev, 0, mailbox->dma, eq_num,
558 0, MLX4_CMD_HW2SW_EQ, MLX4_CMD_TIME_CLASS_A, 555 0, MLX4_CMD_HW2SW_EQ, MLX4_CMD_TIME_CLASS_A,
559 MLX4_CMD_WRAPPED); 556 MLX4_CMD_WRAPPED);
560} 557}
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index a424a19280cc..8a21e10952ea 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -158,7 +158,6 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave,
158 158
159#define QUERY_FUNC_CAP_FLAGS_OFFSET 0x0 159#define QUERY_FUNC_CAP_FLAGS_OFFSET 0x0
160#define QUERY_FUNC_CAP_NUM_PORTS_OFFSET 0x1 160#define QUERY_FUNC_CAP_NUM_PORTS_OFFSET 0x1
161#define QUERY_FUNC_CAP_FUNCTION_OFFSET 0x3
162#define QUERY_FUNC_CAP_PF_BHVR_OFFSET 0x4 161#define QUERY_FUNC_CAP_PF_BHVR_OFFSET 0x4
163#define QUERY_FUNC_CAP_QP_QUOTA_OFFSET 0x10 162#define QUERY_FUNC_CAP_QP_QUOTA_OFFSET 0x10
164#define QUERY_FUNC_CAP_CQ_QUOTA_OFFSET 0x14 163#define QUERY_FUNC_CAP_CQ_QUOTA_OFFSET 0x14
@@ -182,9 +181,6 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave,
182 field = 1 << 7; /* enable only ethernet interface */ 181 field = 1 << 7; /* enable only ethernet interface */
183 MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS_OFFSET); 182 MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS_OFFSET);
184 183
185 field = slave;
186 MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FUNCTION_OFFSET);
187
188 field = dev->caps.num_ports; 184 field = dev->caps.num_ports;
189 MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_NUM_PORTS_OFFSET); 185 MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_NUM_PORTS_OFFSET);
190 186
@@ -249,9 +245,6 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, struct mlx4_func_cap *func_cap)
249 goto out; 245 goto out;
250 } 246 }
251 247
252 MLX4_GET(field, outbox, QUERY_FUNC_CAP_FUNCTION_OFFSET);
253 func_cap->function = field;
254
255 MLX4_GET(field, outbox, QUERY_FUNC_CAP_NUM_PORTS_OFFSET); 248 MLX4_GET(field, outbox, QUERY_FUNC_CAP_NUM_PORTS_OFFSET);
256 func_cap->num_ports = field; 249 func_cap->num_ports = field;
257 250
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.h b/drivers/net/ethernet/mellanox/mlx4/fw.h
index 119e0cc9fab3..e1a5fa56bcbc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.h
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.h
@@ -119,7 +119,6 @@ struct mlx4_dev_cap {
119}; 119};
120 120
121struct mlx4_func_cap { 121struct mlx4_func_cap {
122 u8 function;
123 u8 num_ports; 122 u8 num_ports;
124 u8 flags; 123 u8 flags;
125 u32 pf_context_behaviour; 124 u32 pf_context_behaviour;
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 6bb62c580e2d..678558b502fc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -108,7 +108,7 @@ static struct mlx4_profile default_profile = {
108 .num_cq = 1 << 16, 108 .num_cq = 1 << 16,
109 .num_mcg = 1 << 13, 109 .num_mcg = 1 << 13,
110 .num_mpt = 1 << 19, 110 .num_mpt = 1 << 19,
111 .num_mtt = 1 << 20, 111 .num_mtt = 1 << 20, /* It is really num mtt segements */
112}; 112};
113 113
114static int log_num_mac = 7; 114static int log_num_mac = 7;
@@ -471,7 +471,6 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
471 return -ENOSYS; 471 return -ENOSYS;
472 } 472 }
473 473
474 dev->caps.function = func_cap.function;
475 dev->caps.num_ports = func_cap.num_ports; 474 dev->caps.num_ports = func_cap.num_ports;
476 dev->caps.num_qps = func_cap.qp_quota; 475 dev->caps.num_qps = func_cap.qp_quota;
477 dev->caps.num_srqs = func_cap.srq_quota; 476 dev->caps.num_srqs = func_cap.srq_quota;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index a80121a2b519..c92269f8c057 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -388,9 +388,8 @@ struct mlx4_slave_eqe {
388}; 388};
389 389
390struct mlx4_slave_event_eq_info { 390struct mlx4_slave_event_eq_info {
391 u32 eqn; 391 int eqn;
392 u16 token; 392 u16 token;
393 u64 event_type;
394}; 393};
395 394
396struct mlx4_profile { 395struct mlx4_profile {
@@ -449,6 +448,8 @@ struct mlx4_steer_index {
449 struct list_head duplicates; 448 struct list_head duplicates;
450}; 449};
451 450
451#define MLX4_EVENT_TYPES_NUM 64
452
452struct mlx4_slave_state { 453struct mlx4_slave_state {
453 u8 comm_toggle; 454 u8 comm_toggle;
454 u8 last_cmd; 455 u8 last_cmd;
@@ -461,7 +462,8 @@ struct mlx4_slave_state {
461 struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES]; 462 struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES];
462 struct list_head mcast_filters[MLX4_MAX_PORTS + 1]; 463 struct list_head mcast_filters[MLX4_MAX_PORTS + 1];
463 struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1]; 464 struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1];
464 struct mlx4_slave_event_eq_info event_eq; 465 /* event type to eq number lookup */
466 struct mlx4_slave_event_eq_info event_eq[MLX4_EVENT_TYPES_NUM];
465 u16 eq_pi; 467 u16 eq_pi;
466 u16 eq_ci; 468 u16 eq_ci;
467 spinlock_t lock; 469 spinlock_t lock;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index f2a8e65f5f88..35f08840813c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -325,11 +325,11 @@ struct mlx4_en_port_profile {
325 u8 rx_ppp; 325 u8 rx_ppp;
326 u8 tx_pause; 326 u8 tx_pause;
327 u8 tx_ppp; 327 u8 tx_ppp;
328 int rss_rings;
328}; 329};
329 330
330struct mlx4_en_profile { 331struct mlx4_en_profile {
331 int rss_xor; 332 int rss_xor;
332 int tcp_rss;
333 int udp_rss; 333 int udp_rss;
334 u8 rss_mask; 334 u8 rss_mask;
335 u32 active_ports; 335 u32 active_ports;
@@ -476,6 +476,7 @@ struct mlx4_en_priv {
476 struct mlx4_en_perf_stats pstats; 476 struct mlx4_en_perf_stats pstats;
477 struct mlx4_en_pkt_stats pkstats; 477 struct mlx4_en_pkt_stats pkstats;
478 struct mlx4_en_port_stats port_stats; 478 struct mlx4_en_port_stats port_stats;
479 u64 stats_bitmap;
479 char *mc_addrs; 480 char *mc_addrs;
480 int mc_addrs_cnt; 481 int mc_addrs_cnt;
481 struct mlx4_en_stat_out_mbox hw_stats; 482 struct mlx4_en_stat_out_mbox hw_stats;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
index 01df5567e16e..8deeef98280c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
@@ -291,7 +291,7 @@ static u32 key_to_hw_index(u32 key)
291static int mlx4_SW2HW_MPT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 291static int mlx4_SW2HW_MPT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
292 int mpt_index) 292 int mpt_index)
293{ 293{
294 return mlx4_cmd(dev, mailbox->dma | dev->caps.function , mpt_index, 294 return mlx4_cmd(dev, mailbox->dma, mpt_index,
295 0, MLX4_CMD_SW2HW_MPT, MLX4_CMD_TIME_CLASS_B, 295 0, MLX4_CMD_SW2HW_MPT, MLX4_CMD_TIME_CLASS_B,
296 MLX4_CMD_WRAPPED); 296 MLX4_CMD_WRAPPED);
297} 297}
diff --git a/drivers/net/ethernet/mellanox/mlx4/pd.c b/drivers/net/ethernet/mellanox/mlx4/pd.c
index 5c9a54df17ab..db4746d0dca7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/pd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/pd.c
@@ -52,8 +52,7 @@ int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn)
52 *pdn = mlx4_bitmap_alloc(&priv->pd_bitmap); 52 *pdn = mlx4_bitmap_alloc(&priv->pd_bitmap);
53 if (*pdn == -1) 53 if (*pdn == -1)
54 return -ENOMEM; 54 return -ENOMEM;
55 if (mlx4_is_mfunc(dev)) 55
56 *pdn |= (dev->caps.function + 1) << NOT_MASKED_PD_BITS;
57 return 0; 56 return 0;
58} 57}
59EXPORT_SYMBOL_GPL(mlx4_pd_alloc); 58EXPORT_SYMBOL_GPL(mlx4_pd_alloc);
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index 88b52e547524..f44ae555bf43 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -44,6 +44,11 @@
44#define MLX4_VLAN_VALID (1u << 31) 44#define MLX4_VLAN_VALID (1u << 31)
45#define MLX4_VLAN_MASK 0xfff 45#define MLX4_VLAN_MASK 0xfff
46 46
47#define MLX4_STATS_TRAFFIC_COUNTERS_MASK 0xfULL
48#define MLX4_STATS_TRAFFIC_DROPS_MASK 0xc0ULL
49#define MLX4_STATS_ERROR_COUNTERS_MASK 0x1ffc30ULL
50#define MLX4_STATS_PORT_COUNTERS_MASK 0x1fe00000ULL
51
47void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table) 52void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table)
48{ 53{
49 int i; 54 int i;
@@ -898,6 +903,24 @@ int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
898 struct mlx4_cmd_mailbox *outbox, 903 struct mlx4_cmd_mailbox *outbox,
899 struct mlx4_cmd_info *cmd) 904 struct mlx4_cmd_info *cmd)
900{ 905{
906 if (slave != dev->caps.function)
907 return 0;
901 return mlx4_common_dump_eth_stats(dev, slave, 908 return mlx4_common_dump_eth_stats(dev, slave,
902 vhcr->in_modifier, outbox); 909 vhcr->in_modifier, outbox);
903} 910}
911
912void mlx4_set_stats_bitmap(struct mlx4_dev *dev, u64 *stats_bitmap)
913{
914 if (!mlx4_is_mfunc(dev)) {
915 *stats_bitmap = 0;
916 return;
917 }
918
919 *stats_bitmap = (MLX4_STATS_TRAFFIC_COUNTERS_MASK |
920 MLX4_STATS_TRAFFIC_DROPS_MASK |
921 MLX4_STATS_PORT_COUNTERS_MASK);
922
923 if (mlx4_is_master(dev))
924 *stats_bitmap |= MLX4_STATS_ERROR_COUNTERS_MASK;
925}
926EXPORT_SYMBOL(mlx4_set_stats_bitmap);
diff --git a/drivers/net/ethernet/mellanox/mlx4/profile.c b/drivers/net/ethernet/mellanox/mlx4/profile.c
index 66f91ca7a7c6..1129677daa62 100644
--- a/drivers/net/ethernet/mellanox/mlx4/profile.c
+++ b/drivers/net/ethernet/mellanox/mlx4/profile.c
@@ -110,7 +110,7 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
110 profile[MLX4_RES_EQ].num = min_t(unsigned, dev_cap->max_eqs, MAX_MSIX); 110 profile[MLX4_RES_EQ].num = min_t(unsigned, dev_cap->max_eqs, MAX_MSIX);
111 profile[MLX4_RES_DMPT].num = request->num_mpt; 111 profile[MLX4_RES_DMPT].num = request->num_mpt;
112 profile[MLX4_RES_CMPT].num = MLX4_NUM_CMPTS; 112 profile[MLX4_RES_CMPT].num = MLX4_NUM_CMPTS;
113 profile[MLX4_RES_MTT].num = request->num_mtt; 113 profile[MLX4_RES_MTT].num = request->num_mtt * (1 << log_mtts_per_seg);
114 profile[MLX4_RES_MCG].num = request->num_mcg; 114 profile[MLX4_RES_MCG].num = request->num_mcg;
115 115
116 for (i = 0; i < MLX4_RES_NUM; ++i) { 116 for (i = 0; i < MLX4_RES_NUM; ++i) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
index 6b03ac8b9002..738f950a1ce5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
@@ -162,7 +162,7 @@ static int __mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
162 ((struct mlx4_qp_context *) (mailbox->buf + 8))->local_qpn = 162 ((struct mlx4_qp_context *) (mailbox->buf + 8))->local_qpn =
163 cpu_to_be32(qp->qpn); 163 cpu_to_be32(qp->qpn);
164 164
165 ret = mlx4_cmd(dev, mailbox->dma | dev->caps.function, 165 ret = mlx4_cmd(dev, mailbox->dma,
166 qp->qpn | (!!sqd_event << 31), 166 qp->qpn | (!!sqd_event << 31),
167 new_state == MLX4_QP_STATE_RST ? 2 : 0, 167 new_state == MLX4_QP_STATE_RST ? 2 : 0,
168 op[cur_state][new_state], MLX4_CMD_TIME_CLASS_C, native); 168 op[cur_state][new_state], MLX4_CMD_TIME_CLASS_C, native);
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index ed20751a057d..dcd819bfb2f0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -1561,11 +1561,6 @@ static int mr_get_mtt_size(struct mlx4_mpt_entry *mpt)
1561 return be32_to_cpu(mpt->mtt_sz); 1561 return be32_to_cpu(mpt->mtt_sz);
1562} 1562}
1563 1563
1564static int mr_get_pdn(struct mlx4_mpt_entry *mpt)
1565{
1566 return be32_to_cpu(mpt->pd_flags) & 0xffffff;
1567}
1568
1569static int qp_get_mtt_addr(struct mlx4_qp_context *qpc) 1564static int qp_get_mtt_addr(struct mlx4_qp_context *qpc)
1570{ 1565{
1571 return be32_to_cpu(qpc->mtt_base_addr_l) & 0xfffffff8; 1566 return be32_to_cpu(qpc->mtt_base_addr_l) & 0xfffffff8;
@@ -1602,16 +1597,6 @@ static int qp_get_mtt_size(struct mlx4_qp_context *qpc)
1602 return total_pages; 1597 return total_pages;
1603} 1598}
1604 1599
1605static int qp_get_pdn(struct mlx4_qp_context *qpc)
1606{
1607 return be32_to_cpu(qpc->pd) & 0xffffff;
1608}
1609
1610static int pdn2slave(int pdn)
1611{
1612 return (pdn >> NOT_MASKED_PD_BITS) - 1;
1613}
1614
1615static int check_mtt_range(struct mlx4_dev *dev, int slave, int start, 1600static int check_mtt_range(struct mlx4_dev *dev, int slave, int start,
1616 int size, struct res_mtt *mtt) 1601 int size, struct res_mtt *mtt)
1617{ 1602{
@@ -1656,11 +1641,6 @@ int mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave,
1656 mpt->mtt = mtt; 1641 mpt->mtt = mtt;
1657 } 1642 }
1658 1643
1659 if (pdn2slave(mr_get_pdn(inbox->buf)) != slave) {
1660 err = -EPERM;
1661 goto ex_put;
1662 }
1663
1664 err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd); 1644 err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd);
1665 if (err) 1645 if (err)
1666 goto ex_put; 1646 goto ex_put;
@@ -1792,11 +1772,6 @@ int mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
1792 if (err) 1772 if (err)
1793 goto ex_put_mtt; 1773 goto ex_put_mtt;
1794 1774
1795 if (pdn2slave(qp_get_pdn(qpc)) != slave) {
1796 err = -EPERM;
1797 goto ex_put_mtt;
1798 }
1799
1800 err = get_res(dev, slave, rcqn, RES_CQ, &rcq); 1775 err = get_res(dev, slave, rcqn, RES_CQ, &rcq);
1801 if (err) 1776 if (err)
1802 goto ex_put_mtt; 1777 goto ex_put_mtt;
@@ -2048,10 +2023,10 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe)
2048 if (!priv->mfunc.master.slave_state) 2023 if (!priv->mfunc.master.slave_state)
2049 return -EINVAL; 2024 return -EINVAL;
2050 2025
2051 event_eq = &priv->mfunc.master.slave_state[slave].event_eq; 2026 event_eq = &priv->mfunc.master.slave_state[slave].event_eq[eqe->type];
2052 2027
2053 /* Create the event only if the slave is registered */ 2028 /* Create the event only if the slave is registered */
2054 if ((event_eq->event_type & (1 << eqe->type)) == 0) 2029 if (event_eq->eqn < 0)
2055 return 0; 2030 return 0;
2056 2031
2057 mutex_lock(&priv->mfunc.master.gen_eqe_mutex[slave]); 2032 mutex_lock(&priv->mfunc.master.gen_eqe_mutex[slave]);
@@ -2289,11 +2264,6 @@ ex_put:
2289 return err; 2264 return err;
2290} 2265}
2291 2266
2292static int srq_get_pdn(struct mlx4_srq_context *srqc)
2293{
2294 return be32_to_cpu(srqc->pd) & 0xffffff;
2295}
2296
2297static int srq_get_mtt_size(struct mlx4_srq_context *srqc) 2267static int srq_get_mtt_size(struct mlx4_srq_context *srqc)
2298{ 2268{
2299 int log_srq_size = (be32_to_cpu(srqc->state_logsize_srqn) >> 24) & 0xf; 2269 int log_srq_size = (be32_to_cpu(srqc->state_logsize_srqn) >> 24) & 0xf;
@@ -2333,11 +2303,6 @@ int mlx4_SW2HW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
2333 if (err) 2303 if (err)
2334 goto ex_put_mtt; 2304 goto ex_put_mtt;
2335 2305
2336 if (pdn2slave(srq_get_pdn(srqc)) != slave) {
2337 err = -EPERM;
2338 goto ex_put_mtt;
2339 }
2340
2341 err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd); 2306 err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd);
2342 if (err) 2307 if (err)
2343 goto ex_put_mtt; 2308 goto ex_put_mtt;
diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c
index 2823fffc6383..feda6c00829f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/srq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/srq.c
@@ -67,7 +67,7 @@ void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type)
67static int mlx4_SW2HW_SRQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 67static int mlx4_SW2HW_SRQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
68 int srq_num) 68 int srq_num)
69{ 69{
70 return mlx4_cmd(dev, mailbox->dma | dev->caps.function, srq_num, 0, 70 return mlx4_cmd(dev, mailbox->dma, srq_num, 0,
71 MLX4_CMD_SW2HW_SRQ, MLX4_CMD_TIME_CLASS_A, 71 MLX4_CMD_SW2HW_SRQ, MLX4_CMD_TIME_CLASS_A,
72 MLX4_CMD_WRAPPED); 72 MLX4_CMD_WRAPPED);
73} 73}
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 964e9c0948bc..3ead111111e1 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -1745,6 +1745,12 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
1745 struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring; 1745 struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
1746 int err; 1746 int err;
1747 1747
1748 /* Ensure we have a valid MAC */
1749 if (!is_valid_ether_addr(adapter->hw.mac.addr)) {
1750 pr_err("Error: Invalid MAC address\n");
1751 return -EINVAL;
1752 }
1753
1748 /* hardware has been reset, we need to reload some things */ 1754 /* hardware has been reset, we need to reload some things */
1749 pch_gbe_set_multi(netdev); 1755 pch_gbe_set_multi(netdev);
1750 1756
@@ -2468,9 +2474,14 @@ static int pch_gbe_probe(struct pci_dev *pdev,
2468 2474
2469 memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); 2475 memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
2470 if (!is_valid_ether_addr(netdev->dev_addr)) { 2476 if (!is_valid_ether_addr(netdev->dev_addr)) {
2471 dev_err(&pdev->dev, "Invalid MAC Address\n"); 2477 /*
2472 ret = -EIO; 2478 * If the MAC is invalid (or just missing), display a warning
2473 goto err_free_adapter; 2479 * but do not abort setting up the device. pch_gbe_up will
2480 * prevent the interface from being brought up until a valid MAC
2481 * is set.
2482 */
2483 dev_err(&pdev->dev, "Invalid MAC address, "
2484 "interface disabled.\n");
2474 } 2485 }
2475 setup_timer(&adapter->watchdog_timer, pch_gbe_watchdog, 2486 setup_timer(&adapter->watchdog_timer, pch_gbe_watchdog,
2476 (unsigned long)adapter); 2487 (unsigned long)adapter);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index da4a1042523a..73195329aa46 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -154,7 +154,7 @@ int stmmac_mdio_register(struct net_device *ndev)
154 else 154 else
155 irqlist = priv->mii_irq; 155 irqlist = priv->mii_irq;
156 156
157 new_bus->name = "STMMAC MII Bus"; 157 new_bus->name = "stmmac";
158 new_bus->read = &stmmac_mdio_read; 158 new_bus->read = &stmmac_mdio_read;
159 new_bus->write = &stmmac_mdio_write; 159 new_bus->write = &stmmac_mdio_write;
160 new_bus->reset = &stmmac_mdio_reset; 160 new_bus->reset = &stmmac_mdio_reset;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 54a819a36487..c796de9eed72 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -170,9 +170,9 @@ static int stmmac_pci_resume(struct pci_dev *pdev)
170#define STMMAC_DEVICE_ID 0x1108 170#define STMMAC_DEVICE_ID 0x1108
171 171
172static DEFINE_PCI_DEVICE_TABLE(stmmac_id_table) = { 172static DEFINE_PCI_DEVICE_TABLE(stmmac_id_table) = {
173 { 173 {PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)},
174 PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)}, { 174 {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC)},
175 } 175 {}
176}; 176};
177 177
178MODULE_DEVICE_TABLE(pci, stmmac_id_table); 178MODULE_DEVICE_TABLE(pci, stmmac_id_table);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 462d05f05e84..1a1ca6cfc74a 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -68,11 +68,11 @@ static void do_set_multicast(struct work_struct *w)
68 68
69 nvdev = hv_get_drvdata(ndevctx->device_ctx); 69 nvdev = hv_get_drvdata(ndevctx->device_ctx);
70 if (nvdev == NULL) 70 if (nvdev == NULL)
71 return; 71 goto out;
72 72
73 rdev = nvdev->extension; 73 rdev = nvdev->extension;
74 if (rdev == NULL) 74 if (rdev == NULL)
75 return; 75 goto out;
76 76
77 if (net->flags & IFF_PROMISC) 77 if (net->flags & IFF_PROMISC)
78 rndis_filter_set_packet_filter(rdev, 78 rndis_filter_set_packet_filter(rdev,
@@ -83,6 +83,7 @@ static void do_set_multicast(struct work_struct *w)
83 NDIS_PACKET_TYPE_ALL_MULTICAST | 83 NDIS_PACKET_TYPE_ALL_MULTICAST |
84 NDIS_PACKET_TYPE_DIRECTED); 84 NDIS_PACKET_TYPE_DIRECTED);
85 85
86out:
86 kfree(w); 87 kfree(w);
87} 88}
88 89
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index f2f820c4b40a..9ea99217f116 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -173,6 +173,7 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb)
173 skb = ip_check_defrag(skb, IP_DEFRAG_MACVLAN); 173 skb = ip_check_defrag(skb, IP_DEFRAG_MACVLAN);
174 if (!skb) 174 if (!skb)
175 return RX_HANDLER_CONSUMED; 175 return RX_HANDLER_CONSUMED;
176 eth = eth_hdr(skb);
176 src = macvlan_hash_lookup(port, eth->h_source); 177 src = macvlan_hash_lookup(port, eth->h_source);
177 if (!src) 178 if (!src)
178 /* frame comes from an external address */ 179 /* frame comes from an external address */
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 88cc5db9affd..8985cc62cf41 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -38,12 +38,11 @@
38 38
39/** 39/**
40 * mdiobus_alloc_size - allocate a mii_bus structure 40 * mdiobus_alloc_size - allocate a mii_bus structure
41 * @size: extra amount of memory to allocate for private storage.
42 * If non-zero, then bus->priv is points to that memory.
41 * 43 *
42 * Description: called by a bus driver to allocate an mii_bus 44 * Description: called by a bus driver to allocate an mii_bus
43 * structure to fill in. 45 * structure to fill in.
44 *
45 * 'size' is an an extra amount of memory to allocate for private storage.
46 * If non-zero, then bus->priv is points to that memory.
47 */ 46 */
48struct mii_bus *mdiobus_alloc_size(size_t size) 47struct mii_bus *mdiobus_alloc_size(size_t size)
49{ 48{
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index ed2a862b835d..6b678f38e5ce 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -92,9 +92,9 @@ struct team_option *__team_find_option(struct team *team, const char *opt_name)
92 return NULL; 92 return NULL;
93} 93}
94 94
95int team_options_register(struct team *team, 95int __team_options_register(struct team *team,
96 const struct team_option *option, 96 const struct team_option *option,
97 size_t option_count) 97 size_t option_count)
98{ 98{
99 int i; 99 int i;
100 struct team_option **dst_opts; 100 struct team_option **dst_opts;
@@ -116,8 +116,11 @@ int team_options_register(struct team *team,
116 } 116 }
117 } 117 }
118 118
119 for (i = 0; i < option_count; i++) 119 for (i = 0; i < option_count; i++) {
120 dst_opts[i]->changed = true;
121 dst_opts[i]->removed = false;
120 list_add_tail(&dst_opts[i]->list, &team->option_list); 122 list_add_tail(&dst_opts[i]->list, &team->option_list);
123 }
121 124
122 kfree(dst_opts); 125 kfree(dst_opts);
123 return 0; 126 return 0;
@@ -130,10 +133,22 @@ rollback:
130 return err; 133 return err;
131} 134}
132 135
133EXPORT_SYMBOL(team_options_register); 136static void __team_options_mark_removed(struct team *team,
137 const struct team_option *option,
138 size_t option_count)
139{
140 int i;
141
142 for (i = 0; i < option_count; i++, option++) {
143 struct team_option *del_opt;
134 144
135static void __team_options_change_check(struct team *team, 145 del_opt = __team_find_option(team, option->name);
136 struct team_option *changed_option); 146 if (del_opt) {
147 del_opt->changed = true;
148 del_opt->removed = true;
149 }
150 }
151}
137 152
138static void __team_options_unregister(struct team *team, 153static void __team_options_unregister(struct team *team,
139 const struct team_option *option, 154 const struct team_option *option,
@@ -152,12 +167,29 @@ static void __team_options_unregister(struct team *team,
152 } 167 }
153} 168}
154 169
170static void __team_options_change_check(struct team *team);
171
172int team_options_register(struct team *team,
173 const struct team_option *option,
174 size_t option_count)
175{
176 int err;
177
178 err = __team_options_register(team, option, option_count);
179 if (err)
180 return err;
181 __team_options_change_check(team);
182 return 0;
183}
184EXPORT_SYMBOL(team_options_register);
185
155void team_options_unregister(struct team *team, 186void team_options_unregister(struct team *team,
156 const struct team_option *option, 187 const struct team_option *option,
157 size_t option_count) 188 size_t option_count)
158{ 189{
190 __team_options_mark_removed(team, option, option_count);
191 __team_options_change_check(team);
159 __team_options_unregister(team, option, option_count); 192 __team_options_unregister(team, option, option_count);
160 __team_options_change_check(team, NULL);
161} 193}
162EXPORT_SYMBOL(team_options_unregister); 194EXPORT_SYMBOL(team_options_unregister);
163 195
@@ -176,7 +208,8 @@ static int team_option_set(struct team *team, struct team_option *option,
176 if (err) 208 if (err)
177 return err; 209 return err;
178 210
179 __team_options_change_check(team, option); 211 option->changed = true;
212 __team_options_change_check(team);
180 return err; 213 return err;
181} 214}
182 215
@@ -653,6 +686,7 @@ static int team_port_del(struct team *team, struct net_device *port_dev)
653 return -ENOENT; 686 return -ENOENT;
654 } 687 }
655 688
689 port->removed = true;
656 __team_port_change_check(port, false); 690 __team_port_change_check(port, false);
657 team_port_list_del_port(team, port); 691 team_port_list_del_port(team, port);
658 team_adjust_ops(team); 692 team_adjust_ops(team);
@@ -1200,10 +1234,9 @@ err_fill:
1200 return err; 1234 return err;
1201} 1235}
1202 1236
1203static int team_nl_fill_options_get_changed(struct sk_buff *skb, 1237static int team_nl_fill_options_get(struct sk_buff *skb,
1204 u32 pid, u32 seq, int flags, 1238 u32 pid, u32 seq, int flags,
1205 struct team *team, 1239 struct team *team, bool fillall)
1206 struct team_option *changed_option)
1207{ 1240{
1208 struct nlattr *option_list; 1241 struct nlattr *option_list;
1209 void *hdr; 1242 void *hdr;
@@ -1223,12 +1256,19 @@ static int team_nl_fill_options_get_changed(struct sk_buff *skb,
1223 struct nlattr *option_item; 1256 struct nlattr *option_item;
1224 long arg; 1257 long arg;
1225 1258
1259 /* Include only changed options if fill all mode is not on */
1260 if (!fillall && !option->changed)
1261 continue;
1226 option_item = nla_nest_start(skb, TEAM_ATTR_ITEM_OPTION); 1262 option_item = nla_nest_start(skb, TEAM_ATTR_ITEM_OPTION);
1227 if (!option_item) 1263 if (!option_item)
1228 goto nla_put_failure; 1264 goto nla_put_failure;
1229 NLA_PUT_STRING(skb, TEAM_ATTR_OPTION_NAME, option->name); 1265 NLA_PUT_STRING(skb, TEAM_ATTR_OPTION_NAME, option->name);
1230 if (option == changed_option) 1266 if (option->changed) {
1231 NLA_PUT_FLAG(skb, TEAM_ATTR_OPTION_CHANGED); 1267 NLA_PUT_FLAG(skb, TEAM_ATTR_OPTION_CHANGED);
1268 option->changed = false;
1269 }
1270 if (option->removed)
1271 NLA_PUT_FLAG(skb, TEAM_ATTR_OPTION_REMOVED);
1232 switch (option->type) { 1272 switch (option->type) {
1233 case TEAM_OPTION_TYPE_U32: 1273 case TEAM_OPTION_TYPE_U32:
1234 NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_U32); 1274 NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_U32);
@@ -1255,13 +1295,13 @@ nla_put_failure:
1255 return -EMSGSIZE; 1295 return -EMSGSIZE;
1256} 1296}
1257 1297
1258static int team_nl_fill_options_get(struct sk_buff *skb, 1298static int team_nl_fill_options_get_all(struct sk_buff *skb,
1259 struct genl_info *info, int flags, 1299 struct genl_info *info, int flags,
1260 struct team *team) 1300 struct team *team)
1261{ 1301{
1262 return team_nl_fill_options_get_changed(skb, info->snd_pid, 1302 return team_nl_fill_options_get(skb, info->snd_pid,
1263 info->snd_seq, NLM_F_ACK, 1303 info->snd_seq, NLM_F_ACK,
1264 team, NULL); 1304 team, true);
1265} 1305}
1266 1306
1267static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info) 1307static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info)
@@ -1273,7 +1313,7 @@ static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info)
1273 if (!team) 1313 if (!team)
1274 return -EINVAL; 1314 return -EINVAL;
1275 1315
1276 err = team_nl_send_generic(info, team, team_nl_fill_options_get); 1316 err = team_nl_send_generic(info, team, team_nl_fill_options_get_all);
1277 1317
1278 team_nl_team_put(team); 1318 team_nl_team_put(team);
1279 1319
@@ -1365,10 +1405,10 @@ team_put:
1365 return err; 1405 return err;
1366} 1406}
1367 1407
1368static int team_nl_fill_port_list_get_changed(struct sk_buff *skb, 1408static int team_nl_fill_port_list_get(struct sk_buff *skb,
1369 u32 pid, u32 seq, int flags, 1409 u32 pid, u32 seq, int flags,
1370 struct team *team, 1410 struct team *team,
1371 struct team_port *changed_port) 1411 bool fillall)
1372{ 1412{
1373 struct nlattr *port_list; 1413 struct nlattr *port_list;
1374 void *hdr; 1414 void *hdr;
@@ -1387,12 +1427,19 @@ static int team_nl_fill_port_list_get_changed(struct sk_buff *skb,
1387 list_for_each_entry(port, &team->port_list, list) { 1427 list_for_each_entry(port, &team->port_list, list) {
1388 struct nlattr *port_item; 1428 struct nlattr *port_item;
1389 1429
1430 /* Include only changed ports if fill all mode is not on */
1431 if (!fillall && !port->changed)
1432 continue;
1390 port_item = nla_nest_start(skb, TEAM_ATTR_ITEM_PORT); 1433 port_item = nla_nest_start(skb, TEAM_ATTR_ITEM_PORT);
1391 if (!port_item) 1434 if (!port_item)
1392 goto nla_put_failure; 1435 goto nla_put_failure;
1393 NLA_PUT_U32(skb, TEAM_ATTR_PORT_IFINDEX, port->dev->ifindex); 1436 NLA_PUT_U32(skb, TEAM_ATTR_PORT_IFINDEX, port->dev->ifindex);
1394 if (port == changed_port) 1437 if (port->changed) {
1395 NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_CHANGED); 1438 NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_CHANGED);
1439 port->changed = false;
1440 }
1441 if (port->removed)
1442 NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_REMOVED);
1396 if (port->linkup) 1443 if (port->linkup)
1397 NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_LINKUP); 1444 NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_LINKUP);
1398 NLA_PUT_U32(skb, TEAM_ATTR_PORT_SPEED, port->speed); 1445 NLA_PUT_U32(skb, TEAM_ATTR_PORT_SPEED, port->speed);
@@ -1408,13 +1455,13 @@ nla_put_failure:
1408 return -EMSGSIZE; 1455 return -EMSGSIZE;
1409} 1456}
1410 1457
1411static int team_nl_fill_port_list_get(struct sk_buff *skb, 1458static int team_nl_fill_port_list_get_all(struct sk_buff *skb,
1412 struct genl_info *info, int flags, 1459 struct genl_info *info, int flags,
1413 struct team *team) 1460 struct team *team)
1414{ 1461{
1415 return team_nl_fill_port_list_get_changed(skb, info->snd_pid, 1462 return team_nl_fill_port_list_get(skb, info->snd_pid,
1416 info->snd_seq, NLM_F_ACK, 1463 info->snd_seq, NLM_F_ACK,
1417 team, NULL); 1464 team, true);
1418} 1465}
1419 1466
1420static int team_nl_cmd_port_list_get(struct sk_buff *skb, 1467static int team_nl_cmd_port_list_get(struct sk_buff *skb,
@@ -1427,7 +1474,7 @@ static int team_nl_cmd_port_list_get(struct sk_buff *skb,
1427 if (!team) 1474 if (!team)
1428 return -EINVAL; 1475 return -EINVAL;
1429 1476
1430 err = team_nl_send_generic(info, team, team_nl_fill_port_list_get); 1477 err = team_nl_send_generic(info, team, team_nl_fill_port_list_get_all);
1431 1478
1432 team_nl_team_put(team); 1479 team_nl_team_put(team);
1433 1480
@@ -1464,8 +1511,7 @@ static struct genl_multicast_group team_change_event_mcgrp = {
1464 .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, 1511 .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME,
1465}; 1512};
1466 1513
1467static int team_nl_send_event_options_get(struct team *team, 1514static int team_nl_send_event_options_get(struct team *team)
1468 struct team_option *changed_option)
1469{ 1515{
1470 struct sk_buff *skb; 1516 struct sk_buff *skb;
1471 int err; 1517 int err;
@@ -1475,8 +1521,7 @@ static int team_nl_send_event_options_get(struct team *team,
1475 if (!skb) 1521 if (!skb)
1476 return -ENOMEM; 1522 return -ENOMEM;
1477 1523
1478 err = team_nl_fill_options_get_changed(skb, 0, 0, 0, team, 1524 err = team_nl_fill_options_get(skb, 0, 0, 0, team, false);
1479 changed_option);
1480 if (err < 0) 1525 if (err < 0)
1481 goto err_fill; 1526 goto err_fill;
1482 1527
@@ -1489,18 +1534,17 @@ err_fill:
1489 return err; 1534 return err;
1490} 1535}
1491 1536
1492static int team_nl_send_event_port_list_get(struct team_port *port) 1537static int team_nl_send_event_port_list_get(struct team *team)
1493{ 1538{
1494 struct sk_buff *skb; 1539 struct sk_buff *skb;
1495 int err; 1540 int err;
1496 struct net *net = dev_net(port->team->dev); 1541 struct net *net = dev_net(team->dev);
1497 1542
1498 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 1543 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1499 if (!skb) 1544 if (!skb)
1500 return -ENOMEM; 1545 return -ENOMEM;
1501 1546
1502 err = team_nl_fill_port_list_get_changed(skb, 0, 0, 0, 1547 err = team_nl_fill_port_list_get(skb, 0, 0, 0, team, false);
1503 port->team, port);
1504 if (err < 0) 1548 if (err < 0)
1505 goto err_fill; 1549 goto err_fill;
1506 1550
@@ -1544,12 +1588,11 @@ static void team_nl_fini(void)
1544 * Change checkers 1588 * Change checkers
1545 ******************/ 1589 ******************/
1546 1590
1547static void __team_options_change_check(struct team *team, 1591static void __team_options_change_check(struct team *team)
1548 struct team_option *changed_option)
1549{ 1592{
1550 int err; 1593 int err;
1551 1594
1552 err = team_nl_send_event_options_get(team, changed_option); 1595 err = team_nl_send_event_options_get(team);
1553 if (err) 1596 if (err)
1554 netdev_warn(team->dev, "Failed to send options change via netlink\n"); 1597 netdev_warn(team->dev, "Failed to send options change via netlink\n");
1555} 1598}
@@ -1559,9 +1602,10 @@ static void __team_port_change_check(struct team_port *port, bool linkup)
1559{ 1602{
1560 int err; 1603 int err;
1561 1604
1562 if (port->linkup == linkup) 1605 if (!port->removed && port->linkup == linkup)
1563 return; 1606 return;
1564 1607
1608 port->changed = true;
1565 port->linkup = linkup; 1609 port->linkup = linkup;
1566 if (linkup) { 1610 if (linkup) {
1567 struct ethtool_cmd ecmd; 1611 struct ethtool_cmd ecmd;
@@ -1577,7 +1621,7 @@ static void __team_port_change_check(struct team_port *port, bool linkup)
1577 port->duplex = 0; 1621 port->duplex = 0;
1578 1622
1579send_event: 1623send_event:
1580 err = team_nl_send_event_port_list_get(port); 1624 err = team_nl_send_event_port_list_get(port->team);
1581 if (err) 1625 if (err)
1582 netdev_warn(port->team->dev, "Failed to send port change of device %s via netlink\n", 1626 netdev_warn(port->team->dev, "Failed to send port change of device %s via netlink\n",
1583 port->dev->name); 1627 port->dev->name);
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index b97a40ed5fff..3876c7ea54f4 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -31,6 +31,12 @@ config B43_BCMA
31 depends on B43 && BCMA 31 depends on B43 && BCMA
32 default y 32 default y
33 33
34config B43_BCMA_EXTRA
35 bool "Hardware support that overlaps with the brcmsmac driver"
36 depends on B43_BCMA
37 default n if BRCMSMAC || BRCMSMAC_MODULE
38 default y
39
34config B43_SSB 40config B43_SSB
35 bool 41 bool
36 depends on B43 && SSB 42 depends on B43 && SSB
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index b91f28ef1032..23ffb1b9a86f 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -116,8 +116,10 @@ MODULE_PARM_DESC(pio, "Use PIO accesses by default: 0=DMA, 1=PIO");
116#ifdef CONFIG_B43_BCMA 116#ifdef CONFIG_B43_BCMA
117static const struct bcma_device_id b43_bcma_tbl[] = { 117static const struct bcma_device_id b43_bcma_tbl[] = {
118 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x11, BCMA_ANY_CLASS), 118 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x11, BCMA_ANY_CLASS),
119#ifdef CONFIG_B43_BCMA_EXTRA
119 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x17, BCMA_ANY_CLASS), 120 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x17, BCMA_ANY_CLASS),
120 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x18, BCMA_ANY_CLASS), 121 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x18, BCMA_ANY_CLASS),
122#endif
121 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x1D, BCMA_ANY_CLASS), 123 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x1D, BCMA_ANY_CLASS),
122 BCMA_CORETABLE_END 124 BCMA_CORETABLE_END
123}; 125};
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index f7ed34034f88..f6affc6fd12a 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -7981,13 +7981,21 @@ int brcms_c_get_curband(struct brcms_c_info *wlc)
7981 7981
7982void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop) 7982void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop)
7983{ 7983{
7984 int timeout = 20;
7985
7984 /* flush packet queue when requested */ 7986 /* flush packet queue when requested */
7985 if (drop) 7987 if (drop)
7986 brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL); 7988 brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL);
7987 7989
7988 /* wait for queue and DMA fifos to run dry */ 7990 /* wait for queue and DMA fifos to run dry */
7989 while (!pktq_empty(&wlc->pkt_queue->q) || brcms_txpktpendtot(wlc) > 0) 7991 while (!pktq_empty(&wlc->pkt_queue->q) || brcms_txpktpendtot(wlc) > 0) {
7990 brcms_msleep(wlc->wl, 1); 7992 brcms_msleep(wlc->wl, 1);
7993
7994 if (--timeout == 0)
7995 break;
7996 }
7997
7998 WARN_ON_ONCE(timeout == 0);
7991} 7999}
7992 8000
7993void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval) 8001void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval)
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
index 752493f00406..65d1f05007be 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
@@ -972,11 +972,11 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
972 } 972 }
973#endif 973#endif
974 974
975 spin_unlock_irqrestore(&trans->shrd->lock, flags);
976
977 /* saved interrupt in inta variable now we can reset trans_pcie->inta */ 975 /* saved interrupt in inta variable now we can reset trans_pcie->inta */
978 trans_pcie->inta = 0; 976 trans_pcie->inta = 0;
979 977
978 spin_unlock_irqrestore(&trans->shrd->lock, flags);
979
980 /* Now service all interrupt bits discovered above. */ 980 /* Now service all interrupt bits discovered above. */
981 if (inta & CSR_INT_BIT_HW_ERR) { 981 if (inta & CSR_INT_BIT_HW_ERR) {
982 IWL_ERR(trans, "Hardware error detected. Restarting.\n"); 982 IWL_ERR(trans, "Hardware error detected. Restarting.\n");
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index fa679057630f..698b905058dd 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -68,7 +68,7 @@ struct netfront_cb {
68 68
69#define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) 69#define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE)
70#define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) 70#define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE)
71#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256) 71#define TX_MAX_TARGET min_t(int, NET_TX_RING_SIZE, 256)
72 72
73struct netfront_stats { 73struct netfront_stats {
74 u64 rx_packets; 74 u64 rx_packets;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 97fff785e97e..af295bb21d62 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2802,7 +2802,7 @@ pci_intx(struct pci_dev *pdev, int enable)
2802 2802
2803/** 2803/**
2804 * pci_intx_mask_supported - probe for INTx masking support 2804 * pci_intx_mask_supported - probe for INTx masking support
2805 * @pdev: the PCI device to operate on 2805 * @dev: the PCI device to operate on
2806 * 2806 *
2807 * Check if the device dev support INTx masking via the config space 2807 * Check if the device dev support INTx masking via the config space
2808 * command word. 2808 * command word.
@@ -2884,7 +2884,7 @@ done:
2884 2884
2885/** 2885/**
2886 * pci_check_and_mask_intx - mask INTx on pending interrupt 2886 * pci_check_and_mask_intx - mask INTx on pending interrupt
2887 * @pdev: the PCI device to operate on 2887 * @dev: the PCI device to operate on
2888 * 2888 *
2889 * Check if the device dev has its INTx line asserted, mask it and 2889 * Check if the device dev has its INTx line asserted, mask it and
2890 * return true in that case. False is returned if not interrupt was 2890 * return true in that case. False is returned if not interrupt was
@@ -2898,7 +2898,7 @@ EXPORT_SYMBOL_GPL(pci_check_and_mask_intx);
2898 2898
2899/** 2899/**
2900 * pci_check_and_mask_intx - unmask INTx of no interrupt is pending 2900 * pci_check_and_mask_intx - unmask INTx of no interrupt is pending
2901 * @pdev: the PCI device to operate on 2901 * @dev: the PCI device to operate on
2902 * 2902 *
2903 * Check if the device dev has its INTx line asserted, unmask it if not 2903 * Check if the device dev has its INTx line asserted, unmask it if not
2904 * and return true. False is returned and the mask remains active if 2904 * and return true. False is returned and the mask remains active if
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
index 59866905ea37..27f2fe3b7fb4 100644
--- a/drivers/pcmcia/sa1111_generic.c
+++ b/drivers/pcmcia/sa1111_generic.c
@@ -205,7 +205,8 @@ static int __devexit pcmcia_remove(struct sa1111_dev *dev)
205 205
206 dev_set_drvdata(&dev->dev, NULL); 206 dev_set_drvdata(&dev->dev, NULL);
207 207
208 for (; next = s->next, s; s = next) { 208 for (; s; s = next) {
209 next = s->next;
209 soc_pcmcia_remove_one(&s->soc); 210 soc_pcmcia_remove_one(&s->soc);
210 kfree(s); 211 kfree(s);
211 } 212 }
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 569bdb3ef104..8fe15cf15ac8 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -510,10 +510,12 @@ static struct dentry *debugfs_root;
510 510
511static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) 511static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
512{ 512{
513 static struct dentry *device_root; 513 struct dentry *device_root;
514 514
515 device_root = debugfs_create_dir(dev_name(pctldev->dev), 515 device_root = debugfs_create_dir(dev_name(pctldev->dev),
516 debugfs_root); 516 debugfs_root);
517 pctldev->device_root = device_root;
518
517 if (IS_ERR(device_root) || !device_root) { 519 if (IS_ERR(device_root) || !device_root) {
518 pr_warn("failed to create debugfs directory for %s\n", 520 pr_warn("failed to create debugfs directory for %s\n",
519 dev_name(pctldev->dev)); 521 dev_name(pctldev->dev));
@@ -529,6 +531,11 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
529 pinconf_init_device_debugfs(device_root, pctldev); 531 pinconf_init_device_debugfs(device_root, pctldev);
530} 532}
531 533
534static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
535{
536 debugfs_remove_recursive(pctldev->device_root);
537}
538
532static void pinctrl_init_debugfs(void) 539static void pinctrl_init_debugfs(void)
533{ 540{
534 debugfs_root = debugfs_create_dir("pinctrl", NULL); 541 debugfs_root = debugfs_create_dir("pinctrl", NULL);
@@ -553,6 +560,10 @@ static void pinctrl_init_debugfs(void)
553{ 560{
554} 561}
555 562
563static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
564{
565}
566
556#endif 567#endif
557 568
558/** 569/**
@@ -572,40 +583,40 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
572 if (pctldesc->name == NULL) 583 if (pctldesc->name == NULL)
573 return NULL; 584 return NULL;
574 585
586 pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
587 if (pctldev == NULL)
588 return NULL;
589
590 /* Initialize pin control device struct */
591 pctldev->owner = pctldesc->owner;
592 pctldev->desc = pctldesc;
593 pctldev->driver_data = driver_data;
594 INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
595 spin_lock_init(&pctldev->pin_desc_tree_lock);
596 INIT_LIST_HEAD(&pctldev->gpio_ranges);
597 mutex_init(&pctldev->gpio_ranges_lock);
598 pctldev->dev = dev;
599
575 /* If we're implementing pinmuxing, check the ops for sanity */ 600 /* If we're implementing pinmuxing, check the ops for sanity */
576 if (pctldesc->pmxops) { 601 if (pctldesc->pmxops) {
577 ret = pinmux_check_ops(pctldesc->pmxops); 602 ret = pinmux_check_ops(pctldev);
578 if (ret) { 603 if (ret) {
579 pr_err("%s pinmux ops lacks necessary functions\n", 604 pr_err("%s pinmux ops lacks necessary functions\n",
580 pctldesc->name); 605 pctldesc->name);
581 return NULL; 606 goto out_err;
582 } 607 }
583 } 608 }
584 609
585 /* If we're implementing pinconfig, check the ops for sanity */ 610 /* If we're implementing pinconfig, check the ops for sanity */
586 if (pctldesc->confops) { 611 if (pctldesc->confops) {
587 ret = pinconf_check_ops(pctldesc->confops); 612 ret = pinconf_check_ops(pctldev);
588 if (ret) { 613 if (ret) {
589 pr_err("%s pin config ops lacks necessary functions\n", 614 pr_err("%s pin config ops lacks necessary functions\n",
590 pctldesc->name); 615 pctldesc->name);
591 return NULL; 616 goto out_err;
592 } 617 }
593 } 618 }
594 619
595 pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
596 if (pctldev == NULL)
597 return NULL;
598
599 /* Initialize pin control device struct */
600 pctldev->owner = pctldesc->owner;
601 pctldev->desc = pctldesc;
602 pctldev->driver_data = driver_data;
603 INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
604 spin_lock_init(&pctldev->pin_desc_tree_lock);
605 INIT_LIST_HEAD(&pctldev->gpio_ranges);
606 mutex_init(&pctldev->gpio_ranges_lock);
607 pctldev->dev = dev;
608
609 /* Register all the pins */ 620 /* Register all the pins */
610 pr_debug("try to register %d pins on %s...\n", 621 pr_debug("try to register %d pins on %s...\n",
611 pctldesc->npins, pctldesc->name); 622 pctldesc->npins, pctldesc->name);
@@ -641,6 +652,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
641 if (pctldev == NULL) 652 if (pctldev == NULL)
642 return; 653 return;
643 654
655 pinctrl_remove_device_debugfs(pctldev);
644 pinmux_unhog_maps(pctldev); 656 pinmux_unhog_maps(pctldev);
645 /* TODO: check that no pinmuxes are still active? */ 657 /* TODO: check that no pinmuxes are still active? */
646 mutex_lock(&pinctrldev_list_mutex); 658 mutex_lock(&pinctrldev_list_mutex);
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 177a3310547f..cfa86da6b4b1 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -41,6 +41,9 @@ struct pinctrl_dev {
41 struct device *dev; 41 struct device *dev;
42 struct module *owner; 42 struct module *owner;
43 void *driver_data; 43 void *driver_data;
44#ifdef CONFIG_DEBUG_FS
45 struct dentry *device_root;
46#endif
44#ifdef CONFIG_PINMUX 47#ifdef CONFIG_PINMUX
45 struct mutex pinmux_hogs_lock; 48 struct mutex pinmux_hogs_lock;
46 struct list_head pinmux_hogs; 49 struct list_head pinmux_hogs;
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index 1259872b0a1d..9fb75456824c 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -205,8 +205,10 @@ int pin_config_group_set(const char *dev_name, const char *pin_group,
205} 205}
206EXPORT_SYMBOL(pin_config_group_set); 206EXPORT_SYMBOL(pin_config_group_set);
207 207
208int pinconf_check_ops(const struct pinconf_ops *ops) 208int pinconf_check_ops(struct pinctrl_dev *pctldev)
209{ 209{
210 const struct pinconf_ops *ops = pctldev->desc->confops;
211
210 /* We must be able to read out pin status */ 212 /* We must be able to read out pin status */
211 if (!ops->pin_config_get && !ops->pin_config_group_get) 213 if (!ops->pin_config_get && !ops->pin_config_group_get)
212 return -EINVAL; 214 return -EINVAL;
@@ -236,7 +238,7 @@ static int pinconf_pins_show(struct seq_file *s, void *what)
236 seq_puts(s, "Format: pin (name): pinmux setting array\n"); 238 seq_puts(s, "Format: pin (name): pinmux setting array\n");
237 239
238 /* The pin number can be retrived from the pin controller descriptor */ 240 /* The pin number can be retrived from the pin controller descriptor */
239 for (i = 0; pin < pctldev->desc->npins; i++) { 241 for (i = 0; i < pctldev->desc->npins; i++) {
240 struct pin_desc *desc; 242 struct pin_desc *desc;
241 243
242 pin = pctldev->desc->pins[i].number; 244 pin = pctldev->desc->pins[i].number;
diff --git a/drivers/pinctrl/pinconf.h b/drivers/pinctrl/pinconf.h
index e7dc6165032a..006b77fa737e 100644
--- a/drivers/pinctrl/pinconf.h
+++ b/drivers/pinctrl/pinconf.h
@@ -13,7 +13,7 @@
13 13
14#ifdef CONFIG_PINCONF 14#ifdef CONFIG_PINCONF
15 15
16int pinconf_check_ops(const struct pinconf_ops *ops); 16int pinconf_check_ops(struct pinctrl_dev *pctldev);
17void pinconf_init_device_debugfs(struct dentry *devroot, 17void pinconf_init_device_debugfs(struct dentry *devroot,
18 struct pinctrl_dev *pctldev); 18 struct pinctrl_dev *pctldev);
19int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin, 19int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
@@ -23,7 +23,7 @@ int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
23 23
24#else 24#else
25 25
26static inline int pinconf_check_ops(const struct pinconf_ops *ops) 26static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
27{ 27{
28 return 0; 28 return 0;
29} 29}
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index a76a348321bb..7c3193f7a044 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -53,11 +53,6 @@ struct pinmux_group {
53 * @dev: the device using this pinmux 53 * @dev: the device using this pinmux
54 * @usecount: the number of active users of this mux setting, used to keep 54 * @usecount: the number of active users of this mux setting, used to keep
55 * track of nested use cases 55 * track of nested use cases
56 * @pins: an array of discrete physical pins used in this mapping, taken
57 * from the global pin enumeration space (copied from pinmux map)
58 * @num_pins: the number of pins in this mapping array, i.e. the number of
59 * elements in .pins so we can iterate over that array (copied from
60 * pinmux map)
61 * @pctldev: pin control device handling this pinmux 56 * @pctldev: pin control device handling this pinmux
62 * @func_selector: the function selector for the pinmux device handling 57 * @func_selector: the function selector for the pinmux device handling
63 * this pinmux 58 * this pinmux
@@ -152,8 +147,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
152 status = 0; 147 status = 0;
153 148
154 if (status) 149 if (status)
155 dev_err(pctldev->dev, "->request on device %s failed " 150 dev_err(pctldev->dev, "->request on device %s failed for pin %d\n",
156 "for pin %d\n",
157 pctldev->desc->name, pin); 151 pctldev->desc->name, pin);
158out_free_pin: 152out_free_pin:
159 if (status) { 153 if (status) {
@@ -355,21 +349,20 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
355 /* First sanity check the new mapping */ 349 /* First sanity check the new mapping */
356 for (i = 0; i < num_maps; i++) { 350 for (i = 0; i < num_maps; i++) {
357 if (!maps[i].name) { 351 if (!maps[i].name) {
358 pr_err("failed to register map %d: " 352 pr_err("failed to register map %d: no map name given\n",
359 "no map name given\n", i); 353 i);
360 return -EINVAL; 354 return -EINVAL;
361 } 355 }
362 356
363 if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) { 357 if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) {
364 pr_err("failed to register map %s (%d): " 358 pr_err("failed to register map %s (%d): no pin control device given\n",
365 "no pin control device given\n",
366 maps[i].name, i); 359 maps[i].name, i);
367 return -EINVAL; 360 return -EINVAL;
368 } 361 }
369 362
370 if (!maps[i].function) { 363 if (!maps[i].function) {
371 pr_err("failed to register map %s (%d): " 364 pr_err("failed to register map %s (%d): no function ID given\n",
372 "no function ID given\n", maps[i].name, i); 365 maps[i].name, i);
373 return -EINVAL; 366 return -EINVAL;
374 } 367 }
375 368
@@ -411,7 +404,7 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
411} 404}
412 405
413/** 406/**
414 * acquire_pins() - acquire all the pins for a certain funcion on a pinmux 407 * acquire_pins() - acquire all the pins for a certain function on a pinmux
415 * @pctldev: the device to take the pins on 408 * @pctldev: the device to take the pins on
416 * @func_selector: the function selector to acquire the pins for 409 * @func_selector: the function selector to acquire the pins for
417 * @group_selector: the group selector containing the pins to acquire 410 * @group_selector: the group selector containing the pins to acquire
@@ -442,8 +435,7 @@ static int acquire_pins(struct pinctrl_dev *pctldev,
442 ret = pin_request(pctldev, pins[i], func, NULL); 435 ret = pin_request(pctldev, pins[i], func, NULL);
443 if (ret) { 436 if (ret) {
444 dev_err(pctldev->dev, 437 dev_err(pctldev->dev,
445 "could not get pin %d for function %s " 438 "could not get pin %d for function %s on device %s - conflicting mux mappings?\n",
446 "on device %s - conflicting mux mappings?\n",
447 pins[i], func ? : "(undefined)", 439 pins[i], func ? : "(undefined)",
448 pinctrl_dev_get_name(pctldev)); 440 pinctrl_dev_get_name(pctldev));
449 /* On error release all taken pins */ 441 /* On error release all taken pins */
@@ -458,7 +450,7 @@ static int acquire_pins(struct pinctrl_dev *pctldev,
458 450
459/** 451/**
460 * release_pins() - release pins taken by earlier acquirement 452 * release_pins() - release pins taken by earlier acquirement
461 * @pctldev: the device to free the pinx on 453 * @pctldev: the device to free the pins on
462 * @group_selector: the group selector containing the pins to free 454 * @group_selector: the group selector containing the pins to free
463 */ 455 */
464static void release_pins(struct pinctrl_dev *pctldev, 456static void release_pins(struct pinctrl_dev *pctldev,
@@ -473,8 +465,7 @@ static void release_pins(struct pinctrl_dev *pctldev,
473 ret = pctlops->get_group_pins(pctldev, group_selector, 465 ret = pctlops->get_group_pins(pctldev, group_selector,
474 &pins, &num_pins); 466 &pins, &num_pins);
475 if (ret) { 467 if (ret) {
476 dev_err(pctldev->dev, "could not get pins to release for " 468 dev_err(pctldev->dev, "could not get pins to release for group selector %d\n",
477 "group selector %d\n",
478 group_selector); 469 group_selector);
479 return; 470 return;
480 } 471 }
@@ -526,8 +517,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
526 ret = pinctrl_get_group_selector(pctldev, groups[0]); 517 ret = pinctrl_get_group_selector(pctldev, groups[0]);
527 if (ret < 0) { 518 if (ret < 0) {
528 dev_err(pctldev->dev, 519 dev_err(pctldev->dev,
529 "function %s wants group %s but the pin " 520 "function %s wants group %s but the pin controller does not seem to have that group\n",
530 "controller does not seem to have that group\n",
531 pmxops->get_function_name(pctldev, func_selector), 521 pmxops->get_function_name(pctldev, func_selector),
532 groups[0]); 522 groups[0]);
533 return ret; 523 return ret;
@@ -535,8 +525,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
535 525
536 if (num_groups > 1) 526 if (num_groups > 1)
537 dev_dbg(pctldev->dev, 527 dev_dbg(pctldev->dev,
538 "function %s support more than one group, " 528 "function %s support more than one group, default-selecting first group %s (%d)\n",
539 "default-selecting first group %s (%d)\n",
540 pmxops->get_function_name(pctldev, func_selector), 529 pmxops->get_function_name(pctldev, func_selector),
541 groups[0], 530 groups[0],
542 ret); 531 ret);
@@ -628,10 +617,8 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
628 617
629 if (pmx->pctldev && pmx->pctldev != pctldev) { 618 if (pmx->pctldev && pmx->pctldev != pctldev) {
630 dev_err(pctldev->dev, 619 dev_err(pctldev->dev,
631 "different pin control devices given for device %s, " 620 "different pin control devices given for device %s, function %s\n",
632 "function %s\n", 621 devname, map->function);
633 devname,
634 map->function);
635 return -EINVAL; 622 return -EINVAL;
636 } 623 }
637 pmx->dev = dev; 624 pmx->dev = dev;
@@ -695,7 +682,6 @@ static void pinmux_free_groups(struct pinmux *pmx)
695 */ 682 */
696struct pinmux *pinmux_get(struct device *dev, const char *name) 683struct pinmux *pinmux_get(struct device *dev, const char *name)
697{ 684{
698
699 struct pinmux_map const *map = NULL; 685 struct pinmux_map const *map = NULL;
700 struct pinctrl_dev *pctldev = NULL; 686 struct pinctrl_dev *pctldev = NULL;
701 const char *devname = NULL; 687 const char *devname = NULL;
@@ -745,8 +731,7 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
745 else if (map->ctrl_dev_name) 731 else if (map->ctrl_dev_name)
746 devname = map->ctrl_dev_name; 732 devname = map->ctrl_dev_name;
747 733
748 pr_warning("could not find a pinctrl device for pinmux " 734 pr_warning("could not find a pinctrl device for pinmux function %s, fishy, they shall all have one\n",
749 "function %s, fishy, they shall all have one\n",
750 map->function); 735 map->function);
751 pr_warning("given pinctrl device name: %s", 736 pr_warning("given pinctrl device name: %s",
752 devname ? devname : "UNDEFINED"); 737 devname ? devname : "UNDEFINED");
@@ -904,8 +889,11 @@ void pinmux_disable(struct pinmux *pmx)
904} 889}
905EXPORT_SYMBOL_GPL(pinmux_disable); 890EXPORT_SYMBOL_GPL(pinmux_disable);
906 891
907int pinmux_check_ops(const struct pinmux_ops *ops) 892int pinmux_check_ops(struct pinctrl_dev *pctldev)
908{ 893{
894 const struct pinmux_ops *ops = pctldev->desc->pmxops;
895 unsigned selector = 0;
896
909 /* Check that we implement required operations */ 897 /* Check that we implement required operations */
910 if (!ops->list_functions || 898 if (!ops->list_functions ||
911 !ops->get_function_name || 899 !ops->get_function_name ||
@@ -914,6 +902,18 @@ int pinmux_check_ops(const struct pinmux_ops *ops)
914 !ops->disable) 902 !ops->disable)
915 return -EINVAL; 903 return -EINVAL;
916 904
905 /* Check that all functions registered have names */
906 while (ops->list_functions(pctldev, selector) >= 0) {
907 const char *fname = ops->get_function_name(pctldev,
908 selector);
909 if (!fname) {
910 pr_err("pinmux ops has no name for function%u\n",
911 selector);
912 return -EINVAL;
913 }
914 selector++;
915 }
916
917 return 0; 917 return 0;
918} 918}
919 919
@@ -932,8 +932,8 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
932 * without any problems, so then we can hog pinmuxes for 932 * without any problems, so then we can hog pinmuxes for
933 * all devices that just want a static pin mux at this point. 933 * all devices that just want a static pin mux at this point.
934 */ 934 */
935 dev_err(pctldev->dev, "map %s wants to hog a non-system " 935 dev_err(pctldev->dev, "map %s wants to hog a non-system pinmux, this is not going to work\n",
936 "pinmux, this is not going to work\n", map->name); 936 map->name);
937 return -EINVAL; 937 return -EINVAL;
938 } 938 }
939 939
@@ -993,9 +993,12 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
993 for (i = 0; i < pinmux_maps_num; i++) { 993 for (i = 0; i < pinmux_maps_num; i++) {
994 struct pinmux_map const *map = &pinmux_maps[i]; 994 struct pinmux_map const *map = &pinmux_maps[i];
995 995
996 if (((map->ctrl_dev == dev) || 996 if (!map->hog_on_boot)
997 !strcmp(map->ctrl_dev_name, devname)) && 997 continue;
998 map->hog_on_boot) { 998
999 if ((map->ctrl_dev == dev) ||
1000 (map->ctrl_dev_name &&
1001 !strcmp(map->ctrl_dev_name, devname))) {
999 /* OK time to hog! */ 1002 /* OK time to hog! */
1000 ret = pinmux_hog_map(pctldev, map); 1003 ret = pinmux_hog_map(pctldev, map);
1001 if (ret) 1004 if (ret)
@@ -1122,13 +1125,15 @@ static int pinmux_show(struct seq_file *s, void *what)
1122 1125
1123 seq_printf(s, "device: %s function: %s (%u),", 1126 seq_printf(s, "device: %s function: %s (%u),",
1124 pinctrl_dev_get_name(pmx->pctldev), 1127 pinctrl_dev_get_name(pmx->pctldev),
1125 pmxops->get_function_name(pctldev, pmx->func_selector), 1128 pmxops->get_function_name(pctldev,
1129 pmx->func_selector),
1126 pmx->func_selector); 1130 pmx->func_selector);
1127 1131
1128 seq_printf(s, " groups: ["); 1132 seq_printf(s, " groups: [");
1129 list_for_each_entry(grp, &pmx->groups, node) { 1133 list_for_each_entry(grp, &pmx->groups, node) {
1130 seq_printf(s, " %s (%u)", 1134 seq_printf(s, " %s (%u)",
1131 pctlops->get_group_name(pctldev, grp->group_selector), 1135 pctlops->get_group_name(pctldev,
1136 grp->group_selector),
1132 grp->group_selector); 1137 grp->group_selector);
1133 } 1138 }
1134 seq_printf(s, " ]"); 1139 seq_printf(s, " ]");
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 844500b3331b..97f52223fbc2 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -12,7 +12,7 @@
12 */ 12 */
13#ifdef CONFIG_PINMUX 13#ifdef CONFIG_PINMUX
14 14
15int pinmux_check_ops(const struct pinmux_ops *ops); 15int pinmux_check_ops(struct pinctrl_dev *pctldev);
16void pinmux_init_device_debugfs(struct dentry *devroot, 16void pinmux_init_device_debugfs(struct dentry *devroot,
17 struct pinctrl_dev *pctldev); 17 struct pinctrl_dev *pctldev);
18void pinmux_init_debugfs(struct dentry *subsys_root); 18void pinmux_init_debugfs(struct dentry *subsys_root);
@@ -21,7 +21,7 @@ void pinmux_unhog_maps(struct pinctrl_dev *pctldev);
21 21
22#else 22#else
23 23
24static inline int pinmux_check_ops(const struct pinmux_ops *ops) 24static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
25{ 25{
26 return 0; 26 return 0;
27} 27}
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ca86f39a0fdc..e9a83f84adaf 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2731,6 +2731,8 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
2731 * @dev: struct device for the regulator 2731 * @dev: struct device for the regulator
2732 * @init_data: platform provided init data, passed through by driver 2732 * @init_data: platform provided init data, passed through by driver
2733 * @driver_data: private regulator data 2733 * @driver_data: private regulator data
2734 * @of_node: OpenFirmware node to parse for device tree bindings (may be
2735 * NULL).
2734 * 2736 *
2735 * Called by regulator drivers to register a regulator. 2737 * Called by regulator drivers to register a regulator.
2736 * Returns 0 on success. 2738 * Returns 0 on success.
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index f1651eb69648..679734d26a16 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -35,7 +35,7 @@ static void of_get_regulation_constraints(struct device_node *np,
35 if (constraints->min_uV != constraints->max_uV) 35 if (constraints->min_uV != constraints->max_uV)
36 constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE; 36 constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
37 /* Only one voltage? Then make sure it's set. */ 37 /* Only one voltage? Then make sure it's set. */
38 if (constraints->min_uV == constraints->max_uV) 38 if (min_uV && max_uV && constraints->min_uV == constraints->max_uV)
39 constraints->apply_uV = true; 39 constraints->apply_uV = true;
40 40
41 uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL); 41 uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL);
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index e19a4031f45e..3a125b835546 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -774,7 +774,7 @@ config RTC_DRV_EP93XX
774 774
775config RTC_DRV_SA1100 775config RTC_DRV_SA1100
776 tristate "SA11x0/PXA2xx" 776 tristate "SA11x0/PXA2xx"
777 depends on ARCH_SA1100 || ARCH_PXA || ARCH_MMP 777 depends on ARCH_SA1100 || ARCH_PXA
778 help 778 help
779 If you say Y here you will get access to the real time clock 779 If you say Y here you will get access to the real time clock
780 built into your SA11x0 or PXA2xx CPU. 780 built into your SA11x0 or PXA2xx CPU.
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 4595d3e645a7..cb9a585312cc 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -27,42 +27,34 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/fs.h> 28#include <linux/fs.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/string.h>
30#include <linux/pm.h> 31#include <linux/pm.h>
31#include <linux/slab.h> 32#include <linux/bitops.h>
32#include <linux/clk.h>
33#include <linux/io.h>
34 33
35#include <mach/hardware.h> 34#include <mach/hardware.h>
36#include <asm/irq.h> 35#include <asm/irq.h>
37 36
37#ifdef CONFIG_ARCH_PXA
38#include <mach/regs-rtc.h>
39#endif
40
38#define RTC_DEF_DIVIDER (32768 - 1) 41#define RTC_DEF_DIVIDER (32768 - 1)
39#define RTC_DEF_TRIM 0 42#define RTC_DEF_TRIM 0
40#define RTC_FREQ 1024 43
41 44static const unsigned long RTC_FREQ = 1024;
42#define RCNR 0x00 /* RTC Count Register */ 45static struct rtc_time rtc_alarm;
43#define RTAR 0x04 /* RTC Alarm Register */ 46static DEFINE_SPINLOCK(sa1100_rtc_lock);
44#define RTSR 0x08 /* RTC Status Register */ 47
45#define RTTR 0x0c /* RTC Timer Trim Register */ 48static inline int rtc_periodic_alarm(struct rtc_time *tm)
46 49{
47#define RTSR_HZE (1 << 3) /* HZ interrupt enable */ 50 return (tm->tm_year == -1) ||
48#define RTSR_ALE (1 << 2) /* RTC alarm interrupt enable */ 51 ((unsigned)tm->tm_mon >= 12) ||
49#define RTSR_HZ (1 << 1) /* HZ rising-edge detected */ 52 ((unsigned)(tm->tm_mday - 1) >= 31) ||
50#define RTSR_AL (1 << 0) /* RTC alarm detected */ 53 ((unsigned)tm->tm_hour > 23) ||
51 54 ((unsigned)tm->tm_min > 59) ||
52#define rtc_readl(sa1100_rtc, reg) \ 55 ((unsigned)tm->tm_sec > 59);
53 readl_relaxed((sa1100_rtc)->base + (reg)) 56}
54#define rtc_writel(sa1100_rtc, reg, value) \ 57
55 writel_relaxed((value), (sa1100_rtc)->base + (reg))
56
57struct sa1100_rtc {
58 struct resource *ress;
59 void __iomem *base;
60 struct clk *clk;
61 int irq_1Hz;
62 int irq_Alrm;
63 struct rtc_device *rtc;
64 spinlock_t lock; /* Protects this structure */
65};
66/* 58/*
67 * Calculate the next alarm time given the requested alarm time mask 59 * Calculate the next alarm time given the requested alarm time mask
68 * and the current time. 60 * and the current time.
@@ -90,26 +82,46 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
90 } 82 }
91} 83}
92 84
85static int rtc_update_alarm(struct rtc_time *alrm)
86{
87 struct rtc_time alarm_tm, now_tm;
88 unsigned long now, time;
89 int ret;
90
91 do {
92 now = RCNR;
93 rtc_time_to_tm(now, &now_tm);
94 rtc_next_alarm_time(&alarm_tm, &now_tm, alrm);
95 ret = rtc_tm_to_time(&alarm_tm, &time);
96 if (ret != 0)
97 break;
98
99 RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
100 RTAR = time;
101 } while (now != RCNR);
102
103 return ret;
104}
105
93static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) 106static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
94{ 107{
95 struct platform_device *pdev = to_platform_device(dev_id); 108 struct platform_device *pdev = to_platform_device(dev_id);
96 struct sa1100_rtc *sa1100_rtc = platform_get_drvdata(pdev); 109 struct rtc_device *rtc = platform_get_drvdata(pdev);
97 unsigned int rtsr; 110 unsigned int rtsr;
98 unsigned long events = 0; 111 unsigned long events = 0;
99 112
100 spin_lock(&sa1100_rtc->lock); 113 spin_lock(&sa1100_rtc_lock);
101 114
115 rtsr = RTSR;
102 /* clear interrupt sources */ 116 /* clear interrupt sources */
103 rtsr = rtc_readl(sa1100_rtc, RTSR); 117 RTSR = 0;
104 rtc_writel(sa1100_rtc, RTSR, 0);
105
106 /* Fix for a nasty initialization problem the in SA11xx RTSR register. 118 /* Fix for a nasty initialization problem the in SA11xx RTSR register.
107 * See also the comments in sa1100_rtc_probe(). */ 119 * See also the comments in sa1100_rtc_probe(). */
108 if (rtsr & (RTSR_ALE | RTSR_HZE)) { 120 if (rtsr & (RTSR_ALE | RTSR_HZE)) {
109 /* This is the original code, before there was the if test 121 /* This is the original code, before there was the if test
110 * above. This code does not clear interrupts that were not 122 * above. This code does not clear interrupts that were not
111 * enabled. */ 123 * enabled. */
112 rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ) & (rtsr >> 2)); 124 RTSR = (RTSR_AL | RTSR_HZ) & (rtsr >> 2);
113 } else { 125 } else {
114 /* For some reason, it is possible to enter this routine 126 /* For some reason, it is possible to enter this routine
115 * without interruptions enabled, it has been tested with 127 * without interruptions enabled, it has been tested with
@@ -118,13 +130,13 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
118 * This situation leads to an infinite "loop" of interrupt 130 * This situation leads to an infinite "loop" of interrupt
119 * routine calling and as a result the processor seems to 131 * routine calling and as a result the processor seems to
120 * lock on its first call to open(). */ 132 * lock on its first call to open(). */
121 rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ)); 133 RTSR = RTSR_AL | RTSR_HZ;
122 } 134 }
123 135
124 /* clear alarm interrupt if it has occurred */ 136 /* clear alarm interrupt if it has occurred */
125 if (rtsr & RTSR_AL) 137 if (rtsr & RTSR_AL)
126 rtsr &= ~RTSR_ALE; 138 rtsr &= ~RTSR_ALE;
127 rtc_writel(sa1100_rtc, RTSR, rtsr & (RTSR_ALE | RTSR_HZE)); 139 RTSR = rtsr & (RTSR_ALE | RTSR_HZE);
128 140
129 /* update irq data & counter */ 141 /* update irq data & counter */
130 if (rtsr & RTSR_AL) 142 if (rtsr & RTSR_AL)
@@ -132,100 +144,89 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
132 if (rtsr & RTSR_HZ) 144 if (rtsr & RTSR_HZ)
133 events |= RTC_UF | RTC_IRQF; 145 events |= RTC_UF | RTC_IRQF;
134 146
135 rtc_update_irq(sa1100_rtc->rtc, 1, events); 147 rtc_update_irq(rtc, 1, events);
136 148
137 spin_unlock(&sa1100_rtc->lock); 149 if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm))
150 rtc_update_alarm(&rtc_alarm);
151
152 spin_unlock(&sa1100_rtc_lock);
138 153
139 return IRQ_HANDLED; 154 return IRQ_HANDLED;
140} 155}
141 156
142static int sa1100_rtc_open(struct device *dev) 157static int sa1100_rtc_open(struct device *dev)
143{ 158{
144 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
145 int ret; 159 int ret;
160 struct platform_device *plat_dev = to_platform_device(dev);
161 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
146 162
147 ret = request_irq(sa1100_rtc->irq_1Hz, sa1100_rtc_interrupt, 163 ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED,
148 IRQF_DISABLED, "rtc 1Hz", dev); 164 "rtc 1Hz", dev);
149 if (ret) { 165 if (ret) {
150 dev_err(dev, "IRQ %d already in use.\n", sa1100_rtc->irq_1Hz); 166 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz);
151 goto fail_ui; 167 goto fail_ui;
152 } 168 }
153 ret = request_irq(sa1100_rtc->irq_Alrm, sa1100_rtc_interrupt, 169 ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, IRQF_DISABLED,
154 IRQF_DISABLED, "rtc Alrm", dev); 170 "rtc Alrm", dev);
155 if (ret) { 171 if (ret) {
156 dev_err(dev, "IRQ %d already in use.\n", sa1100_rtc->irq_Alrm); 172 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm);
157 goto fail_ai; 173 goto fail_ai;
158 } 174 }
159 sa1100_rtc->rtc->max_user_freq = RTC_FREQ; 175 rtc->max_user_freq = RTC_FREQ;
160 rtc_irq_set_freq(sa1100_rtc->rtc, NULL, RTC_FREQ); 176 rtc_irq_set_freq(rtc, NULL, RTC_FREQ);
161 177
162 return 0; 178 return 0;
163 179
164 fail_ai: 180 fail_ai:
165 free_irq(sa1100_rtc->irq_1Hz, dev); 181 free_irq(IRQ_RTC1Hz, dev);
166 fail_ui: 182 fail_ui:
167 return ret; 183 return ret;
168} 184}
169 185
170static void sa1100_rtc_release(struct device *dev) 186static void sa1100_rtc_release(struct device *dev)
171{ 187{
172 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 188 spin_lock_irq(&sa1100_rtc_lock);
173 189 RTSR = 0;
174 spin_lock_irq(&sa1100_rtc->lock); 190 spin_unlock_irq(&sa1100_rtc_lock);
175 rtc_writel(sa1100_rtc, RTSR, 0);
176 spin_unlock_irq(&sa1100_rtc->lock);
177 191
178 free_irq(sa1100_rtc->irq_Alrm, dev); 192 free_irq(IRQ_RTCAlrm, dev);
179 free_irq(sa1100_rtc->irq_1Hz, dev); 193 free_irq(IRQ_RTC1Hz, dev);
180} 194}
181 195
182static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) 196static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
183{ 197{
184 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 198 spin_lock_irq(&sa1100_rtc_lock);
185 unsigned int rtsr;
186
187 spin_lock_irq(&sa1100_rtc->lock);
188
189 rtsr = rtc_readl(sa1100_rtc, RTSR);
190 if (enabled) 199 if (enabled)
191 rtsr |= RTSR_ALE; 200 RTSR |= RTSR_ALE;
192 else 201 else
193 rtsr &= ~RTSR_ALE; 202 RTSR &= ~RTSR_ALE;
194 rtc_writel(sa1100_rtc, RTSR, rtsr); 203 spin_unlock_irq(&sa1100_rtc_lock);
195
196 spin_unlock_irq(&sa1100_rtc->lock);
197 return 0; 204 return 0;
198} 205}
199 206
200static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) 207static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
201{ 208{
202 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 209 rtc_time_to_tm(RCNR, tm);
203
204 rtc_time_to_tm(rtc_readl(sa1100_rtc, RCNR), tm);
205 return 0; 210 return 0;
206} 211}
207 212
208static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) 213static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
209{ 214{
210 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
211 unsigned long time; 215 unsigned long time;
212 int ret; 216 int ret;
213 217
214 ret = rtc_tm_to_time(tm, &time); 218 ret = rtc_tm_to_time(tm, &time);
215 if (ret == 0) 219 if (ret == 0)
216 rtc_writel(sa1100_rtc, RCNR, time); 220 RCNR = time;
217 return ret; 221 return ret;
218} 222}
219 223
220static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 224static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
221{ 225{
222 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 226 u32 rtsr;
223 unsigned long time;
224 unsigned int rtsr;
225 227
226 time = rtc_readl(sa1100_rtc, RCNR); 228 memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time));
227 rtc_time_to_tm(time, &alrm->time); 229 rtsr = RTSR;
228 rtsr = rtc_readl(sa1100_rtc, RTSR);
229 alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; 230 alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0;
230 alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; 231 alrm->pending = (rtsr & RTSR_AL) ? 1 : 0;
231 return 0; 232 return 0;
@@ -233,39 +234,26 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
233 234
234static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 235static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
235{ 236{
236 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 237 int ret;
237 struct rtc_time now_tm, alarm_tm;
238 unsigned long time, alarm;
239 unsigned int rtsr;
240
241 spin_lock_irq(&sa1100_rtc->lock);
242
243 time = rtc_readl(sa1100_rtc, RCNR);
244 rtc_time_to_tm(time, &now_tm);
245 rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
246 rtc_tm_to_time(&alarm_tm, &alarm);
247 rtc_writel(sa1100_rtc, RTAR, alarm);
248
249 rtsr = rtc_readl(sa1100_rtc, RTSR);
250 if (alrm->enabled)
251 rtsr |= RTSR_ALE;
252 else
253 rtsr &= ~RTSR_ALE;
254 rtc_writel(sa1100_rtc, RTSR, rtsr);
255 238
256 spin_unlock_irq(&sa1100_rtc->lock); 239 spin_lock_irq(&sa1100_rtc_lock);
240 ret = rtc_update_alarm(&alrm->time);
241 if (ret == 0) {
242 if (alrm->enabled)
243 RTSR |= RTSR_ALE;
244 else
245 RTSR &= ~RTSR_ALE;
246 }
247 spin_unlock_irq(&sa1100_rtc_lock);
257 248
258 return 0; 249 return ret;
259} 250}
260 251
261static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) 252static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
262{ 253{
263 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 254 seq_printf(seq, "trim/divider\t\t: 0x%08x\n", (u32) RTTR);
255 seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", (u32)RTSR);
264 256
265 seq_printf(seq, "trim/divider\t\t: 0x%08x\n",
266 rtc_readl(sa1100_rtc, RTTR));
267 seq_printf(seq, "RTSR\t\t\t: 0x%08x\n",
268 rtc_readl(sa1100_rtc, RTSR));
269 return 0; 257 return 0;
270} 258}
271 259
@@ -282,51 +270,7 @@ static const struct rtc_class_ops sa1100_rtc_ops = {
282 270
283static int sa1100_rtc_probe(struct platform_device *pdev) 271static int sa1100_rtc_probe(struct platform_device *pdev)
284{ 272{
285 struct sa1100_rtc *sa1100_rtc; 273 struct rtc_device *rtc;
286 unsigned int rttr;
287 int ret;
288
289 sa1100_rtc = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL);
290 if (!sa1100_rtc)
291 return -ENOMEM;
292
293 spin_lock_init(&sa1100_rtc->lock);
294 platform_set_drvdata(pdev, sa1100_rtc);
295
296 ret = -ENXIO;
297 sa1100_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
298 if (!sa1100_rtc->ress) {
299 dev_err(&pdev->dev, "No I/O memory resource defined\n");
300 goto err_ress;
301 }
302
303 sa1100_rtc->irq_1Hz = platform_get_irq(pdev, 0);
304 if (sa1100_rtc->irq_1Hz < 0) {
305 dev_err(&pdev->dev, "No 1Hz IRQ resource defined\n");
306 goto err_ress;
307 }
308 sa1100_rtc->irq_Alrm = platform_get_irq(pdev, 1);
309 if (sa1100_rtc->irq_Alrm < 0) {
310 dev_err(&pdev->dev, "No alarm IRQ resource defined\n");
311 goto err_ress;
312 }
313
314 ret = -ENOMEM;
315 sa1100_rtc->base = ioremap(sa1100_rtc->ress->start,
316 resource_size(sa1100_rtc->ress));
317 if (!sa1100_rtc->base) {
318 dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n");
319 goto err_map;
320 }
321
322 sa1100_rtc->clk = clk_get(&pdev->dev, NULL);
323 if (IS_ERR(sa1100_rtc->clk)) {
324 dev_err(&pdev->dev, "failed to find rtc clock source\n");
325 ret = PTR_ERR(sa1100_rtc->clk);
326 goto err_clk;
327 }
328 clk_prepare(sa1100_rtc->clk);
329 clk_enable(sa1100_rtc->clk);
330 274
331 /* 275 /*
332 * According to the manual we should be able to let RTTR be zero 276 * According to the manual we should be able to let RTTR be zero
@@ -335,24 +279,24 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
335 * If the clock divider is uninitialized then reset it to the 279 * If the clock divider is uninitialized then reset it to the
336 * default value to get the 1Hz clock. 280 * default value to get the 1Hz clock.
337 */ 281 */
338 if (rtc_readl(sa1100_rtc, RTTR) == 0) { 282 if (RTTR == 0) {
339 rttr = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); 283 RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
340 rtc_writel(sa1100_rtc, RTTR, rttr); 284 dev_warn(&pdev->dev, "warning: "
341 dev_warn(&pdev->dev, "warning: initializing default clock" 285 "initializing default clock divider/trim value\n");
342 " divider/trim value\n");
343 /* The current RTC value probably doesn't make sense either */ 286 /* The current RTC value probably doesn't make sense either */
344 rtc_writel(sa1100_rtc, RCNR, 0); 287 RCNR = 0;
345 } 288 }
346 289
347 device_init_wakeup(&pdev->dev, 1); 290 device_init_wakeup(&pdev->dev, 1);
348 291
349 sa1100_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, 292 rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops,
350 &sa1100_rtc_ops, THIS_MODULE); 293 THIS_MODULE);
351 if (IS_ERR(sa1100_rtc->rtc)) { 294
352 dev_err(&pdev->dev, "Failed to register RTC device -> %d\n", 295 if (IS_ERR(rtc))
353 ret); 296 return PTR_ERR(rtc);
354 goto err_rtc_reg; 297
355 } 298 platform_set_drvdata(pdev, rtc);
299
356 /* Fix for a nasty initialization problem the in SA11xx RTSR register. 300 /* Fix for a nasty initialization problem the in SA11xx RTSR register.
357 * See also the comments in sa1100_rtc_interrupt(). 301 * See also the comments in sa1100_rtc_interrupt().
358 * 302 *
@@ -375,46 +319,33 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
375 * 319 *
376 * Notice that clearing bit 1 and 0 is accomplished by writting ONES to 320 * Notice that clearing bit 1 and 0 is accomplished by writting ONES to
377 * the corresponding bits in RTSR. */ 321 * the corresponding bits in RTSR. */
378 rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ)); 322 RTSR = RTSR_AL | RTSR_HZ;
379 323
380 return 0; 324 return 0;
381
382err_rtc_reg:
383err_clk:
384 iounmap(sa1100_rtc->base);
385err_ress:
386err_map:
387 kfree(sa1100_rtc);
388 return ret;
389} 325}
390 326
391static int sa1100_rtc_remove(struct platform_device *pdev) 327static int sa1100_rtc_remove(struct platform_device *pdev)
392{ 328{
393 struct sa1100_rtc *sa1100_rtc = platform_get_drvdata(pdev); 329 struct rtc_device *rtc = platform_get_drvdata(pdev);
330
331 if (rtc)
332 rtc_device_unregister(rtc);
394 333
395 rtc_device_unregister(sa1100_rtc->rtc);
396 clk_disable(sa1100_rtc->clk);
397 clk_unprepare(sa1100_rtc->clk);
398 iounmap(sa1100_rtc->base);
399 return 0; 334 return 0;
400} 335}
401 336
402#ifdef CONFIG_PM 337#ifdef CONFIG_PM
403static int sa1100_rtc_suspend(struct device *dev) 338static int sa1100_rtc_suspend(struct device *dev)
404{ 339{
405 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
406
407 if (device_may_wakeup(dev)) 340 if (device_may_wakeup(dev))
408 enable_irq_wake(sa1100_rtc->irq_Alrm); 341 enable_irq_wake(IRQ_RTCAlrm);
409 return 0; 342 return 0;
410} 343}
411 344
412static int sa1100_rtc_resume(struct device *dev) 345static int sa1100_rtc_resume(struct device *dev)
413{ 346{
414 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
415
416 if (device_may_wakeup(dev)) 347 if (device_may_wakeup(dev))
417 disable_irq_wake(sa1100_rtc->irq_Alrm); 348 disable_irq_wake(IRQ_RTCAlrm);
418 return 0; 349 return 0;
419} 350}
420 351
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index eef27a197c00..110137e7ec81 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -3261,6 +3261,12 @@ void dasd_generic_path_event(struct ccw_device *cdev, int *path_event)
3261 device->path_data.tbvpm |= eventlpm; 3261 device->path_data.tbvpm |= eventlpm;
3262 dasd_schedule_device_bh(device); 3262 dasd_schedule_device_bh(device);
3263 } 3263 }
3264 if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) {
3265 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
3266 "Pathgroup re-established\n");
3267 if (device->discipline->kick_validate)
3268 device->discipline->kick_validate(device);
3269 }
3264 } 3270 }
3265 dasd_put_device(device); 3271 dasd_put_device(device);
3266} 3272}
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 553b3c5abb0a..b3beed5434e4 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -189,14 +189,12 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
189 unsigned long flags; 189 unsigned long flags;
190 struct alias_server *server, *newserver; 190 struct alias_server *server, *newserver;
191 struct alias_lcu *lcu, *newlcu; 191 struct alias_lcu *lcu, *newlcu;
192 int is_lcu_known;
193 struct dasd_uid uid; 192 struct dasd_uid uid;
194 193
195 private = (struct dasd_eckd_private *) device->private; 194 private = (struct dasd_eckd_private *) device->private;
196 195
197 device->discipline->get_uid(device, &uid); 196 device->discipline->get_uid(device, &uid);
198 spin_lock_irqsave(&aliastree.lock, flags); 197 spin_lock_irqsave(&aliastree.lock, flags);
199 is_lcu_known = 1;
200 server = _find_server(&uid); 198 server = _find_server(&uid);
201 if (!server) { 199 if (!server) {
202 spin_unlock_irqrestore(&aliastree.lock, flags); 200 spin_unlock_irqrestore(&aliastree.lock, flags);
@@ -208,7 +206,6 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
208 if (!server) { 206 if (!server) {
209 list_add(&newserver->server, &aliastree.serverlist); 207 list_add(&newserver->server, &aliastree.serverlist);
210 server = newserver; 208 server = newserver;
211 is_lcu_known = 0;
212 } else { 209 } else {
213 /* someone was faster */ 210 /* someone was faster */
214 _free_server(newserver); 211 _free_server(newserver);
@@ -226,12 +223,10 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
226 if (!lcu) { 223 if (!lcu) {
227 list_add(&newlcu->lcu, &server->lculist); 224 list_add(&newlcu->lcu, &server->lculist);
228 lcu = newlcu; 225 lcu = newlcu;
229 is_lcu_known = 0;
230 } else { 226 } else {
231 /* someone was faster */ 227 /* someone was faster */
232 _free_lcu(newlcu); 228 _free_lcu(newlcu);
233 } 229 }
234 is_lcu_known = 0;
235 } 230 }
236 spin_lock(&lcu->lock); 231 spin_lock(&lcu->lock);
237 list_add(&device->alias_list, &lcu->inactive_devices); 232 list_add(&device->alias_list, &lcu->inactive_devices);
@@ -239,64 +234,7 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
239 spin_unlock(&lcu->lock); 234 spin_unlock(&lcu->lock);
240 spin_unlock_irqrestore(&aliastree.lock, flags); 235 spin_unlock_irqrestore(&aliastree.lock, flags);
241 236
242 return is_lcu_known; 237 return 0;
243}
244
245/*
246 * The first device to be registered on an LCU will have to do
247 * some additional setup steps to configure that LCU on the
248 * storage server. All further devices should wait with their
249 * initialization until the first device is done.
250 * To synchronize this work, the first device will call
251 * dasd_alias_lcu_setup_complete when it is done, and all
252 * other devices will wait for it with dasd_alias_wait_for_lcu_setup.
253 */
254void dasd_alias_lcu_setup_complete(struct dasd_device *device)
255{
256 unsigned long flags;
257 struct alias_server *server;
258 struct alias_lcu *lcu;
259 struct dasd_uid uid;
260
261 device->discipline->get_uid(device, &uid);
262 lcu = NULL;
263 spin_lock_irqsave(&aliastree.lock, flags);
264 server = _find_server(&uid);
265 if (server)
266 lcu = _find_lcu(server, &uid);
267 spin_unlock_irqrestore(&aliastree.lock, flags);
268 if (!lcu) {
269 DBF_EVENT_DEVID(DBF_ERR, device->cdev,
270 "could not find lcu for %04x %02x",
271 uid.ssid, uid.real_unit_addr);
272 WARN_ON(1);
273 return;
274 }
275 complete_all(&lcu->lcu_setup);
276}
277
278void dasd_alias_wait_for_lcu_setup(struct dasd_device *device)
279{
280 unsigned long flags;
281 struct alias_server *server;
282 struct alias_lcu *lcu;
283 struct dasd_uid uid;
284
285 device->discipline->get_uid(device, &uid);
286 lcu = NULL;
287 spin_lock_irqsave(&aliastree.lock, flags);
288 server = _find_server(&uid);
289 if (server)
290 lcu = _find_lcu(server, &uid);
291 spin_unlock_irqrestore(&aliastree.lock, flags);
292 if (!lcu) {
293 DBF_EVENT_DEVID(DBF_ERR, device->cdev,
294 "could not find lcu for %04x %02x",
295 uid.ssid, uid.real_unit_addr);
296 WARN_ON(1);
297 return;
298 }
299 wait_for_completion(&lcu->lcu_setup);
300} 238}
301 239
302/* 240/*
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index bbcd5e9206ee..70880be26015 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1534,6 +1534,10 @@ static void dasd_eckd_validate_server(struct dasd_device *device)
1534 struct dasd_eckd_private *private; 1534 struct dasd_eckd_private *private;
1535 int enable_pav; 1535 int enable_pav;
1536 1536
1537 private = (struct dasd_eckd_private *) device->private;
1538 if (private->uid.type == UA_BASE_PAV_ALIAS ||
1539 private->uid.type == UA_HYPER_PAV_ALIAS)
1540 return;
1537 if (dasd_nopav || MACHINE_IS_VM) 1541 if (dasd_nopav || MACHINE_IS_VM)
1538 enable_pav = 0; 1542 enable_pav = 0;
1539 else 1543 else
@@ -1542,11 +1546,28 @@ static void dasd_eckd_validate_server(struct dasd_device *device)
1542 1546
1543 /* may be requested feature is not available on server, 1547 /* may be requested feature is not available on server,
1544 * therefore just report error and go ahead */ 1548 * therefore just report error and go ahead */
1545 private = (struct dasd_eckd_private *) device->private;
1546 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x " 1549 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x "
1547 "returned rc=%d", private->uid.ssid, rc); 1550 "returned rc=%d", private->uid.ssid, rc);
1548} 1551}
1549 1552
1553/*
1554 * worker to do a validate server in case of a lost pathgroup
1555 */
1556static void dasd_eckd_do_validate_server(struct work_struct *work)
1557{
1558 struct dasd_device *device = container_of(work, struct dasd_device,
1559 kick_validate);
1560 dasd_eckd_validate_server(device);
1561 dasd_put_device(device);
1562}
1563
1564static void dasd_eckd_kick_validate_server(struct dasd_device *device)
1565{
1566 dasd_get_device(device);
1567 /* queue call to do_validate_server to the kernel event daemon. */
1568 schedule_work(&device->kick_validate);
1569}
1570
1550static u32 get_fcx_max_data(struct dasd_device *device) 1571static u32 get_fcx_max_data(struct dasd_device *device)
1551{ 1572{
1552#if defined(CONFIG_64BIT) 1573#if defined(CONFIG_64BIT)
@@ -1588,10 +1609,13 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
1588 struct dasd_eckd_private *private; 1609 struct dasd_eckd_private *private;
1589 struct dasd_block *block; 1610 struct dasd_block *block;
1590 struct dasd_uid temp_uid; 1611 struct dasd_uid temp_uid;
1591 int is_known, rc, i; 1612 int rc, i;
1592 int readonly; 1613 int readonly;
1593 unsigned long value; 1614 unsigned long value;
1594 1615
1616 /* setup work queue for validate server*/
1617 INIT_WORK(&device->kick_validate, dasd_eckd_do_validate_server);
1618
1595 if (!ccw_device_is_pathgroup(device->cdev)) { 1619 if (!ccw_device_is_pathgroup(device->cdev)) {
1596 dev_warn(&device->cdev->dev, 1620 dev_warn(&device->cdev->dev,
1597 "A channel path group could not be established\n"); 1621 "A channel path group could not be established\n");
@@ -1651,22 +1675,12 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
1651 block->base = device; 1675 block->base = device;
1652 } 1676 }
1653 1677
1654 /* register lcu with alias handling, enable PAV if this is a new lcu */ 1678 /* register lcu with alias handling, enable PAV */
1655 is_known = dasd_alias_make_device_known_to_lcu(device); 1679 rc = dasd_alias_make_device_known_to_lcu(device);
1656 if (is_known < 0) { 1680 if (rc)
1657 rc = is_known;
1658 goto out_err2; 1681 goto out_err2;
1659 } 1682
1660 /* 1683 dasd_eckd_validate_server(device);
1661 * dasd_eckd_validate_server is done on the first device that
1662 * is found for an LCU. All later other devices have to wait
1663 * for it, so they will read the correct feature codes.
1664 */
1665 if (!is_known) {
1666 dasd_eckd_validate_server(device);
1667 dasd_alias_lcu_setup_complete(device);
1668 } else
1669 dasd_alias_wait_for_lcu_setup(device);
1670 1684
1671 /* device may report different configuration data after LCU setup */ 1685 /* device may report different configuration data after LCU setup */
1672 rc = dasd_eckd_read_conf(device); 1686 rc = dasd_eckd_read_conf(device);
@@ -4098,7 +4112,7 @@ static int dasd_eckd_restore_device(struct dasd_device *device)
4098{ 4112{
4099 struct dasd_eckd_private *private; 4113 struct dasd_eckd_private *private;
4100 struct dasd_eckd_characteristics temp_rdc_data; 4114 struct dasd_eckd_characteristics temp_rdc_data;
4101 int is_known, rc; 4115 int rc;
4102 struct dasd_uid temp_uid; 4116 struct dasd_uid temp_uid;
4103 unsigned long flags; 4117 unsigned long flags;
4104 4118
@@ -4121,14 +4135,10 @@ static int dasd_eckd_restore_device(struct dasd_device *device)
4121 goto out_err; 4135 goto out_err;
4122 4136
4123 /* register lcu with alias handling, enable PAV if this is a new lcu */ 4137 /* register lcu with alias handling, enable PAV if this is a new lcu */
4124 is_known = dasd_alias_make_device_known_to_lcu(device); 4138 rc = dasd_alias_make_device_known_to_lcu(device);
4125 if (is_known < 0) 4139 if (rc)
4126 return is_known; 4140 return rc;
4127 if (!is_known) { 4141 dasd_eckd_validate_server(device);
4128 dasd_eckd_validate_server(device);
4129 dasd_alias_lcu_setup_complete(device);
4130 } else
4131 dasd_alias_wait_for_lcu_setup(device);
4132 4142
4133 /* RE-Read Configuration Data */ 4143 /* RE-Read Configuration Data */
4134 rc = dasd_eckd_read_conf(device); 4144 rc = dasd_eckd_read_conf(device);
@@ -4270,6 +4280,7 @@ static struct dasd_discipline dasd_eckd_discipline = {
4270 .restore = dasd_eckd_restore_device, 4280 .restore = dasd_eckd_restore_device,
4271 .reload = dasd_eckd_reload_device, 4281 .reload = dasd_eckd_reload_device,
4272 .get_uid = dasd_eckd_get_uid, 4282 .get_uid = dasd_eckd_get_uid,
4283 .kick_validate = dasd_eckd_kick_validate_server,
4273}; 4284};
4274 4285
4275static int __init 4286static int __init
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index afe8c33422ed..33a6743ddc55 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -355,6 +355,7 @@ struct dasd_discipline {
355 int (*reload) (struct dasd_device *); 355 int (*reload) (struct dasd_device *);
356 356
357 int (*get_uid) (struct dasd_device *, struct dasd_uid *); 357 int (*get_uid) (struct dasd_device *, struct dasd_uid *);
358 void (*kick_validate) (struct dasd_device *);
358}; 359};
359 360
360extern struct dasd_discipline *dasd_diag_discipline_pointer; 361extern struct dasd_discipline *dasd_diag_discipline_pointer;
@@ -455,6 +456,7 @@ struct dasd_device {
455 struct work_struct kick_work; 456 struct work_struct kick_work;
456 struct work_struct restore_device; 457 struct work_struct restore_device;
457 struct work_struct reload_device; 458 struct work_struct reload_device;
459 struct work_struct kick_validate;
458 struct timer_list timer; 460 struct timer_list timer;
459 461
460 debug_info_t *debug_area; 462 debug_info_t *debug_area;
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
index 4ceeace80453..70eb1f79b1ba 100644
--- a/drivers/scsi/mac_esp.c
+++ b/drivers/scsi/mac_esp.c
@@ -565,8 +565,7 @@ static int __devinit esp_mac_probe(struct platform_device *dev)
565 esp_chips[dev->id] = esp; 565 esp_chips[dev->id] = esp;
566 mb(); 566 mb();
567 if (esp_chips[!dev->id] == NULL) { 567 if (esp_chips[!dev->id] == NULL) {
568 err = request_irq(host->irq, mac_scsi_esp_intr, 0, 568 err = request_irq(host->irq, mac_scsi_esp_intr, 0, "ESP", NULL);
569 "Mac ESP", NULL);
570 if (err < 0) { 569 if (err < 0) {
571 esp_chips[dev->id] = NULL; 570 esp_chips[dev->id] = NULL;
572 goto fail_free_priv; 571 goto fail_free_priv;
diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c
index ea2bde206f7f..2bccfbe5661e 100644
--- a/drivers/scsi/mac_scsi.c
+++ b/drivers/scsi/mac_scsi.c
@@ -339,9 +339,6 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance)
339 339
340 printk(KERN_INFO "Macintosh SCSI: resetting the SCSI bus..." ); 340 printk(KERN_INFO "Macintosh SCSI: resetting the SCSI bus..." );
341 341
342 /* switch off SCSI IRQ - catch an interrupt without IRQ bit set else */
343 disable_irq(IRQ_MAC_SCSI);
344
345 /* get in phase */ 342 /* get in phase */
346 NCR5380_write( TARGET_COMMAND_REG, 343 NCR5380_write( TARGET_COMMAND_REG,
347 PHASE_SR_TO_TCR( NCR5380_read(STATUS_REG) )); 344 PHASE_SR_TO_TCR( NCR5380_read(STATUS_REG) ));
@@ -357,9 +354,6 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance)
357 for( end = jiffies + AFTER_RESET_DELAY; time_before(jiffies, end); ) 354 for( end = jiffies + AFTER_RESET_DELAY; time_before(jiffies, end); )
358 barrier(); 355 barrier();
359 356
360 /* switch on SCSI IRQ again */
361 enable_irq(IRQ_MAC_SCSI);
362
363 printk(KERN_INFO " done\n" ); 357 printk(KERN_INFO " done\n" );
364} 358}
365#endif 359#endif
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index dd9a5743fa99..220ce7e31cf5 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1304,7 +1304,7 @@ static struct genl_multicast_group thermal_event_mcgrp = {
1304 .name = THERMAL_GENL_MCAST_GROUP_NAME, 1304 .name = THERMAL_GENL_MCAST_GROUP_NAME,
1305}; 1305};
1306 1306
1307int generate_netlink_event(u32 orig, enum events event) 1307int thermal_generate_netlink_event(u32 orig, enum events event)
1308{ 1308{
1309 struct sk_buff *skb; 1309 struct sk_buff *skb;
1310 struct nlattr *attr; 1310 struct nlattr *attr;
@@ -1363,7 +1363,7 @@ int generate_netlink_event(u32 orig, enum events event)
1363 1363
1364 return result; 1364 return result;
1365} 1365}
1366EXPORT_SYMBOL(generate_netlink_event); 1366EXPORT_SYMBOL(thermal_generate_netlink_event);
1367 1367
1368static int genetlink_init(void) 1368static int genetlink_init(void)
1369{ 1369{
diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250/8250.c
index 9f50c4e3c2be..9f50c4e3c2be 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250/8250.c
diff --git a/drivers/tty/serial/8250.h b/drivers/tty/serial/8250/8250.h
index ae027be57e25..ae027be57e25 100644
--- a/drivers/tty/serial/8250.h
+++ b/drivers/tty/serial/8250/8250.h
diff --git a/drivers/tty/serial/8250_accent.c b/drivers/tty/serial/8250/8250_accent.c
index 34b51c651192..34b51c651192 100644
--- a/drivers/tty/serial/8250_accent.c
+++ b/drivers/tty/serial/8250/8250_accent.c
diff --git a/drivers/tty/serial/8250_acorn.c b/drivers/tty/serial/8250/8250_acorn.c
index b0ce8c56f1a4..b0ce8c56f1a4 100644
--- a/drivers/tty/serial/8250_acorn.c
+++ b/drivers/tty/serial/8250/8250_acorn.c
diff --git a/drivers/tty/serial/8250_boca.c b/drivers/tty/serial/8250/8250_boca.c
index d125dc107985..d125dc107985 100644
--- a/drivers/tty/serial/8250_boca.c
+++ b/drivers/tty/serial/8250/8250_boca.c
diff --git a/drivers/tty/serial/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index f574eef3075f..f574eef3075f 100644
--- a/drivers/tty/serial/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
diff --git a/drivers/tty/serial/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index eaafb98debed..eaafb98debed 100644
--- a/drivers/tty/serial/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
diff --git a/drivers/tty/serial/8250_exar_st16c554.c b/drivers/tty/serial/8250/8250_exar_st16c554.c
index bf53aabf9b5e..bf53aabf9b5e 100644
--- a/drivers/tty/serial/8250_exar_st16c554.c
+++ b/drivers/tty/serial/8250/8250_exar_st16c554.c
diff --git a/drivers/tty/serial/8250_fourport.c b/drivers/tty/serial/8250/8250_fourport.c
index be1582609626..be1582609626 100644
--- a/drivers/tty/serial/8250_fourport.c
+++ b/drivers/tty/serial/8250/8250_fourport.c
diff --git a/drivers/tty/serial/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c
index f4d3c47b88e8..f4d3c47b88e8 100644
--- a/drivers/tty/serial/8250_fsl.c
+++ b/drivers/tty/serial/8250/8250_fsl.c
diff --git a/drivers/tty/serial/8250_gsc.c b/drivers/tty/serial/8250/8250_gsc.c
index d8c0ffbfa6e3..d8c0ffbfa6e3 100644
--- a/drivers/tty/serial/8250_gsc.c
+++ b/drivers/tty/serial/8250/8250_gsc.c
diff --git a/drivers/tty/serial/8250_hp300.c b/drivers/tty/serial/8250/8250_hp300.c
index c13438c93012..c13438c93012 100644
--- a/drivers/tty/serial/8250_hp300.c
+++ b/drivers/tty/serial/8250/8250_hp300.c
diff --git a/drivers/tty/serial/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c
index a5c778e83de0..a5c778e83de0 100644
--- a/drivers/tty/serial/8250_hub6.c
+++ b/drivers/tty/serial/8250/8250_hub6.c
diff --git a/drivers/tty/serial/8250_mca.c b/drivers/tty/serial/8250/8250_mca.c
index d20abf04541e..d20abf04541e 100644
--- a/drivers/tty/serial/8250_mca.c
+++ b/drivers/tty/serial/8250/8250_mca.c
diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index da2b0b0a183f..da2b0b0a183f 100644
--- a/drivers/tty/serial/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
diff --git a/drivers/tty/serial/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index a2f236510ff1..a2f236510ff1 100644
--- a/drivers/tty/serial/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
new file mode 100644
index 000000000000..591f8018e7dd
--- /dev/null
+++ b/drivers/tty/serial/8250/Kconfig
@@ -0,0 +1,280 @@
1#
2# The 8250/16550 serial drivers. You shouldn't be in this list unless
3# you somehow have an implicit or explicit dependency on SERIAL_8250.
4#
5
6config SERIAL_8250
7 tristate "8250/16550 and compatible serial support"
8 select SERIAL_CORE
9 ---help---
10 This selects whether you want to include the driver for the standard
11 serial ports. The standard answer is Y. People who might say N
12 here are those that are setting up dedicated Ethernet WWW/FTP
13 servers, or users that have one of the various bus mice instead of a
14 serial mouse and don't intend to use their machine's standard serial
15 port for anything. (Note that the Cyclades and Stallion multi
16 serial port drivers do not need this driver built in for them to
17 work.)
18
19 To compile this driver as a module, choose M here: the
20 module will be called 8250.
21 [WARNING: Do not compile this driver as a module if you are using
22 non-standard serial ports, since the configuration information will
23 be lost when the driver is unloaded. This limitation may be lifted
24 in the future.]
25
26 BTW1: If you have a mouseman serial mouse which is not recognized by
27 the X window system, try running gpm first.
28
29 BTW2: If you intend to use a software modem (also called Winmodem)
30 under Linux, forget it. These modems are crippled and require
31 proprietary drivers which are only available under Windows.
32
33 Most people will say Y or M here, so that they can use serial mice,
34 modems and similar devices connecting to the standard serial ports.
35
36config SERIAL_8250_CONSOLE
37 bool "Console on 8250/16550 and compatible serial port"
38 depends on SERIAL_8250=y
39 select SERIAL_CORE_CONSOLE
40 ---help---
41 If you say Y here, it will be possible to use a serial port as the
42 system console (the system console is the device which receives all
43 kernel messages and warnings and which allows logins in single user
44 mode). This could be useful if some terminal or printer is connected
45 to that serial port.
46
47 Even if you say Y here, the currently visible virtual console
48 (/dev/tty0) will still be used as the system console by default, but
49 you can alter that using a kernel command line option such as
50 "console=ttyS1". (Try "man bootparam" or see the documentation of
51 your boot loader (grub or lilo or loadlin) about how to pass options
52 to the kernel at boot time.)
53
54 If you don't have a VGA card installed and you say Y here, the
55 kernel will automatically use the first serial line, /dev/ttyS0, as
56 system console.
57
58 You can set that using a kernel command line option such as
59 "console=uart8250,io,0x3f8,9600n8"
60 "console=uart8250,mmio,0xff5e0000,115200n8".
61 and it will switch to normal serial console when the corresponding
62 port is ready.
63 "earlycon=uart8250,io,0x3f8,9600n8"
64 "earlycon=uart8250,mmio,0xff5e0000,115200n8".
65 it will not only setup early console.
66
67 If unsure, say N.
68
69config FIX_EARLYCON_MEM
70 bool
71 depends on X86
72 default y
73
74config SERIAL_8250_GSC
75 tristate
76 depends on SERIAL_8250 && GSC
77 default SERIAL_8250
78
79config SERIAL_8250_PCI
80 tristate "8250/16550 PCI device support" if EXPERT
81 depends on SERIAL_8250 && PCI
82 default SERIAL_8250
83 help
84 This builds standard PCI serial support. You may be able to
85 disable this feature if you only need legacy serial support.
86 Saves about 9K.
87
88config SERIAL_8250_PNP
89 tristate "8250/16550 PNP device support" if EXPERT
90 depends on SERIAL_8250 && PNP
91 default SERIAL_8250
92 help
93 This builds standard PNP serial support. You may be able to
94 disable this feature if you only need legacy serial support.
95
96config SERIAL_8250_HP300
97 tristate
98 depends on SERIAL_8250 && HP300
99 default SERIAL_8250
100
101config SERIAL_8250_CS
102 tristate "8250/16550 PCMCIA device support"
103 depends on PCMCIA && SERIAL_8250
104 ---help---
105 Say Y here to enable support for 16-bit PCMCIA serial devices,
106 including serial port cards, modems, and the modem functions of
107 multi-function Ethernet/modem cards. (PCMCIA- or PC-cards are
108 credit-card size devices often used with laptops.)
109
110 To compile this driver as a module, choose M here: the
111 module will be called serial_cs.
112
113 If unsure, say N.
114
115config SERIAL_8250_NR_UARTS
116 int "Maximum number of 8250/16550 serial ports"
117 depends on SERIAL_8250
118 default "4"
119 help
120 Set this to the number of serial ports you want the driver
121 to support. This includes any ports discovered via ACPI or
122 PCI enumeration and any ports that may be added at run-time
123 via hot-plug, or any ISA multi-port serial cards.
124
125config SERIAL_8250_RUNTIME_UARTS
126 int "Number of 8250/16550 serial ports to register at runtime"
127 depends on SERIAL_8250
128 range 0 SERIAL_8250_NR_UARTS
129 default "4"
130 help
131 Set this to the maximum number of serial ports you want
132 the kernel to register at boot time. This can be overridden
133 with the module parameter "nr_uarts", or boot-time parameter
134 8250.nr_uarts
135
136config SERIAL_8250_EXTENDED
137 bool "Extended 8250/16550 serial driver options"
138 depends on SERIAL_8250
139 help
140 If you wish to use any non-standard features of the standard "dumb"
141 driver, say Y here. This includes HUB6 support, shared serial
142 interrupts, special multiport support, support for more than the
143 four COM 1/2/3/4 boards, etc.
144
145 Note that the answer to this question won't directly affect the
146 kernel: saying N will just cause the configurator to skip all
147 the questions about serial driver options. If unsure, say N.
148
149config SERIAL_8250_MANY_PORTS
150 bool "Support more than 4 legacy serial ports"
151 depends on SERIAL_8250_EXTENDED && !IA64
152 help
153 Say Y here if you have dumb serial boards other than the four
154 standard COM 1/2/3/4 ports. This may happen if you have an AST
155 FourPort, Accent Async, Boca (read the Boca mini-HOWTO, available
156 from <http://www.tldp.org/docs.html#howto>), or other custom
157 serial port hardware which acts similar to standard serial port
158 hardware. If you only use the standard COM 1/2/3/4 ports, you can
159 say N here to save some memory. You can also say Y if you have an
160 "intelligent" multiport card such as Cyclades, Digiboards, etc.
161
162#
163# Multi-port serial cards
164#
165
166config SERIAL_8250_FOURPORT
167 tristate "Support Fourport cards"
168 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
169 help
170 Say Y here if you have an AST FourPort serial board.
171
172 To compile this driver as a module, choose M here: the module
173 will be called 8250_fourport.
174
175config SERIAL_8250_ACCENT
176 tristate "Support Accent cards"
177 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
178 help
179 Say Y here if you have an Accent Async serial board.
180
181 To compile this driver as a module, choose M here: the module
182 will be called 8250_accent.
183
184config SERIAL_8250_BOCA
185 tristate "Support Boca cards"
186 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
187 help
188 Say Y here if you have a Boca serial board. Please read the Boca
189 mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>
190
191 To compile this driver as a module, choose M here: the module
192 will be called 8250_boca.
193
194config SERIAL_8250_EXAR_ST16C554
195 tristate "Support Exar ST16C554/554D Quad UART"
196 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
197 help
198 The Uplogix Envoy TU301 uses this Exar Quad UART. If you are
199 tinkering with your Envoy TU301, or have a machine with this UART,
200 say Y here.
201
202 To compile this driver as a module, choose M here: the module
203 will be called 8250_exar_st16c554.
204
205config SERIAL_8250_HUB6
206 tristate "Support Hub6 cards"
207 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
208 help
209 Say Y here if you have a HUB6 serial board.
210
211 To compile this driver as a module, choose M here: the module
212 will be called 8250_hub6.
213
214#
215# Misc. options/drivers.
216#
217
218config SERIAL_8250_SHARE_IRQ
219 bool "Support for sharing serial interrupts"
220 depends on SERIAL_8250_EXTENDED
221 help
222 Some serial boards have hardware support which allows multiple dumb
223 serial ports on the same board to share a single IRQ. To enable
224 support for this in the serial driver, say Y here.
225
226config SERIAL_8250_DETECT_IRQ
227 bool "Autodetect IRQ on standard ports (unsafe)"
228 depends on SERIAL_8250_EXTENDED
229 help
230 Say Y here if you want the kernel to try to guess which IRQ
231 to use for your serial port.
232
233 This is considered unsafe; it is far better to configure the IRQ in
234 a boot script using the setserial command.
235
236 If unsure, say N.
237
238config SERIAL_8250_RSA
239 bool "Support RSA serial ports"
240 depends on SERIAL_8250_EXTENDED
241 help
242 ::: To be written :::
243
244config SERIAL_8250_MCA
245 tristate "Support 8250-type ports on MCA buses"
246 depends on SERIAL_8250 != n && MCA
247 help
248 Say Y here if you have a MCA serial ports.
249
250 To compile this driver as a module, choose M here: the module
251 will be called 8250_mca.
252
253config SERIAL_8250_ACORN
254 tristate "Acorn expansion card serial port support"
255 depends on ARCH_ACORN && SERIAL_8250
256 help
257 If you have an Atomwide Serial card or Serial Port card for an Acorn
258 system, say Y to this option. The driver can handle 1, 2, or 3 port
259 cards. If unsure, say N.
260
261config SERIAL_8250_RM9K
262 bool "Support for MIPS RM9xxx integrated serial port"
263 depends on SERIAL_8250 != n && SERIAL_RM9000
264 select SERIAL_8250_SHARE_IRQ
265 help
266 Selecting this option will add support for the integrated serial
267 port hardware found on MIPS RM9122 and similar processors.
268 If unsure, say N.
269
270config SERIAL_8250_FSL
271 bool
272 depends on SERIAL_8250_CONSOLE && PPC_UDBG_16550
273 default PPC
274
275config SERIAL_8250_DW
276 tristate "Support for Synopsys DesignWare 8250 quirks"
277 depends on SERIAL_8250 && OF
278 help
279 Selecting this option will enable handling of the extra features
280 present in the Synopsys DesignWare APB UART.
diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile
new file mode 100644
index 000000000000..867bba738908
--- /dev/null
+++ b/drivers/tty/serial/8250/Makefile
@@ -0,0 +1,20 @@
1#
2# Makefile for the 8250 serial device drivers.
3#
4
5obj-$(CONFIG_SERIAL_8250) += 8250.o
6obj-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o
7obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o
8obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o
9obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o
10obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o
11obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o
12obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
13obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
14obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
15obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
16obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
17obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
18obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
19obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o
20obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/8250/m32r_sio.c
index 94a6792bf97b..94a6792bf97b 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/8250/m32r_sio.c
diff --git a/drivers/tty/serial/m32r_sio.h b/drivers/tty/serial/8250/m32r_sio.h
index e9b7e11793b1..e9b7e11793b1 100644
--- a/drivers/tty/serial/m32r_sio.h
+++ b/drivers/tty/serial/8250/m32r_sio.h
diff --git a/drivers/tty/serial/m32r_sio_reg.h b/drivers/tty/serial/8250/m32r_sio_reg.h
index 4671473793e3..4671473793e3 100644
--- a/drivers/tty/serial/m32r_sio_reg.h
+++ b/drivers/tty/serial/8250/m32r_sio_reg.h
diff --git a/drivers/tty/serial/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
index 86090605a84e..86090605a84e 100644
--- a/drivers/tty/serial/serial_cs.c
+++ b/drivers/tty/serial/8250/serial_cs.c
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index aca2386c5ef1..2de99248dfae 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -5,279 +5,7 @@
5menu "Serial drivers" 5menu "Serial drivers"
6 depends on HAS_IOMEM 6 depends on HAS_IOMEM
7 7
8# 8source "drivers/tty/serial/8250/Kconfig"
9# The new 8250/16550 serial drivers
10config SERIAL_8250
11 tristate "8250/16550 and compatible serial support"
12 select SERIAL_CORE
13 ---help---
14 This selects whether you want to include the driver for the standard
15 serial ports. The standard answer is Y. People who might say N
16 here are those that are setting up dedicated Ethernet WWW/FTP
17 servers, or users that have one of the various bus mice instead of a
18 serial mouse and don't intend to use their machine's standard serial
19 port for anything. (Note that the Cyclades and Stallion multi
20 serial port drivers do not need this driver built in for them to
21 work.)
22
23 To compile this driver as a module, choose M here: the
24 module will be called 8250.
25 [WARNING: Do not compile this driver as a module if you are using
26 non-standard serial ports, since the configuration information will
27 be lost when the driver is unloaded. This limitation may be lifted
28 in the future.]
29
30 BTW1: If you have a mouseman serial mouse which is not recognized by
31 the X window system, try running gpm first.
32
33 BTW2: If you intend to use a software modem (also called Winmodem)
34 under Linux, forget it. These modems are crippled and require
35 proprietary drivers which are only available under Windows.
36
37 Most people will say Y or M here, so that they can use serial mice,
38 modems and similar devices connecting to the standard serial ports.
39
40config SERIAL_8250_CONSOLE
41 bool "Console on 8250/16550 and compatible serial port"
42 depends on SERIAL_8250=y
43 select SERIAL_CORE_CONSOLE
44 ---help---
45 If you say Y here, it will be possible to use a serial port as the
46 system console (the system console is the device which receives all
47 kernel messages and warnings and which allows logins in single user
48 mode). This could be useful if some terminal or printer is connected
49 to that serial port.
50
51 Even if you say Y here, the currently visible virtual console
52 (/dev/tty0) will still be used as the system console by default, but
53 you can alter that using a kernel command line option such as
54 "console=ttyS1". (Try "man bootparam" or see the documentation of
55 your boot loader (grub or lilo or loadlin) about how to pass options
56 to the kernel at boot time.)
57
58 If you don't have a VGA card installed and you say Y here, the
59 kernel will automatically use the first serial line, /dev/ttyS0, as
60 system console.
61
62 You can set that using a kernel command line option such as
63 "console=uart8250,io,0x3f8,9600n8"
64 "console=uart8250,mmio,0xff5e0000,115200n8".
65 and it will switch to normal serial console when the corresponding
66 port is ready.
67 "earlycon=uart8250,io,0x3f8,9600n8"
68 "earlycon=uart8250,mmio,0xff5e0000,115200n8".
69 it will not only setup early console.
70
71 If unsure, say N.
72
73config FIX_EARLYCON_MEM
74 bool
75 depends on X86
76 default y
77
78config SERIAL_8250_GSC
79 tristate
80 depends on SERIAL_8250 && GSC
81 default SERIAL_8250
82
83config SERIAL_8250_PCI
84 tristate "8250/16550 PCI device support" if EXPERT
85 depends on SERIAL_8250 && PCI
86 default SERIAL_8250
87 help
88 This builds standard PCI serial support. You may be able to
89 disable this feature if you only need legacy serial support.
90 Saves about 9K.
91
92config SERIAL_8250_PNP
93 tristate "8250/16550 PNP device support" if EXPERT
94 depends on SERIAL_8250 && PNP
95 default SERIAL_8250
96 help
97 This builds standard PNP serial support. You may be able to
98 disable this feature if you only need legacy serial support.
99
100config SERIAL_8250_FSL
101 bool
102 depends on SERIAL_8250_CONSOLE && PPC_UDBG_16550
103 default PPC
104
105config SERIAL_8250_HP300
106 tristate
107 depends on SERIAL_8250 && HP300
108 default SERIAL_8250
109
110config SERIAL_8250_CS
111 tristate "8250/16550 PCMCIA device support"
112 depends on PCMCIA && SERIAL_8250
113 ---help---
114 Say Y here to enable support for 16-bit PCMCIA serial devices,
115 including serial port cards, modems, and the modem functions of
116 multi-function Ethernet/modem cards. (PCMCIA- or PC-cards are
117 credit-card size devices often used with laptops.)
118
119 To compile this driver as a module, choose M here: the
120 module will be called serial_cs.
121
122 If unsure, say N.
123
124config SERIAL_8250_NR_UARTS
125 int "Maximum number of 8250/16550 serial ports"
126 depends on SERIAL_8250
127 default "4"
128 help
129 Set this to the number of serial ports you want the driver
130 to support. This includes any ports discovered via ACPI or
131 PCI enumeration and any ports that may be added at run-time
132 via hot-plug, or any ISA multi-port serial cards.
133
134config SERIAL_8250_RUNTIME_UARTS
135 int "Number of 8250/16550 serial ports to register at runtime"
136 depends on SERIAL_8250
137 range 0 SERIAL_8250_NR_UARTS
138 default "4"
139 help
140 Set this to the maximum number of serial ports you want
141 the kernel to register at boot time. This can be overridden
142 with the module parameter "nr_uarts", or boot-time parameter
143 8250.nr_uarts
144
145config SERIAL_8250_EXTENDED
146 bool "Extended 8250/16550 serial driver options"
147 depends on SERIAL_8250
148 help
149 If you wish to use any non-standard features of the standard "dumb"
150 driver, say Y here. This includes HUB6 support, shared serial
151 interrupts, special multiport support, support for more than the
152 four COM 1/2/3/4 boards, etc.
153
154 Note that the answer to this question won't directly affect the
155 kernel: saying N will just cause the configurator to skip all
156 the questions about serial driver options. If unsure, say N.
157
158config SERIAL_8250_MANY_PORTS
159 bool "Support more than 4 legacy serial ports"
160 depends on SERIAL_8250_EXTENDED && !IA64
161 help
162 Say Y here if you have dumb serial boards other than the four
163 standard COM 1/2/3/4 ports. This may happen if you have an AST
164 FourPort, Accent Async, Boca (read the Boca mini-HOWTO, available
165 from <http://www.tldp.org/docs.html#howto>), or other custom
166 serial port hardware which acts similar to standard serial port
167 hardware. If you only use the standard COM 1/2/3/4 ports, you can
168 say N here to save some memory. You can also say Y if you have an
169 "intelligent" multiport card such as Cyclades, Digiboards, etc.
170
171#
172# Multi-port serial cards
173#
174
175config SERIAL_8250_FOURPORT
176 tristate "Support Fourport cards"
177 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
178 help
179 Say Y here if you have an AST FourPort serial board.
180
181 To compile this driver as a module, choose M here: the module
182 will be called 8250_fourport.
183
184config SERIAL_8250_ACCENT
185 tristate "Support Accent cards"
186 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
187 help
188 Say Y here if you have an Accent Async serial board.
189
190 To compile this driver as a module, choose M here: the module
191 will be called 8250_accent.
192
193config SERIAL_8250_BOCA
194 tristate "Support Boca cards"
195 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
196 help
197 Say Y here if you have a Boca serial board. Please read the Boca
198 mini-HOWTO, available from <http://www.tldp.org/docs.html#howto>
199
200 To compile this driver as a module, choose M here: the module
201 will be called 8250_boca.
202
203config SERIAL_8250_EXAR_ST16C554
204 tristate "Support Exar ST16C554/554D Quad UART"
205 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
206 help
207 The Uplogix Envoy TU301 uses this Exar Quad UART. If you are
208 tinkering with your Envoy TU301, or have a machine with this UART,
209 say Y here.
210
211 To compile this driver as a module, choose M here: the module
212 will be called 8250_exar_st16c554.
213
214config SERIAL_8250_HUB6
215 tristate "Support Hub6 cards"
216 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
217 help
218 Say Y here if you have a HUB6 serial board.
219
220 To compile this driver as a module, choose M here: the module
221 will be called 8250_hub6.
222
223config SERIAL_8250_SHARE_IRQ
224 bool "Support for sharing serial interrupts"
225 depends on SERIAL_8250_EXTENDED
226 help
227 Some serial boards have hardware support which allows multiple dumb
228 serial ports on the same board to share a single IRQ. To enable
229 support for this in the serial driver, say Y here.
230
231config SERIAL_8250_DETECT_IRQ
232 bool "Autodetect IRQ on standard ports (unsafe)"
233 depends on SERIAL_8250_EXTENDED
234 help
235 Say Y here if you want the kernel to try to guess which IRQ
236 to use for your serial port.
237
238 This is considered unsafe; it is far better to configure the IRQ in
239 a boot script using the setserial command.
240
241 If unsure, say N.
242
243config SERIAL_8250_RSA
244 bool "Support RSA serial ports"
245 depends on SERIAL_8250_EXTENDED
246 help
247 ::: To be written :::
248
249config SERIAL_8250_MCA
250 tristate "Support 8250-type ports on MCA buses"
251 depends on SERIAL_8250 != n && MCA
252 help
253 Say Y here if you have a MCA serial ports.
254
255 To compile this driver as a module, choose M here: the module
256 will be called 8250_mca.
257
258config SERIAL_8250_ACORN
259 tristate "Acorn expansion card serial port support"
260 depends on ARCH_ACORN && SERIAL_8250
261 help
262 If you have an Atomwide Serial card or Serial Port card for an Acorn
263 system, say Y to this option. The driver can handle 1, 2, or 3 port
264 cards. If unsure, say N.
265
266config SERIAL_8250_RM9K
267 bool "Support for MIPS RM9xxx integrated serial port"
268 depends on SERIAL_8250 != n && SERIAL_RM9000
269 select SERIAL_8250_SHARE_IRQ
270 help
271 Selecting this option will add support for the integrated serial
272 port hardware found on MIPS RM9122 and similar processors.
273 If unsure, say N.
274
275config SERIAL_8250_DW
276 tristate "Support for Synopsys DesignWare 8250 quirks"
277 depends on SERIAL_8250 && OF
278 help
279 Selecting this option will enable handling of the extra features
280 present in the Synopsys DesignWare APB UART.
281 9
282comment "Non-8250 serial port support" 10comment "Non-8250 serial port support"
283 11
@@ -536,15 +264,6 @@ config SERIAL_MAX3107
536 help 264 help
537 MAX3107 chip support 265 MAX3107 chip support
538 266
539config SERIAL_MAX3107_AAVA
540 tristate "MAX3107 AAVA platform support"
541 depends on X86_MRST && SERIAL_MAX3107 && GPIOLIB
542 select SERIAL_CORE
543 help
544 Support for the MAX3107 chip configuration found on the AAVA
545 platform. Includes the extra initialisation and GPIO support
546 neded for this device.
547
548config SERIAL_DZ 267config SERIAL_DZ
549 bool "DECstation DZ serial driver" 268 bool "DECstation DZ serial driver"
550 depends on MACH_DECSTATION && 32BIT 269 depends on MACH_DECSTATION && 32BIT
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index f5b01f2ce525..fef32e10c851 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -14,22 +14,9 @@ obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o
14obj-$(CONFIG_SERIAL_SUNSU) += sunsu.o 14obj-$(CONFIG_SERIAL_SUNSU) += sunsu.o
15obj-$(CONFIG_SERIAL_SUNSAB) += sunsab.o 15obj-$(CONFIG_SERIAL_SUNSAB) += sunsab.o
16 16
17obj-$(CONFIG_SERIAL_8250) += 8250.o 17# Now bring in any enabled 8250/16450/16550 type drivers.
18obj-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o 18obj-$(CONFIG_SERIAL_8250) += 8250/
19obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o 19
20obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o
21obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o
22obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o
23obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o
24obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
25obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
26obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
27obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
28obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
29obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
30obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
31obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o
32obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o
33obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o 20obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
34obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o 21obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
35obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o 22obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
@@ -42,7 +29,6 @@ obj-$(CONFIG_SERIAL_BFIN_SPORT) += bfin_sport_uart.o
42obj-$(CONFIG_SERIAL_SAMSUNG) += samsung.o 29obj-$(CONFIG_SERIAL_SAMSUNG) += samsung.o
43obj-$(CONFIG_SERIAL_MAX3100) += max3100.o 30obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
44obj-$(CONFIG_SERIAL_MAX3107) += max3107.o 31obj-$(CONFIG_SERIAL_MAX3107) += max3107.o
45obj-$(CONFIG_SERIAL_MAX3107_AAVA) += max3107-aava.o
46obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o 32obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
47obj-$(CONFIG_SERIAL_MUX) += mux.o 33obj-$(CONFIG_SERIAL_MUX) += mux.o
48obj-$(CONFIG_SERIAL_68328) += 68328serial.o 34obj-$(CONFIG_SERIAL_68328) += 68328serial.o
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 9ae024025ff3..6800f5f26241 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -159,6 +159,7 @@ struct uart_amba_port {
159 unsigned int fifosize; /* vendor-specific */ 159 unsigned int fifosize; /* vendor-specific */
160 unsigned int lcrh_tx; /* vendor-specific */ 160 unsigned int lcrh_tx; /* vendor-specific */
161 unsigned int lcrh_rx; /* vendor-specific */ 161 unsigned int lcrh_rx; /* vendor-specific */
162 unsigned int old_cr; /* state during shutdown */
162 bool autorts; 163 bool autorts;
163 char type[12]; 164 char type[12];
164 bool interrupt_may_hang; /* vendor-specific */ 165 bool interrupt_may_hang; /* vendor-specific */
@@ -1411,7 +1412,9 @@ static int pl011_startup(struct uart_port *port)
1411 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY) 1412 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
1412 barrier(); 1413 barrier();
1413 1414
1414 cr = UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE; 1415 /* restore RTS and DTR */
1416 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR);
1417 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE;
1415 writew(cr, uap->port.membase + UART011_CR); 1418 writew(cr, uap->port.membase + UART011_CR);
1416 1419
1417 /* Clear pending error interrupts */ 1420 /* Clear pending error interrupts */
@@ -1469,6 +1472,7 @@ static void pl011_shutdown_channel(struct uart_amba_port *uap,
1469static void pl011_shutdown(struct uart_port *port) 1472static void pl011_shutdown(struct uart_port *port)
1470{ 1473{
1471 struct uart_amba_port *uap = (struct uart_amba_port *)port; 1474 struct uart_amba_port *uap = (struct uart_amba_port *)port;
1475 unsigned int cr;
1472 1476
1473 /* 1477 /*
1474 * disable all interrupts 1478 * disable all interrupts
@@ -1488,9 +1492,16 @@ static void pl011_shutdown(struct uart_port *port)
1488 1492
1489 /* 1493 /*
1490 * disable the port 1494 * disable the port
1495 * disable the port. It should not disable RTS and DTR.
1496 * Also RTS and DTR state should be preserved to restore
1497 * it during startup().
1491 */ 1498 */
1492 uap->autorts = false; 1499 uap->autorts = false;
1493 writew(UART01x_CR_UARTEN | UART011_CR_TXE, uap->port.membase + UART011_CR); 1500 cr = readw(uap->port.membase + UART011_CR);
1501 uap->old_cr = cr;
1502 cr &= UART011_CR_RTS | UART011_CR_DTR;
1503 cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
1504 writew(cr, uap->port.membase + UART011_CR);
1494 1505
1495 /* 1506 /*
1496 * disable break condition and fifos 1507 * disable break condition and fifos
@@ -1740,9 +1751,19 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
1740{ 1751{
1741 struct uart_amba_port *uap = amba_ports[co->index]; 1752 struct uart_amba_port *uap = amba_ports[co->index];
1742 unsigned int status, old_cr, new_cr; 1753 unsigned int status, old_cr, new_cr;
1754 unsigned long flags;
1755 int locked = 1;
1743 1756
1744 clk_enable(uap->clk); 1757 clk_enable(uap->clk);
1745 1758
1759 local_irq_save(flags);
1760 if (uap->port.sysrq)
1761 locked = 0;
1762 else if (oops_in_progress)
1763 locked = spin_trylock(&uap->port.lock);
1764 else
1765 spin_lock(&uap->port.lock);
1766
1746 /* 1767 /*
1747 * First save the CR then disable the interrupts 1768 * First save the CR then disable the interrupts
1748 */ 1769 */
@@ -1762,6 +1783,10 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
1762 } while (status & UART01x_FR_BUSY); 1783 } while (status & UART01x_FR_BUSY);
1763 writew(old_cr, uap->port.membase + UART011_CR); 1784 writew(old_cr, uap->port.membase + UART011_CR);
1764 1785
1786 if (locked)
1787 spin_unlock(&uap->port.lock);
1788 local_irq_restore(flags);
1789
1765 clk_disable(uap->clk); 1790 clk_disable(uap->clk);
1766} 1791}
1767 1792
@@ -1905,6 +1930,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1905 uap->vendor = vendor; 1930 uap->vendor = vendor;
1906 uap->lcrh_rx = vendor->lcrh_rx; 1931 uap->lcrh_rx = vendor->lcrh_rx;
1907 uap->lcrh_tx = vendor->lcrh_tx; 1932 uap->lcrh_tx = vendor->lcrh_tx;
1933 uap->old_cr = 0;
1908 uap->fifosize = vendor->fifosize; 1934 uap->fifosize = vendor->fifosize;
1909 uap->interrupt_may_hang = vendor->interrupt_may_hang; 1935 uap->interrupt_may_hang = vendor->interrupt_may_hang;
1910 uap->port.dev = &dev->dev; 1936 uap->port.dev = &dev->dev;
diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
index 7c867a046c97..7545fe1b9925 100644
--- a/drivers/tty/serial/jsm/jsm_driver.c
+++ b/drivers/tty/serial/jsm/jsm_driver.c
@@ -251,6 +251,7 @@ static void jsm_io_resume(struct pci_dev *pdev)
251 struct jsm_board *brd = pci_get_drvdata(pdev); 251 struct jsm_board *brd = pci_get_drvdata(pdev);
252 252
253 pci_restore_state(pdev); 253 pci_restore_state(pdev);
254 pci_save_state(pdev);
254 255
255 jsm_uart_port_init(brd); 256 jsm_uart_port_init(brd);
256} 257}
diff --git a/drivers/tty/serial/max3107-aava.c b/drivers/tty/serial/max3107-aava.c
deleted file mode 100644
index aae772a71de6..000000000000
--- a/drivers/tty/serial/max3107-aava.c
+++ /dev/null
@@ -1,344 +0,0 @@
1/*
2 * max3107.c - spi uart protocol driver for Maxim 3107
3 * Based on max3100.c
4 * by Christian Pellegrin <chripell@evolware.org>
5 * and max3110.c
6 * by Feng Tang <feng.tang@intel.com>
7 *
8 * Copyright (C) Aavamobile 2009
9 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 *
28 */
29
30#include <linux/delay.h>
31#include <linux/device.h>
32#include <linux/serial_core.h>
33#include <linux/serial.h>
34#include <linux/spi/spi.h>
35#include <linux/freezer.h>
36#include <linux/platform_device.h>
37#include <linux/gpio.h>
38#include <linux/sfi.h>
39#include <linux/module.h>
40#include <asm/mrst.h>
41#include "max3107.h"
42
43/* GPIO direction to input function */
44static int max3107_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
45{
46 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
47 u16 buf[1]; /* Buffer for SPI transfer */
48
49 if (offset >= MAX3107_GPIO_COUNT) {
50 dev_err(&s->spi->dev, "Invalid GPIO\n");
51 return -EINVAL;
52 }
53
54 /* Read current GPIO configuration register */
55 buf[0] = MAX3107_GPIOCFG_REG;
56 /* Perform SPI transfer */
57 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 2)) {
58 dev_err(&s->spi->dev, "SPI transfer GPIO read failed\n");
59 return -EIO;
60 }
61 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
62
63 /* Set GPIO to input */
64 buf[0] &= ~(0x0001 << offset);
65
66 /* Write new GPIO configuration register value */
67 buf[0] |= (MAX3107_WRITE_BIT | MAX3107_GPIOCFG_REG);
68 /* Perform SPI transfer */
69 if (max3107_rw(s, (u8 *)buf, NULL, 2)) {
70 dev_err(&s->spi->dev, "SPI transfer GPIO write failed\n");
71 return -EIO;
72 }
73 return 0;
74}
75
76/* GPIO direction to output function */
77static int max3107_gpio_direction_out(struct gpio_chip *chip, unsigned offset,
78 int value)
79{
80 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
81 u16 buf[2]; /* Buffer for SPI transfers */
82
83 if (offset >= MAX3107_GPIO_COUNT) {
84 dev_err(&s->spi->dev, "Invalid GPIO\n");
85 return -EINVAL;
86 }
87
88 /* Read current GPIO configuration and data registers */
89 buf[0] = MAX3107_GPIOCFG_REG;
90 buf[1] = MAX3107_GPIODATA_REG;
91 /* Perform SPI transfer */
92 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 4)) {
93 dev_err(&s->spi->dev, "SPI transfer gpio failed\n");
94 return -EIO;
95 }
96 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
97 buf[1] &= MAX3107_SPI_RX_DATA_MASK;
98
99 /* Set GPIO to output */
100 buf[0] |= (0x0001 << offset);
101 /* Set value */
102 if (value)
103 buf[1] |= (0x0001 << offset);
104 else
105 buf[1] &= ~(0x0001 << offset);
106
107 /* Write new GPIO configuration and data register values */
108 buf[0] |= (MAX3107_WRITE_BIT | MAX3107_GPIOCFG_REG);
109 buf[1] |= (MAX3107_WRITE_BIT | MAX3107_GPIODATA_REG);
110 /* Perform SPI transfer */
111 if (max3107_rw(s, (u8 *)buf, NULL, 4)) {
112 dev_err(&s->spi->dev,
113 "SPI transfer for GPIO conf data w failed\n");
114 return -EIO;
115 }
116 return 0;
117}
118
119/* GPIO value query function */
120static int max3107_gpio_get(struct gpio_chip *chip, unsigned offset)
121{
122 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
123 u16 buf[1]; /* Buffer for SPI transfer */
124
125 if (offset >= MAX3107_GPIO_COUNT) {
126 dev_err(&s->spi->dev, "Invalid GPIO\n");
127 return -EINVAL;
128 }
129
130 /* Read current GPIO data register */
131 buf[0] = MAX3107_GPIODATA_REG;
132 /* Perform SPI transfer */
133 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 2)) {
134 dev_err(&s->spi->dev, "SPI transfer GPIO data r failed\n");
135 return -EIO;
136 }
137 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
138
139 /* Return value */
140 return buf[0] & (0x0001 << offset);
141}
142
143/* GPIO value set function */
144static void max3107_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
145{
146 struct max3107_port *s = container_of(chip, struct max3107_port, chip);
147 u16 buf[2]; /* Buffer for SPI transfers */
148
149 if (offset >= MAX3107_GPIO_COUNT) {
150 dev_err(&s->spi->dev, "Invalid GPIO\n");
151 return;
152 }
153
154 /* Read current GPIO configuration registers*/
155 buf[0] = MAX3107_GPIODATA_REG;
156 buf[1] = MAX3107_GPIOCFG_REG;
157 /* Perform SPI transfer */
158 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 4)) {
159 dev_err(&s->spi->dev,
160 "SPI transfer for GPIO data and config read failed\n");
161 return;
162 }
163 buf[0] &= MAX3107_SPI_RX_DATA_MASK;
164 buf[1] &= MAX3107_SPI_RX_DATA_MASK;
165
166 if (!(buf[1] & (0x0001 << offset))) {
167 /* Configured as input, can't set value */
168 dev_warn(&s->spi->dev,
169 "Trying to set value for input GPIO\n");
170 return;
171 }
172
173 /* Set value */
174 if (value)
175 buf[0] |= (0x0001 << offset);
176 else
177 buf[0] &= ~(0x0001 << offset);
178
179 /* Write new GPIO data register value */
180 buf[0] |= (MAX3107_WRITE_BIT | MAX3107_GPIODATA_REG);
181 /* Perform SPI transfer */
182 if (max3107_rw(s, (u8 *)buf, NULL, 2))
183 dev_err(&s->spi->dev, "SPI transfer GPIO data w failed\n");
184}
185
186/* GPIO chip data */
187static struct gpio_chip max3107_gpio_chip = {
188 .owner = THIS_MODULE,
189 .direction_input = max3107_gpio_direction_in,
190 .direction_output = max3107_gpio_direction_out,
191 .get = max3107_gpio_get,
192 .set = max3107_gpio_set,
193 .can_sleep = 1,
194 .base = MAX3107_GPIO_BASE,
195 .ngpio = MAX3107_GPIO_COUNT,
196};
197
198/**
199 * max3107_aava_reset - reset on AAVA systems
200 * @spi: The SPI device we are probing
201 *
202 * Reset the device ready for probing.
203 */
204
205static int max3107_aava_reset(struct spi_device *spi)
206{
207 /* Reset the chip */
208 if (gpio_request(MAX3107_RESET_GPIO, "max3107")) {
209 pr_err("Requesting RESET GPIO failed\n");
210 return -EIO;
211 }
212 if (gpio_direction_output(MAX3107_RESET_GPIO, 0)) {
213 pr_err("Setting RESET GPIO to 0 failed\n");
214 gpio_free(MAX3107_RESET_GPIO);
215 return -EIO;
216 }
217 msleep(MAX3107_RESET_DELAY);
218 if (gpio_direction_output(MAX3107_RESET_GPIO, 1)) {
219 pr_err("Setting RESET GPIO to 1 failed\n");
220 gpio_free(MAX3107_RESET_GPIO);
221 return -EIO;
222 }
223 gpio_free(MAX3107_RESET_GPIO);
224 msleep(MAX3107_WAKEUP_DELAY);
225 return 0;
226}
227
228static int max3107_aava_configure(struct max3107_port *s)
229{
230 int retval;
231
232 /* Initialize GPIO chip data */
233 s->chip = max3107_gpio_chip;
234 s->chip.label = s->spi->modalias;
235 s->chip.dev = &s->spi->dev;
236
237 /* Add GPIO chip */
238 retval = gpiochip_add(&s->chip);
239 if (retval) {
240 dev_err(&s->spi->dev, "Adding GPIO chip failed\n");
241 return retval;
242 }
243
244 /* Temporary fix for EV2 boot problems, set modem reset to 0 */
245 max3107_gpio_direction_out(&s->chip, 3, 0);
246 return 0;
247}
248
249#if 0
250/* This will get enabled once we have the board stuff merged for this
251 specific case */
252
253static const struct baud_table brg13_ext[] = {
254 { 300, MAX3107_BRG13_B300 },
255 { 600, MAX3107_BRG13_B600 },
256 { 1200, MAX3107_BRG13_B1200 },
257 { 2400, MAX3107_BRG13_B2400 },
258 { 4800, MAX3107_BRG13_B4800 },
259 { 9600, MAX3107_BRG13_B9600 },
260 { 19200, MAX3107_BRG13_B19200 },
261 { 57600, MAX3107_BRG13_B57600 },
262 { 115200, MAX3107_BRG13_B115200 },
263 { 230400, MAX3107_BRG13_B230400 },
264 { 460800, MAX3107_BRG13_B460800 },
265 { 921600, MAX3107_BRG13_B921600 },
266 { 0, 0 }
267};
268
269static void max3107_aava_init(struct max3107_port *s)
270{
271 /*override for AAVA SC specific*/
272 if (mrst_platform_id() == MRST_PLATFORM_AAVA_SC) {
273 if (get_koski_build_id() <= KOSKI_EV2)
274 if (s->ext_clk) {
275 s->brg_cfg = MAX3107_BRG13_B9600;
276 s->baud_tbl = (struct baud_table *)brg13_ext;
277 }
278 }
279}
280#endif
281
282static int __devexit max3107_aava_remove(struct spi_device *spi)
283{
284 struct max3107_port *s = dev_get_drvdata(&spi->dev);
285
286 /* Remove GPIO chip */
287 if (gpiochip_remove(&s->chip))
288 dev_warn(&spi->dev, "Removing GPIO chip failed\n");
289
290 /* Then do the default remove */
291 return max3107_remove(spi);
292}
293
294/* Platform data */
295static struct max3107_plat aava_plat_data = {
296 .loopback = 0,
297 .ext_clk = 1,
298/* .init = max3107_aava_init, */
299 .configure = max3107_aava_configure,
300 .hw_suspend = max3107_hw_susp,
301 .polled_mode = 0,
302 .poll_time = 0,
303};
304
305
306static int __devinit max3107_probe_aava(struct spi_device *spi)
307{
308 int err = max3107_aava_reset(spi);
309 if (err < 0)
310 return err;
311 return max3107_probe(spi, &aava_plat_data);
312}
313
314/* Spi driver data */
315static struct spi_driver max3107_driver = {
316 .driver = {
317 .name = "aava-max3107",
318 .owner = THIS_MODULE,
319 },
320 .probe = max3107_probe_aava,
321 .remove = __devexit_p(max3107_aava_remove),
322 .suspend = max3107_suspend,
323 .resume = max3107_resume,
324};
325
326/* Driver init function */
327static int __init max3107_init(void)
328{
329 return spi_register_driver(&max3107_driver);
330}
331
332/* Driver exit function */
333static void __exit max3107_exit(void)
334{
335 spi_unregister_driver(&max3107_driver);
336}
337
338module_init(max3107_init);
339module_exit(max3107_exit);
340
341MODULE_DESCRIPTION("MAX3107 driver");
342MODULE_AUTHOR("Aavamobile");
343MODULE_ALIAS("spi:aava-max3107");
344MODULE_LICENSE("GPL v2");
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index d192dcbb82f5..1c2426931484 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1160,7 +1160,7 @@ static struct uart_driver serial_omap_reg = {
1160 .cons = OMAP_CONSOLE, 1160 .cons = OMAP_CONSOLE,
1161}; 1161};
1162 1162
1163#ifdef CONFIG_SUSPEND 1163#ifdef CONFIG_PM_SLEEP
1164static int serial_omap_suspend(struct device *dev) 1164static int serial_omap_suspend(struct device *dev)
1165{ 1165{
1166 struct uart_omap_port *up = dev_get_drvdata(dev); 1166 struct uart_omap_port *up = dev_get_drvdata(dev);
@@ -1521,6 +1521,7 @@ static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1)
1521 } 1521 }
1522} 1522}
1523 1523
1524#ifdef CONFIG_PM_RUNTIME
1524static void serial_omap_restore_context(struct uart_omap_port *up) 1525static void serial_omap_restore_context(struct uart_omap_port *up)
1525{ 1526{
1526 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) 1527 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS)
@@ -1550,7 +1551,6 @@ static void serial_omap_restore_context(struct uart_omap_port *up)
1550 serial_out(up, UART_OMAP_MDR1, up->mdr1); 1551 serial_out(up, UART_OMAP_MDR1, up->mdr1);
1551} 1552}
1552 1553
1553#ifdef CONFIG_PM_RUNTIME
1554static int serial_omap_runtime_suspend(struct device *dev) 1554static int serial_omap_runtime_suspend(struct device *dev)
1555{ 1555{
1556 struct uart_omap_port *up = dev_get_drvdata(dev); 1556 struct uart_omap_port *up = dev_get_drvdata(dev);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c7bf31a6a7e7..13056180adf5 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2348,11 +2348,11 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
2348 */ 2348 */
2349 tty_dev = tty_register_device(drv->tty_driver, uport->line, uport->dev); 2349 tty_dev = tty_register_device(drv->tty_driver, uport->line, uport->dev);
2350 if (likely(!IS_ERR(tty_dev))) { 2350 if (likely(!IS_ERR(tty_dev))) {
2351 device_init_wakeup(tty_dev, 1); 2351 device_set_wakeup_capable(tty_dev, 1);
2352 device_set_wakeup_enable(tty_dev, 0); 2352 } else {
2353 } else
2354 printk(KERN_ERR "Cannot register tty device on line %d\n", 2353 printk(KERN_ERR "Cannot register tty device on line %d\n",
2355 uport->line); 2354 uport->line);
2355 }
2356 2356
2357 /* 2357 /*
2358 * Ensure UPF_DEAD is not set. 2358 * Ensure UPF_DEAD is not set.
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index ef9dd628ba0b..bf6e238146ae 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -227,7 +227,6 @@ int tty_port_block_til_ready(struct tty_port *port,
227 int do_clocal = 0, retval; 227 int do_clocal = 0, retval;
228 unsigned long flags; 228 unsigned long flags;
229 DEFINE_WAIT(wait); 229 DEFINE_WAIT(wait);
230 int cd;
231 230
232 /* block if port is in the process of being closed */ 231 /* block if port is in the process of being closed */
233 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { 232 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
@@ -284,11 +283,14 @@ int tty_port_block_til_ready(struct tty_port *port,
284 retval = -ERESTARTSYS; 283 retval = -ERESTARTSYS;
285 break; 284 break;
286 } 285 }
287 /* Probe the carrier. For devices with no carrier detect this 286 /*
288 will always return true */ 287 * Probe the carrier. For devices with no carrier detect
289 cd = tty_port_carrier_raised(port); 288 * tty_port_carrier_raised will always return true.
289 * Never ask drivers if CLOCAL is set, this causes troubles
290 * on some hardware.
291 */
290 if (!(port->flags & ASYNC_CLOSING) && 292 if (!(port->flags & ASYNC_CLOSING) &&
291 (do_clocal || cd)) 293 (do_clocal || tty_port_carrier_raised(port)))
292 break; 294 break;
293 if (signal_pending(current)) { 295 if (signal_pending(current)) {
294 retval = -ERESTARTSYS; 296 retval = -ERESTARTSYS;
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 1c50baff7725..d2b3cffca3f7 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -57,6 +57,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
57 57
58#define WDM_MAX 16 58#define WDM_MAX 16
59 59
60/* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */
61#define WDM_DEFAULT_BUFSIZE 256
60 62
61static DEFINE_MUTEX(wdm_mutex); 63static DEFINE_MUTEX(wdm_mutex);
62 64
@@ -88,7 +90,8 @@ struct wdm_device {
88 int count; 90 int count;
89 dma_addr_t shandle; 91 dma_addr_t shandle;
90 dma_addr_t ihandle; 92 dma_addr_t ihandle;
91 struct mutex lock; 93 struct mutex wlock;
94 struct mutex rlock;
92 wait_queue_head_t wait; 95 wait_queue_head_t wait;
93 struct work_struct rxwork; 96 struct work_struct rxwork;
94 int werr; 97 int werr;
@@ -323,7 +326,7 @@ static ssize_t wdm_write
323 } 326 }
324 327
325 /* concurrent writes and disconnect */ 328 /* concurrent writes and disconnect */
326 r = mutex_lock_interruptible(&desc->lock); 329 r = mutex_lock_interruptible(&desc->wlock);
327 rv = -ERESTARTSYS; 330 rv = -ERESTARTSYS;
328 if (r) { 331 if (r) {
329 kfree(buf); 332 kfree(buf);
@@ -386,7 +389,7 @@ static ssize_t wdm_write
386out: 389out:
387 usb_autopm_put_interface(desc->intf); 390 usb_autopm_put_interface(desc->intf);
388outnp: 391outnp:
389 mutex_unlock(&desc->lock); 392 mutex_unlock(&desc->wlock);
390outnl: 393outnl:
391 return rv < 0 ? rv : count; 394 return rv < 0 ? rv : count;
392} 395}
@@ -399,7 +402,7 @@ static ssize_t wdm_read
399 struct wdm_device *desc = file->private_data; 402 struct wdm_device *desc = file->private_data;
400 403
401 404
402 rv = mutex_lock_interruptible(&desc->lock); /*concurrent reads */ 405 rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
403 if (rv < 0) 406 if (rv < 0)
404 return -ERESTARTSYS; 407 return -ERESTARTSYS;
405 408
@@ -467,14 +470,16 @@ retry:
467 for (i = 0; i < desc->length - cntr; i++) 470 for (i = 0; i < desc->length - cntr; i++)
468 desc->ubuf[i] = desc->ubuf[i + cntr]; 471 desc->ubuf[i] = desc->ubuf[i + cntr];
469 472
473 spin_lock_irq(&desc->iuspin);
470 desc->length -= cntr; 474 desc->length -= cntr;
475 spin_unlock_irq(&desc->iuspin);
471 /* in case we had outstanding data */ 476 /* in case we had outstanding data */
472 if (!desc->length) 477 if (!desc->length)
473 clear_bit(WDM_READ, &desc->flags); 478 clear_bit(WDM_READ, &desc->flags);
474 rv = cntr; 479 rv = cntr;
475 480
476err: 481err:
477 mutex_unlock(&desc->lock); 482 mutex_unlock(&desc->rlock);
478 return rv; 483 return rv;
479} 484}
480 485
@@ -540,7 +545,8 @@ static int wdm_open(struct inode *inode, struct file *file)
540 } 545 }
541 intf->needs_remote_wakeup = 1; 546 intf->needs_remote_wakeup = 1;
542 547
543 mutex_lock(&desc->lock); 548 /* using write lock to protect desc->count */
549 mutex_lock(&desc->wlock);
544 if (!desc->count++) { 550 if (!desc->count++) {
545 desc->werr = 0; 551 desc->werr = 0;
546 desc->rerr = 0; 552 desc->rerr = 0;
@@ -553,7 +559,7 @@ static int wdm_open(struct inode *inode, struct file *file)
553 } else { 559 } else {
554 rv = 0; 560 rv = 0;
555 } 561 }
556 mutex_unlock(&desc->lock); 562 mutex_unlock(&desc->wlock);
557 usb_autopm_put_interface(desc->intf); 563 usb_autopm_put_interface(desc->intf);
558out: 564out:
559 mutex_unlock(&wdm_mutex); 565 mutex_unlock(&wdm_mutex);
@@ -565,9 +571,11 @@ static int wdm_release(struct inode *inode, struct file *file)
565 struct wdm_device *desc = file->private_data; 571 struct wdm_device *desc = file->private_data;
566 572
567 mutex_lock(&wdm_mutex); 573 mutex_lock(&wdm_mutex);
568 mutex_lock(&desc->lock); 574
575 /* using write lock to protect desc->count */
576 mutex_lock(&desc->wlock);
569 desc->count--; 577 desc->count--;
570 mutex_unlock(&desc->lock); 578 mutex_unlock(&desc->wlock);
571 579
572 if (!desc->count) { 580 if (!desc->count) {
573 dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); 581 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
@@ -630,7 +638,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
630 struct usb_cdc_dmm_desc *dmhd; 638 struct usb_cdc_dmm_desc *dmhd;
631 u8 *buffer = intf->altsetting->extra; 639 u8 *buffer = intf->altsetting->extra;
632 int buflen = intf->altsetting->extralen; 640 int buflen = intf->altsetting->extralen;
633 u16 maxcom = 0; 641 u16 maxcom = WDM_DEFAULT_BUFSIZE;
634 642
635 if (!buffer) 643 if (!buffer)
636 goto out; 644 goto out;
@@ -665,7 +673,8 @@ next_desc:
665 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); 673 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
666 if (!desc) 674 if (!desc)
667 goto out; 675 goto out;
668 mutex_init(&desc->lock); 676 mutex_init(&desc->rlock);
677 mutex_init(&desc->wlock);
669 spin_lock_init(&desc->iuspin); 678 spin_lock_init(&desc->iuspin);
670 init_waitqueue_head(&desc->wait); 679 init_waitqueue_head(&desc->wait);
671 desc->wMaxCommand = maxcom; 680 desc->wMaxCommand = maxcom;
@@ -716,7 +725,7 @@ next_desc:
716 goto err; 725 goto err;
717 726
718 desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), 727 desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf),
719 desc->bMaxPacketSize0, 728 desc->wMaxCommand,
720 GFP_KERNEL, 729 GFP_KERNEL,
721 &desc->response->transfer_dma); 730 &desc->response->transfer_dma);
722 if (!desc->inbuf) 731 if (!desc->inbuf)
@@ -779,11 +788,13 @@ static void wdm_disconnect(struct usb_interface *intf)
779 /* to terminate pending flushes */ 788 /* to terminate pending flushes */
780 clear_bit(WDM_IN_USE, &desc->flags); 789 clear_bit(WDM_IN_USE, &desc->flags);
781 spin_unlock_irqrestore(&desc->iuspin, flags); 790 spin_unlock_irqrestore(&desc->iuspin, flags);
782 mutex_lock(&desc->lock); 791 wake_up_all(&desc->wait);
792 mutex_lock(&desc->rlock);
793 mutex_lock(&desc->wlock);
783 kill_urbs(desc); 794 kill_urbs(desc);
784 cancel_work_sync(&desc->rxwork); 795 cancel_work_sync(&desc->rxwork);
785 mutex_unlock(&desc->lock); 796 mutex_unlock(&desc->wlock);
786 wake_up_all(&desc->wait); 797 mutex_unlock(&desc->rlock);
787 if (!desc->count) 798 if (!desc->count)
788 cleanup(desc); 799 cleanup(desc);
789 mutex_unlock(&wdm_mutex); 800 mutex_unlock(&wdm_mutex);
@@ -798,8 +809,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
798 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); 809 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
799 810
800 /* if this is an autosuspend the caller does the locking */ 811 /* if this is an autosuspend the caller does the locking */
801 if (!PMSG_IS_AUTO(message)) 812 if (!PMSG_IS_AUTO(message)) {
802 mutex_lock(&desc->lock); 813 mutex_lock(&desc->rlock);
814 mutex_lock(&desc->wlock);
815 }
803 spin_lock_irq(&desc->iuspin); 816 spin_lock_irq(&desc->iuspin);
804 817
805 if (PMSG_IS_AUTO(message) && 818 if (PMSG_IS_AUTO(message) &&
@@ -815,8 +828,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
815 kill_urbs(desc); 828 kill_urbs(desc);
816 cancel_work_sync(&desc->rxwork); 829 cancel_work_sync(&desc->rxwork);
817 } 830 }
818 if (!PMSG_IS_AUTO(message)) 831 if (!PMSG_IS_AUTO(message)) {
819 mutex_unlock(&desc->lock); 832 mutex_unlock(&desc->wlock);
833 mutex_unlock(&desc->rlock);
834 }
820 835
821 return rv; 836 return rv;
822} 837}
@@ -854,7 +869,8 @@ static int wdm_pre_reset(struct usb_interface *intf)
854{ 869{
855 struct wdm_device *desc = usb_get_intfdata(intf); 870 struct wdm_device *desc = usb_get_intfdata(intf);
856 871
857 mutex_lock(&desc->lock); 872 mutex_lock(&desc->rlock);
873 mutex_lock(&desc->wlock);
858 kill_urbs(desc); 874 kill_urbs(desc);
859 875
860 /* 876 /*
@@ -876,7 +892,8 @@ static int wdm_post_reset(struct usb_interface *intf)
876 int rv; 892 int rv;
877 893
878 rv = recover_from_urb_loss(desc); 894 rv = recover_from_urb_loss(desc);
879 mutex_unlock(&desc->lock); 895 mutex_unlock(&desc->wlock);
896 mutex_unlock(&desc->rlock);
880 return 0; 897 return 0;
881} 898}
882 899
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 2f51de57593a..c8df1dd967ef 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -126,7 +126,6 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
126 struct dwc3_request *req) 126 struct dwc3_request *req)
127{ 127{
128 struct dwc3 *dwc = dep->dwc; 128 struct dwc3 *dwc = dep->dwc;
129 u32 type;
130 int ret = 0; 129 int ret = 0;
131 130
132 req->request.actual = 0; 131 req->request.actual = 0;
@@ -149,20 +148,14 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
149 148
150 direction = !!(dep->flags & DWC3_EP0_DIR_IN); 149 direction = !!(dep->flags & DWC3_EP0_DIR_IN);
151 150
152 if (dwc->ep0state == EP0_STATUS_PHASE) { 151 if (dwc->ep0state != EP0_DATA_PHASE) {
153 type = dwc->three_stage_setup 152 dev_WARN(dwc->dev, "Unexpected pending request\n");
154 ? DWC3_TRBCTL_CONTROL_STATUS3
155 : DWC3_TRBCTL_CONTROL_STATUS2;
156 } else if (dwc->ep0state == EP0_DATA_PHASE) {
157 type = DWC3_TRBCTL_CONTROL_DATA;
158 } else {
159 /* should never happen */
160 WARN_ON(1);
161 return 0; 153 return 0;
162 } 154 }
163 155
164 ret = dwc3_ep0_start_trans(dwc, direction, 156 ret = dwc3_ep0_start_trans(dwc, direction,
165 req->request.dma, req->request.length, type); 157 req->request.dma, req->request.length,
158 DWC3_TRBCTL_CONTROL_DATA);
166 dep->flags &= ~(DWC3_EP_PENDING_REQUEST | 159 dep->flags &= ~(DWC3_EP_PENDING_REQUEST |
167 DWC3_EP0_DIR_IN); 160 DWC3_EP0_DIR_IN);
168 } else if (dwc->delayed_status) { 161 } else if (dwc->delayed_status) {
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a696bde53222..064b6e2cd411 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -101,7 +101,7 @@ void dwc3_unmap_buffer_from_dma(struct dwc3_request *req)
101 if (req->request.num_mapped_sgs) { 101 if (req->request.num_mapped_sgs) {
102 req->request.dma = DMA_ADDR_INVALID; 102 req->request.dma = DMA_ADDR_INVALID;
103 dma_unmap_sg(dwc->dev, req->request.sg, 103 dma_unmap_sg(dwc->dev, req->request.sg,
104 req->request.num_sgs, 104 req->request.num_mapped_sgs,
105 req->direction ? DMA_TO_DEVICE 105 req->direction ? DMA_TO_DEVICE
106 : DMA_FROM_DEVICE); 106 : DMA_FROM_DEVICE);
107 107
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a95de6a4a134..baaebf2830fc 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -175,13 +175,12 @@ ep_found:
175 _ep->comp_desc = comp_desc; 175 _ep->comp_desc = comp_desc;
176 if (g->speed == USB_SPEED_SUPER) { 176 if (g->speed == USB_SPEED_SUPER) {
177 switch (usb_endpoint_type(_ep->desc)) { 177 switch (usb_endpoint_type(_ep->desc)) {
178 case USB_ENDPOINT_XFER_BULK:
179 case USB_ENDPOINT_XFER_INT:
180 _ep->maxburst = comp_desc->bMaxBurst;
181 break;
182 case USB_ENDPOINT_XFER_ISOC: 178 case USB_ENDPOINT_XFER_ISOC:
183 /* mult: bits 1:0 of bmAttributes */ 179 /* mult: bits 1:0 of bmAttributes */
184 _ep->mult = comp_desc->bmAttributes & 0x3; 180 _ep->mult = comp_desc->bmAttributes & 0x3;
181 case USB_ENDPOINT_XFER_BULK:
182 case USB_ENDPOINT_XFER_INT:
183 _ep->maxburst = comp_desc->bMaxBurst;
185 break; 184 break;
186 default: 185 default:
187 /* Do nothing for control endpoints */ 186 /* Do nothing for control endpoints */
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 753aa0683ac1..e0e6375ef5dd 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -126,7 +126,7 @@ ep_matches (
126 * descriptor and see if the EP matches it 126 * descriptor and see if the EP matches it
127 */ 127 */
128 if (usb_endpoint_xfer_bulk(desc)) { 128 if (usb_endpoint_xfer_bulk(desc)) {
129 if (ep_comp) { 129 if (ep_comp && gadget->max_speed >= USB_SPEED_SUPER) {
130 num_req_streams = ep_comp->bmAttributes & 0x1f; 130 num_req_streams = ep_comp->bmAttributes & 0x1f;
131 if (num_req_streams > ep->max_streams) 131 if (num_req_streams > ep->max_streams)
132 return 0; 132 return 0;
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 6353eca1e852..ee8ceec01560 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -3123,15 +3123,15 @@ fsg_add(struct usb_composite_dev *cdev, struct usb_configuration *c,
3123 3123
3124struct fsg_module_parameters { 3124struct fsg_module_parameters {
3125 char *file[FSG_MAX_LUNS]; 3125 char *file[FSG_MAX_LUNS];
3126 int ro[FSG_MAX_LUNS]; 3126 bool ro[FSG_MAX_LUNS];
3127 int removable[FSG_MAX_LUNS]; 3127 bool removable[FSG_MAX_LUNS];
3128 int cdrom[FSG_MAX_LUNS]; 3128 bool cdrom[FSG_MAX_LUNS];
3129 int nofua[FSG_MAX_LUNS]; 3129 bool nofua[FSG_MAX_LUNS];
3130 3130
3131 unsigned int file_count, ro_count, removable_count, cdrom_count; 3131 unsigned int file_count, ro_count, removable_count, cdrom_count;
3132 unsigned int nofua_count; 3132 unsigned int nofua_count;
3133 unsigned int luns; /* nluns */ 3133 unsigned int luns; /* nluns */
3134 int stall; /* can_stall */ 3134 bool stall; /* can_stall */
3135}; 3135};
3136 3136
3137#define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \ 3137#define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index d7ea6c076ce9..b04712f19f1e 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -1430,7 +1430,7 @@ static void setup_received_irq(struct fsl_udc *udc,
1430 int pipe = get_pipe_by_windex(wIndex); 1430 int pipe = get_pipe_by_windex(wIndex);
1431 struct fsl_ep *ep; 1431 struct fsl_ep *ep;
1432 1432
1433 if (wValue != 0 || wLength != 0 || pipe > udc->max_ep) 1433 if (wValue != 0 || wLength != 0 || pipe >= udc->max_ep)
1434 break; 1434 break;
1435 ep = get_ep_by_pipe(udc, pipe); 1435 ep = get_ep_by_pipe(udc, pipe);
1436 1436
@@ -1673,7 +1673,7 @@ static void dtd_complete_irq(struct fsl_udc *udc)
1673 if (!bit_pos) 1673 if (!bit_pos)
1674 return; 1674 return;
1675 1675
1676 for (i = 0; i < udc->max_ep * 2; i++) { 1676 for (i = 0; i < udc->max_ep; i++) {
1677 ep_num = i >> 1; 1677 ep_num = i >> 1;
1678 direction = i % 2; 1678 direction = i % 2;
1679 1679
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c
index fa0fcc11263f..e2293c1588ee 100644
--- a/drivers/usb/gadget/langwell_udc.c
+++ b/drivers/usb/gadget/langwell_udc.c
@@ -11,11 +11,6 @@
11/* #undef DEBUG */ 11/* #undef DEBUG */
12/* #undef VERBOSE_DEBUG */ 12/* #undef VERBOSE_DEBUG */
13 13
14#if defined(CONFIG_USB_LANGWELL_OTG)
15#define OTG_TRANSCEIVER
16#endif
17
18
19#include <linux/module.h> 14#include <linux/module.h>
20#include <linux/pci.h> 15#include <linux/pci.h>
21#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
@@ -1522,8 +1517,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
1522 1517
1523 1518
1524/* stop all USB activities */ 1519/* stop all USB activities */
1525static void stop_activity(struct langwell_udc *dev, 1520static void stop_activity(struct langwell_udc *dev)
1526 struct usb_gadget_driver *driver)
1527{ 1521{
1528 struct langwell_ep *ep; 1522 struct langwell_ep *ep;
1529 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); 1523 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
@@ -1535,9 +1529,9 @@ static void stop_activity(struct langwell_udc *dev,
1535 } 1529 }
1536 1530
1537 /* report disconnect; the driver is already quiesced */ 1531 /* report disconnect; the driver is already quiesced */
1538 if (driver) { 1532 if (dev->driver) {
1539 spin_unlock(&dev->lock); 1533 spin_unlock(&dev->lock);
1540 driver->disconnect(&dev->gadget); 1534 dev->driver->disconnect(&dev->gadget);
1541 spin_lock(&dev->lock); 1535 spin_lock(&dev->lock);
1542 } 1536 }
1543 1537
@@ -1925,11 +1919,10 @@ static int langwell_stop(struct usb_gadget *g,
1925 1919
1926 /* stop all usb activities */ 1920 /* stop all usb activities */
1927 dev->gadget.speed = USB_SPEED_UNKNOWN; 1921 dev->gadget.speed = USB_SPEED_UNKNOWN;
1928 stop_activity(dev, driver);
1929 spin_unlock_irqrestore(&dev->lock, flags);
1930
1931 dev->gadget.dev.driver = NULL; 1922 dev->gadget.dev.driver = NULL;
1932 dev->driver = NULL; 1923 dev->driver = NULL;
1924 stop_activity(dev);
1925 spin_unlock_irqrestore(&dev->lock, flags);
1933 1926
1934 device_remove_file(&dev->pdev->dev, &dev_attr_function); 1927 device_remove_file(&dev->pdev->dev, &dev_attr_function);
1935 1928
@@ -2315,13 +2308,9 @@ static void handle_setup_packet(struct langwell_udc *dev,
2315 2308
2316 if (!gadget_is_otg(&dev->gadget)) 2309 if (!gadget_is_otg(&dev->gadget))
2317 break; 2310 break;
2318 else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) { 2311 else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE)
2319 dev->gadget.b_hnp_enable = 1; 2312 dev->gadget.b_hnp_enable = 1;
2320#ifdef OTG_TRANSCEIVER 2313 else if (setup->bRequest == USB_DEVICE_A_HNP_SUPPORT)
2321 if (!dev->lotg->otg.default_a)
2322 dev->lotg->hsm.b_hnp_enable = 1;
2323#endif
2324 } else if (setup->bRequest == USB_DEVICE_A_HNP_SUPPORT)
2325 dev->gadget.a_hnp_support = 1; 2314 dev->gadget.a_hnp_support = 1;
2326 else if (setup->bRequest == 2315 else if (setup->bRequest ==
2327 USB_DEVICE_A_ALT_HNP_SUPPORT) 2316 USB_DEVICE_A_ALT_HNP_SUPPORT)
@@ -2733,7 +2722,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2733 dev->bus_reset = 1; 2722 dev->bus_reset = 1;
2734 2723
2735 /* reset all the queues, stop all USB activities */ 2724 /* reset all the queues, stop all USB activities */
2736 stop_activity(dev, dev->driver); 2725 stop_activity(dev);
2737 dev->usb_state = USB_STATE_DEFAULT; 2726 dev->usb_state = USB_STATE_DEFAULT;
2738 } else { 2727 } else {
2739 dev_vdbg(&dev->pdev->dev, "device controller reset\n"); 2728 dev_vdbg(&dev->pdev->dev, "device controller reset\n");
@@ -2741,7 +2730,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2741 langwell_udc_reset(dev); 2730 langwell_udc_reset(dev);
2742 2731
2743 /* reset all the queues, stop all USB activities */ 2732 /* reset all the queues, stop all USB activities */
2744 stop_activity(dev, dev->driver); 2733 stop_activity(dev);
2745 2734
2746 /* reset ep0 dQH and endptctrl */ 2735 /* reset ep0 dQH and endptctrl */
2747 ep0_reset(dev); 2736 ep0_reset(dev);
@@ -2752,12 +2741,6 @@ static void handle_usb_reset(struct langwell_udc *dev)
2752 dev->usb_state = USB_STATE_ATTACHED; 2741 dev->usb_state = USB_STATE_ATTACHED;
2753 } 2742 }
2754 2743
2755#ifdef OTG_TRANSCEIVER
2756 /* refer to USB OTG 6.6.2.3 b_hnp_en is cleared */
2757 if (!dev->lotg->otg.default_a)
2758 dev->lotg->hsm.b_hnp_enable = 0;
2759#endif
2760
2761 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); 2744 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2762} 2745}
2763 2746
@@ -2770,29 +2753,6 @@ static void handle_bus_suspend(struct langwell_udc *dev)
2770 dev->resume_state = dev->usb_state; 2753 dev->resume_state = dev->usb_state;
2771 dev->usb_state = USB_STATE_SUSPENDED; 2754 dev->usb_state = USB_STATE_SUSPENDED;
2772 2755
2773#ifdef OTG_TRANSCEIVER
2774 if (dev->lotg->otg.default_a) {
2775 if (dev->lotg->hsm.b_bus_suspend_vld == 1) {
2776 dev->lotg->hsm.b_bus_suspend = 1;
2777 /* notify transceiver the state changes */
2778 if (spin_trylock(&dev->lotg->wq_lock)) {
2779 langwell_update_transceiver();
2780 spin_unlock(&dev->lotg->wq_lock);
2781 }
2782 }
2783 dev->lotg->hsm.b_bus_suspend_vld++;
2784 } else {
2785 if (!dev->lotg->hsm.a_bus_suspend) {
2786 dev->lotg->hsm.a_bus_suspend = 1;
2787 /* notify transceiver the state changes */
2788 if (spin_trylock(&dev->lotg->wq_lock)) {
2789 langwell_update_transceiver();
2790 spin_unlock(&dev->lotg->wq_lock);
2791 }
2792 }
2793 }
2794#endif
2795
2796 /* report suspend to the driver */ 2756 /* report suspend to the driver */
2797 if (dev->driver) { 2757 if (dev->driver) {
2798 if (dev->driver->suspend) { 2758 if (dev->driver->suspend) {
@@ -2823,11 +2783,6 @@ static void handle_bus_resume(struct langwell_udc *dev)
2823 if (dev->pdev->device != 0x0829) 2783 if (dev->pdev->device != 0x0829)
2824 langwell_phy_low_power(dev, 0); 2784 langwell_phy_low_power(dev, 0);
2825 2785
2826#ifdef OTG_TRANSCEIVER
2827 if (dev->lotg->otg.default_a == 0)
2828 dev->lotg->hsm.a_bus_suspend = 0;
2829#endif
2830
2831 /* report resume to the driver */ 2786 /* report resume to the driver */
2832 if (dev->driver) { 2787 if (dev->driver) {
2833 if (dev->driver->resume) { 2788 if (dev->driver->resume) {
@@ -3020,7 +2975,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3020 2975
3021 dev->done = &done; 2976 dev->done = &done;
3022 2977
3023#ifndef OTG_TRANSCEIVER
3024 /* free dTD dma_pool and dQH */ 2978 /* free dTD dma_pool and dQH */
3025 if (dev->dtd_pool) 2979 if (dev->dtd_pool)
3026 dma_pool_destroy(dev->dtd_pool); 2980 dma_pool_destroy(dev->dtd_pool);
@@ -3032,7 +2986,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3032 /* release SRAM caching */ 2986 /* release SRAM caching */
3033 if (dev->has_sram && dev->got_sram) 2987 if (dev->has_sram && dev->got_sram)
3034 sram_deinit(dev); 2988 sram_deinit(dev);
3035#endif
3036 2989
3037 if (dev->status_req) { 2990 if (dev->status_req) {
3038 kfree(dev->status_req->req.buf); 2991 kfree(dev->status_req->req.buf);
@@ -3045,7 +2998,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3045 if (dev->got_irq) 2998 if (dev->got_irq)
3046 free_irq(pdev->irq, dev); 2999 free_irq(pdev->irq, dev);
3047 3000
3048#ifndef OTG_TRANSCEIVER
3049 if (dev->cap_regs) 3001 if (dev->cap_regs)
3050 iounmap(dev->cap_regs); 3002 iounmap(dev->cap_regs);
3051 3003
@@ -3055,13 +3007,6 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3055 3007
3056 if (dev->enabled) 3008 if (dev->enabled)
3057 pci_disable_device(pdev); 3009 pci_disable_device(pdev);
3058#else
3059 if (dev->transceiver) {
3060 otg_put_transceiver(dev->transceiver);
3061 dev->transceiver = NULL;
3062 dev->lotg = NULL;
3063 }
3064#endif
3065 3010
3066 dev->cap_regs = NULL; 3011 dev->cap_regs = NULL;
3067 3012
@@ -3072,9 +3017,7 @@ static void langwell_udc_remove(struct pci_dev *pdev)
3072 device_remove_file(&pdev->dev, &dev_attr_langwell_udc); 3017 device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
3073 device_remove_file(&pdev->dev, &dev_attr_remote_wakeup); 3018 device_remove_file(&pdev->dev, &dev_attr_remote_wakeup);
3074 3019
3075#ifndef OTG_TRANSCEIVER
3076 pci_set_drvdata(pdev, NULL); 3020 pci_set_drvdata(pdev, NULL);
3077#endif
3078 3021
3079 /* free dev, wait for the release() finished */ 3022 /* free dev, wait for the release() finished */
3080 wait_for_completion(&done); 3023 wait_for_completion(&done);
@@ -3089,9 +3032,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3089 const struct pci_device_id *id) 3032 const struct pci_device_id *id)
3090{ 3033{
3091 struct langwell_udc *dev; 3034 struct langwell_udc *dev;
3092#ifndef OTG_TRANSCEIVER
3093 unsigned long resource, len; 3035 unsigned long resource, len;
3094#endif
3095 void __iomem *base = NULL; 3036 void __iomem *base = NULL;
3096 size_t size; 3037 size_t size;
3097 int retval; 3038 int retval;
@@ -3109,16 +3050,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3109 dev->pdev = pdev; 3050 dev->pdev = pdev;
3110 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); 3051 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
3111 3052
3112#ifdef OTG_TRANSCEIVER
3113 /* PCI device is already enabled by otg_transceiver driver */
3114 dev->enabled = 1;
3115
3116 /* mem region and register base */
3117 dev->region = 1;
3118 dev->transceiver = otg_get_transceiver();
3119 dev->lotg = otg_to_langwell(dev->transceiver);
3120 base = dev->lotg->regs;
3121#else
3122 pci_set_drvdata(pdev, dev); 3053 pci_set_drvdata(pdev, dev);
3123 3054
3124 /* now all the pci goodies ... */ 3055 /* now all the pci goodies ... */
@@ -3139,7 +3070,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3139 dev->region = 1; 3070 dev->region = 1;
3140 3071
3141 base = ioremap_nocache(resource, len); 3072 base = ioremap_nocache(resource, len);
3142#endif
3143 if (base == NULL) { 3073 if (base == NULL) {
3144 dev_err(&dev->pdev->dev, "can't map memory\n"); 3074 dev_err(&dev->pdev->dev, "can't map memory\n");
3145 retval = -EFAULT; 3075 retval = -EFAULT;
@@ -3163,7 +3093,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3163 dev->got_sram = 0; 3093 dev->got_sram = 0;
3164 dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram); 3094 dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram);
3165 3095
3166#ifndef OTG_TRANSCEIVER
3167 /* enable SRAM caching if detected */ 3096 /* enable SRAM caching if detected */
3168 if (dev->has_sram && !dev->got_sram) 3097 if (dev->has_sram && !dev->got_sram)
3169 sram_init(dev); 3098 sram_init(dev);
@@ -3182,7 +3111,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3182 goto error; 3111 goto error;
3183 } 3112 }
3184 dev->got_irq = 1; 3113 dev->got_irq = 1;
3185#endif
3186 3114
3187 /* set stopped bit */ 3115 /* set stopped bit */
3188 dev->stopped = 1; 3116 dev->stopped = 1;
@@ -3257,10 +3185,8 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3257 dev->remote_wakeup = 0; 3185 dev->remote_wakeup = 0;
3258 dev->dev_status = 1 << USB_DEVICE_SELF_POWERED; 3186 dev->dev_status = 1 << USB_DEVICE_SELF_POWERED;
3259 3187
3260#ifndef OTG_TRANSCEIVER
3261 /* reset device controller */ 3188 /* reset device controller */
3262 langwell_udc_reset(dev); 3189 langwell_udc_reset(dev);
3263#endif
3264 3190
3265 /* initialize gadget structure */ 3191 /* initialize gadget structure */
3266 dev->gadget.ops = &langwell_ops; /* usb_gadget_ops */ 3192 dev->gadget.ops = &langwell_ops; /* usb_gadget_ops */
@@ -3268,9 +3194,6 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3268 INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */ 3194 INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */
3269 dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ 3195 dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */
3270 dev->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */ 3196 dev->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */
3271#ifdef OTG_TRANSCEIVER
3272 dev->gadget.is_otg = 1; /* support otg mode */
3273#endif
3274 3197
3275 /* the "gadget" abstracts/virtualizes the controller */ 3198 /* the "gadget" abstracts/virtualizes the controller */
3276 dev_set_name(&dev->gadget.dev, "gadget"); 3199 dev_set_name(&dev->gadget.dev, "gadget");
@@ -3282,10 +3205,8 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3282 /* controller endpoints reinit */ 3205 /* controller endpoints reinit */
3283 eps_reinit(dev); 3206 eps_reinit(dev);
3284 3207
3285#ifndef OTG_TRANSCEIVER
3286 /* reset ep0 dQH and endptctrl */ 3208 /* reset ep0 dQH and endptctrl */
3287 ep0_reset(dev); 3209 ep0_reset(dev);
3288#endif
3289 3210
3290 /* create dTD dma_pool resource */ 3211 /* create dTD dma_pool resource */
3291 dev->dtd_pool = dma_pool_create("langwell_dtd", 3212 dev->dtd_pool = dma_pool_create("langwell_dtd",
@@ -3367,7 +3288,7 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
3367 3288
3368 spin_lock_irq(&dev->lock); 3289 spin_lock_irq(&dev->lock);
3369 /* stop all usb activities */ 3290 /* stop all usb activities */
3370 stop_activity(dev, dev->driver); 3291 stop_activity(dev);
3371 spin_unlock_irq(&dev->lock); 3292 spin_unlock_irq(&dev->lock);
3372 3293
3373 /* free dTD dma_pool and dQH */ 3294 /* free dTD dma_pool and dQH */
@@ -3525,22 +3446,14 @@ static struct pci_driver langwell_pci_driver = {
3525 3446
3526static int __init init(void) 3447static int __init init(void)
3527{ 3448{
3528#ifdef OTG_TRANSCEIVER
3529 return langwell_register_peripheral(&langwell_pci_driver);
3530#else
3531 return pci_register_driver(&langwell_pci_driver); 3449 return pci_register_driver(&langwell_pci_driver);
3532#endif
3533} 3450}
3534module_init(init); 3451module_init(init);
3535 3452
3536 3453
3537static void __exit cleanup(void) 3454static void __exit cleanup(void)
3538{ 3455{
3539#ifdef OTG_TRANSCEIVER
3540 return langwell_unregister_peripheral(&langwell_pci_driver);
3541#else
3542 pci_unregister_driver(&langwell_pci_driver); 3456 pci_unregister_driver(&langwell_pci_driver);
3543#endif
3544} 3457}
3545module_exit(cleanup); 3458module_exit(cleanup);
3546 3459
diff --git a/drivers/usb/gadget/langwell_udc.h b/drivers/usb/gadget/langwell_udc.h
index ef79e242b7b0..d6e78accaffe 100644
--- a/drivers/usb/gadget/langwell_udc.h
+++ b/drivers/usb/gadget/langwell_udc.h
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/usb/langwell_udc.h> 10#include <linux/usb/langwell_udc.h>
11#include <linux/usb/langwell_otg.h>
12 11
13/*-------------------------------------------------------------------------*/ 12/*-------------------------------------------------------------------------*/
14 13
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index c7f291a331df..85ea14e2545e 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -598,16 +598,16 @@ static __maybe_unused struct usb_ss_cap_descriptor fsg_ss_cap_desc = {
598 | USB_5GBPS_OPERATION), 598 | USB_5GBPS_OPERATION),
599 .bFunctionalitySupport = USB_LOW_SPEED_OPERATION, 599 .bFunctionalitySupport = USB_LOW_SPEED_OPERATION,
600 .bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT, 600 .bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT,
601 .bU2DevExitLat = USB_DEFAULT_U2_DEV_EXIT_LAT, 601 .bU2DevExitLat = cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT),
602}; 602};
603 603
604static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = { 604static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = {
605 .bLength = USB_DT_BOS_SIZE, 605 .bLength = USB_DT_BOS_SIZE,
606 .bDescriptorType = USB_DT_BOS, 606 .bDescriptorType = USB_DT_BOS,
607 607
608 .wTotalLength = USB_DT_BOS_SIZE 608 .wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE
609 + USB_DT_USB_EXT_CAP_SIZE 609 + USB_DT_USB_EXT_CAP_SIZE
610 + USB_DT_USB_SS_CAP_SIZE, 610 + USB_DT_USB_SS_CAP_SIZE),
611 611
612 .bNumDeviceCaps = 2, 612 .bNumDeviceCaps = 2,
613}; 613};
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index e90344a17631..b556a72264d1 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -125,7 +125,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
125 */ 125 */
126 if (pdata->init && pdata->init(pdev)) { 126 if (pdata->init && pdata->init(pdev)) {
127 retval = -ENODEV; 127 retval = -ENODEV;
128 goto err3; 128 goto err4;
129 } 129 }
130 130
131 /* Enable USB controller, 83xx or 8536 */ 131 /* Enable USB controller, 83xx or 8536 */
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index f4b627d343ac..01bb7241d6ef 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -276,6 +276,9 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
276 276
277 /* Serial Bus Release Number is at PCI 0x60 offset */ 277 /* Serial Bus Release Number is at PCI 0x60 offset */
278 pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 278 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
279 if (pdev->vendor == PCI_VENDOR_ID_STMICRO
280 && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST)
281 ehci->sbrn = 0x20; /* ConneXT has no sbrn register */
279 282
280 /* Keep this around for a while just in case some EHCI 283 /* Keep this around for a while just in case some EHCI
281 * implementation uses legacy PCI PM support. This test 284 * implementation uses legacy PCI PM support. This test
@@ -526,6 +529,9 @@ static const struct pci_device_id pci_ids [] = { {
526 /* handle any USB 2.0 EHCI controller */ 529 /* handle any USB 2.0 EHCI controller */
527 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), 530 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0),
528 .driver_data = (unsigned long) &ehci_pci_hc_driver, 531 .driver_data = (unsigned long) &ehci_pci_hc_driver,
532 }, {
533 PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST),
534 .driver_data = (unsigned long) &ehci_pci_hc_driver,
529 }, 535 },
530 { /* end: all zeroes */ } 536 { /* end: all zeroes */ }
531}; 537};
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 5df0b0e3392b..77afabc77f9b 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -139,8 +139,23 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
139 } 139 }
140 140
141 iclk = clk_get(&pdev->dev, "ohci_clk"); 141 iclk = clk_get(&pdev->dev, "ohci_clk");
142 if (IS_ERR(iclk)) {
143 dev_err(&pdev->dev, "failed to get ohci_clk\n");
144 retval = PTR_ERR(iclk);
145 goto err3;
146 }
142 fclk = clk_get(&pdev->dev, "uhpck"); 147 fclk = clk_get(&pdev->dev, "uhpck");
148 if (IS_ERR(fclk)) {
149 dev_err(&pdev->dev, "failed to get uhpck\n");
150 retval = PTR_ERR(fclk);
151 goto err4;
152 }
143 hclk = clk_get(&pdev->dev, "hclk"); 153 hclk = clk_get(&pdev->dev, "hclk");
154 if (IS_ERR(hclk)) {
155 dev_err(&pdev->dev, "failed to get hclk\n");
156 retval = PTR_ERR(hclk);
157 goto err5;
158 }
144 159
145 at91_start_hc(pdev); 160 at91_start_hc(pdev);
146 ohci_hcd_init(hcd_to_ohci(hcd)); 161 ohci_hcd_init(hcd_to_ohci(hcd));
@@ -153,9 +168,12 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
153 at91_stop_hc(pdev); 168 at91_stop_hc(pdev);
154 169
155 clk_put(hclk); 170 clk_put(hclk);
171 err5:
156 clk_put(fclk); 172 clk_put(fclk);
173 err4:
157 clk_put(iclk); 174 clk_put(iclk);
158 175
176 err3:
159 iounmap(hcd->regs); 177 iounmap(hcd->regs);
160 178
161 err2: 179 err2:
@@ -226,7 +244,8 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int
226 if (!gpio_is_valid(pdata->vbus_pin[port])) 244 if (!gpio_is_valid(pdata->vbus_pin[port]))
227 return; 245 return;
228 246
229 gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); 247 gpio_set_value(pdata->vbus_pin[port],
248 !pdata->vbus_pin_active_low[port] ^ enable);
230} 249}
231 250
232static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) 251static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
@@ -237,7 +256,8 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
237 if (!gpio_is_valid(pdata->vbus_pin[port])) 256 if (!gpio_is_valid(pdata->vbus_pin[port]))
238 return -EINVAL; 257 return -EINVAL;
239 258
240 return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; 259 return gpio_get_value(pdata->vbus_pin[port]) ^
260 !pdata->vbus_pin_active_low[port];
241} 261}
242 262
243/* 263/*
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 5179fcd73d8a..e4bcb62b930a 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -82,6 +82,14 @@ urb_print(struct urb * urb, char * str, int small, int status)
82 ohci_dbg(ohci,format, ## arg ); \ 82 ohci_dbg(ohci,format, ## arg ); \
83 } while (0); 83 } while (0);
84 84
85/* Version for use where "next" is the address of a local variable */
86#define ohci_dbg_nosw(ohci, next, size, format, arg...) \
87 do { \
88 unsigned s_len; \
89 s_len = scnprintf(*next, *size, format, ## arg); \
90 *size -= s_len; *next += s_len; \
91 } while (0);
92
85 93
86static void ohci_dump_intr_mask ( 94static void ohci_dump_intr_mask (
87 struct ohci_hcd *ohci, 95 struct ohci_hcd *ohci,
@@ -653,7 +661,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
653 661
654 /* dump driver info, then registers in spec order */ 662 /* dump driver info, then registers in spec order */
655 663
656 ohci_dbg_sw (ohci, &next, &size, 664 ohci_dbg_nosw(ohci, &next, &size,
657 "bus %s, device %s\n" 665 "bus %s, device %s\n"
658 "%s\n" 666 "%s\n"
659 "%s\n", 667 "%s\n",
@@ -672,7 +680,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
672 680
673 /* hcca */ 681 /* hcca */
674 if (ohci->hcca) 682 if (ohci->hcca)
675 ohci_dbg_sw (ohci, &next, &size, 683 ohci_dbg_nosw(ohci, &next, &size,
676 "hcca frame 0x%04x\n", ohci_frame_no(ohci)); 684 "hcca frame 0x%04x\n", ohci_frame_no(ohci));
677 685
678 /* other registers mostly affect frame timings */ 686 /* other registers mostly affect frame timings */
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 6109810cc2d3..1843bb68ac7c 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -397,6 +397,10 @@ static const struct pci_device_id pci_ids [] = { {
397 /* handle any USB OHCI controller */ 397 /* handle any USB OHCI controller */
398 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), 398 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0),
399 .driver_data = (unsigned long) &ohci_pci_hc_driver, 399 .driver_data = (unsigned long) &ohci_pci_hc_driver,
400 }, {
401 /* The device in the ConneXT I/O hub has no class reg */
402 PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_OHCI),
403 .driver_data = (unsigned long) &ohci_pci_hc_driver,
400 }, { /* end: all zeroes */ } 404 }, { /* end: all zeroes */ }
401}; 405};
402MODULE_DEVICE_TABLE (pci, pci_ids); 406MODULE_DEVICE_TABLE (pci, pci_ids);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index b90e1386418b..b62037bff688 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1204,6 +1204,7 @@ static void handle_vendor_event(struct xhci_hcd *xhci,
1204 * 1204 *
1205 * Returns a zero-based port number, which is suitable for indexing into each of 1205 * Returns a zero-based port number, which is suitable for indexing into each of
1206 * the split roothubs' port arrays and bus state arrays. 1206 * the split roothubs' port arrays and bus state arrays.
1207 * Add one to it in order to call xhci_find_slot_id_by_port.
1207 */ 1208 */
1208static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, 1209static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd,
1209 struct xhci_hcd *xhci, u32 port_id) 1210 struct xhci_hcd *xhci, u32 port_id)
@@ -1324,7 +1325,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1324 xhci_set_link_state(xhci, port_array, faked_port_index, 1325 xhci_set_link_state(xhci, port_array, faked_port_index,
1325 XDEV_U0); 1326 XDEV_U0);
1326 slot_id = xhci_find_slot_id_by_port(hcd, xhci, 1327 slot_id = xhci_find_slot_id_by_port(hcd, xhci,
1327 faked_port_index); 1328 faked_port_index + 1);
1328 if (!slot_id) { 1329 if (!slot_id) {
1329 xhci_dbg(xhci, "slot_id is zero\n"); 1330 xhci_dbg(xhci, "slot_id is zero\n");
1330 goto cleanup; 1331 goto cleanup;
@@ -3323,7 +3324,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3323 /* Check TD length */ 3324 /* Check TD length */
3324 if (running_total != td_len) { 3325 if (running_total != td_len) {
3325 xhci_err(xhci, "ISOC TD length unmatch\n"); 3326 xhci_err(xhci, "ISOC TD length unmatch\n");
3326 return -EINVAL; 3327 ret = -EINVAL;
3328 goto cleanup;
3327 } 3329 }
3328 } 3330 }
3329 3331
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index d9b6a0355443..da97dcec1f32 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -37,9 +37,6 @@ static int emi26_set_reset(struct usb_device *dev, unsigned char reset_bit);
37static int emi26_load_firmware (struct usb_device *dev); 37static int emi26_load_firmware (struct usb_device *dev);
38static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id); 38static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id);
39static void emi26_disconnect(struct usb_interface *intf); 39static void emi26_disconnect(struct usb_interface *intf);
40static int __init emi26_init (void);
41static void __exit emi26_exit (void);
42
43 40
44/* thanks to drivers/usb/serial/keyspan_pda.c code */ 41/* thanks to drivers/usb/serial/keyspan_pda.c code */
45static int emi26_writememory (struct usb_device *dev, int address, 42static int emi26_writememory (struct usb_device *dev, int address,
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index 9f39062ebb08..4e0f167a6c4e 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -46,9 +46,6 @@ static int emi62_set_reset(struct usb_device *dev, unsigned char reset_bit);
46static int emi62_load_firmware (struct usb_device *dev); 46static int emi62_load_firmware (struct usb_device *dev);
47static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id); 47static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id);
48static void emi62_disconnect(struct usb_interface *intf); 48static void emi62_disconnect(struct usb_interface *intf);
49static int __init emi62_init (void);
50static void __exit emi62_exit (void);
51
52 49
53/* thanks to drivers/usb/serial/keyspan_pda.c code */ 50/* thanks to drivers/usb/serial/keyspan_pda.c code */
54static int emi62_writememory(struct usb_device *dev, int address, 51static int emi62_writememory(struct usb_device *dev, int address,
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index 107bf13b1cf1..b2d82b937392 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -24,7 +24,7 @@
24 24
25#define VENDOR_ID 0x0fc5 25#define VENDOR_ID 0x0fc5
26#define PRODUCT_ID 0x1227 26#define PRODUCT_ID 0x1227
27#define MAXLEN 6 27#define MAXLEN 8
28 28
29/* table of devices that work with this driver */ 29/* table of devices that work with this driver */
30static const struct usb_device_id id_table[] = { 30static const struct usb_device_id id_table[] = {
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index f9a3f62a83b5..7c569f51212a 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -33,9 +33,6 @@
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35 35
36#include <mach/hardware.h>
37#include <mach/memory.h>
38#include <asm/gpio.h>
39#include <mach/cputype.h> 36#include <mach/cputype.h>
40 37
41#include <asm/mach-types.h> 38#include <asm/mach-types.h>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 56cf0243979e..3d11cf64ebd1 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -981,6 +981,9 @@ static void musb_shutdown(struct platform_device *pdev)
981 unsigned long flags; 981 unsigned long flags;
982 982
983 pm_runtime_get_sync(musb->controller); 983 pm_runtime_get_sync(musb->controller);
984
985 musb_gadget_cleanup(musb);
986
984 spin_lock_irqsave(&musb->lock, flags); 987 spin_lock_irqsave(&musb->lock, flags);
985 musb_platform_disable(musb); 988 musb_platform_disable(musb);
986 musb_generic_disable(musb); 989 musb_generic_disable(musb);
@@ -1827,8 +1830,6 @@ static void musb_free(struct musb *musb)
1827 sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); 1830 sysfs_remove_group(&musb->controller->kobj, &musb_attr_group);
1828#endif 1831#endif
1829 1832
1830 musb_gadget_cleanup(musb);
1831
1832 if (musb->nIrq >= 0) { 1833 if (musb->nIrq >= 0) {
1833 if (musb->irq_wake) 1834 if (musb->irq_wake)
1834 disable_irq_wake(musb->nIrq); 1835 disable_irq_wake(musb->nIrq);
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index c27bbbf32b52..df719eae3b03 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -222,7 +222,6 @@ static inline void omap2430_low_level_init(struct musb *musb)
222 musb_writel(musb->mregs, OTG_FORCESTDBY, l); 222 musb_writel(musb->mregs, OTG_FORCESTDBY, l);
223} 223}
224 224
225/* blocking notifier support */
226static int musb_otg_notifications(struct notifier_block *nb, 225static int musb_otg_notifications(struct notifier_block *nb,
227 unsigned long event, void *unused) 226 unsigned long event, void *unused)
228{ 227{
@@ -231,7 +230,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
231 musb->xceiv_event = event; 230 musb->xceiv_event = event;
232 schedule_work(&musb->otg_notifier_work); 231 schedule_work(&musb->otg_notifier_work);
233 232
234 return 0; 233 return NOTIFY_OK;
235} 234}
236 235
237static void musb_otg_notifier_work(struct work_struct *data_notifier_work) 236static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
@@ -386,6 +385,7 @@ static void omap2430_musb_disable(struct musb *musb)
386static int omap2430_musb_exit(struct musb *musb) 385static int omap2430_musb_exit(struct musb *musb)
387{ 386{
388 del_timer_sync(&musb_idle_timer); 387 del_timer_sync(&musb_idle_timer);
388 cancel_work_sync(&musb->otg_notifier_work);
389 389
390 omap2430_low_level_exit(musb); 390 omap2430_low_level_exit(musb);
391 otg_put_transceiver(musb->xceiv); 391 otg_put_transceiver(musb->xceiv);
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 2a25955881fc..76d629345418 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -86,20 +86,6 @@ config NOP_USB_XCEIV
86 built-in with usb ip or which are autonomous and doesn't require any 86 built-in with usb ip or which are autonomous and doesn't require any
87 phy programming such as ISP1x04 etc. 87 phy programming such as ISP1x04 etc.
88 88
89config USB_LANGWELL_OTG
90 tristate "Intel Langwell USB OTG dual-role support"
91 depends on USB && PCI && INTEL_SCU_IPC
92 select USB_OTG
93 select USB_OTG_UTILS
94 help
95 Say Y here if you want to build Intel Langwell USB OTG
96 transciever driver in kernel. This driver implements role
97 switch between EHCI host driver and Langwell USB OTG
98 client driver.
99
100 To compile this driver as a module, choose M here: the
101 module will be called langwell_otg.
102
103config USB_MSM_OTG 89config USB_MSM_OTG
104 tristate "OTG support for Qualcomm on-chip USB controller" 90 tristate "OTG support for Qualcomm on-chip USB controller"
105 depends on (USB || USB_GADGET) && ARCH_MSM 91 depends on (USB || USB_GADGET) && ARCH_MSM
@@ -124,7 +110,7 @@ config AB8500_USB
124 110
125config FSL_USB2_OTG 111config FSL_USB2_OTG
126 bool "Freescale USB OTG Transceiver Driver" 112 bool "Freescale USB OTG Transceiver Driver"
127 depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 113 depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 && USB_SUSPEND
128 select USB_OTG 114 select USB_OTG
129 select USB_OTG_UTILS 115 select USB_OTG_UTILS
130 help 116 help
@@ -132,7 +118,7 @@ config FSL_USB2_OTG
132 118
133config USB_MV_OTG 119config USB_MV_OTG
134 tristate "Marvell USB OTG support" 120 tristate "Marvell USB OTG support"
135 depends on USB_MV_UDC 121 depends on USB_MV_UDC && USB_SUSPEND
136 select USB_OTG 122 select USB_OTG
137 select USB_OTG_UTILS 123 select USB_OTG_UTILS
138 help 124 help
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index b2c5a9598637..41aa5098b139 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
13obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 13obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
14obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o 14obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
15obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o 15obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o
16obj-$(CONFIG_USB_LANGWELL_OTG) += langwell_otg.o
17obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o 16obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o
18obj-$(CONFIG_USB_ULPI) += ulpi.o 17obj-$(CONFIG_USB_ULPI) += ulpi.o
19obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o 18obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
deleted file mode 100644
index f08f784086f7..000000000000
--- a/drivers/usb/otg/langwell_otg.c
+++ /dev/null
@@ -1,2347 +0,0 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19/* This driver helps to switch Langwell OTG controller function between host
20 * and peripheral. It works with EHCI driver and Langwell client controller
21 * driver together.
22 */
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/pci.h>
26#include <linux/errno.h>
27#include <linux/interrupt.h>
28#include <linux/kernel.h>
29#include <linux/device.h>
30#include <linux/moduleparam.h>
31#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h>
33#include <linux/usb.h>
34#include <linux/usb/otg.h>
35#include <linux/usb/hcd.h>
36#include <linux/notifier.h>
37#include <linux/delay.h>
38#include <asm/intel_scu_ipc.h>
39
40#include <linux/usb/langwell_otg.h>
41
42#define DRIVER_DESC "Intel Langwell USB OTG transceiver driver"
43#define DRIVER_VERSION "July 10, 2010"
44
45MODULE_DESCRIPTION(DRIVER_DESC);
46MODULE_AUTHOR("Henry Yuan <hang.yuan@intel.com>, Hao Wu <hao.wu@intel.com>");
47MODULE_VERSION(DRIVER_VERSION);
48MODULE_LICENSE("GPL");
49
50static const char driver_name[] = "langwell_otg";
51
52static int langwell_otg_probe(struct pci_dev *pdev,
53 const struct pci_device_id *id);
54static void langwell_otg_remove(struct pci_dev *pdev);
55static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message);
56static int langwell_otg_resume(struct pci_dev *pdev);
57
58static int langwell_otg_set_host(struct otg_transceiver *otg,
59 struct usb_bus *host);
60static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
61 struct usb_gadget *gadget);
62static int langwell_otg_start_srp(struct otg_transceiver *otg);
63
64static const struct pci_device_id pci_ids[] = {{
65 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
66 .class_mask = ~0,
67 .vendor = 0x8086,
68 .device = 0x0811,
69 .subvendor = PCI_ANY_ID,
70 .subdevice = PCI_ANY_ID,
71}, { /* end: all zeroes */ }
72};
73
74static struct pci_driver otg_pci_driver = {
75 .name = (char *) driver_name,
76 .id_table = pci_ids,
77
78 .probe = langwell_otg_probe,
79 .remove = langwell_otg_remove,
80
81 .suspend = langwell_otg_suspend,
82 .resume = langwell_otg_resume,
83};
84
85/* HSM timers */
86static inline struct langwell_otg_timer *otg_timer_initializer
87(void (*function)(unsigned long), unsigned long expires, unsigned long data)
88{
89 struct langwell_otg_timer *timer;
90 timer = kmalloc(sizeof(struct langwell_otg_timer), GFP_KERNEL);
91 if (timer == NULL)
92 return timer;
93
94 timer->function = function;
95 timer->expires = expires;
96 timer->data = data;
97 return timer;
98}
99
100static struct langwell_otg_timer *a_wait_vrise_tmr, *a_aidl_bdis_tmr,
101 *b_se0_srp_tmr, *b_srp_init_tmr;
102
103static struct list_head active_timers;
104
105static struct langwell_otg *the_transceiver;
106
107/* host/client notify transceiver when event affects HNP state */
108void langwell_update_transceiver(void)
109{
110 struct langwell_otg *lnw = the_transceiver;
111
112 dev_dbg(lnw->dev, "transceiver is updated\n");
113
114 if (!lnw->qwork)
115 return ;
116
117 queue_work(lnw->qwork, &lnw->work);
118}
119EXPORT_SYMBOL(langwell_update_transceiver);
120
121static int langwell_otg_set_host(struct otg_transceiver *otg,
122 struct usb_bus *host)
123{
124 otg->host = host;
125
126 return 0;
127}
128
129static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
130 struct usb_gadget *gadget)
131{
132 otg->gadget = gadget;
133
134 return 0;
135}
136
137static int langwell_otg_set_power(struct otg_transceiver *otg,
138 unsigned mA)
139{
140 return 0;
141}
142
143/* A-device drives vbus, controlled through IPC commands */
144static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled)
145{
146 struct langwell_otg *lnw = the_transceiver;
147 u8 sub_id;
148
149 dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off");
150
151 if (enabled)
152 sub_id = 0x8; /* Turn on the VBus */
153 else
154 sub_id = 0x9; /* Turn off the VBus */
155
156 if (intel_scu_ipc_simple_command(0xef, sub_id)) {
157 dev_dbg(lnw->dev, "Failed to set Vbus via IPC commands\n");
158 return -EBUSY;
159 }
160
161 dev_dbg(lnw->dev, "%s --->\n", __func__);
162
163 return 0;
164}
165
166/* charge vbus or discharge vbus through a resistor to ground */
167static void langwell_otg_chrg_vbus(int on)
168{
169 struct langwell_otg *lnw = the_transceiver;
170 u32 val;
171
172 val = readl(lnw->iotg.base + CI_OTGSC);
173
174 if (on)
175 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VC,
176 lnw->iotg.base + CI_OTGSC);
177 else
178 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VD,
179 lnw->iotg.base + CI_OTGSC);
180}
181
182/* Start SRP */
183static int langwell_otg_start_srp(struct otg_transceiver *otg)
184{
185 struct langwell_otg *lnw = the_transceiver;
186 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
187 u32 val;
188
189 dev_dbg(lnw->dev, "%s --->\n", __func__);
190
191 val = readl(iotg->base + CI_OTGSC);
192
193 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP,
194 iotg->base + CI_OTGSC);
195
196 /* Check if the data plus is finished or not */
197 msleep(8);
198 val = readl(iotg->base + CI_OTGSC);
199 if (val & (OTGSC_HADP | OTGSC_DP))
200 dev_dbg(lnw->dev, "DataLine SRP Error\n");
201
202 /* Disable interrupt - b_sess_vld */
203 val = readl(iotg->base + CI_OTGSC);
204 val &= (~(OTGSC_BSVIE | OTGSC_BSEIE));
205 writel(val, iotg->base + CI_OTGSC);
206
207 /* Start VBus SRP, drive vbus to generate VBus pulse */
208 iotg->otg.set_vbus(&iotg->otg, true);
209 msleep(15);
210 iotg->otg.set_vbus(&iotg->otg, false);
211
212 /* Enable interrupt - b_sess_vld*/
213 val = readl(iotg->base + CI_OTGSC);
214 dev_dbg(lnw->dev, "after VBUS pulse otgsc = %x\n", val);
215
216 val |= (OTGSC_BSVIE | OTGSC_BSEIE);
217 writel(val, iotg->base + CI_OTGSC);
218
219 /* If Vbus is valid, then update the hsm */
220 if (val & OTGSC_BSV) {
221 dev_dbg(lnw->dev, "no b_sess_vld interrupt\n");
222
223 lnw->iotg.hsm.b_sess_vld = 1;
224 langwell_update_transceiver();
225 }
226
227 dev_dbg(lnw->dev, "%s <---\n", __func__);
228 return 0;
229}
230
231/* stop SOF via bus_suspend */
232static void langwell_otg_loc_sof(int on)
233{
234 struct langwell_otg *lnw = the_transceiver;
235 struct usb_hcd *hcd;
236 int err;
237
238 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "suspend" : "resume");
239
240 hcd = bus_to_hcd(lnw->iotg.otg.host);
241 if (on)
242 err = hcd->driver->bus_resume(hcd);
243 else
244 err = hcd->driver->bus_suspend(hcd);
245
246 if (err)
247 dev_dbg(lnw->dev, "Fail to resume/suspend USB bus - %d\n", err);
248
249 dev_dbg(lnw->dev, "%s <---\n", __func__);
250}
251
252static int langwell_otg_check_otgsc(void)
253{
254 struct langwell_otg *lnw = the_transceiver;
255 u32 otgsc, usbcfg;
256
257 dev_dbg(lnw->dev, "check sync OTGSC and USBCFG registers\n");
258
259 otgsc = readl(lnw->iotg.base + CI_OTGSC);
260 usbcfg = readl(lnw->usbcfg);
261
262 dev_dbg(lnw->dev, "OTGSC = %08x, USBCFG = %08x\n",
263 otgsc, usbcfg);
264 dev_dbg(lnw->dev, "OTGSC_AVV = %d\n", !!(otgsc & OTGSC_AVV));
265 dev_dbg(lnw->dev, "USBCFG.VBUSVAL = %d\n",
266 !!(usbcfg & USBCFG_VBUSVAL));
267 dev_dbg(lnw->dev, "OTGSC_ASV = %d\n", !!(otgsc & OTGSC_ASV));
268 dev_dbg(lnw->dev, "USBCFG.AVALID = %d\n",
269 !!(usbcfg & USBCFG_AVALID));
270 dev_dbg(lnw->dev, "OTGSC_BSV = %d\n", !!(otgsc & OTGSC_BSV));
271 dev_dbg(lnw->dev, "USBCFG.BVALID = %d\n",
272 !!(usbcfg & USBCFG_BVALID));
273 dev_dbg(lnw->dev, "OTGSC_BSE = %d\n", !!(otgsc & OTGSC_BSE));
274 dev_dbg(lnw->dev, "USBCFG.SESEND = %d\n",
275 !!(usbcfg & USBCFG_SESEND));
276
277 /* Check USBCFG VBusValid/AValid/BValid/SessEnd */
278 if (!!(otgsc & OTGSC_AVV) ^ !!(usbcfg & USBCFG_VBUSVAL)) {
279 dev_dbg(lnw->dev, "OTGSC.AVV != USBCFG.VBUSVAL\n");
280 goto err;
281 }
282 if (!!(otgsc & OTGSC_ASV) ^ !!(usbcfg & USBCFG_AVALID)) {
283 dev_dbg(lnw->dev, "OTGSC.ASV != USBCFG.AVALID\n");
284 goto err;
285 }
286 if (!!(otgsc & OTGSC_BSV) ^ !!(usbcfg & USBCFG_BVALID)) {
287 dev_dbg(lnw->dev, "OTGSC.BSV != USBCFG.BVALID\n");
288 goto err;
289 }
290 if (!!(otgsc & OTGSC_BSE) ^ !!(usbcfg & USBCFG_SESEND)) {
291 dev_dbg(lnw->dev, "OTGSC.BSE != USBCFG.SESSEN\n");
292 goto err;
293 }
294
295 dev_dbg(lnw->dev, "OTGSC and USBCFG are synced\n");
296
297 return 0;
298
299err:
300 dev_warn(lnw->dev, "OTGSC isn't equal to USBCFG\n");
301 return -EPIPE;
302}
303
304
305static void langwell_otg_phy_low_power(int on)
306{
307 struct langwell_otg *lnw = the_transceiver;
308 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
309 u8 val, phcd;
310 int retval;
311
312 dev_dbg(lnw->dev, "%s ---> %s mode\n",
313 __func__, on ? "Low power" : "Normal");
314
315 phcd = 0x40;
316
317 val = readb(iotg->base + CI_HOSTPC1 + 2);
318
319 if (on) {
320 /* Due to hardware issue, after set PHCD, sync will failed
321 * between USBCFG and OTGSC, so before set PHCD, check if
322 * sync is in process now. If the answer is "yes", then do
323 * not touch PHCD bit */
324 retval = langwell_otg_check_otgsc();
325 if (retval) {
326 dev_dbg(lnw->dev, "Skip PHCD programming..\n");
327 return ;
328 }
329
330 writeb(val | phcd, iotg->base + CI_HOSTPC1 + 2);
331 } else
332 writeb(val & ~phcd, iotg->base + CI_HOSTPC1 + 2);
333
334 dev_dbg(lnw->dev, "%s <--- done\n", __func__);
335}
336
337/* After drv vbus, add 5 ms delay to set PHCD */
338static void langwell_otg_phy_low_power_wait(int on)
339{
340 struct langwell_otg *lnw = the_transceiver;
341
342 dev_dbg(lnw->dev, "add 5ms delay before programing PHCD\n");
343
344 mdelay(5);
345 langwell_otg_phy_low_power(on);
346}
347
348/* Enable/Disable OTG interrupt */
349static void langwell_otg_intr(int on)
350{
351 struct langwell_otg *lnw = the_transceiver;
352 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
353 u32 val;
354
355 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
356
357 val = readl(iotg->base + CI_OTGSC);
358
359 /* OTGSC_INT_MASK doesn't contains 1msInt */
360 if (on) {
361 val = val | (OTGSC_INT_MASK);
362 writel(val, iotg->base + CI_OTGSC);
363 } else {
364 val = val & ~(OTGSC_INT_MASK);
365 writel(val, iotg->base + CI_OTGSC);
366 }
367
368 dev_dbg(lnw->dev, "%s <---\n", __func__);
369}
370
371/* set HAAR: Hardware Assist Auto-Reset */
372static void langwell_otg_HAAR(int on)
373{
374 struct langwell_otg *lnw = the_transceiver;
375 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
376 u32 val;
377
378 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
379
380 val = readl(iotg->base + CI_OTGSC);
381 if (on)
382 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HAAR,
383 iotg->base + CI_OTGSC);
384 else
385 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HAAR,
386 iotg->base + CI_OTGSC);
387
388 dev_dbg(lnw->dev, "%s <---\n", __func__);
389}
390
391/* set HABA: Hardware Assist B-Disconnect to A-Connect */
392static void langwell_otg_HABA(int on)
393{
394 struct langwell_otg *lnw = the_transceiver;
395 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
396 u32 val;
397
398 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
399
400 val = readl(iotg->base + CI_OTGSC);
401 if (on)
402 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HABA,
403 iotg->base + CI_OTGSC);
404 else
405 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HABA,
406 iotg->base + CI_OTGSC);
407
408 dev_dbg(lnw->dev, "%s <---\n", __func__);
409}
410
411static int langwell_otg_check_se0_srp(int on)
412{
413 struct langwell_otg *lnw = the_transceiver;
414 int delay_time = TB_SE0_SRP * 10;
415 u32 val;
416
417 dev_dbg(lnw->dev, "%s --->\n", __func__);
418
419 do {
420 udelay(100);
421 if (!delay_time--)
422 break;
423 val = readl(lnw->iotg.base + CI_PORTSC1);
424 val &= PORTSC_LS;
425 } while (!val);
426
427 dev_dbg(lnw->dev, "%s <---\n", __func__);
428 return val;
429}
430
431/* The timeout callback function to set time out bit */
432static void set_tmout(unsigned long indicator)
433{
434 *(int *)indicator = 1;
435}
436
437void langwell_otg_nsf_msg(unsigned long indicator)
438{
439 struct langwell_otg *lnw = the_transceiver;
440
441 switch (indicator) {
442 case 2:
443 case 4:
444 case 6:
445 case 7:
446 dev_warn(lnw->dev,
447 "OTG:NSF-%lu - deivce not responding\n", indicator);
448 break;
449 case 3:
450 dev_warn(lnw->dev,
451 "OTG:NSF-%lu - deivce not supported\n", indicator);
452 break;
453 default:
454 dev_warn(lnw->dev, "Do not have this kind of NSF\n");
455 break;
456 }
457}
458
459/* Initialize timers */
460static int langwell_otg_init_timers(struct otg_hsm *hsm)
461{
462 /* HSM used timers */
463 a_wait_vrise_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_VRISE,
464 (unsigned long)&hsm->a_wait_vrise_tmout);
465 if (a_wait_vrise_tmr == NULL)
466 return -ENOMEM;
467 a_aidl_bdis_tmr = otg_timer_initializer(&set_tmout, TA_AIDL_BDIS,
468 (unsigned long)&hsm->a_aidl_bdis_tmout);
469 if (a_aidl_bdis_tmr == NULL)
470 return -ENOMEM;
471 b_se0_srp_tmr = otg_timer_initializer(&set_tmout, TB_SE0_SRP,
472 (unsigned long)&hsm->b_se0_srp);
473 if (b_se0_srp_tmr == NULL)
474 return -ENOMEM;
475 b_srp_init_tmr = otg_timer_initializer(&set_tmout, TB_SRP_INIT,
476 (unsigned long)&hsm->b_srp_init_tmout);
477 if (b_srp_init_tmr == NULL)
478 return -ENOMEM;
479
480 return 0;
481}
482
483/* Free timers */
484static void langwell_otg_free_timers(void)
485{
486 kfree(a_wait_vrise_tmr);
487 kfree(a_aidl_bdis_tmr);
488 kfree(b_se0_srp_tmr);
489 kfree(b_srp_init_tmr);
490}
491
492/* The timeout callback function to set time out bit */
493static void langwell_otg_timer_fn(unsigned long indicator)
494{
495 struct langwell_otg *lnw = the_transceiver;
496
497 *(int *)indicator = 1;
498
499 dev_dbg(lnw->dev, "kernel timer - timeout\n");
500
501 langwell_update_transceiver();
502}
503
504/* kernel timer used instead of HW based interrupt */
505static void langwell_otg_add_ktimer(enum langwell_otg_timer_type timers)
506{
507 struct langwell_otg *lnw = the_transceiver;
508 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
509 unsigned long j = jiffies;
510 unsigned long data, time;
511
512 switch (timers) {
513 case TA_WAIT_VRISE_TMR:
514 iotg->hsm.a_wait_vrise_tmout = 0;
515 data = (unsigned long)&iotg->hsm.a_wait_vrise_tmout;
516 time = TA_WAIT_VRISE;
517 break;
518 case TA_WAIT_BCON_TMR:
519 iotg->hsm.a_wait_bcon_tmout = 0;
520 data = (unsigned long)&iotg->hsm.a_wait_bcon_tmout;
521 time = TA_WAIT_BCON;
522 break;
523 case TA_AIDL_BDIS_TMR:
524 iotg->hsm.a_aidl_bdis_tmout = 0;
525 data = (unsigned long)&iotg->hsm.a_aidl_bdis_tmout;
526 time = TA_AIDL_BDIS;
527 break;
528 case TB_ASE0_BRST_TMR:
529 iotg->hsm.b_ase0_brst_tmout = 0;
530 data = (unsigned long)&iotg->hsm.b_ase0_brst_tmout;
531 time = TB_ASE0_BRST;
532 break;
533 case TB_SRP_INIT_TMR:
534 iotg->hsm.b_srp_init_tmout = 0;
535 data = (unsigned long)&iotg->hsm.b_srp_init_tmout;
536 time = TB_SRP_INIT;
537 break;
538 case TB_SRP_FAIL_TMR:
539 iotg->hsm.b_srp_fail_tmout = 0;
540 data = (unsigned long)&iotg->hsm.b_srp_fail_tmout;
541 time = TB_SRP_FAIL;
542 break;
543 case TB_BUS_SUSPEND_TMR:
544 iotg->hsm.b_bus_suspend_tmout = 0;
545 data = (unsigned long)&iotg->hsm.b_bus_suspend_tmout;
546 time = TB_BUS_SUSPEND;
547 break;
548 default:
549 dev_dbg(lnw->dev, "unknown timer, cannot enable it\n");
550 return;
551 }
552
553 lnw->hsm_timer.data = data;
554 lnw->hsm_timer.function = langwell_otg_timer_fn;
555 lnw->hsm_timer.expires = j + time * HZ / 1000; /* milliseconds */
556
557 add_timer(&lnw->hsm_timer);
558
559 dev_dbg(lnw->dev, "add timer successfully\n");
560}
561
562/* Add timer to timer list */
563static void langwell_otg_add_timer(void *gtimer)
564{
565 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
566 struct langwell_otg_timer *tmp_timer;
567 struct intel_mid_otg_xceiv *iotg = &the_transceiver->iotg;
568 u32 val32;
569
570 /* Check if the timer is already in the active list,
571 * if so update timer count
572 */
573 list_for_each_entry(tmp_timer, &active_timers, list)
574 if (tmp_timer == timer) {
575 timer->count = timer->expires;
576 return;
577 }
578 timer->count = timer->expires;
579
580 if (list_empty(&active_timers)) {
581 val32 = readl(iotg->base + CI_OTGSC);
582 writel(val32 | OTGSC_1MSE, iotg->base + CI_OTGSC);
583 }
584
585 list_add_tail(&timer->list, &active_timers);
586}
587
588/* Remove timer from the timer list; clear timeout status */
589static void langwell_otg_del_timer(void *gtimer)
590{
591 struct langwell_otg *lnw = the_transceiver;
592 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
593 struct langwell_otg_timer *tmp_timer, *del_tmp;
594 u32 val32;
595
596 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list)
597 if (tmp_timer == timer)
598 list_del(&timer->list);
599
600 if (list_empty(&active_timers)) {
601 val32 = readl(lnw->iotg.base + CI_OTGSC);
602 writel(val32 & ~OTGSC_1MSE, lnw->iotg.base + CI_OTGSC);
603 }
604}
605
606/* Reduce timer count by 1, and find timeout conditions.*/
607static int langwell_otg_tick_timer(u32 *int_sts)
608{
609 struct langwell_otg *lnw = the_transceiver;
610 struct langwell_otg_timer *tmp_timer, *del_tmp;
611 int expired = 0;
612
613 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list) {
614 tmp_timer->count--;
615 /* check if timer expires */
616 if (!tmp_timer->count) {
617 list_del(&tmp_timer->list);
618 tmp_timer->function(tmp_timer->data);
619 expired = 1;
620 }
621 }
622
623 if (list_empty(&active_timers)) {
624 dev_dbg(lnw->dev, "tick timer: disable 1ms int\n");
625 *int_sts = *int_sts & ~OTGSC_1MSE;
626 }
627 return expired;
628}
629
630static void reset_otg(void)
631{
632 struct langwell_otg *lnw = the_transceiver;
633 int delay_time = 1000;
634 u32 val;
635
636 dev_dbg(lnw->dev, "reseting OTG controller ...\n");
637 val = readl(lnw->iotg.base + CI_USBCMD);
638 writel(val | USBCMD_RST, lnw->iotg.base + CI_USBCMD);
639 do {
640 udelay(100);
641 if (!delay_time--)
642 dev_dbg(lnw->dev, "reset timeout\n");
643 val = readl(lnw->iotg.base + CI_USBCMD);
644 val &= USBCMD_RST;
645 } while (val != 0);
646 dev_dbg(lnw->dev, "reset done.\n");
647}
648
649static void set_host_mode(void)
650{
651 struct langwell_otg *lnw = the_transceiver;
652 u32 val;
653
654 reset_otg();
655 val = readl(lnw->iotg.base + CI_USBMODE);
656 val = (val & (~USBMODE_CM)) | USBMODE_HOST;
657 writel(val, lnw->iotg.base + CI_USBMODE);
658}
659
660static void set_client_mode(void)
661{
662 struct langwell_otg *lnw = the_transceiver;
663 u32 val;
664
665 reset_otg();
666 val = readl(lnw->iotg.base + CI_USBMODE);
667 val = (val & (~USBMODE_CM)) | USBMODE_DEVICE;
668 writel(val, lnw->iotg.base + CI_USBMODE);
669}
670
671static void init_hsm(void)
672{
673 struct langwell_otg *lnw = the_transceiver;
674 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
675 u32 val32;
676
677 /* read OTGSC after reset */
678 val32 = readl(lnw->iotg.base + CI_OTGSC);
679 dev_dbg(lnw->dev, "%s: OTGSC init value = 0x%x\n", __func__, val32);
680
681 /* set init state */
682 if (val32 & OTGSC_ID) {
683 iotg->hsm.id = 1;
684 iotg->otg.default_a = 0;
685 set_client_mode();
686 iotg->otg.state = OTG_STATE_B_IDLE;
687 } else {
688 iotg->hsm.id = 0;
689 iotg->otg.default_a = 1;
690 set_host_mode();
691 iotg->otg.state = OTG_STATE_A_IDLE;
692 }
693
694 /* set session indicator */
695 if (val32 & OTGSC_BSE)
696 iotg->hsm.b_sess_end = 1;
697 if (val32 & OTGSC_BSV)
698 iotg->hsm.b_sess_vld = 1;
699 if (val32 & OTGSC_ASV)
700 iotg->hsm.a_sess_vld = 1;
701 if (val32 & OTGSC_AVV)
702 iotg->hsm.a_vbus_vld = 1;
703
704 /* defautly power the bus */
705 iotg->hsm.a_bus_req = 1;
706 iotg->hsm.a_bus_drop = 0;
707 /* defautly don't request bus as B device */
708 iotg->hsm.b_bus_req = 0;
709 /* no system error */
710 iotg->hsm.a_clr_err = 0;
711
712 langwell_otg_phy_low_power_wait(1);
713}
714
715static void update_hsm(void)
716{
717 struct langwell_otg *lnw = the_transceiver;
718 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
719 u32 val32;
720
721 /* read OTGSC */
722 val32 = readl(lnw->iotg.base + CI_OTGSC);
723 dev_dbg(lnw->dev, "%s: OTGSC value = 0x%x\n", __func__, val32);
724
725 iotg->hsm.id = !!(val32 & OTGSC_ID);
726 iotg->hsm.b_sess_end = !!(val32 & OTGSC_BSE);
727 iotg->hsm.b_sess_vld = !!(val32 & OTGSC_BSV);
728 iotg->hsm.a_sess_vld = !!(val32 & OTGSC_ASV);
729 iotg->hsm.a_vbus_vld = !!(val32 & OTGSC_AVV);
730}
731
732static irqreturn_t otg_dummy_irq(int irq, void *_dev)
733{
734 struct langwell_otg *lnw = the_transceiver;
735 void __iomem *reg_base = _dev;
736 u32 val;
737 u32 int_mask = 0;
738
739 val = readl(reg_base + CI_USBMODE);
740 if ((val & USBMODE_CM) != USBMODE_DEVICE)
741 return IRQ_NONE;
742
743 val = readl(reg_base + CI_USBSTS);
744 int_mask = val & INTR_DUMMY_MASK;
745
746 if (int_mask == 0)
747 return IRQ_NONE;
748
749 /* clear hsm.b_conn here since host driver can't detect it
750 * otg_dummy_irq called means B-disconnect happened.
751 */
752 if (lnw->iotg.hsm.b_conn) {
753 lnw->iotg.hsm.b_conn = 0;
754 if (spin_trylock(&lnw->wq_lock)) {
755 langwell_update_transceiver();
756 spin_unlock(&lnw->wq_lock);
757 }
758 }
759
760 /* Clear interrupts */
761 writel(int_mask, reg_base + CI_USBSTS);
762 return IRQ_HANDLED;
763}
764
765static irqreturn_t otg_irq(int irq, void *_dev)
766{
767 struct langwell_otg *lnw = _dev;
768 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
769 u32 int_sts, int_en;
770 u32 int_mask = 0;
771 int flag = 0;
772
773 int_sts = readl(lnw->iotg.base + CI_OTGSC);
774 int_en = (int_sts & OTGSC_INTEN_MASK) >> 8;
775 int_mask = int_sts & int_en;
776 if (int_mask == 0)
777 return IRQ_NONE;
778
779 if (int_mask & OTGSC_IDIS) {
780 dev_dbg(lnw->dev, "%s: id change int\n", __func__);
781 iotg->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0;
782 dev_dbg(lnw->dev, "id = %d\n", iotg->hsm.id);
783 flag = 1;
784 }
785 if (int_mask & OTGSC_DPIS) {
786 dev_dbg(lnw->dev, "%s: data pulse int\n", __func__);
787 iotg->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0;
788 dev_dbg(lnw->dev, "data pulse = %d\n", iotg->hsm.a_srp_det);
789 flag = 1;
790 }
791 if (int_mask & OTGSC_BSEIS) {
792 dev_dbg(lnw->dev, "%s: b session end int\n", __func__);
793 iotg->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0;
794 dev_dbg(lnw->dev, "b_sess_end = %d\n", iotg->hsm.b_sess_end);
795 flag = 1;
796 }
797 if (int_mask & OTGSC_BSVIS) {
798 dev_dbg(lnw->dev, "%s: b session valid int\n", __func__);
799 iotg->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0;
800 dev_dbg(lnw->dev, "b_sess_vld = %d\n", iotg->hsm.b_sess_end);
801 flag = 1;
802 }
803 if (int_mask & OTGSC_ASVIS) {
804 dev_dbg(lnw->dev, "%s: a session valid int\n", __func__);
805 iotg->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0;
806 dev_dbg(lnw->dev, "a_sess_vld = %d\n", iotg->hsm.a_sess_vld);
807 flag = 1;
808 }
809 if (int_mask & OTGSC_AVVIS) {
810 dev_dbg(lnw->dev, "%s: a vbus valid int\n", __func__);
811 iotg->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0;
812 dev_dbg(lnw->dev, "a_vbus_vld = %d\n", iotg->hsm.a_vbus_vld);
813 flag = 1;
814 }
815
816 if (int_mask & OTGSC_1MSS) {
817 /* need to schedule otg_work if any timer is expired */
818 if (langwell_otg_tick_timer(&int_sts))
819 flag = 1;
820 }
821
822 writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask,
823 lnw->iotg.base + CI_OTGSC);
824 if (flag)
825 langwell_update_transceiver();
826
827 return IRQ_HANDLED;
828}
829
830static int langwell_otg_iotg_notify(struct notifier_block *nb,
831 unsigned long action, void *data)
832{
833 struct langwell_otg *lnw = the_transceiver;
834 struct intel_mid_otg_xceiv *iotg = data;
835 int flag = 0;
836
837 if (iotg == NULL)
838 return NOTIFY_BAD;
839
840 if (lnw == NULL)
841 return NOTIFY_BAD;
842
843 switch (action) {
844 case MID_OTG_NOTIFY_CONNECT:
845 dev_dbg(lnw->dev, "Lnw OTG Notify Connect Event\n");
846 if (iotg->otg.default_a == 1)
847 iotg->hsm.b_conn = 1;
848 else
849 iotg->hsm.a_conn = 1;
850 flag = 1;
851 break;
852 case MID_OTG_NOTIFY_DISCONN:
853 dev_dbg(lnw->dev, "Lnw OTG Notify Disconnect Event\n");
854 if (iotg->otg.default_a == 1)
855 iotg->hsm.b_conn = 0;
856 else
857 iotg->hsm.a_conn = 0;
858 flag = 1;
859 break;
860 case MID_OTG_NOTIFY_HSUSPEND:
861 dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus suspend Event\n");
862 if (iotg->otg.default_a == 1)
863 iotg->hsm.a_suspend_req = 1;
864 else
865 iotg->hsm.b_bus_req = 0;
866 flag = 1;
867 break;
868 case MID_OTG_NOTIFY_HRESUME:
869 dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus resume Event\n");
870 if (iotg->otg.default_a == 1)
871 iotg->hsm.b_bus_resume = 1;
872 flag = 1;
873 break;
874 case MID_OTG_NOTIFY_CSUSPEND:
875 dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus suspend Event\n");
876 if (iotg->otg.default_a == 1) {
877 if (iotg->hsm.b_bus_suspend_vld == 2) {
878 iotg->hsm.b_bus_suspend = 1;
879 iotg->hsm.b_bus_suspend_vld = 0;
880 flag = 1;
881 } else {
882 iotg->hsm.b_bus_suspend_vld++;
883 flag = 0;
884 }
885 } else {
886 if (iotg->hsm.a_bus_suspend == 0) {
887 iotg->hsm.a_bus_suspend = 1;
888 flag = 1;
889 }
890 }
891 break;
892 case MID_OTG_NOTIFY_CRESUME:
893 dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus resume Event\n");
894 if (iotg->otg.default_a == 0)
895 iotg->hsm.a_bus_suspend = 0;
896 flag = 0;
897 break;
898 case MID_OTG_NOTIFY_HOSTADD:
899 dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver Add\n");
900 flag = 1;
901 break;
902 case MID_OTG_NOTIFY_HOSTREMOVE:
903 dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver remove\n");
904 flag = 1;
905 break;
906 case MID_OTG_NOTIFY_CLIENTADD:
907 dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver Add\n");
908 flag = 1;
909 break;
910 case MID_OTG_NOTIFY_CLIENTREMOVE:
911 dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver remove\n");
912 flag = 1;
913 break;
914 default:
915 dev_dbg(lnw->dev, "Lnw OTG Nofity unknown notify message\n");
916 return NOTIFY_DONE;
917 }
918
919 if (flag)
920 langwell_update_transceiver();
921
922 return NOTIFY_OK;
923}
924
925static void langwell_otg_work(struct work_struct *work)
926{
927 struct langwell_otg *lnw;
928 struct intel_mid_otg_xceiv *iotg;
929 int retval;
930 struct pci_dev *pdev;
931
932 lnw = container_of(work, struct langwell_otg, work);
933 iotg = &lnw->iotg;
934 pdev = to_pci_dev(lnw->dev);
935
936 dev_dbg(lnw->dev, "%s: old state = %s\n", __func__,
937 otg_state_string(iotg->otg.state));
938
939 switch (iotg->otg.state) {
940 case OTG_STATE_UNDEFINED:
941 case OTG_STATE_B_IDLE:
942 if (!iotg->hsm.id) {
943 langwell_otg_del_timer(b_srp_init_tmr);
944 del_timer_sync(&lnw->hsm_timer);
945
946 iotg->otg.default_a = 1;
947 iotg->hsm.a_srp_det = 0;
948
949 langwell_otg_chrg_vbus(0);
950 set_host_mode();
951 langwell_otg_phy_low_power(1);
952
953 iotg->otg.state = OTG_STATE_A_IDLE;
954 langwell_update_transceiver();
955 } else if (iotg->hsm.b_sess_vld) {
956 langwell_otg_del_timer(b_srp_init_tmr);
957 del_timer_sync(&lnw->hsm_timer);
958 iotg->hsm.b_sess_end = 0;
959 iotg->hsm.a_bus_suspend = 0;
960 langwell_otg_chrg_vbus(0);
961
962 if (lnw->iotg.start_peripheral) {
963 lnw->iotg.start_peripheral(&lnw->iotg);
964 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
965 } else
966 dev_dbg(lnw->dev, "client driver not loaded\n");
967
968 } else if (iotg->hsm.b_srp_init_tmout) {
969 iotg->hsm.b_srp_init_tmout = 0;
970 dev_warn(lnw->dev, "SRP init timeout\n");
971 } else if (iotg->hsm.b_srp_fail_tmout) {
972 iotg->hsm.b_srp_fail_tmout = 0;
973 iotg->hsm.b_bus_req = 0;
974
975 /* No silence failure */
976 langwell_otg_nsf_msg(6);
977 } else if (iotg->hsm.b_bus_req && iotg->hsm.b_sess_end) {
978 del_timer_sync(&lnw->hsm_timer);
979 /* workaround for b_se0_srp detection */
980 retval = langwell_otg_check_se0_srp(0);
981 if (retval) {
982 iotg->hsm.b_bus_req = 0;
983 dev_dbg(lnw->dev, "LS isn't SE0, try later\n");
984 } else {
985 /* clear the PHCD before start srp */
986 langwell_otg_phy_low_power(0);
987
988 /* Start SRP */
989 langwell_otg_add_timer(b_srp_init_tmr);
990 iotg->otg.start_srp(&iotg->otg);
991 langwell_otg_del_timer(b_srp_init_tmr);
992 langwell_otg_add_ktimer(TB_SRP_FAIL_TMR);
993
994 /* reset PHY low power mode here */
995 langwell_otg_phy_low_power_wait(1);
996 }
997 }
998 break;
999 case OTG_STATE_B_SRP_INIT:
1000 if (!iotg->hsm.id) {
1001 iotg->otg.default_a = 1;
1002 iotg->hsm.a_srp_det = 0;
1003
1004 /* Turn off VBus */
1005 iotg->otg.set_vbus(&iotg->otg, false);
1006 langwell_otg_chrg_vbus(0);
1007 set_host_mode();
1008 langwell_otg_phy_low_power(1);
1009 iotg->otg.state = OTG_STATE_A_IDLE;
1010 langwell_update_transceiver();
1011 } else if (iotg->hsm.b_sess_vld) {
1012 langwell_otg_chrg_vbus(0);
1013 if (lnw->iotg.start_peripheral) {
1014 lnw->iotg.start_peripheral(&lnw->iotg);
1015 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1016 } else
1017 dev_dbg(lnw->dev, "client driver not loaded\n");
1018 }
1019 break;
1020 case OTG_STATE_B_PERIPHERAL:
1021 if (!iotg->hsm.id) {
1022 iotg->otg.default_a = 1;
1023 iotg->hsm.a_srp_det = 0;
1024
1025 langwell_otg_chrg_vbus(0);
1026
1027 if (lnw->iotg.stop_peripheral)
1028 lnw->iotg.stop_peripheral(&lnw->iotg);
1029 else
1030 dev_dbg(lnw->dev,
1031 "client driver has been removed.\n");
1032
1033 set_host_mode();
1034 langwell_otg_phy_low_power(1);
1035 iotg->otg.state = OTG_STATE_A_IDLE;
1036 langwell_update_transceiver();
1037 } else if (!iotg->hsm.b_sess_vld) {
1038 iotg->hsm.b_hnp_enable = 0;
1039
1040 if (lnw->iotg.stop_peripheral)
1041 lnw->iotg.stop_peripheral(&lnw->iotg);
1042 else
1043 dev_dbg(lnw->dev,
1044 "client driver has been removed.\n");
1045
1046 iotg->otg.state = OTG_STATE_B_IDLE;
1047 } else if (iotg->hsm.b_bus_req && iotg->otg.gadget &&
1048 iotg->otg.gadget->b_hnp_enable &&
1049 iotg->hsm.a_bus_suspend) {
1050
1051 if (lnw->iotg.stop_peripheral)
1052 lnw->iotg.stop_peripheral(&lnw->iotg);
1053 else
1054 dev_dbg(lnw->dev,
1055 "client driver has been removed.\n");
1056
1057 langwell_otg_HAAR(1);
1058 iotg->hsm.a_conn = 0;
1059
1060 if (lnw->iotg.start_host) {
1061 lnw->iotg.start_host(&lnw->iotg);
1062 iotg->otg.state = OTG_STATE_B_WAIT_ACON;
1063 } else
1064 dev_dbg(lnw->dev,
1065 "host driver not loaded.\n");
1066
1067 iotg->hsm.a_bus_resume = 0;
1068 langwell_otg_add_ktimer(TB_ASE0_BRST_TMR);
1069 }
1070 break;
1071
1072 case OTG_STATE_B_WAIT_ACON:
1073 if (!iotg->hsm.id) {
1074 /* delete hsm timer for b_ase0_brst_tmr */
1075 del_timer_sync(&lnw->hsm_timer);
1076
1077 iotg->otg.default_a = 1;
1078 iotg->hsm.a_srp_det = 0;
1079
1080 langwell_otg_chrg_vbus(0);
1081
1082 langwell_otg_HAAR(0);
1083 if (lnw->iotg.stop_host)
1084 lnw->iotg.stop_host(&lnw->iotg);
1085 else
1086 dev_dbg(lnw->dev,
1087 "host driver has been removed.\n");
1088
1089 set_host_mode();
1090 langwell_otg_phy_low_power(1);
1091 iotg->otg.state = OTG_STATE_A_IDLE;
1092 langwell_update_transceiver();
1093 } else if (!iotg->hsm.b_sess_vld) {
1094 /* delete hsm timer for b_ase0_brst_tmr */
1095 del_timer_sync(&lnw->hsm_timer);
1096
1097 iotg->hsm.b_hnp_enable = 0;
1098 iotg->hsm.b_bus_req = 0;
1099
1100 langwell_otg_chrg_vbus(0);
1101 langwell_otg_HAAR(0);
1102
1103 if (lnw->iotg.stop_host)
1104 lnw->iotg.stop_host(&lnw->iotg);
1105 else
1106 dev_dbg(lnw->dev,
1107 "host driver has been removed.\n");
1108
1109 set_client_mode();
1110 langwell_otg_phy_low_power(1);
1111 iotg->otg.state = OTG_STATE_B_IDLE;
1112 } else if (iotg->hsm.a_conn) {
1113 /* delete hsm timer for b_ase0_brst_tmr */
1114 del_timer_sync(&lnw->hsm_timer);
1115
1116 langwell_otg_HAAR(0);
1117 iotg->otg.state = OTG_STATE_B_HOST;
1118 langwell_update_transceiver();
1119 } else if (iotg->hsm.a_bus_resume ||
1120 iotg->hsm.b_ase0_brst_tmout) {
1121 /* delete hsm timer for b_ase0_brst_tmr */
1122 del_timer_sync(&lnw->hsm_timer);
1123
1124 langwell_otg_HAAR(0);
1125 langwell_otg_nsf_msg(7);
1126
1127 if (lnw->iotg.stop_host)
1128 lnw->iotg.stop_host(&lnw->iotg);
1129 else
1130 dev_dbg(lnw->dev,
1131 "host driver has been removed.\n");
1132
1133 iotg->hsm.a_bus_suspend = 0;
1134 iotg->hsm.b_bus_req = 0;
1135
1136 if (lnw->iotg.start_peripheral)
1137 lnw->iotg.start_peripheral(&lnw->iotg);
1138 else
1139 dev_dbg(lnw->dev,
1140 "client driver not loaded.\n");
1141
1142 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1143 }
1144 break;
1145
1146 case OTG_STATE_B_HOST:
1147 if (!iotg->hsm.id) {
1148 iotg->otg.default_a = 1;
1149 iotg->hsm.a_srp_det = 0;
1150
1151 langwell_otg_chrg_vbus(0);
1152
1153 if (lnw->iotg.stop_host)
1154 lnw->iotg.stop_host(&lnw->iotg);
1155 else
1156 dev_dbg(lnw->dev,
1157 "host driver has been removed.\n");
1158
1159 set_host_mode();
1160 langwell_otg_phy_low_power(1);
1161 iotg->otg.state = OTG_STATE_A_IDLE;
1162 langwell_update_transceiver();
1163 } else if (!iotg->hsm.b_sess_vld) {
1164 iotg->hsm.b_hnp_enable = 0;
1165 iotg->hsm.b_bus_req = 0;
1166
1167 langwell_otg_chrg_vbus(0);
1168 if (lnw->iotg.stop_host)
1169 lnw->iotg.stop_host(&lnw->iotg);
1170 else
1171 dev_dbg(lnw->dev,
1172 "host driver has been removed.\n");
1173
1174 set_client_mode();
1175 langwell_otg_phy_low_power(1);
1176 iotg->otg.state = OTG_STATE_B_IDLE;
1177 } else if ((!iotg->hsm.b_bus_req) ||
1178 (!iotg->hsm.a_conn)) {
1179 iotg->hsm.b_bus_req = 0;
1180 langwell_otg_loc_sof(0);
1181
1182 if (lnw->iotg.stop_host)
1183 lnw->iotg.stop_host(&lnw->iotg);
1184 else
1185 dev_dbg(lnw->dev,
1186 "host driver has been removed.\n");
1187
1188 iotg->hsm.a_bus_suspend = 0;
1189
1190 if (lnw->iotg.start_peripheral)
1191 lnw->iotg.start_peripheral(&lnw->iotg);
1192 else
1193 dev_dbg(lnw->dev,
1194 "client driver not loaded.\n");
1195
1196 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1197 }
1198 break;
1199
1200 case OTG_STATE_A_IDLE:
1201 iotg->otg.default_a = 1;
1202 if (iotg->hsm.id) {
1203 iotg->otg.default_a = 0;
1204 iotg->hsm.b_bus_req = 0;
1205 iotg->hsm.vbus_srp_up = 0;
1206
1207 langwell_otg_chrg_vbus(0);
1208 set_client_mode();
1209 langwell_otg_phy_low_power(1);
1210 iotg->otg.state = OTG_STATE_B_IDLE;
1211 langwell_update_transceiver();
1212 } else if (!iotg->hsm.a_bus_drop &&
1213 (iotg->hsm.a_srp_det || iotg->hsm.a_bus_req)) {
1214 langwell_otg_phy_low_power(0);
1215
1216 /* Turn on VBus */
1217 iotg->otg.set_vbus(&iotg->otg, true);
1218
1219 iotg->hsm.vbus_srp_up = 0;
1220 iotg->hsm.a_wait_vrise_tmout = 0;
1221 langwell_otg_add_timer(a_wait_vrise_tmr);
1222 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1223 langwell_update_transceiver();
1224 } else if (!iotg->hsm.a_bus_drop && iotg->hsm.a_sess_vld) {
1225 iotg->hsm.vbus_srp_up = 1;
1226 } else if (!iotg->hsm.a_sess_vld && iotg->hsm.vbus_srp_up) {
1227 msleep(10);
1228 langwell_otg_phy_low_power(0);
1229
1230 /* Turn on VBus */
1231 iotg->otg.set_vbus(&iotg->otg, true);
1232 iotg->hsm.a_srp_det = 1;
1233 iotg->hsm.vbus_srp_up = 0;
1234 iotg->hsm.a_wait_vrise_tmout = 0;
1235 langwell_otg_add_timer(a_wait_vrise_tmr);
1236 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1237 langwell_update_transceiver();
1238 } else if (!iotg->hsm.a_sess_vld &&
1239 !iotg->hsm.vbus_srp_up) {
1240 langwell_otg_phy_low_power(1);
1241 }
1242 break;
1243 case OTG_STATE_A_WAIT_VRISE:
1244 if (iotg->hsm.id) {
1245 langwell_otg_del_timer(a_wait_vrise_tmr);
1246 iotg->hsm.b_bus_req = 0;
1247 iotg->otg.default_a = 0;
1248
1249 /* Turn off VBus */
1250 iotg->otg.set_vbus(&iotg->otg, false);
1251 set_client_mode();
1252 langwell_otg_phy_low_power_wait(1);
1253 iotg->otg.state = OTG_STATE_B_IDLE;
1254 } else if (iotg->hsm.a_vbus_vld) {
1255 langwell_otg_del_timer(a_wait_vrise_tmr);
1256 iotg->hsm.b_conn = 0;
1257 if (lnw->iotg.start_host)
1258 lnw->iotg.start_host(&lnw->iotg);
1259 else {
1260 dev_dbg(lnw->dev, "host driver not loaded.\n");
1261 break;
1262 }
1263
1264 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1265 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1266 } else if (iotg->hsm.a_wait_vrise_tmout) {
1267 iotg->hsm.b_conn = 0;
1268 if (iotg->hsm.a_vbus_vld) {
1269 if (lnw->iotg.start_host)
1270 lnw->iotg.start_host(&lnw->iotg);
1271 else {
1272 dev_dbg(lnw->dev,
1273 "host driver not loaded.\n");
1274 break;
1275 }
1276 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1277 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1278 } else {
1279
1280 /* Turn off VBus */
1281 iotg->otg.set_vbus(&iotg->otg, false);
1282 langwell_otg_phy_low_power_wait(1);
1283 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1284 }
1285 }
1286 break;
1287 case OTG_STATE_A_WAIT_BCON:
1288 if (iotg->hsm.id) {
1289 /* delete hsm timer for a_wait_bcon_tmr */
1290 del_timer_sync(&lnw->hsm_timer);
1291
1292 iotg->otg.default_a = 0;
1293 iotg->hsm.b_bus_req = 0;
1294
1295 if (lnw->iotg.stop_host)
1296 lnw->iotg.stop_host(&lnw->iotg);
1297 else
1298 dev_dbg(lnw->dev,
1299 "host driver has been removed.\n");
1300
1301 /* Turn off VBus */
1302 iotg->otg.set_vbus(&iotg->otg, false);
1303 set_client_mode();
1304 langwell_otg_phy_low_power_wait(1);
1305 iotg->otg.state = OTG_STATE_B_IDLE;
1306 langwell_update_transceiver();
1307 } else if (!iotg->hsm.a_vbus_vld) {
1308 /* delete hsm timer for a_wait_bcon_tmr */
1309 del_timer_sync(&lnw->hsm_timer);
1310
1311 if (lnw->iotg.stop_host)
1312 lnw->iotg.stop_host(&lnw->iotg);
1313 else
1314 dev_dbg(lnw->dev,
1315 "host driver has been removed.\n");
1316
1317 /* Turn off VBus */
1318 iotg->otg.set_vbus(&iotg->otg, false);
1319 langwell_otg_phy_low_power_wait(1);
1320 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1321 } else if (iotg->hsm.a_bus_drop ||
1322 (iotg->hsm.a_wait_bcon_tmout &&
1323 !iotg->hsm.a_bus_req)) {
1324 /* delete hsm timer for a_wait_bcon_tmr */
1325 del_timer_sync(&lnw->hsm_timer);
1326
1327 if (lnw->iotg.stop_host)
1328 lnw->iotg.stop_host(&lnw->iotg);
1329 else
1330 dev_dbg(lnw->dev,
1331 "host driver has been removed.\n");
1332
1333 /* Turn off VBus */
1334 iotg->otg.set_vbus(&iotg->otg, false);
1335 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1336 } else if (iotg->hsm.b_conn) {
1337 /* delete hsm timer for a_wait_bcon_tmr */
1338 del_timer_sync(&lnw->hsm_timer);
1339
1340 iotg->hsm.a_suspend_req = 0;
1341 iotg->otg.state = OTG_STATE_A_HOST;
1342 if (iotg->hsm.a_srp_det && iotg->otg.host &&
1343 !iotg->otg.host->b_hnp_enable) {
1344 /* SRP capable peripheral-only device */
1345 iotg->hsm.a_bus_req = 1;
1346 iotg->hsm.a_srp_det = 0;
1347 } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
1348 iotg->otg.host->b_hnp_enable) {
1349 /* It is not safe enough to do a fast
1350 * transition from A_WAIT_BCON to
1351 * A_SUSPEND */
1352 msleep(10000);
1353 if (iotg->hsm.a_bus_req)
1354 break;
1355
1356 if (request_irq(pdev->irq,
1357 otg_dummy_irq, IRQF_SHARED,
1358 driver_name, iotg->base) != 0) {
1359 dev_dbg(lnw->dev,
1360 "request interrupt %d fail\n",
1361 pdev->irq);
1362 }
1363
1364 langwell_otg_HABA(1);
1365 iotg->hsm.b_bus_resume = 0;
1366 iotg->hsm.a_aidl_bdis_tmout = 0;
1367
1368 langwell_otg_loc_sof(0);
1369 /* clear PHCD to enable HW timer */
1370 langwell_otg_phy_low_power(0);
1371 langwell_otg_add_timer(a_aidl_bdis_tmr);
1372 iotg->otg.state = OTG_STATE_A_SUSPEND;
1373 } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
1374 !iotg->otg.host->b_hnp_enable) {
1375 if (lnw->iotg.stop_host)
1376 lnw->iotg.stop_host(&lnw->iotg);
1377 else
1378 dev_dbg(lnw->dev,
1379 "host driver removed.\n");
1380
1381 /* Turn off VBus */
1382 iotg->otg.set_vbus(&iotg->otg, false);
1383 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1384 }
1385 }
1386 break;
1387 case OTG_STATE_A_HOST:
1388 if (iotg->hsm.id) {
1389 iotg->otg.default_a = 0;
1390 iotg->hsm.b_bus_req = 0;
1391
1392 if (lnw->iotg.stop_host)
1393 lnw->iotg.stop_host(&lnw->iotg);
1394 else
1395 dev_dbg(lnw->dev,
1396 "host driver has been removed.\n");
1397
1398 /* Turn off VBus */
1399 iotg->otg.set_vbus(&iotg->otg, false);
1400 set_client_mode();
1401 langwell_otg_phy_low_power_wait(1);
1402 iotg->otg.state = OTG_STATE_B_IDLE;
1403 langwell_update_transceiver();
1404 } else if (iotg->hsm.a_bus_drop ||
1405 (iotg->otg.host &&
1406 !iotg->otg.host->b_hnp_enable &&
1407 !iotg->hsm.a_bus_req)) {
1408 if (lnw->iotg.stop_host)
1409 lnw->iotg.stop_host(&lnw->iotg);
1410 else
1411 dev_dbg(lnw->dev,
1412 "host driver has been removed.\n");
1413
1414 /* Turn off VBus */
1415 iotg->otg.set_vbus(&iotg->otg, false);
1416 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1417 } else if (!iotg->hsm.a_vbus_vld) {
1418 if (lnw->iotg.stop_host)
1419 lnw->iotg.stop_host(&lnw->iotg);
1420 else
1421 dev_dbg(lnw->dev,
1422 "host driver has been removed.\n");
1423
1424 /* Turn off VBus */
1425 iotg->otg.set_vbus(&iotg->otg, false);
1426 langwell_otg_phy_low_power_wait(1);
1427 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1428 } else if (iotg->otg.host &&
1429 iotg->otg.host->b_hnp_enable &&
1430 !iotg->hsm.a_bus_req) {
1431 /* Set HABA to enable hardware assistance to signal
1432 * A-connect after receiver B-disconnect. Hardware
1433 * will then set client mode and enable URE, SLE and
1434 * PCE after the assistance. otg_dummy_irq is used to
1435 * clean these ints when client driver is not resumed.
1436 */
1437 if (request_irq(pdev->irq, otg_dummy_irq, IRQF_SHARED,
1438 driver_name, iotg->base) != 0) {
1439 dev_dbg(lnw->dev,
1440 "request interrupt %d failed\n",
1441 pdev->irq);
1442 }
1443
1444 /* set HABA */
1445 langwell_otg_HABA(1);
1446 iotg->hsm.b_bus_resume = 0;
1447 iotg->hsm.a_aidl_bdis_tmout = 0;
1448 langwell_otg_loc_sof(0);
1449 /* clear PHCD to enable HW timer */
1450 langwell_otg_phy_low_power(0);
1451 langwell_otg_add_timer(a_aidl_bdis_tmr);
1452 iotg->otg.state = OTG_STATE_A_SUSPEND;
1453 } else if (!iotg->hsm.b_conn || !iotg->hsm.a_bus_req) {
1454 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1455 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1456 }
1457 break;
1458 case OTG_STATE_A_SUSPEND:
1459 if (iotg->hsm.id) {
1460 langwell_otg_del_timer(a_aidl_bdis_tmr);
1461 langwell_otg_HABA(0);
1462 free_irq(pdev->irq, iotg->base);
1463 iotg->otg.default_a = 0;
1464 iotg->hsm.b_bus_req = 0;
1465
1466 if (lnw->iotg.stop_host)
1467 lnw->iotg.stop_host(&lnw->iotg);
1468 else
1469 dev_dbg(lnw->dev,
1470 "host driver has been removed.\n");
1471
1472 /* Turn off VBus */
1473 iotg->otg.set_vbus(&iotg->otg, false);
1474 set_client_mode();
1475 langwell_otg_phy_low_power(1);
1476 iotg->otg.state = OTG_STATE_B_IDLE;
1477 langwell_update_transceiver();
1478 } else if (iotg->hsm.a_bus_req ||
1479 iotg->hsm.b_bus_resume) {
1480 langwell_otg_del_timer(a_aidl_bdis_tmr);
1481 langwell_otg_HABA(0);
1482 free_irq(pdev->irq, iotg->base);
1483 iotg->hsm.a_suspend_req = 0;
1484 langwell_otg_loc_sof(1);
1485 iotg->otg.state = OTG_STATE_A_HOST;
1486 } else if (iotg->hsm.a_aidl_bdis_tmout ||
1487 iotg->hsm.a_bus_drop) {
1488 langwell_otg_del_timer(a_aidl_bdis_tmr);
1489 langwell_otg_HABA(0);
1490 free_irq(pdev->irq, iotg->base);
1491 if (lnw->iotg.stop_host)
1492 lnw->iotg.stop_host(&lnw->iotg);
1493 else
1494 dev_dbg(lnw->dev,
1495 "host driver has been removed.\n");
1496
1497 /* Turn off VBus */
1498 iotg->otg.set_vbus(&iotg->otg, false);
1499 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1500 } else if (!iotg->hsm.b_conn && iotg->otg.host &&
1501 iotg->otg.host->b_hnp_enable) {
1502 langwell_otg_del_timer(a_aidl_bdis_tmr);
1503 langwell_otg_HABA(0);
1504 free_irq(pdev->irq, iotg->base);
1505
1506 if (lnw->iotg.stop_host)
1507 lnw->iotg.stop_host(&lnw->iotg);
1508 else
1509 dev_dbg(lnw->dev,
1510 "host driver has been removed.\n");
1511
1512 iotg->hsm.b_bus_suspend = 0;
1513 iotg->hsm.b_bus_suspend_vld = 0;
1514
1515 /* msleep(200); */
1516 if (lnw->iotg.start_peripheral)
1517 lnw->iotg.start_peripheral(&lnw->iotg);
1518 else
1519 dev_dbg(lnw->dev,
1520 "client driver not loaded.\n");
1521
1522 langwell_otg_add_ktimer(TB_BUS_SUSPEND_TMR);
1523 iotg->otg.state = OTG_STATE_A_PERIPHERAL;
1524 break;
1525 } else if (!iotg->hsm.a_vbus_vld) {
1526 langwell_otg_del_timer(a_aidl_bdis_tmr);
1527 langwell_otg_HABA(0);
1528 free_irq(pdev->irq, iotg->base);
1529 if (lnw->iotg.stop_host)
1530 lnw->iotg.stop_host(&lnw->iotg);
1531 else
1532 dev_dbg(lnw->dev,
1533 "host driver has been removed.\n");
1534
1535 /* Turn off VBus */
1536 iotg->otg.set_vbus(&iotg->otg, false);
1537 langwell_otg_phy_low_power_wait(1);
1538 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1539 }
1540 break;
1541 case OTG_STATE_A_PERIPHERAL:
1542 if (iotg->hsm.id) {
1543 /* delete hsm timer for b_bus_suspend_tmr */
1544 del_timer_sync(&lnw->hsm_timer);
1545 iotg->otg.default_a = 0;
1546 iotg->hsm.b_bus_req = 0;
1547 if (lnw->iotg.stop_peripheral)
1548 lnw->iotg.stop_peripheral(&lnw->iotg);
1549 else
1550 dev_dbg(lnw->dev,
1551 "client driver has been removed.\n");
1552
1553 /* Turn off VBus */
1554 iotg->otg.set_vbus(&iotg->otg, false);
1555 set_client_mode();
1556 langwell_otg_phy_low_power_wait(1);
1557 iotg->otg.state = OTG_STATE_B_IDLE;
1558 langwell_update_transceiver();
1559 } else if (!iotg->hsm.a_vbus_vld) {
1560 /* delete hsm timer for b_bus_suspend_tmr */
1561 del_timer_sync(&lnw->hsm_timer);
1562
1563 if (lnw->iotg.stop_peripheral)
1564 lnw->iotg.stop_peripheral(&lnw->iotg);
1565 else
1566 dev_dbg(lnw->dev,
1567 "client driver has been removed.\n");
1568
1569 /* Turn off VBus */
1570 iotg->otg.set_vbus(&iotg->otg, false);
1571 langwell_otg_phy_low_power_wait(1);
1572 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1573 } else if (iotg->hsm.a_bus_drop) {
1574 /* delete hsm timer for b_bus_suspend_tmr */
1575 del_timer_sync(&lnw->hsm_timer);
1576
1577 if (lnw->iotg.stop_peripheral)
1578 lnw->iotg.stop_peripheral(&lnw->iotg);
1579 else
1580 dev_dbg(lnw->dev,
1581 "client driver has been removed.\n");
1582
1583 /* Turn off VBus */
1584 iotg->otg.set_vbus(&iotg->otg, false);
1585 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1586 } else if (iotg->hsm.b_bus_suspend) {
1587 /* delete hsm timer for b_bus_suspend_tmr */
1588 del_timer_sync(&lnw->hsm_timer);
1589
1590 if (lnw->iotg.stop_peripheral)
1591 lnw->iotg.stop_peripheral(&lnw->iotg);
1592 else
1593 dev_dbg(lnw->dev,
1594 "client driver has been removed.\n");
1595
1596 if (lnw->iotg.start_host)
1597 lnw->iotg.start_host(&lnw->iotg);
1598 else
1599 dev_dbg(lnw->dev,
1600 "host driver not loaded.\n");
1601 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1602 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1603 } else if (iotg->hsm.b_bus_suspend_tmout) {
1604 u32 val;
1605 val = readl(lnw->iotg.base + CI_PORTSC1);
1606 if (!(val & PORTSC_SUSP))
1607 break;
1608
1609 if (lnw->iotg.stop_peripheral)
1610 lnw->iotg.stop_peripheral(&lnw->iotg);
1611 else
1612 dev_dbg(lnw->dev,
1613 "client driver has been removed.\n");
1614
1615 if (lnw->iotg.start_host)
1616 lnw->iotg.start_host(&lnw->iotg);
1617 else
1618 dev_dbg(lnw->dev,
1619 "host driver not loaded.\n");
1620 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1621 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1622 }
1623 break;
1624 case OTG_STATE_A_VBUS_ERR:
1625 if (iotg->hsm.id) {
1626 iotg->otg.default_a = 0;
1627 iotg->hsm.a_clr_err = 0;
1628 iotg->hsm.a_srp_det = 0;
1629 set_client_mode();
1630 langwell_otg_phy_low_power(1);
1631 iotg->otg.state = OTG_STATE_B_IDLE;
1632 langwell_update_transceiver();
1633 } else if (iotg->hsm.a_clr_err) {
1634 iotg->hsm.a_clr_err = 0;
1635 iotg->hsm.a_srp_det = 0;
1636 reset_otg();
1637 init_hsm();
1638 if (iotg->otg.state == OTG_STATE_A_IDLE)
1639 langwell_update_transceiver();
1640 } else {
1641 /* FW will clear PHCD bit when any VBus
1642 * event detected. Reset PHCD to 1 again */
1643 langwell_otg_phy_low_power(1);
1644 }
1645 break;
1646 case OTG_STATE_A_WAIT_VFALL:
1647 if (iotg->hsm.id) {
1648 iotg->otg.default_a = 0;
1649 set_client_mode();
1650 langwell_otg_phy_low_power(1);
1651 iotg->otg.state = OTG_STATE_B_IDLE;
1652 langwell_update_transceiver();
1653 } else if (iotg->hsm.a_bus_req) {
1654
1655 /* Turn on VBus */
1656 iotg->otg.set_vbus(&iotg->otg, true);
1657 iotg->hsm.a_wait_vrise_tmout = 0;
1658 langwell_otg_add_timer(a_wait_vrise_tmr);
1659 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1660 } else if (!iotg->hsm.a_sess_vld) {
1661 iotg->hsm.a_srp_det = 0;
1662 set_host_mode();
1663 langwell_otg_phy_low_power(1);
1664 iotg->otg.state = OTG_STATE_A_IDLE;
1665 }
1666 break;
1667 default:
1668 ;
1669 }
1670
1671 dev_dbg(lnw->dev, "%s: new state = %s\n", __func__,
1672 otg_state_string(iotg->otg.state));
1673}
1674
1675static ssize_t
1676show_registers(struct device *_dev, struct device_attribute *attr, char *buf)
1677{
1678 struct langwell_otg *lnw = the_transceiver;
1679 char *next;
1680 unsigned size, t;
1681
1682 next = buf;
1683 size = PAGE_SIZE;
1684
1685 t = scnprintf(next, size,
1686 "\n"
1687 "USBCMD = 0x%08x\n"
1688 "USBSTS = 0x%08x\n"
1689 "USBINTR = 0x%08x\n"
1690 "ASYNCLISTADDR = 0x%08x\n"
1691 "PORTSC1 = 0x%08x\n"
1692 "HOSTPC1 = 0x%08x\n"
1693 "OTGSC = 0x%08x\n"
1694 "USBMODE = 0x%08x\n",
1695 readl(lnw->iotg.base + 0x30),
1696 readl(lnw->iotg.base + 0x34),
1697 readl(lnw->iotg.base + 0x38),
1698 readl(lnw->iotg.base + 0x48),
1699 readl(lnw->iotg.base + 0x74),
1700 readl(lnw->iotg.base + 0xb4),
1701 readl(lnw->iotg.base + 0xf4),
1702 readl(lnw->iotg.base + 0xf8)
1703 );
1704 size -= t;
1705 next += t;
1706
1707 return PAGE_SIZE - size;
1708}
1709static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
1710
1711static ssize_t
1712show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
1713{
1714 struct langwell_otg *lnw = the_transceiver;
1715 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1716 char *next;
1717 unsigned size, t;
1718
1719 next = buf;
1720 size = PAGE_SIZE;
1721
1722 if (iotg->otg.host)
1723 iotg->hsm.a_set_b_hnp_en = iotg->otg.host->b_hnp_enable;
1724
1725 if (iotg->otg.gadget)
1726 iotg->hsm.b_hnp_enable = iotg->otg.gadget->b_hnp_enable;
1727
1728 t = scnprintf(next, size,
1729 "\n"
1730 "current state = %s\n"
1731 "a_bus_resume = \t%d\n"
1732 "a_bus_suspend = \t%d\n"
1733 "a_conn = \t%d\n"
1734 "a_sess_vld = \t%d\n"
1735 "a_srp_det = \t%d\n"
1736 "a_vbus_vld = \t%d\n"
1737 "b_bus_resume = \t%d\n"
1738 "b_bus_suspend = \t%d\n"
1739 "b_conn = \t%d\n"
1740 "b_se0_srp = \t%d\n"
1741 "b_sess_end = \t%d\n"
1742 "b_sess_vld = \t%d\n"
1743 "id = \t%d\n"
1744 "a_set_b_hnp_en = \t%d\n"
1745 "b_srp_done = \t%d\n"
1746 "b_hnp_enable = \t%d\n"
1747 "a_wait_vrise_tmout = \t%d\n"
1748 "a_wait_bcon_tmout = \t%d\n"
1749 "a_aidl_bdis_tmout = \t%d\n"
1750 "b_ase0_brst_tmout = \t%d\n"
1751 "a_bus_drop = \t%d\n"
1752 "a_bus_req = \t%d\n"
1753 "a_clr_err = \t%d\n"
1754 "a_suspend_req = \t%d\n"
1755 "b_bus_req = \t%d\n"
1756 "b_bus_suspend_tmout = \t%d\n"
1757 "b_bus_suspend_vld = \t%d\n",
1758 otg_state_string(iotg->otg.state),
1759 iotg->hsm.a_bus_resume,
1760 iotg->hsm.a_bus_suspend,
1761 iotg->hsm.a_conn,
1762 iotg->hsm.a_sess_vld,
1763 iotg->hsm.a_srp_det,
1764 iotg->hsm.a_vbus_vld,
1765 iotg->hsm.b_bus_resume,
1766 iotg->hsm.b_bus_suspend,
1767 iotg->hsm.b_conn,
1768 iotg->hsm.b_se0_srp,
1769 iotg->hsm.b_sess_end,
1770 iotg->hsm.b_sess_vld,
1771 iotg->hsm.id,
1772 iotg->hsm.a_set_b_hnp_en,
1773 iotg->hsm.b_srp_done,
1774 iotg->hsm.b_hnp_enable,
1775 iotg->hsm.a_wait_vrise_tmout,
1776 iotg->hsm.a_wait_bcon_tmout,
1777 iotg->hsm.a_aidl_bdis_tmout,
1778 iotg->hsm.b_ase0_brst_tmout,
1779 iotg->hsm.a_bus_drop,
1780 iotg->hsm.a_bus_req,
1781 iotg->hsm.a_clr_err,
1782 iotg->hsm.a_suspend_req,
1783 iotg->hsm.b_bus_req,
1784 iotg->hsm.b_bus_suspend_tmout,
1785 iotg->hsm.b_bus_suspend_vld
1786 );
1787 size -= t;
1788 next += t;
1789
1790 return PAGE_SIZE - size;
1791}
1792static DEVICE_ATTR(hsm, S_IRUGO, show_hsm, NULL);
1793
1794static ssize_t
1795get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1796{
1797 struct langwell_otg *lnw = the_transceiver;
1798 char *next;
1799 unsigned size, t;
1800
1801 next = buf;
1802 size = PAGE_SIZE;
1803
1804 t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_req);
1805 size -= t;
1806 next += t;
1807
1808 return PAGE_SIZE - size;
1809}
1810
1811static ssize_t
1812set_a_bus_req(struct device *dev, struct device_attribute *attr,
1813 const char *buf, size_t count)
1814{
1815 struct langwell_otg *lnw = the_transceiver;
1816 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1817
1818 if (!iotg->otg.default_a)
1819 return -1;
1820 if (count > 2)
1821 return -1;
1822
1823 if (buf[0] == '0') {
1824 iotg->hsm.a_bus_req = 0;
1825 dev_dbg(lnw->dev, "User request: a_bus_req = 0\n");
1826 } else if (buf[0] == '1') {
1827 /* If a_bus_drop is TRUE, a_bus_req can't be set */
1828 if (iotg->hsm.a_bus_drop)
1829 return -1;
1830 iotg->hsm.a_bus_req = 1;
1831 dev_dbg(lnw->dev, "User request: a_bus_req = 1\n");
1832 }
1833 if (spin_trylock(&lnw->wq_lock)) {
1834 langwell_update_transceiver();
1835 spin_unlock(&lnw->wq_lock);
1836 }
1837 return count;
1838}
1839static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
1840
1841static ssize_t
1842get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
1843{
1844 struct langwell_otg *lnw = the_transceiver;
1845 char *next;
1846 unsigned size, t;
1847
1848 next = buf;
1849 size = PAGE_SIZE;
1850
1851 t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_drop);
1852 size -= t;
1853 next += t;
1854
1855 return PAGE_SIZE - size;
1856}
1857
1858static ssize_t
1859set_a_bus_drop(struct device *dev, struct device_attribute *attr,
1860 const char *buf, size_t count)
1861{
1862 struct langwell_otg *lnw = the_transceiver;
1863 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1864
1865 if (!iotg->otg.default_a)
1866 return -1;
1867 if (count > 2)
1868 return -1;
1869
1870 if (buf[0] == '0') {
1871 iotg->hsm.a_bus_drop = 0;
1872 dev_dbg(lnw->dev, "User request: a_bus_drop = 0\n");
1873 } else if (buf[0] == '1') {
1874 iotg->hsm.a_bus_drop = 1;
1875 iotg->hsm.a_bus_req = 0;
1876 dev_dbg(lnw->dev, "User request: a_bus_drop = 1\n");
1877 dev_dbg(lnw->dev, "User request: and a_bus_req = 0\n");
1878 }
1879 if (spin_trylock(&lnw->wq_lock)) {
1880 langwell_update_transceiver();
1881 spin_unlock(&lnw->wq_lock);
1882 }
1883 return count;
1884}
1885static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, set_a_bus_drop);
1886
1887static ssize_t
1888get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1889{
1890 struct langwell_otg *lnw = the_transceiver;
1891 char *next;
1892 unsigned size, t;
1893
1894 next = buf;
1895 size = PAGE_SIZE;
1896
1897 t = scnprintf(next, size, "%d", lnw->iotg.hsm.b_bus_req);
1898 size -= t;
1899 next += t;
1900
1901 return PAGE_SIZE - size;
1902}
1903
1904static ssize_t
1905set_b_bus_req(struct device *dev, struct device_attribute *attr,
1906 const char *buf, size_t count)
1907{
1908 struct langwell_otg *lnw = the_transceiver;
1909 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1910
1911 if (iotg->otg.default_a)
1912 return -1;
1913
1914 if (count > 2)
1915 return -1;
1916
1917 if (buf[0] == '0') {
1918 iotg->hsm.b_bus_req = 0;
1919 dev_dbg(lnw->dev, "User request: b_bus_req = 0\n");
1920 } else if (buf[0] == '1') {
1921 iotg->hsm.b_bus_req = 1;
1922 dev_dbg(lnw->dev, "User request: b_bus_req = 1\n");
1923 }
1924 if (spin_trylock(&lnw->wq_lock)) {
1925 langwell_update_transceiver();
1926 spin_unlock(&lnw->wq_lock);
1927 }
1928 return count;
1929}
1930static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req);
1931
1932static ssize_t
1933set_a_clr_err(struct device *dev, struct device_attribute *attr,
1934 const char *buf, size_t count)
1935{
1936 struct langwell_otg *lnw = the_transceiver;
1937 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1938
1939 if (!iotg->otg.default_a)
1940 return -1;
1941 if (count > 2)
1942 return -1;
1943
1944 if (buf[0] == '1') {
1945 iotg->hsm.a_clr_err = 1;
1946 dev_dbg(lnw->dev, "User request: a_clr_err = 1\n");
1947 }
1948 if (spin_trylock(&lnw->wq_lock)) {
1949 langwell_update_transceiver();
1950 spin_unlock(&lnw->wq_lock);
1951 }
1952 return count;
1953}
1954static DEVICE_ATTR(a_clr_err, S_IWUSR, NULL, set_a_clr_err);
1955
1956static struct attribute *inputs_attrs[] = {
1957 &dev_attr_a_bus_req.attr,
1958 &dev_attr_a_bus_drop.attr,
1959 &dev_attr_b_bus_req.attr,
1960 &dev_attr_a_clr_err.attr,
1961 NULL,
1962};
1963
1964static struct attribute_group debug_dev_attr_group = {
1965 .name = "inputs",
1966 .attrs = inputs_attrs,
1967};
1968
1969static int langwell_otg_probe(struct pci_dev *pdev,
1970 const struct pci_device_id *id)
1971{
1972 unsigned long resource, len;
1973 void __iomem *base = NULL;
1974 int retval;
1975 u32 val32;
1976 struct langwell_otg *lnw;
1977 char qname[] = "langwell_otg_queue";
1978
1979 retval = 0;
1980 dev_dbg(&pdev->dev, "\notg controller is detected.\n");
1981 if (pci_enable_device(pdev) < 0) {
1982 retval = -ENODEV;
1983 goto done;
1984 }
1985
1986 lnw = kzalloc(sizeof *lnw, GFP_KERNEL);
1987 if (lnw == NULL) {
1988 retval = -ENOMEM;
1989 goto done;
1990 }
1991 the_transceiver = lnw;
1992
1993 /* control register: BAR 0 */
1994 resource = pci_resource_start(pdev, 0);
1995 len = pci_resource_len(pdev, 0);
1996 if (!request_mem_region(resource, len, driver_name)) {
1997 retval = -EBUSY;
1998 goto err;
1999 }
2000 lnw->region = 1;
2001
2002 base = ioremap_nocache(resource, len);
2003 if (base == NULL) {
2004 retval = -EFAULT;
2005 goto err;
2006 }
2007 lnw->iotg.base = base;
2008
2009 if (!request_mem_region(USBCFG_ADDR, USBCFG_LEN, driver_name)) {
2010 retval = -EBUSY;
2011 goto err;
2012 }
2013 lnw->cfg_region = 1;
2014
2015 /* For the SCCB.USBCFG register */
2016 base = ioremap_nocache(USBCFG_ADDR, USBCFG_LEN);
2017 if (base == NULL) {
2018 retval = -EFAULT;
2019 goto err;
2020 }
2021 lnw->usbcfg = base;
2022
2023 if (!pdev->irq) {
2024 dev_dbg(&pdev->dev, "No IRQ.\n");
2025 retval = -ENODEV;
2026 goto err;
2027 }
2028
2029 lnw->qwork = create_singlethread_workqueue(qname);
2030 if (!lnw->qwork) {
2031 dev_dbg(&pdev->dev, "cannot create workqueue %s\n", qname);
2032 retval = -ENOMEM;
2033 goto err;
2034 }
2035 INIT_WORK(&lnw->work, langwell_otg_work);
2036
2037 /* OTG common part */
2038 lnw->dev = &pdev->dev;
2039 lnw->iotg.otg.dev = lnw->dev;
2040 lnw->iotg.otg.label = driver_name;
2041 lnw->iotg.otg.set_host = langwell_otg_set_host;
2042 lnw->iotg.otg.set_peripheral = langwell_otg_set_peripheral;
2043 lnw->iotg.otg.set_power = langwell_otg_set_power;
2044 lnw->iotg.otg.set_vbus = langwell_otg_set_vbus;
2045 lnw->iotg.otg.start_srp = langwell_otg_start_srp;
2046 lnw->iotg.otg.state = OTG_STATE_UNDEFINED;
2047
2048 if (otg_set_transceiver(&lnw->iotg.otg)) {
2049 dev_dbg(lnw->dev, "can't set transceiver\n");
2050 retval = -EBUSY;
2051 goto err;
2052 }
2053
2054 reset_otg();
2055 init_hsm();
2056
2057 spin_lock_init(&lnw->lock);
2058 spin_lock_init(&lnw->wq_lock);
2059 INIT_LIST_HEAD(&active_timers);
2060 retval = langwell_otg_init_timers(&lnw->iotg.hsm);
2061 if (retval) {
2062 dev_dbg(&pdev->dev, "Failed to init timers\n");
2063 goto err;
2064 }
2065
2066 init_timer(&lnw->hsm_timer);
2067 ATOMIC_INIT_NOTIFIER_HEAD(&lnw->iotg.iotg_notifier);
2068
2069 lnw->iotg_notifier.notifier_call = langwell_otg_iotg_notify;
2070
2071 retval = intel_mid_otg_register_notifier(&lnw->iotg,
2072 &lnw->iotg_notifier);
2073 if (retval) {
2074 dev_dbg(lnw->dev, "Failed to register notifier\n");
2075 goto err;
2076 }
2077
2078 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
2079 driver_name, lnw) != 0) {
2080 dev_dbg(lnw->dev, "request interrupt %d failed\n", pdev->irq);
2081 retval = -EBUSY;
2082 goto err;
2083 }
2084
2085 /* enable OTGSC int */
2086 val32 = OTGSC_DPIE | OTGSC_BSEIE | OTGSC_BSVIE |
2087 OTGSC_ASVIE | OTGSC_AVVIE | OTGSC_IDIE | OTGSC_IDPU;
2088 writel(val32, lnw->iotg.base + CI_OTGSC);
2089
2090 retval = device_create_file(&pdev->dev, &dev_attr_registers);
2091 if (retval < 0) {
2092 dev_dbg(lnw->dev,
2093 "Can't register sysfs attribute: %d\n", retval);
2094 goto err;
2095 }
2096
2097 retval = device_create_file(&pdev->dev, &dev_attr_hsm);
2098 if (retval < 0) {
2099 dev_dbg(lnw->dev, "Can't hsm sysfs attribute: %d\n", retval);
2100 goto err;
2101 }
2102
2103 retval = sysfs_create_group(&pdev->dev.kobj, &debug_dev_attr_group);
2104 if (retval < 0) {
2105 dev_dbg(lnw->dev,
2106 "Can't register sysfs attr group: %d\n", retval);
2107 goto err;
2108 }
2109
2110 if (lnw->iotg.otg.state == OTG_STATE_A_IDLE)
2111 langwell_update_transceiver();
2112
2113 return 0;
2114
2115err:
2116 if (the_transceiver)
2117 langwell_otg_remove(pdev);
2118done:
2119 return retval;
2120}
2121
2122static void langwell_otg_remove(struct pci_dev *pdev)
2123{
2124 struct langwell_otg *lnw = the_transceiver;
2125
2126 if (lnw->qwork) {
2127 flush_workqueue(lnw->qwork);
2128 destroy_workqueue(lnw->qwork);
2129 }
2130 intel_mid_otg_unregister_notifier(&lnw->iotg, &lnw->iotg_notifier);
2131 langwell_otg_free_timers();
2132
2133 /* disable OTGSC interrupt as OTGSC doesn't change in reset */
2134 writel(0, lnw->iotg.base + CI_OTGSC);
2135
2136 if (pdev->irq)
2137 free_irq(pdev->irq, lnw);
2138 if (lnw->usbcfg)
2139 iounmap(lnw->usbcfg);
2140 if (lnw->cfg_region)
2141 release_mem_region(USBCFG_ADDR, USBCFG_LEN);
2142 if (lnw->iotg.base)
2143 iounmap(lnw->iotg.base);
2144 if (lnw->region)
2145 release_mem_region(pci_resource_start(pdev, 0),
2146 pci_resource_len(pdev, 0));
2147
2148 otg_set_transceiver(NULL);
2149 pci_disable_device(pdev);
2150 sysfs_remove_group(&pdev->dev.kobj, &debug_dev_attr_group);
2151 device_remove_file(&pdev->dev, &dev_attr_hsm);
2152 device_remove_file(&pdev->dev, &dev_attr_registers);
2153 kfree(lnw);
2154 lnw = NULL;
2155}
2156
2157static void transceiver_suspend(struct pci_dev *pdev)
2158{
2159 pci_save_state(pdev);
2160 pci_set_power_state(pdev, PCI_D3hot);
2161 langwell_otg_phy_low_power(1);
2162}
2163
2164static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
2165{
2166 struct langwell_otg *lnw = the_transceiver;
2167 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
2168 int ret = 0;
2169
2170 /* Disbale OTG interrupts */
2171 langwell_otg_intr(0);
2172
2173 if (pdev->irq)
2174 free_irq(pdev->irq, lnw);
2175
2176 /* Prevent more otg_work */
2177 flush_workqueue(lnw->qwork);
2178 destroy_workqueue(lnw->qwork);
2179 lnw->qwork = NULL;
2180
2181 /* start actions */
2182 switch (iotg->otg.state) {
2183 case OTG_STATE_A_WAIT_VFALL:
2184 iotg->otg.state = OTG_STATE_A_IDLE;
2185 case OTG_STATE_A_IDLE:
2186 case OTG_STATE_B_IDLE:
2187 case OTG_STATE_A_VBUS_ERR:
2188 transceiver_suspend(pdev);
2189 break;
2190 case OTG_STATE_A_WAIT_VRISE:
2191 langwell_otg_del_timer(a_wait_vrise_tmr);
2192 iotg->hsm.a_srp_det = 0;
2193
2194 /* Turn off VBus */
2195 iotg->otg.set_vbus(&iotg->otg, false);
2196 iotg->otg.state = OTG_STATE_A_IDLE;
2197 transceiver_suspend(pdev);
2198 break;
2199 case OTG_STATE_A_WAIT_BCON:
2200 del_timer_sync(&lnw->hsm_timer);
2201 if (lnw->iotg.stop_host)
2202 lnw->iotg.stop_host(&lnw->iotg);
2203 else
2204 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2205
2206 iotg->hsm.a_srp_det = 0;
2207
2208 /* Turn off VBus */
2209 iotg->otg.set_vbus(&iotg->otg, false);
2210 iotg->otg.state = OTG_STATE_A_IDLE;
2211 transceiver_suspend(pdev);
2212 break;
2213 case OTG_STATE_A_HOST:
2214 if (lnw->iotg.stop_host)
2215 lnw->iotg.stop_host(&lnw->iotg);
2216 else
2217 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2218
2219 iotg->hsm.a_srp_det = 0;
2220
2221 /* Turn off VBus */
2222 iotg->otg.set_vbus(&iotg->otg, false);
2223
2224 iotg->otg.state = OTG_STATE_A_IDLE;
2225 transceiver_suspend(pdev);
2226 break;
2227 case OTG_STATE_A_SUSPEND:
2228 langwell_otg_del_timer(a_aidl_bdis_tmr);
2229 langwell_otg_HABA(0);
2230 if (lnw->iotg.stop_host)
2231 lnw->iotg.stop_host(&lnw->iotg);
2232 else
2233 dev_dbg(lnw->dev, "host driver has been removed.\n");
2234 iotg->hsm.a_srp_det = 0;
2235
2236 /* Turn off VBus */
2237 iotg->otg.set_vbus(&iotg->otg, false);
2238 iotg->otg.state = OTG_STATE_A_IDLE;
2239 transceiver_suspend(pdev);
2240 break;
2241 case OTG_STATE_A_PERIPHERAL:
2242 del_timer_sync(&lnw->hsm_timer);
2243
2244 if (lnw->iotg.stop_peripheral)
2245 lnw->iotg.stop_peripheral(&lnw->iotg);
2246 else
2247 dev_dbg(&pdev->dev,
2248 "client driver has been removed.\n");
2249 iotg->hsm.a_srp_det = 0;
2250
2251 /* Turn off VBus */
2252 iotg->otg.set_vbus(&iotg->otg, false);
2253 iotg->otg.state = OTG_STATE_A_IDLE;
2254 transceiver_suspend(pdev);
2255 break;
2256 case OTG_STATE_B_HOST:
2257 if (lnw->iotg.stop_host)
2258 lnw->iotg.stop_host(&lnw->iotg);
2259 else
2260 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2261 iotg->hsm.b_bus_req = 0;
2262 iotg->otg.state = OTG_STATE_B_IDLE;
2263 transceiver_suspend(pdev);
2264 break;
2265 case OTG_STATE_B_PERIPHERAL:
2266 if (lnw->iotg.stop_peripheral)
2267 lnw->iotg.stop_peripheral(&lnw->iotg);
2268 else
2269 dev_dbg(&pdev->dev,
2270 "client driver has been removed.\n");
2271 iotg->otg.state = OTG_STATE_B_IDLE;
2272 transceiver_suspend(pdev);
2273 break;
2274 case OTG_STATE_B_WAIT_ACON:
2275 /* delete hsm timer for b_ase0_brst_tmr */
2276 del_timer_sync(&lnw->hsm_timer);
2277
2278 langwell_otg_HAAR(0);
2279
2280 if (lnw->iotg.stop_host)
2281 lnw->iotg.stop_host(&lnw->iotg);
2282 else
2283 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2284 iotg->hsm.b_bus_req = 0;
2285 iotg->otg.state = OTG_STATE_B_IDLE;
2286 transceiver_suspend(pdev);
2287 break;
2288 default:
2289 dev_dbg(lnw->dev, "error state before suspend\n");
2290 break;
2291 }
2292
2293 return ret;
2294}
2295
2296static void transceiver_resume(struct pci_dev *pdev)
2297{
2298 pci_restore_state(pdev);
2299 pci_set_power_state(pdev, PCI_D0);
2300}
2301
2302static int langwell_otg_resume(struct pci_dev *pdev)
2303{
2304 struct langwell_otg *lnw = the_transceiver;
2305 int ret = 0;
2306
2307 transceiver_resume(pdev);
2308
2309 lnw->qwork = create_singlethread_workqueue("langwell_otg_queue");
2310 if (!lnw->qwork) {
2311 dev_dbg(&pdev->dev, "cannot create langwell otg workqueuen");
2312 ret = -ENOMEM;
2313 goto error;
2314 }
2315
2316 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
2317 driver_name, lnw) != 0) {
2318 dev_dbg(&pdev->dev, "request interrupt %d failed\n", pdev->irq);
2319 ret = -EBUSY;
2320 goto error;
2321 }
2322
2323 /* enable OTG interrupts */
2324 langwell_otg_intr(1);
2325
2326 update_hsm();
2327
2328 langwell_update_transceiver();
2329
2330 return ret;
2331error:
2332 langwell_otg_intr(0);
2333 transceiver_suspend(pdev);
2334 return ret;
2335}
2336
2337static int __init langwell_otg_init(void)
2338{
2339 return pci_register_driver(&otg_pci_driver);
2340}
2341module_init(langwell_otg_init);
2342
2343static void __exit langwell_otg_cleanup(void)
2344{
2345 pci_unregister_driver(&otg_pci_driver);
2346}
2347module_exit(langwell_otg_cleanup);
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index db0d4fcdc8e2..b5fbe1452ab0 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -202,6 +202,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)
202 202
203static void mv_otg_start_host(struct mv_otg *mvotg, int on) 203static void mv_otg_start_host(struct mv_otg *mvotg, int on)
204{ 204{
205#ifdef CONFIG_USB
205 struct otg_transceiver *otg = &mvotg->otg; 206 struct otg_transceiver *otg = &mvotg->otg;
206 struct usb_hcd *hcd; 207 struct usb_hcd *hcd;
207 208
@@ -216,6 +217,7 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
216 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); 217 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
217 else 218 else
218 usb_remove_hcd(hcd); 219 usb_remove_hcd(hcd);
220#endif /* CONFIG_USB */
219} 221}
220 222
221static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) 223static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 528691d5f3e2..7542aa94a462 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -425,7 +425,7 @@ static int usbhsg_recip_run_handle(struct usbhs_priv *priv,
425 struct usbhs_pipe *pipe; 425 struct usbhs_pipe *pipe;
426 int recip = ctrl->bRequestType & USB_RECIP_MASK; 426 int recip = ctrl->bRequestType & USB_RECIP_MASK;
427 int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK; 427 int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK;
428 int ret; 428 int ret = 0;
429 int (*func)(struct usbhs_priv *priv, struct usbhsg_uep *uep, 429 int (*func)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
430 struct usb_ctrlrequest *ctrl); 430 struct usb_ctrlrequest *ctrl);
431 char *msg; 431 char *msg;
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index fba1147ed916..8dbf51a43c45 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -39,6 +39,8 @@ static void cp210x_get_termios(struct tty_struct *,
39 struct usb_serial_port *port); 39 struct usb_serial_port *port);
40static void cp210x_get_termios_port(struct usb_serial_port *port, 40static void cp210x_get_termios_port(struct usb_serial_port *port,
41 unsigned int *cflagp, unsigned int *baudp); 41 unsigned int *cflagp, unsigned int *baudp);
42static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
43 struct ktermios *);
42static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *, 44static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
43 struct ktermios*); 45 struct ktermios*);
44static int cp210x_tiocmget(struct tty_struct *); 46static int cp210x_tiocmget(struct tty_struct *);
@@ -138,6 +140,7 @@ static const struct usb_device_id id_table[] = {
138 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ 140 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
139 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 141 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
140 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ 142 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
143 { USB_DEVICE(0x3195, 0xF190) }, /* Link Instruments MSO-19 */
141 { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ 144 { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
142 { } /* Terminating Entry */ 145 { } /* Terminating Entry */
143}; 146};
@@ -201,6 +204,8 @@ static struct usb_serial_driver cp210x_device = {
201#define CP210X_EMBED_EVENTS 0x15 204#define CP210X_EMBED_EVENTS 0x15
202#define CP210X_GET_EVENTSTATE 0x16 205#define CP210X_GET_EVENTSTATE 0x16
203#define CP210X_SET_CHARS 0x19 206#define CP210X_SET_CHARS 0x19
207#define CP210X_GET_BAUDRATE 0x1D
208#define CP210X_SET_BAUDRATE 0x1E
204 209
205/* CP210X_IFC_ENABLE */ 210/* CP210X_IFC_ENABLE */
206#define UART_ENABLE 0x0001 211#define UART_ENABLE 0x0001
@@ -360,8 +365,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port,
360 * Quantises the baud rate as per AN205 Table 1 365 * Quantises the baud rate as per AN205 Table 1
361 */ 366 */
362static unsigned int cp210x_quantise_baudrate(unsigned int baud) { 367static unsigned int cp210x_quantise_baudrate(unsigned int baud) {
363 if (baud <= 56) baud = 0; 368 if (baud <= 300)
364 else if (baud <= 300) baud = 300; 369 baud = 300;
365 else if (baud <= 600) baud = 600; 370 else if (baud <= 600) baud = 600;
366 else if (baud <= 1200) baud = 1200; 371 else if (baud <= 1200) baud = 1200;
367 else if (baud <= 1800) baud = 1800; 372 else if (baud <= 1800) baud = 1800;
@@ -389,10 +394,10 @@ static unsigned int cp210x_quantise_baudrate(unsigned int baud) {
389 else if (baud <= 491520) baud = 460800; 394 else if (baud <= 491520) baud = 460800;
390 else if (baud <= 567138) baud = 500000; 395 else if (baud <= 567138) baud = 500000;
391 else if (baud <= 670254) baud = 576000; 396 else if (baud <= 670254) baud = 576000;
392 else if (baud <= 1053257) baud = 921600; 397 else if (baud < 1000000)
393 else if (baud <= 1474560) baud = 1228800; 398 baud = 921600;
394 else if (baud <= 2457600) baud = 1843200; 399 else if (baud > 2000000)
395 else baud = 3686400; 400 baud = 2000000;
396 return baud; 401 return baud;
397} 402}
398 403
@@ -409,13 +414,14 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
409 return result; 414 return result;
410 } 415 }
411 416
412 result = usb_serial_generic_open(tty, port);
413 if (result)
414 return result;
415
416 /* Configure the termios structure */ 417 /* Configure the termios structure */
417 cp210x_get_termios(tty, port); 418 cp210x_get_termios(tty, port);
418 return 0; 419
420 /* The baud rate must be initialised on cp2104 */
421 if (tty)
422 cp210x_change_speed(tty, port, NULL);
423
424 return usb_serial_generic_open(tty, port);
419} 425}
420 426
421static void cp210x_close(struct usb_serial_port *port) 427static void cp210x_close(struct usb_serial_port *port)
@@ -467,10 +473,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
467 473
468 dbg("%s - port %d", __func__, port->number); 474 dbg("%s - port %d", __func__, port->number);
469 475
470 cp210x_get_config(port, CP210X_GET_BAUDDIV, &baud, 2); 476 cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4);
471 /* Convert to baudrate */
472 if (baud)
473 baud = cp210x_quantise_baudrate((BAUD_RATE_GEN_FREQ + baud/2)/ baud);
474 477
475 dbg("%s - baud rate = %d", __func__, baud); 478 dbg("%s - baud rate = %d", __func__, baud);
476 *baudp = baud; 479 *baudp = baud;
@@ -579,11 +582,64 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
579 *cflagp = cflag; 582 *cflagp = cflag;
580} 583}
581 584
585/*
586 * CP2101 supports the following baud rates:
587 *
588 * 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800,
589 * 38400, 56000, 57600, 115200, 128000, 230400, 460800, 921600
590 *
591 * CP2102 and CP2103 support the following additional rates:
592 *
593 * 4000, 16000, 51200, 64000, 76800, 153600, 250000, 256000, 500000,
594 * 576000
595 *
596 * The device will map a requested rate to a supported one, but the result
597 * of requests for rates greater than 1053257 is undefined (see AN205).
598 *
599 * CP2104, CP2105 and CP2110 support most rates up to 2M, 921k and 1M baud,
600 * respectively, with an error less than 1%. The actual rates are determined
601 * by
602 *
603 * div = round(freq / (2 x prescale x request))
604 * actual = freq / (2 x prescale x div)
605 *
606 * For CP2104 and CP2105 freq is 48Mhz and prescale is 4 for request <= 365bps
607 * or 1 otherwise.
608 * For CP2110 freq is 24Mhz and prescale is 4 for request <= 300bps or 1
609 * otherwise.
610 */
611static void cp210x_change_speed(struct tty_struct *tty,
612 struct usb_serial_port *port, struct ktermios *old_termios)
613{
614 u32 baud;
615
616 baud = tty->termios->c_ospeed;
617
618 /* This maps the requested rate to a rate valid on cp2102 or cp2103,
619 * or to an arbitrary rate in [1M,2M].
620 *
621 * NOTE: B0 is not implemented.
622 */
623 baud = cp210x_quantise_baudrate(baud);
624
625 dbg("%s - setting baud rate to %u", __func__, baud);
626 if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud,
627 sizeof(baud))) {
628 dev_warn(&port->dev, "failed to set baud rate to %u\n", baud);
629 if (old_termios)
630 baud = old_termios->c_ospeed;
631 else
632 baud = 9600;
633 }
634
635 tty_encode_baud_rate(tty, baud, baud);
636}
637
582static void cp210x_set_termios(struct tty_struct *tty, 638static void cp210x_set_termios(struct tty_struct *tty,
583 struct usb_serial_port *port, struct ktermios *old_termios) 639 struct usb_serial_port *port, struct ktermios *old_termios)
584{ 640{
585 unsigned int cflag, old_cflag; 641 unsigned int cflag, old_cflag;
586 unsigned int baud = 0, bits; 642 unsigned int bits;
587 unsigned int modem_ctl[4]; 643 unsigned int modem_ctl[4];
588 644
589 dbg("%s - port %d", __func__, port->number); 645 dbg("%s - port %d", __func__, port->number);
@@ -593,20 +649,9 @@ static void cp210x_set_termios(struct tty_struct *tty,
593 649
594 cflag = tty->termios->c_cflag; 650 cflag = tty->termios->c_cflag;
595 old_cflag = old_termios->c_cflag; 651 old_cflag = old_termios->c_cflag;
596 baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); 652
597 653 if (tty->termios->c_ospeed != old_termios->c_ospeed)
598 /* If the baud rate is to be updated*/ 654 cp210x_change_speed(tty, port, old_termios);
599 if (baud != tty_termios_baud_rate(old_termios) && baud != 0) {
600 dbg("%s - Setting baud rate to %d baud", __func__,
601 baud);
602 if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV,
603 ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) {
604 dbg("Baud rate requested not supported by device");
605 baud = tty_termios_baud_rate(old_termios);
606 }
607 }
608 /* Report back the resulting baud rate */
609 tty_encode_baud_rate(tty, baud, baud);
610 655
611 /* If the number of data bits is to be updated */ 656 /* If the number of data bits is to be updated */
612 if ((cflag & CSIZE) != (old_cflag & CSIZE)) { 657 if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 01b6404df395..ad654f8208ef 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -797,6 +797,7 @@ static struct usb_device_id id_table_combined [] = {
797 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 797 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
798 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), 798 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID),
799 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 799 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
800 { USB_DEVICE(HORNBY_VID, HORNBY_ELITE_PID) },
800 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, 801 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
801 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), 802 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
802 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 803 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
@@ -805,6 +806,8 @@ static struct usb_device_id id_table_combined [] = {
805 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) }, 806 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
806 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), 807 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
807 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 808 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
809 { USB_DEVICE(FTDI_VID, TI_XDS100V2_PID),
810 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
808 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 811 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
809 { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) }, 812 { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) },
810 { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) }, 813 { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) },
@@ -841,6 +844,7 @@ static struct usb_device_id id_table_combined [] = {
841 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 844 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
842 { USB_DEVICE(ST_VID, ST_STMCLT1030_PID), 845 { USB_DEVICE(ST_VID, ST_STMCLT1030_PID),
843 .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk }, 846 .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk },
847 { USB_DEVICE(FTDI_VID, FTDI_RF_R106) },
844 { }, /* Optional parameter entry */ 848 { }, /* Optional parameter entry */
845 { } /* Terminating entry */ 849 { } /* Terminating entry */
846}; 850};
@@ -1333,8 +1337,7 @@ static int set_serial_info(struct tty_struct *tty,
1333 goto check_and_exit; 1337 goto check_and_exit;
1334 } 1338 }
1335 1339
1336 if ((new_serial.baud_base != priv->baud_base) && 1340 if (new_serial.baud_base != priv->baud_base) {
1337 (new_serial.baud_base < 9600)) {
1338 mutex_unlock(&priv->cfg_lock); 1341 mutex_unlock(&priv->cfg_lock);
1339 return -EINVAL; 1342 return -EINVAL;
1340 } 1343 }
@@ -1824,6 +1827,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1824 1827
1825static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) 1828static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1826{ 1829{
1830 struct ktermios dummy;
1827 struct usb_device *dev = port->serial->dev; 1831 struct usb_device *dev = port->serial->dev;
1828 struct ftdi_private *priv = usb_get_serial_port_data(port); 1832 struct ftdi_private *priv = usb_get_serial_port_data(port);
1829 int result; 1833 int result;
@@ -1842,8 +1846,10 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1842 This is same behaviour as serial.c/rs_open() - Kuba */ 1846 This is same behaviour as serial.c/rs_open() - Kuba */
1843 1847
1844 /* ftdi_set_termios will send usb control messages */ 1848 /* ftdi_set_termios will send usb control messages */
1845 if (tty) 1849 if (tty) {
1846 ftdi_set_termios(tty, port, tty->termios); 1850 memset(&dummy, 0, sizeof(dummy));
1851 ftdi_set_termios(tty, port, &dummy);
1852 }
1847 1853
1848 /* Start reading from the device */ 1854 /* Start reading from the device */
1849 result = usb_serial_generic_open(tty, port); 1855 result = usb_serial_generic_open(tty, port);
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index df1d7da933ec..f994503df2dd 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -39,6 +39,13 @@
39/* www.candapter.com Ewert Energy Systems CANdapter device */ 39/* www.candapter.com Ewert Energy Systems CANdapter device */
40#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */ 40#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
41 41
42/*
43 * Texas Instruments XDS100v2 JTAG / BeagleBone A3
44 * http://processors.wiki.ti.com/index.php/XDS100
45 * http://beagleboard.org/bone
46 */
47#define TI_XDS100V2_PID 0xa6d0
48
42#define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */ 49#define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */
43 50
44/* US Interface Navigator (http://www.usinterface.com/) */ 51/* US Interface Navigator (http://www.usinterface.com/) */
@@ -525,6 +532,12 @@
525#define ADI_GNICEPLUS_PID 0xF001 532#define ADI_GNICEPLUS_PID 0xF001
526 533
527/* 534/*
535 * Hornby Elite
536 */
537#define HORNBY_VID 0x04D8
538#define HORNBY_ELITE_PID 0x000A
539
540/*
528 * RATOC REX-USB60F 541 * RATOC REX-USB60F
529 */ 542 */
530#define RATOC_VENDOR_ID 0x0584 543#define RATOC_VENDOR_ID 0x0584
@@ -1168,3 +1181,9 @@
1168 */ 1181 */
1169/* TagTracer MIFARE*/ 1182/* TagTracer MIFARE*/
1170#define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0 1183#define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0
1184
1185/*
1186 * Rainforest Automation
1187 */
1188/* ZigBee controller */
1189#define FTDI_RF_R106 0x8A28
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 65bf06aa591a..5818bfc3261e 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2657,15 +2657,7 @@ cleanup:
2657 2657
2658static void edge_disconnect(struct usb_serial *serial) 2658static void edge_disconnect(struct usb_serial *serial)
2659{ 2659{
2660 int i;
2661 struct edgeport_port *edge_port;
2662
2663 dbg("%s", __func__); 2660 dbg("%s", __func__);
2664
2665 for (i = 0; i < serial->num_ports; ++i) {
2666 edge_port = usb_get_serial_port_data(serial->port[i]);
2667 edge_remove_sysfs_attrs(edge_port->port);
2668 }
2669} 2661}
2670 2662
2671static void edge_release(struct usb_serial *serial) 2663static void edge_release(struct usb_serial *serial)
@@ -2744,6 +2736,7 @@ static struct usb_serial_driver edgeport_1port_device = {
2744 .disconnect = edge_disconnect, 2736 .disconnect = edge_disconnect,
2745 .release = edge_release, 2737 .release = edge_release,
2746 .port_probe = edge_create_sysfs_attrs, 2738 .port_probe = edge_create_sysfs_attrs,
2739 .port_remove = edge_remove_sysfs_attrs,
2747 .ioctl = edge_ioctl, 2740 .ioctl = edge_ioctl,
2748 .set_termios = edge_set_termios, 2741 .set_termios = edge_set_termios,
2749 .tiocmget = edge_tiocmget, 2742 .tiocmget = edge_tiocmget,
@@ -2775,6 +2768,7 @@ static struct usb_serial_driver edgeport_2port_device = {
2775 .disconnect = edge_disconnect, 2768 .disconnect = edge_disconnect,
2776 .release = edge_release, 2769 .release = edge_release,
2777 .port_probe = edge_create_sysfs_attrs, 2770 .port_probe = edge_create_sysfs_attrs,
2771 .port_remove = edge_remove_sysfs_attrs,
2778 .ioctl = edge_ioctl, 2772 .ioctl = edge_ioctl,
2779 .set_termios = edge_set_termios, 2773 .set_termios = edge_set_termios,
2780 .tiocmget = edge_tiocmget, 2774 .tiocmget = edge_tiocmget,
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 5d3beeeb5fd9..a92a3efb507b 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -38,7 +38,7 @@
38#include <linux/ioctl.h> 38#include <linux/ioctl.h>
39#include "kobil_sct.h" 39#include "kobil_sct.h"
40 40
41static int debug; 41static bool debug;
42 42
43/* Version Information */ 43/* Version Information */
44#define DRIVER_VERSION "21/05/2004" 44#define DRIVER_VERSION "21/05/2004"
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 420d9857394a..ea126a4490cd 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -480,6 +480,10 @@ static void option_instat_callback(struct urb *urb);
480#define ZD_VENDOR_ID 0x0685 480#define ZD_VENDOR_ID 0x0685
481#define ZD_PRODUCT_7000 0x7000 481#define ZD_PRODUCT_7000 0x7000
482 482
483/* LG products */
484#define LG_VENDOR_ID 0x1004
485#define LG_PRODUCT_L02C 0x618f
486
483/* some devices interfaces need special handling due to a number of reasons */ 487/* some devices interfaces need special handling due to a number of reasons */
484enum option_blacklist_reason { 488enum option_blacklist_reason {
485 OPTION_BLACKLIST_NONE = 0, 489 OPTION_BLACKLIST_NONE = 0,
@@ -1183,6 +1187,7 @@ static const struct usb_device_id option_ids[] = {
1183 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) }, 1187 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) },
1184 { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, 1188 { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) },
1185 { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, 1189 { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) },
1190 { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */
1186 { } /* Terminating entry */ 1191 { } /* Terminating entry */
1187}; 1192};
1188MODULE_DEVICE_TABLE(usb, option_ids); 1193MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
index 30b73e68a904..a34819884c1a 100644
--- a/drivers/usb/serial/qcaux.c
+++ b/drivers/usb/serial/qcaux.c
@@ -36,6 +36,7 @@
36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712 36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712
37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714 37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714
38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715
39#define PANTECH_PRODUCT_UML190_VZW 0x3716
39#define PANTECH_PRODUCT_UML290_VZW 0x3718 40#define PANTECH_PRODUCT_UML290_VZW 0x3718
40 41
41/* CMOTECH devices */ 42/* CMOTECH devices */
@@ -67,7 +68,11 @@ static struct usb_device_id id_table[] = {
67 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, 68 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
68 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, 69 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
69 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, 70 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) },
70 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, 71 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xff, 0xff) },
72 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xfe, 0xff) },
73 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfd, 0xff) }, /* NMEA */
74 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfe, 0xff) }, /* WMC */
75 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, /* DIAG */
71 { }, 76 { },
72}; 77};
73MODULE_DEVICE_TABLE(usb, id_table); 78MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 1f62723ef1a8..d32f72061c09 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -789,7 +789,7 @@ static void rts51x_suspend_timer_fn(unsigned long data)
789 rts51x_set_stat(chip, RTS51X_STAT_SS); 789 rts51x_set_stat(chip, RTS51X_STAT_SS);
790 /* ignore mass storage interface's children */ 790 /* ignore mass storage interface's children */
791 pm_suspend_ignore_children(&us->pusb_intf->dev, true); 791 pm_suspend_ignore_children(&us->pusb_intf->dev, true);
792 usb_autopm_put_interface(us->pusb_intf); 792 usb_autopm_put_interface_async(us->pusb_intf);
793 US_DEBUGP("%s: RTS51X_STAT_SS 01," 793 US_DEBUGP("%s: RTS51X_STAT_SS 01,"
794 "intf->pm_usage_cnt:%d, power.usage:%d\n", 794 "intf->pm_usage_cnt:%d, power.usage:%d\n",
795 __func__, 795 __func__,
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 8efeae24764f..b4a71679c933 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -27,8 +27,6 @@
27#define USB_SKEL_VENDOR_ID 0xfff0 27#define USB_SKEL_VENDOR_ID 0xfff0
28#define USB_SKEL_PRODUCT_ID 0xfff0 28#define USB_SKEL_PRODUCT_ID 0xfff0
29 29
30static DEFINE_MUTEX(skel_mutex);
31
32/* table of devices that work with this driver */ 30/* table of devices that work with this driver */
33static const struct usb_device_id skel_table[] = { 31static const struct usb_device_id skel_table[] = {
34 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 32 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
@@ -101,25 +99,18 @@ static int skel_open(struct inode *inode, struct file *file)
101 goto exit; 99 goto exit;
102 } 100 }
103 101
104 mutex_lock(&skel_mutex);
105 dev = usb_get_intfdata(interface); 102 dev = usb_get_intfdata(interface);
106 if (!dev) { 103 if (!dev) {
107 mutex_unlock(&skel_mutex);
108 retval = -ENODEV; 104 retval = -ENODEV;
109 goto exit; 105 goto exit;
110 } 106 }
111 107
112 /* increment our usage count for the device */ 108 /* increment our usage count for the device */
113 kref_get(&dev->kref); 109 kref_get(&dev->kref);
114 mutex_unlock(&skel_mutex);
115 110
116 /* lock the device to allow correctly handling errors 111 /* lock the device to allow correctly handling errors
117 * in resumption */ 112 * in resumption */
118 mutex_lock(&dev->io_mutex); 113 mutex_lock(&dev->io_mutex);
119 if (!dev->interface) {
120 retval = -ENODEV;
121 goto out_err;
122 }
123 114
124 retval = usb_autopm_get_interface(interface); 115 retval = usb_autopm_get_interface(interface);
125 if (retval) 116 if (retval)
@@ -127,11 +118,7 @@ static int skel_open(struct inode *inode, struct file *file)
127 118
128 /* save our object in the file's private structure */ 119 /* save our object in the file's private structure */
129 file->private_data = dev; 120 file->private_data = dev;
130
131out_err:
132 mutex_unlock(&dev->io_mutex); 121 mutex_unlock(&dev->io_mutex);
133 if (retval)
134 kref_put(&dev->kref, skel_delete);
135 122
136exit: 123exit:
137 return retval; 124 return retval;
@@ -611,6 +598,7 @@ static void skel_disconnect(struct usb_interface *interface)
611 int minor = interface->minor; 598 int minor = interface->minor;
612 599
613 dev = usb_get_intfdata(interface); 600 dev = usb_get_intfdata(interface);
601 usb_set_intfdata(interface, NULL);
614 602
615 /* give back our minor */ 603 /* give back our minor */
616 usb_deregister_dev(interface, &skel_class); 604 usb_deregister_dev(interface, &skel_class);
@@ -622,12 +610,8 @@ static void skel_disconnect(struct usb_interface *interface)
622 610
623 usb_kill_anchored_urbs(&dev->submitted); 611 usb_kill_anchored_urbs(&dev->submitted);
624 612
625 mutex_lock(&skel_mutex);
626 usb_set_intfdata(interface, NULL);
627
628 /* decrement our usage count */ 613 /* decrement our usage count */
629 kref_put(&dev->kref, skel_delete); 614 kref_put(&dev->kref, skel_delete);
630 mutex_unlock(&skel_mutex);
631 615
632 dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); 616 dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor);
633} 617}
diff --git a/drivers/usb/wusbcore/Kconfig b/drivers/usb/wusbcore/Kconfig
index 0ead8826ec79..f29fdd7f6d75 100644
--- a/drivers/usb/wusbcore/Kconfig
+++ b/drivers/usb/wusbcore/Kconfig
@@ -6,7 +6,7 @@ config USB_WUSB
6 depends on EXPERIMENTAL 6 depends on EXPERIMENTAL
7 depends on USB 7 depends on USB
8 depends on PCI 8 depends on PCI
9 select UWB 9 depends on UWB
10 select CRYPTO 10 select CRYPTO
11 select CRYPTO_BLKCIPHER 11 select CRYPTO_BLKCIPHER
12 select CRYPTO_CBC 12 select CRYPTO_CBC
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 66bc74d9ce2a..378276c9d3cf 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -146,7 +146,7 @@ static int adp8860_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask
146 146
147 ret = adp8860_read(client, reg, &reg_val); 147 ret = adp8860_read(client, reg, &reg_val);
148 148
149 if (!ret && ((reg_val & bit_mask) == 0)) { 149 if (!ret && ((reg_val & bit_mask) != bit_mask)) {
150 reg_val |= bit_mask; 150 reg_val |= bit_mask;
151 ret = adp8860_write(client, reg, reg_val); 151 ret = adp8860_write(client, reg, reg_val);
152 } 152 }
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 6c68a6899e87..6735059376d6 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -160,7 +160,7 @@ static int adp8870_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask
160 160
161 ret = adp8870_read(client, reg, &reg_val); 161 ret = adp8870_read(client, reg, &reg_val);
162 162
163 if (!ret && ((reg_val & bit_mask) == 0)) { 163 if (!ret && ((reg_val & bit_mask) != bit_mask)) {
164 reg_val |= bit_mask; 164 reg_val |= bit_mask;
165 ret = adp8870_write(client, reg, reg_val); 165 ret = adp8870_write(client, reg, reg_val);
166 } 166 }
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index 4f5d1c4cb6ab..27d1d7a29c77 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -190,6 +190,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
190 190
191 priv->io_reg = regulator_get(&spi->dev, "vdd"); 191 priv->io_reg = regulator_get(&spi->dev, "vdd");
192 if (IS_ERR(priv->io_reg)) { 192 if (IS_ERR(priv->io_reg)) {
193 ret = PTR_ERR(priv->io_reg);
193 dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", 194 dev_err(&spi->dev, "%s: Unable to get the IO regulator\n",
194 __func__); 195 __func__);
195 goto err3; 196 goto err3;
@@ -197,6 +198,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
197 198
198 priv->core_reg = regulator_get(&spi->dev, "vcore"); 199 priv->core_reg = regulator_get(&spi->dev, "vcore");
199 if (IS_ERR(priv->core_reg)) { 200 if (IS_ERR(priv->core_reg)) {
201 ret = PTR_ERR(priv->core_reg);
200 dev_err(&spi->dev, "%s: Unable to get the core regulator\n", 202 dev_err(&spi->dev, "%s: Unable to get the core regulator\n",
201 __func__); 203 __func__);
202 goto err4; 204 goto err4;
diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c
index 43207cc6cc19..fe01add3700e 100644
--- a/drivers/video/macfb.c
+++ b/drivers/video/macfb.c
@@ -592,12 +592,12 @@ static int __init macfb_init(void)
592 if (!fb_info.screen_base) 592 if (!fb_info.screen_base)
593 return -ENODEV; 593 return -ENODEV;
594 594
595 printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n", 595 pr_info("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n",
596 macfb_fix.smem_start, fb_info.screen_base, 596 macfb_fix.smem_start, fb_info.screen_base,
597 macfb_fix.smem_len / 1024); 597 macfb_fix.smem_len / 1024);
598 printk("macfb: mode is %dx%dx%d, linelength=%d\n", 598 pr_info("macfb: mode is %dx%dx%d, linelength=%d\n",
599 macfb_defined.xres, macfb_defined.yres, 599 macfb_defined.xres, macfb_defined.yres,
600 macfb_defined.bits_per_pixel, macfb_fix.line_length); 600 macfb_defined.bits_per_pixel, macfb_fix.line_length);
601 601
602 /* Fill in the available video resolution */ 602 /* Fill in the available video resolution */
603 macfb_defined.xres_virtual = macfb_defined.xres; 603 macfb_defined.xres_virtual = macfb_defined.xres;
@@ -613,14 +613,10 @@ static int __init macfb_init(void)
613 613
614 switch (macfb_defined.bits_per_pixel) { 614 switch (macfb_defined.bits_per_pixel) {
615 case 1: 615 case 1:
616 /*
617 * XXX: I think this will catch any program that tries
618 * to do FBIO_PUTCMAP when the visual is monochrome.
619 */
620 macfb_defined.red.length = macfb_defined.bits_per_pixel; 616 macfb_defined.red.length = macfb_defined.bits_per_pixel;
621 macfb_defined.green.length = macfb_defined.bits_per_pixel; 617 macfb_defined.green.length = macfb_defined.bits_per_pixel;
622 macfb_defined.blue.length = macfb_defined.bits_per_pixel; 618 macfb_defined.blue.length = macfb_defined.bits_per_pixel;
623 video_cmap_len = 0; 619 video_cmap_len = 2;
624 macfb_fix.visual = FB_VISUAL_MONO01; 620 macfb_fix.visual = FB_VISUAL_MONO01;
625 break; 621 break;
626 case 2: 622 case 2:
@@ -660,11 +656,10 @@ static int __init macfb_init(void)
660 macfb_fix.visual = FB_VISUAL_TRUECOLOR; 656 macfb_fix.visual = FB_VISUAL_TRUECOLOR;
661 break; 657 break;
662 default: 658 default:
663 video_cmap_len = 0; 659 pr_err("macfb: unknown or unsupported bit depth: %d\n",
664 macfb_fix.visual = FB_VISUAL_MONO01;
665 printk("macfb: unknown or unsupported bit depth: %d\n",
666 macfb_defined.bits_per_pixel); 660 macfb_defined.bits_per_pixel);
667 break; 661 err = -EINVAL;
662 goto fail_unmap;
668 } 663 }
669 664
670 /* 665 /*
@@ -734,8 +729,8 @@ static int __init macfb_init(void)
734 case MAC_MODEL_Q950: 729 case MAC_MODEL_Q950:
735 strcpy(macfb_fix.id, "DAFB"); 730 strcpy(macfb_fix.id, "DAFB");
736 macfb_setpalette = dafb_setpalette; 731 macfb_setpalette = dafb_setpalette;
737 macfb_defined.activate = FB_ACTIVATE_NOW;
738 dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000); 732 dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000);
733 macfb_defined.activate = FB_ACTIVATE_NOW;
739 break; 734 break;
740 735
741 /* 736 /*
@@ -744,8 +739,8 @@ static int __init macfb_init(void)
744 case MAC_MODEL_LCII: 739 case MAC_MODEL_LCII:
745 strcpy(macfb_fix.id, "V8"); 740 strcpy(macfb_fix.id, "V8");
746 macfb_setpalette = v8_brazil_setpalette; 741 macfb_setpalette = v8_brazil_setpalette;
747 macfb_defined.activate = FB_ACTIVATE_NOW;
748 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 742 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
743 macfb_defined.activate = FB_ACTIVATE_NOW;
749 break; 744 break;
750 745
751 /* 746 /*
@@ -758,8 +753,8 @@ static int __init macfb_init(void)
758 case MAC_MODEL_P600: 753 case MAC_MODEL_P600:
759 strcpy(macfb_fix.id, "Brazil"); 754 strcpy(macfb_fix.id, "Brazil");
760 macfb_setpalette = v8_brazil_setpalette; 755 macfb_setpalette = v8_brazil_setpalette;
761 macfb_defined.activate = FB_ACTIVATE_NOW;
762 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 756 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
757 macfb_defined.activate = FB_ACTIVATE_NOW;
763 break; 758 break;
764 759
765 /* 760 /*
@@ -773,10 +768,10 @@ static int __init macfb_init(void)
773 case MAC_MODEL_P520: 768 case MAC_MODEL_P520:
774 case MAC_MODEL_P550: 769 case MAC_MODEL_P550:
775 case MAC_MODEL_P460: 770 case MAC_MODEL_P460:
776 macfb_setpalette = v8_brazil_setpalette;
777 macfb_defined.activate = FB_ACTIVATE_NOW;
778 strcpy(macfb_fix.id, "Sonora"); 771 strcpy(macfb_fix.id, "Sonora");
772 macfb_setpalette = v8_brazil_setpalette;
779 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 773 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
774 macfb_defined.activate = FB_ACTIVATE_NOW;
780 break; 775 break;
781 776
782 /* 777 /*
@@ -786,10 +781,10 @@ static int __init macfb_init(void)
786 */ 781 */
787 case MAC_MODEL_IICI: 782 case MAC_MODEL_IICI:
788 case MAC_MODEL_IISI: 783 case MAC_MODEL_IISI:
789 macfb_setpalette = rbv_setpalette;
790 macfb_defined.activate = FB_ACTIVATE_NOW;
791 strcpy(macfb_fix.id, "RBV"); 784 strcpy(macfb_fix.id, "RBV");
785 macfb_setpalette = rbv_setpalette;
792 rbv_cmap_regs = ioremap(DAC_BASE, 0x1000); 786 rbv_cmap_regs = ioremap(DAC_BASE, 0x1000);
787 macfb_defined.activate = FB_ACTIVATE_NOW;
793 break; 788 break;
794 789
795 /* 790 /*
@@ -797,10 +792,10 @@ static int __init macfb_init(void)
797 */ 792 */
798 case MAC_MODEL_Q840: 793 case MAC_MODEL_Q840:
799 case MAC_MODEL_C660: 794 case MAC_MODEL_C660:
800 macfb_setpalette = civic_setpalette;
801 macfb_defined.activate = FB_ACTIVATE_NOW;
802 strcpy(macfb_fix.id, "Civic"); 795 strcpy(macfb_fix.id, "Civic");
796 macfb_setpalette = civic_setpalette;
803 civic_cmap_regs = ioremap(CIVIC_BASE, 0x1000); 797 civic_cmap_regs = ioremap(CIVIC_BASE, 0x1000);
798 macfb_defined.activate = FB_ACTIVATE_NOW;
804 break; 799 break;
805 800
806 801
@@ -809,26 +804,26 @@ static int __init macfb_init(void)
809 * We think this may be like the LC II 804 * We think this may be like the LC II
810 */ 805 */
811 case MAC_MODEL_LC: 806 case MAC_MODEL_LC:
807 strcpy(macfb_fix.id, "LC");
812 if (vidtest) { 808 if (vidtest) {
813 macfb_setpalette = v8_brazil_setpalette; 809 macfb_setpalette = v8_brazil_setpalette;
814 macfb_defined.activate = FB_ACTIVATE_NOW;
815 v8_brazil_cmap_regs = 810 v8_brazil_cmap_regs =
816 ioremap(DAC_BASE, 0x1000); 811 ioremap(DAC_BASE, 0x1000);
812 macfb_defined.activate = FB_ACTIVATE_NOW;
817 } 813 }
818 strcpy(macfb_fix.id, "LC");
819 break; 814 break;
820 815
821 /* 816 /*
822 * We think this may be like the LC II 817 * We think this may be like the LC II
823 */ 818 */
824 case MAC_MODEL_CCL: 819 case MAC_MODEL_CCL:
820 strcpy(macfb_fix.id, "Color Classic");
825 if (vidtest) { 821 if (vidtest) {
826 macfb_setpalette = v8_brazil_setpalette; 822 macfb_setpalette = v8_brazil_setpalette;
827 macfb_defined.activate = FB_ACTIVATE_NOW;
828 v8_brazil_cmap_regs = 823 v8_brazil_cmap_regs =
829 ioremap(DAC_BASE, 0x1000); 824 ioremap(DAC_BASE, 0x1000);
825 macfb_defined.activate = FB_ACTIVATE_NOW;
830 } 826 }
831 strcpy(macfb_fix.id, "Color Classic");
832 break; 827 break;
833 828
834 /* 829 /*
@@ -893,10 +888,10 @@ static int __init macfb_init(void)
893 case MAC_MODEL_PB270C: 888 case MAC_MODEL_PB270C:
894 case MAC_MODEL_PB280: 889 case MAC_MODEL_PB280:
895 case MAC_MODEL_PB280C: 890 case MAC_MODEL_PB280C:
896 macfb_setpalette = csc_setpalette;
897 macfb_defined.activate = FB_ACTIVATE_NOW;
898 strcpy(macfb_fix.id, "CSC"); 891 strcpy(macfb_fix.id, "CSC");
892 macfb_setpalette = csc_setpalette;
899 csc_cmap_regs = ioremap(CSC_BASE, 0x1000); 893 csc_cmap_regs = ioremap(CSC_BASE, 0x1000);
894 macfb_defined.activate = FB_ACTIVATE_NOW;
900 break; 895 break;
901 896
902 default: 897 default:
@@ -918,8 +913,9 @@ static int __init macfb_init(void)
918 if (err) 913 if (err)
919 goto fail_dealloc; 914 goto fail_dealloc;
920 915
921 printk("fb%d: %s frame buffer device\n", 916 pr_info("fb%d: %s frame buffer device\n",
922 fb_info.node, fb_info.fix.id); 917 fb_info.node, fb_info.fix.id);
918
923 return 0; 919 return 0;
924 920
925fail_dealloc: 921fail_dealloc:
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 79e1b292c030..5aa43c3392a2 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -35,7 +35,7 @@
35#define virtio_rmb(vq) \ 35#define virtio_rmb(vq) \
36 do { if ((vq)->weak_barriers) smp_rmb(); else rmb(); } while(0) 36 do { if ((vq)->weak_barriers) smp_rmb(); else rmb(); } while(0)
37#define virtio_wmb(vq) \ 37#define virtio_wmb(vq) \
38 do { if ((vq)->weak_barriers) smp_rmb(); else rmb(); } while(0) 38 do { if ((vq)->weak_barriers) smp_wmb(); else wmb(); } while(0)
39#else 39#else
40/* We must force memory ordering even if guest is UP since host could be 40/* We must force memory ordering even if guest is UP since host could be
41 * running on another CPU, but SMP barriers are defined to barrier() in that 41 * running on another CPU, but SMP barriers are defined to barrier() in that
@@ -308,9 +308,9 @@ bool virtqueue_kick_prepare(struct virtqueue *_vq)
308 bool needs_kick; 308 bool needs_kick;
309 309
310 START_USE(vq); 310 START_USE(vq);
311 /* Descriptors and available array need to be set before we expose the 311 /* We need to expose available array entries before checking avail
312 * new available array entries. */ 312 * event. */
313 virtio_wmb(vq); 313 virtio_mb(vq);
314 314
315 old = vq->vring.avail->idx - vq->num_added; 315 old = vq->vring.avail->idx - vq->num_added;
316 new = vq->vring.avail->idx; 316 new = vq->vring.avail->idx;
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 1b0e3dd81c1a..63d7b58f1c7d 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -300,11 +300,7 @@ static int __devinit dw_wdt_drv_probe(struct platform_device *pdev)
300 if (!mem) 300 if (!mem)
301 return -EINVAL; 301 return -EINVAL;
302 302
303 if (!devm_request_mem_region(&pdev->dev, mem->start, resource_size(mem), 303 dw_wdt.regs = devm_request_and_ioremap(&pdev->dev, mem);
304 "dw_wdt"))
305 return -ENOMEM;
306
307 dw_wdt.regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
308 if (!dw_wdt.regs) 304 if (!dw_wdt.regs)
309 return -ENOMEM; 305 return -ENOMEM;
310 306
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 99796c5d913d..bdf401b240b5 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -36,6 +36,7 @@
36 * document number TBD : Patsburg (PBG) 36 * document number TBD : Patsburg (PBG)
37 * document number TBD : DH89xxCC 37 * document number TBD : DH89xxCC
38 * document number TBD : Panther Point 38 * document number TBD : Panther Point
39 * document number TBD : Lynx Point
39 */ 40 */
40 41
41/* 42/*
@@ -126,6 +127,7 @@ enum iTCO_chipsets {
126 TCO_PBG, /* Patsburg */ 127 TCO_PBG, /* Patsburg */
127 TCO_DH89XXCC, /* DH89xxCC */ 128 TCO_DH89XXCC, /* DH89xxCC */
128 TCO_PPT, /* Panther Point */ 129 TCO_PPT, /* Panther Point */
130 TCO_LPT, /* Lynx Point */
129}; 131};
130 132
131static struct { 133static struct {
@@ -189,6 +191,7 @@ static struct {
189 {"Patsburg", 2}, 191 {"Patsburg", 2},
190 {"DH89xxCC", 2}, 192 {"DH89xxCC", 2},
191 {"Panther Point", 2}, 193 {"Panther Point", 2},
194 {"Lynx Point", 2},
192 {NULL, 0} 195 {NULL, 0}
193}; 196};
194 197
@@ -331,6 +334,38 @@ static DEFINE_PCI_DEVICE_TABLE(iTCO_wdt_pci_tbl) = {
331 { PCI_VDEVICE(INTEL, 0x1e5d), TCO_PPT}, 334 { PCI_VDEVICE(INTEL, 0x1e5d), TCO_PPT},
332 { PCI_VDEVICE(INTEL, 0x1e5e), TCO_PPT}, 335 { PCI_VDEVICE(INTEL, 0x1e5e), TCO_PPT},
333 { PCI_VDEVICE(INTEL, 0x1e5f), TCO_PPT}, 336 { PCI_VDEVICE(INTEL, 0x1e5f), TCO_PPT},
337 { PCI_VDEVICE(INTEL, 0x8c40), TCO_LPT},
338 { PCI_VDEVICE(INTEL, 0x8c41), TCO_LPT},
339 { PCI_VDEVICE(INTEL, 0x8c42), TCO_LPT},
340 { PCI_VDEVICE(INTEL, 0x8c43), TCO_LPT},
341 { PCI_VDEVICE(INTEL, 0x8c44), TCO_LPT},
342 { PCI_VDEVICE(INTEL, 0x8c45), TCO_LPT},
343 { PCI_VDEVICE(INTEL, 0x8c46), TCO_LPT},
344 { PCI_VDEVICE(INTEL, 0x8c47), TCO_LPT},
345 { PCI_VDEVICE(INTEL, 0x8c48), TCO_LPT},
346 { PCI_VDEVICE(INTEL, 0x8c49), TCO_LPT},
347 { PCI_VDEVICE(INTEL, 0x8c4a), TCO_LPT},
348 { PCI_VDEVICE(INTEL, 0x8c4b), TCO_LPT},
349 { PCI_VDEVICE(INTEL, 0x8c4c), TCO_LPT},
350 { PCI_VDEVICE(INTEL, 0x8c4d), TCO_LPT},
351 { PCI_VDEVICE(INTEL, 0x8c4e), TCO_LPT},
352 { PCI_VDEVICE(INTEL, 0x8c4f), TCO_LPT},
353 { PCI_VDEVICE(INTEL, 0x8c50), TCO_LPT},
354 { PCI_VDEVICE(INTEL, 0x8c51), TCO_LPT},
355 { PCI_VDEVICE(INTEL, 0x8c52), TCO_LPT},
356 { PCI_VDEVICE(INTEL, 0x8c53), TCO_LPT},
357 { PCI_VDEVICE(INTEL, 0x8c54), TCO_LPT},
358 { PCI_VDEVICE(INTEL, 0x8c55), TCO_LPT},
359 { PCI_VDEVICE(INTEL, 0x8c56), TCO_LPT},
360 { PCI_VDEVICE(INTEL, 0x8c57), TCO_LPT},
361 { PCI_VDEVICE(INTEL, 0x8c58), TCO_LPT},
362 { PCI_VDEVICE(INTEL, 0x8c59), TCO_LPT},
363 { PCI_VDEVICE(INTEL, 0x8c5a), TCO_LPT},
364 { PCI_VDEVICE(INTEL, 0x8c5b), TCO_LPT},
365 { PCI_VDEVICE(INTEL, 0x8c5c), TCO_LPT},
366 { PCI_VDEVICE(INTEL, 0x8c5d), TCO_LPT},
367 { PCI_VDEVICE(INTEL, 0x8c5e), TCO_LPT},
368 { PCI_VDEVICE(INTEL, 0x8c5f), TCO_LPT},
334 { 0, }, /* End of list */ 369 { 0, }, /* End of list */
335}; 370};
336MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl); 371MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index b8ef2c6dca7c..c44c3334003a 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -247,7 +247,6 @@ static struct miscdevice imx2_wdt_miscdev = {
247static int __init imx2_wdt_probe(struct platform_device *pdev) 247static int __init imx2_wdt_probe(struct platform_device *pdev)
248{ 248{
249 int ret; 249 int ret;
250 int res_size;
251 struct resource *res; 250 struct resource *res;
252 251
253 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 252 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -256,15 +255,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
256 return -ENODEV; 255 return -ENODEV;
257 } 256 }
258 257
259 res_size = resource_size(res); 258 imx2_wdt.base = devm_request_and_ioremap(&pdev->dev, res);
260 if (!devm_request_mem_region(&pdev->dev, res->start, res_size,
261 res->name)) {
262 dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n",
263 res_size, res->start);
264 return -ENOMEM;
265 }
266
267 imx2_wdt.base = devm_ioremap_nocache(&pdev->dev, res->start, res_size);
268 if (!imx2_wdt.base) { 259 if (!imx2_wdt.base) {
269 dev_err(&pdev->dev, "ioremap failed\n"); 260 dev_err(&pdev->dev, "ioremap failed\n");
270 return -ENOMEM; 261 return -ENOMEM;
diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c
index 50359bad9177..529085b8b8fb 100644
--- a/drivers/watchdog/nuc900_wdt.c
+++ b/drivers/watchdog/nuc900_wdt.c
@@ -72,7 +72,7 @@ struct nuc900_wdt {
72}; 72};
73 73
74static unsigned long nuc900wdt_busy; 74static unsigned long nuc900wdt_busy;
75struct nuc900_wdt *nuc900_wdt; 75static struct nuc900_wdt *nuc900_wdt;
76 76
77static inline void nuc900_wdt_keepalive(void) 77static inline void nuc900_wdt_keepalive(void)
78{ 78{
@@ -287,7 +287,8 @@ static int __devinit nuc900wdt_probe(struct platform_device *pdev)
287 287
288 setup_timer(&nuc900_wdt->timer, nuc900_wdt_timer_ping, 0); 288 setup_timer(&nuc900_wdt->timer, nuc900_wdt_timer_ping, 0);
289 289
290 if (misc_register(&nuc900wdt_miscdev)) { 290 ret = misc_register(&nuc900wdt_miscdev);
291 if (ret) {
291 dev_err(&pdev->dev, "err register miscdev on minor=%d (%d)\n", 292 dev_err(&pdev->dev, "err register miscdev on minor=%d (%d)\n",
292 WATCHDOG_MINOR, ret); 293 WATCHDOG_MINOR, ret);
293 goto err_clk; 294 goto err_clk;
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 4b33e3fd726b..d19ff5145e82 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -339,6 +339,7 @@ static int __devinit omap_wdt_probe(struct platform_device *pdev)
339 return 0; 339 return 0;
340 340
341err_misc: 341err_misc:
342 pm_runtime_disable(wdev->dev);
342 platform_set_drvdata(pdev, NULL); 343 platform_set_drvdata(pdev, NULL);
343 iounmap(wdev->base); 344 iounmap(wdev->base);
344 345
@@ -371,6 +372,7 @@ static int __devexit omap_wdt_remove(struct platform_device *pdev)
371 struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); 372 struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
372 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 373 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
373 374
375 pm_runtime_disable(wdev->dev);
374 if (!res) 376 if (!res)
375 return -ENOENT; 377 return -ENOENT;
376 378
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index bd143c9dd3e6..8e210aafdfd0 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -226,7 +226,7 @@ static long pnx4008_wdt_ioctl(struct file *file, unsigned int cmd,
226static int pnx4008_wdt_release(struct inode *inode, struct file *file) 226static int pnx4008_wdt_release(struct inode *inode, struct file *file)
227{ 227{
228 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status)) 228 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status))
229 printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n"); 229 printk(KERN_WARNING "WATCHDOG: Device closed unexpectedly\n");
230 230
231 wdt_disable(); 231 wdt_disable();
232 clk_disable(wdt_clk); 232 clk_disable(wdt_clk);
diff --git a/drivers/watchdog/stmp3xxx_wdt.c b/drivers/watchdog/stmp3xxx_wdt.c
index 4c2a4e8698f9..e37d81178b9e 100644
--- a/drivers/watchdog/stmp3xxx_wdt.c
+++ b/drivers/watchdog/stmp3xxx_wdt.c
@@ -174,7 +174,7 @@ static int stmp3xxx_wdt_release(struct inode *inode, struct file *file)
174 if (!nowayout) { 174 if (!nowayout) {
175 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status)) { 175 if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status)) {
176 wdt_ping(); 176 wdt_ping();
177 pr_debug("%s: Device closed unexpectdly\n", __func__); 177 pr_debug("%s: Device closed unexpectedly\n", __func__);
178 ret = -EINVAL; 178 ret = -EINVAL;
179 } else { 179 } else {
180 wdt_disable(); 180 wdt_disable();
diff --git a/drivers/watchdog/via_wdt.c b/drivers/watchdog/via_wdt.c
index 026b4bbfa0aa..8f07dd4bd94a 100644
--- a/drivers/watchdog/via_wdt.c
+++ b/drivers/watchdog/via_wdt.c
@@ -124,8 +124,6 @@ static int wdt_stop(struct watchdog_device *wdd)
124static int wdt_set_timeout(struct watchdog_device *wdd, 124static int wdt_set_timeout(struct watchdog_device *wdd,
125 unsigned int new_timeout) 125 unsigned int new_timeout)
126{ 126{
127 if (new_timeout < 1 || new_timeout > WDT_TIMEOUT_MAX)
128 return -EINVAL;
129 writel(new_timeout, wdt_mem + VIA_WDT_COUNT); 127 writel(new_timeout, wdt_mem + VIA_WDT_COUNT);
130 timeout = new_timeout; 128 timeout = new_timeout;
131 return 0; 129 return 0;
@@ -150,6 +148,8 @@ static const struct watchdog_ops wdt_ops = {
150static struct watchdog_device wdt_dev = { 148static struct watchdog_device wdt_dev = {
151 .info = &wdt_info, 149 .info = &wdt_info,
152 .ops = &wdt_ops, 150 .ops = &wdt_ops,
151 .min_timeout = 1,
152 .max_timeout = WDT_TIMEOUT_MAX,
153}; 153};
154 154
155static int __devinit wdt_probe(struct pci_dev *pdev, 155static int __devinit wdt_probe(struct pci_dev *pdev,
@@ -233,7 +233,7 @@ static void __devexit wdt_remove(struct pci_dev *pdev)
233 pci_disable_device(pdev); 233 pci_disable_device(pdev);
234} 234}
235 235
236DEFINE_PCI_DEVICE_TABLE(wdt_pci_table) = { 236static DEFINE_PCI_DEVICE_TABLE(wdt_pci_table) = {
237 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700) }, 237 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700) },
238 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800) }, 238 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800) },
239 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) }, 239 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
diff --git a/drivers/watchdog/wafer5823wdt.c b/drivers/watchdog/wafer5823wdt.c
index 42e940c23891..c3c3188c34d7 100644
--- a/drivers/watchdog/wafer5823wdt.c
+++ b/drivers/watchdog/wafer5823wdt.c
@@ -152,12 +152,12 @@ static long wafwdt_ioctl(struct file *file, unsigned int cmd,
152 return -EFAULT; 152 return -EFAULT;
153 153
154 if (options & WDIOS_DISABLECARD) { 154 if (options & WDIOS_DISABLECARD) {
155 wafwdt_start(); 155 wafwdt_stop();
156 retval = 0; 156 retval = 0;
157 } 157 }
158 158
159 if (options & WDIOS_ENABLECARD) { 159 if (options & WDIOS_ENABLECARD) {
160 wafwdt_stop(); 160 wafwdt_start();
161 retval = 0; 161 retval = 0;
162 } 162 }
163 163
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
index 909c78650d3e..5d7113c7e501 100644
--- a/drivers/watchdog/wm8350_wdt.c
+++ b/drivers/watchdog/wm8350_wdt.c
@@ -212,10 +212,10 @@ static long wm8350_wdt_ioctl(struct file *file, unsigned int cmd,
212 212
213 /* Setting both simultaneously means at least one must fail */ 213 /* Setting both simultaneously means at least one must fail */
214 if (options == WDIOS_DISABLECARD) 214 if (options == WDIOS_DISABLECARD)
215 ret = wm8350_wdt_start(wm8350); 215 ret = wm8350_wdt_stop(wm8350);
216 216
217 if (options == WDIOS_ENABLECARD) 217 if (options == WDIOS_ENABLECARD)
218 ret = wm8350_wdt_stop(wm8350); 218 ret = wm8350_wdt_start(wm8350);
219 break; 219 break;
220 } 220 }
221 221
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 1cd94daa71db..b4d4eac761db 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -948,9 +948,12 @@ static void gnttab_request_version(void)
948 int rc; 948 int rc;
949 struct gnttab_set_version gsv; 949 struct gnttab_set_version gsv;
950 950
951 gsv.version = 2; 951 if (xen_hvm_domain())
952 gsv.version = 1;
953 else
954 gsv.version = 2;
952 rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1); 955 rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1);
953 if (rc == 0) { 956 if (rc == 0 && gsv.version == 2) {
954 grant_table_version = 2; 957 grant_table_version = 2;
955 gnttab_interface = &gnttab_v2_ops; 958 gnttab_interface = &gnttab_v2_ops;
956 } else if (grant_table_version == 2) { 959 } else if (grant_table_version == 2) {