aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/Kconfig9
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/libata-acpi.c4
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/pata_palmld.c150
-rw-r--r--drivers/base/bus.c2
-rw-r--r--drivers/block/Kconfig2
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/amiserial.c2
-rw-r--r--drivers/char/hw_random/Kconfig14
-rw-r--r--drivers/char/hw_random/Makefile1
-rw-r--r--drivers/char/hw_random/mxc-rnga.c247
-rw-r--r--drivers/char/hw_random/omap-rng.c2
-rw-r--r--drivers/char/hw_random/timeriomem-rng.c26
-rw-r--r--drivers/char/hw_random/via-rng.c15
-rw-r--r--drivers/connector/Kconfig2
-rw-r--r--drivers/crypto/Kconfig8
-rw-r--r--drivers/crypto/hifn_795x.c8
-rw-r--r--drivers/crypto/padlock-aes.c13
-rw-r--r--drivers/crypto/talitos.c713
-rw-r--r--drivers/edac/e752x_edac.c2
-rw-r--r--drivers/hid/Kconfig92
-rw-r--r--drivers/hid/Makefile10
-rw-r--r--drivers/hid/hid-apple.c4
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hid/hid-debug.c23
-rw-r--r--drivers/hid/hid-drff.c8
-rw-r--r--drivers/hid/hid-gaff.c8
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-lgff.c10
-rw-r--r--drivers/hid/hid-ntrig.c222
-rw-r--r--drivers/hid/hid-sjoy.c180
-rw-r--r--drivers/hid/hid-tmff.c17
-rw-r--r--drivers/hid/hid-wacom.c259
-rw-r--r--drivers/hid/hid-zpff.c7
-rw-r--r--drivers/hid/hidraw.c5
-rw-r--r--drivers/hid/usbhid/hid-core.c7
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-bfin-twi.c59
-rw-r--r--drivers/i2c/busses/i2c-ocores.c5
-rw-r--r--drivers/i2c/busses/i2c-omap.c39
-rw-r--r--drivers/i2c/busses/i2c-pxa.c22
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c48
-rw-r--r--drivers/ide/Kconfig2
-rw-r--r--drivers/ide/ide-atapi.c2
-rw-r--r--drivers/input/misc/Kconfig2
-rw-r--r--drivers/input/serio/ambakmi.c2
-rw-r--r--drivers/isdn/divert/isdn_divert.c2
-rw-r--r--drivers/isdn/mISDN/dsp_core.c2
-rw-r--r--drivers/leds/leds-h1940.c2
-rw-r--r--drivers/leds/leds-s3c24xx.c1
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig2
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c2
-rw-r--r--drivers/message/fusion/lsi/mpi_history.txt6
-rw-r--r--drivers/mmc/host/Kconfig2
-rw-r--r--drivers/mmc/host/atmel-mci.c12
-rw-r--r--drivers/mmc/host/mmci.c2
-rw-r--r--drivers/mmc/host/omap_hsmmc.c6
-rw-r--r--drivers/mmc/host/s3cmci.c5
-rw-r--r--drivers/mtd/Kconfig3
-rw-r--r--drivers/mtd/devices/Kconfig2
-rw-r--r--drivers/mtd/nand/Kconfig4
-rw-r--r--drivers/mtd/onenand/omap2.c1
-rw-r--r--drivers/net/Kconfig4
-rw-r--r--drivers/net/appletalk/ltpc.c2
-rw-r--r--drivers/net/arm/ixp4xx_eth.c26
-rw-r--r--drivers/net/b44.h2
-rw-r--r--drivers/net/cnic.c10
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/e1000e/e1000.h2
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/igbvf/igbvf.h2
-rw-r--r--drivers/net/ipg.h2
-rw-r--r--drivers/net/mlx4/en_netdev.c2
-rw-r--r--drivers/net/niu.h4
-rw-r--r--drivers/net/qlge/qlge_main.c2
-rw-r--r--drivers/net/qlge/qlge_mpi.c6
-rw-r--r--drivers/net/skfp/h/smt.h2
-rw-r--r--drivers/net/smc91x.h5
-rw-r--r--drivers/net/tokenring/3c359.c2
-rw-r--r--drivers/net/tokenring/lanstreamer.c2
-rw-r--r--drivers/net/tokenring/olympic.c2
-rw-r--r--drivers/net/ucc_geth_ethtool.c2
-rw-r--r--drivers/net/usb/usbnet.c2
-rw-r--r--drivers/net/wan/ixp4xx_hss.c11
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/hostap/Kconfig8
-rw-r--r--drivers/net/wireless/iwlwifi/Kconfig4
-rw-r--r--drivers/net/wireless/rndis_wlan.c2
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig14
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h2
-rw-r--r--drivers/net/wireless/wavelan_cs.c2
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c4
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/pcmcia/Makefile1
-rw-r--r--drivers/pcmcia/pxa2xx_stargate2.c174
-rw-r--r--drivers/rtc/rtc-ep93xx.c149
-rw-r--r--drivers/rtc/rtc-pl030.c2
-rw-r--r--drivers/rtc/rtc-pl031.c3
-rw-r--r--drivers/s390/net/Kconfig14
-rw-r--r--drivers/s390/scsi/zfcp_fc.c2
-rw-r--r--drivers/scsi/dpt/osd_util.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c4
-rw-r--r--drivers/scsi/megaraid.h2
-rw-r--r--drivers/scsi/megaraid/mbox_defs.h2
-rw-r--r--drivers/serial/Kconfig2
-rw-r--r--drivers/serial/amba-pl010.c2
-rw-r--r--drivers/serial/amba-pl011.c38
-rw-r--r--drivers/serial/imx.c13
-rw-r--r--drivers/spi/Kconfig11
-rw-r--r--drivers/spi/Makefile1
-rw-r--r--drivers/spi/amba-pl022.c1866
-rw-r--r--drivers/spi/spi_s3c24xx_gpio.c1
-rw-r--r--drivers/staging/go7007/go7007.txt4
-rw-r--r--drivers/staging/panel/lcd-panel-cgram.txt2
-rw-r--r--drivers/staging/rt2860/common/mlme.c2
-rw-r--r--drivers/staging/rt2870/common/mlme.c2
-rw-r--r--drivers/staging/rt3070/common/mlme.c2
-rw-r--r--drivers/staging/wlan-ng/hfa384x_usb.c2
-rw-r--r--drivers/usb/host/ohci-ep93xx.c13
-rw-r--r--drivers/usb/serial/io_ti.c2
-rw-r--r--drivers/video/Kconfig12
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/amba-clcd.c2
-rw-r--r--drivers/video/mx3fb.c4
-rw-r--r--drivers/video/omap/hwa742.c26
-rw-r--r--drivers/video/pxa168fb.c803
-rw-r--r--drivers/video/pxa168fb.h558
-rw-r--r--drivers/w1/Kconfig2
-rw-r--r--drivers/w1/masters/Kconfig6
-rw-r--r--drivers/watchdog/Kconfig12
-rw-r--r--drivers/watchdog/Makefile2
-rw-r--r--drivers/watchdog/iop_wdt.c2
-rw-r--r--drivers/watchdog/orion_wdt.c (renamed from drivers/watchdog/orion5x_wdt.c)120
135 files changed, 5720 insertions, 606 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 9120717c0701..2aa1908e5ce0 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -535,6 +535,15 @@ config PATA_OPTIDMA
535 535
536 If unsure, say N. 536 If unsure, say N.
537 537
538config PATA_PALMLD
539 tristate "Palm LifeDrive PATA support"
540 depends on MACH_PALMLD
541 help
542 This option enables support for Palm LifeDrive's internal ATA
543 port via the new ATA layer.
544
545 If unsure, say N.
546
538config PATA_PCMCIA 547config PATA_PCMCIA
539 tristate "PCMCIA PATA support" 548 tristate "PCMCIA PATA support"
540 depends on PCMCIA 549 depends on PCMCIA
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 7f1ecf99528c..1558059874f0 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_PATA_MPC52xx) += pata_mpc52xx.o
50obj-$(CONFIG_PATA_MARVELL) += pata_marvell.o 50obj-$(CONFIG_PATA_MARVELL) += pata_marvell.o
51obj-$(CONFIG_PATA_MPIIX) += pata_mpiix.o 51obj-$(CONFIG_PATA_MPIIX) += pata_mpiix.o
52obj-$(CONFIG_PATA_OLDPIIX) += pata_oldpiix.o 52obj-$(CONFIG_PATA_OLDPIIX) += pata_oldpiix.o
53obj-$(CONFIG_PATA_PALMLD) += pata_palmld.o
53obj-$(CONFIG_PATA_PCMCIA) += pata_pcmcia.o 54obj-$(CONFIG_PATA_PCMCIA) += pata_pcmcia.o
54obj-$(CONFIG_PATA_PDC2027X) += pata_pdc2027x.o 55obj-$(CONFIG_PATA_PDC2027X) += pata_pdc2027x.o
55obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o 56obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 6273d98d00eb..ac176da1f94e 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -748,9 +748,9 @@ static int ata_acpi_run_tf(struct ata_device *dev,
748/** 748/**
749 * ata_acpi_exec_tfs - get then write drive taskfile settings 749 * ata_acpi_exec_tfs - get then write drive taskfile settings
750 * @dev: target ATA device 750 * @dev: target ATA device
751 * @nr_executed: out paramter for the number of executed commands 751 * @nr_executed: out parameter for the number of executed commands
752 * 752 *
753 * Evaluate _GTF and excute returned taskfiles. 753 * Evaluate _GTF and execute returned taskfiles.
754 * 754 *
755 * LOCKING: 755 * LOCKING:
756 * EH context. 756 * EH context.
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 94919ad03df1..fa22f94ca415 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2864,7 +2864,7 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2864/** 2864/**
2865 * ata_set_mode - Program timings and issue SET FEATURES - XFER 2865 * ata_set_mode - Program timings and issue SET FEATURES - XFER
2866 * @link: link on which timings will be programmed 2866 * @link: link on which timings will be programmed
2867 * @r_failed_dev: out paramter for failed device 2867 * @r_failed_dev: out parameter for failed device
2868 * 2868 *
2869 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If 2869 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If
2870 * ata_set_mode() fails, pointer to the failing device is 2870 * ata_set_mode() fails, pointer to the failing device is
diff --git a/drivers/ata/pata_palmld.c b/drivers/ata/pata_palmld.c
new file mode 100644
index 000000000000..11fb4ccc74b4
--- /dev/null
+++ b/drivers/ata/pata_palmld.c
@@ -0,0 +1,150 @@
1/*
2 * drivers/ata/pata_palmld.c
3 *
4 * Driver for IDE channel in Palm LifeDrive
5 *
6 * Based on research of:
7 * Alex Osborne <ato@meshy.org>
8 *
9 * Rewrite for mainline:
10 * Marek Vasut <marek.vasut@gmail.com>
11 *
12 * Rewritten version based on pata_ixp4xx_cf.c:
13 * ixp4xx PATA/Compact Flash driver
14 * Copyright (C) 2006-07 Tower Technologies
15 * Author: Alessandro Zummo <a.zummo@towertech.it>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License version 2 as
19 * published by the Free Software Foundation.
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/libata.h>
26#include <linux/irq.h>
27#include <linux/platform_device.h>
28#include <linux/delay.h>
29#include <linux/gpio.h>
30
31#include <scsi/scsi_host.h>
32#include <mach/palmld.h>
33
34#define DRV_NAME "pata_palmld"
35
36static struct scsi_host_template palmld_sht = {
37 ATA_PIO_SHT(DRV_NAME),
38};
39
40static struct ata_port_operations palmld_port_ops = {
41 .inherits = &ata_sff_port_ops,
42 .sff_data_xfer = ata_sff_data_xfer_noirq,
43 .cable_detect = ata_cable_40wire,
44};
45
46static __devinit int palmld_pata_probe(struct platform_device *pdev)
47{
48 struct ata_host *host;
49 struct ata_port *ap;
50 void __iomem *mem;
51 int ret;
52
53 /* allocate host */
54 host = ata_host_alloc(&pdev->dev, 1);
55 if (!host)
56 return -ENOMEM;
57
58 /* remap drive's physical memory address */
59 mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000);
60 if (!mem)
61 return -ENOMEM;
62
63 /* request and activate power GPIO, IRQ GPIO */
64 ret = gpio_request(GPIO_NR_PALMLD_IDE_PWEN, "HDD PWR");
65 if (ret)
66 goto err1;
67 ret = gpio_direction_output(GPIO_NR_PALMLD_IDE_PWEN, 1);
68 if (ret)
69 goto err2;
70
71 ret = gpio_request(GPIO_NR_PALMLD_IDE_RESET, "HDD RST");
72 if (ret)
73 goto err2;
74 ret = gpio_direction_output(GPIO_NR_PALMLD_IDE_RESET, 0);
75 if (ret)
76 goto err3;
77
78 /* reset the drive */
79 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0);
80 msleep(30);
81 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 1);
82 msleep(30);
83
84 /* setup the ata port */
85 ap = host->ports[0];
86 ap->ops = &palmld_port_ops;
87 ap->pio_mask = ATA_PIO4;
88 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_PIO_POLLING;
89
90 /* memory mapping voodoo */
91 ap->ioaddr.cmd_addr = mem + 0x10;
92 ap->ioaddr.altstatus_addr = mem + 0xe;
93 ap->ioaddr.ctl_addr = mem + 0xe;
94
95 /* start the port */
96 ata_sff_std_ports(&ap->ioaddr);
97
98 /* activate host */
99 return ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING,
100 &palmld_sht);
101
102err3:
103 gpio_free(GPIO_NR_PALMLD_IDE_RESET);
104err2:
105 gpio_free(GPIO_NR_PALMLD_IDE_PWEN);
106err1:
107 return ret;
108}
109
110static __devexit int palmld_pata_remove(struct platform_device *dev)
111{
112 struct ata_host *host = platform_get_drvdata(dev);
113
114 ata_host_detach(host);
115
116 /* power down the HDD */
117 gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0);
118
119 gpio_free(GPIO_NR_PALMLD_IDE_RESET);
120 gpio_free(GPIO_NR_PALMLD_IDE_PWEN);
121
122 return 0;
123}
124
125static struct platform_driver palmld_pata_platform_driver = {
126 .driver = {
127 .name = DRV_NAME,
128 .owner = THIS_MODULE,
129 },
130 .probe = palmld_pata_probe,
131 .remove = __devexit_p(palmld_pata_remove),
132};
133
134static int __init palmld_pata_init(void)
135{
136 return platform_driver_register(&palmld_pata_platform_driver);
137}
138
139static void __exit palmld_pata_exit(void)
140{
141 platform_driver_unregister(&palmld_pata_platform_driver);
142}
143
144MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
145MODULE_DESCRIPTION("PalmLD PATA driver");
146MODULE_LICENSE("GPL");
147MODULE_ALIAS("platform:" DRV_NAME);
148
149module_init(palmld_pata_init);
150module_exit(palmld_pata_exit);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index c6599618523e..4b04a15146d7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -279,7 +279,7 @@ static struct device *next_device(struct klist_iter *i)
279 * 279 *
280 * NOTE: The device that returns a non-zero value is not retained 280 * NOTE: The device that returns a non-zero value is not retained
281 * in any way, nor is its refcount incremented. If the caller needs 281 * in any way, nor is its refcount incremented. If the caller needs
282 * to retain this data, it should do, and increment the reference 282 * to retain this data, it should do so, and increment the reference
283 * count in the supplied callback. 283 * count in the supplied callback.
284 */ 284 */
285int bus_for_each_dev(struct bus_type *bus, struct device *start, 285int bus_for_each_dev(struct bus_type *bus, struct device *start,
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index ac5e05a98b2f..bb72ada9f074 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -112,7 +112,7 @@ config GDROM
112 with up to 1 GB of data. This drive will also read standard CD ROM 112 with up to 1 GB of data. This drive will also read standard CD ROM
113 disks. Select this option to access any disks in your GD ROM drive. 113 disks. Select this option to access any disks in your GD ROM drive.
114 Most users will want to say "Y" here. 114 Most users will want to say "Y" here.
115 You can also build this as a module which will be called gdrom.ko 115 You can also build this as a module which will be called gdrom.
116 116
117source "drivers/block/paride/Kconfig" 117source "drivers/block/paride/Kconfig"
118 118
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index b1e9652c0d9d..30bae6de6a0d 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -692,7 +692,7 @@ config HVCS
692 this driver. 692 this driver.
693 693
694 To compile this driver as a module, choose M here: the 694 To compile this driver as a module, choose M here: the
695 module will be called hvcs.ko. Additionally, this module 695 module will be called hvcs. Additionally, this module
696 will depend on arch specific APIs exported from hvcserver.ko 696 will depend on arch specific APIs exported from hvcserver.ko
697 which will also be compiled when this driver is built as a 697 which will also be compiled when this driver is built as a
698 module. 698 module.
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index fd3ebd1be570..72429b6b2fa8 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -779,7 +779,7 @@ static void change_speed(struct async_struct *info,
779 info->IER |= UART_IER_MSI; 779 info->IER |= UART_IER_MSI;
780 } 780 }
781 /* TBD: 781 /* TBD:
782 * Does clearing IER_MSI imply that we should disbale the VBL interrupt ? 782 * Does clearing IER_MSI imply that we should disable the VBL interrupt ?
783 */ 783 */
784 784
785 /* 785 /*
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 5fab6470f4b2..f4b3f7293feb 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -88,7 +88,7 @@ config HW_RANDOM_N2RNG
88 88
89config HW_RANDOM_VIA 89config HW_RANDOM_VIA
90 tristate "VIA HW Random Number Generator support" 90 tristate "VIA HW Random Number Generator support"
91 depends on HW_RANDOM && X86_32 91 depends on HW_RANDOM && X86
92 default HW_RANDOM 92 default HW_RANDOM
93 ---help--- 93 ---help---
94 This driver provides kernel-side support for the Random Number 94 This driver provides kernel-side support for the Random Number
@@ -148,3 +148,15 @@ config HW_RANDOM_VIRTIO
148 148
149 To compile this driver as a module, choose M here: the 149 To compile this driver as a module, choose M here: the
150 module will be called virtio-rng. If unsure, say N. 150 module will be called virtio-rng. If unsure, say N.
151
152config HW_RANDOM_MXC_RNGA
153 tristate "Freescale i.MX RNGA Random Number Generator"
154 depends on HW_RANDOM && ARCH_HAS_RNGA
155 ---help---
156 This driver provides kernel-side support for the Random Number
157 Generator hardware found on Freescale i.MX processors.
158
159 To compile this driver as a module, choose M here: the
160 module will be called mxc-rnga.
161
162 If unsure, say Y.
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index e81d21a5f28f..fd1ecd2f6731 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o
15obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o 15obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o
16obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o 16obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o
17obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o 17obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o
18obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o
diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c
new file mode 100644
index 000000000000..187c6be80f43
--- /dev/null
+++ b/drivers/char/hw_random/mxc-rnga.c
@@ -0,0 +1,247 @@
1/*
2 * RNG driver for Freescale RNGA
3 *
4 * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
5 * Author: Alan Carvalho de Assis <acassis@gmail.com>
6 */
7
8/*
9 * The code contained herein is licensed under the GNU General Public
10 * License. You may obtain a copy of the GNU General Public License
11 * Version 2 or later at the following locations:
12 *
13 * http://www.opensource.org/licenses/gpl-license.html
14 * http://www.gnu.org/copyleft/gpl.html
15 *
16 * This driver is based on other RNG drivers.
17 */
18
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/clk.h>
23#include <linux/err.h>
24#include <linux/ioport.h>
25#include <linux/platform_device.h>
26#include <linux/hw_random.h>
27#include <linux/io.h>
28
29/* RNGA Registers */
30#define RNGA_CONTROL 0x00
31#define RNGA_STATUS 0x04
32#define RNGA_ENTROPY 0x08
33#define RNGA_OUTPUT_FIFO 0x0c
34#define RNGA_MODE 0x10
35#define RNGA_VERIFICATION_CONTROL 0x14
36#define RNGA_OSC_CONTROL_COUNTER 0x18
37#define RNGA_OSC1_COUNTER 0x1c
38#define RNGA_OSC2_COUNTER 0x20
39#define RNGA_OSC_COUNTER_STATUS 0x24
40
41/* RNGA Registers Range */
42#define RNG_ADDR_RANGE 0x28
43
44/* RNGA Control Register */
45#define RNGA_CONTROL_SLEEP 0x00000010
46#define RNGA_CONTROL_CLEAR_INT 0x00000008
47#define RNGA_CONTROL_MASK_INTS 0x00000004
48#define RNGA_CONTROL_HIGH_ASSURANCE 0x00000002
49#define RNGA_CONTROL_GO 0x00000001
50
51#define RNGA_STATUS_LEVEL_MASK 0x0000ff00
52
53/* RNGA Status Register */
54#define RNGA_STATUS_OSC_DEAD 0x80000000
55#define RNGA_STATUS_SLEEP 0x00000010
56#define RNGA_STATUS_ERROR_INT 0x00000008
57#define RNGA_STATUS_FIFO_UNDERFLOW 0x00000004
58#define RNGA_STATUS_LAST_READ_STATUS 0x00000002
59#define RNGA_STATUS_SECURITY_VIOLATION 0x00000001
60
61static struct platform_device *rng_dev;
62
63static int mxc_rnga_data_present(struct hwrng *rng)
64{
65 int level;
66 void __iomem *rng_base = (void __iomem *)rng->priv;
67
68 /* how many random numbers is in FIFO? [0-16] */
69 level = ((__raw_readl(rng_base + RNGA_STATUS) &
70 RNGA_STATUS_LEVEL_MASK) >> 8);
71
72 return level > 0 ? 1 : 0;
73}
74
75static int mxc_rnga_data_read(struct hwrng *rng, u32 * data)
76{
77 int err;
78 u32 ctrl;
79 void __iomem *rng_base = (void __iomem *)rng->priv;
80
81 /* retrieve a random number from FIFO */
82 *data = __raw_readl(rng_base + RNGA_OUTPUT_FIFO);
83
84 /* some error while reading this random number? */
85 err = __raw_readl(rng_base + RNGA_STATUS) & RNGA_STATUS_ERROR_INT;
86
87 /* if error: clear error interrupt, but doesn't return random number */
88 if (err) {
89 dev_dbg(&rng_dev->dev, "Error while reading random number!\n");
90 ctrl = __raw_readl(rng_base + RNGA_CONTROL);
91 __raw_writel(ctrl | RNGA_CONTROL_CLEAR_INT,
92 rng_base + RNGA_CONTROL);
93 return 0;
94 } else
95 return 4;
96}
97
98static int mxc_rnga_init(struct hwrng *rng)
99{
100 u32 ctrl, osc;
101 void __iomem *rng_base = (void __iomem *)rng->priv;
102
103 /* wake up */
104 ctrl = __raw_readl(rng_base + RNGA_CONTROL);
105 __raw_writel(ctrl & ~RNGA_CONTROL_SLEEP, rng_base + RNGA_CONTROL);
106
107 /* verify if oscillator is working */
108 osc = __raw_readl(rng_base + RNGA_STATUS);
109 if (osc & RNGA_STATUS_OSC_DEAD) {
110 dev_err(&rng_dev->dev, "RNGA Oscillator is dead!\n");
111 return -ENODEV;
112 }
113
114 /* go running */
115 ctrl = __raw_readl(rng_base + RNGA_CONTROL);
116 __raw_writel(ctrl | RNGA_CONTROL_GO, rng_base + RNGA_CONTROL);
117
118 return 0;
119}
120
121static void mxc_rnga_cleanup(struct hwrng *rng)
122{
123 u32 ctrl;
124 void __iomem *rng_base = (void __iomem *)rng->priv;
125
126 ctrl = __raw_readl(rng_base + RNGA_CONTROL);
127
128 /* stop rnga */
129 __raw_writel(ctrl & ~RNGA_CONTROL_GO, rng_base + RNGA_CONTROL);
130}
131
132static struct hwrng mxc_rnga = {
133 .name = "mxc-rnga",
134 .init = mxc_rnga_init,
135 .cleanup = mxc_rnga_cleanup,
136 .data_present = mxc_rnga_data_present,
137 .data_read = mxc_rnga_data_read
138};
139
140static int __init mxc_rnga_probe(struct platform_device *pdev)
141{
142 int err = -ENODEV;
143 struct clk *clk;
144 struct resource *res, *mem;
145 void __iomem *rng_base = NULL;
146
147 if (rng_dev)
148 return -EBUSY;
149
150 clk = clk_get(&pdev->dev, "rng");
151 if (IS_ERR(clk)) {
152 dev_err(&pdev->dev, "Could not get rng_clk!\n");
153 err = PTR_ERR(clk);
154 goto out;
155 }
156
157 clk_enable(clk);
158
159 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
160 if (!res) {
161 err = -ENOENT;
162 goto err_region;
163 }
164
165 mem = request_mem_region(res->start, resource_size(res), pdev->name);
166 if (mem == NULL) {
167 err = -EBUSY;
168 goto err_region;
169 }
170
171 rng_base = ioremap(res->start, resource_size(res));
172 if (!rng_base) {
173 err = -ENOMEM;
174 goto err_ioremap;
175 }
176
177 mxc_rnga.priv = (unsigned long)rng_base;
178
179 err = hwrng_register(&mxc_rnga);
180 if (err) {
181 dev_err(&pdev->dev, "MXC RNGA registering failed (%d)\n", err);
182 goto err_register;
183 }
184
185 rng_dev = pdev;
186
187 dev_info(&pdev->dev, "MXC RNGA Registered.\n");
188
189 return 0;
190
191err_register:
192 iounmap(rng_base);
193 rng_base = NULL;
194
195err_ioremap:
196 release_mem_region(res->start, resource_size(res));
197
198err_region:
199 clk_disable(clk);
200 clk_put(clk);
201
202out:
203 return err;
204}
205
206static int __exit mxc_rnga_remove(struct platform_device *pdev)
207{
208 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
209 void __iomem *rng_base = (void __iomem *)mxc_rnga.priv;
210 struct clk *clk = clk_get(&pdev->dev, "rng");
211
212 hwrng_unregister(&mxc_rnga);
213
214 iounmap(rng_base);
215
216 release_mem_region(res->start, resource_size(res));
217
218 clk_disable(clk);
219 clk_put(clk);
220
221 return 0;
222}
223
224static struct platform_driver mxc_rnga_driver = {
225 .driver = {
226 .name = "mxc_rnga",
227 .owner = THIS_MODULE,
228 },
229 .remove = __exit_p(mxc_rnga_remove),
230};
231
232static int __init mod_init(void)
233{
234 return platform_driver_probe(&mxc_rnga_driver, mxc_rnga_probe);
235}
236
237static void __exit mod_exit(void)
238{
239 platform_driver_unregister(&mxc_rnga_driver);
240}
241
242module_init(mod_init);
243module_exit(mod_exit);
244
245MODULE_AUTHOR("Freescale Semiconductor, Inc.");
246MODULE_DESCRIPTION("H/W RNGA driver for i.MX");
247MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index 538313f9e7ac..00dd3de1be51 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -89,7 +89,7 @@ static struct hwrng omap_rng_ops = {
89 .data_read = omap_rng_data_read, 89 .data_read = omap_rng_data_read,
90}; 90};
91 91
92static int __init omap_rng_probe(struct platform_device *pdev) 92static int __devinit omap_rng_probe(struct platform_device *pdev)
93{ 93{
94 struct resource *res, *mem; 94 struct resource *res, *mem;
95 int ret; 95 int ret;
diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c
index dcd352ad0e7f..a94e930575f2 100644
--- a/drivers/char/hw_random/timeriomem-rng.c
+++ b/drivers/char/hw_random/timeriomem-rng.c
@@ -88,9 +88,9 @@ static struct hwrng timeriomem_rng_ops = {
88 .priv = 0, 88 .priv = 0,
89}; 89};
90 90
91static int __init timeriomem_rng_probe(struct platform_device *pdev) 91static int __devinit timeriomem_rng_probe(struct platform_device *pdev)
92{ 92{
93 struct resource *res, *mem; 93 struct resource *res;
94 int ret; 94 int ret;
95 95
96 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 96 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -98,21 +98,12 @@ static int __init timeriomem_rng_probe(struct platform_device *pdev)
98 if (!res) 98 if (!res)
99 return -ENOENT; 99 return -ENOENT;
100 100
101 mem = request_mem_region(res->start, res->end - res->start + 1,
102 pdev->name);
103 if (mem == NULL)
104 return -EBUSY;
105
106 dev_set_drvdata(&pdev->dev, mem);
107
108 timeriomem_rng_data = pdev->dev.platform_data; 101 timeriomem_rng_data = pdev->dev.platform_data;
109 102
110 timeriomem_rng_data->address = ioremap(res->start, 103 timeriomem_rng_data->address = ioremap(res->start,
111 res->end - res->start + 1); 104 res->end - res->start + 1);
112 if (!timeriomem_rng_data->address) { 105 if (!timeriomem_rng_data->address)
113 ret = -ENOMEM; 106 return -EIO;
114 goto err_ioremap;
115 }
116 107
117 if (timeriomem_rng_data->period != 0 108 if (timeriomem_rng_data->period != 0
118 && usecs_to_jiffies(timeriomem_rng_data->period) > 0) { 109 && usecs_to_jiffies(timeriomem_rng_data->period) > 0) {
@@ -125,7 +116,7 @@ static int __init timeriomem_rng_probe(struct platform_device *pdev)
125 116
126 ret = hwrng_register(&timeriomem_rng_ops); 117 ret = hwrng_register(&timeriomem_rng_ops);
127 if (ret) 118 if (ret)
128 goto err_register; 119 goto failed;
129 120
130 dev_info(&pdev->dev, "32bits from 0x%p @ %dus\n", 121 dev_info(&pdev->dev, "32bits from 0x%p @ %dus\n",
131 timeriomem_rng_data->address, 122 timeriomem_rng_data->address,
@@ -133,24 +124,19 @@ static int __init timeriomem_rng_probe(struct platform_device *pdev)
133 124
134 return 0; 125 return 0;
135 126
136err_register: 127failed:
137 dev_err(&pdev->dev, "problem registering\n"); 128 dev_err(&pdev->dev, "problem registering\n");
138 iounmap(timeriomem_rng_data->address); 129 iounmap(timeriomem_rng_data->address);
139err_ioremap:
140 release_resource(mem);
141 130
142 return ret; 131 return ret;
143} 132}
144 133
145static int __devexit timeriomem_rng_remove(struct platform_device *pdev) 134static int __devexit timeriomem_rng_remove(struct platform_device *pdev)
146{ 135{
147 struct resource *mem = dev_get_drvdata(&pdev->dev);
148
149 del_timer_sync(&timeriomem_rng_timer); 136 del_timer_sync(&timeriomem_rng_timer);
150 hwrng_unregister(&timeriomem_rng_ops); 137 hwrng_unregister(&timeriomem_rng_ops);
151 138
152 iounmap(timeriomem_rng_data->address); 139 iounmap(timeriomem_rng_data->address);
153 release_resource(mem);
154 140
155 return 0; 141 return 0;
156} 142}
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index 4e9573c1d39e..794aacb715c1 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -132,6 +132,19 @@ static int via_rng_init(struct hwrng *rng)
132 struct cpuinfo_x86 *c = &cpu_data(0); 132 struct cpuinfo_x86 *c = &cpu_data(0);
133 u32 lo, hi, old_lo; 133 u32 lo, hi, old_lo;
134 134
135 /* VIA Nano CPUs don't have the MSR_VIA_RNG anymore. The RNG
136 * is always enabled if CPUID rng_en is set. There is no
137 * RNG configuration like it used to be the case in this
138 * register */
139 if ((c->x86 == 6) && (c->x86_model >= 0x0f)) {
140 if (!cpu_has_xstore_enabled) {
141 printk(KERN_ERR PFX "can't enable hardware RNG "
142 "if XSTORE is not enabled\n");
143 return -ENODEV;
144 }
145 return 0;
146 }
147
135 /* Control the RNG via MSR. Tread lightly and pay very close 148 /* Control the RNG via MSR. Tread lightly and pay very close
136 * close attention to values written, as the reserved fields 149 * close attention to values written, as the reserved fields
137 * are documented to be "undefined and unpredictable"; but it 150 * are documented to be "undefined and unpredictable"; but it
@@ -205,5 +218,5 @@ static void __exit mod_exit(void)
205module_init(mod_init); 218module_init(mod_init);
206module_exit(mod_exit); 219module_exit(mod_exit);
207 220
208MODULE_DESCRIPTION("H/W RNG driver for VIA chipsets"); 221MODULE_DESCRIPTION("H/W RNG driver for VIA CPU with PadLock");
209MODULE_LICENSE("GPL"); 222MODULE_LICENSE("GPL");
diff --git a/drivers/connector/Kconfig b/drivers/connector/Kconfig
index 100bfd422066..6e6730f9dfd1 100644
--- a/drivers/connector/Kconfig
+++ b/drivers/connector/Kconfig
@@ -7,7 +7,7 @@ menuconfig CONNECTOR
7 of the netlink socket protocol. 7 of the netlink socket protocol.
8 8
9 Connector support can also be built as a module. If so, the module 9 Connector support can also be built as a module. If so, the module
10 will be called cn.ko. 10 will be called cn.
11 11
12if CONNECTOR 12if CONNECTOR
13 13
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 01afd758072f..5b27692372bf 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -12,7 +12,7 @@ if CRYPTO_HW
12 12
13config CRYPTO_DEV_PADLOCK 13config CRYPTO_DEV_PADLOCK
14 tristate "Support for VIA PadLock ACE" 14 tristate "Support for VIA PadLock ACE"
15 depends on X86_32 && !UML 15 depends on X86 && !UML
16 select CRYPTO_ALGAPI 16 select CRYPTO_ALGAPI
17 help 17 help
18 Some VIA processors come with an integrated crypto engine 18 Some VIA processors come with an integrated crypto engine
@@ -34,7 +34,7 @@ config CRYPTO_DEV_PADLOCK_AES
34 Available in VIA C3 and newer CPUs. 34 Available in VIA C3 and newer CPUs.
35 35
36 If unsure say M. The compiled module will be 36 If unsure say M. The compiled module will be
37 called padlock-aes.ko 37 called padlock-aes.
38 38
39config CRYPTO_DEV_PADLOCK_SHA 39config CRYPTO_DEV_PADLOCK_SHA
40 tristate "PadLock driver for SHA1 and SHA256 algorithms" 40 tristate "PadLock driver for SHA1 and SHA256 algorithms"
@@ -47,7 +47,7 @@ config CRYPTO_DEV_PADLOCK_SHA
47 Available in VIA C7 and newer processors. 47 Available in VIA C7 and newer processors.
48 48
49 If unsure say M. The compiled module will be 49 If unsure say M. The compiled module will be
50 called padlock-sha.ko 50 called padlock-sha.
51 51
52config CRYPTO_DEV_GEODE 52config CRYPTO_DEV_GEODE
53 tristate "Support for the Geode LX AES engine" 53 tristate "Support for the Geode LX AES engine"
@@ -79,7 +79,7 @@ config ZCRYPT_MONOLITHIC
79 bool "Monolithic zcrypt module" 79 bool "Monolithic zcrypt module"
80 depends on ZCRYPT="m" 80 depends on ZCRYPT="m"
81 help 81 help
82 Select this option if you want to have a single module z90crypt.ko 82 Select this option if you want to have a single module z90crypt,
83 that contains all parts of the crypto device driver (ap bus, 83 that contains all parts of the crypto device driver (ap bus,
84 request router and all the card drivers). 84 request router and all the card drivers).
85 85
diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 2bef086fb342..5f753fc08730 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -2564,7 +2564,7 @@ static void hifn_tasklet_callback(unsigned long data)
2564 hifn_process_queue(dev); 2564 hifn_process_queue(dev);
2565} 2565}
2566 2566
2567static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id) 2567static int __devinit hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2568{ 2568{
2569 int err, i; 2569 int err, i;
2570 struct hifn_device *dev; 2570 struct hifn_device *dev;
@@ -2696,7 +2696,7 @@ err_out_disable_pci_device:
2696 return err; 2696 return err;
2697} 2697}
2698 2698
2699static void hifn_remove(struct pci_dev *pdev) 2699static void __devexit hifn_remove(struct pci_dev *pdev)
2700{ 2700{
2701 int i; 2701 int i;
2702 struct hifn_device *dev; 2702 struct hifn_device *dev;
@@ -2744,7 +2744,7 @@ static struct pci_driver hifn_pci_driver = {
2744 .remove = __devexit_p(hifn_remove), 2744 .remove = __devexit_p(hifn_remove),
2745}; 2745};
2746 2746
2747static int __devinit hifn_init(void) 2747static int __init hifn_init(void)
2748{ 2748{
2749 unsigned int freq; 2749 unsigned int freq;
2750 int err; 2750 int err;
@@ -2789,7 +2789,7 @@ static int __devinit hifn_init(void)
2789 return 0; 2789 return 0;
2790} 2790}
2791 2791
2792static void __devexit hifn_fini(void) 2792static void __exit hifn_fini(void)
2793{ 2793{
2794 pci_unregister_driver(&hifn_pci_driver); 2794 pci_unregister_driver(&hifn_pci_driver);
2795 2795
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 856b3cc25583..87f92c39b5f0 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -154,7 +154,11 @@ static inline void padlock_reset_key(struct cword *cword)
154 int cpu = raw_smp_processor_id(); 154 int cpu = raw_smp_processor_id();
155 155
156 if (cword != per_cpu(last_cword, cpu)) 156 if (cword != per_cpu(last_cword, cpu))
157#ifndef CONFIG_X86_64
157 asm volatile ("pushfl; popfl"); 158 asm volatile ("pushfl; popfl");
159#else
160 asm volatile ("pushfq; popfq");
161#endif
158} 162}
159 163
160static inline void padlock_store_cword(struct cword *cword) 164static inline void padlock_store_cword(struct cword *cword)
@@ -208,10 +212,19 @@ static inline void padlock_xcrypt_ecb(const u8 *input, u8 *output, void *key,
208 212
209 asm volatile ("test $1, %%cl;" 213 asm volatile ("test $1, %%cl;"
210 "je 1f;" 214 "je 1f;"
215#ifndef CONFIG_X86_64
211 "lea -1(%%ecx), %%eax;" 216 "lea -1(%%ecx), %%eax;"
212 "mov $1, %%ecx;" 217 "mov $1, %%ecx;"
218#else
219 "lea -1(%%rcx), %%rax;"
220 "mov $1, %%rcx;"
221#endif
213 ".byte 0xf3,0x0f,0xa7,0xc8;" /* rep xcryptecb */ 222 ".byte 0xf3,0x0f,0xa7,0xc8;" /* rep xcryptecb */
223#ifndef CONFIG_X86_64
214 "mov %%eax, %%ecx;" 224 "mov %%eax, %%ecx;"
225#else
226 "mov %%rax, %%rcx;"
227#endif
215 "1:" 228 "1:"
216 ".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */ 229 ".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */
217 : "+S"(input), "+D"(output) 230 : "+S"(input), "+D"(output)
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index a3918c16b3db..c70775fd3ce2 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -44,6 +44,8 @@
44#include <crypto/sha.h> 44#include <crypto/sha.h>
45#include <crypto/aead.h> 45#include <crypto/aead.h>
46#include <crypto/authenc.h> 46#include <crypto/authenc.h>
47#include <crypto/skcipher.h>
48#include <crypto/scatterwalk.h>
47 49
48#include "talitos.h" 50#include "talitos.h"
49 51
@@ -339,7 +341,8 @@ static void flush_channel(struct device *dev, int ch, int error, int reset_ch)
339 status = error; 341 status = error;
340 342
341 dma_unmap_single(dev, request->dma_desc, 343 dma_unmap_single(dev, request->dma_desc,
342 sizeof(struct talitos_desc), DMA_BIDIRECTIONAL); 344 sizeof(struct talitos_desc),
345 DMA_BIDIRECTIONAL);
343 346
344 /* copy entries so we can call callback outside lock */ 347 /* copy entries so we can call callback outside lock */
345 saved_req.desc = request->desc; 348 saved_req.desc = request->desc;
@@ -413,7 +416,8 @@ static struct talitos_desc *current_desc(struct device *dev, int ch)
413/* 416/*
414 * user diagnostics; report root cause of error based on execution unit status 417 * user diagnostics; report root cause of error based on execution unit status
415 */ 418 */
416static void report_eu_error(struct device *dev, int ch, struct talitos_desc *desc) 419static void report_eu_error(struct device *dev, int ch,
420 struct talitos_desc *desc)
417{ 421{
418 struct talitos_private *priv = dev_get_drvdata(dev); 422 struct talitos_private *priv = dev_get_drvdata(dev);
419 int i; 423 int i;
@@ -684,8 +688,8 @@ struct talitos_ctx {
684 unsigned int authsize; 688 unsigned int authsize;
685}; 689};
686 690
687static int aead_authenc_setauthsize(struct crypto_aead *authenc, 691static int aead_setauthsize(struct crypto_aead *authenc,
688 unsigned int authsize) 692 unsigned int authsize)
689{ 693{
690 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 694 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
691 695
@@ -694,8 +698,8 @@ static int aead_authenc_setauthsize(struct crypto_aead *authenc,
694 return 0; 698 return 0;
695} 699}
696 700
697static int aead_authenc_setkey(struct crypto_aead *authenc, 701static int aead_setkey(struct crypto_aead *authenc,
698 const u8 *key, unsigned int keylen) 702 const u8 *key, unsigned int keylen)
699{ 703{
700 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 704 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
701 struct rtattr *rta = (void *)key; 705 struct rtattr *rta = (void *)key;
@@ -740,7 +744,7 @@ badkey:
740} 744}
741 745
742/* 746/*
743 * ipsec_esp_edesc - s/w-extended ipsec_esp descriptor 747 * talitos_edesc - s/w-extended descriptor
744 * @src_nents: number of segments in input scatterlist 748 * @src_nents: number of segments in input scatterlist
745 * @dst_nents: number of segments in output scatterlist 749 * @dst_nents: number of segments in output scatterlist
746 * @dma_len: length of dma mapped link_tbl space 750 * @dma_len: length of dma mapped link_tbl space
@@ -752,17 +756,67 @@ badkey:
752 * is greater than 1, an integrity check value is concatenated to the end 756 * is greater than 1, an integrity check value is concatenated to the end
753 * of link_tbl data 757 * of link_tbl data
754 */ 758 */
755struct ipsec_esp_edesc { 759struct talitos_edesc {
756 int src_nents; 760 int src_nents;
757 int dst_nents; 761 int dst_nents;
762 int src_is_chained;
763 int dst_is_chained;
758 int dma_len; 764 int dma_len;
759 dma_addr_t dma_link_tbl; 765 dma_addr_t dma_link_tbl;
760 struct talitos_desc desc; 766 struct talitos_desc desc;
761 struct talitos_ptr link_tbl[0]; 767 struct talitos_ptr link_tbl[0];
762}; 768};
763 769
770static int talitos_map_sg(struct device *dev, struct scatterlist *sg,
771 unsigned int nents, enum dma_data_direction dir,
772 int chained)
773{
774 if (unlikely(chained))
775 while (sg) {
776 dma_map_sg(dev, sg, 1, dir);
777 sg = scatterwalk_sg_next(sg);
778 }
779 else
780 dma_map_sg(dev, sg, nents, dir);
781 return nents;
782}
783
784static void talitos_unmap_sg_chain(struct device *dev, struct scatterlist *sg,
785 enum dma_data_direction dir)
786{
787 while (sg) {
788 dma_unmap_sg(dev, sg, 1, dir);
789 sg = scatterwalk_sg_next(sg);
790 }
791}
792
793static void talitos_sg_unmap(struct device *dev,
794 struct talitos_edesc *edesc,
795 struct scatterlist *src,
796 struct scatterlist *dst)
797{
798 unsigned int src_nents = edesc->src_nents ? : 1;
799 unsigned int dst_nents = edesc->dst_nents ? : 1;
800
801 if (src != dst) {
802 if (edesc->src_is_chained)
803 talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE);
804 else
805 dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE);
806
807 if (edesc->dst_is_chained)
808 talitos_unmap_sg_chain(dev, dst, DMA_FROM_DEVICE);
809 else
810 dma_unmap_sg(dev, dst, dst_nents, DMA_FROM_DEVICE);
811 } else
812 if (edesc->src_is_chained)
813 talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL);
814 else
815 dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL);
816}
817
764static void ipsec_esp_unmap(struct device *dev, 818static void ipsec_esp_unmap(struct device *dev,
765 struct ipsec_esp_edesc *edesc, 819 struct talitos_edesc *edesc,
766 struct aead_request *areq) 820 struct aead_request *areq)
767{ 821{
768 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[6], DMA_FROM_DEVICE); 822 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[6], DMA_FROM_DEVICE);
@@ -772,15 +826,7 @@ static void ipsec_esp_unmap(struct device *dev,
772 826
773 dma_unmap_sg(dev, areq->assoc, 1, DMA_TO_DEVICE); 827 dma_unmap_sg(dev, areq->assoc, 1, DMA_TO_DEVICE);
774 828
775 if (areq->src != areq->dst) { 829 talitos_sg_unmap(dev, edesc, areq->src, areq->dst);
776 dma_unmap_sg(dev, areq->src, edesc->src_nents ? : 1,
777 DMA_TO_DEVICE);
778 dma_unmap_sg(dev, areq->dst, edesc->dst_nents ? : 1,
779 DMA_FROM_DEVICE);
780 } else {
781 dma_unmap_sg(dev, areq->src, edesc->src_nents ? : 1,
782 DMA_BIDIRECTIONAL);
783 }
784 830
785 if (edesc->dma_len) 831 if (edesc->dma_len)
786 dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len, 832 dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len,
@@ -795,13 +841,14 @@ static void ipsec_esp_encrypt_done(struct device *dev,
795 int err) 841 int err)
796{ 842{
797 struct aead_request *areq = context; 843 struct aead_request *areq = context;
798 struct ipsec_esp_edesc *edesc =
799 container_of(desc, struct ipsec_esp_edesc, desc);
800 struct crypto_aead *authenc = crypto_aead_reqtfm(areq); 844 struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
801 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 845 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
846 struct talitos_edesc *edesc;
802 struct scatterlist *sg; 847 struct scatterlist *sg;
803 void *icvdata; 848 void *icvdata;
804 849
850 edesc = container_of(desc, struct talitos_edesc, desc);
851
805 ipsec_esp_unmap(dev, edesc, areq); 852 ipsec_esp_unmap(dev, edesc, areq);
806 853
807 /* copy the generated ICV to dst */ 854 /* copy the generated ICV to dst */
@@ -819,17 +866,18 @@ static void ipsec_esp_encrypt_done(struct device *dev,
819} 866}
820 867
821static void ipsec_esp_decrypt_swauth_done(struct device *dev, 868static void ipsec_esp_decrypt_swauth_done(struct device *dev,
822 struct talitos_desc *desc, void *context, 869 struct talitos_desc *desc,
823 int err) 870 void *context, int err)
824{ 871{
825 struct aead_request *req = context; 872 struct aead_request *req = context;
826 struct ipsec_esp_edesc *edesc =
827 container_of(desc, struct ipsec_esp_edesc, desc);
828 struct crypto_aead *authenc = crypto_aead_reqtfm(req); 873 struct crypto_aead *authenc = crypto_aead_reqtfm(req);
829 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 874 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
875 struct talitos_edesc *edesc;
830 struct scatterlist *sg; 876 struct scatterlist *sg;
831 void *icvdata; 877 void *icvdata;
832 878
879 edesc = container_of(desc, struct talitos_edesc, desc);
880
833 ipsec_esp_unmap(dev, edesc, req); 881 ipsec_esp_unmap(dev, edesc, req);
834 882
835 if (!err) { 883 if (!err) {
@@ -851,20 +899,20 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,
851} 899}
852 900
853static void ipsec_esp_decrypt_hwauth_done(struct device *dev, 901static void ipsec_esp_decrypt_hwauth_done(struct device *dev,
854 struct talitos_desc *desc, void *context, 902 struct talitos_desc *desc,
855 int err) 903 void *context, int err)
856{ 904{
857 struct aead_request *req = context; 905 struct aead_request *req = context;
858 struct ipsec_esp_edesc *edesc = 906 struct talitos_edesc *edesc;
859 container_of(desc, struct ipsec_esp_edesc, desc); 907
908 edesc = container_of(desc, struct talitos_edesc, desc);
860 909
861 ipsec_esp_unmap(dev, edesc, req); 910 ipsec_esp_unmap(dev, edesc, req);
862 911
863 /* check ICV auth status */ 912 /* check ICV auth status */
864 if (!err) 913 if (!err && ((desc->hdr_lo & DESC_HDR_LO_ICCR1_MASK) !=
865 if ((desc->hdr_lo & DESC_HDR_LO_ICCR1_MASK) != 914 DESC_HDR_LO_ICCR1_PASS))
866 DESC_HDR_LO_ICCR1_PASS) 915 err = -EBADMSG;
867 err = -EBADMSG;
868 916
869 kfree(edesc); 917 kfree(edesc);
870 918
@@ -886,7 +934,7 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
886 link_tbl_ptr->j_extent = 0; 934 link_tbl_ptr->j_extent = 0;
887 link_tbl_ptr++; 935 link_tbl_ptr++;
888 cryptlen -= sg_dma_len(sg); 936 cryptlen -= sg_dma_len(sg);
889 sg = sg_next(sg); 937 sg = scatterwalk_sg_next(sg);
890 } 938 }
891 939
892 /* adjust (decrease) last one (or two) entry's len to cryptlen */ 940 /* adjust (decrease) last one (or two) entry's len to cryptlen */
@@ -910,7 +958,7 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
910/* 958/*
911 * fill in and submit ipsec_esp descriptor 959 * fill in and submit ipsec_esp descriptor
912 */ 960 */
913static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq, 961static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
914 u8 *giv, u64 seq, 962 u8 *giv, u64 seq,
915 void (*callback) (struct device *dev, 963 void (*callback) (struct device *dev,
916 struct talitos_desc *desc, 964 struct talitos_desc *desc,
@@ -952,32 +1000,31 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
952 desc->ptr[4].len = cpu_to_be16(cryptlen); 1000 desc->ptr[4].len = cpu_to_be16(cryptlen);
953 desc->ptr[4].j_extent = authsize; 1001 desc->ptr[4].j_extent = authsize;
954 1002
955 if (areq->src == areq->dst) 1003 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
956 sg_count = dma_map_sg(dev, areq->src, edesc->src_nents ? : 1, 1004 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
957 DMA_BIDIRECTIONAL); 1005 : DMA_TO_DEVICE,
958 else 1006 edesc->src_is_chained);
959 sg_count = dma_map_sg(dev, areq->src, edesc->src_nents ? : 1,
960 DMA_TO_DEVICE);
961 1007
962 if (sg_count == 1) { 1008 if (sg_count == 1) {
963 desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->src)); 1009 desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->src));
964 } else { 1010 } else {
965 sg_link_tbl_len = cryptlen; 1011 sg_link_tbl_len = cryptlen;
966 1012
967 if ((edesc->desc.hdr & DESC_HDR_MODE1_MDEU_CICV) && 1013 if (edesc->desc.hdr & DESC_HDR_MODE1_MDEU_CICV)
968 (edesc->desc.hdr & DESC_HDR_MODE0_ENCRYPT) == 0) {
969 sg_link_tbl_len = cryptlen + authsize; 1014 sg_link_tbl_len = cryptlen + authsize;
970 } 1015
971 sg_count = sg_to_link_tbl(areq->src, sg_count, sg_link_tbl_len, 1016 sg_count = sg_to_link_tbl(areq->src, sg_count, sg_link_tbl_len,
972 &edesc->link_tbl[0]); 1017 &edesc->link_tbl[0]);
973 if (sg_count > 1) { 1018 if (sg_count > 1) {
974 desc->ptr[4].j_extent |= DESC_PTR_LNKTBL_JUMP; 1019 desc->ptr[4].j_extent |= DESC_PTR_LNKTBL_JUMP;
975 desc->ptr[4].ptr = cpu_to_be32(edesc->dma_link_tbl); 1020 desc->ptr[4].ptr = cpu_to_be32(edesc->dma_link_tbl);
976 dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl, 1021 dma_sync_single_for_device(dev, edesc->dma_link_tbl,
977 edesc->dma_len, DMA_BIDIRECTIONAL); 1022 edesc->dma_len,
1023 DMA_BIDIRECTIONAL);
978 } else { 1024 } else {
979 /* Only one segment now, so no link tbl needed */ 1025 /* Only one segment now, so no link tbl needed */
980 desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->src)); 1026 desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->
1027 src));
981 } 1028 }
982 } 1029 }
983 1030
@@ -985,10 +1032,11 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
985 desc->ptr[5].len = cpu_to_be16(cryptlen); 1032 desc->ptr[5].len = cpu_to_be16(cryptlen);
986 desc->ptr[5].j_extent = authsize; 1033 desc->ptr[5].j_extent = authsize;
987 1034
988 if (areq->src != areq->dst) { 1035 if (areq->src != areq->dst)
989 sg_count = dma_map_sg(dev, areq->dst, edesc->dst_nents ? : 1, 1036 sg_count = talitos_map_sg(dev, areq->dst,
990 DMA_FROM_DEVICE); 1037 edesc->dst_nents ? : 1,
991 } 1038 DMA_FROM_DEVICE,
1039 edesc->dst_is_chained);
992 1040
993 if (sg_count == 1) { 1041 if (sg_count == 1) {
994 desc->ptr[5].ptr = cpu_to_be32(sg_dma_address(areq->dst)); 1042 desc->ptr[5].ptr = cpu_to_be32(sg_dma_address(areq->dst));
@@ -1033,49 +1081,55 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
1033 return ret; 1081 return ret;
1034} 1082}
1035 1083
1036
1037/* 1084/*
1038 * derive number of elements in scatterlist 1085 * derive number of elements in scatterlist
1039 */ 1086 */
1040static int sg_count(struct scatterlist *sg_list, int nbytes) 1087static int sg_count(struct scatterlist *sg_list, int nbytes, int *chained)
1041{ 1088{
1042 struct scatterlist *sg = sg_list; 1089 struct scatterlist *sg = sg_list;
1043 int sg_nents = 0; 1090 int sg_nents = 0;
1044 1091
1045 while (nbytes) { 1092 *chained = 0;
1093 while (nbytes > 0) {
1046 sg_nents++; 1094 sg_nents++;
1047 nbytes -= sg->length; 1095 nbytes -= sg->length;
1048 sg = sg_next(sg); 1096 if (!sg_is_last(sg) && (sg + 1)->length == 0)
1097 *chained = 1;
1098 sg = scatterwalk_sg_next(sg);
1049 } 1099 }
1050 1100
1051 return sg_nents; 1101 return sg_nents;
1052} 1102}
1053 1103
1054/* 1104/*
1055 * allocate and map the ipsec_esp extended descriptor 1105 * allocate and map the extended descriptor
1056 */ 1106 */
1057static struct ipsec_esp_edesc *ipsec_esp_edesc_alloc(struct aead_request *areq, 1107static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1058 int icv_stashing) 1108 struct scatterlist *src,
1109 struct scatterlist *dst,
1110 unsigned int cryptlen,
1111 unsigned int authsize,
1112 int icv_stashing,
1113 u32 cryptoflags)
1059{ 1114{
1060 struct crypto_aead *authenc = crypto_aead_reqtfm(areq); 1115 struct talitos_edesc *edesc;
1061 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1062 struct ipsec_esp_edesc *edesc;
1063 int src_nents, dst_nents, alloc_len, dma_len; 1116 int src_nents, dst_nents, alloc_len, dma_len;
1064 gfp_t flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : 1117 int src_chained, dst_chained = 0;
1118 gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
1065 GFP_ATOMIC; 1119 GFP_ATOMIC;
1066 1120
1067 if (areq->cryptlen + ctx->authsize > TALITOS_MAX_DATA_LEN) { 1121 if (cryptlen + authsize > TALITOS_MAX_DATA_LEN) {
1068 dev_err(ctx->dev, "cryptlen exceeds h/w max limit\n"); 1122 dev_err(dev, "length exceeds h/w max limit\n");
1069 return ERR_PTR(-EINVAL); 1123 return ERR_PTR(-EINVAL);
1070 } 1124 }
1071 1125
1072 src_nents = sg_count(areq->src, areq->cryptlen + ctx->authsize); 1126 src_nents = sg_count(src, cryptlen + authsize, &src_chained);
1073 src_nents = (src_nents == 1) ? 0 : src_nents; 1127 src_nents = (src_nents == 1) ? 0 : src_nents;
1074 1128
1075 if (areq->dst == areq->src) { 1129 if (dst == src) {
1076 dst_nents = src_nents; 1130 dst_nents = src_nents;
1077 } else { 1131 } else {
1078 dst_nents = sg_count(areq->dst, areq->cryptlen + ctx->authsize); 1132 dst_nents = sg_count(dst, cryptlen + authsize, &dst_chained);
1079 dst_nents = (dst_nents == 1) ? 0 : dst_nents; 1133 dst_nents = (dst_nents == 1) ? 0 : dst_nents;
1080 } 1134 }
1081 1135
@@ -1084,39 +1138,52 @@ static struct ipsec_esp_edesc *ipsec_esp_edesc_alloc(struct aead_request *areq,
1084 * allowing for two separate entries for ICV and generated ICV (+ 2), 1138 * allowing for two separate entries for ICV and generated ICV (+ 2),
1085 * and the ICV data itself 1139 * and the ICV data itself
1086 */ 1140 */
1087 alloc_len = sizeof(struct ipsec_esp_edesc); 1141 alloc_len = sizeof(struct talitos_edesc);
1088 if (src_nents || dst_nents) { 1142 if (src_nents || dst_nents) {
1089 dma_len = (src_nents + dst_nents + 2) * 1143 dma_len = (src_nents + dst_nents + 2) *
1090 sizeof(struct talitos_ptr) + ctx->authsize; 1144 sizeof(struct talitos_ptr) + authsize;
1091 alloc_len += dma_len; 1145 alloc_len += dma_len;
1092 } else { 1146 } else {
1093 dma_len = 0; 1147 dma_len = 0;
1094 alloc_len += icv_stashing ? ctx->authsize : 0; 1148 alloc_len += icv_stashing ? authsize : 0;
1095 } 1149 }
1096 1150
1097 edesc = kmalloc(alloc_len, GFP_DMA | flags); 1151 edesc = kmalloc(alloc_len, GFP_DMA | flags);
1098 if (!edesc) { 1152 if (!edesc) {
1099 dev_err(ctx->dev, "could not allocate edescriptor\n"); 1153 dev_err(dev, "could not allocate edescriptor\n");
1100 return ERR_PTR(-ENOMEM); 1154 return ERR_PTR(-ENOMEM);
1101 } 1155 }
1102 1156
1103 edesc->src_nents = src_nents; 1157 edesc->src_nents = src_nents;
1104 edesc->dst_nents = dst_nents; 1158 edesc->dst_nents = dst_nents;
1159 edesc->src_is_chained = src_chained;
1160 edesc->dst_is_chained = dst_chained;
1105 edesc->dma_len = dma_len; 1161 edesc->dma_len = dma_len;
1106 edesc->dma_link_tbl = dma_map_single(ctx->dev, &edesc->link_tbl[0], 1162 edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0],
1107 edesc->dma_len, DMA_BIDIRECTIONAL); 1163 edesc->dma_len, DMA_BIDIRECTIONAL);
1108 1164
1109 return edesc; 1165 return edesc;
1110} 1166}
1111 1167
1112static int aead_authenc_encrypt(struct aead_request *req) 1168static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq,
1169 int icv_stashing)
1170{
1171 struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
1172 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1173
1174 return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst,
1175 areq->cryptlen, ctx->authsize, icv_stashing,
1176 areq->base.flags);
1177}
1178
1179static int aead_encrypt(struct aead_request *req)
1113{ 1180{
1114 struct crypto_aead *authenc = crypto_aead_reqtfm(req); 1181 struct crypto_aead *authenc = crypto_aead_reqtfm(req);
1115 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 1182 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1116 struct ipsec_esp_edesc *edesc; 1183 struct talitos_edesc *edesc;
1117 1184
1118 /* allocate extended descriptor */ 1185 /* allocate extended descriptor */
1119 edesc = ipsec_esp_edesc_alloc(req, 0); 1186 edesc = aead_edesc_alloc(req, 0);
1120 if (IS_ERR(edesc)) 1187 if (IS_ERR(edesc))
1121 return PTR_ERR(edesc); 1188 return PTR_ERR(edesc);
1122 1189
@@ -1126,70 +1193,67 @@ static int aead_authenc_encrypt(struct aead_request *req)
1126 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_encrypt_done); 1193 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_encrypt_done);
1127} 1194}
1128 1195
1129 1196static int aead_decrypt(struct aead_request *req)
1130
1131static int aead_authenc_decrypt(struct aead_request *req)
1132{ 1197{
1133 struct crypto_aead *authenc = crypto_aead_reqtfm(req); 1198 struct crypto_aead *authenc = crypto_aead_reqtfm(req);
1134 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 1199 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1135 unsigned int authsize = ctx->authsize; 1200 unsigned int authsize = ctx->authsize;
1136 struct talitos_private *priv = dev_get_drvdata(ctx->dev); 1201 struct talitos_private *priv = dev_get_drvdata(ctx->dev);
1137 struct ipsec_esp_edesc *edesc; 1202 struct talitos_edesc *edesc;
1138 struct scatterlist *sg; 1203 struct scatterlist *sg;
1139 void *icvdata; 1204 void *icvdata;
1140 1205
1141 req->cryptlen -= authsize; 1206 req->cryptlen -= authsize;
1142 1207
1143 /* allocate extended descriptor */ 1208 /* allocate extended descriptor */
1144 edesc = ipsec_esp_edesc_alloc(req, 1); 1209 edesc = aead_edesc_alloc(req, 1);
1145 if (IS_ERR(edesc)) 1210 if (IS_ERR(edesc))
1146 return PTR_ERR(edesc); 1211 return PTR_ERR(edesc);
1147 1212
1148 if ((priv->features & TALITOS_FTR_HW_AUTH_CHECK) && 1213 if ((priv->features & TALITOS_FTR_HW_AUTH_CHECK) &&
1149 (((!edesc->src_nents && !edesc->dst_nents) || 1214 ((!edesc->src_nents && !edesc->dst_nents) ||
1150 priv->features & TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT))) { 1215 priv->features & TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT)) {
1151 1216
1152 /* decrypt and check the ICV */ 1217 /* decrypt and check the ICV */
1153 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND | 1218 edesc->desc.hdr = ctx->desc_hdr_template |
1219 DESC_HDR_DIR_INBOUND |
1154 DESC_HDR_MODE1_MDEU_CICV; 1220 DESC_HDR_MODE1_MDEU_CICV;
1155 1221
1156 /* reset integrity check result bits */ 1222 /* reset integrity check result bits */
1157 edesc->desc.hdr_lo = 0; 1223 edesc->desc.hdr_lo = 0;
1158 1224
1159 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_hwauth_done); 1225 return ipsec_esp(edesc, req, NULL, 0,
1226 ipsec_esp_decrypt_hwauth_done);
1160 1227
1161 } else { 1228 }
1162
1163 /* Have to check the ICV with software */
1164 1229
1165 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND; 1230 /* Have to check the ICV with software */
1231 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND;
1166 1232
1167 /* stash incoming ICV for later cmp with ICV generated by the h/w */ 1233 /* stash incoming ICV for later cmp with ICV generated by the h/w */
1168 if (edesc->dma_len) 1234 if (edesc->dma_len)
1169 icvdata = &edesc->link_tbl[edesc->src_nents + 1235 icvdata = &edesc->link_tbl[edesc->src_nents +
1170 edesc->dst_nents + 2]; 1236 edesc->dst_nents + 2];
1171 else 1237 else
1172 icvdata = &edesc->link_tbl[0]; 1238 icvdata = &edesc->link_tbl[0];
1173 1239
1174 sg = sg_last(req->src, edesc->src_nents ? : 1); 1240 sg = sg_last(req->src, edesc->src_nents ? : 1);
1175 1241
1176 memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize, 1242 memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize,
1177 ctx->authsize); 1243 ctx->authsize);
1178 1244
1179 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done); 1245 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done);
1180 }
1181} 1246}
1182 1247
1183static int aead_authenc_givencrypt( 1248static int aead_givencrypt(struct aead_givcrypt_request *req)
1184 struct aead_givcrypt_request *req)
1185{ 1249{
1186 struct aead_request *areq = &req->areq; 1250 struct aead_request *areq = &req->areq;
1187 struct crypto_aead *authenc = crypto_aead_reqtfm(areq); 1251 struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
1188 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 1252 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1189 struct ipsec_esp_edesc *edesc; 1253 struct talitos_edesc *edesc;
1190 1254
1191 /* allocate extended descriptor */ 1255 /* allocate extended descriptor */
1192 edesc = ipsec_esp_edesc_alloc(areq, 0); 1256 edesc = aead_edesc_alloc(areq, 0);
1193 if (IS_ERR(edesc)) 1257 if (IS_ERR(edesc))
1194 return PTR_ERR(edesc); 1258 return PTR_ERR(edesc);
1195 1259
@@ -1204,31 +1268,228 @@ static int aead_authenc_givencrypt(
1204 ipsec_esp_encrypt_done); 1268 ipsec_esp_encrypt_done);
1205} 1269}
1206 1270
1271static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
1272 const u8 *key, unsigned int keylen)
1273{
1274 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
1275 struct ablkcipher_alg *alg = crypto_ablkcipher_alg(cipher);
1276
1277 if (keylen > TALITOS_MAX_KEY_SIZE)
1278 goto badkey;
1279
1280 if (keylen < alg->min_keysize || keylen > alg->max_keysize)
1281 goto badkey;
1282
1283 memcpy(&ctx->key, key, keylen);
1284 ctx->keylen = keylen;
1285
1286 return 0;
1287
1288badkey:
1289 crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
1290 return -EINVAL;
1291}
1292
1293static void common_nonsnoop_unmap(struct device *dev,
1294 struct talitos_edesc *edesc,
1295 struct ablkcipher_request *areq)
1296{
1297 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[5], DMA_FROM_DEVICE);
1298 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE);
1299 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[1], DMA_TO_DEVICE);
1300
1301 talitos_sg_unmap(dev, edesc, areq->src, areq->dst);
1302
1303 if (edesc->dma_len)
1304 dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len,
1305 DMA_BIDIRECTIONAL);
1306}
1307
1308static void ablkcipher_done(struct device *dev,
1309 struct talitos_desc *desc, void *context,
1310 int err)
1311{
1312 struct ablkcipher_request *areq = context;
1313 struct talitos_edesc *edesc;
1314
1315 edesc = container_of(desc, struct talitos_edesc, desc);
1316
1317 common_nonsnoop_unmap(dev, edesc, areq);
1318
1319 kfree(edesc);
1320
1321 areq->base.complete(&areq->base, err);
1322}
1323
1324static int common_nonsnoop(struct talitos_edesc *edesc,
1325 struct ablkcipher_request *areq,
1326 u8 *giv,
1327 void (*callback) (struct device *dev,
1328 struct talitos_desc *desc,
1329 void *context, int error))
1330{
1331 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
1332 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
1333 struct device *dev = ctx->dev;
1334 struct talitos_desc *desc = &edesc->desc;
1335 unsigned int cryptlen = areq->nbytes;
1336 unsigned int ivsize;
1337 int sg_count, ret;
1338
1339 /* first DWORD empty */
1340 desc->ptr[0].len = 0;
1341 desc->ptr[0].ptr = 0;
1342 desc->ptr[0].j_extent = 0;
1343
1344 /* cipher iv */
1345 ivsize = crypto_ablkcipher_ivsize(cipher);
1346 map_single_talitos_ptr(dev, &desc->ptr[1], ivsize, giv ?: areq->info, 0,
1347 DMA_TO_DEVICE);
1348
1349 /* cipher key */
1350 map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen,
1351 (char *)&ctx->key, 0, DMA_TO_DEVICE);
1352
1353 /*
1354 * cipher in
1355 */
1356 desc->ptr[3].len = cpu_to_be16(cryptlen);
1357 desc->ptr[3].j_extent = 0;
1358
1359 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
1360 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
1361 : DMA_TO_DEVICE,
1362 edesc->src_is_chained);
1363
1364 if (sg_count == 1) {
1365 desc->ptr[3].ptr = cpu_to_be32(sg_dma_address(areq->src));
1366 } else {
1367 sg_count = sg_to_link_tbl(areq->src, sg_count, cryptlen,
1368 &edesc->link_tbl[0]);
1369 if (sg_count > 1) {
1370 desc->ptr[3].j_extent |= DESC_PTR_LNKTBL_JUMP;
1371 desc->ptr[3].ptr = cpu_to_be32(edesc->dma_link_tbl);
1372 dma_sync_single_for_device(dev, edesc->dma_link_tbl,
1373 edesc->dma_len,
1374 DMA_BIDIRECTIONAL);
1375 } else {
1376 /* Only one segment now, so no link tbl needed */
1377 desc->ptr[3].ptr = cpu_to_be32(sg_dma_address(areq->
1378 src));
1379 }
1380 }
1381
1382 /* cipher out */
1383 desc->ptr[4].len = cpu_to_be16(cryptlen);
1384 desc->ptr[4].j_extent = 0;
1385
1386 if (areq->src != areq->dst)
1387 sg_count = talitos_map_sg(dev, areq->dst,
1388 edesc->dst_nents ? : 1,
1389 DMA_FROM_DEVICE,
1390 edesc->dst_is_chained);
1391
1392 if (sg_count == 1) {
1393 desc->ptr[4].ptr = cpu_to_be32(sg_dma_address(areq->dst));
1394 } else {
1395 struct talitos_ptr *link_tbl_ptr =
1396 &edesc->link_tbl[edesc->src_nents + 1];
1397
1398 desc->ptr[4].j_extent |= DESC_PTR_LNKTBL_JUMP;
1399 desc->ptr[4].ptr = cpu_to_be32((struct talitos_ptr *)
1400 edesc->dma_link_tbl +
1401 edesc->src_nents + 1);
1402 sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen,
1403 link_tbl_ptr);
1404 dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl,
1405 edesc->dma_len, DMA_BIDIRECTIONAL);
1406 }
1407
1408 /* iv out */
1409 map_single_talitos_ptr(dev, &desc->ptr[5], ivsize, ctx->iv, 0,
1410 DMA_FROM_DEVICE);
1411
1412 /* last DWORD empty */
1413 desc->ptr[6].len = 0;
1414 desc->ptr[6].ptr = 0;
1415 desc->ptr[6].j_extent = 0;
1416
1417 ret = talitos_submit(dev, desc, callback, areq);
1418 if (ret != -EINPROGRESS) {
1419 common_nonsnoop_unmap(dev, edesc, areq);
1420 kfree(edesc);
1421 }
1422 return ret;
1423}
1424
1425static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request *
1426 areq)
1427{
1428 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
1429 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
1430
1431 return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, areq->nbytes,
1432 0, 0, areq->base.flags);
1433}
1434
1435static int ablkcipher_encrypt(struct ablkcipher_request *areq)
1436{
1437 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
1438 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
1439 struct talitos_edesc *edesc;
1440
1441 /* allocate extended descriptor */
1442 edesc = ablkcipher_edesc_alloc(areq);
1443 if (IS_ERR(edesc))
1444 return PTR_ERR(edesc);
1445
1446 /* set encrypt */
1447 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT;
1448
1449 return common_nonsnoop(edesc, areq, NULL, ablkcipher_done);
1450}
1451
1452static int ablkcipher_decrypt(struct ablkcipher_request *areq)
1453{
1454 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
1455 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
1456 struct talitos_edesc *edesc;
1457
1458 /* allocate extended descriptor */
1459 edesc = ablkcipher_edesc_alloc(areq);
1460 if (IS_ERR(edesc))
1461 return PTR_ERR(edesc);
1462
1463 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_DIR_INBOUND;
1464
1465 return common_nonsnoop(edesc, areq, NULL, ablkcipher_done);
1466}
1467
1207struct talitos_alg_template { 1468struct talitos_alg_template {
1208 char name[CRYPTO_MAX_ALG_NAME]; 1469 struct crypto_alg alg;
1209 char driver_name[CRYPTO_MAX_ALG_NAME];
1210 unsigned int blocksize;
1211 struct aead_alg aead;
1212 struct device *dev;
1213 __be32 desc_hdr_template; 1470 __be32 desc_hdr_template;
1214}; 1471};
1215 1472
1216static struct talitos_alg_template driver_algs[] = { 1473static struct talitos_alg_template driver_algs[] = {
1217 /* single-pass ipsec_esp descriptor */ 1474 /* AEAD algorithms. These use a single-pass ipsec_esp descriptor */
1218 { 1475 {
1219 .name = "authenc(hmac(sha1),cbc(aes))", 1476 .alg = {
1220 .driver_name = "authenc-hmac-sha1-cbc-aes-talitos", 1477 .cra_name = "authenc(hmac(sha1),cbc(aes))",
1221 .blocksize = AES_BLOCK_SIZE, 1478 .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos",
1222 .aead = { 1479 .cra_blocksize = AES_BLOCK_SIZE,
1223 .setkey = aead_authenc_setkey, 1480 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1224 .setauthsize = aead_authenc_setauthsize, 1481 .cra_type = &crypto_aead_type,
1225 .encrypt = aead_authenc_encrypt, 1482 .cra_aead = {
1226 .decrypt = aead_authenc_decrypt, 1483 .setkey = aead_setkey,
1227 .givencrypt = aead_authenc_givencrypt, 1484 .setauthsize = aead_setauthsize,
1228 .geniv = "<built-in>", 1485 .encrypt = aead_encrypt,
1229 .ivsize = AES_BLOCK_SIZE, 1486 .decrypt = aead_decrypt,
1230 .maxauthsize = SHA1_DIGEST_SIZE, 1487 .givencrypt = aead_givencrypt,
1231 }, 1488 .geniv = "<built-in>",
1489 .ivsize = AES_BLOCK_SIZE,
1490 .maxauthsize = SHA1_DIGEST_SIZE,
1491 }
1492 },
1232 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | 1493 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
1233 DESC_HDR_SEL0_AESU | 1494 DESC_HDR_SEL0_AESU |
1234 DESC_HDR_MODE0_AESU_CBC | 1495 DESC_HDR_MODE0_AESU_CBC |
@@ -1238,19 +1499,23 @@ static struct talitos_alg_template driver_algs[] = {
1238 DESC_HDR_MODE1_MDEU_SHA1_HMAC, 1499 DESC_HDR_MODE1_MDEU_SHA1_HMAC,
1239 }, 1500 },
1240 { 1501 {
1241 .name = "authenc(hmac(sha1),cbc(des3_ede))", 1502 .alg = {
1242 .driver_name = "authenc-hmac-sha1-cbc-3des-talitos", 1503 .cra_name = "authenc(hmac(sha1),cbc(des3_ede))",
1243 .blocksize = DES3_EDE_BLOCK_SIZE, 1504 .cra_driver_name = "authenc-hmac-sha1-cbc-3des-talitos",
1244 .aead = { 1505 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
1245 .setkey = aead_authenc_setkey, 1506 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1246 .setauthsize = aead_authenc_setauthsize, 1507 .cra_type = &crypto_aead_type,
1247 .encrypt = aead_authenc_encrypt, 1508 .cra_aead = {
1248 .decrypt = aead_authenc_decrypt, 1509 .setkey = aead_setkey,
1249 .givencrypt = aead_authenc_givencrypt, 1510 .setauthsize = aead_setauthsize,
1250 .geniv = "<built-in>", 1511 .encrypt = aead_encrypt,
1251 .ivsize = DES3_EDE_BLOCK_SIZE, 1512 .decrypt = aead_decrypt,
1252 .maxauthsize = SHA1_DIGEST_SIZE, 1513 .givencrypt = aead_givencrypt,
1253 }, 1514 .geniv = "<built-in>",
1515 .ivsize = DES3_EDE_BLOCK_SIZE,
1516 .maxauthsize = SHA1_DIGEST_SIZE,
1517 }
1518 },
1254 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | 1519 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
1255 DESC_HDR_SEL0_DEU | 1520 DESC_HDR_SEL0_DEU |
1256 DESC_HDR_MODE0_DEU_CBC | 1521 DESC_HDR_MODE0_DEU_CBC |
@@ -1261,19 +1526,23 @@ static struct talitos_alg_template driver_algs[] = {
1261 DESC_HDR_MODE1_MDEU_SHA1_HMAC, 1526 DESC_HDR_MODE1_MDEU_SHA1_HMAC,
1262 }, 1527 },
1263 { 1528 {
1264 .name = "authenc(hmac(sha256),cbc(aes))", 1529 .alg = {
1265 .driver_name = "authenc-hmac-sha256-cbc-aes-talitos", 1530 .cra_name = "authenc(hmac(sha256),cbc(aes))",
1266 .blocksize = AES_BLOCK_SIZE, 1531 .cra_driver_name = "authenc-hmac-sha256-cbc-aes-talitos",
1267 .aead = { 1532 .cra_blocksize = AES_BLOCK_SIZE,
1268 .setkey = aead_authenc_setkey, 1533 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1269 .setauthsize = aead_authenc_setauthsize, 1534 .cra_type = &crypto_aead_type,
1270 .encrypt = aead_authenc_encrypt, 1535 .cra_aead = {
1271 .decrypt = aead_authenc_decrypt, 1536 .setkey = aead_setkey,
1272 .givencrypt = aead_authenc_givencrypt, 1537 .setauthsize = aead_setauthsize,
1273 .geniv = "<built-in>", 1538 .encrypt = aead_encrypt,
1274 .ivsize = AES_BLOCK_SIZE, 1539 .decrypt = aead_decrypt,
1275 .maxauthsize = SHA256_DIGEST_SIZE, 1540 .givencrypt = aead_givencrypt,
1276 }, 1541 .geniv = "<built-in>",
1542 .ivsize = AES_BLOCK_SIZE,
1543 .maxauthsize = SHA256_DIGEST_SIZE,
1544 }
1545 },
1277 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | 1546 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
1278 DESC_HDR_SEL0_AESU | 1547 DESC_HDR_SEL0_AESU |
1279 DESC_HDR_MODE0_AESU_CBC | 1548 DESC_HDR_MODE0_AESU_CBC |
@@ -1283,19 +1552,23 @@ static struct talitos_alg_template driver_algs[] = {
1283 DESC_HDR_MODE1_MDEU_SHA256_HMAC, 1552 DESC_HDR_MODE1_MDEU_SHA256_HMAC,
1284 }, 1553 },
1285 { 1554 {
1286 .name = "authenc(hmac(sha256),cbc(des3_ede))", 1555 .alg = {
1287 .driver_name = "authenc-hmac-sha256-cbc-3des-talitos", 1556 .cra_name = "authenc(hmac(sha256),cbc(des3_ede))",
1288 .blocksize = DES3_EDE_BLOCK_SIZE, 1557 .cra_driver_name = "authenc-hmac-sha256-cbc-3des-talitos",
1289 .aead = { 1558 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
1290 .setkey = aead_authenc_setkey, 1559 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1291 .setauthsize = aead_authenc_setauthsize, 1560 .cra_type = &crypto_aead_type,
1292 .encrypt = aead_authenc_encrypt, 1561 .cra_aead = {
1293 .decrypt = aead_authenc_decrypt, 1562 .setkey = aead_setkey,
1294 .givencrypt = aead_authenc_givencrypt, 1563 .setauthsize = aead_setauthsize,
1295 .geniv = "<built-in>", 1564 .encrypt = aead_encrypt,
1296 .ivsize = DES3_EDE_BLOCK_SIZE, 1565 .decrypt = aead_decrypt,
1297 .maxauthsize = SHA256_DIGEST_SIZE, 1566 .givencrypt = aead_givencrypt,
1298 }, 1567 .geniv = "<built-in>",
1568 .ivsize = DES3_EDE_BLOCK_SIZE,
1569 .maxauthsize = SHA256_DIGEST_SIZE,
1570 }
1571 },
1299 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | 1572 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
1300 DESC_HDR_SEL0_DEU | 1573 DESC_HDR_SEL0_DEU |
1301 DESC_HDR_MODE0_DEU_CBC | 1574 DESC_HDR_MODE0_DEU_CBC |
@@ -1306,19 +1579,23 @@ static struct talitos_alg_template driver_algs[] = {
1306 DESC_HDR_MODE1_MDEU_SHA256_HMAC, 1579 DESC_HDR_MODE1_MDEU_SHA256_HMAC,
1307 }, 1580 },
1308 { 1581 {
1309 .name = "authenc(hmac(md5),cbc(aes))", 1582 .alg = {
1310 .driver_name = "authenc-hmac-md5-cbc-aes-talitos", 1583 .cra_name = "authenc(hmac(md5),cbc(aes))",
1311 .blocksize = AES_BLOCK_SIZE, 1584 .cra_driver_name = "authenc-hmac-md5-cbc-aes-talitos",
1312 .aead = { 1585 .cra_blocksize = AES_BLOCK_SIZE,
1313 .setkey = aead_authenc_setkey, 1586 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1314 .setauthsize = aead_authenc_setauthsize, 1587 .cra_type = &crypto_aead_type,
1315 .encrypt = aead_authenc_encrypt, 1588 .cra_aead = {
1316 .decrypt = aead_authenc_decrypt, 1589 .setkey = aead_setkey,
1317 .givencrypt = aead_authenc_givencrypt, 1590 .setauthsize = aead_setauthsize,
1318 .geniv = "<built-in>", 1591 .encrypt = aead_encrypt,
1319 .ivsize = AES_BLOCK_SIZE, 1592 .decrypt = aead_decrypt,
1320 .maxauthsize = MD5_DIGEST_SIZE, 1593 .givencrypt = aead_givencrypt,
1321 }, 1594 .geniv = "<built-in>",
1595 .ivsize = AES_BLOCK_SIZE,
1596 .maxauthsize = MD5_DIGEST_SIZE,
1597 }
1598 },
1322 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | 1599 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
1323 DESC_HDR_SEL0_AESU | 1600 DESC_HDR_SEL0_AESU |
1324 DESC_HDR_MODE0_AESU_CBC | 1601 DESC_HDR_MODE0_AESU_CBC |
@@ -1328,19 +1605,23 @@ static struct talitos_alg_template driver_algs[] = {
1328 DESC_HDR_MODE1_MDEU_MD5_HMAC, 1605 DESC_HDR_MODE1_MDEU_MD5_HMAC,
1329 }, 1606 },
1330 { 1607 {
1331 .name = "authenc(hmac(md5),cbc(des3_ede))", 1608 .alg = {
1332 .driver_name = "authenc-hmac-md5-cbc-3des-talitos", 1609 .cra_name = "authenc(hmac(md5),cbc(des3_ede))",
1333 .blocksize = DES3_EDE_BLOCK_SIZE, 1610 .cra_driver_name = "authenc-hmac-md5-cbc-3des-talitos",
1334 .aead = { 1611 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
1335 .setkey = aead_authenc_setkey, 1612 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1336 .setauthsize = aead_authenc_setauthsize, 1613 .cra_type = &crypto_aead_type,
1337 .encrypt = aead_authenc_encrypt, 1614 .cra_aead = {
1338 .decrypt = aead_authenc_decrypt, 1615 .setkey = aead_setkey,
1339 .givencrypt = aead_authenc_givencrypt, 1616 .setauthsize = aead_setauthsize,
1340 .geniv = "<built-in>", 1617 .encrypt = aead_encrypt,
1341 .ivsize = DES3_EDE_BLOCK_SIZE, 1618 .decrypt = aead_decrypt,
1342 .maxauthsize = MD5_DIGEST_SIZE, 1619 .givencrypt = aead_givencrypt,
1343 }, 1620 .geniv = "<built-in>",
1621 .ivsize = DES3_EDE_BLOCK_SIZE,
1622 .maxauthsize = MD5_DIGEST_SIZE,
1623 }
1624 },
1344 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | 1625 .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP |
1345 DESC_HDR_SEL0_DEU | 1626 DESC_HDR_SEL0_DEU |
1346 DESC_HDR_MODE0_DEU_CBC | 1627 DESC_HDR_MODE0_DEU_CBC |
@@ -1349,6 +1630,52 @@ static struct talitos_alg_template driver_algs[] = {
1349 DESC_HDR_MODE1_MDEU_INIT | 1630 DESC_HDR_MODE1_MDEU_INIT |
1350 DESC_HDR_MODE1_MDEU_PAD | 1631 DESC_HDR_MODE1_MDEU_PAD |
1351 DESC_HDR_MODE1_MDEU_MD5_HMAC, 1632 DESC_HDR_MODE1_MDEU_MD5_HMAC,
1633 },
1634 /* ABLKCIPHER algorithms. */
1635 {
1636 .alg = {
1637 .cra_name = "cbc(aes)",
1638 .cra_driver_name = "cbc-aes-talitos",
1639 .cra_blocksize = AES_BLOCK_SIZE,
1640 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
1641 CRYPTO_ALG_ASYNC,
1642 .cra_type = &crypto_ablkcipher_type,
1643 .cra_ablkcipher = {
1644 .setkey = ablkcipher_setkey,
1645 .encrypt = ablkcipher_encrypt,
1646 .decrypt = ablkcipher_decrypt,
1647 .geniv = "eseqiv",
1648 .min_keysize = AES_MIN_KEY_SIZE,
1649 .max_keysize = AES_MAX_KEY_SIZE,
1650 .ivsize = AES_BLOCK_SIZE,
1651 }
1652 },
1653 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
1654 DESC_HDR_SEL0_AESU |
1655 DESC_HDR_MODE0_AESU_CBC,
1656 },
1657 {
1658 .alg = {
1659 .cra_name = "cbc(des3_ede)",
1660 .cra_driver_name = "cbc-3des-talitos",
1661 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
1662 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
1663 CRYPTO_ALG_ASYNC,
1664 .cra_type = &crypto_ablkcipher_type,
1665 .cra_ablkcipher = {
1666 .setkey = ablkcipher_setkey,
1667 .encrypt = ablkcipher_encrypt,
1668 .decrypt = ablkcipher_decrypt,
1669 .geniv = "eseqiv",
1670 .min_keysize = DES3_EDE_KEY_SIZE,
1671 .max_keysize = DES3_EDE_KEY_SIZE,
1672 .ivsize = DES3_EDE_BLOCK_SIZE,
1673 }
1674 },
1675 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
1676 DESC_HDR_SEL0_DEU |
1677 DESC_HDR_MODE0_DEU_CBC |
1678 DESC_HDR_MODE0_DEU_3DES,
1352 } 1679 }
1353}; 1680};
1354 1681
@@ -1362,12 +1689,14 @@ struct talitos_crypto_alg {
1362static int talitos_cra_init(struct crypto_tfm *tfm) 1689static int talitos_cra_init(struct crypto_tfm *tfm)
1363{ 1690{
1364 struct crypto_alg *alg = tfm->__crt_alg; 1691 struct crypto_alg *alg = tfm->__crt_alg;
1365 struct talitos_crypto_alg *talitos_alg = 1692 struct talitos_crypto_alg *talitos_alg;
1366 container_of(alg, struct talitos_crypto_alg, crypto_alg);
1367 struct talitos_ctx *ctx = crypto_tfm_ctx(tfm); 1693 struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
1368 1694
1695 talitos_alg = container_of(alg, struct talitos_crypto_alg, crypto_alg);
1696
1369 /* update context with ptr to dev */ 1697 /* update context with ptr to dev */
1370 ctx->dev = talitos_alg->dev; 1698 ctx->dev = talitos_alg->dev;
1699
1371 /* copy descriptor header template value */ 1700 /* copy descriptor header template value */
1372 ctx->desc_hdr_template = talitos_alg->desc_hdr_template; 1701 ctx->desc_hdr_template = talitos_alg->desc_hdr_template;
1373 1702
@@ -1453,19 +1782,13 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
1453 return ERR_PTR(-ENOMEM); 1782 return ERR_PTR(-ENOMEM);
1454 1783
1455 alg = &t_alg->crypto_alg; 1784 alg = &t_alg->crypto_alg;
1785 *alg = template->alg;
1456 1786
1457 snprintf(alg->cra_name, CRYPTO_MAX_ALG_NAME, "%s", template->name);
1458 snprintf(alg->cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s",
1459 template->driver_name);
1460 alg->cra_module = THIS_MODULE; 1787 alg->cra_module = THIS_MODULE;
1461 alg->cra_init = talitos_cra_init; 1788 alg->cra_init = talitos_cra_init;
1462 alg->cra_priority = TALITOS_CRA_PRIORITY; 1789 alg->cra_priority = TALITOS_CRA_PRIORITY;
1463 alg->cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC;
1464 alg->cra_blocksize = template->blocksize;
1465 alg->cra_alignmask = 0; 1790 alg->cra_alignmask = 0;
1466 alg->cra_type = &crypto_aead_type;
1467 alg->cra_ctxsize = sizeof(struct talitos_ctx); 1791 alg->cra_ctxsize = sizeof(struct talitos_ctx);
1468 alg->cra_u.aead = template->aead;
1469 1792
1470 t_alg->desc_hdr_template = template->desc_hdr_template; 1793 t_alg->desc_hdr_template = template->desc_hdr_template;
1471 t_alg->dev = dev; 1794 t_alg->dev = dev;
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index facfdb1fa71c..d205d493a68a 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -1084,7 +1084,7 @@ static void e752x_init_sysbus_parity_mask(struct e752x_pvt *pvt)
1084 struct pci_dev *dev = pvt->dev_d0f1; 1084 struct pci_dev *dev = pvt->dev_d0f1;
1085 int enable = 1; 1085 int enable = 1;
1086 1086
1087 /* Allow module paramter override, else see if CPU supports parity */ 1087 /* Allow module parameter override, else see if CPU supports parity */
1088 if (sysbus_parity != -1) { 1088 if (sysbus_parity != -1) {
1089 enable = sysbus_parity; 1089 enable = sysbus_parity;
1090 } else if (cpu_id[0] && 1090 } else if (cpu_id[0] &&
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 7e67dcb3d4f6..7831a0318d3c 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -116,9 +116,16 @@ config HID_CYPRESS
116 ---help--- 116 ---help---
117 Support for cypress mouse and barcode readers. 117 Support for cypress mouse and barcode readers.
118 118
119config DRAGONRISE_FF 119config HID_DRAGONRISE
120 tristate "DragonRise Inc. force feedback support" 120 tristate "DragonRise Inc. support" if EMBEDDED
121 depends on USB_HID 121 depends on USB_HID
122 default !EMBEDDED
123 ---help---
124 Say Y here if you have DragonRise Inc.game controllers.
125
126config DRAGONRISE_FF
127 bool "DragonRise Inc. force feedback support"
128 depends on HID_DRAGONRISE
122 select INPUT_FF_MEMLESS 129 select INPUT_FF_MEMLESS
123 ---help--- 130 ---help---
124 Say Y here if you want to enable force feedback support for DragonRise Inc. 131 Say Y here if you want to enable force feedback support for DragonRise Inc.
@@ -160,7 +167,7 @@ config HID_LOGITECH
160 Support for Logitech devices that are not fully compliant with HID standard. 167 Support for Logitech devices that are not fully compliant with HID standard.
161 168
162config LOGITECH_FF 169config LOGITECH_FF
163 bool "Logitech force feedback" 170 bool "Logitech force feedback support"
164 depends on HID_LOGITECH 171 depends on HID_LOGITECH
165 select INPUT_FF_MEMLESS 172 select INPUT_FF_MEMLESS
166 help 173 help
@@ -176,7 +183,7 @@ config LOGITECH_FF
176 force feedback. 183 force feedback.
177 184
178config LOGIRUMBLEPAD2_FF 185config LOGIRUMBLEPAD2_FF
179 bool "Logitech Rumblepad 2 force feedback" 186 bool "Logitech Rumblepad 2 force feedback support"
180 depends on HID_LOGITECH 187 depends on HID_LOGITECH
181 select INPUT_FF_MEMLESS 188 select INPUT_FF_MEMLESS
182 help 189 help
@@ -211,11 +218,19 @@ config HID_PANTHERLORD
211 ---help--- 218 ---help---
212 Support for PantherLord/GreenAsia based device support. 219 Support for PantherLord/GreenAsia based device support.
213 220
221config HID_PANTHERLORD
222 tristate "Pantherlord support" if EMBEDDED
223 depends on USB_HID
224 default !EMBEDDED
225 ---help---
226 Say Y here if you have a PantherLord/GreenAsia based game controller
227 or adapter.
228
214config PANTHERLORD_FF 229config PANTHERLORD_FF
215 bool "Pantherlord force feedback support" 230 bool "Pantherlord force feedback support"
216 depends on HID_PANTHERLORD 231 depends on HID_PANTHERLORD
217 select INPUT_FF_MEMLESS 232 select INPUT_FF_MEMLESS
218 help 233 ---help---
219 Say Y here if you have a PantherLord/GreenAsia based game controller 234 Say Y here if you have a PantherLord/GreenAsia based game controller
220 or adapter and want to enable force feedback support for it. 235 or adapter and want to enable force feedback support for it.
221 236
@@ -247,15 +262,38 @@ config HID_SUNPLUS
247 ---help--- 262 ---help---
248 Support for Sunplus wireless desktop. 263 Support for Sunplus wireless desktop.
249 264
250config GREENASIA_FF 265config HID_GREENASIA
251 tristate "GreenAsia (Product ID 0x12) force feedback support" 266 tristate "GreenAsia (Product ID 0x12) support" if EMBEDDED
252 depends on USB_HID 267 depends on USB_HID
268 default !EMBEDDED
269 ---help---
270 Say Y here if you have a GreenAsia (Product ID 0x12) based game
271 controller or adapter.
272
273config GREENASIA_FF
274 bool "GreenAsia (Product ID 0x12) force feedback support"
275 depends on HID_GREENASIA
253 select INPUT_FF_MEMLESS 276 select INPUT_FF_MEMLESS
254 ---help--- 277 ---help---
255 Say Y here if you have a GreenAsia (Product ID 0x12) based game controller 278 Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
256 (like MANTA Warrior MM816 and SpeedLink Strike2 SL-6635) or adapter 279 (like MANTA Warrior MM816 and SpeedLink Strike2 SL-6635) or adapter
257 and want to enable force feedback support for it. 280 and want to enable force feedback support for it.
258 281
282config HID_SMARTJOYPLUS
283 tristate "SmartJoy PLUS PS2/USB adapter support" if EMBEDDED
284 depends on USB_HID
285 default !EMBEDDED
286 ---help---
287 Support for SmartJoy PLUS PS2/USB adapter.
288
289config SMARTJOYPLUS_FF
290 bool "SmartJoy PLUS PS2/USB adapter force feedback support"
291 depends on HID_SMARTJOYPLUS
292 select INPUT_FF_MEMLESS
293 ---help---
294 Say Y here if you have a SmartJoy PLUS PS2/USB adapter and want to
295 enable force feedback support for it.
296
259config HID_TOPSEED 297config HID_TOPSEED
260 tristate "TopSeed Cyberlink remote control support" if EMBEDDED 298 tristate "TopSeed Cyberlink remote control support" if EMBEDDED
261 depends on USB_HID 299 depends on USB_HID
@@ -263,21 +301,45 @@ config HID_TOPSEED
263 ---help--- 301 ---help---
264 Say Y if you have a TopSeed Cyberlink remote control. 302 Say Y if you have a TopSeed Cyberlink remote control.
265 303
266config THRUSTMASTER_FF 304config HID_THRUSTMASTER
267 tristate "ThrustMaster devices support" 305 tristate "ThrustMaster devices support" if EMBEDDED
268 depends on USB_HID 306 depends on USB_HID
307 default !EMBEDDED
308 ---help---
309 Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
310 a THRUSTMASTER Ferrari GT Rumble Wheel.
311
312config THRUSTMASTER_FF
313 bool "ThrustMaster devices force feedback support"
314 depends on HID_THRUSTMASTER
269 select INPUT_FF_MEMLESS 315 select INPUT_FF_MEMLESS
270 help 316 ---help---
271 Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or 317 Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
272 a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel. 318 a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel and
319 want to enable force feedback support for it.
273 320
274config ZEROPLUS_FF 321config HID_WACOM
275 tristate "Zeroplus based game controller support" 322 tristate "Wacom Bluetooth devices support" if EMBEDDED
323 depends on BT_HIDP
324 default !EMBEDDED
325 ---help---
326 Support for Wacom Graphire Bluetooth tablet.
327
328config HID_ZEROPLUS
329 tristate "Zeroplus based game controller support" if EMBEDDED
276 depends on USB_HID 330 depends on USB_HID
277 select INPUT_FF_MEMLESS 331 default !EMBEDDED
278 help 332 ---help---
279 Say Y here if you have a Zeroplus based game controller. 333 Say Y here if you have a Zeroplus based game controller.
280 334
335config ZEROPLUS_FF
336 bool "Zeroplus based game controller force feedback support"
337 depends on HID_ZEROPLUS
338 select INPUT_FF_MEMLESS
339 ---help---
340 Say Y here if you have a Zeroplus based game controller and want
341 to have force feedback support for it.
342
281endmenu 343endmenu
282 344
283endif # HID_SUPPORT 345endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 1f7cb0fd4505..db35151673b1 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -22,7 +22,7 @@ obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
22obj-$(CONFIG_HID_CHERRY) += hid-cherry.o 22obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
23obj-$(CONFIG_HID_CHICONY) += hid-chicony.o 23obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
24obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o 24obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
25obj-$(CONFIG_DRAGONRISE_FF) += hid-drff.o 25obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o
26obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 26obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
27obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 27obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
28obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o 28obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o
@@ -34,12 +34,14 @@ obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
34obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o 34obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
35obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o 35obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
36obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o 36obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
37obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o
37obj-$(CONFIG_HID_SONY) += hid-sony.o 38obj-$(CONFIG_HID_SONY) += hid-sony.o
38obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o 39obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
39obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o 40obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o
40obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o 41obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o
41obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o 42obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o
42obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o 43obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
44obj-$(CONFIG_HID_WACOM) += hid-wacom.o
43 45
44obj-$(CONFIG_USB_HID) += usbhid/ 46obj-$(CONFIG_USB_HID) += usbhid/
45obj-$(CONFIG_USB_MOUSE) += usbhid/ 47obj-$(CONFIG_USB_MOUSE) += usbhid/
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index acbce5745b0c..303ccce05bb3 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -436,10 +436,6 @@ static const struct hid_device_id apple_devices[] = {
436 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), 436 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
437 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 437 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
438 438
439 /* Apple wireless Mighty Mouse */
440 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c),
441 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
442
443 { } 439 { }
444}; 440};
445MODULE_DEVICE_TABLE(hid, apple_devices); 441MODULE_DEVICE_TABLE(hid, apple_devices);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 8551693d645f..f2c21d5d24e8 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1312,6 +1312,8 @@ static const struct hid_device_id hid_blacklist[] = {
1312 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 1312 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
1313 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1313 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
1314 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 1314 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
1315 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
1316 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
1315 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1317 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
1316 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1318 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
1317 1319
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 47ac1a7d66e1..04359ed64b87 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -137,6 +137,14 @@ static const struct hid_usage_entry hid_usage_table[] = {
137 {0, 0x44, "BarrelSwitch"}, 137 {0, 0x44, "BarrelSwitch"},
138 {0, 0x45, "Eraser"}, 138 {0, 0x45, "Eraser"},
139 {0, 0x46, "TabletPick"}, 139 {0, 0x46, "TabletPick"},
140 {0, 0x47, "Confidence"},
141 {0, 0x48, "Width"},
142 {0, 0x49, "Height"},
143 {0, 0x51, "ContactID"},
144 {0, 0x52, "InputMode"},
145 {0, 0x53, "DeviceIndex"},
146 {0, 0x54, "ContactCount"},
147 {0, 0x55, "ContactMaximumNumber"},
140 { 15, 0, "PhysicalInterfaceDevice" }, 148 { 15, 0, "PhysicalInterfaceDevice" },
141 {0, 0x00, "Undefined"}, 149 {0, 0x00, "Undefined"},
142 {0, 0x01, "Physical_Interface_Device"}, 150 {0, 0x01, "Physical_Interface_Device"},
@@ -514,9 +522,11 @@ static const char *events[EV_MAX + 1] = {
514 [EV_FF_STATUS] = "ForceFeedbackStatus", 522 [EV_FF_STATUS] = "ForceFeedbackStatus",
515}; 523};
516 524
517static const char *syncs[2] = { 525static const char *syncs[3] = {
518 [SYN_REPORT] = "Report", [SYN_CONFIG] = "Config", 526 [SYN_REPORT] = "Report", [SYN_CONFIG] = "Config",
527 [SYN_MT_REPORT] = "MT Report",
519}; 528};
529
520static const char *keys[KEY_MAX + 1] = { 530static const char *keys[KEY_MAX + 1] = {
521 [KEY_RESERVED] = "Reserved", [KEY_ESC] = "Esc", 531 [KEY_RESERVED] = "Reserved", [KEY_ESC] = "Esc",
522 [KEY_1] = "1", [KEY_2] = "2", 532 [KEY_1] = "1", [KEY_2] = "2",
@@ -734,8 +744,17 @@ static const char *absolutes[ABS_MAX + 1] = {
734 [ABS_HAT2Y] = "Hat2Y", [ABS_HAT3X] = "Hat3X", 744 [ABS_HAT2Y] = "Hat2Y", [ABS_HAT3X] = "Hat3X",
735 [ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure", 745 [ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure",
736 [ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt", 746 [ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt",
737 [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "Tool Width", 747 [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "ToolWidth",
738 [ABS_VOLUME] = "Volume", [ABS_MISC] = "Misc", 748 [ABS_VOLUME] = "Volume", [ABS_MISC] = "Misc",
749 [ABS_MT_TOUCH_MAJOR] = "MTMajor",
750 [ABS_MT_TOUCH_MINOR] = "MTMinor",
751 [ABS_MT_WIDTH_MAJOR] = "MTMajorW",
752 [ABS_MT_WIDTH_MINOR] = "MTMinorW",
753 [ABS_MT_ORIENTATION] = "MTOrientation",
754 [ABS_MT_POSITION_X] = "MTPositionX",
755 [ABS_MT_POSITION_Y] = "MTPositionY",
756 [ABS_MT_TOOL_TYPE] = "MTToolType",
757 [ABS_MT_BLOB_ID] = "MTBlobID",
739}; 758};
740 759
741static const char *misc[MSC_MAX + 1] = { 760static const char *misc[MSC_MAX + 1] = {
diff --git a/drivers/hid/hid-drff.c b/drivers/hid/hid-drff.c
index 34f3eb65100b..a239d20ad7a5 100644
--- a/drivers/hid/hid-drff.c
+++ b/drivers/hid/hid-drff.c
@@ -32,6 +32,8 @@
32#include <linux/hid.h> 32#include <linux/hid.h>
33 33
34#include "hid-ids.h" 34#include "hid-ids.h"
35
36#ifdef CONFIG_DRAGONRISE_FF
35#include "usbhid/usbhid.h" 37#include "usbhid/usbhid.h"
36 38
37struct drff_device { 39struct drff_device {
@@ -135,6 +137,12 @@ static int drff_init(struct hid_device *hid)
135 137
136 return 0; 138 return 0;
137} 139}
140#else
141static inline int drff_init(struct hid_device *hid)
142{
143 return 0;
144}
145#endif
138 146
139static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id) 147static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id)
140{ 148{
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
index 510ad3ab8d33..8a11ccddaf2e 100644
--- a/drivers/hid/hid-gaff.c
+++ b/drivers/hid/hid-gaff.c
@@ -31,6 +31,8 @@
31#include <linux/usb.h> 31#include <linux/usb.h>
32#include <linux/hid.h> 32#include <linux/hid.h>
33#include "hid-ids.h" 33#include "hid-ids.h"
34
35#ifdef CONFIG_GREENASIA_FF
34#include "usbhid/usbhid.h" 36#include "usbhid/usbhid.h"
35 37
36struct gaff_device { 38struct gaff_device {
@@ -130,6 +132,12 @@ static int gaff_init(struct hid_device *hid)
130 132
131 return 0; 133 return 0;
132} 134}
135#else
136static inline int gaff_init(struct hid_device *hdev)
137{
138 return 0;
139}
140#endif
133 141
134static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id) 142static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
135{ 143{
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 4d5ee2bbc62b..630101037921 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -414,8 +414,10 @@
414#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 414#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
415 415
416#define USB_VENDOR_ID_WACOM 0x056a 416#define USB_VENDOR_ID_WACOM 0x056a
417#define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81
417 418
418#define USB_VENDOR_ID_WISEGROUP 0x0925 419#define USB_VENDOR_ID_WISEGROUP 0x0925
420#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005
419#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101 421#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101
420#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 422#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
421#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201 423#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
index 51aff08e10ce..56099709581c 100644
--- a/drivers/hid/hid-lgff.c
+++ b/drivers/hid/hid-lgff.c
@@ -50,6 +50,12 @@ static const signed short ff_joystick[] = {
50 -1 50 -1
51}; 51};
52 52
53static const signed short ff_joystick_ac[] = {
54 FF_CONSTANT,
55 FF_AUTOCENTER,
56 -1
57};
58
53static const signed short ff_wheel[] = { 59static const signed short ff_wheel[] = {
54 FF_CONSTANT, 60 FF_CONSTANT,
55 FF_AUTOCENTER, 61 FF_AUTOCENTER,
@@ -60,8 +66,8 @@ static const struct dev_type devices[] = {
60 { 0x046d, 0xc211, ff_rumble }, 66 { 0x046d, 0xc211, ff_rumble },
61 { 0x046d, 0xc219, ff_rumble }, 67 { 0x046d, 0xc219, ff_rumble },
62 { 0x046d, 0xc283, ff_joystick }, 68 { 0x046d, 0xc283, ff_joystick },
63 { 0x046d, 0xc286, ff_joystick }, 69 { 0x046d, 0xc286, ff_joystick_ac },
64 { 0x046d, 0xc294, ff_joystick }, 70 { 0x046d, 0xc294, ff_wheel },
65 { 0x046d, 0xc295, ff_joystick }, 71 { 0x046d, 0xc295, ff_joystick },
66 { 0x046d, 0xca03, ff_wheel }, 72 { 0x046d, 0xca03, ff_wheel },
67}; 73};
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index c5b252be9c21..75ed9d2c1a36 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -1,13 +1,8 @@
1/* 1/*
2 * HID driver for some ntrig "special" devices 2 * HID driver for N-Trig touchscreens
3 * 3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 * Copyright (c) 2008 Rafi Rubin 4 * Copyright (c) 2008 Rafi Rubin
5 * Copyright (c) 2009 Stephane Chatty
11 * 6 *
12 */ 7 */
13 8
@@ -29,15 +24,79 @@
29#define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ 24#define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
30 EV_KEY, (c)) 25 EV_KEY, (c))
31 26
27struct ntrig_data {
28 __s32 x, y, id, w, h;
29 char reading_a_point, found_contact_id;
30};
31
32/*
33 * this driver is aimed at two firmware versions in circulation:
34 * - dual pen/finger single touch
35 * - finger multitouch, pen not working
36 */
37
32static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, 38static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
33 struct hid_field *field, struct hid_usage *usage, 39 struct hid_field *field, struct hid_usage *usage,
34 unsigned long **bit, int *max) 40 unsigned long **bit, int *max)
35{ 41{
36 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_DIGITIZER && 42 switch (usage->hid & HID_USAGE_PAGE) {
37 (usage->hid & 0xff) == 0x47) { 43
38 nt_map_key_clear(BTN_TOOL_DOUBLETAP); 44 case HID_UP_GENDESK:
39 return 1; 45 switch (usage->hid) {
46 case HID_GD_X:
47 hid_map_usage(hi, usage, bit, max,
48 EV_ABS, ABS_MT_POSITION_X);
49 input_set_abs_params(hi->input, ABS_X,
50 field->logical_minimum,
51 field->logical_maximum, 0, 0);
52 return 1;
53 case HID_GD_Y:
54 hid_map_usage(hi, usage, bit, max,
55 EV_ABS, ABS_MT_POSITION_Y);
56 input_set_abs_params(hi->input, ABS_Y,
57 field->logical_minimum,
58 field->logical_maximum, 0, 0);
59 return 1;
60 }
61 return 0;
62
63 case HID_UP_DIGITIZER:
64 switch (usage->hid) {
65 /* we do not want to map these for now */
66 case HID_DG_INVERT: /* value is always 0 */
67 case HID_DG_ERASER: /* value is always 0 */
68 case HID_DG_CONTACTID: /* value is useless */
69 case HID_DG_BARRELSWITCH: /* doubtful */
70 case HID_DG_INPUTMODE:
71 case HID_DG_DEVICEINDEX:
72 case HID_DG_CONTACTCOUNT:
73 case HID_DG_CONTACTMAX:
74 return -1;
75
76 /* original mapping by Rafi Rubin */
77 case HID_DG_CONFIDENCE:
78 nt_map_key_clear(BTN_TOOL_DOUBLETAP);
79 return 1;
80
81 /* width/height mapped on TouchMajor/TouchMinor/Orientation */
82 case HID_DG_WIDTH:
83 hid_map_usage(hi, usage, bit, max,
84 EV_ABS, ABS_MT_TOUCH_MAJOR);
85 return 1;
86 case HID_DG_HEIGHT:
87 hid_map_usage(hi, usage, bit, max,
88 EV_ABS, ABS_MT_TOUCH_MINOR);
89 input_set_abs_params(hi->input, ABS_MT_ORIENTATION,
90 0, 1, 0, 0);
91 return 1;
92 }
93 return 0;
94
95 case 0xff000000:
96 /* we do not want to map these: no input-oriented meaning */
97 return -1;
40 } 98 }
99
41 return 0; 100 return 0;
42} 101}
43 102
@@ -51,6 +110,138 @@ static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi,
51 110
52 return 0; 111 return 0;
53} 112}
113
114/*
115 * this function is called upon all reports
116 * so that we can filter contact point information,
117 * decide whether we are in multi or single touch mode
118 * and call input_mt_sync after each point if necessary
119 */
120static int ntrig_event (struct hid_device *hid, struct hid_field *field,
121 struct hid_usage *usage, __s32 value)
122{
123 struct input_dev *input = field->hidinput->input;
124 struct ntrig_data *nd = hid_get_drvdata(hid);
125
126 if (hid->claimed & HID_CLAIMED_INPUT) {
127 switch (usage->hid) {
128 case HID_GD_X:
129 nd->x = value;
130 nd->reading_a_point = 1;
131 break;
132 case HID_GD_Y:
133 nd->y = value;
134 break;
135 case HID_DG_CONTACTID:
136 nd->id = value;
137 /* we receive this only when in multitouch mode */
138 nd->found_contact_id = 1;
139 break;
140 case HID_DG_WIDTH:
141 nd->w = value;
142 break;
143 case HID_DG_HEIGHT:
144 nd->h = value;
145 /*
146 * when in single touch mode, this is the last
147 * report received in a finger event. We want
148 * to emit a normal (X, Y) position
149 */
150 if (! nd->found_contact_id) {
151 input_event(input, EV_ABS, ABS_X, nd->x);
152 input_event(input, EV_ABS, ABS_Y, nd->y);
153 }
154 break;
155 case HID_DG_TIPPRESSURE:
156 /*
157 * when in single touch mode, this is the last
158 * report received in a pen event. We want
159 * to emit a normal (X, Y) position
160 */
161 if (! nd->found_contact_id) {
162 input_event(input, EV_ABS, ABS_X, nd->x);
163 input_event(input, EV_ABS, ABS_Y, nd->y);
164 input_event(input, EV_ABS, ABS_PRESSURE, value);
165 }
166 break;
167 case 0xff000002:
168 /*
169 * we receive this when the device is in multitouch
170 * mode. The first of the three values tagged with
171 * this usage tells if the contact point is real
172 * or a placeholder
173 */
174 if (!nd->reading_a_point || value != 1)
175 break;
176 /* emit a normal (X, Y) for the first point only */
177 if (nd->id == 0) {
178 input_event(input, EV_ABS, ABS_X, nd->x);
179 input_event(input, EV_ABS, ABS_Y, nd->y);
180 }
181 input_event(input, EV_ABS, ABS_MT_POSITION_X, nd->x);
182 input_event(input, EV_ABS, ABS_MT_POSITION_Y, nd->y);
183 if (nd->w > nd->h) {
184 input_event(input, EV_ABS,
185 ABS_MT_ORIENTATION, 1);
186 input_event(input, EV_ABS,
187 ABS_MT_TOUCH_MAJOR, nd->w);
188 input_event(input, EV_ABS,
189 ABS_MT_TOUCH_MINOR, nd->h);
190 } else {
191 input_event(input, EV_ABS,
192 ABS_MT_ORIENTATION, 0);
193 input_event(input, EV_ABS,
194 ABS_MT_TOUCH_MAJOR, nd->h);
195 input_event(input, EV_ABS,
196 ABS_MT_TOUCH_MINOR, nd->w);
197 }
198 input_mt_sync(field->hidinput->input);
199 nd->reading_a_point = 0;
200 nd->found_contact_id = 0;
201 break;
202
203 default:
204 /* fallback to the generic hidinput handling */
205 return 0;
206 }
207 }
208
209 /* we have handled the hidinput part, now remains hiddev */
210 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
211 hid->hiddev_hid_event(hid, field, usage, value);
212
213 return 1;
214}
215
216static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
217{
218 int ret;
219 struct ntrig_data *nd;
220
221 nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL);
222 if (!nd) {
223 dev_err(&hdev->dev, "cannot allocate N-Trig data\n");
224 return -ENOMEM;
225 }
226 nd->reading_a_point = 0;
227 nd->found_contact_id = 0;
228 hid_set_drvdata(hdev, nd);
229
230 ret = hid_parse(hdev);
231 if (!ret)
232 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
233
234 if (ret)
235 kfree (nd);
236 return ret;
237}
238
239static void ntrig_remove(struct hid_device *hdev)
240{
241 hid_hw_stop(hdev);
242 kfree(hid_get_drvdata(hdev));
243}
244
54static const struct hid_device_id ntrig_devices[] = { 245static const struct hid_device_id ntrig_devices[] = {
55 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN), 246 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN),
56 .driver_data = NTRIG_DUPLICATE_USAGES }, 247 .driver_data = NTRIG_DUPLICATE_USAGES },
@@ -58,11 +249,20 @@ static const struct hid_device_id ntrig_devices[] = {
58}; 249};
59MODULE_DEVICE_TABLE(hid, ntrig_devices); 250MODULE_DEVICE_TABLE(hid, ntrig_devices);
60 251
252static const struct hid_usage_id ntrig_grabbed_usages[] = {
253 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
254 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
255};
256
61static struct hid_driver ntrig_driver = { 257static struct hid_driver ntrig_driver = {
62 .name = "ntrig", 258 .name = "ntrig",
63 .id_table = ntrig_devices, 259 .id_table = ntrig_devices,
260 .probe = ntrig_probe,
261 .remove = ntrig_remove,
64 .input_mapping = ntrig_input_mapping, 262 .input_mapping = ntrig_input_mapping,
65 .input_mapped = ntrig_input_mapped, 263 .input_mapped = ntrig_input_mapped,
264 .usage_table = ntrig_grabbed_usages,
265 .event = ntrig_event,
66}; 266};
67 267
68static int ntrig_init(void) 268static int ntrig_init(void)
diff --git a/drivers/hid/hid-sjoy.c b/drivers/hid/hid-sjoy.c
new file mode 100644
index 000000000000..eab169e5c371
--- /dev/null
+++ b/drivers/hid/hid-sjoy.c
@@ -0,0 +1,180 @@
1/*
2 * Force feedback support for SmartJoy PLUS PS2->USB adapter
3 *
4 * Copyright (c) 2009 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
5 *
6 * Based of hid-pl.c and hid-gaff.c
7 * Copyright (c) 2007, 2009 Anssi Hannula <anssi.hannula@gmail.com>
8 * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
9 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27/* #define DEBUG */
28
29#include <linux/input.h>
30#include <linux/usb.h>
31#include <linux/hid.h>
32#include "hid-ids.h"
33
34#ifdef CONFIG_SMARTJOYPLUS_FF
35#include "usbhid/usbhid.h"
36
37struct sjoyff_device {
38 struct hid_report *report;
39};
40
41static int hid_sjoyff_play(struct input_dev *dev, void *data,
42 struct ff_effect *effect)
43{
44 struct hid_device *hid = input_get_drvdata(dev);
45 struct sjoyff_device *sjoyff = data;
46 u32 left, right;
47
48 left = effect->u.rumble.strong_magnitude;
49 right = effect->u.rumble.weak_magnitude;
50 dev_dbg(&dev->dev, "called with 0x%08x 0x%08x\n", left, right);
51
52 left = left * 0xff / 0xffff;
53 right = (right != 0); /* on/off only */
54
55 sjoyff->report->field[0]->value[1] = right;
56 sjoyff->report->field[0]->value[2] = left;
57 dev_dbg(&dev->dev, "running with 0x%02x 0x%02x\n", left, right);
58 usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT);
59
60 return 0;
61}
62
63static int sjoyff_init(struct hid_device *hid)
64{
65 struct sjoyff_device *sjoyff;
66 struct hid_report *report;
67 struct hid_input *hidinput = list_entry(hid->inputs.next,
68 struct hid_input, list);
69 struct list_head *report_list =
70 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
71 struct list_head *report_ptr = report_list;
72 struct input_dev *dev;
73 int error;
74
75 if (list_empty(report_list)) {
76 dev_err(&hid->dev, "no output reports found\n");
77 return -ENODEV;
78 }
79
80 report_ptr = report_ptr->next;
81
82 if (report_ptr == report_list) {
83 dev_err(&hid->dev, "required output report is "
84 "missing\n");
85 return -ENODEV;
86 }
87
88 report = list_entry(report_ptr, struct hid_report, list);
89 if (report->maxfield < 1) {
90 dev_err(&hid->dev, "no fields in the report\n");
91 return -ENODEV;
92 }
93
94 if (report->field[0]->report_count < 3) {
95 dev_err(&hid->dev, "not enough values in the field\n");
96 return -ENODEV;
97 }
98
99 sjoyff = kzalloc(sizeof(struct sjoyff_device), GFP_KERNEL);
100 if (!sjoyff)
101 return -ENOMEM;
102
103 dev = hidinput->input;
104
105 set_bit(FF_RUMBLE, dev->ffbit);
106
107 error = input_ff_create_memless(dev, sjoyff, hid_sjoyff_play);
108 if (error) {
109 kfree(sjoyff);
110 return error;
111 }
112
113 sjoyff->report = report;
114 sjoyff->report->field[0]->value[0] = 0x01;
115 sjoyff->report->field[0]->value[1] = 0x00;
116 sjoyff->report->field[0]->value[2] = 0x00;
117 usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT);
118
119 dev_info(&hid->dev,
120 "Force feedback for SmartJoy PLUS PS2/USB adapter\n");
121
122 return 0;
123}
124#else
125static inline int sjoyff_init(struct hid_device *hid)
126{
127 return 0;
128}
129#endif
130
131static int sjoy_probe(struct hid_device *hdev, const struct hid_device_id *id)
132{
133 int ret;
134
135 ret = hid_parse(hdev);
136 if (ret) {
137 dev_err(&hdev->dev, "parse failed\n");
138 goto err;
139 }
140
141 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
142 if (ret) {
143 dev_err(&hdev->dev, "hw start failed\n");
144 goto err;
145 }
146
147 sjoyff_init(hdev);
148
149 return 0;
150err:
151 return ret;
152}
153
154static const struct hid_device_id sjoy_devices[] = {
155 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
156 { }
157};
158MODULE_DEVICE_TABLE(hid, sjoy_devices);
159
160static struct hid_driver sjoy_driver = {
161 .name = "smartjoyplus",
162 .id_table = sjoy_devices,
163 .probe = sjoy_probe,
164};
165
166static int sjoy_init(void)
167{
168 return hid_register_driver(&sjoy_driver);
169}
170
171static void sjoy_exit(void)
172{
173 hid_unregister_driver(&sjoy_driver);
174}
175
176module_init(sjoy_init);
177module_exit(sjoy_exit);
178MODULE_LICENSE("GPL");
179MODULE_AUTHOR("Jussi Kivilinna");
180
diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
index 7c1f7b50330c..fcd6ccd02fee 100644
--- a/drivers/hid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -33,11 +33,6 @@
33 33
34#include "hid-ids.h" 34#include "hid-ids.h"
35 35
36#include "usbhid/usbhid.h"
37
38/* Usages for thrustmaster devices I know about */
39#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb)
40
41static const signed short ff_rumble[] = { 36static const signed short ff_rumble[] = {
42 FF_RUMBLE, 37 FF_RUMBLE,
43 -1 38 -1
@@ -48,6 +43,12 @@ static const signed short ff_joystick[] = {
48 -1 43 -1
49}; 44};
50 45
46#ifdef CONFIG_THRUSTMASTER_FF
47#include "usbhid/usbhid.h"
48
49/* Usages for thrustmaster devices I know about */
50#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb)
51
51struct tmff_device { 52struct tmff_device {
52 struct hid_report *report; 53 struct hid_report *report;
53 struct hid_field *ff_field; 54 struct hid_field *ff_field;
@@ -209,6 +210,12 @@ fail:
209 kfree(tmff); 210 kfree(tmff);
210 return error; 211 return error;
211} 212}
213#else
214static inline int tmff_init(struct hid_device *hid, const signed short *ff_bits)
215{
216 return 0;
217}
218#endif
212 219
213static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id) 220static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id)
214{ 221{
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
new file mode 100644
index 000000000000..1f9237f511e3
--- /dev/null
+++ b/drivers/hid/hid-wacom.c
@@ -0,0 +1,259 @@
1/*
2 * Bluetooth Wacom Tablet support
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
10 * Copyright (c) 2006 Andrew Zabolotny <zap@homelink.ru>
11 * Copyright (c) 2009 Bastien Nocera <hadess@hadess.net>
12 */
13
14/*
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option)
18 * any later version.
19 */
20
21#include <linux/device.h>
22#include <linux/hid.h>
23#include <linux/module.h>
24
25#include "hid-ids.h"
26
27struct wacom_data {
28 __u16 tool;
29 unsigned char butstate;
30};
31
32static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
33 u8 *raw_data, int size)
34{
35 struct wacom_data *wdata = hid_get_drvdata(hdev);
36 struct hid_input *hidinput;
37 struct input_dev *input;
38 unsigned char *data = (unsigned char *) raw_data;
39 int tool, x, y, rw;
40
41 if (!(hdev->claimed & HID_CLAIMED_INPUT))
42 return 0;
43
44 tool = 0;
45 hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
46 input = hidinput->input;
47
48 /* Check if this is a tablet report */
49 if (data[0] != 0x03)
50 return 0;
51
52 /* Get X & Y positions */
53 x = le16_to_cpu(*(__le16 *) &data[2]);
54 y = le16_to_cpu(*(__le16 *) &data[4]);
55
56 /* Get current tool identifier */
57 if (data[1] & 0x90) { /* If pen is in the in/active area */
58 switch ((data[1] >> 5) & 3) {
59 case 0: /* Pen */
60 tool = BTN_TOOL_PEN;
61 break;
62
63 case 1: /* Rubber */
64 tool = BTN_TOOL_RUBBER;
65 break;
66
67 case 2: /* Mouse with wheel */
68 case 3: /* Mouse without wheel */
69 tool = BTN_TOOL_MOUSE;
70 break;
71 }
72
73 /* Reset tool if out of active tablet area */
74 if (!(data[1] & 0x10))
75 tool = 0;
76 }
77
78 /* If tool changed, notify input subsystem */
79 if (wdata->tool != tool) {
80 if (wdata->tool) {
81 /* Completely reset old tool state */
82 if (wdata->tool == BTN_TOOL_MOUSE) {
83 input_report_key(input, BTN_LEFT, 0);
84 input_report_key(input, BTN_RIGHT, 0);
85 input_report_key(input, BTN_MIDDLE, 0);
86 input_report_abs(input, ABS_DISTANCE,
87 input->absmax[ABS_DISTANCE]);
88 } else {
89 input_report_key(input, BTN_TOUCH, 0);
90 input_report_key(input, BTN_STYLUS, 0);
91 input_report_key(input, BTN_STYLUS2, 0);
92 input_report_abs(input, ABS_PRESSURE, 0);
93 }
94 input_report_key(input, wdata->tool, 0);
95 input_sync(input);
96 }
97 wdata->tool = tool;
98 if (tool)
99 input_report_key(input, tool, 1);
100 }
101
102 if (tool) {
103 input_report_abs(input, ABS_X, x);
104 input_report_abs(input, ABS_Y, y);
105
106 switch ((data[1] >> 5) & 3) {
107 case 2: /* Mouse with wheel */
108 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
109 rw = (data[6] & 0x01) ? -1 :
110 (data[6] & 0x02) ? 1 : 0;
111 input_report_rel(input, REL_WHEEL, rw);
112 /* fall through */
113
114 case 3: /* Mouse without wheel */
115 input_report_key(input, BTN_LEFT, data[1] & 0x01);
116 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
117 /* Compute distance between mouse and tablet */
118 rw = 44 - (data[6] >> 2);
119 if (rw < 0)
120 rw = 0;
121 else if (rw > 31)
122 rw = 31;
123 input_report_abs(input, ABS_DISTANCE, rw);
124 break;
125
126 default:
127 input_report_abs(input, ABS_PRESSURE,
128 data[6] | (((__u16) (data[1] & 0x08)) << 5));
129 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
130 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
131 input_report_key(input, BTN_STYLUS2, (tool == BTN_TOOL_PEN) && data[1] & 0x04);
132 break;
133 }
134
135 input_sync(input);
136 }
137
138 /* Report the state of the two buttons at the top of the tablet
139 * as two extra fingerpad keys (buttons 4 & 5). */
140 rw = data[7] & 0x03;
141 if (rw != wdata->butstate) {
142 wdata->butstate = rw;
143 input_report_key(input, BTN_0, rw & 0x02);
144 input_report_key(input, BTN_1, rw & 0x01);
145 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
146 input_sync(input);
147 }
148
149 return 1;
150}
151
152static int wacom_probe(struct hid_device *hdev,
153 const struct hid_device_id *id)
154{
155 struct hid_input *hidinput;
156 struct input_dev *input;
157 struct wacom_data *wdata;
158 int ret;
159
160 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
161 if (wdata == NULL) {
162 dev_err(&hdev->dev, "can't alloc wacom descriptor\n");
163 return -ENOMEM;
164 }
165
166 hid_set_drvdata(hdev, wdata);
167
168 ret = hid_parse(hdev);
169 if (ret) {
170 dev_err(&hdev->dev, "parse failed\n");
171 goto err_free;
172 }
173
174 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
175 if (ret) {
176 dev_err(&hdev->dev, "hw start failed\n");
177 goto err_free;
178 }
179
180 hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
181 input = hidinput->input;
182
183 /* Basics */
184 input->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_REL);
185 input->absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) |
186 BIT(ABS_PRESSURE) | BIT(ABS_DISTANCE);
187 input->relbit[0] |= BIT(REL_WHEEL);
188 set_bit(BTN_TOOL_PEN, input->keybit);
189 set_bit(BTN_TOUCH, input->keybit);
190 set_bit(BTN_STYLUS, input->keybit);
191 set_bit(BTN_STYLUS2, input->keybit);
192 set_bit(BTN_LEFT, input->keybit);
193 set_bit(BTN_RIGHT, input->keybit);
194 set_bit(BTN_MIDDLE, input->keybit);
195
196 /* Pad */
197 input->evbit[0] |= BIT(EV_MSC);
198 input->mscbit[0] |= BIT(MSC_SERIAL);
199
200 /* Distance, rubber and mouse */
201 input->absbit[0] |= BIT(ABS_DISTANCE);
202 set_bit(BTN_TOOL_RUBBER, input->keybit);
203 set_bit(BTN_TOOL_MOUSE, input->keybit);
204
205 input->absmax[ABS_PRESSURE] = 511;
206 input->absmax[ABS_DISTANCE] = 32;
207
208 input->absmax[ABS_X] = 16704;
209 input->absmax[ABS_Y] = 12064;
210 input->absfuzz[ABS_X] = 4;
211 input->absfuzz[ABS_Y] = 4;
212
213 return 0;
214err_free:
215 kfree(wdata);
216 return ret;
217}
218
219static void wacom_remove(struct hid_device *hdev)
220{
221 hid_hw_stop(hdev);
222 kfree(hid_get_drvdata(hdev));
223}
224
225static const struct hid_device_id wacom_devices[] = {
226 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
227
228 { }
229};
230MODULE_DEVICE_TABLE(hid, wacom_devices);
231
232static struct hid_driver wacom_driver = {
233 .name = "wacom",
234 .id_table = wacom_devices,
235 .probe = wacom_probe,
236 .remove = wacom_remove,
237 .raw_event = wacom_raw_event,
238};
239
240static int wacom_init(void)
241{
242 int ret;
243
244 ret = hid_register_driver(&wacom_driver);
245 if (ret)
246 printk(KERN_ERR "can't register wacom driver\n");
247 printk(KERN_ERR "wacom driver registered\n");
248 return ret;
249}
250
251static void wacom_exit(void)
252{
253 hid_unregister_driver(&wacom_driver);
254}
255
256module_init(wacom_init);
257module_exit(wacom_exit);
258MODULE_LICENSE("GPL");
259
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
index 85a198a18537..57f710757bf4 100644
--- a/drivers/hid/hid-zpff.c
+++ b/drivers/hid/hid-zpff.c
@@ -27,6 +27,7 @@
27 27
28#include "hid-ids.h" 28#include "hid-ids.h"
29 29
30#ifdef CONFIG_ZEROPLUS_FF
30#include "usbhid/usbhid.h" 31#include "usbhid/usbhid.h"
31 32
32struct zpff_device { 33struct zpff_device {
@@ -108,6 +109,12 @@ static int zpff_init(struct hid_device *hid)
108 109
109 return 0; 110 return 0;
110} 111}
112#else
113static inline int zpff_init(struct hid_device *hid)
114{
115 return 0;
116}
117#endif
111 118
112static int zp_probe(struct hid_device *hdev, const struct hid_device_id *id) 119static int zp_probe(struct hid_device *hdev, const struct hid_device_id *id)
113{ 120{
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 00ccf4b1985d..0c6639ea03dd 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -349,10 +349,7 @@ int hidraw_connect(struct hid_device *hid)
349 int minor, result; 349 int minor, result;
350 struct hidraw *dev; 350 struct hidraw *dev;
351 351
352 /* TODO currently we accept any HID device. This should later 352 /* we accept any HID device, no matter the applications */
353 * probably be fixed to accept only those devices which provide
354 * non-input applications
355 */
356 353
357 dev = kzalloc(sizeof(struct hidraw), GFP_KERNEL); 354 dev = kzalloc(sizeof(struct hidraw), GFP_KERNEL);
358 if (!dev) 355 if (!dev)
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index ac8049b5f1e9..76c4bbe9dccb 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1234,12 +1234,11 @@ static int hid_post_reset(struct usb_interface *intf)
1234 struct hid_device *hid = usb_get_intfdata(intf); 1234 struct hid_device *hid = usb_get_intfdata(intf);
1235 struct usbhid_device *usbhid = hid->driver_data; 1235 struct usbhid_device *usbhid = hid->driver_data;
1236 int status; 1236 int status;
1237 1237
1238 spin_lock_irq(&usbhid->lock); 1238 spin_lock_irq(&usbhid->lock);
1239 clear_bit(HID_RESET_PENDING, &usbhid->iofl); 1239 clear_bit(HID_RESET_PENDING, &usbhid->iofl);
1240 spin_unlock_irq(&usbhid->lock); 1240 spin_unlock_irq(&usbhid->lock);
1241 hid_set_idle(dev, intf->cur_altsetting->desc.bInterfaceNumber, 0, 0); 1241 hid_set_idle(dev, intf->cur_altsetting->desc.bInterfaceNumber, 0, 0);
1242 /* FIXME: Any more reinitialization needed? */
1243 status = hid_start_in(hid); 1242 status = hid_start_in(hid);
1244 if (status < 0) 1243 if (status < 0)
1245 hid_io_error(hid); 1244 hid_io_error(hid);
@@ -1251,14 +1250,14 @@ static int hid_post_reset(struct usb_interface *intf)
1251int usbhid_get_power(struct hid_device *hid) 1250int usbhid_get_power(struct hid_device *hid)
1252{ 1251{
1253 struct usbhid_device *usbhid = hid->driver_data; 1252 struct usbhid_device *usbhid = hid->driver_data;
1254 1253
1255 return usb_autopm_get_interface(usbhid->intf); 1254 return usb_autopm_get_interface(usbhid->intf);
1256} 1255}
1257 1256
1258void usbhid_put_power(struct hid_device *hid) 1257void usbhid_put_power(struct hid_device *hid)
1259{ 1258{
1260 struct usbhid_device *usbhid = hid->driver_data; 1259 struct usbhid_device *usbhid = hid->driver_data;
1261 1260
1262 usb_autopm_put_interface(usbhid->intf); 1261 usb_autopm_put_interface(usbhid->intf);
1263} 1262}
1264 1263
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f1c6ca7e2852..c8460fa9cfac 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -298,7 +298,7 @@ config I2C_BLACKFIN_TWI
298config I2C_BLACKFIN_TWI_CLK_KHZ 298config I2C_BLACKFIN_TWI_CLK_KHZ
299 int "Blackfin TWI I2C clock (kHz)" 299 int "Blackfin TWI I2C clock (kHz)"
300 depends on I2C_BLACKFIN_TWI 300 depends on I2C_BLACKFIN_TWI
301 range 10 400 301 range 21 400
302 default 50 302 default 50
303 help 303 help
304 The unit of the TWI clock is kHz. 304 The unit of the TWI clock is kHz.
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index fc548b3d002e..26d8987e69bf 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -104,9 +104,14 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface)
104 write_MASTER_CTL(iface, 104 write_MASTER_CTL(iface,
105 read_MASTER_CTL(iface) | STOP); 105 read_MASTER_CTL(iface) | STOP);
106 else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && 106 else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
107 iface->cur_msg+1 < iface->msg_num) 107 iface->cur_msg + 1 < iface->msg_num) {
108 write_MASTER_CTL(iface, 108 if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
109 read_MASTER_CTL(iface) | RSTART); 109 write_MASTER_CTL(iface,
110 read_MASTER_CTL(iface) | RSTART | MDIR);
111 else
112 write_MASTER_CTL(iface,
113 (read_MASTER_CTL(iface) | RSTART) & ~MDIR);
114 }
110 SSYNC(); 115 SSYNC();
111 /* Clear status */ 116 /* Clear status */
112 write_INT_STAT(iface, XMTSERV); 117 write_INT_STAT(iface, XMTSERV);
@@ -134,9 +139,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface)
134 read_MASTER_CTL(iface) | STOP); 139 read_MASTER_CTL(iface) | STOP);
135 SSYNC(); 140 SSYNC();
136 } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && 141 } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
137 iface->cur_msg+1 < iface->msg_num) { 142 iface->cur_msg + 1 < iface->msg_num) {
138 write_MASTER_CTL(iface, 143 if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
139 read_MASTER_CTL(iface) | RSTART); 144 write_MASTER_CTL(iface,
145 read_MASTER_CTL(iface) | RSTART | MDIR);
146 else
147 write_MASTER_CTL(iface,
148 (read_MASTER_CTL(iface) | RSTART) & ~MDIR);
140 SSYNC(); 149 SSYNC();
141 } 150 }
142 /* Clear interrupt source */ 151 /* Clear interrupt source */
@@ -196,8 +205,6 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface)
196 /* remove restart bit and enable master receive */ 205 /* remove restart bit and enable master receive */
197 write_MASTER_CTL(iface, 206 write_MASTER_CTL(iface,
198 read_MASTER_CTL(iface) & ~RSTART); 207 read_MASTER_CTL(iface) & ~RSTART);
199 write_MASTER_CTL(iface,
200 read_MASTER_CTL(iface) | MEN | MDIR);
201 SSYNC(); 208 SSYNC();
202 } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && 209 } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
203 iface->cur_msg+1 < iface->msg_num) { 210 iface->cur_msg+1 < iface->msg_num) {
@@ -222,18 +229,19 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface)
222 } 229 }
223 230
224 if (iface->pmsg[iface->cur_msg].len <= 255) 231 if (iface->pmsg[iface->cur_msg].len <= 255)
225 write_MASTER_CTL(iface, 232 write_MASTER_CTL(iface,
226 iface->pmsg[iface->cur_msg].len << 6); 233 (read_MASTER_CTL(iface) &
234 (~(0xff << 6))) |
235 (iface->pmsg[iface->cur_msg].len << 6));
227 else { 236 else {
228 write_MASTER_CTL(iface, 0xff << 6); 237 write_MASTER_CTL(iface,
238 (read_MASTER_CTL(iface) |
239 (0xff << 6)));
229 iface->manual_stop = 1; 240 iface->manual_stop = 1;
230 } 241 }
231 /* remove restart bit and enable master receive */ 242 /* remove restart bit and enable master receive */
232 write_MASTER_CTL(iface, 243 write_MASTER_CTL(iface,
233 read_MASTER_CTL(iface) & ~RSTART); 244 read_MASTER_CTL(iface) & ~RSTART);
234 write_MASTER_CTL(iface, read_MASTER_CTL(iface) |
235 MEN | ((iface->read_write == I2C_SMBUS_READ) ?
236 MDIR : 0));
237 SSYNC(); 245 SSYNC();
238 } else { 246 } else {
239 iface->result = 1; 247 iface->result = 1;
@@ -441,6 +449,16 @@ int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr,
441 } 449 }
442 iface->transPtr = data->block; 450 iface->transPtr = data->block;
443 break; 451 break;
452 case I2C_SMBUS_I2C_BLOCK_DATA:
453 if (read_write == I2C_SMBUS_READ) {
454 iface->readNum = data->block[0];
455 iface->cur_mode = TWI_I2C_MODE_COMBINED;
456 } else {
457 iface->writeNum = data->block[0];
458 iface->cur_mode = TWI_I2C_MODE_STANDARDSUB;
459 }
460 iface->transPtr = (u8 *)&data->block[1];
461 break;
444 default: 462 default:
445 return -1; 463 return -1;
446 } 464 }
@@ -564,7 +582,7 @@ static u32 bfin_twi_functionality(struct i2c_adapter *adap)
564 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 582 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
565 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 583 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
566 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL | 584 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL |
567 I2C_FUNC_I2C; 585 I2C_FUNC_I2C | I2C_FUNC_SMBUS_I2C_BLOCK;
568} 586}
569 587
570static struct i2c_algorithm bfin_twi_algorithm = { 588static struct i2c_algorithm bfin_twi_algorithm = {
@@ -614,6 +632,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
614 struct i2c_adapter *p_adap; 632 struct i2c_adapter *p_adap;
615 struct resource *res; 633 struct resource *res;
616 int rc; 634 int rc;
635 unsigned int clkhilow;
617 636
618 iface = kzalloc(sizeof(struct bfin_twi_iface), GFP_KERNEL); 637 iface = kzalloc(sizeof(struct bfin_twi_iface), GFP_KERNEL);
619 if (!iface) { 638 if (!iface) {
@@ -675,10 +694,14 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
675 /* Set TWI internal clock as 10MHz */ 694 /* Set TWI internal clock as 10MHz */
676 write_CONTROL(iface, ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F); 695 write_CONTROL(iface, ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F);
677 696
697 /*
698 * We will not end up with a CLKDIV=0 because no one will specify
699 * 20kHz SCL or less in Kconfig now. (5 * 1024 / 20 = 0x100)
700 */
701 clkhilow = 5 * 1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ;
702
678 /* Set Twi interface clock as specified */ 703 /* Set Twi interface clock as specified */
679 write_CLKDIV(iface, ((5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ) 704 write_CLKDIV(iface, (clkhilow << 8) | clkhilow);
680 << 8) | ((5*1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ)
681 & 0xFF));
682 705
683 /* Enable TWI */ 706 /* Enable TWI */
684 write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA); 707 write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA);
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index e5193bf75483..3542c6ba98f1 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -216,6 +216,7 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
216 struct ocores_i2c_platform_data *pdata; 216 struct ocores_i2c_platform_data *pdata;
217 struct resource *res, *res2; 217 struct resource *res, *res2;
218 int ret; 218 int ret;
219 int i;
219 220
220 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 221 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
221 if (!res) 222 if (!res)
@@ -271,6 +272,10 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
271 goto add_adapter_failed; 272 goto add_adapter_failed;
272 } 273 }
273 274
275 /* add in known devices to the bus */
276 for (i = 0; i < pdata->num_devices; i++)
277 i2c_new_device(&i2c->adap, pdata->devices + i);
278
274 return 0; 279 return 0;
275 280
276add_adapter_failed: 281add_adapter_failed:
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index ece0125a1ee5..c73475dd0fba 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -333,8 +333,18 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
333 333
334 if (cpu_is_omap2430() || cpu_is_omap34xx()) { 334 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
335 335
336 /* HSI2C controller internal clk rate should be 19.2 Mhz */ 336 /*
337 internal_clk = 19200; 337 * HSI2C controller internal clk rate should be 19.2 Mhz for
338 * HS and for all modes on 2430. On 34xx we can use lower rate
339 * to get longer filter period for better noise suppression.
340 * The filter is iclk (fclk for HS) period.
341 */
342 if (dev->speed > 400 || cpu_is_omap_2430())
343 internal_clk = 19200;
344 else if (dev->speed > 100)
345 internal_clk = 9600;
346 else
347 internal_clk = 4000;
338 fclk_rate = clk_get_rate(dev->fclk) / 1000; 348 fclk_rate = clk_get_rate(dev->fclk) / 1000;
339 349
340 /* Compute prescaler divisor */ 350 /* Compute prescaler divisor */
@@ -343,17 +353,28 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
343 353
344 /* If configured for High Speed */ 354 /* If configured for High Speed */
345 if (dev->speed > 400) { 355 if (dev->speed > 400) {
356 unsigned long scl;
357
346 /* For first phase of HS mode */ 358 /* For first phase of HS mode */
347 fsscll = internal_clk / (400 * 2) - 6; 359 scl = internal_clk / 400;
348 fssclh = internal_clk / (400 * 2) - 6; 360 fsscll = scl - (scl / 3) - 7;
361 fssclh = (scl / 3) - 5;
349 362
350 /* For second phase of HS mode */ 363 /* For second phase of HS mode */
351 hsscll = fclk_rate / (dev->speed * 2) - 6; 364 scl = fclk_rate / dev->speed;
352 hssclh = fclk_rate / (dev->speed * 2) - 6; 365 hsscll = scl - (scl / 3) - 7;
366 hssclh = (scl / 3) - 5;
367 } else if (dev->speed > 100) {
368 unsigned long scl;
369
370 /* Fast mode */
371 scl = internal_clk / dev->speed;
372 fsscll = scl - (scl / 3) - 7;
373 fssclh = (scl / 3) - 5;
353 } else { 374 } else {
354 /* To handle F/S modes */ 375 /* Standard mode */
355 fsscll = internal_clk / (dev->speed * 2) - 6; 376 fsscll = internal_clk / (dev->speed * 2) - 7;
356 fssclh = internal_clk / (dev->speed * 2) - 6; 377 fssclh = internal_clk / (dev->speed * 2) - 5;
357 } 378 }
358 scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll; 379 scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
359 sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh; 380 sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index acc7143d9655..035a6c7e59df 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -34,10 +34,24 @@
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36 36
37#include <mach/hardware.h>
38#include <asm/irq.h> 37#include <asm/irq.h>
39#include <asm/io.h> 38#include <asm/io.h>
40#include <mach/i2c.h> 39#include <plat/i2c.h>
40
41/*
42 * I2C register offsets will be shifted 0 or 1 bit left, depending on
43 * different SoCs
44 */
45#define REG_SHIFT_0 (0 << 0)
46#define REG_SHIFT_1 (1 << 0)
47#define REG_SHIFT(d) ((d) & 0x1)
48
49static const struct platform_device_id i2c_pxa_id_table[] = {
50 { "pxa2xx-i2c", REG_SHIFT_1 },
51 { "pxa3xx-pwri2c", REG_SHIFT_0 },
52 { },
53};
54MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
41 55
42/* 56/*
43 * I2C registers and bit definitions 57 * I2C registers and bit definitions
@@ -985,6 +999,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
985 struct pxa_i2c *i2c; 999 struct pxa_i2c *i2c;
986 struct resource *res; 1000 struct resource *res;
987 struct i2c_pxa_platform_data *plat = dev->dev.platform_data; 1001 struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
1002 struct platform_device_id *id = platform_get_device_id(dev);
988 int ret; 1003 int ret;
989 int irq; 1004 int irq;
990 1005
@@ -1028,7 +1043,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
1028 ret = -EIO; 1043 ret = -EIO;
1029 goto eremap; 1044 goto eremap;
1030 } 1045 }
1031 i2c->reg_shift = (cpu_is_pxa3xx() && (dev->id == 1)) ? 0 : 1; 1046 i2c->reg_shift = REG_SHIFT(id->driver_data);
1032 1047
1033 i2c->iobase = res->start; 1048 i2c->iobase = res->start;
1034 i2c->iosize = res_len(res); 1049 i2c->iosize = res_len(res);
@@ -1150,6 +1165,7 @@ static struct platform_driver i2c_pxa_driver = {
1150 .name = "pxa2xx-i2c", 1165 .name = "pxa2xx-i2c",
1151 .owner = THIS_MODULE, 1166 .owner = THIS_MODULE,
1152 }, 1167 },
1168 .id_table = i2c_pxa_id_table,
1153}; 1169};
1154 1170
1155static int __init i2c_adap_pxa_init(void) 1171static int __init i2c_adap_pxa_init(void)
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1691ef0f1ee1..079a312d36fd 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -51,6 +51,11 @@ enum s3c24xx_i2c_state {
51 STATE_STOP 51 STATE_STOP
52}; 52};
53 53
54enum s3c24xx_i2c_type {
55 TYPE_S3C2410,
56 TYPE_S3C2440,
57};
58
54struct s3c24xx_i2c { 59struct s3c24xx_i2c {
55 spinlock_t lock; 60 spinlock_t lock;
56 wait_queue_head_t wait; 61 wait_queue_head_t wait;
@@ -88,8 +93,10 @@ struct s3c24xx_i2c {
88static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c) 93static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
89{ 94{
90 struct platform_device *pdev = to_platform_device(i2c->dev); 95 struct platform_device *pdev = to_platform_device(i2c->dev);
96 enum s3c24xx_i2c_type type;
91 97
92 return !strcmp(pdev->name, "s3c2440-i2c"); 98 type = platform_get_device_id(pdev)->driver_data;
99 return type == TYPE_S3C2440;
93} 100}
94 101
95/* s3c24xx_i2c_master_complete 102/* s3c24xx_i2c_master_complete
@@ -969,52 +976,41 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
969 976
970/* device driver for platform bus bits */ 977/* device driver for platform bus bits */
971 978
972static struct platform_driver s3c2410_i2c_driver = { 979static struct platform_device_id s3c24xx_driver_ids[] = {
973 .probe = s3c24xx_i2c_probe, 980 {
974 .remove = s3c24xx_i2c_remove, 981 .name = "s3c2410-i2c",
975 .suspend_late = s3c24xx_i2c_suspend_late, 982 .driver_data = TYPE_S3C2410,
976 .resume = s3c24xx_i2c_resume, 983 }, {
977 .driver = { 984 .name = "s3c2440-i2c",
978 .owner = THIS_MODULE, 985 .driver_data = TYPE_S3C2440,
979 .name = "s3c2410-i2c", 986 }, { },
980 },
981}; 987};
988MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
982 989
983static struct platform_driver s3c2440_i2c_driver = { 990static struct platform_driver s3c24xx_i2c_driver = {
984 .probe = s3c24xx_i2c_probe, 991 .probe = s3c24xx_i2c_probe,
985 .remove = s3c24xx_i2c_remove, 992 .remove = s3c24xx_i2c_remove,
986 .suspend_late = s3c24xx_i2c_suspend_late, 993 .suspend_late = s3c24xx_i2c_suspend_late,
987 .resume = s3c24xx_i2c_resume, 994 .resume = s3c24xx_i2c_resume,
995 .id_table = s3c24xx_driver_ids,
988 .driver = { 996 .driver = {
989 .owner = THIS_MODULE, 997 .owner = THIS_MODULE,
990 .name = "s3c2440-i2c", 998 .name = "s3c-i2c",
991 }, 999 },
992}; 1000};
993 1001
994static int __init i2c_adap_s3c_init(void) 1002static int __init i2c_adap_s3c_init(void)
995{ 1003{
996 int ret; 1004 return platform_driver_register(&s3c24xx_i2c_driver);
997
998 ret = platform_driver_register(&s3c2410_i2c_driver);
999 if (ret == 0) {
1000 ret = platform_driver_register(&s3c2440_i2c_driver);
1001 if (ret)
1002 platform_driver_unregister(&s3c2410_i2c_driver);
1003 }
1004
1005 return ret;
1006} 1005}
1007subsys_initcall(i2c_adap_s3c_init); 1006subsys_initcall(i2c_adap_s3c_init);
1008 1007
1009static void __exit i2c_adap_s3c_exit(void) 1008static void __exit i2c_adap_s3c_exit(void)
1010{ 1009{
1011 platform_driver_unregister(&s3c2410_i2c_driver); 1010 platform_driver_unregister(&s3c24xx_i2c_driver);
1012 platform_driver_unregister(&s3c2440_i2c_driver);
1013} 1011}
1014module_exit(i2c_adap_s3c_exit); 1012module_exit(i2c_adap_s3c_exit);
1015 1013
1016MODULE_DESCRIPTION("S3C24XX I2C Bus driver"); 1014MODULE_DESCRIPTION("S3C24XX I2C Bus driver");
1017MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); 1015MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
1018MODULE_LICENSE("GPL"); 1016MODULE_LICENSE("GPL");
1019MODULE_ALIAS("platform:s3c2410-i2c");
1020MODULE_ALIAS("platform:s3c2440-i2c");
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index cf06494bb744..9a5d0aaac9d0 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -46,7 +46,7 @@ menuconfig IDE
46 SMART parameters from disk drives. 46 SMART parameters from disk drives.
47 47
48 To compile this driver as a module, choose M here: the 48 To compile this driver as a module, choose M here: the
49 module will be called ide-core.ko. 49 module will be called ide-core.
50 50
51 For further information, please read <file:Documentation/ide/ide.txt>. 51 For further information, please read <file:Documentation/ide/ide.txt>.
52 52
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index bbdd2547f12a..702ef64a0f12 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -577,7 +577,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
577 577
578 /* 578 /*
579 * If necessary schedule the packet transfer to occur 'timeout' 579 * If necessary schedule the packet transfer to occur 'timeout'
580 * miliseconds later in ide_delayed_transfer_pc() after the 580 * milliseconds later in ide_delayed_transfer_pc() after the
581 * device says it's ready for a packet. 581 * device says it's ready for a packet.
582 */ 582 */
583 if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { 583 if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) {
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5c0a631d1455..06f46fcc0772 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -232,7 +232,7 @@ config INPUT_GPIO_ROTARY_ENCODER
232 depends on GPIOLIB && GENERIC_GPIO 232 depends on GPIOLIB && GENERIC_GPIO
233 help 233 help
234 Say Y here to add support for rotary encoders connected to GPIO lines. 234 Say Y here to add support for rotary encoders connected to GPIO lines.
235 Check file:Documentation/incput/rotary_encoder.txt for more 235 Check file:Documentation/input/rotary-encoder.txt for more
236 information. 236 information.
237 237
238 To compile this driver as a module, choose M here: the 238 To compile this driver as a module, choose M here: the
diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
index a28c06d686e1..89b394183a75 100644
--- a/drivers/input/serio/ambakmi.c
+++ b/drivers/input/serio/ambakmi.c
@@ -135,7 +135,7 @@ static int amba_kmi_probe(struct amba_device *dev, struct amba_id *id)
135 io->dev.parent = &dev->dev; 135 io->dev.parent = &dev->dev;
136 136
137 kmi->io = io; 137 kmi->io = io;
138 kmi->base = ioremap(dev->res.start, KMI_SIZE); 138 kmi->base = ioremap(dev->res.start, resource_size(&dev->res));
139 if (!kmi->base) { 139 if (!kmi->base) {
140 ret = -ENOMEM; 140 ret = -ENOMEM;
141 goto out; 141 goto out;
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 7d97d54588d9..77e9fdda0597 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -183,7 +183,7 @@ int cf_command(int drvid, int mode,
183 (mode != 1) ? "" : " 0 ", 183 (mode != 1) ? "" : " 0 ",
184 (mode != 1) ? "" : fwd_nr); 184 (mode != 1) ? "" : fwd_nr);
185 185
186 retval = divert_if.ll_cmd(&cs->ics); /* excute command */ 186 retval = divert_if.ll_cmd(&cs->ics); /* execute command */
187 187
188 if (!retval) 188 if (!retval)
189 { cs->prev = NULL; 189 { cs->prev = NULL;
diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c
index 3083338716b2..47dbfe298b43 100644
--- a/drivers/isdn/mISDN/dsp_core.c
+++ b/drivers/isdn/mISDN/dsp_core.c
@@ -502,7 +502,7 @@ tone_off:
502 break; 502 break;
503 } 503 }
504 dsp->cmx_delay = (*((int *)data)) << 3; 504 dsp->cmx_delay = (*((int *)data)) << 3;
505 /* miliseconds to samples */ 505 /* milliseconds to samples */
506 if (dsp->cmx_delay >= (CMX_BUFF_HALF>>1)) 506 if (dsp->cmx_delay >= (CMX_BUFF_HALF>>1))
507 /* clip to half of maximum usable buffer 507 /* clip to half of maximum usable buffer
508 (half of half buffer) */ 508 (half of half buffer) */
diff --git a/drivers/leds/leds-h1940.c b/drivers/leds/leds-h1940.c
index 1aa46a390a0d..173d104d9ff2 100644
--- a/drivers/leds/leds-h1940.c
+++ b/drivers/leds/leds-h1940.c
@@ -16,6 +16,8 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/ctype.h> 17#include <linux/ctype.h>
18#include <linux/leds.h> 18#include <linux/leds.h>
19#include <linux/gpio.h>
20
19#include <mach/regs-gpio.h> 21#include <mach/regs-gpio.h>
20#include <mach/hardware.h> 22#include <mach/hardware.h>
21#include <mach/h1940-latch.h> 23#include <mach/h1940-latch.h>
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index aa2e7ae0cdae..aa7acf3b9224 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/leds.h> 17#include <linux/leds.h>
18#include <linux/gpio.h>
18 19
19#include <mach/hardware.h> 20#include <mach/hardware.h>
20#include <mach/regs-gpio.h> 21#include <mach/regs-gpio.h>
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 60955a70d880..1bb66e1ed5a7 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -216,7 +216,7 @@ config DVB_USB_TTUSB2
216 help 216 help
217 Say Y here to support the Pinnacle 400e DVB-S USB2.0 receiver. The 217 Say Y here to support the Pinnacle 400e DVB-S USB2.0 receiver. The
218 firmware protocol used by this module is similar to the one used by the 218 firmware protocol used by this module is similar to the one used by the
219 old ttusb-driver - that's why the module is called dvb-usb-ttusb2.ko. 219 old ttusb-driver - that's why the module is called dvb-usb-ttusb2.
220 220
221config DVB_USB_DTT200U 221config DVB_USB_DTT200U
222 tristate "WideView WT-200U and WT-220U (pen) DVB-T USB2.0 support (Yakumo/Hama/Typhoon/Yuan)" 222 tristate "WideView WT-200U and WT-220U (pen) DVB-T USB2.0 support (Yakumo/Hama/Typhoon/Yuan)"
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9d48da2fb013..57835f5715fc 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -758,10 +758,14 @@ config VIDEO_MX1
758 ---help--- 758 ---help---
759 This is a v4l2 driver for the i.MX1/i.MXL CMOS Sensor Interface 759 This is a v4l2 driver for the i.MX1/i.MXL CMOS Sensor Interface
760 760
761config MX3_VIDEO
762 bool
763
761config VIDEO_MX3 764config VIDEO_MX3
762 tristate "i.MX3x Camera Sensor Interface driver" 765 tristate "i.MX3x Camera Sensor Interface driver"
763 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA 766 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA
764 select VIDEOBUF_DMA_CONTIG 767 select VIDEOBUF_DMA_CONTIG
768 select MX3_VIDEO
765 ---help--- 769 ---help---
766 This is a v4l2 driver for the i.MX3x Camera Sensor Interface 770 This is a v4l2 driver for the i.MX3x Camera Sensor Interface
767 771
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index 3e6ffee8dfed..ccd47f57f42c 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -181,7 +181,7 @@ static int hdpvr_submit_buffers(struct hdpvr_device *dev)
181 buff_list); 181 buff_list);
182 if (buf->status != BUFSTAT_AVAILABLE) { 182 if (buf->status != BUFSTAT_AVAILABLE) {
183 v4l2_err(&dev->v4l2_dev, 183 v4l2_err(&dev->v4l2_dev,
184 "buffer not marked as availbale\n"); 184 "buffer not marked as available\n");
185 ret = -EFAULT; 185 ret = -EFAULT;
186 goto err; 186 goto err;
187 } 187 }
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt
index 693e4b511354..fa9249b4971a 100644
--- a/drivers/message/fusion/lsi/mpi_history.txt
+++ b/drivers/message/fusion/lsi/mpi_history.txt
@@ -130,7 +130,7 @@ mpi_ioc.h
130 * 08-08-01 01.02.01 Original release for v1.2 work. 130 * 08-08-01 01.02.01 Original release for v1.2 work.
131 * New format for FWVersion and ProductId in 131 * New format for FWVersion and ProductId in
132 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER. 132 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER.
133 * 08-31-01 01.02.02 Addded event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and 133 * 08-31-01 01.02.02 Added event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and
134 * related structure and defines. 134 * related structure and defines.
135 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED. 135 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED.
136 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE. 136 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE.
@@ -190,7 +190,7 @@ mpi_ioc.h
190 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED. 190 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED.
191 * Added MaxInitiators field to PortFacts reply. 191 * Added MaxInitiators field to PortFacts reply.
192 * Added SAS Device Status Change ReasonCode for 192 * Added SAS Device Status Change ReasonCode for
193 * asynchronous notificaiton. 193 * asynchronous notification.
194 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event 194 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event
195 * data structure. 195 * data structure.
196 * Added new ImageType values for FWDownload and FWUpload 196 * Added new ImageType values for FWDownload and FWUpload
@@ -623,7 +623,7 @@ mpi_fc.h
623 * 11-02-00 01.01.01 Original release for post 1.0 work 623 * 11-02-00 01.01.01 Original release for post 1.0 work
624 * 12-04-00 01.01.02 Added messages for Common Transport Send and 624 * 12-04-00 01.01.02 Added messages for Common Transport Send and
625 * Primitive Send. 625 * Primitive Send.
626 * 01-09-01 01.01.03 Modifed some of the new flags to have an MPI prefix 626 * 01-09-01 01.01.03 Modified some of the new flags to have an MPI prefix
627 * and modified the FcPrimitiveSend flags. 627 * and modified the FcPrimitiveSend flags.
628 * 01-25-01 01.01.04 Move InitiatorIndex in LinkServiceRsp reply to a larger 628 * 01-25-01 01.01.04 Move InitiatorIndex in LinkServiceRsp reply to a larger
629 * field. 629 * field.
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 660bda0c5a1e..40111a6d8d5b 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -166,7 +166,7 @@ config MMC_ATMELMCI_DMA
166 166
167config MMC_IMX 167config MMC_IMX
168 tristate "Motorola i.MX Multimedia Card Interface support" 168 tristate "Motorola i.MX Multimedia Card Interface support"
169 depends on ARCH_IMX 169 depends on ARCH_MX1
170 help 170 help
171 This selects the Motorola i.MX Multimedia card Interface. 171 This selects the Motorola i.MX Multimedia card Interface.
172 If you have a i.MX platform with a Multimedia Card slot, 172 If you have a i.MX platform with a Multimedia Card slot,
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index cf6a100bb38f..7b603e4b41db 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -177,6 +177,7 @@ struct atmel_mci {
177 * available. 177 * available.
178 * @wp_pin: GPIO pin used for card write protect sending, or negative 178 * @wp_pin: GPIO pin used for card write protect sending, or negative
179 * if not available. 179 * if not available.
180 * @detect_is_active_high: The state of the detect pin when it is active.
180 * @detect_timer: Timer used for debouncing @detect_pin interrupts. 181 * @detect_timer: Timer used for debouncing @detect_pin interrupts.
181 */ 182 */
182struct atmel_mci_slot { 183struct atmel_mci_slot {
@@ -196,6 +197,7 @@ struct atmel_mci_slot {
196 197
197 int detect_pin; 198 int detect_pin;
198 int wp_pin; 199 int wp_pin;
200 bool detect_is_active_high;
199 201
200 struct timer_list detect_timer; 202 struct timer_list detect_timer;
201}; 203};
@@ -924,7 +926,8 @@ static int atmci_get_cd(struct mmc_host *mmc)
924 struct atmel_mci_slot *slot = mmc_priv(mmc); 926 struct atmel_mci_slot *slot = mmc_priv(mmc);
925 927
926 if (gpio_is_valid(slot->detect_pin)) { 928 if (gpio_is_valid(slot->detect_pin)) {
927 present = !gpio_get_value(slot->detect_pin); 929 present = !(gpio_get_value(slot->detect_pin) ^
930 slot->detect_is_active_high);
928 dev_dbg(&mmc->class_dev, "card is %spresent\n", 931 dev_dbg(&mmc->class_dev, "card is %spresent\n",
929 present ? "" : "not "); 932 present ? "" : "not ");
930 } 933 }
@@ -1028,7 +1031,8 @@ static void atmci_detect_change(unsigned long data)
1028 return; 1031 return;
1029 1032
1030 enable_irq(gpio_to_irq(slot->detect_pin)); 1033 enable_irq(gpio_to_irq(slot->detect_pin));
1031 present = !gpio_get_value(slot->detect_pin); 1034 present = !(gpio_get_value(slot->detect_pin) ^
1035 slot->detect_is_active_high);
1032 present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags); 1036 present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags);
1033 1037
1034 dev_vdbg(&slot->mmc->class_dev, "detect change: %d (was %d)\n", 1038 dev_vdbg(&slot->mmc->class_dev, "detect change: %d (was %d)\n",
@@ -1456,6 +1460,7 @@ static int __init atmci_init_slot(struct atmel_mci *host,
1456 slot->host = host; 1460 slot->host = host;
1457 slot->detect_pin = slot_data->detect_pin; 1461 slot->detect_pin = slot_data->detect_pin;
1458 slot->wp_pin = slot_data->wp_pin; 1462 slot->wp_pin = slot_data->wp_pin;
1463 slot->detect_is_active_high = slot_data->detect_is_active_high;
1459 slot->sdc_reg = sdc_reg; 1464 slot->sdc_reg = sdc_reg;
1460 1465
1461 mmc->ops = &atmci_ops; 1466 mmc->ops = &atmci_ops;
@@ -1477,7 +1482,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
1477 if (gpio_request(slot->detect_pin, "mmc_detect")) { 1482 if (gpio_request(slot->detect_pin, "mmc_detect")) {
1478 dev_dbg(&mmc->class_dev, "no detect pin available\n"); 1483 dev_dbg(&mmc->class_dev, "no detect pin available\n");
1479 slot->detect_pin = -EBUSY; 1484 slot->detect_pin = -EBUSY;
1480 } else if (gpio_get_value(slot->detect_pin)) { 1485 } else if (gpio_get_value(slot->detect_pin) ^
1486 slot->detect_is_active_high) {
1481 clear_bit(ATMCI_CARD_PRESENT, &slot->flags); 1487 clear_bit(ATMCI_CARD_PRESENT, &slot->flags);
1482 } 1488 }
1483 } 1489 }
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 7d4febdab286..e1aa8471ab1c 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -546,7 +546,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
546 host->mclk = clk_get_rate(host->clk); 546 host->mclk = clk_get_rate(host->clk);
547 DBG(host, "eventual mclk rate: %u Hz\n", host->mclk); 547 DBG(host, "eventual mclk rate: %u Hz\n", host->mclk);
548 } 548 }
549 host->base = ioremap(dev->res.start, SZ_4K); 549 host->base = ioremap(dev->res.start, resource_size(&dev->res));
550 if (!host->base) { 550 if (!host->base) {
551 ret = -ENOMEM; 551 ret = -ENOMEM;
552 goto clk_disable; 552 goto clk_disable;
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index c40cb96255a2..1cf9cfb3b64f 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1073,7 +1073,6 @@ static int __init omap_mmc_probe(struct platform_device *pdev)
1073 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; 1073 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
1074 mmc->max_seg_size = mmc->max_req_size; 1074 mmc->max_seg_size = mmc->max_req_size;
1075 1075
1076 mmc->ocr_avail = mmc_slot(host).ocr_mask;
1077 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED; 1076 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
1078 1077
1079 if (pdata->slots[host->slot_id].wires >= 8) 1078 if (pdata->slots[host->slot_id].wires >= 8)
@@ -1110,13 +1109,14 @@ static int __init omap_mmc_probe(struct platform_device *pdev)
1110 goto err_irq; 1109 goto err_irq;
1111 } 1110 }
1112 1111
1112 /* initialize power supplies, gpios, etc */
1113 if (pdata->init != NULL) { 1113 if (pdata->init != NULL) {
1114 if (pdata->init(&pdev->dev) != 0) { 1114 if (pdata->init(&pdev->dev) != 0) {
1115 dev_dbg(mmc_dev(host->mmc), 1115 dev_dbg(mmc_dev(host->mmc), "late init error\n");
1116 "Unable to configure MMC IRQs\n");
1117 goto err_irq_cd_init; 1116 goto err_irq_cd_init;
1118 } 1117 }
1119 } 1118 }
1119 mmc->ocr_avail = mmc_slot(host).ocr_mask;
1120 1120
1121 /* Request IRQ for card detect */ 1121 /* Request IRQ for card detect */
1122 if ((mmc_slot(host).card_detect_irq)) { 1122 if ((mmc_slot(host).card_detect_irq)) {
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
index 2db166b7096f..4eb4f37544ab 100644
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -17,6 +17,7 @@
17#include <linux/mmc/host.h> 17#include <linux/mmc/host.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/cpufreq.h> 19#include <linux/cpufreq.h>
20#include <linux/gpio.h>
20#include <linux/irq.h> 21#include <linux/irq.h>
21#include <linux/io.h> 22#include <linux/io.h>
22 23
@@ -789,7 +790,7 @@ static void s3cmci_dma_setup(struct s3cmci_host *host,
789 790
790 last_source = source; 791 last_source = source;
791 792
792 s3c2410_dma_devconfig(host->dma, source, 3, 793 s3c2410_dma_devconfig(host->dma, source,
793 host->mem->start + host->sdidata); 794 host->mem->start + host->sdidata);
794 795
795 if (!setup_ok) { 796 if (!setup_ok) {
@@ -1121,7 +1122,7 @@ static void s3cmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1121 case MMC_POWER_OFF: 1122 case MMC_POWER_OFF:
1122 default: 1123 default:
1123 s3c2410_gpio_setpin(S3C2410_GPE5, 0); 1124 s3c2410_gpio_setpin(S3C2410_GPE5, 0);
1124 s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_OUTP); 1125 s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPIO_OUTPUT);
1125 1126
1126 if (host->is2440) 1127 if (host->is2440)
1127 mci_con |= S3C2440_SDICON_SDRESET; 1128 mci_con |= S3C2440_SDICON_SDRESET;
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 7d04fb9ddcaa..b8e35a0b4d72 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -154,7 +154,8 @@ config MTD_AFS_PARTS
154 154
155 You will still need the parsing functions to be called by the driver 155 You will still need the parsing functions to be called by the driver
156 for your particular device. It won't happen automatically. The 156 for your particular device. It won't happen automatically. The
157 'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example. 157 'armflash' map driver (CONFIG_MTD_ARM_INTEGRATOR) does this, for
158 example.
158 159
159config MTD_OF_PARTS 160config MTD_OF_PARTS
160 tristate "Flash partition map based on OF description" 161 tristate "Flash partition map based on OF description"
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 6fde0a2e3567..325fab92a62c 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -49,7 +49,7 @@ config MTD_MS02NV
49 If you want to compile this driver as a module ( = code which can be 49 If you want to compile this driver as a module ( = code which can be
50 inserted in and removed from the running kernel whenever you want), 50 inserted in and removed from the running kernel whenever you want),
51 say M here and read <file:Documentation/kbuild/modules.txt>. 51 say M here and read <file:Documentation/kbuild/modules.txt>.
52 The module will be called ms02-nv.ko. 52 The module will be called ms02-nv.
53 53
54config MTD_DATAFLASH 54config MTD_DATAFLASH
55 tristate "Support for AT45xxx DataFlash" 55 tristate "Support for AT45xxx DataFlash"
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 890936d0275e..f3276897859e 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -260,7 +260,7 @@ config MTD_NAND_BASLER_EXCITE
260 help 260 help
261 This enables the driver for the NAND flash device found on the 261 This enables the driver for the NAND flash device found on the
262 Basler eXcite Smart Camera. If built as a module, the driver 262 Basler eXcite Smart Camera. If built as a module, the driver
263 will be named "excite_nandflash.ko". 263 will be named excite_nandflash.
264 264
265config MTD_NAND_CAFE 265config MTD_NAND_CAFE
266 tristate "NAND support for OLPC CAFÉ chip" 266 tristate "NAND support for OLPC CAFÉ chip"
@@ -282,7 +282,7 @@ config MTD_NAND_CS553X
282 controller is enabled for NAND, and currently requires that 282 controller is enabled for NAND, and currently requires that
283 the controller be in MMIO mode. 283 the controller be in MMIO mode.
284 284
285 If you say "m", the module will be called "cs553x_nand.ko". 285 If you say "m", the module will be called cs553x_nand.
286 286
287config MTD_NAND_ATMEL 287config MTD_NAND_ATMEL
288 tristate "Support for NAND Flash / SmartMedia on AT91 and AVR32" 288 tristate "Support for NAND Flash / SmartMedia on AT91 and AVR32"
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index f2e9de1414df..6391e3dc8002 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -39,7 +39,6 @@
39#include <mach/gpmc.h> 39#include <mach/gpmc.h>
40#include <mach/onenand.h> 40#include <mach/onenand.h>
41#include <mach/gpio.h> 41#include <mach/gpio.h>
42#include <mach/pm.h>
43 42
44#include <mach/dma.h> 43#include <mach/dma.h>
45 44
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index f3c4a3b910bb..3111b6c7cbc3 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1880,7 +1880,7 @@ config FEC_MPC52xx
1880 ---help--- 1880 ---help---
1881 This option enables support for the MPC5200's on-chip 1881 This option enables support for the MPC5200's on-chip
1882 Fast Ethernet Controller 1882 Fast Ethernet Controller
1883 If compiled as module, it will be called 'fec_mpc52xx.ko'. 1883 If compiled as module, it will be called fec_mpc52xx.
1884 1884
1885config FEC_MPC52xx_MDIO 1885config FEC_MPC52xx_MDIO
1886 bool "MPC52xx FEC MDIO bus driver" 1886 bool "MPC52xx FEC MDIO bus driver"
@@ -1892,7 +1892,7 @@ config FEC_MPC52xx_MDIO
1892 (Motorola? industry standard). 1892 (Motorola? industry standard).
1893 If your board uses an external PHY connected to FEC, enable this. 1893 If your board uses an external PHY connected to FEC, enable this.
1894 If not sure, enable. 1894 If not sure, enable.
1895 If compiled as module, it will be called 'fec_mpc52xx_phy.ko'. 1895 If compiled as module, it will be called fec_mpc52xx_phy.
1896 1896
1897config NE_H8300 1897config NE_H8300
1898 tristate "NE2000 compatible support for H8/300" 1898 tristate "NE2000 compatible support for H8/300"
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index 78cc71469136..b642647170be 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -1220,7 +1220,7 @@ static int __init ltpc_setup(char *str)
1220 if (ints[0] > 2) { 1220 if (ints[0] > 2) {
1221 dma = ints[3]; 1221 dma = ints[3];
1222 } 1222 }
1223 /* ignore any other paramters */ 1223 /* ignore any other parameters */
1224 } 1224 }
1225 return 1; 1225 return 1;
1226} 1226}
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index a740053d3af3..b6d188115caf 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -456,7 +456,8 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
456 debug_desc(phys, desc); 456 debug_desc(phys, desc);
457 BUG_ON(phys & 0x1F); 457 BUG_ON(phys & 0x1F);
458 qmgr_put_entry(queue, phys); 458 qmgr_put_entry(queue, phys);
459 BUG_ON(qmgr_stat_overflow(queue)); 459 /* Don't check for queue overflow here, we've allocated sufficient
460 length and queues >= 32 don't support this check anyway. */
460} 461}
461 462
462 463
@@ -512,8 +513,8 @@ static int eth_poll(struct napi_struct *napi, int budget)
512#endif 513#endif
513 napi_complete(napi); 514 napi_complete(napi);
514 qmgr_enable_irq(rxq); 515 qmgr_enable_irq(rxq);
515 if (!qmgr_stat_empty(rxq) && 516 if (!qmgr_stat_below_low_watermark(rxq) &&
516 napi_reschedule(napi)) { 517 napi_reschedule(napi)) { /* not empty again */
517#if DEBUG_RX 518#if DEBUG_RX
518 printk(KERN_DEBUG "%s: eth_poll" 519 printk(KERN_DEBUG "%s: eth_poll"
519 " napi_reschedule successed\n", 520 " napi_reschedule successed\n",
@@ -630,9 +631,9 @@ static void eth_txdone_irq(void *unused)
630 port->tx_buff_tab[n_desc] = NULL; 631 port->tx_buff_tab[n_desc] = NULL;
631 } 632 }
632 633
633 start = qmgr_stat_empty(port->plat->txreadyq); 634 start = qmgr_stat_below_low_watermark(port->plat->txreadyq);
634 queue_put_desc(port->plat->txreadyq, phys, desc); 635 queue_put_desc(port->plat->txreadyq, phys, desc);
635 if (start) { 636 if (start) { /* TX-ready queue was empty */
636#if DEBUG_TX 637#if DEBUG_TX
637 printk(KERN_DEBUG "%s: eth_txdone_irq xmit ready\n", 638 printk(KERN_DEBUG "%s: eth_txdone_irq xmit ready\n",
638 port->netdev->name); 639 port->netdev->name);
@@ -708,13 +709,14 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev)
708 queue_put_desc(TX_QUEUE(port->id), tx_desc_phys(port, n), desc); 709 queue_put_desc(TX_QUEUE(port->id), tx_desc_phys(port, n), desc);
709 dev->trans_start = jiffies; 710 dev->trans_start = jiffies;
710 711
711 if (qmgr_stat_empty(txreadyq)) { 712 if (qmgr_stat_below_low_watermark(txreadyq)) { /* empty */
712#if DEBUG_TX 713#if DEBUG_TX
713 printk(KERN_DEBUG "%s: eth_xmit queue full\n", dev->name); 714 printk(KERN_DEBUG "%s: eth_xmit queue full\n", dev->name);
714#endif 715#endif
715 netif_stop_queue(dev); 716 netif_stop_queue(dev);
716 /* we could miss TX ready interrupt */ 717 /* we could miss TX ready interrupt */
717 if (!qmgr_stat_empty(txreadyq)) { 718 /* really empty in fact */
719 if (!qmgr_stat_below_low_watermark(txreadyq)) {
718#if DEBUG_TX 720#if DEBUG_TX
719 printk(KERN_DEBUG "%s: eth_xmit ready again\n", 721 printk(KERN_DEBUG "%s: eth_xmit ready again\n",
720 dev->name); 722 dev->name);
@@ -814,29 +816,29 @@ static int request_queues(struct port *port)
814 int err; 816 int err;
815 817
816 err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0, 818 err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0,
817 "%s:RX-free", port->netdev->name); 819 "%s:RX-free", port->netdev->name);
818 if (err) 820 if (err)
819 return err; 821 return err;
820 822
821 err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0, 823 err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0,
822 "%s:RX", port->netdev->name); 824 "%s:RX", port->netdev->name);
823 if (err) 825 if (err)
824 goto rel_rxfree; 826 goto rel_rxfree;
825 827
826 err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0, 828 err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0,
827 "%s:TX", port->netdev->name); 829 "%s:TX", port->netdev->name);
828 if (err) 830 if (err)
829 goto rel_rx; 831 goto rel_rx;
830 832
831 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0, 833 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0,
832 "%s:TX-ready", port->netdev->name); 834 "%s:TX-ready", port->netdev->name);
833 if (err) 835 if (err)
834 goto rel_tx; 836 goto rel_tx;
835 837
836 /* TX-done queue handles skbs sent out by the NPEs */ 838 /* TX-done queue handles skbs sent out by the NPEs */
837 if (!ports_open) { 839 if (!ports_open) {
838 err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0, 840 err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0,
839 "%s:TX-done", DRV_NAME); 841 "%s:TX-done", DRV_NAME);
840 if (err) 842 if (err)
841 goto rel_txready; 843 goto rel_txready;
842 } 844 }
diff --git a/drivers/net/b44.h b/drivers/net/b44.h
index e678498de6db..d24158e7f309 100644
--- a/drivers/net/b44.h
+++ b/drivers/net/b44.h
@@ -97,7 +97,7 @@
97#define B44_DMARX_STAT 0x021CUL /* DMA RX Current Active Desc. + Status */ 97#define B44_DMARX_STAT 0x021CUL /* DMA RX Current Active Desc. + Status */
98#define DMARX_STAT_CDMASK 0x00000fff /* Current Descriptor Mask */ 98#define DMARX_STAT_CDMASK 0x00000fff /* Current Descriptor Mask */
99#define DMARX_STAT_SMASK 0x0000f000 /* State Mask */ 99#define DMARX_STAT_SMASK 0x0000f000 /* State Mask */
100#define DMARX_STAT_SDISABLED 0x00000000 /* State Disbaled */ 100#define DMARX_STAT_SDISABLED 0x00000000 /* State Disabled */
101#define DMARX_STAT_SACTIVE 0x00001000 /* State Active */ 101#define DMARX_STAT_SACTIVE 0x00001000 /* State Active */
102#define DMARX_STAT_SIDLE 0x00002000 /* State Idle Wait */ 102#define DMARX_STAT_SIDLE 0x00002000 /* State Idle Wait */
103#define DMARX_STAT_SSTOPPED 0x00003000 /* State Stopped */ 103#define DMARX_STAT_SSTOPPED 0x00003000 /* State Stopped */
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 8d740376bbd2..44f77eb1180f 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -25,6 +25,8 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/ethtool.h> 26#include <linux/ethtool.h>
27#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
28#include <linux/module.h>
29
28#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 30#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
29#define BCM_VLAN 1 31#define BCM_VLAN 1
30#endif 32#endif
@@ -1454,6 +1456,7 @@ static inline u16 cnic_get_vlan(struct net_device *dev,
1454static int cnic_get_v4_route(struct sockaddr_in *dst_addr, 1456static int cnic_get_v4_route(struct sockaddr_in *dst_addr,
1455 struct dst_entry **dst) 1457 struct dst_entry **dst)
1456{ 1458{
1459#if defined(CONFIG_INET)
1457 struct flowi fl; 1460 struct flowi fl;
1458 int err; 1461 int err;
1459 struct rtable *rt; 1462 struct rtable *rt;
@@ -1465,12 +1468,15 @@ static int cnic_get_v4_route(struct sockaddr_in *dst_addr,
1465 if (!err) 1468 if (!err)
1466 *dst = &rt->u.dst; 1469 *dst = &rt->u.dst;
1467 return err; 1470 return err;
1471#else
1472 return -ENETUNREACH;
1473#endif
1468} 1474}
1469 1475
1470static int cnic_get_v6_route(struct sockaddr_in6 *dst_addr, 1476static int cnic_get_v6_route(struct sockaddr_in6 *dst_addr,
1471 struct dst_entry **dst) 1477 struct dst_entry **dst)
1472{ 1478{
1473#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1479#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
1474 struct flowi fl; 1480 struct flowi fl;
1475 1481
1476 memset(&fl, 0, sizeof(fl)); 1482 memset(&fl, 0, sizeof(fl));
@@ -1550,7 +1556,7 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr)
1550 clear_bit(SK_F_IPV6, &csk->flags); 1556 clear_bit(SK_F_IPV6, &csk->flags);
1551 1557
1552 if (is_v6) { 1558 if (is_v6) {
1553#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1559#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
1554 set_bit(SK_F_IPV6, &csk->flags); 1560 set_bit(SK_F_IPV6, &csk->flags);
1555 err = cnic_get_v6_route(&saddr->remote.v6, &dst); 1561 err = cnic_get_v6_route(&saddr->remote.v6, &dst);
1556 if (err) 1562 if (err)
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 0f9ee1348552..af5364f49550 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2785,7 +2785,7 @@ static int e100_resume(struct pci_dev *pdev)
2785 /* ack any pending wake events, disable PME */ 2785 /* ack any pending wake events, disable PME */
2786 pci_enable_wake(pdev, 0, 0); 2786 pci_enable_wake(pdev, 0, 0);
2787 2787
2788 /* disbale reverse auto-negotiation */ 2788 /* disable reverse auto-negotiation */
2789 if (nic->phy == phy_82552_v) { 2789 if (nic->phy == phy_82552_v) {
2790 u16 smartspeed = mdio_read(netdev, nic->mii.phy_id, 2790 u16 smartspeed = mdio_read(netdev, nic->mii.phy_id,
2791 E100_82552_SMARTSPEED); 2791 E100_82552_SMARTSPEED);
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index f37360aa12a8..44f0bf23dafc 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -62,7 +62,7 @@ struct e1000_info;
62 e_printk(KERN_NOTICE, adapter, format, ## arg) 62 e_printk(KERN_NOTICE, adapter, format, ## arg)
63 63
64 64
65/* Interrupt modes, as used by the IntMode paramter */ 65/* Interrupt modes, as used by the IntMode parameter */
66#define E1000E_INT_MODE_LEGACY 0 66#define E1000E_INT_MODE_LEGACY 0
67#define E1000E_INT_MODE_MSI 1 67#define E1000E_INT_MODE_MSI 1
68#define E1000E_INT_MODE_MSIX 2 68#define E1000E_INT_MODE_MSIX 2
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 16a41389575a..78952f8324e2 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -268,7 +268,7 @@ struct ehea_qp_init_attr {
268}; 268};
269 269
270/* 270/*
271 * Event Queue attributes, passed as paramter 271 * Event Queue attributes, passed as parameter
272 */ 272 */
273struct ehea_eq_attr { 273struct ehea_eq_attr {
274 u32 type; 274 u32 type;
diff --git a/drivers/net/igbvf/igbvf.h b/drivers/net/igbvf/igbvf.h
index 4bff35e46871..d488733893a6 100644
--- a/drivers/net/igbvf/igbvf.h
+++ b/drivers/net/igbvf/igbvf.h
@@ -45,7 +45,7 @@ struct igbvf_adapter;
45/* Interrupt defines */ 45/* Interrupt defines */
46#define IGBVF_START_ITR 648 /* ~6000 ints/sec */ 46#define IGBVF_START_ITR 648 /* ~6000 ints/sec */
47 47
48/* Interrupt modes, as used by the IntMode paramter */ 48/* Interrupt modes, as used by the IntMode parameter */
49#define IGBVF_INT_MODE_LEGACY 0 49#define IGBVF_INT_MODE_LEGACY 0
50#define IGBVF_INT_MODE_MSI 1 50#define IGBVF_INT_MODE_MSI 1
51#define IGBVF_INT_MODE_MSIX 2 51#define IGBVF_INT_MODE_MSIX 2
diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h
index dd9318f19497..dfc2541bb556 100644
--- a/drivers/net/ipg.h
+++ b/drivers/net/ipg.h
@@ -514,7 +514,7 @@ enum ipg_regs {
514#define IPG_DMALIST_ALIGN_PAD 0x07 514#define IPG_DMALIST_ALIGN_PAD 0x07
515#define IPG_MULTICAST_HASHTABLE_SIZE 0x40 515#define IPG_MULTICAST_HASHTABLE_SIZE 0x40
516 516
517/* Number of miliseconds to wait after issuing a software reset. 517/* Number of milliseconds to wait after issuing a software reset.
518 * 0x05 <= IPG_AC_RESETWAIT to account for proper 10Mbps operation. 518 * 0x05 <= IPG_AC_RESETWAIT to account for proper 10Mbps operation.
519 */ 519 */
520#define IPG_AC_RESETWAIT 0x05 520#define IPG_AC_RESETWAIT 0x05
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 7bcc49de1637..e8eeef0c9c9a 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -371,7 +371,7 @@ static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)
371 int i; 371 int i;
372 372
373 /* If we haven't received a specific coalescing setting 373 /* If we haven't received a specific coalescing setting
374 * (module param), we set the moderation paramters as follows: 374 * (module param), we set the moderation parameters as follows:
375 * - moder_cnt is set to the number of mtu sized packets to 375 * - moder_cnt is set to the number of mtu sized packets to
376 * satisfy our coelsing target. 376 * satisfy our coelsing target.
377 * - moder_time is set to a fixed value. 377 * - moder_time is set to a fixed value.
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index 8754e44cadae..3bd0b5933d59 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -3242,8 +3242,8 @@ struct niu {
3242 struct niu_parent *parent; 3242 struct niu_parent *parent;
3243 3243
3244 u32 flags; 3244 u32 flags;
3245#define NIU_FLAGS_HOTPLUG_PHY_PRESENT 0x02000000 /* Removebale PHY detected*/ 3245#define NIU_FLAGS_HOTPLUG_PHY_PRESENT 0x02000000 /* Removeable PHY detected*/
3246#define NIU_FLAGS_HOTPLUG_PHY 0x01000000 /* Removebale PHY */ 3246#define NIU_FLAGS_HOTPLUG_PHY 0x01000000 /* Removeable PHY */
3247#define NIU_FLAGS_VPD_VALID 0x00800000 /* VPD has valid version */ 3247#define NIU_FLAGS_VPD_VALID 0x00800000 /* VPD has valid version */
3248#define NIU_FLAGS_MSIX 0x00400000 /* MSI-X in use */ 3248#define NIU_FLAGS_MSIX 0x00400000 /* MSI-X in use */
3249#define NIU_FLAGS_MCAST 0x00200000 /* multicast filter enabled */ 3249#define NIU_FLAGS_MCAST 0x00200000 /* multicast filter enabled */
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index c92ced247947..1fd5ecb24425 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -3174,7 +3174,7 @@ static int ql_adapter_reset(struct ql_adapter *qdev)
3174 3174
3175 if (value & RST_FO_FR) { 3175 if (value & RST_FO_FR) {
3176 QPRINTK(qdev, IFDOWN, ERR, 3176 QPRINTK(qdev, IFDOWN, ERR,
3177 "ETIMEOUT!!! errored out of resetting the chip!\n"); 3177 "ETIMEDOUT!!! errored out of resetting the chip!\n");
3178 status = -ETIMEDOUT; 3178 status = -ETIMEDOUT;
3179 } 3179 }
3180 3180
diff --git a/drivers/net/qlge/qlge_mpi.c b/drivers/net/qlge/qlge_mpi.c
index 9f81b797f10b..ac9493f6c1a1 100644
--- a/drivers/net/qlge/qlge_mpi.c
+++ b/drivers/net/qlge/qlge_mpi.c
@@ -141,7 +141,7 @@ end:
141/* We are being asked by firmware to accept 141/* We are being asked by firmware to accept
142 * a change to the port. This is only 142 * a change to the port. This is only
143 * a change to max frame sizes (Tx/Rx), pause 143 * a change to max frame sizes (Tx/Rx), pause
144 * paramters, or loopback mode. We wake up a worker 144 * parameters, or loopback mode. We wake up a worker
145 * to handler processing this since a mailbox command 145 * to handler processing this since a mailbox command
146 * will need to be sent to ACK the request. 146 * will need to be sent to ACK the request.
147 */ 147 */
@@ -371,7 +371,7 @@ static int ql_mpi_handler(struct ql_adapter *qdev, struct mbox_params *mbcp)
371 /* We are being asked by firmware to accept 371 /* We are being asked by firmware to accept
372 * a change to the port. This is only 372 * a change to the port. This is only
373 * a change to max frame sizes (Tx/Rx), pause 373 * a change to max frame sizes (Tx/Rx), pause
374 * paramters, or loopback mode. 374 * parameters, or loopback mode.
375 */ 375 */
376 case AEN_IDC_REQ: 376 case AEN_IDC_REQ:
377 status = ql_idc_req_aen(qdev); 377 status = ql_idc_req_aen(qdev);
@@ -380,7 +380,7 @@ static int ql_mpi_handler(struct ql_adapter *qdev, struct mbox_params *mbcp)
380 /* Process and inbound IDC event. 380 /* Process and inbound IDC event.
381 * This will happen when we're trying to 381 * This will happen when we're trying to
382 * change tx/rx max frame size, change pause 382 * change tx/rx max frame size, change pause
383 * paramters or loopback mode. 383 * parameters or loopback mode.
384 */ 384 */
385 case AEN_IDC_CMPLT: 385 case AEN_IDC_CMPLT:
386 case AEN_IDC_EXT: 386 case AEN_IDC_EXT:
diff --git a/drivers/net/skfp/h/smt.h b/drivers/net/skfp/h/smt.h
index 1ff589988d10..2976757a36fb 100644
--- a/drivers/net/skfp/h/smt.h
+++ b/drivers/net/skfp/h/smt.h
@@ -413,7 +413,7 @@ struct smt_p_reason {
413#define SMT_RDF_SUCCESS 0x00000003 /* success (PMF) */ 413#define SMT_RDF_SUCCESS 0x00000003 /* success (PMF) */
414#define SMT_RDF_BADSET 0x00000004 /* bad set count (PMF) */ 414#define SMT_RDF_BADSET 0x00000004 /* bad set count (PMF) */
415#define SMT_RDF_ILLEGAL 0x00000005 /* read only (PMF) */ 415#define SMT_RDF_ILLEGAL 0x00000005 /* read only (PMF) */
416#define SMT_RDF_NOPARAM 0x6 /* paramter not supported (PMF) */ 416#define SMT_RDF_NOPARAM 0x6 /* parameter not supported (PMF) */
417#define SMT_RDF_RANGE 0x8 /* out of range */ 417#define SMT_RDF_RANGE 0x8 /* out of range */
418#define SMT_RDF_AUTHOR 0x9 /* not autohorized */ 418#define SMT_RDF_AUTHOR 0x9 /* not autohorized */
419#define SMT_RDF_LENGTH 0x0a /* length error */ 419#define SMT_RDF_LENGTH 0x0a /* length error */
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 329f890e2903..f1f773b17fe1 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -45,7 +45,8 @@
45 defined(CONFIG_MACH_ZYLONITE) ||\ 45 defined(CONFIG_MACH_ZYLONITE) ||\
46 defined(CONFIG_MACH_LITTLETON) ||\ 46 defined(CONFIG_MACH_LITTLETON) ||\
47 defined(CONFIG_MACH_ZYLONITE2) ||\ 47 defined(CONFIG_MACH_ZYLONITE2) ||\
48 defined(CONFIG_ARCH_VIPER) 48 defined(CONFIG_ARCH_VIPER) ||\
49 defined(CONFIG_MACH_STARGATE2)
49 50
50#include <asm/mach-types.h> 51#include <asm/mach-types.h>
51 52
@@ -73,7 +74,7 @@
73/* We actually can't write halfwords properly if not word aligned */ 74/* We actually can't write halfwords properly if not word aligned */
74static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) 75static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg)
75{ 76{
76 if (machine_is_mainstone() && reg & 2) { 77 if ((machine_is_mainstone() || machine_is_stargate2()) && reg & 2) {
77 unsigned int v = val << 16; 78 unsigned int v = val << 16;
78 v |= readl(ioaddr + (reg & ~2)) & 0xffff; 79 v |= readl(ioaddr + (reg & ~2)) & 0xffff;
79 writel(v, ioaddr + (reg & ~2)); 80 writel(v, ioaddr + (reg & ~2));
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 534c0f38483c..0337b9d673f4 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -79,7 +79,7 @@ MODULE_AUTHOR("Mike Phillips <mikep@linuxtr.net>") ;
79MODULE_DESCRIPTION("3Com 3C359 Velocity XL Token Ring Adapter Driver \n") ; 79MODULE_DESCRIPTION("3Com 3C359 Velocity XL Token Ring Adapter Driver \n") ;
80MODULE_FIRMWARE(FW_NAME); 80MODULE_FIRMWARE(FW_NAME);
81 81
82/* Module paramters */ 82/* Module parameters */
83 83
84/* Ring Speed 0,4,16 84/* Ring Speed 0,4,16
85 * 0 = Autosense 85 * 0 = Autosense
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 2e70ee8f1459..46a2cc92d979 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -169,7 +169,7 @@ static char *open_min_error[] = {
169 "Monitor Contention failer for RPL", "FDX Protocol Error" 169 "Monitor Contention failer for RPL", "FDX Protocol Error"
170}; 170};
171 171
172/* Module paramters */ 172/* Module parameters */
173 173
174/* Ring Speed 0,4,16 174/* Ring Speed 0,4,16
175 * 0 = Autosense 175 * 0 = Autosense
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index d068a9d36883..2d819fc85589 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -132,7 +132,7 @@ static char *open_min_error[] = {"No error", "Function Failure", "Signal Lost",
132 "Reserved", "Reserved", "No Monitor Detected for RPL", 132 "Reserved", "Reserved", "No Monitor Detected for RPL",
133 "Monitor Contention failer for RPL", "FDX Protocol Error"}; 133 "Monitor Contention failer for RPL", "FDX Protocol Error"};
134 134
135/* Module paramters */ 135/* Module parameters */
136 136
137MODULE_AUTHOR("Mike Phillips <mikep@linuxtr.net>") ; 137MODULE_AUTHOR("Mike Phillips <mikep@linuxtr.net>") ;
138MODULE_DESCRIPTION("Olympic PCI/Cardbus Chipset Driver") ; 138MODULE_DESCRIPTION("Olympic PCI/Cardbus Chipset Driver") ;
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
index 6fcb500257bc..61fe80dda3e3 100644
--- a/drivers/net/ucc_geth_ethtool.c
+++ b/drivers/net/ucc_geth_ethtool.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Limitation: 8 * Limitation:
9 * Can only get/set setttings of the first queue. 9 * Can only get/set setttings of the first queue.
10 * Need to re-open the interface manually after changing some paramters. 10 * Need to re-open the interface manually after changing some parameters.
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index f3a2fce6166c..47f68cfa7e21 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -398,7 +398,7 @@ static void rx_complete (struct urb *urb)
398 398
399 /* stalls need manual reset. this is rare ... except that 399 /* stalls need manual reset. this is rare ... except that
400 * when going through USB 2.0 TTs, unplug appears this way. 400 * when going through USB 2.0 TTs, unplug appears this way.
401 * we avoid the highspeed version of the ETIMEOUT/EILSEQ 401 * we avoid the highspeed version of the ETIMEDOUT/EILSEQ
402 * storm, recovering as needed. 402 * storm, recovering as needed.
403 */ 403 */
404 case -EPIPE: 404 case -EPIPE:
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index 765a7f5d6aa4..a6dc317083d3 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -579,7 +579,8 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
579 debug_desc(phys, desc); 579 debug_desc(phys, desc);
580 BUG_ON(phys & 0x1F); 580 BUG_ON(phys & 0x1F);
581 qmgr_put_entry(queue, phys); 581 qmgr_put_entry(queue, phys);
582 BUG_ON(qmgr_stat_overflow(queue)); 582 /* Don't check for queue overflow here, we've allocated sufficient
583 length and queues >= 32 don't support this check anyway. */
583} 584}
584 585
585 586
@@ -789,10 +790,10 @@ static void hss_hdlc_txdone_irq(void *pdev)
789 free_buffer_irq(port->tx_buff_tab[n_desc]); 790 free_buffer_irq(port->tx_buff_tab[n_desc]);
790 port->tx_buff_tab[n_desc] = NULL; 791 port->tx_buff_tab[n_desc] = NULL;
791 792
792 start = qmgr_stat_empty(port->plat->txreadyq); 793 start = qmgr_stat_below_low_watermark(port->plat->txreadyq);
793 queue_put_desc(port->plat->txreadyq, 794 queue_put_desc(port->plat->txreadyq,
794 tx_desc_phys(port, n_desc), desc); 795 tx_desc_phys(port, n_desc), desc);
795 if (start) { 796 if (start) { /* TX-ready queue was empty */
796#if DEBUG_TX 797#if DEBUG_TX
797 printk(KERN_DEBUG "%s: hss_hdlc_txdone_irq xmit" 798 printk(KERN_DEBUG "%s: hss_hdlc_txdone_irq xmit"
798 " ready\n", dev->name); 799 " ready\n", dev->name);
@@ -867,13 +868,13 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
867 queue_put_desc(queue_ids[port->id].tx, tx_desc_phys(port, n), desc); 868 queue_put_desc(queue_ids[port->id].tx, tx_desc_phys(port, n), desc);
868 dev->trans_start = jiffies; 869 dev->trans_start = jiffies;
869 870
870 if (qmgr_stat_empty(txreadyq)) { 871 if (qmgr_stat_below_low_watermark(txreadyq)) { /* empty */
871#if DEBUG_TX 872#if DEBUG_TX
872 printk(KERN_DEBUG "%s: hss_hdlc_xmit queue full\n", dev->name); 873 printk(KERN_DEBUG "%s: hss_hdlc_xmit queue full\n", dev->name);
873#endif 874#endif
874 netif_stop_queue(dev); 875 netif_stop_queue(dev);
875 /* we could miss TX ready interrupt */ 876 /* we could miss TX ready interrupt */
876 if (!qmgr_stat_empty(txreadyq)) { 877 if (!qmgr_stat_below_low_watermark(txreadyq)) {
877#if DEBUG_TX 878#if DEBUG_TX
878 printk(KERN_DEBUG "%s: hss_hdlc_xmit ready again\n", 879 printk(KERN_DEBUG "%s: hss_hdlc_xmit ready again\n",
879 dev->name); 880 dev->name);
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 3d94e7dfea69..3359497012aa 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -310,7 +310,7 @@ config PRISM54
310 If you want to compile the driver as a module ( = code which can be 310 If you want to compile the driver as a module ( = code which can be
311 inserted in and removed from the running kernel whenever you want), 311 inserted in and removed from the running kernel whenever you want),
312 say M here and read <file:Documentation/kbuild/modules.txt>. 312 say M here and read <file:Documentation/kbuild/modules.txt>.
313 The module will be called prism54.ko. 313 The module will be called prism54.
314 314
315config USB_ZD1201 315config USB_ZD1201
316 tristate "USB ZD1201 based Wireless device support" 316 tristate "USB ZD1201 based Wireless device support"
diff --git a/drivers/net/wireless/hostap/Kconfig b/drivers/net/wireless/hostap/Kconfig
index 932d207bce23..c15db2293515 100644
--- a/drivers/net/wireless/hostap/Kconfig
+++ b/drivers/net/wireless/hostap/Kconfig
@@ -29,7 +29,7 @@ config HOSTAP
29 PLX/PCI/CS version of the driver to actually use the driver. 29 PLX/PCI/CS version of the driver to actually use the driver.
30 30
31 The driver can be compiled as a module and it will be called 31 The driver can be compiled as a module and it will be called
32 "hostap.ko". 32 hostap.
33 33
34config HOSTAP_FIRMWARE 34config HOSTAP_FIRMWARE
35 bool "Support downloading firmware images with Host AP driver" 35 bool "Support downloading firmware images with Host AP driver"
@@ -68,7 +68,7 @@ config HOSTAP_PLX
68 driver. 68 driver.
69 69
70 The driver can be compiled as a module and will be named 70 The driver can be compiled as a module and will be named
71 "hostap_plx.ko". 71 hostap_plx.
72 72
73config HOSTAP_PCI 73config HOSTAP_PCI
74 tristate "Host AP driver for Prism2.5 PCI adaptors" 74 tristate "Host AP driver for Prism2.5 PCI adaptors"
@@ -81,7 +81,7 @@ config HOSTAP_PCI
81 driver. 81 driver.
82 82
83 The driver can be compiled as a module and will be named 83 The driver can be compiled as a module and will be named
84 "hostap_pci.ko". 84 hostap_pci.
85 85
86config HOSTAP_CS 86config HOSTAP_CS
87 tristate "Host AP driver for Prism2/2.5/3 PC Cards" 87 tristate "Host AP driver for Prism2/2.5/3 PC Cards"
@@ -94,4 +94,4 @@ config HOSTAP_CS
94 driver. 94 driver.
95 95
96 The driver can be compiled as a module and will be named 96 The driver can be compiled as a module and will be named
97 "hostap_cs.ko". 97 hostap_cs.
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index 8304f6406a17..736162324ba4 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -75,7 +75,7 @@ config IWLAGN
75 If you want to compile the driver as a module ( = code which can be 75 If you want to compile the driver as a module ( = code which can be
76 inserted in and removed from the running kernel whenever you want), 76 inserted in and removed from the running kernel whenever you want),
77 say M here and read <file:Documentation/kbuild/modules.txt>. The 77 say M here and read <file:Documentation/kbuild/modules.txt>. The
78 module will be called iwlagn.ko. 78 module will be called iwlagn.
79 79
80 80
81config IWL4965 81config IWL4965
@@ -113,7 +113,7 @@ config IWL3945
113 If you want to compile the driver as a module ( = code which can be 113 If you want to compile the driver as a module ( = code which can be
114 inserted in and removed from the running kernel whenever you want), 114 inserted in and removed from the running kernel whenever you want),
115 say M here and read <file:Documentation/kbuild/modules.txt>. The 115 say M here and read <file:Documentation/kbuild/modules.txt>. The
116 module will be called iwl3945.ko. 116 module will be called iwl3945.
117 117
118config IWL3945_SPECTRUM_MEASUREMENT 118config IWL3945_SPECTRUM_MEASUREMENT
119 bool "Enable Spectrum Measurement in iwl3945 driver" 119 bool "Enable Spectrum Measurement in iwl3945 driver"
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index bebf735cd4bd..ff0042ffe3e9 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -584,7 +584,7 @@ static int rndis_set_config_parameter(struct usbnet *dev, char *param,
584 ret = rndis_set_oid(dev, OID_GEN_RNDIS_CONFIG_PARAMETER, 584 ret = rndis_set_oid(dev, OID_GEN_RNDIS_CONFIG_PARAMETER,
585 infobuf, info_len); 585 infobuf, info_len);
586 if (ret != 0) 586 if (ret != 0)
587 devdbg(dev, "setting rndis config paramater failed, %d.", ret); 587 devdbg(dev, "setting rndis config parameter failed, %d.", ret);
588 588
589 kfree(infobuf); 589 kfree(infobuf);
590 return ret; 590 return ret;
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index bfc5d9cf716e..1ae11c7f17af 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -9,11 +9,11 @@ menuconfig RT2X00
9 9
10 When building one of the individual drivers, the rt2x00 library 10 When building one of the individual drivers, the rt2x00 library
11 will also be created. That library (when the driver is built as 11 will also be created. That library (when the driver is built as
12 a module) will be called "rt2x00lib.ko". 12 a module) will be called rt2x00lib.
13 13
14 Additionally PCI and USB libraries will also be build depending 14 Additionally PCI and USB libraries will also be build depending
15 on the types of drivers being selected, these libraries will be 15 on the types of drivers being selected, these libraries will be
16 called "rt2x00pci.ko" and "rt2x00usb.ko". 16 called rt2x00pci and rt2x00usb.
17 17
18if RT2X00 18if RT2X00
19 19
@@ -26,7 +26,7 @@ config RT2400PCI
26 This adds support for rt2400 wireless chipset family. 26 This adds support for rt2400 wireless chipset family.
27 Supported chips: RT2460. 27 Supported chips: RT2460.
28 28
29 When compiled as a module, this driver will be called "rt2400pci.ko". 29 When compiled as a module, this driver will be called rt2400pci.
30 30
31config RT2500PCI 31config RT2500PCI
32 tristate "Ralink rt2500 (PCI/PCMCIA) support" 32 tristate "Ralink rt2500 (PCI/PCMCIA) support"
@@ -37,7 +37,7 @@ config RT2500PCI
37 This adds support for rt2500 wireless chipset family. 37 This adds support for rt2500 wireless chipset family.
38 Supported chips: RT2560. 38 Supported chips: RT2560.
39 39
40 When compiled as a module, this driver will be called "rt2500pci.ko". 40 When compiled as a module, this driver will be called rt2500pci.
41 41
42config RT61PCI 42config RT61PCI
43 tristate "Ralink rt2501/rt61 (PCI/PCMCIA) support" 43 tristate "Ralink rt2501/rt61 (PCI/PCMCIA) support"
@@ -51,7 +51,7 @@ config RT61PCI
51 This adds support for rt2501 wireless chipset family. 51 This adds support for rt2501 wireless chipset family.
52 Supported chips: RT2561, RT2561S & RT2661. 52 Supported chips: RT2561, RT2561S & RT2661.
53 53
54 When compiled as a module, this driver will be called "rt61pci.ko". 54 When compiled as a module, this driver will be called rt61pci.
55 55
56config RT2500USB 56config RT2500USB
57 tristate "Ralink rt2500 (USB) support" 57 tristate "Ralink rt2500 (USB) support"
@@ -62,7 +62,7 @@ config RT2500USB
62 This adds support for rt2500 wireless chipset family. 62 This adds support for rt2500 wireless chipset family.
63 Supported chips: RT2571 & RT2572. 63 Supported chips: RT2571 & RT2572.
64 64
65 When compiled as a module, this driver will be called "rt2500usb.ko". 65 When compiled as a module, this driver will be called rt2500usb.
66 66
67config RT73USB 67config RT73USB
68 tristate "Ralink rt2501/rt73 (USB) support" 68 tristate "Ralink rt2501/rt73 (USB) support"
@@ -75,7 +75,7 @@ config RT73USB
75 This adds support for rt2501 wireless chipset family. 75 This adds support for rt2501 wireless chipset family.
76 Supported chips: RT2571W, RT2573 & RT2671. 76 Supported chips: RT2571W, RT2573 & RT2671.
77 77
78 When compiled as a module, this driver will be called "rt73usb.ko". 78 When compiled as a module, this driver will be called rt73usb.
79 79
80config RT2X00_LIB_PCI 80config RT2X00_LIB_PCI
81 tristate 81 tristate
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index a631613177d0..d83e3794d340 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -235,7 +235,7 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna);
235 * @rt2x00dev: Pointer to &struct rt2x00_dev. 235 * @rt2x00dev: Pointer to &struct rt2x00_dev.
236 * 236 *
237 * Initialize work structure and all link tuning related 237 * Initialize work structure and all link tuning related
238 * paramters. This will not start the link tuning process itself. 238 * parameters. This will not start the link tuning process itself.
239 */ 239 */
240void rt2x00link_register(struct rt2x00_dev *rt2x00dev); 240void rt2x00link_register(struct rt2x00_dev *rt2x00dev);
241 241
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index e55b33961aeb..fa2821be44c2 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -138,7 +138,7 @@ psa_read(struct net_device * dev,
138 138
139/*------------------------------------------------------------------*/ 139/*------------------------------------------------------------------*/
140/* 140/*
141 * Write the Paramter Storage Area to the WaveLAN card's memory 141 * Write the Parameter Storage Area to the WaveLAN card's memory
142 */ 142 */
143static void 143static void
144psa_write(struct net_device * dev, 144psa_write(struct net_device * dev,
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 3eee70928d45..2d6da78fddb6 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -679,7 +679,7 @@ alloc_err:
679 return rc; 679 return rc;
680} 680}
681 681
682static int sn_pci_hotplug_init(void) 682static int __init sn_pci_hotplug_init(void)
683{ 683{
684 struct pci_bus *pci_bus = NULL; 684 struct pci_bus *pci_bus = NULL;
685 int rc; 685 int rc;
@@ -716,7 +716,7 @@ static int sn_pci_hotplug_init(void)
716 return registered == 1 ? 0 : -ENODEV; 716 return registered == 1 ? 0 : -ENODEV;
717} 717}
718 718
719static void sn_pci_hotplug_exit(void) 719static void __exit sn_pci_hotplug_exit(void)
720{ 720{
721 struct hotplug_slot *bss_hotplug_slot; 721 struct hotplug_slot *bss_hotplug_slot;
722 722
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 276473543982..fbf965b31c14 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -217,7 +217,7 @@ config PCMCIA_PXA2XX
217 depends on ARM && ARCH_PXA && PCMCIA 217 depends on ARM && ARCH_PXA && PCMCIA
218 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ 218 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
219 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ 219 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
220 || ARCH_VIPER || ARCH_PXA_ESERIES) 220 || ARCH_VIPER || ARCH_PXA_ESERIES || MACH_STARGATE2)
221 help 221 help
222 Say Y here to include support for the PXA2xx PCMCIA controller 222 Say Y here to include support for the PXA2xx PCMCIA controller
223 223
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index bbac46327227..047394d98ac2 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -73,5 +73,6 @@ pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps4.o
73pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o 73pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o
74pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o 74pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o
75pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o 75pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o
76pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o
76 77
77obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_core.o $(pxa2xx-obj-y) 78obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_core.o $(pxa2xx-obj-y)
diff --git a/drivers/pcmcia/pxa2xx_stargate2.c b/drivers/pcmcia/pxa2xx_stargate2.c
new file mode 100644
index 000000000000..490749ea677f
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_stargate2.c
@@ -0,0 +1,174 @@
1/*
2 * linux/drivers/pcmcia/pxa2xx_stargate2.c
3 *
4 * Stargate 2 PCMCIA specific routines.
5 *
6 * Created: December 6, 2005
7 * Author: Ed C. Epp
8 * Copyright: Intel Corp 2005
9 * Jonathan Cameron <jic23@cam.ac.uk> 2009
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/module.h>
17#include <linux/init.h>
18#include <linux/kernel.h>
19#include <linux/interrupt.h>
20#include <linux/delay.h>
21#include <linux/platform_device.h>
22#include <linux/gpio.h>
23
24#include <pcmcia/ss.h>
25
26#include <asm/irq.h>
27#include <asm/mach-types.h>
28
29#include "soc_common.h"
30
31#define SG2_S0_BUFF_CTL 120
32#define SG2_S0_POWER_CTL 108
33#define SG2_S0_GPIO_RESET 82
34#define SG2_S0_GPIO_DETECT 53
35#define SG2_S0_GPIO_READY 81
36
37static struct pcmcia_irqs irqs[] = {
38 { 0, IRQ_GPIO(SG2_S0_GPIO_DETECT), "PCMCIA0 CD" },
39};
40
41static int sg2_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
42{
43 skt->irq = IRQ_GPIO(SG2_S0_GPIO_READY);
44 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
45}
46
47static void sg2_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
48{
49 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
50}
51
52static void sg2_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
53 struct pcmcia_state *state)
54{
55 state->detect = !gpio_get_value(SG2_S0_GPIO_DETECT);
56 state->ready = !!gpio_get_value(SG2_S0_GPIO_READY);
57 state->bvd1 = 0; /* not available - battery detect on card */
58 state->bvd2 = 0; /* not available */
59 state->vs_3v = 1; /* not available - voltage detect for card */
60 state->vs_Xv = 0; /* not available */
61 state->wrprot = 0; /* not available - write protect */
62}
63
64static int sg2_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
65 const socket_state_t *state)
66{
67 /* Enable card power */
68 switch (state->Vcc) {
69 case 0:
70 /* sets power ctl register high */
71 gpio_set_value(SG2_S0_POWER_CTL, 1);
72 break;
73 case 33:
74 case 50:
75 /* sets power control register low (clear) */
76 gpio_set_value(SG2_S0_POWER_CTL, 0);
77 msleep(100);
78 break;
79 default:
80 pr_err("%s(): bad Vcc %u\n",
81 __func__, state->Vcc);
82 return -1;
83 }
84
85 /* reset */
86 gpio_set_value(SG2_S0_GPIO_RESET, !!(state->flags & SS_RESET));
87
88 return 0;
89}
90
91static void sg2_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
92{
93 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
94}
95
96static void sg2_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
97{
98 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
99}
100
101static struct pcmcia_low_level sg2_pcmcia_ops __initdata = {
102 .owner = THIS_MODULE,
103 .hw_init = sg2_pcmcia_hw_init,
104 .hw_shutdown = sg2_pcmcia_hw_shutdown,
105 .socket_state = sg2_pcmcia_socket_state,
106 .configure_socket = sg2_pcmcia_configure_socket,
107 .socket_init = sg2_pcmcia_socket_init,
108 .socket_suspend = sg2_pcmcia_socket_suspend,
109 .nr = 1,
110};
111
112static struct platform_device *sg2_pcmcia_device;
113
114static int __init sg2_pcmcia_init(void)
115{
116 int ret;
117
118 if (!machine_is_stargate2())
119 return -ENODEV;
120
121 sg2_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
122 if (!sg2_pcmcia_device)
123 return -ENOMEM;
124
125 ret = gpio_request(SG2_S0_BUFF_CTL, "SG2 CF buff ctl");
126 if (ret)
127 goto error_put_platform_device;
128 ret = gpio_request(SG2_S0_POWER_CTL, "SG2 CF power ctl");
129 if (ret)
130 goto error_free_gpio_buff_ctl;
131 ret = gpio_request(SG2_S0_GPIO_RESET, "SG2 CF reset");
132 if (ret)
133 goto error_free_gpio_power_ctl;
134 /* Set gpio directions */
135 gpio_direction_output(SG2_S0_BUFF_CTL, 0);
136 gpio_direction_output(SG2_S0_POWER_CTL, 1);
137 gpio_direction_output(SG2_S0_GPIO_RESET, 1);
138
139 ret = platform_device_add_data(sg2_pcmcia_device,
140 &sg2_pcmcia_ops,
141 sizeof(sg2_pcmcia_ops));
142 if (ret)
143 goto error_free_gpio_reset;
144
145 ret = platform_device_add(sg2_pcmcia_device);
146 if (ret)
147 goto error_free_gpio_reset;
148
149 return 0;
150error_free_gpio_reset:
151 gpio_free(SG2_S0_GPIO_RESET);
152error_free_gpio_power_ctl:
153 gpio_free(SG2_S0_POWER_CTL);
154error_free_gpio_buff_ctl:
155 gpio_free(SG2_S0_BUFF_CTL);
156error_put_platform_device:
157 platform_device_put(sg2_pcmcia_device);
158
159 return ret;
160}
161
162static void __exit sg2_pcmcia_exit(void)
163{
164 platform_device_unregister(sg2_pcmcia_device);
165 gpio_free(SG2_S0_BUFF_CTL);
166 gpio_free(SG2_S0_POWER_CTL);
167 gpio_free(SG2_S0_GPIO_RESET);
168}
169
170fs_initcall(sg2_pcmcia_init);
171module_exit(sg2_pcmcia_exit);
172
173MODULE_LICENSE("GPL");
174MODULE_ALIAS("platform:pxa2xx-pcmcia");
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index f7a3283dd029..551332e4ed02 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -12,32 +12,56 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <mach/hardware.h> 15#include <linux/io.h>
16
17#define EP93XX_RTC_DATA 0x000
18#define EP93XX_RTC_MATCH 0x004
19#define EP93XX_RTC_STATUS 0x008
20#define EP93XX_RTC_STATUS_INTR (1<<0)
21#define EP93XX_RTC_LOAD 0x00C
22#define EP93XX_RTC_CONTROL 0x010
23#define EP93XX_RTC_CONTROL_MIE (1<<0)
24#define EP93XX_RTC_SWCOMP 0x108
25#define EP93XX_RTC_SWCOMP_DEL_MASK 0x001f0000
26#define EP93XX_RTC_SWCOMP_DEL_SHIFT 16
27#define EP93XX_RTC_SWCOMP_INT_MASK 0x0000ffff
28#define EP93XX_RTC_SWCOMP_INT_SHIFT 0
29
30#define DRV_VERSION "0.3"
16 31
17#define EP93XX_RTC_REG(x) (EP93XX_RTC_BASE + (x)) 32/*
18#define EP93XX_RTC_DATA EP93XX_RTC_REG(0x0000) 33 * struct device dev.platform_data is used to store our private data
19#define EP93XX_RTC_LOAD EP93XX_RTC_REG(0x000C) 34 * because struct rtc_device does not have a variable to hold it.
20#define EP93XX_RTC_SWCOMP EP93XX_RTC_REG(0x0108) 35 */
21 36struct ep93xx_rtc {
22#define DRV_VERSION "0.2" 37 void __iomem *mmio_base;
38};
23 39
24static int ep93xx_get_swcomp(struct device *dev, unsigned short *preload, 40static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
25 unsigned short *delete) 41 unsigned short *delete)
26{ 42{
27 unsigned short comp = __raw_readl(EP93XX_RTC_SWCOMP); 43 struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
44 unsigned long comp;
45
46 comp = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_SWCOMP);
28 47
29 if (preload) 48 if (preload)
30 *preload = comp & 0xffff; 49 *preload = (comp & EP93XX_RTC_SWCOMP_INT_MASK)
50 >> EP93XX_RTC_SWCOMP_INT_SHIFT;
31 51
32 if (delete) 52 if (delete)
33 *delete = (comp >> 16) & 0x1f; 53 *delete = (comp & EP93XX_RTC_SWCOMP_DEL_MASK)
54 >> EP93XX_RTC_SWCOMP_DEL_SHIFT;
34 55
35 return 0; 56 return 0;
36} 57}
37 58
38static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) 59static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
39{ 60{
40 unsigned long time = __raw_readl(EP93XX_RTC_DATA); 61 struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
62 unsigned long time;
63
64 time = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);
41 65
42 rtc_time_to_tm(time, tm); 66 rtc_time_to_tm(time, tm);
43 return 0; 67 return 0;
@@ -45,7 +69,9 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
45 69
46static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs) 70static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs)
47{ 71{
48 __raw_writel(secs + 1, EP93XX_RTC_LOAD); 72 struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
73
74 __raw_writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD);
49 return 0; 75 return 0;
50} 76}
51 77
@@ -53,7 +79,7 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
53{ 79{
54 unsigned short preload, delete; 80 unsigned short preload, delete;
55 81
56 ep93xx_get_swcomp(dev, &preload, &delete); 82 ep93xx_rtc_get_swcomp(dev, &preload, &delete);
57 83
58 seq_printf(seq, "preload\t\t: %d\n", preload); 84 seq_printf(seq, "preload\t\t: %d\n", preload);
59 seq_printf(seq, "delete\t\t: %d\n", delete); 85 seq_printf(seq, "delete\t\t: %d\n", delete);
@@ -67,54 +93,104 @@ static const struct rtc_class_ops ep93xx_rtc_ops = {
67 .proc = ep93xx_rtc_proc, 93 .proc = ep93xx_rtc_proc,
68}; 94};
69 95
70static ssize_t ep93xx_sysfs_show_comp_preload(struct device *dev, 96static ssize_t ep93xx_rtc_show_comp_preload(struct device *dev,
71 struct device_attribute *attr, char *buf) 97 struct device_attribute *attr, char *buf)
72{ 98{
73 unsigned short preload; 99 unsigned short preload;
74 100
75 ep93xx_get_swcomp(dev, &preload, NULL); 101 ep93xx_rtc_get_swcomp(dev, &preload, NULL);
76 102
77 return sprintf(buf, "%d\n", preload); 103 return sprintf(buf, "%d\n", preload);
78} 104}
79static DEVICE_ATTR(comp_preload, S_IRUGO, ep93xx_sysfs_show_comp_preload, NULL); 105static DEVICE_ATTR(comp_preload, S_IRUGO, ep93xx_rtc_show_comp_preload, NULL);
80 106
81static ssize_t ep93xx_sysfs_show_comp_delete(struct device *dev, 107static ssize_t ep93xx_rtc_show_comp_delete(struct device *dev,
82 struct device_attribute *attr, char *buf) 108 struct device_attribute *attr, char *buf)
83{ 109{
84 unsigned short delete; 110 unsigned short delete;
85 111
86 ep93xx_get_swcomp(dev, NULL, &delete); 112 ep93xx_rtc_get_swcomp(dev, NULL, &delete);
87 113
88 return sprintf(buf, "%d\n", delete); 114 return sprintf(buf, "%d\n", delete);
89} 115}
90static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_sysfs_show_comp_delete, NULL); 116static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_rtc_show_comp_delete, NULL);
91 117
92 118
93static int __devinit ep93xx_rtc_probe(struct platform_device *dev) 119static int __init ep93xx_rtc_probe(struct platform_device *pdev)
94{ 120{
95 struct rtc_device *rtc = rtc_device_register("ep93xx", 121 struct ep93xx_rtc *ep93xx_rtc;
96 &dev->dev, &ep93xx_rtc_ops, THIS_MODULE); 122 struct resource *res;
123 struct rtc_device *rtc;
124 int err;
125
126 ep93xx_rtc = kzalloc(sizeof(struct ep93xx_rtc), GFP_KERNEL);
127 if (ep93xx_rtc == NULL)
128 return -ENOMEM;
129
130 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
131 if (res == NULL)
132 return -ENXIO;
133
134 res = request_mem_region(res->start, resource_size(res), pdev->name);
135 if (res == NULL)
136 return -EBUSY;
137
138 ep93xx_rtc->mmio_base = ioremap(res->start, resource_size(res));
139 if (ep93xx_rtc->mmio_base == NULL) {
140 err = -ENXIO;
141 goto fail;
142 }
97 143
144 pdev->dev.platform_data = ep93xx_rtc;
145
146 rtc = rtc_device_register(pdev->name,
147 &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE);
98 if (IS_ERR(rtc)) { 148 if (IS_ERR(rtc)) {
99 return PTR_ERR(rtc); 149 err = PTR_ERR(rtc);
150 goto fail;
100 } 151 }
101 152
102 platform_set_drvdata(dev, rtc); 153 platform_set_drvdata(pdev, rtc);
103 154
104 device_create_file(&dev->dev, &dev_attr_comp_preload); 155 err = device_create_file(&pdev->dev, &dev_attr_comp_preload);
105 device_create_file(&dev->dev, &dev_attr_comp_delete); 156 if (err)
157 goto fail;
158 err = device_create_file(&pdev->dev, &dev_attr_comp_delete);
159 if (err) {
160 device_remove_file(&pdev->dev, &dev_attr_comp_preload);
161 goto fail;
162 }
106 163
107 return 0; 164 return 0;
165
166fail:
167 if (ep93xx_rtc->mmio_base) {
168 iounmap(ep93xx_rtc->mmio_base);
169 pdev->dev.platform_data = NULL;
170 }
171 release_mem_region(res->start, resource_size(res));
172 return err;
108} 173}
109 174
110static int __devexit ep93xx_rtc_remove(struct platform_device *dev) 175static int __exit ep93xx_rtc_remove(struct platform_device *pdev)
111{ 176{
112 struct rtc_device *rtc = platform_get_drvdata(dev); 177 struct rtc_device *rtc = platform_get_drvdata(pdev);
178 struct ep93xx_rtc *ep93xx_rtc = pdev->dev.platform_data;
179 struct resource *res;
180
181 /* cleanup sysfs */
182 device_remove_file(&pdev->dev, &dev_attr_comp_delete);
183 device_remove_file(&pdev->dev, &dev_attr_comp_preload);
184
185 rtc_device_unregister(rtc);
186
187 iounmap(ep93xx_rtc->mmio_base);
188 pdev->dev.platform_data = NULL;
113 189
114 if (rtc) 190 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
115 rtc_device_unregister(rtc); 191 release_mem_region(res->start, resource_size(res));
116 192
117 platform_set_drvdata(dev, NULL); 193 platform_set_drvdata(pdev, NULL);
118 194
119 return 0; 195 return 0;
120} 196}
@@ -122,23 +198,22 @@ static int __devexit ep93xx_rtc_remove(struct platform_device *dev)
122/* work with hotplug and coldplug */ 198/* work with hotplug and coldplug */
123MODULE_ALIAS("platform:ep93xx-rtc"); 199MODULE_ALIAS("platform:ep93xx-rtc");
124 200
125static struct platform_driver ep93xx_rtc_platform_driver = { 201static struct platform_driver ep93xx_rtc_driver = {
126 .driver = { 202 .driver = {
127 .name = "ep93xx-rtc", 203 .name = "ep93xx-rtc",
128 .owner = THIS_MODULE, 204 .owner = THIS_MODULE,
129 }, 205 },
130 .probe = ep93xx_rtc_probe, 206 .remove = __exit_p(ep93xx_rtc_remove),
131 .remove = __devexit_p(ep93xx_rtc_remove),
132}; 207};
133 208
134static int __init ep93xx_rtc_init(void) 209static int __init ep93xx_rtc_init(void)
135{ 210{
136 return platform_driver_register(&ep93xx_rtc_platform_driver); 211 return platform_driver_probe(&ep93xx_rtc_driver, ep93xx_rtc_probe);
137} 212}
138 213
139static void __exit ep93xx_rtc_exit(void) 214static void __exit ep93xx_rtc_exit(void)
140{ 215{
141 platform_driver_unregister(&ep93xx_rtc_platform_driver); 216 platform_driver_unregister(&ep93xx_rtc_driver);
142} 217}
143 218
144MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 219MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index aaf1f75fa293..457231bb1029 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -117,7 +117,7 @@ static int pl030_probe(struct amba_device *dev, struct amba_id *id)
117 goto err_rtc; 117 goto err_rtc;
118 } 118 }
119 119
120 rtc->base = ioremap(dev->res.start, SZ_4K); 120 rtc->base = ioremap(dev->res.start, resource_size(&dev->res));
121 if (!rtc->base) { 121 if (!rtc->base) {
122 ret = -ENOMEM; 122 ret = -ENOMEM;
123 goto err_map; 123 goto err_map;
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 451fc13784d1..f41873f98f66 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -142,8 +142,7 @@ static int pl031_probe(struct amba_device *adev, struct amba_id *id)
142 goto out; 142 goto out;
143 } 143 }
144 144
145 ldata->base = ioremap(adev->res.start, 145 ldata->base = ioremap(adev->res.start, resource_size(&adev->res));
146 adev->res.end - adev->res.start + 1);
147 if (!ldata->base) { 146 if (!ldata->base) {
148 ret = -ENOMEM; 147 ret = -ENOMEM;
149 goto out_no_remap; 148 goto out_no_remap;
diff --git a/drivers/s390/net/Kconfig b/drivers/s390/net/Kconfig
index a7745c82b4ae..cb909a5b5047 100644
--- a/drivers/s390/net/Kconfig
+++ b/drivers/s390/net/Kconfig
@@ -8,7 +8,7 @@ config LCS
8 Select this option if you want to use LCS networking on IBM System z. 8 Select this option if you want to use LCS networking on IBM System z.
9 This device driver supports Token Ring (IEEE 802.5), 9 This device driver supports Token Ring (IEEE 802.5),
10 FDDI (IEEE 802.7) and Ethernet. 10 FDDI (IEEE 802.7) and Ethernet.
11 To compile as a module, choose M. The module name is lcs.ko. 11 To compile as a module, choose M. The module name is lcs.
12 If you do not know what it is, it's safe to choose Y. 12 If you do not know what it is, it's safe to choose Y.
13 13
14config CTCM 14config CTCM
@@ -21,7 +21,7 @@ config CTCM
21 It also supports virtual CTCs when running under VM. 21 It also supports virtual CTCs when running under VM.
22 This driver also supports channel-to-channel MPC SNA devices. 22 This driver also supports channel-to-channel MPC SNA devices.
23 MPC is an SNA protocol device used by Communication Server for Linux. 23 MPC is an SNA protocol device used by Communication Server for Linux.
24 To compile as a module, choose M. The module name is ctcm.ko. 24 To compile as a module, choose M. The module name is ctcm.
25 To compile into the kernel, choose Y. 25 To compile into the kernel, choose Y.
26 If you do not need any channel-to-channel connection, choose N. 26 If you do not need any channel-to-channel connection, choose N.
27 27
@@ -34,7 +34,7 @@ config NETIUCV
34 link between VM guests. Using ifconfig a point-to-point connection 34 link between VM guests. Using ifconfig a point-to-point connection
35 can be established to the Linux on IBM System z 35 can be established to the Linux on IBM System z
36 running on the other VM guest. To compile as a module, choose M. 36 running on the other VM guest. To compile as a module, choose M.
37 The module name is netiucv.ko. If unsure, choose Y. 37 The module name is netiucv. If unsure, choose Y.
38 38
39config SMSGIUCV 39config SMSGIUCV
40 tristate "IUCV special message support (VM only)" 40 tristate "IUCV special message support (VM only)"
@@ -50,7 +50,7 @@ config CLAW
50 This driver supports channel attached CLAW devices. 50 This driver supports channel attached CLAW devices.
51 CLAW is Common Link Access for Workstation. Common devices 51 CLAW is Common Link Access for Workstation. Common devices
52 that use CLAW are RS/6000s, Cisco Routers (CIP) and 3172 devices. 52 that use CLAW are RS/6000s, Cisco Routers (CIP) and 3172 devices.
53 To compile as a module, choose M. The module name is claw.ko. 53 To compile as a module, choose M. The module name is claw.
54 To compile into the kernel, choose Y. 54 To compile into the kernel, choose Y.
55 55
56config QETH 56config QETH
@@ -65,14 +65,14 @@ config QETH
65 <http://www.ibm.com/developerworks/linux/linux390> 65 <http://www.ibm.com/developerworks/linux/linux390>
66 66
67 To compile this driver as a module, choose M. 67 To compile this driver as a module, choose M.
68 The module name is qeth.ko. 68 The module name is qeth.
69 69
70config QETH_L2 70config QETH_L2
71 tristate "qeth layer 2 device support" 71 tristate "qeth layer 2 device support"
72 depends on QETH 72 depends on QETH
73 help 73 help
74 Select this option to be able to run qeth devices in layer 2 mode. 74 Select this option to be able to run qeth devices in layer 2 mode.
75 To compile as a module, choose M. The module name is qeth_l2.ko. 75 To compile as a module, choose M. The module name is qeth_l2.
76 If unsure, choose y. 76 If unsure, choose y.
77 77
78config QETH_L3 78config QETH_L3
@@ -80,7 +80,7 @@ config QETH_L3
80 depends on QETH 80 depends on QETH
81 help 81 help
82 Select this option to be able to run qeth devices in layer 3 mode. 82 Select this option to be able to run qeth devices in layer 3 mode.
83 To compile as a module choose M. The module name is qeth_l3.ko. 83 To compile as a module choose M. The module name is qeth_l3.
84 If unsure, choose Y. 84 If unsure, choose Y.
85 85
86config QETH_IPV6 86config QETH_IPV6
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index bb2752b4130f..35493a82d2a8 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -116,7 +116,7 @@ static void zfcp_wka_port_put(struct zfcp_wka_port *wka_port)
116{ 116{
117 if (atomic_dec_return(&wka_port->refcount) != 0) 117 if (atomic_dec_return(&wka_port->refcount) != 0)
118 return; 118 return;
119 /* wait 10 miliseconds, other reqs might pop in */ 119 /* wait 10 milliseconds, other reqs might pop in */
120 schedule_delayed_work(&wka_port->work, HZ / 100); 120 schedule_delayed_work(&wka_port->work, HZ / 100);
121} 121}
122 122
diff --git a/drivers/scsi/dpt/osd_util.h b/drivers/scsi/dpt/osd_util.h
index 4b56c0436ba2..b2613c2eaac7 100644
--- a/drivers/scsi/dpt/osd_util.h
+++ b/drivers/scsi/dpt/osd_util.h
@@ -342,7 +342,7 @@ uLONG osdGetThreadID(void);
342/* wakes up the specifed thread */ 342/* wakes up the specifed thread */
343void osdWakeThread(uLONG); 343void osdWakeThread(uLONG);
344 344
345/* osd sleep for x miliseconds */ 345/* osd sleep for x milliseconds */
346void osdSleep(uLONG); 346void osdSleep(uLONG);
347 347
348#define DPT_THREAD_PRIORITY_LOWEST 0x00 348#define DPT_THREAD_PRIORITY_LOWEST 0x00
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index e9fa6762044a..7991ba1980ae 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -1174,8 +1174,8 @@ lpfc_cmd_blksize(struct scsi_cmnd *sc)
1174 * @reftag: out: ref tag (reference tag) 1174 * @reftag: out: ref tag (reference tag)
1175 * 1175 *
1176 * Description: 1176 * Description:
1177 * Extract DIF paramters from the command if possible. Otherwise, 1177 * Extract DIF parameters from the command if possible. Otherwise,
1178 * use default paratmers. 1178 * use default parameters.
1179 * 1179 *
1180 **/ 1180 **/
1181static inline void 1181static inline void
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 795201fa0b48..512c2cc1a33f 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -469,7 +469,7 @@ typedef struct {
469 u8 type; /* Type of the device */ 469 u8 type; /* Type of the device */
470 u8 cur_status; /* current status of the device */ 470 u8 cur_status; /* current status of the device */
471 u8 tag_depth; /* Level of tagging */ 471 u8 tag_depth; /* Level of tagging */
472 u8 sync_neg; /* sync negotiation - ENABLE or DISBALE */ 472 u8 sync_neg; /* sync negotiation - ENABLE or DISABLE */
473 u32 size; /* configurable size in terms of 512 byte 473 u32 size; /* configurable size in terms of 512 byte
474 blocks */ 474 blocks */
475}__attribute__ ((packed)) phys_drv; 475}__attribute__ ((packed)) phys_drv;
diff --git a/drivers/scsi/megaraid/mbox_defs.h b/drivers/scsi/megaraid/mbox_defs.h
index 170399ef06f4..b25b74764ec3 100644
--- a/drivers/scsi/megaraid/mbox_defs.h
+++ b/drivers/scsi/megaraid/mbox_defs.h
@@ -686,7 +686,7 @@ typedef struct {
686 * @type : Type of the device 686 * @type : Type of the device
687 * @cur_status : current status of the device 687 * @cur_status : current status of the device
688 * @tag_depth : Level of tagging 688 * @tag_depth : Level of tagging
689 * @sync_neg : sync negotiation - ENABLE or DISBALE 689 * @sync_neg : sync negotiation - ENABLE or DISABLE
690 * @size : configurable size in terms of 512 byte 690 * @size : configurable size in terms of 512 byte
691 */ 691 */
692typedef struct { 692typedef struct {
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 641e800ed693..1132c5cae7ab 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -861,7 +861,7 @@ config SERIAL_UARTLITE
861 Say Y here if you want to use the Xilinx uartlite serial controller. 861 Say Y here if you want to use the Xilinx uartlite serial controller.
862 862
863 To compile this driver as a module, choose M here: the 863 To compile this driver as a module, choose M here: the
864 module will be called uartlite.ko. 864 module will be called uartlite.
865 865
866config SERIAL_UARTLITE_CONSOLE 866config SERIAL_UARTLITE_CONSOLE
867 bool "Support for console on Xilinx uartlite serial port" 867 bool "Support for console on Xilinx uartlite serial port"
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index cdc049d4350f..58a4879c7e48 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -686,7 +686,7 @@ static int pl010_probe(struct amba_device *dev, struct amba_id *id)
686 goto out; 686 goto out;
687 } 687 }
688 688
689 base = ioremap(dev->res.start, PAGE_SIZE); 689 base = ioremap(dev->res.start, resource_size(&dev->res));
690 if (!base) { 690 if (!base) {
691 ret = -ENOMEM; 691 ret = -ENOMEM;
692 goto free; 692 goto free;
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 88fdac51b6c5..bf82e28770a9 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -70,6 +70,23 @@ struct uart_amba_port {
70 struct clk *clk; 70 struct clk *clk;
71 unsigned int im; /* interrupt mask */ 71 unsigned int im; /* interrupt mask */
72 unsigned int old_status; 72 unsigned int old_status;
73 unsigned int ifls; /* vendor-specific */
74};
75
76/* There is by now at least one vendor with differing details, so handle it */
77struct vendor_data {
78 unsigned int ifls;
79 unsigned int fifosize;
80};
81
82static struct vendor_data vendor_arm = {
83 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8,
84 .fifosize = 16,
85};
86
87static struct vendor_data vendor_st = {
88 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF,
89 .fifosize = 64,
73}; 90};
74 91
75static void pl011_stop_tx(struct uart_port *port) 92static void pl011_stop_tx(struct uart_port *port)
@@ -360,8 +377,7 @@ static int pl011_startup(struct uart_port *port)
360 if (retval) 377 if (retval)
361 goto clk_dis; 378 goto clk_dis;
362 379
363 writew(UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, 380 writew(uap->ifls, uap->port.membase + UART011_IFLS);
364 uap->port.membase + UART011_IFLS);
365 381
366 /* 382 /*
367 * Provoke TX FIFO interrupt into asserting. 383 * Provoke TX FIFO interrupt into asserting.
@@ -732,6 +748,7 @@ static struct uart_driver amba_reg = {
732static int pl011_probe(struct amba_device *dev, struct amba_id *id) 748static int pl011_probe(struct amba_device *dev, struct amba_id *id)
733{ 749{
734 struct uart_amba_port *uap; 750 struct uart_amba_port *uap;
751 struct vendor_data *vendor = id->data;
735 void __iomem *base; 752 void __iomem *base;
736 int i, ret; 753 int i, ret;
737 754
@@ -750,7 +767,7 @@ static int pl011_probe(struct amba_device *dev, struct amba_id *id)
750 goto out; 767 goto out;
751 } 768 }
752 769
753 base = ioremap(dev->res.start, PAGE_SIZE); 770 base = ioremap(dev->res.start, resource_size(&dev->res));
754 if (!base) { 771 if (!base) {
755 ret = -ENOMEM; 772 ret = -ENOMEM;
756 goto free; 773 goto free;
@@ -762,12 +779,13 @@ static int pl011_probe(struct amba_device *dev, struct amba_id *id)
762 goto unmap; 779 goto unmap;
763 } 780 }
764 781
782 uap->ifls = vendor->ifls;
765 uap->port.dev = &dev->dev; 783 uap->port.dev = &dev->dev;
766 uap->port.mapbase = dev->res.start; 784 uap->port.mapbase = dev->res.start;
767 uap->port.membase = base; 785 uap->port.membase = base;
768 uap->port.iotype = UPIO_MEM; 786 uap->port.iotype = UPIO_MEM;
769 uap->port.irq = dev->irq[0]; 787 uap->port.irq = dev->irq[0];
770 uap->port.fifosize = 16; 788 uap->port.fifosize = vendor->fifosize;
771 uap->port.ops = &amba_pl011_pops; 789 uap->port.ops = &amba_pl011_pops;
772 uap->port.flags = UPF_BOOT_AUTOCONF; 790 uap->port.flags = UPF_BOOT_AUTOCONF;
773 uap->port.line = i; 791 uap->port.line = i;
@@ -812,6 +830,12 @@ static struct amba_id pl011_ids[] __initdata = {
812 { 830 {
813 .id = 0x00041011, 831 .id = 0x00041011,
814 .mask = 0x000fffff, 832 .mask = 0x000fffff,
833 .data = &vendor_arm,
834 },
835 {
836 .id = 0x00380802,
837 .mask = 0x00ffffff,
838 .data = &vendor_st,
815 }, 839 },
816 { 0, 0 }, 840 { 0, 0 },
817}; 841};
@@ -845,7 +869,11 @@ static void __exit pl011_exit(void)
845 uart_unregister_driver(&amba_reg); 869 uart_unregister_driver(&amba_reg);
846} 870}
847 871
848module_init(pl011_init); 872/*
873 * While this can be a module, if builtin it's most likely the console
874 * So let's leave module_exit but move module_init to an earlier place
875 */
876arch_initcall(pl011_init);
849module_exit(pl011_exit); 877module_exit(pl011_exit);
850 878
851MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd"); 879MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd");
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 7b5d1de9cfe3..285b414f3054 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -71,7 +71,7 @@
71#define ONEMS 0xb0 /* One Millisecond register */ 71#define ONEMS 0xb0 /* One Millisecond register */
72#define UTS 0xb4 /* UART Test Register */ 72#define UTS 0xb4 /* UART Test Register */
73#endif 73#endif
74#if defined(CONFIG_ARCH_IMX) || defined(CONFIG_ARCH_MX1) 74#ifdef CONFIG_ARCH_MX1
75#define BIPR1 0xb0 /* Incremental Preset Register 1 */ 75#define BIPR1 0xb0 /* Incremental Preset Register 1 */
76#define BIPR2 0xb4 /* Incremental Preset Register 2 */ 76#define BIPR2 0xb4 /* Incremental Preset Register 2 */
77#define BIPR3 0xb8 /* Incremental Preset Register 3 */ 77#define BIPR3 0xb8 /* Incremental Preset Register 3 */
@@ -101,7 +101,7 @@
101#define UCR1_RTSDEN (1<<5) /* RTS delta interrupt enable */ 101#define UCR1_RTSDEN (1<<5) /* RTS delta interrupt enable */
102#define UCR1_SNDBRK (1<<4) /* Send break */ 102#define UCR1_SNDBRK (1<<4) /* Send break */
103#define UCR1_TDMAEN (1<<3) /* Transmitter ready DMA enable */ 103#define UCR1_TDMAEN (1<<3) /* Transmitter ready DMA enable */
104#if defined(CONFIG_ARCH_IMX) || defined(CONFIG_ARCH_MX1) 104#ifdef CONFIG_ARCH_MX1
105#define UCR1_UARTCLKEN (1<<2) /* UART clock enabled */ 105#define UCR1_UARTCLKEN (1<<2) /* UART clock enabled */
106#endif 106#endif
107#if defined CONFIG_ARCH_MX3 || defined CONFIG_ARCH_MX2 107#if defined CONFIG_ARCH_MX3 || defined CONFIG_ARCH_MX2
@@ -132,7 +132,7 @@
132#define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */ 132#define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */
133#define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */ 133#define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */
134#define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */ 134#define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */
135#ifdef CONFIG_ARCH_IMX 135#ifdef CONFIG_ARCH_MX1
136#define UCR3_REF25 (1<<3) /* Ref freq 25 MHz, only on mx1 */ 136#define UCR3_REF25 (1<<3) /* Ref freq 25 MHz, only on mx1 */
137#define UCR3_REF30 (1<<2) /* Ref Freq 30 MHz, only on mx1 */ 137#define UCR3_REF30 (1<<2) /* Ref Freq 30 MHz, only on mx1 */
138#endif 138#endif
@@ -186,13 +186,6 @@
186#define UTS_SOFTRST (1<<0) /* Software reset */ 186#define UTS_SOFTRST (1<<0) /* Software reset */
187 187
188/* We've been assigned a range on the "Low-density serial ports" major */ 188/* We've been assigned a range on the "Low-density serial ports" major */
189#ifdef CONFIG_ARCH_IMX
190#define SERIAL_IMX_MAJOR 204
191#define MINOR_START 41
192#define DEV_NAME "ttySMX"
193#define MAX_INTERNAL_IRQ IMX_IRQS
194#endif
195
196#ifdef CONFIG_ARCH_MXC 189#ifdef CONFIG_ARCH_MXC
197#define SERIAL_IMX_MAJOR 207 190#define SERIAL_IMX_MAJOR 207
198#define MINOR_START 16 191#define MINOR_START 16
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 957494775413..e8aae227b5e0 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -118,7 +118,7 @@ config SPI_GPIO
118 118
119config SPI_IMX 119config SPI_IMX
120 tristate "Freescale iMX SPI controller" 120 tristate "Freescale iMX SPI controller"
121 depends on ARCH_IMX && EXPERIMENTAL 121 depends on ARCH_MX1 && EXPERIMENTAL
122 help 122 help
123 This enables using the Freescale iMX SPI controller in master 123 This enables using the Freescale iMX SPI controller in master
124 mode. 124 mode.
@@ -171,6 +171,15 @@ config SPI_ORION
171 help 171 help
172 This enables using the SPI master controller on the Orion chips. 172 This enables using the SPI master controller on the Orion chips.
173 173
174config SPI_PL022
175 tristate "ARM AMBA PL022 SSP controller (EXPERIMENTAL)"
176 depends on ARM_AMBA && EXPERIMENTAL
177 default y if MACH_U300
178 help
179 This selects the ARM(R) AMBA(R) PrimeCell PL022 SSP
180 controller. If you have an embedded system with an AMBA(R)
181 bus and a PL022 controller, say Y or M here.
182
174config SPI_PXA2XX 183config SPI_PXA2XX
175 tristate "PXA2xx SSP SPI master" 184 tristate "PXA2xx SSP SPI master"
176 depends on ARCH_PXA && EXPERIMENTAL 185 depends on ARCH_PXA && EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 5d0451936d86..ecfadb180482 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o
23obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o 23obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o
24obj-$(CONFIG_SPI_OMAP24XX) += omap2_mcspi.o 24obj-$(CONFIG_SPI_OMAP24XX) += omap2_mcspi.o
25obj-$(CONFIG_SPI_ORION) += orion_spi.o 25obj-$(CONFIG_SPI_ORION) += orion_spi.o
26obj-$(CONFIG_SPI_PL022) += amba-pl022.o
26obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o 27obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o
27obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o 28obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o
28obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o 29obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
new file mode 100644
index 000000000000..da76797ce8b9
--- /dev/null
+++ b/drivers/spi/amba-pl022.c
@@ -0,0 +1,1866 @@
1/*
2 * drivers/spi/amba-pl022.c
3 *
4 * A driver for the ARM PL022 PrimeCell SSP/SPI bus master.
5 *
6 * Copyright (C) 2008-2009 ST-Ericsson AB
7 * Copyright (C) 2006 STMicroelectronics Pvt. Ltd.
8 *
9 * Author: Linus Walleij <linus.walleij@stericsson.com>
10 *
11 * Initial version inspired by:
12 * linux-2.6.17-rc3-mm1/drivers/spi/pxa2xx_spi.c
13 * Initial adoption to PL022 by:
14 * Sachin Verma <sachin.verma@st.com>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 */
26
27/*
28 * TODO:
29 * - add timeout on polled transfers
30 * - add generic DMA framework support
31 */
32
33#include <linux/init.h>
34#include <linux/module.h>
35#include <linux/device.h>
36#include <linux/ioport.h>
37#include <linux/errno.h>
38#include <linux/interrupt.h>
39#include <linux/spi/spi.h>
40#include <linux/workqueue.h>
41#include <linux/errno.h>
42#include <linux/delay.h>
43#include <linux/clk.h>
44#include <linux/err.h>
45#include <linux/amba/bus.h>
46#include <linux/amba/pl022.h>
47#include <linux/io.h>
48#include <linux/delay.h>
49
50/*
51 * This macro is used to define some register default values.
52 * reg is masked with mask, the OR:ed with an (again masked)
53 * val shifted sb steps to the left.
54 */
55#define SSP_WRITE_BITS(reg, val, mask, sb) \
56 ((reg) = (((reg) & ~(mask)) | (((val)<<(sb)) & (mask))))
57
58/*
59 * This macro is also used to define some default values.
60 * It will just shift val by sb steps to the left and mask
61 * the result with mask.
62 */
63#define GEN_MASK_BITS(val, mask, sb) \
64 (((val)<<(sb)) & (mask))
65
66#define DRIVE_TX 0
67#define DO_NOT_DRIVE_TX 1
68
69#define DO_NOT_QUEUE_DMA 0
70#define QUEUE_DMA 1
71
72#define RX_TRANSFER 1
73#define TX_TRANSFER 2
74
75/*
76 * Macros to access SSP Registers with their offsets
77 */
78#define SSP_CR0(r) (r + 0x000)
79#define SSP_CR1(r) (r + 0x004)
80#define SSP_DR(r) (r + 0x008)
81#define SSP_SR(r) (r + 0x00C)
82#define SSP_CPSR(r) (r + 0x010)
83#define SSP_IMSC(r) (r + 0x014)
84#define SSP_RIS(r) (r + 0x018)
85#define SSP_MIS(r) (r + 0x01C)
86#define SSP_ICR(r) (r + 0x020)
87#define SSP_DMACR(r) (r + 0x024)
88#define SSP_ITCR(r) (r + 0x080)
89#define SSP_ITIP(r) (r + 0x084)
90#define SSP_ITOP(r) (r + 0x088)
91#define SSP_TDR(r) (r + 0x08C)
92
93#define SSP_PID0(r) (r + 0xFE0)
94#define SSP_PID1(r) (r + 0xFE4)
95#define SSP_PID2(r) (r + 0xFE8)
96#define SSP_PID3(r) (r + 0xFEC)
97
98#define SSP_CID0(r) (r + 0xFF0)
99#define SSP_CID1(r) (r + 0xFF4)
100#define SSP_CID2(r) (r + 0xFF8)
101#define SSP_CID3(r) (r + 0xFFC)
102
103/*
104 * SSP Control Register 0 - SSP_CR0
105 */
106#define SSP_CR0_MASK_DSS (0x1FUL << 0)
107#define SSP_CR0_MASK_HALFDUP (0x1UL << 5)
108#define SSP_CR0_MASK_SPO (0x1UL << 6)
109#define SSP_CR0_MASK_SPH (0x1UL << 7)
110#define SSP_CR0_MASK_SCR (0xFFUL << 8)
111#define SSP_CR0_MASK_CSS (0x1FUL << 16)
112#define SSP_CR0_MASK_FRF (0x3UL << 21)
113
114/*
115 * SSP Control Register 0 - SSP_CR1
116 */
117#define SSP_CR1_MASK_LBM (0x1UL << 0)
118#define SSP_CR1_MASK_SSE (0x1UL << 1)
119#define SSP_CR1_MASK_MS (0x1UL << 2)
120#define SSP_CR1_MASK_SOD (0x1UL << 3)
121#define SSP_CR1_MASK_RENDN (0x1UL << 4)
122#define SSP_CR1_MASK_TENDN (0x1UL << 5)
123#define SSP_CR1_MASK_MWAIT (0x1UL << 6)
124#define SSP_CR1_MASK_RXIFLSEL (0x7UL << 7)
125#define SSP_CR1_MASK_TXIFLSEL (0x7UL << 10)
126
127/*
128 * SSP Data Register - SSP_DR
129 */
130#define SSP_DR_MASK_DATA 0xFFFFFFFF
131
132/*
133 * SSP Status Register - SSP_SR
134 */
135#define SSP_SR_MASK_TFE (0x1UL << 0) /* Transmit FIFO empty */
136#define SSP_SR_MASK_TNF (0x1UL << 1) /* Transmit FIFO not full */
137#define SSP_SR_MASK_RNE (0x1UL << 2) /* Receive FIFO not empty */
138#define SSP_SR_MASK_RFF (0x1UL << 3) /* Receive FIFO full */
139#define SSP_SR_MASK_BSY (0x1UL << 4) /* Busy Flag */
140
141/*
142 * SSP Clock Prescale Register - SSP_CPSR
143 */
144#define SSP_CPSR_MASK_CPSDVSR (0xFFUL << 0)
145
146/*
147 * SSP Interrupt Mask Set/Clear Register - SSP_IMSC
148 */
149#define SSP_IMSC_MASK_RORIM (0x1UL << 0) /* Receive Overrun Interrupt mask */
150#define SSP_IMSC_MASK_RTIM (0x1UL << 1) /* Receive timeout Interrupt mask */
151#define SSP_IMSC_MASK_RXIM (0x1UL << 2) /* Receive FIFO Interrupt mask */
152#define SSP_IMSC_MASK_TXIM (0x1UL << 3) /* Transmit FIFO Interrupt mask */
153
154/*
155 * SSP Raw Interrupt Status Register - SSP_RIS
156 */
157/* Receive Overrun Raw Interrupt status */
158#define SSP_RIS_MASK_RORRIS (0x1UL << 0)
159/* Receive Timeout Raw Interrupt status */
160#define SSP_RIS_MASK_RTRIS (0x1UL << 1)
161/* Receive FIFO Raw Interrupt status */
162#define SSP_RIS_MASK_RXRIS (0x1UL << 2)
163/* Transmit FIFO Raw Interrupt status */
164#define SSP_RIS_MASK_TXRIS (0x1UL << 3)
165
166/*
167 * SSP Masked Interrupt Status Register - SSP_MIS
168 */
169/* Receive Overrun Masked Interrupt status */
170#define SSP_MIS_MASK_RORMIS (0x1UL << 0)
171/* Receive Timeout Masked Interrupt status */
172#define SSP_MIS_MASK_RTMIS (0x1UL << 1)
173/* Receive FIFO Masked Interrupt status */
174#define SSP_MIS_MASK_RXMIS (0x1UL << 2)
175/* Transmit FIFO Masked Interrupt status */
176#define SSP_MIS_MASK_TXMIS (0x1UL << 3)
177
178/*
179 * SSP Interrupt Clear Register - SSP_ICR
180 */
181/* Receive Overrun Raw Clear Interrupt bit */
182#define SSP_ICR_MASK_RORIC (0x1UL << 0)
183/* Receive Timeout Clear Interrupt bit */
184#define SSP_ICR_MASK_RTIC (0x1UL << 1)
185
186/*
187 * SSP DMA Control Register - SSP_DMACR
188 */
189/* Receive DMA Enable bit */
190#define SSP_DMACR_MASK_RXDMAE (0x1UL << 0)
191/* Transmit DMA Enable bit */
192#define SSP_DMACR_MASK_TXDMAE (0x1UL << 1)
193
194/*
195 * SSP Integration Test control Register - SSP_ITCR
196 */
197#define SSP_ITCR_MASK_ITEN (0x1UL << 0)
198#define SSP_ITCR_MASK_TESTFIFO (0x1UL << 1)
199
200/*
201 * SSP Integration Test Input Register - SSP_ITIP
202 */
203#define ITIP_MASK_SSPRXD (0x1UL << 0)
204#define ITIP_MASK_SSPFSSIN (0x1UL << 1)
205#define ITIP_MASK_SSPCLKIN (0x1UL << 2)
206#define ITIP_MASK_RXDMAC (0x1UL << 3)
207#define ITIP_MASK_TXDMAC (0x1UL << 4)
208#define ITIP_MASK_SSPTXDIN (0x1UL << 5)
209
210/*
211 * SSP Integration Test output Register - SSP_ITOP
212 */
213#define ITOP_MASK_SSPTXD (0x1UL << 0)
214#define ITOP_MASK_SSPFSSOUT (0x1UL << 1)
215#define ITOP_MASK_SSPCLKOUT (0x1UL << 2)
216#define ITOP_MASK_SSPOEn (0x1UL << 3)
217#define ITOP_MASK_SSPCTLOEn (0x1UL << 4)
218#define ITOP_MASK_RORINTR (0x1UL << 5)
219#define ITOP_MASK_RTINTR (0x1UL << 6)
220#define ITOP_MASK_RXINTR (0x1UL << 7)
221#define ITOP_MASK_TXINTR (0x1UL << 8)
222#define ITOP_MASK_INTR (0x1UL << 9)
223#define ITOP_MASK_RXDMABREQ (0x1UL << 10)
224#define ITOP_MASK_RXDMASREQ (0x1UL << 11)
225#define ITOP_MASK_TXDMABREQ (0x1UL << 12)
226#define ITOP_MASK_TXDMASREQ (0x1UL << 13)
227
228/*
229 * SSP Test Data Register - SSP_TDR
230 */
231#define TDR_MASK_TESTDATA (0xFFFFFFFF)
232
233/*
234 * Message State
235 * we use the spi_message.state (void *) pointer to
236 * hold a single state value, that's why all this
237 * (void *) casting is done here.
238 */
239#define STATE_START ((void *) 0)
240#define STATE_RUNNING ((void *) 1)
241#define STATE_DONE ((void *) 2)
242#define STATE_ERROR ((void *) -1)
243
244/*
245 * Queue State
246 */
247#define QUEUE_RUNNING (0)
248#define QUEUE_STOPPED (1)
249/*
250 * SSP State - Whether Enabled or Disabled
251 */
252#define SSP_DISABLED (0)
253#define SSP_ENABLED (1)
254
255/*
256 * SSP DMA State - Whether DMA Enabled or Disabled
257 */
258#define SSP_DMA_DISABLED (0)
259#define SSP_DMA_ENABLED (1)
260
261/*
262 * SSP Clock Defaults
263 */
264#define NMDK_SSP_DEFAULT_CLKRATE 0x2
265#define NMDK_SSP_DEFAULT_PRESCALE 0x40
266
267/*
268 * SSP Clock Parameter ranges
269 */
270#define CPSDVR_MIN 0x02
271#define CPSDVR_MAX 0xFE
272#define SCR_MIN 0x00
273#define SCR_MAX 0xFF
274
275/*
276 * SSP Interrupt related Macros
277 */
278#define DEFAULT_SSP_REG_IMSC 0x0UL
279#define DISABLE_ALL_INTERRUPTS DEFAULT_SSP_REG_IMSC
280#define ENABLE_ALL_INTERRUPTS (~DEFAULT_SSP_REG_IMSC)
281
282#define CLEAR_ALL_INTERRUPTS 0x3
283
284
285/*
286 * The type of reading going on on this chip
287 */
288enum ssp_reading {
289 READING_NULL,
290 READING_U8,
291 READING_U16,
292 READING_U32
293};
294
295/**
296 * The type of writing going on on this chip
297 */
298enum ssp_writing {
299 WRITING_NULL,
300 WRITING_U8,
301 WRITING_U16,
302 WRITING_U32
303};
304
305/**
306 * struct vendor_data - vendor-specific config parameters
307 * for PL022 derivates
308 * @fifodepth: depth of FIFOs (both)
309 * @max_bpw: maximum number of bits per word
310 * @unidir: supports unidirection transfers
311 */
312struct vendor_data {
313 int fifodepth;
314 int max_bpw;
315 bool unidir;
316};
317
318/**
319 * struct pl022 - This is the private SSP driver data structure
320 * @adev: AMBA device model hookup
321 * @phybase: The physical memory where the SSP device resides
322 * @virtbase: The virtual memory where the SSP is mapped
323 * @master: SPI framework hookup
324 * @master_info: controller-specific data from machine setup
325 * @regs: SSP controller register's virtual address
326 * @pump_messages: Work struct for scheduling work to the workqueue
327 * @lock: spinlock to syncronise access to driver data
328 * @workqueue: a workqueue on which any spi_message request is queued
329 * @busy: workqueue is busy
330 * @run: workqueue is running
331 * @pump_transfers: Tasklet used in Interrupt Transfer mode
332 * @cur_msg: Pointer to current spi_message being processed
333 * @cur_transfer: Pointer to current spi_transfer
334 * @cur_chip: pointer to current clients chip(assigned from controller_state)
335 * @tx: current position in TX buffer to be read
336 * @tx_end: end position in TX buffer to be read
337 * @rx: current position in RX buffer to be written
338 * @rx_end: end position in RX buffer to be written
339 * @readingtype: the type of read currently going on
340 * @writingtype: the type or write currently going on
341 */
342struct pl022 {
343 struct amba_device *adev;
344 struct vendor_data *vendor;
345 resource_size_t phybase;
346 void __iomem *virtbase;
347 struct clk *clk;
348 struct spi_master *master;
349 struct pl022_ssp_controller *master_info;
350 /* Driver message queue */
351 struct workqueue_struct *workqueue;
352 struct work_struct pump_messages;
353 spinlock_t queue_lock;
354 struct list_head queue;
355 int busy;
356 int run;
357 /* Message transfer pump */
358 struct tasklet_struct pump_transfers;
359 struct spi_message *cur_msg;
360 struct spi_transfer *cur_transfer;
361 struct chip_data *cur_chip;
362 void *tx;
363 void *tx_end;
364 void *rx;
365 void *rx_end;
366 enum ssp_reading read;
367 enum ssp_writing write;
368};
369
370/**
371 * struct chip_data - To maintain runtime state of SSP for each client chip
372 * @cr0: Value of control register CR0 of SSP
373 * @cr1: Value of control register CR1 of SSP
374 * @dmacr: Value of DMA control Register of SSP
375 * @cpsr: Value of Clock prescale register
376 * @n_bytes: how many bytes(power of 2) reqd for a given data width of client
377 * @enable_dma: Whether to enable DMA or not
378 * @write: function ptr to be used to write when doing xfer for this chip
379 * @read: function ptr to be used to read when doing xfer for this chip
380 * @cs_control: chip select callback provided by chip
381 * @xfer_type: polling/interrupt/DMA
382 *
383 * Runtime state of the SSP controller, maintained per chip,
384 * This would be set according to the current message that would be served
385 */
386struct chip_data {
387 u16 cr0;
388 u16 cr1;
389 u16 dmacr;
390 u16 cpsr;
391 u8 n_bytes;
392 u8 enable_dma:1;
393 enum ssp_reading read;
394 enum ssp_writing write;
395 void (*cs_control) (u32 command);
396 int xfer_type;
397};
398
399/**
400 * null_cs_control - Dummy chip select function
401 * @command: select/delect the chip
402 *
403 * If no chip select function is provided by client this is used as dummy
404 * chip select
405 */
406static void null_cs_control(u32 command)
407{
408 pr_debug("pl022: dummy chip select control, CS=0x%x\n", command);
409}
410
411/**
412 * giveback - current spi_message is over, schedule next message and call
413 * callback of this message. Assumes that caller already
414 * set message->status; dma and pio irqs are blocked
415 * @pl022: SSP driver private data structure
416 */
417static void giveback(struct pl022 *pl022)
418{
419 struct spi_transfer *last_transfer;
420 unsigned long flags;
421 struct spi_message *msg;
422 void (*curr_cs_control) (u32 command);
423
424 /*
425 * This local reference to the chip select function
426 * is needed because we set curr_chip to NULL
427 * as a step toward termininating the message.
428 */
429 curr_cs_control = pl022->cur_chip->cs_control;
430 spin_lock_irqsave(&pl022->queue_lock, flags);
431 msg = pl022->cur_msg;
432 pl022->cur_msg = NULL;
433 pl022->cur_transfer = NULL;
434 pl022->cur_chip = NULL;
435 queue_work(pl022->workqueue, &pl022->pump_messages);
436 spin_unlock_irqrestore(&pl022->queue_lock, flags);
437
438 last_transfer = list_entry(msg->transfers.prev,
439 struct spi_transfer,
440 transfer_list);
441
442 /* Delay if requested before any change in chip select */
443 if (last_transfer->delay_usecs)
444 /*
445 * FIXME: This runs in interrupt context.
446 * Is this really smart?
447 */
448 udelay(last_transfer->delay_usecs);
449
450 /*
451 * Drop chip select UNLESS cs_change is true or we are returning
452 * a message with an error, or next message is for another chip
453 */
454 if (!last_transfer->cs_change)
455 curr_cs_control(SSP_CHIP_DESELECT);
456 else {
457 struct spi_message *next_msg;
458
459 /* Holding of cs was hinted, but we need to make sure
460 * the next message is for the same chip. Don't waste
461 * time with the following tests unless this was hinted.
462 *
463 * We cannot postpone this until pump_messages, because
464 * after calling msg->complete (below) the driver that
465 * sent the current message could be unloaded, which
466 * could invalidate the cs_control() callback...
467 */
468
469 /* get a pointer to the next message, if any */
470 spin_lock_irqsave(&pl022->queue_lock, flags);
471 if (list_empty(&pl022->queue))
472 next_msg = NULL;
473 else
474 next_msg = list_entry(pl022->queue.next,
475 struct spi_message, queue);
476 spin_unlock_irqrestore(&pl022->queue_lock, flags);
477
478 /* see if the next and current messages point
479 * to the same chip
480 */
481 if (next_msg && next_msg->spi != msg->spi)
482 next_msg = NULL;
483 if (!next_msg || msg->state == STATE_ERROR)
484 curr_cs_control(SSP_CHIP_DESELECT);
485 }
486 msg->state = NULL;
487 if (msg->complete)
488 msg->complete(msg->context);
489 /* This message is completed, so let's turn off the clock! */
490 clk_disable(pl022->clk);
491}
492
493/**
494 * flush - flush the FIFO to reach a clean state
495 * @pl022: SSP driver private data structure
496 */
497static int flush(struct pl022 *pl022)
498{
499 unsigned long limit = loops_per_jiffy << 1;
500
501 dev_dbg(&pl022->adev->dev, "flush\n");
502 do {
503 while (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
504 readw(SSP_DR(pl022->virtbase));
505 } while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_BSY) && limit--);
506 return limit;
507}
508
509/**
510 * restore_state - Load configuration of current chip
511 * @pl022: SSP driver private data structure
512 */
513static void restore_state(struct pl022 *pl022)
514{
515 struct chip_data *chip = pl022->cur_chip;
516
517 writew(chip->cr0, SSP_CR0(pl022->virtbase));
518 writew(chip->cr1, SSP_CR1(pl022->virtbase));
519 writew(chip->dmacr, SSP_DMACR(pl022->virtbase));
520 writew(chip->cpsr, SSP_CPSR(pl022->virtbase));
521 writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
522 writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
523}
524
525/**
526 * load_ssp_default_config - Load default configuration for SSP
527 * @pl022: SSP driver private data structure
528 */
529
530/*
531 * Default SSP Register Values
532 */
533#define DEFAULT_SSP_REG_CR0 ( \
534 GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS, 0) | \
535 GEN_MASK_BITS(SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, SSP_CR0_MASK_HALFDUP, 5) | \
536 GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \
537 GEN_MASK_BITS(SSP_CLK_FALLING_EDGE, SSP_CR0_MASK_SPH, 7) | \
538 GEN_MASK_BITS(NMDK_SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) | \
539 GEN_MASK_BITS(SSP_BITS_8, SSP_CR0_MASK_CSS, 16) | \
540 GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF, 21) \
541)
542
543#define DEFAULT_SSP_REG_CR1 ( \
544 GEN_MASK_BITS(LOOPBACK_DISABLED, SSP_CR1_MASK_LBM, 0) | \
545 GEN_MASK_BITS(SSP_DISABLED, SSP_CR1_MASK_SSE, 1) | \
546 GEN_MASK_BITS(SSP_MASTER, SSP_CR1_MASK_MS, 2) | \
547 GEN_MASK_BITS(DO_NOT_DRIVE_TX, SSP_CR1_MASK_SOD, 3) | \
548 GEN_MASK_BITS(SSP_RX_MSB, SSP_CR1_MASK_RENDN, 4) | \
549 GEN_MASK_BITS(SSP_TX_MSB, SSP_CR1_MASK_TENDN, 5) | \
550 GEN_MASK_BITS(SSP_MWIRE_WAIT_ZERO, SSP_CR1_MASK_MWAIT, 6) |\
551 GEN_MASK_BITS(SSP_RX_1_OR_MORE_ELEM, SSP_CR1_MASK_RXIFLSEL, 7) | \
552 GEN_MASK_BITS(SSP_TX_1_OR_MORE_EMPTY_LOC, SSP_CR1_MASK_TXIFLSEL, 10) \
553)
554
555#define DEFAULT_SSP_REG_CPSR ( \
556 GEN_MASK_BITS(NMDK_SSP_DEFAULT_PRESCALE, SSP_CPSR_MASK_CPSDVSR, 0) \
557)
558
559#define DEFAULT_SSP_REG_DMACR (\
560 GEN_MASK_BITS(SSP_DMA_DISABLED, SSP_DMACR_MASK_RXDMAE, 0) | \
561 GEN_MASK_BITS(SSP_DMA_DISABLED, SSP_DMACR_MASK_TXDMAE, 1) \
562)
563
564
565static void load_ssp_default_config(struct pl022 *pl022)
566{
567 writew(DEFAULT_SSP_REG_CR0, SSP_CR0(pl022->virtbase));
568 writew(DEFAULT_SSP_REG_CR1, SSP_CR1(pl022->virtbase));
569 writew(DEFAULT_SSP_REG_DMACR, SSP_DMACR(pl022->virtbase));
570 writew(DEFAULT_SSP_REG_CPSR, SSP_CPSR(pl022->virtbase));
571 writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
572 writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
573}
574
575/**
576 * This will write to TX and read from RX according to the parameters
577 * set in pl022.
578 */
579static void readwriter(struct pl022 *pl022)
580{
581
582 /*
583 * The FIFO depth is different inbetween primecell variants.
584 * I believe filling in too much in the FIFO might cause
585 * errons in 8bit wide transfers on ARM variants (just 8 words
586 * FIFO, means only 8x8 = 64 bits in FIFO) at least.
587 *
588 * FIXME: currently we have no logic to account for this.
589 * perhaps there is even something broken in HW regarding
590 * 8bit transfers (it doesn't fail on 16bit) so this needs
591 * more investigation...
592 */
593 dev_dbg(&pl022->adev->dev,
594 "%s, rx: %p, rxend: %p, tx: %p, txend: %p\n",
595 __func__, pl022->rx, pl022->rx_end, pl022->tx, pl022->tx_end);
596
597 /* Read as much as you can */
598 while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
599 && (pl022->rx < pl022->rx_end)) {
600 switch (pl022->read) {
601 case READING_NULL:
602 readw(SSP_DR(pl022->virtbase));
603 break;
604 case READING_U8:
605 *(u8 *) (pl022->rx) =
606 readw(SSP_DR(pl022->virtbase)) & 0xFFU;
607 break;
608 case READING_U16:
609 *(u16 *) (pl022->rx) =
610 (u16) readw(SSP_DR(pl022->virtbase));
611 break;
612 case READING_U32:
613 *(u32 *) (pl022->rx) =
614 readl(SSP_DR(pl022->virtbase));
615 break;
616 }
617 pl022->rx += (pl022->cur_chip->n_bytes);
618 }
619 /*
620 * Write as much as you can, while keeping an eye on the RX FIFO!
621 */
622 while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_TNF)
623 && (pl022->tx < pl022->tx_end)) {
624 switch (pl022->write) {
625 case WRITING_NULL:
626 writew(0x0, SSP_DR(pl022->virtbase));
627 break;
628 case WRITING_U8:
629 writew(*(u8 *) (pl022->tx), SSP_DR(pl022->virtbase));
630 break;
631 case WRITING_U16:
632 writew((*(u16 *) (pl022->tx)), SSP_DR(pl022->virtbase));
633 break;
634 case WRITING_U32:
635 writel(*(u32 *) (pl022->tx), SSP_DR(pl022->virtbase));
636 break;
637 }
638 pl022->tx += (pl022->cur_chip->n_bytes);
639 /*
640 * This inner reader takes care of things appearing in the RX
641 * FIFO as we're transmitting. This will happen a lot since the
642 * clock starts running when you put things into the TX FIFO,
643 * and then things are continously clocked into the RX FIFO.
644 */
645 while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
646 && (pl022->rx < pl022->rx_end)) {
647 switch (pl022->read) {
648 case READING_NULL:
649 readw(SSP_DR(pl022->virtbase));
650 break;
651 case READING_U8:
652 *(u8 *) (pl022->rx) =
653 readw(SSP_DR(pl022->virtbase)) & 0xFFU;
654 break;
655 case READING_U16:
656 *(u16 *) (pl022->rx) =
657 (u16) readw(SSP_DR(pl022->virtbase));
658 break;
659 case READING_U32:
660 *(u32 *) (pl022->rx) =
661 readl(SSP_DR(pl022->virtbase));
662 break;
663 }
664 pl022->rx += (pl022->cur_chip->n_bytes);
665 }
666 }
667 /*
668 * When we exit here the TX FIFO should be full and the RX FIFO
669 * should be empty
670 */
671}
672
673
674/**
675 * next_transfer - Move to the Next transfer in the current spi message
676 * @pl022: SSP driver private data structure
677 *
678 * This function moves though the linked list of spi transfers in the
679 * current spi message and returns with the state of current spi
680 * message i.e whether its last transfer is done(STATE_DONE) or
681 * Next transfer is ready(STATE_RUNNING)
682 */
683static void *next_transfer(struct pl022 *pl022)
684{
685 struct spi_message *msg = pl022->cur_msg;
686 struct spi_transfer *trans = pl022->cur_transfer;
687
688 /* Move to next transfer */
689 if (trans->transfer_list.next != &msg->transfers) {
690 pl022->cur_transfer =
691 list_entry(trans->transfer_list.next,
692 struct spi_transfer, transfer_list);
693 return STATE_RUNNING;
694 }
695 return STATE_DONE;
696}
697/**
698 * pl022_interrupt_handler - Interrupt handler for SSP controller
699 *
700 * This function handles interrupts generated for an interrupt based transfer.
701 * If a receive overrun (ROR) interrupt is there then we disable SSP, flag the
702 * current message's state as STATE_ERROR and schedule the tasklet
703 * pump_transfers which will do the postprocessing of the current message by
704 * calling giveback(). Otherwise it reads data from RX FIFO till there is no
705 * more data, and writes data in TX FIFO till it is not full. If we complete
706 * the transfer we move to the next transfer and schedule the tasklet.
707 */
708static irqreturn_t pl022_interrupt_handler(int irq, void *dev_id)
709{
710 struct pl022 *pl022 = dev_id;
711 struct spi_message *msg = pl022->cur_msg;
712 u16 irq_status = 0;
713 u16 flag = 0;
714
715 if (unlikely(!msg)) {
716 dev_err(&pl022->adev->dev,
717 "bad message state in interrupt handler");
718 /* Never fail */
719 return IRQ_HANDLED;
720 }
721
722 /* Read the Interrupt Status Register */
723 irq_status = readw(SSP_MIS(pl022->virtbase));
724
725 if (unlikely(!irq_status))
726 return IRQ_NONE;
727
728 /* This handles the error code interrupts */
729 if (unlikely(irq_status & SSP_MIS_MASK_RORMIS)) {
730 /*
731 * Overrun interrupt - bail out since our Data has been
732 * corrupted
733 */
734 dev_err(&pl022->adev->dev,
735 "FIFO overrun\n");
736 if (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RFF)
737 dev_err(&pl022->adev->dev,
738 "RXFIFO is full\n");
739 if (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_TNF)
740 dev_err(&pl022->adev->dev,
741 "TXFIFO is full\n");
742
743 /*
744 * Disable and clear interrupts, disable SSP,
745 * mark message with bad status so it can be
746 * retried.
747 */
748 writew(DISABLE_ALL_INTERRUPTS,
749 SSP_IMSC(pl022->virtbase));
750 writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
751 writew((readw(SSP_CR1(pl022->virtbase)) &
752 (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
753 msg->state = STATE_ERROR;
754
755 /* Schedule message queue handler */
756 tasklet_schedule(&pl022->pump_transfers);
757 return IRQ_HANDLED;
758 }
759
760 readwriter(pl022);
761
762 if ((pl022->tx == pl022->tx_end) && (flag == 0)) {
763 flag = 1;
764 /* Disable Transmit interrupt */
765 writew(readw(SSP_IMSC(pl022->virtbase)) &
766 (~SSP_IMSC_MASK_TXIM),
767 SSP_IMSC(pl022->virtbase));
768 }
769
770 /*
771 * Since all transactions must write as much as shall be read,
772 * we can conclude the entire transaction once RX is complete.
773 * At this point, all TX will always be finished.
774 */
775 if (pl022->rx >= pl022->rx_end) {
776 writew(DISABLE_ALL_INTERRUPTS,
777 SSP_IMSC(pl022->virtbase));
778 writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
779 if (unlikely(pl022->rx > pl022->rx_end)) {
780 dev_warn(&pl022->adev->dev, "read %u surplus "
781 "bytes (did you request an odd "
782 "number of bytes on a 16bit bus?)\n",
783 (u32) (pl022->rx - pl022->rx_end));
784 }
785 /* Update total bytes transfered */
786 msg->actual_length += pl022->cur_transfer->len;
787 if (pl022->cur_transfer->cs_change)
788 pl022->cur_chip->
789 cs_control(SSP_CHIP_DESELECT);
790 /* Move to next transfer */
791 msg->state = next_transfer(pl022);
792 tasklet_schedule(&pl022->pump_transfers);
793 return IRQ_HANDLED;
794 }
795
796 return IRQ_HANDLED;
797}
798
799/**
800 * This sets up the pointers to memory for the next message to
801 * send out on the SPI bus.
802 */
803static int set_up_next_transfer(struct pl022 *pl022,
804 struct spi_transfer *transfer)
805{
806 int residue;
807
808 /* Sanity check the message for this bus width */
809 residue = pl022->cur_transfer->len % pl022->cur_chip->n_bytes;
810 if (unlikely(residue != 0)) {
811 dev_err(&pl022->adev->dev,
812 "message of %u bytes to transmit but the current "
813 "chip bus has a data width of %u bytes!\n",
814 pl022->cur_transfer->len,
815 pl022->cur_chip->n_bytes);
816 dev_err(&pl022->adev->dev, "skipping this message\n");
817 return -EIO;
818 }
819 pl022->tx = (void *)transfer->tx_buf;
820 pl022->tx_end = pl022->tx + pl022->cur_transfer->len;
821 pl022->rx = (void *)transfer->rx_buf;
822 pl022->rx_end = pl022->rx + pl022->cur_transfer->len;
823 pl022->write =
824 pl022->tx ? pl022->cur_chip->write : WRITING_NULL;
825 pl022->read = pl022->rx ? pl022->cur_chip->read : READING_NULL;
826 return 0;
827}
828
829/**
830 * pump_transfers - Tasklet function which schedules next interrupt transfer
831 * when running in interrupt transfer mode.
832 * @data: SSP driver private data structure
833 *
834 */
835static void pump_transfers(unsigned long data)
836{
837 struct pl022 *pl022 = (struct pl022 *) data;
838 struct spi_message *message = NULL;
839 struct spi_transfer *transfer = NULL;
840 struct spi_transfer *previous = NULL;
841
842 /* Get current state information */
843 message = pl022->cur_msg;
844 transfer = pl022->cur_transfer;
845
846 /* Handle for abort */
847 if (message->state == STATE_ERROR) {
848 message->status = -EIO;
849 giveback(pl022);
850 return;
851 }
852
853 /* Handle end of message */
854 if (message->state == STATE_DONE) {
855 message->status = 0;
856 giveback(pl022);
857 return;
858 }
859
860 /* Delay if requested at end of transfer before CS change */
861 if (message->state == STATE_RUNNING) {
862 previous = list_entry(transfer->transfer_list.prev,
863 struct spi_transfer,
864 transfer_list);
865 if (previous->delay_usecs)
866 /*
867 * FIXME: This runs in interrupt context.
868 * Is this really smart?
869 */
870 udelay(previous->delay_usecs);
871
872 /* Drop chip select only if cs_change is requested */
873 if (previous->cs_change)
874 pl022->cur_chip->cs_control(SSP_CHIP_SELECT);
875 } else {
876 /* STATE_START */
877 message->state = STATE_RUNNING;
878 }
879
880 if (set_up_next_transfer(pl022, transfer)) {
881 message->state = STATE_ERROR;
882 message->status = -EIO;
883 giveback(pl022);
884 return;
885 }
886 /* Flush the FIFOs and let's go! */
887 flush(pl022);
888 writew(ENABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
889}
890
891/**
892 * NOT IMPLEMENTED
893 * configure_dma - It configures the DMA pipes for DMA transfers
894 * @data: SSP driver's private data structure
895 *
896 */
897static int configure_dma(void *data)
898{
899 struct pl022 *pl022 = data;
900 dev_dbg(&pl022->adev->dev, "configure DMA\n");
901 return -ENOTSUPP;
902}
903
904/**
905 * do_dma_transfer - It handles transfers of the current message
906 * if it is DMA xfer.
907 * NOT FULLY IMPLEMENTED
908 * @data: SSP driver's private data structure
909 */
910static void do_dma_transfer(void *data)
911{
912 struct pl022 *pl022 = data;
913
914 if (configure_dma(data)) {
915 dev_dbg(&pl022->adev->dev, "configuration of DMA Failed!\n");
916 goto err_config_dma;
917 }
918
919 /* TODO: Implememt DMA setup of pipes here */
920
921 /* Enable target chip, set up transfer */
922 pl022->cur_chip->cs_control(SSP_CHIP_SELECT);
923 if (set_up_next_transfer(pl022, pl022->cur_transfer)) {
924 /* Error path */
925 pl022->cur_msg->state = STATE_ERROR;
926 pl022->cur_msg->status = -EIO;
927 giveback(pl022);
928 return;
929 }
930 /* Enable SSP */
931 writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE),
932 SSP_CR1(pl022->virtbase));
933
934 /* TODO: Enable the DMA transfer here */
935 return;
936
937 err_config_dma:
938 pl022->cur_msg->state = STATE_ERROR;
939 pl022->cur_msg->status = -EIO;
940 giveback(pl022);
941 return;
942}
943
944static void do_interrupt_transfer(void *data)
945{
946 struct pl022 *pl022 = data;
947
948 /* Enable target chip */
949 pl022->cur_chip->cs_control(SSP_CHIP_SELECT);
950 if (set_up_next_transfer(pl022, pl022->cur_transfer)) {
951 /* Error path */
952 pl022->cur_msg->state = STATE_ERROR;
953 pl022->cur_msg->status = -EIO;
954 giveback(pl022);
955 return;
956 }
957 /* Enable SSP, turn on interrupts */
958 writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE),
959 SSP_CR1(pl022->virtbase));
960 writew(ENABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
961}
962
963static void do_polling_transfer(void *data)
964{
965 struct pl022 *pl022 = data;
966 struct spi_message *message = NULL;
967 struct spi_transfer *transfer = NULL;
968 struct spi_transfer *previous = NULL;
969 struct chip_data *chip;
970
971 chip = pl022->cur_chip;
972 message = pl022->cur_msg;
973
974 while (message->state != STATE_DONE) {
975 /* Handle for abort */
976 if (message->state == STATE_ERROR)
977 break;
978 transfer = pl022->cur_transfer;
979
980 /* Delay if requested at end of transfer */
981 if (message->state == STATE_RUNNING) {
982 previous =
983 list_entry(transfer->transfer_list.prev,
984 struct spi_transfer, transfer_list);
985 if (previous->delay_usecs)
986 udelay(previous->delay_usecs);
987 if (previous->cs_change)
988 pl022->cur_chip->cs_control(SSP_CHIP_SELECT);
989 } else {
990 /* STATE_START */
991 message->state = STATE_RUNNING;
992 pl022->cur_chip->cs_control(SSP_CHIP_SELECT);
993 }
994
995 /* Configuration Changing Per Transfer */
996 if (set_up_next_transfer(pl022, transfer)) {
997 /* Error path */
998 message->state = STATE_ERROR;
999 break;
1000 }
1001 /* Flush FIFOs and enable SSP */
1002 flush(pl022);
1003 writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE),
1004 SSP_CR1(pl022->virtbase));
1005
1006 dev_dbg(&pl022->adev->dev, "POLLING TRANSFER ONGOING ... \n");
1007 /* FIXME: insert a timeout so we don't hang here indefinately */
1008 while (pl022->tx < pl022->tx_end || pl022->rx < pl022->rx_end)
1009 readwriter(pl022);
1010
1011 /* Update total byte transfered */
1012 message->actual_length += pl022->cur_transfer->len;
1013 if (pl022->cur_transfer->cs_change)
1014 pl022->cur_chip->cs_control(SSP_CHIP_DESELECT);
1015 /* Move to next transfer */
1016 message->state = next_transfer(pl022);
1017 }
1018
1019 /* Handle end of message */
1020 if (message->state == STATE_DONE)
1021 message->status = 0;
1022 else
1023 message->status = -EIO;
1024
1025 giveback(pl022);
1026 return;
1027}
1028
1029/**
1030 * pump_messages - Workqueue function which processes spi message queue
1031 * @data: pointer to private data of SSP driver
1032 *
1033 * This function checks if there is any spi message in the queue that
1034 * needs processing and delegate control to appropriate function
1035 * do_polling_transfer()/do_interrupt_transfer()/do_dma_transfer()
1036 * based on the kind of the transfer
1037 *
1038 */
1039static void pump_messages(struct work_struct *work)
1040{
1041 struct pl022 *pl022 =
1042 container_of(work, struct pl022, pump_messages);
1043 unsigned long flags;
1044
1045 /* Lock queue and check for queue work */
1046 spin_lock_irqsave(&pl022->queue_lock, flags);
1047 if (list_empty(&pl022->queue) || pl022->run == QUEUE_STOPPED) {
1048 pl022->busy = 0;
1049 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1050 return;
1051 }
1052 /* Make sure we are not already running a message */
1053 if (pl022->cur_msg) {
1054 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1055 return;
1056 }
1057 /* Extract head of queue */
1058 pl022->cur_msg =
1059 list_entry(pl022->queue.next, struct spi_message, queue);
1060
1061 list_del_init(&pl022->cur_msg->queue);
1062 pl022->busy = 1;
1063 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1064
1065 /* Initial message state */
1066 pl022->cur_msg->state = STATE_START;
1067 pl022->cur_transfer = list_entry(pl022->cur_msg->transfers.next,
1068 struct spi_transfer,
1069 transfer_list);
1070
1071 /* Setup the SPI using the per chip configuration */
1072 pl022->cur_chip = spi_get_ctldata(pl022->cur_msg->spi);
1073 /*
1074 * We enable the clock here, then the clock will be disabled when
1075 * giveback() is called in each method (poll/interrupt/DMA)
1076 */
1077 clk_enable(pl022->clk);
1078 restore_state(pl022);
1079 flush(pl022);
1080
1081 if (pl022->cur_chip->xfer_type == POLLING_TRANSFER)
1082 do_polling_transfer(pl022);
1083 else if (pl022->cur_chip->xfer_type == INTERRUPT_TRANSFER)
1084 do_interrupt_transfer(pl022);
1085 else
1086 do_dma_transfer(pl022);
1087}
1088
1089
1090static int __init init_queue(struct pl022 *pl022)
1091{
1092 INIT_LIST_HEAD(&pl022->queue);
1093 spin_lock_init(&pl022->queue_lock);
1094
1095 pl022->run = QUEUE_STOPPED;
1096 pl022->busy = 0;
1097
1098 tasklet_init(&pl022->pump_transfers,
1099 pump_transfers, (unsigned long)pl022);
1100
1101 INIT_WORK(&pl022->pump_messages, pump_messages);
1102 pl022->workqueue = create_singlethread_workqueue(
1103 dev_name(pl022->master->dev.parent));
1104 if (pl022->workqueue == NULL)
1105 return -EBUSY;
1106
1107 return 0;
1108}
1109
1110
1111static int start_queue(struct pl022 *pl022)
1112{
1113 unsigned long flags;
1114
1115 spin_lock_irqsave(&pl022->queue_lock, flags);
1116
1117 if (pl022->run == QUEUE_RUNNING || pl022->busy) {
1118 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1119 return -EBUSY;
1120 }
1121
1122 pl022->run = QUEUE_RUNNING;
1123 pl022->cur_msg = NULL;
1124 pl022->cur_transfer = NULL;
1125 pl022->cur_chip = NULL;
1126 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1127
1128 queue_work(pl022->workqueue, &pl022->pump_messages);
1129
1130 return 0;
1131}
1132
1133
1134static int stop_queue(struct pl022 *pl022)
1135{
1136 unsigned long flags;
1137 unsigned limit = 500;
1138 int status = 0;
1139
1140 spin_lock_irqsave(&pl022->queue_lock, flags);
1141
1142 /* This is a bit lame, but is optimized for the common execution path.
1143 * A wait_queue on the pl022->busy could be used, but then the common
1144 * execution path (pump_messages) would be required to call wake_up or
1145 * friends on every SPI message. Do this instead */
1146 pl022->run = QUEUE_STOPPED;
1147 while (!list_empty(&pl022->queue) && pl022->busy && limit--) {
1148 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1149 msleep(10);
1150 spin_lock_irqsave(&pl022->queue_lock, flags);
1151 }
1152
1153 if (!list_empty(&pl022->queue) || pl022->busy)
1154 status = -EBUSY;
1155
1156 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1157
1158 return status;
1159}
1160
1161static int destroy_queue(struct pl022 *pl022)
1162{
1163 int status;
1164
1165 status = stop_queue(pl022);
1166 /* we are unloading the module or failing to load (only two calls
1167 * to this routine), and neither call can handle a return value.
1168 * However, destroy_workqueue calls flush_workqueue, and that will
1169 * block until all work is done. If the reason that stop_queue
1170 * timed out is that the work will never finish, then it does no
1171 * good to call destroy_workqueue, so return anyway. */
1172 if (status != 0)
1173 return status;
1174
1175 destroy_workqueue(pl022->workqueue);
1176
1177 return 0;
1178}
1179
1180static int verify_controller_parameters(struct pl022 *pl022,
1181 struct pl022_config_chip *chip_info)
1182{
1183 if ((chip_info->lbm != LOOPBACK_ENABLED)
1184 && (chip_info->lbm != LOOPBACK_DISABLED)) {
1185 dev_err(chip_info->dev,
1186 "loopback Mode is configured incorrectly\n");
1187 return -EINVAL;
1188 }
1189 if ((chip_info->iface < SSP_INTERFACE_MOTOROLA_SPI)
1190 || (chip_info->iface > SSP_INTERFACE_UNIDIRECTIONAL)) {
1191 dev_err(chip_info->dev,
1192 "interface is configured incorrectly\n");
1193 return -EINVAL;
1194 }
1195 if ((chip_info->iface == SSP_INTERFACE_UNIDIRECTIONAL) &&
1196 (!pl022->vendor->unidir)) {
1197 dev_err(chip_info->dev,
1198 "unidirectional mode not supported in this "
1199 "hardware version\n");
1200 return -EINVAL;
1201 }
1202 if ((chip_info->hierarchy != SSP_MASTER)
1203 && (chip_info->hierarchy != SSP_SLAVE)) {
1204 dev_err(chip_info->dev,
1205 "hierarchy is configured incorrectly\n");
1206 return -EINVAL;
1207 }
1208 if (((chip_info->clk_freq).cpsdvsr < CPSDVR_MIN)
1209 || ((chip_info->clk_freq).cpsdvsr > CPSDVR_MAX)) {
1210 dev_err(chip_info->dev,
1211 "cpsdvsr is configured incorrectly\n");
1212 return -EINVAL;
1213 }
1214 if ((chip_info->endian_rx != SSP_RX_MSB)
1215 && (chip_info->endian_rx != SSP_RX_LSB)) {
1216 dev_err(chip_info->dev,
1217 "RX FIFO endianess is configured incorrectly\n");
1218 return -EINVAL;
1219 }
1220 if ((chip_info->endian_tx != SSP_TX_MSB)
1221 && (chip_info->endian_tx != SSP_TX_LSB)) {
1222 dev_err(chip_info->dev,
1223 "TX FIFO endianess is configured incorrectly\n");
1224 return -EINVAL;
1225 }
1226 if ((chip_info->data_size < SSP_DATA_BITS_4)
1227 || (chip_info->data_size > SSP_DATA_BITS_32)) {
1228 dev_err(chip_info->dev,
1229 "DATA Size is configured incorrectly\n");
1230 return -EINVAL;
1231 }
1232 if ((chip_info->com_mode != INTERRUPT_TRANSFER)
1233 && (chip_info->com_mode != DMA_TRANSFER)
1234 && (chip_info->com_mode != POLLING_TRANSFER)) {
1235 dev_err(chip_info->dev,
1236 "Communication mode is configured incorrectly\n");
1237 return -EINVAL;
1238 }
1239 if ((chip_info->rx_lev_trig < SSP_RX_1_OR_MORE_ELEM)
1240 || (chip_info->rx_lev_trig > SSP_RX_32_OR_MORE_ELEM)) {
1241 dev_err(chip_info->dev,
1242 "RX FIFO Trigger Level is configured incorrectly\n");
1243 return -EINVAL;
1244 }
1245 if ((chip_info->tx_lev_trig < SSP_TX_1_OR_MORE_EMPTY_LOC)
1246 || (chip_info->tx_lev_trig > SSP_TX_32_OR_MORE_EMPTY_LOC)) {
1247 dev_err(chip_info->dev,
1248 "TX FIFO Trigger Level is configured incorrectly\n");
1249 return -EINVAL;
1250 }
1251 if (chip_info->iface == SSP_INTERFACE_MOTOROLA_SPI) {
1252 if ((chip_info->clk_phase != SSP_CLK_RISING_EDGE)
1253 && (chip_info->clk_phase != SSP_CLK_FALLING_EDGE)) {
1254 dev_err(chip_info->dev,
1255 "Clock Phase is configured incorrectly\n");
1256 return -EINVAL;
1257 }
1258 if ((chip_info->clk_pol != SSP_CLK_POL_IDLE_LOW)
1259 && (chip_info->clk_pol != SSP_CLK_POL_IDLE_HIGH)) {
1260 dev_err(chip_info->dev,
1261 "Clock Polarity is configured incorrectly\n");
1262 return -EINVAL;
1263 }
1264 }
1265 if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) {
1266 if ((chip_info->ctrl_len < SSP_BITS_4)
1267 || (chip_info->ctrl_len > SSP_BITS_32)) {
1268 dev_err(chip_info->dev,
1269 "CTRL LEN is configured incorrectly\n");
1270 return -EINVAL;
1271 }
1272 if ((chip_info->wait_state != SSP_MWIRE_WAIT_ZERO)
1273 && (chip_info->wait_state != SSP_MWIRE_WAIT_ONE)) {
1274 dev_err(chip_info->dev,
1275 "Wait State is configured incorrectly\n");
1276 return -EINVAL;
1277 }
1278 if ((chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
1279 && (chip_info->duplex !=
1280 SSP_MICROWIRE_CHANNEL_HALF_DUPLEX)) {
1281 dev_err(chip_info->dev,
1282 "DUPLEX is configured incorrectly\n");
1283 return -EINVAL;
1284 }
1285 }
1286 if (chip_info->cs_control == NULL) {
1287 dev_warn(chip_info->dev,
1288 "Chip Select Function is NULL for this chip\n");
1289 chip_info->cs_control = null_cs_control;
1290 }
1291 return 0;
1292}
1293
1294/**
1295 * pl022_transfer - transfer function registered to SPI master framework
1296 * @spi: spi device which is requesting transfer
1297 * @msg: spi message which is to handled is queued to driver queue
1298 *
1299 * This function is registered to the SPI framework for this SPI master
1300 * controller. It will queue the spi_message in the queue of driver if
1301 * the queue is not stopped and return.
1302 */
1303static int pl022_transfer(struct spi_device *spi, struct spi_message *msg)
1304{
1305 struct pl022 *pl022 = spi_master_get_devdata(spi->master);
1306 unsigned long flags;
1307
1308 spin_lock_irqsave(&pl022->queue_lock, flags);
1309
1310 if (pl022->run == QUEUE_STOPPED) {
1311 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1312 return -ESHUTDOWN;
1313 }
1314 msg->actual_length = 0;
1315 msg->status = -EINPROGRESS;
1316 msg->state = STATE_START;
1317
1318 list_add_tail(&msg->queue, &pl022->queue);
1319 if (pl022->run == QUEUE_RUNNING && !pl022->busy)
1320 queue_work(pl022->workqueue, &pl022->pump_messages);
1321
1322 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1323 return 0;
1324}
1325
1326static int calculate_effective_freq(struct pl022 *pl022,
1327 int freq,
1328 struct ssp_clock_params *clk_freq)
1329{
1330 /* Lets calculate the frequency parameters */
1331 u16 cpsdvsr = 2;
1332 u16 scr = 0;
1333 bool freq_found = false;
1334 u32 rate;
1335 u32 max_tclk;
1336 u32 min_tclk;
1337
1338 rate = clk_get_rate(pl022->clk);
1339 /* cpsdvscr = 2 & scr 0 */
1340 max_tclk = (rate / (CPSDVR_MIN * (1 + SCR_MIN)));
1341 /* cpsdvsr = 254 & scr = 255 */
1342 min_tclk = (rate / (CPSDVR_MAX * (1 + SCR_MAX)));
1343
1344 if ((freq <= max_tclk) && (freq >= min_tclk)) {
1345 while (cpsdvsr <= CPSDVR_MAX && !freq_found) {
1346 while (scr <= SCR_MAX && !freq_found) {
1347 if ((rate /
1348 (cpsdvsr * (1 + scr))) > freq)
1349 scr += 1;
1350 else {
1351 /*
1352 * This bool is made true when
1353 * effective frequency >=
1354 * target frequency is found
1355 */
1356 freq_found = true;
1357 if ((rate /
1358 (cpsdvsr * (1 + scr))) != freq) {
1359 if (scr == SCR_MIN) {
1360 cpsdvsr -= 2;
1361 scr = SCR_MAX;
1362 } else
1363 scr -= 1;
1364 }
1365 }
1366 }
1367 if (!freq_found) {
1368 cpsdvsr += 2;
1369 scr = SCR_MIN;
1370 }
1371 }
1372 if (cpsdvsr != 0) {
1373 dev_dbg(&pl022->adev->dev,
1374 "SSP Effective Frequency is %u\n",
1375 (rate / (cpsdvsr * (1 + scr))));
1376 clk_freq->cpsdvsr = (u8) (cpsdvsr & 0xFF);
1377 clk_freq->scr = (u8) (scr & 0xFF);
1378 dev_dbg(&pl022->adev->dev,
1379 "SSP cpsdvsr = %d, scr = %d\n",
1380 clk_freq->cpsdvsr, clk_freq->scr);
1381 }
1382 } else {
1383 dev_err(&pl022->adev->dev,
1384 "controller data is incorrect: out of range frequency");
1385 return -EINVAL;
1386 }
1387 return 0;
1388}
1389
1390/**
1391 * NOT IMPLEMENTED
1392 * process_dma_info - Processes the DMA info provided by client drivers
1393 * @chip_info: chip info provided by client device
1394 * @chip: Runtime state maintained by the SSP controller for each spi device
1395 *
1396 * This function processes and stores DMA config provided by client driver
1397 * into the runtime state maintained by the SSP controller driver
1398 */
1399static int process_dma_info(struct pl022_config_chip *chip_info,
1400 struct chip_data *chip)
1401{
1402 dev_err(chip_info->dev,
1403 "cannot process DMA info, DMA not implemented!\n");
1404 return -ENOTSUPP;
1405}
1406
1407/**
1408 * pl022_setup - setup function registered to SPI master framework
1409 * @spi: spi device which is requesting setup
1410 *
1411 * This function is registered to the SPI framework for this SPI master
1412 * controller. If it is the first time when setup is called by this device,
1413 * this function will initialize the runtime state for this chip and save
1414 * the same in the device structure. Else it will update the runtime info
1415 * with the updated chip info. Nothing is really being written to the
1416 * controller hardware here, that is not done until the actual transfer
1417 * commence.
1418 */
1419
1420/* FIXME: JUST GUESSING the spi->mode bits understood by this driver */
1421#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \
1422 | SPI_LSB_FIRST | SPI_LOOP)
1423
1424static int pl022_setup(struct spi_device *spi)
1425{
1426 struct pl022_config_chip *chip_info;
1427 struct chip_data *chip;
1428 int status = 0;
1429 struct pl022 *pl022 = spi_master_get_devdata(spi->master);
1430
1431 if (spi->mode & ~MODEBITS) {
1432 dev_dbg(&spi->dev, "unsupported mode bits %x\n",
1433 spi->mode & ~MODEBITS);
1434 return -EINVAL;
1435 }
1436
1437 if (!spi->max_speed_hz)
1438 return -EINVAL;
1439
1440 /* Get controller_state if one is supplied */
1441 chip = spi_get_ctldata(spi);
1442
1443 if (chip == NULL) {
1444 chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
1445 if (!chip) {
1446 dev_err(&spi->dev,
1447 "cannot allocate controller state\n");
1448 return -ENOMEM;
1449 }
1450 dev_dbg(&spi->dev,
1451 "allocated memory for controller's runtime state\n");
1452 }
1453
1454 /* Get controller data if one is supplied */
1455 chip_info = spi->controller_data;
1456
1457 if (chip_info == NULL) {
1458 /* spi_board_info.controller_data not is supplied */
1459 dev_dbg(&spi->dev,
1460 "using default controller_data settings\n");
1461
1462 chip_info =
1463 kzalloc(sizeof(struct pl022_config_chip), GFP_KERNEL);
1464
1465 if (!chip_info) {
1466 dev_err(&spi->dev,
1467 "cannot allocate controller data\n");
1468 status = -ENOMEM;
1469 goto err_first_setup;
1470 }
1471
1472 dev_dbg(&spi->dev, "allocated memory for controller data\n");
1473
1474 /* Pointer back to the SPI device */
1475 chip_info->dev = &spi->dev;
1476 /*
1477 * Set controller data default values:
1478 * Polling is supported by default
1479 */
1480 chip_info->lbm = LOOPBACK_DISABLED;
1481 chip_info->com_mode = POLLING_TRANSFER;
1482 chip_info->iface = SSP_INTERFACE_MOTOROLA_SPI;
1483 chip_info->hierarchy = SSP_SLAVE;
1484 chip_info->slave_tx_disable = DO_NOT_DRIVE_TX;
1485 chip_info->endian_tx = SSP_TX_LSB;
1486 chip_info->endian_rx = SSP_RX_LSB;
1487 chip_info->data_size = SSP_DATA_BITS_12;
1488 chip_info->rx_lev_trig = SSP_RX_1_OR_MORE_ELEM;
1489 chip_info->tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC;
1490 chip_info->clk_phase = SSP_CLK_FALLING_EDGE;
1491 chip_info->clk_pol = SSP_CLK_POL_IDLE_LOW;
1492 chip_info->ctrl_len = SSP_BITS_8;
1493 chip_info->wait_state = SSP_MWIRE_WAIT_ZERO;
1494 chip_info->duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX;
1495 chip_info->cs_control = null_cs_control;
1496 } else {
1497 dev_dbg(&spi->dev,
1498 "using user supplied controller_data settings\n");
1499 }
1500
1501 /*
1502 * We can override with custom divisors, else we use the board
1503 * frequency setting
1504 */
1505 if ((0 == chip_info->clk_freq.cpsdvsr)
1506 && (0 == chip_info->clk_freq.scr)) {
1507 status = calculate_effective_freq(pl022,
1508 spi->max_speed_hz,
1509 &chip_info->clk_freq);
1510 if (status < 0)
1511 goto err_config_params;
1512 } else {
1513 if ((chip_info->clk_freq.cpsdvsr % 2) != 0)
1514 chip_info->clk_freq.cpsdvsr =
1515 chip_info->clk_freq.cpsdvsr - 1;
1516 }
1517 status = verify_controller_parameters(pl022, chip_info);
1518 if (status) {
1519 dev_err(&spi->dev, "controller data is incorrect");
1520 goto err_config_params;
1521 }
1522 /* Now set controller state based on controller data */
1523 chip->xfer_type = chip_info->com_mode;
1524 chip->cs_control = chip_info->cs_control;
1525
1526 if (chip_info->data_size <= 8) {
1527 dev_dbg(&spi->dev, "1 <= n <=8 bits per word\n");
1528 chip->n_bytes = 1;
1529 chip->read = READING_U8;
1530 chip->write = WRITING_U8;
1531 } else if (chip_info->data_size <= 16) {
1532 dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n");
1533 chip->n_bytes = 2;
1534 chip->read = READING_U16;
1535 chip->write = WRITING_U16;
1536 } else {
1537 if (pl022->vendor->max_bpw >= 32) {
1538 dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
1539 chip->n_bytes = 4;
1540 chip->read = READING_U32;
1541 chip->write = WRITING_U32;
1542 } else {
1543 dev_err(&spi->dev,
1544 "illegal data size for this controller!\n");
1545 dev_err(&spi->dev,
1546 "a standard pl022 can only handle "
1547 "1 <= n <= 16 bit words\n");
1548 goto err_config_params;
1549 }
1550 }
1551
1552 /* Now Initialize all register settings required for this chip */
1553 chip->cr0 = 0;
1554 chip->cr1 = 0;
1555 chip->dmacr = 0;
1556 chip->cpsr = 0;
1557 if ((chip_info->com_mode == DMA_TRANSFER)
1558 && ((pl022->master_info)->enable_dma)) {
1559 chip->enable_dma = 1;
1560 dev_dbg(&spi->dev, "DMA mode set in controller state\n");
1561 status = process_dma_info(chip_info, chip);
1562 if (status < 0)
1563 goto err_config_params;
1564 SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
1565 SSP_DMACR_MASK_RXDMAE, 0);
1566 SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
1567 SSP_DMACR_MASK_TXDMAE, 1);
1568 } else {
1569 chip->enable_dma = 0;
1570 dev_dbg(&spi->dev, "DMA mode NOT set in controller state\n");
1571 SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
1572 SSP_DMACR_MASK_RXDMAE, 0);
1573 SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
1574 SSP_DMACR_MASK_TXDMAE, 1);
1575 }
1576
1577 chip->cpsr = chip_info->clk_freq.cpsdvsr;
1578
1579 SSP_WRITE_BITS(chip->cr0, chip_info->data_size, SSP_CR0_MASK_DSS, 0);
1580 SSP_WRITE_BITS(chip->cr0, chip_info->duplex, SSP_CR0_MASK_HALFDUP, 5);
1581 SSP_WRITE_BITS(chip->cr0, chip_info->clk_pol, SSP_CR0_MASK_SPO, 6);
1582 SSP_WRITE_BITS(chip->cr0, chip_info->clk_phase, SSP_CR0_MASK_SPH, 7);
1583 SSP_WRITE_BITS(chip->cr0, chip_info->clk_freq.scr, SSP_CR0_MASK_SCR, 8);
1584 SSP_WRITE_BITS(chip->cr0, chip_info->ctrl_len, SSP_CR0_MASK_CSS, 16);
1585 SSP_WRITE_BITS(chip->cr0, chip_info->iface, SSP_CR0_MASK_FRF, 21);
1586 SSP_WRITE_BITS(chip->cr1, chip_info->lbm, SSP_CR1_MASK_LBM, 0);
1587 SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1);
1588 SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2);
1589 SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3);
1590 SSP_WRITE_BITS(chip->cr1, chip_info->endian_rx, SSP_CR1_MASK_RENDN, 4);
1591 SSP_WRITE_BITS(chip->cr1, chip_info->endian_tx, SSP_CR1_MASK_TENDN, 5);
1592 SSP_WRITE_BITS(chip->cr1, chip_info->wait_state, SSP_CR1_MASK_MWAIT, 6);
1593 SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig, SSP_CR1_MASK_RXIFLSEL, 7);
1594 SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig, SSP_CR1_MASK_TXIFLSEL, 10);
1595
1596 /* Save controller_state */
1597 spi_set_ctldata(spi, chip);
1598 return status;
1599 err_config_params:
1600 err_first_setup:
1601 kfree(chip);
1602 return status;
1603}
1604
1605/**
1606 * pl022_cleanup - cleanup function registered to SPI master framework
1607 * @spi: spi device which is requesting cleanup
1608 *
1609 * This function is registered to the SPI framework for this SPI master
1610 * controller. It will free the runtime state of chip.
1611 */
1612static void pl022_cleanup(struct spi_device *spi)
1613{
1614 struct chip_data *chip = spi_get_ctldata(spi);
1615
1616 spi_set_ctldata(spi, NULL);
1617 kfree(chip);
1618}
1619
1620
1621static int __init
1622pl022_probe(struct amba_device *adev, struct amba_id *id)
1623{
1624 struct device *dev = &adev->dev;
1625 struct pl022_ssp_controller *platform_info = adev->dev.platform_data;
1626 struct spi_master *master;
1627 struct pl022 *pl022 = NULL; /*Data for this driver */
1628 int status = 0;
1629
1630 dev_info(&adev->dev,
1631 "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid);
1632 if (platform_info == NULL) {
1633 dev_err(&adev->dev, "probe - no platform data supplied\n");
1634 status = -ENODEV;
1635 goto err_no_pdata;
1636 }
1637
1638 /* Allocate master with space for data */
1639 master = spi_alloc_master(dev, sizeof(struct pl022));
1640 if (master == NULL) {
1641 dev_err(&adev->dev, "probe - cannot alloc SPI master\n");
1642 status = -ENOMEM;
1643 goto err_no_master;
1644 }
1645
1646 pl022 = spi_master_get_devdata(master);
1647 pl022->master = master;
1648 pl022->master_info = platform_info;
1649 pl022->adev = adev;
1650 pl022->vendor = id->data;
1651
1652 /*
1653 * Bus Number Which has been Assigned to this SSP controller
1654 * on this board
1655 */
1656 master->bus_num = platform_info->bus_id;
1657 master->num_chipselect = platform_info->num_chipselect;
1658 master->cleanup = pl022_cleanup;
1659 master->setup = pl022_setup;
1660 master->transfer = pl022_transfer;
1661
1662 dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num);
1663
1664 status = amba_request_regions(adev, NULL);
1665 if (status)
1666 goto err_no_ioregion;
1667
1668 pl022->virtbase = ioremap(adev->res.start, resource_size(&adev->res));
1669 if (pl022->virtbase == NULL) {
1670 status = -ENOMEM;
1671 goto err_no_ioremap;
1672 }
1673 printk(KERN_INFO "pl022: mapped registers from 0x%08x to %p\n",
1674 adev->res.start, pl022->virtbase);
1675
1676 pl022->clk = clk_get(&adev->dev, NULL);
1677 if (IS_ERR(pl022->clk)) {
1678 status = PTR_ERR(pl022->clk);
1679 dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
1680 goto err_no_clk;
1681 }
1682
1683 /* Disable SSP */
1684 clk_enable(pl022->clk);
1685 writew((readw(SSP_CR1(pl022->virtbase)) & (~SSP_CR1_MASK_SSE)),
1686 SSP_CR1(pl022->virtbase));
1687 load_ssp_default_config(pl022);
1688 clk_disable(pl022->clk);
1689
1690 status = request_irq(adev->irq[0], pl022_interrupt_handler, 0, "pl022",
1691 pl022);
1692 if (status < 0) {
1693 dev_err(&adev->dev, "probe - cannot get IRQ (%d)\n", status);
1694 goto err_no_irq;
1695 }
1696 /* Initialize and start queue */
1697 status = init_queue(pl022);
1698 if (status != 0) {
1699 dev_err(&adev->dev, "probe - problem initializing queue\n");
1700 goto err_init_queue;
1701 }
1702 status = start_queue(pl022);
1703 if (status != 0) {
1704 dev_err(&adev->dev, "probe - problem starting queue\n");
1705 goto err_start_queue;
1706 }
1707 /* Register with the SPI framework */
1708 amba_set_drvdata(adev, pl022);
1709 status = spi_register_master(master);
1710 if (status != 0) {
1711 dev_err(&adev->dev,
1712 "probe - problem registering spi master\n");
1713 goto err_spi_register;
1714 }
1715 dev_dbg(dev, "probe succeded\n");
1716 return 0;
1717
1718 err_spi_register:
1719 err_start_queue:
1720 err_init_queue:
1721 destroy_queue(pl022);
1722 free_irq(adev->irq[0], pl022);
1723 err_no_irq:
1724 clk_put(pl022->clk);
1725 err_no_clk:
1726 iounmap(pl022->virtbase);
1727 err_no_ioremap:
1728 amba_release_regions(adev);
1729 err_no_ioregion:
1730 spi_master_put(master);
1731 err_no_master:
1732 err_no_pdata:
1733 return status;
1734}
1735
1736static int __exit
1737pl022_remove(struct amba_device *adev)
1738{
1739 struct pl022 *pl022 = amba_get_drvdata(adev);
1740 int status = 0;
1741 if (!pl022)
1742 return 0;
1743
1744 /* Remove the queue */
1745 status = destroy_queue(pl022);
1746 if (status != 0) {
1747 dev_err(&adev->dev,
1748 "queue remove failed (%d)\n", status);
1749 return status;
1750 }
1751 load_ssp_default_config(pl022);
1752 free_irq(adev->irq[0], pl022);
1753 clk_disable(pl022->clk);
1754 clk_put(pl022->clk);
1755 iounmap(pl022->virtbase);
1756 amba_release_regions(adev);
1757 tasklet_disable(&pl022->pump_transfers);
1758 spi_unregister_master(pl022->master);
1759 spi_master_put(pl022->master);
1760 amba_set_drvdata(adev, NULL);
1761 dev_dbg(&adev->dev, "remove succeded\n");
1762 return 0;
1763}
1764
1765#ifdef CONFIG_PM
1766static int pl022_suspend(struct amba_device *adev, pm_message_t state)
1767{
1768 struct pl022 *pl022 = amba_get_drvdata(adev);
1769 int status = 0;
1770
1771 status = stop_queue(pl022);
1772 if (status) {
1773 dev_warn(&adev->dev, "suspend cannot stop queue\n");
1774 return status;
1775 }
1776
1777 clk_enable(pl022->clk);
1778 load_ssp_default_config(pl022);
1779 clk_disable(pl022->clk);
1780 dev_dbg(&adev->dev, "suspended\n");
1781 return 0;
1782}
1783
1784static int pl022_resume(struct amba_device *adev)
1785{
1786 struct pl022 *pl022 = amba_get_drvdata(adev);
1787 int status = 0;
1788
1789 /* Start the queue running */
1790 status = start_queue(pl022);
1791 if (status)
1792 dev_err(&adev->dev, "problem starting queue (%d)\n", status);
1793 else
1794 dev_dbg(&adev->dev, "resumed\n");
1795
1796 return status;
1797}
1798#else
1799#define pl022_suspend NULL
1800#define pl022_resume NULL
1801#endif /* CONFIG_PM */
1802
1803static struct vendor_data vendor_arm = {
1804 .fifodepth = 8,
1805 .max_bpw = 16,
1806 .unidir = false,
1807};
1808
1809
1810static struct vendor_data vendor_st = {
1811 .fifodepth = 32,
1812 .max_bpw = 32,
1813 .unidir = false,
1814};
1815
1816static struct amba_id pl022_ids[] = {
1817 {
1818 /*
1819 * ARM PL022 variant, this has a 16bit wide
1820 * and 8 locations deep TX/RX FIFO
1821 */
1822 .id = 0x00041022,
1823 .mask = 0x000fffff,
1824 .data = &vendor_arm,
1825 },
1826 {
1827 /*
1828 * ST Micro derivative, this has 32bit wide
1829 * and 32 locations deep TX/RX FIFO
1830 */
1831 .id = 0x00108022,
1832 .mask = 0xffffffff,
1833 .data = &vendor_st,
1834 },
1835 { 0, 0 },
1836};
1837
1838static struct amba_driver pl022_driver = {
1839 .drv = {
1840 .name = "ssp-pl022",
1841 },
1842 .id_table = pl022_ids,
1843 .probe = pl022_probe,
1844 .remove = __exit_p(pl022_remove),
1845 .suspend = pl022_suspend,
1846 .resume = pl022_resume,
1847};
1848
1849
1850static int __init pl022_init(void)
1851{
1852 return amba_driver_register(&pl022_driver);
1853}
1854
1855module_init(pl022_init);
1856
1857static void __exit pl022_exit(void)
1858{
1859 amba_driver_unregister(&pl022_driver);
1860}
1861
1862module_exit(pl022_exit);
1863
1864MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
1865MODULE_DESCRIPTION("PL022 SSP Controller Driver");
1866MODULE_LICENSE("GPL");
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c
index f2447a5476bb..bbf9371cd284 100644
--- a/drivers/spi/spi_s3c24xx_gpio.c
+++ b/drivers/spi/spi_s3c24xx_gpio.c
@@ -17,6 +17,7 @@
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/workqueue.h> 18#include <linux/workqueue.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/gpio.h>
20 21
21#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
22#include <linux/spi/spi_bitbang.h> 23#include <linux/spi/spi_bitbang.h>
diff --git a/drivers/staging/go7007/go7007.txt b/drivers/staging/go7007/go7007.txt
index 9f6772bc68c2..1c2907c1dc81 100644
--- a/drivers/staging/go7007/go7007.txt
+++ b/drivers/staging/go7007/go7007.txt
@@ -2,7 +2,7 @@ This is a driver for the WIS GO7007SB multi-format video encoder.
2 2
3Pete Eberlein <pete@sensoray.com> 3Pete Eberlein <pete@sensoray.com>
4 4
5The driver was orignally released under the GPL and is currently hosted at: 5The driver was originally released under the GPL and is currently hosted at:
6http://nikosapi.org/wiki/index.php/WIS_Go7007_Linux_driver 6http://nikosapi.org/wiki/index.php/WIS_Go7007_Linux_driver
7The go7007 firmware can be acquired from the package on the site above. 7The go7007 firmware can be acquired from the package on the site above.
8 8
@@ -24,7 +24,7 @@ These should be used instead of the non-standard GO7007 ioctls described
24below. 24below.
25 25
26 26
27The README files from the orignal package appear below: 27The README files from the original package appears below:
28 28
29--------------------------------------------------------------------------- 29---------------------------------------------------------------------------
30 WIS GO7007SB Public Linux Driver 30 WIS GO7007SB Public Linux Driver
diff --git a/drivers/staging/panel/lcd-panel-cgram.txt b/drivers/staging/panel/lcd-panel-cgram.txt
index f9ceef4322a3..7f82c905763d 100644
--- a/drivers/staging/panel/lcd-panel-cgram.txt
+++ b/drivers/staging/panel/lcd-panel-cgram.txt
@@ -3,7 +3,7 @@ characters 0 to 7. The escape code to define a new character is
3'\e[LG' followed by one digit from 0 to 7, representing the character 3'\e[LG' followed by one digit from 0 to 7, representing the character
4number, and up to 8 couples of hex digits terminated by a semi-colon 4number, and up to 8 couples of hex digits terminated by a semi-colon
5(';'). Each couple of digits represents a line, with 1-bits for each 5(';'). Each couple of digits represents a line, with 1-bits for each
6illuminated pixel with LSB on the right. Lines are numberred from the 6illuminated pixel with LSB on the right. Lines are numbered from the
7top of the character to the bottom. On a 5x7 matrix, only the 5 lower 7top of the character to the bottom. On a 5x7 matrix, only the 5 lower
8bits of the 7 first bytes are used for each character. If the string 8bits of the 7 first bytes are used for each character. If the string
9is incomplete, only complete lines will be redefined. Here are some 9is incomplete, only complete lines will be redefined. Here are some
diff --git a/drivers/staging/rt2860/common/mlme.c b/drivers/staging/rt2860/common/mlme.c
index c00f9ab9c46c..2edf2999f5c8 100644
--- a/drivers/staging/rt2860/common/mlme.c
+++ b/drivers/staging/rt2860/common/mlme.c
@@ -5664,7 +5664,7 @@ VOID AsicUpdateProtect(
5664#if 0 5664#if 0
5665 MacReg |= (pAd->CommonCfg.RtsThreshold << 8); 5665 MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
5666#else 5666#else
5667 // If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096 5667 // If the user want disable RtsThreshold and enable Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
5668 if (( 5668 if ((
5669#ifdef DOT11_N_SUPPORT 5669#ifdef DOT11_N_SUPPORT
5670 (pAd->CommonCfg.BACapability.field.AmsduEnable) || 5670 (pAd->CommonCfg.BACapability.field.AmsduEnable) ||
diff --git a/drivers/staging/rt2870/common/mlme.c b/drivers/staging/rt2870/common/mlme.c
index 8a82cee8bf26..a26bc033337d 100644
--- a/drivers/staging/rt2870/common/mlme.c
+++ b/drivers/staging/rt2870/common/mlme.c
@@ -5561,7 +5561,7 @@ VOID AsicUpdateProtect(
5561#if 0 5561#if 0
5562 MacReg |= (pAd->CommonCfg.RtsThreshold << 8); 5562 MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
5563#else 5563#else
5564 // If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096 5564 // If the user want disable RtsThreshold and enable Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
5565 if (( 5565 if ((
5566#ifdef DOT11_N_SUPPORT 5566#ifdef DOT11_N_SUPPORT
5567 (pAd->CommonCfg.BACapability.field.AmsduEnable) || 5567 (pAd->CommonCfg.BACapability.field.AmsduEnable) ||
diff --git a/drivers/staging/rt3070/common/mlme.c b/drivers/staging/rt3070/common/mlme.c
index 0ffbfa36699e..0189bab013cf 100644
--- a/drivers/staging/rt3070/common/mlme.c
+++ b/drivers/staging/rt3070/common/mlme.c
@@ -5575,7 +5575,7 @@ VOID AsicUpdateProtect(
5575 RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg); 5575 RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
5576 MacReg &= 0xFF0000FF; 5576 MacReg &= 0xFF0000FF;
5577 5577
5578 // If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096 5578 // If the user want disable RtsThreshold and enable Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
5579 if (( 5579 if ((
5580#ifdef DOT11_N_SUPPORT 5580#ifdef DOT11_N_SUPPORT
5581 (pAd->CommonCfg.BACapability.field.AmsduEnable) || 5581 (pAd->CommonCfg.BACapability.field.AmsduEnable) ||
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 888198c9a106..824e65bdc433 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -2424,7 +2424,7 @@ int hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len)
2424* 0 success 2424* 0 success
2425* >0 f/w reported error - f/w status code 2425* >0 f/w reported error - f/w status code
2426* <0 driver reported error 2426* <0 driver reported error
2427* -ETIMEOUT timout waiting for the cmd regs to become 2427* -ETIMEDOUT timout waiting for the cmd regs to become
2428* available, or waiting for the control reg 2428* available, or waiting for the control reg
2429* to indicate the Aux port is enabled. 2429* to indicate the Aux port is enabled.
2430* -ENODATA the buffer does NOT contain a valid PDA. 2430* -ENODATA the buffer does NOT contain a valid PDA.
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 7cf74f8c2db1..b0dbf4157d29 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -47,7 +47,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
47 struct usb_hcd *hcd; 47 struct usb_hcd *hcd;
48 48
49 if (pdev->resource[1].flags != IORESOURCE_IRQ) { 49 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
50 pr_debug("resource[1] is not IORESOURCE_IRQ"); 50 dbg("resource[1] is not IORESOURCE_IRQ");
51 return -ENOMEM; 51 return -ENOMEM;
52 } 52 }
53 53
@@ -65,12 +65,18 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
65 65
66 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 66 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
67 if (hcd->regs == NULL) { 67 if (hcd->regs == NULL) {
68 pr_debug("ioremap failed"); 68 dbg("ioremap failed");
69 retval = -ENOMEM; 69 retval = -ENOMEM;
70 goto err2; 70 goto err2;
71 } 71 }
72 72
73 usb_host_clock = clk_get(&pdev->dev, "usb_host"); 73 usb_host_clock = clk_get(&pdev->dev, NULL);
74 if (IS_ERR(usb_host_clock)) {
75 dbg("clk_get failed");
76 retval = PTR_ERR(usb_host_clock);
77 goto err3;
78 }
79
74 ep93xx_start_hc(&pdev->dev); 80 ep93xx_start_hc(&pdev->dev);
75 81
76 ohci_hcd_init(hcd_to_ohci(hcd)); 82 ohci_hcd_init(hcd_to_ohci(hcd));
@@ -80,6 +86,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
80 return retval; 86 return retval;
81 87
82 ep93xx_stop_hc(&pdev->dev); 88 ep93xx_stop_hc(&pdev->dev);
89err3:
83 iounmap(hcd->regs); 90 iounmap(hcd->regs);
84err2: 91err2:
85 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 92 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index eabf20eeb370..db964db42d3c 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -102,7 +102,7 @@ struct edgeport_port {
102 __u8 shadow_mcr; 102 __u8 shadow_mcr;
103 __u8 shadow_lsr; 103 __u8 shadow_lsr;
104 __u8 lsr_mask; 104 __u8 lsr_mask;
105 __u32 ump_read_timeout; /* Number of miliseconds the UMP will 105 __u32 ump_read_timeout; /* Number of milliseconds the UMP will
106 wait without data before completing 106 wait without data before completing
107 a read short */ 107 a read short */
108 int baud_rate; 108 int baud_rate;
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 74712cb8399a..2b5a691064b7 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -397,7 +397,7 @@ config FB_SA1100
397 397
398config FB_IMX 398config FB_IMX
399 tristate "Motorola i.MX LCD support" 399 tristate "Motorola i.MX LCD support"
400 depends on FB && (ARCH_IMX || ARCH_MX2) 400 depends on FB && (ARCH_MX1 || ARCH_MX2)
401 select FB_CFB_FILLRECT 401 select FB_CFB_FILLRECT
402 select FB_CFB_COPYAREA 402 select FB_CFB_COPYAREA
403 select FB_CFB_IMAGEBLIT 403 select FB_CFB_IMAGEBLIT
@@ -1759,6 +1759,16 @@ config FB_68328
1759 Say Y here if you want to support the built-in frame buffer of 1759 Say Y here if you want to support the built-in frame buffer of
1760 the Motorola 68328 CPU family. 1760 the Motorola 68328 CPU family.
1761 1761
1762config FB_PXA168
1763 tristate "PXA168/910 LCD framebuffer support"
1764 depends on FB && (CPU_PXA168 || CPU_PXA910)
1765 select FB_CFB_FILLRECT
1766 select FB_CFB_COPYAREA
1767 select FB_CFB_IMAGEBLIT
1768 ---help---
1769 Frame buffer driver for the built-in LCD controller in the Marvell
1770 MMP processor.
1771
1762config FB_PXA 1772config FB_PXA
1763 tristate "PXA LCD framebuffer support" 1773 tristate "PXA LCD framebuffer support"
1764 depends on FB && ARCH_PXA 1774 depends on FB && ARCH_PXA
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index d8d0be5151e3..01a819f47371 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_FB_GBE) += gbefb.o
97obj-$(CONFIG_FB_CIRRUS) += cirrusfb.o 97obj-$(CONFIG_FB_CIRRUS) += cirrusfb.o
98obj-$(CONFIG_FB_ASILIANT) += asiliantfb.o 98obj-$(CONFIG_FB_ASILIANT) += asiliantfb.o
99obj-$(CONFIG_FB_PXA) += pxafb.o 99obj-$(CONFIG_FB_PXA) += pxafb.o
100obj-$(CONFIG_FB_PXA168) += pxa168fb.o
100obj-$(CONFIG_FB_W100) += w100fb.o 101obj-$(CONFIG_FB_W100) += w100fb.o
101obj-$(CONFIG_FB_TMIO) += tmiofb.o 102obj-$(CONFIG_FB_TMIO) += tmiofb.o
102obj-$(CONFIG_FB_AU1100) += au1100fb.o 103obj-$(CONFIG_FB_AU1100) += au1100fb.o
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index d1f80bac54f0..fb8163d181ab 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -351,7 +351,7 @@ static int clcdfb_register(struct clcd_fb *fb)
351 } 351 }
352 352
353 fb->fb.fix.mmio_start = fb->dev->res.start; 353 fb->fb.fix.mmio_start = fb->dev->res.start;
354 fb->fb.fix.mmio_len = 4096; 354 fb->fb.fix.mmio_len = resource_size(&fb->dev->res);
355 355
356 fb->regs = ioremap(fb->fb.fix.mmio_start, fb->fb.fix.mmio_len); 356 fb->regs = ioremap(fb->fb.fix.mmio_start, fb->fb.fix.mmio_len);
357 if (!fb->regs) { 357 if (!fb->regs) {
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index 9894de1c9b9f..b7af5256e887 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -706,7 +706,7 @@ static void mx3fb_dma_done(void *arg)
706 dev_dbg(mx3fb->dev, "irq %d callback\n", ichannel->eof_irq); 706 dev_dbg(mx3fb->dev, "irq %d callback\n", ichannel->eof_irq);
707 707
708 /* We only need one interrupt, it will be re-enabled as needed */ 708 /* We only need one interrupt, it will be re-enabled as needed */
709 disable_irq(ichannel->eof_irq); 709 disable_irq_nosync(ichannel->eof_irq);
710 710
711 complete(&mx3_fbi->flip_cmpl); 711 complete(&mx3_fbi->flip_cmpl);
712} 712}
@@ -1366,7 +1366,7 @@ static int init_fb_chan(struct mx3fb_data *mx3fb, struct idmac_channel *ichan)
1366 1366
1367 mx3fb_blank(FB_BLANK_UNBLANK, fbi); 1367 mx3fb_blank(FB_BLANK_UNBLANK, fbi);
1368 1368
1369 dev_info(dev, "mx3fb: fb registered, using mode %s\n", fb_mode); 1369 dev_info(dev, "registered, using mode %s\n", fb_mode);
1370 1370
1371 ret = register_framebuffer(fbi); 1371 ret = register_framebuffer(fbi);
1372 if (ret < 0) 1372 if (ret < 0)
diff --git a/drivers/video/omap/hwa742.c b/drivers/video/omap/hwa742.c
index 8aa6e47202b9..5d4f34887a22 100644
--- a/drivers/video/omap/hwa742.c
+++ b/drivers/video/omap/hwa742.c
@@ -133,8 +133,7 @@ struct {
133 struct lcd_ctrl_extif *extif; 133 struct lcd_ctrl_extif *extif;
134 struct lcd_ctrl *int_ctrl; 134 struct lcd_ctrl *int_ctrl;
135 135
136 void (*power_up)(struct device *dev); 136 struct clk *sys_ck;
137 void (*power_down)(struct device *dev);
138} hwa742; 137} hwa742;
139 138
140struct lcd_ctrl hwa742_ctrl; 139struct lcd_ctrl hwa742_ctrl;
@@ -915,14 +914,13 @@ static void hwa742_suspend(void)
915 hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED); 914 hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED);
916 /* Enable sleep mode */ 915 /* Enable sleep mode */
917 hwa742_write_reg(HWA742_POWER_SAVE, 1 << 1); 916 hwa742_write_reg(HWA742_POWER_SAVE, 1 << 1);
918 if (hwa742.power_down != NULL) 917 clk_disable(hwa742.sys_ck);
919 hwa742.power_down(hwa742.fbdev->dev);
920} 918}
921 919
922static void hwa742_resume(void) 920static void hwa742_resume(void)
923{ 921{
924 if (hwa742.power_up != NULL) 922 clk_enable(hwa742.sys_ck);
925 hwa742.power_up(hwa742.fbdev->dev); 923
926 /* Disable sleep mode */ 924 /* Disable sleep mode */
927 hwa742_write_reg(HWA742_POWER_SAVE, 0); 925 hwa742_write_reg(HWA742_POWER_SAVE, 0);
928 while (1) { 926 while (1) {
@@ -955,14 +953,13 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
955 omapfb_conf = fbdev->dev->platform_data; 953 omapfb_conf = fbdev->dev->platform_data;
956 ctrl_conf = omapfb_conf->ctrl_platform_data; 954 ctrl_conf = omapfb_conf->ctrl_platform_data;
957 955
958 if (ctrl_conf == NULL || ctrl_conf->get_clock_rate == NULL) { 956 if (ctrl_conf == NULL) {
959 dev_err(fbdev->dev, "HWA742: missing platform data\n"); 957 dev_err(fbdev->dev, "HWA742: missing platform data\n");
960 r = -ENOENT; 958 r = -ENOENT;
961 goto err1; 959 goto err1;
962 } 960 }
963 961
964 hwa742.power_down = ctrl_conf->power_down; 962 hwa742.sys_ck = clk_get(NULL, "hwa_sys_ck");
965 hwa742.power_up = ctrl_conf->power_up;
966 963
967 spin_lock_init(&hwa742.req_lock); 964 spin_lock_init(&hwa742.req_lock);
968 965
@@ -972,12 +969,11 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
972 if ((r = hwa742.extif->init(fbdev)) < 0) 969 if ((r = hwa742.extif->init(fbdev)) < 0)
973 goto err2; 970 goto err2;
974 971
975 ext_clk = ctrl_conf->get_clock_rate(fbdev->dev); 972 ext_clk = clk_get_rate(hwa742.sys_ck);
976 if ((r = calc_extif_timings(ext_clk, &extif_mem_div)) < 0) 973 if ((r = calc_extif_timings(ext_clk, &extif_mem_div)) < 0)
977 goto err3; 974 goto err3;
978 hwa742.extif->set_timings(&hwa742.reg_timings); 975 hwa742.extif->set_timings(&hwa742.reg_timings);
979 if (hwa742.power_up != NULL) 976 clk_enable(hwa742.sys_ck);
980 hwa742.power_up(fbdev->dev);
981 977
982 calc_hwa742_clk_rates(ext_clk, &sys_clk, &pix_clk); 978 calc_hwa742_clk_rates(ext_clk, &sys_clk, &pix_clk);
983 if ((r = calc_extif_timings(sys_clk, &extif_mem_div)) < 0) 979 if ((r = calc_extif_timings(sys_clk, &extif_mem_div)) < 0)
@@ -1040,8 +1036,7 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
1040 1036
1041 return 0; 1037 return 0;
1042err4: 1038err4:
1043 if (hwa742.power_down != NULL) 1039 clk_disable(hwa742.sys_ck);
1044 hwa742.power_down(fbdev->dev);
1045err3: 1040err3:
1046 hwa742.extif->cleanup(); 1041 hwa742.extif->cleanup();
1047err2: 1042err2:
@@ -1055,8 +1050,7 @@ static void hwa742_cleanup(void)
1055 hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED); 1050 hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED);
1056 hwa742.extif->cleanup(); 1051 hwa742.extif->cleanup();
1057 hwa742.int_ctrl->cleanup(); 1052 hwa742.int_ctrl->cleanup();
1058 if (hwa742.power_down != NULL) 1053 clk_disable(hwa742.sys_ck);
1059 hwa742.power_down(hwa742.fbdev->dev);
1060} 1054}
1061 1055
1062struct lcd_ctrl hwa742_ctrl = { 1056struct lcd_ctrl hwa742_ctrl = {
diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
new file mode 100644
index 000000000000..84d8327e47db
--- /dev/null
+++ b/drivers/video/pxa168fb.c
@@ -0,0 +1,803 @@
1/*
2 * linux/drivers/video/pxa168fb.c -- Marvell PXA168 LCD Controller
3 *
4 * Copyright (C) 2008 Marvell International Ltd.
5 * All rights reserved.
6 *
7 * 2009-02-16 adapted from original version for PXA168/910
8 * Jun Nie <njun@marvell.com>
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive for
12 * more details.
13 */
14
15#include <linux/module.h>
16#include <linux/kernel.h>
17#include <linux/sched.h>
18#include <linux/string.h>
19#include <linux/interrupt.h>
20#include <linux/slab.h>
21#include <linux/fb.h>
22#include <linux/delay.h>
23#include <linux/init.h>
24#include <linux/ioport.h>
25#include <linux/platform_device.h>
26#include <linux/dma-mapping.h>
27#include <linux/clk.h>
28#include <linux/err.h>
29#include <linux/uaccess.h>
30#include <video/pxa168fb.h>
31
32#include "pxa168fb.h"
33
34#define DEFAULT_REFRESH 60 /* Hz */
35
36static int determine_best_pix_fmt(struct fb_var_screeninfo *var)
37{
38 /*
39 * Pseudocolor mode?
40 */
41 if (var->bits_per_pixel == 8)
42 return PIX_FMT_PSEUDOCOLOR;
43
44 /*
45 * Check for 565/1555.
46 */
47 if (var->bits_per_pixel == 16 && var->red.length <= 5 &&
48 var->green.length <= 6 && var->blue.length <= 5) {
49 if (var->transp.length == 0) {
50 if (var->red.offset >= var->blue.offset)
51 return PIX_FMT_RGB565;
52 else
53 return PIX_FMT_BGR565;
54 }
55
56 if (var->transp.length == 1 && var->green.length <= 5) {
57 if (var->red.offset >= var->blue.offset)
58 return PIX_FMT_RGB1555;
59 else
60 return PIX_FMT_BGR1555;
61 }
62
63 /* fall through */
64 }
65
66 /*
67 * Check for 888/A888.
68 */
69 if (var->bits_per_pixel <= 32 && var->red.length <= 8 &&
70 var->green.length <= 8 && var->blue.length <= 8) {
71 if (var->bits_per_pixel == 24 && var->transp.length == 0) {
72 if (var->red.offset >= var->blue.offset)
73 return PIX_FMT_RGB888PACK;
74 else
75 return PIX_FMT_BGR888PACK;
76 }
77
78 if (var->bits_per_pixel == 32 && var->transp.length == 8) {
79 if (var->red.offset >= var->blue.offset)
80 return PIX_FMT_RGBA888;
81 else
82 return PIX_FMT_BGRA888;
83 } else {
84 if (var->red.offset >= var->blue.offset)
85 return PIX_FMT_RGB888UNPACK;
86 else
87 return PIX_FMT_BGR888UNPACK;
88 }
89
90 /* fall through */
91 }
92
93 return -EINVAL;
94}
95
96static void set_pix_fmt(struct fb_var_screeninfo *var, int pix_fmt)
97{
98 switch (pix_fmt) {
99 case PIX_FMT_RGB565:
100 var->bits_per_pixel = 16;
101 var->red.offset = 11; var->red.length = 5;
102 var->green.offset = 5; var->green.length = 6;
103 var->blue.offset = 0; var->blue.length = 5;
104 var->transp.offset = 0; var->transp.length = 0;
105 break;
106 case PIX_FMT_BGR565:
107 var->bits_per_pixel = 16;
108 var->red.offset = 0; var->red.length = 5;
109 var->green.offset = 5; var->green.length = 6;
110 var->blue.offset = 11; var->blue.length = 5;
111 var->transp.offset = 0; var->transp.length = 0;
112 break;
113 case PIX_FMT_RGB1555:
114 var->bits_per_pixel = 16;
115 var->red.offset = 10; var->red.length = 5;
116 var->green.offset = 5; var->green.length = 5;
117 var->blue.offset = 0; var->blue.length = 5;
118 var->transp.offset = 15; var->transp.length = 1;
119 break;
120 case PIX_FMT_BGR1555:
121 var->bits_per_pixel = 16;
122 var->red.offset = 0; var->red.length = 5;
123 var->green.offset = 5; var->green.length = 5;
124 var->blue.offset = 10; var->blue.length = 5;
125 var->transp.offset = 15; var->transp.length = 1;
126 break;
127 case PIX_FMT_RGB888PACK:
128 var->bits_per_pixel = 24;
129 var->red.offset = 16; var->red.length = 8;
130 var->green.offset = 8; var->green.length = 8;
131 var->blue.offset = 0; var->blue.length = 8;
132 var->transp.offset = 0; var->transp.length = 0;
133 break;
134 case PIX_FMT_BGR888PACK:
135 var->bits_per_pixel = 24;
136 var->red.offset = 0; var->red.length = 8;
137 var->green.offset = 8; var->green.length = 8;
138 var->blue.offset = 16; var->blue.length = 8;
139 var->transp.offset = 0; var->transp.length = 0;
140 break;
141 case PIX_FMT_RGBA888:
142 var->bits_per_pixel = 32;
143 var->red.offset = 16; var->red.length = 8;
144 var->green.offset = 8; var->green.length = 8;
145 var->blue.offset = 0; var->blue.length = 8;
146 var->transp.offset = 24; var->transp.length = 8;
147 break;
148 case PIX_FMT_BGRA888:
149 var->bits_per_pixel = 32;
150 var->red.offset = 0; var->red.length = 8;
151 var->green.offset = 8; var->green.length = 8;
152 var->blue.offset = 16; var->blue.length = 8;
153 var->transp.offset = 24; var->transp.length = 8;
154 break;
155 case PIX_FMT_PSEUDOCOLOR:
156 var->bits_per_pixel = 8;
157 var->red.offset = 0; var->red.length = 8;
158 var->green.offset = 0; var->green.length = 8;
159 var->blue.offset = 0; var->blue.length = 8;
160 var->transp.offset = 0; var->transp.length = 0;
161 break;
162 }
163}
164
165static void set_mode(struct pxa168fb_info *fbi, struct fb_var_screeninfo *var,
166 struct fb_videomode *mode, int pix_fmt, int ystretch)
167{
168 struct fb_info *info = fbi->info;
169
170 set_pix_fmt(var, pix_fmt);
171
172 var->xres = mode->xres;
173 var->yres = mode->yres;
174 var->xres_virtual = max(var->xres, var->xres_virtual);
175 if (ystretch)
176 var->yres_virtual = info->fix.smem_len /
177 (var->xres_virtual * (var->bits_per_pixel >> 3));
178 else
179 var->yres_virtual = max(var->yres, var->yres_virtual);
180 var->grayscale = 0;
181 var->accel_flags = FB_ACCEL_NONE;
182 var->pixclock = mode->pixclock;
183 var->left_margin = mode->left_margin;
184 var->right_margin = mode->right_margin;
185 var->upper_margin = mode->upper_margin;
186 var->lower_margin = mode->lower_margin;
187 var->hsync_len = mode->hsync_len;
188 var->vsync_len = mode->vsync_len;
189 var->sync = mode->sync;
190 var->vmode = FB_VMODE_NONINTERLACED;
191 var->rotate = FB_ROTATE_UR;
192}
193
194static int pxa168fb_check_var(struct fb_var_screeninfo *var,
195 struct fb_info *info)
196{
197 struct pxa168fb_info *fbi = info->par;
198 int pix_fmt;
199
200 /*
201 * Determine which pixel format we're going to use.
202 */
203 pix_fmt = determine_best_pix_fmt(var);
204 if (pix_fmt < 0)
205 return pix_fmt;
206 set_pix_fmt(var, pix_fmt);
207 fbi->pix_fmt = pix_fmt;
208
209 /*
210 * Basic geometry sanity checks.
211 */
212 if (var->xoffset + var->xres > var->xres_virtual)
213 return -EINVAL;
214 if (var->yoffset + var->yres > var->yres_virtual)
215 return -EINVAL;
216 if (var->xres + var->right_margin +
217 var->hsync_len + var->left_margin > 2048)
218 return -EINVAL;
219 if (var->yres + var->lower_margin +
220 var->vsync_len + var->upper_margin > 2048)
221 return -EINVAL;
222
223 /*
224 * Check size of framebuffer.
225 */
226 if (var->xres_virtual * var->yres_virtual *
227 (var->bits_per_pixel >> 3) > info->fix.smem_len)
228 return -EINVAL;
229
230 return 0;
231}
232
233/*
234 * The hardware clock divider has an integer and a fractional
235 * stage:
236 *
237 * clk2 = clk_in / integer_divider
238 * clk_out = clk2 * (1 - (fractional_divider >> 12))
239 *
240 * Calculate integer and fractional divider for given clk_in
241 * and clk_out.
242 */
243static void set_clock_divider(struct pxa168fb_info *fbi,
244 const struct fb_videomode *m)
245{
246 int divider_int;
247 int needed_pixclk;
248 u64 div_result;
249 u32 x = 0;
250
251 /*
252 * Notice: The field pixclock is used by linux fb
253 * is in pixel second. E.g. struct fb_videomode &
254 * struct fb_var_screeninfo
255 */
256
257 /*
258 * Check input values.
259 */
260 if (!m || !m->pixclock || !m->refresh) {
261 dev_err(fbi->dev, "Input refresh or pixclock is wrong.\n");
262 return;
263 }
264
265 /*
266 * Using PLL/AXI clock.
267 */
268 x = 0x80000000;
269
270 /*
271 * Calc divider according to refresh rate.
272 */
273 div_result = 1000000000000ll;
274 do_div(div_result, m->pixclock);
275 needed_pixclk = (u32)div_result;
276
277 divider_int = clk_get_rate(fbi->clk) / needed_pixclk;
278
279 /* check whether divisor is too small. */
280 if (divider_int < 2) {
281 dev_warn(fbi->dev, "Warning: clock source is too slow."
282 "Try smaller resolution\n");
283 divider_int = 2;
284 }
285
286 /*
287 * Set setting to reg.
288 */
289 x |= divider_int;
290 writel(x, fbi->reg_base + LCD_CFG_SCLK_DIV);
291}
292
293static void set_dma_control0(struct pxa168fb_info *fbi)
294{
295 u32 x;
296
297 /*
298 * Set bit to enable graphics DMA.
299 */
300 x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
301 x |= fbi->active ? 0x00000100 : 0;
302 fbi->active = 0;
303
304 /*
305 * If we are in a pseudo-color mode, we need to enable
306 * palette lookup.
307 */
308 if (fbi->pix_fmt == PIX_FMT_PSEUDOCOLOR)
309 x |= 0x10000000;
310
311 /*
312 * Configure hardware pixel format.
313 */
314 x &= ~(0xF << 16);
315 x |= (fbi->pix_fmt >> 1) << 16;
316
317 /*
318 * Check red and blue pixel swap.
319 * 1. source data swap
320 * 2. panel output data swap
321 */
322 x &= ~(1 << 12);
323 x |= ((fbi->pix_fmt & 1) ^ (fbi->panel_rbswap)) << 12;
324
325 writel(x, fbi->reg_base + LCD_SPU_DMA_CTRL0);
326}
327
328static void set_dma_control1(struct pxa168fb_info *fbi, int sync)
329{
330 u32 x;
331
332 /*
333 * Configure default bits: vsync triggers DMA, gated clock
334 * enable, power save enable, configure alpha registers to
335 * display 100% graphics, and set pixel command.
336 */
337 x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL1);
338 x |= 0x2032ff81;
339
340 /*
341 * We trigger DMA on the falling edge of vsync if vsync is
342 * active low, or on the rising edge if vsync is active high.
343 */
344 if (!(sync & FB_SYNC_VERT_HIGH_ACT))
345 x |= 0x08000000;
346
347 writel(x, fbi->reg_base + LCD_SPU_DMA_CTRL1);
348}
349
350static void set_graphics_start(struct fb_info *info, int xoffset, int yoffset)
351{
352 struct pxa168fb_info *fbi = info->par;
353 struct fb_var_screeninfo *var = &info->var;
354 int pixel_offset;
355 unsigned long addr;
356
357 pixel_offset = (yoffset * var->xres_virtual) + xoffset;
358
359 addr = fbi->fb_start_dma + (pixel_offset * (var->bits_per_pixel >> 3));
360 writel(addr, fbi->reg_base + LCD_CFG_GRA_START_ADDR0);
361}
362
363static void set_dumb_panel_control(struct fb_info *info)
364{
365 struct pxa168fb_info *fbi = info->par;
366 struct pxa168fb_mach_info *mi = fbi->dev->platform_data;
367 u32 x;
368
369 /*
370 * Preserve enable flag.
371 */
372 x = readl(fbi->reg_base + LCD_SPU_DUMB_CTRL) & 0x00000001;
373
374 x |= (fbi->is_blanked ? 0x7 : mi->dumb_mode) << 28;
375 x |= mi->gpio_output_data << 20;
376 x |= mi->gpio_output_mask << 12;
377 x |= mi->panel_rgb_reverse_lanes ? 0x00000080 : 0;
378 x |= mi->invert_composite_blank ? 0x00000040 : 0;
379 x |= (info->var.sync & FB_SYNC_COMP_HIGH_ACT) ? 0x00000020 : 0;
380 x |= mi->invert_pix_val_ena ? 0x00000010 : 0;
381 x |= (info->var.sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : 0x00000008;
382 x |= (info->var.sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : 0x00000004;
383 x |= mi->invert_pixclock ? 0x00000002 : 0;
384
385 writel(x, fbi->reg_base + LCD_SPU_DUMB_CTRL);
386}
387
388static void set_dumb_screen_dimensions(struct fb_info *info)
389{
390 struct pxa168fb_info *fbi = info->par;
391 struct fb_var_screeninfo *v = &info->var;
392 int x;
393 int y;
394
395 x = v->xres + v->right_margin + v->hsync_len + v->left_margin;
396 y = v->yres + v->lower_margin + v->vsync_len + v->upper_margin;
397
398 writel((y << 16) | x, fbi->reg_base + LCD_SPUT_V_H_TOTAL);
399}
400
401static int pxa168fb_set_par(struct fb_info *info)
402{
403 struct pxa168fb_info *fbi = info->par;
404 struct fb_var_screeninfo *var = &info->var;
405 struct fb_videomode mode;
406 u32 x;
407 struct pxa168fb_mach_info *mi;
408
409 mi = fbi->dev->platform_data;
410
411 /*
412 * Set additional mode info.
413 */
414 if (fbi->pix_fmt == PIX_FMT_PSEUDOCOLOR)
415 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
416 else
417 info->fix.visual = FB_VISUAL_TRUECOLOR;
418 info->fix.line_length = var->xres_virtual * var->bits_per_pixel / 8;
419 info->fix.ypanstep = var->yres;
420
421 /*
422 * Disable panel output while we setup the display.
423 */
424 x = readl(fbi->reg_base + LCD_SPU_DUMB_CTRL);
425 writel(x & ~1, fbi->reg_base + LCD_SPU_DUMB_CTRL);
426
427 /*
428 * Configure global panel parameters.
429 */
430 writel((var->yres << 16) | var->xres,
431 fbi->reg_base + LCD_SPU_V_H_ACTIVE);
432
433 /*
434 * convet var to video mode
435 */
436 fb_var_to_videomode(&mode, &info->var);
437
438 /* Calculate clock divisor. */
439 set_clock_divider(fbi, &mode);
440
441 /* Configure dma ctrl regs. */
442 set_dma_control0(fbi);
443 set_dma_control1(fbi, info->var.sync);
444
445 /*
446 * Configure graphics DMA parameters.
447 */
448 x = readl(fbi->reg_base + LCD_CFG_GRA_PITCH);
449 x = (x & ~0xFFFF) | ((var->xres_virtual * var->bits_per_pixel) >> 3);
450 writel(x, fbi->reg_base + LCD_CFG_GRA_PITCH);
451 writel((var->yres << 16) | var->xres,
452 fbi->reg_base + LCD_SPU_GRA_HPXL_VLN);
453 writel((var->yres << 16) | var->xres,
454 fbi->reg_base + LCD_SPU_GZM_HPXL_VLN);
455
456 /*
457 * Configure dumb panel ctrl regs & timings.
458 */
459 set_dumb_panel_control(info);
460 set_dumb_screen_dimensions(info);
461
462 writel((var->left_margin << 16) | var->right_margin,
463 fbi->reg_base + LCD_SPU_H_PORCH);
464 writel((var->upper_margin << 16) | var->lower_margin,
465 fbi->reg_base + LCD_SPU_V_PORCH);
466
467 /*
468 * Re-enable panel output.
469 */
470 x = readl(fbi->reg_base + LCD_SPU_DUMB_CTRL);
471 writel(x | 1, fbi->reg_base + LCD_SPU_DUMB_CTRL);
472
473 return 0;
474}
475
476static unsigned int chan_to_field(unsigned int chan, struct fb_bitfield *bf)
477{
478 return ((chan & 0xffff) >> (16 - bf->length)) << bf->offset;
479}
480
481static u32 to_rgb(u16 red, u16 green, u16 blue)
482{
483 red >>= 8;
484 green >>= 8;
485 blue >>= 8;
486
487 return (red << 16) | (green << 8) | blue;
488}
489
490static int
491pxa168fb_setcolreg(unsigned int regno, unsigned int red, unsigned int green,
492 unsigned int blue, unsigned int trans, struct fb_info *info)
493{
494 struct pxa168fb_info *fbi = info->par;
495 u32 val;
496
497 if (info->var.grayscale)
498 red = green = blue = (19595 * red + 38470 * green +
499 7471 * blue) >> 16;
500
501 if (info->fix.visual == FB_VISUAL_TRUECOLOR && regno < 16) {
502 val = chan_to_field(red, &info->var.red);
503 val |= chan_to_field(green, &info->var.green);
504 val |= chan_to_field(blue , &info->var.blue);
505 fbi->pseudo_palette[regno] = val;
506 }
507
508 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) {
509 val = to_rgb(red, green, blue);
510 writel(val, fbi->reg_base + LCD_SPU_SRAM_WRDAT);
511 writel(0x8300 | regno, fbi->reg_base + LCD_SPU_SRAM_CTRL);
512 }
513
514 return 0;
515}
516
517static int pxa168fb_blank(int blank, struct fb_info *info)
518{
519 struct pxa168fb_info *fbi = info->par;
520
521 fbi->is_blanked = (blank == FB_BLANK_UNBLANK) ? 0 : 1;
522 set_dumb_panel_control(info);
523
524 return 0;
525}
526
527static int pxa168fb_pan_display(struct fb_var_screeninfo *var,
528 struct fb_info *info)
529{
530 set_graphics_start(info, var->xoffset, var->yoffset);
531
532 return 0;
533}
534
535static irqreturn_t pxa168fb_handle_irq(int irq, void *dev_id)
536{
537 struct pxa168fb_info *fbi = dev_id;
538 u32 isr = readl(fbi->reg_base + SPU_IRQ_ISR);
539
540 if ((isr & GRA_FRAME_IRQ0_ENA_MASK)) {
541
542 writel(isr & (~GRA_FRAME_IRQ0_ENA_MASK),
543 fbi->reg_base + SPU_IRQ_ISR);
544
545 return IRQ_HANDLED;
546 }
547 return IRQ_NONE;
548}
549
550static struct fb_ops pxa168fb_ops = {
551 .owner = THIS_MODULE,
552 .fb_check_var = pxa168fb_check_var,
553 .fb_set_par = pxa168fb_set_par,
554 .fb_setcolreg = pxa168fb_setcolreg,
555 .fb_blank = pxa168fb_blank,
556 .fb_pan_display = pxa168fb_pan_display,
557 .fb_fillrect = cfb_fillrect,
558 .fb_copyarea = cfb_copyarea,
559 .fb_imageblit = cfb_imageblit,
560};
561
562static int __init pxa168fb_init_mode(struct fb_info *info,
563 struct pxa168fb_mach_info *mi)
564{
565 struct pxa168fb_info *fbi = info->par;
566 struct fb_var_screeninfo *var = &info->var;
567 int ret = 0;
568 u32 total_w, total_h, refresh;
569 u64 div_result;
570 const struct fb_videomode *m;
571
572 /*
573 * Set default value
574 */
575 refresh = DEFAULT_REFRESH;
576
577 /* try to find best video mode. */
578 m = fb_find_best_mode(&info->var, &info->modelist);
579 if (m)
580 fb_videomode_to_var(&info->var, m);
581
582 /* Init settings. */
583 var->xres_virtual = var->xres;
584 var->yres_virtual = info->fix.smem_len /
585 (var->xres_virtual * (var->bits_per_pixel >> 3));
586 dev_dbg(fbi->dev, "pxa168fb: find best mode: res = %dx%d\n",
587 var->xres, var->yres);
588
589 /* correct pixclock. */
590 total_w = var->xres + var->left_margin + var->right_margin +
591 var->hsync_len;
592 total_h = var->yres + var->upper_margin + var->lower_margin +
593 var->vsync_len;
594
595 div_result = 1000000000000ll;
596 do_div(div_result, total_w * total_h * refresh);
597 var->pixclock = (u32)div_result;
598
599 return ret;
600}
601
602static int __init pxa168fb_probe(struct platform_device *pdev)
603{
604 struct pxa168fb_mach_info *mi;
605 struct fb_info *info = 0;
606 struct pxa168fb_info *fbi = 0;
607 struct resource *res;
608 struct clk *clk;
609 int irq, ret;
610
611 mi = pdev->dev.platform_data;
612 if (mi == NULL) {
613 dev_err(&pdev->dev, "no platform data defined\n");
614 return -EINVAL;
615 }
616
617 clk = clk_get(&pdev->dev, "LCDCLK");
618 if (IS_ERR(clk)) {
619 dev_err(&pdev->dev, "unable to get LCDCLK");
620 return PTR_ERR(clk);
621 }
622
623 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
624 if (res == NULL) {
625 dev_err(&pdev->dev, "no IO memory defined\n");
626 return -ENOENT;
627 }
628
629 irq = platform_get_irq(pdev, 0);
630 if (irq < 0) {
631 dev_err(&pdev->dev, "no IRQ defined\n");
632 return -ENOENT;
633 }
634
635 info = framebuffer_alloc(sizeof(struct pxa168fb_info), &pdev->dev);
636 if (info == NULL) {
637 clk_put(clk);
638 return -ENOMEM;
639 }
640
641 /* Initialize private data */
642 fbi = info->par;
643 fbi->info = info;
644 fbi->clk = clk;
645 fbi->dev = info->dev = &pdev->dev;
646 fbi->panel_rbswap = mi->panel_rbswap;
647 fbi->is_blanked = 0;
648 fbi->active = mi->active;
649
650 /*
651 * Initialise static fb parameters.
652 */
653 info->flags = FBINFO_DEFAULT | FBINFO_PARTIAL_PAN_OK |
654 FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN;
655 info->node = -1;
656 strlcpy(info->fix.id, mi->id, 16);
657 info->fix.type = FB_TYPE_PACKED_PIXELS;
658 info->fix.type_aux = 0;
659 info->fix.xpanstep = 0;
660 info->fix.ypanstep = 0;
661 info->fix.ywrapstep = 0;
662 info->fix.mmio_start = res->start;
663 info->fix.mmio_len = res->end - res->start + 1;
664 info->fix.accel = FB_ACCEL_NONE;
665 info->fbops = &pxa168fb_ops;
666 info->pseudo_palette = fbi->pseudo_palette;
667
668 /*
669 * Map LCD controller registers.
670 */
671 fbi->reg_base = ioremap_nocache(res->start, res->end - res->start);
672 if (fbi->reg_base == NULL) {
673 ret = -ENOMEM;
674 goto failed;
675 }
676
677 /*
678 * Allocate framebuffer memory.
679 */
680 info->fix.smem_len = PAGE_ALIGN(DEFAULT_FB_SIZE);
681
682 info->screen_base = dma_alloc_writecombine(fbi->dev, info->fix.smem_len,
683 &fbi->fb_start_dma, GFP_KERNEL);
684 if (info->screen_base == NULL) {
685 ret = -ENOMEM;
686 goto failed;
687 }
688
689 info->fix.smem_start = (unsigned long)fbi->fb_start_dma;
690
691 /*
692 * Set video mode according to platform data.
693 */
694 set_mode(fbi, &info->var, mi->modes, mi->pix_fmt, 1);
695
696 fb_videomode_to_modelist(mi->modes, mi->num_modes, &info->modelist);
697
698 /*
699 * init video mode data.
700 */
701 pxa168fb_init_mode(info, mi);
702
703 ret = pxa168fb_check_var(&info->var, info);
704 if (ret)
705 goto failed_free_fbmem;
706
707 /*
708 * Fill in sane defaults.
709 */
710 ret = pxa168fb_check_var(&info->var, info);
711 if (ret)
712 goto failed;
713
714 /*
715 * enable controller clock
716 */
717 clk_enable(fbi->clk);
718
719 pxa168fb_set_par(info);
720
721 /*
722 * Configure default register values.
723 */
724 writel(0, fbi->reg_base + LCD_SPU_BLANKCOLOR);
725 writel(mi->io_pin_allocation_mode, fbi->reg_base + SPU_IOPAD_CONTROL);
726 writel(0, fbi->reg_base + LCD_CFG_GRA_START_ADDR1);
727 writel(0, fbi->reg_base + LCD_SPU_GRA_OVSA_HPXL_VLN);
728 writel(0, fbi->reg_base + LCD_SPU_SRAM_PARA0);
729 writel(CFG_CSB_256x32(0x1)|CFG_CSB_256x24(0x1)|CFG_CSB_256x8(0x1),
730 fbi->reg_base + LCD_SPU_SRAM_PARA1);
731
732 /*
733 * Allocate color map.
734 */
735 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
736 ret = -ENOMEM;
737 goto failed_free_clk;
738 }
739
740 /*
741 * Register irq handler.
742 */
743 ret = request_irq(irq, pxa168fb_handle_irq, IRQF_SHARED,
744 info->fix.id, fbi);
745 if (ret < 0) {
746 dev_err(&pdev->dev, "unable to request IRQ\n");
747 ret = -ENXIO;
748 goto failed_free_cmap;
749 }
750
751 /*
752 * Enable GFX interrupt
753 */
754 writel(GRA_FRAME_IRQ0_ENA(0x1), fbi->reg_base + SPU_IRQ_ENA);
755
756 /*
757 * Register framebuffer.
758 */
759 ret = register_framebuffer(info);
760 if (ret < 0) {
761 dev_err(&pdev->dev, "Failed to register pxa168-fb: %d\n", ret);
762 ret = -ENXIO;
763 goto failed_free_irq;
764 }
765
766 platform_set_drvdata(pdev, fbi);
767 return 0;
768
769failed_free_irq:
770 free_irq(irq, fbi);
771failed_free_cmap:
772 fb_dealloc_cmap(&info->cmap);
773failed_free_clk:
774 clk_disable(fbi->clk);
775failed_free_fbmem:
776 dma_free_coherent(fbi->dev, info->fix.smem_len,
777 info->screen_base, fbi->fb_start_dma);
778failed:
779 kfree(info);
780 clk_put(clk);
781
782 dev_err(&pdev->dev, "frame buffer device init failed with %d\n", ret);
783 return ret;
784}
785
786static struct platform_driver pxa168fb_driver = {
787 .driver = {
788 .name = "pxa168-fb",
789 .owner = THIS_MODULE,
790 },
791 .probe = pxa168fb_probe,
792};
793
794static int __devinit pxa168fb_init(void)
795{
796 return platform_driver_register(&pxa168fb_driver);
797}
798module_init(pxa168fb_init);
799
800MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com> "
801 "Green Wan <gwan@marvell.com>");
802MODULE_DESCRIPTION("Framebuffer driver for PXA168/910");
803MODULE_LICENSE("GPL");
diff --git a/drivers/video/pxa168fb.h b/drivers/video/pxa168fb.h
new file mode 100644
index 000000000000..eee09279c524
--- /dev/null
+++ b/drivers/video/pxa168fb.h
@@ -0,0 +1,558 @@
1#ifndef __PXA168FB_H__
2#define __PXA168FB_H__
3
4/* ------------< LCD register >------------ */
5/* Video Frame 0&1 start address registers */
6#define LCD_SPU_DMA_START_ADDR_Y0 0x00C0
7#define LCD_SPU_DMA_START_ADDR_U0 0x00C4
8#define LCD_SPU_DMA_START_ADDR_V0 0x00C8
9#define LCD_CFG_DMA_START_ADDR_0 0x00CC /* Cmd address */
10#define LCD_SPU_DMA_START_ADDR_Y1 0x00D0
11#define LCD_SPU_DMA_START_ADDR_U1 0x00D4
12#define LCD_SPU_DMA_START_ADDR_V1 0x00D8
13#define LCD_CFG_DMA_START_ADDR_1 0x00DC /* Cmd address */
14
15/* YC & UV Pitch */
16#define LCD_SPU_DMA_PITCH_YC 0x00E0
17#define SPU_DMA_PITCH_C(c) ((c) << 16)
18#define SPU_DMA_PITCH_Y(y) (y)
19#define LCD_SPU_DMA_PITCH_UV 0x00E4
20#define SPU_DMA_PITCH_V(v) ((v) << 16)
21#define SPU_DMA_PITCH_U(u) (u)
22
23/* Video Starting Point on Screen Register */
24#define LCD_SPUT_DMA_OVSA_HPXL_VLN 0x00E8
25#define CFG_DMA_OVSA_VLN(y) ((y) << 16) /* 0~0xfff */
26#define CFG_DMA_OVSA_HPXL(x) (x) /* 0~0xfff */
27
28/* Video Size Register */
29#define LCD_SPU_DMA_HPXL_VLN 0x00EC
30#define CFG_DMA_VLN(y) ((y) << 16)
31#define CFG_DMA_HPXL(x) (x)
32
33/* Video Size After zooming Register */
34#define LCD_SPU_DZM_HPXL_VLN 0x00F0
35#define CFG_DZM_VLN(y) ((y) << 16)
36#define CFG_DZM_HPXL(x) (x)
37
38/* Graphic Frame 0&1 Starting Address Register */
39#define LCD_CFG_GRA_START_ADDR0 0x00F4
40#define LCD_CFG_GRA_START_ADDR1 0x00F8
41
42/* Graphic Frame Pitch */
43#define LCD_CFG_GRA_PITCH 0x00FC
44
45/* Graphic Starting Point on Screen Register */
46#define LCD_SPU_GRA_OVSA_HPXL_VLN 0x0100
47#define CFG_GRA_OVSA_VLN(y) ((y) << 16)
48#define CFG_GRA_OVSA_HPXL(x) (x)
49
50/* Graphic Size Register */
51#define LCD_SPU_GRA_HPXL_VLN 0x0104
52#define CFG_GRA_VLN(y) ((y) << 16)
53#define CFG_GRA_HPXL(x) (x)
54
55/* Graphic Size after Zooming Register */
56#define LCD_SPU_GZM_HPXL_VLN 0x0108
57#define CFG_GZM_VLN(y) ((y) << 16)
58#define CFG_GZM_HPXL(x) (x)
59
60/* HW Cursor Starting Point on Screen Register */
61#define LCD_SPU_HWC_OVSA_HPXL_VLN 0x010C
62#define CFG_HWC_OVSA_VLN(y) ((y) << 16)
63#define CFG_HWC_OVSA_HPXL(x) (x)
64
65/* HW Cursor Size */
66#define LCD_SPU_HWC_HPXL_VLN 0x0110
67#define CFG_HWC_VLN(y) ((y) << 16)
68#define CFG_HWC_HPXL(x) (x)
69
70/* Total Screen Size Register */
71#define LCD_SPUT_V_H_TOTAL 0x0114
72#define CFG_V_TOTAL(y) ((y) << 16)
73#define CFG_H_TOTAL(x) (x)
74
75/* Total Screen Active Size Register */
76#define LCD_SPU_V_H_ACTIVE 0x0118
77#define CFG_V_ACTIVE(y) ((y) << 16)
78#define CFG_H_ACTIVE(x) (x)
79
80/* Screen H&V Porch Register */
81#define LCD_SPU_H_PORCH 0x011C
82#define CFG_H_BACK_PORCH(b) ((b) << 16)
83#define CFG_H_FRONT_PORCH(f) (f)
84#define LCD_SPU_V_PORCH 0x0120
85#define CFG_V_BACK_PORCH(b) ((b) << 16)
86#define CFG_V_FRONT_PORCH(f) (f)
87
88/* Screen Blank Color Register */
89#define LCD_SPU_BLANKCOLOR 0x0124
90#define CFG_BLANKCOLOR_MASK 0x00FFFFFF
91#define CFG_BLANKCOLOR_R_MASK 0x000000FF
92#define CFG_BLANKCOLOR_G_MASK 0x0000FF00
93#define CFG_BLANKCOLOR_B_MASK 0x00FF0000
94
95/* HW Cursor Color 1&2 Register */
96#define LCD_SPU_ALPHA_COLOR1 0x0128
97#define CFG_HWC_COLOR1 0x00FFFFFF
98#define CFG_HWC_COLOR1_R(red) ((red) << 16)
99#define CFG_HWC_COLOR1_G(green) ((green) << 8)
100#define CFG_HWC_COLOR1_B(blue) (blue)
101#define CFG_HWC_COLOR1_R_MASK 0x000000FF
102#define CFG_HWC_COLOR1_G_MASK 0x0000FF00
103#define CFG_HWC_COLOR1_B_MASK 0x00FF0000
104#define LCD_SPU_ALPHA_COLOR2 0x012C
105#define CFG_HWC_COLOR2 0x00FFFFFF
106#define CFG_HWC_COLOR2_R_MASK 0x000000FF
107#define CFG_HWC_COLOR2_G_MASK 0x0000FF00
108#define CFG_HWC_COLOR2_B_MASK 0x00FF0000
109
110/* Video YUV Color Key Control */
111#define LCD_SPU_COLORKEY_Y 0x0130
112#define CFG_CKEY_Y2(y2) ((y2) << 24)
113#define CFG_CKEY_Y2_MASK 0xFF000000
114#define CFG_CKEY_Y1(y1) ((y1) << 16)
115#define CFG_CKEY_Y1_MASK 0x00FF0000
116#define CFG_CKEY_Y(y) ((y) << 8)
117#define CFG_CKEY_Y_MASK 0x0000FF00
118#define CFG_ALPHA_Y(y) (y)
119#define CFG_ALPHA_Y_MASK 0x000000FF
120#define LCD_SPU_COLORKEY_U 0x0134
121#define CFG_CKEY_U2(u2) ((u2) << 24)
122#define CFG_CKEY_U2_MASK 0xFF000000
123#define CFG_CKEY_U1(u1) ((u1) << 16)
124#define CFG_CKEY_U1_MASK 0x00FF0000
125#define CFG_CKEY_U(u) ((u) << 8)
126#define CFG_CKEY_U_MASK 0x0000FF00
127#define CFG_ALPHA_U(u) (u)
128#define CFG_ALPHA_U_MASK 0x000000FF
129#define LCD_SPU_COLORKEY_V 0x0138
130#define CFG_CKEY_V2(v2) ((v2) << 24)
131#define CFG_CKEY_V2_MASK 0xFF000000
132#define CFG_CKEY_V1(v1) ((v1) << 16)
133#define CFG_CKEY_V1_MASK 0x00FF0000
134#define CFG_CKEY_V(v) ((v) << 8)
135#define CFG_CKEY_V_MASK 0x0000FF00
136#define CFG_ALPHA_V(v) (v)
137#define CFG_ALPHA_V_MASK 0x000000FF
138
139/* SPI Read Data Register */
140#define LCD_SPU_SPI_RXDATA 0x0140
141
142/* Smart Panel Read Data Register */
143#define LCD_SPU_ISA_RSDATA 0x0144
144#define ISA_RXDATA_16BIT_1_DATA_MASK 0x000000FF
145#define ISA_RXDATA_16BIT_2_DATA_MASK 0x0000FF00
146#define ISA_RXDATA_16BIT_3_DATA_MASK 0x00FF0000
147#define ISA_RXDATA_16BIT_4_DATA_MASK 0xFF000000
148#define ISA_RXDATA_32BIT_1_DATA_MASK 0x00FFFFFF
149
150/* HWC SRAM Read Data Register */
151#define LCD_SPU_HWC_RDDAT 0x0158
152
153/* Gamma Table SRAM Read Data Register */
154#define LCD_SPU_GAMMA_RDDAT 0x015c
155#define CFG_GAMMA_RDDAT_MASK 0x000000FF
156
157/* Palette Table SRAM Read Data Register */
158#define LCD_SPU_PALETTE_RDDAT 0x0160
159#define CFG_PALETTE_RDDAT_MASK 0x00FFFFFF
160
161/* I/O Pads Input Read Only Register */
162#define LCD_SPU_IOPAD_IN 0x0178
163#define CFG_IOPAD_IN_MASK 0x0FFFFFFF
164
165/* Reserved Read Only Registers */
166#define LCD_CFG_RDREG5F 0x017C
167#define IRE_FRAME_CNT_MASK 0x000000C0
168#define IPE_FRAME_CNT_MASK 0x00000030
169#define GRA_FRAME_CNT_MASK 0x0000000C /* Graphic */
170#define DMA_FRAME_CNT_MASK 0x00000003 /* Video */
171
172/* SPI Control Register. */
173#define LCD_SPU_SPI_CTRL 0x0180
174#define CFG_SCLKCNT(div) ((div) << 24) /* 0xFF~0x2 */
175#define CFG_SCLKCNT_MASK 0xFF000000
176#define CFG_RXBITS(rx) ((rx) << 16) /* 0x1F~0x1 */
177#define CFG_RXBITS_MASK 0x00FF0000
178#define CFG_TXBITS(tx) ((tx) << 8) /* 0x1F~0x1 */
179#define CFG_TXBITS_MASK 0x0000FF00
180#define CFG_CLKINV(clk) ((clk) << 7)
181#define CFG_CLKINV_MASK 0x00000080
182#define CFG_KEEPXFER(transfer) ((transfer) << 6)
183#define CFG_KEEPXFER_MASK 0x00000040
184#define CFG_RXBITSTO0(rx) ((rx) << 5)
185#define CFG_RXBITSTO0_MASK 0x00000020
186#define CFG_TXBITSTO0(tx) ((tx) << 4)
187#define CFG_TXBITSTO0_MASK 0x00000010
188#define CFG_SPI_ENA(spi) ((spi) << 3)
189#define CFG_SPI_ENA_MASK 0x00000008
190#define CFG_SPI_SEL(spi) ((spi) << 2)
191#define CFG_SPI_SEL_MASK 0x00000004
192#define CFG_SPI_3W4WB(wire) ((wire) << 1)
193#define CFG_SPI_3W4WB_MASK 0x00000002
194#define CFG_SPI_START(start) (start)
195#define CFG_SPI_START_MASK 0x00000001
196
197/* SPI Tx Data Register */
198#define LCD_SPU_SPI_TXDATA 0x0184
199
200/*
201 1. Smart Pannel 8-bit Bus Control Register.
202 2. AHB Slave Path Data Port Register
203*/
204#define LCD_SPU_SMPN_CTRL 0x0188
205
206/* DMA Control 0 Register */
207#define LCD_SPU_DMA_CTRL0 0x0190
208#define CFG_NOBLENDING(nb) ((nb) << 31)
209#define CFG_NOBLENDING_MASK 0x80000000
210#define CFG_GAMMA_ENA(gn) ((gn) << 30)
211#define CFG_GAMMA_ENA_MASK 0x40000000
212#define CFG_CBSH_ENA(cn) ((cn) << 29)
213#define CFG_CBSH_ENA_MASK 0x20000000
214#define CFG_PALETTE_ENA(pn) ((pn) << 28)
215#define CFG_PALETTE_ENA_MASK 0x10000000
216#define CFG_ARBFAST_ENA(an) ((an) << 27)
217#define CFG_ARBFAST_ENA_MASK 0x08000000
218#define CFG_HWC_1BITMOD(mode) ((mode) << 26)
219#define CFG_HWC_1BITMOD_MASK 0x04000000
220#define CFG_HWC_1BITENA(mn) ((mn) << 25)
221#define CFG_HWC_1BITENA_MASK 0x02000000
222#define CFG_HWC_ENA(cn) ((cn) << 24)
223#define CFG_HWC_ENA_MASK 0x01000000
224#define CFG_DMAFORMAT(dmaformat) ((dmaformat) << 20)
225#define CFG_DMAFORMAT_MASK 0x00F00000
226#define CFG_GRAFORMAT(graformat) ((graformat) << 16)
227#define CFG_GRAFORMAT_MASK 0x000F0000
228/* for graphic part */
229#define CFG_GRA_FTOGGLE(toggle) ((toggle) << 15)
230#define CFG_GRA_FTOGGLE_MASK 0x00008000
231#define CFG_GRA_HSMOOTH(smooth) ((smooth) << 14)
232#define CFG_GRA_HSMOOTH_MASK 0x00004000
233#define CFG_GRA_TSTMODE(test) ((test) << 13)
234#define CFG_GRA_TSTMODE_MASK 0x00002000
235#define CFG_GRA_SWAPRB(swap) ((swap) << 12)
236#define CFG_GRA_SWAPRB_MASK 0x00001000
237#define CFG_GRA_SWAPUV(swap) ((swap) << 11)
238#define CFG_GRA_SWAPUV_MASK 0x00000800
239#define CFG_GRA_SWAPYU(swap) ((swap) << 10)
240#define CFG_GRA_SWAPYU_MASK 0x00000400
241#define CFG_YUV2RGB_GRA(cvrt) ((cvrt) << 9)
242#define CFG_YUV2RGB_GRA_MASK 0x00000200
243#define CFG_GRA_ENA(gra) ((gra) << 8)
244#define CFG_GRA_ENA_MASK 0x00000100
245/* for video part */
246#define CFG_DMA_FTOGGLE(toggle) ((toggle) << 7)
247#define CFG_DMA_FTOGGLE_MASK 0x00000080
248#define CFG_DMA_HSMOOTH(smooth) ((smooth) << 6)
249#define CFG_DMA_HSMOOTH_MASK 0x00000040
250#define CFG_DMA_TSTMODE(test) ((test) << 5)
251#define CFG_DMA_TSTMODE_MASK 0x00000020
252#define CFG_DMA_SWAPRB(swap) ((swap) << 4)
253#define CFG_DMA_SWAPRB_MASK 0x00000010
254#define CFG_DMA_SWAPUV(swap) ((swap) << 3)
255#define CFG_DMA_SWAPUV_MASK 0x00000008
256#define CFG_DMA_SWAPYU(swap) ((swap) << 2)
257#define CFG_DMA_SWAPYU_MASK 0x00000004
258#define CFG_DMA_SWAP_MASK 0x0000001C
259#define CFG_YUV2RGB_DMA(cvrt) ((cvrt) << 1)
260#define CFG_YUV2RGB_DMA_MASK 0x00000002
261#define CFG_DMA_ENA(video) (video)
262#define CFG_DMA_ENA_MASK 0x00000001
263
264/* DMA Control 1 Register */
265#define LCD_SPU_DMA_CTRL1 0x0194
266#define CFG_FRAME_TRIG(trig) ((trig) << 31)
267#define CFG_FRAME_TRIG_MASK 0x80000000
268#define CFG_VSYNC_TRIG(trig) ((trig) << 28)
269#define CFG_VSYNC_TRIG_MASK 0x70000000
270#define CFG_VSYNC_INV(inv) ((inv) << 27)
271#define CFG_VSYNC_INV_MASK 0x08000000
272#define CFG_COLOR_KEY_MODE(cmode) ((cmode) << 24)
273#define CFG_COLOR_KEY_MASK 0x07000000
274#define CFG_CARRY(carry) ((carry) << 23)
275#define CFG_CARRY_MASK 0x00800000
276#define CFG_LNBUF_ENA(lnbuf) ((lnbuf) << 22)
277#define CFG_LNBUF_ENA_MASK 0x00400000
278#define CFG_GATED_ENA(gated) ((gated) << 21)
279#define CFG_GATED_ENA_MASK 0x00200000
280#define CFG_PWRDN_ENA(power) ((power) << 20)
281#define CFG_PWRDN_ENA_MASK 0x00100000
282#define CFG_DSCALE(dscale) ((dscale) << 18)
283#define CFG_DSCALE_MASK 0x000C0000
284#define CFG_ALPHA_MODE(amode) ((amode) << 16)
285#define CFG_ALPHA_MODE_MASK 0x00030000
286#define CFG_ALPHA(alpha) ((alpha) << 8)
287#define CFG_ALPHA_MASK 0x0000FF00
288#define CFG_PXLCMD(pxlcmd) (pxlcmd)
289#define CFG_PXLCMD_MASK 0x000000FF
290
291/* SRAM Control Register */
292#define LCD_SPU_SRAM_CTRL 0x0198
293#define CFG_SRAM_INIT_WR_RD(mode) ((mode) << 14)
294#define CFG_SRAM_INIT_WR_RD_MASK 0x0000C000
295#define CFG_SRAM_ADDR_LCDID(id) ((id) << 8)
296#define CFG_SRAM_ADDR_LCDID_MASK 0x00000F00
297#define CFG_SRAM_ADDR(addr) (addr)
298#define CFG_SRAM_ADDR_MASK 0x000000FF
299
300/* SRAM Write Data Register */
301#define LCD_SPU_SRAM_WRDAT 0x019C
302
303/* SRAM RTC/WTC Control Register */
304#define LCD_SPU_SRAM_PARA0 0x01A0
305
306/* SRAM Power Down Control Register */
307#define LCD_SPU_SRAM_PARA1 0x01A4
308#define CFG_CSB_256x32(hwc) ((hwc) << 15) /* HWC */
309#define CFG_CSB_256x32_MASK 0x00008000
310#define CFG_CSB_256x24(palette) ((palette) << 14) /* Palette */
311#define CFG_CSB_256x24_MASK 0x00004000
312#define CFG_CSB_256x8(gamma) ((gamma) << 13) /* Gamma */
313#define CFG_CSB_256x8_MASK 0x00002000
314#define CFG_PDWN256x32(pdwn) ((pdwn) << 7) /* HWC */
315#define CFG_PDWN256x32_MASK 0x00000080
316#define CFG_PDWN256x24(pdwn) ((pdwn) << 6) /* Palette */
317#define CFG_PDWN256x24_MASK 0x00000040
318#define CFG_PDWN256x8(pdwn) ((pdwn) << 5) /* Gamma */
319#define CFG_PDWN256x8_MASK 0x00000020
320#define CFG_PDWN32x32(pdwn) ((pdwn) << 3)
321#define CFG_PDWN32x32_MASK 0x00000008
322#define CFG_PDWN16x66(pdwn) ((pdwn) << 2)
323#define CFG_PDWN16x66_MASK 0x00000004
324#define CFG_PDWN32x66(pdwn) ((pdwn) << 1)
325#define CFG_PDWN32x66_MASK 0x00000002
326#define CFG_PDWN64x66(pdwn) (pdwn)
327#define CFG_PDWN64x66_MASK 0x00000001
328
329/* Smart or Dumb Panel Clock Divider */
330#define LCD_CFG_SCLK_DIV 0x01A8
331#define SCLK_SOURCE_SELECT(src) ((src) << 31)
332#define SCLK_SOURCE_SELECT_MASK 0x80000000
333#define CLK_FRACDIV(frac) ((frac) << 16)
334#define CLK_FRACDIV_MASK 0x0FFF0000
335#define CLK_INT_DIV(div) (div)
336#define CLK_INT_DIV_MASK 0x0000FFFF
337
338/* Video Contrast Register */
339#define LCD_SPU_CONTRAST 0x01AC
340#define CFG_BRIGHTNESS(bright) ((bright) << 16)
341#define CFG_BRIGHTNESS_MASK 0xFFFF0000
342#define CFG_CONTRAST(contrast) (contrast)
343#define CFG_CONTRAST_MASK 0x0000FFFF
344
345/* Video Saturation Register */
346#define LCD_SPU_SATURATION 0x01B0
347#define CFG_C_MULTS(mult) ((mult) << 16)
348#define CFG_C_MULTS_MASK 0xFFFF0000
349#define CFG_SATURATION(sat) (sat)
350#define CFG_SATURATION_MASK 0x0000FFFF
351
352/* Video Hue Adjust Register */
353#define LCD_SPU_CBSH_HUE 0x01B4
354#define CFG_SIN0(sin0) ((sin0) << 16)
355#define CFG_SIN0_MASK 0xFFFF0000
356#define CFG_COS0(con0) (con0)
357#define CFG_COS0_MASK 0x0000FFFF
358
359/* Dump LCD Panel Control Register */
360#define LCD_SPU_DUMB_CTRL 0x01B8
361#define CFG_DUMBMODE(mode) ((mode) << 28)
362#define CFG_DUMBMODE_MASK 0xF0000000
363#define CFG_LCDGPIO_O(data) ((data) << 20)
364#define CFG_LCDGPIO_O_MASK 0x0FF00000
365#define CFG_LCDGPIO_ENA(gpio) ((gpio) << 12)
366#define CFG_LCDGPIO_ENA_MASK 0x000FF000
367#define CFG_BIAS_OUT(bias) ((bias) << 8)
368#define CFG_BIAS_OUT_MASK 0x00000100
369#define CFG_REVERSE_RGB(rRGB) ((rRGB) << 7)
370#define CFG_REVERSE_RGB_MASK 0x00000080
371#define CFG_INV_COMPBLANK(blank) ((blank) << 6)
372#define CFG_INV_COMPBLANK_MASK 0x00000040
373#define CFG_INV_COMPSYNC(sync) ((sync) << 5)
374#define CFG_INV_COMPSYNC_MASK 0x00000020
375#define CFG_INV_HENA(hena) ((hena) << 4)
376#define CFG_INV_HENA_MASK 0x00000010
377#define CFG_INV_VSYNC(vsync) ((vsync) << 3)
378#define CFG_INV_VSYNC_MASK 0x00000008
379#define CFG_INV_HSYNC(hsync) ((hsync) << 2)
380#define CFG_INV_HSYNC_MASK 0x00000004
381#define CFG_INV_PCLK(pclk) ((pclk) << 1)
382#define CFG_INV_PCLK_MASK 0x00000002
383#define CFG_DUMB_ENA(dumb) (dumb)
384#define CFG_DUMB_ENA_MASK 0x00000001
385
386/* LCD I/O Pads Control Register */
387#define SPU_IOPAD_CONTROL 0x01BC
388#define CFG_GRA_VM_ENA(vm) ((vm) << 15) /* gfx */
389#define CFG_GRA_VM_ENA_MASK 0x00008000
390#define CFG_DMA_VM_ENA(vm) ((vm) << 13) /* video */
391#define CFG_DMA_VM_ENA_MASK 0x00002000
392#define CFG_CMD_VM_ENA(vm) ((vm) << 13)
393#define CFG_CMD_VM_ENA_MASK 0x00000800
394#define CFG_CSC(csc) ((csc) << 8) /* csc */
395#define CFG_CSC_MASK 0x00000300
396#define CFG_AXICTRL(axi) ((axi) << 4)
397#define CFG_AXICTRL_MASK 0x000000F0
398#define CFG_IOPADMODE(iopad) (iopad)
399#define CFG_IOPADMODE_MASK 0x0000000F
400
401/* LCD Interrupt Control Register */
402#define SPU_IRQ_ENA 0x01C0
403#define DMA_FRAME_IRQ0_ENA(irq) ((irq) << 31)
404#define DMA_FRAME_IRQ0_ENA_MASK 0x80000000
405#define DMA_FRAME_IRQ1_ENA(irq) ((irq) << 30)
406#define DMA_FRAME_IRQ1_ENA_MASK 0x40000000
407#define DMA_FF_UNDERFLOW_ENA(ff) ((ff) << 29)
408#define DMA_FF_UNDERFLOW_ENA_MASK 0x20000000
409#define GRA_FRAME_IRQ0_ENA(irq) ((irq) << 27)
410#define GRA_FRAME_IRQ0_ENA_MASK 0x08000000
411#define GRA_FRAME_IRQ1_ENA(irq) ((irq) << 26)
412#define GRA_FRAME_IRQ1_ENA_MASK 0x04000000
413#define GRA_FF_UNDERFLOW_ENA(ff) ((ff) << 25)
414#define GRA_FF_UNDERFLOW_ENA_MASK 0x02000000
415#define VSYNC_IRQ_ENA(vsync_irq) ((vsync_irq) << 23)
416#define VSYNC_IRQ_ENA_MASK 0x00800000
417#define DUMB_FRAMEDONE_ENA(fdone) ((fdone) << 22)
418#define DUMB_FRAMEDONE_ENA_MASK 0x00400000
419#define TWC_FRAMEDONE_ENA(fdone) ((fdone) << 21)
420#define TWC_FRAMEDONE_ENA_MASK 0x00200000
421#define HWC_FRAMEDONE_ENA(fdone) ((fdone) << 20)
422#define HWC_FRAMEDONE_ENA_MASK 0x00100000
423#define SLV_IRQ_ENA(irq) ((irq) << 19)
424#define SLV_IRQ_ENA_MASK 0x00080000
425#define SPI_IRQ_ENA(irq) ((irq) << 18)
426#define SPI_IRQ_ENA_MASK 0x00040000
427#define PWRDN_IRQ_ENA(irq) ((irq) << 17)
428#define PWRDN_IRQ_ENA_MASK 0x00020000
429#define ERR_IRQ_ENA(irq) ((irq) << 16)
430#define ERR_IRQ_ENA_MASK 0x00010000
431#define CLEAN_SPU_IRQ_ISR(irq) (irq)
432#define CLEAN_SPU_IRQ_ISR_MASK 0x0000FFFF
433
434/* LCD Interrupt Status Register */
435#define SPU_IRQ_ISR 0x01C4
436#define DMA_FRAME_IRQ0(irq) ((irq) << 31)
437#define DMA_FRAME_IRQ0_MASK 0x80000000
438#define DMA_FRAME_IRQ1(irq) ((irq) << 30)
439#define DMA_FRAME_IRQ1_MASK 0x40000000
440#define DMA_FF_UNDERFLOW(ff) ((ff) << 29)
441#define DMA_FF_UNDERFLOW_MASK 0x20000000
442#define GRA_FRAME_IRQ0(irq) ((irq) << 27)
443#define GRA_FRAME_IRQ0_MASK 0x08000000
444#define GRA_FRAME_IRQ1(irq) ((irq) << 26)
445#define GRA_FRAME_IRQ1_MASK 0x04000000
446#define GRA_FF_UNDERFLOW(ff) ((ff) << 25)
447#define GRA_FF_UNDERFLOW_MASK 0x02000000
448#define VSYNC_IRQ(vsync_irq) ((vsync_irq) << 23)
449#define VSYNC_IRQ_MASK 0x00800000
450#define DUMB_FRAMEDONE(fdone) ((fdone) << 22)
451#define DUMB_FRAMEDONE_MASK 0x00400000
452#define TWC_FRAMEDONE(fdone) ((fdone) << 21)
453#define TWC_FRAMEDONE_MASK 0x00200000
454#define HWC_FRAMEDONE(fdone) ((fdone) << 20)
455#define HWC_FRAMEDONE_MASK 0x00100000
456#define SLV_IRQ(irq) ((irq) << 19)
457#define SLV_IRQ_MASK 0x00080000
458#define SPI_IRQ(irq) ((irq) << 18)
459#define SPI_IRQ_MASK 0x00040000
460#define PWRDN_IRQ(irq) ((irq) << 17)
461#define PWRDN_IRQ_MASK 0x00020000
462#define ERR_IRQ(irq) ((irq) << 16)
463#define ERR_IRQ_MASK 0x00010000
464/* read-only */
465#define DMA_FRAME_IRQ0_LEVEL_MASK 0x00008000
466#define DMA_FRAME_IRQ1_LEVEL_MASK 0x00004000
467#define DMA_FRAME_CNT_ISR_MASK 0x00003000
468#define GRA_FRAME_IRQ0_LEVEL_MASK 0x00000800
469#define GRA_FRAME_IRQ1_LEVEL_MASK 0x00000400
470#define GRA_FRAME_CNT_ISR_MASK 0x00000300
471#define VSYNC_IRQ_LEVEL_MASK 0x00000080
472#define DUMB_FRAMEDONE_LEVEL_MASK 0x00000040
473#define TWC_FRAMEDONE_LEVEL_MASK 0x00000020
474#define HWC_FRAMEDONE_LEVEL_MASK 0x00000010
475#define SLV_FF_EMPTY_MASK 0x00000008
476#define DMA_FF_ALLEMPTY_MASK 0x00000004
477#define GRA_FF_ALLEMPTY_MASK 0x00000002
478#define PWRDN_IRQ_LEVEL_MASK 0x00000001
479
480
481/*
482 * defined Video Memory Color format for DMA control 0 register
483 * DMA0 bit[23:20]
484 */
485#define VMODE_RGB565 0x0
486#define VMODE_RGB1555 0x1
487#define VMODE_RGB888PACKED 0x2
488#define VMODE_RGB888UNPACKED 0x3
489#define VMODE_RGBA888 0x4
490#define VMODE_YUV422PACKED 0x5
491#define VMODE_YUV422PLANAR 0x6
492#define VMODE_YUV420PLANAR 0x7
493#define VMODE_SMPNCMD 0x8
494#define VMODE_PALETTE4BIT 0x9
495#define VMODE_PALETTE8BIT 0xa
496#define VMODE_RESERVED 0xb
497
498/*
499 * defined Graphic Memory Color format for DMA control 0 register
500 * DMA0 bit[19:16]
501 */
502#define GMODE_RGB565 0x0
503#define GMODE_RGB1555 0x1
504#define GMODE_RGB888PACKED 0x2
505#define GMODE_RGB888UNPACKED 0x3
506#define GMODE_RGBA888 0x4
507#define GMODE_YUV422PACKED 0x5
508#define GMODE_YUV422PLANAR 0x6
509#define GMODE_YUV420PLANAR 0x7
510#define GMODE_SMPNCMD 0x8
511#define GMODE_PALETTE4BIT 0x9
512#define GMODE_PALETTE8BIT 0xa
513#define GMODE_RESERVED 0xb
514
515/*
516 * define for DMA control 1 register
517 */
518#define DMA1_FRAME_TRIG 31 /* bit location */
519#define DMA1_VSYNC_MODE 28
520#define DMA1_VSYNC_INV 27
521#define DMA1_CKEY 24
522#define DMA1_CARRY 23
523#define DMA1_LNBUF_ENA 22
524#define DMA1_GATED_ENA 21
525#define DMA1_PWRDN_ENA 20
526#define DMA1_DSCALE 18
527#define DMA1_ALPHA_MODE 16
528#define DMA1_ALPHA 08
529#define DMA1_PXLCMD 00
530
531/*
532 * defined for Configure Dumb Mode
533 * DUMB LCD Panel bit[31:28]
534 */
535#define DUMB16_RGB565_0 0x0
536#define DUMB16_RGB565_1 0x1
537#define DUMB18_RGB666_0 0x2
538#define DUMB18_RGB666_1 0x3
539#define DUMB12_RGB444_0 0x4
540#define DUMB12_RGB444_1 0x5
541#define DUMB24_RGB888_0 0x6
542#define DUMB_BLANK 0x7
543
544/*
545 * defined for Configure I/O Pin Allocation Mode
546 * LCD LCD I/O Pads control register bit[3:0]
547 */
548#define IOPAD_DUMB24 0x0
549#define IOPAD_DUMB18SPI 0x1
550#define IOPAD_DUMB18GPIO 0x2
551#define IOPAD_DUMB16SPI 0x3
552#define IOPAD_DUMB16GPIO 0x4
553#define IOPAD_DUMB12 0x5
554#define IOPAD_SMART18SPI 0x6
555#define IOPAD_SMART16SPI 0x7
556#define IOPAD_SMART8BOTH 0x8
557
558#endif /* __PXA168FB_H__ */
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig
index 9adbb4f90479..fd2c7bd9dfbe 100644
--- a/drivers/w1/Kconfig
+++ b/drivers/w1/Kconfig
@@ -8,7 +8,7 @@ menuconfig W1
8 If you want W1 support, you should say Y here. 8 If you want W1 support, you should say Y here.
9 9
10 This W1 support can also be built as a module. If so, the module 10 This W1 support can also be built as a module. If so, the module
11 will be called wire.ko. 11 will be called wire.
12 12
13if W1 13if W1
14 14
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig
index 96d2f8e4c275..3195fb8b7d9a 100644
--- a/drivers/w1/masters/Kconfig
+++ b/drivers/w1/masters/Kconfig
@@ -12,7 +12,7 @@ config W1_MASTER_MATROX
12 using Matrox's G400 GPIO pins. 12 using Matrox's G400 GPIO pins.
13 13
14 This support is also available as a module. If so, the module 14 This support is also available as a module. If so, the module
15 will be called matrox_w1.ko. 15 will be called matrox_w1.
16 16
17config W1_MASTER_DS2490 17config W1_MASTER_DS2490
18 tristate "DS2490 USB <-> W1 transport layer for 1-wire" 18 tristate "DS2490 USB <-> W1 transport layer for 1-wire"
@@ -22,7 +22,7 @@ config W1_MASTER_DS2490
22 for example DS9490*. 22 for example DS9490*.
23 23
24 This support is also available as a module. If so, the module 24 This support is also available as a module. If so, the module
25 will be called ds2490.ko. 25 will be called ds2490.
26 26
27config W1_MASTER_DS2482 27config W1_MASTER_DS2482
28 tristate "Maxim DS2482 I2C to 1-Wire bridge" 28 tristate "Maxim DS2482 I2C to 1-Wire bridge"
@@ -56,7 +56,7 @@ config W1_MASTER_GPIO
56 GPIO pins. This driver uses the GPIO API to control the wire. 56 GPIO pins. This driver uses the GPIO API to control the wire.
57 57
58 This support is also available as a module. If so, the module 58 This support is also available as a module. If so, the module
59 will be called w1-gpio.ko. 59 will be called w1-gpio.
60 60
61config HDQ_MASTER_OMAP 61config HDQ_MASTER_OMAP
62 tristate "OMAP HDQ driver" 62 tristate "OMAP HDQ driver"
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 5eb8f21da82e..b166f2852a64 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -231,14 +231,14 @@ config DAVINCI_WATCHDOG
231 NOTE: once enabled, this timer cannot be disabled. 231 NOTE: once enabled, this timer cannot be disabled.
232 Say N if you are unsure. 232 Say N if you are unsure.
233 233
234config ORION5X_WATCHDOG 234config ORION_WATCHDOG
235 tristate "Orion5x watchdog" 235 tristate "Orion watchdog"
236 depends on ARCH_ORION5X 236 depends on ARCH_ORION5X || ARCH_KIRKWOOD
237 help 237 help
238 Say Y here if to include support for the watchdog timer 238 Say Y here if to include support for the watchdog timer
239 in the Orion5x ARM SoCs. 239 in the Marvell Orion5x and Kirkwood ARM SoCs.
240 To compile this driver as a module, choose M here: the 240 To compile this driver as a module, choose M here: the
241 module will be called orion5x_wdt. 241 module will be called orion_wdt.
242 242
243# AVR32 Architecture 243# AVR32 Architecture
244 244
@@ -531,7 +531,7 @@ config SBC8360_WDT
531 Board Computer produced by Axiomtek Co., Ltd. (www.axiomtek.com). 531 Board Computer produced by Axiomtek Co., Ltd. (www.axiomtek.com).
532 532
533 To compile this driver as a module, choose M here: the 533 To compile this driver as a module, choose M here: the
534 module will be called sbc8360.ko. 534 module will be called sbc8360.
535 535
536 Most people will say N. 536 Most people will say N.
537 537
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 7f8c56b14f58..c3afa14d5be1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -40,7 +40,7 @@ obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
40obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o 40obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
41obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o 41obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o
42obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o 42obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o
43obj-$(CONFIG_ORION5X_WATCHDOG) += orion5x_wdt.o 43obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o
44 44
45# AVR32 Architecture 45# AVR32 Architecture
46obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o 46obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/iop_wdt.c b/drivers/watchdog/iop_wdt.c
index 96eb2cbe5874..0c9059676690 100644
--- a/drivers/watchdog/iop_wdt.c
+++ b/drivers/watchdog/iop_wdt.c
@@ -192,7 +192,7 @@ static int iop_wdt_release(struct inode *inode, struct file *file)
192 if (test_bit(WDT_ENABLED, &wdt_status)) 192 if (test_bit(WDT_ENABLED, &wdt_status))
193 state = wdt_disable(); 193 state = wdt_disable();
194 194
195 /* if the timer is not disbaled reload and notify that we are still 195 /* if the timer is not disabled reload and notify that we are still
196 * going down 196 * going down
197 */ 197 */
198 if (state != 0) { 198 if (state != 0) {
diff --git a/drivers/watchdog/orion5x_wdt.c b/drivers/watchdog/orion_wdt.c
index 2cde568e4fb0..2d9fb96a9ee9 100644
--- a/drivers/watchdog/orion5x_wdt.c
+++ b/drivers/watchdog/orion_wdt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/watchdog/orion5x_wdt.c 2 * drivers/watchdog/orion_wdt.c
3 * 3 *
4 * Watchdog driver for Orion5x processors 4 * Watchdog driver for Orion/Kirkwood processors
5 * 5 *
6 * Author: Sylver Bruneau <sylver.bruneau@googlemail.com> 6 * Author: Sylver Bruneau <sylver.bruneau@googlemail.com>
7 * 7 *
@@ -23,7 +23,7 @@
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <mach/bridge-regs.h> 25#include <mach/bridge-regs.h>
26#include <plat/orion5x_wdt.h> 26#include <plat/orion_wdt.h>
27 27
28/* 28/*
29 * Watchdog timer block registers. 29 * Watchdog timer block registers.
@@ -43,7 +43,7 @@ static unsigned int wdt_tclk;
43static unsigned long wdt_status; 43static unsigned long wdt_status;
44static spinlock_t wdt_lock; 44static spinlock_t wdt_lock;
45 45
46static void orion5x_wdt_ping(void) 46static void orion_wdt_ping(void)
47{ 47{
48 spin_lock(&wdt_lock); 48 spin_lock(&wdt_lock);
49 49
@@ -53,7 +53,7 @@ static void orion5x_wdt_ping(void)
53 spin_unlock(&wdt_lock); 53 spin_unlock(&wdt_lock);
54} 54}
55 55
56static void orion5x_wdt_enable(void) 56static void orion_wdt_enable(void)
57{ 57{
58 u32 reg; 58 u32 reg;
59 59
@@ -73,23 +73,23 @@ static void orion5x_wdt_enable(void)
73 writel(reg, TIMER_CTRL); 73 writel(reg, TIMER_CTRL);
74 74
75 /* Enable reset on watchdog */ 75 /* Enable reset on watchdog */
76 reg = readl(CPU_RESET_MASK); 76 reg = readl(RSTOUTn_MASK);
77 reg |= WDT_RESET; 77 reg |= WDT_RESET_OUT_EN;
78 writel(reg, CPU_RESET_MASK); 78 writel(reg, RSTOUTn_MASK);
79 79
80 spin_unlock(&wdt_lock); 80 spin_unlock(&wdt_lock);
81} 81}
82 82
83static void orion5x_wdt_disable(void) 83static void orion_wdt_disable(void)
84{ 84{
85 u32 reg; 85 u32 reg;
86 86
87 spin_lock(&wdt_lock); 87 spin_lock(&wdt_lock);
88 88
89 /* Disable reset on watchdog */ 89 /* Disable reset on watchdog */
90 reg = readl(CPU_RESET_MASK); 90 reg = readl(RSTOUTn_MASK);
91 reg &= ~WDT_RESET; 91 reg &= ~WDT_RESET_OUT_EN;
92 writel(reg, CPU_RESET_MASK); 92 writel(reg, RSTOUTn_MASK);
93 93
94 /* Disable watchdog timer */ 94 /* Disable watchdog timer */
95 reg = readl(TIMER_CTRL); 95 reg = readl(TIMER_CTRL);
@@ -99,7 +99,7 @@ static void orion5x_wdt_disable(void)
99 spin_unlock(&wdt_lock); 99 spin_unlock(&wdt_lock);
100} 100}
101 101
102static int orion5x_wdt_get_timeleft(int *time_left) 102static int orion_wdt_get_timeleft(int *time_left)
103{ 103{
104 spin_lock(&wdt_lock); 104 spin_lock(&wdt_lock);
105 *time_left = readl(WDT_VAL) / wdt_tclk; 105 *time_left = readl(WDT_VAL) / wdt_tclk;
@@ -107,16 +107,16 @@ static int orion5x_wdt_get_timeleft(int *time_left)
107 return 0; 107 return 0;
108} 108}
109 109
110static int orion5x_wdt_open(struct inode *inode, struct file *file) 110static int orion_wdt_open(struct inode *inode, struct file *file)
111{ 111{
112 if (test_and_set_bit(WDT_IN_USE, &wdt_status)) 112 if (test_and_set_bit(WDT_IN_USE, &wdt_status))
113 return -EBUSY; 113 return -EBUSY;
114 clear_bit(WDT_OK_TO_CLOSE, &wdt_status); 114 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
115 orion5x_wdt_enable(); 115 orion_wdt_enable();
116 return nonseekable_open(inode, file); 116 return nonseekable_open(inode, file);
117} 117}
118 118
119static ssize_t orion5x_wdt_write(struct file *file, const char *data, 119static ssize_t orion_wdt_write(struct file *file, const char *data,
120 size_t len, loff_t *ppos) 120 size_t len, loff_t *ppos)
121{ 121{
122 if (len) { 122 if (len) {
@@ -133,18 +133,18 @@ static ssize_t orion5x_wdt_write(struct file *file, const char *data,
133 set_bit(WDT_OK_TO_CLOSE, &wdt_status); 133 set_bit(WDT_OK_TO_CLOSE, &wdt_status);
134 } 134 }
135 } 135 }
136 orion5x_wdt_ping(); 136 orion_wdt_ping();
137 } 137 }
138 return len; 138 return len;
139} 139}
140 140
141static int orion5x_wdt_settimeout(int new_time) 141static int orion_wdt_settimeout(int new_time)
142{ 142{
143 if ((new_time <= 0) || (new_time > wdt_max_duration)) 143 if ((new_time <= 0) || (new_time > wdt_max_duration))
144 return -EINVAL; 144 return -EINVAL;
145 145
146 /* Set new watchdog time to be used when 146 /* Set new watchdog time to be used when
147 * orion5x_wdt_enable() or orion5x_wdt_ping() is called. */ 147 * orion_wdt_enable() or orion_wdt_ping() is called. */
148 heartbeat = new_time; 148 heartbeat = new_time;
149 return 0; 149 return 0;
150} 150}
@@ -152,10 +152,10 @@ static int orion5x_wdt_settimeout(int new_time)
152static const struct watchdog_info ident = { 152static const struct watchdog_info ident = {
153 .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | 153 .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT |
154 WDIOF_KEEPALIVEPING, 154 WDIOF_KEEPALIVEPING,
155 .identity = "Orion5x Watchdog", 155 .identity = "Orion Watchdog",
156}; 156};
157 157
158static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, 158static long orion_wdt_ioctl(struct file *file, unsigned int cmd,
159 unsigned long arg) 159 unsigned long arg)
160{ 160{
161 int ret = -ENOTTY; 161 int ret = -ENOTTY;
@@ -173,7 +173,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
173 break; 173 break;
174 174
175 case WDIOC_KEEPALIVE: 175 case WDIOC_KEEPALIVE:
176 orion5x_wdt_ping(); 176 orion_wdt_ping();
177 ret = 0; 177 ret = 0;
178 break; 178 break;
179 179
@@ -182,11 +182,11 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
182 if (ret) 182 if (ret)
183 break; 183 break;
184 184
185 if (orion5x_wdt_settimeout(time)) { 185 if (orion_wdt_settimeout(time)) {
186 ret = -EINVAL; 186 ret = -EINVAL;
187 break; 187 break;
188 } 188 }
189 orion5x_wdt_ping(); 189 orion_wdt_ping();
190 /* Fall through */ 190 /* Fall through */
191 191
192 case WDIOC_GETTIMEOUT: 192 case WDIOC_GETTIMEOUT:
@@ -194,7 +194,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
194 break; 194 break;
195 195
196 case WDIOC_GETTIMELEFT: 196 case WDIOC_GETTIMELEFT:
197 if (orion5x_wdt_get_timeleft(&time)) { 197 if (orion_wdt_get_timeleft(&time)) {
198 ret = -EINVAL; 198 ret = -EINVAL;
199 break; 199 break;
200 } 200 }
@@ -204,10 +204,10 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
204 return ret; 204 return ret;
205} 205}
206 206
207static int orion5x_wdt_release(struct inode *inode, struct file *file) 207static int orion_wdt_release(struct inode *inode, struct file *file)
208{ 208{
209 if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) 209 if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
210 orion5x_wdt_disable(); 210 orion_wdt_disable();
211 else 211 else
212 printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " 212 printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
213 "timer will not stop\n"); 213 "timer will not stop\n");
@@ -218,98 +218,98 @@ static int orion5x_wdt_release(struct inode *inode, struct file *file)
218} 218}
219 219
220 220
221static const struct file_operations orion5x_wdt_fops = { 221static const struct file_operations orion_wdt_fops = {
222 .owner = THIS_MODULE, 222 .owner = THIS_MODULE,
223 .llseek = no_llseek, 223 .llseek = no_llseek,
224 .write = orion5x_wdt_write, 224 .write = orion_wdt_write,
225 .unlocked_ioctl = orion5x_wdt_ioctl, 225 .unlocked_ioctl = orion_wdt_ioctl,
226 .open = orion5x_wdt_open, 226 .open = orion_wdt_open,
227 .release = orion5x_wdt_release, 227 .release = orion_wdt_release,
228}; 228};
229 229
230static struct miscdevice orion5x_wdt_miscdev = { 230static struct miscdevice orion_wdt_miscdev = {
231 .minor = WATCHDOG_MINOR, 231 .minor = WATCHDOG_MINOR,
232 .name = "watchdog", 232 .name = "watchdog",
233 .fops = &orion5x_wdt_fops, 233 .fops = &orion_wdt_fops,
234}; 234};
235 235
236static int __devinit orion5x_wdt_probe(struct platform_device *pdev) 236static int __devinit orion_wdt_probe(struct platform_device *pdev)
237{ 237{
238 struct orion5x_wdt_platform_data *pdata = pdev->dev.platform_data; 238 struct orion_wdt_platform_data *pdata = pdev->dev.platform_data;
239 int ret; 239 int ret;
240 240
241 if (pdata) { 241 if (pdata) {
242 wdt_tclk = pdata->tclk; 242 wdt_tclk = pdata->tclk;
243 } else { 243 } else {
244 printk(KERN_ERR "Orion5x Watchdog misses platform data\n"); 244 printk(KERN_ERR "Orion Watchdog misses platform data\n");
245 return -ENODEV; 245 return -ENODEV;
246 } 246 }
247 247
248 if (orion5x_wdt_miscdev.parent) 248 if (orion_wdt_miscdev.parent)
249 return -EBUSY; 249 return -EBUSY;
250 orion5x_wdt_miscdev.parent = &pdev->dev; 250 orion_wdt_miscdev.parent = &pdev->dev;
251 251
252 wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk; 252 wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk;
253 if (orion5x_wdt_settimeout(heartbeat)) 253 if (orion_wdt_settimeout(heartbeat))
254 heartbeat = wdt_max_duration; 254 heartbeat = wdt_max_duration;
255 255
256 ret = misc_register(&orion5x_wdt_miscdev); 256 ret = misc_register(&orion_wdt_miscdev);
257 if (ret) 257 if (ret)
258 return ret; 258 return ret;
259 259
260 printk(KERN_INFO "Orion5x Watchdog Timer: Initial timeout %d sec%s\n", 260 printk(KERN_INFO "Orion Watchdog Timer: Initial timeout %d sec%s\n",
261 heartbeat, nowayout ? ", nowayout" : ""); 261 heartbeat, nowayout ? ", nowayout" : "");
262 return 0; 262 return 0;
263} 263}
264 264
265static int __devexit orion5x_wdt_remove(struct platform_device *pdev) 265static int __devexit orion_wdt_remove(struct platform_device *pdev)
266{ 266{
267 int ret; 267 int ret;
268 268
269 if (test_bit(WDT_IN_USE, &wdt_status)) { 269 if (test_bit(WDT_IN_USE, &wdt_status)) {
270 orion5x_wdt_disable(); 270 orion_wdt_disable();
271 clear_bit(WDT_IN_USE, &wdt_status); 271 clear_bit(WDT_IN_USE, &wdt_status);
272 } 272 }
273 273
274 ret = misc_deregister(&orion5x_wdt_miscdev); 274 ret = misc_deregister(&orion_wdt_miscdev);
275 if (!ret) 275 if (!ret)
276 orion5x_wdt_miscdev.parent = NULL; 276 orion_wdt_miscdev.parent = NULL;
277 277
278 return ret; 278 return ret;
279} 279}
280 280
281static void orion5x_wdt_shutdown(struct platform_device *pdev) 281static void orion_wdt_shutdown(struct platform_device *pdev)
282{ 282{
283 if (test_bit(WDT_IN_USE, &wdt_status)) 283 if (test_bit(WDT_IN_USE, &wdt_status))
284 orion5x_wdt_disable(); 284 orion_wdt_disable();
285} 285}
286 286
287static struct platform_driver orion5x_wdt_driver = { 287static struct platform_driver orion_wdt_driver = {
288 .probe = orion5x_wdt_probe, 288 .probe = orion_wdt_probe,
289 .remove = __devexit_p(orion5x_wdt_remove), 289 .remove = __devexit_p(orion_wdt_remove),
290 .shutdown = orion5x_wdt_shutdown, 290 .shutdown = orion_wdt_shutdown,
291 .driver = { 291 .driver = {
292 .owner = THIS_MODULE, 292 .owner = THIS_MODULE,
293 .name = "orion5x_wdt", 293 .name = "orion_wdt",
294 }, 294 },
295}; 295};
296 296
297static int __init orion5x_wdt_init(void) 297static int __init orion_wdt_init(void)
298{ 298{
299 spin_lock_init(&wdt_lock); 299 spin_lock_init(&wdt_lock);
300 return platform_driver_register(&orion5x_wdt_driver); 300 return platform_driver_register(&orion_wdt_driver);
301} 301}
302 302
303static void __exit orion5x_wdt_exit(void) 303static void __exit orion_wdt_exit(void)
304{ 304{
305 platform_driver_unregister(&orion5x_wdt_driver); 305 platform_driver_unregister(&orion_wdt_driver);
306} 306}
307 307
308module_init(orion5x_wdt_init); 308module_init(orion_wdt_init);
309module_exit(orion5x_wdt_exit); 309module_exit(orion_wdt_exit);
310 310
311MODULE_AUTHOR("Sylver Bruneau <sylver.bruneau@googlemail.com>"); 311MODULE_AUTHOR("Sylver Bruneau <sylver.bruneau@googlemail.com>");
312MODULE_DESCRIPTION("Orion5x Processor Watchdog"); 312MODULE_DESCRIPTION("Orion Processor Watchdog");
313 313
314module_param(heartbeat, int, 0); 314module_param(heartbeat, int, 0);
315MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds"); 315MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds");