aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-18 14:15:05 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-18 14:15:05 -0500
commit4092762aebfe55c1f8e31440b80a053c2dbe519b (patch)
tree8fb9fd14131194174c12daf5d8195afd3b62bc3e /drivers
parent745b1626dd71ce9661a05ea4db57859ed5c773d2 (diff)
parent1de9e8e70f5acc441550ca75433563d91b269bbe (diff)
Merge branch 'tracing/ftrace'; commit 'v2.6.29-rc2' into tracing/core
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/ec.c73
-rw-r--r--drivers/acpi/sleep.c (renamed from drivers/acpi/main.c)0
-rw-r--r--drivers/acpi/thermal.c16
-rw-r--r--drivers/ata/Kconfig9
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/libata-core.c73
-rw-r--r--drivers/ata/libata-scsi.c17
-rw-r--r--drivers/ata/libata-sff.c9
-rw-r--r--drivers/ata/pata_ali.c28
-rw-r--r--drivers/ata/pata_atiixp.c32
-rw-r--r--drivers/ata/pata_it821x.c17
-rw-r--r--drivers/ata/pata_octeon_cf.c965
-rw-r--r--drivers/ata/sata_fsl.c2
-rw-r--r--drivers/ata/sata_via.c2
-rw-r--r--drivers/block/amiflop.c40
-rw-r--r--drivers/block/nbd.c4
-rw-r--r--drivers/block/ps3disk.c18
-rw-r--r--drivers/block/xsysace.c1
-rw-r--r--drivers/char/amiserial.c36
-rw-r--r--drivers/char/bsr.c2
-rw-r--r--drivers/char/hvc_console.c12
-rw-r--r--drivers/char/hvc_irq.c2
-rw-r--r--drivers/char/ps3flash.c18
-rw-r--r--drivers/char/pty.c4
-rw-r--r--drivers/char/ser_a2232.c12
-rw-r--r--drivers/char/synclink_gt.c16
-rw-r--r--drivers/char/sysrq.c6
-rw-r--r--drivers/char/tty_ioctl.c2
-rw-r--r--drivers/char/vme_scc.c166
-rw-r--r--drivers/dio/dio-sysfs.c19
-rw-r--r--drivers/dio/dio.c18
-rw-r--r--drivers/gpio/max7301.c6
-rw-r--r--drivers/gpio/max732x.c6
-rw-r--r--drivers/gpio/mcp23s08.c6
-rw-r--r--drivers/gpio/pca953x.c6
-rw-r--r--drivers/gpio/pcf857x.c12
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c175
-rw-r--r--drivers/gpu/drm/drm_irq.c18
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c10
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h23
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c189
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c43
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c7
-rw-r--r--drivers/hwmon/Kconfig24
-rw-r--r--drivers/hwmon/Makefile2
-rw-r--r--drivers/hwmon/abituguru3.c24
-rw-r--r--drivers/hwmon/adt7475.c1221
-rw-r--r--drivers/hwmon/applesmc.c5
-rw-r--r--drivers/hwmon/hp_accel.c75
-rw-r--r--drivers/hwmon/k8temp.c55
-rw-r--r--drivers/i2c/chips/Kconfig11
-rw-r--r--drivers/i2c/chips/Makefile1
-rw-r--r--drivers/i2c/chips/mcu_mpc8349emitx.c209
-rw-r--r--drivers/ide/Kconfig5
-rw-r--r--drivers/ide/ide-disk.c2
-rw-r--r--drivers/ide/ide-iops.c2
-rw-r--r--drivers/ide/ide-pm.c12
-rw-r--r--drivers/ide/ide-probe.c2
-rw-r--r--drivers/ide/it821x.c15
-rw-r--r--drivers/ide/sl82c105.c4
-rw-r--r--drivers/ide/tx4938ide.c1
-rw-r--r--drivers/ide/via82cxxx.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c2
-rw-r--r--drivers/infiniband/hw/mlx4/main.c13
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c12
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c38
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c3
-rw-r--r--drivers/infiniband/ulp/iser/Kconfig2
-rw-r--r--drivers/input/misc/Kconfig7
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/pcf50633-input.c132
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c3
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c2
-rw-r--r--drivers/isdn/i4l/isdn_net.c9
-rw-r--r--drivers/isdn/mISDN/dsp_cmx.c5
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c4
-rw-r--r--drivers/leds/Kconfig7
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-hp-disk.c137
-rw-r--r--drivers/message/fusion/lsi/mpi.h7
-rw-r--r--drivers/message/fusion/lsi/mpi_cnfg.h47
-rw-r--r--drivers/message/fusion/lsi/mpi_fc.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_history.txt86
-rw-r--r--drivers/message/fusion/lsi/mpi_init.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_ioc.h22
-rw-r--r--drivers/message/fusion/lsi/mpi_lan.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_log_fc.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_log_sas.h37
-rw-r--r--drivers/message/fusion/lsi/mpi_raid.h11
-rw-r--r--drivers/message/fusion/lsi/mpi_sas.h18
-rw-r--r--drivers/message/fusion/lsi/mpi_targ.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_tool.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_type.h4
-rw-r--r--drivers/message/fusion/mptbase.c87
-rw-r--r--drivers/message/fusion/mptbase.h3
-rw-r--r--drivers/message/fusion/mptscsih.c3
-rw-r--r--drivers/mfd/Kconfig23
-rw-r--r--drivers/mfd/Makefile4
-rw-r--r--drivers/mfd/dm355evm_msp.c10
-rw-r--r--drivers/mfd/pcf50633-adc.c277
-rw-r--r--drivers/mfd/pcf50633-core.c710
-rw-r--r--drivers/mfd/pcf50633-gpio.c118
-rw-r--r--drivers/mfd/sm501.c30
-rw-r--r--drivers/mfd/twl4030-core.c11
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c2
-rw-r--r--drivers/net/3c503.c1
-rw-r--r--drivers/net/3c59x.c2
-rw-r--r--drivers/net/8139cp.c2
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--drivers/net/8390.c1
-rw-r--r--drivers/net/8390p.c1
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/acenic.c1
-rw-r--r--drivers/net/arm/etherh.c1
-rw-r--r--drivers/net/arm/ks8695net.c1
-rw-r--r--drivers/net/ax88796.c27
-rw-r--r--drivers/net/b44.c17
-rw-r--r--drivers/net/b44.h2
-rw-r--r--drivers/net/bnx2x.h19
-rw-r--r--drivers/net/bnx2x_main.c178
-rw-r--r--drivers/net/cxgb3/adapter.h7
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c22
-rw-r--r--drivers/net/cxgb3/sge.c2
-rw-r--r--drivers/net/e1000e/ich8lan.c19
-rw-r--r--drivers/net/e2100.c1
-rw-r--r--drivers/net/ehea/ehea_main.c8
-rw-r--r--drivers/net/ehea/ehea_qmr.c18
-rw-r--r--drivers/net/enic/enic_main.c1
-rw-r--r--drivers/net/forcedeth.c22
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c1
-rw-r--r--drivers/net/gianfar.c23
-rw-r--r--drivers/net/hamachi.c1
-rw-r--r--drivers/net/hamradio/6pack.c3
-rw-r--r--drivers/net/hp-plus.c1
-rw-r--r--drivers/net/hydra.c1
-rw-r--r--drivers/net/ibm_newemac/mal.c4
-rw-r--r--drivers/net/ibm_newemac/mal.h2
-rw-r--r--drivers/net/ibmveth.c16
-rw-r--r--drivers/net/irda/au1k_ir.c2
-rw-r--r--drivers/net/irda/donauboe.c8
-rw-r--r--drivers/net/irda/irda-usb.c2
-rw-r--r--drivers/net/iseries_veth.c2
-rw-r--r--drivers/net/korina.c158
-rw-r--r--drivers/net/mac8390.c1
-rw-r--r--drivers/net/mlx4/en_netdev.c1
-rw-r--r--drivers/net/mlx4/main.c4
-rw-r--r--drivers/net/ne-h8300.c1
-rw-r--r--drivers/net/ne2k-pci.c1
-rw-r--r--drivers/net/netxen/netxen_nic.h146
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c50
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c31
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c97
-rw-r--r--drivers/net/netxen/netxen_nic_init.c105
-rw-r--r--drivers/net/netxen/netxen_nic_main.c210
-rw-r--r--drivers/net/ns83820.c1
-rw-r--r--drivers/net/pasemi_mac.c6
-rw-r--r--drivers/net/phy/phy_device.c9
-rw-r--r--drivers/net/ppp_generic.c43
-rw-r--r--drivers/net/qlge/qlge.h61
-rw-r--r--drivers/net/qlge/qlge_dbg.c62
-rw-r--r--drivers/net/qlge/qlge_main.c80
-rw-r--r--drivers/net/r6040.c43
-rw-r--r--drivers/net/sc92031.c1
-rw-r--r--drivers/net/sfc/tenxpress.c5
-rw-r--r--drivers/net/sis900.c9
-rw-r--r--drivers/net/smc-mca.c1
-rw-r--r--drivers/net/smc-ultra.c1
-rw-r--r--drivers/net/smsc911x.c4
-rw-r--r--drivers/net/smsc9420.c1
-rw-r--r--drivers/net/ucc_geth.c128
-rw-r--r--drivers/net/ucc_geth.h114
-rw-r--r--drivers/net/usb/hso.c12
-rw-r--r--drivers/net/via-rhine.c1
-rw-r--r--drivers/net/via-velocity.c1
-rw-r--r--drivers/net/wan/ixp4xx_hss.c6
-rw-r--r--drivers/net/wd.c1
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/ath5k/base.c8
-rw-r--r--drivers/net/wireless/ath5k/pcu.c4
-rw-r--r--drivers/net/wireless/ath5k/reg.h2
-rw-r--r--drivers/net/wireless/ath9k/Kconfig1
-rw-r--r--drivers/net/wireless/ath9k/main.c4
-rw-r--r--drivers/net/wireless/ath9k/xmit.c48
-rw-r--r--drivers/net/wireless/b43/main.c2
-rw-r--r--drivers/net/wireless/b43legacy/main.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c1
-rw-r--r--drivers/net/wireless/libertas/main.c7
-rw-r--r--drivers/net/wireless/libertas_tf/main.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco.c28
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c1
-rw-r--r--drivers/net/wireless/p54/p54common.c34
-rw-r--r--drivers/net/wireless/p54/p54usb.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c23
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00leds.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180_dev.c1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c5
-rw-r--r--drivers/net/yellowfin.c1
-rw-r--r--drivers/net/zorro8390.c1
-rw-r--r--drivers/of/of_i2c.c19
-rw-r--r--drivers/parisc/superio.c1
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c2
-rw-r--r--drivers/pci/intel-iommu.c3
-rw-r--r--drivers/pci/pci.c8
-rw-r--r--drivers/pci/syscall.c12
-rw-r--r--drivers/pcmcia/electra_cf.c2
-rw-r--r--drivers/platform/x86/Kconfig23
-rw-r--r--drivers/platform/x86/Makefile1
-rw-r--r--drivers/platform/x86/dell-laptop.c (renamed from drivers/misc/dell-laptop.c)2
-rw-r--r--drivers/platform/x86/eeepc-laptop.c4
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c910
-rw-r--r--drivers/power/Kconfig6
-rw-r--r--drivers/power/Makefile1
-rw-r--r--drivers/power/pcf50633-charger.c358
-rw-r--r--drivers/ps3/ps3-lpm.c16
-rw-r--r--drivers/ps3/ps3-vuart.c32
-rw-r--r--drivers/ps3/ps3stor_lib.c14
-rw-r--r--drivers/regulator/Kconfig7
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/pcf50633-regulator.c329
-rw-r--r--drivers/rtc/Kconfig7
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-pcf50633.c344
-rw-r--r--drivers/rtc/rtc-pxa.c2
-rw-r--r--drivers/rtc/rtc-twl4030.c49
-rw-r--r--drivers/s390/net/qeth_l2_main.c2
-rw-r--r--drivers/s390/net/qeth_l3_main.c24
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c14
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.h6
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c12
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/libiscsi_tcp.c3
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c2
-rw-r--r--drivers/scsi/ps3rom.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c58
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c7
-rw-r--r--drivers/scsi/scsi.c5
-rw-r--r--drivers/scsi/scsi_devinfo.c1
-rw-r--r--drivers/serial/8250.c2
-rw-r--r--drivers/serial/8250_pci.c8
-rw-r--r--drivers/serial/8250_pnp.c2
-rw-r--r--drivers/serial/atmel_serial.c2
-rw-r--r--drivers/serial/jsm/jsm_neo.c3
-rw-r--r--drivers/serial/of_serial.c1
-rw-r--r--drivers/serial/pnx8xxx_uart.c23
-rw-r--r--drivers/spi/atmel_spi.c3
-rw-r--r--drivers/spi/xilinx_spi.c137
-rw-r--r--drivers/usb/core/hub.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c73
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h8
-rw-r--r--drivers/usb/serial/usb-serial.c3
-rw-r--r--drivers/video/Makefile4
-rw-r--r--drivers/video/amifb.c6
-rw-r--r--drivers/video/atafb.c112
-rw-r--r--drivers/video/bf54x-lq043fb.c15
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c15
-rw-r--r--drivers/video/c2p.c232
-rw-r--r--drivers/video/c2p.h11
-rw-r--r--drivers/video/c2p_core.h153
-rw-r--r--drivers/video/c2p_iplan2.c153
-rw-r--r--drivers/video/c2p_planar.c156
-rw-r--r--drivers/video/console/fbcon.c38
-rw-r--r--drivers/video/ps3fb.c4
-rw-r--r--drivers/watchdog/Kconfig14
-rw-r--r--drivers/watchdog/Makefile2
-rw-r--r--drivers/watchdog/gef_wdt.c330
-rw-r--r--drivers/watchdog/pika_wdt.c301
-rw-r--r--drivers/watchdog/wm8350_wdt.c6
-rw-r--r--drivers/zorro/.gitignore2
-rw-r--r--drivers/zorro/zorro-sysfs.c20
-rw-r--r--drivers/zorro/zorro.c23
-rw-r--r--drivers/zorro/zorro.h2
284 files changed, 9368 insertions, 2534 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d80f4cc2e0da..65d90c720b5a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -19,7 +19,7 @@ obj-y += osl.o utils.o reboot.o\
19 19
20# sleep related files 20# sleep related files
21obj-y += wakeup.o 21obj-y += wakeup.o
22obj-y += main.o 22obj-y += sleep.o
23obj-$(CONFIG_ACPI_SLEEP) += proc.o 23obj-$(CONFIG_ACPI_SLEEP) += proc.o
24 24
25 25
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 8dfcbb8aff73..a2b82c90a683 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -120,31 +120,6 @@ static struct acpi_ec {
120 spinlock_t curr_lock; 120 spinlock_t curr_lock;
121} *boot_ec, *first_ec; 121} *boot_ec, *first_ec;
122 122
123/*
124 * Some Asus system have exchanged ECDT data/command IO addresses.
125 */
126static int print_ecdt_error(const struct dmi_system_id *id)
127{
128 printk(KERN_NOTICE PREFIX "%s detected - "
129 "ECDT has exchanged control/data I/O address\n",
130 id->ident);
131 return 0;
132}
133
134static struct dmi_system_id __cpuinitdata ec_dmi_table[] = {
135 {
136 print_ecdt_error, "Asus L4R", {
137 DMI_MATCH(DMI_BIOS_VERSION, "1008.006"),
138 DMI_MATCH(DMI_PRODUCT_NAME, "L4R"),
139 DMI_MATCH(DMI_BOARD_NAME, "L4R") }, NULL},
140 {
141 print_ecdt_error, "Asus M6R", {
142 DMI_MATCH(DMI_BIOS_VERSION, "0207"),
143 DMI_MATCH(DMI_PRODUCT_NAME, "M6R"),
144 DMI_MATCH(DMI_BOARD_NAME, "M6R") }, NULL},
145 {},
146};
147
148/* -------------------------------------------------------------------------- 123/* --------------------------------------------------------------------------
149 Transaction Management 124 Transaction Management
150 -------------------------------------------------------------------------- */ 125 -------------------------------------------------------------------------- */
@@ -983,8 +958,8 @@ static const struct acpi_device_id ec_device_ids[] = {
983int __init acpi_ec_ecdt_probe(void) 958int __init acpi_ec_ecdt_probe(void)
984{ 959{
985 acpi_status status; 960 acpi_status status;
961 struct acpi_ec *saved_ec = NULL;
986 struct acpi_table_ecdt *ecdt_ptr; 962 struct acpi_table_ecdt *ecdt_ptr;
987 acpi_handle dummy;
988 963
989 boot_ec = make_acpi_ec(); 964 boot_ec = make_acpi_ec();
990 if (!boot_ec) 965 if (!boot_ec)
@@ -998,21 +973,16 @@ int __init acpi_ec_ecdt_probe(void)
998 pr_info(PREFIX "EC description table is found, configuring boot EC\n"); 973 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
999 boot_ec->command_addr = ecdt_ptr->control.address; 974 boot_ec->command_addr = ecdt_ptr->control.address;
1000 boot_ec->data_addr = ecdt_ptr->data.address; 975 boot_ec->data_addr = ecdt_ptr->data.address;
1001 if (dmi_check_system(ec_dmi_table)) {
1002 /*
1003 * If the board falls into ec_dmi_table, it means
1004 * that ECDT table gives the incorrect command/status
1005 * & data I/O address. Just fix it.
1006 */
1007 boot_ec->data_addr = ecdt_ptr->control.address;
1008 boot_ec->command_addr = ecdt_ptr->data.address;
1009 }
1010 boot_ec->gpe = ecdt_ptr->gpe; 976 boot_ec->gpe = ecdt_ptr->gpe;
1011 boot_ec->handle = ACPI_ROOT_OBJECT; 977 boot_ec->handle = ACPI_ROOT_OBJECT;
1012 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); 978 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
1013 /* Add some basic check against completely broken table */ 979 /* Don't trust ECDT, which comes from ASUSTek */
1014 if (boot_ec->data_addr != boot_ec->command_addr) 980 if (!dmi_name_in_vendors("ASUS"))
1015 goto install; 981 goto install;
982 saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
983 if (!saved_ec)
984 return -ENOMEM;
985 memcpy(&saved_ec, boot_ec, sizeof(saved_ec));
1016 /* fall through */ 986 /* fall through */
1017 } 987 }
1018 /* This workaround is needed only on some broken machines, 988 /* This workaround is needed only on some broken machines,
@@ -1023,12 +993,29 @@ int __init acpi_ec_ecdt_probe(void)
1023 /* Check that acpi_get_devices actually find something */ 993 /* Check that acpi_get_devices actually find something */
1024 if (ACPI_FAILURE(status) || !boot_ec->handle) 994 if (ACPI_FAILURE(status) || !boot_ec->handle)
1025 goto error; 995 goto error;
1026 /* We really need to limit this workaround, the only ASUS, 996 if (saved_ec) {
1027 * which needs it, has fake EC._INI method, so use it as flag. 997 /* try to find good ECDT from ASUSTek */
1028 * Keep boot_ec struct as it will be needed soon. 998 if (saved_ec->command_addr != boot_ec->command_addr ||
1029 */ 999 saved_ec->data_addr != boot_ec->data_addr ||
1030 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy))) 1000 saved_ec->gpe != boot_ec->gpe ||
1031 return -ENODEV; 1001 saved_ec->handle != boot_ec->handle)
1002 pr_info(PREFIX "ASUSTek keeps feeding us with broken "
1003 "ECDT tables, which are very hard to workaround. "
1004 "Trying to use DSDT EC info instead. Please send "
1005 "output of acpidump to linux-acpi@vger.kernel.org\n");
1006 kfree(saved_ec);
1007 saved_ec = NULL;
1008 } else {
1009 /* We really need to limit this workaround, the only ASUS,
1010 * which needs it, has fake EC._INI method, so use it as flag.
1011 * Keep boot_ec struct as it will be needed soon.
1012 */
1013 acpi_handle dummy;
1014 if (!dmi_name_in_vendors("ASUS") ||
1015 ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI",
1016 &dummy)))
1017 return -ENODEV;
1018 }
1032install: 1019install:
1033 if (!ec_install_handlers(boot_ec)) { 1020 if (!ec_install_handlers(boot_ec)) {
1034 first_ec = boot_ec; 1021 first_ec = boot_ec;
diff --git a/drivers/acpi/main.c b/drivers/acpi/sleep.c
index 7e3c609cbef2..7e3c609cbef2 100644
--- a/drivers/acpi/main.c
+++ b/drivers/acpi/sleep.c
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 073ff09218a9..99e6f1f8ea45 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -416,7 +416,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
416 } 416 }
417 417
418 /* Passive (optional) */ 418 /* Passive (optional) */
419 if (flag & ACPI_TRIPS_PASSIVE) { 419 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) ||
420 (flag == ACPI_TRIPS_INIT)) {
420 valid = tz->trips.passive.flags.valid; 421 valid = tz->trips.passive.flags.valid;
421 if (psv == -1) { 422 if (psv == -1) {
422 status = AE_SUPPORT; 423 status = AE_SUPPORT;
@@ -462,8 +463,11 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
462 memset(&devices, 0, sizeof(struct acpi_handle_list)); 463 memset(&devices, 0, sizeof(struct acpi_handle_list));
463 status = acpi_evaluate_reference(tz->device->handle, "_PSL", 464 status = acpi_evaluate_reference(tz->device->handle, "_PSL",
464 NULL, &devices); 465 NULL, &devices);
465 if (ACPI_FAILURE(status)) 466 if (ACPI_FAILURE(status)) {
467 printk(KERN_WARNING PREFIX
468 "Invalid passive threshold\n");
466 tz->trips.passive.flags.valid = 0; 469 tz->trips.passive.flags.valid = 0;
470 }
467 else 471 else
468 tz->trips.passive.flags.valid = 1; 472 tz->trips.passive.flags.valid = 1;
469 473
@@ -487,7 +491,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
487 if (act == -1) 491 if (act == -1)
488 break; /* disable all active trip points */ 492 break; /* disable all active trip points */
489 493
490 if (flag & ACPI_TRIPS_ACTIVE) { 494 if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE) &&
495 tz->trips.active[i].flags.valid)) {
491 status = acpi_evaluate_integer(tz->device->handle, 496 status = acpi_evaluate_integer(tz->device->handle,
492 name, NULL, &tmp); 497 name, NULL, &tmp);
493 if (ACPI_FAILURE(status)) { 498 if (ACPI_FAILURE(status)) {
@@ -521,8 +526,11 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
521 memset(&devices, 0, sizeof(struct acpi_handle_list)); 526 memset(&devices, 0, sizeof(struct acpi_handle_list));
522 status = acpi_evaluate_reference(tz->device->handle, 527 status = acpi_evaluate_reference(tz->device->handle,
523 name, NULL, &devices); 528 name, NULL, &devices);
524 if (ACPI_FAILURE(status)) 529 if (ACPI_FAILURE(status)) {
530 printk(KERN_WARNING PREFIX
531 "Invalid active%d threshold\n", i);
525 tz->trips.active[i].flags.valid = 0; 532 tz->trips.active[i].flags.valid = 0;
533 }
526 else 534 else
527 tz->trips.active[i].flags.valid = 1; 535 tz->trips.active[i].flags.valid = 1;
528 536
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 1a7be96d627b..503a908afc80 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -698,6 +698,15 @@ config PATA_IXP4XX_CF
698 698
699 If unsure, say N. 699 If unsure, say N.
700 700
701config PATA_OCTEON_CF
702 tristate "OCTEON Boot Bus Compact Flash support"
703 depends on CPU_CAVIUM_OCTEON
704 help
705 This option enables a polled compact flash driver for use with
706 compact flash cards attached to the OCTEON boot bus.
707
708 If unsure, say N.
709
701config PATA_SCC 710config PATA_SCC
702 tristate "Toshiba's Cell Reference Set IDE support" 711 tristate "Toshiba's Cell Reference Set IDE support"
703 depends on PCI && PPC_CELLEB 712 depends on PCI && PPC_CELLEB
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 674965fa326d..7f1ecf99528c 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o
69obj-$(CONFIG_PATA_SCC) += pata_scc.o 69obj-$(CONFIG_PATA_SCC) += pata_scc.o
70obj-$(CONFIG_PATA_SCH) += pata_sch.o 70obj-$(CONFIG_PATA_SCH) += pata_sch.o
71obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o 71obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o
72obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o
72obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o 73obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o
73obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o 74obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o
74obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o 75obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 71218d76d75e..88c242856dae 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3029,33 +3029,33 @@ int sata_set_spd(struct ata_link *link)
3029 */ 3029 */
3030 3030
3031static const struct ata_timing ata_timing[] = { 3031static const struct ata_timing ata_timing[] = {
3032/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 }, */ 3032/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 0, 960, 0 }, */
3033 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0 }, 3033 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 0, 600, 0 },
3034 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 383, 0 }, 3034 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 0, 383, 0 },
3035 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 240, 0 }, 3035 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 0, 240, 0 },
3036 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 }, 3036 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 0, 180, 0 },
3037 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 }, 3037 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 0, 120, 0 },
3038 { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 100, 0 }, 3038 { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 0, 100, 0 },
3039 { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 80, 0 }, 3039 { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 0, 80, 0 },
3040 3040
3041 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, 3041 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 50, 960, 0 },
3042 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, 3042 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 30, 480, 0 },
3043 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 }, 3043 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 20, 240, 0 },
3044 3044
3045 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 }, 3045 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 20, 480, 0 },
3046 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 }, 3046 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 5, 150, 0 },
3047 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 }, 3047 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 5, 120, 0 },
3048 { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 100, 0 }, 3048 { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 5, 100, 0 },
3049 { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 80, 0 }, 3049 { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 5, 80, 0 },
3050 3050
3051/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */ 3051/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 0, 150 }, */
3052 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, 3052 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 0, 120 },
3053 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 }, 3053 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 0, 80 },
3054 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 }, 3054 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 0, 60 },
3055 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 }, 3055 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 0, 45 },
3056 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 }, 3056 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 0, 30 },
3057 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 20 }, 3057 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 0, 20 },
3058 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 15 }, 3058 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 0, 15 },
3059 3059
3060 { 0xFF } 3060 { 0xFF }
3061}; 3061};
@@ -3065,14 +3065,15 @@ static const struct ata_timing ata_timing[] = {
3065 3065
3066static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT) 3066static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT)
3067{ 3067{
3068 q->setup = EZ(t->setup * 1000, T); 3068 q->setup = EZ(t->setup * 1000, T);
3069 q->act8b = EZ(t->act8b * 1000, T); 3069 q->act8b = EZ(t->act8b * 1000, T);
3070 q->rec8b = EZ(t->rec8b * 1000, T); 3070 q->rec8b = EZ(t->rec8b * 1000, T);
3071 q->cyc8b = EZ(t->cyc8b * 1000, T); 3071 q->cyc8b = EZ(t->cyc8b * 1000, T);
3072 q->active = EZ(t->active * 1000, T); 3072 q->active = EZ(t->active * 1000, T);
3073 q->recover = EZ(t->recover * 1000, T); 3073 q->recover = EZ(t->recover * 1000, T);
3074 q->cycle = EZ(t->cycle * 1000, T); 3074 q->dmack_hold = EZ(t->dmack_hold * 1000, T);
3075 q->udma = EZ(t->udma * 1000, UT); 3075 q->cycle = EZ(t->cycle * 1000, T);
3076 q->udma = EZ(t->udma * 1000, UT);
3076} 3077}
3077 3078
3078void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b, 3079void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
@@ -3084,6 +3085,7 @@ void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
3084 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b); 3085 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
3085 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active); 3086 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active);
3086 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover); 3087 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
3088 if (what & ATA_TIMING_DMACK_HOLD) m->dmack_hold = max(a->dmack_hold, b->dmack_hold);
3087 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle); 3089 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
3088 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma); 3090 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
3089} 3091}
@@ -6638,7 +6640,6 @@ EXPORT_SYMBOL_GPL(ata_dev_pair);
6638EXPORT_SYMBOL_GPL(ata_port_disable); 6640EXPORT_SYMBOL_GPL(ata_port_disable);
6639EXPORT_SYMBOL_GPL(ata_ratelimit); 6641EXPORT_SYMBOL_GPL(ata_ratelimit);
6640EXPORT_SYMBOL_GPL(ata_wait_register); 6642EXPORT_SYMBOL_GPL(ata_wait_register);
6641EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
6642EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 6643EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
6643EXPORT_SYMBOL_GPL(ata_scsi_slave_config); 6644EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
6644EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); 6645EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 9e92107691f2..a1a6e6298c33 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -423,9 +423,9 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,
423 * RETURNS: 423 * RETURNS:
424 * Zero on success, negative errno on error. 424 * Zero on success, negative errno on error.
425 */ 425 */
426static int ata_get_identity(struct scsi_device *sdev, void __user *arg) 426static int ata_get_identity(struct ata_port *ap, struct scsi_device *sdev,
427 void __user *arg)
427{ 428{
428 struct ata_port *ap = ata_shost_to_port(sdev->host);
429 struct ata_device *dev = ata_scsi_find_dev(ap, sdev); 429 struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
430 u16 __user *dst = arg; 430 u16 __user *dst = arg;
431 char buf[40]; 431 char buf[40];
@@ -645,7 +645,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
645 return rc; 645 return rc;
646} 646}
647 647
648int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) 648int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev,
649 int cmd, void __user *arg)
649{ 650{
650 int val = -EINVAL, rc = -EINVAL; 651 int val = -EINVAL, rc = -EINVAL;
651 652
@@ -663,7 +664,7 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
663 return 0; 664 return 0;
664 665
665 case HDIO_GET_IDENTITY: 666 case HDIO_GET_IDENTITY:
666 return ata_get_identity(scsidev, arg); 667 return ata_get_identity(ap, scsidev, arg);
667 668
668 case HDIO_DRIVE_CMD: 669 case HDIO_DRIVE_CMD:
669 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) 670 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
@@ -682,6 +683,14 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
682 683
683 return rc; 684 return rc;
684} 685}
686EXPORT_SYMBOL_GPL(ata_sas_scsi_ioctl);
687
688int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
689{
690 return ata_sas_scsi_ioctl(ata_shost_to_port(scsidev->host),
691 scsidev, cmd, arg);
692}
693EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
685 694
686/** 695/**
687 * ata_scsi_qc_new - acquire new ata_queued_cmd reference 696 * ata_scsi_qc_new - acquire new ata_queued_cmd reference
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 0eae9b453556..5a4aad123c42 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1013,9 +1013,12 @@ next_sg:
1013 qc->cursg_ofs = 0; 1013 qc->cursg_ofs = 0;
1014 } 1014 }
1015 1015
1016 /* consumed can be larger than count only for the last transfer */ 1016 /*
1017 WARN_ON_ONCE(qc->cursg && count != consumed); 1017 * There used to be a WARN_ON_ONCE(qc->cursg && count != consumed);
1018 1018 * Unfortunately __atapi_pio_bytes doesn't know enough to do the WARN
1019 * check correctly as it doesn't know if it is the last request being
1020 * made. Somebody should implement a proper sanity check.
1021 */
1019 if (bytes) 1022 if (bytes)
1020 goto next_sg; 1023 goto next_sg;
1021 return 0; 1024 return 0;
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index a7999c19f0c9..eb99dbe78081 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -41,7 +41,7 @@ static int ali_atapi_dma = 0;
41module_param_named(atapi_dma, ali_atapi_dma, int, 0644); 41module_param_named(atapi_dma, ali_atapi_dma, int, 0644);
42MODULE_PARM_DESC(atapi_dma, "Enable ATAPI DMA (0=disable, 1=enable)"); 42MODULE_PARM_DESC(atapi_dma, "Enable ATAPI DMA (0=disable, 1=enable)");
43 43
44static struct pci_dev *isa_bridge; 44static struct pci_dev *ali_isa_bridge;
45 45
46/* 46/*
47 * Cable special cases 47 * Cable special cases
@@ -346,13 +346,13 @@ static void ali_c2_c3_postreset(struct ata_link *link, unsigned int *classes)
346 int port_bit = 4 << link->ap->port_no; 346 int port_bit = 4 << link->ap->port_no;
347 347
348 /* If our bridge is an ALI 1533 then do the extra work */ 348 /* If our bridge is an ALI 1533 then do the extra work */
349 if (isa_bridge) { 349 if (ali_isa_bridge) {
350 /* Tristate and re-enable the bus signals */ 350 /* Tristate and re-enable the bus signals */
351 pci_read_config_byte(isa_bridge, 0x58, &r); 351 pci_read_config_byte(ali_isa_bridge, 0x58, &r);
352 r &= ~port_bit; 352 r &= ~port_bit;
353 pci_write_config_byte(isa_bridge, 0x58, r); 353 pci_write_config_byte(ali_isa_bridge, 0x58, r);
354 r |= port_bit; 354 r |= port_bit;
355 pci_write_config_byte(isa_bridge, 0x58, r); 355 pci_write_config_byte(ali_isa_bridge, 0x58, r);
356 } 356 }
357 ata_sff_postreset(link, classes); 357 ata_sff_postreset(link, classes);
358} 358}
@@ -467,14 +467,14 @@ static void ali_init_chipset(struct pci_dev *pdev)
467 pci_write_config_byte(pdev, 0x53, tmp); 467 pci_write_config_byte(pdev, 0x53, tmp);
468 } 468 }
469 north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); 469 north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0));
470 if (north && north->vendor == PCI_VENDOR_ID_AL && isa_bridge) { 470 if (north && north->vendor == PCI_VENDOR_ID_AL && ali_isa_bridge) {
471 /* Configure the ALi bridge logic. For non ALi rely on BIOS. 471 /* Configure the ALi bridge logic. For non ALi rely on BIOS.
472 Set the south bridge enable bit */ 472 Set the south bridge enable bit */
473 pci_read_config_byte(isa_bridge, 0x79, &tmp); 473 pci_read_config_byte(ali_isa_bridge, 0x79, &tmp);
474 if (pdev->revision == 0xC2) 474 if (pdev->revision == 0xC2)
475 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04); 475 pci_write_config_byte(ali_isa_bridge, 0x79, tmp | 0x04);
476 else if (pdev->revision > 0xC2 && pdev->revision < 0xC5) 476 else if (pdev->revision > 0xC2 && pdev->revision < 0xC5)
477 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02); 477 pci_write_config_byte(ali_isa_bridge, 0x79, tmp | 0x02);
478 } 478 }
479 pci_dev_put(north); 479 pci_dev_put(north);
480 ata_pci_bmdma_clear_simplex(pdev); 480 ata_pci_bmdma_clear_simplex(pdev);
@@ -571,9 +571,9 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
571 571
572 ali_init_chipset(pdev); 572 ali_init_chipset(pdev);
573 573
574 if (isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) { 574 if (ali_isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) {
575 /* Are we paired with a UDMA capable chip */ 575 /* Are we paired with a UDMA capable chip */
576 pci_read_config_byte(isa_bridge, 0x5E, &tmp); 576 pci_read_config_byte(ali_isa_bridge, 0x5E, &tmp);
577 if ((tmp & 0x1E) == 0x12) 577 if ((tmp & 0x1E) == 0x12)
578 ppi[0] = &info_20_udma; 578 ppi[0] = &info_20_udma;
579 } 579 }
@@ -617,11 +617,11 @@ static struct pci_driver ali_pci_driver = {
617static int __init ali_init(void) 617static int __init ali_init(void)
618{ 618{
619 int ret; 619 int ret;
620 isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); 620 ali_isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
621 621
622 ret = pci_register_driver(&ali_pci_driver); 622 ret = pci_register_driver(&ali_pci_driver);
623 if (ret < 0) 623 if (ret < 0)
624 pci_dev_put(isa_bridge); 624 pci_dev_put(ali_isa_bridge);
625 return ret; 625 return ret;
626} 626}
627 627
@@ -629,7 +629,7 @@ static int __init ali_init(void)
629static void __exit ali_exit(void) 629static void __exit ali_exit(void)
630{ 630{
631 pci_unregister_driver(&ali_pci_driver); 631 pci_unregister_driver(&ali_pci_driver);
632 pci_dev_put(isa_bridge); 632 pci_dev_put(ali_isa_bridge);
633} 633}
634 634
635 635
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 0e2cde8f9973..506adde8ebb3 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -32,21 +32,6 @@ enum {
32 ATIIXP_IDE_UDMA_MODE = 0x56 32 ATIIXP_IDE_UDMA_MODE = 0x56
33}; 33};
34 34
35static int atiixp_pre_reset(struct ata_link *link, unsigned long deadline)
36{
37 struct ata_port *ap = link->ap;
38 static const struct pci_bits atiixp_enable_bits[] = {
39 { 0x48, 1, 0x01, 0x00 },
40 { 0x48, 1, 0x08, 0x00 }
41 };
42 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
43
44 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
45 return -ENOENT;
46
47 return ata_sff_prereset(link, deadline);
48}
49
50static int atiixp_cable_detect(struct ata_port *ap) 35static int atiixp_cable_detect(struct ata_port *ap)
51{ 36{
52 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 37 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -229,10 +214,9 @@ static struct ata_port_operations atiixp_port_ops = {
229 .cable_detect = atiixp_cable_detect, 214 .cable_detect = atiixp_cable_detect,
230 .set_piomode = atiixp_set_piomode, 215 .set_piomode = atiixp_set_piomode,
231 .set_dmamode = atiixp_set_dmamode, 216 .set_dmamode = atiixp_set_dmamode,
232 .prereset = atiixp_pre_reset,
233}; 217};
234 218
235static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) 219static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
236{ 220{
237 static const struct ata_port_info info = { 221 static const struct ata_port_info info = {
238 .flags = ATA_FLAG_SLAVE_POSS, 222 .flags = ATA_FLAG_SLAVE_POSS,
@@ -241,8 +225,18 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
241 .udma_mask = 0x3F, 225 .udma_mask = 0x3F,
242 .port_ops = &atiixp_port_ops 226 .port_ops = &atiixp_port_ops
243 }; 227 };
244 const struct ata_port_info *ppi[] = { &info, NULL }; 228 static const struct pci_bits atiixp_enable_bits[] = {
245 return ata_pci_sff_init_one(dev, ppi, &atiixp_sht, NULL); 229 { 0x48, 1, 0x01, 0x00 },
230 { 0x48, 1, 0x08, 0x00 }
231 };
232 const struct ata_port_info *ppi[] = { &info, &info };
233 int i;
234
235 for (i = 0; i < 2; i++)
236 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[i]))
237 ppi[i] = &ata_dummy_port_info;
238
239 return ata_pci_sff_init_one(pdev, ppi, &atiixp_sht, NULL);
246} 240}
247 241
248static const struct pci_device_id atiixp[] = { 242static const struct pci_device_id atiixp[] = {
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index f828a29d7756..f1bb2f9fecbf 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -80,7 +80,7 @@
80 80
81 81
82#define DRV_NAME "pata_it821x" 82#define DRV_NAME "pata_it821x"
83#define DRV_VERSION "0.4.0" 83#define DRV_VERSION "0.4.2"
84 84
85struct it821x_dev 85struct it821x_dev
86{ 86{
@@ -494,8 +494,6 @@ static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unus
494 * special. In our case we need to lock the sector count to avoid 494 * special. In our case we need to lock the sector count to avoid
495 * blowing the brains out of the firmware with large LBA48 requests 495 * blowing the brains out of the firmware with large LBA48 requests
496 * 496 *
497 * FIXME: When FUA appears we need to block FUA too. And SMART and
498 * basically we need to filter commands for this chip.
499 */ 497 */
500 498
501static void it821x_dev_config(struct ata_device *adev) 499static void it821x_dev_config(struct ata_device *adev)
@@ -890,6 +888,13 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
890 .flags = ATA_FLAG_SLAVE_POSS, 888 .flags = ATA_FLAG_SLAVE_POSS,
891 .pio_mask = 0x1f, 889 .pio_mask = 0x1f,
892 .mwdma_mask = 0x07, 890 .mwdma_mask = 0x07,
891 .udma_mask = ATA_UDMA6,
892 .port_ops = &it821x_rdc_port_ops
893 };
894 static const struct ata_port_info info_rdc_11 = {
895 .flags = ATA_FLAG_SLAVE_POSS,
896 .pio_mask = 0x1f,
897 .mwdma_mask = 0x07,
893 /* No UDMA */ 898 /* No UDMA */
894 .port_ops = &it821x_rdc_port_ops 899 .port_ops = &it821x_rdc_port_ops
895 }; 900 };
@@ -903,7 +908,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
903 return rc; 908 return rc;
904 909
905 if (pdev->vendor == PCI_VENDOR_ID_RDC) { 910 if (pdev->vendor == PCI_VENDOR_ID_RDC) {
906 ppi[0] = &info_rdc; 911 /* Deal with Vortex86SX */
912 if (pdev->revision == 0x11)
913 ppi[0] = &info_rdc_11;
914 else
915 ppi[0] = &info_rdc;
907 } else { 916 } else {
908 /* Force the card into bypass mode if so requested */ 917 /* Force the card into bypass mode if so requested */
909 if (it8212_noraid) { 918 if (it8212_noraid) {
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
new file mode 100644
index 000000000000..0fe4ef309c62
--- /dev/null
+++ b/drivers/ata/pata_octeon_cf.c
@@ -0,0 +1,965 @@
1/*
2 * Driver for the Octeon bootbus compact flash.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2005 - 2009 Cavium Networks
9 * Copyright (C) 2008 Wind River Systems
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/libata.h>
15#include <linux/irq.h>
16#include <linux/platform_device.h>
17#include <linux/workqueue.h>
18#include <scsi/scsi_host.h>
19
20#include <asm/octeon/octeon.h>
21
22/*
23 * The Octeon bootbus compact flash interface is connected in at least
24 * 3 different configurations on various evaluation boards:
25 *
26 * -- 8 bits no irq, no DMA
27 * -- 16 bits no irq, no DMA
28 * -- 16 bits True IDE mode with DMA, but no irq.
29 *
30 * In the last case the DMA engine can generate an interrupt when the
31 * transfer is complete. For the first two cases only PIO is supported.
32 *
33 */
34
35#define DRV_NAME "pata_octeon_cf"
36#define DRV_VERSION "2.1"
37
38
39struct octeon_cf_port {
40 struct workqueue_struct *wq;
41 struct delayed_work delayed_finish;
42 struct ata_port *ap;
43 int dma_finished;
44};
45
46static struct scsi_host_template octeon_cf_sht = {
47 ATA_PIO_SHT(DRV_NAME),
48};
49
50/**
51 * Convert nanosecond based time to setting used in the
52 * boot bus timing register, based on timing multiple
53 */
54static unsigned int ns_to_tim_reg(unsigned int tim_mult, unsigned int nsecs)
55{
56 unsigned int val;
57
58 /*
59 * Compute # of eclock periods to get desired duration in
60 * nanoseconds.
61 */
62 val = DIV_ROUND_UP(nsecs * (octeon_get_clock_rate() / 1000000),
63 1000 * tim_mult);
64
65 return val;
66}
67
68static void octeon_cf_set_boot_reg_cfg(int cs)
69{
70 union cvmx_mio_boot_reg_cfgx reg_cfg;
71 reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
72 reg_cfg.s.dmack = 0; /* Don't assert DMACK on access */
73 reg_cfg.s.tim_mult = 2; /* Timing mutiplier 2x */
74 reg_cfg.s.rd_dly = 0; /* Sample on falling edge of BOOT_OE */
75 reg_cfg.s.sam = 0; /* Don't combine write and output enable */
76 reg_cfg.s.we_ext = 0; /* No write enable extension */
77 reg_cfg.s.oe_ext = 0; /* No read enable extension */
78 reg_cfg.s.en = 1; /* Enable this region */
79 reg_cfg.s.orbit = 0; /* Don't combine with previous region */
80 reg_cfg.s.ale = 0; /* Don't do address multiplexing */
81 cvmx_write_csr(CVMX_MIO_BOOT_REG_CFGX(cs), reg_cfg.u64);
82}
83
84/**
85 * Called after libata determines the needed PIO mode. This
86 * function programs the Octeon bootbus regions to support the
87 * timing requirements of the PIO mode.
88 *
89 * @ap: ATA port information
90 * @dev: ATA device
91 */
92static void octeon_cf_set_piomode(struct ata_port *ap, struct ata_device *dev)
93{
94 struct octeon_cf_data *ocd = ap->dev->platform_data;
95 union cvmx_mio_boot_reg_timx reg_tim;
96 int cs = ocd->base_region;
97 int T;
98 struct ata_timing timing;
99
100 int use_iordy;
101 int trh;
102 int pause;
103 /* These names are timing parameters from the ATA spec */
104 int t1;
105 int t2;
106 int t2i;
107
108 T = (int)(2000000000000LL / octeon_get_clock_rate());
109
110 if (ata_timing_compute(dev, dev->pio_mode, &timing, T, T))
111 BUG();
112
113 t1 = timing.setup;
114 if (t1)
115 t1--;
116 t2 = timing.active;
117 if (t2)
118 t2--;
119 t2i = timing.act8b;
120 if (t2i)
121 t2i--;
122
123 trh = ns_to_tim_reg(2, 20);
124 if (trh)
125 trh--;
126
127 pause = timing.cycle - timing.active - timing.setup - trh;
128 if (pause)
129 pause--;
130
131 octeon_cf_set_boot_reg_cfg(cs);
132 if (ocd->dma_engine >= 0)
133 /* True IDE mode, program both chip selects. */
134 octeon_cf_set_boot_reg_cfg(cs + 1);
135
136
137 use_iordy = ata_pio_need_iordy(dev);
138
139 reg_tim.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_TIMX(cs));
140 /* Disable page mode */
141 reg_tim.s.pagem = 0;
142 /* Enable dynamic timing */
143 reg_tim.s.waitm = use_iordy;
144 /* Pages are disabled */
145 reg_tim.s.pages = 0;
146 /* We don't use multiplexed address mode */
147 reg_tim.s.ale = 0;
148 /* Not used */
149 reg_tim.s.page = 0;
150 /* Time after IORDY to coninue to assert the data */
151 reg_tim.s.wait = 0;
152 /* Time to wait to complete the cycle. */
153 reg_tim.s.pause = pause;
154 /* How long to hold after a write to de-assert CE. */
155 reg_tim.s.wr_hld = trh;
156 /* How long to wait after a read to de-assert CE. */
157 reg_tim.s.rd_hld = trh;
158 /* How long write enable is asserted */
159 reg_tim.s.we = t2;
160 /* How long read enable is asserted */
161 reg_tim.s.oe = t2;
162 /* Time after CE that read/write starts */
163 reg_tim.s.ce = ns_to_tim_reg(2, 5);
164 /* Time before CE that address is valid */
165 reg_tim.s.adr = 0;
166
167 /* Program the bootbus region timing for the data port chip select. */
168 cvmx_write_csr(CVMX_MIO_BOOT_REG_TIMX(cs), reg_tim.u64);
169 if (ocd->dma_engine >= 0)
170 /* True IDE mode, program both chip selects. */
171 cvmx_write_csr(CVMX_MIO_BOOT_REG_TIMX(cs + 1), reg_tim.u64);
172}
173
174static void octeon_cf_set_dmamode(struct ata_port *ap, struct ata_device *dev)
175{
176 struct octeon_cf_data *ocd = dev->link->ap->dev->platform_data;
177 union cvmx_mio_boot_dma_timx dma_tim;
178 unsigned int oe_a;
179 unsigned int oe_n;
180 unsigned int dma_ackh;
181 unsigned int dma_arq;
182 unsigned int pause;
183 unsigned int T0, Tkr, Td;
184 unsigned int tim_mult;
185
186 const struct ata_timing *timing;
187
188 timing = ata_timing_find_mode(dev->dma_mode);
189 T0 = timing->cycle;
190 Td = timing->active;
191 Tkr = timing->recover;
192 dma_ackh = timing->dmack_hold;
193
194 dma_tim.u64 = 0;
195 /* dma_tim.s.tim_mult = 0 --> 4x */
196 tim_mult = 4;
197
198 /* not spec'ed, value in eclocks, not affected by tim_mult */
199 dma_arq = 8;
200 pause = 25 - dma_arq * 1000 /
201 (octeon_get_clock_rate() / 1000000); /* Tz */
202
203 oe_a = Td;
204 /* Tkr from cf spec, lengthened to meet T0 */
205 oe_n = max(T0 - oe_a, Tkr);
206
207 dma_tim.s.dmack_pi = 1;
208
209 dma_tim.s.oe_n = ns_to_tim_reg(tim_mult, oe_n);
210 dma_tim.s.oe_a = ns_to_tim_reg(tim_mult, oe_a);
211
212 /*
213 * This is tI, C.F. spec. says 0, but Sony CF card requires
214 * more, we use 20 nS.
215 */
216 dma_tim.s.dmack_s = ns_to_tim_reg(tim_mult, 20);;
217 dma_tim.s.dmack_h = ns_to_tim_reg(tim_mult, dma_ackh);
218
219 dma_tim.s.dmarq = dma_arq;
220 dma_tim.s.pause = ns_to_tim_reg(tim_mult, pause);
221
222 dma_tim.s.rd_dly = 0; /* Sample right on edge */
223
224 /* writes only */
225 dma_tim.s.we_n = ns_to_tim_reg(tim_mult, oe_n);
226 dma_tim.s.we_a = ns_to_tim_reg(tim_mult, oe_a);
227
228 pr_debug("ns to ticks (mult %d) of %d is: %d\n", tim_mult, 60,
229 ns_to_tim_reg(tim_mult, 60));
230 pr_debug("oe_n: %d, oe_a: %d, dmack_s: %d, dmack_h: "
231 "%d, dmarq: %d, pause: %d\n",
232 dma_tim.s.oe_n, dma_tim.s.oe_a, dma_tim.s.dmack_s,
233 dma_tim.s.dmack_h, dma_tim.s.dmarq, dma_tim.s.pause);
234
235 cvmx_write_csr(CVMX_MIO_BOOT_DMA_TIMX(ocd->dma_engine),
236 dma_tim.u64);
237
238}
239
240/**
241 * Handle an 8 bit I/O request.
242 *
243 * @dev: Device to access
244 * @buffer: Data buffer
245 * @buflen: Length of the buffer.
246 * @rw: True to write.
247 */
248static unsigned int octeon_cf_data_xfer8(struct ata_device *dev,
249 unsigned char *buffer,
250 unsigned int buflen,
251 int rw)
252{
253 struct ata_port *ap = dev->link->ap;
254 void __iomem *data_addr = ap->ioaddr.data_addr;
255 unsigned long words;
256 int count;
257
258 words = buflen;
259 if (rw) {
260 count = 16;
261 while (words--) {
262 iowrite8(*buffer, data_addr);
263 buffer++;
264 /*
265 * Every 16 writes do a read so the bootbus
266 * FIFO doesn't fill up.
267 */
268 if (--count == 0) {
269 ioread8(ap->ioaddr.altstatus_addr);
270 count = 16;
271 }
272 }
273 } else {
274 ioread8_rep(data_addr, buffer, words);
275 }
276 return buflen;
277}
278
279/**
280 * Handle a 16 bit I/O request.
281 *
282 * @dev: Device to access
283 * @buffer: Data buffer
284 * @buflen: Length of the buffer.
285 * @rw: True to write.
286 */
287static unsigned int octeon_cf_data_xfer16(struct ata_device *dev,
288 unsigned char *buffer,
289 unsigned int buflen,
290 int rw)
291{
292 struct ata_port *ap = dev->link->ap;
293 void __iomem *data_addr = ap->ioaddr.data_addr;
294 unsigned long words;
295 int count;
296
297 words = buflen / 2;
298 if (rw) {
299 count = 16;
300 while (words--) {
301 iowrite16(*(uint16_t *)buffer, data_addr);
302 buffer += sizeof(uint16_t);
303 /*
304 * Every 16 writes do a read so the bootbus
305 * FIFO doesn't fill up.
306 */
307 if (--count == 0) {
308 ioread8(ap->ioaddr.altstatus_addr);
309 count = 16;
310 }
311 }
312 } else {
313 while (words--) {
314 *(uint16_t *)buffer = ioread16(data_addr);
315 buffer += sizeof(uint16_t);
316 }
317 }
318 /* Transfer trailing 1 byte, if any. */
319 if (unlikely(buflen & 0x01)) {
320 __le16 align_buf[1] = { 0 };
321
322 if (rw == READ) {
323 align_buf[0] = cpu_to_le16(ioread16(data_addr));
324 memcpy(buffer, align_buf, 1);
325 } else {
326 memcpy(align_buf, buffer, 1);
327 iowrite16(le16_to_cpu(align_buf[0]), data_addr);
328 }
329 words++;
330 }
331 return buflen;
332}
333
334/**
335 * Read the taskfile for 16bit non-True IDE only.
336 */
337static void octeon_cf_tf_read16(struct ata_port *ap, struct ata_taskfile *tf)
338{
339 u16 blob;
340 /* The base of the registers is at ioaddr.data_addr. */
341 void __iomem *base = ap->ioaddr.data_addr;
342
343 blob = __raw_readw(base + 0xc);
344 tf->feature = blob >> 8;
345
346 blob = __raw_readw(base + 2);
347 tf->nsect = blob & 0xff;
348 tf->lbal = blob >> 8;
349
350 blob = __raw_readw(base + 4);
351 tf->lbam = blob & 0xff;
352 tf->lbah = blob >> 8;
353
354 blob = __raw_readw(base + 6);
355 tf->device = blob & 0xff;
356 tf->command = blob >> 8;
357
358 if (tf->flags & ATA_TFLAG_LBA48) {
359 if (likely(ap->ioaddr.ctl_addr)) {
360 iowrite8(tf->ctl | ATA_HOB, ap->ioaddr.ctl_addr);
361
362 blob = __raw_readw(base + 0xc);
363 tf->hob_feature = blob >> 8;
364
365 blob = __raw_readw(base + 2);
366 tf->hob_nsect = blob & 0xff;
367 tf->hob_lbal = blob >> 8;
368
369 blob = __raw_readw(base + 4);
370 tf->hob_lbam = blob & 0xff;
371 tf->hob_lbah = blob >> 8;
372
373 iowrite8(tf->ctl, ap->ioaddr.ctl_addr);
374 ap->last_ctl = tf->ctl;
375 } else {
376 WARN_ON(1);
377 }
378 }
379}
380
381static u8 octeon_cf_check_status16(struct ata_port *ap)
382{
383 u16 blob;
384 void __iomem *base = ap->ioaddr.data_addr;
385
386 blob = __raw_readw(base + 6);
387 return blob >> 8;
388}
389
390static int octeon_cf_softreset16(struct ata_link *link, unsigned int *classes,
391 unsigned long deadline)
392{
393 struct ata_port *ap = link->ap;
394 void __iomem *base = ap->ioaddr.data_addr;
395 int rc;
396 u8 err;
397
398 DPRINTK("about to softreset\n");
399 __raw_writew(ap->ctl, base + 0xe);
400 udelay(20);
401 __raw_writew(ap->ctl | ATA_SRST, base + 0xe);
402 udelay(20);
403 __raw_writew(ap->ctl, base + 0xe);
404
405 rc = ata_sff_wait_after_reset(link, 1, deadline);
406 if (rc) {
407 ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc);
408 return rc;
409 }
410
411 /* determine by signature whether we have ATA or ATAPI devices */
412 classes[0] = ata_sff_dev_classify(&link->device[0], 1, &err);
413 DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]);
414 return 0;
415}
416
417/**
418 * Load the taskfile for 16bit non-True IDE only. The device_addr is
419 * not loaded, we do this as part of octeon_cf_exec_command16.
420 */
421static void octeon_cf_tf_load16(struct ata_port *ap,
422 const struct ata_taskfile *tf)
423{
424 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
425 /* The base of the registers is at ioaddr.data_addr. */
426 void __iomem *base = ap->ioaddr.data_addr;
427
428 if (tf->ctl != ap->last_ctl) {
429 iowrite8(tf->ctl, ap->ioaddr.ctl_addr);
430 ap->last_ctl = tf->ctl;
431 ata_wait_idle(ap);
432 }
433 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
434 __raw_writew(tf->hob_feature << 8, base + 0xc);
435 __raw_writew(tf->hob_nsect | tf->hob_lbal << 8, base + 2);
436 __raw_writew(tf->hob_lbam | tf->hob_lbah << 8, base + 4);
437 VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
438 tf->hob_feature,
439 tf->hob_nsect,
440 tf->hob_lbal,
441 tf->hob_lbam,
442 tf->hob_lbah);
443 }
444 if (is_addr) {
445 __raw_writew(tf->feature << 8, base + 0xc);
446 __raw_writew(tf->nsect | tf->lbal << 8, base + 2);
447 __raw_writew(tf->lbam | tf->lbah << 8, base + 4);
448 VPRINTK("feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
449 tf->feature,
450 tf->nsect,
451 tf->lbal,
452 tf->lbam,
453 tf->lbah);
454 }
455 ata_wait_idle(ap);
456}
457
458
459static void octeon_cf_dev_select(struct ata_port *ap, unsigned int device)
460{
461/* There is only one device, do nothing. */
462 return;
463}
464
465/*
466 * Issue ATA command to host controller. The device_addr is also sent
467 * as it must be written in a combined write with the command.
468 */
469static void octeon_cf_exec_command16(struct ata_port *ap,
470 const struct ata_taskfile *tf)
471{
472 /* The base of the registers is at ioaddr.data_addr. */
473 void __iomem *base = ap->ioaddr.data_addr;
474 u16 blob;
475
476 if (tf->flags & ATA_TFLAG_DEVICE) {
477 VPRINTK("device 0x%X\n", tf->device);
478 blob = tf->device;
479 } else {
480 blob = 0;
481 }
482
483 DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command);
484 blob |= (tf->command << 8);
485 __raw_writew(blob, base + 6);
486
487
488 ata_wait_idle(ap);
489}
490
491static u8 octeon_cf_irq_on(struct ata_port *ap)
492{
493 return 0;
494}
495
496static void octeon_cf_irq_clear(struct ata_port *ap)
497{
498 return;
499}
500
501static void octeon_cf_dma_setup(struct ata_queued_cmd *qc)
502{
503 struct ata_port *ap = qc->ap;
504 struct octeon_cf_port *cf_port;
505
506 cf_port = (struct octeon_cf_port *)ap->private_data;
507 DPRINTK("ENTER\n");
508 /* issue r/w command */
509 qc->cursg = qc->sg;
510 cf_port->dma_finished = 0;
511 ap->ops->sff_exec_command(ap, &qc->tf);
512 DPRINTK("EXIT\n");
513}
514
515/**
516 * Start a DMA transfer that was already setup
517 *
518 * @qc: Information about the DMA
519 */
520static void octeon_cf_dma_start(struct ata_queued_cmd *qc)
521{
522 struct octeon_cf_data *ocd = qc->ap->dev->platform_data;
523 union cvmx_mio_boot_dma_cfgx mio_boot_dma_cfg;
524 union cvmx_mio_boot_dma_intx mio_boot_dma_int;
525 struct scatterlist *sg;
526
527 VPRINTK("%d scatterlists\n", qc->n_elem);
528
529 /* Get the scatter list entry we need to DMA into */
530 sg = qc->cursg;
531 BUG_ON(!sg);
532
533 /*
534 * Clear the DMA complete status.
535 */
536 mio_boot_dma_int.u64 = 0;
537 mio_boot_dma_int.s.done = 1;
538 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine),
539 mio_boot_dma_int.u64);
540
541 /* Enable the interrupt. */
542 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INT_ENX(ocd->dma_engine),
543 mio_boot_dma_int.u64);
544
545 /* Set the direction of the DMA */
546 mio_boot_dma_cfg.u64 = 0;
547 mio_boot_dma_cfg.s.en = 1;
548 mio_boot_dma_cfg.s.rw = ((qc->tf.flags & ATA_TFLAG_WRITE) != 0);
549
550 /*
551 * Don't stop the DMA if the device deasserts DMARQ. Many
552 * compact flashes deassert DMARQ for a short time between
553 * sectors. Instead of stopping and restarting the DMA, we'll
554 * let the hardware do it. If the DMA is really stopped early
555 * due to an error condition, a later timeout will force us to
556 * stop.
557 */
558 mio_boot_dma_cfg.s.clr = 0;
559
560 /* Size is specified in 16bit words and minus one notation */
561 mio_boot_dma_cfg.s.size = sg_dma_len(sg) / 2 - 1;
562
563 /* We need to swap the high and low bytes of every 16 bits */
564 mio_boot_dma_cfg.s.swap8 = 1;
565
566 mio_boot_dma_cfg.s.adr = sg_dma_address(sg);
567
568 VPRINTK("%s %d bytes address=%p\n",
569 (mio_boot_dma_cfg.s.rw) ? "write" : "read", sg->length,
570 (void *)(unsigned long)mio_boot_dma_cfg.s.adr);
571
572 cvmx_write_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine),
573 mio_boot_dma_cfg.u64);
574}
575
576/**
577 *
578 * LOCKING:
579 * spin_lock_irqsave(host lock)
580 *
581 */
582static unsigned int octeon_cf_dma_finished(struct ata_port *ap,
583 struct ata_queued_cmd *qc)
584{
585 struct ata_eh_info *ehi = &ap->link.eh_info;
586 struct octeon_cf_data *ocd = ap->dev->platform_data;
587 union cvmx_mio_boot_dma_cfgx dma_cfg;
588 union cvmx_mio_boot_dma_intx dma_int;
589 struct octeon_cf_port *cf_port;
590 u8 status;
591
592 VPRINTK("ata%u: protocol %d task_state %d\n",
593 ap->print_id, qc->tf.protocol, ap->hsm_task_state);
594
595
596 if (ap->hsm_task_state != HSM_ST_LAST)
597 return 0;
598
599 cf_port = (struct octeon_cf_port *)ap->private_data;
600
601 dma_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine));
602 if (dma_cfg.s.size != 0xfffff) {
603 /* Error, the transfer was not complete. */
604 qc->err_mask |= AC_ERR_HOST_BUS;
605 ap->hsm_task_state = HSM_ST_ERR;
606 }
607
608 /* Stop and clear the dma engine. */
609 dma_cfg.u64 = 0;
610 dma_cfg.s.size = -1;
611 cvmx_write_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine), dma_cfg.u64);
612
613 /* Disable the interrupt. */
614 dma_int.u64 = 0;
615 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INT_ENX(ocd->dma_engine), dma_int.u64);
616
617 /* Clear the DMA complete status */
618 dma_int.s.done = 1;
619 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine), dma_int.u64);
620
621 status = ap->ops->sff_check_status(ap);
622
623 ata_sff_hsm_move(ap, qc, status, 0);
624
625 if (unlikely(qc->err_mask) && (qc->tf.protocol == ATA_PROT_DMA))
626 ata_ehi_push_desc(ehi, "DMA stat 0x%x", status);
627
628 return 1;
629}
630
631/*
632 * Check if any queued commands have more DMAs, if so start the next
633 * transfer, else do end of transfer handling.
634 */
635static irqreturn_t octeon_cf_interrupt(int irq, void *dev_instance)
636{
637 struct ata_host *host = dev_instance;
638 struct octeon_cf_port *cf_port;
639 int i;
640 unsigned int handled = 0;
641 unsigned long flags;
642
643 spin_lock_irqsave(&host->lock, flags);
644
645 DPRINTK("ENTER\n");
646 for (i = 0; i < host->n_ports; i++) {
647 u8 status;
648 struct ata_port *ap;
649 struct ata_queued_cmd *qc;
650 union cvmx_mio_boot_dma_intx dma_int;
651 union cvmx_mio_boot_dma_cfgx dma_cfg;
652 struct octeon_cf_data *ocd;
653
654 ap = host->ports[i];
655 ocd = ap->dev->platform_data;
656 if (!ap || (ap->flags & ATA_FLAG_DISABLED))
657 continue;
658
659 ocd = ap->dev->platform_data;
660 cf_port = (struct octeon_cf_port *)ap->private_data;
661 dma_int.u64 =
662 cvmx_read_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine));
663 dma_cfg.u64 =
664 cvmx_read_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine));
665
666 qc = ata_qc_from_tag(ap, ap->link.active_tag);
667
668 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
669 (qc->flags & ATA_QCFLAG_ACTIVE)) {
670 if (dma_int.s.done && !dma_cfg.s.en) {
671 if (!sg_is_last(qc->cursg)) {
672 qc->cursg = sg_next(qc->cursg);
673 handled = 1;
674 octeon_cf_dma_start(qc);
675 continue;
676 } else {
677 cf_port->dma_finished = 1;
678 }
679 }
680 if (!cf_port->dma_finished)
681 continue;
682 status = ioread8(ap->ioaddr.altstatus_addr);
683 if (status & (ATA_BUSY | ATA_DRQ)) {
684 /*
685 * We are busy, try to handle it
686 * later. This is the DMA finished
687 * interrupt, and it could take a
688 * little while for the card to be
689 * ready for more commands.
690 */
691 /* Clear DMA irq. */
692 dma_int.u64 = 0;
693 dma_int.s.done = 1;
694 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine),
695 dma_int.u64);
696
697 queue_delayed_work(cf_port->wq,
698 &cf_port->delayed_finish, 1);
699 handled = 1;
700 } else {
701 handled |= octeon_cf_dma_finished(ap, qc);
702 }
703 }
704 }
705 spin_unlock_irqrestore(&host->lock, flags);
706 DPRINTK("EXIT\n");
707 return IRQ_RETVAL(handled);
708}
709
710static void octeon_cf_delayed_finish(struct work_struct *work)
711{
712 struct octeon_cf_port *cf_port = container_of(work,
713 struct octeon_cf_port,
714 delayed_finish.work);
715 struct ata_port *ap = cf_port->ap;
716 struct ata_host *host = ap->host;
717 struct ata_queued_cmd *qc;
718 unsigned long flags;
719 u8 status;
720
721 spin_lock_irqsave(&host->lock, flags);
722
723 /*
724 * If the port is not waiting for completion, it must have
725 * handled it previously. The hsm_task_state is
726 * protected by host->lock.
727 */
728 if (ap->hsm_task_state != HSM_ST_LAST || !cf_port->dma_finished)
729 goto out;
730
731 status = ioread8(ap->ioaddr.altstatus_addr);
732 if (status & (ATA_BUSY | ATA_DRQ)) {
733 /* Still busy, try again. */
734 queue_delayed_work(cf_port->wq,
735 &cf_port->delayed_finish, 1);
736 goto out;
737 }
738 qc = ata_qc_from_tag(ap, ap->link.active_tag);
739 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
740 (qc->flags & ATA_QCFLAG_ACTIVE))
741 octeon_cf_dma_finished(ap, qc);
742out:
743 spin_unlock_irqrestore(&host->lock, flags);
744}
745
746static void octeon_cf_dev_config(struct ata_device *dev)
747{
748 /*
749 * A maximum of 2^20 - 1 16 bit transfers are possible with
750 * the bootbus DMA. So we need to throttle max_sectors to
751 * (2^12 - 1 == 4095) to assure that this can never happen.
752 */
753 dev->max_sectors = min(dev->max_sectors, 4095U);
754}
755
756/*
757 * Trap if driver tries to do standard bmdma commands. They are not
758 * supported.
759 */
760static void unreachable_qc(struct ata_queued_cmd *qc)
761{
762 BUG();
763}
764
765static u8 unreachable_port(struct ata_port *ap)
766{
767 BUG();
768}
769
770/*
771 * We don't do ATAPI DMA so return 0.
772 */
773static int octeon_cf_check_atapi_dma(struct ata_queued_cmd *qc)
774{
775 return 0;
776}
777
778static unsigned int octeon_cf_qc_issue(struct ata_queued_cmd *qc)
779{
780 struct ata_port *ap = qc->ap;
781
782 switch (qc->tf.protocol) {
783 case ATA_PROT_DMA:
784 WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING);
785
786 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
787 octeon_cf_dma_setup(qc); /* set up dma */
788 octeon_cf_dma_start(qc); /* initiate dma */
789 ap->hsm_task_state = HSM_ST_LAST;
790 break;
791
792 case ATAPI_PROT_DMA:
793 dev_err(ap->dev, "Error, ATAPI not supported\n");
794 BUG();
795
796 default:
797 return ata_sff_qc_issue(qc);
798 }
799
800 return 0;
801}
802
803static struct ata_port_operations octeon_cf_ops = {
804 .inherits = &ata_sff_port_ops,
805 .check_atapi_dma = octeon_cf_check_atapi_dma,
806 .qc_prep = ata_noop_qc_prep,
807 .qc_issue = octeon_cf_qc_issue,
808 .sff_dev_select = octeon_cf_dev_select,
809 .sff_irq_on = octeon_cf_irq_on,
810 .sff_irq_clear = octeon_cf_irq_clear,
811 .bmdma_setup = unreachable_qc,
812 .bmdma_start = unreachable_qc,
813 .bmdma_stop = unreachable_qc,
814 .bmdma_status = unreachable_port,
815 .cable_detect = ata_cable_40wire,
816 .set_piomode = octeon_cf_set_piomode,
817 .set_dmamode = octeon_cf_set_dmamode,
818 .dev_config = octeon_cf_dev_config,
819};
820
821static int __devinit octeon_cf_probe(struct platform_device *pdev)
822{
823 struct resource *res_cs0, *res_cs1;
824
825 void __iomem *cs0;
826 void __iomem *cs1 = NULL;
827 struct ata_host *host;
828 struct ata_port *ap;
829 struct octeon_cf_data *ocd;
830 int irq = 0;
831 irq_handler_t irq_handler = NULL;
832 void __iomem *base;
833 struct octeon_cf_port *cf_port;
834
835 res_cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
836
837 if (!res_cs0)
838 return -EINVAL;
839
840 ocd = pdev->dev.platform_data;
841
842 cs0 = devm_ioremap_nocache(&pdev->dev, res_cs0->start,
843 res_cs0->end - res_cs0->start + 1);
844
845 if (!cs0)
846 return -ENOMEM;
847
848 /* Determine from availability of DMA if True IDE mode or not */
849 if (ocd->dma_engine >= 0) {
850 res_cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
851 if (!res_cs1)
852 return -EINVAL;
853
854 cs1 = devm_ioremap_nocache(&pdev->dev, res_cs1->start,
855 res_cs0->end - res_cs1->start + 1);
856
857 if (!cs1)
858 return -ENOMEM;
859 }
860
861 cf_port = kzalloc(sizeof(*cf_port), GFP_KERNEL);
862 if (!cf_port)
863 return -ENOMEM;
864
865 /* allocate host */
866 host = ata_host_alloc(&pdev->dev, 1);
867 if (!host)
868 goto free_cf_port;
869
870 ap = host->ports[0];
871 ap->private_data = cf_port;
872 cf_port->ap = ap;
873 ap->ops = &octeon_cf_ops;
874 ap->pio_mask = 0x7f; /* Support PIO 0-6 */
875 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY
876 | ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING;
877
878 base = cs0 + ocd->base_region_bias;
879 if (!ocd->is16bit) {
880 ap->ioaddr.cmd_addr = base;
881 ata_sff_std_ports(&ap->ioaddr);
882
883 ap->ioaddr.altstatus_addr = base + 0xe;
884 ap->ioaddr.ctl_addr = base + 0xe;
885 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer8;
886 } else if (cs1) {
887 /* Presence of cs1 indicates True IDE mode. */
888 ap->ioaddr.cmd_addr = base + (ATA_REG_CMD << 1) + 1;
889 ap->ioaddr.data_addr = base + (ATA_REG_DATA << 1);
890 ap->ioaddr.error_addr = base + (ATA_REG_ERR << 1) + 1;
891 ap->ioaddr.feature_addr = base + (ATA_REG_FEATURE << 1) + 1;
892 ap->ioaddr.nsect_addr = base + (ATA_REG_NSECT << 1) + 1;
893 ap->ioaddr.lbal_addr = base + (ATA_REG_LBAL << 1) + 1;
894 ap->ioaddr.lbam_addr = base + (ATA_REG_LBAM << 1) + 1;
895 ap->ioaddr.lbah_addr = base + (ATA_REG_LBAH << 1) + 1;
896 ap->ioaddr.device_addr = base + (ATA_REG_DEVICE << 1) + 1;
897 ap->ioaddr.status_addr = base + (ATA_REG_STATUS << 1) + 1;
898 ap->ioaddr.command_addr = base + (ATA_REG_CMD << 1) + 1;
899 ap->ioaddr.altstatus_addr = cs1 + (6 << 1) + 1;
900 ap->ioaddr.ctl_addr = cs1 + (6 << 1) + 1;
901 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer16;
902
903 ap->mwdma_mask = 0x1f; /* Support MWDMA 0-4 */
904 irq = platform_get_irq(pdev, 0);
905 irq_handler = octeon_cf_interrupt;
906
907 /* True IDE mode needs delayed work to poll for not-busy. */
908 cf_port->wq = create_singlethread_workqueue(DRV_NAME);
909 if (!cf_port->wq)
910 goto free_cf_port;
911 INIT_DELAYED_WORK(&cf_port->delayed_finish,
912 octeon_cf_delayed_finish);
913
914 } else {
915 /* 16 bit but not True IDE */
916 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer16;
917 octeon_cf_ops.softreset = octeon_cf_softreset16;
918 octeon_cf_ops.sff_check_status = octeon_cf_check_status16;
919 octeon_cf_ops.sff_tf_read = octeon_cf_tf_read16;
920 octeon_cf_ops.sff_tf_load = octeon_cf_tf_load16;
921 octeon_cf_ops.sff_exec_command = octeon_cf_exec_command16;
922
923 ap->ioaddr.data_addr = base + ATA_REG_DATA;
924 ap->ioaddr.nsect_addr = base + ATA_REG_NSECT;
925 ap->ioaddr.lbal_addr = base + ATA_REG_LBAL;
926 ap->ioaddr.ctl_addr = base + 0xe;
927 ap->ioaddr.altstatus_addr = base + 0xe;
928 }
929
930 ata_port_desc(ap, "cmd %p ctl %p", base, ap->ioaddr.ctl_addr);
931
932
933 dev_info(&pdev->dev, "version " DRV_VERSION" %d bit%s.\n",
934 (ocd->is16bit) ? 16 : 8,
935 (cs1) ? ", True IDE" : "");
936
937
938 return ata_host_activate(host, irq, irq_handler, 0, &octeon_cf_sht);
939
940free_cf_port:
941 kfree(cf_port);
942 return -ENOMEM;
943}
944
945static struct platform_driver octeon_cf_driver = {
946 .probe = octeon_cf_probe,
947 .driver = {
948 .name = DRV_NAME,
949 .owner = THIS_MODULE,
950 },
951};
952
953static int __init octeon_cf_init(void)
954{
955 return platform_driver_register(&octeon_cf_driver);
956}
957
958
959MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
960MODULE_DESCRIPTION("low-level driver for Cavium OCTEON Compact Flash PATA");
961MODULE_LICENSE("GPL");
962MODULE_VERSION(DRV_VERSION);
963MODULE_ALIAS("platform:" DRV_NAME);
964
965module_init(octeon_cf_init);
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 1a56db92ff7a..55bc88c1707b 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1288,7 +1288,7 @@ static const struct ata_port_info sata_fsl_port_info[] = {
1288static int sata_fsl_probe(struct of_device *ofdev, 1288static int sata_fsl_probe(struct of_device *ofdev,
1289 const struct of_device_id *match) 1289 const struct of_device_id *match)
1290{ 1290{
1291 int retval = 0; 1291 int retval = -ENXIO;
1292 void __iomem *hcr_base = NULL; 1292 void __iomem *hcr_base = NULL;
1293 void __iomem *ssr_base = NULL; 1293 void __iomem *ssr_base = NULL;
1294 void __iomem *csr_base = NULL; 1294 void __iomem *csr_base = NULL;
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index c18935f0bda2..5c62da9cd491 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -92,6 +92,8 @@ static const struct pci_device_id svia_pci_tbl[] = {
92 { PCI_VDEVICE(VIA, 0x5372), vt6420 }, 92 { PCI_VDEVICE(VIA, 0x5372), vt6420 },
93 { PCI_VDEVICE(VIA, 0x7372), vt6420 }, 93 { PCI_VDEVICE(VIA, 0x7372), vt6420 },
94 { PCI_VDEVICE(VIA, 0x5287), vt8251 }, /* 2 sata chnls (Master/Slave) */ 94 { PCI_VDEVICE(VIA, 0x5287), vt8251 }, /* 2 sata chnls (Master/Slave) */
95 { PCI_VDEVICE(VIA, 0x9000), vt8251 },
96 { PCI_VDEVICE(VIA, 0x9040), vt8251 },
95 97
96 { } /* terminate list */ 98 { } /* terminate list */
97}; 99};
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 4b1d4ac960f1..8df436ff7068 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -156,7 +156,7 @@ static volatile int fdc_busy = -1;
156static volatile int fdc_nested; 156static volatile int fdc_nested;
157static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); 157static DECLARE_WAIT_QUEUE_HEAD(fdc_wait);
158 158
159static DECLARE_WAIT_QUEUE_HEAD(motor_wait); 159static DECLARE_COMPLETION(motor_on_completion);
160 160
161static volatile int selected = -1; /* currently selected drive */ 161static volatile int selected = -1; /* currently selected drive */
162 162
@@ -184,8 +184,7 @@ static unsigned char mfmencode[16]={
184static unsigned char mfmdecode[128]; 184static unsigned char mfmdecode[128];
185 185
186/* floppy internal millisecond timer stuff */ 186/* floppy internal millisecond timer stuff */
187static volatile int ms_busy = -1; 187static DECLARE_COMPLETION(ms_wait_completion);
188static DECLARE_WAIT_QUEUE_HEAD(ms_wait);
189#define MS_TICKS ((amiga_eclock+50)/1000) 188#define MS_TICKS ((amiga_eclock+50)/1000)
190 189
191/* 190/*
@@ -211,8 +210,7 @@ static int fd_device[4] = { 0, 0, 0, 0 };
211 210
212static irqreturn_t ms_isr(int irq, void *dummy) 211static irqreturn_t ms_isr(int irq, void *dummy)
213{ 212{
214 ms_busy = -1; 213 complete(&ms_wait_completion);
215 wake_up(&ms_wait);
216 return IRQ_HANDLED; 214 return IRQ_HANDLED;
217} 215}
218 216
@@ -220,19 +218,17 @@ static irqreturn_t ms_isr(int irq, void *dummy)
220 A more generic routine would do a schedule a la timer.device */ 218 A more generic routine would do a schedule a la timer.device */
221static void ms_delay(int ms) 219static void ms_delay(int ms)
222{ 220{
223 unsigned long flags;
224 int ticks; 221 int ticks;
222 static DEFINE_MUTEX(mutex);
223
225 if (ms > 0) { 224 if (ms > 0) {
226 local_irq_save(flags); 225 mutex_lock(&mutex);
227 while (ms_busy == 0)
228 sleep_on(&ms_wait);
229 ms_busy = 0;
230 local_irq_restore(flags);
231 ticks = MS_TICKS*ms-1; 226 ticks = MS_TICKS*ms-1;
232 ciaa.tblo=ticks%256; 227 ciaa.tblo=ticks%256;
233 ciaa.tbhi=ticks/256; 228 ciaa.tbhi=ticks/256;
234 ciaa.crb=0x19; /*count eclock, force load, one-shoot, start */ 229 ciaa.crb=0x19; /*count eclock, force load, one-shoot, start */
235 sleep_on(&ms_wait); 230 wait_for_completion(&ms_wait_completion);
231 mutex_unlock(&mutex);
236 } 232 }
237} 233}
238 234
@@ -254,8 +250,7 @@ static void get_fdc(int drive)
254 printk("get_fdc: drive %d fdc_busy %d fdc_nested %d\n",drive,fdc_busy,fdc_nested); 250 printk("get_fdc: drive %d fdc_busy %d fdc_nested %d\n",drive,fdc_busy,fdc_nested);
255#endif 251#endif
256 local_irq_save(flags); 252 local_irq_save(flags);
257 while (!try_fdc(drive)) 253 wait_event(fdc_wait, try_fdc(drive));
258 sleep_on(&fdc_wait);
259 fdc_busy = drive; 254 fdc_busy = drive;
260 fdc_nested++; 255 fdc_nested++;
261 local_irq_restore(flags); 256 local_irq_restore(flags);
@@ -330,7 +325,7 @@ static void fd_deselect (int drive)
330static void motor_on_callback(unsigned long nr) 325static void motor_on_callback(unsigned long nr)
331{ 326{
332 if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) { 327 if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) {
333 wake_up (&motor_wait); 328 complete_all(&motor_on_completion);
334 } else { 329 } else {
335 motor_on_timer.expires = jiffies + HZ/10; 330 motor_on_timer.expires = jiffies + HZ/10;
336 add_timer(&motor_on_timer); 331 add_timer(&motor_on_timer);
@@ -347,11 +342,12 @@ static int fd_motor_on(int nr)
347 unit[nr].motor = 1; 342 unit[nr].motor = 1;
348 fd_select(nr); 343 fd_select(nr);
349 344
345 INIT_COMPLETION(motor_on_completion);
350 motor_on_timer.data = nr; 346 motor_on_timer.data = nr;
351 mod_timer(&motor_on_timer, jiffies + HZ/2); 347 mod_timer(&motor_on_timer, jiffies + HZ/2);
352 348
353 on_attempts = 10; 349 on_attempts = 10;
354 sleep_on (&motor_wait); 350 wait_for_completion(&motor_on_completion);
355 fd_deselect(nr); 351 fd_deselect(nr);
356 } 352 }
357 353
@@ -582,8 +578,7 @@ static void raw_read(int drive)
582{ 578{
583 drive&=3; 579 drive&=3;
584 get_fdc(drive); 580 get_fdc(drive);
585 while (block_flag) 581 wait_event(wait_fd_block, !block_flag);
586 sleep_on(&wait_fd_block);
587 fd_select(drive); 582 fd_select(drive);
588 /* setup adkcon bits correctly */ 583 /* setup adkcon bits correctly */
589 custom.adkcon = ADK_MSBSYNC; 584 custom.adkcon = ADK_MSBSYNC;
@@ -598,8 +593,7 @@ static void raw_read(int drive)
598 593
599 block_flag = 1; 594 block_flag = 1;
600 595
601 while (block_flag) 596 wait_event(wait_fd_block, !block_flag);
602 sleep_on (&wait_fd_block);
603 597
604 custom.dsklen = 0; 598 custom.dsklen = 0;
605 fd_deselect(drive); 599 fd_deselect(drive);
@@ -616,8 +610,7 @@ static int raw_write(int drive)
616 rel_fdc(); 610 rel_fdc();
617 return 0; 611 return 0;
618 } 612 }
619 while (block_flag) 613 wait_event(wait_fd_block, !block_flag);
620 sleep_on(&wait_fd_block);
621 fd_select(drive); 614 fd_select(drive);
622 /* clear adkcon bits */ 615 /* clear adkcon bits */
623 custom.adkcon = ADK_PRECOMP1|ADK_PRECOMP0|ADK_WORDSYNC|ADK_MSBSYNC; 616 custom.adkcon = ADK_PRECOMP1|ADK_PRECOMP0|ADK_WORDSYNC|ADK_MSBSYNC;
@@ -1294,8 +1287,7 @@ static int non_int_flush_track (unsigned long nr)
1294 writepending = 0; 1287 writepending = 0;
1295 return 0; 1288 return 0;
1296 } 1289 }
1297 while (block_flag == 2) 1290 wait_event(wait_fd_block, block_flag != 2);
1298 sleep_on (&wait_fd_block);
1299 } 1291 }
1300 else { 1292 else {
1301 local_irq_restore(flags); 1293 local_irq_restore(flags);
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7bcc1d8bc967..34f80fa6fed1 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -406,6 +406,7 @@ static int nbd_do_it(struct nbd_device *lo)
406 ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); 406 ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
407 if (ret) { 407 if (ret) {
408 printk(KERN_ERR "nbd: sysfs_create_file failed!"); 408 printk(KERN_ERR "nbd: sysfs_create_file failed!");
409 lo->pid = 0;
409 return ret; 410 return ret;
410 } 411 }
411 412
@@ -413,6 +414,7 @@ static int nbd_do_it(struct nbd_device *lo)
413 nbd_end_request(req); 414 nbd_end_request(req);
414 415
415 sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); 416 sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
417 lo->pid = 0;
416 return 0; 418 return 0;
417} 419}
418 420
@@ -648,6 +650,8 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
648 set_capacity(lo->disk, lo->bytesize >> 9); 650 set_capacity(lo->disk, lo->bytesize >> 9);
649 return 0; 651 return 0;
650 case NBD_DO_IT: 652 case NBD_DO_IT:
653 if (lo->pid)
654 return -EBUSY;
651 if (!lo->file) 655 if (!lo->file)
652 return -EINVAL; 656 return -EINVAL;
653 thread = kthread_create(nbd_thread, lo, lo->disk->disk_name); 657 thread = kthread_create(nbd_thread, lo, lo->disk->disk_name);
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index 936466f62afd..bccc42bb9212 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -141,7 +141,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
141 141
142 start_sector = req->sector * priv->blocking_factor; 142 start_sector = req->sector * priv->blocking_factor;
143 sectors = req->nr_sectors * priv->blocking_factor; 143 sectors = req->nr_sectors * priv->blocking_factor;
144 dev_dbg(&dev->sbd.core, "%s:%u: %s %lu sectors starting at %lu\n", 144 dev_dbg(&dev->sbd.core, "%s:%u: %s %llu sectors starting at %llu\n",
145 __func__, __LINE__, op, sectors, start_sector); 145 __func__, __LINE__, op, sectors, start_sector);
146 146
147 if (write) { 147 if (write) {
@@ -178,7 +178,7 @@ static int ps3disk_submit_flush_request(struct ps3_storage_device *dev,
178 LV1_STORAGE_ATA_HDDOUT, 0, 0, 0, 178 LV1_STORAGE_ATA_HDDOUT, 0, 0, 0,
179 0, &dev->tag); 179 0, &dev->tag);
180 if (res) { 180 if (res) {
181 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%lx\n", 181 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%llx\n",
182 __func__, __LINE__, res); 182 __func__, __LINE__, res);
183 end_request(req, 0); 183 end_request(req, 0);
184 return 0; 184 return 0;
@@ -238,11 +238,11 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
238 238
239 if (tag != dev->tag) 239 if (tag != dev->tag)
240 dev_err(&dev->sbd.core, 240 dev_err(&dev->sbd.core,
241 "%s:%u: tag mismatch, got %lx, expected %lx\n", 241 "%s:%u: tag mismatch, got %llx, expected %llx\n",
242 __func__, __LINE__, tag, dev->tag); 242 __func__, __LINE__, tag, dev->tag);
243 243
244 if (res) { 244 if (res) {
245 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n", 245 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%llx\n",
246 __func__, __LINE__, res, status); 246 __func__, __LINE__, res, status);
247 return IRQ_HANDLED; 247 return IRQ_HANDLED;
248 } 248 }
@@ -269,7 +269,7 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
269 op = read ? "read" : "write"; 269 op = read ? "read" : "write";
270 } 270 }
271 if (status) { 271 if (status) {
272 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, 272 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%llx\n", __func__,
273 __LINE__, op, status); 273 __LINE__, op, status);
274 error = -EIO; 274 error = -EIO;
275 } else { 275 } else {
@@ -297,7 +297,7 @@ static int ps3disk_sync_cache(struct ps3_storage_device *dev)
297 297
298 res = ps3stor_send_command(dev, LV1_STORAGE_ATA_HDDOUT, 0, 0, 0, 0); 298 res = ps3stor_send_command(dev, LV1_STORAGE_ATA_HDDOUT, 0, 0, 0, 0);
299 if (res) { 299 if (res) {
300 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%lx\n", 300 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%llx\n",
301 __func__, __LINE__, res); 301 __func__, __LINE__, res);
302 return -EIO; 302 return -EIO;
303 } 303 }
@@ -388,7 +388,7 @@ static int ps3disk_identify(struct ps3_storage_device *dev)
388 sizeof(ata_cmnd), ata_cmnd.buffer, 388 sizeof(ata_cmnd), ata_cmnd.buffer,
389 ata_cmnd.arglen); 389 ata_cmnd.arglen);
390 if (res) { 390 if (res) {
391 dev_err(&dev->sbd.core, "%s:%u: identify disk failed 0x%lx\n", 391 dev_err(&dev->sbd.core, "%s:%u: identify disk failed 0x%llx\n",
392 __func__, __LINE__, res); 392 __func__, __LINE__, res);
393 return -EIO; 393 return -EIO;
394 } 394 }
@@ -426,7 +426,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
426 426
427 if (dev->blk_size < 512) { 427 if (dev->blk_size < 512) {
428 dev_err(&dev->sbd.core, 428 dev_err(&dev->sbd.core,
429 "%s:%u: cannot handle block size %lu\n", __func__, 429 "%s:%u: cannot handle block size %llu\n", __func__,
430 __LINE__, dev->blk_size); 430 __LINE__, dev->blk_size);
431 return -EINVAL; 431 return -EINVAL;
432 } 432 }
@@ -512,7 +512,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
512 dev->regions[dev->region_idx].size*priv->blocking_factor); 512 dev->regions[dev->region_idx].size*priv->blocking_factor);
513 513
514 dev_info(&dev->sbd.core, 514 dev_info(&dev->sbd.core,
515 "%s is a %s (%lu MiB total, %lu MiB for OtherOS)\n", 515 "%s is a %s (%llu MiB total, %lu MiB for OtherOS)\n",
516 gendisk->disk_name, priv->model, priv->raw_capacity >> 11, 516 gendisk->disk_name, priv->model, priv->raw_capacity >> 11,
517 get_capacity(gendisk) >> 11); 517 get_capacity(gendisk) >> 11);
518 518
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 29e1dfafb7c6..381d686fc1a3 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1206,6 +1206,7 @@ static struct of_device_id ace_of_match[] __devinitdata = {
1206 { .compatible = "xlnx,opb-sysace-1.00.b", }, 1206 { .compatible = "xlnx,opb-sysace-1.00.b", },
1207 { .compatible = "xlnx,opb-sysace-1.00.c", }, 1207 { .compatible = "xlnx,opb-sysace-1.00.c", },
1208 { .compatible = "xlnx,xps-sysace-1.00.a", }, 1208 { .compatible = "xlnx,xps-sysace-1.00.a", },
1209 { .compatible = "xlnx,sysace", },
1209 {}, 1210 {},
1210}; 1211};
1211MODULE_DEVICE_TABLE(of, ace_of_match); 1212MODULE_DEVICE_TABLE(of, ace_of_match);
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 4e0cfdeab146..a58869ea8513 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -1963,6 +1963,7 @@ static int __init rs_init(void)
1963{ 1963{
1964 unsigned long flags; 1964 unsigned long flags;
1965 struct serial_state * state; 1965 struct serial_state * state;
1966 int error;
1966 1967
1967 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_SERIAL)) 1968 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_SERIAL))
1968 return -ENODEV; 1969 return -ENODEV;
@@ -1975,8 +1976,11 @@ static int __init rs_init(void)
1975 * We request SERDAT and SERPER only, because the serial registers are 1976 * We request SERDAT and SERPER only, because the serial registers are
1976 * too spreaded over the custom register space 1977 * too spreaded over the custom register space
1977 */ 1978 */
1978 if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4, "amiserial [Paula]")) 1979 if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4,
1979 return -EBUSY; 1980 "amiserial [Paula]")) {
1981 error = -EBUSY;
1982 goto fail_put_tty_driver;
1983 }
1980 1984
1981 IRQ_ports = NULL; 1985 IRQ_ports = NULL;
1982 1986
@@ -1997,8 +2001,9 @@ static int __init rs_init(void)
1997 serial_driver->flags = TTY_DRIVER_REAL_RAW; 2001 serial_driver->flags = TTY_DRIVER_REAL_RAW;
1998 tty_set_operations(serial_driver, &serial_ops); 2002 tty_set_operations(serial_driver, &serial_ops);
1999 2003
2000 if (tty_register_driver(serial_driver)) 2004 error = tty_register_driver(serial_driver);
2001 panic("Couldn't register serial driver\n"); 2005 if (error)
2006 goto fail_release_mem_region;
2002 2007
2003 state = rs_table; 2008 state = rs_table;
2004 state->magic = SSTATE_MAGIC; 2009 state->magic = SSTATE_MAGIC;
@@ -2024,8 +2029,14 @@ static int __init rs_init(void)
2024 local_irq_save(flags); 2029 local_irq_save(flags);
2025 2030
2026 /* set ISRs, and then disable the rx interrupts */ 2031 /* set ISRs, and then disable the rx interrupts */
2027 request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state); 2032 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state);
2028 request_irq(IRQ_AMIGA_RBF, ser_rx_int, IRQF_DISABLED, "serial RX", state); 2033 if (error)
2034 goto fail_unregister;
2035
2036 error = request_irq(IRQ_AMIGA_RBF, ser_rx_int, IRQF_DISABLED,
2037 "serial RX", state);
2038 if (error)
2039 goto fail_free_irq;
2029 2040
2030 /* turn off Rx and Tx interrupts */ 2041 /* turn off Rx and Tx interrupts */
2031 custom.intena = IF_RBF | IF_TBE; 2042 custom.intena = IF_RBF | IF_TBE;
@@ -2045,6 +2056,16 @@ static int __init rs_init(void)
2045 ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */ 2056 ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */
2046 2057
2047 return 0; 2058 return 0;
2059
2060fail_free_irq:
2061 free_irq(IRQ_AMIGA_TBE, state);
2062fail_unregister:
2063 tty_unregister_driver(serial_driver);
2064fail_release_mem_region:
2065 release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
2066fail_put_tty_driver:
2067 put_tty_driver(serial_driver);
2068 return error;
2048} 2069}
2049 2070
2050static __exit void rs_exit(void) 2071static __exit void rs_exit(void)
@@ -2064,6 +2085,9 @@ static __exit void rs_exit(void)
2064 kfree(info); 2085 kfree(info);
2065 } 2086 }
2066 2087
2088 free_irq(IRQ_AMIGA_TBE, rs_table);
2089 free_irq(IRQ_AMIGA_RBF, rs_table);
2090
2067 release_mem_region(CUSTOM_PHYSADDR+0x30, 4); 2091 release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
2068} 2092}
2069 2093
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index 977dfb1096a0..f6094ae0ef33 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -103,7 +103,7 @@ static ssize_t
103bsr_len_show(struct device *dev, struct device_attribute *attr, char *buf) 103bsr_len_show(struct device *dev, struct device_attribute *attr, char *buf)
104{ 104{
105 struct bsr_dev *bsr_dev = dev_get_drvdata(dev); 105 struct bsr_dev *bsr_dev = dev_get_drvdata(dev);
106 return sprintf(buf, "%lu\n", bsr_dev->bsr_len); 106 return sprintf(buf, "%llu\n", bsr_dev->bsr_len);
107} 107}
108 108
109static struct device_attribute bsr_dev_attrs[] = { 109static struct device_attribute bsr_dev_attrs[] = {
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 5a8a4c28c867..94e7e3c8c05a 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -318,7 +318,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
318 } /* else count == 0 */ 318 } /* else count == 0 */
319 319
320 tty->driver_data = hp; 320 tty->driver_data = hp;
321 tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */
322 321
323 hp->tty = tty; 322 hp->tty = tty;
324 323
@@ -764,13 +763,11 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int data,
764 return ERR_PTR(err); 763 return ERR_PTR(err);
765 } 764 }
766 765
767 hp = kmalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, 766 hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size,
768 GFP_KERNEL); 767 GFP_KERNEL);
769 if (!hp) 768 if (!hp)
770 return ERR_PTR(-ENOMEM); 769 return ERR_PTR(-ENOMEM);
771 770
772 memset(hp, 0x00, sizeof(*hp));
773
774 hp->vtermno = vtermno; 771 hp->vtermno = vtermno;
775 hp->data = data; 772 hp->data = data;
776 hp->ops = ops; 773 hp->ops = ops;
@@ -876,8 +873,11 @@ static int hvc_init(void)
876 goto stop_thread; 873 goto stop_thread;
877 } 874 }
878 875
879 /* FIXME: This mb() seems completely random. Remove it. */ 876 /*
880 mb(); 877 * Make sure tty is fully registered before allowing it to be
878 * found by hvc_console_device.
879 */
880 smp_mb();
881 hvc_driver = drv; 881 hvc_driver = drv;
882 return 0; 882 return 0;
883 883
diff --git a/drivers/char/hvc_irq.c b/drivers/char/hvc_irq.c
index d09e5688d449..2623e177e8d6 100644
--- a/drivers/char/hvc_irq.c
+++ b/drivers/char/hvc_irq.c
@@ -37,7 +37,7 @@ int notifier_add_irq(struct hvc_struct *hp, int irq)
37 37
38void notifier_del_irq(struct hvc_struct *hp, int irq) 38void notifier_del_irq(struct hvc_struct *hp, int irq)
39{ 39{
40 if (!irq) 40 if (!hp->irq_requested)
41 return; 41 return;
42 free_irq(irq, hp); 42 free_irq(irq, hp);
43 hp->irq_requested = 0; 43 hp->irq_requested = 0;
diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
index 79b6f461be75..afbe45676d71 100644
--- a/drivers/char/ps3flash.c
+++ b/drivers/char/ps3flash.c
@@ -44,7 +44,7 @@ static ssize_t ps3flash_read_write_sectors(struct ps3_storage_device *dev,
44 u64 res = ps3stor_read_write_sectors(dev, lpar, start_sector, sectors, 44 u64 res = ps3stor_read_write_sectors(dev, lpar, start_sector, sectors,
45 write); 45 write);
46 if (res) { 46 if (res) {
47 dev_err(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, 47 dev_err(&dev->sbd.core, "%s:%u: %s failed 0x%llx\n", __func__,
48 __LINE__, write ? "write" : "read", res); 48 __LINE__, write ? "write" : "read", res);
49 return -EIO; 49 return -EIO;
50 } 50 }
@@ -59,7 +59,7 @@ static ssize_t ps3flash_read_sectors(struct ps3_storage_device *dev,
59 59
60 max_sectors = dev->bounce_size / dev->blk_size; 60 max_sectors = dev->bounce_size / dev->blk_size;
61 if (sectors > max_sectors) { 61 if (sectors > max_sectors) {
62 dev_dbg(&dev->sbd.core, "%s:%u Limiting sectors to %lu\n", 62 dev_dbg(&dev->sbd.core, "%s:%u Limiting sectors to %llu\n",
63 __func__, __LINE__, max_sectors); 63 __func__, __LINE__, max_sectors);
64 sectors = max_sectors; 64 sectors = max_sectors;
65 } 65 }
@@ -144,7 +144,7 @@ static ssize_t ps3flash_read(struct file *file, char __user *buf, size_t count,
144 goto fail; 144 goto fail;
145 } 145 }
146 146
147 n = min(remaining, sectors_read*dev->blk_size-offset); 147 n = min_t(u64, remaining, sectors_read*dev->blk_size-offset);
148 dev_dbg(&dev->sbd.core, 148 dev_dbg(&dev->sbd.core,
149 "%s:%u: copy %lu bytes from 0x%p to user 0x%p\n", 149 "%s:%u: copy %lu bytes from 0x%p to user 0x%p\n",
150 __func__, __LINE__, n, dev->bounce_buf+offset, buf); 150 __func__, __LINE__, n, dev->bounce_buf+offset, buf);
@@ -225,7 +225,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
225 if (end_read_sector >= start_read_sector) { 225 if (end_read_sector >= start_read_sector) {
226 /* Merge head and tail */ 226 /* Merge head and tail */
227 dev_dbg(&dev->sbd.core, 227 dev_dbg(&dev->sbd.core,
228 "Merged head and tail: %lu sectors at %lu\n", 228 "Merged head and tail: %llu sectors at %llu\n",
229 chunk_sectors, start_write_sector); 229 chunk_sectors, start_write_sector);
230 res = ps3flash_read_sectors(dev, start_write_sector, 230 res = ps3flash_read_sectors(dev, start_write_sector,
231 chunk_sectors, 0); 231 chunk_sectors, 0);
@@ -235,7 +235,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
235 if (head) { 235 if (head) {
236 /* Read head */ 236 /* Read head */
237 dev_dbg(&dev->sbd.core, 237 dev_dbg(&dev->sbd.core,
238 "head: %lu sectors at %lu\n", head, 238 "head: %llu sectors at %llu\n", head,
239 start_write_sector); 239 start_write_sector);
240 res = ps3flash_read_sectors(dev, 240 res = ps3flash_read_sectors(dev,
241 start_write_sector, 241 start_write_sector,
@@ -247,7 +247,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
247 start_write_sector+chunk_sectors) { 247 start_write_sector+chunk_sectors) {
248 /* Read tail */ 248 /* Read tail */
249 dev_dbg(&dev->sbd.core, 249 dev_dbg(&dev->sbd.core,
250 "tail: %lu sectors at %lu\n", tail, 250 "tail: %llu sectors at %llu\n", tail,
251 start_read_sector); 251 start_read_sector);
252 sec_off = start_read_sector-start_write_sector; 252 sec_off = start_read_sector-start_write_sector;
253 res = ps3flash_read_sectors(dev, 253 res = ps3flash_read_sectors(dev,
@@ -258,7 +258,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
258 } 258 }
259 } 259 }
260 260
261 n = min(remaining, dev->bounce_size-offset); 261 n = min_t(u64, remaining, dev->bounce_size-offset);
262 dev_dbg(&dev->sbd.core, 262 dev_dbg(&dev->sbd.core,
263 "%s:%u: copy %lu bytes from user 0x%p to 0x%p\n", 263 "%s:%u: copy %lu bytes from user 0x%p to 0x%p\n",
264 __func__, __LINE__, n, buf, dev->bounce_buf+offset); 264 __func__, __LINE__, n, buf, dev->bounce_buf+offset);
@@ -299,11 +299,11 @@ static irqreturn_t ps3flash_interrupt(int irq, void *data)
299 299
300 if (tag != dev->tag) 300 if (tag != dev->tag)
301 dev_err(&dev->sbd.core, 301 dev_err(&dev->sbd.core,
302 "%s:%u: tag mismatch, got %lx, expected %lx\n", 302 "%s:%u: tag mismatch, got %llx, expected %llx\n",
303 __func__, __LINE__, tag, dev->tag); 303 __func__, __LINE__, tag, dev->tag);
304 304
305 if (res) { 305 if (res) {
306 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n", 306 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%llx\n",
307 __func__, __LINE__, res, status); 307 __func__, __LINE__, res, status);
308 } else { 308 } else {
309 dev->lv1_status = status; 309 dev->lv1_status = status;
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 146c97613da0..31038a0052a2 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -230,9 +230,7 @@ static void pty_set_termios(struct tty_struct *tty,
230/** 230/**
231 * pty_do_resize - resize event 231 * pty_do_resize - resize event
232 * @tty: tty being resized 232 * @tty: tty being resized
233 * @real_tty: real tty (not the same as tty if using a pty/tty pair) 233 * @ws: window size being set.
234 * @rows: rows (character)
235 * @cols: cols (character)
236 * 234 *
237 * Update the termios variables and send the neccessary signals to 235 * Update the termios variables and send the neccessary signals to
238 * peform a terminal resize correctly 236 * peform a terminal resize correctly
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index 33872a219df6..33a2b531802e 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -718,6 +718,7 @@ static int __init a2232board_init(void)
718 u_char *from; 718 u_char *from;
719 volatile u_char *to; 719 volatile u_char *to;
720 volatile struct a2232memory *mem; 720 volatile struct a2232memory *mem;
721 int error, i;
721 722
722#ifdef CONFIG_SMP 723#ifdef CONFIG_SMP
723 return -ENODEV; /* This driver is not SMP aware. Is there an SMP ZorroII-bus-machine? */ 724 return -ENODEV; /* This driver is not SMP aware. Is there an SMP ZorroII-bus-machine? */
@@ -797,8 +798,15 @@ static int __init a2232board_init(void)
797 */ 798 */
798 if (a2232_init_drivers()) return -ENODEV; // maybe we should use a different -Exxx? 799 if (a2232_init_drivers()) return -ENODEV; // maybe we should use a different -Exxx?
799 800
800 request_irq(IRQ_AMIGA_VERTB, a2232_vbl_inter, 0, "A2232 serial VBL", a2232_driver_ID); 801 error = request_irq(IRQ_AMIGA_VERTB, a2232_vbl_inter, 0,
801 return 0; 802 "A2232 serial VBL", a2232_driver_ID);
803 if (error) {
804 for (i = 0; i < nr_a2232; i++)
805 zorro_release_device(zd_a2232[i]);
806 tty_unregister_driver(a2232_driver);
807 put_tty_driver(a2232_driver);
808 }
809 return error;
802} 810}
803 811
804static void __exit a2232board_exit(void) 812static void __exit a2232board_exit(void)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 53544e21f191..f329f459817c 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: synclink_gt.c,v 4.50 2007/07/25 19:29:25 paulkf Exp $
3 *
4 * Device driver for Microgate SyncLink GT serial adapters. 2 * Device driver for Microgate SyncLink GT serial adapters.
5 * 3 *
6 * written by Paul Fulghum for Microgate Corporation 4 * written by Paul Fulghum for Microgate Corporation
@@ -91,7 +89,6 @@
91 * module identification 89 * module identification
92 */ 90 */
93static char *driver_name = "SyncLink GT"; 91static char *driver_name = "SyncLink GT";
94static char *driver_version = "$Revision: 4.50 $";
95static char *tty_driver_name = "synclink_gt"; 92static char *tty_driver_name = "synclink_gt";
96static char *tty_dev_prefix = "ttySLG"; 93static char *tty_dev_prefix = "ttySLG";
97MODULE_LICENSE("GPL"); 94MODULE_LICENSE("GPL");
@@ -1309,7 +1306,7 @@ static int read_proc(char *page, char **start, off_t off, int count,
1309 off_t begin = 0; 1306 off_t begin = 0;
1310 struct slgt_info *info; 1307 struct slgt_info *info;
1311 1308
1312 len += sprintf(page, "synclink_gt driver:%s\n", driver_version); 1309 len += sprintf(page, "synclink_gt driver\n");
1313 1310
1314 info = slgt_device_list; 1311 info = slgt_device_list;
1315 while( info ) { 1312 while( info ) {
@@ -2441,7 +2438,7 @@ static void program_hw(struct slgt_info *info)
2441 info->ri_chkcount = 0; 2438 info->ri_chkcount = 0;
2442 info->dsr_chkcount = 0; 2439 info->dsr_chkcount = 0;
2443 2440
2444 slgt_irq_on(info, IRQ_DCD | IRQ_CTS | IRQ_DSR); 2441 slgt_irq_on(info, IRQ_DCD | IRQ_CTS | IRQ_DSR | IRQ_RI);
2445 get_signals(info); 2442 get_signals(info);
2446 2443
2447 if (info->netcount || 2444 if (info->netcount ||
@@ -3576,7 +3573,7 @@ static void slgt_cleanup(void)
3576 struct slgt_info *info; 3573 struct slgt_info *info;
3577 struct slgt_info *tmp; 3574 struct slgt_info *tmp;
3578 3575
3579 printk("unload %s %s\n", driver_name, driver_version); 3576 printk(KERN_INFO "unload %s\n", driver_name);
3580 3577
3581 if (serial_driver) { 3578 if (serial_driver) {
3582 for (info=slgt_device_list ; info != NULL ; info=info->next_device) 3579 for (info=slgt_device_list ; info != NULL ; info=info->next_device)
@@ -3619,7 +3616,7 @@ static int __init slgt_init(void)
3619{ 3616{
3620 int rc; 3617 int rc;
3621 3618
3622 printk("%s %s\n", driver_name, driver_version); 3619 printk(KERN_INFO "%s\n", driver_name);
3623 3620
3624 serial_driver = alloc_tty_driver(MAX_DEVICES); 3621 serial_driver = alloc_tty_driver(MAX_DEVICES);
3625 if (!serial_driver) { 3622 if (!serial_driver) {
@@ -3650,9 +3647,8 @@ static int __init slgt_init(void)
3650 goto error; 3647 goto error;
3651 } 3648 }
3652 3649
3653 printk("%s %s, tty major#%d\n", 3650 printk(KERN_INFO "%s, tty major#%d\n",
3654 driver_name, driver_version, 3651 driver_name, serial_driver->major);
3655 serial_driver->major);
3656 3652
3657 slgt_device_count = 0; 3653 slgt_device_count = 0;
3658 if ((rc = pci_register_driver(&pci_driver)) < 0) { 3654 if ((rc = pci_register_driver(&pci_driver)) < 0) {
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 985dc8f6c747..30659ce9bcf4 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -473,6 +473,12 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
473 unsigned long flags; 473 unsigned long flags;
474 474
475 spin_lock_irqsave(&sysrq_key_table_lock, flags); 475 spin_lock_irqsave(&sysrq_key_table_lock, flags);
476 /*
477 * Raise the apparent loglevel to maximum so that the sysrq header
478 * is shown to provide the user with positive feedback. We do not
479 * simply emit this at KERN_EMERG as that would change message
480 * routing in the consumers of /proc/kmsg.
481 */
476 orig_log_level = console_loglevel; 482 orig_log_level = console_loglevel;
477 console_loglevel = 7; 483 console_loglevel = 7;
478 printk(KERN_INFO "SysRq : "); 484 printk(KERN_INFO "SysRq : ");
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index a408c8e487ec..6f4c7d0a53bf 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -1057,7 +1057,7 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
1057 if (retval) 1057 if (retval)
1058 return retval; 1058 return retval;
1059 1059
1060 ld = tty_ldisc_ref(tty); 1060 ld = tty_ldisc_ref_wait(tty);
1061 switch (arg) { 1061 switch (arg) {
1062 case TCIFLUSH: 1062 case TCIFLUSH:
1063 if (ld && ld->ops->flush_buffer) 1063 if (ld && ld->ops->flush_buffer)
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index 0e8234bd0e19..994e1a58b987 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -198,6 +198,7 @@ static void scc_init_portstructs(void)
198static int mvme147_scc_init(void) 198static int mvme147_scc_init(void)
199{ 199{
200 struct scc_port *port; 200 struct scc_port *port;
201 int error;
201 202
202 printk(KERN_INFO "SCC: MVME147 Serial Driver\n"); 203 printk(KERN_INFO "SCC: MVME147 Serial Driver\n");
203 /* Init channel A */ 204 /* Init channel A */
@@ -207,14 +208,23 @@ static int mvme147_scc_init(void)
207 port->datap = port->ctrlp + 1; 208 port->datap = port->ctrlp + 1;
208 port->port_a = &scc_ports[0]; 209 port->port_a = &scc_ports[0];
209 port->port_b = &scc_ports[1]; 210 port->port_b = &scc_ports[1];
210 request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 211 error = request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
211 "SCC-A TX", port); 212 "SCC-A TX", port);
212 request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 213 if (error)
214 goto fail;
215 error = request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
213 "SCC-A status", port); 216 "SCC-A status", port);
214 request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 217 if (error)
218 goto fail_free_a_tx;
219 error = request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
215 "SCC-A RX", port); 220 "SCC-A RX", port);
216 request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 221 if (error)
217 "SCC-A special cond", port); 222 goto fail_free_a_stat;
223 error = request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int,
224 IRQF_DISABLED, "SCC-A special cond", port);
225 if (error)
226 goto fail_free_a_rx;
227
218 { 228 {
219 SCC_ACCESS_INIT(port); 229 SCC_ACCESS_INIT(port);
220 230
@@ -234,14 +244,23 @@ static int mvme147_scc_init(void)
234 port->datap = port->ctrlp + 1; 244 port->datap = port->ctrlp + 1;
235 port->port_a = &scc_ports[0]; 245 port->port_a = &scc_ports[0];
236 port->port_b = &scc_ports[1]; 246 port->port_b = &scc_ports[1];
237 request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 247 error = request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
238 "SCC-B TX", port); 248 "SCC-B TX", port);
239 request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 249 if (error)
250 goto fail_free_a_spcond;
251 error = request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
240 "SCC-B status", port); 252 "SCC-B status", port);
241 request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 253 if (error)
254 goto fail_free_b_tx;
255 error = request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
242 "SCC-B RX", port); 256 "SCC-B RX", port);
243 request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 257 if (error)
244 "SCC-B special cond", port); 258 goto fail_free_b_stat;
259 error = request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int,
260 IRQF_DISABLED, "SCC-B special cond", port);
261 if (error)
262 goto fail_free_b_rx;
263
245 { 264 {
246 SCC_ACCESS_INIT(port); 265 SCC_ACCESS_INIT(port);
247 266
@@ -257,6 +276,23 @@ static int mvme147_scc_init(void)
257 scc_init_drivers(); 276 scc_init_drivers();
258 277
259 return 0; 278 return 0;
279
280fail_free_b_rx:
281 free_irq(MVME147_IRQ_SCCB_RX, port);
282fail_free_b_stat:
283 free_irq(MVME147_IRQ_SCCB_STAT, port);
284fail_free_b_tx:
285 free_irq(MVME147_IRQ_SCCB_TX, port);
286fail_free_a_spcond:
287 free_irq(MVME147_IRQ_SCCA_SPCOND, port);
288fail_free_a_rx:
289 free_irq(MVME147_IRQ_SCCA_RX, port);
290fail_free_a_stat:
291 free_irq(MVME147_IRQ_SCCA_STAT, port);
292fail_free_a_tx:
293 free_irq(MVME147_IRQ_SCCA_TX, port);
294fail:
295 return error;
260} 296}
261#endif 297#endif
262 298
@@ -265,6 +301,7 @@ static int mvme147_scc_init(void)
265static int mvme162_scc_init(void) 301static int mvme162_scc_init(void)
266{ 302{
267 struct scc_port *port; 303 struct scc_port *port;
304 int error;
268 305
269 if (!(mvme16x_config & MVME16x_CONFIG_GOT_SCCA)) 306 if (!(mvme16x_config & MVME16x_CONFIG_GOT_SCCA))
270 return (-ENODEV); 307 return (-ENODEV);
@@ -277,14 +314,23 @@ static int mvme162_scc_init(void)
277 port->datap = port->ctrlp + 2; 314 port->datap = port->ctrlp + 2;
278 port->port_a = &scc_ports[0]; 315 port->port_a = &scc_ports[0];
279 port->port_b = &scc_ports[1]; 316 port->port_b = &scc_ports[1];
280 request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 317 error = request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
281 "SCC-A TX", port); 318 "SCC-A TX", port);
282 request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 319 if (error)
320 goto fail;
321 error = request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
283 "SCC-A status", port); 322 "SCC-A status", port);
284 request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 323 if (error)
324 goto fail_free_a_tx;
325 error = request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
285 "SCC-A RX", port); 326 "SCC-A RX", port);
286 request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 327 if (error)
287 "SCC-A special cond", port); 328 goto fail_free_a_stat;
329 error = request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int,
330 IRQF_DISABLED, "SCC-A special cond", port);
331 if (error)
332 goto fail_free_a_rx;
333
288 { 334 {
289 SCC_ACCESS_INIT(port); 335 SCC_ACCESS_INIT(port);
290 336
@@ -304,14 +350,22 @@ static int mvme162_scc_init(void)
304 port->datap = port->ctrlp + 2; 350 port->datap = port->ctrlp + 2;
305 port->port_a = &scc_ports[0]; 351 port->port_a = &scc_ports[0];
306 port->port_b = &scc_ports[1]; 352 port->port_b = &scc_ports[1];
307 request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 353 error = request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
308 "SCC-B TX", port); 354 "SCC-B TX", port);
309 request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 355 if (error)
356 goto fail_free_a_spcond;
357 error = request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
310 "SCC-B status", port); 358 "SCC-B status", port);
311 request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 359 if (error)
360 goto fail_free_b_tx;
361 error = request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
312 "SCC-B RX", port); 362 "SCC-B RX", port);
313 request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 363 if (error)
314 "SCC-B special cond", port); 364 goto fail_free_b_stat;
365 error = request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int,
366 IRQF_DISABLED, "SCC-B special cond", port);
367 if (error)
368 goto fail_free_b_rx;
315 369
316 { 370 {
317 SCC_ACCESS_INIT(port); /* Either channel will do */ 371 SCC_ACCESS_INIT(port); /* Either channel will do */
@@ -328,6 +382,23 @@ static int mvme162_scc_init(void)
328 scc_init_drivers(); 382 scc_init_drivers();
329 383
330 return 0; 384 return 0;
385
386fail_free_b_rx:
387 free_irq(MVME162_IRQ_SCCB_RX, port);
388fail_free_b_stat:
389 free_irq(MVME162_IRQ_SCCB_STAT, port);
390fail_free_b_tx:
391 free_irq(MVME162_IRQ_SCCB_TX, port);
392fail_free_a_spcond:
393 free_irq(MVME162_IRQ_SCCA_SPCOND, port);
394fail_free_a_rx:
395 free_irq(MVME162_IRQ_SCCA_RX, port);
396fail_free_a_stat:
397 free_irq(MVME162_IRQ_SCCA_STAT, port);
398fail_free_a_tx:
399 free_irq(MVME162_IRQ_SCCA_TX, port);
400fail:
401 return error;
331} 402}
332#endif 403#endif
333 404
@@ -336,6 +407,7 @@ static int mvme162_scc_init(void)
336static int bvme6000_scc_init(void) 407static int bvme6000_scc_init(void)
337{ 408{
338 struct scc_port *port; 409 struct scc_port *port;
410 int error;
339 411
340 printk(KERN_INFO "SCC: BVME6000 Serial Driver\n"); 412 printk(KERN_INFO "SCC: BVME6000 Serial Driver\n");
341 /* Init channel A */ 413 /* Init channel A */
@@ -345,14 +417,23 @@ static int bvme6000_scc_init(void)
345 port->datap = port->ctrlp + 4; 417 port->datap = port->ctrlp + 4;
346 port->port_a = &scc_ports[0]; 418 port->port_a = &scc_ports[0];
347 port->port_b = &scc_ports[1]; 419 port->port_b = &scc_ports[1];
348 request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 420 error = request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
349 "SCC-A TX", port); 421 "SCC-A TX", port);
350 request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 422 if (error)
423 goto fail;
424 error = request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
351 "SCC-A status", port); 425 "SCC-A status", port);
352 request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 426 if (error)
427 goto fail_free_a_tx;
428 error = request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
353 "SCC-A RX", port); 429 "SCC-A RX", port);
354 request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 430 if (error)
355 "SCC-A special cond", port); 431 goto fail_free_a_stat;
432 error = request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int,
433 IRQF_DISABLED, "SCC-A special cond", port);
434 if (error)
435 goto fail_free_a_rx;
436
356 { 437 {
357 SCC_ACCESS_INIT(port); 438 SCC_ACCESS_INIT(port);
358 439
@@ -372,14 +453,22 @@ static int bvme6000_scc_init(void)
372 port->datap = port->ctrlp + 4; 453 port->datap = port->ctrlp + 4;
373 port->port_a = &scc_ports[0]; 454 port->port_a = &scc_ports[0];
374 port->port_b = &scc_ports[1]; 455 port->port_b = &scc_ports[1];
375 request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 456 error = request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
376 "SCC-B TX", port); 457 "SCC-B TX", port);
377 request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 458 if (error)
459 goto fail_free_a_spcond;
460 error = request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
378 "SCC-B status", port); 461 "SCC-B status", port);
379 request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 462 if (error)
463 goto fail_free_b_tx;
464 error = request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
380 "SCC-B RX", port); 465 "SCC-B RX", port);
381 request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 466 if (error)
382 "SCC-B special cond", port); 467 goto fail_free_b_stat;
468 error = request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int,
469 IRQF_DISABLED, "SCC-B special cond", port);
470 if (error)
471 goto fail_free_b_rx;
383 472
384 { 473 {
385 SCC_ACCESS_INIT(port); /* Either channel will do */ 474 SCC_ACCESS_INIT(port); /* Either channel will do */
@@ -393,6 +482,23 @@ static int bvme6000_scc_init(void)
393 scc_init_drivers(); 482 scc_init_drivers();
394 483
395 return 0; 484 return 0;
485
486fail:
487 free_irq(BVME_IRQ_SCCA_STAT, port);
488fail_free_a_tx:
489 free_irq(BVME_IRQ_SCCA_RX, port);
490fail_free_a_stat:
491 free_irq(BVME_IRQ_SCCA_SPCOND, port);
492fail_free_a_rx:
493 free_irq(BVME_IRQ_SCCB_TX, port);
494fail_free_a_spcond:
495 free_irq(BVME_IRQ_SCCB_STAT, port);
496fail_free_b_tx:
497 free_irq(BVME_IRQ_SCCB_RX, port);
498fail_free_b_stat:
499 free_irq(BVME_IRQ_SCCB_SPCOND, port);
500fail_free_b_rx:
501 return error;
396} 502}
397#endif 503#endif
398 504
diff --git a/drivers/dio/dio-sysfs.c b/drivers/dio/dio-sysfs.c
index f46463038847..ee1a3b59bd4e 100644
--- a/drivers/dio/dio-sysfs.c
+++ b/drivers/dio/dio-sysfs.c
@@ -58,20 +58,25 @@ static ssize_t dio_show_resource(struct device *dev, struct device_attribute *at
58 struct dio_dev *d = to_dio_dev(dev); 58 struct dio_dev *d = to_dio_dev(dev);
59 59
60 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n", 60 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
61 dio_resource_start(d), dio_resource_end(d), 61 (unsigned long)dio_resource_start(d),
62 (unsigned long)dio_resource_end(d),
62 dio_resource_flags(d)); 63 dio_resource_flags(d));
63} 64}
64static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL); 65static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL);
65 66
66void dio_create_sysfs_dev_files(struct dio_dev *d) 67int dio_create_sysfs_dev_files(struct dio_dev *d)
67{ 68{
68 struct device *dev = &d->dev; 69 struct device *dev = &d->dev;
70 int error;
69 71
70 /* current configuration's attributes */ 72 /* current configuration's attributes */
71 device_create_file(dev, &dev_attr_id); 73 if ((error = device_create_file(dev, &dev_attr_id)) ||
72 device_create_file(dev, &dev_attr_ipl); 74 (error = device_create_file(dev, &dev_attr_ipl)) ||
73 device_create_file(dev, &dev_attr_secid); 75 (error = device_create_file(dev, &dev_attr_secid)) ||
74 device_create_file(dev, &dev_attr_name); 76 (error = device_create_file(dev, &dev_attr_name)) ||
75 device_create_file(dev, &dev_attr_resource); 77 (error = device_create_file(dev, &dev_attr_resource)))
78 return error;
79
80 return 0;
76} 81}
77 82
diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
index 07f274f853d9..10c3c498358c 100644
--- a/drivers/dio/dio.c
+++ b/drivers/dio/dio.c
@@ -173,6 +173,7 @@ static int __init dio_init(void)
173 mm_segment_t fs; 173 mm_segment_t fs;
174 int i; 174 int i;
175 struct dio_dev *dev; 175 struct dio_dev *dev;
176 int error;
176 177
177 if (!MACH_IS_HP300) 178 if (!MACH_IS_HP300)
178 return 0; 179 return 0;
@@ -182,7 +183,11 @@ static int __init dio_init(void)
182 /* Initialize the DIO bus */ 183 /* Initialize the DIO bus */
183 INIT_LIST_HEAD(&dio_bus.devices); 184 INIT_LIST_HEAD(&dio_bus.devices);
184 strcpy(dio_bus.dev.bus_id, "dio"); 185 strcpy(dio_bus.dev.bus_id, "dio");
185 device_register(&dio_bus.dev); 186 error = device_register(&dio_bus.dev);
187 if (error) {
188 pr_err("DIO: Error registering dio_bus\n");
189 return error;
190 }
186 191
187 /* Request all resources */ 192 /* Request all resources */
188 dio_bus.num_resources = (hp300_model == HP_320 ? 1 : 2); 193 dio_bus.num_resources = (hp300_model == HP_320 ? 1 : 2);
@@ -252,8 +257,15 @@ static int __init dio_init(void)
252 257
253 if (scode >= DIOII_SCBASE) 258 if (scode >= DIOII_SCBASE)
254 iounmap(va); 259 iounmap(va);
255 device_register(&dev->dev); 260 error = device_register(&dev->dev);
256 dio_create_sysfs_dev_files(dev); 261 if (error) {
262 pr_err("DIO: Error registering device %s\n",
263 dev->name);
264 continue;
265 }
266 error = dio_create_sysfs_dev_files(dev);
267 if (error)
268 dev_err(&dev->dev, "Error creating sysfs files\n");
257 } 269 }
258 return 0; 270 return 0;
259} 271}
diff --git a/drivers/gpio/max7301.c b/drivers/gpio/max7301.c
index 8b24d784db93..3e7f4e06386e 100644
--- a/drivers/gpio/max7301.c
+++ b/drivers/gpio/max7301.c
@@ -217,8 +217,10 @@ static int __devinit max7301_probe(struct spi_device *spi)
217 int i, ret; 217 int i, ret;
218 218
219 pdata = spi->dev.platform_data; 219 pdata = spi->dev.platform_data;
220 if (!pdata || !pdata->base) 220 if (!pdata || !pdata->base) {
221 return -ENODEV; 221 dev_dbg(&spi->dev, "incorrect or missing platform data\n");
222 return -EINVAL;
223 }
222 224
223 /* 225 /*
224 * bits_per_word cannot be configured in platform data 226 * bits_per_word cannot be configured in platform data
diff --git a/drivers/gpio/max732x.c b/drivers/gpio/max732x.c
index 55ae9a41897a..f7868243af89 100644
--- a/drivers/gpio/max732x.c
+++ b/drivers/gpio/max732x.c
@@ -267,8 +267,10 @@ static int __devinit max732x_probe(struct i2c_client *client,
267 int ret, nr_port; 267 int ret, nr_port;
268 268
269 pdata = client->dev.platform_data; 269 pdata = client->dev.platform_data;
270 if (pdata == NULL) 270 if (pdata == NULL) {
271 return -ENODEV; 271 dev_dbg(&client->dev, "no platform data\n");
272 return -EINVAL;
273 }
272 274
273 chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL); 275 chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL);
274 if (chip == NULL) 276 if (chip == NULL)
diff --git a/drivers/gpio/mcp23s08.c b/drivers/gpio/mcp23s08.c
index 89c1d222e9d1..f6fae0e50e65 100644
--- a/drivers/gpio/mcp23s08.c
+++ b/drivers/gpio/mcp23s08.c
@@ -310,8 +310,10 @@ static int mcp23s08_probe(struct spi_device *spi)
310 unsigned base; 310 unsigned base;
311 311
312 pdata = spi->dev.platform_data; 312 pdata = spi->dev.platform_data;
313 if (!pdata || !gpio_is_valid(pdata->base)) 313 if (!pdata || !gpio_is_valid(pdata->base)) {
314 return -ENODEV; 314 dev_dbg(&spi->dev, "invalid or missing platform data\n");
315 return -EINVAL;
316 }
315 317
316 for (addr = 0; addr < 4; addr++) { 318 for (addr = 0; addr < 4; addr++) {
317 if (!pdata->chip[addr].is_present) 319 if (!pdata->chip[addr].is_present)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 37f35388a2ae..8dc0164bd51e 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -202,8 +202,10 @@ static int __devinit pca953x_probe(struct i2c_client *client,
202 int ret; 202 int ret;
203 203
204 pdata = client->dev.platform_data; 204 pdata = client->dev.platform_data;
205 if (pdata == NULL) 205 if (pdata == NULL) {
206 return -ENODEV; 206 dev_dbg(&client->dev, "no platform data\n");
207 return -EINVAL;
208 }
207 209
208 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL); 210 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
209 if (chip == NULL) 211 if (chip == NULL)
diff --git a/drivers/gpio/pcf857x.c b/drivers/gpio/pcf857x.c
index 4bc2070dd4a1..9525724be731 100644
--- a/drivers/gpio/pcf857x.c
+++ b/drivers/gpio/pcf857x.c
@@ -188,8 +188,10 @@ static int pcf857x_probe(struct i2c_client *client,
188 int status; 188 int status;
189 189
190 pdata = client->dev.platform_data; 190 pdata = client->dev.platform_data;
191 if (!pdata) 191 if (!pdata) {
192 return -ENODEV; 192 dev_dbg(&client->dev, "no platform data\n");
193 return -EINVAL;
194 }
193 195
194 /* Allocate, initialize, and register this gpio_chip. */ 196 /* Allocate, initialize, and register this gpio_chip. */
195 gpio = kzalloc(sizeof *gpio, GFP_KERNEL); 197 gpio = kzalloc(sizeof *gpio, GFP_KERNEL);
@@ -248,8 +250,10 @@ static int pcf857x_probe(struct i2c_client *client,
248 else 250 else
249 status = i2c_read_le16(client); 251 status = i2c_read_le16(client);
250 252
251 } else 253 } else {
252 status = -ENODEV; 254 dev_dbg(&client->dev, "unsupported number of gpios\n");
255 status = -EINVAL;
256 }
253 257
254 if (status < 0) 258 if (status < 0)
255 goto fail; 259 goto fail;
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index d8a982b71296..964c5eb1fada 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -36,7 +36,7 @@
36/* 36/*
37 * Detailed mode info for 800x600@60Hz 37 * Detailed mode info for 800x600@60Hz
38 */ 38 */
39static struct drm_display_mode std_mode[] = { 39static struct drm_display_mode std_modes[] = {
40 { DRM_MODE("800x600", DRM_MODE_TYPE_DEFAULT, 40000, 800, 840, 40 { DRM_MODE("800x600", DRM_MODE_TYPE_DEFAULT, 40000, 800, 840,
41 968, 1056, 0, 600, 601, 605, 628, 0, 41 968, 1056, 0, 600, 601, 605, 628, 0,
42 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, 42 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
@@ -60,15 +60,18 @@ static struct drm_display_mode std_mode[] = {
60 * changes have occurred. 60 * changes have occurred.
61 * 61 *
62 * FIXME: take into account monitor limits 62 * FIXME: take into account monitor limits
63 *
64 * RETURNS:
65 * Number of modes found on @connector.
63 */ 66 */
64void drm_helper_probe_single_connector_modes(struct drm_connector *connector, 67int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
65 uint32_t maxX, uint32_t maxY) 68 uint32_t maxX, uint32_t maxY)
66{ 69{
67 struct drm_device *dev = connector->dev; 70 struct drm_device *dev = connector->dev;
68 struct drm_display_mode *mode, *t; 71 struct drm_display_mode *mode, *t;
69 struct drm_connector_helper_funcs *connector_funcs = 72 struct drm_connector_helper_funcs *connector_funcs =
70 connector->helper_private; 73 connector->helper_private;
71 int ret; 74 int count = 0;
72 75
73 DRM_DEBUG("%s\n", drm_get_connector_name(connector)); 76 DRM_DEBUG("%s\n", drm_get_connector_name(connector));
74 /* set all modes to the unverified state */ 77 /* set all modes to the unverified state */
@@ -81,14 +84,14 @@ void drm_helper_probe_single_connector_modes(struct drm_connector *connector,
81 DRM_DEBUG("%s is disconnected\n", 84 DRM_DEBUG("%s is disconnected\n",
82 drm_get_connector_name(connector)); 85 drm_get_connector_name(connector));
83 /* TODO set EDID to NULL */ 86 /* TODO set EDID to NULL */
84 return; 87 return 0;
85 } 88 }
86 89
87 ret = (*connector_funcs->get_modes)(connector); 90 count = (*connector_funcs->get_modes)(connector);
91 if (!count)
92 return 0;
88 93
89 if (ret) { 94 drm_mode_connector_list_update(connector);
90 drm_mode_connector_list_update(connector);
91 }
92 95
93 if (maxX && maxY) 96 if (maxX && maxY)
94 drm_mode_validate_size(dev, &connector->modes, maxX, 97 drm_mode_validate_size(dev, &connector->modes, maxX,
@@ -102,25 +105,8 @@ void drm_helper_probe_single_connector_modes(struct drm_connector *connector,
102 105
103 drm_mode_prune_invalid(dev, &connector->modes, true); 106 drm_mode_prune_invalid(dev, &connector->modes, true);
104 107
105 if (list_empty(&connector->modes)) { 108 if (list_empty(&connector->modes))
106 struct drm_display_mode *stdmode; 109 return 0;
107
108 DRM_DEBUG("No valid modes on %s\n",
109 drm_get_connector_name(connector));
110
111 /* Should we do this here ???
112 * When no valid EDID modes are available we end up
113 * here and bailed in the past, now we add a standard
114 * 640x480@60Hz mode and carry on.
115 */
116 stdmode = drm_mode_duplicate(dev, &std_mode[0]);
117 drm_mode_probed_add(connector, stdmode);
118 drm_mode_list_concat(&connector->probed_modes,
119 &connector->modes);
120
121 DRM_DEBUG("Adding standard 640x480 @ 60Hz to %s\n",
122 drm_get_connector_name(connector));
123 }
124 110
125 drm_mode_sort(&connector->modes); 111 drm_mode_sort(&connector->modes);
126 112
@@ -131,20 +117,58 @@ void drm_helper_probe_single_connector_modes(struct drm_connector *connector,
131 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); 117 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
132 drm_mode_debug_printmodeline(mode); 118 drm_mode_debug_printmodeline(mode);
133 } 119 }
120
121 return count;
134} 122}
135EXPORT_SYMBOL(drm_helper_probe_single_connector_modes); 123EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);
136 124
137void drm_helper_probe_connector_modes(struct drm_device *dev, uint32_t maxX, 125int drm_helper_probe_connector_modes(struct drm_device *dev, uint32_t maxX,
138 uint32_t maxY) 126 uint32_t maxY)
139{ 127{
140 struct drm_connector *connector; 128 struct drm_connector *connector;
129 int count = 0;
141 130
142 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 131 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
143 drm_helper_probe_single_connector_modes(connector, maxX, maxY); 132 count += drm_helper_probe_single_connector_modes(connector,
133 maxX, maxY);
144 } 134 }
135
136 return count;
145} 137}
146EXPORT_SYMBOL(drm_helper_probe_connector_modes); 138EXPORT_SYMBOL(drm_helper_probe_connector_modes);
147 139
140static void drm_helper_add_std_modes(struct drm_device *dev,
141 struct drm_connector *connector)
142{
143 struct drm_display_mode *mode, *t;
144 int i;
145
146 for (i = 0; i < ARRAY_SIZE(std_modes); i++) {
147 struct drm_display_mode *stdmode;
148
149 /*
150 * When no valid EDID modes are available we end up
151 * here and bailed in the past, now we add some standard
152 * modes and move on.
153 */
154 stdmode = drm_mode_duplicate(dev, &std_modes[i]);
155 drm_mode_probed_add(connector, stdmode);
156 drm_mode_list_concat(&connector->probed_modes,
157 &connector->modes);
158
159 DRM_DEBUG("Adding mode %s to %s\n", stdmode->name,
160 drm_get_connector_name(connector));
161 }
162 drm_mode_sort(&connector->modes);
163
164 DRM_DEBUG("Added std modes on %s\n", drm_get_connector_name(connector));
165 list_for_each_entry_safe(mode, t, &connector->modes, head) {
166 mode->vrefresh = drm_mode_vrefresh(mode);
167
168 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
169 drm_mode_debug_printmodeline(mode);
170 }
171}
148 172
149/** 173/**
150 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config 174 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config
@@ -237,6 +261,8 @@ static void drm_enable_connectors(struct drm_device *dev, bool *enabled)
237 261
238 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 262 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
239 enabled[i] = drm_connector_enabled(connector, true); 263 enabled[i] = drm_connector_enabled(connector, true);
264 DRM_DEBUG("connector %d enabled? %s\n", connector->base.id,
265 enabled[i] ? "yes" : "no");
240 any_enabled |= enabled[i]; 266 any_enabled |= enabled[i];
241 i++; 267 i++;
242 } 268 }
@@ -265,11 +291,17 @@ static bool drm_target_preferred(struct drm_device *dev,
265 continue; 291 continue;
266 } 292 }
267 293
294 DRM_DEBUG("looking for preferred mode on connector %d\n",
295 connector->base.id);
296
268 modes[i] = drm_has_preferred_mode(connector, width, height); 297 modes[i] = drm_has_preferred_mode(connector, width, height);
269 if (!modes[i]) { 298 /* No preferred modes, pick one off the list */
299 if (!modes[i] && !list_empty(&connector->modes)) {
270 list_for_each_entry(modes[i], &connector->modes, head) 300 list_for_each_entry(modes[i], &connector->modes, head)
271 break; 301 break;
272 } 302 }
303 DRM_DEBUG("found mode %s\n", modes[i] ? modes[i]->name :
304 "none");
273 i++; 305 i++;
274 } 306 }
275 return true; 307 return true;
@@ -369,6 +401,8 @@ static void drm_setup_crtcs(struct drm_device *dev)
369 int width, height; 401 int width, height;
370 int i, ret; 402 int i, ret;
371 403
404 DRM_DEBUG("\n");
405
372 width = dev->mode_config.max_width; 406 width = dev->mode_config.max_width;
373 height = dev->mode_config.max_height; 407 height = dev->mode_config.max_height;
374 408
@@ -390,6 +424,8 @@ static void drm_setup_crtcs(struct drm_device *dev)
390 if (!ret) 424 if (!ret)
391 DRM_ERROR("Unable to find initial modes\n"); 425 DRM_ERROR("Unable to find initial modes\n");
392 426
427 DRM_DEBUG("picking CRTCs for %dx%d config\n", width, height);
428
393 drm_pick_crtcs(dev, crtcs, modes, 0, width, height); 429 drm_pick_crtcs(dev, crtcs, modes, 0, width, height);
394 430
395 i = 0; 431 i = 0;
@@ -403,6 +439,8 @@ static void drm_setup_crtcs(struct drm_device *dev)
403 } 439 }
404 440
405 if (mode && crtc) { 441 if (mode && crtc) {
442 DRM_DEBUG("desired mode %s set on crtc %d\n",
443 mode->name, crtc->base.id);
406 crtc->desired_mode = mode; 444 crtc->desired_mode = mode;
407 connector->encoder->crtc = crtc; 445 connector->encoder->crtc = crtc;
408 } else 446 } else
@@ -442,6 +480,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
442 int saved_x, saved_y; 480 int saved_x, saved_y;
443 struct drm_encoder *encoder; 481 struct drm_encoder *encoder;
444 bool ret = true; 482 bool ret = true;
483 bool depth_changed, bpp_changed;
445 484
446 adjusted_mode = drm_mode_duplicate(dev, mode); 485 adjusted_mode = drm_mode_duplicate(dev, mode);
447 486
@@ -450,6 +489,15 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
450 if (!crtc->enabled) 489 if (!crtc->enabled)
451 return true; 490 return true;
452 491
492 if (old_fb && crtc->fb) {
493 depth_changed = (old_fb->depth != crtc->fb->depth);
494 bpp_changed = (old_fb->bits_per_pixel !=
495 crtc->fb->bits_per_pixel);
496 } else {
497 depth_changed = true;
498 bpp_changed = true;
499 }
500
453 saved_mode = crtc->mode; 501 saved_mode = crtc->mode;
454 saved_x = crtc->x; 502 saved_x = crtc->x;
455 saved_y = crtc->y; 503 saved_y = crtc->y;
@@ -462,7 +510,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
462 crtc->y = y; 510 crtc->y = y;
463 511
464 if (drm_mode_equal(&saved_mode, &crtc->mode)) { 512 if (drm_mode_equal(&saved_mode, &crtc->mode)) {
465 if (saved_x != crtc->x || saved_y != crtc->y) { 513 if (saved_x != crtc->x || saved_y != crtc->y ||
514 depth_changed || bpp_changed) {
466 crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y, 515 crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y,
467 old_fb); 516 old_fb);
468 goto done; 517 goto done;
@@ -568,8 +617,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
568 struct drm_encoder **save_encoders, *new_encoder; 617 struct drm_encoder **save_encoders, *new_encoder;
569 struct drm_framebuffer *old_fb; 618 struct drm_framebuffer *old_fb;
570 bool save_enabled; 619 bool save_enabled;
571 bool changed = false; 620 bool mode_changed = false;
572 bool flip_or_move = false; 621 bool fb_changed = false;
573 struct drm_connector *connector; 622 struct drm_connector *connector;
574 int count = 0, ro, fail = 0; 623 int count = 0, ro, fail = 0;
575 struct drm_crtc_helper_funcs *crtc_funcs; 624 struct drm_crtc_helper_funcs *crtc_funcs;
@@ -597,7 +646,10 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
597 /* save previous config */ 646 /* save previous config */
598 save_enabled = set->crtc->enabled; 647 save_enabled = set->crtc->enabled;
599 648
600 /* this is meant to be num_connector not num_crtc */ 649 /*
650 * We do mode_config.num_connectors here since we'll look at the
651 * CRTC and encoder associated with each connector later.
652 */
601 save_crtcs = kzalloc(dev->mode_config.num_connector * 653 save_crtcs = kzalloc(dev->mode_config.num_connector *
602 sizeof(struct drm_crtc *), GFP_KERNEL); 654 sizeof(struct drm_crtc *), GFP_KERNEL);
603 if (!save_crtcs) 655 if (!save_crtcs)
@@ -613,21 +665,25 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
613 /* We should be able to check here if the fb has the same properties 665 /* We should be able to check here if the fb has the same properties
614 * and then just flip_or_move it */ 666 * and then just flip_or_move it */
615 if (set->crtc->fb != set->fb) { 667 if (set->crtc->fb != set->fb) {
616 /* if we have no fb then its a change not a flip */ 668 /* If we have no fb then treat it as a full mode set */
617 if (set->crtc->fb == NULL) 669 if (set->crtc->fb == NULL)
618 changed = true; 670 mode_changed = true;
671 else if ((set->fb->bits_per_pixel !=
672 set->crtc->fb->bits_per_pixel) ||
673 set->fb->depth != set->crtc->fb->depth)
674 fb_changed = true;
619 else 675 else
620 flip_or_move = true; 676 fb_changed = true;
621 } 677 }
622 678
623 if (set->x != set->crtc->x || set->y != set->crtc->y) 679 if (set->x != set->crtc->x || set->y != set->crtc->y)
624 flip_or_move = true; 680 fb_changed = true;
625 681
626 if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) { 682 if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) {
627 DRM_DEBUG("modes are different\n"); 683 DRM_DEBUG("modes are different\n");
628 drm_mode_debug_printmodeline(&set->crtc->mode); 684 drm_mode_debug_printmodeline(&set->crtc->mode);
629 drm_mode_debug_printmodeline(set->mode); 685 drm_mode_debug_printmodeline(set->mode);
630 changed = true; 686 mode_changed = true;
631 } 687 }
632 688
633 /* a) traverse passed in connector list and get encoders for them */ 689 /* a) traverse passed in connector list and get encoders for them */
@@ -650,7 +706,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
650 } 706 }
651 707
652 if (new_encoder != connector->encoder) { 708 if (new_encoder != connector->encoder) {
653 changed = true; 709 mode_changed = true;
654 connector->encoder = new_encoder; 710 connector->encoder = new_encoder;
655 } 711 }
656 } 712 }
@@ -677,16 +733,16 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
677 new_crtc = set->crtc; 733 new_crtc = set->crtc;
678 } 734 }
679 if (new_crtc != connector->encoder->crtc) { 735 if (new_crtc != connector->encoder->crtc) {
680 changed = true; 736 mode_changed = true;
681 connector->encoder->crtc = new_crtc; 737 connector->encoder->crtc = new_crtc;
682 } 738 }
683 } 739 }
684 740
685 /* mode_set_base is not a required function */ 741 /* mode_set_base is not a required function */
686 if (flip_or_move && !crtc_funcs->mode_set_base) 742 if (fb_changed && !crtc_funcs->mode_set_base)
687 changed = true; 743 mode_changed = true;
688 744
689 if (changed) { 745 if (mode_changed) {
690 old_fb = set->crtc->fb; 746 old_fb = set->crtc->fb;
691 set->crtc->fb = set->fb; 747 set->crtc->fb = set->fb;
692 set->crtc->enabled = (set->mode != NULL); 748 set->crtc->enabled = (set->mode != NULL);
@@ -705,7 +761,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
705 set->crtc->desired_mode = set->mode; 761 set->crtc->desired_mode = set->mode;
706 } 762 }
707 drm_helper_disable_unused_functions(dev); 763 drm_helper_disable_unused_functions(dev);
708 } else if (flip_or_move) { 764 } else if (fb_changed) {
709 old_fb = set->crtc->fb; 765 old_fb = set->crtc->fb;
710 if (set->crtc->fb != set->fb) 766 if (set->crtc->fb != set->fb)
711 set->crtc->fb = set->fb; 767 set->crtc->fb = set->fb;
@@ -764,10 +820,31 @@ bool drm_helper_plugged_event(struct drm_device *dev)
764 */ 820 */
765bool drm_helper_initial_config(struct drm_device *dev, bool can_grow) 821bool drm_helper_initial_config(struct drm_device *dev, bool can_grow)
766{ 822{
767 int ret = false; 823 struct drm_connector *connector;
824 int count = 0;
768 825
769 drm_helper_plugged_event(dev); 826 count = drm_helper_probe_connector_modes(dev,
770 return ret; 827 dev->mode_config.max_width,
828 dev->mode_config.max_height);
829
830 /*
831 * None of the available connectors had any modes, so add some
832 * and try to light them up anyway
833 */
834 if (!count) {
835 DRM_ERROR("connectors have no modes, using standard modes\n");
836 list_for_each_entry(connector,
837 &dev->mode_config.connector_list,
838 head)
839 drm_helper_add_std_modes(dev, connector);
840 }
841
842 drm_setup_crtcs(dev);
843
844 /* alert the driver fb layer */
845 dev->mode_config.funcs->fb_changed(dev);
846
847 return 0;
771} 848}
772EXPORT_SYMBOL(drm_helper_initial_config); 849EXPORT_SYMBOL(drm_helper_initial_config);
773 850
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 724e505873cf..477caa1b1e4b 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -267,7 +267,8 @@ EXPORT_SYMBOL(drm_irq_install);
267 */ 267 */
268int drm_irq_uninstall(struct drm_device * dev) 268int drm_irq_uninstall(struct drm_device * dev)
269{ 269{
270 int irq_enabled; 270 unsigned long irqflags;
271 int irq_enabled, i;
271 272
272 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 273 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
273 return -EINVAL; 274 return -EINVAL;
@@ -277,6 +278,16 @@ int drm_irq_uninstall(struct drm_device * dev)
277 dev->irq_enabled = 0; 278 dev->irq_enabled = 0;
278 mutex_unlock(&dev->struct_mutex); 279 mutex_unlock(&dev->struct_mutex);
279 280
281 /*
282 * Wake up any waiters so they don't hang.
283 */
284 spin_lock_irqsave(&dev->vbl_lock, irqflags);
285 for (i = 0; i < dev->num_crtcs; i++) {
286 DRM_WAKEUP(&dev->vbl_queue[i]);
287 dev->vblank_enabled[i] = 0;
288 }
289 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
290
280 if (!irq_enabled) 291 if (!irq_enabled)
281 return -EINVAL; 292 return -EINVAL;
282 293
@@ -652,8 +663,9 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
652 vblwait->request.sequence, crtc); 663 vblwait->request.sequence, crtc);
653 dev->last_vblank_wait[crtc] = vblwait->request.sequence; 664 dev->last_vblank_wait[crtc] = vblwait->request.sequence;
654 DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ, 665 DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ,
655 ((drm_vblank_count(dev, crtc) 666 (((drm_vblank_count(dev, crtc) -
656 - vblwait->request.sequence) <= (1 << 23))); 667 vblwait->request.sequence) <= (1 << 23)) ||
668 !dev->irq_enabled));
657 669
658 if (ret != -EINTR) { 670 if (ret != -EINTR) {
659 struct timeval now; 671 struct timeval now;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 62a4bf7b49df..bbadf1c04142 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -177,6 +177,14 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
177 drm_i915_private_t *dev_priv = dev->dev_private; 177 drm_i915_private_t *dev_priv = dev->dev_private;
178 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; 178 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
179 179
180 master_priv->sarea = drm_getsarea(dev);
181 if (master_priv->sarea) {
182 master_priv->sarea_priv = (drm_i915_sarea_t *)
183 ((u8 *)master_priv->sarea->handle + init->sarea_priv_offset);
184 } else {
185 DRM_DEBUG("sarea not found assuming DRI2 userspace\n");
186 }
187
180 if (init->ring_size != 0) { 188 if (init->ring_size != 0) {
181 if (dev_priv->ring.ring_obj != NULL) { 189 if (dev_priv->ring.ring_obj != NULL) {
182 i915_dma_cleanup(dev); 190 i915_dma_cleanup(dev);
@@ -1152,6 +1160,8 @@ int i915_driver_unload(struct drm_device *dev)
1152 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 1160 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1153 intel_modeset_cleanup(dev); 1161 intel_modeset_cleanup(dev);
1154 1162
1163 i915_gem_free_all_phys_object(dev);
1164
1155 mutex_lock(&dev->struct_mutex); 1165 mutex_lock(&dev->struct_mutex);
1156 i915_gem_cleanup_ringbuffer(dev); 1166 i915_gem_cleanup_ringbuffer(dev);
1157 mutex_unlock(&dev->struct_mutex); 1167 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 563de18063fd..e13518252007 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -72,6 +72,18 @@ enum pipe {
72#define WATCH_INACTIVE 0 72#define WATCH_INACTIVE 0
73#define WATCH_PWRITE 0 73#define WATCH_PWRITE 0
74 74
75#define I915_GEM_PHYS_CURSOR_0 1
76#define I915_GEM_PHYS_CURSOR_1 2
77#define I915_GEM_PHYS_OVERLAY_REGS 3
78#define I915_MAX_PHYS_OBJECT (I915_GEM_PHYS_OVERLAY_REGS)
79
80struct drm_i915_gem_phys_object {
81 int id;
82 struct page **page_list;
83 drm_dma_handle_t *handle;
84 struct drm_gem_object *cur_obj;
85};
86
75typedef struct _drm_i915_ring_buffer { 87typedef struct _drm_i915_ring_buffer {
76 int tail_mask; 88 int tail_mask;
77 unsigned long Size; 89 unsigned long Size;
@@ -358,6 +370,9 @@ typedef struct drm_i915_private {
358 uint32_t bit_6_swizzle_x; 370 uint32_t bit_6_swizzle_x;
359 /** Bit 6 swizzling required for Y tiling */ 371 /** Bit 6 swizzling required for Y tiling */
360 uint32_t bit_6_swizzle_y; 372 uint32_t bit_6_swizzle_y;
373
374 /* storage for physical objects */
375 struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
361 } mm; 376 } mm;
362} drm_i915_private_t; 377} drm_i915_private_t;
363 378
@@ -436,6 +451,9 @@ struct drm_i915_gem_object {
436 /** User space pin count and filp owning the pin */ 451 /** User space pin count and filp owning the pin */
437 uint32_t user_pin_count; 452 uint32_t user_pin_count;
438 struct drm_file *pin_filp; 453 struct drm_file *pin_filp;
454
455 /** for phy allocated objects */
456 struct drm_i915_gem_phys_object *phys_obj;
439}; 457};
440 458
441/** 459/**
@@ -598,6 +616,11 @@ int i915_gem_do_init(struct drm_device *dev, unsigned long start,
598int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 616int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
599int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, 617int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj,
600 int write); 618 int write);
619int i915_gem_attach_phys_object(struct drm_device *dev,
620 struct drm_gem_object *obj, int id);
621void i915_gem_detach_phys_object(struct drm_device *dev,
622 struct drm_gem_object *obj);
623void i915_gem_free_all_phys_object(struct drm_device *dev);
601 624
602/* i915_gem_tiling.c */ 625/* i915_gem_tiling.c */
603void i915_gem_detect_bit_6_swizzle(struct drm_device *dev); 626void i915_gem_detect_bit_6_swizzle(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 1384d6686555..96316fd47233 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -55,6 +55,9 @@ static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj,
55static void i915_gem_object_get_fence_reg(struct drm_gem_object *obj); 55static void i915_gem_object_get_fence_reg(struct drm_gem_object *obj);
56static void i915_gem_clear_fence_reg(struct drm_gem_object *obj); 56static void i915_gem_clear_fence_reg(struct drm_gem_object *obj);
57static int i915_gem_evict_something(struct drm_device *dev); 57static int i915_gem_evict_something(struct drm_device *dev);
58static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
59 struct drm_i915_gem_pwrite *args,
60 struct drm_file *file_priv);
58 61
59int i915_gem_do_init(struct drm_device *dev, unsigned long start, 62int i915_gem_do_init(struct drm_device *dev, unsigned long start,
60 unsigned long end) 63 unsigned long end)
@@ -386,8 +389,10 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
386 * pread/pwrite currently are reading and writing from the CPU 389 * pread/pwrite currently are reading and writing from the CPU
387 * perspective, requiring manual detiling by the client. 390 * perspective, requiring manual detiling by the client.
388 */ 391 */
389 if (obj_priv->tiling_mode == I915_TILING_NONE && 392 if (obj_priv->phys_obj)
390 dev->gtt_total != 0) 393 ret = i915_gem_phys_pwrite(dev, obj, args, file_priv);
394 else if (obj_priv->tiling_mode == I915_TILING_NONE &&
395 dev->gtt_total != 0)
391 ret = i915_gem_gtt_pwrite(dev, obj, args, file_priv); 396 ret = i915_gem_gtt_pwrite(dev, obj, args, file_priv);
392 else 397 else
393 ret = i915_gem_shmem_pwrite(dev, obj, args, file_priv); 398 ret = i915_gem_shmem_pwrite(dev, obj, args, file_priv);
@@ -2858,6 +2863,9 @@ void i915_gem_free_object(struct drm_gem_object *obj)
2858 while (obj_priv->pin_count > 0) 2863 while (obj_priv->pin_count > 0)
2859 i915_gem_object_unpin(obj); 2864 i915_gem_object_unpin(obj);
2860 2865
2866 if (obj_priv->phys_obj)
2867 i915_gem_detach_phys_object(dev, obj);
2868
2861 i915_gem_object_unbind(obj); 2869 i915_gem_object_unbind(obj);
2862 2870
2863 list = &obj->map_list; 2871 list = &obj->map_list;
@@ -3293,3 +3301,180 @@ i915_gem_load(struct drm_device *dev)
3293 3301
3294 i915_gem_detect_bit_6_swizzle(dev); 3302 i915_gem_detect_bit_6_swizzle(dev);
3295} 3303}
3304
3305/*
3306 * Create a physically contiguous memory object for this object
3307 * e.g. for cursor + overlay regs
3308 */
3309int i915_gem_init_phys_object(struct drm_device *dev,
3310 int id, int size)
3311{
3312 drm_i915_private_t *dev_priv = dev->dev_private;
3313 struct drm_i915_gem_phys_object *phys_obj;
3314 int ret;
3315
3316 if (dev_priv->mm.phys_objs[id - 1] || !size)
3317 return 0;
3318
3319 phys_obj = drm_calloc(1, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER);
3320 if (!phys_obj)
3321 return -ENOMEM;
3322
3323 phys_obj->id = id;
3324
3325 phys_obj->handle = drm_pci_alloc(dev, size, 0, 0xffffffff);
3326 if (!phys_obj->handle) {
3327 ret = -ENOMEM;
3328 goto kfree_obj;
3329 }
3330#ifdef CONFIG_X86
3331 set_memory_wc((unsigned long)phys_obj->handle->vaddr, phys_obj->handle->size / PAGE_SIZE);
3332#endif
3333
3334 dev_priv->mm.phys_objs[id - 1] = phys_obj;
3335
3336 return 0;
3337kfree_obj:
3338 drm_free(phys_obj, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER);
3339 return ret;
3340}
3341
3342void i915_gem_free_phys_object(struct drm_device *dev, int id)
3343{
3344 drm_i915_private_t *dev_priv = dev->dev_private;
3345 struct drm_i915_gem_phys_object *phys_obj;
3346
3347 if (!dev_priv->mm.phys_objs[id - 1])
3348 return;
3349
3350 phys_obj = dev_priv->mm.phys_objs[id - 1];
3351 if (phys_obj->cur_obj) {
3352 i915_gem_detach_phys_object(dev, phys_obj->cur_obj);
3353 }
3354
3355#ifdef CONFIG_X86
3356 set_memory_wb((unsigned long)phys_obj->handle->vaddr, phys_obj->handle->size / PAGE_SIZE);
3357#endif
3358 drm_pci_free(dev, phys_obj->handle);
3359 kfree(phys_obj);
3360 dev_priv->mm.phys_objs[id - 1] = NULL;
3361}
3362
3363void i915_gem_free_all_phys_object(struct drm_device *dev)
3364{
3365 int i;
3366
3367 for (i = 0; i < I915_MAX_PHYS_OBJECT; i++)
3368 i915_gem_free_phys_object(dev, i);
3369}
3370
3371void i915_gem_detach_phys_object(struct drm_device *dev,
3372 struct drm_gem_object *obj)
3373{
3374 struct drm_i915_gem_object *obj_priv;
3375 int i;
3376 int ret;
3377 int page_count;
3378
3379 obj_priv = obj->driver_private;
3380 if (!obj_priv->phys_obj)
3381 return;
3382
3383 ret = i915_gem_object_get_page_list(obj);
3384 if (ret)
3385 goto out;
3386
3387 page_count = obj->size / PAGE_SIZE;
3388
3389 for (i = 0; i < page_count; i++) {
3390 char *dst = kmap_atomic(obj_priv->page_list[i], KM_USER0);
3391 char *src = obj_priv->phys_obj->handle->vaddr + (i * PAGE_SIZE);
3392
3393 memcpy(dst, src, PAGE_SIZE);
3394 kunmap_atomic(dst, KM_USER0);
3395 }
3396 drm_clflush_pages(obj_priv->page_list, page_count);
3397 drm_agp_chipset_flush(dev);
3398out:
3399 obj_priv->phys_obj->cur_obj = NULL;
3400 obj_priv->phys_obj = NULL;
3401}
3402
3403int
3404i915_gem_attach_phys_object(struct drm_device *dev,
3405 struct drm_gem_object *obj, int id)
3406{
3407 drm_i915_private_t *dev_priv = dev->dev_private;
3408 struct drm_i915_gem_object *obj_priv;
3409 int ret = 0;
3410 int page_count;
3411 int i;
3412
3413 if (id > I915_MAX_PHYS_OBJECT)
3414 return -EINVAL;
3415
3416 obj_priv = obj->driver_private;
3417
3418 if (obj_priv->phys_obj) {
3419 if (obj_priv->phys_obj->id == id)
3420 return 0;
3421 i915_gem_detach_phys_object(dev, obj);
3422 }
3423
3424
3425 /* create a new object */
3426 if (!dev_priv->mm.phys_objs[id - 1]) {
3427 ret = i915_gem_init_phys_object(dev, id,
3428 obj->size);
3429 if (ret) {
3430 DRM_ERROR("failed to init phys object %d size: %d\n", id, obj->size);
3431 goto out;
3432 }
3433 }
3434
3435 /* bind to the object */
3436 obj_priv->phys_obj = dev_priv->mm.phys_objs[id - 1];
3437 obj_priv->phys_obj->cur_obj = obj;
3438
3439 ret = i915_gem_object_get_page_list(obj);
3440 if (ret) {
3441 DRM_ERROR("failed to get page list\n");
3442 goto out;
3443 }
3444
3445 page_count = obj->size / PAGE_SIZE;
3446
3447 for (i = 0; i < page_count; i++) {
3448 char *src = kmap_atomic(obj_priv->page_list[i], KM_USER0);
3449 char *dst = obj_priv->phys_obj->handle->vaddr + (i * PAGE_SIZE);
3450
3451 memcpy(dst, src, PAGE_SIZE);
3452 kunmap_atomic(src, KM_USER0);
3453 }
3454
3455 return 0;
3456out:
3457 return ret;
3458}
3459
3460static int
3461i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
3462 struct drm_i915_gem_pwrite *args,
3463 struct drm_file *file_priv)
3464{
3465 struct drm_i915_gem_object *obj_priv = obj->driver_private;
3466 void *obj_addr;
3467 int ret;
3468 char __user *user_data;
3469
3470 user_data = (char __user *) (uintptr_t) args->data_ptr;
3471 obj_addr = obj_priv->phys_obj->handle->vaddr + args->offset;
3472
3473 DRM_ERROR("obj_addr %p, %lld\n", obj_addr, args->size);
3474 ret = copy_from_user(obj_addr, user_data, args->size);
3475 if (ret)
3476 return -EFAULT;
3477
3478 drm_agp_chipset_flush(dev);
3479 return 0;
3480}
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 0cadafbef411..6290219de6c8 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -411,6 +411,12 @@ int i915_enable_vblank(struct drm_device *dev, int pipe)
411{ 411{
412 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 412 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
413 unsigned long irqflags; 413 unsigned long irqflags;
414 int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
415 u32 pipeconf;
416
417 pipeconf = I915_READ(pipeconf_reg);
418 if (!(pipeconf & PIPEACONF_ENABLE))
419 return -EINVAL;
414 420
415 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); 421 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
416 if (IS_I965G(dev)) 422 if (IS_I965G(dev))
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 8ccb9c3ab868..31c3732b7a69 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -401,6 +401,8 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
401 I915_WRITE(dspstride, crtc->fb->pitch); 401 I915_WRITE(dspstride, crtc->fb->pitch);
402 402
403 dspcntr = I915_READ(dspcntr_reg); 403 dspcntr = I915_READ(dspcntr_reg);
404 /* Mask out pixel format bits in case we change it */
405 dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
404 switch (crtc->fb->bits_per_pixel) { 406 switch (crtc->fb->bits_per_pixel) {
405 case 8: 407 case 8:
406 dspcntr |= DISPPLANE_8BPP; 408 dspcntr |= DISPPLANE_8BPP;
@@ -1014,21 +1016,25 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
1014 1016
1015 if (bo->size < width * height * 4) { 1017 if (bo->size < width * height * 4) {
1016 DRM_ERROR("buffer is to small\n"); 1018 DRM_ERROR("buffer is to small\n");
1017 drm_gem_object_unreference(bo); 1019 ret = -ENOMEM;
1018 return -ENOMEM; 1020 goto fail;
1019 } 1021 }
1020 1022
1021 if (dev_priv->cursor_needs_physical) { 1023 /* we only need to pin inside GTT if cursor is non-phy */
1022 addr = dev->agp->base + obj_priv->gtt_offset; 1024 if (!dev_priv->cursor_needs_physical) {
1023 } else { 1025 ret = i915_gem_object_pin(bo, PAGE_SIZE);
1026 if (ret) {
1027 DRM_ERROR("failed to pin cursor bo\n");
1028 goto fail;
1029 }
1024 addr = obj_priv->gtt_offset; 1030 addr = obj_priv->gtt_offset;
1025 } 1031 } else {
1026 1032 ret = i915_gem_attach_phys_object(dev, bo, (pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1);
1027 ret = i915_gem_object_pin(bo, PAGE_SIZE); 1033 if (ret) {
1028 if (ret) { 1034 DRM_ERROR("failed to attach phys object\n");
1029 DRM_ERROR("failed to pin cursor bo\n"); 1035 goto fail;
1030 drm_gem_object_unreference(bo); 1036 }
1031 return ret; 1037 addr = obj_priv->phys_obj->handle->busaddr;
1032 } 1038 }
1033 1039
1034 temp = 0; 1040 temp = 0;
@@ -1041,14 +1047,25 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
1041 I915_WRITE(base, addr); 1047 I915_WRITE(base, addr);
1042 1048
1043 if (intel_crtc->cursor_bo) { 1049 if (intel_crtc->cursor_bo) {
1044 i915_gem_object_unpin(intel_crtc->cursor_bo); 1050 if (dev_priv->cursor_needs_physical) {
1051 if (intel_crtc->cursor_bo != bo)
1052 i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo);
1053 } else
1054 i915_gem_object_unpin(intel_crtc->cursor_bo);
1055 mutex_lock(&dev->struct_mutex);
1045 drm_gem_object_unreference(intel_crtc->cursor_bo); 1056 drm_gem_object_unreference(intel_crtc->cursor_bo);
1057 mutex_unlock(&dev->struct_mutex);
1046 } 1058 }
1047 1059
1048 intel_crtc->cursor_addr = addr; 1060 intel_crtc->cursor_addr = addr;
1049 intel_crtc->cursor_bo = bo; 1061 intel_crtc->cursor_bo = bo;
1050 1062
1051 return 0; 1063 return 0;
1064fail:
1065 mutex_lock(&dev->struct_mutex);
1066 drm_gem_object_unreference(bo);
1067 mutex_unlock(&dev->struct_mutex);
1068 return ret;
1052} 1069}
1053 1070
1054static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) 1071static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index ccecfaf6307b..2fafdcc108fe 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -456,6 +456,13 @@ void intel_lvds_init(struct drm_device *dev)
456 dev_priv->panel_fixed_mode = 456 dev_priv->panel_fixed_mode =
457 drm_mode_duplicate(dev, dev_priv->vbt_mode); 457 drm_mode_duplicate(dev, dev_priv->vbt_mode);
458 mutex_unlock(&dev->mode_config.mutex); 458 mutex_unlock(&dev->mode_config.mutex);
459 if (dev_priv->panel_fixed_mode) {
460 dev_priv->panel_fixed_mode->type |=
461 DRM_MODE_TYPE_PREFERRED;
462 drm_mode_probed_add(connector,
463 dev_priv->panel_fixed_mode);
464 goto out;
465 }
459 } 466 }
460 467
461 /* 468 /*
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 4b33bc82cc24..b84bf066879b 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -189,6 +189,16 @@ config SENSORS_ADT7473
189 This driver can also be built as a module. If so, the module 189 This driver can also be built as a module. If so, the module
190 will be called adt7473. 190 will be called adt7473.
191 191
192config SENSORS_ADT7475
193 tristate "Analog Devices ADT7475"
194 depends on I2C && EXPERIMENTAL
195 help
196 If you say yes here you get support for the Analog Devices
197 ADT7475 hardware monitoring chips.
198
199 This driver can also be build as a module. If so, the module
200 will be called adt7475.
201
192config SENSORS_K8TEMP 202config SENSORS_K8TEMP
193 tristate "AMD Athlon64/FX or Opteron temperature sensor" 203 tristate "AMD Athlon64/FX or Opteron temperature sensor"
194 depends on X86 && PCI && EXPERIMENTAL 204 depends on X86 && PCI && EXPERIMENTAL
@@ -861,6 +871,8 @@ config SENSORS_HDAPS
861config SENSORS_LIS3LV02D 871config SENSORS_LIS3LV02D
862 tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" 872 tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer"
863 depends on ACPI && INPUT 873 depends on ACPI && INPUT
874 select NEW_LEDS
875 select LEDS_CLASS
864 default n 876 default n
865 help 877 help
866 This driver provides support for the LIS3LV02Dx accelerometer. In 878 This driver provides support for the LIS3LV02Dx accelerometer. In
@@ -872,10 +884,16 @@ config SENSORS_LIS3LV02D
872 /sys/devices/platform/lis3lv02d. 884 /sys/devices/platform/lis3lv02d.
873 885
874 This driver also provides an absolute input class device, allowing 886 This driver also provides an absolute input class device, allowing
875 the laptop to act as a pinball machine-esque joystick. 887 the laptop to act as a pinball machine-esque joystick. On HP laptops,
888 if the led infrastructure is activated, support for a led indicating
889 disk protection will be provided as hp:red:hddprotection.
876 890
877 This driver can also be built as a module. If so, the module 891 This driver can also be built as modules. If so, the core module
878 will be called lis3lv02d. 892 will be called lis3lv02d and a specific module for HP laptops will be
893 called hp_accel.
894
895 Say Y here if you have an applicable laptop and want to experience
896 the awesome power of lis3lv02d.
879 897
880config SENSORS_APPLESMC 898config SENSORS_APPLESMC
881 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" 899 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 19cb1ace3eb4..2e80f37f39eb 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -28,6 +28,8 @@ obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o
28obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o 28obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o
29obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o 29obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o
30obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o 30obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o
31obj-$(CONFIG_SENSORS_ADT7475) += adt7475.o
32
31obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o 33obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
32obj-$(CONFIG_SENSORS_AMS) += ams/ 34obj-$(CONFIG_SENSORS_AMS) += ams/
33obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o 35obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index 70bb854086df..e52b38806d03 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -279,7 +279,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
279 { "OTES1 Fan", 36, 2, 60, 1, 0 }, 279 { "OTES1 Fan", 36, 2, 60, 1, 0 },
280 { NULL, 0, 0, 0, 0, 0 } } 280 { NULL, 0, 0, 0, 0, 0 } }
281 }, 281 },
282 { 0x0011, "AT8 32X(ATI RD580-ULI M1575)", { 282 { 0x0011, "AT8 32X", {
283 { "CPU Core", 0, 0, 10, 1, 0 }, 283 { "CPU Core", 0, 0, 10, 1, 0 },
284 { "DDR", 1, 0, 20, 1, 0 }, 284 { "DDR", 1, 0, 20, 1, 0 },
285 { "DDR VTT", 2, 0, 10, 1, 0 }, 285 { "DDR VTT", 2, 0, 10, 1, 0 },
@@ -402,7 +402,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
402 { "AUX3 Fan", 36, 2, 60, 1, 0 }, 402 { "AUX3 Fan", 36, 2, 60, 1, 0 },
403 { NULL, 0, 0, 0, 0, 0 } } 403 { NULL, 0, 0, 0, 0, 0 } }
404 }, 404 },
405 { 0x0016, "AW9D-MAX (Intel i975-ICH7)", { 405 { 0x0016, "AW9D-MAX", {
406 { "CPU Core", 0, 0, 10, 1, 0 }, 406 { "CPU Core", 0, 0, 10, 1, 0 },
407 { "DDR2", 1, 0, 20, 1, 0 }, 407 { "DDR2", 1, 0, 20, 1, 0 },
408 { "DDR2 VTT", 2, 0, 10, 1, 0 }, 408 { "DDR2 VTT", 2, 0, 10, 1, 0 },
@@ -482,7 +482,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
482 { "AUX3 Fan", 36, 2, 60, 1, 0 }, 482 { "AUX3 Fan", 36, 2, 60, 1, 0 },
483 { NULL, 0, 0, 0, 0, 0 } } 483 { NULL, 0, 0, 0, 0, 0 } }
484 }, 484 },
485 { 0x0019, NULL /* Unknown, need DMI string */, { 485 { 0x0019, "IN9 32X MAX", {
486 { "CPU Core", 7, 0, 10, 1, 0 }, 486 { "CPU Core", 7, 0, 10, 1, 0 },
487 { "DDR2", 13, 0, 20, 1, 0 }, 487 { "DDR2", 13, 0, 20, 1, 0 },
488 { "DDR2 VTT", 14, 0, 10, 1, 0 }, 488 { "DDR2 VTT", 14, 0, 10, 1, 0 },
@@ -509,7 +509,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
509 { "AUX3 FAN", 36, 2, 60, 1, 0 }, 509 { "AUX3 FAN", 36, 2, 60, 1, 0 },
510 { NULL, 0, 0, 0, 0, 0 } } 510 { NULL, 0, 0, 0, 0, 0 } }
511 }, 511 },
512 { 0x001A, "IP35 Pro(Intel P35-ICH9R)", { 512 { 0x001A, "IP35 Pro", {
513 { "CPU Core", 0, 0, 10, 1, 0 }, 513 { "CPU Core", 0, 0, 10, 1, 0 },
514 { "DDR2", 1, 0, 20, 1, 0 }, 514 { "DDR2", 1, 0, 20, 1, 0 },
515 { "DDR2 VTT", 2, 0, 10, 1, 0 }, 515 { "DDR2 VTT", 2, 0, 10, 1, 0 },
@@ -1128,6 +1128,7 @@ static int __init abituguru3_dmi_detect(void)
1128{ 1128{
1129 const char *board_vendor, *board_name; 1129 const char *board_vendor, *board_name;
1130 int i, err = (force) ? 1 : -ENODEV; 1130 int i, err = (force) ? 1 : -ENODEV;
1131 size_t sublen;
1131 1132
1132 board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR); 1133 board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
1133 if (!board_vendor || strcmp(board_vendor, "http://www.abit.com.tw/")) 1134 if (!board_vendor || strcmp(board_vendor, "http://www.abit.com.tw/"))
@@ -1137,9 +1138,20 @@ static int __init abituguru3_dmi_detect(void)
1137 if (!board_name) 1138 if (!board_name)
1138 return err; 1139 return err;
1139 1140
1141 /* At the moment, we don't care about the part of the vendor
1142 * DMI string contained in brackets. Truncate the string at
1143 * the first occurrence of a bracket. Trim any trailing space
1144 * from the substring.
1145 */
1146 sublen = strcspn(board_name, "(");
1147 while (sublen > 0 && board_name[sublen - 1] == ' ')
1148 sublen--;
1149
1140 for (i = 0; abituguru3_motherboards[i].id; i++) { 1150 for (i = 0; abituguru3_motherboards[i].id; i++) {
1141 const char *dmi_name = abituguru3_motherboards[i].dmi_name; 1151 const char *dmi_name = abituguru3_motherboards[i].dmi_name;
1142 if (dmi_name && !strcmp(dmi_name, board_name)) 1152 if (!dmi_name || strlen(dmi_name) != sublen)
1153 continue;
1154 if (!strncasecmp(board_name, dmi_name, sublen))
1143 break; 1155 break;
1144 } 1156 }
1145 1157
@@ -1153,7 +1165,7 @@ static int __init abituguru3_dmi_detect(void)
1153 1165
1154static inline int abituguru3_dmi_detect(void) 1166static inline int abituguru3_dmi_detect(void)
1155{ 1167{
1156 return -ENODEV; 1168 return 1;
1157} 1169}
1158 1170
1159#endif /* CONFIG_DMI */ 1171#endif /* CONFIG_DMI */
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
new file mode 100644
index 000000000000..d39877a7da63
--- /dev/null
+++ b/drivers/hwmon/adt7475.c
@@ -0,0 +1,1221 @@
1/*
2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
6
7 * Derived from the lm83 driver by Jean Delvare
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/slab.h>
17#include <linux/i2c.h>
18#include <linux/hwmon.h>
19#include <linux/hwmon-sysfs.h>
20#include <linux/err.h>
21
22/* Indexes for the sysfs hooks */
23
24#define INPUT 0
25#define MIN 1
26#define MAX 2
27#define CONTROL 3
28#define OFFSET 3
29#define AUTOMIN 4
30#define THERM 5
31#define HYSTERSIS 6
32
33/* These are unique identifiers for the sysfs functions - unlike the
34 numbers above, these are not also indexes into an array
35*/
36
37#define ALARM 9
38#define FAULT 10
39
40/* 7475 Common Registers */
41
42#define REG_VOLTAGE_BASE 0x21
43#define REG_TEMP_BASE 0x25
44#define REG_TACH_BASE 0x28
45#define REG_PWM_BASE 0x30
46#define REG_PWM_MAX_BASE 0x38
47
48#define REG_DEVID 0x3D
49#define REG_VENDID 0x3E
50
51#define REG_STATUS1 0x41
52#define REG_STATUS2 0x42
53
54#define REG_VOLTAGE_MIN_BASE 0x46
55#define REG_VOLTAGE_MAX_BASE 0x47
56
57#define REG_TEMP_MIN_BASE 0x4E
58#define REG_TEMP_MAX_BASE 0x4F
59
60#define REG_TACH_MIN_BASE 0x54
61
62#define REG_PWM_CONFIG_BASE 0x5C
63
64#define REG_TEMP_TRANGE_BASE 0x5F
65
66#define REG_PWM_MIN_BASE 0x64
67
68#define REG_TEMP_TMIN_BASE 0x67
69#define REG_TEMP_THERM_BASE 0x6A
70
71#define REG_REMOTE1_HYSTERSIS 0x6D
72#define REG_REMOTE2_HYSTERSIS 0x6E
73
74#define REG_TEMP_OFFSET_BASE 0x70
75
76#define REG_EXTEND1 0x76
77#define REG_EXTEND2 0x77
78#define REG_CONFIG5 0x7C
79
80#define CONFIG5_TWOSCOMP 0x01
81#define CONFIG5_TEMPOFFSET 0x02
82
83/* ADT7475 Settings */
84
85#define ADT7475_VOLTAGE_COUNT 2
86#define ADT7475_TEMP_COUNT 3
87#define ADT7475_TACH_COUNT 4
88#define ADT7475_PWM_COUNT 3
89
90/* Macro to read the registers */
91
92#define adt7475_read(reg) i2c_smbus_read_byte_data(client, (reg))
93
94/* Macros to easily index the registers */
95
96#define TACH_REG(idx) (REG_TACH_BASE + ((idx) * 2))
97#define TACH_MIN_REG(idx) (REG_TACH_MIN_BASE + ((idx) * 2))
98
99#define PWM_REG(idx) (REG_PWM_BASE + (idx))
100#define PWM_MAX_REG(idx) (REG_PWM_MAX_BASE + (idx))
101#define PWM_MIN_REG(idx) (REG_PWM_MIN_BASE + (idx))
102#define PWM_CONFIG_REG(idx) (REG_PWM_CONFIG_BASE + (idx))
103
104#define VOLTAGE_REG(idx) (REG_VOLTAGE_BASE + (idx))
105#define VOLTAGE_MIN_REG(idx) (REG_VOLTAGE_MIN_BASE + ((idx) * 2))
106#define VOLTAGE_MAX_REG(idx) (REG_VOLTAGE_MAX_BASE + ((idx) * 2))
107
108#define TEMP_REG(idx) (REG_TEMP_BASE + (idx))
109#define TEMP_MIN_REG(idx) (REG_TEMP_MIN_BASE + ((idx) * 2))
110#define TEMP_MAX_REG(idx) (REG_TEMP_MAX_BASE + ((idx) * 2))
111#define TEMP_TMIN_REG(idx) (REG_TEMP_TMIN_BASE + (idx))
112#define TEMP_THERM_REG(idx) (REG_TEMP_THERM_BASE + (idx))
113#define TEMP_OFFSET_REG(idx) (REG_TEMP_OFFSET_BASE + (idx))
114#define TEMP_TRANGE_REG(idx) (REG_TEMP_TRANGE_BASE + (idx))
115
116static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
117
118I2C_CLIENT_INSMOD_1(adt7475);
119
120static const struct i2c_device_id adt7475_id[] = {
121 { "adt7475", adt7475 },
122 { }
123};
124MODULE_DEVICE_TABLE(i2c, adt7475_id);
125
126struct adt7475_data {
127 struct device *hwmon_dev;
128 struct mutex lock;
129
130 unsigned long measure_updated;
131 unsigned long limits_updated;
132 char valid;
133
134 u8 config5;
135 u16 alarms;
136 u16 voltage[3][3];
137 u16 temp[7][3];
138 u16 tach[2][4];
139 u8 pwm[4][3];
140 u8 range[3];
141 u8 pwmctl[3];
142 u8 pwmchan[3];
143};
144
145static struct i2c_driver adt7475_driver;
146static struct adt7475_data *adt7475_update_device(struct device *dev);
147static void adt7475_read_hystersis(struct i2c_client *client);
148static void adt7475_read_pwm(struct i2c_client *client, int index);
149
150/* Given a temp value, convert it to register value */
151
152static inline u16 temp2reg(struct adt7475_data *data, long val)
153{
154 u16 ret;
155
156 if (!(data->config5 & CONFIG5_TWOSCOMP)) {
157 val = SENSORS_LIMIT(val, -64000, 191000);
158 ret = (val + 64500) / 1000;
159 } else {
160 val = SENSORS_LIMIT(val, -128000, 127000);
161 if (val < -500)
162 ret = (256500 + val) / 1000;
163 else
164 ret = (val + 500) / 1000;
165 }
166
167 return ret << 2;
168}
169
170/* Given a register value, convert it to a real temp value */
171
172static inline int reg2temp(struct adt7475_data *data, u16 reg)
173{
174 if (data->config5 & CONFIG5_TWOSCOMP) {
175 if (reg >= 512)
176 return (reg - 1024) * 250;
177 else
178 return reg * 250;
179 } else
180 return (reg - 256) * 250;
181}
182
183static inline int tach2rpm(u16 tach)
184{
185 if (tach == 0 || tach == 0xFFFF)
186 return 0;
187
188 return (90000 * 60) / tach;
189}
190
191static inline u16 rpm2tach(unsigned long rpm)
192{
193 if (rpm == 0)
194 return 0;
195
196 return SENSORS_LIMIT((90000 * 60) / rpm, 1, 0xFFFF);
197}
198
199static inline int reg2vcc(u16 reg)
200{
201 return (4296 * reg) / 1000;
202}
203
204static inline int reg2vccp(u16 reg)
205{
206 return (2929 * reg) / 1000;
207}
208
209static inline u16 vcc2reg(long vcc)
210{
211 vcc = SENSORS_LIMIT(vcc, 0, 4396);
212 return (vcc * 1000) / 4296;
213}
214
215static inline u16 vccp2reg(long vcc)
216{
217 vcc = SENSORS_LIMIT(vcc, 0, 2998);
218 return (vcc * 1000) / 2929;
219}
220
221static u16 adt7475_read_word(struct i2c_client *client, int reg)
222{
223 u16 val;
224
225 val = i2c_smbus_read_byte_data(client, reg);
226 val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8);
227
228 return val;
229}
230
231static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
232{
233 i2c_smbus_write_byte_data(client, reg + 1, val >> 8);
234 i2c_smbus_write_byte_data(client, reg, val & 0xFF);
235}
236
237/* Find the nearest value in a table - used for pwm frequency and
238 auto temp range */
239static int find_nearest(long val, const int *array, int size)
240{
241 int i;
242
243 if (val < array[0])
244 return 0;
245
246 if (val > array[size - 1])
247 return size - 1;
248
249 for (i = 0; i < size - 1; i++) {
250 int a, b;
251
252 if (val > array[i + 1])
253 continue;
254
255 a = val - array[i];
256 b = array[i + 1] - val;
257
258 return (a <= b) ? i : i + 1;
259 }
260
261 return 0;
262}
263
264static ssize_t show_voltage(struct device *dev, struct device_attribute *attr,
265 char *buf)
266{
267 struct adt7475_data *data = adt7475_update_device(dev);
268 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
269 unsigned short val;
270
271 switch (sattr->nr) {
272 case ALARM:
273 return sprintf(buf, "%d\n",
274 (data->alarms >> (sattr->index + 1)) & 1);
275 default:
276 val = data->voltage[sattr->nr][sattr->index];
277 return sprintf(buf, "%d\n",
278 sattr->index ==
279 0 ? reg2vccp(val) : reg2vcc(val));
280 }
281}
282
283static ssize_t set_voltage(struct device *dev, struct device_attribute *attr,
284 const char *buf, size_t count)
285{
286
287 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
288 struct i2c_client *client = to_i2c_client(dev);
289 struct adt7475_data *data = i2c_get_clientdata(client);
290 unsigned char reg;
291 long val;
292
293 if (strict_strtol(buf, 10, &val))
294 return -EINVAL;
295
296 mutex_lock(&data->lock);
297
298 data->voltage[sattr->nr][sattr->index] =
299 sattr->index ? vcc2reg(val) : vccp2reg(val);
300
301 if (sattr->nr == MIN)
302 reg = VOLTAGE_MIN_REG(sattr->index);
303 else
304 reg = VOLTAGE_MAX_REG(sattr->index);
305
306 i2c_smbus_write_byte_data(client, reg,
307 data->voltage[sattr->nr][sattr->index] >> 2);
308 mutex_unlock(&data->lock);
309
310 return count;
311}
312
313static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
314 char *buf)
315{
316 struct adt7475_data *data = adt7475_update_device(dev);
317 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
318 int out;
319
320 switch (sattr->nr) {
321 case HYSTERSIS:
322 mutex_lock(&data->lock);
323 out = data->temp[sattr->nr][sattr->index];
324 if (sattr->index != 1)
325 out = (out >> 4) & 0xF;
326 else
327 out = (out & 0xF);
328 /* Show the value as an absolute number tied to
329 * THERM */
330 out = reg2temp(data, data->temp[THERM][sattr->index]) -
331 out * 1000;
332 mutex_unlock(&data->lock);
333 break;
334
335 case OFFSET:
336 /* Offset is always 2's complement, regardless of the
337 * setting in CONFIG5 */
338 mutex_lock(&data->lock);
339 out = (s8)data->temp[sattr->nr][sattr->index];
340 if (data->config5 & CONFIG5_TEMPOFFSET)
341 out *= 1000;
342 else
343 out *= 500;
344 mutex_unlock(&data->lock);
345 break;
346
347 case ALARM:
348 out = (data->alarms >> (sattr->index + 4)) & 1;
349 break;
350
351 case FAULT:
352 /* Note - only for remote1 and remote2 */
353 out = data->alarms & (sattr->index ? 0x8000 : 0x4000);
354 out = out ? 0 : 1;
355 break;
356
357 default:
358 /* All other temp values are in the configured format */
359 out = reg2temp(data, data->temp[sattr->nr][sattr->index]);
360 }
361
362 return sprintf(buf, "%d\n", out);
363}
364
365static ssize_t set_temp(struct device *dev, struct device_attribute *attr,
366 const char *buf, size_t count)
367{
368 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
369 struct i2c_client *client = to_i2c_client(dev);
370 struct adt7475_data *data = i2c_get_clientdata(client);
371 unsigned char reg = 0;
372 u8 out;
373 int temp;
374 long val;
375
376 if (strict_strtol(buf, 10, &val))
377 return -EINVAL;
378
379 mutex_lock(&data->lock);
380
381 /* We need the config register in all cases for temp <-> reg conv. */
382 data->config5 = adt7475_read(REG_CONFIG5);
383
384 switch (sattr->nr) {
385 case OFFSET:
386 if (data->config5 & CONFIG5_TEMPOFFSET) {
387 val = SENSORS_LIMIT(val, -63000, 127000);
388 out = data->temp[OFFSET][sattr->index] = val / 1000;
389 } else {
390 val = SENSORS_LIMIT(val, -63000, 64000);
391 out = data->temp[OFFSET][sattr->index] = val / 500;
392 }
393 break;
394
395 case HYSTERSIS:
396 /* The value will be given as an absolute value, turn it
397 into an offset based on THERM */
398
399 /* Read fresh THERM and HYSTERSIS values from the chip */
400 data->temp[THERM][sattr->index] =
401 adt7475_read(TEMP_THERM_REG(sattr->index)) << 2;
402 adt7475_read_hystersis(client);
403
404 temp = reg2temp(data, data->temp[THERM][sattr->index]);
405 val = SENSORS_LIMIT(val, temp - 15000, temp);
406 val = (temp - val) / 1000;
407
408 if (sattr->index != 1) {
409 data->temp[HYSTERSIS][sattr->index] &= 0xF0;
410 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF) << 4;
411 } else {
412 data->temp[HYSTERSIS][sattr->index] &= 0x0F;
413 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF);
414 }
415
416 out = data->temp[HYSTERSIS][sattr->index];
417 break;
418
419 default:
420 data->temp[sattr->nr][sattr->index] = temp2reg(data, val);
421
422 /* We maintain an extra 2 digits of precision for simplicity
423 * - shift those back off before writing the value */
424 out = (u8) (data->temp[sattr->nr][sattr->index] >> 2);
425 }
426
427 switch (sattr->nr) {
428 case MIN:
429 reg = TEMP_MIN_REG(sattr->index);
430 break;
431 case MAX:
432 reg = TEMP_MAX_REG(sattr->index);
433 break;
434 case OFFSET:
435 reg = TEMP_OFFSET_REG(sattr->index);
436 break;
437 case AUTOMIN:
438 reg = TEMP_TMIN_REG(sattr->index);
439 break;
440 case THERM:
441 reg = TEMP_THERM_REG(sattr->index);
442 break;
443 case HYSTERSIS:
444 if (sattr->index != 2)
445 reg = REG_REMOTE1_HYSTERSIS;
446 else
447 reg = REG_REMOTE2_HYSTERSIS;
448
449 break;
450 }
451
452 i2c_smbus_write_byte_data(client, reg, out);
453
454 mutex_unlock(&data->lock);
455 return count;
456}
457
458/* Table of autorange values - the user will write the value in millidegrees,
459 and we'll convert it */
460static const int autorange_table[] = {
461 2000, 2500, 3330, 4000, 5000, 6670, 8000,
462 10000, 13330, 16000, 20000, 26670, 32000, 40000,
463 53330, 80000
464};
465
466static ssize_t show_point2(struct device *dev, struct device_attribute *attr,
467 char *buf)
468{
469 struct adt7475_data *data = adt7475_update_device(dev);
470 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
471 int out, val;
472
473 mutex_lock(&data->lock);
474 out = (data->range[sattr->index] >> 4) & 0x0F;
475 val = reg2temp(data, data->temp[AUTOMIN][sattr->index]);
476 mutex_unlock(&data->lock);
477
478 return sprintf(buf, "%d\n", val + autorange_table[out]);
479}
480
481static ssize_t set_point2(struct device *dev, struct device_attribute *attr,
482 const char *buf, size_t count)
483{
484 struct i2c_client *client = to_i2c_client(dev);
485 struct adt7475_data *data = i2c_get_clientdata(client);
486 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
487 int temp;
488 long val;
489
490 if (strict_strtol(buf, 10, &val))
491 return -EINVAL;
492
493 mutex_lock(&data->lock);
494
495 /* Get a fresh copy of the needed registers */
496 data->config5 = adt7475_read(REG_CONFIG5);
497 data->temp[AUTOMIN][sattr->index] =
498 adt7475_read(TEMP_TMIN_REG(sattr->index)) << 2;
499 data->range[sattr->index] =
500 adt7475_read(TEMP_TRANGE_REG(sattr->index));
501
502 /* The user will write an absolute value, so subtract the start point
503 to figure the range */
504 temp = reg2temp(data, data->temp[AUTOMIN][sattr->index]);
505 val = SENSORS_LIMIT(val, temp + autorange_table[0],
506 temp + autorange_table[ARRAY_SIZE(autorange_table) - 1]);
507 val -= temp;
508
509 /* Find the nearest table entry to what the user wrote */
510 val = find_nearest(val, autorange_table, ARRAY_SIZE(autorange_table));
511
512 data->range[sattr->index] &= ~0xF0;
513 data->range[sattr->index] |= val << 4;
514
515 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
516 data->range[sattr->index]);
517
518 mutex_unlock(&data->lock);
519 return count;
520}
521
522static ssize_t show_tach(struct device *dev, struct device_attribute *attr,
523 char *buf)
524{
525 struct adt7475_data *data = adt7475_update_device(dev);
526 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
527 int out;
528
529 if (sattr->nr == ALARM)
530 out = (data->alarms >> (sattr->index + 10)) & 1;
531 else
532 out = tach2rpm(data->tach[sattr->nr][sattr->index]);
533
534 return sprintf(buf, "%d\n", out);
535}
536
537static ssize_t set_tach(struct device *dev, struct device_attribute *attr,
538 const char *buf, size_t count)
539{
540
541 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
542 struct i2c_client *client = to_i2c_client(dev);
543 struct adt7475_data *data = i2c_get_clientdata(client);
544 unsigned long val;
545
546 if (strict_strtoul(buf, 10, &val))
547 return -EINVAL;
548
549 mutex_lock(&data->lock);
550
551 data->tach[MIN][sattr->index] = rpm2tach(val);
552
553 adt7475_write_word(client, TACH_MIN_REG(sattr->index),
554 data->tach[MIN][sattr->index]);
555
556 mutex_unlock(&data->lock);
557 return count;
558}
559
560static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
561 char *buf)
562{
563 struct adt7475_data *data = adt7475_update_device(dev);
564 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
565
566 return sprintf(buf, "%d\n", data->pwm[sattr->nr][sattr->index]);
567}
568
569static ssize_t show_pwmchan(struct device *dev, struct device_attribute *attr,
570 char *buf)
571{
572 struct adt7475_data *data = adt7475_update_device(dev);
573 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
574
575 return sprintf(buf, "%d\n", data->pwmchan[sattr->index]);
576}
577
578static ssize_t show_pwmctrl(struct device *dev, struct device_attribute *attr,
579 char *buf)
580{
581 struct adt7475_data *data = adt7475_update_device(dev);
582 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
583
584 return sprintf(buf, "%d\n", data->pwmctl[sattr->index]);
585}
586
587static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
588 const char *buf, size_t count)
589{
590
591 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
592 struct i2c_client *client = to_i2c_client(dev);
593 struct adt7475_data *data = i2c_get_clientdata(client);
594 unsigned char reg = 0;
595 long val;
596
597 if (strict_strtol(buf, 10, &val))
598 return -EINVAL;
599
600 mutex_lock(&data->lock);
601
602 switch (sattr->nr) {
603 case INPUT:
604 /* Get a fresh value for CONTROL */
605 data->pwm[CONTROL][sattr->index] =
606 adt7475_read(PWM_CONFIG_REG(sattr->index));
607
608 /* If we are not in manual mode, then we shouldn't allow
609 * the user to set the pwm speed */
610 if (((data->pwm[CONTROL][sattr->index] >> 5) & 7) != 7) {
611 mutex_unlock(&data->lock);
612 return count;
613 }
614
615 reg = PWM_REG(sattr->index);
616 break;
617
618 case MIN:
619 reg = PWM_MIN_REG(sattr->index);
620 break;
621
622 case MAX:
623 reg = PWM_MAX_REG(sattr->index);
624 break;
625 }
626
627 data->pwm[sattr->nr][sattr->index] = SENSORS_LIMIT(val, 0, 0xFF);
628 i2c_smbus_write_byte_data(client, reg,
629 data->pwm[sattr->nr][sattr->index]);
630
631 mutex_unlock(&data->lock);
632
633 return count;
634}
635
636/* Called by set_pwmctrl and set_pwmchan */
637
638static int hw_set_pwm(struct i2c_client *client, int index,
639 unsigned int pwmctl, unsigned int pwmchan)
640{
641 struct adt7475_data *data = i2c_get_clientdata(client);
642 long val = 0;
643
644 switch (pwmctl) {
645 case 0:
646 val = 0x03; /* Run at full speed */
647 break;
648 case 1:
649 val = 0x07; /* Manual mode */
650 break;
651 case 2:
652 switch (pwmchan) {
653 case 1:
654 /* Remote1 controls PWM */
655 val = 0x00;
656 break;
657 case 2:
658 /* local controls PWM */
659 val = 0x01;
660 break;
661 case 4:
662 /* remote2 controls PWM */
663 val = 0x02;
664 break;
665 case 6:
666 /* local/remote2 control PWM */
667 val = 0x05;
668 break;
669 case 7:
670 /* All three control PWM */
671 val = 0x06;
672 break;
673 default:
674 return -EINVAL;
675 }
676 break;
677 default:
678 return -EINVAL;
679 }
680
681 data->pwmctl[index] = pwmctl;
682 data->pwmchan[index] = pwmchan;
683
684 data->pwm[CONTROL][index] &= ~0xE0;
685 data->pwm[CONTROL][index] |= (val & 7) << 5;
686
687 i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index),
688 data->pwm[CONTROL][index]);
689
690 return 0;
691}
692
693static ssize_t set_pwmchan(struct device *dev, struct device_attribute *attr,
694 const char *buf, size_t count)
695{
696 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
697 struct i2c_client *client = to_i2c_client(dev);
698 struct adt7475_data *data = i2c_get_clientdata(client);
699 int r;
700 long val;
701
702 if (strict_strtol(buf, 10, &val))
703 return -EINVAL;
704
705 mutex_lock(&data->lock);
706 /* Read Modify Write PWM values */
707 adt7475_read_pwm(client, sattr->index);
708 r = hw_set_pwm(client, sattr->index, data->pwmctl[sattr->index], val);
709 if (r)
710 count = r;
711 mutex_unlock(&data->lock);
712
713 return count;
714}
715
716static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr,
717 const char *buf, size_t count)
718{
719 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
720 struct i2c_client *client = to_i2c_client(dev);
721 struct adt7475_data *data = i2c_get_clientdata(client);
722 int r;
723 long val;
724
725 if (strict_strtol(buf, 10, &val))
726 return -EINVAL;
727
728 mutex_lock(&data->lock);
729 /* Read Modify Write PWM values */
730 adt7475_read_pwm(client, sattr->index);
731 r = hw_set_pwm(client, sattr->index, val, data->pwmchan[sattr->index]);
732 if (r)
733 count = r;
734 mutex_unlock(&data->lock);
735
736 return count;
737}
738
739/* List of frequencies for the PWM */
740static const int pwmfreq_table[] = {
741 11, 14, 22, 29, 35, 44, 58, 88
742};
743
744static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
745 char *buf)
746{
747 struct adt7475_data *data = adt7475_update_device(dev);
748 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
749
750 return sprintf(buf, "%d\n",
751 pwmfreq_table[data->range[sattr->index] & 7]);
752}
753
754static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
755 const char *buf, size_t count)
756{
757 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
758 struct i2c_client *client = to_i2c_client(dev);
759 struct adt7475_data *data = i2c_get_clientdata(client);
760 int out;
761 long val;
762
763 if (strict_strtol(buf, 10, &val))
764 return -EINVAL;
765
766 out = find_nearest(val, pwmfreq_table, ARRAY_SIZE(pwmfreq_table));
767
768 mutex_lock(&data->lock);
769
770 data->range[sattr->index] =
771 adt7475_read(TEMP_TRANGE_REG(sattr->index));
772 data->range[sattr->index] &= ~7;
773 data->range[sattr->index] |= out;
774
775 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
776 data->range[sattr->index]);
777
778 mutex_unlock(&data->lock);
779 return count;
780}
781
782static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 0);
783static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage,
784 set_voltage, MAX, 0);
785static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_voltage,
786 set_voltage, MIN, 0);
787static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0);
788static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_voltage, NULL, INPUT, 1);
789static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage,
790 set_voltage, MAX, 1);
791static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_voltage,
792 set_voltage, MIN, 1);
793static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_voltage, NULL, ALARM, 1);
794static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, INPUT, 0);
795static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, show_temp, NULL, ALARM, 0);
796static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_temp, NULL, FAULT, 0);
797static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
798 MAX, 0);
799static SENSOR_DEVICE_ATTR_2(temp1_min, S_IRUGO | S_IWUSR, show_temp, set_temp,
800 MIN, 0);
801static SENSOR_DEVICE_ATTR_2(temp1_offset, S_IRUGO | S_IWUSR, show_temp,
802 set_temp, OFFSET, 0);
803static SENSOR_DEVICE_ATTR_2(temp1_auto_point1_temp, S_IRUGO | S_IWUSR,
804 show_temp, set_temp, AUTOMIN, 0);
805static SENSOR_DEVICE_ATTR_2(temp1_auto_point2_temp, S_IRUGO | S_IWUSR,
806 show_point2, set_point2, 0, 0);
807static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
808 THERM, 0);
809static SENSOR_DEVICE_ATTR_2(temp1_crit_hyst, S_IRUGO | S_IWUSR, show_temp,
810 set_temp, HYSTERSIS, 0);
811static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, INPUT, 1);
812static SENSOR_DEVICE_ATTR_2(temp2_alarm, S_IRUGO, show_temp, NULL, ALARM, 1);
813static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
814 MAX, 1);
815static SENSOR_DEVICE_ATTR_2(temp2_min, S_IRUGO | S_IWUSR, show_temp, set_temp,
816 MIN, 1);
817static SENSOR_DEVICE_ATTR_2(temp2_offset, S_IRUGO | S_IWUSR, show_temp,
818 set_temp, OFFSET, 1);
819static SENSOR_DEVICE_ATTR_2(temp2_auto_point1_temp, S_IRUGO | S_IWUSR,
820 show_temp, set_temp, AUTOMIN, 1);
821static SENSOR_DEVICE_ATTR_2(temp2_auto_point2_temp, S_IRUGO | S_IWUSR,
822 show_point2, set_point2, 0, 1);
823static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
824 THERM, 1);
825static SENSOR_DEVICE_ATTR_2(temp2_crit_hyst, S_IRUGO | S_IWUSR, show_temp,
826 set_temp, HYSTERSIS, 1);
827static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, INPUT, 2);
828static SENSOR_DEVICE_ATTR_2(temp3_alarm, S_IRUGO, show_temp, NULL, ALARM, 2);
829static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_temp, NULL, FAULT, 2);
830static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
831 MAX, 2);
832static SENSOR_DEVICE_ATTR_2(temp3_min, S_IRUGO | S_IWUSR, show_temp, set_temp,
833 MIN, 2);
834static SENSOR_DEVICE_ATTR_2(temp3_offset, S_IRUGO | S_IWUSR, show_temp,
835 set_temp, OFFSET, 2);
836static SENSOR_DEVICE_ATTR_2(temp3_auto_point1_temp, S_IRUGO | S_IWUSR,
837 show_temp, set_temp, AUTOMIN, 2);
838static SENSOR_DEVICE_ATTR_2(temp3_auto_point2_temp, S_IRUGO | S_IWUSR,
839 show_point2, set_point2, 0, 2);
840static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
841 THERM, 2);
842static SENSOR_DEVICE_ATTR_2(temp3_crit_hyst, S_IRUGO | S_IWUSR, show_temp,
843 set_temp, HYSTERSIS, 2);
844static SENSOR_DEVICE_ATTR_2(fan1_input, S_IRUGO, show_tach, NULL, INPUT, 0);
845static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
846 MIN, 0);
847static SENSOR_DEVICE_ATTR_2(fan1_alarm, S_IRUGO, show_tach, NULL, ALARM, 0);
848static SENSOR_DEVICE_ATTR_2(fan2_input, S_IRUGO, show_tach, NULL, INPUT, 1);
849static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
850 MIN, 1);
851static SENSOR_DEVICE_ATTR_2(fan2_alarm, S_IRUGO, show_tach, NULL, ALARM, 1);
852static SENSOR_DEVICE_ATTR_2(fan3_input, S_IRUGO, show_tach, NULL, INPUT, 2);
853static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
854 MIN, 2);
855static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_tach, NULL, ALARM, 2);
856static SENSOR_DEVICE_ATTR_2(fan4_input, S_IRUGO, show_tach, NULL, INPUT, 3);
857static SENSOR_DEVICE_ATTR_2(fan4_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
858 MIN, 3);
859static SENSOR_DEVICE_ATTR_2(fan4_alarm, S_IRUGO, show_tach, NULL, ALARM, 3);
860static SENSOR_DEVICE_ATTR_2(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
861 0);
862static SENSOR_DEVICE_ATTR_2(pwm1_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
863 set_pwmfreq, INPUT, 0);
864static SENSOR_DEVICE_ATTR_2(pwm1_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
865 set_pwmctrl, INPUT, 0);
866static SENSOR_DEVICE_ATTR_2(pwm1_auto_channel_temp, S_IRUGO | S_IWUSR,
867 show_pwmchan, set_pwmchan, INPUT, 0);
868static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
869 set_pwm, MIN, 0);
870static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
871 set_pwm, MAX, 0);
872static SENSOR_DEVICE_ATTR_2(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
873 1);
874static SENSOR_DEVICE_ATTR_2(pwm2_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
875 set_pwmfreq, INPUT, 1);
876static SENSOR_DEVICE_ATTR_2(pwm2_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
877 set_pwmctrl, INPUT, 1);
878static SENSOR_DEVICE_ATTR_2(pwm2_auto_channel_temp, S_IRUGO | S_IWUSR,
879 show_pwmchan, set_pwmchan, INPUT, 1);
880static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
881 set_pwm, MIN, 1);
882static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
883 set_pwm, MAX, 1);
884static SENSOR_DEVICE_ATTR_2(pwm3, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
885 2);
886static SENSOR_DEVICE_ATTR_2(pwm3_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
887 set_pwmfreq, INPUT, 2);
888static SENSOR_DEVICE_ATTR_2(pwm3_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
889 set_pwmctrl, INPUT, 2);
890static SENSOR_DEVICE_ATTR_2(pwm3_auto_channel_temp, S_IRUGO | S_IWUSR,
891 show_pwmchan, set_pwmchan, INPUT, 2);
892static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
893 set_pwm, MIN, 2);
894static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
895 set_pwm, MAX, 2);
896
897static struct attribute *adt7475_attrs[] = {
898 &sensor_dev_attr_in1_input.dev_attr.attr,
899 &sensor_dev_attr_in1_max.dev_attr.attr,
900 &sensor_dev_attr_in1_min.dev_attr.attr,
901 &sensor_dev_attr_in1_alarm.dev_attr.attr,
902 &sensor_dev_attr_in2_input.dev_attr.attr,
903 &sensor_dev_attr_in2_max.dev_attr.attr,
904 &sensor_dev_attr_in2_min.dev_attr.attr,
905 &sensor_dev_attr_in2_alarm.dev_attr.attr,
906 &sensor_dev_attr_temp1_input.dev_attr.attr,
907 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
908 &sensor_dev_attr_temp1_fault.dev_attr.attr,
909 &sensor_dev_attr_temp1_max.dev_attr.attr,
910 &sensor_dev_attr_temp1_min.dev_attr.attr,
911 &sensor_dev_attr_temp1_offset.dev_attr.attr,
912 &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr,
913 &sensor_dev_attr_temp1_auto_point2_temp.dev_attr.attr,
914 &sensor_dev_attr_temp1_crit.dev_attr.attr,
915 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
916 &sensor_dev_attr_temp2_input.dev_attr.attr,
917 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
918 &sensor_dev_attr_temp2_max.dev_attr.attr,
919 &sensor_dev_attr_temp2_min.dev_attr.attr,
920 &sensor_dev_attr_temp2_offset.dev_attr.attr,
921 &sensor_dev_attr_temp2_auto_point1_temp.dev_attr.attr,
922 &sensor_dev_attr_temp2_auto_point2_temp.dev_attr.attr,
923 &sensor_dev_attr_temp2_crit.dev_attr.attr,
924 &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr,
925 &sensor_dev_attr_temp3_input.dev_attr.attr,
926 &sensor_dev_attr_temp3_fault.dev_attr.attr,
927 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
928 &sensor_dev_attr_temp3_max.dev_attr.attr,
929 &sensor_dev_attr_temp3_min.dev_attr.attr,
930 &sensor_dev_attr_temp3_offset.dev_attr.attr,
931 &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr,
932 &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr,
933 &sensor_dev_attr_temp3_crit.dev_attr.attr,
934 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr,
935 &sensor_dev_attr_fan1_input.dev_attr.attr,
936 &sensor_dev_attr_fan1_min.dev_attr.attr,
937 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
938 &sensor_dev_attr_fan2_input.dev_attr.attr,
939 &sensor_dev_attr_fan2_min.dev_attr.attr,
940 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
941 &sensor_dev_attr_fan3_input.dev_attr.attr,
942 &sensor_dev_attr_fan3_min.dev_attr.attr,
943 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
944 &sensor_dev_attr_fan4_input.dev_attr.attr,
945 &sensor_dev_attr_fan4_min.dev_attr.attr,
946 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
947 &sensor_dev_attr_pwm1.dev_attr.attr,
948 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
949 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
950 &sensor_dev_attr_pwm1_auto_channel_temp.dev_attr.attr,
951 &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
952 &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr,
953 &sensor_dev_attr_pwm2.dev_attr.attr,
954 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
955 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
956 &sensor_dev_attr_pwm2_auto_channel_temp.dev_attr.attr,
957 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr,
958 &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr,
959 &sensor_dev_attr_pwm3.dev_attr.attr,
960 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
961 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
962 &sensor_dev_attr_pwm3_auto_channel_temp.dev_attr.attr,
963 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr,
964 &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr,
965 NULL,
966};
967
968struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs };
969
970static int adt7475_detect(struct i2c_client *client, int kind,
971 struct i2c_board_info *info)
972{
973 struct i2c_adapter *adapter = client->adapter;
974
975 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
976 return -ENODEV;
977
978 if (kind <= 0) {
979 if (adt7475_read(REG_VENDID) != 0x41 ||
980 adt7475_read(REG_DEVID) != 0x75) {
981 dev_err(&adapter->dev,
982 "Couldn't detect a adt7475 part at 0x%02x\n",
983 (unsigned int)client->addr);
984 return -ENODEV;
985 }
986 }
987
988 strlcpy(info->type, adt7475_id[0].name, I2C_NAME_SIZE);
989
990 return 0;
991}
992
993static int adt7475_probe(struct i2c_client *client,
994 const struct i2c_device_id *id)
995{
996 struct adt7475_data *data;
997 int i, ret = 0;
998
999 data = kzalloc(sizeof(*data), GFP_KERNEL);
1000 if (data == NULL)
1001 return -ENOMEM;
1002
1003 mutex_init(&data->lock);
1004 i2c_set_clientdata(client, data);
1005
1006 /* Call adt7475_read_pwm for all pwm's as this will reprogram any
1007 pwm's which are disabled to manual mode with 0% duty cycle */
1008 for (i = 0; i < ADT7475_PWM_COUNT; i++)
1009 adt7475_read_pwm(client, i);
1010
1011 ret = sysfs_create_group(&client->dev.kobj, &adt7475_attr_group);
1012 if (ret)
1013 goto efree;
1014
1015 data->hwmon_dev = hwmon_device_register(&client->dev);
1016 if (IS_ERR(data->hwmon_dev)) {
1017 ret = PTR_ERR(data->hwmon_dev);
1018 goto eremove;
1019 }
1020
1021 return 0;
1022
1023eremove:
1024 sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
1025efree:
1026 kfree(data);
1027 return ret;
1028}
1029
1030static int adt7475_remove(struct i2c_client *client)
1031{
1032 struct adt7475_data *data = i2c_get_clientdata(client);
1033
1034 hwmon_device_unregister(data->hwmon_dev);
1035 sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
1036 kfree(data);
1037
1038 return 0;
1039}
1040
1041static struct i2c_driver adt7475_driver = {
1042 .class = I2C_CLASS_HWMON,
1043 .driver = {
1044 .name = "adt7475",
1045 },
1046 .probe = adt7475_probe,
1047 .remove = adt7475_remove,
1048 .id_table = adt7475_id,
1049 .detect = adt7475_detect,
1050 .address_data = &addr_data,
1051};
1052
1053static void adt7475_read_hystersis(struct i2c_client *client)
1054{
1055 struct adt7475_data *data = i2c_get_clientdata(client);
1056
1057 data->temp[HYSTERSIS][0] = (u16) adt7475_read(REG_REMOTE1_HYSTERSIS);
1058 data->temp[HYSTERSIS][1] = data->temp[HYSTERSIS][0];
1059 data->temp[HYSTERSIS][2] = (u16) adt7475_read(REG_REMOTE2_HYSTERSIS);
1060}
1061
1062static void adt7475_read_pwm(struct i2c_client *client, int index)
1063{
1064 struct adt7475_data *data = i2c_get_clientdata(client);
1065 unsigned int v;
1066
1067 data->pwm[CONTROL][index] = adt7475_read(PWM_CONFIG_REG(index));
1068
1069 /* Figure out the internal value for pwmctrl and pwmchan
1070 based on the current settings */
1071 v = (data->pwm[CONTROL][index] >> 5) & 7;
1072
1073 if (v == 3)
1074 data->pwmctl[index] = 0;
1075 else if (v == 7)
1076 data->pwmctl[index] = 1;
1077 else if (v == 4) {
1078 /* The fan is disabled - we don't want to
1079 support that, so change to manual mode and
1080 set the duty cycle to 0 instead
1081 */
1082 data->pwm[INPUT][index] = 0;
1083 data->pwm[CONTROL][index] &= ~0xE0;
1084 data->pwm[CONTROL][index] |= (7 << 5);
1085
1086 i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index),
1087 data->pwm[INPUT][index]);
1088
1089 i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index),
1090 data->pwm[CONTROL][index]);
1091
1092 data->pwmctl[index] = 1;
1093 } else {
1094 data->pwmctl[index] = 2;
1095
1096 switch (v) {
1097 case 0:
1098 data->pwmchan[index] = 1;
1099 break;
1100 case 1:
1101 data->pwmchan[index] = 2;
1102 break;
1103 case 2:
1104 data->pwmchan[index] = 4;
1105 break;
1106 case 5:
1107 data->pwmchan[index] = 6;
1108 break;
1109 case 6:
1110 data->pwmchan[index] = 7;
1111 break;
1112 }
1113 }
1114}
1115
1116static struct adt7475_data *adt7475_update_device(struct device *dev)
1117{
1118 struct i2c_client *client = to_i2c_client(dev);
1119 struct adt7475_data *data = i2c_get_clientdata(client);
1120 u8 ext;
1121 int i;
1122
1123 mutex_lock(&data->lock);
1124
1125 /* Measurement values update every 2 seconds */
1126 if (time_after(jiffies, data->measure_updated + HZ * 2) ||
1127 !data->valid) {
1128 data->alarms = adt7475_read(REG_STATUS2) << 8;
1129 data->alarms |= adt7475_read(REG_STATUS1);
1130
1131 ext = adt7475_read(REG_EXTEND1);
1132 for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++)
1133 data->voltage[INPUT][i] =
1134 (adt7475_read(VOLTAGE_REG(i)) << 2) |
1135 ((ext >> ((i + 1) * 2)) & 3);
1136
1137 ext = adt7475_read(REG_EXTEND2);
1138 for (i = 0; i < ADT7475_TEMP_COUNT; i++)
1139 data->temp[INPUT][i] =
1140 (adt7475_read(TEMP_REG(i)) << 2) |
1141 ((ext >> ((i + 1) * 2)) & 3);
1142
1143 for (i = 0; i < ADT7475_TACH_COUNT; i++)
1144 data->tach[INPUT][i] =
1145 adt7475_read_word(client, TACH_REG(i));
1146
1147 /* Updated by hw when in auto mode */
1148 for (i = 0; i < ADT7475_PWM_COUNT; i++)
1149 data->pwm[INPUT][i] = adt7475_read(PWM_REG(i));
1150
1151 data->measure_updated = jiffies;
1152 }
1153
1154 /* Limits and settings, should never change update every 60 seconds */
1155 if (time_after(jiffies, data->limits_updated + HZ * 2) ||
1156 !data->valid) {
1157 data->config5 = adt7475_read(REG_CONFIG5);
1158
1159 for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) {
1160 /* Adjust values so they match the input precision */
1161 data->voltage[MIN][i] =
1162 adt7475_read(VOLTAGE_MIN_REG(i)) << 2;
1163 data->voltage[MAX][i] =
1164 adt7475_read(VOLTAGE_MAX_REG(i)) << 2;
1165 }
1166
1167 for (i = 0; i < ADT7475_TEMP_COUNT; i++) {
1168 /* Adjust values so they match the input precision */
1169 data->temp[MIN][i] =
1170 adt7475_read(TEMP_MIN_REG(i)) << 2;
1171 data->temp[MAX][i] =
1172 adt7475_read(TEMP_MAX_REG(i)) << 2;
1173 data->temp[AUTOMIN][i] =
1174 adt7475_read(TEMP_TMIN_REG(i)) << 2;
1175 data->temp[THERM][i] =
1176 adt7475_read(TEMP_THERM_REG(i)) << 2;
1177 data->temp[OFFSET][i] =
1178 adt7475_read(TEMP_OFFSET_REG(i));
1179 }
1180 adt7475_read_hystersis(client);
1181
1182 for (i = 0; i < ADT7475_TACH_COUNT; i++)
1183 data->tach[MIN][i] =
1184 adt7475_read_word(client, TACH_MIN_REG(i));
1185
1186 for (i = 0; i < ADT7475_PWM_COUNT; i++) {
1187 data->pwm[MAX][i] = adt7475_read(PWM_MAX_REG(i));
1188 data->pwm[MIN][i] = adt7475_read(PWM_MIN_REG(i));
1189 /* Set the channel and control information */
1190 adt7475_read_pwm(client, i);
1191 }
1192
1193 data->range[0] = adt7475_read(TEMP_TRANGE_REG(0));
1194 data->range[1] = adt7475_read(TEMP_TRANGE_REG(1));
1195 data->range[2] = adt7475_read(TEMP_TRANGE_REG(2));
1196
1197 data->limits_updated = jiffies;
1198 data->valid = 1;
1199 }
1200
1201 mutex_unlock(&data->lock);
1202
1203 return data;
1204}
1205
1206static int __init sensors_adt7475_init(void)
1207{
1208 return i2c_add_driver(&adt7475_driver);
1209}
1210
1211static void __exit sensors_adt7475_exit(void)
1212{
1213 i2c_del_driver(&adt7475_driver);
1214}
1215
1216MODULE_AUTHOR("Advanced Micro Devices, Inc");
1217MODULE_DESCRIPTION("adt7475 driver");
1218MODULE_LICENSE("GPL");
1219
1220module_init(sensors_adt7475_init);
1221module_exit(sensors_adt7475_exit);
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index dca47a591baf..e30186236588 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -590,6 +590,11 @@ static ssize_t applesmc_light_show(struct device *dev,
590 } 590 }
591 591
592 ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length); 592 ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length);
593 /* newer macbooks report a single 10-bit bigendian value */
594 if (data_length == 10) {
595 left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2;
596 goto out;
597 }
593 left = buffer[2]; 598 left = buffer[2];
594 if (ret) 599 if (ret)
595 goto out; 600 goto out;
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
index bf8d40580577..03705240000f 100644
--- a/drivers/hwmon/hp_accel.c
+++ b/drivers/hwmon/hp_accel.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2007-2008 Yan Burman 4 * Copyright (C) 2007-2008 Yan Burman
5 * Copyright (C) 2008 Eric Piel 5 * Copyright (C) 2008 Eric Piel
6 * Copyright (C) 2008 Pavel Machek 6 * Copyright (C) 2008-2009 Pavel Machek
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
36#include <linux/freezer.h> 36#include <linux/freezer.h>
37#include <linux/version.h> 37#include <linux/version.h>
38#include <linux/uaccess.h> 38#include <linux/uaccess.h>
39#include <linux/leds.h>
39#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_drivers.h>
40#include <asm/atomic.h> 41#include <asm/atomic.h>
41#include "lis3lv02d.h" 42#include "lis3lv02d.h"
@@ -43,6 +44,36 @@
43#define DRIVER_NAME "lis3lv02d" 44#define DRIVER_NAME "lis3lv02d"
44#define ACPI_MDPS_CLASS "accelerometer" 45#define ACPI_MDPS_CLASS "accelerometer"
45 46
47/* Delayed LEDs infrastructure ------------------------------------ */
48
49/* Special LED class that can defer work */
50struct delayed_led_classdev {
51 struct led_classdev led_classdev;
52 struct work_struct work;
53 enum led_brightness new_brightness;
54
55 unsigned int led; /* For driver */
56 void (*set_brightness)(struct delayed_led_classdev *data, enum led_brightness value);
57};
58
59static inline void delayed_set_status_worker(struct work_struct *work)
60{
61 struct delayed_led_classdev *data =
62 container_of(work, struct delayed_led_classdev, work);
63
64 data->set_brightness(data, data->new_brightness);
65}
66
67static inline void delayed_sysfs_set(struct led_classdev *led_cdev,
68 enum led_brightness brightness)
69{
70 struct delayed_led_classdev *data = container_of(led_cdev,
71 struct delayed_led_classdev, led_classdev);
72 data->new_brightness = brightness;
73 schedule_work(&data->work);
74}
75
76/* HP-specific accelerometer driver ------------------------------------ */
46 77
47/* For automatic insertion of the module */ 78/* For automatic insertion of the module */
48static struct acpi_device_id lis3lv02d_device_ids[] = { 79static struct acpi_device_id lis3lv02d_device_ids[] = {
@@ -154,10 +185,33 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
154 */ 185 */
155}; 186};
156 187
188static void hpled_set(struct delayed_led_classdev *led_cdev, enum led_brightness value)
189{
190 acpi_handle handle = adev.device->handle;
191 unsigned long long ret; /* Not used when writing */
192 union acpi_object in_obj[1];
193 struct acpi_object_list args = { 1, in_obj };
194
195 in_obj[0].type = ACPI_TYPE_INTEGER;
196 in_obj[0].integer.value = !!value;
197
198 acpi_evaluate_integer(handle, "ALED", &args, &ret);
199}
200
201static struct delayed_led_classdev hpled_led = {
202 .led_classdev = {
203 .name = "hp::hddprotect",
204 .default_trigger = "none",
205 .brightness_set = delayed_sysfs_set,
206 .flags = LED_CORE_SUSPENDRESUME,
207 },
208 .set_brightness = hpled_set,
209};
157 210
158static int lis3lv02d_add(struct acpi_device *device) 211static int lis3lv02d_add(struct acpi_device *device)
159{ 212{
160 u8 val; 213 u8 val;
214 int ret;
161 215
162 if (!device) 216 if (!device)
163 return -EINVAL; 217 return -EINVAL;
@@ -183,7 +237,19 @@ static int lis3lv02d_add(struct acpi_device *device)
183 adev.ac = lis3lv02d_axis_normal; 237 adev.ac = lis3lv02d_axis_normal;
184 } 238 }
185 239
186 return lis3lv02d_init_device(&adev); 240 INIT_WORK(&hpled_led.work, delayed_set_status_worker);
241 ret = led_classdev_register(NULL, &hpled_led.led_classdev);
242 if (ret)
243 return ret;
244
245 ret = lis3lv02d_init_device(&adev);
246 if (ret) {
247 flush_work(&hpled_led.work);
248 led_classdev_unregister(&hpled_led.led_classdev);
249 return ret;
250 }
251
252 return ret;
187} 253}
188 254
189static int lis3lv02d_remove(struct acpi_device *device, int type) 255static int lis3lv02d_remove(struct acpi_device *device, int type)
@@ -194,6 +260,9 @@ static int lis3lv02d_remove(struct acpi_device *device, int type)
194 lis3lv02d_joystick_disable(); 260 lis3lv02d_joystick_disable();
195 lis3lv02d_poweroff(device->handle); 261 lis3lv02d_poweroff(device->handle);
196 262
263 flush_work(&hpled_led.work);
264 led_classdev_unregister(&hpled_led.led_classdev);
265
197 return lis3lv02d_remove_fs(); 266 return lis3lv02d_remove_fs();
198} 267}
199 268
@@ -256,7 +325,7 @@ static void __exit lis3lv02d_exit_module(void)
256 acpi_bus_unregister_driver(&lis3lv02d_driver); 325 acpi_bus_unregister_driver(&lis3lv02d_driver);
257} 326}
258 327
259MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS"); 328MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS and support for disk protection LED.");
260MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek"); 329MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
261MODULE_LICENSE("GPL"); 330MODULE_LICENSE("GPL");
262 331
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index bd2bde0ef95e..1fe995111841 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -31,6 +31,7 @@
31#include <linux/hwmon-sysfs.h> 31#include <linux/hwmon-sysfs.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <asm/processor.h>
34 35
35#define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000) 36#define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000)
36#define REG_TEMP 0xe4 37#define REG_TEMP 0xe4
@@ -47,6 +48,8 @@ struct k8temp_data {
47 /* registers values */ 48 /* registers values */
48 u8 sensorsp; /* sensor presence bits - SEL_CORE & SEL_PLACE */ 49 u8 sensorsp; /* sensor presence bits - SEL_CORE & SEL_PLACE */
49 u32 temp[2][2]; /* core, place */ 50 u32 temp[2][2]; /* core, place */
51 u8 swap_core_select; /* meaning of SEL_CORE is inverted */
52 u32 temp_offset;
50}; 53};
51 54
52static struct k8temp_data *k8temp_update_device(struct device *dev) 55static struct k8temp_data *k8temp_update_device(struct device *dev)
@@ -114,10 +117,15 @@ static ssize_t show_temp(struct device *dev,
114 to_sensor_dev_attr_2(devattr); 117 to_sensor_dev_attr_2(devattr);
115 int core = attr->nr; 118 int core = attr->nr;
116 int place = attr->index; 119 int place = attr->index;
120 int temp;
117 struct k8temp_data *data = k8temp_update_device(dev); 121 struct k8temp_data *data = k8temp_update_device(dev);
118 122
119 return sprintf(buf, "%d\n", 123 if (data->swap_core_select)
120 TEMP_FROM_REG(data->temp[core][place])); 124 core = core ? 0 : 1;
125
126 temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
127
128 return sprintf(buf, "%d\n", temp);
121} 129}
122 130
123/* core, place */ 131/* core, place */
@@ -141,20 +149,49 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
141 int err; 149 int err;
142 u8 scfg; 150 u8 scfg;
143 u32 temp; 151 u32 temp;
152 u8 model, stepping;
144 struct k8temp_data *data; 153 struct k8temp_data *data;
145 u32 cpuid = cpuid_eax(1);
146
147 /* this feature should be available since SH-C0 core */
148 if ((cpuid == 0xf40) || (cpuid == 0xf50) || (cpuid == 0xf51)) {
149 err = -ENODEV;
150 goto exit;
151 }
152 154
153 if (!(data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL))) { 155 if (!(data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL))) {
154 err = -ENOMEM; 156 err = -ENOMEM;
155 goto exit; 157 goto exit;
156 } 158 }
157 159
160 model = boot_cpu_data.x86_model;
161 stepping = boot_cpu_data.x86_mask;
162
163 switch (boot_cpu_data.x86) {
164 case 0xf:
165 /* feature available since SH-C0, exclude older revisions */
166 if (((model == 4) && (stepping == 0)) ||
167 ((model == 5) && (stepping <= 1))) {
168 err = -ENODEV;
169 goto exit_free;
170 }
171
172 /*
173 * AMD NPT family 0fh, i.e. RevF and RevG:
174 * meaning of SEL_CORE bit is inverted
175 */
176 if (model >= 0x40) {
177 data->swap_core_select = 1;
178 dev_warn(&pdev->dev, "Temperature readouts might be "
179 "wrong - check erratum #141\n");
180 }
181
182 if ((model >= 0x69) &&
183 !(model == 0xc1 || model == 0x6c || model == 0x7c)) {
184 /*
185 * RevG desktop CPUs (i.e. no socket S1G1 parts)
186 * need additional offset, otherwise reported
187 * temperature is below ambient temperature
188 */
189 data->temp_offset = 21000;
190 }
191
192 break;
193 }
194
158 pci_read_config_byte(pdev, REG_TEMP, &scfg); 195 pci_read_config_byte(pdev, REG_TEMP, &scfg);
159 scfg &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */ 196 scfg &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */
160 pci_write_config_byte(pdev, REG_TEMP, scfg); 197 pci_write_config_byte(pdev, REG_TEMP, scfg);
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 59c3d23f5bdc..b9bef04b7be4 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -139,15 +139,4 @@ config SENSORS_TSL2550
139 This driver can also be built as a module. If so, the module 139 This driver can also be built as a module. If so, the module
140 will be called tsl2550. 140 will be called tsl2550.
141 141
142config MCU_MPC8349EMITX
143 tristate "MPC8349E-mITX MCU driver"
144 depends on I2C && PPC_83xx
145 select GENERIC_GPIO
146 select ARCH_REQUIRE_GPIOLIB
147 help
148 Say Y here to enable soft power-off functionality on the Freescale
149 boards with the MPC8349E-mITX-compatible MCU chips. This driver will
150 also register MCU GPIOs with the generic GPIO API, so you'll able
151 to use MCU pins as GPIOs.
152
153endmenu 142endmenu
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 83accaaf8164..00fcb5193ac2 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
19obj-$(CONFIG_PCF8575) += pcf8575.o 19obj-$(CONFIG_PCF8575) += pcf8575.o
20obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 20obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
21obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o 21obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
22obj-$(CONFIG_MCU_MPC8349EMITX) += mcu_mpc8349emitx.o
23 22
24ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) 23ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
25EXTRA_CFLAGS += -DDEBUG 24EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/i2c/chips/mcu_mpc8349emitx.c b/drivers/i2c/chips/mcu_mpc8349emitx.c
deleted file mode 100644
index 82a9bcb858b6..000000000000
--- a/drivers/i2c/chips/mcu_mpc8349emitx.c
+++ /dev/null
@@ -1,209 +0,0 @@
1/*
2 * Power Management and GPIO expander driver for MPC8349E-mITX-compatible MCU
3 *
4 * Copyright (c) 2008 MontaVista Software, Inc.
5 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/device.h>
18#include <linux/mutex.h>
19#include <linux/i2c.h>
20#include <linux/gpio.h>
21#include <linux/of.h>
22#include <linux/of_gpio.h>
23#include <asm/prom.h>
24#include <asm/machdep.h>
25
26/*
27 * I don't have specifications for the MCU firmware, I found this register
28 * and bits positions by the trial&error method.
29 */
30#define MCU_REG_CTRL 0x20
31#define MCU_CTRL_POFF 0x40
32
33#define MCU_NUM_GPIO 2
34
35struct mcu {
36 struct mutex lock;
37 struct device_node *np;
38 struct i2c_client *client;
39 struct of_gpio_chip of_gc;
40 u8 reg_ctrl;
41};
42
43static struct mcu *glob_mcu;
44
45static void mcu_power_off(void)
46{
47 struct mcu *mcu = glob_mcu;
48
49 pr_info("Sending power-off request to the MCU...\n");
50 mutex_lock(&mcu->lock);
51 i2c_smbus_write_byte_data(glob_mcu->client, MCU_REG_CTRL,
52 mcu->reg_ctrl | MCU_CTRL_POFF);
53 mutex_unlock(&mcu->lock);
54}
55
56static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
57{
58 struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
59 struct mcu *mcu = container_of(of_gc, struct mcu, of_gc);
60 u8 bit = 1 << (4 + gpio);
61
62 mutex_lock(&mcu->lock);
63 if (val)
64 mcu->reg_ctrl &= ~bit;
65 else
66 mcu->reg_ctrl |= bit;
67
68 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, mcu->reg_ctrl);
69 mutex_unlock(&mcu->lock);
70}
71
72static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
73{
74 mcu_gpio_set(gc, gpio, val);
75 return 0;
76}
77
78static int mcu_gpiochip_add(struct mcu *mcu)
79{
80 struct device_node *np;
81 struct of_gpio_chip *of_gc = &mcu->of_gc;
82 struct gpio_chip *gc = &of_gc->gc;
83 int ret;
84
85 np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx");
86 if (!np)
87 return -ENODEV;
88
89 gc->owner = THIS_MODULE;
90 gc->label = np->full_name;
91 gc->can_sleep = 1;
92 gc->ngpio = MCU_NUM_GPIO;
93 gc->base = -1;
94 gc->set = mcu_gpio_set;
95 gc->direction_output = mcu_gpio_dir_out;
96 of_gc->gpio_cells = 2;
97 of_gc->xlate = of_gpio_simple_xlate;
98
99 np->data = of_gc;
100 mcu->np = np;
101
102 /*
103 * We don't want to lose the node, its ->data and ->full_name...
104 * So, if succeeded, we don't put the node here.
105 */
106 ret = gpiochip_add(gc);
107 if (ret)
108 of_node_put(np);
109 return ret;
110}
111
112static int mcu_gpiochip_remove(struct mcu *mcu)
113{
114 int ret;
115
116 ret = gpiochip_remove(&mcu->of_gc.gc);
117 if (ret)
118 return ret;
119 of_node_put(mcu->np);
120
121 return 0;
122}
123
124static int __devinit mcu_probe(struct i2c_client *client,
125 const struct i2c_device_id *id)
126{
127 struct mcu *mcu;
128 int ret;
129
130 mcu = kzalloc(sizeof(*mcu), GFP_KERNEL);
131 if (!mcu)
132 return -ENOMEM;
133
134 mutex_init(&mcu->lock);
135 mcu->client = client;
136 i2c_set_clientdata(client, mcu);
137
138 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL);
139 if (ret < 0)
140 goto err;
141 mcu->reg_ctrl = ret;
142
143 ret = mcu_gpiochip_add(mcu);
144 if (ret)
145 goto err;
146
147 /* XXX: this is potentially racy, but there is no lock for ppc_md */
148 if (!ppc_md.power_off) {
149 glob_mcu = mcu;
150 ppc_md.power_off = mcu_power_off;
151 dev_info(&client->dev, "will provide power-off service\n");
152 }
153
154 return 0;
155err:
156 kfree(mcu);
157 return ret;
158}
159
160static int __devexit mcu_remove(struct i2c_client *client)
161{
162 struct mcu *mcu = i2c_get_clientdata(client);
163 int ret;
164
165 if (glob_mcu == mcu) {
166 ppc_md.power_off = NULL;
167 glob_mcu = NULL;
168 }
169
170 ret = mcu_gpiochip_remove(mcu);
171 if (ret)
172 return ret;
173 i2c_set_clientdata(client, NULL);
174 kfree(mcu);
175 return 0;
176}
177
178static const struct i2c_device_id mcu_ids[] = {
179 { "mcu-mpc8349emitx", },
180 {},
181};
182MODULE_DEVICE_TABLE(i2c, mcu_ids);
183
184static struct i2c_driver mcu_driver = {
185 .driver = {
186 .name = "mcu-mpc8349emitx",
187 .owner = THIS_MODULE,
188 },
189 .probe = mcu_probe,
190 .remove = __devexit_p(mcu_remove),
191 .id_table = mcu_ids,
192};
193
194static int __init mcu_init(void)
195{
196 return i2c_add_driver(&mcu_driver);
197}
198module_init(mcu_init);
199
200static void __exit mcu_exit(void)
201{
202 i2c_del_driver(&mcu_driver);
203}
204module_exit(mcu_exit);
205
206MODULE_DESCRIPTION("Power Management and GPIO expander driver for "
207 "MPC8349E-mITX-compatible MCU");
208MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
209MODULE_LICENSE("GPL");
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 3f9503867e6b..b1c6f68d98ce 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -701,11 +701,6 @@ config BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
701 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX 701 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX
702endchoice 702endchoice
703 703
704config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
705 int "Maximum transfer size (KB) per request (up to 128)"
706 default "128"
707 depends on BLK_DEV_IDE_AU1XXX
708
709config BLK_DEV_IDE_TX4938 704config BLK_DEV_IDE_TX4938
710 tristate "TX4938 internal IDE support" 705 tristate "TX4938 internal IDE support"
711 depends on SOC_TX4938 706 depends on SOC_TX4938
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 4088a622873e..806760d24cef 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -633,7 +633,7 @@ static void ide_disk_setup(ide_drive_t *drive)
633 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, 633 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
634 q->max_sectors / 2); 634 q->max_sectors / 2);
635 635
636 if (ata_id_is_ssd(id) || ata_id_is_cfa(id)) 636 if (ata_id_is_ssd(id))
637 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); 637 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
638 638
639 /* calculate drive capacity, and select LBA if possible */ 639 /* calculate drive capacity, and select LBA if possible */
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index e728cfe7273f..753b92ebe0ae 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -493,7 +493,7 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
493 stat = tp_ops->read_status(hwif); 493 stat = tp_ops->read_status(hwif);
494 494
495 if (stat & ATA_BUSY) { 495 if (stat & ATA_BUSY) {
496 local_irq_save(flags); 496 local_save_flags(flags);
497 local_irq_enable_in_hardirq(); 497 local_irq_enable_in_hardirq();
498 timeout += jiffies; 498 timeout += jiffies;
499 while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) { 499 while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) {
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 4b3bf6a06b70..60538d9c84ee 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -186,12 +186,10 @@ void ide_complete_pm_request(ide_drive_t *drive, struct request *rq)
186 blk_pm_suspend_request(rq) ? "suspend" : "resume"); 186 blk_pm_suspend_request(rq) ? "suspend" : "resume");
187#endif 187#endif
188 spin_lock_irqsave(q->queue_lock, flags); 188 spin_lock_irqsave(q->queue_lock, flags);
189 if (blk_pm_suspend_request(rq)) { 189 if (blk_pm_suspend_request(rq))
190 blk_stop_queue(q); 190 blk_stop_queue(q);
191 } else { 191 else
192 drive->dev_flags &= ~IDE_DFLAG_BLOCKED; 192 drive->dev_flags &= ~IDE_DFLAG_BLOCKED;
193 blk_start_queue(q);
194 }
195 spin_unlock_irqrestore(q->queue_lock, flags); 193 spin_unlock_irqrestore(q->queue_lock, flags);
196 194
197 drive->hwif->rq = NULL; 195 drive->hwif->rq = NULL;
@@ -219,6 +217,8 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
219 * point. 217 * point.
220 */ 218 */
221 ide_hwif_t *hwif = drive->hwif; 219 ide_hwif_t *hwif = drive->hwif;
220 struct request_queue *q = drive->queue;
221 unsigned long flags;
222 int rc; 222 int rc;
223#ifdef DEBUG_PM 223#ifdef DEBUG_PM
224 printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name); 224 printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name);
@@ -231,5 +231,9 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
231 rc = ide_wait_not_busy(hwif, 100000); 231 rc = ide_wait_not_busy(hwif, 100000);
232 if (rc) 232 if (rc)
233 printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name); 233 printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name);
234
235 spin_lock_irqsave(q->queue_lock, flags);
236 blk_start_queue(q);
237 spin_unlock_irqrestore(q->queue_lock, flags);
234 } 238 }
235} 239}
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 0ccbb4459fb9..312127ea443a 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -796,7 +796,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
796 if (irqd) 796 if (irqd)
797 disable_irq(hwif->irq); 797 disable_irq(hwif->irq);
798 798
799 local_irq_save(flags); 799 local_save_flags(flags);
800 local_irq_enable_in_hardirq(); 800 local_irq_enable_in_hardirq();
801 801
802 if (ide_port_wait_ready(hwif) == -EBUSY) 802 if (ide_port_wait_ready(hwif) == -EBUSY)
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
index 0be27ac1f077..e1c4f5437396 100644
--- a/drivers/ide/it821x.c
+++ b/drivers/ide/it821x.c
@@ -68,6 +68,8 @@
68 68
69#define DRV_NAME "it821x" 69#define DRV_NAME "it821x"
70 70
71#define QUIRK_VORTEX86 1
72
71struct it821x_dev 73struct it821x_dev
72{ 74{
73 unsigned int smart:1, /* Are we in smart raid mode */ 75 unsigned int smart:1, /* Are we in smart raid mode */
@@ -79,6 +81,7 @@ struct it821x_dev
79 u16 pio[2]; /* Cached PIO values */ 81 u16 pio[2]; /* Cached PIO values */
80 u16 mwdma[2]; /* Cached MWDMA values */ 82 u16 mwdma[2]; /* Cached MWDMA values */
81 u16 udma[2]; /* Cached UDMA values (per drive) */ 83 u16 udma[2]; /* Cached UDMA values (per drive) */
84 u16 quirks;
82}; 85};
83 86
84#define ATA_66 0 87#define ATA_66 0
@@ -557,8 +560,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
557 * this is necessary. 560 * this is necessary.
558 */ 561 */
559 562
560 pci_read_config_byte(dev, 0x08, &conf); 563 if (dev->revision == 0x10) {
561 if (conf == 0x10) {
562 idev->timing10 = 1; 564 idev->timing10 = 1;
563 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 565 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
564 if (idev->smart == 0) 566 if (idev->smart == 0)
@@ -577,6 +579,12 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
577 579
578 hwif->ultra_mask = ATA_UDMA6; 580 hwif->ultra_mask = ATA_UDMA6;
579 hwif->mwdma_mask = ATA_MWDMA2; 581 hwif->mwdma_mask = ATA_MWDMA2;
582
583 /* Vortex86SX quirk: prevent Ultra-DMA mode to fix BadCRC issue */
584 if (idev->quirks & QUIRK_VORTEX86) {
585 if (dev->revision == 0x11)
586 hwif->ultra_mask = 0;
587 }
580} 588}
581 589
582static void it8212_disable_raid(struct pci_dev *dev) 590static void it8212_disable_raid(struct pci_dev *dev)
@@ -649,6 +657,8 @@ static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_devic
649 return -ENOMEM; 657 return -ENOMEM;
650 } 658 }
651 659
660 itdevs->quirks = id->driver_data;
661
652 rc = ide_pci_init_one(dev, &it821x_chipset, itdevs); 662 rc = ide_pci_init_one(dev, &it821x_chipset, itdevs);
653 if (rc) 663 if (rc)
654 kfree(itdevs); 664 kfree(itdevs);
@@ -668,6 +678,7 @@ static void __devexit it821x_remove(struct pci_dev *dev)
668static const struct pci_device_id it821x_pci_tbl[] = { 678static const struct pci_device_id it821x_pci_tbl[] = {
669 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), 0 }, 679 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), 0 },
670 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), 0 }, 680 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), 0 },
681 { PCI_VDEVICE(RDC, PCI_DEVICE_ID_RDC_D1010), QUIRK_VORTEX86 },
671 { 0, }, 682 { 0, },
672}; 683};
673 684
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
index 48cc748c5043..6297956507c0 100644
--- a/drivers/ide/sl82c105.c
+++ b/drivers/ide/sl82c105.c
@@ -310,10 +310,6 @@ static const struct ide_port_info sl82c105_chipset __devinitdata = {
310 .dma_ops = &sl82c105_dma_ops, 310 .dma_ops = &sl82c105_dma_ops,
311 .host_flags = IDE_HFLAG_IO_32BIT | 311 .host_flags = IDE_HFLAG_IO_32BIT |
312 IDE_HFLAG_UNMASK_IRQS | 312 IDE_HFLAG_UNMASK_IRQS |
313/* FIXME: check for Compatibility mode in generic IDE PCI code */
314#if defined(CONFIG_LOPEC) || defined(CONFIG_SANDPOINT)
315 IDE_HFLAG_FORCE_LEGACY_IRQS |
316#endif
317 IDE_HFLAG_SERIALIZE_DMA | 313 IDE_HFLAG_SERIALIZE_DMA |
318 IDE_HFLAG_NO_AUTODMA, 314 IDE_HFLAG_NO_AUTODMA,
319 .pio_mask = ATA_PIO5, 315 .pio_mask = ATA_PIO5,
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
index b4ef218072cd..d9095345f7ca 100644
--- a/drivers/ide/tx4938ide.c
+++ b/drivers/ide/tx4938ide.c
@@ -202,7 +202,6 @@ static const struct ide_tp_ops tx4938ide_tp_ops = {
202 .exec_command = ide_exec_command, 202 .exec_command = ide_exec_command,
203 .read_status = ide_read_status, 203 .read_status = ide_read_status,
204 .read_altstatus = ide_read_altstatus, 204 .read_altstatus = ide_read_altstatus,
205 .read_sff_dma_status = ide_read_sff_dma_status,
206 205
207 .set_irq = ide_set_irq, 206 .set_irq = ide_set_irq,
208 207
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index fecc0e03c3fc..703c3eeb20a8 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -432,8 +432,6 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
432 if (via_clock < 20000 || via_clock > 50000) { 432 if (via_clock < 20000 || via_clock > 50000) {
433 printk(KERN_WARNING DRV_NAME ": User given PCI clock speed " 433 printk(KERN_WARNING DRV_NAME ": User given PCI clock speed "
434 "impossible (%d), using 33 MHz instead.\n", via_clock); 434 "impossible (%d), using 33 MHz instead.\n", via_clock);
435 printk(KERN_WARNING DRV_NAME ": Use ide0=ata66 if you want "
436 "to assume 80-wire cable.\n");
437 via_clock = 33333; 435 via_clock = 33333;
438 } 436 }
439 437
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 3b77b674cbf6..c7b8a506af65 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -955,7 +955,7 @@ void ehca_poll_eqs(unsigned long data)
955 struct ehca_eq *eq = &shca->eq; 955 struct ehca_eq *eq = &shca->eq;
956 int max = 3; 956 int max = 3;
957 volatile u64 q_ofs, q_ofs2; 957 volatile u64 q_ofs, q_ofs2;
958 u64 flags; 958 unsigned long flags;
959 spin_lock_irqsave(&eq->spinlock, flags); 959 spin_lock_irqsave(&eq->spinlock, flags);
960 q_ofs = eq->ipz_queue.current_q_offset; 960 q_ofs = eq->ipz_queue.current_q_offset;
961 spin_unlock_irqrestore(&eq->spinlock, flags); 961 spin_unlock_irqrestore(&eq->spinlock, flags);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index dcefe1fceb5c..61588bd273bd 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -543,14 +543,21 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
543{ 543{
544 static int mlx4_ib_version_printed; 544 static int mlx4_ib_version_printed;
545 struct mlx4_ib_dev *ibdev; 545 struct mlx4_ib_dev *ibdev;
546 int num_ports = 0;
546 int i; 547 int i;
547 548
548
549 if (!mlx4_ib_version_printed) { 549 if (!mlx4_ib_version_printed) {
550 printk(KERN_INFO "%s", mlx4_ib_version); 550 printk(KERN_INFO "%s", mlx4_ib_version);
551 ++mlx4_ib_version_printed; 551 ++mlx4_ib_version_printed;
552 } 552 }
553 553
554 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
555 num_ports++;
556
557 /* No point in registering a device with no ports... */
558 if (num_ports == 0)
559 return NULL;
560
554 ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev); 561 ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
555 if (!ibdev) { 562 if (!ibdev) {
556 dev_err(&dev->pdev->dev, "Device struct alloc failed\n"); 563 dev_err(&dev->pdev->dev, "Device struct alloc failed\n");
@@ -574,9 +581,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
574 ibdev->ib_dev.owner = THIS_MODULE; 581 ibdev->ib_dev.owner = THIS_MODULE;
575 ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; 582 ibdev->ib_dev.node_type = RDMA_NODE_IB_CA;
576 ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey; 583 ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey;
577 ibdev->num_ports = 0; 584 ibdev->num_ports = num_ports;
578 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
579 ibdev->num_ports++;
580 ibdev->ib_dev.phys_port_cnt = ibdev->num_ports; 585 ibdev->ib_dev.phys_port_cnt = ibdev->num_ports;
581 ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors; 586 ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors;
582 ibdev->ib_dev.dma_device = &dev->pdev->dev; 587 ibdev->ib_dev.dma_device = &dev->pdev->dev;
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 6ba57e91d7ab..a01b4488208b 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -778,12 +778,13 @@ static struct nes_cm_node *find_node(struct nes_cm_core *cm_core,
778 unsigned long flags; 778 unsigned long flags;
779 struct list_head *hte; 779 struct list_head *hte;
780 struct nes_cm_node *cm_node; 780 struct nes_cm_node *cm_node;
781 __be32 tmp_addr = cpu_to_be32(loc_addr);
781 782
782 /* get a handle on the hte */ 783 /* get a handle on the hte */
783 hte = &cm_core->connected_nodes; 784 hte = &cm_core->connected_nodes;
784 785
785 nes_debug(NES_DBG_CM, "Searching for an owner node: %pI4:%x from core %p->%p\n", 786 nes_debug(NES_DBG_CM, "Searching for an owner node: %pI4:%x from core %p->%p\n",
786 &loc_addr, loc_port, cm_core, hte); 787 &tmp_addr, loc_port, cm_core, hte);
787 788
788 /* walk list and find cm_node associated with this session ID */ 789 /* walk list and find cm_node associated with this session ID */
789 spin_lock_irqsave(&cm_core->ht_lock, flags); 790 spin_lock_irqsave(&cm_core->ht_lock, flags);
@@ -816,6 +817,7 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
816{ 817{
817 unsigned long flags; 818 unsigned long flags;
818 struct nes_cm_listener *listen_node; 819 struct nes_cm_listener *listen_node;
820 __be32 tmp_addr = cpu_to_be32(dst_addr);
819 821
820 /* walk list and find cm_node associated with this session ID */ 822 /* walk list and find cm_node associated with this session ID */
821 spin_lock_irqsave(&cm_core->listen_list_lock, flags); 823 spin_lock_irqsave(&cm_core->listen_list_lock, flags);
@@ -833,7 +835,7 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
833 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags); 835 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
834 836
835 nes_debug(NES_DBG_CM, "Unable to find listener for %pI4:%x\n", 837 nes_debug(NES_DBG_CM, "Unable to find listener for %pI4:%x\n",
836 &dst_addr, dst_port); 838 &tmp_addr, dst_port);
837 839
838 /* no listener */ 840 /* no listener */
839 return NULL; 841 return NULL;
@@ -2059,6 +2061,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
2059 struct tcphdr *tcph; 2061 struct tcphdr *tcph;
2060 struct nes_cm_info nfo; 2062 struct nes_cm_info nfo;
2061 int skb_handled = 1; 2063 int skb_handled = 1;
2064 __be32 tmp_daddr, tmp_saddr;
2062 2065
2063 if (!skb) 2066 if (!skb)
2064 return 0; 2067 return 0;
@@ -2074,8 +2077,11 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
2074 nfo.rem_addr = ntohl(iph->saddr); 2077 nfo.rem_addr = ntohl(iph->saddr);
2075 nfo.rem_port = ntohs(tcph->source); 2078 nfo.rem_port = ntohs(tcph->source);
2076 2079
2080 tmp_daddr = cpu_to_be32(iph->daddr);
2081 tmp_saddr = cpu_to_be32(iph->saddr);
2082
2077 nes_debug(NES_DBG_CM, "Received packet: dest=%pI4:0x%04X src=%pI4:0x%04X\n", 2083 nes_debug(NES_DBG_CM, "Received packet: dest=%pI4:0x%04X src=%pI4:0x%04X\n",
2078 &iph->daddr, tcph->dest, &iph->saddr, tcph->source); 2084 &tmp_daddr, tcph->dest, &tmp_saddr, tcph->source);
2079 2085
2080 do { 2086 do {
2081 cm_node = find_node(cm_core, 2087 cm_node = find_node(cm_core,
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index aa9b7348c728..6f3bc1b6bf22 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -655,6 +655,7 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
655 struct nes_adapter *nesadapter = nesdev->nesadapter; 655 struct nes_adapter *nesadapter = nesdev->nesadapter;
656 int arp_index; 656 int arp_index;
657 int err = 0; 657 int err = 0;
658 __be32 tmp_addr;
658 659
659 for (arp_index = 0; (u32) arp_index < nesadapter->arp_table_size; arp_index++) { 660 for (arp_index = 0; (u32) arp_index < nesadapter->arp_table_size; arp_index++) {
660 if (nesadapter->arp_table[arp_index].ip_addr == ip_addr) 661 if (nesadapter->arp_table[arp_index].ip_addr == ip_addr)
@@ -682,8 +683,9 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
682 683
683 /* DELETE or RESOLVE */ 684 /* DELETE or RESOLVE */
684 if (arp_index == nesadapter->arp_table_size) { 685 if (arp_index == nesadapter->arp_table_size) {
686 tmp_addr = cpu_to_be32(ip_addr);
685 nes_debug(NES_DBG_NETDEV, "MAC for %pI4 not in ARP table - cannot %s\n", 687 nes_debug(NES_DBG_NETDEV, "MAC for %pI4 not in ARP table - cannot %s\n",
686 &ip_addr, action == NES_ARP_RESOLVE ? "resolve" : "delete"); 688 &tmp_addr, action == NES_ARP_RESOLVE ? "resolve" : "delete");
687 return -1; 689 return -1;
688 } 690 }
689 691
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 19e06bc38b39..dce0443f9d69 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -711,26 +711,26 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
711 711
712 neigh = *to_ipoib_neigh(skb->dst->neighbour); 712 neigh = *to_ipoib_neigh(skb->dst->neighbour);
713 713
714 if (neigh->ah) 714 if (unlikely((memcmp(&neigh->dgid.raw,
715 if (unlikely((memcmp(&neigh->dgid.raw, 715 skb->dst->neighbour->ha + 4,
716 skb->dst->neighbour->ha + 4, 716 sizeof(union ib_gid))) ||
717 sizeof(union ib_gid))) || 717 (neigh->dev != dev))) {
718 (neigh->dev != dev))) { 718 spin_lock_irqsave(&priv->lock, flags);
719 spin_lock_irqsave(&priv->lock, flags); 719 /*
720 /* 720 * It's safe to call ipoib_put_ah() inside
721 * It's safe to call ipoib_put_ah() inside 721 * priv->lock here, because we know that
722 * priv->lock here, because we know that 722 * path->ah will always hold one more reference,
723 * path->ah will always hold one more reference, 723 * so ipoib_put_ah() will never do more than
724 * so ipoib_put_ah() will never do more than 724 * decrement the ref count.
725 * decrement the ref count. 725 */
726 */ 726 if (neigh->ah)
727 ipoib_put_ah(neigh->ah); 727 ipoib_put_ah(neigh->ah);
728 list_del(&neigh->list); 728 list_del(&neigh->list);
729 ipoib_neigh_free(dev, neigh); 729 ipoib_neigh_free(dev, neigh);
730 spin_unlock_irqrestore(&priv->lock, flags); 730 spin_unlock_irqrestore(&priv->lock, flags);
731 ipoib_path_lookup(skb, dev); 731 ipoib_path_lookup(skb, dev);
732 return NETDEV_TX_OK; 732 return NETDEV_TX_OK;
733 } 733 }
734 734
735 if (ipoib_cm_get(neigh)) { 735 if (ipoib_cm_get(neigh)) {
736 if (ipoib_cm_up(neigh)) { 736 if (ipoib_cm_up(neigh)) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index a2eb3b9789eb..59d02e0b8df1 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -529,6 +529,9 @@ void ipoib_mcast_join_task(struct work_struct *work)
529 if (!priv->broadcast) { 529 if (!priv->broadcast) {
530 struct ipoib_mcast *broadcast; 530 struct ipoib_mcast *broadcast;
531 531
532 if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
533 return;
534
532 broadcast = ipoib_mcast_alloc(dev, 1); 535 broadcast = ipoib_mcast_alloc(dev, 1);
533 if (!broadcast) { 536 if (!broadcast) {
534 ipoib_warn(priv, "failed to allocate broadcast group\n"); 537 ipoib_warn(priv, "failed to allocate broadcast group\n");
diff --git a/drivers/infiniband/ulp/iser/Kconfig b/drivers/infiniband/ulp/iser/Kconfig
index 77dedba829e6..b411c51842da 100644
--- a/drivers/infiniband/ulp/iser/Kconfig
+++ b/drivers/infiniband/ulp/iser/Kconfig
@@ -1,6 +1,6 @@
1config INFINIBAND_ISER 1config INFINIBAND_ISER
2 tristate "iSCSI Extensions for RDMA (iSER)" 2 tristate "iSCSI Extensions for RDMA (iSER)"
3 depends on SCSI && INET 3 depends on SCSI && INET && INFINIBAND_ADDR_TRANS
4 select SCSI_ISCSI_ATTRS 4 select SCSI_ISCSI_ATTRS
5 ---help--- 5 ---help---
6 Support for the iSCSI Extensions for RDMA (iSER) Protocol 6 Support for the iSCSI Extensions for RDMA (iSER) Protocol
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 199055db5082..67e5553f699a 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -220,4 +220,11 @@ config HP_SDC_RTC
220 Say Y here if you want to support the built-in real time clock 220 Say Y here if you want to support the built-in real time clock
221 of the HP SDC controller. 221 of the HP SDC controller.
222 222
223config INPUT_PCF50633_PMU
224 tristate "PCF50633 PMU events"
225 depends on MFD_PCF50633
226 help
227 Say Y to include support for delivering PMU events via input
228 layer on NXP PCF50633.
229
223endif 230endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index d7db2aeb8a98..bb62e6efacf3 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
21obj-$(CONFIG_INPUT_UINPUT) += uinput.o 21obj-$(CONFIG_INPUT_UINPUT) += uinput.o
22obj-$(CONFIG_INPUT_APANEL) += apanel.o 22obj-$(CONFIG_INPUT_APANEL) += apanel.o
23obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 23obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
24obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c
new file mode 100644
index 000000000000..039dcb00ebd9
--- /dev/null
+++ b/drivers/input/misc/pcf50633-input.c
@@ -0,0 +1,132 @@
1/* NXP PCF50633 Input Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/platform_device.h>
22#include <linux/input.h>
23
24#include <linux/mfd/pcf50633/core.h>
25
26#define PCF50633_OOCSTAT_ONKEY 0x01
27#define PCF50633_REG_OOCSTAT 0x12
28#define PCF50633_REG_OOCMODE 0x10
29
30struct pcf50633_input {
31 struct pcf50633 *pcf;
32 struct input_dev *input_dev;
33};
34
35static void
36pcf50633_input_irq(int irq, void *data)
37{
38 struct pcf50633_input *input;
39 int onkey_released;
40
41 input = data;
42
43 /* We report only one event depending on the key press status */
44 onkey_released = pcf50633_reg_read(input->pcf, PCF50633_REG_OOCSTAT)
45 & PCF50633_OOCSTAT_ONKEY;
46
47 if (irq == PCF50633_IRQ_ONKEYF && !onkey_released)
48 input_report_key(input->input_dev, KEY_POWER, 1);
49 else if (irq == PCF50633_IRQ_ONKEYR && onkey_released)
50 input_report_key(input->input_dev, KEY_POWER, 0);
51
52 input_sync(input->input_dev);
53}
54
55static int __devinit pcf50633_input_probe(struct platform_device *pdev)
56{
57 struct pcf50633_input *input;
58 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
59 struct input_dev *input_dev;
60 int ret;
61
62
63 input = kzalloc(sizeof(*input), GFP_KERNEL);
64 if (!input)
65 return -ENOMEM;
66
67 input_dev = input_allocate_device();
68 if (!input_dev) {
69 kfree(input);
70 return -ENOMEM;
71 }
72
73 platform_set_drvdata(pdev, input);
74 input->pcf = pdata->pcf;
75 input->input_dev = input_dev;
76
77 input_dev->name = "PCF50633 PMU events";
78 input_dev->id.bustype = BUS_I2C;
79 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
80 set_bit(KEY_POWER, input_dev->keybit);
81
82 ret = input_register_device(input_dev);
83 if (ret) {
84 input_free_device(input_dev);
85 kfree(input);
86 return ret;
87 }
88 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYR,
89 pcf50633_input_irq, input);
90 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYF,
91 pcf50633_input_irq, input);
92
93 return 0;
94}
95
96static int __devexit pcf50633_input_remove(struct platform_device *pdev)
97{
98 struct pcf50633_input *input = platform_get_drvdata(pdev);
99
100 pcf50633_free_irq(input->pcf, PCF50633_IRQ_ONKEYR);
101 pcf50633_free_irq(input->pcf, PCF50633_IRQ_ONKEYF);
102
103 input_unregister_device(input->input_dev);
104 kfree(input);
105
106 return 0;
107}
108
109static struct platform_driver pcf50633_input_driver = {
110 .driver = {
111 .name = "pcf50633-input",
112 },
113 .probe = pcf50633_input_probe,
114 .remove = __devexit_p(pcf50633_input_remove),
115};
116
117static int __init pcf50633_input_init(void)
118{
119 return platform_driver_register(&pcf50633_input_driver);
120}
121module_init(pcf50633_input_init);
122
123static void __exit pcf50633_input_exit(void)
124{
125 platform_driver_unregister(&pcf50633_input_driver);
126}
127module_exit(pcf50633_input_exit);
128
129MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
130MODULE_DESCRIPTION("PCF50633 input driver");
131MODULE_LICENSE("GPL");
132MODULE_ALIAS("platform:pcf50633-input");
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 97f4708b3879..595ba8eb4a07 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -3615,7 +3615,7 @@ hfcm_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
3615static void 3615static void
3616ph_state_change(struct dchannel *dch) 3616ph_state_change(struct dchannel *dch)
3617{ 3617{
3618 struct hfc_multi *hc = dch->hw; 3618 struct hfc_multi *hc;
3619 int ch, i; 3619 int ch, i;
3620 3620
3621 if (!dch) { 3621 if (!dch) {
@@ -3623,6 +3623,7 @@ ph_state_change(struct dchannel *dch)
3623 __func__); 3623 __func__);
3624 return; 3624 return;
3625 } 3625 }
3626 hc = dch->hw;
3626 ch = dch->slot; 3627 ch = dch->slot;
3627 3628
3628 if (hc->type == 1) { 3629 if (hc->type == 1) {
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 917bf41a293b..f0e14dfcf71d 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -61,7 +61,7 @@ u32 hfc_jiffies;
61 61
62MODULE_AUTHOR("Karsten Keil"); 62MODULE_AUTHOR("Karsten Keil");
63MODULE_LICENSE("GPL"); 63MODULE_LICENSE("GPL");
64module_param(debug, uint, 0); 64module_param(debug, uint, S_IRUGO | S_IWUSR);
65module_param(poll, uint, S_IRUGO | S_IWUSR); 65module_param(poll, uint, S_IRUGO | S_IWUSR);
66 66
67enum { 67enum {
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 7c5f97033b9f..cb8943da4f12 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -292,7 +292,9 @@ isdn_net_unbind_channel(isdn_net_local * lp)
292 lp->dialstate = 0; 292 lp->dialstate = 0;
293 dev->rx_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL; 293 dev->rx_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL;
294 dev->st_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL; 294 dev->st_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL;
295 isdn_free_channel(lp->isdn_device, lp->isdn_channel, ISDN_USAGE_NET); 295 if (lp->isdn_device != -1 && lp->isdn_channel != -1)
296 isdn_free_channel(lp->isdn_device, lp->isdn_channel,
297 ISDN_USAGE_NET);
296 lp->flags &= ~ISDN_NET_CONNECTED; 298 lp->flags &= ~ISDN_NET_CONNECTED;
297 lp->isdn_device = -1; 299 lp->isdn_device = -1;
298 lp->isdn_channel = -1; 300 lp->isdn_channel = -1;
@@ -2513,7 +2515,6 @@ static const struct net_device_ops isdn_netdev_ops = {
2513 .ndo_stop = isdn_net_close, 2515 .ndo_stop = isdn_net_close,
2514 .ndo_do_ioctl = isdn_net_ioctl, 2516 .ndo_do_ioctl = isdn_net_ioctl,
2515 2517
2516 .ndo_validate_addr = NULL,
2517 .ndo_start_xmit = isdn_net_start_xmit, 2518 .ndo_start_xmit = isdn_net_start_xmit,
2518 .ndo_get_stats = isdn_net_get_stats, 2519 .ndo_get_stats = isdn_net_get_stats,
2519 .ndo_tx_timeout = isdn_net_tx_timeout, 2520 .ndo_tx_timeout = isdn_net_tx_timeout,
@@ -2528,12 +2529,8 @@ static void _isdn_setup(struct net_device *dev)
2528 2529
2529 ether_setup(dev); 2530 ether_setup(dev);
2530 2531
2531 dev->flags = IFF_NOARP | IFF_POINTOPOINT;
2532 /* Setup the generic properties */ 2532 /* Setup the generic properties */
2533 dev->mtu = 1500;
2534 dev->flags = IFF_NOARP|IFF_POINTOPOINT; 2533 dev->flags = IFF_NOARP|IFF_POINTOPOINT;
2535 dev->type = ARPHRD_ETHER;
2536 dev->addr_len = ETH_ALEN;
2537 dev->header_ops = NULL; 2534 dev->header_ops = NULL;
2538 dev->netdev_ops = &isdn_netdev_ops; 2535 dev->netdev_ops = &isdn_netdev_ops;
2539 2536
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index 0ac67bff303a..58c43e429f73 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -1579,7 +1579,7 @@ send_packet:
1579 schedule_work(&dsp->workq); 1579 schedule_work(&dsp->workq);
1580} 1580}
1581 1581
1582static u32 jittercount; /* counter for jitter check */; 1582static u32 jittercount; /* counter for jitter check */
1583struct timer_list dsp_spl_tl; 1583struct timer_list dsp_spl_tl;
1584u32 dsp_spl_jiffies; /* calculate the next time to fire */ 1584u32 dsp_spl_jiffies; /* calculate the next time to fire */
1585static u16 dsp_count; /* last sample count */ 1585static u16 dsp_count; /* last sample count */
@@ -1893,7 +1893,7 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
1893 /* in case of hardware (echo) */ 1893 /* in case of hardware (echo) */
1894 if (dsp->pcm_slot_tx >= 0) 1894 if (dsp->pcm_slot_tx >= 0)
1895 return; 1895 return;
1896 if (dsp->echo) 1896 if (dsp->echo) {
1897 nskb = skb_clone(skb, GFP_ATOMIC); 1897 nskb = skb_clone(skb, GFP_ATOMIC);
1898 if (nskb) { 1898 if (nskb) {
1899 hh = mISDN_HEAD_P(nskb); 1899 hh = mISDN_HEAD_P(nskb);
@@ -1902,6 +1902,7 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
1902 skb_queue_tail(&dsp->sendq, nskb); 1902 skb_queue_tail(&dsp->sendq, nskb);
1903 schedule_work(&dsp->workq); 1903 schedule_work(&dsp->workq);
1904 } 1904 }
1905 }
1905 return; 1906 return;
1906 } 1907 }
1907 /* in case of hardware conference */ 1908 /* in case of hardware conference */
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index bf999bdc41c3..18cf87c113e7 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -110,8 +110,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
110 } 110 }
111 list_add_tail(&entry->list, &dsp_elements); 111 list_add_tail(&entry->list, &dsp_elements);
112 112
113 for (i = 0; i < (sizeof(element_attributes) 113 for (i = 0; i < ARRAY_SIZE(element_attributes); ++i) {
114 / sizeof(struct device_attribute)); ++i)
115 ret = device_create_file(&entry->dev, 114 ret = device_create_file(&entry->dev,
116 &element_attributes[i]); 115 &element_attributes[i]);
117 if (ret) { 116 if (ret) {
@@ -119,6 +118,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
119 __func__); 118 __func__);
120 goto err2; 119 goto err2;
121 } 120 }
121 }
122 122
123#ifdef PIPELINE_DEBUG 123#ifdef PIPELINE_DEBUG
124 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name); 124 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index a4a1ae214630..742713611bc5 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -119,13 +119,6 @@ config LEDS_GPIO
119 outputs. To be useful the particular board must have LEDs 119 outputs. To be useful the particular board must have LEDs
120 and they must be connected to the GPIO lines. 120 and they must be connected to the GPIO lines.
121 121
122config LEDS_HP_DISK
123 tristate "LED Support for disk protection LED on HP notebooks"
124 depends on LEDS_CLASS && ACPI
125 help
126 This option enable support for disk protection LED, found on
127 newer HP notebooks.
128
129config LEDS_CLEVO_MAIL 122config LEDS_CLEVO_MAIL
130 tristate "Mail LED on Clevo notebook (EXPERIMENTAL)" 123 tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
131 depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL 124 depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index bc247cb02e82..9d76f0f160a4 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -23,7 +23,6 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
23obj-$(CONFIG_LEDS_FSG) += leds-fsg.o 23obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
24obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o 24obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
25obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o 25obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
26obj-$(CONFIG_LEDS_HP_DISK) += leds-hp-disk.o
27obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o 26obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
28 27
29# LED Triggers 28# LED Triggers
diff --git a/drivers/leds/leds-hp-disk.c b/drivers/leds/leds-hp-disk.c
deleted file mode 100644
index d786adc8c5e3..000000000000
--- a/drivers/leds/leds-hp-disk.c
+++ /dev/null
@@ -1,137 +0,0 @@
1/*
2 * leds-hp-disk.c - driver for HP "hard disk protection" LED
3 *
4 * Copyright (C) 2008 Pavel Machek
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/dmi.h>
24#include <linux/module.h>
25#include <linux/types.h>
26#include <linux/platform_device.h>
27#include <linux/interrupt.h>
28#include <linux/input.h>
29#include <linux/kthread.h>
30#include <linux/leds.h>
31#include <acpi/acpi_drivers.h>
32
33#define DRIVER_NAME "leds-hp-disk"
34#define ACPI_MDPS_CLASS "led"
35
36/* For automatic insertion of the module */
37static struct acpi_device_id hpled_device_ids[] = {
38 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
39 {"", 0},
40};
41MODULE_DEVICE_TABLE(acpi, hpled_device_ids);
42
43struct acpi_hpled {
44 struct acpi_device *device; /* The ACPI device */
45};
46
47static struct acpi_hpled adev;
48
49static acpi_status hpled_acpi_write(acpi_handle handle, int reg)
50{
51 unsigned long long ret; /* Not used when writing */
52 union acpi_object in_obj[1];
53 struct acpi_object_list args = { 1, in_obj };
54
55 in_obj[0].type = ACPI_TYPE_INTEGER;
56 in_obj[0].integer.value = reg;
57
58 return acpi_evaluate_integer(handle, "ALED", &args, &ret);
59}
60
61static void hpled_set(struct led_classdev *led_cdev,
62 enum led_brightness value)
63{
64 hpled_acpi_write(adev.device->handle, !!value);
65}
66
67static struct led_classdev hpled_led = {
68 .name = "hp:red:hddprotection",
69 .default_trigger = "heartbeat",
70 .brightness_set = hpled_set,
71 .flags = LED_CORE_SUSPENDRESUME,
72};
73
74static int hpled_add(struct acpi_device *device)
75{
76 int ret;
77
78 if (!device)
79 return -EINVAL;
80
81 adev.device = device;
82 strcpy(acpi_device_name(device), DRIVER_NAME);
83 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
84 device->driver_data = &adev;
85
86 ret = led_classdev_register(NULL, &hpled_led);
87 return ret;
88}
89
90static int hpled_remove(struct acpi_device *device, int type)
91{
92 if (!device)
93 return -EINVAL;
94
95 led_classdev_unregister(&hpled_led);
96 return 0;
97}
98
99
100
101static struct acpi_driver leds_hp_driver = {
102 .name = DRIVER_NAME,
103 .class = ACPI_MDPS_CLASS,
104 .ids = hpled_device_ids,
105 .ops = {
106 .add = hpled_add,
107 .remove = hpled_remove,
108 }
109};
110
111static int __init hpled_init_module(void)
112{
113 int ret;
114
115 if (acpi_disabled)
116 return -ENODEV;
117
118 ret = acpi_bus_register_driver(&leds_hp_driver);
119 if (ret < 0)
120 return ret;
121
122 printk(KERN_INFO DRIVER_NAME " driver loaded.\n");
123
124 return 0;
125}
126
127static void __exit hpled_exit_module(void)
128{
129 acpi_bus_unregister_driver(&leds_hp_driver);
130}
131
132MODULE_DESCRIPTION("Driver for HP disk protection LED");
133MODULE_AUTHOR("Pavel Machek <pavel@suse.cz>");
134MODULE_LICENSE("GPL");
135
136module_init(hpled_init_module);
137module_exit(hpled_exit_module);
diff --git a/drivers/message/fusion/lsi/mpi.h b/drivers/message/fusion/lsi/mpi.h
index 10b6ef758725..11c0f461320e 100644
--- a/drivers/message/fusion/lsi/mpi.h
+++ b/drivers/message/fusion/lsi/mpi.h
@@ -6,7 +6,7 @@
6 * Title: MPI Message independent structures and definitions 6 * Title: MPI Message independent structures and definitions
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi.h Version: 01.05.13 9 * mpi.h Version: 01.05.16
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -79,6 +79,9 @@
79 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT. 79 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.
80 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT. 80 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT.
81 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT. 81 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT.
82 * 08-07-07 01.05.14 Bumped MPI_HEADER_VERSION_UNIT.
83 * 01-15-08 01.05.15 Bumped MPI_HEADER_VERSION_UNIT.
84 * 03-28-08 01.05.16 Bumped MPI_HEADER_VERSION_UNIT.
82 * -------------------------------------------------------------------------- 85 * --------------------------------------------------------------------------
83 */ 86 */
84 87
@@ -109,7 +112,7 @@
109/* Note: The major versions of 0xe0 through 0xff are reserved */ 112/* Note: The major versions of 0xe0 through 0xff are reserved */
110 113
111/* versioning for this MPI header set */ 114/* versioning for this MPI header set */
112#define MPI_HEADER_VERSION_UNIT (0x10) 115#define MPI_HEADER_VERSION_UNIT (0x13)
113#define MPI_HEADER_VERSION_DEV (0x00) 116#define MPI_HEADER_VERSION_DEV (0x00)
114#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00) 117#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00)
115#define MPI_HEADER_VERSION_UNIT_SHIFT (8) 118#define MPI_HEADER_VERSION_UNIT_SHIFT (8)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index b2db3330c591..013c7d881948 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -6,7 +6,7 @@
6 * Title: MPI Config message, structures, and Pages 6 * Title: MPI Config message, structures, and Pages
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi_cnfg.h Version: 01.05.15 9 * mpi_cnfg.h Version: 01.05.18
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -308,6 +308,20 @@
308 * Expander Page 0 Flags field. 308 * Expander Page 0 Flags field.
309 * Fixed define for 309 * Fixed define for
310 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED. 310 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED.
311 * 08-07-07 01.05.16 Added MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT
312 * define.
313 * Added BIOS Page 4 structure.
314 * Added MPI_RAID_PHYS_DISK1_PATH_MAX define for RAID
315 * Physcial Disk Page 1.
316 * 01-15-07 01.05.17 Added additional bit defines for ExtFlags field of
317 * Manufacturing Page 4.
318 * Added Solid State Drives Supported bit to IOC Page 6
319 * Capabilities Flags.
320 * Added new value for AccessStatus field of SAS Device
321 * Page 0 (_SATA_NEEDS_INITIALIZATION).
322 * 03-28-08 01.05.18 Defined new bits in Manufacturing Page 4 ExtFlags field
323 * to control coercion size and the mixing of SAS and SATA
324 * SSD drives.
311 * -------------------------------------------------------------------------- 325 * --------------------------------------------------------------------------
312 */ 326 */
313 327
@@ -686,6 +700,14 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_4
686#define MPI_MANPAGE4_IR_NO_MIX_SAS_SATA (0x01) 700#define MPI_MANPAGE4_IR_NO_MIX_SAS_SATA (0x01)
687 701
688/* defines for the ExtFlags field */ 702/* defines for the ExtFlags field */
703#define MPI_MANPAGE4_EXTFLAGS_MASK_COERCION_SIZE (0x0180)
704#define MPI_MANPAGE4_EXTFLAGS_SHIFT_COERCION_SIZE (7)
705#define MPI_MANPAGE4_EXTFLAGS_1GB_COERCION_SIZE (0)
706#define MPI_MANPAGE4_EXTFLAGS_128MB_COERCION_SIZE (1)
707
708#define MPI_MANPAGE4_EXTFLAGS_NO_MIX_SSD_SAS_SATA (0x0040)
709#define MPI_MANPAGE4_EXTFLAGS_MIX_SSD_AND_NON_SSD (0x0020)
710#define MPI_MANPAGE4_EXTFLAGS_DUAL_PORT_SUPPORT (0x0010)
689#define MPI_MANPAGE4_EXTFLAGS_HIDE_NON_IR_METADATA (0x0008) 711#define MPI_MANPAGE4_EXTFLAGS_HIDE_NON_IR_METADATA (0x0008)
690#define MPI_MANPAGE4_EXTFLAGS_SAS_CACHE_DISABLE (0x0004) 712#define MPI_MANPAGE4_EXTFLAGS_SAS_CACHE_DISABLE (0x0004)
691#define MPI_MANPAGE4_EXTFLAGS_SATA_CACHE_DISABLE (0x0002) 713#define MPI_MANPAGE4_EXTFLAGS_SATA_CACHE_DISABLE (0x0002)
@@ -1159,6 +1181,8 @@ typedef struct _CONFIG_PAGE_IOC_6
1159 1181
1160/* IOC Page 6 Capabilities Flags */ 1182/* IOC Page 6 Capabilities Flags */
1161 1183
1184#define MPI_IOCPAGE6_CAP_FLAGS_SSD_SUPPORT (0x00000020)
1185#define MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT (0x00000010)
1162#define MPI_IOCPAGE6_CAP_FLAGS_DISABLE_SMART_POLLING (0x00000008) 1186#define MPI_IOCPAGE6_CAP_FLAGS_DISABLE_SMART_POLLING (0x00000008)
1163 1187
1164#define MPI_IOCPAGE6_CAP_FLAGS_MASK_METADATA_SIZE (0x00000006) 1188#define MPI_IOCPAGE6_CAP_FLAGS_MASK_METADATA_SIZE (0x00000006)
@@ -1428,6 +1452,15 @@ typedef struct _CONFIG_PAGE_BIOS_2
1428#define MPI_BIOSPAGE2_FORM_SAS_WWN (0x05) 1452#define MPI_BIOSPAGE2_FORM_SAS_WWN (0x05)
1429#define MPI_BIOSPAGE2_FORM_ENCLOSURE_SLOT (0x06) 1453#define MPI_BIOSPAGE2_FORM_ENCLOSURE_SLOT (0x06)
1430 1454
1455typedef struct _CONFIG_PAGE_BIOS_4
1456{
1457 CONFIG_PAGE_HEADER Header; /* 00h */
1458 U64 ReassignmentBaseWWID; /* 04h */
1459} CONFIG_PAGE_BIOS_4, MPI_POINTER PTR_CONFIG_PAGE_BIOS_4,
1460 BIOSPage4_t, MPI_POINTER pBIOSPage4_t;
1461
1462#define MPI_BIOSPAGE4_PAGEVERSION (0x00)
1463
1431 1464
1432/**************************************************************************** 1465/****************************************************************************
1433* SCSI Port Config Pages 1466* SCSI Port Config Pages
@@ -2419,6 +2452,15 @@ typedef struct _RAID_PHYS_DISK1_PATH
2419#define MPI_RAID_PHYSDISK1_FLAG_BROKEN (0x0002) 2452#define MPI_RAID_PHYSDISK1_FLAG_BROKEN (0x0002)
2420#define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001) 2453#define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001)
2421 2454
2455
2456/*
2457 * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
2458 * one and check Header.PageLength or NumPhysDiskPaths at runtime.
2459 */
2460#ifndef MPI_RAID_PHYS_DISK1_PATH_MAX
2461#define MPI_RAID_PHYS_DISK1_PATH_MAX (1)
2462#endif
2463
2422typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 2464typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1
2423{ 2465{
2424 CONFIG_PAGE_HEADER Header; /* 00h */ 2466 CONFIG_PAGE_HEADER Header; /* 00h */
@@ -2426,7 +2468,7 @@ typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1
2426 U8 PhysDiskNum; /* 05h */ 2468 U8 PhysDiskNum; /* 05h */
2427 U16 Reserved2; /* 06h */ 2469 U16 Reserved2; /* 06h */
2428 U32 Reserved1; /* 08h */ 2470 U32 Reserved1; /* 08h */
2429 RAID_PHYS_DISK1_PATH Path[1]; /* 0Ch */ 2471 RAID_PHYS_DISK1_PATH Path[MPI_RAID_PHYS_DISK1_PATH_MAX];/* 0Ch */
2430} CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1, 2472} CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1,
2431 RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t; 2473 RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t;
2432 2474
@@ -2844,6 +2886,7 @@ typedef struct _CONFIG_PAGE_SAS_DEVICE_0
2844#define MPI_SAS_DEVICE0_ASTATUS_SATA_INIT_FAILED (0x01) 2886#define MPI_SAS_DEVICE0_ASTATUS_SATA_INIT_FAILED (0x01)
2845#define MPI_SAS_DEVICE0_ASTATUS_SATA_CAPABILITY_FAILED (0x02) 2887#define MPI_SAS_DEVICE0_ASTATUS_SATA_CAPABILITY_FAILED (0x02)
2846#define MPI_SAS_DEVICE0_ASTATUS_SATA_AFFILIATION_CONFLICT (0x03) 2888#define MPI_SAS_DEVICE0_ASTATUS_SATA_AFFILIATION_CONFLICT (0x03)
2889#define MPI_SAS_DEVICE0_ASTATUS_SATA_NEEDS_INITIALIZATION (0x04)
2847/* specific values for SATA Init failures */ 2890/* specific values for SATA Init failures */
2848#define MPI_SAS_DEVICE0_ASTATUS_SIF_UNKNOWN (0x10) 2891#define MPI_SAS_DEVICE0_ASTATUS_SIF_UNKNOWN (0x10)
2849#define MPI_SAS_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT (0x11) 2892#define MPI_SAS_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT (0x11)
diff --git a/drivers/message/fusion/lsi/mpi_fc.h b/drivers/message/fusion/lsi/mpi_fc.h
index 627acfbb8623..7d663ce76f8c 100644
--- a/drivers/message/fusion/lsi/mpi_fc.h
+++ b/drivers/message/fusion/lsi/mpi_fc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_fc.h 5 * Name: mpi_fc.h
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt
index 3f15fcfe4a2e..693e4b511354 100644
--- a/drivers/message/fusion/lsi/mpi_history.txt
+++ b/drivers/message/fusion/lsi/mpi_history.txt
@@ -3,28 +3,28 @@
3 MPI Header File Change History 3 MPI Header File Change History
4 ============================== 4 ==============================
5 5
6 Copyright (c) 2000-2007 LSI Corporation. 6 Copyright (c) 2000-2008 LSI Corporation.
7 7
8 --------------------------------------- 8 ---------------------------------------
9 Header Set Release Version: 01.05.16 9 Header Set Release Version: 01.05.19
10 Header Set Release Date: 05-24-07 10 Header Set Release Date: 03-28-08
11 --------------------------------------- 11 ---------------------------------------
12 12
13 Filename Current version Prior version 13 Filename Current version Prior version
14 ---------- --------------- ------------- 14 ---------- --------------- -------------
15 mpi.h 01.05.13 01.05.12 15 mpi.h 01.05.16 01.05.15
16 mpi_ioc.h 01.05.14 01.05.13 16 mpi_ioc.h 01.05.16 01.05.15
17 mpi_cnfg.h 01.05.15 01.05.14 17 mpi_cnfg.h 01.05.18 01.05.17
18 mpi_init.h 01.05.09 01.05.09 18 mpi_init.h 01.05.09 01.05.09
19 mpi_targ.h 01.05.06 01.05.06 19 mpi_targ.h 01.05.06 01.05.06
20 mpi_fc.h 01.05.01 01.05.01 20 mpi_fc.h 01.05.01 01.05.01
21 mpi_lan.h 01.05.01 01.05.01 21 mpi_lan.h 01.05.01 01.05.01
22 mpi_raid.h 01.05.03 01.05.03 22 mpi_raid.h 01.05.05 01.05.05
23 mpi_tool.h 01.05.03 01.05.03 23 mpi_tool.h 01.05.03 01.05.03
24 mpi_inb.h 01.05.01 01.05.01 24 mpi_inb.h 01.05.01 01.05.01
25 mpi_sas.h 01.05.04 01.05.04 25 mpi_sas.h 01.05.05 01.05.05
26 mpi_type.h 01.05.02 01.05.02 26 mpi_type.h 01.05.02 01.05.02
27 mpi_history.txt 01.05.14 01.05.14 27 mpi_history.txt 01.05.19 01.05.18
28 28
29 29
30 * Date Version Description 30 * Date Version Description
@@ -96,6 +96,9 @@ mpi.h
96 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT. 96 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.
97 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT. 97 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT.
98 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT. 98 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT.
99 * 08-07-07 01.05.14 Bumped MPI_HEADER_VERSION_UNIT.
100 * 01-15-08 01.05.15 Bumped MPI_HEADER_VERSION_UNIT.
101 * 03-28-08 01.05.16 Bumped MPI_HEADER_VERSION_UNIT.
99 * -------------------------------------------------------------------------- 102 * --------------------------------------------------------------------------
100 103
101mpi_ioc.h 104mpi_ioc.h
@@ -127,7 +130,7 @@ mpi_ioc.h
127 * 08-08-01 01.02.01 Original release for v1.2 work. 130 * 08-08-01 01.02.01 Original release for v1.2 work.
128 * New format for FWVersion and ProductId in 131 * New format for FWVersion and ProductId in
129 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER. 132 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER.
130 * 08-31-01 01.02.02 Added event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and 133 * 08-31-01 01.02.02 Addded event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and
131 * related structure and defines. 134 * related structure and defines.
132 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED. 135 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED.
133 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE. 136 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE.
@@ -187,7 +190,7 @@ mpi_ioc.h
187 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED. 190 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED.
188 * Added MaxInitiators field to PortFacts reply. 191 * Added MaxInitiators field to PortFacts reply.
189 * Added SAS Device Status Change ReasonCode for 192 * Added SAS Device Status Change ReasonCode for
190 * asynchronous notification. 193 * asynchronous notificaiton.
191 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event 194 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event
192 * data structure. 195 * data structure.
193 * Added new ImageType values for FWDownload and FWUpload 196 * Added new ImageType values for FWDownload and FWUpload
@@ -199,6 +202,16 @@ mpi_ioc.h
199 * added _MULTI_PORT_DOMAIN. 202 * added _MULTI_PORT_DOMAIN.
200 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request. 203 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request.
201 * Added Common Boot Block type to FWUpload Request. 204 * Added Common Boot Block type to FWUpload Request.
205 * 08-07-07 01.05.15 Added MPI_EVENT_SAS_INIT_RC_REMOVED define.
206 * Added MPI_EVENT_IR2_RC_DUAL_PORT_ADDED and
207 * MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED for IR2 event data.
208 * Added SASAddress field to SAS Initiator Device Table
209 * Overflow event data structure.
210 * 03-28-08 01.05.16 Added two new ReasonCode values to SAS Device Status
211 * Change Event data to indicate completion of internally
212 * generated task management.
213 * Added MPI_EVENT_DSCVRY_ERR_DS_SATA_INIT_FAILURE define.
214 * Added MPI_EVENT_SAS_INIT_RC_INACCESSIBLE define.
202 * -------------------------------------------------------------------------- 215 * --------------------------------------------------------------------------
203 216
204mpi_cnfg.h 217mpi_cnfg.h
@@ -213,7 +226,7 @@ mpi_cnfg.h
213 * Added _RESPONSE_ID_MASK definition to SCSI_PORT_1 226 * Added _RESPONSE_ID_MASK definition to SCSI_PORT_1
214 * page and updated the page version. 227 * page and updated the page version.
215 * Added Information field and _INFO_PARAMS_NEGOTIATED 228 * Added Information field and _INFO_PARAMS_NEGOTIATED
216 * definition to SCSI_DEVICE_0 page. 229 * definitionto SCSI_DEVICE_0 page.
217 * 06-22-00 01.00.03 Removed batch controls from LAN_0 page and updated the 230 * 06-22-00 01.00.03 Removed batch controls from LAN_0 page and updated the
218 * page version. 231 * page version.
219 * Added BucketsRemaining to LAN_1 page, redefined the 232 * Added BucketsRemaining to LAN_1 page, redefined the
@@ -496,6 +509,20 @@ mpi_cnfg.h
496 * Expander Page 0 Flags field. 509 * Expander Page 0 Flags field.
497 * Fixed define for 510 * Fixed define for
498 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED. 511 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED.
512 * 08-07-07 01.05.16 Added MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT
513 * define.
514 * Added BIOS Page 4 structure.
515 * Added MPI_RAID_PHYS_DISK1_PATH_MAX define for RAID
516 * Physcial Disk Page 1.
517 * 01-15-07 01.05.17 Added additional bit defines for ExtFlags field of
518 * Manufacturing Page 4.
519 * Added Solid State Drives Supported bit to IOC Page 6
520 * Capabilities Flags.
521 * Added new value for AccessStatus field of SAS Device
522 * Page 0 (_SATA_NEEDS_INITIALIZATION).
523 * 03-28-08 01.05.18 Defined new bits in Manufacturing Page 4 ExtFlags field
524 * to control coercion size and the mixing of SAS and SATA
525 * SSD drives.
499 * -------------------------------------------------------------------------- 526 * --------------------------------------------------------------------------
500 527
501mpi_init.h 528mpi_init.h
@@ -661,6 +688,9 @@ mpi_raid.h
661 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE. 688 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE.
662 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and 689 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and
663 * associated defines. 690 * associated defines.
691 * 08-07-07 01.05.04 Added Disable Full Rebuild bit to the ActionDataWord
692 * for the RAID Action MPI_RAID_ACTION_DISABLE_VOLUME.
693 * 01-15-08 01.05.05 Added define for MPI_RAID_ACTION_SET_VOLUME_NAME.
664 * -------------------------------------------------------------------------- 694 * --------------------------------------------------------------------------
665 695
666mpi_tool.h 696mpi_tool.h
@@ -694,6 +724,10 @@ mpi_sas.h
694 * reply. 724 * reply.
695 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO 725 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO
696 * Unit Control request. 726 * Unit Control request.
727 * 01-15-08 01.05.05 Added support for MPI_SAS_OP_SET_IOC_PARAMETER,
728 * including adding IOCParameter and IOCParameter value
729 * fields to SAS IO Unit Control Request.
730 * Added MPI_SAS_DEVICE_INFO_PRODUCT_SPECIFIC define.
697 * -------------------------------------------------------------------------- 731 * --------------------------------------------------------------------------
698 732
699mpi_type.h 733mpi_type.h
@@ -709,20 +743,20 @@ mpi_type.h
709 743
710mpi_history.txt Parts list history 744mpi_history.txt Parts list history
711 745
712Filename 01.05.15 01.05.15 746Filename 01.05.19 01.05.18 01.05.17 01.05.16 01.05.15
713---------- -------- -------- 747---------- -------- -------- -------- -------- --------
714mpi.h 01.05.12 01.05.13 748mpi.h 01.05.16 01.05.15 01.05.14 01.05.13 01.05.12
715mpi_ioc.h 01.05.13 01.05.14 749mpi_ioc.h 01.05.16 01.05.15 01.05.15 01.05.14 01.05.13
716mpi_cnfg.h 01.05.14 01.05.15 750mpi_cnfg.h 01.05.18 01.05.17 01.05.16 01.05.15 01.05.14
717mpi_init.h 01.05.09 01.05.09 751mpi_init.h 01.05.09 01.05.09 01.05.09 01.05.09 01.05.09
718mpi_targ.h 01.05.06 01.05.06 752mpi_targ.h 01.05.06 01.05.06 01.05.06 01.05.06 01.05.06
719mpi_fc.h 01.05.01 01.05.01 753mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
720mpi_lan.h 01.05.01 01.05.01 754mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
721mpi_raid.h 01.05.03 01.05.03 755mpi_raid.h 01.05.05 01.05.05 01.05.04 01.05.03 01.05.03
722mpi_tool.h 01.05.03 01.05.03 756mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03 01.05.03
723mpi_inb.h 01.05.01 01.05.01 757mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
724mpi_sas.h 01.05.04 01.05.04 758mpi_sas.h 01.05.05 01.05.05 01.05.04 01.05.04 01.05.04
725mpi_type.h 01.05.02 01.05.02 759mpi_type.h 01.05.02 01.05.02 01.05.02 01.05.02 01.05.02
726 760
727Filename 01.05.14 01.05.13 01.05.12 01.05.11 01.05.10 01.05.09 761Filename 01.05.14 01.05.13 01.05.12 01.05.11 01.05.10 01.05.09
728---------- -------- -------- -------- -------- -------- -------- 762---------- -------- -------- -------- -------- -------- --------
diff --git a/drivers/message/fusion/lsi/mpi_init.h b/drivers/message/fusion/lsi/mpi_init.h
index a9e3693601a7..4295d062caa7 100644
--- a/drivers/message/fusion/lsi/mpi_init.h
+++ b/drivers/message/fusion/lsi/mpi_init.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2007 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_init.h 5 * Name: mpi_init.h
diff --git a/drivers/message/fusion/lsi/mpi_ioc.h b/drivers/message/fusion/lsi/mpi_ioc.h
index 5cbb6bd048e1..8faa4fab7b89 100644
--- a/drivers/message/fusion/lsi/mpi_ioc.h
+++ b/drivers/message/fusion/lsi/mpi_ioc.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2007 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_ioc.h 5 * Name: mpi_ioc.h
6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages 6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages
7 * Creation Date: August 11, 2000 7 * Creation Date: August 11, 2000
8 * 8 *
9 * mpi_ioc.h Version: 01.05.14 9 * mpi_ioc.h Version: 01.05.16
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -113,6 +113,16 @@
113 * added _MULTI_PORT_DOMAIN. 113 * added _MULTI_PORT_DOMAIN.
114 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request. 114 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request.
115 * Added Common Boot Block type to FWUpload Request. 115 * Added Common Boot Block type to FWUpload Request.
116 * 08-07-07 01.05.15 Added MPI_EVENT_SAS_INIT_RC_REMOVED define.
117 * Added MPI_EVENT_IR2_RC_DUAL_PORT_ADDED and
118 * MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED for IR2 event data.
119 * Added SASAddress field to SAS Initiator Device Table
120 * Overflow event data structure.
121 * 03-28-08 01.05.16 Added two new ReasonCode values to SAS Device Status
122 * Change Event data to indicate completion of internally
123 * generated task management.
124 * Added MPI_EVENT_DSCVRY_ERR_DS_SATA_INIT_FAILURE define.
125 * Added MPI_EVENT_SAS_INIT_RC_INACCESSIBLE define.
116 * -------------------------------------------------------------------------- 126 * --------------------------------------------------------------------------
117 */ 127 */
118 128
@@ -612,6 +622,8 @@ typedef struct _EVENT_DATA_SAS_DEVICE_STATUS_CHANGE
612#define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B) 622#define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B)
613#define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C) 623#define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C)
614#define MPI_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION (0x0D) 624#define MPI_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION (0x0D)
625#define MPI_EVENT_SAS_DEV_STAT_RC_CMPL_INTERNAL_DEV_RESET (0x0E)
626#define MPI_EVENT_SAS_DEV_STAT_RC_CMPL_TASK_ABORT_INTERNAL (0x0F)
615 627
616 628
617/* SCSI Event data for Queue Full event */ 629/* SCSI Event data for Queue Full event */
@@ -708,6 +720,8 @@ typedef struct _MPI_EVENT_DATA_IR2
708#define MPI_EVENT_IR2_RC_PD_REMOVED (0x05) 720#define MPI_EVENT_IR2_RC_PD_REMOVED (0x05)
709#define MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED (0x06) 721#define MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED (0x06)
710#define MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR (0x07) 722#define MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR (0x07)
723#define MPI_EVENT_IR2_RC_DUAL_PORT_ADDED (0x08)
724#define MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED (0x09)
711 725
712/* defines for logical disk states */ 726/* defines for logical disk states */
713#define MPI_LD_STATE_OPTIMAL (0x00) 727#define MPI_LD_STATE_OPTIMAL (0x00)
@@ -867,6 +881,7 @@ typedef struct _EVENT_DATA_DISCOVERY_ERROR
867#define MPI_EVENT_DSCVRY_ERR_DS_UNSUPPORTED_DEVICE (0x00000800) 881#define MPI_EVENT_DSCVRY_ERR_DS_UNSUPPORTED_DEVICE (0x00000800)
868#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000) 882#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000)
869#define MPI_EVENT_DSCVRY_ERR_DS_MULTI_PORT_DOMAIN (0x00002000) 883#define MPI_EVENT_DSCVRY_ERR_DS_MULTI_PORT_DOMAIN (0x00002000)
884#define MPI_EVENT_DSCVRY_ERR_DS_SATA_INIT_FAILURE (0x00004000)
870 885
871/* SAS SMP Error Event data */ 886/* SAS SMP Error Event data */
872 887
@@ -902,6 +917,8 @@ typedef struct _EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE
902 917
903/* defines for the ReasonCode field of the SAS Initiator Device Status Change event */ 918/* defines for the ReasonCode field of the SAS Initiator Device Status Change event */
904#define MPI_EVENT_SAS_INIT_RC_ADDED (0x01) 919#define MPI_EVENT_SAS_INIT_RC_ADDED (0x01)
920#define MPI_EVENT_SAS_INIT_RC_REMOVED (0x02)
921#define MPI_EVENT_SAS_INIT_RC_INACCESSIBLE (0x03)
905 922
906/* SAS Initiator Device Table Overflow Event data */ 923/* SAS Initiator Device Table Overflow Event data */
907 924
@@ -910,6 +927,7 @@ typedef struct _EVENT_DATA_SAS_INIT_TABLE_OVERFLOW
910 U8 MaxInit; /* 00h */ 927 U8 MaxInit; /* 00h */
911 U8 CurrentInit; /* 01h */ 928 U8 CurrentInit; /* 01h */
912 U16 Reserved1; /* 02h */ 929 U16 Reserved1; /* 02h */
930 U64 SASAddress; /* 04h */
913} EVENT_DATA_SAS_INIT_TABLE_OVERFLOW, 931} EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
914 MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW, 932 MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
915 MpiEventDataSasInitTableOverflow_t, 933 MpiEventDataSasInitTableOverflow_t,
diff --git a/drivers/message/fusion/lsi/mpi_lan.h b/drivers/message/fusion/lsi/mpi_lan.h
index 03253b53b785..f41fcb69b359 100644
--- a/drivers/message/fusion/lsi/mpi_lan.h
+++ b/drivers/message/fusion/lsi/mpi_lan.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_lan.h 5 * Name: mpi_lan.h
diff --git a/drivers/message/fusion/lsi/mpi_log_fc.h b/drivers/message/fusion/lsi/mpi_log_fc.h
index e4dafcefeecd..face6e7acc72 100644
--- a/drivers/message/fusion/lsi/mpi_log_fc.h
+++ b/drivers/message/fusion/lsi/mpi_log_fc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2001 LSI Corporation. All rights reserved. 2 * Copyright (c) 2000-2008 LSI Corporation. All rights reserved.
3 * 3 *
4 * NAME: fc_log.h 4 * NAME: fc_log.h
5 * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips 5 * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips
diff --git a/drivers/message/fusion/lsi/mpi_log_sas.h b/drivers/message/fusion/lsi/mpi_log_sas.h
index af9da03e95e5..691620dbedd2 100644
--- a/drivers/message/fusion/lsi/mpi_log_sas.h
+++ b/drivers/message/fusion/lsi/mpi_log_sas.h
@@ -1,6 +1,6 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * Copyright 2003 LSI Corporation. All rights reserved. * 3 * Copyright (c) 2000-2008 LSI Corporation. All rights reserved. *
4 * * 4 * *
5 * Description * 5 * Description *
6 * ------------ * 6 * ------------ *
@@ -73,6 +73,8 @@
73#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO (0x00070004) 73#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO (0x00070004)
74#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO_REQ (0x00070005) 74#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO_REQ (0x00070005)
75 75
76#define IOP_LOGINFO_CODE_LOG_TIMESTAMP_EVENT (0x00080000)
77
76/****************************************************************************/ 78/****************************************************************************/
77/* PL LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = PL */ 79/* PL LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = PL */
78/****************************************************************************/ 80/****************************************************************************/
@@ -92,7 +94,7 @@
92#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_OPEN_TIMEOUT_EXP (0x0000000C) 94#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_OPEN_TIMEOUT_EXP (0x0000000C)
93#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_UNUSED_0D (0x0000000D) 95#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_UNUSED_0D (0x0000000D)
94#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_DVTBLE_ACCSS_FAIL (0x0000000E) 96#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_DVTBLE_ACCSS_FAIL (0x0000000E)
95#define PL_LOGINFO_SUB CODE_OPEN_FAIL_BAD_DEST (0x00000011) 97#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_BAD_DEST (0x00000011)
96#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RATE_NOT_SUPP (0x00000012) 98#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RATE_NOT_SUPP (0x00000012)
97#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_PROT_NOT_SUPP (0x00000013) 99#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_PROT_NOT_SUPP (0x00000013)
98#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RESERVED_ABANDON0 (0x00000014) 100#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RESERVED_ABANDON0 (0x00000014)
@@ -159,10 +161,11 @@
159 161
160#define PL_LOGINFO_SUB_CODE_INVALID_SGL (0x00000200) 162#define PL_LOGINFO_SUB_CODE_INVALID_SGL (0x00000200)
161#define PL_LOGINFO_SUB_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH (0x00000300) 163#define PL_LOGINFO_SUB_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH (0x00000300)
162#define PL_LOGINFO_SUB_CODE_FRAME_XFER_ERROR (0x00000400) /* Bits 0-3 encode Transport Status Register (offset 0x08) */ 164#define PL_LOGINFO_SUB_CODE_FRAME_XFER_ERROR (0x00000400)
163 /* Bit 0 is Status Bit 0: FrameXferErr */ 165/* Bits 0-3 encode Transport Status Register (offset 0x08) */
164 /* Bit 1 & 2 are Status Bits 16 and 17: FrameXmitErrStatus */ 166/* Bit 0 is Status Bit 0: FrameXferErr */
165 /* Bit 3 is Status Bit 18 WriteDataLengthGTDataLengthErr */ 167/* Bit 1 & 2 are Status Bits 16 and 17: FrameXmitErrStatus */
168/* Bit 3 is Status Bit 18 WriteDataLenghtGTDataLengthErr */
166 169
167#define PL_LOGINFO_SUB_CODE_TX_FM_CONNECTED_LOW (0x00000500) 170#define PL_LOGINFO_SUB_CODE_TX_FM_CONNECTED_LOW (0x00000500)
168#define PL_LOGINFO_SUB_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET (0x00000600) 171#define PL_LOGINFO_SUB_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET (0x00000600)
@@ -177,6 +180,11 @@
177#define PL_LOGINFO_SUB_CODE_DISCOVERY_REMOTE_SEP_RESET (0x00000E01) 180#define PL_LOGINFO_SUB_CODE_DISCOVERY_REMOTE_SEP_RESET (0x00000E01)
178#define PL_LOGINFO_SUB_CODE_SECOND_OPEN (0x00000F00) 181#define PL_LOGINFO_SUB_CODE_SECOND_OPEN (0x00000F00)
179#define PL_LOGINFO_SUB_CODE_DSCVRY_SATA_INIT_TIMEOUT (0x00001000) 182#define PL_LOGINFO_SUB_CODE_DSCVRY_SATA_INIT_TIMEOUT (0x00001000)
183#define PL_LOGINFO_SUB_CODE_BREAK_ON_SATA_CONNECTION (0x00002000)
184/* not currently used in mainline */
185#define PL_LOGINFO_SUB_CODE_BREAK_ON_STUCK_LINK (0x00003000)
186#define PL_LOGINFO_SUB_CODE_BREAK_ON_STUCK_LINK_AIP (0x00004000)
187#define PL_LOGINFO_SUB_CODE_BREAK_ON_INCOMPLETE_BREAK_RCVD (0x00005000)
180 188
181#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_FRAME_FAILURE (0x00200000) /* Can't get SMP Frame */ 189#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_FRAME_FAILURE (0x00200000) /* Can't get SMP Frame */
182#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_READ_ERROR (0x00200010) /* Error occured on SMP Read */ 190#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_READ_ERROR (0x00200010) /* Error occured on SMP Read */
@@ -243,6 +251,8 @@
243#define IR_LOGINFO_VOLUME_ACTIVATE_VOLUME_FAILED (0x00010014) 251#define IR_LOGINFO_VOLUME_ACTIVATE_VOLUME_FAILED (0x00010014)
244/* Activation failed trying to import the volume */ 252/* Activation failed trying to import the volume */
245#define IR_LOGINFO_VOLUME_ACTIVATING_IMPORT_VOLUME_FAILED (0x00010015) 253#define IR_LOGINFO_VOLUME_ACTIVATING_IMPORT_VOLUME_FAILED (0x00010015)
254/* Activation failed trying to import the volume */
255#define IR_LOGINFO_VOLUME_ACTIVATING_TOO_MANY_PHYS_DISKS (0x00010016)
246 256
247/* Phys Disk failed, too many phys disks */ 257/* Phys Disk failed, too many phys disks */
248#define IR_LOGINFO_PHYSDISK_CREATE_TOO_MANY_DISKS (0x00010020) 258#define IR_LOGINFO_PHYSDISK_CREATE_TOO_MANY_DISKS (0x00010020)
@@ -285,6 +295,21 @@
285/* Compatibility Error : IME size limited to < 2TB */ 295/* Compatibility Error : IME size limited to < 2TB */
286#define IR_LOGINFO_COMPAT_ERROR_IME_VOL_NOT_CURRENTLY_SUPPORTED (0x0001003D) 296#define IR_LOGINFO_COMPAT_ERROR_IME_VOL_NOT_CURRENTLY_SUPPORTED (0x0001003D)
287 297
298/* Device Firmware Update: DFU can only be started once */
299#define IR_LOGINFO_DEV_FW_UPDATE_ERR_DFU_IN_PROGRESS (0x00010050)
300/* Device Firmware Update: Volume must be Optimal/Active/non-Quiesced */
301#define IR_LOGINFO_DEV_FW_UPDATE_ERR_DEVICE_IN_INVALID_STATE (0x00010051)
302/* Device Firmware Update: DFU Timeout cannot be zero */
303#define IR_LOGINFO_DEV_FW_UPDATE_ERR_INVALID_TIMEOUT (0x00010052)
304/* Device Firmware Update: CREATE TIMER FAILED */
305#define IR_LOGINFO_DEV_FW_UPDATE_ERR_NO_TIMERS (0x00010053)
306/* Device Firmware Update: Failed to read SAS_IO_UNIT_PG_1 */
307#define IR_LOGINFO_DEV_FW_UPDATE_ERR_READING_CFG_PAGE (0x00010054)
308/* Device Firmware Update: Invalid SAS_IO_UNIT_PG_1 value(s) */
309#define IR_LOGINFO_DEV_FW_UPDATE_ERR_PORT_IO_TIMEOUTS_REQUIRED (0x00010055)
310/* Device Firmware Update: Unable to allocate memory for page */
311#define IR_LOGINFO_DEV_FW_UPDATE_ERR_ALLOC_CFG_PAGE (0x00010056)
312
288 313
289/****************************************************************************/ 314/****************************************************************************/
290/* Defines for convenience */ 315/* Defines for convenience */
diff --git a/drivers/message/fusion/lsi/mpi_raid.h b/drivers/message/fusion/lsi/mpi_raid.h
index 2856108421d7..add60cc85be1 100644
--- a/drivers/message/fusion/lsi/mpi_raid.h
+++ b/drivers/message/fusion/lsi/mpi_raid.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2001-2007 LSI Corporation. 2 * Copyright (c) 2001-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_raid.h 5 * Name: mpi_raid.h
6 * Title: MPI RAID message and structures 6 * Title: MPI RAID message and structures
7 * Creation Date: February 27, 2001 7 * Creation Date: February 27, 2001
8 * 8 *
9 * mpi_raid.h Version: 01.05.03 9 * mpi_raid.h Version: 01.05.05
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -34,6 +34,9 @@
34 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE. 34 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE.
35 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and 35 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and
36 * associated defines. 36 * associated defines.
37 * 08-07-07 01.05.04 Added Disable Full Rebuild bit to the ActionDataWord
38 * for the RAID Action MPI_RAID_ACTION_DISABLE_VOLUME.
39 * 01-15-08 01.05.05 Added define for MPI_RAID_ACTION_SET_VOLUME_NAME.
37 * -------------------------------------------------------------------------- 40 * --------------------------------------------------------------------------
38 */ 41 */
39 42
@@ -93,6 +96,7 @@ typedef struct _MSG_RAID_ACTION
93#define MPI_RAID_ACTION_SET_RESYNC_RATE (0x13) 96#define MPI_RAID_ACTION_SET_RESYNC_RATE (0x13)
94#define MPI_RAID_ACTION_SET_DATA_SCRUB_RATE (0x14) 97#define MPI_RAID_ACTION_SET_DATA_SCRUB_RATE (0x14)
95#define MPI_RAID_ACTION_DEVICE_FW_UPDATE_MODE (0x15) 98#define MPI_RAID_ACTION_DEVICE_FW_UPDATE_MODE (0x15)
99#define MPI_RAID_ACTION_SET_VOLUME_NAME (0x16)
96 100
97/* ActionDataWord defines for use with MPI_RAID_ACTION_CREATE_VOLUME action */ 101/* ActionDataWord defines for use with MPI_RAID_ACTION_CREATE_VOLUME action */
98#define MPI_RAID_ACTION_ADATA_DO_NOT_SYNC (0x00000001) 102#define MPI_RAID_ACTION_ADATA_DO_NOT_SYNC (0x00000001)
@@ -105,6 +109,9 @@ typedef struct _MSG_RAID_ACTION
105#define MPI_RAID_ACTION_ADATA_KEEP_LBA0 (0x00000000) 109#define MPI_RAID_ACTION_ADATA_KEEP_LBA0 (0x00000000)
106#define MPI_RAID_ACTION_ADATA_ZERO_LBA0 (0x00000002) 110#define MPI_RAID_ACTION_ADATA_ZERO_LBA0 (0x00000002)
107 111
112/* ActionDataWord defines for use with MPI_RAID_ACTION_DISABLE_VOLUME action */
113#define MPI_RAID_ACTION_ADATA_DISABLE_FULL_REBUILD (0x00000001)
114
108/* ActionDataWord defines for use with MPI_RAID_ACTION_ACTIVATE_VOLUME action */ 115/* ActionDataWord defines for use with MPI_RAID_ACTION_ACTIVATE_VOLUME action */
109#define MPI_RAID_ACTION_ADATA_INACTIVATE_ALL (0x00000001) 116#define MPI_RAID_ACTION_ADATA_INACTIVATE_ALL (0x00000001)
110 117
diff --git a/drivers/message/fusion/lsi/mpi_sas.h b/drivers/message/fusion/lsi/mpi_sas.h
index 33fca83cefc2..ab410036bbfc 100644
--- a/drivers/message/fusion/lsi/mpi_sas.h
+++ b/drivers/message/fusion/lsi/mpi_sas.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2004-2006 LSI Corporation. 2 * Copyright (c) 2004-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_sas.h 5 * Name: mpi_sas.h
6 * Title: MPI Serial Attached SCSI structures and definitions 6 * Title: MPI Serial Attached SCSI structures and definitions
7 * Creation Date: August 19, 2004 7 * Creation Date: August 19, 2004
8 * 8 *
9 * mpi_sas.h Version: 01.05.04 9 * mpi_sas.h Version: 01.05.05
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -23,6 +23,10 @@
23 * reply. 23 * reply.
24 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO 24 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO
25 * Unit Control request. 25 * Unit Control request.
26 * 01-15-08 01.05.05 Added support for MPI_SAS_OP_SET_IOC_PARAMETER,
27 * including adding IOCParameter and IOCParameter value
28 * fields to SAS IO Unit Control Request.
29 * Added MPI_SAS_DEVICE_INFO_PRODUCT_SPECIFIC define.
26 * -------------------------------------------------------------------------- 30 * --------------------------------------------------------------------------
27 */ 31 */
28 32
@@ -60,6 +64,8 @@
60 * Values for the SAS DeviceInfo field used in SAS Device Status Change Event 64 * Values for the SAS DeviceInfo field used in SAS Device Status Change Event
61 * data and SAS IO Unit Configuration pages. 65 * data and SAS IO Unit Configuration pages.
62 */ 66 */
67#define MPI_SAS_DEVICE_INFO_PRODUCT_SPECIFIC (0xF0000000)
68
63#define MPI_SAS_DEVICE_INFO_SEP (0x00004000) 69#define MPI_SAS_DEVICE_INFO_SEP (0x00004000)
64#define MPI_SAS_DEVICE_INFO_ATAPI_DEVICE (0x00002000) 70#define MPI_SAS_DEVICE_INFO_ATAPI_DEVICE (0x00002000)
65#define MPI_SAS_DEVICE_INFO_LSI_DEVICE (0x00001000) 71#define MPI_SAS_DEVICE_INFO_LSI_DEVICE (0x00001000)
@@ -216,7 +222,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
216 U8 ChainOffset; /* 02h */ 222 U8 ChainOffset; /* 02h */
217 U8 Function; /* 03h */ 223 U8 Function; /* 03h */
218 U16 DevHandle; /* 04h */ 224 U16 DevHandle; /* 04h */
219 U8 Reserved3; /* 06h */ 225 U8 IOCParameter; /* 06h */
220 U8 MsgFlags; /* 07h */ 226 U8 MsgFlags; /* 07h */
221 U32 MsgContext; /* 08h */ 227 U32 MsgContext; /* 08h */
222 U8 TargetID; /* 0Ch */ 228 U8 TargetID; /* 0Ch */
@@ -225,7 +231,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
225 U8 PrimFlags; /* 0Fh */ 231 U8 PrimFlags; /* 0Fh */
226 U32 Primitive; /* 10h */ 232 U32 Primitive; /* 10h */
227 U64 SASAddress; /* 14h */ 233 U64 SASAddress; /* 14h */
228 U32 Reserved4; /* 1Ch */ 234 U32 IOCParameterValue; /* 1Ch */
229} MSG_SAS_IOUNIT_CONTROL_REQUEST, MPI_POINTER PTR_MSG_SAS_IOUNIT_CONTROL_REQUEST, 235} MSG_SAS_IOUNIT_CONTROL_REQUEST, MPI_POINTER PTR_MSG_SAS_IOUNIT_CONTROL_REQUEST,
230 SasIoUnitControlRequest_t, MPI_POINTER pSasIoUnitControlRequest_t; 236 SasIoUnitControlRequest_t, MPI_POINTER pSasIoUnitControlRequest_t;
231 237
@@ -241,6 +247,8 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
241#define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL (0x0C) 247#define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL (0x0C)
242#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE (0x0D) /* obsolete name */ 248#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE (0x0D) /* obsolete name */
243#define MPI_SAS_OP_REMOVE_DEVICE (0x0D) 249#define MPI_SAS_OP_REMOVE_DEVICE (0x0D)
250#define MPI_SAS_OP_SET_IOC_PARAMETER (0x0E)
251#define MPI_SAS_OP_PRODUCT_SPECIFIC_MIN (0x80)
244 252
245/* values for the PrimFlags field */ 253/* values for the PrimFlags field */
246#define MPI_SAS_PRIMFLAGS_SINGLE (0x08) 254#define MPI_SAS_PRIMFLAGS_SINGLE (0x08)
@@ -256,7 +264,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REPLY
256 U8 MsgLength; /* 02h */ 264 U8 MsgLength; /* 02h */
257 U8 Function; /* 03h */ 265 U8 Function; /* 03h */
258 U16 DevHandle; /* 04h */ 266 U16 DevHandle; /* 04h */
259 U8 Reserved3; /* 06h */ 267 U8 IOCParameter; /* 06h */
260 U8 MsgFlags; /* 07h */ 268 U8 MsgFlags; /* 07h */
261 U32 MsgContext; /* 08h */ 269 U32 MsgContext; /* 08h */
262 U16 Reserved4; /* 0Ch */ 270 U16 Reserved4; /* 0Ch */
diff --git a/drivers/message/fusion/lsi/mpi_targ.h b/drivers/message/fusion/lsi/mpi_targ.h
index ff8c37d3fdcb..c3dea7f6909d 100644
--- a/drivers/message/fusion/lsi/mpi_targ.h
+++ b/drivers/message/fusion/lsi/mpi_targ.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_targ.h 5 * Name: mpi_targ.h
diff --git a/drivers/message/fusion/lsi/mpi_tool.h b/drivers/message/fusion/lsi/mpi_tool.h
index 8834ae6ce0f2..53cd715aa7e4 100644
--- a/drivers/message/fusion/lsi/mpi_tool.h
+++ b/drivers/message/fusion/lsi/mpi_tool.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2001-2005 LSI Corporation. 2 * Copyright (c) 2001-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_tool.h 5 * Name: mpi_tool.h
diff --git a/drivers/message/fusion/lsi/mpi_type.h b/drivers/message/fusion/lsi/mpi_type.h
index 08dad9c1e446..888b26dbc413 100644
--- a/drivers/message/fusion/lsi/mpi_type.h
+++ b/drivers/message/fusion/lsi/mpi_type.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_type.h 5 * Name: mpi_type.h
6 * Title: MPI Basic type definitions 6 * Title: MPI Basic type definitions
7 * Creation Date: June 6, 2000 7 * Creation Date: June 6, 2000
8 * 8 *
9 * mpi_type.h Version: 01.05.01 9 * mpi_type.h Version: 01.05.02
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index c4e8b9aa3827..96ac88317b8e 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -79,9 +79,22 @@ MODULE_VERSION(my_VERSION);
79/* 79/*
80 * cmd line parameters 80 * cmd line parameters
81 */ 81 */
82static int mpt_msi_enable = -1; 82
83module_param(mpt_msi_enable, int, 0); 83static int mpt_msi_enable_spi;
84MODULE_PARM_DESC(mpt_msi_enable, " MSI Support Enable (default=0)"); 84module_param(mpt_msi_enable_spi, int, 0);
85MODULE_PARM_DESC(mpt_msi_enable_spi, " Enable MSI Support for SPI \
86 controllers (default=0)");
87
88static int mpt_msi_enable_fc;
89module_param(mpt_msi_enable_fc, int, 0);
90MODULE_PARM_DESC(mpt_msi_enable_fc, " Enable MSI Support for FC \
91 controllers (default=0)");
92
93static int mpt_msi_enable_sas;
94module_param(mpt_msi_enable_sas, int, 1);
95MODULE_PARM_DESC(mpt_msi_enable_sas, " Enable MSI Support for SAS \
96 controllers (default=1)");
97
85 98
86static int mpt_channel_mapping; 99static int mpt_channel_mapping;
87module_param(mpt_channel_mapping, int, 0); 100module_param(mpt_channel_mapping, int, 0);
@@ -91,7 +104,17 @@ static int mpt_debug_level;
91static int mpt_set_debug_level(const char *val, struct kernel_param *kp); 104static int mpt_set_debug_level(const char *val, struct kernel_param *kp);
92module_param_call(mpt_debug_level, mpt_set_debug_level, param_get_int, 105module_param_call(mpt_debug_level, mpt_set_debug_level, param_get_int,
93 &mpt_debug_level, 0600); 106 &mpt_debug_level, 0600);
94MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h - (default=0)"); 107MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h \
108 - (default=0)");
109
110int mpt_fwfault_debug;
111EXPORT_SYMBOL(mpt_fwfault_debug);
112module_param_call(mpt_fwfault_debug, param_set_int, param_get_int,
113 &mpt_fwfault_debug, 0600);
114MODULE_PARM_DESC(mpt_fwfault_debug, "Enable detection of Firmware fault"
115 " and halt Firmware on fault - (default=0)");
116
117
95 118
96#ifdef MFCNT 119#ifdef MFCNT
97static int mfcounter = 0; 120static int mfcounter = 0;
@@ -1751,16 +1774,25 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1751 ioc->bus_type = SAS; 1774 ioc->bus_type = SAS;
1752 } 1775 }
1753 1776
1754 if (mpt_msi_enable == -1) {
1755 /* Enable on SAS, disable on FC and SPI */
1756 if (ioc->bus_type == SAS)
1757 ioc->msi_enable = 1;
1758 else
1759 ioc->msi_enable = 0;
1760 } else
1761 /* follow flag: 0 - disable; 1 - enable */
1762 ioc->msi_enable = mpt_msi_enable;
1763 1777
1778 switch (ioc->bus_type) {
1779
1780 case SAS:
1781 ioc->msi_enable = mpt_msi_enable_sas;
1782 break;
1783
1784 case SPI:
1785 ioc->msi_enable = mpt_msi_enable_spi;
1786 break;
1787
1788 case FC:
1789 ioc->msi_enable = mpt_msi_enable_fc;
1790 break;
1791
1792 default:
1793 ioc->msi_enable = 0;
1794 break;
1795 }
1764 if (ioc->errata_flag_1064) 1796 if (ioc->errata_flag_1064)
1765 pci_disable_io_access(pdev); 1797 pci_disable_io_access(pdev);
1766 1798
@@ -6313,6 +6345,33 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
6313 *size = y; 6345 *size = y;
6314} 6346}
6315 6347
6348
6349/**
6350 * mpt_halt_firmware - Halts the firmware if it is operational and panic
6351 * the kernel
6352 * @ioc: Pointer to MPT_ADAPTER structure
6353 *
6354 **/
6355void
6356mpt_halt_firmware(MPT_ADAPTER *ioc)
6357{
6358 u32 ioc_raw_state;
6359
6360 ioc_raw_state = mpt_GetIocState(ioc, 0);
6361
6362 if ((ioc_raw_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) {
6363 printk(MYIOC_s_ERR_FMT "IOC is in FAULT state (%04xh)!!!\n",
6364 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK);
6365 panic("%s: IOC Fault (%04xh)!!!\n", ioc->name,
6366 ioc_raw_state & MPI_DOORBELL_DATA_MASK);
6367 } else {
6368 CHIPREG_WRITE32(&ioc->chip->Doorbell, 0xC0FFEE00);
6369 panic("%s: Firmware is halted due to command timeout\n",
6370 ioc->name);
6371 }
6372}
6373EXPORT_SYMBOL(mpt_halt_firmware);
6374
6316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6375/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6317/* 6376/*
6318 * Reset Handling 6377 * Reset Handling
@@ -6345,6 +6404,8 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6345 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name); 6404 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name);
6346 printk("MF count 0x%x !\n", ioc->mfcnt); 6405 printk("MF count 0x%x !\n", ioc->mfcnt);
6347#endif 6406#endif
6407 if (mpt_fwfault_debug)
6408 mpt_halt_firmware(ioc);
6348 6409
6349 /* Reset the adapter. Prevent more than 1 call to 6410 /* Reset the adapter. Prevent more than 1 call to
6350 * mpt_do_ioc_recovery at any instant in time. 6411 * mpt_do_ioc_recovery at any instant in time.
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index dff048cfa101..b3e981d2a506 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -922,11 +922,14 @@ extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
922extern int mpt_findImVolumes(MPT_ADAPTER *ioc); 922extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
923extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); 923extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
924extern int mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num, pRaidPhysDiskPage0_t phys_disk); 924extern int mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num, pRaidPhysDiskPage0_t phys_disk);
925extern void mpt_halt_firmware(MPT_ADAPTER *ioc);
926
925 927
926/* 928/*
927 * Public data decl's... 929 * Public data decl's...
928 */ 930 */
929extern struct list_head ioc_list; 931extern struct list_head ioc_list;
932extern int mpt_fwfault_debug;
930 933
931/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 934/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
932#endif /* } __KERNEL__ */ 935#endif /* } __KERNEL__ */
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index ee090413e598..e62c6bc4ad33 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1846,6 +1846,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1846 if (hd->timeouts < -1) 1846 if (hd->timeouts < -1)
1847 hd->timeouts++; 1847 hd->timeouts++;
1848 1848
1849 if (mpt_fwfault_debug)
1850 mpt_halt_firmware(ioc);
1851
1849 /* Most important! Set TaskMsgContext to SCpnt's MsgContext! 1852 /* Most important! Set TaskMsgContext to SCpnt's MsgContext!
1850 * (the IO to be ABORT'd) 1853 * (the IO to be ABORT'd)
1851 * 1854 *
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 416f9e7286ba..06a2b0f7737c 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -217,6 +217,29 @@ config MFD_WM8350_I2C
217 I2C as the control interface. Additional options must be 217 I2C as the control interface. Additional options must be
218 selected to enable support for the functionality of the chip. 218 selected to enable support for the functionality of the chip.
219 219
220config MFD_PCF50633
221 tristate "Support for NXP PCF50633"
222 depends on I2C
223 help
224 Say yes here if you have NXP PCF50633 chip on your board.
225 This core driver provides register access and IRQ handling
226 facilities, and registers devices for the various functions
227 so that function-specific drivers can bind to them.
228
229config PCF50633_ADC
230 tristate "Support for NXP PCF50633 ADC"
231 depends on MFD_PCF50633
232 help
233 Say yes here if you want to include support for ADC in the
234 NXP PCF50633 chip.
235
236config PCF50633_GPIO
237 tristate "Support for NXP PCF50633 GPIO"
238 depends on MFD_PCF50633
239 help
240 Say yes here if you want to include support GPIO for pins on
241 the PCF50633 chip.
242
220endmenu 243endmenu
221 244
222menu "Multimedia Capabilities Port drivers" 245menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0c9418b36c26..3afb5192e4da 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -37,3 +37,7 @@ endif
37obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o 37obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
38 38
39obj-$(CONFIG_PMIC_DA903X) += da903x.o 39obj-$(CONFIG_PMIC_DA903X) += da903x.o
40
41obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o
42obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
43obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o \ No newline at end of file
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 4214b3f72426..7ac12cb0be4a 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -107,6 +107,9 @@ static const u8 msp_gpios[] = {
107 MSP_GPIO(0, SWITCH1), MSP_GPIO(1, SWITCH1), 107 MSP_GPIO(0, SWITCH1), MSP_GPIO(1, SWITCH1),
108 MSP_GPIO(2, SWITCH1), MSP_GPIO(3, SWITCH1), 108 MSP_GPIO(2, SWITCH1), MSP_GPIO(3, SWITCH1),
109 MSP_GPIO(4, SWITCH1), 109 MSP_GPIO(4, SWITCH1),
110 /* switches on MMC/SD sockets */
111 MSP_GPIO(1, SDMMC), MSP_GPIO(2, SDMMC), /* mmc0 WP, nCD */
112 MSP_GPIO(3, SDMMC), MSP_GPIO(4, SDMMC), /* mmc1 WP, nCD */
110}; 113};
111 114
112#define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3) 115#define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3)
@@ -304,6 +307,13 @@ static int add_children(struct i2c_client *client)
304 gpio_export(gpio, false); 307 gpio_export(gpio, false);
305 } 308 }
306 309
310 /* MMC/SD inputs -- right after the last config input */
311 if (client->dev.platform_data) {
312 void (*mmcsd_setup)(unsigned) = client->dev.platform_data;
313
314 mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5);
315 }
316
307 /* RTC is a 32 bit counter, no alarm */ 317 /* RTC is a 32 bit counter, no alarm */
308 if (msp_has_rtc()) { 318 if (msp_has_rtc()) {
309 child = add_child(client, "rtc-dm355evm", 319 child = add_child(client, "rtc-dm355evm",
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c
new file mode 100644
index 000000000000..c2d05becfa97
--- /dev/null
+++ b/drivers/mfd/pcf50633-adc.c
@@ -0,0 +1,277 @@
1/* NXP PCF50633 ADC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * NOTE: This driver does not yet support subtractive ADC mode, which means
16 * you can do only one measurement per read request.
17 */
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/device.h>
23#include <linux/platform_device.h>
24#include <linux/completion.h>
25
26#include <linux/mfd/pcf50633/core.h>
27#include <linux/mfd/pcf50633/adc.h>
28
29struct pcf50633_adc_request {
30 int mux;
31 int avg;
32 int result;
33 void (*callback)(struct pcf50633 *, void *, int);
34 void *callback_param;
35
36 /* Used in case of sync requests */
37 struct completion completion;
38
39};
40
41#define PCF50633_MAX_ADC_FIFO_DEPTH 8
42
43struct pcf50633_adc {
44 struct pcf50633 *pcf;
45
46 /* Private stuff */
47 struct pcf50633_adc_request *queue[PCF50633_MAX_ADC_FIFO_DEPTH];
48 int queue_head;
49 int queue_tail;
50 struct mutex queue_mutex;
51};
52
53static inline struct pcf50633_adc *__to_adc(struct pcf50633 *pcf)
54{
55 return platform_get_drvdata(pcf->adc_pdev);
56}
57
58static void adc_setup(struct pcf50633 *pcf, int channel, int avg)
59{
60 channel &= PCF50633_ADCC1_ADCMUX_MASK;
61
62 /* kill ratiometric, but enable ACCSW biasing */
63 pcf50633_reg_write(pcf, PCF50633_REG_ADCC2, 0x00);
64 pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x01);
65
66 /* start ADC conversion on selected channel */
67 pcf50633_reg_write(pcf, PCF50633_REG_ADCC1, channel | avg |
68 PCF50633_ADCC1_ADCSTART | PCF50633_ADCC1_RES_10BIT);
69}
70
71static void trigger_next_adc_job_if_any(struct pcf50633 *pcf)
72{
73 struct pcf50633_adc *adc = __to_adc(pcf);
74 int head;
75
76 mutex_lock(&adc->queue_mutex);
77
78 head = adc->queue_head;
79
80 if (!adc->queue[head]) {
81 mutex_unlock(&adc->queue_mutex);
82 return;
83 }
84 mutex_unlock(&adc->queue_mutex);
85
86 adc_setup(pcf, adc->queue[head]->mux, adc->queue[head]->avg);
87}
88
89static int
90adc_enqueue_request(struct pcf50633 *pcf, struct pcf50633_adc_request *req)
91{
92 struct pcf50633_adc *adc = __to_adc(pcf);
93 int head, tail;
94
95 mutex_lock(&adc->queue_mutex);
96
97 head = adc->queue_head;
98 tail = adc->queue_tail;
99
100 if (adc->queue[tail]) {
101 mutex_unlock(&adc->queue_mutex);
102 return -EBUSY;
103 }
104
105 adc->queue[tail] = req;
106 adc->queue_tail = (tail + 1) & (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
107
108 mutex_unlock(&adc->queue_mutex);
109
110 trigger_next_adc_job_if_any(pcf);
111
112 return 0;
113}
114
115static void
116pcf50633_adc_sync_read_callback(struct pcf50633 *pcf, void *param, int result)
117{
118 struct pcf50633_adc_request *req = param;
119
120 req->result = result;
121 complete(&req->completion);
122}
123
124int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg)
125{
126 struct pcf50633_adc_request *req;
127
128 /* req is freed when the result is ready, in interrupt handler */
129 req = kzalloc(sizeof(*req), GFP_KERNEL);
130 if (!req)
131 return -ENOMEM;
132
133 req->mux = mux;
134 req->avg = avg;
135 req->callback = pcf50633_adc_sync_read_callback;
136 req->callback_param = req;
137
138 init_completion(&req->completion);
139 adc_enqueue_request(pcf, req);
140 wait_for_completion(&req->completion);
141
142 return req->result;
143}
144EXPORT_SYMBOL_GPL(pcf50633_adc_sync_read);
145
146int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg,
147 void (*callback)(struct pcf50633 *, void *, int),
148 void *callback_param)
149{
150 struct pcf50633_adc_request *req;
151
152 /* req is freed when the result is ready, in interrupt handler */
153 req = kmalloc(sizeof(*req), GFP_KERNEL);
154 if (!req)
155 return -ENOMEM;
156
157 req->mux = mux;
158 req->avg = avg;
159 req->callback = callback;
160 req->callback_param = callback_param;
161
162 adc_enqueue_request(pcf, req);
163
164 return 0;
165}
166EXPORT_SYMBOL_GPL(pcf50633_adc_async_read);
167
168static int adc_result(struct pcf50633 *pcf)
169{
170 u8 adcs1, adcs3;
171 u16 result;
172
173 adcs1 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS1);
174 adcs3 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS3);
175 result = (adcs1 << 2) | (adcs3 & PCF50633_ADCS3_ADCDAT1L_MASK);
176
177 dev_dbg(pcf->dev, "adc result = %d\n", result);
178
179 return result;
180}
181
182static void pcf50633_adc_irq(int irq, void *data)
183{
184 struct pcf50633_adc *adc = data;
185 struct pcf50633 *pcf = adc->pcf;
186 struct pcf50633_adc_request *req;
187 int head;
188
189 mutex_lock(&adc->queue_mutex);
190 head = adc->queue_head;
191
192 req = adc->queue[head];
193 if (WARN_ON(!req)) {
194 dev_err(pcf->dev, "pcf50633-adc irq: ADC queue empty!\n");
195 mutex_unlock(&adc->queue_mutex);
196 return;
197 }
198 adc->queue[head] = NULL;
199 adc->queue_head = (head + 1) &
200 (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
201
202 mutex_unlock(&adc->queue_mutex);
203
204 req->callback(pcf, req->callback_param, adc_result(pcf));
205 kfree(req);
206
207 trigger_next_adc_job_if_any(pcf);
208}
209
210static int __devinit pcf50633_adc_probe(struct platform_device *pdev)
211{
212 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
213 struct pcf50633_adc *adc;
214
215 adc = kzalloc(sizeof(*adc), GFP_KERNEL);
216 if (!adc)
217 return -ENOMEM;
218
219 adc->pcf = pdata->pcf;
220 platform_set_drvdata(pdev, adc);
221
222 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ADCRDY,
223 pcf50633_adc_irq, adc);
224
225 mutex_init(&adc->queue_mutex);
226
227 return 0;
228}
229
230static int __devexit pcf50633_adc_remove(struct platform_device *pdev)
231{
232 struct pcf50633_adc *adc = platform_get_drvdata(pdev);
233 int i, head;
234
235 pcf50633_free_irq(adc->pcf, PCF50633_IRQ_ADCRDY);
236
237 mutex_lock(&adc->queue_mutex);
238 head = adc->queue_head;
239
240 if (WARN_ON(adc->queue[head]))
241 dev_err(adc->pcf->dev,
242 "adc driver removed with request pending\n");
243
244 for (i = 0; i < PCF50633_MAX_ADC_FIFO_DEPTH; i++)
245 kfree(adc->queue[i]);
246
247 mutex_unlock(&adc->queue_mutex);
248 kfree(adc);
249
250 return 0;
251}
252
253static struct platform_driver pcf50633_adc_driver = {
254 .driver = {
255 .name = "pcf50633-adc",
256 },
257 .probe = pcf50633_adc_probe,
258 .remove = __devexit_p(pcf50633_adc_remove),
259};
260
261static int __init pcf50633_adc_init(void)
262{
263 return platform_driver_register(&pcf50633_adc_driver);
264}
265module_init(pcf50633_adc_init);
266
267static void __exit pcf50633_adc_exit(void)
268{
269 platform_driver_unregister(&pcf50633_adc_driver);
270}
271module_exit(pcf50633_adc_exit);
272
273MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
274MODULE_DESCRIPTION("PCF50633 adc driver");
275MODULE_LICENSE("GPL");
276MODULE_ALIAS("platform:pcf50633-adc");
277
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
new file mode 100644
index 000000000000..24508e28e3fb
--- /dev/null
+++ b/drivers/mfd/pcf50633-core.c
@@ -0,0 +1,710 @@
1/* NXP PCF50633 Power Management Unit (PMU) driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Harald Welte <laforge@openmoko.org>
5 * Balaji Rao <balajirrao@openmoko.org>
6 * All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/device.h>
17#include <linux/sysfs.h>
18#include <linux/device.h>
19#include <linux/module.h>
20#include <linux/types.h>
21#include <linux/interrupt.h>
22#include <linux/workqueue.h>
23#include <linux/platform_device.h>
24#include <linux/i2c.h>
25#include <linux/irq.h>
26
27#include <linux/mfd/pcf50633/core.h>
28
29/* Two MBCS registers used during cold start */
30#define PCF50633_REG_MBCS1 0x4b
31#define PCF50633_REG_MBCS2 0x4c
32#define PCF50633_MBCS1_USBPRES 0x01
33#define PCF50633_MBCS1_ADAPTPRES 0x01
34
35static int __pcf50633_read(struct pcf50633 *pcf, u8 reg, int num, u8 *data)
36{
37 int ret;
38
39 ret = i2c_smbus_read_i2c_block_data(pcf->i2c_client, reg,
40 num, data);
41 if (ret < 0)
42 dev_err(pcf->dev, "Error reading %d regs at %d\n", num, reg);
43
44 return ret;
45}
46
47static int __pcf50633_write(struct pcf50633 *pcf, u8 reg, int num, u8 *data)
48{
49 int ret;
50
51 ret = i2c_smbus_write_i2c_block_data(pcf->i2c_client, reg,
52 num, data);
53 if (ret < 0)
54 dev_err(pcf->dev, "Error writing %d regs at %d\n", num, reg);
55
56 return ret;
57
58}
59
60/* Read a block of upto 32 regs */
61int pcf50633_read_block(struct pcf50633 *pcf, u8 reg,
62 int nr_regs, u8 *data)
63{
64 int ret;
65
66 mutex_lock(&pcf->lock);
67 ret = __pcf50633_read(pcf, reg, nr_regs, data);
68 mutex_unlock(&pcf->lock);
69
70 return ret;
71}
72EXPORT_SYMBOL_GPL(pcf50633_read_block);
73
74/* Write a block of upto 32 regs */
75int pcf50633_write_block(struct pcf50633 *pcf , u8 reg,
76 int nr_regs, u8 *data)
77{
78 int ret;
79
80 mutex_lock(&pcf->lock);
81 ret = __pcf50633_write(pcf, reg, nr_regs, data);
82 mutex_unlock(&pcf->lock);
83
84 return ret;
85}
86EXPORT_SYMBOL_GPL(pcf50633_write_block);
87
88u8 pcf50633_reg_read(struct pcf50633 *pcf, u8 reg)
89{
90 u8 val;
91
92 mutex_lock(&pcf->lock);
93 __pcf50633_read(pcf, reg, 1, &val);
94 mutex_unlock(&pcf->lock);
95
96 return val;
97}
98EXPORT_SYMBOL_GPL(pcf50633_reg_read);
99
100int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val)
101{
102 int ret;
103
104 mutex_lock(&pcf->lock);
105 ret = __pcf50633_write(pcf, reg, 1, &val);
106 mutex_unlock(&pcf->lock);
107
108 return ret;
109}
110EXPORT_SYMBOL_GPL(pcf50633_reg_write);
111
112int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val)
113{
114 int ret;
115 u8 tmp;
116
117 val &= mask;
118
119 mutex_lock(&pcf->lock);
120 ret = __pcf50633_read(pcf, reg, 1, &tmp);
121 if (ret < 0)
122 goto out;
123
124 tmp &= ~mask;
125 tmp |= val;
126 ret = __pcf50633_write(pcf, reg, 1, &tmp);
127
128out:
129 mutex_unlock(&pcf->lock);
130
131 return ret;
132}
133EXPORT_SYMBOL_GPL(pcf50633_reg_set_bit_mask);
134
135int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 val)
136{
137 int ret;
138 u8 tmp;
139
140 mutex_lock(&pcf->lock);
141 ret = __pcf50633_read(pcf, reg, 1, &tmp);
142 if (ret < 0)
143 goto out;
144
145 tmp &= ~val;
146 ret = __pcf50633_write(pcf, reg, 1, &tmp);
147
148out:
149 mutex_unlock(&pcf->lock);
150
151 return ret;
152}
153EXPORT_SYMBOL_GPL(pcf50633_reg_clear_bits);
154
155/* sysfs attributes */
156static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
157 char *buf)
158{
159 struct pcf50633 *pcf = dev_get_drvdata(dev);
160 u8 dump[16];
161 int n, n1, idx = 0;
162 char *buf1 = buf;
163 static u8 address_no_read[] = { /* must be ascending */
164 PCF50633_REG_INT1,
165 PCF50633_REG_INT2,
166 PCF50633_REG_INT3,
167 PCF50633_REG_INT4,
168 PCF50633_REG_INT5,
169 0 /* terminator */
170 };
171
172 for (n = 0; n < 256; n += sizeof(dump)) {
173 for (n1 = 0; n1 < sizeof(dump); n1++)
174 if (n == address_no_read[idx]) {
175 idx++;
176 dump[n1] = 0x00;
177 } else
178 dump[n1] = pcf50633_reg_read(pcf, n + n1);
179
180 hex_dump_to_buffer(dump, sizeof(dump), 16, 1, buf1, 128, 0);
181 buf1 += strlen(buf1);
182 *buf1++ = '\n';
183 *buf1 = '\0';
184 }
185
186 return buf1 - buf;
187}
188static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL);
189
190static ssize_t show_resume_reason(struct device *dev,
191 struct device_attribute *attr, char *buf)
192{
193 struct pcf50633 *pcf = dev_get_drvdata(dev);
194 int n;
195
196 n = sprintf(buf, "%02x%02x%02x%02x%02x\n",
197 pcf->resume_reason[0],
198 pcf->resume_reason[1],
199 pcf->resume_reason[2],
200 pcf->resume_reason[3],
201 pcf->resume_reason[4]);
202
203 return n;
204}
205static DEVICE_ATTR(resume_reason, 0400, show_resume_reason, NULL);
206
207static struct attribute *pcf_sysfs_entries[] = {
208 &dev_attr_dump_regs.attr,
209 &dev_attr_resume_reason.attr,
210 NULL,
211};
212
213static struct attribute_group pcf_attr_group = {
214 .name = NULL, /* put in device directory */
215 .attrs = pcf_sysfs_entries,
216};
217
218int pcf50633_register_irq(struct pcf50633 *pcf, int irq,
219 void (*handler) (int, void *), void *data)
220{
221 if (irq < 0 || irq > PCF50633_NUM_IRQ || !handler)
222 return -EINVAL;
223
224 if (WARN_ON(pcf->irq_handler[irq].handler))
225 return -EBUSY;
226
227 mutex_lock(&pcf->lock);
228 pcf->irq_handler[irq].handler = handler;
229 pcf->irq_handler[irq].data = data;
230 mutex_unlock(&pcf->lock);
231
232 return 0;
233}
234EXPORT_SYMBOL_GPL(pcf50633_register_irq);
235
236int pcf50633_free_irq(struct pcf50633 *pcf, int irq)
237{
238 if (irq < 0 || irq > PCF50633_NUM_IRQ)
239 return -EINVAL;
240
241 mutex_lock(&pcf->lock);
242 pcf->irq_handler[irq].handler = NULL;
243 mutex_unlock(&pcf->lock);
244
245 return 0;
246}
247EXPORT_SYMBOL_GPL(pcf50633_free_irq);
248
249static int __pcf50633_irq_mask_set(struct pcf50633 *pcf, int irq, u8 mask)
250{
251 u8 reg, bits, tmp;
252 int ret = 0, idx;
253
254 idx = irq >> 3;
255 reg = PCF50633_REG_INT1M + idx;
256 bits = 1 << (irq & 0x07);
257
258 mutex_lock(&pcf->lock);
259
260 if (mask) {
261 ret = __pcf50633_read(pcf, reg, 1, &tmp);
262 if (ret < 0)
263 goto out;
264
265 tmp |= bits;
266
267 ret = __pcf50633_write(pcf, reg, 1, &tmp);
268 if (ret < 0)
269 goto out;
270
271 pcf->mask_regs[idx] &= ~bits;
272 pcf->mask_regs[idx] |= bits;
273 } else {
274 ret = __pcf50633_read(pcf, reg, 1, &tmp);
275 if (ret < 0)
276 goto out;
277
278 tmp &= ~bits;
279
280 ret = __pcf50633_write(pcf, reg, 1, &tmp);
281 if (ret < 0)
282 goto out;
283
284 pcf->mask_regs[idx] &= ~bits;
285 }
286out:
287 mutex_unlock(&pcf->lock);
288
289 return ret;
290}
291
292int pcf50633_irq_mask(struct pcf50633 *pcf, int irq)
293{
294 dev_info(pcf->dev, "Masking IRQ %d\n", irq);
295
296 return __pcf50633_irq_mask_set(pcf, irq, 1);
297}
298EXPORT_SYMBOL_GPL(pcf50633_irq_mask);
299
300int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq)
301{
302 dev_info(pcf->dev, "Unmasking IRQ %d\n", irq);
303
304 return __pcf50633_irq_mask_set(pcf, irq, 0);
305}
306EXPORT_SYMBOL_GPL(pcf50633_irq_unmask);
307
308int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq)
309{
310 u8 reg, bits;
311
312 reg = irq >> 3;
313 bits = 1 << (irq & 0x07);
314
315 return pcf->mask_regs[reg] & bits;
316}
317EXPORT_SYMBOL_GPL(pcf50633_irq_mask_get);
318
319static void pcf50633_irq_call_handler(struct pcf50633 *pcf, int irq)
320{
321 if (pcf->irq_handler[irq].handler)
322 pcf->irq_handler[irq].handler(irq, pcf->irq_handler[irq].data);
323}
324
325/* Maximum amount of time ONKEY is held before emergency action is taken */
326#define PCF50633_ONKEY1S_TIMEOUT 8
327
328static void pcf50633_irq_worker(struct work_struct *work)
329{
330 struct pcf50633 *pcf;
331 int ret, i, j;
332 u8 pcf_int[5], chgstat;
333
334 pcf = container_of(work, struct pcf50633, irq_work);
335
336 /* Read the 5 INT regs in one transaction */
337 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1,
338 ARRAY_SIZE(pcf_int), pcf_int);
339 if (ret != ARRAY_SIZE(pcf_int)) {
340 dev_err(pcf->dev, "Error reading INT registers\n");
341
342 /*
343 * If this doesn't ACK the interrupt to the chip, we'll be
344 * called once again as we're level triggered.
345 */
346 goto out;
347 }
348
349 /* We immediately read the usb and adapter status. We thus make sure
350 * only of USBINS/USBREM IRQ handlers are called */
351 if (pcf_int[0] & (PCF50633_INT1_USBINS | PCF50633_INT1_USBREM)) {
352 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
353 if (chgstat & (0x3 << 4))
354 pcf_int[0] &= ~(1 << PCF50633_INT1_USBREM);
355 else
356 pcf_int[0] &= ~(1 << PCF50633_INT1_USBINS);
357 }
358
359 /* Make sure only one of ADPINS or ADPREM is set */
360 if (pcf_int[0] & (PCF50633_INT1_ADPINS | PCF50633_INT1_ADPREM)) {
361 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
362 if (chgstat & (0x3 << 4))
363 pcf_int[0] &= ~(1 << PCF50633_INT1_ADPREM);
364 else
365 pcf_int[0] &= ~(1 << PCF50633_INT1_ADPINS);
366 }
367
368 dev_dbg(pcf->dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x "
369 "INT4=0x%02x INT5=0x%02x\n", pcf_int[0],
370 pcf_int[1], pcf_int[2], pcf_int[3], pcf_int[4]);
371
372 /* Some revisions of the chip don't have a 8s standby mode on
373 * ONKEY1S press. We try to manually do it in such cases. */
374 if ((pcf_int[0] & PCF50633_INT1_SECOND) && pcf->onkey1s_held) {
375 dev_info(pcf->dev, "ONKEY1S held for %d secs\n",
376 pcf->onkey1s_held);
377 if (pcf->onkey1s_held++ == PCF50633_ONKEY1S_TIMEOUT)
378 if (pcf->pdata->force_shutdown)
379 pcf->pdata->force_shutdown(pcf);
380 }
381
382 if (pcf_int[2] & PCF50633_INT3_ONKEY1S) {
383 dev_info(pcf->dev, "ONKEY1S held\n");
384 pcf->onkey1s_held = 1 ;
385
386 /* Unmask IRQ_SECOND */
387 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT1M,
388 PCF50633_INT1_SECOND);
389
390 /* Unmask IRQ_ONKEYR */
391 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT2M,
392 PCF50633_INT2_ONKEYR);
393 }
394
395 if ((pcf_int[1] & PCF50633_INT2_ONKEYR) && pcf->onkey1s_held) {
396 pcf->onkey1s_held = 0;
397
398 /* Mask SECOND and ONKEYR interrupts */
399 if (pcf->mask_regs[0] & PCF50633_INT1_SECOND)
400 pcf50633_reg_set_bit_mask(pcf,
401 PCF50633_REG_INT1M,
402 PCF50633_INT1_SECOND,
403 PCF50633_INT1_SECOND);
404
405 if (pcf->mask_regs[1] & PCF50633_INT2_ONKEYR)
406 pcf50633_reg_set_bit_mask(pcf,
407 PCF50633_REG_INT2M,
408 PCF50633_INT2_ONKEYR,
409 PCF50633_INT2_ONKEYR);
410 }
411
412 /* Have we just resumed ? */
413 if (pcf->is_suspended) {
414 pcf->is_suspended = 0;
415
416 /* Set the resume reason filtering out non resumers */
417 for (i = 0; i < ARRAY_SIZE(pcf_int); i++)
418 pcf->resume_reason[i] = pcf_int[i] &
419 pcf->pdata->resumers[i];
420
421 /* Make sure we don't pass on any ONKEY events to
422 * userspace now */
423 pcf_int[1] &= ~(PCF50633_INT2_ONKEYR | PCF50633_INT2_ONKEYF);
424 }
425
426 for (i = 0; i < ARRAY_SIZE(pcf_int); i++) {
427 /* Unset masked interrupts */
428 pcf_int[i] &= ~pcf->mask_regs[i];
429
430 for (j = 0; j < 8 ; j++)
431 if (pcf_int[i] & (1 << j))
432 pcf50633_irq_call_handler(pcf, (i * 8) + j);
433 }
434
435out:
436 put_device(pcf->dev);
437 enable_irq(pcf->irq);
438}
439
440static irqreturn_t pcf50633_irq(int irq, void *data)
441{
442 struct pcf50633 *pcf = data;
443
444 dev_dbg(pcf->dev, "pcf50633_irq\n");
445
446 get_device(pcf->dev);
447 disable_irq(pcf->irq);
448 schedule_work(&pcf->irq_work);
449
450 return IRQ_HANDLED;
451}
452
453static void
454pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
455 struct platform_device **pdev)
456{
457 struct pcf50633_subdev_pdata *subdev_pdata;
458 int ret;
459
460 *pdev = platform_device_alloc(name, -1);
461 if (!*pdev) {
462 dev_err(pcf->dev, "Falied to allocate %s\n", name);
463 return;
464 }
465
466 subdev_pdata = kmalloc(sizeof(*subdev_pdata), GFP_KERNEL);
467 if (!subdev_pdata) {
468 dev_err(pcf->dev, "Error allocating subdev pdata\n");
469 platform_device_put(*pdev);
470 }
471
472 subdev_pdata->pcf = pcf;
473 platform_device_add_data(*pdev, subdev_pdata, sizeof(*subdev_pdata));
474
475 (*pdev)->dev.parent = pcf->dev;
476
477 ret = platform_device_add(*pdev);
478 if (ret) {
479 dev_err(pcf->dev, "Failed to register %s: %d\n", name, ret);
480 platform_device_put(*pdev);
481 *pdev = NULL;
482 }
483}
484
485#ifdef CONFIG_PM
486static int pcf50633_suspend(struct device *dev, pm_message_t state)
487{
488 struct pcf50633 *pcf;
489 int ret = 0, i;
490 u8 res[5];
491
492 pcf = dev_get_drvdata(dev);
493
494 /* Make sure our interrupt handlers are not called
495 * henceforth */
496 disable_irq(pcf->irq);
497
498 /* Make sure that any running IRQ worker has quit */
499 cancel_work_sync(&pcf->irq_work);
500
501 /* Save the masks */
502 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M,
503 ARRAY_SIZE(pcf->suspend_irq_masks),
504 pcf->suspend_irq_masks);
505 if (ret < 0) {
506 dev_err(pcf->dev, "error saving irq masks\n");
507 goto out;
508 }
509
510 /* Write wakeup irq masks */
511 for (i = 0; i < ARRAY_SIZE(res); i++)
512 res[i] = ~pcf->pdata->resumers[i];
513
514 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
515 ARRAY_SIZE(res), &res[0]);
516 if (ret < 0) {
517 dev_err(pcf->dev, "error writing wakeup irq masks\n");
518 goto out;
519 }
520
521 pcf->is_suspended = 1;
522
523out:
524 return ret;
525}
526
527static int pcf50633_resume(struct device *dev)
528{
529 struct pcf50633 *pcf;
530 int ret;
531
532 pcf = dev_get_drvdata(dev);
533
534 /* Write the saved mask registers */
535 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
536 ARRAY_SIZE(pcf->suspend_irq_masks),
537 pcf->suspend_irq_masks);
538 if (ret < 0)
539 dev_err(pcf->dev, "Error restoring saved suspend masks\n");
540
541 /* Restore regulators' state */
542
543
544 get_device(pcf->dev);
545
546 /*
547 * Clear any pending interrupts and set resume reason if any.
548 * This will leave with enable_irq()
549 */
550 pcf50633_irq_worker(&pcf->irq_work);
551
552 return 0;
553}
554#else
555#define pcf50633_suspend NULL
556#define pcf50633_resume NULL
557#endif
558
559static int __devinit pcf50633_probe(struct i2c_client *client,
560 const struct i2c_device_id *ids)
561{
562 struct pcf50633 *pcf;
563 struct pcf50633_platform_data *pdata = client->dev.platform_data;
564 int i, ret = 0;
565 int version, variant;
566
567 pcf = kzalloc(sizeof(*pcf), GFP_KERNEL);
568 if (!pcf)
569 return -ENOMEM;
570
571 pcf->pdata = pdata;
572
573 mutex_init(&pcf->lock);
574
575 i2c_set_clientdata(client, pcf);
576 pcf->dev = &client->dev;
577 pcf->i2c_client = client;
578 pcf->irq = client->irq;
579
580 INIT_WORK(&pcf->irq_work, pcf50633_irq_worker);
581
582 version = pcf50633_reg_read(pcf, 0);
583 variant = pcf50633_reg_read(pcf, 1);
584 if (version < 0 || variant < 0) {
585 dev_err(pcf->dev, "Unable to probe pcf50633\n");
586 ret = -ENODEV;
587 goto err;
588 }
589
590 dev_info(pcf->dev, "Probed device version %d variant %d\n",
591 version, variant);
592
593 /* Enable all interrupts except RTC SECOND */
594 pcf->mask_regs[0] = 0x80;
595 pcf50633_reg_write(pcf, PCF50633_REG_INT1M, pcf->mask_regs[0]);
596 pcf50633_reg_write(pcf, PCF50633_REG_INT2M, 0x00);
597 pcf50633_reg_write(pcf, PCF50633_REG_INT3M, 0x00);
598 pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00);
599 pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00);
600
601 /* Create sub devices */
602 pcf50633_client_dev_register(pcf, "pcf50633-input",
603 &pcf->input_pdev);
604 pcf50633_client_dev_register(pcf, "pcf50633-rtc",
605 &pcf->rtc_pdev);
606 pcf50633_client_dev_register(pcf, "pcf50633-mbc",
607 &pcf->mbc_pdev);
608 pcf50633_client_dev_register(pcf, "pcf50633-adc",
609 &pcf->adc_pdev);
610
611 for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
612 struct platform_device *pdev;
613
614 pdev = platform_device_alloc("pcf50633-regltr", i);
615 if (!pdev) {
616 dev_err(pcf->dev, "Cannot create regulator\n");
617 continue;
618 }
619
620 pdev->dev.parent = pcf->dev;
621 pdev->dev.platform_data = &pdata->reg_init_data[i];
622 pdev->dev.driver_data = pcf;
623 pcf->regulator_pdev[i] = pdev;
624
625 platform_device_add(pdev);
626 }
627
628 if (client->irq) {
629 set_irq_handler(client->irq, handle_level_irq);
630 ret = request_irq(client->irq, pcf50633_irq,
631 IRQF_TRIGGER_LOW, "pcf50633", pcf);
632
633 if (ret) {
634 dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
635 goto err;
636 }
637 } else {
638 dev_err(pcf->dev, "No IRQ configured\n");
639 goto err;
640 }
641
642 if (enable_irq_wake(client->irq) < 0)
643 dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source"
644 "in this hardware revision", client->irq);
645
646 ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group);
647 if (ret)
648 dev_err(pcf->dev, "error creating sysfs entries\n");
649
650 if (pdata->probe_done)
651 pdata->probe_done(pcf);
652
653 return 0;
654
655err:
656 kfree(pcf);
657 return ret;
658}
659
660static int __devexit pcf50633_remove(struct i2c_client *client)
661{
662 struct pcf50633 *pcf = i2c_get_clientdata(client);
663 int i;
664
665 free_irq(pcf->irq, pcf);
666
667 platform_device_unregister(pcf->input_pdev);
668 platform_device_unregister(pcf->rtc_pdev);
669 platform_device_unregister(pcf->mbc_pdev);
670 platform_device_unregister(pcf->adc_pdev);
671
672 for (i = 0; i < PCF50633_NUM_REGULATORS; i++)
673 platform_device_unregister(pcf->regulator_pdev[i]);
674
675 kfree(pcf);
676
677 return 0;
678}
679
680static struct i2c_device_id pcf50633_id_table[] = {
681 {"pcf50633", 0x73},
682};
683
684static struct i2c_driver pcf50633_driver = {
685 .driver = {
686 .name = "pcf50633",
687 .suspend = pcf50633_suspend,
688 .resume = pcf50633_resume,
689 },
690 .id_table = pcf50633_id_table,
691 .probe = pcf50633_probe,
692 .remove = __devexit_p(pcf50633_remove),
693};
694
695static int __init pcf50633_init(void)
696{
697 return i2c_add_driver(&pcf50633_driver);
698}
699
700static void __exit pcf50633_exit(void)
701{
702 i2c_del_driver(&pcf50633_driver);
703}
704
705MODULE_DESCRIPTION("I2C chip driver for NXP PCF50633 PMU");
706MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>");
707MODULE_LICENSE("GPL");
708
709module_init(pcf50633_init);
710module_exit(pcf50633_exit);
diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c
new file mode 100644
index 000000000000..2fa2eca5c9cc
--- /dev/null
+++ b/drivers/mfd/pcf50633-gpio.c
@@ -0,0 +1,118 @@
1/* NXP PCF50633 GPIO Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18
19#include <linux/mfd/pcf50633/core.h>
20#include <linux/mfd/pcf50633/gpio.h>
21
22enum pcf50633_regulator_id {
23 PCF50633_REGULATOR_AUTO,
24 PCF50633_REGULATOR_DOWN1,
25 PCF50633_REGULATOR_DOWN2,
26 PCF50633_REGULATOR_LDO1,
27 PCF50633_REGULATOR_LDO2,
28 PCF50633_REGULATOR_LDO3,
29 PCF50633_REGULATOR_LDO4,
30 PCF50633_REGULATOR_LDO5,
31 PCF50633_REGULATOR_LDO6,
32 PCF50633_REGULATOR_HCLDO,
33 PCF50633_REGULATOR_MEMLDO,
34};
35
36#define PCF50633_REG_AUTOOUT 0x1a
37#define PCF50633_REG_DOWN1OUT 0x1e
38#define PCF50633_REG_DOWN2OUT 0x22
39#define PCF50633_REG_MEMLDOOUT 0x26
40#define PCF50633_REG_LDO1OUT 0x2d
41#define PCF50633_REG_LDO2OUT 0x2f
42#define PCF50633_REG_LDO3OUT 0x31
43#define PCF50633_REG_LDO4OUT 0x33
44#define PCF50633_REG_LDO5OUT 0x35
45#define PCF50633_REG_LDO6OUT 0x37
46#define PCF50633_REG_HCLDOOUT 0x39
47
48static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
49 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
50 [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,
51 [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,
52 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,
53 [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,
54 [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,
55 [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,
56 [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,
57 [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,
58 [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,
59 [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,
60};
61
62int pcf50633_gpio_set(struct pcf50633 *pcf, int gpio, u8 val)
63{
64 u8 reg;
65
66 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
67
68 return pcf50633_reg_set_bit_mask(pcf, reg, 0x07, val);
69}
70EXPORT_SYMBOL_GPL(pcf50633_gpio_set);
71
72u8 pcf50633_gpio_get(struct pcf50633 *pcf, int gpio)
73{
74 u8 reg, val;
75
76 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
77 val = pcf50633_reg_read(pcf, reg) & 0x07;
78
79 return val;
80}
81EXPORT_SYMBOL_GPL(pcf50633_gpio_get);
82
83int pcf50633_gpio_invert_set(struct pcf50633 *pcf, int gpio, int invert)
84{
85 u8 val, reg;
86
87 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
88 val = !!invert << 3;
89
90 return pcf50633_reg_set_bit_mask(pcf, reg, 1 << 3, val);
91}
92EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_set);
93
94int pcf50633_gpio_invert_get(struct pcf50633 *pcf, int gpio)
95{
96 u8 reg, val;
97
98 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
99 val = pcf50633_reg_read(pcf, reg);
100
101 return val & (1 << 3);
102}
103EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_get);
104
105int pcf50633_gpio_power_supply_set(struct pcf50633 *pcf,
106 int gpio, int regulator, int on)
107{
108 u8 reg, val, mask;
109
110 /* the *ENA register is always one after the *OUT register */
111 reg = pcf50633_regulator_registers[regulator] + 1;
112
113 val = !!on << (gpio - PCF50633_GPIO1);
114 mask = 1 << (gpio - PCF50633_GPIO1);
115
116 return pcf50633_reg_set_bit_mask(pcf, reg, mask, val);
117}
118EXPORT_SYMBOL_GPL(pcf50633_gpio_power_supply_set);
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 170f9d47c2f9..0e5761f12634 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -41,6 +41,7 @@ struct sm501_gpio_chip {
41 struct gpio_chip gpio; 41 struct gpio_chip gpio;
42 struct sm501_gpio *ourgpio; /* to get back to parent. */ 42 struct sm501_gpio *ourgpio; /* to get back to parent. */
43 void __iomem *regbase; 43 void __iomem *regbase;
44 void __iomem *control; /* address of control reg. */
44}; 45};
45 46
46struct sm501_gpio { 47struct sm501_gpio {
@@ -908,6 +909,25 @@ static int sm501_gpio_get(struct gpio_chip *chip, unsigned offset)
908 return result & 1UL; 909 return result & 1UL;
909} 910}
910 911
912static void sm501_gpio_ensure_gpio(struct sm501_gpio_chip *smchip,
913 unsigned long bit)
914{
915 unsigned long ctrl;
916
917 /* check and modify if this pin is not set as gpio. */
918
919 if (readl(smchip->control) & bit) {
920 dev_info(sm501_gpio_to_dev(smchip->ourgpio)->dev,
921 "changing mode of gpio, bit %08lx\n", bit);
922
923 ctrl = readl(smchip->control);
924 ctrl &= ~bit;
925 writel(ctrl, smchip->control);
926
927 sm501_sync_regs(sm501_gpio_to_dev(smchip->ourgpio));
928 }
929}
930
911static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 931static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
912 932
913{ 933{
@@ -929,6 +949,8 @@ static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
929 writel(val, regs); 949 writel(val, regs);
930 950
931 sm501_sync_regs(sm501_gpio_to_dev(smgpio)); 951 sm501_sync_regs(sm501_gpio_to_dev(smgpio));
952 sm501_gpio_ensure_gpio(smchip, bit);
953
932 spin_unlock_irqrestore(&smgpio->lock, save); 954 spin_unlock_irqrestore(&smgpio->lock, save);
933} 955}
934 956
@@ -941,8 +963,8 @@ static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset)
941 unsigned long save; 963 unsigned long save;
942 unsigned long ddr; 964 unsigned long ddr;
943 965
944 dev_info(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n", 966 dev_dbg(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n",
945 __func__, chip, offset); 967 __func__, chip, offset);
946 968
947 spin_lock_irqsave(&smgpio->lock, save); 969 spin_lock_irqsave(&smgpio->lock, save);
948 970
@@ -950,6 +972,8 @@ static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset)
950 writel(ddr & ~bit, regs + SM501_GPIO_DDR_LOW); 972 writel(ddr & ~bit, regs + SM501_GPIO_DDR_LOW);
951 973
952 sm501_sync_regs(sm501_gpio_to_dev(smgpio)); 974 sm501_sync_regs(sm501_gpio_to_dev(smgpio));
975 sm501_gpio_ensure_gpio(smchip, bit);
976
953 spin_unlock_irqrestore(&smgpio->lock, save); 977 spin_unlock_irqrestore(&smgpio->lock, save);
954 978
955 return 0; 979 return 0;
@@ -1012,9 +1036,11 @@ static int __devinit sm501_gpio_register_chip(struct sm501_devdata *sm,
1012 if (base > 0) 1036 if (base > 0)
1013 base += 32; 1037 base += 32;
1014 chip->regbase = gpio->regs + SM501_GPIO_DATA_HIGH; 1038 chip->regbase = gpio->regs + SM501_GPIO_DATA_HIGH;
1039 chip->control = sm->regs + SM501_GPIO63_32_CONTROL;
1015 gchip->label = "SM501-HIGH"; 1040 gchip->label = "SM501-HIGH";
1016 } else { 1041 } else {
1017 chip->regbase = gpio->regs + SM501_GPIO_DATA_LOW; 1042 chip->regbase = gpio->regs + SM501_GPIO_DATA_LOW;
1043 chip->control = sm->regs + SM501_GPIO31_0_CONTROL;
1018 gchip->label = "SM501-LOW"; 1044 gchip->label = "SM501-LOW";
1019 } 1045 }
1020 1046
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index b59c385cbc12..e7ab0035d305 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -38,6 +38,9 @@
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c/twl4030.h> 39#include <linux/i2c/twl4030.h>
40 40
41#ifdef CONFIG_ARM
42#include <mach/cpu.h>
43#endif
41 44
42/* 45/*
43 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power 46 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power
@@ -646,7 +649,7 @@ static inline int __init unprotect_pm_master(void)
646 return e; 649 return e;
647} 650}
648 651
649static void __init clocks_init(void) 652static void __init clocks_init(struct device *dev)
650{ 653{
651 int e = 0; 654 int e = 0;
652 struct clk *osc; 655 struct clk *osc;
@@ -655,9 +658,9 @@ static void __init clocks_init(void)
655 658
656#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 659#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
657 if (cpu_is_omap2430()) 660 if (cpu_is_omap2430())
658 osc = clk_get(NULL, "osc_ck"); 661 osc = clk_get(dev, "osc_ck");
659 else 662 else
660 osc = clk_get(NULL, "osc_sys_ck"); 663 osc = clk_get(dev, "osc_sys_ck");
661 664
662 if (IS_ERR(osc)) { 665 if (IS_ERR(osc)) {
663 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 666 printk(KERN_WARNING "Skipping twl4030 internal clock init and "
@@ -773,7 +776,7 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
773 inuse = true; 776 inuse = true;
774 777
775 /* setup clock framework */ 778 /* setup clock framework */
776 clocks_init(); 779 clocks_init(&client->dev);
777 780
778 /* Maybe init the T2 Interrupt subsystem */ 781 /* Maybe init the T2 Interrupt subsystem */
779 if (client->irq 782 if (client->irq
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 9cf8ae6e4b39..d5749a7bc777 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -10,7 +10,6 @@ obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
10obj-$(CONFIG_ICS932S401) += ics932s401.o 10obj-$(CONFIG_ICS932S401) += ics932s401.o
11obj-$(CONFIG_LKDTM) += lkdtm.o 11obj-$(CONFIG_LKDTM) += lkdtm.o
12obj-$(CONFIG_TIFM_CORE) += tifm_core.o 12obj-$(CONFIG_TIFM_CORE) += tifm_core.o
13obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
14obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o 13obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
15obj-$(CONFIG_PHANTOM) += phantom.o 14obj-$(CONFIG_PHANTOM) += phantom.o
16obj-$(CONFIG_SGI_IOC4) += ioc4.o 15obj-$(CONFIG_SGI_IOC4) += ioc4.o
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index 73b7fb8de47a..82fb9958f22f 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -899,7 +899,7 @@ xpc_update_partition_info_sn2(struct xpc_partition *part, u8 remote_rp_version,
899 dev_dbg(xpc_part, " remote_vars_pa = 0x%016lx\n", 899 dev_dbg(xpc_part, " remote_vars_pa = 0x%016lx\n",
900 part_sn2->remote_vars_pa); 900 part_sn2->remote_vars_pa);
901 901
902 part->last_heartbeat = remote_vars->heartbeat; 902 part->last_heartbeat = remote_vars->heartbeat - 1;
903 dev_dbg(xpc_part, " last_heartbeat = 0x%016lx\n", 903 dev_dbg(xpc_part, " last_heartbeat = 0x%016lx\n",
904 part->last_heartbeat); 904 part->last_heartbeat);
905 905
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index c092c3929224..5b91a85fe107 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -177,6 +177,7 @@ static const struct net_device_ops el2_netdev_ops = {
177 .ndo_get_stats = eip_get_stats, 177 .ndo_get_stats = eip_get_stats,
178 .ndo_set_multicast_list = eip_set_multicast_list, 178 .ndo_set_multicast_list = eip_set_multicast_list,
179 .ndo_validate_addr = eth_validate_addr, 179 .ndo_validate_addr = eth_validate_addr,
180 .ndo_set_mac_address = eth_mac_addr,
180 .ndo_change_mtu = eth_change_mtu, 181 .ndo_change_mtu = eth_change_mtu,
181#ifdef CONFIG_NET_POLL_CONTROLLER 182#ifdef CONFIG_NET_POLL_CONTROLLER
182 .ndo_poll_controller = eip_poll, 183 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 665e7fdf27a1..cdbbb6226fc5 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -3109,6 +3109,8 @@ static void acpi_set_WOL(struct net_device *dev)
3109 struct vortex_private *vp = netdev_priv(dev); 3109 struct vortex_private *vp = netdev_priv(dev);
3110 void __iomem *ioaddr = vp->ioaddr; 3110 void __iomem *ioaddr = vp->ioaddr;
3111 3111
3112 device_set_wakeup_enable(vp->gendev, vp->enable_wol);
3113
3112 if (vp->enable_wol) { 3114 if (vp->enable_wol) {
3113 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */ 3115 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */
3114 EL3WINDOW(7); 3116 EL3WINDOW(7);
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index dd7ac8290aec..4e19ae3ce6be 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1821,6 +1821,7 @@ static const struct net_device_ops cp_netdev_ops = {
1821 .ndo_open = cp_open, 1821 .ndo_open = cp_open,
1822 .ndo_stop = cp_close, 1822 .ndo_stop = cp_close,
1823 .ndo_validate_addr = eth_validate_addr, 1823 .ndo_validate_addr = eth_validate_addr,
1824 .ndo_set_mac_address = eth_mac_addr,
1824 .ndo_set_multicast_list = cp_set_rx_mode, 1825 .ndo_set_multicast_list = cp_set_rx_mode,
1825 .ndo_get_stats = cp_get_stats, 1826 .ndo_get_stats = cp_get_stats,
1826 .ndo_do_ioctl = cp_ioctl, 1827 .ndo_do_ioctl = cp_ioctl,
@@ -1832,6 +1833,7 @@ static const struct net_device_ops cp_netdev_ops = {
1832#ifdef BROKEN 1833#ifdef BROKEN
1833 .ndo_change_mtu = cp_change_mtu, 1834 .ndo_change_mtu = cp_change_mtu,
1834#endif 1835#endif
1836
1835#ifdef CONFIG_NET_POLL_CONTROLLER 1837#ifdef CONFIG_NET_POLL_CONTROLLER
1836 .ndo_poll_controller = cp_poll_controller, 1838 .ndo_poll_controller = cp_poll_controller,
1837#endif 1839#endif
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index fe370f805793..a5b24202d564 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -917,6 +917,7 @@ static const struct net_device_ops rtl8139_netdev_ops = {
917 .ndo_stop = rtl8139_close, 917 .ndo_stop = rtl8139_close,
918 .ndo_get_stats = rtl8139_get_stats, 918 .ndo_get_stats = rtl8139_get_stats,
919 .ndo_validate_addr = eth_validate_addr, 919 .ndo_validate_addr = eth_validate_addr,
920 .ndo_set_mac_address = eth_mac_addr,
920 .ndo_start_xmit = rtl8139_start_xmit, 921 .ndo_start_xmit = rtl8139_start_xmit,
921 .ndo_set_multicast_list = rtl8139_set_rx_mode, 922 .ndo_set_multicast_list = rtl8139_set_rx_mode,
922 .ndo_do_ioctl = netdev_ioctl, 923 .ndo_do_ioctl = netdev_ioctl,
@@ -924,7 +925,6 @@ static const struct net_device_ops rtl8139_netdev_ops = {
924#ifdef CONFIG_NET_POLL_CONTROLLER 925#ifdef CONFIG_NET_POLL_CONTROLLER
925 .ndo_poll_controller = rtl8139_poll_controller, 926 .ndo_poll_controller = rtl8139_poll_controller,
926#endif 927#endif
927
928}; 928};
929 929
930static int __devinit rtl8139_init_one (struct pci_dev *pdev, 930static int __devinit rtl8139_init_one (struct pci_dev *pdev,
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index fbe609a51e02..ec3e22e6306f 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -63,6 +63,7 @@ const struct net_device_ops ei_netdev_ops = {
63 .ndo_get_stats = ei_get_stats, 63 .ndo_get_stats = ei_get_stats,
64 .ndo_set_multicast_list = ei_set_multicast_list, 64 .ndo_set_multicast_list = ei_set_multicast_list,
65 .ndo_validate_addr = eth_validate_addr, 65 .ndo_validate_addr = eth_validate_addr,
66 .ndo_set_mac_address = eth_mac_addr,
66 .ndo_change_mtu = eth_change_mtu, 67 .ndo_change_mtu = eth_change_mtu,
67#ifdef CONFIG_NET_POLL_CONTROLLER 68#ifdef CONFIG_NET_POLL_CONTROLLER
68 .ndo_poll_controller = ei_poll, 69 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/8390p.c b/drivers/net/8390p.c
index ee70b358a816..da863c91d1d0 100644
--- a/drivers/net/8390p.c
+++ b/drivers/net/8390p.c
@@ -68,6 +68,7 @@ const struct net_device_ops eip_netdev_ops = {
68 .ndo_get_stats = eip_get_stats, 68 .ndo_get_stats = eip_get_stats,
69 .ndo_set_multicast_list = eip_set_multicast_list, 69 .ndo_set_multicast_list = eip_set_multicast_list,
70 .ndo_validate_addr = eth_validate_addr, 70 .ndo_validate_addr = eth_validate_addr,
71 .ndo_set_mac_address = eth_mac_addr,
71 .ndo_change_mtu = eth_change_mtu, 72 .ndo_change_mtu = eth_change_mtu,
72#ifdef CONFIG_NET_POLL_CONTROLLER 73#ifdef CONFIG_NET_POLL_CONTROLLER
73 .ndo_poll_controller = eip_poll, 74 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 65afda4a62d9..9fe8cb7d43ac 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1600,7 +1600,7 @@ config 8139_OLD_RX_RESET
1600 old RX-reset behavior. If unsure, say N. 1600 old RX-reset behavior. If unsure, say N.
1601 1601
1602config R6040 1602config R6040
1603 tristate "RDC R6040 Fast Ethernet Adapter support (EXPERIMENTAL)" 1603 tristate "RDC R6040 Fast Ethernet Adapter support"
1604 depends on NET_PCI && PCI 1604 depends on NET_PCI && PCI
1605 select CRC32 1605 select CRC32
1606 select MII 1606 select MII
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 5b396ff6c83f..9589d620639d 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -460,6 +460,7 @@ static const struct net_device_ops ace_netdev_ops = {
460 .ndo_get_stats = ace_get_stats, 460 .ndo_get_stats = ace_get_stats,
461 .ndo_start_xmit = ace_start_xmit, 461 .ndo_start_xmit = ace_start_xmit,
462 .ndo_set_multicast_list = ace_set_multicast_list, 462 .ndo_set_multicast_list = ace_set_multicast_list,
463 .ndo_validate_addr = eth_validate_addr,
463 .ndo_set_mac_address = ace_set_mac_addr, 464 .ndo_set_mac_address = ace_set_mac_addr,
464 .ndo_change_mtu = ace_change_mtu, 465 .ndo_change_mtu = ace_change_mtu,
465#if ACENIC_DO_VLAN 466#if ACENIC_DO_VLAN
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 6278606d1049..d15d8b79d8e5 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -646,6 +646,7 @@ static const struct net_device_ops etherh_netdev_ops = {
646 .ndo_get_stats = ei_get_stats, 646 .ndo_get_stats = ei_get_stats,
647 .ndo_set_multicast_list = ei_set_multicast_list, 647 .ndo_set_multicast_list = ei_set_multicast_list,
648 .ndo_validate_addr = eth_validate_addr, 648 .ndo_validate_addr = eth_validate_addr,
649 .ndo_set_mac_address = eth_set_mac_addr,
649 .ndo_change_mtu = eth_change_mtu, 650 .ndo_change_mtu = eth_change_mtu,
650#ifdef CONFIG_NET_POLL_CONTROLLER 651#ifdef CONFIG_NET_POLL_CONTROLLER
651 .ndo_poll_controller = ei_poll, 652 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index 9ad22d1b00fd..1cf2f949c0b4 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -1357,6 +1357,7 @@ static const struct net_device_ops ks8695_netdev_ops = {
1357 .ndo_start_xmit = ks8695_start_xmit, 1357 .ndo_start_xmit = ks8695_start_xmit,
1358 .ndo_tx_timeout = ks8695_timeout, 1358 .ndo_tx_timeout = ks8695_timeout,
1359 .ndo_set_mac_address = ks8695_set_mac, 1359 .ndo_set_mac_address = ks8695_set_mac,
1360 .ndo_validate_addr = eth_validate_addr,
1360 .ndo_set_multicast_list = ks8695_set_multicast, 1361 .ndo_set_multicast_list = ks8695_set_multicast,
1361}; 1362};
1362 1363
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 337488ec707c..a4eb6c40678c 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -37,7 +37,10 @@ static int phy_debug = 0;
37#define __ei_open ax_ei_open 37#define __ei_open ax_ei_open
38#define __ei_close ax_ei_close 38#define __ei_close ax_ei_close
39#define __ei_poll ax_ei_poll 39#define __ei_poll ax_ei_poll
40#define __ei_start_xmit ax_ei_start_xmit
40#define __ei_tx_timeout ax_ei_tx_timeout 41#define __ei_tx_timeout ax_ei_tx_timeout
42#define __ei_get_stats ax_ei_get_stats
43#define __ei_set_multicast_list ax_ei_set_multicast_list
41#define __ei_interrupt ax_ei_interrupt 44#define __ei_interrupt ax_ei_interrupt
42#define ____alloc_ei_netdev ax__alloc_ei_netdev 45#define ____alloc_ei_netdev ax__alloc_ei_netdev
43#define __NS8390_init ax_NS8390_init 46#define __NS8390_init ax_NS8390_init
@@ -623,6 +626,23 @@ static void ax_eeprom_register_write(struct eeprom_93cx6 *eeprom)
623} 626}
624#endif 627#endif
625 628
629static const struct net_device_ops ax_netdev_ops = {
630 .ndo_open = ax_open,
631 .ndo_stop = ax_close,
632 .ndo_do_ioctl = ax_ioctl,
633
634 .ndo_start_xmit = ax_ei_start_xmit,
635 .ndo_tx_timeout = ax_ei_tx_timeout,
636 .ndo_get_stats = ax_ei_get_stats,
637 .ndo_set_multicast_list = ax_ei_set_multicast_list,
638 .ndo_validate_addr = eth_validate_addr,
639 .ndo_set_mac_address = eth_mac_addr,
640 .ndo_change_mtu = eth_change_mtu,
641#ifdef CONFIG_NET_POLL_CONTROLLER
642 .ndo_poll_controller = ax_ei_poll,
643#endif
644};
645
626/* setup code */ 646/* setup code */
627 647
628static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local) 648static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local)
@@ -738,9 +758,7 @@ static int ax_init_dev(struct net_device *dev, int first_init)
738 ei_status.get_8390_hdr = &ax_get_8390_hdr; 758 ei_status.get_8390_hdr = &ax_get_8390_hdr;
739 ei_status.priv = 0; 759 ei_status.priv = 0;
740 760
741 dev->open = ax_open; 761 dev->netdev_ops = &ax_netdev_ops;
742 dev->stop = ax_close;
743 dev->do_ioctl = ax_ioctl;
744 dev->ethtool_ops = &ax_ethtool_ops; 762 dev->ethtool_ops = &ax_ethtool_ops;
745 763
746 ax->msg_enable = NETIF_MSG_LINK; 764 ax->msg_enable = NETIF_MSG_LINK;
@@ -753,9 +771,6 @@ static int ax_init_dev(struct net_device *dev, int first_init)
753 ax->mii.mdio_write = ax_phy_write; 771 ax->mii.mdio_write = ax_phy_write;
754 ax->mii.dev = dev; 772 ax->mii.dev = dev;
755 773
756#ifdef CONFIG_NET_POLL_CONTROLLER
757 dev->poll_controller = ax_ei_poll;
758#endif
759 ax_NS8390_init(dev, 0); 774 ax_NS8390_init(dev, 0);
760 775
761 if (first_init) 776 if (first_init)
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 6926ebedfdc9..c38512ebcea6 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -73,8 +73,8 @@
73 (BP)->tx_cons - (BP)->tx_prod - TX_RING_GAP(BP)) 73 (BP)->tx_cons - (BP)->tx_prod - TX_RING_GAP(BP))
74#define NEXT_TX(N) (((N) + 1) & (B44_TX_RING_SIZE - 1)) 74#define NEXT_TX(N) (((N) + 1) & (B44_TX_RING_SIZE - 1))
75 75
76#define RX_PKT_OFFSET 30 76#define RX_PKT_OFFSET (RX_HEADER_LEN + 2)
77#define RX_PKT_BUF_SZ (1536 + RX_PKT_OFFSET + 64) 77#define RX_PKT_BUF_SZ (1536 + RX_PKT_OFFSET)
78 78
79/* minimum number of free TX descriptors required to wake up TX process */ 79/* minimum number of free TX descriptors required to wake up TX process */
80#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4) 80#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4)
@@ -679,10 +679,10 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
679 dev_kfree_skb_any(skb); 679 dev_kfree_skb_any(skb);
680 return -ENOMEM; 680 return -ENOMEM;
681 } 681 }
682 bp->force_copybreak = 1;
682 } 683 }
683 684
684 rh = (struct rx_header *) skb->data; 685 rh = (struct rx_header *) skb->data;
685 skb_reserve(skb, RX_PKT_OFFSET);
686 686
687 rh->len = 0; 687 rh->len = 0;
688 rh->flags = 0; 688 rh->flags = 0;
@@ -693,13 +693,13 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
693 if (src_map != NULL) 693 if (src_map != NULL)
694 src_map->skb = NULL; 694 src_map->skb = NULL;
695 695
696 ctrl = (DESC_CTRL_LEN & (RX_PKT_BUF_SZ - RX_PKT_OFFSET)); 696 ctrl = (DESC_CTRL_LEN & RX_PKT_BUF_SZ);
697 if (dest_idx == (B44_RX_RING_SIZE - 1)) 697 if (dest_idx == (B44_RX_RING_SIZE - 1))
698 ctrl |= DESC_CTRL_EOT; 698 ctrl |= DESC_CTRL_EOT;
699 699
700 dp = &bp->rx_ring[dest_idx]; 700 dp = &bp->rx_ring[dest_idx];
701 dp->ctrl = cpu_to_le32(ctrl); 701 dp->ctrl = cpu_to_le32(ctrl);
702 dp->addr = cpu_to_le32((u32) mapping + RX_PKT_OFFSET + bp->dma_offset); 702 dp->addr = cpu_to_le32((u32) mapping + bp->dma_offset);
703 703
704 if (bp->flags & B44_FLAG_RX_RING_HACK) 704 if (bp->flags & B44_FLAG_RX_RING_HACK)
705 b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma, 705 b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma,
@@ -801,7 +801,7 @@ static int b44_rx(struct b44 *bp, int budget)
801 /* Omit CRC. */ 801 /* Omit CRC. */
802 len -= 4; 802 len -= 4;
803 803
804 if (len > RX_COPY_THRESHOLD) { 804 if (!bp->force_copybreak && len > RX_COPY_THRESHOLD) {
805 int skb_size; 805 int skb_size;
806 skb_size = b44_alloc_rx_skb(bp, cons, bp->rx_prod); 806 skb_size = b44_alloc_rx_skb(bp, cons, bp->rx_prod);
807 if (skb_size < 0) 807 if (skb_size < 0)
@@ -809,8 +809,8 @@ static int b44_rx(struct b44 *bp, int budget)
809 ssb_dma_unmap_single(bp->sdev, map, 809 ssb_dma_unmap_single(bp->sdev, map,
810 skb_size, DMA_FROM_DEVICE); 810 skb_size, DMA_FROM_DEVICE);
811 /* Leave out rx_header */ 811 /* Leave out rx_header */
812 skb_put(skb, len + RX_PKT_OFFSET); 812 skb_put(skb, len + RX_PKT_OFFSET);
813 skb_pull(skb, RX_PKT_OFFSET); 813 skb_pull(skb, RX_PKT_OFFSET);
814 } else { 814 } else {
815 struct sk_buff *copy_skb; 815 struct sk_buff *copy_skb;
816 816
@@ -2153,6 +2153,7 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2153 bp = netdev_priv(dev); 2153 bp = netdev_priv(dev);
2154 bp->sdev = sdev; 2154 bp->sdev = sdev;
2155 bp->dev = dev; 2155 bp->dev = dev;
2156 bp->force_copybreak = 0;
2156 2157
2157 bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE); 2158 bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE);
2158 2159
diff --git a/drivers/net/b44.h b/drivers/net/b44.h
index 7db0c84a7950..e678498de6db 100644
--- a/drivers/net/b44.h
+++ b/drivers/net/b44.h
@@ -395,7 +395,7 @@ struct b44 {
395 u32 rx_pending; 395 u32 rx_pending;
396 u32 tx_pending; 396 u32 tx_pending;
397 u8 phy_addr; 397 u8 phy_addr;
398 398 u8 force_copybreak;
399 struct mii_if_info mii_if; 399 struct mii_if_info mii_if;
400}; 400};
401 401
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index fd705d1295a7..6fcccef4cf3d 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -20,6 +20,11 @@
20 * (you will need to reboot afterwards) */ 20 * (you will need to reboot afterwards) */
21/* #define BNX2X_STOP_ON_ERROR */ 21/* #define BNX2X_STOP_ON_ERROR */
22 22
23#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
24#define BCM_VLAN 1
25#endif
26
27
23/* error/debug prints */ 28/* error/debug prints */
24 29
25#define DRV_MODULE_NAME "bnx2x" 30#define DRV_MODULE_NAME "bnx2x"
@@ -78,11 +83,6 @@
78#endif 83#endif
79 84
80 85
81#ifdef NETIF_F_HW_VLAN_TX
82#define BCM_VLAN 1
83#endif
84
85
86#define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff) 86#define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff)
87#define U64_HI(x) (u32)(((u64)(x)) >> 32) 87#define U64_HI(x) (u32)(((u64)(x)) >> 32)
88#define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo)) 88#define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
@@ -150,6 +150,9 @@ struct sw_rx_page {
150 150
151#define PAGES_PER_SGE_SHIFT 0 151#define PAGES_PER_SGE_SHIFT 0
152#define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT) 152#define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT)
153#define SGE_PAGE_SIZE PAGE_SIZE
154#define SGE_PAGE_SHIFT PAGE_SHIFT
155#define SGE_PAGE_ALIGN(addr) PAGE_ALIGN(addr)
153 156
154#define BCM_RX_ETH_PAYLOAD_ALIGN 64 157#define BCM_RX_ETH_PAYLOAD_ALIGN 64
155 158
@@ -736,7 +739,7 @@ struct bnx2x {
736 struct bnx2x_fastpath fp[MAX_CONTEXT]; 739 struct bnx2x_fastpath fp[MAX_CONTEXT];
737 void __iomem *regview; 740 void __iomem *regview;
738 void __iomem *doorbells; 741 void __iomem *doorbells;
739#define BNX2X_DB_SIZE (16*2048) 742#define BNX2X_DB_SIZE (16*BCM_PAGE_SIZE)
740 743
741 struct net_device *dev; 744 struct net_device *dev;
742 struct pci_dev *pdev; 745 struct pci_dev *pdev;
@@ -801,6 +804,8 @@ struct bnx2x {
801#define TPA_ENABLE_FLAG 0x80 804#define TPA_ENABLE_FLAG 0x80
802#define NO_MCP_FLAG 0x100 805#define NO_MCP_FLAG 0x100
803#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) 806#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
807#define HW_VLAN_TX_FLAG 0x400
808#define HW_VLAN_RX_FLAG 0x800
804 809
805 int func; 810 int func;
806#define BP_PORT(bp) (bp->func % PORT_MAX) 811#define BP_PORT(bp) (bp->func % PORT_MAX)
@@ -811,7 +816,7 @@ struct bnx2x {
811 int pm_cap; 816 int pm_cap;
812 int pcie_cap; 817 int pcie_cap;
813 818
814 struct work_struct sp_task; 819 struct delayed_work sp_task;
815 struct work_struct reset_task; 820 struct work_struct reset_task;
816 821
817 struct timer_list timer; 822 struct timer_list timer;
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 4be05847f86f..7c533797c064 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -38,9 +38,7 @@
38#include <linux/time.h> 38#include <linux/time.h>
39#include <linux/ethtool.h> 39#include <linux/ethtool.h>
40#include <linux/mii.h> 40#include <linux/mii.h>
41#ifdef NETIF_F_HW_VLAN_TX 41#include <linux/if_vlan.h>
42 #include <linux/if_vlan.h>
43#endif
44#include <net/ip.h> 42#include <net/ip.h>
45#include <net/tcp.h> 43#include <net/tcp.h>
46#include <net/checksum.h> 44#include <net/checksum.h>
@@ -95,6 +93,7 @@ MODULE_PARM_DESC(debug, "default debug msglevel");
95module_param(use_multi, int, 0); 93module_param(use_multi, int, 0);
96MODULE_PARM_DESC(use_multi, "use per-CPU queues"); 94MODULE_PARM_DESC(use_multi, "use per-CPU queues");
97#endif 95#endif
96static struct workqueue_struct *bnx2x_wq;
98 97
99enum bnx2x_board_type { 98enum bnx2x_board_type {
100 BCM57710 = 0, 99 BCM57710 = 0,
@@ -671,7 +670,8 @@ static void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw)
671 synchronize_irq(bp->pdev->irq); 670 synchronize_irq(bp->pdev->irq);
672 671
673 /* make sure sp_task is not running */ 672 /* make sure sp_task is not running */
674 cancel_work_sync(&bp->sp_task); 673 cancel_delayed_work(&bp->sp_task);
674 flush_workqueue(bnx2x_wq);
675} 675}
676 676
677/* fast path */ 677/* fast path */
@@ -972,7 +972,7 @@ static inline void bnx2x_free_rx_sge(struct bnx2x *bp,
972 return; 972 return;
973 973
974 pci_unmap_page(bp->pdev, pci_unmap_addr(sw_buf, mapping), 974 pci_unmap_page(bp->pdev, pci_unmap_addr(sw_buf, mapping),
975 BCM_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE); 975 SGE_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE);
976 __free_pages(page, PAGES_PER_SGE_SHIFT); 976 __free_pages(page, PAGES_PER_SGE_SHIFT);
977 977
978 sw_buf->page = NULL; 978 sw_buf->page = NULL;
@@ -1000,7 +1000,7 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp,
1000 if (unlikely(page == NULL)) 1000 if (unlikely(page == NULL))
1001 return -ENOMEM; 1001 return -ENOMEM;
1002 1002
1003 mapping = pci_map_page(bp->pdev, page, 0, BCM_PAGE_SIZE*PAGES_PER_SGE, 1003 mapping = pci_map_page(bp->pdev, page, 0, SGE_PAGE_SIZE*PAGES_PER_SGE,
1004 PCI_DMA_FROMDEVICE); 1004 PCI_DMA_FROMDEVICE);
1005 if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { 1005 if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) {
1006 __free_pages(page, PAGES_PER_SGE_SHIFT); 1006 __free_pages(page, PAGES_PER_SGE_SHIFT);
@@ -1096,9 +1096,9 @@ static void bnx2x_update_sge_prod(struct bnx2x_fastpath *fp,
1096 struct eth_fast_path_rx_cqe *fp_cqe) 1096 struct eth_fast_path_rx_cqe *fp_cqe)
1097{ 1097{
1098 struct bnx2x *bp = fp->bp; 1098 struct bnx2x *bp = fp->bp;
1099 u16 sge_len = BCM_PAGE_ALIGN(le16_to_cpu(fp_cqe->pkt_len) - 1099 u16 sge_len = SGE_PAGE_ALIGN(le16_to_cpu(fp_cqe->pkt_len) -
1100 le16_to_cpu(fp_cqe->len_on_bd)) >> 1100 le16_to_cpu(fp_cqe->len_on_bd)) >>
1101 BCM_PAGE_SHIFT; 1101 SGE_PAGE_SHIFT;
1102 u16 last_max, last_elem, first_elem; 1102 u16 last_max, last_elem, first_elem;
1103 u16 delta = 0; 1103 u16 delta = 0;
1104 u16 i; 1104 u16 i;
@@ -1203,22 +1203,22 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1203 u16 cqe_idx) 1203 u16 cqe_idx)
1204{ 1204{
1205 struct sw_rx_page *rx_pg, old_rx_pg; 1205 struct sw_rx_page *rx_pg, old_rx_pg;
1206 struct page *sge;
1207 u16 len_on_bd = le16_to_cpu(fp_cqe->len_on_bd); 1206 u16 len_on_bd = le16_to_cpu(fp_cqe->len_on_bd);
1208 u32 i, frag_len, frag_size, pages; 1207 u32 i, frag_len, frag_size, pages;
1209 int err; 1208 int err;
1210 int j; 1209 int j;
1211 1210
1212 frag_size = le16_to_cpu(fp_cqe->pkt_len) - len_on_bd; 1211 frag_size = le16_to_cpu(fp_cqe->pkt_len) - len_on_bd;
1213 pages = BCM_PAGE_ALIGN(frag_size) >> BCM_PAGE_SHIFT; 1212 pages = SGE_PAGE_ALIGN(frag_size) >> SGE_PAGE_SHIFT;
1214 1213
1215 /* This is needed in order to enable forwarding support */ 1214 /* This is needed in order to enable forwarding support */
1216 if (frag_size) 1215 if (frag_size)
1217 skb_shinfo(skb)->gso_size = min((u32)BCM_PAGE_SIZE, 1216 skb_shinfo(skb)->gso_size = min((u32)SGE_PAGE_SIZE,
1218 max(frag_size, (u32)len_on_bd)); 1217 max(frag_size, (u32)len_on_bd));
1219 1218
1220#ifdef BNX2X_STOP_ON_ERROR 1219#ifdef BNX2X_STOP_ON_ERROR
1221 if (pages > 8*PAGES_PER_SGE) { 1220 if (pages >
1221 min((u32)8, (u32)MAX_SKB_FRAGS) * SGE_PAGE_SIZE * PAGES_PER_SGE) {
1222 BNX2X_ERR("SGL length is too long: %d. CQE index is %d\n", 1222 BNX2X_ERR("SGL length is too long: %d. CQE index is %d\n",
1223 pages, cqe_idx); 1223 pages, cqe_idx);
1224 BNX2X_ERR("fp_cqe->pkt_len = %d fp_cqe->len_on_bd = %d\n", 1224 BNX2X_ERR("fp_cqe->pkt_len = %d fp_cqe->len_on_bd = %d\n",
@@ -1234,9 +1234,8 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1234 1234
1235 /* FW gives the indices of the SGE as if the ring is an array 1235 /* FW gives the indices of the SGE as if the ring is an array
1236 (meaning that "next" element will consume 2 indices) */ 1236 (meaning that "next" element will consume 2 indices) */
1237 frag_len = min(frag_size, (u32)(BCM_PAGE_SIZE*PAGES_PER_SGE)); 1237 frag_len = min(frag_size, (u32)(SGE_PAGE_SIZE*PAGES_PER_SGE));
1238 rx_pg = &fp->rx_page_ring[sge_idx]; 1238 rx_pg = &fp->rx_page_ring[sge_idx];
1239 sge = rx_pg->page;
1240 old_rx_pg = *rx_pg; 1239 old_rx_pg = *rx_pg;
1241 1240
1242 /* If we fail to allocate a substitute page, we simply stop 1241 /* If we fail to allocate a substitute page, we simply stop
@@ -1249,7 +1248,7 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1249 1248
1250 /* Unmap the page as we r going to pass it to the stack */ 1249 /* Unmap the page as we r going to pass it to the stack */
1251 pci_unmap_page(bp->pdev, pci_unmap_addr(&old_rx_pg, mapping), 1250 pci_unmap_page(bp->pdev, pci_unmap_addr(&old_rx_pg, mapping),
1252 BCM_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE); 1251 SGE_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE);
1253 1252
1254 /* Add one frag and update the appropriate fields in the skb */ 1253 /* Add one frag and update the appropriate fields in the skb */
1255 skb_fill_page_desc(skb, j, old_rx_pg.page, 0, frag_len); 1254 skb_fill_page_desc(skb, j, old_rx_pg.page, 0, frag_len);
@@ -1282,6 +1281,13 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1282 if (likely(new_skb)) { 1281 if (likely(new_skb)) {
1283 /* fix ip xsum and give it to the stack */ 1282 /* fix ip xsum and give it to the stack */
1284 /* (no need to map the new skb) */ 1283 /* (no need to map the new skb) */
1284#ifdef BCM_VLAN
1285 int is_vlan_cqe =
1286 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) &
1287 PARSING_FLAGS_VLAN);
1288 int is_not_hwaccel_vlan_cqe =
1289 (is_vlan_cqe && (!(bp->flags & HW_VLAN_RX_FLAG)));
1290#endif
1285 1291
1286 prefetch(skb); 1292 prefetch(skb);
1287 prefetch(((char *)(skb)) + 128); 1293 prefetch(((char *)(skb)) + 128);
@@ -1306,6 +1312,12 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1306 struct iphdr *iph; 1312 struct iphdr *iph;
1307 1313
1308 iph = (struct iphdr *)skb->data; 1314 iph = (struct iphdr *)skb->data;
1315#ifdef BCM_VLAN
1316 /* If there is no Rx VLAN offloading -
1317 take VLAN tag into an account */
1318 if (unlikely(is_not_hwaccel_vlan_cqe))
1319 iph = (struct iphdr *)((u8 *)iph + VLAN_HLEN);
1320#endif
1309 iph->check = 0; 1321 iph->check = 0;
1310 iph->check = ip_fast_csum((u8 *)iph, iph->ihl); 1322 iph->check = ip_fast_csum((u8 *)iph, iph->ihl);
1311 } 1323 }
@@ -1313,9 +1325,8 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1313 if (!bnx2x_fill_frag_skb(bp, fp, skb, 1325 if (!bnx2x_fill_frag_skb(bp, fp, skb,
1314 &cqe->fast_path_cqe, cqe_idx)) { 1326 &cqe->fast_path_cqe, cqe_idx)) {
1315#ifdef BCM_VLAN 1327#ifdef BCM_VLAN
1316 if ((bp->vlgrp != NULL) && 1328 if ((bp->vlgrp != NULL) && is_vlan_cqe &&
1317 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) & 1329 (!is_not_hwaccel_vlan_cqe))
1318 PARSING_FLAGS_VLAN))
1319 vlan_hwaccel_receive_skb(skb, bp->vlgrp, 1330 vlan_hwaccel_receive_skb(skb, bp->vlgrp,
1320 le16_to_cpu(cqe->fast_path_cqe. 1331 le16_to_cpu(cqe->fast_path_cqe.
1321 vlan_tag)); 1332 vlan_tag));
@@ -1355,11 +1366,23 @@ static inline void bnx2x_update_rx_prod(struct bnx2x *bp,
1355 rx_prods.cqe_prod = rx_comp_prod; 1366 rx_prods.cqe_prod = rx_comp_prod;
1356 rx_prods.sge_prod = rx_sge_prod; 1367 rx_prods.sge_prod = rx_sge_prod;
1357 1368
1369 /*
1370 * Make sure that the BD and SGE data is updated before updating the
1371 * producers since FW might read the BD/SGE right after the producer
1372 * is updated.
1373 * This is only applicable for weak-ordered memory model archs such
1374 * as IA-64. The following barrier is also mandatory since FW will
1375 * assumes BDs must have buffers.
1376 */
1377 wmb();
1378
1358 for (i = 0; i < sizeof(struct tstorm_eth_rx_producers)/4; i++) 1379 for (i = 0; i < sizeof(struct tstorm_eth_rx_producers)/4; i++)
1359 REG_WR(bp, BAR_TSTRORM_INTMEM + 1380 REG_WR(bp, BAR_TSTRORM_INTMEM +
1360 TSTORM_RX_PRODS_OFFSET(BP_PORT(bp), FP_CL_ID(fp)) + i*4, 1381 TSTORM_RX_PRODS_OFFSET(BP_PORT(bp), FP_CL_ID(fp)) + i*4,
1361 ((u32 *)&rx_prods)[i]); 1382 ((u32 *)&rx_prods)[i]);
1362 1383
1384 mmiowb(); /* keep prod updates ordered */
1385
1363 DP(NETIF_MSG_RX_STATUS, 1386 DP(NETIF_MSG_RX_STATUS,
1364 "Wrote: bd_prod %u cqe_prod %u sge_prod %u\n", 1387 "Wrote: bd_prod %u cqe_prod %u sge_prod %u\n",
1365 bd_prod, rx_comp_prod, rx_sge_prod); 1388 bd_prod, rx_comp_prod, rx_sge_prod);
@@ -1415,7 +1438,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
1415 DP(NETIF_MSG_RX_STATUS, "CQE type %x err %x status %x" 1438 DP(NETIF_MSG_RX_STATUS, "CQE type %x err %x status %x"
1416 " queue %x vlan %x len %u\n", CQE_TYPE(cqe_fp_flags), 1439 " queue %x vlan %x len %u\n", CQE_TYPE(cqe_fp_flags),
1417 cqe_fp_flags, cqe->fast_path_cqe.status_flags, 1440 cqe_fp_flags, cqe->fast_path_cqe.status_flags,
1418 cqe->fast_path_cqe.rss_hash_result, 1441 le32_to_cpu(cqe->fast_path_cqe.rss_hash_result),
1419 le16_to_cpu(cqe->fast_path_cqe.vlan_tag), 1442 le16_to_cpu(cqe->fast_path_cqe.vlan_tag),
1420 le16_to_cpu(cqe->fast_path_cqe.pkt_len)); 1443 le16_to_cpu(cqe->fast_path_cqe.pkt_len));
1421 1444
@@ -1547,7 +1570,7 @@ reuse_rx:
1547 } 1570 }
1548 1571
1549#ifdef BCM_VLAN 1572#ifdef BCM_VLAN
1550 if ((bp->vlgrp != NULL) && 1573 if ((bp->vlgrp != NULL) && (bp->flags & HW_VLAN_RX_FLAG) &&
1551 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) & 1574 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) &
1552 PARSING_FLAGS_VLAN)) 1575 PARSING_FLAGS_VLAN))
1553 vlan_hwaccel_receive_skb(skb, bp->vlgrp, 1576 vlan_hwaccel_receive_skb(skb, bp->vlgrp,
@@ -1580,7 +1603,6 @@ next_cqe:
1580 /* Update producers */ 1603 /* Update producers */
1581 bnx2x_update_rx_prod(bp, fp, bd_prod_fw, sw_comp_prod, 1604 bnx2x_update_rx_prod(bp, fp, bd_prod_fw, sw_comp_prod,
1582 fp->rx_sge_prod); 1605 fp->rx_sge_prod);
1583 mmiowb(); /* keep prod updates ordered */
1584 1606
1585 fp->rx_pkt += rx_pkt; 1607 fp->rx_pkt += rx_pkt;
1586 fp->rx_calls++; 1608 fp->rx_calls++;
@@ -1660,7 +1682,7 @@ static irqreturn_t bnx2x_interrupt(int irq, void *dev_instance)
1660 1682
1661 1683
1662 if (unlikely(status & 0x1)) { 1684 if (unlikely(status & 0x1)) {
1663 schedule_work(&bp->sp_task); 1685 queue_delayed_work(bnx2x_wq, &bp->sp_task, 0);
1664 1686
1665 status &= ~0x1; 1687 status &= ~0x1;
1666 if (!status) 1688 if (!status)
@@ -1887,7 +1909,8 @@ static int bnx2x_set_spio(struct bnx2x *bp, int spio_num, u32 mode)
1887 1909
1888static void bnx2x_calc_fc_adv(struct bnx2x *bp) 1910static void bnx2x_calc_fc_adv(struct bnx2x *bp)
1889{ 1911{
1890 switch (bp->link_vars.ieee_fc) { 1912 switch (bp->link_vars.ieee_fc &
1913 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK) {
1891 case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE: 1914 case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE:
1892 bp->port.advertising &= ~(ADVERTISED_Asym_Pause | 1915 bp->port.advertising &= ~(ADVERTISED_Asym_Pause |
1893 ADVERTISED_Pause); 1916 ADVERTISED_Pause);
@@ -1957,10 +1980,11 @@ static u8 bnx2x_initial_phy_init(struct bnx2x *bp)
1957 rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars); 1980 rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars);
1958 bnx2x_release_phy_lock(bp); 1981 bnx2x_release_phy_lock(bp);
1959 1982
1983 bnx2x_calc_fc_adv(bp);
1984
1960 if (bp->link_vars.link_up) 1985 if (bp->link_vars.link_up)
1961 bnx2x_link_report(bp); 1986 bnx2x_link_report(bp);
1962 1987
1963 bnx2x_calc_fc_adv(bp);
1964 1988
1965 return rc; 1989 return rc;
1966 } 1990 }
@@ -2220,9 +2244,7 @@ static void bnx2x_link_attn(struct bnx2x *bp)
2220 /* Make sure that we are synced with the current statistics */ 2244 /* Make sure that we are synced with the current statistics */
2221 bnx2x_stats_handle(bp, STATS_EVENT_STOP); 2245 bnx2x_stats_handle(bp, STATS_EVENT_STOP);
2222 2246
2223 bnx2x_acquire_phy_lock(bp);
2224 bnx2x_link_update(&bp->link_params, &bp->link_vars); 2247 bnx2x_link_update(&bp->link_params, &bp->link_vars);
2225 bnx2x_release_phy_lock(bp);
2226 2248
2227 if (bp->link_vars.link_up) { 2249 if (bp->link_vars.link_up) {
2228 2250
@@ -2471,6 +2493,8 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
2471 if (asserted & ATTN_HARD_WIRED_MASK) { 2493 if (asserted & ATTN_HARD_WIRED_MASK) {
2472 if (asserted & ATTN_NIG_FOR_FUNC) { 2494 if (asserted & ATTN_NIG_FOR_FUNC) {
2473 2495
2496 bnx2x_acquire_phy_lock(bp);
2497
2474 /* save nig interrupt mask */ 2498 /* save nig interrupt mask */
2475 bp->nig_mask = REG_RD(bp, nig_int_mask_addr); 2499 bp->nig_mask = REG_RD(bp, nig_int_mask_addr);
2476 REG_WR(bp, nig_int_mask_addr, 0); 2500 REG_WR(bp, nig_int_mask_addr, 0);
@@ -2526,8 +2550,10 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
2526 REG_WR(bp, hc_addr, asserted); 2550 REG_WR(bp, hc_addr, asserted);
2527 2551
2528 /* now set back the mask */ 2552 /* now set back the mask */
2529 if (asserted & ATTN_NIG_FOR_FUNC) 2553 if (asserted & ATTN_NIG_FOR_FUNC) {
2530 REG_WR(bp, nig_int_mask_addr, bp->nig_mask); 2554 REG_WR(bp, nig_int_mask_addr, bp->nig_mask);
2555 bnx2x_release_phy_lock(bp);
2556 }
2531} 2557}
2532 2558
2533static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) 2559static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn)
@@ -2795,8 +2821,10 @@ static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted)
2795static void bnx2x_attn_int(struct bnx2x *bp) 2821static void bnx2x_attn_int(struct bnx2x *bp)
2796{ 2822{
2797 /* read local copy of bits */ 2823 /* read local copy of bits */
2798 u32 attn_bits = bp->def_status_blk->atten_status_block.attn_bits; 2824 u32 attn_bits = le32_to_cpu(bp->def_status_blk->atten_status_block.
2799 u32 attn_ack = bp->def_status_blk->atten_status_block.attn_bits_ack; 2825 attn_bits);
2826 u32 attn_ack = le32_to_cpu(bp->def_status_blk->atten_status_block.
2827 attn_bits_ack);
2800 u32 attn_state = bp->attn_state; 2828 u32 attn_state = bp->attn_state;
2801 2829
2802 /* look for changed bits */ 2830 /* look for changed bits */
@@ -2820,7 +2848,7 @@ static void bnx2x_attn_int(struct bnx2x *bp)
2820 2848
2821static void bnx2x_sp_task(struct work_struct *work) 2849static void bnx2x_sp_task(struct work_struct *work)
2822{ 2850{
2823 struct bnx2x *bp = container_of(work, struct bnx2x, sp_task); 2851 struct bnx2x *bp = container_of(work, struct bnx2x, sp_task.work);
2824 u16 status; 2852 u16 status;
2825 2853
2826 2854
@@ -2844,7 +2872,7 @@ static void bnx2x_sp_task(struct work_struct *work)
2844 if (status & 0x2) 2872 if (status & 0x2)
2845 bp->stats_pending = 0; 2873 bp->stats_pending = 0;
2846 2874
2847 bnx2x_ack_sb(bp, DEF_SB_ID, ATTENTION_ID, bp->def_att_idx, 2875 bnx2x_ack_sb(bp, DEF_SB_ID, ATTENTION_ID, le16_to_cpu(bp->def_att_idx),
2848 IGU_INT_NOP, 1); 2876 IGU_INT_NOP, 1);
2849 bnx2x_ack_sb(bp, DEF_SB_ID, USTORM_ID, le16_to_cpu(bp->def_u_idx), 2877 bnx2x_ack_sb(bp, DEF_SB_ID, USTORM_ID, le16_to_cpu(bp->def_u_idx),
2850 IGU_INT_NOP, 1); 2878 IGU_INT_NOP, 1);
@@ -2875,7 +2903,7 @@ static irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
2875 return IRQ_HANDLED; 2903 return IRQ_HANDLED;
2876#endif 2904#endif
2877 2905
2878 schedule_work(&bp->sp_task); 2906 queue_delayed_work(bnx2x_wq, &bp->sp_task, 0);
2879 2907
2880 return IRQ_HANDLED; 2908 return IRQ_HANDLED;
2881} 2909}
@@ -2892,7 +2920,7 @@ static irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
2892#define ADD_64(s_hi, a_hi, s_lo, a_lo) \ 2920#define ADD_64(s_hi, a_hi, s_lo, a_lo) \
2893 do { \ 2921 do { \
2894 s_lo += a_lo; \ 2922 s_lo += a_lo; \
2895 s_hi += a_hi + (s_lo < a_lo) ? 1 : 0; \ 2923 s_hi += a_hi + ((s_lo < a_lo) ? 1 : 0); \
2896 } while (0) 2924 } while (0)
2897 2925
2898/* difference = minuend - subtrahend */ 2926/* difference = minuend - subtrahend */
@@ -4496,7 +4524,7 @@ static void bnx2x_init_context(struct bnx2x *bp)
4496 4524
4497static void bnx2x_init_ind_table(struct bnx2x *bp) 4525static void bnx2x_init_ind_table(struct bnx2x *bp)
4498{ 4526{
4499 int port = BP_PORT(bp); 4527 int func = BP_FUNC(bp);
4500 int i; 4528 int i;
4501 4529
4502 if (!is_multi(bp)) 4530 if (!is_multi(bp))
@@ -4505,10 +4533,8 @@ static void bnx2x_init_ind_table(struct bnx2x *bp)
4505 DP(NETIF_MSG_IFUP, "Initializing indirection table\n"); 4533 DP(NETIF_MSG_IFUP, "Initializing indirection table\n");
4506 for (i = 0; i < TSTORM_INDIRECTION_TABLE_SIZE; i++) 4534 for (i = 0; i < TSTORM_INDIRECTION_TABLE_SIZE; i++)
4507 REG_WR8(bp, BAR_TSTRORM_INTMEM + 4535 REG_WR8(bp, BAR_TSTRORM_INTMEM +
4508 TSTORM_INDIRECTION_TABLE_OFFSET(port) + i, 4536 TSTORM_INDIRECTION_TABLE_OFFSET(func) + i,
4509 i % bp->num_queues); 4537 BP_CL_ID(bp) + (i % bp->num_queues));
4510
4511 REG_WR(bp, PRS_REG_A_PRSU_20, 0xf);
4512} 4538}
4513 4539
4514static void bnx2x_set_client_config(struct bnx2x *bp) 4540static void bnx2x_set_client_config(struct bnx2x *bp)
@@ -4517,12 +4543,12 @@ static void bnx2x_set_client_config(struct bnx2x *bp)
4517 int port = BP_PORT(bp); 4543 int port = BP_PORT(bp);
4518 int i; 4544 int i;
4519 4545
4520 tstorm_client.mtu = bp->dev->mtu + ETH_OVREHEAD; 4546 tstorm_client.mtu = bp->dev->mtu;
4521 tstorm_client.statistics_counter_id = BP_CL_ID(bp); 4547 tstorm_client.statistics_counter_id = BP_CL_ID(bp);
4522 tstorm_client.config_flags = 4548 tstorm_client.config_flags =
4523 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE; 4549 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE;
4524#ifdef BCM_VLAN 4550#ifdef BCM_VLAN
4525 if (bp->rx_mode && bp->vlgrp) { 4551 if (bp->rx_mode && bp->vlgrp && (bp->flags & HW_VLAN_RX_FLAG)) {
4526 tstorm_client.config_flags |= 4552 tstorm_client.config_flags |=
4527 TSTORM_ETH_CLIENT_CONFIG_VLAN_REMOVAL_ENABLE; 4553 TSTORM_ETH_CLIENT_CONFIG_VLAN_REMOVAL_ENABLE;
4528 DP(NETIF_MSG_IFUP, "vlan removal enabled\n"); 4554 DP(NETIF_MSG_IFUP, "vlan removal enabled\n");
@@ -4531,7 +4557,7 @@ static void bnx2x_set_client_config(struct bnx2x *bp)
4531 4557
4532 if (bp->flags & TPA_ENABLE_FLAG) { 4558 if (bp->flags & TPA_ENABLE_FLAG) {
4533 tstorm_client.max_sges_for_packet = 4559 tstorm_client.max_sges_for_packet =
4534 BCM_PAGE_ALIGN(tstorm_client.mtu) >> BCM_PAGE_SHIFT; 4560 SGE_PAGE_ALIGN(tstorm_client.mtu) >> SGE_PAGE_SHIFT;
4535 tstorm_client.max_sges_for_packet = 4561 tstorm_client.max_sges_for_packet =
4536 ((tstorm_client.max_sges_for_packet + 4562 ((tstorm_client.max_sges_for_packet +
4537 PAGES_PER_SGE - 1) & (~(PAGES_PER_SGE - 1))) >> 4563 PAGES_PER_SGE - 1) & (~(PAGES_PER_SGE - 1))) >>
@@ -4714,10 +4740,11 @@ static void bnx2x_init_internal_func(struct bnx2x *bp)
4714 bp->e1hov); 4740 bp->e1hov);
4715 } 4741 }
4716 4742
4717 /* Init CQ ring mapping and aggregation size */ 4743 /* Init CQ ring mapping and aggregation size, the FW limit is 8 frags */
4718 max_agg_size = min((u32)(bp->rx_buf_size + 4744 max_agg_size =
4719 8*BCM_PAGE_SIZE*PAGES_PER_SGE), 4745 min((u32)(min((u32)8, (u32)MAX_SKB_FRAGS) *
4720 (u32)0xffff); 4746 SGE_PAGE_SIZE * PAGES_PER_SGE),
4747 (u32)0xffff);
4721 for_each_queue(bp, i) { 4748 for_each_queue(bp, i) {
4722 struct bnx2x_fastpath *fp = &bp->fp[i]; 4749 struct bnx2x_fastpath *fp = &bp->fp[i];
4723 4750
@@ -4785,6 +4812,15 @@ static void bnx2x_nic_init(struct bnx2x *bp, u32 load_code)
4785 bnx2x_init_context(bp); 4812 bnx2x_init_context(bp);
4786 bnx2x_init_internal(bp, load_code); 4813 bnx2x_init_internal(bp, load_code);
4787 bnx2x_init_ind_table(bp); 4814 bnx2x_init_ind_table(bp);
4815 bnx2x_stats_init(bp);
4816
4817 /* At this point, we are ready for interrupts */
4818 atomic_set(&bp->intr_sem, 0);
4819
4820 /* flush all before enabling interrupts */
4821 mb();
4822 mmiowb();
4823
4788 bnx2x_int_enable(bp); 4824 bnx2x_int_enable(bp);
4789} 4825}
4790 4826
@@ -5134,7 +5170,6 @@ static int bnx2x_init_common(struct bnx2x *bp)
5134 REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, 1); 5170 REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, 1);
5135 REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, 1); 5171 REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, 1);
5136 REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, 1); 5172 REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, 1);
5137 REG_WR(bp, PXP2_REG_RQ_HC_ENDIAN_M, 1);
5138 5173
5139/* REG_WR(bp, PXP2_REG_RD_PBF_SWAP_MODE, 1); */ 5174/* REG_WR(bp, PXP2_REG_RD_PBF_SWAP_MODE, 1); */
5140 REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, 1); 5175 REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, 1);
@@ -5212,6 +5247,7 @@ static int bnx2x_init_common(struct bnx2x *bp)
5212 } 5247 }
5213 5248
5214 bnx2x_init_block(bp, PRS_COMMON_START, PRS_COMMON_END); 5249 bnx2x_init_block(bp, PRS_COMMON_START, PRS_COMMON_END);
5250 REG_WR(bp, PRS_REG_A_PRSU_20, 0xf);
5215 /* set NIC mode */ 5251 /* set NIC mode */
5216 REG_WR(bp, PRS_REG_NIC_MODE, 1); 5252 REG_WR(bp, PRS_REG_NIC_MODE, 1);
5217 if (CHIP_IS_E1H(bp)) 5253 if (CHIP_IS_E1H(bp))
@@ -6393,17 +6429,8 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
6393 } 6429 }
6394 } 6430 }
6395 6431
6396 bnx2x_stats_init(bp);
6397
6398 bp->state = BNX2X_STATE_OPENING_WAIT4_PORT; 6432 bp->state = BNX2X_STATE_OPENING_WAIT4_PORT;
6399 6433
6400 /* Enable Rx interrupt handling before sending the ramrod
6401 as it's completed on Rx FP queue */
6402 bnx2x_napi_enable(bp);
6403
6404 /* Enable interrupt handling */
6405 atomic_set(&bp->intr_sem, 0);
6406
6407 rc = bnx2x_setup_leading(bp); 6434 rc = bnx2x_setup_leading(bp);
6408 if (rc) { 6435 if (rc) {
6409 BNX2X_ERR("Setup leading failed!\n"); 6436 BNX2X_ERR("Setup leading failed!\n");
@@ -7501,7 +7528,7 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
7501 7528
7502 mutex_init(&bp->port.phy_mutex); 7529 mutex_init(&bp->port.phy_mutex);
7503 7530
7504 INIT_WORK(&bp->sp_task, bnx2x_sp_task); 7531 INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task);
7505 INIT_WORK(&bp->reset_task, bnx2x_reset_task); 7532 INIT_WORK(&bp->reset_task, bnx2x_reset_task);
7506 7533
7507 rc = bnx2x_get_hwinfo(bp); 7534 rc = bnx2x_get_hwinfo(bp);
@@ -8727,6 +8754,8 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode, u8 link_up)
8727 tx_bd->general_data = ((UNICAST_ADDRESS << 8754 tx_bd->general_data = ((UNICAST_ADDRESS <<
8728 ETH_TX_BD_ETH_ADDR_TYPE_SHIFT) | 1); 8755 ETH_TX_BD_ETH_ADDR_TYPE_SHIFT) | 1);
8729 8756
8757 wmb();
8758
8730 fp->hw_tx_prods->bds_prod = 8759 fp->hw_tx_prods->bds_prod =
8731 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + 1); 8760 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + 1);
8732 mb(); /* FW restriction: must not reorder writing nbd and packets */ 8761 mb(); /* FW restriction: must not reorder writing nbd and packets */
@@ -8778,7 +8807,6 @@ test_loopback_rx_exit:
8778 /* Update producers */ 8807 /* Update producers */
8779 bnx2x_update_rx_prod(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod, 8808 bnx2x_update_rx_prod(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod,
8780 fp->rx_sge_prod); 8809 fp->rx_sge_prod);
8781 mmiowb(); /* keep prod updates ordered */
8782 8810
8783test_loopback_exit: 8811test_loopback_exit:
8784 bp->link_params.loopback_mode = LOOPBACK_NONE; 8812 bp->link_params.loopback_mode = LOOPBACK_NONE;
@@ -9549,11 +9577,14 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
9549 "sending pkt %u @%p next_idx %u bd %u @%p\n", 9577 "sending pkt %u @%p next_idx %u bd %u @%p\n",
9550 pkt_prod, tx_buf, fp->tx_pkt_prod, bd_prod, tx_bd); 9578 pkt_prod, tx_buf, fp->tx_pkt_prod, bd_prod, tx_bd);
9551 9579
9552 if ((bp->vlgrp != NULL) && vlan_tx_tag_present(skb)) { 9580#ifdef BCM_VLAN
9581 if ((bp->vlgrp != NULL) && vlan_tx_tag_present(skb) &&
9582 (bp->flags & HW_VLAN_TX_FLAG)) {
9553 tx_bd->vlan = cpu_to_le16(vlan_tx_tag_get(skb)); 9583 tx_bd->vlan = cpu_to_le16(vlan_tx_tag_get(skb));
9554 tx_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_VLAN_TAG; 9584 tx_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_VLAN_TAG;
9555 vlan_off += 4; 9585 vlan_off += 4;
9556 } else 9586 } else
9587#endif
9557 tx_bd->vlan = cpu_to_le16(pkt_prod); 9588 tx_bd->vlan = cpu_to_le16(pkt_prod);
9558 9589
9559 if (xmit_type) { 9590 if (xmit_type) {
@@ -9705,6 +9736,15 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
9705 9736
9706 DP(NETIF_MSG_TX_QUEUED, "doorbell: nbd %d bd %u\n", nbd, bd_prod); 9737 DP(NETIF_MSG_TX_QUEUED, "doorbell: nbd %d bd %u\n", nbd, bd_prod);
9707 9738
9739 /*
9740 * Make sure that the BD data is updated before updating the producer
9741 * since FW might read the BD right after the producer is updated.
9742 * This is only applicable for weak-ordered memory model archs such
9743 * as IA-64. The following barrier is also mandatory since FW will
9744 * assumes packets must have BDs.
9745 */
9746 wmb();
9747
9708 fp->hw_tx_prods->bds_prod = 9748 fp->hw_tx_prods->bds_prod =
9709 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + nbd); 9749 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + nbd);
9710 mb(); /* FW restriction: must not reorder writing nbd and packets */ 9750 mb(); /* FW restriction: must not reorder writing nbd and packets */
@@ -9718,6 +9758,9 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
9718 dev->trans_start = jiffies; 9758 dev->trans_start = jiffies;
9719 9759
9720 if (unlikely(bnx2x_tx_avail(fp) < MAX_SKB_FRAGS + 3)) { 9760 if (unlikely(bnx2x_tx_avail(fp) < MAX_SKB_FRAGS + 3)) {
9761 /* We want bnx2x_tx_int to "see" the updated tx_bd_prod
9762 if we put Tx into XOFF state. */
9763 smp_mb();
9721 netif_stop_queue(dev); 9764 netif_stop_queue(dev);
9722 bp->eth_stats.driver_xoff++; 9765 bp->eth_stats.driver_xoff++;
9723 if (bnx2x_tx_avail(fp) >= MAX_SKB_FRAGS + 3) 9766 if (bnx2x_tx_avail(fp) >= MAX_SKB_FRAGS + 3)
@@ -9987,6 +10030,16 @@ static void bnx2x_vlan_rx_register(struct net_device *dev,
9987 struct bnx2x *bp = netdev_priv(dev); 10030 struct bnx2x *bp = netdev_priv(dev);
9988 10031
9989 bp->vlgrp = vlgrp; 10032 bp->vlgrp = vlgrp;
10033
10034 /* Set flags according to the required capabilities */
10035 bp->flags &= ~(HW_VLAN_RX_FLAG | HW_VLAN_TX_FLAG);
10036
10037 if (dev->features & NETIF_F_HW_VLAN_TX)
10038 bp->flags |= HW_VLAN_TX_FLAG;
10039
10040 if (dev->features & NETIF_F_HW_VLAN_RX)
10041 bp->flags |= HW_VLAN_RX_FLAG;
10042
9990 if (netif_running(dev)) 10043 if (netif_running(dev))
9991 bnx2x_set_client_config(bp); 10044 bnx2x_set_client_config(bp);
9992} 10045}
@@ -10143,6 +10196,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10143 dev->features |= NETIF_F_HIGHDMA; 10196 dev->features |= NETIF_F_HIGHDMA;
10144#ifdef BCM_VLAN 10197#ifdef BCM_VLAN
10145 dev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); 10198 dev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX);
10199 bp->flags |= (HW_VLAN_RX_FLAG | HW_VLAN_TX_FLAG);
10146#endif 10200#endif
10147 dev->features |= (NETIF_F_TSO | NETIF_F_TSO_ECN); 10201 dev->features |= (NETIF_F_TSO | NETIF_F_TSO_ECN);
10148 dev->features |= NETIF_F_TSO6; 10202 dev->features |= NETIF_F_TSO6;
@@ -10519,12 +10573,20 @@ static struct pci_driver bnx2x_pci_driver = {
10519 10573
10520static int __init bnx2x_init(void) 10574static int __init bnx2x_init(void)
10521{ 10575{
10576 bnx2x_wq = create_singlethread_workqueue("bnx2x");
10577 if (bnx2x_wq == NULL) {
10578 printk(KERN_ERR PFX "Cannot create workqueue\n");
10579 return -ENOMEM;
10580 }
10581
10522 return pci_register_driver(&bnx2x_pci_driver); 10582 return pci_register_driver(&bnx2x_pci_driver);
10523} 10583}
10524 10584
10525static void __exit bnx2x_cleanup(void) 10585static void __exit bnx2x_cleanup(void)
10526{ 10586{
10527 pci_unregister_driver(&bnx2x_pci_driver); 10587 pci_unregister_driver(&bnx2x_pci_driver);
10588
10589 destroy_workqueue(bnx2x_wq);
10528} 10590}
10529 10591
10530module_init(bnx2x_init); 10592module_init(bnx2x_init);
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 5b346f9eaa8b..a89d8cc51205 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -50,12 +50,17 @@ struct vlan_group;
50struct adapter; 50struct adapter;
51struct sge_qset; 51struct sge_qset;
52 52
53enum { /* rx_offload flags */
54 T3_RX_CSUM = 1 << 0,
55 T3_LRO = 1 << 1,
56};
57
53struct port_info { 58struct port_info {
54 struct adapter *adapter; 59 struct adapter *adapter;
55 struct vlan_group *vlan_grp; 60 struct vlan_group *vlan_grp;
56 struct sge_qset *qs; 61 struct sge_qset *qs;
57 u8 port_id; 62 u8 port_id;
58 u8 rx_csum_offload; 63 u8 rx_offload;
59 u8 nqsets; 64 u8 nqsets;
60 u8 first_qset; 65 u8 first_qset;
61 struct cphy phy; 66 struct cphy phy;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 2847f947499d..0089746b8d02 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -546,7 +546,7 @@ static int setup_sge_qsets(struct adapter *adap)
546 pi->qs = &adap->sge.qs[pi->first_qset]; 546 pi->qs = &adap->sge.qs[pi->first_qset];
547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets; 547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets;
548 ++j, ++qset_idx) { 548 ++j, ++qset_idx) {
549 set_qset_lro(dev, qset_idx, pi->rx_csum_offload); 549 set_qset_lro(dev, qset_idx, pi->rx_offload & T3_LRO);
550 err = t3_sge_alloc_qset(adap, qset_idx, 1, 550 err = t3_sge_alloc_qset(adap, qset_idx, 1,
551 (adap->flags & USING_MSIX) ? qset_idx + 1 : 551 (adap->flags & USING_MSIX) ? qset_idx + 1 :
552 irq_idx, 552 irq_idx,
@@ -1657,17 +1657,19 @@ static u32 get_rx_csum(struct net_device *dev)
1657{ 1657{
1658 struct port_info *p = netdev_priv(dev); 1658 struct port_info *p = netdev_priv(dev);
1659 1659
1660 return p->rx_csum_offload; 1660 return p->rx_offload & T3_RX_CSUM;
1661} 1661}
1662 1662
1663static int set_rx_csum(struct net_device *dev, u32 data) 1663static int set_rx_csum(struct net_device *dev, u32 data)
1664{ 1664{
1665 struct port_info *p = netdev_priv(dev); 1665 struct port_info *p = netdev_priv(dev);
1666 1666
1667 p->rx_csum_offload = data; 1667 if (data) {
1668 if (!data) { 1668 p->rx_offload |= T3_RX_CSUM;
1669 } else {
1669 int i; 1670 int i;
1670 1671
1672 p->rx_offload &= ~(T3_RX_CSUM | T3_LRO);
1671 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) 1673 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++)
1672 set_qset_lro(dev, i, 0); 1674 set_qset_lro(dev, i, 0);
1673 } 1675 }
@@ -1830,15 +1832,18 @@ static int cxgb3_set_flags(struct net_device *dev, u32 data)
1830 int i; 1832 int i;
1831 1833
1832 if (data & ETH_FLAG_LRO) { 1834 if (data & ETH_FLAG_LRO) {
1833 if (!pi->rx_csum_offload) 1835 if (!(pi->rx_offload & T3_RX_CSUM))
1834 return -EINVAL; 1836 return -EINVAL;
1835 1837
1838 pi->rx_offload |= T3_LRO;
1836 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1839 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1837 set_qset_lro(dev, i, 1); 1840 set_qset_lro(dev, i, 1);
1838 1841
1839 } else 1842 } else {
1843 pi->rx_offload &= ~T3_LRO;
1840 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1844 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1841 set_qset_lro(dev, i, 0); 1845 set_qset_lro(dev, i, 0);
1846 }
1842 1847
1843 return 0; 1848 return 0;
1844} 1849}
@@ -1926,7 +1931,7 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1926 pi = adap2pinfo(adapter, i); 1931 pi = adap2pinfo(adapter, i);
1927 if (t.qset_idx >= pi->first_qset && 1932 if (t.qset_idx >= pi->first_qset &&
1928 t.qset_idx < pi->first_qset + pi->nqsets && 1933 t.qset_idx < pi->first_qset + pi->nqsets &&
1929 !pi->rx_csum_offload) 1934 !(pi->rx_offload & T3_RX_CSUM))
1930 return -EINVAL; 1935 return -EINVAL;
1931 } 1936 }
1932 1937
@@ -2946,7 +2951,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2946 adapter->port[i] = netdev; 2951 adapter->port[i] = netdev;
2947 pi = netdev_priv(netdev); 2952 pi = netdev_priv(netdev);
2948 pi->adapter = adapter; 2953 pi->adapter = adapter;
2949 pi->rx_csum_offload = 1; 2954 pi->rx_offload = T3_RX_CSUM | T3_LRO;
2950 pi->port_id = i; 2955 pi->port_id = i;
2951 netif_carrier_off(netdev); 2956 netif_carrier_off(netdev);
2952 netif_tx_stop_all_queues(netdev); 2957 netif_tx_stop_all_queues(netdev);
@@ -2955,6 +2960,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2955 netdev->mem_end = mmio_start + mmio_len - 1; 2960 netdev->mem_end = mmio_start + mmio_len - 1;
2956 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; 2961 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
2957 netdev->features |= NETIF_F_LLTX; 2962 netdev->features |= NETIF_F_LLTX;
2963 netdev->features |= NETIF_F_LRO;
2958 if (pci_using_dac) 2964 if (pci_using_dac)
2959 netdev->features |= NETIF_F_HIGHDMA; 2965 netdev->features |= NETIF_F_HIGHDMA;
2960 2966
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 6c641a889471..14f9fb3e8795 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1932,7 +1932,7 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq,
1932 skb_pull(skb, sizeof(*p) + pad); 1932 skb_pull(skb, sizeof(*p) + pad);
1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]); 1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]);
1934 pi = netdev_priv(skb->dev); 1934 pi = netdev_priv(skb->dev);
1935 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) && 1935 if ((pi->rx_offload & T3_RX_CSUM) && p->csum_valid && p->csum == htons(0xffff) &&
1936 !p->fragment) { 1936 !p->fragment) {
1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++; 1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++;
1938 skb->ip_summed = CHECKSUM_UNNECESSARY; 1938 skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index f2a5963b5a95..e415e81ecd3e 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -390,7 +390,8 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
390} 390}
391 391
392static DEFINE_MUTEX(nvm_mutex); 392static DEFINE_MUTEX(nvm_mutex);
393static pid_t nvm_owner = -1; 393static pid_t nvm_owner_pid = -1;
394static char nvm_owner_name[TASK_COMM_LEN] = "";
394 395
395/** 396/**
396 * e1000_acquire_swflag_ich8lan - Acquire software control flag 397 * e1000_acquire_swflag_ich8lan - Acquire software control flag
@@ -408,11 +409,15 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
408 might_sleep(); 409 might_sleep();
409 410
410 if (!mutex_trylock(&nvm_mutex)) { 411 if (!mutex_trylock(&nvm_mutex)) {
411 WARN(1, KERN_ERR "e1000e mutex contention. Owned by pid %d\n", 412 WARN(1, KERN_ERR "e1000e mutex contention. Owned by process "
412 nvm_owner); 413 "%s (pid %d), required by process %s (pid %d)\n",
414 nvm_owner_name, nvm_owner_pid,
415 current->comm, current->pid);
416
413 mutex_lock(&nvm_mutex); 417 mutex_lock(&nvm_mutex);
414 } 418 }
415 nvm_owner = current->pid; 419 nvm_owner_pid = current->pid;
420 strncpy(nvm_owner_name, current->comm, TASK_COMM_LEN);
416 421
417 while (timeout) { 422 while (timeout) {
418 extcnf_ctrl = er32(EXTCNF_CTRL); 423 extcnf_ctrl = er32(EXTCNF_CTRL);
@@ -430,7 +435,8 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
430 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 435 hw_dbg(hw, "FW or HW has locked the resource for too long.\n");
431 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 436 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
432 ew32(EXTCNF_CTRL, extcnf_ctrl); 437 ew32(EXTCNF_CTRL, extcnf_ctrl);
433 nvm_owner = -1; 438 nvm_owner_pid = -1;
439 strcpy(nvm_owner_name, "");
434 mutex_unlock(&nvm_mutex); 440 mutex_unlock(&nvm_mutex);
435 return -E1000_ERR_CONFIG; 441 return -E1000_ERR_CONFIG;
436 } 442 }
@@ -454,7 +460,8 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
454 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 460 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
455 ew32(EXTCNF_CTRL, extcnf_ctrl); 461 ew32(EXTCNF_CTRL, extcnf_ctrl);
456 462
457 nvm_owner = -1; 463 nvm_owner_pid = -1;
464 strcpy(nvm_owner_name, "");
458 mutex_unlock(&nvm_mutex); 465 mutex_unlock(&nvm_mutex);
459} 466}
460 467
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c
index 20eb05cddb83..b07ba1924de0 100644
--- a/drivers/net/e2100.c
+++ b/drivers/net/e2100.c
@@ -169,6 +169,7 @@ static const struct net_device_ops e21_netdev_ops = {
169 .ndo_get_stats = ei_get_stats, 169 .ndo_get_stats = ei_get_stats,
170 .ndo_set_multicast_list = ei_set_multicast_list, 170 .ndo_set_multicast_list = ei_set_multicast_list,
171 .ndo_validate_addr = eth_validate_addr, 171 .ndo_validate_addr = eth_validate_addr,
172 .ndo_set_mac_address = eth_mac_addr,
172 .ndo_change_mtu = eth_change_mtu, 173 .ndo_change_mtu = eth_change_mtu,
173#ifdef CONFIG_NET_POLL_CONTROLLER 174#ifdef CONFIG_NET_POLL_CONTROLLER
174 .ndo_poll_controller = ei_poll, 175 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index e3131ea629cd..dfe92264e825 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -132,7 +132,7 @@ void ehea_dump(void *adr, int len, char *msg)
132 int x; 132 int x;
133 unsigned char *deb = adr; 133 unsigned char *deb = adr;
134 for (x = 0; x < len; x += 16) { 134 for (x = 0; x < len; x += 16) {
135 printk(DRV_NAME " %s adr=%p ofs=%04x %016lx %016lx\n", msg, 135 printk(DRV_NAME " %s adr=%p ofs=%04x %016llx %016llx\n", msg,
136 deb, x, *((u64 *)&deb[0]), *((u64 *)&deb[8])); 136 deb, x, *((u64 *)&deb[0]), *((u64 *)&deb[8]));
137 deb += 16; 137 deb += 16;
138 } 138 }
@@ -883,7 +883,7 @@ static irqreturn_t ehea_qp_aff_irq_handler(int irq, void *param)
883 883
884 while (eqe) { 884 while (eqe) {
885 qp_token = EHEA_BMASK_GET(EHEA_EQE_QP_TOKEN, eqe->entry); 885 qp_token = EHEA_BMASK_GET(EHEA_EQE_QP_TOKEN, eqe->entry);
886 ehea_error("QP aff_err: entry=0x%lx, token=0x%x", 886 ehea_error("QP aff_err: entry=0x%llx, token=0x%x",
887 eqe->entry, qp_token); 887 eqe->entry, qp_token);
888 888
889 qp = port->port_res[qp_token].qp; 889 qp = port->port_res[qp_token].qp;
@@ -1159,7 +1159,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
1159 netif_stop_queue(port->netdev); 1159 netif_stop_queue(port->netdev);
1160 break; 1160 break;
1161 default: 1161 default:
1162 ehea_error("unknown event code %x, eqe=0x%lX", ec, eqe); 1162 ehea_error("unknown event code %x, eqe=0x%llX", ec, eqe);
1163 break; 1163 break;
1164 } 1164 }
1165} 1165}
@@ -1971,7 +1971,7 @@ static void ehea_set_multicast_list(struct net_device *dev)
1971 } 1971 }
1972 1972
1973 if (dev->mc_count > port->adapter->max_mc_mac) { 1973 if (dev->mc_count > port->adapter->max_mc_mac) {
1974 ehea_info("Mcast registration limit reached (0x%lx). " 1974 ehea_info("Mcast registration limit reached (0x%llx). "
1975 "Use ALLMULTI!", 1975 "Use ALLMULTI!",
1976 port->adapter->max_mc_mac); 1976 port->adapter->max_mc_mac);
1977 goto out; 1977 goto out;
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index 225c692b5d99..49d766ebbcf4 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -168,7 +168,7 @@ struct ehea_cq *ehea_create_cq(struct ehea_adapter *adapter,
168 cq->fw_handle, rpage, 1); 168 cq->fw_handle, rpage, 1);
169 if (hret < H_SUCCESS) { 169 if (hret < H_SUCCESS) {
170 ehea_error("register_rpage_cq failed ehea_cq=%p " 170 ehea_error("register_rpage_cq failed ehea_cq=%p "
171 "hret=%lx counter=%i act_pages=%i", 171 "hret=%llx counter=%i act_pages=%i",
172 cq, hret, counter, cq->attr.nr_pages); 172 cq, hret, counter, cq->attr.nr_pages);
173 goto out_kill_hwq; 173 goto out_kill_hwq;
174 } 174 }
@@ -178,13 +178,13 @@ struct ehea_cq *ehea_create_cq(struct ehea_adapter *adapter,
178 178
179 if ((hret != H_SUCCESS) || (vpage)) { 179 if ((hret != H_SUCCESS) || (vpage)) {
180 ehea_error("registration of pages not " 180 ehea_error("registration of pages not "
181 "complete hret=%lx\n", hret); 181 "complete hret=%llx\n", hret);
182 goto out_kill_hwq; 182 goto out_kill_hwq;
183 } 183 }
184 } else { 184 } else {
185 if (hret != H_PAGE_REGISTERED) { 185 if (hret != H_PAGE_REGISTERED) {
186 ehea_error("CQ: registration of page failed " 186 ehea_error("CQ: registration of page failed "
187 "hret=%lx\n", hret); 187 "hret=%llx\n", hret);
188 goto out_kill_hwq; 188 goto out_kill_hwq;
189 } 189 }
190 } 190 }
@@ -986,15 +986,15 @@ void print_error_data(u64 *data)
986 length = EHEA_PAGESIZE; 986 length = EHEA_PAGESIZE;
987 987
988 if (type == 0x8) /* Queue Pair */ 988 if (type == 0x8) /* Queue Pair */
989 ehea_error("QP (resource=%lX) state: AER=0x%lX, AERR=0x%lX, " 989 ehea_error("QP (resource=%llX) state: AER=0x%llX, AERR=0x%llX, "
990 "port=%lX", resource, data[6], data[12], data[22]); 990 "port=%llX", resource, data[6], data[12], data[22]);
991 991
992 if (type == 0x4) /* Completion Queue */ 992 if (type == 0x4) /* Completion Queue */
993 ehea_error("CQ (resource=%lX) state: AER=0x%lX", resource, 993 ehea_error("CQ (resource=%llX) state: AER=0x%llX", resource,
994 data[6]); 994 data[6]);
995 995
996 if (type == 0x3) /* Event Queue */ 996 if (type == 0x3) /* Event Queue */
997 ehea_error("EQ (resource=%lX) state: AER=0x%lX", resource, 997 ehea_error("EQ (resource=%llX) state: AER=0x%llX", resource,
998 data[6]); 998 data[6]);
999 999
1000 ehea_dump(data, length, "error data"); 1000 ehea_dump(data, length, "error data");
@@ -1016,11 +1016,11 @@ void ehea_error_data(struct ehea_adapter *adapter, u64 res_handle)
1016 rblock); 1016 rblock);
1017 1017
1018 if (ret == H_R_STATE) 1018 if (ret == H_R_STATE)
1019 ehea_error("No error data is available: %lX.", res_handle); 1019 ehea_error("No error data is available: %llX.", res_handle);
1020 else if (ret == H_SUCCESS) 1020 else if (ret == H_SUCCESS)
1021 print_error_data(rblock); 1021 print_error_data(rblock);
1022 else 1022 else
1023 ehea_error("Error data could not be fetched: %lX", res_handle); 1023 ehea_error("Error data could not be fetched: %llX", res_handle);
1024 1024
1025 kfree(rblock); 1025 kfree(rblock);
1026} 1026}
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index d039e16f2763..7d60551d538f 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1599,6 +1599,7 @@ static const struct net_device_ops enic_netdev_ops = {
1599 .ndo_start_xmit = enic_hard_start_xmit, 1599 .ndo_start_xmit = enic_hard_start_xmit,
1600 .ndo_get_stats = enic_get_stats, 1600 .ndo_get_stats = enic_get_stats,
1601 .ndo_validate_addr = eth_validate_addr, 1601 .ndo_validate_addr = eth_validate_addr,
1602 .ndo_set_mac_address = eth_mac_addr,
1602 .ndo_set_multicast_list = enic_set_multicast_list, 1603 .ndo_set_multicast_list = enic_set_multicast_list,
1603 .ndo_change_mtu = enic_change_mtu, 1604 .ndo_change_mtu = enic_change_mtu,
1604 .ndo_vlan_rx_register = enic_vlan_rx_register, 1605 .ndo_vlan_rx_register = enic_vlan_rx_register,
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 5b68dc20168d..5b910cf63740 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -13,7 +13,7 @@
13 * Copyright (C) 2004 Andrew de Quincey (wol support) 13 * Copyright (C) 2004 Andrew de Quincey (wol support)
14 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane 14 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane
15 * IRQ rate fixes, bigendian fixes, cleanups, verification) 15 * IRQ rate fixes, bigendian fixes, cleanups, verification)
16 * Copyright (c) 2004,2005,2006,2007,2008 NVIDIA Corporation 16 * Copyright (c) 2004,2005,2006,2007,2008,2009 NVIDIA Corporation
17 * 17 *
18 * This program is free software; you can redistribute it and/or modify 18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by 19 * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
39 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 39 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
40 * superfluous timer interrupts from the nic. 40 * superfluous timer interrupts from the nic.
41 */ 41 */
42#define FORCEDETH_VERSION "0.61" 42#define FORCEDETH_VERSION "0.62"
43#define DRV_NAME "forcedeth" 43#define DRV_NAME "forcedeth"
44 44
45#include <linux/module.h> 45#include <linux/module.h>
@@ -2096,14 +2096,15 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
2096 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0); 2096 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
2097 } 2097 }
2098 2098
2099 spin_lock_irqsave(&np->lock, flags);
2099 empty_slots = nv_get_empty_tx_slots(np); 2100 empty_slots = nv_get_empty_tx_slots(np);
2100 if (unlikely(empty_slots <= entries)) { 2101 if (unlikely(empty_slots <= entries)) {
2101 spin_lock_irqsave(&np->lock, flags);
2102 netif_stop_queue(dev); 2102 netif_stop_queue(dev);
2103 np->tx_stop = 1; 2103 np->tx_stop = 1;
2104 spin_unlock_irqrestore(&np->lock, flags); 2104 spin_unlock_irqrestore(&np->lock, flags);
2105 return NETDEV_TX_BUSY; 2105 return NETDEV_TX_BUSY;
2106 } 2106 }
2107 spin_unlock_irqrestore(&np->lock, flags);
2107 2108
2108 start_tx = put_tx = np->put_tx.orig; 2109 start_tx = put_tx = np->put_tx.orig;
2109 2110
@@ -2214,14 +2215,15 @@ static int nv_start_xmit_optimized(struct sk_buff *skb, struct net_device *dev)
2214 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0); 2215 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
2215 } 2216 }
2216 2217
2218 spin_lock_irqsave(&np->lock, flags);
2217 empty_slots = nv_get_empty_tx_slots(np); 2219 empty_slots = nv_get_empty_tx_slots(np);
2218 if (unlikely(empty_slots <= entries)) { 2220 if (unlikely(empty_slots <= entries)) {
2219 spin_lock_irqsave(&np->lock, flags);
2220 netif_stop_queue(dev); 2221 netif_stop_queue(dev);
2221 np->tx_stop = 1; 2222 np->tx_stop = 1;
2222 spin_unlock_irqrestore(&np->lock, flags); 2223 spin_unlock_irqrestore(&np->lock, flags);
2223 return NETDEV_TX_BUSY; 2224 return NETDEV_TX_BUSY;
2224 } 2225 }
2226 spin_unlock_irqrestore(&np->lock, flags);
2225 2227
2226 start_tx = put_tx = np->put_tx.ex; 2228 start_tx = put_tx = np->put_tx.ex;
2227 start_tx_ctx = np->put_tx_ctx; 2229 start_tx_ctx = np->put_tx_ctx;
@@ -3403,10 +3405,10 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
3403 3405
3404#ifdef CONFIG_FORCEDETH_NAPI 3406#ifdef CONFIG_FORCEDETH_NAPI
3405 if (events & NVREG_IRQ_RX_ALL) { 3407 if (events & NVREG_IRQ_RX_ALL) {
3408 spin_lock(&np->lock);
3406 netif_rx_schedule(&np->napi); 3409 netif_rx_schedule(&np->napi);
3407 3410
3408 /* Disable furthur receive irq's */ 3411 /* Disable furthur receive irq's */
3409 spin_lock(&np->lock);
3410 np->irqmask &= ~NVREG_IRQ_RX_ALL; 3412 np->irqmask &= ~NVREG_IRQ_RX_ALL;
3411 3413
3412 if (np->msi_flags & NV_MSI_X_ENABLED) 3414 if (np->msi_flags & NV_MSI_X_ENABLED)
@@ -3520,10 +3522,10 @@ static irqreturn_t nv_nic_irq_optimized(int foo, void *data)
3520 3522
3521#ifdef CONFIG_FORCEDETH_NAPI 3523#ifdef CONFIG_FORCEDETH_NAPI
3522 if (events & NVREG_IRQ_RX_ALL) { 3524 if (events & NVREG_IRQ_RX_ALL) {
3525 spin_lock(&np->lock);
3523 netif_rx_schedule(&np->napi); 3526 netif_rx_schedule(&np->napi);
3524 3527
3525 /* Disable furthur receive irq's */ 3528 /* Disable furthur receive irq's */
3526 spin_lock(&np->lock);
3527 np->irqmask &= ~NVREG_IRQ_RX_ALL; 3529 np->irqmask &= ~NVREG_IRQ_RX_ALL;
3528 3530
3529 if (np->msi_flags & NV_MSI_X_ENABLED) 3531 if (np->msi_flags & NV_MSI_X_ENABLED)
@@ -6167,19 +6169,19 @@ static struct pci_device_id pci_tbl[] = {
6167 }, 6169 },
6168 { /* MCP79 Ethernet Controller */ 6170 { /* MCP79 Ethernet Controller */
6169 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36), 6171 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36),
6170 .driver_data = DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6172 .driver_data = DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6171 }, 6173 },
6172 { /* MCP79 Ethernet Controller */ 6174 { /* MCP79 Ethernet Controller */
6173 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37), 6175 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37),
6174 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6176 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6175 }, 6177 },
6176 { /* MCP79 Ethernet Controller */ 6178 { /* MCP79 Ethernet Controller */
6177 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38), 6179 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38),
6178 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6180 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6179 }, 6181 },
6180 { /* MCP79 Ethernet Controller */ 6182 { /* MCP79 Ethernet Controller */
6181 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39), 6183 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39),
6182 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6184 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6183 }, 6185 },
6184 {0,}, 6186 {0,},
6185}; 6187};
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 4e6a9195fe5f..ce900e54d8d1 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -795,6 +795,7 @@ static int fs_enet_open(struct net_device *dev)
795 795
796 err = fs_init_phy(dev); 796 err = fs_init_phy(dev);
797 if (err) { 797 if (err) {
798 free_irq(fep->interrupt, dev);
798 if (fep->fpi->use_napi) 799 if (fep->fpi->use_napi)
799 napi_disable(&fep->napi); 800 napi_disable(&fep->napi);
800 return err; 801 return err;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 1b8deca8b9f8..ea530673236e 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -296,6 +296,20 @@ err_out:
296 return err; 296 return err;
297} 297}
298 298
299/* Ioctl MII Interface */
300static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
301{
302 struct gfar_private *priv = netdev_priv(dev);
303
304 if (!netif_running(dev))
305 return -EINVAL;
306
307 if (!priv->phydev)
308 return -ENODEV;
309
310 return phy_mii_ioctl(priv->phydev, if_mii(rq), cmd);
311}
312
299/* Set up the ethernet device structure, private data, 313/* Set up the ethernet device structure, private data,
300 * and anything else we need before we start */ 314 * and anything else we need before we start */
301static int gfar_probe(struct of_device *ofdev, 315static int gfar_probe(struct of_device *ofdev,
@@ -366,6 +380,7 @@ static int gfar_probe(struct of_device *ofdev,
366 dev->set_multicast_list = gfar_set_multi; 380 dev->set_multicast_list = gfar_set_multi;
367 381
368 dev->ethtool_ops = &gfar_ethtool_ops; 382 dev->ethtool_ops = &gfar_ethtool_ops;
383 dev->do_ioctl = gfar_ioctl;
369 384
370 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { 385 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
371 priv->rx_csum_enable = 1; 386 priv->rx_csum_enable = 1;
@@ -1607,10 +1622,18 @@ static int gfar_clean_tx_ring(struct net_device *dev)
1607static void gfar_schedule_cleanup(struct net_device *dev) 1622static void gfar_schedule_cleanup(struct net_device *dev)
1608{ 1623{
1609 struct gfar_private *priv = netdev_priv(dev); 1624 struct gfar_private *priv = netdev_priv(dev);
1625 unsigned long flags;
1626
1627 spin_lock_irqsave(&priv->txlock, flags);
1628 spin_lock(&priv->rxlock);
1629
1610 if (netif_rx_schedule_prep(&priv->napi)) { 1630 if (netif_rx_schedule_prep(&priv->napi)) {
1611 gfar_write(&priv->regs->imask, IMASK_RTX_DISABLED); 1631 gfar_write(&priv->regs->imask, IMASK_RTX_DISABLED);
1612 __netif_rx_schedule(&priv->napi); 1632 __netif_rx_schedule(&priv->napi);
1613 } 1633 }
1634
1635 spin_unlock(&priv->rxlock);
1636 spin_unlock_irqrestore(&priv->txlock, flags);
1614} 1637}
1615 1638
1616/* Interrupt Handler for Transmit complete */ 1639/* Interrupt Handler for Transmit complete */
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 32200227c923..7e8b3c59a7d6 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -576,6 +576,7 @@ static const struct net_device_ops hamachi_netdev_ops = {
576 .ndo_set_multicast_list = set_rx_mode, 576 .ndo_set_multicast_list = set_rx_mode,
577 .ndo_change_mtu = eth_change_mtu, 577 .ndo_change_mtu = eth_change_mtu,
578 .ndo_validate_addr = eth_validate_addr, 578 .ndo_validate_addr = eth_validate_addr,
579 .ndo_set_mac_address = eth_mac_addr,
579 .ndo_tx_timeout = hamachi_tx_timeout, 580 .ndo_tx_timeout = hamachi_tx_timeout,
580 .ndo_do_ioctl = netdev_ioctl, 581 .ndo_do_ioctl = netdev_ioctl,
581}; 582};
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 50f1e172ee8f..2d4089894ec7 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -717,11 +717,12 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
717 unsigned int cmd, unsigned long arg) 717 unsigned int cmd, unsigned long arg)
718{ 718{
719 struct sixpack *sp = sp_get(tty); 719 struct sixpack *sp = sp_get(tty);
720 struct net_device *dev = sp->dev; 720 struct net_device *dev;
721 unsigned int tmp, err; 721 unsigned int tmp, err;
722 722
723 if (!sp) 723 if (!sp)
724 return -ENXIO; 724 return -ENXIO;
725 dev = sp->dev;
725 726
726 switch(cmd) { 727 switch(cmd) {
727 case SIOCGIFNAME: 728 case SIOCGIFNAME:
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index b507dbc16e62..5e070f446635 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -166,6 +166,7 @@ static const struct net_device_ops hpp_netdev_ops = {
166 .ndo_get_stats = eip_get_stats, 166 .ndo_get_stats = eip_get_stats,
167 .ndo_set_multicast_list = eip_set_multicast_list, 167 .ndo_set_multicast_list = eip_set_multicast_list,
168 .ndo_validate_addr = eth_validate_addr, 168 .ndo_validate_addr = eth_validate_addr,
169 .ndo_set_mac_address = eth_mac_addr,
169 .ndo_change_mtu = eth_change_mtu, 170 .ndo_change_mtu = eth_change_mtu,
170#ifdef CONFIG_NET_POLL_CONTROLLER 171#ifdef CONFIG_NET_POLL_CONTROLLER
171 .ndo_poll_controller = eip_poll, 172 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index 9cb38a8d4387..8ac0930c183c 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -103,6 +103,7 @@ static const struct net_device_ops hydra_netdev_ops = {
103 .ndo_get_stats = ei_get_stats, 103 .ndo_get_stats = ei_get_stats,
104 .ndo_set_multicast_list = ei_set_multicast_list, 104 .ndo_set_multicast_list = ei_set_multicast_list,
105 .ndo_validate_addr = eth_validate_addr, 105 .ndo_validate_addr = eth_validate_addr,
106 .ndo_set_mac_address = eth_mac_addr,
106 .ndo_change_mtu = eth_change_mtu, 107 .ndo_change_mtu = eth_change_mtu,
107#ifdef CONFIG_NET_POLL_CONTROLLER 108#ifdef CONFIG_NET_POLL_CONTROLLER
108 .ndo_poll_controller = ei_poll, 109 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c
index ecf9798987fa..2a2fc17b2878 100644
--- a/drivers/net/ibm_newemac/mal.c
+++ b/drivers/net/ibm_newemac/mal.c
@@ -613,7 +613,9 @@ static int __devinit mal_probe(struct of_device *ofdev,
613 INIT_LIST_HEAD(&mal->list); 613 INIT_LIST_HEAD(&mal->list);
614 spin_lock_init(&mal->lock); 614 spin_lock_init(&mal->lock);
615 615
616 netif_napi_add(NULL, &mal->napi, mal_poll, 616 init_dummy_netdev(&mal->dummy_dev);
617
618 netif_napi_add(&mal->dummy_dev, &mal->napi, mal_poll,
617 CONFIG_IBM_NEW_EMAC_POLL_WEIGHT); 619 CONFIG_IBM_NEW_EMAC_POLL_WEIGHT);
618 620
619 /* Load power-on reset defaults */ 621 /* Load power-on reset defaults */
diff --git a/drivers/net/ibm_newemac/mal.h b/drivers/net/ibm_newemac/mal.h
index 2f0a87360844..9ededfbf0726 100644
--- a/drivers/net/ibm_newemac/mal.h
+++ b/drivers/net/ibm_newemac/mal.h
@@ -214,6 +214,8 @@ struct mal_instance {
214 int index; 214 int index;
215 spinlock_t lock; 215 spinlock_t lock;
216 216
217 struct net_device dummy_dev;
218
217 unsigned int features; 219 unsigned int features;
218}; 220};
219 221
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index ca3bb9f7321b..dfa6348ac1dc 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -602,7 +602,7 @@ static int ibmveth_open(struct net_device *netdev)
602 602
603 if(lpar_rc != H_SUCCESS) { 603 if(lpar_rc != H_SUCCESS) {
604 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc); 604 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc);
605 ibmveth_error_printk("buffer TCE:0x%lx filter TCE:0x%lx rxq desc:0x%lx MAC:0x%lx\n", 605 ibmveth_error_printk("buffer TCE:0x%llx filter TCE:0x%llx rxq desc:0x%llx MAC:0x%llx\n",
606 adapter->buffer_list_dma, 606 adapter->buffer_list_dma,
607 adapter->filter_list_dma, 607 adapter->filter_list_dma,
608 rxq_desc.desc, 608 rxq_desc.desc,
@@ -1378,13 +1378,13 @@ static int ibmveth_show(struct seq_file *seq, void *v)
1378 seq_printf(seq, "Firmware MAC: %pM\n", firmware_mac); 1378 seq_printf(seq, "Firmware MAC: %pM\n", firmware_mac);
1379 1379
1380 seq_printf(seq, "\nAdapter Statistics:\n"); 1380 seq_printf(seq, "\nAdapter Statistics:\n");
1381 seq_printf(seq, " TX: vio_map_single failres: %ld\n", adapter->tx_map_failed); 1381 seq_printf(seq, " TX: vio_map_single failres: %lld\n", adapter->tx_map_failed);
1382 seq_printf(seq, " send failures: %ld\n", adapter->tx_send_failed); 1382 seq_printf(seq, " send failures: %lld\n", adapter->tx_send_failed);
1383 seq_printf(seq, " RX: replenish task cycles: %ld\n", adapter->replenish_task_cycles); 1383 seq_printf(seq, " RX: replenish task cycles: %lld\n", adapter->replenish_task_cycles);
1384 seq_printf(seq, " alloc_skb_failures: %ld\n", adapter->replenish_no_mem); 1384 seq_printf(seq, " alloc_skb_failures: %lld\n", adapter->replenish_no_mem);
1385 seq_printf(seq, " add buffer failures: %ld\n", adapter->replenish_add_buff_failure); 1385 seq_printf(seq, " add buffer failures: %lld\n", adapter->replenish_add_buff_failure);
1386 seq_printf(seq, " invalid buffers: %ld\n", adapter->rx_invalid_buffer); 1386 seq_printf(seq, " invalid buffers: %lld\n", adapter->rx_invalid_buffer);
1387 seq_printf(seq, " no buffers: %ld\n", adapter->rx_no_buffer); 1387 seq_printf(seq, " no buffers: %lld\n", adapter->rx_no_buffer);
1388 1388
1389 return 0; 1389 return 0;
1390} 1390}
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index 75a1d0a86dee..941164076a2b 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -594,7 +594,7 @@ static int au1k_irda_rx(struct net_device *dev)
594 update_rx_stats(dev, flags, count); 594 update_rx_stats(dev, flags, count);
595 skb=alloc_skb(count+1,GFP_ATOMIC); 595 skb=alloc_skb(count+1,GFP_ATOMIC);
596 if (skb == NULL) { 596 if (skb == NULL) {
597 aup->stats.rx_dropped++; 597 aup->netdev->stats.rx_dropped++;
598 continue; 598 continue;
599 } 599 }
600 skb_reserve(skb, 1); 600 skb_reserve(skb, 1);
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 687c2d53d4d2..6f3e7f71658d 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -1194,13 +1194,13 @@ toshoboe_interrupt (int irq, void *dev_id)
1194 txp = txpc; 1194 txp = txpc;
1195 txpc++; 1195 txpc++;
1196 txpc %= TX_SLOTS; 1196 txpc %= TX_SLOTS;
1197 self->stats.tx_packets++; 1197 self->netdev->stats.tx_packets++;
1198 if (self->ring->tx[txpc].control & OBOE_CTL_TX_HW_OWNS) 1198 if (self->ring->tx[txpc].control & OBOE_CTL_TX_HW_OWNS)
1199 self->ring->tx[txp].control &= ~OBOE_CTL_TX_RTCENTX; 1199 self->ring->tx[txp].control &= ~OBOE_CTL_TX_RTCENTX;
1200 } 1200 }
1201 self->stats.tx_packets--; 1201 self->netdev->stats.tx_packets--;
1202#else 1202#else
1203 self->stats.tx_packets++; 1203 self->netdev->stats.tx_packets++;
1204#endif 1204#endif
1205 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX); 1205 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX);
1206 } 1206 }
@@ -1280,7 +1280,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1280 skb_put (skb, len); 1280 skb_put (skb, len);
1281 skb_copy_to_linear_data(skb, self->rx_bufs[self->rxs], 1281 skb_copy_to_linear_data(skb, self->rx_bufs[self->rxs],
1282 len); 1282 len);
1283 self->stats.rx_packets++; 1283 self->netdev->stats.rx_packets++;
1284 skb->dev = self->netdev; 1284 skb->dev = self->netdev;
1285 skb_reset_mac_header(skb); 1285 skb_reset_mac_header(skb);
1286 skb->protocol = htons (ETH_P_IRDA); 1286 skb->protocol = htons (ETH_P_IRDA);
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 29118f58a141..3a22dc41b656 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1073,7 +1073,7 @@ static int stir421x_patch_device(struct irda_usb_cb *self)
1073{ 1073{
1074 unsigned int i; 1074 unsigned int i;
1075 int ret; 1075 int ret;
1076 char stir421x_fw_name[11]; 1076 char stir421x_fw_name[12];
1077 const struct firmware *fw; 1077 const struct firmware *fw;
1078 const unsigned char *fw_version_ptr; /* pointer to version string */ 1078 const unsigned char *fw_version_ptr; /* pointer to version string */
1079 unsigned long fw_version = 0; 1079 unsigned long fw_version = 0;
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index c7457f97259d..cb793c2bade2 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -429,7 +429,7 @@ SIMPLE_PORT_ATTR(promiscuous);
429SIMPLE_PORT_ATTR(num_mcast); 429SIMPLE_PORT_ATTR(num_mcast);
430CUSTOM_PORT_ATTR(lpar_map, "0x%X\n", port->lpar_map); 430CUSTOM_PORT_ATTR(lpar_map, "0x%X\n", port->lpar_map);
431CUSTOM_PORT_ATTR(stopped_map, "0x%X\n", port->stopped_map); 431CUSTOM_PORT_ATTR(stopped_map, "0x%X\n", port->stopped_map);
432CUSTOM_PORT_ATTR(mac_addr, "0x%lX\n", port->mac_addr); 432CUSTOM_PORT_ATTR(mac_addr, "0x%llX\n", port->mac_addr);
433 433
434#define GET_PORT_ATTR(_name) (&veth_port_attr_##_name.attr) 434#define GET_PORT_ATTR(_name) (&veth_port_attr_##_name.attr)
435static struct attribute *veth_port_default_attrs[] = { 435static struct attribute *veth_port_default_attrs[] = {
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index 4a5580c1126a..1d6e48e13366 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -84,7 +84,10 @@
84#define KORINA_NUM_RDS 64 /* number of receive descriptors */ 84#define KORINA_NUM_RDS 64 /* number of receive descriptors */
85#define KORINA_NUM_TDS 64 /* number of transmit descriptors */ 85#define KORINA_NUM_TDS 64 /* number of transmit descriptors */
86 86
87#define KORINA_RBSIZE 536 /* size of one resource buffer = Ether MTU */ 87/* KORINA_RBSIZE is the hardware's default maximum receive
88 * frame size in bytes. Having this hardcoded means that there
89 * is no support for MTU sizes greater than 1500. */
90#define KORINA_RBSIZE 1536 /* size of one resource buffer = Ether MTU */
88#define KORINA_RDS_MASK (KORINA_NUM_RDS - 1) 91#define KORINA_RDS_MASK (KORINA_NUM_RDS - 1)
89#define KORINA_TDS_MASK (KORINA_NUM_TDS - 1) 92#define KORINA_TDS_MASK (KORINA_NUM_TDS - 1)
90#define RD_RING_SIZE (KORINA_NUM_RDS * sizeof(struct dma_desc)) 93#define RD_RING_SIZE (KORINA_NUM_RDS * sizeof(struct dma_desc))
@@ -196,7 +199,7 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
196 struct korina_private *lp = netdev_priv(dev); 199 struct korina_private *lp = netdev_priv(dev);
197 unsigned long flags; 200 unsigned long flags;
198 u32 length; 201 u32 length;
199 u32 chain_index; 202 u32 chain_prev, chain_next;
200 struct dma_desc *td; 203 struct dma_desc *td;
201 204
202 spin_lock_irqsave(&lp->lock, flags); 205 spin_lock_irqsave(&lp->lock, flags);
@@ -228,8 +231,8 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
228 /* Setup the transmit descriptor. */ 231 /* Setup the transmit descriptor. */
229 dma_cache_inv((u32) td, sizeof(*td)); 232 dma_cache_inv((u32) td, sizeof(*td));
230 td->ca = CPHYSADDR(skb->data); 233 td->ca = CPHYSADDR(skb->data);
231 chain_index = (lp->tx_chain_tail - 1) & 234 chain_prev = (lp->tx_chain_tail - 1) & KORINA_TDS_MASK;
232 KORINA_TDS_MASK; 235 chain_next = (lp->tx_chain_tail + 1) & KORINA_TDS_MASK;
233 236
234 if (readl(&(lp->tx_dma_regs->dmandptr)) == 0) { 237 if (readl(&(lp->tx_dma_regs->dmandptr)) == 0) {
235 if (lp->tx_chain_status == desc_empty) { 238 if (lp->tx_chain_status == desc_empty) {
@@ -237,7 +240,7 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
237 td->control = DMA_COUNT(length) | 240 td->control = DMA_COUNT(length) |
238 DMA_DESC_COF | DMA_DESC_IOF; 241 DMA_DESC_COF | DMA_DESC_IOF;
239 /* Move tail */ 242 /* Move tail */
240 lp->tx_chain_tail = chain_index; 243 lp->tx_chain_tail = chain_next;
241 /* Write to NDPTR */ 244 /* Write to NDPTR */
242 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), 245 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]),
243 &lp->tx_dma_regs->dmandptr); 246 &lp->tx_dma_regs->dmandptr);
@@ -248,12 +251,12 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
248 td->control = DMA_COUNT(length) | 251 td->control = DMA_COUNT(length) |
249 DMA_DESC_COF | DMA_DESC_IOF; 252 DMA_DESC_COF | DMA_DESC_IOF;
250 /* Link to prev */ 253 /* Link to prev */
251 lp->td_ring[chain_index].control &= 254 lp->td_ring[chain_prev].control &=
252 ~DMA_DESC_COF; 255 ~DMA_DESC_COF;
253 /* Link to prev */ 256 /* Link to prev */
254 lp->td_ring[chain_index].link = CPHYSADDR(td); 257 lp->td_ring[chain_prev].link = CPHYSADDR(td);
255 /* Move tail */ 258 /* Move tail */
256 lp->tx_chain_tail = chain_index; 259 lp->tx_chain_tail = chain_next;
257 /* Write to NDPTR */ 260 /* Write to NDPTR */
258 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), 261 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]),
259 &(lp->tx_dma_regs->dmandptr)); 262 &(lp->tx_dma_regs->dmandptr));
@@ -267,17 +270,16 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
267 td->control = DMA_COUNT(length) | 270 td->control = DMA_COUNT(length) |
268 DMA_DESC_COF | DMA_DESC_IOF; 271 DMA_DESC_COF | DMA_DESC_IOF;
269 /* Move tail */ 272 /* Move tail */
270 lp->tx_chain_tail = chain_index; 273 lp->tx_chain_tail = chain_next;
271 lp->tx_chain_status = desc_filled; 274 lp->tx_chain_status = desc_filled;
272 netif_stop_queue(dev);
273 } else { 275 } else {
274 /* Update tail */ 276 /* Update tail */
275 td->control = DMA_COUNT(length) | 277 td->control = DMA_COUNT(length) |
276 DMA_DESC_COF | DMA_DESC_IOF; 278 DMA_DESC_COF | DMA_DESC_IOF;
277 lp->td_ring[chain_index].control &= 279 lp->td_ring[chain_prev].control &=
278 ~DMA_DESC_COF; 280 ~DMA_DESC_COF;
279 lp->td_ring[chain_index].link = CPHYSADDR(td); 281 lp->td_ring[chain_prev].link = CPHYSADDR(td);
280 lp->tx_chain_tail = chain_index; 282 lp->tx_chain_tail = chain_next;
281 } 283 }
282 } 284 }
283 dma_cache_wback((u32) td, sizeof(*td)); 285 dma_cache_wback((u32) td, sizeof(*td));
@@ -327,13 +329,13 @@ static irqreturn_t korina_rx_dma_interrupt(int irq, void *dev_id)
327 329
328 dmas = readl(&lp->rx_dma_regs->dmas); 330 dmas = readl(&lp->rx_dma_regs->dmas);
329 if (dmas & (DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR)) { 331 if (dmas & (DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR)) {
330 netif_rx_schedule_prep(&lp->napi);
331
332 dmasm = readl(&lp->rx_dma_regs->dmasm); 332 dmasm = readl(&lp->rx_dma_regs->dmasm);
333 writel(dmasm | (DMA_STAT_DONE | 333 writel(dmasm | (DMA_STAT_DONE |
334 DMA_STAT_HALT | DMA_STAT_ERR), 334 DMA_STAT_HALT | DMA_STAT_ERR),
335 &lp->rx_dma_regs->dmasm); 335 &lp->rx_dma_regs->dmasm);
336 336
337 netif_rx_schedule(&lp->napi);
338
337 if (dmas & DMA_STAT_ERR) 339 if (dmas & DMA_STAT_ERR)
338 printk(KERN_ERR DRV_NAME "%s: DMA error\n", dev->name); 340 printk(KERN_ERR DRV_NAME "%s: DMA error\n", dev->name);
339 341
@@ -350,15 +352,20 @@ static int korina_rx(struct net_device *dev, int limit)
350 struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done]; 352 struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done];
351 struct sk_buff *skb, *skb_new; 353 struct sk_buff *skb, *skb_new;
352 u8 *pkt_buf; 354 u8 *pkt_buf;
353 u32 devcs, pkt_len, dmas, rx_free_desc; 355 u32 devcs, pkt_len, dmas;
354 int count; 356 int count;
355 357
356 dma_cache_inv((u32)rd, sizeof(*rd)); 358 dma_cache_inv((u32)rd, sizeof(*rd));
357 359
358 for (count = 0; count < limit; count++) { 360 for (count = 0; count < limit; count++) {
361 skb = lp->rx_skb[lp->rx_next_done];
362 skb_new = NULL;
359 363
360 devcs = rd->devcs; 364 devcs = rd->devcs;
361 365
366 if ((KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) == 0)
367 break;
368
362 /* Update statistics counters */ 369 /* Update statistics counters */
363 if (devcs & ETH_RX_CRC) 370 if (devcs & ETH_RX_CRC)
364 dev->stats.rx_crc_errors++; 371 dev->stats.rx_crc_errors++;
@@ -381,63 +388,55 @@ static int korina_rx(struct net_device *dev, int limit)
381 * in Rc32434 (errata ref #077) */ 388 * in Rc32434 (errata ref #077) */
382 dev->stats.rx_errors++; 389 dev->stats.rx_errors++;
383 dev->stats.rx_dropped++; 390 dev->stats.rx_dropped++;
384 } 391 } else if ((devcs & ETH_RX_ROK)) {
385
386 while ((rx_free_desc = KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) != 0) {
387 /* init the var. used for the later
388 * operations within the while loop */
389 skb_new = NULL;
390 pkt_len = RCVPKT_LENGTH(devcs); 392 pkt_len = RCVPKT_LENGTH(devcs);
391 skb = lp->rx_skb[lp->rx_next_done]; 393
392 394 /* must be the (first and) last
393 if ((devcs & ETH_RX_ROK)) { 395 * descriptor then */
394 /* must be the (first and) last 396 pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
395 * descriptor then */ 397
396 pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data; 398 /* invalidate the cache */
397 399 dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4);
398 /* invalidate the cache */ 400
399 dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4); 401 /* Malloc up new buffer. */
400 402 skb_new = netdev_alloc_skb(dev, KORINA_RBSIZE + 2);
401 /* Malloc up new buffer. */ 403
402 skb_new = netdev_alloc_skb(dev, KORINA_RBSIZE + 2); 404 if (!skb_new)
403 405 break;
404 if (!skb_new) 406 /* Do not count the CRC */
405 break; 407 skb_put(skb, pkt_len - 4);
406 /* Do not count the CRC */ 408 skb->protocol = eth_type_trans(skb, dev);
407 skb_put(skb, pkt_len - 4); 409
408 skb->protocol = eth_type_trans(skb, dev); 410 /* Pass the packet to upper layers */
409 411 netif_receive_skb(skb);
410 /* Pass the packet to upper layers */ 412 dev->stats.rx_packets++;
411 netif_receive_skb(skb); 413 dev->stats.rx_bytes += pkt_len;
412 dev->stats.rx_packets++; 414
413 dev->stats.rx_bytes += pkt_len; 415 /* Update the mcast stats */
414 416 if (devcs & ETH_RX_MP)
415 /* Update the mcast stats */ 417 dev->stats.multicast++;
416 if (devcs & ETH_RX_MP) 418
417 dev->stats.multicast++; 419 lp->rx_skb[lp->rx_next_done] = skb_new;
418
419 lp->rx_skb[lp->rx_next_done] = skb_new;
420 }
421
422 rd->devcs = 0;
423
424 /* Restore descriptor's curr_addr */
425 if (skb_new)
426 rd->ca = CPHYSADDR(skb_new->data);
427 else
428 rd->ca = CPHYSADDR(skb->data);
429
430 rd->control = DMA_COUNT(KORINA_RBSIZE) |
431 DMA_DESC_COD | DMA_DESC_IOD;
432 lp->rd_ring[(lp->rx_next_done - 1) &
433 KORINA_RDS_MASK].control &=
434 ~DMA_DESC_COD;
435
436 lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
437 dma_cache_wback((u32)rd, sizeof(*rd));
438 rd = &lp->rd_ring[lp->rx_next_done];
439 writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
440 } 420 }
421
422 rd->devcs = 0;
423
424 /* Restore descriptor's curr_addr */
425 if (skb_new)
426 rd->ca = CPHYSADDR(skb_new->data);
427 else
428 rd->ca = CPHYSADDR(skb->data);
429
430 rd->control = DMA_COUNT(KORINA_RBSIZE) |
431 DMA_DESC_COD | DMA_DESC_IOD;
432 lp->rd_ring[(lp->rx_next_done - 1) &
433 KORINA_RDS_MASK].control &=
434 ~DMA_DESC_COD;
435
436 lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
437 dma_cache_wback((u32)rd, sizeof(*rd));
438 rd = &lp->rd_ring[lp->rx_next_done];
439 writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
441 } 440 }
442 441
443 dmas = readl(&lp->rx_dma_regs->dmas); 442 dmas = readl(&lp->rx_dma_regs->dmas);
@@ -623,12 +622,12 @@ korina_tx_dma_interrupt(int irq, void *dev_id)
623 dmas = readl(&lp->tx_dma_regs->dmas); 622 dmas = readl(&lp->tx_dma_regs->dmas);
624 623
625 if (dmas & (DMA_STAT_FINI | DMA_STAT_ERR)) { 624 if (dmas & (DMA_STAT_FINI | DMA_STAT_ERR)) {
626 korina_tx(dev);
627
628 dmasm = readl(&lp->tx_dma_regs->dmasm); 625 dmasm = readl(&lp->tx_dma_regs->dmasm);
629 writel(dmasm | (DMA_STAT_FINI | DMA_STAT_ERR), 626 writel(dmasm | (DMA_STAT_FINI | DMA_STAT_ERR),
630 &lp->tx_dma_regs->dmasm); 627 &lp->tx_dma_regs->dmasm);
631 628
629 korina_tx(dev);
630
632 if (lp->tx_chain_status == desc_filled && 631 if (lp->tx_chain_status == desc_filled &&
633 (readl(&(lp->tx_dma_regs->dmandptr)) == 0)) { 632 (readl(&(lp->tx_dma_regs->dmandptr)) == 0)) {
634 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), 633 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]),
@@ -901,6 +900,8 @@ static int korina_restart(struct net_device *dev)
901 900
902 korina_free_ring(dev); 901 korina_free_ring(dev);
903 902
903 napi_disable(&lp->napi);
904
904 ret = korina_init(dev); 905 ret = korina_init(dev);
905 if (ret < 0) { 906 if (ret < 0) {
906 printk(KERN_ERR DRV_NAME "%s: cannot restart device\n", 907 printk(KERN_ERR DRV_NAME "%s: cannot restart device\n",
@@ -999,14 +1000,14 @@ static int korina_open(struct net_device *dev)
999 * that handles the Done Finished 1000 * that handles the Done Finished
1000 * Ovr and Und Events */ 1001 * Ovr and Und Events */
1001 ret = request_irq(lp->rx_irq, &korina_rx_dma_interrupt, 1002 ret = request_irq(lp->rx_irq, &korina_rx_dma_interrupt,
1002 IRQF_SHARED | IRQF_DISABLED, "Korina ethernet Rx", dev); 1003 IRQF_DISABLED, "Korina ethernet Rx", dev);
1003 if (ret < 0) { 1004 if (ret < 0) {
1004 printk(KERN_ERR DRV_NAME "%s: unable to get Rx DMA IRQ %d\n", 1005 printk(KERN_ERR DRV_NAME "%s: unable to get Rx DMA IRQ %d\n",
1005 dev->name, lp->rx_irq); 1006 dev->name, lp->rx_irq);
1006 goto err_release; 1007 goto err_release;
1007 } 1008 }
1008 ret = request_irq(lp->tx_irq, &korina_tx_dma_interrupt, 1009 ret = request_irq(lp->tx_irq, &korina_tx_dma_interrupt,
1009 IRQF_SHARED | IRQF_DISABLED, "Korina ethernet Tx", dev); 1010 IRQF_DISABLED, "Korina ethernet Tx", dev);
1010 if (ret < 0) { 1011 if (ret < 0) {
1011 printk(KERN_ERR DRV_NAME "%s: unable to get Tx DMA IRQ %d\n", 1012 printk(KERN_ERR DRV_NAME "%s: unable to get Tx DMA IRQ %d\n",
1012 dev->name, lp->tx_irq); 1013 dev->name, lp->tx_irq);
@@ -1015,7 +1016,7 @@ static int korina_open(struct net_device *dev)
1015 1016
1016 /* Install handler for overrun error. */ 1017 /* Install handler for overrun error. */
1017 ret = request_irq(lp->ovr_irq, &korina_ovr_interrupt, 1018 ret = request_irq(lp->ovr_irq, &korina_ovr_interrupt,
1018 IRQF_SHARED | IRQF_DISABLED, "Ethernet Overflow", dev); 1019 IRQF_DISABLED, "Ethernet Overflow", dev);
1019 if (ret < 0) { 1020 if (ret < 0) {
1020 printk(KERN_ERR DRV_NAME"%s: unable to get OVR IRQ %d\n", 1021 printk(KERN_ERR DRV_NAME"%s: unable to get OVR IRQ %d\n",
1021 dev->name, lp->ovr_irq); 1022 dev->name, lp->ovr_irq);
@@ -1024,7 +1025,7 @@ static int korina_open(struct net_device *dev)
1024 1025
1025 /* Install handler for underflow error. */ 1026 /* Install handler for underflow error. */
1026 ret = request_irq(lp->und_irq, &korina_und_interrupt, 1027 ret = request_irq(lp->und_irq, &korina_und_interrupt,
1027 IRQF_SHARED | IRQF_DISABLED, "Ethernet Underflow", dev); 1028 IRQF_DISABLED, "Ethernet Underflow", dev);
1028 if (ret < 0) { 1029 if (ret < 0) {
1029 printk(KERN_ERR DRV_NAME "%s: unable to get UND IRQ %d\n", 1030 printk(KERN_ERR DRV_NAME "%s: unable to get UND IRQ %d\n",
1030 dev->name, lp->und_irq); 1031 dev->name, lp->und_irq);
@@ -1067,6 +1068,8 @@ static int korina_close(struct net_device *dev)
1067 1068
1068 korina_free_ring(dev); 1069 korina_free_ring(dev);
1069 1070
1071 napi_disable(&lp->napi);
1072
1070 free_irq(lp->rx_irq, dev); 1073 free_irq(lp->rx_irq, dev);
1071 free_irq(lp->tx_irq, dev); 1074 free_irq(lp->tx_irq, dev);
1072 free_irq(lp->ovr_irq, dev); 1075 free_irq(lp->ovr_irq, dev);
@@ -1089,7 +1092,6 @@ static int korina_probe(struct platform_device *pdev)
1089 return -ENOMEM; 1092 return -ENOMEM;
1090 } 1093 }
1091 SET_NETDEV_DEV(dev, &pdev->dev); 1094 SET_NETDEV_DEV(dev, &pdev->dev);
1092 platform_set_drvdata(pdev, dev);
1093 lp = netdev_priv(dev); 1095 lp = netdev_priv(dev);
1094 1096
1095 bif->dev = dev; 1097 bif->dev = dev;
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index 57716e22660c..8e884869a05b 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -486,6 +486,7 @@ static const struct net_device_ops mac8390_netdev_ops = {
486 .ndo_get_stats = ei_get_stats, 486 .ndo_get_stats = ei_get_stats,
487 .ndo_set_multicast_list = ei_set_multicast_list, 487 .ndo_set_multicast_list = ei_set_multicast_list,
488 .ndo_validate_addr = eth_validate_addr, 488 .ndo_validate_addr = eth_validate_addr,
489 .ndo_set_mac_address = eth_mac_addr,
489 .ndo_change_mtu = eth_change_mtu, 490 .ndo_change_mtu = eth_change_mtu,
490#ifdef CONFIG_NET_POLL_CONTROLLER 491#ifdef CONFIG_NET_POLL_CONTROLLER
491 .ndo_poll_controller = ei_poll, 492 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 15bb38d99304..9f6644a44030 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -952,6 +952,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
952 .ndo_get_stats = mlx4_en_get_stats, 952 .ndo_get_stats = mlx4_en_get_stats,
953 .ndo_set_multicast_list = mlx4_en_set_multicast, 953 .ndo_set_multicast_list = mlx4_en_set_multicast,
954 .ndo_set_mac_address = mlx4_en_set_mac, 954 .ndo_set_mac_address = mlx4_en_set_mac,
955 .ndo_validate_addr = eth_validate_addr,
955 .ndo_change_mtu = mlx4_en_change_mtu, 956 .ndo_change_mtu = mlx4_en_change_mtu,
956 .ndo_tx_timeout = mlx4_en_tx_timeout, 957 .ndo_tx_timeout = mlx4_en_tx_timeout,
957 .ndo_vlan_rx_register = mlx4_en_vlan_rx_register, 958 .ndo_vlan_rx_register = mlx4_en_vlan_rx_register,
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index 710c79e7a2db..6ef2490d5c3e 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -912,8 +912,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
912 int i; 912 int i;
913 913
914 if (msi_x) { 914 if (msi_x) {
915 nreq = min(dev->caps.num_eqs - dev->caps.reserved_eqs, 915 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
916 num_possible_cpus() + 1); 916 num_possible_cpus() + 1);
917 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); 917 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
918 if (!entries) 918 if (!entries)
919 goto no_msi; 919 goto no_msi;
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index b57239171046..7bd6662d5b04 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -202,6 +202,7 @@ static const struct net_device_ops ne_netdev_ops = {
202 .ndo_get_stats = ei_get_stats, 202 .ndo_get_stats = ei_get_stats,
203 .ndo_set_multicast_list = ei_set_multicast_list, 203 .ndo_set_multicast_list = ei_set_multicast_list,
204 .ndo_validate_addr = eth_validate_addr, 204 .ndo_validate_addr = eth_validate_addr,
205 .ndo_set_mac_address = eth_mac_addr,
205 .ndo_change_mtu = eth_change_mtu, 206 .ndo_change_mtu = eth_change_mtu,
206#ifdef CONFIG_NET_POLL_CONTROLLER 207#ifdef CONFIG_NET_POLL_CONTROLLER
207 .ndo_poll_controller = ei_poll, 208 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index 62f20ba211cb..f090d3b9ec94 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -208,6 +208,7 @@ static const struct net_device_ops ne2k_netdev_ops = {
208 .ndo_get_stats = ei_get_stats, 208 .ndo_get_stats = ei_get_stats,
209 .ndo_set_multicast_list = ei_set_multicast_list, 209 .ndo_set_multicast_list = ei_set_multicast_list,
210 .ndo_validate_addr = eth_validate_addr, 210 .ndo_validate_addr = eth_validate_addr,
211 .ndo_set_mac_address = eth_mac_addr,
211 .ndo_change_mtu = eth_change_mtu, 212 .ndo_change_mtu = eth_change_mtu,
212#ifdef CONFIG_NET_POLL_CONTROLLER 213#ifdef CONFIG_NET_POLL_CONTROLLER
213 .ndo_poll_controller = ei_poll, 214 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index f8e601c51da7..c11c568fd7db 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -308,27 +308,16 @@ struct netxen_ring_ctx {
308#define netxen_set_cmd_desc_ctxid(cmd_desc, var) \ 308#define netxen_set_cmd_desc_ctxid(cmd_desc, var) \
309 ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0)) 309 ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0))
310 310
311#define netxen_set_cmd_desc_flags(cmd_desc, val) \ 311#define netxen_set_tx_port(_desc, _port) \
312 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \ 312 (_desc)->port_ctxid = ((_port) & 0xf) | (((_port) << 4) & 0xf0)
313 ~cpu_to_le16(0x7f)) | cpu_to_le16((val) & 0x7f) 313
314#define netxen_set_cmd_desc_opcode(cmd_desc, val) \ 314#define netxen_set_tx_flags_opcode(_desc, _flags, _opcode) \
315 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \ 315 (_desc)->flags_opcode = \
316 ~cpu_to_le16((u16)0x3f << 7)) | cpu_to_le16(((val) & 0x3f) << 7) 316 cpu_to_le16(((_flags) & 0x7f) | (((_opcode) & 0x3f) << 7))
317 317
318#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ 318#define netxen_set_tx_frags_len(_desc, _frags, _len) \
319 (cmd_desc)->num_of_buffers_total_length = \ 319 (_desc)->num_of_buffers_total_length = \
320 ((cmd_desc)->num_of_buffers_total_length & \ 320 cpu_to_le32(((_frags) & 0xff) | (((_len) & 0xffffff) << 8))
321 ~cpu_to_le32(0xff)) | cpu_to_le32((val) & 0xff)
322#define netxen_set_cmd_desc_totallength(cmd_desc, val) \
323 (cmd_desc)->num_of_buffers_total_length = \
324 ((cmd_desc)->num_of_buffers_total_length & \
325 ~cpu_to_le32((u32)0xffffff << 8)) | \
326 cpu_to_le32(((val) & 0xffffff) << 8)
327
328#define netxen_get_cmd_desc_opcode(cmd_desc) \
329 ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003f)
330#define netxen_get_cmd_desc_totallength(cmd_desc) \
331 ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 0xffffff)
332 321
333struct cmd_desc_type0 { 322struct cmd_desc_type0 {
334 u8 tcp_hdr_offset; /* For LSO only */ 323 u8 tcp_hdr_offset; /* For LSO only */
@@ -510,7 +499,8 @@ typedef enum {
510 NETXEN_BRDTYPE_P3_10G_SFP_CT = 0x002a, 499 NETXEN_BRDTYPE_P3_10G_SFP_CT = 0x002a,
511 NETXEN_BRDTYPE_P3_10G_SFP_QT = 0x002b, 500 NETXEN_BRDTYPE_P3_10G_SFP_QT = 0x002b,
512 NETXEN_BRDTYPE_P3_10G_CX4 = 0x0031, 501 NETXEN_BRDTYPE_P3_10G_CX4 = 0x0031,
513 NETXEN_BRDTYPE_P3_10G_XFP = 0x0032 502 NETXEN_BRDTYPE_P3_10G_XFP = 0x0032,
503 NETXEN_BRDTYPE_P3_10G_TP = 0x0080
514 504
515} netxen_brdtype_t; 505} netxen_brdtype_t;
516 506
@@ -757,7 +747,7 @@ extern char netxen_nic_driver_name[];
757 */ 747 */
758struct netxen_skb_frag { 748struct netxen_skb_frag {
759 u64 dma; 749 u64 dma;
760 u32 length; 750 ulong length;
761}; 751};
762 752
763#define _netxen_set_bits(config_word, start, bits, val) {\ 753#define _netxen_set_bits(config_word, start, bits, val) {\
@@ -783,13 +773,7 @@ struct netxen_skb_frag {
783struct netxen_cmd_buffer { 773struct netxen_cmd_buffer {
784 struct sk_buff *skb; 774 struct sk_buff *skb;
785 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1]; 775 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
786 u32 total_length; 776 u32 frag_count;
787 u32 mss;
788 u16 port;
789 u8 cmd;
790 u8 frag_count;
791 unsigned long time_stamp;
792 u32 state;
793}; 777};
794 778
795/* In rx_buffer, we do not need multiple fragments as is a single buffer */ 779/* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -876,7 +860,6 @@ struct nx_host_rds_ring {
876 u32 skb_size; 860 u32 skb_size;
877 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */ 861 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */
878 struct list_head free_list; 862 struct list_head free_list;
879 int begin_alloc;
880}; 863};
881 864
882/* 865/*
@@ -995,31 +978,31 @@ struct netxen_recv_context {
995 */ 978 */
996 979
997typedef struct { 980typedef struct {
998 u64 host_phys_addr; /* Ring base addr */ 981 __le64 host_phys_addr; /* Ring base addr */
999 u32 ring_size; /* Ring entries */ 982 __le32 ring_size; /* Ring entries */
1000 u16 msi_index; 983 __le16 msi_index;
1001 u16 rsvd; /* Padding */ 984 __le16 rsvd; /* Padding */
1002} nx_hostrq_sds_ring_t; 985} nx_hostrq_sds_ring_t;
1003 986
1004typedef struct { 987typedef struct {
1005 u64 host_phys_addr; /* Ring base addr */ 988 __le64 host_phys_addr; /* Ring base addr */
1006 u64 buff_size; /* Packet buffer size */ 989 __le64 buff_size; /* Packet buffer size */
1007 u32 ring_size; /* Ring entries */ 990 __le32 ring_size; /* Ring entries */
1008 u32 ring_kind; /* Class of ring */ 991 __le32 ring_kind; /* Class of ring */
1009} nx_hostrq_rds_ring_t; 992} nx_hostrq_rds_ring_t;
1010 993
1011typedef struct { 994typedef struct {
1012 u64 host_rsp_dma_addr; /* Response dma'd here */ 995 __le64 host_rsp_dma_addr; /* Response dma'd here */
1013 u32 capabilities[4]; /* Flag bit vector */ 996 __le32 capabilities[4]; /* Flag bit vector */
1014 u32 host_int_crb_mode; /* Interrupt crb usage */ 997 __le32 host_int_crb_mode; /* Interrupt crb usage */
1015 u32 host_rds_crb_mode; /* RDS crb usage */ 998 __le32 host_rds_crb_mode; /* RDS crb usage */
1016 /* These ring offsets are relative to data[0] below */ 999 /* These ring offsets are relative to data[0] below */
1017 u32 rds_ring_offset; /* Offset to RDS config */ 1000 __le32 rds_ring_offset; /* Offset to RDS config */
1018 u32 sds_ring_offset; /* Offset to SDS config */ 1001 __le32 sds_ring_offset; /* Offset to SDS config */
1019 u16 num_rds_rings; /* Count of RDS rings */ 1002 __le16 num_rds_rings; /* Count of RDS rings */
1020 u16 num_sds_rings; /* Count of SDS rings */ 1003 __le16 num_sds_rings; /* Count of SDS rings */
1021 u16 rsvd1; /* Padding */ 1004 __le16 rsvd1; /* Padding */
1022 u16 rsvd2; /* Padding */ 1005 __le16 rsvd2; /* Padding */
1023 u8 reserved[128]; /* reserve space for future expansion*/ 1006 u8 reserved[128]; /* reserve space for future expansion*/
1024 /* MUST BE 64-bit aligned. 1007 /* MUST BE 64-bit aligned.
1025 The following is packed: 1008 The following is packed:
@@ -1029,24 +1012,24 @@ typedef struct {
1029} nx_hostrq_rx_ctx_t; 1012} nx_hostrq_rx_ctx_t;
1030 1013
1031typedef struct { 1014typedef struct {
1032 u32 host_producer_crb; /* Crb to use */ 1015 __le32 host_producer_crb; /* Crb to use */
1033 u32 rsvd1; /* Padding */ 1016 __le32 rsvd1; /* Padding */
1034} nx_cardrsp_rds_ring_t; 1017} nx_cardrsp_rds_ring_t;
1035 1018
1036typedef struct { 1019typedef struct {
1037 u32 host_consumer_crb; /* Crb to use */ 1020 __le32 host_consumer_crb; /* Crb to use */
1038 u32 interrupt_crb; /* Crb to use */ 1021 __le32 interrupt_crb; /* Crb to use */
1039} nx_cardrsp_sds_ring_t; 1022} nx_cardrsp_sds_ring_t;
1040 1023
1041typedef struct { 1024typedef struct {
1042 /* These ring offsets are relative to data[0] below */ 1025 /* These ring offsets are relative to data[0] below */
1043 u32 rds_ring_offset; /* Offset to RDS config */ 1026 __le32 rds_ring_offset; /* Offset to RDS config */
1044 u32 sds_ring_offset; /* Offset to SDS config */ 1027 __le32 sds_ring_offset; /* Offset to SDS config */
1045 u32 host_ctx_state; /* Starting State */ 1028 __le32 host_ctx_state; /* Starting State */
1046 u32 num_fn_per_port; /* How many PCI fn share the port */ 1029 __le32 num_fn_per_port; /* How many PCI fn share the port */
1047 u16 num_rds_rings; /* Count of RDS rings */ 1030 __le16 num_rds_rings; /* Count of RDS rings */
1048 u16 num_sds_rings; /* Count of SDS rings */ 1031 __le16 num_sds_rings; /* Count of SDS rings */
1049 u16 context_id; /* Handle for context */ 1032 __le16 context_id; /* Handle for context */
1050 u8 phys_port; /* Physical id of port */ 1033 u8 phys_port; /* Physical id of port */
1051 u8 virt_port; /* Virtual/Logical id of port */ 1034 u8 virt_port; /* Virtual/Logical id of port */
1052 u8 reserved[128]; /* save space for future expansion */ 1035 u8 reserved[128]; /* save space for future expansion */
@@ -1072,34 +1055,34 @@ typedef struct {
1072 */ 1055 */
1073 1056
1074typedef struct { 1057typedef struct {
1075 u64 host_phys_addr; /* Ring base addr */ 1058 __le64 host_phys_addr; /* Ring base addr */
1076 u32 ring_size; /* Ring entries */ 1059 __le32 ring_size; /* Ring entries */
1077 u32 rsvd; /* Padding */ 1060 __le32 rsvd; /* Padding */
1078} nx_hostrq_cds_ring_t; 1061} nx_hostrq_cds_ring_t;
1079 1062
1080typedef struct { 1063typedef struct {
1081 u64 host_rsp_dma_addr; /* Response dma'd here */ 1064 __le64 host_rsp_dma_addr; /* Response dma'd here */
1082 u64 cmd_cons_dma_addr; /* */ 1065 __le64 cmd_cons_dma_addr; /* */
1083 u64 dummy_dma_addr; /* */ 1066 __le64 dummy_dma_addr; /* */
1084 u32 capabilities[4]; /* Flag bit vector */ 1067 __le32 capabilities[4]; /* Flag bit vector */
1085 u32 host_int_crb_mode; /* Interrupt crb usage */ 1068 __le32 host_int_crb_mode; /* Interrupt crb usage */
1086 u32 rsvd1; /* Padding */ 1069 __le32 rsvd1; /* Padding */
1087 u16 rsvd2; /* Padding */ 1070 __le16 rsvd2; /* Padding */
1088 u16 interrupt_ctl; 1071 __le16 interrupt_ctl;
1089 u16 msi_index; 1072 __le16 msi_index;
1090 u16 rsvd3; /* Padding */ 1073 __le16 rsvd3; /* Padding */
1091 nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */ 1074 nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */
1092 u8 reserved[128]; /* future expansion */ 1075 u8 reserved[128]; /* future expansion */
1093} nx_hostrq_tx_ctx_t; 1076} nx_hostrq_tx_ctx_t;
1094 1077
1095typedef struct { 1078typedef struct {
1096 u32 host_producer_crb; /* Crb to use */ 1079 __le32 host_producer_crb; /* Crb to use */
1097 u32 interrupt_crb; /* Crb to use */ 1080 __le32 interrupt_crb; /* Crb to use */
1098} nx_cardrsp_cds_ring_t; 1081} nx_cardrsp_cds_ring_t;
1099 1082
1100typedef struct { 1083typedef struct {
1101 u32 host_ctx_state; /* Starting state */ 1084 __le32 host_ctx_state; /* Starting state */
1102 u16 context_id; /* Handle for context */ 1085 __le16 context_id; /* Handle for context */
1103 u8 phys_port; /* Physical id of port */ 1086 u8 phys_port; /* Physical id of port */
1104 u8 virt_port; /* Virtual/Logical id of port */ 1087 u8 virt_port; /* Virtual/Logical id of port */
1105 nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */ 1088 nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */
@@ -1202,9 +1185,9 @@ enum {
1202#define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */ 1185#define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */
1203 1186
1204typedef struct { 1187typedef struct {
1205 u64 qhdr; 1188 __le64 qhdr;
1206 u64 req_hdr; 1189 __le64 req_hdr;
1207 u64 words[6]; 1190 __le64 words[6];
1208} nx_nic_req_t; 1191} nx_nic_req_t;
1209 1192
1210typedef struct { 1193typedef struct {
@@ -1486,8 +1469,6 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter);
1486 1469
1487void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); 1470void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
1488int netxen_init_firmware(struct netxen_adapter *adapter); 1471int netxen_init_firmware(struct netxen_adapter *adapter);
1489void netxen_tso_check(struct netxen_adapter *adapter,
1490 struct cmd_desc_type0 *desc, struct sk_buff *skb);
1491void netxen_nic_clear_stats(struct netxen_adapter *adapter); 1472void netxen_nic_clear_stats(struct netxen_adapter *adapter);
1492void netxen_watchdog_task(struct work_struct *work); 1473void netxen_watchdog_task(struct work_struct *work);
1493void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, 1474void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
@@ -1496,6 +1477,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter);
1496u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); 1477u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
1497void netxen_p2_nic_set_multi(struct net_device *netdev); 1478void netxen_p2_nic_set_multi(struct net_device *netdev);
1498void netxen_p3_nic_set_multi(struct net_device *netdev); 1479void netxen_p3_nic_set_multi(struct net_device *netdev);
1480void netxen_p3_free_mac_list(struct netxen_adapter *adapter);
1499int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32); 1481int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32);
1500int netxen_config_intr_coalesce(struct netxen_adapter *adapter); 1482int netxen_config_intr_coalesce(struct netxen_adapter *adapter);
1501 1483
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index 64b51643c626..746bdb470418 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -76,7 +76,7 @@ netxen_api_unlock(struct netxen_adapter *adapter)
76static u32 76static u32
77netxen_poll_rsp(struct netxen_adapter *adapter) 77netxen_poll_rsp(struct netxen_adapter *adapter)
78{ 78{
79 u32 raw_rsp, rsp = NX_CDRP_RSP_OK; 79 u32 rsp = NX_CDRP_RSP_OK;
80 int timeout = 0; 80 int timeout = 0;
81 81
82 do { 82 do {
@@ -86,10 +86,7 @@ netxen_poll_rsp(struct netxen_adapter *adapter)
86 if (++timeout > NX_OS_CRB_RETRY_COUNT) 86 if (++timeout > NX_OS_CRB_RETRY_COUNT)
87 return NX_CDRP_RSP_TIMEOUT; 87 return NX_CDRP_RSP_TIMEOUT;
88 88
89 netxen_nic_read_w1(adapter, NX_CDRP_CRB_OFFSET, 89 netxen_nic_read_w1(adapter, NX_CDRP_CRB_OFFSET, &rsp);
90 &raw_rsp);
91
92 rsp = le32_to_cpu(raw_rsp);
93 } while (!NX_CDRP_IS_RSP(rsp)); 90 } while (!NX_CDRP_IS_RSP(rsp));
94 91
95 return rsp; 92 return rsp;
@@ -109,20 +106,16 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
109 if (netxen_api_lock(adapter)) 106 if (netxen_api_lock(adapter))
110 return NX_RCODE_TIMEOUT; 107 return NX_RCODE_TIMEOUT;
111 108
112 netxen_nic_write_w1(adapter, NX_SIGN_CRB_OFFSET, 109 netxen_nic_write_w1(adapter, NX_SIGN_CRB_OFFSET, signature);
113 cpu_to_le32(signature));
114 110
115 netxen_nic_write_w1(adapter, NX_ARG1_CRB_OFFSET, 111 netxen_nic_write_w1(adapter, NX_ARG1_CRB_OFFSET, arg1);
116 cpu_to_le32(arg1));
117 112
118 netxen_nic_write_w1(adapter, NX_ARG2_CRB_OFFSET, 113 netxen_nic_write_w1(adapter, NX_ARG2_CRB_OFFSET, arg2);
119 cpu_to_le32(arg2));
120 114
121 netxen_nic_write_w1(adapter, NX_ARG3_CRB_OFFSET, 115 netxen_nic_write_w1(adapter, NX_ARG3_CRB_OFFSET, arg3);
122 cpu_to_le32(arg3));
123 116
124 netxen_nic_write_w1(adapter, NX_CDRP_CRB_OFFSET, 117 netxen_nic_write_w1(adapter, NX_CDRP_CRB_OFFSET,
125 cpu_to_le32(NX_CDRP_FORM_CMD(cmd))); 118 NX_CDRP_FORM_CMD(cmd));
126 119
127 rsp = netxen_poll_rsp(adapter); 120 rsp = netxen_poll_rsp(adapter);
128 121
@@ -133,7 +126,6 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
133 rcode = NX_RCODE_TIMEOUT; 126 rcode = NX_RCODE_TIMEOUT;
134 } else if (rsp == NX_CDRP_RSP_FAIL) { 127 } else if (rsp == NX_CDRP_RSP_FAIL) {
135 netxen_nic_read_w1(adapter, NX_ARG1_CRB_OFFSET, &rcode); 128 netxen_nic_read_w1(adapter, NX_ARG1_CRB_OFFSET, &rcode);
136 rcode = le32_to_cpu(rcode);
137 129
138 printk(KERN_ERR "%s: failed card response code:0x%x\n", 130 printk(KERN_ERR "%s: failed card response code:0x%x\n",
139 netxen_nic_driver_name, rcode); 131 netxen_nic_driver_name, rcode);
@@ -183,7 +175,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
183 175
184 int i, nrds_rings, nsds_rings; 176 int i, nrds_rings, nsds_rings;
185 size_t rq_size, rsp_size; 177 size_t rq_size, rsp_size;
186 u32 cap, reg; 178 u32 cap, reg, val;
187 179
188 int err; 180 int err;
189 181
@@ -225,11 +217,14 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
225 217
226 prq->num_rds_rings = cpu_to_le16(nrds_rings); 218 prq->num_rds_rings = cpu_to_le16(nrds_rings);
227 prq->num_sds_rings = cpu_to_le16(nsds_rings); 219 prq->num_sds_rings = cpu_to_le16(nsds_rings);
228 prq->rds_ring_offset = 0; 220 prq->rds_ring_offset = cpu_to_le32(0);
229 prq->sds_ring_offset = prq->rds_ring_offset + 221
222 val = le32_to_cpu(prq->rds_ring_offset) +
230 (sizeof(nx_hostrq_rds_ring_t) * nrds_rings); 223 (sizeof(nx_hostrq_rds_ring_t) * nrds_rings);
224 prq->sds_ring_offset = cpu_to_le32(val);
231 225
232 prq_rds = (nx_hostrq_rds_ring_t *)(prq->data + prq->rds_ring_offset); 226 prq_rds = (nx_hostrq_rds_ring_t *)(prq->data +
227 le32_to_cpu(prq->rds_ring_offset));
233 228
234 for (i = 0; i < nrds_rings; i++) { 229 for (i = 0; i < nrds_rings; i++) {
235 230
@@ -241,17 +236,14 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
241 prq_rds[i].buff_size = cpu_to_le64(rds_ring->dma_size); 236 prq_rds[i].buff_size = cpu_to_le64(rds_ring->dma_size);
242 } 237 }
243 238
244 prq_sds = (nx_hostrq_sds_ring_t *)(prq->data + prq->sds_ring_offset); 239 prq_sds = (nx_hostrq_sds_ring_t *)(prq->data +
240 le32_to_cpu(prq->sds_ring_offset));
245 241
246 prq_sds[0].host_phys_addr = 242 prq_sds[0].host_phys_addr =
247 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); 243 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr);
248 prq_sds[0].ring_size = cpu_to_le32(adapter->max_rx_desc_count); 244 prq_sds[0].ring_size = cpu_to_le32(adapter->max_rx_desc_count);
249 /* only one msix vector for now */ 245 /* only one msix vector for now */
250 prq_sds[0].msi_index = cpu_to_le32(0); 246 prq_sds[0].msi_index = cpu_to_le16(0);
251
252 /* now byteswap offsets */
253 prq->rds_ring_offset = cpu_to_le32(prq->rds_ring_offset);
254 prq->sds_ring_offset = cpu_to_le32(prq->sds_ring_offset);
255 247
256 phys_addr = hostrq_phys_addr; 248 phys_addr = hostrq_phys_addr;
257 err = netxen_issue_cmd(adapter, 249 err = netxen_issue_cmd(adapter,
@@ -269,9 +261,9 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
269 261
270 262
271 prsp_rds = ((nx_cardrsp_rds_ring_t *) 263 prsp_rds = ((nx_cardrsp_rds_ring_t *)
272 &prsp->data[prsp->rds_ring_offset]); 264 &prsp->data[le32_to_cpu(prsp->rds_ring_offset)]);
273 265
274 for (i = 0; i < le32_to_cpu(prsp->num_rds_rings); i++) { 266 for (i = 0; i < le16_to_cpu(prsp->num_rds_rings); i++) {
275 rds_ring = &recv_ctx->rds_rings[i]; 267 rds_ring = &recv_ctx->rds_rings[i];
276 268
277 reg = le32_to_cpu(prsp_rds[i].host_producer_crb); 269 reg = le32_to_cpu(prsp_rds[i].host_producer_crb);
@@ -279,7 +271,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
279 } 271 }
280 272
281 prsp_sds = ((nx_cardrsp_sds_ring_t *) 273 prsp_sds = ((nx_cardrsp_sds_ring_t *)
282 &prsp->data[prsp->sds_ring_offset]); 274 &prsp->data[le32_to_cpu(prsp->sds_ring_offset)]);
283 reg = le32_to_cpu(prsp_sds[0].host_consumer_crb); 275 reg = le32_to_cpu(prsp_sds[0].host_consumer_crb);
284 recv_ctx->crb_sts_consumer = NETXEN_NIC_REG(reg - 0x200); 276 recv_ctx->crb_sts_consumer = NETXEN_NIC_REG(reg - 0x200);
285 277
@@ -288,7 +280,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
288 280
289 recv_ctx->state = le32_to_cpu(prsp->host_ctx_state); 281 recv_ctx->state = le32_to_cpu(prsp->host_ctx_state);
290 recv_ctx->context_id = le16_to_cpu(prsp->context_id); 282 recv_ctx->context_id = le16_to_cpu(prsp->context_id);
291 recv_ctx->virt_port = le16_to_cpu(prsp->virt_port); 283 recv_ctx->virt_port = prsp->virt_port;
292 284
293out_free_rsp: 285out_free_rsp:
294 pci_free_consistent(adapter->pdev, rsp_size, prsp, cardrsp_phys_addr); 286 pci_free_consistent(adapter->pdev, rsp_size, prsp, cardrsp_phys_addr);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index e45ce2951729..c0bd40fcf708 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -136,11 +136,9 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
136 136
137 ecmd->port = PORT_TP; 137 ecmd->port = PORT_TP;
138 138
139 if (netif_running(dev)) { 139 ecmd->speed = adapter->link_speed;
140 ecmd->speed = adapter->link_speed; 140 ecmd->duplex = adapter->link_duplex;
141 ecmd->duplex = adapter->link_duplex; 141 ecmd->autoneg = adapter->link_autoneg;
142 ecmd->autoneg = adapter->link_autoneg;
143 }
144 142
145 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { 143 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
146 u32 val; 144 u32 val;
@@ -171,7 +169,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
171 } else 169 } else
172 return -EIO; 170 return -EIO;
173 171
174 ecmd->phy_address = adapter->portnum; 172 ecmd->phy_address = adapter->physical_port;
175 ecmd->transceiver = XCVR_EXTERNAL; 173 ecmd->transceiver = XCVR_EXTERNAL;
176 174
177 switch ((netxen_brdtype_t) boardinfo->board_type) { 175 switch ((netxen_brdtype_t) boardinfo->board_type) {
@@ -180,13 +178,13 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
180 case NETXEN_BRDTYPE_P3_REF_QG: 178 case NETXEN_BRDTYPE_P3_REF_QG:
181 case NETXEN_BRDTYPE_P3_4_GB: 179 case NETXEN_BRDTYPE_P3_4_GB:
182 case NETXEN_BRDTYPE_P3_4_GB_MM: 180 case NETXEN_BRDTYPE_P3_4_GB_MM:
183 case NETXEN_BRDTYPE_P3_10000_BASE_T:
184 181
185 ecmd->supported |= SUPPORTED_Autoneg; 182 ecmd->supported |= SUPPORTED_Autoneg;
186 ecmd->advertising |= ADVERTISED_Autoneg; 183 ecmd->advertising |= ADVERTISED_Autoneg;
187 case NETXEN_BRDTYPE_P2_SB31_10G_CX4: 184 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
188 case NETXEN_BRDTYPE_P3_10G_CX4: 185 case NETXEN_BRDTYPE_P3_10G_CX4:
189 case NETXEN_BRDTYPE_P3_10G_CX4_LP: 186 case NETXEN_BRDTYPE_P3_10G_CX4_LP:
187 case NETXEN_BRDTYPE_P3_10000_BASE_T:
190 ecmd->supported |= SUPPORTED_TP; 188 ecmd->supported |= SUPPORTED_TP;
191 ecmd->advertising |= ADVERTISED_TP; 189 ecmd->advertising |= ADVERTISED_TP;
192 ecmd->port = PORT_TP; 190 ecmd->port = PORT_TP;
@@ -204,16 +202,33 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
204 ecmd->port = PORT_FIBRE; 202 ecmd->port = PORT_FIBRE;
205 ecmd->autoneg = AUTONEG_DISABLE; 203 ecmd->autoneg = AUTONEG_DISABLE;
206 break; 204 break;
207 case NETXEN_BRDTYPE_P2_SB31_10G:
208 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS: 205 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
209 case NETXEN_BRDTYPE_P3_10G_SFP_CT: 206 case NETXEN_BRDTYPE_P3_10G_SFP_CT:
210 case NETXEN_BRDTYPE_P3_10G_SFP_QT: 207 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
208 ecmd->advertising |= ADVERTISED_TP;
209 ecmd->supported |= SUPPORTED_TP;
210 case NETXEN_BRDTYPE_P2_SB31_10G:
211 case NETXEN_BRDTYPE_P3_10G_XFP: 211 case NETXEN_BRDTYPE_P3_10G_XFP:
212 ecmd->supported |= SUPPORTED_FIBRE; 212 ecmd->supported |= SUPPORTED_FIBRE;
213 ecmd->advertising |= ADVERTISED_FIBRE; 213 ecmd->advertising |= ADVERTISED_FIBRE;
214 ecmd->port = PORT_FIBRE; 214 ecmd->port = PORT_FIBRE;
215 ecmd->autoneg = AUTONEG_DISABLE; 215 ecmd->autoneg = AUTONEG_DISABLE;
216 break; 216 break;
217 case NETXEN_BRDTYPE_P3_10G_TP:
218 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
219 ecmd->autoneg = AUTONEG_DISABLE;
220 ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP);
221 ecmd->advertising |=
222 (ADVERTISED_FIBRE | ADVERTISED_TP);
223 ecmd->port = PORT_FIBRE;
224 } else {
225 ecmd->autoneg = AUTONEG_ENABLE;
226 ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg);
227 ecmd->advertising |=
228 (ADVERTISED_TP | ADVERTISED_Autoneg);
229 ecmd->port = PORT_TP;
230 }
231 break;
217 default: 232 default:
218 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", 233 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
219 (netxen_brdtype_t) boardinfo->board_type); 234 (netxen_brdtype_t) boardinfo->board_type);
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index aa6e603bfcbf..821cff68b3f3 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -503,17 +503,15 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
503 503
504 i = 0; 504 i = 0;
505 505
506 netif_tx_lock_bh(adapter->netdev);
507
506 producer = adapter->cmd_producer; 508 producer = adapter->cmd_producer;
507 do { 509 do {
508 cmd_desc = &cmd_desc_arr[i]; 510 cmd_desc = &cmd_desc_arr[i];
509 511
510 pbuf = &adapter->cmd_buf_arr[producer]; 512 pbuf = &adapter->cmd_buf_arr[producer];
511 pbuf->mss = 0;
512 pbuf->total_length = 0;
513 pbuf->skb = NULL; 513 pbuf->skb = NULL;
514 pbuf->cmd = 0;
515 pbuf->frag_count = 0; 514 pbuf->frag_count = 0;
516 pbuf->port = 0;
517 515
518 /* adapter->ahw.cmd_desc_head[producer] = *cmd_desc; */ 516 /* adapter->ahw.cmd_desc_head[producer] = *cmd_desc; */
519 memcpy(&adapter->ahw.cmd_desc_head[producer], 517 memcpy(&adapter->ahw.cmd_desc_head[producer],
@@ -531,6 +529,8 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
531 529
532 netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer); 530 netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer);
533 531
532 netif_tx_unlock_bh(adapter->netdev);
533
534 return 0; 534 return 0;
535} 535}
536 536
@@ -539,16 +539,19 @@ static int nx_p3_sre_macaddr_change(struct net_device *dev,
539{ 539{
540 struct netxen_adapter *adapter = netdev_priv(dev); 540 struct netxen_adapter *adapter = netdev_priv(dev);
541 nx_nic_req_t req; 541 nx_nic_req_t req;
542 nx_mac_req_t mac_req; 542 nx_mac_req_t *mac_req;
543 u64 word;
543 int rv; 544 int rv;
544 545
545 memset(&req, 0, sizeof(nx_nic_req_t)); 546 memset(&req, 0, sizeof(nx_nic_req_t));
546 req.qhdr |= (NX_NIC_REQUEST << 23); 547 req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23);
547 req.req_hdr |= NX_MAC_EVENT; 548
548 req.req_hdr |= ((u64)adapter->portnum << 16); 549 word = NX_MAC_EVENT | ((u64)adapter->portnum << 16);
549 mac_req.op = op; 550 req.req_hdr = cpu_to_le64(word);
550 memcpy(&mac_req.mac_addr, addr, 6); 551
551 req.words[0] = cpu_to_le64(*(u64 *)&mac_req); 552 mac_req = (nx_mac_req_t *)&req.words[0];
553 mac_req->op = op;
554 memcpy(mac_req->mac_addr, addr, 6);
552 555
553 rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); 556 rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
554 if (rv != 0) { 557 if (rv != 0) {
@@ -612,18 +615,35 @@ send_fw_cmd:
612int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode) 615int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
613{ 616{
614 nx_nic_req_t req; 617 nx_nic_req_t req;
618 u64 word;
615 619
616 memset(&req, 0, sizeof(nx_nic_req_t)); 620 memset(&req, 0, sizeof(nx_nic_req_t));
617 621
618 req.qhdr |= (NX_HOST_REQUEST << 23); 622 req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23);
619 req.req_hdr |= NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE; 623
620 req.req_hdr |= ((u64)adapter->portnum << 16); 624 word = NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE |
625 ((u64)adapter->portnum << 16);
626 req.req_hdr = cpu_to_le64(word);
627
621 req.words[0] = cpu_to_le64(mode); 628 req.words[0] = cpu_to_le64(mode);
622 629
623 return netxen_send_cmd_descs(adapter, 630 return netxen_send_cmd_descs(adapter,
624 (struct cmd_desc_type0 *)&req, 1); 631 (struct cmd_desc_type0 *)&req, 1);
625} 632}
626 633
634void netxen_p3_free_mac_list(struct netxen_adapter *adapter)
635{
636 nx_mac_list_t *cur, *next;
637
638 cur = adapter->mac_list;
639
640 while (cur) {
641 next = cur->next;
642 kfree(cur);
643 cur = next;
644 }
645}
646
627#define NETXEN_CONFIG_INTR_COALESCE 3 647#define NETXEN_CONFIG_INTR_COALESCE 3
628 648
629/* 649/*
@@ -632,13 +652,15 @@ int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
632int netxen_config_intr_coalesce(struct netxen_adapter *adapter) 652int netxen_config_intr_coalesce(struct netxen_adapter *adapter)
633{ 653{
634 nx_nic_req_t req; 654 nx_nic_req_t req;
655 u64 word;
635 int rv; 656 int rv;
636 657
637 memset(&req, 0, sizeof(nx_nic_req_t)); 658 memset(&req, 0, sizeof(nx_nic_req_t));
638 659
639 req.qhdr |= (NX_NIC_REQUEST << 23); 660 req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23);
640 req.req_hdr |= NETXEN_CONFIG_INTR_COALESCE; 661
641 req.req_hdr |= ((u64)adapter->portnum << 16); 662 word = NETXEN_CONFIG_INTR_COALESCE | ((u64)adapter->portnum << 16);
663 req.req_hdr = cpu_to_le64(word);
642 664
643 memcpy(&req.words[0], &adapter->coal, sizeof(adapter->coal)); 665 memcpy(&req.words[0], &adapter->coal, sizeof(adapter->coal));
644 666
@@ -772,13 +794,10 @@ int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac)
772 adapter->hw_read_wx(adapter, crbaddr, &mac_lo, 4); 794 adapter->hw_read_wx(adapter, crbaddr, &mac_lo, 4);
773 adapter->hw_read_wx(adapter, crbaddr+4, &mac_hi, 4); 795 adapter->hw_read_wx(adapter, crbaddr+4, &mac_hi, 4);
774 796
775 mac_hi = cpu_to_le32(mac_hi);
776 mac_lo = cpu_to_le32(mac_lo);
777
778 if (pci_func & 1) 797 if (pci_func & 1)
779 *mac = ((mac_lo >> 16) | ((u64)mac_hi << 16)); 798 *mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16));
780 else 799 else
781 *mac = ((mac_lo) | ((u64)mac_hi << 32)); 800 *mac = le64_to_cpu((u64)mac_lo | ((u64)mac_hi << 32));
782 801
783 return 0; 802 return 0;
784} 803}
@@ -937,7 +956,7 @@ int netxen_load_firmware(struct netxen_adapter *adapter)
937{ 956{
938 int i; 957 int i;
939 u32 data, size = 0; 958 u32 data, size = 0;
940 u32 flashaddr = NETXEN_BOOTLD_START, memaddr = NETXEN_BOOTLD_START; 959 u32 flashaddr = NETXEN_BOOTLD_START;
941 960
942 size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START)/4; 961 size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START)/4;
943 962
@@ -949,10 +968,8 @@ int netxen_load_firmware(struct netxen_adapter *adapter)
949 if (netxen_rom_fast_read(adapter, flashaddr, (int *)&data) != 0) 968 if (netxen_rom_fast_read(adapter, flashaddr, (int *)&data) != 0)
950 return -EIO; 969 return -EIO;
951 970
952 adapter->pci_mem_write(adapter, memaddr, &data, 4); 971 adapter->pci_mem_write(adapter, flashaddr, &data, 4);
953 flashaddr += 4; 972 flashaddr += 4;
954 memaddr += 4;
955 cond_resched();
956 } 973 }
957 msleep(1); 974 msleep(1);
958 975
@@ -2034,7 +2051,13 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2034 rv = -1; 2051 rv = -1;
2035 } 2052 }
2036 2053
2037 DPRINTK(INFO, "Discovered board type:0x%x ", boardinfo->board_type); 2054 if (boardinfo->board_type == NETXEN_BRDTYPE_P3_4_GB_MM) {
2055 u32 gpio = netxen_nic_reg_read(adapter,
2056 NETXEN_ROMUSB_GLB_PAD_GPIO_I);
2057 if ((gpio & 0x8000) == 0)
2058 boardinfo->board_type = NETXEN_BRDTYPE_P3_10G_TP;
2059 }
2060
2038 switch ((netxen_brdtype_t) boardinfo->board_type) { 2061 switch ((netxen_brdtype_t) boardinfo->board_type) {
2039 case NETXEN_BRDTYPE_P2_SB35_4G: 2062 case NETXEN_BRDTYPE_P2_SB35_4G:
2040 adapter->ahw.board_type = NETXEN_NIC_GBE; 2063 adapter->ahw.board_type = NETXEN_NIC_GBE;
@@ -2053,7 +2076,6 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2053 case NETXEN_BRDTYPE_P3_10G_SFP_QT: 2076 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
2054 case NETXEN_BRDTYPE_P3_10G_XFP: 2077 case NETXEN_BRDTYPE_P3_10G_XFP:
2055 case NETXEN_BRDTYPE_P3_10000_BASE_T: 2078 case NETXEN_BRDTYPE_P3_10000_BASE_T:
2056
2057 adapter->ahw.board_type = NETXEN_NIC_XGBE; 2079 adapter->ahw.board_type = NETXEN_NIC_XGBE;
2058 break; 2080 break;
2059 case NETXEN_BRDTYPE_P1_BD: 2081 case NETXEN_BRDTYPE_P1_BD:
@@ -2063,9 +2085,12 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2063 case NETXEN_BRDTYPE_P3_REF_QG: 2085 case NETXEN_BRDTYPE_P3_REF_QG:
2064 case NETXEN_BRDTYPE_P3_4_GB: 2086 case NETXEN_BRDTYPE_P3_4_GB:
2065 case NETXEN_BRDTYPE_P3_4_GB_MM: 2087 case NETXEN_BRDTYPE_P3_4_GB_MM:
2066
2067 adapter->ahw.board_type = NETXEN_NIC_GBE; 2088 adapter->ahw.board_type = NETXEN_NIC_GBE;
2068 break; 2089 break;
2090 case NETXEN_BRDTYPE_P3_10G_TP:
2091 adapter->ahw.board_type = (adapter->portnum < 2) ?
2092 NETXEN_NIC_XGBE : NETXEN_NIC_GBE;
2093 break;
2069 default: 2094 default:
2070 printk("%s: Unknown(%x)\n", netxen_nic_driver_name, 2095 printk("%s: Unknown(%x)\n", netxen_nic_driver_name,
2071 boardinfo->board_type); 2096 boardinfo->board_type);
@@ -2110,12 +2135,16 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2110{ 2135{
2111 __u32 status; 2136 __u32 status;
2112 __u32 autoneg; 2137 __u32 autoneg;
2113 __u32 mode;
2114 __u32 port_mode; 2138 __u32 port_mode;
2115 2139
2116 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode); 2140 if (!netif_carrier_ok(adapter->netdev)) {
2117 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ 2141 adapter->link_speed = 0;
2142 adapter->link_duplex = -1;
2143 adapter->link_autoneg = AUTONEG_ENABLE;
2144 return;
2145 }
2118 2146
2147 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
2119 adapter->hw_read_wx(adapter, 2148 adapter->hw_read_wx(adapter,
2120 NETXEN_PORT_MODE_ADDR, &port_mode, 4); 2149 NETXEN_PORT_MODE_ADDR, &port_mode, 4);
2121 if (port_mode == NETXEN_PORT_MODE_802_3_AP) { 2150 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
@@ -2141,7 +2170,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2141 adapter->link_speed = SPEED_1000; 2170 adapter->link_speed = SPEED_1000;
2142 break; 2171 break;
2143 default: 2172 default:
2144 adapter->link_speed = -1; 2173 adapter->link_speed = 0;
2145 break; 2174 break;
2146 } 2175 }
2147 switch (netxen_get_phy_duplex(status)) { 2176 switch (netxen_get_phy_duplex(status)) {
@@ -2164,7 +2193,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2164 goto link_down; 2193 goto link_down;
2165 } else { 2194 } else {
2166 link_down: 2195 link_down:
2167 adapter->link_speed = -1; 2196 adapter->link_speed = 0;
2168 adapter->link_duplex = -1; 2197 adapter->link_duplex = -1;
2169 } 2198 }
2170 } 2199 }
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index d924468e506e..ca7c8d8050c9 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -308,7 +308,6 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
308 } 308 }
309 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE); 309 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE);
310 INIT_LIST_HEAD(&rds_ring->free_list); 310 INIT_LIST_HEAD(&rds_ring->free_list);
311 rds_ring->begin_alloc = 0;
312 /* 311 /*
313 * Now go through all of them, set reference handles 312 * Now go through all of them, set reference handles
314 * and put them in the queues. 313 * and put them in the queues.
@@ -439,6 +438,8 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter)
439 long timeout = 0; 438 long timeout = 0;
440 long done = 0; 439 long done = 0;
441 440
441 cond_resched();
442
442 while (done == 0) { 443 while (done == 0) {
443 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS); 444 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS);
444 done &= 2; 445 done &= 2;
@@ -533,12 +534,9 @@ static int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
533static int do_rom_fast_read(struct netxen_adapter *adapter, 534static int do_rom_fast_read(struct netxen_adapter *adapter,
534 int addr, int *valp) 535 int addr, int *valp)
535{ 536{
536 cond_resched();
537
538 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); 537 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
539 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
540 udelay(100); /* prevent bursting on CRB */
541 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); 538 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
539 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
542 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb); 540 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb);
543 if (netxen_wait_rom_done(adapter)) { 541 if (netxen_wait_rom_done(adapter)) {
544 printk("Error waiting for rom done\n"); 542 printk("Error waiting for rom done\n");
@@ -546,7 +544,7 @@ static int do_rom_fast_read(struct netxen_adapter *adapter,
546 } 544 }
547 /* reset abyte_cnt and dummy_byte_cnt */ 545 /* reset abyte_cnt and dummy_byte_cnt */
548 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); 546 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
549 udelay(100); /* prevent bursting on CRB */ 547 udelay(10);
550 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); 548 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
551 549
552 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA); 550 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA);
@@ -884,14 +882,16 @@ int netxen_flash_unlock(struct netxen_adapter *adapter)
884int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) 882int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
885{ 883{
886 int addr, val; 884 int addr, val;
887 int i, init_delay = 0; 885 int i, n, init_delay = 0;
888 struct crb_addr_pair *buf; 886 struct crb_addr_pair *buf;
889 unsigned offset, n; 887 unsigned offset;
890 u32 off; 888 u32 off;
891 889
892 /* resetall */ 890 /* resetall */
891 rom_lock(adapter);
893 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 892 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
894 0xffffffff); 893 0xffffffff);
894 netxen_rom_unlock(adapter);
895 895
896 if (verbose) { 896 if (verbose) {
897 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0) 897 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0)
@@ -910,7 +910,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
910 910
911 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 911 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
912 if (netxen_rom_fast_read(adapter, 0, &n) != 0 || 912 if (netxen_rom_fast_read(adapter, 0, &n) != 0 ||
913 (n != 0xcafecafeUL) || 913 (n != 0xcafecafe) ||
914 netxen_rom_fast_read(adapter, 4, &n) != 0) { 914 netxen_rom_fast_read(adapter, 4, &n) != 0) {
915 printk(KERN_ERR "%s: ERROR Reading crb_init area: " 915 printk(KERN_ERR "%s: ERROR Reading crb_init area: "
916 "n: %08x\n", netxen_nic_driver_name, n); 916 "n: %08x\n", netxen_nic_driver_name, n);
@@ -975,6 +975,14 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
975 /* do not reset PCI */ 975 /* do not reset PCI */
976 if (off == (ROMUSB_GLB + 0xbc)) 976 if (off == (ROMUSB_GLB + 0xbc))
977 continue; 977 continue;
978 if (off == (ROMUSB_GLB + 0xa8))
979 continue;
980 if (off == (ROMUSB_GLB + 0xc8)) /* core clock */
981 continue;
982 if (off == (ROMUSB_GLB + 0x24)) /* MN clock */
983 continue;
984 if (off == (ROMUSB_GLB + 0x1c)) /* MS clock */
985 continue;
978 if (off == (NETXEN_CRB_PEG_NET_1 + 0x18)) 986 if (off == (NETXEN_CRB_PEG_NET_1 + 0x18))
979 buf[i].data = 0x1020; 987 buf[i].data = 0x1020;
980 /* skip the function enable register */ 988 /* skip the function enable register */
@@ -992,23 +1000,21 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
992 continue; 1000 continue;
993 } 1001 }
994 1002
1003 init_delay = 1;
995 /* After writing this register, HW needs time for CRB */ 1004 /* After writing this register, HW needs time for CRB */
996 /* to quiet down (else crb_window returns 0xffffffff) */ 1005 /* to quiet down (else crb_window returns 0xffffffff) */
997 if (off == NETXEN_ROMUSB_GLB_SW_RESET) { 1006 if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
998 init_delay = 1; 1007 init_delay = 1000;
999 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 1008 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
1000 /* hold xdma in reset also */ 1009 /* hold xdma in reset also */
1001 buf[i].data = NETXEN_NIC_XDMA_RESET; 1010 buf[i].data = NETXEN_NIC_XDMA_RESET;
1011 buf[i].data = 0x8000ff;
1002 } 1012 }
1003 } 1013 }
1004 1014
1005 adapter->hw_write_wx(adapter, off, &buf[i].data, 4); 1015 adapter->hw_write_wx(adapter, off, &buf[i].data, 4);
1006 1016
1007 if (init_delay == 1) { 1017 msleep(init_delay);
1008 msleep(1000);
1009 init_delay = 0;
1010 }
1011 msleep(1);
1012 } 1018 }
1013 kfree(buf); 1019 kfree(buf);
1014 1020
@@ -1277,7 +1283,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1277 1283
1278 dev_kfree_skb_any(skb); 1284 dev_kfree_skb_any(skb);
1279 for (i = 0; i < nr_frags; i++) { 1285 for (i = 0; i < nr_frags; i++) {
1280 index = frag_desc->frag_handles[i]; 1286 index = le16_to_cpu(frag_desc->frag_handles[i]);
1281 skb = netxen_process_rxbuf(adapter, 1287 skb = netxen_process_rxbuf(adapter,
1282 rds_ring, index, cksum); 1288 rds_ring, index, cksum);
1283 if (skb) 1289 if (skb)
@@ -1428,7 +1434,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1428 struct rcv_desc *pdesc; 1434 struct rcv_desc *pdesc;
1429 struct netxen_rx_buffer *buffer; 1435 struct netxen_rx_buffer *buffer;
1430 int count = 0; 1436 int count = 0;
1431 int index = 0;
1432 netxen_ctx_msg msg = 0; 1437 netxen_ctx_msg msg = 0;
1433 dma_addr_t dma; 1438 dma_addr_t dma;
1434 struct list_head *head; 1439 struct list_head *head;
@@ -1436,7 +1441,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1436 rds_ring = &recv_ctx->rds_rings[ringid]; 1441 rds_ring = &recv_ctx->rds_rings[ringid];
1437 1442
1438 producer = rds_ring->producer; 1443 producer = rds_ring->producer;
1439 index = rds_ring->begin_alloc;
1440 head = &rds_ring->free_list; 1444 head = &rds_ring->free_list;
1441 1445
1442 /* We can start writing rx descriptors into the phantom memory. */ 1446 /* We can start writing rx descriptors into the phantom memory. */
@@ -1444,39 +1448,37 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1444 1448
1445 skb = dev_alloc_skb(rds_ring->skb_size); 1449 skb = dev_alloc_skb(rds_ring->skb_size);
1446 if (unlikely(!skb)) { 1450 if (unlikely(!skb)) {
1447 rds_ring->begin_alloc = index;
1448 break; 1451 break;
1449 } 1452 }
1450 1453
1454 if (!adapter->ahw.cut_through)
1455 skb_reserve(skb, 2);
1456
1457 dma = pci_map_single(pdev, skb->data,
1458 rds_ring->dma_size, PCI_DMA_FROMDEVICE);
1459 if (pci_dma_mapping_error(pdev, dma)) {
1460 dev_kfree_skb_any(skb);
1461 break;
1462 }
1463
1464 count++;
1451 buffer = list_entry(head->next, struct netxen_rx_buffer, list); 1465 buffer = list_entry(head->next, struct netxen_rx_buffer, list);
1452 list_del(&buffer->list); 1466 list_del(&buffer->list);
1453 1467
1454 count++; /* now there should be no failure */
1455 pdesc = &rds_ring->desc_head[producer];
1456
1457 if (!adapter->ahw.cut_through)
1458 skb_reserve(skb, 2);
1459 /* This will be setup when we receive the
1460 * buffer after it has been filled FSL TBD TBD
1461 * skb->dev = netdev;
1462 */
1463 dma = pci_map_single(pdev, skb->data, rds_ring->dma_size,
1464 PCI_DMA_FROMDEVICE);
1465 pdesc->addr_buffer = cpu_to_le64(dma);
1466 buffer->skb = skb; 1468 buffer->skb = skb;
1467 buffer->state = NETXEN_BUFFER_BUSY; 1469 buffer->state = NETXEN_BUFFER_BUSY;
1468 buffer->dma = dma; 1470 buffer->dma = dma;
1471
1469 /* make a rcv descriptor */ 1472 /* make a rcv descriptor */
1473 pdesc = &rds_ring->desc_head[producer];
1474 pdesc->addr_buffer = cpu_to_le64(dma);
1470 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1475 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1471 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1476 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1472 DPRINTK(INFO, "done writing descripter\n"); 1477
1473 producer = 1478 producer = get_next_index(producer, rds_ring->max_rx_desc_count);
1474 get_next_index(producer, rds_ring->max_rx_desc_count);
1475 index = get_next_index(index, rds_ring->max_rx_desc_count);
1476 } 1479 }
1477 /* if we did allocate buffers, then write the count to Phantom */ 1480 /* if we did allocate buffers, then write the count to Phantom */
1478 if (count) { 1481 if (count) {
1479 rds_ring->begin_alloc = index;
1480 rds_ring->producer = producer; 1482 rds_ring->producer = producer;
1481 /* Window = 1 */ 1483 /* Window = 1 */
1482 adapter->pci_write_normalize(adapter, 1484 adapter->pci_write_normalize(adapter,
@@ -1515,49 +1517,50 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1515 struct rcv_desc *pdesc; 1517 struct rcv_desc *pdesc;
1516 struct netxen_rx_buffer *buffer; 1518 struct netxen_rx_buffer *buffer;
1517 int count = 0; 1519 int count = 0;
1518 int index = 0;
1519 struct list_head *head; 1520 struct list_head *head;
1521 dma_addr_t dma;
1520 1522
1521 rds_ring = &recv_ctx->rds_rings[ringid]; 1523 rds_ring = &recv_ctx->rds_rings[ringid];
1522 1524
1523 producer = rds_ring->producer; 1525 producer = rds_ring->producer;
1524 index = rds_ring->begin_alloc;
1525 head = &rds_ring->free_list; 1526 head = &rds_ring->free_list;
1526 /* We can start writing rx descriptors into the phantom memory. */ 1527 /* We can start writing rx descriptors into the phantom memory. */
1527 while (!list_empty(head)) { 1528 while (!list_empty(head)) {
1528 1529
1529 skb = dev_alloc_skb(rds_ring->skb_size); 1530 skb = dev_alloc_skb(rds_ring->skb_size);
1530 if (unlikely(!skb)) { 1531 if (unlikely(!skb)) {
1531 rds_ring->begin_alloc = index;
1532 break; 1532 break;
1533 } 1533 }
1534 1534
1535 if (!adapter->ahw.cut_through)
1536 skb_reserve(skb, 2);
1537
1538 dma = pci_map_single(pdev, skb->data,
1539 rds_ring->dma_size, PCI_DMA_FROMDEVICE);
1540 if (pci_dma_mapping_error(pdev, dma)) {
1541 dev_kfree_skb_any(skb);
1542 break;
1543 }
1544
1545 count++;
1535 buffer = list_entry(head->next, struct netxen_rx_buffer, list); 1546 buffer = list_entry(head->next, struct netxen_rx_buffer, list);
1536 list_del(&buffer->list); 1547 list_del(&buffer->list);
1537 1548
1538 count++; /* now there should be no failure */
1539 pdesc = &rds_ring->desc_head[producer];
1540 if (!adapter->ahw.cut_through)
1541 skb_reserve(skb, 2);
1542 buffer->skb = skb; 1549 buffer->skb = skb;
1543 buffer->state = NETXEN_BUFFER_BUSY; 1550 buffer->state = NETXEN_BUFFER_BUSY;
1544 buffer->dma = pci_map_single(pdev, skb->data, 1551 buffer->dma = dma;
1545 rds_ring->dma_size,
1546 PCI_DMA_FROMDEVICE);
1547 1552
1548 /* make a rcv descriptor */ 1553 /* make a rcv descriptor */
1554 pdesc = &rds_ring->desc_head[producer];
1549 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1555 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1550 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1556 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1551 pdesc->addr_buffer = cpu_to_le64(buffer->dma); 1557 pdesc->addr_buffer = cpu_to_le64(buffer->dma);
1552 producer = 1558
1553 get_next_index(producer, rds_ring->max_rx_desc_count); 1559 producer = get_next_index(producer, rds_ring->max_rx_desc_count);
1554 index = get_next_index(index, rds_ring->max_rx_desc_count);
1555 buffer = &rds_ring->rx_buf_arr[index];
1556 } 1560 }
1557 1561
1558 /* if we did allocate buffers, then write the count to Phantom */ 1562 /* if we did allocate buffers, then write the count to Phantom */
1559 if (count) { 1563 if (count) {
1560 rds_ring->begin_alloc = index;
1561 rds_ring->producer = producer; 1564 rds_ring->producer = producer;
1562 /* Window = 1 */ 1565 /* Window = 1 */
1563 adapter->pci_write_normalize(adapter, 1566 adapter->pci_write_normalize(adapter,
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index ba01524b5531..d854f07ef4d3 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -39,7 +39,9 @@
39#include "netxen_nic_phan_reg.h" 39#include "netxen_nic_phan_reg.h"
40 40
41#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
42#include <linux/if_vlan.h>
42#include <net/ip.h> 43#include <net/ip.h>
44#include <linux/ipv6.h>
43 45
44MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); 46MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
45MODULE_LICENSE("GPL"); 47MODULE_LICENSE("GPL");
@@ -242,7 +244,7 @@ static void netxen_check_options(struct netxen_adapter *adapter)
242 case NETXEN_BRDTYPE_P3_4_GB: 244 case NETXEN_BRDTYPE_P3_4_GB:
243 case NETXEN_BRDTYPE_P3_4_GB_MM: 245 case NETXEN_BRDTYPE_P3_4_GB_MM:
244 adapter->msix_supported = !!use_msi_x; 246 adapter->msix_supported = !!use_msi_x;
245 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G; 247 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
246 break; 248 break;
247 249
248 case NETXEN_BRDTYPE_P2_SB35_4G: 250 case NETXEN_BRDTYPE_P2_SB35_4G:
@@ -251,6 +253,14 @@ static void netxen_check_options(struct netxen_adapter *adapter)
251 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; 253 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
252 break; 254 break;
253 255
256 case NETXEN_BRDTYPE_P3_10G_TP:
257 adapter->msix_supported = !!use_msi_x;
258 if (adapter->ahw.board_type == NETXEN_NIC_XGBE)
259 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
260 else
261 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
262 break;
263
254 default: 264 default:
255 adapter->msix_supported = 0; 265 adapter->msix_supported = 0;
256 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; 266 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
@@ -271,10 +281,15 @@ static void netxen_check_options(struct netxen_adapter *adapter)
271static int 281static int
272netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot) 282netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
273{ 283{
274 int ret = 0; 284 u32 val, timeout;
275 285
276 if (first_boot == 0x55555555) { 286 if (first_boot == 0x55555555) {
277 /* This is the first boot after power up */ 287 /* This is the first boot after power up */
288 adapter->pci_write_normalize(adapter,
289 NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
290
291 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
292 return 0;
278 293
279 /* PCI bus master workaround */ 294 /* PCI bus master workaround */
280 adapter->hw_read_wx(adapter, 295 adapter->hw_read_wx(adapter,
@@ -294,18 +309,26 @@ netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
294 /* clear the register for future unloads/loads */ 309 /* clear the register for future unloads/loads */
295 adapter->pci_write_normalize(adapter, 310 adapter->pci_write_normalize(adapter,
296 NETXEN_CAM_RAM(0x1fc), 0); 311 NETXEN_CAM_RAM(0x1fc), 0);
297 ret = -1; 312 return -EIO;
298 } 313 }
299 314
300 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 315 /* Start P2 boot loader */
301 /* Start P2 boot loader */ 316 val = adapter->pci_read_normalize(adapter,
302 adapter->pci_write_normalize(adapter, 317 NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
303 NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); 318 adapter->pci_write_normalize(adapter,
304 adapter->pci_write_normalize(adapter, 319 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1);
305 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, 1); 320 timeout = 0;
306 } 321 do {
322 msleep(1);
323 val = adapter->pci_read_normalize(adapter,
324 NETXEN_CAM_RAM(0x1fc));
325
326 if (++timeout > 5000)
327 return -EIO;
328
329 } while (val == NETXEN_BDINFO_MAGIC);
307 } 330 }
308 return ret; 331 return 0;
309} 332}
310 333
311static void netxen_set_port_mode(struct netxen_adapter *adapter) 334static void netxen_set_port_mode(struct netxen_adapter *adapter)
@@ -784,8 +807,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
784 CRB_CMDPEG_STATE, 0); 807 CRB_CMDPEG_STATE, 0);
785 netxen_pinit_from_rom(adapter, 0); 808 netxen_pinit_from_rom(adapter, 0);
786 msleep(1); 809 msleep(1);
787 netxen_load_firmware(adapter);
788 } 810 }
811 netxen_load_firmware(adapter);
789 812
790 if (NX_IS_REVISION_P3(revision_id)) 813 if (NX_IS_REVISION_P3(revision_id))
791 netxen_pcie_strap_init(adapter); 814 netxen_pcie_strap_init(adapter);
@@ -801,13 +824,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
801 824
802 } 825 }
803 826
804 if ((first_boot == 0x55555555) &&
805 (NX_IS_REVISION_P2(revision_id))) {
806 /* Unlock the HW, prompting the boot sequence */
807 adapter->pci_write_normalize(adapter,
808 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, 1);
809 }
810
811 err = netxen_initialize_adapter_offload(adapter); 827 err = netxen_initialize_adapter_offload(adapter);
812 if (err) 828 if (err)
813 goto err_out_iounmap; 829 goto err_out_iounmap;
@@ -821,7 +837,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
821 adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, i); 837 adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, i);
822 838
823 /* Handshake with the card before we register the devices. */ 839 /* Handshake with the card before we register the devices. */
824 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 840 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
841 if (err)
842 goto err_out_free_offload;
825 843
826 } /* first_driver */ 844 } /* first_driver */
827 845
@@ -925,6 +943,7 @@ err_out_disable_msi:
925 if (adapter->flags & NETXEN_NIC_MSI_ENABLED) 943 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
926 pci_disable_msi(pdev); 944 pci_disable_msi(pdev);
927 945
946err_out_free_offload:
928 if (first_driver) 947 if (first_driver)
929 netxen_free_adapter_offload(adapter); 948 netxen_free_adapter_offload(adapter);
930 949
@@ -968,6 +987,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
968 netxen_free_hw_resources(adapter); 987 netxen_free_hw_resources(adapter);
969 netxen_release_rx_buffers(adapter); 988 netxen_release_rx_buffers(adapter);
970 netxen_free_sw_resources(adapter); 989 netxen_free_sw_resources(adapter);
990
991 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
992 netxen_p3_free_mac_list(adapter);
971 } 993 }
972 994
973 if (adapter->portnum == 0) 995 if (adapter->portnum == 0)
@@ -983,8 +1005,10 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
983 1005
984 iounmap(adapter->ahw.db_base); 1006 iounmap(adapter->ahw.db_base);
985 iounmap(adapter->ahw.pci_base0); 1007 iounmap(adapter->ahw.pci_base0);
986 iounmap(adapter->ahw.pci_base1); 1008 if (adapter->ahw.pci_base1 != NULL)
987 iounmap(adapter->ahw.pci_base2); 1009 iounmap(adapter->ahw.pci_base1);
1010 if (adapter->ahw.pci_base2 != NULL)
1011 iounmap(adapter->ahw.pci_base2);
988 1012
989 pci_release_regions(pdev); 1013 pci_release_regions(pdev);
990 pci_disable_device(pdev); 1014 pci_disable_device(pdev);
@@ -1137,29 +1161,64 @@ static int netxen_nic_close(struct net_device *netdev)
1137 return 0; 1161 return 0;
1138} 1162}
1139 1163
1140void netxen_tso_check(struct netxen_adapter *adapter, 1164static bool netxen_tso_check(struct net_device *netdev,
1141 struct cmd_desc_type0 *desc, struct sk_buff *skb) 1165 struct cmd_desc_type0 *desc, struct sk_buff *skb)
1142{ 1166{
1143 if (desc->mss) { 1167 bool tso = false;
1144 desc->total_hdr_length = (sizeof(struct ethhdr) + 1168 u8 opcode = TX_ETHER_PKT;
1145 ip_hdrlen(skb) + tcp_hdrlen(skb));
1146 1169
1147 if ((NX_IS_REVISION_P3(adapter->ahw.revision_id)) && 1170 if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) &&
1148 (skb->protocol == htons(ETH_P_IPV6))) 1171 skb_shinfo(skb)->gso_size > 0) {
1149 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO6); 1172
1150 else 1173 desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
1151 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO); 1174 desc->total_hdr_length =
1175 skb_transport_offset(skb) + tcp_hdrlen(skb);
1176
1177 opcode = (skb->protocol == htons(ETH_P_IPV6)) ?
1178 TX_TCP_LSO6 : TX_TCP_LSO;
1179 tso = true;
1152 1180
1153 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { 1181 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
1154 if (ip_hdr(skb)->protocol == IPPROTO_TCP) 1182 u8 l4proto;
1155 netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT); 1183
1156 else if (ip_hdr(skb)->protocol == IPPROTO_UDP) 1184 if (skb->protocol == htons(ETH_P_IP)) {
1157 netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT); 1185 l4proto = ip_hdr(skb)->protocol;
1158 else 1186
1159 return; 1187 if (l4proto == IPPROTO_TCP)
1188 opcode = TX_TCP_PKT;
1189 else if(l4proto == IPPROTO_UDP)
1190 opcode = TX_UDP_PKT;
1191 } else if (skb->protocol == htons(ETH_P_IPV6)) {
1192 l4proto = ipv6_hdr(skb)->nexthdr;
1193
1194 if (l4proto == IPPROTO_TCP)
1195 opcode = TX_TCPV6_PKT;
1196 else if(l4proto == IPPROTO_UDP)
1197 opcode = TX_UDPV6_PKT;
1198 }
1160 } 1199 }
1161 desc->tcp_hdr_offset = skb_transport_offset(skb); 1200 desc->tcp_hdr_offset = skb_transport_offset(skb);
1162 desc->ip_hdr_offset = skb_network_offset(skb); 1201 desc->ip_hdr_offset = skb_network_offset(skb);
1202 netxen_set_tx_flags_opcode(desc, 0, opcode);
1203 return tso;
1204}
1205
1206static void
1207netxen_clean_tx_dma_mapping(struct pci_dev *pdev,
1208 struct netxen_cmd_buffer *pbuf, int last)
1209{
1210 int k;
1211 struct netxen_skb_frag *buffrag;
1212
1213 buffrag = &pbuf->frag_array[0];
1214 pci_unmap_single(pdev, buffrag->dma,
1215 buffrag->length, PCI_DMA_TODEVICE);
1216
1217 for (k = 1; k < last; k++) {
1218 buffrag = &pbuf->frag_array[k];
1219 pci_unmap_page(pdev, buffrag->dma,
1220 buffrag->length, PCI_DMA_TODEVICE);
1221 }
1163} 1222}
1164 1223
1165static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 1224static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
@@ -1167,33 +1226,22 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1167 struct netxen_adapter *adapter = netdev_priv(netdev); 1226 struct netxen_adapter *adapter = netdev_priv(netdev);
1168 struct netxen_hardware_context *hw = &adapter->ahw; 1227 struct netxen_hardware_context *hw = &adapter->ahw;
1169 unsigned int first_seg_len = skb->len - skb->data_len; 1228 unsigned int first_seg_len = skb->len - skb->data_len;
1229 struct netxen_cmd_buffer *pbuf;
1170 struct netxen_skb_frag *buffrag; 1230 struct netxen_skb_frag *buffrag;
1171 unsigned int i; 1231 struct cmd_desc_type0 *hwdesc;
1232 struct pci_dev *pdev = adapter->pdev;
1233 dma_addr_t temp_dma;
1234 int i, k;
1172 1235
1173 u32 producer, consumer; 1236 u32 producer, consumer;
1174 u32 saved_producer = 0; 1237 int frag_count, no_of_desc;
1175 struct cmd_desc_type0 *hwdesc;
1176 int k;
1177 struct netxen_cmd_buffer *pbuf = NULL;
1178 int frag_count;
1179 int no_of_desc;
1180 u32 num_txd = adapter->max_tx_desc_count; 1238 u32 num_txd = adapter->max_tx_desc_count;
1239 bool is_tso = false;
1181 1240
1182 frag_count = skb_shinfo(skb)->nr_frags + 1; 1241 frag_count = skb_shinfo(skb)->nr_frags + 1;
1183 1242
1184 /* There 4 fragments per descriptor */ 1243 /* There 4 fragments per descriptor */
1185 no_of_desc = (frag_count + 3) >> 2; 1244 no_of_desc = (frag_count + 3) >> 2;
1186 if (netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) {
1187 if (skb_shinfo(skb)->gso_size > 0) {
1188
1189 no_of_desc++;
1190 if ((ip_hdrlen(skb) + tcp_hdrlen(skb) +
1191 sizeof(struct ethhdr)) >
1192 (sizeof(struct cmd_desc_type0) - 2)) {
1193 no_of_desc++;
1194 }
1195 }
1196 }
1197 1245
1198 producer = adapter->cmd_producer; 1246 producer = adapter->cmd_producer;
1199 smp_mb(); 1247 smp_mb();
@@ -1205,34 +1253,26 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1205 } 1253 }
1206 1254
1207 /* Copy the descriptors into the hardware */ 1255 /* Copy the descriptors into the hardware */
1208 saved_producer = producer;
1209 hwdesc = &hw->cmd_desc_head[producer]; 1256 hwdesc = &hw->cmd_desc_head[producer];
1210 memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); 1257 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
1211 /* Take skb->data itself */ 1258 /* Take skb->data itself */
1212 pbuf = &adapter->cmd_buf_arr[producer]; 1259 pbuf = &adapter->cmd_buf_arr[producer];
1213 if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) && 1260
1214 skb_shinfo(skb)->gso_size > 0) { 1261 is_tso = netxen_tso_check(netdev, hwdesc, skb);
1215 pbuf->mss = skb_shinfo(skb)->gso_size; 1262
1216 hwdesc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
1217 } else {
1218 pbuf->mss = 0;
1219 hwdesc->mss = 0;
1220 }
1221 pbuf->total_length = skb->len;
1222 pbuf->skb = skb; 1263 pbuf->skb = skb;
1223 pbuf->cmd = TX_ETHER_PKT;
1224 pbuf->frag_count = frag_count; 1264 pbuf->frag_count = frag_count;
1225 pbuf->port = adapter->portnum;
1226 buffrag = &pbuf->frag_array[0]; 1265 buffrag = &pbuf->frag_array[0];
1227 buffrag->dma = pci_map_single(adapter->pdev, skb->data, first_seg_len, 1266 temp_dma = pci_map_single(pdev, skb->data, first_seg_len,
1228 PCI_DMA_TODEVICE); 1267 PCI_DMA_TODEVICE);
1268 if (pci_dma_mapping_error(pdev, temp_dma))
1269 goto drop_packet;
1270
1271 buffrag->dma = temp_dma;
1229 buffrag->length = first_seg_len; 1272 buffrag->length = first_seg_len;
1230 netxen_set_cmd_desc_totallength(hwdesc, skb->len); 1273 netxen_set_tx_frags_len(hwdesc, frag_count, skb->len);
1231 netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count); 1274 netxen_set_tx_port(hwdesc, adapter->portnum);
1232 netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT);
1233 1275
1234 netxen_set_cmd_desc_port(hwdesc, adapter->portnum);
1235 netxen_set_cmd_desc_ctxid(hwdesc, adapter->portnum);
1236 hwdesc->buffer1_length = cpu_to_le16(first_seg_len); 1276 hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
1237 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); 1277 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
1238 1278
@@ -1240,7 +1280,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1240 struct skb_frag_struct *frag; 1280 struct skb_frag_struct *frag;
1241 int len, temp_len; 1281 int len, temp_len;
1242 unsigned long offset; 1282 unsigned long offset;
1243 dma_addr_t temp_dma;
1244 1283
1245 /* move to next desc. if there is a need */ 1284 /* move to next desc. if there is a need */
1246 if ((i & 0x3) == 0) { 1285 if ((i & 0x3) == 0) {
@@ -1256,8 +1295,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1256 offset = frag->page_offset; 1295 offset = frag->page_offset;
1257 1296
1258 temp_len = len; 1297 temp_len = len;
1259 temp_dma = pci_map_page(adapter->pdev, frag->page, offset, 1298 temp_dma = pci_map_page(pdev, frag->page, offset,
1260 len, PCI_DMA_TODEVICE); 1299 len, PCI_DMA_TODEVICE);
1300 if (pci_dma_mapping_error(pdev, temp_dma)) {
1301 netxen_clean_tx_dma_mapping(pdev, pbuf, i);
1302 goto drop_packet;
1303 }
1261 1304
1262 buffrag++; 1305 buffrag++;
1263 buffrag->dma = temp_dma; 1306 buffrag->dma = temp_dma;
@@ -1285,16 +1328,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1285 } 1328 }
1286 producer = get_next_index(producer, num_txd); 1329 producer = get_next_index(producer, num_txd);
1287 1330
1288 /* might change opcode to TX_TCP_LSO */
1289 netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb);
1290
1291 /* For LSO, we need to copy the MAC/IP/TCP headers into 1331 /* For LSO, we need to copy the MAC/IP/TCP headers into
1292 * the descriptor ring 1332 * the descriptor ring
1293 */ 1333 */
1294 if (netxen_get_cmd_desc_opcode(&hw->cmd_desc_head[saved_producer]) 1334 if (is_tso) {
1295 == TX_TCP_LSO) {
1296 int hdr_len, first_hdr_len, more_hdr; 1335 int hdr_len, first_hdr_len, more_hdr;
1297 hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length; 1336 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1298 if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) { 1337 if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) {
1299 first_hdr_len = sizeof(struct cmd_desc_type0) - 2; 1338 first_hdr_len = sizeof(struct cmd_desc_type0) - 2;
1300 more_hdr = 1; 1339 more_hdr = 1;
@@ -1336,6 +1375,11 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1336 netdev->trans_start = jiffies; 1375 netdev->trans_start = jiffies;
1337 1376
1338 return NETDEV_TX_OK; 1377 return NETDEV_TX_OK;
1378
1379drop_packet:
1380 adapter->stats.txdropped++;
1381 dev_kfree_skb_any(skb);
1382 return NETDEV_TX_OK;
1339} 1383}
1340 1384
1341static int netxen_nic_check_temp(struct netxen_adapter *adapter) 1385static int netxen_nic_check_temp(struct netxen_adapter *adapter)
@@ -1407,6 +1451,8 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
1407 netif_carrier_off(netdev); 1451 netif_carrier_off(netdev);
1408 netif_stop_queue(netdev); 1452 netif_stop_queue(netdev);
1409 } 1453 }
1454
1455 netxen_nic_set_link_parameters(adapter);
1410 } else if (!adapter->ahw.linkup && linkup) { 1456 } else if (!adapter->ahw.linkup && linkup) {
1411 printk(KERN_INFO "%s: %s NIC Link is up\n", 1457 printk(KERN_INFO "%s: %s NIC Link is up\n",
1412 netxen_nic_driver_name, netdev->name); 1458 netxen_nic_driver_name, netdev->name);
@@ -1415,6 +1461,8 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
1415 netif_carrier_on(netdev); 1461 netif_carrier_on(netdev);
1416 netif_wake_queue(netdev); 1462 netif_wake_queue(netdev);
1417 } 1463 }
1464
1465 netxen_nic_set_link_parameters(adapter);
1418 } 1466 }
1419} 1467}
1420 1468
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 42021aca1ddd..e80294d8cc19 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -1956,6 +1956,7 @@ static const struct net_device_ops netdev_ops = {
1956 .ndo_change_mtu = ns83820_change_mtu, 1956 .ndo_change_mtu = ns83820_change_mtu,
1957 .ndo_set_multicast_list = ns83820_set_multicast, 1957 .ndo_set_multicast_list = ns83820_set_multicast,
1958 .ndo_validate_addr = eth_validate_addr, 1958 .ndo_validate_addr = eth_validate_addr,
1959 .ndo_set_mac_address = eth_mac_addr,
1959 .ndo_tx_timeout = ns83820_tx_timeout, 1960 .ndo_tx_timeout = ns83820_tx_timeout,
1960#ifdef NS83820_VLAN_ACCEL_SUPPORT 1961#ifdef NS83820_VLAN_ACCEL_SUPPORT
1961 .ndo_vlan_rx_register = ns83820_vlan_rx_register, 1962 .ndo_vlan_rx_register = ns83820_vlan_rx_register,
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 5b7a574ce571..d0349e7d73ea 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -712,7 +712,7 @@ static inline void pasemi_mac_rx_error(const struct pasemi_mac *mac,
712 rcmdsta = read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if)); 712 rcmdsta = read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if));
713 ccmdsta = read_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno)); 713 ccmdsta = read_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno));
714 714
715 printk(KERN_ERR "pasemi_mac: rx error. macrx %016lx, rx status %lx\n", 715 printk(KERN_ERR "pasemi_mac: rx error. macrx %016llx, rx status %llx\n",
716 macrx, *chan->status); 716 macrx, *chan->status);
717 717
718 printk(KERN_ERR "pasemi_mac: rcmdsta %08x ccmdsta %08x\n", 718 printk(KERN_ERR "pasemi_mac: rcmdsta %08x ccmdsta %08x\n",
@@ -730,8 +730,8 @@ static inline void pasemi_mac_tx_error(const struct pasemi_mac *mac,
730 730
731 cmdsta = read_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno)); 731 cmdsta = read_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno));
732 732
733 printk(KERN_ERR "pasemi_mac: tx error. mactx 0x%016lx, "\ 733 printk(KERN_ERR "pasemi_mac: tx error. mactx 0x%016llx, "\
734 "tx status 0x%016lx\n", mactx, *chan->status); 734 "tx status 0x%016llx\n", mactx, *chan->status);
735 735
736 printk(KERN_ERR "pasemi_mac: tcmdsta 0x%08x\n", cmdsta); 736 printk(KERN_ERR "pasemi_mac: tcmdsta 0x%08x\n", cmdsta);
737} 737}
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e35460165bf7..0a06e4fd37d9 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -231,15 +231,6 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
231 if ((phy_id & 0x1fffffff) == 0x1fffffff) 231 if ((phy_id & 0x1fffffff) == 0x1fffffff)
232 return NULL; 232 return NULL;
233 233
234 /*
235 * Broken hardware is sometimes missing the pull-up resistor on the
236 * MDIO line, which results in reads to non-existent devices returning
237 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
238 * device as well.
239 */
240 if (phy_id == 0)
241 return NULL;
242
243 dev = phy_device_create(bus, addr, phy_id); 234 dev = phy_device_create(bus, addr, phy_id);
244 235
245 return dev; 236 return dev;
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 06b448285eb5..7b2728b8f1b7 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -250,6 +250,7 @@ static int ppp_connect_channel(struct channel *pch, int unit);
250static int ppp_disconnect_channel(struct channel *pch); 250static int ppp_disconnect_channel(struct channel *pch);
251static void ppp_destroy_channel(struct channel *pch); 251static void ppp_destroy_channel(struct channel *pch);
252static int unit_get(struct idr *p, void *ptr); 252static int unit_get(struct idr *p, void *ptr);
253static int unit_set(struct idr *p, void *ptr, int n);
253static void unit_put(struct idr *p, int n); 254static void unit_put(struct idr *p, int n);
254static void *unit_find(struct idr *p, int n); 255static void *unit_find(struct idr *p, int n);
255 256
@@ -2432,11 +2433,18 @@ ppp_create_interface(int unit, int *retp)
2432 } else { 2433 } else {
2433 if (unit_find(&ppp_units_idr, unit)) 2434 if (unit_find(&ppp_units_idr, unit))
2434 goto out2; /* unit already exists */ 2435 goto out2; /* unit already exists */
2435 else { 2436 /*
2436 /* darn, someone is cheating us? */ 2437 * if caller need a specified unit number
2437 *retp = -EINVAL; 2438 * lets try to satisfy him, otherwise --
2439 * he should better ask us for new unit number
2440 *
2441 * NOTE: yes I know that returning EEXIST it's not
2442 * fair but at least pppd will ask us to allocate
2443 * new unit in this case so user is happy :)
2444 */
2445 unit = unit_set(&ppp_units_idr, ppp, unit);
2446 if (unit < 0)
2438 goto out2; 2447 goto out2;
2439 }
2440 } 2448 }
2441 2449
2442 /* Initialize the new ppp unit */ 2450 /* Initialize the new ppp unit */
@@ -2677,14 +2685,37 @@ static void __exit ppp_cleanup(void)
2677 * by holding all_ppp_mutex 2685 * by holding all_ppp_mutex
2678 */ 2686 */
2679 2687
2688/* associate pointer with specified number */
2689static int unit_set(struct idr *p, void *ptr, int n)
2690{
2691 int unit, err;
2692
2693again:
2694 if (!idr_pre_get(p, GFP_KERNEL)) {
2695 printk(KERN_ERR "PPP: No free memory for idr\n");
2696 return -ENOMEM;
2697 }
2698
2699 err = idr_get_new_above(p, ptr, n, &unit);
2700 if (err == -EAGAIN)
2701 goto again;
2702
2703 if (unit != n) {
2704 idr_remove(p, unit);
2705 return -EINVAL;
2706 }
2707
2708 return unit;
2709}
2710
2680/* get new free unit number and associate pointer with it */ 2711/* get new free unit number and associate pointer with it */
2681static int unit_get(struct idr *p, void *ptr) 2712static int unit_get(struct idr *p, void *ptr)
2682{ 2713{
2683 int unit, err; 2714 int unit, err;
2684 2715
2685again: 2716again:
2686 if (idr_pre_get(p, GFP_KERNEL) == 0) { 2717 if (!idr_pre_get(p, GFP_KERNEL)) {
2687 printk(KERN_ERR "Out of memory expanding drawable idr\n"); 2718 printk(KERN_ERR "PPP: No free memory for idr\n");
2688 return -ENOMEM; 2719 return -ENOMEM;
2689 } 2720 }
2690 2721
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 459663a4023d..c1dadadfab18 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -28,11 +28,11 @@
28 } while (0) 28 } while (0)
29 29
30#define QLGE_VENDOR_ID 0x1077 30#define QLGE_VENDOR_ID 0x1077
31#define QLGE_DEVICE_ID1 0x8012 31#define QLGE_DEVICE_ID 0x8012
32#define QLGE_DEVICE_ID 0x8000
33 32
34#define MAX_RX_RINGS 128 33#define MAX_CPUS 8
35#define MAX_TX_RINGS 128 34#define MAX_TX_RINGS MAX_CPUS
35#define MAX_RX_RINGS ((MAX_CPUS * 2) + 1)
36 36
37#define NUM_TX_RING_ENTRIES 256 37#define NUM_TX_RING_ENTRIES 256
38#define NUM_RX_RING_ENTRIES 256 38#define NUM_RX_RING_ENTRIES 256
@@ -45,6 +45,7 @@
45#define MAX_SPLIT_SIZE 1023 45#define MAX_SPLIT_SIZE 1023
46#define QLGE_SB_PAD 32 46#define QLGE_SB_PAD 32
47 47
48#define MAX_CQ 128
48#define DFLT_COALESCE_WAIT 100 /* 100 usec wait for coalescing */ 49#define DFLT_COALESCE_WAIT 100 /* 100 usec wait for coalescing */
49#define MAX_INTER_FRAME_WAIT 10 /* 10 usec max interframe-wait for coalescing */ 50#define MAX_INTER_FRAME_WAIT 10 /* 10 usec max interframe-wait for coalescing */
50#define DFLT_INTER_FRAME_WAIT (MAX_INTER_FRAME_WAIT/2) 51#define DFLT_INTER_FRAME_WAIT (MAX_INTER_FRAME_WAIT/2)
@@ -961,8 +962,7 @@ struct ib_mac_iocb_rsp {
961#define IB_MAC_IOCB_RSP_DS 0x40 /* data is in small buffer */ 962#define IB_MAC_IOCB_RSP_DS 0x40 /* data is in small buffer */
962#define IB_MAC_IOCB_RSP_DL 0x80 /* data is in large buffer */ 963#define IB_MAC_IOCB_RSP_DL 0x80 /* data is in large buffer */
963 __le32 data_len; /* */ 964 __le32 data_len; /* */
964 __le32 data_addr_lo; /* */ 965 __le64 data_addr; /* */
965 __le32 data_addr_hi; /* */
966 __le32 rss; /* */ 966 __le32 rss; /* */
967 __le16 vlan_id; /* 12 bits */ 967 __le16 vlan_id; /* 12 bits */
968#define IB_MAC_IOCB_RSP_C 0x1000 /* VLAN CFI bit */ 968#define IB_MAC_IOCB_RSP_C 0x1000 /* VLAN CFI bit */
@@ -976,8 +976,7 @@ struct ib_mac_iocb_rsp {
976#define IB_MAC_IOCB_RSP_HS 0x40 976#define IB_MAC_IOCB_RSP_HS 0x40
977#define IB_MAC_IOCB_RSP_HL 0x80 977#define IB_MAC_IOCB_RSP_HL 0x80
978 __le32 hdr_len; /* */ 978 __le32 hdr_len; /* */
979 __le32 hdr_addr_lo; /* */ 979 __le64 hdr_addr; /* */
980 __le32 hdr_addr_hi; /* */
981} __attribute((packed)); 980} __attribute((packed));
982 981
983struct ib_ae_iocb_rsp { 982struct ib_ae_iocb_rsp {
@@ -1042,10 +1041,8 @@ struct wqicb {
1042 __le16 cq_id_rss; 1041 __le16 cq_id_rss;
1043#define Q_CQ_ID_RSS_RV 0x8000 1042#define Q_CQ_ID_RSS_RV 0x8000
1044 __le16 rid; 1043 __le16 rid;
1045 __le32 addr_lo; 1044 __le64 addr;
1046 __le32 addr_hi; 1045 __le64 cnsmr_idx_addr;
1047 __le32 cnsmr_idx_addr_lo;
1048 __le32 cnsmr_idx_addr_hi;
1049} __attribute((packed)); 1046} __attribute((packed));
1050 1047
1051/* 1048/*
@@ -1070,18 +1067,14 @@ struct cqicb {
1070#define LEN_CPP_64 0x0002 1067#define LEN_CPP_64 0x0002
1071#define LEN_CPP_128 0x0003 1068#define LEN_CPP_128 0x0003
1072 __le16 rid; 1069 __le16 rid;
1073 __le32 addr_lo; 1070 __le64 addr;
1074 __le32 addr_hi; 1071 __le64 prod_idx_addr;
1075 __le32 prod_idx_addr_lo;
1076 __le32 prod_idx_addr_hi;
1077 __le16 pkt_delay; 1072 __le16 pkt_delay;
1078 __le16 irq_delay; 1073 __le16 irq_delay;
1079 __le32 lbq_addr_lo; 1074 __le64 lbq_addr;
1080 __le32 lbq_addr_hi;
1081 __le16 lbq_buf_size; 1075 __le16 lbq_buf_size;
1082 __le16 lbq_len; /* entry count */ 1076 __le16 lbq_len; /* entry count */
1083 __le32 sbq_addr_lo; 1077 __le64 sbq_addr;
1084 __le32 sbq_addr_hi;
1085 __le16 sbq_buf_size; 1078 __le16 sbq_buf_size;
1086 __le16 sbq_len; /* entry count */ 1079 __le16 sbq_len; /* entry count */
1087} __attribute((packed)); 1080} __attribute((packed));
@@ -1145,7 +1138,7 @@ struct tx_ring {
1145 struct wqicb wqicb; /* structure used to inform chip of new queue */ 1138 struct wqicb wqicb; /* structure used to inform chip of new queue */
1146 void *wq_base; /* pci_alloc:virtual addr for tx */ 1139 void *wq_base; /* pci_alloc:virtual addr for tx */
1147 dma_addr_t wq_base_dma; /* pci_alloc:dma addr for tx */ 1140 dma_addr_t wq_base_dma; /* pci_alloc:dma addr for tx */
1148 u32 *cnsmr_idx_sh_reg; /* shadow copy of consumer idx */ 1141 __le32 *cnsmr_idx_sh_reg; /* shadow copy of consumer idx */
1149 dma_addr_t cnsmr_idx_sh_reg_dma; /* dma-shadow copy of consumer */ 1142 dma_addr_t cnsmr_idx_sh_reg_dma; /* dma-shadow copy of consumer */
1150 u32 wq_size; /* size in bytes of queue area */ 1143 u32 wq_size; /* size in bytes of queue area */
1151 u32 wq_len; /* number of entries in queue */ 1144 u32 wq_len; /* number of entries in queue */
@@ -1181,7 +1174,7 @@ struct rx_ring {
1181 u32 cq_size; 1174 u32 cq_size;
1182 u32 cq_len; 1175 u32 cq_len;
1183 u16 cq_id; 1176 u16 cq_id;
1184 volatile __le32 *prod_idx_sh_reg; /* Shadowed producer register. */ 1177 __le32 *prod_idx_sh_reg; /* Shadowed producer register. */
1185 dma_addr_t prod_idx_sh_reg_dma; 1178 dma_addr_t prod_idx_sh_reg_dma;
1186 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */ 1179 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */
1187 u32 cnsmr_idx; /* current sw idx */ 1180 u32 cnsmr_idx; /* current sw idx */
@@ -1402,9 +1395,11 @@ struct ql_adapter {
1402 int rx_ring_count; 1395 int rx_ring_count;
1403 int ring_mem_size; 1396 int ring_mem_size;
1404 void *ring_mem; 1397 void *ring_mem;
1405 struct rx_ring *rx_ring; 1398
1399 struct rx_ring rx_ring[MAX_RX_RINGS];
1400 struct tx_ring tx_ring[MAX_TX_RINGS];
1401
1406 int rx_csum; 1402 int rx_csum;
1407 struct tx_ring *tx_ring;
1408 u32 default_rx_queue; 1403 u32 default_rx_queue;
1409 1404
1410 u16 rx_coalesce_usecs; /* cqicb->int_delay */ 1405 u16 rx_coalesce_usecs; /* cqicb->int_delay */
@@ -1459,6 +1454,24 @@ static inline void ql_write_db_reg(u32 val, void __iomem *addr)
1459 mmiowb(); 1454 mmiowb();
1460} 1455}
1461 1456
1457/*
1458 * Shadow Registers:
1459 * Outbound queues have a consumer index that is maintained by the chip.
1460 * Inbound queues have a producer index that is maintained by the chip.
1461 * For lower overhead, these registers are "shadowed" to host memory
1462 * which allows the device driver to track the queue progress without
1463 * PCI reads. When an entry is placed on an inbound queue, the chip will
1464 * update the relevant index register and then copy the value to the
1465 * shadow register in host memory.
1466 */
1467static inline u32 ql_read_sh_reg(__le32 *addr)
1468{
1469 u32 reg;
1470 reg = le32_to_cpu(*addr);
1471 rmb();
1472 return reg;
1473}
1474
1462extern char qlge_driver_name[]; 1475extern char qlge_driver_name[];
1463extern const char qlge_driver_version[]; 1476extern const char qlge_driver_version[];
1464extern const struct ethtool_ops qlge_ethtool_ops; 1477extern const struct ethtool_ops qlge_ethtool_ops;
diff --git a/drivers/net/qlge/qlge_dbg.c b/drivers/net/qlge/qlge_dbg.c
index 3f5e02d2e4a9..379b895ed6e6 100644
--- a/drivers/net/qlge/qlge_dbg.c
+++ b/drivers/net/qlge/qlge_dbg.c
@@ -435,14 +435,10 @@ void ql_dump_wqicb(struct wqicb *wqicb)
435 printk(KERN_ERR PFX "wqicb->cq_id_rss = %d.\n", 435 printk(KERN_ERR PFX "wqicb->cq_id_rss = %d.\n",
436 le16_to_cpu(wqicb->cq_id_rss)); 436 le16_to_cpu(wqicb->cq_id_rss));
437 printk(KERN_ERR PFX "wqicb->rid = 0x%x.\n", le16_to_cpu(wqicb->rid)); 437 printk(KERN_ERR PFX "wqicb->rid = 0x%x.\n", le16_to_cpu(wqicb->rid));
438 printk(KERN_ERR PFX "wqicb->wq_addr_lo = 0x%.08x.\n", 438 printk(KERN_ERR PFX "wqicb->wq_addr = 0x%llx.\n",
439 le32_to_cpu(wqicb->addr_lo)); 439 (unsigned long long) le64_to_cpu(wqicb->addr));
440 printk(KERN_ERR PFX "wqicb->wq_addr_hi = 0x%.08x.\n", 440 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr = 0x%llx.\n",
441 le32_to_cpu(wqicb->addr_hi)); 441 (unsigned long long) le64_to_cpu(wqicb->cnsmr_idx_addr));
442 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr_lo = 0x%.08x.\n",
443 le32_to_cpu(wqicb->cnsmr_idx_addr_lo));
444 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr_hi = 0x%.08x.\n",
445 le32_to_cpu(wqicb->cnsmr_idx_addr_hi));
446} 442}
447 443
448void ql_dump_tx_ring(struct tx_ring *tx_ring) 444void ql_dump_tx_ring(struct tx_ring *tx_ring)
@@ -455,10 +451,11 @@ void ql_dump_tx_ring(struct tx_ring *tx_ring)
455 printk(KERN_ERR PFX "tx_ring->base = %p.\n", tx_ring->wq_base); 451 printk(KERN_ERR PFX "tx_ring->base = %p.\n", tx_ring->wq_base);
456 printk(KERN_ERR PFX "tx_ring->base_dma = 0x%llx.\n", 452 printk(KERN_ERR PFX "tx_ring->base_dma = 0x%llx.\n",
457 (unsigned long long) tx_ring->wq_base_dma); 453 (unsigned long long) tx_ring->wq_base_dma);
458 printk(KERN_ERR PFX "tx_ring->cnsmr_idx_sh_reg = %p.\n", 454 printk(KERN_ERR PFX
459 tx_ring->cnsmr_idx_sh_reg); 455 "tx_ring->cnsmr_idx_sh_reg, addr = 0x%p, value = %d.\n",
460 printk(KERN_ERR PFX "tx_ring->cnsmr_idx_sh_reg_dma = 0x%llx.\n", 456 tx_ring->cnsmr_idx_sh_reg,
461 (unsigned long long) tx_ring->cnsmr_idx_sh_reg_dma); 457 tx_ring->cnsmr_idx_sh_reg
458 ? ql_read_sh_reg(tx_ring->cnsmr_idx_sh_reg) : 0);
462 printk(KERN_ERR PFX "tx_ring->size = %d.\n", tx_ring->wq_size); 459 printk(KERN_ERR PFX "tx_ring->size = %d.\n", tx_ring->wq_size);
463 printk(KERN_ERR PFX "tx_ring->len = %d.\n", tx_ring->wq_len); 460 printk(KERN_ERR PFX "tx_ring->len = %d.\n", tx_ring->wq_len);
464 printk(KERN_ERR PFX "tx_ring->prod_idx_db_reg = %p.\n", 461 printk(KERN_ERR PFX "tx_ring->prod_idx_db_reg = %p.\n",
@@ -510,30 +507,22 @@ void ql_dump_cqicb(struct cqicb *cqicb)
510 printk(KERN_ERR PFX "cqicb->msix_vect = %d.\n", cqicb->msix_vect); 507 printk(KERN_ERR PFX "cqicb->msix_vect = %d.\n", cqicb->msix_vect);
511 printk(KERN_ERR PFX "cqicb->flags = %x.\n", cqicb->flags); 508 printk(KERN_ERR PFX "cqicb->flags = %x.\n", cqicb->flags);
512 printk(KERN_ERR PFX "cqicb->len = %d.\n", le16_to_cpu(cqicb->len)); 509 printk(KERN_ERR PFX "cqicb->len = %d.\n", le16_to_cpu(cqicb->len));
513 printk(KERN_ERR PFX "cqicb->addr_lo = %x.\n", 510 printk(KERN_ERR PFX "cqicb->addr = 0x%llx.\n",
514 le32_to_cpu(cqicb->addr_lo)); 511 (unsigned long long) le64_to_cpu(cqicb->addr));
515 printk(KERN_ERR PFX "cqicb->addr_hi = %x.\n", 512 printk(KERN_ERR PFX "cqicb->prod_idx_addr = 0x%llx.\n",
516 le32_to_cpu(cqicb->addr_hi)); 513 (unsigned long long) le64_to_cpu(cqicb->prod_idx_addr));
517 printk(KERN_ERR PFX "cqicb->prod_idx_addr_lo = %x.\n",
518 le32_to_cpu(cqicb->prod_idx_addr_lo));
519 printk(KERN_ERR PFX "cqicb->prod_idx_addr_hi = %x.\n",
520 le32_to_cpu(cqicb->prod_idx_addr_hi));
521 printk(KERN_ERR PFX "cqicb->pkt_delay = 0x%.04x.\n", 514 printk(KERN_ERR PFX "cqicb->pkt_delay = 0x%.04x.\n",
522 le16_to_cpu(cqicb->pkt_delay)); 515 le16_to_cpu(cqicb->pkt_delay));
523 printk(KERN_ERR PFX "cqicb->irq_delay = 0x%.04x.\n", 516 printk(KERN_ERR PFX "cqicb->irq_delay = 0x%.04x.\n",
524 le16_to_cpu(cqicb->irq_delay)); 517 le16_to_cpu(cqicb->irq_delay));
525 printk(KERN_ERR PFX "cqicb->lbq_addr_lo = %x.\n", 518 printk(KERN_ERR PFX "cqicb->lbq_addr = 0x%llx.\n",
526 le32_to_cpu(cqicb->lbq_addr_lo)); 519 (unsigned long long) le64_to_cpu(cqicb->lbq_addr));
527 printk(KERN_ERR PFX "cqicb->lbq_addr_hi = %x.\n",
528 le32_to_cpu(cqicb->lbq_addr_hi));
529 printk(KERN_ERR PFX "cqicb->lbq_buf_size = 0x%.04x.\n", 520 printk(KERN_ERR PFX "cqicb->lbq_buf_size = 0x%.04x.\n",
530 le16_to_cpu(cqicb->lbq_buf_size)); 521 le16_to_cpu(cqicb->lbq_buf_size));
531 printk(KERN_ERR PFX "cqicb->lbq_len = 0x%.04x.\n", 522 printk(KERN_ERR PFX "cqicb->lbq_len = 0x%.04x.\n",
532 le16_to_cpu(cqicb->lbq_len)); 523 le16_to_cpu(cqicb->lbq_len));
533 printk(KERN_ERR PFX "cqicb->sbq_addr_lo = %x.\n", 524 printk(KERN_ERR PFX "cqicb->sbq_addr = 0x%llx.\n",
534 le32_to_cpu(cqicb->sbq_addr_lo)); 525 (unsigned long long) le64_to_cpu(cqicb->sbq_addr));
535 printk(KERN_ERR PFX "cqicb->sbq_addr_hi = %x.\n",
536 le32_to_cpu(cqicb->sbq_addr_hi));
537 printk(KERN_ERR PFX "cqicb->sbq_buf_size = 0x%.04x.\n", 526 printk(KERN_ERR PFX "cqicb->sbq_buf_size = 0x%.04x.\n",
538 le16_to_cpu(cqicb->sbq_buf_size)); 527 le16_to_cpu(cqicb->sbq_buf_size));
539 printk(KERN_ERR PFX "cqicb->sbq_len = 0x%.04x.\n", 528 printk(KERN_ERR PFX "cqicb->sbq_len = 0x%.04x.\n",
@@ -558,9 +547,10 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring)
558 printk(KERN_ERR PFX "rx_ring->cq_size = %d.\n", rx_ring->cq_size); 547 printk(KERN_ERR PFX "rx_ring->cq_size = %d.\n", rx_ring->cq_size);
559 printk(KERN_ERR PFX "rx_ring->cq_len = %d.\n", rx_ring->cq_len); 548 printk(KERN_ERR PFX "rx_ring->cq_len = %d.\n", rx_ring->cq_len);
560 printk(KERN_ERR PFX 549 printk(KERN_ERR PFX
561 "rx_ring->prod_idx_sh_reg, addr = %p, value = %d.\n", 550 "rx_ring->prod_idx_sh_reg, addr = 0x%p, value = %d.\n",
562 rx_ring->prod_idx_sh_reg, 551 rx_ring->prod_idx_sh_reg,
563 rx_ring->prod_idx_sh_reg ? *(rx_ring->prod_idx_sh_reg) : 0); 552 rx_ring->prod_idx_sh_reg
553 ? ql_read_sh_reg(rx_ring->prod_idx_sh_reg) : 0);
564 printk(KERN_ERR PFX "rx_ring->prod_idx_sh_reg_dma = %llx.\n", 554 printk(KERN_ERR PFX "rx_ring->prod_idx_sh_reg_dma = %llx.\n",
565 (unsigned long long) rx_ring->prod_idx_sh_reg_dma); 555 (unsigned long long) rx_ring->prod_idx_sh_reg_dma);
566 printk(KERN_ERR PFX "rx_ring->cnsmr_idx_db_reg = %p.\n", 556 printk(KERN_ERR PFX "rx_ring->cnsmr_idx_db_reg = %p.\n",
@@ -809,10 +799,8 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
809 799
810 printk(KERN_ERR PFX "data_len = %d\n", 800 printk(KERN_ERR PFX "data_len = %d\n",
811 le32_to_cpu(ib_mac_rsp->data_len)); 801 le32_to_cpu(ib_mac_rsp->data_len));
812 printk(KERN_ERR PFX "data_addr_hi = 0x%x\n", 802 printk(KERN_ERR PFX "data_addr = 0x%llx\n",
813 le32_to_cpu(ib_mac_rsp->data_addr_hi)); 803 (unsigned long long) le64_to_cpu(ib_mac_rsp->data_addr));
814 printk(KERN_ERR PFX "data_addr_lo = 0x%x\n",
815 le32_to_cpu(ib_mac_rsp->data_addr_lo));
816 if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) 804 if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK)
817 printk(KERN_ERR PFX "rss = %x\n", 805 printk(KERN_ERR PFX "rss = %x\n",
818 le32_to_cpu(ib_mac_rsp->rss)); 806 le32_to_cpu(ib_mac_rsp->rss));
@@ -828,10 +816,8 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
828 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) { 816 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
829 printk(KERN_ERR PFX "hdr length = %d.\n", 817 printk(KERN_ERR PFX "hdr length = %d.\n",
830 le32_to_cpu(ib_mac_rsp->hdr_len)); 818 le32_to_cpu(ib_mac_rsp->hdr_len));
831 printk(KERN_ERR PFX "hdr addr_hi = 0x%x.\n", 819 printk(KERN_ERR PFX "hdr addr = 0x%llx.\n",
832 le32_to_cpu(ib_mac_rsp->hdr_addr_hi)); 820 (unsigned long long) le64_to_cpu(ib_mac_rsp->hdr_addr));
833 printk(KERN_ERR PFX "hdr addr_lo = 0x%x.\n",
834 le32_to_cpu(ib_mac_rsp->hdr_addr_lo));
835 } 821 }
836} 822}
837#endif 823#endif
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index f4c016012f18..45421c8b6010 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -76,7 +76,6 @@ MODULE_PARM_DESC(irq_type, "0 = MSI-X, 1 = MSI, 2 = Legacy.");
76 76
77static struct pci_device_id qlge_pci_tbl[] __devinitdata = { 77static struct pci_device_id qlge_pci_tbl[] __devinitdata = {
78 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID)}, 78 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID)},
79 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID1)},
80 /* required last entry */ 79 /* required last entry */
81 {0,} 80 {0,}
82}; 81};
@@ -127,12 +126,12 @@ static int ql_sem_trylock(struct ql_adapter *qdev, u32 sem_mask)
127 126
128int ql_sem_spinlock(struct ql_adapter *qdev, u32 sem_mask) 127int ql_sem_spinlock(struct ql_adapter *qdev, u32 sem_mask)
129{ 128{
130 unsigned int seconds = 3; 129 unsigned int wait_count = 30;
131 do { 130 do {
132 if (!ql_sem_trylock(qdev, sem_mask)) 131 if (!ql_sem_trylock(qdev, sem_mask))
133 return 0; 132 return 0;
134 ssleep(1); 133 udelay(100);
135 } while (--seconds); 134 } while (--wait_count);
136 return -ETIMEDOUT; 135 return -ETIMEDOUT;
137} 136}
138 137
@@ -1545,7 +1544,7 @@ static void ql_process_chip_ae_intr(struct ql_adapter *qdev,
1545static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) 1544static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1546{ 1545{
1547 struct ql_adapter *qdev = rx_ring->qdev; 1546 struct ql_adapter *qdev = rx_ring->qdev;
1548 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1547 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1549 struct ob_mac_iocb_rsp *net_rsp = NULL; 1548 struct ob_mac_iocb_rsp *net_rsp = NULL;
1550 int count = 0; 1549 int count = 0;
1551 1550
@@ -1571,7 +1570,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1571 } 1570 }
1572 count++; 1571 count++;
1573 ql_update_cq(rx_ring); 1572 ql_update_cq(rx_ring);
1574 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1573 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1575 } 1574 }
1576 ql_write_cq_idx(rx_ring); 1575 ql_write_cq_idx(rx_ring);
1577 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) { 1576 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) {
@@ -1591,7 +1590,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1591static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) 1590static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1592{ 1591{
1593 struct ql_adapter *qdev = rx_ring->qdev; 1592 struct ql_adapter *qdev = rx_ring->qdev;
1594 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1593 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1595 struct ql_net_rsp_iocb *net_rsp; 1594 struct ql_net_rsp_iocb *net_rsp;
1596 int count = 0; 1595 int count = 0;
1597 1596
@@ -1624,7 +1623,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1624 } 1623 }
1625 count++; 1624 count++;
1626 ql_update_cq(rx_ring); 1625 ql_update_cq(rx_ring);
1627 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1626 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1628 if (count == budget) 1627 if (count == budget)
1629 break; 1628 break;
1630 } 1629 }
@@ -1787,7 +1786,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1787 * Check the default queue and wake handler if active. 1786 * Check the default queue and wake handler if active.
1788 */ 1787 */
1789 rx_ring = &qdev->rx_ring[0]; 1788 rx_ring = &qdev->rx_ring[0];
1790 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) { 1789 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) {
1791 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n"); 1790 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n");
1792 ql_disable_completion_interrupt(qdev, intr_context->intr); 1791 ql_disable_completion_interrupt(qdev, intr_context->intr);
1793 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue, 1792 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue,
@@ -1801,7 +1800,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1801 */ 1800 */
1802 for (i = 1; i < qdev->rx_ring_count; i++) { 1801 for (i = 1; i < qdev->rx_ring_count; i++) {
1803 rx_ring = &qdev->rx_ring[i]; 1802 rx_ring = &qdev->rx_ring[i];
1804 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != 1803 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) !=
1805 rx_ring->cnsmr_idx) { 1804 rx_ring->cnsmr_idx) {
1806 QPRINTK(qdev, INTR, INFO, 1805 QPRINTK(qdev, INTR, INFO,
1807 "Waking handler for rx_ring[%d].\n", i); 1806 "Waking handler for rx_ring[%d].\n", i);
@@ -2356,28 +2355,6 @@ static void ql_tx_ring_clean(struct ql_adapter *qdev)
2356 } 2355 }
2357} 2356}
2358 2357
2359static void ql_free_ring_cb(struct ql_adapter *qdev)
2360{
2361 kfree(qdev->ring_mem);
2362}
2363
2364static int ql_alloc_ring_cb(struct ql_adapter *qdev)
2365{
2366 /* Allocate space for tx/rx ring control blocks. */
2367 qdev->ring_mem_size =
2368 (qdev->tx_ring_count * sizeof(struct tx_ring)) +
2369 (qdev->rx_ring_count * sizeof(struct rx_ring));
2370 qdev->ring_mem = kmalloc(qdev->ring_mem_size, GFP_KERNEL);
2371 if (qdev->ring_mem == NULL) {
2372 return -ENOMEM;
2373 } else {
2374 qdev->rx_ring = qdev->ring_mem;
2375 qdev->tx_ring = qdev->ring_mem +
2376 (qdev->rx_ring_count * sizeof(struct rx_ring));
2377 }
2378 return 0;
2379}
2380
2381static void ql_free_mem_resources(struct ql_adapter *qdev) 2358static void ql_free_mem_resources(struct ql_adapter *qdev)
2382{ 2359{
2383 int i; 2360 int i;
@@ -2467,12 +2444,9 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2467 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len; 2444 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len;
2468 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT); 2445 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT);
2469 2446
2470 cqicb->addr_lo = cpu_to_le32(rx_ring->cq_base_dma); 2447 cqicb->addr = cpu_to_le64(rx_ring->cq_base_dma);
2471 cqicb->addr_hi = cpu_to_le32((u64) rx_ring->cq_base_dma >> 32);
2472 2448
2473 cqicb->prod_idx_addr_lo = cpu_to_le32(rx_ring->prod_idx_sh_reg_dma); 2449 cqicb->prod_idx_addr = cpu_to_le64(rx_ring->prod_idx_sh_reg_dma);
2474 cqicb->prod_idx_addr_hi =
2475 cpu_to_le32((u64) rx_ring->prod_idx_sh_reg_dma >> 32);
2476 2450
2477 /* 2451 /*
2478 * Set up the control block load flags. 2452 * Set up the control block load flags.
@@ -2483,10 +2457,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2483 if (rx_ring->lbq_len) { 2457 if (rx_ring->lbq_len) {
2484 cqicb->flags |= FLAGS_LL; /* Load lbq values */ 2458 cqicb->flags |= FLAGS_LL; /* Load lbq values */
2485 *((u64 *) rx_ring->lbq_base_indirect) = rx_ring->lbq_base_dma; 2459 *((u64 *) rx_ring->lbq_base_indirect) = rx_ring->lbq_base_dma;
2486 cqicb->lbq_addr_lo = 2460 cqicb->lbq_addr =
2487 cpu_to_le32(rx_ring->lbq_base_indirect_dma); 2461 cpu_to_le64(rx_ring->lbq_base_indirect_dma);
2488 cqicb->lbq_addr_hi =
2489 cpu_to_le32((u64) rx_ring->lbq_base_indirect_dma >> 32);
2490 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 : 2462 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 :
2491 (u16) rx_ring->lbq_buf_size; 2463 (u16) rx_ring->lbq_buf_size;
2492 cqicb->lbq_buf_size = cpu_to_le16(bq_len); 2464 cqicb->lbq_buf_size = cpu_to_le16(bq_len);
@@ -2501,10 +2473,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2501 if (rx_ring->sbq_len) { 2473 if (rx_ring->sbq_len) {
2502 cqicb->flags |= FLAGS_LS; /* Load sbq values */ 2474 cqicb->flags |= FLAGS_LS; /* Load sbq values */
2503 *((u64 *) rx_ring->sbq_base_indirect) = rx_ring->sbq_base_dma; 2475 *((u64 *) rx_ring->sbq_base_indirect) = rx_ring->sbq_base_dma;
2504 cqicb->sbq_addr_lo = 2476 cqicb->sbq_addr =
2505 cpu_to_le32(rx_ring->sbq_base_indirect_dma); 2477 cpu_to_le64(rx_ring->sbq_base_indirect_dma);
2506 cqicb->sbq_addr_hi =
2507 cpu_to_le32((u64) rx_ring->sbq_base_indirect_dma >> 32);
2508 cqicb->sbq_buf_size = 2478 cqicb->sbq_buf_size =
2509 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8); 2479 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8);
2510 bq_len = (rx_ring->sbq_len == 65536) ? 0 : 2480 bq_len = (rx_ring->sbq_len == 65536) ? 0 :
@@ -2611,12 +2581,9 @@ static int ql_start_tx_ring(struct ql_adapter *qdev, struct tx_ring *tx_ring)
2611 Q_FLAGS_LB | Q_FLAGS_LI | Q_FLAGS_LO); 2581 Q_FLAGS_LB | Q_FLAGS_LI | Q_FLAGS_LO);
2612 wqicb->cq_id_rss = cpu_to_le16(tx_ring->cq_id); 2582 wqicb->cq_id_rss = cpu_to_le16(tx_ring->cq_id);
2613 wqicb->rid = 0; 2583 wqicb->rid = 0;
2614 wqicb->addr_lo = cpu_to_le32(tx_ring->wq_base_dma); 2584 wqicb->addr = cpu_to_le64(tx_ring->wq_base_dma);
2615 wqicb->addr_hi = cpu_to_le32((u64) tx_ring->wq_base_dma >> 32);
2616 2585
2617 wqicb->cnsmr_idx_addr_lo = cpu_to_le32(tx_ring->cnsmr_idx_sh_reg_dma); 2586 wqicb->cnsmr_idx_addr = cpu_to_le64(tx_ring->cnsmr_idx_sh_reg_dma);
2618 wqicb->cnsmr_idx_addr_hi =
2619 cpu_to_le32((u64) tx_ring->cnsmr_idx_sh_reg_dma >> 32);
2620 2587
2621 ql_init_tx_ring(qdev, tx_ring); 2588 ql_init_tx_ring(qdev, tx_ring);
2622 2589
@@ -2746,14 +2713,14 @@ static void ql_resolve_queues_to_irqs(struct ql_adapter *qdev)
2746 * Outbound queue is for outbound completions only. 2713 * Outbound queue is for outbound completions only.
2747 */ 2714 */
2748 intr_context->handler = qlge_msix_tx_isr; 2715 intr_context->handler = qlge_msix_tx_isr;
2749 sprintf(intr_context->name, "%s-txq-%d", 2716 sprintf(intr_context->name, "%s-tx-%d",
2750 qdev->ndev->name, i); 2717 qdev->ndev->name, i);
2751 } else { 2718 } else {
2752 /* 2719 /*
2753 * Inbound queues handle unicast frames only. 2720 * Inbound queues handle unicast frames only.
2754 */ 2721 */
2755 intr_context->handler = qlge_msix_rx_isr; 2722 intr_context->handler = qlge_msix_rx_isr;
2756 sprintf(intr_context->name, "%s-rxq-%d", 2723 sprintf(intr_context->name, "%s-rx-%d",
2757 qdev->ndev->name, i); 2724 qdev->ndev->name, i);
2758 } 2725 }
2759 } 2726 }
@@ -3247,7 +3214,6 @@ static int qlge_close(struct net_device *ndev)
3247 msleep(1); 3214 msleep(1);
3248 ql_adapter_down(qdev); 3215 ql_adapter_down(qdev);
3249 ql_release_adapter_resources(qdev); 3216 ql_release_adapter_resources(qdev);
3250 ql_free_ring_cb(qdev);
3251 return 0; 3217 return 0;
3252} 3218}
3253 3219
@@ -3273,8 +3239,8 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3273 * This limitation can be removed when requested. 3239 * This limitation can be removed when requested.
3274 */ 3240 */
3275 3241
3276 if (cpu_cnt > 8) 3242 if (cpu_cnt > MAX_CPUS)
3277 cpu_cnt = 8; 3243 cpu_cnt = MAX_CPUS;
3278 3244
3279 /* 3245 /*
3280 * rx_ring[0] is always the default queue. 3246 * rx_ring[0] is always the default queue.
@@ -3294,9 +3260,6 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3294 */ 3260 */
3295 qdev->rx_ring_count = qdev->tx_ring_count + qdev->rss_ring_count + 1; 3261 qdev->rx_ring_count = qdev->tx_ring_count + qdev->rss_ring_count + 1;
3296 3262
3297 if (ql_alloc_ring_cb(qdev))
3298 return -ENOMEM;
3299
3300 for (i = 0; i < qdev->tx_ring_count; i++) { 3263 for (i = 0; i < qdev->tx_ring_count; i++) {
3301 tx_ring = &qdev->tx_ring[i]; 3264 tx_ring = &qdev->tx_ring[i];
3302 memset((void *)tx_ring, 0, sizeof(tx_ring)); 3265 memset((void *)tx_ring, 0, sizeof(tx_ring));
@@ -3393,7 +3356,6 @@ static int qlge_open(struct net_device *ndev)
3393 3356
3394error_up: 3357error_up:
3395 ql_release_adapter_resources(qdev); 3358 ql_release_adapter_resources(qdev);
3396 ql_free_ring_cb(qdev);
3397 return err; 3359 return err;
3398} 3360}
3399 3361
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index cf3a082bc89d..72fd9e97c190 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -49,8 +49,8 @@
49#include <asm/processor.h> 49#include <asm/processor.h>
50 50
51#define DRV_NAME "r6040" 51#define DRV_NAME "r6040"
52#define DRV_VERSION "0.20" 52#define DRV_VERSION "0.21"
53#define DRV_RELDATE "07Jan2009" 53#define DRV_RELDATE "09Jan2009"
54 54
55/* PHY CHIP Address */ 55/* PHY CHIP Address */
56#define PHY1_ADDR 1 /* For MAC1 */ 56#define PHY1_ADDR 1 /* For MAC1 */
@@ -457,22 +457,12 @@ static void r6040_down(struct net_device *dev)
457 iowrite16(adrp[0], ioaddr + MID_0L); 457 iowrite16(adrp[0], ioaddr + MID_0L);
458 iowrite16(adrp[1], ioaddr + MID_0M); 458 iowrite16(adrp[1], ioaddr + MID_0M);
459 iowrite16(adrp[2], ioaddr + MID_0H); 459 iowrite16(adrp[2], ioaddr + MID_0H);
460 free_irq(dev->irq, dev);
461
462 /* Free RX buffer */
463 r6040_free_rxbufs(dev);
464
465 /* Free TX buffer */
466 r6040_free_txbufs(dev);
467
468 /* Free Descriptor memory */
469 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
470 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
471} 460}
472 461
473static int r6040_close(struct net_device *dev) 462static int r6040_close(struct net_device *dev)
474{ 463{
475 struct r6040_private *lp = netdev_priv(dev); 464 struct r6040_private *lp = netdev_priv(dev);
465 struct pci_dev *pdev = lp->pdev;
476 466
477 /* deleted timer */ 467 /* deleted timer */
478 del_timer_sync(&lp->timer); 468 del_timer_sync(&lp->timer);
@@ -481,8 +471,28 @@ static int r6040_close(struct net_device *dev)
481 napi_disable(&lp->napi); 471 napi_disable(&lp->napi);
482 netif_stop_queue(dev); 472 netif_stop_queue(dev);
483 r6040_down(dev); 473 r6040_down(dev);
474
475 free_irq(dev->irq, dev);
476
477 /* Free RX buffer */
478 r6040_free_rxbufs(dev);
479
480 /* Free TX buffer */
481 r6040_free_txbufs(dev);
482
484 spin_unlock_irq(&lp->lock); 483 spin_unlock_irq(&lp->lock);
485 484
485 /* Free Descriptor memory */
486 if (lp->rx_ring) {
487 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
488 lp->rx_ring = 0;
489 }
490
491 if (lp->tx_ring) {
492 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
493 lp->tx_ring = 0;
494 }
495
486 return 0; 496 return 0;
487} 497}
488 498
@@ -1049,6 +1059,7 @@ static const struct net_device_ops r6040_netdev_ops = {
1049 .ndo_set_multicast_list = r6040_multicast_list, 1059 .ndo_set_multicast_list = r6040_multicast_list,
1050 .ndo_change_mtu = eth_change_mtu, 1060 .ndo_change_mtu = eth_change_mtu,
1051 .ndo_validate_addr = eth_validate_addr, 1061 .ndo_validate_addr = eth_validate_addr,
1062 .ndo_set_mac_address = eth_mac_addr,
1052 .ndo_do_ioctl = r6040_ioctl, 1063 .ndo_do_ioctl = r6040_ioctl,
1053 .ndo_tx_timeout = r6040_tx_timeout, 1064 .ndo_tx_timeout = r6040_tx_timeout,
1054#ifdef CONFIG_NET_POLL_CONTROLLER 1065#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1143,8 +1154,10 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1143 1154
1144 /* Some bootloader/BIOSes do not initialize 1155 /* Some bootloader/BIOSes do not initialize
1145 * MAC address, warn about that */ 1156 * MAC address, warn about that */
1146 if (!(adrp[0] || adrp[1] || adrp[2])) 1157 if (!(adrp[0] || adrp[1] || adrp[2])) {
1147 printk(KERN_WARNING DRV_NAME ": MAC address not initialized\n"); 1158 printk(KERN_WARNING DRV_NAME ": MAC address not initialized, generating random\n");
1159 random_ether_addr(dev->dev_addr);
1160 }
1148 1161
1149 /* Link new device into r6040_root_dev */ 1162 /* Link new device into r6040_root_dev */
1150 lp->pdev = pdev; 1163 lp->pdev = pdev;
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index 42fd31276602..8b75bef4a841 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -1408,6 +1408,7 @@ static const struct net_device_ops sc92031_netdev_ops = {
1408 .ndo_set_multicast_list = sc92031_set_multicast_list, 1408 .ndo_set_multicast_list = sc92031_set_multicast_list,
1409 .ndo_change_mtu = eth_change_mtu, 1409 .ndo_change_mtu = eth_change_mtu,
1410 .ndo_validate_addr = eth_validate_addr, 1410 .ndo_validate_addr = eth_validate_addr,
1411 .ndo_set_mac_address = eth_mac_addr,
1411 .ndo_tx_timeout = sc92031_tx_timeout, 1412 .ndo_tx_timeout = sc92031_tx_timeout,
1412#ifdef CONFIG_NET_POLL_CONTROLLER 1413#ifdef CONFIG_NET_POLL_CONTROLLER
1413 .ndo_poll_controller = sc92031_poll_controller, 1414 .ndo_poll_controller = sc92031_poll_controller,
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index b9768760fae7..9ecb77da9545 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -636,10 +636,11 @@ static void tenxpress_phy_fini(struct efx_nic *efx)
636{ 636{
637 int reg; 637 int reg;
638 638
639 if (efx->phy_type == PHY_TYPE_SFT9001B) { 639 if (efx->phy_type == PHY_TYPE_SFT9001B)
640 device_remove_file(&efx->pci_dev->dev, 640 device_remove_file(&efx->pci_dev->dev,
641 &dev_attr_phy_short_reach); 641 &dev_attr_phy_short_reach);
642 } else { 642
643 if (efx->phy_type == PHY_TYPE_SFX7101) {
643 /* Power down the LNPGA */ 644 /* Power down the LNPGA */
644 reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN); 645 reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN);
645 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD, 646 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index 4acd41a093ad..be4465bc0a69 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -389,6 +389,7 @@ static const struct net_device_ops sis900_netdev_ops = {
389 .ndo_set_multicast_list = set_rx_mode, 389 .ndo_set_multicast_list = set_rx_mode,
390 .ndo_change_mtu = eth_change_mtu, 390 .ndo_change_mtu = eth_change_mtu,
391 .ndo_validate_addr = eth_validate_addr, 391 .ndo_validate_addr = eth_validate_addr,
392 .ndo_set_mac_address = eth_mac_addr,
392 .ndo_do_ioctl = mii_ioctl, 393 .ndo_do_ioctl = mii_ioctl,
393 .ndo_tx_timeout = sis900_tx_timeout, 394 .ndo_tx_timeout = sis900_tx_timeout,
394#ifdef CONFIG_NET_POLL_CONTROLLER 395#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -508,10 +509,10 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
508 else 509 else
509 ret = sis900_get_mac_addr(pci_dev, net_dev); 510 ret = sis900_get_mac_addr(pci_dev, net_dev);
510 511
511 if (ret == 0) { 512 if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) {
512 printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name); 513 random_ether_addr(net_dev->dev_addr);
513 ret = -ENODEV; 514 printk(KERN_WARNING "%s: Unreadable or invalid MAC address,"
514 goto err_unmap_rx; 515 "using random generated one\n", dev_name);
515 } 516 }
516 517
517 /* 630ET : set the mii access mode as software-mode */ 518 /* 630ET : set the mii access mode as software-mode */
diff --git a/drivers/net/smc-mca.c b/drivers/net/smc-mca.c
index 404b80e5ba11..8d36d40649ef 100644
--- a/drivers/net/smc-mca.c
+++ b/drivers/net/smc-mca.c
@@ -192,6 +192,7 @@ static const struct net_device_ops ultramca_netdev_ops = {
192 .ndo_get_stats = ei_get_stats, 192 .ndo_get_stats = ei_get_stats,
193 .ndo_set_multicast_list = ei_set_multicast_list, 193 .ndo_set_multicast_list = ei_set_multicast_list,
194 .ndo_validate_addr = eth_validate_addr, 194 .ndo_validate_addr = eth_validate_addr,
195 .ndo_set_mac_address = eth_mac_addr,
195 .ndo_change_mtu = eth_change_mtu, 196 .ndo_change_mtu = eth_change_mtu,
196#ifdef CONFIG_NET_POLL_CONTROLLER 197#ifdef CONFIG_NET_POLL_CONTROLLER
197 .ndo_poll_controller = ei_poll, 198 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index b3866089a206..2033fee3143a 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -196,6 +196,7 @@ static const struct net_device_ops ultra_netdev_ops = {
196 .ndo_get_stats = ei_get_stats, 196 .ndo_get_stats = ei_get_stats,
197 .ndo_set_multicast_list = ei_set_multicast_list, 197 .ndo_set_multicast_list = ei_set_multicast_list,
198 .ndo_validate_addr = eth_validate_addr, 198 .ndo_validate_addr = eth_validate_addr,
199 .ndo_set_mac_address = eth_mac_addr,
199 .ndo_change_mtu = eth_change_mtu, 200 .ndo_change_mtu = eth_change_mtu,
200#ifdef CONFIG_NET_POLL_CONTROLLER 201#ifdef CONFIG_NET_POLL_CONTROLLER
201 .ndo_poll_controller = ei_poll, 202 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index dc3f1108884d..f513bdf1c887 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -144,6 +144,7 @@ static inline u32 smsc911x_reg_read(struct smsc911x_data *pdata, u32 reg)
144 } 144 }
145 145
146 BUG(); 146 BUG();
147 return 0;
147} 148}
148 149
149static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg, 150static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg,
@@ -1740,6 +1741,7 @@ static const struct net_device_ops smsc911x_netdev_ops = {
1740 .ndo_set_multicast_list = smsc911x_set_multicast_list, 1741 .ndo_set_multicast_list = smsc911x_set_multicast_list,
1741 .ndo_do_ioctl = smsc911x_do_ioctl, 1742 .ndo_do_ioctl = smsc911x_do_ioctl,
1742 .ndo_validate_addr = eth_validate_addr, 1743 .ndo_validate_addr = eth_validate_addr,
1744 .ndo_set_mac_address = eth_mac_addr,
1743#ifdef CONFIG_NET_POLL_CONTROLLER 1745#ifdef CONFIG_NET_POLL_CONTROLLER
1744 .ndo_poll_controller = smsc911x_poll_controller, 1746 .ndo_poll_controller = smsc911x_poll_controller,
1745#endif 1747#endif
@@ -1967,7 +1969,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
1967 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF); 1969 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF);
1968 1970
1969 retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED, 1971 retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED,
1970 SMSC_CHIPNAME, dev); 1972 dev->name, dev);
1971 if (retval) { 1973 if (retval) {
1972 SMSC_WARNING(PROBE, 1974 SMSC_WARNING(PROBE,
1973 "Unable to claim requested irq: %d", dev->irq); 1975 "Unable to claim requested irq: %d", dev->irq);
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c
index 27e017d96966..c14a4c6452c7 100644
--- a/drivers/net/smsc9420.c
+++ b/drivers/net/smsc9420.c
@@ -1551,6 +1551,7 @@ static const struct net_device_ops smsc9420_netdev_ops = {
1551 .ndo_set_multicast_list = smsc9420_set_multicast_list, 1551 .ndo_set_multicast_list = smsc9420_set_multicast_list,
1552 .ndo_do_ioctl = smsc9420_do_ioctl, 1552 .ndo_do_ioctl = smsc9420_do_ioctl,
1553 .ndo_validate_addr = eth_validate_addr, 1553 .ndo_validate_addr = eth_validate_addr,
1554 .ndo_set_mac_address = eth_mac_addr,
1554#ifdef CONFIG_NET_POLL_CONTROLLER 1555#ifdef CONFIG_NET_POLL_CONTROLLER
1555 .ndo_poll_controller = smsc9420_poll_controller, 1556 .ndo_poll_controller = smsc9420_poll_controller,
1556#endif /* CONFIG_NET_POLL_CONTROLLER */ 1557#endif /* CONFIG_NET_POLL_CONTROLLER */
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 7d5a1303e30d..11441225bf41 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -442,40 +442,30 @@ static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
442{ 442{
443 struct ucc_fast_private *uccf; 443 struct ucc_fast_private *uccf;
444 struct ucc_geth __iomem *ug_regs; 444 struct ucc_geth __iomem *ug_regs;
445 u32 maccfg2, uccm;
446 445
447 uccf = ugeth->uccf; 446 uccf = ugeth->uccf;
448 ug_regs = ugeth->ug_regs; 447 ug_regs = ugeth->ug_regs;
449 448
450 /* Enable interrupts for magic packet detection */ 449 /* Enable interrupts for magic packet detection */
451 uccm = in_be32(uccf->p_uccm); 450 setbits32(uccf->p_uccm, UCC_GETH_UCCE_MPD);
452 uccm |= UCCE_MPD;
453 out_be32(uccf->p_uccm, uccm);
454 451
455 /* Enable magic packet detection */ 452 /* Enable magic packet detection */
456 maccfg2 = in_be32(&ug_regs->maccfg2); 453 setbits32(&ug_regs->maccfg2, MACCFG2_MPE);
457 maccfg2 |= MACCFG2_MPE;
458 out_be32(&ug_regs->maccfg2, maccfg2);
459} 454}
460 455
461static void magic_packet_detection_disable(struct ucc_geth_private *ugeth) 456static void magic_packet_detection_disable(struct ucc_geth_private *ugeth)
462{ 457{
463 struct ucc_fast_private *uccf; 458 struct ucc_fast_private *uccf;
464 struct ucc_geth __iomem *ug_regs; 459 struct ucc_geth __iomem *ug_regs;
465 u32 maccfg2, uccm;
466 460
467 uccf = ugeth->uccf; 461 uccf = ugeth->uccf;
468 ug_regs = ugeth->ug_regs; 462 ug_regs = ugeth->ug_regs;
469 463
470 /* Disable interrupts for magic packet detection */ 464 /* Disable interrupts for magic packet detection */
471 uccm = in_be32(uccf->p_uccm); 465 clrbits32(uccf->p_uccm, UCC_GETH_UCCE_MPD);
472 uccm &= ~UCCE_MPD;
473 out_be32(uccf->p_uccm, uccm);
474 466
475 /* Disable magic packet detection */ 467 /* Disable magic packet detection */
476 maccfg2 = in_be32(&ug_regs->maccfg2); 468 clrbits32(&ug_regs->maccfg2, MACCFG2_MPE);
477 maccfg2 &= ~MACCFG2_MPE;
478 out_be32(&ug_regs->maccfg2, maccfg2);
479} 469}
480#endif /* MAGIC_PACKET */ 470#endif /* MAGIC_PACKET */
481 471
@@ -585,7 +575,8 @@ static void get_statistics(struct ucc_geth_private *ugeth,
585 575
586 /* Hardware only if user handed pointer and driver actually 576 /* Hardware only if user handed pointer and driver actually
587 gathers hardware statistics */ 577 gathers hardware statistics */
588 if (hardware_statistics && (in_be32(&uf_regs->upsmr) & UPSMR_HSE)) { 578 if (hardware_statistics &&
579 (in_be32(&uf_regs->upsmr) & UCC_GETH_UPSMR_HSE)) {
589 hardware_statistics->tx64 = in_be32(&ug_regs->tx64); 580 hardware_statistics->tx64 = in_be32(&ug_regs->tx64);
590 hardware_statistics->tx127 = in_be32(&ug_regs->tx127); 581 hardware_statistics->tx127 = in_be32(&ug_regs->tx127);
591 hardware_statistics->tx255 = in_be32(&ug_regs->tx255); 582 hardware_statistics->tx255 = in_be32(&ug_regs->tx255);
@@ -1181,9 +1172,7 @@ int init_flow_control_params(u32 automatic_flow_control_mode,
1181 out_be32(uempr_register, value); 1172 out_be32(uempr_register, value);
1182 1173
1183 /* Set UPSMR register */ 1174 /* Set UPSMR register */
1184 value = in_be32(upsmr_register); 1175 setbits32(upsmr_register, automatic_flow_control_mode);
1185 value |= automatic_flow_control_mode;
1186 out_be32(upsmr_register, value);
1187 1176
1188 value = in_be32(maccfg1_register); 1177 value = in_be32(maccfg1_register);
1189 if (rx_flow_control_enable) 1178 if (rx_flow_control_enable)
@@ -1200,14 +1189,11 @@ static int init_hw_statistics_gathering_mode(int enable_hardware_statistics,
1200 u32 __iomem *upsmr_register, 1189 u32 __iomem *upsmr_register,
1201 u16 __iomem *uescr_register) 1190 u16 __iomem *uescr_register)
1202{ 1191{
1203 u32 upsmr_value = 0;
1204 u16 uescr_value = 0; 1192 u16 uescr_value = 0;
1193
1205 /* Enable hardware statistics gathering if requested */ 1194 /* Enable hardware statistics gathering if requested */
1206 if (enable_hardware_statistics) { 1195 if (enable_hardware_statistics)
1207 upsmr_value = in_be32(upsmr_register); 1196 setbits32(upsmr_register, UCC_GETH_UPSMR_HSE);
1208 upsmr_value |= UPSMR_HSE;
1209 out_be32(upsmr_register, upsmr_value);
1210 }
1211 1197
1212 /* Clear hardware statistics counters */ 1198 /* Clear hardware statistics counters */
1213 uescr_value = in_be16(uescr_register); 1199 uescr_value = in_be16(uescr_register);
@@ -1233,23 +1219,17 @@ static int init_firmware_statistics_gathering_mode(int
1233{ 1219{
1234 /* Note: this function does not check if */ 1220 /* Note: this function does not check if */
1235 /* the parameters it receives are NULL */ 1221 /* the parameters it receives are NULL */
1236 u16 temoder_value;
1237 u32 remoder_value;
1238 1222
1239 if (enable_tx_firmware_statistics) { 1223 if (enable_tx_firmware_statistics) {
1240 out_be32(tx_rmon_base_ptr, 1224 out_be32(tx_rmon_base_ptr,
1241 tx_firmware_statistics_structure_address); 1225 tx_firmware_statistics_structure_address);
1242 temoder_value = in_be16(temoder_register); 1226 setbits16(temoder_register, TEMODER_TX_RMON_STATISTICS_ENABLE);
1243 temoder_value |= TEMODER_TX_RMON_STATISTICS_ENABLE;
1244 out_be16(temoder_register, temoder_value);
1245 } 1227 }
1246 1228
1247 if (enable_rx_firmware_statistics) { 1229 if (enable_rx_firmware_statistics) {
1248 out_be32(rx_rmon_base_ptr, 1230 out_be32(rx_rmon_base_ptr,
1249 rx_firmware_statistics_structure_address); 1231 rx_firmware_statistics_structure_address);
1250 remoder_value = in_be32(remoder_register); 1232 setbits32(remoder_register, REMODER_RX_RMON_STATISTICS_ENABLE);
1251 remoder_value |= REMODER_RX_RMON_STATISTICS_ENABLE;
1252 out_be32(remoder_register, remoder_value);
1253 } 1233 }
1254 1234
1255 return 0; 1235 return 0;
@@ -1316,15 +1296,12 @@ static int init_check_frame_length_mode(int length_check,
1316static int init_preamble_length(u8 preamble_length, 1296static int init_preamble_length(u8 preamble_length,
1317 u32 __iomem *maccfg2_register) 1297 u32 __iomem *maccfg2_register)
1318{ 1298{
1319 u32 value = 0;
1320
1321 if ((preamble_length < 3) || (preamble_length > 7)) 1299 if ((preamble_length < 3) || (preamble_length > 7))
1322 return -EINVAL; 1300 return -EINVAL;
1323 1301
1324 value = in_be32(maccfg2_register); 1302 clrsetbits_be32(maccfg2_register, MACCFG2_PREL_MASK,
1325 value &= ~MACCFG2_PREL_MASK; 1303 preamble_length << MACCFG2_PREL_SHIFT);
1326 value |= (preamble_length << MACCFG2_PREL_SHIFT); 1304
1327 out_be32(maccfg2_register, value);
1328 return 0; 1305 return 0;
1329} 1306}
1330 1307
@@ -1337,19 +1314,19 @@ static int init_rx_parameters(int reject_broadcast,
1337 value = in_be32(upsmr_register); 1314 value = in_be32(upsmr_register);
1338 1315
1339 if (reject_broadcast) 1316 if (reject_broadcast)
1340 value |= UPSMR_BRO; 1317 value |= UCC_GETH_UPSMR_BRO;
1341 else 1318 else
1342 value &= ~UPSMR_BRO; 1319 value &= ~UCC_GETH_UPSMR_BRO;
1343 1320
1344 if (receive_short_frames) 1321 if (receive_short_frames)
1345 value |= UPSMR_RSH; 1322 value |= UCC_GETH_UPSMR_RSH;
1346 else 1323 else
1347 value &= ~UPSMR_RSH; 1324 value &= ~UCC_GETH_UPSMR_RSH;
1348 1325
1349 if (promiscuous) 1326 if (promiscuous)
1350 value |= UPSMR_PRO; 1327 value |= UCC_GETH_UPSMR_PRO;
1351 else 1328 else
1352 value &= ~UPSMR_PRO; 1329 value &= ~UCC_GETH_UPSMR_PRO;
1353 1330
1354 out_be32(upsmr_register, value); 1331 out_be32(upsmr_register, value);
1355 1332
@@ -1410,26 +1387,27 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1410 1387
1411 /* Set UPSMR */ 1388 /* Set UPSMR */
1412 upsmr = in_be32(&uf_regs->upsmr); 1389 upsmr = in_be32(&uf_regs->upsmr);
1413 upsmr &= ~(UPSMR_RPM | UPSMR_R10M | UPSMR_TBIM | UPSMR_RMM); 1390 upsmr &= ~(UCC_GETH_UPSMR_RPM | UCC_GETH_UPSMR_R10M |
1391 UCC_GETH_UPSMR_TBIM | UCC_GETH_UPSMR_RMM);
1414 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) || 1392 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) ||
1415 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) || 1393 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) ||
1416 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) || 1394 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
1417 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) || 1395 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
1418 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) || 1396 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1419 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1397 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1420 upsmr |= UPSMR_RPM; 1398 upsmr |= UCC_GETH_UPSMR_RPM;
1421 switch (ugeth->max_speed) { 1399 switch (ugeth->max_speed) {
1422 case SPEED_10: 1400 case SPEED_10:
1423 upsmr |= UPSMR_R10M; 1401 upsmr |= UCC_GETH_UPSMR_R10M;
1424 /* FALLTHROUGH */ 1402 /* FALLTHROUGH */
1425 case SPEED_100: 1403 case SPEED_100:
1426 if (ugeth->phy_interface != PHY_INTERFACE_MODE_RTBI) 1404 if (ugeth->phy_interface != PHY_INTERFACE_MODE_RTBI)
1427 upsmr |= UPSMR_RMM; 1405 upsmr |= UCC_GETH_UPSMR_RMM;
1428 } 1406 }
1429 } 1407 }
1430 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) || 1408 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) ||
1431 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1409 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1432 upsmr |= UPSMR_TBIM; 1410 upsmr |= UCC_GETH_UPSMR_TBIM;
1433 } 1411 }
1434 out_be32(&uf_regs->upsmr, upsmr); 1412 out_be32(&uf_regs->upsmr, upsmr);
1435 1413
@@ -1517,9 +1495,9 @@ static void adjust_link(struct net_device *dev)
1517 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) || 1495 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1518 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1496 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1519 if (phydev->speed == SPEED_10) 1497 if (phydev->speed == SPEED_10)
1520 upsmr |= UPSMR_R10M; 1498 upsmr |= UCC_GETH_UPSMR_R10M;
1521 else 1499 else
1522 upsmr &= ~(UPSMR_R10M); 1500 upsmr &= ~UCC_GETH_UPSMR_R10M;
1523 } 1501 }
1524 break; 1502 break;
1525 default: 1503 default:
@@ -1602,10 +1580,8 @@ static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1602 uccf = ugeth->uccf; 1580 uccf = ugeth->uccf;
1603 1581
1604 /* Mask GRACEFUL STOP TX interrupt bit and clear it */ 1582 /* Mask GRACEFUL STOP TX interrupt bit and clear it */
1605 temp = in_be32(uccf->p_uccm); 1583 clrbits32(uccf->p_uccm, UCC_GETH_UCCE_GRA);
1606 temp &= ~UCCE_GRA; 1584 out_be32(uccf->p_ucce, UCC_GETH_UCCE_GRA); /* clear by writing 1 */
1607 out_be32(uccf->p_uccm, temp);
1608 out_be32(uccf->p_ucce, UCCE_GRA); /* clear by writing 1 */
1609 1585
1610 /* Issue host command */ 1586 /* Issue host command */
1611 cecr_subblock = 1587 cecr_subblock =
@@ -1617,7 +1593,7 @@ static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1617 do { 1593 do {
1618 msleep(10); 1594 msleep(10);
1619 temp = in_be32(uccf->p_ucce); 1595 temp = in_be32(uccf->p_ucce);
1620 } while (!(temp & UCCE_GRA) && --i); 1596 } while (!(temp & UCC_GETH_UCCE_GRA) && --i);
1621 1597
1622 uccf->stopped_tx = 1; 1598 uccf->stopped_tx = 1;
1623 1599
@@ -1975,12 +1951,9 @@ static void ucc_geth_set_multi(struct net_device *dev)
1975 uf_regs = ugeth->uccf->uf_regs; 1951 uf_regs = ugeth->uccf->uf_regs;
1976 1952
1977 if (dev->flags & IFF_PROMISC) { 1953 if (dev->flags & IFF_PROMISC) {
1978 1954 setbits32(&uf_regs->upsmr, UCC_GETH_UPSMR_PRO);
1979 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr) | UPSMR_PRO);
1980
1981 } else { 1955 } else {
1982 1956 clrbits32(&uf_regs->upsmr, UCC_GETH_UPSMR_PRO);
1983 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr)&~UPSMR_PRO);
1984 1957
1985 p_82xx_addr_filt = 1958 p_82xx_addr_filt =
1986 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth-> 1959 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth->
@@ -2020,7 +1993,6 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2020{ 1993{
2021 struct ucc_geth __iomem *ug_regs = ugeth->ug_regs; 1994 struct ucc_geth __iomem *ug_regs = ugeth->ug_regs;
2022 struct phy_device *phydev = ugeth->phydev; 1995 struct phy_device *phydev = ugeth->phydev;
2023 u32 tempval;
2024 1996
2025 ugeth_vdbg("%s: IN", __func__); 1997 ugeth_vdbg("%s: IN", __func__);
2026 1998
@@ -2037,9 +2009,7 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2037 out_be32(ugeth->uccf->p_ucce, 0xffffffff); 2009 out_be32(ugeth->uccf->p_ucce, 0xffffffff);
2038 2010
2039 /* Disable Rx and Tx */ 2011 /* Disable Rx and Tx */
2040 tempval = in_be32(&ug_regs->maccfg1); 2012 clrbits32(&ug_regs->maccfg1, MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2041 tempval &= ~(MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2042 out_be32(&ug_regs->maccfg1, tempval);
2043 2013
2044 ucc_geth_memclean(ugeth); 2014 ucc_geth_memclean(ugeth);
2045} 2015}
@@ -2153,10 +2123,10 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2153 /* Generate uccm_mask for receive */ 2123 /* Generate uccm_mask for receive */
2154 uf_info->uccm_mask = ug_info->eventRegMask & UCCE_OTHER;/* Errors */ 2124 uf_info->uccm_mask = ug_info->eventRegMask & UCCE_OTHER;/* Errors */
2155 for (i = 0; i < ug_info->numQueuesRx; i++) 2125 for (i = 0; i < ug_info->numQueuesRx; i++)
2156 uf_info->uccm_mask |= (UCCE_RXBF_SINGLE_MASK << i); 2126 uf_info->uccm_mask |= (UCC_GETH_UCCE_RXF0 << i);
2157 2127
2158 for (i = 0; i < ug_info->numQueuesTx; i++) 2128 for (i = 0; i < ug_info->numQueuesTx; i++)
2159 uf_info->uccm_mask |= (UCCE_TXBF_SINGLE_MASK << i); 2129 uf_info->uccm_mask |= (UCC_GETH_UCCE_TXB0 << i);
2160 /* Initialize the general fast UCC block. */ 2130 /* Initialize the general fast UCC block. */
2161 if (ucc_fast_init(uf_info, &ugeth->uccf)) { 2131 if (ucc_fast_init(uf_info, &ugeth->uccf)) {
2162 if (netif_msg_probe(ugeth)) 2132 if (netif_msg_probe(ugeth))
@@ -2185,7 +2155,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2185 struct ucc_geth __iomem *ug_regs; 2155 struct ucc_geth __iomem *ug_regs;
2186 int ret_val = -EINVAL; 2156 int ret_val = -EINVAL;
2187 u32 remoder = UCC_GETH_REMODER_INIT; 2157 u32 remoder = UCC_GETH_REMODER_INIT;
2188 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1; 2158 u32 init_enet_pram_offset, cecr_subblock, command;
2189 u32 ifstat, i, j, size, l2qt, l3qt, length; 2159 u32 ifstat, i, j, size, l2qt, l3qt, length;
2190 u16 temoder = UCC_GETH_TEMODER_INIT; 2160 u16 temoder = UCC_GETH_TEMODER_INIT;
2191 u16 test; 2161 u16 test;
@@ -2281,10 +2251,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2281 &uf_regs->upsmr, 2251 &uf_regs->upsmr,
2282 &ug_regs->uempr, &ug_regs->maccfg1); 2252 &ug_regs->uempr, &ug_regs->maccfg1);
2283 2253
2284 maccfg1 = in_be32(&ug_regs->maccfg1); 2254 setbits32(&ug_regs->maccfg1, MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2285 maccfg1 |= MACCFG1_ENABLE_RX;
2286 maccfg1 |= MACCFG1_ENABLE_TX;
2287 out_be32(&ug_regs->maccfg1, maccfg1);
2288 2255
2289 /* Set IPGIFG */ 2256 /* Set IPGIFG */
2290 /* For more details see the hardware spec. */ 2257 /* For more details see the hardware spec. */
@@ -3274,7 +3241,6 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3274static int ucc_geth_poll(struct napi_struct *napi, int budget) 3241static int ucc_geth_poll(struct napi_struct *napi, int budget)
3275{ 3242{
3276 struct ucc_geth_private *ugeth = container_of(napi, struct ucc_geth_private, napi); 3243 struct ucc_geth_private *ugeth = container_of(napi, struct ucc_geth_private, napi);
3277 struct net_device *dev = ugeth->dev;
3278 struct ucc_geth_info *ug_info; 3244 struct ucc_geth_info *ug_info;
3279 int howmany, i; 3245 int howmany, i;
3280 3246
@@ -3285,14 +3251,8 @@ static int ucc_geth_poll(struct napi_struct *napi, int budget)
3285 howmany += ucc_geth_rx(ugeth, i, budget - howmany); 3251 howmany += ucc_geth_rx(ugeth, i, budget - howmany);
3286 3252
3287 if (howmany < budget) { 3253 if (howmany < budget) {
3288 struct ucc_fast_private *uccf;
3289 u32 uccm;
3290
3291 netif_rx_complete(napi); 3254 netif_rx_complete(napi);
3292 uccf = ugeth->uccf; 3255 setbits32(ugeth->uccf->p_uccm, UCCE_RX_EVENTS);
3293 uccm = in_be32(uccf->p_uccm);
3294 uccm |= UCCE_RX_EVENTS;
3295 out_be32(uccf->p_uccm, uccm);
3296 } 3256 }
3297 3257
3298 return howmany; 3258 return howmany;
@@ -3332,7 +3292,7 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3332 /* Tx event processing */ 3292 /* Tx event processing */
3333 if (ucce & UCCE_TX_EVENTS) { 3293 if (ucce & UCCE_TX_EVENTS) {
3334 spin_lock(&ugeth->lock); 3294 spin_lock(&ugeth->lock);
3335 tx_mask = UCCE_TXBF_SINGLE_MASK; 3295 tx_mask = UCC_GETH_UCCE_TXB0;
3336 for (i = 0; i < ug_info->numQueuesTx; i++) { 3296 for (i = 0; i < ug_info->numQueuesTx; i++) {
3337 if (ucce & tx_mask) 3297 if (ucce & tx_mask)
3338 ucc_geth_tx(dev, i); 3298 ucc_geth_tx(dev, i);
@@ -3344,12 +3304,10 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3344 3304
3345 /* Errors and other events */ 3305 /* Errors and other events */
3346 if (ucce & UCCE_OTHER) { 3306 if (ucce & UCCE_OTHER) {
3347 if (ucce & UCCE_BSY) { 3307 if (ucce & UCC_GETH_UCCE_BSY)
3348 dev->stats.rx_errors++; 3308 dev->stats.rx_errors++;
3349 } 3309 if (ucce & UCC_GETH_UCCE_TXE)
3350 if (ucce & UCCE_TXE) {
3351 dev->stats.tx_errors++; 3310 dev->stats.tx_errors++;
3352 }
3353 } 3311 }
3354 3312
3355 return IRQ_HANDLED; 3313 return IRQ_HANDLED;
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index d74d2f7cb739..8f699cb773ee 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -162,92 +162,27 @@ struct ucc_geth {
162 boundary */ 162 boundary */
163 163
164/* UCC GETH Event Register */ 164/* UCC GETH Event Register */
165#define UCCE_MPD 0x80000000 /* Magic packet 165#define UCCE_TXB (UCC_GETH_UCCE_TXB7 | UCC_GETH_UCCE_TXB6 | \
166 detection */ 166 UCC_GETH_UCCE_TXB5 | UCC_GETH_UCCE_TXB4 | \
167#define UCCE_SCAR 0x40000000 167 UCC_GETH_UCCE_TXB3 | UCC_GETH_UCCE_TXB2 | \
168#define UCCE_GRA 0x20000000 /* Tx graceful 168 UCC_GETH_UCCE_TXB1 | UCC_GETH_UCCE_TXB0)
169 stop 169
170 complete */ 170#define UCCE_RXB (UCC_GETH_UCCE_RXB7 | UCC_GETH_UCCE_RXB6 | \
171#define UCCE_CBPR 0x10000000 171 UCC_GETH_UCCE_RXB5 | UCC_GETH_UCCE_RXB4 | \
172#define UCCE_BSY 0x08000000 172 UCC_GETH_UCCE_RXB3 | UCC_GETH_UCCE_RXB2 | \
173#define UCCE_RXC 0x04000000 173 UCC_GETH_UCCE_RXB1 | UCC_GETH_UCCE_RXB0)
174#define UCCE_TXC 0x02000000 174
175#define UCCE_TXE 0x01000000 175#define UCCE_RXF (UCC_GETH_UCCE_RXF7 | UCC_GETH_UCCE_RXF6 | \
176#define UCCE_TXB7 0x00800000 176 UCC_GETH_UCCE_RXF5 | UCC_GETH_UCCE_RXF4 | \
177#define UCCE_TXB6 0x00400000 177 UCC_GETH_UCCE_RXF3 | UCC_GETH_UCCE_RXF2 | \
178#define UCCE_TXB5 0x00200000 178 UCC_GETH_UCCE_RXF1 | UCC_GETH_UCCE_RXF0)
179#define UCCE_TXB4 0x00100000 179
180#define UCCE_TXB3 0x00080000 180#define UCCE_OTHER (UCC_GETH_UCCE_SCAR | UCC_GETH_UCCE_GRA | \
181#define UCCE_TXB2 0x00040000 181 UCC_GETH_UCCE_CBPR | UCC_GETH_UCCE_BSY | \
182#define UCCE_TXB1 0x00020000 182 UCC_GETH_UCCE_RXC | UCC_GETH_UCCE_TXC | UCC_GETH_UCCE_TXE)
183#define UCCE_TXB0 0x00010000 183
184#define UCCE_RXB7 0x00008000 184#define UCCE_RX_EVENTS (UCCE_RXF | UCC_GETH_UCCE_BSY)
185#define UCCE_RXB6 0x00004000 185#define UCCE_TX_EVENTS (UCCE_TXB | UCC_GETH_UCCE_TXE)
186#define UCCE_RXB5 0x00002000
187#define UCCE_RXB4 0x00001000
188#define UCCE_RXB3 0x00000800
189#define UCCE_RXB2 0x00000400
190#define UCCE_RXB1 0x00000200
191#define UCCE_RXB0 0x00000100
192#define UCCE_RXF7 0x00000080
193#define UCCE_RXF6 0x00000040
194#define UCCE_RXF5 0x00000020
195#define UCCE_RXF4 0x00000010
196#define UCCE_RXF3 0x00000008
197#define UCCE_RXF2 0x00000004
198#define UCCE_RXF1 0x00000002
199#define UCCE_RXF0 0x00000001
200
201#define UCCE_RXBF_SINGLE_MASK (UCCE_RXF0)
202#define UCCE_TXBF_SINGLE_MASK (UCCE_TXB0)
203
204#define UCCE_TXB (UCCE_TXB7 | UCCE_TXB6 | UCCE_TXB5 | UCCE_TXB4 |\
205 UCCE_TXB3 | UCCE_TXB2 | UCCE_TXB1 | UCCE_TXB0)
206#define UCCE_RXB (UCCE_RXB7 | UCCE_RXB6 | UCCE_RXB5 | UCCE_RXB4 |\
207 UCCE_RXB3 | UCCE_RXB2 | UCCE_RXB1 | UCCE_RXB0)
208#define UCCE_RXF (UCCE_RXF7 | UCCE_RXF6 | UCCE_RXF5 | UCCE_RXF4 |\
209 UCCE_RXF3 | UCCE_RXF2 | UCCE_RXF1 | UCCE_RXF0)
210#define UCCE_OTHER (UCCE_SCAR | UCCE_GRA | UCCE_CBPR | UCCE_BSY |\
211 UCCE_RXC | UCCE_TXC | UCCE_TXE)
212
213#define UCCE_RX_EVENTS (UCCE_RXF | UCCE_BSY)
214#define UCCE_TX_EVENTS (UCCE_TXB | UCCE_TXE)
215
216/* UCC GETH UPSMR (Protocol Specific Mode Register) */
217#define UPSMR_ECM 0x04000000 /* Enable CAM
218 Miss or
219 Enable
220 Filtering
221 Miss */
222#define UPSMR_HSE 0x02000000 /* Hardware
223 Statistics
224 Enable */
225#define UPSMR_PRO 0x00400000 /* Promiscuous*/
226#define UPSMR_CAP 0x00200000 /* CAM polarity
227 */
228#define UPSMR_RSH 0x00100000 /* Receive
229 Short Frames
230 */
231#define UPSMR_RPM 0x00080000 /* Reduced Pin
232 Mode
233 interfaces */
234#define UPSMR_R10M 0x00040000 /* RGMII/RMII
235 10 Mode */
236#define UPSMR_RLPB 0x00020000 /* RMII
237 Loopback
238 Mode */
239#define UPSMR_TBIM 0x00010000 /* Ten-bit
240 Interface
241 Mode */
242#define UPSMR_RMM 0x00001000 /* RMII/RGMII
243 Mode */
244#define UPSMR_CAM 0x00000400 /* CAM Address
245 Matching */
246#define UPSMR_BRO 0x00000200 /* Broadcast
247 Address */
248#define UPSMR_RES1 0x00002000 /* Reserved
249 feild - must
250 be 1 */
251 186
252/* UCC GETH MACCFG1 (MAC Configuration 1 Register) */ 187/* UCC GETH MACCFG1 (MAC Configuration 1 Register) */
253#define MACCFG1_FLOW_RX 0x00000020 /* Flow Control 188#define MACCFG1_FLOW_RX 0x00000020 /* Flow Control
@@ -945,9 +880,10 @@ struct ucc_geth_hardware_statistics {
945#define UCC_GETH_REMODER_INIT 0 /* bits that must be 880#define UCC_GETH_REMODER_INIT 0 /* bits that must be
946 set */ 881 set */
947#define UCC_GETH_TEMODER_INIT 0xC000 /* bits that must */ 882#define UCC_GETH_TEMODER_INIT 0xC000 /* bits that must */
948#define UCC_GETH_UPSMR_INIT (UPSMR_RES1) /* Start value 883
949 for this 884/* Initial value for UPSMR */
950 register */ 885#define UCC_GETH_UPSMR_INIT UCC_GETH_UPSMR_RES1
886
951#define UCC_GETH_MACCFG1_INIT 0 887#define UCC_GETH_MACCFG1_INIT 0
952#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1) 888#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1)
953 889
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index c4918b86ed19..0d0fa91c0251 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1297,6 +1297,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
1297 /* setup */ 1297 /* setup */
1298 spin_lock_irq(&serial->serial_lock); 1298 spin_lock_irq(&serial->serial_lock);
1299 tty->driver_data = serial; 1299 tty->driver_data = serial;
1300 tty_kref_put(serial->tty);
1300 serial->tty = tty_kref_get(tty); 1301 serial->tty = tty_kref_get(tty);
1301 spin_unlock_irq(&serial->serial_lock); 1302 spin_unlock_irq(&serial->serial_lock);
1302 1303
@@ -1792,8 +1793,8 @@ static int mux_device_request(struct hso_serial *serial, u8 type, u16 port,
1792 1793
1793 /* initialize */ 1794 /* initialize */
1794 ctrl_req->wValue = 0; 1795 ctrl_req->wValue = 0;
1795 ctrl_req->wIndex = hso_port_to_mux(port); 1796 ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port));
1796 ctrl_req->wLength = size; 1797 ctrl_req->wLength = cpu_to_le16(size);
1797 1798
1798 if (type == USB_CDC_GET_ENCAPSULATED_RESPONSE) { 1799 if (type == USB_CDC_GET_ENCAPSULATED_RESPONSE) {
1799 /* Reading command */ 1800 /* Reading command */
@@ -2043,9 +2044,8 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
2043 return -2; 2044 return -2;
2044 } 2045 }
2045 2046
2046 spin_lock(&serial->serial_lock); 2047 /* All callers to put_rxbuf_data hold serial_lock */
2047 tty = tty_kref_get(serial->tty); 2048 tty = tty_kref_get(serial->tty);
2048 spin_unlock(&serial->serial_lock);
2049 2049
2050 /* Push data to tty */ 2050 /* Push data to tty */
2051 if (tty) { 2051 if (tty) {
@@ -2053,8 +2053,10 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
2053 serial->curr_rx_urb_offset; 2053 serial->curr_rx_urb_offset;
2054 D1("data to push to tty"); 2054 D1("data to push to tty");
2055 while (write_length_remaining) { 2055 while (write_length_remaining) {
2056 if (test_bit(TTY_THROTTLED, &tty->flags)) 2056 if (test_bit(TTY_THROTTLED, &tty->flags)) {
2057 tty_kref_put(tty);
2057 return -1; 2058 return -1;
2059 }
2058 curr_write_len = tty_insert_flip_string 2060 curr_write_len = tty_insert_flip_string
2059 (tty, urb->transfer_buffer + 2061 (tty, urb->transfer_buffer +
2060 serial->curr_rx_urb_offset, 2062 serial->curr_rx_urb_offset,
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index ac07cc6e3cb2..3b8e63254277 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -622,6 +622,7 @@ static const struct net_device_ops rhine_netdev_ops = {
622 .ndo_get_stats = rhine_get_stats, 622 .ndo_get_stats = rhine_get_stats,
623 .ndo_set_multicast_list = rhine_set_rx_mode, 623 .ndo_set_multicast_list = rhine_set_rx_mode,
624 .ndo_validate_addr = eth_validate_addr, 624 .ndo_validate_addr = eth_validate_addr,
625 .ndo_set_mac_address = eth_mac_addr,
625 .ndo_do_ioctl = netdev_ioctl, 626 .ndo_do_ioctl = netdev_ioctl,
626 .ndo_tx_timeout = rhine_tx_timeout, 627 .ndo_tx_timeout = rhine_tx_timeout,
627#ifdef CONFIG_NET_POLL_CONTROLLER 628#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 58e25d090ae0..a75f91dc3153 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -855,6 +855,7 @@ static const struct net_device_ops velocity_netdev_ops = {
855 .ndo_start_xmit = velocity_xmit, 855 .ndo_start_xmit = velocity_xmit,
856 .ndo_get_stats = velocity_get_stats, 856 .ndo_get_stats = velocity_get_stats,
857 .ndo_validate_addr = eth_validate_addr, 857 .ndo_validate_addr = eth_validate_addr,
858 .ndo_set_mac_address = eth_mac_addr,
858 .ndo_set_multicast_list = velocity_set_multi, 859 .ndo_set_multicast_list = velocity_set_multi,
859 .ndo_change_mtu = velocity_change_mtu, 860 .ndo_change_mtu = velocity_change_mtu,
860 .ndo_do_ioctl = velocity_ioctl, 861 .ndo_do_ioctl = velocity_ioctl,
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index 2dc241689d37..0dbd85b0162d 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -622,7 +622,7 @@ static void hss_hdlc_rx_irq(void *pdev)
622 printk(KERN_DEBUG "%s: hss_hdlc_rx_irq\n", dev->name); 622 printk(KERN_DEBUG "%s: hss_hdlc_rx_irq\n", dev->name);
623#endif 623#endif
624 qmgr_disable_irq(queue_ids[port->id].rx); 624 qmgr_disable_irq(queue_ids[port->id].rx);
625 netif_rx_schedule(dev, &port->napi); 625 netif_rx_schedule(&port->napi);
626} 626}
627 627
628static int hss_hdlc_poll(struct napi_struct *napi, int budget) 628static int hss_hdlc_poll(struct napi_struct *napi, int budget)
@@ -651,7 +651,7 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget)
651 printk(KERN_DEBUG "%s: hss_hdlc_poll" 651 printk(KERN_DEBUG "%s: hss_hdlc_poll"
652 " netif_rx_complete\n", dev->name); 652 " netif_rx_complete\n", dev->name);
653#endif 653#endif
654 netif_rx_complete(dev, napi); 654 netif_rx_complete(napi);
655 qmgr_enable_irq(rxq); 655 qmgr_enable_irq(rxq);
656 if (!qmgr_stat_empty(rxq) && 656 if (!qmgr_stat_empty(rxq) &&
657 netif_rx_reschedule(napi)) { 657 netif_rx_reschedule(napi)) {
@@ -1069,7 +1069,7 @@ static int hss_hdlc_open(struct net_device *dev)
1069 hss_start_hdlc(port); 1069 hss_start_hdlc(port);
1070 1070
1071 /* we may already have RX data, enables IRQ */ 1071 /* we may already have RX data, enables IRQ */
1072 netif_rx_schedule(dev, &port->napi); 1072 netif_rx_schedule(&port->napi);
1073 return 0; 1073 return 0;
1074 1074
1075err_unlock: 1075err_unlock:
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index 3c1edda08d3d..d8322d2d1e29 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -155,6 +155,7 @@ static const struct net_device_ops wd_netdev_ops = {
155 .ndo_get_stats = ei_get_stats, 155 .ndo_get_stats = ei_get_stats,
156 .ndo_set_multicast_list = ei_set_multicast_list, 156 .ndo_set_multicast_list = ei_set_multicast_list,
157 .ndo_validate_addr = eth_validate_addr, 157 .ndo_validate_addr = eth_validate_addr,
158 .ndo_set_mac_address = eth_mac_addr,
158 .ndo_change_mtu = eth_change_mtu, 159 .ndo_change_mtu = eth_change_mtu,
159#ifdef CONFIG_NET_POLL_CONTROLLER 160#ifdef CONFIG_NET_POLL_CONTROLLER
160 .ndo_poll_controller = ei_poll, 161 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index ea543fcf2687..e4f9f747de88 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -111,7 +111,7 @@ config WLAN_80211
111 lets you choose drivers. 111 lets you choose drivers.
112 112
113config PCMCIA_RAYCS 113config PCMCIA_RAYCS
114 tristate "Aviator/Raytheon 2.4MHz wireless support" 114 tristate "Aviator/Raytheon 2.4GHz wireless support"
115 depends on PCMCIA && WLAN_80211 115 depends on PCMCIA && WLAN_80211
116 select WIRELESS_EXT 116 select WIRELESS_EXT
117 ---help--- 117 ---help---
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index 4af2607deec0..8ef87356e083 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -2644,7 +2644,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2644 if (skb_headroom(skb) < padsize) { 2644 if (skb_headroom(skb) < padsize) {
2645 ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough" 2645 ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough"
2646 " headroom to pad %d\n", hdrlen, padsize); 2646 " headroom to pad %d\n", hdrlen, padsize);
2647 return -1; 2647 return NETDEV_TX_BUSY;
2648 } 2648 }
2649 skb_push(skb, padsize); 2649 skb_push(skb, padsize);
2650 memmove(skb->data, skb->data+padsize, hdrlen); 2650 memmove(skb->data, skb->data+padsize, hdrlen);
@@ -2655,7 +2655,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2655 ATH5K_ERR(sc, "no further txbuf available, dropping packet\n"); 2655 ATH5K_ERR(sc, "no further txbuf available, dropping packet\n");
2656 spin_unlock_irqrestore(&sc->txbuflock, flags); 2656 spin_unlock_irqrestore(&sc->txbuflock, flags);
2657 ieee80211_stop_queue(hw, skb_get_queue_mapping(skb)); 2657 ieee80211_stop_queue(hw, skb_get_queue_mapping(skb));
2658 return -1; 2658 return NETDEV_TX_BUSY;
2659 } 2659 }
2660 bf = list_first_entry(&sc->txbuf, struct ath5k_buf, list); 2660 bf = list_first_entry(&sc->txbuf, struct ath5k_buf, list);
2661 list_del(&bf->list); 2661 list_del(&bf->list);
@@ -2673,10 +2673,10 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2673 sc->txbuf_len++; 2673 sc->txbuf_len++;
2674 spin_unlock_irqrestore(&sc->txbuflock, flags); 2674 spin_unlock_irqrestore(&sc->txbuflock, flags);
2675 dev_kfree_skb_any(skb); 2675 dev_kfree_skb_any(skb);
2676 return 0; 2676 return NETDEV_TX_OK;
2677 } 2677 }
2678 2678
2679 return 0; 2679 return NETDEV_TX_OK;
2680} 2680}
2681 2681
2682static int 2682static int
diff --git a/drivers/net/wireless/ath5k/pcu.c b/drivers/net/wireless/ath5k/pcu.c
index 0cac05c6a9ce..75eb9f43c741 100644
--- a/drivers/net/wireless/ath5k/pcu.c
+++ b/drivers/net/wireless/ath5k/pcu.c
@@ -65,7 +65,7 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
65 if (ah->ah_version == AR5K_AR5210) 65 if (ah->ah_version == AR5K_AR5210)
66 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL; 66 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
67 else 67 else
68 AR5K_REG_DISABLE_BITS(ah, AR5K_CFG, AR5K_CFG_ADHOC); 68 AR5K_REG_ENABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
69 break; 69 break;
70 70
71 case NL80211_IFTYPE_AP: 71 case NL80211_IFTYPE_AP:
@@ -75,7 +75,7 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
75 if (ah->ah_version == AR5K_AR5210) 75 if (ah->ah_version == AR5K_AR5210)
76 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL; 76 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
77 else 77 else
78 AR5K_REG_ENABLE_BITS(ah, AR5K_CFG, AR5K_CFG_ADHOC); 78 AR5K_REG_DISABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
79 break; 79 break;
80 80
81 case NL80211_IFTYPE_STATION: 81 case NL80211_IFTYPE_STATION:
diff --git a/drivers/net/wireless/ath5k/reg.h b/drivers/net/wireless/ath5k/reg.h
index 91aaeaf88199..9189ab13286c 100644
--- a/drivers/net/wireless/ath5k/reg.h
+++ b/drivers/net/wireless/ath5k/reg.h
@@ -73,7 +73,7 @@
73#define AR5K_CFG_SWRD 0x00000004 /* Byte-swap RX descriptor */ 73#define AR5K_CFG_SWRD 0x00000004 /* Byte-swap RX descriptor */
74#define AR5K_CFG_SWRB 0x00000008 /* Byte-swap RX buffer */ 74#define AR5K_CFG_SWRB 0x00000008 /* Byte-swap RX buffer */
75#define AR5K_CFG_SWRG 0x00000010 /* Byte-swap Register access */ 75#define AR5K_CFG_SWRG 0x00000010 /* Byte-swap Register access */
76#define AR5K_CFG_ADHOC 0x00000020 /* AP/Adhoc indication [5211+] */ 76#define AR5K_CFG_IBSS 0x00000020 /* 0-BSS, 1-IBSS [5211+] */
77#define AR5K_CFG_PHY_OK 0x00000100 /* [5211+] */ 77#define AR5K_CFG_PHY_OK 0x00000100 /* [5211+] */
78#define AR5K_CFG_EEBS 0x00000200 /* EEPROM is busy */ 78#define AR5K_CFG_EEBS 0x00000200 /* EEPROM is busy */
79#define AR5K_CFG_CLKGD 0x00000400 /* Clock gated (Disable dynamic clock) */ 79#define AR5K_CFG_CLKGD 0x00000400 /* Clock gated (Disable dynamic clock) */
diff --git a/drivers/net/wireless/ath9k/Kconfig b/drivers/net/wireless/ath9k/Kconfig
index c43bd321f97f..90a8dd873786 100644
--- a/drivers/net/wireless/ath9k/Kconfig
+++ b/drivers/net/wireless/ath9k/Kconfig
@@ -1,6 +1,7 @@
1config ATH9K 1config ATH9K
2 tristate "Atheros 802.11n wireless cards support" 2 tristate "Atheros 802.11n wireless cards support"
3 depends on PCI && MAC80211 && WLAN_80211 3 depends on PCI && MAC80211 && WLAN_80211
4 depends on RFKILL || RFKILL=n
4 select MAC80211_LEDS 5 select MAC80211_LEDS
5 select LEDS_CLASS 6 select LEDS_CLASS
6 select NEW_LEDS 7 select NEW_LEDS
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 191eec50dc75..727f067aca4f 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -2164,13 +2164,13 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
2164 conf->ht.channel_type); 2164 conf->ht.channel_type);
2165 } 2165 }
2166 2166
2167 ath_update_chainmask(sc, conf->ht.enabled);
2168
2167 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0) { 2169 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0) {
2168 DPRINTF(sc, ATH_DBG_FATAL, "Unable to set channel\n"); 2170 DPRINTF(sc, ATH_DBG_FATAL, "Unable to set channel\n");
2169 mutex_unlock(&sc->mutex); 2171 mutex_unlock(&sc->mutex);
2170 return -EINVAL; 2172 return -EINVAL;
2171 } 2173 }
2172
2173 ath_update_chainmask(sc, conf->ht.enabled);
2174 } 2174 }
2175 2175
2176 if (changed & IEEE80211_CONF_CHANGE_POWER) 2176 if (changed & IEEE80211_CONF_CHANGE_POWER)
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index 3bfc3b90f256..c92f0c6e4adc 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -126,15 +126,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
126 tx_info->flags |= IEEE80211_TX_STAT_ACK; 126 tx_info->flags |= IEEE80211_TX_STAT_ACK;
127 } 127 }
128 128
129 tx_info->status.rates[0].count = tx_status->retries; 129 tx_info->status.rates[0].count = tx_status->retries + 1;
130 if (tx_info->status.rates[0].flags & IEEE80211_TX_RC_MCS) {
131 /* Change idx from internal table index to MCS index */
132 int idx = tx_info->status.rates[0].idx;
133 struct ath_rate_table *rate_table = sc->cur_rate_table;
134 if (idx >= 0 && idx < rate_table->rate_cnt)
135 tx_info->status.rates[0].idx =
136 rate_table->info[idx].ratecode & 0x7f;
137 }
138 130
139 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 131 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
140 padsize = hdrlen & 3; 132 padsize = hdrlen & 3;
@@ -264,25 +256,22 @@ static void assign_aggr_tid_seqno(struct sk_buff *skb,
264 } 256 }
265 257
266 /* Get seqno */ 258 /* Get seqno */
267 259 /* For HT capable stations, we save tidno for later use.
268 if (ieee80211_is_data(fc) && !is_pae(skb)) { 260 * We also override seqno set by upper layer with the one
269 /* For HT capable stations, we save tidno for later use. 261 * in tx aggregation state.
270 * We also override seqno set by upper layer with the one 262 *
271 * in tx aggregation state. 263 * If fragmentation is on, the sequence number is
272 * 264 * not overridden, since it has been
273 * If fragmentation is on, the sequence number is 265 * incremented by the fragmentation routine.
274 * not overridden, since it has been 266 *
275 * incremented by the fragmentation routine. 267 * FIXME: check if the fragmentation threshold exceeds
276 * 268 * IEEE80211 max.
277 * FIXME: check if the fragmentation threshold exceeds 269 */
278 * IEEE80211 max. 270 tid = ATH_AN_2_TID(an, bf->bf_tidno);
279 */ 271 hdr->seq_ctrl = cpu_to_le16(tid->seq_next <<
280 tid = ATH_AN_2_TID(an, bf->bf_tidno); 272 IEEE80211_SEQ_SEQ_SHIFT);
281 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << 273 bf->bf_seqno = tid->seq_next;
282 IEEE80211_SEQ_SEQ_SHIFT); 274 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
283 bf->bf_seqno = tid->seq_next;
284 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
285 }
286} 275}
287 276
288static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb, 277static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb,
@@ -1718,11 +1707,10 @@ static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
1718 1707
1719 /* Assign seqno, tidno */ 1708 /* Assign seqno, tidno */
1720 1709
1721 if (bf_isht(bf) && (sc->sc_flags & SC_OP_TXAGGR)) 1710 if (ieee80211_is_data_qos(fc) && (sc->sc_flags & SC_OP_TXAGGR))
1722 assign_aggr_tid_seqno(skb, bf); 1711 assign_aggr_tid_seqno(skb, bf);
1723 1712
1724 /* DMA setup */ 1713 /* DMA setup */
1725
1726 bf->bf_mpdu = skb; 1714 bf->bf_mpdu = skb;
1727 1715
1728 bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data, 1716 bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data,
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 7b31a327b24a..c788bad10661 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -3261,7 +3261,7 @@ static int b43_switch_band(struct b43_wl *wl, struct ieee80211_channel *chan)
3261 struct b43_wldev *down_dev; 3261 struct b43_wldev *down_dev;
3262 struct b43_wldev *d; 3262 struct b43_wldev *d;
3263 int err; 3263 int err;
3264 bool gmode; 3264 bool uninitialized_var(gmode);
3265 int prev_status; 3265 int prev_status;
3266 3266
3267 /* Find a device and PHY which supports the band. */ 3267 /* Find a device and PHY which supports the band. */
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index c1324e31d2f6..fb996c27a19b 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -2465,7 +2465,7 @@ static void b43legacy_put_phy_into_reset(struct b43legacy_wldev *dev)
2465static int b43legacy_switch_phymode(struct b43legacy_wl *wl, 2465static int b43legacy_switch_phymode(struct b43legacy_wl *wl,
2466 unsigned int new_mode) 2466 unsigned int new_mode)
2467{ 2467{
2468 struct b43legacy_wldev *up_dev; 2468 struct b43legacy_wldev *uninitialized_var(up_dev);
2469 struct b43legacy_wldev *down_dev; 2469 struct b43legacy_wldev *down_dev;
2470 int err; 2470 int err;
2471 bool gmode = 0; 2471 bool gmode = 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 8fdb34222c0a..45cfa1cf194a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2219,7 +2219,7 @@ int iwl3945_txpower_set_from_eeprom(struct iwl3945_priv *priv)
2219 /* set tx power value for all OFDM rates */ 2219 /* set tx power value for all OFDM rates */
2220 for (rate_index = 0; rate_index < IWL_OFDM_RATES; 2220 for (rate_index = 0; rate_index < IWL_OFDM_RATES;
2221 rate_index++) { 2221 rate_index++) {
2222 s32 power_idx; 2222 s32 uninitialized_var(power_idx);
2223 int rc; 2223 int rc;
2224 2224
2225 /* use channel group's clip-power table, 2225 /* use channel group's clip-power table,
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 52966ffbef6e..ba997204c8d4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -255,7 +255,7 @@ struct iwl_cmd_header {
255 * 0x3) 54 Mbps 255 * 0x3) 54 Mbps
256 * 256 *
257 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"): 257 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
258 * 3-0: 10) 1 Mbps 258 * 6-0: 10) 1 Mbps
259 * 20) 2 Mbps 259 * 20) 2 Mbps
260 * 55) 5.5 Mbps 260 * 55) 5.5 Mbps
261 * 110) 11 Mbps 261 * 110) 11 Mbps
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index 01a2169cecec..8c71ad4f88c5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -51,6 +51,7 @@ const char *get_cmd_string(u8 cmd)
51 IWL_CMD(REPLY_REMOVE_STA); 51 IWL_CMD(REPLY_REMOVE_STA);
52 IWL_CMD(REPLY_REMOVE_ALL_STA); 52 IWL_CMD(REPLY_REMOVE_ALL_STA);
53 IWL_CMD(REPLY_WEPKEY); 53 IWL_CMD(REPLY_WEPKEY);
54 IWL_CMD(REPLY_3945_RX);
54 IWL_CMD(REPLY_TX); 55 IWL_CMD(REPLY_TX);
55 IWL_CMD(REPLY_RATE_SCALE); 56 IWL_CMD(REPLY_RATE_SCALE);
56 IWL_CMD(REPLY_LEDS_CMD); 57 IWL_CMD(REPLY_LEDS_CMD);
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 3dba83679444..4e0007d20030 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1369,7 +1369,7 @@ EXPORT_SYMBOL_GPL(lbs_start_card);
1369 1369
1370void lbs_stop_card(struct lbs_private *priv) 1370void lbs_stop_card(struct lbs_private *priv)
1371{ 1371{
1372 struct net_device *dev = priv->dev; 1372 struct net_device *dev;
1373 struct cmd_ctrl_node *cmdnode; 1373 struct cmd_ctrl_node *cmdnode;
1374 unsigned long flags; 1374 unsigned long flags;
1375 1375
@@ -1377,9 +1377,10 @@ void lbs_stop_card(struct lbs_private *priv)
1377 1377
1378 if (!priv) 1378 if (!priv)
1379 goto out; 1379 goto out;
1380 dev = priv->dev;
1380 1381
1381 netif_stop_queue(priv->dev); 1382 netif_stop_queue(dev);
1382 netif_carrier_off(priv->dev); 1383 netif_carrier_off(dev);
1383 1384
1384 lbs_debugfs_remove_one(priv); 1385 lbs_debugfs_remove_one(priv);
1385 if (priv->mesh_tlv) { 1386 if (priv->mesh_tlv) {
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index d1fc305de5fe..e7289e2e7f16 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -206,7 +206,7 @@ static int lbtf_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
206 * there are no buffered multicast frames to send 206 * there are no buffered multicast frames to send
207 */ 207 */
208 ieee80211_stop_queues(priv->hw); 208 ieee80211_stop_queues(priv->hw);
209 return 0; 209 return NETDEV_TX_OK;
210} 210}
211 211
212static void lbtf_tx_work(struct work_struct *work) 212static void lbtf_tx_work(struct work_struct *work)
diff --git a/drivers/net/wireless/orinoco/orinoco.c b/drivers/net/wireless/orinoco/orinoco.c
index bc84e2792f8a..c3bb85e0251e 100644
--- a/drivers/net/wireless/orinoco/orinoco.c
+++ b/drivers/net/wireless/orinoco/orinoco.c
@@ -1610,6 +1610,16 @@ static void orinoco_rx_isr_tasklet(unsigned long data)
1610 struct orinoco_rx_data *rx_data, *temp; 1610 struct orinoco_rx_data *rx_data, *temp;
1611 struct hermes_rx_descriptor *desc; 1611 struct hermes_rx_descriptor *desc;
1612 struct sk_buff *skb; 1612 struct sk_buff *skb;
1613 unsigned long flags;
1614
1615 /* orinoco_rx requires the driver lock, and we also need to
1616 * protect priv->rx_list, so just hold the lock over the
1617 * lot.
1618 *
1619 * If orinoco_lock fails, we've unplugged the card. In this
1620 * case just abort. */
1621 if (orinoco_lock(priv, &flags) != 0)
1622 return;
1613 1623
1614 /* extract desc and skb from queue */ 1624 /* extract desc and skb from queue */
1615 list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) { 1625 list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) {
@@ -1622,6 +1632,8 @@ static void orinoco_rx_isr_tasklet(unsigned long data)
1622 1632
1623 kfree(desc); 1633 kfree(desc);
1624 } 1634 }
1635
1636 orinoco_unlock(priv, &flags);
1625} 1637}
1626 1638
1627/********************************************************************/ 1639/********************************************************************/
@@ -3645,12 +3657,22 @@ struct net_device
3645void free_orinocodev(struct net_device *dev) 3657void free_orinocodev(struct net_device *dev)
3646{ 3658{
3647 struct orinoco_private *priv = netdev_priv(dev); 3659 struct orinoco_private *priv = netdev_priv(dev);
3660 struct orinoco_rx_data *rx_data, *temp;
3648 3661
3649 /* No need to empty priv->rx_list: if the tasklet is scheduled 3662 /* If the tasklet is scheduled when we call tasklet_kill it
3650 * when we call tasklet_kill it will run one final time, 3663 * will run one final time. However the tasklet will only
3651 * emptying the list */ 3664 * drain priv->rx_list if the hw is still available. */
3652 tasklet_kill(&priv->rx_tasklet); 3665 tasklet_kill(&priv->rx_tasklet);
3653 3666
3667 /* Explicitly drain priv->rx_list */
3668 list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) {
3669 list_del(&rx_data->list);
3670
3671 dev_kfree_skb(rx_data->skb);
3672 kfree(rx_data->desc);
3673 kfree(rx_data);
3674 }
3675
3654 unregister_pm_notifier(&priv->pm_notifier); 3676 unregister_pm_notifier(&priv->pm_notifier);
3655 orinoco_uncache_fw(priv); 3677 orinoco_uncache_fw(priv);
3656 3678
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index f127602670ec..0b32215d3f5d 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -435,6 +435,7 @@ static struct pcmcia_device_id orinoco_cs_ids[] = {
435 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */ 435 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */
436 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */ 436 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */
437 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */ 437 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */
438 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0003), /* ARtem Onair Comcard 11 */
438 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */ 439 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */
439 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */ 440 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */
440 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */ 441 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 82354b974a04..c6a370fa9bcb 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -138,6 +138,7 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
138 u8 *fw_version = NULL; 138 u8 *fw_version = NULL;
139 size_t len; 139 size_t len;
140 int i; 140 int i;
141 int maxlen;
141 142
142 if (priv->rx_start) 143 if (priv->rx_start)
143 return 0; 144 return 0;
@@ -195,6 +196,16 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
195 else 196 else
196 priv->rx_mtu = (size_t) 197 priv->rx_mtu = (size_t)
197 0x620 - priv->tx_hdr_len; 198 0x620 - priv->tx_hdr_len;
199 maxlen = priv->tx_hdr_len + /* USB devices */
200 sizeof(struct p54_rx_data) +
201 4 + /* rx alignment */
202 IEEE80211_MAX_FRAG_THRESHOLD;
203 if (priv->rx_mtu > maxlen && PAGE_SIZE == 4096) {
204 printk(KERN_INFO "p54: rx_mtu reduced from %d "
205 "to %d\n", priv->rx_mtu,
206 maxlen);
207 priv->rx_mtu = maxlen;
208 }
198 break; 209 break;
199 } 210 }
200 case BR_CODE_EXPOSED_IF: 211 case BR_CODE_EXPOSED_IF:
@@ -575,6 +586,7 @@ static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
575 u16 freq = le16_to_cpu(hdr->freq); 586 u16 freq = le16_to_cpu(hdr->freq);
576 size_t header_len = sizeof(*hdr); 587 size_t header_len = sizeof(*hdr);
577 u32 tsf32; 588 u32 tsf32;
589 u8 rate = hdr->rate & 0xf;
578 590
579 /* 591 /*
580 * If the device is in a unspecified state we have to 592 * If the device is in a unspecified state we have to
@@ -603,8 +615,11 @@ static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
603 rx_status.qual = (100 * hdr->rssi) / 127; 615 rx_status.qual = (100 * hdr->rssi) / 127;
604 if (hdr->rate & 0x10) 616 if (hdr->rate & 0x10)
605 rx_status.flag |= RX_FLAG_SHORTPRE; 617 rx_status.flag |= RX_FLAG_SHORTPRE;
606 rx_status.rate_idx = (dev->conf.channel->band == IEEE80211_BAND_2GHZ ? 618 if (dev->conf.channel->band == IEEE80211_BAND_5GHZ)
607 hdr->rate : (hdr->rate - 4)) & 0xf; 619 rx_status.rate_idx = (rate < 4) ? 0 : rate - 4;
620 else
621 rx_status.rate_idx = rate;
622
608 rx_status.freq = freq; 623 rx_status.freq = freq;
609 rx_status.band = dev->conf.channel->band; 624 rx_status.band = dev->conf.channel->band;
610 rx_status.antenna = hdr->antenna; 625 rx_status.antenna = hdr->antenna;
@@ -798,6 +813,16 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
798 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 813 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
799 info->status.ack_signal = p54_rssi_to_dbm(dev, 814 info->status.ack_signal = p54_rssi_to_dbm(dev,
800 (int)payload->ack_rssi); 815 (int)payload->ack_rssi);
816
817 if (entry_data->key_type == P54_CRYPTO_TKIPMICHAEL) {
818 u8 *iv = (u8 *)(entry_data->align + pad +
819 entry_data->crypt_offset);
820
821 /* Restore the original TKIP IV. */
822 iv[2] = iv[0];
823 iv[0] = iv[1];
824 iv[1] = (iv[0] | 0x20) & 0x7f; /* WEPSeed - 8.3.2.2 */
825 }
801 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data)); 826 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data));
802 ieee80211_tx_status_irqsafe(dev, entry); 827 ieee80211_tx_status_irqsafe(dev, entry);
803 goto out; 828 goto out;
@@ -1383,7 +1408,6 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1383 hdr->tries = ridx; 1408 hdr->tries = ridx;
1384 txhdr->rts_rate_idx = 0; 1409 txhdr->rts_rate_idx = 0;
1385 if (info->control.hw_key) { 1410 if (info->control.hw_key) {
1386 crypt_offset += info->control.hw_key->iv_len;
1387 txhdr->key_type = p54_convert_algo(info->control.hw_key->alg); 1411 txhdr->key_type = p54_convert_algo(info->control.hw_key->alg);
1388 txhdr->key_len = min((u8)16, info->control.hw_key->keylen); 1412 txhdr->key_len = min((u8)16, info->control.hw_key->keylen);
1389 memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len); 1413 memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len);
@@ -1397,6 +1421,8 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1397 } 1421 }
1398 /* reserve some space for ICV */ 1422 /* reserve some space for ICV */
1399 len += info->control.hw_key->icv_len; 1423 len += info->control.hw_key->icv_len;
1424 memset(skb_put(skb, info->control.hw_key->icv_len), 0,
1425 info->control.hw_key->icv_len);
1400 } else { 1426 } else {
1401 txhdr->key_type = 0; 1427 txhdr->key_type = 0;
1402 txhdr->key_len = 0; 1428 txhdr->key_len = 0;
@@ -1824,7 +1850,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
1824 1850
1825static int p54_config(struct ieee80211_hw *dev, u32 changed) 1851static int p54_config(struct ieee80211_hw *dev, u32 changed)
1826{ 1852{
1827 int ret; 1853 int ret = 0;
1828 struct p54_common *priv = dev->priv; 1854 struct p54_common *priv = dev->priv;
1829 struct ieee80211_conf *conf = &dev->conf; 1855 struct ieee80211_conf *conf = &dev->conf;
1830 1856
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index c44a200059d2..6a6a72f6f82c 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -56,6 +56,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
56 {USB_DEVICE(0x050d, 0x7050)}, /* Belkin F5D7050 ver 1000 */ 56 {USB_DEVICE(0x050d, 0x7050)}, /* Belkin F5D7050 ver 1000 */
57 {USB_DEVICE(0x0572, 0x2000)}, /* Cohiba Proto board */ 57 {USB_DEVICE(0x0572, 0x2000)}, /* Cohiba Proto board */
58 {USB_DEVICE(0x0572, 0x2002)}, /* Cohiba Proto board */ 58 {USB_DEVICE(0x0572, 0x2002)}, /* Cohiba Proto board */
59 {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
59 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */ 60 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
60 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */ 61 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
61 {USB_DEVICE(0x0846, 0x4240)}, /* Netgear WG111 (v2) */ 62 {USB_DEVICE(0x0846, 0x4240)}, /* Netgear WG111 (v2) */
@@ -284,6 +285,7 @@ static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb)
284 usb_fill_bulk_urb(data_urb, priv->udev, 285 usb_fill_bulk_urb(data_urb, priv->udev,
285 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), 286 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
286 skb->data, skb->len, p54u_tx_cb, skb); 287 skb->data, skb->len, p54u_tx_cb, skb);
288 data_urb->transfer_flags |= URB_ZERO_PACKET;
287 289
288 usb_anchor_urb(data_urb, &priv->submitted); 290 usb_anchor_urb(data_urb, &priv->submitted);
289 if (usb_submit_urb(data_urb, GFP_ATOMIC)) { 291 if (usb_submit_urb(data_urb, GFP_ATOMIC)) {
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 30028e2422fc..af6b5847be5c 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -38,7 +38,7 @@
38/* 38/*
39 * Allow hardware encryption to be disabled. 39 * Allow hardware encryption to be disabled.
40 */ 40 */
41static int modparam_nohwcrypt = 1; 41static int modparam_nohwcrypt = 0;
42module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); 42module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
43MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); 43MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
44 44
@@ -376,11 +376,11 @@ static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
376 376
377 /* 377 /*
378 * The driver does not support the IV/EIV generation 378 * The driver does not support the IV/EIV generation
379 * in hardware. However it doesn't support the IV/EIV 379 * in hardware. However it demands the data to be provided
380 * inside the ieee80211 frame either, but requires it 380 * both seperately as well as inside the frame.
381 * to be provided seperately for the descriptor. 381 * We already provided the CONFIG_CRYPTO_COPY_IV to rt2x00lib
382 * rt2x00lib will cut the IV/EIV data out of all frames 382 * to ensure rt2x00lib will not strip the data from the
383 * given to us by mac80211, but we must tell mac80211 383 * frame after the copy, now we must tell mac80211
384 * to generate the IV/EIV data. 384 * to generate the IV/EIV data.
385 */ 385 */
386 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 386 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -1181,7 +1181,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1181 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)); 1181 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
1182 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); 1182 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1183 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len); 1183 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len);
1184 rt2x00_set_field32(&word, TXD_W0_CIPHER, txdesc->cipher); 1184 rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher);
1185 rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx); 1185 rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx);
1186 rt2x00_desc_write(txd, 0, word); 1186 rt2x00_desc_write(txd, 0, word);
1187} 1187}
@@ -1334,14 +1334,7 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
1334 1334
1335 /* ICV is located at the end of frame */ 1335 /* ICV is located at the end of frame */
1336 1336
1337 /* 1337 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
1338 * Hardware has stripped IV/EIV data from 802.11 frame during
1339 * decryption. It has provided the data seperately but rt2x00lib
1340 * should decide if it should be reinserted.
1341 */
1342 rxdesc->flags |= RX_FLAG_IV_STRIPPED;
1343 if (rxdesc->cipher != CIPHER_TKIP)
1344 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
1345 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) 1338 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
1346 rxdesc->flags |= RX_FLAG_DECRYPTED; 1339 rxdesc->flags |= RX_FLAG_DECRYPTED;
1347 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) 1340 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 6d92542fcf0d..87c0f2c83077 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -807,13 +807,11 @@ static void rt2x00lib_rate(struct ieee80211_rate *entry,
807{ 807{
808 entry->flags = 0; 808 entry->flags = 0;
809 entry->bitrate = rate->bitrate; 809 entry->bitrate = rate->bitrate;
810 entry->hw_value = rt2x00_create_rate_hw_value(index, 0); 810 entry->hw_value =index;
811 entry->hw_value_short = entry->hw_value; 811 entry->hw_value_short = index;
812 812
813 if (rate->flags & DEV_RATE_SHORT_PREAMBLE) { 813 if (rate->flags & DEV_RATE_SHORT_PREAMBLE)
814 entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE; 814 entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
815 entry->hw_value_short |= rt2x00_create_rate_hw_value(index, 1);
816 }
817} 815}
818 816
819static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, 817static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00leds.c b/drivers/net/wireless/rt2x00/rt2x00leds.c
index 68f4e0fc35b9..a0cd35b6beb5 100644
--- a/drivers/net/wireless/rt2x00/rt2x00leds.c
+++ b/drivers/net/wireless/rt2x00/rt2x00leds.c
@@ -97,7 +97,7 @@ void rt2x00leds_led_assoc(struct rt2x00_dev *rt2x00dev, bool enabled)
97 97
98void rt2x00leds_led_radio(struct rt2x00_dev *rt2x00dev, bool enabled) 98void rt2x00leds_led_radio(struct rt2x00_dev *rt2x00dev, bool enabled)
99{ 99{
100 if (rt2x00dev->led_radio.type == LED_TYPE_ASSOC) 100 if (rt2x00dev->led_radio.type == LED_TYPE_RADIO)
101 rt2x00led_led_simple(&rt2x00dev->led_radio, enabled); 101 rt2x00led_led_simple(&rt2x00dev->led_radio, enabled);
102} 102}
103 103
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 03024327767b..86cd26fbf769 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -52,22 +52,11 @@ struct rt2x00_rate {
52 52
53extern const struct rt2x00_rate rt2x00_supported_rates[12]; 53extern const struct rt2x00_rate rt2x00_supported_rates[12];
54 54
55static inline u16 rt2x00_create_rate_hw_value(const u16 index,
56 const u16 short_preamble)
57{
58 return (short_preamble << 8) | (index & 0xff);
59}
60
61static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value) 55static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value)
62{ 56{
63 return &rt2x00_supported_rates[hw_value & 0xff]; 57 return &rt2x00_supported_rates[hw_value & 0xff];
64} 58}
65 59
66static inline int rt2x00_get_rate_preamble(const u16 hw_value)
67{
68 return (hw_value & 0xff00);
69}
70
71/* 60/*
72 * Radio control handlers. 61 * Radio control handlers.
73 */ 62 */
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index eaec6bd93ed5..746a8f36b931 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -313,7 +313,7 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
313 * When preamble is enabled we should set the 313 * When preamble is enabled we should set the
314 * preamble bit for the signal. 314 * preamble bit for the signal.
315 */ 315 */
316 if (rt2x00_get_rate_preamble(rate->hw_value)) 316 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
317 txdesc->signal |= 0x08; 317 txdesc->signal |= 0x08;
318 } 318 }
319} 319}
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 83df312ac56f..0b29d767a258 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -434,11 +434,11 @@ static int rt2x00usb_find_endpoints(struct rt2x00_dev *rt2x00dev)
434 434
435 if (usb_endpoint_is_bulk_in(ep_desc)) { 435 if (usb_endpoint_is_bulk_in(ep_desc)) {
436 rt2x00usb_assign_endpoint(rt2x00dev->rx, ep_desc); 436 rt2x00usb_assign_endpoint(rt2x00dev->rx, ep_desc);
437 } else if (usb_endpoint_is_bulk_out(ep_desc)) { 437 } else if (usb_endpoint_is_bulk_out(ep_desc) &&
438 (queue != queue_end(rt2x00dev))) {
438 rt2x00usb_assign_endpoint(queue, ep_desc); 439 rt2x00usb_assign_endpoint(queue, ep_desc);
440 queue = queue_next(queue);
439 441
440 if (queue != queue_end(rt2x00dev))
441 queue = queue_next(queue);
442 tx_ep_desc = ep_desc; 442 tx_ep_desc = ep_desc;
443 } 443 }
444 } 444 }
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index d638a8a59370..96a8d69f8790 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2321,6 +2321,7 @@ static struct usb_device_id rt73usb_device_table[] = {
2321 /* Linksys */ 2321 /* Linksys */
2322 { USB_DEVICE(0x13b1, 0x0020), USB_DEVICE_DATA(&rt73usb_ops) }, 2322 { USB_DEVICE(0x13b1, 0x0020), USB_DEVICE_DATA(&rt73usb_ops) },
2323 { USB_DEVICE(0x13b1, 0x0023), USB_DEVICE_DATA(&rt73usb_ops) }, 2323 { USB_DEVICE(0x13b1, 0x0023), USB_DEVICE_DATA(&rt73usb_ops) },
2324 { USB_DEVICE(0x13b1, 0x0028), USB_DEVICE_DATA(&rt73usb_ops) },
2324 /* MSI */ 2325 /* MSI */
2325 { USB_DEVICE(0x0db0, 0x6877), USB_DEVICE_DATA(&rt73usb_ops) }, 2326 { USB_DEVICE(0x0db0, 0x6877), USB_DEVICE_DATA(&rt73usb_ops) },
2326 { USB_DEVICE(0x0db0, 0x6874), USB_DEVICE_DATA(&rt73usb_ops) }, 2327 { USB_DEVICE(0x0db0, 0x6874), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
index 5f887fb137a9..387c133ec0f2 100644
--- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
@@ -897,6 +897,7 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
897 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 897 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
898 IEEE80211_HW_RX_INCLUDES_FCS | 898 IEEE80211_HW_RX_INCLUDES_FCS |
899 IEEE80211_HW_SIGNAL_UNSPEC; 899 IEEE80211_HW_SIGNAL_UNSPEC;
900 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
900 dev->queues = 1; 901 dev->queues = 1;
901 dev->max_signal = 65; 902 dev->max_signal = 65;
902 903
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 00ce3ef39abe..6ad6bac37706 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -213,7 +213,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
213 urb = usb_alloc_urb(0, GFP_ATOMIC); 213 urb = usb_alloc_urb(0, GFP_ATOMIC);
214 if (!urb) { 214 if (!urb) {
215 kfree_skb(skb); 215 kfree_skb(skb);
216 return -ENOMEM; 216 return NETDEV_TX_OK;
217 } 217 }
218 218
219 flags = skb->len; 219 flags = skb->len;
@@ -281,7 +281,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
281 } 281 }
282 usb_free_urb(urb); 282 usb_free_urb(urb);
283 283
284 return rc; 284 return NETDEV_TX_OK;
285} 285}
286 286
287static void rtl8187_rx_cb(struct urb *urb) 287static void rtl8187_rx_cb(struct urb *urb)
@@ -1471,6 +1471,7 @@ static void __devexit rtl8187_disconnect(struct usb_interface *intf)
1471 ieee80211_unregister_hw(dev); 1471 ieee80211_unregister_hw(dev);
1472 1472
1473 priv = dev->priv; 1473 priv = dev->priv;
1474 usb_reset_device(priv->udev);
1474 usb_put_dev(interface_to_usbdev(intf)); 1475 usb_put_dev(interface_to_usbdev(intf));
1475 ieee80211_free_hw(dev); 1476 ieee80211_free_hw(dev);
1476} 1477}
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index cf9712922778..2f1645dcb8c8 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -362,6 +362,7 @@ static const struct net_device_ops netdev_ops = {
362 .ndo_set_multicast_list = set_rx_mode, 362 .ndo_set_multicast_list = set_rx_mode,
363 .ndo_change_mtu = eth_change_mtu, 363 .ndo_change_mtu = eth_change_mtu,
364 .ndo_validate_addr = eth_validate_addr, 364 .ndo_validate_addr = eth_validate_addr,
365 .ndo_set_mac_address = eth_mac_addr,
365 .ndo_do_ioctl = netdev_ioctl, 366 .ndo_do_ioctl = netdev_ioctl,
366 .ndo_tx_timeout = yellowfin_tx_timeout, 367 .ndo_tx_timeout = yellowfin_tx_timeout,
367}; 368};
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index affd904deafc..37c84e3b8be0 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -147,6 +147,7 @@ static const struct net_device_ops zorro8390_netdev_ops = {
147 .ndo_get_stats = ei_get_stats, 147 .ndo_get_stats = ei_get_stats,
148 .ndo_set_multicast_list = ei_set_multicast_list, 148 .ndo_set_multicast_list = ei_set_multicast_list,
149 .ndo_validate_addr = eth_validate_addr, 149 .ndo_validate_addr = eth_validate_addr,
150 .ndo_set_mac_address = eth_mac_addr,
150 .ndo_change_mtu = eth_change_mtu, 151 .ndo_change_mtu = eth_change_mtu,
151#ifdef CONFIG_NET_POLL_CONTROLLER 152#ifdef CONFIG_NET_POLL_CONTROLLER
152 .ndo_poll_controller = ei_poll, 153 .ndo_poll_controller = ei_poll,
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index e1b0ad6e918f..fa65a2b2ae2e 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -66,4 +66,23 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
66} 66}
67EXPORT_SYMBOL(of_register_i2c_devices); 67EXPORT_SYMBOL(of_register_i2c_devices);
68 68
69static int of_dev_node_match(struct device *dev, void *data)
70{
71 return dev_archdata_get_node(&dev->archdata) == data;
72}
73
74/* must call put_device() when done with returned i2c_client device */
75struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
76{
77 struct device *dev;
78
79 dev = bus_find_device(&i2c_bus_type, NULL, node,
80 of_dev_node_match);
81 if (!dev)
82 return NULL;
83
84 return to_i2c_client(dev);
85}
86EXPORT_SYMBOL(of_find_i2c_device_by_node);
87
69MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index 1e93c837514f..4fa3bb2ddfe4 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -405,7 +405,6 @@ static void __init superio_serial_init(void)
405 serial_port.type = PORT_16550A; 405 serial_port.type = PORT_16550A;
406 serial_port.uartclk = 115200*16; 406 serial_port.uartclk = 115200*16;
407 serial_port.fifosize = 16; 407 serial_port.fifosize = 16;
408 spin_lock_init(&serial_port.lock);
409 408
410 /* serial port #1 */ 409 /* serial port #1 */
411 serial_port.iobase = sio_dev.sp1_base; 410 serial_port.iobase = sio_dev.sp1_base;
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index f09b1010d477..803d9ddd6e75 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -266,6 +266,8 @@ static int detect_ejectable_slots(struct pci_bus *pbus)
266 int found = acpi_pci_detect_ejectable(pbus); 266 int found = acpi_pci_detect_ejectable(pbus);
267 if (!found) { 267 if (!found) {
268 acpi_handle bridge_handle = acpi_pci_get_bridge_handle(pbus); 268 acpi_handle bridge_handle = acpi_pci_get_bridge_handle(pbus);
269 if (!bridge_handle)
270 return 0;
269 acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1, 271 acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1,
270 is_pci_dock_device, (void *)&found, NULL); 272 is_pci_dock_device, (void *)&found, NULL);
271 } 273 }
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 235fb7a5a8a5..3dfecb20d5e7 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -438,7 +438,8 @@ static struct intel_iommu *device_to_iommu(u8 bus, u8 devfn)
438 continue; 438 continue;
439 439
440 for (i = 0; i < drhd->devices_cnt; i++) 440 for (i = 0; i < drhd->devices_cnt; i++)
441 if (drhd->devices[i]->bus->number == bus && 441 if (drhd->devices[i] &&
442 drhd->devices[i]->bus->number == bus &&
442 drhd->devices[i]->devfn == devfn) 443 drhd->devices[i]->devfn == devfn)
443 return drhd->iommu; 444 return drhd->iommu;
444 445
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c12f6c790698..e491fdedf705 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1260,15 +1260,14 @@ void pci_pm_init(struct pci_dev *dev)
1260 /* find PCI PM capability in list */ 1260 /* find PCI PM capability in list */
1261 pm = pci_find_capability(dev, PCI_CAP_ID_PM); 1261 pm = pci_find_capability(dev, PCI_CAP_ID_PM);
1262 if (!pm) 1262 if (!pm)
1263 goto Exit; 1263 return;
1264
1265 /* Check device's ability to generate PME# */ 1264 /* Check device's ability to generate PME# */
1266 pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc); 1265 pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc);
1267 1266
1268 if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { 1267 if ((pmc & PCI_PM_CAP_VER_MASK) > 3) {
1269 dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", 1268 dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n",
1270 pmc & PCI_PM_CAP_VER_MASK); 1269 pmc & PCI_PM_CAP_VER_MASK);
1271 goto Exit; 1270 return;
1272 } 1271 }
1273 1272
1274 dev->pm_cap = pm; 1273 dev->pm_cap = pm;
@@ -1307,9 +1306,6 @@ void pci_pm_init(struct pci_dev *dev)
1307 } else { 1306 } else {
1308 dev->pme_support = 0; 1307 dev->pme_support = 0;
1309 } 1308 }
1310
1311 Exit:
1312 pci_update_current_state(dev, PCI_D0);
1313} 1309}
1314 1310
1315/** 1311/**
diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
index 645d7a60e412..ec22284eed30 100644
--- a/drivers/pci/syscall.c
+++ b/drivers/pci/syscall.c
@@ -14,10 +14,8 @@
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include "pci.h" 15#include "pci.h"
16 16
17asmlinkage long 17SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
18sys_pciconfig_read(unsigned long bus, unsigned long dfn, 18 unsigned long, off, unsigned long, len, void __user *, buf)
19 unsigned long off, unsigned long len,
20 void __user *buf)
21{ 19{
22 struct pci_dev *dev; 20 struct pci_dev *dev;
23 u8 byte; 21 u8 byte;
@@ -86,10 +84,8 @@ error:
86 return err; 84 return err;
87} 85}
88 86
89asmlinkage long 87SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,
90sys_pciconfig_write(unsigned long bus, unsigned long dfn, 88 unsigned long, off, unsigned long, len, void __user *, buf)
91 unsigned long off, unsigned long len,
92 void __user *buf)
93{ 89{
94 struct pci_dev *dev; 90 struct pci_dev *dev;
95 u8 byte; 91 u8 byte;
diff --git a/drivers/pcmcia/electra_cf.c b/drivers/pcmcia/electra_cf.c
index a34284b1482a..d187ba4c5e0e 100644
--- a/drivers/pcmcia/electra_cf.c
+++ b/drivers/pcmcia/electra_cf.c
@@ -297,7 +297,7 @@ static int __devinit electra_cf_probe(struct of_device *ofdev,
297 goto fail3; 297 goto fail3;
298 } 298 }
299 299
300 dev_info(device, "at mem 0x%lx io 0x%lx irq %d\n", 300 dev_info(device, "at mem 0x%lx io 0x%llx irq %d\n",
301 cf->mem_phys, io.start, cf->irq); 301 cf->mem_phys, io.start, cf->irq);
302 302
303 cf->active = 1; 303 cf->active = 1;
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index e65448e99b48..1a266d4ab5f1 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -54,6 +54,18 @@ config ASUS_LAPTOP
54 54
55 If you have an ACPI-compatible ASUS laptop, say Y or M here. 55 If you have an ACPI-compatible ASUS laptop, say Y or M here.
56 56
57config DELL_LAPTOP
58 tristate "Dell Laptop Extras (EXPERIMENTAL)"
59 depends on X86
60 depends on DCDBAS
61 depends on EXPERIMENTAL
62 depends on BACKLIGHT_CLASS_DEVICE
63 depends on RFKILL
64 default n
65 ---help---
66 This driver adds support for rfkill and backlight control to Dell
67 laptops.
68
57config FUJITSU_LAPTOP 69config FUJITSU_LAPTOP
58 tristate "Fujitsu Laptop Extras" 70 tristate "Fujitsu Laptop Extras"
59 depends on ACPI 71 depends on ACPI
@@ -192,6 +204,17 @@ config THINKPAD_ACPI
192 204
193 If you have an IBM or Lenovo ThinkPad laptop, say Y or M here. 205 If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
194 206
207config THINKPAD_ACPI_DEBUGFACILITIES
208 bool "Maintainer debug facilities"
209 depends on THINKPAD_ACPI
210 default n
211 ---help---
212 Enables extra stuff in the thinkpad-acpi which is completely useless
213 for normal use. Read the driver source to find out what it does.
214
215 Say N here, unless you were told by a kernel maintainer to do
216 otherwise.
217
195config THINKPAD_ACPI_DEBUG 218config THINKPAD_ACPI_DEBUG
196 bool "Verbose debug mode" 219 bool "Verbose debug mode"
197 depends on THINKPAD_ACPI 220 depends on THINKPAD_ACPI
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 1e9de2ae0de5..e29065120be9 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
6obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o 6obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o
7obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o 7obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
8obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o 8obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
9obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
9obj-$(CONFIG_ACER_WMI) += acer-wmi.o 10obj-$(CONFIG_ACER_WMI) += acer-wmi.o
10obj-$(CONFIG_HP_WMI) += hp-wmi.o 11obj-$(CONFIG_HP_WMI) += hp-wmi.o
11obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o 12obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
diff --git a/drivers/misc/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 4d33a2068b7a..16e11c2ee19a 100644
--- a/drivers/misc/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -22,7 +22,7 @@
22#include <linux/rfkill.h> 22#include <linux/rfkill.h>
23#include <linux/power_supply.h> 23#include <linux/power_supply.h>
24#include <linux/acpi.h> 24#include <linux/acpi.h>
25#include "../firmware/dcdbas.h" 25#include "../../firmware/dcdbas.h"
26 26
27#define BRIGHTNESS_TOKEN 0x7d 27#define BRIGHTNESS_TOKEN 0x7d
28 28
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 02fe2b8b8939..9d93cb971e59 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -90,7 +90,7 @@ enum {
90}; 90};
91 91
92static const char *cm_getv[] = { 92static const char *cm_getv[] = {
93 "WLDG", NULL, NULL, NULL, 93 "WLDG", "BTHG", NULL, NULL,
94 "CAMG", NULL, NULL, NULL, 94 "CAMG", NULL, NULL, NULL,
95 NULL, "PBLG", NULL, NULL, 95 NULL, "PBLG", NULL, NULL,
96 "CFVG", NULL, NULL, NULL, 96 "CFVG", NULL, NULL, NULL,
@@ -99,7 +99,7 @@ static const char *cm_getv[] = {
99}; 99};
100 100
101static const char *cm_setv[] = { 101static const char *cm_setv[] = {
102 "WLDS", NULL, NULL, NULL, 102 "WLDS", "BTHS", NULL, NULL,
103 "CAMS", NULL, NULL, NULL, 103 "CAMS", NULL, NULL, NULL,
104 "SDSP", "PBLS", "HDPS", NULL, 104 "SDSP", "PBLS", "HDPS", NULL,
105 "CFVS", NULL, NULL, NULL, 105 "CFVS", NULL, NULL, NULL,
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 3478453eba7a..bcbc05107ba8 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -21,7 +21,7 @@
21 * 02110-1301, USA. 21 * 02110-1301, USA.
22 */ 22 */
23 23
24#define TPACPI_VERSION "0.21" 24#define TPACPI_VERSION "0.22"
25#define TPACPI_SYSFS_VERSION 0x020200 25#define TPACPI_SYSFS_VERSION 0x020200
26 26
27/* 27/*
@@ -122,6 +122,27 @@ enum {
122#define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */ 122#define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */
123#define TPACPI_HKEY_INPUT_VERSION 0x4101 123#define TPACPI_HKEY_INPUT_VERSION 0x4101
124 124
125/* ACPI \WGSV commands */
126enum {
127 TP_ACPI_WGSV_GET_STATE = 0x01, /* Get state information */
128 TP_ACPI_WGSV_PWR_ON_ON_RESUME = 0x02, /* Resume WWAN powered on */
129 TP_ACPI_WGSV_PWR_OFF_ON_RESUME = 0x03, /* Resume WWAN powered off */
130 TP_ACPI_WGSV_SAVE_STATE = 0x04, /* Save state for S4/S5 */
131};
132
133/* TP_ACPI_WGSV_GET_STATE bits */
134enum {
135 TP_ACPI_WGSV_STATE_WWANEXIST = 0x0001, /* WWAN hw available */
136 TP_ACPI_WGSV_STATE_WWANPWR = 0x0002, /* WWAN radio enabled */
137 TP_ACPI_WGSV_STATE_WWANPWRRES = 0x0004, /* WWAN state at resume */
138 TP_ACPI_WGSV_STATE_WWANBIOSOFF = 0x0008, /* WWAN disabled in BIOS */
139 TP_ACPI_WGSV_STATE_BLTHEXIST = 0x0001, /* BLTH hw available */
140 TP_ACPI_WGSV_STATE_BLTHPWR = 0x0002, /* BLTH radio enabled */
141 TP_ACPI_WGSV_STATE_BLTHPWRRES = 0x0004, /* BLTH state at resume */
142 TP_ACPI_WGSV_STATE_BLTHBIOSOFF = 0x0008, /* BLTH disabled in BIOS */
143 TP_ACPI_WGSV_STATE_UWBEXIST = 0x0010, /* UWB hw available */
144 TP_ACPI_WGSV_STATE_UWBPWR = 0x0020, /* UWB radio enabled */
145};
125 146
126/**************************************************************************** 147/****************************************************************************
127 * Main driver 148 * Main driver
@@ -148,14 +169,17 @@ enum {
148enum { 169enum {
149 TPACPI_RFK_BLUETOOTH_SW_ID = 0, 170 TPACPI_RFK_BLUETOOTH_SW_ID = 0,
150 TPACPI_RFK_WWAN_SW_ID, 171 TPACPI_RFK_WWAN_SW_ID,
172 TPACPI_RFK_UWB_SW_ID,
151}; 173};
152 174
153/* Debugging */ 175/* Debugging */
154#define TPACPI_LOG TPACPI_FILE ": " 176#define TPACPI_LOG TPACPI_FILE ": "
155#define TPACPI_ERR KERN_ERR TPACPI_LOG 177#define TPACPI_ALERT KERN_ALERT TPACPI_LOG
156#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG 178#define TPACPI_CRIT KERN_CRIT TPACPI_LOG
157#define TPACPI_INFO KERN_INFO TPACPI_LOG 179#define TPACPI_ERR KERN_ERR TPACPI_LOG
158#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG 180#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG
181#define TPACPI_INFO KERN_INFO TPACPI_LOG
182#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG
159 183
160#define TPACPI_DBG_ALL 0xffff 184#define TPACPI_DBG_ALL 0xffff
161#define TPACPI_DBG_INIT 0x0001 185#define TPACPI_DBG_INIT 0x0001
@@ -201,6 +225,7 @@ struct ibm_struct {
201 void (*exit) (void); 225 void (*exit) (void);
202 void (*resume) (void); 226 void (*resume) (void);
203 void (*suspend) (pm_message_t state); 227 void (*suspend) (pm_message_t state);
228 void (*shutdown) (void);
204 229
205 struct list_head all_drivers; 230 struct list_head all_drivers;
206 231
@@ -239,6 +264,7 @@ static struct {
239 u32 bright_16levels:1; 264 u32 bright_16levels:1;
240 u32 bright_acpimode:1; 265 u32 bright_acpimode:1;
241 u32 wan:1; 266 u32 wan:1;
267 u32 uwb:1;
242 u32 fan_ctrl_status_undef:1; 268 u32 fan_ctrl_status_undef:1;
243 u32 input_device_registered:1; 269 u32 input_device_registered:1;
244 u32 platform_drv_registered:1; 270 u32 platform_drv_registered:1;
@@ -288,6 +314,18 @@ struct tpacpi_led_classdev {
288 unsigned int led; 314 unsigned int led;
289}; 315};
290 316
317#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
318static int dbg_wlswemul;
319static int tpacpi_wlsw_emulstate;
320static int dbg_bluetoothemul;
321static int tpacpi_bluetooth_emulstate;
322static int dbg_wwanemul;
323static int tpacpi_wwan_emulstate;
324static int dbg_uwbemul;
325static int tpacpi_uwb_emulstate;
326#endif
327
328
291/**************************************************************************** 329/****************************************************************************
292 **************************************************************************** 330 ****************************************************************************
293 * 331 *
@@ -728,6 +766,18 @@ static int tpacpi_resume_handler(struct platform_device *pdev)
728 return 0; 766 return 0;
729} 767}
730 768
769static void tpacpi_shutdown_handler(struct platform_device *pdev)
770{
771 struct ibm_struct *ibm, *itmp;
772
773 list_for_each_entry_safe(ibm, itmp,
774 &tpacpi_all_drivers,
775 all_drivers) {
776 if (ibm->shutdown)
777 (ibm->shutdown)();
778 }
779}
780
731static struct platform_driver tpacpi_pdriver = { 781static struct platform_driver tpacpi_pdriver = {
732 .driver = { 782 .driver = {
733 .name = TPACPI_DRVR_NAME, 783 .name = TPACPI_DRVR_NAME,
@@ -735,6 +785,7 @@ static struct platform_driver tpacpi_pdriver = {
735 }, 785 },
736 .suspend = tpacpi_suspend_handler, 786 .suspend = tpacpi_suspend_handler,
737 .resume = tpacpi_resume_handler, 787 .resume = tpacpi_resume_handler,
788 .shutdown = tpacpi_shutdown_handler,
738}; 789};
739 790
740static struct platform_driver tpacpi_hwmon_pdriver = { 791static struct platform_driver tpacpi_hwmon_pdriver = {
@@ -922,11 +973,27 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
922 struct rfkill **rfk, 973 struct rfkill **rfk,
923 const enum rfkill_type rfktype, 974 const enum rfkill_type rfktype,
924 const char *name, 975 const char *name,
976 const bool set_default,
925 int (*toggle_radio)(void *, enum rfkill_state), 977 int (*toggle_radio)(void *, enum rfkill_state),
926 int (*get_state)(void *, enum rfkill_state *)) 978 int (*get_state)(void *, enum rfkill_state *))
927{ 979{
928 int res; 980 int res;
929 enum rfkill_state initial_state; 981 enum rfkill_state initial_state = RFKILL_STATE_SOFT_BLOCKED;
982
983 res = get_state(NULL, &initial_state);
984 if (res < 0) {
985 printk(TPACPI_ERR
986 "failed to read initial state for %s, error %d; "
987 "will turn radio off\n", name, res);
988 } else if (set_default) {
989 /* try to set the initial state as the default for the rfkill
990 * type, since we ask the firmware to preserve it across S5 in
991 * NVRAM */
992 rfkill_set_default(rfktype,
993 (initial_state == RFKILL_STATE_UNBLOCKED) ?
994 RFKILL_STATE_UNBLOCKED :
995 RFKILL_STATE_SOFT_BLOCKED);
996 }
930 997
931 *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype); 998 *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype);
932 if (!*rfk) { 999 if (!*rfk) {
@@ -938,9 +1005,7 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
938 (*rfk)->name = name; 1005 (*rfk)->name = name;
939 (*rfk)->get_state = get_state; 1006 (*rfk)->get_state = get_state;
940 (*rfk)->toggle_radio = toggle_radio; 1007 (*rfk)->toggle_radio = toggle_radio;
941 1008 (*rfk)->state = initial_state;
942 if (!get_state(NULL, &initial_state))
943 (*rfk)->state = initial_state;
944 1009
945 res = rfkill_register(*rfk); 1010 res = rfkill_register(*rfk);
946 if (res < 0) { 1011 if (res < 0) {
@@ -1006,6 +1071,119 @@ static DRIVER_ATTR(version, S_IRUGO,
1006 1071
1007/* --------------------------------------------------------------------- */ 1072/* --------------------------------------------------------------------- */
1008 1073
1074#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
1075
1076static void tpacpi_send_radiosw_update(void);
1077
1078/* wlsw_emulstate ------------------------------------------------------ */
1079static ssize_t tpacpi_driver_wlsw_emulstate_show(struct device_driver *drv,
1080 char *buf)
1081{
1082 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wlsw_emulstate);
1083}
1084
1085static ssize_t tpacpi_driver_wlsw_emulstate_store(struct device_driver *drv,
1086 const char *buf, size_t count)
1087{
1088 unsigned long t;
1089
1090 if (parse_strtoul(buf, 1, &t))
1091 return -EINVAL;
1092
1093 if (tpacpi_wlsw_emulstate != t) {
1094 tpacpi_wlsw_emulstate = !!t;
1095 tpacpi_send_radiosw_update();
1096 } else
1097 tpacpi_wlsw_emulstate = !!t;
1098
1099 return count;
1100}
1101
1102static DRIVER_ATTR(wlsw_emulstate, S_IWUSR | S_IRUGO,
1103 tpacpi_driver_wlsw_emulstate_show,
1104 tpacpi_driver_wlsw_emulstate_store);
1105
1106/* bluetooth_emulstate ------------------------------------------------- */
1107static ssize_t tpacpi_driver_bluetooth_emulstate_show(
1108 struct device_driver *drv,
1109 char *buf)
1110{
1111 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_bluetooth_emulstate);
1112}
1113
1114static ssize_t tpacpi_driver_bluetooth_emulstate_store(
1115 struct device_driver *drv,
1116 const char *buf, size_t count)
1117{
1118 unsigned long t;
1119
1120 if (parse_strtoul(buf, 1, &t))
1121 return -EINVAL;
1122
1123 tpacpi_bluetooth_emulstate = !!t;
1124
1125 return count;
1126}
1127
1128static DRIVER_ATTR(bluetooth_emulstate, S_IWUSR | S_IRUGO,
1129 tpacpi_driver_bluetooth_emulstate_show,
1130 tpacpi_driver_bluetooth_emulstate_store);
1131
1132/* wwan_emulstate ------------------------------------------------- */
1133static ssize_t tpacpi_driver_wwan_emulstate_show(
1134 struct device_driver *drv,
1135 char *buf)
1136{
1137 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wwan_emulstate);
1138}
1139
1140static ssize_t tpacpi_driver_wwan_emulstate_store(
1141 struct device_driver *drv,
1142 const char *buf, size_t count)
1143{
1144 unsigned long t;
1145
1146 if (parse_strtoul(buf, 1, &t))
1147 return -EINVAL;
1148
1149 tpacpi_wwan_emulstate = !!t;
1150
1151 return count;
1152}
1153
1154static DRIVER_ATTR(wwan_emulstate, S_IWUSR | S_IRUGO,
1155 tpacpi_driver_wwan_emulstate_show,
1156 tpacpi_driver_wwan_emulstate_store);
1157
1158/* uwb_emulstate ------------------------------------------------- */
1159static ssize_t tpacpi_driver_uwb_emulstate_show(
1160 struct device_driver *drv,
1161 char *buf)
1162{
1163 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_uwb_emulstate);
1164}
1165
1166static ssize_t tpacpi_driver_uwb_emulstate_store(
1167 struct device_driver *drv,
1168 const char *buf, size_t count)
1169{
1170 unsigned long t;
1171
1172 if (parse_strtoul(buf, 1, &t))
1173 return -EINVAL;
1174
1175 tpacpi_uwb_emulstate = !!t;
1176
1177 return count;
1178}
1179
1180static DRIVER_ATTR(uwb_emulstate, S_IWUSR | S_IRUGO,
1181 tpacpi_driver_uwb_emulstate_show,
1182 tpacpi_driver_uwb_emulstate_store);
1183#endif
1184
1185/* --------------------------------------------------------------------- */
1186
1009static struct driver_attribute *tpacpi_driver_attributes[] = { 1187static struct driver_attribute *tpacpi_driver_attributes[] = {
1010 &driver_attr_debug_level, &driver_attr_version, 1188 &driver_attr_debug_level, &driver_attr_version,
1011 &driver_attr_interface_version, 1189 &driver_attr_interface_version,
@@ -1022,6 +1200,17 @@ static int __init tpacpi_create_driver_attributes(struct device_driver *drv)
1022 i++; 1200 i++;
1023 } 1201 }
1024 1202
1203#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
1204 if (!res && dbg_wlswemul)
1205 res = driver_create_file(drv, &driver_attr_wlsw_emulstate);
1206 if (!res && dbg_bluetoothemul)
1207 res = driver_create_file(drv, &driver_attr_bluetooth_emulstate);
1208 if (!res && dbg_wwanemul)
1209 res = driver_create_file(drv, &driver_attr_wwan_emulstate);
1210 if (!res && dbg_uwbemul)
1211 res = driver_create_file(drv, &driver_attr_uwb_emulstate);
1212#endif
1213
1025 return res; 1214 return res;
1026} 1215}
1027 1216
@@ -1031,6 +1220,13 @@ static void tpacpi_remove_driver_attributes(struct device_driver *drv)
1031 1220
1032 for (i = 0; i < ARRAY_SIZE(tpacpi_driver_attributes); i++) 1221 for (i = 0; i < ARRAY_SIZE(tpacpi_driver_attributes); i++)
1033 driver_remove_file(drv, tpacpi_driver_attributes[i]); 1222 driver_remove_file(drv, tpacpi_driver_attributes[i]);
1223
1224#ifdef THINKPAD_ACPI_DEBUGFACILITIES
1225 driver_remove_file(drv, &driver_attr_wlsw_emulstate);
1226 driver_remove_file(drv, &driver_attr_bluetooth_emulstate);
1227 driver_remove_file(drv, &driver_attr_wwan_emulstate);
1228 driver_remove_file(drv, &driver_attr_uwb_emulstate);
1229#endif
1034} 1230}
1035 1231
1036/**************************************************************************** 1232/****************************************************************************
@@ -1216,6 +1412,12 @@ static struct attribute_set *hotkey_dev_attributes;
1216 1412
1217static int hotkey_get_wlsw(int *status) 1413static int hotkey_get_wlsw(int *status)
1218{ 1414{
1415#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
1416 if (dbg_wlswemul) {
1417 *status = !!tpacpi_wlsw_emulstate;
1418 return 0;
1419 }
1420#endif
1219 if (!acpi_evalf(hkey_handle, status, "WLSW", "d")) 1421 if (!acpi_evalf(hkey_handle, status, "WLSW", "d"))
1220 return -EIO; 1422 return -EIO;
1221 return 0; 1423 return 0;
@@ -1678,7 +1880,7 @@ static ssize_t hotkey_mask_show(struct device *dev,
1678{ 1880{
1679 int res; 1881 int res;
1680 1882
1681 if (mutex_lock_interruptible(&hotkey_mutex)) 1883 if (mutex_lock_killable(&hotkey_mutex))
1682 return -ERESTARTSYS; 1884 return -ERESTARTSYS;
1683 res = hotkey_mask_get(); 1885 res = hotkey_mask_get();
1684 mutex_unlock(&hotkey_mutex); 1886 mutex_unlock(&hotkey_mutex);
@@ -1697,7 +1899,7 @@ static ssize_t hotkey_mask_store(struct device *dev,
1697 if (parse_strtoul(buf, 0xffffffffUL, &t)) 1899 if (parse_strtoul(buf, 0xffffffffUL, &t))
1698 return -EINVAL; 1900 return -EINVAL;
1699 1901
1700 if (mutex_lock_interruptible(&hotkey_mutex)) 1902 if (mutex_lock_killable(&hotkey_mutex))
1701 return -ERESTARTSYS; 1903 return -ERESTARTSYS;
1702 1904
1703 res = hotkey_mask_set(t); 1905 res = hotkey_mask_set(t);
@@ -1783,7 +1985,7 @@ static ssize_t hotkey_source_mask_store(struct device *dev,
1783 ((t & ~TPACPI_HKEY_NVRAM_KNOWN_MASK) != 0)) 1985 ((t & ~TPACPI_HKEY_NVRAM_KNOWN_MASK) != 0))
1784 return -EINVAL; 1986 return -EINVAL;
1785 1987
1786 if (mutex_lock_interruptible(&hotkey_mutex)) 1988 if (mutex_lock_killable(&hotkey_mutex))
1787 return -ERESTARTSYS; 1989 return -ERESTARTSYS;
1788 1990
1789 HOTKEY_CONFIG_CRITICAL_START 1991 HOTKEY_CONFIG_CRITICAL_START
@@ -1818,7 +2020,7 @@ static ssize_t hotkey_poll_freq_store(struct device *dev,
1818 if (parse_strtoul(buf, 25, &t)) 2020 if (parse_strtoul(buf, 25, &t))
1819 return -EINVAL; 2021 return -EINVAL;
1820 2022
1821 if (mutex_lock_interruptible(&hotkey_mutex)) 2023 if (mutex_lock_killable(&hotkey_mutex))
1822 return -ERESTARTSYS; 2024 return -ERESTARTSYS;
1823 2025
1824 hotkey_poll_freq = t; 2026 hotkey_poll_freq = t;
@@ -1958,6 +2160,7 @@ static struct attribute *hotkey_mask_attributes[] __initdata = {
1958 2160
1959static void bluetooth_update_rfk(void); 2161static void bluetooth_update_rfk(void);
1960static void wan_update_rfk(void); 2162static void wan_update_rfk(void);
2163static void uwb_update_rfk(void);
1961static void tpacpi_send_radiosw_update(void) 2164static void tpacpi_send_radiosw_update(void)
1962{ 2165{
1963 int wlsw; 2166 int wlsw;
@@ -1967,6 +2170,8 @@ static void tpacpi_send_radiosw_update(void)
1967 bluetooth_update_rfk(); 2170 bluetooth_update_rfk();
1968 if (tp_features.wan) 2171 if (tp_features.wan)
1969 wan_update_rfk(); 2172 wan_update_rfk();
2173 if (tp_features.uwb)
2174 uwb_update_rfk();
1970 2175
1971 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { 2176 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
1972 mutex_lock(&tpacpi_inputdev_send_mutex); 2177 mutex_lock(&tpacpi_inputdev_send_mutex);
@@ -2222,6 +2427,13 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
2222 hotkey_source_mask, hotkey_poll_freq); 2427 hotkey_source_mask, hotkey_poll_freq);
2223#endif 2428#endif
2224 2429
2430#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2431 if (dbg_wlswemul) {
2432 tp_features.hotkey_wlsw = 1;
2433 printk(TPACPI_INFO
2434 "radio switch emulation enabled\n");
2435 } else
2436#endif
2225 /* Not all thinkpads have a hardware radio switch */ 2437 /* Not all thinkpads have a hardware radio switch */
2226 if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) { 2438 if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
2227 tp_features.hotkey_wlsw = 1; 2439 tp_features.hotkey_wlsw = 1;
@@ -2361,13 +2573,154 @@ err_exit:
2361 return (res < 0)? res : 1; 2573 return (res < 0)? res : 1;
2362} 2574}
2363 2575
2576static bool hotkey_notify_hotkey(const u32 hkey,
2577 bool *send_acpi_ev,
2578 bool *ignore_acpi_ev)
2579{
2580 /* 0x1000-0x1FFF: key presses */
2581 unsigned int scancode = hkey & 0xfff;
2582 *send_acpi_ev = true;
2583 *ignore_acpi_ev = false;
2584
2585 if (scancode > 0 && scancode < 0x21) {
2586 scancode--;
2587 if (!(hotkey_source_mask & (1 << scancode))) {
2588 tpacpi_input_send_key(scancode);
2589 *send_acpi_ev = false;
2590 } else {
2591 *ignore_acpi_ev = true;
2592 }
2593 return true;
2594 }
2595 return false;
2596}
2597
2598static bool hotkey_notify_wakeup(const u32 hkey,
2599 bool *send_acpi_ev,
2600 bool *ignore_acpi_ev)
2601{
2602 /* 0x2000-0x2FFF: Wakeup reason */
2603 *send_acpi_ev = true;
2604 *ignore_acpi_ev = false;
2605
2606 switch (hkey) {
2607 case 0x2304: /* suspend, undock */
2608 case 0x2404: /* hibernation, undock */
2609 hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK;
2610 *ignore_acpi_ev = true;
2611 break;
2612
2613 case 0x2305: /* suspend, bay eject */
2614 case 0x2405: /* hibernation, bay eject */
2615 hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ;
2616 *ignore_acpi_ev = true;
2617 break;
2618
2619 case 0x2313: /* Battery on critical low level (S3) */
2620 case 0x2413: /* Battery on critical low level (S4) */
2621 printk(TPACPI_ALERT
2622 "EMERGENCY WAKEUP: battery almost empty\n");
2623 /* how to auto-heal: */
2624 /* 2313: woke up from S3, go to S4/S5 */
2625 /* 2413: woke up from S4, go to S5 */
2626 break;
2627
2628 default:
2629 return false;
2630 }
2631
2632 if (hotkey_wakeup_reason != TP_ACPI_WAKEUP_NONE) {
2633 printk(TPACPI_INFO
2634 "woke up due to a hot-unplug "
2635 "request...\n");
2636 hotkey_wakeup_reason_notify_change();
2637 }
2638 return true;
2639}
2640
2641static bool hotkey_notify_usrevent(const u32 hkey,
2642 bool *send_acpi_ev,
2643 bool *ignore_acpi_ev)
2644{
2645 /* 0x5000-0x5FFF: human interface helpers */
2646 *send_acpi_ev = true;
2647 *ignore_acpi_ev = false;
2648
2649 switch (hkey) {
2650 case 0x5010: /* Lenovo new BIOS: brightness changed */
2651 case 0x500b: /* X61t: tablet pen inserted into bay */
2652 case 0x500c: /* X61t: tablet pen removed from bay */
2653 return true;
2654
2655 case 0x5009: /* X41t-X61t: swivel up (tablet mode) */
2656 case 0x500a: /* X41t-X61t: swivel down (normal mode) */
2657 tpacpi_input_send_tabletsw();
2658 hotkey_tablet_mode_notify_change();
2659 *send_acpi_ev = false;
2660 return true;
2661
2662 case 0x5001:
2663 case 0x5002:
2664 /* LID switch events. Do not propagate */
2665 *ignore_acpi_ev = true;
2666 return true;
2667
2668 default:
2669 return false;
2670 }
2671}
2672
2673static bool hotkey_notify_thermal(const u32 hkey,
2674 bool *send_acpi_ev,
2675 bool *ignore_acpi_ev)
2676{
2677 /* 0x6000-0x6FFF: thermal alarms */
2678 *send_acpi_ev = true;
2679 *ignore_acpi_ev = false;
2680
2681 switch (hkey) {
2682 case 0x6011:
2683 printk(TPACPI_CRIT
2684 "THERMAL ALARM: battery is too hot!\n");
2685 /* recommended action: warn user through gui */
2686 return true;
2687 case 0x6012:
2688 printk(TPACPI_ALERT
2689 "THERMAL EMERGENCY: battery is extremely hot!\n");
2690 /* recommended action: immediate sleep/hibernate */
2691 return true;
2692 case 0x6021:
2693 printk(TPACPI_CRIT
2694 "THERMAL ALARM: "
2695 "a sensor reports something is too hot!\n");
2696 /* recommended action: warn user through gui, that */
2697 /* some internal component is too hot */
2698 return true;
2699 case 0x6022:
2700 printk(TPACPI_ALERT
2701 "THERMAL EMERGENCY: "
2702 "a sensor reports something is extremely hot!\n");
2703 /* recommended action: immediate sleep/hibernate */
2704 return true;
2705 case 0x6030:
2706 printk(TPACPI_INFO
2707 "EC reports that Thermal Table has changed\n");
2708 /* recommended action: do nothing, we don't have
2709 * Lenovo ATM information */
2710 return true;
2711 default:
2712 printk(TPACPI_ALERT
2713 "THERMAL ALERT: unknown thermal alarm received\n");
2714 return false;
2715 }
2716}
2717
2364static void hotkey_notify(struct ibm_struct *ibm, u32 event) 2718static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2365{ 2719{
2366 u32 hkey; 2720 u32 hkey;
2367 unsigned int scancode; 2721 bool send_acpi_ev;
2368 int send_acpi_ev; 2722 bool ignore_acpi_ev;
2369 int ignore_acpi_ev; 2723 bool known_ev;
2370 int unk_ev;
2371 2724
2372 if (event != 0x80) { 2725 if (event != 0x80) {
2373 printk(TPACPI_ERR 2726 printk(TPACPI_ERR
@@ -2375,7 +2728,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2375 /* forward it to userspace, maybe it knows how to handle it */ 2728 /* forward it to userspace, maybe it knows how to handle it */
2376 acpi_bus_generate_netlink_event( 2729 acpi_bus_generate_netlink_event(
2377 ibm->acpi->device->pnp.device_class, 2730 ibm->acpi->device->pnp.device_class,
2378 ibm->acpi->device->dev.bus_id, 2731 dev_name(&ibm->acpi->device->dev),
2379 event, 0); 2732 event, 0);
2380 return; 2733 return;
2381 } 2734 }
@@ -2391,107 +2744,72 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2391 return; 2744 return;
2392 } 2745 }
2393 2746
2394 send_acpi_ev = 1; 2747 send_acpi_ev = true;
2395 ignore_acpi_ev = 0; 2748 ignore_acpi_ev = false;
2396 unk_ev = 0;
2397 2749
2398 switch (hkey >> 12) { 2750 switch (hkey >> 12) {
2399 case 1: 2751 case 1:
2400 /* 0x1000-0x1FFF: key presses */ 2752 /* 0x1000-0x1FFF: key presses */
2401 scancode = hkey & 0xfff; 2753 known_ev = hotkey_notify_hotkey(hkey, &send_acpi_ev,
2402 if (scancode > 0 && scancode < 0x21) { 2754 &ignore_acpi_ev);
2403 scancode--;
2404 if (!(hotkey_source_mask & (1 << scancode))) {
2405 tpacpi_input_send_key(scancode);
2406 send_acpi_ev = 0;
2407 } else {
2408 ignore_acpi_ev = 1;
2409 }
2410 } else {
2411 unk_ev = 1;
2412 }
2413 break; 2755 break;
2414 case 2: 2756 case 2:
2415 /* Wakeup reason */ 2757 /* 0x2000-0x2FFF: Wakeup reason */
2416 switch (hkey) { 2758 known_ev = hotkey_notify_wakeup(hkey, &send_acpi_ev,
2417 case 0x2304: /* suspend, undock */ 2759 &ignore_acpi_ev);
2418 case 0x2404: /* hibernation, undock */
2419 hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK;
2420 ignore_acpi_ev = 1;
2421 break;
2422 case 0x2305: /* suspend, bay eject */
2423 case 0x2405: /* hibernation, bay eject */
2424 hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ;
2425 ignore_acpi_ev = 1;
2426 break;
2427 default:
2428 unk_ev = 1;
2429 }
2430 if (hotkey_wakeup_reason != TP_ACPI_WAKEUP_NONE) {
2431 printk(TPACPI_INFO
2432 "woke up due to a hot-unplug "
2433 "request...\n");
2434 hotkey_wakeup_reason_notify_change();
2435 }
2436 break; 2760 break;
2437 case 3: 2761 case 3:
2438 /* bay-related wakeups */ 2762 /* 0x3000-0x3FFF: bay-related wakeups */
2439 if (hkey == 0x3003) { 2763 if (hkey == 0x3003) {
2440 hotkey_autosleep_ack = 1; 2764 hotkey_autosleep_ack = 1;
2441 printk(TPACPI_INFO 2765 printk(TPACPI_INFO
2442 "bay ejected\n"); 2766 "bay ejected\n");
2443 hotkey_wakeup_hotunplug_complete_notify_change(); 2767 hotkey_wakeup_hotunplug_complete_notify_change();
2768 known_ev = true;
2444 } else { 2769 } else {
2445 unk_ev = 1; 2770 known_ev = false;
2446 } 2771 }
2447 break; 2772 break;
2448 case 4: 2773 case 4:
2449 /* dock-related wakeups */ 2774 /* 0x4000-0x4FFF: dock-related wakeups */
2450 if (hkey == 0x4003) { 2775 if (hkey == 0x4003) {
2451 hotkey_autosleep_ack = 1; 2776 hotkey_autosleep_ack = 1;
2452 printk(TPACPI_INFO 2777 printk(TPACPI_INFO
2453 "undocked\n"); 2778 "undocked\n");
2454 hotkey_wakeup_hotunplug_complete_notify_change(); 2779 hotkey_wakeup_hotunplug_complete_notify_change();
2780 known_ev = true;
2455 } else { 2781 } else {
2456 unk_ev = 1; 2782 known_ev = false;
2457 } 2783 }
2458 break; 2784 break;
2459 case 5: 2785 case 5:
2460 /* 0x5000-0x5FFF: human interface helpers */ 2786 /* 0x5000-0x5FFF: human interface helpers */
2461 switch (hkey) { 2787 known_ev = hotkey_notify_usrevent(hkey, &send_acpi_ev,
2462 case 0x5010: /* Lenovo new BIOS: brightness changed */ 2788 &ignore_acpi_ev);
2463 case 0x500b: /* X61t: tablet pen inserted into bay */ 2789 break;
2464 case 0x500c: /* X61t: tablet pen removed from bay */ 2790 case 6:
2465 break; 2791 /* 0x6000-0x6FFF: thermal alarms */
2466 case 0x5009: /* X41t-X61t: swivel up (tablet mode) */ 2792 known_ev = hotkey_notify_thermal(hkey, &send_acpi_ev,
2467 case 0x500a: /* X41t-X61t: swivel down (normal mode) */ 2793 &ignore_acpi_ev);
2468 tpacpi_input_send_tabletsw();
2469 hotkey_tablet_mode_notify_change();
2470 send_acpi_ev = 0;
2471 break;
2472 case 0x5001:
2473 case 0x5002:
2474 /* LID switch events. Do not propagate */
2475 ignore_acpi_ev = 1;
2476 break;
2477 default:
2478 unk_ev = 1;
2479 }
2480 break; 2794 break;
2481 case 7: 2795 case 7:
2482 /* 0x7000-0x7FFF: misc */ 2796 /* 0x7000-0x7FFF: misc */
2483 if (tp_features.hotkey_wlsw && hkey == 0x7000) { 2797 if (tp_features.hotkey_wlsw && hkey == 0x7000) {
2484 tpacpi_send_radiosw_update(); 2798 tpacpi_send_radiosw_update();
2485 send_acpi_ev = 0; 2799 send_acpi_ev = 0;
2800 known_ev = true;
2486 break; 2801 break;
2487 } 2802 }
2488 /* fallthrough to default */ 2803 /* fallthrough to default */
2489 default: 2804 default:
2490 unk_ev = 1; 2805 known_ev = false;
2491 } 2806 }
2492 if (unk_ev) { 2807 if (!known_ev) {
2493 printk(TPACPI_NOTICE 2808 printk(TPACPI_NOTICE
2494 "unhandled HKEY event 0x%04x\n", hkey); 2809 "unhandled HKEY event 0x%04x\n", hkey);
2810 printk(TPACPI_NOTICE
2811 "please report the conditions when this "
2812 "event happened to %s\n", TPACPI_MAIL);
2495 } 2813 }
2496 2814
2497 /* Legacy events */ 2815 /* Legacy events */
@@ -2505,7 +2823,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2505 if (!ignore_acpi_ev && send_acpi_ev) { 2823 if (!ignore_acpi_ev && send_acpi_ev) {
2506 acpi_bus_generate_netlink_event( 2824 acpi_bus_generate_netlink_event(
2507 ibm->acpi->device->pnp.device_class, 2825 ibm->acpi->device->pnp.device_class,
2508 ibm->acpi->device->dev.bus_id, 2826 dev_name(&ibm->acpi->device->dev),
2509 event, hkey); 2827 event, hkey);
2510 } 2828 }
2511 } 2829 }
@@ -2544,7 +2862,7 @@ static int hotkey_read(char *p)
2544 return len; 2862 return len;
2545 } 2863 }
2546 2864
2547 if (mutex_lock_interruptible(&hotkey_mutex)) 2865 if (mutex_lock_killable(&hotkey_mutex))
2548 return -ERESTARTSYS; 2866 return -ERESTARTSYS;
2549 res = hotkey_status_get(&status); 2867 res = hotkey_status_get(&status);
2550 if (!res) 2868 if (!res)
@@ -2575,7 +2893,7 @@ static int hotkey_write(char *buf)
2575 if (!tp_features.hotkey) 2893 if (!tp_features.hotkey)
2576 return -ENODEV; 2894 return -ENODEV;
2577 2895
2578 if (mutex_lock_interruptible(&hotkey_mutex)) 2896 if (mutex_lock_killable(&hotkey_mutex))
2579 return -ERESTARTSYS; 2897 return -ERESTARTSYS;
2580 2898
2581 status = -1; 2899 status = -1;
@@ -2640,11 +2958,28 @@ enum {
2640 /* ACPI GBDC/SBDC bits */ 2958 /* ACPI GBDC/SBDC bits */
2641 TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */ 2959 TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */
2642 TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */ 2960 TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */
2643 TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */ 2961 TP_ACPI_BLUETOOTH_RESUMECTRL = 0x04, /* Bluetooth state at resume:
2962 off / last state */
2963};
2964
2965enum {
2966 /* ACPI \BLTH commands */
2967 TP_ACPI_BLTH_GET_ULTRAPORT_ID = 0x00, /* Get Ultraport BT ID */
2968 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
2969 TP_ACPI_BLTH_PWR_ON_ON_RESUME = 0x02, /* Resume powered on */
2970 TP_ACPI_BLTH_PWR_OFF_ON_RESUME = 0x03, /* Resume powered off */
2971 TP_ACPI_BLTH_SAVE_STATE = 0x05, /* Save state for S4/S5 */
2644}; 2972};
2645 2973
2646static struct rfkill *tpacpi_bluetooth_rfkill; 2974static struct rfkill *tpacpi_bluetooth_rfkill;
2647 2975
2976static void bluetooth_suspend(pm_message_t state)
2977{
2978 /* Try to make sure radio will resume powered off */
2979 acpi_evalf(NULL, NULL, "\\BLTH", "vd",
2980 TP_ACPI_BLTH_PWR_OFF_ON_RESUME);
2981}
2982
2648static int bluetooth_get_radiosw(void) 2983static int bluetooth_get_radiosw(void)
2649{ 2984{
2650 int status; 2985 int status;
@@ -2656,6 +2991,12 @@ static int bluetooth_get_radiosw(void)
2656 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status) 2991 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status)
2657 return RFKILL_STATE_HARD_BLOCKED; 2992 return RFKILL_STATE_HARD_BLOCKED;
2658 2993
2994#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2995 if (dbg_bluetoothemul)
2996 return (tpacpi_bluetooth_emulstate) ?
2997 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
2998#endif
2999
2659 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) 3000 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
2660 return -EIO; 3001 return -EIO;
2661 3002
@@ -2689,12 +3030,20 @@ static int bluetooth_set_radiosw(int radio_on, int update_rfk)
2689 && radio_on) 3030 && radio_on)
2690 return -EPERM; 3031 return -EPERM;
2691 3032
2692 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) 3033#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2693 return -EIO; 3034 if (dbg_bluetoothemul) {
3035 tpacpi_bluetooth_emulstate = !!radio_on;
3036 if (update_rfk)
3037 bluetooth_update_rfk();
3038 return 0;
3039 }
3040#endif
3041
3042 /* We make sure to keep TP_ACPI_BLUETOOTH_RESUMECTRL off */
2694 if (radio_on) 3043 if (radio_on)
2695 status |= TP_ACPI_BLUETOOTH_RADIOSSW; 3044 status = TP_ACPI_BLUETOOTH_RADIOSSW;
2696 else 3045 else
2697 status &= ~TP_ACPI_BLUETOOTH_RADIOSSW; 3046 status = 0;
2698 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) 3047 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
2699 return -EIO; 3048 return -EIO;
2700 3049
@@ -2765,8 +3114,19 @@ static int tpacpi_bluetooth_rfk_set(void *data, enum rfkill_state state)
2765 return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); 3114 return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
2766} 3115}
2767 3116
3117static void bluetooth_shutdown(void)
3118{
3119 /* Order firmware to save current state to NVRAM */
3120 if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd",
3121 TP_ACPI_BLTH_SAVE_STATE))
3122 printk(TPACPI_NOTICE
3123 "failed to save bluetooth state to NVRAM\n");
3124}
3125
2768static void bluetooth_exit(void) 3126static void bluetooth_exit(void)
2769{ 3127{
3128 bluetooth_shutdown();
3129
2770 if (tpacpi_bluetooth_rfkill) 3130 if (tpacpi_bluetooth_rfkill)
2771 rfkill_unregister(tpacpi_bluetooth_rfkill); 3131 rfkill_unregister(tpacpi_bluetooth_rfkill);
2772 3132
@@ -2792,6 +3152,13 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
2792 str_supported(tp_features.bluetooth), 3152 str_supported(tp_features.bluetooth),
2793 status); 3153 status);
2794 3154
3155#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3156 if (dbg_bluetoothemul) {
3157 tp_features.bluetooth = 1;
3158 printk(TPACPI_INFO
3159 "bluetooth switch emulation enabled\n");
3160 } else
3161#endif
2795 if (tp_features.bluetooth && 3162 if (tp_features.bluetooth &&
2796 !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) { 3163 !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) {
2797 /* no bluetooth hardware present in system */ 3164 /* no bluetooth hardware present in system */
@@ -2812,6 +3179,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
2812 &tpacpi_bluetooth_rfkill, 3179 &tpacpi_bluetooth_rfkill,
2813 RFKILL_TYPE_BLUETOOTH, 3180 RFKILL_TYPE_BLUETOOTH,
2814 "tpacpi_bluetooth_sw", 3181 "tpacpi_bluetooth_sw",
3182 true,
2815 tpacpi_bluetooth_rfk_set, 3183 tpacpi_bluetooth_rfk_set,
2816 tpacpi_bluetooth_rfk_get); 3184 tpacpi_bluetooth_rfk_get);
2817 if (res) { 3185 if (res) {
@@ -2864,6 +3232,8 @@ static struct ibm_struct bluetooth_driver_data = {
2864 .read = bluetooth_read, 3232 .read = bluetooth_read,
2865 .write = bluetooth_write, 3233 .write = bluetooth_write,
2866 .exit = bluetooth_exit, 3234 .exit = bluetooth_exit,
3235 .suspend = bluetooth_suspend,
3236 .shutdown = bluetooth_shutdown,
2867}; 3237};
2868 3238
2869/************************************************************************* 3239/*************************************************************************
@@ -2874,11 +3244,19 @@ enum {
2874 /* ACPI GWAN/SWAN bits */ 3244 /* ACPI GWAN/SWAN bits */
2875 TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */ 3245 TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */
2876 TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */ 3246 TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */
2877 TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */ 3247 TP_ACPI_WANCARD_RESUMECTRL = 0x04, /* Wan state at resume:
3248 off / last state */
2878}; 3249};
2879 3250
2880static struct rfkill *tpacpi_wan_rfkill; 3251static struct rfkill *tpacpi_wan_rfkill;
2881 3252
3253static void wan_suspend(pm_message_t state)
3254{
3255 /* Try to make sure radio will resume powered off */
3256 acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
3257 TP_ACPI_WGSV_PWR_OFF_ON_RESUME);
3258}
3259
2882static int wan_get_radiosw(void) 3260static int wan_get_radiosw(void)
2883{ 3261{
2884 int status; 3262 int status;
@@ -2890,6 +3268,12 @@ static int wan_get_radiosw(void)
2890 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status) 3268 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status)
2891 return RFKILL_STATE_HARD_BLOCKED; 3269 return RFKILL_STATE_HARD_BLOCKED;
2892 3270
3271#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3272 if (dbg_wwanemul)
3273 return (tpacpi_wwan_emulstate) ?
3274 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
3275#endif
3276
2893 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) 3277 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
2894 return -EIO; 3278 return -EIO;
2895 3279
@@ -2923,12 +3307,20 @@ static int wan_set_radiosw(int radio_on, int update_rfk)
2923 && radio_on) 3307 && radio_on)
2924 return -EPERM; 3308 return -EPERM;
2925 3309
2926 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) 3310#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2927 return -EIO; 3311 if (dbg_wwanemul) {
3312 tpacpi_wwan_emulstate = !!radio_on;
3313 if (update_rfk)
3314 wan_update_rfk();
3315 return 0;
3316 }
3317#endif
3318
3319 /* We make sure to keep TP_ACPI_WANCARD_RESUMECTRL off */
2928 if (radio_on) 3320 if (radio_on)
2929 status |= TP_ACPI_WANCARD_RADIOSSW; 3321 status = TP_ACPI_WANCARD_RADIOSSW;
2930 else 3322 else
2931 status &= ~TP_ACPI_WANCARD_RADIOSSW; 3323 status = 0;
2932 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status)) 3324 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
2933 return -EIO; 3325 return -EIO;
2934 3326
@@ -2999,8 +3391,19 @@ static int tpacpi_wan_rfk_set(void *data, enum rfkill_state state)
2999 return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); 3391 return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
3000} 3392}
3001 3393
3394static void wan_shutdown(void)
3395{
3396 /* Order firmware to save current state to NVRAM */
3397 if (!acpi_evalf(NULL, NULL, "\\WGSV", "vd",
3398 TP_ACPI_WGSV_SAVE_STATE))
3399 printk(TPACPI_NOTICE
3400 "failed to save WWAN state to NVRAM\n");
3401}
3402
3002static void wan_exit(void) 3403static void wan_exit(void)
3003{ 3404{
3405 wan_shutdown();
3406
3004 if (tpacpi_wan_rfkill) 3407 if (tpacpi_wan_rfkill)
3005 rfkill_unregister(tpacpi_wan_rfkill); 3408 rfkill_unregister(tpacpi_wan_rfkill);
3006 3409
@@ -3024,6 +3427,13 @@ static int __init wan_init(struct ibm_init_struct *iibm)
3024 str_supported(tp_features.wan), 3427 str_supported(tp_features.wan),
3025 status); 3428 status);
3026 3429
3430#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3431 if (dbg_wwanemul) {
3432 tp_features.wan = 1;
3433 printk(TPACPI_INFO
3434 "wwan switch emulation enabled\n");
3435 } else
3436#endif
3027 if (tp_features.wan && 3437 if (tp_features.wan &&
3028 !(status & TP_ACPI_WANCARD_HWPRESENT)) { 3438 !(status & TP_ACPI_WANCARD_HWPRESENT)) {
3029 /* no wan hardware present in system */ 3439 /* no wan hardware present in system */
@@ -3044,6 +3454,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
3044 &tpacpi_wan_rfkill, 3454 &tpacpi_wan_rfkill,
3045 RFKILL_TYPE_WWAN, 3455 RFKILL_TYPE_WWAN,
3046 "tpacpi_wwan_sw", 3456 "tpacpi_wwan_sw",
3457 true,
3047 tpacpi_wan_rfk_set, 3458 tpacpi_wan_rfk_set,
3048 tpacpi_wan_rfk_get); 3459 tpacpi_wan_rfk_get);
3049 if (res) { 3460 if (res) {
@@ -3096,6 +3507,164 @@ static struct ibm_struct wan_driver_data = {
3096 .read = wan_read, 3507 .read = wan_read,
3097 .write = wan_write, 3508 .write = wan_write,
3098 .exit = wan_exit, 3509 .exit = wan_exit,
3510 .suspend = wan_suspend,
3511 .shutdown = wan_shutdown,
3512};
3513
3514/*************************************************************************
3515 * UWB subdriver
3516 */
3517
3518enum {
3519 /* ACPI GUWB/SUWB bits */
3520 TP_ACPI_UWB_HWPRESENT = 0x01, /* UWB hw available */
3521 TP_ACPI_UWB_RADIOSSW = 0x02, /* UWB radio enabled */
3522};
3523
3524static struct rfkill *tpacpi_uwb_rfkill;
3525
3526static int uwb_get_radiosw(void)
3527{
3528 int status;
3529
3530 if (!tp_features.uwb)
3531 return -ENODEV;
3532
3533 /* WLSW overrides UWB in firmware/hardware, reflect that */
3534 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status)
3535 return RFKILL_STATE_HARD_BLOCKED;
3536
3537#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3538 if (dbg_uwbemul)
3539 return (tpacpi_uwb_emulstate) ?
3540 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
3541#endif
3542
3543 if (!acpi_evalf(hkey_handle, &status, "GUWB", "d"))
3544 return -EIO;
3545
3546 return ((status & TP_ACPI_UWB_RADIOSSW) != 0) ?
3547 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
3548}
3549
3550static void uwb_update_rfk(void)
3551{
3552 int status;
3553
3554 if (!tpacpi_uwb_rfkill)
3555 return;
3556
3557 status = uwb_get_radiosw();
3558 if (status < 0)
3559 return;
3560 rfkill_force_state(tpacpi_uwb_rfkill, status);
3561}
3562
3563static int uwb_set_radiosw(int radio_on, int update_rfk)
3564{
3565 int status;
3566
3567 if (!tp_features.uwb)
3568 return -ENODEV;
3569
3570 /* WLSW overrides UWB in firmware/hardware, but there is no
3571 * reason to risk weird behaviour. */
3572 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status
3573 && radio_on)
3574 return -EPERM;
3575
3576#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3577 if (dbg_uwbemul) {
3578 tpacpi_uwb_emulstate = !!radio_on;
3579 if (update_rfk)
3580 uwb_update_rfk();
3581 return 0;
3582 }
3583#endif
3584
3585 status = (radio_on) ? TP_ACPI_UWB_RADIOSSW : 0;
3586 if (!acpi_evalf(hkey_handle, NULL, "SUWB", "vd", status))
3587 return -EIO;
3588
3589 if (update_rfk)
3590 uwb_update_rfk();
3591
3592 return 0;
3593}
3594
3595/* --------------------------------------------------------------------- */
3596
3597static int tpacpi_uwb_rfk_get(void *data, enum rfkill_state *state)
3598{
3599 int uwbs = uwb_get_radiosw();
3600
3601 if (uwbs < 0)
3602 return uwbs;
3603
3604 *state = uwbs;
3605 return 0;
3606}
3607
3608static int tpacpi_uwb_rfk_set(void *data, enum rfkill_state state)
3609{
3610 return uwb_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
3611}
3612
3613static void uwb_exit(void)
3614{
3615 if (tpacpi_uwb_rfkill)
3616 rfkill_unregister(tpacpi_uwb_rfkill);
3617}
3618
3619static int __init uwb_init(struct ibm_init_struct *iibm)
3620{
3621 int res;
3622 int status = 0;
3623
3624 vdbg_printk(TPACPI_DBG_INIT, "initializing uwb subdriver\n");
3625
3626 TPACPI_ACPIHANDLE_INIT(hkey);
3627
3628 tp_features.uwb = hkey_handle &&
3629 acpi_evalf(hkey_handle, &status, "GUWB", "qd");
3630
3631 vdbg_printk(TPACPI_DBG_INIT, "uwb is %s, status 0x%02x\n",
3632 str_supported(tp_features.uwb),
3633 status);
3634
3635#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3636 if (dbg_uwbemul) {
3637 tp_features.uwb = 1;
3638 printk(TPACPI_INFO
3639 "uwb switch emulation enabled\n");
3640 } else
3641#endif
3642 if (tp_features.uwb &&
3643 !(status & TP_ACPI_UWB_HWPRESENT)) {
3644 /* no uwb hardware present in system */
3645 tp_features.uwb = 0;
3646 dbg_printk(TPACPI_DBG_INIT,
3647 "uwb hardware not installed\n");
3648 }
3649
3650 if (!tp_features.uwb)
3651 return 1;
3652
3653 res = tpacpi_new_rfkill(TPACPI_RFK_UWB_SW_ID,
3654 &tpacpi_uwb_rfkill,
3655 RFKILL_TYPE_UWB,
3656 "tpacpi_uwb_sw",
3657 false,
3658 tpacpi_uwb_rfk_set,
3659 tpacpi_uwb_rfk_get);
3660
3661 return res;
3662}
3663
3664static struct ibm_struct uwb_driver_data = {
3665 .name = "uwb",
3666 .exit = uwb_exit,
3667 .flags.experimental = 1,
3099}; 3668};
3100 3669
3101/************************************************************************* 3670/*************************************************************************
@@ -3724,7 +4293,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event)
3724 } 4293 }
3725 acpi_bus_generate_proc_event(ibm->acpi->device, event, data); 4294 acpi_bus_generate_proc_event(ibm->acpi->device, event, data);
3726 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, 4295 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
3727 ibm->acpi->device->dev.bus_id, 4296 dev_name(&ibm->acpi->device->dev),
3728 event, data); 4297 event, data);
3729} 4298}
3730 4299
@@ -3826,7 +4395,7 @@ static void bay_notify(struct ibm_struct *ibm, u32 event)
3826{ 4395{
3827 acpi_bus_generate_proc_event(ibm->acpi->device, event, 0); 4396 acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
3828 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, 4397 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
3829 ibm->acpi->device->dev.bus_id, 4398 dev_name(&ibm->acpi->device->dev),
3830 event, 0); 4399 event, 0);
3831} 4400}
3832 4401
@@ -4850,7 +5419,7 @@ static int brightness_set(int value)
4850 value < 0) 5419 value < 0)
4851 return -EINVAL; 5420 return -EINVAL;
4852 5421
4853 res = mutex_lock_interruptible(&brightness_mutex); 5422 res = mutex_lock_killable(&brightness_mutex);
4854 if (res < 0) 5423 if (res < 0)
4855 return res; 5424 return res;
4856 5425
@@ -5334,6 +5903,60 @@ TPACPI_HANDLE(sfan, ec, "SFAN", /* 570 */
5334 ); /* all others */ 5903 ); /* all others */
5335 5904
5336/* 5905/*
5906 * Unitialized HFSP quirk: ACPI DSDT and EC fail to initialize the
5907 * HFSP register at boot, so it contains 0x07 but the Thinkpad could
5908 * be in auto mode (0x80).
5909 *
5910 * This is corrected by any write to HFSP either by the driver, or
5911 * by the firmware.
5912 *
5913 * We assume 0x07 really means auto mode while this quirk is active,
5914 * as this is far more likely than the ThinkPad being in level 7,
5915 * which is only used by the firmware during thermal emergencies.
5916 */
5917
5918static void fan_quirk1_detect(void)
5919{
5920 /* In some ThinkPads, neither the EC nor the ACPI
5921 * DSDT initialize the HFSP register, and it ends up
5922 * being initially set to 0x07 when it *could* be
5923 * either 0x07 or 0x80.
5924 *
5925 * Enable for TP-1Y (T43), TP-78 (R51e),
5926 * TP-76 (R52), TP-70 (T43, R52), which are known
5927 * to be buggy. */
5928 if (fan_control_initial_status == 0x07) {
5929 switch (thinkpad_id.ec_model) {
5930 case 0x5931: /* TP-1Y */
5931 case 0x3837: /* TP-78 */
5932 case 0x3637: /* TP-76 */
5933 case 0x3037: /* TP-70 */
5934 printk(TPACPI_NOTICE
5935 "fan_init: initial fan status is unknown, "
5936 "assuming it is in auto mode\n");
5937 tp_features.fan_ctrl_status_undef = 1;
5938 ;;
5939 }
5940 }
5941}
5942
5943static void fan_quirk1_handle(u8 *fan_status)
5944{
5945 if (unlikely(tp_features.fan_ctrl_status_undef)) {
5946 if (*fan_status != fan_control_initial_status) {
5947 /* something changed the HFSP regisnter since
5948 * driver init time, so it is not undefined
5949 * anymore */
5950 tp_features.fan_ctrl_status_undef = 0;
5951 } else {
5952 /* Return most likely status. In fact, it
5953 * might be the only possible status */
5954 *fan_status = TP_EC_FAN_AUTO;
5955 }
5956 }
5957}
5958
5959/*
5337 * Call with fan_mutex held 5960 * Call with fan_mutex held
5338 */ 5961 */
5339static void fan_update_desired_level(u8 status) 5962static void fan_update_desired_level(u8 status)
@@ -5371,8 +5994,10 @@ static int fan_get_status(u8 *status)
5371 if (unlikely(!acpi_ec_read(fan_status_offset, &s))) 5994 if (unlikely(!acpi_ec_read(fan_status_offset, &s)))
5372 return -EIO; 5995 return -EIO;
5373 5996
5374 if (likely(status)) 5997 if (likely(status)) {
5375 *status = s; 5998 *status = s;
5999 fan_quirk1_handle(status);
6000 }
5376 6001
5377 break; 6002 break;
5378 6003
@@ -5388,7 +6013,7 @@ static int fan_get_status_safe(u8 *status)
5388 int rc; 6013 int rc;
5389 u8 s; 6014 u8 s;
5390 6015
5391 if (mutex_lock_interruptible(&fan_mutex)) 6016 if (mutex_lock_killable(&fan_mutex))
5392 return -ERESTARTSYS; 6017 return -ERESTARTSYS;
5393 rc = fan_get_status(&s); 6018 rc = fan_get_status(&s);
5394 if (!rc) 6019 if (!rc)
@@ -5471,7 +6096,7 @@ static int fan_set_level_safe(int level)
5471 if (!fan_control_allowed) 6096 if (!fan_control_allowed)
5472 return -EPERM; 6097 return -EPERM;
5473 6098
5474 if (mutex_lock_interruptible(&fan_mutex)) 6099 if (mutex_lock_killable(&fan_mutex))
5475 return -ERESTARTSYS; 6100 return -ERESTARTSYS;
5476 6101
5477 if (level == TPACPI_FAN_LAST_LEVEL) 6102 if (level == TPACPI_FAN_LAST_LEVEL)
@@ -5493,7 +6118,7 @@ static int fan_set_enable(void)
5493 if (!fan_control_allowed) 6118 if (!fan_control_allowed)
5494 return -EPERM; 6119 return -EPERM;
5495 6120
5496 if (mutex_lock_interruptible(&fan_mutex)) 6121 if (mutex_lock_killable(&fan_mutex))
5497 return -ERESTARTSYS; 6122 return -ERESTARTSYS;
5498 6123
5499 switch (fan_control_access_mode) { 6124 switch (fan_control_access_mode) {
@@ -5548,7 +6173,7 @@ static int fan_set_disable(void)
5548 if (!fan_control_allowed) 6173 if (!fan_control_allowed)
5549 return -EPERM; 6174 return -EPERM;
5550 6175
5551 if (mutex_lock_interruptible(&fan_mutex)) 6176 if (mutex_lock_killable(&fan_mutex))
5552 return -ERESTARTSYS; 6177 return -ERESTARTSYS;
5553 6178
5554 rc = 0; 6179 rc = 0;
@@ -5586,7 +6211,7 @@ static int fan_set_speed(int speed)
5586 if (!fan_control_allowed) 6211 if (!fan_control_allowed)
5587 return -EPERM; 6212 return -EPERM;
5588 6213
5589 if (mutex_lock_interruptible(&fan_mutex)) 6214 if (mutex_lock_killable(&fan_mutex))
5590 return -ERESTARTSYS; 6215 return -ERESTARTSYS;
5591 6216
5592 rc = 0; 6217 rc = 0;
@@ -5682,16 +6307,6 @@ static ssize_t fan_pwm1_enable_show(struct device *dev,
5682 if (res) 6307 if (res)
5683 return res; 6308 return res;
5684 6309
5685 if (unlikely(tp_features.fan_ctrl_status_undef)) {
5686 if (status != fan_control_initial_status) {
5687 tp_features.fan_ctrl_status_undef = 0;
5688 } else {
5689 /* Return most likely status. In fact, it
5690 * might be the only possible status */
5691 status = TP_EC_FAN_AUTO;
5692 }
5693 }
5694
5695 if (status & TP_EC_FAN_FULLSPEED) { 6310 if (status & TP_EC_FAN_FULLSPEED) {
5696 mode = 0; 6311 mode = 0;
5697 } else if (status & TP_EC_FAN_AUTO) { 6312 } else if (status & TP_EC_FAN_AUTO) {
@@ -5756,14 +6371,6 @@ static ssize_t fan_pwm1_show(struct device *dev,
5756 if (res) 6371 if (res)
5757 return res; 6372 return res;
5758 6373
5759 if (unlikely(tp_features.fan_ctrl_status_undef)) {
5760 if (status != fan_control_initial_status) {
5761 tp_features.fan_ctrl_status_undef = 0;
5762 } else {
5763 status = TP_EC_FAN_AUTO;
5764 }
5765 }
5766
5767 if ((status & 6374 if ((status &
5768 (TP_EC_FAN_AUTO | TP_EC_FAN_FULLSPEED)) != 0) 6375 (TP_EC_FAN_AUTO | TP_EC_FAN_FULLSPEED)) != 0)
5769 status = fan_control_desired_level; 6376 status = fan_control_desired_level;
@@ -5788,7 +6395,7 @@ static ssize_t fan_pwm1_store(struct device *dev,
5788 /* scale down from 0-255 to 0-7 */ 6395 /* scale down from 0-255 to 0-7 */
5789 newlevel = (s >> 5) & 0x07; 6396 newlevel = (s >> 5) & 0x07;
5790 6397
5791 if (mutex_lock_interruptible(&fan_mutex)) 6398 if (mutex_lock_killable(&fan_mutex))
5792 return -ERESTARTSYS; 6399 return -ERESTARTSYS;
5793 6400
5794 rc = fan_get_status(&status); 6401 rc = fan_get_status(&status);
@@ -5895,29 +6502,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
5895 if (likely(acpi_ec_read(fan_status_offset, 6502 if (likely(acpi_ec_read(fan_status_offset,
5896 &fan_control_initial_status))) { 6503 &fan_control_initial_status))) {
5897 fan_status_access_mode = TPACPI_FAN_RD_TPEC; 6504 fan_status_access_mode = TPACPI_FAN_RD_TPEC;
5898 6505 fan_quirk1_detect();
5899 /* In some ThinkPads, neither the EC nor the ACPI
5900 * DSDT initialize the fan status, and it ends up
5901 * being set to 0x07 when it *could* be either
5902 * 0x07 or 0x80.
5903 *
5904 * Enable for TP-1Y (T43), TP-78 (R51e),
5905 * TP-76 (R52), TP-70 (T43, R52), which are known
5906 * to be buggy. */
5907 if (fan_control_initial_status == 0x07) {
5908 switch (thinkpad_id.ec_model) {
5909 case 0x5931: /* TP-1Y */
5910 case 0x3837: /* TP-78 */
5911 case 0x3637: /* TP-76 */
5912 case 0x3037: /* TP-70 */
5913 printk(TPACPI_NOTICE
5914 "fan_init: initial fan status "
5915 "is unknown, assuming it is "
5916 "in auto mode\n");
5917 tp_features.fan_ctrl_status_undef = 1;
5918 ;;
5919 }
5920 }
5921 } else { 6506 } else {
5922 printk(TPACPI_ERR 6507 printk(TPACPI_ERR
5923 "ThinkPad ACPI EC access misbehaving, " 6508 "ThinkPad ACPI EC access misbehaving, "
@@ -6106,15 +6691,6 @@ static int fan_read(char *p)
6106 if (rc < 0) 6691 if (rc < 0)
6107 return rc; 6692 return rc;
6108 6693
6109 if (unlikely(tp_features.fan_ctrl_status_undef)) {
6110 if (status != fan_control_initial_status)
6111 tp_features.fan_ctrl_status_undef = 0;
6112 else
6113 /* Return most likely status. In fact, it
6114 * might be the only possible status */
6115 status = TP_EC_FAN_AUTO;
6116 }
6117
6118 len += sprintf(p + len, "status:\t\t%s\n", 6694 len += sprintf(p + len, "status:\t\t%s\n",
6119 (status != 0) ? "enabled" : "disabled"); 6695 (status != 0) ? "enabled" : "disabled");
6120 6696
@@ -6563,6 +7139,10 @@ static struct ibm_init_struct ibms_init[] __initdata = {
6563 .init = wan_init, 7139 .init = wan_init,
6564 .data = &wan_driver_data, 7140 .data = &wan_driver_data,
6565 }, 7141 },
7142 {
7143 .init = uwb_init,
7144 .data = &uwb_driver_data,
7145 },
6566#ifdef CONFIG_THINKPAD_ACPI_VIDEO 7146#ifdef CONFIG_THINKPAD_ACPI_VIDEO
6567 { 7147 {
6568 .init = video_init, 7148 .init = video_init,
@@ -6701,6 +7281,32 @@ TPACPI_PARAM(brightness);
6701TPACPI_PARAM(volume); 7281TPACPI_PARAM(volume);
6702TPACPI_PARAM(fan); 7282TPACPI_PARAM(fan);
6703 7283
7284#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
7285module_param(dbg_wlswemul, uint, 0);
7286MODULE_PARM_DESC(dbg_wlswemul, "Enables WLSW emulation");
7287module_param_named(wlsw_state, tpacpi_wlsw_emulstate, bool, 0);
7288MODULE_PARM_DESC(wlsw_state,
7289 "Initial state of the emulated WLSW switch");
7290
7291module_param(dbg_bluetoothemul, uint, 0);
7292MODULE_PARM_DESC(dbg_bluetoothemul, "Enables bluetooth switch emulation");
7293module_param_named(bluetooth_state, tpacpi_bluetooth_emulstate, bool, 0);
7294MODULE_PARM_DESC(bluetooth_state,
7295 "Initial state of the emulated bluetooth switch");
7296
7297module_param(dbg_wwanemul, uint, 0);
7298MODULE_PARM_DESC(dbg_wwanemul, "Enables WWAN switch emulation");
7299module_param_named(wwan_state, tpacpi_wwan_emulstate, bool, 0);
7300MODULE_PARM_DESC(wwan_state,
7301 "Initial state of the emulated WWAN switch");
7302
7303module_param(dbg_uwbemul, uint, 0);
7304MODULE_PARM_DESC(dbg_uwbemul, "Enables UWB switch emulation");
7305module_param_named(uwb_state, tpacpi_uwb_emulstate, bool, 0);
7306MODULE_PARM_DESC(uwb_state,
7307 "Initial state of the emulated UWB switch");
7308#endif
7309
6704static void thinkpad_acpi_module_exit(void) 7310static void thinkpad_acpi_module_exit(void)
6705{ 7311{
6706 struct ibm_struct *ibm, *itmp; 7312 struct ibm_struct *ibm, *itmp;
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 668472405a57..33da1127992a 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -82,4 +82,10 @@ config BATTERY_DA9030
82 Say Y here to enable support for batteries charger integrated into 82 Say Y here to enable support for batteries charger integrated into
83 DA9030 PMIC. 83 DA9030 PMIC.
84 84
85config CHARGER_PCF50633
86 tristate "NXP PCF50633 MBC"
87 depends on MFD_PCF50633
88 help
89 Say Y to include support for NXP PCF50633 Main Battery Charger.
90
85endif # POWER_SUPPLY 91endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index eebb15505a40..2fcf41d13e5c 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o
25obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o 25obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
26obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o 26obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
27obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o 27obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
28obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o \ No newline at end of file
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
new file mode 100644
index 000000000000..e988ec130fcd
--- /dev/null
+++ b/drivers/power/pcf50633-charger.c
@@ -0,0 +1,358 @@
1/* NXP PCF50633 Main Battery Charger Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/types.h>
21#include <linux/device.h>
22#include <linux/sysfs.h>
23#include <linux/platform_device.h>
24#include <linux/power_supply.h>
25
26#include <linux/mfd/pcf50633/core.h>
27#include <linux/mfd/pcf50633/mbc.h>
28
29struct pcf50633_mbc {
30 struct pcf50633 *pcf;
31
32 int adapter_active;
33 int adapter_online;
34 int usb_active;
35 int usb_online;
36
37 struct power_supply usb;
38 struct power_supply adapter;
39};
40
41int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
42{
43 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
44 int ret = 0;
45 u8 bits;
46
47 if (ma >= 1000)
48 bits = PCF50633_MBCC7_USB_1000mA;
49 else if (ma >= 500)
50 bits = PCF50633_MBCC7_USB_500mA;
51 else if (ma >= 100)
52 bits = PCF50633_MBCC7_USB_100mA;
53 else
54 bits = PCF50633_MBCC7_USB_SUSPEND;
55
56 ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC7,
57 PCF50633_MBCC7_USB_MASK, bits);
58 if (ret)
59 dev_err(pcf->dev, "error setting usb curlim to %d mA\n", ma);
60 else
61 dev_info(pcf->dev, "usb curlim to %d mA\n", ma);
62
63 power_supply_changed(&mbc->usb);
64
65 return ret;
66}
67EXPORT_SYMBOL_GPL(pcf50633_mbc_usb_curlim_set);
68
69int pcf50633_mbc_get_status(struct pcf50633 *pcf)
70{
71 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
72 int status = 0;
73
74 if (mbc->usb_online)
75 status |= PCF50633_MBC_USB_ONLINE;
76 if (mbc->usb_active)
77 status |= PCF50633_MBC_USB_ACTIVE;
78 if (mbc->adapter_online)
79 status |= PCF50633_MBC_ADAPTER_ONLINE;
80 if (mbc->adapter_active)
81 status |= PCF50633_MBC_ADAPTER_ACTIVE;
82
83 return status;
84}
85EXPORT_SYMBOL_GPL(pcf50633_mbc_get_status);
86
87void pcf50633_mbc_set_status(struct pcf50633 *pcf, int what, int status)
88{
89 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
90
91 if (what & PCF50633_MBC_USB_ONLINE)
92 mbc->usb_online = !!status;
93 if (what & PCF50633_MBC_USB_ACTIVE)
94 mbc->usb_active = !!status;
95 if (what & PCF50633_MBC_ADAPTER_ONLINE)
96 mbc->adapter_online = !!status;
97 if (what & PCF50633_MBC_ADAPTER_ACTIVE)
98 mbc->adapter_active = !!status;
99}
100EXPORT_SYMBOL_GPL(pcf50633_mbc_set_status);
101
102static ssize_t
103show_chgmode(struct device *dev, struct device_attribute *attr, char *buf)
104{
105 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
106
107 u8 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2);
108 u8 chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
109
110 return sprintf(buf, "%d\n", chgmod);
111}
112static DEVICE_ATTR(chgmode, S_IRUGO, show_chgmode, NULL);
113
114static ssize_t
115show_usblim(struct device *dev, struct device_attribute *attr, char *buf)
116{
117 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
118 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
119 PCF50633_MBCC7_USB_MASK;
120 unsigned int ma;
121
122 if (usblim == PCF50633_MBCC7_USB_1000mA)
123 ma = 1000;
124 else if (usblim == PCF50633_MBCC7_USB_500mA)
125 ma = 500;
126 else if (usblim == PCF50633_MBCC7_USB_100mA)
127 ma = 100;
128 else
129 ma = 0;
130
131 return sprintf(buf, "%u\n", ma);
132}
133
134static ssize_t set_usblim(struct device *dev,
135 struct device_attribute *attr, const char *buf, size_t count)
136{
137 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
138 unsigned long ma;
139 int ret;
140
141 ret = strict_strtoul(buf, 10, &ma);
142 if (ret)
143 return -EINVAL;
144
145 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma);
146
147 return count;
148}
149
150static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, set_usblim);
151
152static struct attribute *pcf50633_mbc_sysfs_entries[] = {
153 &dev_attr_chgmode.attr,
154 &dev_attr_usb_curlim.attr,
155 NULL,
156};
157
158static struct attribute_group mbc_attr_group = {
159 .name = NULL, /* put in device directory */
160 .attrs = pcf50633_mbc_sysfs_entries,
161};
162
163static void
164pcf50633_mbc_irq_handler(int irq, void *data)
165{
166 struct pcf50633_mbc *mbc = data;
167
168 /* USB */
169 if (irq == PCF50633_IRQ_USBINS) {
170 mbc->usb_online = 1;
171 } else if (irq == PCF50633_IRQ_USBREM) {
172 mbc->usb_online = 0;
173 mbc->usb_active = 0;
174 pcf50633_mbc_usb_curlim_set(mbc->pcf, 0);
175 }
176
177 /* Adapter */
178 if (irq == PCF50633_IRQ_ADPINS) {
179 mbc->adapter_online = 1;
180 mbc->adapter_active = 1;
181 } else if (irq == PCF50633_IRQ_ADPREM) {
182 mbc->adapter_online = 0;
183 mbc->adapter_active = 0;
184 }
185
186 if (irq == PCF50633_IRQ_BATFULL) {
187 mbc->usb_active = 0;
188 mbc->adapter_active = 0;
189 }
190
191 power_supply_changed(&mbc->usb);
192 power_supply_changed(&mbc->adapter);
193
194 if (mbc->pcf->pdata->mbc_event_callback)
195 mbc->pcf->pdata->mbc_event_callback(mbc->pcf, irq);
196}
197
198static int adapter_get_property(struct power_supply *psy,
199 enum power_supply_property psp,
200 union power_supply_propval *val)
201{
202 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
203 int ret = 0;
204
205 switch (psp) {
206 case POWER_SUPPLY_PROP_ONLINE:
207 val->intval = mbc->adapter_online;
208 break;
209 default:
210 ret = -EINVAL;
211 break;
212 }
213 return ret;
214}
215
216static int usb_get_property(struct power_supply *psy,
217 enum power_supply_property psp,
218 union power_supply_propval *val)
219{
220 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
221 int ret = 0;
222
223 switch (psp) {
224 case POWER_SUPPLY_PROP_ONLINE:
225 val->intval = mbc->usb_online;
226 break;
227 default:
228 ret = -EINVAL;
229 break;
230 }
231 return ret;
232}
233
234static enum power_supply_property power_props[] = {
235 POWER_SUPPLY_PROP_ONLINE,
236};
237
238static const u8 mbc_irq_handlers[] = {
239 PCF50633_IRQ_ADPINS,
240 PCF50633_IRQ_ADPREM,
241 PCF50633_IRQ_USBINS,
242 PCF50633_IRQ_USBREM,
243 PCF50633_IRQ_BATFULL,
244 PCF50633_IRQ_CHGHALT,
245 PCF50633_IRQ_THLIMON,
246 PCF50633_IRQ_THLIMOFF,
247 PCF50633_IRQ_USBLIMON,
248 PCF50633_IRQ_USBLIMOFF,
249 PCF50633_IRQ_LOWSYS,
250 PCF50633_IRQ_LOWBAT,
251};
252
253static int __devinit pcf50633_mbc_probe(struct platform_device *pdev)
254{
255 struct pcf50633_mbc *mbc;
256 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
257 int ret;
258 int i;
259 u8 mbcs1;
260
261 mbc = kzalloc(sizeof(*mbc), GFP_KERNEL);
262 if (!mbc)
263 return -ENOMEM;
264
265 platform_set_drvdata(pdev, mbc);
266 mbc->pcf = pdata->pcf;
267
268 /* Set up IRQ handlers */
269 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
270 pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i],
271 pcf50633_mbc_irq_handler, mbc);
272
273 /* Create power supplies */
274 mbc->adapter.name = "adapter";
275 mbc->adapter.type = POWER_SUPPLY_TYPE_MAINS;
276 mbc->adapter.properties = power_props;
277 mbc->adapter.num_properties = ARRAY_SIZE(power_props);
278 mbc->adapter.get_property = &adapter_get_property;
279 mbc->adapter.supplied_to = mbc->pcf->pdata->batteries;
280 mbc->adapter.num_supplicants = mbc->pcf->pdata->num_batteries;
281
282 mbc->usb.name = "usb";
283 mbc->usb.type = POWER_SUPPLY_TYPE_USB;
284 mbc->usb.properties = power_props;
285 mbc->usb.num_properties = ARRAY_SIZE(power_props);
286 mbc->usb.get_property = usb_get_property;
287 mbc->usb.supplied_to = mbc->pcf->pdata->batteries;
288 mbc->usb.num_supplicants = mbc->pcf->pdata->num_batteries;
289
290 ret = power_supply_register(&pdev->dev, &mbc->adapter);
291 if (ret) {
292 dev_err(mbc->pcf->dev, "failed to register adapter\n");
293 kfree(mbc);
294 return ret;
295 }
296
297 ret = power_supply_register(&pdev->dev, &mbc->usb);
298 if (ret) {
299 dev_err(mbc->pcf->dev, "failed to register usb\n");
300 power_supply_unregister(&mbc->adapter);
301 kfree(mbc);
302 return ret;
303 }
304
305 ret = sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group);
306 if (ret)
307 dev_err(mbc->pcf->dev, "failed to create sysfs entries\n");
308
309 mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1);
310 if (mbcs1 & PCF50633_MBCS1_USBPRES)
311 pcf50633_mbc_irq_handler(PCF50633_IRQ_USBINS, mbc);
312 if (mbcs1 & PCF50633_MBCS1_ADAPTPRES)
313 pcf50633_mbc_irq_handler(PCF50633_IRQ_ADPINS, mbc);
314
315 return 0;
316}
317
318static int __devexit pcf50633_mbc_remove(struct platform_device *pdev)
319{
320 struct pcf50633_mbc *mbc = platform_get_drvdata(pdev);
321 int i;
322
323 /* Remove IRQ handlers */
324 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
325 pcf50633_free_irq(mbc->pcf, mbc_irq_handlers[i]);
326
327 power_supply_unregister(&mbc->usb);
328 power_supply_unregister(&mbc->adapter);
329
330 kfree(mbc);
331
332 return 0;
333}
334
335static struct platform_driver pcf50633_mbc_driver = {
336 .driver = {
337 .name = "pcf50633-mbc",
338 },
339 .probe = pcf50633_mbc_probe,
340 .remove = __devexit_p(pcf50633_mbc_remove),
341};
342
343static int __init pcf50633_mbc_init(void)
344{
345 return platform_driver_register(&pcf50633_mbc_driver);
346}
347module_init(pcf50633_mbc_init);
348
349static void __exit pcf50633_mbc_exit(void)
350{
351 platform_driver_unregister(&pcf50633_mbc_driver);
352}
353module_exit(pcf50633_mbc_exit);
354
355MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
356MODULE_DESCRIPTION("PCF50633 mbc driver");
357MODULE_LICENSE("GPL");
358MODULE_ALIAS("platform:pcf50633-mbc");
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
index 204158cf7a55..fe96793e3f08 100644
--- a/drivers/ps3/ps3-lpm.c
+++ b/drivers/ps3/ps3-lpm.c
@@ -732,7 +732,7 @@ static u64 pm_signal_group_to_ps3_lv1_signal_group(u64 group)
732 case 8: 732 case 8:
733 return pm_translate_signal_group_number_on_island8(subgroup); 733 return pm_translate_signal_group_number_on_island8(subgroup);
734 default: 734 default:
735 dev_dbg(sbd_core(), "%s:%u: island not found: %lu\n", __func__, 735 dev_dbg(sbd_core(), "%s:%u: island not found: %llu\n", __func__,
736 __LINE__, group); 736 __LINE__, group);
737 BUG(); 737 BUG();
738 break; 738 break;
@@ -765,7 +765,7 @@ static int __ps3_set_signal(u64 lv1_signal_group, u64 bus_select,
765 signal_select, attr1, attr2, attr3); 765 signal_select, attr1, attr2, attr3);
766 if (ret) 766 if (ret)
767 dev_err(sbd_core(), 767 dev_err(sbd_core(),
768 "%s:%u: error:%d 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n", 768 "%s:%u: error:%d 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx\n",
769 __func__, __LINE__, ret, lv1_signal_group, bus_select, 769 __func__, __LINE__, ret, lv1_signal_group, bus_select,
770 signal_select, attr1, attr2, attr3); 770 signal_select, attr1, attr2, attr3);
771 771
@@ -908,7 +908,7 @@ void ps3_disable_pm(u32 cpu)
908 908
909 lpm_priv->tb_count = tmp; 909 lpm_priv->tb_count = tmp;
910 910
911 dev_dbg(sbd_core(), "%s:%u: tb_count %lu (%lxh)\n", __func__, __LINE__, 911 dev_dbg(sbd_core(), "%s:%u: tb_count %llu (%llxh)\n", __func__, __LINE__,
912 lpm_priv->tb_count, lpm_priv->tb_count); 912 lpm_priv->tb_count, lpm_priv->tb_count);
913} 913}
914EXPORT_SYMBOL_GPL(ps3_disable_pm); 914EXPORT_SYMBOL_GPL(ps3_disable_pm);
@@ -938,7 +938,7 @@ int ps3_lpm_copy_tb(unsigned long offset, void *buf, unsigned long count,
938 if (offset >= lpm_priv->tb_count) 938 if (offset >= lpm_priv->tb_count)
939 return 0; 939 return 0;
940 940
941 count = min(count, lpm_priv->tb_count - offset); 941 count = min_t(u64, count, lpm_priv->tb_count - offset);
942 942
943 while (*bytes_copied < count) { 943 while (*bytes_copied < count) {
944 const unsigned long request = count - *bytes_copied; 944 const unsigned long request = count - *bytes_copied;
@@ -993,7 +993,7 @@ int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
993 if (offset >= lpm_priv->tb_count) 993 if (offset >= lpm_priv->tb_count)
994 return 0; 994 return 0;
995 995
996 count = min(count, lpm_priv->tb_count - offset); 996 count = min_t(u64, count, lpm_priv->tb_count - offset);
997 997
998 while (*bytes_copied < count) { 998 while (*bytes_copied < count) {
999 const unsigned long request = count - *bytes_copied; 999 const unsigned long request = count - *bytes_copied;
@@ -1013,7 +1013,7 @@ int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
1013 result = copy_to_user(buf, lpm_priv->tb_cache, tmp); 1013 result = copy_to_user(buf, lpm_priv->tb_cache, tmp);
1014 1014
1015 if (result) { 1015 if (result) {
1016 dev_dbg(sbd_core(), "%s:%u: 0x%lx bytes at 0x%p\n", 1016 dev_dbg(sbd_core(), "%s:%u: 0x%llx bytes at 0x%p\n",
1017 __func__, __LINE__, tmp, buf); 1017 __func__, __LINE__, tmp, buf);
1018 dev_err(sbd_core(), "%s:%u: copy_to_user failed: %d\n", 1018 dev_err(sbd_core(), "%s:%u: copy_to_user failed: %d\n",
1019 __func__, __LINE__, result); 1019 __func__, __LINE__, result);
@@ -1148,8 +1148,8 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
1148 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT; 1148 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT;
1149 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT; 1149 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT;
1150 1150
1151 dev_dbg(sbd_core(), "%s:%u: lpm_id 0x%lx, outlet_id 0x%lx, " 1151 dev_dbg(sbd_core(), "%s:%u: lpm_id 0x%llx, outlet_id 0x%llx, "
1152 "tb_size 0x%lx\n", __func__, __LINE__, lpm_priv->lpm_id, 1152 "tb_size 0x%llx\n", __func__, __LINE__, lpm_priv->lpm_id,
1153 lpm_priv->outlet_id, tb_size); 1153 lpm_priv->outlet_id, tb_size);
1154 1154
1155 return 0; 1155 return 0;
diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index 90c097a7a47a..e4ad5ba5d0a3 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -114,7 +114,7 @@ struct ports_bmp {
114static void __maybe_unused _dump_ports_bmp( 114static void __maybe_unused _dump_ports_bmp(
115 const struct ports_bmp *bmp, const char *func, int line) 115 const struct ports_bmp *bmp, const char *func, int line)
116{ 116{
117 pr_debug("%s:%d: ports_bmp: %016lxh\n", func, line, bmp->status); 117 pr_debug("%s:%d: ports_bmp: %016llxh\n", func, line, bmp->status);
118} 118}
119 119
120#define dump_port_params(_b) _dump_port_params(_b, __func__, __LINE__) 120#define dump_port_params(_b) _dump_port_params(_b, __func__, __LINE__)
@@ -159,11 +159,13 @@ int ps3_vuart_get_triggers(struct ps3_system_bus_device *dev,
159 struct vuart_triggers *trig) 159 struct vuart_triggers *trig)
160{ 160{
161 int result; 161 int result;
162 unsigned long size; 162 u64 size;
163 unsigned long val; 163 u64 val;
164 u64 tx;
164 165
165 result = lv1_get_virtual_uart_param(dev->port_number, 166 result = lv1_get_virtual_uart_param(dev->port_number,
166 PARAM_TX_TRIGGER, &trig->tx); 167 PARAM_TX_TRIGGER, &tx);
168 trig->tx = tx;
167 169
168 if (result) { 170 if (result) {
169 dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n", 171 dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n",
@@ -201,7 +203,7 @@ int ps3_vuart_set_triggers(struct ps3_system_bus_device *dev, unsigned int tx,
201 unsigned int rx) 203 unsigned int rx)
202{ 204{
203 int result; 205 int result;
204 unsigned long size; 206 u64 size;
205 207
206 result = lv1_set_virtual_uart_param(dev->port_number, 208 result = lv1_set_virtual_uart_param(dev->port_number,
207 PARAM_TX_TRIGGER, tx); 209 PARAM_TX_TRIGGER, tx);
@@ -248,7 +250,7 @@ static int ps3_vuart_get_rx_bytes_waiting(struct ps3_system_bus_device *dev,
248 dev_dbg(&dev->core, "%s:%d: rx_bytes failed: %s\n", 250 dev_dbg(&dev->core, "%s:%d: rx_bytes failed: %s\n",
249 __func__, __LINE__, ps3_result(result)); 251 __func__, __LINE__, ps3_result(result));
250 252
251 dev_dbg(&dev->core, "%s:%d: %lxh\n", __func__, __LINE__, 253 dev_dbg(&dev->core, "%s:%d: %llxh\n", __func__, __LINE__,
252 *bytes_waiting); 254 *bytes_waiting);
253 return result; 255 return result;
254} 256}
@@ -295,7 +297,7 @@ static int ps3_vuart_get_interrupt_status(struct ps3_system_bus_device *dev,
295 297
296 *status = tmp & priv->interrupt_mask; 298 *status = tmp & priv->interrupt_mask;
297 299
298 dev_dbg(&dev->core, "%s:%d: m %lxh, s %lxh, m&s %lxh\n", 300 dev_dbg(&dev->core, "%s:%d: m %llxh, s %llxh, m&s %lxh\n",
299 __func__, __LINE__, priv->interrupt_mask, tmp, *status); 301 __func__, __LINE__, priv->interrupt_mask, tmp, *status);
300 302
301 return result; 303 return result;
@@ -363,7 +365,7 @@ int ps3_vuart_disable_interrupt_disconnect(struct ps3_system_bus_device *dev)
363 */ 365 */
364 366
365static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev, 367static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev,
366 const void *buf, unsigned int bytes, unsigned long *bytes_written) 368 const void *buf, unsigned int bytes, u64 *bytes_written)
367{ 369{
368 int result; 370 int result;
369 struct ps3_vuart_port_priv *priv = to_port_priv(dev); 371 struct ps3_vuart_port_priv *priv = to_port_priv(dev);
@@ -379,7 +381,7 @@ static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev,
379 381
380 priv->stats.bytes_written += *bytes_written; 382 priv->stats.bytes_written += *bytes_written;
381 383
382 dev_dbg(&dev->core, "%s:%d: wrote %lxh/%xh=>%lxh\n", __func__, __LINE__, 384 dev_dbg(&dev->core, "%s:%d: wrote %llxh/%xh=>%lxh\n", __func__, __LINE__,
383 *bytes_written, bytes, priv->stats.bytes_written); 385 *bytes_written, bytes, priv->stats.bytes_written);
384 386
385 return result; 387 return result;
@@ -393,7 +395,7 @@ static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev,
393 */ 395 */
394 396
395static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf, 397static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf,
396 unsigned int bytes, unsigned long *bytes_read) 398 unsigned int bytes, u64 *bytes_read)
397{ 399{
398 int result; 400 int result;
399 struct ps3_vuart_port_priv *priv = to_port_priv(dev); 401 struct ps3_vuart_port_priv *priv = to_port_priv(dev);
@@ -411,7 +413,7 @@ static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf,
411 413
412 priv->stats.bytes_read += *bytes_read; 414 priv->stats.bytes_read += *bytes_read;
413 415
414 dev_dbg(&dev->core, "%s:%d: read %lxh/%xh=>%lxh\n", __func__, __LINE__, 416 dev_dbg(&dev->core, "%s:%d: read %llxh/%xh=>%lxh\n", __func__, __LINE__,
415 *bytes_read, bytes, priv->stats.bytes_read); 417 *bytes_read, bytes, priv->stats.bytes_read);
416 418
417 return result; 419 return result;
@@ -500,7 +502,7 @@ int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf,
500 spin_lock_irqsave(&priv->tx_list.lock, flags); 502 spin_lock_irqsave(&priv->tx_list.lock, flags);
501 503
502 if (list_empty(&priv->tx_list.head)) { 504 if (list_empty(&priv->tx_list.head)) {
503 unsigned long bytes_written; 505 u64 bytes_written;
504 506
505 result = ps3_vuart_raw_write(dev, buf, bytes, &bytes_written); 507 result = ps3_vuart_raw_write(dev, buf, bytes, &bytes_written);
506 508
@@ -592,7 +594,7 @@ static int ps3_vuart_queue_rx_bytes(struct ps3_system_bus_device *dev,
592 list_add_tail(&lb->link, &priv->rx_list.head); 594 list_add_tail(&lb->link, &priv->rx_list.head);
593 priv->rx_list.bytes_held += bytes; 595 priv->rx_list.bytes_held += bytes;
594 596
595 dev_dbg(&dev->core, "%s:%d: buf_%lu: queued %lxh bytes\n", 597 dev_dbg(&dev->core, "%s:%d: buf_%lu: queued %llxh bytes\n",
596 __func__, __LINE__, lb->dbg_number, bytes); 598 __func__, __LINE__, lb->dbg_number, bytes);
597 599
598 *bytes_queued = bytes; 600 *bytes_queued = bytes;
@@ -745,7 +747,7 @@ static int ps3_vuart_handle_interrupt_tx(struct ps3_system_bus_device *dev)
745 747
746 list_for_each_entry_safe(lb, n, &priv->tx_list.head, link) { 748 list_for_each_entry_safe(lb, n, &priv->tx_list.head, link) {
747 749
748 unsigned long bytes_written; 750 u64 bytes_written;
749 751
750 result = ps3_vuart_raw_write(dev, lb->head, lb->tail - lb->head, 752 result = ps3_vuart_raw_write(dev, lb->head, lb->tail - lb->head,
751 &bytes_written); 753 &bytes_written);
@@ -762,7 +764,7 @@ static int ps3_vuart_handle_interrupt_tx(struct ps3_system_bus_device *dev)
762 if (bytes_written < lb->tail - lb->head) { 764 if (bytes_written < lb->tail - lb->head) {
763 lb->head += bytes_written; 765 lb->head += bytes_written;
764 dev_dbg(&dev->core, 766 dev_dbg(&dev->core,
765 "%s:%d cleared buf_%lu, %lxh bytes\n", 767 "%s:%d cleared buf_%lu, %llxh bytes\n",
766 __func__, __LINE__, lb->dbg_number, 768 __func__, __LINE__, lb->dbg_number,
767 bytes_written); 769 bytes_written);
768 goto port_full; 770 goto port_full;
diff --git a/drivers/ps3/ps3stor_lib.c b/drivers/ps3/ps3stor_lib.c
index 55955f16ad91..18066d555397 100644
--- a/drivers/ps3/ps3stor_lib.c
+++ b/drivers/ps3/ps3stor_lib.c
@@ -70,7 +70,7 @@ static int ps3stor_probe_access(struct ps3_storage_device *dev)
70 __func__, __LINE__, n); 70 __func__, __LINE__, n);
71 dev->region_idx = __ffs(dev->accessible_regions); 71 dev->region_idx = __ffs(dev->accessible_regions);
72 dev_info(&dev->sbd.core, 72 dev_info(&dev->sbd.core,
73 "First accessible region has index %u start %lu size %lu\n", 73 "First accessible region has index %u start %llu size %llu\n",
74 dev->region_idx, dev->regions[dev->region_idx].start, 74 dev->region_idx, dev->regions[dev->region_idx].start,
75 dev->regions[dev->region_idx].size); 75 dev->regions[dev->region_idx].size);
76 76
@@ -220,7 +220,7 @@ u64 ps3stor_read_write_sectors(struct ps3_storage_device *dev, u64 lpar,
220 const char *op = write ? "write" : "read"; 220 const char *op = write ? "write" : "read";
221 int res; 221 int res;
222 222
223 dev_dbg(&dev->sbd.core, "%s:%u: %s %lu sectors starting at %lu\n", 223 dev_dbg(&dev->sbd.core, "%s:%u: %s %llu sectors starting at %llu\n",
224 __func__, __LINE__, op, sectors, start_sector); 224 __func__, __LINE__, op, sectors, start_sector);
225 225
226 init_completion(&dev->done); 226 init_completion(&dev->done);
@@ -238,7 +238,7 @@ u64 ps3stor_read_write_sectors(struct ps3_storage_device *dev, u64 lpar,
238 238
239 wait_for_completion(&dev->done); 239 wait_for_completion(&dev->done);
240 if (dev->lv1_status) { 240 if (dev->lv1_status) {
241 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, 241 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%llx\n", __func__,
242 __LINE__, op, dev->lv1_status); 242 __LINE__, op, dev->lv1_status);
243 return dev->lv1_status; 243 return dev->lv1_status;
244 } 244 }
@@ -268,7 +268,7 @@ u64 ps3stor_send_command(struct ps3_storage_device *dev, u64 cmd, u64 arg1,
268{ 268{
269 int res; 269 int res;
270 270
271 dev_dbg(&dev->sbd.core, "%s:%u: send device command 0x%lx\n", __func__, 271 dev_dbg(&dev->sbd.core, "%s:%u: send device command 0x%llx\n", __func__,
272 __LINE__, cmd); 272 __LINE__, cmd);
273 273
274 init_completion(&dev->done); 274 init_completion(&dev->done);
@@ -277,19 +277,19 @@ u64 ps3stor_send_command(struct ps3_storage_device *dev, u64 cmd, u64 arg1,
277 arg2, arg3, arg4, &dev->tag); 277 arg2, arg3, arg4, &dev->tag);
278 if (res) { 278 if (res) {
279 dev_err(&dev->sbd.core, 279 dev_err(&dev->sbd.core,
280 "%s:%u: send_device_command 0x%lx failed %d\n", 280 "%s:%u: send_device_command 0x%llx failed %d\n",
281 __func__, __LINE__, cmd, res); 281 __func__, __LINE__, cmd, res);
282 return -1; 282 return -1;
283 } 283 }
284 284
285 wait_for_completion(&dev->done); 285 wait_for_completion(&dev->done);
286 if (dev->lv1_status) { 286 if (dev->lv1_status) {
287 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%lx failed 0x%lx\n", 287 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%llx failed 0x%llx\n",
288 __func__, __LINE__, cmd, dev->lv1_status); 288 __func__, __LINE__, cmd, dev->lv1_status);
289 return dev->lv1_status; 289 return dev->lv1_status;
290 } 290 }
291 291
292 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%lx completed\n", __func__, 292 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%llx completed\n", __func__,
293 __LINE__, cmd); 293 __LINE__, cmd);
294 294
295 return 0; 295 return 0;
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 39360e2a4540..e7e0cf102d6d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -73,4 +73,11 @@ config REGULATOR_DA903X
73 Say y here to support the BUCKs and LDOs regulators found on 73 Say y here to support the BUCKs and LDOs regulators found on
74 Dialog Semiconductor DA9030/DA9034 PMIC. 74 Dialog Semiconductor DA9030/DA9034 PMIC.
75 75
76config REGULATOR_PCF50633
77 tristate "PCF50633 regulator driver"
78 depends on MFD_PCF50633
79 help
80 Say Y here to support the voltage regulators and convertors
81 on PCF50633
82
76endif 83endif
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 254d40c02ee8..61b30c6ddecc 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -11,5 +11,6 @@ obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o 11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o 12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
14obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
14 15
15ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG 16ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
new file mode 100644
index 000000000000..4cc85ec6e120
--- /dev/null
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -0,0 +1,329 @@
1/* NXP PCF50633 PMIC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte and Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/err.h>
22#include <linux/platform_device.h>
23
24#include <linux/mfd/pcf50633/core.h>
25#include <linux/mfd/pcf50633/pmic.h>
26
27#define PCF50633_REGULATOR(_name, _id) \
28 { \
29 .name = _name, \
30 .id = _id, \
31 .ops = &pcf50633_regulator_ops, \
32 .type = REGULATOR_VOLTAGE, \
33 .owner = THIS_MODULE, \
34 }
35
36static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
37 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
38 [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,
39 [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,
40 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,
41 [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,
42 [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,
43 [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,
44 [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,
45 [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,
46 [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,
47 [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,
48};
49
50/* Bits from voltage value */
51static u8 auto_voltage_bits(unsigned int millivolts)
52{
53 if (millivolts < 1800)
54 return 0;
55 if (millivolts > 3800)
56 return 0xff;
57
58 millivolts -= 625;
59
60 return millivolts / 25;
61}
62
63static u8 down_voltage_bits(unsigned int millivolts)
64{
65 if (millivolts < 625)
66 return 0;
67 else if (millivolts > 3000)
68 return 0xff;
69
70 millivolts -= 625;
71
72 return millivolts / 25;
73}
74
75static u8 ldo_voltage_bits(unsigned int millivolts)
76{
77 if (millivolts < 900)
78 return 0;
79 else if (millivolts > 3600)
80 return 0x1f;
81
82 millivolts -= 900;
83 return millivolts / 100;
84}
85
86/* Obtain voltage value from bits */
87static unsigned int auto_voltage_value(u8 bits)
88{
89 if (bits < 0x2f)
90 return 0;
91
92 return 625 + (bits * 25);
93}
94
95
96static unsigned int down_voltage_value(u8 bits)
97{
98 return 625 + (bits * 25);
99}
100
101
102static unsigned int ldo_voltage_value(u8 bits)
103{
104 bits &= 0x1f;
105
106 return 900 + (bits * 100);
107}
108
109static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev,
110 int min_uV, int max_uV)
111{
112 struct pcf50633 *pcf;
113 int regulator_id, millivolts;
114 u8 volt_bits, regnr;
115
116 pcf = rdev_get_drvdata(rdev);
117
118 regulator_id = rdev_get_id(rdev);
119 if (regulator_id >= PCF50633_NUM_REGULATORS)
120 return -EINVAL;
121
122 millivolts = min_uV / 1000;
123
124 regnr = pcf50633_regulator_registers[regulator_id];
125
126 switch (regulator_id) {
127 case PCF50633_REGULATOR_AUTO:
128 volt_bits = auto_voltage_bits(millivolts);
129 break;
130 case PCF50633_REGULATOR_DOWN1:
131 volt_bits = down_voltage_bits(millivolts);
132 break;
133 case PCF50633_REGULATOR_DOWN2:
134 volt_bits = down_voltage_bits(millivolts);
135 break;
136 case PCF50633_REGULATOR_LDO1:
137 case PCF50633_REGULATOR_LDO2:
138 case PCF50633_REGULATOR_LDO3:
139 case PCF50633_REGULATOR_LDO4:
140 case PCF50633_REGULATOR_LDO5:
141 case PCF50633_REGULATOR_LDO6:
142 case PCF50633_REGULATOR_HCLDO:
143 volt_bits = ldo_voltage_bits(millivolts);
144 break;
145 default:
146 return -EINVAL;
147 }
148
149 return pcf50633_reg_write(pcf, regnr, volt_bits);
150}
151
152static int pcf50633_regulator_get_voltage(struct regulator_dev *rdev)
153{
154 struct pcf50633 *pcf;
155 int regulator_id, millivolts, volt_bits;
156 u8 regnr;
157
158 pcf = rdev_get_drvdata(rdev);;
159
160 regulator_id = rdev_get_id(rdev);
161 if (regulator_id >= PCF50633_NUM_REGULATORS)
162 return -EINVAL;
163
164 regnr = pcf50633_regulator_registers[regulator_id];
165
166 volt_bits = pcf50633_reg_read(pcf, regnr);
167 if (volt_bits < 0)
168 return -1;
169
170 switch (regulator_id) {
171 case PCF50633_REGULATOR_AUTO:
172 millivolts = auto_voltage_value(volt_bits);
173 break;
174 case PCF50633_REGULATOR_DOWN1:
175 millivolts = down_voltage_value(volt_bits);
176 break;
177 case PCF50633_REGULATOR_DOWN2:
178 millivolts = down_voltage_value(volt_bits);
179 break;
180 case PCF50633_REGULATOR_LDO1:
181 case PCF50633_REGULATOR_LDO2:
182 case PCF50633_REGULATOR_LDO3:
183 case PCF50633_REGULATOR_LDO4:
184 case PCF50633_REGULATOR_LDO5:
185 case PCF50633_REGULATOR_LDO6:
186 case PCF50633_REGULATOR_HCLDO:
187 millivolts = ldo_voltage_value(volt_bits);
188 break;
189 default:
190 return -EINVAL;
191 }
192
193 return millivolts * 1000;
194}
195
196static int pcf50633_regulator_enable(struct regulator_dev *rdev)
197{
198 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
199 int regulator_id;
200 u8 regnr;
201
202 regulator_id = rdev_get_id(rdev);
203 if (regulator_id >= PCF50633_NUM_REGULATORS)
204 return -EINVAL;
205
206 /* The *ENA register is always one after the *OUT register */
207 regnr = pcf50633_regulator_registers[regulator_id] + 1;
208
209 return pcf50633_reg_set_bit_mask(pcf, regnr, PCF50633_REGULATOR_ON,
210 PCF50633_REGULATOR_ON);
211}
212
213static int pcf50633_regulator_disable(struct regulator_dev *rdev)
214{
215 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
216 int regulator_id;
217 u8 regnr;
218
219 regulator_id = rdev_get_id(rdev);
220 if (regulator_id >= PCF50633_NUM_REGULATORS)
221 return -EINVAL;
222
223 /* the *ENA register is always one after the *OUT register */
224 regnr = pcf50633_regulator_registers[regulator_id] + 1;
225
226 return pcf50633_reg_set_bit_mask(pcf, regnr,
227 PCF50633_REGULATOR_ON, 0);
228}
229
230static int pcf50633_regulator_is_enabled(struct regulator_dev *rdev)
231{
232 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
233 int regulator_id = rdev_get_id(rdev);
234 u8 regnr;
235
236 regulator_id = rdev_get_id(rdev);
237 if (regulator_id >= PCF50633_NUM_REGULATORS)
238 return -EINVAL;
239
240 /* the *ENA register is always one after the *OUT register */
241 regnr = pcf50633_regulator_registers[regulator_id] + 1;
242
243 return pcf50633_reg_read(pcf, regnr) & PCF50633_REGULATOR_ON;
244}
245
246static struct regulator_ops pcf50633_regulator_ops = {
247 .set_voltage = pcf50633_regulator_set_voltage,
248 .get_voltage = pcf50633_regulator_get_voltage,
249 .enable = pcf50633_regulator_enable,
250 .disable = pcf50633_regulator_disable,
251 .is_enabled = pcf50633_regulator_is_enabled,
252};
253
254static struct regulator_desc regulators[] = {
255 [PCF50633_REGULATOR_AUTO] =
256 PCF50633_REGULATOR("auto", PCF50633_REGULATOR_AUTO),
257 [PCF50633_REGULATOR_DOWN1] =
258 PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1),
259 [PCF50633_REGULATOR_DOWN2] =
260 PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2),
261 [PCF50633_REGULATOR_LDO1] =
262 PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1),
263 [PCF50633_REGULATOR_LDO2] =
264 PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2),
265 [PCF50633_REGULATOR_LDO3] =
266 PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3),
267 [PCF50633_REGULATOR_LDO4] =
268 PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4),
269 [PCF50633_REGULATOR_LDO5] =
270 PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5),
271 [PCF50633_REGULATOR_LDO6] =
272 PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6),
273 [PCF50633_REGULATOR_HCLDO] =
274 PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO),
275 [PCF50633_REGULATOR_MEMLDO] =
276 PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO),
277};
278
279static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
280{
281 struct regulator_dev *rdev;
282 struct pcf50633 *pcf;
283
284 /* Already set by core driver */
285 pcf = platform_get_drvdata(pdev);
286
287 rdev = regulator_register(&regulators[pdev->id], &pdev->dev, pcf);
288 if (IS_ERR(rdev))
289 return PTR_ERR(rdev);
290
291 if (pcf->pdata->regulator_registered)
292 pcf->pdata->regulator_registered(pcf, pdev->id);
293
294 return 0;
295}
296
297static int __devexit pcf50633_regulator_remove(struct platform_device *pdev)
298{
299 struct regulator_dev *rdev = platform_get_drvdata(pdev);
300
301 regulator_unregister(rdev);
302
303 return 0;
304}
305
306static struct platform_driver pcf50633_regulator_driver = {
307 .driver = {
308 .name = "pcf50633-regltr",
309 },
310 .probe = pcf50633_regulator_probe,
311 .remove = __devexit_p(pcf50633_regulator_remove),
312};
313
314static int __init pcf50633_regulator_init(void)
315{
316 return platform_driver_register(&pcf50633_regulator_driver);
317}
318module_init(pcf50633_regulator_init);
319
320static void __exit pcf50633_regulator_exit(void)
321{
322 platform_driver_unregister(&pcf50633_regulator_driver);
323}
324module_exit(pcf50633_regulator_exit);
325
326MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
327MODULE_DESCRIPTION("PCF50633 regulator driver");
328MODULE_LICENSE("GPL");
329MODULE_ALIAS("platform:pcf50633-regulator");
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4ad831de41ad..cced4d108319 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -502,6 +502,13 @@ config RTC_DRV_WM8350
502 This driver can also be built as a module. If so, the module 502 This driver can also be built as a module. If so, the module
503 will be called "rtc-wm8350". 503 will be called "rtc-wm8350".
504 504
505config RTC_DRV_PCF50633
506 depends on MFD_PCF50633
507 tristate "NXP PCF50633 RTC"
508 help
509 If you say yes here you get support for the RTC subsystem of the
510 NXP PCF50633 used in embedded systems.
511
505comment "on-CPU RTC drivers" 512comment "on-CPU RTC drivers"
506 513
507config RTC_DRV_OMAP 514config RTC_DRV_OMAP
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 9a4340d48f26..6e28021abb9d 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
74obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o 74obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
75obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o 75obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o
76obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o 76obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
77obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
new file mode 100644
index 000000000000..f4dd87e29075
--- /dev/null
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -0,0 +1,344 @@
1/* NXP PCF50633 RTC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/platform_device.h>
22#include <linux/rtc.h>
23#include <linux/bcd.h>
24#include <linux/err.h>
25
26#include <linux/mfd/pcf50633/core.h>
27
28#define PCF50633_REG_RTCSC 0x59 /* Second */
29#define PCF50633_REG_RTCMN 0x5a /* Minute */
30#define PCF50633_REG_RTCHR 0x5b /* Hour */
31#define PCF50633_REG_RTCWD 0x5c /* Weekday */
32#define PCF50633_REG_RTCDT 0x5d /* Day */
33#define PCF50633_REG_RTCMT 0x5e /* Month */
34#define PCF50633_REG_RTCYR 0x5f /* Year */
35#define PCF50633_REG_RTCSCA 0x60 /* Alarm Second */
36#define PCF50633_REG_RTCMNA 0x61 /* Alarm Minute */
37#define PCF50633_REG_RTCHRA 0x62 /* Alarm Hour */
38#define PCF50633_REG_RTCWDA 0x63 /* Alarm Weekday */
39#define PCF50633_REG_RTCDTA 0x64 /* Alarm Day */
40#define PCF50633_REG_RTCMTA 0x65 /* Alarm Month */
41#define PCF50633_REG_RTCYRA 0x66 /* Alarm Year */
42
43enum pcf50633_time_indexes {
44 PCF50633_TI_SEC,
45 PCF50633_TI_MIN,
46 PCF50633_TI_HOUR,
47 PCF50633_TI_WKDAY,
48 PCF50633_TI_DAY,
49 PCF50633_TI_MONTH,
50 PCF50633_TI_YEAR,
51 PCF50633_TI_EXTENT /* always last */
52};
53
54struct pcf50633_time {
55 u_int8_t time[PCF50633_TI_EXTENT];
56};
57
58struct pcf50633_rtc {
59 int alarm_enabled;
60 int second_enabled;
61
62 struct pcf50633 *pcf;
63 struct rtc_device *rtc_dev;
64};
65
66static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf)
67{
68 rtc->tm_sec = bcd2bin(pcf->time[PCF50633_TI_SEC]);
69 rtc->tm_min = bcd2bin(pcf->time[PCF50633_TI_MIN]);
70 rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]);
71 rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]);
72 rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]);
73 rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]);
74 rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100;
75}
76
77static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc)
78{
79 pcf->time[PCF50633_TI_SEC] = bin2bcd(rtc->tm_sec);
80 pcf->time[PCF50633_TI_MIN] = bin2bcd(rtc->tm_min);
81 pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour);
82 pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday);
83 pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday);
84 pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon);
85 pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100);
86}
87
88static int
89pcf50633_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
90{
91 struct pcf50633_rtc *rtc = dev_get_drvdata(dev);
92 int err;
93
94 if (enabled)
95 err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
96 else
97 err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
98
99 if (err < 0)
100 return err;
101
102 rtc->alarm_enabled = enabled;
103
104 return 0;
105}
106
107static int
108pcf50633_rtc_update_irq_enable(struct device *dev, unsigned int enabled)
109{
110 struct pcf50633_rtc *rtc = dev_get_drvdata(dev);
111 int err;
112
113 if (enabled)
114 err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
115 else
116 err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
117
118 if (err < 0)
119 return err;
120
121 rtc->second_enabled = enabled;
122
123 return 0;
124}
125
126static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm)
127{
128 struct pcf50633_rtc *rtc;
129 struct pcf50633_time pcf_tm;
130 int ret;
131
132 rtc = dev_get_drvdata(dev);
133
134 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSC,
135 PCF50633_TI_EXTENT,
136 &pcf_tm.time[0]);
137 if (ret != PCF50633_TI_EXTENT) {
138 dev_err(dev, "Failed to read time\n");
139 return -EIO;
140 }
141
142 dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
143 pcf_tm.time[PCF50633_TI_DAY],
144 pcf_tm.time[PCF50633_TI_MONTH],
145 pcf_tm.time[PCF50633_TI_YEAR],
146 pcf_tm.time[PCF50633_TI_HOUR],
147 pcf_tm.time[PCF50633_TI_MIN],
148 pcf_tm.time[PCF50633_TI_SEC]);
149
150 pcf2rtc_time(tm, &pcf_tm);
151
152 dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
153 tm->tm_mday, tm->tm_mon, tm->tm_year,
154 tm->tm_hour, tm->tm_min, tm->tm_sec);
155
156 return rtc_valid_tm(tm);
157}
158
159static int pcf50633_rtc_set_time(struct device *dev, struct rtc_time *tm)
160{
161 struct pcf50633_rtc *rtc;
162 struct pcf50633_time pcf_tm;
163 int second_masked, alarm_masked, ret = 0;
164
165 rtc = dev_get_drvdata(dev);
166
167 dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
168 tm->tm_mday, tm->tm_mon, tm->tm_year,
169 tm->tm_hour, tm->tm_min, tm->tm_sec);
170
171 rtc2pcf_time(&pcf_tm, tm);
172
173 dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
174 pcf_tm.time[PCF50633_TI_DAY],
175 pcf_tm.time[PCF50633_TI_MONTH],
176 pcf_tm.time[PCF50633_TI_YEAR],
177 pcf_tm.time[PCF50633_TI_HOUR],
178 pcf_tm.time[PCF50633_TI_MIN],
179 pcf_tm.time[PCF50633_TI_SEC]);
180
181
182 second_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_SECOND);
183 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM);
184
185 if (!second_masked)
186 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
187 if (!alarm_masked)
188 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
189
190 /* Returns 0 on success */
191 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSC,
192 PCF50633_TI_EXTENT,
193 &pcf_tm.time[0]);
194
195 if (!second_masked)
196 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
197 if (!alarm_masked)
198 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
199
200 return ret;
201}
202
203static int pcf50633_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
204{
205 struct pcf50633_rtc *rtc;
206 struct pcf50633_time pcf_tm;
207 int ret = 0;
208
209 rtc = dev_get_drvdata(dev);
210
211 alrm->enabled = rtc->alarm_enabled;
212
213 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA,
214 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
215 if (ret != PCF50633_TI_EXTENT) {
216 dev_err(dev, "Failed to read time\n");
217 return -EIO;
218 }
219
220 pcf2rtc_time(&alrm->time, &pcf_tm);
221
222 return rtc_valid_tm(&alrm->time);
223}
224
225static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
226{
227 struct pcf50633_rtc *rtc;
228 struct pcf50633_time pcf_tm;
229 int alarm_masked, ret = 0;
230
231 rtc = dev_get_drvdata(dev);
232
233 rtc2pcf_time(&pcf_tm, &alrm->time);
234
235 /* do like mktime does and ignore tm_wday */
236 pcf_tm.time[PCF50633_TI_WKDAY] = 7;
237
238 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM);
239
240 /* disable alarm interrupt */
241 if (!alarm_masked)
242 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
243
244 /* Returns 0 on success */
245 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
246 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
247
248 if (!alarm_masked)
249 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
250
251 return ret;
252}
253
254static struct rtc_class_ops pcf50633_rtc_ops = {
255 .read_time = pcf50633_rtc_read_time,
256 .set_time = pcf50633_rtc_set_time,
257 .read_alarm = pcf50633_rtc_read_alarm,
258 .set_alarm = pcf50633_rtc_set_alarm,
259 .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable,
260 .update_irq_enable = pcf50633_rtc_update_irq_enable,
261};
262
263static void pcf50633_rtc_irq(int irq, void *data)
264{
265 struct pcf50633_rtc *rtc = data;
266
267 switch (irq) {
268 case PCF50633_IRQ_ALARM:
269 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
270 break;
271 case PCF50633_IRQ_SECOND:
272 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
273 break;
274 }
275}
276
277static int __devinit pcf50633_rtc_probe(struct platform_device *pdev)
278{
279 struct pcf50633_subdev_pdata *pdata;
280 struct pcf50633_rtc *rtc;
281
282
283 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
284 if (!rtc)
285 return -ENOMEM;
286
287 pdata = pdev->dev.platform_data;
288 rtc->pcf = pdata->pcf;
289 platform_set_drvdata(pdev, rtc);
290 rtc->rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev,
291 &pcf50633_rtc_ops, THIS_MODULE);
292
293 if (IS_ERR(rtc->rtc_dev)) {
294 kfree(rtc);
295 return PTR_ERR(rtc->rtc_dev);
296 }
297
298 pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM,
299 pcf50633_rtc_irq, rtc);
300 pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_SECOND,
301 pcf50633_rtc_irq, rtc);
302
303 return 0;
304}
305
306static int __devexit pcf50633_rtc_remove(struct platform_device *pdev)
307{
308 struct pcf50633_rtc *rtc;
309
310 rtc = platform_get_drvdata(pdev);
311
312 pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM);
313 pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_SECOND);
314
315 rtc_device_unregister(rtc->rtc_dev);
316 kfree(rtc);
317
318 return 0;
319}
320
321static struct platform_driver pcf50633_rtc_driver = {
322 .driver = {
323 .name = "pcf50633-rtc",
324 },
325 .probe = pcf50633_rtc_probe,
326 .remove = __devexit_p(pcf50633_rtc_remove),
327};
328
329static int __init pcf50633_rtc_init(void)
330{
331 return platform_driver_register(&pcf50633_rtc_driver);
332}
333module_init(pcf50633_rtc_init);
334
335static void __exit pcf50633_rtc_exit(void)
336{
337 platform_driver_unregister(&pcf50633_rtc_driver);
338}
339module_exit(pcf50633_rtc_exit);
340
341MODULE_DESCRIPTION("PCF50633 RTC driver");
342MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
343MODULE_LICENSE("GPL");
344
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index cc7eb8767b82..bd56a033bfd0 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -27,6 +27,8 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/io.h> 28#include <linux/io.h>
29 29
30#include <mach/hardware.h>
31
30#define TIMER_FREQ CLOCK_TICK_RATE 32#define TIMER_FREQ CLOCK_TICK_RATE
31#define RTC_DEF_DIVIDER (32768 - 1) 33#define RTC_DEF_DIVIDER (32768 - 1)
32#define RTC_DEF_TRIM 0 34#define RTC_DEF_TRIM 0
diff --git a/drivers/rtc/rtc-twl4030.c b/drivers/rtc/rtc-twl4030.c
index 8ce5f74ee45b..ad35f76c46b7 100644
--- a/drivers/rtc/rtc-twl4030.c
+++ b/drivers/rtc/rtc-twl4030.c
@@ -120,7 +120,7 @@ static int twl4030_rtc_write_u8(u8 data, u8 reg)
120static unsigned char rtc_irq_bits; 120static unsigned char rtc_irq_bits;
121 121
122/* 122/*
123 * Enable timer and/or alarm interrupts. 123 * Enable 1/second update and/or alarm interrupts.
124 */ 124 */
125static int set_rtc_irq_bit(unsigned char bit) 125static int set_rtc_irq_bit(unsigned char bit)
126{ 126{
@@ -128,6 +128,7 @@ static int set_rtc_irq_bit(unsigned char bit)
128 int ret; 128 int ret;
129 129
130 val = rtc_irq_bits | bit; 130 val = rtc_irq_bits | bit;
131 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M;
131 ret = twl4030_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 132 ret = twl4030_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
132 if (ret == 0) 133 if (ret == 0)
133 rtc_irq_bits = val; 134 rtc_irq_bits = val;
@@ -136,7 +137,7 @@ static int set_rtc_irq_bit(unsigned char bit)
136} 137}
137 138
138/* 139/*
139 * Disable timer and/or alarm interrupts. 140 * Disable update and/or alarm interrupts.
140 */ 141 */
141static int mask_rtc_irq_bit(unsigned char bit) 142static int mask_rtc_irq_bit(unsigned char bit)
142{ 143{
@@ -151,7 +152,7 @@ static int mask_rtc_irq_bit(unsigned char bit)
151 return ret; 152 return ret;
152} 153}
153 154
154static inline int twl4030_rtc_alarm_irq_set_state(int enabled) 155static int twl4030_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
155{ 156{
156 int ret; 157 int ret;
157 158
@@ -163,7 +164,7 @@ static inline int twl4030_rtc_alarm_irq_set_state(int enabled)
163 return ret; 164 return ret;
164} 165}
165 166
166static inline int twl4030_rtc_irq_set_state(int enabled) 167static int twl4030_rtc_update_irq_enable(struct device *dev, unsigned enabled)
167{ 168{
168 int ret; 169 int ret;
169 170
@@ -292,7 +293,7 @@ static int twl4030_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
292 unsigned char alarm_data[ALL_TIME_REGS + 1]; 293 unsigned char alarm_data[ALL_TIME_REGS + 1];
293 int ret; 294 int ret;
294 295
295 ret = twl4030_rtc_alarm_irq_set_state(0); 296 ret = twl4030_rtc_alarm_irq_enable(dev, 0);
296 if (ret) 297 if (ret)
297 goto out; 298 goto out;
298 299
@@ -312,35 +313,11 @@ static int twl4030_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
312 } 313 }
313 314
314 if (alm->enabled) 315 if (alm->enabled)
315 ret = twl4030_rtc_alarm_irq_set_state(1); 316 ret = twl4030_rtc_alarm_irq_enable(dev, 1);
316out: 317out:
317 return ret; 318 return ret;
318} 319}
319 320
320#ifdef CONFIG_RTC_INTF_DEV
321
322static int twl4030_rtc_ioctl(struct device *dev, unsigned int cmd,
323 unsigned long arg)
324{
325 switch (cmd) {
326 case RTC_AIE_OFF:
327 return twl4030_rtc_alarm_irq_set_state(0);
328 case RTC_AIE_ON:
329 return twl4030_rtc_alarm_irq_set_state(1);
330 case RTC_UIE_OFF:
331 return twl4030_rtc_irq_set_state(0);
332 case RTC_UIE_ON:
333 return twl4030_rtc_irq_set_state(1);
334
335 default:
336 return -ENOIOCTLCMD;
337 }
338}
339
340#else
341#define twl4030_rtc_ioctl NULL
342#endif
343
344static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc) 321static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc)
345{ 322{
346 unsigned long events = 0; 323 unsigned long events = 0;
@@ -400,11 +377,12 @@ out:
400} 377}
401 378
402static struct rtc_class_ops twl4030_rtc_ops = { 379static struct rtc_class_ops twl4030_rtc_ops = {
403 .ioctl = twl4030_rtc_ioctl,
404 .read_time = twl4030_rtc_read_time, 380 .read_time = twl4030_rtc_read_time,
405 .set_time = twl4030_rtc_set_time, 381 .set_time = twl4030_rtc_set_time,
406 .read_alarm = twl4030_rtc_read_alarm, 382 .read_alarm = twl4030_rtc_read_alarm,
407 .set_alarm = twl4030_rtc_set_alarm, 383 .set_alarm = twl4030_rtc_set_alarm,
384 .alarm_irq_enable = twl4030_rtc_alarm_irq_enable,
385 .update_irq_enable = twl4030_rtc_update_irq_enable,
408}; 386};
409 387
410/*----------------------------------------------------------------------*/ 388/*----------------------------------------------------------------------*/
@@ -422,7 +400,7 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
422 rtc = rtc_device_register(pdev->name, 400 rtc = rtc_device_register(pdev->name,
423 &pdev->dev, &twl4030_rtc_ops, THIS_MODULE); 401 &pdev->dev, &twl4030_rtc_ops, THIS_MODULE);
424 if (IS_ERR(rtc)) { 402 if (IS_ERR(rtc)) {
425 ret = -EINVAL; 403 ret = PTR_ERR(rtc);
426 dev_err(&pdev->dev, "can't register RTC device, err %ld\n", 404 dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
427 PTR_ERR(rtc)); 405 PTR_ERR(rtc));
428 goto out0; 406 goto out0;
@@ -432,7 +410,6 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
432 platform_set_drvdata(pdev, rtc); 410 platform_set_drvdata(pdev, rtc);
433 411
434 ret = twl4030_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); 412 ret = twl4030_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
435
436 if (ret < 0) 413 if (ret < 0)
437 goto out1; 414 goto out1;
438 415
@@ -475,7 +452,6 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
475 452
476 return ret; 453 return ret;
477 454
478
479out2: 455out2:
480 free_irq(irq, rtc); 456 free_irq(irq, rtc);
481out1: 457out1:
@@ -506,8 +482,9 @@ static int __devexit twl4030_rtc_remove(struct platform_device *pdev)
506 482
507static void twl4030_rtc_shutdown(struct platform_device *pdev) 483static void twl4030_rtc_shutdown(struct platform_device *pdev)
508{ 484{
509 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M | 485 /* mask timer interrupts, but leave alarm interrupts on to enable
510 BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); 486 power-on when alarm is triggered */
487 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
511} 488}
512 489
513#ifdef CONFIG_PM 490#ifdef CONFIG_PM
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index c4f1b046c3b1..07ab8a5c1c46 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -916,7 +916,7 @@ static struct ethtool_ops qeth_l2_osn_ops = {
916 .get_drvinfo = qeth_core_get_drvinfo, 916 .get_drvinfo = qeth_core_get_drvinfo,
917}; 917};
918 918
919static struct net_device_ops qeth_l2_netdev_ops = { 919static const struct net_device_ops qeth_l2_netdev_ops = {
920 .ndo_open = qeth_l2_open, 920 .ndo_open = qeth_l2_open,
921 .ndo_stop = qeth_l2_stop, 921 .ndo_stop = qeth_l2_stop,
922 .ndo_get_stats = qeth_get_stats, 922 .ndo_get_stats = qeth_get_stats,
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 68d623ab7e6e..3d04920b9bb9 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -2894,7 +2894,7 @@ qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np)
2894 return 0; 2894 return 0;
2895} 2895}
2896 2896
2897static struct net_device_ops qeth_l3_netdev_ops = { 2897static const struct net_device_ops qeth_l3_netdev_ops = {
2898 .ndo_open = qeth_l3_open, 2898 .ndo_open = qeth_l3_open,
2899 .ndo_stop = qeth_l3_stop, 2899 .ndo_stop = qeth_l3_stop,
2900 .ndo_get_stats = qeth_get_stats, 2900 .ndo_get_stats = qeth_get_stats,
@@ -2909,6 +2909,22 @@ static struct net_device_ops qeth_l3_netdev_ops = {
2909 .ndo_tx_timeout = qeth_tx_timeout, 2909 .ndo_tx_timeout = qeth_tx_timeout,
2910}; 2910};
2911 2911
2912static const struct net_device_ops qeth_l3_osa_netdev_ops = {
2913 .ndo_open = qeth_l3_open,
2914 .ndo_stop = qeth_l3_stop,
2915 .ndo_get_stats = qeth_get_stats,
2916 .ndo_start_xmit = qeth_l3_hard_start_xmit,
2917 .ndo_validate_addr = eth_validate_addr,
2918 .ndo_set_multicast_list = qeth_l3_set_multicast_list,
2919 .ndo_do_ioctl = qeth_l3_do_ioctl,
2920 .ndo_change_mtu = qeth_change_mtu,
2921 .ndo_vlan_rx_register = qeth_l3_vlan_rx_register,
2922 .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid,
2923 .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid,
2924 .ndo_tx_timeout = qeth_tx_timeout,
2925 .ndo_neigh_setup = qeth_l3_neigh_setup,
2926};
2927
2912static int qeth_l3_setup_netdev(struct qeth_card *card) 2928static int qeth_l3_setup_netdev(struct qeth_card *card)
2913{ 2929{
2914 if (card->info.type == QETH_CARD_TYPE_OSAE) { 2930 if (card->info.type == QETH_CARD_TYPE_OSAE) {
@@ -2919,12 +2935,12 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2919#endif 2935#endif
2920 if (!card->dev) 2936 if (!card->dev)
2921 return -ENODEV; 2937 return -ENODEV;
2938 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2922 } else { 2939 } else {
2923 card->dev = alloc_etherdev(0); 2940 card->dev = alloc_etherdev(0);
2924 if (!card->dev) 2941 if (!card->dev)
2925 return -ENODEV; 2942 return -ENODEV;
2926 qeth_l3_netdev_ops.ndo_neigh_setup = 2943 card->dev->netdev_ops = &qeth_l3_osa_netdev_ops;
2927 qeth_l3_neigh_setup;
2928 2944
2929 /*IPv6 address autoconfiguration stuff*/ 2945 /*IPv6 address autoconfiguration stuff*/
2930 qeth_l3_get_unique_id(card); 2946 qeth_l3_get_unique_id(card);
@@ -2937,6 +2953,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2937 if (!card->dev) 2953 if (!card->dev)
2938 return -ENODEV; 2954 return -ENODEV;
2939 card->dev->flags |= IFF_NOARP; 2955 card->dev->flags |= IFF_NOARP;
2956 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2940 qeth_l3_iqd_read_initial_mac(card); 2957 qeth_l3_iqd_read_initial_mac(card);
2941 } else 2958 } else
2942 return -ENODEV; 2959 return -ENODEV;
@@ -2944,7 +2961,6 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2944 card->dev->ml_priv = card; 2961 card->dev->ml_priv = card;
2945 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; 2962 card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
2946 card->dev->mtu = card->info.initial_mtu; 2963 card->dev->mtu = card->info.initial_mtu;
2947 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2948 SET_ETHTOOL_OPS(card->dev, &qeth_l3_ethtool_ops); 2964 SET_ETHTOOL_OPS(card->dev, &qeth_l3_ethtool_ops);
2949 card->dev->features |= NETIF_F_HW_VLAN_TX | 2965 card->dev->features |= NETIF_F_HW_VLAN_TX |
2950 NETIF_F_HW_VLAN_RX | 2966 NETIF_F_HW_VLAN_RX |
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index ee0739b217b6..91ef669d98f6 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -933,7 +933,7 @@ static void ibmvfc_get_host_speed(struct Scsi_Host *shost)
933 fc_host_speed(shost) = FC_PORTSPEED_16GBIT; 933 fc_host_speed(shost) = FC_PORTSPEED_16GBIT;
934 break; 934 break;
935 default: 935 default:
936 ibmvfc_log(vhost, 3, "Unknown port speed: %ld Gbit\n", 936 ibmvfc_log(vhost, 3, "Unknown port speed: %lld Gbit\n",
937 vhost->login_buf->resp.link_speed / 100); 937 vhost->login_buf->resp.link_speed / 100);
938 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; 938 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
939 break; 939 break;
@@ -2149,8 +2149,8 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq,
2149{ 2149{
2150 const char *desc = ibmvfc_get_ae_desc(crq->event); 2150 const char *desc = ibmvfc_get_ae_desc(crq->event);
2151 2151
2152 ibmvfc_log(vhost, 3, "%s event received. scsi_id: %lx, wwpn: %lx," 2152 ibmvfc_log(vhost, 3, "%s event received. scsi_id: %llx, wwpn: %llx,"
2153 " node_name: %lx\n", desc, crq->scsi_id, crq->wwpn, crq->node_name); 2153 " node_name: %llx\n", desc, crq->scsi_id, crq->wwpn, crq->node_name);
2154 2154
2155 switch (crq->event) { 2155 switch (crq->event) {
2156 case IBMVFC_AE_LINK_UP: 2156 case IBMVFC_AE_LINK_UP:
@@ -2184,7 +2184,7 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq,
2184 ibmvfc_link_down(vhost, IBMVFC_HALTED); 2184 ibmvfc_link_down(vhost, IBMVFC_HALTED);
2185 break; 2185 break;
2186 default: 2186 default:
2187 dev_err(vhost->dev, "Unknown async event received: %ld\n", crq->event); 2187 dev_err(vhost->dev, "Unknown async event received: %lld\n", crq->event);
2188 break; 2188 break;
2189 }; 2189 };
2190} 2190}
@@ -2261,13 +2261,13 @@ static void ibmvfc_handle_crq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost)
2261 * actually sent 2261 * actually sent
2262 */ 2262 */
2263 if (unlikely(!ibmvfc_valid_event(&vhost->pool, evt))) { 2263 if (unlikely(!ibmvfc_valid_event(&vhost->pool, evt))) {
2264 dev_err(vhost->dev, "Returned correlation_token 0x%08lx is invalid!\n", 2264 dev_err(vhost->dev, "Returned correlation_token 0x%08llx is invalid!\n",
2265 crq->ioba); 2265 crq->ioba);
2266 return; 2266 return;
2267 } 2267 }
2268 2268
2269 if (unlikely(atomic_read(&evt->free))) { 2269 if (unlikely(atomic_read(&evt->free))) {
2270 dev_err(vhost->dev, "Received duplicate correlation_token 0x%08lx!\n", 2270 dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n",
2271 crq->ioba); 2271 crq->ioba);
2272 return; 2272 return;
2273 } 2273 }
@@ -3259,7 +3259,7 @@ static int ibmvfc_alloc_target(struct ibmvfc_host *vhost, u64 scsi_id)
3259 3259
3260 tgt = mempool_alloc(vhost->tgt_pool, GFP_KERNEL); 3260 tgt = mempool_alloc(vhost->tgt_pool, GFP_KERNEL);
3261 if (!tgt) { 3261 if (!tgt) {
3262 dev_err(vhost->dev, "Target allocation failure for scsi id %08lx\n", 3262 dev_err(vhost->dev, "Target allocation failure for scsi id %08llx\n",
3263 scsi_id); 3263 scsi_id);
3264 return -ENOMEM; 3264 return -ENOMEM;
3265 } 3265 }
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h
index babdf3db59df..87dafd0f8d44 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.h
+++ b/drivers/scsi/ibmvscsi/ibmvfc.h
@@ -691,13 +691,13 @@ struct ibmvfc_host {
691#define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0) 691#define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
692 692
693#define tgt_dbg(t, fmt, ...) \ 693#define tgt_dbg(t, fmt, ...) \
694 DBG_CMD(dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)) 694 DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
695 695
696#define tgt_info(t, fmt, ...) \ 696#define tgt_info(t, fmt, ...) \
697 dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 697 dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
698 698
699#define tgt_err(t, fmt, ...) \ 699#define tgt_err(t, fmt, ...) \
700 dev_err((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 700 dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
701 701
702#define ibmvfc_dbg(vhost, ...) \ 702#define ibmvfc_dbg(vhost, ...) \
703 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__)) 703 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 5c541f7850f9..74d07d137dae 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1061,7 +1061,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
1061 } 1061 }
1062 1062
1063 sdev_printk(KERN_INFO, cmd->device, 1063 sdev_printk(KERN_INFO, cmd->device,
1064 "aborting command. lun 0x%lx, tag 0x%lx\n", 1064 "aborting command. lun 0x%llx, tag 0x%llx\n",
1065 (((u64) lun) << 48), (u64) found_evt); 1065 (((u64) lun) << 48), (u64) found_evt);
1066 1066
1067 wait_for_completion(&evt->comp); 1067 wait_for_completion(&evt->comp);
@@ -1082,7 +1082,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
1082 if (rsp_rc) { 1082 if (rsp_rc) {
1083 if (printk_ratelimit()) 1083 if (printk_ratelimit())
1084 sdev_printk(KERN_WARNING, cmd->device, 1084 sdev_printk(KERN_WARNING, cmd->device,
1085 "abort code %d for task tag 0x%lx\n", 1085 "abort code %d for task tag 0x%llx\n",
1086 rsp_rc, tsk_mgmt->task_tag); 1086 rsp_rc, tsk_mgmt->task_tag);
1087 return FAILED; 1087 return FAILED;
1088 } 1088 }
@@ -1102,12 +1102,12 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
1102 1102
1103 if (found_evt == NULL) { 1103 if (found_evt == NULL) {
1104 spin_unlock_irqrestore(hostdata->host->host_lock, flags); 1104 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1105 sdev_printk(KERN_INFO, cmd->device, "aborted task tag 0x%lx completed\n", 1105 sdev_printk(KERN_INFO, cmd->device, "aborted task tag 0x%llx completed\n",
1106 tsk_mgmt->task_tag); 1106 tsk_mgmt->task_tag);
1107 return SUCCESS; 1107 return SUCCESS;
1108 } 1108 }
1109 1109
1110 sdev_printk(KERN_INFO, cmd->device, "successfully aborted task tag 0x%lx\n", 1110 sdev_printk(KERN_INFO, cmd->device, "successfully aborted task tag 0x%llx\n",
1111 tsk_mgmt->task_tag); 1111 tsk_mgmt->task_tag);
1112 1112
1113 cmd->result = (DID_ABORT << 16); 1113 cmd->result = (DID_ABORT << 16);
@@ -1182,7 +1182,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1182 return FAILED; 1182 return FAILED;
1183 } 1183 }
1184 1184
1185 sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%lx\n", 1185 sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%llx\n",
1186 (((u64) lun) << 48)); 1186 (((u64) lun) << 48));
1187 1187
1188 wait_for_completion(&evt->comp); 1188 wait_for_completion(&evt->comp);
@@ -1203,7 +1203,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1203 if (rsp_rc) { 1203 if (rsp_rc) {
1204 if (printk_ratelimit()) 1204 if (printk_ratelimit())
1205 sdev_printk(KERN_WARNING, cmd->device, 1205 sdev_printk(KERN_WARNING, cmd->device,
1206 "reset code %d for task tag 0x%lx\n", 1206 "reset code %d for task tag 0x%llx\n",
1207 rsp_rc, tsk_mgmt->task_tag); 1207 rsp_rc, tsk_mgmt->task_tag);
1208 return FAILED; 1208 return FAILED;
1209 } 1209 }
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 841f460edbc4..07829009a8be 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -4912,7 +4912,7 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
4912 if (res && ipr_is_gata(res)) { 4912 if (res && ipr_is_gata(res)) {
4913 if (cmd == HDIO_GET_IDENTITY) 4913 if (cmd == HDIO_GET_IDENTITY)
4914 return -ENOTTY; 4914 return -ENOTTY;
4915 return ata_scsi_ioctl(sdev, cmd, arg); 4915 return ata_sas_scsi_ioctl(res->sata_port->ap, sdev, cmd, arg);
4916 } 4916 }
4917 4917
4918 return -EINVAL; 4918 return -EINVAL;
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index a745f91d2928..e7705d3532c9 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -177,7 +177,6 @@ int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
177 struct iscsi_segment *segment, int recv, 177 struct iscsi_segment *segment, int recv,
178 unsigned copied) 178 unsigned copied)
179{ 179{
180 static unsigned char padbuf[ISCSI_PAD_LEN];
181 struct scatterlist sg; 180 struct scatterlist sg;
182 unsigned int pad; 181 unsigned int pad;
183 182
@@ -233,7 +232,7 @@ int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
233 debug_tcp("consume %d pad bytes\n", pad); 232 debug_tcp("consume %d pad bytes\n", pad);
234 segment->total_size += pad; 233 segment->total_size += pad;
235 segment->size = pad; 234 segment->size = pad;
236 segment->data = padbuf; 235 segment->data = segment->padbuf;
237 return 0; 236 return 0;
238 } 237 }
239 } 238 }
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 744838780ada..1c558d3bce18 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -717,7 +717,7 @@ int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
717 struct domain_device *dev = sdev_to_domain_dev(sdev); 717 struct domain_device *dev = sdev_to_domain_dev(sdev);
718 718
719 if (dev_is_sata(dev)) 719 if (dev_is_sata(dev))
720 return ata_scsi_ioctl(sdev, cmd, arg); 720 return ata_sas_scsi_ioctl(dev->sata_dev.ap, sdev, cmd, arg);
721 721
722 return -EINVAL; 722 return -EINVAL;
723} 723}
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
index ce48e2d0193c..ca0dd33497ec 100644
--- a/drivers/scsi/ps3rom.c
+++ b/drivers/scsi/ps3rom.c
@@ -290,11 +290,11 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data)
290 290
291 if (tag != dev->tag) 291 if (tag != dev->tag)
292 dev_err(&dev->sbd.core, 292 dev_err(&dev->sbd.core,
293 "%s:%u: tag mismatch, got %lx, expected %lx\n", 293 "%s:%u: tag mismatch, got %llx, expected %llx\n",
294 __func__, __LINE__, tag, dev->tag); 294 __func__, __LINE__, tag, dev->tag);
295 295
296 if (res) { 296 if (res) {
297 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n", 297 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%llx\n",
298 __func__, __LINE__, res, status); 298 __func__, __LINE__, res, status);
299 return IRQ_HANDLED; 299 return IRQ_HANDLED;
300 } 300 }
@@ -364,7 +364,7 @@ static int __devinit ps3rom_probe(struct ps3_system_bus_device *_dev)
364 364
365 if (dev->blk_size != CD_FRAMESIZE) { 365 if (dev->blk_size != CD_FRAMESIZE) {
366 dev_err(&dev->sbd.core, 366 dev_err(&dev->sbd.core,
367 "%s:%u: cannot handle block size %lu\n", __func__, 367 "%s:%u: cannot handle block size %llu\n", __func__,
368 __LINE__, dev->blk_size); 368 __LINE__, dev->blk_size);
369 return -EINVAL; 369 return -EINVAL;
370 } 370 }
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 2d4f32b4df5c..9ad4d0968e5c 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1258,35 +1258,48 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
1258{ 1258{
1259 int rval; 1259 int rval;
1260 unsigned long flags = 0; 1260 unsigned long flags = 0;
1261 int cnt; 1261 int cnt, que;
1262 struct qla_hw_data *ha = vha->hw; 1262 struct qla_hw_data *ha = vha->hw;
1263 struct req_que *req = ha->req_q_map[0]; 1263 struct req_que *req;
1264 struct rsp_que *rsp = ha->rsp_q_map[0]; 1264 struct rsp_que *rsp;
1265 struct scsi_qla_host *vp;
1265 struct mid_init_cb_24xx *mid_init_cb = 1266 struct mid_init_cb_24xx *mid_init_cb =
1266 (struct mid_init_cb_24xx *) ha->init_cb; 1267 (struct mid_init_cb_24xx *) ha->init_cb;
1267 1268
1268 spin_lock_irqsave(&ha->hardware_lock, flags); 1269 spin_lock_irqsave(&ha->hardware_lock, flags);
1269 1270
1270 /* Clear outstanding commands array. */ 1271 /* Clear outstanding commands array. */
1271 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) 1272 for (que = 0; que < ha->max_queues; que++) {
1272 req->outstanding_cmds[cnt] = NULL; 1273 req = ha->req_q_map[que];
1274 if (!req)
1275 continue;
1276 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++)
1277 req->outstanding_cmds[cnt] = NULL;
1273 1278
1274 req->current_outstanding_cmd = 0; 1279 req->current_outstanding_cmd = 0;
1275 1280
1276 /* Clear RSCN queue. */ 1281 /* Initialize firmware. */
1277 vha->rscn_in_ptr = 0; 1282 req->ring_ptr = req->ring;
1278 vha->rscn_out_ptr = 0; 1283 req->ring_index = 0;
1284 req->cnt = req->length;
1285 }
1279 1286
1280 /* Initialize firmware. */ 1287 for (que = 0; que < ha->max_queues; que++) {
1281 req->ring_ptr = req->ring; 1288 rsp = ha->rsp_q_map[que];
1282 req->ring_index = 0; 1289 if (!rsp)
1283 req->cnt = req->length; 1290 continue;
1284 rsp->ring_ptr = rsp->ring; 1291 rsp->ring_ptr = rsp->ring;
1285 rsp->ring_index = 0; 1292 rsp->ring_index = 0;
1286 1293
1287 /* Initialize response queue entries */ 1294 /* Initialize response queue entries */
1288 qla2x00_init_response_q_entries(rsp); 1295 qla2x00_init_response_q_entries(rsp);
1296 }
1289 1297
1298 /* Clear RSCN queue. */
1299 list_for_each_entry(vp, &ha->vp_list, list) {
1300 vp->rscn_in_ptr = 0;
1301 vp->rscn_out_ptr = 0;
1302 }
1290 ha->isp_ops->config_rings(vha); 1303 ha->isp_ops->config_rings(vha);
1291 1304
1292 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1305 spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -3212,8 +3225,8 @@ qla2x00_loop_resync(scsi_qla_host_t *vha)
3212 int rval = QLA_SUCCESS; 3225 int rval = QLA_SUCCESS;
3213 uint32_t wait_time; 3226 uint32_t wait_time;
3214 struct qla_hw_data *ha = vha->hw; 3227 struct qla_hw_data *ha = vha->hw;
3215 struct req_que *req = ha->req_q_map[0]; 3228 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
3216 struct rsp_que *rsp = ha->rsp_q_map[0]; 3229 struct rsp_que *rsp = req->rsp;
3217 3230
3218 atomic_set(&vha->loop_state, LOOP_UPDATE); 3231 atomic_set(&vha->loop_state, LOOP_UPDATE);
3219 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); 3232 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags);
@@ -3492,6 +3505,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
3492 } 3505 }
3493 req = ha->req_q_map[i]; 3506 req = ha->req_q_map[i];
3494 if (req) { 3507 if (req) {
3508 /* Clear outstanding commands array. */
3495 req->options &= ~BIT_0; 3509 req->options &= ~BIT_0;
3496 ret = qla25xx_init_req_que(base_vha, req, req->options); 3510 ret = qla25xx_init_req_que(base_vha, req, req->options);
3497 if (ret != QLA_SUCCESS) 3511 if (ret != QLA_SUCCESS)
@@ -3500,7 +3514,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
3500 req->id)); 3514 req->id));
3501 else 3515 else
3502 DEBUG2_17(printk(KERN_WARNING 3516 DEBUG2_17(printk(KERN_WARNING
3503 "%s Rsp que:%d inited\n", __func__, 3517 "%s Req que:%d inited\n", __func__,
3504 req->id)); 3518 req->id));
3505 } 3519 }
3506 } 3520 }
@@ -4151,8 +4165,8 @@ qla24xx_configure_vhba(scsi_qla_host_t *vha)
4151 uint16_t mb[MAILBOX_REGISTER_COUNT]; 4165 uint16_t mb[MAILBOX_REGISTER_COUNT];
4152 struct qla_hw_data *ha = vha->hw; 4166 struct qla_hw_data *ha = vha->hw;
4153 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); 4167 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
4154 struct req_que *req = ha->req_q_map[0]; 4168 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
4155 struct rsp_que *rsp = ha->rsp_q_map[0]; 4169 struct rsp_que *rsp = req->rsp;
4156 4170
4157 if (!vha->vp_idx) 4171 if (!vha->vp_idx)
4158 return -EINVAL; 4172 return -EINVAL;
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 886323130fcc..f53179c46423 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -629,6 +629,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
629 req->ring_index = 0; 629 req->ring_index = 0;
630 req->cnt = req->length; 630 req->cnt = req->length;
631 req->id = que_id; 631 req->id = que_id;
632 req->max_q_depth = ha->req_q_map[0]->max_q_depth;
632 mutex_unlock(&ha->vport_lock); 633 mutex_unlock(&ha->vport_lock);
633 634
634 ret = qla25xx_init_req_que(base_vha, req, options); 635 ret = qla25xx_init_req_que(base_vha, req, options);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 4a71f522f925..cf32653fe01a 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1158,8 +1158,8 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
1158 struct req_que *req; 1158 struct req_que *req;
1159 1159
1160 spin_lock_irqsave(&ha->hardware_lock, flags); 1160 spin_lock_irqsave(&ha->hardware_lock, flags);
1161 for (que = 0; que < QLA_MAX_HOST_QUES; que++) { 1161 for (que = 0; que < ha->max_queues; que++) {
1162 req = ha->req_q_map[vha->req_ques[que]]; 1162 req = ha->req_q_map[que];
1163 if (!req) 1163 if (!req)
1164 continue; 1164 continue;
1165 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { 1165 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
@@ -1193,7 +1193,7 @@ qla2xxx_slave_configure(struct scsi_device *sdev)
1193 scsi_qla_host_t *vha = shost_priv(sdev->host); 1193 scsi_qla_host_t *vha = shost_priv(sdev->host);
1194 struct qla_hw_data *ha = vha->hw; 1194 struct qla_hw_data *ha = vha->hw;
1195 struct fc_rport *rport = starget_to_rport(sdev->sdev_target); 1195 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1196 struct req_que *req = ha->req_q_map[0]; 1196 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
1197 1197
1198 if (sdev->tagged_supported) 1198 if (sdev->tagged_supported)
1199 scsi_activate_tcq(sdev, req->max_q_depth); 1199 scsi_activate_tcq(sdev, req->max_q_depth);
@@ -1998,7 +1998,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1998 return 0; 1998 return 0;
1999 1999
2000probe_failed: 2000probe_failed:
2001 qla2x00_free_que(ha, req, rsp);
2002 qla2x00_free_device(base_vha); 2001 qla2x00_free_device(base_vha);
2003 2002
2004 scsi_host_put(base_vha->host); 2003 scsi_host_put(base_vha->host);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 42e72a2c1f98..cbcd3f681b62 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1095,7 +1095,8 @@ EXPORT_SYMBOL(__starget_for_each_device);
1095 * Description: Looks up the scsi_device with the specified @lun for a given 1095 * Description: Looks up the scsi_device with the specified @lun for a given
1096 * @starget. The returned scsi_device does not have an additional 1096 * @starget. The returned scsi_device does not have an additional
1097 * reference. You must hold the host's host_lock over this call and 1097 * reference. You must hold the host's host_lock over this call and
1098 * any access to the returned scsi_device. 1098 * any access to the returned scsi_device. A scsi_device in state
1099 * SDEV_DEL is skipped.
1099 * 1100 *
1100 * Note: The only reason why drivers should use this is because 1101 * Note: The only reason why drivers should use this is because
1101 * they need to access the device list in irq context. Otherwise you 1102 * they need to access the device list in irq context. Otherwise you
@@ -1107,6 +1108,8 @@ struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *starget,
1107 struct scsi_device *sdev; 1108 struct scsi_device *sdev;
1108 1109
1109 list_for_each_entry(sdev, &starget->devices, same_target_siblings) { 1110 list_for_each_entry(sdev, &starget->devices, same_target_siblings) {
1111 if (sdev->sdev_state == SDEV_DEL)
1112 continue;
1110 if (sdev->lun ==lun) 1113 if (sdev->lun ==lun)
1111 return sdev; 1114 return sdev;
1112 } 1115 }
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 4969e4ec75ea..099b5455bbce 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -224,6 +224,7 @@ static struct {
224 {"SGI", "TP9100", "*", BLIST_REPORTLUN2}, 224 {"SGI", "TP9100", "*", BLIST_REPORTLUN2},
225 {"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, 225 {"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
226 {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, 226 {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
227 {"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
227 {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36}, 228 {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36},
228 {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN}, 229 {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
229 {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */ 230 {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 1889a63ebc22..0d934bfbdd9b 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2839,6 +2839,8 @@ int __init early_serial_setup(struct uart_port *port)
2839 p->flags = port->flags; 2839 p->flags = port->flags;
2840 p->mapbase = port->mapbase; 2840 p->mapbase = port->mapbase;
2841 p->private_data = port->private_data; 2841 p->private_data = port->private_data;
2842 p->type = port->type;
2843 p->line = port->line;
2842 2844
2843 set_io_from_upio(p); 2845 set_io_from_upio(p);
2844 if (port->serial_in) 2846 if (port->serial_in)
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index c088146b7513..2a3671233b15 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -602,6 +602,10 @@ static int pci_netmos_init(struct pci_dev *dev)
602 /* subdevice 0x00PS means <P> parallel, <S> serial */ 602 /* subdevice 0x00PS means <P> parallel, <S> serial */
603 unsigned int num_serial = dev->subsystem_device & 0xf; 603 unsigned int num_serial = dev->subsystem_device & 0xf;
604 604
605 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
606 dev->subsystem_device == 0x0299)
607 return 0;
608
605 if (num_serial == 0) 609 if (num_serial == 0)
606 return -ENODEV; 610 return -ENODEV;
607 return num_serial; 611 return num_serial;
@@ -3096,6 +3100,10 @@ static struct pci_device_id serial_pci_tbl[] = {
3096 0, 3100 0,
3097 pbn_b0_8_115200 }, 3101 pbn_b0_8_115200 },
3098 3102
3103 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9835,
3104 PCI_VENDOR_ID_IBM, 0x0299,
3105 0, 0, pbn_b0_bt_2_115200 },
3106
3099 /* 3107 /*
3100 * These entries match devices with class COMMUNICATION_SERIAL, 3108 * These entries match devices with class COMMUNICATION_SERIAL,
3101 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL 3109 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index fde7f9ccf57e..bbcfc26a3b6d 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -270,6 +270,8 @@ static const struct pnp_device_id pnp_dev_table[] = {
270 { "RSS0250", 0 }, 270 { "RSS0250", 0 },
271 /* SupraExpress 28.8 Data/Fax PnP modem */ 271 /* SupraExpress 28.8 Data/Fax PnP modem */
272 { "SUP1310", 0 }, 272 { "SUP1310", 0 },
273 /* SupraExpress 336i PnP Voice Modem */
274 { "SUP1381", 0 },
273 /* SupraExpress 33.6 Data/Fax PnP modem */ 275 /* SupraExpress 33.6 Data/Fax PnP modem */
274 { "SUP1421", 0 }, 276 { "SUP1421", 0 },
275 /* SupraExpress 33.6 Data/Fax PnP modem */ 277 /* SupraExpress 33.6 Data/Fax PnP modem */
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index d5efd6c77904..89362d733d62 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -579,7 +579,7 @@ static void atmel_tx_dma(struct uart_port *port)
579 /* disable PDC transmit */ 579 /* disable PDC transmit */
580 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS); 580 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
581 581
582 if (!uart_circ_empty(xmit)) { 582 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) {
583 dma_sync_single_for_device(port->dev, 583 dma_sync_single_for_device(port->dev,
584 pdc->dma_addr, 584 pdc->dma_addr,
585 pdc->dma_size, 585 pdc->dma_size,
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index b7584ca55ade..e6390d023634 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -577,9 +577,6 @@ static void neo_parse_modem(struct jsm_channel *ch, u8 signals)
577 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev, 577 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev,
578 "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals); 578 "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals);
579 579
580 if (!ch)
581 return;
582
583 /* Scrub off lower bits. They signify delta's, which I don't care about */ 580 /* Scrub off lower bits. They signify delta's, which I don't care about */
584 /* Keep DDCD and DDSR though */ 581 /* Keep DDCD and DDSR though */
585 msignals &= 0xf8; 582 msignals &= 0xf8;
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index a821e3a3d664..14f8fa9135be 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -163,6 +163,7 @@ static struct of_device_id __devinitdata of_platform_serial_table[] = {
163 { .type = "serial", .compatible = "ns16450", .data = (void *)PORT_16450, }, 163 { .type = "serial", .compatible = "ns16450", .data = (void *)PORT_16450, },
164 { .type = "serial", .compatible = "ns16550", .data = (void *)PORT_16550, }, 164 { .type = "serial", .compatible = "ns16550", .data = (void *)PORT_16550, },
165 { .type = "serial", .compatible = "ns16750", .data = (void *)PORT_16750, }, 165 { .type = "serial", .compatible = "ns16750", .data = (void *)PORT_16750, },
166 { .type = "serial", .compatible = "ns16850", .data = (void *)PORT_16850, },
166#ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL 167#ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL
167 { .type = "serial", .compatible = "ibm,qpace-nwp-serial", 168 { .type = "serial", .compatible = "ibm,qpace-nwp-serial",
168 .data = (void *)PORT_NWPSERIAL, }, 169 .data = (void *)PORT_NWPSERIAL, },
diff --git a/drivers/serial/pnx8xxx_uart.c b/drivers/serial/pnx8xxx_uart.c
index 22e30d21225e..1bb8f1b45767 100644
--- a/drivers/serial/pnx8xxx_uart.c
+++ b/drivers/serial/pnx8xxx_uart.c
@@ -187,7 +187,7 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport)
187 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | 187 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) |
188 ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); 188 ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT));
189 while (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFIFO)) { 189 while (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFIFO)) {
190 ch = serial_in(sport, PNX8XXX_FIFO); 190 ch = serial_in(sport, PNX8XXX_FIFO) & 0xff;
191 191
192 sport->port.icount.rx++; 192 sport->port.icount.rx++;
193 193
@@ -198,9 +198,16 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport)
198 * out of the main execution path 198 * out of the main execution path
199 */ 199 */
200 if (status & (FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE | 200 if (status & (FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE |
201 PNX8XXX_UART_FIFO_RXPAR) | 201 PNX8XXX_UART_FIFO_RXPAR |
202 PNX8XXX_UART_FIFO_RXBRK) |
202 ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN))) { 203 ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN))) {
203 if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR)) 204 if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXBRK)) {
205 status &= ~(FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) |
206 FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR));
207 sport->port.icount.brk++;
208 if (uart_handle_break(&sport->port))
209 goto ignore_char;
210 } else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR))
204 sport->port.icount.parity++; 211 sport->port.icount.parity++;
205 else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE)) 212 else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE))
206 sport->port.icount.frame++; 213 sport->port.icount.frame++;
@@ -284,14 +291,8 @@ static irqreturn_t pnx8xxx_int(int irq, void *dev_id)
284 /* Get the interrupts */ 291 /* Get the interrupts */
285 status = serial_in(sport, PNX8XXX_ISTAT) & serial_in(sport, PNX8XXX_IEN); 292 status = serial_in(sport, PNX8XXX_ISTAT) & serial_in(sport, PNX8XXX_IEN);
286 293
287 /* Break signal received */ 294 /* Byte or break signal received */
288 if (status & PNX8XXX_UART_INT_BREAK) { 295 if (status & (PNX8XXX_UART_INT_RX | PNX8XXX_UART_INT_BREAK))
289 sport->port.icount.brk++;
290 uart_handle_break(&sport->port);
291 }
292
293 /* Byte received */
294 if (status & PNX8XXX_UART_INT_RX)
295 pnx8xxx_rx_chars(sport); 296 pnx8xxx_rx_chars(sport);
296 297
297 /* TX holding register empty - transmit a byte */ 298 /* TX holding register empty - transmit a byte */
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 5e39bac9c51b..56ff3e6864ea 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -670,8 +670,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
670 dev_dbg(controller, "new message %p submitted for %s\n", 670 dev_dbg(controller, "new message %p submitted for %s\n",
671 msg, spi->dev.bus_id); 671 msg, spi->dev.bus_id);
672 672
673 if (unlikely(list_empty(&msg->transfers) 673 if (unlikely(list_empty(&msg->transfers)))
674 || !spi->max_speed_hz))
675 return -EINVAL; 674 return -EINVAL;
676 675
677 if (as->stopping) 676 if (as->stopping)
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 68d6f4988fb5..fe7e5f35e5d0 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -15,12 +15,15 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18
19#include <linux/of_platform.h>
20#include <linux/of_device.h>
21#include <linux/of_spi.h>
22
18#include <linux/spi/spi.h> 23#include <linux/spi/spi.h>
19#include <linux/spi/spi_bitbang.h> 24#include <linux/spi/spi_bitbang.h>
20#include <linux/io.h> 25#include <linux/io.h>
21 26
22#include <syslib/virtex_devices.h>
23
24#define XILINX_SPI_NAME "xilinx_spi" 27#define XILINX_SPI_NAME "xilinx_spi"
25 28
26/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e) 29/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
@@ -144,23 +147,14 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
144 struct spi_transfer *t) 147 struct spi_transfer *t)
145{ 148{
146 u8 bits_per_word; 149 u8 bits_per_word;
147 u32 hz;
148 struct xilinx_spi *xspi = spi_master_get_devdata(spi->master);
149 150
150 bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word; 151 bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
151 hz = (t) ? t->speed_hz : spi->max_speed_hz;
152 if (bits_per_word != 8) { 152 if (bits_per_word != 8) {
153 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", 153 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
154 __func__, bits_per_word); 154 __func__, bits_per_word);
155 return -EINVAL; 155 return -EINVAL;
156 } 156 }
157 157
158 if (hz && xspi->speed_hz > hz) {
159 dev_err(&spi->dev, "%s, unsupported clock rate %uHz\n",
160 __func__, hz);
161 return -EINVAL;
162 }
163
164 return 0; 158 return 0;
165} 159}
166 160
@@ -304,32 +298,38 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
304 return IRQ_HANDLED; 298 return IRQ_HANDLED;
305} 299}
306 300
307static int __init xilinx_spi_probe(struct platform_device *dev) 301static int __init xilinx_spi_of_probe(struct of_device *ofdev,
302 const struct of_device_id *match)
308{ 303{
309 int ret = 0;
310 struct spi_master *master; 304 struct spi_master *master;
311 struct xilinx_spi *xspi; 305 struct xilinx_spi *xspi;
312 struct xspi_platform_data *pdata; 306 struct resource r_irq_struct;
313 struct resource *r; 307 struct resource r_mem_struct;
308
309 struct resource *r_irq = &r_irq_struct;
310 struct resource *r_mem = &r_mem_struct;
311 int rc = 0;
312 const u32 *prop;
313 int len;
314 314
315 /* Get resources(memory, IRQ) associated with the device */ 315 /* Get resources(memory, IRQ) associated with the device */
316 master = spi_alloc_master(&dev->dev, sizeof(struct xilinx_spi)); 316 master = spi_alloc_master(&ofdev->dev, sizeof(struct xilinx_spi));
317 317
318 if (master == NULL) { 318 if (master == NULL) {
319 return -ENOMEM; 319 return -ENOMEM;
320 } 320 }
321 321
322 platform_set_drvdata(dev, master); 322 dev_set_drvdata(&ofdev->dev, master);
323 pdata = dev->dev.platform_data;
324 323
325 if (pdata == NULL) { 324 rc = of_address_to_resource(ofdev->node, 0, r_mem);
326 ret = -ENODEV; 325 if (rc) {
326 dev_warn(&ofdev->dev, "invalid address\n");
327 goto put_master; 327 goto put_master;
328 } 328 }
329 329
330 r = platform_get_resource(dev, IORESOURCE_MEM, 0); 330 rc = of_irq_to_resource(ofdev->node, 0, r_irq);
331 if (r == NULL) { 331 if (rc == NO_IRQ) {
332 ret = -ENODEV; 332 dev_warn(&ofdev->dev, "no IRQ found\n");
333 goto put_master; 333 goto put_master;
334 } 334 }
335 335
@@ -341,47 +341,57 @@ static int __init xilinx_spi_probe(struct platform_device *dev)
341 xspi->bitbang.master->setup = xilinx_spi_setup; 341 xspi->bitbang.master->setup = xilinx_spi_setup;
342 init_completion(&xspi->done); 342 init_completion(&xspi->done);
343 343
344 if (!request_mem_region(r->start, 344 xspi->irq = r_irq->start;
345 r->end - r->start + 1, XILINX_SPI_NAME)) { 345
346 ret = -ENXIO; 346 if (!request_mem_region(r_mem->start,
347 r_mem->end - r_mem->start + 1, XILINX_SPI_NAME)) {
348 rc = -ENXIO;
349 dev_warn(&ofdev->dev, "memory request failure\n");
347 goto put_master; 350 goto put_master;
348 } 351 }
349 352
350 xspi->regs = ioremap(r->start, r->end - r->start + 1); 353 xspi->regs = ioremap(r_mem->start, r_mem->end - r_mem->start + 1);
351 if (xspi->regs == NULL) { 354 if (xspi->regs == NULL) {
352 ret = -ENOMEM; 355 rc = -ENOMEM;
356 dev_warn(&ofdev->dev, "ioremap failure\n");
353 goto put_master; 357 goto put_master;
354 } 358 }
359 xspi->irq = r_irq->start;
355 360
356 ret = platform_get_irq(dev, 0); 361 /* dynamic bus assignment */
357 if (ret < 0) { 362 master->bus_num = -1;
358 ret = -ENXIO;
359 goto unmap_io;
360 }
361 xspi->irq = ret;
362 363
363 master->bus_num = pdata->bus_num; 364 /* number of slave select bits is required */
364 master->num_chipselect = pdata->num_chipselect; 365 prop = of_get_property(ofdev->node, "xlnx,num-ss-bits", &len);
365 xspi->speed_hz = pdata->speed_hz; 366 if (!prop || len < sizeof(*prop)) {
367 dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
368 goto put_master;
369 }
370 master->num_chipselect = *prop;
366 371
367 /* SPI controller initializations */ 372 /* SPI controller initializations */
368 xspi_init_hw(xspi->regs); 373 xspi_init_hw(xspi->regs);
369 374
370 /* Register for SPI Interrupt */ 375 /* Register for SPI Interrupt */
371 ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); 376 rc = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi);
372 if (ret != 0) 377 if (rc != 0) {
378 dev_warn(&ofdev->dev, "irq request failure: %d\n", xspi->irq);
373 goto unmap_io; 379 goto unmap_io;
380 }
374 381
375 ret = spi_bitbang_start(&xspi->bitbang); 382 rc = spi_bitbang_start(&xspi->bitbang);
376 if (ret != 0) { 383 if (rc != 0) {
377 dev_err(&dev->dev, "spi_bitbang_start FAILED\n"); 384 dev_err(&ofdev->dev, "spi_bitbang_start FAILED\n");
378 goto free_irq; 385 goto free_irq;
379 } 386 }
380 387
381 dev_info(&dev->dev, "at 0x%08X mapped to 0x%08X, irq=%d\n", 388 dev_info(&ofdev->dev, "at 0x%08X mapped to 0x%08X, irq=%d\n",
382 r->start, (u32)xspi->regs, xspi->irq); 389 (unsigned int)r_mem->start, (u32)xspi->regs, xspi->irq);
383 390
384 return ret; 391 /* Add any subnodes on the SPI bus */
392 of_register_spi_devices(master, ofdev->node);
393
394 return rc;
385 395
386free_irq: 396free_irq:
387 free_irq(xspi->irq, xspi); 397 free_irq(xspi->irq, xspi);
@@ -389,21 +399,21 @@ unmap_io:
389 iounmap(xspi->regs); 399 iounmap(xspi->regs);
390put_master: 400put_master:
391 spi_master_put(master); 401 spi_master_put(master);
392 return ret; 402 return rc;
393} 403}
394 404
395static int __devexit xilinx_spi_remove(struct platform_device *dev) 405static int __devexit xilinx_spi_remove(struct of_device *ofdev)
396{ 406{
397 struct xilinx_spi *xspi; 407 struct xilinx_spi *xspi;
398 struct spi_master *master; 408 struct spi_master *master;
399 409
400 master = platform_get_drvdata(dev); 410 master = platform_get_drvdata(ofdev);
401 xspi = spi_master_get_devdata(master); 411 xspi = spi_master_get_devdata(master);
402 412
403 spi_bitbang_stop(&xspi->bitbang); 413 spi_bitbang_stop(&xspi->bitbang);
404 free_irq(xspi->irq, xspi); 414 free_irq(xspi->irq, xspi);
405 iounmap(xspi->regs); 415 iounmap(xspi->regs);
406 platform_set_drvdata(dev, 0); 416 dev_set_drvdata(&ofdev->dev, 0);
407 spi_master_put(xspi->bitbang.master); 417 spi_master_put(xspi->bitbang.master);
408 418
409 return 0; 419 return 0;
@@ -412,27 +422,42 @@ static int __devexit xilinx_spi_remove(struct platform_device *dev)
412/* work with hotplug and coldplug */ 422/* work with hotplug and coldplug */
413MODULE_ALIAS("platform:" XILINX_SPI_NAME); 423MODULE_ALIAS("platform:" XILINX_SPI_NAME);
414 424
415static struct platform_driver xilinx_spi_driver = { 425static int __exit xilinx_spi_of_remove(struct of_device *op)
416 .probe = xilinx_spi_probe, 426{
417 .remove = __devexit_p(xilinx_spi_remove), 427 return xilinx_spi_remove(op);
428}
429
430static struct of_device_id xilinx_spi_of_match[] = {
431 { .compatible = "xlnx,xps-spi-2.00.a", },
432 { .compatible = "xlnx,xps-spi-2.00.b", },
433 {}
434};
435
436MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
437
438static struct of_platform_driver xilinx_spi_of_driver = {
439 .owner = THIS_MODULE,
440 .name = "xilinx-xps-spi",
441 .match_table = xilinx_spi_of_match,
442 .probe = xilinx_spi_of_probe,
443 .remove = __exit_p(xilinx_spi_of_remove),
418 .driver = { 444 .driver = {
419 .name = XILINX_SPI_NAME, 445 .name = "xilinx-xps-spi",
420 .owner = THIS_MODULE, 446 .owner = THIS_MODULE,
421 }, 447 },
422}; 448};
423 449
424static int __init xilinx_spi_init(void) 450static int __init xilinx_spi_init(void)
425{ 451{
426 return platform_driver_register(&xilinx_spi_driver); 452 return of_register_platform_driver(&xilinx_spi_of_driver);
427} 453}
428module_init(xilinx_spi_init); 454module_init(xilinx_spi_init);
429 455
430static void __exit xilinx_spi_exit(void) 456static void __exit xilinx_spi_exit(void)
431{ 457{
432 platform_driver_unregister(&xilinx_spi_driver); 458 of_unregister_platform_driver(&xilinx_spi_of_driver);
433} 459}
434module_exit(xilinx_spi_exit); 460module_exit(xilinx_spi_exit);
435
436MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); 461MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
437MODULE_DESCRIPTION("Xilinx SPI driver"); 462MODULE_DESCRIPTION("Xilinx SPI driver");
438MODULE_LICENSE("GPL"); 463MODULE_LICENSE("GPL");
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d5d0e40b1e2d..94d5ee263c20 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1554,7 +1554,7 @@ static int usb_configure_device_otg(struct usb_device *udev)
1554 * (Includes HNP test device.) 1554 * (Includes HNP test device.)
1555 */ 1555 */
1556 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1556 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1557 err = usb_port_suspend(udev); 1557 err = usb_port_suspend(udev, PMSG_SUSPEND);
1558 if (err < 0) 1558 if (err < 0)
1559 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1559 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
1560 } 1560 }
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index ef6cfa5a447f..c70a8f667d85 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2030,7 +2030,7 @@ static void ftdi_process_read(struct work_struct *work)
2030 spin_unlock_irqrestore(&priv->rx_lock, flags); 2030 spin_unlock_irqrestore(&priv->rx_lock, flags);
2031 dbg("%s - deferring remainder until unthrottled", 2031 dbg("%s - deferring remainder until unthrottled",
2032 __func__); 2032 __func__);
2033 return; 2033 goto out;
2034 } 2034 }
2035 spin_unlock_irqrestore(&priv->rx_lock, flags); 2035 spin_unlock_irqrestore(&priv->rx_lock, flags);
2036 /* if the port is closed stop trying to read */ 2036 /* if the port is closed stop trying to read */
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 01d0c70d60e9..3cf41df302d7 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -145,7 +145,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
145static int ti_write_byte(struct ti_device *tdev, unsigned long addr, 145static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
146 __u8 mask, __u8 byte); 146 __u8 mask, __u8 byte);
147 147
148static int ti_download_firmware(struct ti_device *tdev, int type); 148static int ti_download_firmware(struct ti_device *tdev);
149 149
150/* circular buffer */ 150/* circular buffer */
151static struct circ_buf *ti_buf_alloc(void); 151static struct circ_buf *ti_buf_alloc(void);
@@ -176,9 +176,14 @@ static unsigned int product_5052_count;
176/* the array dimension is the number of default entries plus */ 176/* the array dimension is the number of default entries plus */
177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
178/* null entry */ 178/* null entry */
179static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = { 179static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = {
180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
182 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
183 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_NO_FW_PRODUCT_ID) },
184 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
182}; 187};
183 188
184static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 189static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -188,9 +193,14 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
188 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
189}; 194};
190 195
191static struct usb_device_id ti_id_table_combined[] = { 196static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] = {
192 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 197 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 198 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
199 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
200 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_NO_FW_PRODUCT_ID) },
201 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
202 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
203 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
194 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 204 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
195 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 205 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
196 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 206 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -272,6 +282,9 @@ MODULE_LICENSE("GPL");
272 282
273MODULE_FIRMWARE("ti_3410.fw"); 283MODULE_FIRMWARE("ti_3410.fw");
274MODULE_FIRMWARE("ti_5052.fw"); 284MODULE_FIRMWARE("ti_5052.fw");
285MODULE_FIRMWARE("mts_cdma.fw");
286MODULE_FIRMWARE("mts_gsm.fw");
287MODULE_FIRMWARE("mts_edge.fw");
275 288
276module_param(debug, bool, S_IRUGO | S_IWUSR); 289module_param(debug, bool, S_IRUGO | S_IWUSR);
277MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); 290MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
@@ -304,21 +317,28 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
304 317
305static int __init ti_init(void) 318static int __init ti_init(void)
306{ 319{
307 int i, j; 320 int i, j, c;
308 int ret; 321 int ret;
309 322
310 /* insert extra vendor and product ids */ 323 /* insert extra vendor and product ids */
324 c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1;
311 j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; 325 j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
312 for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++) { 326 for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++, c++) {
313 ti_id_table_3410[j].idVendor = vendor_3410[i]; 327 ti_id_table_3410[j].idVendor = vendor_3410[i];
314 ti_id_table_3410[j].idProduct = product_3410[i]; 328 ti_id_table_3410[j].idProduct = product_3410[i];
315 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 329 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
330 ti_id_table_combined[c].idVendor = vendor_3410[i];
331 ti_id_table_combined[c].idProduct = product_3410[i];
332 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
316 } 333 }
317 j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1; 334 j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1;
318 for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++) { 335 for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++, c++) {
319 ti_id_table_5052[j].idVendor = vendor_5052[i]; 336 ti_id_table_5052[j].idVendor = vendor_5052[i];
320 ti_id_table_5052[j].idProduct = product_5052[i]; 337 ti_id_table_5052[j].idProduct = product_5052[i];
321 ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 338 ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
339 ti_id_table_combined[c].idVendor = vendor_5052[i];
340 ti_id_table_combined[c].idProduct = product_5052[i];
341 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
322 } 342 }
323 343
324 ret = usb_serial_register(&ti_1port_device); 344 ret = usb_serial_register(&ti_1port_device);
@@ -390,11 +410,7 @@ static int ti_startup(struct usb_serial *serial)
390 410
391 /* if we have only 1 configuration, download firmware */ 411 /* if we have only 1 configuration, download firmware */
392 if (dev->descriptor.bNumConfigurations == 1) { 412 if (dev->descriptor.bNumConfigurations == 1) {
393 if (tdev->td_is_3410) 413 if ((status = ti_download_firmware(tdev)) != 0)
394 status = ti_download_firmware(tdev, 3410);
395 else
396 status = ti_download_firmware(tdev, 5052);
397 if (status)
398 goto free_tdev; 414 goto free_tdev;
399 415
400 /* 3410 must be reset, 5052 resets itself */ 416 /* 3410 must be reset, 5052 resets itself */
@@ -1671,9 +1687,9 @@ static int ti_do_download(struct usb_device *dev, int pipe,
1671 return status; 1687 return status;
1672} 1688}
1673 1689
1674static int ti_download_firmware(struct ti_device *tdev, int type) 1690static int ti_download_firmware(struct ti_device *tdev)
1675{ 1691{
1676 int status = -ENOMEM; 1692 int status;
1677 int buffer_size; 1693 int buffer_size;
1678 __u8 *buffer; 1694 __u8 *buffer;
1679 struct usb_device *dev = tdev->td_serial->dev; 1695 struct usb_device *dev = tdev->td_serial->dev;
@@ -1681,9 +1697,34 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1681 tdev->td_serial->port[0]->bulk_out_endpointAddress); 1697 tdev->td_serial->port[0]->bulk_out_endpointAddress);
1682 const struct firmware *fw_p; 1698 const struct firmware *fw_p;
1683 char buf[32]; 1699 char buf[32];
1684 sprintf(buf, "ti_usb-%d.bin", type);
1685 1700
1686 if (request_firmware(&fw_p, buf, &dev->dev)) { 1701 /* try ID specific firmware first, then try generic firmware */
1702 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor,
1703 dev->descriptor.idProduct);
1704 if ((status = request_firmware(&fw_p, buf, &dev->dev)) != 0) {
1705 buf[0] = '\0';
1706 if (dev->descriptor.idVendor == MTS_VENDOR_ID) {
1707 switch (dev->descriptor.idProduct) {
1708 case MTS_CDMA_PRODUCT_ID:
1709 strcpy(buf, "mts_cdma.fw");
1710 break;
1711 case MTS_GSM_PRODUCT_ID:
1712 strcpy(buf, "mts_gsm.fw");
1713 break;
1714 case MTS_EDGE_PRODUCT_ID:
1715 strcpy(buf, "mts_edge.fw");
1716 break;
1717 }
1718 }
1719 if (buf[0] == '\0') {
1720 if (tdev->td_is_3410)
1721 strcpy(buf, "ti_3410.fw");
1722 else
1723 strcpy(buf, "ti_5052.fw");
1724 }
1725 status = request_firmware(&fw_p, buf, &dev->dev);
1726 }
1727 if (status) {
1687 dev_err(&dev->dev, "%s - firmware not found\n", __func__); 1728 dev_err(&dev->dev, "%s - firmware not found\n", __func__);
1688 return -ENOENT; 1729 return -ENOENT;
1689 } 1730 }
@@ -1699,6 +1740,8 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1699 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); 1740 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
1700 status = ti_do_download(dev, pipe, buffer, fw_p->size); 1741 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1701 kfree(buffer); 1742 kfree(buffer);
1743 } else {
1744 status = -ENOMEM;
1702 } 1745 }
1703 release_firmware(fw_p); 1746 release_firmware(fw_p);
1704 if (status) { 1747 if (status) {
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index b5541bf991ba..7e4752fbf232 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -34,6 +34,14 @@
34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */ 34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
35#define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */ 35#define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */
36 36
37/* Multi-Tech vendor and product ids */
38#define MTS_VENDOR_ID 0x06E0
39#define MTS_GSM_NO_FW_PRODUCT_ID 0xF108
40#define MTS_CDMA_NO_FW_PRODUCT_ID 0xF109
41#define MTS_CDMA_PRODUCT_ID 0xF110
42#define MTS_GSM_PRODUCT_ID 0xF111
43#define MTS_EDGE_PRODUCT_ID 0xF112
44
37/* Commands */ 45/* Commands */
38#define TI_GET_VERSION 0x01 46#define TI_GET_VERSION 0x01
39#define TI_GET_PORT_STATUS 0x02 47#define TI_GET_PORT_STATUS 0x02
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 080ade223d53..cfcfd5ab06ce 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -511,9 +511,6 @@ static void usb_serial_port_work(struct work_struct *work)
511 511
512 dbg("%s - port %d", __func__, port->number); 512 dbg("%s - port %d", __func__, port->number);
513 513
514 if (!port)
515 return;
516
517 tty = tty_port_tty_get(&port->port); 514 tty = tty_port_tty_get(&port->port);
518 if (!tty) 515 if (!tty)
519 return; 516 return;
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index e39e33e797da..be2b657546ef 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_FB_DDC) += fb_ddc.o
28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o 28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
29 29
30# Hardware specific drivers go first 30# Hardware specific drivers go first
31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o 31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
32obj-$(CONFIG_FB_ARC) += arcfb.o 32obj-$(CONFIG_FB_ARC) += arcfb.o
33obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o 33obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o
34obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o 34obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
@@ -72,7 +72,7 @@ obj-$(CONFIG_FB_TCX) += tcx.o sbuslib.o
72obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o 72obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o
73obj-$(CONFIG_FB_SGIVW) += sgivwfb.o 73obj-$(CONFIG_FB_SGIVW) += sgivwfb.o
74obj-$(CONFIG_FB_ACORN) += acornfb.o 74obj-$(CONFIG_FB_ACORN) += acornfb.o
75obj-$(CONFIG_FB_ATARI) += atafb.o c2p.o atafb_mfb.o \ 75obj-$(CONFIG_FB_ATARI) += atafb.o c2p_iplan2.o atafb_mfb.o \
76 atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o 76 atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o
77obj-$(CONFIG_FB_MAC) += macfb.o 77obj-$(CONFIG_FB_MAC) += macfb.o
78obj-$(CONFIG_FB_HECUBA) += hecubafb.o 78obj-$(CONFIG_FB_HECUBA) += hecubafb.o
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index b8e9a8682f2d..100f23661465 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -2159,9 +2159,9 @@ static void amifb_imageblit(struct fb_info *info, const struct fb_image *image)
2159 src += pitch; 2159 src += pitch;
2160 } 2160 }
2161 } else { 2161 } else {
2162 c2p(info->screen_base, image->data, dx, dy, width, height, 2162 c2p_planar(info->screen_base, image->data, dx, dy, width,
2163 par->next_line, par->next_plane, image->width, 2163 height, par->next_line, par->next_plane,
2164 info->var.bits_per_pixel); 2164 image->width, info->var.bits_per_pixel);
2165 } 2165 }
2166} 2166}
2167 2167
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index 77eb8b34fbfa..8058572a7428 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -122,7 +122,6 @@ static struct atafb_par {
122 void *screen_base; 122 void *screen_base;
123 int yres_virtual; 123 int yres_virtual;
124 u_long next_line; 124 u_long next_line;
125 u_long next_plane;
126#if defined ATAFB_TT || defined ATAFB_STE 125#if defined ATAFB_TT || defined ATAFB_STE
127 union { 126 union {
128 struct { 127 struct {
@@ -149,6 +148,7 @@ static struct atafb_par {
149 short mono; 148 short mono;
150 short ste_mode; 149 short ste_mode;
151 short bpp; 150 short bpp;
151 u32 pseudo_palette[16];
152 } falcon; 152 } falcon;
153#endif 153#endif
154 /* Nothing needed for external mode */ 154 /* Nothing needed for external mode */
@@ -614,7 +614,7 @@ static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
614 fix->xpanstep = 0; 614 fix->xpanstep = 0;
615 fix->ypanstep = 1; 615 fix->ypanstep = 1;
616 fix->ywrapstep = 0; 616 fix->ywrapstep = 0;
617 fix->line_length = 0; 617 fix->line_length = par->next_line;
618 fix->accel = FB_ACCEL_ATARIBLITT; 618 fix->accel = FB_ACCEL_ATARIBLITT;
619 return 0; 619 return 0;
620} 620}
@@ -691,6 +691,7 @@ static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
691 return -EINVAL; 691 return -EINVAL;
692 par->yres_virtual = yres_virtual; 692 par->yres_virtual = yres_virtual;
693 par->screen_base = screen_base + var->yoffset * linelen; 693 par->screen_base = screen_base + var->yoffset * linelen;
694 par->next_line = linelen;
694 return 0; 695 return 0;
695} 696}
696 697
@@ -884,10 +885,6 @@ static int vdl_prescale[4][3] = {
884/* Default hsync timing [mon_type] in picoseconds */ 885/* Default hsync timing [mon_type] in picoseconds */
885static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 }; 886static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 };
886 887
887#ifdef FBCON_HAS_CFB16
888static u16 fbcon_cfb16_cmap[16];
889#endif
890
891static inline int hxx_prescale(struct falcon_hw *hw) 888static inline int hxx_prescale(struct falcon_hw *hw)
892{ 889{
893 return hw->ste_mode ? 16 890 return hw->ste_mode ? 16
@@ -918,7 +915,7 @@ static int falcon_encode_fix(struct fb_fix_screeninfo *fix,
918 fix->visual = FB_VISUAL_TRUECOLOR; 915 fix->visual = FB_VISUAL_TRUECOLOR;
919 fix->xpanstep = 2; 916 fix->xpanstep = 2;
920 } 917 }
921 fix->line_length = 0; 918 fix->line_length = par->next_line;
922 fix->accel = FB_ACCEL_ATARIBLITT; 919 fix->accel = FB_ACCEL_ATARIBLITT;
923 return 0; 920 return 0;
924} 921}
@@ -1394,14 +1391,7 @@ set_screen_base:
1394 par->screen_base = screen_base + var->yoffset * linelen; 1391 par->screen_base = screen_base + var->yoffset * linelen;
1395 par->hw.falcon.xoffset = 0; 1392 par->hw.falcon.xoffset = 0;
1396 1393
1397 // FIXME!!! sort of works, no crash
1398 //par->next_line = linelen;
1399 //par->next_plane = yres_virtual * linelen;
1400 par->next_line = linelen; 1394 par->next_line = linelen;
1401 par->next_plane = 2;
1402 // crashes
1403 //par->next_plane = linelen;
1404 //par->next_line = yres_virtual * linelen;
1405 1395
1406 return 0; 1396 return 0;
1407} 1397}
@@ -1735,10 +1725,10 @@ static int falcon_setcolreg(unsigned int regno, unsigned int red,
1735 (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) | 1725 (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) |
1736 (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) | 1726 (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) |
1737 ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); 1727 ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12);
1738#ifdef FBCON_HAS_CFB16 1728#ifdef ATAFB_FALCON
1739 fbcon_cfb16_cmap[regno] = ((red & 0xf800) | 1729 ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) |
1740 ((green & 0xfc00) >> 5) | 1730 ((green & 0xfc00) >> 5) |
1741 ((blue & 0xf800) >> 11)); 1731 ((blue & 0xf800) >> 11));
1742#endif 1732#endif
1743 } 1733 }
1744 return 0; 1734 return 0;
@@ -1852,7 +1842,7 @@ static int stste_encode_fix(struct fb_fix_screeninfo *fix,
1852 fix->ypanstep = 0; 1842 fix->ypanstep = 0;
1853 } 1843 }
1854 fix->ywrapstep = 0; 1844 fix->ywrapstep = 0;
1855 fix->line_length = 0; 1845 fix->line_length = par->next_line;
1856 fix->accel = FB_ACCEL_ATARIBLITT; 1846 fix->accel = FB_ACCEL_ATARIBLITT;
1857 return 0; 1847 return 0;
1858} 1848}
@@ -1910,6 +1900,7 @@ static int stste_decode_var(struct fb_var_screeninfo *var,
1910 return -EINVAL; 1900 return -EINVAL;
1911 par->yres_virtual = yres_virtual; 1901 par->yres_virtual = yres_virtual;
1912 par->screen_base = screen_base + var->yoffset * linelen; 1902 par->screen_base = screen_base + var->yoffset * linelen;
1903 par->next_line = linelen;
1913 return 0; 1904 return 0;
1914} 1905}
1915 1906
@@ -2169,7 +2160,7 @@ static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
2169 fix->xpanstep = 0; 2160 fix->xpanstep = 0;
2170 fix->ypanstep = 0; 2161 fix->ypanstep = 0;
2171 fix->ywrapstep = 0; 2162 fix->ywrapstep = 0;
2172 fix->line_length = 0; 2163 fix->line_length = par->next_line;
2173 return 0; 2164 return 0;
2174} 2165}
2175 2166
@@ -2184,6 +2175,8 @@ static int ext_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
2184 var->xoffset > 0 || 2175 var->xoffset > 0 ||
2185 var->yoffset > 0) 2176 var->yoffset > 0)
2186 return -EINVAL; 2177 return -EINVAL;
2178
2179 par->next_line = external_xres_virtual * external_depth / 8;
2187 return 0; 2180 return 0;
2188} 2181}
2189 2182
@@ -2443,42 +2436,6 @@ static void atafb_set_disp(struct fb_info *info)
2443 atafb_get_fix(&info->fix, info); 2436 atafb_get_fix(&info->fix, info);
2444 2437
2445 info->screen_base = (void *)info->fix.smem_start; 2438 info->screen_base = (void *)info->fix.smem_start;
2446
2447 switch (info->fix.type) {
2448 case FB_TYPE_INTERLEAVED_PLANES:
2449 switch (info->var.bits_per_pixel) {
2450 case 2:
2451 // display->dispsw = &fbcon_iplan2p2;
2452 break;
2453 case 4:
2454 // display->dispsw = &fbcon_iplan2p4;
2455 break;
2456 case 8:
2457 // display->dispsw = &fbcon_iplan2p8;
2458 break;
2459 }
2460 break;
2461 case FB_TYPE_PACKED_PIXELS:
2462 switch (info->var.bits_per_pixel) {
2463#ifdef FBCON_HAS_MFB
2464 case 1:
2465 // display->dispsw = &fbcon_mfb;
2466 break;
2467#endif
2468#ifdef FBCON_HAS_CFB8
2469 case 8:
2470 // display->dispsw = &fbcon_cfb8;
2471 break;
2472#endif
2473#ifdef FBCON_HAS_CFB16
2474 case 16:
2475 // display->dispsw = &fbcon_cfb16;
2476 // display->dispsw_data = fbcon_cfb16_cmap;
2477 break;
2478#endif
2479 }
2480 break;
2481 }
2482} 2439}
2483 2440
2484static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, 2441static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
@@ -2549,6 +2506,13 @@ static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
2549 if (!rect->width || !rect->height) 2506 if (!rect->width || !rect->height)
2550 return; 2507 return;
2551 2508
2509#ifdef ATAFB_FALCON
2510 if (info->var.bits_per_pixel == 16) {
2511 cfb_fillrect(info, rect);
2512 return;
2513 }
2514#endif
2515
2552 /* 2516 /*
2553 * We could use hardware clipping but on many cards you get around 2517 * We could use hardware clipping but on many cards you get around
2554 * hardware clipping by writing to framebuffer directly. 2518 * hardware clipping by writing to framebuffer directly.
@@ -2583,6 +2547,13 @@ static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
2583 u32 dx, dy, sx, sy, width, height; 2547 u32 dx, dy, sx, sy, width, height;
2584 int rev_copy = 0; 2548 int rev_copy = 0;
2585 2549
2550#ifdef ATAFB_FALCON
2551 if (info->var.bits_per_pixel == 16) {
2552 cfb_copyarea(info, area);
2553 return;
2554 }
2555#endif
2556
2586 /* clip the destination */ 2557 /* clip the destination */
2587 x2 = area->dx + area->width; 2558 x2 = area->dx + area->width;
2588 y2 = area->dy + area->height; 2559 y2 = area->dy + area->height;
@@ -2632,6 +2603,13 @@ static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
2632 const char *src; 2603 const char *src;
2633 u32 dx, dy, width, height, pitch; 2604 u32 dx, dy, width, height, pitch;
2634 2605
2606#ifdef ATAFB_FALCON
2607 if (info->var.bits_per_pixel == 16) {
2608 cfb_imageblit(info, image);
2609 return;
2610 }
2611#endif
2612
2635 /* 2613 /*
2636 * We could use hardware clipping but on many cards you get around 2614 * We could use hardware clipping but on many cards you get around
2637 * hardware clipping by writing to framebuffer directly like we are 2615 * hardware clipping by writing to framebuffer directly like we are
@@ -2676,10 +2654,9 @@ static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
2676 src += pitch; 2654 src += pitch;
2677 } 2655 }
2678 } else { 2656 } else {
2679 // only used for logo; broken 2657 c2p_iplan2(info->screen_base, image->data, dx, dy, width,
2680 c2p(info->screen_base, image->data, dx, dy, width, height, 2658 height, par->next_line, image->width,
2681 par->next_line, par->next_plane, image->width, 2659 info->var.bits_per_pixel);
2682 info->var.bits_per_pixel);
2683 } 2660 }
2684} 2661}
2685 2662
@@ -3098,8 +3075,7 @@ int __init atafb_setup(char *options)
3098 3075
3099int __init atafb_init(void) 3076int __init atafb_init(void)
3100{ 3077{
3101 int pad; 3078 int pad, detected_mode, error;
3102 int detected_mode;
3103 unsigned int defmode = 0; 3079 unsigned int defmode = 0;
3104 unsigned long mem_req; 3080 unsigned long mem_req;
3105 3081
@@ -3139,8 +3115,12 @@ int __init atafb_init(void)
3139 printk("atafb_init: initializing Falcon hw\n"); 3115 printk("atafb_init: initializing Falcon hw\n");
3140 fbhw = &falcon_switch; 3116 fbhw = &falcon_switch;
3141 atafb_ops.fb_setcolreg = &falcon_setcolreg; 3117 atafb_ops.fb_setcolreg = &falcon_setcolreg;
3142 request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, 3118 error = request_irq(IRQ_AUTO_4, falcon_vbl_switcher,
3143 "framebuffer/modeswitch", falcon_vbl_switcher); 3119 IRQ_TYPE_PRIO,
3120 "framebuffer/modeswitch",
3121 falcon_vbl_switcher);
3122 if (error)
3123 return error;
3144 defmode = DEFMODE_F30; 3124 defmode = DEFMODE_F30;
3145 break; 3125 break;
3146 } 3126 }
@@ -3225,6 +3205,10 @@ int __init atafb_init(void)
3225 // tries to read from HW which may not be initialized yet 3205 // tries to read from HW which may not be initialized yet
3226 // so set sane var first, then call atafb_set_par 3206 // so set sane var first, then call atafb_set_par
3227 atafb_get_var(&fb_info.var, &fb_info); 3207 atafb_get_var(&fb_info.var, &fb_info);
3208
3209#ifdef ATAFB_FALCON
3210 fb_info.pseudo_palette = current_par.hw.falcon.pseudo_palette;
3211#endif
3228 fb_info.flags = FBINFO_FLAG_DEFAULT; 3212 fb_info.flags = FBINFO_FLAG_DEFAULT;
3229 3213
3230 if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb, 3214 if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb,
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index 7644ed249564..37e60b1d2ed9 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -335,7 +335,20 @@ static int bfin_bf54x_fb_check_var(struct fb_var_screeninfo *var,
335 struct fb_info *info) 335 struct fb_info *info)
336{ 336{
337 337
338 if (var->bits_per_pixel != LCD_BPP) { 338 switch (var->bits_per_pixel) {
339 case 24:/* TRUECOLOUR, 16m */
340 var->red.offset = 16;
341 var->green.offset = 8;
342 var->blue.offset = 0;
343 var->red.length = var->green.length = var->blue.length = 8;
344 var->transp.offset = 0;
345 var->transp.length = 0;
346 var->transp.msb_right = 0;
347 var->red.msb_right = 0;
348 var->green.msb_right = 0;
349 var->blue.msb_right = 0;
350 break;
351 default:
339 pr_debug("%s: depth not supported: %u BPP\n", __func__, 352 pr_debug("%s: depth not supported: %u BPP\n", __func__,
340 var->bits_per_pixel); 353 var->bits_per_pixel);
341 return -EINVAL; 354 return -EINVAL;
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index a9b3ada05d99..2a423d3a2a8e 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -254,7 +254,20 @@ static int bfin_t350mcqb_fb_check_var(struct fb_var_screeninfo *var,
254 struct fb_info *info) 254 struct fb_info *info)
255{ 255{
256 256
257 if (var->bits_per_pixel != LCD_BPP) { 257 switch (var->bits_per_pixel) {
258 case 24:/* TRUECOLOUR, 16m */
259 var->red.offset = 0;
260 var->green.offset = 8;
261 var->blue.offset = 16;
262 var->red.length = var->green.length = var->blue.length = 8;
263 var->transp.offset = 0;
264 var->transp.length = 0;
265 var->transp.msb_right = 0;
266 var->red.msb_right = 0;
267 var->green.msb_right = 0;
268 var->blue.msb_right = 0;
269 break;
270 default:
258 pr_debug("%s: depth not supported: %u BPP\n", __func__, 271 pr_debug("%s: depth not supported: %u BPP\n", __func__,
259 var->bits_per_pixel); 272 var->bits_per_pixel);
260 return -EINVAL; 273 return -EINVAL;
diff --git a/drivers/video/c2p.c b/drivers/video/c2p.c
deleted file mode 100644
index 376bc07ff952..000000000000
--- a/drivers/video/c2p.c
+++ /dev/null
@@ -1,232 +0,0 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003 Geert Uytterhoeven
5 *
6 * NOTES:
7 * - This code was inspired by Scout's C2P tutorial
8 * - It assumes to run on a big endian system
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15#include <linux/module.h>
16#include <linux/string.h>
17#include "c2p.h"
18
19
20 /*
21 * Basic transpose step
22 */
23
24#define _transp(d, i1, i2, shift, mask) \
25 do { \
26 u32 t = (d[i1] ^ (d[i2] >> shift)) & mask; \
27 d[i1] ^= t; \
28 d[i2] ^= t << shift; \
29 } while (0)
30
31static inline u32 get_mask(int n)
32{
33 switch (n) {
34 case 1:
35 return 0x55555555;
36 break;
37
38 case 2:
39 return 0x33333333;
40 break;
41
42 case 4:
43 return 0x0f0f0f0f;
44 break;
45
46 case 8:
47 return 0x00ff00ff;
48 break;
49
50 case 16:
51 return 0x0000ffff;
52 break;
53 }
54 return 0;
55}
56
57#define transp_nx1(d, n) \
58 do { \
59 u32 mask = get_mask(n); \
60 /* First block */ \
61 _transp(d, 0, 1, n, mask); \
62 /* Second block */ \
63 _transp(d, 2, 3, n, mask); \
64 /* Third block */ \
65 _transp(d, 4, 5, n, mask); \
66 /* Fourth block */ \
67 _transp(d, 6, 7, n, mask); \
68 } while (0)
69
70#define transp_nx2(d, n) \
71 do { \
72 u32 mask = get_mask(n); \
73 /* First block */ \
74 _transp(d, 0, 2, n, mask); \
75 _transp(d, 1, 3, n, mask); \
76 /* Second block */ \
77 _transp(d, 4, 6, n, mask); \
78 _transp(d, 5, 7, n, mask); \
79 } while (0)
80
81#define transp_nx4(d, n) \
82 do { \
83 u32 mask = get_mask(n); \
84 _transp(d, 0, 4, n, mask); \
85 _transp(d, 1, 5, n, mask); \
86 _transp(d, 2, 6, n, mask); \
87 _transp(d, 3, 7, n, mask); \
88 } while (0)
89
90#define transp(d, n, m) transp_nx ## m(d, n)
91
92
93 /*
94 * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words
95 * containing
96 * - 32 8-bit chunky pixels on input
97 * - permuted planar data on output
98 */
99
100static void c2p_8bpp(u32 d[8])
101{
102 transp(d, 16, 4);
103 transp(d, 8, 2);
104 transp(d, 4, 1);
105 transp(d, 2, 4);
106 transp(d, 1, 2);
107}
108
109
110 /*
111 * Array containing the permution indices of the planar data after c2p
112 */
113
114static const int perm_c2p_8bpp[8] = { 7, 5, 3, 1, 6, 4, 2, 0 };
115
116
117 /*
118 * Compose two values, using a bitmask as decision value
119 * This is equivalent to (a & mask) | (b & ~mask)
120 */
121
122static inline unsigned long comp(unsigned long a, unsigned long b,
123 unsigned long mask)
124{
125 return ((a ^ b) & mask) ^ b;
126}
127
128
129 /*
130 * Store a full block of planar data after c2p conversion
131 */
132
133static inline void store_planar(char *dst, u32 dst_inc, u32 bpp, u32 d[8])
134{
135 int i;
136
137 for (i = 0; i < bpp; i++, dst += dst_inc)
138 *(u32 *)dst = d[perm_c2p_8bpp[i]];
139}
140
141
142 /*
143 * Store a partial block of planar data after c2p conversion
144 */
145
146static inline void store_planar_masked(char *dst, u32 dst_inc, u32 bpp,
147 u32 d[8], u32 mask)
148{
149 int i;
150
151 for (i = 0; i < bpp; i++, dst += dst_inc)
152 *(u32 *)dst = comp(d[perm_c2p_8bpp[i]], *(u32 *)dst, mask);
153}
154
155
156 /*
157 * c2p - Copy 8-bit chunky image data to a planar frame buffer
158 * @dst: Starting address of the planar frame buffer
159 * @dx: Horizontal destination offset (in pixels)
160 * @dy: Vertical destination offset (in pixels)
161 * @width: Image width (in pixels)
162 * @height: Image height (in pixels)
163 * @dst_nextline: Frame buffer offset to the next line (in bytes)
164 * @dst_nextplane: Frame buffer offset to the next plane (in bytes)
165 * @src_nextline: Image offset to the next line (in bytes)
166 * @bpp: Bits per pixel of the planar frame buffer (1-8)
167 */
168
169void c2p(u8 *dst, const u8 *src, u32 dx, u32 dy, u32 width, u32 height,
170 u32 dst_nextline, u32 dst_nextplane, u32 src_nextline, u32 bpp)
171{
172 int dst_idx;
173 u32 d[8], first, last, w;
174 const u8 *c;
175 u8 *p;
176
177 dst += dy*dst_nextline+(dx & ~31);
178 dst_idx = dx % 32;
179 first = ~0UL >> dst_idx;
180 last = ~(~0UL >> ((dst_idx+width) % 32));
181 while (height--) {
182 c = src;
183 p = dst;
184 w = width;
185 if (dst_idx+width <= 32) {
186 /* Single destination word */
187 first &= last;
188 memset(d, 0, sizeof(d));
189 memcpy((u8 *)d+dst_idx, c, width);
190 c += width;
191 c2p_8bpp(d);
192 store_planar_masked(p, dst_nextplane, bpp, d, first);
193 p += 4;
194 } else {
195 /* Multiple destination words */
196 w = width;
197 /* Leading bits */
198 if (dst_idx) {
199 w = 32 - dst_idx;
200 memset(d, 0, dst_idx);
201 memcpy((u8 *)d+dst_idx, c, w);
202 c += w;
203 c2p_8bpp(d);
204 store_planar_masked(p, dst_nextplane, bpp, d, first);
205 p += 4;
206 w = width-w;
207 }
208 /* Main chunk */
209 while (w >= 32) {
210 memcpy(d, c, 32);
211 c += 32;
212 c2p_8bpp(d);
213 store_planar(p, dst_nextplane, bpp, d);
214 p += 4;
215 w -= 32;
216 }
217 /* Trailing bits */
218 w %= 32;
219 if (w > 0) {
220 memcpy(d, c, w);
221 memset((u8 *)d+w, 0, 32-w);
222 c2p_8bpp(d);
223 store_planar_masked(p, dst_nextplane, bpp, d, last);
224 }
225 }
226 src += src_nextline;
227 dst += dst_nextline;
228 }
229}
230EXPORT_SYMBOL_GPL(c2p);
231
232MODULE_LICENSE("GPL");
diff --git a/drivers/video/c2p.h b/drivers/video/c2p.h
index c77cbf17e043..6c38d40427d8 100644
--- a/drivers/video/c2p.h
+++ b/drivers/video/c2p.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Fast C2P (Chunky-to-Planar) Conversion 2 * Fast C2P (Chunky-to-Planar) Conversion
3 * 3 *
4 * Copyright (C) 2003 Geert Uytterhoeven 4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive 7 * License. See the file COPYING in the main directory of this archive
@@ -10,7 +10,10 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13extern void c2p(u8 *dst, const u8 *src, u32 dx, u32 dy, u32 width, u32 height, 13extern void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width,
14 u32 dst_nextline, u32 dst_nextplane, u32 src_nextline, 14 u32 height, u32 dst_nextline, u32 dst_nextplane,
15 u32 bpp); 15 u32 src_nextline, u32 bpp);
16 16
17extern void c2p_iplan2(void *dst, const void *src, u32 dx, u32 dy, u32 width,
18 u32 height, u32 dst_nextline, u32 src_nextline,
19 u32 bpp);
diff --git a/drivers/video/c2p_core.h b/drivers/video/c2p_core.h
new file mode 100644
index 000000000000..e1035a865fb9
--- /dev/null
+++ b/drivers/video/c2p_core.h
@@ -0,0 +1,153 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * NOTES:
7 * - This code was inspired by Scout's C2P tutorial
8 * - It assumes to run on a big endian system
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15
16 /*
17 * Basic transpose step
18 */
19
20static inline void _transp(u32 d[], unsigned int i1, unsigned int i2,
21 unsigned int shift, u32 mask)
22{
23 u32 t = (d[i1] ^ (d[i2] >> shift)) & mask;
24
25 d[i1] ^= t;
26 d[i2] ^= t << shift;
27}
28
29
30extern void c2p_unsupported(void);
31
32static inline u32 get_mask(unsigned int n)
33{
34 switch (n) {
35 case 1:
36 return 0x55555555;
37
38 case 2:
39 return 0x33333333;
40
41 case 4:
42 return 0x0f0f0f0f;
43
44 case 8:
45 return 0x00ff00ff;
46
47 case 16:
48 return 0x0000ffff;
49 }
50
51 c2p_unsupported();
52 return 0;
53}
54
55
56 /*
57 * Transpose operations on 8 32-bit words
58 */
59
60static inline void transp8(u32 d[], unsigned int n, unsigned int m)
61{
62 u32 mask = get_mask(n);
63
64 switch (m) {
65 case 1:
66 /* First n x 1 block */
67 _transp(d, 0, 1, n, mask);
68 /* Second n x 1 block */
69 _transp(d, 2, 3, n, mask);
70 /* Third n x 1 block */
71 _transp(d, 4, 5, n, mask);
72 /* Fourth n x 1 block */
73 _transp(d, 6, 7, n, mask);
74 return;
75
76 case 2:
77 /* First n x 2 block */
78 _transp(d, 0, 2, n, mask);
79 _transp(d, 1, 3, n, mask);
80 /* Second n x 2 block */
81 _transp(d, 4, 6, n, mask);
82 _transp(d, 5, 7, n, mask);
83 return;
84
85 case 4:
86 /* Single n x 4 block */
87 _transp(d, 0, 4, n, mask);
88 _transp(d, 1, 5, n, mask);
89 _transp(d, 2, 6, n, mask);
90 _transp(d, 3, 7, n, mask);
91 return;
92 }
93
94 c2p_unsupported();
95}
96
97
98 /*
99 * Transpose operations on 4 32-bit words
100 */
101
102static inline void transp4(u32 d[], unsigned int n, unsigned int m)
103{
104 u32 mask = get_mask(n);
105
106 switch (m) {
107 case 1:
108 /* First n x 1 block */
109 _transp(d, 0, 1, n, mask);
110 /* Second n x 1 block */
111 _transp(d, 2, 3, n, mask);
112 return;
113
114 case 2:
115 /* Single n x 2 block */
116 _transp(d, 0, 2, n, mask);
117 _transp(d, 1, 3, n, mask);
118 return;
119 }
120
121 c2p_unsupported();
122}
123
124
125 /*
126 * Transpose operations on 4 32-bit words (reverse order)
127 */
128
129static inline void transp4x(u32 d[], unsigned int n, unsigned int m)
130{
131 u32 mask = get_mask(n);
132
133 switch (m) {
134 case 2:
135 /* Single n x 2 block */
136 _transp(d, 2, 0, n, mask);
137 _transp(d, 3, 1, n, mask);
138 return;
139 }
140
141 c2p_unsupported();
142}
143
144
145 /*
146 * Compose two values, using a bitmask as decision value
147 * This is equivalent to (a & mask) | (b & ~mask)
148 */
149
150static inline u32 comp(u32 a, u32 b, u32 mask)
151{
152 return ((a ^ b) & mask) ^ b;
153}
diff --git a/drivers/video/c2p_iplan2.c b/drivers/video/c2p_iplan2.c
new file mode 100644
index 000000000000..19156dc6158c
--- /dev/null
+++ b/drivers/video/c2p_iplan2.c
@@ -0,0 +1,153 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/string.h>
13
14#include <asm/unaligned.h>
15
16#include "c2p.h"
17#include "c2p_core.h"
18
19
20 /*
21 * Perform a full C2P step on 16 8-bit pixels, stored in 4 32-bit words
22 * containing
23 * - 16 8-bit chunky pixels on input
24 * - permutated planar data (2 planes per 32-bit word) on output
25 */
26
27static void c2p_16x8(u32 d[4])
28{
29 transp4(d, 8, 2);
30 transp4(d, 1, 2);
31 transp4x(d, 16, 2);
32 transp4x(d, 2, 2);
33 transp4(d, 4, 1);
34}
35
36
37 /*
38 * Array containing the permutation indices of the planar data after c2p
39 */
40
41static const int perm_c2p_16x8[4] = { 1, 3, 0, 2 };
42
43
44 /*
45 * Store a full block of iplan2 data after c2p conversion
46 */
47
48static inline void store_iplan2(void *dst, u32 bpp, u32 d[4])
49{
50 int i;
51
52 for (i = 0; i < bpp/2; i++, dst += 4)
53 put_unaligned_be32(d[perm_c2p_16x8[i]], dst);
54}
55
56
57 /*
58 * Store a partial block of iplan2 data after c2p conversion
59 */
60
61static inline void store_iplan2_masked(void *dst, u32 bpp, u32 d[4], u32 mask)
62{
63 int i;
64
65 for (i = 0; i < bpp/2; i++, dst += 4)
66 put_unaligned_be32(comp(d[perm_c2p_16x8[i]],
67 get_unaligned_be32(dst), mask),
68 dst);
69}
70
71
72 /*
73 * c2p_iplan2 - Copy 8-bit chunky image data to an interleaved planar
74 * frame buffer with 2 bytes of interleave
75 * @dst: Starting address of the planar frame buffer
76 * @dx: Horizontal destination offset (in pixels)
77 * @dy: Vertical destination offset (in pixels)
78 * @width: Image width (in pixels)
79 * @height: Image height (in pixels)
80 * @dst_nextline: Frame buffer offset to the next line (in bytes)
81 * @src_nextline: Image offset to the next line (in bytes)
82 * @bpp: Bits per pixel of the planar frame buffer (2, 4, or 8)
83 */
84
85void c2p_iplan2(void *dst, const void *src, u32 dx, u32 dy, u32 width,
86 u32 height, u32 dst_nextline, u32 src_nextline, u32 bpp)
87{
88 union {
89 u8 pixels[16];
90 u32 words[4];
91 } d;
92 u32 dst_idx, first, last, w;
93 const u8 *c;
94 void *p;
95
96 dst += dy*dst_nextline+(dx & ~15)*bpp;
97 dst_idx = dx % 16;
98 first = 0xffffU >> dst_idx;
99 first |= first << 16;
100 last = 0xffffU ^ (0xffffU >> ((dst_idx+width) % 16));
101 last |= last << 16;
102 while (height--) {
103 c = src;
104 p = dst;
105 w = width;
106 if (dst_idx+width <= 16) {
107 /* Single destination word */
108 first &= last;
109 memset(d.pixels, 0, sizeof(d));
110 memcpy(d.pixels+dst_idx, c, width);
111 c += width;
112 c2p_16x8(d.words);
113 store_iplan2_masked(p, bpp, d.words, first);
114 p += bpp*2;
115 } else {
116 /* Multiple destination words */
117 w = width;
118 /* Leading bits */
119 if (dst_idx) {
120 w = 16 - dst_idx;
121 memset(d.pixels, 0, dst_idx);
122 memcpy(d.pixels+dst_idx, c, w);
123 c += w;
124 c2p_16x8(d.words);
125 store_iplan2_masked(p, bpp, d.words, first);
126 p += bpp*2;
127 w = width-w;
128 }
129 /* Main chunk */
130 while (w >= 16) {
131 memcpy(d.pixels, c, 16);
132 c += 16;
133 c2p_16x8(d.words);
134 store_iplan2(p, bpp, d.words);
135 p += bpp*2;
136 w -= 16;
137 }
138 /* Trailing bits */
139 w %= 16;
140 if (w > 0) {
141 memcpy(d.pixels, c, w);
142 memset(d.pixels+w, 0, 16-w);
143 c2p_16x8(d.words);
144 store_iplan2_masked(p, bpp, d.words, last);
145 }
146 }
147 src += src_nextline;
148 dst += dst_nextline;
149 }
150}
151EXPORT_SYMBOL_GPL(c2p_iplan2);
152
153MODULE_LICENSE("GPL");
diff --git a/drivers/video/c2p_planar.c b/drivers/video/c2p_planar.c
new file mode 100644
index 000000000000..ec7ac8526f06
--- /dev/null
+++ b/drivers/video/c2p_planar.c
@@ -0,0 +1,156 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/string.h>
13
14#include <asm/unaligned.h>
15
16#include "c2p.h"
17#include "c2p_core.h"
18
19
20 /*
21 * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words
22 * containing
23 * - 32 8-bit chunky pixels on input
24 * - permutated planar data (1 plane per 32-bit word) on output
25 */
26
27static void c2p_32x8(u32 d[8])
28{
29 transp8(d, 16, 4);
30 transp8(d, 8, 2);
31 transp8(d, 4, 1);
32 transp8(d, 2, 4);
33 transp8(d, 1, 2);
34}
35
36
37 /*
38 * Array containing the permutation indices of the planar data after c2p
39 */
40
41static const int perm_c2p_32x8[8] = { 7, 5, 3, 1, 6, 4, 2, 0 };
42
43
44 /*
45 * Store a full block of planar data after c2p conversion
46 */
47
48static inline void store_planar(void *dst, u32 dst_inc, u32 bpp, u32 d[8])
49{
50 int i;
51
52 for (i = 0; i < bpp; i++, dst += dst_inc)
53 put_unaligned_be32(d[perm_c2p_32x8[i]], dst);
54}
55
56
57 /*
58 * Store a partial block of planar data after c2p conversion
59 */
60
61static inline void store_planar_masked(void *dst, u32 dst_inc, u32 bpp,
62 u32 d[8], u32 mask)
63{
64 int i;
65
66 for (i = 0; i < bpp; i++, dst += dst_inc)
67 put_unaligned_be32(comp(d[perm_c2p_32x8[i]],
68 get_unaligned_be32(dst), mask),
69 dst);
70}
71
72
73 /*
74 * c2p_planar - Copy 8-bit chunky image data to a planar frame buffer
75 * @dst: Starting address of the planar frame buffer
76 * @dx: Horizontal destination offset (in pixels)
77 * @dy: Vertical destination offset (in pixels)
78 * @width: Image width (in pixels)
79 * @height: Image height (in pixels)
80 * @dst_nextline: Frame buffer offset to the next line (in bytes)
81 * @dst_nextplane: Frame buffer offset to the next plane (in bytes)
82 * @src_nextline: Image offset to the next line (in bytes)
83 * @bpp: Bits per pixel of the planar frame buffer (1-8)
84 */
85
86void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width,
87 u32 height, u32 dst_nextline, u32 dst_nextplane,
88 u32 src_nextline, u32 bpp)
89{
90 union {
91 u8 pixels[32];
92 u32 words[8];
93 } d;
94 u32 dst_idx, first, last, w;
95 const u8 *c;
96 void *p;
97
98 dst += dy*dst_nextline+(dx & ~31);
99 dst_idx = dx % 32;
100 first = 0xffffffffU >> dst_idx;
101 last = ~(0xffffffffU >> ((dst_idx+width) % 32));
102 while (height--) {
103 c = src;
104 p = dst;
105 w = width;
106 if (dst_idx+width <= 32) {
107 /* Single destination word */
108 first &= last;
109 memset(d.pixels, 0, sizeof(d));
110 memcpy(d.pixels+dst_idx, c, width);
111 c += width;
112 c2p_32x8(d.words);
113 store_planar_masked(p, dst_nextplane, bpp, d.words,
114 first);
115 p += 4;
116 } else {
117 /* Multiple destination words */
118 w = width;
119 /* Leading bits */
120 if (dst_idx) {
121 w = 32 - dst_idx;
122 memset(d.pixels, 0, dst_idx);
123 memcpy(d.pixels+dst_idx, c, w);
124 c += w;
125 c2p_32x8(d.words);
126 store_planar_masked(p, dst_nextplane, bpp,
127 d.words, first);
128 p += 4;
129 w = width-w;
130 }
131 /* Main chunk */
132 while (w >= 32) {
133 memcpy(d.pixels, c, 32);
134 c += 32;
135 c2p_32x8(d.words);
136 store_planar(p, dst_nextplane, bpp, d.words);
137 p += 4;
138 w -= 32;
139 }
140 /* Trailing bits */
141 w %= 32;
142 if (w > 0) {
143 memcpy(d.pixels, c, w);
144 memset(d.pixels+w, 0, 32-w);
145 c2p_32x8(d.words);
146 store_planar_masked(p, dst_nextplane, bpp,
147 d.words, last);
148 }
149 }
150 src += src_nextline;
151 dst += dst_nextline;
152 }
153}
154EXPORT_SYMBOL_GPL(c2p_planar);
155
156MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 4bcff81b50e0..1657b9608b04 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -78,13 +78,6 @@
78#include <asm/fb.h> 78#include <asm/fb.h>
79#include <asm/irq.h> 79#include <asm/irq.h>
80#include <asm/system.h> 80#include <asm/system.h>
81#ifdef CONFIG_ATARI
82#include <asm/atariints.h>
83#endif
84#if defined(__mc68000__)
85#include <asm/machdep.h>
86#include <asm/setup.h>
87#endif
88 81
89#include "fbcon.h" 82#include "fbcon.h"
90 83
@@ -155,9 +148,6 @@ static int fbcon_set_origin(struct vc_data *);
155 148
156#define CURSOR_DRAW_DELAY (1) 149#define CURSOR_DRAW_DELAY (1)
157 150
158/* # VBL ints between cursor state changes */
159#define ATARI_CURSOR_BLINK_RATE (42)
160
161static int vbl_cursor_cnt; 151static int vbl_cursor_cnt;
162static int fbcon_cursor_noblink; 152static int fbcon_cursor_noblink;
163 153
@@ -403,20 +393,6 @@ static void fb_flashcursor(struct work_struct *work)
403 release_console_sem(); 393 release_console_sem();
404} 394}
405 395
406#ifdef CONFIG_ATARI
407static int cursor_blink_rate;
408static irqreturn_t fb_vbl_handler(int irq, void *dev_id)
409{
410 struct fb_info *info = dev_id;
411
412 if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) {
413 schedule_work(&info->queue);
414 vbl_cursor_cnt = cursor_blink_rate;
415 }
416 return IRQ_HANDLED;
417}
418#endif
419
420static void cursor_timer_handler(unsigned long dev_addr) 396static void cursor_timer_handler(unsigned long dev_addr)
421{ 397{
422 struct fb_info *info = (struct fb_info *) dev_addr; 398 struct fb_info *info = (struct fb_info *) dev_addr;
@@ -1017,15 +993,6 @@ static const char *fbcon_startup(void)
1017 info->var.yres, 993 info->var.yres,
1018 info->var.bits_per_pixel); 994 info->var.bits_per_pixel);
1019 995
1020#ifdef CONFIG_ATARI
1021 if (MACH_IS_ATARI) {
1022 cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
1023 (void)request_irq(IRQ_AUTO_4, fb_vbl_handler,
1024 IRQ_TYPE_PRIO, "framebuffer vbl",
1025 info);
1026 }
1027#endif /* CONFIG_ATARI */
1028
1029 fbcon_add_cursor_timer(info); 996 fbcon_add_cursor_timer(info);
1030 fbcon_has_exited = 0; 997 fbcon_has_exited = 0;
1031 return display_desc; 998 return display_desc;
@@ -3454,11 +3421,6 @@ static void fbcon_exit(void)
3454 if (fbcon_has_exited) 3421 if (fbcon_has_exited)
3455 return; 3422 return;
3456 3423
3457#ifdef CONFIG_ATARI
3458 if (MACH_IS_ATARI)
3459 free_irq(IRQ_AUTO_4, fb_vbl_handler);
3460#endif
3461
3462 kfree((void *)softback_buf); 3424 kfree((void *)softback_buf);
3463 softback_buf = 0UL; 3425 softback_buf = 0UL;
3464 3426
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 38ac805db97d..87f826e4c958 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -1006,7 +1006,7 @@ static int ps3fb_xdr_settings(u64 xdr_lpar, struct device *dev)
1006 __func__, status); 1006 __func__, status);
1007 return -ENXIO; 1007 return -ENXIO;
1008 } 1008 }
1009 dev_dbg(dev, "video:%p ioif:%lx lpar:%lx size:%lx\n", 1009 dev_dbg(dev, "video:%p ioif:%lx lpar:%llx size:%lx\n",
1010 ps3fb_videomemory.address, GPU_IOIF, xdr_lpar, 1010 ps3fb_videomemory.address, GPU_IOIF, xdr_lpar,
1011 ps3fb_videomemory.size); 1011 ps3fb_videomemory.size);
1012 1012
@@ -1133,7 +1133,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1133 __func__, status); 1133 __func__, status);
1134 goto err; 1134 goto err;
1135 } 1135 }
1136 dev_dbg(&dev->core, "ddr:lpar:0x%lx\n", ddr_lpar); 1136 dev_dbg(&dev->core, "ddr:lpar:0x%llx\n", ddr_lpar);
1137 1137
1138 status = lv1_gpu_context_allocate(ps3fb.memory_handle, 0, 1138 status = lv1_gpu_context_allocate(ps3fb.memory_handle, 0,
1139 &ps3fb.context_handle, 1139 &ps3fb.context_handle,
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ec68c741b564..3efa12f9ee50 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -770,6 +770,12 @@ config TXX9_WDT
770 770
771# POWERPC Architecture 771# POWERPC Architecture
772 772
773config GEF_WDT
774 tristate "GE Fanuc Watchdog Timer"
775 depends on GEF_SBC610
776 ---help---
777 Watchdog timer found in a number of GE Fanuc single board computers.
778
773config MPC5200_WDT 779config MPC5200_WDT
774 tristate "MPC5200 Watchdog Timer" 780 tristate "MPC5200 Watchdog Timer"
775 depends on PPC_MPC52xx 781 depends on PPC_MPC52xx
@@ -790,6 +796,14 @@ config MV64X60_WDT
790 tristate "MV64X60 (Marvell Discovery) Watchdog Timer" 796 tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
791 depends on MV64X60 797 depends on MV64X60
792 798
799config PIKA_WDT
800 tristate "PIKA FPGA Watchdog"
801 depends on WARP
802 default y
803 help
804 This enables the watchdog in the PIKA FPGA. Currently used on
805 the Warp platform.
806
793config BOOKE_WDT 807config BOOKE_WDT
794 bool "PowerPC Book-E Watchdog Timer" 808 bool "PowerPC Book-E Watchdog Timer"
795 depends on BOOKE || 4xx 809 depends on BOOKE || 4xx
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index c19b866f5ed1..806b3eb08536 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -111,9 +111,11 @@ obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
111# PARISC Architecture 111# PARISC Architecture
112 112
113# POWERPC Architecture 113# POWERPC Architecture
114obj-$(CONFIG_GEF_WDT) += gef_wdt.o
114obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o 115obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o
115obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o 116obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
116obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o 117obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
118obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
117obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o 119obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
118 120
119# PPC64 Architecture 121# PPC64 Architecture
diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c
new file mode 100644
index 000000000000..f0c2b7a1a175
--- /dev/null
+++ b/drivers/watchdog/gef_wdt.c
@@ -0,0 +1,330 @@
1/*
2 * GE Fanuc watchdog userspace interface
3 *
4 * Author: Martyn Welch <martyn.welch@gefanuc.com>
5 *
6 * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Based on: mv64x60_wdt.c (MV64X60 watchdog userspace interface)
14 * Author: James Chapman <jchapman@katalix.com>
15 */
16
17/* TODO:
18 * This driver does not provide support for the hardwares capability of sending
19 * an interrupt at a programmable threshold.
20 *
21 * This driver currently can only support 1 watchdog - there are 2 in the
22 * hardware that this driver supports. Thus one could be configured as a
23 * process-based watchdog (via /dev/watchdog), the second (using the interrupt
24 * capabilities) a kernel-based watchdog.
25 */
26
27#include <linux/kernel.h>
28#include <linux/compiler.h>
29#include <linux/init.h>
30#include <linux/module.h>
31#include <linux/miscdevice.h>
32#include <linux/watchdog.h>
33#include <linux/of.h>
34#include <linux/of_platform.h>
35#include <linux/io.h>
36#include <linux/uaccess.h>
37
38#include <sysdev/fsl_soc.h>
39
40/*
41 * The watchdog configuration register contains a pair of 2-bit fields,
42 * 1. a reload field, bits 27-26, which triggers a reload of
43 * the countdown register, and
44 * 2. an enable field, bits 25-24, which toggles between
45 * enabling and disabling the watchdog timer.
46 * Bit 31 is a read-only field which indicates whether the
47 * watchdog timer is currently enabled.
48 *
49 * The low 24 bits contain the timer reload value.
50 */
51#define GEF_WDC_ENABLE_SHIFT 24
52#define GEF_WDC_SERVICE_SHIFT 26
53#define GEF_WDC_ENABLED_SHIFT 31
54
55#define GEF_WDC_ENABLED_TRUE 1
56#define GEF_WDC_ENABLED_FALSE 0
57
58/* Flags bits */
59#define GEF_WDOG_FLAG_OPENED 0
60
61static unsigned long wdt_flags;
62static int wdt_status;
63static void __iomem *gef_wdt_regs;
64static int gef_wdt_timeout;
65static int gef_wdt_count;
66static unsigned int bus_clk;
67static char expect_close;
68static DEFINE_SPINLOCK(gef_wdt_spinlock);
69
70static int nowayout = WATCHDOG_NOWAYOUT;
71module_param(nowayout, int, 0);
72MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
73 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
74
75
76static int gef_wdt_toggle_wdc(int enabled_predicate, int field_shift)
77{
78 u32 data;
79 u32 enabled;
80 int ret = 0;
81
82 spin_lock(&gef_wdt_spinlock);
83 data = ioread32be(gef_wdt_regs);
84 enabled = (data >> GEF_WDC_ENABLED_SHIFT) & 1;
85
86 /* only toggle the requested field if enabled state matches predicate */
87 if ((enabled ^ enabled_predicate) == 0) {
88 /* We write a 1, then a 2 -- to the appropriate field */
89 data = (1 << field_shift) | gef_wdt_count;
90 iowrite32be(data, gef_wdt_regs);
91
92 data = (2 << field_shift) | gef_wdt_count;
93 iowrite32be(data, gef_wdt_regs);
94 ret = 1;
95 }
96 spin_unlock(&gef_wdt_spinlock);
97
98 return ret;
99}
100
101static void gef_wdt_service(void)
102{
103 gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE,
104 GEF_WDC_SERVICE_SHIFT);
105}
106
107static void gef_wdt_handler_enable(void)
108{
109 if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_FALSE,
110 GEF_WDC_ENABLE_SHIFT)) {
111 gef_wdt_service();
112 printk(KERN_NOTICE "gef_wdt: watchdog activated\n");
113 }
114}
115
116static void gef_wdt_handler_disable(void)
117{
118 if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE,
119 GEF_WDC_ENABLE_SHIFT))
120 printk(KERN_NOTICE "gef_wdt: watchdog deactivated\n");
121}
122
123static void gef_wdt_set_timeout(unsigned int timeout)
124{
125 /* maximum bus cycle count is 0xFFFFFFFF */
126 if (timeout > 0xFFFFFFFF / bus_clk)
127 timeout = 0xFFFFFFFF / bus_clk;
128
129 /* Register only holds upper 24 bits, bit shifted into lower 24 */
130 gef_wdt_count = (timeout * bus_clk) >> 8;
131 gef_wdt_timeout = timeout;
132}
133
134
135static ssize_t gef_wdt_write(struct file *file, const char __user *data,
136 size_t len, loff_t *ppos)
137{
138 if (len) {
139 if (!nowayout) {
140 size_t i;
141
142 expect_close = 0;
143
144 for (i = 0; i != len; i++) {
145 char c;
146 if (get_user(c, data + i))
147 return -EFAULT;
148 if (c == 'V')
149 expect_close = 42;
150 }
151 }
152 gef_wdt_service();
153 }
154
155 return len;
156}
157
158static long gef_wdt_ioctl(struct file *file, unsigned int cmd,
159 unsigned long arg)
160{
161 int timeout;
162 int options;
163 void __user *argp = (void __user *)arg;
164 static struct watchdog_info info = {
165 .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE |
166 WDIOF_KEEPALIVEPING,
167 .firmware_version = 0,
168 .identity = "GE Fanuc watchdog",
169 };
170
171 switch (cmd) {
172 case WDIOC_GETSUPPORT:
173 if (copy_to_user(argp, &info, sizeof(info)))
174 return -EFAULT;
175 break;
176
177 case WDIOC_GETSTATUS:
178 case WDIOC_GETBOOTSTATUS:
179 if (put_user(wdt_status, (int __user *)argp))
180 return -EFAULT;
181 wdt_status &= ~WDIOF_KEEPALIVEPING;
182 break;
183
184 case WDIOC_SETOPTIONS:
185 if (get_user(options, (int __user *)argp))
186 return -EFAULT;
187
188 if (options & WDIOS_DISABLECARD)
189 gef_wdt_handler_disable();
190
191 if (options & WDIOS_ENABLECARD)
192 gef_wdt_handler_enable();
193 break;
194
195 case WDIOC_KEEPALIVE:
196 gef_wdt_service();
197 wdt_status |= WDIOF_KEEPALIVEPING;
198 break;
199
200 case WDIOC_SETTIMEOUT:
201 if (get_user(timeout, (int __user *)argp))
202 return -EFAULT;
203 gef_wdt_set_timeout(timeout);
204 /* Fall through */
205
206 case WDIOC_GETTIMEOUT:
207 if (put_user(gef_wdt_timeout, (int __user *)argp))
208 return -EFAULT;
209 break;
210
211 default:
212 return -ENOTTY;
213 }
214
215 return 0;
216}
217
218static int gef_wdt_open(struct inode *inode, struct file *file)
219{
220 if (test_and_set_bit(GEF_WDOG_FLAG_OPENED, &wdt_flags))
221 return -EBUSY;
222
223 if (nowayout)
224 __module_get(THIS_MODULE);
225
226 gef_wdt_handler_enable();
227
228 return nonseekable_open(inode, file);
229}
230
231static int gef_wdt_release(struct inode *inode, struct file *file)
232{
233 if (expect_close == 42)
234 gef_wdt_handler_disable();
235 else {
236 printk(KERN_CRIT
237 "gef_wdt: unexpected close, not stopping timer!\n");
238 gef_wdt_service();
239 }
240 expect_close = 0;
241
242 clear_bit(GEF_WDOG_FLAG_OPENED, &wdt_flags);
243
244 return 0;
245}
246
247static const struct file_operations gef_wdt_fops = {
248 .owner = THIS_MODULE,
249 .llseek = no_llseek,
250 .write = gef_wdt_write,
251 .unlocked_ioctl = gef_wdt_ioctl,
252 .open = gef_wdt_open,
253 .release = gef_wdt_release,
254};
255
256static struct miscdevice gef_wdt_miscdev = {
257 .minor = WATCHDOG_MINOR,
258 .name = "watchdog",
259 .fops = &gef_wdt_fops,
260};
261
262
263static int __devinit gef_wdt_probe(struct of_device *dev,
264 const struct of_device_id *match)
265{
266 int timeout = 10;
267 u32 freq;
268
269 bus_clk = 133; /* in MHz */
270
271 freq = fsl_get_sys_freq();
272 if (freq > 0)
273 bus_clk = freq;
274
275 /* Map devices registers into memory */
276 gef_wdt_regs = of_iomap(dev->node, 0);
277 if (gef_wdt_regs == NULL)
278 return -ENOMEM;
279
280 gef_wdt_set_timeout(timeout);
281
282 gef_wdt_handler_disable(); /* in case timer was already running */
283
284 return misc_register(&gef_wdt_miscdev);
285}
286
287static int __devexit gef_wdt_remove(struct platform_device *dev)
288{
289 misc_deregister(&gef_wdt_miscdev);
290
291 gef_wdt_handler_disable();
292
293 iounmap(gef_wdt_regs);
294
295 return 0;
296}
297
298static const struct of_device_id gef_wdt_ids[] = {
299 {
300 .compatible = "gef,fpga-wdt",
301 },
302 {},
303};
304
305static struct of_platform_driver gef_wdt_driver = {
306 .owner = THIS_MODULE,
307 .name = "gef_wdt",
308 .match_table = gef_wdt_ids,
309 .probe = gef_wdt_probe,
310};
311
312static int __init gef_wdt_init(void)
313{
314 printk(KERN_INFO "GE Fanuc watchdog driver\n");
315 return of_register_platform_driver(&gef_wdt_driver);
316}
317
318static void __exit gef_wdt_exit(void)
319{
320 of_unregister_platform_driver(&gef_wdt_driver);
321}
322
323module_init(gef_wdt_init);
324module_exit(gef_wdt_exit);
325
326MODULE_AUTHOR("Martyn Welch <martyn.welch@gefanuc.com>");
327MODULE_DESCRIPTION("GE Fanuc watchdog driver");
328MODULE_LICENSE("GPL");
329MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
330MODULE_ALIAS("platform: gef_wdt");
diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
new file mode 100644
index 000000000000..2d22e996e996
--- /dev/null
+++ b/drivers/watchdog/pika_wdt.c
@@ -0,0 +1,301 @@
1/*
2 * PIKA FPGA based Watchdog Timer
3 *
4 * Copyright (c) 2008 PIKA Technologies
5 * Sean MacLennan <smaclennan@pikatech.com>
6 */
7
8#include <linux/init.h>
9#include <linux/errno.h>
10#include <linux/module.h>
11#include <linux/moduleparam.h>
12#include <linux/types.h>
13#include <linux/kernel.h>
14#include <linux/fs.h>
15#include <linux/miscdevice.h>
16#include <linux/watchdog.h>
17#include <linux/reboot.h>
18#include <linux/jiffies.h>
19#include <linux/timer.h>
20#include <linux/bitops.h>
21#include <linux/uaccess.h>
22#include <linux/io.h>
23#include <linux/of_platform.h>
24
25#define DRV_NAME "PIKA-WDT"
26#define PFX DRV_NAME ": "
27
28/* Hardware timeout in seconds */
29#define WDT_HW_TIMEOUT 2
30
31/* Timer heartbeat (500ms) */
32#define WDT_TIMEOUT (HZ/2)
33
34/* User land timeout */
35#define WDT_HEARTBEAT 15
36static int heartbeat = WDT_HEARTBEAT;
37module_param(heartbeat, int, 0);
38MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. "
39 "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")");
40
41static int nowayout = WATCHDOG_NOWAYOUT;
42module_param(nowayout, int, 0);
43MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
44 "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
45
46static struct {
47 void __iomem *fpga;
48 unsigned long next_heartbeat; /* the next_heartbeat for the timer */
49 unsigned long open;
50 char expect_close;
51 int bootstatus;
52 struct timer_list timer; /* The timer that pings the watchdog */
53} pikawdt_private;
54
55static struct watchdog_info ident = {
56 .identity = DRV_NAME,
57 .options = WDIOF_CARDRESET |
58 WDIOF_SETTIMEOUT |
59 WDIOF_KEEPALIVEPING |
60 WDIOF_MAGICCLOSE,
61};
62
63/*
64 * Reload the watchdog timer. (ie, pat the watchdog)
65 */
66static inline void pikawdt_reset(void)
67{
68 /* -- FPGA: Reset Control Register (32bit R/W) (Offset: 0x14) --
69 * Bit 7, WTCHDG_EN: When set to 1, the watchdog timer is enabled.
70 * Once enabled, it cannot be disabled. The watchdog can be
71 * kicked by performing any write access to the reset
72 * control register (this register).
73 * Bit 8-11, WTCHDG_TIMEOUT_SEC: Sets the watchdog timeout value in
74 * seconds. Valid ranges are 1 to 15 seconds. The value can
75 * be modified dynamically.
76 */
77 unsigned reset = in_be32(pikawdt_private.fpga + 0x14);
78 /* enable with max timeout - 15 seconds */
79 reset |= (1 << 7) + (WDT_HW_TIMEOUT << 8);
80 out_be32(pikawdt_private.fpga + 0x14, reset);
81}
82
83/*
84 * Timer tick
85 */
86static void pikawdt_ping(unsigned long data)
87{
88 if (time_before(jiffies, pikawdt_private.next_heartbeat) ||
89 (!nowayout && !pikawdt_private.open)) {
90 pikawdt_reset();
91 mod_timer(&pikawdt_private.timer, jiffies + WDT_TIMEOUT);
92 } else
93 printk(KERN_CRIT PFX "I will reset your machine !\n");
94}
95
96
97static void pikawdt_keepalive(void)
98{
99 pikawdt_private.next_heartbeat = jiffies + heartbeat * HZ;
100}
101
102static void pikawdt_start(void)
103{
104 pikawdt_keepalive();
105 mod_timer(&pikawdt_private.timer, jiffies + WDT_TIMEOUT);
106}
107
108/*
109 * Watchdog device is opened, and watchdog starts running.
110 */
111static int pikawdt_open(struct inode *inode, struct file *file)
112{
113 /* /dev/watchdog can only be opened once */
114 if (test_and_set_bit(0, &pikawdt_private.open))
115 return -EBUSY;
116
117 pikawdt_start();
118
119 return nonseekable_open(inode, file);
120}
121
122/*
123 * Close the watchdog device.
124 */
125static int pikawdt_release(struct inode *inode, struct file *file)
126{
127 /* stop internal ping */
128 if (!pikawdt_private.expect_close)
129 del_timer(&pikawdt_private.timer);
130
131 clear_bit(0, &pikawdt_private.open);
132 pikawdt_private.expect_close = 0;
133 return 0;
134}
135
136/*
137 * Pat the watchdog whenever device is written to.
138 */
139static ssize_t pikawdt_write(struct file *file, const char __user *data,
140 size_t len, loff_t *ppos)
141{
142 if (!len)
143 return 0;
144
145 /* Scan for magic character */
146 if (!nowayout) {
147 size_t i;
148
149 pikawdt_private.expect_close = 0;
150
151 for (i = 0; i < len; i++) {
152 char c;
153 if (get_user(c, data + i))
154 return -EFAULT;
155 if (c == 'V') {
156 pikawdt_private.expect_close = 42;
157 break;
158 }
159 }
160 }
161
162 pikawdt_keepalive();
163
164 return len;
165}
166
167/*
168 * Handle commands from user-space.
169 */
170static long pikawdt_ioctl(struct file *file,
171 unsigned int cmd, unsigned long arg)
172{
173 void __user *argp = (void __user *)arg;
174 int __user *p = argp;
175 int new_value;
176
177 switch (cmd) {
178 case WDIOC_GETSUPPORT:
179 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
180
181 case WDIOC_GETSTATUS:
182 return put_user(0, p);
183
184 case WDIOC_GETBOOTSTATUS:
185 return put_user(pikawdt_private.bootstatus, p);
186
187 case WDIOC_KEEPALIVE:
188 pikawdt_keepalive();
189 return 0;
190
191 case WDIOC_SETTIMEOUT:
192 if (get_user(new_value, p))
193 return -EFAULT;
194
195 heartbeat = new_value;
196 pikawdt_keepalive();
197
198 return put_user(new_value, p); /* return current value */
199
200 case WDIOC_GETTIMEOUT:
201 return put_user(heartbeat, p);
202 }
203 return -ENOTTY;
204}
205
206
207static const struct file_operations pikawdt_fops = {
208 .owner = THIS_MODULE,
209 .llseek = no_llseek,
210 .open = pikawdt_open,
211 .release = pikawdt_release,
212 .write = pikawdt_write,
213 .unlocked_ioctl = pikawdt_ioctl,
214};
215
216static struct miscdevice pikawdt_miscdev = {
217 .minor = WATCHDOG_MINOR,
218 .name = "watchdog",
219 .fops = &pikawdt_fops,
220};
221
222static int __init pikawdt_init(void)
223{
224 struct device_node *np;
225 void __iomem *fpga;
226 static u32 post1;
227 int ret;
228
229 np = of_find_compatible_node(NULL, NULL, "pika,fpga");
230 if (np == NULL) {
231 printk(KERN_ERR PFX "Unable to find fpga.\n");
232 return -ENOENT;
233 }
234
235 pikawdt_private.fpga = of_iomap(np, 0);
236 of_node_put(np);
237 if (pikawdt_private.fpga == NULL) {
238 printk(KERN_ERR PFX "Unable to map fpga.\n");
239 return -ENOMEM;
240 }
241
242 ident.firmware_version = in_be32(pikawdt_private.fpga + 0x1c) & 0xffff;
243
244 /* POST information is in the sd area. */
245 np = of_find_compatible_node(NULL, NULL, "pika,fpga-sd");
246 if (np == NULL) {
247 printk(KERN_ERR PFX "Unable to find fpga-sd.\n");
248 ret = -ENOENT;
249 goto out;
250 }
251
252 fpga = of_iomap(np, 0);
253 of_node_put(np);
254 if (fpga == NULL) {
255 printk(KERN_ERR PFX "Unable to map fpga-sd.\n");
256 ret = -ENOMEM;
257 goto out;
258 }
259
260 /* -- FPGA: POST Test Results Register 1 (32bit R/W) (Offset: 0x4040) --
261 * Bit 31, WDOG: Set to 1 when the last reset was caused by a watchdog
262 * timeout.
263 */
264 post1 = in_be32(fpga + 0x40);
265 if (post1 & 0x80000000)
266 pikawdt_private.bootstatus = WDIOF_CARDRESET;
267
268 iounmap(fpga);
269
270 setup_timer(&pikawdt_private.timer, pikawdt_ping, 0);
271
272 ret = misc_register(&pikawdt_miscdev);
273 if (ret) {
274 printk(KERN_ERR PFX "Unable to register miscdev.\n");
275 goto out;
276 }
277
278 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
279 heartbeat, nowayout);
280 return 0;
281
282out:
283 iounmap(pikawdt_private.fpga);
284 return ret;
285}
286
287static void __exit pikawdt_exit(void)
288{
289 misc_deregister(&pikawdt_miscdev);
290
291 iounmap(pikawdt_private.fpga);
292}
293
294module_init(pikawdt_init);
295module_exit(pikawdt_exit);
296
297MODULE_AUTHOR("Sean MacLennan <smaclennan@pikatech.com>");
298MODULE_DESCRIPTION("PIKA FPGA based Watchdog Timer");
299MODULE_LICENSE("GPL");
300MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
301
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
index 2bc0d4d4b415..a2d2e8eb2282 100644
--- a/drivers/watchdog/wm8350_wdt.c
+++ b/drivers/watchdog/wm8350_wdt.c
@@ -279,7 +279,7 @@ static struct miscdevice wm8350_wdt_miscdev = {
279 .fops = &wm8350_wdt_fops, 279 .fops = &wm8350_wdt_fops,
280}; 280};
281 281
282static int wm8350_wdt_probe(struct platform_device *pdev) 282static int __devinit wm8350_wdt_probe(struct platform_device *pdev)
283{ 283{
284 struct wm8350 *wm8350 = platform_get_drvdata(pdev); 284 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
285 285
@@ -296,7 +296,7 @@ static int wm8350_wdt_probe(struct platform_device *pdev)
296 return misc_register(&wm8350_wdt_miscdev); 296 return misc_register(&wm8350_wdt_miscdev);
297} 297}
298 298
299static int __exit wm8350_wdt_remove(struct platform_device *pdev) 299static int __devexit wm8350_wdt_remove(struct platform_device *pdev)
300{ 300{
301 misc_deregister(&wm8350_wdt_miscdev); 301 misc_deregister(&wm8350_wdt_miscdev);
302 302
@@ -305,7 +305,7 @@ static int __exit wm8350_wdt_remove(struct platform_device *pdev)
305 305
306static struct platform_driver wm8350_wdt_driver = { 306static struct platform_driver wm8350_wdt_driver = {
307 .probe = wm8350_wdt_probe, 307 .probe = wm8350_wdt_probe,
308 .remove = wm8350_wdt_remove, 308 .remove = __devexit_p(wm8350_wdt_remove),
309 .driver = { 309 .driver = {
310 .name = "wm8350-wdt", 310 .name = "wm8350-wdt",
311 }, 311 },
diff --git a/drivers/zorro/.gitignore b/drivers/zorro/.gitignore
new file mode 100644
index 000000000000..34f980bd8ff6
--- /dev/null
+++ b/drivers/zorro/.gitignore
@@ -0,0 +1,2 @@
1devlist.h
2gen-devlist
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index 5290552d2ef7..1d2a772ea14c 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -77,17 +77,21 @@ static struct bin_attribute zorro_config_attr = {
77 .read = zorro_read_config, 77 .read = zorro_read_config,
78}; 78};
79 79
80void zorro_create_sysfs_dev_files(struct zorro_dev *z) 80int zorro_create_sysfs_dev_files(struct zorro_dev *z)
81{ 81{
82 struct device *dev = &z->dev; 82 struct device *dev = &z->dev;
83 int error;
83 84
84 /* current configuration's attributes */ 85 /* current configuration's attributes */
85 device_create_file(dev, &dev_attr_id); 86 if ((error = device_create_file(dev, &dev_attr_id)) ||
86 device_create_file(dev, &dev_attr_type); 87 (error = device_create_file(dev, &dev_attr_type)) ||
87 device_create_file(dev, &dev_attr_serial); 88 (error = device_create_file(dev, &dev_attr_serial)) ||
88 device_create_file(dev, &dev_attr_slotaddr); 89 (error = device_create_file(dev, &dev_attr_slotaddr)) ||
89 device_create_file(dev, &dev_attr_slotsize); 90 (error = device_create_file(dev, &dev_attr_slotsize)) ||
90 device_create_file(dev, &dev_attr_resource); 91 (error = device_create_file(dev, &dev_attr_resource)) ||
91 sysfs_create_bin_file(&dev->kobj, &zorro_config_attr); 92 (error = sysfs_create_bin_file(&dev->kobj, &zorro_config_attr)))
93 return error;
94
95 return 0;
92} 96}
93 97
diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
index dff16d9767d8..a1585d6f6486 100644
--- a/drivers/zorro/zorro.c
+++ b/drivers/zorro/zorro.c
@@ -130,6 +130,7 @@ static int __init zorro_init(void)
130{ 130{
131 struct zorro_dev *z; 131 struct zorro_dev *z;
132 unsigned int i; 132 unsigned int i;
133 int error;
133 134
134 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) 135 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
135 return 0; 136 return 0;
@@ -140,7 +141,11 @@ static int __init zorro_init(void)
140 /* Initialize the Zorro bus */ 141 /* Initialize the Zorro bus */
141 INIT_LIST_HEAD(&zorro_bus.devices); 142 INIT_LIST_HEAD(&zorro_bus.devices);
142 strcpy(zorro_bus.dev.bus_id, "zorro"); 143 strcpy(zorro_bus.dev.bus_id, "zorro");
143 device_register(&zorro_bus.dev); 144 error = device_register(&zorro_bus.dev);
145 if (error) {
146 pr_err("Zorro: Error registering zorro_bus\n");
147 return error;
148 }
144 149
145 /* Request the resources */ 150 /* Request the resources */
146 zorro_bus.num_resources = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2; 151 zorro_bus.num_resources = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
@@ -160,15 +165,19 @@ static int __init zorro_init(void)
160 zorro_name_device(z); 165 zorro_name_device(z);
161 z->resource.name = z->name; 166 z->resource.name = z->name;
162 if (request_resource(zorro_find_parent_resource(z), &z->resource)) 167 if (request_resource(zorro_find_parent_resource(z), &z->resource))
163 printk(KERN_ERR "Zorro: Address space collision on device %s " 168 pr_err("Zorro: Address space collision on device %s %pR\n",
164 "[%lx:%lx]\n", 169 z->name, &z->resource);
165 z->name, (unsigned long)zorro_resource_start(z),
166 (unsigned long)zorro_resource_end(z));
167 sprintf(z->dev.bus_id, "%02x", i); 170 sprintf(z->dev.bus_id, "%02x", i);
168 z->dev.parent = &zorro_bus.dev; 171 z->dev.parent = &zorro_bus.dev;
169 z->dev.bus = &zorro_bus_type; 172 z->dev.bus = &zorro_bus_type;
170 device_register(&z->dev); 173 error = device_register(&z->dev);
171 zorro_create_sysfs_dev_files(z); 174 if (error) {
175 pr_err("Zorro: Error registering device %s\n", z->name);
176 continue;
177 }
178 error = zorro_create_sysfs_dev_files(z);
179 if (error)
180 dev_err(&z->dev, "Error creating sysfs files\n");
172 } 181 }
173 182
174 /* Mark all available Zorro II memory */ 183 /* Mark all available Zorro II memory */
diff --git a/drivers/zorro/zorro.h b/drivers/zorro/zorro.h
index 5c91adac4df1..b682d5ccd63f 100644
--- a/drivers/zorro/zorro.h
+++ b/drivers/zorro/zorro.h
@@ -1,4 +1,4 @@
1 1
2extern void zorro_name_device(struct zorro_dev *z); 2extern void zorro_name_device(struct zorro_dev *z);
3extern void zorro_create_sysfs_dev_files(struct zorro_dev *z); 3extern int zorro_create_sysfs_dev_files(struct zorro_dev *z);
4 4