aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ahci.c57
-rw-r--r--drivers/ata/libata-core.c4
-rw-r--r--drivers/ata/sata_via.c2
-rw-r--r--drivers/atm/solos-pci.c2
-rw-r--r--drivers/block/cciss.c2
-rw-r--r--drivers/char/agp/intel-agp.c3
-rw-r--r--drivers/char/sysrq.c1
-rw-r--r--drivers/edac/edac_core.h12
-rw-r--r--drivers/edac/edac_device.c2
-rw-r--r--drivers/edac/edac_mc.c2
-rw-r--r--drivers/edac/edac_pci.c2
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/hp_accel.c1
-rw-r--r--drivers/hwmon/sht15.c692
-rw-r--r--drivers/input/input.c13
-rw-r--r--drivers/input/keyboard/atkbd.c135
-rw-r--r--drivers/input/keyboard/bf54x-keys.c4
-rw-r--r--drivers/input/keyboard/hilkbd.c140
-rw-r--r--drivers/input/misc/Kconfig23
-rw-r--r--drivers/input/misc/Makefile28
-rw-r--r--drivers/input/misc/ati_remote2.c277
-rw-r--r--drivers/input/misc/rb532_button.c120
-rw-r--r--drivers/input/misc/rotary_encoder.c221
-rw-r--r--drivers/input/mouse/Kconfig11
-rw-r--r--drivers/input/mouse/Makefile9
-rw-r--r--drivers/input/mouse/hgpk.c2
-rw-r--r--drivers/input/mouse/maplemouse.c147
-rw-r--r--drivers/input/mouse/pc110pad.c5
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h8
-rw-r--r--drivers/input/touchscreen/Kconfig58
-rw-r--r--drivers/input/touchscreen/Makefile3
-rw-r--r--drivers/input/touchscreen/ad7877.c844
-rw-r--r--drivers/input/touchscreen/ad7879.c782
-rw-r--r--drivers/input/touchscreen/mainstone-wm97xx.c3
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c5
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c13
-rw-r--r--drivers/input/touchscreen/zylonite-wm97xx.c240
-rw-r--r--drivers/misc/eeprom/at24.c8
-rw-r--r--drivers/misc/eeprom/at25.c5
-rw-r--r--drivers/misc/sgi-xp/xpc.h254
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c138
-rw-r--r--drivers/misc/sgi-xp/xpc_main.c128
-rw-r--r--drivers/misc/sgi-xp/xpc_partition.c20
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c164
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c257
-rw-r--r--drivers/net/atl1c/atl1c_main.c4
-rw-r--r--drivers/net/benet/be_main.c4
-rw-r--r--drivers/net/jme.c8
-rw-r--r--drivers/net/wireless/ath9k/pci.c4
-rw-r--r--drivers/net/wireless/p54/p54pci.c4
-rw-r--r--drivers/parisc/superio.c3
-rw-r--r--drivers/pci/dmar.c11
-rw-r--r--drivers/pci/intel-iommu.c4
-rw-r--r--drivers/scsi/3w-9xxx.c8
-rw-r--r--drivers/scsi/aacraid/aachba.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c2
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c10
-rw-r--r--drivers/scsi/scsi_priv.h3
-rw-r--r--drivers/scsi/scsi_wait_scan.c2
-rw-r--r--drivers/sh/intc.c35
-rw-r--r--drivers/spi/spi.c22
-rw-r--r--drivers/staging/b3dfg/b3dfg.c2
-rw-r--r--drivers/usb/class/cdc-acm.c4
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c4
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c26
-rw-r--r--drivers/video/aty/radeon_base.c4
-rw-r--r--drivers/video/backlight/backlight.c3
-rw-r--r--drivers/video/backlight/lcd.c3
-rw-r--r--drivers/video/cirrusfb.c4
-rw-r--r--drivers/video/console/fbcon.c55
-rw-r--r--drivers/video/efifb.c7
-rw-r--r--drivers/video/fbmem.c19
-rw-r--r--drivers/video/intelfb/intelfb.h2
-rw-r--r--drivers/video/intelfb/intelfb_i2c.c1
-rw-r--r--drivers/video/intelfb/intelfbdrv.c1
-rw-r--r--drivers/video/intelfb/intelfbhw.c5
-rw-r--r--drivers/video/s3fb.c6
-rw-r--r--drivers/video/sa1100fb.c15
-rw-r--r--drivers/video/sa1100fb.h7
-rw-r--r--drivers/video/sis/sis_main.c2
-rw-r--r--drivers/video/skeletonfb.c8
-rw-r--r--drivers/video/uvesafb.c35
-rw-r--r--drivers/video/vfb.c11
-rw-r--r--drivers/xen/cpu_hotplug.c40
-rw-r--r--drivers/xen/manage.c5
86 files changed, 4361 insertions, 892 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 57be6bea48eb..08186ecbaf8d 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -114,6 +114,7 @@ enum {
114 board_ahci_sb700 = 5, /* for SB700 and SB800 */ 114 board_ahci_sb700 = 5, /* for SB700 and SB800 */
115 board_ahci_mcp65 = 6, 115 board_ahci_mcp65 = 6,
116 board_ahci_nopmp = 7, 116 board_ahci_nopmp = 7,
117 board_ahci_yesncq = 8,
117 118
118 /* global controller registers */ 119 /* global controller registers */
119 HOST_CAP = 0x00, /* host capabilities */ 120 HOST_CAP = 0x00, /* host capabilities */
@@ -469,6 +470,14 @@ static const struct ata_port_info ahci_port_info[] = {
469 .udma_mask = ATA_UDMA6, 470 .udma_mask = ATA_UDMA6,
470 .port_ops = &ahci_ops, 471 .port_ops = &ahci_ops,
471 }, 472 },
473 /* board_ahci_yesncq */
474 {
475 AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ),
476 .flags = AHCI_FLAG_COMMON,
477 .pio_mask = ATA_PIO4,
478 .udma_mask = ATA_UDMA6,
479 .port_ops = &ahci_ops,
480 },
472}; 481};
473 482
474static const struct pci_device_id ahci_pci_tbl[] = { 483static const struct pci_device_id ahci_pci_tbl[] = {
@@ -535,30 +544,30 @@ static const struct pci_device_id ahci_pci_tbl[] = {
535 { PCI_VDEVICE(NVIDIA, 0x045d), board_ahci_mcp65 }, /* MCP65 */ 544 { PCI_VDEVICE(NVIDIA, 0x045d), board_ahci_mcp65 }, /* MCP65 */
536 { PCI_VDEVICE(NVIDIA, 0x045e), board_ahci_mcp65 }, /* MCP65 */ 545 { PCI_VDEVICE(NVIDIA, 0x045e), board_ahci_mcp65 }, /* MCP65 */
537 { PCI_VDEVICE(NVIDIA, 0x045f), board_ahci_mcp65 }, /* MCP65 */ 546 { PCI_VDEVICE(NVIDIA, 0x045f), board_ahci_mcp65 }, /* MCP65 */
538 { PCI_VDEVICE(NVIDIA, 0x0550), board_ahci }, /* MCP67 */ 547 { PCI_VDEVICE(NVIDIA, 0x0550), board_ahci_yesncq }, /* MCP67 */
539 { PCI_VDEVICE(NVIDIA, 0x0551), board_ahci }, /* MCP67 */ 548 { PCI_VDEVICE(NVIDIA, 0x0551), board_ahci_yesncq }, /* MCP67 */
540 { PCI_VDEVICE(NVIDIA, 0x0552), board_ahci }, /* MCP67 */ 549 { PCI_VDEVICE(NVIDIA, 0x0552), board_ahci_yesncq }, /* MCP67 */
541 { PCI_VDEVICE(NVIDIA, 0x0553), board_ahci }, /* MCP67 */ 550 { PCI_VDEVICE(NVIDIA, 0x0553), board_ahci_yesncq }, /* MCP67 */
542 { PCI_VDEVICE(NVIDIA, 0x0554), board_ahci }, /* MCP67 */ 551 { PCI_VDEVICE(NVIDIA, 0x0554), board_ahci_yesncq }, /* MCP67 */
543 { PCI_VDEVICE(NVIDIA, 0x0555), board_ahci }, /* MCP67 */ 552 { PCI_VDEVICE(NVIDIA, 0x0555), board_ahci_yesncq }, /* MCP67 */
544 { PCI_VDEVICE(NVIDIA, 0x0556), board_ahci }, /* MCP67 */ 553 { PCI_VDEVICE(NVIDIA, 0x0556), board_ahci_yesncq }, /* MCP67 */
545 { PCI_VDEVICE(NVIDIA, 0x0557), board_ahci }, /* MCP67 */ 554 { PCI_VDEVICE(NVIDIA, 0x0557), board_ahci_yesncq }, /* MCP67 */
546 { PCI_VDEVICE(NVIDIA, 0x0558), board_ahci }, /* MCP67 */ 555 { PCI_VDEVICE(NVIDIA, 0x0558), board_ahci_yesncq }, /* MCP67 */
547 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */ 556 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci_yesncq }, /* MCP67 */
548 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */ 557 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci_yesncq }, /* MCP67 */
549 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */ 558 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci_yesncq }, /* MCP67 */
550 { PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci }, /* MCP73 */ 559 { PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci_yesncq }, /* MCP73 */
551 { PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci }, /* MCP73 */ 560 { PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci_yesncq }, /* MCP73 */
552 { PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci }, /* MCP73 */ 561 { PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci_yesncq }, /* MCP73 */
553 { PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci }, /* MCP73 */ 562 { PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci_yesncq }, /* MCP73 */
554 { PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci }, /* MCP73 */ 563 { PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci_yesncq }, /* MCP73 */
555 { PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci }, /* MCP73 */ 564 { PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci_yesncq }, /* MCP73 */
556 { PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci }, /* MCP73 */ 565 { PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci_yesncq }, /* MCP73 */
557 { PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci }, /* MCP73 */ 566 { PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci_yesncq }, /* MCP73 */
558 { PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci }, /* MCP73 */ 567 { PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci_yesncq }, /* MCP73 */
559 { PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci }, /* MCP73 */ 568 { PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci_yesncq }, /* MCP73 */
560 { PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci }, /* MCP73 */ 569 { PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci_yesncq }, /* MCP73 */
561 { PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci }, /* MCP73 */ 570 { PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci_yesncq }, /* MCP73 */
562 { PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci }, /* MCP77 */ 571 { PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci }, /* MCP77 */
563 { PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci }, /* MCP77 */ 572 { PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci }, /* MCP77 */
564 { PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci }, /* MCP77 */ 573 { PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci }, /* MCP77 */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index e7ea77cf6069..065507c46644 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6110,13 +6110,11 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6110 ata_port_printk(ap, KERN_INFO, "DUMMY\n"); 6110 ata_port_printk(ap, KERN_INFO, "DUMMY\n");
6111 } 6111 }
6112 6112
6113 /* perform each probe synchronously */ 6113 /* perform each probe asynchronously */
6114 DPRINTK("probe begin\n");
6115 for (i = 0; i < host->n_ports; i++) { 6114 for (i = 0; i < host->n_ports; i++) {
6116 struct ata_port *ap = host->ports[i]; 6115 struct ata_port *ap = host->ports[i];
6117 async_schedule(async_port_probe, ap); 6116 async_schedule(async_port_probe, ap);
6118 } 6117 }
6119 DPRINTK("probe end\n");
6120 6118
6121 return 0; 6119 return 0;
6122} 6120}
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 98e8c50703b3..bdd43c7f432e 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -566,7 +566,7 @@ static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
566 static int printed_version; 566 static int printed_version;
567 unsigned int i; 567 unsigned int i;
568 int rc; 568 int rc;
569 struct ata_host *host; 569 struct ata_host *host = NULL;
570 int board_id = (int) ent->driver_data; 570 int board_id = (int) ent->driver_data;
571 const unsigned *bar_sizes; 571 const unsigned *bar_sizes;
572 572
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index be204308cc1b..9359613addc5 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -1059,7 +1059,7 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1059 goto out; 1059 goto out;
1060 } 1060 }
1061 1061
1062 err = pci_set_dma_mask(dev, DMA_32BIT_MASK); 1062 err = pci_set_dma_mask(dev, DMA_BIT_MASK(32));
1063 if (err) { 1063 if (err) {
1064 dev_warn(&dev->dev, "Failed to set 32-bit DMA mask\n"); 1064 dev_warn(&dev->dev, "Failed to set 32-bit DMA mask\n");
1065 goto out; 1065 goto out;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 0ef6f08aa6ea..4d4d5e0d3fa6 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3505,7 +3505,7 @@ static __devinit int cciss_message(struct pci_dev *pdev, unsigned char opcode, u
3505 /* The Inbound Post Queue only accepts 32-bit physical addresses for the 3505 /* The Inbound Post Queue only accepts 32-bit physical addresses for the
3506 CCISS commands, so they must be allocated from the lower 4GiB of 3506 CCISS commands, so they must be allocated from the lower 4GiB of
3507 memory. */ 3507 memory. */
3508 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 3508 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
3509 if (err) { 3509 if (err) {
3510 iounmap(vaddr); 3510 iounmap(vaddr);
3511 return -ENOMEM; 3511 return -ENOMEM;
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 9d9490e22e07..3686912427ba 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -2131,6 +2131,8 @@ static const struct intel_driver_description {
2131 { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, 0, "830M", 2131 { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, 0, "830M",
2132 &intel_845_driver, &intel_830_driver }, 2132 &intel_845_driver, &intel_830_driver },
2133 { PCI_DEVICE_ID_INTEL_82850_HB, 0, 0, "i850", &intel_850_driver, NULL }, 2133 { PCI_DEVICE_ID_INTEL_82850_HB, 0, 0, "i850", &intel_850_driver, NULL },
2134 { PCI_DEVICE_ID_INTEL_82854_HB, PCI_DEVICE_ID_INTEL_82854_IG, 0, "854",
2135 &intel_845_driver, &intel_830_driver },
2134 { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, 0, "855PM", &intel_845_driver, NULL }, 2136 { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, 0, "855PM", &intel_845_driver, NULL },
2135 { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, 0, "855GM", 2137 { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, 0, "855GM",
2136 &intel_845_driver, &intel_830_driver }, 2138 &intel_845_driver, &intel_830_driver },
@@ -2355,6 +2357,7 @@ static struct pci_device_id agp_intel_pci_table[] = {
2355 ID(PCI_DEVICE_ID_INTEL_82845_HB), 2357 ID(PCI_DEVICE_ID_INTEL_82845_HB),
2356 ID(PCI_DEVICE_ID_INTEL_82845G_HB), 2358 ID(PCI_DEVICE_ID_INTEL_82845G_HB),
2357 ID(PCI_DEVICE_ID_INTEL_82850_HB), 2359 ID(PCI_DEVICE_ID_INTEL_82850_HB),
2360 ID(PCI_DEVICE_ID_INTEL_82854_HB),
2358 ID(PCI_DEVICE_ID_INTEL_82855PM_HB), 2361 ID(PCI_DEVICE_ID_INTEL_82855PM_HB),
2359 ID(PCI_DEVICE_ID_INTEL_82855GM_HB), 2362 ID(PCI_DEVICE_ID_INTEL_82855GM_HB),
2360 ID(PCI_DEVICE_ID_INTEL_82860_HB), 2363 ID(PCI_DEVICE_ID_INTEL_82860_HB),
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 6de020d078e1..b0a6a3e51924 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -35,7 +35,6 @@
35#include <linux/vt_kern.h> 35#include <linux/vt_kern.h>
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37#include <linux/kexec.h> 37#include <linux/kexec.h>
38#include <linux/interrupt.h>
39#include <linux/hrtimer.h> 38#include <linux/hrtimer.h>
40#include <linux/oom.h> 39#include <linux/oom.h>
41 40
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 28f2c3f959b5..6ad95c8d6363 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -767,11 +767,19 @@ static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
767 pci_write_config_word(pdev, offset, value); 767 pci_write_config_word(pdev, offset, value);
768} 768}
769 769
770/* write all or some bits in a dword-register*/ 770/*
771 * pci_write_bits32
772 *
773 * edac local routine to do pci_write_config_dword, but adds
774 * a mask parameter. If mask is all ones, ignore the mask.
775 * Otherwise utilize the mask to isolate specified bits
776 *
777 * write all or some bits in a dword-register
778 */
771static inline void pci_write_bits32(struct pci_dev *pdev, int offset, 779static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
772 u32 value, u32 mask) 780 u32 value, u32 mask)
773{ 781{
774 if (mask != 0xffff) { 782 if (mask != 0xffffffff) {
775 u32 buf; 783 u32 buf;
776 784
777 pci_read_config_dword(pdev, offset, &buf); 785 pci_read_config_dword(pdev, offset, &buf);
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
index ca9113e1c106..a7d2c717d033 100644
--- a/drivers/edac/edac_device.c
+++ b/drivers/edac/edac_device.c
@@ -389,7 +389,7 @@ static void del_edac_device_from_global_list(struct edac_device_ctl_info
389 */ 389 */
390static void edac_device_workq_function(struct work_struct *work_req) 390static void edac_device_workq_function(struct work_struct *work_req)
391{ 391{
392 struct delayed_work *d_work = (struct delayed_work *)work_req; 392 struct delayed_work *d_work = to_delayed_work(work_req);
393 struct edac_device_ctl_info *edac_dev = to_edac_device_ctl_work(d_work); 393 struct edac_device_ctl_info *edac_dev = to_edac_device_ctl_work(d_work);
394 394
395 mutex_lock(&device_ctls_mutex); 395 mutex_lock(&device_ctls_mutex);
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 25d66940b4fa..335b7ebdb11c 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -260,7 +260,7 @@ static int edac_mc_assert_error_check_and_clear(void)
260 */ 260 */
261static void edac_mc_workq_function(struct work_struct *work_req) 261static void edac_mc_workq_function(struct work_struct *work_req)
262{ 262{
263 struct delayed_work *d_work = (struct delayed_work *)work_req; 263 struct delayed_work *d_work = to_delayed_work(work_req);
264 struct mem_ctl_info *mci = to_edac_mem_ctl_work(d_work); 264 struct mem_ctl_info *mci = to_edac_mem_ctl_work(d_work);
265 265
266 mutex_lock(&mem_ctls_mutex); 266 mutex_lock(&mem_ctls_mutex);
diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
index 5b150aea703a..30b585b1d60b 100644
--- a/drivers/edac/edac_pci.c
+++ b/drivers/edac/edac_pci.c
@@ -233,7 +233,7 @@ EXPORT_SYMBOL_GPL(edac_pci_find);
233 */ 233 */
234static void edac_pci_workq_function(struct work_struct *work_req) 234static void edac_pci_workq_function(struct work_struct *work_req)
235{ 235{
236 struct delayed_work *d_work = (struct delayed_work *)work_req; 236 struct delayed_work *d_work = to_delayed_work(work_req);
237 struct edac_pci_ctl_info *pci = to_edac_pci_ctl_work(d_work); 237 struct edac_pci_ctl_info *pci = to_edac_pci_ctl_work(d_work);
238 int msec; 238 int msec;
239 unsigned long delay; 239 unsigned long delay;
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 0e8a9185f676..d73f5f473e38 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -692,6 +692,16 @@ config SENSORS_PCF8591
692 These devices are hard to detect and rarely found on mainstream 692 These devices are hard to detect and rarely found on mainstream
693 hardware. If unsure, say N. 693 hardware. If unsure, say N.
694 694
695config SENSORS_SHT15
696 tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
697 depends on GENERIC_GPIO
698 help
699 If you say yes here you get support for the Sensiron SHT10, SHT11,
700 SHT15, SHT71, SHT75 humidity and temperature sensors.
701
702 This driver can also be built as a module. If so, the module
703 will be called sht15.
704
695config SENSORS_SIS5595 705config SENSORS_SIS5595
696 tristate "Silicon Integrated Systems Corp. SiS5595" 706 tristate "Silicon Integrated Systems Corp. SiS5595"
697 depends on PCI 707 depends on PCI
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 1d3757837b4f..0ae26984ba45 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_SENSORS_MAX6650) += max6650.o
76obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 76obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
77obj-$(CONFIG_SENSORS_PC87427) += pc87427.o 77obj-$(CONFIG_SENSORS_PC87427) += pc87427.o
78obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 78obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
79obj-$(CONFIG_SENSORS_SHT15) += sht15.o
79obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o 80obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
80obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 81obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
81obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 82obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
index 55d3dc565be6..abca7e9f953b 100644
--- a/drivers/hwmon/hp_accel.c
+++ b/drivers/hwmon/hp_accel.c
@@ -34,7 +34,6 @@
34#include <linux/wait.h> 34#include <linux/wait.h>
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/freezer.h> 36#include <linux/freezer.h>
37#include <linux/version.h>
38#include <linux/uaccess.h> 37#include <linux/uaccess.h>
39#include <linux/leds.h> 38#include <linux/leds.h>
40#include <acpi/acpi_drivers.h> 39#include <acpi/acpi_drivers.h>
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
new file mode 100644
index 000000000000..6cbdc2fea734
--- /dev/null
+++ b/drivers/hwmon/sht15.c
@@ -0,0 +1,692 @@
1/*
2 * sht15.c - support for the SHT15 Temperature and Humidity Sensor
3 *
4 * Copyright (c) 2009 Jonathan Cameron
5 *
6 * Copyright (c) 2007 Wouter Horre
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 version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Currently ignoring checksum on readings.
13 * Default resolution only (14bit temp, 12bit humidity)
14 * Ignoring battery status.
15 * Heater not enabled.
16 * Timings are all conservative.
17 *
18 * Data sheet available (1/2009) at
19 * http://www.sensirion.ch/en/pdf/product_information/Datasheet-humidity-sensor-SHT1x.pdf
20 *
21 * Regulator supply name = vcc
22 */
23
24#include <linux/interrupt.h>
25#include <linux/irq.h>
26#include <linux/gpio.h>
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/hwmon.h>
30#include <linux/hwmon-sysfs.h>
31#include <linux/mutex.h>
32#include <linux/platform_device.h>
33#include <linux/delay.h>
34#include <linux/jiffies.h>
35#include <linux/err.h>
36#include <linux/sht15.h>
37#include <linux/regulator/consumer.h>
38#include <asm/atomic.h>
39
40#define SHT15_MEASURE_TEMP 3
41#define SHT15_MEASURE_RH 5
42
43#define SHT15_READING_NOTHING 0
44#define SHT15_READING_TEMP 1
45#define SHT15_READING_HUMID 2
46
47/* Min timings in nsecs */
48#define SHT15_TSCKL 100 /* clock low */
49#define SHT15_TSCKH 100 /* clock high */
50#define SHT15_TSU 150 /* data setup time */
51
52/**
53 * struct sht15_temppair - elements of voltage dependant temp calc
54 * @vdd: supply voltage in microvolts
55 * @d1: see data sheet
56 */
57struct sht15_temppair {
58 int vdd; /* microvolts */
59 int d1;
60};
61
62/* Table 9 from data sheet - relates temperature calculation
63 * to supply voltage.
64 */
65static const struct sht15_temppair temppoints[] = {
66 { 2500000, -39400 },
67 { 3000000, -39600 },
68 { 3500000, -39700 },
69 { 4000000, -39800 },
70 { 5000000, -40100 },
71};
72
73/**
74 * struct sht15_data - device instance specific data
75 * @pdata: platform data (gpio's etc)
76 * @read_work: bh of interrupt handler
77 * @wait_queue: wait queue for getting values from device
78 * @val_temp: last temperature value read from device
79 * @val_humid: last humidity value read from device
80 * @flag: status flag used to identify what the last request was
81 * @valid: are the current stored values valid (start condition)
82 * @last_updat: time of last update
83 * @read_lock: mutex to ensure only one read in progress
84 * at a time.
85 * @dev: associate device structure
86 * @hwmon_dev: device associated with hwmon subsystem
87 * @reg: associated regulator (if specified)
88 * @nb: notifier block to handle notifications of voltage changes
89 * @supply_uV: local copy of supply voltage used to allow
90 * use of regulator consumer if available
91 * @supply_uV_valid: indicates that an updated value has not yet
92 * been obtained from the regulator and so any calculations
93 * based upon it will be invalid.
94 * @update_supply_work: work struct that is used to update the supply_uV
95 * @interrupt_handled: flag used to indicate a hander has been scheduled
96 */
97struct sht15_data {
98 struct sht15_platform_data *pdata;
99 struct work_struct read_work;
100 wait_queue_head_t wait_queue;
101 uint16_t val_temp;
102 uint16_t val_humid;
103 u8 flag;
104 u8 valid;
105 unsigned long last_updat;
106 struct mutex read_lock;
107 struct device *dev;
108 struct device *hwmon_dev;
109 struct regulator *reg;
110 struct notifier_block nb;
111 int supply_uV;
112 int supply_uV_valid;
113 struct work_struct update_supply_work;
114 atomic_t interrupt_handled;
115};
116
117/**
118 * sht15_connection_reset() - reset the comms interface
119 * @data: sht15 specific data
120 *
121 * This implements section 3.4 of the data sheet
122 */
123static void sht15_connection_reset(struct sht15_data *data)
124{
125 int i;
126 gpio_direction_output(data->pdata->gpio_data, 1);
127 ndelay(SHT15_TSCKL);
128 gpio_set_value(data->pdata->gpio_sck, 0);
129 ndelay(SHT15_TSCKL);
130 for (i = 0; i < 9; ++i) {
131 gpio_set_value(data->pdata->gpio_sck, 1);
132 ndelay(SHT15_TSCKH);
133 gpio_set_value(data->pdata->gpio_sck, 0);
134 ndelay(SHT15_TSCKL);
135 }
136}
137/**
138 * sht15_send_bit() - send an individual bit to the device
139 * @data: device state data
140 * @val: value of bit to be sent
141 **/
142static inline void sht15_send_bit(struct sht15_data *data, int val)
143{
144
145 gpio_set_value(data->pdata->gpio_data, val);
146 ndelay(SHT15_TSU);
147 gpio_set_value(data->pdata->gpio_sck, 1);
148 ndelay(SHT15_TSCKH);
149 gpio_set_value(data->pdata->gpio_sck, 0);
150 ndelay(SHT15_TSCKL); /* clock low time */
151}
152
153/**
154 * sht15_transmission_start() - specific sequence for new transmission
155 *
156 * @data: device state data
157 * Timings for this are not documented on the data sheet, so very
158 * conservative ones used in implementation. This implements
159 * figure 12 on the data sheet.
160 **/
161static void sht15_transmission_start(struct sht15_data *data)
162{
163 /* ensure data is high and output */
164 gpio_direction_output(data->pdata->gpio_data, 1);
165 ndelay(SHT15_TSU);
166 gpio_set_value(data->pdata->gpio_sck, 0);
167 ndelay(SHT15_TSCKL);
168 gpio_set_value(data->pdata->gpio_sck, 1);
169 ndelay(SHT15_TSCKH);
170 gpio_set_value(data->pdata->gpio_data, 0);
171 ndelay(SHT15_TSU);
172 gpio_set_value(data->pdata->gpio_sck, 0);
173 ndelay(SHT15_TSCKL);
174 gpio_set_value(data->pdata->gpio_sck, 1);
175 ndelay(SHT15_TSCKH);
176 gpio_set_value(data->pdata->gpio_data, 1);
177 ndelay(SHT15_TSU);
178 gpio_set_value(data->pdata->gpio_sck, 0);
179 ndelay(SHT15_TSCKL);
180}
181/**
182 * sht15_send_byte() - send a single byte to the device
183 * @data: device state
184 * @byte: value to be sent
185 **/
186static void sht15_send_byte(struct sht15_data *data, u8 byte)
187{
188 int i;
189 for (i = 0; i < 8; i++) {
190 sht15_send_bit(data, !!(byte & 0x80));
191 byte <<= 1;
192 }
193}
194/**
195 * sht15_wait_for_response() - checks for ack from device
196 * @data: device state
197 **/
198static int sht15_wait_for_response(struct sht15_data *data)
199{
200 gpio_direction_input(data->pdata->gpio_data);
201 gpio_set_value(data->pdata->gpio_sck, 1);
202 ndelay(SHT15_TSCKH);
203 if (gpio_get_value(data->pdata->gpio_data)) {
204 gpio_set_value(data->pdata->gpio_sck, 0);
205 dev_err(data->dev, "Command not acknowledged\n");
206 sht15_connection_reset(data);
207 return -EIO;
208 }
209 gpio_set_value(data->pdata->gpio_sck, 0);
210 ndelay(SHT15_TSCKL);
211 return 0;
212}
213
214/**
215 * sht15_send_cmd() - Sends a command to the device.
216 * @data: device state
217 * @cmd: command byte to be sent
218 *
219 * On entry, sck is output low, data is output pull high
220 * and the interrupt disabled.
221 **/
222static int sht15_send_cmd(struct sht15_data *data, u8 cmd)
223{
224 int ret = 0;
225 sht15_transmission_start(data);
226 sht15_send_byte(data, cmd);
227 ret = sht15_wait_for_response(data);
228 return ret;
229}
230/**
231 * sht15_update_single_val() - get a new value from device
232 * @data: device instance specific data
233 * @command: command sent to request value
234 * @timeout_msecs: timeout after which comms are assumed
235 * to have failed are reset.
236 **/
237static inline int sht15_update_single_val(struct sht15_data *data,
238 int command,
239 int timeout_msecs)
240{
241 int ret;
242 ret = sht15_send_cmd(data, command);
243 if (ret)
244 return ret;
245
246 gpio_direction_input(data->pdata->gpio_data);
247 atomic_set(&data->interrupt_handled, 0);
248
249 enable_irq(gpio_to_irq(data->pdata->gpio_data));
250 if (gpio_get_value(data->pdata->gpio_data) == 0) {
251 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
252 /* Only relevant if the interrupt hasn't occured. */
253 if (!atomic_read(&data->interrupt_handled))
254 schedule_work(&data->read_work);
255 }
256 ret = wait_event_timeout(data->wait_queue,
257 (data->flag == SHT15_READING_NOTHING),
258 msecs_to_jiffies(timeout_msecs));
259 if (ret == 0) {/* timeout occurred */
260 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));;
261 sht15_connection_reset(data);
262 return -ETIME;
263 }
264 return 0;
265}
266
267/**
268 * sht15_update_vals() - get updated readings from device if too old
269 * @data: device state
270 **/
271static int sht15_update_vals(struct sht15_data *data)
272{
273 int ret = 0;
274 int timeout = HZ;
275
276 mutex_lock(&data->read_lock);
277 if (time_after(jiffies, data->last_updat + timeout)
278 || !data->valid) {
279 data->flag = SHT15_READING_HUMID;
280 ret = sht15_update_single_val(data, SHT15_MEASURE_RH, 160);
281 if (ret)
282 goto error_ret;
283 data->flag = SHT15_READING_TEMP;
284 ret = sht15_update_single_val(data, SHT15_MEASURE_TEMP, 400);
285 if (ret)
286 goto error_ret;
287 data->valid = 1;
288 data->last_updat = jiffies;
289 }
290error_ret:
291 mutex_unlock(&data->read_lock);
292
293 return ret;
294}
295
296/**
297 * sht15_calc_temp() - convert the raw reading to a temperature
298 * @data: device state
299 *
300 * As per section 4.3 of the data sheet.
301 **/
302static inline int sht15_calc_temp(struct sht15_data *data)
303{
304 int d1 = 0;
305 int i;
306
307 for (i = 1; i < ARRAY_SIZE(temppoints) - 1; i++)
308 /* Find pointer to interpolate */
309 if (data->supply_uV > temppoints[i - 1].vdd) {
310 d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd)
311 * (temppoints[i].d1 - temppoints[i - 1].d1)
312 / (temppoints[i].vdd - temppoints[i - 1].vdd)
313 + temppoints[i - 1].d1;
314 break;
315 }
316
317 return data->val_temp*10 + d1;
318}
319
320/**
321 * sht15_calc_humid() - using last temperature convert raw to humid
322 * @data: device state
323 *
324 * This is the temperature compensated version as per section 4.2 of
325 * the data sheet.
326 **/
327static inline int sht15_calc_humid(struct sht15_data *data)
328{
329 int RHlinear; /* milli percent */
330 int temp = sht15_calc_temp(data);
331
332 const int c1 = -4;
333 const int c2 = 40500; /* x 10 ^ -6 */
334 const int c3 = 2800; /* x10 ^ -9 */
335
336 RHlinear = c1*1000
337 + c2 * data->val_humid/1000
338 + (data->val_humid * data->val_humid * c3)/1000000;
339 return (temp - 25000) * (10000 + 800 * data->val_humid)
340 / 1000000 + RHlinear;
341}
342
343static ssize_t sht15_show_temp(struct device *dev,
344 struct device_attribute *attr,
345 char *buf)
346{
347 int ret;
348 struct sht15_data *data = dev_get_drvdata(dev);
349
350 /* Technically no need to read humidity as well */
351 ret = sht15_update_vals(data);
352
353 return ret ? ret : sprintf(buf, "%d\n",
354 sht15_calc_temp(data));
355}
356
357static ssize_t sht15_show_humidity(struct device *dev,
358 struct device_attribute *attr,
359 char *buf)
360{
361 int ret;
362 struct sht15_data *data = dev_get_drvdata(dev);
363
364 ret = sht15_update_vals(data);
365
366 return ret ? ret : sprintf(buf, "%d\n", sht15_calc_humid(data));
367
368};
369static ssize_t show_name(struct device *dev,
370 struct device_attribute *attr,
371 char *buf)
372{
373 struct platform_device *pdev = to_platform_device(dev);
374 return sprintf(buf, "%s\n", pdev->name);
375}
376
377static SENSOR_DEVICE_ATTR(temp1_input,
378 S_IRUGO, sht15_show_temp,
379 NULL, 0);
380static SENSOR_DEVICE_ATTR(humidity1_input,
381 S_IRUGO, sht15_show_humidity,
382 NULL, 0);
383static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
384static struct attribute *sht15_attrs[] = {
385 &sensor_dev_attr_temp1_input.dev_attr.attr,
386 &sensor_dev_attr_humidity1_input.dev_attr.attr,
387 &dev_attr_name.attr,
388 NULL,
389};
390
391static const struct attribute_group sht15_attr_group = {
392 .attrs = sht15_attrs,
393};
394
395static irqreturn_t sht15_interrupt_fired(int irq, void *d)
396{
397 struct sht15_data *data = d;
398 /* First disable the interrupt */
399 disable_irq_nosync(irq);
400 atomic_inc(&data->interrupt_handled);
401 /* Then schedule a reading work struct */
402 if (data->flag != SHT15_READING_NOTHING)
403 schedule_work(&data->read_work);
404 return IRQ_HANDLED;
405}
406
407/* Each byte of data is acknowledged by pulling the data line
408 * low for one clock pulse.
409 */
410static void sht15_ack(struct sht15_data *data)
411{
412 gpio_direction_output(data->pdata->gpio_data, 0);
413 ndelay(SHT15_TSU);
414 gpio_set_value(data->pdata->gpio_sck, 1);
415 ndelay(SHT15_TSU);
416 gpio_set_value(data->pdata->gpio_sck, 0);
417 ndelay(SHT15_TSU);
418 gpio_set_value(data->pdata->gpio_data, 1);
419
420 gpio_direction_input(data->pdata->gpio_data);
421}
422/**
423 * sht15_end_transmission() - notify device of end of transmission
424 * @data: device state
425 *
426 * This is basically a NAK. (single clock pulse, data high)
427 **/
428static void sht15_end_transmission(struct sht15_data *data)
429{
430 gpio_direction_output(data->pdata->gpio_data, 1);
431 ndelay(SHT15_TSU);
432 gpio_set_value(data->pdata->gpio_sck, 1);
433 ndelay(SHT15_TSCKH);
434 gpio_set_value(data->pdata->gpio_sck, 0);
435 ndelay(SHT15_TSCKL);
436}
437
438static void sht15_bh_read_data(struct work_struct *work_s)
439{
440 int i;
441 uint16_t val = 0;
442 struct sht15_data *data
443 = container_of(work_s, struct sht15_data,
444 read_work);
445 /* Firstly, verify the line is low */
446 if (gpio_get_value(data->pdata->gpio_data)) {
447 /* If not, then start the interrupt again - care
448 here as could have gone low in meantime so verify
449 it hasn't!
450 */
451 atomic_set(&data->interrupt_handled, 0);
452 enable_irq(gpio_to_irq(data->pdata->gpio_data));
453 /* If still not occured or another handler has been scheduled */
454 if (gpio_get_value(data->pdata->gpio_data)
455 || atomic_read(&data->interrupt_handled))
456 return;
457 }
458 /* Read the data back from the device */
459 for (i = 0; i < 16; ++i) {
460 val <<= 1;
461 gpio_set_value(data->pdata->gpio_sck, 1);
462 ndelay(SHT15_TSCKH);
463 val |= !!gpio_get_value(data->pdata->gpio_data);
464 gpio_set_value(data->pdata->gpio_sck, 0);
465 ndelay(SHT15_TSCKL);
466 if (i == 7)
467 sht15_ack(data);
468 }
469 /* Tell the device we are done */
470 sht15_end_transmission(data);
471
472 switch (data->flag) {
473 case SHT15_READING_TEMP:
474 data->val_temp = val;
475 break;
476 case SHT15_READING_HUMID:
477 data->val_humid = val;
478 break;
479 }
480
481 data->flag = SHT15_READING_NOTHING;
482 wake_up(&data->wait_queue);
483}
484
485static void sht15_update_voltage(struct work_struct *work_s)
486{
487 struct sht15_data *data
488 = container_of(work_s, struct sht15_data,
489 update_supply_work);
490 data->supply_uV = regulator_get_voltage(data->reg);
491}
492
493/**
494 * sht15_invalidate_voltage() - mark supply voltage invalid when notified by reg
495 * @nb: associated notification structure
496 * @event: voltage regulator state change event code
497 * @ignored: function parameter - ignored here
498 *
499 * Note that as the notification code holds the regulator lock, we have
500 * to schedule an update of the supply voltage rather than getting it directly.
501 **/
502static int sht15_invalidate_voltage(struct notifier_block *nb,
503 unsigned long event,
504 void *ignored)
505{
506 struct sht15_data *data = container_of(nb, struct sht15_data, nb);
507
508 if (event == REGULATOR_EVENT_VOLTAGE_CHANGE)
509 data->supply_uV_valid = false;
510 schedule_work(&data->update_supply_work);
511
512 return NOTIFY_OK;
513}
514
515static int __devinit sht15_probe(struct platform_device *pdev)
516{
517 int ret = 0;
518 struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL);
519
520 if (!data) {
521 ret = -ENOMEM;
522 dev_err(&pdev->dev, "kzalloc failed");
523 goto error_ret;
524 }
525
526 INIT_WORK(&data->read_work, sht15_bh_read_data);
527 INIT_WORK(&data->update_supply_work, sht15_update_voltage);
528 platform_set_drvdata(pdev, data);
529 mutex_init(&data->read_lock);
530 data->dev = &pdev->dev;
531 init_waitqueue_head(&data->wait_queue);
532
533 if (pdev->dev.platform_data == NULL) {
534 dev_err(&pdev->dev, "no platform data supplied");
535 goto err_free_data;
536 }
537 data->pdata = pdev->dev.platform_data;
538 data->supply_uV = data->pdata->supply_mv*1000;
539
540/* If a regulator is available, query what the supply voltage actually is!*/
541 data->reg = regulator_get(data->dev, "vcc");
542 if (!IS_ERR(data->reg)) {
543 data->supply_uV = regulator_get_voltage(data->reg);
544 regulator_enable(data->reg);
545 /* setup a notifier block to update this if another device
546 * causes the voltage to change */
547 data->nb.notifier_call = &sht15_invalidate_voltage;
548 ret = regulator_register_notifier(data->reg, &data->nb);
549 }
550/* Try requesting the GPIOs */
551 ret = gpio_request(data->pdata->gpio_sck, "SHT15 sck");
552 if (ret) {
553 dev_err(&pdev->dev, "gpio request failed");
554 goto err_free_data;
555 }
556 gpio_direction_output(data->pdata->gpio_sck, 0);
557 ret = gpio_request(data->pdata->gpio_data, "SHT15 data");
558 if (ret) {
559 dev_err(&pdev->dev, "gpio request failed");
560 goto err_release_gpio_sck;
561 }
562 ret = sysfs_create_group(&pdev->dev.kobj, &sht15_attr_group);
563 if (ret) {
564 dev_err(&pdev->dev, "sysfs create failed");
565 goto err_free_data;
566 }
567
568 ret = request_irq(gpio_to_irq(data->pdata->gpio_data),
569 sht15_interrupt_fired,
570 IRQF_TRIGGER_FALLING,
571 "sht15 data",
572 data);
573 if (ret) {
574 dev_err(&pdev->dev, "failed to get irq for data line");
575 goto err_release_gpio_data;
576 }
577 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
578 sht15_connection_reset(data);
579 sht15_send_cmd(data, 0x1E);
580
581 data->hwmon_dev = hwmon_device_register(data->dev);
582 if (IS_ERR(data->hwmon_dev)) {
583 ret = PTR_ERR(data->hwmon_dev);
584 goto err_release_gpio_data;
585 }
586 return 0;
587
588err_release_gpio_data:
589 gpio_free(data->pdata->gpio_data);
590err_release_gpio_sck:
591 gpio_free(data->pdata->gpio_sck);
592err_free_data:
593 kfree(data);
594error_ret:
595
596 return ret;
597}
598
599static int __devexit sht15_remove(struct platform_device *pdev)
600{
601 struct sht15_data *data = platform_get_drvdata(pdev);
602
603 /* Make sure any reads from the device are done and
604 * prevent new ones beginnning */
605 mutex_lock(&data->read_lock);
606 hwmon_device_unregister(data->hwmon_dev);
607 sysfs_remove_group(&pdev->dev.kobj, &sht15_attr_group);
608 if (!IS_ERR(data->reg)) {
609 regulator_unregister_notifier(data->reg, &data->nb);
610 regulator_disable(data->reg);
611 regulator_put(data->reg);
612 }
613
614 free_irq(gpio_to_irq(data->pdata->gpio_data), data);
615 gpio_free(data->pdata->gpio_data);
616 gpio_free(data->pdata->gpio_sck);
617 mutex_unlock(&data->read_lock);
618 kfree(data);
619 return 0;
620}
621
622
623static struct platform_driver sht_drivers[] = {
624 {
625 .driver = {
626 .name = "sht10",
627 .owner = THIS_MODULE,
628 },
629 .probe = sht15_probe,
630 .remove = sht15_remove,
631 }, {
632 .driver = {
633 .name = "sht11",
634 .owner = THIS_MODULE,
635 },
636 .probe = sht15_probe,
637 .remove = sht15_remove,
638 }, {
639 .driver = {
640 .name = "sht15",
641 .owner = THIS_MODULE,
642 },
643 .probe = sht15_probe,
644 .remove = sht15_remove,
645 }, {
646 .driver = {
647 .name = "sht71",
648 .owner = THIS_MODULE,
649 },
650 .probe = sht15_probe,
651 .remove = sht15_remove,
652 }, {
653 .driver = {
654 .name = "sht75",
655 .owner = THIS_MODULE,
656 },
657 .probe = sht15_probe,
658 .remove = sht15_remove,
659 },
660};
661
662
663static int __init sht15_init(void)
664{
665 int ret;
666 int i;
667
668 for (i = 0; i < ARRAY_SIZE(sht_drivers); i++) {
669 ret = platform_driver_register(&sht_drivers[i]);
670 if (ret)
671 goto error_unreg;
672 }
673
674 return 0;
675
676error_unreg:
677 while (--i >= 0)
678 platform_driver_unregister(&sht_drivers[i]);
679
680 return ret;
681}
682module_init(sht15_init);
683
684static void __exit sht15_exit(void)
685{
686 int i;
687 for (i = ARRAY_SIZE(sht_drivers) - 1; i >= 0; i--)
688 platform_driver_unregister(&sht_drivers[i]);
689}
690module_exit(sht15_exit);
691
692MODULE_LICENSE("GPL");
diff --git a/drivers/input/input.c b/drivers/input/input.c
index ec3db3ade118..d44065d2e662 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -132,6 +132,11 @@ static void input_start_autorepeat(struct input_dev *dev, int code)
132 } 132 }
133} 133}
134 134
135static void input_stop_autorepeat(struct input_dev *dev)
136{
137 del_timer(&dev->timer);
138}
139
135#define INPUT_IGNORE_EVENT 0 140#define INPUT_IGNORE_EVENT 0
136#define INPUT_PASS_TO_HANDLERS 1 141#define INPUT_PASS_TO_HANDLERS 1
137#define INPUT_PASS_TO_DEVICE 2 142#define INPUT_PASS_TO_DEVICE 2
@@ -167,6 +172,8 @@ static void input_handle_event(struct input_dev *dev,
167 __change_bit(code, dev->key); 172 __change_bit(code, dev->key);
168 if (value) 173 if (value)
169 input_start_autorepeat(dev, code); 174 input_start_autorepeat(dev, code);
175 else
176 input_stop_autorepeat(dev);
170 } 177 }
171 178
172 disposition = INPUT_PASS_TO_HANDLERS; 179 disposition = INPUT_PASS_TO_HANDLERS;
@@ -737,11 +744,11 @@ static inline void input_wakeup_procfs_readers(void)
737 744
738static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait) 745static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
739{ 746{
740 int state = input_devices_state;
741
742 poll_wait(file, &input_devices_poll_wait, wait); 747 poll_wait(file, &input_devices_poll_wait, wait);
743 if (state != input_devices_state) 748 if (file->f_version != input_devices_state) {
749 file->f_version = input_devices_state;
744 return POLLIN | POLLRDNORM; 750 return POLLIN | POLLRDNORM;
751 }
745 752
746 return 0; 753 return 0;
747} 754}
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 45470f18d7e9..f999dc60c3b8 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -229,7 +229,8 @@ struct atkbd {
229/* 229/*
230 * System-specific ketymap fixup routine 230 * System-specific ketymap fixup routine
231 */ 231 */
232static void (*atkbd_platform_fixup)(struct atkbd *); 232static void (*atkbd_platform_fixup)(struct atkbd *, const void *data);
233static void *atkbd_platform_fixup_data;
233 234
234static ssize_t atkbd_attr_show_helper(struct device *dev, char *buf, 235static ssize_t atkbd_attr_show_helper(struct device *dev, char *buf,
235 ssize_t (*handler)(struct atkbd *, char *)); 236 ssize_t (*handler)(struct atkbd *, char *));
@@ -834,87 +835,64 @@ static void atkbd_disconnect(struct serio *serio)
834} 835}
835 836
836/* 837/*
837 * Most special keys (Fn+F?) on Dell laptops do not generate release 838 * generate release events for the keycodes given in data
838 * events so we have to do it ourselves.
839 */ 839 */
840static void atkbd_dell_laptop_keymap_fixup(struct atkbd *atkbd) 840static void atkbd_apply_forced_release_keylist(struct atkbd* atkbd,
841 const void *data)
841{ 842{
842 static const unsigned int forced_release_keys[] = { 843 const unsigned int *keys = data;
843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93, 844 unsigned int i;
844 };
845 int i;
846 845
847 if (atkbd->set == 2) 846 if (atkbd->set == 2)
848 for (i = 0; i < ARRAY_SIZE(forced_release_keys); i++) 847 for (i = 0; keys[i] != -1U; i++)
849 __set_bit(forced_release_keys[i], 848 __set_bit(keys[i], atkbd->force_release_mask);
850 atkbd->force_release_mask);
851} 849}
852 850
853/* 851/*
852 * Most special keys (Fn+F?) on Dell laptops do not generate release
853 * events so we have to do it ourselves.
854 */
855static unsigned int atkbd_dell_laptop_forced_release_keys[] = {
856 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93, -1U
857};
858
859/*
854 * Perform fixup for HP system that doesn't generate release 860 * Perform fixup for HP system that doesn't generate release
855 * for its video switch 861 * for its video switch
856 */ 862 */
857static void atkbd_hp_keymap_fixup(struct atkbd *atkbd) 863static unsigned int atkbd_hp_forced_release_keys[] = {
858{ 864 0x94, -1U
859 static const unsigned int forced_release_keys[] = { 865};
860 0x94,
861 };
862 int i;
863
864 if (atkbd->set == 2)
865 for (i = 0; i < ARRAY_SIZE(forced_release_keys); i++)
866 __set_bit(forced_release_keys[i],
867 atkbd->force_release_mask);
868}
869 866
870/* 867/*
871 * Inventec system with broken key release on volume keys 868 * Inventec system with broken key release on volume keys
872 */ 869 */
873static void atkbd_inventec_keymap_fixup(struct atkbd *atkbd) 870static unsigned int atkbd_inventec_forced_release_keys[] = {
874{ 871 0xae, 0xb0, -1U
875 const unsigned int forced_release_keys[] = { 872};
876 0xae, 0xb0,
877 };
878 int i;
879
880 if (atkbd->set == 2)
881 for (i = 0; i < ARRAY_SIZE(forced_release_keys); i++)
882 __set_bit(forced_release_keys[i],
883 atkbd->force_release_mask);
884}
885 873
886/* 874/*
887 * Perform fixup for HP Pavilion ZV6100 laptop that doesn't generate release 875 * Perform fixup for HP Pavilion ZV6100 laptop that doesn't generate release
888 * for its volume buttons 876 * for its volume buttons
889 */ 877 */
890static void atkbd_hp_zv6100_keymap_fixup(struct atkbd *atkbd) 878static unsigned int atkbd_hp_zv6100_forced_release_keys[] = {
891{ 879 0xae, 0xb0, -1U
892 const unsigned int forced_release_keys[] = { 880};
893 0xae, 0xb0,
894 };
895 int i;
896
897 if (atkbd->set == 2)
898 for (i = 0; i < ARRAY_SIZE(forced_release_keys); i++)
899 __set_bit(forced_release_keys[i],
900 atkbd->force_release_mask);
901}
902 881
903/* 882/*
904 * Samsung NC10 with Fn+F? key release not working 883 * Samsung NC10 with Fn+F? key release not working
905 */ 884 */
906static void atkbd_samsung_keymap_fixup(struct atkbd *atkbd) 885static unsigned int atkbd_samsung_forced_release_keys[] = {
907{ 886 0x82, 0x83, 0x84, 0x86, 0x88, 0x89, 0xb3, 0xf7, 0xf9, -1U
908 const unsigned int forced_release_keys[] = { 887};
909 0x82, 0x83, 0x84, 0x86, 0x88, 0x89, 0xb3, 0xf7, 0xf9,
910 };
911 int i;
912 888
913 if (atkbd->set == 2) 889/*
914 for (i = 0; i < ARRAY_SIZE(forced_release_keys); i++) 890 * The volume up and volume down special keys on a Fujitsu Amilo PA 1510 laptop
915 __set_bit(forced_release_keys[i], 891 * do not generate release events so we have to do it ourselves.
916 atkbd->force_release_mask); 892 */
917} 893static unsigned int atkbd_amilo_pa1510_forced_release_keys[] = {
894 0xb0, 0xae, -1U
895};
918 896
919/* 897/*
920 * atkbd_set_keycode_table() initializes keyboard's keycode table 898 * atkbd_set_keycode_table() initializes keyboard's keycode table
@@ -967,7 +945,7 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd)
967 * Perform additional fixups 945 * Perform additional fixups
968 */ 946 */
969 if (atkbd_platform_fixup) 947 if (atkbd_platform_fixup)
970 atkbd_platform_fixup(atkbd); 948 atkbd_platform_fixup(atkbd, atkbd_platform_fixup_data);
971} 949}
972 950
973/* 951/*
@@ -1492,9 +1470,11 @@ static ssize_t atkbd_show_err_count(struct atkbd *atkbd, char *buf)
1492 return sprintf(buf, "%lu\n", atkbd->err_count); 1470 return sprintf(buf, "%lu\n", atkbd->err_count);
1493} 1471}
1494 1472
1495static int __init atkbd_setup_fixup(const struct dmi_system_id *id) 1473static int __init atkbd_setup_forced_release(const struct dmi_system_id *id)
1496{ 1474{
1497 atkbd_platform_fixup = id->driver_data; 1475 atkbd_platform_fixup = atkbd_apply_forced_release_keylist;
1476 atkbd_platform_fixup_data = id->driver_data;
1477
1498 return 0; 1478 return 0;
1499} 1479}
1500 1480
@@ -1505,8 +1485,8 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1505 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1485 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
1506 DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */ 1486 DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
1507 }, 1487 },
1508 .callback = atkbd_setup_fixup, 1488 .callback = atkbd_setup_forced_release,
1509 .driver_data = atkbd_dell_laptop_keymap_fixup, 1489 .driver_data = atkbd_dell_laptop_forced_release_keys,
1510 }, 1490 },
1511 { 1491 {
1512 .ident = "Dell Laptop", 1492 .ident = "Dell Laptop",
@@ -1514,8 +1494,8 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1514 DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), 1494 DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
1515 DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */ 1495 DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
1516 }, 1496 },
1517 .callback = atkbd_setup_fixup, 1497 .callback = atkbd_setup_forced_release,
1518 .driver_data = atkbd_dell_laptop_keymap_fixup, 1498 .driver_data = atkbd_dell_laptop_forced_release_keys,
1519 }, 1499 },
1520 { 1500 {
1521 .ident = "HP 2133", 1501 .ident = "HP 2133",
@@ -1523,8 +1503,8 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1523 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1503 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1524 DMI_MATCH(DMI_PRODUCT_NAME, "HP 2133"), 1504 DMI_MATCH(DMI_PRODUCT_NAME, "HP 2133"),
1525 }, 1505 },
1526 .callback = atkbd_setup_fixup, 1506 .callback = atkbd_setup_forced_release,
1527 .driver_data = atkbd_hp_keymap_fixup, 1507 .driver_data = atkbd_hp_forced_release_keys,
1528 }, 1508 },
1529 { 1509 {
1530 .ident = "HP Pavilion ZV6100", 1510 .ident = "HP Pavilion ZV6100",
@@ -1532,8 +1512,8 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1532 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1512 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1533 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion ZV6100"), 1513 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion ZV6100"),
1534 }, 1514 },
1535 .callback = atkbd_setup_fixup, 1515 .callback = atkbd_setup_forced_release,
1536 .driver_data = atkbd_hp_zv6100_keymap_fixup, 1516 .driver_data = atkbd_hp_zv6100_forced_release_keys,
1537 }, 1517 },
1538 { 1518 {
1539 .ident = "Inventec Symphony", 1519 .ident = "Inventec Symphony",
@@ -1541,8 +1521,8 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1541 DMI_MATCH(DMI_SYS_VENDOR, "INVENTEC"), 1521 DMI_MATCH(DMI_SYS_VENDOR, "INVENTEC"),
1542 DMI_MATCH(DMI_PRODUCT_NAME, "SYMPHONY 6.0/7.0"), 1522 DMI_MATCH(DMI_PRODUCT_NAME, "SYMPHONY 6.0/7.0"),
1543 }, 1523 },
1544 .callback = atkbd_setup_fixup, 1524 .callback = atkbd_setup_forced_release,
1545 .driver_data = atkbd_inventec_keymap_fixup, 1525 .driver_data = atkbd_inventec_forced_release_keys,
1546 }, 1526 },
1547 { 1527 {
1548 .ident = "Samsung NC10", 1528 .ident = "Samsung NC10",
@@ -1550,8 +1530,17 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1550 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 1530 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1551 DMI_MATCH(DMI_PRODUCT_NAME, "NC10"), 1531 DMI_MATCH(DMI_PRODUCT_NAME, "NC10"),
1552 }, 1532 },
1553 .callback = atkbd_setup_fixup, 1533 .callback = atkbd_setup_forced_release,
1554 .driver_data = atkbd_samsung_keymap_fixup, 1534 .driver_data = atkbd_samsung_forced_release_keys,
1535 },
1536 {
1537 .ident = "Fujitsu Amilo PA 1510",
1538 .matches = {
1539 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1540 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pa 1510"),
1541 },
1542 .callback = atkbd_setup_forced_release,
1543 .driver_data = atkbd_amilo_pa1510_forced_release_keys,
1555 }, 1544 },
1556 { } 1545 { }
1557}; 1546};
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index ee855c5202e8..e94b7d735aca 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -211,8 +211,8 @@ static int __devinit bfin_kpad_probe(struct platform_device *pdev)
211 211
212 if (!pdata->debounce_time || pdata->debounce_time > MAX_MULT || 212 if (!pdata->debounce_time || pdata->debounce_time > MAX_MULT ||
213 !pdata->coldrive_time || pdata->coldrive_time > MAX_MULT) { 213 !pdata->coldrive_time || pdata->coldrive_time > MAX_MULT) {
214 printk(KERN_ERR DRV_NAME 214 printk(KERN_WARNING DRV_NAME
215 ": Invalid Debounce/Columdrive Time from pdata\n"); 215 ": Invalid Debounce/Columndrive Time in platform data\n");
216 bfin_write_KPAD_MSEL(0xFF0); /* Default MSEL */ 216 bfin_write_KPAD_MSEL(0xFF0); /* Default MSEL */
217 } else { 217 } else {
218 bfin_write_KPAD_MSEL( 218 bfin_write_KPAD_MSEL(
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
index aacf71f3cd44..e9d639ec283d 100644
--- a/drivers/input/keyboard/hilkbd.c
+++ b/drivers/input/keyboard/hilkbd.c
@@ -198,45 +198,28 @@ static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len)
198} 198}
199 199
200 200
201/* initialise HIL */ 201/* initialize HIL */
202static int __init 202static int __devinit hil_keyb_init(void)
203hil_keyb_init(void)
204{ 203{
205 unsigned char c; 204 unsigned char c;
206 unsigned int i, kbid; 205 unsigned int i, kbid;
207 wait_queue_head_t hil_wait; 206 wait_queue_head_t hil_wait;
208 int err; 207 int err;
209 208
210 if (hil_dev.dev) { 209 if (hil_dev.dev)
211 return -ENODEV; /* already initialized */ 210 return -ENODEV; /* already initialized */
212 }
213 211
212 init_waitqueue_head(&hil_wait);
214 spin_lock_init(&hil_dev.lock); 213 spin_lock_init(&hil_dev.lock);
214
215 hil_dev.dev = input_allocate_device(); 215 hil_dev.dev = input_allocate_device();
216 if (!hil_dev.dev) 216 if (!hil_dev.dev)
217 return -ENOMEM; 217 return -ENOMEM;
218 218
219#if defined(CONFIG_HP300)
220 if (!MACH_IS_HP300) {
221 err = -ENODEV;
222 goto err1;
223 }
224 if (!hwreg_present((void *)(HILBASE + HIL_DATA))) {
225 printk(KERN_ERR "HIL: hardware register was not found\n");
226 err = -ENODEV;
227 goto err1;
228 }
229 if (!request_region(HILBASE + HIL_DATA, 2, "hil")) {
230 printk(KERN_ERR "HIL: IOPORT region already used\n");
231 err = -EIO;
232 goto err1;
233 }
234#endif
235
236 err = request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id); 219 err = request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id);
237 if (err) { 220 if (err) {
238 printk(KERN_ERR "HIL: Can't get IRQ\n"); 221 printk(KERN_ERR "HIL: Can't get IRQ\n");
239 goto err2; 222 goto err1;
240 } 223 }
241 224
242 /* Turn on interrupts */ 225 /* Turn on interrupts */
@@ -246,11 +229,9 @@ hil_keyb_init(void)
246 hil_dev.valid = 0; /* clear any pending data */ 229 hil_dev.valid = 0; /* clear any pending data */
247 hil_do(HIL_READKBDSADR, NULL, 0); 230 hil_do(HIL_READKBDSADR, NULL, 0);
248 231
249 init_waitqueue_head(&hil_wait); 232 wait_event_interruptible_timeout(hil_wait, hil_dev.valid, 3 * HZ);
250 wait_event_interruptible_timeout(hil_wait, hil_dev.valid, 3*HZ); 233 if (!hil_dev.valid)
251 if (!hil_dev.valid) {
252 printk(KERN_WARNING "HIL: timed out, assuming no keyboard present\n"); 234 printk(KERN_WARNING "HIL: timed out, assuming no keyboard present\n");
253 }
254 235
255 c = hil_dev.c; 236 c = hil_dev.c;
256 hil_dev.valid = 0; 237 hil_dev.valid = 0;
@@ -268,7 +249,7 @@ hil_keyb_init(void)
268 249
269 for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++) 250 for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++)
270 if (hphilkeyb_keycode[i] != KEY_RESERVED) 251 if (hphilkeyb_keycode[i] != KEY_RESERVED)
271 set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit); 252 __set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit);
272 253
273 hil_dev.dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 254 hil_dev.dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
274 hil_dev.dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) | 255 hil_dev.dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) |
@@ -287,34 +268,45 @@ hil_keyb_init(void)
287 err = input_register_device(hil_dev.dev); 268 err = input_register_device(hil_dev.dev);
288 if (err) { 269 if (err) {
289 printk(KERN_ERR "HIL: Can't register device\n"); 270 printk(KERN_ERR "HIL: Can't register device\n");
290 goto err3; 271 goto err2;
291 } 272 }
273
292 printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n", 274 printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n",
293 hil_dev.dev->name, kbid, HILBASE, HIL_IRQ); 275 hil_dev.dev->name, kbid, HILBASE, HIL_IRQ);
294 276
295 return 0; 277 return 0;
296 278
297err3: 279err2:
298 hil_do(HIL_INTOFF, NULL, 0); 280 hil_do(HIL_INTOFF, NULL, 0);
299 disable_irq(HIL_IRQ);
300 free_irq(HIL_IRQ, hil_dev.dev_id); 281 free_irq(HIL_IRQ, hil_dev.dev_id);
301err2:
302#if defined(CONFIG_HP300)
303 release_region(HILBASE + HIL_DATA, 2);
304err1: 282err1:
305#endif
306 input_free_device(hil_dev.dev); 283 input_free_device(hil_dev.dev);
307 hil_dev.dev = NULL; 284 hil_dev.dev = NULL;
308 return err; 285 return err;
309} 286}
310 287
288static void __devexit hil_keyb_exit(void)
289{
290 if (HIL_IRQ)
291 free_irq(HIL_IRQ, hil_dev.dev_id);
292
293 /* Turn off interrupts */
294 hil_do(HIL_INTOFF, NULL, 0);
295
296 input_unregister_device(hil_dev.dev);
297 hil_dev.dev = NULL;
298}
311 299
312#if defined(CONFIG_PARISC) 300#if defined(CONFIG_PARISC)
313static int __init 301static int __devinit hil_probe_chip(struct parisc_device *dev)
314hil_init_chip(struct parisc_device *dev)
315{ 302{
303 /* Only allow one HIL keyboard */
304 if (hil_dev.dev)
305 return -ENODEV;
306
316 if (!dev->irq) { 307 if (!dev->irq) {
317 printk(KERN_WARNING "HIL: IRQ not found for HIL bus at 0x%08lx\n", dev->hpa.start); 308 printk(KERN_WARNING "HIL: IRQ not found for HIL bus at 0x%p\n",
309 (void *)dev->hpa.start);
318 return -ENODEV; 310 return -ENODEV;
319 } 311 }
320 312
@@ -327,51 +319,79 @@ hil_init_chip(struct parisc_device *dev)
327 return hil_keyb_init(); 319 return hil_keyb_init();
328} 320}
329 321
322static int __devexit hil_remove_chip(struct parisc_device *dev)
323{
324 hil_keyb_exit();
325
326 return 0;
327}
328
330static struct parisc_device_id hil_tbl[] = { 329static struct parisc_device_id hil_tbl[] = {
331 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00073 }, 330 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00073 },
332 { 0, } 331 { 0, }
333}; 332};
334 333
334#if 0
335/* Disabled to avoid conflicts with the HP SDC HIL drivers */
335MODULE_DEVICE_TABLE(parisc, hil_tbl); 336MODULE_DEVICE_TABLE(parisc, hil_tbl);
337#endif
336 338
337static struct parisc_driver hil_driver = { 339static struct parisc_driver hil_driver = {
338 .name = "hil", 340 .name = "hil",
339 .id_table = hil_tbl, 341 .id_table = hil_tbl,
340 .probe = hil_init_chip, 342 .probe = hil_probe_chip,
343 .remove = __devexit_p(hil_remove_chip),
341}; 344};
342#endif /* CONFIG_PARISC */
343
344 345
345static int __init hil_init(void) 346static int __init hil_init(void)
346{ 347{
347#if defined(CONFIG_PARISC)
348 return register_parisc_driver(&hil_driver); 348 return register_parisc_driver(&hil_driver);
349#else
350 return hil_keyb_init();
351#endif
352} 349}
353 350
354
355static void __exit hil_exit(void) 351static void __exit hil_exit(void)
356{ 352{
357 if (HIL_IRQ) { 353 unregister_parisc_driver(&hil_driver);
358 disable_irq(HIL_IRQ); 354}
359 free_irq(HIL_IRQ, hil_dev.dev_id); 355
356#else /* !CONFIG_PARISC */
357
358static int __init hil_init(void)
359{
360 int error;
361
362 /* Only allow one HIL keyboard */
363 if (hil_dev.dev)
364 return -EBUSY;
365
366 if (!MACH_IS_HP300)
367 return -ENODEV;
368
369 if (!hwreg_present((void *)(HILBASE + HIL_DATA))) {
370 printk(KERN_ERR "HIL: hardware register was not found\n");
371 return -ENODEV;
360 } 372 }
361 373
362 /* Turn off interrupts */ 374 if (!request_region(HILBASE + HIL_DATA, 2, "hil")) {
363 hil_do(HIL_INTOFF, NULL, 0); 375 printk(KERN_ERR "HIL: IOPORT region already used\n");
376 return -EIO;
377 }
364 378
365 input_unregister_device(hil_dev.dev); 379 error = hil_keyb_init();
380 if (error) {
381 release_region(HILBASE + HIL_DATA, 2);
382 return error;
383 }
366 384
367 hil_dev.dev = NULL; 385 return 0;
386}
368 387
369#if defined(CONFIG_PARISC) 388static void __exit hil_exit(void)
370 unregister_parisc_driver(&hil_driver); 389{
371#else 390 hil_keyb_exit();
372 release_region(HILBASE+HIL_DATA, 2); 391 release_region(HILBASE + HIL_DATA, 2);
373#endif
374} 392}
375 393
394#endif /* CONFIG_PARISC */
395
376module_init(hil_init); 396module_init(hil_init);
377module_exit(hil_exit); 397module_exit(hil_exit);
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 67e5553f699a..203abac1e23e 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -227,4 +227,27 @@ config INPUT_PCF50633_PMU
227 Say Y to include support for delivering PMU events via input 227 Say Y to include support for delivering PMU events via input
228 layer on NXP PCF50633. 228 layer on NXP PCF50633.
229 229
230config INPUT_GPIO_ROTARY_ENCODER
231 tristate "Rotary encoders connected to GPIO pins"
232 depends on GPIOLIB && GENERIC_GPIO
233 help
234 Say Y here to add support for rotary encoders connected to GPIO lines.
235 Check file:Documentation/incput/rotary_encoder.txt for more
236 information.
237
238 To compile this driver as a module, choose M here: the
239 module will be called rotary_encoder.
240
241config INPUT_RB532_BUTTON
242 tristate "Mikrotik Routerboard 532 button interface"
243 depends on MIKROTIK_RB532
244 depends on GPIOLIB && GENERIC_GPIO
245 select INPUT_POLLDEV
246 help
247 Say Y here if you want support for the S1 button built into
248 Mikrotik's Routerboard 532.
249
250 To compile this driver as a module, choose M here: the
251 module will be called rb532_button.
252
230endif 253endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index bb62e6efacf3..eb3f407baedf 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -4,21 +4,23 @@
4 4
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o 7obj-$(CONFIG_INPUT_APANEL) += apanel.o
8obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
9obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o
10obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o
11obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o
12obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
13obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
14obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o 8obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o
15obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o 9obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
16obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o 10obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
17obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
18obj-$(CONFIG_INPUT_YEALINK) += yealink.o
19obj-$(CONFIG_INPUT_CM109) += cm109.o 11obj-$(CONFIG_INPUT_CM109) += cm109.o
12obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o
20obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 13obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
21obj-$(CONFIG_INPUT_UINPUT) += uinput.o 14obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o
22obj-$(CONFIG_INPUT_APANEL) += apanel.o 15obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o
23obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 16obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o
24obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o 17obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
18obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
19obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
20obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
21obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
22obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
23obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o
24obj-$(CONFIG_INPUT_UINPUT) += uinput.o
25obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
26obj-$(CONFIG_INPUT_YEALINK) += yealink.o
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 3c9988dc0e9f..922c05141585 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -31,12 +31,73 @@ MODULE_LICENSE("GPL");
31 * newly configured "channel". 31 * newly configured "channel".
32 */ 32 */
33 33
34static unsigned int channel_mask = 0xFFFF; 34enum {
35module_param(channel_mask, uint, 0644); 35 ATI_REMOTE2_MAX_CHANNEL_MASK = 0xFFFF,
36 ATI_REMOTE2_MAX_MODE_MASK = 0x1F,
37};
38
39static int ati_remote2_set_mask(const char *val,
40 struct kernel_param *kp, unsigned int max)
41{
42 unsigned long mask;
43 int ret;
44
45 if (!val)
46 return -EINVAL;
47
48 ret = strict_strtoul(val, 0, &mask);
49 if (ret)
50 return ret;
51
52 if (mask & ~max)
53 return -EINVAL;
54
55 *(unsigned int *)kp->arg = mask;
56
57 return 0;
58}
59
60static int ati_remote2_set_channel_mask(const char *val,
61 struct kernel_param *kp)
62{
63 pr_debug("%s()\n", __func__);
64
65 return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_CHANNEL_MASK);
66}
67
68static int ati_remote2_get_channel_mask(char *buffer, struct kernel_param *kp)
69{
70 pr_debug("%s()\n", __func__);
71
72 return sprintf(buffer, "0x%04x", *(unsigned int *)kp->arg);
73}
74
75static int ati_remote2_set_mode_mask(const char *val, struct kernel_param *kp)
76{
77 pr_debug("%s()\n", __func__);
78
79 return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_MODE_MASK);
80}
81
82static int ati_remote2_get_mode_mask(char *buffer, struct kernel_param *kp)
83{
84 pr_debug("%s()\n", __func__);
85
86 return sprintf(buffer, "0x%02x", *(unsigned int *)kp->arg);
87}
88
89static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK;
90#define param_check_channel_mask(name, p) __param_check(name, p, unsigned int)
91#define param_set_channel_mask ati_remote2_set_channel_mask
92#define param_get_channel_mask ati_remote2_get_channel_mask
93module_param(channel_mask, channel_mask, 0644);
36MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>"); 94MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>");
37 95
38static unsigned int mode_mask = 0x1F; 96static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK;
39module_param(mode_mask, uint, 0644); 97#define param_check_mode_mask(name, p) __param_check(name, p, unsigned int)
98#define param_set_mode_mask ati_remote2_set_mode_mask
99#define param_get_mode_mask ati_remote2_get_mode_mask
100module_param(mode_mask, mode_mask, 0644);
40MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>"); 101MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>");
41 102
42static struct usb_device_id ati_remote2_id_table[] = { 103static struct usb_device_id ati_remote2_id_table[] = {
@@ -133,12 +194,18 @@ struct ati_remote2 {
133 u16 keycode[ATI_REMOTE2_MODES][ARRAY_SIZE(ati_remote2_key_table)]; 194 u16 keycode[ATI_REMOTE2_MODES][ARRAY_SIZE(ati_remote2_key_table)];
134 195
135 unsigned int flags; 196 unsigned int flags;
197
198 unsigned int channel_mask;
199 unsigned int mode_mask;
136}; 200};
137 201
138static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); 202static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id);
139static void ati_remote2_disconnect(struct usb_interface *interface); 203static void ati_remote2_disconnect(struct usb_interface *interface);
140static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message); 204static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message);
141static int ati_remote2_resume(struct usb_interface *interface); 205static int ati_remote2_resume(struct usb_interface *interface);
206static int ati_remote2_reset_resume(struct usb_interface *interface);
207static int ati_remote2_pre_reset(struct usb_interface *interface);
208static int ati_remote2_post_reset(struct usb_interface *interface);
142 209
143static struct usb_driver ati_remote2_driver = { 210static struct usb_driver ati_remote2_driver = {
144 .name = "ati_remote2", 211 .name = "ati_remote2",
@@ -147,6 +214,9 @@ static struct usb_driver ati_remote2_driver = {
147 .id_table = ati_remote2_id_table, 214 .id_table = ati_remote2_id_table,
148 .suspend = ati_remote2_suspend, 215 .suspend = ati_remote2_suspend,
149 .resume = ati_remote2_resume, 216 .resume = ati_remote2_resume,
217 .reset_resume = ati_remote2_reset_resume,
218 .pre_reset = ati_remote2_pre_reset,
219 .post_reset = ati_remote2_post_reset,
150 .supports_autosuspend = 1, 220 .supports_autosuspend = 1,
151}; 221};
152 222
@@ -238,7 +308,7 @@ static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
238 308
239 channel = data[0] >> 4; 309 channel = data[0] >> 4;
240 310
241 if (!((1 << channel) & channel_mask)) 311 if (!((1 << channel) & ar2->channel_mask))
242 return; 312 return;
243 313
244 mode = data[0] & 0x0F; 314 mode = data[0] & 0x0F;
@@ -250,7 +320,7 @@ static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
250 return; 320 return;
251 } 321 }
252 322
253 if (!((1 << mode) & mode_mask)) 323 if (!((1 << mode) & ar2->mode_mask))
254 return; 324 return;
255 325
256 input_event(idev, EV_REL, REL_X, (s8) data[1]); 326 input_event(idev, EV_REL, REL_X, (s8) data[1]);
@@ -277,7 +347,7 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2)
277 347
278 channel = data[0] >> 4; 348 channel = data[0] >> 4;
279 349
280 if (!((1 << channel) & channel_mask)) 350 if (!((1 << channel) & ar2->channel_mask))
281 return; 351 return;
282 352
283 mode = data[0] & 0x0F; 353 mode = data[0] & 0x0F;
@@ -305,7 +375,7 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2)
305 ar2->mode = mode; 375 ar2->mode = mode;
306 } 376 }
307 377
308 if (!((1 << mode) & mode_mask)) 378 if (!((1 << mode) & ar2->mode_mask))
309 return; 379 return;
310 380
311 index = ati_remote2_lookup(hw_code); 381 index = ati_remote2_lookup(hw_code);
@@ -410,7 +480,7 @@ static int ati_remote2_getkeycode(struct input_dev *idev,
410 int index, mode; 480 int index, mode;
411 481
412 mode = scancode >> 8; 482 mode = scancode >> 8;
413 if (mode > ATI_REMOTE2_PC || !((1 << mode) & mode_mask)) 483 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
414 return -EINVAL; 484 return -EINVAL;
415 485
416 index = ati_remote2_lookup(scancode & 0xFF); 486 index = ati_remote2_lookup(scancode & 0xFF);
@@ -427,7 +497,7 @@ static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keyc
427 int index, mode, old_keycode; 497 int index, mode, old_keycode;
428 498
429 mode = scancode >> 8; 499 mode = scancode >> 8;
430 if (mode > ATI_REMOTE2_PC || !((1 << mode) & mode_mask)) 500 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
431 return -EINVAL; 501 return -EINVAL;
432 502
433 index = ati_remote2_lookup(scancode & 0xFF); 503 index = ati_remote2_lookup(scancode & 0xFF);
@@ -550,7 +620,7 @@ static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2)
550 } 620 }
551} 621}
552 622
553static int ati_remote2_setup(struct ati_remote2 *ar2) 623static int ati_remote2_setup(struct ati_remote2 *ar2, unsigned int ch_mask)
554{ 624{
555 int r, i, channel; 625 int r, i, channel;
556 626
@@ -565,8 +635,8 @@ static int ati_remote2_setup(struct ati_remote2 *ar2)
565 635
566 channel = 0; 636 channel = 0;
567 for (i = 0; i < 16; i++) { 637 for (i = 0; i < 16; i++) {
568 if ((1 << i) & channel_mask) { 638 if ((1 << i) & ch_mask) {
569 if (!(~(1 << i) & 0xFFFF & channel_mask)) 639 if (!(~(1 << i) & ch_mask))
570 channel = i + 1; 640 channel = i + 1;
571 break; 641 break;
572 } 642 }
@@ -585,6 +655,99 @@ static int ati_remote2_setup(struct ati_remote2 *ar2)
585 return 0; 655 return 0;
586} 656}
587 657
658static ssize_t ati_remote2_show_channel_mask(struct device *dev,
659 struct device_attribute *attr,
660 char *buf)
661{
662 struct usb_device *udev = to_usb_device(dev);
663 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
664 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
665
666 return sprintf(buf, "0x%04x\n", ar2->channel_mask);
667}
668
669static ssize_t ati_remote2_store_channel_mask(struct device *dev,
670 struct device_attribute *attr,
671 const char *buf, size_t count)
672{
673 struct usb_device *udev = to_usb_device(dev);
674 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
675 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
676 unsigned long mask;
677 int r;
678
679 if (strict_strtoul(buf, 0, &mask))
680 return -EINVAL;
681
682 if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK)
683 return -EINVAL;
684
685 r = usb_autopm_get_interface(ar2->intf[0]);
686 if (r) {
687 dev_err(&ar2->intf[0]->dev,
688 "%s(): usb_autopm_get_interface() = %d\n", __func__, r);
689 return r;
690 }
691
692 mutex_lock(&ati_remote2_mutex);
693
694 if (mask != ar2->channel_mask && !ati_remote2_setup(ar2, mask))
695 ar2->channel_mask = mask;
696
697 mutex_unlock(&ati_remote2_mutex);
698
699 usb_autopm_put_interface(ar2->intf[0]);
700
701 return count;
702}
703
704static ssize_t ati_remote2_show_mode_mask(struct device *dev,
705 struct device_attribute *attr,
706 char *buf)
707{
708 struct usb_device *udev = to_usb_device(dev);
709 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
710 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
711
712 return sprintf(buf, "0x%02x\n", ar2->mode_mask);
713}
714
715static ssize_t ati_remote2_store_mode_mask(struct device *dev,
716 struct device_attribute *attr,
717 const char *buf, size_t count)
718{
719 struct usb_device *udev = to_usb_device(dev);
720 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
721 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
722 unsigned long mask;
723
724 if (strict_strtoul(buf, 0, &mask))
725 return -EINVAL;
726
727 if (mask & ~ATI_REMOTE2_MAX_MODE_MASK)
728 return -EINVAL;
729
730 ar2->mode_mask = mask;
731
732 return count;
733}
734
735static DEVICE_ATTR(channel_mask, 0644, ati_remote2_show_channel_mask,
736 ati_remote2_store_channel_mask);
737
738static DEVICE_ATTR(mode_mask, 0644, ati_remote2_show_mode_mask,
739 ati_remote2_store_mode_mask);
740
741static struct attribute *ati_remote2_attrs[] = {
742 &dev_attr_channel_mask.attr,
743 &dev_attr_mode_mask.attr,
744 NULL,
745};
746
747static struct attribute_group ati_remote2_attr_group = {
748 .attrs = ati_remote2_attrs,
749};
750
588static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id) 751static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id)
589{ 752{
590 struct usb_device *udev = interface_to_usbdev(interface); 753 struct usb_device *udev = interface_to_usbdev(interface);
@@ -615,7 +778,10 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
615 if (r) 778 if (r)
616 goto fail2; 779 goto fail2;
617 780
618 r = ati_remote2_setup(ar2); 781 ar2->channel_mask = channel_mask;
782 ar2->mode_mask = mode_mask;
783
784 r = ati_remote2_setup(ar2, ar2->channel_mask);
619 if (r) 785 if (r)
620 goto fail2; 786 goto fail2;
621 787
@@ -624,19 +790,24 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
624 790
625 strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name)); 791 strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name));
626 792
627 r = ati_remote2_input_init(ar2); 793 r = sysfs_create_group(&udev->dev.kobj, &ati_remote2_attr_group);
628 if (r) 794 if (r)
629 goto fail2; 795 goto fail2;
630 796
797 r = ati_remote2_input_init(ar2);
798 if (r)
799 goto fail3;
800
631 usb_set_intfdata(interface, ar2); 801 usb_set_intfdata(interface, ar2);
632 802
633 interface->needs_remote_wakeup = 1; 803 interface->needs_remote_wakeup = 1;
634 804
635 return 0; 805 return 0;
636 806
807 fail3:
808 sysfs_remove_group(&udev->dev.kobj, &ati_remote2_attr_group);
637 fail2: 809 fail2:
638 ati_remote2_urb_cleanup(ar2); 810 ati_remote2_urb_cleanup(ar2);
639
640 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); 811 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
641 fail1: 812 fail1:
642 kfree(ar2); 813 kfree(ar2);
@@ -657,6 +828,8 @@ static void ati_remote2_disconnect(struct usb_interface *interface)
657 828
658 input_unregister_device(ar2->idev); 829 input_unregister_device(ar2->idev);
659 830
831 sysfs_remove_group(&ar2->udev->dev.kobj, &ati_remote2_attr_group);
832
660 ati_remote2_urb_cleanup(ar2); 833 ati_remote2_urb_cleanup(ar2);
661 834
662 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); 835 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
@@ -715,6 +888,78 @@ static int ati_remote2_resume(struct usb_interface *interface)
715 return r; 888 return r;
716} 889}
717 890
891static int ati_remote2_reset_resume(struct usb_interface *interface)
892{
893 struct ati_remote2 *ar2;
894 struct usb_host_interface *alt = interface->cur_altsetting;
895 int r = 0;
896
897 if (alt->desc.bInterfaceNumber)
898 return 0;
899
900 ar2 = usb_get_intfdata(interface);
901
902 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
903
904 mutex_lock(&ati_remote2_mutex);
905
906 r = ati_remote2_setup(ar2, ar2->channel_mask);
907 if (r)
908 goto out;
909
910 if (ar2->flags & ATI_REMOTE2_OPENED)
911 r = ati_remote2_submit_urbs(ar2);
912
913 if (!r)
914 ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
915
916 out:
917 mutex_unlock(&ati_remote2_mutex);
918
919 return r;
920}
921
922static int ati_remote2_pre_reset(struct usb_interface *interface)
923{
924 struct ati_remote2 *ar2;
925 struct usb_host_interface *alt = interface->cur_altsetting;
926
927 if (alt->desc.bInterfaceNumber)
928 return 0;
929
930 ar2 = usb_get_intfdata(interface);
931
932 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
933
934 mutex_lock(&ati_remote2_mutex);
935
936 if (ar2->flags == ATI_REMOTE2_OPENED)
937 ati_remote2_kill_urbs(ar2);
938
939 return 0;
940}
941
942static int ati_remote2_post_reset(struct usb_interface *interface)
943{
944 struct ati_remote2 *ar2;
945 struct usb_host_interface *alt = interface->cur_altsetting;
946 int r = 0;
947
948 if (alt->desc.bInterfaceNumber)
949 return 0;
950
951 ar2 = usb_get_intfdata(interface);
952
953 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
954
955 if (ar2->flags == ATI_REMOTE2_OPENED)
956 r = ati_remote2_submit_urbs(ar2);
957
958 mutex_unlock(&ati_remote2_mutex);
959
960 return r;
961}
962
718static int __init ati_remote2_init(void) 963static int __init ati_remote2_init(void)
719{ 964{
720 int r; 965 int r;
diff --git a/drivers/input/misc/rb532_button.c b/drivers/input/misc/rb532_button.c
new file mode 100644
index 000000000000..e2c7f622a0b5
--- /dev/null
+++ b/drivers/input/misc/rb532_button.c
@@ -0,0 +1,120 @@
1/*
2 * Support for the S1 button on Routerboard 532
3 *
4 * Copyright (C) 2009 Phil Sutter <n0-1@freewrt.org>
5 */
6
7#include <linux/input-polldev.h>
8#include <linux/module.h>
9#include <linux/platform_device.h>
10
11#include <asm/mach-rc32434/gpio.h>
12#include <asm/mach-rc32434/rb.h>
13
14#define DRV_NAME "rb532-button"
15
16#define RB532_BTN_RATE 100 /* msec */
17#define RB532_BTN_KSYM BTN_0
18
19/* The S1 button state is provided by GPIO pin 1. But as this
20 * pin is also used for uart input as alternate function, the
21 * operational modes must be switched first:
22 * 1) disable uart using set_latch_u5()
23 * 2) turn off alternate function implicitly through
24 * gpio_direction_input()
25 * 3) read the GPIO's current value
26 * 4) undo step 2 by enabling alternate function (in this
27 * mode the GPIO direction is fixed, so no change needed)
28 * 5) turn on uart again
29 * The GPIO value occurs to be inverted, so pin high means
30 * button is not pressed.
31 */
32static bool rb532_button_pressed(void)
33{
34 int val;
35
36 set_latch_u5(0, LO_FOFF);
37 gpio_direction_input(GPIO_BTN_S1);
38
39 val = gpio_get_value(GPIO_BTN_S1);
40
41 rb532_gpio_set_func(GPIO_BTN_S1);
42 set_latch_u5(LO_FOFF, 0);
43
44 return !val;
45}
46
47static void rb532_button_poll(struct input_polled_dev *poll_dev)
48{
49 input_report_key(poll_dev->input, RB532_BTN_KSYM,
50 rb532_button_pressed());
51 input_sync(poll_dev->input);
52}
53
54static int __devinit rb532_button_probe(struct platform_device *pdev)
55{
56 struct input_polled_dev *poll_dev;
57 int error;
58
59 poll_dev = input_allocate_polled_device();
60 if (!poll_dev)
61 return -ENOMEM;
62
63 poll_dev->poll = rb532_button_poll;
64 poll_dev->poll_interval = RB532_BTN_RATE;
65
66 poll_dev->input->name = "rb532 button";
67 poll_dev->input->phys = "rb532/button0";
68 poll_dev->input->id.bustype = BUS_HOST;
69 poll_dev->input->dev.parent = &pdev->dev;
70
71 dev_set_drvdata(&pdev->dev, poll_dev);
72
73 input_set_capability(poll_dev->input, EV_KEY, RB532_BTN_KSYM);
74
75 error = input_register_polled_device(poll_dev);
76 if (error) {
77 input_free_polled_device(poll_dev);
78 return error;
79 }
80
81 return 0;
82}
83
84static int __devexit rb532_button_remove(struct platform_device *pdev)
85{
86 struct input_polled_dev *poll_dev = dev_get_drvdata(&pdev->dev);
87
88 input_unregister_polled_device(poll_dev);
89 input_free_polled_device(poll_dev);
90 dev_set_drvdata(&pdev->dev, NULL);
91
92 return 0;
93}
94
95static struct platform_driver rb532_button_driver = {
96 .probe = rb532_button_probe,
97 .remove = __devexit_p(rb532_button_remove),
98 .driver = {
99 .name = DRV_NAME,
100 .owner = THIS_MODULE,
101 },
102};
103
104static int __init rb532_button_init(void)
105{
106 return platform_driver_register(&rb532_button_driver);
107}
108
109static void __exit rb532_button_exit(void)
110{
111 platform_driver_unregister(&rb532_button_driver);
112}
113
114module_init(rb532_button_init);
115module_exit(rb532_button_exit);
116
117MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>");
118MODULE_LICENSE("GPL");
119MODULE_DESCRIPTION("Support for S1 button on Routerboard 532");
120MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
new file mode 100644
index 000000000000..5bb3ab51b8c6
--- /dev/null
+++ b/drivers/input/misc/rotary_encoder.c
@@ -0,0 +1,221 @@
1/*
2 * rotary_encoder.c
3 *
4 * (c) 2009 Daniel Mack <daniel@caiaq.de>
5 *
6 * state machine code inspired by code from Tim Ruetz
7 *
8 * A generic driver for rotary encoders connected to GPIO lines.
9 * See file:Documentation/input/rotary_encoder.txt for more information
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/init.h>
19#include <linux/interrupt.h>
20#include <linux/input.h>
21#include <linux/device.h>
22#include <linux/platform_device.h>
23#include <linux/gpio.h>
24#include <linux/rotary_encoder.h>
25
26#define DRV_NAME "rotary-encoder"
27
28struct rotary_encoder {
29 unsigned int irq_a;
30 unsigned int irq_b;
31 unsigned int pos;
32 unsigned int armed;
33 unsigned int dir;
34 struct input_dev *input;
35 struct rotary_encoder_platform_data *pdata;
36};
37
38static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
39{
40 struct rotary_encoder *encoder = dev_id;
41 struct rotary_encoder_platform_data *pdata = encoder->pdata;
42 int a = !!gpio_get_value(pdata->gpio_a);
43 int b = !!gpio_get_value(pdata->gpio_b);
44 int state;
45
46 a ^= pdata->inverted_a;
47 b ^= pdata->inverted_b;
48 state = (a << 1) | b;
49
50 switch (state) {
51
52 case 0x0:
53 if (!encoder->armed)
54 break;
55
56 if (encoder->dir) {
57 /* turning counter-clockwise */
58 encoder->pos += pdata->steps;
59 encoder->pos--;
60 encoder->pos %= pdata->steps;
61 } else {
62 /* turning clockwise */
63 encoder->pos++;
64 encoder->pos %= pdata->steps;
65 }
66
67 input_report_abs(encoder->input, pdata->axis, encoder->pos);
68 input_sync(encoder->input);
69
70 encoder->armed = 0;
71 break;
72
73 case 0x1:
74 case 0x2:
75 if (encoder->armed)
76 encoder->dir = state - 1;
77 break;
78
79 case 0x3:
80 encoder->armed = 1;
81 break;
82 }
83
84 return IRQ_HANDLED;
85}
86
87static int __devinit rotary_encoder_probe(struct platform_device *pdev)
88{
89 struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data;
90 struct rotary_encoder *encoder;
91 struct input_dev *input;
92 int err;
93
94 if (!pdata || !pdata->steps) {
95 dev_err(&pdev->dev, "invalid platform data\n");
96 return -ENOENT;
97 }
98
99 encoder = kzalloc(sizeof(struct rotary_encoder), GFP_KERNEL);
100 input = input_allocate_device();
101 if (!encoder || !input) {
102 dev_err(&pdev->dev, "failed to allocate memory for device\n");
103 err = -ENOMEM;
104 goto exit_free_mem;
105 }
106
107 encoder->input = input;
108 encoder->pdata = pdata;
109 encoder->irq_a = gpio_to_irq(pdata->gpio_a);
110 encoder->irq_b = gpio_to_irq(pdata->gpio_b);
111
112 /* create and register the input driver */
113 input->name = pdev->name;
114 input->id.bustype = BUS_HOST;
115 input->dev.parent = &pdev->dev;
116 input->evbit[0] = BIT_MASK(EV_ABS);
117 input_set_abs_params(encoder->input,
118 pdata->axis, 0, pdata->steps, 0, 1);
119
120 err = input_register_device(input);
121 if (err) {
122 dev_err(&pdev->dev, "failed to register input device\n");
123 goto exit_free_mem;
124 }
125
126 /* request the GPIOs */
127 err = gpio_request(pdata->gpio_a, DRV_NAME);
128 if (err) {
129 dev_err(&pdev->dev, "unable to request GPIO %d\n",
130 pdata->gpio_a);
131 goto exit_unregister_input;
132 }
133
134 err = gpio_request(pdata->gpio_b, DRV_NAME);
135 if (err) {
136 dev_err(&pdev->dev, "unable to request GPIO %d\n",
137 pdata->gpio_b);
138 goto exit_free_gpio_a;
139 }
140
141 /* request the IRQs */
142 err = request_irq(encoder->irq_a, &rotary_encoder_irq,
143 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
144 DRV_NAME, encoder);
145 if (err) {
146 dev_err(&pdev->dev, "unable to request IRQ %d\n",
147 encoder->irq_a);
148 goto exit_free_gpio_b;
149 }
150
151 err = request_irq(encoder->irq_b, &rotary_encoder_irq,
152 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
153 DRV_NAME, encoder);
154 if (err) {
155 dev_err(&pdev->dev, "unable to request IRQ %d\n",
156 encoder->irq_b);
157 goto exit_free_irq_a;
158 }
159
160 platform_set_drvdata(pdev, encoder);
161
162 return 0;
163
164exit_free_irq_a:
165 free_irq(encoder->irq_a, encoder);
166exit_free_gpio_b:
167 gpio_free(pdata->gpio_b);
168exit_free_gpio_a:
169 gpio_free(pdata->gpio_a);
170exit_unregister_input:
171 input_unregister_device(input);
172 input = NULL; /* so we don't try to free it */
173exit_free_mem:
174 input_free_device(input);
175 kfree(encoder);
176 return err;
177}
178
179static int __devexit rotary_encoder_remove(struct platform_device *pdev)
180{
181 struct rotary_encoder *encoder = platform_get_drvdata(pdev);
182 struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data;
183
184 free_irq(encoder->irq_a, encoder);
185 free_irq(encoder->irq_b, encoder);
186 gpio_free(pdata->gpio_a);
187 gpio_free(pdata->gpio_b);
188 input_unregister_device(encoder->input);
189 platform_set_drvdata(pdev, NULL);
190 kfree(encoder);
191
192 return 0;
193}
194
195static struct platform_driver rotary_encoder_driver = {
196 .probe = rotary_encoder_probe,
197 .remove = __devexit_p(rotary_encoder_remove),
198 .driver = {
199 .name = DRV_NAME,
200 .owner = THIS_MODULE,
201 }
202};
203
204static int __init rotary_encoder_init(void)
205{
206 return platform_driver_register(&rotary_encoder_driver);
207}
208
209static void __exit rotary_encoder_exit(void)
210{
211 platform_driver_unregister(&rotary_encoder_driver);
212}
213
214module_init(rotary_encoder_init);
215module_exit(rotary_encoder_exit);
216
217MODULE_ALIAS("platform:" DRV_NAME);
218MODULE_DESCRIPTION("GPIO rotary encoder driver");
219MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
220MODULE_LICENSE("GPL v2");
221
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 4f38e6f7dfdd..c66cc3d08c2f 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -292,4 +292,15 @@ config MOUSE_PXA930_TRKBALL
292 help 292 help
293 Say Y here to support PXA930 Trackball mouse. 293 Say Y here to support PXA930 Trackball mouse.
294 294
295config MOUSE_MAPLE
296 tristate "Maple mouse (for the Dreamcast)"
297 depends on MAPLE
298 help
299 This driver supports the Maple mouse on the SEGA Dreamcast.
300
301 Most Dreamcast users, who have a mouse, will say Y here.
302
303 To compile this driver as a module choose M here: the module will be
304 called maplemouse.
305
295endif 306endif
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 8c8a1f236e28..472189468d67 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -6,18 +6,19 @@
6 6
7obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o 7obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o
8obj-$(CONFIG_MOUSE_APPLETOUCH) += appletouch.o 8obj-$(CONFIG_MOUSE_APPLETOUCH) += appletouch.o
9obj-$(CONFIG_MOUSE_BCM5974) += bcm5974.o
10obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o 9obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o
11obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o 10obj-$(CONFIG_MOUSE_BCM5974) += bcm5974.o
11obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse.o
12obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
12obj-$(CONFIG_MOUSE_INPORT) += inport.o 13obj-$(CONFIG_MOUSE_INPORT) += inport.o
13obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o 14obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
15obj-$(CONFIG_MOUSE_MAPLE) += maplemouse.o
14obj-$(CONFIG_MOUSE_PC110PAD) += pc110pad.o 16obj-$(CONFIG_MOUSE_PC110PAD) += pc110pad.o
15obj-$(CONFIG_MOUSE_PS2) += psmouse.o 17obj-$(CONFIG_MOUSE_PS2) += psmouse.o
16obj-$(CONFIG_MOUSE_PXA930_TRKBALL) += pxa930_trkball.o 18obj-$(CONFIG_MOUSE_PXA930_TRKBALL) += pxa930_trkball.o
19obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o
17obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o 20obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o
18obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
19obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o 21obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o
20obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse.o
21 22
22psmouse-objs := psmouse-base.o synaptics.o 23psmouse-objs := psmouse-base.o synaptics.o
23 24
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index 55cd0fa68339..a1ad2f1a7bb3 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -472,7 +472,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)
472 return -EIO; 472 return -EIO;
473 } 473 }
474 474
475 hgpk_dbg(psmouse, "ID: %02x %02x %02x", param[0], param[1], param[2]); 475 hgpk_dbg(psmouse, "ID: %02x %02x %02x\n", param[0], param[1], param[2]);
476 476
477 /* HGPK signature: 0x67, 0x00, 0x<model> */ 477 /* HGPK signature: 0x67, 0x00, 0x<model> */
478 if (param[0] != 0x67 || param[1] != 0x00) 478 if (param[0] != 0x67 || param[1] != 0x00)
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
new file mode 100644
index 000000000000..d196abfb68bc
--- /dev/null
+++ b/drivers/input/mouse/maplemouse.c
@@ -0,0 +1,147 @@
1/*
2 * SEGA Dreamcast mouse driver
3 * Based on drivers/usb/usbmouse.c
4 *
5 * Copyright Yaegashi Takeshi, 2001
6 * Adrian McMenamin, 2008
7 */
8
9#include <linux/kernel.h>
10#include <linux/slab.h>
11#include <linux/input.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/timer.h>
15#include <linux/maple.h>
16
17MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk>");
18MODULE_DESCRIPTION("SEGA Dreamcast mouse driver");
19MODULE_LICENSE("GPL");
20
21struct dc_mouse {
22 struct input_dev *dev;
23 struct maple_device *mdev;
24};
25
26static void dc_mouse_callback(struct mapleq *mq)
27{
28 int buttons, relx, rely, relz;
29 struct maple_device *mapledev = mq->dev;
30 struct dc_mouse *mse = maple_get_drvdata(mapledev);
31 struct input_dev *dev = mse->dev;
32 unsigned char *res = mq->recvbuf;
33
34 buttons = ~res[8];
35 relx = *(unsigned short *)(res + 12) - 512;
36 rely = *(unsigned short *)(res + 14) - 512;
37 relz = *(unsigned short *)(res + 16) - 512;
38
39 input_report_key(dev, BTN_LEFT, buttons & 4);
40 input_report_key(dev, BTN_MIDDLE, buttons & 9);
41 input_report_key(dev, BTN_RIGHT, buttons & 2);
42 input_report_rel(dev, REL_X, relx);
43 input_report_rel(dev, REL_Y, rely);
44 input_report_rel(dev, REL_WHEEL, relz);
45 input_sync(dev);
46}
47
48static int dc_mouse_open(struct input_dev *dev)
49{
50 struct dc_mouse *mse = dev->dev.platform_data;
51
52 maple_getcond_callback(mse->mdev, dc_mouse_callback, HZ/50,
53 MAPLE_FUNC_MOUSE);
54
55 return 0;
56}
57
58static void dc_mouse_close(struct input_dev *dev)
59{
60 struct dc_mouse *mse = dev->dev.platform_data;
61
62 maple_getcond_callback(mse->mdev, dc_mouse_callback, 0,
63 MAPLE_FUNC_MOUSE);
64}
65
66
67static int __devinit probe_maple_mouse(struct device *dev)
68{
69 struct maple_device *mdev = to_maple_dev(dev);
70 struct maple_driver *mdrv = to_maple_driver(dev->driver);
71 struct input_dev *input_dev;
72 struct dc_mouse *mse;
73 int error;
74
75 mse = kzalloc(sizeof(struct dc_mouse), GFP_KERNEL);
76 input_dev = input_allocate_device();
77
78 if (!mse || !input_dev) {
79 error = -ENOMEM;
80 goto fail;
81 }
82
83 mse->dev = input_dev;
84 mse->mdev = mdev;
85
86 input_set_drvdata(input_dev, mse);
87 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
88 input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
89 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
90 input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) |
91 BIT_MASK(REL_WHEEL);
92 input_dev->name = mdev->product_name;
93 input_dev->id.bustype = BUS_HOST;
94 input_dev->open = dc_mouse_open;
95 input_dev->close = dc_mouse_close;
96
97 mdev->driver = mdrv;
98 maple_set_drvdata(mdev, mse);
99
100 error = input_register_device(input_dev);
101 if (error)
102 goto fail;
103
104 return 0;
105
106fail:
107 input_free_device(input_dev);
108 maple_set_drvdata(mdev, NULL);
109 kfree(mse);
110 mdev->driver = NULL;
111 return error;
112}
113
114static int __devexit remove_maple_mouse(struct device *dev)
115{
116 struct maple_device *mdev = to_maple_dev(dev);
117 struct dc_mouse *mse = maple_get_drvdata(mdev);
118
119 mdev->callback = NULL;
120 input_unregister_device(mse->dev);
121 maple_set_drvdata(mdev, NULL);
122 kfree(mse);
123
124 return 0;
125}
126
127static struct maple_driver dc_mouse_driver = {
128 .function = MAPLE_FUNC_MOUSE,
129 .drv = {
130 .name = "Dreamcast_mouse",
131 .probe = probe_maple_mouse,
132 .remove = __devexit_p(remove_maple_mouse),
133 },
134};
135
136static int __init dc_mouse_init(void)
137{
138 return maple_driver_register(&dc_mouse_driver);
139}
140
141static void __exit dc_mouse_exit(void)
142{
143 maple_driver_unregister(&dc_mouse_driver);
144}
145
146module_init(dc_mouse_init);
147module_exit(dc_mouse_exit);
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
index fd09c8df81f2..f63995f854ff 100644
--- a/drivers/input/mouse/pc110pad.c
+++ b/drivers/input/mouse/pc110pad.c
@@ -111,11 +111,8 @@ static int __init pc110pad_init(void)
111 struct pci_dev *dev; 111 struct pci_dev *dev;
112 int err; 112 int err;
113 113
114 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); 114 if (!no_pci_devices())
115 if (dev) {
116 pci_dev_put(dev);
117 return -ENODEV; 115 return -ENODEV;
118 }
119 116
120 if (!request_region(pc110pad_io, 4, "pc110pad")) { 117 if (!request_region(pc110pad_io, 4, "pc110pad")) {
121 printk(KERN_ERR "pc110pad: I/O area %#x-%#x in use.\n", 118 printk(KERN_ERR "pc110pad: I/O area %#x-%#x in use.\n",
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 6fa2deff7446..83ed2d56b924 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -151,6 +151,14 @@ static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
151 DMI_MATCH(DMI_PRODUCT_VERSION, "01"), 151 DMI_MATCH(DMI_PRODUCT_VERSION, "01"),
152 }, 152 },
153 }, 153 },
154 {
155 .ident = "HP DV9700",
156 .matches = {
157 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
158 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
159 DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"),
160 },
161 },
154 { } 162 { }
155}; 163};
156 164
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index bb6486a8c070..b01fd61dadcc 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -29,6 +29,51 @@ config TOUCHSCREEN_ADS7846
29 To compile this driver as a module, choose M here: the 29 To compile this driver as a module, choose M here: the
30 module will be called ads7846. 30 module will be called ads7846.
31 31
32config TOUCHSCREEN_AD7877
33 tristate "AD7877 based touchscreens"
34 depends on SPI_MASTER
35 help
36 Say Y here if you have a touchscreen interface using the
37 AD7877 controller, and your board-specific initialization
38 code includes that in its table of SPI devices.
39
40 If unsure, say N (but it's safe to say "Y").
41
42 To compile this driver as a module, choose M here: the
43 module will be called ad7877.
44
45config TOUCHSCREEN_AD7879_I2C
46 tristate "AD7879 based touchscreens: AD7879-1 I2C Interface"
47 depends on I2C
48 select TOUCHSCREEN_AD7879
49 help
50 Say Y here if you have a touchscreen interface using the
51 AD7879-1 controller, and your board-specific initialization
52 code includes that in its table of I2C devices.
53
54 If unsure, say N (but it's safe to say "Y").
55
56 To compile this driver as a module, choose M here: the
57 module will be called ad7879.
58
59config TOUCHSCREEN_AD7879_SPI
60 tristate "AD7879 based touchscreens: AD7879 SPI Interface"
61 depends on SPI_MASTER && TOUCHSCREEN_AD7879_I2C = n
62 select TOUCHSCREEN_AD7879
63 help
64 Say Y here if you have a touchscreen interface using the
65 AD7879 controller, and your board-specific initialization
66 code includes that in its table of SPI devices.
67
68 If unsure, say N (but it's safe to say "Y").
69
70 To compile this driver as a module, choose M here: the
71 module will be called ad7879.
72
73config TOUCHSCREEN_AD7879
74 tristate
75 default n
76
32config TOUCHSCREEN_BITSY 77config TOUCHSCREEN_BITSY
33 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" 78 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen"
34 depends on SA1100_BITSY 79 depends on SA1100_BITSY
@@ -308,6 +353,19 @@ config TOUCHSCREEN_WM97XX_MAINSTONE
308 To compile this driver as a module, choose M here: the 353 To compile this driver as a module, choose M here: the
309 module will be called mainstone-wm97xx. 354 module will be called mainstone-wm97xx.
310 355
356config TOUCHSCREEN_WM97XX_ZYLONITE
357 tristate "Zylonite accelerated touch"
358 depends on TOUCHSCREEN_WM97XX && MACH_ZYLONITE
359 select TOUCHSCREEN_WM9713
360 help
361 Say Y here for support for streaming mode with the touchscreen
362 on Zylonite systems.
363
364 If unsure, say N.
365
366 To compile this driver as a module, choose M here: the
367 module will be called zylonite-wm97xx.
368
311config TOUCHSCREEN_USB_COMPOSITE 369config TOUCHSCREEN_USB_COMPOSITE
312 tristate "USB Touchscreen Driver" 370 tristate "USB Touchscreen Driver"
313 depends on USB_ARCH_HAS_HCD 371 depends on USB_ARCH_HAS_HCD
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index d3375aff46fe..6700f7b9d165 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -6,6 +6,8 @@
6 6
7wm97xx-ts-y := wm97xx-core.o 7wm97xx-ts-y := wm97xx-core.o
8 8
9obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o
10obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o
9obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 11obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
10obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 12obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
11obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 13obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
@@ -34,3 +36,4 @@ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o
34wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o 36wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o
35wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o 37wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o
36obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o 38obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o
39obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
new file mode 100644
index 000000000000..e4728a28f492
--- /dev/null
+++ b/drivers/input/touchscreen/ad7877.c
@@ -0,0 +1,844 @@
1/*
2 * Copyright (C) 2006-2008 Michael Hennerich, Analog Devices Inc.
3 *
4 * Description: AD7877 based touchscreen, sensor (ADCs), DAC and GPIO driver
5 * Based on: ads7846.c
6 *
7 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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 as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see the file COPYING, or write
21 * to the Free Software Foundation, Inc.,
22 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 *
24 * History:
25 * Copyright (c) 2005 David Brownell
26 * Copyright (c) 2006 Nokia Corporation
27 * Various changes: Imre Deak <imre.deak@nokia.com>
28 *
29 * Using code from:
30 * - corgi_ts.c
31 * Copyright (C) 2004-2005 Richard Purdie
32 * - omap_ts.[hc], ads7846.h, ts_osk.c
33 * Copyright (C) 2002 MontaVista Software
34 * Copyright (C) 2004 Texas Instruments
35 * Copyright (C) 2005 Dirk Behme
36 */
37
38
39#include <linux/device.h>
40#include <linux/init.h>
41#include <linux/delay.h>
42#include <linux/input.h>
43#include <linux/interrupt.h>
44#include <linux/slab.h>
45#include <linux/spi/spi.h>
46#include <linux/spi/ad7877.h>
47#include <asm/irq.h>
48
49#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50)
50
51#define MAX_SPI_FREQ_HZ 20000000
52#define MAX_12BIT ((1<<12)-1)
53
54#define AD7877_REG_ZEROS 0
55#define AD7877_REG_CTRL1 1
56#define AD7877_REG_CTRL2 2
57#define AD7877_REG_ALERT 3
58#define AD7877_REG_AUX1HIGH 4
59#define AD7877_REG_AUX1LOW 5
60#define AD7877_REG_BAT1HIGH 6
61#define AD7877_REG_BAT1LOW 7
62#define AD7877_REG_BAT2HIGH 8
63#define AD7877_REG_BAT2LOW 9
64#define AD7877_REG_TEMP1HIGH 10
65#define AD7877_REG_TEMP1LOW 11
66#define AD7877_REG_SEQ0 12
67#define AD7877_REG_SEQ1 13
68#define AD7877_REG_DAC 14
69#define AD7877_REG_NONE1 15
70#define AD7877_REG_EXTWRITE 15
71#define AD7877_REG_XPLUS 16
72#define AD7877_REG_YPLUS 17
73#define AD7877_REG_Z2 18
74#define AD7877_REG_aux1 19
75#define AD7877_REG_aux2 20
76#define AD7877_REG_aux3 21
77#define AD7877_REG_bat1 22
78#define AD7877_REG_bat2 23
79#define AD7877_REG_temp1 24
80#define AD7877_REG_temp2 25
81#define AD7877_REG_Z1 26
82#define AD7877_REG_GPIOCTRL1 27
83#define AD7877_REG_GPIOCTRL2 28
84#define AD7877_REG_GPIODATA 29
85#define AD7877_REG_NONE2 30
86#define AD7877_REG_NONE3 31
87
88#define AD7877_SEQ_YPLUS_BIT (1<<11)
89#define AD7877_SEQ_XPLUS_BIT (1<<10)
90#define AD7877_SEQ_Z2_BIT (1<<9)
91#define AD7877_SEQ_AUX1_BIT (1<<8)
92#define AD7877_SEQ_AUX2_BIT (1<<7)
93#define AD7877_SEQ_AUX3_BIT (1<<6)
94#define AD7877_SEQ_BAT1_BIT (1<<5)
95#define AD7877_SEQ_BAT2_BIT (1<<4)
96#define AD7877_SEQ_TEMP1_BIT (1<<3)
97#define AD7877_SEQ_TEMP2_BIT (1<<2)
98#define AD7877_SEQ_Z1_BIT (1<<1)
99
100enum {
101 AD7877_SEQ_YPOS = 0,
102 AD7877_SEQ_XPOS = 1,
103 AD7877_SEQ_Z2 = 2,
104 AD7877_SEQ_AUX1 = 3,
105 AD7877_SEQ_AUX2 = 4,
106 AD7877_SEQ_AUX3 = 5,
107 AD7877_SEQ_BAT1 = 6,
108 AD7877_SEQ_BAT2 = 7,
109 AD7877_SEQ_TEMP1 = 8,
110 AD7877_SEQ_TEMP2 = 9,
111 AD7877_SEQ_Z1 = 10,
112 AD7877_NR_SENSE = 11,
113};
114
115/* DAC Register Default RANGE 0 to Vcc, Volatge Mode, DAC On */
116#define AD7877_DAC_CONF 0x1
117
118/* If gpio3 is set AUX3/GPIO3 acts as GPIO Output */
119#define AD7877_EXTW_GPIO_3_CONF 0x1C4
120#define AD7877_EXTW_GPIO_DATA 0x200
121
122/* Control REG 2 */
123#define AD7877_TMR(x) ((x & 0x3) << 0)
124#define AD7877_REF(x) ((x & 0x1) << 2)
125#define AD7877_POL(x) ((x & 0x1) << 3)
126#define AD7877_FCD(x) ((x & 0x3) << 4)
127#define AD7877_PM(x) ((x & 0x3) << 6)
128#define AD7877_ACQ(x) ((x & 0x3) << 8)
129#define AD7877_AVG(x) ((x & 0x3) << 10)
130
131/* Control REG 1 */
132#define AD7877_SER (1 << 11) /* non-differential */
133#define AD7877_DFR (0 << 11) /* differential */
134
135#define AD7877_MODE_NOC (0) /* Do not convert */
136#define AD7877_MODE_SCC (1) /* Single channel conversion */
137#define AD7877_MODE_SEQ0 (2) /* Sequence 0 in Slave Mode */
138#define AD7877_MODE_SEQ1 (3) /* Sequence 1 in Master Mode */
139
140#define AD7877_CHANADD(x) ((x&0xF)<<7)
141#define AD7877_READADD(x) ((x)<<2)
142#define AD7877_WRITEADD(x) ((x)<<12)
143
144#define AD7877_READ_CHAN(x) (AD7877_WRITEADD(AD7877_REG_CTRL1) | AD7877_SER | \
145 AD7877_MODE_SCC | AD7877_CHANADD(AD7877_REG_ ## x) | \
146 AD7877_READADD(AD7877_REG_ ## x))
147
148#define AD7877_MM_SEQUENCE (AD7877_SEQ_YPLUS_BIT | AD7877_SEQ_XPLUS_BIT | \
149 AD7877_SEQ_Z2_BIT | AD7877_SEQ_Z1_BIT)
150
151/*
152 * Non-touchscreen sensors only use single-ended conversions.
153 */
154
155struct ser_req {
156 u16 reset;
157 u16 ref_on;
158 u16 command;
159 u16 sample;
160 struct spi_message msg;
161 struct spi_transfer xfer[6];
162};
163
164struct ad7877 {
165 struct input_dev *input;
166 char phys[32];
167
168 struct spi_device *spi;
169 u16 model;
170 u16 vref_delay_usecs;
171 u16 x_plate_ohms;
172 u16 pressure_max;
173
174 u16 cmd_crtl1;
175 u16 cmd_crtl2;
176 u16 cmd_dummy;
177 u16 dac;
178
179 u8 stopacq_polarity;
180 u8 first_conversion_delay;
181 u8 acquisition_time;
182 u8 averaging;
183 u8 pen_down_acc_interval;
184
185 u16 conversion_data[AD7877_NR_SENSE];
186
187 struct spi_transfer xfer[AD7877_NR_SENSE + 2];
188 struct spi_message msg;
189
190 struct mutex mutex;
191 unsigned disabled:1; /* P: mutex */
192 unsigned gpio3:1; /* P: mutex */
193 unsigned gpio4:1; /* P: mutex */
194
195 spinlock_t lock;
196 struct timer_list timer; /* P: lock */
197 unsigned pending:1; /* P: lock */
198};
199
200static int gpio3;
201module_param(gpio3, int, 0);
202MODULE_PARM_DESC(gpio3, "If gpio3 is set to 1 AUX3 acts as GPIO3");
203
204/*
205 * ad7877_read/write are only used for initial setup and for sysfs controls.
206 * The main traffic is done using spi_async() in the interrupt handler.
207 */
208
209static int ad7877_read(struct spi_device *spi, u16 reg)
210{
211 struct ser_req *req;
212 int status, ret;
213
214 req = kzalloc(sizeof *req, GFP_KERNEL);
215 if (!req)
216 return -ENOMEM;
217
218 spi_message_init(&req->msg);
219
220 req->command = (u16) (AD7877_WRITEADD(AD7877_REG_CTRL1) |
221 AD7877_READADD(reg));
222 req->xfer[0].tx_buf = &req->command;
223 req->xfer[0].len = 2;
224
225 req->xfer[1].rx_buf = &req->sample;
226 req->xfer[1].len = 2;
227
228 spi_message_add_tail(&req->xfer[0], &req->msg);
229 spi_message_add_tail(&req->xfer[1], &req->msg);
230
231 status = spi_sync(spi, &req->msg);
232 ret = status ? : req->sample;
233
234 kfree(req);
235
236 return ret;
237}
238
239static int ad7877_write(struct spi_device *spi, u16 reg, u16 val)
240{
241 struct ser_req *req;
242 int status;
243
244 req = kzalloc(sizeof *req, GFP_KERNEL);
245 if (!req)
246 return -ENOMEM;
247
248 spi_message_init(&req->msg);
249
250 req->command = (u16) (AD7877_WRITEADD(reg) | (val & MAX_12BIT));
251 req->xfer[0].tx_buf = &req->command;
252 req->xfer[0].len = 2;
253
254 spi_message_add_tail(&req->xfer[0], &req->msg);
255
256 status = spi_sync(spi, &req->msg);
257
258 kfree(req);
259
260 return status;
261}
262
263static int ad7877_read_adc(struct spi_device *spi, unsigned command)
264{
265 struct ad7877 *ts = dev_get_drvdata(&spi->dev);
266 struct ser_req *req;
267 int status;
268 int sample;
269 int i;
270
271 req = kzalloc(sizeof *req, GFP_KERNEL);
272 if (!req)
273 return -ENOMEM;
274
275 spi_message_init(&req->msg);
276
277 /* activate reference, so it has time to settle; */
278 req->ref_on = AD7877_WRITEADD(AD7877_REG_CTRL2) |
279 AD7877_POL(ts->stopacq_polarity) |
280 AD7877_AVG(0) | AD7877_PM(2) | AD7877_TMR(0) |
281 AD7877_ACQ(ts->acquisition_time) | AD7877_FCD(0);
282
283 req->reset = AD7877_WRITEADD(AD7877_REG_CTRL1) | AD7877_MODE_NOC;
284
285 req->command = (u16) command;
286
287 req->xfer[0].tx_buf = &req->reset;
288 req->xfer[0].len = 2;
289
290 req->xfer[1].tx_buf = &req->ref_on;
291 req->xfer[1].len = 2;
292 req->xfer[1].delay_usecs = ts->vref_delay_usecs;
293
294 req->xfer[2].tx_buf = &req->command;
295 req->xfer[2].len = 2;
296 req->xfer[2].delay_usecs = ts->vref_delay_usecs;
297
298 req->xfer[3].rx_buf = &req->sample;
299 req->xfer[3].len = 2;
300
301 req->xfer[4].tx_buf = &ts->cmd_crtl2; /*REF OFF*/
302 req->xfer[4].len = 2;
303
304 req->xfer[5].tx_buf = &ts->cmd_crtl1; /*DEFAULT*/
305 req->xfer[5].len = 2;
306
307 /* group all the transfers together, so we can't interfere with
308 * reading touchscreen state; disable penirq while sampling
309 */
310 for (i = 0; i < 6; i++)
311 spi_message_add_tail(&req->xfer[i], &req->msg);
312
313 status = spi_sync(spi, &req->msg);
314 sample = req->sample;
315
316 kfree(req);
317
318 return status ? : sample;
319}
320
321static void ad7877_rx(struct ad7877 *ts)
322{
323 struct input_dev *input_dev = ts->input;
324 unsigned Rt;
325 u16 x, y, z1, z2;
326
327 x = ts->conversion_data[AD7877_SEQ_XPOS] & MAX_12BIT;
328 y = ts->conversion_data[AD7877_SEQ_YPOS] & MAX_12BIT;
329 z1 = ts->conversion_data[AD7877_SEQ_Z1] & MAX_12BIT;
330 z2 = ts->conversion_data[AD7877_SEQ_Z2] & MAX_12BIT;
331
332 /*
333 * The samples processed here are already preprocessed by the AD7877.
334 * The preprocessing function consists of an averaging filter.
335 * The combination of 'first conversion delay' and averaging provides a robust solution,
336 * discarding the spurious noise in the signal and keeping only the data of interest.
337 * The size of the averaging filter is programmable. (dev.platform_data, see linux/spi/ad7877.h)
338 * Other user-programmable conversion controls include variable acquisition time,
339 * and first conversion delay. Up to 16 averages can be taken per conversion.
340 */
341
342 if (likely(x && z1)) {
343 /* compute touch pressure resistance using equation #1 */
344 Rt = (z2 - z1) * x * ts->x_plate_ohms;
345 Rt /= z1;
346 Rt = (Rt + 2047) >> 12;
347
348 input_report_abs(input_dev, ABS_X, x);
349 input_report_abs(input_dev, ABS_Y, y);
350 input_report_abs(input_dev, ABS_PRESSURE, Rt);
351 input_sync(input_dev);
352 }
353}
354
355static inline void ad7877_ts_event_release(struct ad7877 *ts)
356{
357 struct input_dev *input_dev = ts->input;
358
359 input_report_abs(input_dev, ABS_PRESSURE, 0);
360 input_sync(input_dev);
361}
362
363static void ad7877_timer(unsigned long handle)
364{
365 struct ad7877 *ts = (void *)handle;
366
367 ad7877_ts_event_release(ts);
368}
369
370static irqreturn_t ad7877_irq(int irq, void *handle)
371{
372 struct ad7877 *ts = handle;
373 unsigned long flags;
374 int status;
375
376 /*
377 * The repeated conversion sequencer controlled by TMR kicked off
378 * too fast. We ignore the last and process the sample sequence
379 * currently in the queue. It can't be older than 9.4ms, and we
380 * need to avoid that ts->msg doesn't get issued twice while in work.
381 */
382
383 spin_lock_irqsave(&ts->lock, flags);
384 if (!ts->pending) {
385 ts->pending = 1;
386
387 status = spi_async(ts->spi, &ts->msg);
388 if (status)
389 dev_err(&ts->spi->dev, "spi_sync --> %d\n", status);
390 }
391 spin_unlock_irqrestore(&ts->lock, flags);
392
393 return IRQ_HANDLED;
394}
395
396static void ad7877_callback(void *_ts)
397{
398 struct ad7877 *ts = _ts;
399
400 spin_lock_irq(&ts->lock);
401
402 ad7877_rx(ts);
403 ts->pending = 0;
404 mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
405
406 spin_unlock_irq(&ts->lock);
407}
408
409static void ad7877_disable(struct ad7877 *ts)
410{
411 mutex_lock(&ts->mutex);
412
413 if (!ts->disabled) {
414 ts->disabled = 1;
415 disable_irq(ts->spi->irq);
416
417 /* Wait for spi_async callback */
418 while (ts->pending)
419 msleep(1);
420
421 if (del_timer_sync(&ts->timer))
422 ad7877_ts_event_release(ts);
423 }
424
425 /* we know the chip's in lowpower mode since we always
426 * leave it that way after every request
427 */
428
429 mutex_unlock(&ts->mutex);
430}
431
432static void ad7877_enable(struct ad7877 *ts)
433{
434 mutex_lock(&ts->mutex);
435
436 if (ts->disabled) {
437 ts->disabled = 0;
438 enable_irq(ts->spi->irq);
439 }
440
441 mutex_unlock(&ts->mutex);
442}
443
444#define SHOW(name) static ssize_t \
445name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
446{ \
447 struct ad7877 *ts = dev_get_drvdata(dev); \
448 ssize_t v = ad7877_read_adc(ts->spi, \
449 AD7877_READ_CHAN(name)); \
450 if (v < 0) \
451 return v; \
452 return sprintf(buf, "%u\n", (unsigned) v); \
453} \
454static DEVICE_ATTR(name, S_IRUGO, name ## _show, NULL);
455
456SHOW(aux1)
457SHOW(aux2)
458SHOW(aux3)
459SHOW(bat1)
460SHOW(bat2)
461SHOW(temp1)
462SHOW(temp2)
463
464static ssize_t ad7877_disable_show(struct device *dev,
465 struct device_attribute *attr, char *buf)
466{
467 struct ad7877 *ts = dev_get_drvdata(dev);
468
469 return sprintf(buf, "%u\n", ts->disabled);
470}
471
472static ssize_t ad7877_disable_store(struct device *dev,
473 struct device_attribute *attr,
474 const char *buf, size_t count)
475{
476 struct ad7877 *ts = dev_get_drvdata(dev);
477 unsigned long val;
478 int error;
479
480 error = strict_strtoul(buf, 10, &val);
481 if (error)
482 return error;
483
484 if (val)
485 ad7877_disable(ts);
486 else
487 ad7877_enable(ts);
488
489 return count;
490}
491
492static DEVICE_ATTR(disable, 0664, ad7877_disable_show, ad7877_disable_store);
493
494static ssize_t ad7877_dac_show(struct device *dev,
495 struct device_attribute *attr, char *buf)
496{
497 struct ad7877 *ts = dev_get_drvdata(dev);
498
499 return sprintf(buf, "%u\n", ts->dac);
500}
501
502static ssize_t ad7877_dac_store(struct device *dev,
503 struct device_attribute *attr,
504 const char *buf, size_t count)
505{
506 struct ad7877 *ts = dev_get_drvdata(dev);
507 unsigned long val;
508 int error;
509
510 error = strict_strtoul(buf, 10, &val);
511 if (error)
512 return error;
513
514 mutex_lock(&ts->mutex);
515 ts->dac = val & 0xFF;
516 ad7877_write(ts->spi, AD7877_REG_DAC, (ts->dac << 4) | AD7877_DAC_CONF);
517 mutex_unlock(&ts->mutex);
518
519 return count;
520}
521
522static DEVICE_ATTR(dac, 0664, ad7877_dac_show, ad7877_dac_store);
523
524static ssize_t ad7877_gpio3_show(struct device *dev,
525 struct device_attribute *attr, char *buf)
526{
527 struct ad7877 *ts = dev_get_drvdata(dev);
528
529 return sprintf(buf, "%u\n", ts->gpio3);
530}
531
532static ssize_t ad7877_gpio3_store(struct device *dev,
533 struct device_attribute *attr,
534 const char *buf, size_t count)
535{
536 struct ad7877 *ts = dev_get_drvdata(dev);
537 unsigned long val;
538 int error;
539
540 error = strict_strtoul(buf, 10, &val);
541 if (error)
542 return error;
543
544 mutex_lock(&ts->mutex);
545 ts->gpio3 = !!val;
546 ad7877_write(ts->spi, AD7877_REG_EXTWRITE, AD7877_EXTW_GPIO_DATA |
547 (ts->gpio4 << 4) | (ts->gpio3 << 5));
548 mutex_unlock(&ts->mutex);
549
550 return count;
551}
552
553static DEVICE_ATTR(gpio3, 0664, ad7877_gpio3_show, ad7877_gpio3_store);
554
555static ssize_t ad7877_gpio4_show(struct device *dev,
556 struct device_attribute *attr, char *buf)
557{
558 struct ad7877 *ts = dev_get_drvdata(dev);
559
560 return sprintf(buf, "%u\n", ts->gpio4);
561}
562
563static ssize_t ad7877_gpio4_store(struct device *dev,
564 struct device_attribute *attr,
565 const char *buf, size_t count)
566{
567 struct ad7877 *ts = dev_get_drvdata(dev);
568 unsigned long val;
569 int error;
570
571 error = strict_strtoul(buf, 10, &val);
572 if (error)
573 return error;
574
575 mutex_lock(&ts->mutex);
576 ts->gpio4 = !!val;
577 ad7877_write(ts->spi, AD7877_REG_EXTWRITE, AD7877_EXTW_GPIO_DATA |
578 (ts->gpio4 << 4) | (ts->gpio3 << 5));
579 mutex_unlock(&ts->mutex);
580
581 return count;
582}
583
584static DEVICE_ATTR(gpio4, 0664, ad7877_gpio4_show, ad7877_gpio4_store);
585
586static struct attribute *ad7877_attributes[] = {
587 &dev_attr_temp1.attr,
588 &dev_attr_temp2.attr,
589 &dev_attr_aux1.attr,
590 &dev_attr_aux2.attr,
591 &dev_attr_bat1.attr,
592 &dev_attr_bat2.attr,
593 &dev_attr_disable.attr,
594 &dev_attr_dac.attr,
595 &dev_attr_gpio4.attr,
596 NULL
597};
598
599static const struct attribute_group ad7877_attr_group = {
600 .attrs = ad7877_attributes,
601};
602
603static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts)
604{
605 struct spi_message *m;
606 int i;
607
608 ts->cmd_crtl2 = AD7877_WRITEADD(AD7877_REG_CTRL2) |
609 AD7877_POL(ts->stopacq_polarity) |
610 AD7877_AVG(ts->averaging) | AD7877_PM(1) |
611 AD7877_TMR(ts->pen_down_acc_interval) |
612 AD7877_ACQ(ts->acquisition_time) |
613 AD7877_FCD(ts->first_conversion_delay);
614
615 ad7877_write(spi, AD7877_REG_CTRL2, ts->cmd_crtl2);
616
617 ts->cmd_crtl1 = AD7877_WRITEADD(AD7877_REG_CTRL1) |
618 AD7877_READADD(AD7877_REG_XPLUS-1) |
619 AD7877_MODE_SEQ1 | AD7877_DFR;
620
621 ad7877_write(spi, AD7877_REG_CTRL1, ts->cmd_crtl1);
622
623 ts->cmd_dummy = 0;
624
625 m = &ts->msg;
626
627 spi_message_init(m);
628
629 m->complete = ad7877_callback;
630 m->context = ts;
631
632 ts->xfer[0].tx_buf = &ts->cmd_crtl1;
633 ts->xfer[0].len = 2;
634
635 spi_message_add_tail(&ts->xfer[0], m);
636
637 ts->xfer[1].tx_buf = &ts->cmd_dummy; /* Send ZERO */
638 ts->xfer[1].len = 2;
639
640 spi_message_add_tail(&ts->xfer[1], m);
641
642 for (i = 0; i < 11; i++) {
643 ts->xfer[i + 2].rx_buf = &ts->conversion_data[AD7877_SEQ_YPOS + i];
644 ts->xfer[i + 2].len = 2;
645 spi_message_add_tail(&ts->xfer[i + 2], m);
646 }
647}
648
649static int __devinit ad7877_probe(struct spi_device *spi)
650{
651 struct ad7877 *ts;
652 struct input_dev *input_dev;
653 struct ad7877_platform_data *pdata = spi->dev.platform_data;
654 int err;
655 u16 verify;
656
657 if (!spi->irq) {
658 dev_dbg(&spi->dev, "no IRQ?\n");
659 return -ENODEV;
660 }
661
662 if (!pdata) {
663 dev_dbg(&spi->dev, "no platform data?\n");
664 return -ENODEV;
665 }
666
667 /* don't exceed max specified SPI CLK frequency */
668 if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) {
669 dev_dbg(&spi->dev, "SPI CLK %d Hz?\n",spi->max_speed_hz);
670 return -EINVAL;
671 }
672
673 ts = kzalloc(sizeof(struct ad7877), GFP_KERNEL);
674 input_dev = input_allocate_device();
675 if (!ts || !input_dev) {
676 err = -ENOMEM;
677 goto err_free_mem;
678 }
679
680 dev_set_drvdata(&spi->dev, ts);
681 ts->spi = spi;
682 ts->input = input_dev;
683
684 setup_timer(&ts->timer, ad7877_timer, (unsigned long) ts);
685 mutex_init(&ts->mutex);
686 spin_lock_init(&ts->lock);
687
688 ts->model = pdata->model ? : 7877;
689 ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
690 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
691 ts->pressure_max = pdata->pressure_max ? : ~0;
692
693 ts->stopacq_polarity = pdata->stopacq_polarity;
694 ts->first_conversion_delay = pdata->first_conversion_delay;
695 ts->acquisition_time = pdata->acquisition_time;
696 ts->averaging = pdata->averaging;
697 ts->pen_down_acc_interval = pdata->pen_down_acc_interval;
698
699 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&spi->dev));
700
701 input_dev->name = "AD7877 Touchscreen";
702 input_dev->phys = ts->phys;
703 input_dev->dev.parent = &spi->dev;
704
705 __set_bit(EV_ABS, input_dev->evbit);
706 __set_bit(ABS_X, input_dev->absbit);
707 __set_bit(ABS_Y, input_dev->absbit);
708 __set_bit(ABS_PRESSURE, input_dev->absbit);
709
710 input_set_abs_params(input_dev, ABS_X,
711 pdata->x_min ? : 0,
712 pdata->x_max ? : MAX_12BIT,
713 0, 0);
714 input_set_abs_params(input_dev, ABS_Y,
715 pdata->y_min ? : 0,
716 pdata->y_max ? : MAX_12BIT,
717 0, 0);
718 input_set_abs_params(input_dev, ABS_PRESSURE,
719 pdata->pressure_min, pdata->pressure_max, 0, 0);
720
721 ad7877_write(spi, AD7877_REG_SEQ1, AD7877_MM_SEQUENCE);
722
723 verify = ad7877_read(spi, AD7877_REG_SEQ1);
724
725 if (verify != AD7877_MM_SEQUENCE){
726 dev_err(&spi->dev, "%s: Failed to probe %s\n",
727 dev_name(&spi->dev), input_dev->name);
728 err = -ENODEV;
729 goto err_free_mem;
730 }
731
732 if (gpio3)
733 ad7877_write(spi, AD7877_REG_EXTWRITE, AD7877_EXTW_GPIO_3_CONF);
734
735 ad7877_setup_ts_def_msg(spi, ts);
736
737 /* Request AD7877 /DAV GPIO interrupt */
738
739 err = request_irq(spi->irq, ad7877_irq, IRQF_TRIGGER_FALLING |
740 IRQF_SAMPLE_RANDOM, spi->dev.driver->name, ts);
741 if (err) {
742 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
743 goto err_free_mem;
744 }
745
746 err = sysfs_create_group(&spi->dev.kobj, &ad7877_attr_group);
747 if (err)
748 goto err_free_irq;
749
750 err = device_create_file(&spi->dev,
751 gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3);
752 if (err)
753 goto err_remove_attr_group;
754
755 err = input_register_device(input_dev);
756 if (err)
757 goto err_remove_attr;
758
759 return 0;
760
761err_remove_attr:
762 device_remove_file(&spi->dev,
763 gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3);
764err_remove_attr_group:
765 sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
766err_free_irq:
767 free_irq(spi->irq, ts);
768err_free_mem:
769 input_free_device(input_dev);
770 kfree(ts);
771 dev_set_drvdata(&spi->dev, NULL);
772 return err;
773}
774
775static int __devexit ad7877_remove(struct spi_device *spi)
776{
777 struct ad7877 *ts = dev_get_drvdata(&spi->dev);
778
779 sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
780 device_remove_file(&spi->dev,
781 gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3);
782
783 ad7877_disable(ts);
784 free_irq(ts->spi->irq, ts);
785
786 input_unregister_device(ts->input);
787 kfree(ts);
788
789 dev_dbg(&spi->dev, "unregistered touchscreen\n");
790 dev_set_drvdata(&spi->dev, NULL);
791
792 return 0;
793}
794
795#ifdef CONFIG_PM
796static int ad7877_suspend(struct spi_device *spi, pm_message_t message)
797{
798 struct ad7877 *ts = dev_get_drvdata(&spi->dev);
799
800 ad7877_disable(ts);
801
802 return 0;
803}
804
805static int ad7877_resume(struct spi_device *spi)
806{
807 struct ad7877 *ts = dev_get_drvdata(&spi->dev);
808
809 ad7877_enable(ts);
810
811 return 0;
812}
813#else
814#define ad7877_suspend NULL
815#define ad7877_resume NULL
816#endif
817
818static struct spi_driver ad7877_driver = {
819 .driver = {
820 .name = "ad7877",
821 .bus = &spi_bus_type,
822 .owner = THIS_MODULE,
823 },
824 .probe = ad7877_probe,
825 .remove = __devexit_p(ad7877_remove),
826 .suspend = ad7877_suspend,
827 .resume = ad7877_resume,
828};
829
830static int __init ad7877_init(void)
831{
832 return spi_register_driver(&ad7877_driver);
833}
834module_init(ad7877_init);
835
836static void __exit ad7877_exit(void)
837{
838 spi_unregister_driver(&ad7877_driver);
839}
840module_exit(ad7877_exit);
841
842MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
843MODULE_DESCRIPTION("AD7877 touchscreen Driver");
844MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
new file mode 100644
index 000000000000..ea4c61d68683
--- /dev/null
+++ b/drivers/input/touchscreen/ad7879.c
@@ -0,0 +1,782 @@
1/*
2 * Copyright (C) 2008 Michael Hennerich, Analog Devices Inc.
3 *
4 * Description: AD7879 based touchscreen, and GPIO driver (I2C/SPI Interface)
5 *
6 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see the file COPYING, or write
20 * to the Free Software Foundation, Inc.,
21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * History:
24 * Copyright (c) 2005 David Brownell
25 * Copyright (c) 2006 Nokia Corporation
26 * Various changes: Imre Deak <imre.deak@nokia.com>
27 *
28 * Using code from:
29 * - corgi_ts.c
30 * Copyright (C) 2004-2005 Richard Purdie
31 * - omap_ts.[hc], ads7846.h, ts_osk.c
32 * Copyright (C) 2002 MontaVista Software
33 * Copyright (C) 2004 Texas Instruments
34 * Copyright (C) 2005 Dirk Behme
35 * - ad7877.c
36 * Copyright (C) 2006-2008 Analog Devices Inc.
37 */
38
39#include <linux/device.h>
40#include <linux/init.h>
41#include <linux/delay.h>
42#include <linux/input.h>
43#include <linux/interrupt.h>
44#include <linux/irq.h>
45#include <linux/slab.h>
46#include <linux/workqueue.h>
47#include <linux/spi/spi.h>
48#include <linux/i2c.h>
49
50#include <linux/spi/ad7879.h>
51
52#define AD7879_REG_ZEROS 0
53#define AD7879_REG_CTRL1 1
54#define AD7879_REG_CTRL2 2
55#define AD7879_REG_CTRL3 3
56#define AD7879_REG_AUX1HIGH 4
57#define AD7879_REG_AUX1LOW 5
58#define AD7879_REG_TEMP1HIGH 6
59#define AD7879_REG_TEMP1LOW 7
60#define AD7879_REG_XPLUS 8
61#define AD7879_REG_YPLUS 9
62#define AD7879_REG_Z1 10
63#define AD7879_REG_Z2 11
64#define AD7879_REG_AUXVBAT 12
65#define AD7879_REG_TEMP 13
66#define AD7879_REG_REVID 14
67
68/* Control REG 1 */
69#define AD7879_TMR(x) ((x & 0xFF) << 0)
70#define AD7879_ACQ(x) ((x & 0x3) << 8)
71#define AD7879_MODE_NOC (0 << 10) /* Do not convert */
72#define AD7879_MODE_SCC (1 << 10) /* Single channel conversion */
73#define AD7879_MODE_SEQ0 (2 << 10) /* Sequence 0 in Slave Mode */
74#define AD7879_MODE_SEQ1 (3 << 10) /* Sequence 1 in Master Mode */
75#define AD7879_MODE_INT (1 << 15) /* PENIRQ disabled INT enabled */
76
77/* Control REG 2 */
78#define AD7879_FCD(x) ((x & 0x3) << 0)
79#define AD7879_RESET (1 << 4)
80#define AD7879_MFS(x) ((x & 0x3) << 5)
81#define AD7879_AVG(x) ((x & 0x3) << 7)
82#define AD7879_SER (1 << 9) /* non-differential */
83#define AD7879_DFR (0 << 9) /* differential */
84#define AD7879_GPIOPOL (1 << 10)
85#define AD7879_GPIODIR (1 << 11)
86#define AD7879_GPIO_DATA (1 << 12)
87#define AD7879_GPIO_EN (1 << 13)
88#define AD7879_PM(x) ((x & 0x3) << 14)
89#define AD7879_PM_SHUTDOWN (0)
90#define AD7879_PM_DYN (1)
91#define AD7879_PM_FULLON (2)
92
93/* Control REG 3 */
94#define AD7879_TEMPMASK_BIT (1<<15)
95#define AD7879_AUXVBATMASK_BIT (1<<14)
96#define AD7879_INTMODE_BIT (1<<13)
97#define AD7879_GPIOALERTMASK_BIT (1<<12)
98#define AD7879_AUXLOW_BIT (1<<11)
99#define AD7879_AUXHIGH_BIT (1<<10)
100#define AD7879_TEMPLOW_BIT (1<<9)
101#define AD7879_TEMPHIGH_BIT (1<<8)
102#define AD7879_YPLUS_BIT (1<<7)
103#define AD7879_XPLUS_BIT (1<<6)
104#define AD7879_Z1_BIT (1<<5)
105#define AD7879_Z2_BIT (1<<4)
106#define AD7879_AUX_BIT (1<<3)
107#define AD7879_VBAT_BIT (1<<2)
108#define AD7879_TEMP_BIT (1<<1)
109
110enum {
111 AD7879_SEQ_XPOS = 0,
112 AD7879_SEQ_YPOS = 1,
113 AD7879_SEQ_Z1 = 2,
114 AD7879_SEQ_Z2 = 3,
115 AD7879_NR_SENSE = 4,
116};
117
118#define MAX_12BIT ((1<<12)-1)
119#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50)
120
121#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
122#define AD7879_DEVID 0x7A
123typedef struct spi_device bus_device;
124#elif defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
125#define AD7879_DEVID 0x79
126typedef struct i2c_client bus_device;
127#endif
128
129struct ad7879 {
130 bus_device *bus;
131 struct input_dev *input;
132 struct work_struct work;
133 struct timer_list timer;
134
135 struct mutex mutex;
136 unsigned disabled:1; /* P: mutex */
137
138#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
139 struct spi_message msg;
140 struct spi_transfer xfer[AD7879_NR_SENSE + 1];
141 u16 cmd;
142#endif
143 u16 conversion_data[AD7879_NR_SENSE];
144 char phys[32];
145 u8 first_conversion_delay;
146 u8 acquisition_time;
147 u8 averaging;
148 u8 pen_down_acc_interval;
149 u8 median;
150 u16 x_plate_ohms;
151 u16 pressure_max;
152 u16 gpio_init;
153 u16 cmd_crtl1;
154 u16 cmd_crtl2;
155 u16 cmd_crtl3;
156 unsigned gpio:1;
157};
158
159static int ad7879_read(bus_device *, u8);
160static int ad7879_write(bus_device *, u8, u16);
161static void ad7879_collect(struct ad7879 *);
162
163static void ad7879_report(struct ad7879 *ts)
164{
165 struct input_dev *input_dev = ts->input;
166 unsigned Rt;
167 u16 x, y, z1, z2;
168
169 x = ts->conversion_data[AD7879_SEQ_XPOS] & MAX_12BIT;
170 y = ts->conversion_data[AD7879_SEQ_YPOS] & MAX_12BIT;
171 z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT;
172 z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT;
173
174 /*
175 * The samples processed here are already preprocessed by the AD7879.
176 * The preprocessing function consists of a median and an averaging filter.
177 * The combination of these two techniques provides a robust solution,
178 * discarding the spurious noise in the signal and keeping only the data of interest.
179 * The size of both filters is programmable. (dev.platform_data, see linux/spi/ad7879.h)
180 * Other user-programmable conversion controls include variable acquisition time,
181 * and first conversion delay. Up to 16 averages can be taken per conversion.
182 */
183
184 if (likely(x && z1)) {
185 /* compute touch pressure resistance using equation #1 */
186 Rt = (z2 - z1) * x * ts->x_plate_ohms;
187 Rt /= z1;
188 Rt = (Rt + 2047) >> 12;
189
190 input_report_abs(input_dev, ABS_X, x);
191 input_report_abs(input_dev, ABS_Y, y);
192 input_report_abs(input_dev, ABS_PRESSURE, Rt);
193 input_sync(input_dev);
194 }
195}
196
197static void ad7879_work(struct work_struct *work)
198{
199 struct ad7879 *ts = container_of(work, struct ad7879, work);
200
201 /* use keventd context to read the result registers */
202 ad7879_collect(ts);
203 ad7879_report(ts);
204 mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
205}
206
207static void ad7879_ts_event_release(struct ad7879 *ts)
208{
209 struct input_dev *input_dev = ts->input;
210
211 input_report_abs(input_dev, ABS_PRESSURE, 0);
212 input_sync(input_dev);
213}
214
215static void ad7879_timer(unsigned long handle)
216{
217 struct ad7879 *ts = (void *)handle;
218
219 ad7879_ts_event_release(ts);
220}
221
222static irqreturn_t ad7879_irq(int irq, void *handle)
223{
224 struct ad7879 *ts = handle;
225
226 /* The repeated conversion sequencer controlled by TMR kicked off too fast.
227 * We ignore the last and process the sample sequence currently in the queue.
228 * It can't be older than 9.4ms
229 */
230
231 if (!work_pending(&ts->work))
232 schedule_work(&ts->work);
233
234 return IRQ_HANDLED;
235}
236
237static void ad7879_setup(struct ad7879 *ts)
238{
239 ts->cmd_crtl3 = AD7879_YPLUS_BIT |
240 AD7879_XPLUS_BIT |
241 AD7879_Z2_BIT |
242 AD7879_Z1_BIT |
243 AD7879_TEMPMASK_BIT |
244 AD7879_AUXVBATMASK_BIT |
245 AD7879_GPIOALERTMASK_BIT;
246
247 ts->cmd_crtl2 = AD7879_PM(AD7879_PM_DYN) | AD7879_DFR |
248 AD7879_AVG(ts->averaging) |
249 AD7879_MFS(ts->median) |
250 AD7879_FCD(ts->first_conversion_delay) |
251 ts->gpio_init;
252
253 ts->cmd_crtl1 = AD7879_MODE_INT | AD7879_MODE_SEQ1 |
254 AD7879_ACQ(ts->acquisition_time) |
255 AD7879_TMR(ts->pen_down_acc_interval);
256
257 ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2);
258 ad7879_write(ts->bus, AD7879_REG_CTRL3, ts->cmd_crtl3);
259 ad7879_write(ts->bus, AD7879_REG_CTRL1, ts->cmd_crtl1);
260}
261
262static void ad7879_disable(struct ad7879 *ts)
263{
264 mutex_lock(&ts->mutex);
265
266 if (!ts->disabled) {
267
268 ts->disabled = 1;
269 disable_irq(ts->bus->irq);
270
271 cancel_work_sync(&ts->work);
272
273 if (del_timer_sync(&ts->timer))
274 ad7879_ts_event_release(ts);
275
276 ad7879_write(ts->bus, AD7879_REG_CTRL2,
277 AD7879_PM(AD7879_PM_SHUTDOWN));
278 }
279
280 mutex_unlock(&ts->mutex);
281}
282
283static void ad7879_enable(struct ad7879 *ts)
284{
285 mutex_lock(&ts->mutex);
286
287 if (ts->disabled) {
288 ad7879_setup(ts);
289 ts->disabled = 0;
290 enable_irq(ts->bus->irq);
291 }
292
293 mutex_unlock(&ts->mutex);
294}
295
296static ssize_t ad7879_disable_show(struct device *dev,
297 struct device_attribute *attr, char *buf)
298{
299 struct ad7879 *ts = dev_get_drvdata(dev);
300
301 return sprintf(buf, "%u\n", ts->disabled);
302}
303
304static ssize_t ad7879_disable_store(struct device *dev,
305 struct device_attribute *attr,
306 const char *buf, size_t count)
307{
308 struct ad7879 *ts = dev_get_drvdata(dev);
309 unsigned long val;
310 int error;
311
312 error = strict_strtoul(buf, 10, &val);
313 if (error)
314 return error;
315
316 if (val)
317 ad7879_disable(ts);
318 else
319 ad7879_enable(ts);
320
321 return count;
322}
323
324static DEVICE_ATTR(disable, 0664, ad7879_disable_show, ad7879_disable_store);
325
326static ssize_t ad7879_gpio_show(struct device *dev,
327 struct device_attribute *attr, char *buf)
328{
329 struct ad7879 *ts = dev_get_drvdata(dev);
330
331 return sprintf(buf, "%u\n", ts->gpio);
332}
333
334static ssize_t ad7879_gpio_store(struct device *dev,
335 struct device_attribute *attr,
336 const char *buf, size_t count)
337{
338 struct ad7879 *ts = dev_get_drvdata(dev);
339 unsigned long val;
340 int error;
341
342 error = strict_strtoul(buf, 10, &val);
343 if (error)
344 return error;
345
346 mutex_lock(&ts->mutex);
347 ts->gpio = !!val;
348 error = ad7879_write(ts->bus, AD7879_REG_CTRL2,
349 ts->gpio ?
350 ts->cmd_crtl2 & ~AD7879_GPIO_DATA :
351 ts->cmd_crtl2 | AD7879_GPIO_DATA);
352 mutex_unlock(&ts->mutex);
353
354 return error ? : count;
355}
356
357static DEVICE_ATTR(gpio, 0664, ad7879_gpio_show, ad7879_gpio_store);
358
359static struct attribute *ad7879_attributes[] = {
360 &dev_attr_disable.attr,
361 &dev_attr_gpio.attr,
362 NULL
363};
364
365static const struct attribute_group ad7879_attr_group = {
366 .attrs = ad7879_attributes,
367};
368
369static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts)
370{
371 struct input_dev *input_dev;
372 struct ad7879_platform_data *pdata = bus->dev.platform_data;
373 int err;
374 u16 revid;
375
376 if (!bus->irq) {
377 dev_err(&bus->dev, "no IRQ?\n");
378 return -ENODEV;
379 }
380
381 if (!pdata) {
382 dev_err(&bus->dev, "no platform data?\n");
383 return -ENODEV;
384 }
385
386 input_dev = input_allocate_device();
387 if (!input_dev)
388 return -ENOMEM;
389
390 ts->input = input_dev;
391
392 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts);
393 INIT_WORK(&ts->work, ad7879_work);
394 mutex_init(&ts->mutex);
395
396 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
397 ts->pressure_max = pdata->pressure_max ? : ~0;
398
399 ts->first_conversion_delay = pdata->first_conversion_delay;
400 ts->acquisition_time = pdata->acquisition_time;
401 ts->averaging = pdata->averaging;
402 ts->pen_down_acc_interval = pdata->pen_down_acc_interval;
403 ts->median = pdata->median;
404
405 if (pdata->gpio_output)
406 ts->gpio_init = AD7879_GPIO_EN |
407 (pdata->gpio_default ? 0 : AD7879_GPIO_DATA);
408 else
409 ts->gpio_init = AD7879_GPIO_EN | AD7879_GPIODIR;
410
411 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&bus->dev));
412
413 input_dev->name = "AD7879 Touchscreen";
414 input_dev->phys = ts->phys;
415 input_dev->dev.parent = &bus->dev;
416
417 __set_bit(EV_ABS, input_dev->evbit);
418 __set_bit(ABS_X, input_dev->absbit);
419 __set_bit(ABS_Y, input_dev->absbit);
420 __set_bit(ABS_PRESSURE, input_dev->absbit);
421
422 input_set_abs_params(input_dev, ABS_X,
423 pdata->x_min ? : 0,
424 pdata->x_max ? : MAX_12BIT,
425 0, 0);
426 input_set_abs_params(input_dev, ABS_Y,
427 pdata->y_min ? : 0,
428 pdata->y_max ? : MAX_12BIT,
429 0, 0);
430 input_set_abs_params(input_dev, ABS_PRESSURE,
431 pdata->pressure_min, pdata->pressure_max, 0, 0);
432
433 err = ad7879_write(bus, AD7879_REG_CTRL2, AD7879_RESET);
434
435 if (err < 0) {
436 dev_err(&bus->dev, "Failed to write %s\n", input_dev->name);
437 goto err_free_mem;
438 }
439
440 revid = ad7879_read(bus, AD7879_REG_REVID);
441
442 if ((revid & 0xFF) != AD7879_DEVID) {
443 dev_err(&bus->dev, "Failed to probe %s\n", input_dev->name);
444 err = -ENODEV;
445 goto err_free_mem;
446 }
447
448 ad7879_setup(ts);
449
450 err = request_irq(bus->irq, ad7879_irq,
451 IRQF_TRIGGER_FALLING | IRQF_SAMPLE_RANDOM,
452 bus->dev.driver->name, ts);
453
454 if (err) {
455 dev_err(&bus->dev, "irq %d busy?\n", bus->irq);
456 goto err_free_mem;
457 }
458
459 err = sysfs_create_group(&bus->dev.kobj, &ad7879_attr_group);
460 if (err)
461 goto err_free_irq;
462
463 err = input_register_device(input_dev);
464 if (err)
465 goto err_remove_attr;
466
467 dev_info(&bus->dev, "Rev.%d touchscreen, irq %d\n",
468 revid >> 8, bus->irq);
469
470 return 0;
471
472err_remove_attr:
473 sysfs_remove_group(&bus->dev.kobj, &ad7879_attr_group);
474err_free_irq:
475 free_irq(bus->irq, ts);
476err_free_mem:
477 input_free_device(input_dev);
478
479 return err;
480}
481
482static int __devexit ad7879_destroy(bus_device *bus, struct ad7879 *ts)
483{
484 ad7879_disable(ts);
485 sysfs_remove_group(&ts->bus->dev.kobj, &ad7879_attr_group);
486 free_irq(ts->bus->irq, ts);
487 input_unregister_device(ts->input);
488 dev_dbg(&bus->dev, "unregistered touchscreen\n");
489
490 return 0;
491}
492
493#ifdef CONFIG_PM
494static int ad7879_suspend(bus_device *bus, pm_message_t message)
495{
496 struct ad7879 *ts = dev_get_drvdata(&bus->dev);
497
498 ad7879_disable(ts);
499
500 return 0;
501}
502
503static int ad7879_resume(bus_device *bus)
504{
505 struct ad7879 *ts = dev_get_drvdata(&bus->dev);
506
507 ad7879_enable(ts);
508
509 return 0;
510}
511#else
512#define ad7879_suspend NULL
513#define ad7879_resume NULL
514#endif
515
516#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
517#define MAX_SPI_FREQ_HZ 5000000
518#define AD7879_CMD_MAGIC 0xE000
519#define AD7879_CMD_READ (1 << 10)
520#define AD7879_WRITECMD(reg) (AD7879_CMD_MAGIC | (reg & 0xF))
521#define AD7879_READCMD(reg) (AD7879_CMD_MAGIC | AD7879_CMD_READ | (reg & 0xF))
522
523struct ser_req {
524 u16 command;
525 u16 data;
526 struct spi_message msg;
527 struct spi_transfer xfer[2];
528};
529
530/*
531 * ad7879_read/write are only used for initial setup and for sysfs controls.
532 * The main traffic is done in ad7879_collect().
533 */
534
535static int ad7879_read(struct spi_device *spi, u8 reg)
536{
537 struct ser_req *req;
538 int status, ret;
539
540 req = kzalloc(sizeof *req, GFP_KERNEL);
541 if (!req)
542 return -ENOMEM;
543
544 spi_message_init(&req->msg);
545
546 req->command = (u16) AD7879_READCMD(reg);
547 req->xfer[0].tx_buf = &req->command;
548 req->xfer[0].len = 2;
549
550 req->xfer[1].rx_buf = &req->data;
551 req->xfer[1].len = 2;
552
553 spi_message_add_tail(&req->xfer[0], &req->msg);
554 spi_message_add_tail(&req->xfer[1], &req->msg);
555
556 status = spi_sync(spi, &req->msg);
557 ret = status ? : req->data;
558
559 kfree(req);
560
561 return ret;
562}
563
564static int ad7879_write(struct spi_device *spi, u8 reg, u16 val)
565{
566 struct ser_req *req;
567 int status;
568
569 req = kzalloc(sizeof *req, GFP_KERNEL);
570 if (!req)
571 return -ENOMEM;
572
573 spi_message_init(&req->msg);
574
575 req->command = (u16) AD7879_WRITECMD(reg);
576 req->xfer[0].tx_buf = &req->command;
577 req->xfer[0].len = 2;
578
579 req->data = val;
580 req->xfer[1].tx_buf = &req->data;
581 req->xfer[1].len = 2;
582
583 spi_message_add_tail(&req->xfer[0], &req->msg);
584 spi_message_add_tail(&req->xfer[1], &req->msg);
585
586 status = spi_sync(spi, &req->msg);
587
588 kfree(req);
589
590 return status;
591}
592
593static void ad7879_collect(struct ad7879 *ts)
594{
595 int status = spi_sync(ts->bus, &ts->msg);
596
597 if (status)
598 dev_err(&ts->bus->dev, "spi_sync --> %d\n", status);
599}
600
601static void ad7879_setup_ts_def_msg(struct ad7879 *ts)
602{
603 struct spi_message *m;
604 int i;
605
606 ts->cmd = (u16) AD7879_READCMD(AD7879_REG_XPLUS);
607
608 m = &ts->msg;
609 spi_message_init(m);
610 ts->xfer[0].tx_buf = &ts->cmd;
611 ts->xfer[0].len = 2;
612
613 spi_message_add_tail(&ts->xfer[0], m);
614
615 for (i = 0; i < AD7879_NR_SENSE; i++) {
616 ts->xfer[i + 1].rx_buf = &ts->conversion_data[i];
617 ts->xfer[i + 1].len = 2;
618 spi_message_add_tail(&ts->xfer[i + 1], m);
619 }
620}
621
622static int __devinit ad7879_probe(struct spi_device *spi)
623{
624 struct ad7879 *ts;
625 int error;
626
627 /* don't exceed max specified SPI CLK frequency */
628 if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) {
629 dev_err(&spi->dev, "SPI CLK %d Hz?\n", spi->max_speed_hz);
630 return -EINVAL;
631 }
632
633 ts = kzalloc(sizeof(struct ad7879), GFP_KERNEL);
634 if (!ts)
635 return -ENOMEM;
636
637 dev_set_drvdata(&spi->dev, ts);
638 ts->bus = spi;
639
640 ad7879_setup_ts_def_msg(ts);
641
642 error = ad7879_construct(spi, ts);
643 if (error) {
644 dev_set_drvdata(&spi->dev, NULL);
645 kfree(ts);
646 }
647
648 return 0;
649}
650
651static int __devexit ad7879_remove(struct spi_device *spi)
652{
653 struct ad7879 *ts = dev_get_drvdata(&spi->dev);
654
655 ad7879_destroy(spi, ts);
656 dev_set_drvdata(&spi->dev, NULL);
657 kfree(ts);
658
659 return 0;
660}
661
662static struct spi_driver ad7879_driver = {
663 .driver = {
664 .name = "ad7879",
665 .bus = &spi_bus_type,
666 .owner = THIS_MODULE,
667 },
668 .probe = ad7879_probe,
669 .remove = __devexit_p(ad7879_remove),
670 .suspend = ad7879_suspend,
671 .resume = ad7879_resume,
672};
673
674static int __init ad7879_init(void)
675{
676 return spi_register_driver(&ad7879_driver);
677}
678module_init(ad7879_init);
679
680static void __exit ad7879_exit(void)
681{
682 spi_unregister_driver(&ad7879_driver);
683}
684module_exit(ad7879_exit);
685
686#elif defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
687
688/* All registers are word-sized.
689 * AD7879 uses a high-byte first convention.
690 */
691static int ad7879_read(struct i2c_client *client, u8 reg)
692{
693 return swab16(i2c_smbus_read_word_data(client, reg));
694}
695
696static int ad7879_write(struct i2c_client *client, u8 reg, u16 val)
697{
698 return i2c_smbus_write_word_data(client, reg, swab16(val));
699}
700
701static void ad7879_collect(struct ad7879 *ts)
702{
703 int i;
704
705 for (i = 0; i < AD7879_NR_SENSE; i++)
706 ts->conversion_data[i] = ad7879_read(ts->bus,
707 AD7879_REG_XPLUS + i);
708}
709
710static int __devinit ad7879_probe(struct i2c_client *client,
711 const struct i2c_device_id *id)
712{
713 struct ad7879 *ts;
714 int error;
715
716 if (!i2c_check_functionality(client->adapter,
717 I2C_FUNC_SMBUS_WORD_DATA)) {
718 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
719 return -EIO;
720 }
721
722 ts = kzalloc(sizeof(struct ad7879), GFP_KERNEL);
723 if (!ts)
724 return -ENOMEM;
725
726 i2c_set_clientdata(client, ts);
727 ts->bus = client;
728
729 error = ad7879_construct(client, ts);
730 if (error) {
731 i2c_set_clientdata(client, NULL);
732 kfree(ts);
733 }
734
735 return 0;
736}
737
738static int __devexit ad7879_remove(struct i2c_client *client)
739{
740 struct ad7879 *ts = dev_get_drvdata(&client->dev);
741
742 ad7879_destroy(client, ts);
743 i2c_set_clientdata(client, NULL);
744 kfree(ts);
745
746 return 0;
747}
748
749static const struct i2c_device_id ad7879_id[] = {
750 { "ad7879", 0 },
751 { }
752};
753MODULE_DEVICE_TABLE(i2c, ad7879_id);
754
755static struct i2c_driver ad7879_driver = {
756 .driver = {
757 .name = "ad7879",
758 .owner = THIS_MODULE,
759 },
760 .probe = ad7879_probe,
761 .remove = __devexit_p(ad7879_remove),
762 .suspend = ad7879_suspend,
763 .resume = ad7879_resume,
764 .id_table = ad7879_id,
765};
766
767static int __init ad7879_init(void)
768{
769 return i2c_add_driver(&ad7879_driver);
770}
771module_init(ad7879_init);
772
773static void __exit ad7879_exit(void)
774{
775 i2c_del_driver(&ad7879_driver);
776}
777module_exit(ad7879_exit);
778#endif
779
780MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
781MODULE_DESCRIPTION("AD7879(-1) touchscreen Driver");
782MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 1d11e2be9ef8..dfa6a84ab50a 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -162,6 +162,7 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
162 input_report_abs(wm->input_dev, ABS_X, x & 0xfff); 162 input_report_abs(wm->input_dev, ABS_X, x & 0xfff);
163 input_report_abs(wm->input_dev, ABS_Y, y & 0xfff); 163 input_report_abs(wm->input_dev, ABS_Y, y & 0xfff);
164 input_report_abs(wm->input_dev, ABS_PRESSURE, p & 0xfff); 164 input_report_abs(wm->input_dev, ABS_PRESSURE, p & 0xfff);
165 input_report_key(wm->input_dev, BTN_TOUCH, (p != 0));
165 input_sync(wm->input_dev); 166 input_sync(wm->input_dev);
166 reads++; 167 reads++;
167 } while (reads < cinfo[sp_idx].reads); 168 } while (reads < cinfo[sp_idx].reads);
@@ -245,7 +246,7 @@ static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
245 if (enable) 246 if (enable)
246 enable_irq(wm->pen_irq); 247 enable_irq(wm->pen_irq);
247 else 248 else
248 disable_irq(wm->pen_irq); 249 disable_irq_nosync(wm->pen_irq);
249} 250}
250 251
251static struct wm97xx_mach_ops mainstone_mach_ops = { 252static struct wm97xx_mach_ops mainstone_mach_ops = {
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index 54986627def0..e868264fe799 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -151,12 +151,14 @@ static void ucb1400_ts_evt_add(struct input_dev *idev, u16 pressure, u16 x, u16
151 input_report_abs(idev, ABS_X, x); 151 input_report_abs(idev, ABS_X, x);
152 input_report_abs(idev, ABS_Y, y); 152 input_report_abs(idev, ABS_Y, y);
153 input_report_abs(idev, ABS_PRESSURE, pressure); 153 input_report_abs(idev, ABS_PRESSURE, pressure);
154 input_report_key(idev, BTN_TOUCH, 1);
154 input_sync(idev); 155 input_sync(idev);
155} 156}
156 157
157static void ucb1400_ts_event_release(struct input_dev *idev) 158static void ucb1400_ts_event_release(struct input_dev *idev)
158{ 159{
159 input_report_abs(idev, ABS_PRESSURE, 0); 160 input_report_abs(idev, ABS_PRESSURE, 0);
161 input_report_key(idev, BTN_TOUCH, 0);
160 input_sync(idev); 162 input_sync(idev);
161} 163}
162 164
@@ -377,7 +379,8 @@ static int ucb1400_ts_probe(struct platform_device *dev)
377 ucb->ts_idev->id.product = ucb->id; 379 ucb->ts_idev->id.product = ucb->id;
378 ucb->ts_idev->open = ucb1400_ts_open; 380 ucb->ts_idev->open = ucb1400_ts_open;
379 ucb->ts_idev->close = ucb1400_ts_close; 381 ucb->ts_idev->close = ucb1400_ts_close;
380 ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS); 382 ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY);
383 ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
381 384
382 ucb1400_adc_enable(ucb->ac97); 385 ucb1400_adc_enable(ucb->ac97);
383 x_res = ucb1400_ts_read_xres(ucb); 386 x_res = ucb1400_ts_read_xres(ucb);
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index d15aa11d7056..cec480bffe38 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -409,6 +409,7 @@ static int wm97xx_read_samples(struct wm97xx *wm)
409 wm->pen_is_down = 0; 409 wm->pen_is_down = 0;
410 dev_dbg(wm->dev, "pen up\n"); 410 dev_dbg(wm->dev, "pen up\n");
411 input_report_abs(wm->input_dev, ABS_PRESSURE, 0); 411 input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
412 input_report_key(wm->input_dev, BTN_TOUCH, 0);
412 input_sync(wm->input_dev); 413 input_sync(wm->input_dev);
413 } else if (!(rc & RC_AGAIN)) { 414 } else if (!(rc & RC_AGAIN)) {
414 /* We need high frequency updates only while 415 /* We need high frequency updates only while
@@ -433,6 +434,7 @@ static int wm97xx_read_samples(struct wm97xx *wm)
433 input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff); 434 input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff);
434 input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff); 435 input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff);
435 input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff); 436 input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff);
437 input_report_key(wm->input_dev, BTN_TOUCH, 1);
436 input_sync(wm->input_dev); 438 input_sync(wm->input_dev);
437 wm->pen_is_down = 1; 439 wm->pen_is_down = 1;
438 wm->ts_reader_interval = wm->ts_reader_min_interval; 440 wm->ts_reader_interval = wm->ts_reader_min_interval;
@@ -628,18 +630,21 @@ static int wm97xx_probe(struct device *dev)
628 wm->input_dev->phys = "wm97xx"; 630 wm->input_dev->phys = "wm97xx";
629 wm->input_dev->open = wm97xx_ts_input_open; 631 wm->input_dev->open = wm97xx_ts_input_open;
630 wm->input_dev->close = wm97xx_ts_input_close; 632 wm->input_dev->close = wm97xx_ts_input_close;
631 set_bit(EV_ABS, wm->input_dev->evbit); 633
632 set_bit(ABS_X, wm->input_dev->absbit); 634 __set_bit(EV_ABS, wm->input_dev->evbit);
633 set_bit(ABS_Y, wm->input_dev->absbit); 635 __set_bit(EV_KEY, wm->input_dev->evbit);
634 set_bit(ABS_PRESSURE, wm->input_dev->absbit); 636 __set_bit(BTN_TOUCH, wm->input_dev->keybit);
637
635 input_set_abs_params(wm->input_dev, ABS_X, abs_x[0], abs_x[1], 638 input_set_abs_params(wm->input_dev, ABS_X, abs_x[0], abs_x[1],
636 abs_x[2], 0); 639 abs_x[2], 0);
637 input_set_abs_params(wm->input_dev, ABS_Y, abs_y[0], abs_y[1], 640 input_set_abs_params(wm->input_dev, ABS_Y, abs_y[0], abs_y[1],
638 abs_y[2], 0); 641 abs_y[2], 0);
639 input_set_abs_params(wm->input_dev, ABS_PRESSURE, abs_p[0], abs_p[1], 642 input_set_abs_params(wm->input_dev, ABS_PRESSURE, abs_p[0], abs_p[1],
640 abs_p[2], 0); 643 abs_p[2], 0);
644
641 input_set_drvdata(wm->input_dev, wm); 645 input_set_drvdata(wm->input_dev, wm);
642 wm->input_dev->dev.parent = dev; 646 wm->input_dev->dev.parent = dev;
647
643 ret = input_register_device(wm->input_dev); 648 ret = input_register_device(wm->input_dev);
644 if (ret < 0) 649 if (ret < 0)
645 goto dev_alloc_err; 650 goto dev_alloc_err;
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c
new file mode 100644
index 000000000000..41e4359c277c
--- /dev/null
+++ b/drivers/input/touchscreen/zylonite-wm97xx.c
@@ -0,0 +1,240 @@
1/*
2 * zylonite-wm97xx.c -- Zylonite Continuous Touch screen driver
3 *
4 * Copyright 2004, 2007, 2008 Wolfson Microelectronics PLC.
5 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
6 * Parts Copyright : Ian Molton <spyro@f2s.com>
7 * Andrew Zabolotny <zap@homelink.ru>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * Notes:
15 * This is a wm97xx extended touch driver supporting interrupt driven
16 * and continuous operation on Marvell Zylonite development systems
17 * (which have a WM9713 on board).
18 */
19
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/delay.h>
25#include <linux/irq.h>
26#include <linux/interrupt.h>
27#include <linux/io.h>
28#include <linux/wm97xx.h>
29
30#include <mach/hardware.h>
31#include <mach/mfp.h>
32#include <mach/regs-ac97.h>
33
34struct continuous {
35 u16 id; /* codec id */
36 u8 code; /* continuous code */
37 u8 reads; /* number of coord reads per read cycle */
38 u32 speed; /* number of coords per second */
39};
40
41#define WM_READS(sp) ((sp / HZ) + 1)
42
43static const struct continuous cinfo[] = {
44 { WM9713_ID2, 0, WM_READS(94), 94 },
45 { WM9713_ID2, 1, WM_READS(120), 120 },
46 { WM9713_ID2, 2, WM_READS(154), 154 },
47 { WM9713_ID2, 3, WM_READS(188), 188 },
48};
49
50/* continuous speed index */
51static int sp_idx;
52
53/*
54 * Pen sampling frequency (Hz) in continuous mode.
55 */
56static int cont_rate = 200;
57module_param(cont_rate, int, 0);
58MODULE_PARM_DESC(cont_rate, "Sampling rate in continuous mode (Hz)");
59
60/*
61 * Pressure readback.
62 *
63 * Set to 1 to read back pen down pressure
64 */
65static int pressure;
66module_param(pressure, int, 0);
67MODULE_PARM_DESC(pressure, "Pressure readback (1 = pressure, 0 = no pressure)");
68
69/*
70 * AC97 touch data slot.
71 *
72 * Touch screen readback data ac97 slot
73 */
74static int ac97_touch_slot = 5;
75module_param(ac97_touch_slot, int, 0);
76MODULE_PARM_DESC(ac97_touch_slot, "Touch screen data slot AC97 number");
77
78
79/* flush AC97 slot 5 FIFO machines */
80static void wm97xx_acc_pen_up(struct wm97xx *wm)
81{
82 int i;
83
84 msleep(1);
85
86 for (i = 0; i < 16; i++)
87 MODR;
88}
89
90static int wm97xx_acc_pen_down(struct wm97xx *wm)
91{
92 u16 x, y, p = 0x100 | WM97XX_ADCSEL_PRES;
93 int reads = 0;
94 static u16 last, tries;
95
96 /* When the AC97 queue has been drained we need to allow time
97 * to buffer up samples otherwise we end up spinning polling
98 * for samples. The controller can't have a suitably low
99 * threashold set to use the notifications it gives.
100 */
101 msleep(1);
102
103 if (tries > 5) {
104 tries = 0;
105 return RC_PENUP;
106 }
107
108 x = MODR;
109 if (x == last) {
110 tries++;
111 return RC_AGAIN;
112 }
113 last = x;
114 do {
115 if (reads)
116 x = MODR;
117 y = MODR;
118 if (pressure)
119 p = MODR;
120
121 /* are samples valid */
122 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X ||
123 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
124 (p & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_PRES)
125 goto up;
126
127 /* coordinate is good */
128 tries = 0;
129 input_report_abs(wm->input_dev, ABS_X, x & 0xfff);
130 input_report_abs(wm->input_dev, ABS_Y, y & 0xfff);
131 input_report_abs(wm->input_dev, ABS_PRESSURE, p & 0xfff);
132 input_report_key(wm->input_dev, BTN_TOUCH, (p != 0));
133 input_sync(wm->input_dev);
134 reads++;
135 } while (reads < cinfo[sp_idx].reads);
136up:
137 return RC_PENDOWN | RC_AGAIN;
138}
139
140static int wm97xx_acc_startup(struct wm97xx *wm)
141{
142 int idx;
143
144 /* check we have a codec */
145 if (wm->ac97 == NULL)
146 return -ENODEV;
147
148 /* Go you big red fire engine */
149 for (idx = 0; idx < ARRAY_SIZE(cinfo); idx++) {
150 if (wm->id != cinfo[idx].id)
151 continue;
152 sp_idx = idx;
153 if (cont_rate <= cinfo[idx].speed)
154 break;
155 }
156 wm->acc_rate = cinfo[sp_idx].code;
157 wm->acc_slot = ac97_touch_slot;
158 dev_info(wm->dev,
159 "zylonite accelerated touchscreen driver, %d samples/sec\n",
160 cinfo[sp_idx].speed);
161
162 return 0;
163}
164
165static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
166{
167 if (enable)
168 enable_irq(wm->pen_irq);
169 else
170 disable_irq_nosync(wm->pen_irq);
171}
172
173static struct wm97xx_mach_ops zylonite_mach_ops = {
174 .acc_enabled = 1,
175 .acc_pen_up = wm97xx_acc_pen_up,
176 .acc_pen_down = wm97xx_acc_pen_down,
177 .acc_startup = wm97xx_acc_startup,
178 .irq_enable = wm97xx_irq_enable,
179 .irq_gpio = WM97XX_GPIO_2,
180};
181
182static int zylonite_wm97xx_probe(struct platform_device *pdev)
183{
184 struct wm97xx *wm = platform_get_drvdata(pdev);
185 int gpio_touch_irq;
186
187 if (cpu_is_pxa320())
188 gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO15);
189 else
190 gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO26);
191
192 wm->pen_irq = IRQ_GPIO(gpio_touch_irq);
193 set_irq_type(IRQ_GPIO(gpio_touch_irq), IRQ_TYPE_EDGE_BOTH);
194
195 wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN,
196 WM97XX_GPIO_POL_HIGH,
197 WM97XX_GPIO_STICKY,
198 WM97XX_GPIO_WAKE);
199 wm97xx_config_gpio(wm, WM97XX_GPIO_2, WM97XX_GPIO_OUT,
200 WM97XX_GPIO_POL_HIGH,
201 WM97XX_GPIO_NOTSTICKY,
202 WM97XX_GPIO_NOWAKE);
203
204 return wm97xx_register_mach_ops(wm, &zylonite_mach_ops);
205}
206
207static int zylonite_wm97xx_remove(struct platform_device *pdev)
208{
209 struct wm97xx *wm = platform_get_drvdata(pdev);
210
211 wm97xx_unregister_mach_ops(wm);
212
213 return 0;
214}
215
216static struct platform_driver zylonite_wm97xx_driver = {
217 .probe = zylonite_wm97xx_probe,
218 .remove = zylonite_wm97xx_remove,
219 .driver = {
220 .name = "wm97xx-touch",
221 },
222};
223
224static int __init zylonite_wm97xx_init(void)
225{
226 return platform_driver_register(&zylonite_wm97xx_driver);
227}
228
229static void __exit zylonite_wm97xx_exit(void)
230{
231 platform_driver_unregister(&zylonite_wm97xx_driver);
232}
233
234module_init(zylonite_wm97xx_init);
235module_exit(zylonite_wm97xx_exit);
236
237/* Module information */
238MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
239MODULE_DESCRIPTION("wm97xx continuous touch driver for Zylonite");
240MODULE_LICENSE("GPL");
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index d184dfab9631..db39f4a52f53 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -278,7 +278,7 @@ static ssize_t at24_bin_read(struct kobject *kobj, struct bin_attribute *attr,
278 * We only use page mode writes; the alternative is sloooow. This routine 278 * We only use page mode writes; the alternative is sloooow. This routine
279 * writes at most one page. 279 * writes at most one page.
280 */ 280 */
281static ssize_t at24_eeprom_write(struct at24_data *at24, char *buf, 281static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
282 unsigned offset, size_t count) 282 unsigned offset, size_t count)
283{ 283{
284 struct i2c_client *client; 284 struct i2c_client *client;
@@ -347,8 +347,8 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, char *buf,
347 return -ETIMEDOUT; 347 return -ETIMEDOUT;
348} 348}
349 349
350static ssize_t at24_write(struct at24_data *at24, 350static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
351 char *buf, loff_t off, size_t count) 351 size_t count)
352{ 352{
353 ssize_t retval = 0; 353 ssize_t retval = 0;
354 354
@@ -406,7 +406,7 @@ static ssize_t at24_macc_read(struct memory_accessor *macc, char *buf,
406 return at24_read(at24, buf, offset, count); 406 return at24_read(at24, buf, offset, count);
407} 407}
408 408
409static ssize_t at24_macc_write(struct memory_accessor *macc, char *buf, 409static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
410 off_t offset, size_t count) 410 off_t offset, size_t count)
411{ 411{
412 struct at24_data *at24 = container_of(macc, struct at24_data, macc); 412 struct at24_data *at24 = container_of(macc, struct at24_data, macc);
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index 6bc0dac5c1e8..b34cb5f79eea 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -140,7 +140,8 @@ at25_bin_read(struct kobject *kobj, struct bin_attribute *bin_attr,
140 140
141 141
142static ssize_t 142static ssize_t
143at25_ee_write(struct at25_data *at25, char *buf, loff_t off, size_t count) 143at25_ee_write(struct at25_data *at25, const char *buf, loff_t off,
144 size_t count)
144{ 145{
145 ssize_t status = 0; 146 ssize_t status = 0;
146 unsigned written = 0; 147 unsigned written = 0;
@@ -276,7 +277,7 @@ static ssize_t at25_mem_read(struct memory_accessor *mem, char *buf,
276 return at25_ee_read(at25, buf, offset, count); 277 return at25_ee_read(at25, buf, offset, count);
277} 278}
278 279
279static ssize_t at25_mem_write(struct memory_accessor *mem, char *buf, 280static ssize_t at25_mem_write(struct memory_accessor *mem, const char *buf,
280 off_t offset, size_t count) 281 off_t offset, size_t count)
281{ 282{
282 struct at25_data *at25 = container_of(mem, struct at25_data, mem); 283 struct at25_data *at25 = container_of(mem, struct at25_data, mem);
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
index 114444cfd496..b94d5f767703 100644
--- a/drivers/misc/sgi-xp/xpc.h
+++ b/drivers/misc/sgi-xp/xpc.h
@@ -90,18 +90,21 @@ struct xpc_rsvd_page {
90 short max_npartitions; /* value of XPC_MAX_PARTITIONS */ 90 short max_npartitions; /* value of XPC_MAX_PARTITIONS */
91 u8 version; 91 u8 version;
92 u8 pad1[3]; /* align to next u64 in 1st 64-byte cacheline */ 92 u8 pad1[3]; /* align to next u64 in 1st 64-byte cacheline */
93 unsigned long ts_jiffies; /* timestamp when rsvd pg was setup by XPC */
93 union { 94 union {
94 unsigned long vars_pa; /* phys address of struct xpc_vars */ 95 struct {
95 unsigned long activate_gru_mq_desc_gpa; /* phys addr of */ 96 unsigned long vars_pa; /* phys addr */
96 /* activate mq's */ 97 } sn2;
97 /* gru mq descriptor */ 98 struct {
99 unsigned long heartbeat_gpa; /* phys addr */
100 unsigned long activate_gru_mq_desc_gpa; /* phys addr */
101 } uv;
98 } sn; 102 } sn;
99 unsigned long ts_jiffies; /* timestamp when rsvd pg was setup by XPC */ 103 u64 pad2[9]; /* align to last u64 in 2nd 64-byte cacheline */
100 u64 pad2[10]; /* align to last u64 in 2nd 64-byte cacheline */
101 u64 SAL_nasids_size; /* SAL: size of each nasid mask in bytes */ 104 u64 SAL_nasids_size; /* SAL: size of each nasid mask in bytes */
102}; 105};
103 106
104#define XPC_RP_VERSION _XPC_VERSION(2, 0) /* version 2.0 of the reserved page */ 107#define XPC_RP_VERSION _XPC_VERSION(3, 0) /* version 3.0 of the reserved page */
105 108
106/* 109/*
107 * Define the structures by which XPC variables can be exported to other 110 * Define the structures by which XPC variables can be exported to other
@@ -182,6 +185,17 @@ struct xpc_vars_part_sn2 {
182 (XPC_RP_MACH_NASIDS(_rp) + \ 185 (XPC_RP_MACH_NASIDS(_rp) + \
183 xpc_nasid_mask_nlongs)) 186 xpc_nasid_mask_nlongs))
184 187
188
189/*
190 * The following structure describes the partition's heartbeat info which
191 * will be periodically read by other partitions to determine whether this
192 * XPC is still 'alive'.
193 */
194struct xpc_heartbeat_uv {
195 unsigned long value;
196 unsigned long offline; /* if 0, heartbeat should be changing */
197};
198
185/* 199/*
186 * Info pertinent to a GRU message queue using a watch list for irq generation. 200 * Info pertinent to a GRU message queue using a watch list for irq generation.
187 */ 201 */
@@ -198,7 +212,7 @@ struct xpc_gru_mq_uv {
198 212
199/* 213/*
200 * The activate_mq is used to send/receive GRU messages that affect XPC's 214 * The activate_mq is used to send/receive GRU messages that affect XPC's
201 * heartbeat, partition active state, and channel state. This is UV only. 215 * partition active state and channel state. This is uv only.
202 */ 216 */
203struct xpc_activate_mq_msghdr_uv { 217struct xpc_activate_mq_msghdr_uv {
204 unsigned int gru_msg_hdr; /* FOR GRU INTERNAL USE ONLY */ 218 unsigned int gru_msg_hdr; /* FOR GRU INTERNAL USE ONLY */
@@ -210,33 +224,27 @@ struct xpc_activate_mq_msghdr_uv {
210 224
211/* activate_mq defined message types */ 225/* activate_mq defined message types */
212#define XPC_ACTIVATE_MQ_MSG_SYNC_ACT_STATE_UV 0 226#define XPC_ACTIVATE_MQ_MSG_SYNC_ACT_STATE_UV 0
213#define XPC_ACTIVATE_MQ_MSG_INC_HEARTBEAT_UV 1
214#define XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV 2
215#define XPC_ACTIVATE_MQ_MSG_ONLINE_HEARTBEAT_UV 3
216 227
217#define XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV 4 228#define XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV 1
218#define XPC_ACTIVATE_MQ_MSG_DEACTIVATE_REQ_UV 5 229#define XPC_ACTIVATE_MQ_MSG_DEACTIVATE_REQ_UV 2
219 230
220#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREQUEST_UV 6 231#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREQUEST_UV 3
221#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREPLY_UV 7 232#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREPLY_UV 4
222#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREQUEST_UV 8 233#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREQUEST_UV 5
223#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREPLY_UV 9 234#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREPLY_UV 6
235#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENCOMPLETE_UV 7
224 236
225#define XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV 10 237#define XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV 8
226#define XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV 11 238#define XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV 9
227 239
228struct xpc_activate_mq_msg_uv { 240struct xpc_activate_mq_msg_uv {
229 struct xpc_activate_mq_msghdr_uv hdr; 241 struct xpc_activate_mq_msghdr_uv hdr;
230}; 242};
231 243
232struct xpc_activate_mq_msg_heartbeat_req_uv {
233 struct xpc_activate_mq_msghdr_uv hdr;
234 u64 heartbeat;
235};
236
237struct xpc_activate_mq_msg_activate_req_uv { 244struct xpc_activate_mq_msg_activate_req_uv {
238 struct xpc_activate_mq_msghdr_uv hdr; 245 struct xpc_activate_mq_msghdr_uv hdr;
239 unsigned long rp_gpa; 246 unsigned long rp_gpa;
247 unsigned long heartbeat_gpa;
240 unsigned long activate_gru_mq_desc_gpa; 248 unsigned long activate_gru_mq_desc_gpa;
241}; 249};
242 250
@@ -271,6 +279,11 @@ struct xpc_activate_mq_msg_chctl_openreply_uv {
271 unsigned long notify_gru_mq_desc_gpa; 279 unsigned long notify_gru_mq_desc_gpa;
272}; 280};
273 281
282struct xpc_activate_mq_msg_chctl_opencomplete_uv {
283 struct xpc_activate_mq_msghdr_uv hdr;
284 short ch_number;
285};
286
274/* 287/*
275 * Functions registered by add_timer() or called by kernel_thread() only 288 * Functions registered by add_timer() or called by kernel_thread() only
276 * allow for a single 64-bit argument. The following macros can be used to 289 * allow for a single 64-bit argument. The following macros can be used to
@@ -576,30 +589,32 @@ struct xpc_channel {
576 589
577#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */ 590#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */
578 591
579#define XPC_C_ROPENREPLY 0x00000002 /* remote open channel reply */ 592#define XPC_C_ROPENCOMPLETE 0x00000002 /* remote open channel complete */
580#define XPC_C_OPENREPLY 0x00000004 /* local open channel reply */ 593#define XPC_C_OPENCOMPLETE 0x00000004 /* local open channel complete */
581#define XPC_C_ROPENREQUEST 0x00000008 /* remote open channel request */ 594#define XPC_C_ROPENREPLY 0x00000008 /* remote open channel reply */
582#define XPC_C_OPENREQUEST 0x00000010 /* local open channel request */ 595#define XPC_C_OPENREPLY 0x00000010 /* local open channel reply */
596#define XPC_C_ROPENREQUEST 0x00000020 /* remote open channel request */
597#define XPC_C_OPENREQUEST 0x00000040 /* local open channel request */
583 598
584#define XPC_C_SETUP 0x00000020 /* channel's msgqueues are alloc'd */ 599#define XPC_C_SETUP 0x00000080 /* channel's msgqueues are alloc'd */
585#define XPC_C_CONNECTEDCALLOUT 0x00000040 /* connected callout initiated */ 600#define XPC_C_CONNECTEDCALLOUT 0x00000100 /* connected callout initiated */
586#define XPC_C_CONNECTEDCALLOUT_MADE \ 601#define XPC_C_CONNECTEDCALLOUT_MADE \
587 0x00000080 /* connected callout completed */ 602 0x00000200 /* connected callout completed */
588#define XPC_C_CONNECTED 0x00000100 /* local channel is connected */ 603#define XPC_C_CONNECTED 0x00000400 /* local channel is connected */
589#define XPC_C_CONNECTING 0x00000200 /* channel is being connected */ 604#define XPC_C_CONNECTING 0x00000800 /* channel is being connected */
590 605
591#define XPC_C_RCLOSEREPLY 0x00000400 /* remote close channel reply */ 606#define XPC_C_RCLOSEREPLY 0x00001000 /* remote close channel reply */
592#define XPC_C_CLOSEREPLY 0x00000800 /* local close channel reply */ 607#define XPC_C_CLOSEREPLY 0x00002000 /* local close channel reply */
593#define XPC_C_RCLOSEREQUEST 0x00001000 /* remote close channel request */ 608#define XPC_C_RCLOSEREQUEST 0x00004000 /* remote close channel request */
594#define XPC_C_CLOSEREQUEST 0x00002000 /* local close channel request */ 609#define XPC_C_CLOSEREQUEST 0x00008000 /* local close channel request */
595 610
596#define XPC_C_DISCONNECTED 0x00004000 /* channel is disconnected */ 611#define XPC_C_DISCONNECTED 0x00010000 /* channel is disconnected */
597#define XPC_C_DISCONNECTING 0x00008000 /* channel is being disconnected */ 612#define XPC_C_DISCONNECTING 0x00020000 /* channel is being disconnected */
598#define XPC_C_DISCONNECTINGCALLOUT \ 613#define XPC_C_DISCONNECTINGCALLOUT \
599 0x00010000 /* disconnecting callout initiated */ 614 0x00040000 /* disconnecting callout initiated */
600#define XPC_C_DISCONNECTINGCALLOUT_MADE \ 615#define XPC_C_DISCONNECTINGCALLOUT_MADE \
601 0x00020000 /* disconnecting callout completed */ 616 0x00080000 /* disconnecting callout completed */
602#define XPC_C_WDISCONNECT 0x00040000 /* waiting for channel disconnect */ 617#define XPC_C_WDISCONNECT 0x00100000 /* waiting for channel disconnect */
603 618
604/* 619/*
605 * The channel control flags (chctl) union consists of a 64-bit variable which 620 * The channel control flags (chctl) union consists of a 64-bit variable which
@@ -618,11 +633,13 @@ union xpc_channel_ctl_flags {
618#define XPC_CHCTL_CLOSEREPLY 0x02 633#define XPC_CHCTL_CLOSEREPLY 0x02
619#define XPC_CHCTL_OPENREQUEST 0x04 634#define XPC_CHCTL_OPENREQUEST 0x04
620#define XPC_CHCTL_OPENREPLY 0x08 635#define XPC_CHCTL_OPENREPLY 0x08
621#define XPC_CHCTL_MSGREQUEST 0x10 636#define XPC_CHCTL_OPENCOMPLETE 0x10
637#define XPC_CHCTL_MSGREQUEST 0x20
622 638
623#define XPC_OPENCLOSE_CHCTL_FLAGS \ 639#define XPC_OPENCLOSE_CHCTL_FLAGS \
624 (XPC_CHCTL_CLOSEREQUEST | XPC_CHCTL_CLOSEREPLY | \ 640 (XPC_CHCTL_CLOSEREQUEST | XPC_CHCTL_CLOSEREPLY | \
625 XPC_CHCTL_OPENREQUEST | XPC_CHCTL_OPENREPLY) 641 XPC_CHCTL_OPENREQUEST | XPC_CHCTL_OPENREPLY | \
642 XPC_CHCTL_OPENCOMPLETE)
626#define XPC_MSG_CHCTL_FLAGS XPC_CHCTL_MSGREQUEST 643#define XPC_MSG_CHCTL_FLAGS XPC_CHCTL_MSGREQUEST
627 644
628static inline int 645static inline int
@@ -687,6 +704,9 @@ struct xpc_partition_sn2 {
687}; 704};
688 705
689struct xpc_partition_uv { 706struct xpc_partition_uv {
707 unsigned long heartbeat_gpa; /* phys addr of partition's heartbeat */
708 struct xpc_heartbeat_uv cached_heartbeat; /* cached copy of */
709 /* partition's heartbeat */
690 unsigned long activate_gru_mq_desc_gpa; /* phys addr of parititon's */ 710 unsigned long activate_gru_mq_desc_gpa; /* phys addr of parititon's */
691 /* activate mq's gru mq */ 711 /* activate mq's gru mq */
692 /* descriptor */ 712 /* descriptor */
@@ -698,14 +718,12 @@ struct xpc_partition_uv {
698 u8 remote_act_state; /* remote partition's act_state */ 718 u8 remote_act_state; /* remote partition's act_state */
699 u8 act_state_req; /* act_state request from remote partition */ 719 u8 act_state_req; /* act_state request from remote partition */
700 enum xp_retval reason; /* reason for deactivate act_state request */ 720 enum xp_retval reason; /* reason for deactivate act_state request */
701 u64 heartbeat; /* incremented by remote partition */
702}; 721};
703 722
704/* struct xpc_partition_uv flags */ 723/* struct xpc_partition_uv flags */
705 724
706#define XPC_P_HEARTBEAT_OFFLINE_UV 0x00000001 725#define XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV 0x00000001
707#define XPC_P_ENGAGED_UV 0x00000002 726#define XPC_P_ENGAGED_UV 0x00000002
708#define XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV 0x00000004
709 727
710/* struct xpc_partition_uv act_state change requests */ 728/* struct xpc_partition_uv act_state change requests */
711 729
@@ -762,6 +780,62 @@ struct xpc_partition {
762 780
763} ____cacheline_aligned; 781} ____cacheline_aligned;
764 782
783struct xpc_arch_operations {
784 int (*setup_partitions) (void);
785 void (*teardown_partitions) (void);
786 void (*process_activate_IRQ_rcvd) (void);
787 enum xp_retval (*get_partition_rsvd_page_pa)
788 (void *, u64 *, unsigned long *, size_t *);
789 int (*setup_rsvd_page) (struct xpc_rsvd_page *);
790
791 void (*allow_hb) (short);
792 void (*disallow_hb) (short);
793 void (*disallow_all_hbs) (void);
794 void (*increment_heartbeat) (void);
795 void (*offline_heartbeat) (void);
796 void (*online_heartbeat) (void);
797 void (*heartbeat_init) (void);
798 void (*heartbeat_exit) (void);
799 enum xp_retval (*get_remote_heartbeat) (struct xpc_partition *);
800
801 void (*request_partition_activation) (struct xpc_rsvd_page *,
802 unsigned long, int);
803 void (*request_partition_reactivation) (struct xpc_partition *);
804 void (*request_partition_deactivation) (struct xpc_partition *);
805 void (*cancel_partition_deactivation_request) (struct xpc_partition *);
806 enum xp_retval (*setup_ch_structures) (struct xpc_partition *);
807 void (*teardown_ch_structures) (struct xpc_partition *);
808
809 enum xp_retval (*make_first_contact) (struct xpc_partition *);
810
811 u64 (*get_chctl_all_flags) (struct xpc_partition *);
812 void (*send_chctl_closerequest) (struct xpc_channel *, unsigned long *);
813 void (*send_chctl_closereply) (struct xpc_channel *, unsigned long *);
814 void (*send_chctl_openrequest) (struct xpc_channel *, unsigned long *);
815 void (*send_chctl_openreply) (struct xpc_channel *, unsigned long *);
816 void (*send_chctl_opencomplete) (struct xpc_channel *, unsigned long *);
817 void (*process_msg_chctl_flags) (struct xpc_partition *, int);
818
819 enum xp_retval (*save_remote_msgqueue_pa) (struct xpc_channel *,
820 unsigned long);
821
822 enum xp_retval (*setup_msg_structures) (struct xpc_channel *);
823 void (*teardown_msg_structures) (struct xpc_channel *);
824
825 void (*indicate_partition_engaged) (struct xpc_partition *);
826 void (*indicate_partition_disengaged) (struct xpc_partition *);
827 void (*assume_partition_disengaged) (short);
828 int (*partition_engaged) (short);
829 int (*any_partition_engaged) (void);
830
831 int (*n_of_deliverable_payloads) (struct xpc_channel *);
832 enum xp_retval (*send_payload) (struct xpc_channel *, u32, void *,
833 u16, u8, xpc_notify_func, void *);
834 void *(*get_deliverable_payload) (struct xpc_channel *);
835 void (*received_payload) (struct xpc_channel *, void *);
836 void (*notify_senders_of_disconnect) (struct xpc_channel *);
837};
838
765/* struct xpc_partition act_state values (for XPC HB) */ 839/* struct xpc_partition act_state values (for XPC HB) */
766 840
767#define XPC_P_AS_INACTIVE 0x00 /* partition is not active */ 841#define XPC_P_AS_INACTIVE 0x00 /* partition is not active */
@@ -802,67 +876,17 @@ extern struct xpc_registration xpc_registrations[];
802/* found in xpc_main.c */ 876/* found in xpc_main.c */
803extern struct device *xpc_part; 877extern struct device *xpc_part;
804extern struct device *xpc_chan; 878extern struct device *xpc_chan;
879extern struct xpc_arch_operations xpc_arch_ops;
805extern int xpc_disengage_timelimit; 880extern int xpc_disengage_timelimit;
806extern int xpc_disengage_timedout; 881extern int xpc_disengage_timedout;
807extern int xpc_activate_IRQ_rcvd; 882extern int xpc_activate_IRQ_rcvd;
808extern spinlock_t xpc_activate_IRQ_rcvd_lock; 883extern spinlock_t xpc_activate_IRQ_rcvd_lock;
809extern wait_queue_head_t xpc_activate_IRQ_wq; 884extern wait_queue_head_t xpc_activate_IRQ_wq;
810extern void *xpc_heartbeating_to_mask;
811extern void *xpc_kzalloc_cacheline_aligned(size_t, gfp_t, void **); 885extern void *xpc_kzalloc_cacheline_aligned(size_t, gfp_t, void **);
812extern void xpc_activate_partition(struct xpc_partition *); 886extern void xpc_activate_partition(struct xpc_partition *);
813extern void xpc_activate_kthreads(struct xpc_channel *, int); 887extern void xpc_activate_kthreads(struct xpc_channel *, int);
814extern void xpc_create_kthreads(struct xpc_channel *, int, int); 888extern void xpc_create_kthreads(struct xpc_channel *, int, int);
815extern void xpc_disconnect_wait(int); 889extern void xpc_disconnect_wait(int);
816extern int (*xpc_setup_partitions_sn) (void);
817extern void (*xpc_teardown_partitions_sn) (void);
818extern enum xp_retval (*xpc_get_partition_rsvd_page_pa) (void *, u64 *,
819 unsigned long *,
820 size_t *);
821extern int (*xpc_setup_rsvd_page_sn) (struct xpc_rsvd_page *);
822extern void (*xpc_heartbeat_init) (void);
823extern void (*xpc_heartbeat_exit) (void);
824extern void (*xpc_increment_heartbeat) (void);
825extern void (*xpc_offline_heartbeat) (void);
826extern void (*xpc_online_heartbeat) (void);
827extern enum xp_retval (*xpc_get_remote_heartbeat) (struct xpc_partition *);
828extern enum xp_retval (*xpc_make_first_contact) (struct xpc_partition *);
829extern u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *);
830extern enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *);
831extern void (*xpc_teardown_msg_structures) (struct xpc_channel *);
832extern void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *);
833extern void (*xpc_process_msg_chctl_flags) (struct xpc_partition *, int);
834extern int (*xpc_n_of_deliverable_payloads) (struct xpc_channel *);
835extern void *(*xpc_get_deliverable_payload) (struct xpc_channel *);
836extern void (*xpc_request_partition_activation) (struct xpc_rsvd_page *,
837 unsigned long, int);
838extern void (*xpc_request_partition_reactivation) (struct xpc_partition *);
839extern void (*xpc_request_partition_deactivation) (struct xpc_partition *);
840extern void (*xpc_cancel_partition_deactivation_request) (
841 struct xpc_partition *);
842extern void (*xpc_process_activate_IRQ_rcvd) (void);
843extern enum xp_retval (*xpc_setup_ch_structures_sn) (struct xpc_partition *);
844extern void (*xpc_teardown_ch_structures_sn) (struct xpc_partition *);
845
846extern void (*xpc_indicate_partition_engaged) (struct xpc_partition *);
847extern int (*xpc_partition_engaged) (short);
848extern int (*xpc_any_partition_engaged) (void);
849extern void (*xpc_indicate_partition_disengaged) (struct xpc_partition *);
850extern void (*xpc_assume_partition_disengaged) (short);
851
852extern void (*xpc_send_chctl_closerequest) (struct xpc_channel *,
853 unsigned long *);
854extern void (*xpc_send_chctl_closereply) (struct xpc_channel *,
855 unsigned long *);
856extern void (*xpc_send_chctl_openrequest) (struct xpc_channel *,
857 unsigned long *);
858extern void (*xpc_send_chctl_openreply) (struct xpc_channel *, unsigned long *);
859
860extern enum xp_retval (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *,
861 unsigned long);
862
863extern enum xp_retval (*xpc_send_payload) (struct xpc_channel *, u32, void *,
864 u16, u8, xpc_notify_func, void *);
865extern void (*xpc_received_payload) (struct xpc_channel *, void *);
866 890
867/* found in xpc_sn2.c */ 891/* found in xpc_sn2.c */
868extern int xpc_init_sn2(void); 892extern int xpc_init_sn2(void);
@@ -909,40 +933,6 @@ extern void xpc_disconnect_channel(const int, struct xpc_channel *,
909extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval); 933extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval);
910extern void xpc_partition_going_down(struct xpc_partition *, enum xp_retval); 934extern void xpc_partition_going_down(struct xpc_partition *, enum xp_retval);
911 935
912static inline int
913xpc_hb_allowed(short partid, void *heartbeating_to_mask)
914{
915 return test_bit(partid, heartbeating_to_mask);
916}
917
918static inline int
919xpc_any_hbs_allowed(void)
920{
921 DBUG_ON(xpc_heartbeating_to_mask == NULL);
922 return !bitmap_empty(xpc_heartbeating_to_mask, xp_max_npartitions);
923}
924
925static inline void
926xpc_allow_hb(short partid)
927{
928 DBUG_ON(xpc_heartbeating_to_mask == NULL);
929 set_bit(partid, xpc_heartbeating_to_mask);
930}
931
932static inline void
933xpc_disallow_hb(short partid)
934{
935 DBUG_ON(xpc_heartbeating_to_mask == NULL);
936 clear_bit(partid, xpc_heartbeating_to_mask);
937}
938
939static inline void
940xpc_disallow_all_hbs(void)
941{
942 DBUG_ON(xpc_heartbeating_to_mask == NULL);
943 bitmap_zero(xpc_heartbeating_to_mask, xp_max_npartitions);
944}
945
946static inline void 936static inline void
947xpc_wakeup_channel_mgr(struct xpc_partition *part) 937xpc_wakeup_channel_mgr(struct xpc_partition *part)
948{ 938{
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index 99a2534c38a1..652593fc486d 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2004-2009 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* 9/*
@@ -39,34 +39,38 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
39 39
40 if (!(ch->flags & XPC_C_SETUP)) { 40 if (!(ch->flags & XPC_C_SETUP)) {
41 spin_unlock_irqrestore(&ch->lock, *irq_flags); 41 spin_unlock_irqrestore(&ch->lock, *irq_flags);
42 ret = xpc_setup_msg_structures(ch); 42 ret = xpc_arch_ops.setup_msg_structures(ch);
43 spin_lock_irqsave(&ch->lock, *irq_flags); 43 spin_lock_irqsave(&ch->lock, *irq_flags);
44 44
45 if (ret != xpSuccess) 45 if (ret != xpSuccess)
46 XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags); 46 XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags);
47 else
48 ch->flags |= XPC_C_SETUP;
47 49
48 ch->flags |= XPC_C_SETUP; 50 if (ch->flags & XPC_C_DISCONNECTING)
49
50 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING))
51 return; 51 return;
52 } 52 }
53 53
54 if (!(ch->flags & XPC_C_OPENREPLY)) { 54 if (!(ch->flags & XPC_C_OPENREPLY)) {
55 ch->flags |= XPC_C_OPENREPLY; 55 ch->flags |= XPC_C_OPENREPLY;
56 xpc_send_chctl_openreply(ch, irq_flags); 56 xpc_arch_ops.send_chctl_openreply(ch, irq_flags);
57 } 57 }
58 58
59 if (!(ch->flags & XPC_C_ROPENREPLY)) 59 if (!(ch->flags & XPC_C_ROPENREPLY))
60 return; 60 return;
61 61
62 ch->flags = (XPC_C_CONNECTED | XPC_C_SETUP); /* clear all else */ 62 if (!(ch->flags & XPC_C_OPENCOMPLETE)) {
63 ch->flags |= (XPC_C_OPENCOMPLETE | XPC_C_CONNECTED);
64 xpc_arch_ops.send_chctl_opencomplete(ch, irq_flags);
65 }
66
67 if (!(ch->flags & XPC_C_ROPENCOMPLETE))
68 return;
63 69
64 dev_info(xpc_chan, "channel %d to partition %d connected\n", 70 dev_info(xpc_chan, "channel %d to partition %d connected\n",
65 ch->number, ch->partid); 71 ch->number, ch->partid);
66 72
67 spin_unlock_irqrestore(&ch->lock, *irq_flags); 73 ch->flags = (XPC_C_CONNECTED | XPC_C_SETUP); /* clear all else */
68 xpc_create_kthreads(ch, 1, 0);
69 spin_lock_irqsave(&ch->lock, *irq_flags);
70} 74}
71 75
72/* 76/*
@@ -96,7 +100,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
96 100
97 if (part->act_state == XPC_P_AS_DEACTIVATING) { 101 if (part->act_state == XPC_P_AS_DEACTIVATING) {
98 /* can't proceed until the other side disengages from us */ 102 /* can't proceed until the other side disengages from us */
99 if (xpc_partition_engaged(ch->partid)) 103 if (xpc_arch_ops.partition_engaged(ch->partid))
100 return; 104 return;
101 105
102 } else { 106 } else {
@@ -108,7 +112,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
108 112
109 if (!(ch->flags & XPC_C_CLOSEREPLY)) { 113 if (!(ch->flags & XPC_C_CLOSEREPLY)) {
110 ch->flags |= XPC_C_CLOSEREPLY; 114 ch->flags |= XPC_C_CLOSEREPLY;
111 xpc_send_chctl_closereply(ch, irq_flags); 115 xpc_arch_ops.send_chctl_closereply(ch, irq_flags);
112 } 116 }
113 117
114 if (!(ch->flags & XPC_C_RCLOSEREPLY)) 118 if (!(ch->flags & XPC_C_RCLOSEREPLY))
@@ -118,7 +122,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
118 /* wake those waiting for notify completion */ 122 /* wake those waiting for notify completion */
119 if (atomic_read(&ch->n_to_notify) > 0) { 123 if (atomic_read(&ch->n_to_notify) > 0) {
120 /* we do callout while holding ch->lock, callout can't block */ 124 /* we do callout while holding ch->lock, callout can't block */
121 xpc_notify_senders_of_disconnect(ch); 125 xpc_arch_ops.notify_senders_of_disconnect(ch);
122 } 126 }
123 127
124 /* both sides are disconnected now */ 128 /* both sides are disconnected now */
@@ -132,7 +136,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
132 DBUG_ON(atomic_read(&ch->n_to_notify) != 0); 136 DBUG_ON(atomic_read(&ch->n_to_notify) != 0);
133 137
134 /* it's now safe to free the channel's message queues */ 138 /* it's now safe to free the channel's message queues */
135 xpc_teardown_msg_structures(ch); 139 xpc_arch_ops.teardown_msg_structures(ch);
136 140
137 ch->func = NULL; 141 ch->func = NULL;
138 ch->key = NULL; 142 ch->key = NULL;
@@ -144,8 +148,9 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
144 148
145 /* 149 /*
146 * Mark the channel disconnected and clear all other flags, including 150 * Mark the channel disconnected and clear all other flags, including
147 * XPC_C_SETUP (because of call to xpc_teardown_msg_structures()) but 151 * XPC_C_SETUP (because of call to
148 * not including XPC_C_WDISCONNECT (if it was set). 152 * xpc_arch_ops.teardown_msg_structures()) but not including
153 * XPC_C_WDISCONNECT (if it was set).
149 */ 154 */
150 ch->flags = (XPC_C_DISCONNECTED | (ch->flags & XPC_C_WDISCONNECT)); 155 ch->flags = (XPC_C_DISCONNECTED | (ch->flags & XPC_C_WDISCONNECT));
151 156
@@ -184,6 +189,7 @@ xpc_process_openclose_chctl_flags(struct xpc_partition *part, int ch_number,
184 struct xpc_channel *ch = &part->channels[ch_number]; 189 struct xpc_channel *ch = &part->channels[ch_number];
185 enum xp_retval reason; 190 enum xp_retval reason;
186 enum xp_retval ret; 191 enum xp_retval ret;
192 int create_kthread = 0;
187 193
188 spin_lock_irqsave(&ch->lock, irq_flags); 194 spin_lock_irqsave(&ch->lock, irq_flags);
189 195
@@ -196,8 +202,7 @@ again:
196 * has had a chance to see that the channel is disconnected. 202 * has had a chance to see that the channel is disconnected.
197 */ 203 */
198 ch->delayed_chctl_flags |= chctl_flags; 204 ch->delayed_chctl_flags |= chctl_flags;
199 spin_unlock_irqrestore(&ch->lock, irq_flags); 205 goto out;
200 return;
201 } 206 }
202 207
203 if (chctl_flags & XPC_CHCTL_CLOSEREQUEST) { 208 if (chctl_flags & XPC_CHCTL_CLOSEREQUEST) {
@@ -239,8 +244,7 @@ again:
239 XPC_CHCTL_CLOSEREQUEST; 244 XPC_CHCTL_CLOSEREQUEST;
240 spin_unlock(&part->chctl_lock); 245 spin_unlock(&part->chctl_lock);
241 } 246 }
242 spin_unlock_irqrestore(&ch->lock, irq_flags); 247 goto out;
243 return;
244 } 248 }
245 249
246 XPC_SET_REASON(ch, 0, 0); 250 XPC_SET_REASON(ch, 0, 0);
@@ -250,7 +254,8 @@ again:
250 ch->flags |= (XPC_C_CONNECTING | XPC_C_ROPENREQUEST); 254 ch->flags |= (XPC_C_CONNECTING | XPC_C_ROPENREQUEST);
251 } 255 }
252 256
253 chctl_flags &= ~(XPC_CHCTL_OPENREQUEST | XPC_CHCTL_OPENREPLY); 257 chctl_flags &= ~(XPC_CHCTL_OPENREQUEST | XPC_CHCTL_OPENREPLY |
258 XPC_CHCTL_OPENCOMPLETE);
254 259
255 /* 260 /*
256 * The meaningful CLOSEREQUEST connection state fields are: 261 * The meaningful CLOSEREQUEST connection state fields are:
@@ -269,8 +274,7 @@ again:
269 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags); 274 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags);
270 275
271 DBUG_ON(chctl_flags & XPC_CHCTL_CLOSEREPLY); 276 DBUG_ON(chctl_flags & XPC_CHCTL_CLOSEREPLY);
272 spin_unlock_irqrestore(&ch->lock, irq_flags); 277 goto out;
273 return;
274 } 278 }
275 279
276 xpc_process_disconnect(ch, &irq_flags); 280 xpc_process_disconnect(ch, &irq_flags);
@@ -283,8 +287,7 @@ again:
283 287
284 if (ch->flags & XPC_C_DISCONNECTED) { 288 if (ch->flags & XPC_C_DISCONNECTED) {
285 DBUG_ON(part->act_state != XPC_P_AS_DEACTIVATING); 289 DBUG_ON(part->act_state != XPC_P_AS_DEACTIVATING);
286 spin_unlock_irqrestore(&ch->lock, irq_flags); 290 goto out;
287 return;
288 } 291 }
289 292
290 DBUG_ON(!(ch->flags & XPC_C_CLOSEREQUEST)); 293 DBUG_ON(!(ch->flags & XPC_C_CLOSEREQUEST));
@@ -299,8 +302,7 @@ again:
299 XPC_CHCTL_CLOSEREPLY; 302 XPC_CHCTL_CLOSEREPLY;
300 spin_unlock(&part->chctl_lock); 303 spin_unlock(&part->chctl_lock);
301 } 304 }
302 spin_unlock_irqrestore(&ch->lock, irq_flags); 305 goto out;
303 return;
304 } 306 }
305 307
306 ch->flags |= XPC_C_RCLOSEREPLY; 308 ch->flags |= XPC_C_RCLOSEREPLY;
@@ -320,14 +322,12 @@ again:
320 322
321 if (part->act_state == XPC_P_AS_DEACTIVATING || 323 if (part->act_state == XPC_P_AS_DEACTIVATING ||
322 (ch->flags & XPC_C_ROPENREQUEST)) { 324 (ch->flags & XPC_C_ROPENREQUEST)) {
323 spin_unlock_irqrestore(&ch->lock, irq_flags); 325 goto out;
324 return;
325 } 326 }
326 327
327 if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_WDISCONNECT)) { 328 if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_WDISCONNECT)) {
328 ch->delayed_chctl_flags |= XPC_CHCTL_OPENREQUEST; 329 ch->delayed_chctl_flags |= XPC_CHCTL_OPENREQUEST;
329 spin_unlock_irqrestore(&ch->lock, irq_flags); 330 goto out;
330 return;
331 } 331 }
332 DBUG_ON(!(ch->flags & (XPC_C_DISCONNECTED | 332 DBUG_ON(!(ch->flags & (XPC_C_DISCONNECTED |
333 XPC_C_OPENREQUEST))); 333 XPC_C_OPENREQUEST)));
@@ -341,8 +341,7 @@ again:
341 */ 341 */
342 if (args->entry_size == 0 || args->local_nentries == 0) { 342 if (args->entry_size == 0 || args->local_nentries == 0) {
343 /* assume OPENREQUEST was delayed by mistake */ 343 /* assume OPENREQUEST was delayed by mistake */
344 spin_unlock_irqrestore(&ch->lock, irq_flags); 344 goto out;
345 return;
346 } 345 }
347 346
348 ch->flags |= (XPC_C_ROPENREQUEST | XPC_C_CONNECTING); 347 ch->flags |= (XPC_C_ROPENREQUEST | XPC_C_CONNECTING);
@@ -352,8 +351,7 @@ again:
352 if (args->entry_size != ch->entry_size) { 351 if (args->entry_size != ch->entry_size) {
353 XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes, 352 XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes,
354 &irq_flags); 353 &irq_flags);
355 spin_unlock_irqrestore(&ch->lock, irq_flags); 354 goto out;
356 return;
357 } 355 }
358 } else { 356 } else {
359 ch->entry_size = args->entry_size; 357 ch->entry_size = args->entry_size;
@@ -375,15 +373,13 @@ again:
375 args->local_msgqueue_pa, args->local_nentries, 373 args->local_msgqueue_pa, args->local_nentries,
376 args->remote_nentries, ch->partid, ch->number); 374 args->remote_nentries, ch->partid, ch->number);
377 375
378 if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_DISCONNECTED)) { 376 if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_DISCONNECTED))
379 spin_unlock_irqrestore(&ch->lock, irq_flags); 377 goto out;
380 return; 378
381 }
382 if (!(ch->flags & XPC_C_OPENREQUEST)) { 379 if (!(ch->flags & XPC_C_OPENREQUEST)) {
383 XPC_DISCONNECT_CHANNEL(ch, xpOpenCloseError, 380 XPC_DISCONNECT_CHANNEL(ch, xpOpenCloseError,
384 &irq_flags); 381 &irq_flags);
385 spin_unlock_irqrestore(&ch->lock, irq_flags); 382 goto out;
386 return;
387 } 383 }
388 384
389 DBUG_ON(!(ch->flags & XPC_C_ROPENREQUEST)); 385 DBUG_ON(!(ch->flags & XPC_C_ROPENREQUEST));
@@ -400,11 +396,11 @@ again:
400 DBUG_ON(args->local_nentries == 0); 396 DBUG_ON(args->local_nentries == 0);
401 DBUG_ON(args->remote_nentries == 0); 397 DBUG_ON(args->remote_nentries == 0);
402 398
403 ret = xpc_save_remote_msgqueue_pa(ch, args->local_msgqueue_pa); 399 ret = xpc_arch_ops.save_remote_msgqueue_pa(ch,
400 args->local_msgqueue_pa);
404 if (ret != xpSuccess) { 401 if (ret != xpSuccess) {
405 XPC_DISCONNECT_CHANNEL(ch, ret, &irq_flags); 402 XPC_DISCONNECT_CHANNEL(ch, ret, &irq_flags);
406 spin_unlock_irqrestore(&ch->lock, irq_flags); 403 goto out;
407 return;
408 } 404 }
409 ch->flags |= XPC_C_ROPENREPLY; 405 ch->flags |= XPC_C_ROPENREPLY;
410 406
@@ -430,7 +426,36 @@ again:
430 xpc_process_connect(ch, &irq_flags); 426 xpc_process_connect(ch, &irq_flags);
431 } 427 }
432 428
429 if (chctl_flags & XPC_CHCTL_OPENCOMPLETE) {
430
431 dev_dbg(xpc_chan, "XPC_CHCTL_OPENCOMPLETE received from "
432 "partid=%d, channel=%d\n", ch->partid, ch->number);
433
434 if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_DISCONNECTED))
435 goto out;
436
437 if (!(ch->flags & XPC_C_OPENREQUEST) ||
438 !(ch->flags & XPC_C_OPENREPLY)) {
439 XPC_DISCONNECT_CHANNEL(ch, xpOpenCloseError,
440 &irq_flags);
441 goto out;
442 }
443
444 DBUG_ON(!(ch->flags & XPC_C_ROPENREQUEST));
445 DBUG_ON(!(ch->flags & XPC_C_ROPENREPLY));
446 DBUG_ON(!(ch->flags & XPC_C_CONNECTED));
447
448 ch->flags |= XPC_C_ROPENCOMPLETE;
449
450 xpc_process_connect(ch, &irq_flags);
451 create_kthread = 1;
452 }
453
454out:
433 spin_unlock_irqrestore(&ch->lock, irq_flags); 455 spin_unlock_irqrestore(&ch->lock, irq_flags);
456
457 if (create_kthread)
458 xpc_create_kthreads(ch, 1, 0);
434} 459}
435 460
436/* 461/*
@@ -508,7 +533,7 @@ xpc_connect_channel(struct xpc_channel *ch)
508 /* initiate the connection */ 533 /* initiate the connection */
509 534
510 ch->flags |= (XPC_C_OPENREQUEST | XPC_C_CONNECTING); 535 ch->flags |= (XPC_C_OPENREQUEST | XPC_C_CONNECTING);
511 xpc_send_chctl_openrequest(ch, &irq_flags); 536 xpc_arch_ops.send_chctl_openrequest(ch, &irq_flags);
512 537
513 xpc_process_connect(ch, &irq_flags); 538 xpc_process_connect(ch, &irq_flags);
514 539
@@ -526,7 +551,7 @@ xpc_process_sent_chctl_flags(struct xpc_partition *part)
526 int ch_number; 551 int ch_number;
527 u32 ch_flags; 552 u32 ch_flags;
528 553
529 chctl.all_flags = xpc_get_chctl_all_flags(part); 554 chctl.all_flags = xpc_arch_ops.get_chctl_all_flags(part);
530 555
531 /* 556 /*
532 * Initiate channel connections for registered channels. 557 * Initiate channel connections for registered channels.
@@ -564,10 +589,6 @@ xpc_process_sent_chctl_flags(struct xpc_partition *part)
564 if (!(ch_flags & XPC_C_OPENREQUEST)) { 589 if (!(ch_flags & XPC_C_OPENREQUEST)) {
565 DBUG_ON(ch_flags & XPC_C_SETUP); 590 DBUG_ON(ch_flags & XPC_C_SETUP);
566 (void)xpc_connect_channel(ch); 591 (void)xpc_connect_channel(ch);
567 } else {
568 spin_lock_irqsave(&ch->lock, irq_flags);
569 xpc_process_connect(ch, &irq_flags);
570 spin_unlock_irqrestore(&ch->lock, irq_flags);
571 } 592 }
572 continue; 593 continue;
573 } 594 }
@@ -579,7 +600,7 @@ xpc_process_sent_chctl_flags(struct xpc_partition *part)
579 */ 600 */
580 601
581 if (chctl.flags[ch_number] & XPC_MSG_CHCTL_FLAGS) 602 if (chctl.flags[ch_number] & XPC_MSG_CHCTL_FLAGS)
582 xpc_process_msg_chctl_flags(part, ch_number); 603 xpc_arch_ops.process_msg_chctl_flags(part, ch_number);
583 } 604 }
584} 605}
585 606
@@ -755,7 +776,7 @@ xpc_disconnect_channel(const int line, struct xpc_channel *ch,
755 XPC_C_ROPENREQUEST | XPC_C_ROPENREPLY | 776 XPC_C_ROPENREQUEST | XPC_C_ROPENREPLY |
756 XPC_C_CONNECTING | XPC_C_CONNECTED); 777 XPC_C_CONNECTING | XPC_C_CONNECTED);
757 778
758 xpc_send_chctl_closerequest(ch, irq_flags); 779 xpc_arch_ops.send_chctl_closerequest(ch, irq_flags);
759 780
760 if (channel_was_connected) 781 if (channel_was_connected)
761 ch->flags |= XPC_C_WASCONNECTED; 782 ch->flags |= XPC_C_WASCONNECTED;
@@ -862,8 +883,8 @@ xpc_initiate_send(short partid, int ch_number, u32 flags, void *payload,
862 DBUG_ON(payload == NULL); 883 DBUG_ON(payload == NULL);
863 884
864 if (xpc_part_ref(part)) { 885 if (xpc_part_ref(part)) {
865 ret = xpc_send_payload(&part->channels[ch_number], flags, 886 ret = xpc_arch_ops.send_payload(&part->channels[ch_number],
866 payload, payload_size, 0, NULL, NULL); 887 flags, payload, payload_size, 0, NULL, NULL);
867 xpc_part_deref(part); 888 xpc_part_deref(part);
868 } 889 }
869 890
@@ -914,9 +935,8 @@ xpc_initiate_send_notify(short partid, int ch_number, u32 flags, void *payload,
914 DBUG_ON(func == NULL); 935 DBUG_ON(func == NULL);
915 936
916 if (xpc_part_ref(part)) { 937 if (xpc_part_ref(part)) {
917 ret = xpc_send_payload(&part->channels[ch_number], flags, 938 ret = xpc_arch_ops.send_payload(&part->channels[ch_number],
918 payload, payload_size, XPC_N_CALL, func, 939 flags, payload, payload_size, XPC_N_CALL, func, key);
919 key);
920 xpc_part_deref(part); 940 xpc_part_deref(part);
921 } 941 }
922 return ret; 942 return ret;
@@ -930,7 +950,7 @@ xpc_deliver_payload(struct xpc_channel *ch)
930{ 950{
931 void *payload; 951 void *payload;
932 952
933 payload = xpc_get_deliverable_payload(ch); 953 payload = xpc_arch_ops.get_deliverable_payload(ch);
934 if (payload != NULL) { 954 if (payload != NULL) {
935 955
936 /* 956 /*
@@ -984,7 +1004,7 @@ xpc_initiate_received(short partid, int ch_number, void *payload)
984 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels); 1004 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
985 1005
986 ch = &part->channels[ch_number]; 1006 ch = &part->channels[ch_number];
987 xpc_received_payload(ch, payload); 1007 xpc_arch_ops.received_payload(ch, payload);
988 1008
989 /* the call to xpc_msgqueue_ref() was done by xpc_deliver_payload() */ 1009 /* the call to xpc_msgqueue_ref() was done by xpc_deliver_payload() */
990 xpc_msgqueue_deref(ch); 1010 xpc_msgqueue_deref(ch);
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index 1ab9fda87fab..fd3688a3e23f 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2004-2009 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* 9/*
@@ -150,7 +150,6 @@ DECLARE_WAIT_QUEUE_HEAD(xpc_activate_IRQ_wq);
150 150
151static unsigned long xpc_hb_check_timeout; 151static unsigned long xpc_hb_check_timeout;
152static struct timer_list xpc_hb_timer; 152static struct timer_list xpc_hb_timer;
153void *xpc_heartbeating_to_mask;
154 153
155/* notification that the xpc_hb_checker thread has exited */ 154/* notification that the xpc_hb_checker thread has exited */
156static DECLARE_COMPLETION(xpc_hb_checker_exited); 155static DECLARE_COMPLETION(xpc_hb_checker_exited);
@@ -170,62 +169,7 @@ static struct notifier_block xpc_die_notifier = {
170 .notifier_call = xpc_system_die, 169 .notifier_call = xpc_system_die,
171}; 170};
172 171
173int (*xpc_setup_partitions_sn) (void); 172struct xpc_arch_operations xpc_arch_ops;
174void (*xpc_teardown_partitions_sn) (void);
175enum xp_retval (*xpc_get_partition_rsvd_page_pa) (void *buf, u64 *cookie,
176 unsigned long *rp_pa,
177 size_t *len);
178int (*xpc_setup_rsvd_page_sn) (struct xpc_rsvd_page *rp);
179void (*xpc_heartbeat_init) (void);
180void (*xpc_heartbeat_exit) (void);
181void (*xpc_increment_heartbeat) (void);
182void (*xpc_offline_heartbeat) (void);
183void (*xpc_online_heartbeat) (void);
184enum xp_retval (*xpc_get_remote_heartbeat) (struct xpc_partition *part);
185
186enum xp_retval (*xpc_make_first_contact) (struct xpc_partition *part);
187void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *ch);
188u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *part);
189enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *ch);
190void (*xpc_teardown_msg_structures) (struct xpc_channel *ch);
191void (*xpc_process_msg_chctl_flags) (struct xpc_partition *part, int ch_number);
192int (*xpc_n_of_deliverable_payloads) (struct xpc_channel *ch);
193void *(*xpc_get_deliverable_payload) (struct xpc_channel *ch);
194
195void (*xpc_request_partition_activation) (struct xpc_rsvd_page *remote_rp,
196 unsigned long remote_rp_pa,
197 int nasid);
198void (*xpc_request_partition_reactivation) (struct xpc_partition *part);
199void (*xpc_request_partition_deactivation) (struct xpc_partition *part);
200void (*xpc_cancel_partition_deactivation_request) (struct xpc_partition *part);
201
202void (*xpc_process_activate_IRQ_rcvd) (void);
203enum xp_retval (*xpc_setup_ch_structures_sn) (struct xpc_partition *part);
204void (*xpc_teardown_ch_structures_sn) (struct xpc_partition *part);
205
206void (*xpc_indicate_partition_engaged) (struct xpc_partition *part);
207int (*xpc_partition_engaged) (short partid);
208int (*xpc_any_partition_engaged) (void);
209void (*xpc_indicate_partition_disengaged) (struct xpc_partition *part);
210void (*xpc_assume_partition_disengaged) (short partid);
211
212void (*xpc_send_chctl_closerequest) (struct xpc_channel *ch,
213 unsigned long *irq_flags);
214void (*xpc_send_chctl_closereply) (struct xpc_channel *ch,
215 unsigned long *irq_flags);
216void (*xpc_send_chctl_openrequest) (struct xpc_channel *ch,
217 unsigned long *irq_flags);
218void (*xpc_send_chctl_openreply) (struct xpc_channel *ch,
219 unsigned long *irq_flags);
220
221enum xp_retval (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *ch,
222 unsigned long msgqueue_pa);
223
224enum xp_retval (*xpc_send_payload) (struct xpc_channel *ch, u32 flags,
225 void *payload, u16 payload_size,
226 u8 notify_type, xpc_notify_func func,
227 void *key);
228void (*xpc_received_payload) (struct xpc_channel *ch, void *payload);
229 173
230/* 174/*
231 * Timer function to enforce the timelimit on the partition disengage. 175 * Timer function to enforce the timelimit on the partition disengage.
@@ -240,7 +184,7 @@ xpc_timeout_partition_disengage(unsigned long data)
240 (void)xpc_partition_disengaged(part); 184 (void)xpc_partition_disengaged(part);
241 185
242 DBUG_ON(part->disengage_timeout != 0); 186 DBUG_ON(part->disengage_timeout != 0);
243 DBUG_ON(xpc_partition_engaged(XPC_PARTID(part))); 187 DBUG_ON(xpc_arch_ops.partition_engaged(XPC_PARTID(part)));
244} 188}
245 189
246/* 190/*
@@ -251,7 +195,7 @@ xpc_timeout_partition_disengage(unsigned long data)
251static void 195static void
252xpc_hb_beater(unsigned long dummy) 196xpc_hb_beater(unsigned long dummy)
253{ 197{
254 xpc_increment_heartbeat(); 198 xpc_arch_ops.increment_heartbeat();
255 199
256 if (time_is_before_eq_jiffies(xpc_hb_check_timeout)) 200 if (time_is_before_eq_jiffies(xpc_hb_check_timeout))
257 wake_up_interruptible(&xpc_activate_IRQ_wq); 201 wake_up_interruptible(&xpc_activate_IRQ_wq);
@@ -263,7 +207,7 @@ xpc_hb_beater(unsigned long dummy)
263static void 207static void
264xpc_start_hb_beater(void) 208xpc_start_hb_beater(void)
265{ 209{
266 xpc_heartbeat_init(); 210 xpc_arch_ops.heartbeat_init();
267 init_timer(&xpc_hb_timer); 211 init_timer(&xpc_hb_timer);
268 xpc_hb_timer.function = xpc_hb_beater; 212 xpc_hb_timer.function = xpc_hb_beater;
269 xpc_hb_beater(0); 213 xpc_hb_beater(0);
@@ -273,7 +217,7 @@ static void
273xpc_stop_hb_beater(void) 217xpc_stop_hb_beater(void)
274{ 218{
275 del_timer_sync(&xpc_hb_timer); 219 del_timer_sync(&xpc_hb_timer);
276 xpc_heartbeat_exit(); 220 xpc_arch_ops.heartbeat_exit();
277} 221}
278 222
279/* 223/*
@@ -302,7 +246,7 @@ xpc_check_remote_hb(void)
302 continue; 246 continue;
303 } 247 }
304 248
305 ret = xpc_get_remote_heartbeat(part); 249 ret = xpc_arch_ops.get_remote_heartbeat(part);
306 if (ret != xpSuccess) 250 if (ret != xpSuccess)
307 XPC_DEACTIVATE_PARTITION(part, ret); 251 XPC_DEACTIVATE_PARTITION(part, ret);
308 } 252 }
@@ -353,7 +297,7 @@ xpc_hb_checker(void *ignore)
353 force_IRQ = 0; 297 force_IRQ = 0;
354 dev_dbg(xpc_part, "processing activate IRQs " 298 dev_dbg(xpc_part, "processing activate IRQs "
355 "received\n"); 299 "received\n");
356 xpc_process_activate_IRQ_rcvd(); 300 xpc_arch_ops.process_activate_IRQ_rcvd();
357 } 301 }
358 302
359 /* wait for IRQ or timeout */ 303 /* wait for IRQ or timeout */
@@ -528,7 +472,7 @@ xpc_setup_ch_structures(struct xpc_partition *part)
528 init_waitqueue_head(&ch->idle_wq); 472 init_waitqueue_head(&ch->idle_wq);
529 } 473 }
530 474
531 ret = xpc_setup_ch_structures_sn(part); 475 ret = xpc_arch_ops.setup_ch_structures(part);
532 if (ret != xpSuccess) 476 if (ret != xpSuccess)
533 goto out_2; 477 goto out_2;
534 478
@@ -572,7 +516,7 @@ xpc_teardown_ch_structures(struct xpc_partition *part)
572 516
573 /* now we can begin tearing down the infrastructure */ 517 /* now we can begin tearing down the infrastructure */
574 518
575 xpc_teardown_ch_structures_sn(part); 519 xpc_arch_ops.teardown_ch_structures(part);
576 520
577 kfree(part->remote_openclose_args_base); 521 kfree(part->remote_openclose_args_base);
578 part->remote_openclose_args = NULL; 522 part->remote_openclose_args = NULL;
@@ -620,12 +564,12 @@ xpc_activating(void *__partid)
620 564
621 dev_dbg(xpc_part, "activating partition %d\n", partid); 565 dev_dbg(xpc_part, "activating partition %d\n", partid);
622 566
623 xpc_allow_hb(partid); 567 xpc_arch_ops.allow_hb(partid);
624 568
625 if (xpc_setup_ch_structures(part) == xpSuccess) { 569 if (xpc_setup_ch_structures(part) == xpSuccess) {
626 (void)xpc_part_ref(part); /* this will always succeed */ 570 (void)xpc_part_ref(part); /* this will always succeed */
627 571
628 if (xpc_make_first_contact(part) == xpSuccess) { 572 if (xpc_arch_ops.make_first_contact(part) == xpSuccess) {
629 xpc_mark_partition_active(part); 573 xpc_mark_partition_active(part);
630 xpc_channel_mgr(part); 574 xpc_channel_mgr(part);
631 /* won't return until partition is deactivating */ 575 /* won't return until partition is deactivating */
@@ -635,12 +579,12 @@ xpc_activating(void *__partid)
635 xpc_teardown_ch_structures(part); 579 xpc_teardown_ch_structures(part);
636 } 580 }
637 581
638 xpc_disallow_hb(partid); 582 xpc_arch_ops.disallow_hb(partid);
639 xpc_mark_partition_inactive(part); 583 xpc_mark_partition_inactive(part);
640 584
641 if (part->reason == xpReactivating) { 585 if (part->reason == xpReactivating) {
642 /* interrupting ourselves results in activating partition */ 586 /* interrupting ourselves results in activating partition */
643 xpc_request_partition_reactivation(part); 587 xpc_arch_ops.request_partition_reactivation(part);
644 } 588 }
645 589
646 return 0; 590 return 0;
@@ -713,10 +657,13 @@ xpc_activate_kthreads(struct xpc_channel *ch, int needed)
713static void 657static void
714xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch) 658xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
715{ 659{
660 int (*n_of_deliverable_payloads) (struct xpc_channel *) =
661 xpc_arch_ops.n_of_deliverable_payloads;
662
716 do { 663 do {
717 /* deliver messages to their intended recipients */ 664 /* deliver messages to their intended recipients */
718 665
719 while (xpc_n_of_deliverable_payloads(ch) > 0 && 666 while (n_of_deliverable_payloads(ch) > 0 &&
720 !(ch->flags & XPC_C_DISCONNECTING)) { 667 !(ch->flags & XPC_C_DISCONNECTING)) {
721 xpc_deliver_payload(ch); 668 xpc_deliver_payload(ch);
722 } 669 }
@@ -732,7 +679,7 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
732 "wait_event_interruptible_exclusive()\n"); 679 "wait_event_interruptible_exclusive()\n");
733 680
734 (void)wait_event_interruptible_exclusive(ch->idle_wq, 681 (void)wait_event_interruptible_exclusive(ch->idle_wq,
735 (xpc_n_of_deliverable_payloads(ch) > 0 || 682 (n_of_deliverable_payloads(ch) > 0 ||
736 (ch->flags & XPC_C_DISCONNECTING))); 683 (ch->flags & XPC_C_DISCONNECTING)));
737 684
738 atomic_dec(&ch->kthreads_idle); 685 atomic_dec(&ch->kthreads_idle);
@@ -749,6 +696,8 @@ xpc_kthread_start(void *args)
749 struct xpc_channel *ch; 696 struct xpc_channel *ch;
750 int n_needed; 697 int n_needed;
751 unsigned long irq_flags; 698 unsigned long irq_flags;
699 int (*n_of_deliverable_payloads) (struct xpc_channel *) =
700 xpc_arch_ops.n_of_deliverable_payloads;
752 701
753 dev_dbg(xpc_chan, "kthread starting, partid=%d, channel=%d\n", 702 dev_dbg(xpc_chan, "kthread starting, partid=%d, channel=%d\n",
754 partid, ch_number); 703 partid, ch_number);
@@ -777,7 +726,7 @@ xpc_kthread_start(void *args)
777 * additional kthreads to help deliver them. We only 726 * additional kthreads to help deliver them. We only
778 * need one less than total #of messages to deliver. 727 * need one less than total #of messages to deliver.
779 */ 728 */
780 n_needed = xpc_n_of_deliverable_payloads(ch) - 1; 729 n_needed = n_of_deliverable_payloads(ch) - 1;
781 if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING)) 730 if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING))
782 xpc_activate_kthreads(ch, n_needed); 731 xpc_activate_kthreads(ch, n_needed);
783 732
@@ -805,7 +754,7 @@ xpc_kthread_start(void *args)
805 754
806 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && 755 if (atomic_dec_return(&ch->kthreads_assigned) == 0 &&
807 atomic_dec_return(&part->nchannels_engaged) == 0) { 756 atomic_dec_return(&part->nchannels_engaged) == 0) {
808 xpc_indicate_partition_disengaged(part); 757 xpc_arch_ops.indicate_partition_disengaged(part);
809 } 758 }
810 759
811 xpc_msgqueue_deref(ch); 760 xpc_msgqueue_deref(ch);
@@ -837,6 +786,8 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed,
837 u64 args = XPC_PACK_ARGS(ch->partid, ch->number); 786 u64 args = XPC_PACK_ARGS(ch->partid, ch->number);
838 struct xpc_partition *part = &xpc_partitions[ch->partid]; 787 struct xpc_partition *part = &xpc_partitions[ch->partid];
839 struct task_struct *kthread; 788 struct task_struct *kthread;
789 void (*indicate_partition_disengaged) (struct xpc_partition *) =
790 xpc_arch_ops.indicate_partition_disengaged;
840 791
841 while (needed-- > 0) { 792 while (needed-- > 0) {
842 793
@@ -858,7 +809,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed,
858 809
859 } else if (atomic_inc_return(&ch->kthreads_assigned) == 1 && 810 } else if (atomic_inc_return(&ch->kthreads_assigned) == 1 &&
860 atomic_inc_return(&part->nchannels_engaged) == 1) { 811 atomic_inc_return(&part->nchannels_engaged) == 1) {
861 xpc_indicate_partition_engaged(part); 812 xpc_arch_ops.indicate_partition_engaged(part);
862 } 813 }
863 (void)xpc_part_ref(part); 814 (void)xpc_part_ref(part);
864 xpc_msgqueue_ref(ch); 815 xpc_msgqueue_ref(ch);
@@ -880,7 +831,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed,
880 831
881 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && 832 if (atomic_dec_return(&ch->kthreads_assigned) == 0 &&
882 atomic_dec_return(&part->nchannels_engaged) == 0) { 833 atomic_dec_return(&part->nchannels_engaged) == 0) {
883 xpc_indicate_partition_disengaged(part); 834 indicate_partition_disengaged(part);
884 } 835 }
885 xpc_msgqueue_deref(ch); 836 xpc_msgqueue_deref(ch);
886 xpc_part_deref(part); 837 xpc_part_deref(part);
@@ -993,13 +944,13 @@ xpc_setup_partitions(void)
993 atomic_set(&part->references, 0); 944 atomic_set(&part->references, 0);
994 } 945 }
995 946
996 return xpc_setup_partitions_sn(); 947 return xpc_arch_ops.setup_partitions();
997} 948}
998 949
999static void 950static void
1000xpc_teardown_partitions(void) 951xpc_teardown_partitions(void)
1001{ 952{
1002 xpc_teardown_partitions_sn(); 953 xpc_arch_ops.teardown_partitions();
1003 kfree(xpc_partitions); 954 kfree(xpc_partitions);
1004} 955}
1005 956
@@ -1055,7 +1006,7 @@ xpc_do_exit(enum xp_retval reason)
1055 disengage_timeout = part->disengage_timeout; 1006 disengage_timeout = part->disengage_timeout;
1056 } 1007 }
1057 1008
1058 if (xpc_any_partition_engaged()) { 1009 if (xpc_arch_ops.any_partition_engaged()) {
1059 if (time_is_before_jiffies(printmsg_time)) { 1010 if (time_is_before_jiffies(printmsg_time)) {
1060 dev_info(xpc_part, "waiting for remote " 1011 dev_info(xpc_part, "waiting for remote "
1061 "partitions to deactivate, timeout in " 1012 "partitions to deactivate, timeout in "
@@ -1086,8 +1037,7 @@ xpc_do_exit(enum xp_retval reason)
1086 1037
1087 } while (1); 1038 } while (1);
1088 1039
1089 DBUG_ON(xpc_any_partition_engaged()); 1040 DBUG_ON(xpc_arch_ops.any_partition_engaged());
1090 DBUG_ON(xpc_any_hbs_allowed() != 0);
1091 1041
1092 xpc_teardown_rsvd_page(); 1042 xpc_teardown_rsvd_page();
1093 1043
@@ -1152,15 +1102,15 @@ xpc_die_deactivate(void)
1152 /* keep xpc_hb_checker thread from doing anything (just in case) */ 1102 /* keep xpc_hb_checker thread from doing anything (just in case) */
1153 xpc_exiting = 1; 1103 xpc_exiting = 1;
1154 1104
1155 xpc_disallow_all_hbs(); /*indicate we're deactivated */ 1105 xpc_arch_ops.disallow_all_hbs(); /*indicate we're deactivated */
1156 1106
1157 for (partid = 0; partid < xp_max_npartitions; partid++) { 1107 for (partid = 0; partid < xp_max_npartitions; partid++) {
1158 part = &xpc_partitions[partid]; 1108 part = &xpc_partitions[partid];
1159 1109
1160 if (xpc_partition_engaged(partid) || 1110 if (xpc_arch_ops.partition_engaged(partid) ||
1161 part->act_state != XPC_P_AS_INACTIVE) { 1111 part->act_state != XPC_P_AS_INACTIVE) {
1162 xpc_request_partition_deactivation(part); 1112 xpc_arch_ops.request_partition_deactivation(part);
1163 xpc_indicate_partition_disengaged(part); 1113 xpc_arch_ops.indicate_partition_disengaged(part);
1164 } 1114 }
1165 } 1115 }
1166 1116
@@ -1177,7 +1127,7 @@ xpc_die_deactivate(void)
1177 wait_to_print = XPC_DEACTIVATE_PRINTMSG_INTERVAL * 1000 * 5; 1127 wait_to_print = XPC_DEACTIVATE_PRINTMSG_INTERVAL * 1000 * 5;
1178 1128
1179 while (1) { 1129 while (1) {
1180 any_engaged = xpc_any_partition_engaged(); 1130 any_engaged = xpc_arch_ops.any_partition_engaged();
1181 if (!any_engaged) { 1131 if (!any_engaged) {
1182 dev_info(xpc_part, "all partitions have deactivated\n"); 1132 dev_info(xpc_part, "all partitions have deactivated\n");
1183 break; 1133 break;
@@ -1186,7 +1136,7 @@ xpc_die_deactivate(void)
1186 if (!keep_waiting--) { 1136 if (!keep_waiting--) {
1187 for (partid = 0; partid < xp_max_npartitions; 1137 for (partid = 0; partid < xp_max_npartitions;
1188 partid++) { 1138 partid++) {
1189 if (xpc_partition_engaged(partid)) { 1139 if (xpc_arch_ops.partition_engaged(partid)) {
1190 dev_info(xpc_part, "deactivate from " 1140 dev_info(xpc_part, "deactivate from "
1191 "remote partition %d timed " 1141 "remote partition %d timed "
1192 "out\n", partid); 1142 "out\n", partid);
@@ -1233,7 +1183,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *unused)
1233 /* fall through */ 1183 /* fall through */
1234 case DIE_MCA_MONARCH_ENTER: 1184 case DIE_MCA_MONARCH_ENTER:
1235 case DIE_INIT_MONARCH_ENTER: 1185 case DIE_INIT_MONARCH_ENTER:
1236 xpc_offline_heartbeat(); 1186 xpc_arch_ops.offline_heartbeat();
1237 break; 1187 break;
1238 1188
1239 case DIE_KDEBUG_LEAVE: 1189 case DIE_KDEBUG_LEAVE:
@@ -1244,7 +1194,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *unused)
1244 /* fall through */ 1194 /* fall through */
1245 case DIE_MCA_MONARCH_LEAVE: 1195 case DIE_MCA_MONARCH_LEAVE:
1246 case DIE_INIT_MONARCH_LEAVE: 1196 case DIE_INIT_MONARCH_LEAVE:
1247 xpc_online_heartbeat(); 1197 xpc_arch_ops.online_heartbeat();
1248 break; 1198 break;
1249 } 1199 }
1250#else 1200#else
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
index 6722f6fe4dc7..65877bc5edaa 100644
--- a/drivers/misc/sgi-xp/xpc_partition.c
+++ b/drivers/misc/sgi-xp/xpc_partition.c
@@ -70,6 +70,9 @@ xpc_get_rsvd_page_pa(int nasid)
70 size_t buf_len = 0; 70 size_t buf_len = 0;
71 void *buf = buf; 71 void *buf = buf;
72 void *buf_base = NULL; 72 void *buf_base = NULL;
73 enum xp_retval (*get_partition_rsvd_page_pa)
74 (void *, u64 *, unsigned long *, size_t *) =
75 xpc_arch_ops.get_partition_rsvd_page_pa;
73 76
74 while (1) { 77 while (1) {
75 78
@@ -79,8 +82,7 @@ xpc_get_rsvd_page_pa(int nasid)
79 * ??? function or have two versions? Rename rp_pa for UV to 82 * ??? function or have two versions? Rename rp_pa for UV to
80 * ??? rp_gpa? 83 * ??? rp_gpa?
81 */ 84 */
82 ret = xpc_get_partition_rsvd_page_pa(buf, &cookie, &rp_pa, 85 ret = get_partition_rsvd_page_pa(buf, &cookie, &rp_pa, &len);
83 &len);
84 86
85 dev_dbg(xpc_part, "SAL returned with ret=%d, cookie=0x%016lx, " 87 dev_dbg(xpc_part, "SAL returned with ret=%d, cookie=0x%016lx, "
86 "address=0x%016lx, len=0x%016lx\n", ret, 88 "address=0x%016lx, len=0x%016lx\n", ret,
@@ -172,7 +174,7 @@ xpc_setup_rsvd_page(void)
172 xpc_part_nasids = XPC_RP_PART_NASIDS(rp); 174 xpc_part_nasids = XPC_RP_PART_NASIDS(rp);
173 xpc_mach_nasids = XPC_RP_MACH_NASIDS(rp); 175 xpc_mach_nasids = XPC_RP_MACH_NASIDS(rp);
174 176
175 ret = xpc_setup_rsvd_page_sn(rp); 177 ret = xpc_arch_ops.setup_rsvd_page(rp);
176 if (ret != 0) 178 if (ret != 0)
177 return ret; 179 return ret;
178 180
@@ -264,7 +266,7 @@ xpc_partition_disengaged(struct xpc_partition *part)
264 short partid = XPC_PARTID(part); 266 short partid = XPC_PARTID(part);
265 int disengaged; 267 int disengaged;
266 268
267 disengaged = !xpc_partition_engaged(partid); 269 disengaged = !xpc_arch_ops.partition_engaged(partid);
268 if (part->disengage_timeout) { 270 if (part->disengage_timeout) {
269 if (!disengaged) { 271 if (!disengaged) {
270 if (time_is_after_jiffies(part->disengage_timeout)) { 272 if (time_is_after_jiffies(part->disengage_timeout)) {
@@ -280,7 +282,7 @@ xpc_partition_disengaged(struct xpc_partition *part)
280 dev_info(xpc_part, "deactivate request to remote " 282 dev_info(xpc_part, "deactivate request to remote "
281 "partition %d timed out\n", partid); 283 "partition %d timed out\n", partid);
282 xpc_disengage_timedout = 1; 284 xpc_disengage_timedout = 1;
283 xpc_assume_partition_disengaged(partid); 285 xpc_arch_ops.assume_partition_disengaged(partid);
284 disengaged = 1; 286 disengaged = 1;
285 } 287 }
286 part->disengage_timeout = 0; 288 part->disengage_timeout = 0;
@@ -294,7 +296,7 @@ xpc_partition_disengaged(struct xpc_partition *part)
294 if (part->act_state != XPC_P_AS_INACTIVE) 296 if (part->act_state != XPC_P_AS_INACTIVE)
295 xpc_wakeup_channel_mgr(part); 297 xpc_wakeup_channel_mgr(part);
296 298
297 xpc_cancel_partition_deactivation_request(part); 299 xpc_arch_ops.cancel_partition_deactivation_request(part);
298 } 300 }
299 return disengaged; 301 return disengaged;
300} 302}
@@ -339,7 +341,7 @@ xpc_deactivate_partition(const int line, struct xpc_partition *part,
339 spin_unlock_irqrestore(&part->act_lock, irq_flags); 341 spin_unlock_irqrestore(&part->act_lock, irq_flags);
340 if (reason == xpReactivating) { 342 if (reason == xpReactivating) {
341 /* we interrupt ourselves to reactivate partition */ 343 /* we interrupt ourselves to reactivate partition */
342 xpc_request_partition_reactivation(part); 344 xpc_arch_ops.request_partition_reactivation(part);
343 } 345 }
344 return; 346 return;
345 } 347 }
@@ -358,7 +360,7 @@ xpc_deactivate_partition(const int line, struct xpc_partition *part,
358 spin_unlock_irqrestore(&part->act_lock, irq_flags); 360 spin_unlock_irqrestore(&part->act_lock, irq_flags);
359 361
360 /* ask remote partition to deactivate with regard to us */ 362 /* ask remote partition to deactivate with regard to us */
361 xpc_request_partition_deactivation(part); 363 xpc_arch_ops.request_partition_deactivation(part);
362 364
363 /* set a timelimit on the disengage phase of the deactivation request */ 365 /* set a timelimit on the disengage phase of the deactivation request */
364 part->disengage_timeout = jiffies + (xpc_disengage_timelimit * HZ); 366 part->disengage_timeout = jiffies + (xpc_disengage_timelimit * HZ);
@@ -496,7 +498,7 @@ xpc_discovery(void)
496 continue; 498 continue;
497 } 499 }
498 500
499 xpc_request_partition_activation(remote_rp, 501 xpc_arch_ops.request_partition_activation(remote_rp,
500 remote_rp_pa, nasid); 502 remote_rp_pa, nasid);
501 } 503 }
502 } 504 }
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index eaaa964942de..915a3b495da5 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2008-2009 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* 9/*
@@ -60,14 +60,14 @@ static struct xpc_vars_sn2 *xpc_vars_sn2;
60static struct xpc_vars_part_sn2 *xpc_vars_part_sn2; 60static struct xpc_vars_part_sn2 *xpc_vars_part_sn2;
61 61
62static int 62static int
63xpc_setup_partitions_sn_sn2(void) 63xpc_setup_partitions_sn2(void)
64{ 64{
65 /* nothing needs to be done */ 65 /* nothing needs to be done */
66 return 0; 66 return 0;
67} 67}
68 68
69static void 69static void
70xpc_teardown_partitions_sn_sn2(void) 70xpc_teardown_partitions_sn2(void)
71{ 71{
72 /* nothing needs to be done */ 72 /* nothing needs to be done */
73} 73}
@@ -431,6 +431,13 @@ xpc_send_chctl_openreply_sn2(struct xpc_channel *ch, unsigned long *irq_flags)
431} 431}
432 432
433static void 433static void
434xpc_send_chctl_opencomplete_sn2(struct xpc_channel *ch,
435 unsigned long *irq_flags)
436{
437 XPC_SEND_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_OPENCOMPLETE, irq_flags);
438}
439
440static void
434xpc_send_chctl_msgrequest_sn2(struct xpc_channel *ch) 441xpc_send_chctl_msgrequest_sn2(struct xpc_channel *ch)
435{ 442{
436 XPC_SEND_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_MSGREQUEST, NULL); 443 XPC_SEND_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_MSGREQUEST, NULL);
@@ -621,7 +628,7 @@ xpc_get_partition_rsvd_page_pa_sn2(void *buf, u64 *cookie, unsigned long *rp_pa,
621 628
622 629
623static int 630static int
624xpc_setup_rsvd_page_sn_sn2(struct xpc_rsvd_page *rp) 631xpc_setup_rsvd_page_sn2(struct xpc_rsvd_page *rp)
625{ 632{
626 struct amo *amos_page; 633 struct amo *amos_page;
627 int i; 634 int i;
@@ -629,7 +636,7 @@ xpc_setup_rsvd_page_sn_sn2(struct xpc_rsvd_page *rp)
629 636
630 xpc_vars_sn2 = XPC_RP_VARS(rp); 637 xpc_vars_sn2 = XPC_RP_VARS(rp);
631 638
632 rp->sn.vars_pa = xp_pa(xpc_vars_sn2); 639 rp->sn.sn2.vars_pa = xp_pa(xpc_vars_sn2);
633 640
634 /* vars_part array follows immediately after vars */ 641 /* vars_part array follows immediately after vars */
635 xpc_vars_part_sn2 = (struct xpc_vars_part_sn2 *)((u8 *)XPC_RP_VARS(rp) + 642 xpc_vars_part_sn2 = (struct xpc_vars_part_sn2 *)((u8 *)XPC_RP_VARS(rp) +
@@ -693,6 +700,33 @@ xpc_setup_rsvd_page_sn_sn2(struct xpc_rsvd_page *rp)
693 return 0; 700 return 0;
694} 701}
695 702
703static int
704xpc_hb_allowed_sn2(short partid, void *heartbeating_to_mask)
705{
706 return test_bit(partid, heartbeating_to_mask);
707}
708
709static void
710xpc_allow_hb_sn2(short partid)
711{
712 DBUG_ON(xpc_vars_sn2 == NULL);
713 set_bit(partid, xpc_vars_sn2->heartbeating_to_mask);
714}
715
716static void
717xpc_disallow_hb_sn2(short partid)
718{
719 DBUG_ON(xpc_vars_sn2 == NULL);
720 clear_bit(partid, xpc_vars_sn2->heartbeating_to_mask);
721}
722
723static void
724xpc_disallow_all_hbs_sn2(void)
725{
726 DBUG_ON(xpc_vars_sn2 == NULL);
727 bitmap_zero(xpc_vars_sn2->heartbeating_to_mask, xp_max_npartitions);
728}
729
696static void 730static void
697xpc_increment_heartbeat_sn2(void) 731xpc_increment_heartbeat_sn2(void)
698{ 732{
@@ -719,7 +753,6 @@ xpc_heartbeat_init_sn2(void)
719 DBUG_ON(xpc_vars_sn2 == NULL); 753 DBUG_ON(xpc_vars_sn2 == NULL);
720 754
721 bitmap_zero(xpc_vars_sn2->heartbeating_to_mask, XP_MAX_NPARTITIONS_SN2); 755 bitmap_zero(xpc_vars_sn2->heartbeating_to_mask, XP_MAX_NPARTITIONS_SN2);
722 xpc_heartbeating_to_mask = &xpc_vars_sn2->heartbeating_to_mask[0];
723 xpc_online_heartbeat_sn2(); 756 xpc_online_heartbeat_sn2();
724} 757}
725 758
@@ -751,9 +784,9 @@ xpc_get_remote_heartbeat_sn2(struct xpc_partition *part)
751 remote_vars->heartbeating_to_mask[0]); 784 remote_vars->heartbeating_to_mask[0]);
752 785
753 if ((remote_vars->heartbeat == part->last_heartbeat && 786 if ((remote_vars->heartbeat == part->last_heartbeat &&
754 remote_vars->heartbeat_offline == 0) || 787 !remote_vars->heartbeat_offline) ||
755 !xpc_hb_allowed(sn_partition_id, 788 !xpc_hb_allowed_sn2(sn_partition_id,
756 &remote_vars->heartbeating_to_mask)) { 789 remote_vars->heartbeating_to_mask)) {
757 ret = xpNoHeartbeat; 790 ret = xpNoHeartbeat;
758 } else { 791 } else {
759 part->last_heartbeat = remote_vars->heartbeat; 792 part->last_heartbeat = remote_vars->heartbeat;
@@ -972,7 +1005,7 @@ xpc_identify_activate_IRQ_req_sn2(int nasid)
972 return; 1005 return;
973 } 1006 }
974 1007
975 remote_vars_pa = remote_rp->sn.vars_pa; 1008 remote_vars_pa = remote_rp->sn.sn2.vars_pa;
976 remote_rp_version = remote_rp->version; 1009 remote_rp_version = remote_rp->version;
977 remote_rp_ts_jiffies = remote_rp->ts_jiffies; 1010 remote_rp_ts_jiffies = remote_rp->ts_jiffies;
978 1011
@@ -1129,7 +1162,7 @@ xpc_process_activate_IRQ_rcvd_sn2(void)
1129 * Setup the channel structures that are sn2 specific. 1162 * Setup the channel structures that are sn2 specific.
1130 */ 1163 */
1131static enum xp_retval 1164static enum xp_retval
1132xpc_setup_ch_structures_sn_sn2(struct xpc_partition *part) 1165xpc_setup_ch_structures_sn2(struct xpc_partition *part)
1133{ 1166{
1134 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2; 1167 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2;
1135 struct xpc_channel_sn2 *ch_sn2; 1168 struct xpc_channel_sn2 *ch_sn2;
@@ -1251,7 +1284,7 @@ out_1:
1251 * Teardown the channel structures that are sn2 specific. 1284 * Teardown the channel structures that are sn2 specific.
1252 */ 1285 */
1253static void 1286static void
1254xpc_teardown_ch_structures_sn_sn2(struct xpc_partition *part) 1287xpc_teardown_ch_structures_sn2(struct xpc_partition *part)
1255{ 1288{
1256 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2; 1289 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2;
1257 short partid = XPC_PARTID(part); 1290 short partid = XPC_PARTID(part);
@@ -2315,61 +2348,70 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
2315 xpc_acknowledge_msgs_sn2(ch, get, msg->flags); 2348 xpc_acknowledge_msgs_sn2(ch, get, msg->flags);
2316} 2349}
2317 2350
2351static struct xpc_arch_operations xpc_arch_ops_sn2 = {
2352 .setup_partitions = xpc_setup_partitions_sn2,
2353 .teardown_partitions = xpc_teardown_partitions_sn2,
2354 .process_activate_IRQ_rcvd = xpc_process_activate_IRQ_rcvd_sn2,
2355 .get_partition_rsvd_page_pa = xpc_get_partition_rsvd_page_pa_sn2,
2356 .setup_rsvd_page = xpc_setup_rsvd_page_sn2,
2357
2358 .allow_hb = xpc_allow_hb_sn2,
2359 .disallow_hb = xpc_disallow_hb_sn2,
2360 .disallow_all_hbs = xpc_disallow_all_hbs_sn2,
2361 .increment_heartbeat = xpc_increment_heartbeat_sn2,
2362 .offline_heartbeat = xpc_offline_heartbeat_sn2,
2363 .online_heartbeat = xpc_online_heartbeat_sn2,
2364 .heartbeat_init = xpc_heartbeat_init_sn2,
2365 .heartbeat_exit = xpc_heartbeat_exit_sn2,
2366 .get_remote_heartbeat = xpc_get_remote_heartbeat_sn2,
2367
2368 .request_partition_activation =
2369 xpc_request_partition_activation_sn2,
2370 .request_partition_reactivation =
2371 xpc_request_partition_reactivation_sn2,
2372 .request_partition_deactivation =
2373 xpc_request_partition_deactivation_sn2,
2374 .cancel_partition_deactivation_request =
2375 xpc_cancel_partition_deactivation_request_sn2,
2376
2377 .setup_ch_structures = xpc_setup_ch_structures_sn2,
2378 .teardown_ch_structures = xpc_teardown_ch_structures_sn2,
2379
2380 .make_first_contact = xpc_make_first_contact_sn2,
2381
2382 .get_chctl_all_flags = xpc_get_chctl_all_flags_sn2,
2383 .send_chctl_closerequest = xpc_send_chctl_closerequest_sn2,
2384 .send_chctl_closereply = xpc_send_chctl_closereply_sn2,
2385 .send_chctl_openrequest = xpc_send_chctl_openrequest_sn2,
2386 .send_chctl_openreply = xpc_send_chctl_openreply_sn2,
2387 .send_chctl_opencomplete = xpc_send_chctl_opencomplete_sn2,
2388 .process_msg_chctl_flags = xpc_process_msg_chctl_flags_sn2,
2389
2390 .save_remote_msgqueue_pa = xpc_save_remote_msgqueue_pa_sn2,
2391
2392 .setup_msg_structures = xpc_setup_msg_structures_sn2,
2393 .teardown_msg_structures = xpc_teardown_msg_structures_sn2,
2394
2395 .indicate_partition_engaged = xpc_indicate_partition_engaged_sn2,
2396 .indicate_partition_disengaged = xpc_indicate_partition_disengaged_sn2,
2397 .partition_engaged = xpc_partition_engaged_sn2,
2398 .any_partition_engaged = xpc_any_partition_engaged_sn2,
2399 .assume_partition_disengaged = xpc_assume_partition_disengaged_sn2,
2400
2401 .n_of_deliverable_payloads = xpc_n_of_deliverable_payloads_sn2,
2402 .send_payload = xpc_send_payload_sn2,
2403 .get_deliverable_payload = xpc_get_deliverable_payload_sn2,
2404 .received_payload = xpc_received_payload_sn2,
2405 .notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_sn2,
2406};
2407
2318int 2408int
2319xpc_init_sn2(void) 2409xpc_init_sn2(void)
2320{ 2410{
2321 int ret; 2411 int ret;
2322 size_t buf_size; 2412 size_t buf_size;
2323 2413
2324 xpc_setup_partitions_sn = xpc_setup_partitions_sn_sn2; 2414 xpc_arch_ops = xpc_arch_ops_sn2;
2325 xpc_teardown_partitions_sn = xpc_teardown_partitions_sn_sn2;
2326 xpc_get_partition_rsvd_page_pa = xpc_get_partition_rsvd_page_pa_sn2;
2327 xpc_setup_rsvd_page_sn = xpc_setup_rsvd_page_sn_sn2;
2328 xpc_increment_heartbeat = xpc_increment_heartbeat_sn2;
2329 xpc_offline_heartbeat = xpc_offline_heartbeat_sn2;
2330 xpc_online_heartbeat = xpc_online_heartbeat_sn2;
2331 xpc_heartbeat_init = xpc_heartbeat_init_sn2;
2332 xpc_heartbeat_exit = xpc_heartbeat_exit_sn2;
2333 xpc_get_remote_heartbeat = xpc_get_remote_heartbeat_sn2;
2334
2335 xpc_request_partition_activation = xpc_request_partition_activation_sn2;
2336 xpc_request_partition_reactivation =
2337 xpc_request_partition_reactivation_sn2;
2338 xpc_request_partition_deactivation =
2339 xpc_request_partition_deactivation_sn2;
2340 xpc_cancel_partition_deactivation_request =
2341 xpc_cancel_partition_deactivation_request_sn2;
2342
2343 xpc_process_activate_IRQ_rcvd = xpc_process_activate_IRQ_rcvd_sn2;
2344 xpc_setup_ch_structures_sn = xpc_setup_ch_structures_sn_sn2;
2345 xpc_teardown_ch_structures_sn = xpc_teardown_ch_structures_sn_sn2;
2346 xpc_make_first_contact = xpc_make_first_contact_sn2;
2347
2348 xpc_get_chctl_all_flags = xpc_get_chctl_all_flags_sn2;
2349 xpc_send_chctl_closerequest = xpc_send_chctl_closerequest_sn2;
2350 xpc_send_chctl_closereply = xpc_send_chctl_closereply_sn2;
2351 xpc_send_chctl_openrequest = xpc_send_chctl_openrequest_sn2;
2352 xpc_send_chctl_openreply = xpc_send_chctl_openreply_sn2;
2353
2354 xpc_save_remote_msgqueue_pa = xpc_save_remote_msgqueue_pa_sn2;
2355
2356 xpc_setup_msg_structures = xpc_setup_msg_structures_sn2;
2357 xpc_teardown_msg_structures = xpc_teardown_msg_structures_sn2;
2358
2359 xpc_notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_sn2;
2360 xpc_process_msg_chctl_flags = xpc_process_msg_chctl_flags_sn2;
2361 xpc_n_of_deliverable_payloads = xpc_n_of_deliverable_payloads_sn2;
2362 xpc_get_deliverable_payload = xpc_get_deliverable_payload_sn2;
2363
2364 xpc_indicate_partition_engaged = xpc_indicate_partition_engaged_sn2;
2365 xpc_indicate_partition_disengaged =
2366 xpc_indicate_partition_disengaged_sn2;
2367 xpc_partition_engaged = xpc_partition_engaged_sn2;
2368 xpc_any_partition_engaged = xpc_any_partition_engaged_sn2;
2369 xpc_assume_partition_disengaged = xpc_assume_partition_disengaged_sn2;
2370
2371 xpc_send_payload = xpc_send_payload_sn2;
2372 xpc_received_payload = xpc_received_payload_sn2;
2373 2415
2374 if (offsetof(struct xpc_msg_sn2, payload) > XPC_MSG_HDR_MAX_SIZE) { 2416 if (offsetof(struct xpc_msg_sn2, payload) > XPC_MSG_HDR_MAX_SIZE) {
2375 dev_err(xpc_part, "header portion of struct xpc_msg_sn2 is " 2417 dev_err(xpc_part, "header portion of struct xpc_msg_sn2 is "
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index f7fff4727edb..9172fcdee4e2 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -46,8 +46,7 @@ struct uv_IO_APIC_route_entry {
46}; 46};
47#endif 47#endif
48 48
49static atomic64_t xpc_heartbeat_uv; 49static struct xpc_heartbeat_uv *xpc_heartbeat_uv;
50static DECLARE_BITMAP(xpc_heartbeating_to_mask_uv, XP_MAX_NPARTITIONS_UV);
51 50
52#define XPC_ACTIVATE_MSG_SIZE_UV (1 * GRU_CACHE_LINE_BYTES) 51#define XPC_ACTIVATE_MSG_SIZE_UV (1 * GRU_CACHE_LINE_BYTES)
53#define XPC_ACTIVATE_MQ_SIZE_UV (4 * XP_MAX_NPARTITIONS_UV * \ 52#define XPC_ACTIVATE_MQ_SIZE_UV (4 * XP_MAX_NPARTITIONS_UV * \
@@ -63,7 +62,7 @@ static struct xpc_gru_mq_uv *xpc_activate_mq_uv;
63static struct xpc_gru_mq_uv *xpc_notify_mq_uv; 62static struct xpc_gru_mq_uv *xpc_notify_mq_uv;
64 63
65static int 64static int
66xpc_setup_partitions_sn_uv(void) 65xpc_setup_partitions_uv(void)
67{ 66{
68 short partid; 67 short partid;
69 struct xpc_partition_uv *part_uv; 68 struct xpc_partition_uv *part_uv;
@@ -79,7 +78,7 @@ xpc_setup_partitions_sn_uv(void)
79} 78}
80 79
81static void 80static void
82xpc_teardown_partitions_sn_uv(void) 81xpc_teardown_partitions_uv(void)
83{ 82{
84 short partid; 83 short partid;
85 struct xpc_partition_uv *part_uv; 84 struct xpc_partition_uv *part_uv;
@@ -423,41 +422,6 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
423 /* syncing of remote_act_state was just done above */ 422 /* syncing of remote_act_state was just done above */
424 break; 423 break;
425 424
426 case XPC_ACTIVATE_MQ_MSG_INC_HEARTBEAT_UV: {
427 struct xpc_activate_mq_msg_heartbeat_req_uv *msg;
428
429 msg = container_of(msg_hdr,
430 struct xpc_activate_mq_msg_heartbeat_req_uv,
431 hdr);
432 part_uv->heartbeat = msg->heartbeat;
433 break;
434 }
435 case XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV: {
436 struct xpc_activate_mq_msg_heartbeat_req_uv *msg;
437
438 msg = container_of(msg_hdr,
439 struct xpc_activate_mq_msg_heartbeat_req_uv,
440 hdr);
441 part_uv->heartbeat = msg->heartbeat;
442
443 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
444 part_uv->flags |= XPC_P_HEARTBEAT_OFFLINE_UV;
445 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
446 break;
447 }
448 case XPC_ACTIVATE_MQ_MSG_ONLINE_HEARTBEAT_UV: {
449 struct xpc_activate_mq_msg_heartbeat_req_uv *msg;
450
451 msg = container_of(msg_hdr,
452 struct xpc_activate_mq_msg_heartbeat_req_uv,
453 hdr);
454 part_uv->heartbeat = msg->heartbeat;
455
456 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
457 part_uv->flags &= ~XPC_P_HEARTBEAT_OFFLINE_UV;
458 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
459 break;
460 }
461 case XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV: { 425 case XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV: {
462 struct xpc_activate_mq_msg_activate_req_uv *msg; 426 struct xpc_activate_mq_msg_activate_req_uv *msg;
463 427
@@ -475,6 +439,7 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
475 part_uv->act_state_req = XPC_P_ASR_ACTIVATE_UV; 439 part_uv->act_state_req = XPC_P_ASR_ACTIVATE_UV;
476 part->remote_rp_pa = msg->rp_gpa; /* !!! _pa is _gpa */ 440 part->remote_rp_pa = msg->rp_gpa; /* !!! _pa is _gpa */
477 part->remote_rp_ts_jiffies = msg_hdr->rp_ts_jiffies; 441 part->remote_rp_ts_jiffies = msg_hdr->rp_ts_jiffies;
442 part_uv->heartbeat_gpa = msg->heartbeat_gpa;
478 443
479 if (msg->activate_gru_mq_desc_gpa != 444 if (msg->activate_gru_mq_desc_gpa !=
480 part_uv->activate_gru_mq_desc_gpa) { 445 part_uv->activate_gru_mq_desc_gpa) {
@@ -569,6 +534,17 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
569 xpc_wakeup_channel_mgr(part); 534 xpc_wakeup_channel_mgr(part);
570 break; 535 break;
571 } 536 }
537 case XPC_ACTIVATE_MQ_MSG_CHCTL_OPENCOMPLETE_UV: {
538 struct xpc_activate_mq_msg_chctl_opencomplete_uv *msg;
539
540 msg = container_of(msg_hdr, struct
541 xpc_activate_mq_msg_chctl_opencomplete_uv, hdr);
542 spin_lock_irqsave(&part->chctl_lock, irq_flags);
543 part->chctl.flags[msg->ch_number] |= XPC_CHCTL_OPENCOMPLETE;
544 spin_unlock_irqrestore(&part->chctl_lock, irq_flags);
545
546 xpc_wakeup_channel_mgr(part);
547 }
572 case XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV: 548 case XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV:
573 spin_lock_irqsave(&part_uv->flags_lock, irq_flags); 549 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
574 part_uv->flags |= XPC_P_ENGAGED_UV; 550 part_uv->flags |= XPC_P_ENGAGED_UV;
@@ -759,7 +735,7 @@ xpc_send_local_activate_IRQ_uv(struct xpc_partition *part, int act_state_req)
759 735
760 /* 736 /*
761 * !!! Make our side think that the remote partition sent an activate 737 * !!! Make our side think that the remote partition sent an activate
762 * !!! message our way by doing what the activate IRQ handler would 738 * !!! mq message our way by doing what the activate IRQ handler would
763 * !!! do had one really been sent. 739 * !!! do had one really been sent.
764 */ 740 */
765 741
@@ -806,90 +782,82 @@ xpc_get_partition_rsvd_page_pa_uv(void *buf, u64 *cookie, unsigned long *rp_pa,
806} 782}
807 783
808static int 784static int
809xpc_setup_rsvd_page_sn_uv(struct xpc_rsvd_page *rp) 785xpc_setup_rsvd_page_uv(struct xpc_rsvd_page *rp)
810{ 786{
811 rp->sn.activate_gru_mq_desc_gpa = 787 xpc_heartbeat_uv =
788 &xpc_partitions[sn_partition_id].sn.uv.cached_heartbeat;
789 rp->sn.uv.heartbeat_gpa = uv_gpa(xpc_heartbeat_uv);
790 rp->sn.uv.activate_gru_mq_desc_gpa =
812 uv_gpa(xpc_activate_mq_uv->gru_mq_desc); 791 uv_gpa(xpc_activate_mq_uv->gru_mq_desc);
813 return 0; 792 return 0;
814} 793}
815 794
816static void 795static void
817xpc_send_heartbeat_uv(int msg_type) 796xpc_allow_hb_uv(short partid)
818{ 797{
819 short partid; 798}
820 struct xpc_partition *part;
821 struct xpc_activate_mq_msg_heartbeat_req_uv msg;
822
823 /*
824 * !!! On uv we're broadcasting a heartbeat message every 5 seconds.
825 * !!! Whereas on sn2 we're bte_copy'ng the heartbeat info every 20
826 * !!! seconds. This is an increase in numalink traffic.
827 * ??? Is this good?
828 */
829
830 msg.heartbeat = atomic64_inc_return(&xpc_heartbeat_uv);
831
832 partid = find_first_bit(xpc_heartbeating_to_mask_uv,
833 XP_MAX_NPARTITIONS_UV);
834
835 while (partid < XP_MAX_NPARTITIONS_UV) {
836 part = &xpc_partitions[partid];
837 799
838 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg), 800static void
839 msg_type); 801xpc_disallow_hb_uv(short partid)
802{
803}
840 804
841 partid = find_next_bit(xpc_heartbeating_to_mask_uv, 805static void
842 XP_MAX_NPARTITIONS_UV, partid + 1); 806xpc_disallow_all_hbs_uv(void)
843 } 807{
844} 808}
845 809
846static void 810static void
847xpc_increment_heartbeat_uv(void) 811xpc_increment_heartbeat_uv(void)
848{ 812{
849 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_INC_HEARTBEAT_UV); 813 xpc_heartbeat_uv->value++;
850} 814}
851 815
852static void 816static void
853xpc_offline_heartbeat_uv(void) 817xpc_offline_heartbeat_uv(void)
854{ 818{
855 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV); 819 xpc_increment_heartbeat_uv();
820 xpc_heartbeat_uv->offline = 1;
856} 821}
857 822
858static void 823static void
859xpc_online_heartbeat_uv(void) 824xpc_online_heartbeat_uv(void)
860{ 825{
861 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_ONLINE_HEARTBEAT_UV); 826 xpc_increment_heartbeat_uv();
827 xpc_heartbeat_uv->offline = 0;
862} 828}
863 829
864static void 830static void
865xpc_heartbeat_init_uv(void) 831xpc_heartbeat_init_uv(void)
866{ 832{
867 atomic64_set(&xpc_heartbeat_uv, 0); 833 xpc_heartbeat_uv->value = 1;
868 bitmap_zero(xpc_heartbeating_to_mask_uv, XP_MAX_NPARTITIONS_UV); 834 xpc_heartbeat_uv->offline = 0;
869 xpc_heartbeating_to_mask = &xpc_heartbeating_to_mask_uv[0];
870} 835}
871 836
872static void 837static void
873xpc_heartbeat_exit_uv(void) 838xpc_heartbeat_exit_uv(void)
874{ 839{
875 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV); 840 xpc_offline_heartbeat_uv();
876} 841}
877 842
878static enum xp_retval 843static enum xp_retval
879xpc_get_remote_heartbeat_uv(struct xpc_partition *part) 844xpc_get_remote_heartbeat_uv(struct xpc_partition *part)
880{ 845{
881 struct xpc_partition_uv *part_uv = &part->sn.uv; 846 struct xpc_partition_uv *part_uv = &part->sn.uv;
882 enum xp_retval ret = xpNoHeartbeat; 847 enum xp_retval ret;
883 848
884 if (part_uv->remote_act_state != XPC_P_AS_INACTIVE && 849 ret = xp_remote_memcpy(uv_gpa(&part_uv->cached_heartbeat),
885 part_uv->remote_act_state != XPC_P_AS_DEACTIVATING) { 850 part_uv->heartbeat_gpa,
851 sizeof(struct xpc_heartbeat_uv));
852 if (ret != xpSuccess)
853 return ret;
886 854
887 if (part_uv->heartbeat != part->last_heartbeat || 855 if (part_uv->cached_heartbeat.value == part->last_heartbeat &&
888 (part_uv->flags & XPC_P_HEARTBEAT_OFFLINE_UV)) { 856 !part_uv->cached_heartbeat.offline) {
889 857
890 part->last_heartbeat = part_uv->heartbeat; 858 ret = xpNoHeartbeat;
891 ret = xpSuccess; 859 } else {
892 } 860 part->last_heartbeat = part_uv->cached_heartbeat.value;
893 } 861 }
894 return ret; 862 return ret;
895} 863}
@@ -904,8 +872,9 @@ xpc_request_partition_activation_uv(struct xpc_rsvd_page *remote_rp,
904 872
905 part->remote_rp_pa = remote_rp_gpa; /* !!! _pa here is really _gpa */ 873 part->remote_rp_pa = remote_rp_gpa; /* !!! _pa here is really _gpa */
906 part->remote_rp_ts_jiffies = remote_rp->ts_jiffies; 874 part->remote_rp_ts_jiffies = remote_rp->ts_jiffies;
875 part->sn.uv.heartbeat_gpa = remote_rp->sn.uv.heartbeat_gpa;
907 part->sn.uv.activate_gru_mq_desc_gpa = 876 part->sn.uv.activate_gru_mq_desc_gpa =
908 remote_rp->sn.activate_gru_mq_desc_gpa; 877 remote_rp->sn.uv.activate_gru_mq_desc_gpa;
909 878
910 /* 879 /*
911 * ??? Is it a good idea to make this conditional on what is 880 * ??? Is it a good idea to make this conditional on what is
@@ -913,8 +882,9 @@ xpc_request_partition_activation_uv(struct xpc_rsvd_page *remote_rp,
913 */ 882 */
914 if (part->sn.uv.remote_act_state == XPC_P_AS_INACTIVE) { 883 if (part->sn.uv.remote_act_state == XPC_P_AS_INACTIVE) {
915 msg.rp_gpa = uv_gpa(xpc_rsvd_page); 884 msg.rp_gpa = uv_gpa(xpc_rsvd_page);
885 msg.heartbeat_gpa = xpc_rsvd_page->sn.uv.heartbeat_gpa;
916 msg.activate_gru_mq_desc_gpa = 886 msg.activate_gru_mq_desc_gpa =
917 xpc_rsvd_page->sn.activate_gru_mq_desc_gpa; 887 xpc_rsvd_page->sn.uv.activate_gru_mq_desc_gpa;
918 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg), 888 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
919 XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV); 889 XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV);
920 } 890 }
@@ -1010,7 +980,7 @@ xpc_n_of_fifo_entries_uv(struct xpc_fifo_head_uv *head)
1010 * Setup the channel structures that are uv specific. 980 * Setup the channel structures that are uv specific.
1011 */ 981 */
1012static enum xp_retval 982static enum xp_retval
1013xpc_setup_ch_structures_sn_uv(struct xpc_partition *part) 983xpc_setup_ch_structures_uv(struct xpc_partition *part)
1014{ 984{
1015 struct xpc_channel_uv *ch_uv; 985 struct xpc_channel_uv *ch_uv;
1016 int ch_number; 986 int ch_number;
@@ -1029,7 +999,7 @@ xpc_setup_ch_structures_sn_uv(struct xpc_partition *part)
1029 * Teardown the channel structures that are uv specific. 999 * Teardown the channel structures that are uv specific.
1030 */ 1000 */
1031static void 1001static void
1032xpc_teardown_ch_structures_sn_uv(struct xpc_partition *part) 1002xpc_teardown_ch_structures_uv(struct xpc_partition *part)
1033{ 1003{
1034 /* nothing needs to be done */ 1004 /* nothing needs to be done */
1035 return; 1005 return;
@@ -1243,6 +1213,16 @@ xpc_send_chctl_openreply_uv(struct xpc_channel *ch, unsigned long *irq_flags)
1243} 1213}
1244 1214
1245static void 1215static void
1216xpc_send_chctl_opencomplete_uv(struct xpc_channel *ch, unsigned long *irq_flags)
1217{
1218 struct xpc_activate_mq_msg_chctl_opencomplete_uv msg;
1219
1220 msg.ch_number = ch->number;
1221 xpc_send_activate_IRQ_ch_uv(ch, irq_flags, &msg, sizeof(msg),
1222 XPC_ACTIVATE_MQ_MSG_CHCTL_OPENCOMPLETE_UV);
1223}
1224
1225static void
1246xpc_send_chctl_local_msgrequest_uv(struct xpc_partition *part, int ch_number) 1226xpc_send_chctl_local_msgrequest_uv(struct xpc_partition *part, int ch_number)
1247{ 1227{
1248 unsigned long irq_flags; 1228 unsigned long irq_flags;
@@ -1669,58 +1649,67 @@ xpc_received_payload_uv(struct xpc_channel *ch, void *payload)
1669 msg->hdr.msg_slot_number += ch->remote_nentries; 1649 msg->hdr.msg_slot_number += ch->remote_nentries;
1670} 1650}
1671 1651
1652static struct xpc_arch_operations xpc_arch_ops_uv = {
1653 .setup_partitions = xpc_setup_partitions_uv,
1654 .teardown_partitions = xpc_teardown_partitions_uv,
1655 .process_activate_IRQ_rcvd = xpc_process_activate_IRQ_rcvd_uv,
1656 .get_partition_rsvd_page_pa = xpc_get_partition_rsvd_page_pa_uv,
1657 .setup_rsvd_page = xpc_setup_rsvd_page_uv,
1658
1659 .allow_hb = xpc_allow_hb_uv,
1660 .disallow_hb = xpc_disallow_hb_uv,
1661 .disallow_all_hbs = xpc_disallow_all_hbs_uv,
1662 .increment_heartbeat = xpc_increment_heartbeat_uv,
1663 .offline_heartbeat = xpc_offline_heartbeat_uv,
1664 .online_heartbeat = xpc_online_heartbeat_uv,
1665 .heartbeat_init = xpc_heartbeat_init_uv,
1666 .heartbeat_exit = xpc_heartbeat_exit_uv,
1667 .get_remote_heartbeat = xpc_get_remote_heartbeat_uv,
1668
1669 .request_partition_activation =
1670 xpc_request_partition_activation_uv,
1671 .request_partition_reactivation =
1672 xpc_request_partition_reactivation_uv,
1673 .request_partition_deactivation =
1674 xpc_request_partition_deactivation_uv,
1675 .cancel_partition_deactivation_request =
1676 xpc_cancel_partition_deactivation_request_uv,
1677
1678 .setup_ch_structures = xpc_setup_ch_structures_uv,
1679 .teardown_ch_structures = xpc_teardown_ch_structures_uv,
1680
1681 .make_first_contact = xpc_make_first_contact_uv,
1682
1683 .get_chctl_all_flags = xpc_get_chctl_all_flags_uv,
1684 .send_chctl_closerequest = xpc_send_chctl_closerequest_uv,
1685 .send_chctl_closereply = xpc_send_chctl_closereply_uv,
1686 .send_chctl_openrequest = xpc_send_chctl_openrequest_uv,
1687 .send_chctl_openreply = xpc_send_chctl_openreply_uv,
1688 .send_chctl_opencomplete = xpc_send_chctl_opencomplete_uv,
1689 .process_msg_chctl_flags = xpc_process_msg_chctl_flags_uv,
1690
1691 .save_remote_msgqueue_pa = xpc_save_remote_msgqueue_pa_uv,
1692
1693 .setup_msg_structures = xpc_setup_msg_structures_uv,
1694 .teardown_msg_structures = xpc_teardown_msg_structures_uv,
1695
1696 .indicate_partition_engaged = xpc_indicate_partition_engaged_uv,
1697 .indicate_partition_disengaged = xpc_indicate_partition_disengaged_uv,
1698 .assume_partition_disengaged = xpc_assume_partition_disengaged_uv,
1699 .partition_engaged = xpc_partition_engaged_uv,
1700 .any_partition_engaged = xpc_any_partition_engaged_uv,
1701
1702 .n_of_deliverable_payloads = xpc_n_of_deliverable_payloads_uv,
1703 .send_payload = xpc_send_payload_uv,
1704 .get_deliverable_payload = xpc_get_deliverable_payload_uv,
1705 .received_payload = xpc_received_payload_uv,
1706 .notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_uv,
1707};
1708
1672int 1709int
1673xpc_init_uv(void) 1710xpc_init_uv(void)
1674{ 1711{
1675 xpc_setup_partitions_sn = xpc_setup_partitions_sn_uv; 1712 xpc_arch_ops = xpc_arch_ops_uv;
1676 xpc_teardown_partitions_sn = xpc_teardown_partitions_sn_uv;
1677 xpc_process_activate_IRQ_rcvd = xpc_process_activate_IRQ_rcvd_uv;
1678 xpc_get_partition_rsvd_page_pa = xpc_get_partition_rsvd_page_pa_uv;
1679 xpc_setup_rsvd_page_sn = xpc_setup_rsvd_page_sn_uv;
1680 xpc_increment_heartbeat = xpc_increment_heartbeat_uv;
1681 xpc_offline_heartbeat = xpc_offline_heartbeat_uv;
1682 xpc_online_heartbeat = xpc_online_heartbeat_uv;
1683 xpc_heartbeat_init = xpc_heartbeat_init_uv;
1684 xpc_heartbeat_exit = xpc_heartbeat_exit_uv;
1685 xpc_get_remote_heartbeat = xpc_get_remote_heartbeat_uv;
1686
1687 xpc_request_partition_activation = xpc_request_partition_activation_uv;
1688 xpc_request_partition_reactivation =
1689 xpc_request_partition_reactivation_uv;
1690 xpc_request_partition_deactivation =
1691 xpc_request_partition_deactivation_uv;
1692 xpc_cancel_partition_deactivation_request =
1693 xpc_cancel_partition_deactivation_request_uv;
1694
1695 xpc_setup_ch_structures_sn = xpc_setup_ch_structures_sn_uv;
1696 xpc_teardown_ch_structures_sn = xpc_teardown_ch_structures_sn_uv;
1697
1698 xpc_make_first_contact = xpc_make_first_contact_uv;
1699
1700 xpc_get_chctl_all_flags = xpc_get_chctl_all_flags_uv;
1701 xpc_send_chctl_closerequest = xpc_send_chctl_closerequest_uv;
1702 xpc_send_chctl_closereply = xpc_send_chctl_closereply_uv;
1703 xpc_send_chctl_openrequest = xpc_send_chctl_openrequest_uv;
1704 xpc_send_chctl_openreply = xpc_send_chctl_openreply_uv;
1705
1706 xpc_save_remote_msgqueue_pa = xpc_save_remote_msgqueue_pa_uv;
1707
1708 xpc_setup_msg_structures = xpc_setup_msg_structures_uv;
1709 xpc_teardown_msg_structures = xpc_teardown_msg_structures_uv;
1710
1711 xpc_indicate_partition_engaged = xpc_indicate_partition_engaged_uv;
1712 xpc_indicate_partition_disengaged =
1713 xpc_indicate_partition_disengaged_uv;
1714 xpc_assume_partition_disengaged = xpc_assume_partition_disengaged_uv;
1715 xpc_partition_engaged = xpc_partition_engaged_uv;
1716 xpc_any_partition_engaged = xpc_any_partition_engaged_uv;
1717
1718 xpc_n_of_deliverable_payloads = xpc_n_of_deliverable_payloads_uv;
1719 xpc_process_msg_chctl_flags = xpc_process_msg_chctl_flags_uv;
1720 xpc_send_payload = xpc_send_payload_uv;
1721 xpc_notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_uv;
1722 xpc_get_deliverable_payload = xpc_get_deliverable_payload_uv;
1723 xpc_received_payload = xpc_received_payload_uv;
1724 1713
1725 if (sizeof(struct xpc_notify_mq_msghdr_uv) > XPC_MSG_HDR_MAX_SIZE) { 1714 if (sizeof(struct xpc_notify_mq_msghdr_uv) > XPC_MSG_HDR_MAX_SIZE) {
1726 dev_err(xpc_part, "xpc_notify_mq_msghdr_uv is larger than %d\n", 1715 dev_err(xpc_part, "xpc_notify_mq_msghdr_uv is larger than %d\n",
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index deb7b53167ee..83a12125b94e 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -2532,8 +2532,8 @@ static int __devinit atl1c_probe(struct pci_dev *pdev,
2532 * various kernel subsystems to support the mechanics required by a 2532 * various kernel subsystems to support the mechanics required by a
2533 * fixed-high-32-bit system. 2533 * fixed-high-32-bit system.
2534 */ 2534 */
2535 if ((pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) || 2535 if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) ||
2536 (pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK) != 0)) { 2536 (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)) {
2537 dev_err(&pdev->dev, "No usable DMA configuration,aborting\n"); 2537 dev_err(&pdev->dev, "No usable DMA configuration,aborting\n");
2538 goto err_dma; 2538 goto err_dma;
2539 } 2539 }
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 9b75aa630062..30d0c81c989e 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -1821,11 +1821,11 @@ static int __devinit be_probe(struct pci_dev *pdev,
1821 1821
1822 be_msix_enable(adapter); 1822 be_msix_enable(adapter);
1823 1823
1824 status = pci_set_dma_mask(pdev, DMA_64BIT_MASK); 1824 status = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
1825 if (!status) { 1825 if (!status) {
1826 netdev->features |= NETIF_F_HIGHDMA; 1826 netdev->features |= NETIF_F_HIGHDMA;
1827 } else { 1827 } else {
1828 status = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 1828 status = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1829 if (status) { 1829 if (status) {
1830 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n"); 1830 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n");
1831 goto free_netdev; 1831 goto free_netdev;
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index ece35040288c..621a7c0c46ba 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -2591,13 +2591,13 @@ static int
2591jme_pci_dma64(struct pci_dev *pdev) 2591jme_pci_dma64(struct pci_dev *pdev)
2592{ 2592{
2593 if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 && 2593 if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 &&
2594 !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) 2594 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
2595 if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) 2595 if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
2596 return 1; 2596 return 1;
2597 2597
2598 if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 && 2598 if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 &&
2599 !pci_set_dma_mask(pdev, DMA_40BIT_MASK)) 2599 !pci_set_dma_mask(pdev, DMA_BIT_MASK(40)))
2600 if (!pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK)) 2600 if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40)))
2601 return 1; 2601 return 1;
2602 2602
2603 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) 2603 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
diff --git a/drivers/net/wireless/ath9k/pci.c b/drivers/net/wireless/ath9k/pci.c
index 6dbc58580abb..168411d322a2 100644
--- a/drivers/net/wireless/ath9k/pci.c
+++ b/drivers/net/wireless/ath9k/pci.c
@@ -93,14 +93,14 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
93 if (pci_enable_device(pdev)) 93 if (pci_enable_device(pdev))
94 return -EIO; 94 return -EIO;
95 95
96 ret = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 96 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
97 97
98 if (ret) { 98 if (ret) {
99 printk(KERN_ERR "ath9k: 32-bit DMA not available\n"); 99 printk(KERN_ERR "ath9k: 32-bit DMA not available\n");
100 goto bad; 100 goto bad;
101 } 101 }
102 102
103 ret = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 103 ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
104 104
105 if (ret) { 105 if (ret) {
106 printk(KERN_ERR "ath9k: 32-bit DMA consistent " 106 printk(KERN_ERR "ath9k: 32-bit DMA consistent "
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index e3569a0a952d..b1610ea4bb3d 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -492,8 +492,8 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
492 goto err_disable_dev; 492 goto err_disable_dev;
493 } 493 }
494 494
495 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) || 495 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) ||
496 pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) { 496 pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
497 dev_err(&pdev->dev, "No suitable DMA available\n"); 497 dev_err(&pdev->dev, "No suitable DMA available\n");
498 goto err_free_reg; 498 goto err_free_reg;
499 } 499 }
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index 4fa3bb2ddfe4..33e5ade774ca 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -434,7 +434,8 @@ static void __init superio_parport_init(void)
434 0 /*base_hi*/, 434 0 /*base_hi*/,
435 PAR_IRQ, 435 PAR_IRQ,
436 PARPORT_DMA_NONE /* dma */, 436 PARPORT_DMA_NONE /* dma */,
437 NULL /*struct pci_dev* */) ) 437 NULL /*struct pci_dev* */),
438 0 /* shared irq flags */ )
438 439
439 printk(KERN_WARNING PFX "Probing parallel port failed.\n"); 440 printk(KERN_WARNING PFX "Probing parallel port failed.\n");
440#endif /* CONFIG_PARPORT_PC */ 441#endif /* CONFIG_PARPORT_PC */
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 25a00ce4f24d..fa3a11365ec3 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -173,12 +173,21 @@ dmar_parse_one_drhd(struct acpi_dmar_header *header)
173 struct dmar_drhd_unit *dmaru; 173 struct dmar_drhd_unit *dmaru;
174 int ret = 0; 174 int ret = 0;
175 175
176 drhd = (struct acpi_dmar_hardware_unit *)header;
177 if (!drhd->address) {
178 /* Promote an attitude of violence to a BIOS engineer today */
179 WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
180 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
181 dmi_get_system_info(DMI_BIOS_VENDOR),
182 dmi_get_system_info(DMI_BIOS_VERSION),
183 dmi_get_system_info(DMI_PRODUCT_VERSION));
184 return -ENODEV;
185 }
176 dmaru = kzalloc(sizeof(*dmaru), GFP_KERNEL); 186 dmaru = kzalloc(sizeof(*dmaru), GFP_KERNEL);
177 if (!dmaru) 187 if (!dmaru)
178 return -ENOMEM; 188 return -ENOMEM;
179 189
180 dmaru->hdr = header; 190 dmaru->hdr = header;
181 drhd = (struct acpi_dmar_hardware_unit *)header;
182 dmaru->reg_base_addr = drhd->address; 191 dmaru->reg_base_addr = drhd->address;
183 dmaru->segment = drhd->segment; 192 dmaru->segment = drhd->segment;
184 dmaru->include_all = drhd->flags & 0x1; /* BIT0: INCLUDE_ALL */ 193 dmaru->include_all = drhd->flags & 0x1; /* BIT0: INCLUDE_ALL */
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index fb3a3f3fca7a..001b328adf80 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -733,8 +733,8 @@ static void dma_pte_clear_range(struct dmar_domain *domain, u64 start, u64 end)
733 start &= (((u64)1) << addr_width) - 1; 733 start &= (((u64)1) << addr_width) - 1;
734 end &= (((u64)1) << addr_width) - 1; 734 end &= (((u64)1) << addr_width) - 1;
735 /* in case it's partial page */ 735 /* in case it's partial page */
736 start = PAGE_ALIGN(start); 736 start &= PAGE_MASK;
737 end &= PAGE_MASK; 737 end = PAGE_ALIGN(end);
738 npages = (end - start) / VTD_PAGE_SIZE; 738 npages = (end - start) / VTD_PAGE_SIZE;
739 739
740 /* we don't need lock here, nobody else touches the iova range */ 740 /* we don't need lock here, nobody else touches the iova range */
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index fdb14ec4fd47..8b7983aba8f7 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -2234,10 +2234,10 @@ static int twa_resume(struct pci_dev *pdev)
2234 pci_set_master(pdev); 2234 pci_set_master(pdev);
2235 pci_try_set_mwi(pdev); 2235 pci_try_set_mwi(pdev);
2236 2236
2237 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) 2237 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
2238 || pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) 2238 || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
2239 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) 2239 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
2240 || pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) { 2240 || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
2241 TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume"); 2241 TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
2242 retval = -ENODEV; 2242 retval = -ENODEV;
2243 goto out_disable_device; 2243 goto out_disable_device;
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 280261c451d6..2a889853a106 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1378,7 +1378,7 @@ int aac_get_adapter_info(struct aac_dev* dev)
1378 if (dev->nondasd_support && !dev->in_reset) 1378 if (dev->nondasd_support && !dev->in_reset)
1379 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id); 1379 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id);
1380 1380
1381 if (dma_get_required_mask(&dev->pdev->dev) > DMA_32BIT_MASK) 1381 if (dma_get_required_mask(&dev->pdev->dev) > DMA_BIT_MASK(32))
1382 dev->needs_dac = 1; 1382 dev->needs_dac = 1;
1383 dev->dac_support = 0; 1383 dev->dac_support = 0;
1384 if ((sizeof(dma_addr_t) > 4) && dev->needs_dac && 1384 if ((sizeof(dma_addr_t) > 4) && dev->needs_dac &&
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index b1bd3fc7bae8..36fd2e75da1c 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -1394,7 +1394,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1394 */ 1394 */
1395 cmd->sense_buffer[8] = 0; /* Information */ 1395 cmd->sense_buffer[8] = 0; /* Information */
1396 cmd->sense_buffer[9] = 0xa; /* Add. length */ 1396 cmd->sense_buffer[9] = 0xa; /* Add. length */
1397 do_div(bghm, cmd->device->sector_size); 1397 bghm /= cmd->device->sector_size;
1398 1398
1399 failing_sector = scsi_get_lba(cmd); 1399 failing_sector = scsi_get_lba(cmd);
1400 failing_sector += bghm; 1400 failing_sector += bghm;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 52427a8324f5..a91f5143ceac 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -855,9 +855,9 @@ _base_config_dma_addressing(struct MPT2SAS_ADAPTER *ioc, struct pci_dev *pdev)
855 if (sizeof(dma_addr_t) > 4) { 855 if (sizeof(dma_addr_t) > 4) {
856 const uint64_t required_mask = 856 const uint64_t required_mask =
857 dma_get_required_mask(&pdev->dev); 857 dma_get_required_mask(&pdev->dev);
858 if ((required_mask > DMA_32BIT_MASK) && !pci_set_dma_mask(pdev, 858 if ((required_mask > DMA_BIT_MASK(32)) && !pci_set_dma_mask(pdev,
859 DMA_64BIT_MASK) && !pci_set_consistent_dma_mask(pdev, 859 DMA_BIT_MASK(64)) && !pci_set_consistent_dma_mask(pdev,
860 DMA_64BIT_MASK)) { 860 DMA_BIT_MASK(64))) {
861 ioc->base_add_sg_single = &_base_add_sg_single_64; 861 ioc->base_add_sg_single = &_base_add_sg_single_64;
862 ioc->sge_size = sizeof(Mpi2SGESimple64_t); 862 ioc->sge_size = sizeof(Mpi2SGESimple64_t);
863 desc = "64"; 863 desc = "64";
@@ -865,8 +865,8 @@ _base_config_dma_addressing(struct MPT2SAS_ADAPTER *ioc, struct pci_dev *pdev)
865 } 865 }
866 } 866 }
867 867
868 if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK) 868 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
869 && !pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) { 869 && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
870 ioc->base_add_sg_single = &_base_add_sg_single_32; 870 ioc->base_add_sg_single = &_base_add_sg_single_32;
871 ioc->sge_size = sizeof(Mpi2SGESimple32_t); 871 ioc->sge_size = sizeof(Mpi2SGESimple32_t);
872 desc = "32"; 872 desc = "32";
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index e1850904ff73..fbc83bebdd8e 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -38,9 +38,6 @@ static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
38 { }; 38 { };
39#endif 39#endif
40 40
41/* scsi_scan.c */
42int scsi_complete_async_scans(void);
43
44/* scsi_devinfo.c */ 41/* scsi_devinfo.c */
45extern int scsi_get_device_flags(struct scsi_device *sdev, 42extern int scsi_get_device_flags(struct scsi_device *sdev,
46 const unsigned char *vendor, 43 const unsigned char *vendor,
diff --git a/drivers/scsi/scsi_wait_scan.c b/drivers/scsi/scsi_wait_scan.c
index 8a636103083d..2f21af21269a 100644
--- a/drivers/scsi/scsi_wait_scan.c
+++ b/drivers/scsi/scsi_wait_scan.c
@@ -11,7 +11,7 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include "scsi_priv.h" 14#include <scsi/scsi_scan.h>
15 15
16static int __init wait_scan_init(void) 16static int __init wait_scan_init(void)
17{ 17{
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c
index 7fb9b5c4669a..12d13d99b6f0 100644
--- a/drivers/sh/intc.c
+++ b/drivers/sh/intc.c
@@ -44,6 +44,7 @@ struct intc_handle_int {
44struct intc_desc_int { 44struct intc_desc_int {
45 struct list_head list; 45 struct list_head list;
46 struct sys_device sysdev; 46 struct sys_device sysdev;
47 pm_message_t state;
47 unsigned long *reg; 48 unsigned long *reg;
48#ifdef CONFIG_SMP 49#ifdef CONFIG_SMP
49 unsigned long *smp; 50 unsigned long *smp;
@@ -786,18 +787,44 @@ static int intc_suspend(struct sys_device *dev, pm_message_t state)
786 /* get intc controller associated with this sysdev */ 787 /* get intc controller associated with this sysdev */
787 d = container_of(dev, struct intc_desc_int, sysdev); 788 d = container_of(dev, struct intc_desc_int, sysdev);
788 789
789 /* enable wakeup irqs belonging to this intc controller */ 790 switch (state.event) {
790 for_each_irq_desc(irq, desc) { 791 case PM_EVENT_ON:
791 if ((desc->status & IRQ_WAKEUP) && (desc->chip == &d->chip)) 792 if (d->state.event != PM_EVENT_FREEZE)
792 intc_enable(irq); 793 break;
794 for_each_irq_desc(irq, desc) {
795 if (desc->chip != &d->chip)
796 continue;
797 if (desc->status & IRQ_DISABLED)
798 intc_disable(irq);
799 else
800 intc_enable(irq);
801 }
802 break;
803 case PM_EVENT_FREEZE:
804 /* nothing has to be done */
805 break;
806 case PM_EVENT_SUSPEND:
807 /* enable wakeup irqs belonging to this intc controller */
808 for_each_irq_desc(irq, desc) {
809 if ((desc->status & IRQ_WAKEUP) && (desc->chip == &d->chip))
810 intc_enable(irq);
811 }
812 break;
793 } 813 }
814 d->state = state;
794 815
795 return 0; 816 return 0;
796} 817}
797 818
819static int intc_resume(struct sys_device *dev)
820{
821 return intc_suspend(dev, PMSG_ON);
822}
823
798static struct sysdev_class intc_sysdev_class = { 824static struct sysdev_class intc_sysdev_class = {
799 .name = "intc", 825 .name = "intc",
800 .suspend = intc_suspend, 826 .suspend = intc_suspend,
827 .resume = intc_resume,
801}; 828};
802 829
803/* register this intc as sysdev to allow suspend/resume */ 830/* register this intc as sysdev to allow suspend/resume */
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 643908b74bc0..8eba98c8ed1e 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -658,7 +658,7 @@ int spi_write_then_read(struct spi_device *spi,
658 658
659 int status; 659 int status;
660 struct spi_message message; 660 struct spi_message message;
661 struct spi_transfer x; 661 struct spi_transfer x[2];
662 u8 *local_buf; 662 u8 *local_buf;
663 663
664 /* Use preallocated DMA-safe buffer. We can't avoid copying here, 664 /* Use preallocated DMA-safe buffer. We can't avoid copying here,
@@ -669,9 +669,15 @@ int spi_write_then_read(struct spi_device *spi,
669 return -EINVAL; 669 return -EINVAL;
670 670
671 spi_message_init(&message); 671 spi_message_init(&message);
672 memset(&x, 0, sizeof x); 672 memset(x, 0, sizeof x);
673 x.len = n_tx + n_rx; 673 if (n_tx) {
674 spi_message_add_tail(&x, &message); 674 x[0].len = n_tx;
675 spi_message_add_tail(&x[0], &message);
676 }
677 if (n_rx) {
678 x[1].len = n_rx;
679 spi_message_add_tail(&x[1], &message);
680 }
675 681
676 /* ... unless someone else is using the pre-allocated buffer */ 682 /* ... unless someone else is using the pre-allocated buffer */
677 if (!mutex_trylock(&lock)) { 683 if (!mutex_trylock(&lock)) {
@@ -682,15 +688,15 @@ int spi_write_then_read(struct spi_device *spi,
682 local_buf = buf; 688 local_buf = buf;
683 689
684 memcpy(local_buf, txbuf, n_tx); 690 memcpy(local_buf, txbuf, n_tx);
685 x.tx_buf = local_buf; 691 x[0].tx_buf = local_buf;
686 x.rx_buf = local_buf; 692 x[1].rx_buf = local_buf + n_tx;
687 693
688 /* do the i/o */ 694 /* do the i/o */
689 status = spi_sync(spi, &message); 695 status = spi_sync(spi, &message);
690 if (status == 0) 696 if (status == 0)
691 memcpy(rxbuf, x.rx_buf + n_tx, n_rx); 697 memcpy(rxbuf, x[1].rx_buf, n_rx);
692 698
693 if (x.tx_buf == buf) 699 if (x[0].tx_buf == buf)
694 mutex_unlock(&lock); 700 mutex_unlock(&lock);
695 else 701 else
696 kfree(local_buf); 702 kfree(local_buf);
diff --git a/drivers/staging/b3dfg/b3dfg.c b/drivers/staging/b3dfg/b3dfg.c
index 0348072b3ab5..75ebe338c6f2 100644
--- a/drivers/staging/b3dfg/b3dfg.c
+++ b/drivers/staging/b3dfg/b3dfg.c
@@ -1000,7 +1000,7 @@ static int __devinit b3dfg_probe(struct pci_dev *pdev,
1000 1000
1001 pci_set_master(pdev); 1001 pci_set_master(pdev);
1002 1002
1003 r = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 1003 r = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1004 if (r) { 1004 if (r) {
1005 dev_err(&pdev->dev, "no usable DMA configuration\n"); 1005 dev_err(&pdev->dev, "no usable DMA configuration\n");
1006 goto err_free_res; 1006 goto err_free_res;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 869d47cb6db3..0a69c0977e3f 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -546,10 +546,6 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
546 tty->driver_data = acm; 546 tty->driver_data = acm;
547 acm->tty = tty; 547 acm->tty = tty;
548 548
549 /* force low_latency on so that our tty_push actually forces the data through,
550 otherwise it is scheduled, and with high data rates data can get lost. */
551 tty->low_latency = 1;
552
553 if (usb_autopm_get_interface(acm->control) < 0) 549 if (usb_autopm_get_interface(acm->control) < 0)
554 goto early_bail; 550 goto early_bail;
555 else 551 else
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index 4b933f646f2e..c567168f89af 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -36,14 +36,14 @@ struct nop_usb_xceiv {
36 struct device *dev; 36 struct device *dev;
37}; 37};
38 38
39static u64 nop_xceiv_dmamask = DMA_32BIT_MASK; 39static u64 nop_xceiv_dmamask = DMA_BIT_MASK(32);
40 40
41static struct platform_device nop_xceiv_device = { 41static struct platform_device nop_xceiv_device = {
42 .name = "nop_usb_xceiv", 42 .name = "nop_usb_xceiv",
43 .id = -1, 43 .id = -1,
44 .dev = { 44 .dev = {
45 .dma_mask = &nop_xceiv_dmamask, 45 .dma_mask = &nop_xceiv_dmamask,
46 .coherent_dma_mask = DMA_32BIT_MASK, 46 .coherent_dma_mask = DMA_BIT_MASK(32),
47 .platform_data = NULL, 47 .platform_data = NULL,
48 }, 48 },
49}; 49};
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 2620bf6fe5e1..9c4c700c7cc6 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1215,20 +1215,22 @@ static void ti_bulk_in_callback(struct urb *urb)
1215 } 1215 }
1216 1216
1217 tty = tty_port_tty_get(&port->port); 1217 tty = tty_port_tty_get(&port->port);
1218 if (tty && urb->actual_length) { 1218 if (tty) {
1219 usb_serial_debug_data(debug, dev, __func__, 1219 if (urb->actual_length) {
1220 urb->actual_length, urb->transfer_buffer); 1220 usb_serial_debug_data(debug, dev, __func__,
1221 1221 urb->actual_length, urb->transfer_buffer);
1222 if (!tport->tp_is_open) 1222
1223 dbg("%s - port closed, dropping data", __func__); 1223 if (!tport->tp_is_open)
1224 else 1224 dbg("%s - port closed, dropping data",
1225 ti_recv(&urb->dev->dev, tty, 1225 __func__);
1226 else
1227 ti_recv(&urb->dev->dev, tty,
1226 urb->transfer_buffer, 1228 urb->transfer_buffer,
1227 urb->actual_length); 1229 urb->actual_length);
1228 1230 spin_lock(&tport->tp_lock);
1229 spin_lock(&tport->tp_lock); 1231 tport->tp_icount.rx += urb->actual_length;
1230 tport->tp_icount.rx += urb->actual_length; 1232 spin_unlock(&tport->tp_lock);
1231 spin_unlock(&tport->tp_lock); 1233 }
1232 tty_kref_put(tty); 1234 tty_kref_put(tty);
1233 } 1235 }
1234 1236
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 16bb7e3c0310..6c37e8ee5efe 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -698,8 +698,8 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
698found: 698found:
699 /* 699 /*
700 * Some methods fail to retrieve SCLK and MCLK values, we apply default 700 * Some methods fail to retrieve SCLK and MCLK values, we apply default
701 * settings in this case (200Mhz). If that really happne often, we could 701 * settings in this case (200Mhz). If that really happens often, we
702 * fetch from registers instead... 702 * could fetch from registers instead...
703 */ 703 */
704 if (rinfo->pll.mclk == 0) 704 if (rinfo->pll.mclk == 0)
705 rinfo->pll.mclk = 20000; 705 rinfo->pll.mclk = 20000;
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index dd37cbcaf8ce..157057c79ca3 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -35,8 +35,6 @@ static int fb_notifier_callback(struct notifier_block *self,
35 return 0; 35 return 0;
36 36
37 bd = container_of(self, struct backlight_device, fb_notif); 37 bd = container_of(self, struct backlight_device, fb_notif);
38 if (!lock_fb_info(evdata->info))
39 return -ENODEV;
40 mutex_lock(&bd->ops_lock); 38 mutex_lock(&bd->ops_lock);
41 if (bd->ops) 39 if (bd->ops)
42 if (!bd->ops->check_fb || 40 if (!bd->ops->check_fb ||
@@ -49,7 +47,6 @@ static int fb_notifier_callback(struct notifier_block *self,
49 backlight_update_status(bd); 47 backlight_update_status(bd);
50 } 48 }
51 mutex_unlock(&bd->ops_lock); 49 mutex_unlock(&bd->ops_lock);
52 unlock_fb_info(evdata->info);
53 return 0; 50 return 0;
54} 51}
55 52
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 0bb13df0fa89..b6449470106c 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -40,8 +40,6 @@ static int fb_notifier_callback(struct notifier_block *self,
40 if (!ld->ops) 40 if (!ld->ops)
41 return 0; 41 return 0;
42 42
43 if (!lock_fb_info(evdata->info))
44 return -ENODEV;
45 mutex_lock(&ld->ops_lock); 43 mutex_lock(&ld->ops_lock);
46 if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) { 44 if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) {
47 if (event == FB_EVENT_BLANK) { 45 if (event == FB_EVENT_BLANK) {
@@ -53,7 +51,6 @@ static int fb_notifier_callback(struct notifier_block *self,
53 } 51 }
54 } 52 }
55 mutex_unlock(&ld->ops_lock); 53 mutex_unlock(&ld->ops_lock);
56 unlock_fb_info(evdata->info);
57 return 0; 54 return 0;
58} 55}
59 56
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index d42e385f091c..4c2bf923418c 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -567,9 +567,7 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var,
567 default: 567 default:
568 dev_dbg(info->device, 568 dev_dbg(info->device,
569 "Unsupported bpp size: %d\n", var->bits_per_pixel); 569 "Unsupported bpp size: %d\n", var->bits_per_pixel);
570 assert(false); 570 return -EINVAL;
571 /* should never occur */
572 break;
573 } 571 }
574 572
575 if (var->xres_virtual < var->xres) 573 if (var->xres_virtual < var->xres)
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 2cd500a304f2..471a9a60376a 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2263,9 +2263,12 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
2263 } 2263 }
2264 2264
2265 2265
2266 if (!lock_fb_info(info))
2267 return;
2266 event.info = info; 2268 event.info = info;
2267 event.data = &blank; 2269 event.data = &blank;
2268 fb_notifier_call_chain(FB_EVENT_CONBLANK, &event); 2270 fb_notifier_call_chain(FB_EVENT_CONBLANK, &event);
2271 unlock_fb_info(info);
2269} 2272}
2270 2273
2271static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) 2274static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
@@ -2956,8 +2959,6 @@ static int fbcon_fb_unregistered(struct fb_info *info)
2956{ 2959{
2957 int i, idx; 2960 int i, idx;
2958 2961
2959 if (!lock_fb_info(info))
2960 return -ENODEV;
2961 idx = info->node; 2962 idx = info->node;
2962 for (i = first_fb_vc; i <= last_fb_vc; i++) { 2963 for (i = first_fb_vc; i <= last_fb_vc; i++) {
2963 if (con2fb_map[i] == idx) 2964 if (con2fb_map[i] == idx)
@@ -2985,8 +2986,6 @@ static int fbcon_fb_unregistered(struct fb_info *info)
2985 if (primary_device == idx) 2986 if (primary_device == idx)
2986 primary_device = -1; 2987 primary_device = -1;
2987 2988
2988 unlock_fb_info(info);
2989
2990 if (!num_registered_fb) 2989 if (!num_registered_fb)
2991 unregister_con_driver(&fb_con); 2990 unregister_con_driver(&fb_con);
2992 2991
@@ -3027,11 +3026,8 @@ static int fbcon_fb_registered(struct fb_info *info)
3027{ 3026{
3028 int ret = 0, i, idx; 3027 int ret = 0, i, idx;
3029 3028
3030 if (!lock_fb_info(info))
3031 return -ENODEV;
3032 idx = info->node; 3029 idx = info->node;
3033 fbcon_select_primary(info); 3030 fbcon_select_primary(info);
3034 unlock_fb_info(info);
3035 3031
3036 if (info_idx == -1) { 3032 if (info_idx == -1) {
3037 for (i = first_fb_vc; i <= last_fb_vc; i++) { 3033 for (i = first_fb_vc; i <= last_fb_vc; i++) {
@@ -3152,53 +3148,23 @@ static int fbcon_event_notify(struct notifier_block *self,
3152 3148
3153 switch(action) { 3149 switch(action) {
3154 case FB_EVENT_SUSPEND: 3150 case FB_EVENT_SUSPEND:
3155 if (!lock_fb_info(info)) {
3156 ret = -ENODEV;
3157 goto done;
3158 }
3159 fbcon_suspended(info); 3151 fbcon_suspended(info);
3160 unlock_fb_info(info);
3161 break; 3152 break;
3162 case FB_EVENT_RESUME: 3153 case FB_EVENT_RESUME:
3163 if (!lock_fb_info(info)) {
3164 ret = -ENODEV;
3165 goto done;
3166 }
3167 fbcon_resumed(info); 3154 fbcon_resumed(info);
3168 unlock_fb_info(info);
3169 break; 3155 break;
3170 case FB_EVENT_MODE_CHANGE: 3156 case FB_EVENT_MODE_CHANGE:
3171 if (!lock_fb_info(info)) {
3172 ret = -ENODEV;
3173 goto done;
3174 }
3175 fbcon_modechanged(info); 3157 fbcon_modechanged(info);
3176 unlock_fb_info(info);
3177 break; 3158 break;
3178 case FB_EVENT_MODE_CHANGE_ALL: 3159 case FB_EVENT_MODE_CHANGE_ALL:
3179 if (!lock_fb_info(info)) {
3180 ret = -ENODEV;
3181 goto done;
3182 }
3183 fbcon_set_all_vcs(info); 3160 fbcon_set_all_vcs(info);
3184 unlock_fb_info(info);
3185 break; 3161 break;
3186 case FB_EVENT_MODE_DELETE: 3162 case FB_EVENT_MODE_DELETE:
3187 mode = event->data; 3163 mode = event->data;
3188 if (!lock_fb_info(info)) {
3189 ret = -ENODEV;
3190 goto done;
3191 }
3192 ret = fbcon_mode_deleted(info, mode); 3164 ret = fbcon_mode_deleted(info, mode);
3193 unlock_fb_info(info);
3194 break; 3165 break;
3195 case FB_EVENT_FB_UNBIND: 3166 case FB_EVENT_FB_UNBIND:
3196 if (!lock_fb_info(info)) {
3197 ret = -ENODEV;
3198 goto done;
3199 }
3200 idx = info->node; 3167 idx = info->node;
3201 unlock_fb_info(info);
3202 ret = fbcon_fb_unbind(idx); 3168 ret = fbcon_fb_unbind(idx);
3203 break; 3169 break;
3204 case FB_EVENT_FB_REGISTERED: 3170 case FB_EVENT_FB_REGISTERED:
@@ -3217,29 +3183,14 @@ static int fbcon_event_notify(struct notifier_block *self,
3217 con2fb->framebuffer = con2fb_map[con2fb->console - 1]; 3183 con2fb->framebuffer = con2fb_map[con2fb->console - 1];
3218 break; 3184 break;
3219 case FB_EVENT_BLANK: 3185 case FB_EVENT_BLANK:
3220 if (!lock_fb_info(info)) {
3221 ret = -ENODEV;
3222 goto done;
3223 }
3224 fbcon_fb_blanked(info, *(int *)event->data); 3186 fbcon_fb_blanked(info, *(int *)event->data);
3225 unlock_fb_info(info);
3226 break; 3187 break;
3227 case FB_EVENT_NEW_MODELIST: 3188 case FB_EVENT_NEW_MODELIST:
3228 if (!lock_fb_info(info)) {
3229 ret = -ENODEV;
3230 goto done;
3231 }
3232 fbcon_new_modelist(info); 3189 fbcon_new_modelist(info);
3233 unlock_fb_info(info);
3234 break; 3190 break;
3235 case FB_EVENT_GET_REQ: 3191 case FB_EVENT_GET_REQ:
3236 caps = event->data; 3192 caps = event->data;
3237 if (!lock_fb_info(info)) {
3238 ret = -ENODEV;
3239 goto done;
3240 }
3241 fbcon_get_requirement(info, caps); 3193 fbcon_get_requirement(info, caps);
3242 unlock_fb_info(info);
3243 break; 3194 break;
3244 } 3195 }
3245done: 3196done:
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index 0c5b9a9fd56f..8dea2bc92705 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -210,12 +210,15 @@ static int __init efifb_probe(struct platform_device *dev)
210 unsigned int size_total; 210 unsigned int size_total;
211 int request_succeeded = 0; 211 int request_succeeded = 0;
212 212
213 printk(KERN_INFO "efifb: probing for efifb\n");
214
215 if (!screen_info.lfb_depth) 213 if (!screen_info.lfb_depth)
216 screen_info.lfb_depth = 32; 214 screen_info.lfb_depth = 32;
217 if (!screen_info.pages) 215 if (!screen_info.pages)
218 screen_info.pages = 1; 216 screen_info.pages = 1;
217 if (!screen_info.lfb_base) {
218 printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
219 return -ENODEV;
220 }
221 printk(KERN_INFO "efifb: probing for efifb\n");
219 222
220 /* just assume they're all unset if any are */ 223 /* just assume they're all unset if any are */
221 if (!screen_info.blue_size) { 224 if (!screen_info.blue_size) {
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 2ac32e6b5953..d412a1ddc12f 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1097,8 +1097,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1097 return -EINVAL; 1097 return -EINVAL;
1098 con2fb.framebuffer = -1; 1098 con2fb.framebuffer = -1;
1099 event.data = &con2fb; 1099 event.data = &con2fb;
1100 if (!lock_fb_info(info))
1101 return -ENODEV;
1100 event.info = info; 1102 event.info = info;
1101 fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event); 1103 fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event);
1104 unlock_fb_info(info);
1102 ret = copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0; 1105 ret = copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0;
1103 break; 1106 break;
1104 case FBIOPUT_CON2FBMAP: 1107 case FBIOPUT_CON2FBMAP:
@@ -1115,8 +1118,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1115 break; 1118 break;
1116 } 1119 }
1117 event.data = &con2fb; 1120 event.data = &con2fb;
1121 if (!lock_fb_info(info))
1122 return -ENODEV;
1118 event.info = info; 1123 event.info = info;
1119 ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, &event); 1124 ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, &event);
1125 unlock_fb_info(info);
1120 break; 1126 break;
1121 case FBIOBLANK: 1127 case FBIOBLANK:
1122 if (!lock_fb_info(info)) 1128 if (!lock_fb_info(info))
@@ -1521,7 +1527,10 @@ register_framebuffer(struct fb_info *fb_info)
1521 registered_fb[i] = fb_info; 1527 registered_fb[i] = fb_info;
1522 1528
1523 event.info = fb_info; 1529 event.info = fb_info;
1530 if (!lock_fb_info(fb_info))
1531 return -ENODEV;
1524 fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event); 1532 fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
1533 unlock_fb_info(fb_info);
1525 return 0; 1534 return 0;
1526} 1535}
1527 1536
@@ -1555,8 +1564,12 @@ unregister_framebuffer(struct fb_info *fb_info)
1555 goto done; 1564 goto done;
1556 } 1565 }
1557 1566
1567
1568 if (!lock_fb_info(fb_info))
1569 return -ENODEV;
1558 event.info = fb_info; 1570 event.info = fb_info;
1559 ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event); 1571 ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event);
1572 unlock_fb_info(fb_info);
1560 1573
1561 if (ret) { 1574 if (ret) {
1562 ret = -EINVAL; 1575 ret = -EINVAL;
@@ -1590,6 +1603,8 @@ void fb_set_suspend(struct fb_info *info, int state)
1590{ 1603{
1591 struct fb_event event; 1604 struct fb_event event;
1592 1605
1606 if (!lock_fb_info(info))
1607 return;
1593 event.info = info; 1608 event.info = info;
1594 if (state) { 1609 if (state) {
1595 fb_notifier_call_chain(FB_EVENT_SUSPEND, &event); 1610 fb_notifier_call_chain(FB_EVENT_SUSPEND, &event);
@@ -1598,6 +1613,7 @@ void fb_set_suspend(struct fb_info *info, int state)
1598 info->state = FBINFO_STATE_RUNNING; 1613 info->state = FBINFO_STATE_RUNNING;
1599 fb_notifier_call_chain(FB_EVENT_RESUME, &event); 1614 fb_notifier_call_chain(FB_EVENT_RESUME, &event);
1600 } 1615 }
1616 unlock_fb_info(info);
1601} 1617}
1602 1618
1603/** 1619/**
@@ -1667,8 +1683,11 @@ int fb_new_modelist(struct fb_info *info)
1667 err = 1; 1683 err = 1;
1668 1684
1669 if (!list_empty(&info->modelist)) { 1685 if (!list_empty(&info->modelist)) {
1686 if (!lock_fb_info(info))
1687 return -ENODEV;
1670 event.info = info; 1688 event.info = info;
1671 err = fb_notifier_call_chain(FB_EVENT_NEW_MODELIST, &event); 1689 err = fb_notifier_call_chain(FB_EVENT_NEW_MODELIST, &event);
1690 unlock_fb_info(info);
1672 } 1691 }
1673 1692
1674 return err; 1693 return err;
diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h
index a50bea614804..40984551c927 100644
--- a/drivers/video/intelfb/intelfb.h
+++ b/drivers/video/intelfb/intelfb.h
@@ -53,6 +53,7 @@
53#define PCI_DEVICE_ID_INTEL_830M 0x3577 53#define PCI_DEVICE_ID_INTEL_830M 0x3577
54#define PCI_DEVICE_ID_INTEL_845G 0x2562 54#define PCI_DEVICE_ID_INTEL_845G 0x2562
55#define PCI_DEVICE_ID_INTEL_85XGM 0x3582 55#define PCI_DEVICE_ID_INTEL_85XGM 0x3582
56#define PCI_DEVICE_ID_INTEL_854 0x358E
56#define PCI_DEVICE_ID_INTEL_865G 0x2572 57#define PCI_DEVICE_ID_INTEL_865G 0x2572
57#define PCI_DEVICE_ID_INTEL_915G 0x2582 58#define PCI_DEVICE_ID_INTEL_915G 0x2582
58#define PCI_DEVICE_ID_INTEL_915GM 0x2592 59#define PCI_DEVICE_ID_INTEL_915GM 0x2592
@@ -154,6 +155,7 @@ enum intel_chips {
154 INTEL_85XGM, 155 INTEL_85XGM,
155 INTEL_852GM, 156 INTEL_852GM,
156 INTEL_852GME, 157 INTEL_852GME,
158 INTEL_854,
157 INTEL_855GM, 159 INTEL_855GM,
158 INTEL_855GME, 160 INTEL_855GME,
159 INTEL_865G, 161 INTEL_865G,
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c
index b3065492bb20..487f2be47460 100644
--- a/drivers/video/intelfb/intelfb_i2c.c
+++ b/drivers/video/intelfb/intelfb_i2c.c
@@ -156,6 +156,7 @@ void intelfb_create_i2c_busses(struct intelfb_info *dinfo)
156 switch(dinfo->chipset) { 156 switch(dinfo->chipset) {
157 case INTEL_830M: 157 case INTEL_830M:
158 case INTEL_845G: 158 case INTEL_845G:
159 case INTEL_854:
159 case INTEL_855GM: 160 case INTEL_855GM:
160 case INTEL_865G: 161 case INTEL_865G:
161 dinfo->output[i].type = INTELFB_OUTPUT_DVO; 162 dinfo->output[i].type = INTELFB_OUTPUT_DVO;
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 6d8e5415c809..ace14fe02fc4 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -182,6 +182,7 @@ static struct pci_device_id intelfb_pci_table[] __devinitdata = {
182 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_845G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_845G }, 182 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_845G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_845G },
183 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_85XGM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_85XGM }, 183 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_85XGM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_85XGM },
184 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_865G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_865G }, 184 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_865G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_865G },
185 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_854, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_854 },
185 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915G }, 186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915G },
186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM }, 187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM },
187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G }, 188 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G },
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index 8b26b27c2db6..0689f97c5238 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -84,6 +84,11 @@ int intelfbhw_get_chipset(struct pci_dev *pdev, struct intelfb_info *dinfo)
84 dinfo->mobile = 0; 84 dinfo->mobile = 0;
85 dinfo->pll_index = PLLS_I8xx; 85 dinfo->pll_index = PLLS_I8xx;
86 return 0; 86 return 0;
87 case PCI_DEVICE_ID_INTEL_854:
88 dinfo->mobile = 1;
89 dinfo->name = "Intel(R) 854";
90 dinfo->chipset = INTEL_854;
91 return 0;
87 case PCI_DEVICE_ID_INTEL_85XGM: 92 case PCI_DEVICE_ID_INTEL_85XGM:
88 tmp = 0; 93 tmp = 0;
89 dinfo->mobile = 1; 94 dinfo->mobile = 1;
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c
index 4dcec48a1d78..c3fad34309ed 100644
--- a/drivers/video/s3fb.c
+++ b/drivers/video/s3fb.c
@@ -45,11 +45,11 @@ struct s3fb_info {
45static const struct svga_fb_format s3fb_formats[] = { 45static const struct svga_fb_format s3fb_formats[] = {
46 { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 46 { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
47 FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 16}, 47 FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 16},
48 { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 48 { 4, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0,
49 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16}, 49 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16},
50 { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1, 50 { 4, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 1,
51 FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16}, 51 FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16},
52 { 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 52 { 8, {0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
53 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 4, 8}, 53 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 4, 8},
54 {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0, 54 {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0,
55 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 4}, 55 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 4},
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index fad58cf9ef73..10ddad8e17d6 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -199,16 +199,20 @@
199extern void (*sa1100fb_backlight_power)(int on); 199extern void (*sa1100fb_backlight_power)(int on);
200extern void (*sa1100fb_lcd_power)(int on); 200extern void (*sa1100fb_lcd_power)(int on);
201 201
202/* 202static struct sa1100fb_rgb rgb_4 = {
203 * IMHO this looks wrong. In 8BPP, length should be 8.
204 */
205static struct sa1100fb_rgb rgb_8 = {
206 .red = { .offset = 0, .length = 4, }, 203 .red = { .offset = 0, .length = 4, },
207 .green = { .offset = 0, .length = 4, }, 204 .green = { .offset = 0, .length = 4, },
208 .blue = { .offset = 0, .length = 4, }, 205 .blue = { .offset = 0, .length = 4, },
209 .transp = { .offset = 0, .length = 0, }, 206 .transp = { .offset = 0, .length = 0, },
210}; 207};
211 208
209static struct sa1100fb_rgb rgb_8 = {
210 .red = { .offset = 0, .length = 8, },
211 .green = { .offset = 0, .length = 8, },
212 .blue = { .offset = 0, .length = 8, },
213 .transp = { .offset = 0, .length = 0, },
214};
215
212static struct sa1100fb_rgb def_rgb_16 = { 216static struct sa1100fb_rgb def_rgb_16 = {
213 .red = { .offset = 11, .length = 5, }, 217 .red = { .offset = 11, .length = 5, },
214 .green = { .offset = 5, .length = 6, }, 218 .green = { .offset = 5, .length = 6, },
@@ -613,7 +617,7 @@ sa1100fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
613 DPRINTK("var->bits_per_pixel=%d\n", var->bits_per_pixel); 617 DPRINTK("var->bits_per_pixel=%d\n", var->bits_per_pixel);
614 switch (var->bits_per_pixel) { 618 switch (var->bits_per_pixel) {
615 case 4: 619 case 4:
616 rgbidx = RGB_8; 620 rgbidx = RGB_4;
617 break; 621 break;
618 case 8: 622 case 8:
619 rgbidx = RGB_8; 623 rgbidx = RGB_8;
@@ -1382,6 +1386,7 @@ static struct sa1100fb_info * __init sa1100fb_init_fbinfo(struct device *dev)
1382 fbi->fb.monspecs = monspecs; 1386 fbi->fb.monspecs = monspecs;
1383 fbi->fb.pseudo_palette = (fbi + 1); 1387 fbi->fb.pseudo_palette = (fbi + 1);
1384 1388
1389 fbi->rgb[RGB_4] = &rgb_4;
1385 fbi->rgb[RGB_8] = &rgb_8; 1390 fbi->rgb[RGB_8] = &rgb_8;
1386 fbi->rgb[RGB_16] = &def_rgb_16; 1391 fbi->rgb[RGB_16] = &def_rgb_16;
1387 1392
diff --git a/drivers/video/sa1100fb.h b/drivers/video/sa1100fb.h
index 86831db9a042..1c3b459865d8 100644
--- a/drivers/video/sa1100fb.h
+++ b/drivers/video/sa1100fb.h
@@ -57,9 +57,10 @@ struct sa1100fb_lcd_reg {
57 unsigned long lccr3; 57 unsigned long lccr3;
58}; 58};
59 59
60#define RGB_8 (0) 60#define RGB_4 (0)
61#define RGB_16 (1) 61#define RGB_8 (1)
62#define NR_RGB 2 62#define RGB_16 (2)
63#define NR_RGB 3
63 64
64struct sa1100fb_info { 65struct sa1100fb_info {
65 struct fb_info fb; 66 struct fb_info fb;
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index 346d6458cf76..7e17ee95a97a 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -1129,7 +1129,7 @@ sisfb_bpp_to_var(struct sis_video_info *ivideo, struct fb_var_screeninfo *var)
1129 switch(var->bits_per_pixel) { 1129 switch(var->bits_per_pixel) {
1130 case 8: 1130 case 8:
1131 var->red.offset = var->green.offset = var->blue.offset = 0; 1131 var->red.offset = var->green.offset = var->blue.offset = 0;
1132 var->red.length = var->green.length = var->blue.length = 6; 1132 var->red.length = var->green.length = var->blue.length = 8;
1133 break; 1133 break;
1134 case 16: 1134 case 16:
1135 var->red.offset = 11; 1135 var->red.offset = 11;
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
index a439159204a8..89158bc71da2 100644
--- a/drivers/video/skeletonfb.c
+++ b/drivers/video/skeletonfb.c
@@ -308,9 +308,11 @@ static int xxxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
308 * color depth = SUM(var->{color}.length) 308 * color depth = SUM(var->{color}.length)
309 * 309 *
310 * Pseudocolor: 310 * Pseudocolor:
311 * var->{color}.offset is 0 311 * var->{color}.offset is 0 unless the palette index takes less than
312 * var->{color}.length contains width of DAC or the number of unique 312 * bits_per_pixel bits and is stored in the upper
313 * colors available (color depth) 313 * bits of the pixel value
314 * var->{color}.length is set so that 1 << length is the number of
315 * available palette entries
314 * pseudo_palette is not used 316 * pseudo_palette is not used
315 * RAMDAC[X] is programmed to (red, green, blue) 317 * RAMDAC[X] is programmed to (red, green, blue)
316 * color depth = var->{color}.length 318 * color depth = var->{color}.length
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 0b370aebdbfd..421770b5e6ab 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -55,6 +55,7 @@ static u16 maxvf __devinitdata; /* maximum vertical frequency */
55static u16 maxhf __devinitdata; /* maximum horizontal frequency */ 55static u16 maxhf __devinitdata; /* maximum horizontal frequency */
56static u16 vbemode __devinitdata; /* force use of a specific VBE mode */ 56static u16 vbemode __devinitdata; /* force use of a specific VBE mode */
57static char *mode_option __devinitdata; 57static char *mode_option __devinitdata;
58static u8 dac_width = 6;
58 59
59static struct uvesafb_ktask *uvfb_tasks[UVESAFB_TASKS_MAX]; 60static struct uvesafb_ktask *uvfb_tasks[UVESAFB_TASKS_MAX];
60static DEFINE_MUTEX(uvfb_lock); 61static DEFINE_MUTEX(uvfb_lock);
@@ -303,22 +304,10 @@ static void uvesafb_setup_var(struct fb_var_screeninfo *var,
303 var->blue.offset = 0; 304 var->blue.offset = 0;
304 var->transp.offset = 0; 305 var->transp.offset = 0;
305 306
306 /* 307 var->red.length = 8;
307 * We're assuming that we can switch the DAC to 8 bits. If 308 var->green.length = 8;
308 * this proves to be incorrect, we'll update the fields 309 var->blue.length = 8;
309 * later in set_par(). 310 var->transp.length = 0;
310 */
311 if (par->vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC) {
312 var->red.length = 8;
313 var->green.length = 8;
314 var->blue.length = 8;
315 var->transp.length = 0;
316 } else {
317 var->red.length = 6;
318 var->green.length = 6;
319 var->blue.length = 6;
320 var->transp.length = 0;
321 }
322 } 311 }
323} 312}
324 313
@@ -1006,7 +995,7 @@ static int uvesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
1006 struct fb_info *info) 995 struct fb_info *info)
1007{ 996{
1008 struct uvesafb_pal_entry entry; 997 struct uvesafb_pal_entry entry;
1009 int shift = 16 - info->var.green.length; 998 int shift = 16 - dac_width;
1010 int err = 0; 999 int err = 0;
1011 1000
1012 if (regno >= info->cmap.len) 1001 if (regno >= info->cmap.len)
@@ -1055,7 +1044,7 @@ static int uvesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
1055static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info) 1044static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
1056{ 1045{
1057 struct uvesafb_pal_entry *entries; 1046 struct uvesafb_pal_entry *entries;
1058 int shift = 16 - info->var.green.length; 1047 int shift = 16 - dac_width;
1059 int i, err = 0; 1048 int i, err = 0;
1060 1049
1061 if (info->var.bits_per_pixel == 8) { 1050 if (info->var.bits_per_pixel == 8) {
@@ -1317,13 +1306,9 @@ setmode:
1317 err = uvesafb_exec(task); 1306 err = uvesafb_exec(task);
1318 if (err || (task->t.regs.eax & 0xffff) != 0x004f || 1307 if (err || (task->t.regs.eax & 0xffff) != 0x004f ||
1319 ((task->t.regs.ebx & 0xff00) >> 8) != 8) { 1308 ((task->t.regs.ebx & 0xff00) >> 8) != 8) {
1320 /* 1309 dac_width = 6;
1321 * We've failed to set the DAC palette format - 1310 } else {
1322 * time to correct var. 1311 dac_width = 8;
1323 */
1324 info->var.red.length = 6;
1325 info->var.green.length = 6;
1326 info->var.blue.length = 6;
1327 } 1312 }
1328 } 1313 }
1329 1314
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c
index cc919ae46571..050d432c7d95 100644
--- a/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -318,13 +318,16 @@ static int vfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
318 * {hardwarespecific} contains width of RAMDAC 318 * {hardwarespecific} contains width of RAMDAC
319 * cmap[X] is programmed to (X << red.offset) | (X << green.offset) | (X << blue.offset) 319 * cmap[X] is programmed to (X << red.offset) | (X << green.offset) | (X << blue.offset)
320 * RAMDAC[X] is programmed to (red, green, blue) 320 * RAMDAC[X] is programmed to (red, green, blue)
321 * 321 *
322 * Pseudocolor: 322 * Pseudocolor:
323 * uses offset = 0 && length = RAMDAC register width. 323 * var->{color}.offset is 0 unless the palette index takes less than
324 * var->{color}.offset is 0 324 * bits_per_pixel bits and is stored in the upper
325 * var->{color}.length contains widht of DAC 325 * bits of the pixel value
326 * var->{color}.length is set so that 1 << length is the number of available
327 * palette entries
326 * cmap is not used 328 * cmap is not used
327 * RAMDAC[X] is programmed to (red, green, blue) 329 * RAMDAC[X] is programmed to (red, green, blue)
330 *
328 * Truecolor: 331 * Truecolor:
329 * does not use DAC. Usually 3 are present. 332 * does not use DAC. Usually 3 are present.
330 * var->{color}.offset contains start of bitfield 333 * var->{color}.offset contains start of bitfield
diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
index 5f54c01c1568..bdfd584ad853 100644
--- a/drivers/xen/cpu_hotplug.c
+++ b/drivers/xen/cpu_hotplug.c
@@ -21,29 +21,41 @@ static void disable_hotplug_cpu(int cpu)
21 set_cpu_present(cpu, false); 21 set_cpu_present(cpu, false);
22} 22}
23 23
24static void vcpu_hotplug(unsigned int cpu) 24static int vcpu_online(unsigned int cpu)
25{ 25{
26 int err; 26 int err;
27 char dir[32], state[32]; 27 char dir[32], state[32];
28 28
29 if (!cpu_possible(cpu))
30 return;
31
32 sprintf(dir, "cpu/%u", cpu); 29 sprintf(dir, "cpu/%u", cpu);
33 err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state); 30 err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state);
34 if (err != 1) { 31 if (err != 1) {
35 printk(KERN_ERR "XENBUS: Unable to read cpu state\n"); 32 printk(KERN_ERR "XENBUS: Unable to read cpu state\n");
36 return; 33 return err;
37 } 34 }
38 35
39 if (strcmp(state, "online") == 0) { 36 if (strcmp(state, "online") == 0)
37 return 1;
38 else if (strcmp(state, "offline") == 0)
39 return 0;
40
41 printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n", state, cpu);
42 return -EINVAL;
43}
44static void vcpu_hotplug(unsigned int cpu)
45{
46 if (!cpu_possible(cpu))
47 return;
48
49 switch (vcpu_online(cpu)) {
50 case 1:
40 enable_hotplug_cpu(cpu); 51 enable_hotplug_cpu(cpu);
41 } else if (strcmp(state, "offline") == 0) { 52 break;
53 case 0:
42 (void)cpu_down(cpu); 54 (void)cpu_down(cpu);
43 disable_hotplug_cpu(cpu); 55 disable_hotplug_cpu(cpu);
44 } else { 56 break;
45 printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n", 57 default:
46 state, cpu); 58 break;
47 } 59 }
48} 60}
49 61
@@ -64,12 +76,20 @@ static void handle_vcpu_hotplug_event(struct xenbus_watch *watch,
64static int setup_cpu_watcher(struct notifier_block *notifier, 76static int setup_cpu_watcher(struct notifier_block *notifier,
65 unsigned long event, void *data) 77 unsigned long event, void *data)
66{ 78{
79 int cpu;
67 static struct xenbus_watch cpu_watch = { 80 static struct xenbus_watch cpu_watch = {
68 .node = "cpu", 81 .node = "cpu",
69 .callback = handle_vcpu_hotplug_event}; 82 .callback = handle_vcpu_hotplug_event};
70 83
71 (void)register_xenbus_watch(&cpu_watch); 84 (void)register_xenbus_watch(&cpu_watch);
72 85
86 for_each_possible_cpu(cpu) {
87 if (vcpu_online(cpu) == 0) {
88 (void)cpu_down(cpu);
89 cpu_clear(cpu, cpu_present_map);
90 }
91 }
92
73 return NOTIFY_DONE; 93 return NOTIFY_DONE;
74} 94}
75 95
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 0d61db1e7b49..4b5b84837ee1 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -62,14 +62,15 @@ static int xen_suspend(void *data)
62 gnttab_resume(); 62 gnttab_resume();
63 xen_mm_unpin_all(); 63 xen_mm_unpin_all();
64 64
65 sysdev_resume();
66
67 if (!*cancelled) { 65 if (!*cancelled) {
68 xen_irq_resume(); 66 xen_irq_resume();
69 xen_console_resume(); 67 xen_console_resume();
70 xen_timer_resume(); 68 xen_timer_resume();
71 } 69 }
72 70
71 sysdev_resume();
72 device_power_up(PMSG_RESUME);
73
73 return 0; 74 return 0;
74} 75}
75 76